From 8b7d8191679ec7b79a9df939d49e9e9ae8150222 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 2 Jul 2018 23:44:59 +0200 Subject: [PATCH 0001/3904] add travis CI --- .travis.yml | 82 ----------------------------------------------------- 1 file changed, 82 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac331dcf9..250756396 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -<<<<<<< HEAD language: cpp compiler: @@ -22,84 +21,3 @@ notifications: - "Alt Message : %{repository_slug} - (%{commit} - %{author}): %{message}, Build Time: %{duration}" - "Change view : %{compare_url}" - "Build details : %{build_url}" -======= -# errata: -# - A travis bug causes caches to trample eachother when using the same -# compiler key (which we don't use anyway). This is worked around for now by -# replacing the "compilers" with a build name prefixed by the no-op ":" -# command. See: https://github.com/travis-ci/travis-ci/issues/4393 -# - sudo/dist/group are set so as to get Blue Box VMs, necessary for [loopback] -# IPv6 support - -sudo: required -dist: precise -group: legacy - -os: linux -language: cpp -compiler: gcc -env: - global: - - MAKEJOBS=-j3 - - RUN_TESTS=false - - BOOST_TEST_RANDOM=1$TRAVIS_BUILD_ID - - CCACHE_SIZE=100M - - CCACHE_TEMPDIR=/tmp/.ccache-temp - - CCACHE_COMPRESS=1 - - BASE_OUTDIR=$TRAVIS_BUILD_DIR/out - - SDK_URL=https://bitcoincore.org/depends-sources/sdks - - PYTHON_DEBUG=1 - - WINEDEBUG=fixme-all -cache: - apt: true - directories: - - depends/built - - depends/sdk-sources - - $HOME/.ccache -matrix: - fast_finish: true - include: - - compiler: ": ARM" - env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="" GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" - - compiler: ": Win32" - env: HOST=i686-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2" - - compiler: ": 32-bit + dash" - env: HOST=i686-pc-linux-gnu PACKAGES="g++-multilib bc python-zmq" PPA="ppa:chris-lea/zeromq" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash" - - compiler: ": Win64" - env: HOST=x86_64-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2" - - compiler: ": bitcoind" - env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc python-zmq" PPA="ppa:chris-lea/zeromq" DEP_OPTS="DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER" - - compiler: ": No wallet" - env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" - - compiler: ": Cross-Mac" - env: HOST=x86_64-apple-darwin11 PACKAGES="cmake libcap-dev libz-dev libbz2-dev" BITCOIN_CONFIG="--enable-reduce-exports" OSX_SDK=10.9 GOAL="deploy" - exclude: - - compiler: gcc -install: - - if [ -n "$PACKAGES" ]; then sudo rm -f /etc/apt/sources.list.d/travis_ci_zeromq3-source.list; fi - - if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get update; fi - - if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi -before_script: - - unset CC; unset CXX - - mkdir -p depends/SDKs depends/sdk-sources - - if [ -n "$OSX_SDK" -a ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi - - if [ -n "$OSX_SDK" -a -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi - - make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS -script: - - if [ -n "$USE_SHELL" ]; then export CONFIG_SHELL="$USE_SHELL"; fi - - OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST - - BITCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$TRAVIS_BUILD_DIR/depends/$HOST --bindir=$OUTDIR/bin --libdir=$OUTDIR/lib" - - depends/$HOST/native/bin/ccache --max-size=$CCACHE_SIZE - - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export CCACHE_READONLY=1; fi - - test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' || ./autogen.sh - - ./configure --cache-file=config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false) - - make distdir PACKAGE=bitcoin VERSION=$HOST - - cd bitcoin-$HOST - - ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false) - - make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false ) - - export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib - - if [ "$RUN_TESTS" = "true" ]; then make check; fi - - if [ "$RUN_TESTS" = "true" ]; then qa/pull-tester/rpc-tests.sh; fi -after_script: - - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then (echo "Upload goes here. Something like: scp -r $BASE_OUTDIR server" || echo "upload failed"); fi ->>>>>>> zcash/master From 1c95172918220a3f713c095a984225bbd9c8d2e4 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 3 Jul 2018 14:43:11 +0200 Subject: [PATCH 0002/3904] test --- .travis.yml | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 250756396..547c74092 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,28 @@ language: cpp - compiler: - - gcc - +- gcc before_install: - - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa - - sudo apt-get update -qq - - sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate -#install: - -script: - - ./zcutil/build.sh -j 5 - +- sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa +- sudo apt-get update -qq +- sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev + m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils + automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate +script: +- "./zcutil/build.sh -j 5" notifications: irc: channels: - - "chat.freenode.net#komodoplatform" + - chat.freenode.net#komodoplatform template: - - "%{repository}/%{branch} (%{commit} - %{author}): %{message}" - - "Alt Message : %{repository_slug} - (%{commit} - %{author}): %{message}, Build Time: %{duration}" - - "Change view : %{compare_url}" - - "Build details : %{build_url}" + - "%{repository}/%{branch} (%{commit} - %{author}): %{message}" + - 'Alt Message : %{repository_slug} - (%{commit} - %{author}): %{message}, Build + Time: %{duration}' + - 'Change view : %{compare_url}' + - 'Build details : %{build_url}' +deploy: + provider: releases + api_key: + secure: oyMB9JDSoL/val/d80Em3sd3mSJY+PPkiclUb3ktizNz7DgYZbBiStUOZIJo95GUYADEvm9RVrP0JmBiDuqneEjfFRzME9/MnpY/LmRCiYGgprMDR80ZqbLgOzSKpE10RE2XM3vZkZeXT/JcGGayUm0faElep2qx62S4ozsAxSvFJ5l/PG+wEltrlnp1z8uYdXV3PBChbjzXJ0BdMVxMrrU39kwzqwu2Ge9PnNjVv0AVxn/oZpf+bzYa7vkSuGTRe2Jcs8U9AABYnZ22wu+tdlD76pdOJzGEwR70e8CjUJmdSn+M+wwAPPHStPW/JHFwSaWsKZtUyB5EWQW2kqq6P+M1Fe7yo6srznsaAcZRWeCrbUO/k44bEfnj7HMGmxfjDJOwbxVEoHg7im+l3HLUiG8rcw5dM/TAnrmgjH/OEj/EM1lbwV2C+PdDGOjdguljEhjBABGRbRABMZjwW8w+uBFVlKlcn7y+zJbMB3mGd+FNGo/OgAcsFzRcpaN8SrC/kzUF2SeEwJjTKvAqRgA66yl7CzDPBtUv2NtoPUz/8YO9rsdGElcWfmDIVacuIEjo1CizlbDzeS7zPiFPW5MRCGryLFLt0WjA/s8lkLO+DbGYXPa4rG6+7ZNUDLfziM+lFqZH8b382/bhv+a6ctpWjaazjiW6yWemsuN8QhByuGw= + file: src/komodod + on: + repo: KomodoPlatform/komodo From 1297265374f8a2fb2b1546f878dde92a1d6d494e Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 3 Jul 2018 14:45:35 +0200 Subject: [PATCH 0003/3904] change travis CI distro --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 547c74092..305e42294 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,11 @@ +dist: xenial language: cpp compiler: - gcc before_install: - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa - sudo apt-get update -qq +- sudo apt-get install libgnutls28-dev - sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate From 2ab1a322f3f4a7c33aea20c6716d7077a936c71d Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 3 Jul 2018 20:21:22 +0200 Subject: [PATCH 0004/3904] test --- .travis.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 305e42294..0b2ae6a4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,20 @@ +os: + - linux + - osx dist: xenial language: cpp compiler: - gcc before_install: -- sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa -- sudo apt-get update -qq -- sudo apt-get install libgnutls28-dev -- sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev - m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils - automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa; fi +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; fi +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libgnutls28-dev; fi +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc5; fi script: -- "./zcutil/build.sh -j 5" +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi notifications: irc: channels: @@ -21,10 +25,16 @@ notifications: Time: %{duration}' - 'Change view : %{compare_url}' - 'Build details : %{build_url}' +before_deploy: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git tag "linux-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git tag "osx-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)"; fi deploy: provider: releases api_key: secure: oyMB9JDSoL/val/d80Em3sd3mSJY+PPkiclUb3ktizNz7DgYZbBiStUOZIJo95GUYADEvm9RVrP0JmBiDuqneEjfFRzME9/MnpY/LmRCiYGgprMDR80ZqbLgOzSKpE10RE2XM3vZkZeXT/JcGGayUm0faElep2qx62S4ozsAxSvFJ5l/PG+wEltrlnp1z8uYdXV3PBChbjzXJ0BdMVxMrrU39kwzqwu2Ge9PnNjVv0AVxn/oZpf+bzYa7vkSuGTRe2Jcs8U9AABYnZ22wu+tdlD76pdOJzGEwR70e8CjUJmdSn+M+wwAPPHStPW/JHFwSaWsKZtUyB5EWQW2kqq6P+M1Fe7yo6srznsaAcZRWeCrbUO/k44bEfnj7HMGmxfjDJOwbxVEoHg7im+l3HLUiG8rcw5dM/TAnrmgjH/OEj/EM1lbwV2C+PdDGOjdguljEhjBABGRbRABMZjwW8w+uBFVlKlcn7y+zJbMB3mGd+FNGo/OgAcsFzRcpaN8SrC/kzUF2SeEwJjTKvAqRgA66yl7CzDPBtUv2NtoPUz/8YO9rsdGElcWfmDIVacuIEjo1CizlbDzeS7zPiFPW5MRCGryLFLt0WjA/s8lkLO+DbGYXPa4rG6+7ZNUDLfziM+lFqZH8b382/bhv+a6ctpWjaazjiW6yWemsuN8QhByuGw= - file: src/komodod + file: + - src/komodod + - src/komodo-cli + skip_cleanup: true on: repo: KomodoPlatform/komodo From 9a66a8bf5da6d2c86b2e219cd2695337df56b65c Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 3 Jul 2018 20:54:08 +0200 Subject: [PATCH 0005/3904] test --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0b2ae6a4d..4770f7016 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc5; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@5; fi script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi From a6a437652ef5f55047d0f21596abde93fc0aefaa Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 4 Aug 2018 20:22:57 +0200 Subject: [PATCH 0006/3904] update travis --- .travis.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4770f7016..d9237a104 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ -os: - - linux - - osx -dist: xenial language: cpp + +matrix: + include: + - os: linux + dist: xenial + sudo: required + - os: osx + osx_image: xcode8 compiler: - gcc before_install: @@ -10,9 +14,10 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libgnutls28-dev; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc5; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@5; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rm '/usr/local/include/c++'; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc@6; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@6; fi script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi @@ -27,12 +32,12 @@ notifications: - 'Change view : %{compare_url}' - 'Build details : %{build_url}' before_deploy: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git tag "linux-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)"; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git tag "osx-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)"; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git tag "linux-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git tag "osx-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi deploy: provider: releases api_key: - secure: oyMB9JDSoL/val/d80Em3sd3mSJY+PPkiclUb3ktizNz7DgYZbBiStUOZIJo95GUYADEvm9RVrP0JmBiDuqneEjfFRzME9/MnpY/LmRCiYGgprMDR80ZqbLgOzSKpE10RE2XM3vZkZeXT/JcGGayUm0faElep2qx62S4ozsAxSvFJ5l/PG+wEltrlnp1z8uYdXV3PBChbjzXJ0BdMVxMrrU39kwzqwu2Ge9PnNjVv0AVxn/oZpf+bzYa7vkSuGTRe2Jcs8U9AABYnZ22wu+tdlD76pdOJzGEwR70e8CjUJmdSn+M+wwAPPHSt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odo-cli From f97c46158fed7d2488f1fa6cafe4c02d46052908 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 4 Aug 2018 21:01:13 +0200 Subject: [PATCH 0007/3904] update builder darwin specific --- depends/builders/darwin.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/depends/builders/darwin.mk b/depends/builders/darwin.mk index 0028d3f6f..f9b066fcf 100644 --- a/depends/builders/darwin.mk +++ b/depends/builders/darwin.mk @@ -1,5 +1,5 @@ -build_darwin_CC = gcc-5 -build_darwin_CXX = g++-5 +build_darwin_CC = gcc-6 +build_darwin_CXX = g++-6 build_darwin_AR: = $(shell xcrun -f ar) build_darwin_RANLIB: = $(shell xcrun -f ranlib) build_darwin_STRIP: = $(shell xcrun -f strip) @@ -10,8 +10,8 @@ build_darwin_SHA256SUM = shasum -a 256 build_darwin_DOWNLOAD = curl --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -L -f -o #darwin host on darwin builder. overrides darwin host preferences. -darwin_CC= gcc-5 -darwin_CXX= g++-5 +darwin_CC= gcc-6 +darwin_CXX= g++-6 darwin_AR:=$(shell xcrun -f ar) darwin_RANLIB:=$(shell xcrun -f ranlib) darwin_STRIP:=$(shell xcrun -f strip) From fd928880a60601a5d2b48c448af2919ccf1639fb Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 4 Aug 2018 21:01:48 +0200 Subject: [PATCH 0008/3904] update host config use gcc/g++ v6 --- depends/hosts/darwin.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 70211078b..bb04d62ec 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -1,9 +1,9 @@ -OSX_MIN_VERSION=10.8 +OSX_MIN_VERSION=10.11 OSX_SDK_VERSION=10.11 OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=253.9 -darwin_CC=gcc-5 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -darwin_CXX=g++-5 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CC=gcc-6 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CXX=g++-6 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) From 10f0bdc03a56fc85e8d69a5c224c86c668c42e11 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 4 Aug 2018 21:03:57 +0200 Subject: [PATCH 0009/3904] update darwin makefile use gcc/g++ v6 include correct gcc libs v6.4.0 --- zcutil/build-mac.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index cf2af5a2a..138508cb5 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -1,6 +1,6 @@ #!/bin/bash -export CC=gcc-5 -export CXX=g++-5 +export CC=gcc-6 +export CXX=g++-6 export LIBTOOL=libtool export AR=ar export RANLIB=ranlib @@ -44,7 +44,7 @@ make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 ./autogen.sh CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \ -CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc5/5.4.0/include/c++/5.4.0 -I$PREFIX/include -fwrapv -fno-strict-aliasing -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ +CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ ./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" make "$@" V=1 NO_GTEST=1 STATIC=1 From afd50b9e11c33e6b67a417359ddf975d201f4a16 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 4 Aug 2018 23:03:34 +0200 Subject: [PATCH 0010/3904] update apikey travisCI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d9237a104..3e6d9a0f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ before_deploy: deploy: provider: releases api_key: - secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + secure: Ko7UZqZMQMyVhoyovtAlhxY8wSWdeaLoMn9g7LDD+HwMfMhyMb5zJnsMjUalS/T+8a7Oymphj0mpbC1Q9w8hcOCwW4J8QYzlTJ7fKtIFeuJUSHhG0LTUu/oM/eR3Kw4E2INiemEemUc9RPBeyFFW55FmPyLZsRcAyQuTOTR0cmvAFpLARm7cRD2P0oZEIMM+HJOcfZIY7ly8S1CluZ88Zb0h92eHEE3oVf8qBYUS8Wstn8M4GjnGNrCb4RHKr528BemWMmLT5FD8kpvmp3dluyYK66rLT3nva3LyC63LhXbivQaJILWphVh1J0Hq0TfC8zN8tqh+A8mcqtcVXSps9wfSXVRxx+A5/ZRcuy3QXuqOq2xTdk5DJPVUZYwd75nX9GAPV6H5fYviiAe3KZVZdExpF/Tfsj+Y5L/YpwRYnq/c/eGG37YqXC2dj4FsL3ZR627JB6olFHvHXG5nEwMperSKT/aiWB73Du7hs5ICO6UPzY+3UQvPmSX6ISIWHRgrqOVvf2aw06YZFbhu3GFLbI6+y1pF2DeabfCuqKKI4w/Iqnp7yd1L9CK+S4YGVwJ5iIvE/Ou8tqeUqW5pImyEvkd/kMtlo+G4maz42m2Jaea5uIIxPVutTzten1KSInblHhF34z8hurVFjm8n6sEO4UOJNp+mMm8gPxlgIC45fcg= file: - src/komodod - src/komodo-cli From 06955861024f548bb38452ad049a5c5a790a9d6f Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 4 Aug 2018 23:10:37 +0200 Subject: [PATCH 0011/3904] test travisCI build thread incr --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e6d9a0f6..c238da584 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,8 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc@6; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@6; fi script: -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j5; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j6; fi notifications: irc: channels: From 4e7f0c5e5a192e97ddbf97373d61792f25414b60 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 5 Aug 2018 11:09:06 +0200 Subject: [PATCH 0012/3904] test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c238da584..0ffda964f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: dist: xenial sudo: required - os: osx - osx_image: xcode8 + osx_image: xcode8.3 compiler: - gcc before_install: From cb9bbcdd70636d0b1d54820df936b7cbdc57d958 Mon Sep 17 00:00:00 2001 From: ca333 Date: Wed, 8 Aug 2018 15:42:03 +0200 Subject: [PATCH 0013/3904] test --- .travis.yml | 65 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ffda964f..994476d0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ + language: cpp matrix: @@ -6,21 +7,24 @@ matrix: dist: xenial sudo: required - os: osx - osx_image: xcode8.3 + osx_image: xcode8 compiler: -- gcc + - gcc before_install: -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa; fi -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; fi -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libgnutls28-dev; fi -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rm '/usr/local/include/c++'; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc@6; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@6; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libgnutls28-dev; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rm '/usr/local/include/c++'; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc@6; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@6; fi script: -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j5; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j6; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar cvfz komodo_linux.tar.gz src/komodod src/komodo-cli; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./makeRelease.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar cvfz komodo_osx.tar.gz src/komodod src/komodo-cli src/libgcc_s.1.dylib src/libgomp.1.dylib src/libstdc++.6.dylib; fi notifications: irc: channels: @@ -32,15 +36,30 @@ notifications: - 'Change view : %{compare_url}' - 'Build details : %{build_url}' before_deploy: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git tag "linux-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git tag "osx-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git tag "linux-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git tag "osx-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi deploy: - provider: releases - api_key: - secure: Ko7UZqZMQMyVhoyovtAlhxY8wSWdeaLoMn9g7LDD+HwMfMhyMb5zJnsMjUalS/T+8a7Oymphj0mpbC1Q9w8hcOCwW4J8QYzlTJ7fKtIFeuJUSHhG0LTUu/oM/eR3Kw4E2INiemEemUc9RPBeyFFW55FmPyLZsRcAyQuTOTR0cmvAFpLARm7cRD2P0oZEIMM+HJOcfZIY7ly8S1CluZ88Zb0h92eHEE3oVf8qBYUS8Wstn8M4GjnGNrCb4RHKr528BemWMmLT5FD8kpvmp3dluyYK66rLT3nva3LyC63LhXbivQaJILWphVh1J0Hq0TfC8zN8tqh+A8mcqtcVXSps9wfSXVRxx+A5/ZRcuy3QXuqOq2xTdk5DJPVUZYwd75nX9GAPV6H5fYviiAe3KZVZdExpF/Tfsj+Y5L/YpwRYnq/c/eGG37YqXC2dj4FsL3ZR627JB6olFHvHXG5nEwMperSKT/aiWB73Du7hs5ICO6UPzY+3UQvPmSX6ISIWHRgrqOVvf2aw06YZFbhu3GFLbI6+y1pF2DeabfCuqKKI4w/Iqnp7yd1L9CK+S4YGVwJ5iIvE/Ou8tqeUqW5pImyEvkd/kMtlo+G4maz42m2Jaea5uIIxPVutTzten1KSInblHhF34z8hurVFjm8n6sEO4UOJNp+mMm8gPxlgIC45fcg= - file: - - src/komodod - - src/komodo-cli - skip_cleanup: true - on: - repo: KomodoPlatform/komodo + - provider: releases + api_key: + secure: Ko7UZqZMQMyVhoyovtAlhxY8wSWdeaLoMn9g7LDD+HwMfMhyMb5zJnsMjUalS/T+8a7Oymphj0mpbC1Q9w8hcOCwW4J8QYzlTJ7fKtIFeuJUSHhG0LTUu/oM/eR3Kw4E2INiemEemUc9RPBeyFFW55FmPyLZsRcAyQuTOTR0cmvAFpLARm7cRD2P0oZEIMM+HJOcfZIY7ly8S1CluZ88Zb0h92eHEE3oVf8qBYUS8Wstn8M4GjnGNrCb4RHKr528BemWMmLT5FD8kpvmp3dluyYK66rLT3nva3LyC63LhXbivQaJILWphVh1J0Hq0TfC8zN8tqh+A8mcqtcVXSps9wfSXVRxx+A5/ZRcuy3QXuqOq2xTdk5DJPVUZYwd75nX9GAPV6H5fYviiAe3KZVZdExpF/Tfsj+Y5L/YpwRYnq/c/eGG37YqXC2dj4FsL3ZR627JB6olFHvHXG5nEwMperSKT/aiWB73Du7hs5ICO6UPzY+3UQvPmSX6ISIWHRgrqOVvf2aw06YZFbhu3GFLbI6+y1pF2DeabfCuqKKI4w/Iqnp7yd1L9CK+S4YGVwJ5iIvE/Ou8tqeUqW5pImyEvkd/kMtlo+G4maz42m2Jaea5uIIxPVutTzten1KSInblHhF34z8hurVFjm8n6sEO4UOJNp+mMm8gPxlgIC45fcg= + name: komodo_linux + prerelease: true + file: + - komodo_linux.tar.gz + skip_cleanup: true + on: + repo: ca333/dsec + branch: master + condition: "$TRAVIS_OS_NAME = linux" + - provider: releases + api_key: + secure: Ko7UZqZMQMyVhoyovtAlhxY8wSWdeaLoMn9g7LDD+HwMfMhyMb5zJnsMjUalS/T+8a7Oymphj0mpbC1Q9w8hcOCwW4J8QYzlTJ7fKtIFeuJUSHhG0LTUu/oM/eR3Kw4E2INiemEemUc9RPBeyFFW55FmPyLZsRcAyQuTOTR0cmvAFpLARm7cRD2P0oZEIMM+HJOcfZIY7ly8S1CluZ88Zb0h92eHEE3oVf8qBYUS8Wstn8M4GjnGNrCb4RHKr528BemWMmLT5FD8kpvmp3dluyYK66rLT3nva3LyC63LhXbivQaJILWphVh1J0Hq0TfC8zN8tqh+A8mcqtcVXSps9wfSXVRxx+A5/ZRcuy3QXuqOq2xTdk5DJPVUZYwd75nX9GAPV6H5fYviiAe3KZVZdExpF/Tfsj+Y5L/YpwRYnq/c/eGG37YqXC2dj4FsL3ZR627JB6olFHvHXG5nEwMperSKT/aiWB73Du7hs5ICO6UPzY+3UQvPmSX6ISIWHRgrqOVvf2aw06YZFbhu3GFLbI6+y1pF2DeabfCuqKKI4w/Iqnp7yd1L9CK+S4YGVwJ5iIvE/Ou8tqeUqW5pImyEvkd/kMtlo+G4maz42m2Jaea5uIIxPVutTzten1KSInblHhF34z8hurVFjm8n6sEO4UOJNp+mMm8gPxlgIC45fcg= + name: komodo_osx + prerelease: true + file: + - komodo_osx.tar.gz + skip_cleanup: true + on: + repo: ca333/dsec + branch: master + condition: "$TRAVIS_OS_NAME = osx" From 6dd7c4ef34f7a2ff8dc22cfe2011815828372ef4 Mon Sep 17 00:00:00 2001 From: ca333 Date: Wed, 8 Aug 2018 16:06:35 +0200 Subject: [PATCH 0014/3904] test --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 994476d0c..6f613ad22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ deploy: - komodo_linux.tar.gz skip_cleanup: true on: - repo: ca333/dsec + repo: KomodoPlatform/komodo branch: master condition: "$TRAVIS_OS_NAME = linux" - provider: releases @@ -60,6 +60,6 @@ deploy: - komodo_osx.tar.gz skip_cleanup: true on: - repo: ca333/dsec + repo: KomodoPlatform/komodo branch: master condition: "$TRAVIS_OS_NAME = osx" From cc0e1e13e4e3f688e534848236108062523fefb3 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 9 Aug 2018 23:13:14 +0200 Subject: [PATCH 0015/3904] update travis --- .travis.yml | 91 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9237a104..6792e41bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,22 +5,32 @@ matrix: - os: linux dist: xenial sudo: required + env: LINUX_DEPLOY="true" OSX_DEPLOY="false" - os: osx - osx_image: xcode8 + osx_image: xcode8 + env: OSX_DEPLOY="true" LINUX_DEPLOY="false" +branches: + only: + - master + - dev + - cctests compiler: -- gcc + - gcc before_install: -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa; fi -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; fi -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libgnutls28-dev; fi -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rm '/usr/local/include/c++'; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc@6; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@6; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libgnutls28-dev; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rm '/usr/local/include/c++'; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc@6; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@6; fi script: -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar cvfz komodo_linux.tar.gz src/komodod src/komodo-cli; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./makeRelease.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar cvfz komodo_osx.tar.gz src/komodod src/komodo-cli src/libgcc_s.1.dylib src/libgomp.1.dylib src/libstdc++.6.dylib; fi notifications: irc: channels: @@ -32,15 +42,50 @@ notifications: - 'Change view : %{compare_url}' - 'Build details : %{build_url}' before_deploy: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git tag "linux-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git tag "osx-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git tag "$TRAVIS_BRANCH-linux-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git tag "$TRAVIS_BRANCH-osx-$(date +'%Y%m%d%H%M')-$(git log --format=%h -1)"; fi deploy: - provider: releases - api_key: - secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= - file: - - src/komodod - - src/komodo-cli - skip_cleanup: true - on: - repo: KomodoPlatform/komodo + - provider: releases + api_key: + secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + name: komodo_linux-$TRAVIS_BRANCH + prerelease: true + file: komodo_linux.tar.gz + skip_cleanup: true + on: + repo: KomodoPlatform/komodo + branch: master + condition: $LINUX_DEPLOY = "true" + - provider: releases + api_key: + secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + name: komodo_linux-$TRAVIS_BRANCH + prerelease: true + file: komodo_linux.tar.gz + skip_cleanup: true + on: + repo: KomodoPlatform/komodo + branch: dev + condition: $LINUX_DEPLOY = "true" + - provider: releases + api_key: + secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + name: komodo_osx-$TRAVIS_BRANCH + prerelease: true + file: komodo_osx.tar.gz + skip_cleanup: true + on: + repo: KomodoPlatform/komodo + branch: master + condition: $OSX_DEPLOY = "true" + - provider: releases + api_key: + secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + name: komodo_osx-$TRAVIS_BRANCH + prerelease: true + file: komodo_osx.tar.gz + skip_cleanup: true + on: + repo: KomodoPlatform/komodo + branch: dev + condition: $OSX_DEPLOY = "true" From 22ba373414d719eb0e65f2bbf8ff8399ee733860 Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 10 Aug 2018 00:11:23 +0200 Subject: [PATCH 0016/3904] update deployment keys --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6792e41bb..93307b3a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ before_deploy: deploy: - provider: releases api_key: - secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_linux-$TRAVIS_BRANCH prerelease: true file: komodo_linux.tar.gz @@ -58,7 +58,7 @@ deploy: condition: $LINUX_DEPLOY = "true" - provider: releases api_key: - secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_linux-$TRAVIS_BRANCH prerelease: true file: komodo_linux.tar.gz @@ -69,7 +69,7 @@ deploy: condition: $LINUX_DEPLOY = "true" - provider: releases api_key: - secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRa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cYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_osx-$TRAVIS_BRANCH prerelease: true file: komodo_osx.tar.gz @@ -80,7 +80,7 @@ deploy: condition: $OSX_DEPLOY = "true" - provider: releases api_key: - secure: Jms7dz5GMZmuXUCHl5u6iZUtAybv86oW3x36DCJfdzbDiO4B9EWB04z7zA0qvoomefyujHTmQUHxyOKfd4h9/rVMFFv9hgmUxWkrcg7KyLNisOQRaovVOuNtu2lRNXTOSF16Cy+xFGkVh1ObBRhAoMsVKPhMl6PCDiKhNWIekRR9pBtjafKsClQ2ieknUYfqhuvgj7zmqCedeyVaVQyt2W/J65leD0BkfCUESTpANSprHs4bQB65VuQIKKMi+URKx2VgpDdUcWJySt9jAHVPIbI5cT5maAT6RUMnE4oha7Ca1Ox8StBqjQ/hkkMyDbN0keIlN7RjZlwdZQf/qUnT/dPQhsyUCdPXOxmEJ2jekezEK/LGr4Fb+v+vjd9dhLNkD5nVn9zp36biGSCjiMpffQ3fjMeM0YGmVEVRP9kZXLWVRYQoVKrzjyzg5dY8iChbiQEfYpTeBuU+e2rqj4mns+Jvy0zjUbMy6Tyva+iqdZ/PdsBDbiB7c+FIgB1IUTVOD+GgKx6dhCtBZEccn5EyWFwZF9IdQJHZCYV4PA7nuzfm1Ol9SDdZkGHd2OgRCqK/sTwyfTHv8exNqZ1k+epGJp2a0q4IOEknc9aPCAF+m9pHahk7s7VO5gmhO6pvbvuKoeEtEXRZHRzCkGkXfzJlBk+23X5gBexKb6inRdBlj6M= + secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_osx-$TRAVIS_BRANCH prerelease: true file: komodo_osx.tar.gz From 1fd0b9a823b04ca1574e0ceb30ee127ccd519bef Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 10 Aug 2018 14:00:24 +0200 Subject: [PATCH 0017/3904] test --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93307b3a5..5490f0f08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,10 @@ matrix: - os: linux dist: xenial sudo: required - env: LINUX_DEPLOY="true" OSX_DEPLOY="false" + env: LINUX_DEPLOY="true" OSX_DEPLOY="false" $TRAVIS_OS_NAME="linux" - os: osx osx_image: xcode8 - env: OSX_DEPLOY="true" LINUX_DEPLOY="false" + env: OSX_DEPLOY="true" LINUX_DEPLOY="false" $TRAVIS_OS_NAME="osx" branches: only: - master @@ -27,10 +27,10 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --overwrite gcc@6; fi script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./zcutil/build.sh -j 5; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar cvfz komodo_linux.tar.gz src/komodod src/komodo-cli; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar cvfz komodo_linux_$TRAVIS_BRANCH.tar.gz src/komodod src/komodo-cli; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./zcutil/build-mac.sh -j 5; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./makeRelease.sh; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar cvfz komodo_osx.tar.gz src/komodod src/komodo-cli src/libgcc_s.1.dylib src/libgomp.1.dylib src/libstdc++.6.dylib; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar cvfz komodo_osx_$TRAVIS_BRANCH.tar.gz src/komodod src/komodo-cli src/libgcc_s.1.dylib src/libgomp.1.dylib src/libstdc++.6.dylib; fi notifications: irc: channels: @@ -50,7 +50,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_linux-$TRAVIS_BRANCH prerelease: true - file: komodo_linux.tar.gz + file: komodo_linux_$TRAVIS_BRANCH.tar.gz.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo @@ -61,7 +61,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_linux-$TRAVIS_BRANCH prerelease: true - file: komodo_linux.tar.gz + file: komodo_linux_$TRAVIS_BRANCH.tar.gz.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo @@ -72,7 +72,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_osx-$TRAVIS_BRANCH prerelease: true - file: komodo_osx.tar.gz + file: komodo_osx_$TRAVIS_BRANCH.tar.gz.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo @@ -83,7 +83,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_osx-$TRAVIS_BRANCH prerelease: true - file: komodo_osx.tar.gz + file: komodo_osx_$TRAVIS_BRANCH.tar.gz.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo From 32f6814d7e40d1b1fcfea12ac476c991a9795c00 Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 10 Aug 2018 14:01:31 +0200 Subject: [PATCH 0018/3904] test --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5490f0f08..bfc8b8b4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_linux-$TRAVIS_BRANCH prerelease: true - file: komodo_linux_$TRAVIS_BRANCH.tar.gz.tar.gz + file: komodo_linux_$TRAVIS_BRANCH.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo @@ -61,7 +61,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_linux-$TRAVIS_BRANCH prerelease: true - file: komodo_linux_$TRAVIS_BRANCH.tar.gz.tar.gz + file: komodo_linux_$TRAVIS_BRANCH.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo @@ -72,7 +72,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_osx-$TRAVIS_BRANCH prerelease: true - file: komodo_osx_$TRAVIS_BRANCH.tar.gz.tar.gz + file: komodo_osx_$TRAVIS_BRANCH.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo @@ -83,7 +83,7 @@ deploy: secure: id69KBVsY0p41WFlqd5cGrAIksJAkUempmdrQwHtfqIbB6es7MVfXuxfmTxk7lZNEItSvLGilYtqhBMNVAVjRRPvk90hveGDMkbpjFz3XBbFEFqtrAr2GdIcpGtII2T3T/TG7j11TMtJ6GvBVt4OcatHFVsKBCFDIx0fB0fd1oLrEAwgRdBO2Jq7bMzoLdzGx3mVtdW5dSRBQzG/Z0yvx+R9mQHSvyPGh6oNPD6mvXPzEaCeRW6Y8g8y1SW/6zDJR6sSdOKA0jsHkr/hM8st3Qkr5Cu3roEbL8598uvfBahjxVHVT8+lu/nJnQyrvtWZKu/uUefybqgZl7UpGvZVFxbNwAB/ZNn0pBKIpZlX/kh6rdGF0XrAG7g+Ths6iklh7wDefYP2JeGwHWJ38YcdF8T/VcSdOXz7EiWwEeZO5sGcTRSl5Ql8mcU3YyyB7BTdViYNTHf5VFFJ/baLZG+shZ/0tb1Ntx5mLDbV8vcYXJpUNTJcXbhcUDSF3QuSz04ftkzgpcsODzcTzD6+2sezV1vlOAlxK04C+zzxG96Md/TegvZYYns78RSgrP/UH1qwEbgxTo3xpErGllzntzZfHJ887Goez+DeB9ga7pUBc5AXGpfRhYqJP66wR10zqfWuWYvjAwRBRNySjr3pUvaA3T1iSZ5HLrpKBfcHXJOTg8M= name: komodo_osx-$TRAVIS_BRANCH prerelease: true - file: komodo_osx_$TRAVIS_BRANCH.tar.gz.tar.gz + file: komodo_osx_$TRAVIS_BRANCH.tar.gz skip_cleanup: true on: repo: KomodoPlatform/komodo From cbb14226569d8815137524c672fde8250b3327c4 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Tue, 4 Sep 2018 17:12:04 -0300 Subject: [PATCH 0019/3904] fix for TXSCL data leak --- src/crosschain.cpp | 7 +++++-- src/notarisationdb.cpp | 7 ++++++- src/notarisationdb.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 197390e59..831c7bcae 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -50,6 +50,8 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh int seenOwnNotarisations = 0; + bool txscl = IsTXSCL(symbol); + for (int i=0; i kmdHeight) break; NotarisationsInBlock notarisations; @@ -72,8 +74,9 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (seenOwnNotarisations == 1) { BOOST_FOREACH(Notarisation& nota, notarisations) { - if (nota.second.ccId == targetCCid) - moms.push_back(nota.second.MoM); + if (IsTXSCL(nota.second.symbol) == txscl) + if (nota.second.ccId == targetCCid) + moms.push_back(nota.second.MoM); } } } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index cdfbb82c1..de3dd75f2 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -26,7 +26,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) { NotarisationData data; if (ParseNotarisationOpReturn(tx, data)) - if (strlen(data.symbol) >= 5 && strncmp(data.symbol, "TXSCL", 5) == 0) + if (IsTXSCL(data.symbol)) isTxscl = 1; } @@ -46,6 +46,11 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) return vNotarisations; } +bool IsTXSCL(const char* symbol) +{ + return strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0; +} + bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs) { diff --git a/src/notarisationdb.h b/src/notarisationdb.h index b8cd93691..f01a5a587 100644 --- a/src/notarisationdb.h +++ b/src/notarisationdb.h @@ -24,5 +24,6 @@ bool GetBackNotarisation(uint256 notarisationHash, Notarisation &n); void WriteBackNotarisations(const NotarisationsInBlock notarisations, CLevelDBBatch &batch); void EraseBackNotarisations(const NotarisationsInBlock notarisations, CLevelDBBatch &batch); int ScanNotarisationsDB(int height, std::string symbol, int scanLimitBlocks, Notarisation& out); +bool IsTXSCL(const char* symbol); #endif /* NOTARISATIONDB_H */ From 538de2ee49fe3b3531c6a09dd9ac6f08bb090287 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Wed, 5 Sep 2018 00:19:12 -0300 Subject: [PATCH 0020/3904] multiple authorities --- src/Makefile.am | 1 + src/cc/eval.cpp | 36 ++---------------- src/crosschain.cpp | 4 +- src/crosschain.h | 14 +++++++ src/crosschain_authority.cpp | 72 ++++++++++++++++++++++++++++++++++++ src/notarisationdb.cpp | 44 ++++++++++------------ 6 files changed, 113 insertions(+), 58 deletions(-) create mode 100644 src/crosschain_authority.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 8b10c06e0..7a9f660e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -272,6 +272,7 @@ libbitcoin_server_a_SOURCES = \ chain.cpp \ checkpoints.cpp \ crosschain.cpp \ + crosschain_authority.cpp \ deprecation.cpp \ httprpc.cpp \ httpserver.cpp \ diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index b6fcf57dd..cb9774a7a 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -140,45 +140,17 @@ int32_t Eval::GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t time return komodo_notaries(pubkeys, height, timestamp); } - bool Eval::CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const { if (tx.vin.size() < 11) return false; - uint8_t seenNotaries[64] = {0}; - uint8_t notaries[64][33]; - int nNotaries = GetNotaries(notaries, height, timestamp); + CrosschainAuthority auth; + auth.requiredSigs = 11; + auth.size = GetNotaries(auth.notaries, height, timestamp); - BOOST_FOREACH(const CTxIn &txIn, tx.vin) - { - // Get notary pubkey - CTransaction tx; - uint256 hashBlock; - if (!GetTxUnconfirmed(txIn.prevout.hash, tx, hashBlock)) return false; - if (tx.vout.size() < txIn.prevout.n) return false; - CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; - if (spk.size() != 35) return false; - const unsigned char *pk = spk.data(); - if (pk++[0] != 33) return false; - if (pk[33] != OP_CHECKSIG) return false; - - // Check it's a notary - for (int i=0; i kmdHeight) break; @@ -74,7 +74,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (seenOwnNotarisations == 1) { BOOST_FOREACH(Notarisation& nota, notarisations) { - if (IsTXSCL(nota.second.symbol) == txscl) + if (GetSymbolAuthority(nota.second.symbol) == authority) if (nota.second.ccId == targetCCid) moms.push_back(nota.second.MoM); } diff --git a/src/crosschain.h b/src/crosschain.h index 15452ac63..65be53f92 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -3,6 +3,20 @@ #include "cc/eval.h" +const int CROSSCHAIN_KOMODO = 1; +const int CROSSCHAIN_TXSCL = 2; +const int CROSSCHAIN_STAKED = 3; + +typedef struct CrosschainAuthority { + uint8_t notaries[64][33]; + size_t size; + size_t requiredSigs; +} CrosschainAuthority; + +extern const CrosschainAuthority auth_STAKED; + +int GetSymbolAuthority(const char* symbol); +bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth); /* On assetchain */ TxProof GetAssetchainProof(uint256 hash); diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp new file mode 100644 index 000000000..5ea277387 --- /dev/null +++ b/src/crosschain_authority.cpp @@ -0,0 +1,72 @@ +#include "cc/eval.h" +#include "crosschain.h" +#include "notarisationdb.h" + + +int GetSymbolAuthority(const char* symbol) +{ + if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) + return CROSSCHAIN_TXSCL; + if (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) + return CROSSCHAIN_STAKED; + return CROSSCHAIN_KOMODO; +} + + +bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) +{ + EvalRef eval; + + if (tx.vin.size() < auth.requiredSigs) return false; + + uint8_t seesize[64]; + + BOOST_FOREACH(const CTxIn &txIn, tx.vin) + { + // Get notary pubkey + CTransaction tx; + uint256 hashBlock; + if (!eval->GetTxUnconfirmed(txIn.prevout.hash, tx, hashBlock)) return false; + if (tx.vout.size() < txIn.prevout.n) return false; + CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; + if (spk.size() != 35) return false; + const unsigned char *pk = spk.data(); + if (pk++[0] != 33) return false; + if (pk[33] != OP_CHECKSIG) return false; + + // Check it's a notary + for (int i=0; i @@ -21,36 +22,31 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; - // Special case for TXSCL. Should prob be removed at some point. - bool isTxscl = 0; - { - NotarisationData data; - if (ParseNotarisationOpReturn(tx, data)) - if (IsTXSCL(data.symbol)) - isTxscl = 1; + NotarisationData data; + bool parsed = ParseNotarisationOpReturn(tx, data); + if (!parsed) data = NotarisationData(); + int authority = GetSymbolAuthority(data.symbol); + + if (authority == CROSSCHAIN_KOMODO) { + if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) + continue; + } else if (authority == CROSSCHAIN_STAKED) { + if (!CheckTxAuthority(tx, auth_STAKED)) + continue; } - if (isTxscl || eval->CheckNotaryInputs(tx, nHeight, block.nTime)) { - NotarisationData data; - if (ParseNotarisationOpReturn(tx, data)) { - vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", - // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); - //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); - } - else - LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", - tx.GetHash().GetHex().data(), nHeight); - } + if (parsed) { + vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); + //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", + // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); + //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); + } else + LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", + tx.GetHash().GetHex().data(), nHeight); } return vNotarisations; } -bool IsTXSCL(const char* symbol) -{ - return strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0; -} - bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs) { From 64a4efaa700e5682096998a741116b140178799a Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Wed, 5 Sep 2018 00:22:38 -0300 Subject: [PATCH 0021/3904] put clarifying comment --- src/crosschain_authority.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 5ea277387..d9d75632a 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -59,6 +59,11 @@ const char *notaries_STAKED[4][2] = {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"} }; +/* + * TO EDIT: + * 1) Edit sigs above + * 2) Update size and requiredSigs below + */ const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; From 040078433fd6f2e5db76fddf86b44efa5a91a214 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Wed, 5 Sep 2018 00:27:06 -0300 Subject: [PATCH 0022/3904] fix outrageous typo --- src/crosschain_authority.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index d9d75632a..0eeb8ad27 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,7 +19,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vin.size() < auth.requiredSigs) return false; - uint8_t seesize[64]; + uint8_t seen[64]; BOOST_FOREACH(const CTxIn &txIn, tx.vin) { @@ -36,9 +36,9 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) // Check it's a notary for (int i=0; i Date: Wed, 5 Sep 2018 20:47:22 +0000 Subject: [PATCH 0023/3904] temp add test pubkeys --- src/crosschain_authority.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 0eeb8ad27..a75016770 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -54,9 +54,9 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const char *notaries_STAKED[4][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"} + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"} }; /* From 062b77092772a7dc96c8009010d22aa363ab2617 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Thu, 6 Sep 2018 00:14:45 -0300 Subject: [PATCH 0024/3904] bugfix; seen members not zeroed --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 0eeb8ad27..33c1d1d3e 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,7 +19,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vin.size() < auth.requiredSigs) return false; - uint8_t seen[64]; + uint8_t seen[64] = {0}; BOOST_FOREACH(const CTxIn &txIn, tx.vin) { From 489eb6710d8216aedba89d20c4140267bbf20000 Mon Sep 17 00:00:00 2001 From: blackjok3rtt Date: Fri, 7 Sep 2018 04:02:17 +0800 Subject: [PATCH 0025/3904] Test modification to allow STAKED* chains to have their own notary pubkeys. --- src/komodo_notary.h | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4711a9afc..8d1b6d582 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -198,6 +198,20 @@ const char *Notaries_elected1[][2] = {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, }; +const char *Notaries_staked[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; + + int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; @@ -226,13 +240,24 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1)); - for (i=0; i Date: Sat, 8 Sep 2018 09:29:00 +0800 Subject: [PATCH 0026/3904] Test, use single array, dynamically sized for crosschain auth --- src/crosschain_authority.cpp | 20 +++----------------- src/komodo_notary.h | 8 ++++---- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 12a44d8ce..7a153b7ff 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,6 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" +#include "komodo_notary.h" int GetSymbolAuthority(const char* symbol) @@ -51,27 +52,12 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) } -const char *notaries_STAKED[4][2] = -{ - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"} -}; - -/* - * TO EDIT: - * 1) Edit sigs above - * 2) Update size and requiredSigs below - */ - const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = 4; - auth.requiredSigs = 2; + auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + auth.requiredSigs = (auth.size/5); for (int n=0; n Date: Sat, 8 Sep 2018 09:35:26 +0800 Subject: [PATCH 0027/3904] try again --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7a153b7ff..fc8752db1 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,7 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -#include "komodo_notary.h" +#include "notaries_STAKED.h" int GetSymbolAuthority(const char* symbol) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6334af56b..6246fca52 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,6 +18,8 @@ #include "komodo_cJSON.h" +#include "notaries_STAKED.h" + #define KOMODO_MAINNET_START 178999 const char *Notaries_genesis[][2] = @@ -198,20 +200,6 @@ const char *Notaries_elected1[][2] = {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, }; -const char notaries_STAKED[][2] = -{ - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, -}; - - int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; From e18e04bed7bfd8296dda21fb0489311cf31aa326 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:38:12 +0800 Subject: [PATCH 0028/3904] LOL im drunk --- notaries_STAKED.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 notaries_STAKED.h diff --git a/notaries_STAKED.h b/notaries_STAKED.h new file mode 100644 index 000000000..8891a92fa --- /dev/null +++ b/notaries_STAKED.h @@ -0,0 +1,14 @@ +# notaries_STAKED + +const char notaries_STAKED[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; From c069525a77da1d84a6c9dc9f4e2db07aed381dd8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:49:50 +0800 Subject: [PATCH 0029/3904] fix stupidity --- notaries_STAKED.h => src/notaries_STAKED.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename notaries_STAKED.h => src/notaries_STAKED.h (100%) diff --git a/notaries_STAKED.h b/src/notaries_STAKED.h similarity index 100% rename from notaries_STAKED.h rename to src/notaries_STAKED.h From 9f93a0de963896d317a83095cc1c6c808f5be583 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:52:08 +0800 Subject: [PATCH 0030/3904] poofish --- src/notaries_STAKED.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 8891a92fa..a53cb3e27 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,3 @@ -# notaries_STAKED - const char notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From d5b43746be0dd22d09cdd9d71118d8e91a4164fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:58:29 +0800 Subject: [PATCH 0031/3904] fingers crossed --- src/notaries_STAKED.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index a53cb3e27..b5454d2f4 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,4 +1,4 @@ -const char notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, From 1ab289383976c956d1714b048aa85e0615d8d17c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:08:07 +0800 Subject: [PATCH 0032/3904] test --- src/notaries_STAKED.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index b5454d2f4..94f20acd2 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,3 +1,4 @@ +#pragma once const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From 14f27f2e498235b3b616706ab02d062a56cef7dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:26:32 +0800 Subject: [PATCH 0033/3904] test --- src/notaries_STAKED.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 94f20acd2..ed21cd2bd 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,4 +1,5 @@ #pragma once +#define notaries_STAKED const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From 1049d013b78bafd35ef38cef6c22f6c4217438f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:28:02 +0800 Subject: [PATCH 0034/3904] test --- src/notaries_STAKED.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index ed21cd2bd..7c540c9a4 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ #pragma once -#define notaries_STAKED +#define *notaries_STAKED[][2] const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From f04396d2c0497a7c2c6a5256aad102745155841e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:30:47 +0800 Subject: [PATCH 0035/3904] a --- src/crosschain_authority.cpp | 2 +- src/notaries_STAKED.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index fc8752db1..6c60d9f97 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,7 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -#include "notaries_STAKED.h" +//#include "notaries_STAKED.h" int GetSymbolAuthority(const char* symbol) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 7c540c9a4..f75c453b6 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ #pragma once -#define *notaries_STAKED[][2] + const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From ead6f50464ca7d91f70a2c40447802ada993daad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:38:29 +0800 Subject: [PATCH 0036/3904] testing --- src/crosschain_authority.cpp | 13 +++++++++++++ src/komodo_notary.h | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6c60d9f97..48162ad24 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,6 +3,19 @@ #include "notarisationdb.h" //#include "notaries_STAKED.h" +const char *notaries_STAKED[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; + int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6246fca52..5e63a4648 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,20 @@ #include "komodo_cJSON.h" -#include "notaries_STAKED.h" +//#include "notaries_STAKED.h" + +const char *notaries_STAKED[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; #define KOMODO_MAINNET_START 178999 From b20459fee2dcb4504f21ccd39d1b1ad79c6f156b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 13:01:02 +0800 Subject: [PATCH 0037/3904] test again --- src/crosschain_authority.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 48162ad24..eaeb010b4 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,7 @@ #include "notarisationdb.h" //#include "notaries_STAKED.h" -const char *notaries_STAKED[][2] = +const char *notaries_STAKEDcc[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, @@ -67,10 +67,10 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); auth.requiredSigs = (auth.size/5); for (int n=0; n Date: Sat, 8 Sep 2018 21:25:55 +0800 Subject: [PATCH 0038/3904] update pubkeys --- src/crosschain_authority.cpp | 20 +++++++++++--------- src/komodo_notary.h | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index eaeb010b4..c8108608c 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,15 +5,17 @@ const char *notaries_STAKEDcc[][2] = { - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, + {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, + {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, + {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, + {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, + {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"} }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5e63a4648..43c6805c6 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -21,16 +21,17 @@ //#include "notaries_STAKED.h" const char *notaries_STAKED[][2] = -{ - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, + {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, + {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, + {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, + {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, + {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, }; #define KOMODO_MAINNET_START 178999 From a8e94f86c5e1ee15b747b74cab90e1ee878fff58 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:28:31 +0800 Subject: [PATCH 0039/3904] pubkeys update --- src/crosschain_authority.cpp | 4 ++-- src/komodo_notary.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index c8108608c..a2fb95cff 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,9 +5,9 @@ const char *notaries_STAKEDcc[][2] = { - {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 43c6805c6..d377de319 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -21,9 +21,9 @@ //#include "notaries_STAKED.h" const char *notaries_STAKED[][2] = - {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, From fa9fd0a1e32f2623cbc2c5d682fe0c76aa32d688 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:40:20 +0800 Subject: [PATCH 0040/3904] drunk again --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index a2fb95cff..1960d7c32 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -15,7 +15,7 @@ const char *notaries_STAKEDcc[][2] = {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, - {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"} + {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, }; From e84001da53303bf8f18fe06ec9909cdb06cc80e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:44:19 +0800 Subject: [PATCH 0041/3904] soooo drunk --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1960d7c32..ffb3048ea 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -6,7 +6,7 @@ const char *notaries_STAKEDcc[][2] = { {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d377de319..e64024a19 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ const char *notaries_STAKED[][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, From 362c398046dad7c89fb84189ff6beecf03093b42 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:52:50 +0800 Subject: [PATCH 0042/3904] more beer --- src/crosschain_authority.cpp | 21 ++++++++++----------- src/komodo_notary.h | 18 +++++++++--------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ffb3048ea..492b5149b 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,17 +5,16 @@ const char *notaries_STAKEDcc[][2] = { - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, - {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, - {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, - {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, - {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, - {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, - {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, + {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, + {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, + {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e64024a19..a49ceeda9 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,20 +18,20 @@ #include "komodo_cJSON.h" -//#include "notaries_STAKED.h" +#include "notaries_STAKED.h" const char *notaries_STAKED[][2] = +{ {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, - {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, - {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, - {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, - {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, - {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, - {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, + {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, + {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, + {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, }; #define KOMODO_MAINNET_START 178999 From fe6f552be66ee806db2ff922a541eed06ee61d79 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:55:32 +0800 Subject: [PATCH 0043/3904] LOL lol --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index a49ceeda9..e9570db6a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,7 @@ #include "komodo_cJSON.h" -#include "notaries_STAKED.h" +//include "notaries_STAKED.h" const char *notaries_STAKED[][2] = { From 89223d139888ea373896d53c1b33d6f1217c9a98 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Sat, 8 Sep 2018 14:39:26 +0000 Subject: [PATCH 0044/3904] add pubkey --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 492b5149b..ccac930f7 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -15,6 +15,7 @@ const char *notaries_STAKEDcc[][2] = {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e9570db6a..c46fb22dd 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -32,6 +32,7 @@ const char *notaries_STAKED[][2] = {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; #define KOMODO_MAINNET_START 178999 From a35ead4321925533f2c8dd8ff2638b35321576ab Mon Sep 17 00:00:00 2001 From: tonymorony Date: Sat, 8 Sep 2018 21:25:03 +0000 Subject: [PATCH 0045/3904] changed pubket TonyL --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ccac930f7..b726c034d 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -13,7 +13,7 @@ const char *notaries_STAKEDcc[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, - {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c46fb22dd..bfcdcfba5 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -30,7 +30,7 @@ const char *notaries_STAKED[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, - {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; From 2f358266f8acb5d495c088ec0afbdb6b39d09dcf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 9 Sep 2018 07:18:39 +0800 Subject: [PATCH 0046/3904] fix webworker --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 492b5149b..883bd886f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -6,7 +6,7 @@ const char *notaries_STAKEDcc[][2] = { {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, + {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e9570db6a..d20ae6912 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -23,7 +23,7 @@ const char *notaries_STAKED[][2] = { {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, + {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 From ce77a270483eba8924473477d565a25cdc48e033 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 05:08:48 +0000 Subject: [PATCH 0047/3904] finalize pubkeys --- src/crosschain_authority.cpp | 8 +++----- src/komodo_notary.h | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index f169c47b3..4913a4ea0 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,16 +5,14 @@ const char *notaries_STAKEDcc[][2] = { + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, - {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, - {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index db0aeb988..3fbcb25ff 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,16 +22,14 @@ const char *notaries_STAKED[][2] = { + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, - {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, - {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; From d33fc13c596c3e2960b37009a1166586a2858076 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 05:17:20 +0000 Subject: [PATCH 0048/3904] add titomane --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 4913a4ea0..4b5f7f62d 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -14,6 +14,7 @@ const char *notaries_STAKEDcc[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3fbcb25ff..acbff97c7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -31,6 +31,7 @@ const char *notaries_STAKED[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, }; #define KOMODO_MAINNET_START 178999 From fdae4d44e9c0d606d1fdcbe3c5e482e41771145b Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 05:40:41 +0000 Subject: [PATCH 0049/3904] add CHMEX, add addresses --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 4b5f7f62d..772558268 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -15,6 +15,7 @@ const char *notaries_STAKEDcc[][2] = {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index acbff97c7..9214ee3e0 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,16 +22,17 @@ const char *notaries_STAKED[][2] = { - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, }; #define KOMODO_MAINNET_START 178999 From 31b6db4b4187a94bbc2666dbcc998d917c25ad63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Sep 2018 13:53:47 +0800 Subject: [PATCH 0050/3904] fix spaces just incase --- src/crosschain_authority.cpp | 6 +++--- src/komodo_notary.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 772558268..e191fec84 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -6,9 +6,9 @@ const char *notaries_STAKEDcc[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9214ee3e0..131fc2438 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -23,9 +23,9 @@ const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 From a86d6f81ad9f740f458440eff77f8dcfd2d16c0b Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 07:36:17 +0000 Subject: [PATCH 0051/3904] add metaphilibert --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 772558268..1c2c2146b 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -16,6 +16,7 @@ const char *notaries_STAKEDcc[][2] = {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9214ee3e0..23fa61b9c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -32,7 +32,8 @@ const char *notaries_STAKED[][2] = {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 }; #define KOMODO_MAINNET_START 178999 From 48d531894933bc11ce137d6c4dc75fd6f2603876 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 07:43:05 +0000 Subject: [PATCH 0052/3904] add address --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index bd3e5acd1..9e6f17097 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -29,7 +29,7 @@ const char *notaries_STAKED[][2] = {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL From de3377d94467495223f753ea479472653bae86d2 Mon Sep 17 00:00:00 2001 From: webworker01 Date: Mon, 10 Sep 2018 07:52:10 +0000 Subject: [PATCH 0053/3904] update webworker keys --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1b82c32af..39579811c 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ const char *notaries_STAKEDcc[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9e6f17097..d42d3e17e 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -24,7 +24,7 @@ const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, From e3f69857503c5ed0e205ee1b4d99eb047a4d12a0 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 09:07:43 +0000 Subject: [PATCH 0054/3904] add jusoaresf, add mylo --- src/crosschain_authority.cpp | 2 ++ src/komodo_notary.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1b82c32af..6c92cfe07 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -17,6 +17,8 @@ const char *notaries_STAKEDcc[][2] = {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9e6f17097..105f4a5b1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -34,6 +34,8 @@ const char *notaries_STAKED[][2] = {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx }; #define KOMODO_MAINNET_START 178999 From b3c526f9c667aa14f49b1c7028f77f558f632526 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Sep 2018 20:28:20 +0800 Subject: [PATCH 0055/3904] add placeholder 15th pubkey --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6c92cfe07..33b868e3a 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,6 +19,7 @@ const char *notaries_STAKEDcc[][2] = {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 105f4a5b1..a08e7fc97 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -36,6 +36,7 @@ const char *notaries_STAKED[][2] = {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. }; #define KOMODO_MAINNET_START 178999 From 63fe933da5c566dd772918bc0e5726dbee048584 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Sep 2018 20:30:04 +0800 Subject: [PATCH 0056/3904] notaries_staked.h bounty to fix this is valid --- src/notaries_STAKED.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index f75c453b6..a92d71684 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -2,13 +2,19 @@ const char *notaries_STAKED[][2] = { - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. }; From b22e7d44f43f2a3247d14a34478d13e28d4a5e72 Mon Sep 17 00:00:00 2001 From: blackjok3rtt Date: Tue, 11 Sep 2018 14:09:04 +0000 Subject: [PATCH 0057/3904] add modofication to stop normal komodo repo using staked chains --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d98418c82..4856931ac 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1554,7 +1554,7 @@ void komodo_args(char *argv0) if ( name.c_str()[0] != 0 ) { MAX_BLOCK_SIGOPS = 60000; - ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); + ASSETCHAINS_SUPPLY = ( GetArg("-ac_supply",10) + 1 ); ASSETCHAINS_ENDSUBSIDY = GetArg("-ac_end",0); ASSETCHAINS_REWARD = GetArg("-ac_reward",0); ASSETCHAINS_HALVING = GetArg("-ac_halving",0); From 139aca9821e857775ba2962c5f8970e82667345b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 12 Sep 2018 21:22:05 +0800 Subject: [PATCH 0058/3904] Add smk762 --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 21d824f9e..f5eed2fb0 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -10,7 +10,7 @@ const char *notaries_STAKEDcc[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, + {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 15932378b..ddea06e2c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -27,7 +27,7 @@ const char *notaries_STAKED[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, + {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 From 2333d409375d4a1ab2d6b71aee4aeebf507ea735 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 12 Sep 2018 23:34:28 +0800 Subject: [PATCH 0059/3904] FIX STKD != STAKED --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index f5eed2fb0..6553b66d3 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -27,7 +27,7 @@ int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) + if (strlen(symbol) >= 6 && strncmp(symbol, "STKD", 4) == 0) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index ddea06e2c..618cecd5d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -247,7 +247,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( strncmp("STAKED",ASSETCHAINS_SYMBOL,6) == 0 ) + if ( strncmp("STKD",ASSETCHAINS_SYMBOL,4) == 0 ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Wed, 12 Sep 2018 23:51:25 +0800 Subject: [PATCH 0060/3904] Fix --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6553b66d3..af8f82b6f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -27,7 +27,7 @@ int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (strlen(symbol) >= 6 && strncmp(symbol, "STKD", 4) == 0) + if (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } From 55215da21811a10871eab3d45c28321dc5c481b9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 00:03:41 +0800 Subject: [PATCH 0061/3904] not sure --- src/crosschain_authority.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index af8f82b6f..e383272cb 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,24 +5,25 @@ const char *notaries_STAKEDcc[][2] = { - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, - {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, + {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. }; + int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) From 4aa70c42538d5f3898e570deba0d45e1e308dbd7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 02:07:47 +0800 Subject: [PATCH 0062/3904] put metaphillibert back in ... etf happened there LOL --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index e383272cb..ec8a286ce 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -16,7 +16,7 @@ const char *notaries_STAKEDcc[][2] = {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 618cecd5d..fd7e31864 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -33,7 +33,7 @@ const char *notaries_STAKED[][2] = {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. From a025b6f4e707c314a18de0667050101f757aea83 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 02:13:14 +0800 Subject: [PATCH 0063/3904] fix smk WTF?!? --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ec8a286ce..75bb3d516 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -10,7 +10,7 @@ const char *notaries_STAKEDcc[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 diff --git a/src/komodo_notary.h b/src/komodo_notary.h index fd7e31864..0c010a962 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -27,7 +27,7 @@ const char *notaries_STAKED[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 From bd2169b57dc5adcdc5276c3202724fe4e3d76988 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 12:37:28 +0800 Subject: [PATCH 0064/3904] Add some keys, and change to use STKD and STAKED. --- src/crosschain_authority.cpp | 7 +++---- src/komodo_notary.h | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 75bb3d516..13f27fb4c 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -9,7 +9,6 @@ const char *notaries_STAKEDcc[][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev @@ -19,16 +18,16 @@ const char *notaries_STAKEDcc[][2] = {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN }; - int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) + if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 0c010a962..1872d49ca 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -26,7 +26,6 @@ const char *notaries_STAKED[][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev @@ -36,7 +35,8 @@ const char *notaries_STAKED[][2] = {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN }; #define KOMODO_MAINNET_START 178999 @@ -247,7 +247,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( strncmp("STKD",ASSETCHAINS_SYMBOL,4) == 0 ) + if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Thu, 13 Sep 2018 13:50:47 +0800 Subject: [PATCH 0065/3904] fix stupid mistake --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1872d49ca..28797a003 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -247,7 +247,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) + if ( (strlen(ASSETCHAINS_SYMBOL) >= 4 && strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strlen(ASSETCHAINS_SYMBOL) >= 6 && strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Thu, 13 Sep 2018 19:10:52 +0800 Subject: [PATCH 0066/3904] remove one pubkey just incase --- src/crosschain_authority.cpp | 1 - src/komodo_notary.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 13f27fb4c..b6b6c22e7 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -13,7 +13,6 @@ const char *notaries_STAKEDcc[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 28797a003..05c7f0f42 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -30,7 +30,6 @@ const char *notaries_STAKED[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu From c0128ed414fda99c0b9193776a399e582dc0dea1 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Sat, 15 Sep 2018 14:17:18 +0800 Subject: [PATCH 0067/3904] fix issue where if there are not two notarisations the MoMoM is indeterninate --- src/crosschain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 76771b186..16fc5e854 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -80,6 +80,11 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh } } } + + // Not enough own notarisations found to return determinate MoMoM + destNotarisationTxid = uint256(); + moms.clear(); + return uint256(); end: return GetMerkleRoot(moms); From 1444ed4e2d92d3d74e5f01a27ac01f2652127b83 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 19 Sep 2018 14:51:41 +0800 Subject: [PATCH 0068/3904] add print of MoMoM data each time it is called. --- src/cc/import.cpp | 6 +++--- src/crosschain.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index ffc94ac43..988264aa6 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -37,7 +37,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!UnmarshalImportTx(importTx, proof, burnTx, payouts)) return Invalid("invalid-params"); - + // Control all aspects of this transaction // It should not be at all malleable if (MakeImportCoinTransaction(proof, burnTx, payouts).GetHash() != importTx.GetHash()) @@ -79,6 +79,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); + printf("momom: %s\n", momom.GetHex().data()) + target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) return Invalid("momom-check-fail"); @@ -86,5 +88,3 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp return Valid(); } - - diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 8d886ece6..97e6d9823 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -80,7 +80,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh } } } - + // Not enough own notarisations found to return determinate MoMoM destNotarisationTxid = uint256(); moms.clear(); @@ -162,6 +162,8 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); + printf("momom: %s\n", MoMoM.GetHex().data()) + // Find index of source MoM in MoMoM int nIndex; for (nIndex=0; nIndex Date: Wed, 19 Sep 2018 14:52:22 +0800 Subject: [PATCH 0069/3904] ; --- src/cc/import.cpp | 4 ++-- src/crosschain.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 988264aa6..7224c40cd 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,8 +79,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("momom: %s\n", momom.GetHex().data()) - + printf("momom: %s\n", momom.GetHex().data()); + target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) return Invalid("momom-check-fail"); diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 97e6d9823..82d4be193 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,8 +162,8 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("momom: %s\n", MoMoM.GetHex().data()) - + printf("momom: %s\n", MoMoM.GetHex().data()); + // Find index of source MoM in MoMoM int nIndex; for (nIndex=0; nIndex Date: Wed, 19 Sep 2018 15:31:09 +0800 Subject: [PATCH 0070/3904] make it so prints are diffrent. --- src/cc/import.cpp | 2 +- src/crosschain.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 7224c40cd..cc0c3b61f 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,7 +79,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("momom: %s\n", momom.GetHex().data()); + printf("IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 82d4be193..23416c682 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,7 +162,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("momom: %s\n", MoMoM.GetHex().data()); + printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); // Find index of source MoM in MoMoM int nIndex; From d1b74ce6d19ecfad8a2e4ac404e27a43bef20e1b Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Wed, 19 Sep 2018 18:50:38 +0200 Subject: [PATCH 0071/3904] hard fork mandatory update --- src/komodo_notary.h | 3 +++ src/version.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c2645b3f2..e0851b209 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -36,6 +36,9 @@ const char *notaries_STAKED[][2] = {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; #define KOMODO_MAINNET_START 178999 diff --git a/src/version.h b/src/version.h index 25527895d..1efbecdf8 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170003; +static const int PROTOCOL_VERSION = 170004; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -18,7 +18,7 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170002; +static const int MIN_PEER_PROTO_VERSION = 170004; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 3a9b05001400575cd6f54deca233ac12d84873fb Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Wed, 19 Sep 2018 18:52:22 +0200 Subject: [PATCH 0072/3904] whoops --- src/crosschain_authority.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b6b6c22e7..d635e6e22 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,6 +19,9 @@ const char *notaries_STAKEDcc[][2] = {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; From c2059876c3a13c60d4d41c0c31b0e2417dd005af Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Wed, 19 Sep 2018 13:38:33 -0400 Subject: [PATCH 0073/3904] Update version.h --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 1efbecdf8..25527895d 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170004; +static const int PROTOCOL_VERSION = 170003; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -18,7 +18,7 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170004; +static const int MIN_PEER_PROTO_VERSION = 170002; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 3330881171f284e9edc2b578e681237f551aedd3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 20 Sep 2018 22:44:41 +0800 Subject: [PATCH 0074/3904] Use min sigs = 3 for staked chains, so we can add more pubkeys. --- src/crosschain_authority.cpp | 2 +- src/komodo.h | 5 +++-- src/komodo_notary.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b6b6c22e7..30e4e725a 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -73,7 +73,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); - auth.requiredSigs = (auth.size/5); + auth.requiredSigs = 3; for (int n=0; n= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5)) ) + numvalid > (numnotaries/5)) || + ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 3 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c2645b3f2..c2e7ed631 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -246,7 +246,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( (strlen(ASSETCHAINS_SYMBOL) >= 4 && strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strlen(ASSETCHAINS_SYMBOL) >= 6 && strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Thu, 20 Sep 2018 23:15:00 +0800 Subject: [PATCH 0075/3904] Change min protcol version so STAKED chains have their own value, so KMD can still work. --- src/main.cpp | 1128 +++++++++++++++++++++++++------------------------ src/version.h | 3 +- 2 files changed, 573 insertions(+), 558 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4edb4f604..73a1ff364 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,30 +114,30 @@ const string strMessageMagic = "Komodo Signed Message:\n"; // Internal stuff namespace { - + struct CBlockIndexWorkComparator { bool operator()(CBlockIndex *pa, CBlockIndex *pb) const { // First sort by most total work, ... if (pa->nChainWork > pb->nChainWork) return false; if (pa->nChainWork < pb->nChainWork) return true; - + // ... then by earliest time received, ... if (pa->nSequenceId < pb->nSequenceId) return false; if (pa->nSequenceId > pb->nSequenceId) return true; - + // Use pointer address as tie breaker (should only happen with blocks // loaded from disk, as those all have id 0). if (pa < pb) return false; if (pa > pb) return true; - + // Identical blocks. return false; } }; - + CBlockIndex *pindexBestInvalid; - + /** * The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and * as good as our current tip or better. Entries may be failed, though, and pruning nodes may be @@ -150,7 +150,7 @@ namespace { * Pruned nodes may have entries where B is missing data. */ multimap mapBlocksUnlinked; - + CCriticalSection cs_LastBlockFile; std::vector vinfoBlockFile; int nLastBlockFile = 0; @@ -159,7 +159,7 @@ namespace { * or if we allocate more file space when we're in prune mode */ bool fCheckForPruning = false; - + /** * Every received block is assigned a unique and increasing identifier, so we * know which one to give priority in case of a fork. @@ -167,14 +167,14 @@ namespace { CCriticalSection cs_nBlockSequenceId; /** Blocks loaded from disk are assigned id 0, so start the counter at 1. */ uint32_t nBlockSequenceId = 1; - + /** * Sources of received blocks, saved to be able to send them reject * messages or ban them when processing happens afterwards. Protected by * cs_main. */ map mapBlockSource; - + /** * Filter for transactions that were recently rejected by * AcceptToMemoryPool. These are not rerequested until the chain tip @@ -197,7 +197,7 @@ namespace { */ boost::scoped_ptr recentRejects; uint256 hashRecentRejectsChainTip; - + /** Blocks that are in flight, and that are in the queue to be downloaded. Protected by cs_main. */ struct QueuedBlock { uint256 hash; @@ -207,16 +207,16 @@ namespace { int64_t nTimeDisconnect; //! The timeout for this block request (for disconnecting a slow peer) }; map::iterator> > mapBlocksInFlight; - + /** Number of blocks in flight with validated headers. */ int nQueuedValidatedHeaders = 0; - + /** Number of preferable block download peers. */ int nPreferredDownload = 0; - + /** Dirty block index entries. */ set setDirtyBlockIndex; - + /** Dirty block file entries. */ set setDirtyFileInfo; } // anon namespace @@ -227,13 +227,13 @@ namespace { // namespace { - + struct CBlockReject { unsigned char chRejectCode; string strRejectReason; uint256 hashBlock; }; - + /** * Maintain validation-specific state about nodes, protected by cs_main, instead * by CNode's own locks. This simplifies asynchronous operation, where @@ -268,7 +268,7 @@ namespace { int nBlocksInFlightValidHeaders; //! Whether we consider this a preferred download peer. bool fPreferredDownload; - + CNodeState() { fCurrentlyConnected = false; nMisbehavior = 0; @@ -283,10 +283,10 @@ namespace { fPreferredDownload = false; } }; - + /** Map maintaining per-node state. Requires cs_main. */ map mapNodeState; - + // Requires cs_main. CNodeState *State(NodeId pnode) { map::iterator it = mapNodeState.find(pnode); @@ -294,67 +294,67 @@ namespace { return NULL; return &it->second; } - + int GetHeight() { LOCK(cs_main); return chainActive.Height(); } - + void UpdatePreferredDownload(CNode* node, CNodeState* state) { nPreferredDownload -= state->fPreferredDownload; - + // Whether this node should be marked as a preferred download node. state->fPreferredDownload = (!node->fInbound || node->fWhitelisted) && !node->fOneShot && !node->fClient; - + nPreferredDownload += state->fPreferredDownload; } - + // Returns time at which to timeout block request (nTime in microseconds) int64_t GetBlockTimeout(int64_t nTime, int nValidatedQueuedBefore, const Consensus::Params &consensusParams) { return nTime + 500000 * consensusParams.nPowTargetSpacing * (4 + nValidatedQueuedBefore); } - + void InitializeNode(NodeId nodeid, const CNode *pnode) { LOCK(cs_main); CNodeState &state = mapNodeState.insert(std::make_pair(nodeid, CNodeState())).first->second; state.name = pnode->addrName; state.address = pnode->addr; } - + void FinalizeNode(NodeId nodeid) { LOCK(cs_main); CNodeState *state = State(nodeid); - + if (state->fSyncStarted) nSyncStarted--; - + if (state->nMisbehavior == 0 && state->fCurrentlyConnected) { AddressCurrentlyConnected(state->address); } - + BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight) mapBlocksInFlight.erase(entry.hash); EraseOrphansFor(nodeid); nPreferredDownload -= state->fPreferredDownload; - + mapNodeState.erase(nodeid); } - + void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) { /* int expired = pool.Expire(GetTime() - age); if (expired != 0) LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired); - + std::vector vNoSpendsRemaining; pool.TrimToSize(limit, &vNoSpendsRemaining); BOOST_FOREACH(const uint256& removed, vNoSpendsRemaining) pcoinsTip->Uncache(removed);*/ } - + // Requires cs_main. // Returns a bool indicating whether we requested this block. bool MarkBlockAsReceived(const uint256& hash) { @@ -371,15 +371,15 @@ namespace { } return false; } - + // Requires cs_main. void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Params& consensusParams, CBlockIndex *pindex = NULL) { CNodeState *state = State(nodeid); assert(state != NULL); - + // Make sure it's not listed somewhere already. MarkBlockAsReceived(hash); - + int64_t nNow = GetTimeMicros(); QueuedBlock newentry = {hash, pindex, nNow, pindex != NULL, GetBlockTimeout(nNow, nQueuedValidatedHeaders, consensusParams)}; nQueuedValidatedHeaders += newentry.fValidatedHeaders; @@ -388,12 +388,12 @@ namespace { state->nBlocksInFlightValidHeaders += newentry.fValidatedHeaders; mapBlocksInFlight[hash] = std::make_pair(nodeid, it); } - + /** Check whether the last unknown block a peer advertized is not yet known. */ void ProcessBlockAvailability(NodeId nodeid) { CNodeState *state = State(nodeid); assert(state != NULL); - + if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) @@ -404,14 +404,14 @@ namespace { } } } - + /** Update tracking information about which blocks a peer is assumed to have. */ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { CNodeState *state = State(nodeid); assert(state != NULL); - + /*ProcessBlockAvailability(nodeid); - + BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. @@ -423,7 +423,7 @@ namespace { state->hashLastUnknownBlock = hash; } } - + /** Find the last common ancestor two blocks have. * Both pa and pb must be non-NULL. */ CBlockIndex* LastCommonAncestor(CBlockIndex* pa, CBlockIndex* pb) { @@ -432,47 +432,47 @@ namespace { } else if (pb->nHeight > pa->nHeight) { pb = pb->GetAncestor(pa->nHeight); } - + while (pa != pb && pa && pb) { pa = pa->pprev; pb = pb->pprev; } - + // Eventually all chain branches meet at the genesis block. assert(pa == pb); return pa; } - + /** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has * at most count entries. */ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector& vBlocks, NodeId& nodeStaller) { if (count == 0) return; - + vBlocks.reserve(vBlocks.size() + count); CNodeState *state = State(nodeid); assert(state != NULL); - + // Make sure pindexBestKnownBlock is up to date, we'll need it. ProcessBlockAvailability(nodeid); - + if (state->pindexBestKnownBlock == NULL || state->pindexBestKnownBlock->nChainWork < chainActive.Tip()->nChainWork) { // This peer has nothing interesting. return; } - + if (state->pindexLastCommonBlock == NULL) { // Bootstrap quickly by guessing a parent of our best tip is the forking point. // Guessing wrong in either direction is not a problem. state->pindexLastCommonBlock = chainActive[std::min(state->pindexBestKnownBlock->nHeight, chainActive.Height())]; } - + // If the peer reorganized, our previous pindexLastCommonBlock may not be an ancestor // of its current tip anymore. Go back enough to fix that. state->pindexLastCommonBlock = LastCommonAncestor(state->pindexLastCommonBlock, state->pindexBestKnownBlock); if (state->pindexLastCommonBlock == state->pindexBestKnownBlock) return; - + std::vector vToFetch; CBlockIndex *pindexWalk = state->pindexLastCommonBlock; // Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last @@ -492,7 +492,7 @@ namespace { for (unsigned int i = nToFetch - 1; i > 0; i--) { vToFetch[i - 1] = vToFetch[i]->pprev; } - + // Iterate over those blocks in vToFetch (in forward direction), adding the ones that // are not yet downloaded and not in flight to vBlocks. In the meantime, update // pindexLastCommonBlock as long as all ancestors are already downloaded, or if it's @@ -526,7 +526,7 @@ namespace { } } } - + } // anon namespace bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) { @@ -616,7 +616,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c uint256 hash = tx.GetHash(); if (mapOrphanTransactions.count(hash)) return false; - + // Ignore big transactions, to avoid a // send-big-orphans memory exhaustion attack. If a peer has a legitimate // large transaction with a missing parent then we assume @@ -630,12 +630,12 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c LogPrint("mempool", "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString()); return false; } - + mapOrphanTransactions[hash].tx = tx; mapOrphanTransactions[hash].fromPeer = peer; BOOST_FOREACH(const CTxIn& txin, tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); - + LogPrint("mempool", "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(), mapOrphanTransactions.size(), mapOrphanTransactionsByPrev.size()); return true; @@ -695,7 +695,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRE bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) { bool isOverwinter = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - + if (isOverwinter) { // Overwinter standard rules apply if (tx.nVersion > CTransaction::OVERWINTER_MAX_CURRENT_VERSION || tx.nVersion < CTransaction::OVERWINTER_MIN_CURRENT_VERSION) { @@ -709,7 +709,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) return false; } } - + BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed @@ -728,7 +728,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) return false; } } - + unsigned int v=0,nDataOut = 0; txnouttype whichType; BOOST_FOREACH(const CTxOut& txout, tx.vout) @@ -739,7 +739,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) //fprintf(stderr,">>>>>>>>>>>>>>> vout.%d nDataout.%d\n",v,nDataOut); return false; } - + if (whichType == TX_NULL_DATA) { if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE ) @@ -759,13 +759,13 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) } v++; } - + // only one OP_RETURN txout is permitted if (nDataOut > 1) { reason = "multi-op-return"; return false; } - + return true; } @@ -780,7 +780,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) { if ( txin.nSequence == 0xfffffffe && (((int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime > nBlockTime) || ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime > nBlockHeight)) ) { - + } else if (!txin.IsFinal()) { @@ -802,7 +802,7 @@ bool IsExpiredTx(const CTransaction &tx, int nBlockHeight) bool CheckFinalTx(const CTransaction &tx, int flags) { AssertLockHeld(cs_main); - + // By convention a negative value for flags indicates that the // current network-enforced consensus rules should be used. In // a future soft-fork scenario that would mean checking which @@ -810,7 +810,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) // appropriate flags. At the present time no soft-forks are // scheduled, so no flags are set. flags = std::max(flags, 0); - + // CheckFinalTx() uses chainActive.Height()+1 to evaluate // nLockTime because when IsFinalTx() is called within // CBlock::AcceptBlock(), the height of the block *being* @@ -818,7 +818,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) // transaction can be part of the *next* block, we need to call // IsFinalTx() with one more than chainActive.Height(). const int nBlockHeight = chainActive.Height() + 1; - + // Timestamps on the other hand don't get any special treatment, // because we can't know what timestamp the next block will have, // and there aren't timestamp applications where it matters. @@ -826,7 +826,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) const int64_t nBlockTime = (flags & LOCKTIME_MEDIAN_TIME_PAST) ? chainActive.Tip()->GetMedianTimePast() : GetAdjustedTime(); - + return IsFinalTx(tx, nBlockHeight, nBlockTime); } @@ -850,7 +850,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxOut& prev = mapInputs.GetOutputFor(tx.vin[i]); - + vector > vSolutions; txnouttype whichType; // get the scriptPubKey corresponding to this input: @@ -860,7 +860,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions); if (nArgsExpected < 0) return false; - + // Transactions with extra stuff in their scriptSigs are // non-standard. Note that this EvalScript() call will // be quick, because if there are any operations @@ -870,7 +870,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, vector > stack; if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), consensusBranchId)) return false; - + if (whichType == TX_SCRIPTHASH) { if (stack.empty()) @@ -893,11 +893,11 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, return (sigops <= MAX_P2SH_SIGOPS); } } - + if (stack.size() != (unsigned int)nArgsExpected) return false; } - + return true; } @@ -919,7 +919,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in { if (tx.IsCoinBase() || tx.IsCoinImport()) return 0; - + unsigned int nSigOps = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) { @@ -942,13 +942,13 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, { bool isOverwinter = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); bool isSprout = !isOverwinter; - + // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond if (isSprout && tx.fOverwintered) { return state.DoS(dosLevel, error("ContextualCheckTransaction(): overwinter is not active yet"), REJECT_INVALID, "tx-overwinter-not-active"); } - + // If Overwinter rules apply: if (isOverwinter) { // Reject transactions with valid version but missing overwinter flag @@ -956,19 +956,19 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, return state.DoS(dosLevel, error("ContextualCheckTransaction(): overwinter flag must be set"), REJECT_INVALID, "tx-overwinter-flag-not-set"); } - + // Reject transactions with invalid version if (tx.fOverwintered && tx.nVersion > OVERWINTER_MAX_TX_VERSION ) { return state.DoS(100, error("CheckTransaction(): overwinter version too high"), REJECT_INVALID, "bad-tx-overwinter-version-too-high"); } - + // Reject transactions intended for Sprout if (!tx.fOverwintered) { return state.DoS(dosLevel, error("ContextualCheckTransaction: overwinter is active"), REJECT_INVALID, "tx-overwinter-active"); } - + // Check that all transactions are unexpired if (IsExpiredTx(tx, nHeight)) { return state.DoS(dosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired"); @@ -986,9 +986,9 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, return state.DoS(100, error("CheckTransaction(): error computing signature hash"), REJECT_INVALID, "error-computing-signature-hash"); } - + BOOST_STATIC_ASSERT(crypto_sign_PUBLICKEYBYTES == 32); - + // We rely on libsodium to check that the signature is canonical. // https://github.com/jedisct1/libsodium/commit/62911edb7ff2275cccd74bf1c8aefcc4d76924e0 if (crypto_sign_verify_detached(&tx.joinSplitSig[0], @@ -1026,7 +1026,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, if (!tx.IsCoinBase()) { transactionsValidated.increment(); } - + if (!CheckTransactionWithoutProofVerification(tx, state)) { return false; } else { @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state) { // Basic checks that don't depend on any context - + /** * Previously: * 1. The consensus rule below was: @@ -1085,7 +1085,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio REJECT_INVALID, "bad-tx-expiry-height-too-high"); } } - + // Transactions can contain empty `vin` and `vout` so long as // `vjoinsplit` is non-empty. // Migrations may also have empty `vin` @@ -1095,13 +1095,13 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio if (tx.vout.empty() && tx.vjoinsplit.empty()) return state.DoS(10, error("CheckTransaction(): vout empty"), REJECT_INVALID, "bad-txns-vout-empty"); - + // Size limits BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE > MAX_TX_SIZE); // sanity if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE) return state.DoS(100, error("CheckTransaction(): size limits failed"), REJECT_INVALID, "bad-txns-oversize"); - + // Check for negative or overflow output values CAmount nValueOut = 0; int32_t iscoinbase = tx.IsCoinBase(); @@ -1128,7 +1128,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio return state.DoS(100, error("CheckTransaction(): txout total out of range"), REJECT_INVALID, "bad-txns-txouttotal-toolarge"); } - + // Ensure that joinsplit values are well-formed BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) { @@ -1141,34 +1141,34 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_old negative"), REJECT_INVALID, "bad-txns-vpub_old-negative"); } - + if (joinsplit.vpub_new < 0) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_new negative"), REJECT_INVALID, "bad-txns-vpub_new-negative"); } - + if (joinsplit.vpub_old > MAX_MONEY) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_old too high"), REJECT_INVALID, "bad-txns-vpub_old-toolarge"); } - + if (joinsplit.vpub_new > MAX_MONEY) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_new too high"), REJECT_INVALID, "bad-txns-vpub_new-toolarge"); } - + if (joinsplit.vpub_new != 0 && joinsplit.vpub_old != 0) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_new and joinsplit.vpub_old both nonzero"), REJECT_INVALID, "bad-txns-vpubs-both-nonzero"); } - + nValueOut += joinsplit.vpub_old; if (!MoneyRange(nValueOut)) { return state.DoS(100, error("CheckTransaction(): txout total out of range"), REJECT_INVALID, "bad-txns-txouttotal-toolarge"); } } - + // Ensure input values do not exceed MAX_MONEY // We have not resolved the txin values at this stage, // but we do know what the joinsplits claim to add @@ -1178,15 +1178,15 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio for (std::vector::const_iterator it(tx.vjoinsplit.begin()); it != tx.vjoinsplit.end(); ++it) { nValueIn += it->vpub_new; - + if (!MoneyRange(it->vpub_new) || !MoneyRange(nValueIn)) { return state.DoS(100, error("CheckTransaction(): txin total out of range"), REJECT_INVALID, "bad-txns-txintotal-toolarge"); } } } - - + + // Check for duplicate inputs set vInOutPoints; BOOST_FOREACH(const CTxIn& txin, tx.vin) @@ -1196,7 +1196,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio REJECT_INVALID, "bad-txns-inputs-duplicate"); vInOutPoints.insert(txin.prevout); } - + // Check for duplicate joinsplit nullifiers in this transaction set vJoinSplitNullifiers; BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) @@ -1206,18 +1206,18 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio if (vJoinSplitNullifiers.count(nf)) return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"), REJECT_INVALID, "bad-joinsplits-nullifiers-duplicate"); - + vJoinSplitNullifiers.insert(nf); } } - + if (tx.IsMint()) { // There should be no joinsplits in a coinbase transaction if (tx.vjoinsplit.size() > 0) return state.DoS(100, error("CheckTransaction(): coinbase has joinsplits"), REJECT_INVALID, "bad-cb-has-joinsplits"); - + if (tx.vin[0].scriptSig.size() < 2 || tx.vin[0].scriptSig.size() > 100) return state.DoS(100, error("CheckTransaction(): coinbase script size"), REJECT_INVALID, "bad-cb-length"); @@ -1229,7 +1229,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio return state.DoS(10, error("CheckTransaction(): prevout is null"), REJECT_INVALID, "bad-txns-prevout-null"); } - + return true; } @@ -1245,9 +1245,9 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF if (dPriorityDelta > 0 || nFeeDelta > 0) return 0; } - + CAmount nMinFee = ::minRelayTxFee.GetFee(nBytes); - + if (fAllowFree) { // There is a free transaction area in blocks created by most miners, @@ -1257,7 +1257,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF if (nBytes < (DEFAULT_BLOCK_PRIORITY_SIZE - 1000)) nMinFee = 0; } - + if (!MoneyRange(nMinFee)) nMinFee = MAX_MONEY; return nMinFee; @@ -1269,10 +1269,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa AssertLockHeld(cs_main); if (pfMissingInputs) *pfMissingInputs = false; - + int flag=0,nextBlockHeight = chainActive.Height() + 1; auto consensusBranchId = CurrentEpochBranchId(nextBlockHeight, Params().GetConsensus()); - + // Node operator can choose to reject tx by number of transparent inputs static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "size_t too small"); size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); @@ -1283,7 +1283,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } - + auto verifier = libzcash::ProofVerifier::Strict(); if ( komodo_validate_interest(tx,chainActive.LastTip()->nHeight+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 ) { @@ -1300,7 +1300,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } - + // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) { @@ -1329,7 +1329,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"already in mempool\n"); return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); } - + // Check for conflicts with in-memory transactions { LOCK(pool.cs); // protect pool.mapNextTx @@ -1357,7 +1357,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } - + { CCoinsView dummy; CCoinsViewCache view(&dummy); @@ -1367,14 +1367,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa LOCK(pool.cs); CCoinsViewMemPool viewMemPool(pcoinsTip, pool); view.SetBackend(viewMemPool); - + // do we already have it? if (view.HaveCoins(hash)) { //fprintf(stderr,"view.HaveCoins(hash) error\n"); return state.Invalid(false, REJECT_DUPLICATE, "already have coins"); } - + if (tx.IsCoinImport()) { // Inverse of normal case; if input exists, it's been spent @@ -1396,7 +1396,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } - + // are the actual inputs available? if (!view.HaveInputs(tx)) { @@ -1410,21 +1410,21 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"accept failure.2\n"); return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met"); } - + // Bring the best block into scope view.GetBestBlock(); - + nValueIn = view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime); if ( 0 && interest != 0 ) fprintf(stderr,"add interest %.8f\n",(double)interest/COIN); // we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool view.SetBackend(dummy); } - + // Check for non-standard pay-to-script-hash in inputs if (Params().RequireStandard() && !AreInputsStandard(tx, view, consensusBranchId)) return error("AcceptToMemoryPool: reject nonstandard transaction input"); - + // Check that the transaction doesn't have an excessive number of // sigops, making it impossible to mine. Since the coinbase transaction // itself can contain sigops MAX_STANDARD_TX_SIGOPS is less than @@ -1437,11 +1437,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa fprintf(stderr,"accept failure.4\n"); return state.DoS(0, error("AcceptToMemoryPool: too many sigops %s, %d > %d", hash.ToString(), nSigOps, MAX_STANDARD_TX_SIGOPS),REJECT_NONSTANDARD, "bad-txns-too-many-sigops"); } - + CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; double dPriority = view.GetPriority(tx, chainActive.Height()); - + // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; @@ -1454,15 +1454,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } - + // Grab the branch ID we expect this transaction to commit to. We don't // yet know if it does, but if the entry gets added to the mempool, then // it has passed ContextualCheckInputs and therefore this is correct. auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - + CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), mempool.HasNoInputsOf(tx), fSpendsCoinbase, consensusBranchId); unsigned int nSize = entry.GetTxSize(); - + // Accept a tx if it contains joinsplits and has at least the default fee specified by z_sendmany. if (tx.vjoinsplit.size() > 0 && nFees >= ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE) { // In future we will we have more accurate and dynamic computation of fees for tx with joinsplits. @@ -1475,13 +1475,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return state.DoS(0, error("AcceptToMemoryPool: not enough fees %s, %d < %d",hash.ToString(), nFees, txMinFee),REJECT_INSUFFICIENTFEE, "insufficient fee"); } } - + // Require that free transactions have sufficient priority to be mined in the next block. if (GetBoolArg("-relaypriority", false) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) { fprintf(stderr,"accept failure.6\n"); return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority"); } - + // Continuously rate-limit free (really, very-low-fee) transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. @@ -1491,9 +1491,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa static double dFreeCount; static int64_t nLastTime; int64_t nNow = GetTime(); - + LOCK(csFreeLimiter); - + // Use an exponentially decaying ~10-minute window: dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); nLastTime = nNow; @@ -1507,13 +1507,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); dFreeCount += nSize; } - + if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > nValueOut/19 ) { fprintf(stderr,"accept failure.8\n"); return error("AcceptToMemoryPool: absurdly high fees %s, %d > %d",hash.ToString(), nFees, ::minRelayTxFee.GetFee(nSize) * 10000); } - + // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. PrecomputedTransactionData txdata(tx); @@ -1522,7 +1522,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"accept failure.9\n"); return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString()); } - + // Check again against just the consensus-critical mandatory script // verification flags, in case of bugs in the standard flags that cause // transactions to pass as valid when they're actually invalid. For @@ -1565,9 +1565,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } - + SyncWithWallets(tx, NULL); - + return true; } @@ -1685,14 +1685,14 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow) { CBlockIndex *pindexSlow = NULL; - + LOCK(cs_main); - + if (mempool.lookup(hash, txOut)) { return true; } - + if (fTxIndex) { CDiskTxPos postx; if (pblocktree->ReadTxIndex(hash, postx)) { @@ -1713,7 +1713,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock return true; } } - + if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it int nHeight = -1; { @@ -1725,7 +1725,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock if (nHeight > 0) pindexSlow = chainActive[nHeight]; } - + if (pindexSlow) { CBlock block; if (ReadBlockFromDisk(block, pindexSlow,1)) { @@ -1738,7 +1738,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock } } } - + return false; } @@ -1768,18 +1768,18 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::M CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION); if (fileout.IsNull()) return error("WriteBlockToDisk: OpenBlockFile failed"); - + // Write index header unsigned int nSize = fileout.GetSerializeSize(block); fileout << FLATDATA(messageStart) << nSize; - + // Write block long fileOutPos = ftell(fileout.Get()); if (fileOutPos < 0) return error("WriteBlockToDisk: ftell failed"); pos.nPos = (unsigned int)fileOutPos; fileout << block; - + return true; } @@ -1787,7 +1787,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos,bo { uint8_t pubkey33[33]; block.SetNull(); - + // Open history file to read CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION); if (filein.IsNull()) @@ -1795,7 +1795,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos,bo //fprintf(stderr,"readblockfromdisk err A\n"); return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString()); } - + // Read block try { filein >> block; @@ -1813,7 +1813,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos,bo int32_t i; for (i=0; i<33; i++) fprintf(stderr,"%02x",pubkey33[i]); fprintf(stderr," warning unexpected diff at ht.%d\n",height); - + return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); } } @@ -1911,14 +1911,14 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) nSubsidy *= (nHeight+1); return nSubsidy; } - + assert(nHeight > consensusParams.SubsidySlowStartShift()); int halvings = (nHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nSubsidyHalvingInterval;*/ // Force block reward to zero when right shift is undefined. //int halvings = nHeight / consensusParams.nSubsidyHalvingInterval; //if (halvings >= 64) // return 0; - + // Subsidy is cut in half every 840,000 blocks which will occur approximately every 4 years. //nSubsidy >>= halvings; return nSubsidy; @@ -1972,12 +1972,12 @@ void CheckForkWarningConditions() // (we assume we don't get stuck on a fork before the last checkpoint) if (IsInitialBlockDownload()) return; - + // If our best fork is no longer within 288 blocks (+/- 12 hours if no one mines it) // of our head, drop it if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->nHeight >= 288) pindexBestForkTip = NULL; - + if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.LastTip()->nChainWork + (GetBlockProof(*chainActive.LastTip()) * 6))) { if (!fLargeWorkForkFound && pindexBestForkBase) @@ -2022,7 +2022,7 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) break; pfork = pfork->pprev; } - + // We define a condition where we should warn the user about as a fork of at least 7 blocks // with a tip within 72 blocks (+/- 3 hours if no one mines it) of ours // We use 7 blocks rather arbitrarily as it represents just under 10% of sustained network @@ -2037,7 +2037,7 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) pindexBestForkTip = pindexNewForkTip; pindexBestForkBase = pfork; } - + CheckForkWarningConditions(); } @@ -2046,11 +2046,11 @@ void Misbehaving(NodeId pnode, int howmuch) { if (howmuch == 0) return; - + CNodeState *state = State(pnode); if (state == NULL) return; - + state->nMisbehavior += howmuch; int banscore = GetArg("-banscore", 101); if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore) @@ -2065,7 +2065,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew) { if (!pindexBestInvalid || pindexNew->nChainWork > pindexBestInvalid->nChainWork) pindexBestInvalid = pindexNew; - + LogPrintf("%s: invalid block=%s height=%d log2_work=%.8g date=%s\n", __func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", @@ -2105,7 +2105,7 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund BOOST_FOREACH(const CTxIn &txin, tx.vin) { CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash); unsigned nPos = txin.prevout.n; - + if (nPos >= coins->vout.size() || coins->vout[nPos].IsNull()) assert(false); // mark an outpoint spent, and construct undo information @@ -2125,7 +2125,7 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund } } inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight); // add outputs - + // Unorthodox state if (tx.IsCoinImport()) { // add a tombstone for the burnTx @@ -2163,11 +2163,11 @@ namespace Consensus { // for an attacker to attempt to split the network. if (!inputs.HaveInputs(tx)) return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetHash().ToString())); - + // are the JoinSplit's requirements met? if (!inputs.HaveJoinSplitRequirements(tx)) return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetHash().ToString())); - + CAmount nValueIn = 0; CAmount nFees = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) @@ -2175,7 +2175,7 @@ namespace Consensus { const COutPoint &prevout = tx.vin[i].prevout; const CCoins *coins = inputs.AccessCoins(prevout.hash); assert(coins); - + if (coins->IsCoinBase()) { // Ensure that coinbases are matured if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { @@ -2183,7 +2183,7 @@ namespace Consensus { error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight), REJECT_INVALID, "bad-txns-premature-spend-of-coinbase"); } - + // Ensure that coinbases cannot be spent to transparent outputs // Disabled on regtest if (fCoinbaseEnforcedProtectionEnabled && @@ -2194,7 +2194,7 @@ namespace Consensus { REJECT_INVALID, "bad-txns-coinbase-spend-has-transparent-outputs"); } } - + // Check for negative or overflow input values nValueIn += coins->vout[prevout.n].nValue; #ifdef KOMODO_ENABLE_INTEREST @@ -2214,14 +2214,14 @@ namespace Consensus { if (!MoneyRange(coins->vout[prevout.n].nValue) || !MoneyRange(nValueIn)) return state.DoS(100, error("CheckInputs(): txin values out of range"), REJECT_INVALID, "bad-txns-inputvalues-outofrange"); - + } - + nValueIn += tx.GetJoinSplitValueIn(); if (!MoneyRange(nValueIn)) return state.DoS(100, error("CheckInputs(): vpub_old values out of range"), REJECT_INVALID, "bad-txns-inputvalues-outofrange"); - + if (nValueIn < tx.GetValueOut()) { fprintf(stderr,"spentheight.%d valuein %s vs %s error\n",nSpendHeight,FormatMoney(nValueIn).c_str(), FormatMoney(tx.GetValueOut()).c_str()); @@ -2258,14 +2258,14 @@ bool ContextualCheckInputs( if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs), consensusParams)) { return false; } - + if (pvChecks) pvChecks->reserve(tx.vin.size()); - + // The first loop above does all the inexpensive checks. // Only if ALL inputs pass do we perform expensive ECDSA signature checks. // Helps prevent CPU exhaustion attacks. - + // Skip ECDSA signature verification when connecting blocks // before the last block chain checkpoint. This is safe because block merkle hashes are // still computed and checked, and any change will be caught at the next checkpoint. @@ -2274,7 +2274,7 @@ bool ContextualCheckInputs( const COutPoint &prevout = tx.vin[i].prevout; const CCoins* coins = inputs.AccessCoins(prevout.hash); assert(coins); - + // Verify signature CScriptCheck check(*coins, tx, i, flags, cacheStore, consensusBranchId, &txdata); if (pvChecks) { @@ -2322,7 +2322,7 @@ bool ContextualCheckInputs( fprintf(stderr,"ContextualCheckInputs failure.0\n"); return false; } - + if (!tx.IsCoinBase()) { // While checking, GetBestBlock() refers to the parent block. @@ -2336,60 +2336,60 @@ bool ContextualCheckInputs( // Assertion is okay because NonContextualCheckInputs ensures the inputs // are available. assert(coins); - + // If prev is coinbase, check that it's matured if (coins->IsCoinBase()) { if ( ASSETCHAINS_SYMBOL[0] == 0 ) COINBASE_MATURITY = _COINBASE_MATURITY; if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { fprintf(stderr,"ContextualCheckInputs failure.1 i.%d of %d\n",i,(int32_t)tx.vin.size()); - + return state.Invalid( error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight),REJECT_INVALID, "bad-txns-premature-spend-of-coinbase"); } } } } - + return true; }*/ namespace { - + bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart) { // Open history file to append CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION); if (fileout.IsNull()) return error("%s: OpenUndoFile failed", __func__); - + // Write index header unsigned int nSize = fileout.GetSerializeSize(blockundo); fileout << FLATDATA(messageStart) << nSize; - + // Write undo data long fileOutPos = ftell(fileout.Get()); if (fileOutPos < 0) return error("%s: ftell failed", __func__); pos.nPos = (unsigned int)fileOutPos; fileout << blockundo; - + // calculate & write checksum CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION); hasher << hashBlock; hasher << blockundo; fileout << hasher.GetHash(); - + return true; } - + bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock) { // Open history file to read CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION); if (filein.IsNull()) return error("%s: OpenBlockFile failed", __func__); - + // Read block uint256 hashChecksum; try { @@ -2405,10 +2405,10 @@ namespace { hasher << blockundo; if (hashChecksum != hasher.GetHash()) return error("%s: Checksum mismatch", __func__); - + return true; } - + /** Abort with a message */ bool AbortNode(const std::string& strMessage, const std::string& userMessage="") { @@ -2420,13 +2420,13 @@ namespace { StartShutdown(); return false; } - + bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="") { AbortNode(strMessage, userMessage); return state.Error(strMessage); } - + } // anon namespace /** @@ -2439,7 +2439,7 @@ namespace { static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint& out) { bool fClean = true; - + CCoinsModifier coins = view.ModifyCoins(out.hash); if (undo.nHeight != 0) { // undo data contains height: this is the last output of the prevout tx being spent @@ -2458,7 +2458,7 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const CO if (coins->vout.size() < out.n+1) coins->vout.resize(out.n+1); coins->vout[out.n] = undo.txout; - + return fClean; } @@ -2496,10 +2496,10 @@ void DisconnectNotarisations(const CBlock &block) bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean) { assert(pindex->GetBlockHash() == view.GetBestBlock()); - + if (pfClean) *pfClean = false; - + bool fClean = true; komodo_disconnect(pindex,block); CBlockUndo blockUndo; @@ -2508,7 +2508,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex return error("DisconnectBlock(): no undo data available"); if (!UndoReadFromDisk(blockUndo, pos, pindex->pprev->GetBlockHash())) return error("DisconnectBlock(): failure reading undo data"); - + if (blockUndo.vtxundo.size() + 1 != block.vtx.size()) return error("DisconnectBlock(): block and undo data inconsistent"); std::vector > addressIndex; @@ -2546,23 +2546,23 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex } else if (out.scriptPubKey.IsPayToPublicKey()) { vector hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34); - + // undo receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, k, false), out.nValue)); - + // undo unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), hash, k), CAddressUnspentValue())); - + } else if (out.scriptPubKey.IsPayToCryptoCondition()) { vector hashBytes(out.scriptPubKey.begin(), out.scriptPubKey.end()); - + // undo receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, k, false), out.nValue)); - + // undo unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), hash, k), CAddressUnspentValue())); - + } else { continue; @@ -2577,7 +2577,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex { CCoinsModifier outs = view.ModifyCoins(hash); outs->ClearUnspendable(); - + CCoins outsBlock(tx, pindex->nHeight); // The CCoins serialization does not serialize negative numbers. // No network rules currently depend on the version here, so an inconsistency is harmless @@ -2586,18 +2586,18 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex outs->nVersion = outsBlock.nVersion; if (*outs != outsBlock) fClean = fClean && error("DisconnectBlock(): added transaction mismatch? database corrupted"); - + // remove outputs outs->Clear(); } - + // unspend nullifiers BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { view.SetNullifier(nf, false); } } - + // restore inputs if (!tx.IsMint()) { const CTxUndo &txundo = blockUndo.vtxundo[i-1]; @@ -2641,23 +2641,23 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex } else if (prevout.scriptPubKey.IsPayToPublicKey()) { vector hashBytes(prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34); - + // undo spending activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, j, true), prevout.nValue * -1)); - + // restore unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), input.prevout.hash, input.prevout.n), CAddressUnspentValue(prevout.nValue, prevout.scriptPubKey, undo.nHeight))); - + } else if (prevout.scriptPubKey.IsPayToCryptoCondition()) { vector hashBytes(prevout.scriptPubKey.begin(), prevout.scriptPubKey.end()); - + // undo spending activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, j, true), prevout.nValue * -1)); - + // restore unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), input.prevout.hash, input.prevout.n), CAddressUnspentValue(prevout.nValue, prevout.scriptPubKey, undo.nHeight))); - + } else { continue; @@ -2673,10 +2673,10 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex // set the old best anchor back view.PopAnchor(blockUndo.old_tree_root); - + // move best block pointer to prevout block view.SetBestBlock(pindex->pprev->GetBlockHash()); - + if (pfClean) { *pfClean = fClean; return true; @@ -2697,9 +2697,9 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex void static FlushBlockFile(bool fFinalize = false) { LOCK(cs_LastBlockFile); - + CDiskBlockPos posOld(nLastBlockFile, 0); - + FILE *fileOld = OpenBlockFile(posOld); if (fileOld) { if (fFinalize) @@ -2707,7 +2707,7 @@ void static FlushBlockFile(bool fFinalize = false) FileCommit(fileOld); fclose(fileOld); } - + fileOld = OpenUndoFile(posOld); if (fileOld) { if (fFinalize) @@ -2735,20 +2735,20 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const int64_t nPowTargetSpacing) { if (bestHeader == NULL || initialDownloadCheck()) return; - + static int64_t lastAlertTime = 0; int64_t now = GetAdjustedTime(); if (lastAlertTime > now-60*60*24) return; // Alert at most once per day - + const int SPAN_HOURS=4; const int SPAN_SECONDS=SPAN_HOURS*60*60; int BLOCKS_EXPECTED = SPAN_SECONDS / nPowTargetSpacing; - + boost::math::poisson_distribution poisson(BLOCKS_EXPECTED); - + std::string strWarning; int64_t startTime = GetAdjustedTime()-SPAN_SECONDS; - + LOCK(cs); const CBlockIndex* i = bestHeader; int nBlocks = 0; @@ -2757,17 +2757,17 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const i = i->pprev; if (i == NULL) return; // Ran out of chain, we must not be fully synced } - + // How likely is it to find that many by chance? double p = boost::math::pdf(poisson, nBlocks); - + LogPrint("partitioncheck", "%s : Found %d blocks in the last %d hours\n", __func__, nBlocks, SPAN_HOURS); LogPrint("partitioncheck", "%s : likelihood: %g\n", __func__, p); - + // Aim for one false-positive about every fifty years of normal running: const int FIFTY_YEARS = 50*365*24*60*60; double alertThreshold = 1.0 / (FIFTY_YEARS / SPAN_SECONDS); - + if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED) { // Many fewer blocks than expected: alert! @@ -2819,7 +2819,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - + // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); if ( hashPrevBlock != view.GetBestBlock() ) @@ -2829,7 +2829,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin REJECT_INVALID, "hashPrevBlock-not-bestblock"); } assert(hashPrevBlock == view.GetBestBlock()); - + // Special case for the genesis block, skipping connection of its transactions // (its coinbase is unspendable) if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) { @@ -2843,7 +2843,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } return true; } - + bool fScriptChecks = (!fCheckpointsEnabled || pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints())); //if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" // return(false); @@ -2855,13 +2855,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): tried to overwrite transaction"), REJECT_INVALID, "bad-txns-BIP30"); } - + unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; - + // DERSIG (BIP66) is also always enforced, but does not have a flag. - + CBlockUndo blockundo; - + if ( ASSETCHAINS_CC != 0 ) { if ( scriptcheckqueue.IsIdle() == 0 ) @@ -2871,7 +2871,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } CCheckQueueControl control(fExpensiveChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL); - + int64_t nTimeStart = GetTimeMicros(); CAmount nFees = 0; int nInputs = 0; @@ -2895,16 +2895,16 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // This should never fail: we should always be able to get the root // that is on the tip of our chain assert(view.GetAnchorAt(old_tree_root, tree)); - + { // Consistency check: the root of the tree we're given should // match what we asked for. assert(tree.root() == old_tree_root); } - + // Grab the consensus branch ID for the block's height auto consensusBranchId = CurrentEpochBranchId(pindex->nHeight, Params().GetConsensus()); - + std::vector txdata; txdata.reserve(block.vtx.size()); // Required so that pointers to individual PrecomputedTransactionData don't get invalidated for (unsigned int i = 0; i < block.vtx.size(); i++) @@ -2982,14 +2982,14 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): too many sigops"), REJECT_INVALID, "bad-blk-sigops"); } - + txdata.emplace_back(tx); - + if (!tx.IsCoinBase()) { nFees += view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime) - tx.GetValueOut(); sum += interest; - + std::vector vChecks; if (!ContextualCheckInputs(tx, state, view, fExpensiveChecks, flags, false, txdata[i], chainparams.GetConsensus(), consensusBranchId, nScriptCheckThreads ? &vChecks : NULL)) return false; @@ -3022,23 +3022,23 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } else if (out.scriptPubKey.IsPayToPublicKey()) { vector hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34); - + // record receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, txhash, k, false), out.nValue)); - + // record unspent output addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), txhash, k), CAddressUnspentValue(out.nValue, out.scriptPubKey, pindex->nHeight))); - + } else if (out.scriptPubKey.IsPayToCryptoCondition()) { vector hashBytes(out.scriptPubKey.begin(), out.scriptPubKey.end()); - + // record receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, txhash, k, false), out.nValue)); - + // record unspent output addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), txhash, k), CAddressUnspentValue(out.nValue, out.scriptPubKey, pindex->nHeight))); - + } else { continue; @@ -3054,28 +3054,28 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin blockundo.vtxundo.push_back(CTxUndo()); } UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight); - + BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 ¬e_commitment, joinsplit.commitments) { // Insert the note commitments into our temporary tree. - + tree.append(note_commitment); } } - + vPos.push_back(std::make_pair(tx.GetHash(), pos)); pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); } - + view.PushAnchor(tree); if (!fJustCheck) { pindex->hashAnchorEnd = tree.root(); } blockundo.old_tree_root = old_tree_root; - + int64_t nTime1 = GetTimeMicros(); nTimeConnect += nTime1 - nTimeStart; LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); - + CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) { @@ -3102,10 +3102,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, false); int64_t nTime2 = GetTimeMicros(); nTimeVerify += nTime2 - nTimeStart; LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime2 - nTimeStart), nInputs <= 1 ? 0 : 0.001 * (nTime2 - nTimeStart) / (nInputs-1), nTimeVerify * 0.000001); - + if (fJustCheck) return true; - + // Write undo information to disk if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS)) { @@ -3115,12 +3115,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return error("ConnectBlock(): FindUndoPos failed"); if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart())) return AbortNode(state, "Failed to write undo data"); - + // update nUndoPos in block index pindex->nUndoPos = pos.nPos; pindex->nStatus |= BLOCK_HAVE_UNDO; } - + // Now that all consensus rules have been validated, set nCachedBranchId. // Move this if BLOCK_VALID_CONSENSUS is ever altered. static_assert(BLOCK_VALID_CONSENSUS == BLOCK_VALID_SCRIPTS, @@ -3131,13 +3131,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } else if (pindex->pprev) { pindex->nCachedBranchId = pindex->pprev->nCachedBranchId; } - + pindex->RaiseValidity(BLOCK_VALID_SCRIPTS); setDirtyBlockIndex.insert(pindex); } ConnectNotarisations(block, pindex->nHeight); - + if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) return AbortNode(state, "Failed to write transaction index"); @@ -3178,18 +3178,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // add this block to the view's block chain view.SetBestBlock(pindex->GetBlockHash()); - + int64_t nTime3 = GetTimeMicros(); nTimeIndex += nTime3 - nTime2; LogPrint("bench", " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeIndex * 0.000001); - + // Watch for changes to the previous coinbase transaction. static uint256 hashPrevBestCoinBase; GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase); hashPrevBestCoinBase = block.vtx[0].GetHash(); - + int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3; LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); - + //FlushStateToDisk(); komodo_connectblock(pindex,*(CBlock *)&block); return true; @@ -3319,7 +3319,7 @@ void PruneAndFlush() { void static UpdateTip(CBlockIndex *pindexNew) { const CChainParams& chainParams = Params(); chainActive.SetTip(pindexNew); - + // New best block nTimeBestReceived = GetTime(); mempool.AddTransactionsUpdated(1); @@ -3337,9 +3337,9 @@ void static UpdateTip(CBlockIndex *pindexNew) { log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.LastTip()->nChainTx, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.LastTip()->GetBlockTime()), progress, pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); - + cvBlockChange.notify_all(); - + // Check the version of the last 100 blocks to see if we need to upgrade: static bool fWarned = false; if (!IsInitialBlockDownload() && !fWarned) @@ -3403,7 +3403,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { // Write the chain state to disk, if necessary. if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED)) return false; - + if (!fBare) { // Resurrect mempool transactions from the disconnected block. @@ -3423,7 +3423,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { mempool.removeWithAnchor(anchorBeforeDisconnect); } } - + // Update chainActive and related variables. UpdateTip(pindexDelete->pprev); // Get the current commitment tree @@ -3464,7 +3464,7 @@ static int64_t nTimePostConnect = 0; * You probably want to call mempool.removeWithoutBranchId after this, with cs_main held. */ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) { - + assert(pindexNew->pprev == chainActive.Tip()); // Read block from disk. int64_t nTime1 = GetTimeMicros(); @@ -3507,10 +3507,10 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * // Remove conflicting transactions from the mempool. list txConflicted; mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload()); - + // Remove transactions that expire at new block height from mempool mempool.removeExpired(pindexNew->nHeight); - + // Update chainActive & related variables. UpdateTip(pindexNew); // Tell wallet about transactions that went from mempool @@ -3525,9 +3525,9 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * // Update cached incremental witnesses //fprintf(stderr,"chaintip true\n"); GetMainSignals().ChainTip(pindexNew, pblock, oldTree, true); - + EnforceNodeDeprecation(pindexNew->nHeight); - + int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1; LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); @@ -3547,7 +3547,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * static CBlockIndex* FindMostWorkChain() { do { CBlockIndex *pindexNew = NULL; - + // Find the best candidate header. { std::set::reverse_iterator it = setBlockIndexCandidates.rbegin(); @@ -3555,14 +3555,14 @@ static CBlockIndex* FindMostWorkChain() { return NULL; pindexNew = *it; } - + // Check whether all blocks on the path between the currently active chain and the candidate are valid. // Just going until the active chain is an optimization, as we know all blocks in it are valid already. CBlockIndex *pindexTest = pindexNew; bool fInvalidAncestor = false; while (pindexTest && !chainActive.Contains(pindexTest)) { assert(pindexTest->nChainTx || pindexTest->nHeight == 0); - + // Pruned nodes may have entries in setBlockIndexCandidates for // which block files have been deleted. Remove those as candidates // for the most work chain if we come across them; we can't switch @@ -3619,7 +3619,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo bool fInvalidFound = false; const CBlockIndex *pindexOldTip = chainActive.Tip(); const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork); - + // - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks. // - If pindexMostWork is in a chain that doesn't have the same genesis block as our chain, // then pindexFork will be null, and we would need to remove the entire chain including @@ -3644,7 +3644,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo StartShutdown(); return false; } - + // Disconnect active blocks which are no longer in the best chain. bool fBlocksDisconnected = false; while (chainActive.Tip() && chainActive.Tip() != pindexFork) { @@ -3686,7 +3686,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo pindexIter = pindexIter->pprev; } nHeight = nTargetHeight; - + // Connect new blocks. BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) { if (!ConnectTip(state, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) { @@ -3712,20 +3712,20 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } } } - + if (fBlocksDisconnected) { mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS); } mempool.removeWithoutBranchId( CurrentEpochBranchId(chainActive.Tip()->nHeight + 1, Params().GetConsensus())); mempool.check(pcoinsTip); - + // Callbacks/notifications for a new best chain. if (fInvalidFound) CheckForkWarningConditionsOnNewFork(vpindexToConnect.back()); else CheckForkWarningConditions(); - + return true; } @@ -3740,23 +3740,23 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { const CChainParams& chainParams = Params(); do { boost::this_thread::interruption_point(); - + bool fInitialDownload; { LOCK(cs_main); pindexMostWork = FindMostWorkChain(); - + // Whether we have anything to do at all. if (pindexMostWork == NULL || pindexMostWork == chainActive.Tip()) return true; - + if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) return false; pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); } // When we reach this point, we switched to a new tip (stored in pindexNewTip). - + // Notifications/callbacks that can run without cs_main if (!fInitialDownload) { uint256 hashNewTip = pindexNewTip->GetBlockHash(); @@ -3778,23 +3778,23 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { } //else fprintf(stderr,"initial download skips propagation\n"); } while(pindexMostWork != chainActive.Tip()); CheckBlockIndex(); - + // Write changes periodically to disk, after relay. if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC)) { return false; } - + return true; } bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { AssertLockHeld(cs_main); - + // Mark the block itself as invalid. pindex->nStatus |= BLOCK_FAILED_VALID; setDirtyBlockIndex.insert(pindex); setBlockIndexCandidates.erase(pindex); - + while (chainActive.Contains(pindex)) { CBlockIndex *pindexWalk = chainActive.Tip(); pindexWalk->nStatus |= BLOCK_FAILED_CHILD; @@ -3810,7 +3810,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { } } //LimitMempoolSize(mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); - + // The resulting new best tip may not be in setBlockIndexCandidates anymore, so // add it again. BlockMap::iterator it = mapBlockIndex.begin(); @@ -3820,7 +3820,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { } it++; } - + InvalidChainFound(pindex); mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS); mempool.removeWithoutBranchId( @@ -3830,9 +3830,9 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) { AssertLockHeld(cs_main); - + int nHeight = pindex->nHeight; - + // Remove the invalidity flag from this block and all its descendants. BlockMap::iterator it = mapBlockIndex.begin(); while (it != mapBlockIndex.end()) { @@ -3849,7 +3849,7 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) { } it++; } - + // Remove the invalidity flag from all ancestors too. while (pindex != NULL) { if (pindex->nStatus & BLOCK_FAILED_MASK) { @@ -3901,7 +3901,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) pindexNew->RaiseValidity(BLOCK_VALID_TREE); if (pindexBestHeader == NULL || pindexBestHeader->nChainWork < pindexNew->nChainWork) pindexBestHeader = pindexNew; - + setDirtyBlockIndex.insert(pindexNew); //fprintf(stderr,"added to block index %s %p\n",hash.ToString().c_str(),pindexNew); mi->second = pindexNew; @@ -3928,12 +3928,12 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl pindexNew->nStatus |= BLOCK_HAVE_DATA; pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS); setDirtyBlockIndex.insert(pindexNew); - + if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) { // If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS. deque queue; queue.push_back(pindexNew); - + // Recursively process any descendant blocks that now may be eligible to be connected. while (!queue.empty()) { CBlockIndex *pindex = queue.front(); @@ -3968,19 +3968,19 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl mapBlocksUnlinked.insert(std::make_pair(pindexNew->pprev, pindexNew)); } } - + return true; } bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false) { LOCK(cs_LastBlockFile); - + unsigned int nFile = fKnown ? pos.nFile : nLastBlockFile; if (vinfoBlockFile.size() <= nFile) { vinfoBlockFile.resize(nFile + 1); } - + if (!fKnown) { while (vinfoBlockFile[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { nFile++; @@ -3991,7 +3991,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd pos.nFile = nFile; pos.nPos = vinfoBlockFile[nFile].nSize; } - + if (nFile != nLastBlockFile) { if (!fKnown) { LogPrintf("Leaving block file %i: %s\n", nFile, vinfoBlockFile[nFile].ToString()); @@ -3999,13 +3999,13 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd FlushBlockFile(!fKnown); nLastBlockFile = nFile; } - + vinfoBlockFile[nFile].AddBlock(nHeight, nTime); if (fKnown) vinfoBlockFile[nFile].nSize = std::max(pos.nPos + nAddSize, vinfoBlockFile[nFile].nSize); else vinfoBlockFile[nFile].nSize += nAddSize; - + if (!fKnown) { unsigned int nOldChunks = (pos.nPos + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE; unsigned int nNewChunks = (vinfoBlockFile[nFile].nSize + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE; @@ -4024,7 +4024,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd return state.Error("out of disk space"); } } - + setDirtyFileInfo.insert(nFile); return true; } @@ -4032,14 +4032,14 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize) { pos.nFile = nFile; - + LOCK(cs_LastBlockFile); - + unsigned int nNewSize; pos.nPos = vinfoBlockFile[nFile].nUndoSize; nNewSize = vinfoBlockFile[nFile].nUndoSize += nAddSize; setDirtyFileInfo.insert(nFile); - + unsigned int nOldChunks = (pos.nPos + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE; unsigned int nNewChunks = (nNewSize + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE; if (nNewChunks > nOldChunks) { @@ -4056,7 +4056,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne else return state.Error("out of disk space"); } - + return true; } @@ -4101,7 +4101,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, // Check block version if (height > 0 && blockhdr.nVersion < MIN_BLOCK_VERSION) return state.DoS(100, error("CheckBlockHeader(): block version too low"),REJECT_INVALID, "version-too-low"); - + // Check Equihash solution is valid if ( fCheckPOW ) { @@ -4156,7 +4156,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (block.hashMerkleRoot != hashMerkleRoot2) return state.DoS(100, error("CheckBlock: hashMerkleRoot mismatch"), REJECT_INVALID, "bad-txnmrklroot", true); - + // Check for merkle tree malleability (CVE-2012-2459): repeating sequences // of transactions in a block without affecting the merkle root of a block, // while still invalidating it. @@ -4164,16 +4164,16 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C return state.DoS(100, error("CheckBlock: duplicate transaction"), REJECT_INVALID, "bad-txns-duplicate", true); } - + // All potential-corruption validation must be done before we do any // transaction validation, as otherwise we may mark the header as invalid // because we receive the wrong transactions for it. - + // Size limits if (block.vtx.empty() || block.vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) return state.DoS(100, error("CheckBlock: size limits failed"), REJECT_INVALID, "bad-blk-length"); - + // First transaction must be coinbase, the rest must not be if (block.vtx.empty() || !block.vtx[0].IsCoinBase()) return state.DoS(100, error("CheckBlock: first tx is not coinbase"), @@ -4182,7 +4182,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (block.vtx[i].IsCoinBase()) return state.DoS(100, error("CheckBlock: more than one coinbase"), REJECT_INVALID, "bad-cb-multiple"); - + // Check transactions if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { @@ -4246,11 +4246,11 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta uint256 hash = block.GetHash(); if (hash == consensusParams.hashGenesisBlock) return true; - + assert(pindexPrev); - + int nHeight = pindexPrev->nHeight+1; - + // Check proof of work if ( (ASSETCHAINS_SYMBOL[0] != 0 || nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) { @@ -4258,12 +4258,12 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta return state.DoS(100, error("%s: incorrect proof of work", __func__), REJECT_INVALID, "bad-diffbits"); } - + // Check timestamp against prev if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast()) return state.Invalid(error("%s: block's timestamp is too early", __func__), REJECT_INVALID, "time-too-old"); - + if (fCheckpointsEnabled) { // Check that the block chain matches the known block chain up to a checkpoint @@ -4306,7 +4306,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta if (block.nVersion < 4) return state.Invalid(error("%s : rejected nVersion<4 block", __func__), REJECT_OBSOLETE, "bad-version"); - + return true; } @@ -4314,15 +4314,15 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn { const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; const Consensus::Params& consensusParams = Params().GetConsensus(); - + // Check that all transactions are finalized BOOST_FOREACH(const CTransaction& tx, block.vtx) { - + // Check transaction contextually against consensus rules at block height if (!ContextualCheckTransaction(tx, state, nHeight, 100)) { return false; // Failure reason has been set in validation state object } - + int nLockTimeFlags = 0; int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) ? pindexPrev->GetMedianTimePast() @@ -4331,7 +4331,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } - + // Enforce BIP 34 rule that the coinbase starts with serialized block height. // In Zcash this has been enforced since launch, except that the genesis // block didn't include the height in the coinbase (see Zcash protocol spec @@ -4344,7 +4344,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); } } - + return true; } @@ -4437,7 +4437,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C { const CChainParams& chainparams = Params(); AssertLockHeld(cs_main); - + CBlockIndex *&pindex = *ppindex; if (!AcceptBlockHeader(futureblockp,block, state, &pindex)) { @@ -4464,7 +4464,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // regardless of whether pruning is enabled; it should generally be safe to // not process unrequested blocks. bool fTooFarAhead = (pindex->nHeight > int(chainActive.Height() + BLOCK_DOWNLOAD_WINDOW)); //MIN_BLOCKS_TO_KEEP)); - + // TODO: deal better with return value and error conditions for duplicate // and unrequested blocks. //fprintf(stderr,"Accept %s flags already.%d requested.%d morework.%d farahead.%d\n",pindex->GetBlockHash().ToString().c_str(),fAlreadyHave,fRequested,fHasMoreWork,fTooFarAhead); @@ -4474,7 +4474,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if (!fHasMoreWork) return true; // Don't process less-work chains if (fTooFarAhead) return true; // Block height is too high } - + // See method docstring for why this is always disabled auto verifier = libzcash::ProofVerifier::Disabled(); if ((!CheckBlock(futureblockp,pindex->nHeight,pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev)) @@ -4489,7 +4489,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C return false; } } - + int nHeight = pindex->nHeight; // Write block to history file try { @@ -4507,7 +4507,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); } - + if (fCheckForPruning) FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files if ( *futureblockp == 0 ) @@ -4653,7 +4653,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo return error("%s: AcceptBlock FAILED", __func__); //else fprintf(stderr,"added block %s %p\n",pindex->GetBlockHash().ToString().c_str(),pindex->pprev); } - + if (futureblock == 0 && !ActivateBestChain(state, pblock)) return error("%s: ActivateBestChain failed", __func__); //fprintf(stderr,"finished ProcessBlock %d\n",(int32_t)chainActive.LastTip()->nHeight); @@ -4665,7 +4665,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex { AssertLockHeld(cs_main); assert(pindexPrev == chainActive.Tip()); - + CCoinsViewCache viewNew(pcoinsTip); CBlockIndex indexDummy(block); indexDummy.pprev = pindexPrev; @@ -4726,7 +4726,7 @@ void PruneOneBlockFile(const int fileNumber) pindex->nDataPos = 0; pindex->nUndoPos = 0; setDirtyBlockIndex.insert(pindex); - + // Prune from mapBlocksUnlinked -- any block we prune would have // to be downloaded again in order to consider its chain, at which // point it would be considered as a candidate for @@ -4741,7 +4741,7 @@ void PruneOneBlockFile(const int fileNumber) } } } - + vinfoBlockFile[fileNumber].SetNull(); setDirtyFileInfo.insert(fileNumber); } @@ -4775,21 +4775,21 @@ void FindFilesToPrune(std::set& setFilesToPrune) uint64_t nBuffer = BLOCKFILE_CHUNK_SIZE + UNDOFILE_CHUNK_SIZE; uint64_t nBytesToPrune; int count=0; - + if (nCurrentUsage + nBuffer >= nPruneTarget) { for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) { nBytesToPrune = vinfoBlockFile[fileNumber].nSize + vinfoBlockFile[fileNumber].nUndoSize; - + if (vinfoBlockFile[fileNumber].nSize == 0) continue; - + if (nCurrentUsage + nBuffer < nPruneTarget) // are we below our target? break; - + // don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip but keep scanning if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) continue; - + PruneOneBlockFile(fileNumber); // Queue up the files for removal setFilesToPrune.insert(fileNumber); @@ -4797,7 +4797,7 @@ void FindFilesToPrune(std::set& setFilesToPrune) count++; } } - + LogPrint("prune", "Prune: target=%dMiB actual=%dMiB diff=%dMiB max_prune_height=%d removed %d blk/rev pairs\n", nPruneTarget/1024/1024, nCurrentUsage/1024/1024, ((int64_t)nPruneTarget - (int64_t)nCurrentUsage)/1024/1024, @@ -4807,11 +4807,11 @@ void FindFilesToPrune(std::set& setFilesToPrune) bool CheckDiskSpace(uint64_t nAdditionalBytes) { uint64_t nFreeBytesAvailable = boost::filesystem::space(GetDataDir()).available; - + // Check for nMinDiskSpace bytes (currently 50MB) if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes) return AbortNode("Disk space is low!", _("Error: Disk space is low!")); - + return true; } @@ -4861,12 +4861,12 @@ CBlockIndex * InsertBlockIndex(uint256 hash) { if (hash.IsNull()) return NULL; - + // Return existing BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) return (*mi).second; - + // Create new CBlockIndex* pindexNew = new CBlockIndex(); if (!pindexNew) @@ -4888,7 +4888,7 @@ bool static LoadBlockIndexDB() return false; LogPrintf("%s: loaded guts\n", __func__); boost::this_thread::interruption_point(); - + // Calculate nChainWork vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); @@ -4967,7 +4967,7 @@ bool static LoadBlockIndexDB() break; } } - + // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); set setBlkDataFiles; @@ -4987,17 +4987,17 @@ bool static LoadBlockIndexDB() return false; } } - + // Check whether we have ever pruned block & undo files pblocktree->ReadFlag("prunedblockfiles", fHavePruned); if (fHavePruned) LogPrintf("LoadBlockIndexDB(): Block files have previously been pruned\n"); - + // Check whether we need to continue reindexing bool fReindexing = false; pblocktree->ReadReindexing(fReindexing); fReindex |= fReindexing; - + // Check whether we have a transaction index pblocktree->ReadFlag("txindex", fTxIndex); LogPrintf("%s: transaction index %s\n", __func__, fTxIndex ? "enabled" : "disabled"); @@ -5027,7 +5027,7 @@ bool static LoadBlockIndexDB() } //komodo_pindex_init(pindex,(int32_t)pindex->nHeight); } - + // Load pointer to end of best chain BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); if (it == mapBlockIndex.end()) @@ -5035,7 +5035,7 @@ bool static LoadBlockIndexDB() chainActive.SetTip(it->second); // Set hashAnchorEnd for the end of best chain it->second->hashAnchorEnd = pcoinsTip->GetBestAnchor(); - + PruneBlockIndexCandidates(); double progress; @@ -5047,14 +5047,14 @@ bool static LoadBlockIndexDB() // runs, which makes it return 0, so we guess 50% for now progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 0.5; } - + LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__, chainActive.LastTip()->GetBlockHash().ToString(), chainActive.Height(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.LastTip()->GetBlockTime()), progress); - + EnforceNodeDeprecation(chainActive.Height(), true); - + return true; } @@ -5073,7 +5073,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth LOCK(cs_main); if (chainActive.Tip() == NULL || chainActive.Tip()->pprev == NULL) return true; - + // Verify blocks in the best chain if (nCheckDepth <= 0) nCheckDepth = 1000000000; // suffices until the year 19000 @@ -5130,7 +5130,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth //fprintf(stderr,"end VerifyDB %u\n",(uint32_t)time(NULL)); if (pindexFailure) return error("VerifyDB(): *** coin database inconsistencies found (last %i blocks, %i good transactions before that)\n", chainActive.Height() - pindexFailure->nHeight + 1, nGoodTransactions); - + // check level 4: try reconnecting blocks if (nCheckLevel >= 4) { CBlockIndex *pindex = pindexState; @@ -5145,16 +5145,16 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); } } - + LogPrintf("No coin database inconsistencies in last %i blocks (%i transactions)\n", chainActive.Height() - pindexState->nHeight, nGoodTransactions); - + return true; } bool RewindBlockIndex(const CChainParams& params) { LOCK(cs_main); - + // RewindBlockIndex is called after LoadBlockIndex, so at this point every block // index will have nCachedBranchId set based on the values previously persisted // to disk. By definition, a set nCachedBranchId means that the block was @@ -5172,7 +5172,7 @@ bool RewindBlockIndex(const CChainParams& params) pindex->nCachedBranchId && *pindex->nCachedBranchId == CurrentEpochBranchId(pindex->nHeight, consensus); }; - + int nHeight = 1; while (nHeight <= chainActive.Height()) { if (!sufficientlyValidated(chainActive[nHeight])) { @@ -5180,7 +5180,7 @@ bool RewindBlockIndex(const CChainParams& params) } nHeight++; } - + // nHeight is now the height of the first insufficiently-validated block, or tipheight + 1 auto rewindLength = chainActive.Height() - nHeight; if (rewindLength > 0 && rewindLength > MAX_REORG_LENGTH) { @@ -5201,7 +5201,7 @@ bool RewindBlockIndex(const CChainParams& params) StartShutdown(); return false; } - + CValidationState state; CBlockIndex* pindex = chainActive.Tip(); while (chainActive.Height() >= nHeight) { @@ -5220,13 +5220,13 @@ bool RewindBlockIndex(const CChainParams& params) if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC)) return false; } - + // Reduce validity flag and have-data flags. // We do this after actual disconnecting, otherwise we'll end up writing the lack of data // to disk before writing the chainstate, resulting in a failure to continue if interrupted. for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) { CBlockIndex* pindexIter = it->second; - + // Note: If we encounter an insufficiently validated block that // is on chainActive, it must be because we are a pruning node, and // this block or some successor doesn't HAVE_DATA, so we were unable to @@ -5259,7 +5259,7 @@ bool RewindBlockIndex(const CChainParams& params) //fprintf(stderr,"Reset invalid block marker if it was pointing to this block\n"); pindexBestInvalid = NULL; } - + // Update indices setBlockIndexCandidates.erase(pindexIter); auto ret = mapBlocksUnlinked.equal_range(pindexIter->pprev); @@ -5274,15 +5274,15 @@ bool RewindBlockIndex(const CChainParams& params) setBlockIndexCandidates.insert(pindexIter); } } - + PruneBlockIndexCandidates(); - + CheckBlockIndex(); - + if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) { return false; } - + return true; } @@ -5309,7 +5309,7 @@ void UnloadBlockIndex() setDirtyFileInfo.clear(); mapNodeState.clear(); recentRejects.reset(NULL); - + BOOST_FOREACH(BlockMap::value_type& entry, mapBlockIndex) { delete entry.second; } @@ -5334,7 +5334,7 @@ bool LoadBlockIndex() bool InitBlockIndex() { const CChainParams& chainparams = Params(); LOCK(cs_main); - + // Initialize global variables that cannot be constructed at startup. recentRejects.reset(new CRollingBloomFilter(120000, 0.000001)); // Check whether we're already initialized @@ -5352,12 +5352,12 @@ bool InitBlockIndex() { // Use the provided setting for -timestampindex in the new database fTimestampIndex = GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX); pblocktree->WriteFlag("timestampindex", fTimestampIndex); - + fSpentIndex = GetBoolArg("-spentindex", DEFAULT_SPENTINDEX); pblocktree->WriteFlag("spentindex", fSpentIndex); fprintf(stderr,"fAddressIndex.%d/%d fSpentIndex.%d/%d\n",fAddressIndex,DEFAULT_ADDRESSINDEX,fSpentIndex,DEFAULT_SPENTINDEX); LogPrintf("Initializing databases...\n"); - + // Only add the genesis block if not reindexing (in which case we reuse the one already on disk) if (!fReindex) { try { @@ -5383,7 +5383,7 @@ bool InitBlockIndex() { return error("LoadBlockIndex(): failed to initialize block database: %s", e.what()); } } - + return true; } @@ -5395,7 +5395,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) // Map of disk positions for blocks with unknown parent (only used for reindex) static std::multimap mapBlocksUnknownParent; int64_t nStart = GetTimeMillis(); - + int nLoaded = 0; try { // This takes over fileIn and calls fclose() on it in the CBufferedFile destructor @@ -5404,7 +5404,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) uint64_t nRewind = blkdat.GetPos(); while (!blkdat.eof()) { boost::this_thread::interruption_point(); - + blkdat.SetPos(nRewind); nRewind++; // start one byte further next time, in case of failure blkdat.SetLimit(); // remove former limit @@ -5435,7 +5435,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) CBlock block; blkdat >> block; nRewind = blkdat.GetPos(); - + // detect out of order blocks, and store them for later uint256 hash = block.GetHash(); if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex.find(block.hashPrevBlock) == mapBlockIndex.end()) { @@ -5445,7 +5445,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) mapBlocksUnknownParent.insert(std::make_pair(block.hashPrevBlock, *dbp)); continue; } - + // process in case the block isn't known yet if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) { CValidationState state; @@ -5456,7 +5456,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) } else if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex[hash]->nHeight % 1000 == 0) { LogPrintf("Block Import: already had block %s at height %d\n", hash.ToString(), mapBlockIndex[hash]->nHeight); } - + // Recursively process earlier encountered successors of this block deque queue; queue.push_back(hash); @@ -5499,9 +5499,9 @@ void static CheckBlockIndex() if (!fCheckBlockIndex) { return; } - + LOCK(cs_main); - + // During a reindex, we read the genesis block and call CheckBlockIndex before ActivateBestChain, // so we have the genesis block in mapBlockIndex but no active chain. (A few of the tests when // iterating the block tree require that chainActive has been initialized.) @@ -5509,7 +5509,7 @@ void static CheckBlockIndex() assert(mapBlockIndex.size() <= 1); return; } - + // Build forward-pointing map of the entire block tree. std::multimap forward; for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) { @@ -5518,12 +5518,12 @@ void static CheckBlockIndex() } if ( Params().NetworkIDString() != "regtest" ) assert(forward.size() == mapBlockIndex.size()); - + std::pair::iterator,std::multimap::iterator> rangeGenesis = forward.equal_range(NULL); CBlockIndex *pindex = rangeGenesis.first->second; rangeGenesis.first++; assert(rangeGenesis.first == rangeGenesis.second); // There is only one index entry with parent NULL. - + // Iterate over the entire block tree, using depth-first search. // Along the way, remember whether there are blocks on the path from genesis // block being explored which are the first to have certain properties. @@ -5545,7 +5545,7 @@ void static CheckBlockIndex() if (pindex->pprev != NULL && pindexFirstNotTransactionsValid == NULL && (pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS) pindexFirstNotTransactionsValid = pindex; if (pindex->pprev != NULL && pindexFirstNotChainValid == NULL && (pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_CHAIN) pindexFirstNotChainValid = pindex; if (pindex->pprev != NULL && pindexFirstNotScriptsValid == NULL && (pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_SCRIPTS) pindexFirstNotScriptsValid = pindex; - + // Begin: actual consistency checks. if (pindex->pprev == NULL) { // Genesis block checks. @@ -5631,7 +5631,7 @@ void static CheckBlockIndex() } // assert(pindex->GetBlockHash() == pindex->GetBlockHeader().GetHash()); // Perhaps too slow // End: actual consistency checks. - + // Try descending into the first subnode. std::pair::iterator,std::multimap::iterator> range = forward.equal_range(pindex); if (range.first != range.second) { @@ -5674,7 +5674,7 @@ void static CheckBlockIndex() } } } - + // Check that we actually traversed the entire map. assert(nNodes == forward.size()); } @@ -5689,20 +5689,20 @@ std::string GetWarnings(const std::string& strFor) int nPriority = 0; string strStatusBar; string strRPC; - + if (!CLIENT_VERSION_IS_RELEASE) strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); - + if (GetBoolArg("-testsafemode", false)) strStatusBar = strRPC = "testsafemode enabled"; - + // Misc warnings like out of disk space and clock is wrong if (strMiscWarning != "") { nPriority = 1000; strStatusBar = strMiscWarning; } - + if (fLargeWorkForkFound) { nPriority = 2000; @@ -5713,7 +5713,7 @@ std::string GetWarnings(const std::string& strFor) nPriority = 2000; strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade."); } - + // Alerts { LOCK(cs_mapAlerts); @@ -5730,7 +5730,7 @@ std::string GetWarnings(const std::string& strFor) } } } - + if (strFor == "statusbar") return strStatusBar; else if (strFor == "rpc") @@ -5768,7 +5768,7 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) hashRecentRejectsChainTip = chainActive.Tip()->GetBlockHash(); recentRejects->reset(); } - + return recentRejects->contains(inv.hash) || mempool.exists(inv.hash) || mapOrphanTransactions.count(inv.hash) || @@ -5784,21 +5784,21 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) void static ProcessGetData(CNode* pfrom) { std::deque::iterator it = pfrom->vRecvGetData.begin(); - + vector vNotFound; - + LOCK(cs_main); - + while (it != pfrom->vRecvGetData.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->nSendSize >= SendBufferSize()) break; - + const CInv &inv = *it; { boost::this_thread::interruption_point(); it++; - + if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK) { bool send = false; @@ -5902,17 +5902,17 @@ void static ProcessGetData(CNode* pfrom) vNotFound.push_back(inv); } } - + // Track requests for our stuff. GetMainSignals().Inventory(inv.hash); - + if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK) break; } } - + pfrom->vRecvGetData.erase(pfrom->vRecvGetData.begin(), it); - + if (!vNotFound.empty()) { // Let the peer know that we didn't find what it asked for, so it doesn't // have to wait around forever. Currently only SPV clients actually care @@ -5935,10 +5935,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } - - - - + + + + if (strCommand == "version") { // Each connection can only send one version message @@ -5948,22 +5948,36 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 1); return false; } - + int64_t nTime; CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) + if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) { - // disconnect from peers older than this proto version - LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); - pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, - strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); - pfrom->fDisconnect = true; - return false; + if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) + { + // disconnect from peers older than this proto version + LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); + pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, + strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); + pfrom->fDisconnect = true; + return false; + } + } else + { + if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) + { + // disconnect from peers older than this proto version + LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); + pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, + strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); + pfrom->fDisconnect = true; + return false; + } } - + // When Overwinter is active, reject incoming connections from non-Overwinter nodes const Consensus::Params& params = Params().GetConsensus(); if (NetworkUpgradeActive(GetHeight(), params, Consensus::UPGRADE_OVERWINTER) @@ -5976,7 +5990,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - + if (pfrom->nVersion == 10300) pfrom->nVersion = 300; if (!vRecv.empty()) @@ -5991,7 +6005,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vRecv >> pfrom->fRelayTxes; // set to true after we get the first filter* message else pfrom->fRelayTxes = true; - + // Disconnect if we connected to ourself if (nNonce == nLocalHostNonce && nNonce > 1) { @@ -5999,26 +6013,26 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return true; } - + pfrom->addrLocal = addrMe; if (pfrom->fInbound && addrMe.IsRoutable()) { SeenLocal(addrMe); } - + // Be shy and don't send version until we hear if (pfrom->fInbound) pfrom->PushVersion(); - + pfrom->fClient = !(pfrom->nServices & NODE_NETWORK); - + // Potentially mark this peer as a preferred download peer. UpdatePreferredDownload(pfrom, State(pfrom->GetId())); - + // Change version pfrom->PushMessage("verack"); pfrom->ssSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); - + if (!pfrom->fInbound) { // Advertise our address @@ -6035,7 +6049,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->PushAddress(addr); } } - + // Get recent addresses if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || addrman.size() < 1000) { @@ -6050,51 +6064,51 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, addrman.Good(addrFrom); } } - + // Relay alerts { LOCK(cs_mapAlerts); BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) item.second.RelayTo(pfrom); } - + pfrom->fSuccessfullyConnected = true; - + string remoteAddr; if (fLogIPs) remoteAddr = ", peeraddr=" + pfrom->addr.ToString(); - + LogPrintf("receive version message: %s: version %d, blocks=%d, us=%s, peer=%d%s\n", pfrom->cleanSubVer, pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), pfrom->id, remoteAddr); - + int64_t nTimeOffset = nTime - GetTime(); pfrom->nTimeOffset = nTimeOffset; AddTimeData(pfrom->addr, nTimeOffset); } - - + + else if (pfrom->nVersion == 0) { // Must have a version message before anything else Misbehaving(pfrom->GetId(), 1); return false; } - - + + else if (strCommand == "verack") { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); - + // Mark this node as currently connected, so we update its timestamp later. if (pfrom->fNetworkNode) { LOCK(cs_main); State(pfrom->GetId())->fCurrentlyConnected = true; } } - - + + // Disconnect existing peer connection when: // 1. The version message has been received // 2. Overwinter is active @@ -6109,13 +6123,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - - + + else if (strCommand == "addr") { vector vAddr; vRecv >> vAddr; - + // Don't want addr from older versions unless seeding if (pfrom->nVersion < CADDR_TIME_VERSION && addrman.size() > 1000) return true; @@ -6124,7 +6138,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 20); return error("message addr size() = %u", vAddr.size()); } - + // Store the new addresses vector vAddrOk; int64_t nNow = GetAdjustedTime(); @@ -6132,7 +6146,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, BOOST_FOREACH(CAddress& addr, vAddr) { boost::this_thread::interruption_point(); - + if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) addr.nTime = nNow - 5 * 24 * 60 * 60; pfrom->AddAddressKnown(addr); @@ -6176,8 +6190,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (pfrom->fOneShot) pfrom->fDisconnect = true; } - - + + else if (strCommand == "inv") { vector vInv; @@ -6187,24 +6201,24 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 20); return error("message inv size() = %u", vInv.size()); } - + LOCK(cs_main); - + std::vector vToFetch; - + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { const CInv &inv = vInv[nInv]; - + boost::this_thread::interruption_point(); pfrom->AddInventoryKnown(inv); - + bool fAlreadyHave = AlreadyHave(inv); LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id); - + if (!fAlreadyHave && !fImporting && !fReindex && inv.type != MSG_BLOCK) pfrom->AskFor(inv); - + if (inv.type == MSG_BLOCK) { UpdateBlockAvailability(pfrom->GetId(), inv.hash); if (!fAlreadyHave && !fImporting && !fReindex && !mapBlocksInFlight.count(inv.hash)) { @@ -6228,21 +6242,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrint("net", "getheaders (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->id); } } - + // Track requests for our stuff GetMainSignals().Inventory(inv.hash); - + if (pfrom->nSendSize > (SendBufferSize() * 2)) { Misbehaving(pfrom->GetId(), 50); return error("send buffer size() = %u", pfrom->nSendSize); } } - + if (!vToFetch.empty()) pfrom->PushMessage("getdata", vToFetch); } - - + + else if (strCommand == "getdata") { vector vInv; @@ -6252,29 +6266,29 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 20); return error("message getdata size() = %u", vInv.size()); } - + if (fDebug || (vInv.size() != 1)) LogPrint("net", "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id); - + if ((fDebug && vInv.size() > 0) || (vInv.size() == 1)) LogPrint("net", "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id); - + pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); ProcessGetData(pfrom); } - - + + else if (strCommand == "getblocks") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; - + LOCK(cs_main); - + // Find the last block the caller has in the main chain CBlockIndex* pindex = FindForkInGlobalIndex(chainActive, locator); - + // Send the rest of the chain if (pindex) pindex = chainActive.Next(pindex); @@ -6298,19 +6312,19 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } - - + + else if (strCommand == "getheaders") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; - + LOCK(cs_main); - + if (IsInitialBlockDownload()) return true; - + CBlockIndex* pindex = NULL; if (locator.IsNull()) { @@ -6327,7 +6341,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (pindex) pindex = chainActive.Next(pindex); } - + // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end vector vHeaders; int nLimit = MAX_HEADERS_RESULTS; @@ -6350,37 +6364,37 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, fprintf(stderr,"you can ignore redundant getheaders from peer.%d %d prev.%d\n",(int32_t)pfrom->id,(int32_t)(pindex ? pindex->nHeight : -1),pfrom->lasthdrsreq); }*/ } - - + + else if (strCommand == "tx") { vector vWorkQueue; vector vEraseQueue; CTransaction tx; vRecv >> tx; - + CInv inv(MSG_TX, tx.GetHash()); pfrom->AddInventoryKnown(inv); - + LOCK(cs_main); - + bool fMissingInputs = false; CValidationState state; - + pfrom->setAskFor.erase(inv.hash); mapAlreadyAskedFor.erase(inv); - + if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) { mempool.check(pcoinsTip); RelayTransaction(tx); vWorkQueue.push_back(inv.hash); - + LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s: accepted %s (poolsz %u)\n", pfrom->id, pfrom->cleanSubVer, tx.GetHash().ToString(), mempool.mapTx.size()); - + // Recursively process any orphan transactions that depended on this one set setMisbehaving; for (unsigned int i = 0; i < vWorkQueue.size(); i++) @@ -6400,8 +6414,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get // anyone relaying LegitTxX banned) CValidationState stateDummy; - - + + if (setMisbehaving.count(fromPeer)) continue; if (AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2)) @@ -6431,7 +6445,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, mempool.check(pcoinsTip); } } - + BOOST_FOREACH(uint256 hash, vEraseQueue) EraseOrphanTx(hash); } @@ -6439,7 +6453,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if (fMissingInputs && tx.vjoinsplit.size() == 0) { AddOrphanTx(tx, pfrom->GetId()); - + // DoS prevention: do not allow mapOrphanTransactions to grow unbounded unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); @@ -6448,7 +6462,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } else { assert(recentRejects); recentRejects->insert(tx.GetHash()); - + if (pfrom->fWhitelisted) { // Always relay transactions received from whitelisted peers, even // if they were already in the mempool or rejected from it due @@ -6480,12 +6494,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), nDoS); } } - - + + else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing { std::vector headers; - + // Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks. unsigned int nCount = ReadCompactSize(vRecv); if (nCount > MAX_HEADERS_RESULTS) { @@ -6497,14 +6511,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vRecv >> headers[n]; ReadCompactSize(vRecv); // ignore tx count; assume it is 0. } - + LOCK(cs_main); - + if (nCount == 0) { // Nothing interesting. Stop asking this peers for more headers. return true; } - + CBlockIndex *pindexLast = NULL; BOOST_FOREACH(const CBlockHeader& header, headers) { CValidationState state; @@ -6523,10 +6537,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } - + if (pindexLast) UpdateBlockAvailability(pfrom->GetId(), pindexLast->GetBlockHash()); - + if (nCount == MAX_HEADERS_RESULTS && pindexLast) { // Headers message had its maximum size; the peer may have more headers. // TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue @@ -6538,20 +6552,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256()); } } - + CheckBlockIndex(); } - + else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing { CBlock block; vRecv >> block; - + CInv inv(MSG_BLOCK, block.GetHash()); LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id); - + pfrom->AddInventoryKnown(inv); - + CValidationState state; // Process all blocks from whitelisted peers, even if not requested, // unless we're still syncing with the network. @@ -6568,10 +6582,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), nDoS); } } - + } - - + + // This asymmetric behavior for inbound and outbound connections was introduced // to prevent a fingerprinting attack: an attacker can send specific fake addresses // to users' AddrMan and later request them by sending getaddr messages. @@ -6586,18 +6600,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } pfrom->fSentAddr = true; - + pfrom->vAddrToSend.clear(); vector vAddr = addrman.GetAddr(); BOOST_FOREACH(const CAddress &addr, vAddr) pfrom->PushAddress(addr); } - - + + else if (strCommand == "mempool") { LOCK2(cs_main, pfrom->cs_filter); - + std::vector vtxid; mempool.queryHashes(vtxid); vector vInv; @@ -6617,8 +6631,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (vInv.size() > 0) pfrom->PushMessage("inv", vInv); } - - + + else if (strCommand == "ping") { if (pfrom->nVersion > BIP0031_VERSION) @@ -6639,8 +6653,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->PushMessage("pong", nonce); } } - - + + else if (strCommand == "pong") { int64_t pingUsecEnd = nTimeReceived; @@ -6648,10 +6662,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, size_t nAvail = vRecv.in_avail(); bool bPingFinished = false; std::string sProblem; - + if (nAvail >= sizeof(nonce)) { vRecv >> nonce; - + // Only process pong message if there is an outstanding ping (old ping without nonce should never pong) if (pfrom->nPingNonceSent != 0) { if (nonce == pfrom->nPingNonceSent) { @@ -6683,7 +6697,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, bPingFinished = true; sProblem = "Short payload"; } - + if (!(sProblem.empty())) { LogPrint("net", "pong peer=%d %s: %s, %x expected, %x received, %u bytes\n", pfrom->id, @@ -6697,13 +6711,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->nPingNonceSent = 0; } } - - + + else if (fAlerts && strCommand == "alert") { CAlert alert; vRecv >> alert; - + uint256 alertHash = alert.GetHash(); if (pfrom->setKnown.count(alertHash) == 0) { @@ -6728,13 +6742,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } - - + + else if (strCommand == "filterload") { CBloomFilter filter; vRecv >> filter; - + if (!filter.IsWithinSizeConstraints()) // There is no excuse for sending a too-large filter Misbehaving(pfrom->GetId(), 100); @@ -6747,13 +6761,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } pfrom->fRelayTxes = true; } - - + + else if (strCommand == "filteradd") { vector vData; vRecv >> vData; - + // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object, // and thus, the maximum size any matched object can have) in a filteradd message if (vData.size() > MAX_SCRIPT_ELEMENT_SIZE) @@ -6767,8 +6781,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 100); } } - - + + else if (strCommand == "filterclear") { LOCK(pfrom->cs_filter); @@ -6776,18 +6790,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->pfilter = new CBloomFilter(); pfrom->fRelayTxes = true; } - - + + else if (strCommand == "reject") { if (fDebug) { try { string strMsg; unsigned char ccode; string strReason; vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH); - + ostringstream ss; ss << strMsg << " code " << itostr(ccode) << ": " << strReason; - + if (strMsg == "block" || strMsg == "tx") { uint256 hash; @@ -6805,14 +6819,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // We do not care about the NOTFOUND message, but logging an Unknown Command // message would be undesirable as we transmit it ourselves. } - + else { // Ignore unknown commands for extensibility LogPrint("net", "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id); } - - - + + + return true; } @@ -6821,7 +6835,7 @@ bool ProcessMessages(CNode* pfrom) { //if (fDebug) // LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size()); - + // // Message format // (4) message start @@ -6831,41 +6845,41 @@ bool ProcessMessages(CNode* pfrom) // (x) data // bool fOk = true; - + if (!pfrom->vRecvGetData.empty()) ProcessGetData(pfrom); - + // this maintains the order of responses if (!pfrom->vRecvGetData.empty()) return fOk; - + std::deque::iterator it = pfrom->vRecvMsg.begin(); while (!pfrom->fDisconnect && it != pfrom->vRecvMsg.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->nSendSize >= SendBufferSize()) break; - + // get next message CNetMessage& msg = *it; - + //if (fDebug) // LogPrintf("%s(message %u msgsz, %u bytes, complete:%s)\n", __func__, // msg.hdr.nMessageSize, msg.vRecv.size(), // msg.complete() ? "Y" : "N"); - + // end, if an incomplete message is found if (!msg.complete()) break; - + // at this point, any failure means we can delete the current message it++; - + // Scan for message start if (memcmp(msg.hdr.pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) { LogPrintf("PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->id); fOk = false; break; } - + // Read header CMessageHeader& hdr = msg.hdr; if (!hdr.IsValid(Params().MessageStart())) @@ -6874,10 +6888,10 @@ bool ProcessMessages(CNode* pfrom) continue; } string strCommand = hdr.GetCommand(); - + // Message size unsigned int nMessageSize = hdr.nMessageSize; - + // Checksum CDataStream& vRecv = msg.vRecv; uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); @@ -6888,7 +6902,7 @@ bool ProcessMessages(CNode* pfrom) SanitizeString(strCommand), nMessageSize, nChecksum, hdr.nChecksum); continue; } - + // Process message bool fRet = false; try @@ -6922,17 +6936,17 @@ bool ProcessMessages(CNode* pfrom) } catch (...) { PrintExceptionContinue(NULL, "ProcessMessages()"); } - + if (!fRet) LogPrintf("%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(strCommand), nMessageSize, pfrom->id); - + break; } - + // In case the connection got shut down, its receive buffer was wiped if (!pfrom->fDisconnect) pfrom->vRecvMsg.erase(pfrom->vRecvMsg.begin(), it); - + return fOk; } @@ -6944,7 +6958,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Don't send anything until we get its version message if (pto->nVersion == 0) return true; - + // // Message: ping // @@ -6973,11 +6987,11 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pto->PushMessage("ping"); } } - + TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState() if (!lockMain) return true; - + // Address refresh broadcast static int64_t nLastRebroadcast; if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) @@ -6988,14 +7002,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Periodically clear addrKnown to allow refresh broadcasts if (nLastRebroadcast) pnode->addrKnown.reset(); - + // Rebroadcast our address AdvertizeLocal(pnode); } if (!vNodes.empty()) nLastRebroadcast = GetTime(); } - + // // Message: addr // @@ -7021,7 +7035,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (!vAddr.empty()) pto->PushMessage("addr", vAddr); } - + CNodeState &state = *State(pto->GetId()); if (state.fShouldBan) { if (pto->fWhitelisted) @@ -7037,11 +7051,11 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } state.fShouldBan = false; } - + BOOST_FOREACH(const CBlockReject& reject, state.rejects) pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock); state.rejects.clear(); - + // Start block sync if (pindexBestHeader == NULL) pindexBestHeader = chainActive.Tip(); @@ -7056,7 +7070,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); } } - + // Resend wallet transactions that haven't gotten in a block yet // Except during reindex, importing and IBD, when old wallet // transactions become unconfirmed and spams other nodes. @@ -7064,7 +7078,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) { GetMainSignals().Broadcast(nTimeBestReceived); } - + // // Message: inventory // @@ -7078,7 +7092,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) { if (pto->setInventoryKnown.count(inv)) continue; - + // trickle out tx inv to protect privacy if (inv.type == MSG_TX && !fSendTrickle) { @@ -7089,14 +7103,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle) uint256 hashRand = ArithToUint256(UintToArith256(inv.hash) ^ UintToArith256(hashSalt)); hashRand = Hash(BEGIN(hashRand), END(hashRand)); bool fTrickleWait = ((UintToArith256(hashRand) & 3) != 0); - + if (fTrickleWait) { vInvWait.push_back(inv); continue; } } - + // returns true if wasn't already contained in the set if (pto->setInventoryKnown.insert(inv).second) { @@ -7112,7 +7126,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } if (!vInv.empty()) pto->PushMessage("inv", vInv); - + // Detect whether we're stalling int64_t nNow = GetTimeMicros(); if (!pto->fDisconnect && state.nStallingSince && state.nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT) { @@ -7144,7 +7158,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pto->fDisconnect = true; } } - + // // Message: getdata (blocks) // @@ -7181,7 +7195,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) komodo_requestedcount = 0; } }*/ - + // // Message: getdata (non-blocks) // @@ -7206,7 +7220,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } if (!vGetData.empty()) pto->PushMessage("getdata", vGetData); - + } return true; } @@ -7227,7 +7241,7 @@ public: for (; it1 != mapBlockIndex.end(); it1++) delete (*it1).second; mapBlockIndex.clear(); - + // orphan transactions mapOrphanTransactions.clear(); mapOrphanTransactionsByPrev.clear(); @@ -7244,14 +7258,14 @@ extern "C" const char* getDataDir() CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight) { CMutableTransaction mtx; - + bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); if (isOverwintered) { mtx.fOverwintered = true; mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; mtx.nVersion = 3; // Expiry height is not set. Only fields required for a parser to treat as a valid Overwinter V3 tx. - + // TODO: In future, when moving from Overwinter to Sapling, it will be useful // to set the expiry height to: min(activation_height - 1, default_expiry_height) } diff --git a/src/version.h b/src/version.h index 25527895d..b28225df4 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170003; +static const int PROTOCOL_VERSION = 170004; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -19,6 +19,7 @@ static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version static const int MIN_PEER_PROTO_VERSION = 170002; +static const int STAKEDMIN_PEER_PROTO_VERSION = 170004; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 47cd790436985fd93b253337b58ffc8caf5c89e0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 01:46:02 +0800 Subject: [PATCH 0076/3904] try staked.h again --- src/crosschain_authority.cpp | 29 ++++++----------------------- src/komodo_notary.h | 22 +++------------------- src/notaries_STAKED.h | 14 ++++++++------ 3 files changed, 17 insertions(+), 48 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 30e4e725a..3c257c4a7 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,32 +1,15 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -//#include "notaries_STAKED.h" - -const char *notaries_STAKEDcc[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN -}; +#include "notaries_STAKED.h" +extern char *notaries_STAKED int GetSymbolAuthority(const char* symbol) { - if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) + if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) + if ( (strncmp(symbol, "STKD", 4) == 0) || (strncmp(symbol, "STAKED", 6) == 0) ) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } @@ -72,10 +55,10 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); + auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); auth.requiredSigs = 3; for (int n=0; n Date: Fri, 21 Sep 2018 01:48:37 +0800 Subject: [PATCH 0077/3904] ; --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 3c257c4a7..046abff82 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,7 @@ #include "notarisationdb.h" #include "notaries_STAKED.h" -extern char *notaries_STAKED +extern char *notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 37fa6b1ac..08ed1a91a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ #define KOMODO_MAINNET_START 178999 -extern char *notaries_STAKED +extern char *notaries_STAKED; const char *Notaries_genesis[][2] = { From 9a241aa9c29c40bf75da075cccc9ecb69233d8ec Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:10:11 +0800 Subject: [PATCH 0078/3904] try again --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- src/notaries_STAKED.cpp | 22 ++++++++++++++++++++++ src/notaries_STAKED.h | 26 +++++--------------------- 4 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 src/notaries_STAKED.cpp diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 046abff82..10145013b 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,7 @@ #include "notarisationdb.h" #include "notaries_STAKED.h" -extern char *notaries_STAKED; +//extern char *notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 08ed1a91a..7bec772b1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ #define KOMODO_MAINNET_START 178999 -extern char *notaries_STAKED; +//extern char *notaries_STAKED; const char *Notaries_genesis[][2] = { diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp new file mode 100644 index 000000000..e34100eff --- /dev/null +++ b/src/notaries_STAKED.cpp @@ -0,0 +1,22 @@ +#include "notaries_STAKED.h" + +const char *notaries_STAKED[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 99169f1a6..b6e209733 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,22 +1,6 @@ -#pragma once +#ifndef NOTARIES_STAKED +#define NOTARIES_STAKED -const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; +extern char *notaries_STAKED[][2]; + +#endif From 550e9a54ac185935bb1b87ed53546182fb0c8467 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:19:24 +0800 Subject: [PATCH 0079/3904] i --- src/notaries_STAKED.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index b6e209733..479979a57 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,6 +1,26 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -extern char *notaries_STAKED[][2]; +//extern char *notaries_STAKED[][2]; +const char *notaries_STAKED[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; #endif From 9b97cb1a5dadef69047f6ebf39ad84828098a61b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:54:13 +0800 Subject: [PATCH 0080/3904] one more time --- src/notaries_STAKED.cpp | 7 +++++++ src/notaries_STAKED.h | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp index e34100eff..a012bc08c 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_STAKED.cpp @@ -20,3 +20,10 @@ const char *notaries_STAKED[][2] = {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; + +bool is_STAKED() { + int32_t STAKED = 0; + if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + STAKED = 1; + return(STAKED) +} diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 479979a57..f6be14222 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,9 +1,11 @@ -#ifndef NOTARIES_STAKED -#define NOTARIES_STAKED +#ifndef NOTARIES_STAKED_H +#define NOTARIES_STAKED_H -//extern char *notaries_STAKED[][2]; +extern const char *notaries_STAKED[][2]; -const char *notaries_STAKED[][2] = +bool is_STAKED(); + +/*const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -22,5 +24,5 @@ const char *notaries_STAKED[][2] = {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; +};*/ #endif From f58cc01b5e0451e1c8f3182523d3639c3a17d559 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:58:53 +0800 Subject: [PATCH 0081/3904] ; --- src/notaries_STAKED.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp index a012bc08c..2038f6897 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_STAKED.cpp @@ -26,4 +26,4 @@ bool is_STAKED() { if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED) -} +}; From 75a86d88a299c8251193b09ae4cb3894832ae4df Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 03:10:28 +0800 Subject: [PATCH 0082/3904] ? --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- src/notaries_STAKED.cpp | 4 +++- src/notaries_STAKED.h | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 10145013b..6b4f1d7ad 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -55,7 +55,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + auth.size = num_notaries_STAKED; auth.requiredSigs = 3; for (int n=0; n Date: Fri, 21 Sep 2018 03:12:24 +0800 Subject: [PATCH 0083/3904] ? --- src/notaries_STAKED.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 23e58e1ee..814cc0a7a 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ -#ifndef NOTARIES_STAKED_H -#define NOTARIES_STAKED_H +//#ifndef NOTARIES_STAKED_H +//#define NOTARIES_STAKED_H extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; @@ -26,4 +26,4 @@ bool is_STAKED(); {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s };*/ -#endif +//#endif From 41c25e89db3dc730229e07b578dfe96a90265309 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 03:16:35 +0800 Subject: [PATCH 0084/3904] ? --- src/notaries_STAKED.cpp | 2 +- src/notaries_STAKED.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp index 41b106066..b3c97020a 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_STAKED.cpp @@ -28,4 +28,4 @@ bool is_STAKED() { return(STAKED) }; -int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 814cc0a7a..4b2f8ba90 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -2,7 +2,7 @@ //#define NOTARIES_STAKED_H extern const char *notaries_STAKED[][2]; -extern int num_notaries_STAKED; +extern const int num_notaries_STAKED; bool is_STAKED(); From 24f0f84417bd0dc89d48f741c91a01cf36953c03 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 11:20:09 +0800 Subject: [PATCH 0085/3904] try this --- src/notaries_STAKED.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 4b2f8ba90..7bf13b8c9 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ -//#ifndef NOTARIES_STAKED_H -//#define NOTARIES_STAKED_H +#ifndef NOTARIES_STAKED_H +#define NOTARIES_STAKED_H extern const char *notaries_STAKED[][2]; extern const int num_notaries_STAKED; @@ -26,4 +26,4 @@ bool is_STAKED(); {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s };*/ -//#endif +#endif From b7a3348ed19dde86b3dbc174d3f48db39aa703bd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 11:43:32 +0800 Subject: [PATCH 0086/3904] change some stuff --- src/crosschain_authority.cpp | 3 ++- src/komodo_notary.h | 3 ++- src/{notaries_STAKED.cpp => notaries_staked.cpp} | 5 +++-- src/{notaries_STAKED.h => notaries_staked.h} | 11 +++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) rename src/{notaries_STAKED.cpp => notaries_staked.cpp} (94%) rename src/{notaries_STAKED.h => notaries_staked.h} (91%) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6b4f1d7ad..6ccf631dc 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,8 @@ #include "notarisationdb.h" #include "notaries_STAKED.h" -//extern char *notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index cf485e41f..cab36642d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,8 @@ #define KOMODO_MAINNET_START 178999 -//extern char *notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; const char *Notaries_genesis[][2] = { diff --git a/src/notaries_STAKED.cpp b/src/notaries_staked.cpp similarity index 94% rename from src/notaries_STAKED.cpp rename to src/notaries_staked.cpp index b3c97020a..daab6fe3d 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_STAKED.h" -const char *notaries_STAKED[][2] = +/*const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -20,6 +20,7 @@ const char *notaries_STAKED[][2] = {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; +*/ bool is_STAKED() { bool STAKED = 0; @@ -28,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +//const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_STAKED.h b/src/notaries_staked.h similarity index 91% rename from src/notaries_STAKED.h rename to src/notaries_staked.h index 7bf13b8c9..ba491dd95 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_staked.h @@ -1,12 +1,12 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; bool is_STAKED(); -/*const char *notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -25,5 +25,8 @@ bool is_STAKED(); {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -};*/ +}; + +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + #endif From 6f3af3ff83c717689b3ed1551b0dcaffbf69bd7b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 11:46:25 +0800 Subject: [PATCH 0087/3904] Change minsigs to 4, remove supply hack. --- src/crosschain_authority.cpp | 2 +- src/komodo.h | 2 +- src/komodo_utils.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7cec5f382..a010126a1 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -76,7 +76,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); - auth.requiredSigs = 3; + auth.requiredSigs = 4; for (int n=0; n= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 3 ) + ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 4 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4856931ac..44516ba6b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1554,7 +1554,7 @@ void komodo_args(char *argv0) if ( name.c_str()[0] != 0 ) { MAX_BLOCK_SIGOPS = 60000; - ASSETCHAINS_SUPPLY = ( GetArg("-ac_supply",10) + 1 ); + ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_ENDSUBSIDY = GetArg("-ac_end",0); ASSETCHAINS_REWARD = GetArg("-ac_reward",0); ASSETCHAINS_HALVING = GetArg("-ac_halving",0); @@ -1752,4 +1752,3 @@ void komodo_prefetch(FILE *fp) } fseek(fp,fpos,SEEK_SET); } - From 95918c6402d806a7d6793bec58370db1ee0f361d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 12:29:39 +0800 Subject: [PATCH 0088/3904] fix dumbness --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 27 +-------------------------- src/notaries_staked.cpp | 2 +- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 849c083bc..b382b4fc9 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,7 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -#include "notaries_STAKED.h" +#include "notaries_staked.h" extern const char *notaries_STAKED[][2]; extern const int num_notaries_STAKED; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index b5e147855..7b041f8b9 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,32 +18,7 @@ #include "komodo_cJSON.h" -<<<<<<< HEAD -//include "notaries_STAKED.h" -//{"kmdcrazy", "02da444a2627d420f1f622fcdfb9bddb67d6d4241ad6b4d5054716ddbde8a25dfb"} // RJPJBbHcm5mkAxhkkERHRfEE9Cvkr4Euoi -const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; -======= -#include "notaries_STAKED.h" ->>>>>>> blackjok3r +#include "notaries_staked.h" #define KOMODO_MAINNET_START 178999 diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index daab6fe3d..9f6301f80 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,4 +1,4 @@ -#include "notaries_STAKED.h" +#include "notaries_staked.h" /*const char *notaries_STAKED[][2] = { From 9f1e5ad6c0ffd3d11f667e262c28f1c553fda919 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 12:41:10 +0800 Subject: [PATCH 0089/3904] runnign around in circles here, little sense! --- src/notaries_staked.cpp | 6 +++--- src/notaries_staked.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9f6301f80..a3b3844d3 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -/*const char *notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -20,7 +20,7 @@ {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; -*/ + bool is_STAKED() { bool STAKED = 0; @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -//const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ba491dd95..59e083a41 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,12 +1,12 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; bool is_STAKED(); -const char *notaries_STAKED[][2] = +/*const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -28,5 +28,5 @@ const char *notaries_STAKED[][2] = }; const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); - +*/ #endif From 3dcbdcb85c3c441fbacc3916c8f8bfeaaaca6e19 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:08:13 +0800 Subject: [PATCH 0090/3904] try something else --- src/notaries_staked.cpp | 4 ++-- src/notaries_staked.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a3b3844d3..9350ecdf2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -const char *notaries_STAKED[][2] = +extern const char *const notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +extern const int const num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 59e083a41..a3d3599b7 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,8 +1,8 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +extern const char *const notaries_STAKED[][2]; +extern const int const num_notaries_STAKED; bool is_STAKED(); From bb7815b05bd650fefb8e89051f4e9c9fa795f8ef Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:09:53 +0800 Subject: [PATCH 0091/3904] that didnt work --- src/notaries_staked.cpp | 4 ++-- src/notaries_staked.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9350ecdf2..0a9db207d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -extern const char *const notaries_STAKED[][2] = +extern const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -extern const int const num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +extern const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index a3d3599b7..59e083a41 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,8 +1,8 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -extern const char *const notaries_STAKED[][2]; -extern const int const num_notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; bool is_STAKED(); From 158d7befbc384c5d45ecada1c35d5e373ecb4858 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:11:12 +0800 Subject: [PATCH 0092/3904] WTF!??!? --- src/notaries_staked.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 59e083a41..9b843f2c5 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,6 +1,3 @@ -#ifndef NOTARIES_STAKED_H -#define NOTARIES_STAKED_H - extern const char *notaries_STAKED[][2]; extern const int num_notaries_STAKED; @@ -29,4 +26,3 @@ bool is_STAKED(); const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); */ -#endif From 14acb852d578d8ca39da6834bed7124449c439f4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:23:00 +0800 Subject: [PATCH 0093/3904] try again --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 0a9db207d..a3b3844d3 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -extern const char *notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -extern const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); From 1183a043b2a561327b09eac8b11d62edd7a7b30e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:28:25 +0800 Subject: [PATCH 0094/3904] try again --- src/crosschain_authority.cpp | 4 ++-- src/komodo_notary.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b382b4fc9..31ea0b547 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,8 +3,8 @@ #include "notarisationdb.h" #include "notaries_staked.h" -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 7b041f8b9..d8b25a0ef 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,8 +22,8 @@ #define KOMODO_MAINNET_START 178999 -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; const char *Notaries_genesis[][2] = { From 9a469cda6f4c03c8dd136ab4089bd28db913be6b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:37:26 +0800 Subject: [PATCH 0095/3904] try hardcode of array length --- src/notaries_staked.cpp | 4 ++-- src/notaries_staked.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a3b3844d3..24c8562df 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -const char *notaries_STAKED[][2] = +const char *notaries_STAKED[17][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9b843f2c5..ef54eb6aa 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,5 +1,5 @@ -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +extern const char *notaries_STAKED[17[2]; +extern int num_notaries_STAKED; bool is_STAKED(); From 3539848b6031b76204a2a0e2675c26b478eaec38 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:41:40 +0800 Subject: [PATCH 0096/3904] typo --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ef54eb6aa..3defe851c 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,4 +1,4 @@ -extern const char *notaries_STAKED[17[2]; +extern const char *notaries_STAKED[17][2]; extern int num_notaries_STAKED; bool is_STAKED(); From bb33491657b778b6e9bc02bde8c8a8b9ae3ecc87 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:11:36 +0800 Subject: [PATCH 0097/3904] thanks mike --- src/notaries_staked.cpp | 12 ++++++++---- src/notaries_staked.h | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 24c8562df..735136b7d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,10 @@ -#include "notaries_staked.h" -const char *notaries_STAKED[17][2] = +#include "notaries_staked.h" +#include + +extern char ASSETCHAINS_SYMBOL[65]; + +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -26,7 +30,7 @@ bool is_STAKED() { bool STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; - return(STAKED) + return(STAKED); }; -int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 3defe851c..d7ea4c4fd 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,3 +1,7 @@ + +#ifndef NOTARIES_STAKED +#define NOTARIES_STAKED + extern const char *notaries_STAKED[17][2]; extern int num_notaries_STAKED; @@ -26,3 +30,4 @@ bool is_STAKED(); const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); */ +#endif From c83285ffe2dcfe09cfa637121da2fb5d6548b447 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:24:53 +0800 Subject: [PATCH 0098/3904] add include file to makefile ... Please work?! --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index 7113a1e42..de476385e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -291,6 +291,7 @@ libbitcoin_server_a_SOURCES = \ metrics.cpp \ miner.cpp \ net.cpp \ + notaries_staked.cpp \ noui.cpp \ notarisationdb.cpp \ paymentdisclosure.cpp \ From 77ee7feec84a9e91f7d7532f0c06340da4d10d61 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:43:16 +0800 Subject: [PATCH 0099/3904] about to blow it up --- src/bitcoin-cli.cpp | 3 ++- src/komodo_notary.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index bf189e483..db99b6a67 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -74,11 +74,12 @@ public: #include "komodo_globals.h" #include "komodo_utils.h" #include "komodo_cJSON.c" +#include "notaries_staked.h" #include "komodo_notary.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { - + } uint32_t komodo_heightstamp(int32_t height) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d8b25a0ef..45f325648 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,7 @@ #include "komodo_cJSON.h" -#include "notaries_staked.h" +//#include "notaries_staked.h" #define KOMODO_MAINNET_START 178999 From 7384746b72d090a32f92e8d69fe85f7277292828 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:48:26 +0800 Subject: [PATCH 0100/3904] WTFWTFW --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 45f325648..d8b25a0ef 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,7 @@ #include "komodo_cJSON.h" -//#include "notaries_staked.h" +#include "notaries_staked.h" #define KOMODO_MAINNET_START 178999 From 3b210ee00cbd89399088c3dadb4eda43b4740b0f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:57:30 +0800 Subject: [PATCH 0101/3904] WTFTWTFEWIDlknPI --- src/bitcoin-cli.cpp | 1 - src/notaries_staked.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index db99b6a67..60a185284 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -74,7 +74,6 @@ public: #include "komodo_globals.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "notaries_staked.h" #include "komodo_notary.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index d7ea4c4fd..b8243513d 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,7 +2,7 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -extern const char *notaries_STAKED[17][2]; +extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; bool is_STAKED(); From 5f2b70662553a62518d9bd680bb43cafe911f21e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 16:09:51 +0800 Subject: [PATCH 0102/3904] meh --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index de476385e..0559230c0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -179,6 +179,7 @@ BITCOIN_CORE_H = \ mruset.h \ net.h \ netbase.h \ + notaries_staked.h \ noui.h \ paymentdisclosure.h \ paymentdisclosuredb.h \ From 263c24b266e9e4537772064da62c0725f0d6a152 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 16:56:34 +0800 Subject: [PATCH 0103/3904] maybe --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 60a185284..6164cf463 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -75,6 +75,7 @@ public: #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" +#include "notaries_staked.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From c85b1ace10f684a7e92282011231f6a858529377 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:02:22 +0800 Subject: [PATCH 0104/3904] hmmmm --- src/notaries_staked.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 735136b7d..01e09bf07 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -25,7 +25,6 @@ const char *notaries_STAKED[][2] = {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; - bool is_STAKED() { bool STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) From 90f50a9ee705766c3bc369f83e2677d2defdac92 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:15:21 +0800 Subject: [PATCH 0105/3904] add is_staked function --- src/crosschain_authority.cpp | 7 ++----- src/komodo.h | 3 ++- src/komodo_notary.h | 2 +- src/main.cpp | 4 ++-- src/notaries_staked.h | 25 ++----------------------- 5 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 31ea0b547..cca6d6b21 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,14 +3,11 @@ #include "notarisationdb.h" #include "notaries_staked.h" -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if ( (strncmp(symbol, "STKD", 4) == 0) || (strncmp(symbol, "STAKED", 6) == 0) ) + if (is_STAKED() == 1) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } @@ -56,7 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.requiredSigs = 4; + auth.requiredSigs = STAKED_MIN_SIGS; auth.size = num_notaries_STAKED; for (int n=0; n= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 4 ) + ( (is_STAKED == 1) && (numvalid > STAKED_MIN_SIGS) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d8b25a0ef..6cb69ef0c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -231,7 +231,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if (is_STAKED == 1) { n1 = num_notaries_STAKED; for (i=0; i> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if ( is_STAKED == 1 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { diff --git a/src/notaries_staked.h b/src/notaries_staked.h index b8243513d..eac34e0d0 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,29 +5,8 @@ extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; +static const int STAKED_MIN_SIGS = 4; + bool is_STAKED(); -/*const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); -*/ #endif From 0233e249cf1cd2079b69553ded79a594717d5697 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:19:16 +0800 Subject: [PATCH 0106/3904] change to int --- src/notaries_staked.cpp | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 01e09bf07..323ec094f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -25,7 +25,7 @@ const char *notaries_STAKED[][2] = {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; -bool is_STAKED() { +int is_STAKED() { bool STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index eac34e0d0..bf8c3c58e 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,6 +7,6 @@ extern int num_notaries_STAKED; static const int STAKED_MIN_SIGS = 4; -bool is_STAKED(); +int is_STAKED(); #endif From c2ec9c54688da5386af23959e29256bb0d90d0e9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:21:30 +0800 Subject: [PATCH 0107/3904] syntax --- src/komodo.h | 2 +- src/komodo_notary.h | 2 +- src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7c8a226df..4ff65fa18 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,7 +858,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (is_STAKED == 1) && (numvalid > STAKED_MIN_SIGS) ) + ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6cb69ef0c..d4f3e4ead 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -231,7 +231,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if (is_STAKED == 1) + if (is_STAKED() == 1) { n1 = num_notaries_STAKED; for (i=0; i> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( is_STAKED == 1 ) + if ( is_STAKED() == 1 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { From d35a88824596927ed36405b9d322f3d03250d522 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:23:26 +0800 Subject: [PATCH 0108/3904] ) --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 4ff65fa18..cdf660189 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,7 +858,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) ) + ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) )) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { From b076f0ed148421a8ff06860ac1d6ce710670ddd5 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Sat, 22 Sep 2018 23:58:55 +0000 Subject: [PATCH 0109/3904] edit assetchains.json STAKED chains --- src/assetchains.json | 195 +++++++++++-------------------------------- 1 file changed, 51 insertions(+), 144 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index ceda4cce1..9faa54f16 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -1,149 +1,56 @@ [ { - "ac_name": "REVS", - "ac_supply": "1300000" - }, - { - "ac_name": "SUPERNET", - "ac_supply": "816061" - }, - { - "ac_name": "DEX", - "ac_supply": "999999" - }, - { - "ac_name": "PANGEA", - "ac_supply": "999999" - }, - { - "ac_name": "JUMBLR", - "ac_supply": "999999" - }, - { - "ac_name": "BET", - "ac_supply": "999999" - }, - { - "ac_name": "CRYPTO", - "ac_supply": "999999" - }, - { - "ac_name": "HODL", - "ac_supply": "9999999" - }, - { - "ac_name": "MSHARK", - "ac_supply": "1400000" - }, - { - "ac_name": "BOTS", - "ac_supply": "999999" - }, - { - "ac_name": "MGW", - "ac_supply": "999999" - }, - { - "ac_name": "COQUI", - "ac_supply": "72000000", - "ac_ccactivate": "200000" - }, - { - "ac_name": "WLC", - "ac_supply": "210000000" - }, - { - "ac_name": "KV", - "ac_supply": "1000000" - }, - { - "ac_name": "CEAL", - "ac_supply": "366666666" - }, - { - "ac_name": "MESH", - "ac_supply": "1000007" - }, - { - "ac_name": "MNZ", - "ac_supply": "257142858" - }, - { - "ac_name": "AXO", - "ac_supply": "200000000" - }, - { - "ac_name": "ETOMIC", - "ac_supply": "100000000" - }, - { - "ac_name": "BTCH", - "ac_supply": "20998641" - }, - { - "ac_name": "PIZZA", - "ac_supply": "100000000" - }, - { - "ac_name": "BEER", - "ac_supply": "100000000" - }, - { - "ac_name": "NINJA", - "ac_supply": "100000000" - }, - { - "ac_name": "OOT", - "ac_supply": "216000000" - }, - { - "ac_name": "BNTN", - "ac_supply": "500000000" - }, - { - "ac_name": "CHAIN", - "ac_supply": "999999" - }, - { - "ac_name": "PRLPAY", - "ac_supply": "500000000" - }, - { - "ac_name": "DSEC", - "ac_supply": "7000000" - }, - { - "ac_name": "GLXT", - "ac_supply": "10000000000" - }, - { - "ac_name": "EQL", - "ac_supply": "500000000" - }, - { - "ac_name": "ZILLA", - "ac_supply": "11000000" - }, - { - "ac_name": "RFOX", - "ac_supply": "1000000000", - "ac_reward": "100000000" - }, - { - "ac_name": "SEC", - "ac_supply": "1000000000", - "ac_cc": "333" - }, - { - "ac_name": "CCL", - "ac_supply": "200000000", - "ac_end": "1", - "ac_cc": "2", - "addressindex": "1", - "spentindex": "1", + "ac_name": "STAKEDB1", + "ac_supply": "100000", + "ac_reward" : "1000000000", + "ac_cc": "667", "addnode": [ - "142.93.136.89", - "195.201.22.89" + "195.201.137.5", + "195.201.20.230" ] - } + }, + { + "ac_name": "STAKEDW1", + "ac_supply": "100000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDPERC", + "ac_supply": "1000000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "ac_perc": "10000000", + "ac_pubkey": "03bd221868abc063b54a3fceafb9898b1931ed767298a17ac0c9923500a7c60e4b", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDS1", + "ac_supply": "1000000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "ac_staked": "10", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDS9", + "ac_supply": "1000000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "ac_staked": "90", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + } ] From 44f2c39adae28a792dd3fef97b688373f09939ae Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:27:14 +0800 Subject: [PATCH 0110/3904] try and add eras, for notaries, with timestamp activation --- src/crosschain_authority.cpp | 2 +- src/komodo.h | 3 +- src/komodo_notary.h | 132 ++++++++++++++++++++++++----------- src/main.cpp | 2 +- src/notaries_staked.cpp | 91 +++++++++++++++++++++++- src/notaries_staked.h | 15 +++- 6 files changed, 199 insertions(+), 46 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index cca6d6b21..1d9ba93f4 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED() == 1) + if (is_STAKED() != 0) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } diff --git a/src/komodo.h b/src/komodo.h index cdf660189..d1587fbb4 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -857,8 +857,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5)) || - ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) )) + numvalid > (numnotaries/5)) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d4f3e4ead..87947a9b8 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -206,53 +206,107 @@ const char *Notaries_elected1[][2] = int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; + static uint8_t staked_pubkeys[64][33],staked_pubkeys1[64][33],didstaked,didstaked1; static int32_t ns,ns1; + static uint8_t staked_pubkeys2[64][33],staked_pubkeys3[64][33],didstaked2,didstaked3; static int32_t ns2,ns3; + int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) timestamp = komodo_heightstamp(height); else if ( ASSETCHAINS_SYMBOL[0] == 0 ) timestamp = 0; - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. + if (is_STAKED() == 0) { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; diff --git a/src/main.cpp b/src/main.cpp index e86fe47bc..596518ecf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5954,7 +5954,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrFrom; uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( is_STAKED() == 1 ) + if ( is_STAKED() != 0 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 323ec094f..4f335a444 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,6 +4,7 @@ extern char ASSETCHAINS_SYMBOL[65]; +// Era 0 set of pubkeys const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x @@ -25,11 +26,97 @@ const char *notaries_STAKED[][2] = {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; +int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + +// Era 1 set of pubkeys +const char *notaries_STAKED1[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED1 = (sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1)); + +// Era 2 set of pubkeys +const char *notaries_STAKED2[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED2 = (sizeof(notaries_STAKED2)/sizeof(*notaries_STAKED2)); + +// Era 3 set of pubkeys +const char *notaries_STAKED3[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); + int is_STAKED() { - bool STAKED = 0; + int STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED); }; -int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +int STAKED_era(uint32_t timestamp) +{ + int era; + if (timestamp <= STAKED_NOTARIES_TIMESTAMP) + era = 0; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 && timestamp >= STAKED_NOTARIES_TIMESTAMP) + era = 1; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= STAKED_NOTARIES_TIMESTAMP1) + era = 2; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= STAKED_NOTARIES_TIMESTAMP2) + era = 3; + return(era); +} diff --git a/src/notaries_staked.h b/src/notaries_staked.h index bf8c3c58e..201f8cb40 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,11 +2,24 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED +static const uint32_t STAKED_NOTARIES_TIMESTAMP = 1537780949; +static const uint32_t STAKED_NOTARIES_TIMESTAMP1 = 1537791749; +static const uint32_t STAKED_NOTARIES_TIMESTAMP2 = 1537802549; +static const uint32_t STAKED_NOTARIES_TIMESTAMP3 = 1537813349; + extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; -static const int STAKED_MIN_SIGS = 4; +extern const char *notaries_STAKED1[][2]; +extern int num_notaries_STAKED1; + +extern const char *notaries_STAKED2[][2]; +extern int num_notaries_STAKED2; + +extern const char *notaries_STAKED3[][2]; +extern int num_notaries_STAKED3; int is_STAKED(); +int STAKED_era(uint32_t timestamp); #endif From 91c308014611e1b9edb5b8bf423d8a533fc9e85c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:37:15 +0800 Subject: [PATCH 0111/3904] hmmm need to have height activation for MoMoM aswell, as uses a diffrent array for its pubkeys,disable this for now to test. --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1d9ba93f4..06a01dbd5 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,7 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.requiredSigs = STAKED_MIN_SIGS; + auth.requiredSigs = 4; auth.size = num_notaries_STAKED; for (int n=0; n Date: Mon, 24 Sep 2018 15:43:43 +0800 Subject: [PATCH 0112/3904] change to just int, compiler was mad --- src/notaries_staked.cpp | 2 +- src/notaries_staked.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 4f335a444..81d249d96 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED() { return(STAKED); }; -int STAKED_era(uint32_t timestamp) +int STAKED_era(int timestamp) { int era; if (timestamp <= STAKED_NOTARIES_TIMESTAMP) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 201f8cb40..84296d4e5 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,10 +2,10 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -static const uint32_t STAKED_NOTARIES_TIMESTAMP = 1537780949; -static const uint32_t STAKED_NOTARIES_TIMESTAMP1 = 1537791749; -static const uint32_t STAKED_NOTARIES_TIMESTAMP2 = 1537802549; -static const uint32_t STAKED_NOTARIES_TIMESTAMP3 = 1537813349; +static const int STAKED_NOTARIES_TIMESTAMP = 1537780949; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537791749; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537802549; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537813349; extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; @@ -20,6 +20,6 @@ extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; int is_STAKED(); -int STAKED_era(uint32_t timestamp); +int STAKED_era(int timestamp); #endif From 5ef1dc51272e4c036c4d23fe492029c03286ebde Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:45:03 +0800 Subject: [PATCH 0113/3904] ; --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 87947a9b8..5c85c0885 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -303,7 +303,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam memcpy(pubkeys,staked_pubkeys3,ns1 * 33); return(ns3); } - free(staked_era) + free(staked_era); } } From 533cb0369c9daab7a387d7096ac4a1019fd8ee1b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:46:38 +0800 Subject: [PATCH 0114/3904] pointless line remove --- src/komodo_notary.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5c85c0885..8be1c2feb 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -303,7 +303,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam memcpy(pubkeys,staked_pubkeys3,ns1 * 33); return(ns3); } - free(staked_era); } } From fdf332d9abcf8be292dc573620da298c59d38a11 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 16:24:25 +0800 Subject: [PATCH 0115/3904] fix silly --- src/komodo_notary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 8be1c2feb..af84287b4 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -264,7 +264,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam didstaked = 1; printf("THIS CHAIN IS A STAKED CHAIN and is era 0 \n"); } - memcpy(pubkeys,staked_pubkeys,n1 * 33); + memcpy(pubkeys,staked_pubkeys,ns * 33); return(ns); } else if (staked_era == 1) { @@ -288,7 +288,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam didstaked2 = 1; printf("THIS CHAIN IS A STAKED CHAIN and is era 2 \n"); } - memcpy(pubkeys,staked_pubkeys2,ns1 * 33); + memcpy(pubkeys,staked_pubkeys2,ns2 * 33); return(ns2); } else if (staked_era == 3) { @@ -300,7 +300,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam didstaked2 = 1; printf("THIS CHAIN IS A STAKED CHAIN and is era 3 \n"); } - memcpy(pubkeys,staked_pubkeys3,ns1 * 33); + memcpy(pubkeys,staked_pubkeys3,ns3 * 33); return(ns3); } } From 6120642eb124099c2b0b63f1104eaa84e412809d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 18:58:38 +0800 Subject: [PATCH 0116/3904] add a print for isstaked --- src/crosschain_authority.cpp | 3 ++- src/komodo_notary.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 06a01dbd5..049b97cd4 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -8,6 +8,7 @@ int GetSymbolAuthority(const char* symbol) if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; if (is_STAKED() != 0) + printf("RETURNED CROSSCHAIN STAKED AS TRUE"); return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } @@ -53,7 +54,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.requiredSigs = 4; + auth.requiredSigs = (num_notaries_STAKED / 5); auth.size = num_notaries_STAKED; for (int n=0; n Date: Mon, 24 Sep 2018 19:14:59 +0800 Subject: [PATCH 0117/3904] fix format --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 049b97cd4..aa2188457 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -8,7 +8,7 @@ int GetSymbolAuthority(const char* symbol) if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; if (is_STAKED() != 0) - printf("RETURNED CROSSCHAIN STAKED AS TRUE"); + printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } From b2c4fd58ecc344f9f92c34fdcf9a90d447b5f5a8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:45:17 +0800 Subject: [PATCH 0118/3904] add another print --- src/notarisationdb.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 779489fd8..0df999e53 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -24,6 +24,8 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); + printf("Parsed notarisation data for %s",data.symbol); + if (!parsed) data = NotarisationData(); int authority = GetSymbolAuthority(data.symbol); From 8496fdbeeded2173d0493448880938419ffb7587 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:49:10 +0800 Subject: [PATCH 0119/3904] better? --- src/notarisationdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 0df999e53..45aff2ac7 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -24,9 +24,10 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); - printf("Parsed notarisation data for %s",data.symbol); + printf("Parsed notarisation data for %s \n",data.symbol); if (!parsed) data = NotarisationData(); + printf("Parsed notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { From d75be221a0b256e3d60750b8fa5339bcce74d4bd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:55:23 +0800 Subject: [PATCH 0120/3904] fux stupid error --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- src/main.cpp | 2 +- src/notaries_staked.cpp | 6 ++---- src/notaries_staked.h | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index aa2188457..1b41c2aad 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED() != 0) + if (is_STAKED(symbol) != 0) printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4f1645f98..1b572b17c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -215,7 +215,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam else if ( ASSETCHAINS_SYMBOL[0] == 0 ) timestamp = 0; // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. - if (is_STAKED() == 0) + if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) { if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/main.cpp b/src/main.cpp index 596518ecf..89aea8360 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5954,7 +5954,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrFrom; uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( is_STAKED() != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 81d249d96..33dfa8bb5 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -2,8 +2,6 @@ #include "notaries_staked.h" #include -extern char ASSETCHAINS_SYMBOL[65]; - // Era 0 set of pubkeys const char *notaries_STAKED[][2] = { @@ -100,9 +98,9 @@ const char *notaries_STAKED3[][2] = int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); -int is_STAKED() { +int is_STAKED(const *char chain_name) { int STAKED = 0; - if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 84296d4e5..7d3748d4e 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -19,7 +19,7 @@ extern int num_notaries_STAKED2; extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; -int is_STAKED(); +int is_STAKED(const *char chain_name); int STAKED_era(int timestamp); #endif From 267745130baca8ddbd6db732f06ea7ca9e126643 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:58:56 +0800 Subject: [PATCH 0121/3904] ok --- src/notaries_staked.cpp | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 33dfa8bb5..0741ecd58 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -98,7 +98,7 @@ const char *notaries_STAKED3[][2] = int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); -int is_STAKED(const *char chain_name) { +int is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 7d3748d4e..d0df3906c 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -19,7 +19,7 @@ extern int num_notaries_STAKED2; extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; -int is_STAKED(const *char chain_name); +int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); #endif From 108c04eaf6bec0725bf1dc48074ff4936b571c12 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:03:01 +0800 Subject: [PATCH 0122/3904] more prints --- src/notarisationdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 45aff2ac7..9243cd17f 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -27,7 +27,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Parsed notarisation data for %s \n",data.symbol); if (!parsed) data = NotarisationData(); - printf("Parsed notarisation data for %s \n",data.symbol); + printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { @@ -47,6 +47,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight); } + printf("Authorised and added notarisation data for %s \n",data.symbol); return vNotarisations; } From 6f610e9bdd2cc400b082c833dceed8859cdd427e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:06:33 +0800 Subject: [PATCH 0123/3904] things --- src/notarisationdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 9243cd17f..b79527cca 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -35,6 +35,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) continue; } else if (authority == CROSSCHAIN_STAKED) { if (!CheckTxAuthority(tx, auth_STAKED)) + printf("Authorised notarisation data for %s \n",data.symbol); continue; } @@ -47,7 +48,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight); } - printf("Authorised and added notarisation data for %s \n",data.symbol); + printf("Added notarisation data\n"); return vNotarisations; } From 250cb3ffd4d0f47a5c4e81dce2e5ac911b91ed88 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:14:35 +0800 Subject: [PATCH 0124/3904] try again --- src/notarisationdb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index b79527cca..20b412979 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -34,13 +34,14 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; } else if (authority == CROSSCHAIN_STAKED) { + printf("Authorised notarisation data for %s \n",data.symbol); if (!CheckTxAuthority(tx, auth_STAKED)) - printf("Authorised notarisation data for %s \n",data.symbol); continue; } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); + printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); @@ -48,7 +49,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight); } - printf("Added notarisation data\n"); return vNotarisations; } From 93381421e1ca4ffc8c54a6ea390dae037c1a0190 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:21:31 +0800 Subject: [PATCH 0125/3904] more --- src/notarisationdb.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 20b412979..d9f1b2aeb 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -31,6 +31,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { + printf("Authorised notarisation data for %s \n",data.symbol); if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; } else if (authority == CROSSCHAIN_STAKED) { @@ -38,7 +39,8 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!CheckTxAuthority(tx, auth_STAKED)) continue; } - + printf("Authorised notarisation data for %s \n",data.symbol); + if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); printf("Added notarisation data for %s \n",data.symbol); From f7826be127553d469211c0c9cc97cdbdc65e6ad6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:41:19 +0800 Subject: [PATCH 0126/3904] test --- src/crosschain_authority.cpp | 4 +++- src/notarisationdb.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1b41c2aad..7f95d1533 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,9 +7,11 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED(symbol) != 0) + if (is_STAKED(symbol) != 0) { printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; + } + printf("RETURNED CROSSCHAIN KOMODO AS TRUE\n"); return CROSSCHAIN_KOMODO; } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index d9f1b2aeb..51b692270 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -40,7 +40,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) continue; } printf("Authorised notarisation data for %s \n",data.symbol); - + if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); printf("Added notarisation data for %s \n",data.symbol); From 43de331bef672f00acd64d9cbf4baa5f28afac55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:46:52 +0800 Subject: [PATCH 0127/3904] make staked chains not authorised to test if notarizations are still added --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7f95d1533..5c0897512 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED(symbol) != 0) { + if (is_STAKED("TEST") != 0) { printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; } From a8412c31cea05d6dc9a1e50998a725b9036965f3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:58:30 +0800 Subject: [PATCH 0128/3904] bail from check notarization if there is no valid notarization --- src/notarisationdb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 51b692270..ee99a8020 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -24,9 +24,13 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); + printf("Parsed notarisation data for %s \n",data.symbol); if (!parsed) data = NotarisationData(); + if (strlen(data.symbol) == 0) + continue; + printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); From 8010a2567c55c4ab28a4af4853a7af50084c4779 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:04:26 +0800 Subject: [PATCH 0129/3904] check --- src/notarisationdb.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index ee99a8020..916a5a185 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -30,7 +30,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!parsed) data = NotarisationData(); if (strlen(data.symbol) == 0) continue; - + printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); @@ -43,7 +43,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!CheckTxAuthority(tx, auth_STAKED)) continue; } - printf("Authorised notarisation data for %s \n",data.symbol); if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); From 7aea99c1a4abe7ef5893be07f37cc319d9be810c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:24:48 +0800 Subject: [PATCH 0130/3904] try and get timesstamp for crosschain auth height activation --- src/crosschain_authority.cpp | 1 - src/notarisationdb.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 5c0897512..78958b362 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,7 +53,6 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } - const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.requiredSigs = (num_notaries_STAKED / 5); diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 916a5a185..ee6b4d267 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -4,6 +4,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "main.h" +#include "notaries_staked.h" #include @@ -18,6 +19,9 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) { EvalRef eval; NotarisationsInBlock vNotarisations; + //CrosschainAuthority auth_STAKED; + int timestamp = komodo_heightstamp(nHeight); + printf("timestamp = %d",timestamp) for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; @@ -40,6 +44,8 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) continue; } else if (authority == CROSSCHAIN_STAKED) { printf("Authorised notarisation data for %s \n",data.symbol); + // We need to create auth_STAKED dynamically here based on timestamp + if (!CheckTxAuthority(tx, auth_STAKED)) continue; } From 2b91c1d732801f90a9e9d20f4dfcbd1f15e989d0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:29:20 +0800 Subject: [PATCH 0131/3904] try this instead --- src/notarisationdb.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index ee6b4d267..1b459e363 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -39,15 +39,14 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { - printf("Authorised notarisation data for %s \n",data.symbol); if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; - } else if (authority == CROSSCHAIN_STAKED) { printf("Authorised notarisation data for %s \n",data.symbol); + } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp - if (!CheckTxAuthority(tx, auth_STAKED)) continue; + printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { From f541d4a7d5b27c91b34b1d17dc72c11a18e1e4c7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:40:51 +0800 Subject: [PATCH 0132/3904] try pull from cBlock --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 1b459e363..8ec508e21 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -20,7 +20,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) EvalRef eval; NotarisationsInBlock vNotarisations; //CrosschainAuthority auth_STAKED; - int timestamp = komodo_heightstamp(nHeight); + int timestamp = block.nTime; printf("timestamp = %d",timestamp) for (unsigned int i = 0; i < block.vtx.size(); i++) { From 360925ac6a238c592589ee99e0df18e66dd92afd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:42:22 +0800 Subject: [PATCH 0133/3904] ; --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 8ec508e21..a2052c8bf 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -21,7 +21,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationsInBlock vNotarisations; //CrosschainAuthority auth_STAKED; int timestamp = block.nTime; - printf("timestamp = %d",timestamp) + printf("timestamp = %d",timestamp); for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; From 7d8a97e1f98ae9d72f56ba62a123409248c4f9e9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:51:13 +0800 Subject: [PATCH 0134/3904] reactivate staked auth, and try to fetch era from auto function --- src/crosschain_authority.cpp | 2 +- src/notarisationdb.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 78958b362..8dc8fc77f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED("TEST") != 0) { + if (is_STAKED(symbol) != 0) { printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index a2052c8bf..f4ba4dfe7 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -21,7 +21,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationsInBlock vNotarisations; //CrosschainAuthority auth_STAKED; int timestamp = block.nTime; - printf("timestamp = %d",timestamp); for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; @@ -44,6 +43,9 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp + printf("timestamp = %d\n",timestamp); + int staked_era = STAKED_era(timestamp); + printf("ERA = %d \n", ); if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From 9cdde9ca1257cbab6801beae2eae86ed2f24b88e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:53:00 +0800 Subject: [PATCH 0135/3904] oops --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index f4ba4dfe7..3811ccb8f 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -45,7 +45,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) // We need to create auth_STAKED dynamically here based on timestamp printf("timestamp = %d\n",timestamp); int staked_era = STAKED_era(timestamp); - printf("ERA = %d \n", ); + printf("ERA = %d \n",staked_era); if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From bb5402c9a9199db1ea64b7931e50eb2965445f02 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 22:10:37 +0800 Subject: [PATCH 0136/3904] add eras for cross chain auth? --- src/crosschain_authority.cpp | 2 ++ src/notarisationdb.cpp | 42 +++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 8dc8fc77f..ed7457e23 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,6 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } +/* const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.requiredSigs = (num_notaries_STAKED / 5); @@ -62,3 +63,4 @@ const CrosschainAuthority auth_STAKED = [&](){ sscanf(notaries_STAKED[n][1]+(i*2), "%2hhx", auth.notaries[n]+i); return auth; }(); +*/ diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 3811ccb8f..3c5234089 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -19,7 +19,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) { EvalRef eval; NotarisationsInBlock vNotarisations; - //CrosschainAuthority auth_STAKED; + CrosschainAuthority auth_STAKED; int timestamp = block.nTime; for (unsigned int i = 0; i < block.vtx.size(); i++) { @@ -43,9 +43,45 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp - printf("timestamp = %d\n",timestamp); int staked_era = STAKED_era(timestamp); - printf("ERA = %d \n",staked_era); + printf("ERA.(%d) \n",staked_era); + if (staked_era == 0) + { + // era 0 + auth_STAKED.requiredSigs = (num_notaries_STAKED / 5); + auth_STAKED.size = num_notaries_STAKED; + for (int n=0; n 3) { + printf("Invalid ERA.(%d), this should not happen",staked_era); + continue; + } + } if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From 3ae25942127ee7a1cfd8548c8bdba5adc2e0b208 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 22:13:38 +0800 Subject: [PATCH 0137/3904] } --- src/notarisationdb.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 3c5234089..685440d1a 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -81,7 +81,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Invalid ERA.(%d), this should not happen",staked_era); continue; } - } if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From 475e8bc5cb8c163cfa6b447af5321b759d9da6e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:22:38 +0800 Subject: [PATCH 0138/3904] add era gap, and change to start at era 1 instead of 0. --- src/komodo_notary.h | 41 ++++++++++++++++----------- src/notaries_staked.cpp | 61 +++++++++++++++++++++-------------------- src/notaries_staked.h | 14 ++++++---- src/notarisationdb.cpp | 20 ++++++++------ 4 files changed, 76 insertions(+), 60 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1b572b17c..3dc0c05f3 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -206,8 +206,9 @@ const char *Notaries_elected1[][2] = int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys[64][33],staked_pubkeys1[64][33],didstaked,didstaked1; static int32_t ns,ns1; - static uint8_t staked_pubkeys2[64][33],staked_pubkeys3[64][33],didstaked2,didstaked3; static int32_t ns2,ns3; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; + static uint8_t null_pubkeys[64][33]; int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -250,23 +251,11 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } } else - { // here we can activate our pubkeys. + { // here we can activate our pubkeys for STAKED chains by era. if (timestamp != 0) { staked_era = STAKED_era(timestamp); - if (staked_era == 0) - { - if (didstaked == 0) - { - ns = num_notaries_STAKED; - for (i=0; i -// Era 0 set of pubkeys -const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); - // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = { @@ -98,6 +74,30 @@ const char *notaries_STAKED3[][2] = int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); +// Era 4 set of pubkeys +const char *notaries_STAKED4[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); + int is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) @@ -108,13 +108,16 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int era; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP) - era = 0; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 && timestamp >= STAKED_NOTARIES_TIMESTAMP) + if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 era = 1; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= STAKED_NOTARIES_TIMESTAMP1) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) era = 2; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= STAKED_NOTARIES_TIMESTAMP2) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + era = 4; + else + era = 0; + // if we are in a gap, return era 0, so any notarizations submitted are invalid. return(era); } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index d0df3906c..6c51a0050 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,13 +2,12 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -static const int STAKED_NOTARIES_TIMESTAMP = 1537780949; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537791749; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537802549; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537813349; +static const int STAKED_ERA_GAP = 777; -extern const char *notaries_STAKED[][2]; -extern int num_notaries_STAKED; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537780949; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537791749; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537802549; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537813349; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; @@ -19,6 +18,9 @@ extern int num_notaries_STAKED2; extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; +extern const char *notaries_STAKED4[][2]; +extern int num_notaries_STAKED4; + int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 685440d1a..9f2610feb 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -47,12 +47,9 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { - // era 0 - auth_STAKED.requiredSigs = (num_notaries_STAKED / 5); - auth_STAKED.size = num_notaries_STAKED; - for (int n=0; n 3) { - printf("Invalid ERA.(%d), this should not happen",staked_era); - continue; + } else if (staked_era == 4) + { + // era 4 + auth_STAKED.requiredSigs = (num_notaries_STAKED4 / 5); + auth_STAKED.size = num_notaries_STAKED4; + for (int n=0; n Date: Mon, 24 Sep 2018 23:25:33 +0800 Subject: [PATCH 0139/3904] ) --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 2c45b5dbd..f7d64a168 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -108,7 +108,7 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int era; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 + if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) era = 2; From 595f3d7a5fbb7efd47d6e1c5d68eb4b1ed29e769 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:27:45 +0800 Subject: [PATCH 0140/3904] fix pointless print --- src/notarisationdb.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 9f2610feb..4e0be704a 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -27,9 +27,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); - - printf("Parsed notarisation data for %s \n",data.symbol); - if (!parsed) data = NotarisationData(); if (strlen(data.symbol) == 0) continue; From 01b6ef666a5da230a6ab73ade08c052ac7e83d9c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:46:08 +0800 Subject: [PATCH 0141/3904] add check for num vins over 2 for all AC --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index d1587fbb4..3fef07475 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized. { static FILE *signedfp; if ( signedfp == 0 ) From 6368a83fe3c921581dd20fb32ac518515f938bec Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:51:38 +0800 Subject: [PATCH 0142/3904] retest gap --- src/komodo.h | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3fef07475..ead20f034 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized. + if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized.u { static FILE *signedfp; if ( signedfp == 0 ) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 6c51a0050..aab392301 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1537780949; static const int STAKED_NOTARIES_TIMESTAMP2 = 1537791749; static const int STAKED_NOTARIES_TIMESTAMP3 = 1537802549; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537813349; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537805431; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From b60948261bf96b7acfd3a9d83795987811583e3a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 00:03:00 +0800 Subject: [PATCH 0143/3904] reset eras, try from reqync --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index aab392301..f1af9595a 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -4,10 +4,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537780949; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537791749; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537802549; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537805431; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537807474; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537818274; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537839874; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 2cf2e5f83ed27dcf45b1b98d57683819b7b93f49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 01:17:49 +0800 Subject: [PATCH 0144/3904] try to zero array of pubkeys --- src/komodo.h | 2 +- src/komodo_notary.h | 18 +++++++++--------- src/notarisationdb.cpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ead20f034..d8376d15c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized.u + if ( ASSETCHAINS_SYMBOL[0] != 0) { static FILE *signedfp; if ( signedfp == 0 ) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3dc0c05f3..352316e77 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -208,7 +208,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33]; + static uint8_t null_pubkeys[64][33] = {0}; int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -263,7 +263,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam for (i=0; i Date: Tue, 25 Sep 2018 10:16:05 +0800 Subject: [PATCH 0145/3904] that didnt work, try another way --- src/komodo.h | 5 ++++- src/komodo_notary.h | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d8376d15c..3c708989f 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,6 +831,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) != 0)) + printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); + continue; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; @@ -857,7 +860,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5)) ) + numvalid > (numnotaries/5))) { if ( ASSETCHAINS_SYMBOL[0] != 0) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 352316e77..de343e184 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -305,12 +305,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam return(ns4); } else if (staked_era == 0) { - // this means we are in a gap, so we set the array of pubkeys to zero, so all notarizations are invalid. + // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. for (i=0; i<1; i++) decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); - printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we ignored it.\n",ASSETCHAINS_SYMBOL); + printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); memcpy(pubkeys,null_pubkeys,64 * 33); - return(2); + return(64); } } } From 2e82dcdf8efccdbc3c2c3787f0d1b91276ed4cd2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 10:19:27 +0800 Subject: [PATCH 0146/3904] change eras --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index f1af9595a..5545f8714 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -4,9 +4,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537807474; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537818274; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537839874; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537839874; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537843474; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537847074; static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; extern const char *notaries_STAKED1[][2]; From 582b359c15385428800f7eb75661510d5690e3f7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 10:24:15 +0800 Subject: [PATCH 0147/3904] == 0 --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 3c708989f..7c927a3d8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,7 +831,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) != 0)) + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era(pindex->GetBlockTime()) == 0)) printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; txhash = block.vtx[i].GetHash(); From 3e86777927d5bf04a5064248659ca11eb2994f3d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 13:49:15 +0800 Subject: [PATCH 0148/3904] try move crosschain auth to a function, and clean up code a bit. --- src/crosschain_authority.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ed7457e23..6c8df2219 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,6 +53,15 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen,int num_notaries){ + CrosschainAuthority auth; + auth.requiredSigs = (num_notaries / 5); + auth.size = num_notaries; + for (int n=0; n Date: Tue, 25 Sep 2018 14:16:39 +0800 Subject: [PATCH 0149/3904] timstaps --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 5545f8714..5d2450f0b 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -4,10 +4,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537839874; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537843474; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537847074; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537859688; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537863288; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537866888; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537870488; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 562d0132f7a532a8c1c1ce78707fe58e23ce803c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 14:20:21 +0800 Subject: [PATCH 0150/3904] test --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6c8df2219..be54f2a43 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,7 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen,int num_notaries){ +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ CrosschainAuthority auth; auth.requiredSigs = (num_notaries / 5); auth.size = num_notaries; From 84f0f23626ec988d8726b688816fdc9ee95fbdf0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 14:25:27 +0800 Subject: [PATCH 0151/3904] try call function --- src/notarisationdb.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index fd2d9cac0..1867aa748 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -50,11 +50,14 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (staked_era == 1) { // era 1 + auth_STAKED = auth_STAKED_chosen(notaries_STAKED,num_notaries_STAKED); + /* auth_STAKED.requiredSigs = (num_notaries_STAKED1 / 5); auth_STAKED.size = num_notaries_STAKED1; for (int n=0; n Date: Tue, 25 Sep 2018 14:27:08 +0800 Subject: [PATCH 0152/3904] 1 --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 1867aa748..be1ae5dfa 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -50,7 +50,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (staked_era == 1) { // era 1 - auth_STAKED = auth_STAKED_chosen(notaries_STAKED,num_notaries_STAKED); + auth_STAKED = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1); /* auth_STAKED.requiredSigs = (num_notaries_STAKED1 / 5); auth_STAKED.size = num_notaries_STAKED1; From f16893312fe10e00eec9f88fd9b07eb1a6a346a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 14:29:22 +0800 Subject: [PATCH 0153/3904] try that --- src/crosschain.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain.h b/src/crosschain.h index 65be53f92..75c0b2e9f 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -13,7 +13,7 @@ typedef struct CrosschainAuthority { size_t requiredSigs; } CrosschainAuthority; -extern const CrosschainAuthority auth_STAKED; +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); int GetSymbolAuthority(const char* symbol); bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth); From 07f90f985292e2991ad1e0c5db0202b34475c27e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 15:17:51 +0800 Subject: [PATCH 0154/3904] move cross chain choose to staked.cpp --- src/crosschain.h | 2 -- src/crosschain_authority.cpp | 10 +--------- src/notaries_staked.cpp | 11 +++++++++++ src/notaries_staked.h | 3 +++ src/notarisationdb.cpp | 7 ------- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/crosschain.h b/src/crosschain.h index 75c0b2e9f..29b6bec4b 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -13,8 +13,6 @@ typedef struct CrosschainAuthority { size_t requiredSigs; } CrosschainAuthority; -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); - int GetSymbolAuthority(const char* symbol); bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth); diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index be54f2a43..ef09c5e00 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,15 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ - CrosschainAuthority auth; - auth.requiredSigs = (num_notaries / 5); - auth.size = num_notaries; - for (int n=0; n // Era 1 set of pubkeys @@ -121,3 +122,13 @@ int STAKED_era(int timestamp) // if we are in a gap, return era 0, so any notarizations submitted are invalid. return(era); } + +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ + CrosschainAuthority auth; + auth.requiredSigs = (num_notaries / 5); + auth.size = num_notaries; + for (int n=0; n Date: Tue, 25 Sep 2018 15:19:21 +0800 Subject: [PATCH 0155/3904] opps --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index f6139cc98..375077cac 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -24,7 +24,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); -CrosschainAuthority Choose_auth_STAKED(staked_era) +//CrosschainAuthority Choose_auth_STAKED(staked_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); #endif From a2d3bd9f849129a37d0d85820d2211d52a24d257 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 15:21:04 +0800 Subject: [PATCH 0156/3904] try --- src/notaries_staked.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 375077cac..c5ffe5219 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,6 +2,8 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED +#include "crosschain.h" + static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1537859688; From 211f57fb452943fe44ece0be3f6a513a52c3c942 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 15:40:44 +0800 Subject: [PATCH 0157/3904] tidy up --- src/notaries_staked.cpp | 27 +++++++++++++++++++++++---- src/notaries_staked.h | 2 +- src/notarisationdb.cpp | 38 ++++++-------------------------------- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d2cc0bafb..489a9ea78 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -115,15 +115,34 @@ int STAKED_era(int timestamp) era = 2; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; else era = 0; - // if we are in a gap, return era 0, so any notarizations submitted are invalid. + // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. return(era); -} +}; -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ +CrosschainAuthority Choose_auth_STAKED(int chosen_era) { + CrosschainAuthority auth; + switch (chosen_era) { + case 1: + auth = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1); + break; + case 2: + auth = auth_STAKED_chosen(notaries_STAKED2,num_notaries_STAKED2); + break; + case 3: + auth = auth_STAKED_chosen(notaries_STAKED3,num_notaries_STAKED3); + break; + case 4: + auth = auth_STAKED_chosen(notaries_STAKED4,num_notaries_STAKED4); + break; + } + return(auth); +}; + +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries) { CrosschainAuthority auth; auth.requiredSigs = (num_notaries / 5); auth.size = num_notaries; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index c5ffe5219..3776c6828 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -26,7 +26,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); -//CrosschainAuthority Choose_auth_STAKED(staked_era); +CrosschainAuthority Choose_auth_STAKED(int chosen_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); #endif diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index acd1d2287..68c00546b 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -31,50 +31,24 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (strlen(data.symbol) == 0) continue; - printf("Checked notarisation data for %s \n",data.symbol); + //printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; - printf("Authorised notarisation data for %s \n",data.symbol); + //printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int staked_era = STAKED_era(timestamp); printf("ERA.(%d) \n",staked_era); - if (staked_era == 0) - { + if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; - } else if (staked_era == 1) - { - // era 1 - auth_STAKED = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1); - } else if (staked_era == 2) - { - // era 2 - auth_STAKED.requiredSigs = (num_notaries_STAKED2 / 5); - auth_STAKED.size = num_notaries_STAKED2; - for (int n=0; n Date: Tue, 25 Sep 2018 15:41:55 +0800 Subject: [PATCH 0158/3904] ) --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 489a9ea78..9a91b9d84 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -115,7 +115,7 @@ int STAKED_era(int timestamp) era = 2; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; - else if timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if (timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; else era = 0; From 1a948db4fda982931c763e62b847d3a54ab35a7e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 16:38:39 +0800 Subject: [PATCH 0159/3904] who knows --- src/crosschain_authority.cpp | 4 ++-- src/komodo_notary.h | 2 +- src/notaries_staked.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ef09c5e00..8116b2887 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -8,10 +8,10 @@ int GetSymbolAuthority(const char* symbol) if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; if (is_STAKED(symbol) != 0) { - printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); + //printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; } - printf("RETURNED CROSSCHAIN KOMODO AS TRUE\n"); + //printf("RETURNED CROSSCHAIN KOMODO AS TRUE\n"); return CROSSCHAIN_KOMODO; } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index de343e184..4f5f7aea7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -305,7 +305,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam return(ns4); } else if (staked_era == 0) { - // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. + // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell, fix here welcome. for (i=0; i<1; i++) decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 3776c6828..c87f27f98 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537859688; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537863288; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537866888; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537870488; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537868073; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537871673; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537875273; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537878873; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 75979d037a877904965ae852a012d6713c2ad970 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 17:27:10 +0800 Subject: [PATCH 0160/3904] increse era wtf happened there lol --- src/notaries_staked.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 5545f8714..0a722f512 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,12 +2,14 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED +#include "crosschain.h" + static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537839874; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537843474; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537847074; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537871673; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537875273; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537878873; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537895873; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; @@ -24,4 +26,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); +CrosschainAuthority Choose_auth_STAKED(int chosen_era); +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); + #endif From 3aee2fae5e4125627b692d013d119a9284445082 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Tue, 25 Sep 2018 17:38:18 +0800 Subject: [PATCH 0161/3904] hopefully fixed that lol --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9a91b9d84..e2170ba94 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -115,7 +115,7 @@ int STAKED_era(int timestamp) era = 2; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; - else if (timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; else era = 0; From 15fe2fb59dada5d57d36b4413be7f271fb44aa90 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 17:50:51 +0800 Subject: [PATCH 0162/3904] I think this might be it --- src/komodo_notary.h | 4 ++-- src/notaries_staked.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4f5f7aea7..a4e673b79 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -306,8 +306,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } else if (staked_era == 0) { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell, fix here welcome. - for (i=0; i<1; i++) - decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); + //for (i=0; i<1; i++) + // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); memcpy(pubkeys,null_pubkeys,64 * 33); return(64); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index c87f27f98..03ed5f306 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537868073; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537871673; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537875273; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537878873; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537872577; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537876177; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537879777; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537883377; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 8abbd8e183bb4b431f0488e96fb93bf63fc9ab55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 17:56:49 +0800 Subject: [PATCH 0163/3904] meh --- src/komodo.h | 4 ++-- src/komodo_notary.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7c927a3d8..66374f6fe 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,9 +858,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || + if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5))) + numvalid > (numnotaries/5) ) { if ( ASSETCHAINS_SYMBOL[0] != 0) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index a4e673b79..84d0cbed1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -308,9 +308,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell, fix here welcome. //for (i=0; i<1; i++) // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); - printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); - memcpy(pubkeys,null_pubkeys,64 * 33); - return(64); + printf("%s IS A STAKED CHAIN and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); + //memcpy(pubkeys,null_pubkeys,64 * 33); + return(0); } } } From 7422645f78c5c4d7998861e4f7fb5fb4a02a4fa0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:08:30 +0800 Subject: [PATCH 0164/3904] add print for numvalid --- src/komodo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo.h b/src/komodo.h index 7c927a3d8..6fc219c32 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,6 +858,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); + printf("numvalid.%d \n",numvalid); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5))) From b9673a33a8a62cc443ff840255cdce87989b65af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:14:13 +0800 Subject: [PATCH 0165/3904] more rpints --- src/komodo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo.h b/src/komodo.h index 6fc219c32..b0056f6c7 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -810,6 +810,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); + printf("numnotaries.%d\n",numnotaries); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; From ad98d05ba1938404adf32223fee9e82fd1e0265f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:26:47 +0800 Subject: [PATCH 0166/3904] more prints --- src/komodo.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index b0056f6c7..e7ea104aa 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -810,7 +810,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); - printf("numnotaries.%d\n",numnotaries); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; @@ -826,8 +825,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->nHeight); + printf("BEFORE pindex != 0 check.\n", ); if ( pindex != 0 ) { + printf("AFTER pindex != 0 check.\n", ); height = pindex->nHeight; txn_count = block.vtx.size(); for (i=0; i 0 ) { @@ -860,9 +862,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } numvalid = bitweight(signedmask); printf("numvalid.%d \n",numvalid); - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || + if (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5))) + numvalid > (numnotaries/5)) { if ( ASSETCHAINS_SYMBOL[0] != 0) { From aeeec99a0b3830a23e1e756f652f2caafcbd00cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:28:50 +0800 Subject: [PATCH 0167/3904] oops --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e7ea104aa..937e1f788 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,10 +825,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->nHeight); - printf("BEFORE pindex != 0 check.\n", ); + printf("BEFORE pindex != 0 check.\n"); if ( pindex != 0 ) { - printf("AFTER pindex != 0 check.\n", ); + printf("AFTER pindex != 0 check.\n"); height = pindex->nHeight; txn_count = block.vtx.size(); for (i=0; i Date: Tue, 25 Sep 2018 18:29:52 +0800 Subject: [PATCH 0168/3904] opps --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 937e1f788..7d2a75b4e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -845,7 +845,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (j=0; j 0 ) { From 233666172a91564fc01b1c445a4f29bdb13b7e95 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:33:28 +0800 Subject: [PATCH 0169/3904] maybe this lol --- src/komodo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7d2a75b4e..0425a5002 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,17 +825,17 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->nHeight); - printf("BEFORE pindex != 0 check.\n"); if ( pindex != 0 ) { - printf("AFTER pindex != 0 check.\n"); height = pindex->nHeight; txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) == 0)) + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era(pindex->GetBlockTime()) == 0)) { printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; + } + printf("we working now?\n"); txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; From b3cb6ec56de629090cb986902b8bc6c315d537e0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:37:02 +0800 Subject: [PATCH 0170/3904] fix --- src/komodo.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0425a5002..c4200a1e8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -835,7 +835,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } - printf("we working now?\n"); txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; @@ -845,7 +844,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (j=0; j 0 ) { From 5b1b6887ecdec3f463d4318d1bc1176d828c02c4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:41:08 +0800 Subject: [PATCH 0171/3904] good --- src/komodo.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index c4200a1e8..cc2a5dd3d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); - printf("numvalid.%d \n",numvalid); if (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) From 4becb91f8e90fca4e31becf2e683e6f99e99b53d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:42:30 +0800 Subject: [PATCH 0172/3904] fix silly mistake --- src/komodo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 66374f6fe..fb40c1e09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,9 +831,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) == 0)) + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era(pindex->GetBlockTime()) == 0)) { printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; + } txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; From 6ecc2a17bf75b6847dcd2a0ea99c443add9a944d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:53:32 +0800 Subject: [PATCH 0173/3904] new timestamps try again lol --- src/komodo_notary.h | 4 ++-- src/notaries_staked.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 84d0cbed1..1e764a603 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -309,8 +309,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam //for (i=0; i<1; i++) // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); printf("%s IS A STAKED CHAIN and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - //memcpy(pubkeys,null_pubkeys,64 * 33); - return(0); + memcpy(pubkeys,null_pubkeys,64 * 33); + return(64); } } } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 03ed5f306..12aae29d3 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537872577; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537876177; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537879777; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537883377; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537876325; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537879925; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537883525; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537983525; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 2e25cdf0a4958f156d62eaf6105dafa0402c7e32 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Wed, 26 Sep 2018 02:26:48 +0000 Subject: [PATCH 0174/3904] add STAKEDED --- src/assetchains.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/assetchains.json b/src/assetchains.json index 9faa54f16..00c491935 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -52,5 +52,15 @@ "195.201.137.5", "195.201.20.230" ] + }, + { + "ac_name": "STAKEDED", + "ac_supply": "1072452", + "ac_reward" : "1000000000", + "ac_cc": "667", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] } ] From dcffb1c796c151fe528a3c600c6d3be68bb8b11a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 11:30:31 +0800 Subject: [PATCH 0175/3904] change ERA's --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 12aae29d3..526ad5f9b 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1537876325; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537879925; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537883525; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537983525; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537983525; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1538083525; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1548083525; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From dee9067adc99f3d677417bf40aa5b83c770522e9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 14:53:41 +0800 Subject: [PATCH 0176/3904] modified: src/komodo_notary.h --- src/komodo_notary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index de343e184..0365a1faf 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -306,9 +306,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } else if (staked_era == 0) { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. - for (i=0; i<1; i++) - decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); - printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); + //for (i=0; i<1; i++) + // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); + printf("%s IS A STAKED CHAIN and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); memcpy(pubkeys,null_pubkeys,64 * 33); return(64); } From 79171fa13b55fcb4445e5dbb5a0255bf8489839b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 15:03:55 +0800 Subject: [PATCH 0177/3904] try to add error check if export/import chain is the same --- src/rpccrosschain.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 09f1b21d1..baa4d4984 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -50,7 +50,7 @@ UniValue assetchainproof(const UniValue& params, bool fHelp) UniValue crosschainproof(const UniValue& params, bool fHelp) { - + } @@ -90,7 +90,7 @@ UniValue height_MoM(const UniValue& params, bool fHelp) ret.push_back(Pair("kmdendi",kmdendi)); } } else ret.push_back(Pair("error",(char *)"no MoM for height")); - + return ret; } @@ -169,6 +169,9 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); + if (strncmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) + throw runtime_error("cant send a coin to the same chain"); + CAmount burnAmount = AmountFromValue(params[2]); if (burnAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export"); @@ -220,8 +223,8 @@ UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp) CTransaction burnTx; if (!E_UNMARSHAL(txData, ss >> burnTx)) throw runtime_error("Couldn't parse burnTx"); - - + + vector payouts; if (!E_UNMARSHAL(ParseHexV(params[1], "argument 2"), ss >> payouts)) throw runtime_error("Couldn't parse payouts"); @@ -240,7 +243,7 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp) throw runtime_error("migrate_completeimporttransaction importTx\n\n" "Takes a cross chain import tx with proof generated on assetchain " "and extends proof to target chain proof root"); - + if (ASSETCHAINS_SYMBOL[0] != 0) throw runtime_error("Must be called on KMD"); @@ -294,7 +297,7 @@ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp) if (height == 0) { height = chainActive.Height(); } - + Notarisation nota; int matchedHeight = ScanNotarisationsDB(height, symbol, limit, nota); if (!matchedHeight) return NullUniValue; From 054eb923f9c4266f085edd04e47c1a08e5ebee55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 15:56:38 +0800 Subject: [PATCH 0178/3904] n --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index baa4d4984..15e7a0393 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - if (strncmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) throw runtime_error("cant send a coin to the same chain"); CAmount burnAmount = AmountFromValue(params[2]); From 7d7b68dc6fe6b42a3207474055ea5929021e5db1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 15:58:23 +0800 Subject: [PATCH 0179/3904] maybe thos willl work --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 15e7a0393..eaa059ec8 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) + if (ASSETCHAINS_SYMBOL == targetSymbol) throw runtime_error("cant send a coin to the same chain"); CAmount burnAmount = AmountFromValue(params[2]); From 66874998de55e44ffbcda4c750b05fb2ee99466d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 16:02:36 +0800 Subject: [PATCH 0180/3904] or this --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index eaa059ec8..52df5efaf 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - if (ASSETCHAINS_SYMBOL == targetSymbol) + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); CAmount burnAmount = AmountFromValue(params[2]); From 3e94e0a37bd3e0b1980d7f6c4328d47645e08e8b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 16:59:52 +0800 Subject: [PATCH 0181/3904] hmmm --- src/rpccrosschain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 52df5efaf..83554d1f6 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,6 +169,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); + printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()) + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From dc43d728486b5b5b550b23204fbddcb0372877be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:04:02 +0800 Subject: [PATCH 0182/3904] ; --- src/rpccrosschain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 83554d1f6..e991de71e 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,8 +169,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()) - + printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From 42df9ee0602ef7d63716bb7c9da9de8c87749289 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:19:17 +0800 Subject: [PATCH 0183/3904] try this --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index e991de71e..f92632c8b 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); + fprintf(stderr,"source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From 1a0749e538df926521b6eeda6820e4d15d77410c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:24:06 +0800 Subject: [PATCH 0184/3904] remove non wokring print --- src/rpccrosschain.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index f92632c8b..52df5efaf 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,8 +169,6 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - fprintf(stderr,"source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); - if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From 396d4e42099cdad584573935e8d7c8fad7635eb2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:25:02 +0800 Subject: [PATCH 0185/3904] Add error for sending coin to source chain --- src/rpccrosschain.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 09f1b21d1..52df5efaf 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -50,7 +50,7 @@ UniValue assetchainproof(const UniValue& params, bool fHelp) UniValue crosschainproof(const UniValue& params, bool fHelp) { - + } @@ -90,7 +90,7 @@ UniValue height_MoM(const UniValue& params, bool fHelp) ret.push_back(Pair("kmdendi",kmdendi)); } } else ret.push_back(Pair("error",(char *)"no MoM for height")); - + return ret; } @@ -169,6 +169,9 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) + throw runtime_error("cant send a coin to the same chain"); + CAmount burnAmount = AmountFromValue(params[2]); if (burnAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export"); @@ -220,8 +223,8 @@ UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp) CTransaction burnTx; if (!E_UNMARSHAL(txData, ss >> burnTx)) throw runtime_error("Couldn't parse burnTx"); - - + + vector payouts; if (!E_UNMARSHAL(ParseHexV(params[1], "argument 2"), ss >> payouts)) throw runtime_error("Couldn't parse payouts"); @@ -240,7 +243,7 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp) throw runtime_error("migrate_completeimporttransaction importTx\n\n" "Takes a cross chain import tx with proof generated on assetchain " "and extends proof to target chain proof root"); - + if (ASSETCHAINS_SYMBOL[0] != 0) throw runtime_error("Must be called on KMD"); @@ -294,7 +297,7 @@ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp) if (height == 0) { height = chainActive.Height(); } - + Notarisation nota; int matchedHeight = ScanNotarisationsDB(height, symbol, limit, nota); if (!matchedHeight) return NullUniValue; From e5eda68dbd79448bef5a9ec3700014ff585a6dbe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 18:00:28 +0800 Subject: [PATCH 0186/3904] remove all prints that are not momom that we normally see --- src/komodo.h | 18 +++++++++--------- src/komodo_bitcoind.h | 34 +++++++++++++++++----------------- src/notarisationdb.cpp | 6 +++--- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index fb40c1e09..dcb5f63de 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); + //printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); @@ -856,7 +856,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("%02x",scriptPubKey[k]); printf(" scriptPubKey doesnt match any notary vini.%d of %d\n",j,numvins); } - } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); + } //else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || @@ -880,7 +880,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + //printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; } @@ -917,20 +917,20 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { for (k=0; k 2 ) { @@ -959,8 +959,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); - printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); - } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); + //printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); + } //else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); } } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 13501d2a9..4a2a9fc41 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -169,7 +169,7 @@ try_again: curl_handle = curl_easy_init(); init_string(&s); headers = curl_slist_append(0,"Expect:"); - + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); @@ -198,7 +198,7 @@ try_again: bracket0 = (char *)"["; bracket1 = (char *)"]"; } - + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); @@ -238,7 +238,7 @@ try_again: free(s.ptr); sleep((1<= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ @@ -1303,24 +1303,24 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he { n++; percPoS++; - if ( ASSETCHAINS_STAKED < 100 ) - fprintf(stderr,"0"); + //if ( ASSETCHAINS_STAKED < 100 ) + // fprintf(stderr,"0"); } else { - if ( ASSETCHAINS_STAKED < 100 ) - fprintf(stderr,"1"); + //if ( ASSETCHAINS_STAKED < 100 ) + // fprintf(stderr,"1"); sum += UintToArith256(pindex->GetBlockHash()); m++; } } - if ( ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) - fprintf(stderr," %d, ",percPoS); + //if ( ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) + // fprintf(stderr," %d, ",percPoS); } if ( m+n < 100 ) percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; if ( ASSETCHAINS_STAKED < 100 ) - fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); + //fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; if ( m > 0 ) { @@ -1337,7 +1337,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( oldflag != 0 ) bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); else bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); - if ( ASSETCHAINS_STAKED < 100 ) + /*if ( ASSETCHAINS_STAKED < 100 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1348,7 +1348,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&target)[i]); fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); - } + }*/ } else if ( percPoS > goalperc ) // decrease PoW diff -> raise bnTarget { @@ -1367,7 +1367,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( bnTarget < ave ) bnTarget = ave; } - if ( 1 ) + /*if ( 1 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1378,7 +1378,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&target)[i]); fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); - } + }*/ } else bnTarget = ave; // recent ave is perfect return(bnTarget); diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 68c00546b..426cdb806 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -44,7 +44,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization - printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); + //printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; } else { // pass era slection off to notaries_staked.cpp file @@ -52,12 +52,12 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } if (!CheckTxAuthority(tx, auth_STAKED)) continue; - printf("Authorised notarisation data for %s \n",data.symbol); + //printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - printf("Added notarisation data for %s \n",data.symbol); + //printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); From f0587239fa5fe099f9d6b9b7d3bc004e5fc2aef1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 19:04:24 +0800 Subject: [PATCH 0187/3904] found more --- src/komodo.h | 16 ++++++++-------- src/notarisationdb.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index dcb5f63de..1846fd25c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -620,8 +620,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr notarized = 1; if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 ) notarized = 1; - if ( 0 && opretlen != 149 ) - printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); + //if ( 0 && opretlen != 149 ) + // printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash); len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); if ( matched != 0 ) @@ -685,8 +685,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - if ( matched != 0 ) - printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); + //if ( matched != 0 ) + // printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); @@ -706,8 +706,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->MoMdepth = MoMdepth; } komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + // printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -733,8 +733,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } } } - } else if ( opretlen != 149 && height > 600000 && matched != 0 ) - printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); + } //else if ( opretlen != 149 && height > 600000 && matched != 0 ) + //printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 426cdb806..df17de2c7 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -41,7 +41,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int staked_era = STAKED_era(timestamp); - printf("ERA.(%d) \n",staked_era); + //printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization //printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); From a5c1bc3360cfcae92204e36d575c25fb77b10233 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 19:50:45 +0800 Subject: [PATCH 0188/3904] add target to MoMoM print --- src/cc/import.cpp | 4 ++-- src/crosschain.cpp | 2 +- src/komodo_bitcoind.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index cc0c3b61f..dc5eff440 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,11 +79,11 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("IMPORT momom: %s\n", momom.GetHex().data()); + printf("[%s] IMPORT momom: %s\n", targetSymbol,momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) - return Invalid("momom-check-fail"); + return Invalid("momom-check-fai"); } return Valid(); diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 23416c682..335bcc6c8 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,7 +162,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); + printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); // Find index of source MoM in MoMoM int nIndex; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4a2a9fc41..4a354830d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1445,7 +1445,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( isPoS != 2 ) { - fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); + //fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); isPoS = 0; } else From eddc4d53952181123454a5fe991e0290c65c62fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 20:00:40 +0800 Subject: [PATCH 0189/3904] remove for import, compile angry --- src/cc/import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index dc5eff440..578e6a52b 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,7 +79,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("[%s] IMPORT momom: %s\n", targetSymbol,momom.GetHex().data()); + printf("IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) From 32ed8b04441f1ed1e2419a2691e0822ae8e5b62e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 20:32:37 +0800 Subject: [PATCH 0190/3904] another one --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4a354830d..5afb549cc 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1453,7 +1453,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) { - fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); + //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; } } From 97a59fc2c62aa2452b79c1abb19951e6e2d0d704 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 20:57:58 +0800 Subject: [PATCH 0191/3904] fprintf? --- src/cc/import.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 578e6a52b..fd0126ad4 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -78,8 +78,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp uint256 momom, target; if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - - printf("IMPORT momom: %s\n", momom.GetHex().data()); + + fprintf(stderr,"IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) From 985808cbb40f0b8fb5c66e5c3d99579a14bc2d0a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 21:38:00 +0800 Subject: [PATCH 0192/3904] try print momom to file --- src/cc/import.cpp | 6 +++++- src/crosschain.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index fd0126ad4..1f96a5d29 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -78,8 +78,12 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp uint256 momom, target; if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - + fprintf(stderr,"IMPORT momom: %s\n", momom.GetHex().data()); + FILE * fptr; + fptr = fopen("/home/cc/kmdmomom", "a+"); + fprintf(fptr, "%s\n", momom.GetHex().data()); + fclose(fptr); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 335bcc6c8..137e823ab 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -163,6 +163,10 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ throw std::runtime_error("No MoMs found"); printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); + FILE * fptr; + fptr = fopen("/home/cc/acmomom", "a+"); + fprintf(fptr, "%s\n", MoMoM.GetHex().data()); + fclose(fptr); // Find index of source MoM in MoMoM int nIndex; From 2782c1fb5b9a3afd70a8bb2ec9dd9a968feed195 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 12:31:16 +0800 Subject: [PATCH 0193/3904] fix error typo --- src/cc/import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 1f96a5d29..b72124735 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -87,7 +87,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) - return Invalid("momom-check-fai"); + return Invalid("momom-check-fail"); } return Valid(); From f56c91238afddd751cd34158f6aa8d2a0748ed42 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 12:49:40 +0800 Subject: [PATCH 0194/3904] change ac_private pubkeys to use STAKED notaries instead of elected --- src/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4fabaeb29..5a4d5c152 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,8 @@ #include "wallet/asyncrpcoperation_sendmany.h" #include "wallet/asyncrpcoperation_shieldcoinbase.h" +#include "notaries_staked.h" + #include #include @@ -1045,21 +1047,21 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; + static int32_t didinit; static char notaryaddrs[sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) + 1][64]; int32_t i; if ( didinit == 0 ) { uint8_t pubkey33[33]; - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) { - if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) - decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); + if ( i < sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) ) + decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); } didinit = 1; } - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); return(0); From c6fb1e911760c72a40447342c7da24937d1c9580 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 13:00:09 +0800 Subject: [PATCH 0195/3904] try this instead --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5a4d5c152..90dac54aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1047,21 +1047,21 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - static int32_t didinit; static char notaryaddrs[sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) + 1][64]; + static int32_t didinit; static char notaryaddrs[num_notaries_STAKED1 + 1][64]; int32_t i; if ( didinit == 0 ) { uint8_t pubkey33[33]; - for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) + for (i=0; i<=num_notaries_STAKED1; i++) { - if ( i < sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) ) + if ( i < num_notaries_STAKED1 ) decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); } didinit = 1; } - for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) + for (i=0; i<=num_notaries_STAKED1; i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); return(0); From d5f8644985e50469a3efebe57c4033dfcef3551a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 13:07:38 +0800 Subject: [PATCH 0196/3904] change array to non static and remove init --- src/main.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 90dac54aa..b3e31681c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1047,20 +1047,16 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - static int32_t didinit; static char notaryaddrs[num_notaries_STAKED1 + 1][64]; + char notaryaddrs[num_notaries_STAKED1 + 1][64]; int32_t i; - if ( didinit == 0 ) - { - uint8_t pubkey33[33]; - for (i=0; i<=num_notaries_STAKED1; i++) - { - if ( i < num_notaries_STAKED1 ) - decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - didinit = 1; - } + uint8_t pubkey33[33]; + for (i=0; i<=num_notaries_STAKED1; i++) + { + if ( i < num_notaries_STAKED1 ) + decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } for (i=0; i<=num_notaries_STAKED1; i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); From 220df8ac00ab64f44d3acc6708e68d63a3744353 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 13:12:33 +0800 Subject: [PATCH 0197/3904] hard code number of notaries --- src/main.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b3e31681c..f432eca29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1047,17 +1047,21 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - char notaryaddrs[num_notaries_STAKED1 + 1][64]; + static int32_t didinit; static char notaryaddrs[17 + 1][64]; int32_t i; - uint8_t pubkey33[33]; - for (i=0; i<=num_notaries_STAKED1; i++) - { - if ( i < num_notaries_STAKED1 ) - decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - for (i=0; i<=num_notaries_STAKED1; i++) + if ( didinit == 0 ) + { + uint8_t pubkey33[33]; + for (i=0; i<=17; i++) + { + if ( i < 17 ) + decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } + didinit = 1; + } + for (i=0; i<=17; i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); return(0); From 03327034480ce73196a49e1df10a447804e36a76 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Sun, 30 Sep 2018 11:32:39 +0000 Subject: [PATCH 0198/3904] add ac_priv chains --- src/assetchains.json | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 00c491935..4b3247d48 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -62,5 +62,27 @@ "195.201.137.5", "195.201.20.230" ] - } + }, + { + "ac_name": "STAKEDPRIV", + "ac_supply": "1000000", + "ac_reward" : "10000000000", + "ac_private": "1", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDCCP", + "ac_supply": "1000000", + "ac_reward" : "10000000000", + "ac_private": "1", + "ac_cc": "667", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + } +] ] From ae33616fc4d933e0b5319d97667bbaab04b44242 Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 1 Oct 2018 10:53:12 +0100 Subject: [PATCH 0199/3904] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e8ed8c3cb..2285e8827 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ This is the official Komodo sourcecode repository based on https://github.com/jl777/komodo. ## Development Resources - -- Komodo Website: [https://komodoplatform.com/](https://komodoplatform.com/) -- Komodo Blockexplorer: [https://kmdexplorer.io//](https://https://kmdexplorer.io/) -- Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/) +- Komodo Website: [https://komodoplatform.com](https://komodoplatform.com/) +- Komodo Blockexplorer: [https://kmdexplorer.io](https://kmdexplorer.io/) +- Komodo Discord: [https://komodoplatform.com/discord](https://komodoplatform.com/discord) +- Forum: [https://forum.komodoplatform.com](https://forum.komodoplatform.com/) - Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com) - Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home) -- Knowledgebase & How-to: [https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages](https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages) -- API references: [http://docs.komodoplatform.com/](http://docs.komodoplatform.com/) -- Blog: [http://blog.komodoplatform.com/](http://blog.komodoplatform.com/) -- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/wp-content/uploads/2018/03/2018-03-12-Komodo-White-Paper-Full.pdf) +- Knowledgebase & How-to: [https://support.komodoplatform.com/en/support/solutions](https://support.komodoplatform.com/en/support/solutions) +- API references & Dev Documentation: [https://docs.komodoplatform.com](https://docs.komodoplatform.com/) +- Blog: [https://blog.komodoplatform.com](https://blog.komodoplatform.com/) +- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/whitepaper) - Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0) ## List of Komodo Platform Technologies From 644ae923c06f8334c88aca48d55ccd2a76d896d1 Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Mon, 1 Oct 2018 08:09:21 -0400 Subject: [PATCH 0200/3904] derp --- src/assetchains.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 4b3247d48..aa7c8bfb4 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -85,4 +85,3 @@ ] } ] -] From 12e14f15a0972a866975b8c089a5169d36f877d1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:13:35 +0800 Subject: [PATCH 0201/3904] add some prints to see where values are --- src/wallet/rpcwallet.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 055352973..e5433d4ff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -398,7 +398,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Parse Zcash address CScript scriptPubKey = GetScriptForDestination(address); - + // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; @@ -4133,7 +4133,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) strDisabledMsg = "\nWARNING: z_mergetoaddress is DISABLED but can be enabled as an experimental feature.\n"; } - if (fHelp || params.size() < 2 || params.size() > 6) + if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( "z_mergetoaddress [\"fromaddress\", ... ] \"toaddress\" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )\n" + strDisabledMsg + @@ -4165,6 +4165,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" + "6. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" "\nResult:\n" "{\n" " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" @@ -4295,6 +4296,16 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } + if (params.size() > 6) { + maximum_utxo_size = params[6].get_int() + printf("maximum utxo size = %d\n", maximum_utxo_size); + if (maximum_utxo_size < 10) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + } + } else { + maximum_utxo_size = 0; + } + MergeToAddressRecipient recipient(destaddress, memo); // Prepare to get UTXOs and notes @@ -4343,6 +4354,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) utxoCounter++; CAmount nValue = out.tx->vout[out.i].nValue; + if (maximum_utxo_size != 0) { + printf("maximum utxo size = %d \n", maximum_utxo_size); + printf("nValue = %s\n", nValue); + } + if (!maxedOutUTXOsFlag) { CBitcoinAddress ba(address); size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; @@ -5669,7 +5685,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) UniValue oraclessamples(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; + UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessamples oracletxid batonutxo num\n"); if ( ensure_CCrequirements() < 0 ) From d411178c7e0fa3df85e47776e1c0b63112a0207f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:18:05 +0800 Subject: [PATCH 0202/3904] syntax --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e5433d4ff..b1261c695 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,6 +4296,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } + std::int maximum_utxo_size if (params.size() > 6) { maximum_utxo_size = params[6].get_int() printf("maximum utxo size = %d\n", maximum_utxo_size); @@ -4356,7 +4357,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %d \n", maximum_utxo_size); - printf("nValue = %s\n", nValue); + printf("nValue = %lld\n", nValue); } if (!maxedOutUTXOsFlag) { From 4f1650383a88438d961d4847101ad3ef90f3ccb4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:21:49 +0800 Subject: [PATCH 0203/3904] test --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b1261c695..e005eec5b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,10 +4296,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - std::int maximum_utxo_size + CAmount maximum_utxo_size if (params.size() > 6) { maximum_utxo_size = params[6].get_int() - printf("maximum utxo size = %d\n", maximum_utxo_size); + printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); } @@ -4357,7 +4357,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %d \n", maximum_utxo_size); - printf("nValue = %lld\n", nValue); + printf("nValue = %ld\n", nValue); } if (!maxedOutUTXOsFlag) { From 57d237b5bc68a88e25c0078b373194dca63152f5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:24:04 +0800 Subject: [PATCH 0204/3904] ; --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e005eec5b..81383d992 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,7 +4296,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - CAmount maximum_utxo_size + CAmount maximum_utxo_size; if (params.size() > 6) { maximum_utxo_size = params[6].get_int() printf("maximum utxo size = %ld\n", maximum_utxo_size); From 2499a4fef8fa8f846b8fd89edaaf2843917ee115 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:25:17 +0800 Subject: [PATCH 0205/3904] ld --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 81383d992..1cd38bca2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4356,7 +4356,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - printf("maximum utxo size = %d \n", maximum_utxo_size); + printf("maximum utxo size = %ld \n", maximum_utxo_size); printf("nValue = %ld\n", nValue); } From 2b81045e2ba5193127a582e629c808ff49e28f66 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:27:58 +0800 Subject: [PATCH 0206/3904] ; --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1cd38bca2..f407710c7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4298,7 +4298,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 6) { - maximum_utxo_size = params[6].get_int() + maximum_utxo_size = params[6].get_int(); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From 93253d38ea755bca797d8acff08646ba880675db Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:43:03 +0800 Subject: [PATCH 0207/3904] make memo last feild again --- src/wallet/rpcwallet.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f407710c7..01dabc4cc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,8 +4164,9 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" - "6. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" + "\nResult:\n" "{\n" " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" @@ -4283,9 +4284,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - std::string memo; + CAmount maximum_utxo_size; if (params.size() > 5) { - memo = params[5].get_str(); + maximum_utxo_size = params[5].get_int(); + printf("maximum utxo size = %ld\n", maximum_utxo_size); + if (maximum_utxo_size < 10) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + } + } else { + maximum_utxo_size = 0; + } + + std::string memo; + if (params.size() > 6) { + memo = params[6].get_str(); if (!isToZaddr) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo can not be used with a taddr. It can only be used with a zaddr."); } else if (!IsHex(memo)) { @@ -4296,17 +4308,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - CAmount maximum_utxo_size; - if (params.size() > 6) { - maximum_utxo_size = params[6].get_int(); - printf("maximum utxo size = %ld\n", maximum_utxo_size); - if (maximum_utxo_size < 10) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); - } - } else { - maximum_utxo_size = 0; - } - MergeToAddressRecipient recipient(destaddress, memo); // Prepare to get UTXOs and notes From a0c1d43977433cfabf79292d5f12acbc9bc23053 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:48:24 +0800 Subject: [PATCH 0208/3904] long --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 01dabc4cc..f69e9eb4b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4286,7 +4286,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { - maximum_utxo_size = params[5].get_int(); + maximum_utxo_size = params[5].get_real(); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From 4bdd7e26cd5ed9e64c87118bf4eb9992eeab210d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:58:42 +0800 Subject: [PATCH 0209/3904] try --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f69e9eb4b..b147d4307 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4286,7 +4286,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { - maximum_utxo_size = params[5].get_real(); + maximum_utxo_size = AmountFromValue( params[5] ); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From dfba8357f375f599bf641c09dea73af64f75d04c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:09:36 +0800 Subject: [PATCH 0210/3904] fingers crossed --- src/wallet/rpcwallet.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b147d4307..e0efa9cb4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,7 +4164,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged.\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4289,7 +4289,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) maximum_utxo_size = AmountFromValue( params[5] ); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 0.00000010."); } } else { maximum_utxo_size = 0; @@ -4358,7 +4358,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %ld \n", maximum_utxo_size); - printf("nValue = %ld\n", nValue); + if (nValue > maximum_utxo_size) { + printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); + continue; + } else { + printf("utxo found under maximum size so we will add it!\n", ); + } } if (!maxedOutUTXOsFlag) { From 743131799fb25db2145a450aa59d1bfb52e224e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:10:53 +0800 Subject: [PATCH 0211/3904] , --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e0efa9cb4..cb81244ae 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - printf("utxo found under maximum size so we will add it!\n", ); + printf("utxo found under maximum size so we will add it!\n"); } } From cd6fbe09777fbef8a5b6f9a130c3bb71a4f334a9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:25:24 +0800 Subject: [PATCH 0212/3904] add exeption for iguana utxo --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cb81244ae..a05aed988 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - printf("utxo found under maximum size so we will add it!\n"); + if (out.tx->vout[out.i].scriptPubKey.size() != 35) { + printf("utxo is an iguana utxo so we will ingore it!\n"); + continue; + } + printf("utxo found under maximum size that is not p2pk so we will add it!\n"); } } From 41fddfc0bf860d178a9b5328a4c8c69924cfa91d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:31:05 +0800 Subject: [PATCH 0213/3904] fix --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a05aed988..def79e51d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4357,12 +4357,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - printf("maximum utxo size = %ld \n", maximum_utxo_size); + //printf("maximum utxo size = %ld \n", maximum_utxo_size); if (nValue > maximum_utxo_size) { printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() != 35) { + if (out.tx->vout[out.i].scriptPubKey.size() = 35) { printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } From 30c320d1f66032ca1e02a505982a0940f362a94e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:32:21 +0800 Subject: [PATCH 0214/3904] = --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index def79e51d..e766e6bf6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() = 35) { + if (out.tx->vout[out.i].scriptPubKey.size() == 35) { printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } From 5d8a1637ae63b3aa38e60e1ac18ac42298462683 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:43:20 +0800 Subject: [PATCH 0215/3904] remove prints to speed it up --- src/wallet/rpcwallet.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e766e6bf6..a429b81ac 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,7 +4164,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores p2pk utxo!\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4287,7 +4287,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { maximum_utxo_size = AmountFromValue( params[5] ); - printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 0.00000010."); } @@ -4366,7 +4365,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } - printf("utxo found under maximum size that is not p2pk so we will add it!\n"); } } From f882623570959e3566ae0dca500272d4ebdf5de4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:42:14 +0800 Subject: [PATCH 0216/3904] remove prints and fix utxo counter in wrong place --- src/wallet/rpcwallet.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a429b81ac..641a42f04 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4352,22 +4352,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) continue; } - utxoCounter++; CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - //printf("maximum utxo size = %ld \n", maximum_utxo_size); if (nValue > maximum_utxo_size) { - printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { if (out.tx->vout[out.i].scriptPubKey.size() == 35) { - printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } } } + utxoCounter++; + if (!maxedOutUTXOsFlag) { CBitcoinAddress ba(address); size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; From 478370fd6c3322dc6a2e65960d2ac8ed27d08450 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:52:12 +0800 Subject: [PATCH 0217/3904] numutxos < 2 instead of 0... cant merge 1 utxo --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 641a42f04..7ef43e5db 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4429,7 +4429,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) #endif - if (numUtxos == 0 && numNotes == 0) { + if (numUtxos > 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From 0367b1a6856da6f5176f76ff11f15023d97ca3d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:53:28 +0800 Subject: [PATCH 0218/3904] < --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7ef43e5db..7de29528f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4429,7 +4429,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) #endif - if (numUtxos > 2 && numNotes == 0) { + if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From b9b7f12d84dad450d80cac7834a81321bfb6e0b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 12 Oct 2018 14:06:26 +0800 Subject: [PATCH 0219/3904] fix edgcase where eras before current get chosen out of order and prevent later ones being activated. --- src/komodo_notary.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d0ab8c078..a9750369a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -264,6 +264,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam for (i=0; i Date: Tue, 16 Oct 2018 12:58:43 +0800 Subject: [PATCH 0220/3904] give this a go --- src/komodo_bitcoind.h | 48 +++++++++-------- src/komodo_globals.h | 2 +- src/komodo_utils.h | 6 ++- src/main.cpp | 16 +++++- src/miner.cpp | 117 +++++++++++++++++++++--------------------- src/pow.cpp | 48 +++++++++-------- 6 files changed, 135 insertions(+), 102 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 86ed8f7b3..8bfca7dc4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -169,7 +169,7 @@ try_again: curl_handle = curl_easy_init(); init_string(&s); headers = curl_slist_append(0,"Expect:"); - + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); @@ -198,7 +198,7 @@ try_again: bracket0 = (char *)"["; bracket1 = (char *)"]"; } - + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); @@ -238,7 +238,7 @@ try_again: free(s.ptr); sleep((1<= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ +extern int32_t ASSETCHAINS_STREAM; uint64_t komodo_commission(const CBlock *pblock) { - int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; - txn_count = pblock->vtx.size(); - for (i=0; ivtx[i].vout.size(); - for (j=0; jvtx[i].vout[j].nValue; - } + int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; + txn_count = pblock->vtx.size(); + for (i=0; ivtx[i].vout.size(); + for (j=0; jvtx[i].vout[j].nValue; + } + } + //fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN)); + commission = ((total * ASSETCHAINS_COMMISSION) / COIN); + if ( commission < 10000 ) + commission = 0; + } + else + { + commission = 10000; } - //fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN)); - commission = ((total * ASSETCHAINS_COMMISSION) / COIN); - if ( commission < 10000 ) - commission = 0; return(commission); } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f352b5333..c456d3e44 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index bfd59fd57..50b0e3020 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1561,6 +1561,7 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = GetArg("-ac_decay",0); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); + ASSETCHAINS_STREAM = GetArg("-ac_stream",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) @@ -1589,7 +1590,10 @@ void komodo_args(char *argv0) { ASSETCHAINS_COMMISSION = 0; printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); - } + } else if ( ASSETCHAINS_STREAM != 0) { + ASSETCHAINS_STREAM = 0; + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); + } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); diff --git a/src/main.cpp b/src/main.cpp index 1ff5f8012..39270a0b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1866,6 +1866,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint32_t ASSETCHAINS_MAGIC; +extern int32_t ASSETCHAINS_STREAM; extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; @@ -1895,7 +1896,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { if ( ASSETCHAINS_REWARD == 0 ) return(10000); - else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY ) + else if ( ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )|| ASSETCHAINS_STREAM != 0) return(0); else { @@ -2961,6 +2962,19 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!view.HaveJoinSplitRequirements(tx)) return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met"); + + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( ASSETCHAINS_STREAM != 0 ) + { + if ( block.vtx.size() == 1 && block.vtx[0].vout.size() == 2 && pindex->nHeight > ASSETCHAINS_MINHEIGHT) + { + return state.DoS(100, error("ConnectBlock(): There are no TX in this block, it is invalid!"), + REJECT_INVALID, "bad-block-no-transactions"); + } + } + } + if (fAddressIndex || fSpentIndex) { for (size_t j = 0; j < tx.vin.size(); j++) { diff --git a/src/miner.cpp b/src/miner.cpp index 874c1b4f8..8fbfcff05 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -64,7 +64,7 @@ public: set setDependsOn; CFeeRate feeRate; double dPriority; - + COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0) { } @@ -78,10 +78,10 @@ typedef boost::tuple TxPriority; class TxPriorityCompare { bool byFee; - + public: TxPriorityCompare(bool _byFee) : byFee(_byFee) { } - + bool operator()(const TxPriority& a, const TxPriority& b) { if (byFee) @@ -106,7 +106,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; @@ -141,27 +141,27 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // -blockversion=N to test forking scenarios if (Params().MineBlocksOnDemand()) pblock->nVersion = GetArg("-blockversion", pblock->nVersion); - + // Add dummy coinbase tx as first transaction pblock->vtx.push_back(CTransaction()); pblocktemplate->vTxFees.push_back(-1); // updated at end pblocktemplate->vTxSigOps.push_back(-1); // updated at end - + // Largest block you're willing to create: unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE); // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize)); - + // How much of the block should be dedicated to high-priority transactions, // included regardless of the fees they pay unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE); nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); - + // Minimum block size you want to create; block will be filled with free transactions // until there are no more or the block reaches this size: unsigned int nBlockMinSize = GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE); nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); - + // Collect memory pool transactions into the block CAmount nFees = 0; CBlockIndex* pindexPrev = 0; @@ -174,12 +174,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); CCoinsViewCache view(pcoinsTip); uint32_t expired; uint64_t commission; - + // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; bool fPrintPriority = GetBoolArg("-printpriority", false); - + // This vector will be sorted into a priority queue: vector vecPriority; vecPriority.reserve(mempool.mapTx.size()); @@ -187,11 +187,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) mi != mempool.mapTx.end(); ++mi) { const CTransaction& tx = mi->GetTx(); - + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) ? nMedianTimePast : pblock->GetBlockTime(); - + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) { //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); @@ -256,16 +256,16 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } if (fMissingInputs) continue; - + // Priority is sum(valuein * age) / modified_txsize unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); dPriority = tx.ComputePriority(dPriority, nTxSize); - + uint256 hash = tx.GetHash(); mempool.ApplyDeltas(hash, dPriority, nTotalIn); - + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - + if (porphan) { porphan->dPriority = dPriority; @@ -274,27 +274,27 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } - + // Collect transactions into block uint64_t nBlockSize = 1000; uint64_t nBlockTx = 0; int64_t interest; int nBlockSigOps = 100; bool fSortedByFee = (nBlockPrioritySize <= 0); - + TxPriorityCompare comparer(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - + while (!vecPriority.empty()) { // Take highest priority transaction off the priority queue: double dPriority = vecPriority.front().get<0>(); CFeeRate feeRate = vecPriority.front().get<1>(); const CTransaction& tx = *(vecPriority.front().get<2>()); - + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); vecPriority.pop_back(); - + // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx @@ -302,7 +302,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); continue; } - + // Legacy limits on sigOps: unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) @@ -329,14 +329,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) comparer = TxPriorityCompare(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); } - + if (!view.HaveInputs(tx)) { //fprintf(stderr,"dont have inputs\n"); continue; } CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - + nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { @@ -354,7 +354,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) continue; } UpdateCoins(tx, view, nHeight); - + // Added pblock->vtx.push_back(tx); pblocktemplate->vTxFees.push_back(nTxFees); @@ -363,12 +363,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) ++nBlockTx; nBlockSigOps += nTxSigOps; nFees += nTxFees; - + if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); } - + // Add transactions that depend on this one to the priority queue if (mapDependers.count(hash)) { @@ -386,7 +386,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } } } - + nLastBlockTx = nBlockTx; nLastBlockSize = nBlockSize; blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); @@ -411,7 +411,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->nHeight+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } - + // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(chainparams.GetConsensus(), nHeight); txNew.vin.resize(1); @@ -426,9 +426,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; - + pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); @@ -449,7 +449,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) nonce <<= 32; nonce >>= 16; pblock->nNonce = ArithToUint256(nonce); - + // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); pblock->hashReserved = uint256(); @@ -527,7 +527,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return pblocktemplate.release(); } - + /* #ifdef ENABLE_WALLET boost::optional GetMinerScriptPubKey(CReserveKey& reservekey) @@ -550,11 +550,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return boost::optional(); #endif } - + CScript scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG; return scriptPubKey; } - + #ifdef ENABLE_WALLET CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) { @@ -564,7 +564,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) { boost::optional scriptPubKey = GetMinerScriptPubKey(); #endif - + if (!scriptPubKey) { return NULL; } @@ -592,7 +592,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& CMutableTransaction txCoinbase(pblock->vtx[0]); txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS; assert(txCoinbase.vin[0].scriptSig.size() <= 100); - + pblock->vtx[0] = txCoinbase; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); } @@ -606,7 +606,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i; - if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) + if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; } @@ -615,7 +615,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } - else { if (!reservekey.GetReservedKey(pubkey)) { @@ -661,7 +660,7 @@ static bool ProcessBlockFound(CBlock* pblock) { LogPrintf("%s\n", pblock->ToString()); LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.LastTip()->nHeight+1); - + // Found a solution { //LOCK(cs_main); @@ -676,11 +675,11 @@ static bool ProcessBlockFound(CBlock* pblock) for (i=31; i>=0; i--) fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); fprintf(stderr," <- chainTip (stale)\n"); - + return error("KomodoMiner: generated block is stale"); } } - + #ifdef ENABLE_WALLET // Remove key from key pool if ( IS_KOMODO_NOTARY == 0 ) @@ -704,7 +703,7 @@ static bool ProcessBlockFound(CBlock* pblock) CValidationState state; if (!ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, pblock, true, NULL)) return error("KomodoMiner: ProcessNewBlock, block not accepted"); - + TrackMinedBlock(pblock->GetHash()); komodo_broadcast(pblock,16); return true; @@ -728,15 +727,15 @@ void static BitcoinMiner() SetThreadPriority(THREAD_PRIORITY_LOWEST); RenameThread("komodo-miner"); const CChainParams& chainparams = Params(); - + #ifdef ENABLE_WALLET // Each thread has its own key CReserveKey reservekey(pwallet); #endif - + // Each thread has its own counter unsigned int nExtraNonce = 0; - + unsigned int n = chainparams.EquihashN(); unsigned int k = chainparams.EquihashK(); uint8_t *script; uint64_t total,checktoshis; int32_t i,j,gpucount=KOMODO_MAXGPUCOUNT,notaryid = -1; @@ -767,7 +766,7 @@ void static BitcoinMiner() } ); miningTimer.start(); - + try { if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); @@ -790,7 +789,7 @@ void static BitcoinMiner() break; MilliSleep(15000); //fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload()); - + } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); miningTimer.start(); @@ -1054,13 +1053,13 @@ void static BitcoinMiner() std::lock_guard lock{m_cs}; return cancelSolver; }; - + // TODO: factor this out into a function with the same API for each solver. if (solver == "tromp" ) { //&& notaryid >= 0 ) { // Create solver and initialize it. equi eq(1); eq.setstate(&curr_state); - + // Initialization done, start algo driver. eq.digit0(0); eq.xfull = eq.bfull = eq.hfull = 0; @@ -1072,7 +1071,7 @@ void static BitcoinMiner() } eq.digitK(0); ehSolverRuns.increment(); - + // Convert solution indices to byte array (decompress) and pass it to validBlock method. for (size_t s = 0; s < eq.nsols; s++) { LogPrint("pow", "Checking solution %d\n", s+1); @@ -1081,7 +1080,7 @@ void static BitcoinMiner() index_vector[i] = eq.sols[s][i]; } std::vector sol_char = GetMinimalFromIndices(index_vector, DIGITBITS); - + if (validBlock(sol_char)) { // If we find a POW solution, do not try other solutions // because they become invalid as we created a new block in blockchain. @@ -1108,7 +1107,7 @@ void static BitcoinMiner() cancelSolver = false; } } - + // Check for stop or if block needs to be rebuilt boost::this_thread::interruption_point(); // Regtest mode doesn't require peers @@ -1178,7 +1177,7 @@ void static BitcoinMiner() miningTimer.stop(); c.disconnect(); } - + #ifdef ENABLE_WALLET void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads) #else @@ -1186,10 +1185,10 @@ void static BitcoinMiner() #endif { static boost::thread_group* minerThreads = NULL; - + if (nThreads < 0) nThreads = GetNumCores(); - + if (minerThreads != NULL) { minerThreads->interrupt_all(); @@ -1201,7 +1200,7 @@ void static BitcoinMiner() nThreads = 1; if (nThreads == 0 || !fGenerate) return; - + minerThreads = new boost::thread_group(); for (int i = 0; i < nThreads; i++) { #ifdef ENABLE_WALLET @@ -1211,5 +1210,5 @@ void static BitcoinMiner() #endif } } - + #endif // ENABLE_MINING diff --git a/src/pow.cpp b/src/pow.cpp index 1291e445e..9c8f68586 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -20,31 +20,39 @@ #include "librustzcash.h" #endif // ENABLE_RUST uint32_t komodo_chainactive_timestamp(); +extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); - // Genesis block - if (pindexLast == NULL ) - return nProofOfWorkLimit; + if ( ASSETCHAINS_STREAM == 0) + { + unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); + // Genesis block + if (pindexLast == NULL ) + return nProofOfWorkLimit; - // Find the first block in the averaging interval - const CBlockIndex* pindexFirst = pindexLast; - arith_uint256 bnTot {0}; - for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { - arith_uint256 bnTmp; - bnTmp.SetCompact(pindexFirst->nBits); - bnTot += bnTmp; - pindexFirst = pindexFirst->pprev; + // Find the first block in the averaging interval + const CBlockIndex* pindexFirst = pindexLast; + arith_uint256 bnTot {0}; + for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { + arith_uint256 bnTmp; + bnTmp.SetCompact(pindexFirst->nBits); + bnTot += bnTmp; + pindexFirst = pindexFirst->pprev; + } + + // Check we have enough blocks + if (pindexFirst == NULL) + return nProofOfWorkLimit; + + arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; + + return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); + } + else + { + return 537857807; } - - // Check we have enough blocks - if (pindexFirst == NULL) - return nProofOfWorkLimit; - - arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; - - return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); } unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, From 4e9596efeab6fa2426960c338b1dc72576143e98 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:02:16 +0800 Subject: [PATCH 0221/3904] fix commission --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8bfca7dc4..1b8daf3a7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1109,9 +1109,9 @@ extern int32_t ASSETCHAINS_STREAM; uint64_t komodo_commission(const CBlock *pblock) { + int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; if ( ASSETCHAINS_STREAM == 0 ) { - int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); for (i=0; i Date: Tue, 16 Oct 2018 13:07:30 +0800 Subject: [PATCH 0222/3904] prevent STREAM and PERC being used at the same time --- src/komodo_utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 50b0e3020..4c4827f6d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,6 +1562,11 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); + if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_COMMISSION != 0 ) { + printf("ASSETCHAINS_STREAM cannot be used with ASSETCHAINS_COMMISSION setting both to 0! \n"); + ASSETCHAINS_STREAM = 0; + ASSETCHAINS_COMMISSION = 0; + } if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) From c175848729fa19799d0910a6bac236c2123e1d4c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:12:53 +0800 Subject: [PATCH 0223/3904] set minimum supply for ac_stream to 100k --- src/komodo_utils.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4c4827f6d..b60328c54 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1599,6 +1599,10 @@ void komodo_args(char *argv0) ASSETCHAINS_STREAM = 0; printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); } + if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { + ASSETCHAINS_SUPPLY = 100000; + printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 100,000 coins. \n"); + } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); From 0d63c1f908db9bcd68e2dddb89d9eae7f01cd966 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:36:24 +0800 Subject: [PATCH 0224/3904] add some prints --- src/komodo_bitcoind.h | 5 ++++- src/miner.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1b8daf3a7..83b8399b8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1577,9 +1577,12 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { if ( height == 1 ) { + fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { + fprintf(stderr, "failed the check\n"); return(-1); + } } else { diff --git a/src/miner.cpp b/src/miner.cpp index 8fbfcff05..79a3c1eec 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -609,6 +609,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + fprintf(stderr, "assechains stream should be mining to override pubkey\n"); } else if ( USE_EXTERNAL_PUBKEY != 0 ) { From 497f834d1f1d81ef89f99c9e84b57d8640b310e3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:49:38 +0800 Subject: [PATCH 0225/3904] disable check to see what block is being created --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 83b8399b8..d0ee426b8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1575,7 +1575,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - if ( height == 1 ) + /*if ( height == 1 ) { fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); @@ -1585,10 +1585,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } } else - { + {*/ if ( komodo_checkcommission(pblock,height) < 0 ) return(-1); - } + //} } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) From 45ef1a21c7552c5dfe9a722104b777c9ea0aeb56 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 14:21:23 +0800 Subject: [PATCH 0226/3904] try this --- src/komodo_bitcoind.h | 8 ++++---- src/komodo_gateway.h | 13 ++++++------- src/komodo_utils.h | 2 +- src/main.cpp | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d0ee426b8..f1f5b8efd 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1472,7 +1472,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script; - if ( ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) { checktoshis = komodo_commission(pblock); if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) @@ -1575,7 +1575,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - /*if ( height == 1 ) + if ( height == 1 ) { fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); @@ -1585,10 +1585,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } } else - {*/ + { if ( komodo_checkcommission(pblock,height) < 0 ) return(-1); - //} + } } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 379224b48..233f87fcf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -90,7 +90,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout pax->marked = mark; //if ( height > 214700 || pax->height > 214700 ) // printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - + } pthread_mutex_unlock(&komodo_mutex); return(pax); @@ -203,9 +203,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t // return(0); incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); //41e77b91cb68dc2aa02fa88550eae6b6d44db676a7e935337b6d1392d9718f03cb0200305c90660400000000fbcbeb1f000000bde801006201000058e7945ad08ddba1eac9c9b6c8e1e97e8016a2d152 - + // 41e94d736ec69d88c08b5d238abeeca609c02357a8317e0d56c328bcb1c259be5d0200485bc80200000000404b4c000000000059470200b80b000061f22ba7d19fe29ac3baebd839af8b7127d1f9075553440046bb4cc7a3b5cd39dffe7206507a3482a00780e617f68b273cce9817ed69298d02001069ca1b0000000080f0fa02000000005b470200b90b000061f22ba7d19fe29ac3baebd839af8b7127d1f90755 - + //for (i=0; i 1 ) + if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) { @@ -772,7 +772,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -1185,7 +1185,7 @@ void komodo_stateind_set(struct komodo_state *sp,uint32_t *inds,int32_t n,uint8_ printf("numR.%d numV.%d numN.%d count.%d\n",numR,numV,numN,count); /*else if ( func == 'K' ) // KMD height: stop after 1st else if ( func == 'T' ) // KMD height+timestamp: stop after 1st - + else if ( func == 'N' ) // notarization, scan backwards 1440+ blocks; else if ( func == 'V' ) // price feed: can stop after 1440+ else if ( func == 'R' ) // opreturn:*/ @@ -1518,4 +1518,3 @@ void komodo_passport_iteration() printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid); } } - diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b60328c54..ebeb8324f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1597,7 +1597,7 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } else if ( ASSETCHAINS_STREAM != 0) { ASSETCHAINS_STREAM = 0; - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n %s",ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); } if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { ASSETCHAINS_SUPPLY = 100000; diff --git a/src/main.cpp b/src/main.cpp index 39270a0b9..42f1d624d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3124,7 +3124,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; - if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) ) { uint64_t checktoshis; if ( (checktoshis= komodo_commission((CBlock *)&block)) != 0 ) From 8ca9133eb4c7ef0735cf93d6e3721d12160dcbb4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 14:44:55 +0800 Subject: [PATCH 0227/3904] fix --- src/komodo_utils.h | 2 +- src/miner.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ebeb8324f..5dc218d76 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1603,7 +1603,7 @@ void komodo_args(char *argv0) ASSETCHAINS_SUPPLY = 100000; printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 100,000 coins. \n"); } - if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_STREAM != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); extraptr = extrabuf; diff --git a/src/miner.cpp b/src/miner.cpp index 79a3c1eec..b058a7c7d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -439,7 +439,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) for (i=0; i<33; i++) ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; ptr[34] = OP_CHECKSIG; - //printf("autocreate commision vout\n"); + printf("autocreate commission vout\n"); pblock->vtx[0] = txNew; } pblocktemplate->vTxFees[0] = -nFees; From 3793c6386097185cd973b6823e55c208564228e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 15:33:09 +0800 Subject: [PATCH 0228/3904] oops LOL --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index b058a7c7d..36ed84f05 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -615,7 +615,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in { //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; - } + } else { if (!reservekey.GetReservedKey(pubkey)) { From b66f366d5cb4ca6a6c009ed928a3b93dad627b91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 16:06:49 +0800 Subject: [PATCH 0229/3904] next try --- src/komodo_bitcoind.h | 2 -- src/main.cpp | 9 +++++++-- src/miner.cpp | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f1f5b8efd..b13a2c36e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1577,10 +1577,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { if ( height == 1 ) { - fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { - fprintf(stderr, "failed the check\n"); return(-1); } } diff --git a/src/main.cpp b/src/main.cpp index 42f1d624d..c6d2ee9e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1895,8 +1895,13 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) else if ( ASSETCHAINS_ENDSUBSIDY == 0 || nHeight < ASSETCHAINS_ENDSUBSIDY ) { if ( ASSETCHAINS_REWARD == 0 ) - return(10000); - else if ( ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )|| ASSETCHAINS_STREAM != 0) + { + if ( ASSETCHAINS_STREAM != 0 && nHeight > 128 ) + return(0); + else + return(10000); + } + else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY ) return(0); else { diff --git a/src/miner.cpp b/src/miner.cpp index 36ed84f05..39caa35c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -609,7 +609,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; - fprintf(stderr, "assechains stream should be mining to override pubkey\n"); } else if ( USE_EXTERNAL_PUBKEY != 0 ) { From 68032ee5a71a557fc10a14a78f951f34d9079566 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 17:14:07 +0800 Subject: [PATCH 0230/3904] change so only ac_pubkey can mine coinbase --- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 13 ++++++------- src/miner.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b13a2c36e..4051eb095 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1575,7 +1575,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - if ( height == 1 ) + if ( height == 1 || ASSETCHAINS_STREAM != 0 ) { script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5dc218d76..1535d5812 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,10 +1562,9 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_COMMISSION != 0 ) { - printf("ASSETCHAINS_STREAM cannot be used with ASSETCHAINS_COMMISSION setting both to 0! \n"); - ASSETCHAINS_STREAM = 0; - ASSETCHAINS_COMMISSION = 0; + if ( ASSETCHAINS_STREAM != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0) { + printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); + exit(0); } if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1597,11 +1596,11 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } else if ( ASSETCHAINS_STREAM != 0) { ASSETCHAINS_STREAM = 0; - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n %s",ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); } if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { - ASSETCHAINS_SUPPLY = 100000; - printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 100,000 coins. \n"); + ASSETCHAINS_SUPPLY = 1000000; + printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 1,000,000 coins. \n"); } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_STREAM != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 39caa35c3..1c83c5a61 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -439,7 +439,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) for (i=0; i<33; i++) ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; ptr[34] = OP_CHECKSIG; - printf("autocreate commission vout\n"); + //printf("autocreate commission vout\n"); pblock->vtx[0] = txNew; } pblocktemplate->vTxFees[0] = -nFees; @@ -839,7 +839,10 @@ void static BitcoinMiner() { if ( ASSETCHAINS_REWARD == 0 ) { - if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) + int minvoutsize = 1; + if ( ASSETCHAINS_STREAM != 0 ) + minvoutsize = 2; + if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) { static uint32_t counter; if ( counter++ < 10 ) From dc92daa03cd4f7f45dea09d07b0e82da30686909 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 17:17:44 +0800 Subject: [PATCH 0231/3904] oops --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1535d5812..aedb6d3c2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,7 +1562,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - if ( ASSETCHAINS_STREAM != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0) { + if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); exit(0); } From fb0f519301b7cb105b2087e7a4364b9eaaba5de5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 21:17:27 +0800 Subject: [PATCH 0232/3904] try to make miner spend p2pk utxo --- src/miner.cpp | 20 ++++++++++++++++++++ src/wallet/rpcwallet.cpp | 14 ++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1c83c5a61..668c5127f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -493,6 +493,26 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } + else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + { + CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); + if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) + { + CAmount txfees = 10000; + pblock->vtx.push_back(txStream); + pblocktemplate->vTxFees.push_back(txfees); + pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStream)); + nFees += txfees; + pblocktemplate->vTxFees[0] = -nFees; + //*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; + //fprintf(stderr,"added notaryvin\n"); + } + else + { + fprintf(stderr,"error adding streamer vin, the chain broke! \n"); + return(0); + } + } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 936c31fd9..6359dfca5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -44,6 +44,8 @@ using namespace std; using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; +extern int32_t ASSETCHAINS_STREAM; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern uint8_t ASSETCHAINS_PRIVATE; uint32_t komodo_segid32(char *coinaddr); @@ -4606,8 +4608,16 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; - txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; - txNew.vout[0].nValue = utxovalue - txfee; + if ( ASSETCHAINS_STREAM != 0 ) + { + txNew.vout[0].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].nValue = 0; + } + else + { + txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; + txNew.vout[0].nValue = utxovalue - txfee; + } CTransaction txNewConst(txNew); signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); if (!signSuccess) From a11c10fdd215ac290fdfa73da31fa86a4604a163 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 21:39:54 +0800 Subject: [PATCH 0233/3904] send 0 value utxo to CRYPTO777 address instead of ac_pubkey --- src/wallet/rpcwallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6359dfca5..d352c89e4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4610,14 +4610,13 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin[0].prevout.n = utxovout; if ( ASSETCHAINS_STREAM != 0 ) { - txNew.vout[0].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = 0; } else - { - txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; + { txNew.vout[0].nValue = utxovalue - txfee; } + txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; CTransaction txNewConst(txNew); signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); if (!signSuccess) From 1f5efd44aa827003cc84aca1625ecab67df4e6d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:02:47 +0800 Subject: [PATCH 0234/3904] not a chance this will work? --- src/komodo_bitcoind.h | 15 +++++++++++++-- src/miner.cpp | 9 ++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4051eb095..988a8251c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1575,14 +1575,25 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - if ( height == 1 || ASSETCHAINS_STREAM != 0 ) + if ( height == 1 ) { script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { return(-1); } } - else + else if ( ASSETCHAINS_STREAM != 0 ) { + int lasttx = ( pblock->vtx.size() -1 ); + uint256 hash; CTransaction tx; CTxIn& txin; + txin = pblock->vtx[lasttx]; + if (GetTransaction(txin.prevout.hash,tx,hash,false)) + { + script = (uint8_t *)tx.vout[txin.prevout.n].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { + return(-1); + } + } + } else { if ( komodo_checkcommission(pblock,height) < 0 ) return(-1); diff --git a/src/miner.cpp b/src/miner.cpp index 668c5127f..a36a33a17 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -626,10 +626,17 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i; - if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) + if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; } + else if ( ASSETCHAINS_STREAM != 0 ) + { + if ( nHeight < 128 ) + scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + else + scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; + } else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); From 3267a72a823709b4b985ef3f19f5bec734d174f7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:05:49 +0800 Subject: [PATCH 0235/3904] try again --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 988a8251c..37f2a4411 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1584,7 +1584,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; CTxIn& txin; + uint256 hash; CTransaction tx; CTransaction txin; txin = pblock->vtx[lasttx]; if (GetTransaction(txin.prevout.hash,tx,hash,false)) { From 2e587cdae3f3903b5c231803e141d58ff94e0451 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:07:55 +0800 Subject: [PATCH 0236/3904] again --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 37f2a4411..9b1b05930 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1584,7 +1584,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; CTransaction txin; + uint256 hash; CTransaction tx; CTxIn txin; txin = pblock->vtx[lasttx]; if (GetTransaction(txin.prevout.hash,tx,hash,false)) { From 45df365f804108d2caa1ed52a097f0504270d9f8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:11:21 +0800 Subject: [PATCH 0237/3904] again --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9b1b05930..deffb6f8a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1584,9 +1584,9 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; CTxIn txin; - txin = pblock->vtx[lasttx]; - if (GetTransaction(txin.prevout.hash,tx,hash,false)) + uint256 hash; CTransaction tx; + //txin = ; + if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { script = (uint8_t *)tx.vout[txin.prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { From 2448754cc934f86ee6d1a36ac3582ac8a84c932f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:13:34 +0800 Subject: [PATCH 0238/3904] again --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index deffb6f8a..b0df98356 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1588,7 +1588,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) //txin = ; if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { - script = (uint8_t *)tx.vout[txin.prevout.n].scriptPubKey.data(); + script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { return(-1); } From 0be6e9eec81100a282e72eece790f3107470f8be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:18:37 +0800 Subject: [PATCH 0239/3904] add prints too see if its working --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b0df98356..aa6f848ef 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1585,11 +1585,13 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); uint256 hash; CTransaction tx; - //txin = ; + printf("ABOUT TO CHECK LAST TX: %d\n",lasttx); if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { + printf("CHECKING THE script pubkey\n"); script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { + printf("THE PUBKEY IS WRONG!\n"); return(-1); } } From 43b535c4c8335656abd66fd1f0a4441ef10236e3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:19:16 +0800 Subject: [PATCH 0240/3904] remove the actual return --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index aa6f848ef..61d86d0d6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1592,7 +1592,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { printf("THE PUBKEY IS WRONG!\n"); - return(-1); + //return(-1); } } } else From 987bed370592604a81a261978d482b4f24451fb2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:31:17 +0800 Subject: [PATCH 0241/3904] enforce check add print if passed --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 61d86d0d6..278bba0af 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1592,8 +1592,9 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { printf("THE PUBKEY IS WRONG!\n"); - //return(-1); + return(-1); } + printf("THE PUBKEY IS RIGHT! \n"); } } else { From d118b457b0aa06283a1c568deb6253366649b96e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:47:48 +0800 Subject: [PATCH 0242/3904] temp disable adding last tx to test consensus rule --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index a36a33a17..42d2b209b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -493,7 +493,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } - else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + /* else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } + } */ else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; From a3b0c674155ea518b63b9e836b618bf69a85d6b2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 00:13:38 +0800 Subject: [PATCH 0243/3904] fix miner, with extra TX --- src/miner.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 42d2b209b..44fb0ba27 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -493,7 +493,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } - /* else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } */ + } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; @@ -867,16 +867,18 @@ void static BitcoinMiner() if ( ASSETCHAINS_REWARD == 0 ) { int minvoutsize = 1; + int minvtxsize = 1; if ( ASSETCHAINS_STREAM != 0 ) minvoutsize = 2; - if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) + minvtxsize = 2; + if ( pblock->vtx.size() == minvtxsize && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) { static uint32_t counter; if ( counter++ < 10 ) fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; - } else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } else fprintf(stderr,"%s tx.%d vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx.size(),(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); From b6b33147b1d85e3b736035d25ac03e5dbdb16845 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 00:31:57 +0800 Subject: [PATCH 0244/3904] change it, might be safter this way --- src/komodo_bitcoind.h | 16 ++++++++++------ src/wallet/rpcwallet.cpp | 9 +-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 278bba0af..ad8da74d4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1582,10 +1582,18 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } - else if ( ASSETCHAINS_STREAM != 0 ) { + else + { + if ( komodo_checkcommission(pblock,height) < 0 ) + return(-1); + } + if ( ASSETCHAINS_STREAM != 0 && height > 128 ) + { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; printf("ABOUT TO CHECK LAST TX: %d\n",lasttx); + if ( lasttx == 0 ) + return(-1); + uint256 hash; CTransaction tx; if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { printf("CHECKING THE script pubkey\n"); @@ -1596,10 +1604,6 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } printf("THE PUBKEY IS RIGHT! \n"); } - } else - { - if ( komodo_checkcommission(pblock,height) < 0 ) - return(-1); } } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d352c89e4..0e9fc8e80 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4608,14 +4608,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; - if ( ASSETCHAINS_STREAM != 0 ) - { - txNew.vout[0].nValue = 0; - } - else - { - txNew.vout[0].nValue = utxovalue - txfee; - } + txNew.vout[0].nValue = utxovalue - txfee; txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; CTransaction txNewConst(txNew); signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); From af7ee589436c5050266573867bd3dc70ea4ff376 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 09:58:42 +0800 Subject: [PATCH 0245/3904] disable miner TX to test again --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 44fb0ba27..3f3175e2a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -492,7 +492,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); return(0); } - } + } /* else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } + } */ else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; From 4da719819f298b4ff6f99632d200f38415d5e099 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 10:57:19 +0800 Subject: [PATCH 0246/3904] disable need for extra TX under 128 blocks --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3f3175e2a..4af7383c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -492,8 +492,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); return(0); } - } /* - else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + } + else if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SYMBOL[0] != 0 && nHeight > 128 ) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } */ + } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; From 3448cd83bbcf3ebe995ba83aadcf0a426a50d9c1 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 19 Oct 2018 23:03:20 +0200 Subject: [PATCH 0247/3904] comment out spamming print --- src/cc/oracles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 7cccad0f6..0c7d9e6e2 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -666,7 +666,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); + //fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 5418cd4ad7b7d35e7d2f46c14c0b9983960f0dd9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 22 Oct 2018 17:11:27 +0800 Subject: [PATCH 0248/3904] disaable longestchain check in miner under 128 blocks --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4af7383c3..7ebf9bc27 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -957,7 +957,7 @@ void static BitcoinMiner() } while (true) { - if ( KOMODO_INSYNC == 0 ) + if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) { fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height); if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN ) From 62c220a9c2c603dbefbf92bb44f0ea4c8b50d8a4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 22 Oct 2018 22:16:16 +0800 Subject: [PATCH 0249/3904] remove insync check all together, slowing it down too much --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7ebf9bc27..2e26cf6cd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -957,13 +957,13 @@ void static BitcoinMiner() } while (true) { - if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) + /*if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) { fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height); if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN ) KOMODO_INSYNC = 1; sleep(3); - } + } */ // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; From 0aa4f46cccfb3c0f066b7134eec5c439b16df32f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 23 Oct 2018 23:29:49 +0800 Subject: [PATCH 0250/3904] add getblockdata RPC --- src/rpcblockchain.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++- src/rpcserver.cpp | 25 +++++++------- src/rpcserver.h | 1 + 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e9cf54bb4..ccbf4a6dd 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,6 +257,80 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } +UniValue getdatafromblock(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getdatafromblock \"hash|height\"\n" + "\nReturns all the data sent via streamer in block if there was any data in it.\n" + "\nArguments:\n" + "1. \"hash|height\" (string, required) The block hash or height\n" + "\nResult (for verbose=false):\n" + "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" + "\nExamples:\n" + + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + + HelpExampleCli("getblock", "12800") + + HelpExampleRpc("getblock", "12800") + ); + + LOCK(cs_main); + + std::string strHash = params[0].get_str(); + + // If height is supplied, find the hash + if (strHash.size() < (2 * sizeof(uint256))) { + // std::stoi allows characters, whereas we want to be strict + regex r("[[:digit:]]+"); + if (!regex_match(strHash, r)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + int nHeight = -1; + try { + nHeight = std::stoi(strHash); + } + catch (const std::exception &e) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + if (nHeight < 0 || nHeight > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + } + strHash = chainActive[nHeight]->GetBlockHash().GetHex(); + } + + uint256 hash(uint256S(strHash)); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + fprintf(stderr, "%s\n",tx.GetHash().GetHex()); + } + return chainActive.Height(); + /* + UniValue result(UniValue::VOBJ); + UniValue txs(UniValue::VARR); + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + txs.push_back(tx.GetHash().GetHex()); + } + result.push_back(Pair("tx", txs)); + return result; + */ +} + UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) { UniValue result(UniValue::VOBJ); @@ -816,7 +890,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp) " \"currentheight\": xxxxx, (numeric) current height of the chain\n" " \"key\": \"xxxxx\", (string) key\n" " \"keylen\": xxxxx, (string) length of the key \n" - " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" + " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" " \"height\": xxxxx, (numeric) height the key was stored at\n" " \"expiration\": xxxxx, (numeric) height the key will expire\n" " \"flags\": x (numeric) 1 if the key was created with a password; 0 otherwise.\n" diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 7d2eab1e3..b23dbc826 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -285,6 +285,7 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "getbestblockhash", &getbestblockhash, true }, { "blockchain", "getblockcount", &getblockcount, true }, { "blockchain", "getblock", &getblock, true }, + { "blockchain", "getdatafromblock", &getdatafromblock, true }, { "blockchain", "getblockdeltas", &getblockdeltas, false }, { "blockchain", "getblockhashes", &getblockhashes, true }, { "blockchain", "getblockhash", &getblockhash, true }, @@ -350,16 +351,16 @@ static const CRPCCommand vRPCCommands[] = #endif /* auction */ { "auction", "auctionaddress", &auctionaddress, true }, - + /* lotto */ { "lotto", "lottoaddress", &lottoaddress, true }, - + /* fsm */ { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + /* rewards */ { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -368,16 +369,16 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + /* faucet */ { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - + /* MofN */ { "MofN", "mofnaddress", &mofnaddress, true }, - + /* Channels */ { "channels", "channelsaddress", &channelsaddress, true }, { "channels", "channelsinfo", &channelsinfo, true }, @@ -385,7 +386,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + /* Oracles */ { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -395,7 +396,7 @@ static const CRPCCommand vRPCCommands[] = { "oracles", "oraclessubscribe", &oraclessubscribe, true }, { "oracles", "oraclesdata", &oraclesdata, true }, { "oracles", "oraclessamples", &oraclessamples, true }, - + /* Prices */ { "prices", "pricesaddress", &pricesaddress, true }, { "prices", "priceslist", &priceslist, true }, @@ -405,16 +406,16 @@ static const CRPCCommand vRPCCommands[] = { "prices", "pricesbet", &pricesbet, true }, { "prices", "pricesstatus", &pricesstatus, true }, { "prices", "pricesfinish", &pricesfinish, true }, - + /* Pegs */ { "pegs", "pegsaddress", &pegsaddress, true }, - + /* Triggers */ { "triggers", "triggersaddress", &triggersaddress, true }, - + /* Payments */ { "payments", "paymentsaddress", &paymentsaddress, true }, - + /* Gateways */ { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index a78f1b6fc..d2194db4f 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -363,6 +363,7 @@ extern UniValue getblockdeltas(const UniValue& params, bool fHelp); extern UniValue getblockhash(const UniValue& params, bool fHelp); extern UniValue getblockheader(const UniValue& params, bool fHelp); extern UniValue getblock(const UniValue& params, bool fHelp); +extern UniValue getdatafromblock(const UniValue& params, bool fHelp); extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp); extern UniValue gettxout(const UniValue& params, bool fHelp); extern UniValue verifychain(const UniValue& params, bool fHelp); From 10fbb81f2992e43e41b04b6c844d8b6aadb7ac52 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 23 Oct 2018 23:31:29 +0800 Subject: [PATCH 0251/3904] cstr --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index ccbf4a6dd..13d6d2ad9 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -316,7 +316,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) BOOST_FOREACH(const CTransaction&tx, block.vtx) { - fprintf(stderr, "%s\n",tx.GetHash().GetHex()); + fprintf(stderr, "%s\n",tx.GetHash().GetHex().cstr()); } return chainActive.Height(); /* From 4b6c433e49c7a878b4c9d8d321f118c606def0b4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 23 Oct 2018 23:34:37 +0800 Subject: [PATCH 0252/3904] try --- src/rpcblockchain.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 13d6d2ad9..a92da3b7c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -314,21 +314,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if(!ReadBlockFromDisk(block, pblockindex,1)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - BOOST_FOREACH(const CTransaction&tx, block.vtx) + /*BOOST_FOREACH(const CTransaction&tx, block.vtx) { fprintf(stderr, "%s\n",tx.GetHash().GetHex().cstr()); } return chainActive.Height(); - /* + */ UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - txs.push_back(tx.GetHash().GetHex()); + UniValue objTx(UniValue::VOBJ); + TxToJSON(tx, uint256(), objTx); + txs.push_back(objTx); } result.push_back(Pair("tx", txs)); return result; - */ } UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) From bbcfc72a6874b53e99e3fc7ca6c878c6223121ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:02:23 +0800 Subject: [PATCH 0253/3904] try --- src/rpcblockchain.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a92da3b7c..9d842c0e4 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -325,11 +325,23 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) BOOST_FOREACH(const CTransaction&tx, block.vtx) { UniValue objTx(UniValue::VOBJ); - TxToJSON(tx, uint256(), objTx); + voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); } result.push_back(Pair("tx", txs)); - return result; + return true; +} + +void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) +{ + UniValue vout(UniValue::VARR); + for (unsigned int i = 0; i < tx.vout.size(); i++) { + const CTxOut& txout = tx.vout[i]; + UniValue out(UniValue::VOBJ); + out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); + vout.push_back(out); + } + entry.push_back(Pair("vout", vout)); } UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) From f376020ee67c2723dcba352bf6a86f4179e7d03e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:04:04 +0800 Subject: [PATCH 0254/3904] fix --- src/rpcblockchain.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 9d842c0e4..f49902afc 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,6 +257,18 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } +void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) +{ + UniValue vout(UniValue::VARR); + for (unsigned int i = 0; i < tx.vout.size(); i++) { + const CTxOut& txout = tx.vout[i]; + UniValue out(UniValue::VOBJ); + out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); + vout.push_back(out); + } + entry.push_back(Pair("vout", vout)); +} + UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -332,18 +344,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return true; } -void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) -{ - UniValue vout(UniValue::VARR); - for (unsigned int i = 0; i < tx.vout.size(); i++) { - const CTxOut& txout = tx.vout[i]; - UniValue out(UniValue::VOBJ); - out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); - vout.push_back(out); - } - entry.push_back(Pair("vout", vout)); -} - UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) { UniValue result(UniValue::VOBJ); From f9bc9ee1e450e984c55b465d8550fb4cf06af276 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:05:28 +0800 Subject: [PATCH 0255/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f49902afc..95ae2d1dd 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -341,7 +341,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) txs.push_back(objTx); } result.push_back(Pair("tx", txs)); - return true; + return result; } UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) From 5143ef0c76287ebe10c5689375682cda0bfd5f3b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:11:06 +0800 Subject: [PATCH 0256/3904] try --- src/rpcblockchain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 95ae2d1dd..fd520122b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -334,11 +334,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) */ UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); + unsigned int i = 0; BOOST_FOREACH(const CTransaction&tx, block.vtx) { + if ( i != 0 || i != block.vxt.size() ) + { UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); + i = i + 1; + } } result.push_back(Pair("tx", txs)); return result; From b93f04b2bd2c6c29fc6be5bb6f8d16d1c8ea319e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:12:14 +0800 Subject: [PATCH 0257/3904] xt --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index fd520122b..9bfc8c696 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -337,7 +337,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) unsigned int i = 0; BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( i != 0 || i != block.vxt.size() ) + if ( i != 0 || i != block.vtx.size() ) { UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); From c540920d85329997400e6a18c066f09122072554 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:14:33 +0800 Subject: [PATCH 0258/3904] again --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 9bfc8c696..25853bc5b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -337,7 +337,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) unsigned int i = 0; BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( i != 0 || i != block.vtx.size() ) + if ( i != 0 || i != (block.vtx.size() -1) ) { UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); From f0d9eab81c29a55d8c763c44d058b3b1b239253f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:18:03 +0800 Subject: [PATCH 0259/3904] prints --- src/rpcblockchain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 25853bc5b..00db32085 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -335,8 +335,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); unsigned int i = 0; + fprintf(stderr, "%d\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { + fprintf(stderr, "tx number: %d \n",i); if ( i != 0 || i != (block.vtx.size() -1) ) { UniValue objTx(UniValue::VOBJ); From 10a51db52fba6f11d52ec2ebf1290b2661abe062 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:19:24 +0800 Subject: [PATCH 0260/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 00db32085..97339ef82 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -335,7 +335,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); unsigned int i = 0; - fprintf(stderr, "%d\n", block.vtx.size()); + fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { fprintf(stderr, "tx number: %d \n",i); From 65453a89387c04e0f62b31394d77b3b717920b49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:22:44 +0800 Subject: [PATCH 0261/3904] t --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 97339ef82..3d1ea7e90 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,9 +338,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - fprintf(stderr, "tx number: %d \n",i); if ( i != 0 || i != (block.vtx.size() -1) ) { + fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); From 9408ce62bd1bea34947bd1cc6b642c736203905b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:27:04 +0800 Subject: [PATCH 0262/3904] wtf --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 3d1ea7e90..00d18c4ba 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,14 +338,14 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( i != 0 || i != (block.vtx.size() -1) ) + if ( (i === 0) || (i == (block.vtx.size() -1)) ) { fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); - i = i + 1; } + i = i + 1; } result.push_back(Pair("tx", txs)); return result; From b6a0c1d55ab2ca187b9cefef6d593b82cd9a8646 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:28:12 +0800 Subject: [PATCH 0263/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 00d18c4ba..a674dba2d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,7 +338,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( (i === 0) || (i == (block.vtx.size() -1)) ) + if ( (i == 0) || (i == (block.vtx.size() -1)) ) { fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); From c465fbf0d3358425d8aac17289f58cdf9450297f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:30:58 +0800 Subject: [PATCH 0264/3904] fix --- src/rpcblockchain.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a674dba2d..ad36e2818 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -333,17 +333,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VOBJ); - UniValue txs(UniValue::VARR); unsigned int i = 0; - fprintf(stderr, "%ld\n", block.vtx.size()); + fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( (i == 0) || (i == (block.vtx.size() -1)) ) + if ( (i != 0) || (i != (block.vtx.size() -1)) ) { fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); - txs.push_back(objTx); + result.push_back(objTx); } i = i + 1; } From dc9e877b656b65a298af434fbc858efd759437ee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:32:09 +0800 Subject: [PATCH 0265/3904] fix --- src/rpcblockchain.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index ad36e2818..afc0159ba 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -346,7 +346,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - result.push_back(Pair("tx", txs)); return result; } From 85fecb9f761cc579c88b9f7022244bc43521622d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:36:38 +0800 Subject: [PATCH 0266/3904] fix? --- src/rpcblockchain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index afc0159ba..8ed47c140 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -332,14 +332,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } return chainActive.Height(); */ - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VARR); unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( (i != 0) || (i != (block.vtx.size() -1)) ) + if ( (i == 0) || (i == (block.vtx.size() -1)) ) { - fprintf(stderr, "tx number: %d \n",i); + fprintf(stderr, "skipped tx number: %d \n",i); + } else { + fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); result.push_back(objTx); From 5a363fdffcf612133e218ea3f37b665fd61f03f1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:41:36 +0800 Subject: [PATCH 0267/3904] maybe --- src/rpcblockchain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8ed47c140..e54ff8fb8 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -343,7 +343,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else { fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); - voutToJSON(tx, uint256(), objTx); + //voutToJSON(tx, uint256(), objTx); + //const CTxOut& txout = tx.vout[i]; + //UniValue out(UniValue::VOBJ); + objTx.push_back(Pair("hex", HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()))); result.push_back(objTx); } i = i + 1; From c4ee47ec3651ec29ce2a5da50ad0cbb21cee8990 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 12:12:18 +0800 Subject: [PATCH 0268/3904] add rpc to return pubkey --- src/rpcblockchain.cpp | 20 +++++--------------- src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e54ff8fb8..5499ca742 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,18 +257,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) -{ - UniValue vout(UniValue::VARR); - for (unsigned int i = 0; i < tx.vout.size(); i++) { - const CTxOut& txout = tx.vout[i]; - UniValue out(UniValue::VOBJ); - out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); - vout.push_back(out); - } - entry.push_back(Pair("vout", vout)); -} - UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -335,18 +323,20 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue result(UniValue::VARR); unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); + // Iif block tx size is > 2 then we can do this BOOST_FOREACH(const CTransaction&tx, block.vtx) { + //if the vout size = 3 then its a valid TX get the data. dont use the test here! it wont work with notarisations! if ( (i == 0) || (i == (block.vtx.size() -1)) ) { fprintf(stderr, "skipped tx number: %d \n",i); } else { fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); - //voutToJSON(tx, uint256(), objTx); - //const CTxOut& txout = tx.vout[i]; - //UniValue out(UniValue::VOBJ); + objTx.push_back(Pair("hex", HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()))); + // function here to extract seqid from first and last TX + // we an push the data or not depending on input from RPC. result.push_back(objTx); } i = i + 1; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index b23dbc826..15f31d8ef 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,6 +264,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "stop", &stop, true }, + { "control", "getpubkey", &getpubkey, true }, /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index d2194db4f..658102af0 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -322,6 +322,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); +extern UniValue getpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0e9fc8e80..e075a0d8b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4953,6 +4953,35 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +UniValue getpubkey(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + if (fHelp || params.size() > 0) + throw runtime_error( + "getpubkey\n" + "\nReturns the -pubkey the daemon was started with.\n" + "\nResult:\n" + "[\n" + " {\n" + " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " }\n" + "]\n" + "\nExamples:\n" + "\nList pubkey.\n" + + HelpExampleCli("getpubkey", "") + + HelpExampleRpc("getpubkey", "") + ); + + extern uint8_t NOTARY_PUBKEY33[]; + extern std::string NOTARY_PUBKEY; + if ( NOTARY_PUBKEY33[0] == 0 ) { + result.push_back(Pair("error","pubkey was not set!"; + } else { + result.push_back(Pair("pubkey", NOTARY_PUBKEY); + } + return result; +} + UniValue oraclesaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; From fac14d5dc4abd1c47f031596d15b2798445f14d6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 12:16:36 +0800 Subject: [PATCH 0269/3904] add pubkey to getinfo for all pubkeys, not just notary --- src/rpcmisc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a42afbb61..a1d576d58 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -158,6 +159,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 ) { + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } } if ( ASSETCHAINS_CC != 0 ) From 9920c80bde876e8b598b13ec4c3bde9c81ae801b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 12:49:12 +0800 Subject: [PATCH 0270/3904] add pubkey output to getinfo, and try setpubkey RPC --- src/rpcmisc.cpp | 3 +++ src/rpcserver.cpp | 2 +- src/rpcserver.h | 2 +- src/wallet/rpcwallet.cpp | 20 ++++++++++---------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a42afbb61..f104899e1 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -158,6 +159,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 ) { + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } } if ( ASSETCHAINS_CC != 0 ) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 15f31d8ef..1b590c5ae 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,7 +264,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "stop", &stop, true }, - { "control", "getpubkey", &getpubkey, true }, + { "control", "setpubkey", &setpubkey, true }, /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 658102af0..81ca8a8b9 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -322,7 +322,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); -extern UniValue getpubkey(const UniValue& params, bool fHelp); +extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e075a0d8b..acbe165c2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4953,13 +4953,13 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } -UniValue getpubkey(const UniValue& params, bool fHelp) +UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); - if (fHelp || params.size() > 0) + if ( fHelp || params.size() != 1 ) throw runtime_error( - "getpubkey\n" - "\nReturns the -pubkey the daemon was started with.\n" + "setpubkey\n" + "\Sets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" "\nResult:\n" "[\n" " {\n" @@ -4968,17 +4968,17 @@ UniValue getpubkey(const UniValue& params, bool fHelp) "]\n" "\nExamples:\n" "\nList pubkey.\n" - + HelpExampleCli("getpubkey", "") - + HelpExampleRpc("getpubkey", "") + + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 ) { - result.push_back(Pair("error","pubkey was not set!"; - } else { - result.push_back(Pair("pubkey", NOTARY_PUBKEY); + if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 )) { + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } + result.push_back(Pair("pubkey", NOTARY_PUBKEY); return result; } From 07bc62d2c3dd601a14408eee62605b7a993ef592 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 13:06:51 +0800 Subject: [PATCH 0271/3904] fix --- src/wallet/rpcwallet.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index acbe165c2..19ec2a498 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4958,27 +4958,26 @@ UniValue setpubkey(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); if ( fHelp || params.size() != 1 ) throw runtime_error( - "setpubkey\n" - "\Sets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" - "\nResult:\n" - "[\n" - " {\n" - " \"pubkey\" : \"pubkey\", (string) The pubkey\n" - " }\n" - "]\n" - "\nExamples:\n" - "\nList pubkey.\n" - + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - ); + "setpubkey\n" + "\nSets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" + "\nArguments:\n" + "1. \"pubkey\" (string) pubkey to set.\n" + "\nResult:\n" + " {\n" + " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " }\n" + "\nExamples:\n" + + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + ); extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 )) { + if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } - result.push_back(Pair("pubkey", NOTARY_PUBKEY); + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); return result; } From 9b6bc59d958e71523db59dfc6daeac591d33cfdf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 13:34:52 +0800 Subject: [PATCH 0272/3904] set pubkey fix --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 19ec2a498..fd51c47b6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4959,7 +4959,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error( "setpubkey\n" - "\nSets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" + "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" "\nArguments:\n" "1. \"pubkey\" (string) pubkey to set.\n" "\nResult:\n" @@ -4974,8 +4974,12 @@ UniValue setpubkey(const UniValue& params, bool fHelp) extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { + LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + + } else { + result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } result.push_back(Pair("pubkey", NOTARY_PUBKEY)); return result; From 5e95a0e51f0e6c6d60f8b5888172dc32b38400e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:13:39 +0800 Subject: [PATCH 0273/3904] add convert pubkey to address call --- src/wallet/rpcwallet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fd51c47b6..5509a6b09 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4971,13 +4971,15 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); + char *address; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - + pubkey2addr(address,(uint8_t *)NOTARY_PUBKEY33); + result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From bec8436996ad4d495b6e6fa74799963edd3f5b93 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:16:02 +0800 Subject: [PATCH 0274/3904] try --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5509a6b09..26e9602e9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4953,6 +4953,8 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); From 064e6b67e435ff96092ab8360db6079299bf18ab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:19:33 +0800 Subject: [PATCH 0275/3904] fix? --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 26e9602e9..1b85e2494 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4980,7 +4980,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr(address,(uint8_t *)NOTARY_PUBKEY33); + pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); + printf("%s\n",address); result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From fb13ce2e73ee2465c8d70301a8e2b8eedbca6410 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:23:43 +0800 Subject: [PATCH 0276/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1b85e2494..c69b9250e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4973,7 +4973,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); - char *address; + char address[20]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { From 4e989f5d0ed25909ad31b4c9dad6bc5f90377537 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:30:30 +0800 Subject: [PATCH 0277/3904] fix? --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c69b9250e..ab9eeced1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4982,7 +4982,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); printf("%s\n",address); - result.push_back(Pair("R-address", address)); + std::string str(address); + result.push_back(Pair("R-address", str)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 327f5aeb966f7ceced26409af97e212c4bb0065f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:35:47 +0800 Subject: [PATCH 0278/3904] hmm --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ab9eeced1..1724be26f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4983,7 +4983,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); printf("%s\n",address); std::string str(address); - result.push_back(Pair("R-address", str)); + cout << str; + //result.push_back(Pair("R-address", str)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 7cc09a50cc13a2e13a5e4b65259c9d2b255a5c68 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:39:04 +0800 Subject: [PATCH 0279/3904] try --- src/wallet/rpcwallet.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1724be26f..9f25005c1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4973,18 +4973,16 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); - char address[20]; + char address[18]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { - LOCK(cs_main); + //LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); printf("%s\n",address); - std::string str(address); - cout << str; - //result.push_back(Pair("R-address", str)); + result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 27402fecd1251487d8c2348e87b1eb4fec7959cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:46:37 +0800 Subject: [PATCH 0280/3904] try --- src/wallet/rpcwallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9f25005c1..00b33f7e6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4974,14 +4974,17 @@ UniValue setpubkey(const UniValue& params, bool fHelp) ); char address[18]; + uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)address,(uint8_t *)pubkey33); + printf("%s\n",address); + extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { //LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); - printf("%s\n",address); result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From ecfeb9dd9c449c54c1a6893963a6a3166f85fbce Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:50:43 +0800 Subject: [PATCH 0281/3904] try --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 00b33f7e6..63e2371f6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4976,9 +4976,9 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char address[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33); - printf("%s\n",address); - + if (pubkey2addr((char *)address,(uint8_t *)pubkey33)) + printf("%s\n",address); + extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { From b412964cf243607a1aec635968ee4aecd672c409 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:58:07 +0800 Subject: [PATCH 0282/3904] fix --- src/wallet/rpcwallet.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 63e2371f6..9bb049371 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4967,6 +4967,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) "\nResult:\n" " {\n" " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " \"R-address\" : \"R address\", (string) The pubkey\n" " }\n" "\nExamples:\n" + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") @@ -4975,16 +4976,14 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char address[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - if (pubkey2addr((char *)address,(uint8_t *)pubkey33)) - printf("%s\n",address); - extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { //LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)address,(uint8_t *)pubkey33) result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From 906935b4efa6e7c9c00212f84b754618e30d315e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:00:49 +0800 Subject: [PATCH 0283/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9bb049371..f32f08a84 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4983,7 +4983,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33) + pubkey2addr((char *)address,(uint8_t *)pubkey33); result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From 6ef59e5094e3bae67ec15cf322b2241d1dba90d4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:14:54 +0800 Subject: [PATCH 0284/3904] error checks --- src/wallet/rpcwallet.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f32f08a84..77863165e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4978,13 +4978,19 @@ UniValue setpubkey(const UniValue& params, bool fHelp) uint8_t pubkey33[33]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { - //LOCK(cs_main); - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33); - result.push_back(Pair("R-address", address)); + if ( NOTARY_PUBKEY33[0] == 0 ) { + if (strlen(params[0].get_str().c_str()) == 66) { + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)address,(uint8_t *)pubkey33); + if (strncmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { + result.push_back(Pair("error", "pubkey entered is invalid.")); + } else { + LOCK(cs_main); + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + result.push_back(Pair("R-address", address)); + } + } } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 841a3cc642236f0dfa045dc438a3338b7b44f8c9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:16:10 +0800 Subject: [PATCH 0285/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 77863165e..f24deadf8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4982,7 +4982,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); pubkey2addr((char *)address,(uint8_t *)pubkey33); - if (strncmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { + if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { result.push_back(Pair("error", "pubkey entered is invalid.")); } else { LOCK(cs_main); From 021d89a826201e2719ccd1829b23dbb47df51406 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:19:05 +0800 Subject: [PATCH 0286/3904] fix --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f24deadf8..74bdf7e47 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4990,6 +4990,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); result.push_back(Pair("R-address", address)); } + } else { + result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); } } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From fc9a044c7e1be004b04ccdc890e6c995f619d0be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:31:27 +0800 Subject: [PATCH 0287/3904] try --- src/wallet/rpcwallet.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 74bdf7e47..7a166a495 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4974,21 +4974,37 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); - char address[18]; +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +#else + LOCK(cs_main); +#endif + + char Raddress[18]; uint8_t pubkey33[33]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { result.push_back(Pair("error", "pubkey entered is invalid.")); } else { - LOCK(cs_main); + CBitcoinAddress address(Raddress); + bool isValid = address.IsValid(); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + result.push_back(Pair("address", currentAddress)); +#ifdef ENABLE_WALLET + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); +#endif + } NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - result.push_back(Pair("R-address", address)); } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); From e3237f4a0b3d09e440ac36f369e60bf167462341 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:48:19 +0800 Subject: [PATCH 0288/3904] test adding pubkey to getinfo and setpubkey RPC --- src/rpcmisc.cpp | 3 ++ src/rpcserver.cpp | 25 ++++++++-------- src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 12 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a42afbb61..a1d576d58 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -158,6 +159,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 ) { + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } } if ( ASSETCHAINS_CC != 0 ) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 7d2eab1e3..f724b5071 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -350,16 +350,16 @@ static const CRPCCommand vRPCCommands[] = #endif /* auction */ { "auction", "auctionaddress", &auctionaddress, true }, - + /* lotto */ { "lotto", "lottoaddress", &lottoaddress, true }, - + /* fsm */ { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + /* rewards */ { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -368,16 +368,16 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + /* faucet */ { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - + /* MofN */ { "MofN", "mofnaddress", &mofnaddress, true }, - + /* Channels */ { "channels", "channelsaddress", &channelsaddress, true }, { "channels", "channelsinfo", &channelsinfo, true }, @@ -385,7 +385,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + /* Oracles */ { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -395,7 +395,7 @@ static const CRPCCommand vRPCCommands[] = { "oracles", "oraclessubscribe", &oraclessubscribe, true }, { "oracles", "oraclesdata", &oraclesdata, true }, { "oracles", "oraclessamples", &oraclessamples, true }, - + /* Prices */ { "prices", "pricesaddress", &pricesaddress, true }, { "prices", "priceslist", &priceslist, true }, @@ -405,16 +405,16 @@ static const CRPCCommand vRPCCommands[] = { "prices", "pricesbet", &pricesbet, true }, { "prices", "pricesstatus", &pricesstatus, true }, { "prices", "pricesfinish", &pricesfinish, true }, - + /* Pegs */ { "pegs", "pegsaddress", &pegsaddress, true }, - + /* Triggers */ { "triggers", "triggersaddress", &triggersaddress, true }, - + /* Payments */ { "payments", "paymentsaddress", &paymentsaddress, true }, - + /* Gateways */ { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, @@ -521,6 +521,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "sendmany", &sendmany, false }, { "wallet", "sendtoaddress", &sendtoaddress, false }, { "wallet", "setaccount", &setaccount, true }, + { "wallet", "setpubkey", &setpubkey, true }, { "wallet", "settxfee", &settxfee, true }, { "wallet", "signmessage", &signmessage, true }, { "wallet", "walletlock", &walletlock, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index a78f1b6fc..98c3357f9 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -322,6 +322,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); +extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 936c31fd9..c06477099 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4951,6 +4951,68 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +UniValue setpubkey(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + if ( fHelp || params.size() != 1 ) + throw runtime_error( + "setpubkey\n" + "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" + "\nArguments:\n" + "1. \"pubkey\" (string) pubkey to set.\n" + "\nResult:\n" + " {\n" + " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " \"ismine\" : \"true/false\", (bool)\n" + " \"R-address\" : \"R address\", (string) The pubkey\n" + " }\n" + "\nExamples:\n" + + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + ); + +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +#else + LOCK(cs_main); +#endif + + char Raddress[18]; + uint8_t pubkey33[33]; + extern uint8_t NOTARY_PUBKEY33[]; + extern std::string NOTARY_PUBKEY; + if ( NOTARY_PUBKEY33[0] == 0 ) { + if (strlen(params[0].get_str().c_str()) == 66) { + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { + result.push_back(Pair("error", "pubkey entered is invalid.")); + } else { + CBitcoinAddress address(Raddress); + bool isValid = address.IsValid(); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + result.push_back(Pair("address", currentAddress)); +#ifdef ENABLE_WALLET + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); +#endif + } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + } + } else { + result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); + } + } else { + result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); + } + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + return result; +} + UniValue oraclesaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; From d1791de6f1b6e624c009f7d1afe583c928365d7d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:55:59 +0800 Subject: [PATCH 0289/3904] fix --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c06477099..3f42fb241 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4951,6 +4951,8 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); From dc28f2eb66d2552ea0856e4e4dcbf709fbcac3b5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 23:57:26 +0800 Subject: [PATCH 0290/3904] update getdata function --- src/rpcblockchain.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 5499ca742..2212811ef 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -324,22 +324,33 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this - BOOST_FOREACH(const CTransaction&tx, block.vtx) - { - //if the vout size = 3 then its a valid TX get the data. dont use the test here! it wont work with notarisations! - if ( (i == 0) || (i == (block.vtx.size() -1)) ) + if ( block.vtx.size() > 2 ) { + BOOST_FOREACH(const CTransaction&tx, block.vtx) { - fprintf(stderr, "skipped tx number: %d \n",i); - } else { - fprintf(stderr, "added tx number: %d \n",i); - UniValue objTx(UniValue::VOBJ); - - objTx.push_back(Pair("hex", HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()))); - // function here to extract seqid from first and last TX - // we an push the data or not depending on input from RPC. - result.push_back(objTx); + // ignore first and last TX and any TX that does not have 3 vouts. + if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) + { + fprintf(stderr, "skipped tx number: %d \n",i); + } else { + fprintf(stderr, "added tx number: %d \n",i); + UniValue objTx(UniValue::VOBJ); + std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()) + if ( opretstr.size() > 81 ) { + std::string idstr = str.substr (8,64); // stream ID or txid + std::string seqid = str.substr (72,8); // sequence ID + std::string data = str.substr (80); // data chunk + objTx.push_back(Pair("idstr", idstr)); + objTx.push_back(Pair("seqid", seqid)); + objTx.push_back(Pair("data", data)); + result.push_back(objTx); + } + // function here to extract seqid from first and last TX + // we an push the data or not depending on input from RPC. + } + i = i + 1; } - i = i + 1; + } else { + result.push_back(Pair("error","there are no TX in this block.")) } return result; } From d89e0313cbb0fcd71a274693741386707ecf7b5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:01:15 +0800 Subject: [PATCH 0291/3904] ; --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 2212811ef..eb0aa4675 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -334,7 +334,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else { fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); - std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()) + std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = str.substr (8,64); // stream ID or txid std::string seqid = str.substr (72,8); // sequence ID @@ -345,7 +345,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(objTx); } // function here to extract seqid from first and last TX - // we an push the data or not depending on input from RPC. + // we an push the data or not depending on input from RPC. } i = i + 1; } From e80718809fad34d12529b19192b2325bb87c95ed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:02:31 +0800 Subject: [PATCH 0292/3904] oops --- src/rpcblockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index eb0aa4675..206aabfcf 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -336,9 +336,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue objTx(UniValue::VOBJ); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { - std::string idstr = str.substr (8,64); // stream ID or txid - std::string seqid = str.substr (72,8); // sequence ID - std::string data = str.substr (80); // data chunk + std::string idstr = opretstr.substr (8,64); // stream ID or txid + std::string seqid = opretstr.substr (72,8); // sequence ID + std::string data = opretstr.substr (80); // data chunk objTx.push_back(Pair("idstr", idstr)); objTx.push_back(Pair("seqid", seqid)); objTx.push_back(Pair("data", data)); From deeb2e2d20c347557162c948ef51ad4c8446fbcb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:03:36 +0800 Subject: [PATCH 0293/3904] ; --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 206aabfcf..85c7ce343 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -350,7 +350,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) i = i + 1; } } else { - result.push_back(Pair("error","there are no TX in this block.")) + result.push_back(Pair("error","there are no TX in this block.")); } return result; } From 7566c9f1612f5bcd1bdf0c6f8ccbe5e799acf925 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:21:50 +0800 Subject: [PATCH 0294/3904] seqid as int --- src/rpcblockchain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 85c7ce343..cfa823112 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,6 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); + unsigned int lastseqid = 0; unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this @@ -337,7 +338,11 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid - std::string seqid = opretstr.substr (72,8); // sequence ID + std::string seqidstr = opretstr.substr (72,8); // sequence ID + unsigned int seqid; + std::stringstream ss; + ss << std::hex << seqidstr; + ss >> seqid; std::string data = opretstr.substr (80); // data chunk objTx.push_back(Pair("idstr", idstr)); objTx.push_back(Pair("seqid", seqid)); From f8dbd08dc8b14988ae4621b33b115a1630af127e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:24:20 +0800 Subject: [PATCH 0295/3904] ? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index cfa823112..16316ae4e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -345,7 +345,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; std::string data = opretstr.substr (80); // data chunk objTx.push_back(Pair("idstr", idstr)); - objTx.push_back(Pair("seqid", seqid)); + objTx.push_back(Pair("seqid", (int)seqid)); objTx.push_back(Pair("data", data)); result.push_back(objTx); } From b52da6b92141cfff32588b7e17f5a50982b25fa1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:52:33 +0800 Subject: [PATCH 0296/3904] try --- src/rpcblockchain.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 16316ae4e..a4d5d8040 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,8 +321,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); - unsigned int lastseqid = 0; - unsigned int i = 0; + unsigned int firstdeqid = lastseqid = i = did1 = 0; + static std::string streamid,firsttxid; + std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this if ( block.vtx.size() > 2 ) { @@ -334,26 +335,37 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "skipped tx number: %d \n",i); } else { fprintf(stderr, "added tx number: %d \n",i); - UniValue objTx(UniValue::VOBJ); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID + std::string data = opretstr.substr (80); // data chunk unsigned int seqid; std::stringstream ss; ss << std::hex << seqidstr; ss >> seqid; - std::string data = opretstr.substr (80); // data chunk - objTx.push_back(Pair("idstr", idstr)); - objTx.push_back(Pair("seqid", (int)seqid)); - objTx.push_back(Pair("data", data)); - result.push_back(objTx); + if ( seqid == 1 ) { + streamid = idstr; + } + if ( seqid == (lastseqid + 1 )) { + blockdata.append(data); + } + if ( did1 == 0 ) { + firstdeqid = seqid; + did1 = 1; + } + lastseqid = seqid; } // function here to extract seqid from first and last TX // we an push the data or not depending on input from RPC. } i = i + 1; } + result.push_back(Pair("streamid", streamid)); + result.push_back(Pair("firstseqid", (int)firstseqid)); + result.push_back(Pair("lastseqid", (int)lastseqid)); + result.push_back(Pair("data", blockdata)); + result.push_back(objTx); } else { result.push_back(Pair("error","there are no TX in this block.")); } From d640ffcea71a8012ec84fdfa120d1b884161f5d9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:54:11 +0800 Subject: [PATCH 0297/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a4d5d8040..c9942a5f4 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); - unsigned int firstdeqid = lastseqid = i = did1 = 0; + unsigned int firstdeqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); From 04278865dc9596951bed0fb46a60ea0209b7c3d3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:54:28 +0800 Subject: [PATCH 0298/3904] fix --- src/rpcblockchain.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c9942a5f4..674f99f42 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -365,7 +365,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); result.push_back(Pair("data", blockdata)); - result.push_back(objTx); } else { result.push_back(Pair("error","there are no TX in this block.")); } From 61cbc5257fceb7435faa3f238411a745176df961 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:55:30 +0800 Subject: [PATCH 0299/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 674f99f42..847ee13db 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); - unsigned int firstdeqid,lastseqid,i,did1; + unsigned int firstseqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); From 11eccfa80bbdea7da4995e8001fb5185156c7910 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:56:24 +0800 Subject: [PATCH 0300/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 847ee13db..51036995d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -351,7 +351,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) blockdata.append(data); } if ( did1 == 0 ) { - firstdeqid = seqid; + firstseqid = seqid; did1 = 1; } lastseqid = seqid; From 659f97c027ca016c0ef9224cb5dc86308cb69fca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:02:19 +0800 Subject: [PATCH 0301/3904] fix? --- src/rpcblockchain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 51036995d..f3f483b5b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -320,7 +320,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } return chainActive.Height(); */ - UniValue result(UniValue::VARR); + UniValue result(UniValue::VOBJ); unsigned int firstseqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; @@ -332,9 +332,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d \n",i); + fprintf(stderr, "skipped tx number: %u \n",i); } else { - fprintf(stderr, "added tx number: %d \n",i); + fprintf(stderr, "added tx number: %u \n",i); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid @@ -346,6 +346,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; if ( seqid == 1 ) { streamid = idstr; + printf("streamid: %s\n",streamid.c_str()); } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -353,6 +354,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( did1 == 0 ) { firstseqid = seqid; did1 = 1; + printf("DID 1 first seqid = %u\n", firstseqid); } lastseqid = seqid; } From 426015aa75d50e763065e15d5c629f3ef80a9f05 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:09:19 +0800 Subject: [PATCH 0302/3904] WOW! it works --- src/rpcblockchain.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f3f483b5b..adaed6b2e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VOBJ); - unsigned int firstseqid,lastseqid,i,did1; + signed int firstseqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); @@ -332,9 +332,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %u \n",i); + fprintf(stderr, "skipped tx number: %d \n",i); } else { - fprintf(stderr, "added tx number: %u \n",i); + fprintf(stderr, "added tx number: %d \n",i); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid @@ -346,7 +346,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; if ( seqid == 1 ) { streamid = idstr; - printf("streamid: %s\n",streamid.c_str()); + } else if ( seqid == 2 ) { + firsttxid = idstr; } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -354,7 +355,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( did1 == 0 ) { firstseqid = seqid; did1 = 1; - printf("DID 1 first seqid = %u\n", firstseqid); } lastseqid = seqid; } @@ -364,6 +364,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) i = i + 1; } result.push_back(Pair("streamid", streamid)); + result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); result.push_back(Pair("data", blockdata)); From 3d29921a2562895d1634031e36400618a76aa111 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:13:43 +0800 Subject: [PATCH 0303/3904] fix --- src/rpcblockchain.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index adaed6b2e..56ac5f777 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VOBJ); - signed int firstseqid,lastseqid,i,did1; + signed int firstseqid,lastseqid; + int i = 0; + int did1 = 0; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); @@ -332,9 +334,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d \n",i); + fprintf(stderr, "skipped tx number: %d\n,i"; } else { - fprintf(stderr, "added tx number: %d \n",i); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid From 81ae02e649f3565bf3a285ea29de52b322c05341 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:14:47 +0800 Subject: [PATCH 0304/3904] oops --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 56ac5f777..a972900c1 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -334,7 +334,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d\n,i"; + fprintf(stderr, "skipped tx number: %d\n,i)"; } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { From e42dcb0474697084d94ad3c1761e6a19cbfcf4f6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:24:19 +0800 Subject: [PATCH 0305/3904] more stuff --- src/rpcblockchain.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a972900c1..0468ace89 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,6 +257,12 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } +int convertstreamid(char *streamid_str, char *streamid_hex) { + char decodedhextest[32]; + decode_hex(streamid_str,32,streamid_hex); + printf("decoded hex: %s\n",decodedhextest); +} + UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -314,12 +320,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if(!ReadBlockFromDisk(block, pblockindex,1)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - /*BOOST_FOREACH(const CTransaction&tx, block.vtx) - { - fprintf(stderr, "%s\n",tx.GetHash().GetHex().cstr()); - } - return chainActive.Height(); - */ UniValue result(UniValue::VOBJ); signed int firstseqid,lastseqid; int i = 0; @@ -338,9 +338,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { - std::string idstr = opretstr.substr (8,64); // stream ID or txid + std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID - std::string data = opretstr.substr (80); // data chunk + std::string data = opretstr.substr (80); // data chunk unsigned int seqid; std::stringstream ss; ss << std::hex << seqidstr; @@ -349,6 +349,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) streamid = idstr; } else if ( seqid == 2 ) { firsttxid = idstr; + } else if (firsttxid.isempty()) { + firsttxid == idstr; } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -364,13 +366,24 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - result.push_back(Pair("streamid", streamid)); + if (streamid.isempty()) { + uint256 hash,firsttxid_256; CTransaction firsttx; + firsttxid_256 = bits256_conv(firsttxid); + if (GetTransaction(firsttxid_256,firsttx,hash,false)) { + std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); + std::string streamid = firststreamid.substr (8,64); + } + } + char decodedstreamid[32]; + decode_hex(decodedstreamid,32,streamid.c_str()); + printf("decoded hex: %s\n",decodedstreamid); + result.push_back(Pair("streamid", decodedstreamid); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); result.push_back(Pair("data", blockdata)); } else { - result.push_back(Pair("error","there are no TX in this block.")); + result.push_back(Pair("error","there is no data in this block.")); } return result; } From be21e25e563456e18a6642358cb2bb80778e4a1f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:32:55 +0800 Subject: [PATCH 0306/3904] fix --- src/rpcblockchain.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0468ace89..45ce9b70c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,10 +257,14 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int convertstreamid(char *streamid_str, char *streamid_hex) { - char decodedhextest[32]; - decode_hex(streamid_str,32,streamid_hex); - printf("decoded hex: %s\n",decodedhextest); +int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +bits256 bits256_conv(char *hexstr) +{ + bits256 x; + memset(&x,0,sizeof(x)); + if ( strlen(hexstr) == sizeof(x)*2) + decode_hex(x.bytes,sizeof(x.bytes),hexstr); + return(x); } UniValue getdatafromblock(const UniValue& params, bool fHelp) @@ -349,7 +353,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) streamid = idstr; } else if ( seqid == 2 ) { firsttxid = idstr; - } else if (firsttxid.isempty()) { + } else if (firsttxid.empty()) { firsttxid == idstr; } if ( seqid == (lastseqid + 1 )) { @@ -366,7 +370,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - if (streamid.isempty()) { + if (streamid.empty()) { uint256 hash,firsttxid_256; CTransaction firsttx; firsttxid_256 = bits256_conv(firsttxid); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { From aae6bbcdf263295a4fbcc7fa025c493a91716f1c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:35:51 +0800 Subject: [PATCH 0307/3904] fix some --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 45ce9b70c..f77f5dba7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,7 +338,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d\n,i)"; + fprintf(stderr, "skipped tx number: %d\n",i); } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { @@ -381,7 +381,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) char decodedstreamid[32]; decode_hex(decodedstreamid,32,streamid.c_str()); printf("decoded hex: %s\n",decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid); + result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); From 5e0dd924c6cda3f6d2f24eaa9cc8e24956ec0dcf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:51:28 +0800 Subject: [PATCH 0308/3904] try --- src/rpcblockchain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f77f5dba7..e48473c1c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -258,9 +258,9 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) } int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); -bits256 bits256_conv(char *hexstr) +uint256 bits256_conv(char *hexstr) { - bits256 x; + uint256 x; memset(&x,0,sizeof(x)); if ( strlen(hexstr) == sizeof(x)*2) decode_hex(x.bytes,sizeof(x.bytes),hexstr); @@ -379,8 +379,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } char decodedstreamid[32]; - decode_hex(decodedstreamid,32,streamid.c_str()); - printf("decoded hex: %s\n",decodedstreamid); + decode_hex((char *)decodedstreamid,32,streamid.c_str()); + printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); From a1141951cab2afa1c0ebeb3a3547579be9c5d884 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:05:53 +0800 Subject: [PATCH 0309/3904] try --- src/rpcblockchain.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e48473c1c..d0eb45401 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -258,14 +258,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) } int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); -uint256 bits256_conv(char *hexstr) -{ - uint256 x; - memset(&x,0,sizeof(x)); - if ( strlen(hexstr) == sizeof(x)*2) - decode_hex(x.bytes,sizeof(x.bytes),hexstr); - return(x); -} UniValue getdatafromblock(const UniValue& params, bool fHelp) { @@ -371,15 +363,15 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) i = i + 1; } if (streamid.empty()) { - uint256 hash,firsttxid_256; CTransaction firsttx; - firsttxid_256 = bits256_conv(firsttxid); + uint256 hash; CTransaction firsttx; + uint256 firsttxid_256 = ParseHashV(firsttxid); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); std::string streamid = firststreamid.substr (8,64); } } char decodedstreamid[32]; - decode_hex((char *)decodedstreamid,32,streamid.c_str()); + decode_hex((uint8_t)decodedstreamid,32,streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From 7768292e180714c1b980c18425a9ddb5f7d378f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:08:15 +0800 Subject: [PATCH 0310/3904] ? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index d0eb45401..b798cb22e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -364,7 +364,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } if (streamid.empty()) { uint256 hash; CTransaction firsttx; - uint256 firsttxid_256 = ParseHashV(firsttxid); + uint256 firsttxid_256 = ParseHashV(firsttxid,"firsttxid"); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); std::string streamid = firststreamid.substr (8,64); From 2630e93a16851c5b6549fe2604d63ff2abe492fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:11:42 +0800 Subject: [PATCH 0311/3904] ? --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b798cb22e..c32e645da 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,7 +257,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +int32_t decode_hex(char *bytes,int32_t n,char *hex); UniValue getdatafromblock(const UniValue& params, bool fHelp) { @@ -371,7 +371,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } char decodedstreamid[32]; - decode_hex((uint8_t)decodedstreamid,32,streamid.c_str()); + decode_hex(decodedstreamid,32,streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From 5b11f256aae923e98c47920000131a2b61e7b1ad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:15:07 +0800 Subject: [PATCH 0312/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c32e645da..a009a2752 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -371,7 +371,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } char decodedstreamid[32]; - decode_hex(decodedstreamid,32,streamid.c_str()); + decode_hex(decodedstreamid,32,(char *)streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From 89f6e171dee2c861b7928b89eca6bb8b722c74e5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:17:16 +0800 Subject: [PATCH 0313/3904] again --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a009a2752..b0dd031a9 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,7 +257,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int32_t decode_hex(char *bytes,int32_t n,char *hex); +int32_t decode_hex(uint8_t bytes,int32_t n,char *hex); UniValue getdatafromblock(const UniValue& params, bool fHelp) { From 5d5c1bd4738821416cbf01b57f616cbb68a62098 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:25:40 +0800 Subject: [PATCH 0314/3904] try --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b0dd031a9..c062669a7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -370,7 +370,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string streamid = firststreamid.substr (8,64); } } - char decodedstreamid[32]; + uint8_t decodedstreamid[32]; decode_hex(decodedstreamid,32,(char *)streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); From 1e8cd9ff69ddcb4a37ff5c1d47a2d69133e9ff63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:28:28 +0800 Subject: [PATCH 0315/3904] ? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c062669a7..74b3f297d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -371,7 +371,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } uint8_t decodedstreamid[32]; - decode_hex(decodedstreamid,32,(char *)streamid.c_str()); + decode_hex(*decodedstreamid,32,(char *)streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From e8caddfca3adfbc4f848e8c3b3da961332c02bab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:31:20 +0800 Subject: [PATCH 0316/3904] include decode hex --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 74b3f297d..76395ca8f 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -20,6 +20,7 @@ #include "script/script_error.h" #include "script/sign.h" #include "script/standard.h" +#include "komodo_utils.h" #include From 5489c976f0c479a69997ad69b315471deebc2832 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:37:54 +0800 Subject: [PATCH 0317/3904] fix --- src/rpcblockchain.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 76395ca8f..eec2130c1 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -20,7 +20,6 @@ #include "script/script_error.h" #include "script/sign.h" #include "script/standard.h" -#include "komodo_utils.h" #include @@ -258,7 +257,30 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int32_t decode_hex(uint8_t bytes,int32_t n,char *hex); +unsigned char hexval(unsigned char c) +{ + if ('0' <= c && c <= '9') + return c - '0'; + else if ('a' <= c && c <= 'f') + return c - 'a' + 10; + else if ('A' <= c && c <= 'F') + return c - 'A' + 10; + else abort(); +} + +void hex2ascii(const string& in, string& out) +{ + out.clear(); + out.reserve(in.length() / 2); + for (string::const_iterator p = in.begin(); p != in.end(); p++) + { + unsigned char c = hexval(*p); + p++; + if (p == in.end()) break; // incomplete last digit - should report error + c = (c << 4) + hexval(*p); // + takes precedence over << + out.push_back(c); + } +} UniValue getdatafromblock(const UniValue& params, bool fHelp) { @@ -371,9 +393,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string streamid = firststreamid.substr (8,64); } } - uint8_t decodedstreamid[32]; - decode_hex(*decodedstreamid,32,(char *)streamid.c_str()); - printf("decoded hex: %s\n",(char *)decodedstreamid); + std::string decodedstreamid; + hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); From 95992d4492aff6bdd2ce865697b357fe7e1f0192 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:50:47 +0800 Subject: [PATCH 0318/3904] add t/f flag for data --- src/rpcblockchain.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index eec2130c1..5f6142300 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -330,6 +330,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (mapBlockIndex.count(hash) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + bool fVerbose = true; + if (params.size() > 1) + fVerbose = params[1].get_bool(); + CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; @@ -399,7 +403,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - result.push_back(Pair("data", blockdata)); + if (fVerbose) { + result.push_back(Pair("data", blockdata)); + } } else { result.push_back(Pair("error","there is no data in this block.")); } From c4434400d19d42dc9fd05d767f5d9244c6c1dc40 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:55:29 +0800 Subject: [PATCH 0319/3904] try --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 5f6142300..612acf2bf 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -330,9 +330,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (mapBlockIndex.count(hash) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - bool fVerbose = true; + bool fVerbose = false; if (params.size() > 1) - fVerbose = params[1].get_bool(); + fVerbose = (params[1].get_int() != 0); CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; From e8cd54ea2fbdb43b495792acf5979ac3d8851f94 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 12:02:58 +0800 Subject: [PATCH 0320/3904] ? --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 612acf2bf..0178fbf43 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -373,6 +373,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if ( seqid == 2 ) { firsttxid = idstr; } else if (firsttxid.empty()) { + printf("firsttxid is empty: %s\n",idstr.c_str()); firsttxid == idstr; } if ( seqid == (lastseqid + 1 )) { From 6ac869140f17fbead6dff7e1e68d5315032aea8f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 12:53:05 +0800 Subject: [PATCH 0321/3904] ? --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0178fbf43..204ea7b23 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -374,7 +374,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid = idstr; } else if (firsttxid.empty()) { printf("firsttxid is empty: %s\n",idstr.c_str()); - firsttxid == idstr; + firsttxid.append(idstr); } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -392,7 +392,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } if (streamid.empty()) { uint256 hash; CTransaction firsttx; - uint256 firsttxid_256 = ParseHashV(firsttxid,"firsttxid"); + uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); std::string streamid = firststreamid.substr (8,64); From ee7e3de254a836821036585c8f60ffca8a54ec7c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 12:57:07 +0800 Subject: [PATCH 0322/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 204ea7b23..0fdb17dea 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -395,7 +395,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - std::string streamid = firststreamid.substr (8,64); + streamid.append(firststreamid.substr (8,64)); } } std::string decodedstreamid; From 07f2fa7b1f4a1d7a45708008df4860cf2dac563f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 13:00:29 +0800 Subject: [PATCH 0323/3904] hex --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0fdb17dea..38c450224 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -401,6 +401,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); + result.push_back(Pair("streamidhex", streamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); From d32cdefe7bc9b415469d407e9ea91e145a3bb68f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 13:18:23 +0800 Subject: [PATCH 0324/3904] test --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 38c450224..f013420e4 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -278,6 +278,7 @@ void hex2ascii(const string& in, string& out) p++; if (p == in.end()) break; // incomplete last digit - should report error c = (c << 4) + hexval(*p); // + takes precedence over << + printf("char: %d\n",c); out.push_back(c); } } From ed7c03730365c8cca5a77a38570eed48009d52c6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 13:26:17 +0800 Subject: [PATCH 0325/3904] try --- src/rpcblockchain.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f013420e4..655d2c906 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -278,7 +278,6 @@ void hex2ascii(const string& in, string& out) p++; if (p == in.end()) break; // incomplete last digit - should report error c = (c << 4) + hexval(*p); // + takes precedence over << - printf("char: %d\n",c); out.push_back(c); } } @@ -401,7 +400,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid)); + result.push_back(Pair("streamid", decodedstreamid.c_str())); result.push_back(Pair("streamidhex", streamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); From 1ec39b2b97a7b1361303020f7048988b3466455a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:09:51 +0800 Subject: [PATCH 0326/3904] try 2 arg as str --- src/rpcblockchain.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 655d2c906..cd7167dcf 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -303,6 +303,11 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string strHash = params[0].get_str(); + if (params.size() > 1) { + std::string getdata = params[1].get_str(); + printf("%s\n",getdata.c_str()); + } + // If height is supplied, find the hash if (strHash.size() < (2 * sizeof(uint256))) { // std::stoi allows characters, whereas we want to be strict @@ -330,10 +335,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (mapBlockIndex.count(hash) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - bool fVerbose = false; - if (params.size() > 1) - fVerbose = (params[1].get_int() != 0); - CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; @@ -360,6 +361,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "skipped tx number: %d\n",i); } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); + // scriptPubKey is longer than 81, should mean its an OP_RETURN. if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID @@ -373,11 +375,15 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if ( seqid == 2 ) { firsttxid = idstr; } else if (firsttxid.empty()) { - printf("firsttxid is empty: %s\n",idstr.c_str()); firsttxid.append(idstr); } + if ( seqid == (lastseqid + 1 )) { blockdata.append(data); + } else { + result.push_back(Pair("error","chunck out of order in this block!")); + result.push_back(Pair("lastvalidseqid", (int)seqid)); + break; } if ( did1 == 0 ) { firstseqid = seqid; @@ -401,7 +407,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); - result.push_back(Pair("streamidhex", streamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); From a5c99046866f2eaae4616ae4d5a315ba93ff377a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:11:33 +0800 Subject: [PATCH 0327/3904] fix --- src/rpcblockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index cd7167dcf..b7def7ea6 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -410,9 +410,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose) { - result.push_back(Pair("data", blockdata)); - } + //if (fVerbose) { + // result.push_back(Pair("data", blockdata)); + //} } else { result.push_back(Pair("error","there is no data in this block.")); } From 806a8e93aa997779fd9cb5920db65d8fb78e9a62 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:15:12 +0800 Subject: [PATCH 0328/3904] fix? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b7def7ea6..f4ec0d1fa 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -378,7 +378,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } - if ( seqid == (lastseqid + 1 )) { + if ( (seqid == (lastseqid + 1 )) && lastseqid != 0 ) { blockdata.append(data); } else { result.push_back(Pair("error","chunck out of order in this block!")); From 9b3cd72603436b8f8e4cc0b0835388b94e49c9fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:23:26 +0800 Subject: [PATCH 0329/3904] wtf --- src/rpcblockchain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f4ec0d1fa..74536a2af 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -345,7 +345,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); UniValue result(UniValue::VOBJ); - signed int firstseqid,lastseqid; + int firstseqid = 0; + int lastseqid = 0; int i = 0; int did1 = 0; static std::string streamid,firsttxid; @@ -378,12 +379,13 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } - if ( (seqid == (lastseqid + 1 )) && lastseqid != 0 ) { + if ( seqid == (lastseqid + 1 ) ) { blockdata.append(data); } else { + printf("seqid.%d lastseqid.%d\n",seqid,lastseqid); result.push_back(Pair("error","chunck out of order in this block!")); result.push_back(Pair("lastvalidseqid", (int)seqid)); - break; + //break; } if ( did1 == 0 ) { firstseqid = seqid; From 1dd2a13d7c7ea8f231be9b9cdc59d56821910ed7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:29:13 +0800 Subject: [PATCH 0330/3904] fixed --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 74536a2af..02547ac66 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -379,7 +379,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } - if ( seqid == (lastseqid + 1 ) ) { + if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { printf("seqid.%d lastseqid.%d\n",seqid,lastseqid); From a3b73317734d4552f78175e8b1c08a57c811317a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:52:23 +0800 Subject: [PATCH 0331/3904] try --- src/rpcblockchain.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 02547ac66..5309b9536 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -286,26 +286,38 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "getdatafromblock \"hash|height\"\n" + "getdatafromblock \"hash|height\" true/false\n" "\nReturns all the data sent via streamer in block if there was any data in it.\n" "\nArguments:\n" "1. \"hash|height\" (string, required) The block hash or height\n" + "2. \"true/false\" (bool, optional) if false do not return the actual data. Default true.\n" + "\nResult (for verbose = true):\n" + "{\n" + " \"streamid\" : \"string\", (string) the name of the stream.\n" + " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" + " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" + " \"data\" : \"xxxx\", (string) A hex string containing all the data chunks in this block.\n" + "}\n" "\nResult (for verbose=false):\n" - "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" - "\nExamples:\n" - + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + " \"streamid\" : \"string\", (string) the name of the stream.\n" + " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" + " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" + + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 false\"") + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + HelpExampleCli("getblock", "12800") - + HelpExampleRpc("getblock", "12800") + + HelpExampleRpc("getblock", "12800 false") ); LOCK(cs_main); std::string strHash = params[0].get_str(); - + bool fVerbose = true; if (params.size() > 1) { - std::string getdata = params[1].get_str(); - printf("%s\n",getdata.c_str()); + std::string verboseflag = params[1].get_str(); + if ( verboseflag.compare("false") ) + fVerbose = false; } // If height is supplied, find the hash @@ -382,10 +394,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { - printf("seqid.%d lastseqid.%d\n",seqid,lastseqid); result.push_back(Pair("error","chunck out of order in this block!")); - result.push_back(Pair("lastvalidseqid", (int)seqid)); - //break; + result.push_back(Pair("lastvalidseqid", (int)lastseqid)); + break; } if ( did1 == 0 ) { firstseqid = seqid; @@ -412,9 +423,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - //if (fVerbose) { - // result.push_back(Pair("data", blockdata)); - //} + if (fVerbose) { + result.push_back(Pair("data", blockdata)); + } } else { result.push_back(Pair("error","there is no data in this block.")); } From abddda8830bf5f4df0b09f95d6b3f66b4ca6d295 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:54:50 +0800 Subject: [PATCH 0332/3904] try --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 5309b9536..31b629ac3 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -316,7 +316,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) bool fVerbose = true; if (params.size() > 1) { std::string verboseflag = params[1].get_str(); - if ( verboseflag.compare("false") ) + if ( verboseflag.compare("false") == 1 ) fVerbose = false; } From 71ee7345e5b5a03e8b03a2272d61f31e2eb9c52f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:58:22 +0800 Subject: [PATCH 0333/3904] try again --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 31b629ac3..6badd753e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -316,7 +316,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) bool fVerbose = true; if (params.size() > 1) { std::string verboseflag = params[1].get_str(); - if ( verboseflag.compare("false") == 1 ) + if ( verboseflag == "false" ) fVerbose = false; } From ce5bf4b0811a0fe15848022d4d6a0ffb3deaac9b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:59:02 +0800 Subject: [PATCH 0334/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 6badd753e..0c19bcc20 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -423,7 +423,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose) { + if (fVerbose == true) { result.push_back(Pair("data", blockdata)); } } else { From 900f9fc8ec43a0bef74fd5d0d8423b7cc972c9cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:08:39 +0800 Subject: [PATCH 0335/3904] try to print block hash --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0c19bcc20..1edd2152c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -415,6 +415,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); + printf("block hash: %s\n",hash.ToString().c_str()); } } std::string decodedstreamid; From 8cec48894b7c16b6761a270b6d265839eb8cf2fd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:39:17 +0800 Subject: [PATCH 0336/3904] more error checks --- src/rpcblockchain.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 1edd2152c..f2387a691 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -361,17 +361,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) int lastseqid = 0; int i = 0; int did1 = 0; + int skippedtxs = 0; + int failed = 0; static std::string streamid,firsttxid; + static int firsttxnHeight; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this - if ( block.vtx.size() > 2 ) { + if ( block.vtx.size() > 2 ) + { BOOST_FOREACH(const CTransaction&tx, block.vtx) { // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { fprintf(stderr, "skipped tx number: %d\n",i); + skippedtxs = skippedtxs + 1; } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); // scriptPubKey is longer than 81, should mean its an OP_RETURN. @@ -389,6 +394,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid = idstr; } else if (firsttxid.empty()) { firsttxid.append(idstr); + } else if ( firsttxid != idstr ) { + printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); } if ( seqid == (lastseqid + 1) || did1 == 0 ) { @@ -403,6 +410,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) did1 = 1; } lastseqid = seqid; + } else { + skippedtxs = skippedtxs + 1; + fprintf(stderr, "skipped tx number: %d\n",i); } // function here to extract seqid from first and last TX // we an push the data or not depending on input from RPC. @@ -415,7 +425,14 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); - printf("block hash: %s\n",hash.ToString().c_str()); + BlockMap::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + if (chainActive.Contains(pindex)) { + firsttxnHeight = pindex->nHeight; + printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); + } + } } } std::string decodedstreamid; @@ -428,6 +445,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("data", blockdata)); } } else { + failed = 1; + } + + if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); } return result; From 2b21b2e94d534915227f58c22e2d24585ffcea40 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:44:01 +0800 Subject: [PATCH 0337/3904] fix --- src/rpcblockchain.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f2387a691..bbd5b6d56 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -435,21 +435,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } } - std::string decodedstreamid; - hex2ascii(streamid, decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid.c_str())); - result.push_back(Pair("firsttxid", firsttxid)); - result.push_back(Pair("firstseqid", (int)firstseqid)); - result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose == true) { - result.push_back(Pair("data", blockdata)); - } } else { failed = 1; } if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); + } else { + std::string decodedstreamid; + hex2ascii(streamid, decodedstreamid); + result.push_back(Pair("streamid", decodedstreamid.c_str())); + result.push_back(Pair("firsttxid", firsttxid)); + result.push_back(Pair("firstseqid", (int)firstseqid)); + result.push_back(Pair("lastseqid", (int)lastseqid)); + if (fVerbose == true) { + result.push_back(Pair("data", blockdata)); + } } return result; } From 56afde8d171868f0892b25cf0f2427498bb07724 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:52:38 +0800 Subject: [PATCH 0338/3904] move block print --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index bbd5b6d56..94e140aa5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -430,7 +430,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) CBlockIndex* pindex = (*mi).second; if (chainActive.Contains(pindex)) { firsttxnHeight = pindex->nHeight; - printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); } } } @@ -442,6 +441,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); } else { + printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); From d647a00ba762de93ed5f7b63ac37fe009aa1be2b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:59:24 +0800 Subject: [PATCH 0339/3904] ready for a new chain --- src/rpcblockchain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 94e140aa5..a29464201 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -295,6 +295,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) "{\n" " \"streamid\" : \"string\", (string) the name of the stream.\n" " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" " \"data\" : \"xxxx\", (string) A hex string containing all the data chunks in this block.\n" @@ -302,6 +303,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) "\nResult (for verbose=false):\n" " \"streamid\" : \"string\", (string) the name of the stream.\n" " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 false\"") @@ -446,6 +448,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); result.push_back(Pair("firsttxid", firsttxid)); + result.push_back(Pair("firstblockheight", (int)firsttxnHeight)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); if (fVerbose == true) { From 8c0de51c083f0b222340d2fb4c8a5d144dbcdb56 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 17:00:35 +0800 Subject: [PATCH 0340/3904] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a29464201..0bbba22a8 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -397,7 +397,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if (firsttxid.empty()) { firsttxid.append(idstr); } else if ( firsttxid != idstr ) { - printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); + printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n we are in a new stream here I think\n",firsttxid.c_str(),idstr.c_str()); } if ( seqid == (lastseqid + 1) || did1 == 0 ) { From c3a4829ba563f633ebbb72b2deb2e87ca98473ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 17:46:09 +0800 Subject: [PATCH 0341/3904] try fix for calling getdata out of order --- src/rpcblockchain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0bbba22a8..6aa8ab384 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -398,6 +398,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } else if ( firsttxid != idstr ) { printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n we are in a new stream here I think\n",firsttxid.c_str(),idstr.c_str()); + firsttxid.clear(); + firsttxid.append(idstr); + streamid.clear(); } if ( seqid == (lastseqid + 1) || did1 == 0 ) { From 9fbf73b63255c68d80652354f25a9e73afff0856 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 26 Oct 2018 01:08:26 +0200 Subject: [PATCH 0342/3904] comment out spamming addoracleeinputs print --- src/cc/oracles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 5a352afeb..1cd3be0d0 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -666,7 +666,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); + //fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 7700741e46a3197ef252defbd3d7954d94ff131b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 26 Oct 2018 23:08:26 +0800 Subject: [PATCH 0343/3904] try? --- src/rpcblockchain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 6aa8ab384..f52b3ac7c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -401,12 +401,13 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.clear(); firsttxid.append(idstr); streamid.clear(); + firsttxnHeight = 0; } if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { - result.push_back(Pair("error","chunck out of order in this block!")); + result.push_back(Pair("error","chunck out of order or missing in this block!")); result.push_back(Pair("lastvalidseqid", (int)lastseqid)); break; } From 8c552c067ccbd88c682eaaa21c3e76694e1f3c09 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 26 Oct 2018 23:23:49 +0800 Subject: [PATCH 0344/3904] debug --- src/rpcblockchain.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f52b3ac7c..ab9985b44 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -397,7 +397,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if (firsttxid.empty()) { firsttxid.append(idstr); } else if ( firsttxid != idstr ) { - printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n we are in a new stream here I think\n",firsttxid.c_str(),idstr.c_str()); + printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); firsttxid.clear(); firsttxid.append(idstr); streamid.clear(); @@ -430,10 +430,12 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); + printf("first stream id changed to: %s\n", firststreamid.c_str()); streamid.append(firststreamid.substr (8,64)); BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { CBlockIndex* pindex = (*mi).second; + printf("found block height: %d\n",pindex->nHeight); if (chainActive.Contains(pindex)) { firsttxnHeight = pindex->nHeight; } @@ -447,7 +449,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); } else { - printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); From db0fa8d71cacf5ded3d1f137e3f19b5377cdf50f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 26 Oct 2018 23:41:49 +0800 Subject: [PATCH 0345/3904] try? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index ab9985b44..e1877d058 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -430,8 +430,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - printf("first stream id changed to: %s\n", firststreamid.c_str()); streamid.append(firststreamid.substr (8,64)); + printf("first stream id changed to: %s\n", streamid.c_str()); BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { CBlockIndex* pindex = (*mi).second; From b1727e55cb667e6291331537cb35278cbc4a9232 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:01:24 +0800 Subject: [PATCH 0346/3904] try --- src/rpcblockchain.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e1877d058..0b6bfc713 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -432,12 +432,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); printf("first stream id changed to: %s\n", streamid.c_str()); - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - printf("found block height: %d\n",pindex->nHeight); - if (chainActive.Contains(pindex)) { - firsttxnHeight = pindex->nHeight; + if ( firstdeqid == 1 ) { + firsttxnHeight == block.nHeight; + } else { + BlockMap::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + printf("found block height: %d\n",pindex->nHeight); + if (chainActive.Contains(pindex)) { + firsttxnHeight = pindex->nHeight; + } } } } From 5e786e2e4cf3919ca6dfaaaa0f1f52022a3bdcbf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:07:45 +0800 Subject: [PATCH 0347/3904] fix --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0b6bfc713..e0597a541 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -432,8 +432,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); printf("first stream id changed to: %s\n", streamid.c_str()); - if ( firstdeqid == 1 ) { - firsttxnHeight == block.nHeight; + if ( firstseqid == 1 ) { + firsttxnHeight == pblockindex->nHeight; } else { BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { From fd8fe7b404768508463745b6606fc54b3b01c60e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:13:26 +0800 Subject: [PATCH 0348/3904] try --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e0597a541..e383a87f7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -434,6 +434,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) printf("first stream id changed to: %s\n", streamid.c_str()); if ( firstseqid == 1 ) { firsttxnHeight == pblockindex->nHeight; + printf("first seq id is 1 and found height: %d\n",firsttxnHeight ); } else { BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { From baa6c490848933b036e5fcb89569807b66010f46 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:29:21 +0800 Subject: [PATCH 0349/3904] try this --- src/rpcblockchain.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e383a87f7..53971e782 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -365,6 +365,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) int did1 = 0; int skippedtxs = 0; int failed = 0; + int getfirstblock = 0; static std::string streamid,firsttxid; static int firsttxnHeight; std::string blockdata; @@ -392,6 +393,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; if ( seqid == 1 ) { streamid = idstr; + getfirstblock = 1; } else if ( seqid == 2 ) { firsttxid = idstr; } else if (firsttxid.empty()) { @@ -403,7 +405,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) streamid.clear(); firsttxnHeight = 0; } - if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { @@ -425,24 +426,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - if (streamid.empty()) { + if (streamid.empty() || getfirstblock == 1) { + if ( lastseqid == 1) { + firsttxid = block.vtx[1].GetHash().GetHex(); + } uint256 hash; CTransaction firsttx; uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); printf("first stream id changed to: %s\n", streamid.c_str()); - if ( firstseqid == 1 ) { - firsttxnHeight == pblockindex->nHeight; - printf("first seq id is 1 and found height: %d\n",firsttxnHeight ); - } else { - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - printf("found block height: %d\n",pindex->nHeight); - if (chainActive.Contains(pindex)) { - firsttxnHeight = pindex->nHeight; - } + BlockMap::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + printf("found block height: %d\n",pindex->nHeight); + if (chainActive.Contains(pindex)) { + firsttxnHeight = pindex->nHeight; } } } From 99196bfb15664b1db67731259aee4d8ab4fb2432 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:35:18 +0800 Subject: [PATCH 0350/3904] fix --- src/rpcblockchain.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 53971e782..07cf53ad2 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -433,8 +433,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 hash; CTransaction firsttx; uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { - std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - streamid.append(firststreamid.substr (8,64)); + if ( streamid.empty() ) { + std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); + streamid.append(firststreamid.substr (8,64)); + } printf("first stream id changed to: %s\n", streamid.c_str()); BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { From 8d50000c49a41820b09a697a88b9814c68699aa3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 01:34:24 +0800 Subject: [PATCH 0351/3904] try send in chunks --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 07cf53ad2..0a00a614c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -382,7 +382,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) skippedtxs = skippedtxs + 1; } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); - // scriptPubKey is longer than 81, should mean its an OP_RETURN. + // scriptPubKey is longer than 81, should mean its an OP_RETURN, maybe also check vout == 0 ? if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID From 577cdc7da84b59aacdefdba9fef62d64e0e9a35f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 04:36:20 +0800 Subject: [PATCH 0352/3904] add num entropy to diceinfo ? --- src/cc/dice.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4271186da..95013944c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -655,7 +655,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int64_t *entropytxs) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0; uint8_t funcid; std::vector > unspentOutputs; @@ -734,6 +734,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); + entropytxs = n; return(totalinputs); } @@ -826,7 +827,9 @@ UniValue DiceInfo(uint256 diceid) result.push_back(Pair("timeoutblocks",timeoutblocks)); cp = CCinit(&C,EVAL_DICE); dicepk = GetUnspendable(cp,0); - funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid); + int64_t entropytxs = 0; + funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid,entropytxs); + result.push_back(Pair("entropytxs",entropytxs)); sprintf(numstr,"%.8f",(double)funding/COIN); result.push_back(Pair("funding",numstr)); return(result); From 3c4a0b4f4d558f7684fcc75cce54693d6adadcb2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:16:59 +0800 Subject: [PATCH 0353/3904] fix --- src/cc/dice.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 95013944c..d92a1711d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -655,7 +655,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int64_t *entropytxs) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int32_t *entropytxs) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0; uint8_t funcid; std::vector > unspentOutputs; @@ -827,7 +827,7 @@ UniValue DiceInfo(uint256 diceid) result.push_back(Pair("timeoutblocks",timeoutblocks)); cp = CCinit(&C,EVAL_DICE); dicepk = GetUnspendable(cp,0); - int64_t entropytxs = 0; + int32_t entropytxs = 0; funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid,entropytxs); result.push_back(Pair("entropytxs",entropytxs)); sprintf(numstr,"%.8f",(double)funding/COIN); @@ -958,7 +958,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid)) >= 2*bet*odds+txfee && entropyval != 0 ) + int32_t entropytxs; + if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs)) >= 2*bet*odds+txfee && entropyval != 0 ) { if ( myIsutxo_spentinmempool(entropytxid,0) != 0 ) { From 5ff09e4e1a72b2ff6a89a56959af5180313216e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:18:47 +0800 Subject: [PATCH 0354/3904] try --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index d92a1711d..1e5446486 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -734,7 +734,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); - entropytxs = n; + *entropytxs = n; return(totalinputs); } From d99b91584c2a681a292c7226db0d8f6493b2dd5d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:22:11 +0800 Subject: [PATCH 0355/3904] fix --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 1e5446486..6fafaa1fd 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -655,7 +655,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int32_t *entropytxs) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int32_t &entropytxs) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0; uint8_t funcid; std::vector > unspentOutputs; From dc28cc1a8530096dc3d922ad49ee90f5881c9151 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:23:54 +0800 Subject: [PATCH 0356/3904] fix --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 6fafaa1fd..c90ec0f06 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -734,7 +734,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); - *entropytxs = n; + entropytxs = n; return(totalinputs); } From 26623a35919323754b9862b34ef3904a6e6c5f86 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 30 Oct 2018 22:43:33 +0800 Subject: [PATCH 0357/3904] remove dupe --- src/rpcserver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index e8df01c53..653c786fe 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,7 +264,6 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "stop", &stop, true }, - { "control", "setpubkey", &setpubkey, true }, /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true }, From 53b0665f84928a97aa3f422ac27ff48bc015cb8e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 12:08:17 +0800 Subject: [PATCH 0358/3904] start of commit --- src/komodo_globals.h | 4 ++-- src/komodo_utils.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c456d3e44..569e29a5a 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; @@ -55,7 +55,7 @@ uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; +uint64_t ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index aedb6d3c2..445841596 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1561,7 +1561,10 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = GetArg("-ac_decay",0); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); + ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_freward",0); + ASSETCHAINS_OVERRIDE_ADDRESS = GetArg("-ac_address",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); + if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); exit(0); @@ -1595,8 +1598,8 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 0; printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } else if ( ASSETCHAINS_STREAM != 0) { - ASSETCHAINS_STREAM = 0; - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); + exit(0); } if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { ASSETCHAINS_SUPPLY = 1000000; From e0235aa0367d000f37f10395a3bb9f58d4e590f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 12:20:06 +0800 Subject: [PATCH 0359/3904] Revert "Merge branch 'momom_printsonly' into master" This reverts commit e4e1c3874ee5e060d361489d2d75787cb093d623, reversing changes made to 9fbf73b63255c68d80652354f25a9e73afff0856. revert this stupid commit git made by accident! --- src/cc/import.cpp | 6 +----- src/crosschain.cpp | 6 +----- src/komodo.h | 34 +++++++++++++++++----------------- src/komodo_bitcoind.h | 17 ++++++++--------- src/notarisationdb.cpp | 8 ++++---- 5 files changed, 31 insertions(+), 40 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index b72124735..cc0c3b61f 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,11 +79,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - fprintf(stderr,"IMPORT momom: %s\n", momom.GetHex().data()); - FILE * fptr; - fptr = fopen("/home/cc/kmdmomom", "a+"); - fprintf(fptr, "%s\n", momom.GetHex().data()); - fclose(fptr); + printf("IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 137e823ab..23416c682 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,11 +162,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); - FILE * fptr; - fptr = fopen("/home/cc/acmomom", "a+"); - fprintf(fptr, "%s\n", MoMoM.GetHex().data()); - fclose(fptr); + printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); // Find index of source MoM in MoMoM int nIndex; diff --git a/src/komodo.h b/src/komodo.h index 1846fd25c..fb40c1e09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -620,8 +620,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr notarized = 1; if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 ) notarized = 1; - //if ( 0 && opretlen != 149 ) - // printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); + if ( 0 && opretlen != 149 ) + printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash); len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); if ( matched != 0 ) @@ -685,8 +685,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - //if ( matched != 0 ) - // printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); + if ( matched != 0 ) + printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); @@ -706,8 +706,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->MoMdepth = MoMdepth; } komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - // printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -733,8 +733,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } } } - } //else if ( opretlen != 149 && height > 600000 && matched != 0 ) - //printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); + } else if ( opretlen != 149 && height > 600000 && matched != 0 ) + printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - //printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); + printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); @@ -856,7 +856,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("%02x",scriptPubKey[k]); printf(" scriptPubKey doesnt match any notary vini.%d of %d\n",j,numvins); } - } //else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); + } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || @@ -880,7 +880,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - //printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; } @@ -917,20 +917,20 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { for (k=0; k 2 ) { @@ -959,8 +959,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); - //printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); - } //else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); + printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); + } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); } } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ebc6b0c7f..86ed8f7b3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -169,7 +169,7 @@ try_again: curl_handle = curl_easy_init(); init_string(&s); headers = curl_slist_append(0,"Expect:"); - + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); @@ -198,7 +198,7 @@ try_again: bracket0 = (char *)"["; bracket1 = (char *)"]"; } - + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); @@ -238,7 +238,7 @@ try_again: free(s.ptr); sleep((1<= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ @@ -1336,7 +1336,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); else bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) - if ( ASSETCHAINS_STAKED < 100 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1443,7 +1442,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( isPoS != 2 ) { - //fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); + fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); isPoS = 0; } else @@ -1451,7 +1450,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) { - //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); + fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; } } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index df17de2c7..68c00546b 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -41,10 +41,10 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int staked_era = STAKED_era(timestamp); - //printf("ERA.(%d) \n",staked_era); + printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization - //printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); + printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; } else { // pass era slection off to notaries_staked.cpp file @@ -52,12 +52,12 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } if (!CheckTxAuthority(tx, auth_STAKED)) continue; - //printf("Authorised notarisation data for %s \n",data.symbol); + printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - //printf("Added notarisation data for %s \n",data.symbol); + printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); From de707f9e1fd68602e75662a99fc5c6a30639a593 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 14:49:21 +0800 Subject: [PATCH 0360/3904] add some prints --- src/crosschain.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 23416c682..5ad4d69ee 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -68,6 +68,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh destNotarisationTxid = nota.first; else if (seenOwnNotarisations == 2) goto end; + fprintf(stderr, "kmd heigt notarisation added: %d\n",kmdHeight-i); break; } } @@ -75,8 +76,9 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (seenOwnNotarisations == 1) { BOOST_FOREACH(Notarisation& nota, notarisations) { if (GetSymbolAuthority(nota.second.symbol) == authority) - if (nota.second.ccId == targetCCid) - moms.push_back(nota.second.MoM); + if (nota.second.ccId == targetCCid) { + moms.push_back(nota.second.MoM); + fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); } } } @@ -162,7 +164,11 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); + printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); + FILE * fptr; + fptr = fopen("/home/cc/momom_on_kmd", "a+"); + fprintf(fptr, "%s\n", MoMoM.GetHex().data()); + fclose(fptr); // Find index of source MoM in MoMoM int nIndex; From f0cb2e1187d920e2b99bdf94c635474190378c3e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 14:51:23 +0800 Subject: [PATCH 0361/3904] fix --- src/crosschain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 5ad4d69ee..37908f38e 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -79,6 +79,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (nota.second.ccId == targetCCid) { moms.push_back(nota.second.MoM); fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); + } } } } From f46d51c08f5fbb05532c78b13abf6eb601e04b77 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 15:16:06 +0800 Subject: [PATCH 0362/3904] fix? --- src/cc/import.cpp | 4 ++-- src/crosschain.cpp | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index cc0c3b61f..92e96fabb 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -78,8 +78,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp uint256 momom, target; if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - - printf("IMPORT momom: %s\n", momom.GetHex().data()); + + fprintf(stderr,"IMPORT momom: %s\nKMD TX HASH: %s\n", momom.GetHex().data(),proof.first.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 37908f38e..2e512806e 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -166,10 +166,6 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ throw std::runtime_error("No MoMs found"); printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); - FILE * fptr; - fptr = fopen("/home/cc/momom_on_kmd", "a+"); - fprintf(fptr, "%s\n", MoMoM.GetHex().data()); - fclose(fptr); // Find index of source MoM in MoMoM int nIndex; From d1e85c5128866355fe7e61832aee2754692991b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 1 Nov 2018 13:51:07 +0800 Subject: [PATCH 0363/3904] fix for notarisations in KMD more than 1 block. --- src/crosschain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 2e512806e..982f67d8b 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -69,7 +69,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh else if (seenOwnNotarisations == 2) goto end; fprintf(stderr, "kmd heigt notarisation added: %d\n",kmdHeight-i); - break; + //break; } } @@ -78,7 +78,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (GetSymbolAuthority(nota.second.symbol) == authority) if (nota.second.ccId == targetCCid) { moms.push_back(nota.second.MoM); - fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); + //fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); } } } From 40fca878a2f3018f354e778da8a03648c2949dbe Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Thu, 1 Nov 2018 07:13:43 +0100 Subject: [PATCH 0364/3904] Add CFEK exception for testnet chains --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e2170ba94..a803eeead 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -101,7 +101,7 @@ int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); int is_STAKED(const char *chain_name) { int STAKED = 0; - if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) + if ( (strncmp(chain_name, "CFEK", 4) == 0) || (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED); }; From a190053bda4132347b80f49029a82817c17ed5cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 1 Nov 2018 14:48:29 +0800 Subject: [PATCH 0365/3904] reset all eras to 2 years into future --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 526ad5f9b..10458d9ea 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537876325; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537983525; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1538083525; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1548083525; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1604212834; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 6055c2fe327f0d361ab20385b4f2d208b0d8dce9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 01:10:55 +0800 Subject: [PATCH 0366/3904] fix is_STAKED function --- src/notaries_staked.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a803eeead..5a544a2e8 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -101,8 +101,12 @@ int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); int is_STAKED(const char *chain_name) { int STAKED = 0; - if ( (strncmp(chain_name, "CFEK", 4) == 0) || (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) + if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; + else if ( (strcmp(chain_name, "STKD") == 0) || (strncmp(chain_name, "STKD", 4) == 0) ) + STAKED = 2; + else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + STAKED = 3; return(STAKED); }; From 427ff12734b6911843964278ba7e5e286ca89d91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 01:42:23 +0800 Subject: [PATCH 0367/3904] add print to is_STAKED --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 5a544a2e8..264f2060a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,6 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; + fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From 600f580dc5729efcb273d55120bfba8459602412 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:24:54 +0800 Subject: [PATCH 0368/3904] try --- src/notaries_staked.cpp | 2 +- src/wallet/wallet.cpp | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 264f2060a..966b41850 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 47c93545b..0565d9ae4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -180,7 +180,7 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey) bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector &vchCryptedSecret) { - + if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret)) return false; if (!fFileBacked) @@ -520,7 +520,7 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er } catch (const boost::filesystem::filesystem_error&) { // failure is ok (well, not really, but it's not worse than what we started with) } - + // try again if (!bitdb.Open(GetDataDir())) { // if it still fails, it probably means we can't even create the database env @@ -529,14 +529,14 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er return true; } } - + if (GetBoolArg("-salvagewallet", false)) { // Recover readable keypairs: if (!CWalletDB::Recover(bitdb, walletFile, true)) return false; } - + if (boost::filesystem::exists(GetDataDir() / walletFile)) { CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover); @@ -550,7 +550,7 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er if (r == CDBEnv::RECOVER_FAIL) errorString += _("wallet.dat corrupt, salvage failed"); } - + return true; } @@ -1202,6 +1202,13 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { + int64_t totalvoutvalue = 0; + for (size_t i = 0; i < tx.vout.size() ; i++) { + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + fprintf(stderr, "total: %ld \nvout %d = %ld", totalvoutvalue, i, tx.vout[i].nValue); + } + + //if ( IsFromMe(tx) && tx.vout[0].value ) { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; @@ -2296,7 +2303,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const int nDepth = pcoin->GetDepthInMainChain(); if (nDepth < 0) continue; - + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { isminetype mine = IsMine(pcoin->vout[i]); @@ -2642,7 +2649,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC CReserveKey reservekey(this); CWalletTx wtx; - + if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosRet, strFailReason, &coinControl, false)) return false; @@ -2708,7 +2715,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt txNew.nExpiryHeight = nextBlockHeight + expiryDelta; } } - + { LOCK2(cs_main, cs_wallet); { @@ -3194,7 +3201,7 @@ bool CWallet::SetDefaultKey(const CPubKey &vchPubKey) /** * Mark old keypool keys as used, - * and generate all new keys + * and generate all new keys */ bool CWallet::NewKeyPool() { @@ -3902,7 +3909,7 @@ void CWallet::GetFilteredNotes( if (ignoreUnspendable && !HaveSpendingKey(pa)) { continue; } - + // skip locked notes if (IsLockedNote(jsop.hash, jsop.js, jsop.n)) { continue; From 8616d8e5f773bd16a79013bc67376aaecf3c7cbc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:28:55 +0800 Subject: [PATCH 0369/3904] ld --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0565d9ae4..a518674de 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1205,7 +1205,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %d = %ld", totalvoutvalue, i, tx.vout[i].nValue); + fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); } //if ( IsFromMe(tx) && tx.vout[0].value ) From a5b17840a6b77338f083179f443accd78665048c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:40:58 +0800 Subject: [PATCH 0370/3904] fix --- src/wallet/wallet.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a518674de..b5fe66476 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,13 +1202,6 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { - int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vout.size() ; i++) { - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); - } - - //if ( IsFromMe(tx) && tx.vout[0].value ) { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; @@ -1216,6 +1209,12 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl auto noteData = FindMyNotes(tx); if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { + int64_t totalvoutvalue = 0; + for (size_t i = 0; i < tx.vout.size() ; i++) { + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + } + CWalletTx wtx(this,tx); if (noteData.size() > 0) { From 3bbb29e600b5c0a7891f83f5a970cccf76b33dfd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:56:20 +0800 Subject: [PATCH 0371/3904] try print back --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 966b41850..264f2060a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From a2cec89073a02a16700da10c8b0c118a59d1465a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:59:49 +0800 Subject: [PATCH 0372/3904] fix era --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 10458d9ea..fbb3506ba 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From c0fa673964ffdfb1101ab9f3bd364fcea7a96afd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:05:24 +0800 Subject: [PATCH 0373/3904] remove print --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 264f2060a..966b41850 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From 203e3004f848e9d81956ea467927a35d991b103e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:13:32 +0800 Subject: [PATCH 0374/3904] try --- src/wallet/wallet.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b5fe66476..311264419 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1207,14 +1207,23 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); - if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) + bool mine = IsMine(tx); + bool isent = IsFromMe(tx); + + if ( isent ) + fprintf(stderr, "I sent this tx ?\n"); + + if (mine) + fprintf(stderr, "I reveived it ? \n"); + + if (fExisted || mine || isent || noteData.size() > 0) { int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + fprintf(stderr, "total: %ld \nvout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); } - + CWalletTx wtx(this,tx); if (noteData.size() > 0) { From 287ddc4a6b220a605d9137abd652d00a5b118bd5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:37:38 +0800 Subject: [PATCH 0375/3904] try --- src/wallet/wallet.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 311264419..9f7ba37c6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,18 +1210,19 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl bool mine = IsMine(tx); bool isent = IsFromMe(tx); - if ( isent ) - fprintf(stderr, "I sent this tx ?\n"); - - if (mine) - fprintf(stderr, "I reveived it ? \n"); - if (fExisted || mine || isent || noteData.size() > 0) { int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); + if (IsChange(tx.vout[i])) { + fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); + } else { + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + + fprintf(stderr, "this is not change? total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + } + } CWalletTx wtx(this,tx); From 023ee98af06fe02dc612885b434bb0684e0030ee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:48:40 +0800 Subject: [PATCH 0376/3904] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9f7ba37c6..9269817c4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1219,8 +1219,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); } else { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - - fprintf(stderr, "this is not change? total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + + fprintf(stderr, "this is not change? vout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); } } From dbf49cd4d2c0d770711af73ae80fd886d8ebed49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:54:50 +0800 Subject: [PATCH 0377/3904] try --- src/wallet/wallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9269817c4..396f0d167 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1207,14 +1207,14 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); - bool mine = IsMine(tx); - bool isent = IsFromMe(tx); - if (fExisted || mine || isent || noteData.size() > 0) + if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + if ( IsMine(tx.vout[i].prevout) ) + fprintf(stderr, "prevout is mine? %s\n"); if (IsChange(tx.vout[i])) { fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); } else { From 0737f32e4d655c1c4748b224ef471281450b54c7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:07:32 +0800 Subject: [PATCH 0378/3904] try --- src/wallet/wallet.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 396f0d167..75d0a2d3e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,11 +1210,15 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { + + if ( IsMine(tx.vin[0].prevout) ) + fprintf(stderr, "prevout is mine? %s\n"); + + int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - if ( IsMine(tx.vout[i].prevout) ) - fprintf(stderr, "prevout is mine? %s\n"); + if (IsChange(tx.vout[i])) { fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); } else { From d83243962d41be4dc31d33cabed78caa88d101f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:10:39 +0800 Subject: [PATCH 0379/3904] a --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 75d0a2d3e..1b4395b9a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,7 +1211,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( IsMine(tx.vin[0].prevout) ) + if ( IsMine(tx) ) fprintf(stderr, "prevout is mine? %s\n"); From 08241004e190867981e1b6b7d02ae172ade02fa4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:23:48 +0800 Subject: [PATCH 0380/3904] try --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1b4395b9a..10a46c547 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,7 +1212,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( IsMine(tx) ) - fprintf(stderr, "prevout is mine? %s\n"); + fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash..ToString().c_str()]); int64_t totalvoutvalue = 0; From 43104ff55c4c584bdb532fda26288b498495a459 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:30:46 +0800 Subject: [PATCH 0381/3904] oo --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 10a46c547..4ecc12d9d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,7 +1212,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( IsMine(tx) ) - fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash..ToString().c_str()]); + fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash.ToString().c_str()); int64_t totalvoutvalue = 0; From 6ea2be525feb60a679d0ce241d4536ddc4fcfa69 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:44:34 +0800 Subject: [PATCH 0382/3904] oops --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4ecc12d9d..5b0b914ed 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1224,7 +1224,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } else { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "this is not change? vout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); + fprintf(stderr, "this is not change? vout %ld = %ld\n", i, tx.vout[i].nValue); } } From 0d9cf86b64a69c9b6b33ae8ce80910b80e0d8193 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:16:16 +0800 Subject: [PATCH 0383/3904] try --- src/wallet/wallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5b0b914ed..8b91e3c2a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,8 +1211,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( IsMine(tx) ) - fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash.ToString().c_str()); + CTransaction tx; + uint256 hashBlock; + GetTransaction(tx.vin[0].prevout.hash,tx,hashBlock,false) + + fprintf(stderr, "vin 1 script pubkey : %s\n",tx.vout[0].scriptPubKey); int64_t totalvoutvalue = 0; From 4bce36c1ade6f550a8c181ffc27208538b548f99 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:22:42 +0800 Subject: [PATCH 0384/3904] try --- src/wallet/wallet.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8b91e3c2a..096966452 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,12 +1211,18 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - CTransaction tx; + CTransaction txin; uint256 hashBlock; - GetTransaction(tx.vin[0].prevout.hash,tx,hashBlock,false) + GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); - fprintf(stderr, "vin 1 script pubkey : %s\n",tx.vout[0].scriptPubKey); + fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey); + CTxDestination address; + ExtractDestination(txin.vout[0].scriptPubKey, address) + + LOCK(cs_wallet); + if (!mapAddressBook.count(address)) + fprintf(stderr, "vin 0 address is in my wallet \n" ); int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { From 05b2d67fc4e439173e9d1456f3f507e49beef981 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:24:55 +0800 Subject: [PATCH 0385/3904] fix --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 096966452..335861e72 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1215,7 +1215,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl uint256 hashBlock; GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); - fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey); + fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); CTxDestination address; ExtractDestination(txin.vout[0].scriptPubKey, address) From db2460a381d0d1312462e63098983f4095048685 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:26:04 +0800 Subject: [PATCH 0386/3904] ; modified: src/wallet/wallet.cpp --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 335861e72..5b710a64c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1218,7 +1218,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); CTxDestination address; - ExtractDestination(txin.vout[0].scriptPubKey, address) + ExtractDestination(txin.vout[0].scriptPubKey, address); LOCK(cs_wallet); if (!mapAddressBook.count(address)) From 750f8351063034a30fa6a1ea2dfb2f17060c79c9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:29:36 +0800 Subject: [PATCH 0387/3904] try --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5b710a64c..afe2d8565 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1215,6 +1215,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl uint256 hashBlock; GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); + fprintf(stderr, "vin tx hash: %s\n", tx.vin[0].prevout.hash.ToString().c_str()); + fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); CTxDestination address; From aaab9bf85d304efec6cb49ec7af3d4c2df26a744 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:40:36 +0800 Subject: [PATCH 0388/3904] try this --- src/wallet/wallet.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index afe2d8565..65121caf8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,21 +1210,17 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - - CTransaction txin; - uint256 hashBlock; - GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); - - fprintf(stderr, "vin tx hash: %s\n", tx.vin[0].prevout.hash.ToString().c_str()); - - fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); - - CTxDestination address; - ExtractDestination(txin.vout[0].scriptPubKey, address); - - LOCK(cs_wallet); - if (!mapAddressBook.count(address)) - fprintf(stderr, "vin 0 address is in my wallet \n" ); + uint256 hash; CTransaction txin; + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + { + printf("CHECKING THE script pubkey\n"); + script = (uint8_t *)txin.vout[tx.vin[0].prevout.n].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,NOTARY_PUBKEY33,33) != 0 ) { + printf("vin 0 prevout is from some other kunt!\n"); + //return(-1); + } + printf("vin 0 prevvout is from our pubkey \n"); + } int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { From f8e62200d09478ea43a7dd12796ade80e0622800 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:42:30 +0800 Subject: [PATCH 0389/3904] delcare --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 65121caf8..f4b1ef2a8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,7 +1210,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - uint256 hash; CTransaction txin; + uint256 hash; CTransaction txin; uint8_t *script; if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { printf("CHECKING THE script pubkey\n"); From 151847b000ac63acf1fabbdb4dc25f2cf15ef509 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:44:30 +0800 Subject: [PATCH 0390/3904] fix --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f4b1ef2a8..b3d7ac2c0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1200,6 +1200,8 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * pblock is optional, but should be provided if the transaction is known to be in a block. * If fUpdate is true, existing transactions will be updated. */ +extern uint8_t NOTARY_PUBKEY33[33]; + bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { From 5fdb5772a80be2321c03ebf27dc102d4c0fef524 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:47:31 +0800 Subject: [PATCH 0391/3904] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b3d7ac2c0..ebad28293 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1220,8 +1220,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,NOTARY_PUBKEY33,33) != 0 ) { printf("vin 0 prevout is from some other kunt!\n"); //return(-1); - } - printf("vin 0 prevvout is from our pubkey \n"); + } else + printf("vin 0 prevvout is from our pubkey \n"); } int64_t totalvoutvalue = 0; From d21d7f6c798805aa521cc9a6ee2c6b8766268dcb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:10:19 +0800 Subject: [PATCH 0392/3904] try --- src/wallet/wallet.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ebad28293..fcb96dcab 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,16 +1212,13 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - uint256 hash; CTransaction txin; uint8_t *script; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + uint256 hash; CTransaction txin; CTxDestination address; + if (GetTransaction(tx.prevout.hash,txin,hash,false)) { - printf("CHECKING THE script pubkey\n"); - script = (uint8_t *)txin.vout[tx.vin[0].prevout.n].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,NOTARY_PUBKEY33,33) != 0 ) { - printf("vin 0 prevout is from some other kunt!\n"); - //return(-1); - } else - printf("vin 0 prevvout is from our pubkey \n"); + if (ExtractDestination(txin.vout[tx.prevout.n].scriptPubKey, address)) { + if (mapAddressBook.count(address)) + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); + } } int64_t totalvoutvalue = 0; From 580cea6efcad51799cf2487b75ce453a05897938 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:14:02 +0800 Subject: [PATCH 0393/3904] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fcb96dcab..697deff97 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,9 +1213,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.prevout.hash,txin,hash,false)) + if (GetTransaction(tx.vout[0].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.prevout.n].scriptPubKey, address)) { + if (ExtractDestination(txin.vout[tx.vout[0].prevout.n].scriptPubKey, address)) { if (mapAddressBook.count(address)) fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); } From 36957b0a7d9cb4491ac7a95def3138b31e2c2d22 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:17:09 +0800 Subject: [PATCH 0394/3904] fix vin --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 697deff97..0ca9a077d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,9 +1213,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vout[0].prevout.hash,txin,hash,false)) + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.vout[0].prevout.n].scriptPubKey, address)) { + if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { if (mapAddressBook.count(address)) fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); } From 496c0b2ac6396a3eb6c62b6737a4fc05f9416c52 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:18:39 +0800 Subject: [PATCH 0395/3904] fix --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0ca9a077d..0f2ab284e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1217,7 +1217,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { if (mapAddressBook.count(address)) - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } } From 0ea25a07b1bcd6727395d503199f07011468ea80 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:22:06 +0800 Subject: [PATCH 0396/3904] try --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0f2ab284e..6dcd9ecc2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1216,6 +1216,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); if (mapAddressBook.count(address)) fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } From 73c0dd2b2e9e8703ccd4941a252fa3d28baaa4b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:42:53 +0800 Subject: [PATCH 0397/3904] getting close --- src/wallet/wallet.cpp | 48 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6dcd9ecc2..388f0e47b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,29 +1212,35 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) - { - if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if (mapAddressBook.count(address)) - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - } + int numvinIsOurs, numvoutIsOurs; int64_t totalvoutvalue; + for (size_t i = 0; i < tx.vin.size(); i++) { + uint256 hash; CTransaction txin; CTxDestination address; + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + { + if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + if (!mapAddressBook.count(address)) { + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + numvinIsOurs++; + } + } + } } - - int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vout.size() ; i++) { - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - - if (IsChange(tx.vout[i])) { - fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); - } else { - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - - fprintf(stderr, "this is not change? vout %ld = %ld\n", i, tx.vout[i].nValue); - } - + if ( numvinIsOurs == 0 ) { + for (size_t i = 0; i < tx.vout.size() ; i++) { + CTxDestination address2; + if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { + if (!mapAddressBook.count(address2)) { + fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); + numvoutIsOurs++; + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + } + } + } + } else if ( numvinIsOurs < tx.vin.size() ) { + fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } + fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); CWalletTx wtx(this,tx); From b14b985d7d38d5d603ccad346e7589060982642b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:01:10 +0800 Subject: [PATCH 0398/3904] backwards --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 388f0e47b..95f36b801 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1230,7 +1230,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if (!mapAddressBook.count(address2)) { + if (mapAddressBook.count(address2)) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From 0ec91dd3a9e4ed7e757ac8d9a5a5f791a93c0242 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:23:56 +0800 Subject: [PATCH 0399/3904] try --- src/wallet/wallet.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 95f36b801..53d75c522 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,6 +1202,15 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; +bool RaddIsPubkey(char *address) { + char exaddress[18]; + pubkey2addr((char *)exaddress[i],(uint8_t *)NOTARY_PUBKEY33); + for (i=0; i<=17; i++) + if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) + return true; + return false +} + bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { @@ -1219,10 +1228,10 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if (!mapAddressBook.count(address)) { - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { numvinIsOurs++; - } + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + } } } } @@ -1230,7 +1239,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if (mapAddressBook.count(address2)) { + if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From e836e146a3f196b0e36a38395313a341c1c15c31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:25:22 +0800 Subject: [PATCH 0400/3904] fix --- src/wallet/wallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 53d75c522..77bc46304 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1205,9 +1205,8 @@ extern uint8_t NOTARY_PUBKEY33[33]; bool RaddIsPubkey(char *address) { char exaddress[18]; pubkey2addr((char *)exaddress[i],(uint8_t *)NOTARY_PUBKEY33); - for (i=0; i<=17; i++) - if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) - return true; + if ( strcmp(coinaddr,exaddress) == 0 ) + return true; return false } From dd18452d2096335d05cb3c0e8aa415b1a3fe50d3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:27:19 +0800 Subject: [PATCH 0401/3904] fix? --- src/wallet/wallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 77bc46304..fc60c4bf0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,10 +1201,11 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool RaddIsPubkey(char *address) { char exaddress[18]; - pubkey2addr((char *)exaddress[i],(uint8_t *)NOTARY_PUBKEY33); + pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); if ( strcmp(coinaddr,exaddress) == 0 ) return true; return false From 958095444dfa50662fe13634293e1539ae2cf6ab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:28:43 +0800 Subject: [PATCH 0402/3904] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fc60c4bf0..e8c0af281 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1206,7 +1206,7 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool RaddIsPubkey(char *address) { char exaddress[18]; pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); - if ( strcmp(coinaddr,exaddress) == 0 ) + if ( strcmp(address,exaddress) == 0 ) return true; return false } @@ -1239,7 +1239,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { + if ( RaddIsPubkey(CBitcoinAddress(address2).ToString().c_str()) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From f699248ef187624a223ba69c7304f2e1932030e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:29:29 +0800 Subject: [PATCH 0403/3904] ; --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e8c0af281..ea892d2ba 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1208,7 +1208,7 @@ bool RaddIsPubkey(char *address) { pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); if ( strcmp(address,exaddress) == 0 ) return true; - return false + return false; } bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) From 2d82fd3f29825265ee38ac6dd74c606ee6caded2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:30:49 +0800 Subject: [PATCH 0404/3904] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ea892d2ba..538eb3d54 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1228,7 +1228,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { + if ( RaddIsPubkey((char *)CBitcoinAddress(address).ToString().c_str()) == true ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1239,7 +1239,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( RaddIsPubkey(CBitcoinAddress(address2).ToString().c_str()) == true ) { + if ( RaddIsPubkey((char *)CBitcoinAddress(address2).ToString().c_str()) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From 18b9025ffc566a1debb263e8a08772bfe4bbb6d6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:38:45 +0800 Subject: [PATCH 0405/3904] try --- src/wallet/wallet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 538eb3d54..a6c4a8486 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,7 +1201,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +bool pubkey2addr(char destaddr,uint8_t *pubkey33); bool RaddIsPubkey(char *address) { char exaddress[18]; @@ -1228,7 +1228,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey((char *)CBitcoinAddress(address).ToString().c_str()) == true ) { + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + if ( RaddIsPubkey(chraddress) == true ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1239,7 +1240,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( RaddIsPubkey((char *)CBitcoinAddress(address2).ToString().c_str()) == true ) { + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + if ( RaddIsPubkey(chraddress) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From ea856ec7b3281b3ebd5a4e31a8e9dfd4c81087d7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:40:15 +0800 Subject: [PATCH 0406/3904] try --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a6c4a8486..59bbf3731 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1228,7 +1228,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); if ( RaddIsPubkey(chraddress) == true ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); @@ -1240,7 +1240,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); if ( RaddIsPubkey(chraddress) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; From 997c7844a57b200d83e302efa8ac76f1dc82ef29 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:52:39 +0800 Subject: [PATCH 0407/3904] try this --- src/komodo_globals.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- src/wallet/wallet.cpp | 15 +++------------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 33d269793..133743c52 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 56793f78b..d9255ce70 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4989,7 +4989,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; + extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -5002,7 +5002,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); + string currentAddress = address.ToString() = NOTARY_ADDRESS; result.push_back(Pair("address", currentAddress)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 59bbf3731..d2767fa1e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,16 +1201,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; +extern std::string NOTARY_ADDRESS; bool pubkey2addr(char destaddr,uint8_t *pubkey33); -bool RaddIsPubkey(char *address) { - char exaddress[18]; - pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); - if ( strcmp(address,exaddress) == 0 ) - return true; - return false; -} - bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { @@ -1228,8 +1221,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey(chraddress) == true ) { + if ( strcmp(CBitcoinAddress(address).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1240,8 +1232,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey(chraddress) == true ) { + if ( strcmp(CBitcoinAddress(address2).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From 4b044d68f0da67b361abdabd6aebb34357c9bb87 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:54:51 +0800 Subject: [PATCH 0408/3904] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d2767fa1e..085ee14ce 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1221,7 +1221,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if ( strcmp(CBitcoinAddress(address).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { + if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1232,7 +1232,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( strcmp(CBitcoinAddress(address2).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { + if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From cddd4eebf45b30f24e8427c5355da434a7e81000 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:57:52 +0800 Subject: [PATCH 0409/3904] oops --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d9255ce70..2d5644ced 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5002,7 +5002,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - string currentAddress = address.ToString() = NOTARY_ADDRESS; + string currentAddress = NOTARY_ADDRESS = address.ToString(); result.push_back(Pair("address", currentAddress)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; From 5ecc6857c45998901841653710ad5bfaff828295 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 11:07:52 +0800 Subject: [PATCH 0410/3904] try --- src/wallet/wallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 085ee14ce..f27046767 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1223,7 +1223,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + fprintf(stderr, "address on prev vin is in wallet: %s and numvins ours so far is: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); } } } @@ -1233,16 +1233,16 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { - fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS,numvoutIsOurs,totalvoutvalue); } } } } else if ( numvinIsOurs < tx.vin.size() ) { fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } - fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); + //fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); CWalletTx wtx(this,tx); From 588b53717cbe1861c0990387914b7529961a1195 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 11:14:16 +0800 Subject: [PATCH 0411/3904] poo --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f27046767..637b98448 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - int numvinIsOurs, numvoutIsOurs; int64_t totalvoutvalue; + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) @@ -1235,7 +1235,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS,numvoutIsOurs,totalvoutvalue); + fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS.c_str(),numvoutIsOurs,totalvoutvalue); } } } From de3bc9d0c2410ce9a4b2db43713dbec079ab04ef Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 11:33:44 +0800 Subject: [PATCH 0412/3904] fix --- src/wallet/wallet.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 637b98448..2e1664188 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1220,29 +1220,34 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { - //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + // This means we sent the tx.. if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; - fprintf(stderr, "address on prev vin is in wallet: %s and numvins ours so far is: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); } } } } + // No we know if it was a tx we sent, if it was all ours, we leave and let add to wallet. + fprintf(stderr, "address: %s sent vouts: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); if ( numvinIsOurs == 0 ) { for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { + // this should be a received tx.. numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS.c_str(),numvoutIsOurs,totalvoutvalue); } } } + fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); + // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. + + } else if ( numvinIsOurs < tx.vin.size() ) { + // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and nothing else. fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } - //fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); CWalletTx wtx(this,tx); From b9316f3b8d1e2ec6f8f16b484733d72cd3ad811a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 12:22:00 +0800 Subject: [PATCH 0413/3904] looking good --- src/wallet/wallet.cpp | 68 ++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2e1664188..5a0014ed4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,39 +1214,47 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vin.size(); i++) { - uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) - { - if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { - // This means we sent the tx.. - if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { - numvinIsOurs++; - } - } - } - } - // No we know if it was a tx we sent, if it was all ours, we leave and let add to wallet. - fprintf(stderr, "address: %s sent vouts: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); - if ( numvinIsOurs == 0 ) { - for (size_t i = 0; i < tx.vout.size() ; i++) { - CTxDestination address2; - if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { - // this should be a received tx.. - numvoutIsOurs++; - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - } + if ( NOTARY_ADDRESS != "" ) + { + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; + for (size_t i = 0; i < tx.vin.size(); i++) { + uint256 hash; CTransaction txin; CTxDestination address; + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + { + if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + // This means we sent the tx.. + if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { + numvinIsOurs++; + } + } } } - fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); - // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. + // Now we know if it was a tx we sent, if it was all ours, we leave and let add to wallet. + fprintf(stderr, "address: %s sent vouts: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); + if ( numvinIsOurs == 0 ) { + for (size_t i = 0; i < tx.vout.size() ; i++) { + CTxDestination address2; + if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { + if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { + // this should be a received tx.. + numvoutIsOurs++; + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + } + } + } + fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); + // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. + int64_t avgVoutSize = totalvoutvalue \ numvoutIsOurs; + if ( avgVoutSize < 100000000 ) { + // average vout size is less than 1 coin, we will ignore it + fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); + return false; + } - - } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and nothing else. - fprintf(stderr, "There are vins that are not ours, notarisation?\n"); + } else if ( numvinIsOurs < tx.vin.size() ) { + // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and do nothing else. + fprintf(stderr, "There are vins that are not ours, notarisation?\n"); + } } CWalletTx wtx(this,tx); From 8649c79024f321e96393af9f2bcebc312b54f6d9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 12:23:01 +0800 Subject: [PATCH 0414/3904] / --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5a0014ed4..6731d40f0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1244,7 +1244,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. - int64_t avgVoutSize = totalvoutvalue \ numvoutIsOurs; + int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; if ( avgVoutSize < 100000000 ) { // average vout size is less than 1 coin, we will ignore it fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); From c800e8f376240d343c664d40f48281840471800b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:27:27 +0800 Subject: [PATCH 0415/3904] try add Raddress for -pubkey --- src/komodo_utils.h | 6 +++++- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ef33bd56b..4153aebca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1485,6 +1485,10 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; + char Raddress[18]; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + //CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = Raddress.ToString(); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } @@ -1564,7 +1568,7 @@ void komodo_args(char *argv0) ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_freward",0); ASSETCHAINS_OVERRIDE_ADDRESS = GetArg("-ac_address",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - + if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); exit(0); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2d5644ced..862df0c0f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5002,8 +5002,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - string currentAddress = NOTARY_ADDRESS = address.ToString(); - result.push_back(Pair("address", currentAddress)); + NOTARY_ADDRESS = address.ToString(); + result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From 0e848a2fd44847951f1439a209b41141223031eb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:30:58 +0800 Subject: [PATCH 0416/3904] nopiie --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4153aebca..f10f4e1c1 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1487,8 +1487,8 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) pubkeystr[66] = 0; char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - //CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = Raddress.ToString(); + CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = address.ToString(); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From 2e750b76da4204d6b50b24ff5196e84389f1c83d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:33:31 +0800 Subject: [PATCH 0417/3904] try --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f10f4e1c1..1cede9279 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1487,8 +1487,8 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) pubkeystr[66] = 0; char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = address.ToString(); + //CBitcoinAddress address(Raddress); + NOTARY_ADDRESS.assign(Raddress); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From b71d83e7b01db09f5f58168f41574da7de4e8169 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:34:36 +0800 Subject: [PATCH 0418/3904] fix --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1cede9279..c484accc5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1478,6 +1478,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From b74d98e6bb6afcd5a23fe4213e4fd2ad463ba47d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:36:58 +0800 Subject: [PATCH 0419/3904] fix --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c484accc5..6d9777b73 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1478,7 +1478,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +extern bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From 2ff5d746dc2f7f318c70b46236177ba9d1576040 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:41:56 +0800 Subject: [PATCH 0420/3904] :S --- src/komodo_utils.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6d9777b73..2dcdd215d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,6 +13,7 @@ * * ******************************************************************************/ #include "komodo_defs.h" +#include "komodo_globals.h" #ifdef _WIN32 #include @@ -1478,8 +1479,6 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -extern bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; From 97c7042ce83548aaec91ccc23897532fb3d3641e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:45:36 +0800 Subject: [PATCH 0421/3904] fix --- src/komodo_utils.h | 3 ++- src/wallet/wallet.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2dcdd215d..c734e7add 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,7 +13,6 @@ * * ******************************************************************************/ #include "komodo_defs.h" -#include "komodo_globals.h" #ifdef _WIN32 #include @@ -1479,6 +1478,8 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +bool pubkey2addr(char destaddr,uint8_t *pubkey33); + int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6731d40f0..a8d287bac 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,7 +1202,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -bool pubkey2addr(char destaddr,uint8_t *pubkey33); + bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { From 387466a273c0848131ccdda31f88da300b31d0b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:48:31 +0800 Subject: [PATCH 0422/3904] try --- src/cc/utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/utils.h b/src/cc/utils.h index f0b91962d..8762cbaf1 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -23,6 +23,7 @@ /* * Serialisation boilerplate */ +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); template std::vector SerializeF(const T f) From c6976b687703a9a9c1f8c3f50aa80ac9a76eedea Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:03:02 +0800 Subject: [PATCH 0423/3904] try --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c734e7add..c484accc5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1478,7 +1478,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char destaddr,uint8_t *pubkey33); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From 0f9b4c1d8107f67ee3066602ee7ef5f629856c5f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:11:35 +0800 Subject: [PATCH 0424/3904] try --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c484accc5..c774dba9b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,6 +13,8 @@ * * ******************************************************************************/ #include "komodo_defs.h" +#include "cc/utils.h" +#include "cc/CCutils.cpp" #ifdef _WIN32 #include @@ -1478,8 +1480,6 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; From 5d64fdd67d4ef40053ae5c807884f172cf339fc9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:18:11 +0800 Subject: [PATCH 0425/3904] try again --- src/komodo_utils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c774dba9b..02f226028 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -14,7 +14,6 @@ ******************************************************************************/ #include "komodo_defs.h" #include "cc/utils.h" -#include "cc/CCutils.cpp" #ifdef _WIN32 #include From 3c612cfc9e31c24ee2b2038c93806c4ba4f43325 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:19:47 +0800 Subject: [PATCH 0426/3904] try --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 6164cf463..19aa87fe4 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,6 +9,7 @@ #include "rpcprotocol.h" #include "util.h" #include "utilstrencodings.h" +#include "cc/utils.h" #include #include From 3b8bc700b3dcfe2877c7b56668fe39651025a5ec Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:22:51 +0800 Subject: [PATCH 0427/3904] try --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 19aa87fe4..ebf8d5660 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,7 +9,7 @@ #include "rpcprotocol.h" #include "util.h" #include "utilstrencodings.h" -#include "cc/utils.h" +#include "cc/CCutils.cpp" #include #include From f32a8a151e520a756b092aa6bfb4bbd0a2886fd7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:24:05 +0800 Subject: [PATCH 0428/3904] try again --- src/bitcoin-cli.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index ebf8d5660..d70638d89 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,7 +9,7 @@ #include "rpcprotocol.h" #include "util.h" #include "utilstrencodings.h" -#include "cc/CCutils.cpp" + #include #include @@ -24,6 +24,7 @@ using namespace std; int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t komodo_maxallowed(int32_t baseid) { return(100000000LL * 1000000); } // stub +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900; From 9da9b21de773e0e2cba8c5b0484b34cea18edebd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:27:55 +0800 Subject: [PATCH 0429/3904] try again --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index d70638d89..ea72bbc14 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -24,7 +24,6 @@ using namespace std; int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t komodo_maxallowed(int32_t baseid) { return(100000000LL * 1000000); } // stub -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900; @@ -78,6 +77,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From 3a20421a0553816abcd4172a4aead07576d14c57 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:30:26 +0800 Subject: [PATCH 0430/3904] again --- src/cc/CCinclude.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 8be4bce29..ab320e58a 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -24,7 +24,7 @@ so you can pay to a pubkey, or to its hash. or to a script's hash. the last is h all of the above are the standard bitcoin vout types and there should be plenty of materials about it Encrypted by a verified device what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. - + but it gets more interesting each CC script has an evalcode this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different @@ -149,6 +149,7 @@ bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t n bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); std::vector Mypubkey(); bool Myprivkey(uint8_t myprivkey[]); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int64_t CCduration(int32_t &numblocks,uint256 txid); bool isCCTxNotarizedConfirmed(uint256 txid); // CCtx From c75cdae8c69a37e63e1d12a596f944477c3f7d66 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:33:52 +0800 Subject: [PATCH 0431/3904] oops --- src/bitcoin-cli.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index ea72bbc14..e44be663c 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,7 +77,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From 0da06744056072e82fe48ddbb84be680818548b8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:35:15 +0800 Subject: [PATCH 0432/3904] try --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e44be663c..f1b75fb42 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,6 +77,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From be4539034e5702a1e2d9a28d0da37219ab3d91a2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:38:23 +0800 Subject: [PATCH 0433/3904] try again --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f1b75fb42..527765094 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -70,7 +70,7 @@ public: #include "uint256.h" #include "arith_uint256.h" -#include "komodo_structs.h" +//#include "komodo_structs.h" #include "komodo_globals.h" #include "komodo_utils.h" From 9d44f850bf567646cd6412b114eb6979aa751572 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:59:26 +0800 Subject: [PATCH 0434/3904] try --- src/bitcoin-cli.cpp | 2 +- src/cc/utils.h | 1 - src/komodo_globals.h | 1 - src/wallet/wallet.cpp | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 527765094..f1b75fb42 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -70,7 +70,7 @@ public: #include "uint256.h" #include "arith_uint256.h" -//#include "komodo_structs.h" +#include "komodo_structs.h" #include "komodo_globals.h" #include "komodo_utils.h" diff --git a/src/cc/utils.h b/src/cc/utils.h index 8762cbaf1..f0b91962d 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -23,7 +23,6 @@ /* * Serialisation boilerplate */ -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); template std::vector SerializeF(const T f) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 133743c52..a09008824 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,7 +29,6 @@ uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); pthread_mutex_t komodo_mutex; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a8d287bac..4fea5dae7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1203,7 +1203,6 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; - bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { From af21a290f3743722374e3a8371b82443fd0f1dbe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:14:11 +0800 Subject: [PATCH 0435/3904] fix --- src/bitcoin-cli.cpp | 1 - src/main.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f1b75fb42..e44be663c 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,7 +77,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { diff --git a/src/main.cpp b/src/main.cpp index 91ec53faf..c7b0e0e9b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,7 @@ int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); void komodo_broadcast(CBlock *pblock,int32_t limit); void komodo_broadcast(CBlock *pblock,int32_t limit); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); BlockMap mapBlockIndex; CChain chainActive; From b61cf9dd216af09e073458b1093538f92827c830 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:18:14 +0800 Subject: [PATCH 0436/3904] try --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e44be663c..5abc9eba3 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,6 +77,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From b9923c1dcae33e511e931da0c630d23f8b91e2af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:30:11 +0800 Subject: [PATCH 0437/3904] try --- src/bitcoin-cli.cpp | 4 +++- src/komodo_utils.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 5abc9eba3..d82049cf3 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -73,11 +73,13 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" +##include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 02f226028..61c2f8c6a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -742,6 +742,8 @@ uint32_t calc_crc32(uint32_t crc,const void *buf,size_t size) return crc ^ ~0U; } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen) { bits256 hash; From 8963872dca12d7c7a6f74b54cb0ff18ad4616c5d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:31:33 +0800 Subject: [PATCH 0438/3904] lol --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index d82049cf3..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -73,7 +73,7 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -##include "cc/utils.h" +#include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" From 02da812eb6e5e411a3007900a974d76c69ed643c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:37:11 +0800 Subject: [PATCH 0439/3904] wtf --- src/komodo_globals.h | 1 + src/komodo_utils.h | 10 ++++++++-- src/main.cpp | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a09008824..133743c52 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,6 +29,7 @@ uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); pthread_mutex_t komodo_mutex; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 61c2f8c6a..1cd7fc219 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -742,8 +742,6 @@ uint32_t calc_crc32(uint32_t crc,const void *buf,size_t size) return crc ^ ~0U; } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen) { bits256 hash; @@ -1481,6 +1479,14 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33) +{ + std::vectorpk; int32_t i; + for (i=0; i<33; i++) + pk.push_back(pubkey33[i]); + return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); +} + int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; diff --git a/src/main.cpp b/src/main.cpp index c7b0e0e9b..91ec53faf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,7 +64,6 @@ int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); void komodo_broadcast(CBlock *pblock,int32_t limit); void komodo_broadcast(CBlock *pblock,int32_t limit); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); BlockMap mapBlockIndex; CChain chainActive; From 7a306f46f8e0097cba9a442c98f3cd390d5491b5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:42:07 +0800 Subject: [PATCH 0440/3904] try --- src/komodo_utils.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1cd7fc219..48ddd8682 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1480,12 +1480,6 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; bool pubkey2addr(char *destaddr,uint8_t *pubkey33) -{ - std::vectorpk; int32_t i; - for (i=0; i<33; i++) - pk.push_back(pubkey33[i]); - return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); -} int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From 08548dc9e2ee04f15f26bfbf1dc129eede5bff53 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:43:43 +0800 Subject: [PATCH 0441/3904] try --- src/komodo_utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 48ddd8682..f4e03387f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1479,10 +1479,11 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33) + int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { + bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t i,notaryid; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); From ce5285f7e92a6899ca46271523a6c3e05511f6f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:06:49 +0800 Subject: [PATCH 0442/3904] try that --- src/komodo_utils.h | 5 ----- src/wallet/wallet.cpp | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f4e03387f..a9d16fd52 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1483,15 +1483,10 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { - bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t i,notaryid; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; - char Raddress[18]; - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - //CBitcoinAddress address(Raddress); - NOTARY_ADDRESS.assign(Raddress); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4fea5dae7..5a776c6e6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,9 +1202,17 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { + static bool didNA; + if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_PUBKEY.empty() ) { + char Raddress[18]; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + NOTARY_ADDRESS.assign(Raddress); + didNA == true; + } { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; From cfa4c9731d20ccabb721eb62055e91d4d1505f61 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:09:05 +0800 Subject: [PATCH 0443/3904] fix --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5a776c6e6..cf253db5f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1207,7 +1207,7 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { static bool didNA; - if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_PUBKEY.empty() ) { + if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); From 861c5d5553eb2d9432db8fa27fe5748c6056e745 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:14:14 +0800 Subject: [PATCH 0444/3904] 7 --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index cf253db5f..6b98df5d0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1209,6 +1209,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl static bool didNA; if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { char Raddress[18]; + fprintf(stderr, "test thing\n"); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); didNA == true; From 334314cef42ca343ae2ab7b5e12f903643ad1aba Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:16:53 +0800 Subject: [PATCH 0445/3904] try --- src/wallet/wallet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6b98df5d0..65dc60f8d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,14 +1202,13 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +bool pubkey2addr(char destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { static bool didNA; if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { char Raddress[18]; - fprintf(stderr, "test thing\n"); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); didNA == true; From eba1ffb18c8ea0dc3db842c93e7d1ba6c278e6a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:43:22 +0800 Subject: [PATCH 0446/3904] fix eras --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 10458d9ea..fbb3506ba 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From f48342ba788204b1270ab3321e9026949b899a64 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:45:14 +0800 Subject: [PATCH 0447/3904] remove flooding print --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 264f2060a..966b41850 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From 85bbfadd2f94f7e6940be3a17a40319c3cd4ac63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:40:04 +0800 Subject: [PATCH 0448/3904] attempt to add Raddress array --- src/komodo_globals.h | 4 ++-- src/komodo_notary.h | 40 ++++++++++++++++++++++++++++++++-------- src/main.cpp | 9 +++++---- src/notaries_staked.cpp | 35 +++++++++++++++++++++++++++++++++++ src/notaries_staked.h | 2 ++ src/wallet/wallet.cpp | 15 ++++----------- 6 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 133743c52..48071e072 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,12 +45,12 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[18][64]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 8e2fdf6fc..033fe8bba 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,6 +22,8 @@ #define KOMODO_MAINNET_START 178999 +extern NOTARYADDRS[18][64]; + //extern const char *notaries_STAKED[][2]; //extern const int num_notaries_STAKED; @@ -226,8 +228,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam if ( did0 == 0 ) { n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i STAKED_ERA ) + STAKED_ERA = era; return(era); }; +extern NOTARYADDRS[18][64]; + +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { + int8_t notaryID = -1; + if ( STAKED_ERA != 0 ) { + switch (STAKED_ERA) { + case 1: + notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname); + break; + case 2: + notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname); + break; + case 3: + notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname); + break; + case 4: + notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname); + break; + } + } + return(notaryID); +} + +int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { + for (size_t i = 0; i < num_notaries; i++) { + if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { + notaryname.assign(notaries_chosen[i][0]); + return(i); + } + } + return(-1) +} + CrosschainAuthority Choose_auth_STAKED(int chosen_era) { CrosschainAuthority auth; switch (chosen_era) { diff --git a/src/notaries_staked.h b/src/notaries_staked.h index fbb3506ba..d3927e68f 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -25,6 +25,8 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); +int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); CrosschainAuthority Choose_auth_STAKED(int chosen_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 65dc60f8d..a73ea31fe 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,17 +1202,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -bool pubkey2addr(char destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { - static bool didNA; - if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { - char Raddress[18]; - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - NOTARY_ADDRESS.assign(Raddress); - didNA == true; - } { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; @@ -1226,9 +1218,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + if (GetTransaction(tx.vin[i].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) { // This means we sent the tx.. if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; @@ -1259,7 +1251,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and do nothing else. + // this means we were in a multi sig, we wil remove the utxo we spent from our wallet, + // IF there exisited a function for that. fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 2d1a27fddf7b4c57f101a0bd6df84193ada5b6dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:43:46 +0800 Subject: [PATCH 0449/3904] fix --- src/notaries_staked.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 775f9c9cd..1066d18d0 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -130,7 +130,8 @@ int STAKED_era(int timestamp) return(era); }; -extern NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64]; +extern int32_t STAKED_ERA; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; @@ -160,7 +161,7 @@ int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *R return(i); } } - return(-1) + return(-1); } CrosschainAuthority Choose_auth_STAKED(int chosen_era) { From 351405ce375de6eb40b81c7ab9cd5c86423c56d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:47:50 +0800 Subject: [PATCH 0450/3904] more fix --- src/komodo_notary.h | 2 +- src/notaries_staked.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 033fe8bba..5f96e9145 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ #define KOMODO_MAINNET_START 178999 -extern NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64]; //extern const char *notaries_STAKED[][2]; //extern const int num_notaries_STAKED; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 1066d18d0..9d413fd5d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -3,6 +3,9 @@ #include "crosschain.h" #include +extern char NOTARYADDRS[18][64]; +extern int32_t STAKED_ERA; + // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = { @@ -130,9 +133,6 @@ int STAKED_era(int timestamp) return(era); }; -extern char NOTARYADDRS[18][64]; -extern int32_t STAKED_ERA; - int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; if ( STAKED_ERA != 0 ) { From 234da7a784ce1b0b8822f048c7c451b1ce22d0b0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:51:41 +0800 Subject: [PATCH 0451/3904] fix --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cd6cf11d6..7ea4f85e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } -extern NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64]; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { @@ -1062,7 +1062,7 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only } didinit = 1; } */ - for (i=0; i<=64; i++) + for (int32_t i=0; i<=64; i++) if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) return(1); return(0); From 65c77d6ffc9157a1529e3649a4d09161c370dd55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:13:38 +0800 Subject: [PATCH 0452/3904] fix --- src/cc/CCinclude.h | 4 +++- src/komodo_structs.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index ab320e58a..2e447f485 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -55,9 +55,11 @@ extern std::string CCerror; #define SMALLVAL 0.000000000000001 #define MIN_NOTARIZATION_CONFIRMS 2 +#ifndef _BITS256 +#define _BITS256 union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; typedef union _bits256 bits256; - +#endif struct CC_utxo { uint256 txid; diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 3d8f50718..470eeda09 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -47,10 +47,11 @@ #define KOMODO_KVBINARY 2 #define KOMODO_KVDURATION 1440 #define KOMODO_ASSETCHAIN_MAXLEN 65 - +#ifndef _BITS256 +#define _BITS256 union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; typedef union _bits256 bits256; - +#endif union _bits320 { uint8_t bytes[40]; uint16_t ushorts[20]; uint32_t uints[10]; uint64_t ulongs[5]; uint64_t txid; }; typedef union _bits320 bits320; From 8207ebdaa1aee995634ba09081951bab2e79379e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:16:27 +0800 Subject: [PATCH 0453/3904] try --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..deb956a1a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,7 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" - +#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) From 37c7d4108dc52d567e072f2f6e6e3f247df08c6b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:17:35 +0800 Subject: [PATCH 0454/3904] cpp include? --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index deb956a1a..717717a53 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,7 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCinclude.h" +#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) From 0b8cb81d2ce86247761360c616660988318044ab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:23:11 +0800 Subject: [PATCH 0455/3904] try --- src/cc/CCutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 491798a98..0270a09ff 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -14,7 +14,7 @@ ******************************************************************************/ #include "CCinclude.h" - +#include "../standard.h" /* CCutils has low level functions that are universally useful for all contracts. */ From e1b67809d9432dfb3fe7d94feaef9cd844120289 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:25:12 +0800 Subject: [PATCH 0456/3904] script --- src/cc/CCutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 0270a09ff..b586f5fcf 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -14,7 +14,7 @@ ******************************************************************************/ #include "CCinclude.h" -#include "../standard.h" +#include "../script/standard.h" /* CCutils has low level functions that are universally useful for all contracts. */ From 5f81cde8f71ca894e0ec431d425ade4ef04eabbd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:35:05 +0800 Subject: [PATCH 0457/3904] guessing --- src/bitcoin-cli.cpp | 1 - src/cc/utils.cpp | 22 ++++++++++++++++++++++ src/cc/utils.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 717717a53..a886c27f2 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,7 +78,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/cc/utils.cpp b/src/cc/utils.cpp index e69de29bb..e13c6054d 100644 --- a/src/cc/utils.cpp +++ b/src/cc/utils.cpp @@ -0,0 +1,22 @@ +#include "../script/standard.h" +#include "../base58.h" + +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) +{ + CTxDestination address; txnouttype whichType; + if ( ExtractDestination(scriptPubKey,address) != 0 ) + { + strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); + return(true); + } + fprintf(stderr,"ExtractDestination failed\n"); + return(false); +} + +bool pubkey2addr(char *destaddr,uint8_t *pubkey33) +{ + std::vectorpk; int32_t i; + for (i=0; i<33; i++) + pk.push_back(pubkey33[i]); + return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); +} diff --git a/src/cc/utils.h b/src/cc/utils.h index f0b91962d..6a70b6828 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -42,6 +42,8 @@ bool DeserializeF(const std::vector vIn, T f) } catch(...) {} return false; } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); #define E_MARSHAL(body) SerializeF([&] (CDataStream &ss) {body;}) #define E_UNMARSHAL(params, body) DeserializeF(params, [&] (CDataStream &ss) {body;}) From e75e7e21c6dea8ffeddaad5b180de405b6c1aad6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:39:58 +0800 Subject: [PATCH 0458/3904] try again --- src/komodo_notary.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5f96e9145..b4b8edc4b 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,6 +20,8 @@ #include "notaries_staked.h" +#include "cc/utils.cpp" + #define KOMODO_MAINNET_START 178999 extern char NOTARYADDRS[18][64]; @@ -206,6 +208,8 @@ const char *Notaries_elected1[][2] = }; #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; From c4e4197a659df34a058481fe8fd18c72caf6ec6f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:44:52 +0800 Subject: [PATCH 0459/3904] guess --- src/cc/utils.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/utils.cpp b/src/cc/utils.cpp index e13c6054d..fb41aaabf 100644 --- a/src/cc/utils.cpp +++ b/src/cc/utils.cpp @@ -1,6 +1,4 @@ -#include "../script/standard.h" -#include "../base58.h" - +#include "../main.h" bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { CTxDestination address; txnouttype whichType; From 54054b83970ff5bb190050c41d97ff6a308db716 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:47:16 +0800 Subject: [PATCH 0460/3904] try again --- src/bitcoin-cli.cpp | 2 ++ src/cc/utils.cpp | 20 -------------------- src/cc/utils.h | 3 +-- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index a886c27f2..420123d93 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,6 +78,8 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "main.h" +#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/cc/utils.cpp b/src/cc/utils.cpp index fb41aaabf..e69de29bb 100644 --- a/src/cc/utils.cpp +++ b/src/cc/utils.cpp @@ -1,20 +0,0 @@ -#include "../main.h" -bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) -{ - CTxDestination address; txnouttype whichType; - if ( ExtractDestination(scriptPubKey,address) != 0 ) - { - strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); - return(true); - } - fprintf(stderr,"ExtractDestination failed\n"); - return(false); -} - -bool pubkey2addr(char *destaddr,uint8_t *pubkey33) -{ - std::vectorpk; int32_t i; - for (i=0; i<33; i++) - pk.push_back(pubkey33[i]); - return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); -} diff --git a/src/cc/utils.h b/src/cc/utils.h index 6a70b6828..69410adbb 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -20,6 +20,7 @@ #include "version.h" + /* * Serialisation boilerplate */ @@ -42,8 +43,6 @@ bool DeserializeF(const std::vector vIn, T f) } catch(...) {} return false; } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); -bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); #define E_MARSHAL(body) SerializeF([&] (CDataStream &ss) {body;}) #define E_UNMARSHAL(params, body) DeserializeF(params, [&] (CDataStream &ss) {body;}) From d0e0ae97ba7203daeb1bca363b44b1fe52d60c45 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:49:55 +0800 Subject: [PATCH 0461/3904] wtf --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 420123d93..a1f06525c 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -79,7 +79,7 @@ public: #include "komodo_notary.h" #include "notaries_staked.cpp" #include "main.h" -#include "cc/CCutils.cpp" +#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) From 20c46df9be2a4bef8b94519d5f0b299ec5034248 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:53:57 +0800 Subject: [PATCH 0462/3904] dead --- src/bitcoin-cli.cpp | 3 +-- src/cc/CCutils.cpp | 2 +- src/komodo_notary.h | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index a1f06525c..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,8 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "main.h" -#include "cc/CCinclude.h" + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index b586f5fcf..491798a98 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -14,7 +14,7 @@ ******************************************************************************/ #include "CCinclude.h" -#include "../script/standard.h" + /* CCutils has low level functions that are universally useful for all contracts. */ diff --git a/src/komodo_notary.h b/src/komodo_notary.h index b4b8edc4b..c67d62342 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,7 +20,8 @@ #include "notaries_staked.h" -#include "cc/utils.cpp" +#include "main.h" +#include "cc/CCinclude.h" #define KOMODO_MAINNET_START 178999 From 7ccc6fe7ed4699ebdf806389ae38eb1f88240e01 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 23:26:07 +0800 Subject: [PATCH 0463/3904] try --- src/komodo_globals.h | 1 - src/komodo_notary.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 48071e072..bf96cfa44 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,7 +29,6 @@ uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); pthread_mutex_t komodo_mutex; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c67d62342..d5c54aeaf 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,6 +22,7 @@ #include "main.h" #include "cc/CCinclude.h" +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); #define KOMODO_MAINNET_START 178999 From 099b691e24767b74be11f15fe302617166d3fd78 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 23:33:41 +0800 Subject: [PATCH 0464/3904] hacky fix --- src/komodo_notary.h | 16 +++++++--------- src/main.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d5c54aeaf..cc841bc9d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,9 +20,7 @@ #include "notaries_staked.h" -#include "main.h" -#include "cc/CCinclude.h" -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; #define KOMODO_MAINNET_START 178999 @@ -237,7 +235,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam for (i=0; i Date: Fri, 2 Nov 2018 23:40:20 +0800 Subject: [PATCH 0465/3904] fix not compile --- src/wallet/rpcwallet.cpp | 69 ++-------------------------------------- 1 file changed, 3 insertions(+), 66 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 153a87dc7..f2cfae5a6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4565,7 +4565,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); if (!EnsureWalletIsAvailable(0)) return 0; - + const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4728,7 +4728,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; - + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); @@ -5029,69 +5029,6 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -UniValue setpubkey(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); - if ( fHelp || params.size() != 1 ) - throw runtime_error( - "setpubkey\n" - "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" - "\nArguments:\n" - "1. \"pubkey\" (string) pubkey to set.\n" - "\nResult:\n" - " {\n" - " \"pubkey\" : \"pubkey\", (string) The pubkey\n" - " \"ismine\" : \"true/false\", (bool)\n" - " \"R-address\" : \"R address\", (string) The pubkey\n" - " }\n" - "\nExamples:\n" - + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - ); - -#ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else - LOCK(cs_main); -#endif - - char Raddress[18]; - uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 ) { - if (strlen(params[0].get_str().c_str()) == 66) { - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { - result.push_back(Pair("error", "pubkey entered is invalid.")); - } else { - CBitcoinAddress address(Raddress); - bool isValid = address.IsValid(); - if (isValid) - { - CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); - result.push_back(Pair("address", currentAddress)); -#ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); -#endif - } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - } - } else { - result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } - } else { - result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); - } - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); - return result; -} UniValue oraclesaddress(const UniValue& params, bool fHelp) { @@ -6769,7 +6706,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR); CTxDestination address; if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + const CKeyStore& keystore = *pwalletMain; CAmount nValues[64],nValues2[64],nValue,total,total2; int32_t i,segid; assert(pwalletMain != NULL); From 885f304f9c325957792acece4a134ae02a3a003c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 00:47:19 +0800 Subject: [PATCH 0466/3904] try --- src/main.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.h b/src/main.h index fd418502a..0dd5e35c2 100644 --- a/src/main.h +++ b/src/main.h @@ -180,11 +180,11 @@ void RegisterNodeSignals(CNodeSignals& nodeSignals); /** Unregister a network node */ void UnregisterNodeSignals(CNodeSignals& nodeSignals); -/** +/** * Process an incoming block. This only returns after the best known valid * block is made active. Note that it does not, however, guarantee that the * specific block passed to it has been checked for validity! - * + * * @param[out] state This may be set to an Error state if any error occurred processing it, including during validation/connection/etc of otherwise unrelated blocks during reorganisation; or it may be set to an Invalid state if pblock is itself invalid (but this is not guaranteed even when the block is checked). If you want to *possibly* get feedback on whether pblock is valid, you must also install a CValidationInterface (see validationinterface.h) - this will have its BlockChecked method called whenever *any* block completes validation. * @param[in] pfrom The node which we are receiving the block from; it is added to mapBlockSource and may be penalised if the block is invalid. * @param[in] pblock The block we want to process. @@ -269,6 +269,7 @@ void PruneAndFlush(); bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectAbsurdFee=false); +int32_t pubkey2address(char *destaddr,uint8_t *pubkey33); struct CNodeStateStats { int nMisbehavior; @@ -640,7 +641,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF /** * Check transaction inputs, and make sure any * pay-to-script-hash transactions are evaluating IsStandard scripts - * + * * Why bother? To avoid denial-of-service attacks; an attacker * can submit a standard HASH... OP_EQUAL transaction, * which will get accepted into blocks. The redemption @@ -649,14 +650,14 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF * DUP CHECKSIG DROP ... repeated 100 times... OP_1 */ -/** +/** * Check for standard transaction types * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return True if all inputs (scriptSigs) use only standard transaction forms */ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, uint32_t consensusBranchId); -/** +/** * Count ECDSA signature operations the old-fashioned (pre-0.6) way * @return number of sigops this transaction's outputs will produce when spent * @see CTransaction::FetchInputs @@ -665,7 +666,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx); /** * Count ECDSA signature operations in pay-to-script-hash inputs. - * + * * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return maximum number of sigops required to validate this transaction's inputs * @see CTransaction::FetchInputs @@ -732,9 +733,9 @@ bool IsExpiredTx(const CTransaction &tx, int nBlockHeight); */ bool CheckFinalTx(const CTransaction &tx, int flags = -1); -/** +/** * Closure representing one script verification - * Note that this stores references to the spending transaction + * Note that this stores references to the spending transaction */ class CScriptCheck { From 943026456e03552914bae5b7e93328db4d6818c2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:22:18 +0800 Subject: [PATCH 0467/3904] try this arr --- src/main.h | 1 - src/rpcrawtransaction.cpp | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.h b/src/main.h index 0dd5e35c2..76e0f73ae 100644 --- a/src/main.h +++ b/src/main.h @@ -269,7 +269,6 @@ void PruneAndFlush(); bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectAbsurdFee=false); -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33); struct CNodeStateStats { int nMisbehavior; diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index a870d526c..6d874f420 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -480,7 +480,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid uint256 hashBlock; if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) return(-1); - else if ( n < tx.vout.size() ) + else if ( n < tx.vout.size() ) { ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); m = tx.vout[n].scriptPubKey.size(); @@ -492,6 +492,13 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid return(-1); } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + +int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) +{ + pubkey2addr((char *)destaddr,(uint8_t *)pubkey33); +} + UniValue gettxoutproof(const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 1 && params.size() != 2)) @@ -1155,7 +1162,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp) } } else if (fHaveChain) { throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain"); - } + } RelayTransaction(tx); return hashTx.GetHex(); From 43b7d6c90a37fd24a9eaa4c5ac4d188bb1e51435 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:27:11 +0800 Subject: [PATCH 0468/3904] try again --- src/main.cpp | 6 ------ src/rpcrawtransaction.cpp | 21 +++++++++++++++++---- src/rpcserver.h | 3 +++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c1c7b0936..7ea4f85e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1045,7 +1045,6 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, } } extern char NOTARYADDRS[18][64]; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { @@ -1069,11 +1068,6 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only return(0); } -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) -{ - pubkey2addr((char *)destaddr,(uint8_t *)pubkey33); -} - bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state) { // Basic checks that don't depend on any context diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 6d874f420..5710e502f 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -492,11 +492,24 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid return(-1); } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { - pubkey2addr((char *)destaddr,(uint8_t *)pubkey33); + CTxDestination address; txnouttype whichType; + if ( ExtractDestination(scriptPubKey,address) != 0 ) + { + strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); + return(true); + } + fprintf(stderr,"ExtractDestination failed\n"); + return(false); +} + +bool pubkey2address(char *destaddr,uint8_t *pubkey33) +{ + std::vectorpk; int32_t i; + for (i=0; i<33; i++) + pk.push_back(pubkey33[i]); + return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); } UniValue gettxoutproof(const UniValue& params, bool fHelp) diff --git a/src/rpcserver.h b/src/rpcserver.h index 81ca8a8b9..372d84392 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -287,6 +287,9 @@ extern UniValue FSMlist(const UniValue& params, bool fHelp); extern UniValue FSMinfo(const UniValue& params, bool fHelp); extern UniValue auctionaddress(const UniValue& params, bool fHelp); +extern bool pubkey2address(char *destaddr,uint8_t *pubkey33); +extern bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); + extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp //extern UniValue getnewaddress64(const UniValue& params, bool fHelp); // in rpcwallet.cpp extern UniValue getaccountaddress(const UniValue& params, bool fHelp); From cd477f81781eb73c7a51784d8becfe374c41c9bb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:31:50 +0800 Subject: [PATCH 0469/3904] try --- src/rpcrawtransaction.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 5710e502f..cf8aa8fb8 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -24,6 +24,7 @@ #endif #include "komodo_defs.h" +#include "komodo_notary.h" #include From c87ce0d841612bf9d1e4dc94a4cef49721f5035c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:37:39 +0800 Subject: [PATCH 0470/3904] why not --- src/komodo_notary.h | 2 +- src/rpcrawtransaction.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index cc841bc9d..6291c8e1a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,7 +20,7 @@ #include "notaries_staked.h" -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; +extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; #define KOMODO_MAINNET_START 178999 diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index cf8aa8fb8..5710e502f 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -24,7 +24,6 @@ #endif #include "komodo_defs.h" -#include "komodo_notary.h" #include From 0a598aeea7526552272e99a3ca0ce7f9ded9cd76 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:41:03 +0800 Subject: [PATCH 0471/3904] extreme lengths --- src/komodo_notary.h | 709 -------------------------------------------- 1 file changed, 709 deletions(-) delete mode 100644 src/komodo_notary.h diff --git a/src/komodo_notary.h b/src/komodo_notary.h deleted file mode 100644 index 6291c8e1a..000000000 --- a/src/komodo_notary.h +++ /dev/null @@ -1,709 +0,0 @@ -/****************************************************************************** - * Copyright © 2014-2018 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - - -#include "komodo_defs.h" - -#include "komodo_cJSON.h" - -#include "notaries_staked.h" - -extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; - -#define KOMODO_MAINNET_START 178999 - -extern char NOTARYADDRS[18][64]; - -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - -const char *Notaries_genesis[][2] = -{ - { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, - { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, - { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 - { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, - { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, - { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, - { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, -}; - -const char *Notaries_elected0[][2] = -{ - { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 - { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, - { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, - { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 - { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, - { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, - { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, - { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, - { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 - { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, - { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, - { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, - { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 - { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, - { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, - { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, - { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, - { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, - { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, - { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 - { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 - { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, - { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, - { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, - { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, - { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, - { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 - { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, - { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, - { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } -}; - -#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 -#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) - -const char *Notaries_elected1[][2] = -{ - {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, - {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, - {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, - {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, - {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 - {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, - {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, - {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, - {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, - {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, - {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, - {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, - {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, - {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, - {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 - {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, - {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, - {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, - {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, - {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, - {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, - {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, - {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 - {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, - {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, - {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, - {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, - {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, - {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, - {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, - {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 - {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, - {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, - {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, - {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, - {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, - {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, - {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, - {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 - {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, - {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, - {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, - {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, - {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, - {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, - {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, - {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, -}; -#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" - -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) -{ - static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33] = {0}; - int staked_era; - int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - timestamp = komodo_heightstamp(height); - else if ( ASSETCHAINS_SYMBOL[0] == 0 ) - timestamp = 0; - // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. - if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) - { - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - if ( Pubkeys == 0 ) - { - komodo_init(height); - //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); - } - pthread_mutex_lock(&komodo_mutex); - n = Pubkeys[htind].numnotaries; - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); - HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) - { - if ( kp->notaryid < n ) - { - mask |= (1LL << kp->notaryid); - memcpy(pubkeys[kp->notaryid],kp->pubkey,33); - } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); - } - pthread_mutex_unlock(&komodo_mutex); - if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) - return(n); - printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); - return(-1); -} - -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) -{ - int32_t i,n; uint8_t pubkeys[64][33]; - n = komodo_notaries(pubkeys,height,timestamp); - *numnotariesp = n; - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - numnotaries = Pubkeys[htind].numnotaries; - for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) - return(1); - else return(0); -} - -void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) -{ - static int32_t hwmheight; - int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; - if ( Pubkeys == 0 ) - Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); - memset(&N,0,sizeof(N)); - if ( origheight > 0 ) - { - height = (origheight + KOMODO_ELECTION_GAP/2); - height /= KOMODO_ELECTION_GAP; - height = ((height + 1) * KOMODO_ELECTION_GAP); - htind = (height / KOMODO_ELECTION_GAP); - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); - } else htind = 0; - pthread_mutex_lock(&komodo_mutex); - for (k=0; kpubkey,pubkeys[k],33); - kp->notaryid = k; - HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) - { - for (i=0; i<33; i++) - printf("%02x",pubkeys[k][i]); - printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); - } - } - N.numnotaries = num; - for (i=htind; i hwmheight ) - hwmheight = origheight; -} - -int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) -{ - // -1 if not notary, 0 if notary, 1 if special notary - struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; - *notaryidp = -1; - if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) - { - printf("komodo_chosennotary ht.%d illegal\n",height); - return(-1); - } - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) - { - modval = ((height % numnotaries) == *notaryidp); - return(modval); - } - } - if ( height >= 250000 ) - return(-1); - if ( Pubkeys == 0 ) - komodo_init(0); - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); - pthread_mutex_unlock(&komodo_mutex); - if ( kp != 0 ) - { - if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) - { - *notaryidp = kp->notaryid; - modval = ((height % numnotaries) == kp->notaryid); - //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); - } else printf("unexpected zero notaries at height.%d\n",height); - } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); - //int32_t i; for (i=0; i<33; i++) - // printf("%02x",pubkey33[i]); - //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); - return(modval); -} - -//struct komodo_state *komodo_stateptr(char *symbol,char *dest); - -struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - *idx = i; - np = &sp->NPOINTS[i]; - if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) - return(np); - } - } - *idx = -1; - return(0); -} - -struct notarized_checkpoint *komodo_npptr(int32_t height) -{ - int idx; - return komodo_npptr_for_height(height, &idx); -} - -struct notarized_checkpoint *komodo_npptr_at(int idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - if (idx < sp->NUM_NPOINTS) - return &sp->NPOINTS[idx]; - return(0); -} - -int32_t komodo_prevMoMheight() -{ - static uint256 zero; - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - np = &sp->NPOINTS[i]; - if ( np->MoM != zero ) - return(np->notarized_height); - } - } - return(0); -} - -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - *hashp = sp->NOTARIZED_HASH; - *txidp = sp->NOTARIZED_DESTTXID; - *prevMoMheightp = komodo_prevMoMheight(); - return(sp->NOTARIZED_HEIGHT); - } - else - { - *prevMoMheightp = 0; - memset(hashp,0,sizeof(*hashp)); - memset(txidp,0,sizeof(*txidp)); - return(0); - } -} - -int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NOTARIZED_HEIGHT > 0 ) - { - if ( txheight < sp->NOTARIZED_HEIGHT ) - return(numconfs); - else return(1); - } - } - return(numconfs); -} - -int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) -{ - struct notarized_checkpoint *np = 0; - if ( (np= komodo_npptr(height)) != 0 ) - { - *notarized_htp = np->notarized_height; - *MoMp = np->MoM; - *kmdtxidp = np->notarized_desttxid; - *MoMoMp = np->MoMoM; - *MoMoMoffsetp = np->MoMoMoffset; - *MoMoMdepthp = np->MoMoMdepth; - *kmdstartip = np->kmdstarti; - *kmdendip = np->kmdendi; - return(np->MoMdepth & 0xffff); - } - *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; - memset(MoMp,0,sizeof(*MoMp)); - memset(MoMoMp,0,sizeof(*MoMoMp)); - memset(kmdtxidp,0,sizeof(*kmdtxidp)); - return(0); -} - -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) -{ - struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NUM_NPOINTS > 0 ) - { - flag = 0; - if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) - { - np = &sp->NPOINTS[sp->last_NPOINTSi-1]; - if ( np->nHeight < nHeight ) - { - for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); - flag = 1; - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( flag == 0 ) - { - np = 0; - for (i=0; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( np != 0 ) - { - //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); - if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) - printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); - *notarized_hashp = np->notarized_hash; - *notarized_desttxidp = np->notarized_desttxid; - return(np->notarized_height); - } - } - memset(notarized_hashp,0,sizeof(*notarized_hashp)); - memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); - return(0); -} - -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) -{ - struct notarized_checkpoint *np; - if ( notarized_height >= nHeight ) - { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); - return; - } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); -} - -void komodo_init(int32_t height) -{ - static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; - if ( 0 && height != 0 ) - printf("komodo_init ht.%d didinit.%d\n",height,didinit); - memset(&zero,0,sizeof(zero)); - if ( didinit == 0 ) - { - pthread_mutex_init(&komodo_mutex,NULL); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - if ( height >= 0 ) - { - n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); - for (k=0; k Date: Sat, 3 Nov 2018 01:41:39 +0800 Subject: [PATCH 0472/3904] oops --- src/main.cpp | 711 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 711 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 7ea4f85e8..c8e67f8b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1068,6 +1068,717 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only return(0); } +/****************************************************************************** + * Copyright © 2014-2018 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + + +#include "komodo_defs.h" + +#include "komodo_cJSON.h" + +#include "notaries_staked.h" + +extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; + +#define KOMODO_MAINNET_START 178999 + +extern char NOTARYADDRS[18][64]; + +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; + +const char *Notaries_genesis[][2] = +{ + { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, + { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, + { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 + { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, + { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, + { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, + { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, +}; + +const char *Notaries_elected0[][2] = +{ + { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 + { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, + { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, + { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 + { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, + { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, + { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, + { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, + { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 + { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, + { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, + { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, + { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 + { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, + { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, + { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, + { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, + { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, + { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, + { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 + { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 + { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, + { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, + { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, + { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, + { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, + { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 + { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, + { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } +}; + +#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 +#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) + +const char *Notaries_elected1[][2] = +{ + {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, + {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, + {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, + {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, + {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 + {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, + {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, + {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, + {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, + {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, + {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, + {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, + {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, + {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, + {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 + {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, + {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, + {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, + {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, + {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, + {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, + {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, + {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 + {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, + {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, + {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, + {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, + {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, + {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, + {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, + {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 + {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, + {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, + {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, + {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, + {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, + {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, + {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, + {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 + {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, + {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, + {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, + {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, + {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, + {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, + {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, + {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; +#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" + +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) +{ + static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; + static uint8_t null_pubkeys[64][33] = {0}; + int staked_era; + int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; + if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = komodo_heightstamp(height); + else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + timestamp = 0; + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. + if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) + { + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + if ( Pubkeys == 0 ) + { + komodo_init(height); + //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); + } + pthread_mutex_lock(&komodo_mutex); + n = Pubkeys[htind].numnotaries; + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); + HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) + { + if ( kp->notaryid < n ) + { + mask |= (1LL << kp->notaryid); + memcpy(pubkeys[kp->notaryid],kp->pubkey,33); + } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); + } + pthread_mutex_unlock(&komodo_mutex); + if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) + return(n); + printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); + return(-1); +} + +int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) +{ + int32_t i,n; uint8_t pubkeys[64][33]; + n = komodo_notaries(pubkeys,height,timestamp); + *numnotariesp = n; + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + numnotaries = Pubkeys[htind].numnotaries; + for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) + return(1); + else return(0); +} + +void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) +{ + static int32_t hwmheight; + int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; + if ( Pubkeys == 0 ) + Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); + memset(&N,0,sizeof(N)); + if ( origheight > 0 ) + { + height = (origheight + KOMODO_ELECTION_GAP/2); + height /= KOMODO_ELECTION_GAP; + height = ((height + 1) * KOMODO_ELECTION_GAP); + htind = (height / KOMODO_ELECTION_GAP); + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); + } else htind = 0; + pthread_mutex_lock(&komodo_mutex); + for (k=0; kpubkey,pubkeys[k],33); + kp->notaryid = k; + HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); + if ( 0 && height > 10000 ) + { + for (i=0; i<33; i++) + printf("%02x",pubkeys[k][i]); + printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); + } + } + N.numnotaries = num; + for (i=htind; i hwmheight ) + hwmheight = origheight; +} + +int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) +{ + // -1 if not notary, 0 if notary, 1 if special notary + struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; + *notaryidp = -1; + if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) + { + printf("komodo_chosennotary ht.%d illegal\n",height); + return(-1); + } + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) + { + modval = ((height % numnotaries) == *notaryidp); + return(modval); + } + } + if ( height >= 250000 ) + return(-1); + if ( Pubkeys == 0 ) + komodo_init(0); + htind = height / KOMODO_ELECTION_GAP; + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + pthread_mutex_lock(&komodo_mutex); + HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); + pthread_mutex_unlock(&komodo_mutex); + if ( kp != 0 ) + { + if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) + { + *notaryidp = kp->notaryid; + modval = ((height % numnotaries) == kp->notaryid); + //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); + } else printf("unexpected zero notaries at height.%d\n",height); + } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); + //int32_t i; for (i=0; i<33; i++) + // printf("%02x",pubkey33[i]); + //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); + return(modval); +} + +//struct komodo_state *komodo_stateptr(char *symbol,char *dest); + +struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + *idx = i; + np = &sp->NPOINTS[i]; + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) + return(np); + } + } + *idx = -1; + return(0); +} + +struct notarized_checkpoint *komodo_npptr(int32_t height) +{ + int idx; + return komodo_npptr_for_height(height, &idx); +} + +struct notarized_checkpoint *komodo_npptr_at(int idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if (idx < sp->NUM_NPOINTS) + return &sp->NPOINTS[idx]; + return(0); +} + +int32_t komodo_prevMoMheight() +{ + static uint256 zero; + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( np->MoM != zero ) + return(np->notarized_height); + } + } + return(0); +} + +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + *hashp = sp->NOTARIZED_HASH; + *txidp = sp->NOTARIZED_DESTTXID; + *prevMoMheightp = komodo_prevMoMheight(); + return(sp->NOTARIZED_HEIGHT); + } + else + { + *prevMoMheightp = 0; + memset(hashp,0,sizeof(*hashp)); + memset(txidp,0,sizeof(*txidp)); + return(0); + } +} + +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NOTARIZED_HEIGHT > 0 ) + { + if ( txheight < sp->NOTARIZED_HEIGHT ) + return(numconfs); + else return(1); + } + } + return(numconfs); +} + +int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) +{ + struct notarized_checkpoint *np = 0; + if ( (np= komodo_npptr(height)) != 0 ) + { + *notarized_htp = np->notarized_height; + *MoMp = np->MoM; + *kmdtxidp = np->notarized_desttxid; + *MoMoMp = np->MoMoM; + *MoMoMoffsetp = np->MoMoMoffset; + *MoMoMdepthp = np->MoMoMdepth; + *kmdstartip = np->kmdstarti; + *kmdendip = np->kmdendi; + return(np->MoMdepth & 0xffff); + } + *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; + memset(MoMp,0,sizeof(*MoMp)); + memset(MoMoMp,0,sizeof(*MoMoMp)); + memset(kmdtxidp,0,sizeof(*kmdtxidp)); + return(0); +} + +int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) +{ + struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NUM_NPOINTS > 0 ) + { + flag = 0; + if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) + { + np = &sp->NPOINTS[sp->last_NPOINTSi-1]; + if ( np->nHeight < nHeight ) + { + for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); + flag = 1; + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( flag == 0 ) + { + np = 0; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( np != 0 ) + { + //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); + if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) + printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); + *notarized_hashp = np->notarized_hash; + *notarized_desttxidp = np->notarized_desttxid; + return(np->notarized_height); + } + } + memset(notarized_hashp,0,sizeof(*notarized_hashp)); + memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); + return(0); +} + +void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +{ + struct notarized_checkpoint *np; + if ( notarized_height >= nHeight ) + { + fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + return; + } + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); +} + +void komodo_init(int32_t height) +{ + static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; + if ( 0 && height != 0 ) + printf("komodo_init ht.%d didinit.%d\n",height,didinit); + memset(&zero,0,sizeof(zero)); + if ( didinit == 0 ) + { + pthread_mutex_init(&komodo_mutex,NULL); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + if ( height >= 0 ) + { + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; k Date: Sat, 3 Nov 2018 01:43:55 +0800 Subject: [PATCH 0473/3904] unikely --- src/bitcoin-cli.cpp | 2 +- src/komodo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..bd39318c3 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,7 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "komodo_notary.h" +//#include "komodo_notary.h" #include "notaries_staked.cpp" diff --git a/src/komodo.h b/src/komodo.h index d2d0231f3..94a50a337 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -48,7 +48,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_bitcoind.h" #include "komodo_interest.h" #include "komodo_pax.h" -#include "komodo_notary.h" +//#include "komodo_notary.h" int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" From f8889dbe6d326f933d7877ef673870a454725269 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:46:19 +0800 Subject: [PATCH 0474/3904] main.h? --- src/main.cpp | 711 --------------------------------------------------- src/main.h | 708 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 708 insertions(+), 711 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c8e67f8b4..7ea4f85e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1068,717 +1068,6 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only return(0); } -/****************************************************************************** - * Copyright © 2014-2018 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - - -#include "komodo_defs.h" - -#include "komodo_cJSON.h" - -#include "notaries_staked.h" - -extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; - -#define KOMODO_MAINNET_START 178999 - -extern char NOTARYADDRS[18][64]; - -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - -const char *Notaries_genesis[][2] = -{ - { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, - { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, - { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 - { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, - { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, - { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, - { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, -}; - -const char *Notaries_elected0[][2] = -{ - { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 - { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, - { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, - { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 - { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, - { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, - { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, - { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, - { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 - { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, - { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, - { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, - { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 - { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, - { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, - { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, - { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, - { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, - { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, - { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 - { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 - { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, - { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, - { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, - { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, - { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, - { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 - { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, - { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, - { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } -}; - -#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 -#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) - -const char *Notaries_elected1[][2] = -{ - {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, - {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, - {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, - {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, - {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 - {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, - {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, - {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, - {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, - {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, - {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, - {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, - {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, - {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, - {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 - {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, - {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, - {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, - {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, - {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, - {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, - {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, - {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 - {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, - {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, - {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, - {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, - {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, - {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, - {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, - {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 - {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, - {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, - {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, - {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, - {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, - {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, - {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, - {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 - {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, - {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, - {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, - {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, - {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, - {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, - {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, - {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, -}; -#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" - -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) -{ - static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33] = {0}; - int staked_era; - int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - timestamp = komodo_heightstamp(height); - else if ( ASSETCHAINS_SYMBOL[0] == 0 ) - timestamp = 0; - // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. - if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) - { - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - if ( Pubkeys == 0 ) - { - komodo_init(height); - //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); - } - pthread_mutex_lock(&komodo_mutex); - n = Pubkeys[htind].numnotaries; - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); - HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) - { - if ( kp->notaryid < n ) - { - mask |= (1LL << kp->notaryid); - memcpy(pubkeys[kp->notaryid],kp->pubkey,33); - } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); - } - pthread_mutex_unlock(&komodo_mutex); - if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) - return(n); - printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); - return(-1); -} - -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) -{ - int32_t i,n; uint8_t pubkeys[64][33]; - n = komodo_notaries(pubkeys,height,timestamp); - *numnotariesp = n; - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - numnotaries = Pubkeys[htind].numnotaries; - for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) - return(1); - else return(0); -} - -void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) -{ - static int32_t hwmheight; - int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; - if ( Pubkeys == 0 ) - Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); - memset(&N,0,sizeof(N)); - if ( origheight > 0 ) - { - height = (origheight + KOMODO_ELECTION_GAP/2); - height /= KOMODO_ELECTION_GAP; - height = ((height + 1) * KOMODO_ELECTION_GAP); - htind = (height / KOMODO_ELECTION_GAP); - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); - } else htind = 0; - pthread_mutex_lock(&komodo_mutex); - for (k=0; kpubkey,pubkeys[k],33); - kp->notaryid = k; - HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) - { - for (i=0; i<33; i++) - printf("%02x",pubkeys[k][i]); - printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); - } - } - N.numnotaries = num; - for (i=htind; i hwmheight ) - hwmheight = origheight; -} - -int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) -{ - // -1 if not notary, 0 if notary, 1 if special notary - struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; - *notaryidp = -1; - if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) - { - printf("komodo_chosennotary ht.%d illegal\n",height); - return(-1); - } - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) - { - modval = ((height % numnotaries) == *notaryidp); - return(modval); - } - } - if ( height >= 250000 ) - return(-1); - if ( Pubkeys == 0 ) - komodo_init(0); - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); - pthread_mutex_unlock(&komodo_mutex); - if ( kp != 0 ) - { - if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) - { - *notaryidp = kp->notaryid; - modval = ((height % numnotaries) == kp->notaryid); - //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); - } else printf("unexpected zero notaries at height.%d\n",height); - } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); - //int32_t i; for (i=0; i<33; i++) - // printf("%02x",pubkey33[i]); - //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); - return(modval); -} - -//struct komodo_state *komodo_stateptr(char *symbol,char *dest); - -struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - *idx = i; - np = &sp->NPOINTS[i]; - if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) - return(np); - } - } - *idx = -1; - return(0); -} - -struct notarized_checkpoint *komodo_npptr(int32_t height) -{ - int idx; - return komodo_npptr_for_height(height, &idx); -} - -struct notarized_checkpoint *komodo_npptr_at(int idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - if (idx < sp->NUM_NPOINTS) - return &sp->NPOINTS[idx]; - return(0); -} - -int32_t komodo_prevMoMheight() -{ - static uint256 zero; - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - np = &sp->NPOINTS[i]; - if ( np->MoM != zero ) - return(np->notarized_height); - } - } - return(0); -} - -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - *hashp = sp->NOTARIZED_HASH; - *txidp = sp->NOTARIZED_DESTTXID; - *prevMoMheightp = komodo_prevMoMheight(); - return(sp->NOTARIZED_HEIGHT); - } - else - { - *prevMoMheightp = 0; - memset(hashp,0,sizeof(*hashp)); - memset(txidp,0,sizeof(*txidp)); - return(0); - } -} - -int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NOTARIZED_HEIGHT > 0 ) - { - if ( txheight < sp->NOTARIZED_HEIGHT ) - return(numconfs); - else return(1); - } - } - return(numconfs); -} - -int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) -{ - struct notarized_checkpoint *np = 0; - if ( (np= komodo_npptr(height)) != 0 ) - { - *notarized_htp = np->notarized_height; - *MoMp = np->MoM; - *kmdtxidp = np->notarized_desttxid; - *MoMoMp = np->MoMoM; - *MoMoMoffsetp = np->MoMoMoffset; - *MoMoMdepthp = np->MoMoMdepth; - *kmdstartip = np->kmdstarti; - *kmdendip = np->kmdendi; - return(np->MoMdepth & 0xffff); - } - *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; - memset(MoMp,0,sizeof(*MoMp)); - memset(MoMoMp,0,sizeof(*MoMoMp)); - memset(kmdtxidp,0,sizeof(*kmdtxidp)); - return(0); -} - -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) -{ - struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NUM_NPOINTS > 0 ) - { - flag = 0; - if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) - { - np = &sp->NPOINTS[sp->last_NPOINTSi-1]; - if ( np->nHeight < nHeight ) - { - for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); - flag = 1; - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( flag == 0 ) - { - np = 0; - for (i=0; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( np != 0 ) - { - //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); - if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) - printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); - *notarized_hashp = np->notarized_hash; - *notarized_desttxidp = np->notarized_desttxid; - return(np->notarized_height); - } - } - memset(notarized_hashp,0,sizeof(*notarized_hashp)); - memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); - return(0); -} - -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) -{ - struct notarized_checkpoint *np; - if ( notarized_height >= nHeight ) - { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); - return; - } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); -} - -void komodo_init(int32_t height) -{ - static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; - if ( 0 && height != 0 ) - printf("komodo_init ht.%d didinit.%d\n",height,didinit); - memset(&zero,0,sizeof(zero)); - if ( didinit == 0 ) - { - pthread_mutex_init(&komodo_mutex,NULL); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - if ( height >= 0 ) - { - n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); - for (k=0; k= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + if ( Pubkeys == 0 ) + { + komodo_init(height); + //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); + } + pthread_mutex_lock(&komodo_mutex); + n = Pubkeys[htind].numnotaries; + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); + HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) + { + if ( kp->notaryid < n ) + { + mask |= (1LL << kp->notaryid); + memcpy(pubkeys[kp->notaryid],kp->pubkey,33); + } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); + } + pthread_mutex_unlock(&komodo_mutex); + if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) + return(n); + printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); + return(-1); +} + +int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) +{ + int32_t i,n; uint8_t pubkeys[64][33]; + n = komodo_notaries(pubkeys,height,timestamp); + *numnotariesp = n; + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + numnotaries = Pubkeys[htind].numnotaries; + for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) + return(1); + else return(0); +} + +void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) +{ + static int32_t hwmheight; + int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; + if ( Pubkeys == 0 ) + Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); + memset(&N,0,sizeof(N)); + if ( origheight > 0 ) + { + height = (origheight + KOMODO_ELECTION_GAP/2); + height /= KOMODO_ELECTION_GAP; + height = ((height + 1) * KOMODO_ELECTION_GAP); + htind = (height / KOMODO_ELECTION_GAP); + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); + } else htind = 0; + pthread_mutex_lock(&komodo_mutex); + for (k=0; kpubkey,pubkeys[k],33); + kp->notaryid = k; + HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); + if ( 0 && height > 10000 ) + { + for (i=0; i<33; i++) + printf("%02x",pubkeys[k][i]); + printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); + } + } + N.numnotaries = num; + for (i=htind; i hwmheight ) + hwmheight = origheight; +} + +int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) +{ + // -1 if not notary, 0 if notary, 1 if special notary + struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; + *notaryidp = -1; + if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) + { + printf("komodo_chosennotary ht.%d illegal\n",height); + return(-1); + } + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) + { + modval = ((height % numnotaries) == *notaryidp); + return(modval); + } + } + if ( height >= 250000 ) + return(-1); + if ( Pubkeys == 0 ) + komodo_init(0); + htind = height / KOMODO_ELECTION_GAP; + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + pthread_mutex_lock(&komodo_mutex); + HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); + pthread_mutex_unlock(&komodo_mutex); + if ( kp != 0 ) + { + if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) + { + *notaryidp = kp->notaryid; + modval = ((height % numnotaries) == kp->notaryid); + //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); + } else printf("unexpected zero notaries at height.%d\n",height); + } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); + //int32_t i; for (i=0; i<33; i++) + // printf("%02x",pubkey33[i]); + //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); + return(modval); +} + +//struct komodo_state *komodo_stateptr(char *symbol,char *dest); + +struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + *idx = i; + np = &sp->NPOINTS[i]; + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) + return(np); + } + } + *idx = -1; + return(0); +} + +struct notarized_checkpoint *komodo_npptr(int32_t height) +{ + int idx; + return komodo_npptr_for_height(height, &idx); +} + +struct notarized_checkpoint *komodo_npptr_at(int idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if (idx < sp->NUM_NPOINTS) + return &sp->NPOINTS[idx]; + return(0); +} + +int32_t komodo_prevMoMheight() +{ + static uint256 zero; + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( np->MoM != zero ) + return(np->notarized_height); + } + } + return(0); +} + +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + *hashp = sp->NOTARIZED_HASH; + *txidp = sp->NOTARIZED_DESTTXID; + *prevMoMheightp = komodo_prevMoMheight(); + return(sp->NOTARIZED_HEIGHT); + } + else + { + *prevMoMheightp = 0; + memset(hashp,0,sizeof(*hashp)); + memset(txidp,0,sizeof(*txidp)); + return(0); + } +} + +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NOTARIZED_HEIGHT > 0 ) + { + if ( txheight < sp->NOTARIZED_HEIGHT ) + return(numconfs); + else return(1); + } + } + return(numconfs); +} + +int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) +{ + struct notarized_checkpoint *np = 0; + if ( (np= komodo_npptr(height)) != 0 ) + { + *notarized_htp = np->notarized_height; + *MoMp = np->MoM; + *kmdtxidp = np->notarized_desttxid; + *MoMoMp = np->MoMoM; + *MoMoMoffsetp = np->MoMoMoffset; + *MoMoMdepthp = np->MoMoMdepth; + *kmdstartip = np->kmdstarti; + *kmdendip = np->kmdendi; + return(np->MoMdepth & 0xffff); + } + *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; + memset(MoMp,0,sizeof(*MoMp)); + memset(MoMoMp,0,sizeof(*MoMoMp)); + memset(kmdtxidp,0,sizeof(*kmdtxidp)); + return(0); +} + +int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) +{ + struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NUM_NPOINTS > 0 ) + { + flag = 0; + if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) + { + np = &sp->NPOINTS[sp->last_NPOINTSi-1]; + if ( np->nHeight < nHeight ) + { + for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); + flag = 1; + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( flag == 0 ) + { + np = 0; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( np != 0 ) + { + //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); + if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) + printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); + *notarized_hashp = np->notarized_hash; + *notarized_desttxidp = np->notarized_desttxid; + return(np->notarized_height); + } + } + memset(notarized_hashp,0,sizeof(*notarized_hashp)); + memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); + return(0); +} + +void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +{ + struct notarized_checkpoint *np; + if ( notarized_height >= nHeight ) + { + fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + return; + } + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); +} + +void komodo_init(int32_t height) +{ + static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; + if ( 0 && height != 0 ) + printf("komodo_init ht.%d didinit.%d\n",height,didinit); + memset(&zero,0,sizeof(zero)); + if ( didinit == 0 ) + { + pthread_mutex_init(&komodo_mutex,NULL); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + if ( height >= 0 ) + { + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; k Date: Sat, 3 Nov 2018 01:48:53 +0800 Subject: [PATCH 0475/3904] try --- src/bitcoin-cli.cpp | 2 +- src/komodo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index bd39318c3..2cababe69 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,7 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -//#include "komodo_notary.h" +#include "main.h" #include "notaries_staked.cpp" diff --git a/src/komodo.h b/src/komodo.h index 94a50a337..46338b705 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -48,7 +48,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_bitcoind.h" #include "komodo_interest.h" #include "komodo_pax.h" -//#include "komodo_notary.h" +#include "main.h" int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" From 98a8eea3fa339f9596d354775d0f0f49238fae76 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 02:06:19 +0800 Subject: [PATCH 0476/3904] revert that --- src/bitcoin-cli.cpp | 2 +- src/komodo.h | 2 +- src/komodo_notary.h | 709 ++++++++++++++++++++++++++++++++++++++++++++ src/main.h | 708 ------------------------------------------- 4 files changed, 711 insertions(+), 710 deletions(-) create mode 100644 src/komodo_notary.h diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 2cababe69..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,7 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "main.h" +#include "komodo_notary.h" #include "notaries_staked.cpp" diff --git a/src/komodo.h b/src/komodo.h index 46338b705..d2d0231f3 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -48,7 +48,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_bitcoind.h" #include "komodo_interest.h" #include "komodo_pax.h" -#include "main.h" +#include "komodo_notary.h" int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" diff --git a/src/komodo_notary.h b/src/komodo_notary.h new file mode 100644 index 000000000..6291c8e1a --- /dev/null +++ b/src/komodo_notary.h @@ -0,0 +1,709 @@ +/****************************************************************************** + * Copyright © 2014-2018 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + + +#include "komodo_defs.h" + +#include "komodo_cJSON.h" + +#include "notaries_staked.h" + +extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; + +#define KOMODO_MAINNET_START 178999 + +extern char NOTARYADDRS[18][64]; + +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; + +const char *Notaries_genesis[][2] = +{ + { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, + { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, + { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 + { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, + { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, + { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, + { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, +}; + +const char *Notaries_elected0[][2] = +{ + { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 + { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, + { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, + { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 + { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, + { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, + { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, + { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, + { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 + { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, + { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, + { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, + { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 + { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, + { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, + { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, + { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, + { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, + { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, + { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 + { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 + { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, + { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, + { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, + { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, + { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, + { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 + { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, + { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } +}; + +#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 +#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) + +const char *Notaries_elected1[][2] = +{ + {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, + {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, + {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, + {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, + {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 + {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, + {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, + {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, + {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, + {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, + {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, + {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, + {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, + {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, + {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 + {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, + {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, + {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, + {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, + {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, + {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, + {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, + {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 + {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, + {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, + {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, + {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, + {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, + {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, + {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, + {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 + {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, + {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, + {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, + {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, + {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, + {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, + {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, + {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 + {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, + {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, + {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, + {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, + {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, + {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, + {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, + {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; +#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" + +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) +{ + static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; + static uint8_t null_pubkeys[64][33] = {0}; + int staked_era; + int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; + if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = komodo_heightstamp(height); + else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + timestamp = 0; + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. + if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) + { + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + if ( Pubkeys == 0 ) + { + komodo_init(height); + //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); + } + pthread_mutex_lock(&komodo_mutex); + n = Pubkeys[htind].numnotaries; + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); + HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) + { + if ( kp->notaryid < n ) + { + mask |= (1LL << kp->notaryid); + memcpy(pubkeys[kp->notaryid],kp->pubkey,33); + } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); + } + pthread_mutex_unlock(&komodo_mutex); + if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) + return(n); + printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); + return(-1); +} + +int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) +{ + int32_t i,n; uint8_t pubkeys[64][33]; + n = komodo_notaries(pubkeys,height,timestamp); + *numnotariesp = n; + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + numnotaries = Pubkeys[htind].numnotaries; + for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) + return(1); + else return(0); +} + +void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) +{ + static int32_t hwmheight; + int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; + if ( Pubkeys == 0 ) + Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); + memset(&N,0,sizeof(N)); + if ( origheight > 0 ) + { + height = (origheight + KOMODO_ELECTION_GAP/2); + height /= KOMODO_ELECTION_GAP; + height = ((height + 1) * KOMODO_ELECTION_GAP); + htind = (height / KOMODO_ELECTION_GAP); + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); + } else htind = 0; + pthread_mutex_lock(&komodo_mutex); + for (k=0; kpubkey,pubkeys[k],33); + kp->notaryid = k; + HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); + if ( 0 && height > 10000 ) + { + for (i=0; i<33; i++) + printf("%02x",pubkeys[k][i]); + printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); + } + } + N.numnotaries = num; + for (i=htind; i hwmheight ) + hwmheight = origheight; +} + +int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) +{ + // -1 if not notary, 0 if notary, 1 if special notary + struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; + *notaryidp = -1; + if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) + { + printf("komodo_chosennotary ht.%d illegal\n",height); + return(-1); + } + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) + { + modval = ((height % numnotaries) == *notaryidp); + return(modval); + } + } + if ( height >= 250000 ) + return(-1); + if ( Pubkeys == 0 ) + komodo_init(0); + htind = height / KOMODO_ELECTION_GAP; + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + pthread_mutex_lock(&komodo_mutex); + HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); + pthread_mutex_unlock(&komodo_mutex); + if ( kp != 0 ) + { + if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) + { + *notaryidp = kp->notaryid; + modval = ((height % numnotaries) == kp->notaryid); + //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); + } else printf("unexpected zero notaries at height.%d\n",height); + } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); + //int32_t i; for (i=0; i<33; i++) + // printf("%02x",pubkey33[i]); + //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); + return(modval); +} + +//struct komodo_state *komodo_stateptr(char *symbol,char *dest); + +struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + *idx = i; + np = &sp->NPOINTS[i]; + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) + return(np); + } + } + *idx = -1; + return(0); +} + +struct notarized_checkpoint *komodo_npptr(int32_t height) +{ + int idx; + return komodo_npptr_for_height(height, &idx); +} + +struct notarized_checkpoint *komodo_npptr_at(int idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if (idx < sp->NUM_NPOINTS) + return &sp->NPOINTS[idx]; + return(0); +} + +int32_t komodo_prevMoMheight() +{ + static uint256 zero; + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( np->MoM != zero ) + return(np->notarized_height); + } + } + return(0); +} + +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + *hashp = sp->NOTARIZED_HASH; + *txidp = sp->NOTARIZED_DESTTXID; + *prevMoMheightp = komodo_prevMoMheight(); + return(sp->NOTARIZED_HEIGHT); + } + else + { + *prevMoMheightp = 0; + memset(hashp,0,sizeof(*hashp)); + memset(txidp,0,sizeof(*txidp)); + return(0); + } +} + +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NOTARIZED_HEIGHT > 0 ) + { + if ( txheight < sp->NOTARIZED_HEIGHT ) + return(numconfs); + else return(1); + } + } + return(numconfs); +} + +int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) +{ + struct notarized_checkpoint *np = 0; + if ( (np= komodo_npptr(height)) != 0 ) + { + *notarized_htp = np->notarized_height; + *MoMp = np->MoM; + *kmdtxidp = np->notarized_desttxid; + *MoMoMp = np->MoMoM; + *MoMoMoffsetp = np->MoMoMoffset; + *MoMoMdepthp = np->MoMoMdepth; + *kmdstartip = np->kmdstarti; + *kmdendip = np->kmdendi; + return(np->MoMdepth & 0xffff); + } + *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; + memset(MoMp,0,sizeof(*MoMp)); + memset(MoMoMp,0,sizeof(*MoMoMp)); + memset(kmdtxidp,0,sizeof(*kmdtxidp)); + return(0); +} + +int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) +{ + struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NUM_NPOINTS > 0 ) + { + flag = 0; + if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) + { + np = &sp->NPOINTS[sp->last_NPOINTSi-1]; + if ( np->nHeight < nHeight ) + { + for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); + flag = 1; + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( flag == 0 ) + { + np = 0; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( np != 0 ) + { + //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); + if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) + printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); + *notarized_hashp = np->notarized_hash; + *notarized_desttxidp = np->notarized_desttxid; + return(np->notarized_height); + } + } + memset(notarized_hashp,0,sizeof(*notarized_hashp)); + memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); + return(0); +} + +void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +{ + struct notarized_checkpoint *np; + if ( notarized_height >= nHeight ) + { + fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + return; + } + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); +} + +void komodo_init(int32_t height) +{ + static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; + if ( 0 && height != 0 ) + printf("komodo_init ht.%d didinit.%d\n",height,didinit); + memset(&zero,0,sizeof(zero)); + if ( didinit == 0 ) + { + pthread_mutex_init(&komodo_mutex,NULL); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + if ( height >= 0 ) + { + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; k= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - if ( Pubkeys == 0 ) - { - komodo_init(height); - //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); - } - pthread_mutex_lock(&komodo_mutex); - n = Pubkeys[htind].numnotaries; - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); - HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) - { - if ( kp->notaryid < n ) - { - mask |= (1LL << kp->notaryid); - memcpy(pubkeys[kp->notaryid],kp->pubkey,33); - } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); - } - pthread_mutex_unlock(&komodo_mutex); - if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) - return(n); - printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); - return(-1); -} - -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) -{ - int32_t i,n; uint8_t pubkeys[64][33]; - n = komodo_notaries(pubkeys,height,timestamp); - *numnotariesp = n; - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - numnotaries = Pubkeys[htind].numnotaries; - for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) - return(1); - else return(0); -} - -void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) -{ - static int32_t hwmheight; - int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; - if ( Pubkeys == 0 ) - Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); - memset(&N,0,sizeof(N)); - if ( origheight > 0 ) - { - height = (origheight + KOMODO_ELECTION_GAP/2); - height /= KOMODO_ELECTION_GAP; - height = ((height + 1) * KOMODO_ELECTION_GAP); - htind = (height / KOMODO_ELECTION_GAP); - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); - } else htind = 0; - pthread_mutex_lock(&komodo_mutex); - for (k=0; kpubkey,pubkeys[k],33); - kp->notaryid = k; - HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) - { - for (i=0; i<33; i++) - printf("%02x",pubkeys[k][i]); - printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); - } - } - N.numnotaries = num; - for (i=htind; i hwmheight ) - hwmheight = origheight; -} - -int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) -{ - // -1 if not notary, 0 if notary, 1 if special notary - struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; - *notaryidp = -1; - if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) - { - printf("komodo_chosennotary ht.%d illegal\n",height); - return(-1); - } - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) - { - modval = ((height % numnotaries) == *notaryidp); - return(modval); - } - } - if ( height >= 250000 ) - return(-1); - if ( Pubkeys == 0 ) - komodo_init(0); - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); - pthread_mutex_unlock(&komodo_mutex); - if ( kp != 0 ) - { - if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) - { - *notaryidp = kp->notaryid; - modval = ((height % numnotaries) == kp->notaryid); - //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); - } else printf("unexpected zero notaries at height.%d\n",height); - } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); - //int32_t i; for (i=0; i<33; i++) - // printf("%02x",pubkey33[i]); - //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); - return(modval); -} - -//struct komodo_state *komodo_stateptr(char *symbol,char *dest); - -struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - *idx = i; - np = &sp->NPOINTS[i]; - if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) - return(np); - } - } - *idx = -1; - return(0); -} - -struct notarized_checkpoint *komodo_npptr(int32_t height) -{ - int idx; - return komodo_npptr_for_height(height, &idx); -} - -struct notarized_checkpoint *komodo_npptr_at(int idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - if (idx < sp->NUM_NPOINTS) - return &sp->NPOINTS[idx]; - return(0); -} - -int32_t komodo_prevMoMheight() -{ - static uint256 zero; - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - np = &sp->NPOINTS[i]; - if ( np->MoM != zero ) - return(np->notarized_height); - } - } - return(0); -} - -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - *hashp = sp->NOTARIZED_HASH; - *txidp = sp->NOTARIZED_DESTTXID; - *prevMoMheightp = komodo_prevMoMheight(); - return(sp->NOTARIZED_HEIGHT); - } - else - { - *prevMoMheightp = 0; - memset(hashp,0,sizeof(*hashp)); - memset(txidp,0,sizeof(*txidp)); - return(0); - } -} - -int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NOTARIZED_HEIGHT > 0 ) - { - if ( txheight < sp->NOTARIZED_HEIGHT ) - return(numconfs); - else return(1); - } - } - return(numconfs); -} - -int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) -{ - struct notarized_checkpoint *np = 0; - if ( (np= komodo_npptr(height)) != 0 ) - { - *notarized_htp = np->notarized_height; - *MoMp = np->MoM; - *kmdtxidp = np->notarized_desttxid; - *MoMoMp = np->MoMoM; - *MoMoMoffsetp = np->MoMoMoffset; - *MoMoMdepthp = np->MoMoMdepth; - *kmdstartip = np->kmdstarti; - *kmdendip = np->kmdendi; - return(np->MoMdepth & 0xffff); - } - *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; - memset(MoMp,0,sizeof(*MoMp)); - memset(MoMoMp,0,sizeof(*MoMoMp)); - memset(kmdtxidp,0,sizeof(*kmdtxidp)); - return(0); -} - -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) -{ - struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NUM_NPOINTS > 0 ) - { - flag = 0; - if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) - { - np = &sp->NPOINTS[sp->last_NPOINTSi-1]; - if ( np->nHeight < nHeight ) - { - for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); - flag = 1; - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( flag == 0 ) - { - np = 0; - for (i=0; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( np != 0 ) - { - //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); - if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) - printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); - *notarized_hashp = np->notarized_hash; - *notarized_desttxidp = np->notarized_desttxid; - return(np->notarized_height); - } - } - memset(notarized_hashp,0,sizeof(*notarized_hashp)); - memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); - return(0); -} - -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) -{ - struct notarized_checkpoint *np; - if ( notarized_height >= nHeight ) - { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); - return; - } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); -} - -void komodo_init(int32_t height) -{ - static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; - if ( 0 && height != 0 ) - printf("komodo_init ht.%d didinit.%d\n",height,didinit); - memset(&zero,0,sizeof(zero)); - if ( didinit == 0 ) - { - pthread_mutex_init(&komodo_mutex,NULL); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - if ( height >= 0 ) - { - n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); - for (k=0; k Date: Sat, 3 Nov 2018 02:22:53 +0800 Subject: [PATCH 0477/3904] fix dupe --- src/rpcrawtransaction.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 5710e502f..f446756f2 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -492,26 +492,6 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid return(-1); } -bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) -{ - CTxDestination address; txnouttype whichType; - if ( ExtractDestination(scriptPubKey,address) != 0 ) - { - strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); - return(true); - } - fprintf(stderr,"ExtractDestination failed\n"); - return(false); -} - -bool pubkey2address(char *destaddr,uint8_t *pubkey33) -{ - std::vectorpk; int32_t i; - for (i=0; i<33; i++) - pk.push_back(pubkey33[i]); - return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); -} - UniValue gettxoutproof(const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 1 && params.size() != 2)) From e024ec35fc8f106436b813f3567ff5ee11f83ed3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 03:01:39 +0800 Subject: [PATCH 0478/3904] last tim --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..6d6ecf77f 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,6 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "cc/CCutils.cpp" From cfa9c3c640a130e764ed147e03f0762b1b950e36 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 14:49:09 +0800 Subject: [PATCH 0479/3904] try this first --- src/Makefile.am | 4 ++-- src/komodo_notary.h | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 0559230c0..f18c192e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -246,8 +246,8 @@ obj/build.h: FORCE libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: zcashd -libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -DSERVER +libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSEVER libbitcoin_server_a_SOURCES = \ sendalert.cpp \ addrman.cpp \ diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6291c8e1a..8169d6117 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,8 +20,6 @@ #include "notaries_staked.h" -extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; - #define KOMODO_MAINNET_START 178999 extern char NOTARYADDRS[18][64]; @@ -234,9 +232,11 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); for (i=0; i Date: Sat, 3 Nov 2018 14:54:57 +0800 Subject: [PATCH 0480/3904] modified: src/komodo_notary.h --- src/komodo_notary.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 8169d6117..febc7e40c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -234,7 +234,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -254,7 +254,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -281,7 +281,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -302,7 +302,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -322,7 +322,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -341,7 +341,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } From be77469369ca30003afe7f36cf4a1d85d4f84202 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 14:58:50 +0800 Subject: [PATCH 0481/3904] unneded include --- src/bitcoin-cli.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 6d6ecf77f..37ed26572 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,11 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCutils.cpp" - - void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From f876160b78e9f9c3dc780ac787b37ec2bc47e4d0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:02:27 +0800 Subject: [PATCH 0482/3904] hhmmm --- src/bitcoin-cli.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 37ed26572..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,8 +76,11 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" +#include "komodo_notary.h" #include "notaries_staked.cpp" + + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From 55fd0444f6b4c5e6d5f702a4bf93d408134f3268 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:15:34 +0800 Subject: [PATCH 0483/3904] try --- src/komodo_notary.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index febc7e40c..1c90b689a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -281,6 +281,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); + fprintf(stderr, "pubkey?: %s\n", notaries_STAKED1[i][1]); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif From e126f4cecf9c4f241414af59a999c66cb4abe1ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:27:44 +0800 Subject: [PATCH 0484/3904] try --- src/script/standard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index fde836154..b2e98bf2c 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,6 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); + fprintf(stderr, "pubkey in exdest: %s\n",pubKey.GetHash().ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); @@ -263,7 +264,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) addressRet = CScriptID(uint160(vSolutions[0])); return true; } - + else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION) { addressRet = CKeyID(uint160(vSolutions[0])); From 302427b0791768ec54f15f9fbe758b951c84d900 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:39:31 +0800 Subject: [PATCH 0485/3904] try this --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index b2e98bf2c..9707b8c2e 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",pubKey.GetHash().ToString().c_str()); + fprintf(stderr, "pubkey in exdest: %s\n",pubKey.ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); From 4c93a4dd7b5e7b1ca94f70dbf8cce78e3683a1c3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:40:32 +0800 Subject: [PATCH 0486/3904] try --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 9707b8c2e..d24d278f3 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",pubKey.ToString().c_str()); + fprintf(stderr, "pubkey in exdest: %s\n",pubKey.CPubKey().ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); From ca7f0b86431378025e3f9af993fa3058be1f49dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:42:02 +0800 Subject: [PATCH 0487/3904] try --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index d24d278f3..2c3f4afc7 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",pubKey.CPubKey().ToString().c_str()); + fprintf(stderr, "pubkey in exdest: %s\n",scriptPubKey.ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); From c52c8d2a37c299d5b1569174d53db9b90cb0e459 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:44:45 +0800 Subject: [PATCH 0488/3904] fix --- src/komodo_notary.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1c90b689a..dafcbe820 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -281,8 +281,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - fprintf(stderr, "pubkey?: %s\n", notaries_STAKED1[i][1]); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); + fprintf(stderr, "pubkey?: %s\n",staked_pubkeys1[i]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif } From 4d857068593b9da3c19bb1c211f3ec34138d03dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 16:35:51 +0800 Subject: [PATCH 0489/3904] is this working now? --- src/komodo_notary.h | 11 +++++------ src/script/standard.cpp | 1 - src/wallet/rpcwallet.cpp | 16 ++++++++++++++-- src/wallet/wallet.cpp | 6 ++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index dafcbe820..e02860414 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -234,7 +234,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys0[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -254,7 +254,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -281,7 +281,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - fprintf(stderr, "pubkey?: %s\n",staked_pubkeys1[i]); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif @@ -303,7 +302,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys2[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -323,7 +322,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys3[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -342,7 +341,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys4[i]); pthread_mutex_unlock(&komodo_mutex); #endif } diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 2c3f4afc7..9aa02bfb7 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,6 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",scriptPubKey.ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 862df0c0f..dc0b19ecc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4959,6 +4959,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) } bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +extern int32_t IS_KOMODO_NOTARY; UniValue setpubkey(const UniValue& params, bool fHelp) { @@ -5005,9 +5006,20 @@ UniValue setpubkey(const UniValue& params, bool fHelp) NOTARY_ADDRESS = address.ToString(); result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); + isminetype mine = pwalletMain; + if ( IsMine(*pwalletMain, dest) == ISMINE_NO ) { + result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); + } else { + result.push_back(Pair("ismine", "true")); + std::string notaryname; + if ( StakedNotaryID(notaryname, Raddress) != -1 ) { + IS_KOMODO_NOTARY = 1; + result.push_back(Pair("IsNotary", notaryname)); + } + } #endif + } else { + result.push_back(Pair("error", "pubkey entered is invalid.")); } NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a73ea31fe..8a8f96d8f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,7 +1213,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( NOTARY_ADDRESS != "" ) + if ( NOTARY_ADDRESS != "" && IS_KOMODO_NOTARY == 1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { @@ -1252,7 +1252,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } else if ( numvinIsOurs < tx.vin.size() ) { // this means we were in a multi sig, we wil remove the utxo we spent from our wallet, - // IF there exisited a function for that. + // IF there exisited a function for that. + // Maybe check if there are any vouts unspetn in this TX + // then purge the TX from wallet if all spent? fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 2a91d7e00270bee2bccb752c13564337e1d9cd2f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 16:40:57 +0800 Subject: [PATCH 0490/3904] fix --- src/wallet/rpcwallet.cpp | 8 ++++---- src/wallet/wallet.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index dc0b19ecc..36ebb1893 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4960,6 +4960,8 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) bool pubkey2addr(char *destaddr,uint8_t *pubkey33); extern int32_t IS_KOMODO_NOTARY; +extern uint8_t NOTARY_PUBKEY33[]; +extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; UniValue setpubkey(const UniValue& params, bool fHelp) { @@ -4989,8 +4991,6 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -5006,8 +5006,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) NOTARY_ADDRESS = address.ToString(); result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET - isminetype mine = pwalletMain; - if ( IsMine(*pwalletMain, dest) == ISMINE_NO ) { + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + if ( mine == ISMINE_NO ) { result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8a8f96d8f..50a825cc6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,6 +1202,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; +extern int32_t IS_KOMODO_NOTARY; bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { @@ -1254,7 +1255,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl // this means we were in a multi sig, we wil remove the utxo we spent from our wallet, // IF there exisited a function for that. // Maybe check if there are any vouts unspetn in this TX - // then purge the TX from wallet if all spent? + // then purge the TX from wallet if all spent? fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From a673e42f9525069be6a668a672ef4ccafe1ec04b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 16:43:39 +0800 Subject: [PATCH 0491/3904] include --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 36ebb1893..292f4666c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -20,6 +20,7 @@ #include "primitives/transaction.h" #include "zcbenchmarks.h" #include "script/interpreter.h" +#include "notaries_staked.h" #include "utiltime.h" #include "asyncrpcoperation.h" From 102b0839f846bc76e175ce1223a028e0bf82ae4b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:09:13 +0800 Subject: [PATCH 0492/3904] do addresss for -pubkey? --- src/komodo_utils.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a9d16fd52..732b1ecdb 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1483,10 +1483,13 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { - int32_t i,notaryid; + int32_t i,notaryid; char Raddress[18]; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = address.ToString(); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From f307fe52bf7a44bbedad2972a60072130053ef93 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:11:36 +0800 Subject: [PATCH 0493/3904] try --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 732b1ecdb..f248d96f5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -14,6 +14,7 @@ ******************************************************************************/ #include "komodo_defs.h" #include "cc/utils.h" +#include "cc/CCinclude.h" #ifdef _WIN32 #include From eb36c662f6a8ebb2a31454768e384a1da9e124ac Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:13:37 +0800 Subject: [PATCH 0494/3904] define --- src/komodo_utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f248d96f5..3c366770c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1488,9 +1488,11 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; +#ifdef SERVER pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); +#endif komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From f36ad447b8fdf242546fca23ee0586a52ce176fc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:40:27 +0800 Subject: [PATCH 0495/3904] fix --- src/komodo_notary.h | 6 ++++++ src/komodo_utils.h | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e02860414..668378eef 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -700,6 +700,12 @@ void komodo_init(int32_t height) { pthread_mutex_init(&komodo_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); +#ifdef SERVER + char Raddress[18]; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = address.ToString(); +#endif if ( height >= 0 ) { n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 3c366770c..85d18f169 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1484,15 +1484,10 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { - int32_t i,notaryid; char Raddress[18]; + int32_t i,notaryid; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; -#ifdef SERVER - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = address.ToString(); -#endif komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From 798999bdae40cdeb8d3e6c029f1ccae27d98158a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:43:54 +0800 Subject: [PATCH 0496/3904] try print --- src/komodo_notary.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 668378eef..d180f114f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -703,6 +703,7 @@ void komodo_init(int32_t height) #ifdef SERVER char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + printf("address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); #endif From 02cc6355d9037e9a398706add5287a939e55073e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:47:51 +0800 Subject: [PATCH 0497/3904] try --- src/komodo_notary.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d180f114f..de255ca8f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -701,8 +701,9 @@ void komodo_init(int32_t height) pthread_mutex_init(&komodo_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); #ifdef SERVER - char Raddress[18]; - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + char Raddress[18]; uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); printf("address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); From 5f5a803d5176040a1f1f7b6b7611432c95982d67 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:51:06 +0800 Subject: [PATCH 0498/3904] fix prit --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index de255ca8f..18b21d37e 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -704,7 +704,7 @@ void komodo_init(int32_t height) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - printf("address: %s\n",Raddress); + fprintf(stderr,"address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); #endif From 5349a582ba28ce82cc4b50a0d27aaae9fcf2ffaa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:59:33 +0800 Subject: [PATCH 0499/3904] try --- src/wallet/rpcwallet.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 292f4666c..6cfa3fed5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5031,7 +5031,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp) } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + if ( NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() == false ) { + result.push_back(Pair("address", NOTARY_ADDRESS)); + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + } return result; } From 20d6d163994462a1e4e056725354370b9545a6cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:32:05 +0800 Subject: [PATCH 0500/3904] add -stakednotary daemon flag --- src/komodo_globals.h | 2 +- src/komodo_notary.h | 10 +++++++++- src/komodo_utils.h | 3 ++- src/rpcmisc.cpp | 13 ++++++++++--- src/wallet/wallet.cpp | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index bf96cfa44..eb4597011 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 18b21d37e..9a866a5eb 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -704,9 +704,17 @@ void komodo_init(int32_t height) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - fprintf(stderr,"address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); + if ( IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.empty() != 0 ) { + std::string notaryname; + if (StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) != -1 ) { + IS_STAKED_NOTARY = 1; + IS_KOMODO_NOTARY = 0; + } else { + IS_STAKED_NOTARY = 0; + } + } #endif if ( height >= 0 ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 85d18f169..4fb95dcca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1508,6 +1508,7 @@ void komodo_args(char *argv0) extern const char *Notaries_elected1[][2]; std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); + IS_STAKED_NOTARY = GetBoolArg("-stakednotary", false); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; @@ -1515,7 +1516,7 @@ void komodo_args(char *argv0) fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); DONATION_PUBKEY = GetArg("-donation", ""); NOTARY_PUBKEY = GetArg("-pubkey", ""); - if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) + if ( strlen(NOTARY_PUBKEY.c_str()) == 66 || IS_STAKED_NOTARY == false ) { USE_EXTERNAL_PUBKEY = 1; if ( IS_KOMODO_NOTARY == 0 ) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a1d576d58..824758b26 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -13,6 +13,7 @@ #include "timedata.h" #include "txmempool.h" #include "util.h" +#include "notaries_staked.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #include "wallet/walletdb.h" @@ -50,11 +51,12 @@ int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); #define KOMODO_VERSION "0.2.1" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; @@ -152,13 +154,18 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); { - char pubkeystr[65]; int32_t notaryid; - if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) + char pubkeystr[65]; int32_t notaryid; std::string notaryname; + if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_STAKED_NOTARY == 0 )) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.emtpy() == false ) { + notaryid = StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("notaryname", notaryname)); + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } else if ( NOTARY_PUBKEY33[0] != 0 ) { obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 50a825cc6..f770c8e18 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( NOTARY_ADDRESS != "" && IS_KOMODO_NOTARY == 1 ) + if ( NOTARY_ADDRESS != "" && IS_STAKED_NOTARY == 1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { From 793ebde434ac68e6da56d1a92c6a560b9a8b4c1d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:42:13 +0800 Subject: [PATCH 0501/3904] fix --- src/komodo_notary.h | 2 +- src/wallet/wallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9a866a5eb..c9696e34f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -708,7 +708,7 @@ void komodo_init(int32_t height) NOTARY_ADDRESS = address.ToString(); if ( IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.empty() != 0 ) { std::string notaryname; - if (StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) != -1 ) { + if (StakedNotaryID(notaryname, Raddress) != -1 ) { IS_STAKED_NOTARY = 1; IS_KOMODO_NOTARY = 0; } else { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f770c8e18..26689cfde 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,7 +1202,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -extern int32_t IS_KOMODO_NOTARY; +extern int32_t IS_STAKED_NOTARY; bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { From 0b5ef8057fb728fcf801a56cf250ec6f3b391b13 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:43:31 +0800 Subject: [PATCH 0502/3904] fix last --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 824758b26..2e4613ac6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -66,7 +66,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; - extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; + extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" From 7eca3743c80821e8d277967cc5056e4f2e13fc00 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:50:08 +0800 Subject: [PATCH 0503/3904] fix --- src/rpcmisc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 2e4613ac6..083955db2 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -154,7 +154,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); { - char pubkeystr[65]; int32_t notaryid; std::string notaryname; + char pubkeystr[65]; int32_t notaryid; std::string notaryname; char *Raddress; if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_STAKED_NOTARY == 0 )) { obj.push_back(Pair("notaryid", notaryid)); @@ -162,7 +162,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.emtpy() == false ) { - notaryid = StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) + Raddress = NOTARY_ADDRESS.c_str(); + notaryid = StakedNotaryID(notaryname, Raddress) obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); From 8df94887b3215d2898ce09cd749ab7d65b390327 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:51:31 +0800 Subject: [PATCH 0504/3904] fix better --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 083955db2..e656ab72a 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -161,7 +161,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.emtpy() == false ) { + } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { Raddress = NOTARY_ADDRESS.c_str(); notaryid = StakedNotaryID(notaryname, Raddress) obj.push_back(Pair("notaryid", notaryid)); From ac99a6b738609de933cb9a67941d522f2f7f2b31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:52:06 +0800 Subject: [PATCH 0505/3904] ; --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index e656ab72a..0f8669757 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -163,7 +163,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { Raddress = NOTARY_ADDRESS.c_str(); - notaryid = StakedNotaryID(notaryname, Raddress) + notaryid = StakedNotaryID(notaryname, Raddress); obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); From 59d1c8e2ae8f3943b4da4d19f5dd88f3af782978 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:53:30 +0800 Subject: [PATCH 0506/3904] ? --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 0f8669757..fbb183717 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -162,7 +162,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { - Raddress = NOTARY_ADDRESS.c_str(); + Raddress = (char *)NOTARY_ADDRESS.c_str(); notaryid = StakedNotaryID(notaryname, Raddress); obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); From 2dd5abbcdf997fe970c4a2866435bac35646d36b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:59:59 +0800 Subject: [PATCH 0507/3904] try --- src/rpcmisc.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index fbb183717..f0062ebc4 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -51,7 +51,7 @@ int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); @@ -155,18 +155,17 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("errors", GetWarnings("statusbar"))); { char pubkeystr[65]; int32_t notaryid; std::string notaryname; char *Raddress; - if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_STAKED_NOTARY == 0 )) - { - obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("pubkey", pubkeystr)); - if ( KOMODO_LASTMINED != 0 ) - obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { + if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY == 1 ) { Raddress = (char *)NOTARY_ADDRESS.c_str(); notaryid = StakedNotaryID(notaryname, Raddress); obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); + } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_KOMODO_NOTARY == 1 ) ) { + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("pubkey", pubkeystr)); + if ( KOMODO_LASTMINED != 0 ) + obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 ) { obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } From 482f2dcb744a8a41e098bd07f4c73509be617d3b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:04:31 +0800 Subject: [PATCH 0508/3904] try fix --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c9696e34f..f9ad785bf 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -706,7 +706,7 @@ void komodo_init(int32_t height) pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); - if ( IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.empty() != 0 ) { + if ( IS_STAKED_NOTARY != 0 || NOTARY_ADDRESS.empty() != 0 ) { std::string notaryname; if (StakedNotaryID(notaryname, Raddress) != -1 ) { IS_STAKED_NOTARY = 1; From dd80445e563d4058185e106d695bbebab21671a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:12:36 +0800 Subject: [PATCH 0509/3904] fix :Wq qqq --- src/komodo_notary.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index f9ad785bf..60655f41d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -706,14 +706,12 @@ void komodo_init(int32_t height) pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); - if ( IS_STAKED_NOTARY != 0 || NOTARY_ADDRESS.empty() != 0 ) { - std::string notaryname; - if (StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_STAKED_NOTARY = 1; - IS_KOMODO_NOTARY = 0; - } else { - IS_STAKED_NOTARY = 0; - } + std::string notaryname; + if (StakedNotaryID(notaryname, Raddress) != -1 ) { + IS_STAKED_NOTARY = 1; + IS_KOMODO_NOTARY = 0; + } else { + IS_STAKED_NOTARY = 0; } #endif if ( height >= 0 ) From 00c9e899f12826e7caacf367811d4bd731baf1db Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:20:54 +0800 Subject: [PATCH 0510/3904] try --- src/rpcmisc.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f0062ebc4..3b897e892 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -154,10 +154,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); { - char pubkeystr[65]; int32_t notaryid; std::string notaryname; char *Raddress; - if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY == 1 ) { - Raddress = (char *)NOTARY_ADDRESS.c_str(); - notaryid = StakedNotaryID(notaryname, Raddress); + char pubkeystr[65]; int32_t notaryid; std::string notaryname; + if ( (NOTARY_PUBKEY33[0] != 0) && (notaryid = StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); From 6b62237c9149361058c1bc7155521f5e2eb216bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:27:33 +0800 Subject: [PATCH 0511/3904] try --- src/wallet/rpcwallet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6cfa3fed5..cdfd5633d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5005,7 +5005,6 @@ UniValue setpubkey(const UniValue& params, bool fHelp) { CTxDestination dest = address.Get(); NOTARY_ADDRESS = address.ToString(); - result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { @@ -5014,7 +5013,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) result.push_back(Pair("ismine", "true")); std::string notaryname; if ( StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_KOMODO_NOTARY = 1; + IS_STAKED_NOTARY = 1; result.push_back(Pair("IsNotary", notaryname)); } } From 44ebe794f78aeca589340e4a1737e45f6718fb9b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:28:50 +0800 Subject: [PATCH 0512/3904] try --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cdfd5633d..88f4ece82 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4960,7 +4960,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) } bool pubkey2addr(char *destaddr,uint8_t *pubkey33); -extern int32_t IS_KOMODO_NOTARY; +extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; From 72bbdaef489b2dead6fc066dd7856d526110df9d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:32:54 +0800 Subject: [PATCH 0513/3904] add print --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9d413fd5d..c97a03dee 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,6 +156,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { + fprintf(stderr, "%s\n", NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); return(i); From 023adb99c2b5d85fee6624e3177285ccec6632a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:37:57 +0800 Subject: [PATCH 0514/3904] fix --- src/rpcmisc.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 3b897e892..1c044c030 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -153,20 +153,17 @@ UniValue getinfo(const UniValue& params, bool fHelp) #endif obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); - { + if ( NOTARY_PUBKEY33[0] != 0 ) { char pubkeystr[65]; int32_t notaryid; std::string notaryname; - if ( (NOTARY_PUBKEY33[0] != 0) && (notaryid = StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { + if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); - obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); - } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_KOMODO_NOTARY == 1 ) ) { + } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) - obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } else if ( NOTARY_PUBKEY33[0] != 0 ) { - obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); + obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } if ( ASSETCHAINS_CC != 0 ) obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); From 4cfe878d46a0a0204e0876c0a544ea720ecea4f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:42:59 +0800 Subject: [PATCH 0515/3904] try --- src/notaries_staked.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c97a03dee..2d3bd9e63 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,9 +156,10 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "%s\n", NOTARYADDRS[i]); + fprintf(stderr, "%ld :: %s\n",i, NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); + fprintf(stderr, "FOUND: %ld :: %s\n",i,notaryname.c_str()); return(i); } } From 152d34f3a468159808702e4758828e263d9b5ab7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:47:18 +0800 Subject: [PATCH 0516/3904] fix --- src/notaries_staked.cpp | 2 -- src/rpcmisc.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 2d3bd9e63..9d413fd5d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,10 +156,8 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "%ld :: %s\n",i, NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - fprintf(stderr, "FOUND: %ld :: %s\n",i,notaryname.c_str()); return(i); } } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 1c044c030..37e5bc901 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -155,7 +155,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("errors", GetWarnings("statusbar"))); if ( NOTARY_PUBKEY33[0] != 0 ) { char pubkeystr[65]; int32_t notaryid; std::string notaryname; - if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { + if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str())) != -1 ) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { From 16b97d7f2200507805e9f79c4ab3e9cbc87ce08b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 20:42:59 +0800 Subject: [PATCH 0517/3904] make function, so IS notaty can update on era change --- src/komodo_notary.h | 8 +------- src/notaries_staked.cpp | 20 ++++++++++++++++++-- src/notaries_staked.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 60655f41d..596ee69d1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -706,13 +706,7 @@ void komodo_init(int32_t height) pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); - std::string notaryname; - if (StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_STAKED_NOTARY = 1; - IS_KOMODO_NOTARY = 0; - } else { - IS_STAKED_NOTARY = 0; - } + updateStakedNotary(); #endif if ( height >= 0 ) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9d413fd5d..594a31d77 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,8 @@ #include extern char NOTARYADDRS[18][64]; -extern int32_t STAKED_ERA; +extern std::string NOTARY_ADDRESS; +extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = @@ -114,6 +115,19 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; +int updateStakedNotary() { + std::string notaryname; + pthread_mutex_lock(&komodo_mutex); + if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { + IS_STAKED_NOTARY = 1; + IS_KOMODO_NOTARY = 0; + } else { + IS_STAKED_NOTARY = 0; + } + pthread_mutex_unlock(&komodo_mutex); + return(0); +} + int STAKED_era(int timestamp) { int era; @@ -128,8 +142,10 @@ int STAKED_era(int timestamp) else era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - if ( era > STAKED_ERA ) + if ( era > STAKED_ERA ) { STAKED_ERA = era; + updateStakedNotary(); + } return(era); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index d3927e68f..8f0802eb3 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -25,6 +25,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); +void updateStakedNotary(); int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); From 0f6dac83806a356a18cf1fcb4cdb0c155ae19a15 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 20:47:50 +0800 Subject: [PATCH 0518/3904] fix --- src/notaries_staked.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 594a31d77..bd404ab33 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -6,6 +6,7 @@ extern char NOTARYADDRS[18][64]; extern std::string NOTARY_ADDRESS; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; +extern pthread_mutex_t komodo_mutex; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = @@ -115,7 +116,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -int updateStakedNotary() { +void updateStakedNotary() { std::string notaryname; pthread_mutex_lock(&komodo_mutex); if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { From 1a5c39bcfdaf094844269f108db09bdf69e462e2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 20:48:41 +0800 Subject: [PATCH 0519/3904] return --- src/notaries_staked.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index bd404ab33..3fec522f7 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -126,7 +126,6 @@ void updateStakedNotary() { IS_STAKED_NOTARY = 0; } pthread_mutex_unlock(&komodo_mutex); - return(0); } int STAKED_era(int timestamp) From 818f6fc43b1db3d7de54a8bd97e649424737093f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 21:15:01 +0800 Subject: [PATCH 0520/3904] dupe --- src/notaries_staked.cpp | 4 +-- src/wallet/rpcwallet.cpp | 70 ++-------------------------------------- 2 files changed, 5 insertions(+), 69 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3fec522f7..bf59a68b7 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,14 +118,14 @@ int is_STAKED(const char *chain_name) { void updateStakedNotary() { std::string notaryname; - pthread_mutex_lock(&komodo_mutex); + //pthread_mutex_lock(&komodo_mutex); if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { IS_STAKED_NOTARY = 1; IS_KOMODO_NOTARY = 0; } else { IS_STAKED_NOTARY = 0; } - pthread_mutex_unlock(&komodo_mutex); + //pthread_mutex_unlock(&komodo_mutex); } int STAKED_era(int timestamp) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a0d88dc48..7e2109329 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4566,7 +4566,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); if (!EnsureWalletIsAvailable(0)) return 0; - + const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4729,7 +4729,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; - + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); @@ -4939,70 +4939,6 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vectorcs_wallet : NULL); -#else - LOCK(cs_main); -#endif - - char Raddress[18]; - uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 ) { - if (strlen(params[0].get_str().c_str()) == 66) { - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { - result.push_back(Pair("error", "pubkey entered is invalid.")); - } else { - CBitcoinAddress address(Raddress); - bool isValid = address.IsValid(); - if (isValid) - { - CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); - result.push_back(Pair("address", currentAddress)); -#ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); -#endif - } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - } - } else { - result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } - } else { - result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); - } - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); - return result; -} - UniValue channelsaddress(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector destpubkey; CPubKey pk,pk2; char destaddr[64]; @@ -6784,7 +6720,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR); CTxDestination address; if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + const CKeyStore& keystore = *pwalletMain; CAmount nValues[64],nValues2[64],nValue,total,total2; int32_t i,segid; assert(pwalletMain != NULL); From afcd147d30af68e4ce960d2efc84cd47e9b46ee7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 21:24:23 +0800 Subject: [PATCH 0521/3904] dupe modified: src/komodo_globals.h --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 4c3c08af0..2070e1240 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[18][64]; From fd31d05ab581218c86469786db1c36716f282d8b Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Sat, 3 Nov 2018 09:31:22 -0400 Subject: [PATCH 0522/3904] Update assetchains.json --- src/assetchains.json | 82 +++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 54 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index aa7c8bfb4..454852efe 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -1,84 +1,58 @@ [ { - "ac_name": "STAKEDB1", + "ac_name": "CFEK", "ac_supply": "100000", - "ac_reward" : "1000000000", - "ac_cc": "667", + "ac_reward": "10000000000000", + "ac_staked": "51", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDW1", - "ac_supply": "100000", - "ac_reward" : "1000000000", - "ac_cc": "667", + "ac_name": "CFEKED", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDPERC", - "ac_supply": "1000000", - "ac_reward" : "1000000000", - "ac_cc": "667", - "ac_perc": "10000000", - "ac_pubkey": "03bd221868abc063b54a3fceafb9898b1931ed767298a17ac0c9923500a7c60e4b", + "ac_name": "CFEKING", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDS1", - "ac_supply": "1000000", - "ac_reward" : "1000000000", - "ac_cc": "667", - "ac_staked": "10", + "ac_name": "CFEKLF", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDS9", - "ac_supply": "1000000", - "ac_reward" : "1000000000", - "ac_cc": "667", - "ac_staked": "90", - "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "STAKEDED", - "ac_supply": "1072452", - "ac_reward" : "1000000000", - "ac_cc": "667", - "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "STAKEDPRIV", - "ac_supply": "1000000", - "ac_reward" : "10000000000", - "ac_private": "1", - "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "STAKEDCCP", - "ac_supply": "1000000", - "ac_reward" : "10000000000", - "ac_private": "1", - "ac_cc": "667", + "ac_name": "CFEKMLT", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" From 565a17dc86b73fd9d84425f3672235f24947e740 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 15:53:30 +0800 Subject: [PATCH 0523/3904] try this please work --- src/komodo_notary.h | 8 -------- src/komodo_utils.h | 7 ++++--- src/notaries_staked.cpp | 42 ++++++++++++++++++++++++++-------------- src/notaries_staked.h | 3 ++- src/wallet/rpcwallet.cpp | 26 ++++++++++++------------- src/wallet/wallet.cpp | 2 +- 6 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 596ee69d1..e02860414 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -700,14 +700,6 @@ void komodo_init(int32_t height) { pthread_mutex_init(&komodo_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); -#ifdef SERVER - char Raddress[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = address.ToString(); - updateStakedNotary(); -#endif if ( height >= 0 ) { n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 36c93cedd..2a0452f1f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1508,7 +1508,7 @@ void komodo_args(char *argv0) extern const char *Notaries_elected1[][2]; std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); - IS_STAKED_NOTARY = GetBoolArg("-stakednotary", false); + IS_STAKED_NOTARY = GetArg("-stakednotary", -1); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; @@ -1516,7 +1516,7 @@ void komodo_args(char *argv0) fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); DONATION_PUBKEY = GetArg("-donation", ""); NOTARY_PUBKEY = GetArg("-pubkey", ""); - if ( strlen(NOTARY_PUBKEY.c_str()) == 66 || IS_STAKED_NOTARY == false ) + if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { USE_EXTERNAL_PUBKEY = 1; if ( IS_KOMODO_NOTARY == 0 ) @@ -1525,11 +1525,12 @@ void komodo_args(char *argv0) if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 ) { IS_KOMODO_NOTARY = 1; + IS_STAKED_NOTARY = -1; fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); break; } } - //KOMODO_PAX = 1; + //KOMODO_PAX = 1; } //else KOMODO_PAX = GetArg("-pax",0); name = GetArg("-ac_name",""); if ( argv0 != 0 ) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index bf59a68b7..c10d21a8f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,7 @@ #include "notaries_staked.h" #include "crosschain.h" +#include "cc/CCinclude.h" #include extern char NOTARYADDRS[18][64]; @@ -116,21 +117,21 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -void updateStakedNotary() { +int8_t updateStakedNotary() { std::string notaryname; - //pthread_mutex_lock(&komodo_mutex); - if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { - IS_STAKED_NOTARY = 1; - IS_KOMODO_NOTARY = 0; - } else { - IS_STAKED_NOTARY = 0; - } - //pthread_mutex_unlock(&komodo_mutex); + char Raddress[18]; uint8_t pubkey33[33]; + pthread_mutex_lock(&komodo_mutex); + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + NOTARY_ADDRESS.clear(); + NOTARY_ADDRESS.assign(Raddress); + pthread_mutex_unlock(&komodo_mutex); + return(StakedNotaryID(notaryname,Raddress)); } int STAKED_era(int timestamp) { - int era; + int8_t era, didera; if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -142,9 +143,18 @@ int STAKED_era(int timestamp) else era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - if ( era > STAKED_ERA ) { - STAKED_ERA = era; - updateStakedNotary(); + if ( era > STAKED_ERA || didera == 0 ) + { + STAKED_ERA = era; + if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) + { + if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + { + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "INIT.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + } + didera++; + } } return(era); }; @@ -171,13 +181,15 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { } int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { + int found = -1; for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - return(i); + found = i; } + fprintf(stderr, "[%ld] %s\n",i,NOTARYADDRS[i]); } - return(-1); + return(found); } CrosschainAuthority Choose_auth_STAKED(int chosen_era) { diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 8f0802eb3..de502eb6d 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -3,6 +3,7 @@ #define NOTARIES_STAKED #include "crosschain.h" +#include "cc/CCinclude.h" static const int STAKED_ERA_GAP = 777; @@ -25,7 +26,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); -void updateStakedNotary(); +int8_t updateStakedNotary(); int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7e2109329..c56d60a40 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4967,7 +4967,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) } bool pubkey2addr(char *destaddr,uint8_t *pubkey33); -extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY; +extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; @@ -4994,7 +4994,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) #ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); #else - LOCK(cs_main); + LOCK2(cs_main); #endif char Raddress[18]; @@ -5018,18 +5018,18 @@ UniValue setpubkey(const UniValue& params, bool fHelp) result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); - std::string notaryname; - if ( StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_STAKED_NOTARY = 1; - result.push_back(Pair("IsNotary", notaryname)); - } - } #endif - } else { + std::string notaryname; + if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { + result.push_back(Pair("IsNotary", notaryname)); + IS_KOMODO_NOTARY = 0; + USE_EXTERNAL_PUBKEY = 1; + } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + } + } else result.push_back(Pair("error", "pubkey entered is invalid.")); - } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); @@ -5037,7 +5037,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - if ( NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() == false ) { + if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { result.push_back(Pair("address", NOTARY_ADDRESS)); result.push_back(Pair("pubkey", NOTARY_PUBKEY)); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 26689cfde..b4d61fddc 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( NOTARY_ADDRESS != "" && IS_STAKED_NOTARY == 1 ) + if ( !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { From d986a9be49cbdf1a8a1a0e56876bb3109759d97a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:37:22 +0800 Subject: [PATCH 0524/3904] fix --- src/notaries_staked.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c10d21a8f..868763cc0 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -5,9 +5,10 @@ #include extern char NOTARYADDRS[18][64]; -extern std::string NOTARY_ADDRESS; +extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t komodo_mutex; +extern uint8_t NOTARY_PUBKEY33[33]; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = From c9c5655377a8466e13b76a06e91dfde50cefa480 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:39:59 +0800 Subject: [PATCH 0525/3904] fix --- src/notaries_staked.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 868763cc0..3fcd6c418 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,6 +118,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; +#ifdef SERVER0 int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; @@ -129,6 +130,7 @@ int8_t updateStakedNotary() { pthread_mutex_unlock(&komodo_mutex); return(StakedNotaryID(notaryname,Raddress)); } +#endif int STAKED_era(int timestamp) { From bf743f3e9397792c39866f0d23f0ba8ce782a7a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:44:05 +0800 Subject: [PATCH 0526/3904] try --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3fcd6c418..c0972213f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,7 +118,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -#ifdef SERVER0 +#ifdef SERVER int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; From 5c3d966b17a13a60a5104b44dab2347455317248 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:45:51 +0800 Subject: [PATCH 0527/3904] try --- src/notaries_staked.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c0972213f..06ec4abfe 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -130,6 +130,10 @@ int8_t updateStakedNotary() { pthread_mutex_unlock(&komodo_mutex); return(StakedNotaryID(notaryname,Raddress)); } +#else +int8_t updateStakedNotary() { + return(-1) +} #endif int STAKED_era(int timestamp) From 93c2aac037e2685d5b19550a8b1a58f81b8f1a80 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:46:41 +0800 Subject: [PATCH 0528/3904] ; --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 06ec4abfe..4b50c01b4 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -132,7 +132,7 @@ int8_t updateStakedNotary() { } #else int8_t updateStakedNotary() { - return(-1) + return(-1); } #endif From e32a1ae447fa3f930afe3e04396cf757a5faefee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:54:31 +0800 Subject: [PATCH 0529/3904] prints fix --- src/notaries_staked.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 4b50c01b4..d44dad31d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -138,7 +138,8 @@ int8_t updateStakedNotary() { int STAKED_era(int timestamp) { - int8_t era, didera; + int8_t era = 0; + static int didera; if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -158,7 +159,7 @@ int STAKED_era(int timestamp) if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "INIT.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); } didera++; } @@ -188,15 +189,13 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { } int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { - int found = -1; for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - found = i; + return(i); } - fprintf(stderr, "[%ld] %s\n",i,NOTARYADDRS[i]); } - return(found); + return(-1); } CrosschainAuthority Choose_auth_STAKED(int chosen_era) { From 629d69debe6e514d2b0bd34bd0436c0a781b25c7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:02:08 +0800 Subject: [PATCH 0530/3904] print --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d44dad31d..07f7b3dee 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -125,6 +125,7 @@ int8_t updateStakedNotary() { pthread_mutex_lock(&komodo_mutex); decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + fprintf(stderr, "Raddress: %s\n",Raddress); NOTARY_ADDRESS.clear(); NOTARY_ADDRESS.assign(Raddress); pthread_mutex_unlock(&komodo_mutex); From e712367feae426ff6ef232d3be10c294cd8700e6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:08:51 +0800 Subject: [PATCH 0531/3904] i --- src/notaries_staked.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 07f7b3dee..d1640403b 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -125,7 +125,6 @@ int8_t updateStakedNotary() { pthread_mutex_lock(&komodo_mutex); decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - fprintf(stderr, "Raddress: %s\n",Raddress); NOTARY_ADDRESS.clear(); NOTARY_ADDRESS.assign(Raddress); pthread_mutex_unlock(&komodo_mutex); @@ -152,11 +151,15 @@ int STAKED_era(int timestamp) else era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. + + fprintf(stderr, "era.%d stakedEra.%s didea.%d\n",era,STAKED_ER,didera); if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; + fprintf(stderr, "NUMBER 2 era.%d stakedEra.%s\n",era,STAKED_ERA); if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { + fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; @@ -193,6 +196,7 @@ int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *R for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); + printf("notary number: %ld\n",i ); return(i); } } From 955510333cfb5fa76d162f40437fa34585e65c32 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:16:18 +0800 Subject: [PATCH 0532/3904] fix --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d1640403b..c22168aaf 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -152,11 +152,11 @@ int STAKED_era(int timestamp) era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - fprintf(stderr, "era.%d stakedEra.%s didea.%d\n",era,STAKED_ER,didera); + fprintf(stderr, "era.%d stakedEra.%d didea.%d\n",era,STAKED_ERA,didera); if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - fprintf(stderr, "NUMBER 2 era.%d stakedEra.%s\n",era,STAKED_ERA); + fprintf(stderr, "NUMBER 2 era.%d stakedEra.%d\n",era,STAKED_ERA); if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); From ec87ec9af5b7cb61d786ee77bac354adeb8a5247 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:19:50 +0800 Subject: [PATCH 0533/3904] fix --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c22168aaf..82323513d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -152,7 +152,7 @@ int STAKED_era(int timestamp) era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - fprintf(stderr, "era.%d stakedEra.%d didea.%d\n",era,STAKED_ERA,didera); + //fprintf(stderr, "era.%d stakedEra.%d didea.%d\n",era,STAKED_ERA,didera); if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; @@ -160,7 +160,7 @@ int STAKED_era(int timestamp) if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); - if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + if ( ( IS_STAKED_NOTARY= updateStakedNotary() > -1 ) ) { IS_KOMODO_NOTARY = 0; fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); From e30bbc5dd7de8632b86582c478dc70dbbca99ac2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:25:23 +0800 Subject: [PATCH 0534/3904] try this --- src/notaries_staked.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 82323513d..7bb1ee003 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,11 +156,10 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - fprintf(stderr, "NUMBER 2 era.%d stakedEra.%d\n",era,STAKED_ERA); if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { - fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); - if ( ( IS_STAKED_NOTARY= updateStakedNotary() > -1 ) ) + IS_STAKED_NOTARY= updateStakedNotary(); + if ( IS_STAKED_NOTARY > -1 ) { IS_KOMODO_NOTARY = 0; fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); @@ -194,6 +193,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { + fprintf(stderr, "Raddress: %s Array address: %s\n",Raddress,NOTARYADDRS[13]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); printf("notary number: %ld\n",i ); From 366554f203ca14accce8ceac5156c4d1700b9f9d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:26:24 +0800 Subject: [PATCH 0535/3904] try --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 7bb1ee003..be1505d54 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -159,6 +159,7 @@ int STAKED_era(int timestamp) if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { IS_STAKED_NOTARY= updateStakedNotary(); + fprintf(stderr, "notary number: %d\n", IS_STAKED_NOTARY); if ( IS_STAKED_NOTARY > -1 ) { IS_KOMODO_NOTARY = 0; From 82628b5640050276e49b11ce8d921229a4edb071 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:37:56 +0800 Subject: [PATCH 0536/3904] aok --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index be1505d54..f551f6d51 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,7 +156,7 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) + if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0][0] != 0 ) { IS_STAKED_NOTARY= updateStakedNotary(); fprintf(stderr, "notary number: %d\n", IS_STAKED_NOTARY); From c9ba061ecb3415e2b64e95ec2c2d49b571e602f8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:41:58 +0800 Subject: [PATCH 0537/3904] workdin? --- src/notaries_staked.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index f551f6d51..7e690fab3 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -158,9 +158,7 @@ int STAKED_era(int timestamp) STAKED_ERA = era; if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0][0] != 0 ) { - IS_STAKED_NOTARY= updateStakedNotary(); - fprintf(stderr, "notary number: %d\n", IS_STAKED_NOTARY); - if ( IS_STAKED_NOTARY > -1 ) + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); @@ -194,10 +192,9 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "Raddress: %s Array address: %s\n",Raddress,NOTARYADDRS[13]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - printf("notary number: %ld\n",i ); + //printf("notary number: %ld\n",i ); return(i); } } From d6dfe034855bb552c07e52346014c33c5a9a5b68 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:18:34 +0800 Subject: [PATCH 0538/3904] here we go :D --- src/komodo_notary.h | 74 ++++++++------------------------------ src/komodo_utils.h | 13 ++++--- src/notaries_staked.cpp | 78 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 94 insertions(+), 71 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e02860414..88ce299f7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,11 +22,6 @@ #define KOMODO_MAINNET_START 178999 -extern char NOTARYADDRS[18][64]; - -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - const char *Notaries_genesis[][2] = { { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, @@ -206,8 +201,6 @@ const char *Notaries_elected1[][2] = }; #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; @@ -220,6 +213,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam timestamp = komodo_heightstamp(height); else if ( ASSETCHAINS_SYMBOL[0] == 0 ) timestamp = 0; + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) { @@ -232,11 +226,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); for (i=0; i STAKED_ERA || didera == 0 ) { + pthread_mutex_lock(&komodo_mutex); STAKED_ERA = era; - if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0][0] != 0 ) + if ( NOTARY_PUBKEY33[0] != 0 ) { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); + fprintf(stderr, "Staked Notary Protection Active! INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); } didera++; } + pthread_mutex_unlock(&komodo_mutex); } return(era); }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; + static char ChainName[65]; + + if ( ChainName[0] == 0 ) { + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + strcpy(ChainName,"KMD"); + else + strcpy(ChainName,ASSETCHAINS_SYMBOL); + } + if ( STAKED_ERA != 0 ) { switch (STAKED_ERA) { case 1: + if ( didstaked1 == 0 ) { + for (i=0; i Date: Sun, 4 Nov 2018 20:38:06 +0800 Subject: [PATCH 0539/3904] i --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index b758a74a8..c327f11e4 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -169,7 +169,7 @@ int STAKED_era(int timestamp) }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - int8_t notaryID = -1; + int8_t notaryID = -1; int i; static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static char ChainName[65]; From 87542679855527ad6957b9f494f167d02a9fc0a3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:45:23 +0800 Subject: [PATCH 0540/3904] disable mutex --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c327f11e4..0951e130a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -152,7 +152,7 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { - pthread_mutex_lock(&komodo_mutex); + //pthread_mutex_lock(&komodo_mutex); STAKED_ERA = era; if ( NOTARY_PUBKEY33[0] != 0 ) { @@ -163,7 +163,7 @@ int STAKED_era(int timestamp) } didera++; } - pthread_mutex_unlock(&komodo_mutex); + //pthread_mutex_unlock(&komodo_mutex); } return(era); }; From 26a2155af5964d7a13046b7483e35f69b383bcc7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:50:50 +0800 Subject: [PATCH 0541/3904] fix --- src/notaries_staked.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 0951e130a..41e707f7f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64],ASSETCHAINS_SYMBOL; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t komodo_mutex; @@ -152,7 +152,6 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { - //pthread_mutex_lock(&komodo_mutex); STAKED_ERA = era; if ( NOTARY_PUBKEY33[0] != 0 ) { @@ -163,7 +162,6 @@ int STAKED_era(int timestamp) } didera++; } - //pthread_mutex_unlock(&komodo_mutex); } return(era); }; @@ -175,7 +173,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { static char ChainName[65]; if ( ChainName[0] == 0 ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) strcpy(ChainName,"KMD"); else strcpy(ChainName,ASSETCHAINS_SYMBOL); From d41373edec9e6dad7ab288aa026748348ede585a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:52:03 +0800 Subject: [PATCH 0542/3904] again --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 41e707f7f..1f6cb71c7 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[18][64],ASSETCHAINS_SYMBOL; +extern char NOTARYADDRS[18][64]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t komodo_mutex; From f07284c6820b2fdad11109d8dd50fb4cee85e4f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 14:28:43 +0800 Subject: [PATCH 0543/3904] Move 99% of staked notary code to its own file --- src/komodo_globals.h | 2 +- src/komodo_notary.h | 87 ++++++++-------------------- src/komodo_utils.h | 4 +- src/notaries_staked.cpp | 124 +++++++++++++++++++++++++--------------- src/notaries_staked.h | 1 + src/wallet/wallet.cpp | 14 +++-- 6 files changed, 115 insertions(+), 117 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 2070e1240..50952af69 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -30,7 +30,7 @@ int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); -pthread_mutex_t komodo_mutex; +pthread_mutex_t komodo_mutex,staked_mutex; #define KOMODO_ELECTION_GAP 2000 //((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100) #define KOMODO_ASSETCHAIN_MAXLEN 65 diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 88ce299f7..48eeb6cba 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -204,15 +204,17 @@ const char *Notaries_elected1[][2] = int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33] = {0}; - int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( timestamp == 0 ) timestamp = komodo_heightstamp(height); - else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { + // Here we run the staked notaries function to populate the Notary Address's global var on KMD. + if ( IS_STAKED_NOTARY != -1 ) { + uint8_t tmp_pubkeys[64][33]; + numStakedNotaries(tmp_pubkeys,is_STAKED(timestamp)); + } timestamp = 0; + } // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) @@ -253,67 +255,26 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } else { // here we can activate our pubkeys for STAKED chains by era. - if (timestamp != 0) - { - staked_era = STAKED_era(timestamp); - if (staked_era == 1) + if (timestamp != 0) { - if (didstaked1 == 0) + int staked_era; int32_t numSN; + uint8_t staked_pubkeys[64][33]; uint8_t null_pubkeys[64][33] = {0}; + staked_era = STAKED_era(timestamp); + + if (staked_era != 0) { - ns1 = num_notaries_STAKED1; - for (i=0; i STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - if ( NOTARY_PUBKEY33[0] != 0 ) + if ( NOTARYADDRS[0][0] != 0 ) { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + if ( NOTARY_PUBKEY33[0] != 0 ) { - IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + { + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + } } didera++; } @@ -167,89 +170,120 @@ int STAKED_era(int timestamp) }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - int8_t notaryID = -1; int i; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; - static char ChainName[65]; + int8_t notaryID = -1; + if ( STAKED_ERA != 0 ) { + switch (STAKED_ERA) { + case 1: + notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname); + break; + case 2: + notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname); + break; + case 3: + notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname); + break; + case 4: + notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname); + break; + } + } + return(notaryID); +} - if ( ChainName[0] == 0 ) { +int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { + int i; int8_t retval = 0; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; + static char ChainName[65]; + + if ( ChainName[0] == 0 ) + { + pthread_mutex_init(&staked_mutex,NULL); if ( ASSETCHAINS_SYMBOL[0] == 0 ) strcpy(ChainName,"KMD"); else strcpy(ChainName,ASSETCHAINS_SYMBOL); } - if ( STAKED_ERA != 0 ) { - switch (STAKED_ERA) { + if ( era != 0 ) { + switch (era) { case 1: - if ( didstaked1 == 0 ) { - for (i=0; i Date: Mon, 5 Nov 2018 14:30:36 +0800 Subject: [PATCH 0544/3904] fix --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 48eeb6cba..9b14060a6 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -211,7 +211,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam // Here we run the staked notaries function to populate the Notary Address's global var on KMD. if ( IS_STAKED_NOTARY != -1 ) { uint8_t tmp_pubkeys[64][33]; - numStakedNotaries(tmp_pubkeys,is_STAKED(timestamp)); + numStakedNotaries(tmp_pubkeys,STAKED_era(timestamp)); } timestamp = 0; } From 64c4af2756bd2e55d22973c8ad643a1bc5cdc628 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 14:51:05 +0800 Subject: [PATCH 0545/3904] fix --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c56d60a40..bcd490915 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5011,14 +5011,14 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - NOTARY_ADDRESS = address.ToString(); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { - result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); + result.push_back(Pair("error", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); #endif + NOTARY_ADDRESS = address.ToString(); std::string notaryname; if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { result.push_back(Pair("IsNotary", notaryname)); From 068c48214d1b5c33cccc7961587f826700a9f2de Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 15:36:47 +0800 Subject: [PATCH 0546/3904] remove unneeded things --- src/bitcoin-cli.cpp | 1 - src/rpcserver.h | 3 --- src/wallet/rpcwallet.cpp | 6 ------ src/wallet/wallet.cpp | 12 +++++++----- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..d7c906669 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -73,7 +73,6 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -#include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" diff --git a/src/rpcserver.h b/src/rpcserver.h index 372d84392..81ca8a8b9 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -287,9 +287,6 @@ extern UniValue FSMlist(const UniValue& params, bool fHelp); extern UniValue FSMinfo(const UniValue& params, bool fHelp); extern UniValue auctionaddress(const UniValue& params, bool fHelp); -extern bool pubkey2address(char *destaddr,uint8_t *pubkey33); -extern bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); - extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp //extern UniValue getnewaddress64(const UniValue& params, bool fHelp); // in rpcwallet.cpp extern UniValue getaccountaddress(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bcd490915..fe21544dc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4991,11 +4991,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); -#ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else - LOCK2(cs_main); -#endif char Raddress[18]; uint8_t pubkey33[33]; @@ -5011,13 +5007,11 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); -#ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { result.push_back(Pair("error", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); -#endif NOTARY_ADDRESS = address.ToString(); std::string notaryname; if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f21c23810..a340ecfae 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1230,7 +1230,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } } // Now we know if it was a tx sent to us, that wasnt from ourself. - fprintf(stderr, "We sent from address: %s vouts: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); + if ( numvinIsOurs != 0 ) + fprintf(stderr, "We sent from address: %s vins: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); // Count vouts, check if OUR notary address is the receiver. if ( numvinIsOurs == 0 ) { for (size_t i = 0; i < tx.vout.size() ; i++) { @@ -1244,8 +1245,10 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } } // If no vouts are to the notary address we will ignore them. - if ( numvoutIsOurs == 0 ) + if ( numvoutIsOurs == 0 ) { + fprintf(stderr, "Received transaction to address other than notary address, ignored! \n"); return false; + } fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; @@ -1254,10 +1257,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); return false; } - } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, ideally we would remove the utxo we spent from our wallet, but you cant do that. - // this will be removed later... RPC call PurgeWalletSpents will be created instead. + // this means we were in a multi sig, ideally we would remove the utxo we spent from our wallet, but you cant do that, unless all the tx's vouts are also spent. + // RPC call PurgeWalletSpents will be created to clean all fully spent tx's instead. fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 623ec7787750409ed5dfd7bc01ea4d0f32f321cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:06:53 +0800 Subject: [PATCH 0547/3904] more --- src/komodo_utils.h | 2 -- src/main.cpp | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 07296466b..546fa8a13 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,8 +13,6 @@ * * ******************************************************************************/ #include "komodo_defs.h" -#include "cc/utils.h" -#include "cc/CCinclude.h" #ifdef _WIN32 #include diff --git a/src/main.cpp b/src/main.cpp index e272adff8..c5d2db923 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1062,9 +1062,12 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only } didinit = 1; } */ - for (int32_t i=0; i<=64; i++) - if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) - return(1); + if ( NOTARYADDRS[0][0] != 0 ) + { + for (int32_t i=0; i<=64; i++) + if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) + return(1); + } return(0); } @@ -1218,7 +1221,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio } } } - + // Ensure input values do not exceed MAX_MONEY // We have not resolved the txin values at this stage, // but we do know what the joinsplits claim to add From f0b07a30a7c7346dda0e5a805ca203211885ced3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:16:49 +0800 Subject: [PATCH 0548/3904] fix notaryaddrs var ? --- src/komodo_globals.h | 2 +- src/main.cpp | 2 +- src/notaries_staked.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 50952af69..783a3bafc 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -49,7 +49,7 @@ int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JU std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[18][64]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][18]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; diff --git a/src/main.cpp b/src/main.cpp index c5d2db923..53067481e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } -extern char NOTARYADDRS[18][64]; +extern char NOTARYADDRS[64][18]; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 6d98b480c..23b1eaa9c 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[18][64]; +extern char NOTARYADDRS[64][18]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; @@ -283,6 +283,11 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { break; } } + else + { + // era is zero so we need to null ut the notary address's + //NOTARYADDRS[64][18] + } return(retval); } From 2c795c0f1c540c6cf22fdcb4866de7deba93ad74 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:30:08 +0800 Subject: [PATCH 0549/3904] fix --- src/komodo_globals.h | 2 +- src/main.cpp | 2 +- src/notaries_staked.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 783a3bafc..b91a6666e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -49,7 +49,7 @@ int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JU std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][18]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; diff --git a/src/main.cpp b/src/main.cpp index 53067481e..ea4bc1234 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } -extern char NOTARYADDRS[64][18]; +extern char NOTARYADDRS[64][36]; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 23b1eaa9c..790fe5ece 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[64][18]; +extern char NOTARYADDRS[64][36]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; @@ -216,6 +216,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); pthread_mutex_unlock(&staked_mutex); + fprintf(stderr, "copied address [%d]: %s\n",i,NOTARYADDRS[i]); #endif } didstaked1 = 1; @@ -224,6 +225,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { didstaked4 = 0; printf("%s is a STAKED chain in era 1 \n",ChainName); } + memcpy(pubkeys,staked_pubkeys1,num_notaries_STAKED1 * 33); retval = num_notaries_STAKED1; break; From 1c497de1facad745c5d3bd8807a3b9931b6262c2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:34:55 +0800 Subject: [PATCH 0550/3904] test --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 790fe5ece..e6ae00961 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -219,6 +219,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { fprintf(stderr, "copied address [%d]: %s\n",i,NOTARYADDRS[i]); #endif } + fprintf(stderr, "size of notaryaddrs array: %ld\n",sizeof(NOTARYADDRS)); didstaked1 = 1; didstaked2 = 0; didstaked3 = 0; From 8d687f0312495a94d66c55cab13fd782d688015c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:11:32 +0800 Subject: [PATCH 0551/3904] add num notaris golbal, and reset notaries on era 0 --- src/komodo_globals.h | 2 +- src/komodo_notary.h | 4 ++-- src/main.cpp | 48 +++++++++++++++++++++++++---------------- src/notaries_staked.cpp | 15 ++++++++----- src/notaries_staked.h | 2 +- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b91a6666e..05af4edd8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9b14060a6..d032475bb 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -258,7 +258,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam if (timestamp != 0) { int staked_era; int32_t numSN; - uint8_t staked_pubkeys[64][33]; uint8_t null_pubkeys[64][33] = {0}; + uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); if (staked_era != 0) @@ -271,7 +271,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - memcpy(pubkeys,null_pubkeys,64 * 33); + memset(pubkeys,0,sizeof(pubkeys)); return(64); } } diff --git a/src/main.cpp b/src/main.cpp index ea4bc1234..386eb122e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,29 +1044,39 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } + extern char NOTARYADDRS[64][36]; +extern uint8_t NUM_NOTARIES; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - /*static int32_t didinit; - int32_t i; - if ( didinit == 0 ) - { - uint8_t pubkey33[33]; - for (i=0; i<=17; i++) - { - if ( i < 17 ) - decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - didinit = 1; - } */ - if ( NOTARYADDRS[0][0] != 0 ) - { - for (int32_t i=0; i<=64; i++) - if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) - return(1); + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) { + for (int32_t i=0; i<=NUM_NOTARIES; i++) + if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) + return(1); + } + } + else + { + static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; + int32_t i; + if ( didinit == 0 ) + { + uint8_t pubkey33[33]; + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + { + if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) + decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } + didinit = 1; + } + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) + return(1); } return(0); } diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e6ae00961..baf090bbf 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -8,7 +8,7 @@ extern char NOTARYADDRS[64][36]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; -extern uint8_t NOTARY_PUBKEY33[33]; +extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = @@ -215,11 +215,10 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); + NUM_NOTARIES = num_notaries_STAKED1; pthread_mutex_unlock(&staked_mutex); - fprintf(stderr, "copied address [%d]: %s\n",i,NOTARYADDRS[i]); #endif } - fprintf(stderr, "size of notaryaddrs array: %ld\n",sizeof(NOTARYADDRS)); didstaked1 = 1; didstaked2 = 0; didstaked3 = 0; @@ -238,6 +237,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys2[i]); + NUM_NOTARIES = num_notaries_STAKED2; pthread_mutex_unlock(&staked_mutex); #endif } @@ -257,6 +257,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys3[i]); + NUM_NOTARIES = num_notaries_STAKED3; pthread_mutex_unlock(&staked_mutex); #endif } @@ -275,6 +276,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys4[i]); + NUM_NOTARIES = num_notaries_STAKED4; pthread_mutex_unlock(&staked_mutex); #endif } @@ -288,8 +290,11 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { } else { - // era is zero so we need to null ut the notary address's - //NOTARYADDRS[64][18] + // era is zero so we need to null out the notary address's + pthread_mutex_lock(&staked_mutex); + memset(NOTARYADDRS,0,sizeof(NOTARYADDRS)); + NUM_NOTARIES = 0; + pthread_mutex_unlock(&staked_mutex); } return(retval); } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 6aedbdbe1..9944c8465 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -8,7 +8,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541409634; static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; From 51442c510db7555335576d94825ae8aec3384c69 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:14:49 +0800 Subject: [PATCH 0552/3904] fix test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d032475bb..39263f579 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -271,7 +271,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - memset(pubkeys,0,sizeof(pubkeys)); + memset(pubkeys,0,64 * 33); return(64); } } From fec7d5f7fc927486f4b02be9d3b3952ecc6b319e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:23:02 +0800 Subject: [PATCH 0553/3904] test.. changed wrong era --- src/notaries_staked.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9944c8465..9a8fc2a50 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,8 +7,8 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541409634; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604233000; static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; From a22a25ed89b281a3c080be524b75412e3a8b54f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:34:24 +0800 Subject: [PATCH 0554/3904] try --- src/notaries_staked.cpp | 1 + src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index baf090bbf..ac983d1ac 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -302,6 +302,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { + fprintf(stderr, "address [%d]: %s\n",i,NOTARYADDRS[i]); notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); return(i); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9a8fc2a50..06d1c53f2 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -8,7 +8,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604233000; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541411534; static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; From ae338198b4a94d8fab00d9fd916ba426e0b7f214 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:35:44 +0800 Subject: [PATCH 0555/3904] fix --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ac983d1ac..3ccf4c5b9 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -302,7 +302,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { - fprintf(stderr, "address [%d]: %s\n",i,NOTARYADDRS[i]); + fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); return(i); From becfd7b0c7fbad44f6a091acd9a18512ce21108b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:42:10 +0800 Subject: [PATCH 0556/3904] fix print --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3ccf4c5b9..7c39f3f62 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -301,8 +301,8 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { + fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { - fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); return(i); From 0f712b6074686e95a6e494ea3d370049d03dfb16 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:44:23 +0800 Subject: [PATCH 0557/3904] tests era 3 --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 06d1c53f2..82988c1fc 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -9,7 +9,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; static const int STAKED_NOTARIES_TIMESTAMP2 = 1541411534; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541412000; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 102e221887478c1ea1cbbefd632342530c76a0e0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:58:23 +0800 Subject: [PATCH 0558/3904] test eras again --- src/komodo_notary.h | 17 +++-------------- src/notaries_staked.cpp | 5 ++++- src/notaries_staked.h | 6 +++--- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 39263f579..4e40dc6e7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -260,20 +260,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam int staked_era; int32_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); - - if (staked_era != 0) - { - numSN = numStakedNotaries(staked_pubkeys,staked_era); - memcpy(pubkeys,staked_pubkeys,numSN * 33); - return(numSN); - } - else - { - // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. - printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - memset(pubkeys,0,64 * 33); - return(64); - } + numSN = numStakedNotaries(staked_pubkeys,staked_era); + memcpy(pubkeys,staked_pubkeys,numSN * 33); + return(numSN); } } diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 7c39f3f62..257076999 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -290,11 +290,14 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { } else { - // era is zero so we need to null out the notary address's + // era is zero so we need to null out the notary address's and pubkeys. pthread_mutex_lock(&staked_mutex); memset(NOTARYADDRS,0,sizeof(NOTARYADDRS)); NUM_NOTARIES = 0; + memset(pubkeys,0,64 * 33); pthread_mutex_unlock(&staked_mutex); + printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); + return(64); } return(retval); } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 82988c1fc..e7ee0a395 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541411534; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541412000; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541412157; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541413657; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 8aee84c5b3e0048ec9eb60ffcf7f312668692568 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:23:59 +0800 Subject: [PATCH 0559/3904] fix --- src/komodo.h | 1 - src/notaries_staked.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d2d0231f3..e406e565a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 257076999..31e88e414 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -208,7 +208,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { if ( era != 0 ) { switch (era) { case 1: - if ( didstaked1 == 0 ) + if ( didstaked1 == 0 || NOTARYADDRS[0][0] == 0 ) { for (i=0; i Date: Mon, 5 Nov 2018 18:27:08 +0800 Subject: [PATCH 0560/3904] too slow --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index e7ee0a395..cbd746bf3 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -9,7 +9,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1541412157; static const int STAKED_NOTARIES_TIMESTAMP2 = 1541413657; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541414977; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 21aa805a693d1e37b8190ce4dafc996c7d7712f1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:29:45 +0800 Subject: [PATCH 0561/3904] fix --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index cbd746bf3..97cf8f7b1 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541412157; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541413657; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541414977; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541413921; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541414898; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541415875; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From d5593b354c3909e4012144292f89775c00ef0252 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:48:10 +0800 Subject: [PATCH 0562/3904] try this --- src/notaries_staked.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 31e88e414..18b8f8801 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -146,8 +146,9 @@ int STAKED_era(int timestamp) era = 3; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; - else - era = 0; + else { + era = 0; didera = 0; + } // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. if ( era > STAKED_ERA || didera == 0 ) From 76eb9a496eb866bb471d19002a5e7a0c37788b1f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:50:25 +0800 Subject: [PATCH 0563/3904] new eras test --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 97cf8f7b1..9c2b5d811 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541413921; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541414898; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541415875; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541415367; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541416544; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541417721; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 96c7f474b9f987ec3d9f20977b32cef35b7b2d38 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 19:48:36 +0800 Subject: [PATCH 0564/3904] try print --- src/komodo.h | 1 + src/komodo_notary.h | 2 +- src/notaries_staked.cpp | 33 +++++++++++++++++---------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e406e565a..2cf18d24e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,6 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { + printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4e40dc6e7..f9534ac18 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -254,7 +254,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } } else - { // here we can activate our pubkeys for STAKED chains by era. + { // here we can activate our pubkeys for STAKED chains everythig is in notaries_staked.cpp if (timestamp != 0) { int staked_era; int32_t numSN; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 18b8f8801..1bcc6ce93 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,22 +118,6 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -#ifdef SERVER -int8_t updateStakedNotary() { - std::string notaryname; - char Raddress[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - NOTARY_ADDRESS.clear(); - NOTARY_ADDRESS.assign(Raddress); - return(StakedNotaryID(notaryname,Raddress)); -} -#else -int8_t updateStakedNotary() { - return(-1); -} -#endif - int STAKED_era(int timestamp) { int8_t era = 0; @@ -170,6 +154,23 @@ int STAKED_era(int timestamp) return(era); }; +#ifdef SERVER +int8_t updateStakedNotary() { + if ( NOTARY_ADDRESS.empty() ) { + std::string notaryname; + char Raddress[18]; uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + NOTARY_ADDRESS.assign(Raddress); + } + return(StakedNotaryID(notaryname,Raddress)); +} +#else +int8_t updateStakedNotary() { + return(-1); +} +#endif + int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; if ( STAKED_ERA != 0 ) { From dfe8e4a6cdae8d99b64b90b3fb72939356d2c0b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 20:44:37 +0800 Subject: [PATCH 0565/3904] test --- src/komodo.h | 2 +- src/komodo_notary.h | 1 + src/notaries_staked.cpp | 6 ++++++ src/notaries_staked.h | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 2cf18d24e..bc691eb81 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),pindex->nTime,ASSETCHAINS_SYMBOL); + printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index f9534ac18..ff7bc5cc3 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -205,6 +205,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; + if ( timestamp == 0 ) timestamp = komodo_heightstamp(height); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 1bcc6ce93..3343ef716 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -121,7 +121,12 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int8_t era = 0; + static uint32_t lasttimestamp; static int didera; + // test this, seems to sometimes get called into the past? + if ( timestamp < lasttimestamp ) + timestamp = lasttimestamp; + if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -151,6 +156,7 @@ int STAKED_era(int timestamp) didera++; } } + lasttimestamp = timestamp; return(era); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9c2b5d811..a4e381a45 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541415367; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541416544; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541417721; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541422105; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541423282; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541424459; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 1102a73bf817190c95ccc3f526c270cee43e20b4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 20:48:08 +0800 Subject: [PATCH 0566/3904] cant do that --- src/notaries_staked.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3343ef716..a3d37690e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -162,13 +162,12 @@ int STAKED_era(int timestamp) #ifdef SERVER int8_t updateStakedNotary() { - if ( NOTARY_ADDRESS.empty() ) { - std::string notaryname; - char Raddress[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - NOTARY_ADDRESS.assign(Raddress); - } + std::string notaryname; + char Raddress[18]; uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + NOTARY_ADDRESS.clear(); + NOTARY_ADDRESS.assign(Raddress); return(StakedNotaryID(notaryname,Raddress)); } #else From f4f9c03cb4c957808cc77ebe7b25f8b7cb8e2378 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 20:51:20 +0800 Subject: [PATCH 0567/3904] fix? --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index bc691eb81..c30e41af5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); + printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); From 73a83354dcaf5ac7b0f7580cd2b01161377201a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 21:32:37 +0800 Subject: [PATCH 0568/3904] fast --- src/komodo.h | 4 ++-- src/notaries_staked.cpp | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index c30e41af5..ba69a2761 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,8 +831,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era((uint32_t)pindex->nTime) == 0)) { + //printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a3d37690e..cc3869835 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -227,9 +227,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #endif } didstaked1 = 1; - didstaked2 = 0; - didstaked3 = 0; - didstaked4 = 0; printf("%s is a STAKED chain in era 1 \n",ChainName); } @@ -249,8 +246,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #endif } didstaked2 = 1; - didstaked3 = 0; - didstaked4 = 0; printf("%s is a STAKED chain in era 2 \n",ChainName); } memcpy(pubkeys,staked_pubkeys2,num_notaries_STAKED2 * 33); @@ -269,7 +264,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #endif } didstaked3 = 1; - didstaked4 = 0; printf("%s is a STAKED chain in era 3 \n",ChainName); } memcpy(pubkeys,staked_pubkeys3,num_notaries_STAKED3 * 33); From 6556f635f0bda6b35fe2380cad61f00a9fdddfea Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 23:35:28 +0800 Subject: [PATCH 0569/3904] Add maximum priority for notarisations. --- src/komodo_globals.h | 2 +- src/miner.cpp | 24 ++++++++++++++++++++++-- src/notaries_staked.cpp | 2 +- src/wallet/wallet.cpp | 4 ++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 05af4edd8..9dfcf0546 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; -int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; +int32_t KOMODO_INSYNC,KOMODO_LASTMINED,KOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; diff --git a/src/miner.cpp b/src/miner.cpp index 6c25a5007..5aef46148 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -108,11 +108,11 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],NOTARYADDRS[64][36]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); -extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; +extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],NUM_NOTARIES; uint32_t Mining_start,Mining_height; int32_t My_notaryid = -1; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); @@ -206,12 +206,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) double dPriority = 0; CAmount nTotalIn = 0; bool fMissingInputs = false; + bool fNotarisation = false; if (tx.IsCoinImport()) { CAmount nValueIn = GetCoinImportValue(tx); nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { + int numNotaryVins = 0; BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -250,8 +252,23 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) int nConf = nHeight - coins->nHeight; + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { + uint256 hash; CTransaction tx1; CTxDestination address; + if (GetTransaction(txin.prevout.hash,tx1,hash,false)) + { + if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { + for (int i = 0; i < NUM_NOTARIES; i++) { + if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) + numNotaryVins++; + } + } + } + } dPriority += (double)nValueIn * nConf; } + if ( numNotaryVins > NUM_NOTARIES / 5 ) + fNotarisation = true; nTotalIn += tx.GetJoinSplitValueIn(); } @@ -266,6 +283,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + if (fNotarisation) + dPriority = 1e16; + if (porphan) { porphan->dPriority = dPriority; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index cc3869835..b528df512 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -305,7 +305,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); + //fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a340ecfae..0133d6895 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { @@ -1240,7 +1240,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { // this should be a received tx.. numvoutIsOurs++; - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + totalvoutvalue += tx.vout[i].nValue; } } } From ab27a044a00ea68f5ca67bcba23278203f62f5bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 23:37:40 +0800 Subject: [PATCH 0570/3904] oops --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9dfcf0546..05af4edd8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; -int32_t KOMODO_INSYNC,KOMODO_LASTMINED,KOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; +int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; From 68ae8e0468c1f020a082a62db8ba53ecfb2f79ed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 16:26:08 +0800 Subject: [PATCH 0571/3904] move initalise notaryaddrs to connect block to stop it being called out of order --- src/komodo.h | 29 +++++++++++-- src/notaries_staked.cpp | 96 +++++++++++++++-------------------------- src/notaries_staked.h | 1 + 3 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ba69a2761..d27981250 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -797,6 +797,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; + int8_t StakedEra; static int8_t lastStakedEra; + uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; @@ -809,6 +811,27 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) return; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY != -1 ) { + staked_era = STAKED_era(pindex->GetBlockTime()); + if ( staked_era != lastStakedEra ) { + uint8_t tmp_pubkeys[64][33]; + int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); + UpdateNotaryAddrs(tmp_pubkeys,numSN); + STAKED_ERA = staked_era; + if ( NOTARYADDRS[0][0] != 0 ) + { + if ( NOTARY_PUBKEY33[0] != 0 ) + { + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + { + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + } + } + } + } + lastStakedEra = staked_era; + } numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -831,9 +854,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; inTime) == 0)) { - //printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); - continue; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 && staked_era == 0 ) { + // in era gap no point checking any invlaid notarisations. + break; } txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index b528df512..ec0f2054e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -121,12 +121,6 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int8_t era = 0; - static uint32_t lasttimestamp; - static int didera; - // test this, seems to sometimes get called into the past? - if ( timestamp < lasttimestamp ) - timestamp = lasttimestamp; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -135,28 +129,9 @@ int STAKED_era(int timestamp) era = 3; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; - else { - era = 0; didera = 0; - } + else + era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - - if ( era > STAKED_ERA || didera == 0 ) - { - STAKED_ERA = era; - if ( NOTARYADDRS[0][0] != 0 ) - { - if ( NOTARY_PUBKEY33[0] != 0 ) - { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) - { - IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); - } - } - didera++; - } - } - lasttimestamp = timestamp; return(era); }; @@ -205,7 +180,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { if ( ChainName[0] == 0 ) { - pthread_mutex_init(&staked_mutex,NULL); if ( ASSETCHAINS_SYMBOL[0] == 0 ) strcpy(ChainName,"KMD"); else @@ -215,35 +189,22 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { if ( era != 0 ) { switch (era) { case 1: - if ( didstaked1 == 0 || NOTARYADDRS[0][0] == 0 ) + if ( didstaked1 == 0 ) { for (i=0; i Date: Tue, 6 Nov 2018 16:30:35 +0800 Subject: [PATCH 0572/3904] fix --- src/notaries_staked.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ec0f2054e..f061810ab 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -268,8 +268,10 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { // staked era is set. #ifdef SERVER pthread_mutex_lock(&staked_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)pubkeys[i]); - NUM_NOTARIES = numNotaries; + for (int i = 0; i Date: Tue, 6 Nov 2018 16:31:51 +0800 Subject: [PATCH 0573/3904] typo --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d27981250..515185ef3 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -797,7 +797,7 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; - int8_t StakedEra; static int8_t lastStakedEra; + int8_t staked_era; static int8_t lastStakedEra; uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; @@ -855,7 +855,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; i Date: Tue, 6 Nov 2018 16:32:46 +0800 Subject: [PATCH 0574/3904] another --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 515185ef3..2a4a1252a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,7 +825,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); } } } From 120b7c3b02224d96b5653c44884f99abf3557e5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 16:43:41 +0800 Subject: [PATCH 0575/3904] test new era logic --- src/komodo.h | 11 ++++------- src/notaries_staked.h | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 2a4a1252a..e8dab9c77 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -818,15 +818,12 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); UpdateNotaryAddrs(tmp_pubkeys,numSN); STAKED_ERA = staked_era; - if ( NOTARYADDRS[0][0] != 0 ) + if ( NOTARYADDRS[0][0] != 0 && NOTARY_PUBKEY33[0] != 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 ) + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) - { - IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); - } + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); } } } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 5a63861d7..0e590e19b 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,11 +5,11 @@ #include "crosschain.h" #include "cc/CCinclude.h" -static const int STAKED_ERA_GAP = 777; +static const int STAKED_ERA_GAP = 300; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541422105; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541423282; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541424459; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541494052; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541494052; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541494052; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From b09c8e9f4701385e0b162d7cd3dc70cbc3f4e95f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 17:12:48 +0800 Subject: [PATCH 0576/3904] add STAKED_ERA to getinfo .. clean code up --- src/rpcmisc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 9a578e1a5..af4eb0ee2 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -51,7 +51,7 @@ int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); @@ -62,12 +62,11 @@ extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; -extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; +extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; - extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -171,6 +170,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + obj.push_back(Pair("StakedEra", STAKED_ERA)); //obj.push_back(Pair("name", ASSETCHAINS_SYMBOL)); obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); From 75479b3253a02dd1237b72527aa197d7a4168d19 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 17:26:54 +0800 Subject: [PATCH 0577/3904] test eras again --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 0e590e19b..2f368b163 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,11 +5,11 @@ #include "crosschain.h" #include "cc/CCinclude.h" -static const int STAKED_ERA_GAP = 300; +static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541494052; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541494052; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541494052; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541496946; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541497546; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541498546; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 0a7c652d842f57c30e8c0dc060144643d95a563a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 17:47:38 +0800 Subject: [PATCH 0578/3904] fix --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 2f368b163..caee446e7 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541496946; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541497546; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541498546; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541498901; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541500201; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541501501; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 863e164e998971eb706554ecfcf37a0c4c51d026 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 13:11:03 +0800 Subject: [PATCH 0579/3904] final version? --- src/komodo_notary.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index ff7bc5cc3..1d43e2770 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -205,17 +205,11 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - - if ( timestamp == 0 ) - timestamp = komodo_heightstamp(height); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - // Here we run the staked notaries function to populate the Notary Address's global var on KMD. - if ( IS_STAKED_NOTARY != -1 ) { - uint8_t tmp_pubkeys[64][33]; - numStakedNotaries(tmp_pubkeys,STAKED_era(timestamp)); - } - timestamp = 0; - } + + if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = komodo_heightstamp(height); + else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + timestamp = 0; // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) From 0920b59572b35cc55b82e7d324c4c07286da37b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:27:57 +0800 Subject: [PATCH 0580/3904] add min recv size and whitelist address --- src/komodo.h | 6 +++-- src/komodo_globals.h | 4 ++-- src/komodo_notary.h | 2 +- src/komodo_utils.h | 2 ++ src/notaries_staked.cpp | 6 ++--- src/notaries_staked.h | 6 ++--- src/notarisationdb.cpp | 2 +- src/wallet/wallet.cpp | 50 +++++++++++++++++++++++++---------------- 8 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e8dab9c77..48d25d776 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -797,7 +797,7 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; - int8_t staked_era; static int8_t lastStakedEra; + int32_t staked_era; static int32_t lastStakedEra; uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; @@ -823,7 +823,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); + if ( MIN_RECV_SATS == -1 ) + MIN_RECV_SATS = 100000000; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d MIN_TX_VALUE.%lu \n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era,MIN_RECV_SATS); } } } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 05af4edd8..d415cc847 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; @@ -54,7 +54,7 @@ uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; +uint64_t ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1d43e2770..96497b755 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -252,7 +252,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { // here we can activate our pubkeys for STAKED chains everythig is in notaries_staked.cpp if (timestamp != 0) { - int staked_era; int32_t numSN; + int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); numSN = numStakedNotaries(staked_pubkeys,staked_era); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 546fa8a13..eeacf90d0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1511,6 +1511,8 @@ void komodo_args(char *argv0) fprintf(stderr, "Cannot be STAKED and KMD notary at the same time!\n"); exit(0); } + MIN_RECV_SATS = GetArg("-mintxvalue",-1); + WHITELIST_ADDRESS = GetArg("-whitelist",""); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index f061810ab..e4e1c8ddb 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -106,7 +106,7 @@ const char *notaries_STAKED4[][2] = int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); -int is_STAKED(const char *chain_name) { +int8_t is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; @@ -118,7 +118,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -int STAKED_era(int timestamp) +int32_t STAKED_era(int timestamp) { int8_t era = 0; if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) @@ -289,7 +289,7 @@ int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *R return(-1); } -CrosschainAuthority Choose_auth_STAKED(int chosen_era) { +CrosschainAuthority Choose_auth_STAKED(int32_t chosen_era) { CrosschainAuthority auth; switch (chosen_era) { case 1: diff --git a/src/notaries_staked.h b/src/notaries_staked.h index caee446e7..ae16e316d 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -24,15 +24,15 @@ extern int num_notaries_STAKED3; extern const char *notaries_STAKED4[][2]; extern int num_notaries_STAKED4; -int is_STAKED(const char *chain_name); -int STAKED_era(int timestamp); +int8_t is_STAKED(const char *chain_name); +int32_t STAKED_era(int timestamp); int8_t updateStakedNotary(); int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era); int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries); int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); -CrosschainAuthority Choose_auth_STAKED(int chosen_era); +CrosschainAuthority Choose_auth_STAKED(int32_t chosen_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); #endif diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 68c00546b..f551edf3f 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -40,7 +40,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) //printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp - int staked_era = STAKED_era(timestamp); + int32_t staked_era = STAKED_era(timestamp); printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0133d6895..30d2ad461 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,8 +1201,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; -extern std::string NOTARY_ADDRESS; +extern std::string NOTARY_ADDRESS,WHITELIST_ADDRESS; extern int32_t IS_STAKED_NOTARY; +extern uint64_t MIN_RECV_SATS; bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { @@ -1216,34 +1217,49 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vin.size(); i++) { + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted = false; + for (size_t i = 0; i < tx.vin.size(); i++) + { uint256 hash; CTransaction txin; CTxDestination address; if (GetTransaction(tx.vin[i].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) { - // This means we sent the tx.. - if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { + if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) + { + if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) numvinIsOurs++; + if ( !WHITELIST_ADDRESS.empty() ) + { + if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) + whitelisted == true; } - } + } } } - // Now we know if it was a tx sent to us, that wasnt from ourself. + // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. if ( numvinIsOurs != 0 ) fprintf(stderr, "We sent from address: %s vins: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); + if ( whitelisted == true ) + fprintf(stderr, "We received from whitelisted address: %s\n",WHITELIST_ADDRESS.c_str()); // Count vouts, check if OUR notary address is the receiver. - if ( numvinIsOurs == 0 ) { - for (size_t i = 0; i < tx.vout.size() ; i++) { + if ( numvinIsOurs == 0 && whitelisted == false ) + { + for (size_t i = 0; i < tx.vout.size() ; i++) + { CTxDestination address2; - if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { - // this should be a received tx.. + if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) + { + if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) + { numvoutIsOurs++; totalvoutvalue += tx.vout[i].nValue; } } } + // if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. + if ( MIN_RECV_SATS == 0 ) { + fprintf(stderr, "This node is on full lock down all txs are ignored! \n"); + return false; + } // If no vouts are to the notary address we will ignore them. if ( numvoutIsOurs == 0 ) { fprintf(stderr, "Received transaction to address other than notary address, ignored! \n"); @@ -1252,15 +1268,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; - if ( avgVoutSize < 100000000 ) { - // average vout size is less than 1 coin, we will ignore it + if ( avgVoutSize < MIN_RECV_SATS ) { + // average vout size is less than set minimum, default is 1 coin, we will ignore it fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); return false; } - } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, ideally we would remove the utxo we spent from our wallet, but you cant do that, unless all the tx's vouts are also spent. - // RPC call PurgeWalletSpents will be created to clean all fully spent tx's instead. - fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 8d0278b46db7f216a5d6aabfaddd674e435ac3cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:47:39 +0800 Subject: [PATCH 0581/3904] whitelist arg already used! --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index eeacf90d0..d5ac096f5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1512,7 +1512,7 @@ void komodo_args(char *argv0) exit(0); } MIN_RECV_SATS = GetArg("-mintxvalue",-1); - WHITELIST_ADDRESS = GetArg("-whitelist",""); + WHITELIST_ADDRESS = GetArg("-whitelistaddress",""); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; From be7ce20da40268d11c1edd1931ebb4a79db2e3b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:54:59 +0800 Subject: [PATCH 0582/3904] tets --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 30d2ad461..089f82372 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1229,6 +1229,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() ) { + fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString()); if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) whitelisted == true; } From d92a50e5705a7a8079487a7b3f020d6af442913a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:56:17 +0800 Subject: [PATCH 0583/3904] fix --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 089f82372..c64e9940f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1229,7 +1229,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() ) { - fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString()); + fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) whitelisted == true; } From 6af23bd81d8497da5d27b8c0b45d1c4675aa83be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 18:01:28 +0800 Subject: [PATCH 0584/3904] debug more --- src/wallet/wallet.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c64e9940f..fbdac9540 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1217,7 +1217,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted = false; + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; @@ -1230,8 +1230,14 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( !WHITELIST_ADDRESS.empty() ) { fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString().c_str()); - if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) + if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) { + fprintf(stderr, "whitlisted is set to true here.\n"); whitelisted == true; + } + } + else { + whitelisted == false; + fprintf(stderr, "whitlisted is set to false here.\n"); } } } From 0be25e9aca6e1b77ccd2a936bf436522acabf031 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 18:06:58 +0800 Subject: [PATCH 0585/3904] try this instead? --- src/wallet/wallet.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fbdac9540..ea47c39c1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1217,7 +1217,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted; + int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; @@ -1232,23 +1232,19 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) { fprintf(stderr, "whitlisted is set to true here.\n"); - whitelisted == true; + numvinIsWhiteList++; } } - else { - whitelisted == false; - fprintf(stderr, "whitlisted is set to false here.\n"); - } } } } // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. if ( numvinIsOurs != 0 ) fprintf(stderr, "We sent from address: %s vins: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); - if ( whitelisted == true ) + if ( numvinIsWhiteList != 0 ) fprintf(stderr, "We received from whitelisted address: %s\n",WHITELIST_ADDRESS.c_str()); // Count vouts, check if OUR notary address is the receiver. - if ( numvinIsOurs == 0 && whitelisted == false ) + if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) { for (size_t i = 0; i < tx.vout.size() ; i++) { From d07da88136c7a2aab60dd01edcbb4806c938f813 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 9 Nov 2018 14:14:02 +0800 Subject: [PATCH 0586/3904] add cleanwalletnotarisations RPC call for testing --- src/rpcserver.cpp | 25 ++++---- src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 133 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 145 insertions(+), 14 deletions(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 8934ae717..32c3ba5db 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -350,16 +350,16 @@ static const CRPCCommand vRPCCommands[] = #endif /* auction */ { "auction", "auctionaddress", &auctionaddress, true }, - + /* lotto */ { "lotto", "lottoaddress", &lottoaddress, true }, - + /* fsm */ { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + /* rewards */ { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -368,16 +368,16 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + /* faucet */ { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - + /* MofN */ { "MofN", "mofnaddress", &mofnaddress, true }, - + /* Channels */ { "channels", "channelsaddress", &channelsaddress, true }, { "channels", "channelsinfo", &channelsinfo, true }, @@ -386,7 +386,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelscollect", &channelscollect, true }, { "channels", "channelsstop", &channelsstop, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + /* Oracles */ { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -396,7 +396,7 @@ static const CRPCCommand vRPCCommands[] = { "oracles", "oraclessubscribe", &oraclessubscribe, true }, { "oracles", "oraclesdata", &oraclesdata, true }, { "oracles", "oraclessamples", &oraclessamples, true }, - + /* Prices */ { "prices", "pricesaddress", &pricesaddress, true }, { "prices", "priceslist", &priceslist, true }, @@ -406,16 +406,16 @@ static const CRPCCommand vRPCCommands[] = { "prices", "pricesbet", &pricesbet, true }, { "prices", "pricesstatus", &pricesstatus, true }, { "prices", "pricesfinish", &pricesfinish, true }, - + /* Pegs */ { "pegs", "pegsaddress", &pegsaddress, true }, - + /* Triggers */ { "triggers", "triggersaddress", &triggersaddress, true }, - + /* Payments */ { "payments", "paymentsaddress", &paymentsaddress, true }, - + /* Gateways */ { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, @@ -494,6 +494,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, + { "wallet", "cleanwalletnotarisations", &cleanwalletnotarisations, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index f4c502d63..4a1370465 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -301,6 +301,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); +extern UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 055352973..d5ec198e8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -398,7 +398,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Parse Zcash address CScript scriptPubKey = GetScriptForDestination(address); - + // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; @@ -995,6 +995,135 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } +UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) +{ + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() > 1 ) + throw runtime_error( + "cleanwalletnotarisations \"txid\"\n" + "\nRemove all txs which are totally spent and all notarisations created from them, you can clear all txs bar one, by specifiying a txid.\n" + "\nPlease backup your wallet.dat before running this command.\n" + "\nArguments:\n" + "1. \"txid\" (string, optional) The transaction id to keep.\n" + "\nResult:\n" + "{\n" + " \"total_transactons\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n" + " \"remaining_transactons\" : n, (numeric) Transactions in wallet after clean.\n" + " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("cleanoldtxs", "") + + HelpExampleCli("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("cleanoldtxs", "") + + HelpExampleRpc("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + UniValue ret(UniValue::VOBJ); + uint256 exception; int32_t txs = 0; + std::vector TxToRemove; + if (params.size() == 1) + { + exception.SetHex(params[0].get_str()); + uint256 tmp_hash; CTransaction tmp_tx; + if (GetTransaction(exception,tmp_tx,tmp_hash,false)) + { + if ( !pwalletMain->IsMine(tmp_tx) ) + { + throw runtime_error("\nThe transaction is not yours!\n"); + } + else + { + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + txs++; + const CWalletTx& wtx = (*it).second; + if ( wtx.GetHash() != exception ) + { + TxToRemove.push_back(wtx.GetHash()); + } + } + } + } + else + { + throw runtime_error("\nThe transaction could not be found!\n"); + } + } + else + { + std::vector NotarisationTxs; + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 50 ) + continue; + + CCoins coins; + if (!pcoinsTip->GetCoins(wtx.GetHash(), coins)) + { + int spents = 0; int mine = 0; + for (unsigned int n = 0; n < wtx.vout.size() ; n++) + { + if ( pwalletMain->IsMine(wtx.vout[n]) ) + mine++; + if ( ((unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) ) + spents++; + } + if ( spents == mine ) + { + TxToRemove.push_back(wtx.GetHash()); + for (unsigned int n = 0; n < wtx.vin.size() ; n++) + { + if ( pwalletMain->IsMine(wtx.vin[n]) ) + TxToRemove.push_back(wtx.vin[n].prevout.hash); + } + } + } + + CTxDestination address; + // get all notarisations + if ( ExtractDestination(wtx.vout[0].scriptPubKey, address) ) + { + if ( strcmp(CBitcoinAddress(address).ToString().c_str(),CRYPTO777_KMDADDR) == 0 ) + NotarisationTxs.push_back(wtx); + } + txs++; + } + + // Erase notarisations spending from fully spent splits. + BOOST_FOREACH (CWalletTx& tx, NotarisationTxs) + { + for (int n = 0; n < tx.vin.size(); n++) + { + BOOST_FOREACH (uint256& SpentHash, TxToRemove) + { + if ( SpentHash == tx.vin[n].prevout.hash ) + { + pwalletMain->EraseFromWallet(tx.GetHash()); + //fprintf(stderr, "ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); + } + } + } + } + } + + // erase txs + BOOST_FOREACH (uint256& hash, TxToRemove) + { + pwalletMain->EraseFromWallet(hash); + //fprintf(stderr, "ERASED spent Tx: %s\n",hash.ToString().c_str()); + } + + // build return JSON for stats. + int remaining = pwalletMain->mapWallet.size(); + ret.push_back(Pair("total_transactons", (int)txs)); + ret.push_back(Pair("remaining_transactons", (int)remaining)); + ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); + return (ret); +} UniValue getbalance(const UniValue& params, bool fHelp) { @@ -5669,7 +5798,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) UniValue oraclessamples(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; + UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessamples oracletxid batonutxo num\n"); if ( ensure_CCrequirements() < 0 ) From b5c356dddfd4e31c4a2a3a5ec7b76a63b84477af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 9 Nov 2018 14:58:10 +0800 Subject: [PATCH 0587/3904] fix txs counter --- src/wallet/rpcwallet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d5ec198e8..8a62b2153 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1022,7 +1022,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); UniValue ret(UniValue::VOBJ); - uint256 exception; int32_t txs = 0; + uint256 exception; int32_t txs = pwalletMain->mapWallet.size(); std::vector TxToRemove; if (params.size() == 1) { @@ -1090,7 +1090,6 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) if ( strcmp(CBitcoinAddress(address).ToString().c_str(),CRYPTO777_KMDADDR) == 0 ) NotarisationTxs.push_back(wtx); } - txs++; } // Erase notarisations spending from fully spent splits. From 3ce2f4ec500cf863d8132c6f2a19a8887251cd80 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 18:19:01 +0800 Subject: [PATCH 0588/3904] try ignore 0 sat coinbase --- src/wallet/wallet.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ea47c39c1..e86c54ae2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1209,6 +1209,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { { AssertLockHeld(cs_wallet); + if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) + { + fprintf(stderr, "ZERO sat coinbase, ignored!\n"); + return false; + } bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); From bf554eb6cff6042787ead1ef9abdc4e601776cc2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 18:45:39 +0800 Subject: [PATCH 0589/3904] remove print ... 0 sat coinbase ignore is working --- src/wallet/wallet.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e86c54ae2..96ec88e6e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,10 +1210,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) - { - fprintf(stderr, "ZERO sat coinbase, ignored!\n"); return false; - } bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); From 9f4d613cf365801c0389b70945a3b42bb9e58d66 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 19:40:34 +0800 Subject: [PATCH 0590/3904] add Bar_F1sh_Rel .. move PoSPerc to debug.log add longest chain miner back --- src/miner.cpp | 12 ++++++------ src/notaries_staked.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5aef46148..ce5021cde 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -979,20 +979,20 @@ void static BitcoinMiner() HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); if ( ASSETCHAINS_STAKED < 100 ) { - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); - fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED); + //for (z=31; z>=0; z--) + // fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); + LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } while (true) { - /*if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) + if ( KOMODO_INSYNC == 0 && KOMODO_LONGESTCHAIN != 0 ) { fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height); if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN ) KOMODO_INSYNC = 1; sleep(3); - } */ + } // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; @@ -1008,7 +1008,7 @@ void static BitcoinMiner() curr_state = state; crypto_generichash_blake2b_update(&curr_state,pblock->nNonce.begin(),pblock->nNonce.size()); // (x_1, x_2, ...) = A(I, V, n, k) - LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); + LogPrintf("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); arith_uint256 hashTarget; if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e4e1c8ddb..bb2289a17 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -22,7 +22,7 @@ const char *notaries_STAKED1[][2] = {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca From a573cd9e263c0f6bf4ea07fa837068779d74057d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 20:00:04 +0800 Subject: [PATCH 0591/3904] remove +1 sat for staked chains, needs ot be tested! --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c4fb3b6e9..590e3569f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3188,7 +3188,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size()); } } - if ( block.vtx[0].GetValueOut() > blockReward+1 ) + + if ( ( block.vtx[0].GetValueOut() > blockReward+1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward ) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From d10c7b83583314a4e8578aea222653835a1ddc91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 21:11:42 +0800 Subject: [PATCH 0592/3904] fix max money problem, maximum 1 million coins per export, minimum max money on fungible chains 1 milion. --- src/komodo_utils.h | 2 ++ src/rpccrosschain.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d5ac096f5..188e62603 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1636,6 +1636,8 @@ void komodo_args(char *argv0) MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN; else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; + if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) + MAX_MONEY = 1000000LL*COIN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 52df5efaf..26edb575a 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -175,6 +175,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) CAmount burnAmount = AmountFromValue(params[2]); if (burnAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export"); + if (burnAmount > 1000000LL*COIN) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export, cannot export more than 1 million coins per export."); { CAmount needed = 0; for (int i=0; i Date: Sat, 10 Nov 2018 21:19:15 +0800 Subject: [PATCH 0593/3904] fix --- src/komodo_defs.h | 1 + src/komodo_utils.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 1efd187d9..ca9a05c37 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -9,6 +9,7 @@ #define IGUANA_MAXSCRIPTSIZE 10001 #define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" +#define KOMODO_FIRSTFUNGIBLEID 100 extern uint8_t ASSETCHAINS_TXPOW; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 188e62603..962af99aa 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1637,7 +1637,7 @@ void komodo_args(char *argv0) else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) - MAX_MONEY = 1000000LL*COIN; + MAX_MONEY = 1000000LL*SATOSHIDEN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From 973fa76710f704f5690a2f53e7a1c75f5985c5e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 00:52:44 +0800 Subject: [PATCH 0594/3904] fix logprint, extra f ? --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index ce5021cde..c2b95178e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1008,7 +1008,7 @@ void static BitcoinMiner() curr_state = state; crypto_generichash_blake2b_update(&curr_state,pblock->nNonce.begin(),pblock->nNonce.size()); // (x_1, x_2, ...) = A(I, V, n, k) - LogPrintf("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); + LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); arith_uint256 hashTarget; if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; From 1fe70b907a40043a5f8cf9f1b3e9927f75f4463f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 05:18:03 +0800 Subject: [PATCH 0595/3904] make coinbase normal tx --- src/rpcmining.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 0a2b56ca9..48c63aff1 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -673,8 +673,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) uint256 txHash = tx.GetHash(); setTxIndex[txHash] = i++; - if (tx.IsCoinBase() && !coinbasetxn) - continue; + //if (tx.IsCoinBase() && !coinbasetxn) + // continue; UniValue entry(UniValue::VOBJ); @@ -694,17 +694,17 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template])); entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template])); - if (tx.IsCoinBase()) { + //if (tx.IsCoinBase()) { // Show founders' reward if it is required //if (pblock->vtx[0].vout.size() > 1) { // Correct this if GetBlockTemplate changes the order // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); //} - CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); - entry.push_back(Pair("coinbasevalue", nReward)); - entry.push_back(Pair("required", true)); - txCoinbase = entry; - } else + // CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); + // entry.push_back(Pair("coinbasevalue", nReward)); + // entry.push_back(Pair("required", true)); + // txCoinbase = entry; + // } else transactions.push_back(entry); } @@ -726,13 +726,13 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) result.push_back(Pair("version", pblock->nVersion)); result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); - if (coinbasetxn) { - assert(txCoinbase.isObject()); - result.push_back(Pair("coinbasetxn", txCoinbase)); - } else { - result.push_back(Pair("coinbaseaux", aux)); - result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); - } + //if (coinbasetxn) { + // assert(txCoinbase.isObject()); + // result.push_back(Pair("coinbasetxn", txCoinbase)); + //} else { + // result.push_back(Pair("coinbaseaux", aux)); + // result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + //} result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); if ( ASSETCHAINS_STAKED != 0 ) { From 921b6a7d52d570a839a706db7b4ba5f7b5179fee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:04:36 +0800 Subject: [PATCH 0596/3904] add disablecb option to getblocktemplate --- src/rpcmining.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 48c63aff1..7d5b2ebdc 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -518,7 +518,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) #endif } - std::string strMode = "template"; UniValue lpval = NullUniValue; // TODO: Re-enable coinbasevalue once a specification has been written bool coinbasetxn = true; @@ -530,12 +529,15 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) strMode = modeval.get_str(); else if (modeval.isNull()) { - /* Do nothing */ + std::string strMode = "template"; } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); lpval = find_value(oparam, "longpollid"); + if (strMode == "disablecb") + coinbasetxn = false; + if (strMode == "proposal") { const UniValue& dataval = find_value(oparam, "data"); @@ -567,7 +569,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } } - if (strMode != "template") + if (strMode != "template" || strMode != "disablecb") throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) @@ -694,17 +696,17 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template])); entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template])); - //if (tx.IsCoinBase()) { + if (tx.IsCoinBase() && coinbasetxn == true ) { // Show founders' reward if it is required //if (pblock->vtx[0].vout.size() > 1) { // Correct this if GetBlockTemplate changes the order // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); //} - // CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); - // entry.push_back(Pair("coinbasevalue", nReward)); - // entry.push_back(Pair("required", true)); - // txCoinbase = entry; - // } else + CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); + entry.push_back(Pair("coinbasevalue", nReward)); + entry.push_back(Pair("required", true)); + txCoinbase = entry; + } else transactions.push_back(entry); } @@ -726,12 +728,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) result.push_back(Pair("version", pblock->nVersion)); result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); - //if (coinbasetxn) { - // assert(txCoinbase.isObject()); - // result.push_back(Pair("coinbasetxn", txCoinbase)); - //} else { - // result.push_back(Pair("coinbaseaux", aux)); - // result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + if (coinbasetxn) { + assert(txCoinbase.isObject()); + result.push_back(Pair("coinbasetxn", txCoinbase)); + } // else { + // result.push_back(Pair("coinbaseaux", aux)); + // result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); //} result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); if ( ASSETCHAINS_STAKED != 0 ) From 2205820299eefee6bdedbcb2188cd07e2bc51124 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:11:19 +0800 Subject: [PATCH 0597/3904] fix --- src/rpcmining.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 7d5b2ebdc..a3d7a5893 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -521,6 +521,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) UniValue lpval = NullUniValue; // TODO: Re-enable coinbasevalue once a specification has been written bool coinbasetxn = true; + std::string strMode; if (params.size() > 0) { const UniValue& oparam = params[0].get_obj(); @@ -529,7 +530,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) strMode = modeval.get_str(); else if (modeval.isNull()) { - std::string strMode = "template"; + strMode = "template"; } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); From 4129000ec324cf9bd23678307b4d176d12c52092 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:23:51 +0800 Subject: [PATCH 0598/3904] print --- src/rpcmining.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index a3d7a5893..944879120 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -528,6 +528,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) const UniValue& modeval = find_value(oparam, "mode"); if (modeval.isStr()) strMode = modeval.get_str(); + fprintf(stderr, "%s\n",strMode); else if (modeval.isNull()) { strMode = "template"; From 3354f67d5d576fafd16453fcc4c1b398d56c298b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:25:19 +0800 Subject: [PATCH 0599/3904] fix --- src/rpcmining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 944879120..cb421b9e0 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -528,7 +528,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) const UniValue& modeval = find_value(oparam, "mode"); if (modeval.isStr()) strMode = modeval.get_str(); - fprintf(stderr, "%s\n",strMode); + fprintf(stderr, "%s\n",strMode.c_str()); else if (modeval.isNull()) { strMode = "template"; From b6f711b69d3e0a0d702537a50b66c84ed5b03b9b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:26:36 +0800 Subject: [PATCH 0600/3904] fix --- src/rpcmining.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index cb421b9e0..b317190dd 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -526,9 +526,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) { const UniValue& oparam = params[0].get_obj(); const UniValue& modeval = find_value(oparam, "mode"); - if (modeval.isStr()) + if (modeval.isStr()) { strMode = modeval.get_str(); - fprintf(stderr, "%s\n",strMode.c_str()); + fprintf(stderr, "%s\n",strMode.c_str()); + } else if (modeval.isNull()) { strMode = "template"; From 1d3226eafa4934936fae8fba749835c081750204 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:29:06 +0800 Subject: [PATCH 0601/3904] fix --- src/rpcmining.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index b317190dd..ad2058fd5 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -526,10 +526,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) { const UniValue& oparam = params[0].get_obj(); const UniValue& modeval = find_value(oparam, "mode"); - if (modeval.isStr()) { + if (modeval.isStr()) strMode = modeval.get_str(); - fprintf(stderr, "%s\n",strMode.c_str()); - } else if (modeval.isNull()) { strMode = "template"; @@ -571,6 +569,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } + fprintf(stderr, "%s\n",strMode.c_str()); if (strMode != "template" || strMode != "disablecb") throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); From 47bc56ea6a88664e7d14b69e2fe3095e03824964 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:32:53 +0800 Subject: [PATCH 0602/3904] fix? --- src/rpcmining.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index ad2058fd5..907d13ada 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -569,10 +569,11 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } - fprintf(stderr, "%s\n",strMode.c_str()); + if (coinbasetxn == false ) + fprintf(stderr, "disable coinbase: %s\n",strMode.c_str()); - if (strMode != "template" || strMode != "disablecb") - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); + //if (strMode != "template" || strMode != "disablecb") + // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!"); From 7e45307718c3f325f550fae104f79da27d991629 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:35:30 +0800 Subject: [PATCH 0603/3904] done --- src/rpcmining.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 907d13ada..d3f0563f8 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -569,11 +569,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } - if (coinbasetxn == false ) - fprintf(stderr, "disable coinbase: %s\n",strMode.c_str()); - - //if (strMode != "template" || strMode != "disablecb") - // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!"); From 2016042c79ad810dfdd92c06c36da7e8cdfa1241 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 13:16:56 +0800 Subject: [PATCH 0604/3904] fix! lol --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ae16e316d..51124be23 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541498901; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541500201; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541501501; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1604211111; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 677d4f9b5053791a804a86c908948894ff54fe6e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 14:23:46 +0800 Subject: [PATCH 0605/3904] remove vin,vins --- src/wallet/rpcwallet.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8a62b2153..3d5d41871 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1074,12 +1074,18 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) } if ( spents == mine ) { - TxToRemove.push_back(wtx.GetHash()); for (unsigned int n = 0; n < wtx.vin.size() ; n++) { - if ( pwalletMain->IsMine(wtx.vin[n]) ) - TxToRemove.push_back(wtx.vin[n].prevout.hash); + //if ( pwalletMain->IsMine(wtx.vin[n]) ) + CTransaction vintx; uint256 hashBlock; + if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) + { + for (unsigned int z = 0; z < vintx.vin.size() ; z++) + TxToRemove.push_back(vintx.vin[z].prevout.hash); + } + TxToRemove.push_back(wtx.vin[n].prevout.hash); } + TxToRemove.push_back(wtx.GetHash()); } } From 13a5aa70a7c6e2be3d327820da9ba81dbc901797 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:10:41 +0800 Subject: [PATCH 0606/3904] print --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3d5d41871..a393a0518 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1058,7 +1058,8 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 50 ) + fprintf(stderr, "depth in main chain: %d\n", wtx.GetDepthInMainChain()); + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; CCoins coins; From 462acd24ab3a84a2365190a992beb40f13d2aef5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:21:38 +0800 Subject: [PATCH 0607/3904] fix print --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a393a0518..688675d71 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1058,7 +1058,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - fprintf(stderr, "depth in main chain: %d\n", wtx.GetDepthInMainChain()); + fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; From 2e4ff8898f7d13bd7363d559eb62ad776b3595f4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:32:28 +0800 Subject: [PATCH 0608/3904] try --- src/wallet/rpcwallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 688675d71..725cba3a0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1059,7 +1059,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { const CWalletTx& wtx = (*it).second; fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() > 360 ) continue; CCoins coins; @@ -1082,7 +1082,10 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) - TxToRemove.push_back(vintx.vin[z].prevout.hash); + { + fprintf(stderr, "[ %s ] depth : %d\n", vintx.GetHash().ToString().c_str(),vintx.GetDepthInMainChain()); + TxToRemove.push_back(vintx.vin[z].prevout.hash); + } } TxToRemove.push_back(wtx.vin[n].prevout.hash); } From e0383c82b916480011fb55de8e5a696005d3b855 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:35:50 +0800 Subject: [PATCH 0609/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 725cba3a0..d89368ba5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1083,7 +1083,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) { - fprintf(stderr, "[ %s ] depth : %d\n", vintx.GetHash().ToString().c_str(),vintx.GetDepthInMainChain()); + fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str(); TxToRemove.push_back(vintx.vin[z].prevout.hash); } } From 025924e9ffc8a9ce2da2dc89685f364f659537b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:36:54 +0800 Subject: [PATCH 0610/3904] ) --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d89368ba5..f9ac24016 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1083,7 +1083,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) { - fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str(); + fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str()); TxToRemove.push_back(vintx.vin[z].prevout.hash); } } From 4d6499bd8d737b9bb95818bf13b7aaf0c8463744 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:42:26 +0800 Subject: [PATCH 0611/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f9ac24016..e7a7a2953 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1059,7 +1059,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { const CWalletTx& wtx = (*it).second; fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() > 360 ) + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; CCoins coins; From 2e91034c1ec168edecec4d6b5c7c65a659f4af91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:57:40 +0800 Subject: [PATCH 0612/3904] LogPrintf the removed txs --- src/wallet/rpcwallet.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e7a7a2953..238744805 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1058,7 +1058,6 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; @@ -1077,13 +1076,11 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (unsigned int n = 0; n < wtx.vin.size() ; n++) { - //if ( pwalletMain->IsMine(wtx.vin[n]) ) CTransaction vintx; uint256 hashBlock; if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) { - fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str()); TxToRemove.push_back(vintx.vin[z].prevout.hash); } } @@ -1112,7 +1109,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) if ( SpentHash == tx.vin[n].prevout.hash ) { pwalletMain->EraseFromWallet(tx.GetHash()); - //fprintf(stderr, "ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); + LogPrintf("ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); } } } @@ -1123,7 +1120,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) BOOST_FOREACH (uint256& hash, TxToRemove) { pwalletMain->EraseFromWallet(hash); - //fprintf(stderr, "ERASED spent Tx: %s\n",hash.ToString().c_str()); + LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str()); } // build return JSON for stats. From 55b48771eabd6e77d86795132aaed122f52fceb3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 17:50:01 +0800 Subject: [PATCH 0613/3904] fix --- src/cc/dice.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 847fc5bee..a321d7149 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1425,11 +1425,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { -<<<<<<< HEAD - CCerror = "Diceinit error in bet, is your transaction confirmed?"; -======= + CCerror = "error in Diceinit"; ->>>>>>> 880fda004f9487b7ca227f54d2f733f3139d935e return(""); } if ( bet < minbet || bet > maxbet || odds > maxodds ) @@ -1437,10 +1434,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CCerror = strprintf("Dice plan %s illegal bet %.8f: minbet %.8f maxbet %.8f or odds %d vs max.%d\n",planstr,(double)bet/COIN,(double)minbet/COIN,(double)maxbet/COIN,(int32_t)odds,(int32_t)maxodds); return(""); } -<<<<<<< HEAD - int32_t entropytxs; - if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs)) >= 2*bet*odds+txfee && entropyval != 0 ) -======= int32_t entropytxs=0,emptyvar=0; funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); DicePlanFunds(entropyval2,entropytxid2,sbits,cp,dicepk,fundingtxid,emptyvar,true); @@ -1450,7 +1443,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet entropytxid = entropytxid2; } if ( ( funding >= 2*bet*odds+txfee && entropyval != 0 ) ) ->>>>>>> 880fda004f9487b7ca227f54d2f733f3139d935e { if ( entropytxs < 100 ) { CCerror = "Your dealer is broke, find a new casino."; From c7fec5f7b694c122af0c25c5ce53a899b362d6af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 17:51:00 +0800 Subject: [PATCH 0614/3904] fix --- src/cc/dice.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a321d7149..5a206727b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1643,12 +1643,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { -<<<<<<< HEAD - CCerror = "Diceinit error in status, is your transaction confirmed?"; - fprintf(stderr,"%s\n", CCerror.c_str() ); -======= CCerror = "Diceinit error in status"; ->>>>>>> 880fda004f9487b7ca227f54d2f733f3139d935e return(0.); } win = loss = 0; From 0d318f6411454abebed095070618a0411b55fd10 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:03:52 +0800 Subject: [PATCH 0615/3904] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index f471b0013..c6ac90196 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -458,7 +458,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block),(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From 13a13cd164590cbeb9b8509bf1d3d911c924b69f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:05:55 +0800 Subject: [PATCH 0616/3904] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c6ac90196..43ebf8607 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -458,7 +458,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block),(int32_t)nHeight)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From ecd40761e8b85770f701e035a4329214d55add13 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:31:51 +0800 Subject: [PATCH 0617/3904] fix stream option? --- src/komodo_utils.h | 12 ++++++------ src/pow.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index be39b4d46..9b54dace7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1600,6 +1600,11 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 && ASSETCHAINS_STREAM != 0 ) + { + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); + exit(0); + } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) @@ -1607,11 +1612,6 @@ void komodo_args(char *argv0) decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); } - else if ( ASSETCHAINS_STREAM != 0) - { - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); - exit(0); - } if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { ASSETCHAINS_COMMISSION = 53846154; // maps to 35% @@ -1661,7 +1661,7 @@ void komodo_args(char *argv0) MAX_MONEY = 1000000LL*SATOSHIDEN; if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) MAX_MONEY = 1000000000LL*SATOSHIDEN; - //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); + fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) diff --git a/src/pow.cpp b/src/pow.cpp index 9c8f68586..0e7e6678c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -24,7 +24,7 @@ extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if ( ASSETCHAINS_STREAM == 0) + if ( ASSETCHAINS_STREAM != 2 ) { unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block From eb7f16be6a8c5e0f9033f7900a79aeb47c53fdb3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:45:20 +0800 Subject: [PATCH 0618/3904] h --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9b54dace7..0add63fbb 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1623,12 +1623,12 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_COMMISSION != 0 ) { ASSETCHAINS_COMMISSION = 0; - printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); + printf("ASSETCHAINS_COMMISSION needs an ASSETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } if ( ASSETCHAINS_FOUNDERS != 0 ) { ASSETCHAINS_FOUNDERS = 0; - printf("ASSETCHAINS_FOUNDERS needs an ASETCHAINS_OVERRIDE_PUBKEY\n"); + printf("ASSETCHAINS_FOUNDERS needs an ASSETCHAINS_OVERRIDE_PUBKEY or ASSETCHAINS_SCRIPTPUB\n"); } } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) @@ -1661,7 +1661,7 @@ void komodo_args(char *argv0) MAX_MONEY = 1000000LL*SATOSHIDEN; if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) MAX_MONEY = 1000000000LL*SATOSHIDEN; - fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); + //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From 7c50dd216c722eea4e3f1903d1d168d6ac7a3a4f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 01:33:57 +0800 Subject: [PATCH 0619/3904] try --- src/cc/CCinclude.h | 1 - src/miner.cpp | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index f9924e173..0f3603d41 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -155,7 +155,6 @@ bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t n bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); std::vector Mypubkey(); bool Myprivkey(uint8_t myprivkey[]); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int64_t CCduration(int32_t &numblocks,uint256 txid); bool isCCTxNotarizedConfirmed(uint256 txid); // CCtx diff --git a/src/miner.cpp b/src/miner.cpp index 43ebf8607..a657e773e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -674,7 +674,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - //fprintf(stderr,"use notary pubkey\n"); + fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 05cbb5dee..0641b446c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5085,7 +5085,7 @@ extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); - if ( fHelp || params.size() != 1 ) + if ( fHelp || params.size() > 1 ) throw runtime_error( "setpubkey\n" "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" @@ -5128,10 +5128,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { result.push_back(Pair("IsNotary", notaryname)); IS_KOMODO_NOTARY = 0; - USE_EXTERNAL_PUBKEY = 1; } NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + USE_EXTERNAL_PUBKEY = 1; } } else result.push_back(Pair("error", "pubkey entered is invalid.")); From 025d680a9e209a7813fbd5cbd969ada66372a755 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 10:40:49 +0800 Subject: [PATCH 0620/3904] remove print again --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index a657e773e..43ebf8607 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -674,7 +674,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - fprintf(stderr,"use notary pubkey\n"); + //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { From 8e1f081a7e76bffb9f4eb0a0ea43c7af7001b51c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 11:53:07 +0800 Subject: [PATCH 0621/3904] ix? --- src/cc/dice.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index cc669c771..ea5edea7e 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1254,12 +1254,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } else { return(0); } -<<<<<<< HEAD fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); entropytxs = n; return(totalinputs); -======= ->>>>>>> 4d711ae4aa4c84f55cb63c56770205b46332f40a } bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) @@ -1351,14 +1348,8 @@ UniValue DiceInfo(uint256 diceid) result.push_back(Pair("timeoutblocks",timeoutblocks)); cp = CCinit(&C,EVAL_DICE); dicepk = GetUnspendable(cp,0); -<<<<<<< HEAD - int32_t entropytxs = 0; - funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid,entropytxs); - result.push_back(Pair("entropytxs",entropytxs)); -======= int32_t entropytxs; funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid,entropytxs,false); ->>>>>>> 4d711ae4aa4c84f55cb63c56770205b46332f40a sprintf(numstr,"%.8f",(double)funding/COIN); result.push_back(Pair("funding",numstr)); result.push_back(Pair("entropytxs",entropytxs)); @@ -1485,10 +1476,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CCerror = strprintf("Dice plan %s illegal bet %.8f: minbet %.8f maxbet %.8f or odds %d vs max.%d\n",planstr,(double)bet/COIN,(double)minbet/COIN,(double)maxbet/COIN,(int32_t)odds,(int32_t)maxodds); return(""); } -<<<<<<< HEAD - int32_t entropytxs; - if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs)) >= 2*bet*odds+txfee && entropyval != 0 ) -======= int32_t entropytxs=0,emptyvar=0; funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); DicePlanFunds(entropyval2,entropytxid2,sbits,cp,dicepk,fundingtxid,emptyvar,true); @@ -1498,7 +1485,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet entropytxid = entropytxid2; } if ( ( funding >= 2*bet*odds+txfee && entropyval != 0 ) ) ->>>>>>> 4d711ae4aa4c84f55cb63c56770205b46332f40a { if ( entropytxs < 100 ) { CCerror = "Your dealer is broke, find a new casino."; From 02a54b36a8bf5534dc534fba5d2ccff979167346 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 12:39:11 +0800 Subject: [PATCH 0622/3904] fix max money cap!? --- src/assetchains.json | 12 ++++++++++++ src/komodo_utils.h | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index d26f3a99a..4cac1fc6e 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -177,6 +177,18 @@ ] }, { + "ac_name": "KMDICE", + "ac_supply": "10500000", + "ac_reward": "2500000000", + "ac_halving": "210000", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", + "addnode": [ + "144.76.217.232" + ] + }, + { "ac_name": "DION", "ac_supply": "3900000000", "ac_reward": "22260000000", diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fe6397dcd..2ed50b994 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1641,8 +1641,8 @@ void komodo_args(char *argv0) MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; - if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) - MAX_MONEY = 1000000000LL*SATOSHIDEN; + //if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) + // MAX_MONEY = 1000000000LL*SATOSHIDEN; //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); From e5028657278760d5536ada58319a576b05c15518 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 15:20:20 +0800 Subject: [PATCH 0623/3904] fix setpubkey for pool --- src/wallet/rpcwallet.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0641b446c..17d28aced 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5120,26 +5120,31 @@ UniValue setpubkey(const UniValue& params, bool fHelp) CTxDestination dest = address.Get(); isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { - result.push_back(Pair("error", "privkey for this pubkey is not imported to wallet!")); + result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); - NOTARY_ADDRESS = address.ToString(); std::string notaryname; if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { result.push_back(Pair("IsNotary", notaryname)); IS_KOMODO_NOTARY = 0; } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - USE_EXTERNAL_PUBKEY = 1; } - } else + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + USE_EXTERNAL_PUBKEY = 1; + NOTARY_ADDRESS = address.ToString(); + } else { result.push_back(Pair("error", "pubkey entered is invalid.")); + } } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); } } else { + if ( NOTARY_ADDRESS.empty() ) { + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + NOTARY_ADDRESS.assign(Raddress); + } result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { From 0724759fc48231f550a3f4614e47b61159f45cbd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 13:57:06 +0800 Subject: [PATCH 0624/3904] fix KMD sync issue? --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 92634de0f..2072aadb5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3192,7 +3192,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - if ( ( block.vtx[0].GetValueOut() > blockReward+1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward ) ) + if ( ( block.vtx[0].GetValueOut() > blockReward && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward+1 ) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From 2120ab4fd111d67d655eb434dd9ce6b54bb4f90b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 18:09:23 +0800 Subject: [PATCH 0625/3904] fix --- src/cc/dice.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 7ef00ad6c..81a141d3b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1425,12 +1425,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { -<<<<<<< HEAD CCerror = "error in Diceinit"; -======= - CCerror = "Diceinit error in bet, is your transaction confirmed?"; ->>>>>>> 08b2f80458cd1f0313af8089c9fda3b9a82ea68c return(""); } if ( bet < minbet || bet > maxbet || odds > maxodds ) From cad34b503d51f9076adef1e65435854f54fdba68 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 18:25:07 +0800 Subject: [PATCH 0626/3904] fix streamer with ac_pubey requiring ac_perc --- src/cryptoconditions/compile | 13 +++++----- src/komodo_utils.h | 4 +-- src/pow.cpp | 50 +++++++++++++++++------------------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/cryptoconditions/compile b/src/cryptoconditions/compile index a85b723c7..99e50524b 100755 --- a/src/cryptoconditions/compile +++ b/src/cryptoconditions/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2012-10-14.11; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -255,7 +255,8 @@ EOF echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -339,9 +340,9 @@ exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a1705c20a..80581a1f8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1620,10 +1620,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else + else if ( ASSETCHAINS_STREAM == 0 ) { ASSETCHAINS_OVERRIDE_PUBKEY.clear(); - printf("-ac_perc must be set with -ac_pubkey\n"); + printf("-ac_perc or -ac_stream must be set with -ac_pubkey\n"); } } } diff --git a/src/pow.cpp b/src/pow.cpp index 0e7e6678c..07776e273 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -24,35 +24,31 @@ extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if ( ASSETCHAINS_STREAM != 2 ) - { - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); - // Genesis block - if (pindexLast == NULL ) - return nProofOfWorkLimit; - - // Find the first block in the averaging interval - const CBlockIndex* pindexFirst = pindexLast; - arith_uint256 bnTot {0}; - for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { - arith_uint256 bnTmp; - bnTmp.SetCompact(pindexFirst->nBits); - bnTot += bnTmp; - pindexFirst = pindexFirst->pprev; - } - - // Check we have enough blocks - if (pindexFirst == NULL) - return nProofOfWorkLimit; - - arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; - - return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); - } - else - { + if ( ASSETCHAINS_STREAM == 2 ) return 537857807; + + unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); + // Genesis block + if (pindexLast == NULL ) + return nProofOfWorkLimit; + + // Find the first block in the averaging interval + const CBlockIndex* pindexFirst = pindexLast; + arith_uint256 bnTot {0}; + for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { + arith_uint256 bnTmp; + bnTmp.SetCompact(pindexFirst->nBits); + bnTot += bnTmp; + pindexFirst = pindexFirst->pprev; } + + // Check we have enough blocks + if (pindexFirst == NULL) + return nProofOfWorkLimit; + + arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; + + return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); } unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, From 3cc9f623a8ce2f95f9030ce80a95e78fa2cd9171 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 20:44:52 +0800 Subject: [PATCH 0627/3904] commit toest to dev, clean wallet branch broken --- src/rpcserver.cpp | 2 +- src/rpcserver.h | 2 +- src/wallet/rpcwallet.cpp | 37 ++++++++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 4100d2210..81a8f7cf5 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -494,7 +494,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - { "wallet", "cleanwalletnotarisations", &cleanwalletnotarisations, false }, + { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 579db50c9..5be24c633 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -300,7 +300,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -extern UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp); +extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c16df1a42..c46e3043d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -999,15 +999,15 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } -UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) +UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; if (fHelp || params.size() > 1 ) throw runtime_error( - "cleanwalletnotarisations \"txid\"\n" - "\nRemove all txs which are totally spent and all notarisations created from them, you can clear all txs bar one, by specifiying a txid.\n" + "cleanwallettransactions \"txid\"\n" + "\nRemove all txs which are totally spent, you can clear all txs bar one, by specifiying a txid.\n" "\nPlease backup your wallet.dat before running this command.\n" "\nArguments:\n" "1. \"txid\" (string, optional) The transaction id to keep.\n" @@ -1042,7 +1042,6 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - txs++; const CWalletTx& wtx = (*it).second; if ( wtx.GetHash() != exception ) { @@ -1058,7 +1057,23 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) } else { - std::vector NotarisationTxs; + // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, + // then delete all txs in the wallet before this block + 10 as safety buffer. + vector vecOutputs; + assert(pwalletMain != NULL); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + int32_t oldestTxHeight = 0; + BOOST_FOREACH(const COutput& out, vecOutputs) + { + int32_t txheight = out.nDepth; + fprintf(stderr, "txheight.%i\n", txheight); + if ( txheight > oldestTxHeight ) + oldestTxHeight = txheight; + } + fprintf(stderr, "oldestTxHeight.%i\n",oldestTxHeight); + + + /*std::vector NotarisationTxs; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; @@ -1117,15 +1132,15 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) } } } - } + } */ } // erase txs - BOOST_FOREACH (uint256& hash, TxToRemove) + /*BOOST_FOREACH (uint256& hash, TxToRemove) { pwalletMain->EraseFromWallet(hash); LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str()); - } + } */ // build return JSON for stats. int remaining = pwalletMain->mapWallet.size(); @@ -5755,7 +5770,7 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); - coin = params[1].get_str(); + coin = params[1].get_str(); withdrawpub = ParseHex(params[2].get_str()); amount = atof((char *)params[3].get_str().c_str()) * COIN; hex = GatewaysWithdraw(0,bindtxid,coin,pubkey2pk(withdrawpub),amount); @@ -5808,7 +5823,7 @@ UniValue gatewaysmultisig(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK2(cs_main, pwalletMain->cs_wallet); txidaddr = (char *)params[0].get_str().c_str(); return(GatewaysMultisig(txidaddr)); } @@ -5821,7 +5836,7 @@ UniValue gatewayspartialsign(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); parthex = params[2].get_str(); From eead6be2c7b1fc6eb4f1199bf8b16ad9c8120c98 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 21:24:08 +0800 Subject: [PATCH 0628/3904] add delete logic --- src/wallet/rpcwallet.cpp | 89 ++++++++-------------------------------- 1 file changed, 18 insertions(+), 71 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c46e3043d..73f3e7f66 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1057,90 +1057,37 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) } else { - // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, - // then delete all txs in the wallet before this block + 10 as safety buffer. - vector vecOutputs; - assert(pwalletMain != NULL); - pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - int32_t oldestTxHeight = 0; - BOOST_FOREACH(const COutput& out, vecOutputs) - { - int32_t txheight = out.nDepth; - fprintf(stderr, "txheight.%i\n", txheight); - if ( txheight > oldestTxHeight ) - oldestTxHeight = txheight; - } - fprintf(stderr, "oldestTxHeight.%i\n",oldestTxHeight); + // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, + vector vecOutputs; + assert(pwalletMain != NULL); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + int32_t oldestTxDepth = 0; + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( out.nDepth > oldestTxHeight ) + oldestTxDepth = out.nDepth; + } + oldestTxDepth = oldestTxDepth + 1; + fprintf(stderr, "oldestTxHeight.%i\n",oldestTxHeight); - - /*std::vector NotarisationTxs; + // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) - continue; - - CCoins coins; - if (!pcoinsTip->GetCoins(wtx.GetHash(), coins)) + if (wtx.GetDepthInMainChain() < oldestTxDepth) { - int spents = 0; int mine = 0; - for (unsigned int n = 0; n < wtx.vout.size() ; n++) - { - if ( pwalletMain->IsMine(wtx.vout[n]) ) - mine++; - if ( ((unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) ) - spents++; - } - if ( spents == mine ) - { - for (unsigned int n = 0; n < wtx.vin.size() ; n++) - { - CTransaction vintx; uint256 hashBlock; - if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) - { - for (unsigned int z = 0; z < vintx.vin.size() ; z++) - { - TxToRemove.push_back(vintx.vin[z].prevout.hash); - } - } - TxToRemove.push_back(wtx.vin[n].prevout.hash); - } - TxToRemove.push_back(wtx.GetHash()); - } - } - - CTxDestination address; - // get all notarisations - if ( ExtractDestination(wtx.vout[0].scriptPubKey, address) ) - { - if ( strcmp(CBitcoinAddress(address).ToString().c_str(),CRYPTO777_KMDADDR) == 0 ) - NotarisationTxs.push_back(wtx); + TxToRemove.push_back(wtx.GetHash()); + fprintf(stderr, "[%s] : depth.%i \n",wtx.GetHash(),wtx.GetDepthInMainChain()); } } - - // Erase notarisations spending from fully spent splits. - BOOST_FOREACH (CWalletTx& tx, NotarisationTxs) - { - for (int n = 0; n < tx.vin.size(); n++) - { - BOOST_FOREACH (uint256& SpentHash, TxToRemove) - { - if ( SpentHash == tx.vin[n].prevout.hash ) - { - pwalletMain->EraseFromWallet(tx.GetHash()); - LogPrintf("ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); - } - } - } - } */ } // erase txs - /*BOOST_FOREACH (uint256& hash, TxToRemove) + BOOST_FOREACH (uint256& hash, TxToRemove) { pwalletMain->EraseFromWallet(hash); LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str()); - } */ + } // build return JSON for stats. int remaining = pwalletMain->mapWallet.size(); From 769d800441bbefa5fe94454cd72374a482fa1aed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 21:26:03 +0800 Subject: [PATCH 0629/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 73f3e7f66..2e848cd75 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1077,7 +1077,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) if (wtx.GetDepthInMainChain() < oldestTxDepth) { TxToRemove.push_back(wtx.GetHash()); - fprintf(stderr, "[%s] : depth.%i \n",wtx.GetHash(),wtx.GetDepthInMainChain()); + fprintf(stderr, "[%s] : depth.%i \n",wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); } } } From 702f709517bf5b0e201b169a530ea87df71f2082 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 21:27:12 +0800 Subject: [PATCH 0630/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2e848cd75..631a475de 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1068,7 +1068,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) oldestTxDepth = out.nDepth; } oldestTxDepth = oldestTxDepth + 1; - fprintf(stderr, "oldestTxHeight.%i\n",oldestTxHeight); + fprintf(stderr, "oldestTxDepth.%i\n",oldestTxDepth); // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) From dbbe6d419194f7f9f6df88764bc539234a963541 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 21:28:10 +0800 Subject: [PATCH 0631/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 631a475de..fed60ff31 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1064,7 +1064,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) int32_t oldestTxDepth = 0; BOOST_FOREACH(const COutput& out, vecOutputs) { - if ( out.nDepth > oldestTxHeight ) + if ( out.nDepth > oldestTxDepth ) oldestTxDepth = out.nDepth; } oldestTxDepth = oldestTxDepth + 1; From d506b5433e3e5be219ea10870036f4e0d3f83944 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 21:32:19 +0800 Subject: [PATCH 0632/3904] > --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fed60ff31..a5cb169d6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1074,7 +1074,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - if (wtx.GetDepthInMainChain() < oldestTxDepth) + if (wtx.GetDepthInMainChain() > oldestTxDepth) { TxToRemove.push_back(wtx.GetHash()); fprintf(stderr, "[%s] : depth.%i \n",wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); From 540e3f03b2f70f86052edeba424dfac3140ef80c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 22:31:20 +0800 Subject: [PATCH 0633/3904] fix log prints --- src/wallet/rpcwallet.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index de50d0257..56525625f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1008,7 +1008,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) if (fHelp || params.size() > 1 ) throw runtime_error( "cleanwallettransactions \"txid\"\n" - "\nRemove all txs which are totally spent, you can clear all txs bar one, by specifiying a txid.\n" + "\nRemove all txs that are spent. You can clear all txs bar one, by specifiying a txid.\n" "\nPlease backup your wallet.dat before running this command.\n" "\nArguments:\n" "1. \"txid\" (string, optional) The transaction id to keep.\n" @@ -1068,18 +1068,14 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) if ( out.nDepth > oldestTxDepth ) oldestTxDepth = out.nDepth; } - oldestTxDepth = oldestTxDepth + 1; - fprintf(stderr, "oldestTxDepth.%i\n",oldestTxDepth); + oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.GetDepthInMainChain() > oldestTxDepth) - { TxToRemove.push_back(wtx.GetHash()); - fprintf(stderr, "[%s] : depth.%i \n",wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); - } } } @@ -1087,7 +1083,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) BOOST_FOREACH (uint256& hash, TxToRemove) { pwalletMain->EraseFromWallet(hash); - LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str()); + LogPrintf("Erased %s from wallet.\n",hash.ToString().c_str()); } // build return JSON for stats. From 02c49755a585fab54e469206da5c7dbc97a7fcf4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 22:55:36 +0800 Subject: [PATCH 0634/3904] fix wallet cleaner --- src/rpcserver.cpp | 2 +- src/rpcserver.h | 2 +- src/wallet/rpcwallet.cpp | 88 +++++++++++----------------------------- 3 files changed, 25 insertions(+), 67 deletions(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 7267461b3..65f12a346 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -495,7 +495,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - { "wallet", "cleanwalletnotarisations", &cleanwalletnotarisations, false }, + { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 873e2dc05..f7fa65942 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -300,7 +300,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -extern UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp); +extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 69c310bcf..a5c8bdaff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1003,15 +1003,15 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } -UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) +UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; if (fHelp || params.size() > 1 ) throw runtime_error( - "cleanwalletnotarisations \"txid\"\n" - "\nRemove all txs which are totally spent and all notarisations created from them, you can clear all txs bar one, by specifiying a txid.\n" + "cleanwallettransactions \"txid\"\n" + "\nRemove all txs that are spent. You can clear all txs bar one, by specifiying a txid.\n" "\nPlease backup your wallet.dat before running this command.\n" "\nArguments:\n" "1. \"txid\" (string, optional) The transaction id to keep.\n" @@ -1022,10 +1022,10 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("cleanoldtxs", "") - + HelpExampleCli("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") - + HelpExampleRpc("cleanoldtxs", "") - + HelpExampleRpc("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleCli("cleanwallettransactions", "") + + HelpExampleCli("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("cleanwallettransactions", "") + + HelpExampleRpc("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1046,7 +1046,6 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - txs++; const CWalletTx& wtx = (*it).second; if ( wtx.GetHash() != exception ) { @@ -1062,65 +1061,24 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) } else { - std::vector NotarisationTxs; + // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, + vector vecOutputs; + assert(pwalletMain != NULL); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + int32_t oldestTxDepth = 0; + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( out.nDepth > oldestTxDepth ) + oldestTxDepth = out.nDepth; + } + oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + + // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) - continue; - - CCoins coins; - if (!pcoinsTip->GetCoins(wtx.GetHash(), coins)) - { - int spents = 0; int mine = 0; - for (unsigned int n = 0; n < wtx.vout.size() ; n++) - { - if ( pwalletMain->IsMine(wtx.vout[n]) ) - mine++; - if ( ((unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) ) - spents++; - } - if ( spents == mine ) - { - for (unsigned int n = 0; n < wtx.vin.size() ; n++) - { - CTransaction vintx; uint256 hashBlock; - if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) - { - for (unsigned int z = 0; z < vintx.vin.size() ; z++) - { - TxToRemove.push_back(vintx.vin[z].prevout.hash); - } - } - TxToRemove.push_back(wtx.vin[n].prevout.hash); - } - TxToRemove.push_back(wtx.GetHash()); - } - } - - CTxDestination address; - // get all notarisations - if ( ExtractDestination(wtx.vout[0].scriptPubKey, address) ) - { - if ( strcmp(CBitcoinAddress(address).ToString().c_str(),CRYPTO777_KMDADDR) == 0 ) - NotarisationTxs.push_back(wtx); - } - } - - // Erase notarisations spending from fully spent splits. - BOOST_FOREACH (CWalletTx& tx, NotarisationTxs) - { - for (int n = 0; n < tx.vin.size(); n++) - { - BOOST_FOREACH (uint256& SpentHash, TxToRemove) - { - if ( SpentHash == tx.vin[n].prevout.hash ) - { - pwalletMain->EraseFromWallet(tx.GetHash()); - LogPrintf("ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); - } - } - } + if (wtx.GetDepthInMainChain() > oldestTxDepth) + TxToRemove.push_back(wtx.GetHash()); } } @@ -1128,7 +1086,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) BOOST_FOREACH (uint256& hash, TxToRemove) { pwalletMain->EraseFromWallet(hash); - LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str()); + LogPrintf("Erased %s from wallet.\n",hash.ToString().c_str()); } // build return JSON for stats. From b22e82022f94e71dfef378146a6d737dd482a3ed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 22:56:23 +0800 Subject: [PATCH 0635/3904] fix help --- src/wallet/rpcwallet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 56525625f..605e55c74 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1019,10 +1019,10 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("cleanoldtxs", "") - + HelpExampleCli("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") - + HelpExampleRpc("cleanoldtxs", "") - + HelpExampleRpc("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleCli("cleanwallettransactions", "") + + HelpExampleCli("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("cleanwallettransactions", "") + + HelpExampleRpc("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); From 7a89c512ce4a61f7652adf3986fbf262c5f3a093 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 20 Nov 2018 13:32:17 +0800 Subject: [PATCH 0636/3904] x10 safety margin --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 605e55c74..b075c22d3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1068,7 +1068,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) if ( out.nDepth > oldestTxDepth ) oldestTxDepth = out.nDepth; } - oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + oldestTxDepth = oldestTxDepth + 1; // add extra 10 blocks just for safety. // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) From 692de95bb7e1cfdc03c96b2118cc028254c8a2ac Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 21 Nov 2018 18:20:31 +0800 Subject: [PATCH 0637/3904] unlock locked utxo before fetching unspents, then relock them. --- src/wallet/rpcwallet.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b075c22d3..00222f116 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1058,6 +1058,11 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) } else { + // get all locked utxos to relock them later. + vector vLockedUTXO; + pwalletMain->ListLockedCoins(vLockedUTXO); + // unlock all coins so that the following call containes all utxos. + pwalletMain->UnlockAllCoins(); // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, vector vecOutputs; assert(pwalletMain != NULL); @@ -1068,7 +1073,11 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) if ( out.nDepth > oldestTxDepth ) oldestTxDepth = out.nDepth; } - oldestTxDepth = oldestTxDepth + 1; // add extra 10 blocks just for safety. + oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + // lock all the previouly locked coins. + BOOST_FOREACH(COutPoint &outpt, vOutpts) { + pwalletMain->LockCoin(outpt); + } // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) From 805ea3594f77cdcef7bba926268c09be8f5fe27f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 21 Nov 2018 18:23:02 +0800 Subject: [PATCH 0638/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 00222f116..ac64027d6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1075,7 +1075,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) } oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. // lock all the previouly locked coins. - BOOST_FOREACH(COutPoint &outpt, vOutpts) { + BOOST_FOREACH(COutPoint &outpt, vLockedUTXO) { pwalletMain->LockCoin(outpt); } From f72c3ba1d27e3e8d4dc7e0f19ed0138c4965ba5c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 16:51:34 +0800 Subject: [PATCH 0639/3904] fix --- src/komodo.h | 6 ++++-- src/rpcmisc.cpp | 8 ++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 9 +++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e6c9a8c54..5b1bfe1ac 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -811,9 +811,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) return; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY != -1 ) { + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { staked_era = STAKED_era(pindex->GetBlockTime()); - if ( staked_era != lastStakedEra ) { + if ( staked_era != lastStakedEra ) + { uint8_t tmp_pubkeys[64][33]; int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); UpdateNotaryAddrs(tmp_pubkeys,numSN); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index e51a50a97..f85705a90 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,14 @@ extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; +UniValue getiguanajson(const UniValue& params, bool fHelp) +{ + if ( params.size() != 1 ) + throw runtime_error("please supply old staked.json!\n"); + UniValue json = params[0].get_obj(); + return json; +} + UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 65f12a346..dc0ebd465 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -263,6 +263,7 @@ static const CRPCCommand vRPCCommands[] = /* Overall control/query calls */ { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, + { "control", "getiguanajson", &getiguanajson, true }, { "control", "stop", &stop, true }, /* P2P networking */ diff --git a/src/rpcserver.h b/src/rpcserver.h index f7fa65942..2ae1e8de1 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -324,6 +324,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); +extern UniValue getiguanajson(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a5c8bdaff..d6a06525d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1061,6 +1061,11 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) } else { + // get all locked utxos to relock them later. + vector vLockedUTXO; + pwalletMain->ListLockedCoins(vLockedUTXO); + // unlock all coins so that the following call containes all utxos. + pwalletMain->UnlockAllCoins(); // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, vector vecOutputs; assert(pwalletMain != NULL); @@ -1072,6 +1077,10 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) oldestTxDepth = out.nDepth; } oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + // lock all the previouly locked coins. + BOOST_FOREACH(COutPoint &outpt, vLockedUTXO) { + pwalletMain->LockCoin(outpt); + } // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) From 06659e51f2ba27e7a022ea0cd29d7b1f7723f7bb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 16:55:14 +0800 Subject: [PATCH 0640/3904] remove wrong +1 fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 590e3569f..840705d2d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3189,7 +3189,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - if ( ( block.vtx[0].GetValueOut() > blockReward+1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward ) ) + if ( ( block.vtx[0].GetValueOut() > blockReward+1 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From ec8f86f89db78e29f1898fc5d36dd9e93fef82b7 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Thu, 22 Nov 2018 11:05:39 +0100 Subject: [PATCH 0641/3904] update ERA2 --- src/notaries_staked.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index bb2289a17..ae2646e9e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -40,20 +40,25 @@ const char *notaries_STAKED2[][2] = {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, //RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu + {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 + {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p + {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s + {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t + {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 + {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q + {"dukeleto", "03e4322510ee46d417b8382fe124f5a381a3cef6aef08f8a4e90c66a42a04b4015" }, // RB8vS1fkGuttoNYkA2B1ivNn8vhqbCEqbe + {"gcharang", "03336ca9db27cb6e882830e20dc525884e27dc94d557a5e68b972a5cbf9e8c62a8" }, // RJYiWn3FRCSSLf9Pe5RJcbrKQYosaMburP + {"ca333", "03a18a33313ccdbf3c9778776e33c423e073ff5833fa1de092ce9e921de52f22f6" }, // RX333A56jWdeW15MwZsaW3mHxGaDu2Yutp + {"computergenie", "03448ce28fb21748e8b05bbe32d6b1e758b589ac1eb359e5d552f8868f2b75dc92" }, // RGeniexxkjnR34hg7ZnCf36kmfuJusf6rE }; int num_notaries_STAKED2 = (sizeof(notaries_STAKED2)/sizeof(*notaries_STAKED2)); From 7d13c2e5a0b4eadb56d87433ebb5254daea2a6aa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 19:49:49 +0800 Subject: [PATCH 0642/3904] add getiguanajson RPC, for ERA2 only at this stage. --- src/notaries_staked.cpp | 24 ++++++++++++++++------ src/notaries_staked.h | 11 ++++++---- src/rpcmisc.cpp | 45 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 67 insertions(+), 13 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ae2646e9e..65e71f0c6 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -10,6 +10,18 @@ extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; +const char *iguanaSeeds[8][1] = +{ + {"80.240.17.222"}, + {"103.6.12.112"}, + {"18.224.176.46"}, + {"45.76.120.247"}, + {"103.6.12.112"}, + {"103.6.12.112"}, + {"103.6.12.112"}, + {"103.6.12.112"}, +}; + // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = { @@ -113,9 +125,9 @@ int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); int8_t is_STAKED(const char *chain_name) { int STAKED = 0; - if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; - else if ( (strcmp(chain_name, "STKD") == 0) || (strncmp(chain_name, "STKD", 4) == 0) ) + else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; @@ -126,13 +138,13 @@ int8_t is_STAKED(const char *chain_name) { int32_t STAKED_era(int timestamp) { int8_t era = 0; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) + if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) era = 1; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[1] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[0] + STAKED_ERA_GAP)) era = 2; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[2] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[1] + STAKED_ERA_GAP)) era = 3; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[3] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[2] + STAKED_ERA_GAP)) era = 4; else era = 0; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 51124be23..f71f75264 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,12 +5,15 @@ #include "crosschain.h" #include "cc/CCinclude.h" +static const int32_t iguanaPort = 9997; +static const int8_t BTCminsigs = 13; +static const int8_t overrideMinSigs = 0; +extern const char *iguanaSeeds[8][1]; + static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1604211111; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; +static const int NUM_STAKED_ERAS = 4; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542885514, 1604222222, 1604233333, 1604244444}; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f85705a90..965286d6b 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -66,9 +66,48 @@ extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[ UniValue getiguanajson(const UniValue& params, bool fHelp) { - if ( params.size() != 1 ) - throw runtime_error("please supply old staked.json!\n"); - UniValue json = params[0].get_obj(); + if (fHelp || params.size() != 0) + throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA."); + + UniValue json(UniValue::VOBJ); + UniValue seeds(UniValue::VARR); + UniValue notaries(UniValue::VARR); + // get the current era, use local time for now. + // should ideally take blocktime of last known block. + int now = time(NULL); int32_t era; + for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { + if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + era = i + 1; + break; + } + } + if ( era != 2 ) + throw runtime_error("its not era2 yet!"); + + // loop over seeds array and push back to json array for seeds + for (int8_t i = 0; i < 8; i++) { + seeds.push_back(iguanaSeeds[i][0]); + } + + // loop over era's notaries and push back each pair to the notary array + for (int8_t i = 0; i < num_notaries_STAKED2; i++) { + UniValue notary(UniValue::VOBJ); + notary.push_back(Pair(notaries_STAKED2[i][0],notaries_STAKED2[i][1])); + notaries.push_back(notary); + } + + // get the min sigs + int minsigs; + if ( num_notaries_STAKED2/5 > overrideMinSigs ) + minsigs = (num_notaries_STAKED2 + 4) / 5; + else + minsigs = overrideMinSigs; + + json.push_back(Pair("port",iguanaPort)); + json.push_back(Pair("BTCminsigs",BTCminsigs)); + json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("seeds", seeds)); + json.push_back(Pair("notaries",notaries)); return json; } From 03c35656685cff2ff1db602fc2d025a47ba8c2c3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 19:51:13 +0800 Subject: [PATCH 0643/3904] fix ( --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 840705d2d..903b07a65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3189,7 +3189,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - if ( ( block.vtx[0].GetValueOut() > blockReward+1 ) + if ( block.vtx[0].GetValueOut() > blockReward+1 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From 5bbc803ee844b8d977b62609b0e9fab293aabbed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 23:05:15 +0800 Subject: [PATCH 0644/3904] refactor to use 3d array of pubkeys --- src/notaries_staked.cpp | 236 +++++++--------------------------------- src/notaries_staked.h | 113 ++++++++++++++++--- src/rpcmisc.cpp | 12 +- 3 files changed, 146 insertions(+), 215 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 65e71f0c6..19fe06b81 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -10,119 +10,6 @@ extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; -const char *iguanaSeeds[8][1] = -{ - {"80.240.17.222"}, - {"103.6.12.112"}, - {"18.224.176.46"}, - {"45.76.120.247"}, - {"103.6.12.112"}, - {"103.6.12.112"}, - {"103.6.12.112"}, - {"103.6.12.112"}, -}; - -// Era 1 set of pubkeys -const char *notaries_STAKED1[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED1 = (sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1)); - -// Era 2 set of pubkeys -const char *notaries_STAKED2[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, //RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu - {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 - {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p - {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t - {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 - {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q - {"dukeleto", "03e4322510ee46d417b8382fe124f5a381a3cef6aef08f8a4e90c66a42a04b4015" }, // RB8vS1fkGuttoNYkA2B1ivNn8vhqbCEqbe - {"gcharang", "03336ca9db27cb6e882830e20dc525884e27dc94d557a5e68b972a5cbf9e8c62a8" }, // RJYiWn3FRCSSLf9Pe5RJcbrKQYosaMburP - {"ca333", "03a18a33313ccdbf3c9778776e33c423e073ff5833fa1de092ce9e921de52f22f6" }, // RX333A56jWdeW15MwZsaW3mHxGaDu2Yutp - {"computergenie", "03448ce28fb21748e8b05bbe32d6b1e758b589ac1eb359e5d552f8868f2b75dc92" }, // RGeniexxkjnR34hg7ZnCf36kmfuJusf6rE -}; - -int num_notaries_STAKED2 = (sizeof(notaries_STAKED2)/sizeof(*notaries_STAKED2)); - -// Era 3 set of pubkeys -const char *notaries_STAKED3[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); - -// Era 4 set of pubkeys -const char *notaries_STAKED4[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); - int8_t is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) @@ -137,19 +24,16 @@ int8_t is_STAKED(const char *chain_name) { int32_t STAKED_era(int timestamp) { - int8_t era = 0; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) - era = 1; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[1] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[0] + STAKED_ERA_GAP)) - era = 2; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[2] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[1] + STAKED_ERA_GAP)) - era = 3; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[3] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[2] + STAKED_ERA_GAP)) - era = 4; - else - era = 0; + int8_t era = 0; + if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) + return(1); + for (int32_t i = 1; i < NUM_STAKED_ERAS; i++) + { + if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP)) + return(i); + } // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - return(era); + return(0); }; #ifdef SERVER @@ -169,24 +53,16 @@ int8_t updateStakedNotary() { #endif int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - int8_t notaryID = -1; - if ( STAKED_ERA != 0 ) { - switch (STAKED_ERA) { - case 1: - notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname); - break; - case 2: - notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname); - break; - case 3: - notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname); - break; - case 4: - notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname); - break; - } + if ( STAKED_ERA != 0 ) + { + for (int8_t i = 0; i < num_notaries_STAKED[STAKED_ERA-1]; i++) { + if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { + notaryname.assign(notaries_STAKED[STAKED_ERA-1][i][0]); + return(i); + } + } } - return(notaryID); + return(-1); } int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { @@ -208,50 +84,50 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { case 1: if ( didstaked1 == 0 ) { - for (i=0; i overrideMinSigs ) - minsigs = (num_notaries_STAKED2 + 4) / 5; + if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) + minsigs = (num_notaries_STAKED[era] + 4) / 5; else minsigs = overrideMinSigs; From e232fd00498c4e3c844f0200540a71f5abdf5cd1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 00:02:46 +0800 Subject: [PATCH 0645/3904] fix new era function --- src/notaries_staked.cpp | 4 ++-- src/rpcmisc.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 19fe06b81..d29d5dfb2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -18,7 +18,7 @@ int8_t is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chain is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; @@ -30,7 +30,7 @@ int32_t STAKED_era(int timestamp) for (int32_t i = 1; i < NUM_STAKED_ERAS; i++) { if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP)) - return(i); + return(i+1); } // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. return(0); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 1a5095823..a8f1830ff 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -109,6 +109,8 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) return json; } + + UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; From 1dfb6457a1b533335e84689dee9dd99c6ffb22ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 00:17:57 +0800 Subject: [PATCH 0646/3904] fix --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 5b1bfe1ac..e58fe9be6 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -811,7 +811,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) return; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); if ( staked_era != lastStakedEra ) From f24352c4a21f58d96f7c4b08ee038fdcda1662b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 01:28:05 +0800 Subject: [PATCH 0647/3904] revert era to 1 --- src/notaries_staked.h | 2 +- src/rpcmisc.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index a931abdf7..0c2a7eb22 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542885514, 1604222222, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1604111111, 1604222222, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a8f1830ff..4160da730 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -109,7 +109,28 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) return json; } - +UniValue getnotarysendmany(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error("getnotarysendmany\n "); + // era + int32_t era = params[0].get_int() - 1; + if ( era < 0 || era > NUM_STAKED_ERAS ) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); + // Amount + CAmount nAmount = AmountFromValue(params[1]); + if (nAmount <= 0) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); + UniValue ret(UniValue::VOBJ) + for (int i = 0; i Date: Fri, 23 Nov 2018 01:29:52 +0800 Subject: [PATCH 0648/3904] fix --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 4160da730..a9ce7ffd8 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -121,7 +121,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) CAmount nAmount = AmountFromValue(params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); - UniValue ret(UniValue::VOBJ) + UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 02:32:25 +0800 Subject: [PATCH 0649/3904] try this --- src/notarisationdb.cpp | 1 + src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 3 files changed, 3 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index f551edf3f..a4efa8b24 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -50,6 +50,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) // pass era slection off to notaries_staked.cpp file auth_STAKED = Choose_auth_STAKED(staked_era); } + printf("minsigs.%i era.%i authsize.%i\n",auth_STAKED.requiredSigs,staked_era,auth_STAKED.size); if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index dc0ebd465..d4143fcfb 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,6 +264,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "getiguanajson", &getiguanajson, true }, + { "control", "getnotarysendmany", &getnotarysendmany, true }, { "control", "stop", &stop, true }, /* P2P networking */ diff --git a/src/rpcserver.h b/src/rpcserver.h index 2ae1e8de1..9ab033d12 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -325,6 +325,7 @@ extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); extern UniValue getiguanajson(const UniValue& params, bool fHelp); +extern UniValue getnotarysendmany(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); From eb533cf7d7975fea498d3dc6fc8c7d1fd653c67e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 02:42:57 +0800 Subject: [PATCH 0650/3904] fix? --- src/crosschain.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain.h b/src/crosschain.h index c186d5161..b59037cc8 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -9,8 +9,8 @@ const int CROSSCHAIN_STAKED = 3; typedef struct CrosschainAuthority { uint8_t notaries[64][33]; - size_t size; - size_t requiredSigs; + int8_t size; + int8_t requiredSigs; } CrosschainAuthority; int GetSymbolAuthority(const char* symbol); From 46f857e7300d349df264a3567557958d0f868c6e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:04:30 +0800 Subject: [PATCH 0651/3904] try --- src/crosschain_authority.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 8116b2887..c43639836 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -42,10 +42,14 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (!seen[i]) { if (memcmp(pk, auth.notaries[i], 33) == 0) { seen[i] = 1; + printf("seennotary..%i\n",i); goto found; + } else { + printf("notary.%i is not valid!\n",i); } } } + return false; found:; } From f6c1f9803821d0f911c95ae49bf0b05cf971b8c2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:09:15 +0800 Subject: [PATCH 0652/3904] fix --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a9ce7ffd8..d3dd9a569 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -111,7 +111,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany\n "); // era int32_t era = params[0].get_int() - 1; From 141cca7fa7de59c0298a3f40a6cfb8e95992021e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:33:04 +0800 Subject: [PATCH 0653/3904] try --- src/crosschain_authority.cpp | 2 +- src/rpcmisc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index c43639836..262a70c40 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -42,7 +42,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (!seen[i]) { if (memcmp(pk, auth.notaries[i], 33) == 0) { seen[i] = 1; - printf("seennotary..%i\n",i); + printf("seennotary.%i\n",i); goto found; } else { printf("notary.%i is not valid!\n",i); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index d3dd9a569..5deaf15c1 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany\n "); // era - int32_t era = params[0].get_int() - 1; + int32_t era = (int)params[0] - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From d7d0047b8f4a4b1d0b777c1458eff885d1f6a1cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:58:04 +0800 Subject: [PATCH 0654/3904] try --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5deaf15c1..89c66355f 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany\n "); // era - int32_t era = (int)params[0] - 1; + int32_t era = params[0] - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From 84c5374aaa307feeb252829676cd372e51ef8019 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:03:27 +0800 Subject: [PATCH 0655/3904] try --- src/rpcmisc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 89c66355f..64537d401 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -112,13 +112,13 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 2) - throw runtime_error("getnotarysendmany\n "); + throw runtime_error("getnotarysendmany "); // era - int32_t era = params[0] - 1; + int32_t era = params[1].get_int() - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount - CAmount nAmount = AmountFromValue(params[1]); + CAmount nAmount = AmountFromValue(params[0]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); UniValue ret(UniValue::VOBJ); From 504d318eac432298d03ece964c9689271c9e67b8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:08:49 +0800 Subject: [PATCH 0656/3904] try --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 64537d401..0ffe4ecf6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era - int32_t era = params[1].get_int() - 1; + era = params[1].get_int() - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From a632f010dd202868d2f21eb89b7776848e28510f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:10:18 +0800 Subject: [PATCH 0657/3904] try --- src/rpcmisc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 0ffe4ecf6..f323a73ce 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,6 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era + int era = 1; era = params[1].get_int() - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); From 918ba2b923a812cd93a7a4b3caf630da6b5afc29 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:15:53 +0800 Subject: [PATCH 0658/3904] try --- src/rpcmisc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f323a73ce..003c39bde 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,8 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era - int era = 1; - era = params[1].get_int() - 1; + int era = ValueFromAmount(AmountFromValue(params[1])); if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From 9168011a9a74ff5e174a57d9a786c8e5c64d5eed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:18:14 +0800 Subject: [PATCH 0659/3904] fix --- src/rpcmisc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 003c39bde..91faf6221 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,8 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era - int era = ValueFromAmount(AmountFromValue(params[1])); + int era = AmountFromValue(params[1]); + printf("%i\n",era ); if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From 85a7b3b92a327c4589b588ae7c3a6be12357af6e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:26:07 +0800 Subject: [PATCH 0660/3904] try --- src/rpcmisc.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 91faf6221..6413f4ee0 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,16 @@ extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; +int32_t getera(int now) +{ + for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { + if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + era = i; + break; + } + } +} + UniValue getiguanajson(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -74,13 +84,8 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue notaries(UniValue::VARR); // get the current era, use local time for now. // should ideally take blocktime of last known block. - int now = time(NULL); int32_t era; - for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { - if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { - era = i; - break; - } - } + int now = time(NULL); + int32_t era = getera(now); // loop over seeds array and push back to json array for seeds for (int8_t i = 0; i < 8; i++) { @@ -111,13 +116,10 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 2) - throw runtime_error("getnotarysendmany "); + if (fHelp || params.size() != 1) + throw runtime_error("getnotarysendmany "); // era - int era = AmountFromValue(params[1]); - printf("%i\n",era ); - if ( era < 0 || era > NUM_STAKED_ERAS ) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); + int32_t era = getera(time(NULL)); // Amount CAmount nAmount = AmountFromValue(params[0]); if (nAmount <= 0) From 8c8c1a5aeae33303146f630a49420acf45089409 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:27:18 +0800 Subject: [PATCH 0661/3904] fix --- src/rpcmisc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 6413f4ee0..bd05635f6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -68,8 +68,7 @@ int32_t getera(int now) { for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { - era = i; - break; + return(i); } } } From a89c137047fc4417c0331b74db6ce062d24067a8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:37:39 +0800 Subject: [PATCH 0662/3904] fix? --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index bd05635f6..063a71bed 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -126,7 +126,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 12:10:09 +0800 Subject: [PATCH 0663/3904] fix --- src/rpcmisc.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 063a71bed..5f1db9636 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,21 +115,32 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) - throw runtime_error("getnotarysendmany "); - // era - int32_t era = getera(time(NULL)); + if (fHelp || params.size() > 2) + throw runtime_error( + "getnotarysendmany ( era amount_to_send )\n" + "\nReturn a sendmany array for all notary address in defined era.\n" + ); + int era = 0; + if (params.size() > 0) { + era = params[0].get_int(); + } + if (era < 0 || era > NUM_STAKED_ERAS) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); + } // Amount - CAmount nAmount = AmountFromValue(params[0]); + if (params.size() > 1) + CAmount nAmount = AmountFromValue(params[1]); + if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 12:22:21 +0800 Subject: [PATCH 0664/3904] fix --- src/rpcmisc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5f1db9636..864b23aac 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -120,6 +120,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) "getnotarysendmany ( era amount_to_send )\n" "\nReturn a sendmany array for all notary address in defined era.\n" ); + // era int era = 0; if (params.size() > 0) { era = params[0].get_int(); @@ -128,8 +129,9 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); } // Amount + CAmount nAmount; if (params.size() > 1) - CAmount nAmount = AmountFromValue(params[1]); + nAmount = AmountFromValue(params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); From deab4769eec95eda79e826e89d9b8a8f94d89f42 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 12:35:11 +0800 Subject: [PATCH 0665/3904] try --- src/rpcmisc.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 864b23aac..bd1c4ade8 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,23 +115,15 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() > 2) + if (fHelp || params.size() != 1) throw runtime_error( - "getnotarysendmany ( era amount_to_send )\n" - "\nReturn a sendmany array for all notary address in defined era.\n" + "getnotarysendmany ( amount_to_send )\n" + "\nReturn a sendmany array for all notary address in current era.\n" ); // era - int era = 0; - if (params.size() > 0) { - era = params[0].get_int(); - } - if (era < 0 || era > NUM_STAKED_ERAS) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); - } + int era = getera(time(NULL)); // Amount - CAmount nAmount; - if (params.size() > 1) - nAmount = AmountFromValue(params[1]); + CAmount nAmount = AmountFromValue(params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); From 537d2f88216d3951b6f000750a9c45f71033d569 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 12:39:53 +0800 Subject: [PATCH 0666/3904] fix --- src/rpcmisc.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index bd1c4ade8..3583fe590 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,15 +115,23 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() > 3) throw runtime_error( - "getnotarysendmany ( amount_to_send )\n" - "\nReturn a sendmany array for all notary address in current era.\n" + "getnotarysendmany ( all era amount_to_send )\n" + "\nReturn a sendmany array for all notary address in defined era.\n" ); - // era - int era = getera(time(NULL)); + // era: + int era = 0; + if (params.size() > 0) { + era = params[1].get_int(); + } + if (era < 0 || era > NUM_STAKED_ERAS) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); + } // Amount - CAmount nAmount = AmountFromValue(params[1]); + CAmount nAmount; + if (params.size() > 1) + nAmount = AmountFromValue(params[2]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); From a959c865b824ecf46fbdd8364eb87444b499c5c4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 12:43:25 +0800 Subject: [PATCH 0667/3904] wtf?!?! --- src/rpcmisc.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 3583fe590..499eafea0 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,26 +115,12 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() > 3) - throw runtime_error( - "getnotarysendmany ( all era amount_to_send )\n" - "\nReturn a sendmany array for all notary address in defined era.\n" - ); - // era: - int era = 0; - if (params.size() > 0) { - era = params[1].get_int(); - } - if (era < 0 || era > NUM_STAKED_ERAS) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); - } - // Amount - CAmount nAmount; - if (params.size() > 1) - nAmount = AmountFromValue(params[2]); - if (nAmount <= 0) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); + // era: + int era = getera(time(NULL)); + // Amount + CAmount nAmount = AmountFromValue(10); + UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 13:02:21 +0800 Subject: [PATCH 0668/3904] fix --- src/crosschain_authority.cpp | 2 +- src/rpcmisc.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 262a70c40..f7f51c8df 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -45,7 +45,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) printf("seennotary.%i\n",i); goto found; } else { - printf("notary.%i is not valid!\n",i); + //printf("notary.%i is not valid!\n",i); } } } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 499eafea0..98bcf70d1 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,11 +115,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - - // era: int era = getera(time(NULL)); - // Amount - CAmount nAmount = AmountFromValue(10); UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 13:14:04 +0800 Subject: [PATCH 0669/3904] fix --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 98bcf70d1..9be0af7c0 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -123,7 +123,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)notaries_STAKED[era][i][1]); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - ret.push_back(Pair(Raddress,(int)10); + ret.push_back(Pair(Raddress,(int)10)); } return ret; } From a8e89788c5869d0c61ec26a1dac31983a9294c71 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 15:17:02 +0800 Subject: [PATCH 0670/3904] change protocol version and ERA --- src/notaries_staked.h | 2 +- src/version.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 0c2a7eb22..9d0a3aae0 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1604111111, 1604222222, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1604222222, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = diff --git a/src/version.h b/src/version.h index aaa172403..633f2ec18 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170005; +static const int PROTOCOL_VERSION = 170006; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -19,7 +19,7 @@ static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version static const int MIN_PEER_PROTO_VERSION = 170002; -static const int STAKEDMIN_PEER_PROTO_VERSION = 170005; +static const int STAKEDMIN_PEER_PROTO_VERSION = 170006; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 4ef4377c8b3e8085381b7629ecd92592d88c7736 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 15:25:55 +0800 Subject: [PATCH 0671/3904] change CrisF pubkey --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9d0a3aae0..82b226ee6 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -51,7 +51,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, //RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu + {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, // RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev From aeaab7fb86d53cafec8640ca74fb6f329e873ba4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 22:39:57 +0800 Subject: [PATCH 0672/3904] fix dwy_merge for only 10ksat size p2pk --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d6a06525d..a05eede52 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4473,7 +4473,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (nValue > maximum_utxo_size) { continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() == 35) { + if (out.tx->vout[out.i].scriptPubKey.size() == 35 && nValue == 10000) { continue; } } From cbc4bd2bacef68ffc19f1ae68633819707f454e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 24 Nov 2018 12:32:52 +0800 Subject: [PATCH 0673/3904] add smk again, wrong key somehow --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 82b226ee6..8b1a1e945 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -52,7 +52,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, // RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu - {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 + {"smk762", "029f6c1f38c4d6825acb3b4b5147f7992e943b617cdaa0f4f5f36187e239d52d5a" }, // RPy6Xj2LWrxNoEW9YyREDgBZDZZ5qURXBU {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 From e341d1c1efc486d3350339409f4fad747563d741 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 24 Nov 2018 15:59:47 +0800 Subject: [PATCH 0674/3904] add kmdcrazy corret key --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 8b1a1e945..b407e6412 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -62,7 +62,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"kmdkrazy", "02da444a2627d420f1f622fcdfb9bddb67d6d4241ad6b4d5054716ddbde8a25dfb" }, // RJPJBbHcm5mkAxhkkERHRfEE9Cvkr4Euoi {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q From bde984aee2fdfc09820a2cb0ebfb8dc6e2796f87 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 25 Nov 2018 00:16:00 +0800 Subject: [PATCH 0675/3904] jl77s peferct fix --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index cd415040a..c24ca2bde 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2017,6 +2017,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) bool IsInitialBlockDownload() { + return false; const CChainParams& chainParams = Params(); LOCK(cs_main); if (fImporting || fReindex) From 1c4dda372adf492da2988b846d5f91f2c7153162 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 25 Nov 2018 00:23:17 +0800 Subject: [PATCH 0676/3904] no boueno --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c24ca2bde..cd415040a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2017,7 +2017,6 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) bool IsInitialBlockDownload() { - return false; const CChainParams& chainParams = Params(); LOCK(cs_main); if (fImporting || fReindex) From 677170d4e5436ce9bae992d74ea58a25a9787e61 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 25 Nov 2018 12:20:31 +0100 Subject: [PATCH 0677/3904] add gitlab CI conf --- .gitlab-ci.yml | 164 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..1bbf7a699 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,164 @@ +stages: +- build +- test +######################################################################################################################## +####START#### PROJECT LEVEL VARIABLES ####START#### +######################################################################################################################## +variables: + PACKAGE_DIR_LINUX: linux64 + PACKAGE_DIR_WINDOWS: win64 + PACKAGE_DIR_MACOS: macos + AGAMA_ARTIFACTS_LINUX: ${PACKAGE_DIR_LINUX}.tar.gz + AGAMA_ARTIFACTS_WINDOWS: ${PACKAGE_DIR_WINDOWS}.zip + AGAMA_ARTIFACTS_MACOS: ${PACKAGE_DIR_MACOS}.tar.gz + AGAMA_ARTIFACTS_LINUX_CHECKSUM: ${AGAMA_ARTIFACTS_LINUX}.md5 + AGAMA_ARTIFACTS_WINDOWS_CHECKSUM: ${AGAMA_ARTIFACTS_WINDOWS}.md5 + AGAMA_ARTIFACTS_MACOS_CHECKSUM: ${AGAMA_ARTIFACTS_MACOS}.md5 + ARTIFACT_EXPIRATION: 1 week + +######################################################################################################################## +####END#### PROJECT LEVEL VARIABLES ####END#### +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +####START#### Build Stage: compile and package komodo binaries for the Agama Wallet. ####START##### +######################################################################################################################## +######################################################################################################################## +####START#### LINUX ####START#### +######################################################################################################################## +build:ubuntu: + stage: build + image: ca333/komodo-builders:komodo-ubuntu + variables: + DOCKER_DRIVER: overlay2 + cache: + key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" + paths: + - depends/built + script: + - zcutil/build.sh -j$(nproc) + - mkdir ${PACKAGE_DIR_LINUX} + - cp src/komodod + src/komodo-cli + ${PACKAGE_DIR_LINUX} + - chmod +x ${PACKAGE_DIR_LINUX}/komodod + - chmod +x ${PACKAGE_DIR_LINUX}/komodo-cli + - tar -czvf ${AGAMA_ARTIFACTS_LINUX} ${PACKAGE_DIR_LINUX} + - md5sum ${AGAMA_ARTIFACTS_LINUX} > ${AGAMA_ARTIFACTS_LINUX_CHECKSUM} + artifacts: + paths: + - ${AGAMA_ARTIFACTS_LINUX} + - ${AGAMA_ARTIFACTS_LINUX_CHECKSUM} + expire_in: 1 week + +######################################################################################################################## +####END#### LINUX ####END#### +######################################################################################################################## +####START#### WINDOWS ####START#### +######################################################################################################################## +build:windows: + stage: build + image: ca333/komodo-builders:komodo-windows + variables: + DOCKER_DRIVER: overlay2 + cache: + key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" + paths: + - depends/built + script: + - zcutil/build-win.sh -j$(nproc) + - mkdir ${PACKAGE_DIR_WINDOWS} + - cp src/komodod.exe + src/komodo-cli.exe + src/komodo-tx.exe + ${PACKAGE_DIR_WINDOWS} + - zip -r ${PACKAGE_DIR_WINDOWS} + - md5sum ${AGAMA_ARTIFACTS_WINDOWS} > ${AGAMA_ARTIFACTS_WINDOWS_CHECKSUM} + artifacts: + paths: + - ${AGAMA_ARTIFACTS_WINDOWS} + - ${AGAMA_ARTIFACTS_WINDOWS_CHECKSUM} + expire_in: 1 week +######################################################################################################################## +####END#### WINDOWS ####END#### +######################################################################################################################## +####START#### MACOS ####START#### +######################################################################################################################## +build:macos: + stage: build + tags: ["High Sierra"] + cache: + key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" + paths: + - depends/built + script: + - zcutil/build-mac.sh -j$(sysctl -n hw.physicalcpu) + - ./makeRelease.sh ${PACKAGE_DIR_MACOS} + - tar -czvf ${AGAMA_ARTIFACTS_MACOS} ${PACKAGE_DIR_MACOS} + - md5sum ${AGAMA_ARTIFACTS_MACOS} > ${AGAMA_ARTIFACTS_MACOS_CHECKSUM} + artifacts: + paths: + - ${AGAMA_ARTIFACTS_MACOS} + - ${AGAMA_ARTIFACTS_MACOS_CHECKSUM} + expire_in: 1 week +######################################################################################################################## +####END#### MACOS ####END#### +######################################################################################################################## +######################################################################################################################## +####END#### Build Stage ####END#### +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +####START#### Test stage: Produce code quality and static application security test reports. ####START#### +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +####START#### Code Quality ####START#### +######################################################################################################################## +code_quality: + image: docker:stable + variables: + DOCKER_DRIVER: overlay2 + allow_failure: true + services: + - docker:stable-dind + script: + - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') + - docker run + --env SOURCE_CODE="$PWD" + --volume "$PWD":/code + --volume /var/run/docker.sock:/var/run/docker.sock + "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code + artifacts: + paths: [gl-code-quality-report.json] +######################################################################################################################## +####END#### Code Quality ####END#### +######################################################################################################################## +######################################################################################################################## +####START#### Static Application Security Tests ####START#### +######################################################################################################################## +sast: + image: docker:stable + variables: + DOCKER_DRIVER: overlay2 + allow_failure: true + services: + - docker:stable-dind + script: + - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') + - docker run + --env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}" + --volume "$PWD:/code" + --volume /var/run/docker.sock:/var/run/docker.sock + "registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code + artifacts: + paths: [gl-sast-report.json] +######################################################################################################################## +####END#### Static Application Security Tests ####END#### +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +####END#### Test stage ####END#### +######################################################################################################################## +######################################################################################################################## From f1fed89795a809ac84a84c2b42a45daa03394463 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 25 Nov 2018 13:31:53 +0100 Subject: [PATCH 0678/3904] fix CI zip archiver --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1bbf7a699..3ace05cb9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,7 +72,7 @@ build:windows: src/komodo-cli.exe src/komodo-tx.exe ${PACKAGE_DIR_WINDOWS} - - zip -r ${PACKAGE_DIR_WINDOWS} + - zip -r ${PACKAGE_DIR_WINDOWS}.zip ${PACKAGE_DIR_WINDOWS} - md5sum ${AGAMA_ARTIFACTS_WINDOWS} > ${AGAMA_ARTIFACTS_WINDOWS_CHECKSUM} artifacts: paths: From 7b7271aa452943abe27fc21c2e1f99affa5c0e2d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 15:26:00 +0800 Subject: [PATCH 0679/3904] remove isinitialblockdl from tmpmempool and revert false as default --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cd415040a..36624e624 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4313,7 +4313,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C const uint256 &hash = tx.GetHash(); if ( tx.vjoinsplit.size() == 0 ) { transactionsToRemove.push_back(tx); - tmpmempool.addUnchecked(hash,e,!IsInitialBlockDownload()); + tmpmempool.addUnchecked(hash,e,false); } } BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) { From f4ff5f49b53d0ce3b1d9eeb47a9deed2c5105fc1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 15:31:54 +0800 Subject: [PATCH 0680/3904] fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 36624e624..33bd98928 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4313,7 +4313,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C const uint256 &hash = tx.GetHash(); if ( tx.vjoinsplit.size() == 0 ) { transactionsToRemove.push_back(tx); - tmpmempool.addUnchecked(hash,e,false); + tmpmempool.addUnchecked(hash,e,true); } } BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) { From 7399a87134480f12a04ff7ba33017ce5e9a53dac Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 16:15:27 +0800 Subject: [PATCH 0681/3904] fix --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 33bd98928..2b6966659 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4374,6 +4374,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // here we add back all txs from the temp mempool to the main mempool. // which removes any tx locally that were invalid after the block arrives. int invalidtxs = 0; + LOCK(mempool.cs); BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { CTransaction tx = e.GetTx(); CValidationState state; bool fMissingInputs,fOverrideFees = false; From 7a25c614cf50353776e295be8a1583c0401f2734 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 20:52:50 +0800 Subject: [PATCH 0682/3904] speed up miner modifications? --- src/miner.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index aad8d0c44..fc0280868 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -105,6 +105,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #include "komodo_defs.h" +#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; @@ -214,7 +215,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { - int numNotaryVins = 0; + // TODO: It will be much faster here to just compare scriptpubkey! + CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; + if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { + if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) + fToCryptoAddress = true; + } BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -253,7 +259,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) int nConf = nHeight - coins->nHeight; - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) { uint256 hash; CTransaction tx1; CTxDestination address; if (GetTransaction(txin.prevout.hash,tx1,hash,false)) From f5746c6416a52e74f65ecfe93b61d8747774d50a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 20:55:46 +0800 Subject: [PATCH 0683/3904] debug print --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index fc0280868..0b38afa88 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -290,8 +290,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if (fNotarisation) + if (fNotarisation) { dPriority = 1e16; + fprintf(stderr, "Notarisation.%s set to maximum priority.\n",tx.hash.ToString().c_str()); + } if (porphan) { From c3e81dab26d099f080cea0286c288f8a437481c3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 20:58:12 +0800 Subject: [PATCH 0684/3904] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0b38afa88..012e89c95 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -292,7 +292,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) if (fNotarisation) { dPriority = 1e16; - fprintf(stderr, "Notarisation.%s set to maximum priority.\n",tx.hash.ToString().c_str()); + fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); } if (porphan) From d1fa5c68b426ce4cee0fb2c353e71e6ca98cd4ad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 21:36:41 +0800 Subject: [PATCH 0685/3904] more debug --- src/miner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 012e89c95..3bbf928f4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -218,6 +218,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // TODO: It will be much faster here to just compare scriptpubkey! CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { + fprintf(stderr, "%s %s\n",CRYPTO777_KMDADDR, CBitcoinAddress(ToAddress).ToString().c_str()); if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) fToCryptoAddress = true; } @@ -262,6 +263,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) { uint256 hash; CTransaction tx1; CTxDestination address; + fprintf(stderr, "Checking vins for notarisation.\n"); if (GetTransaction(txin.prevout.hash,tx1,hash,false)) { if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { From ea8cf3fc1cb7d80ec5807b442a8d9fe27353df5b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 21:46:41 +0800 Subject: [PATCH 0686/3904] try again --- src/miner.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3bbf928f4..ef826d05d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -218,7 +218,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // TODO: It will be much faster here to just compare scriptpubkey! CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { - fprintf(stderr, "%s %s\n",CRYPTO777_KMDADDR, CBitcoinAddress(ToAddress).ToString().c_str()); if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) fToCryptoAddress = true; } @@ -263,7 +262,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) { uint256 hash; CTransaction tx1; CTxDestination address; - fprintf(stderr, "Checking vins for notarisation.\n"); if (GetTransaction(txin.prevout.hash,tx1,hash,false)) { if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { @@ -276,6 +274,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } dPriority += (double)nValueIn * nConf; } + fprintf(stderr, "minsigs.%i vs numsigs.%i\n",(NUM_NOTARIES/5),numNotaryVins); if ( numNotaryVins > NUM_NOTARIES / 5 ) fNotarisation = true; nTotalIn += tx.GetJoinSplitValueIn(); From 9a72f91980227622cf7c508391d73ac25d469e56 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 21:50:30 +0800 Subject: [PATCH 0687/3904] fix! --- src/miner.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ef826d05d..7d15c3003 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -274,8 +274,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } dPriority += (double)nValueIn * nConf; } - fprintf(stderr, "minsigs.%i vs numsigs.%i\n",(NUM_NOTARIES/5),numNotaryVins); - if ( numNotaryVins > NUM_NOTARIES / 5 ) + if ( numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; nTotalIn += tx.GetJoinSplitValueIn(); } From 0b6970c798ac63e02dbf380f1f2f201cb4caec02 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 09:35:50 +0800 Subject: [PATCH 0688/3904] change min sigs to +1 --- src/komodo.h | 4 ++++ src/miner.cpp | 2 +- src/rpcmisc.cpp | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e58fe9be6..d5f5817a1 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -708,6 +708,10 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); + //if ( is_STAKED != 0 ) + //{ + // HERE we should add the notarisation to libscotts DB. + //} if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 7d15c3003..7370beb64 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -215,7 +215,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { - // TODO: It will be much faster here to just compare scriptpubkey! + // TODO: It will be much faster here to just compare scriptpubkey to the crypto pubkey! CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 9be0af7c0..4f436f41a 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -82,7 +82,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue seeds(UniValue::VARR); UniValue notaries(UniValue::VARR); // get the current era, use local time for now. - // should ideally take blocktime of last known block. + // should ideally take blocktime of last known block? int now = time(NULL); int32_t era = getera(now); @@ -98,10 +98,10 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) notaries.push_back(notary); } - // get the min sigs + // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. int minsigs; if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) - minsigs = (num_notaries_STAKED[era] + 4) / 5; + minsigs = (num_notaries_STAKED[era] / 5) + 1; else minsigs = overrideMinSigs; From 7cb41a160528c0c6908b0989319da966eb42f4fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 11:03:56 +0800 Subject: [PATCH 0689/3904] fix kmdice twice --- src/assetchains.json | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 43242ea42..09f7cdb96 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -177,18 +177,6 @@ "190.114.254.104" ] }, - { - "ac_name": "KMDICE", - "ac_supply": "10500000", - "ac_reward": "2500000000", - "ac_halving": "210000", - "ac_cc": "2", - "addressindex": "1", - "spentindex": "1", - "addnode": [ - "144.76.217.232" - ] - }, { "ac_name": "DION", "ac_supply": "3900000000", From d54d5424585c2b91ebf166f9a302eb89d37a7f73 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 22:33:01 +0800 Subject: [PATCH 0690/3904] remove streamer --- src/komodo_bitcoind.h | 52 ++++------ src/komodo_gateway.h | 2 +- src/komodo_globals.h | 2 +- src/komodo_utils.h | 14 +-- src/main.cpp | 22 +--- src/miner.cpp | 40 +------- src/pow.cpp | 4 - src/rpcblockchain.cpp | 212 --------------------------------------- src/rpcserver.cpp | 1 - src/rpcserver.h | 1 - src/wallet/rpcwallet.cpp | 1 - 11 files changed, 27 insertions(+), 324 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d0d6a7632..c00d33216 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1105,7 +1105,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ commission must be in coinbase.vout[1] and must be >= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ -extern int32_t ASSETCHAINS_STREAM; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); @@ -1113,29 +1112,26 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); - if ( ASSETCHAINS_STREAM == 0 ) + if ( ASSETCHAINS_FOUNDERS != 0 ) { - if ( ASSETCHAINS_FOUNDERS != 0 ) + nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); + //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); + n = pblock->vtx[0].vout.size(); + for (j=0; jvtx[0].vout[j].nValue; + } + else + { + for (i=0; ivtx[0].vout.size(); + n = pblock->vtx[i].vout.size(); for (j=0; jvtx[0].vout[j].nValue; - } - else - { - for (i=0; ivtx[i].vout.size(); - for (j=0; jvtx[i].vout[j].nValue; - } + //fprintf(stderr,"(%d %.8f).%d ",i,dstr(block.vtx[i].vout[j].nValue),j); + if ( i != 0 || j != 1 ) + total += pblock->vtx[i].vout[j].nValue; } } } @@ -1483,7 +1479,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; - if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0 ) + if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock,height); //fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); @@ -1632,20 +1628,6 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( komodo_checkcommission(pblock,height) < 0 ) return(-1); } - if ( ASSETCHAINS_STREAM != 0 && height > 128 ) - { - int lasttx = ( pblock->vtx.size() -1 ); - if ( lasttx == 0 ) - return(-1); - uint256 hash; CTransaction tx; - if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) - { - script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { - return(-1); - } - } - } } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ed05897d..3845030ca 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -744,7 +744,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim else { checktoshis = 0; - if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && height > 1 ) + if ( ASSETCHAINS_COMMISSION != 0 && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0953713b0..dda78a6e1 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES,ASSETCHAINS_FOUNDERS; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 80581a1f8..1a6757b49 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1573,12 +1573,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { - printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); - exit(0); - } if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) @@ -1601,11 +1596,6 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } - if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 && ASSETCHAINS_STREAM != 0 ) - { - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); - exit(0); - } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) @@ -1620,10 +1610,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else if ( ASSETCHAINS_STREAM == 0 ) + else { ASSETCHAINS_OVERRIDE_PUBKEY.clear(); - printf("-ac_perc or -ac_stream must be set with -ac_pubkey\n"); + printf("-ac_perc must be set with -ac_pubkey\n"); } } } diff --git a/src/main.cpp b/src/main.cpp index 2b6966659..26b5e8f5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1918,7 +1918,6 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint32_t ASSETCHAINS_MAGIC; -extern int32_t ASSETCHAINS_STREAM; extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; @@ -1947,12 +1946,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) else if ( ASSETCHAINS_ENDSUBSIDY == 0 || nHeight < ASSETCHAINS_ENDSUBSIDY ) { if ( ASSETCHAINS_REWARD == 0 ) - { - if ( ASSETCHAINS_STREAM != 0 && nHeight > 128 ) - return(0); - else - return(10000); - } + return(10000); else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY ) return(0); else @@ -3020,18 +3014,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met"); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( ASSETCHAINS_STREAM != 0 ) - { - if ( block.vtx.size() == 1 && block.vtx[0].vout.size() == 2 && pindex->nHeight > ASSETCHAINS_MINHEIGHT) - { - return state.DoS(100, error("ConnectBlock(): There are no TX in this block, it is invalid!"), - REJECT_INVALID, "bad-block-no-transactions"); - } - } - } - if (fAddressIndex || fSpentIndex) { for (size_t j = 0; j < tx.vin.size(); j++) { @@ -3181,7 +3163,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; - if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && + if ( ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && { uint64_t checktoshis; if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->nHeight)) != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 7370beb64..709ba6a65 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -107,7 +107,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" #define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],NOTARYADDRS[64][36]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; @@ -467,7 +467,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); @@ -544,26 +544,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } - else if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SYMBOL[0] != 0 && nHeight > 128 ) - { - CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); - if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) - { - CAmount txfees = 10000; - pblock->vtx.push_back(txStream); - pblocktemplate->vTxFees.push_back(txfees); - pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStream)); - nFees += txfees; - pblocktemplate->vTxFees[0] = -nFees; - //*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; - //fprintf(stderr,"added notaryvin\n"); - } - else - { - fprintf(stderr,"error adding streamer vin, the chain broke! \n"); - return(0); - } - } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; @@ -690,13 +670,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); } } - else if ( ASSETCHAINS_STREAM != 0 ) - { - if ( nHeight < 128 ) - scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; - else - scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; - } else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); @@ -926,19 +899,14 @@ void static BitcoinMiner() { if ( ASSETCHAINS_REWARD == 0 ) { - int minvoutsize = 1; - int minvtxsize = 1; - if ( ASSETCHAINS_STREAM != 0 ) - minvoutsize = 2; - minvtxsize = 2; - if ( pblock->vtx.size() == minvtxsize && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) + if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) { static uint32_t counter; if ( counter++ < 10 ) fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; - } else fprintf(stderr,"%s tx.%d vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx.size(),(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); diff --git a/src/pow.cpp b/src/pow.cpp index 07776e273..1291e445e 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -20,13 +20,9 @@ #include "librustzcash.h" #endif // ENABLE_RUST uint32_t komodo_chainactive_timestamp(); -extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if ( ASSETCHAINS_STREAM == 2 ) - return 537857807; - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block if (pindexLast == NULL ) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index abc8864bc..f078094ff 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -261,218 +261,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -unsigned char hexval(unsigned char c) -{ - if ('0' <= c && c <= '9') - return c - '0'; - else if ('a' <= c && c <= 'f') - return c - 'a' + 10; - else if ('A' <= c && c <= 'F') - return c - 'A' + 10; - else abort(); -} - -void hex2ascii(const string& in, string& out) -{ - out.clear(); - out.reserve(in.length() / 2); - for (string::const_iterator p = in.begin(); p != in.end(); p++) - { - unsigned char c = hexval(*p); - p++; - if (p == in.end()) break; // incomplete last digit - should report error - c = (c << 4) + hexval(*p); // + takes precedence over << - out.push_back(c); - } -} - -UniValue getdatafromblock(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 1 || params.size() > 2) - throw runtime_error( - "getdatafromblock \"hash|height\" true/false\n" - "\nReturns all the data sent via streamer in block if there was any data in it.\n" - "\nArguments:\n" - "1. \"hash|height\" (string, required) The block hash or height\n" - "2. \"true/false\" (bool, optional) if false do not return the actual data. Default true.\n" - "\nResult (for verbose = true):\n" - "{\n" - " \"streamid\" : \"string\", (string) the name of the stream.\n" - " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" - " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" - " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" - " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" - " \"data\" : \"xxxx\", (string) A hex string containing all the data chunks in this block.\n" - "}\n" - "\nResult (for verbose=false):\n" - " \"streamid\" : \"string\", (string) the name of the stream.\n" - " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" - " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" - " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" - " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" - + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 false\"") - + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") - + HelpExampleCli("getblock", "12800") - + HelpExampleRpc("getblock", "12800 false") - ); - - LOCK(cs_main); - - std::string strHash = params[0].get_str(); - bool fVerbose = true; - if (params.size() > 1) { - std::string verboseflag = params[1].get_str(); - if ( verboseflag == "false" ) - fVerbose = false; - } - - // If height is supplied, find the hash - if (strHash.size() < (2 * sizeof(uint256))) { - // std::stoi allows characters, whereas we want to be strict - regex r("[[:digit:]]+"); - if (!regex_match(strHash, r)) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); - } - - int nHeight = -1; - try { - nHeight = std::stoi(strHash); - } - catch (const std::exception &e) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); - } - - if (nHeight < 0 || nHeight > chainActive.Height()) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - } - strHash = chainActive[nHeight]->GetBlockHash().GetHex(); - } - - uint256 hash(uint256S(strHash)); - - if (mapBlockIndex.count(hash) == 0) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - - CBlock block; - CBlockIndex* pblockindex = mapBlockIndex[hash]; - - if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - - if(!ReadBlockFromDisk(block, pblockindex,1)) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - - UniValue result(UniValue::VOBJ); - int firstseqid = 0; - int lastseqid = 0; - int i = 0; - int did1 = 0; - int skippedtxs = 0; - int failed = 0; - int getfirstblock = 0; - static std::string streamid,firsttxid; - static int firsttxnHeight; - std::string blockdata; - fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); - // Iif block tx size is > 2 then we can do this - if ( block.vtx.size() > 2 ) - { - BOOST_FOREACH(const CTransaction&tx, block.vtx) - { - // ignore first and last TX and any TX that does not have 3 vouts. - if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) - { - fprintf(stderr, "skipped tx number: %d\n",i); - skippedtxs = skippedtxs + 1; - } else { - std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); - // scriptPubKey is longer than 81, should mean its an OP_RETURN, maybe also check vout == 0 ? - if ( opretstr.size() > 81 ) { - std::string idstr = opretstr.substr (8,64); // stream ID or txid - std::string seqidstr = opretstr.substr (72,8); // sequence ID - std::string data = opretstr.substr (80); // data chunk - unsigned int seqid; - std::stringstream ss; - ss << std::hex << seqidstr; - ss >> seqid; - if ( seqid == 1 ) { - streamid = idstr; - getfirstblock = 1; - } else if ( seqid == 2 ) { - firsttxid = idstr; - } else if (firsttxid.empty()) { - firsttxid.append(idstr); - } else if ( firsttxid != idstr ) { - printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); - firsttxid.clear(); - firsttxid.append(idstr); - streamid.clear(); - firsttxnHeight = 0; - } - if ( seqid == (lastseqid + 1) || did1 == 0 ) { - blockdata.append(data); - } else { - result.push_back(Pair("error","chunck out of order or missing in this block!")); - result.push_back(Pair("lastvalidseqid", (int)lastseqid)); - break; - } - if ( did1 == 0 ) { - firstseqid = seqid; - did1 = 1; - } - lastseqid = seqid; - } else { - skippedtxs = skippedtxs + 1; - fprintf(stderr, "skipped tx number: %d\n",i); - } - // function here to extract seqid from first and last TX - // we an push the data or not depending on input from RPC. - } - i = i + 1; - } - if (streamid.empty() || getfirstblock == 1) { - if ( lastseqid == 1) { - firsttxid = block.vtx[1].GetHash().GetHex(); - } - uint256 hash; CTransaction firsttx; - uint256 firsttxid_256(uint256S(firsttxid)); - if (GetTransaction(firsttxid_256,firsttx,hash,false)) { - if ( streamid.empty() ) { - std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - streamid.append(firststreamid.substr (8,64)); - } - printf("first stream id changed to: %s\n", streamid.c_str()); - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - printf("found block height: %d\n",pindex->nHeight); - if (chainActive.Contains(pindex)) { - firsttxnHeight = pindex->nHeight; - } - } - } - } - } else { - failed = 1; - } - - if ( failed == 1 || skippedtxs == i ) { - result.push_back(Pair("error","there is no data in this block.")); - } else { - std::string decodedstreamid; - hex2ascii(streamid, decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid.c_str())); - result.push_back(Pair("firsttxid", firsttxid)); - result.push_back(Pair("firstblockheight", (int)firsttxnHeight)); - result.push_back(Pair("firstseqid", (int)firstseqid)); - result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose == true) { - result.push_back(Pair("data", blockdata)); - } - } - return result; -} - UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) { UniValue result(UniValue::VOBJ); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index d4143fcfb..98417e201 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -287,7 +287,6 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "getbestblockhash", &getbestblockhash, true }, { "blockchain", "getblockcount", &getblockcount, true }, { "blockchain", "getblock", &getblock, true }, - { "blockchain", "getdatafromblock", &getdatafromblock, true }, { "blockchain", "getblockdeltas", &getblockdeltas, false }, { "blockchain", "getblockhashes", &getblockhashes, true }, { "blockchain", "getblockhash", &getblockhash, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 9ab033d12..851c39d42 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -368,7 +368,6 @@ extern UniValue getblockdeltas(const UniValue& params, bool fHelp); extern UniValue getblockhash(const UniValue& params, bool fHelp); extern UniValue getblockheader(const UniValue& params, bool fHelp); extern UniValue getblock(const UniValue& params, bool fHelp); -extern UniValue getdatafromblock(const UniValue& params, bool fHelp); extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp); extern UniValue gettxout(const UniValue& params, bool fHelp); extern UniValue verifychain(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a05eede52..5e24f1530 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -46,7 +46,6 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; -extern int32_t ASSETCHAINS_STREAM; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern uint8_t ASSETCHAINS_PRIVATE; extern int32_t USE_EXTERNAL_PUBKEY; From 5dead9f36b8ea0cd8b79d5a31d929feab225caaa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 22:37:23 +0800 Subject: [PATCH 0691/3904] fix --- src/komodo_bitcoind.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c00d33216..124c8f2b2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1135,10 +1135,6 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } } } - else - { - commission = 10000; - } return(commission); } From aba30935272dc1215f52ba14808cbcd42ac98721 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:36:51 +0800 Subject: [PATCH 0692/3904] try fix --- src/crosschain.cpp | 2 +- src/crosschain_authority.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index ff143da2c..fbd6b8f1a 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -284,7 +284,7 @@ bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom) return nota.second.MoMoM == momom; }; - return (bool) ScanNotarisationsFromHeight(block.nHeight-100, checkMoMoM, nota); + return (bool) ScanNotarisationsFromHeight(block.GetHeight()-100, checkMoMoM, nota); } diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index f7f51c8df..7aeb27f01 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = spk.data(); + const unsigned char *pk = spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From 598ccdb0900514850bc71a3f7b79beaac30b2f72 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:39:57 +0800 Subject: [PATCH 0693/3904] fix --- src/crosschain_authority.cpp | 2 +- src/komodo_globals.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7aeb27f01..3fbc39b42 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = spk[0]; + const unsigned char *pk = (char *)spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a09d81e4e..c0de313ab 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; bool VERUS_MINTBLOCKS; From d2b899687e374bd25ce2ca9df8fed4016ef734a1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:41:15 +0800 Subject: [PATCH 0694/3904] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 3fbc39b42..af462731f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = (char *)spk[0]; + const unsigned char *pk = (char *)&spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From ab2a8e53ca0ddf0c0f4ff427e32b4b60e2e6e47f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:43:59 +0800 Subject: [PATCH 0695/3904] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index af462731f..928f6ed64 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = (char *)&spk[0]; + char *pk = *spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From 88da77886c0c231af8d36965a6902db43553395b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:45:42 +0800 Subject: [PATCH 0696/3904] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 928f6ed64..551c322fe 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - char *pk = *spk[0]; + unsigned char *pk = *spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From be1b9071a1c1eae51058dddebc051a8a75afc78e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:46:34 +0800 Subject: [PATCH 0697/3904] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 551c322fe..b4379c010 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - unsigned char *pk = *spk[0]; + const unsigned char *pk = &spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From c8e652c452504de65333246368caebe5d190ab3e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:50:38 +0800 Subject: [PATCH 0698/3904] fix --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 35b9b0120..edc0ba40c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -277,7 +277,7 @@ libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: zcashd libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -DSERVER -libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSEVER +libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSERVER libbitcoin_server_a_SOURCES = \ sendalert.cpp \ addrman.cpp \ From 43a6b39140840314678ac07720f6a1c400d3f890 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:55:14 +0800 Subject: [PATCH 0699/3904] try --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 31cfd9a3d..e49ffadcc 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -75,7 +75,7 @@ public: #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" -#include "notaries_staked.cpp" +//#include "notaries_staked.cpp" From 104f60f0949fbe5132330910bc013f6890b68139 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:56:28 +0800 Subject: [PATCH 0700/3904] uh --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e49ffadcc..31cfd9a3d 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -75,7 +75,7 @@ public: #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" -//#include "notaries_staked.cpp" +#include "notaries_staked.cpp" From 95fbd857070b9a3688d28915f35b0362df6e98b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:59:48 +0800 Subject: [PATCH 0701/3904] try --- src/bitcoin-cli.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 31cfd9a3d..488516abb 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -74,8 +74,8 @@ public: #include "komodo_globals.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "komodo_notary.h" -#include "notaries_staked.cpp" +//#include "komodo_notary.h" +//#include "notaries_staked.cpp" From 3a55d61fb6f1b7dbdbd34e37ebbbc54b3b794b1f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:01:24 +0800 Subject: [PATCH 0702/3904] try --- src/bitcoin-cli.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 488516abb..e6e7819f5 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -72,8 +72,8 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -#include "komodo_utils.h" -#include "komodo_cJSON.c" +//#include "komodo_utils.h" +//#include "komodo_cJSON.c" //#include "komodo_notary.h" //#include "notaries_staked.cpp" From d56e1595668aca0ff17031b821208d7fafa8b5d6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:14:53 +0800 Subject: [PATCH 0703/3904] y --- src/bitcoin-cli.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e6e7819f5..c06b24693 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -72,10 +72,10 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -//#include "komodo_utils.h" -//#include "komodo_cJSON.c" -//#include "komodo_notary.h" -//#include "notaries_staked.cpp" +#include "komodo_utils.h" +#include "komodo_cJSON.c" +#include "komodo_notary.h" +#include "notaries_staked.h" From 6f16da8472e827faad938b312a1c65e7ec3af4bb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:15:59 +0800 Subject: [PATCH 0704/3904] y --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index c06b24693..4731fd9a2 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,6 +76,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.h" +#include "notaries_staked.cpp" From 5552614eeac670242511ce1447d7a6024abd7e22 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:25:25 +0800 Subject: [PATCH 0705/3904] try --- src/coins.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/coins.h b/src/coins.h index f35af02f0..62943eb83 100644 --- a/src/coins.h +++ b/src/coins.h @@ -26,7 +26,7 @@ #include "zcash/IncrementalMerkleTree.hpp" #include "veruslaunch.h" -/** +/** * Pruned version of CTransaction: only retains metadata and unspent transaction outputs * * Serialized format: @@ -428,10 +428,10 @@ public: class CCoinsViewCache; -/** +/** * A reference to a mutable cache entry. Encapsulating it allows us to run * cleanup code after the modification is finished, and keeping track of - * concurrent modifications. + * concurrent modifications. */ class CCoinsModifier { @@ -456,6 +456,7 @@ class CTransactionExceptionData CTransactionExceptionData() : scriptPubKey(), voutMask() {} }; +#ifdef SERVER class CLaunchMap { public: @@ -478,6 +479,7 @@ class CLaunchMap } }; static CLaunchMap launchMap = CLaunchMap(); +#endif /** CCoinsView that adds a memory cache for transactions to another CCoinsView */ class CCoinsViewCache : public CCoinsViewBacked @@ -488,7 +490,7 @@ protected: /** * Make mutable so that we can "fill the cache" even from Get-methods - * declared as "const". + * declared as "const". */ mutable uint256 hashBlock; mutable CCoinsMap cacheCoins; @@ -564,7 +566,7 @@ public: //! Calculate the size of the cache (in bytes) size_t DynamicMemoryUsage() const; - /** + /** * Amount of bitcoins coming in to a transaction * Note that lightweight clients may not know anything besides the hash of previous transactions, * so may not be able to calculate this. From caad5eaee1856469ae75fa019b2a2821b5b07da0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:32:20 +0800 Subject: [PATCH 0706/3904] fix --- src/coins.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coins.h b/src/coins.h index 62943eb83..4ef6ad29f 100644 --- a/src/coins.h +++ b/src/coins.h @@ -456,7 +456,6 @@ class CTransactionExceptionData CTransactionExceptionData() : scriptPubKey(), voutMask() {} }; -#ifdef SERVER class CLaunchMap { public: @@ -479,7 +478,6 @@ class CLaunchMap } }; static CLaunchMap launchMap = CLaunchMap(); -#endif /** CCoinsView that adds a memory cache for transactions to another CCoinsView */ class CCoinsViewCache : public CCoinsViewBacked From a4e70bd4644bbad5e31692408a3f8d83e383fbbe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:48:04 +0800 Subject: [PATCH 0707/3904] try reverse --- src/Makefile.am | 10 +++++----- src/notaries_staked.cpp | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index edc0ba40c..daced98c8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -276,8 +276,8 @@ obj/build.h: FORCE libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: zcashd -libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -DSERVER -libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSERVER +libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) +libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_server_a_SOURCES = \ sendalert.cpp \ addrman.cpp \ @@ -581,9 +581,9 @@ endif # bitcoin-cli binary # komodo_cli_SOURCES = bitcoin-cli.cpp -komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -DCLI +komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DCLI +komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -DCLI # wallet-utility binary # if ENABLE_WALLET diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d29d5dfb2..e69a43397 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -36,7 +36,11 @@ int32_t STAKED_era(int timestamp) return(0); }; -#ifdef SERVER +#ifdef CLI +int8_t updateStakedNotary() { + return(-1); +} +#else int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; @@ -46,10 +50,6 @@ int8_t updateStakedNotary() { NOTARY_ADDRESS.assign(Raddress); return(StakedNotaryID(notaryname,Raddress)); } -#else -int8_t updateStakedNotary() { - return(-1); -} #endif int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { @@ -150,24 +150,24 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { if ( pubkeys[0][0] == 0 ) { // null pubkeys, era 0. -#ifdef SERVER pthread_mutex_lock(&staked_mutex); memset(NOTARYADDRS,0,sizeof(NOTARYADDRS)); NUM_NOTARIES = 0; pthread_mutex_unlock(&staked_mutex); -#endif } else { // staked era is set. -#ifdef SERVER pthread_mutex_lock(&staked_mutex); for (int i = 0; i Date: Fri, 30 Nov 2018 00:55:05 +0800 Subject: [PATCH 0708/3904] wtrf --- src/bitcoin-cli.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 4731fd9a2..e123e536b 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -69,14 +69,14 @@ public: #include "uint256.h" #include "arith_uint256.h" -#include "komodo_structs.h" +//#include "komodo_structs.h" -#include "komodo_globals.h" -#include "komodo_utils.h" -#include "komodo_cJSON.c" -#include "komodo_notary.h" -#include "notaries_staked.h" -#include "notaries_staked.cpp" +//#include "komodo_globals.h" +//#include "komodo_utils.h" +//#include "komodo_cJSON.c" +//#include "komodo_notary.h" +//#include "notaries_staked.h" +//#include "notaries_staked.cpp" @@ -104,7 +104,7 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - komodo_args(argv[0]); + //komodo_args(argv[0]); if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { From 2afd221d79dbcc7308cc0b531a9e1429fb23e351 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 01:05:05 +0800 Subject: [PATCH 0709/3904] really --- src/bitcoin-cli.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e123e536b..d30d75d38 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -65,19 +65,19 @@ public: }; +#ifdef FROM_CLI #define FROM_CLI #include "uint256.h" #include "arith_uint256.h" -//#include "komodo_structs.h" - -//#include "komodo_globals.h" -//#include "komodo_utils.h" -//#include "komodo_cJSON.c" -//#include "komodo_notary.h" -//#include "notaries_staked.h" -//#include "notaries_staked.cpp" +#include "komodo_structs.h" +#include "komodo_globals.h" +#include "komodo_utils.h" +#include "komodo_cJSON.c" +#include "komodo_notary.h" +#include "notaries_staked.cpp" +#endif void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) @@ -104,7 +104,7 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - //komodo_args(argv[0]); + komodo_args(argv[0]); if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { From 7ca059a0fbdd453d80913c809c2ba5d2cbe59a75 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 01:31:00 +0800 Subject: [PATCH 0710/3904] last attempt --- src/bitcoin-cli.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index d30d75d38..e4357dbfa 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -17,6 +17,8 @@ #include #include #include "support/events.h" +uint16_t BITCOIND_RPCPORT = 7771; +char ASSETCHAINS_SYMBOL[65]; #include @@ -65,7 +67,7 @@ public: }; -#ifdef FROM_CLI +/* #define FROM_CLI #include "uint256.h" #include "arith_uint256.h" @@ -77,7 +79,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#endif void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) @@ -89,6 +90,7 @@ uint32_t komodo_heightstamp(int32_t height) { return(0); } +*/ // // This function returns either one of EXIT_ codes when it's expected to stop the process or @@ -104,7 +106,12 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - komodo_args(argv[0]); + //komodo_args(argv[0]); + std:string name; + name = GetArg("-ac_name",""); + if ( !name.empty() ) + strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); + if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { @@ -218,7 +225,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) { std::string host = GetArg("-rpcconnect", "127.0.0.1"); int port = GetArg("-rpcport", BaseParams().RPCPort()); - BITCOIND_RPCPORT = port; + //BITCOIND_RPCPORT = port; // Obtain event base raii_event_base base = obtain_event_base(); From a4313d45366b97838d9fbc7f6e0649e61a9601ad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 01:53:45 +0800 Subject: [PATCH 0711/3904] clean up --- src/Makefile.am | 6 +++--- src/bitcoin-cli.cpp | 28 +--------------------------- src/notaries_staked.cpp | 10 ---------- 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index daced98c8..1eada2c1d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -581,9 +581,9 @@ endif # bitcoin-cli binary # komodo_cli_SOURCES = bitcoin-cli.cpp -komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -DCLI -komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DCLI -komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -DCLI +komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) +komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) # wallet-utility binary # if ENABLE_WALLET diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e4357dbfa..f8f0fe002 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -67,31 +67,6 @@ public: }; -/* -#define FROM_CLI -#include "uint256.h" -#include "arith_uint256.h" - -#include "komodo_structs.h" - -#include "komodo_globals.h" -#include "komodo_utils.h" -#include "komodo_cJSON.c" -#include "komodo_notary.h" -#include "notaries_staked.cpp" - - -void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) -{ - -} - -uint32_t komodo_heightstamp(int32_t height) -{ - return(0); -} -*/ - // // This function returns either one of EXIT_ codes when it's expected to stop the process or // CONTINUE_EXECUTION when it's expected to continue further. @@ -106,7 +81,6 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - //komodo_args(argv[0]); std:string name; name = GetArg("-ac_name",""); if ( !name.empty() ) @@ -225,7 +199,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) { std::string host = GetArg("-rpcconnect", "127.0.0.1"); int port = GetArg("-rpcport", BaseParams().RPCPort()); - //BITCOIND_RPCPORT = port; + BITCOIND_RPCPORT = port; // Obtain event base raii_event_base base = obtain_event_base(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e69a43397..ba9a88343 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -36,11 +36,6 @@ int32_t STAKED_era(int timestamp) return(0); }; -#ifdef CLI -int8_t updateStakedNotary() { - return(-1); -} -#else int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; @@ -50,7 +45,6 @@ int8_t updateStakedNotary() { NOTARY_ADDRESS.assign(Raddress); return(StakedNotaryID(notaryname,Raddress)); } -#endif int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { if ( STAKED_ERA != 0 ) @@ -160,12 +154,8 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { // staked era is set. pthread_mutex_lock(&staked_mutex); for (int i = 0; i Date: Fri, 30 Nov 2018 19:19:58 +0800 Subject: [PATCH 0712/3904] try --- src/bitcoin-cli.cpp | 2 +- src/main.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f8f0fe002..f632c8827 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -80,7 +80,7 @@ static int AppInitRPC(int argc, char* argv[]) // // Parameters // - ParseParameters(argc, argv); + ParseParameters(argc, lolargv); std:string name; name = GetArg("-ac_name",""); if ( !name.empty() ) diff --git a/src/main.cpp b/src/main.cpp index 0404df255..06c564f7f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6556,7 +6556,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } -//fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); + fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); if (strCommand == "version") { @@ -6572,12 +6572,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; + fprintf(stderr, "version.%i\n",pfrom->nVersion); int nVersion; // use temporary for version, don't set version number until validated as connected vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe; if (nVersion == 10300) nVersion = 300; if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { + fprintf(stderr, "Is Staked!\n"); if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version @@ -6587,8 +6589,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - } else + } + else { + fprintf(stderr, "Is not staked!\n"); if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version From f74593d621328048ff2e0b7f614e669584997bad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 19:22:49 +0800 Subject: [PATCH 0713/3904] go --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f632c8827..f8f0fe002 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -80,7 +80,7 @@ static int AppInitRPC(int argc, char* argv[]) // // Parameters // - ParseParameters(argc, lolargv); + ParseParameters(argc, argv); std:string name; name = GetArg("-ac_name",""); if ( !name.empty() ) From fd988f01f14eb3c625b906d3484b600360655a85 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 19:30:09 +0800 Subject: [PATCH 0714/3904] try fix --- src/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 06c564f7f..53265e7e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6579,8 +6579,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, nVersion = 300; if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { - fprintf(stderr, "Is Staked!\n"); - if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) + if (nVersion < STAKEDMIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); @@ -6592,8 +6591,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } else { - fprintf(stderr, "Is not staked!\n"); - if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) + if (nVersion < MIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); From 7644808ff16e50f954914d95ca333a375dbf7732 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 21:21:08 +0800 Subject: [PATCH 0715/3904] try --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 53265e7e3..7a81501e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6556,7 +6556,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } - fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); + //fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); if (strCommand == "version") { @@ -6572,7 +6572,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; - fprintf(stderr, "version.%i\n",pfrom->nVersion); int nVersion; // use temporary for version, don't set version number until validated as connected vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe; if (nVersion == 10300) From a089187c442bc897ae1f672fc2d1de5cc0b6a72f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 1 Dec 2018 12:02:09 +0800 Subject: [PATCH 0716/3904] attempt wallet fix for empty vin issue --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 96ec88e6e..91d3e6d56 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,6 +1211,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) return false; + if ( tx.vin.empty() ) + return false; bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); From 0fc3fd3de9876e1280b97a4fc0dfe14176eafaba Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 1 Dec 2018 12:18:44 +0800 Subject: [PATCH 0717/3904] fix getblocktemplate --- src/rpc/mining.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index aed10944c..e4a1dcd4a 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -606,9 +606,13 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } + else + { + strMode = "template"; + } - if (strMode != "template") - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); + //if (strMode != "template") + // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); bool fvNodesEmpty; { From 905a829964f30925399dc0604668fbe3f23f3389 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 1 Dec 2018 14:08:51 +0800 Subject: [PATCH 0718/3904] p --- src/rpc/mining.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index e4a1dcd4a..25b75c301 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -611,9 +611,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) strMode = "template"; } - //if (strMode != "template") - // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); - bool fvNodesEmpty; { LOCK(cs_vNodes); From 52b1898322c16f2a008767264f7e7ff99e17dacd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 4 Dec 2018 11:19:44 +0800 Subject: [PATCH 0719/3904] p --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6d50bdef5..2e1b1cef4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -331,7 +331,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } dPriority += (double)nValueIn * nConf; } - if ( numNotaryVins >= NUM_NOTARIES / 5 ) + if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; nTotalIn += tx.GetShieldedValueIn(); } From 6595ab0201e6dc448cee218c323b13241f3fd1f3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:21:12 +0800 Subject: [PATCH 0720/3904] try fix wallet get corrupt, add prints --- src/main.cpp | 7 +++++-- src/miner.cpp | 6 ++++-- src/wallet/rpcwallet.cpp | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0f694c5b6..e76299a25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1757,7 +1757,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { if (pfMissingInputs) *pfMissingInputs = true; - //fprintf(stderr,"missing inputs\n"); + fprintf(stderr,"missing inputs in %s\n",tx.GetHash().ToString().c_str()); return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); } } @@ -3839,7 +3839,10 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { //if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))) if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { - EraseFromWallets(tx.GetHash()); + //EraseFromWallets(tx.GetHash()); +#ifdef ENABLE_WALLET + pwalletMain->EraseFromWallet(tx.GetHash()); +#endif } else { diff --git a/src/miner.cpp b/src/miner.cpp index 272ca98be..bb38e1c02 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1569,7 +1569,7 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; - if ( ASSETCHAINS_STAKED != 0 ) + if ( ASSETCHAINS_STAKED > 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); @@ -1858,8 +1858,10 @@ void static BitcoinMiner() } //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); - if ( nThreads == 0 && ASSETCHAINS_STAKED ) + if ( ASSETCHAINS_STAKED > 0 && pwallet != NULL && nThreads == 0 ) nThreads = 1; + else + return; if ((nThreads == 0 || !fGenerate) && (VERUS_MINTBLOCKS == 0 || pwallet == NULL)) return; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 06f87a79b..73293c669 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5365,7 +5365,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } //else fprintf(stderr,"utxo not eligible\n"); } - if ( numkp < 10000 && array != 0 ) + if ( numkp < 1000000 && array != 0 ) { free(array); array = 0; @@ -7283,7 +7283,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); asktxid = Parseuint256((char *)params[1].get_str().c_str()); - //fillunits = atol(params[2].get_str().c_str()); + //fillunits = atol(params[2].get_str().c_str()); fillunits = atoll(params[2].get_str().c_str()); // dimxy changed to prevent loss of significance if ( fillunits <= 0 ) { From 0545cb9ba6e72c6799c553dd27dd2e57716153de Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:28:29 +0800 Subject: [PATCH 0721/3904] prints --- src/main.cpp | 4 +++- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e76299a25..17cd42f2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1316,9 +1316,11 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio // Transactions containing empty `vin` must have either non-empty // `vjoinsplit` or non-empty `vShieldedSpend`. - if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) + if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); + printf("vim empty for tx: %s\n",tx.GetHash().ToString().c_str()); + } // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. if (tx.vout.empty() && tx.vjoinsplit.empty() && tx.vShieldedOutput.empty()) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 73293c669..c4204f8a0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5365,7 +5365,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } //else fprintf(stderr,"utxo not eligible\n"); } - if ( numkp < 1000000 && array != 0 ) + if ( numkp < 10000 && array != 0 ) { free(array); array = 0; From f27f8c2821c2f82d08236f2ef4e93457e1f7158b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:38:19 +0800 Subject: [PATCH 0722/3904] fix --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 17cd42f2b..cca92b681 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1319,7 +1319,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); - printf("vim empty for tx: %s\n",tx.GetHash().ToString().c_str()); + fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); } // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. @@ -1759,7 +1759,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { if (pfMissingInputs) *pfMissingInputs = true; - fprintf(stderr,"missing inputs in %s\n",tx.GetHash().ToString().c_str()); + //fprintf(stderr,"missing inputs in %s\n",tx.GetHash().ToString().c_str()); return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); } } From 3a705a843e6632c7221c657abb96adf3e3ada344 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:39:27 +0800 Subject: [PATCH 0723/3904] fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cca92b681..7668f7f87 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1317,9 +1317,9 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio // Transactions containing empty `vin` must have either non-empty // `vjoinsplit` or non-empty `vShieldedSpend`. if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { + fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); - fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); } // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. From 1602f04ac8c07a167a08d38e7f0c2ffc2e3ed4df Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 16:59:28 +0800 Subject: [PATCH 0724/3904] fix miner try to stop staker pegging a core --- src/init.cpp | 2 +- src/miner.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index f3d728933..6015106aa 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1501,7 +1501,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fReindex = true; } } - + bool clearWitnessCaches = false; bool fLoaded = false; diff --git a/src/miner.cpp b/src/miner.cpp index bb38e1c02..da9824fd4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1638,8 +1638,8 @@ void static BitcoinMiner() fprintf(stderr," POW\n");*/ if ( h > hashTarget ) { - //if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) - // sleep(1); + if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) + MilliSleep(30); return false; } if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetAdjustedTime() ) @@ -1858,10 +1858,14 @@ void static BitcoinMiner() } //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); - if ( ASSETCHAINS_STAKED > 0 && pwallet != NULL && nThreads == 0 ) - nThreads = 1; - else - return; + + if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 ) + { + if ( pwallet != NULL ) + nThreads = 1; + else + return; + } if ((nThreads == 0 || !fGenerate) && (VERUS_MINTBLOCKS == 0 || pwallet == NULL)) return; From d84aad965157fdb91ed4b67d83fe9f21cd99b40c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 18:41:28 +0800 Subject: [PATCH 0725/3904] remove sleep does nothign --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index da9824fd4..fe9fff5bc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1638,8 +1638,8 @@ void static BitcoinMiner() fprintf(stderr," POW\n");*/ if ( h > hashTarget ) { - if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) - MilliSleep(30); + //if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) + // MilliSleep(30); return false; } if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetAdjustedTime() ) From e9719a96b00fdf5ef74ed382c0ea3b527dbcb620 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 20:08:01 +0800 Subject: [PATCH 0726/3904] disavle DNS seeds --- src/net.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net.cpp b/src/net.cpp index 47aaf921c..c33f82627 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1263,6 +1263,7 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { + return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From 3dd1038988c7aecdc6042561b63612af318aea0d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 20:09:57 +0800 Subject: [PATCH 0727/3904] what --- src/rpcmisc.cpp | 1300 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1300 insertions(+) create mode 100644 src/rpcmisc.cpp diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp new file mode 100644 index 000000000..4f436f41a --- /dev/null +++ b/src/rpcmisc.cpp @@ -0,0 +1,1300 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "base58.h" +#include "clientversion.h" +#include "init.h" +#include "main.h" +#include "net.h" +#include "netbase.h" +#include "rpcserver.h" +#include "timedata.h" +#include "txmempool.h" +#include "util.h" +#include "notaries_staked.h" +#ifdef ENABLE_WALLET +#include "wallet/wallet.h" +#include "wallet/walletdb.h" +#endif + +#include + +#include + +#include + +#include "zcash/Address.hpp" + +using namespace std; + +/** + * @note Do not add or change anything in the information returned by this + * method. `getinfo` exists for backwards-compatibility only. It combines + * information from wildly different sources in the program, which is a mess, + * and is thus planned to be deprecated eventually. + * + * Based on the source of the information, new information should be added to: + * - `getblockchaininfo`, + * - `getnetworkinfo` or + * - `getwalletinfo` + * + * Or alternatively, create a specific query method for the information. + **/ + +int32_t Jumblr_depositaddradd(char *depositaddr); +int32_t Jumblr_secretaddradd(char *secretaddr); +uint64_t komodo_interestsum(); +int32_t komodo_longestchain(); +int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); +uint32_t komodo_chainactive_timestamp(); +int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); +extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +uint32_t komodo_segid32(char *coinaddr); +int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); +int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); +#define KOMODO_VERSION "0.2.1" +extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; +extern uint32_t ASSETCHAINS_CC; +extern uint32_t ASSETCHAINS_MAGIC; +extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; +extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; + +int32_t getera(int now) +{ + for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { + if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + return(i); + } + } +} + +UniValue getiguanajson(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA."); + + UniValue json(UniValue::VOBJ); + UniValue seeds(UniValue::VARR); + UniValue notaries(UniValue::VARR); + // get the current era, use local time for now. + // should ideally take blocktime of last known block? + int now = time(NULL); + int32_t era = getera(now); + + // loop over seeds array and push back to json array for seeds + for (int8_t i = 0; i < 8; i++) { + seeds.push_back(iguanaSeeds[i][0]); + } + + // loop over era's notaries and push back each pair to the notary array + for (int8_t i = 0; i < num_notaries_STAKED[era]; i++) { + UniValue notary(UniValue::VOBJ); + notary.push_back(Pair(notaries_STAKED[era][i][0],notaries_STAKED[era][i][1])); + notaries.push_back(notary); + } + + // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. + int minsigs; + if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) + minsigs = (num_notaries_STAKED[era] / 5) + 1; + else + minsigs = overrideMinSigs; + + json.push_back(Pair("port",iguanaPort)); + json.push_back(Pair("BTCminsigs",BTCminsigs)); + json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("seeds", seeds)); + json.push_back(Pair("notaries",notaries)); + return json; +} + +UniValue getnotarysendmany(const UniValue& params, bool fHelp) +{ + int era = getera(time(NULL)); + + UniValue ret(UniValue::VOBJ); + for (int i = 0; ics_wallet : NULL); +//#else + LOCK(cs_main); +//#endif + + proxyType proxy; + GetProxy(NET_IPV4, proxy); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); + + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("version", CLIENT_VERSION)); + obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); + obj.push_back(Pair("KMDversion", KOMODO_VERSION)); + obj.push_back(Pair("notarized", notarized_height)); + obj.push_back(Pair("prevMoMheight", prevMoMheight)); + obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); + obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); + txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + if ( txid_height > 0 ) + obj.push_back(Pair("notarizedtxid_height", txid_height)); + else obj.push_back(Pair("notarizedtxid_height", "mempool")); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); + obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); + //fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); +#ifdef ENABLE_WALLET + if (pwalletMain) { + obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); + obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() + } + else + { + obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); // + } + } +#endif + //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); + obj.push_back(Pair("blocks", (int)chainActive.Height())); + if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) + longestchain = chainActive.Height(); + //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); + obj.push_back(Pair("longestchain", longestchain)); + obj.push_back(Pair("timeoffset", GetTimeOffset())); + if ( chainActive.LastTip() != 0 ) + obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime)); + obj.push_back(Pair("connections", (int)vNodes.size())); + obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); + obj.push_back(Pair("difficulty", (double)GetDifficulty())); + obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); +#ifdef ENABLE_WALLET + if (pwalletMain) { + obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); + obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + } + if (pwalletMain && pwalletMain->IsCrypted()) + obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); + obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); +#endif + obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); + obj.push_back(Pair("errors", GetWarnings("statusbar"))); + if ( NOTARY_PUBKEY33[0] != 0 ) { + char pubkeystr[65]; int32_t notaryid; std::string notaryname; + if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str())) != -1 ) { + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("notaryname", notaryname)); + } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { + obj.push_back(Pair("notaryid", notaryid)); + if ( KOMODO_LASTMINED != 0 ) + obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); + } + if ( ASSETCHAINS_CC != 0 ) + obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); + obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); + obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); + obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + obj.push_back(Pair("StakedEra", STAKED_ERA)); + //obj.push_back(Pair("name", ASSETCHAINS_SYMBOL)); + obj.push_back(Pair("magic", (int)ASSETCHAINS_MAGIC)); + if ( ASSETCHAINS_SUPPLY != 0 ) + obj.push_back(Pair("premine", ASSETCHAINS_SUPPLY)); + if ( ASSETCHAINS_REWARD != 0 ) + obj.push_back(Pair("reward", ASSETCHAINS_REWARD)); + if ( ASSETCHAINS_HALVING != 0 ) + obj.push_back(Pair("halving", ASSETCHAINS_HALVING)); + if ( ASSETCHAINS_DECAY != 0 ) + obj.push_back(Pair("decay", ASSETCHAINS_DECAY)); + if ( ASSETCHAINS_ENDSUBSIDY != 0 ) + obj.push_back(Pair("endsubsidy", ASSETCHAINS_ENDSUBSIDY)); + if ( ASSETCHAINS_COMMISSION != 0 ) + obj.push_back(Pair("commission", ASSETCHAINS_COMMISSION)); + if ( ASSETCHAINS_STAKED != 0 ) + obj.push_back(Pair("staked", ASSETCHAINS_STAKED)); + } + return obj; +} + +#ifdef ENABLE_WALLET +class DescribeAddressVisitor : public boost::static_visitor +{ +public: + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } + + UniValue operator()(const CKeyID &keyID) const { + UniValue obj(UniValue::VOBJ); + CPubKey vchPubKey; + obj.push_back(Pair("isscript", false)); + if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) { + obj.push_back(Pair("pubkey", HexStr(vchPubKey))); + obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); + } + return obj; + } + + UniValue operator()(const CScriptID &scriptID) const { + UniValue obj(UniValue::VOBJ); + CScript subscript; + obj.push_back(Pair("isscript", true)); + if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) { + std::vector addresses; + txnouttype whichType; + int nRequired; + ExtractDestinations(subscript, whichType, addresses, nRequired); + obj.push_back(Pair("script", GetTxnOutputType(whichType))); + obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); + UniValue a(UniValue::VARR); + BOOST_FOREACH(const CTxDestination& addr, addresses) + a.push_back(CBitcoinAddress(addr).ToString()); + obj.push_back(Pair("addresses", a)); + if (whichType == TX_MULTISIG) + obj.push_back(Pair("sigsrequired", nRequired)); + } + return obj; + } +}; +#endif + +UniValue coinsupply(const UniValue& params, bool fHelp) +{ + int32_t height = 0; int32_t currentHeight; int64_t zfunds,supply = 0; UniValue result(UniValue::VOBJ); + if (fHelp || params.size() > 1) + throw runtime_error("coinsupply \n" + "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" + "\nArguments:\n" + "1. \"height\" (integer, optional) Block height\n" + "\nResult:\n" + "{\n" + " \"result\" : \"success\", (string) If the request was successful.\n" + " \"coin\" : \"KMD\", (string) The currency symbol of the coin for asset chains, otherwise KMD.\n" + " \"height\" : 420, (integer) The height of this coin supply data\n" + " \"supply\" : \"777.0\", (float) The transparent coin supply\n" + " \"zfunds\" : \"0.777\", (float) The shielded coin supply (in zaddrs)\n" + " \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("coinsupply", "420") + + HelpExampleRpc("coinsupply", "420") + ); + if ( params.size() == 0 ) + height = chainActive.Height(); + else height = atoi(params[0].get_str()); + currentHeight = chainActive.Height(); + + if (height >= 0 && height <= currentHeight) { + if ( (supply= komodo_coinsupply(&zfunds,height)) > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("coin", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); + result.push_back(Pair("height", (int)height)); + result.push_back(Pair("supply", ValueFromAmount(supply))); + result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); + result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); + } else result.push_back(Pair("error", "couldnt calculate supply")); + } else { + result.push_back(Pair("error", "invalid height")); + } + return(result); +} + +UniValue jumblr_deposit(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp || params.size() != 1) + throw runtime_error("jumblr_deposit \"depositaddress\"\n"); + CBitcoinAddress address(params[0].get_str()); + bool isValid = address.IsValid(); + if ( isValid != 0 ) + { + string addr = params[0].get_str(); + if ( (retval= Jumblr_depositaddradd((char *)addr.c_str())) >= 0 ) + { + result.push_back(Pair("result", retval)); + JUMBLR_PAUSE = 0; + } + else result.push_back(Pair("error", retval)); + } else result.push_back(Pair("error", "invalid address")); + return(result); +} + +UniValue jumblr_secret(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp || params.size() != 1) + throw runtime_error("jumblr_secret \"secretaddress\"\n"); + CBitcoinAddress address(params[0].get_str()); + bool isValid = address.IsValid(); + if ( isValid != 0 ) + { + string addr = params[0].get_str(); + retval = Jumblr_secretaddradd((char *)addr.c_str()); + result.push_back(Pair("result", "success")); + result.push_back(Pair("num", retval)); + JUMBLR_PAUSE = 0; + } else result.push_back(Pair("error", "invalid address")); + return(result); +} + +UniValue jumblr_pause(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp ) + throw runtime_error("jumblr_pause\n"); + JUMBLR_PAUSE = 1; + result.push_back(Pair("result", "paused")); + return(result); +} + +UniValue jumblr_resume(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp ) + throw runtime_error("jumblr_resume\n"); + JUMBLR_PAUSE = 0; + result.push_back(Pair("result", "resumed")); + return(result); +} + +UniValue validateaddress(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "validateaddress \"komodoaddress\"\n" + "\nReturn information about the given Komodo address.\n" + "\nArguments:\n" + "1. \"komodoaddress\" (string, required) The Komodo address to validate\n" + "\nResult:\n" + "{\n" + " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" + " \"address\" : \"komodoaddress\", (string) The Komodo address validated\n" + " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" + " \"ismine\" : true|false, (boolean) If the address is yours or not\n" + " \"isscript\" : true|false, (boolean) If the key is a script\n" + " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" + " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" + " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") + + HelpExampleRpc("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") + ); + +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +#else + LOCK(cs_main); +#endif + + CBitcoinAddress address(params[0].get_str()); + bool isValid = address.IsValid(); + + UniValue ret(UniValue::VOBJ); + ret.push_back(Pair("isvalid", isValid)); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + ret.push_back(Pair("address", currentAddress)); + + CScript scriptPubKey = GetScriptForDestination(dest); + ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); + ret.push_back(Pair("segid", (int32_t)komodo_segid32((char *)params[0].get_str().c_str()) & 0x3f)); +#ifdef ENABLE_WALLET + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); + ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); + UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest); + ret.pushKVs(detail); + if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) + ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name)); +#endif + } + return ret; +} + + +UniValue z_validateaddress(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "z_validateaddress \"zaddr\"\n" + "\nReturn information about the given z address.\n" + "\nArguments:\n" + "1. \"zaddr\" (string, required) The z address to validate\n" + "\nResult:\n" + "{\n" + " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" + " \"address\" : \"zaddr\", (string) The z address validated\n" + " \"ismine\" : true|false, (boolean) If the address is yours or not\n" + " \"payingkey\" : \"hex\", (string) The hex value of the paying key, a_pk\n" + " \"transmissionkey\" : \"hex\", (string) The hex value of the transmission key, pk_enc\n" + + "}\n" + "\nExamples:\n" + + HelpExampleCli("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") + + HelpExampleRpc("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") + ); + + +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain->cs_wallet); +#else + LOCK(cs_main); +#endif + + bool isValid = false; + bool isMine = false; + std::string payingKey, transmissionKey; + + string strAddress = params[0].get_str(); + try { + CZCPaymentAddress address(strAddress); + libzcash::PaymentAddress addr = address.Get(); + +#ifdef ENABLE_WALLET + isMine = pwalletMain->HaveSpendingKey(addr); +#endif + payingKey = addr.a_pk.GetHex(); + transmissionKey = addr.pk_enc.GetHex(); + isValid = true; + } catch (std::runtime_error e) { + // address is invalid, nop here as isValid is false. + } + + UniValue ret(UniValue::VOBJ); + ret.push_back(Pair("isvalid", isValid)); + if (isValid) + { + ret.push_back(Pair("address", strAddress)); + ret.push_back(Pair("payingkey", payingKey)); + ret.push_back(Pair("transmissionkey", transmissionKey)); +#ifdef ENABLE_WALLET + ret.push_back(Pair("ismine", isMine)); +#endif + } + return ret; +} + + +/** + * Used by addmultisigaddress / createmultisig: + */ +CScript _createmultisig_redeemScript(const UniValue& params) +{ + int nRequired = params[0].get_int(); + const UniValue& keys = params[1].get_array(); + + // Gather public keys + if (nRequired < 1) + throw runtime_error("a multisignature address must require at least one key to redeem"); + if ((int)keys.size() < nRequired) + throw runtime_error( + strprintf("not enough keys supplied " + "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired)); + if (keys.size() > 16) + throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number"); + std::vector pubkeys; + pubkeys.resize(keys.size()); + for (unsigned int i = 0; i < keys.size(); i++) + { + const std::string& ks = keys[i].get_str(); +#ifdef ENABLE_WALLET + // Case 1: Bitcoin address and we have full public key: + CBitcoinAddress address(ks); + if (pwalletMain && address.IsValid()) + { + CKeyID keyID; + if (!address.GetKeyID(keyID)) + throw runtime_error( + strprintf("%s does not refer to a key",ks)); + CPubKey vchPubKey; + if (!pwalletMain->GetPubKey(keyID, vchPubKey)) + throw runtime_error( + strprintf("no full public key for address %s",ks)); + if (!vchPubKey.IsFullyValid()) + throw runtime_error(" Invalid public key: "+ks); + pubkeys[i] = vchPubKey; + } + + // Case 2: hex public key + else +#endif + if (IsHex(ks)) + { + CPubKey vchPubKey(ParseHex(ks)); + if (!vchPubKey.IsFullyValid()) + throw runtime_error(" Invalid public key: "+ks); + pubkeys[i] = vchPubKey; + } + else + { + throw runtime_error(" Invalid public key: "+ks); + } + } + CScript result = GetScriptForMultisig(nRequired, pubkeys); + + if (result.size() > MAX_SCRIPT_ELEMENT_SIZE) + throw runtime_error( + strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE)); + + return result; +} + +UniValue createmultisig(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() < 2 || params.size() > 2) + { + string msg = "createmultisig nrequired [\"key\",...]\n" + "\nCreates a multi-signature address with n signature of m keys required.\n" + "It returns a json object with the address and redeemScript.\n" + + "\nArguments:\n" + "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" + "2. \"keys\" (string, required) A json array of keys which are Komodo addresses or hex-encoded public keys\n" + " [\n" + " \"key\" (string) Komodo address or hex-encoded public key\n" + " ,...\n" + " ]\n" + + "\nResult:\n" + "{\n" + " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" + " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" + "}\n" + + "\nExamples:\n" + "\nCreate a multisig address from 2 addresses\n" + + HelpExampleCli("createmultisig", "2 \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + + "\nAs a json rpc call\n" + + HelpExampleRpc("createmultisig", "2, \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + ; + throw runtime_error(msg); + } + + // Construct using pay-to-script-hash: + CScript inner = _createmultisig_redeemScript(params); + CScriptID innerID(inner); + CBitcoinAddress address(innerID); + + UniValue result(UniValue::VOBJ); + result.push_back(Pair("address", address.ToString())); + result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); + + return result; +} + +UniValue verifymessage(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 3) + throw runtime_error( + "verifymessage \"komodoaddress\" \"signature\" \"message\"\n" + "\nVerify a signed message\n" + "\nArguments:\n" + "1. \"komodoaddress\" (string, required) The Komodo address to use for the signature.\n" + "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n" + "3. \"message\" (string, required) The message that was signed.\n" + "\nResult:\n" + "true|false (boolean) If the signature is verified or not.\n" + "\nExamples:\n" + "\nUnlock the wallet for 30 seconds\n" + + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + + "\nCreate the signature\n" + + HelpExampleCli("signmessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"my message\"") + + "\nVerify the signature\n" + + HelpExampleCli("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"signature\" \"my message\"") + + "\nAs json rpc\n" + + HelpExampleRpc("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", \"signature\", \"my message\"") + ); + + LOCK(cs_main); + + string strAddress = params[0].get_str(); + string strSign = params[1].get_str(); + string strMessage = params[2].get_str(); + + CBitcoinAddress addr(strAddress); + if (!addr.IsValid()) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); + + CKeyID keyID; + if (!addr.GetKeyID(keyID)) + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); + + bool fInvalid = false; + vector vchSig = DecodeBase64(strSign.c_str(), &fInvalid); + + if (fInvalid) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); + + CHashWriter ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << strMessage; + + CPubKey pubkey; + if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) + return false; + + return (pubkey.GetID() == keyID); +} + +UniValue setmocktime(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "setmocktime timestamp\n" + "\nSet the local time to given timestamp (-regtest only)\n" + "\nArguments:\n" + "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" + " Pass 0 to go back to using the system time." + ); + + if (!Params().MineBlocksOnDemand()) + throw runtime_error("setmocktime for regression testing (-regtest mode) only"); + + // cs_vNodes is locked and node send/receive times are updated + // atomically with the time change to prevent peers from being + // disconnected because we think we haven't communicated with them + // in a long time. + LOCK2(cs_main, cs_vNodes); + + RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); + SetMockTime(params[0].get_int64()); + + uint64_t t = GetTime(); + BOOST_FOREACH(CNode* pnode, vNodes) { + pnode->nLastSend = pnode->nLastRecv = t; + } + + return NullUniValue; +} + +bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address) +{ + if (type == 2) { + address = CBitcoinAddress(CScriptID(hash)).ToString(); + } else if (type == 1) { + address = CBitcoinAddress(CKeyID(hash)).ToString(); + } + else { + return false; + } + return true; +} + +bool getAddressesFromParams(const UniValue& params, std::vector > &addresses) +{ + if (params[0].isStr()) { + CBitcoinAddress address(params[0].get_str()); + uint160 hashBytes; + int type = 0; + if (!address.GetIndexKey(hashBytes, type)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + addresses.push_back(std::make_pair(hashBytes, type)); + } else if (params[0].isObject()) { + + UniValue addressValues = find_value(params[0].get_obj(), "addresses"); + if (!addressValues.isArray()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Addresses is expected to be an array"); + } + + std::vector values = addressValues.getValues(); + + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + + CBitcoinAddress address(it->get_str()); + uint160 hashBytes; + int type = 0; + if (!address.GetIndexKey(hashBytes, type)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses"); + } + addresses.push_back(std::make_pair(hashBytes, type)); + } + } else { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresse"); + } + + return true; +} + +bool heightSort(std::pair a, + std::pair b) { + return a.second.blockHeight < b.second.blockHeight; +} + +bool timestampSort(std::pair a, + std::pair b) { + return a.second.time < b.second.time; +} + +UniValue getaddressmempool(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddressmempool\n" + "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + "}\n" + "\nResult:\n" + "[\n" + " {\n" + " \"address\" (string) The base58check encoded address\n" + " \"txid\" (string) The related txid\n" + " \"index\" (number) The related input or output index\n" + " \"satoshis\" (number) The difference of satoshis\n" + " \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n" + " \"prevtxid\" (string) The previous txid (if spending)\n" + " \"prevout\" (string) The previous transaction output index (if spending)\n" + " }\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > indexes; + + if (!mempool.getAddressIndex(addresses, indexes)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + + std::sort(indexes.begin(), indexes.end(), timestampSort); + + UniValue result(UniValue::VARR); + + for (std::vector >::iterator it = indexes.begin(); + it != indexes.end(); it++) { + + std::string address; + if (!getAddressFromIndex(it->first.type, it->first.addressBytes, address)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); + } + + UniValue delta(UniValue::VOBJ); + delta.push_back(Pair("address", address)); + delta.push_back(Pair("txid", it->first.txhash.GetHex())); + delta.push_back(Pair("index", (int)it->first.index)); + delta.push_back(Pair("satoshis", it->second.amount)); + delta.push_back(Pair("timestamp", it->second.time)); + if (it->second.amount < 0) { + delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex())); + delta.push_back(Pair("prevout", (int)it->second.prevout)); + } + result.push_back(delta); + } + + return result; +} + +UniValue getaddressutxos(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddressutxos\n" + "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ],\n" + " \"chainInfo\" (boolean) Include chain info with results\n" + "}\n" + "\nResult\n" + "[\n" + " {\n" + " \"address\" (string) The address base58check encoded\n" + " \"txid\" (string) The output txid\n" + " \"height\" (number) The block height\n" + " \"outputIndex\" (number) The output index\n" + " \"script\" (strin) The script hex encoded\n" + " \"satoshis\" (number) The number of satoshis of the output\n" + " }\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + bool includeChainInfo = false; + if (params[0].isObject()) { + UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); + if (chainInfo.isBool()) { + includeChainInfo = chainInfo.get_bool(); + } + } + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > unspentOutputs; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (!GetAddressUnspent((*it).first, (*it).second, unspentOutputs)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + + std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort); + + UniValue utxos(UniValue::VARR); + + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { + UniValue output(UniValue::VOBJ); + std::string address; + if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); + } + + output.push_back(Pair("address", address)); + output.push_back(Pair("txid", it->first.txhash.GetHex())); + output.push_back(Pair("outputIndex", (int)it->first.index)); + output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end()))); + output.push_back(Pair("satoshis", it->second.satoshis)); + output.push_back(Pair("height", it->second.blockHeight)); + utxos.push_back(output); + } + + if (includeChainInfo) { + UniValue result(UniValue::VOBJ); + result.push_back(Pair("utxos", utxos)); + + LOCK(cs_main); + result.push_back(Pair("hash", chainActive.LastTip()->GetBlockHash().GetHex())); + result.push_back(Pair("height", (int)chainActive.Height())); + return result; + } else { + return utxos; + } +} + +UniValue getaddressdeltas(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1 || !params[0].isObject()) + throw runtime_error( + "getaddressdeltas\n" + "\nReturns all changes for an address (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + " \"start\" (number) The start block height\n" + " \"end\" (number) The end block height\n" + " \"chainInfo\" (boolean) Include chain info in results, only applies if start and end specified\n" + "}\n" + "\nResult:\n" + "[\n" + " {\n" + " \"satoshis\" (number) The difference of satoshis\n" + " \"txid\" (string) The related txid\n" + " \"index\" (number) The related input or output index\n" + " \"height\" (number) The block height\n" + " \"address\" (string) The base58check encoded address\n" + " }\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + + UniValue startValue = find_value(params[0].get_obj(), "start"); + UniValue endValue = find_value(params[0].get_obj(), "end"); + + UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); + bool includeChainInfo = false; + if (chainInfo.isBool()) { + includeChainInfo = chainInfo.get_bool(); + } + + int start = 0; + int end = 0; + + if (startValue.isNum() && endValue.isNum()) { + start = startValue.get_int(); + end = endValue.get_int(); + if (start <= 0 || end <= 0) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start and end is expected to be greater than zero"); + } + if (end < start) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "End value is expected to be greater than start"); + } + } + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > addressIndex; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (start > 0 && end > 0) { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } else { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + } + + UniValue deltas(UniValue::VARR); + + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { + std::string address; + if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); + } + + UniValue delta(UniValue::VOBJ); + delta.push_back(Pair("satoshis", it->second)); + delta.push_back(Pair("txid", it->first.txhash.GetHex())); + delta.push_back(Pair("index", (int)it->first.index)); + delta.push_back(Pair("blockindex", (int)it->first.txindex)); + delta.push_back(Pair("height", it->first.blockHeight)); + delta.push_back(Pair("address", address)); + deltas.push_back(delta); + } + + UniValue result(UniValue::VOBJ); + + if (includeChainInfo && start > 0 && end > 0) { + LOCK(cs_main); + + if (start > chainActive.Height() || end > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start or end is outside chain range"); + } + + CBlockIndex* startIndex = chainActive[start]; + CBlockIndex* endIndex = chainActive[end]; + + UniValue startInfo(UniValue::VOBJ); + UniValue endInfo(UniValue::VOBJ); + + startInfo.push_back(Pair("hash", startIndex->GetBlockHash().GetHex())); + startInfo.push_back(Pair("height", start)); + + endInfo.push_back(Pair("hash", endIndex->GetBlockHash().GetHex())); + endInfo.push_back(Pair("height", end)); + + result.push_back(Pair("deltas", deltas)); + result.push_back(Pair("start", startInfo)); + result.push_back(Pair("end", endInfo)); + + return result; + } else { + return deltas; + } +} + +UniValue getaddressbalance(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddressbalance\n" + "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + "}\n" + "\nResult:\n" + "{\n" + " \"balance\" (string) The current balance in satoshis\n" + " \"received\" (string) The total number of satoshis received (including change)\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > addressIndex; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + + CAmount balance = 0; + CAmount received = 0; + + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { + if (it->second > 0) { + received += it->second; + } + balance += it->second; + } + + UniValue result(UniValue::VOBJ); + result.push_back(Pair("balance", balance)); + result.push_back(Pair("received", received)); + + return result; + +} + +UniValue komodo_snapshot(int top); + +UniValue getsnapshot(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); int64_t total; int32_t top = 0; + + if (params.size() > 0 && !params[0].isNull()) { + top = atoi(params[0].get_str().c_str()); + if (top <= 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer"); + } + + if ( fHelp || params.size() > 1) + { + throw runtime_error( + "getsnapshot\n" + "\nReturns a snapshot of (address,amount) pairs at current height (requires addressindex to be enabled).\n" + "\nArguments:\n" + " \"top\" (number, optional) Only return this many addresses, i.e. top N richlist\n" + "\nResult:\n" + "{\n" + " \"addresses\": [\n" + " {\n" + " \"addr\": \"RMEBhzvATA8mrfVK82E5TgPzzjtaggRGN3\",\n" + " \"amount\": \"100.0\"\n" + " },\n" + " {\n" + " \"addr\": \"RqEBhzvATAJmrfVL82E57gPzzjtaggR777\",\n" + " \"amount\": \"23.45\"\n" + " }\n" + " ],\n" + " \"total\": 123.45 (numeric) Total amount in snapshot\n" + " \"average\": 61.7, (numeric) Average amount in each address \n" + " \"utxos\": 14, (number) Total number of UTXOs in snapshot\n" + " \"total_addresses\": 2, (number) Total number of addresses in snapshot,\n" + " \"start_height\": 91, (number) Block height snapshot began\n" + " \"ending_height\": 91 (number) Block height snapsho finished,\n" + " \"start_time\": 1531982752, (number) Unix epoch time snapshot started\n" + " \"end_time\": 1531982752 (number) Unix epoch time snapshot finished\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getsnapshot","") + + HelpExampleRpc("getsnapshot", "1000") + ); + } + result = komodo_snapshot(top); + if ( result.size() > 0 ) { + result.push_back(Pair("end_time", (int) time(NULL))); + } else { + result.push_back(Pair("error", "no addressindex")); + } + return(result); +} + +UniValue getaddresstxids(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddresstxids\n" + "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + " \"start\" (number) The start block height\n" + " \"end\" (number) The end block height\n" + "}\n" + "\nResult:\n" + "[\n" + " \"transactionid\" (string) The transaction id\n" + " ,...\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + int start = 0; + int end = 0; + if (params[0].isObject()) { + UniValue startValue = find_value(params[0].get_obj(), "start"); + UniValue endValue = find_value(params[0].get_obj(), "end"); + if (startValue.isNum() && endValue.isNum()) { + start = startValue.get_int(); + end = endValue.get_int(); + } + } + + std::vector > addressIndex; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (start > 0 && end > 0) { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } else { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + } + + std::set > txids; + UniValue result(UniValue::VARR); + + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { + int height = it->first.blockHeight; + std::string txid = it->first.txhash.GetHex(); + + if (addresses.size() > 1) { + txids.insert(std::make_pair(height, txid)); + } else { + if (txids.insert(std::make_pair(height, txid)).second) { + result.push_back(txid); + } + } + } + + if (addresses.size() > 1) { + for (std::set >::const_iterator it=txids.begin(); it!=txids.end(); it++) { + result.push_back(it->second); + } + } + + return result; + +} + +UniValue getspentinfo(const UniValue& params, bool fHelp) +{ + + if (fHelp || params.size() != 1 || !params[0].isObject()) + throw runtime_error( + "getspentinfo\n" + "\nReturns the txid and index where an output is spent.\n" + "\nArguments:\n" + "{\n" + " \"txid\" (string) The hex string of the txid\n" + " \"index\" (number) The start block height\n" + "}\n" + "\nResult:\n" + "{\n" + " \"txid\" (string) The transaction id\n" + " \"index\" (number) The spending input index\n" + " ,...\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'") + + HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}") + ); + + UniValue txidValue = find_value(params[0].get_obj(), "txid"); + UniValue indexValue = find_value(params[0].get_obj(), "index"); + + if (!txidValue.isStr() || !indexValue.isNum()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid txid or index"); + } + + uint256 txid = ParseHashV(txidValue, "txid"); + int outputIndex = indexValue.get_int(); + + CSpentIndexKey key(txid, outputIndex); + CSpentIndexValue value; + + if (!GetSpentIndex(key, value)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info"); + } + + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("txid", value.txid.GetHex())); + obj.push_back(Pair("index", (int)value.inputIndex)); + obj.push_back(Pair("height", value.blockHeight)); + + return obj; +} From 6b8d3d392ad0dac9b71f0d229448eb0020f9d01a Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Wed, 5 Dec 2018 20:13:30 +0800 Subject: [PATCH 0728/3904] Delete rpcmisc.cpp --- src/rpcmisc.cpp | 1300 ----------------------------------------------- 1 file changed, 1300 deletions(-) delete mode 100644 src/rpcmisc.cpp diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp deleted file mode 100644 index 4f436f41a..000000000 --- a/src/rpcmisc.cpp +++ /dev/null @@ -1,1300 +0,0 @@ -// Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "base58.h" -#include "clientversion.h" -#include "init.h" -#include "main.h" -#include "net.h" -#include "netbase.h" -#include "rpcserver.h" -#include "timedata.h" -#include "txmempool.h" -#include "util.h" -#include "notaries_staked.h" -#ifdef ENABLE_WALLET -#include "wallet/wallet.h" -#include "wallet/walletdb.h" -#endif - -#include - -#include - -#include - -#include "zcash/Address.hpp" - -using namespace std; - -/** - * @note Do not add or change anything in the information returned by this - * method. `getinfo` exists for backwards-compatibility only. It combines - * information from wildly different sources in the program, which is a mess, - * and is thus planned to be deprecated eventually. - * - * Based on the source of the information, new information should be added to: - * - `getblockchaininfo`, - * - `getnetworkinfo` or - * - `getwalletinfo` - * - * Or alternatively, create a specific query method for the information. - **/ - -int32_t Jumblr_depositaddradd(char *depositaddr); -int32_t Jumblr_secretaddradd(char *secretaddr); -uint64_t komodo_interestsum(); -int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); -uint32_t komodo_chainactive_timestamp(); -int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); -extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -uint32_t komodo_segid32(char *coinaddr); -int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); -int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); -#define KOMODO_VERSION "0.2.1" -extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAINS_CC; -extern uint32_t ASSETCHAINS_MAGIC; -extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; -extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; - -int32_t getera(int now) -{ - for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { - if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { - return(i); - } - } -} - -UniValue getiguanajson(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA."); - - UniValue json(UniValue::VOBJ); - UniValue seeds(UniValue::VARR); - UniValue notaries(UniValue::VARR); - // get the current era, use local time for now. - // should ideally take blocktime of last known block? - int now = time(NULL); - int32_t era = getera(now); - - // loop over seeds array and push back to json array for seeds - for (int8_t i = 0; i < 8; i++) { - seeds.push_back(iguanaSeeds[i][0]); - } - - // loop over era's notaries and push back each pair to the notary array - for (int8_t i = 0; i < num_notaries_STAKED[era]; i++) { - UniValue notary(UniValue::VOBJ); - notary.push_back(Pair(notaries_STAKED[era][i][0],notaries_STAKED[era][i][1])); - notaries.push_back(notary); - } - - // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. - int minsigs; - if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) - minsigs = (num_notaries_STAKED[era] / 5) + 1; - else - minsigs = overrideMinSigs; - - json.push_back(Pair("port",iguanaPort)); - json.push_back(Pair("BTCminsigs",BTCminsigs)); - json.push_back(Pair("minsigs",minsigs)); - json.push_back(Pair("seeds", seeds)); - json.push_back(Pair("notaries",notaries)); - return json; -} - -UniValue getnotarysendmany(const UniValue& params, bool fHelp) -{ - int era = getera(time(NULL)); - - UniValue ret(UniValue::VOBJ); - for (int i = 0; ics_wallet : NULL); -//#else - LOCK(cs_main); -//#endif - - proxyType proxy; - GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); - //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("version", CLIENT_VERSION)); - obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); - obj.push_back(Pair("KMDversion", KOMODO_VERSION)); - obj.push_back(Pair("notarized", notarized_height)); - obj.push_back(Pair("prevMoMheight", prevMoMheight)); - obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); - obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); - txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); - if ( txid_height > 0 ) - obj.push_back(Pair("notarizedtxid_height", txid_height)); - else obj.push_back(Pair("notarizedtxid_height", "mempool")); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); - //fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); -#ifdef ENABLE_WALLET - if (pwalletMain) { - obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); - obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() - } - else - { - obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); // - } - } -#endif - //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); - obj.push_back(Pair("blocks", (int)chainActive.Height())); - if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) - longestchain = chainActive.Height(); - //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); - obj.push_back(Pair("longestchain", longestchain)); - obj.push_back(Pair("timeoffset", GetTimeOffset())); - if ( chainActive.LastTip() != 0 ) - obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime)); - obj.push_back(Pair("connections", (int)vNodes.size())); - obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); - obj.push_back(Pair("difficulty", (double)GetDifficulty())); - obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); -#ifdef ENABLE_WALLET - if (pwalletMain) { - obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); - obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); - } - if (pwalletMain && pwalletMain->IsCrypted()) - obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); - obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); -#endif - obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); - obj.push_back(Pair("errors", GetWarnings("statusbar"))); - if ( NOTARY_PUBKEY33[0] != 0 ) { - char pubkeystr[65]; int32_t notaryid; std::string notaryname; - if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str())) != -1 ) { - obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("notaryname", notaryname)); - } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { - obj.push_back(Pair("notaryid", notaryid)); - if ( KOMODO_LASTMINED != 0 ) - obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } - obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); - } - if ( ASSETCHAINS_CC != 0 ) - obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); - obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); - obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); - obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - obj.push_back(Pair("StakedEra", STAKED_ERA)); - //obj.push_back(Pair("name", ASSETCHAINS_SYMBOL)); - obj.push_back(Pair("magic", (int)ASSETCHAINS_MAGIC)); - if ( ASSETCHAINS_SUPPLY != 0 ) - obj.push_back(Pair("premine", ASSETCHAINS_SUPPLY)); - if ( ASSETCHAINS_REWARD != 0 ) - obj.push_back(Pair("reward", ASSETCHAINS_REWARD)); - if ( ASSETCHAINS_HALVING != 0 ) - obj.push_back(Pair("halving", ASSETCHAINS_HALVING)); - if ( ASSETCHAINS_DECAY != 0 ) - obj.push_back(Pair("decay", ASSETCHAINS_DECAY)); - if ( ASSETCHAINS_ENDSUBSIDY != 0 ) - obj.push_back(Pair("endsubsidy", ASSETCHAINS_ENDSUBSIDY)); - if ( ASSETCHAINS_COMMISSION != 0 ) - obj.push_back(Pair("commission", ASSETCHAINS_COMMISSION)); - if ( ASSETCHAINS_STAKED != 0 ) - obj.push_back(Pair("staked", ASSETCHAINS_STAKED)); - } - return obj; -} - -#ifdef ENABLE_WALLET -class DescribeAddressVisitor : public boost::static_visitor -{ -public: - UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } - - UniValue operator()(const CKeyID &keyID) const { - UniValue obj(UniValue::VOBJ); - CPubKey vchPubKey; - obj.push_back(Pair("isscript", false)); - if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) { - obj.push_back(Pair("pubkey", HexStr(vchPubKey))); - obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); - } - return obj; - } - - UniValue operator()(const CScriptID &scriptID) const { - UniValue obj(UniValue::VOBJ); - CScript subscript; - obj.push_back(Pair("isscript", true)); - if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) { - std::vector addresses; - txnouttype whichType; - int nRequired; - ExtractDestinations(subscript, whichType, addresses, nRequired); - obj.push_back(Pair("script", GetTxnOutputType(whichType))); - obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); - UniValue a(UniValue::VARR); - BOOST_FOREACH(const CTxDestination& addr, addresses) - a.push_back(CBitcoinAddress(addr).ToString()); - obj.push_back(Pair("addresses", a)); - if (whichType == TX_MULTISIG) - obj.push_back(Pair("sigsrequired", nRequired)); - } - return obj; - } -}; -#endif - -UniValue coinsupply(const UniValue& params, bool fHelp) -{ - int32_t height = 0; int32_t currentHeight; int64_t zfunds,supply = 0; UniValue result(UniValue::VOBJ); - if (fHelp || params.size() > 1) - throw runtime_error("coinsupply \n" - "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" - "\nArguments:\n" - "1. \"height\" (integer, optional) Block height\n" - "\nResult:\n" - "{\n" - " \"result\" : \"success\", (string) If the request was successful.\n" - " \"coin\" : \"KMD\", (string) The currency symbol of the coin for asset chains, otherwise KMD.\n" - " \"height\" : 420, (integer) The height of this coin supply data\n" - " \"supply\" : \"777.0\", (float) The transparent coin supply\n" - " \"zfunds\" : \"0.777\", (float) The shielded coin supply (in zaddrs)\n" - " \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("coinsupply", "420") - + HelpExampleRpc("coinsupply", "420") - ); - if ( params.size() == 0 ) - height = chainActive.Height(); - else height = atoi(params[0].get_str()); - currentHeight = chainActive.Height(); - - if (height >= 0 && height <= currentHeight) { - if ( (supply= komodo_coinsupply(&zfunds,height)) > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("coin", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); - result.push_back(Pair("height", (int)height)); - result.push_back(Pair("supply", ValueFromAmount(supply))); - result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); - result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); - } else result.push_back(Pair("error", "couldnt calculate supply")); - } else { - result.push_back(Pair("error", "invalid height")); - } - return(result); -} - -UniValue jumblr_deposit(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp || params.size() != 1) - throw runtime_error("jumblr_deposit \"depositaddress\"\n"); - CBitcoinAddress address(params[0].get_str()); - bool isValid = address.IsValid(); - if ( isValid != 0 ) - { - string addr = params[0].get_str(); - if ( (retval= Jumblr_depositaddradd((char *)addr.c_str())) >= 0 ) - { - result.push_back(Pair("result", retval)); - JUMBLR_PAUSE = 0; - } - else result.push_back(Pair("error", retval)); - } else result.push_back(Pair("error", "invalid address")); - return(result); -} - -UniValue jumblr_secret(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp || params.size() != 1) - throw runtime_error("jumblr_secret \"secretaddress\"\n"); - CBitcoinAddress address(params[0].get_str()); - bool isValid = address.IsValid(); - if ( isValid != 0 ) - { - string addr = params[0].get_str(); - retval = Jumblr_secretaddradd((char *)addr.c_str()); - result.push_back(Pair("result", "success")); - result.push_back(Pair("num", retval)); - JUMBLR_PAUSE = 0; - } else result.push_back(Pair("error", "invalid address")); - return(result); -} - -UniValue jumblr_pause(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp ) - throw runtime_error("jumblr_pause\n"); - JUMBLR_PAUSE = 1; - result.push_back(Pair("result", "paused")); - return(result); -} - -UniValue jumblr_resume(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp ) - throw runtime_error("jumblr_resume\n"); - JUMBLR_PAUSE = 0; - result.push_back(Pair("result", "resumed")); - return(result); -} - -UniValue validateaddress(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "validateaddress \"komodoaddress\"\n" - "\nReturn information about the given Komodo address.\n" - "\nArguments:\n" - "1. \"komodoaddress\" (string, required) The Komodo address to validate\n" - "\nResult:\n" - "{\n" - " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" - " \"address\" : \"komodoaddress\", (string) The Komodo address validated\n" - " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" - " \"ismine\" : true|false, (boolean) If the address is yours or not\n" - " \"isscript\" : true|false, (boolean) If the key is a script\n" - " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" - " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" - " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") - + HelpExampleRpc("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") - ); - -#ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else - LOCK(cs_main); -#endif - - CBitcoinAddress address(params[0].get_str()); - bool isValid = address.IsValid(); - - UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("isvalid", isValid)); - if (isValid) - { - CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); - ret.push_back(Pair("address", currentAddress)); - - CScript scriptPubKey = GetScriptForDestination(dest); - ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - ret.push_back(Pair("segid", (int32_t)komodo_segid32((char *)params[0].get_str().c_str()) & 0x3f)); -#ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); - ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); - UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest); - ret.pushKVs(detail); - if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) - ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name)); -#endif - } - return ret; -} - - -UniValue z_validateaddress(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "z_validateaddress \"zaddr\"\n" - "\nReturn information about the given z address.\n" - "\nArguments:\n" - "1. \"zaddr\" (string, required) The z address to validate\n" - "\nResult:\n" - "{\n" - " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" - " \"address\" : \"zaddr\", (string) The z address validated\n" - " \"ismine\" : true|false, (boolean) If the address is yours or not\n" - " \"payingkey\" : \"hex\", (string) The hex value of the paying key, a_pk\n" - " \"transmissionkey\" : \"hex\", (string) The hex value of the transmission key, pk_enc\n" - - "}\n" - "\nExamples:\n" - + HelpExampleCli("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") - + HelpExampleRpc("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") - ); - - -#ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain->cs_wallet); -#else - LOCK(cs_main); -#endif - - bool isValid = false; - bool isMine = false; - std::string payingKey, transmissionKey; - - string strAddress = params[0].get_str(); - try { - CZCPaymentAddress address(strAddress); - libzcash::PaymentAddress addr = address.Get(); - -#ifdef ENABLE_WALLET - isMine = pwalletMain->HaveSpendingKey(addr); -#endif - payingKey = addr.a_pk.GetHex(); - transmissionKey = addr.pk_enc.GetHex(); - isValid = true; - } catch (std::runtime_error e) { - // address is invalid, nop here as isValid is false. - } - - UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("isvalid", isValid)); - if (isValid) - { - ret.push_back(Pair("address", strAddress)); - ret.push_back(Pair("payingkey", payingKey)); - ret.push_back(Pair("transmissionkey", transmissionKey)); -#ifdef ENABLE_WALLET - ret.push_back(Pair("ismine", isMine)); -#endif - } - return ret; -} - - -/** - * Used by addmultisigaddress / createmultisig: - */ -CScript _createmultisig_redeemScript(const UniValue& params) -{ - int nRequired = params[0].get_int(); - const UniValue& keys = params[1].get_array(); - - // Gather public keys - if (nRequired < 1) - throw runtime_error("a multisignature address must require at least one key to redeem"); - if ((int)keys.size() < nRequired) - throw runtime_error( - strprintf("not enough keys supplied " - "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired)); - if (keys.size() > 16) - throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number"); - std::vector pubkeys; - pubkeys.resize(keys.size()); - for (unsigned int i = 0; i < keys.size(); i++) - { - const std::string& ks = keys[i].get_str(); -#ifdef ENABLE_WALLET - // Case 1: Bitcoin address and we have full public key: - CBitcoinAddress address(ks); - if (pwalletMain && address.IsValid()) - { - CKeyID keyID; - if (!address.GetKeyID(keyID)) - throw runtime_error( - strprintf("%s does not refer to a key",ks)); - CPubKey vchPubKey; - if (!pwalletMain->GetPubKey(keyID, vchPubKey)) - throw runtime_error( - strprintf("no full public key for address %s",ks)); - if (!vchPubKey.IsFullyValid()) - throw runtime_error(" Invalid public key: "+ks); - pubkeys[i] = vchPubKey; - } - - // Case 2: hex public key - else -#endif - if (IsHex(ks)) - { - CPubKey vchPubKey(ParseHex(ks)); - if (!vchPubKey.IsFullyValid()) - throw runtime_error(" Invalid public key: "+ks); - pubkeys[i] = vchPubKey; - } - else - { - throw runtime_error(" Invalid public key: "+ks); - } - } - CScript result = GetScriptForMultisig(nRequired, pubkeys); - - if (result.size() > MAX_SCRIPT_ELEMENT_SIZE) - throw runtime_error( - strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE)); - - return result; -} - -UniValue createmultisig(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 2 || params.size() > 2) - { - string msg = "createmultisig nrequired [\"key\",...]\n" - "\nCreates a multi-signature address with n signature of m keys required.\n" - "It returns a json object with the address and redeemScript.\n" - - "\nArguments:\n" - "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" - "2. \"keys\" (string, required) A json array of keys which are Komodo addresses or hex-encoded public keys\n" - " [\n" - " \"key\" (string) Komodo address or hex-encoded public key\n" - " ,...\n" - " ]\n" - - "\nResult:\n" - "{\n" - " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" - " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" - "}\n" - - "\nExamples:\n" - "\nCreate a multisig address from 2 addresses\n" - + HelpExampleCli("createmultisig", "2 \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + - "\nAs a json rpc call\n" - + HelpExampleRpc("createmultisig", "2, \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") - ; - throw runtime_error(msg); - } - - // Construct using pay-to-script-hash: - CScript inner = _createmultisig_redeemScript(params); - CScriptID innerID(inner); - CBitcoinAddress address(innerID); - - UniValue result(UniValue::VOBJ); - result.push_back(Pair("address", address.ToString())); - result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); - - return result; -} - -UniValue verifymessage(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 3) - throw runtime_error( - "verifymessage \"komodoaddress\" \"signature\" \"message\"\n" - "\nVerify a signed message\n" - "\nArguments:\n" - "1. \"komodoaddress\" (string, required) The Komodo address to use for the signature.\n" - "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n" - "3. \"message\" (string, required) The message that was signed.\n" - "\nResult:\n" - "true|false (boolean) If the signature is verified or not.\n" - "\nExamples:\n" - "\nUnlock the wallet for 30 seconds\n" - + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + - "\nCreate the signature\n" - + HelpExampleCli("signmessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"my message\"") + - "\nVerify the signature\n" - + HelpExampleCli("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"signature\" \"my message\"") + - "\nAs json rpc\n" - + HelpExampleRpc("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", \"signature\", \"my message\"") - ); - - LOCK(cs_main); - - string strAddress = params[0].get_str(); - string strSign = params[1].get_str(); - string strMessage = params[2].get_str(); - - CBitcoinAddress addr(strAddress); - if (!addr.IsValid()) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); - - CKeyID keyID; - if (!addr.GetKeyID(keyID)) - throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); - - bool fInvalid = false; - vector vchSig = DecodeBase64(strSign.c_str(), &fInvalid); - - if (fInvalid) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); - - CHashWriter ss(SER_GETHASH, 0); - ss << strMessageMagic; - ss << strMessage; - - CPubKey pubkey; - if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) - return false; - - return (pubkey.GetID() == keyID); -} - -UniValue setmocktime(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "setmocktime timestamp\n" - "\nSet the local time to given timestamp (-regtest only)\n" - "\nArguments:\n" - "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" - " Pass 0 to go back to using the system time." - ); - - if (!Params().MineBlocksOnDemand()) - throw runtime_error("setmocktime for regression testing (-regtest mode) only"); - - // cs_vNodes is locked and node send/receive times are updated - // atomically with the time change to prevent peers from being - // disconnected because we think we haven't communicated with them - // in a long time. - LOCK2(cs_main, cs_vNodes); - - RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); - SetMockTime(params[0].get_int64()); - - uint64_t t = GetTime(); - BOOST_FOREACH(CNode* pnode, vNodes) { - pnode->nLastSend = pnode->nLastRecv = t; - } - - return NullUniValue; -} - -bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address) -{ - if (type == 2) { - address = CBitcoinAddress(CScriptID(hash)).ToString(); - } else if (type == 1) { - address = CBitcoinAddress(CKeyID(hash)).ToString(); - } - else { - return false; - } - return true; -} - -bool getAddressesFromParams(const UniValue& params, std::vector > &addresses) -{ - if (params[0].isStr()) { - CBitcoinAddress address(params[0].get_str()); - uint160 hashBytes; - int type = 0; - if (!address.GetIndexKey(hashBytes, type)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - addresses.push_back(std::make_pair(hashBytes, type)); - } else if (params[0].isObject()) { - - UniValue addressValues = find_value(params[0].get_obj(), "addresses"); - if (!addressValues.isArray()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Addresses is expected to be an array"); - } - - std::vector values = addressValues.getValues(); - - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { - - CBitcoinAddress address(it->get_str()); - uint160 hashBytes; - int type = 0; - if (!address.GetIndexKey(hashBytes, type)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses"); - } - addresses.push_back(std::make_pair(hashBytes, type)); - } - } else { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresse"); - } - - return true; -} - -bool heightSort(std::pair a, - std::pair b) { - return a.second.blockHeight < b.second.blockHeight; -} - -bool timestampSort(std::pair a, - std::pair b) { - return a.second.time < b.second.time; -} - -UniValue getaddressmempool(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddressmempool\n" - "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - "}\n" - "\nResult:\n" - "[\n" - " {\n" - " \"address\" (string) The base58check encoded address\n" - " \"txid\" (string) The related txid\n" - " \"index\" (number) The related input or output index\n" - " \"satoshis\" (number) The difference of satoshis\n" - " \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n" - " \"prevtxid\" (string) The previous txid (if spending)\n" - " \"prevout\" (string) The previous transaction output index (if spending)\n" - " }\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > indexes; - - if (!mempool.getAddressIndex(addresses, indexes)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - - std::sort(indexes.begin(), indexes.end(), timestampSort); - - UniValue result(UniValue::VARR); - - for (std::vector >::iterator it = indexes.begin(); - it != indexes.end(); it++) { - - std::string address; - if (!getAddressFromIndex(it->first.type, it->first.addressBytes, address)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); - } - - UniValue delta(UniValue::VOBJ); - delta.push_back(Pair("address", address)); - delta.push_back(Pair("txid", it->first.txhash.GetHex())); - delta.push_back(Pair("index", (int)it->first.index)); - delta.push_back(Pair("satoshis", it->second.amount)); - delta.push_back(Pair("timestamp", it->second.time)); - if (it->second.amount < 0) { - delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex())); - delta.push_back(Pair("prevout", (int)it->second.prevout)); - } - result.push_back(delta); - } - - return result; -} - -UniValue getaddressutxos(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddressutxos\n" - "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ],\n" - " \"chainInfo\" (boolean) Include chain info with results\n" - "}\n" - "\nResult\n" - "[\n" - " {\n" - " \"address\" (string) The address base58check encoded\n" - " \"txid\" (string) The output txid\n" - " \"height\" (number) The block height\n" - " \"outputIndex\" (number) The output index\n" - " \"script\" (strin) The script hex encoded\n" - " \"satoshis\" (number) The number of satoshis of the output\n" - " }\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - bool includeChainInfo = false; - if (params[0].isObject()) { - UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); - if (chainInfo.isBool()) { - includeChainInfo = chainInfo.get_bool(); - } - } - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > unspentOutputs; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (!GetAddressUnspent((*it).first, (*it).second, unspentOutputs)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - - std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort); - - UniValue utxos(UniValue::VARR); - - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - UniValue output(UniValue::VOBJ); - std::string address; - if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); - } - - output.push_back(Pair("address", address)); - output.push_back(Pair("txid", it->first.txhash.GetHex())); - output.push_back(Pair("outputIndex", (int)it->first.index)); - output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end()))); - output.push_back(Pair("satoshis", it->second.satoshis)); - output.push_back(Pair("height", it->second.blockHeight)); - utxos.push_back(output); - } - - if (includeChainInfo) { - UniValue result(UniValue::VOBJ); - result.push_back(Pair("utxos", utxos)); - - LOCK(cs_main); - result.push_back(Pair("hash", chainActive.LastTip()->GetBlockHash().GetHex())); - result.push_back(Pair("height", (int)chainActive.Height())); - return result; - } else { - return utxos; - } -} - -UniValue getaddressdeltas(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1 || !params[0].isObject()) - throw runtime_error( - "getaddressdeltas\n" - "\nReturns all changes for an address (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - " \"start\" (number) The start block height\n" - " \"end\" (number) The end block height\n" - " \"chainInfo\" (boolean) Include chain info in results, only applies if start and end specified\n" - "}\n" - "\nResult:\n" - "[\n" - " {\n" - " \"satoshis\" (number) The difference of satoshis\n" - " \"txid\" (string) The related txid\n" - " \"index\" (number) The related input or output index\n" - " \"height\" (number) The block height\n" - " \"address\" (string) The base58check encoded address\n" - " }\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - - UniValue startValue = find_value(params[0].get_obj(), "start"); - UniValue endValue = find_value(params[0].get_obj(), "end"); - - UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); - bool includeChainInfo = false; - if (chainInfo.isBool()) { - includeChainInfo = chainInfo.get_bool(); - } - - int start = 0; - int end = 0; - - if (startValue.isNum() && endValue.isNum()) { - start = startValue.get_int(); - end = endValue.get_int(); - if (start <= 0 || end <= 0) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start and end is expected to be greater than zero"); - } - if (end < start) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "End value is expected to be greater than start"); - } - } - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > addressIndex; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (start > 0 && end > 0) { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } else { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - } - - UniValue deltas(UniValue::VARR); - - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { - std::string address; - if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); - } - - UniValue delta(UniValue::VOBJ); - delta.push_back(Pair("satoshis", it->second)); - delta.push_back(Pair("txid", it->first.txhash.GetHex())); - delta.push_back(Pair("index", (int)it->first.index)); - delta.push_back(Pair("blockindex", (int)it->first.txindex)); - delta.push_back(Pair("height", it->first.blockHeight)); - delta.push_back(Pair("address", address)); - deltas.push_back(delta); - } - - UniValue result(UniValue::VOBJ); - - if (includeChainInfo && start > 0 && end > 0) { - LOCK(cs_main); - - if (start > chainActive.Height() || end > chainActive.Height()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start or end is outside chain range"); - } - - CBlockIndex* startIndex = chainActive[start]; - CBlockIndex* endIndex = chainActive[end]; - - UniValue startInfo(UniValue::VOBJ); - UniValue endInfo(UniValue::VOBJ); - - startInfo.push_back(Pair("hash", startIndex->GetBlockHash().GetHex())); - startInfo.push_back(Pair("height", start)); - - endInfo.push_back(Pair("hash", endIndex->GetBlockHash().GetHex())); - endInfo.push_back(Pair("height", end)); - - result.push_back(Pair("deltas", deltas)); - result.push_back(Pair("start", startInfo)); - result.push_back(Pair("end", endInfo)); - - return result; - } else { - return deltas; - } -} - -UniValue getaddressbalance(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddressbalance\n" - "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - "}\n" - "\nResult:\n" - "{\n" - " \"balance\" (string) The current balance in satoshis\n" - " \"received\" (string) The total number of satoshis received (including change)\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > addressIndex; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - - CAmount balance = 0; - CAmount received = 0; - - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { - if (it->second > 0) { - received += it->second; - } - balance += it->second; - } - - UniValue result(UniValue::VOBJ); - result.push_back(Pair("balance", balance)); - result.push_back(Pair("received", received)); - - return result; - -} - -UniValue komodo_snapshot(int top); - -UniValue getsnapshot(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); int64_t total; int32_t top = 0; - - if (params.size() > 0 && !params[0].isNull()) { - top = atoi(params[0].get_str().c_str()); - if (top <= 0) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer"); - } - - if ( fHelp || params.size() > 1) - { - throw runtime_error( - "getsnapshot\n" - "\nReturns a snapshot of (address,amount) pairs at current height (requires addressindex to be enabled).\n" - "\nArguments:\n" - " \"top\" (number, optional) Only return this many addresses, i.e. top N richlist\n" - "\nResult:\n" - "{\n" - " \"addresses\": [\n" - " {\n" - " \"addr\": \"RMEBhzvATA8mrfVK82E5TgPzzjtaggRGN3\",\n" - " \"amount\": \"100.0\"\n" - " },\n" - " {\n" - " \"addr\": \"RqEBhzvATAJmrfVL82E57gPzzjtaggR777\",\n" - " \"amount\": \"23.45\"\n" - " }\n" - " ],\n" - " \"total\": 123.45 (numeric) Total amount in snapshot\n" - " \"average\": 61.7, (numeric) Average amount in each address \n" - " \"utxos\": 14, (number) Total number of UTXOs in snapshot\n" - " \"total_addresses\": 2, (number) Total number of addresses in snapshot,\n" - " \"start_height\": 91, (number) Block height snapshot began\n" - " \"ending_height\": 91 (number) Block height snapsho finished,\n" - " \"start_time\": 1531982752, (number) Unix epoch time snapshot started\n" - " \"end_time\": 1531982752 (number) Unix epoch time snapshot finished\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getsnapshot","") - + HelpExampleRpc("getsnapshot", "1000") - ); - } - result = komodo_snapshot(top); - if ( result.size() > 0 ) { - result.push_back(Pair("end_time", (int) time(NULL))); - } else { - result.push_back(Pair("error", "no addressindex")); - } - return(result); -} - -UniValue getaddresstxids(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddresstxids\n" - "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - " \"start\" (number) The start block height\n" - " \"end\" (number) The end block height\n" - "}\n" - "\nResult:\n" - "[\n" - " \"transactionid\" (string) The transaction id\n" - " ,...\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - int start = 0; - int end = 0; - if (params[0].isObject()) { - UniValue startValue = find_value(params[0].get_obj(), "start"); - UniValue endValue = find_value(params[0].get_obj(), "end"); - if (startValue.isNum() && endValue.isNum()) { - start = startValue.get_int(); - end = endValue.get_int(); - } - } - - std::vector > addressIndex; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (start > 0 && end > 0) { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } else { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - } - - std::set > txids; - UniValue result(UniValue::VARR); - - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { - int height = it->first.blockHeight; - std::string txid = it->first.txhash.GetHex(); - - if (addresses.size() > 1) { - txids.insert(std::make_pair(height, txid)); - } else { - if (txids.insert(std::make_pair(height, txid)).second) { - result.push_back(txid); - } - } - } - - if (addresses.size() > 1) { - for (std::set >::const_iterator it=txids.begin(); it!=txids.end(); it++) { - result.push_back(it->second); - } - } - - return result; - -} - -UniValue getspentinfo(const UniValue& params, bool fHelp) -{ - - if (fHelp || params.size() != 1 || !params[0].isObject()) - throw runtime_error( - "getspentinfo\n" - "\nReturns the txid and index where an output is spent.\n" - "\nArguments:\n" - "{\n" - " \"txid\" (string) The hex string of the txid\n" - " \"index\" (number) The start block height\n" - "}\n" - "\nResult:\n" - "{\n" - " \"txid\" (string) The transaction id\n" - " \"index\" (number) The spending input index\n" - " ,...\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'") - + HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}") - ); - - UniValue txidValue = find_value(params[0].get_obj(), "txid"); - UniValue indexValue = find_value(params[0].get_obj(), "index"); - - if (!txidValue.isStr() || !indexValue.isNum()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid txid or index"); - } - - uint256 txid = ParseHashV(txidValue, "txid"); - int outputIndex = indexValue.get_int(); - - CSpentIndexKey key(txid, outputIndex); - CSpentIndexValue value; - - if (!GetSpentIndex(key, value)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info"); - } - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("txid", value.txid.GetHex())); - obj.push_back(Pair("index", (int)value.inputIndex)); - obj.push_back(Pair("height", value.blockHeight)); - - return obj; -} From 0ae2e97a1dc62464b4c240d0ab14fe475343b734 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 20:57:21 +0800 Subject: [PATCH 0729/3904] FIX COMMENTED OUT COIN IMPORT --- src/cc/eval.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 03a0cd142..96b85a6dc 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -74,11 +74,11 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) switch ( ecode ) { case EVAL_IMPORTPAYOUT: - //return ImportPayout(vparams, txTo, nIn); + return ImportPayout(vparams, txTo, nIn); break; case EVAL_IMPORTCOIN: - //return ImportCoin(vparams, txTo, nIn); + return ImportCoin(vparams, txTo, nIn); break; default: From d29eed22d5c374a38d123109afdfa7183ceaa959 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:14:50 +0800 Subject: [PATCH 0730/3904] try periodic founders payment first time --- src/komodo_bitcoind.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 582509e57..a0560287f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,6 +1112,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ commission must be in coinbase.vout[1] and must be >= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ +int32_t ASSETCHAINS_FOUNDERS_PERIOD = 5; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); @@ -1123,11 +1124,14 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - n = pblock->vtx[0].vout.size(); - for (j=0; jvtx[0].vout[j].nValue; + comission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + { + if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + comission = comission * ASSETCHAINS_FOUNDERS_PERIOD; + else + comission = 0; + } } else { @@ -1141,7 +1145,10 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) total += pblock->vtx[i].vout[j].nValue; } } + commission = ((total * ASSETCHAINS_COMMISSION) / COIN); } + if ( commission < 10000 ) + commission = 0; return(commission); } @@ -1541,7 +1548,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) { fprintf(stderr,"ERROR: chain not fully loaded or invalid PoS block %s - no past block found\n",blkHash.ToString().c_str()); } - else + else #ifndef KOMODO_ZCASH if (!GetTransaction(txid, tx, Params().GetConsensus(), blkHash, true)) #else @@ -1574,7 +1581,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) { BlockMap::const_iterator it = mapBlockIndex.find(blkHash); if ((it == mapBlockIndex.end()) || - !(pastBlockIndex = it->second) || + !(pastBlockIndex = it->second) || (height - pastBlockIndex->GetHeight()) < VERUS_MIN_STAKEAGE) { fprintf(stderr,"ERROR: invalid PoS block %s - stake source too new or not found\n",blkHash.ToString().c_str()); @@ -1665,9 +1672,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { checktoshis = komodo_commission(pblock,height); //fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); - /*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here - return(-1); - else*/ if ( checktoshis != 0 ) + if ( checktoshis != 0 ) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); From d7a2e9ff2ca8db6b1c8f1cd38fa20f77f76e886e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:26:31 +0800 Subject: [PATCH 0731/3904] fix splling --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a0560287f..0d74a72e2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1124,13 +1124,13 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - comission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) + commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) - comission = comission * ASSETCHAINS_FOUNDERS_PERIOD; + commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else - comission = 0; + commission = 0; } } else From d361307ffadf26a0ea7afb94ab2b969869b0846d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:28:24 +0800 Subject: [PATCH 0732/3904] ;# --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0d74a72e2..d50032073 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1124,7 +1124,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) + commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) From 11a9543ba3b1a493fcb9a4a8483a8f2cbfb48419 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:29:44 +0800 Subject: [PATCH 0733/3904] fix --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d50032073..f7d209639 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1127,7 +1127,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { - if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + if ( pblock.GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else commission = 0; From 5fa97bf2082bafd407bf43b1f983171073a69a7c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:31:02 +0800 Subject: [PATCH 0734/3904] fix asgin --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f7d209639..8ceb28f26 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1127,7 +1127,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { - if ( pblock.GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + if ( pblock->GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else commission = 0; From d5e2a1f96bc5502b63881e813a3be1b7ebf89e22 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:32:49 +0800 Subject: [PATCH 0735/3904] oops --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8ceb28f26..b74c958e1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1127,7 +1127,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { - if ( pblock->GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + if ( height % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else commission = 0; From 311aa931cc143422b68a7cd5a2dfa0466585b9b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:19:31 +0800 Subject: [PATCH 0736/3904] add ac_period and try to fix sendmany --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 1 + src/rpc/client.cpp | 2 ++ src/rpc/misc.cpp | 13 +++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c0de313ab..5c17e8dce 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS_PERIOD; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 31cc577e6..2533f4860 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1772,6 +1772,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); + ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 91b158f45..6553a348a 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -36,6 +36,8 @@ static const CRPCConvertParam vRPCConvertParams[] = { "sendtoaddress", 1 }, { "sendtoaddress", 4 }, { "settxfee", 0 }, + { "getnotarysendmany", 0 }, + { "getnotarysendmany", 1 }, { "getreceivedbyaddress", 1 }, { "getreceivedbyaccount", 1 }, { "listreceivedbyaddress", 0 }, diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index abd293b28..4ded906c6 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -119,6 +119,19 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { + if (fHelp || params.size() > 1) + throw runtime_error( + "getnotarysendmany\n" + "Returns a sendmany JSON array with all current notaries Raddress's.\n" + "\nExamples:\n" + + HelpExampleCli("getnotarysendmany", "10") + + HelpExampleRpc("getnotarysendmany", "10") + ); + int amount = 0; + if ( params.size() = 1 ) { + amount = params[0].get_int(); + } + int era = getera(time(NULL)); UniValue ret(UniValue::VOBJ); From 51b4c9a346492881c9a42708885f1b02e9d5bf04 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:21:36 +0800 Subject: [PATCH 0737/3904] missed save --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b74c958e1..d9afece44 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ commission must be in coinbase.vout[1] and must be >= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ -int32_t ASSETCHAINS_FOUNDERS_PERIOD = 5; +extern int32_t ASSETCHAINS_FOUNDERS_PERIOD; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); From 6731ee159f2f6dc2f3627ce0ce9718dc5e138fe9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:22:23 +0800 Subject: [PATCH 0738/3904] fix --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 4ded906c6..878eb3755 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -128,7 +128,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) + HelpExampleRpc("getnotarysendmany", "10") ); int amount = 0; - if ( params.size() = 1 ) { + if ( params.size() == 1 ) { amount = params[0].get_int(); } From 1e8e9c621b6651aac2fdd6eb2dc1764f878ad65f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:26:33 +0800 Subject: [PATCH 0739/3904] fix --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 878eb3755..e9efaecd5 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -140,7 +140,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)notaries_STAKED[era][i][1]); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - ret.push_back(Pair(Raddress,(int)10)); + ret.push_back(Pair(Raddress,amount)); } return ret; } From 6a7df872138c299c1b2369f5e30f8a5b207edaab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 12:19:21 +0800 Subject: [PATCH 0740/3904] add print --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c4204f8a0..aa308faee 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7365,7 +7365,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) if ( out.nDepth < 100 ) nValues2[segid] += nValue, total2 += nValue; else nValues[segid] += nValue, total += nValue; - //fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); + fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); } else fprintf(stderr,"no destination\n"); } ret.push_back(Pair("mature",(double)total/COIN)); From 665d5446d122f5a0cfba61d251d4fb87b69f9c33 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 12:54:01 +0800 Subject: [PATCH 0741/3904] debug prints --- src/miner.cpp | 10 +++++++--- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fe9fff5bc..e8b1c211d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -760,23 +760,27 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - //fprintf(stderr,"use notary pubkey\n"); + fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { + fprintf(stderr,"do not use notary pubkey\n"); if (!isStake) { + fprintf(stderr,"is not stake.. whatever that means...\n"); if (!reservekey.GetReservedKey(pubkey)) { + fprintf(stderr,"returning null here\n"); return NULL; } scriptPubKey.resize(35); ptr = (uint8_t *)pubkey.begin(); scriptPubKey[0] = 33; - for (i=0; i<33; i++) + for (i=0; i<33; i++) { scriptPubKey[i+1] = ptr[i]; + fprintf(stderr,"%02x",scriptPubKey[i+1]); + } scriptPubKey[34] = OP_CHECKSIG; - //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } } return CreateNewBlock(scriptPubKey, gpucount, isStake); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index aa308faee..c4204f8a0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7365,7 +7365,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) if ( out.nDepth < 100 ) nValues2[segid] += nValue, total2 += nValue; else nValues[segid] += nValue, total += nValue; - fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); + //fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); } else fprintf(stderr,"no destination\n"); } ret.push_back(Pair("mature",(double)total/COIN)); From 52f7a22072f892d819478ca1782b7cc5064c01a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:13:21 +0800 Subject: [PATCH 0742/3904] a --- src/miner.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e8b1c211d..f996841a2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -760,17 +760,14 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - fprintf(stderr,"use notary pubkey\n"); + //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { - fprintf(stderr,"do not use notary pubkey\n"); if (!isStake) { - fprintf(stderr,"is not stake.. whatever that means...\n"); if (!reservekey.GetReservedKey(pubkey)) { - fprintf(stderr,"returning null here\n"); return NULL; } scriptPubKey.resize(35); @@ -778,11 +775,15 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey[0] = 33; for (i=0; i<33; i++) { scriptPubKey[i+1] = ptr[i]; - fprintf(stderr,"%02x",scriptPubKey[i+1]); } scriptPubKey[34] = OP_CHECKSIG; } } + fprintf(stderr,"selected pubkey for new block: "); + for (i=0; i<33; i++) { + fprintf(stderr,"%02x",scriptPubKey[i+1]); + } + fprintf(stderr,"/n"); return CreateNewBlock(scriptPubKey, gpucount, isStake); } From 18c8e33c42de502d8a4e487f01ee936f5db62054 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:20:59 +0800 Subject: [PATCH 0743/3904] more prints --- src/miner.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index f996841a2..523546f46 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,6 +154,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if (txT == TX_PUBKEY) pk = CPubKey(vAddrs[0]); } + fprintf(stderr,"selected pubkey inside CreateBlock: "); + for (i=0; i<33; i++) { + fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); + } + fprintf(stderr,"/n"); uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); //fprintf(stderr,"create new block\n"); From bc874c93c57248c4036c22929722a6617dd4b9fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:25:27 +0800 Subject: [PATCH 0744/3904] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 523546f46..96c1ba894 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,7 +155,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, pk = CPubKey(vAddrs[0]); } fprintf(stderr,"selected pubkey inside CreateBlock: "); - for (i=0; i<33; i++) { + for (int i=0; i<33; i++) { fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); } fprintf(stderr,"/n"); From 94b968f032b659ea57a71a66c73428c40527d1ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:35:02 +0800 Subject: [PATCH 0745/3904] check --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 96c1ba894..70bc59868 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -158,7 +158,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, for (int i=0; i<33; i++) { fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); } - fprintf(stderr,"/n"); + fprintf(stderr,"\n"); uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); //fprintf(stderr,"create new block\n"); @@ -773,6 +773,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, { if (!reservekey.GetReservedKey(pubkey)) { + fprintf(stderr,"selected NULL pubkey."); return NULL; } scriptPubKey.resize(35); @@ -788,7 +789,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, for (i=0; i<33; i++) { fprintf(stderr,"%02x",scriptPubKey[i+1]); } - fprintf(stderr,"/n"); + fprintf(stderr,"\n"); return CreateNewBlock(scriptPubKey, gpucount, isStake); } From b0988d092a6797fd85f7f36e4f945274828831d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:42:35 +0800 Subject: [PATCH 0746/3904] p --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 70bc59868..5af2af034 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -773,7 +773,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, { if (!reservekey.GetReservedKey(pubkey)) { - fprintf(stderr,"selected NULL pubkey."); return NULL; } scriptPubKey.resize(35); @@ -784,6 +783,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } scriptPubKey[34] = OP_CHECKSIG; } + else fprintf(stderr,"IsStake\n"); } fprintf(stderr,"selected pubkey for new block: "); for (i=0; i<33; i++) { From 69a96d010c5a6517619eba2c76dc11283f00d3a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:54:23 +0800 Subject: [PATCH 0747/3904] FIX easter EGG! --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5af2af034..d2f37fbef 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1479,7 +1479,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0; #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From b5a2aa83c53e2f33de71aa02a5c7a2fdc6a2a223 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:00:15 +0800 Subject: [PATCH 0748/3904] ) --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index d2f37fbef..6dd32564c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1479,7 +1479,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0; + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From f63a5470fb9a74a8d891af6321d39c9e311c6e31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:24:57 +0800 Subject: [PATCH 0749/3904] try --- src/rpc/mining.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 25b75c301..d680e3867 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -332,7 +332,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) if (params.size() > 0) fGenerate = params[0].get_bool(); - int nGenProcLimit = GetArg("-genproclimit", -1);; + int nGenProcLimit = GetArg("-genproclimit", 0);; if (params.size() > 1) { nGenProcLimit = params[1].get_int(); @@ -356,6 +356,8 @@ UniValue setgenerate(const UniValue& params, bool fHelp) mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); + fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0); + #ifdef ENABLE_WALLET GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); #else From 5acd49d9e60fb3c786b4a5d2f06353e497ff8a5f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:26:08 +0800 Subject: [PATCH 0750/3904] _= --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index d680e3867..b61ee0f6e 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -356,7 +356,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0); + fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); #ifdef ENABLE_WALLET GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); From a78c87124a1b523b9448f4e80c91c50413588e3b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:34:46 +0800 Subject: [PATCH 0751/3904] fix --- src/miner.cpp | 10 ++-------- src/rpc/mining.cpp | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6dd32564c..388de0ba7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -769,7 +769,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { - if (!isStake) + if (!isStake && ASSETCHAINS_STAKED != 0) { if (!reservekey.GetReservedKey(pubkey)) { @@ -783,13 +783,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } scriptPubKey[34] = OP_CHECKSIG; } - else fprintf(stderr,"IsStake\n"); } - fprintf(stderr,"selected pubkey for new block: "); - for (i=0; i<33; i++) { - fprintf(stderr,"%02x",scriptPubKey[i+1]); - } - fprintf(stderr,"\n"); return CreateNewBlock(scriptPubKey, gpucount, isStake); } @@ -1479,7 +1473,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index b61ee0f6e..368f68921 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -353,6 +353,8 @@ UniValue setgenerate(const UniValue& params, bool fHelp) } else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; + fprintf(stderr, "BEFORE MAP miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); + mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); From 128a02eb9b07b49a19148c4becfd0d00d65708d2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:44:34 +0800 Subject: [PATCH 0752/3904] fix --- src/miner.cpp | 2 +- src/rpc/mining.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 388de0ba7..9e60753a9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -769,7 +769,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { - if (!isStake && ASSETCHAINS_STAKED != 0) + if (!isStake || ASSETCHAINS_STAKED != 0) { if (!reservekey.GetReservedKey(pubkey)) { diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 368f68921..9285a1258 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -344,7 +344,10 @@ UniValue setgenerate(const UniValue& params, bool fHelp) { VERUS_MINTBLOCKS = 1; fGenerate = GetBoolArg("-gen", false); - nGenProcLimit = KOMODO_MININGTHREADS; + if ( ASSETCHAINS_STAKED != 0 ) + nGenProcLimit = KOMODO_MININGTHREADS; + else + KOMODO_MININGTHREADS = nGenProcLimit; } else if (!fGenerate) { @@ -353,8 +356,6 @@ UniValue setgenerate(const UniValue& params, bool fHelp) } else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; - fprintf(stderr, "BEFORE MAP miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); - mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); From 4b45ea8d969f739787e0c13bfaa0dcc7ebae1c45 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:49:25 +0800 Subject: [PATCH 0753/3904] fix --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 9285a1258..8e6b1dfa2 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -344,7 +344,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) { VERUS_MINTBLOCKS = 1; fGenerate = GetBoolArg("-gen", false); - if ( ASSETCHAINS_STAKED != 0 ) + if ( ASSETCHAINS_STAKED == 0 ) nGenProcLimit = KOMODO_MININGTHREADS; else KOMODO_MININGTHREADS = nGenProcLimit; From f8bbd607ea2b5c632311677c0533d07751fa8e0f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 15:46:14 +0800 Subject: [PATCH 0754/3904] fix debug prints --- src/miner.cpp | 5 ----- src/rpc/mining.cpp | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9e60753a9..772980fba 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,11 +154,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if (txT == TX_PUBKEY) pk = CPubKey(vAddrs[0]); } - fprintf(stderr,"selected pubkey inside CreateBlock: "); - for (int i=0; i<33; i++) { - fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); - } - fprintf(stderr,"\n"); uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); //fprintf(stderr,"create new block\n"); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 8e6b1dfa2..52f4afd10 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -359,8 +359,6 @@ UniValue setgenerate(const UniValue& params, bool fHelp) mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); - #ifdef ENABLE_WALLET GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); #else From d33edb4ff3dbecc1235d5d2079695cc9a171a601 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:05:36 +0800 Subject: [PATCH 0755/3904] change DNS seeds to exit only if staked chain --- src/net.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index c33f82627..34aebfc1a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1259,11 +1259,14 @@ void ThreadSocketHandler() } } } - +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN] +extern int8_t is_STAKED(const char *chain_name) void ThreadDNSAddressSeed() { - return; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From 38d065a44236526ae42b7e7704a915bb5a336614 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:09:28 +0800 Subject: [PATCH 0756/3904] fix --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 34aebfc1a..3e7c71242 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,7 +1260,7 @@ void ThreadSocketHandler() } } extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN] -extern int8_t is_STAKED(const char *chain_name) +int8_t is_STAKED(const char *chain_name) void ThreadDNSAddressSeed() { From 1c6795117148754adde41acf6f5cc2024b19268f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:10:15 +0800 Subject: [PATCH 0757/3904] real fix --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 3e7c71242..f305bd733 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1259,8 +1259,8 @@ void ThreadSocketHandler() } } } -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN] -int8_t is_STAKED(const char *chain_name) +extern char ASSETCHAINS_SYMBOL; +extern int8_t is_STAKED(const char *chain_name) void ThreadDNSAddressSeed() { From 04e51c373ca27f990c5b9f9121081ebe15ff6e2a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:11:01 +0800 Subject: [PATCH 0758/3904] now its fixed --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index f305bd733..8655e05cb 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,7 +1260,7 @@ void ThreadSocketHandler() } } extern char ASSETCHAINS_SYMBOL; -extern int8_t is_STAKED(const char *chain_name) +extern int8_t is_STAKED(const char *chain_name); void ThreadDNSAddressSeed() { From 98b374cdd6136e402dea45d41997e9465f941f4d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:15:00 +0800 Subject: [PATCH 0759/3904] try this --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 8655e05cb..d7d81558a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -17,6 +17,7 @@ #include "scheduler.h" #include "ui_interface.h" #include "crypto/common.h" +#include "notaries_staked.h" #ifdef _WIN32 #include @@ -1260,7 +1261,6 @@ void ThreadSocketHandler() } } extern char ASSETCHAINS_SYMBOL; -extern int8_t is_STAKED(const char *chain_name); void ThreadDNSAddressSeed() { From 01861c777f84449ec50080ce769e10a8f11a3393 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:16:20 +0800 Subject: [PATCH 0760/3904] wtf --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index d7d81558a..25e2fed9f 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1265,7 +1265,7 @@ extern char ASSETCHAINS_SYMBOL; void ThreadDNSAddressSeed() { // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED((const char*)ASSETCHAINS_SYMBOL) != 0 ) return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && From d5ce03972a25da4ae831e8708514ab5479123ae5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:17:16 +0800 Subject: [PATCH 0761/3904] y --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 25e2fed9f..2d9daf380 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,12 +1260,12 @@ void ThreadSocketHandler() } } } -extern char ASSETCHAINS_SYMBOL; +//extern char ASSETCHAINS_SYMBOL[]; void ThreadDNSAddressSeed() { // skip DNS seeds for staked chains. - if ( is_STAKED((const char*)ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && From 0ccd6d40be1e22f8e2dfd959fcb8381672f12f39 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:22:31 +0800 Subject: [PATCH 0762/3904] try --- src/net.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 2d9daf380..f7e86bd34 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,7 +1260,6 @@ void ThreadSocketHandler() } } } -//extern char ASSETCHAINS_SYMBOL[]; void ThreadDNSAddressSeed() { From 7e85c39a79738fbca409fd1c7caaba222833ad08 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:54:07 +0800 Subject: [PATCH 0763/3904] the is better, should be able to add own seeds if this works --- src/chainparams.cpp | 13 +++++++++++-- src/net.cpp | 4 ---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a04e4131a..1885088ac 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -6,6 +6,7 @@ #include "key_io.h" #include "main.h" #include "crypto/equihash.h" +#include "notaries_staked.h" #include "util.h" #include "utilstrencodings.h" @@ -201,6 +202,14 @@ public: fMineBlocksOnDemand = false; fTestnetToBeDeprecatedFieldRPC = false; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n", ); + vFixedSeeds.clear(); + vSeeds.clear(); + } + if ( pthread_create((pthread_t *)malloc(sizeof(pthread_t)),NULL,chainparams_commandline,(void *)&consensus) != 0 ) { @@ -257,7 +266,7 @@ void *chainparams_commandline(void *ptr) if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: - // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing + // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing mainParams.consensus.nLwmaAjustedWeight = 1350; mainParams.consensus.nPowAveragingWindow = 45; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); @@ -632,7 +641,7 @@ public: BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); nEquihashN = N; nEquihashK = K; - + genesis = CreateGenesisBlock( 1296688602, uint256S("0x0000000000000000000000000000000000000000000000000000000000000009"), diff --git a/src/net.cpp b/src/net.cpp index f7e86bd34..b36723b28 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -17,7 +17,6 @@ #include "scheduler.h" #include "ui_interface.h" #include "crypto/common.h" -#include "notaries_staked.h" #ifdef _WIN32 #include @@ -1263,9 +1262,6 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From c09d9ceefdb89212e83e42a2c3515006e9298279 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:55:15 +0800 Subject: [PATCH 0764/3904] fix --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1885088ac..1bc848c6d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -205,7 +205,7 @@ public: // skip DNS seeds for staked chains. if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n", ); + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); vFixedSeeds.clear(); vSeeds.clear(); } From 96ea4486a76f1c9a5aca4a36894edb388c990660 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:56:47 +0800 Subject: [PATCH 0765/3904] try --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1bc848c6d..b4a383456 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -6,7 +6,6 @@ #include "key_io.h" #include "main.h" #include "crypto/equihash.h" -#include "notaries_staked.h" #include "util.h" #include "utilstrencodings.h" @@ -77,6 +76,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st */ void *chainparams_commandline(void *ptr); #include "komodo_defs.h" +#include "notaries_staked.h" extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; From ade96c9e6520682d4fbe94a567b885bd099578f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:58:50 +0800 Subject: [PATCH 0766/3904] try --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index b4a383456..ff2cbc48e 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -76,7 +76,6 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st */ void *chainparams_commandline(void *ptr); #include "komodo_defs.h" -#include "notaries_staked.h" extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; @@ -84,6 +83,7 @@ extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; +int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { From e6515a9f87ca02b511670e6e1b1cfc4a696b0c4c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:03:00 +0800 Subject: [PATCH 0767/3904] sloppy --- src/chainparams.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index ff2cbc48e..7f7eb8820 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -83,7 +83,6 @@ extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; -int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { @@ -203,7 +202,14 @@ public: fTestnetToBeDeprecatedFieldRPC = false; // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + int8_t STAKED = 0; + if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) + STAKED = 1; + else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) + STAKED = 2; + else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + STAKED = 3; + if ( STAKED != 0 ) { fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); vFixedSeeds.clear(); From 2a0cb852a55fa8633cafc32edab1315fffb4a40a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:07:00 +0800 Subject: [PATCH 0768/3904] fix --- src/chainparams.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7f7eb8820..eb3b5f514 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -203,11 +203,11 @@ public: // skip DNS seeds for staked chains. int8_t STAKED = 0; - if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) + if ( (strcmp(ASSETCHAINS_SYMBOL, "LABS") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LABS", 4) == 0) ) STAKED = 1; - else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) + else if ( (strcmp(ASSETCHAINS_SYMBOL, "LAB") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LAB", 3) == 0) ) STAKED = 2; - else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + else if ( (strcmp(ASSETCHAINS_SYMBOL, "CFEK") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "CFEK", 4) == 0) ) STAKED = 3; if ( STAKED != 0 ) { From e108119312c4dc771477fadac8c6c266d0a7a64f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:15:06 +0800 Subject: [PATCH 0769/3904] better again? --- src/chainparams.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index eb3b5f514..cd6635552 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -83,6 +83,7 @@ extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; +extern int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { @@ -201,21 +202,6 @@ public: fMineBlocksOnDemand = false; fTestnetToBeDeprecatedFieldRPC = false; - // skip DNS seeds for staked chains. - int8_t STAKED = 0; - if ( (strcmp(ASSETCHAINS_SYMBOL, "LABS") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LABS", 4) == 0) ) - STAKED = 1; - else if ( (strcmp(ASSETCHAINS_SYMBOL, "LAB") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LAB", 3) == 0) ) - STAKED = 2; - else if ( (strcmp(ASSETCHAINS_SYMBOL, "CFEK") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "CFEK", 4) == 0) ) - STAKED = 3; - if ( STAKED != 0 ) - { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - vFixedSeeds.clear(); - vSeeds.clear(); - } - if ( pthread_create((pthread_t *)malloc(sizeof(pthread_t)),NULL,chainparams_commandline,(void *)&consensus) != 0 ) { @@ -267,6 +253,13 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); + mainParams.vFixedSeeds.clear(); + mainParams.vSeeds.clear(); + } fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) From d4c29970c53dbb3810966ce51606c7383c52207e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:26:25 +0800 Subject: [PATCH 0770/3904] fix? --- src/chainparams.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chainparams.h b/src/chainparams.h index 566f07f36..fb0af946a 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -111,6 +111,8 @@ public: //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); }; CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved Consensus::Params consensus; + std::vector vFixedSeeds; + std::vector vSeeds; protected: CChainParams() {} @@ -123,14 +125,12 @@ protected: uint64_t nPruneAfterHeight = 0; unsigned int nEquihashN = 0; unsigned int nEquihashK = 0; - std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; std::string bech32HRPs[MAX_BECH32_TYPES]; std::string strNetworkID; std::string strCurrencyUnits; uint32_t bip44CoinType; CBlock genesis; - std::vector vFixedSeeds; bool fMiningRequiresPeers = false; bool fDefaultConsistencyChecks = false; bool fRequireStandard = false; From 1e487493a6ac9b839deb95000f9ea879046d73a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:37:54 +0800 Subject: [PATCH 0771/3904] try --- src/chainparams.cpp | 6 ++++++ src/chainparams.h | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index cd6635552..9cf7fcf97 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -216,6 +216,12 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat CChainParams::checkpointData = checkpointData; } +void ClearSeeds() +{ + vSeeds.clear(); + vFixedSeeds.clear(); +} + int32_t MAX_BLOCK_SIZE(int32_t height) { //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); diff --git a/src/chainparams.h b/src/chainparams.h index fb0af946a..6637f9ac1 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -104,6 +104,7 @@ public: void SetDefaultPort(uint16_t port) { nDefaultPort = port; } void SetCheckpointData(CCheckpointData checkpointData); + void ClearSeeds(); //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); } //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; } @@ -111,8 +112,6 @@ public: //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); }; CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved Consensus::Params consensus; - std::vector vFixedSeeds; - std::vector vSeeds; protected: CChainParams() {} @@ -125,12 +124,14 @@ protected: uint64_t nPruneAfterHeight = 0; unsigned int nEquihashN = 0; unsigned int nEquihashK = 0; + std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; std::string bech32HRPs[MAX_BECH32_TYPES]; std::string strNetworkID; std::string strCurrencyUnits; uint32_t bip44CoinType; CBlock genesis; + std::vector vFixedSeeds; bool fMiningRequiresPeers = false; bool fDefaultConsistencyChecks = false; bool fRequireStandard = false; From 73afad81775d112c00f12fa4db3d3a50fbf8de1a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:42:37 +0800 Subject: [PATCH 0772/3904] fool errand --- src/chainparams.cpp | 13 ------------- src/chainparams.h | 1 - src/net.cpp | 9 +++++++++ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9cf7fcf97..452e232a6 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -216,12 +216,6 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat CChainParams::checkpointData = checkpointData; } -void ClearSeeds() -{ - vSeeds.clear(); - vFixedSeeds.clear(); -} - int32_t MAX_BLOCK_SIZE(int32_t height) { //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); @@ -259,13 +253,6 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - mainParams.vFixedSeeds.clear(); - mainParams.vSeeds.clear(); - } fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) diff --git a/src/chainparams.h b/src/chainparams.h index 6637f9ac1..566f07f36 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -104,7 +104,6 @@ public: void SetDefaultPort(uint16_t port) { nDefaultPort = port; } void SetCheckpointData(CCheckpointData checkpointData); - void ClearSeeds(); //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); } //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; } diff --git a/src/net.cpp b/src/net.cpp index b36723b28..a456830a4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1262,6 +1262,15 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { + extern int8_t is_STAKED(const char *chain_name); + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); + mainParams.vFixedSeeds.clear(); + mainParams.vSeeds.clear(); + } + // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From 7f19010a7be811968ec44acaba09057e57d51736 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:44:27 +0800 Subject: [PATCH 0773/3904] try --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index a456830a4..db1794699 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1263,12 +1263,12 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { extern int8_t is_STAKED(const char *chain_name); + extern char ASSETCHAINS_SYMBOL[65]; // skip DNS seeds for staked chains. if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - mainParams.vFixedSeeds.clear(); - mainParams.vSeeds.clear(); + return; } // goal: only query DNS seeds if address need is acute From 29cefb7ef161aa9b4d8c42f790156e34150047cd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:53:05 +0800 Subject: [PATCH 0774/3904] FIXED? --- src/net.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index db1794699..e78f1846c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1380,13 +1380,19 @@ void ThreadOpenConnections() // Add seed nodes if DNS seeds are all down (an infrastructure attack?). // if (addrman.size() == 0 && (GetTime() - nStart > 60)) { - if (GetTime() - nStart > 60) { - static bool done = false; - if (!done) { - //LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); - LogPrintf("Adding fixed seed nodes.\n"); - addrman.Add(convertSeed6(Params().FixedSeeds()), CNetAddr("127.0.0.1")); - done = true; + extern int8_t is_STAKED(const char *chain_name); + extern char ASSETCHAINS_SYMBOL[65]; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 ) + { + if (GetTime() - nStart > 60) { + static bool done = false; + if (!done) { + //LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); + LogPrintf("Adding fixed seed nodes.\n"); + addrman.Add(convertSeed6(Params().FixedSeeds()), CNetAddr("127.0.0.1")); + done = true; + } } } From ce88a314868dd1f341a354a80605449c61c19798 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:16:11 +0800 Subject: [PATCH 0775/3904] ipv6 unreachable no print --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 7369b0167..84e84f6ca 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -498,7 +498,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe CloseSocket(hSocket); return false; } - if (nRet != 0) + if (nRet != 0 && nRet != 101) { LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); From 04c758ba8bbbe4ed55235e337edd42a044dd8e5c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:23:48 +0800 Subject: [PATCH 0776/3904] fix --- src/netbase.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 84e84f6ca..cb443e5ea 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -498,9 +498,10 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe CloseSocket(hSocket); return false; } - if (nRet != 0 && nRet != 101) + if (nRet != 0) { - LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); + if ( nRet != 101) + LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); return false; } From a02f7be2539eeb6624abf369e8a1a72e54e17402 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:29:06 +0800 Subject: [PATCH 0777/3904] fix --- src/netbase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index cb443e5ea..e9aea7965 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -500,8 +500,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe } if (nRet != 0) { - if ( nRet != 101) - LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); + LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); return false; } @@ -512,7 +511,8 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); + if ( nRet != 101) + LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } From 135ad0456cb4cccc87f3b7a9dac1e08343dc0443 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:30:47 +0800 Subject: [PATCH 0778/3904] try --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index e9aea7965..a8d279ad7 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,7 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - if ( nRet != 101) + if ( NetworkErrorString(WSAGetLastError() != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; From c9b2ab288a31ac294b97076b6cd400475c9706cd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:31:29 +0800 Subject: [PATCH 0779/3904] fix --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index a8d279ad7..28adce0e2 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,7 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - if ( NetworkErrorString(WSAGetLastError() != "101") + if ( NetworkErrorString(WSAGetLastError()) != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; From c144c7d68bfc1ddc3c38d526f4a865ba3b207646 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:50:54 +0800 Subject: [PATCH 0780/3904] wtf --- src/netbase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/netbase.cpp b/src/netbase.cpp index 28adce0e2..9838c4528 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,6 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { + fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError())); if ( NetworkErrorString(WSAGetLastError()) != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); From b1d5f3efc7a7f05767aa40bbe149c540f7afb986 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:52:23 +0800 Subject: [PATCH 0781/3904] fix --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 9838c4528..167cd8f95 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,7 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError())); + fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError()).c_str()); if ( NetworkErrorString(WSAGetLastError()) != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); From 04285b4b257648f89e81829426aca4e706702e24 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:54:08 +0800 Subject: [PATCH 0782/3904] finally works? --- src/netbase.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 167cd8f95..baae83e4a 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,8 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError()).c_str()); - if ( NetworkErrorString(WSAGetLastError()) != "101") + if ( NetworkErrorString(WSAGetLastError()) != "Network is unreachable (101)") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; From b76ca3dc43dce40ca09b462803cb558f2c2e7249 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 7 Dec 2018 00:38:13 +0800 Subject: [PATCH 0783/3904] Try wallet fix here --- src/main.cpp | 24 ++++++++++++++++++++++-- src/wallet/walletdb.cpp | 9 ++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7668f7f87..912ab7cf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3835,15 +3835,16 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), newSaplingTree)); // Let wallets know transactions went from 1-confirmed to // 0-confirmed or conflicted: + std::vector TxToRemove; for (int i = 0; i < block.vtx.size(); i++) { CTransaction &tx = block.vtx[i]; //if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))) if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { - //EraseFromWallets(tx.GetHash()); #ifdef ENABLE_WALLET - pwalletMain->EraseFromWallet(tx.GetHash()); + TxToRemove.push_back(tx.GetHash()); + //pwalletMain->EraseFromWallet(tx.GetHash()); #endif } else @@ -3851,6 +3852,25 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { SyncWithWallets(tx, NULL); } } + if ( ASSETCHAINS_STAKED != 0 ) // If Staked chain, scan wallet for orphaned txs and delete them. + { + LOCK2(cs_main, pwalletMain->cs_wallet); + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction((*it).first,tx,hashBlock,true)) + { + fprintf(stderr, "TX Does Not Exist: %s\n",(*it).first.ToString().c_str()); + TxToRemove.push_back((*it).first); + } + } + BOOST_FOREACH (uint256& hash, TxToRemove) + { + pwalletMain->EraseFromWallet(hash); + fprintf(stderr, "Erased %s from wallet.\n",hash.ToString().c_str()); + } + } // Update cached incremental witnesses GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false); return true; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 41c0de4b2..52c815ce2 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -867,6 +867,8 @@ static bool IsKeyType(string strType) strType == "mkey" || strType == "ckey"); } +extern uint64_t ASSETCHAINS_STAKED; + DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { pwallet->vchDefaultKey = CPubKey(); @@ -918,8 +920,9 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. - if (strType == "tx") - // Rescan if there is a bad transaction record: + if (strType == "tx" && ASSETCHAINS_STAKED == 0 ) + // Rescan if there is a bad transaction record.. + // But dont on staked chains! SoftSetBoolArg("-rescan", true); } } @@ -967,7 +970,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if (wss.fAnyUnordered) result = ReorderTransactions(pwallet); - + return result; } From dd6b254fd46edfe9a73cda32b291179d8292f04a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 7 Dec 2018 00:52:38 +0800 Subject: [PATCH 0784/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c4204f8a0..fe1ead8ad 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5294,7 +5294,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { - fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + //fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; From 25406293e54ad4a1ef25890494aedafab40cffc9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 7 Dec 2018 01:34:15 +0800 Subject: [PATCH 0785/3904] add ac_period to --- src/komodo_utils.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2533f4860..67a080556 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1771,8 +1771,8 @@ void komodo_args(char *argv0) ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); - ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); + ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); + ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1874,7 +1874,11 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } From d13edd721e72e691f4679a7f21a767a93df3ba0c Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 8 Dec 2018 19:15:48 +0100 Subject: [PATCH 0786/3904] add changelog 0.3.0 --- doc/release-notes/release-notes-0.3.0.md | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 doc/release-notes/release-notes-0.3.0.md diff --git a/doc/release-notes/release-notes-0.3.0.md b/doc/release-notes/release-notes-0.3.0.md new file mode 100644 index 000000000..84ffc8efb --- /dev/null +++ b/doc/release-notes/release-notes-0.3.0.md @@ -0,0 +1,58 @@ + +Komodo specific changelog: + +- add CC functionality and bugfixes +- set sapling activation +- change z-addr prefix byte +- blocksize increased from 2MB to 4 MB +- transaction size increased from 100KB to 200KB + +Sapling related changelog: + +- Decoupled Spend Authority +- Improved Performance for Shielded Transactions (using sapling instead of sprout) +- transaction format changed + +Alex Morcos (1): Output line to debug.log when IsInitialBlockDownload latches to false + +Ariel Gabizon (1): Extend Joinsplit tests to Groth + +Charlie OKeefe (1): Remove extra slash from lockfile path + +Cory Fields (1): crypter: shuffle Makefile so that crypto can be used by the wallet + +Daira Hopwood (1): Support testnet rollback. + +Daniel Cousens (2): move rpc* to rpc/ rpc: update inline comments to refer to new file paths + +Dimitris Apostolou (1): Fix typos + +Duke Leto (3): Fix absurd fee bug reported in #3281, with tests Update comment as per @arielgabizon Improve error message + +Eirik Ogilvie-Wigley (24): Add more options when asserting in RPC tests Add change indicator for notes Fix test broken by change indicator Rename note data to include sprout Remove redundant curly braces Consolidate for loops Add out point for sapling note data Add sapling note data and map Decrement sapling note witnesses Clear sapling witness cache Extract method for copying previous witnesses Extract methods for incrementing witnesses Extract method for incrementing witness heights Pass sapling merkle tree when incrementing witnesses Increment sapling note witnesses Rename sprout specific methods Remove extra indentation Add getter and setter for sapling note data and update tests Add parameter for version in GetValidReceive Rename Merkle Trees to include sprout or sapling Rename Witnesses to include sprout or sapling Rename test objects to include sprout or sapling Only include the change field if we have a spending key Fix assertion and comment + +Gregory Maxwell (2): IBD check uses minimumchain work instead of checkpoints. IsInitialBlockDownload no longer uses header-only timestamps. + +Jack Grigg (41): Add some more checkpoints, up to the 1.1.0 release Add Sapling support to z_validateaddress Update payment-api.md with type field of z_validateaddress Alter SaplingNote::nullifier() to take a SaplingFullViewingKey Expose note position in IncrementalMerkleWitness TransactionBuilder with support for creating Sapling-only transactions TransactionBuilder: Check that all anchors in a transaction are identical Formatting test: Move ECC_Start() call into src/gtest/main.cpp TransactionBuilder: Add support for transparent inputs and outputs TransactionBuilder: Add change output to transaction TransactionBuilder: Make fee configurable Rename xsk to expsk Implement CKeyStore::GetSaplingPaymentAddresses() Raise the 90-character limit on Bech32 encodings Add Sapling support to z_getnewaddress and z_listaddresses Fix block hash for checkpoint at height 270000 Formatting test: Deduplicate logic in wallet_addresses RPC test test: Another assert in wallet_zkeys_tests.store_and_load_sapling_zkeys test: Fix permissions of wallet_addresses test: Update rpc_wallet_z_importexport to account for Sapling changes Rename DecryptSpendingKey -> DecryptSproutSpendingKey Rename CryptedSpendingKeyMap -> CryptedSproutSpendingKeyMap Add Sapling decryption check to CCryptoKeyStore::Unlock() Check for unencrypted Sapling keys in CCryptoKeyStore::SetCrypted() Remove outdated comment Add CWallet::AddCryptedSaplingSpendingKey() hook Pass SaplingPaymentAddress to store through the CKeyStore Rename SpendingKeyMap -> SproutSpendingKeyMap Rename SerializedSize -> SerializedSproutSize Rename ViewingKey -> SproutViewingKey Formatting nits Rename *SpendingKey -> *SproutSpendingKey chainparams: Add BIP 44 coin type (as registered in SLIP 44) Upgrade Rust to 1.28.0 stable Adjust Makefile so that common can be used by the wallet Move RewindBlockIndex log message inside rewindLength check test: gtest for Sapling encoding and decoding test: Use regtest in key_tests/zs_address_test Disable Sapling features on mainnet + +Jay Graber (13): Add Sapling Add/Have/Get to keystore Add SaplingIncomingViewingKeys map, SaplingFullViewingKey methods Add StoreAndRetrieveSaplingSpendingKey test Change default_address to return SaplingPaymentAddr and not boost::optional Add crypted keystore sapling add key Discard sk if ivk == 0 Add Sapling support to z_exportkey Add Sapling support to z_importkey Add Sapling to rpc_wallet_z_importexport test Refactor into visitors and throw errors for invalid key or address. Take expiryheight as param to createrawtransaction Add Sapling have/get sk crypter overrides Add Sapling keys to CCryptoKeyStore::EncryptKeys + +Jonas Schnelli (2): [RPC, Wallet] Move RPC dispatch table registration to wallet/ code Fix test_bitcoin circular dependency issue + +Kaz Wesley (1): IsInitialBlockDownload: usually avoid locking + +Larry Ruane (4): Disable libsnark debug logging in Boost tests add extra help how to enable experimental features Add call to sync_all() after (z_sendmany, wait) don't ban peers when loading pre-overwinter blocks + +Pejvan (2): Update README.md Update README.md + +Richard Littauer (1): docs(LICENSE): update license year to 2018 + +Sean Bowe (21): Update librustzcash Implementation of Sapling in-band secret distribution. Swap types in OutputDescription to use new NoteEncryption interfaces. Prevent nonce reuse in Sapling note encryption API. Add get_esk() function to Sapling note encryption. Minor edits Decryption and tests of note/outgoing encryption. Update librustzcash and sapling-crypto. Fix bug in return value. Ensure sum of valueBalance and all vpub_new's does not exceed MAX_MONEY inside of CheckTransactionWithoutProofVerification. Move extern params to beginning of test_checktransaction. Relocate ECC_Start() to avoid test failures. Don't call ECC_Start/ECC_Stop outside the test harness. Make changes to gtest ECC behavior suggested by @str4d. Check the hash of the (Sapling+) zk-SNARK parameters during initialization. Switch to use the official Sapling parameters. make-release.py: Versioning changes for 2.0.0-rc1. make-release.py: Updated manpages for 2.0.0-rc1. make-release.py: Updated release notes and changelog for 2.0.0-rc1. Always write the empty root down as the best root, since we may roll back. Sapling mainnet activation height + +Simon Liu (11): Add encryption of SaplingNotePlaintext and SaplingOutgoingPlaintext classes. Update and fix per review comments, the test for absurd fee. Minor update to address nits in review. Implement Sapling note decryption using full viewing key. Rename AttemptSaplingEncDecryptionUsingFullViewingKey and use function overloading. Only check for a valid Sapling anchor after Sapling activation. Clean up for rebase: rename mapNoteData to mapSproutNoteData. Clean up help messages for RPC createrawtransaction. Add tests for expiryheight parameter of RPC createrawtransaction. make-release.py: Versioning changes for 2.0.0. make-release.py: Updated manpages for 2.0.0. + +Wladimir J. van der Laan (2): Make max tip age an option instead of chainparam rpc: Register calls where they are defined + +kozyilmaz (1): Add -Wl,-pie linker option for macOS and use it instead of -pie + +mdr0id (1): Fix minor references to auto-senescence in code From 6d3a761da6552656aa68693363976271a9f69c01 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Dec 2018 17:57:28 +0800 Subject: [PATCH 0787/3904] is this fixed? --- src/komodo_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 67a080556..37b411ead 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1874,11 +1874,11 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - } + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } From 6b2d9e254ce9730950c04c415688ec8b0da3568a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 07:27:15 +0800 Subject: [PATCH 0788/3904] remove, cleanwallettransactions --- src/rpc/server.cpp | 12 ++-- src/rpc/server.h | 2 +- src/wallet/rpcwallet.cpp | 133 +++++---------------------------------- 3 files changed, 23 insertions(+), 124 deletions(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index b232e4802..99bc21f0d 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -364,16 +364,16 @@ static const CRPCCommand vRPCCommands[] = // auction { "auction", "auctionaddress", &auctionaddress, true }, - + // lotto { "lotto", "lottoaddress", &lottoaddress, true }, - + // fsm { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + // rewards { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -382,7 +382,7 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + // faucet { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, @@ -399,7 +399,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + // Oracles { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -508,7 +508,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, + { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 410c2e915..434df0a87 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -317,7 +317,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); + extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3143f9d08..e41c76ef6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1016,108 +1016,7 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } -UniValue cleanwallettransactions(const UniValue& params, bool fHelp) -{ - if (!EnsureWalletIsAvailable(fHelp)) - return NullUniValue; - if (fHelp || params.size() > 1 ) - throw runtime_error( - "cleanwallettransactions \"txid\"\n" - "\nRemove all txs that are spent. You can clear all txs bar one, by specifiying a txid.\n" - "\nPlease backup your wallet.dat before running this command.\n" - "\nArguments:\n" - "1. \"txid\" (string, optional) The transaction id to keep.\n" - "\nResult:\n" - "{\n" - " \"total_transactons\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n" - " \"remaining_transactons\" : n, (numeric) Transactions in wallet after clean.\n" - " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("cleanwallettransactions", "") - + HelpExampleCli("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") - + HelpExampleRpc("cleanwallettransactions", "") - + HelpExampleRpc("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") - ); - - LOCK2(cs_main, pwalletMain->cs_wallet); - UniValue ret(UniValue::VOBJ); - uint256 exception; int32_t txs = pwalletMain->mapWallet.size(); - std::vector TxToRemove; - if (params.size() == 1) - { - exception.SetHex(params[0].get_str()); - uint256 tmp_hash; CTransaction tmp_tx; - if (GetTransaction(exception,tmp_tx,tmp_hash,false)) - { - if ( !pwalletMain->IsMine(tmp_tx) ) - { - throw runtime_error("\nThe transaction is not yours!\n"); - } - else - { - for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - if ( wtx.GetHash() != exception ) - { - TxToRemove.push_back(wtx.GetHash()); - } - } - } - } - else - { - throw runtime_error("\nThe transaction could not be found!\n"); - } - } - else - { - // get all locked utxos to relock them later. - vector vLockedUTXO; - pwalletMain->ListLockedCoins(vLockedUTXO); - // unlock all coins so that the following call containes all utxos. - pwalletMain->UnlockAllCoins(); - // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, - vector vecOutputs; - assert(pwalletMain != NULL); - pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - int32_t oldestTxDepth = 0; - BOOST_FOREACH(const COutput& out, vecOutputs) - { - if ( out.nDepth > oldestTxDepth ) - oldestTxDepth = out.nDepth; - } - oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. - // lock all the previouly locked coins. - BOOST_FOREACH(COutPoint &outpt, vLockedUTXO) { - pwalletMain->LockCoin(outpt); - } - - // then add all txs in the wallet before this block to the list to remove. - for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - if (wtx.GetDepthInMainChain() > oldestTxDepth) - TxToRemove.push_back(wtx.GetHash()); - } - } - - // erase txs - BOOST_FOREACH (uint256& hash, TxToRemove) - { - pwalletMain->EraseFromWallet(hash); - LogPrintf("Erased %s from wallet.\n",hash.ToString().c_str()); - } - - // build return JSON for stats. - int remaining = pwalletMain->mapWallet.size(); - ret.push_back(Pair("total_transactons", (int)txs)); - ret.push_back(Pair("remaining_transactons", (int)remaining)); - ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); - return (ret); -} UniValue getbalance(const UniValue& params, bool fHelp) { @@ -1776,7 +1675,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY)) entry.push_back(Pair("involvesWatchonly", true)); entry.push_back(Pair("account", account)); - + CTxDestination dest; if (CScriptExt::ExtractVoutDestination(wtx, r.vout, dest)) MaybePushAddress(entry, dest); @@ -3017,11 +2916,11 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) // User did not provide zaddrs, so use default i.e. all addresses std::set sproutzaddrs = {}; pwalletMain->GetSproutPaymentAddresses(sproutzaddrs); - + // Sapling support std::set saplingzaddrs = {}; pwalletMain->GetSaplingPaymentAddresses(saplingzaddrs); - + zaddrs.insert(sproutzaddrs.begin(), sproutzaddrs.end()); zaddrs.insert(saplingzaddrs.begin(), saplingzaddrs.end()); } @@ -3033,7 +2932,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) std::vector saplingEntries; pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs, nMinDepth, nMaxDepth, true, !fIncludeWatchonly, false); std::set> nullifierSet = pwalletMain->GetNullifiersForAddresses(zaddrs); - + for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", entry.jsop.hash.ToString())); @@ -3051,7 +2950,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) } results.push_back(obj); } - + for (auto & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", entry.op.hash.ToString())); @@ -6083,7 +5982,7 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp) if ( params.size() < 6+i+1 ) throw runtime_error("not enough parameters for N pubkeys\n"); pubkey = ParseHex(params[6+i].get_str().c_str()); - if (pubkey.size()!= 33) + if (pubkey.size()!= 33) throw runtime_error("invalid destination pubkey"); pubkeys.push_back(pubkey2pk(pubkey)); } @@ -6117,8 +6016,8 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp) amount = atof((char *)params[8].get_str().c_str()) * COIN + 0.00000000499999; if ( amount <= 0 || claimvout < 0 ) throw runtime_error("invalid param: amount, numpks or claimvout\n"); - if (destpub.size()!= 33) - throw runtime_error("invalid destination pubkey"); + if (destpub.size()!= 33) + throw runtime_error("invalid destination pubkey"); hex = GatewaysDeposit(0,bindtxid,height,coin,cointxid,claimvout,deposithex,proof,pubkey2pk(destpub),amount); RETURN_IF_ERROR(CCerror); @@ -6143,9 +6042,9 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp) coin = params[1].get_str(); deposittxid = Parseuint256((char *)params[2].get_str().c_str()); destpub = ParseHex(params[3].get_str()); - amount = atof((char *)params[4].get_str().c_str()) * COIN + 0.00000000499999; - if (destpub.size()!= 33) - throw runtime_error("invalid destination pubkey"); + amount = atof((char *)params[4].get_str().c_str()) * COIN + 0.00000000499999; + if (destpub.size()!= 33) + throw runtime_error("invalid destination pubkey"); hex = GatewaysClaim(0,bindtxid,coin,deposittxid,pubkey2pk(destpub),amount); RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) @@ -6168,9 +6067,9 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); withdrawpub = ParseHex(params[2].get_str()); - amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999; - if (withdrawpub.size()!= 33) - throw runtime_error("invalid destination pubkey"); + amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999; + if (withdrawpub.size()!= 33) + throw runtime_error("invalid destination pubkey"); hex = GatewaysWithdraw(0,bindtxid,coin,pubkey2pk(withdrawpub),amount); RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) @@ -6189,7 +6088,7 @@ UniValue gatewayspartialsign(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); parthex = params[2].get_str(); @@ -6234,7 +6133,7 @@ UniValue gatewaysmarkdone(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); completetxid = Parseuint256((char *)params[0].get_str().c_str()); - coin = params[1].get_str(); + coin = params[1].get_str(); hex = GatewaysMarkDone(0,completetxid,coin); RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) From 9452d0d77d1c69a30a37b8a6a2998b206fb94625 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 07:27:55 +0800 Subject: [PATCH 0789/3904] Add cleanwallettransactions RPC --- src/rpc/server.cpp | 2 +- src/rpc/server.h | 2 +- src/wallet/rpcwallet.cpp | 101 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 2 deletions(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 99bc21f0d..938556f0f 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -508,7 +508,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - + { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 434df0a87..410c2e915 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -317,7 +317,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); - +extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e41c76ef6..742c21b1b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1016,7 +1016,108 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } +UniValue cleanwallettransactions(const UniValue& params, bool fHelp) +{ + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + if (fHelp || params.size() > 1 ) + throw runtime_error( + "cleanwallettransactions \"txid\"\n" + "\nRemove all txs that are spent. You can clear all txs bar one, by specifiying a txid.\n" + "\nPlease backup your wallet.dat before running this command.\n" + "\nArguments:\n" + "1. \"txid\" (string, optional) The transaction id to keep.\n" + "\nResult:\n" + "{\n" + " \"total_transactons\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n" + " \"remaining_transactons\" : n, (numeric) Transactions in wallet after clean.\n" + " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("cleanwallettransactions", "") + + HelpExampleCli("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("cleanwallettransactions", "") + + HelpExampleRpc("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + UniValue ret(UniValue::VOBJ); + uint256 exception; int32_t txs = pwalletMain->mapWallet.size(); + std::vector TxToRemove; + if (params.size() == 1) + { + exception.SetHex(params[0].get_str()); + uint256 tmp_hash; CTransaction tmp_tx; + if (GetTransaction(exception,tmp_tx,tmp_hash,false)) + { + if ( !pwalletMain->IsMine(tmp_tx) ) + { + throw runtime_error("\nThe transaction is not yours!\n"); + } + else + { + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if ( wtx.GetHash() != exception ) + { + TxToRemove.push_back(wtx.GetHash()); + } + } + } + } + else + { + throw runtime_error("\nThe transaction could not be found!\n"); + } + } + else + { + // get all locked utxos to relock them later. + vector vLockedUTXO; + pwalletMain->ListLockedCoins(vLockedUTXO); + // unlock all coins so that the following call containes all utxos. + pwalletMain->UnlockAllCoins(); + // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, + vector vecOutputs; + assert(pwalletMain != NULL); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + int32_t oldestTxDepth = 0; + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( out.nDepth > oldestTxDepth ) + oldestTxDepth = out.nDepth; + } + oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + // lock all the previouly locked coins. + BOOST_FOREACH(COutPoint &outpt, vLockedUTXO) { + pwalletMain->LockCoin(outpt); + } + + // then add all txs in the wallet before this block to the list to remove. + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (wtx.GetDepthInMainChain() > oldestTxDepth) + TxToRemove.push_back(wtx.GetHash()); + } + } + + // erase txs + BOOST_FOREACH (uint256& hash, TxToRemove) + { + pwalletMain->EraseFromWallet(hash); + LogPrintf("Erased %s from wallet.\n",hash.ToString().c_str()); + } + + // build return JSON for stats. + int remaining = pwalletMain->mapWallet.size(); + ret.push_back(Pair("total_transactons", (int)txs)); + ret.push_back(Pair("remaining_transactons", (int)remaining)); + ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); + return (ret); +} UniValue getbalance(const UniValue& params, bool fHelp) { From 0a1874835c2b65e84e2d30b898009d1cba615c67 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 08:31:15 +0800 Subject: [PATCH 0790/3904] fix silly code --- src/notaries_staked.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ba9a88343..e53553b23 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -153,10 +153,9 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { { // staked era is set. pthread_mutex_lock(&staked_mutex); - for (int i = 0; i Date: Tue, 11 Dec 2018 08:57:09 +0800 Subject: [PATCH 0791/3904] attempt simpler to crypto address function --- src/main.cpp | 3 --- src/miner.cpp | 12 ++++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 912ab7cf8..7084ddbb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1597,7 +1597,6 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree) { - extern int32_t KOMODO_ON_DEMAND; { LOCK(mempool.cs); uint256 hash = tx.GetHash(); @@ -1918,8 +1917,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa KOMODO_CONNECTING = -1; // Store transaction in memory - if ( komodo_is_notarytx(tx) == 0 ) - KOMODO_ON_DEMAND++; pool.addUnchecked(hash, entry, !IsInitialBlockDownload()); if (!tx.IsCoinImport()) diff --git a/src/miner.cpp b/src/miner.cpp index 772980fba..484b03a6d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #include "komodo_defs.h" -#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" +//#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" extern CCriticalSection cs_metrics; extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; @@ -272,12 +272,16 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { - // TODO: It will be much faster here to just compare scriptpubkey to the crypto pubkey! - CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; + int numNotaryVins = 0; bool fToCryptoAddress = false; + if ( komodo_is_notarytx(tx) == 1 ) + fToCryptoAddress = true; + + /*CTxDestination ToAddress; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) fToCryptoAddress = true; - } + } */ + BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction From 319308d956e117ad35a0bc924f58d858101b7983 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 08:59:17 +0800 Subject: [PATCH 0792/3904] fix --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index 484b03a6d..39155dc50 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -141,6 +141,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +int32_t komodo_is_notarytx(const CTransaction& tx); CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { From 7c60f8032a05544b2b43182cb2a3d875e5d04596 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 09:59:10 +0800 Subject: [PATCH 0793/3904] clean up. --- src/miner.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 39155dc50..c5cdd6ac2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,6 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #include "komodo_defs.h" -//#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" extern CCriticalSection cs_metrics; extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; @@ -277,12 +276,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if ( komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; - /*CTxDestination ToAddress; - if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { - if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) - fToCryptoAddress = true; - } */ - BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction From bf11ecef123d5398d38746abe7b8d9507d10a575 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:15:17 +0800 Subject: [PATCH 0794/3904] Add segid to getsnapshot --- src/txdb.cpp | 71 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 212eda7a0..0b55f3338 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -45,7 +45,7 @@ static const char DB_LAST_BLOCK = 'l'; CCoinsViewDB::CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / dbName, nCacheSize, fMemory, fWipe) { } -CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe) +CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe) { } @@ -107,7 +107,7 @@ uint256 CCoinsViewDB::GetBestBlock() const { uint256 CCoinsViewDB::GetBestAnchor(ShieldedType type) const { uint256 hashBestAnchor; - + switch (type) { case SPROUT: if (!db.Read(DB_BEST_SPROUT_ANCHOR, hashBestAnchor)) @@ -421,6 +421,7 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, } bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); +uint32_t komodo_segid32(char *coinaddr); UniValue CBlockTreeDB::Snapshot(int top) { @@ -433,23 +434,23 @@ UniValue CBlockTreeDB::Snapshot(int top) result.push_back(Pair("start_time", (int) time(NULL))); std::map ignoredMap = { - {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, - {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, - {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, - {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, - {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, - {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, - {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, - {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, - {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, - {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, - {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, - {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, - {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey + {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, + {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, + {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, + {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, + {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, + {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, + {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, + {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, + {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, + {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, + {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, + {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, + {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, + {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, + {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey }; int64_t startingHeight = chainActive.Height(); @@ -511,29 +512,31 @@ UniValue CBlockTreeDB::Snapshot(int top) //fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses); for (std::pair element : addressAmounts) { - vaddr.push_back( make_pair(element.second, element.first) ); + vaddr.push_back( make_pair(element.second, element.first) ); } std::sort(vaddr.rbegin(), vaddr.rend()); UniValue obj(UniValue::VOBJ); UniValue addressesSorted(UniValue::VARR); int topN = 0; - for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) { - UniValue obj(UniValue::VOBJ); - obj.push_back( make_pair("addr", it->second.c_str() ) ); - char amount[32]; - sprintf(amount, "%.8f", (double) it->first / COIN); - obj.push_back( make_pair("amount", amount) ); - total += it->first; - addressesSorted.push_back(obj); - topN++; - // If requested, only show top N addresses in output JSON - if (top == topN) - break; + for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) + { + UniValue obj(UniValue::VOBJ); + obj.push_back( make_pair("addr", it->second.c_str() ) ); + char amount[32]; + sprintf(amount, "%.8f", (double) it->first / COIN); + obj.push_back( make_pair("amount", amount) ); + obj.push_back( make_pair("segid", komodo_segid32(it->second.c_str()))); + total += it->first; + addressesSorted.push_back(obj); + topN++; + // If requested, only show top N addresses in output JSON + if (top == topN) + break; } if (top) - totalAddresses = top; + totalAddresses = top; if (totalAddresses > 0) { // Array of all addreses with balances @@ -670,7 +673,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nCachedBranchId = diskindex.nCachedBranchId; pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; - + // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From d75387aa35e38e484d7c85987ee30e3203639288 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:16:57 +0800 Subject: [PATCH 0795/3904] fix? --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 0b55f3338..5183599f9 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", komodo_segid32(it->second.c_str()))); + obj.push_back( make_pair("segid", komodo_segid32((char *)it->second.c_str()))); total += it->first; addressesSorted.push_back(obj); topN++; From 10e4b836a4bb2f38d1ab627b2615f4502c875761 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:18:00 +0800 Subject: [PATCH 0796/3904] fix --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 5183599f9..f0ebb2deb 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", komodo_segid32((char *)it->second.c_str()))); + obj.push_back( make_pair("segid", (int)komodo_segid32((char *)it->second.c_str()))); total += it->first; addressesSorted.push_back(obj); topN++; From bcf2def09789ac0d91a7a0a36839ac71b74936d9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:34:26 +0800 Subject: [PATCH 0797/3904] fix --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index f0ebb2deb..15c46fc08 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", (int)komodo_segid32((char *)it->second.c_str()))); + obj.push_back( make_pair("segid", (uint32_t)komodo_segid32((char *)it->second.c_str()))); total += it->first; addressesSorted.push_back(obj); topN++; From 5dcc40c3add9c825803018b9d5e69578f82943e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:41:11 +0800 Subject: [PATCH 0798/3904] convert unsigned int --- src/txdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 15c46fc08..123917549 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,8 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", (uint32_t)komodo_segid32((char *)it->second.c_str()))); + int segid = (short) komodo_segid32( (char *)it->second.c_str() ); + obj.push_back( make_pair("segid",(int) segid)) ); total += it->first; addressesSorted.push_back(obj); topN++; From 632d84fd6116c23c877bd7e6dd11fb995536ae0e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:42:24 +0800 Subject: [PATCH 0799/3904] ) --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 123917549..8d2ae7366 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -527,7 +527,7 @@ UniValue CBlockTreeDB::Snapshot(int top) sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); int segid = (short) komodo_segid32( (char *)it->second.c_str() ); - obj.push_back( make_pair("segid",(int) segid)) ); + obj.push_back( make_pair("segid",(int) segid) ); total += it->first; addressesSorted.push_back(obj); topN++; From 3a35b8345bff0849d48f01db5db221b0b253739b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:47:35 +0800 Subject: [PATCH 0800/3904] fixed --- src/txdb.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 8d2ae7366..00e43495a 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,8 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - int segid = (short) komodo_segid32( (char *)it->second.c_str() ); - obj.push_back( make_pair("segid",(int) segid) ); + obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f) ); total += it->first; addressesSorted.push_back(obj); topN++; From a0ad1185d8f4b6cb1c30b8136cb473f8d7070d5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:50:11 +0800 Subject: [PATCH 0801/3904] nope --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 00e43495a..c54c3e28e 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f) ); + obj.push_back( make_pair("segid",((int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f)) ); total += it->first; addressesSorted.push_back(obj); topN++; From ab5447324f16c9496a465ea5b9888b8271dd1cb6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:52:39 +0800 Subject: [PATCH 0802/3904] fix --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index c54c3e28e..11c52f071 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid",((int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f)) ); + obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str()) & 0x3f) ); total += it->first; addressesSorted.push_back(obj); topN++; From 5ced63c9c902d3da02bde1d97dc3e46c0481f129 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 14:18:44 +0800 Subject: [PATCH 0803/3904] Add getlastsegidstakes RPC --- src/rpc/blockchain.cpp | 64 +++++++++++++++++++++++++++++++++++++++++- src/rpc/client.cpp | 1 + src/rpc/server.cpp | 11 ++++---- src/rpc/server.h | 1 + 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a69a4ebb3..f2bf20e3e 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -606,6 +606,68 @@ UniValue getblockhash(const UniValue& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } +extern uint64_t ASSETCHAINS_STAKED; +int32_t komodo_isPoS(CBlock *pblock); +uint32_t komodo_segid32(char *coinaddr); + +UniValue getlastsegidstakes(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getlastsegidstakes depth\n" + "\nReturns object containing the counts of the last X blocks staked by each segid.\n" + "\nArguments:\n" + "1. depth (numeric, required) The amount of blocks to scan back." + "\nResult:\n" + "{\n" + " \"0\" : n, (numeric) number of stakes from segid 0 in the last X blocks.\n" + " .....\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getlastsegidstakes", "1000") + + HelpExampleRpc("getlastsegidstakes", "1000") + ); + + if ( ASSETCHAINS_STAKED == 0 ) + throw runtime_error("Only applies to ac_staked chains\n"); + + LOCK(cs_main); + + int depth = params[0].get_int(); + int32_t segids[64] = {0}; + + for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) + { + CBlockIndex* pblockindex = chainActive[i]; + CBlock block; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + if ( komodo_isPoS((CBlock *)&block) != 0 ) + { + CTxDestination voutaddress; int32_t segid; + if ( ExtractDestination(block.vtx[block.vtx.size()-1].vout[0].scriptPubKey,voutaddress) ) + { + segid = (int32_t)komodo_segid32((char *)CBitcoinAddress(voutaddress).ToString().c_str()) & 0x3f; + segids[segid] += 1; + } + } + } + + UniValue ret(UniValue::VOBJ); + for (int8_t i = 0; i < 64; i++) + { + char str[4]; + sprintf(str, "%d", i); + ret.push_back(Pair(str,segids[i])); + } + return ret; +} + /*uint256 _komodo_getblockhash(int32_t nHeight) { uint256 hash; @@ -859,7 +921,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp) " \"currentheight\": xxxxx, (numeric) current height of the chain\n" " \"key\": \"xxxxx\", (string) key\n" " \"keylen\": xxxxx, (string) length of the key \n" - " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" + " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" " \"height\": xxxxx, (numeric) height the key was stored at\n" " \"expiration\": xxxxx, (numeric) height the key will expire\n" " \"flags\": x (numeric) 1 if the key was created with a password; 0 otherwise.\n" diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 6553a348a..bf8cb0c38 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -74,6 +74,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listunspent", 2 }, { "getblock", 1 }, { "getblockheader", 1 }, + { "getlastsegidstakes", 0 }, { "gettransaction", 1 }, { "getrawtransaction", 1 }, { "createrawtransaction", 0 }, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 47f29bbfa..eb3cc80a0 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -304,6 +304,7 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "getblockhashes", &getblockhashes, true }, { "blockchain", "getblockhash", &getblockhash, true }, { "blockchain", "getblockheader", &getblockheader, true }, + { "blockchain", "getlastsegidstakes", &getlastsegidstakes, true }, { "blockchain", "getchaintips", &getchaintips, true }, { "blockchain", "getdifficulty", &getdifficulty, true }, { "blockchain", "getmempoolinfo", &getmempoolinfo, true }, @@ -366,16 +367,16 @@ static const CRPCCommand vRPCCommands[] = // auction { "auction", "auctionaddress", &auctionaddress, true }, - + // lotto { "lotto", "lottoaddress", &lottoaddress, true }, - + // fsm { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + // rewards { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -384,7 +385,7 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + // faucet { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, @@ -401,7 +402,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + // Oracles { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 122e818c3..e64216116 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -385,6 +385,7 @@ extern UniValue getblockhashes(const UniValue& params, bool fHelp); extern UniValue getblockdeltas(const UniValue& params, bool fHelp); extern UniValue getblockhash(const UniValue& params, bool fHelp); extern UniValue getblockheader(const UniValue& params, bool fHelp); +extern UniValue getlastsegidstakes(const UniValue& params, bool fHelp); extern UniValue getblock(const UniValue& params, bool fHelp); extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp); extern UniValue gettxout(const UniValue& params, bool fHelp); From 345260d1b5d42dc9eb9ec492726bd90aa99d2c2f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Dec 2018 13:13:57 +0800 Subject: [PATCH 0804/3904] oops --- src/wallet/rpcwallet.cpp | 53 ---------------------------------------- 1 file changed, 53 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 062e2ec24..dab6f19dd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4641,7 +4641,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (!fEnableMergeToAddress) { strDisabledMsg = experimentalDisabledHelpMsg("z_mergetoaddress", enableArg); } -<<<<<<< HEAD if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( @@ -4694,58 +4693,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") ); -======= - - if (fHelp || params.size() < 2 || params.size() > 6) - throw runtime_error( - "z_mergetoaddress [\"fromaddress\", ... ] \"toaddress\" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )\n" - + strDisabledMsg + - "\nMerge multiple UTXOs and notes into a single UTXO or note. Coinbase UTXOs are ignored; use `z_shieldcoinbase`" - "\nto combine those into a single note." - "\n\nThis is an asynchronous operation, and UTXOs selected for merging will be locked. If there is an error, they" - "\nare unlocked. The RPC call `listlockunspent` can be used to return a list of locked UTXOs." - "\n\nThe number of UTXOs and notes selected for merging can be limited by the caller. If the transparent limit" - "\nparameter is set to zero, and Overwinter is not yet active, the -mempooltxinputlimit option will determine the" - "\nnumber of UTXOs. Any limit is constrained by the consensus rule defining a maximum transaction size of" - + strprintf("\n%d bytes before Sapling, and %d bytes once Sapling activates.", MAX_TX_SIZE_BEFORE_SAPLING, MAX_TX_SIZE_AFTER_SAPLING) - + HelpRequiringPassphrase() + "\n" - "\nArguments:\n" - "1. fromaddresses (string, required) A JSON array with addresses.\n" - " The following special strings are accepted inside the array:\n" - " - \"ANY_TADDR\": Merge UTXOs from any t-addrs belonging to the wallet.\n" - " - \"ANY_SPROUT\": Merge notes from any Sprout z-addrs belonging to the wallet.\n" - " - \"ANY_SAPLING\": Merge notes from any Sapling z-addrs belonging to the wallet.\n" - " If a special string is given, any given addresses of that type will be ignored.\n" - " [\n" - " \"address\" (string) Can be a t-addr or a z-addr\n" - " ,...\n" - " ]\n" - "2. \"toaddress\" (string, required) The t-addr or z-addr to send the funds to.\n" - "3. fee (numeric, optional, default=" - + strprintf("%s", FormatMoney(MERGE_TO_ADDRESS_OPERATION_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n" - "4. transparent_limit (numeric, optional, default=" - + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n" - "4. shielded_limit (numeric, optional, default=" - + strprintf("%d Sprout or %d Sapling Notes", MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT, MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" - "\nResult:\n" - "{\n" - " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" - " \"remainingTransparentValue\": xxx (numeric) Value of UTXOs still available for merging.\n" - " \"remainingNotes\": xxx (numeric) Number of notes still available for merging.\n" - " \"remainingShieldedValue\": xxx (numeric) Value of notes still available for merging.\n" - " \"mergingUTXOs\": xxx (numeric) Number of UTXOs being merged.\n" - " \"mergingTransparentValue\": xxx (numeric) Value of UTXOs being merged.\n" - " \"mergingNotes\": xxx (numeric) Number of notes being merged.\n" - " \"mergingShieldedValue\": xxx (numeric) Value of notes being merged.\n" - " \"opid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("z_mergetoaddress", "'[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") - + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\"") - ); - ->>>>>>> e719e666307adb77fb4b79c7737256ea959fe188 if (!fEnableMergeToAddress) { throw JSONRPCError(RPC_WALLET_ERROR, "Error: z_mergetoaddress is disabled."); } From 3e7c05f2f0dc79118675bf9f9599956e8fb6576c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Dec 2018 13:18:06 +0800 Subject: [PATCH 0805/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index dab6f19dd..1771e6abb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4672,7 +4672,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) "4. transparent_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n" "4. shielded_limit (numeric, optional, default=" - + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" + + strprintf("%d Sprout or %d Sapling Notes", MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT, MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores p2pk utxo!\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" From 58076c86ea94a3d9c682695618c4ebf00802afc1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 09:34:03 +0800 Subject: [PATCH 0806/3904] fix build --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b4214d491..519753090 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; From 95cada6581668e87acb89ca53a51ba1da1d063bf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 09:37:28 +0800 Subject: [PATCH 0807/3904] fix conflict --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 519753090..8f2fa782c 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; bool VERUS_MINTBLOCKS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ebeebd712..94a44d123 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1774,13 +1774,7 @@ void komodo_args(char *argv0) ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); -<<<<<<< HEAD - ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); -======= ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - //ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); ->>>>>>> 655ef3c8ae43446c2cd361677699dcbe37f8fea4 if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; From de19acf57f3af47a596ff855902634f812da7798 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 10:51:43 +0800 Subject: [PATCH 0808/3904] try fix --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 94a44d123..6af8af4cc 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1538,7 +1538,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr printf("ports\n"); }*/ -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"sapling\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1}\""; From c75b409f673557c13d1c63913a21186d1c62c7aa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 11:05:37 +0800 Subject: [PATCH 0809/3904] revert --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6af8af4cc..94a44d123 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1538,7 +1538,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr printf("ports\n"); }*/ -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1}\""; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"sapling\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; From e474c107ed5bc3047b872af7775c41edb6377d4f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 11:40:00 +0800 Subject: [PATCH 0810/3904] revert agin --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 94a44d123..6af8af4cc 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1538,7 +1538,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr printf("ports\n"); }*/ -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"sapling\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1}\""; From 3028d884e531765a4f02b5be21b91cf324690fa2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 16 Dec 2018 23:04:45 +0800 Subject: [PATCH 0811/3904] Major rebase and fix staking. --- src/komodo_bitcoind.h | 1 - src/komodo_notary.h | 78 +++++++++++++++++++--------------------- src/komodo_utils.h | 2 +- src/main.cpp | 70 ++++++++++++------------------------ src/wallet/rpcwallet.cpp | 4 +-- src/wallet/walletdb.cpp | 5 +-- 6 files changed, 63 insertions(+), 97 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 882292032..a342bb459 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ commission must be in coinbase.vout[1] and must be >= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ -extern int32_t ASSETCHAINS_FOUNDERS_PERIOD; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 96497b755..58bc3bffa 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -207,59 +207,55 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - timestamp = komodo_heightstamp(height); + timestamp = komodo_heightstamp(height); else if ( ASSETCHAINS_SYMBOL[0] == 0 ) - timestamp = 0; + timestamp = 0; // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) { - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = 0; + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6af8af4cc..c4c26e0c7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1711,7 +1711,7 @@ void komodo_args(char *argv0) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); } - if ( name.c_str()[0] != 0 ) + if ( name.c_str()[0] != 0 ) { std::string selectedAlgo = GetArg("-ac_algo", std::string(ASSETCHAINS_ALGORITHMS[0])); diff --git a/src/main.cpp b/src/main.cpp index 17ff3cbb8..1385ab69b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1244,7 +1244,8 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) { + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { for (int32_t i=0; i<=NUM_NOTARIES; i++) if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) return(1); @@ -1764,8 +1765,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (pfMissingInputs) *pfMissingInputs = true; //fprintf(stderr,"missing inputs\n"); - return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); - return(false); + if (!fSkipExpiry) + return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); + else + return(false); } } @@ -1773,7 +1776,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (!view.HaveInputs(tx)) { //fprintf(stderr,"accept failure.1\n"); - return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); + if (!fSkipExpiry) + return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); + else + return(false); } } // are the joinsplit's requirements met? @@ -3302,7 +3308,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if (!view.HaveInputs(tx)) { - return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), + return state.DoS(100, error("ConnectBlock(): inputs missing/spent %s",tx.GetHash().ToString().c_str()), REJECT_INVALID, "bad-txns-inputs-missingorspent"); } // are the JoinSplit's requirements met? @@ -3846,8 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET - TxToRemove.push_back(tx.GetHash()); - //pwalletMain->EraseFromWallet(tx.GetHash()); + pwalletMain->EraseFromWallet(tx.GetHash()); #endif } else @@ -3855,25 +3860,6 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { SyncWithWallets(tx, NULL); } } - if ( ASSETCHAINS_STAKED != 0 ) // If Staked chain, scan wallet for orphaned txs and delete them. - { - LOCK2(cs_main, pwalletMain->cs_wallet); - for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - CTransaction tx; - uint256 hashBlock; - if (!GetTransaction((*it).first,tx,hashBlock,true)) - { - fprintf(stderr, "TX Does Not Exist: %s\n",(*it).first.ToString().c_str()); - TxToRemove.push_back((*it).first); - } - } - BOOST_FOREACH (uint256& hash, TxToRemove) - { - pwalletMain->EraseFromWallet(hash); - fprintf(stderr, "Erased %s from wallet.\n",hash.ToString().c_str()); - } - } // Update cached incremental witnesses GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false); return true; @@ -6601,32 +6587,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrFrom; uint64_t nNonce = 1; int nVersion; // use temporary for version, don't set version number until validated as connected + int minVersion = MIN_PEER_PROTO_VERSION; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + minVersion = STAKEDMIN_PEER_PROTO_VERSION; vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe; if (nVersion == 10300) nVersion = 300; - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if (nVersion < minVersion) { - if (nVersion < STAKEDMIN_PEER_PROTO_VERSION) - { - // disconnect from peers older than this proto version - LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); - pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, - strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); - pfrom->fDisconnect = true; - return false; - } - } - else - { - if (nVersion < MIN_PEER_PROTO_VERSION) - { - // disconnect from peers older than this proto version - LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); - pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, - strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); - pfrom->fDisconnect = true; - return false; - } + // disconnect from peers older than this proto version + LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); + pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, + strprintf("Version must be %d or greater", minVersion)); + pfrom->fDisconnect = true; + return false; } // Reject incoming connections from nodes that don't know about the current epoch diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1771e6abb..2f6455701 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5317,7 +5317,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { - //fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; @@ -5388,7 +5388,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } //else fprintf(stderr,"utxo not eligible\n"); } - if ( numkp < 10000 && array != 0 ) + if ( numkp < 1000 && array != 0 ) { free(array); array = 0; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 52c815ce2..4dedab834 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -867,8 +867,6 @@ static bool IsKeyType(string strType) strType == "mkey" || strType == "ckey"); } -extern uint64_t ASSETCHAINS_STAKED; - DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { pwallet->vchDefaultKey = CPubKey(); @@ -920,9 +918,8 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. - if (strType == "tx" && ASSETCHAINS_STAKED == 0 ) + if (strType == "tx" ) // Rescan if there is a bad transaction record.. - // But dont on staked chains! SoftSetBoolArg("-rescan", true); } } From c1e694dd80b5dd3b77e37bfe929f3ef267201e94 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 04:59:04 -1100 Subject: [PATCH 0812/3904] Update zmigrate --- src/cc/dapps/zmigrate.c | 67 +++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 81de2c13d..8a57ebda5 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -20,18 +20,18 @@ #include "cJSON.c" /* -z_migrate: the purpose of z_migrate is to make converting of all sprout outputs into sapling. the usage would be for the user to specify a sapling address and call z_migrate zsaddr, until it returns that there is nothing left to be done. - -its main functionality is quite similar to a z_mergetoaddress ANY_ZADDR -> onetime_taddr followed by a z_sendmany onetime_taddr -> zsaddr - -since the z_mergetoaddress will take time, it would just queue up an async operation. When it starts, it should see if there are any onetime_taddr with 10000.0001 funds in it, that is a signal for it to do the sapling tx and it can just do that without async as it is fast enough, especially with a taddr input. Maybe it limits itself to one, or it does all possible taddr -> sapling as fast as it can. either is fine as it will be called over and over anyway. - -It might be that there is nothing to do, but some operations are pending. in that case it would return such a status. as soon as the operation finishes, there would be more work to do. - -the amount sent to the taddr, should be 10000.0001 - -The GUI or user would be expected to generate a sapling address and then call z_migrate saplingaddr in a loop, until it returns that it is all done. this loop should pause for 10 seconds or so, if z_migrate is just waiting for opid to complete. -*/ + z_migrate: the purpose of z_migrate is to make converting of all sprout outputs into sapling. the usage would be for the user to specify a sapling address and call z_migrate zsaddr, until it returns that there is nothing left to be done. + + its main functionality is quite similar to a z_mergetoaddress ANY_ZADDR -> onetime_taddr followed by a z_sendmany onetime_taddr -> zsaddr + + since the z_mergetoaddress will take time, it would just queue up an async operation. When it starts, it should see if there are any onetime_taddr with 10000.0001 funds in it, that is a signal for it to do the sapling tx and it can just do that without async as it is fast enough, especially with a taddr input. Maybe it limits itself to one, or it does all possible taddr -> sapling as fast as it can. either is fine as it will be called over and over anyway. + + It might be that there is nothing to do, but some operations are pending. in that case it would return such a status. as soon as the operation finishes, there would be more work to do. + + the amount sent to the taddr, should be 10000.0001 + + The GUI or user would be expected to generate a sapling address and then call z_migrate saplingaddr in a loop, until it returns that it is all done. this loop should pause for 10 seconds or so, if z_migrate is just waiting for opid to complete. + */ bits256 zeroid; @@ -331,7 +331,7 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char system(cmdstr); *retstrp = 0; if ( (jsonstr= filestr(&fsize,fname)) != 0 ) - { + { jsonstr[strlen(jsonstr)-1]='\0'; //fprintf(stderr,"%s -> jsonstr.(%s)\n",cmdstr,jsonstr); if ( (jsonstr[0] != '{' && jsonstr[0] != '[') || (retjson= cJSON_Parse(jsonstr)) == 0 ) @@ -599,13 +599,13 @@ int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* comp cJSON *retjson; char *retstr; int32_t res=0; if ( (retjson= get_komodocli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 ) { - if (is_cJSON_True(jobj(retjson,compare)) != 0 ) res=1; + if (is_cJSON_True(jobj(retjson,compare)) != 0 ) res=1; free_json(retjson); } else if ( retstr != 0 ) { fprintf(stderr,"validateaddress.(%s) %s error.(%s)\n",refcoin,acname,retstr); - free(retstr); + free(retstr); } return (res); } @@ -670,6 +670,7 @@ int64_t find_onetime_amount(char *coinstr,char *coinaddr) coinaddr[0] = 0; if ( (array= get_listunspent(coinstr,"")) != 0 ) { + //printf("got listunspent.(%s)\n",jprint(array,0)); if ( (n= cJSON_GetArraySize(array)) > 0 ) { for (i=0; i %s\n",srcaddr,params); if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 ) { printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0)); @@ -797,7 +799,7 @@ int32_t tx_has_voutaddress(char *refcoin,char *acname,bits256 txid,char *coinadd if ( (vouts= jarray(&numarray,txobj,"vout")) != 0 ) { for (i=0; i txfee ) @@ -930,14 +932,33 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 - if ( amount > stdamount+txfee ) - amount = stdamount + txfee; + static int64_t lastamount,lastamount2,lastamount3,lastamount4,refamount = 5000 * SATOSHIDEN; + stdamount = refamount; + if ( amount == lastamount && amount == lastamount2 ) + { + stdamount /= 10; + if ( amount == lastamount3 && amount == lastamount4 ) + stdamount /= 10; + } + if ( stdamount < COIN ) + { + stdamount = COIN; + refamount = COIN * 50; + } + if ( stdamount < refamount ) + refamount = stdamount; + lastamount4 = lastamount3; + lastamount3 = lastamount2; + lastamount2 = lastamount; + lastamount = amount; + if ( amount > stdamount+2*txfee ) + amount = stdamount + 2*txfee; if ( getnewaddress(coinaddr,coinstr,"") == 0 ) { z_sendmany(opidstr,coinstr,"",zcaddr,coinaddr,amount-txfee); lastopid = (uint32_t)time(NULL); } else printf("couldnt getnewaddress!\n"); - sleep(30); + sleep(3); continue; } if ( time(NULL) > lastopid+600 ) From e9b100e50fac7772b4080c0d182f751f21d0ec58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 05:51:21 -1100 Subject: [PATCH 0813/3904] COIN -> SATOSHIDEN --- src/cc/dapps/zmigrate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 8a57ebda5..d492163c4 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -940,10 +940,10 @@ again: if ( amount == lastamount3 && amount == lastamount4 ) stdamount /= 10; } - if ( stdamount < COIN ) + if ( stdamount < SATOSHIDEN ) { - stdamount = COIN; - refamount = COIN * 50; + stdamount = SATOSHIDEN; + refamount = SATOSHIDEN * 50; } if ( stdamount < refamount ) refamount = stdamount; From fe32a3be6c8950266d759103d2fb2beda635967e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Dec 2018 07:39:54 -1100 Subject: [PATCH 0814/3904] Fix stuck sync for nodes that are doing full sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sapling height is calculated near the sapling activation timestamp. Until it is set, the node doesn’t know when sapling should be active. Depending on the speed at which you get blocks from the future, it was possible that you could see a sapling active block before the sapling height was set. This would happen only if syncing from a node that didn’t know the sapling height and a full resync with the most peers and most variety of incoming block sources was most likely hit by this. The net effect was that the blocks after sapling activation were marked as invalid, so by the time the node synced up to the sapling height, it couldn’t advance. --- src/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 6c33feb08..d822c8686 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5043,6 +5043,19 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C auto verifier = libzcash::ProofVerifier::Disabled(); if ((!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev)) { + static int32_t saplinght = -1; + CBlockIndex *tmpptr; + if ( saplinght == -1 ) + saplinght = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; + if ( saplinght < 0 ) + *futureblockp = 1; + // the problem is when a future sapling block comes in before we detected saplinght + if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 ) + { + fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); + if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) + *futureblockp = 1; + } if ( *futureblockp == 0 ) { if (state.IsInvalid() && !state.CorruptionPossible()) { From 2ebdae67e8fbe0e8decd4f7fded3410c1c826390 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 11:41:26 +0800 Subject: [PATCH 0815/3904] fix setgenerate better, bug on deamon stop it was starting another staking thread. --- src/miner.cpp | 4 ++-- src/rpc/mining.cpp | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 01ee92234..5c8109f40 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1441,7 +1441,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", -1) == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif @@ -1831,7 +1831,7 @@ void static BitcoinMiner() } //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); - if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 ) + if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 && fGenerate ) { if ( pwallet != NULL ) nThreads = 1; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 5ed1de14c..042dd9b00 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -339,22 +339,25 @@ UniValue setgenerate(const UniValue& params, bool fHelp) //if (nGenProcLimit == 0) // fGenerate = false; } - - if (fGenerate && !nGenProcLimit) + if ( ASSETCHAINS_LWMAPOS != 0 ) { - VERUS_MINTBLOCKS = 1; - fGenerate = GetBoolArg("-gen", false); - if ( ASSETCHAINS_STAKED == 0 ) - nGenProcLimit = KOMODO_MININGTHREADS; - else + if (fGenerate && !nGenProcLimit) + { + VERUS_MINTBLOCKS = 1; + fGenerate = GetBoolArg("-gen", false); KOMODO_MININGTHREADS = nGenProcLimit; + } + else if (!fGenerate) + { + VERUS_MINTBLOCKS = 0; + KOMODO_MININGTHREADS = 0; + } + else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; } - else if (!fGenerate) + else { - VERUS_MINTBLOCKS = 0; - KOMODO_MININGTHREADS = 0; + KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; } - else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); From 45bbd04fb2741ff6cdc0e9a62a78002942eb040d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 12:34:40 +0800 Subject: [PATCH 0816/3904] cleanwallettransactions --- src/rpc/server.cpp | 11 +- src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 226 ++++++++++++++++++++++++++++----------- 3 files changed, 171 insertions(+), 67 deletions(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 1b6856be5..938556f0f 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -364,16 +364,16 @@ static const CRPCCommand vRPCCommands[] = // auction { "auction", "auctionaddress", &auctionaddress, true }, - + // lotto { "lotto", "lottoaddress", &lottoaddress, true }, - + // fsm { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + // rewards { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -382,7 +382,7 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + // faucet { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, @@ -399,7 +399,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + // Oracles { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -508,6 +508,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, + { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 6638024b8..410c2e915 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -317,6 +317,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); +extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f8b507403..bd81c950d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1015,6 +1015,108 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } +UniValue cleanwallettransactions(const UniValue& params, bool fHelp) +{ + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() > 1 ) + throw runtime_error( + "cleanwallettransactions \"txid\"\n" + "\nRemove all txs that are spent. You can clear all txs bar one, by specifiying a txid.\n" + "\nPlease backup your wallet.dat before running this command.\n" + "\nArguments:\n" + "1. \"txid\" (string, optional) The transaction id to keep.\n" + "\nResult:\n" + "{\n" + " \"total_transactons\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n" + " \"remaining_transactons\" : n, (numeric) Transactions in wallet after clean.\n" + " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("cleanwallettransactions", "") + + HelpExampleCli("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("cleanwallettransactions", "") + + HelpExampleRpc("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + UniValue ret(UniValue::VOBJ); + uint256 exception; int32_t txs = pwalletMain->mapWallet.size(); + std::vector TxToRemove; + if (params.size() == 1) + { + exception.SetHex(params[0].get_str()); + uint256 tmp_hash; CTransaction tmp_tx; + if (GetTransaction(exception,tmp_tx,tmp_hash,false)) + { + if ( !pwalletMain->IsMine(tmp_tx) ) + { + throw runtime_error("\nThe transaction is not yours!\n"); + } + else + { + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if ( wtx.GetHash() != exception ) + { + TxToRemove.push_back(wtx.GetHash()); + } + } + } + } + else + { + throw runtime_error("\nThe transaction could not be found!\n"); + } + } + else + { + // get all locked utxos to relock them later. + vector vLockedUTXO; + pwalletMain->ListLockedCoins(vLockedUTXO); + // unlock all coins so that the following call containes all utxos. + pwalletMain->UnlockAllCoins(); + // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, + vector vecOutputs; + assert(pwalletMain != NULL); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + int32_t oldestTxDepth = 0; + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( out.nDepth > oldestTxDepth ) + oldestTxDepth = out.nDepth; + } + oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + // lock all the previouly locked coins. + BOOST_FOREACH(COutPoint &outpt, vLockedUTXO) { + pwalletMain->LockCoin(outpt); + } + + // then add all txs in the wallet before this block to the list to remove. + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (wtx.GetDepthInMainChain() > oldestTxDepth) + TxToRemove.push_back(wtx.GetHash()); + } + } + + // erase txs + BOOST_FOREACH (uint256& hash, TxToRemove) + { + pwalletMain->EraseFromWallet(hash); + LogPrintf("Erased %s from wallet.\n",hash.ToString().c_str()); + } + + // build return JSON for stats. + int remaining = pwalletMain->mapWallet.size(); + ret.push_back(Pair("total_transactons", (int)txs)); + ret.push_back(Pair("remaining_transactons", (int)remaining)); + ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); + return (ret); +} UniValue getbalance(const UniValue& params, bool fHelp) { @@ -1674,7 +1776,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY)) entry.push_back(Pair("involvesWatchonly", true)); entry.push_back(Pair("account", account)); - + CTxDestination dest; if (CScriptExt::ExtractVoutDestination(wtx, r.vout, dest)) MaybePushAddress(entry, dest); @@ -2920,11 +3022,11 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) // User did not provide zaddrs, so use default i.e. all addresses std::set sproutzaddrs = {}; pwalletMain->GetSproutPaymentAddresses(sproutzaddrs); - + // Sapling support std::set saplingzaddrs = {}; pwalletMain->GetSaplingPaymentAddresses(saplingzaddrs); - + zaddrs.insert(sproutzaddrs.begin(), sproutzaddrs.end()); zaddrs.insert(saplingzaddrs.begin(), saplingzaddrs.end()); } @@ -2936,7 +3038,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) std::vector saplingEntries; pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs, nMinDepth, nMaxDepth, true, !fIncludeWatchonly, false); std::set> nullifierSet = pwalletMain->GetNullifiersForAddresses(zaddrs); - + for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", entry.jsop.hash.ToString())); @@ -2954,7 +3056,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) } results.push_back(obj); } - + for (auto & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", entry.op.hash.ToString())); @@ -4115,7 +4217,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) } if ( toSapling && ASSETCHAINS_SYMBOL[0] == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER,"Sprout usage will expire soon"); - + // If we are sending from a shielded address, all recipient // shielded addresses must be of the same type. if ((fromSprout && toSapling) || (fromSapling && toSprout)) { @@ -4534,14 +4636,14 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + string enableArg = "zmergetoaddress"; auto fEnableMergeToAddress = fExperimentalMode && GetBoolArg("-" + enableArg, true); std::string strDisabledMsg = ""; if (!fEnableMergeToAddress) { strDisabledMsg = experimentalDisabledHelpMsg("z_mergetoaddress", enableArg); } - + if (fHelp || params.size() < 2 || params.size() > 6) throw runtime_error( "z_mergetoaddress [\"fromaddress\", ... ] \"toaddress\" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )\n" @@ -4590,33 +4692,33 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + HelpExampleCli("z_mergetoaddress", "'[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\"") ); - + if (!fEnableMergeToAddress) { throw JSONRPCError(RPC_WALLET_ERROR, "Error: z_mergetoaddress is disabled."); } - + LOCK2(cs_main, pwalletMain->cs_wallet); - + bool useAnyUTXO = false; bool useAnySprout = false; bool useAnySapling = false; std::set taddrs = {}; std::set zaddrs = {}; - + UniValue addresses = params[0].get_array(); if (addresses.size()==0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, fromaddresses array is empty."); - + // Keep track of addresses to spot duplicates std::set setAddress; - + // Sources for (const UniValue& o : addresses.getValues()) { if (!o.isStr()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected string"); - + std::string address = o.get_str(); - + if (address == "ANY_TADDR") { useAnyUTXO = true; } else if (address == "ANY_SPROUT") { @@ -4636,23 +4738,23 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } } - + if (setAddress.count(address)) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ") + address); setAddress.insert(address); } - + if (useAnyUTXO && taddrs.size() > 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify specific t-addrs when using \"ANY_TADDR\""); } if ((useAnySprout || useAnySapling) && zaddrs.size() > 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify specific z-addrs when using \"ANY_SPROUT\" or \"ANY_SAPLING\""); } - + const int nextBlockHeight = chainActive.Height() + 1; const bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); const bool saplingActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); - + // Validate the destination address auto destaddress = params[1].get_str(); bool isToSproutZaddr = false; @@ -4674,7 +4776,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ") + destaddress ); } } - + // Convert fee from currency format to zatoshis CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE; if (params.size() > 2) { @@ -4684,7 +4786,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) nFee = AmountFromValue( params[2] ); } } - + int nUTXOLimit = MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT; if (params.size() > 3) { nUTXOLimit = params[3].get_int(); @@ -4692,7 +4794,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "Limit on maximum number of UTXOs cannot be negative"); } } - + int sproutNoteLimit = MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT; int saplingNoteLimit = MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT; if (params.size() > 4) { @@ -4703,7 +4805,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) sproutNoteLimit = nNoteLimit; saplingNoteLimit = nNoteLimit; } - + std::string memo; if (params.size() > 5) { memo = params[5].get_str(); @@ -4716,9 +4818,9 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE )); } } - + MergeToAddressRecipient recipient(destaddress, memo); - + // Prepare to get UTXOs and notes std::vector utxoInputs; std::vector sproutNoteInputs; @@ -4732,7 +4834,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) bool maxedOutUTXOsFlag = false; bool maxedOutNotesFlag = false; size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0)); - + unsigned int max_tx_size = saplingActive ? MAX_TX_SIZE_AFTER_SAPLING : MAX_TX_SIZE_BEFORE_SAPLING; size_t estimatedTxSize = 200; // tx overhead + wiggle room if (isToSproutZaddr) { @@ -4740,20 +4842,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } else if (isToSaplingZaddr) { estimatedTxSize += OUTPUTDESCRIPTION_SIZE; } - + if (useAnyUTXO || taddrs.size() > 0) { // Get available utxos vector vecOutputs; pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, false); - + // Find unspent utxos and update estimated size for (const COutput& out : vecOutputs) { if (!out.fSpendable) { continue; } - + CScript scriptPubKey = out.tx->vout[out.i].scriptPubKey; - + CTxDestination address; if (!ExtractDestination(scriptPubKey, address)) { continue; @@ -4762,10 +4864,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (taddrs.size() > 0 && !taddrs.count(address)) { continue; } - + utxoCounter++; CAmount nValue = out.tx->vout[out.i].nValue; - + if (!maxedOutUTXOsFlag) { size_t increase = (boost::get(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; if (estimatedTxSize + increase >= max_tx_size || @@ -4779,19 +4881,19 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) mergedUTXOValue += nValue; } } - + if (maxedOutUTXOsFlag) { remainingUTXOValue += nValue; } } } - + if (useAnySprout || useAnySapling || zaddrs.size() > 0) { // Get available notes std::vector sproutEntries; std::vector saplingEntries; pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs); - + // If Sapling is not active, do not allow sending from a sapling addresses. if (!saplingActive && saplingEntries.size() > 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); @@ -4808,12 +4910,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) RPC_INVALID_PARAMETER, "Cannot send between Sprout and Sapling addresses using z_mergetoaddress"); } - + // Find unspent notes and update estimated size for (const CSproutNotePlaintextEntry& entry : sproutEntries) { noteCounter++; CAmount nValue = entry.plaintext.value(); - + if (!maxedOutNotesFlag) { // If we haven't added any notes yet and the merge is to a // z-address, we have already accounted for the first JoinSplit. @@ -4831,12 +4933,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) mergedNoteValue += nValue; } } - + if (maxedOutNotesFlag) { remainingNoteValue += nValue; } } - + for (const SaplingNoteEntry& entry : saplingEntries) { noteCounter++; CAmount nValue = entry.note.value(); @@ -4856,20 +4958,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) mergedNoteValue += nValue; } } - + if (maxedOutNotesFlag) { remainingNoteValue += nValue; } } } - + size_t numUtxos = utxoInputs.size(); size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); - + if (numUtxos == 0 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } - + // Sanity check: Don't do anything if: // - We only have one from address // - It's equal to toaddress @@ -4877,26 +4979,26 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (setAddress.size() == 1 && setAddress.count(destaddress) && (numUtxos + numNotes) == 1) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Destination address is also the only source address, and all its funds are already merged."); } - + CAmount mergedValue = mergedUTXOValue + mergedNoteValue; if (mergedValue < nFee) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strprintf("Insufficient funds, have %s, which is less than miners fee %s", FormatMoney(mergedValue), FormatMoney(nFee))); } - + // Check that the user specified fee is sane (if too high, it can result in error -25 absurd fee) CAmount netAmount = mergedValue - nFee; if (nFee > netAmount) { throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Fee %s is greater than the net amount to be shielded %s", FormatMoney(nFee), FormatMoney(netAmount))); } - + // Keep record of parameters in context object UniValue contextInfo(UniValue::VOBJ); contextInfo.push_back(Pair("fromaddresses", params[0])); contextInfo.push_back(Pair("toaddress", params[1])); contextInfo.push_back(Pair("fee", ValueFromAmount(nFee))); - + // Contextual transaction we will build on CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), @@ -4905,7 +5007,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (contextualTx.nVersion == 1 && isSproutShielded) { contextualTx.nVersion = 2; // Tx format should support vjoinsplit } - + // Builder (used if Sapling addresses are involved) boost::optional builder; if (isToSaplingZaddr || saplingNoteInputs.size() > 0) { @@ -4917,7 +5019,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) new AsyncRPCOperation_mergetoaddress(builder, contextualTx, utxoInputs, sproutNoteInputs, saplingNoteInputs, recipient, nFee, contextInfo) ); q->addOperation(operation); AsyncRPCOperationId operationId = operation->getId(); - + // Return continuation information UniValue o(UniValue::VOBJ); o.push_back(Pair("remainingUTXOs", static_cast(utxoCounter - numUtxos))); @@ -6018,7 +6120,7 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp) if ( params.size() < 6+i+1 ) throw runtime_error("not enough parameters for N pubkeys\n"); pubkey = ParseHex(params[6+i].get_str().c_str()); - if (pubkey.size()!= 33) + if (pubkey.size()!= 33) throw runtime_error("invalid destination pubkey"); pubkeys.push_back(pubkey2pk(pubkey)); } @@ -6052,8 +6154,8 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp) amount = atof((char *)params[8].get_str().c_str()) * COIN + 0.00000000499999; if ( amount <= 0 || claimvout < 0 ) throw runtime_error("invalid param: amount, numpks or claimvout\n"); - if (destpub.size()!= 33) - throw runtime_error("invalid destination pubkey"); + if (destpub.size()!= 33) + throw runtime_error("invalid destination pubkey"); hex = GatewaysDeposit(0,bindtxid,height,coin,cointxid,claimvout,deposithex,proof,pubkey2pk(destpub),amount); RETURN_IF_ERROR(CCerror); @@ -6078,9 +6180,9 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp) coin = params[1].get_str(); deposittxid = Parseuint256((char *)params[2].get_str().c_str()); destpub = ParseHex(params[3].get_str()); - amount = atof((char *)params[4].get_str().c_str()) * COIN + 0.00000000499999; - if (destpub.size()!= 33) - throw runtime_error("invalid destination pubkey"); + amount = atof((char *)params[4].get_str().c_str()) * COIN + 0.00000000499999; + if (destpub.size()!= 33) + throw runtime_error("invalid destination pubkey"); hex = GatewaysClaim(0,bindtxid,coin,deposittxid,pubkey2pk(destpub),amount); RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) @@ -6103,9 +6205,9 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); withdrawpub = ParseHex(params[2].get_str()); - amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999; - if (withdrawpub.size()!= 33) - throw runtime_error("invalid destination pubkey"); + amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999; + if (withdrawpub.size()!= 33) + throw runtime_error("invalid destination pubkey"); hex = GatewaysWithdraw(0,bindtxid,coin,pubkey2pk(withdrawpub),amount); RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) @@ -6124,7 +6226,7 @@ UniValue gatewayspartialsign(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); parthex = params[2].get_str(); @@ -6169,7 +6271,7 @@ UniValue gatewaysmarkdone(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); completetxid = Parseuint256((char *)params[0].get_str().c_str()); - coin = params[1].get_str(); + coin = params[1].get_str(); hex = GatewaysMarkDone(0,completetxid,coin); RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) @@ -7173,7 +7275,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); asktxid = Parseuint256((char *)params[1].get_str().c_str()); - //fillunits = atol(params[2].get_str().c_str()); + //fillunits = atol(params[2].get_str().c_str()); fillunits = atoll(params[2].get_str().c_str()); // dimxy changed to prevent loss of significance if ( fillunits <= 0 ) { From cacd2c7c02ca85bfaf5daa6d05f2181953d52bb1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 16:24:29 +0800 Subject: [PATCH 0817/3904] fix prints and revert mempool error. --- src/crosschain_authority.cpp | 1 - src/main.cpp | 2 +- src/notarisationdb.cpp | 5 ----- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b4379c010..7487e4879 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -42,7 +42,6 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (!seen[i]) { if (memcmp(pk, auth.notaries[i], 33) == 0) { seen[i] = 1; - printf("seennotary.%i\n",i); goto found; } else { //printf("notary.%i is not valid!\n",i); diff --git a/src/main.cpp b/src/main.cpp index c11e58818..cc97b366f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4748,7 +4748,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C CValidationState state; CTransaction Tx; const CTransaction &tx = (CTransaction)block.vtx[i]; - if (tx.IsCoinBase() || (!tx.vjoinsplit.empty() && !tx.vShieldedSpend.empty()) || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) + if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) continue; Tx = tx; if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index c1cee2877..3b0746d80 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -41,24 +41,19 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int32_t staked_era = STAKED_era(timestamp); - printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization - printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; } else { // pass era slection off to notaries_staked.cpp file auth_STAKED = Choose_auth_STAKED(staked_era); } - printf("minsigs.%i era.%i authsize.%i\n",auth_STAKED.requiredSigs,staked_era,auth_STAKED.size); if (!CheckTxAuthority(tx, auth_STAKED)) continue; - printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); From 1d1b1290e7d45da563549063fe4467576e8b866e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:23:30 +0800 Subject: [PATCH 0818/3904] try this --- src/miner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index bce67d116..3e3791288 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1682,7 +1682,8 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); - return(false); + break; + //return(false); } KOMODO_CHOSEN_ONE = 1; // Found a solution From 7a7ae42ab63e7ebe683ae55d7b92c53ce1fdb865 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:36:30 +0800 Subject: [PATCH 0819/3904] fix? --- src/miner.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3e3791288..4ecf39cb7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1589,6 +1589,7 @@ void static BitcoinMiner() KOMODO_INSYNC = Mining_height; sleep(3); }*/ + bool breakLoop = false; komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; @@ -1682,8 +1683,9 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); - break; - //return(false); + if ( ASSETCHAINS_STAKED != 0 ) + breakLoop = true; + return(false); } KOMODO_CHOSEN_ONE = 1; // Found a solution @@ -1818,6 +1820,8 @@ void static BitcoinMiner() } }*/ } + if (breakLoop) + break; } } catch (const boost::thread_interrupted&) From 867f7853706d8b867198fd6d4837c59cbf3a5869 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:40:35 +0800 Subject: [PATCH 0820/3904] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4ecf39cb7..dec49ac12 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1614,7 +1614,7 @@ void static BitcoinMiner() else hashTarget = HASHTarget; std::function)> validBlock = #ifdef ENABLE_WALLET - [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams] + [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams, &breakLoop] #else [&pblock, &hashTarget, &m_cs, &cancelSolver, &chainparams] #endif From 90d1fee4812acc76156ea06da2a62e018144c1d1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:46:20 +0800 Subject: [PATCH 0821/3904] try --- src/miner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index dec49ac12..2de3816f6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1579,6 +1579,7 @@ void static BitcoinMiner() LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } + bool breakLoop; while (true) { /*if ( KOMODO_INSYNC == 0 ) @@ -1589,7 +1590,7 @@ void static BitcoinMiner() KOMODO_INSYNC = Mining_height; sleep(3); }*/ - bool breakLoop = false; + breakLoop = false; komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; From 8402a8e954bc6d1d03be5d9bb2ff27621211052c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 18:28:45 +0800 Subject: [PATCH 0822/3904] fix --- src/miner.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 2de3816f6..9e63da568 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1579,7 +1579,7 @@ void static BitcoinMiner() LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } - bool breakLoop; + //bool breakLoop; while (true) { /*if ( KOMODO_INSYNC == 0 ) @@ -1590,7 +1590,7 @@ void static BitcoinMiner() KOMODO_INSYNC = Mining_height; sleep(3); }*/ - breakLoop = false; + bool breakLoop = false; komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; @@ -1716,7 +1716,8 @@ void static BitcoinMiner() std::lock_guard lock{m_cs}; return cancelSolver; }; - + if (breakLoop) + break; // TODO: factor this out into a function with the same API for each solver. if (solver == "tromp" ) { //&& notaryid >= 0 ) { // Create solver and initialize it. @@ -1821,8 +1822,6 @@ void static BitcoinMiner() } }*/ } - if (breakLoop) - break; } } catch (const boost::thread_interrupted&) From e57b2a05fa1eb5f33ed8a93c778443f820b9df2b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 19:14:49 +0800 Subject: [PATCH 0823/3904] print --- src/main.cpp | 3 ++- src/miner.cpp | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cc97b366f..8b88d44b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3311,7 +3311,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if (!view.HaveInputs(tx)) { - return state.DoS(100, error("ConnectBlock(): inputs missing/spent %s",tx.GetHash().ToString().c_str()), + fprintf(stderr, "Connect Block missing inputs tx_number.%d \nvin txid.%s vout.%ld \n",i,tx.vin[0].prevout.hash.ToString().c_str(),tx.vin[0].prevout.n); + return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); } // are the JoinSplit's requirements met? diff --git a/src/miner.cpp b/src/miner.cpp index 9e63da568..dfadf2e33 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1579,7 +1579,6 @@ void static BitcoinMiner() LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } - //bool breakLoop; while (true) { /*if ( KOMODO_INSYNC == 0 ) From 993444ec3c891e1eea0c4e8c101aa3d0e9230bf7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 19:19:43 +0800 Subject: [PATCH 0824/3904] fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8b88d44b3..3e6264480 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3311,7 +3311,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if (!view.HaveInputs(tx)) { - fprintf(stderr, "Connect Block missing inputs tx_number.%d \nvin txid.%s vout.%ld \n",i,tx.vin[0].prevout.hash.ToString().c_str(),tx.vin[0].prevout.n); + fprintf(stderr, "Connect Block missing inputs tx_number.%d \nvin txid.%s vout.%d \n",i,tx.vin[0].prevout.hash.ToString().c_str(),tx.vin[0].prevout.n); return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); } From 165634876794b60091a99646a44386ac3dc767bf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Dec 2018 00:26:35 +0800 Subject: [PATCH 0825/3904] Ram staker is fixed! --- src/komodo_bitcoind.h | 277 +++++++++++++++++++++++++++++++++++++++ src/miner.cpp | 7 +- src/wallet/rpcwallet.cpp | 246 +--------------------------------- 3 files changed, 279 insertions(+), 251 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3f524d136..ef915f06c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -25,6 +25,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); +bool EnsureWalletIsAvailable(bool avoidException); //#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr)) @@ -610,6 +611,28 @@ uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr) return(txtime); } +int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout) +{ + int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; + if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 ) + { + txid = pblock->vtx[n-1].vin[0].prevout.hash; + vout = pblock->vtx[n-1].vin[0].prevout.n; + txtime = komodo_txtime(&value,txid,vout,destaddr); + if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) + { + strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + if ( strcmp(destaddr,voutaddr) == 0 && pblock->vtx[n-1].vout[0].nValue == value ) + { + //fprintf(stderr,"is PoS block!\n"); + addressout = voutaddress; + return(1); + } + } + } + return(0); +} + int32_t komodo_isPoS(CBlock *pblock) { int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; @@ -1935,3 +1958,257 @@ int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height) *sproutfundsp = sproutfunds; return(supply); } + +struct komodo_staking +{ + char address[64]; + uint256 txid; + arith_uint256 hashval; + uint64_t nValue; + uint32_t segid32,txtime; + int32_t vout; + CScript scriptPubKey; +}; + +struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numkp,int32_t *maxkp,uint32_t txtime,uint64_t nValue,uint256 txid,int32_t vout,char *address,uint8_t *hashbuf,CScript pk) +{ + uint256 hash; uint32_t segid32; struct komodo_staking *kp; + segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); + if ( *numkp >= *maxkp ) + { + *maxkp += 1000; + array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp)); + //fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array); + } + kp = &array[(*numkp)++]; + //fprintf(stderr,"kp.%p num.%d\n",kp,*numkp); + memset(kp,0,sizeof(*kp)); + strcpy(kp->address,address); + kp->txid = txid; + kp->vout = vout; + kp->hashval = UintToArith256(hash); + kp->txtime = txtime; + kp->segid32 = segid32; + kp->nValue = nValue; + kp->scriptPubKey = pk; + return(array); +} + +arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) +{ + int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; + diff = (iter + blocktime - kp->txtime - minage); + if ( diff < 0 ) + diff = 60; + else if ( diff > 3600*24*30 ) + diff = 3600*24*30; + if ( iter > 0 ) + diff += segid*2; + coinage = ((uint64_t)kp->nValue * diff); + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + coinage256 = arith_uint256(coinage+1); + hashval = ratio * (kp->hashval / coinage256); + return(hashval); +} + +uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komodo_staking *kp,int32_t nHeight,uint32_t blocktime,uint32_t prevtime,int32_t minage,uint8_t *hashbuf) +{ + int32_t maxiters = 600; uint256 hash; + int32_t segid,iter,diff; uint64_t coinage; arith_uint256 hashval,coinage256; + komodo_stakehash(&hash,kp->address,hashbuf,kp->txid,kp->vout); + kp->hashval = UintToArith256(hash); + segid = ((nHeight + kp->segid32) & 0x3f); + hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); + //for (int i=32; i>=0; i--) + // fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + //fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); + if ( hashval <= bnTarget ) + { + for (iter=0; itertxtime+minage ) + continue; + hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); + if ( hashval <= bnTarget ) + { + //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); + blocktime += iter; + blocktime += segid * 2; + return(blocktime); + } + } + } else fprintf(stderr,"maxiters is not good enough\n"); + return(0); +} + +int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) +{ + static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; + set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; + if (!EnsureWalletIsAvailable(0)) + return 0; + + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + ratio = (mindiff / bnTarget); + assert(pwalletMain != NULL); + *utxovaluep = 0; + memset(utxotxidp,0,sizeof(*utxotxidp)); + memset(utxovoutp,0,sizeof(*utxovoutp)); + memset(utxosig,0,72); + if ( (tipindex= chainActive.Tip()) == 0 ) + return(0); + nHeight = tipindex->GetHeight() + 1; + if ( (minage= nHeight*3) > 6000 ) // about 100 blocks + minage = 6000; + komodo_segids(hashbuf,nHeight-101,100); + if ( *blocktimep < tipindex->nTime+60 ) + *blocktimep = tipindex->nTime+60; + //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); + + bool resetstaker = false; + if ( array != 0 ) + { + CBlockIndex* pblockindex = chainActive[tipindex->GetHeight()]; + CBlock block; CTxDestination addressout; + if( ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0 ) + { + resetstaker = true; + fprintf(stderr, "Reset ram staker after mining a block!\n"); + } + } + + if ( time(NULL) > lasttime+600 || array == 0 || resetstaker ) + { + LOCK2(cs_main, pwalletMain->cs_wallet); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + if ( array != 0 ) + { + free(array); + array = 0; + maxkp = numkp = 0; + lasttime = 0; + } + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( (tipindex= chainActive.Tip()) == 0 || tipindex->GetHeight()+1 > nHeight ) + { + fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); + return(0); + } + counter++; + if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) + { + fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + continue; + } + CAmount nValue = out.tx->vout[out.i].nValue; + if ( nValue < COIN || !out.fSpendable ) + continue; + const CScript& pk = out.tx->vout[out.i].scriptPubKey; + if ( ExtractDestination(pk,address) != 0 ) + { + if ( IsMine(*pwalletMain,address) == 0 ) + continue; + if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) + { + array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); + //fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); + } + } + } + lasttime = (uint32_t)time(NULL); +//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); + } +//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); + block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; + for (i=winners=0; iGetHeight()+1 > nHeight ) + { + fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); + return(0); + } + kp = &array[i]; + if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) + continue; + eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); +//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); + if ( eligible > 0 ) + { + besttime = m = 0; + if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + { + while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + { + besttime = eligible; + eligible--; + if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier + break; + m++; +//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); + } + } + else + { + fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); + continue; + } + eligible = besttime; + winners++; +//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); + if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) + { + earliest = eligible; + best_scriptPubKey = kp->scriptPubKey; //out.tx->vout[out.i].scriptPubKey; + *utxovaluep = (uint64_t)kp->nValue; + //decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); + decode_hex((uint8_t *)utxotxidp,32,(char *)kp->txid.GetHex().c_str()); + *utxovoutp = kp->vout; + *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; + fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); + } + } //else fprintf(stderr,"utxo not eligible\n"); + } + if ( numkp < 1000 && array != 0 ) + { + free(array); + array = 0; + maxkp = numkp = 0; + lasttime = 0; + } + if ( earliest != 0 ) + { + bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; + auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); + const CKeyStore& keystore = *pwalletMain; + txNew.vin.resize(1); + txNew.vout.resize(1); + txfee = 0; + for (i=0; i<32; i++) + ((uint8_t *)&revtxid)[i] = ((uint8_t *)utxotxidp)[31 - i]; + txNew.vin[0].prevout.hash = revtxid; + txNew.vin[0].prevout.n = *utxovoutp; + txNew.vout[0].scriptPubKey = best_scriptPubKey;// CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].nValue = *utxovaluep - txfee; + txNew.nLockTime = earliest; + CTransaction txNewConst(txNew); + signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); + if (!signSuccess) + fprintf(stderr,"failed to create signature\n"); + else + { + UpdateTransaction(txNew,0,sigdata); + ptr = (uint8_t *)&sigdata.scriptSig[0]; + siglen = sigdata.scriptSig.size(); + for (i=0; i)> validBlock = #ifdef ENABLE_WALLET - [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams, &breakLoop] + [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams] #else [&pblock, &hashTarget, &m_cs, &cancelSolver, &chainparams] #endif @@ -1683,8 +1682,6 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); - if ( ASSETCHAINS_STAKED != 0 ) - breakLoop = true; return(false); } KOMODO_CHOSEN_ONE = 1; @@ -1715,8 +1712,6 @@ void static BitcoinMiner() std::lock_guard lock{m_cs}; return cancelSolver; }; - if (breakLoop) - break; // TODO: factor this out into a function with the same API for each solver. if (solver == "tromp" ) { //&& notaryid >= 0 ) { // Create solver and initialize it. diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c8b747dc7..710210a80 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4218,7 +4218,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) } if ( toSapling && ASSETCHAINS_SYMBOL[0] == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER,"Sprout usage will expire soon"); - + // If we are sending from a shielded address, all recipient // shielded addresses must be of the same type. if ((fromSprout && toSapling) || (fromSapling && toSprout)) { @@ -5109,9 +5109,6 @@ UniValue z_listoperationids(const UniValue& params, bool fHelp) #include "script/sign.h" int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); extern std::string NOTARY_PUBKEY; -uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 hash,int32_t n,uint32_t blocktime,uint32_t prevtime,char *destaddr); -int8_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256 txid,int32_t vout); -void komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { @@ -5192,247 +5189,6 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) return(siglen); } -struct komodo_staking -{ - char address[64]; - uint256 txid; - arith_uint256 hashval; - uint64_t nValue; - uint32_t segid32,txtime; - int32_t vout; - CScript scriptPubKey; -}; - -struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numkp,int32_t *maxkp,uint32_t txtime,uint64_t nValue,uint256 txid,int32_t vout,char *address,uint8_t *hashbuf,CScript pk) -{ - uint256 hash; uint32_t segid32; struct komodo_staking *kp; - segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); - if ( *numkp >= *maxkp ) - { - *maxkp += 1000; - array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp)); - //fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array); - } - kp = &array[(*numkp)++]; - //fprintf(stderr,"kp.%p num.%d\n",kp,*numkp); - memset(kp,0,sizeof(*kp)); - strcpy(kp->address,address); - kp->txid = txid; - kp->vout = vout; - kp->hashval = UintToArith256(hash); - kp->txtime = txtime; - kp->segid32 = segid32; - kp->nValue = nValue; - kp->scriptPubKey = pk; - return(array); -} - -arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) -{ - int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; - diff = (iter + blocktime - kp->txtime - minage); - if ( diff < 0 ) - diff = 60; - else if ( diff > 3600*24*30 ) - diff = 3600*24*30; - if ( iter > 0 ) - diff += segid*2; - coinage = ((uint64_t)kp->nValue * diff); - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); - coinage256 = arith_uint256(coinage+1); - hashval = ratio * (kp->hashval / coinage256); - return(hashval); -} - -uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komodo_staking *kp,int32_t nHeight,uint32_t blocktime,uint32_t prevtime,int32_t minage,uint8_t *hashbuf) -{ - int32_t maxiters = 600; uint256 hash; - int32_t segid,iter,diff; uint64_t coinage; arith_uint256 hashval,coinage256; - komodo_stakehash(&hash,kp->address,hashbuf,kp->txid,kp->vout); - kp->hashval = UintToArith256(hash); - segid = ((nHeight + kp->segid32) & 0x3f); - hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - //for (int i=32; i>=0; i--) - // fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - //fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - for (iter=0; itertxtime+minage ) - continue; - hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); - blocktime += iter; - blocktime += segid * 2; - return(blocktime); - } - } - } else fprintf(stderr,"maxiters is not good enough\n"); - return(0); -} - -int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) -{ - static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; - set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; - if (!EnsureWalletIsAvailable(0)) - return 0; - - bnTarget.SetCompact(nBits, &fNegative, &fOverflow); - mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - ratio = (mindiff / bnTarget); - assert(pwalletMain != NULL); - LOCK2(cs_main, pwalletMain->cs_wallet); - *utxovaluep = 0; - memset(utxotxidp,0,sizeof(*utxotxidp)); - memset(utxovoutp,0,sizeof(*utxovoutp)); - memset(utxosig,0,72); - pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - if ( (tipindex= chainActive.Tip()) == 0 ) - return(0); - nHeight = tipindex->GetHeight() + 1; - if ( (minage= nHeight*3) > 6000 ) // about 100 blocks - minage = 6000; - komodo_segids(hashbuf,nHeight-101,100); - if ( *blocktimep < tipindex->nTime+60 ) - *blocktimep = tipindex->nTime+60; - //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); - if ( time(NULL) > lasttime+600 || array == 0 ) - { - if ( array != 0 ) - { - free(array); - array = 0; - maxkp = numkp = 0; - lasttime = 0; - } - BOOST_FOREACH(const COutput& out, vecOutputs) - { - if ( (tipindex= chainActive.Tip()) == 0 || tipindex->GetHeight()+1 > nHeight ) - { - fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); - return(0); - } - counter++; - if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) - { - fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); - continue; - } - CAmount nValue = out.tx->vout[out.i].nValue; - if ( nValue < COIN || !out.fSpendable ) - continue; - const CScript& pk = out.tx->vout[out.i].scriptPubKey; - if ( ExtractDestination(pk,address) != 0 ) - { - if ( IsMine(*pwalletMain,address) == 0 ) - continue; - if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) - { - array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); - //fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); - } - } - } - lasttime = (uint32_t)time(NULL); -//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); - } -//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); - block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; - for (i=winners=0; iGetHeight()+1 > nHeight ) - { - fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); - return(0); - } - kp = &array[i]; - if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) - continue; - eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); -//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); - if ( eligible > 0 ) - { - besttime = m = 0; - if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) - { - while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) - { - besttime = eligible; - eligible--; - if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier - break; - m++; -//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); - } - } - else - { - fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); - continue; - } - eligible = besttime; - winners++; -//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); - if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) - { - earliest = eligible; - best_scriptPubKey = kp->scriptPubKey; //out.tx->vout[out.i].scriptPubKey; - *utxovaluep = (uint64_t)kp->nValue; - //decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); - decode_hex((uint8_t *)utxotxidp,32,(char *)kp->txid.GetHex().c_str()); - *utxovoutp = kp->vout; - *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; - fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); - } - } //else fprintf(stderr,"utxo not eligible\n"); - } - if ( numkp < 1000 && array != 0 ) - { - free(array); - array = 0; - maxkp = numkp = 0; - lasttime = 0; - } - if ( earliest != 0 ) - { - bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; - auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - const CKeyStore& keystore = *pwalletMain; - txNew.vin.resize(1); - txNew.vout.resize(1); - txfee = 0; - for (i=0; i<32; i++) - ((uint8_t *)&revtxid)[i] = ((uint8_t *)utxotxidp)[31 - i]; - txNew.vin[0].prevout.hash = revtxid; - txNew.vin[0].prevout.n = *utxovoutp; - txNew.vout[0].scriptPubKey = best_scriptPubKey;// CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; - txNew.vout[0].nValue = *utxovaluep - txfee; - txNew.nLockTime = earliest; - CTransaction txNewConst(txNew); - signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); - if (!signSuccess) - fprintf(stderr,"failed to create signature\n"); - else - { - UpdateTransaction(txNew,0,sigdata); - ptr = (uint8_t *)&sigdata.scriptSig[0]; - siglen = sigdata.scriptSig.size(); - for (i=0; iVerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig, pk); From 6a2e2b414c281633fb371dcc89431946b1f2150d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Dec 2018 23:36:00 +0800 Subject: [PATCH 0826/3904] Fix lockups with ram staker! --- src/miner.cpp | 527 +++++++++++++++++++++++++------------------------- 1 file changed, 264 insertions(+), 263 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index d68c0d192..ab0630e6f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -200,286 +200,288 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, boost::optional cheatSpend; uint256 cbHash; - CBlockIndex* pindexPrev = 0; + SaplingMerkleTree sapling_tree; uint64_t commission; + int nHeight = 0; + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + + CBlockIndex* pindexPrev = chainActive.LastTip();; { - LOCK2(cs_main, mempool.cs); - pindexPrev = chainActive.LastTip(); - const int nHeight = pindexPrev->GetHeight() + 1; - const Consensus::Params &consensusParams = chainparams.GetConsensus(); - uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); - bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); + { // contain lock to block generation and not staking loops. + LOCK2(cs_main, mempool.cs); + nHeight = pindexPrev->GetHeight() + 1; + uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); + bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); - const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - { - // too fast or stuck, this addresses the too fast issue, while moving - // forward as quickly as possible - for (int i; i < 100; i++) + const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + uint32_t proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) { - proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - MilliSleep(10); - } - } - pblock->nTime = GetAdjustedTime(); - - CCoinsViewCache view(pcoinsTip); - uint32_t expired; uint64_t commission; - - SaplingMerkleTree sapling_tree; - assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); - - // Priority order to process transactions - list vOrphan; // list memory doesn't move - map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); - - // This vector will be sorted into a priority queue: - vector vecPriority; - vecPriority.reserve(mempool.mapTx.size() + 1); - - // now add transactions from the mem pool - for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) - { - const CTransaction& tx = mi->GetTx(); - - int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) - ? nMedianTimePast - : pblock->GetBlockTime(); - - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) - { - //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); - continue; - } - - if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) - { - //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); - continue; - } - - COrphan* porphan = NULL; - double dPriority = 0; - CAmount nTotalIn = 0; - bool fMissingInputs = false; - bool fNotarisation = false; - if (tx.IsCoinImport()) - { - CAmount nValueIn = GetCoinImportValue(tx); - nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier - } else { - int numNotaryVins = 0; bool fToCryptoAddress = false; - if ( komodo_is_notarytx(tx) == 1 ) - fToCryptoAddress = true; - - BOOST_FOREACH(const CTxIn& txin, tx.vin) + // too fast or stuck, this addresses the too fast issue, while moving + // forward as quickly as possible + for (int i; i < 100; i++) { - // Read prev transaction - if (!view.HaveCoins(txin.prevout.hash)) - { - // This should never happen; all transactions in the memory - // pool should connect to either transactions in the chain - // or other transactions in the memory pool. - if (!mempool.mapTx.count(txin.prevout.hash)) - { - LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); - fMissingInputs = true; - if (porphan) - vOrphan.pop_back(); - break; - } + proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + MilliSleep(10); + } + } + pblock->nTime = GetAdjustedTime(); - // Has to wait for dependencies - if (!porphan) - { - // Use list for automatic deletion - vOrphan.push_back(COrphan(&tx)); - porphan = &vOrphan.back(); - } - mapDependers[txin.prevout.hash].push_back(porphan); - porphan->setDependsOn.insert(txin.prevout.hash); - nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; - continue; - } - const CCoins* coins = view.AccessCoins(txin.prevout.hash); - assert(coins); + CCoinsViewCache view(pcoinsTip); + uint32_t expired; - CAmount nValueIn = coins->vout[txin.prevout.n].nValue; + assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); + + // Priority order to process transactions + list vOrphan; // list memory doesn't move + map > mapDependers; + bool fPrintPriority = GetBoolArg("-printpriority", false); + + // This vector will be sorted into a priority queue: + vector vecPriority; + vecPriority.reserve(mempool.mapTx.size() + 1); + + // now add transactions from the mem pool + for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); + mi != mempool.mapTx.end(); ++mi) + { + const CTransaction& tx = mi->GetTx(); + + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) + ? nMedianTimePast + : pblock->GetBlockTime(); + + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) + { + //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); + continue; + } + + if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) + { + //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); + continue; + } + + COrphan* porphan = NULL; + double dPriority = 0; + CAmount nTotalIn = 0; + bool fMissingInputs = false; + bool fNotarisation = false; + if (tx.IsCoinImport()) + { + CAmount nValueIn = GetCoinImportValue(tx); nTotalIn += nValueIn; + dPriority += (double)nValueIn * 1000; // flat multiplier + } else { + int numNotaryVins = 0; bool fToCryptoAddress = false; + if ( komodo_is_notarytx(tx) == 1 ) + fToCryptoAddress = true; - int nConf = nHeight - coins->nHeight; - - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) + BOOST_FOREACH(const CTxIn& txin, tx.vin) { - uint256 hash; CTransaction tx1; CTxDestination address; - if (GetTransaction(txin.prevout.hash,tx1,hash,false)) + // Read prev transaction + if (!view.HaveCoins(txin.prevout.hash)) { - if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { - for (int i = 0; i < NUM_NOTARIES; i++) { + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) + { + LogPrintf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; + } + + // Has to wait for dependencies + if (!porphan) + { + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); + } + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; + continue; + } + const CCoins* coins = view.AccessCoins(txin.prevout.hash); + assert(coins); + + CAmount nValueIn = coins->vout[txin.prevout.n].nValue; + nTotalIn += nValueIn; + + int nConf = nHeight - coins->nHeight; + + // This is to test is a tx is a notarisation and assign it max priotity. + if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { + uint256 hash; CTransaction tx1; CTxDestination address; + if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) + { + for (int i = 0; i < NUM_NOTARIES; i++) if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) numNotaryVins++; - } + } + } + dPriority += (double)nValueIn * nConf; + } + if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) + fNotarisation = true; + nTotalIn += tx.GetShieldedValueIn(); + } + + if (fMissingInputs) continue; + + // Priority is sum(valuein * age) / modified_txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority = tx.ComputePriority(dPriority, nTxSize); + + uint256 hash = tx.GetHash(); + mempool.ApplyDeltas(hash, dPriority, nTotalIn); + + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + + if (fNotarisation) { + dPriority = 1e16; + fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); + } + + if (porphan) + { + porphan->dPriority = dPriority; + porphan->feeRate = feeRate; + } + else + vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + } + + // Collect transactions into block + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int64_t interest; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); + + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& tx = *(vecPriority.front().get<2>()); + + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx + { + //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); + continue; + } + + // Legacy limits on sigOps: + unsigned int nTxSigOps = GetLegacySigOpCount(tx); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Skip free transactions if we're past the minimum block size: + const uint256& hash = tx.GetHash(); + double dPriorityDelta = 0; + CAmount nFeeDelta = 0; + mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); + if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + { + //fprintf(stderr,"fee rate skip\n"); + continue; + } + // Prioritise by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } + + if (!view.HaveInputs(tx)) + { + //fprintf(stderr,"dont have inputs\n"); + continue; + } + CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); + + nTxSigOps += GetP2SHSigOpCount(tx, view); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Note that flags: we don't want to set mempool/IsStandard() + // policy here, but we still have to ensure that the block we + // create only contains transactions that are valid in new blocks. + CValidationState state; + PrecomputedTransactionData txdata(tx); + if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + { + //fprintf(stderr,"context failure\n"); + continue; + } + UpdateCoins(tx, view, nHeight); + + BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { + sapling_tree.append(outDescription.cm); + } + + // Added + pblock->vtx.push_back(tx); + pblocktemplate->vTxFees.push_back(nTxFees); + pblocktemplate->vTxSigOps.push_back(nTxSigOps); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fPrintPriority) + { + LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); + } + + // Add transactions that depend on this one to the priority queue + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + { + if (!porphan->setDependsOn.empty()) + { + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) + { + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); } } } - dPriority += (double)nValueIn * nConf; - } - if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) - fNotarisation = true; - nTotalIn += tx.GetShieldedValueIn(); - } - - if (fMissingInputs) continue; - - // Priority is sum(valuein * age) / modified_txsize - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - dPriority = tx.ComputePriority(dPriority, nTxSize); - - uint256 hash = tx.GetHash(); - mempool.ApplyDeltas(hash, dPriority, nTotalIn); - - CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - - if (fNotarisation) { - dPriority = 1e16; - fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); - } - - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; - } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); - } - - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); - - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - - while (!vecPriority.empty()) - { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); - - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx - { - //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); - continue; - } - - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); - - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } - - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; - - if (fPrintPriority) - { - LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); - } - - // Add transactions that depend on this one to the priority queue - if (mapDependers.count(hash)) - { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) - { - if (!porphan->setDependsOn.empty()) - { - porphan->setDependsOn.erase(hash); - if (porphan->setDependsOn.empty()) - { - vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); - std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - } } } - } - nLastBlockTx = nBlockTx; - nLastBlockSize = nBlockSize; - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - //pblock->nTime = blocktime + 1; - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + //pblock->nTime = blocktime + 1; + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); + + } // contain lock to block generation only! int32_t stakeHeight = chainActive.Height() + 1; @@ -523,7 +525,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } - // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); txNew.vin.resize(1); From ce8f41325a00a9b131977f42e190f051ed5c09fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 19 Dec 2018 00:53:05 +0800 Subject: [PATCH 0827/3904] this is fine --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8b8f52935..0a9efe6ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4724,7 +4724,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); // Copy all non Z-txs in mempool to temporary mempool because there can be tx in local mempool that make the block invalid. - LOCK2(cs_main,mempool.cs); + LOCK(mempool.cs); //fprintf(stderr, "starting... mempoolsize.%ld\n",mempool.size()); list transactionsToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { From b3837525ee282e12144c868edcdd5fbce9ceb2ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 18 Dec 2018 09:00:04 -1100 Subject: [PATCH 0828/3904] New migrate --- .gitignore | 2 + src/cc/dapps/zmigrate.c | 86 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 01e45a168..cd2641c22 100644 --- a/.gitignore +++ b/.gitignore @@ -124,3 +124,5 @@ src/komodo-tx.exe #output during builds, symbol tables? *.dSYM + +src/cryptoconditions/compile diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index d492163c4..441b51b19 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -647,6 +647,25 @@ int64_t z_getbalance(char *refcoin,char *acname,char *coinaddr) return (amount); } +int32_t z_exportkey(char *privkey,char *refcoin,char *acname,char *zaddr) +{ + cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; + privkey[0] = 0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_exportkey",zaddr,"","","")) != 0 ) + { + fprintf(stderr,"z_exportkey.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + return(-1); + } + else if ( retstr != 0 ) + { + //printf("retstr %s -> %.8f\n",retstr,dstr(amount)); + strcpy(privkey,retstr); + free(retstr); + return(0); + } +} + int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) { cJSON *retjson; char *retstr; int64_t amount=0; @@ -664,6 +683,23 @@ int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) } } +int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname,char *typestr) +{ + cJSON *retjson; char *retstr; int64_t amount=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","")) != 0 ) + { + fprintf(stderr,"z_getnewaddress.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + return(-1); + } + else if ( retstr != 0 ) + { + strcpy(coinaddr,retstr); + free(retstr); + return(0); + } +} + int64_t find_onetime_amount(char *coinstr,char *coinaddr) { cJSON *array,*item; int32_t i,n; char *addr; int64_t amount = 0; @@ -751,6 +787,39 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char * } } +int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr) +{ + cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; + sprintf(addr,"[\\\"ANY_SPROUT\\\"]"); + //printf("z_sendmany from.(%s) -> %s\n",addr,destaddr); + if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) + { + /*{ + "remainingUTXOs": 0, + "remainingTransparentValue": 0.00000000, + "remainingNotes": 222, + "remainingShieldedValue": 5413.39093055, + "mergingUTXOs": 0, + "mergingTransparentValue": 0.00000000, + "mergingNotes": 10, + "mergingShieldedValue": 822.47447172, + "opid": "opid-f28f6261-4120-436c-aca5-859870a40a70" + }*/ + if ( (opstr= jstr(retjson,"opid")) != 0 ) + strcpy(opidstr,opstr); + retval = jint(retjson,"remainingNotes"); + fprintf(stderr,"%s\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_mergetoaddress.(%s) -> opid.(%s)\n",coinstr,retstr); + strcpy(opidstr,retstr); + free(retstr); + } + return(retval); +} + int32_t empty_mempool(char *coinstr,char *acname) { cJSON *array; int32_t n; @@ -907,10 +976,25 @@ int32_t main(int32_t argc,char **argv) } zsaddr = clonestr(argv[2]); printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr); - uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; + uint32_t lastopid; char coinaddr[64],privkey[1024],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; //stdamount = 500 * SATOSHIDEN; txfee = 10000; again: + if ( z_getnewaddress(zcaddr,coinstr,"","sprout") == 0 ) + { + z_exportkey(privkey,coinstr,"",zcaddr); + printf("zcaddr.(%s) -> z_exportkey.(%s)\n",zcaddr,privkey); + while ( 1 ) + { + if ( have_pending_opid(coinstr,0) != 0 ) + { + sleep(10); + continue; + } + if ( z_mergetoaddress(opidstr,coinstr,"",zcaddr) <= 0 ) + break; + } + } printf("start processing zmigrate\n"); lastopid = (uint32_t)time(NULL); finished = 0; From 261dfbcead4d3e0caca2b014feb6a109be00a2e5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 19 Dec 2018 17:22:44 +0800 Subject: [PATCH 0829/3904] fix staking crash on shutdown. fix segid in block index. --- src/komodo_bitcoind.h | 18 +++++++++++++----- src/rpc/blockchain.cpp | 19 ++++--------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ef915f06c..c427897af 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -26,7 +26,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); bool EnsureWalletIsAvailable(bool avoidException); - +extern bool fRequestShutdown; //#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr)) struct MemoryStruct { char *memory; size_t size; }; @@ -1462,7 +1462,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ if ( slowflag != 0 && pindex != 0 ) { pindex->segid = -1; - fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } } else @@ -1470,11 +1470,17 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ isPoS = 2; // 2 means staking utxo validated if ( slowflag != 0 && height > 100 ) { - segid = -3; - if ( pindex != 0 && pindex->segid == -2 && (segid= komodo_segid(1,height)) >= 0 ) + CTxDestination voutaddress; char voutaddr[64]; + if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) + { + strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + segid = komodo_segid32(voutaddr) & 0x3f; + //fprintf(stderr,"komodo_segid.(%d) -> %d\n",height,segid); + } + if ( pindex != 0 && segid >= 0 ) { pindex->segid = segid; - fprintf(stderr,"B set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"B set segid.%d <- %d\n",height,pindex->segid); } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } } @@ -2125,6 +2131,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; iGetHeight()+1 > nHeight ) { fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index f2bf20e3e..849391e18 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -639,23 +639,12 @@ UniValue getlastsegidstakes(const UniValue& params, bool fHelp) for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) { CBlockIndex* pblockindex = chainActive[i]; - CBlock block; - if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + //if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + // throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - if(!ReadBlockFromDisk(block, pblockindex,1)) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - - if ( komodo_isPoS((CBlock *)&block) != 0 ) - { - CTxDestination voutaddress; int32_t segid; - if ( ExtractDestination(block.vtx[block.vtx.size()-1].vout[0].scriptPubKey,voutaddress) ) - { - segid = (int32_t)komodo_segid32((char *)CBitcoinAddress(voutaddress).ToString().c_str()) & 0x3f; - segids[segid] += 1; - } - } + if ( pblockindex->segid >= 0 ) + segids[pblockindex->segid] += 1; } UniValue ret(UniValue::VOBJ); From 97658a0c03a35073bdfe45f3922e05af1ed3ea6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 19 Dec 2018 09:03:54 -1100 Subject: [PATCH 0830/3904] z_mergetoaddress fix --- src/wallet/rpcwallet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f8b507403..f431bce81 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4789,9 +4789,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (useAnySprout || useAnySapling || zaddrs.size() > 0) { // Get available notes std::vector sproutEntries; - std::vector saplingEntries; - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs); - + //std::vector saplingEntries; + //pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs); + std::vector saplingEntries,skipsapling; + pwalletMain->GetFilteredNotes(sproutEntries, useAnySprout == 0 ? saplingEntries : skipsapling, zaddrs); + // If Sapling is not active, do not allow sending from a sapling addresses. if (!saplingActive && saplingEntries.size() > 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); From 93f18db31afd9afb3103c89b3118c3932e7ab43e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 19 Dec 2018 09:25:38 -1100 Subject: [PATCH 0831/3904] Skip unspendable addresses in migrate --- src/cc/dapps/zmigrate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 441b51b19..6fa3c3cc8 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -712,6 +712,10 @@ int64_t find_onetime_amount(char *coinstr,char *coinaddr) for (i=0; i Date: Thu, 20 Dec 2018 19:56:00 +0800 Subject: [PATCH 0832/3904] fix mempool fix, to allow adding transactions out of order. --- src/main.cpp | 47 ++++++++++++++++++++++-------------------- src/rpc/blockchain.cpp | 4 ---- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0a9efe6ea..98ed24c3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1645,6 +1645,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if ( nextBlockHeight <= 1 || chainActive.LastTip() == 0 ) tiptime = (uint32_t)time(NULL); else tiptime = (uint32_t)chainActive.LastTip()->nTime; + + // is it already in the memory pool? + uint256 hash = tx.GetHash(); + if (pool.exists(hash)) + { + //fprintf(stderr,"already in mempool\n"); + return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); + } + // Node operator can choose to reject tx by number of transparent inputs static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "size_t too small"); size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); @@ -1683,7 +1692,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // Rather not work on nonstandard transactions (unless -testnet/-regtest) string reason; - if (Params().RequireStandard() && !IsStandardTx(tx, reason, nextBlockHeight)) + if (!fSkipExpiry && Params().RequireStandard() && !IsStandardTx(tx, reason, nextBlockHeight)) { // //fprintf(stderr,"AcceptToMemoryPool reject nonstandard transaction: %s\nscriptPubKey: %s\n",reason.c_str(),tx.vout[0].scriptPubKey.ToString().c_str()); @@ -1692,21 +1701,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Only accept nLockTime-using transactions that can be mined in the next // block; we don't want our mempool filled up with transactions that can't // be mined yet. - if (!CheckFinalTx(tx, STANDARD_LOCKTIME_VERIFY_FLAGS)) + if (!fSkipExpiry && !CheckFinalTx(tx, STANDARD_LOCKTIME_VERIFY_FLAGS)) { //fprintf(stderr,"AcceptToMemoryPool reject non-final\n"); return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); } - // is it already in the memory pool? - uint256 hash = tx.GetHash(); - if (pool.exists(hash)) - { - //fprintf(stderr,"already in mempool\n"); - return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); - } - // Check for conflicts with in-memory transactions + if (!fSkipExpiry) { LOCK(pool.cs); // protect pool.mapNextTx for (unsigned int i = 0; i < tx.vin.size(); i++) @@ -1756,7 +1758,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (ExistsImportTombstone(tx, view)) return state.Invalid(false, REJECT_DUPLICATE, "import tombstone exists"); } - else + else if (!fSkipExpiry) { // do all inputs exist? // Note that this does not check for the presence of actual outputs (see the next check for that), @@ -1768,10 +1770,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (pfMissingInputs) *pfMissingInputs = true; //fprintf(stderr,"missing inputs\n"); - if (!fSkipExpiry) - return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); - else - return(false); + return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); } } @@ -1779,10 +1778,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (!view.HaveInputs(tx)) { //fprintf(stderr,"accept failure.1\n"); - if (!fSkipExpiry) - return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); - else - return(false); + return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); } } // are the joinsplit's requirements met? @@ -1826,7 +1822,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; - if (!tx.IsCoinImport()) { + if (!fSkipExpiry && !tx.IsCoinImport()) { BOOST_FOREACH(const CTxIn &txin, tx.vin) { const CCoins *coins = view.AccessCoins(txin.prevout.hash); if (coins->IsCoinBase()) { @@ -1901,7 +1897,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) { //fprintf(stderr,"accept failure.9\n"); return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString()); @@ -1922,7 +1918,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa flag = 1; KOMODO_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1; } - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) { if ( flag != 0 ) KOMODO_CONNECTING = -1; @@ -4719,6 +4715,9 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // Check transactions CTransaction sTx; CTransaction *ptx = NULL; + if ( ASSETCHAINS_CC != 0 && !fCheckPOW ) + return true; + if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { int32_t i,j,rejects=0,lastrejects=0; @@ -4788,6 +4787,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (!CheckTransaction(tiptime,tx, state, verifier)) return error("CheckBlock: CheckTransaction failed"); } + unsigned int nSigOps = 0; BOOST_FOREACH(const CTransaction& tx, block.vtx) { @@ -7018,6 +7018,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if (strCommand == "tx") { + if (IsInitialBlockDownload()) + return true; + vector vWorkQueue; vector vEraseQueue; CTransaction tx; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 849391e18..c5da4ed40 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -639,10 +639,6 @@ UniValue getlastsegidstakes(const UniValue& params, bool fHelp) for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) { CBlockIndex* pblockindex = chainActive[i]; - - //if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - // throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - if ( pblockindex->segid >= 0 ) segids[pblockindex->segid] += 1; } From 5a09ff96c55cb456ce4f1f1cff92360d85078a89 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 20 Dec 2018 23:56:33 +0800 Subject: [PATCH 0833/3904] fix --- src/wallet/rpcwallet.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d7cef2700..b36ca6ef7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4809,7 +4809,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) saplingNoteLimit = nNoteLimit; } - std::string memo; CAmount maximum_utxo_size; if (params.size() > 5) { maximum_utxo_size = AmountFromValue( params[5] ); @@ -4879,8 +4878,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) continue; } - CAmount nValue = out.tx->vout[out.i].nValue; - if (maximum_utxo_size != 0) { if (nValue > maximum_utxo_size) { continue; From 2a606443239ea9b521eaa34b9e30e0e8a3782e70 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 20 Dec 2018 23:58:26 +0800 Subject: [PATCH 0834/3904] fix --- src/wallet/rpcwallet.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b36ca6ef7..5985a63c2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4878,6 +4878,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) continue; } + CAmount nValue = out.tx->vout[out.i].nValue; + if (maximum_utxo_size != 0) { if (nValue > maximum_utxo_size) { continue; @@ -4936,7 +4938,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) // Find unspent notes and update estimated size for (const CSproutNotePlaintextEntry& entry : sproutEntries) { noteCounter++; - CAmount nValue = entry.plaintext.value(); + nValue = entry.plaintext.value(); if (!maxedOutNotesFlag) { // If we haven't added any notes yet and the merge is to a @@ -4963,7 +4965,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) for (const SaplingNoteEntry& entry : saplingEntries) { noteCounter++; - CAmount nValue = entry.note.value(); + nValue = entry.note.value(); if (!maxedOutNotesFlag) { size_t increase = SPENDDESCRIPTION_SIZE; if (estimatedTxSize + increase >= max_tx_size || From 66bac37186273817ca4972562a07ec87249eb055 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Dec 2018 00:00:11 +0800 Subject: [PATCH 0835/3904] fixed --- src/wallet/rpcwallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5985a63c2..07761f339 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4891,7 +4891,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } utxoCounter++; - CAmount nValue = out.tx->vout[out.i].nValue; if (!maxedOutUTXOsFlag) { size_t increase = (boost::get(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; if (estimatedTxSize + increase >= max_tx_size || @@ -4938,7 +4937,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) // Find unspent notes and update estimated size for (const CSproutNotePlaintextEntry& entry : sproutEntries) { noteCounter++; - nValue = entry.plaintext.value(); + CAmount nValue = entry.plaintext.value(); if (!maxedOutNotesFlag) { // If we haven't added any notes yet and the merge is to a @@ -4965,7 +4964,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) for (const SaplingNoteEntry& entry : saplingEntries) { noteCounter++; - nValue = entry.note.value(); + CAmount nValue = entry.note.value(); if (!maxedOutNotesFlag) { size_t increase = SPENDDESCRIPTION_SIZE; if (estimatedTxSize + increase >= max_tx_size || From 254467774ea75c77c488852414b4d3c003736bda Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Fri, 21 Dec 2018 01:12:53 +0300 Subject: [PATCH 0836/3904] KSB --- src/ac/ksb | 2 + src/assetchains.json | 11 +- src/assetchains.old | 1 + src/fiat/ksb | 2 + src/fundnotaries | 705 ------------------------------------------- 5 files changed, 15 insertions(+), 706 deletions(-) create mode 100755 src/ac/ksb create mode 100755 src/fiat/ksb delete mode 100755 src/fundnotaries diff --git a/src/ac/ksb b/src/ac/ksb new file mode 100755 index 000000000..450c3b3f6 --- /dev/null +++ b/src/ac/ksb @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=KSB $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index 1a0ae25e2..1b23bc616 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -215,5 +215,14 @@ "addnode": [ "5.9.102.210" ] - } + }, + { + "ac_name": "KSB", + "ac_supply": "1000000000", + "ac_end": "1", + "ac_public": "1", + "addnode": [ + "37.187.225.231" + ] + } ] diff --git a/src/assetchains.old b/src/assetchains.old index 6df854903..ede6c3e23 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -45,3 +45,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KMDICE -ac_supply=10500000 -ac_reward=2500000000 -ac_halving=210000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=144.76.217.232 & ./komodod -pubkey=$pubkey -ac_name=DION -ac_supply=3900000000 -ac_reward=22260000000 -ac_staked=100 -ac_cc=1 -ac_end=4300000000 -addnode=51.75.124.34 & ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & +./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 diff --git a/src/fiat/ksb b/src/fiat/ksb new file mode 100755 index 000000000..450c3b3f6 --- /dev/null +++ b/src/fiat/ksb @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=KSB $1 $2 $3 $4 $5 $6 diff --git a/src/fundnotaries b/src/fundnotaries deleted file mode 100755 index cd6841966..000000000 --- a/src/fundnotaries +++ /dev/null @@ -1,705 +0,0 @@ -./komodo-cli -ac_name=REVS sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=REVS sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=SUPERNET sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=DEX sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=PANGEA sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=JUMBLR sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=BET sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=BET sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=BET sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=BET sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=BET sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=BET sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=CRYPTO sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=HODL sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=SHARK sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=BOTS sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RHPGxpiwRHP4dKZXjYPdpon1nCto7qVE8s 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RLQoAcs1RaqW1xfN2NJwoZWW5twexPhuGB 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RXF3aHUaWDUY4fRRYmBNALoHWkgSQCiJ4f 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RL2SkPSCGMvcHqZ56ErfMxbQGdA4nk7MZp 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RFssbc211PJdVy1bvcvAG5X2N4ovPAoy5o 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RNoz2DKPZ2ppMxgYx5tce9sjZBHefvPvNB 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RVxtoUT9CXbC1LdhztNAf9yR5ySnFnSPQh 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress R9XBrbj8iKkwy9M4erUqRaBinAiZSTXav3 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RSHdRnHHGdPtVej7fiehHBQ6dyTbEM1GHi 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RDW8EDkCkzQ1LA4xbVUoAERsBVhhYRLXCr 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RAxQTHdsy89tfSXwoce2sHeWrYXmDsMXQq 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RT2k2voy9n8jwppeTTJMQAhvaqA9pc9jHh 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RRvaVyKS59NJWhPp8Pn7mVPGhMuhJJXrdh 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RBpp98VwHx7SFv7dNbw8NY65t14XFq9fVD 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RPjUmFNcWEW9Bu275kPxzRXyWDz6bfQpPD 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RDY2CvzydimY2AtDqSjBAB1eCeogRE55DX 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RUreYvNjhZYc1vP8cND9Cztpni1pYsigXb 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RHv3wyVnnanG2kSQmLNmjwAQeYRRAptxUy 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RLVwuTM5TitV4Gk79Rja731RwYkAzz7GWn 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RHbxwDa7JT1KJLHDKwb5n3gd8NREErqtQY 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RFDAZ1yCvKPmpqcgzg8r2qQJ8nPPgeoMrB 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RHsZesZXMfkdrsSEper3JWUBKwk29JTFfT 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RPJjzoKPb8idoUCT9XLBkNojNgysjJ5qrE 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RFQNjTfcvSAmf8D83og1NrdHj1wH2fc5X4 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RPknkGAHMwUBvfKQfvw9FyatTZzicSiN4y 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RMqbQz4NPNbG15QBwy9EFvLn4NX5Fa7w5g 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RQipE6ycbVVb9vCkhqrK8PGZs2p5YmiBtg 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RCA8H1npFPW5pnJRzycF8tFEJmn6XZhD4j 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RJD5jRidYW9Cu8qxjg9HDCsx6J3A4wQ4LU 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RQMwcDYMVBx9f4QCFfFk31px8QZP4e8uhA 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RXzsovGBQ3W97xnVC6JnWxXsV4qb7p7iBi 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RLHr8gUm2MZ3EEgDU4EmK7bdn5ZsxLYmnt 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RFTsWSzgKRd5Xa7d287w9eRFeYefKBso6Z 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress REuQ7EoxKeMYk4EGptV6EwdfV9LZXuc44g 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RX1tP6ftwe96p6scgJn4dpgNdHDgyg9R87 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RERp696QtNTeWDfBy3x3QbRwPYN2NxwxfA 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RNZKqUgoAPwWd7wNtuSKP7k1HSJAyPeH4N 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress R9jhJCwgT78pyjnkNuxgH3CE8ekxgT8iwB 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RSCQKVUhihKb13rb5VJwXsbSY6pdRPUZ6V 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RDVqM6t5xZw9jbYXEw2CJgkiSbrHBHiKR3 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RSSNgf98kiMGUxs55DvhNnumyxVudd2KQQ 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RXqdRmv7n9hygf9C7f7vj4VQyNR9RvzXss 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RE3P8D8rcWZBeKmT8DURPdezW87MU5Ho3F 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RS3v2u6d4SJ1ujLz7CHNSFLSmxn6Tx6mJp 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RREc88bQzxHCvzqErPDnTQH2Qg5yUtjbyp 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RJ9wAk3ZNrFwdso1RVbwASiqqQaDNyKjd2 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RVKtRKozg8RKvEYCumMD43fCU6f212M5RD 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RCvsbvzCwA1AaxeoYVSL9Q3BdnybEWfXaH 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RXtADsErZLmsGhNyQdW2DekHMGZ23cLrav 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RYGrWs5b8CVFFpxGpjiBaMwfYV9X5UqFaB 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RHASfhhM6bvDFakRDqkzA2wc3V4R4oNmXi 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RATaU3jjn4RwHK61YWoJ4eg7Eggk3puZW8 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RXbb9PkefXcsqq8wqiUZZUuq8e3p29mw1G 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RDY9LJZTEJ9FsvugUuD69gceA98uqan5XL 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress R9tjkpdNbzw6mNfxorb5bvTPmsuon5aLrC 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RT2JyVts5tb1prC7KYykmznrqw7VXJo1HB 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RFHRWQ5pAXNfmudHfxdxw3Wo8yFGoeDn6z 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RTw3vi3dGa9n8LLbKvk7jDAwLdt3A5ET7a 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RQeuhk4KcPM3F5hefwTBWezDdcktSGQQSq 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress R9TGdzN25MgdRkYfsYfxZWzHCLVCyWFAei 0.010000 -./komodo-cli -ac_name=MGW sendtoaddress RDYsrWBZkYSWhRDupGRrfGqrVnFtK9hJGC 0.010000 - From 0f7b6c143894a0865da6e00a73d0488358b05e3b Mon Sep 17 00:00:00 2001 From: SHossain Date: Fri, 21 Dec 2018 15:14:38 +0000 Subject: [PATCH 0837/3904] Update assetchains.old --- src/assetchains.old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index ede6c3e23..136f7c709 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -45,4 +45,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KMDICE -ac_supply=10500000 -ac_reward=2500000000 -ac_halving=210000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=144.76.217.232 & ./komodod -pubkey=$pubkey -ac_name=DION -ac_supply=3900000000 -ac_reward=22260000000 -ac_staked=100 -ac_cc=1 -ac_end=4300000000 -addnode=51.75.124.34 & ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & -./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 +./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & From 292962b36d7ef794fd1e6b1452c303940e3e20b9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 28 Dec 2018 15:42:23 +0800 Subject: [PATCH 0838/3904] Fix flood of send block on chain sync. Make net code to ignore KMD peers for LABS faster. --- src/miner.cpp | 2 ++ src/net.cpp | 33 +++++++++++++++------------------ src/rpc/blockchain.cpp | 2 -- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ab0630e6f..ecf411c5e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -783,6 +783,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, void komodo_broadcast(CBlock *pblock,int32_t limit) { + if (IsInitialBlockDownload()) + return; int32_t n = 1; //fprintf(stderr,"broadcast new block t.%u\n",(uint32_t)time(NULL)); { diff --git a/src/net.cpp b/src/net.cpp index 87abe8e85..9c0683c8e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -63,6 +63,8 @@ namespace { // Global state variables // extern uint16_t ASSETCHAINS_P2PPORT; +extern int8_t is_STAKED(const char *chain_name); +extern char ASSETCHAINS_SYMBOL[65]; bool fDiscover = true; bool fListen = true; @@ -1262,15 +1264,6 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { - extern int8_t is_STAKED(const char *chain_name); - extern char ASSETCHAINS_SYMBOL[65]; - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - return; - } - // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { @@ -1380,22 +1373,20 @@ void ThreadOpenConnections() // Add seed nodes if DNS seeds are all down (an infrastructure attack?). // if (addrman.size() == 0 && (GetTime() - nStart > 60)) { - extern int8_t is_STAKED(const char *chain_name); - extern char ASSETCHAINS_SYMBOL[65]; - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 ) - { - if (GetTime() - nStart > 60) { - static bool done = false; - if (!done) { + if (GetTime() - nStart > 60) { + static bool done = false; + if (!done) { + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 ) { //LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); LogPrintf("Adding fixed seed nodes.\n"); addrman.Add(convertSeed6(Params().FixedSeeds()), CNetAddr("127.0.0.1")); - done = true; } + done = true; } } + // // Choose an address to connect to based on most recently seen // @@ -1802,6 +1793,12 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) Discover(threadGroup); + // skip DNS seeds for staked chains. + extern int8_t is_STAKED(const char *chain_name); + extern char ASSETCHAINS_SYMBOL[65]; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + SoftSetBoolArg("-dnsseed", false); + // // Start threads // diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c5da4ed40..f024215b6 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -607,8 +607,6 @@ UniValue getblockhash(const UniValue& params, bool fHelp) } extern uint64_t ASSETCHAINS_STAKED; -int32_t komodo_isPoS(CBlock *pblock); -uint32_t komodo_segid32(char *coinaddr); UniValue getlastsegidstakes(const UniValue& params, bool fHelp) { From 045afa5dd787db3de5753b965102ecabac1eb84e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 20:08:48 +0800 Subject: [PATCH 0839/3904] fix MoMoM transaction version. --- src/importcoin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index d36943b5d..bc0b6168f 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -10,7 +10,7 @@ CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts) { std::vector payload = E_MARSHAL(ss << EVAL_IMPORTCOIN); - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); mtx.vout = payouts; auto importData = E_MARSHAL(ss << proof; ss << burnTx); @@ -47,7 +47,7 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); - ss >> targetSymbol; + ss >> targetSymbol; ss >> payoutsHash); } @@ -76,7 +76,7 @@ bool VerifyCoinImport(const CScript& scriptSig, TransactionSignatureChecker& che auto pc = scriptSig.begin(); opcodetype opcode; std::vector evalScript; - + auto f = [&] () { if (!scriptSig.GetOp(pc, opcode, evalScript)) return false; From 0de6fd12eed8dea35765e91c98e65fdf2231782c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 20:41:00 +0800 Subject: [PATCH 0840/3904] fix build... disable komodo-tx for now. --- src/Makefile.am | 3 ++- src/importcoin.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 98cc79adf..06ce32b40 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,8 +122,9 @@ TESTS = bin_PROGRAMS += komodod #endif +# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli komodo-tx + bin_PROGRAMS += komodo-cli endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility diff --git a/src/importcoin.cpp b/src/importcoin.cpp index bc0b6168f..71e469423 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -5,10 +5,15 @@ #include "hash.h" #include "script/cc.h" #include "primitives/transaction.h" +#include "core_io.h" +#include "script/sign.h" +#include "wallet/wallet.h" +int32_t komodo_nextheight(); CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts) { + std::vector payload = E_MARSHAL(ss << EVAL_IMPORTCOIN); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); From 8799583cc0f756df48471934e02612792efe7f31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 21:18:45 +0800 Subject: [PATCH 0841/3904] remove rescan for corrupt tx and add LOCK2 for deleteion of staking tx. debug prints. --- src/main.cpp | 1 + src/wallet/walletdb.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 98ed24c3d..d7d6037ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3852,6 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->EraseFromWallet(tx.GetHash()); #endif } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 4dedab834..3bfb40648 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -919,8 +919,13 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. if (strType == "tx" ) + { // Rescan if there is a bad transaction record.. - SoftSetBoolArg("-rescan", true); + //SoftSetBoolArg("-rescan", true); + uint256 hash; + ssKey >> hash; + fprintf(stderr, "TX corrupted hash: %s\n", hash.ToString().c_str()); + } } } if (!strErr.empty()) From abffb831a69c3a17bc9723de58852b6d7307f567 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 21:31:55 +0800 Subject: [PATCH 0842/3904] try this --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d7d6037ba..302a6162a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3852,7 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK(cs_main); pwalletMain->EraseFromWallet(tx.GetHash()); #endif } From 9237e43052743b15adb7ce994bc3d5f1aeca8c63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 21:44:48 +0800 Subject: [PATCH 0843/3904] change tombstone, revert LOCK, problem isnt that. --- src/importcoin.cpp | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 71e469423..3a5ddcc30 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -107,7 +107,7 @@ void AddImportTombstone(const CTransaction &importTx, CCoinsViewCache &inputs, i uint256 burnHash = importTx.vin[0].prevout.hash; CCoinsModifier modifier = inputs.ModifyCoins(burnHash); modifier->nHeight = nHeight; - modifier->nVersion = 1; + modifier->nVersion = 4; modifier->vout.push_back(CTxOut(0, CScript() << OP_0)); } diff --git a/src/main.cpp b/src/main.cpp index 302a6162a..d7d6037ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3852,7 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET - LOCK(cs_main); + LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->EraseFromWallet(tx.GetHash()); #endif } From 0161c77e078fcd3b89739039b987daa86b164193 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Dec 2018 12:31:03 +0800 Subject: [PATCH 0844/3904] Fix createexport transaction. Leave params != to 3, for backwards compatability, third param is now ignored. --- src/rpc/crosschain.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 7d299fc1a..8853b3fb2 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -145,9 +145,9 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 3) + if (fHelp || params.size() != 3 || params.size() != 2) throw runtime_error( - "migrate_converttoexport rawTx dest_symbol export_amount\n" + "migrate_converttoexport rawTx dest_symbol\n" "\nConvert a raw transaction to a cross-chain export.\n" "If neccesary, the transaction should be funded using fundrawtransaction.\n" "Finally, the transaction should be signed using signrawtransaction\n" @@ -174,17 +174,13 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); - CAmount burnAmount = AmountFromValue(params[2]); + CAmount burnAmount = 0; + + for (int i=0; i 1000000LL*COIN) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export, cannot export more than 1 million coins per export."); - { - CAmount needed = 0; - for (int i=0; i Date: Sun, 30 Dec 2018 13:02:43 +0800 Subject: [PATCH 0845/3904] that didnt work. Need to change all scripts! --- src/rpc/crosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 8853b3fb2..98267aae9 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -145,7 +145,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 3 || params.size() != 2) + if (fHelp || params.size() != 2) throw runtime_error( "migrate_converttoexport rawTx dest_symbol\n" "\nConvert a raw transaction to a cross-chain export.\n" From aefee8dada8f76b1243acbf92103c591333c622b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Dec 2018 17:02:37 +0800 Subject: [PATCH 0846/3904] set expiryHeight to 0 for Import TXs --- src/importcoin.cpp | 4 ++-- src/main.cpp | 18 ------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 3a5ddcc30..487954289 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -13,9 +13,10 @@ int32_t komodo_nextheight(); CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts) { - std::vector payload = E_MARSHAL(ss << EVAL_IMPORTCOIN); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + if (mtx.fOverwintered) + mtx.nExpiryHeight = 0; mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); mtx.vout = payouts; auto importData = E_MARSHAL(ss << proof; ss << burnTx); @@ -23,7 +24,6 @@ CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction b return CTransaction(mtx); } - CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts) { std::vector opret = E_MARSHAL(ss << VARINT(targetCCid); diff --git a/src/main.cpp b/src/main.cpp index d7d6037ba..0b878b245 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1489,24 +1489,6 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio } } - if ( ASSETCHAINS_TXPOW != 0 && tx.vjoinsplit.size() == 0 ) - { - // genesis coinbase 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - uint256 txid = tx.GetHash(); - if ( ((ASSETCHAINS_TXPOW & 2) != 0 && iscoinbase != 0) || ((ASSETCHAINS_TXPOW & 1) != 0 && iscoinbase == 0) ) - { - if ( ((uint8_t *)&txid)[0] != 0 || ((uint8_t *)&txid)[31] != 0 ) - { - uint256 genesistxid = uint256S("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"); - if ( txid != genesistxid ) - { - fprintf(stderr,"private chain iscoinbase.%d invalid txpow.%d txid.%s\n",iscoinbase,ASSETCHAINS_TXPOW,txid.GetHex().c_str()); - return state.DoS(100, error("CheckTransaction(): this is a txpow chain, must have 0x00 ends"),REJECT_INVALID, "bad-txns-actxpow-chain"); - } - } - } - } - // Ensure input values do not exceed MAX_MONEY // We have not resolved the txin values at this stage, // but we do know what the joinsplits claim to add From 9a849703c0c69467c9ac6bd9ca2e69a3243fc0a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 31 Dec 2018 18:27:10 +0800 Subject: [PATCH 0847/3904] revert the change here to see if it stops deamons locking up. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 0b878b245..9e7cd3b60 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4706,7 +4706,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); // Copy all non Z-txs in mempool to temporary mempool because there can be tx in local mempool that make the block invalid. - LOCK(mempool.cs); + LOCK2(cs_main,mempool.cs); //fprintf(stderr, "starting... mempoolsize.%ld\n",mempool.size()); list transactionsToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { From 91b6694c71b4c5ebaa2caef34eaf854552fd6bc5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 2 Jan 2019 23:04:26 +0800 Subject: [PATCH 0848/3904] Fix some bugs? Add getimports RPC. --- src/notaries_staked.cpp | 7 ++- src/rpc/crosschain.cpp | 105 ++++++++++++++++++++++++++++++++++++++++ src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/walletdb.cpp | 6 +-- 5 files changed, 115 insertions(+), 5 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e53553b23..8cce14a0b 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -11,14 +11,19 @@ extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { - int STAKED = 0; + static int8_t STAKED,doneinit; + if (doneinit == 1) + return(STAKED); if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; + else + STAKED = 0; //fprintf(stderr, "This chain is: %s which is: %d\n", chain_name,STAKED); + doneinit = 1; return(STAKED); }; diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 98267aae9..3950e48a1 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -307,3 +307,108 @@ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp) out.pushKV("opreturn", HexStr(E_MARSHAL(ss << nota.second))); return out; } + +UniValue getimports(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getmigrates \"hash|height\"\n" + "\n\n" + "\nResult:\n" + "{\n" + " \"imports\" : [ (json array)\n" + " \"transactionid\" : { (json object)\n" + " \"value\" : (numeric)\n" + " \"address\" : (string)\n" + " \"export\" { (json object)\n" + " \"txid\" : (string)\n" + " \"value\" : (numeric)\n" + " \"chain\" : (string)\n" //TODO! + " }\n" + " }" + " ]\n" + " \"TotalImported\" : (numeric)\n" + " \"time\" : (numeric)\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleRpc("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleCli("getmigrates", "12800") + + HelpExampleRpc("getmigrates", "12800") + ); + + LOCK(cs_main); + + std::string strHash = params[0].get_str(); + + // If height is supplied, find the hash + if (strHash.size() < (2 * sizeof(uint256))) { + // std::stoi allows characters, whereas we want to be strict + regex r("[[:digit:]]+"); + if (!regex_match(strHash, r)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + int nHeight = -1; + try { + nHeight = std::stoi(strHash); + } + catch (const std::exception &e) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + if (nHeight < 0 || nHeight > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + } + strHash = chainActive[nHeight]->GetBlockHash().GetHex(); + } + + uint256 hash(uint256S(strHash)); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + UniValue result(UniValue::VOBJ); + CAmount TotalImported; + UniValue imports(UniValue::VARR); + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + if(tx.IsCoinImport()) + { + UniValue objTx(UniValue::VOBJ); + objTx.push_back(Pair("txid",tx.GetHash().ToString())); + TxProof proof; + CTransaction burnTx; + std::vector payouts; + TotalImported += tx.vout[1].nValue; + printf("nvalue.%li TotalImported.%li\n",tx.vout[1].nValue,TotalImported); + objTx.push_back(Pair("amount", ValueFromAmount(tx.vout[1].nValue))); + CTxDestination importaddress; + if (ExtractDestination(tx.vout[1].scriptPubKey, importaddress)) + { + objTx.push_back(Pair("address", CBitcoinAddress(importaddress).ToString())); + } + UniValue objBurnTx(UniValue::VOBJ); + if (UnmarshalImportTx(tx, proof, burnTx, payouts)) { + objBurnTx.push_back(Pair("txid", burnTx.GetHash().ToString())); + objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.size() ? burnTx.vout.back().nValue : 0))); + // TODO: add source chain, using new data in burn OP_RETURN from upsteam. + } + objTx.push_back(Pair("export", objBurnTx)); + imports.push_back(objTx); + } + } + result.push_back(Pair("imports", imports)); + result.push_back(Pair("TotalImported", ValueFromAmount(TotalImported))); + result.push_back(Pair("time", block.GetBlockTime())); + return result; +} diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 800c01423..d1c4d56b9 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -333,6 +333,7 @@ static const CRPCCommand vRPCCommands[] = { "crosschain", "crosschainproof", &crosschainproof, true }, { "crosschain", "getNotarisationsForBlock", &getNotarisationsForBlock, true }, { "crosschain", "scanNotarisationsDB", &scanNotarisationsDB, true }, + { "crosschain", "getimports", &getimports, true }, { "crosschain", "migrate_converttoexport", &migrate_converttoexport, true }, { "crosschain", "migrate_createimporttransaction", &migrate_createimporttransaction, true }, { "crosschain", "migrate_completeimporttransaction", &migrate_completeimporttransaction, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index a49355c88..b1f94701e 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -426,6 +426,7 @@ extern UniValue assetchainproof(const UniValue& params, bool fHelp); extern UniValue crosschainproof(const UniValue& params, bool fHelp); extern UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp); extern UniValue scanNotarisationsDB(const UniValue& params, bool fHelp); +extern UniValue getimports(const UniValue& params, bool fHelp); extern UniValue migrate_converttoexport(const UniValue& params, bool fHelp); extern UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp); extern UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 3bfb40648..a230910f3 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -859,7 +859,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, static bool IsKeyType(string strType) { - return (strType== "key" || strType == "wkey" || + return (strType == "key" || strType == "wkey" || strType == "hdseed" || strType == "chdseed" || strType == "zkey" || strType == "czkey" || strType == "sapzkey" || strType == "csapzkey" || @@ -922,9 +922,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Rescan if there is a bad transaction record.. //SoftSetBoolArg("-rescan", true); - uint256 hash; - ssKey >> hash; - fprintf(stderr, "TX corrupted hash: %s\n", hash.ToString().c_str()); + fprintf(stderr, "TX corrupted.. aborted rescan!\n"); } } } From bb95bce9e70d5e51b3f517a223e5adddea1103a0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 3 Jan 2019 01:02:45 +0800 Subject: [PATCH 0849/3904] Add source chain to burn op return, and extract it in getimports RPC if it exists. --- src/importcoin.cpp | 17 +++++++++++++---- src/komodo_globals.h | 2 +- src/rpc/crosschain.cpp | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 402a1fb36..b47832beb 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -70,10 +70,19 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); - return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); - ss >> targetSymbol; - ss >> payoutsHash; - ss >> rawproof); + if ( ccid != 0xffffffff ) + { + return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); + ss >> targetSymbol; + ss >> payoutsHash); + } + else + { + return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); + ss >> targetSymbol; + ss >> payoutsHash; + ss >> rawproof); + } } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c2d6aa0c4..815dbafe2 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS,,ASSETCHAINS_SELFIMPORT; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS,ASSETCHAINS_SELFIMPORT; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; bool VERUS_MINTBLOCKS; diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 7b12128e2..49c506e78 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -163,7 +163,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - std::vector rawproof; uint8_t *ptr; int32_t i; uint32_t ccid = ASSETCHAINS_CC; + std::vector rawproof; uint8_t *ptr; uint8_t i; uint32_t ccid = ASSETCHAINS_CC; if (fHelp || params.size() != 2) throw runtime_error( "migrate_converttoexport rawTx dest_symbol\n" @@ -374,7 +374,7 @@ UniValue getimports(const UniValue& params, bool fHelp) " \"export\" { (json object)\n" " \"txid\" : (string)\n" " \"value\" : (numeric)\n" - " \"chain\" : (string)\n" //TODO! + " \"chain\" : (string)\n" " }\n" " }" " ]\n" @@ -437,22 +437,40 @@ UniValue getimports(const UniValue& params, bool fHelp) { UniValue objTx(UniValue::VOBJ); objTx.push_back(Pair("txid",tx.GetHash().ToString())); - TxProof proof; - CTransaction burnTx; - std::vector payouts; + TxProof proof; CTransaction burnTx; std::vector payouts; CTxDestination importaddress; TotalImported += tx.vout[1].nValue; - printf("nvalue.%li TotalImported.%li\n",tx.vout[1].nValue,TotalImported); objTx.push_back(Pair("amount", ValueFromAmount(tx.vout[1].nValue))); - CTxDestination importaddress; if (ExtractDestination(tx.vout[1].scriptPubKey, importaddress)) { objTx.push_back(Pair("address", CBitcoinAddress(importaddress).ToString())); } UniValue objBurnTx(UniValue::VOBJ); - if (UnmarshalImportTx(tx, proof, burnTx, payouts)) { + if (UnmarshalImportTx(tx, proof, burnTx, payouts)) + { + if (burnTx.vout.size() == 0) + continue; objBurnTx.push_back(Pair("txid", burnTx.GetHash().ToString())); - objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.size() ? burnTx.vout.back().nValue : 0))); - // TODO: add source chain, using new data in burn OP_RETURN from upsteam. + objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.back().nValue))); + // extract op_return to get burn source chain. + std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; + GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); + if (E_UNMARSHAL(burnOpret, ss >> VARINT(targetCCid); + ss >> targetSymbol; + ss >> payoutsHash; + ss >> rawproof)); + { + if (rawproof.size() > 0) + { + char *buffer; int32_t n; + buffer = (char*) malloc (65); + if (buffer!=NULL) + { + for (n=0; n<65; n++) + buffer[n]=rawproof[n]; + objBurnTx.push_back(Pair("source", buffer)); + } + } + } } objTx.push_back(Pair("export", objBurnTx)); imports.push_back(objTx); From 3e22247501654a29856fa024754271da556005c5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 3 Jan 2019 09:55:56 +0800 Subject: [PATCH 0850/3904] try to fix invalid burntx decode error --- src/importcoin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index b47832beb..8d08c2167 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -69,20 +69,20 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint std::vector burnOpret; uint32_t ccid = 0; if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); - E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); - if ( ccid != 0xffffffff ) + //E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); + /*if ( ccid != 0xffffffff ) { return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash); } else - { + {*/ return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash; ss >> rawproof); - } + //} } From 542607e4e26ccbfa7738e3d90f2502fe59025005 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 3 Jan 2019 19:52:02 +0800 Subject: [PATCH 0851/3904] fix my stupidity guys.. sorry --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 8cce14a0b..ebee4868e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -12,7 +12,7 @@ extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; - if (doneinit == 1) + if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; From 75ae32c0aa866a4c1038b50ec9ce67dcc68cbcef Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 14:35:34 +0800 Subject: [PATCH 0852/3904] fix source chain display error --- src/importcoin.cpp | 12 +----------- src/rpc/crosschain.cpp | 16 +++------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 8d08c2167..05fd79a95 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -69,20 +69,10 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint std::vector burnOpret; uint32_t ccid = 0; if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); - //E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); - /*if ( ccid != 0xffffffff ) - { - return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); - ss >> targetSymbol; - ss >> payoutsHash); - } - else - {*/ - return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); + return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash; ss >> rawproof); - //} } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 49c506e78..5519f0e17 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -453,22 +453,12 @@ UniValue getimports(const UniValue& params, bool fHelp) objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.back().nValue))); // extract op_return to get burn source chain. std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; - GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); - if (E_UNMARSHAL(burnOpret, ss >> VARINT(targetCCid); - ss >> targetSymbol; - ss >> payoutsHash; - ss >> rawproof)); + if (UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof)) { if (rawproof.size() > 0) { - char *buffer; int32_t n; - buffer = (char*) malloc (65); - if (buffer!=NULL) - { - for (n=0; n<65; n++) - buffer[n]=rawproof[n]; - objBurnTx.push_back(Pair("source", buffer)); - } + std::string sourceSymbol(rawproof.begin(), rawproof.end()); + objBurnTx.push_back(Pair("source", sourceSymbol)); } } } From 5837b5bc05338966cf4a62d21bed7e153ad5b3f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 16:11:51 +0800 Subject: [PATCH 0853/3904] Wallet corruption fix. No longer calls a rescan on daemon load, instead we now delete the non existant txs from the wallet, so next time you load it the error is gone. --- src/main.cpp | 5 ++--- src/wallet/walletdb.cpp | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9537a5c81..c8af01656 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1342,11 +1342,10 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio // Transactions containing empty `vin` must have either non-empty // `vjoinsplit` or non-empty `vShieldedSpend`. - if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { - fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); + if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); - } + // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. if (tx.vout.empty() && tx.vjoinsplit.empty() && tx.vShieldedOutput.empty()) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index ed37877e7..fc9f4b20f 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -39,6 +39,7 @@ using namespace std; static uint64_t nAccountingEntryNumber = 0; +static list deadTxns; // // CWalletDB @@ -484,8 +485,11 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, CValidationState state; auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) + { + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + deadTxns.push_back(hash); return false; - + } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) { @@ -933,12 +937,6 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. - if (strType == "tx" ) - { - // Rescan if there is a bad transaction record.. - //SoftSetBoolArg("-rescan", true); - fprintf(stderr, "TX corrupted.. aborted rescan!\n"); - } } } if (!strErr.empty()) @@ -952,6 +950,16 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) catch (...) { result = DB_CORRUPT; } + + if (!deadTxns.empty()) + { + BOOST_FOREACH (uint256& hash, deadTxns) { + if (!EraseTx(hash)) + fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); + } + fprintf(stderr, "Cleared %i corrupted transactions from wallet.\n",deadTxns.size()); + deadTxns.clear(); + } if (fNoncriticalErrors && result == DB_LOAD_OK) result = DB_NONCRITICAL_ERROR; From ff43475a31a04aaad2b329180dec4f4e5d99150f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 17:26:28 +0800 Subject: [PATCH 0854/3904] Re-add txs that were removed from wallet, if they are valid. --- src/wallet/wallet.cpp | 2 -- src/wallet/walletdb.cpp | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8ecda92f1..7e77d2d24 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1753,8 +1753,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) return false; - if ( tx.vin.empty() ) - return false; bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto sproutNoteData = FindMySproutNotes(tx); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index fc9f4b20f..21139e0c2 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -489,7 +489,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); deadTxns.push_back(hash); return false; - } + } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) { @@ -953,11 +953,19 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if (!deadTxns.empty()) { + int32_t reAdded = 0; BOOST_FOREACH (uint256& hash, deadTxns) { if (!EraseTx(hash)) fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); + uint256 blockhash; CTransaction tx; + if (GetTransaction(hash,tx,blockhash,true)) + { + CWalletTx wtx(pwallet,tx); + pwallet->AddToWallet(wtx, true, NULL); + reAdded++; + } } - fprintf(stderr, "Cleared %i corrupted transactions from wallet.\n",deadTxns.size()); + fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i on chain transactions.\n",deadTxns.size(),reAdded); deadTxns.clear(); } From 1cd888132960ff5f8b220811d9fdbbccf197b784 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 17:51:23 +0800 Subject: [PATCH 0855/3904] change print --- src/wallet/walletdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 21139e0c2..95ada1448 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -965,7 +965,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) reAdded++; } } - fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i on chain transactions.\n",deadTxns.size(),reAdded); + fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",deadTxns.size(),reAdded); deadTxns.clear(); } From 536580bdeca6d3a9b719c5f8adc4ac1a9a1dcb57 Mon Sep 17 00:00:00 2001 From: wallnutkraken Date: Sun, 6 Jan 2019 22:10:59 +0100 Subject: [PATCH 0856/3904] Fixed a 404'd libsodium link --- depends/packages/libsodium.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 67e096fae..76f0d9a28 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -9,7 +9,7 @@ $(package)_config_opts= else package=libsodium $(package)_version=1.0.15 -$(package)_download_path=https://download.libsodium.org/libsodium/releases +$(package)_download_path=https://download.libsodium.org/libsodium/releases/old $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 $(package)_dependencies= From d53a4a9e5b4dcc0bf9e14e1e01b79ad1aa1cee8f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 7 Jan 2019 18:11:51 +0800 Subject: [PATCH 0857/3904] push changes for getrawtransaction --- src/rpc/rawtransaction.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 117d2ac34..9badcbd30 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -35,6 +35,7 @@ #include "script/sign.h" #include "script/standard.h" #include "uint256.h" +#include "importcoin.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif @@ -202,6 +203,25 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); else if (tx.IsCoinImport()) { in.push_back(Pair("is_import", "1")); + TxProof proof; CTransaction burnTx; std::vector payouts; CTxDestination importaddress; + if (UnmarshalImportTx(tx, proof, burnTx, payouts)) + { + if (burnTx.vout.size() == 0) + continue; + in.push_back(Pair("txid", burnTx.GetHash().ToString())); + in.push_back(Pair("value", ValueFromAmount(burnTx.vout.back().nValue))); + in.push_back(Pair("valueSat", burnTx.vout.back().nValue)); + // extract op_return to get burn source chain. + std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; + if (UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof)) + { + if (rawproof.size() > 0) + { + std::string sourceSymbol(rawproof.begin(), rawproof.end()); + in.push_back(Pair("source", sourceSymbol)); + } + } + } } else { in.push_back(Pair("txid", txin.prevout.hash.GetHex())); From 5d34792067130ae4b104e800f3df01f926b643f6 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Mon, 7 Jan 2019 20:41:54 +0800 Subject: [PATCH 0858/3904] fix --- depends/packages/libsodium.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 67e096fae..76f0d9a28 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -9,7 +9,7 @@ $(package)_config_opts= else package=libsodium $(package)_version=1.0.15 -$(package)_download_path=https://download.libsodium.org/libsodium/releases +$(package)_download_path=https://download.libsodium.org/libsodium/releases/old $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 $(package)_dependencies= From 58cb0e8ea23226b37e6ec1ec53d1cddb51289d47 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 7 Jan 2019 22:36:58 +0800 Subject: [PATCH 0859/3904] use unused address variable for source, to get source chain to explorer. --- src/rpc/rawtransaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 9badcbd30..d4b5c1b1c 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -218,7 +218,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& if (rawproof.size() > 0) { std::string sourceSymbol(rawproof.begin(), rawproof.end()); - in.push_back(Pair("source", sourceSymbol)); + in.push_back(Pair("address", sourceSymbol)); } } } From 6794cfc0cc4e5932e44934c1fc007cc0489755cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 7 Jan 2019 23:04:54 +0800 Subject: [PATCH 0860/3904] add IMP-- to export address for explorer. --- src/rpc/rawtransaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index d4b5c1b1c..94296616f 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -218,7 +218,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& if (rawproof.size() > 0) { std::string sourceSymbol(rawproof.begin(), rawproof.end()); - in.push_back(Pair("address", sourceSymbol)); + in.push_back(Pair("address", "IMP-" + sourceSymbol + "-" + burnTx.GetHash().ToString())); } } } From 6decb5e22bfcd1806087d44af980e38535d2962c Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 7 Jan 2019 19:06:21 +0100 Subject: [PATCH 0861/3904] update libsodium url fix broken path --- depends/packages/libsodium.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 67e096fae..76f0d9a28 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -9,7 +9,7 @@ $(package)_config_opts= else package=libsodium $(package)_version=1.0.15 -$(package)_download_path=https://download.libsodium.org/libsodium/releases +$(package)_download_path=https://download.libsodium.org/libsodium/releases/old $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 $(package)_dependencies= From 7d56db54d1c89218992616f271dbb320f19a5b8e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 Jan 2019 07:33:23 -1100 Subject: [PATCH 0862/3904] Messages --- src/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.h b/src/net.h index e2fbdb0bd..02714e20f 100644 --- a/src/net.h +++ b/src/net.h @@ -48,7 +48,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024; +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From ce5995738b3b4c5dbb953e58b4df590f0c143ffe Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 Jan 2019 07:43:15 -1100 Subject: [PATCH 0863/3904] Update version --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 7bfb98f7b..323540790 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -56,7 +56,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -#define KOMODO_VERSION "0.3.1" +#define KOMODO_VERSION "0.3.3" #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; From ddd4b8eab9ae298e1c9217aad4fc8fc222e14f61 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 11:00:26 +0800 Subject: [PATCH 0864/3904] 4mb blocks --- src/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.h b/src/net.h index 7d3047d80..8901146ca 100644 --- a/src/net.h +++ b/src/net.h @@ -63,7 +63,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024; +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From 0b24307e2bd478c5b5bcde8a43bc3608d4e737af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 14:33:27 +0800 Subject: [PATCH 0865/3904] Add export description to burn TX on explorer. --- src/rpc/rawtransaction.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 94296616f..87e95c14c 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -276,6 +276,14 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& out.push_back(Pair("n", (int64_t)i)); UniValue o(UniValue::VOBJ); ScriptPubKeyToJSON(txout.scriptPubKey, o, true); + if (txout.scriptPubKey.IsOpReturn() && txout.nValue != 0) + { + std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; + if (UnmarshalBurnTx(tx, targetSymbol, &targetCCid, payoutsHash, rawproof)) + { + out.push_back(Pair("target", "EXPORT->" + targetSymbol)); + } + } out.push_back(Pair("scriptPubKey", o)); // Add spent information if spentindex is enabled From 449fa23bb4d1f40f1a1b4f1c2f54da347da9b506 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 15:58:10 +0800 Subject: [PATCH 0866/3904] Disable BTC txid checks on parse of statefile. For @lukechilds. --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c6eb05324..4b104646f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -449,7 +449,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t } else if ( strcmp(dest,"BTC") == 0 ) { - if ( BTCUSERPASS[0] != 0 ) + if ( BTCUSERPASS[0] != 0 && KOMODO_PASSPORT_INITDONE == 1 ) { //printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); From df2b40b9d091d0bc63c09a3fa1f7477ffbac7818 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 16:09:50 +0800 Subject: [PATCH 0867/3904] revert that change for myself. --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4b104646f..c6eb05324 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -449,7 +449,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t } else if ( strcmp(dest,"BTC") == 0 ) { - if ( BTCUSERPASS[0] != 0 && KOMODO_PASSPORT_INITDONE == 1 ) + if ( BTCUSERPASS[0] != 0 ) { //printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); From 0dee67a800d0b5257950da5d473aede299352fe4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 23:07:34 +0800 Subject: [PATCH 0868/3904] set import max priotity, and also 0.001 flat fee. --- src/miner.cpp | 7 ++++--- src/rpc/crosschain.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 66ba92514..3ccacea1c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -285,9 +285,10 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool fNotarisation = false; if (tx.IsCoinImport()) { - CAmount nValueIn = GetCoinImportValue(tx); - nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier + CAmount nValueIn = GetCoinImportValue(tx); // burn amount + //tx.vout[1].nValue import amount + //nTotalIn += nValueIn; + dPriority += 1e16; //(double)nValueIn * 1000; // flat multiplier } else { int numNotaryVins = 0; bool fToCryptoAddress = false; if ( komodo_is_notarytx(tx) == 1 ) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 5519f0e17..550efed71 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -205,7 +205,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) ptr = rawproof.data(); for (i=0; i Date: Tue, 8 Jan 2019 23:48:34 +0800 Subject: [PATCH 0869/3904] oops --- src/rpc/crosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 550efed71..5519f0e17 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -205,7 +205,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) ptr = rawproof.data(); for (i=0; i Date: Wed, 9 Jan 2019 01:39:55 +0800 Subject: [PATCH 0870/3904] fix minign lock? --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 113fa4c03..a7251057e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1603,7 +1603,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree) { { - LOCK(mempool.cs); + LOCK2(cs_main, mempool.cs); uint256 hash = tx.GetHash(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; From 6ab190c5b44ab00fc6bb00a5bc05b67c04288517 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 9 Jan 2019 04:29:27 +0800 Subject: [PATCH 0871/3904] try --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a7251057e..dea9ee85f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1872,7 +1872,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa nLastTime = nNow; // -limitfreerelay unit is thousand-bytes-per-minute // At default rate it would take over a month to fill 1GB - if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000) + if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*50000) { fprintf(stderr,"accept failure.7\n"); return state.DoS(0, error("AcceptToMemoryPool: free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); From 7bc81ad0de308e4c97390f4e182740d6e55bc32b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 9 Jan 2019 04:38:54 +0800 Subject: [PATCH 0872/3904] fix mempool propagation --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index dea9ee85f..0720e2caa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1858,7 +1858,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Continuously rate-limit free (really, very-low-fee) transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. - if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize)) + if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize) && !tx.IsCoinImport()) { static CCriticalSection csFreeLimiter; static double dFreeCount; From 68ef9dd9a9ba02d4d88560c7881ee7f95b5cd57f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:10:49 -1100 Subject: [PATCH 0873/3904] Add contextual check in connect block from connecttip --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index bffddf01f..22c8eb4f4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3180,7 +3180,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - + if ( fCheckPOW != 0 && pindex->nTime > 1546028567 && !ContextualCheckBlock(block, state, pindex->pprev) ) + { + fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->nHeight); + return false; + } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); if ( hashPrevBlock != view.GetBestBlock() ) From c299983eaf2ccb6e87235e382eb33111ac22ffcc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:11:38 -1100 Subject: [PATCH 0874/3904] GetHeight() --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 22c8eb4f4..82dae2593 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3182,7 +3182,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } if ( fCheckPOW != 0 && pindex->nTime > 1546028567 && !ContextualCheckBlock(block, state, pindex->pprev) ) { - fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->nHeight); + fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); return false; } // verify that the view's current state corresponds to the previous block From 8e172149f632cdcb7944b563c2f0e5819b8abbf9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:19:28 -1100 Subject: [PATCH 0875/3904] Add context check in connectTip --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 20f28d46a..8dcd3cc10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3170,6 +3170,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } + if ( fCheckPOW != 0 && pindex->nTime > 1548979200 && !ContextualCheckBlock(block, state, pindex->pprev) ) // activate check Feb 1, 2019 + { + fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); + return false; + } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); From cb64a2dc5673b7e9d94704fdd34013ebbdabf669 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:20:34 -1100 Subject: [PATCH 0876/3904] Activate jan 15th --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8dcd3cc10..861fb7eab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3170,7 +3170,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - if ( fCheckPOW != 0 && pindex->nTime > 1548979200 && !ContextualCheckBlock(block, state, pindex->pprev) ) // activate check Feb 1, 2019 + if ( fCheckPOW != 0 && pindex->nTime > 1547510400 && !ContextualCheckBlock(block, state, pindex->pprev) ) // activate check Jan 15, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); return false; From f52cbb1b069f228b1d6747a0ef25345e61b88d39 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:25:42 -1100 Subject: [PATCH 0877/3904] Jan 15th activation --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 82dae2593..6aebb4708 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3180,7 +3180,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - if ( fCheckPOW != 0 && pindex->nTime > 1546028567 && !ContextualCheckBlock(block, state, pindex->pprev) ) + if ( fCheckPOW != 0 && pindex->nTime > 1547510400 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); return false; From 665c152e30d29fb7c977a87af083e24ba9d09964 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:35:05 -1100 Subject: [PATCH 0878/3904] +prints --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 6aebb4708..04f26d765 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1091,6 +1091,7 @@ bool ContextualCheckTransaction( } // Rules that apply to Overwinter or later: + fprintf(stderr,"ht.%d overwinterActive.%d tx.overwintered.%d\n",nHeight,overwinterActive,overwinterActive); if (overwinterActive) { // Reject transactions intended for Sprout @@ -3180,7 +3181,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - if ( fCheckPOW != 0 && pindex->nTime > 1547510400 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019 + fprintf(stderr,"connect.%d checkPOW.%d nTime.%u %d\n",fCheckPOW,(uint32_t)pindex->nTime,ContextualCheckBlock(block, state, pindex->pprev)); + if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) //&& pindex->nTime > 1547510400 Activate Jan 15th, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); return false; From b0a3c8589c8eefb9500ed4affb7bf27c1b1e7d77 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:39:49 -1100 Subject: [PATCH 0879/3904] Type --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 04f26d765..82d548f53 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3181,7 +3181,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - fprintf(stderr,"connect.%d checkPOW.%d nTime.%u %d\n",fCheckPOW,(uint32_t)pindex->nTime,ContextualCheckBlock(block, state, pindex->pprev)); + fprintf(stderr,"connect.%d checkPOW.%d nTime.%u %d\n",pindex->GetHeight(),fCheckPOW,(uint32_t)pindex->nTime,ContextualCheckBlock(block, state, pindex->pprev)); if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) //&& pindex->nTime > 1547510400 Activate Jan 15th, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); From e5e2d5007f550695acce0f321c8e0aea47fc88cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:46:02 -1100 Subject: [PATCH 0880/3904] Cap sapling accept block exemption --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 82d548f53..056f08dbd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5077,7 +5077,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // the problem is when a future sapling block comes in before we detected saplinght if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 ) { - fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); + fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+10000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) *futureblockp = 1; } From f421590c81a074f3fc1764da246da12e994bbeef Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:49:16 -1100 Subject: [PATCH 0881/3904] Fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 056f08dbd..14b21b861 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5078,7 +5078,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 ) { fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+10000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); - if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) + if ( pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+10000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) *futureblockp = 1; } if ( *futureblockp == 0 ) From 21ee92f6f334b62a5988f08ae663fba1a6410786 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Jan 2019 23:58:46 -1100 Subject: [PATCH 0882/3904] Grandfather logic --- src/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 14b21b861..117c6604e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3181,11 +3181,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - fprintf(stderr,"connect.%d checkPOW.%d nTime.%u %d\n",pindex->GetHeight(),fCheckPOW,(uint32_t)pindex->nTime,ContextualCheckBlock(block, state, pindex->pprev)); - if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) //&& pindex->nTime > 1547510400 Activate Jan 15th, 2019 + //fprintf(stderr,"connect.%d checkPOW.%d nTime.%u %d\n",pindex->GetHeight(),fCheckPOW,(uint32_t)pindex->nTime,ContextualCheckBlock(block, state, pindex->pprev)); + if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); - return false; + if ( pindex->nTime > 1547510400 ) + return false; + fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); @@ -5077,8 +5079,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // the problem is when a future sapling block comes in before we detected saplinght if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 ) { - fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+10000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); - if ( pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+10000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) + fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+50000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); + if ( pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+50000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) *futureblockp = 1; } if ( *futureblockp == 0 ) From 0234e33c938cd5531537935221b6ff76d03e471c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 00:00:46 -1100 Subject: [PATCH 0883/3904] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 117c6604e..c27c1f0e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1091,7 +1091,7 @@ bool ContextualCheckTransaction( } // Rules that apply to Overwinter or later: - fprintf(stderr,"ht.%d overwinterActive.%d tx.overwintered.%d\n",nHeight,overwinterActive,overwinterActive); + //fprintf(stderr,"ht.%d overwinterActive.%d tx.overwintered.%d\n",nHeight,overwinterActive,overwinterActive); if (overwinterActive) { // Reject transactions intended for Sprout From 0e49163d4af4fba54bce04c47e21c8d2e9cb2067 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 00:04:30 -1100 Subject: [PATCH 0884/3904] Jan 15th activation of stricter block checks --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 861fb7eab..fe6fb4030 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3170,10 +3170,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - if ( fCheckPOW != 0 && pindex->nTime > 1547510400 && !ContextualCheckBlock(block, state, pindex->pprev) ) // activate check Jan 15, 2019 + if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); - return false; + if ( pindex->nTime > 1547510400 ) + return false; + fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // verify that the view's current state corresponds to the previous block From 8a5f7bdf6a35a967c0fad805424a500ce3a8aad4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 00:05:22 -1100 Subject: [PATCH 0885/3904] Version 0.3.3b --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 323540790..e29abc60e 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -56,7 +56,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -#define KOMODO_VERSION "0.3.3" +#define KOMODO_VERSION "0.3.3b" #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; From bce13f9276ce64e1a2def0a0af60def624cb0ec6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 00:07:01 -1100 Subject: [PATCH 0886/3904] 0.3.3b --- src/main.cpp | 1 - src/rpc/misc.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c27c1f0e5..f5922d840 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3181,7 +3181,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - //fprintf(stderr,"connect.%d checkPOW.%d nTime.%u %d\n",pindex->GetHeight(),fCheckPOW,(uint32_t)pindex->nTime,ContextualCheckBlock(block, state, pindex->pprev)); if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 181d6cdbb..0ebfa7b25 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -72,7 +72,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -#define KOMODO_VERSION "0.3.3" +#define KOMODO_VERSION "0.3.3b" #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; From 42911ea6c2f2af88923b865bee619ed7753dcbc4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 01:21:29 -1100 Subject: [PATCH 0887/3904] Double maxreorg --- src/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.h b/src/main.h index f318a8c13..2c4cef14e 100644 --- a/src/main.h +++ b/src/main.h @@ -78,7 +78,7 @@ static const bool DEFAULT_ALERTS = true; /** Minimum alert priority for enabling safe mode. */ static const int ALERT_PRIORITY_SAFE_MODE = 4000; /** Maximum reorg length we will accept before we shut down and alert the user. */ -static const unsigned int MAX_REORG_LENGTH = _COINBASE_MATURITY - 1; +static const unsigned int MAX_REORG_LENGTH = 2*(_COINBASE_MATURITY - 1); /** Maximum number of signature check operations in an IsStandard() P2SH script */ static const unsigned int MAX_P2SH_SIGOPS = 15; /** The maximum number of sigops we're willing to relay/mine in a single tx */ From 9269bc177c448d4a66e9f88222bb306e1779184f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 01:25:23 -1100 Subject: [PATCH 0888/3904] Allow tunable maxreorg --- src/komodo_utils.h | 1 + src/main.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2437b0bf6..6010cf4c4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1701,6 +1701,7 @@ void komodo_args(char *argv0) } } KOMODO_STOPAT = GetArg("-stopat",0); + MAX_REORG_LENGTH = GetArg("-maxreorg",MAX_REORG_LENGTH); ASSETCHAINS_CC = GetArg("-ac_cc",0); KOMODO_CCACTIVATE = GetArg("-ac_ccactivate",0); ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); diff --git a/src/main.h b/src/main.h index 2c4cef14e..463c91237 100644 --- a/src/main.h +++ b/src/main.h @@ -78,7 +78,7 @@ static const bool DEFAULT_ALERTS = true; /** Minimum alert priority for enabling safe mode. */ static const int ALERT_PRIORITY_SAFE_MODE = 4000; /** Maximum reorg length we will accept before we shut down and alert the user. */ -static const unsigned int MAX_REORG_LENGTH = 2*(_COINBASE_MATURITY - 1); +static unsigned int MAX_REORG_LENGTH = (_COINBASE_MATURITY - 1); /** Maximum number of signature check operations in an IsStandard() P2SH script */ static const unsigned int MAX_P2SH_SIGOPS = 15; /** The maximum number of sigops we're willing to relay/mine in a single tx */ From 1f46aa58e6913856f4a921305329b407d3af28fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 01:26:25 -1100 Subject: [PATCH 0889/3904] Allow tunable maxreorg --- src/komodo_utils.h | 1 + src/main.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 19941a172..aa887bba3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1701,6 +1701,7 @@ void komodo_args(char *argv0) } } KOMODO_STOPAT = GetArg("-stopat",0); + MAX_REORG_LENGTH = GetArg("-maxreorg",MAX_REORG_LENGTH); ASSETCHAINS_CC = GetArg("-ac_cc",0); KOMODO_CCACTIVATE = GetArg("-ac_ccactivate",0); ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); diff --git a/src/main.h b/src/main.h index fdd9fcae8..775b31eb6 100644 --- a/src/main.h +++ b/src/main.h @@ -63,7 +63,7 @@ static const bool DEFAULT_ALERTS = true; /** Minimum alert priority for enabling safe mode. */ static const int ALERT_PRIORITY_SAFE_MODE = 4000; /** Maximum reorg length we will accept before we shut down and alert the user. */ -static const unsigned int MAX_REORG_LENGTH = _COINBASE_MATURITY - 1; +static unsigned int MAX_REORG_LENGTH = _COINBASE_MATURITY - 1; /** Maximum number of signature check operations in an IsStandard() P2SH script */ static const unsigned int MAX_P2SH_SIGOPS = 15; /** The maximum number of sigops we're willing to relay/mine in a single tx */ From 10b90968afce6a863ebab317f09510993bc2ff69 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 01:28:17 -1100 Subject: [PATCH 0890/3904] +comments --- src/chainparams.cpp | 2 +- src/net.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 49f08e98e..d97ed8624 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -230,7 +230,7 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat CChainParams::checkpointData = checkpointData; } -int32_t MAX_BLOCK_SIZE(int32_t height) +int32_t MAX_BLOCK_SIZE(int32_t height) // make sure to change MAX_PROTOCOL_MESSAGE_LENGTH also!!!! { //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); if ( height <= 0 || (mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight > 0 && height >= mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) ) diff --git a/src/net.h b/src/net.h index 8901146ca..3f30175c3 100644 --- a/src/net.h +++ b/src/net.h @@ -63,7 +63,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; // depends on MAX_BLOCK_SIZE /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From 59177fa5980649d5fa38f86b7ca767fe7718240d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 01:39:53 -1100 Subject: [PATCH 0891/3904] No static assert --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f5922d840..aefb3bcb0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4088,7 +4088,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // then pindexFork will be null, and we would need to remove the entire chain including // our genesis block. In practice this (probably) won't happen because of checks elsewhere. auto reorgLength = pindexOldTip ? pindexOldTip->GetHeight() - (pindexFork ? pindexFork->GetHeight() : -1) : 0; - static_assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance"); + assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; From 2f847e2ef4ca3c77b6131183f1913e3b3714afad Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 01:40:34 -1100 Subject: [PATCH 0892/3904] Assert 1 arg --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index aefb3bcb0..f5e5a6ab0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4088,7 +4088,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // then pindexFork will be null, and we would need to remove the entire chain including // our genesis block. In practice this (probably) won't happen because of checks elsewhere. auto reorgLength = pindexOldTip ? pindexOldTip->GetHeight() - (pindexFork ? pindexFork->GetHeight() : -1) : 0; - assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance"); + assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; From ba1b2b5c5674af96051eb7a22ce86d1b707566d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 01:43:10 -1100 Subject: [PATCH 0893/3904] -Static assert --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index fe6fb4030..3d2f19b55 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4078,7 +4078,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // then pindexFork will be null, and we would need to remove the entire chain including // our genesis block. In practice this (probably) won't happen because of checks elsewhere. auto reorgLength = pindexOldTip ? pindexOldTip->GetHeight() - (pindexFork ? pindexFork->GetHeight() : -1) : 0; - static_assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance"); + assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; From c5b3b68ace990ee876587a3e2c2794796ef3ace2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 02:18:19 -1100 Subject: [PATCH 0894/3904] Increase witness cache size for maxreorg --- src/komodo_utils.h | 3 +++ src/wallet/wallet.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6010cf4c4..2252cce38 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1650,6 +1650,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } extern int64_t MAX_MONEY; +extern unsigned int WITNESS_CACHE_SIZE; void komodo_args(char *argv0) { @@ -1702,6 +1703,8 @@ void komodo_args(char *argv0) } KOMODO_STOPAT = GetArg("-stopat",0); MAX_REORG_LENGTH = GetArg("-maxreorg",MAX_REORG_LENGTH); + WITNESS_CACHE_SIZE = MAX_REORG_LENGTH+10; + ASSETCHAINS_CC = GetArg("-ac_cc",0); KOMODO_CCACTIVATE = GetArg("-ac_ccactivate",0); ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 29f1737eb..653603ff7 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -76,7 +76,7 @@ static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000; // Should be large enough that we can expect not to reorg beyond our cache // unless there is some exceptional network disruption. #define _COINBASE_MATURITY 100 -static const unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; +unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; //! Size of HD seed in bytes static const size_t HD_WALLET_SEED_LENGTH = 32; From 9040d03af61ceec11d5c352dca337b480ae8acad Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 02:21:47 -1100 Subject: [PATCH 0895/3904] Match WITNESS_CACHE_SIZE to maxreorg --- src/komodo_utils.h | 1 + src/wallet/wallet.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index aa887bba3..d15f7d7e4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1650,6 +1650,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } extern int64_t MAX_MONEY; +extern unsigned int WITNESS_CACHE_SIZE; void komodo_args(char *argv0) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index c5cfedda8..5f040dded 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -61,7 +61,7 @@ static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000; // Should be large enough that we can expect not to reorg beyond our cache // unless there is some exceptional network disruption. #define _COINBASE_MATURITY 100 -static const unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; +unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; //! Size of HD seed in bytes static const size_t HD_WALLET_SEED_LENGTH = 32; From 02d75902ad4a84c2e5042dd29fab9f228d640f28 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 02:30:47 -1100 Subject: [PATCH 0896/3904] Move declaration WITNESS_CACHE --- src/komodo_globals.h | 1 + src/komodo_utils.h | 1 - src/wallet/wallet.h | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a14cea753..8a72b5ad7 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,6 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; +unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2252cce38..a5b22e592 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1650,7 +1650,6 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } extern int64_t MAX_MONEY; -extern unsigned int WITNESS_CACHE_SIZE; void komodo_args(char *argv0) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 653603ff7..c8f9bcbb6 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -75,8 +75,8 @@ static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000; //! Size of witness cache // Should be large enough that we can expect not to reorg beyond our cache // unless there is some exceptional network disruption. -#define _COINBASE_MATURITY 100 -unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; +extern unsigned int WITNESS_CACHE_SIZE; + //! Size of HD seed in bytes static const size_t HD_WALLET_SEED_LENGTH = 32; From 93b616becd062079d1ed44edc9d865617f3c75b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 02:32:11 -1100 Subject: [PATCH 0897/3904] Move WITNESS_CACHE_SIZE --- src/komodo_globals.h | 1 + src/komodo_utils.h | 1 - src/wallet/wallet.h | 3 +-- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 3e9b84db1..ff3748729 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,6 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; +unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d15f7d7e4..aa887bba3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1650,7 +1650,6 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } extern int64_t MAX_MONEY; -extern unsigned int WITNESS_CACHE_SIZE; void komodo_args(char *argv0) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 5f040dded..7adfb4e35 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -60,8 +60,7 @@ static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000; //! Size of witness cache // Should be large enough that we can expect not to reorg beyond our cache // unless there is some exceptional network disruption. -#define _COINBASE_MATURITY 100 -unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; +extern unsigned int WITNESS_CACHE_SIZE; //! Size of HD seed in bytes static const size_t HD_WALLET_SEED_LENGTH = 32; From 2df13c428f9740e563f0b2a960901b458db21e36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 04:24:04 -1100 Subject: [PATCH 0898/3904] Workaround for -maxreorg --- src/komodo_defs.h | 3 ++- src/wallet/wallet.cpp | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index c0a3caffd..bd516be61 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -28,7 +28,8 @@ #define KOMODO_FIRSTFUNGIBLEID 100 #define KOMODO_SAPLING_ACTIVATION 1544832000 // Dec 15th, 2018 #define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019 - +#define _COINBASE_MATURITY 100 + extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 024194695..969e0c81b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1184,6 +1184,7 @@ bool DecrementNoteWitnesses(NoteDataMap& noteDataMap, int indexHeight, int64_t n return true; } + void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) { LOCK(cs_wallet); @@ -1193,10 +1194,17 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) if (!::DecrementNoteWitnesses(wtxItem.second.mapSaplingNoteData, pindex->GetHeight(), nWitnessCacheSize)) needsRescan = true; } - nWitnessCacheSize -= 1; - // TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302) - assert(nWitnessCacheSize > 0); - + if ( WITNESS_CACHE_SIZE == _COINBASE_MATURITY+10 ) + { + nWitnessCacheSize -= 1; + // TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302) + assert(nWitnessCacheSize > 0); + } + else + { + if ( nWitnessCacheSize > 0 ) + nWitnessCacheSize-- + } // For performance reasons, we write out the witness cache in // CWallet::SetBestChain() (which also ensures that overall consistency // of the wallet.dat is maintained). From 512d96862abc5ab95bd0afd1bd6fd695458f14f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 04:30:24 -1100 Subject: [PATCH 0899/3904] Help human instructions for -maxreorg --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f5e5a6ab0..b29e80efc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4114,7 +4114,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo "- " + strprintf(_("Fork point: %s %s, height %d"), ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" + _("Please help, human!"); - LogPrintf("*** %s\n", msg); + LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); StartShutdown(); return false; From 4f48570935324e2c3a531bfb084810764e7d1fff Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 04:31:04 -1100 Subject: [PATCH 0900/3904] ; --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 969e0c81b..dd188d418 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1203,8 +1203,8 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) else { if ( nWitnessCacheSize > 0 ) - nWitnessCacheSize-- - } + nWitnessCacheSize--; + } // For performance reasons, we write out the witness cache in // CWallet::SetBestChain() (which also ensures that overall consistency // of the wallet.dat is maintained). From 9646dd709a04f1b444eb2b472f10a7ebb779580e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 01:35:18 +0800 Subject: [PATCH 0901/3904] revert changes to import priority. Re-try flat transaction fee. Change miner lock to something safer. Add lock cs_main to import validation when accepting to mempool. --- src/main.cpp | 5 +- src/miner.cpp | 486 +++++++++++++++++++++-------------------- src/rpc/crosschain.cpp | 4 +- 3 files changed, 249 insertions(+), 246 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0720e2caa..fae0998b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1603,7 +1603,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree) { { - LOCK2(cs_main, mempool.cs); + LOCK(mempool.cs); uint256 hash = tx.GetHash(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; @@ -1872,7 +1872,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa nLastTime = nNow; // -limitfreerelay unit is thousand-bytes-per-minute // At default rate it would take over a month to fill 1GB - if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*50000) + if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000) { fprintf(stderr,"accept failure.7\n"); return state.DoS(0, error("AcceptToMemoryPool: free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); @@ -2709,6 +2709,7 @@ bool ContextualCheckInputs( if (tx.IsCoinImport()) { + LOCK(cs_main); ServerTransactionSignatureChecker checker(&tx, 0, 0, false, txdata); return VerifyCoinImport(tx.vin[0].scriptSig, checker, state); } diff --git a/src/miner.cpp b/src/miner.cpp index 3ccacea1c..483aef891 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -214,290 +214,286 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CTransaction cheatTx; boost::optional cheatSpend; uint256 cbHash; - - SaplingMerkleTree sapling_tree; uint64_t commission; - int nHeight = 0; - const Consensus::Params &consensusParams = chainparams.GetConsensus(); - - CBlockIndex* pindexPrev = chainActive.LastTip();; + + CBlockIndex* pindexPrev = 0; { - { // contain lock to block generation and not staking loops. - LOCK2(cs_main, mempool.cs); - nHeight = pindexPrev->GetHeight() + 1; - uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); - bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); + pindexPrev = chainActive.LastTip(); + const int nHeight = pindexPrev->GetHeight() + 1; + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); + bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); - const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) + const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + uint32_t proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + { + // too fast or stuck, this addresses the too fast issue, while moving + // forward as quickly as possible + for (int i; i < 100; i++) { - // too fast or stuck, this addresses the too fast issue, while moving - // forward as quickly as possible - for (int i; i < 100; i++) - { - proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - MilliSleep(10); - } + proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + MilliSleep(10); } - pblock->nTime = GetAdjustedTime(); + } + pblock->nTime = GetAdjustedTime(); - CCoinsViewCache view(pcoinsTip); - uint32_t expired; + CCoinsViewCache view(pcoinsTip); + uint32_t expired; uint64_t commission; + + SaplingMerkleTree sapling_tree; + assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); - assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); + // Priority order to process transactions + list vOrphan; // list memory doesn't move + map > mapDependers; + bool fPrintPriority = GetBoolArg("-printpriority", false); - // Priority order to process transactions - list vOrphan; // list memory doesn't move - map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); + // This vector will be sorted into a priority queue: + vector vecPriority; + vecPriority.reserve(mempool.mapTx.size() + 1); - // This vector will be sorted into a priority queue: - vector vecPriority; - vecPriority.reserve(mempool.mapTx.size() + 1); + // now add transactions from the mem pool + for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); + mi != mempool.mapTx.end(); ++mi) + { + const CTransaction& tx = mi->GetTx(); - // now add transactions from the mem pool - for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) + ? nMedianTimePast + : pblock->GetBlockTime(); + + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) { - const CTransaction& tx = mi->GetTx(); + //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); + continue; + } - int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) - ? nMedianTimePast - : pblock->GetBlockTime(); + if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) + { + //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); + continue; + } - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) + COrphan* porphan = NULL; + double dPriority = 0; + CAmount nTotalIn = 0; + bool fMissingInputs = false; + bool fNotarisation = false; + if (tx.IsCoinImport()) + { + CAmount nValueIn = GetCoinImportValue(tx); // burn amount + nTotalIn += nValueIn; + dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. + } else { + int numNotaryVins = 0; bool fToCryptoAddress = false; + if ( komodo_is_notarytx(tx) == 1 ) + fToCryptoAddress = true; + + BOOST_FOREACH(const CTxIn& txin, tx.vin) { - //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); - continue; - } - - if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) - { - //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); - continue; - } - - COrphan* porphan = NULL; - double dPriority = 0; - CAmount nTotalIn = 0; - bool fMissingInputs = false; - bool fNotarisation = false; - if (tx.IsCoinImport()) - { - CAmount nValueIn = GetCoinImportValue(tx); // burn amount - //tx.vout[1].nValue import amount - //nTotalIn += nValueIn; - dPriority += 1e16; //(double)nValueIn * 1000; // flat multiplier - } else { - int numNotaryVins = 0; bool fToCryptoAddress = false; - if ( komodo_is_notarytx(tx) == 1 ) - fToCryptoAddress = true; - - BOOST_FOREACH(const CTxIn& txin, tx.vin) + // Read prev transaction + if (!view.HaveCoins(txin.prevout.hash)) { - // Read prev transaction - if (!view.HaveCoins(txin.prevout.hash)) + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) { - // This should never happen; all transactions in the memory - // pool should connect to either transactions in the chain - // or other transactions in the memory pool. - if (!mempool.mapTx.count(txin.prevout.hash)) - { - LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); - fMissingInputs = true; - if (porphan) - vOrphan.pop_back(); - break; - } - - // Has to wait for dependencies - if (!porphan) - { - // Use list for automatic deletion - vOrphan.push_back(COrphan(&tx)); - porphan = &vOrphan.back(); - } - mapDependers[txin.prevout.hash].push_back(porphan); - porphan->setDependsOn.insert(txin.prevout.hash); - nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; - continue; + LogPrintf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; } - const CCoins* coins = view.AccessCoins(txin.prevout.hash); - assert(coins); - CAmount nValueIn = coins->vout[txin.prevout.n].nValue; - nTotalIn += nValueIn; - - int nConf = nHeight - coins->nHeight; - - // This is to test is a tx is a notarisation and assign it max priotity. - if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + // Has to wait for dependencies + if (!porphan) { - uint256 hash; CTransaction tx1; CTxDestination address; - if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) - { - for (int i = 0; i < NUM_NOTARIES; i++) - if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) - numNotaryVins++; - } + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); } - dPriority += (double)nValueIn * nConf; + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; + continue; } - if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) - fNotarisation = true; - nTotalIn += tx.GetShieldedValueIn(); + const CCoins* coins = view.AccessCoins(txin.prevout.hash); + assert(coins); + + CAmount nValueIn = coins->vout[txin.prevout.n].nValue; + nTotalIn += nValueIn; + + int nConf = nHeight - coins->nHeight; + + // This is to test is a tx is a notarisation and assign it max priotity. + if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { + uint256 hash; CTransaction tx1; CTxDestination address; + if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) + { + for (int i = 0; i < NUM_NOTARIES; i++) + if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) + numNotaryVins++; + } + } + dPriority += (double)nValueIn * nConf; } - - if (fMissingInputs) continue; - - // Priority is sum(valuein * age) / modified_txsize - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - dPriority = tx.ComputePriority(dPriority, nTxSize); - - uint256 hash = tx.GetHash(); - mempool.ApplyDeltas(hash, dPriority, nTotalIn); - - CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - - if (fNotarisation) { - dPriority = 1e16; - fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); - } - - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; - } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) + fNotarisation = true; + nTotalIn += tx.GetShieldedValueIn(); } - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); + if (fMissingInputs) continue; - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + // Priority is sum(valuein * age) / modified_txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority = tx.ComputePriority(dPriority, nTxSize); - while (!vecPriority.empty()) + uint256 hash = tx.GetHash(); + mempool.ApplyDeltas(hash, dPriority, nTotalIn); + + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + + if (fNotarisation) { + dPriority = 1e16; + //fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); + } + + if (porphan) { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); + porphan->dPriority = dPriority; + porphan->feeRate = feeRate; + } + else + vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + } - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); + // Collect transactions into block + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int64_t interest; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx - { - //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); - continue; - } + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& tx = *(vecPriority.front().get<2>()); - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx + { + //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); + continue; + } - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } + // Legacy limits on sigOps: + unsigned int nTxSigOps = GetLegacySigOpCount(tx); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Skip free transactions if we're past the minimum block size: + const uint256& hash = tx.GetHash(); + double dPriorityDelta = 0; + CAmount nFeeDelta = 0; + mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); + if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + { + //fprintf(stderr,"fee rate skip\n"); + continue; + } + // Prioritise by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; + if (!view.HaveInputs(tx)) + { + //fprintf(stderr,"dont have inputs\n"); + continue; + } + CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - if (fPrintPriority) + nTxSigOps += GetP2SHSigOpCount(tx, view); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Note that flags: we don't want to set mempool/IsStandard() + // policy here, but we still have to ensure that the block we + // create only contains transactions that are valid in new blocks. + CValidationState state; + PrecomputedTransactionData txdata(tx); + if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + { + //fprintf(stderr,"context failure\n"); + continue; + } + UpdateCoins(tx, view, nHeight); + + BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { + sapling_tree.append(outDescription.cm); + } + + // Added + pblock->vtx.push_back(tx); + pblocktemplate->vTxFees.push_back(nTxFees); + pblocktemplate->vTxSigOps.push_back(nTxSigOps); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fPrintPriority) + { + LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); + } + + // Add transactions that depend on this one to the priority queue + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) { - LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); - } - - // Add transactions that depend on this one to the priority queue - if (mapDependers.count(hash)) - { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + if (!porphan->setDependsOn.empty()) { - if (!porphan->setDependsOn.empty()) + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) { - porphan->setDependsOn.erase(hash); - if (porphan->setDependsOn.empty()) - { - vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); - std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); } } } } + } - nLastBlockTx = nBlockTx; - nLastBlockSize = nBlockSize; - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - //pblock->nTime = blocktime + 1; - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); - - } // contain lock to block generation only! + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + //pblock->nTime = blocktime + 1; + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); int32_t stakeHeight = chainActive.Height() + 1; @@ -524,7 +520,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = GetAdjustedTime(); //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); } if ( siglen > 0 ) @@ -678,6 +678,8 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //fprintf(stderr,"valid\n"); } } + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 5519f0e17..15e27ead2 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -163,7 +163,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - std::vector rawproof; uint8_t *ptr; uint8_t i; uint32_t ccid = ASSETCHAINS_CC; + std::vector rawproof; uint8_t *ptr; uint8_t i; uint32_t ccid = ASSETCHAINS_CC; uint64_t txfee = 10000; if (fHelp || params.size() != 2) throw runtime_error( "migrate_converttoexport rawTx dest_symbol\n" @@ -205,7 +205,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) ptr = rawproof.data(); for (i=0; i Date: Thu, 10 Jan 2019 02:51:03 +0800 Subject: [PATCH 0902/3904] fix merge problem --- src/net.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/net.h b/src/net.h index b43422184..3f30175c3 100644 --- a/src/net.h +++ b/src/net.h @@ -63,11 +63,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -<<<<<<< HEAD -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; -======= static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; // depends on MAX_BLOCK_SIZE ->>>>>>> e755fa0e7bfc079b94c0aa80e80d3b990c9f4b64 /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From 775c57ce46af5a9512440e4e8a0ab530b2e0f268 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 12:36:43 +0800 Subject: [PATCH 0903/3904] Possible fix for miner crashing on OnDemand Blocks --- src/miner.cpp | 445 +++++++++++++++++++++++++------------------------- 1 file changed, 224 insertions(+), 221 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index cd79ea6b8..d504a2456 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -212,268 +212,265 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // we will attempt to spend any cheats we see CTransaction cheatTx; boost::optional cheatSpend; - uint256 cbHash; + uint256 cbHash; - SaplingMerkleTree sapling_tree; uint64_t commission; - int nHeight = 0; - const Consensus::Params &consensusParams = chainparams.GetConsensus(); - - CBlockIndex* pindexPrev = chainActive.LastTip();; + CBlockIndex* pindexPrev = 0; { - { // contain lock to block generation and not staking loops. - LOCK2(cs_main, mempool.cs); - nHeight = pindexPrev->GetHeight() + 1; - uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); - bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); + pindexPrev = chainActive.LastTip(); + const int nHeight = pindexPrev->GetHeight() + 1; + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); + bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); - const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) + const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + uint32_t proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + { + // too fast or stuck, this addresses the too fast issue, while moving + // forward as quickly as possible + for (int i; i < 100; i++) { - // too fast or stuck, this addresses the too fast issue, while moving - // forward as quickly as possible - for (int i; i < 100; i++) - { - proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - MilliSleep(10); - } + proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + MilliSleep(10); } - pblock->nTime = GetAdjustedTime(); + } + pblock->nTime = GetAdjustedTime(); - CCoinsViewCache view(pcoinsTip); - uint32_t expired; + CCoinsViewCache view(pcoinsTip); + uint32_t expired; uint64_t commission; + + SaplingMerkleTree sapling_tree; uint64_t commission; + assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); - assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); + // Priority order to process transactions + list vOrphan; // list memory doesn't move + map > mapDependers; + bool fPrintPriority = GetBoolArg("-printpriority", false); - // Priority order to process transactions - list vOrphan; // list memory doesn't move - map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); + // This vector will be sorted into a priority queue: + vector vecPriority; + vecPriority.reserve(mempool.mapTx.size() + 1); - // This vector will be sorted into a priority queue: - vector vecPriority; - vecPriority.reserve(mempool.mapTx.size() + 1); + // now add transactions from the mem pool + for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); + mi != mempool.mapTx.end(); ++mi) + { + const CTransaction& tx = mi->GetTx(); - // now add transactions from the mem pool - for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) + ? nMedianTimePast + : pblock->GetBlockTime(); + + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) { - const CTransaction& tx = mi->GetTx(); + //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); + continue; + } - int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) - ? nMedianTimePast - : pblock->GetBlockTime(); + if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) + { + //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); + continue; + } - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) + COrphan* porphan = NULL; + double dPriority = 0; + CAmount nTotalIn = 0; + bool fMissingInputs = false; + bool fNotarisation = false; + if (tx.IsCoinImport()) + { + CAmount nValueIn = GetCoinImportValue(tx); + nTotalIn += nValueIn; + dPriority += (double)nValueIn * 1000; // flat multiplier + } else { + BOOST_FOREACH(const CTxIn& txin, tx.vin) { - //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); - continue; - } + // Read prev transaction + if (!view.HaveCoins(txin.prevout.hash)) + { + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) + { + LogPrintf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; + } - if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) - { - //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); - continue; - } + // Has to wait for dependencies + if (!porphan) + { + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); + } + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; + continue; + } + const CCoins* coins = view.AccessCoins(txin.prevout.hash); + assert(coins); - COrphan* porphan = NULL; - double dPriority = 0; - CAmount nTotalIn = 0; - bool fMissingInputs = false; - bool fNotarisation = false; - if (tx.IsCoinImport()) - { - CAmount nValueIn = GetCoinImportValue(tx); + CAmount nValueIn = coins->vout[txin.prevout.n].nValue; nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier - } else { - BOOST_FOREACH(const CTxIn& txin, tx.vin) - { - // Read prev transaction - if (!view.HaveCoins(txin.prevout.hash)) - { - // This should never happen; all transactions in the memory - // pool should connect to either transactions in the chain - // or other transactions in the memory pool. - if (!mempool.mapTx.count(txin.prevout.hash)) - { - LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); - fMissingInputs = true; - if (porphan) - vOrphan.pop_back(); - break; - } - // Has to wait for dependencies - if (!porphan) - { - // Use list for automatic deletion - vOrphan.push_back(COrphan(&tx)); - porphan = &vOrphan.back(); - } - mapDependers[txin.prevout.hash].push_back(porphan); - porphan->setDependsOn.insert(txin.prevout.hash); - nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; - continue; - } - const CCoins* coins = view.AccessCoins(txin.prevout.hash); - assert(coins); + int nConf = nHeight - coins->nHeight; - CAmount nValueIn = coins->vout[txin.prevout.n].nValue; - nTotalIn += nValueIn; - - int nConf = nHeight - coins->nHeight; - - dPriority += (double)nValueIn * nConf; - } - nTotalIn += tx.GetShieldedValueIn(); + dPriority += (double)nValueIn * nConf; } - - if (fMissingInputs) continue; - - // Priority is sum(valuein * age) / modified_txsize - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - dPriority = tx.ComputePriority(dPriority, nTxSize); - - uint256 hash = tx.GetHash(); - mempool.ApplyDeltas(hash, dPriority, nTotalIn); - - CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; - } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + nTotalIn += tx.GetShieldedValueIn(); } - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); + if (fMissingInputs) continue; - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + // Priority is sum(valuein * age) / modified_txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority = tx.ComputePriority(dPriority, nTxSize); - while (!vecPriority.empty()) + uint256 hash = tx.GetHash(); + mempool.ApplyDeltas(hash, dPriority, nTotalIn); + + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + + if (porphan) { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); + porphan->dPriority = dPriority; + porphan->feeRate = feeRate; + } + else + vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + } - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); + // Collect transactions into block + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int64_t interest; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx - { - //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); - continue; - } + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& tx = *(vecPriority.front().get<2>()); - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx + { + //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); + continue; + } - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } + // Legacy limits on sigOps: + unsigned int nTxSigOps = GetLegacySigOpCount(tx); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Skip free transactions if we're past the minimum block size: + const uint256& hash = tx.GetHash(); + double dPriorityDelta = 0; + CAmount nFeeDelta = 0; + mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); + if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + { + //fprintf(stderr,"fee rate skip\n"); + continue; + } + // Prioritise by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; + if (!view.HaveInputs(tx)) + { + //fprintf(stderr,"dont have inputs\n"); + continue; + } + CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - if (fPrintPriority) + nTxSigOps += GetP2SHSigOpCount(tx, view); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Note that flags: we don't want to set mempool/IsStandard() + // policy here, but we still have to ensure that the block we + // create only contains transactions that are valid in new blocks. + CValidationState state; + PrecomputedTransactionData txdata(tx); + if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + { + //fprintf(stderr,"context failure\n"); + continue; + } + UpdateCoins(tx, view, nHeight); + + BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { + sapling_tree.append(outDescription.cm); + } + + // Added + pblock->vtx.push_back(tx); + pblocktemplate->vTxFees.push_back(nTxFees); + pblocktemplate->vTxSigOps.push_back(nTxSigOps); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fPrintPriority) + { + LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); + } + + // Add transactions that depend on this one to the priority queue + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) { - LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); - } - - // Add transactions that depend on this one to the priority queue - if (mapDependers.count(hash)) - { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + if (!porphan->setDependsOn.empty()) { - if (!porphan->setDependsOn.empty()) + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) { - porphan->setDependsOn.erase(hash); - if (porphan->setDependsOn.empty()) - { - vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); - std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); } } } } + } - nLastBlockTx = nBlockTx; - nLastBlockSize = nBlockSize; - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - //pblock->nTime = blocktime + 1; - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); - - } // contain lock to block generation only! + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + //pblock->nTime = blocktime + 1; + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); int32_t stakeHeight = chainActive.Height() + 1; @@ -500,7 +497,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = GetAdjustedTime(); //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); } if ( siglen > 0 ) @@ -654,6 +655,8 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //fprintf(stderr,"valid\n"); } } + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } From 7f0f70f5ae8b35a751cbe9c945f2cdf6b20f90cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 12:46:18 +0800 Subject: [PATCH 0904/3904] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index d504a2456..c308dcf41 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -242,7 +242,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CCoinsViewCache view(pcoinsTip); uint32_t expired; uint64_t commission; - SaplingMerkleTree sapling_tree; uint64_t commission; + SaplingMerkleTree sapling_tree; assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); // Priority order to process transactions From 5cb458b5f20cdeda85d774dd93cac43850007fb5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 16:44:09 +0800 Subject: [PATCH 0905/3904] fix bug with getimports... Fix miner loop deadlock with staker. Remove annoying pointless prints for staker. --- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 16 +++++++++------- src/rpc/crosschain.cpp | 6 +++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fda088631..260f6bc14 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2106,7 +2106,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { - fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + //fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; @@ -2160,7 +2160,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { - fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); + //fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); continue; } eligible = besttime; diff --git a/src/miner.cpp b/src/miner.cpp index 957d4cbba..714641bc0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -494,12 +494,14 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); - + int32_t stakeHeight = chainActive.Height() + 1; //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); @@ -520,11 +522,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = GetAdjustedTime(); //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); - ENTER_CRITICAL_SECTION(cs_main); - ENTER_CRITICAL_SECTION(mempool.cs); } if ( siglen > 0 ) @@ -540,6 +538,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); + } // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); @@ -678,8 +677,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //fprintf(stderr,"valid\n"); } } - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 15e27ead2..e2770b28c 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -363,7 +363,7 @@ UniValue getimports(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( - "getmigrates \"hash|height\"\n" + "getimports \"hash|height\"\n" "\n\n" "\nResult:\n" "{\n" @@ -429,7 +429,7 @@ UniValue getimports(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); UniValue result(UniValue::VOBJ); - CAmount TotalImported; + CAmount TotalImported = 0; UniValue imports(UniValue::VARR); BOOST_FOREACH(const CTransaction&tx, block.vtx) { @@ -467,7 +467,7 @@ UniValue getimports(const UniValue& params, bool fHelp) } } result.push_back(Pair("imports", imports)); - result.push_back(Pair("TotalImported", ValueFromAmount(TotalImported))); + result.push_back(Pair("TotalImported", TotalImported > 0 ? ValueFromAmount(TotalImported) : 0 )); result.push_back(Pair("time", block.GetBlockTime())); return result; } From d7c08abe516f1f7ab4755113165eead95eb05e3b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 22:29:01 +0800 Subject: [PATCH 0906/3904] fix miner possible crash, fix dead lock for large numbers of import transactions. --- src/main.cpp | 1 + src/miner.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b29e80efc..cd3c0d35f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2694,6 +2694,7 @@ bool ContextualCheckInputs( if (tx.IsCoinImport()) { + LOCK(cs_main); ServerTransactionSignatureChecker checker(&tx, 0, 0, false, txdata); return VerifyCoinImport(tx.vin[0].scriptSig, checker, state); } diff --git a/src/miner.cpp b/src/miner.cpp index c308dcf41..7948fd0cd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -477,6 +477,8 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); @@ -497,11 +499,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = GetAdjustedTime(); //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); - ENTER_CRITICAL_SECTION(cs_main); - ENTER_CRITICAL_SECTION(mempool.cs); } if ( siglen > 0 ) @@ -655,8 +653,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //fprintf(stderr,"valid\n"); } } - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } From 325f71b713609fe2b01fc2437cf4ce2d4507832a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 22:36:38 +0800 Subject: [PATCH 0907/3904] fix possible miner crash up with PoW, fix possible deadlock with large numbers of import transactions. --- src/main.cpp | 1 + src/miner.cpp | 446 +++++++++++++++++++++++++------------------------- 2 files changed, 226 insertions(+), 221 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b29e80efc..cd3c0d35f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2694,6 +2694,7 @@ bool ContextualCheckInputs( if (tx.IsCoinImport()) { + LOCK(cs_main); ServerTransactionSignatureChecker checker(&tx, 0, 0, false, txdata); return VerifyCoinImport(tx.vin[0].scriptSig, checker, state); } diff --git a/src/miner.cpp b/src/miner.cpp index cd79ea6b8..7948fd0cd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -212,274 +212,273 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // we will attempt to spend any cheats we see CTransaction cheatTx; boost::optional cheatSpend; - uint256 cbHash; + uint256 cbHash; - SaplingMerkleTree sapling_tree; uint64_t commission; - int nHeight = 0; - const Consensus::Params &consensusParams = chainparams.GetConsensus(); - - CBlockIndex* pindexPrev = chainActive.LastTip();; + CBlockIndex* pindexPrev = 0; { - { // contain lock to block generation and not staking loops. - LOCK2(cs_main, mempool.cs); - nHeight = pindexPrev->GetHeight() + 1; - uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); - bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); + pindexPrev = chainActive.LastTip(); + const int nHeight = pindexPrev->GetHeight() + 1; + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); + bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); - const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) + const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + uint32_t proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + { + // too fast or stuck, this addresses the too fast issue, while moving + // forward as quickly as possible + for (int i; i < 100; i++) { - // too fast or stuck, this addresses the too fast issue, while moving - // forward as quickly as possible - for (int i; i < 100; i++) - { - proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - MilliSleep(10); - } + proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + MilliSleep(10); } - pblock->nTime = GetAdjustedTime(); + } + pblock->nTime = GetAdjustedTime(); - CCoinsViewCache view(pcoinsTip); - uint32_t expired; + CCoinsViewCache view(pcoinsTip); + uint32_t expired; uint64_t commission; + + SaplingMerkleTree sapling_tree; + assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); - assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); + // Priority order to process transactions + list vOrphan; // list memory doesn't move + map > mapDependers; + bool fPrintPriority = GetBoolArg("-printpriority", false); - // Priority order to process transactions - list vOrphan; // list memory doesn't move - map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); + // This vector will be sorted into a priority queue: + vector vecPriority; + vecPriority.reserve(mempool.mapTx.size() + 1); - // This vector will be sorted into a priority queue: - vector vecPriority; - vecPriority.reserve(mempool.mapTx.size() + 1); + // now add transactions from the mem pool + for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); + mi != mempool.mapTx.end(); ++mi) + { + const CTransaction& tx = mi->GetTx(); - // now add transactions from the mem pool - for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) + ? nMedianTimePast + : pblock->GetBlockTime(); + + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) { - const CTransaction& tx = mi->GetTx(); + //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); + continue; + } - int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) - ? nMedianTimePast - : pblock->GetBlockTime(); + if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) + { + //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); + continue; + } - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) + COrphan* porphan = NULL; + double dPriority = 0; + CAmount nTotalIn = 0; + bool fMissingInputs = false; + bool fNotarisation = false; + if (tx.IsCoinImport()) + { + CAmount nValueIn = GetCoinImportValue(tx); + nTotalIn += nValueIn; + dPriority += (double)nValueIn * 1000; // flat multiplier + } else { + BOOST_FOREACH(const CTxIn& txin, tx.vin) { - //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); - continue; - } + // Read prev transaction + if (!view.HaveCoins(txin.prevout.hash)) + { + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) + { + LogPrintf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; + } - if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) - { - //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); - continue; - } + // Has to wait for dependencies + if (!porphan) + { + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); + } + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; + continue; + } + const CCoins* coins = view.AccessCoins(txin.prevout.hash); + assert(coins); - COrphan* porphan = NULL; - double dPriority = 0; - CAmount nTotalIn = 0; - bool fMissingInputs = false; - bool fNotarisation = false; - if (tx.IsCoinImport()) - { - CAmount nValueIn = GetCoinImportValue(tx); + CAmount nValueIn = coins->vout[txin.prevout.n].nValue; nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier - } else { - BOOST_FOREACH(const CTxIn& txin, tx.vin) - { - // Read prev transaction - if (!view.HaveCoins(txin.prevout.hash)) - { - // This should never happen; all transactions in the memory - // pool should connect to either transactions in the chain - // or other transactions in the memory pool. - if (!mempool.mapTx.count(txin.prevout.hash)) - { - LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); - fMissingInputs = true; - if (porphan) - vOrphan.pop_back(); - break; - } - // Has to wait for dependencies - if (!porphan) - { - // Use list for automatic deletion - vOrphan.push_back(COrphan(&tx)); - porphan = &vOrphan.back(); - } - mapDependers[txin.prevout.hash].push_back(porphan); - porphan->setDependsOn.insert(txin.prevout.hash); - nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; - continue; - } - const CCoins* coins = view.AccessCoins(txin.prevout.hash); - assert(coins); + int nConf = nHeight - coins->nHeight; - CAmount nValueIn = coins->vout[txin.prevout.n].nValue; - nTotalIn += nValueIn; - - int nConf = nHeight - coins->nHeight; - - dPriority += (double)nValueIn * nConf; - } - nTotalIn += tx.GetShieldedValueIn(); + dPriority += (double)nValueIn * nConf; } - - if (fMissingInputs) continue; - - // Priority is sum(valuein * age) / modified_txsize - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - dPriority = tx.ComputePriority(dPriority, nTxSize); - - uint256 hash = tx.GetHash(); - mempool.ApplyDeltas(hash, dPriority, nTotalIn); - - CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; - } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + nTotalIn += tx.GetShieldedValueIn(); } - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); + if (fMissingInputs) continue; - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + // Priority is sum(valuein * age) / modified_txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority = tx.ComputePriority(dPriority, nTxSize); - while (!vecPriority.empty()) + uint256 hash = tx.GetHash(); + mempool.ApplyDeltas(hash, dPriority, nTotalIn); + + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + + if (porphan) { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); + porphan->dPriority = dPriority; + porphan->feeRate = feeRate; + } + else + vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + } - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); + // Collect transactions into block + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int64_t interest; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx - { - //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); - continue; - } + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& tx = *(vecPriority.front().get<2>()); - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx + { + //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); + continue; + } - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } + // Legacy limits on sigOps: + unsigned int nTxSigOps = GetLegacySigOpCount(tx); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Skip free transactions if we're past the minimum block size: + const uint256& hash = tx.GetHash(); + double dPriorityDelta = 0; + CAmount nFeeDelta = 0; + mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); + if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + { + //fprintf(stderr,"fee rate skip\n"); + continue; + } + // Prioritise by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; + if (!view.HaveInputs(tx)) + { + //fprintf(stderr,"dont have inputs\n"); + continue; + } + CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - if (fPrintPriority) + nTxSigOps += GetP2SHSigOpCount(tx, view); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Note that flags: we don't want to set mempool/IsStandard() + // policy here, but we still have to ensure that the block we + // create only contains transactions that are valid in new blocks. + CValidationState state; + PrecomputedTransactionData txdata(tx); + if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + { + //fprintf(stderr,"context failure\n"); + continue; + } + UpdateCoins(tx, view, nHeight); + + BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { + sapling_tree.append(outDescription.cm); + } + + // Added + pblock->vtx.push_back(tx); + pblocktemplate->vTxFees.push_back(nTxFees); + pblocktemplate->vTxSigOps.push_back(nTxSigOps); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fPrintPriority) + { + LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); + } + + // Add transactions that depend on this one to the priority queue + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) { - LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); - } - - // Add transactions that depend on this one to the priority queue - if (mapDependers.count(hash)) - { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + if (!porphan->setDependsOn.empty()) { - if (!porphan->setDependsOn.empty()) + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) { - porphan->setDependsOn.erase(hash); - if (porphan->setDependsOn.empty()) - { - vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); - std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); } } } } + } - nLastBlockTx = nBlockTx; - nLastBlockSize = nBlockSize; - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - //pblock->nTime = blocktime + 1; - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); - - } // contain lock to block generation only! + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + //pblock->nTime = blocktime + 1; + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); int32_t stakeHeight = chainActive.Height() + 1; //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); @@ -654,6 +653,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //fprintf(stderr,"valid\n"); } } + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } From 2cbde4d787542224e07b662974001d7ea915ec37 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 23:16:28 +0800 Subject: [PATCH 0908/3904] fix wallet expired on load, fix pindex->segid for PoW. --- src/komodo_bitcoind.h | 17 ++++++++++++++--- src/wallet/walletdb.cpp | 9 ++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 260f6bc14..c8a5d0d19 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1460,7 +1460,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr,"komodo_is_PoSblock PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)pblock->nTime,(int32_t)(eligible - pblock->nTime)); - if ( slowflag != 0 && pindex != 0 ) + if ( slowflag != 0 && pindex != 0 && height > 100) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); @@ -1481,7 +1481,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ if ( pindex != 0 && segid >= 0 ) { pindex->segid = segid; - //fprintf(stderr,"B set segid.%d <- %d\n",height,pindex->segid); + fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } } @@ -1817,7 +1817,18 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED); return(-1); - } else failed = 0; + } else + { + // I think this means the block is valid PoW. We need to set the pindex->segid here. + failed = 0; + CBlockIndex *pindex; + BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); + pindex = it != mapBlockIndex.end() ? it->second : NULL; + if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { + pindex->segid = -1; + fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); + } + } } } else if ( is_PoSblock < 0 ) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 95ada1448..daa8881f5 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -486,9 +486,12 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) { - fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); - deadTxns.push_back(hash); - return false; + if (state.GetRejectReason() != "tx-overwinter-expired") + { + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + deadTxns.push_back(hash); + return false; + } } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) From b8ae55bd3ad7ea57ea49515dcbecfaebed3f11d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 23:31:10 +0800 Subject: [PATCH 0909/3904] remove prints --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c8a5d0d19..0ae824cd6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1481,7 +1481,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ if ( pindex != 0 && segid >= 0 ) { pindex->segid = segid; - fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } } @@ -1826,7 +1826,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { pindex->segid = -1; - fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } } } From 5b6a65f30a86e816166351e1c1292b8e37cfcf75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Jan 2019 07:30:00 -1100 Subject: [PATCH 0910/3904] -prints --- src/wallet/rpcwallet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6e5bc5b83..79710969a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2979,7 +2979,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); if (it != mapBlockIndex.end()) { nHeight = it->second->GetHeight(); - fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); } else { // TODO: should we throw JSONRPCError ? fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); @@ -3013,7 +3013,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); if (it != mapBlockIndex.end()) { nHeight = it->second->GetHeight(); - fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); } else { // TODO: should we throw JSONRPCError ? fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); @@ -3804,7 +3804,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); if (it != mapBlockIndex.end()) { nHeight = it->second->GetHeight(); - fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); } else { fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); } @@ -3836,7 +3836,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); if (it != mapBlockIndex.end()) { nHeight = it->second->GetHeight(); - fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); } else { fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); } From 4f5c4db6152792ff78035d9cf51c35c92ebb56ec Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 11 Jan 2019 05:49:55 +0100 Subject: [PATCH 0911/3904] update BIP44 cointype we had the wrong cointype - 141 is the correct one and assigned to KMD https://github.com/satoshilabs/slips/blob/master/slip-0044.md --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d97ed8624..23d900d4e 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -107,7 +107,7 @@ public: strNetworkID = "main"; strCurrencyUnits = "KMD"; - bip44CoinType = 133; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC) + bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC) consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800 consensus.nSubsidySlowStartInterval = 20000; consensus.nSubsidyHalvingInterval = 840000; From a47ba0cf7ae1df3df13fcdfc78242a4ae159193c Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 11 Jan 2019 05:53:17 +0100 Subject: [PATCH 0912/3904] update BIP44 cointype use correct assigned BIP44 cointype --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a04e4131a..af82f3a35 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -92,7 +92,7 @@ public: strNetworkID = "main"; strCurrencyUnits = "KMD"; - bip44CoinType = 133; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC) + bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC) consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800 consensus.nSubsidySlowStartInterval = 20000; consensus.nSubsidyHalvingInterval = 840000; From 7598204bf98d5316c3dad7c40a458810b6c71d55 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Jan 2019 18:49:38 -1100 Subject: [PATCH 0913/3904] Fix bip44 code --- src/chainparams.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a04e4131a..02b73f04b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -92,7 +92,8 @@ public: strNetworkID = "main"; strCurrencyUnits = "KMD"; - bip44CoinType = 133; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC) + bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md + consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800 consensus.nSubsidySlowStartInterval = 20000; consensus.nSubsidyHalvingInterval = 840000; From 1e0e89523c062019a529c8125d869f9bb3d3ab59 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 11 Jan 2019 17:06:06 +0800 Subject: [PATCH 0914/3904] fix segid in pindex, fix help. Remove more pointless prints. --- src/komodo_bitcoind.h | 4 ++-- src/rpc/blockchain.cpp | 34 ++++++++++++++++++++++++++-------- src/rpc/crosschain.cpp | 8 ++++---- src/txdb.cpp | 6 +++++- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0ae824cd6..a13442760 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2055,7 +2055,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod return(blocktime); } } - } else fprintf(stderr,"maxiters is not good enough\n"); + } //else fprintf(stderr,"maxiters is not good enough\n"); return(0); } @@ -2186,7 +2186,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt decode_hex((uint8_t *)utxotxidp,32,(char *)kp->txid.GetHex().c_str()); *utxovoutp = kp->vout; *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; - fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); + //fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); } } //else fprintf(stderr,"utxo not eligible\n"); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c210e3099..bb46f47fb 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -49,6 +49,7 @@ extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); int32_t komodo_longestchain(); int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +extern int8_t komodo_segid(int32_t nocache,int32_t height); extern int32_t KOMODO_LONGESTCHAIN; double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty) @@ -147,7 +148,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex) result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits))); result.push_back(Pair("difficulty", GetDifficulty(blockindex))); result.push_back(Pair("chainwork", blockindex->chainPower.chainWork.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); + result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight()))); if (blockindex->pprev) result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); @@ -174,7 +175,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) result.push_back(Pair("height", blockindex->GetHeight())); result.push_back(Pair("version", block.nVersion)); result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); + result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight()))); UniValue deltas(UniValue::VARR); @@ -292,7 +293,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx result.push_back(Pair("height", blockindex->GetHeight())); result.push_back(Pair("version", block.nVersion)); result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); + result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight()))); result.push_back(Pair("finalsaplingroot", block.hashFinalSaplingRoot.GetHex())); UniValue txs(UniValue::VARR); BOOST_FOREACH(const CTransaction&tx, block.vtx) @@ -647,22 +648,39 @@ UniValue getlastsegidstakes(const UniValue& params, bool fHelp) LOCK(cs_main); int depth = params[0].get_int(); + if ( depth > chainActive.Height() ) + throw runtime_error("Not enough blocks to scan back that far.\n"); + int32_t segids[64] = {0}; + int32_t pow = 0; + int32_t notset = 0; for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) { - CBlockIndex* pblockindex = chainActive[i]; - if ( pblockindex->segid >= 0 ) - segids[pblockindex->segid] += 1; + int8_t segid = komodo_segid(0,i); + //CBlockIndex* pblockindex = chainActive[i]; + if ( segid >= 0 ) + segids[segid] += 1; + else if ( segid == -1 ) + pow++; + else + notset++; } - + + int8_t posperc = 100*(depth-pow)/depth; + UniValue ret(UniValue::VOBJ); + UniValue objsegids(UniValue::VOBJ); for (int8_t i = 0; i < 64; i++) { char str[4]; sprintf(str, "%d", i); - ret.push_back(Pair(str,segids[i])); + objsegids.push_back(Pair(str,segids[i])); } + ret.push_back(Pair("NotSet",notset)); + ret.push_back(Pair("PoW",pow)); + ret.push_back(Pair("PoSPerc",posperc)); + ret.push_back(Pair("SegIds",objsegids)); return ret; } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index e2770b28c..d02c1a562 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -382,10 +382,10 @@ UniValue getimports(const UniValue& params, bool fHelp) " \"time\" : (numeric)\n" "}\n" "\nExamples:\n" - + HelpExampleCli("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") - + HelpExampleRpc("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") - + HelpExampleCli("getmigrates", "12800") - + HelpExampleRpc("getmigrates", "12800") + + HelpExampleCli("getimports", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleRpc("getimports", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleCli("getimports", "12800") + + HelpExampleRpc("getimports", "12800") ); LOCK(cs_main); diff --git a/src/txdb.cpp b/src/txdb.cpp index 55f71b28a..fbb94bb65 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -689,7 +689,11 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; pindexNew->nSaplingValue = diskindex.nSaplingValue; - + pindexNew->segid = diskindex.segid; + pindexNew->newcoins = diskindex.newcoins; + pindexNew->zfunds = diskindex.zfunds; + pindexNew->sproutfunds = diskindex.sproutfunds; + // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From dbf6a1f83d736ff99fa39f2b66e8b2be6f216646 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 11 Jan 2019 17:44:10 +0800 Subject: [PATCH 0915/3904] better fix --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a13442760..4117347b6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1202,7 +1202,8 @@ int8_t komodo_segid(int32_t nocache,int32_t height) if ( strcmp(destaddr,voutaddr) == 0 && block.vtx[txn_count-1].vout[0].nValue == value ) { segid = komodo_segid32(voutaddr) & 0x3f; - //fprintf(stderr,"komodo_segid.(%d) -> %02x\n",height,segid); + pindex->segid = segid; + //fprintf(stderr,"komodo_segid.(%d) -> %d\n",height,pindex->segid); } } else fprintf(stderr,"komodo_segid ht.%d couldnt extract voutaddress\n",height); } @@ -1476,7 +1477,6 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); segid = komodo_segid32(voutaddr) & 0x3f; - //fprintf(stderr,"komodo_segid.(%d) -> %d\n",height,segid); } if ( pindex != 0 && segid >= 0 ) { From 8b7ca0ed32f9ecb7b137d95fec3182e38ec6f630 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 11 Jan 2019 23:24:12 +0800 Subject: [PATCH 0916/3904] Exit LOCK when return(0)! --- src/miner.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 7948fd0cd..cbefcbc41 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -547,6 +547,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if (scriptPubKeyIn.IsPayToScriptHash() || scriptPubKeyIn.IsPayToCryptoCondition()) { fprintf(stderr,"CreateNewBlock: attempt to add timelock to pay2sh or pay2cc\n"); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } return 0; } @@ -639,6 +644,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, else { fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } return(0); } } From 3bf6b75986fe58c37f35828260eb434b6a2dca74 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 00:02:06 +0800 Subject: [PATCH 0917/3904] fix miner.cpp --- src/miner.cpp | 130 +------------------------------------------------- 1 file changed, 2 insertions(+), 128 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 56f348f6a..fb61e96ed 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -213,13 +213,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // we will attempt to spend any cheats we see CTransaction cheatTx; boost::optional cheatSpend; -<<<<<<< HEAD - uint256 cbHash; - -======= - uint256 cbHash; ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed + uint256 cbHash; + CBlockIndex* pindexPrev = 0; { ENTER_CRITICAL_SECTION(cs_main); @@ -289,7 +285,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool fNotarisation = false; if (tx.IsCoinImport()) { -<<<<<<< HEAD CAmount nValueIn = GetCoinImportValue(tx); // burn amount nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. @@ -298,12 +293,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if ( komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; -======= - CAmount nValueIn = GetCoinImportValue(tx); - nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier - } else { ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -342,7 +331,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, int nConf = nHeight - coins->nHeight; -<<<<<<< HEAD // This is to test is a tx is a notarisation and assign it max priotity. if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) { @@ -358,10 +346,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; -======= - dPriority += (double)nValueIn * nConf; } ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed nTotalIn += tx.GetShieldedValueIn(); } @@ -376,22 +361,10 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); -<<<<<<< HEAD if (fNotarisation) { dPriority = 1e16; //fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); -======= - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); - } - -<<<<<<< HEAD if (porphan) { porphan->dPriority = dPriority; @@ -494,101 +467,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, nBlockSigOps += nTxSigOps; nFees += nTxFees; -======= - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); - - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - - while (!vecPriority.empty()) - { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); - - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx - { - //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); - continue; - } - - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); - - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } - - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; - ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); @@ -617,11 +495,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); -<<<<<<< HEAD - -======= ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed int32_t stakeHeight = chainActive.Height() + 1; //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); From dbf6a552fcedbed6f720bd7f8933177e46984c0b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 00:04:49 +0800 Subject: [PATCH 0918/3904] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index fb61e96ed..06cf809c8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -346,7 +346,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; - } + nTotalIn += tx.GetShieldedValueIn(); } From a963718c7c04d76134cbdbfd3826039ac6f8ee55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 00:35:39 +0800 Subject: [PATCH 0919/3904] tx-overwinter-active skip check on wallet load --- src/wallet/walletdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index daa8881f5..3a3bdf500 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -486,7 +486,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) { - if (state.GetRejectReason() != "tx-overwinter-expired") + if (state.GetRejectReason() != "tx-overwinter-expired" && state.GetRejectReason() != "tx-overwinter-active") { fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); deadTxns.push_back(hash); From 94593ce8fd486049452f55eaf9d0d798d8c61871 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 01:15:19 +0800 Subject: [PATCH 0920/3904] CheckTransaction does not call overwinter checks --- src/wallet/walletdb.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 3a3bdf500..95ada1448 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -486,12 +486,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) { - if (state.GetRejectReason() != "tx-overwinter-expired" && state.GetRejectReason() != "tx-overwinter-active") - { - fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); - deadTxns.push_back(hash); - return false; - } + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + deadTxns.push_back(hash); + return false; } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) From 9392a2b9ecbbd3f2c802df817eb56cfa1e1b1081 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Sat, 12 Jan 2019 15:27:17 +0700 Subject: [PATCH 0921/3904] oracles autotests fixed --- qa/rpc-tests/cryptoconditions_oracles.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index f295bf020..048b577d1 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -112,17 +112,15 @@ class CryptoconditionsOraclesTest(CryptoconditionsTestFramework): # baton oraclesdata_d = self.send_and_mine(result["hex"], rpc) result = rpc.oraclessamples(globals()["oracle_{}".format("d")], oraclesdata_d, "1") - # TODO: working not correct now! - #assert_equal("[u'01']", str(result["samples"][0]), "Data match") + assert_equal("[u'01']", str(result["samples"][0]), "Data match") # D type - result = rpc.oraclesdata(globals()["oracle_{}".format("D")], "0101") + result = rpc.oraclesdata(globals()["oracle_{}".format("D")], "010001") assert_success(result) # baton oraclesdata_D = self.send_and_mine(result["hex"], rpc) result = rpc.oraclessamples(globals()["oracle_{}".format("D")], oraclesdata_D, "1") - # TODO: working not correct now! - #assert_equal("[u'01']", str(result["samples"][0]), "Data match") + assert_equal("[u'01']", str(result["samples"][0]), "Data match") # c type result = rpc.oraclesdata(globals()["oracle_{}".format("c")], "ff") @@ -198,12 +196,12 @@ class CryptoconditionsOraclesTest(CryptoconditionsTestFramework): assert_equal("[u'ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000']", str(result["samples"][0]), "Data match") # Ihh type - result = rpc.oraclesdata(globals()["oracle_{}".format("Ihh")], "00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff") + result = rpc.oraclesdata(globals()["oracle_{}".format("Ihh")], "ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff") assert_success(result) # baton oraclesdata_Ihh = self.send_and_mine(result["hex"], rpc) result = rpc.oraclessamples(globals()["oracle_{}".format("Ihh")], oraclesdata_Ihh, "1") - assert_equal("[u'0']", str(result["samples"][0]), "Data match") + assert_equal("[u'4294967295', u'ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000', u'ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000']", str(result["samples"][0]), "Data match") def run_test(self): From 2bde89c9ce4b3ae6d068a47bc3e2d43c070d829e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 00:29:37 -1100 Subject: [PATCH 0922/3904] Marmara coinbase initial impl --- src/cc/CCMarmara.h | 5 ++++ src/cc/marmara.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++ src/chainparams.cpp | 2 +- src/komodo_gateway.h | 10 +++++++ src/komodo_globals.h | 2 +- src/komodo_utils.h | 5 +++- 6 files changed, 85 insertions(+), 3 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 45fda83bd..5fc7fd673 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -19,6 +19,11 @@ #include "CCinclude.h" +#define MARMARA_GROUPSIZE 60 +#define MARMARA_MINLOCK (1440 * 3 * 30) +#define MARMARA_MAXLOCK (1440 * 24 * 30) +uint64_t komodo_block_prg(uint32_t nHeight); + bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 4bbccee4a..0f166e5df 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -71,6 +71,70 @@ bool MarmaraExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransactio else return(true); } +int32_t MarmaraRandomize(uint32_t ind) +{ + uint64_t val64; uint32_t val,range = (MARMARA_MAXLOCK - MARMARA_MINLOCK); + val64 = komodo_block_prg(ind); + val = (uint32_t)(val64 >> 32); + val ^= (uint32_t)val64; + return(val % range); +} + +int32_t MarmaraUnlockht(int32_t height) +{ + uint32_t ind = height / MARMARA_GROUPSIZE; + return(height + MarmaraRandomize(ind)); +} + +CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t height) +{ + CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_ORACLES; + unlockht = MarmaraUnlockht(ht); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << pk << height << unlockht); + return(opret); +} + +uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int32_t &height,int32_t &unlckht) +{ + std::vector vopret; uint8_t *script,e,f,funcid; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && script[0] == EVAL_MARMARA ) + { + if ( script[1] == 'C' ) + { + if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> height; ss >> unlockht) != 0 ) + { + return(script[1]); + } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for C\n"); + } + } + return(0); +} + +int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) +{ + struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; + cp = CCinit(&C,EVAL_MARMARA); + for (ht=0; ht<10000; ht+=MARMARA_GROUPSIZE/3) + fprintf(stderr,"%d ",MarmaraUnlockht(ht)); + fprintf(stderr,"<- unlock hts\n"); + if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) + { + if ( DecodeMaramaraCoinbaseOpRet(tx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' ) + { + if ( ht == height && MarmaraUnlockht(height) == unlockht ) + { + ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); + if ( ccvout.scriptPubKey == tx.vout[0].scriptPubKey ) + return(0); + fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey\n",height); + } else fprintf(stderr,"ht.%d %d vs %d unlock.%d\n",height,MarmaraUnlockht(height),ht,unlockht); + } else fprintf(stderr,"ht.%d error decoding coinbase opret\n"); + } + return(-1); +} + bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 23d900d4e..47f4d48a8 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -107,7 +107,7 @@ public: strNetworkID = "main"; strCurrencyUnits = "KMD"; - bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC) + bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800 consensus.nSubsidySlowStartInterval = 20000; consensus.nSubsidyHalvingInterval = 840000; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 982f16b0b..360ddfcc0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -16,6 +16,8 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse #include "komodo_defs.h" +int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx); + int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; @@ -687,6 +689,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } } + if ( ASSETCHAINS_MARMARA != 0 && (height & 1) != 0 ) + { + if ( MarmaraValidateCoinbase(height,block.vtx[0]) < 0 ) + { + fprintf(stderr,"MARMARA constrains odd height blocks to pay 100% to CC in vout0\n"); + return(-1); + } + } // we don't want these checks in VRSC, leave it at the Sapling upgrade if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_COMMISSION != 0 && height > 1) || diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 8a72b5ad7..f434674b7 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -49,7 +49,7 @@ unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,ASSETCHAINS_SELFIMPORT; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; bool VERUS_MINTBLOCKS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a5b22e592..55b9bec35 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1778,6 +1778,7 @@ void komodo_args(char *argv0) ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); + ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { fprintf(stderr,"can only have one of -ac_beam or -ac_coda\n"); @@ -1857,7 +1858,7 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_FOUNDERS needs an ASETCHAINS_OVERRIDE_PUBKEY\n"); } } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1931,6 +1932,8 @@ void komodo_args(char *argv0) extraptr[extralen++] = 'b'; if ( ASSETCHAINS_CODAPORT != 0 ) extraptr[extralen++] = 'c'; + if ( ASSETCHAINS_MARMARA != 0 ) + extraptr[extralen++] = ASSETCHAINS_MARMARA; } addn = GetArg("-seednode",""); From 2515d72e58e6d8606344476da150cd43c0e3447b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 00:32:20 -1100 Subject: [PATCH 0923/3904] Syntax --- src/cc/marmara.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 0f166e5df..1a67b4df6 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -86,15 +86,15 @@ int32_t MarmaraUnlockht(int32_t height) return(height + MarmaraRandomize(ind)); } -CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t height) +CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t ht) { CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_ORACLES; unlockht = MarmaraUnlockht(ht); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << pk << height << unlockht); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << pk << ht << unlockht); return(opret); } -uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int32_t &height,int32_t &unlckht) +uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int32_t &height,int32_t &unlockht) { std::vector vopret; uint8_t *script,e,f,funcid; GetOpReturnData(scriptPubKey,vopret); @@ -130,7 +130,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) return(0); fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey\n",height); } else fprintf(stderr,"ht.%d %d vs %d unlock.%d\n",height,MarmaraUnlockht(height),ht,unlockht); - } else fprintf(stderr,"ht.%d error decoding coinbase opret\n"); + } else fprintf(stderr,"ht.%d error decoding coinbase opret\n",height); } return(-1); } From 99f0709686d756806394ef7fd07472529d1ab1f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 00:34:24 -1100 Subject: [PATCH 0924/3904] Fix --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 360ddfcc0..0ad1b66ad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -693,7 +693,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( MarmaraValidateCoinbase(height,block.vtx[0]) < 0 ) { - fprintf(stderr,"MARMARA constrains odd height blocks to pay 100% to CC in vout0\n"); + fprintf(stderr,"MARMARA constrains odd height blocks to pay 100%% to CC in vout0 with opreturn\n"); return(-1); } } From c0a9c015adcc209562af07492d9f7bc4b097d0d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 00:37:41 -1100 Subject: [PATCH 0925/3904] Even heights with constraint so ac_supply is unlocked --- src/cc/marmara.cpp | 2 ++ src/komodo_gateway.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 1a67b4df6..359092ef9 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -119,6 +119,8 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) for (ht=0; ht<10000; ht+=MARMARA_GROUPSIZE/3) fprintf(stderr,"%d ",MarmaraUnlockht(ht)); fprintf(stderr,"<- unlock hts\n"); + if ( (height & 1) != 0 ) + return(0); if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { if ( DecodeMaramaraCoinbaseOpRet(tx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0ad1b66ad..fcdf4b85e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -689,11 +689,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } } - if ( ASSETCHAINS_MARMARA != 0 && (height & 1) != 0 ) + if ( height > 0 && ASSETCHAINS_MARMARA != 0 && (height & 1) == 0 ) { if ( MarmaraValidateCoinbase(height,block.vtx[0]) < 0 ) { - fprintf(stderr,"MARMARA constrains odd height blocks to pay 100%% to CC in vout0 with opreturn\n"); + fprintf(stderr,"MARMARA constrains even height blocks to pay 100%% to CC in vout0 with opreturn\n"); return(-1); } } From 5435d63aedd64fa8eb3abdf11d5872bdbe8331c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 00:57:16 -1100 Subject: [PATCH 0926/3904] Histogram --- src/cc/marmara.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 359092ef9..908e3557d 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -116,9 +116,18 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); - for (ht=0; ht<10000; ht+=MARMARA_GROUPSIZE/3) - fprintf(stderr,"%d ",MarmaraUnlockht(ht)); - fprintf(stderr,"<- unlock hts\n"); + int32_t d,histo[365*2]; + for (ht=2; ht<1000000; ht+=MARMARA_GROUPSIZE) + { + memset(histo,0,sizeof(histo)); + d = (MarmaraUnlockht(ht) - ht) / 1440 + if ( d < 0 || d > sizeof(histo)/sizeof(*histo) ) + fprintf(stderr,"d error.%d at ht.%d\n",d,ht); + else histo[d]++; + } + for (ht=0; ht Date: Sat, 12 Jan 2019 00:57:55 -1100 Subject: [PATCH 0927/3904] ; --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 908e3557d..254b62efd 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -120,7 +120,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) for (ht=2; ht<1000000; ht+=MARMARA_GROUPSIZE) { memset(histo,0,sizeof(histo)); - d = (MarmaraUnlockht(ht) - ht) / 1440 + d = (MarmaraUnlockht(ht) - ht) / 1440; if ( d < 0 || d > sizeof(histo)/sizeof(*histo) ) fprintf(stderr,"d error.%d at ht.%d\n",d,ht); else histo[d]++; From f816960557f9fe8e868bad5733372adf5023dc72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:00:08 -1100 Subject: [PATCH 0928/3904] memset Outside loop --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 254b62efd..389ed0227 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -117,9 +117,9 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); int32_t d,histo[365*2]; + memset(histo,0,sizeof(histo)); for (ht=2; ht<1000000; ht+=MARMARA_GROUPSIZE) { - memset(histo,0,sizeof(histo)); d = (MarmaraUnlockht(ht) - ht) / 1440; if ( d < 0 || d > sizeof(histo)/sizeof(*histo) ) fprintf(stderr,"d error.%d at ht.%d\n",d,ht); @@ -127,7 +127,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) } for (ht=0; ht Date: Sat, 12 Jan 2019 01:03:22 -1100 Subject: [PATCH 0929/3904] += MARMARA_MINLOCK --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 389ed0227..dadbb9249 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -77,7 +77,7 @@ int32_t MarmaraRandomize(uint32_t ind) val64 = komodo_block_prg(ind); val = (uint32_t)(val64 >> 32); val ^= (uint32_t)val64; - return(val % range); + return((val % range) + MARMARA_MINLOCK); } int32_t MarmaraUnlockht(int32_t height) @@ -116,7 +116,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); - int32_t d,histo[365*2]; + int32_t d,histo[365*2+30]; memset(histo,0,sizeof(histo)); for (ht=2; ht<1000000; ht+=MARMARA_GROUPSIZE) { From 9e55c207256cf83cc98aaa6c792ebb51ac2450d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:08:17 -1100 Subject: [PATCH 0930/3904] -print --- src/cc/marmara.cpp | 23 +++++++++++++---------- src/komodo_gateway.h | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index dadbb9249..8cfd6f6de 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -116,18 +116,21 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); - int32_t d,histo[365*2+30]; - memset(histo,0,sizeof(histo)); - for (ht=2; ht<1000000; ht+=MARMARA_GROUPSIZE) + if ( 0 ) { - d = (MarmaraUnlockht(ht) - ht) / 1440; - if ( d < 0 || d > sizeof(histo)/sizeof(*histo) ) - fprintf(stderr,"d error.%d at ht.%d\n",d,ht); - else histo[d]++; + int32_t d,histo[365*2+30]; + memset(histo,0,sizeof(histo)); + for (ht=2; ht<1000000; ht+=MARMARA_GROUPSIZE) + { + d = (MarmaraUnlockht(ht) - ht) / 1440; + if ( d < 0 || d > sizeof(histo)/sizeof(*histo) ) + fprintf(stderr,"d error.%d at ht.%d\n",d,ht); + else histo[d]++; + } + for (ht=0; ht Date: Sat, 12 Jan 2019 01:36:01 -1100 Subject: [PATCH 0931/3904] Marmara coinbase opret --- src/cc/marmara.cpp | 29 +++++++++++++++++++++++++++++ src/miner.cpp | 14 ++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8cfd6f6de..a7e9f2d1f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -112,6 +112,35 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 return(0); } +CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey) +{ + CTxOut ccvout; uint8_t *ptr; CPubKey pk; + if ( height > 0 && ASSETCHAINS_MARMARA != 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) + { + ptr = (uint8_t *)pubkey.begin(); + if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) + pk = buf2pk(ptr+1); + ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); + return(ccvout.scriptPubKey); + } + return(scriptPubKey); +} + +CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey) +{ + uint8_t *ptr; CPubKey pk; + if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) + { + ptr = (uint8_t *)pubkey.begin(); + if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) + { + pk = buf2pk(ptr+1); + return(EncodeMarmaraCoinbaseOpRet(pk,height); + } + } + return(scriptPubKey); +} + int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; diff --git a/src/miner.cpp b/src/miner.cpp index 7948fd0cd..223972c80 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -141,7 +141,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); -extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; +extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; uint32_t Mining_start,Mining_height; int32_t My_notaryid = -1; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); @@ -155,6 +155,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey); +CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey); CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -534,7 +536,13 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // check if coinbase transactions must be time locked at current subsidy and prepend the time lock // to transaction if so, cast for GTE operator - if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) + if ( ASSETCHAINS_MARMARA != 0 && height > 0 && (height & 1) == 0 ) + { + txNew.vout.resize(2); + txNew.vout[1].nValue = 0; + txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret(nHeight,scriptPubKeyIn); + } + else if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { int32_t opretlen, p2shlen, scriptlen; CScriptExt opretScript = CScriptExt(); @@ -775,6 +783,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } } + if ( ASSETCHAINS_MARMARA != 0 ) + scriptPubKey = Marmara_scriptPubKey(height,scriptPubKey); return CreateNewBlock(scriptPubKey, gpucount, isStake); } From 5b4ae1d702358a4cfc171ef599c2152d9e89fc31 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:37:41 -1100 Subject: [PATCH 0932/3904] Fix --- src/cc/marmara.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index a7e9f2d1f..93d24b868 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -115,9 +115,9 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey) { CTxOut ccvout; uint8_t *ptr; CPubKey pk; - if ( height > 0 && ASSETCHAINS_MARMARA != 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) + if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) { - ptr = (uint8_t *)pubkey.begin(); + ptr = (uint8_t *)scriptPubKey.begin(); if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) pk = buf2pk(ptr+1); ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); @@ -131,11 +131,11 @@ CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey) uint8_t *ptr; CPubKey pk; if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) { - ptr = (uint8_t *)pubkey.begin(); + ptr = (uint8_t *)scriptPubKey.begin(); if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) { pk = buf2pk(ptr+1); - return(EncodeMarmaraCoinbaseOpRet(pk,height); + return(EncodeMarmaraCoinbaseOpRet(pk,height)); } } return(scriptPubKey); From e656efa89c2c468921d2297f2bbcb2e474209c0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:38:30 -1100 Subject: [PATCH 0933/3904] data() --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 93d24b868..f25b0c62a 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -117,7 +117,7 @@ CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey) CTxOut ccvout; uint8_t *ptr; CPubKey pk; if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) { - ptr = (uint8_t *)scriptPubKey.begin(); + ptr = (uint8_t *)scriptPubKey.data(); if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) pk = buf2pk(ptr+1); ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); @@ -131,7 +131,7 @@ CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey) uint8_t *ptr; CPubKey pk; if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) { - ptr = (uint8_t *)scriptPubKey.begin(); + ptr = (uint8_t *)scriptPubKey.data(); if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) { pk = buf2pk(ptr+1); From 9a46e8a5774207d45950fcf7a83251d271a6f050 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:45:23 -1100 Subject: [PATCH 0934/3904] Use pk --- src/cc/marmara.cpp | 29 ++++++++--------------------- src/miner.cpp | 18 +++++++++++------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f25b0c62a..63a8bbe3b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -112,33 +112,20 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 return(0); } -CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey) +CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { - CTxOut ccvout; uint8_t *ptr; CPubKey pk; - if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) - { - ptr = (uint8_t *)scriptPubKey.data(); - if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) - pk = buf2pk(ptr+1); + CTxOut ccvout; + if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); - return(ccvout.scriptPubKey); - } - return(scriptPubKey); + return(ccvout.scriptPubKey); } -CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey) +CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk) { uint8_t *ptr; CPubKey pk; - if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) - { - ptr = (uint8_t *)scriptPubKey.data(); - if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) - { - pk = buf2pk(ptr+1); - return(EncodeMarmaraCoinbaseOpRet(pk,height)); - } - } - return(scriptPubKey); + if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) + return(EncodeMarmaraCoinbaseOpRet(pk,height)); + return(CScript()); } int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) diff --git a/src/miner.cpp b/src/miner.cpp index 223972c80..3322bbb16 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,8 +155,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); -CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey); -CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey); +CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); +CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk); CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -540,7 +540,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, { txNew.vout.resize(2); txNew.vout[1].nValue = 0; - txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret(nHeight,scriptPubKeyIn); + txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret(nHeight,pk); } else if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { @@ -751,7 +751,10 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 ) { if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) - scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + { + pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY); + scriptPubKey = CScript() << pubkey << OP_CHECKSIG; + } else { len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); @@ -764,7 +767,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); - scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + pubkey = ParseHex(NOTARY_PUBKEY); + scriptPubKey = CScript() << pubkey << OP_CHECKSIG; } else { @@ -783,8 +787,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } } - if ( ASSETCHAINS_MARMARA != 0 ) - scriptPubKey = Marmara_scriptPubKey(height,scriptPubKey); + if ( ASSETCHAINS_MARMARA != 0 && height > 0 && (height & 1) == 0 ) + scriptPubKey = Marmara_scriptPubKey(height,pubkey); return CreateNewBlock(scriptPubKey, gpucount, isStake); } From 8b43e641290d0a4bdf34bfb035d2bd0a0b348c1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:45:57 -1100 Subject: [PATCH 0935/3904] Fx --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 63a8bbe3b..18ba87734 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -122,7 +122,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk) { - uint8_t *ptr; CPubKey pk; + uint8_t *ptr; if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) return(EncodeMarmaraCoinbaseOpRet(pk,height)); return(CScript()); From 621be31f25d3473bc313fab756bd3fa3ea9b5751 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:48:55 -1100 Subject: [PATCH 0936/3904] nHeight --- src/miner.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3322bbb16..51078f963 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -536,7 +536,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // check if coinbase transactions must be time locked at current subsidy and prepend the time lock // to transaction if so, cast for GTE operator - if ( ASSETCHAINS_MARMARA != 0 && height > 0 && (height & 1) == 0 ) + if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) { txNew.vout.resize(2); txNew.vout[1].nValue = 0; @@ -753,7 +753,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY); - scriptPubKey = CScript() << pubkey << OP_CHECKSIG; + scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG; } else { @@ -768,7 +768,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, { //fprintf(stderr,"use notary pubkey\n"); pubkey = ParseHex(NOTARY_PUBKEY); - scriptPubKey = CScript() << pubkey << OP_CHECKSIG; + scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG; } else { @@ -787,8 +787,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } } - if ( ASSETCHAINS_MARMARA != 0 && height > 0 && (height & 1) == 0 ) - scriptPubKey = Marmara_scriptPubKey(height,pubkey); + if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) + scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey); return CreateNewBlock(scriptPubKey, gpucount, isStake); } From 4bb5c6cbd311b291ecf9a5259e68175974609a10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:54:01 -1100 Subject: [PATCH 0937/3904] EVAL_MARMARA --- src/cc/marmara.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 18ba87734..a069af713 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -88,7 +88,7 @@ int32_t MarmaraUnlockht(int32_t height) CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t ht) { - CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_ORACLES; + CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_MARMARA; unlockht = MarmaraUnlockht(ht); opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << pk << ht << unlockht); return(opret); @@ -107,8 +107,8 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 { return(script[1]); } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for C\n"); - } - } + } else fprintf(stderr,"script[1] is %d != 'C' %d\n",script[1],'C'); + } else fprintf(stderr,"vopret.size() is %d [0] is %d != %d\n",vopret.size(),script[0],EVAL_MARMARA); return(0); } From e1dd671e66eb2c243c562b8dff4ea9e12fdeed1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 01:54:48 -1100 Subject: [PATCH 0938/3904] (Int32_t) --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index a069af713..41a85802e 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -108,7 +108,7 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 return(script[1]); } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for C\n"); } else fprintf(stderr,"script[1] is %d != 'C' %d\n",script[1],'C'); - } else fprintf(stderr,"vopret.size() is %d [0] is %d != %d\n",vopret.size(),script[0],EVAL_MARMARA); + } else fprintf(stderr,"vopret.size() is %d [0] is %d != %d\n",(int32_t)vopret.size(),script[0],EVAL_MARMARA); return(0); } From 8250a4bab83940782ef5b0331eb5ff719db58215 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 02:00:17 -1100 Subject: [PATCH 0939/3904] +print --- src/cc/marmara.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 41a85802e..9cb9ce813 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -91,6 +91,16 @@ CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t ht) CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_MARMARA; unlockht = MarmaraUnlockht(ht); opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << pk << ht << unlockht); + { + std::vector vopret; uint8_t *script,i; + GetOpReturnData(opret,vopret); + script = (uint8_t *)vopret.data(); + { + for (i=0; i vopret; uint8_t *script,e,f,funcid; GetOpReturnData(scriptPubKey,vopret); script = (uint8_t *)vopret.data(); + { + int32_t i; + for (i=0; i 2 && script[0] == EVAL_MARMARA ) { if ( script[1] == 'C' ) @@ -108,7 +124,7 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 return(script[1]); } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for C\n"); } else fprintf(stderr,"script[1] is %d != 'C' %d\n",script[1],'C'); - } else fprintf(stderr,"vopret.size() is %d [0] is %d != %d\n",(int32_t)vopret.size(),script[0],EVAL_MARMARA); + } else fprintf(stderr,"vopret.size() is %d\n",(int32_t)vopret.size()); return(0); } From cf2251127a9044097fbf667bb71b6d5336f1f34d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 02:03:53 -1100 Subject: [PATCH 0940/3904] +prints --- src/cc/marmara.cpp | 1 + src/miner.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 9cb9ce813..d69585046 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -139,6 +139,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk) { uint8_t *ptr; + fprintf(stderr,"height.%d pksize.%d\n",height,(int32_t)pk.size()); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) return(EncodeMarmaraCoinbaseOpRet(pk,height)); return(CScript()); diff --git a/src/miner.cpp b/src/miner.cpp index 51078f963..62eb46f69 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -167,6 +167,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, txnouttype txT; if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs)) { + fprintf(stderr,"txT.%d vs TX_PUBKEY.%d\n",txT,TX_PUBKEY); if (txT == TX_PUBKEY) pk = CPubKey(vAddrs[0]); } From a06cbd09ae778f953d9e441de36a088ed2cc1684 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 02:10:49 -1100 Subject: [PATCH 0941/3904] Pass in _pk to CreateBlock --- src/miner.cpp | 23 +++++++++++++---------- src/miner.h | 2 +- src/test/miner_tests.cpp | 26 +++++++++++++------------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 62eb46f69..c6df5cdb6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -158,19 +158,22 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk); -CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) +CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { CScript scriptPubKeyIn(_scriptPubKeyIn); - CPubKey pk = CPubKey(); - std::vector> vAddrs; - txnouttype txT; - if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs)) + CPubKey pk; + if ( _pk.size() != 33 ) { - fprintf(stderr,"txT.%d vs TX_PUBKEY.%d\n",txT,TX_PUBKEY); - if (txT == TX_PUBKEY) - pk = CPubKey(vAddrs[0]); - } + pk = CPubKey(); + std::vector> vAddrs; + txnouttype txT; + if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs)) + { + if (txT == TX_PUBKEY) + pk = CPubKey(vAddrs[0]); + } + } else pk = _pk; uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); //fprintf(stderr,"create new block\n"); @@ -790,7 +793,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey); - return CreateNewBlock(scriptPubKey, gpucount, isStake); + return CreateNewBlock(pubkey,scriptPubKey, gpucount, isStake); } void komodo_broadcast(CBlock *pblock,int32_t limit) diff --git a/src/miner.h b/src/miner.h index 5494022bd..a3bedd292 100644 --- a/src/miner.h +++ b/src/miner.h @@ -43,7 +43,7 @@ struct CBlockTemplate #define KOMODO_MAXGPUCOUNT 65 /** Generate a new block, without valid proof-of-work */ -CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, int32_t gpucount, bool isStake = false); +CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& scriptPubKeyIn, int32_t gpucount, bool isStake = false); #ifdef ENABLE_WALLET boost::optional GetMinerScriptPubKey(CReserveKey& reservekey); CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake = false); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 6d80fc4b7..277b726c8 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i) { // Simple block creation, nothing special yet: - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); CBlock *pblock = &pblocktemplate->block; // pointer for convenience pblock->nVersion = 4; @@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) } // Just to make sure we can still make simple blocks - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; // block sigops > limit: 1000 CHECKMULTISIG + 1 @@ -292,7 +292,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); tx.vin[0].prevout.hash = hash; } - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -313,14 +313,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); tx.vin[0].prevout.hash = hash; } - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); // orphan in mempool hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -338,7 +338,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue = 49000LL; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -349,7 +349,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue = 0; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -367,7 +367,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue -= 10000; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); @@ -381,17 +381,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].scriptPubKey = CScript() << OP_2; hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; mempool.clear(); // subsidy changing int nHeight = chainActive.Height(); chainActive.Tip()->SetHeight(209999); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; chainActive.Tip()->SetHeight(210000); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); delete pblocktemplate; chainActive.Tip()->SetHeight(nHeight); @@ -423,7 +423,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx2)); BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); // Neither tx should have made it into the template. BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1); @@ -438,7 +438,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) //BOOST_CHECK(CheckFinalTx(tx)); //BOOST_CHECK(CheckFinalTx(tx2)); - BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1)); + BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1)); BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2); delete pblocktemplate; From 5a8af74e4ddc92784747ce5dbe7497ec4cd3c977 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 02:13:18 -1100 Subject: [PATCH 0942/3904] Include pubkey.h --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index c6df5cdb6..35ba20798 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -24,6 +24,7 @@ #endif #include "amount.h" +#include "pubkey.h" #include "chainparams.h" #include "importcoin.h" #include "consensus/consensus.h" From ad0842336bf9c45ea11e44c4170ba1e25de0bf17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 02:13:32 -1100 Subject: [PATCH 0943/3904] First --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 35ba20798..fb9ed8820 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -18,13 +18,13 @@ * * ******************************************************************************/ +#include "pubkey.h" #include "miner.h" #ifdef ENABLE_MINING #include "pow/tromp/equi_miner.h" #endif #include "amount.h" -#include "pubkey.h" #include "chainparams.h" #include "importcoin.h" #include "consensus/consensus.h" From 0638d3b056c04e949004f0e5e3b2614a58604117 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 02:18:55 -1100 Subject: [PATCH 0944/3904] Map all unlock hts in group to same unlockht --- src/cc/marmara.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d69585046..8cd949981 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -83,6 +83,7 @@ int32_t MarmaraRandomize(uint32_t ind) int32_t MarmaraUnlockht(int32_t height) { uint32_t ind = height / MARMARA_GROUPSIZE; + height = (height / MARMARA_GROUPSIZE) * MARMARA_GROUPSIZE; return(height + MarmaraRandomize(ind)); } @@ -91,6 +92,7 @@ CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t ht) CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_MARMARA; unlockht = MarmaraUnlockht(ht); opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << pk << ht << unlockht); + if ( 0 ) { std::vector vopret; uint8_t *script,i; GetOpReturnData(opret,vopret); @@ -109,6 +111,7 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 std::vector vopret; uint8_t *script,e,f,funcid; GetOpReturnData(scriptPubKey,vopret); script = (uint8_t *)vopret.data(); + if ( 0 ) { int32_t i; for (i=0; i 0 && (height & 1) == 0 && pk.size() == 33 ) return(EncodeMarmaraCoinbaseOpRet(pk,height)); return(CScript()); @@ -149,10 +152,13 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); - if ( 0 ) + if ( 1 ) { int32_t d,histo[365*2+30]; memset(histo,0,sizeof(histo)); + for (ht=2; ht<100; ht++) + fprintf(stderr,"%d ",MarmaraUnlockht(ht)); + fprintf(stderr," <- first 100 unlock heights\n"); for (ht=2; ht<1000000; ht+=MARMARA_GROUPSIZE) { d = (MarmaraUnlockht(ht) - ht) / 1440; From f3b0e439c38e96396720ebe03d8e83c0a73340c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 02:21:32 -1100 Subject: [PATCH 0945/3904] Test --- src/cc/marmara.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8cd949981..3c011ec02 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -152,7 +152,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); - if ( 1 ) + if ( 0 ) { int32_t d,histo[365*2+30]; memset(histo,0,sizeof(histo)); @@ -178,6 +178,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { if ( ht == height && MarmaraUnlockht(height) == unlockht ) { + fprintf(stderr,"ht.%d -> unlock.%d\n",ht,unlockht); ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); if ( ccvout.scriptPubKey == tx.vout[0].scriptPubKey ) return(0); From a0c16d089ac51644e0a25c7cf09458b6851d583e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:20:30 -1100 Subject: [PATCH 0946/3904] MarmaraPoolPayout --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 132 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 108 insertions(+), 25 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 5fc7fd673..15a8f811f 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -23,6 +23,7 @@ #define MARMARA_MINLOCK (1440 * 3 * 30) #define MARMARA_MAXLOCK (1440 * 24 * 30) uint64_t komodo_block_prg(uint32_t nHeight); +UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKey poolpk,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 3c011ec02..2167c1364 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -87,11 +87,11 @@ int32_t MarmaraUnlockht(int32_t height) return(height + MarmaraRandomize(ind)); } -CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t ht) +CScript EncodeMarmaraCoinbaseOpRet(uint8_t funcid,CPubKey pk,int32_t ht) { CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_MARMARA; unlockht = MarmaraUnlockht(ht); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << pk << ht << unlockht); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk << ht << unlockht); if ( 0 ) { std::vector vopret; uint8_t *script,i; @@ -100,13 +100,13 @@ CScript EncodeMarmaraCoinbaseOpRet(CPubKey pk,int32_t ht) { for (i=0; i vopret; uint8_t *script,e,f,funcid; GetOpReturnData(scriptPubKey,vopret); @@ -120,13 +120,13 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 } if ( vopret.size() > 2 && script[0] == EVAL_MARMARA ) { - if ( script[1] == 'C' ) + if ( script[1] == 'C' || script[1] == 'P' ) { if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> height; ss >> unlockht) != 0 ) { return(script[1]); - } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for C\n"); - } else fprintf(stderr,"script[1] is %d != 'C' %d\n",script[1],'C'); + } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for %c\n",script[1]); + } else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d\n",script[1],'C','P'); } else fprintf(stderr,"vopret.size() is %d\n",(int32_t)vopret.size()); return(0); } @@ -144,7 +144,7 @@ CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk) uint8_t *ptr; //fprintf(stderr,"height.%d pksize.%d\n",height,(int32_t)pk.size()); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) - return(EncodeMarmaraCoinbaseOpRet(pk,height)); + return(EncodeMarmaraCoinbaseOpRet('C',pk,height)); return(CScript()); } @@ -230,29 +230,31 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t // helper functions for rpc calls in rpcwallet.cpp -int64_t AddMarmaraInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx,int32_t firstheight,CPubKey poolpk,int32_t maxinputs) { - // add threshold check - char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; + char coinaddr[64]; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,pk); + GetCCaddress(cp,coinaddr,poolpk); SetCCunspents(unspentOutputs,coinaddr); + unlocks = MarmaraUnlockHt(firstheight); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; vout = (int32_t)it->first.index; - // no need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && vintx.IsCoinBase() != 0 ) { - if ( (nValue= IsMarmaravout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk ) { - if ( total != 0 && maxinputs != 0 ) - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - nValue = it->second.satoshis; - totalinputs += nValue; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) - break; + if ( (nValue= IsMarmaravout(cp,vintx,vout)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + if ( maxinputs != 0 ) + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + nValue = it->second.satoshis; + totalinputs += nValue; + n++; + if ( maxinputs > 0 && n >= maxinputs ) + break; + } } } } @@ -326,9 +328,89 @@ UniValue MarmaraInfo() result.push_back(Pair("name","Marmara")); cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); - funding = AddMarmaraInputs(cp,mtx,Marmarapk,0,0); - sprintf(numstr,"%.8f",(double)funding/COIN); - result.push_back(Pair("funding",numstr)); + return(result); +} + +UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKey poolpk,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); cJSON *item,*array; std::string res; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; + if ( pubkey2pk(Mypubkey()) != poolpk ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","poolpk is not your pubkey")); + return(result); + } + if ( txfee == 0 ) + txfee = 10000; + cp = CCinit(&C,EVAL_MARMARA); + Marmarapk = GetUnspendable(cp,0); + if ( (array= cJSON_Parse(jsonstr)) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; i SMALLVAL ) + { + shares += shares * perc; + if ( (total= AddMarmaraCoinbases(cp,mtx,firstheight,poolpk,60)) > 0 ) + { + for (i=0; i SMALLVAL ) + { + payout = (share * (total - txfee)) / shares; + if ( payout > 0 ) + { + if ( (pkstr= jstr(jitem(item,0))) != 0 && strlen(pkstr) == 66 ) + { + totalpayout += payout; + decode_hex(buf,33,pkstr); + mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,payout,Marmarapk,buf2pk(buf))); + } + } + } + } + if ( totalpayout > 0 && total > totalpayout-txfee ) + { + mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,total - totalpayout - txfee,Marmarapk,poolpk)); + } + rawtx = FinalizeCCTx(0,cp,mtx,poolpk,txfee,MarmaraCoinbaseOpret('P',height,poolpk))); + if ( rawtx.size() == 0 ) + errorstr = "couldnt finalize CCtx"; + } else errorstr = "couldnt find any coinbases to payout"; + } + else if ( errorstr == 0 ) + errorstr = "no valid shares submitted"; + free(array); + } else errorstr = "couldnt parse poolshares jsonstr"; + if ( rawtx.size() == 0 || errorstr != 0 ) + { + result.push_back(Pair("result","error")); + if ( errorstr != 0 ) + result.push_back(Pair("error",errorstr)); + } + else + { + result.push_back(Pair("result","success")); + result.push_back(Pair("rawtx",rawtx)); + if ( totalpayout > 0 && total > totalpayout-txfee ) + { + result.push_back(Pair("totalpayout",(double)totalpayout/COIN)); + result.push_back(Pair("totalshares",shares)); + result.push_back(Pair("poolfee",(double)(total - totalpayout)/COIN)); + result.push_back(Pair("perc",100. * (double)(total - totalpayout)/totalpayout)); + } + } return(result); } From a36f051e0c4c88f089d2632f2355fc6973eee7dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:23:32 -1100 Subject: [PATCH 0947/3904] cJSON.h --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 15a8f811f..a5f816fbe 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -18,6 +18,7 @@ #define CC_TRIGGERS_H #include "CCinclude.h" +#include "../cJSON.h" #define MARMARA_GROUPSIZE 60 #define MARMARA_MINLOCK (1440 * 3 * 30) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 2167c1364..8f3ec46c7 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -232,11 +232,11 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx,int32_t firstheight,CPubKey poolpk,int32_t maxinputs) { - char coinaddr[64]; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; + char coinaddr[64]; CPubKey pk; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,poolpk); SetCCunspents(unspentOutputs,coinaddr); - unlocks = MarmaraUnlockHt(firstheight); + unlocks = MarmaraUnlockht(firstheight); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -334,7 +334,7 @@ UniValue MarmaraInfo() UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKey poolpk,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); cJSON *item,*array; std::string res; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; if ( pubkey2pk(Mypubkey()) != poolpk ) { result.push_back(Pair("result","error")); @@ -354,7 +354,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKe shares += jdouble(jitem(item,1),0); else { - errorstr = "all items must be of the form [, ]"; + errorstr = (char *)"all items must be of the form [, ]"; break; } } @@ -386,13 +386,13 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKe } rawtx = FinalizeCCTx(0,cp,mtx,poolpk,txfee,MarmaraCoinbaseOpret('P',height,poolpk))); if ( rawtx.size() == 0 ) - errorstr = "couldnt finalize CCtx"; - } else errorstr = "couldnt find any coinbases to payout"; + errorstr = (char *)"couldnt finalize CCtx"; + } else errorstr = (char *)"couldnt find any coinbases to payout"; } else if ( errorstr == 0 ) - errorstr = "no valid shares submitted"; + errorstr = (char *)"no valid shares submitted"; free(array); - } else errorstr = "couldnt parse poolshares jsonstr"; + } else errorstr = (char *)"couldnt parse poolshares jsonstr"; if ( rawtx.size() == 0 || errorstr != 0 ) { result.push_back(Pair("result","error")); @@ -401,7 +401,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKe } else { - result.push_back(Pair("result","success")); + result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); if ( totalpayout > 0 && total > totalpayout-txfee ) { From f9f1452336c235f9932664ffba55abd12a6b0077 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:26:34 -1100 Subject: [PATCH 0948/3904] komodo_cJSON.h --- src/cc/CCMarmara.h | 2 +- src/cc/marmara.cpp | 41 ----------------------------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index a5f816fbe..b25f73f4b 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -18,7 +18,7 @@ #define CC_TRIGGERS_H #include "CCinclude.h" -#include "../cJSON.h" +#include "../komodo_cJSON.h" #define MARMARA_GROUPSIZE 60 #define MARMARA_MINLOCK (1440 * 3 * 30) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8f3ec46c7..f04941da3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -261,47 +261,6 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, return(totalinputs); } -std::string MarmaraGet(uint64_t txfee,int64_t nValue) -{ - CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Marmarapk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; - cp = CCinit(&C,EVAL_MARMARA); - if ( txfee == 0 ) - txfee = 10000; - Marmarapk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddMarmaraInputs(cp,mtx,Marmarapk,nValue+txfee,60)) > 0 ) - { - if ( inputs > nValue ) - CCchange = (inputs - nValue - txfee); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,CCchange,Marmarapk)); - mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - fprintf(stderr,"start at %u\n",(uint32_t)time(NULL)); - j = rand() & 0xfffffff; - for (i=0; i<1000000; i++,j++) - { - tmpmtx = mtx; - rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_MARMARA << (uint8_t)'G' << j)); - if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 ) - { - len >>= 1; - decode_hex(buf,len,(char *)rawhex.c_str()); - hash = bits256_doublesha256(0,buf,len); - if ( (hash.bytes[0] & 0xff) == 0 && (hash.bytes[31] & 0xff) == 0 ) - { - fprintf(stderr,"found valid txid after %d iterations %u\n",i,(uint32_t)time(NULL)); - return(rawhex); - } - //fprintf(stderr,"%02x%02x ",hash.bytes[0],hash.bytes[31]); - } - } - fprintf(stderr,"couldnt generate valid txid %u\n",(uint32_t)time(NULL)); - return(""); - } else fprintf(stderr,"cant find Marmara inputs\n"); - return(""); -} - std::string MarmaraFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); From 38705bdb2168e0cc4a328a618524ec43d6f7bceb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:28:04 -1100 Subject: [PATCH 0949/3904] Syntax --- src/cc/marmara.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f04941da3..5e9706ca9 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -309,7 +309,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKe for (i=0; i 0 ) { - if ( (pkstr= jstr(jitem(item,0))) != 0 && strlen(pkstr) == 66 ) + if ( (pkstr= jstr(jitem(item,0),0)) != 0 && strlen(pkstr) == 66 ) { totalpayout += payout; decode_hex(buf,33,pkstr); @@ -343,7 +343,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKe { mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,total - totalpayout - txfee,Marmarapk,poolpk)); } - rawtx = FinalizeCCTx(0,cp,mtx,poolpk,txfee,MarmaraCoinbaseOpret('P',height,poolpk))); + rawtx = FinalizeCCTx(0,cp,mtx,poolpk,txfee,MarmaraCoinbaseOpret('P',firstheight,poolpk))); if ( rawtx.size() == 0 ) errorstr = (char *)"couldnt finalize CCtx"; } else errorstr = (char *)"couldnt find any coinbases to payout"; From ee21bd6bc8156e99b3eeb76ef4c552b4b0e19db9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:31:29 -1100 Subject: [PATCH 0950/3904] Coinbaseopret --- src/cc/marmara.cpp | 4 ++-- src/miner.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5e9706ca9..6ba46dc8f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -139,12 +139,12 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) return(ccvout.scriptPubKey); } -CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk) +CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk) { uint8_t *ptr; //fprintf(stderr,"height.%d pksize.%d\n",height,(int32_t)pk.size()); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) - return(EncodeMarmaraCoinbaseOpRet('C',pk,height)); + return(EncodeMarmaraCoinbaseOpRet(funcid,pk,height)); return(CScript()); } diff --git a/src/miner.cpp b/src/miner.cpp index fb9ed8820..5ea5aafe0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -157,7 +157,7 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); -CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk); +CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -545,7 +545,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { txNew.vout.resize(2); txNew.vout[1].nValue = 0; - txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret(nHeight,pk); + txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); } else if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { From 386286c95d7220174ef1a838db0c2a09639d7b82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:47:18 -1100 Subject: [PATCH 0951/3904] +prints --- src/komodo_bitcoind.h | 8 ++++---- src/komodo_utils.h | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c6eb05324..00ce20853 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1721,10 +1721,10 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) matched = 25; if ( matched == 0 ) { - //int32_t i; - //for (i=0; i<25; i++) - // fprintf(stderr,"%02x",script[i]); - //fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d]\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2); + int32_t i; + for (i=0; i 1 && ASSETCHAINS_MARMARA != 0 ) + { + fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); + exit(0); + } if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); From b02113975d8ca9be2a1d122b0649e6f6d4043bf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:48:09 -1100 Subject: [PATCH 0952/3904] -) --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 6ba46dc8f..bdd7b2be7 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -343,7 +343,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKe { mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,total - totalpayout - txfee,Marmarapk,poolpk)); } - rawtx = FinalizeCCTx(0,cp,mtx,poolpk,txfee,MarmaraCoinbaseOpret('P',firstheight,poolpk))); + rawtx = FinalizeCCTx(0,cp,mtx,poolpk,txfee,MarmaraCoinbaseOpret('P',firstheight,poolpk)); if ( rawtx.size() == 0 ) errorstr = (char *)"couldnt finalize CCtx"; } else errorstr = (char *)"couldnt find any coinbases to payout"; From dda3ecd759fdae1216ad653bd1f85c25fe4f408a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 06:58:58 -1100 Subject: [PATCH 0953/3904] Connect marmara_poolpayout --- src/cc/CCMarmara.h | 2 +- src/cc/marmara.cpp | 11 +++-------- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 13 +++++++++++++ 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index b25f73f4b..4a50c2539 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -24,7 +24,7 @@ #define MARMARA_MINLOCK (1440 * 3 * 30) #define MARMARA_MAXLOCK (1440 * 24 * 30) uint64_t komodo_block_prg(uint32_t nHeight); -UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKey poolpk,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] +UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index bdd7b2be7..bce201383 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -290,16 +290,11 @@ UniValue MarmaraInfo() return(result); } -UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,CPubKey poolpk,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] +UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; - if ( pubkey2pk(Mypubkey()) != poolpk ) - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","poolpk is not your pubkey")); - return(result); - } + UniValue result(UniValue::VOBJ); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; + poolpk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 1a932382e..56b32c837 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -443,6 +443,7 @@ static const CRPCCommand vRPCCommands[] = // Marmara { "marmara", "Marmaraaddress", &marmaraaddress, true }, + { "marmara", "Marmarapoolpayout", &marmara_poolpayout, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 5bdf62799..bd00bb9d1 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -272,6 +272,7 @@ extern UniValue pricesstatus(const UniValue& params, bool fHelp); extern UniValue pricesfinish(const UniValue& params, bool fHelp); extern UniValue pegsaddress(const UniValue& params, bool fHelp); extern UniValue marmaraaddress(const UniValue& params, bool fHelp); +extern UniValue marmara_poolpayout(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 79710969a..36e23c93d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5531,6 +5531,19 @@ UniValue tokenaddress(const UniValue& params, bool fHelp) return(CCaddress(cp,(char *)"Assets",pubkey)); } +UniValue marmara_poolpayout(const UniValue& params, bool fHelp) +{ + int32_t firstheight; double perc; char *jsonstr; + if ( fHelp || params.size() != 3 ) + throw runtime_error("marmara_poolpayout perc firstheight \"[[pubkey:shares], ...]\"\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + perc = atof(params[0].get_str().c_str()) / 100.; + firstheight = atol(params[1].get_str().c_str()); + jsonstr = (char *)params[2].get_str().c_str(); + return(MarmaraPoolPayout(0,firstheight,perc,jsonstr)); // [[pk0, shares0], [pk1, shares1], ...] +} + UniValue channelslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) From 45096107db5fa0104989c9b1105e4a71ebb1e4ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:24:19 -1100 Subject: [PATCH 0954/3904] Test --- src/komodo_bitcoind.h | 3 ++- src/miner.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 00ce20853..b6173def9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1704,7 +1704,8 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) return(-1); else*/ if ( checktoshis != 0 ) { - script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; + //script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; + script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 5ea5aafe0..bdbf7a570 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -589,8 +589,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; ptr[0] = 33; for (i=0; i<33; i++) + { ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; + fprintf(stderr,"%02x",ptr[i+1]); + } ptr[34] = OP_CHECKSIG; + fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } //printf("autocreate commision vout\n"); } From bbc8c98e7180a35287bc699b6595807010dd9ac6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:26:24 -1100 Subject: [PATCH 0955/3904] Syntax --- src/komodo_bitcoind.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b6173def9..00ce20853 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1704,8 +1704,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) return(-1); else*/ if ( checktoshis != 0 ) { - //script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; - script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); + script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { From 18c82335b59c122e76e5f9f81c8208e1083d0cc6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:34:05 -1100 Subject: [PATCH 0956/3904] Test --- src/komodo_bitcoind.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 00ce20853..1b8bb85b0 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1699,13 +1699,19 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock,height); - //fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); - /*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here + if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) + { + fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); return(-1); - else*/ if ( checktoshis != 0 ) + } + else if ( checktoshis != 0 ) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); + int32_t i; + for (i=0; ivtx[0].vout[1].nValue/COIN)); if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) @@ -1721,9 +1727,6 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) matched = 25; if ( matched == 0 ) { - int32_t i; - for (i=0; ivtx[0].vout[0].scriptPubKey[0]; - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size(); + if ( scriptlen != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) return(-1); } } From 36a74b8d2787ba7ee5ab2976daa33e94c1cf0090 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:34:48 -1100 Subject: [PATCH 0957/3904] -) --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1b8bb85b0..a36e1f744 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1711,7 +1711,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) int32_t i; for (i=0; ivtx[0].vout[1].nValue/COIN)); + fprintf(stderr," vout[1] %.8f vs %.8f\n",(double)checktoshis/COIN,(double)pblock->vtx[0].vout[1].nValue/COIN); if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) From 43cbde9fe4f46baf17f6a6618c13e2f60a07cfed Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:35:50 -1100 Subject: [PATCH 0958/3904] scriptlen --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a36e1f744..341ee49e2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1745,7 +1745,7 @@ bool KOMODO_TEST_ASSETCHAIN_SKIP_POW = 0; int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { - uint256 hash; arith_uint256 bnTarget,bhash; bool fNegative,fOverflow; uint8_t *script,pubkey33[33],pubkeys[64][33]; int32_t i,possible,PoSperc,is_PoSblock=0,n,failed = 0,notaryid = -1; int64_t checktoshis,value; CBlockIndex *pprev; + uint256 hash; arith_uint256 bnTarget,bhash; bool fNegative,fOverflow; uint8_t *script,pubkey33[33],pubkeys[64][33]; int32_t i,scriptlen,possible,PoSperc,is_PoSblock=0,n,failed = 0,notaryid = -1; int64_t checktoshis,value; CBlockIndex *pprev; if ( KOMODO_TEST_ASSETCHAIN_SKIP_POW == 0 && Params().NetworkIDString() == "regtest" ) KOMODO_TEST_ASSETCHAIN_SKIP_POW = 1; if ( !CheckEquihashSolution(pblock, Params()) ) From e3110f16fb9b75524cb11688d67d6cad8068dc37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:41:26 -1100 Subject: [PATCH 0959/3904] Change priority of mining ac_variants --- src/miner.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index bdbf7a570..5bf230050 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -547,28 +547,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); } - else if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) - { - int32_t opretlen, p2shlen, scriptlen; - CScriptExt opretScript = CScriptExt(); - - txNew.vout.resize(2); - - // prepend time lock to original script unless original script is P2SH, in which case, we will leave the coins - // protected only by the time lock rather than 100% inaccessible - opretScript.AddCheckLockTimeVerify(komodo_block_unlocktime(nHeight)); - if (scriptPubKeyIn.IsPayToScriptHash() || scriptPubKeyIn.IsPayToCryptoCondition()) - { - fprintf(stderr,"CreateNewBlock: attempt to add timelock to pay2sh or pay2cc\n"); - return 0; - } - - opretScript += scriptPubKeyIn; - - txNew.vout[0].scriptPubKey = CScriptExt().PayToScriptHash(CScriptID(opretScript)); - txNew.vout[1].scriptPubKey = CScriptExt().OpReturnScript(opretScript, OPRETTYPE_TIMELOCK); - txNew.vout[1].nValue = 0; - } // timelocks and commissions are currently incompatible due to validation complexity of the combination else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; @@ -598,6 +576,28 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } //printf("autocreate commision vout\n"); } + else if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) + { + int32_t opretlen, p2shlen, scriptlen; + CScriptExt opretScript = CScriptExt(); + + txNew.vout.resize(2); + + // prepend time lock to original script unless original script is P2SH, in which case, we will leave the coins + // protected only by the time lock rather than 100% inaccessible + opretScript.AddCheckLockTimeVerify(komodo_block_unlocktime(nHeight)); + if (scriptPubKeyIn.IsPayToScriptHash() || scriptPubKeyIn.IsPayToCryptoCondition()) + { + fprintf(stderr,"CreateNewBlock: attempt to add timelock to pay2sh or pay2cc\n"); + return 0; + } + + opretScript += scriptPubKeyIn; + + txNew.vout[0].scriptPubKey = CScriptExt().PayToScriptHash(CScriptID(opretScript)); + txNew.vout[1].scriptPubKey = CScriptExt().OpReturnScript(opretScript, OPRETTYPE_TIMELOCK); + txNew.vout[1].nValue = 0; + } // timelocks and commissions are currently incompatible due to validation complexity of the combination pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; From 6f345c4ed1e0247a148df575756ec062a12ad743 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:48:13 -1100 Subject: [PATCH 0960/3904] +prints --- src/komodo_bitcoind.h | 10 +++++----- src/miner.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 341ee49e2..c647b1692 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1162,7 +1162,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; jvtx[i].vout[j].nValue; } @@ -1708,10 +1708,10 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - int32_t i; - for (i=0; ivtx[0].vout[1].nValue/COIN); + //int32_t i; + //for (i=0; ivtx[0].vout[1].nValue/COIN); if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) diff --git a/src/miner.cpp b/src/miner.cpp index 5bf230050..dc476b4c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -576,7 +576,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } //printf("autocreate commision vout\n"); } - else if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) + else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { int32_t opretlen, p2shlen, scriptlen; CScriptExt opretScript = CScriptExt(); From 8ffe7c1119f6a8b3bf3aba589be0ca5bc2280b46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:48:58 -1100 Subject: [PATCH 0961/3904] Block --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c647b1692..64faa28bc 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1162,7 +1162,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; jvtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) total += pblock->vtx[i].vout[j].nValue; } From 5ddb8a234694978fa34034a2e48e043f9c5fedf5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 07:56:04 -1100 Subject: [PATCH 0962/3904] Test --- src/komodo_bitcoind.h | 1 + src/miner.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 64faa28bc..82abfb1f2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1171,6 +1171,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } if ( commission < 10000 ) commission = 0; + fprintf(stderr,"-> %.8f\n",(double)commission/COIN); return(commission); } diff --git a/src/miner.cpp b/src/miner.cpp index dc476b4c3..71366bd12 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -554,6 +554,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = commission; if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { + fprintf(stderr,"mine to -ac_script\n"); //txNew.vout[1].scriptPubKey = CScript() << ParseHex(); int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); len >>= 1; From 36a962d0b58d95ed61acd640776149d2130e052b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:02:03 -1100 Subject: [PATCH 0963/3904] Test --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index 71366bd12..0e7c093de 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -539,6 +539,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_SYMBOL[0] == 0 && IS_KOMODO_NOTARY != 0 && My_notaryid >= 0 ) txNew.vout[0].nValue += 5000; + fprintf(stderr,"ht.%d cmp.%d\n",nHeight,nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0); // check if coinbase transactions must be time locked at current subsidy and prepend the time lock // to transaction if so, cast for GTE operator if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) From c877777d7b88874b098fcdae3a42bc884e22115f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:04:38 -1100 Subject: [PATCH 0964/3904] +print --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0e7c093de..a5712025f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -539,7 +539,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_SYMBOL[0] == 0 && IS_KOMODO_NOTARY != 0 && My_notaryid >= 0 ) txNew.vout[0].nValue += 5000; - fprintf(stderr,"ht.%d cmp.%d\n",nHeight,nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0); + fprintf(stderr,"ht.%d cmp.%d [%d %d %d %d %d]\n",nHeight,nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0,nHeight > 1,ASSETCHAINS_SYMBOL[0] != 0, (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1), ASSETCHAINS_COMMISSION != 0,(commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0); // check if coinbase transactions must be time locked at current subsidy and prepend the time lock // to transaction if so, cast for GTE operator if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) From de4aed1a620e2406b01e53116b12c9970c0c1efb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:07:56 -1100 Subject: [PATCH 0965/3904] pblock->vtx[0] = txNew; --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index a5712025f..f634be072 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -538,6 +538,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_SYMBOL[0] == 0 && IS_KOMODO_NOTARY != 0 && My_notaryid >= 0 ) txNew.vout[0].nValue += 5000; + pblock->vtx[0] = txNew; fprintf(stderr,"ht.%d cmp.%d [%d %d %d %d %d]\n",nHeight,nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0,nHeight > 1,ASSETCHAINS_SYMBOL[0] != 0, (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1), ASSETCHAINS_COMMISSION != 0,(commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0); // check if coinbase transactions must be time locked at current subsidy and prepend the time lock From 34a26023f206dbbad74abe4cacfa469af4cd6c2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:09:54 -1100 Subject: [PATCH 0966/3904] Test --- src/komodo_bitcoind.h | 6 +++--- src/miner.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 82abfb1f2..6e6dc7b35 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1162,7 +1162,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; jvtx[i].vout[j].nValue),j); + //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) total += pblock->vtx[i].vout[j].nValue; } @@ -1171,7 +1171,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } if ( commission < 10000 ) commission = 0; - fprintf(stderr,"-> %.8f\n",(double)commission/COIN); + //fprintf(stderr,"-> %.8f\n",(double)commission/COIN); return(commission); } @@ -1702,7 +1702,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) { - fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); + //fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); return(-1); } else if ( checktoshis != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index f634be072..128a94e3a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -540,7 +540,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[0].nValue += 5000; pblock->vtx[0] = txNew; - fprintf(stderr,"ht.%d cmp.%d [%d %d %d %d %d]\n",nHeight,nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0,nHeight > 1,ASSETCHAINS_SYMBOL[0] != 0, (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1), ASSETCHAINS_COMMISSION != 0,(commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0); + //fprintf(stderr,"ht.%d cmp.%d [%d %d %d %d %d]\n",nHeight,nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0,nHeight > 1,ASSETCHAINS_SYMBOL[0] != 0, (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1), ASSETCHAINS_COMMISSION != 0,(commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0); // check if coinbase transactions must be time locked at current subsidy and prepend the time lock // to transaction if so, cast for GTE operator if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) @@ -572,10 +572,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 for (i=0; i<33; i++) { ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; - fprintf(stderr,"%02x",ptr[i+1]); + //fprintf(stderr,"%02x",ptr[i+1]); } ptr[34] = OP_CHECKSIG; - fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); + //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } //printf("autocreate commision vout\n"); } From 4c900a4708e44e4cc68a689ccc9f503a78f6dc11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:21:57 -1100 Subject: [PATCH 0967/3904] Son --- src/rpc/server.cpp | 4 ++-- src/wallet/rpcwallet.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 56b32c837..d6b801dd5 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -442,8 +442,8 @@ static const CRPCCommand vRPCCommands[] = { "pegs", "pegsaddress", &pegsaddress, true }, // Marmara - { "marmara", "Marmaraaddress", &marmaraaddress, true }, - { "marmara", "Marmarapoolpayout", &marmara_poolpayout, true }, + { "marmara", "marmaraaddress", &marmaraaddress, true }, + { "marmara", "marmarapoolpayout", &marmara_poolpayout, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 36e23c93d..a4b30e383 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5535,7 +5535,10 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) { int32_t firstheight; double perc; char *jsonstr; if ( fHelp || params.size() != 3 ) - throw runtime_error("marmara_poolpayout perc firstheight \"[[pubkey:shares], ...]\"\n"); + { + fprintf(stderr,"params.size %d\n",(int32_t)params.size()); + throw runtime_error("marmara_poolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); + } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); perc = atof(params[0].get_str().c_str()) / 100.; From 3fb0d3a82adaf30138f5d98a4575cc17d6312d67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:24:41 -1100 Subject: [PATCH 0968/3904] Test --- src/cc/marmara.cpp | 2 +- src/wallet/rpcwallet.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index bce201383..bb06b3e39 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -178,7 +178,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { if ( ht == height && MarmaraUnlockht(height) == unlockht ) { - fprintf(stderr,"ht.%d -> unlock.%d\n",ht,unlockht); + //fprintf(stderr,"ht.%d -> unlock.%d\n",ht,unlockht); ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); if ( ccvout.scriptPubKey == tx.vout[0].scriptPubKey ) return(0); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a4b30e383..4a7024eb4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5534,7 +5534,7 @@ UniValue tokenaddress(const UniValue& params, bool fHelp) UniValue marmara_poolpayout(const UniValue& params, bool fHelp) { int32_t firstheight; double perc; char *jsonstr; - if ( fHelp || params.size() != 3 ) + if ( fHelp || params.size() < 3 ) { fprintf(stderr,"params.size %d\n",(int32_t)params.size()); throw runtime_error("marmara_poolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); @@ -5544,6 +5544,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) perc = atof(params[0].get_str().c_str()) / 100.; firstheight = atol(params[1].get_str().c_str()); jsonstr = (char *)params[2].get_str().c_str(); + fprintf(stderr,"perc %.2f ht.%d (%s)\n",perc,firstheight,jsonstr); return(MarmaraPoolPayout(0,firstheight,perc,jsonstr)); // [[pk0, shares0], [pk1, shares1], ...] } From 1e17cbc61790d8c0c0bd8ee4df21b05aff73908c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:26:54 -1100 Subject: [PATCH 0969/3904] -print --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cd3c0d35f..44dab5ed1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3462,7 +3462,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if ( block.vtx[0].vout.size() >= 2 && block.vtx[0].vout[1].nValue == checktoshis ) blockReward += checktoshis; - else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size()); + else if ( pindex->nHeight > 1 ) + fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) From 7ebf1d817686b6dfe32465235b5ba3739bd250a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:41:23 -1100 Subject: [PATCH 0970/3904] +print --- src/cc/marmara.cpp | 31 ++++++++++++++++++------------- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index bb06b3e39..353f3edba 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -237,26 +237,31 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, GetCCaddress(cp,coinaddr,poolpk); SetCCunspents(unspentOutputs,coinaddr); unlocks = MarmaraUnlockht(firstheight); + fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; vout = (int32_t)it->first.index; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && vintx.IsCoinBase() != 0 ) + fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk ) + if ( vintx.IsCoinBase() != 0 ) { - if ( (nValue= IsMarmaravout(cp,vintx,vout)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk ) { - if ( maxinputs != 0 ) - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - nValue = it->second.satoshis; - totalinputs += nValue; - n++; - if ( maxinputs > 0 && n >= maxinputs ) - break; - } - } - } + if ( (nValue= IsMarmaravout(cp,vintx,vout)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + if ( maxinputs != 0 ) + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + nValue = it->second.satoshis; + totalinputs += nValue; + n++; + if ( maxinputs > 0 && n >= maxinputs ) + break; + } else fprintf(stderr,"nValue.%8f\n",(double)nValue/COIN); + } else fprintf(stderr,"decode error\n"); + } else fprintf(stderr,"not coinbase\n"); + } else fprintf(stderr,"error getting tx\n"); } return(totalinputs); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4a7024eb4..6a2a351dc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5544,7 +5544,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) perc = atof(params[0].get_str().c_str()) / 100.; firstheight = atol(params[1].get_str().c_str()); jsonstr = (char *)params[2].get_str().c_str(); - fprintf(stderr,"perc %.2f ht.%d (%s)\n",perc,firstheight,jsonstr); + fprintf(stderr,"perc %.8f ht.%d (%s)\n",perc,firstheight,jsonstr); return(MarmaraPoolPayout(0,firstheight,perc,jsonstr)); // [[pk0, shares0], [pk1, shares1], ...] } From 80c61ba5053b5ba20898e6134aa29217b3634b3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:44:14 -1100 Subject: [PATCH 0971/3904] ->GetHeight() --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 44dab5ed1..929ec9d5e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3462,7 +3462,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if ( block.vtx[0].vout.size() >= 2 && block.vtx[0].vout[1].nValue == checktoshis ) blockReward += checktoshis; - else if ( pindex->nHeight > 1 ) + else if ( pindex->GetHeight() > 1 ) fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } From c31f8ea3d57d400bd4d51967196efd345a4399ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:52:30 -1100 Subject: [PATCH 0972/3904] Test --- src/cc/marmara.cpp | 5 +++-- src/wallet/rpcwallet.cpp | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 353f3edba..66d082cb9 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -124,6 +124,7 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32 { if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> height; ss >> unlockht) != 0 ) { + fprintf(stderr,"return %c\n",script[1]); return(script[1]); } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for %c\n",script[1]); } else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d\n",script[1],'C','P'); @@ -245,7 +246,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( vintx.IsCoinBase() != 0 ) + if ( vintx.IsCoinBase() != 0 && vintx.vout.size() == 2 && vintx.vout[1].nValue == 0 ) { if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk ) { @@ -259,7 +260,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, if ( maxinputs > 0 && n >= maxinputs ) break; } else fprintf(stderr,"nValue.%8f\n",(double)nValue/COIN); - } else fprintf(stderr,"decode error\n"); + } else fprintf(stderr,"decode error unlockht.%d vs %d pk.%d\n",unlockht,unlocks,pk == poolpk); } else fprintf(stderr,"not coinbase\n"); } else fprintf(stderr,"error getting tx\n"); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6a2a351dc..fc9655ec1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5536,7 +5536,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) int32_t firstheight; double perc; char *jsonstr; if ( fHelp || params.size() < 3 ) { - fprintf(stderr,"params.size %d\n",(int32_t)params.size()); + // marmarapoolpayout "0.5" 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000],["02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",100]]'; throw runtime_error("marmara_poolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5544,7 +5544,6 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) perc = atof(params[0].get_str().c_str()) / 100.; firstheight = atol(params[1].get_str().c_str()); jsonstr = (char *)params[2].get_str().c_str(); - fprintf(stderr,"perc %.8f ht.%d (%s)\n",perc,firstheight,jsonstr); return(MarmaraPoolPayout(0,firstheight,perc,jsonstr)); // [[pk0, shares0], [pk1, shares1], ...] } From f6af25e545ee3ff9e9da583c8039d4c88bd8b7f1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:56:00 -1100 Subject: [PATCH 0973/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 66d082cb9..304d97f74 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -250,7 +250,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, { if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk ) { - if ( (nValue= IsMarmaravout(cp,vintx,vout)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From fefe5dbd246bfc1139d0556ffed441d45bf3265b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 08:59:23 -1100 Subject: [PATCH 0974/3904] Args 3 --- src/cc/marmara.cpp | 1 - src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 304d97f74..b3be7cb32 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -124,7 +124,6 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32 { if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> height; ss >> unlockht) != 0 ) { - fprintf(stderr,"return %c\n",script[1]); return(script[1]); } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for %c\n",script[1]); } else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d\n",script[1],'C','P'); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fc9655ec1..2bc4aeeba 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5534,7 +5534,7 @@ UniValue tokenaddress(const UniValue& params, bool fHelp) UniValue marmara_poolpayout(const UniValue& params, bool fHelp) { int32_t firstheight; double perc; char *jsonstr; - if ( fHelp || params.size() < 3 ) + if ( fHelp || params.size() != 3 ) { // marmarapoolpayout "0.5" 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000],["02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",100]]'; throw runtime_error("marmara_poolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); From 028725471c7a176605512ec4e3d5e7c9185f8b2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:17:22 -1100 Subject: [PATCH 0975/3904] Total field --- src/cc/marmara.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index b3be7cb32..103e8d51a 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -364,6 +364,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * result.push_back(Pair("rawtx",rawtx)); if ( totalpayout > 0 && total > totalpayout-txfee ) { + result.push_back(Pair("total",(double)total/COIN)); result.push_back(Pair("totalpayout",(double)totalpayout/COIN)); result.push_back(Pair("totalshares",shares)); result.push_back(Pair("poolfee",(double)(total - totalpayout)/COIN)); From 1b46c66023b207223070d06740516e1e8082987c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:21:54 -1100 Subject: [PATCH 0976/3904] Payouts --- src/cc/marmara.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 103e8d51a..852ac8469 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -237,12 +237,12 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, GetCCaddress(cp,coinaddr,poolpk); SetCCunspents(unspentOutputs,coinaddr); unlocks = MarmaraUnlockht(firstheight); - fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); + //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; vout = (int32_t)it->first.index; - fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); + //fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { if ( vintx.IsCoinBase() != 0 && vintx.vout.size() == 2 && vintx.vout[1].nValue == 0 ) @@ -259,7 +259,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, if ( maxinputs > 0 && n >= maxinputs ) break; } else fprintf(stderr,"nValue.%8f\n",(double)nValue/COIN); - } else fprintf(stderr,"decode error unlockht.%d vs %d pk.%d\n",unlockht,unlocks,pk == poolpk); + } //else fprintf(stderr,"decode error unlockht.%d vs %d pk.%d\n",unlockht,unlocks,pk == poolpk); } else fprintf(stderr,"not coinbase\n"); } else fprintf(stderr,"error getting tx\n"); } @@ -298,7 +298,7 @@ UniValue MarmaraInfo() UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; poolpk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; @@ -335,6 +335,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * totalpayout += payout; decode_hex(buf,33,pkstr); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,payout,Marmarapk,buf2pk(buf))); + a.push_back(Pair(pkstr,(double)payout/COIN)); } } } @@ -369,6 +370,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * result.push_back(Pair("totalshares",shares)); result.push_back(Pair("poolfee",(double)(total - totalpayout)/COIN)); result.push_back(Pair("perc",100. * (double)(total - totalpayout)/totalpayout)); + result.push_back(Pair("payouts",a); } } return(result); From cdbdf8662b712b643266f44a736f56c1b81967d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:23:02 -1100 Subject: [PATCH 0977/3904] +) --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 852ac8469..82d0a9995 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -370,7 +370,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * result.push_back(Pair("totalshares",shares)); result.push_back(Pair("poolfee",(double)(total - totalpayout)/COIN)); result.push_back(Pair("perc",100. * (double)(total - totalpayout)/totalpayout)); - result.push_back(Pair("payouts",a); + result.push_back(Pair("payouts",a)); } } return(result); From 9e94b62aa3f83d9a422d5c9a7332df6aea9a8455 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:25:30 -1100 Subject: [PATCH 0978/3904] Payout --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 82d0a9995..b1603cfbc 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -335,7 +335,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * totalpayout += payout; decode_hex(buf,33,pkstr); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,payout,Marmarapk,buf2pk(buf))); - a.push_back(Pair(pkstr,(double)payout/COIN)); + a.push_back((double)payout/COIN); } } } From 70de1f76bd446c74e9a11752a2228e1882af805f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:28:12 -1100 Subject: [PATCH 0979/3904] x(UniValue::VOBJ), --- src/cc/marmara.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index b1603cfbc..f993d5555 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -332,10 +332,12 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * { if ( (pkstr= jstr(jitem(item,0),0)) != 0 && strlen(pkstr) == 66 ) { + UniValue x(UniValue::VOBJ); totalpayout += payout; decode_hex(buf,33,pkstr); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,payout,Marmarapk,buf2pk(buf))); - a.push_back((double)payout/COIN); + x.push_back(Pair(pkstr, (double)payout/COIN)); + a.push_back(item); } } } From 78b7341aa5aa03248bd3ba74fd1f3cec2e3b555e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:29:45 -1100 Subject: [PATCH 0980/3904] x --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f993d5555..4a32639af 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -337,7 +337,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * decode_hex(buf,33,pkstr); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,payout,Marmarapk,buf2pk(buf))); x.push_back(Pair(pkstr, (double)payout/COIN)); - a.push_back(item); + a.push_back(x); } } } From 513c19d096298af8ee832cab2b3471642056ce36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:38:33 -1100 Subject: [PATCH 0981/3904] Split commission calc into 2 divs --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6e6dc7b35..079e58fc5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1167,7 +1167,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) total += pblock->vtx[i].vout[j].nValue; } } - commission = ((total * ASSETCHAINS_COMMISSION) / COIN); + commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000); + //commission = ((total * ASSETCHAINS_COMMISSION) / COIN); } if ( commission < 10000 ) commission = 0; From 59bb5fd47030ff9d5221edf19108d879e45ca960 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:46:58 -1100 Subject: [PATCH 0982/3904] -) --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 079e58fc5..841396a00 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1167,7 +1167,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) total += pblock->vtx[i].vout[j].nValue; } } - commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000); + commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000; //commission = ((total * ASSETCHAINS_COMMISSION) / COIN); } if ( commission < 10000 ) From f105e133b972f9fdae7ce56eebd304ea0ae85911 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:54:12 -1100 Subject: [PATCH 0983/3904] First/last heights --- src/cc/marmara.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 4a32639af..763c19ebe 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -367,6 +367,8 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * result.push_back(Pair("rawtx",rawtx)); if ( totalpayout > 0 && total > totalpayout-txfee ) { + result.push_back(Pair("firstheight",firstheight)); + result.push_back(Pair("lastheight",((firstheight / MARMARA_GROUPSIZE)+1) * MARMARA_GROUPSIZE - 1)); result.push_back(Pair("total",(double)total/COIN)); result.push_back(Pair("totalpayout",(double)totalpayout/COIN)); result.push_back(Pair("totalshares",shares)); From cae219a0c8970d80efb52d8cdf810d1fb67d24fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 09:56:52 -1100 Subject: [PATCH 0984/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 763c19ebe..4b154cc8c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -247,7 +247,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, { if ( vintx.IsCoinBase() != 0 && vintx.vout.size() == 2 && vintx.vout[1].nValue == 0 ) { - if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk ) + if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk && ht >= firstheight ) { if ( (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { From 7949fcb64857a72118307ae7818575ab4689fe92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 15:51:07 -1100 Subject: [PATCH 0985/3904] Tweak perc calc --- src/cc/marmara.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 4b154cc8c..ccce9083f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -319,7 +319,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * } if ( errorstr == 0 && shares > SMALLVAL ) { - shares += shares * perc; + shares += (shares / (1. - perc)); if ( (total= AddMarmaraCoinbases(cp,mtx,firstheight,poolpk,60)) > 0 ) { for (i=0; i Date: Sat, 12 Jan 2019 15:55:31 -1100 Subject: [PATCH 0986/3904] Fix perc math --- src/cc/marmara.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ccce9083f..639a69567 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -319,7 +319,9 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * } if ( errorstr == 0 && shares > SMALLVAL ) { - shares += (shares / (1. - perc)); + //shares += shares * perc; + shares /= (1. - perc); + if ( (total= AddMarmaraCoinbases(cp,mtx,firstheight,poolpk,60)) > 0 ) { for (i=0; i Date: Sat, 12 Jan 2019 16:00:11 -1100 Subject: [PATCH 0987/3904] Revert --- src/cc/marmara.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 639a69567..4b154cc8c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -319,9 +319,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * } if ( errorstr == 0 && shares > SMALLVAL ) { - //shares += shares * perc; - shares /= (1. - perc); - + shares += shares * perc; if ( (total= AddMarmaraCoinbases(cp,mtx,firstheight,poolpk,60)) > 0 ) { for (i=0; i Date: Sat, 12 Jan 2019 16:04:43 -1100 Subject: [PATCH 0988/3904] Adjust pool fee disp by three --- src/cc/marmara.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 4b154cc8c..751eb569b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -298,7 +298,7 @@ UniValue MarmaraInfo() UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,poolfee=0,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; poolpk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; @@ -344,7 +344,8 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * } if ( totalpayout > 0 && total > totalpayout-txfee ) { - mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,total - totalpayout - txfee,Marmarapk,poolpk)); + poolfee = (total - totalpayout - txfee); + mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,poolfee,Marmarapk,poolpk)); } rawtx = FinalizeCCTx(0,cp,mtx,poolpk,txfee,MarmaraCoinbaseOpret('P',firstheight,poolpk)); if ( rawtx.size() == 0 ) @@ -372,8 +373,8 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * result.push_back(Pair("total",(double)total/COIN)); result.push_back(Pair("totalpayout",(double)totalpayout/COIN)); result.push_back(Pair("totalshares",shares)); - result.push_back(Pair("poolfee",(double)(total - totalpayout)/COIN)); - result.push_back(Pair("perc",100. * (double)(total - totalpayout)/totalpayout)); + result.push_back(Pair("poolfee",(double)poolfee/COIN)); + result.push_back(Pair("perc",100. * (double)poolfee/totalpayout)); result.push_back(Pair("payouts",a)); } } From 5ee45ecb45990a3f3d51480d9f08e5a7d070a2c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 16:12:24 -1100 Subject: [PATCH 0989/3904] ValueFromAmount( --- src/cc/marmara.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 751eb569b..ef2f62b40 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -370,10 +370,10 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * { result.push_back(Pair("firstheight",firstheight)); result.push_back(Pair("lastheight",((firstheight / MARMARA_GROUPSIZE)+1) * MARMARA_GROUPSIZE - 1)); - result.push_back(Pair("total",(double)total/COIN)); - result.push_back(Pair("totalpayout",(double)totalpayout/COIN)); + result.push_back(Pair("total",ValueFromAmount(total)); + result.push_back(Pair("totalpayout",ValueFromAmount(totalpayout)); result.push_back(Pair("totalshares",shares)); - result.push_back(Pair("poolfee",(double)poolfee/COIN)); + result.push_back(Pair("poolfee",ValueFromAmount(poolfee)); result.push_back(Pair("perc",100. * (double)poolfee/totalpayout)); result.push_back(Pair("payouts",a)); } From 857bf5f4e6ea57df49c2e1debff69421e7428a39 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 16:13:54 -1100 Subject: [PATCH 0990/3904] UniValue ValueFromAmount(const CAmount& amount) --- src/cc/CCinclude.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 0906a57c6..aaeadcc61 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -187,5 +187,6 @@ bits256 curve25519_basepoint9(); bits256 curve25519(bits256 mysecret,bits256 basepoint); void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); bits256 bits256_doublesha256(char *deprecated,uint8_t *data,int32_t datalen); +UniValue ValueFromAmount(const CAmount& amount); #endif From ba5462eec9a2172a9c60344ee0cb646cdc013807 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 16:16:21 -1100 Subject: [PATCH 0991/3904] +))) --- src/cc/marmara.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ef2f62b40..593ee48f7 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -370,10 +370,10 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * { result.push_back(Pair("firstheight",firstheight)); result.push_back(Pair("lastheight",((firstheight / MARMARA_GROUPSIZE)+1) * MARMARA_GROUPSIZE - 1)); - result.push_back(Pair("total",ValueFromAmount(total)); - result.push_back(Pair("totalpayout",ValueFromAmount(totalpayout)); + result.push_back(Pair("total",ValueFromAmount(total))); + result.push_back(Pair("totalpayout",ValueFromAmount(totalpayout))); result.push_back(Pair("totalshares",shares)); - result.push_back(Pair("poolfee",ValueFromAmount(poolfee)); + result.push_back(Pair("poolfee",ValueFromAmount(poolfee))); result.push_back(Pair("perc",100. * (double)poolfee/totalpayout)); result.push_back(Pair("payouts",a)); } From 24cd52e8956201c8a8b01d91f686dda6f8486259 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 16:20:09 -1100 Subject: [PATCH 0992/3904] return eval->Invalid("no validation yet"); --- src/cc/auction.cpp | 2 +- src/cc/fsm.cpp | 2 +- src/cc/heir.cpp | 2 +- src/cc/lotto.cpp | 2 +- src/cc/marmara.cpp | 2 +- src/cc/payments.cpp | 2 +- src/cc/pegs.cpp | 2 +- src/cc/prices.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/auction.cpp b/src/cc/auction.cpp index 70bc64379..0858facfa 100644 --- a/src/cc/auction.cpp +++ b/src/cc/auction.cpp @@ -73,7 +73,7 @@ bool AuctionExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransactio bool AuctionValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; - return(false); // reject any auction CC for now + return eval->Invalid("no validation yet"); numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index 04ca1d5a0..0bcc61a1b 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -75,7 +75,7 @@ bool FSMExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &t bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; - return(false); // reject any FSM CC for now + return eval->Invalid("no validation yet"); numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 5caa6594a..44f01a8a4 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -74,7 +74,7 @@ bool HeirExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction & bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return(false); + return eval->Invalid("no validation yet"); std::vector > txids; numvins = tx.vin.size(); numvouts = tx.vout.size(); diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index 7b44a99b7..e9c263ff1 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -115,7 +115,7 @@ bool LottoExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; - return(false); // reject any lotto CC for now + return eval->Invalid("no validation yet"); numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 593ee48f7..a4d548176 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -192,7 +192,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return(false); + return eval->Invalid("no validation yet"); std::vector > txids; numvins = tx.vin.size(); numvouts = tx.vout.size(); diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 1b6d88214..859a5ba3f 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -75,7 +75,7 @@ bool PaymentsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return(false); + return eval->Invalid("no validation yet"); std::vector > txids; numvins = tx.vin.size(); numvouts = tx.vout.size(); diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 4e414d695..e2893bec8 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -82,7 +82,7 @@ bool PegsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction & bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return(false); + return eval->Invalid("no validation yet"); std::vector > txids; numvins = tx.vin.size(); numvouts = tx.vout.size(); diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 8c2ecc021..5d919d6e8 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -89,7 +89,7 @@ uint8_t DecodePricesFundingOpRet(CScript scriptPubKey,CPubKey &planpk,uint256 &o bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return(false); + return eval->Invalid("no validation yet"); std::vector > txids; numvins = tx.vin.size(); numvouts = tx.vout.size(); From b6eed136785c5662cc18d83d231c588943d32392 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 16:22:59 -1100 Subject: [PATCH 0993/3904] Truncate perc print --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index a4d548176..171ef713d 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -374,7 +374,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * result.push_back(Pair("totalpayout",ValueFromAmount(totalpayout))); result.push_back(Pair("totalshares",shares)); result.push_back(Pair("poolfee",ValueFromAmount(poolfee))); - result.push_back(Pair("perc",100. * (double)poolfee/totalpayout)); + result.push_back(Pair("perc",ValueFromAmount((int64_t)(100. * (double)poolfee/totalpayout)))); result.push_back(Pair("payouts",a)); } } From c38e4a0521534e81e81a25f95c9f33afd52730c5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 16:24:23 -1100 Subject: [PATCH 0994/3904] * COIN --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 171ef713d..2e56c21b2 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -374,7 +374,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * result.push_back(Pair("totalpayout",ValueFromAmount(totalpayout))); result.push_back(Pair("totalshares",shares)); result.push_back(Pair("poolfee",ValueFromAmount(poolfee))); - result.push_back(Pair("perc",ValueFromAmount((int64_t)(100. * (double)poolfee/totalpayout)))); + result.push_back(Pair("perc",ValueFromAmount((int64_t)(100. * (double)poolfee/totalpayout * COIN)))); result.push_back(Pair("payouts",a)); } } From 0b58392fff0671169aa06f16c8cab9bb2869daac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 17:29:18 -1100 Subject: [PATCH 0995/3904] Validation for marmara 'P' --- src/cc/eval.cpp | 5 +++-- src/cc/marmara.cpp | 45 ++++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index d50bc8a0d..9161f2007 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -38,8 +38,9 @@ bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn) pthread_mutex_lock(&KOMODO_CC_mutex); bool out = eval->Dispatch(cond, tx, nIn); pthread_mutex_unlock(&KOMODO_CC_mutex); - //fprintf(stderr,"out %d vs %d isValid\n",(int32_t)out,(int32_t)eval->state.IsValid()); - assert(eval->state.IsValid() == out); + if ( eval->state.IsValid() != out) + fprintf(stderr,"out %d vs %d isValid\n",(int32_t)out,(int32_t)eval->state.IsValid()); + //assert(eval->state.IsValid() == out); if (eval->state.IsValid()) return true; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 2e56c21b2..d12959d2a 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -191,40 +191,39 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { - int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return eval->Invalid("no validation yet"); - std::vector > txids; + CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid; CPubKey pk,vpk; numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; if ( numvouts < 1 ) return eval->Invalid("no vouts"); - else + else if ( tx.vout.size() >= 2 ) { - for (i=0; iInvalid("illegal normal vini"); + if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 ) + { + if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) + return eval->Invalid("cant find vinTx"); + else + { + if ( vinTx.IsCoinbase() == 0 ) + return eval->Invalid("noncoinbase input"); + else if ( vinTx.size() != 2 ) + return eval->Invalid("coinbase doesnt have 2 vouts"); + vfuncid = DecodeMaramaraCoinbaseOpRet(vinTx.vout[1].scriptPubKey,vpk,vht,vunlockht); + if ( vfuncid != 'C' || vpk != pk || vunlockht != unlockht ) + return eval->Invalid("mismatched opreturn"); + } + } } - } - //fprintf(stderr,"check amounts\n"); - if ( MarmaraExactAmounts(cp,eval,tx,1,10000) == false ) - { - fprintf(stderr,"Marmaraget invalid amount\n"); - return false; - } - else - { - txid = tx.GetHash(); - memcpy(hash,&txid,sizeof(hash)); - retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); - if ( retval != 0 ) - fprintf(stderr,"Marmaraget validated\n"); - else fprintf(stderr,"Marmaraget invalid\n"); - return(retval); + return(true); } } + return eval->Invalid("fall through error"); } // end of consensus code From 7c0fb95d183384df38838e634e7555f19bba8a0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 17:29:47 -1100 Subject: [PATCH 0996/3904] Syntax --- src/cc/marmara.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d12959d2a..f272ecf8d 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -194,7 +194,6 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid; CPubKey pk,vpk; numvins = tx.vin.size(); numvouts = tx.vout.size(); - preventCCvins = preventCCvouts = -1; if ( numvouts < 1 ) return eval->Invalid("no vouts"); else if ( tx.vout.size() >= 2 ) From ba281dae9f79fd287151c09211552a01a2736031 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 17:32:15 -1100 Subject: [PATCH 0997/3904] syntax --- src/cc/marmara.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f272ecf8d..dd8e304cf 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -191,7 +191,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { - CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid; CPubKey pk,vpk; + CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid; CPubKey pk,vpk; numvins = tx.vin.size(); numvouts = tx.vout.size(); if ( numvouts < 1 ) @@ -209,9 +209,9 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t return eval->Invalid("cant find vinTx"); else { - if ( vinTx.IsCoinbase() == 0 ) + if ( vinTx.IsCoinBase() == 0 ) return eval->Invalid("noncoinbase input"); - else if ( vinTx.size() != 2 ) + else if ( vinTx.vout.size() != 2 ) return eval->Invalid("coinbase doesnt have 2 vouts"); vfuncid = DecodeMaramaraCoinbaseOpRet(vinTx.vout[1].scriptPubKey,vpk,vht,vunlockht); if ( vfuncid != 'C' || vpk != pk || vunlockht != unlockht ) From fe9d96b291bc4bdfdcf164b11765e4d02fb75cf2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Jan 2019 17:35:48 -1100 Subject: [PATCH 0998/3904] Last vout is I-return --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index dd8e304cf..5c36eb563 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -198,7 +198,7 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t return eval->Invalid("no vouts"); else if ( tx.vout.size() >= 2 ) { - funcid = DecodeMaramaraCoinbaseOpRet(tx.vout[1].scriptPubKey,pk,ht,unlockht); + funcid = DecodeMaramaraCoinbaseOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,pk,ht,unlockht); if ( funcid == 'P' ) { for (i=0; i Date: Sat, 12 Jan 2019 17:38:17 -1100 Subject: [PATCH 0999/3904] -print --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5c36eb563..6415671f8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -256,7 +256,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, n++; if ( maxinputs > 0 && n >= maxinputs ) break; - } else fprintf(stderr,"nValue.%8f\n",(double)nValue/COIN); + } //else fprintf(stderr,"nValue.%8f\n",(double)nValue/COIN); } //else fprintf(stderr,"decode error unlockht.%d vs %d pk.%d\n",unlockht,unlocks,pk == poolpk); } else fprintf(stderr,"not coinbase\n"); } else fprintf(stderr,"error getting tx\n"); From e149a4e4d798b31c6cdc69ba16b5bdcd6ab19530 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 02:34:07 -1100 Subject: [PATCH 1000/3904] Initial MarmaraReceive --- src/cc/marmara.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 6415671f8..ba4e4b005 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -33,7 +33,7 @@ int64_t IsMarmaravout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -bool MarmaraExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +/*bool MarmaraExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -69,7 +69,7 @@ bool MarmaraExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransactio return eval->Invalid("mismatched inputs != outputs + txfee"); } else return(true); -} +}*/ int32_t MarmaraRandomize(uint32_t ind) { @@ -191,16 +191,21 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { - CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid; CPubKey pk,vpk; + std::vector vopret; CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid,*script; CPubKey pk,vpk; numvins = tx.vin.size(); numvouts = tx.vout.size(); if ( numvouts < 1 ) return eval->Invalid("no vouts"); else if ( tx.vout.size() >= 2 ) { - funcid = DecodeMaramaraCoinbaseOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,pk,ht,unlockht); + GetOpReturnData(tx.vout[tx.vout.size()-1].scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() < 2 || script[0] != EVAL_MARMARA ) + return eval->Invalid("no opreturn"); + funcid = script[1]; if ( funcid == 'P' ) { + funcid = DecodeMaramaraCoinbaseOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,pk,ht,unlockht); for (i=0; iismyvin)(tx.vin[i].scriptSig) != 0 ) @@ -221,6 +226,38 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t } return(true); } + else if ( funcid == 'L' ) // lock -> lock funds with a unlockht + { + return(true); + } + else if ( funcid == 'R' ) // receive -> agree to receive 'I' from pk, amount, currency, dueht + { + return(true); + } + else if ( funcid == 'I' ) // issue -> issue currency to pk with due date height + { + return(true); + } + else if ( funcid == 'T' ) // transfer -> given 'R' transfer 'I' or 'T' to the pk of 'R' + { + return(true); + } + else if ( funcid == 'S' ) // collect -> automatically spend issuers locked funds, given 'I' + { + return(true); + } + else if ( funcid == 'A' ) // agree -> agree that 'I' is unable to be redeemed, remainder + { + return(true); + } + else if ( funcid == 'D' ) // dispute -> given 'I' submit for manual arbitration + { + return(true); + } + else if ( funcid == 'F' ) // foreclose -> given 'A' collect as much of remainder from credit loop + { + return(true); + } } return eval->Invalid("fall through error"); } @@ -264,6 +301,34 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, return(totalinputs); } +UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 issuetxid) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; + cp = CCinit(&C,EVAL_MARMARA); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + errorstr = (char *)"couldnt finalize CCtx"; + if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) + { + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(senderpk)) << OP_CHECKSIG)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraOpret('R',issuetxid,senderpk,amount,matures,currency)); + } else errorstr = "dont have enough normal inputs for 2*txfee"; + if ( rawtx.size() == 0 || errorstr != 0 ) + { + result.push_back(Pair("result","error")); + if ( errorstr != 0 ) + result.push_back(Pair("error",errorstr)); + } + else + { + result.push_back(Pair("result",(char *)"success")); + result.push_back(Pair("rawtx",rawtx)); + } + return(result); +} + std::string MarmaraFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); From b7341671fa97623020bf8e4781549761775f05cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 02:45:51 -1100 Subject: [PATCH 1001/3904] CC baton for credit loop --- src/cc/marmara.cpp | 73 +++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ba4e4b005..75f9e0ee4 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -87,25 +87,6 @@ int32_t MarmaraUnlockht(int32_t height) return(height + MarmaraRandomize(ind)); } -CScript EncodeMarmaraCoinbaseOpRet(uint8_t funcid,CPubKey pk,int32_t ht) -{ - CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_MARMARA; - unlockht = MarmaraUnlockht(ht); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk << ht << unlockht); - if ( 0 ) - { - std::vector vopret; uint8_t *script,i; - GetOpReturnData(opret,vopret); - script = (uint8_t *)vopret.data(); - { - for (i=0; i vopret; uint8_t *script,e,f,funcid; @@ -131,6 +112,32 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32 return(0); } +CScript EncodeMarmaraCoinbaseOpRet(uint8_t funcid,CPubKey pk,int32_t ht) +{ + CScript opret; int32_t unlockht; uint8_t evalcode = EVAL_MARMARA; + unlockht = MarmaraUnlockht(ht); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk << ht << unlockht); + if ( 0 ) + { + std::vector vopret; uint8_t *script,i; + GetOpReturnData(opret,vopret); + script = (uint8_t *)vopret.data(); + { + for (i=0; i 0 ) + if ( currency != "MARMARA" ) + errorstr = "for now, only MARMARA loops are supported"; + else if ( amount < txfee ) + errorstr = "amount must be for more than txfee"; + else if ( matures <= chainActive.LastTip->GetHeight() ) + errorstr = "it must mature in the future"; + if ( errorstr == 0 ) { - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(senderpk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraOpret('R',issuetxid,senderpk,amount,matures,currency)); - } else errorstr = "dont have enough normal inputs for 2*txfee"; + if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) + { + errorstr = (char *)"couldnt finalize CCtx"; + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,senderpk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('R',createtxid,senderpk,amount,matures,currency)); + } else errorstr = (char *)"dont have enough normal inputs for 2*txfee"; + } if ( rawtx.size() == 0 || errorstr != 0 ) { result.push_back(Pair("result","error")); @@ -325,6 +341,11 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri { result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("createtxid",createtxid)); + result.push_back(Pair("senderpk",senderpk)); + result.push_back(Pair("amount",ValueFromAmount(amount))); + result.push_back(Pair("matures",matures)); + result.push_back(Pair("currency",currency)); } return(result); } From cd4b54dfeae90ccfadb39435f99b2eda88bbbb89 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 02:47:18 -1100 Subject: [PATCH 1002/3904] Strings --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 75f9e0ee4..5db0c07c3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -341,8 +341,8 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri { result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); - result.push_back(Pair("createtxid",createtxid)); - result.push_back(Pair("senderpk",senderpk)); + result.push_back(Pair("createtxid",createtxid.GetHex())); + result.push_back(Pair("senderpk",HexStr(senderpk))); result.push_back(Pair("amount",ValueFromAmount(amount))); result.push_back(Pair("matures",matures)); result.push_back(Pair("currency",currency)); From 85271fb3a507ae79e8325b2450c2ed48881ce1b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 02:48:20 -1100 Subject: [PATCH 1003/3904] Test --- src/cc/marmara.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5db0c07c3..a50059305 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -317,11 +317,11 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri txfee = 10000; mypk = pubkey2pk(Mypubkey()); if ( currency != "MARMARA" ) - errorstr = "for now, only MARMARA loops are supported"; + errorstr = (char *)"for now, only MARMARA loops are supported"; else if ( amount < txfee ) - errorstr = "amount must be for more than txfee"; - else if ( matures <= chainActive.LastTip->GetHeight() ) - errorstr = "it must mature in the future"; + errorstr = (char *)"amount must be for more than txfee"; + else if ( matures <= chainActive.LastTip()->GetHeight() ) + errorstr = (char *)"it must mature in the future"; if ( errorstr == 0 ) { if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) From 38093ec82aeacf182fd322b69f89498256d5c495 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 02:52:29 -1100 Subject: [PATCH 1004/3904] Need baton in 'R' --- src/cc/marmara.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index a50059305..1ff1855dd 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -311,7 +311,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; + UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; int32_t needbaton = 0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; @@ -324,10 +324,13 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri errorstr = (char *)"it must mature in the future"; if ( errorstr == 0 ) { - if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) + if ( createtxid == zeroid ) + needbaton = 1; + if ( AddNormalinputs(mtx,mypk,(1+needbaton)*txfee,1) > 0 ) { errorstr = (char *)"couldnt finalize CCtx"; - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,senderpk)); + if ( needbaton != 0 ) + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,senderpk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('R',createtxid,senderpk,amount,matures,currency)); } else errorstr = (char *)"dont have enough normal inputs for 2*txfee"; } From 908ee69451cc2cceb48775b0a9344d331234a261 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 03:04:34 -1100 Subject: [PATCH 1005/3904] Marmarareceive roc --- src/cc/CCMarmara.h | 1 + src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 27 ++++++++++++++++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 4a50c2539..d3eb67b77 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -25,6 +25,7 @@ #define MARMARA_MAXLOCK (1440 * 24 * 30) uint64_t komodo_block_prg(uint32_t nHeight); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] +UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index d6b801dd5..5baadf34a 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -444,6 +444,7 @@ static const CRPCCommand vRPCCommands[] = // Marmara { "marmara", "marmaraaddress", &marmaraaddress, true }, { "marmara", "marmarapoolpayout", &marmara_poolpayout, true }, + { "marmara", "marmarareceive", &marmara_receive, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index bd00bb9d1..4787130e2 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -273,6 +273,7 @@ extern UniValue pricesfinish(const UniValue& params, bool fHelp); extern UniValue pegsaddress(const UniValue& params, bool fHelp); extern UniValue marmaraaddress(const UniValue& params, bool fHelp); extern UniValue marmara_poolpayout(const UniValue& params, bool fHelp); +extern UniValue marmara_receive(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1790a574a..a2b0afa37 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5537,7 +5537,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) { // marmarapoolpayout 0.5 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000],["02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",100]]'; - throw runtime_error("marmara_poolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); + throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -5547,6 +5547,31 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) return(MarmaraPoolPayout(0,firstheight,perc,jsonstr)); // [[pk0, shares0], [pk1, shares1], ...] } +UniValue marmara_receive(const UniValue& params, bool fHelp) +{ + uint256 createtxid; std::vector senderpub; int64_t amount; int32_t matures; + if ( fHelp || (params.size() != 5 && params.size() != 4) ) + { + // marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 + throw runtime_error("marmarareceive senderpk amount currency matures createtxid\n"); + } + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + memset(&createtxid,0,sizeof(createtxid)); + senderpub = ParseHex(params[0].get_str().c_str()); + if (senderpub.size()!= 33) + { + ERR_RESULT("invalid sender pubkey"); + return result; + } + amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; + currency = params[2].get_str(); + matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1; + if ( params.size() == 5 ) + createtxid = Parseuint256((char *)params[4].get_str().c_str()); + return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,createtxid)); +} + UniValue channelslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) From 2084694843126a610875b6a5294219b30e0c3925 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 03:08:37 -1100 Subject: [PATCH 1006/3904] Syntax --- src/wallet/rpcwallet.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a2b0afa37..7160489de 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5549,10 +5549,11 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) UniValue marmara_receive(const UniValue& params, bool fHelp) { - uint256 createtxid; std::vector senderpub; int64_t amount; int32_t matures; + UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector senderpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || (params.size() != 5 && params.size() != 4) ) { - // marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 + // 1st marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 + // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 throw runtime_error("marmarareceive senderpk amount currency matures createtxid\n"); } if ( ensure_CCrequirements() < 0 ) From a90b1bb7d516a9e21d8ae9f5bb751024923ef016 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 03:10:35 -1100 Subject: [PATCH 1007/3904] Clear default errorstr --- src/cc/marmara.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 1ff1855dd..353e07a30 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -332,6 +332,8 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri if ( needbaton != 0 ) mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,senderpk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('R',createtxid,senderpk,amount,matures,currency)); + if ( rawtx.size() > 0 ) + errorstr = 0; } else errorstr = (char *)"dont have enough normal inputs for 2*txfee"; } if ( rawtx.size() == 0 || errorstr != 0 ) From 46069b7159ed360f0ec32e92d79a9553468cfd58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 03:12:07 -1100 Subject: [PATCH 1008/3904] funcid --- src/cc/marmara.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 353e07a30..85487f748 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -346,6 +346,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri { result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("funcid","R")); result.push_back(Pair("createtxid",createtxid.GetHex())); result.push_back(Pair("senderpk",HexStr(senderpk))); result.push_back(Pair("amount",ValueFromAmount(amount))); From c10dfbb858ed1f36384043a82ff1a033f2a6299c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 03:21:20 -1100 Subject: [PATCH 1009/3904] marmara_issue --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 45 ++++++++++++++++++++++++++++++++++++++++ src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 23 ++++++++++++++++++++ 5 files changed, 71 insertions(+) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index d3eb67b77..5fc1ce891 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -26,6 +26,7 @@ uint64_t komodo_block_prg(uint32_t nHeight); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); +UniValue MarmaraIssue(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 85487f748..5cd623966 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -356,6 +356,51 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri return(result); } +UniValue MarmaraIssue(uint64_t txfee,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; + cp = CCinit(&C,EVAL_MARMARA); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + if ( currency != "MARMARA" ) + errorstr = (char *)"for now, only MARMARA loops are supported"; + else if ( amount < txfee ) + errorstr = (char *)"amount must be for more than txfee"; + else if ( matures <= chainActive.LastTip()->GetHeight() ) + errorstr = (char *)"it must mature in the future"; + if ( errorstr == 0 ) + { + if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) + { + errorstr = (char *)"couldnt finalize CCtx"; + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,receiverpk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('I',createtxid,receiverpk,amount,matures,currency)); + if ( rawtx.size() > 0 ) + errorstr = 0; + } else errorstr = (char *)"dont have enough normal inputs for 2*txfee"; + } + if ( rawtx.size() == 0 || errorstr != 0 ) + { + result.push_back(Pair("result","error")); + if ( errorstr != 0 ) + result.push_back(Pair("error",errorstr)); + } + else + { + result.push_back(Pair("result",(char *)"success")); + result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("funcid","R")); + result.push_back(Pair("createtxid",createtxid.GetHex())); + result.push_back(Pair("receiverpk",HexStr(receiverpk))); + result.push_back(Pair("amount",ValueFromAmount(amount))); + result.push_back(Pair("matures",matures)); + result.push_back(Pair("currency",currency)); + } + return(result); +} + std::string MarmaraFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 5baadf34a..add90902c 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -445,6 +445,7 @@ static const CRPCCommand vRPCCommands[] = { "marmara", "marmaraaddress", &marmaraaddress, true }, { "marmara", "marmarapoolpayout", &marmara_poolpayout, true }, { "marmara", "marmarareceive", &marmara_receive, true }, + { "marmara", "marmaraissue", &marmara_issue, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 4787130e2..b7654da38 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -274,6 +274,7 @@ extern UniValue pegsaddress(const UniValue& params, bool fHelp); extern UniValue marmaraaddress(const UniValue& params, bool fHelp); extern UniValue marmara_poolpayout(const UniValue& params, bool fHelp); extern UniValue marmara_receive(const UniValue& params, bool fHelp); +extern UniValue marmara_issue(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7160489de..bb6bb8c12 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5573,6 +5573,29 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,createtxid)); } +UniValue marmara_issue(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + if ( fHelp || params.size() != 5 ) + { + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + throw runtime_error("marmarareceive receiverpk amount currency matures createtxid\n"); + } + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + receiverpub = ParseHex(params[0].get_str().c_str()); + if (receiverpub.size()!= 33) + { + ERR_RESULT("invalid receiverpub pubkey"); + return result; + } + amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; + currency = params[2].get_str(); + matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1; + createtxid = Parseuint256((char *)params[4].get_str().c_str()); + return(MarmaraIssue(0,pubkey2pk(receiverpub),amount,currency,matures,createtxid)); +} + UniValue channelslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) From 8ae7b65569a4f5dc8b0aee5929841a544e518539 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 03:26:43 -1100 Subject: [PATCH 1010/3904] Off by 1 --- src/cc/marmara.cpp | 2 +- src/wallet/rpcwallet.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5cd623966..1b06dfd2f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -391,7 +391,7 @@ UniValue MarmaraIssue(uint64_t txfee,CPubKey receiverpk,int64_t amount,std::stri { result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); - result.push_back(Pair("funcid","R")); + result.push_back(Pair("funcid","I")); result.push_back(Pair("createtxid",createtxid.GetHex())); result.push_back(Pair("receiverpk",HexStr(receiverpk))); result.push_back(Pair("amount",ValueFromAmount(amount))); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bb6bb8c12..e77f8e55a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5578,8 +5578,8 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb - throw runtime_error("marmarareceive receiverpk amount currency matures createtxid\n"); + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + throw runtime_error("marmaraissue receiverpk amount currency matures createtxid\n"); } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -5591,7 +5591,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) } amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; currency = params[2].get_str(); - matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1; + matures = atol(params[3].get_str().c_str()); createtxid = Parseuint256((char *)params[4].get_str().c_str()); return(MarmaraIssue(0,pubkey2pk(receiverpub),amount,currency,matures,createtxid)); } From c334d5c2e426605445bb6a5372dcfb3c99d634d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 03:36:14 -1100 Subject: [PATCH 1011/3904] Marmara transfer --- src/cc/CCMarmara.h | 2 +- src/cc/marmara.cpp | 5 +++-- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 25 ++++++++++++++++++++++++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 5fc1ce891..8fbe25b62 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -26,7 +26,7 @@ uint64_t komodo_block_prg(uint32_t nHeight); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); -UniValue MarmaraIssue(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); +UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 1b06dfd2f..41287c76f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -356,7 +356,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri return(result); } -UniValue MarmaraIssue(uint64_t txfee,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid) +UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; @@ -391,7 +391,8 @@ UniValue MarmaraIssue(uint64_t txfee,CPubKey receiverpk,int64_t amount,std::stri { result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); - result.push_back(Pair("funcid","I")); + char str[2]; str[0] = funcid, str[1] = 0; + result.push_back(Pair("funcid",str)); result.push_back(Pair("createtxid",createtxid.GetHex())); result.push_back(Pair("receiverpk",HexStr(receiverpk))); result.push_back(Pair("amount",ValueFromAmount(amount))); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index add90902c..497cb1ae2 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -446,6 +446,7 @@ static const CRPCCommand vRPCCommands[] = { "marmara", "marmarapoolpayout", &marmara_poolpayout, true }, { "marmara", "marmarareceive", &marmara_receive, true }, { "marmara", "marmaraissue", &marmara_issue, true }, + { "marmara", "marmaratransfer", &marmara_transfer, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index b7654da38..19680c0ef 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -275,6 +275,7 @@ extern UniValue marmaraaddress(const UniValue& params, bool fHelp); extern UniValue marmara_poolpayout(const UniValue& params, bool fHelp); extern UniValue marmara_receive(const UniValue& params, bool fHelp); extern UniValue marmara_issue(const UniValue& params, bool fHelp); +extern UniValue marmara_transfer(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e77f8e55a..d0dc60489 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5593,7 +5593,30 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()); createtxid = Parseuint256((char *)params[4].get_str().c_str()); - return(MarmaraIssue(0,pubkey2pk(receiverpub),amount,currency,matures,createtxid)); + return(MarmaraIssue(0,'I',pubkey2pk(receiverpub),amount,currency,matures,createtxid)); +} + +UniValue marmara_transfer(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + if ( fHelp || params.size() != 5 ) + { + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + throw runtime_error("marmaratransfer receiverpk amount currency matures createtxid\n"); + } + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + receiverpub = ParseHex(params[0].get_str().c_str()); + if (receiverpub.size()!= 33) + { + ERR_RESULT("invalid receiverpub pubkey"); + return result; + } + amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; + currency = params[2].get_str(); + matures = atol(params[3].get_str().c_str()); + createtxid = Parseuint256((char *)params[4].get_str().c_str()); + return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,createtxid)); } UniValue channelslist(const UniValue& params, bool fHelp) From e06138fecf70ac4e36ce1e084e64b1336738ec42 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 05:34:42 -1100 Subject: [PATCH 1012/3904] Cap -ac_perc to be based on million max --- src/cc/marmara.cpp | 19 +++++-------------- src/komodo_bitcoind.h | 6 ++++-- src/wallet/rpcwallet.cpp | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 41287c76f..9a5a1e6ef 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -251,20 +251,9 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t } else if ( funcid == 'S' ) // collect -> automatically spend issuers locked funds, given 'I' { - return(true); - } - else if ( funcid == 'A' ) // agree -> agree that 'I' is unable to be redeemed, remainder - { - return(true); - } - else if ( funcid == 'D' ) // dispute -> given 'I' submit for manual arbitration - { - return(true); - } - else if ( funcid == 'F' ) // foreclose -> given 'A' collect as much of remainder from credit loop - { - return(true); + return(true); // iterate from issuer all remainder after maturity } + // staking only for locked utxo } return eval->Invalid("fall through error"); } @@ -315,6 +304,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; + // check for batonownership by senderpk and parameters match createtxid mypk = pubkey2pk(Mypubkey()); if ( currency != "MARMARA" ) errorstr = (char *)"for now, only MARMARA loops are supported"; @@ -363,6 +353,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; + // make sure if transfer that it is not too late mypk = pubkey2pk(Mypubkey()); if ( currency != "MARMARA" ) errorstr = (char *)"for now, only MARMARA loops are supported"; @@ -376,7 +367,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a { errorstr = (char *)"couldnt finalize CCtx"; mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,receiverpk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('I',createtxid,receiverpk,amount,matures,currency)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret(funcid,createtxid,receiverpk,amount,matures,currency)); if ( rawtx.size() > 0 ) errorstr = 0; } else errorstr = (char *)"dont have enough normal inputs for 2*txfee"; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 841396a00..9ecb8ce77 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1165,10 +1165,12 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) total += pblock->vtx[i].vout[j].nValue; + if ( total > 1000000 * COIN ) + total = 1000000 * COIN; } } - commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000; - //commission = ((total * ASSETCHAINS_COMMISSION) / COIN); + //commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000; + commission = ((total * ASSETCHAINS_COMMISSION) / COIN); } if ( commission < 10000 ) commission = 0; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d0dc60489..f17faca58 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5601,7 +5601,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + // marmaratransfer 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb throw runtime_error("marmaratransfer receiverpk amount currency matures createtxid\n"); } if ( ensure_CCrequirements() < 0 ) From e565e0b7204314b2e48fdf83d6454a97a9b04df3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 06:15:44 -1100 Subject: [PATCH 1013/3904] Break --- src/komodo_bitcoind.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9ecb8ce77..b99b998e1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1166,7 +1166,10 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if ( i != 0 || j != 1 ) total += pblock->vtx[i].vout[j].nValue; if ( total > 1000000 * COIN ) + { total = 1000000 * COIN; + break; + } } } //commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000; From aa7d0e8d888b5f11e4caf5e031924d2b196e8c93 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 06:57:20 -1100 Subject: [PATCH 1014/3904] Fix pos64 with verushash --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 128a94e3a..ce2b88156 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1197,7 +1197,7 @@ void static BitcoinMiner_noeq() miningTimer.start(); #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", -1) == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From 530fb3901342196b595572ffe6519d0516ec525f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:04:45 -1100 Subject: [PATCH 1015/3904] +print --- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b99b998e1..b640d3db0 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2084,7 +2084,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt komodo_segids(hashbuf,nHeight-101,100); if ( *blocktimep < tipindex->nTime+60 ) *blocktimep = tipindex->nTime+60; - //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); +fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); bool resetstaker = false; if ( array != 0 ) @@ -2140,7 +2140,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt lasttime = (uint32_t)time(NULL); //fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } -//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); +fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; inBits); + printf("isStake.%d\n",isStake); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { LEAVE_CRITICAL_SECTION(cs_main); From 6c9d66ed0de5ca0af847cbf139251fefa6669dab Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:10:50 -1100 Subject: [PATCH 1016/3904] Set isStaked --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 02a3e1a91..2c6f4af8d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -482,7 +482,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t stakeHeight = chainActive.Height() + 1; //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); - printf("isStake.%d\n",isStake); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { LEAVE_CRITICAL_SECTION(cs_main); @@ -802,6 +801,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey); + if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) + isStake = true; return CreateNewBlock(pubkey,scriptPubKey, gpucount, isStake); } @@ -1198,7 +1199,7 @@ void static BitcoinMiner_noeq() miningTimer.start(); #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", -1) == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From db879566f571cc7c123b554fe83769d845ead722 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:16:34 -1100 Subject: [PATCH 1017/3904] Test --- src/komodo_bitcoind.h | 8 ++++---- src/miner.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b640d3db0..66097b3f9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1312,12 +1312,12 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( validateflag != 0 ) { - /*for (i=31; i>=24; i--) + for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs "); for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff); break; } } @@ -2084,7 +2084,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt komodo_segids(hashbuf,nHeight-101,100); if ( *blocktimep < tipindex->nTime+60 ) *blocktimep = tipindex->nTime+60; -fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); +//fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); bool resetstaker = false; if ( array != 0 ) @@ -2140,7 +2140,7 @@ fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL), lasttime = (uint32_t)time(NULL); //fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } -fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); +//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; iGetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", -1) == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif @@ -1502,7 +1502,7 @@ void static BitcoinMiner() { static uint32_t counter; if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) - fprintf(stderr,"created illegal block, retry\n"); + fprintf(stderr,"created illegal blockB, retry\n"); sleep(1); continue; } From 3118af7d07ab9b9375a8b8c1b4fb6a579a6100be Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:24:38 -1100 Subject: [PATCH 1018/3904] +print --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 66097b3f9..478aa9ac4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2039,9 +2039,9 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod kp->hashval = UintToArith256(hash); segid = ((nHeight + kp->segid32) & 0x3f); hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - //for (int i=32; i>=0; i--) - // fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - //fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); + for (int i=32; i>=0; i--) + fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); if ( hashval <= bnTarget ) { for (iter=0; iter Date: Sun, 13 Jan 2019 07:26:02 -1100 Subject: [PATCH 1019/3904] Test --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f88b8f260..f6c3e1aac 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1199,14 +1199,14 @@ void static BitcoinMiner_noeq() miningTimer.start(); #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif if ( ptr == 0 ) { static uint32_t counter; - if ( counter++ < 100 ) + if ( counter++ < 10 ) fprintf(stderr,"created illegal block, retry\n"); continue; } @@ -1501,7 +1501,7 @@ void static BitcoinMiner() if ( ptr == 0 ) { static uint32_t counter; - if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) + if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 ) fprintf(stderr,"created illegal blockB, retry\n"); sleep(1); continue; From 290926a05f81cbb586d60d24f106415507851981 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:34:22 -1100 Subject: [PATCH 1020/3904] Test --- src/komodo_bitcoind.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 478aa9ac4..fb5ca24a0 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1312,12 +1312,12 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( validateflag != 0 ) { - for (i=31; i>=24; i--) + /*for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs "); for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff); + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ break; } } @@ -2039,8 +2039,11 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod kp->hashval = UintToArith256(hash); segid = ((nHeight + kp->segid32) & 0x3f); hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - for (int i=32; i>=0; i--) + for (int i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," vs "); + for (int i=31; i>=16; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); if ( hashval <= bnTarget ) { From 265c9b3c3b04bc1234594bc5aaee344502dff81c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:40:06 -1100 Subject: [PATCH 1021/3904] Test --- src/komodo_bitcoind.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fb5ca24a0..9e05ea1f9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2052,9 +2052,15 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod if ( blocktime+iter+segid*2 < kp->txtime+minage ) continue; hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); + for (int i=31; i>=16; i--) + fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," vs "); + for (int i=31; i>=16; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," iter.%d\n",iter); if ( hashval <= bnTarget ) { - //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); + fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); blocktime += iter; blocktime += segid * 2; return(blocktime); From 6922cdfa835e697a850bfed64e0a90f61ab42e39 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:43:40 -1100 Subject: [PATCH 1022/3904] Test --- src/komodo_bitcoind.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9e05ea1f9..bf7dff756 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2039,12 +2039,12 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod kp->hashval = UintToArith256(hash); segid = ((nHeight + kp->segid32) & 0x3f); hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - for (int i=31; i>=16; i--) + /*for (int i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs "); for (int i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); + fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime);*/ if ( hashval <= bnTarget ) { for (iter=0; itertxtime+minage ) continue; hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); - for (int i=31; i>=16; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," vs "); - for (int i=31; i>=16; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," iter.%d\n",iter); if ( hashval <= bnTarget ) { fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); @@ -2164,7 +2158,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); -//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); +fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; @@ -2177,7 +2171,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier break; m++; -//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); +fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); } } else @@ -2187,7 +2181,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } eligible = besttime; winners++; -//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); +fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) { earliest = eligible; @@ -2199,7 +2193,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); } - } //else fprintf(stderr,"utxo not eligible\n"); + } else fprintf(stderr,"utxo not eligible\n"); } if ( numkp < 1000 && array != 0 ) { From 31bad59a04c8a09aa92c53a4d96e203fe4ef9094 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:46:32 -1100 Subject: [PATCH 1023/3904] Test --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bf7dff756..634f61abf 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1267,7 +1267,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) { - //fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); + fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); return(0); } if ( value < SATOSHIDEN ) @@ -1312,12 +1312,12 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( validateflag != 0 ) { - /*for (i=31; i>=24; i--) + for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs "); for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff); break; } } @@ -2054,7 +2054,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); if ( hashval <= bnTarget ) { - fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); + //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); blocktime += iter; blocktime += segid * 2; return(blocktime); From 05f3d0f8723ba0810ba099ba5cdcc5e094fcbadf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:52:01 -1100 Subject: [PATCH 1024/3904] Test --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 634f61abf..ae564dc80 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1304,7 +1304,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh winner = 1; if ( validateflag == 0 ) { - //fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); + fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); blocktime += iter; blocktime += segid * 2; } @@ -1312,17 +1312,17 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( validateflag != 0 ) { - for (i=31; i>=24; i--) + /*for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs "); for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff); + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ break; } } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( 0 && validateflag != 0 ) + //if ( 0 && validateflag != 0 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); From b7f3a6778a92c16a5d93eb8ffa2906c2910a2eba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 07:58:01 -1100 Subject: [PATCH 1025/3904] Test --- src/komodo_bitcoind.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ae564dc80..7741bfb11 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2158,7 +2158,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); -fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); +//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; @@ -2171,7 +2171,7 @@ fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier break; m++; -fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); +//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); } } else @@ -2181,7 +2181,7 @@ fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u te } eligible = besttime; winners++; -fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); +//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) { earliest = eligible; @@ -2193,7 +2193,7 @@ fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",n *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); } - } else fprintf(stderr,"utxo not eligible\n"); + } //else fprintf(stderr,"utxo not eligible\n"); } if ( numkp < 1000 && array != 0 ) { @@ -2229,7 +2229,7 @@ fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",n for (i=0; i Date: Sun, 13 Jan 2019 07:59:28 -1100 Subject: [PATCH 1026/3904] Split commission calc --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7741bfb11..9dc481529 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1172,8 +1172,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } } } - //commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000; - commission = ((total * ASSETCHAINS_COMMISSION) / COIN); + commission = ((total / 10000) * ASSETCHAINS_COMMISSION) / 10000; + //commission = ((total * ASSETCHAINS_COMMISSION) / COIN); } if ( commission < 10000 ) commission = 0; From c50181ee6b42b611016553b37fb8615d1de78ce2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 08:10:52 -1100 Subject: [PATCH 1027/3904] Use BitcoinMiner for staking verushash --- src/komodo_bitcoind.h | 2 +- src/miner.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9dc481529..a469ad2ed 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1322,7 +1322,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - //if ( 0 && validateflag != 0 ) + if ( 0 && validateflag != 0 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); diff --git a/src/miner.cpp b/src/miner.cpp index f6c3e1aac..d68ea7369 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1907,12 +1907,12 @@ void static BitcoinMiner() for (int i = 0; i < nThreads; i++) { #ifdef ENABLE_WALLET - if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH || (ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0) ) minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet)); else minerThreads->create_thread(boost::bind(&BitcoinMiner_noeq, pwallet)); #else - if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH || (ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0) ) minerThreads->create_thread(&BitcoinMiner); else minerThreads->create_thread(&BitcoinMiner_noeq); From 5ee83c628c943094f7ab2c5b60c6d22ed65e5503 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 08:24:46 -1100 Subject: [PATCH 1028/3904] -print --- src/komodo_bitcoind.h | 6 +++--- src/miner.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a469ad2ed..ebc50fa62 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1267,7 +1267,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) { - fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); + //fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); return(0); } if ( value < SATOSHIDEN ) @@ -1304,7 +1304,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh winner = 1; if ( validateflag == 0 ) { - fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); + //fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); blocktime += iter; blocktime += segid * 2; } @@ -2229,7 +2229,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt for (i=0; i 1 ) { - fprintf(stderr,"mine to -ac_script\n"); + //fprintf(stderr,"mine to -ac_script\n"); //txNew.vout[1].scriptPubKey = CScript() << ParseHex(); int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); len >>= 1; From cf9f6577fc260772a5f47ac022246577599d7622 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Jan 2019 14:10:11 -1100 Subject: [PATCH 1029/3904] Adjust assert --- src/wallet/rpcwallet.cpp | 1 + src/wallet/wallet.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f17faca58..007c187a6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5537,6 +5537,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) { // marmarapoolpayout 0.5 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000],["02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",100]]'; + marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } if ( ensure_CCrequirements() < 0 ) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index dd188d418..0000f8d42 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1180,7 +1180,7 @@ bool DecrementNoteWitnesses(NoteDataMap& noteDataMap, int indexHeight, int64_t n assert((nWitnessCacheSize - 1) >= nd->witnesses.size()); } } - assert(KOMODO_REWIND != 0 || nWitnessCacheSize > 0); + assert(KOMODO_REWIND != 0 || nWitnessCacheSize > 0 || WITNESS_CACHE_SIZE != _COINBASE_MATURITY+10); return true; } From c2ce7ca9ced8e364a34d98cf814e7bca11bcdae4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 13:23:31 +0800 Subject: [PATCH 1030/3904] add segid to listunspent --- src/wallet/rpcwallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5a756ad7a..ff1f70eaa 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2775,6 +2775,8 @@ UniValue resendwallettransactions(const UniValue& params, bool fHelp) return result; } +extern uint32_t komodo_segid32(char *coinaddr); + UniValue listunspent(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -2869,6 +2871,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) if (fValidAddress) { entry.push_back(Pair("address", EncodeDestination(address))); + entry.push_back(Pair("segid", (int)komodo_segid32((char*)EncodeDestination(address).c_str()) & 0x3f )); if (pwalletMain->mapAddressBook.count(address)) entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); From 41363b7ea4089cc8720877f7a9eb3f626cb9cda0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 17:09:17 +0800 Subject: [PATCH 1031/3904] fix prints --- src/miner.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 26d1a1df9..e06a570c7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1303,9 +1303,8 @@ void static BitcoinMiner_noeq() { int32_t percPoS,z; hashTarget = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&hashTarget)[z]); - fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED); + if ( ASSETCHAINS_STAKED < 100 ) + LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } while (true) @@ -1630,18 +1629,16 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; + if ( ASSETCHAINS_STAKED > 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); if ( ASSETCHAINS_STAKED < 100 ) - { - //for (z=31; z>=0; z--) - // fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); - } } + while (true) { /*if ( KOMODO_INSYNC == 0 ) From b0ca0415ef02b2f32753e51befa98c4709a12d16 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 17:27:34 +0800 Subject: [PATCH 1032/3904] fix build --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9e253b6ea..eae71f987 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5672,7 +5672,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) { // marmarapoolpayout 0.5 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000],["02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",100]]'; - marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' + //marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } if ( ensure_CCrequirements() < 0 ) From f20420ea80a5147d56502968c6a77b8f2678851d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 18:18:18 +0800 Subject: [PATCH 1033/3904] fixed staking/generate in getmininginfo --- src/rpc/mining.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index dccbd9cfe..3843529ac 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -438,8 +438,11 @@ UniValue getmininginfo(const UniValue& params, bool fHelp) obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); obj.push_back(Pair("chain", Params().NetworkIDString())); #ifdef ENABLE_MINING - obj.push_back(Pair("staking", VERUS_MINTBLOCKS)); - obj.push_back(Pair("generate", GetBoolArg("-gen", false))); + bool staking = VERUS_MINTBLOCKS; + if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 ) + staking = true; + obj.push_back(Pair("staking", staking)); + obj.push_back(Pair("generate", GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) != 0 )); obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS)); #endif return obj; From 920a182c2bfb26de0416c56e1d983deff0ec4bc8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 21:21:37 -1100 Subject: [PATCH 1034/3904] marmarainfo firstheight lastheight minamount maxamount [currency issuerpk] --- src/cc/CCMarmara.h | 9 ++- src/cc/CCinclude.h | 2 + src/cc/CCtx.cpp | 4 +- src/cc/marmara.cpp | 167 +++++++++++++++++++++++++++++++++------ src/rpc/server.cpp | 2 + src/rpc/server.h | 2 + src/wallet/rpcwallet.cpp | 69 +++++++++++++--- 7 files changed, 216 insertions(+), 39 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 8fbe25b62..79372fa27 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -23,10 +23,15 @@ #define MARMARA_GROUPSIZE 60 #define MARMARA_MINLOCK (1440 * 3 * 30) #define MARMARA_MAXLOCK (1440 * 24 * 30) + uint64_t komodo_block_prg(uint32_t nHeight); +int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); + UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] -UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); -UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid); +UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid); +UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid); +UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency); +UniValue MarmaraCrediloop(uint256 batontxid); bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index aaeadcc61..0744156a5 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -56,6 +56,8 @@ extern uint32_t ASSETCHAINS_CC; extern char ASSETCHAINS_SYMBOL[]; extern std::string CCerror; +#define CC_MAXVINS 1024 + #define SMALLVAL 0.000000000000001 #ifndef _BITS256 #define _BITS256 diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 32d525517..a70d4f038 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -42,7 +42,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; - int64_t utxovalues[64],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; + int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64]; uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; CC *mycond=0,*othercond=0,*othercond2=0,*othercond3=0,*cond; CPubKey unspendablepk; n = mtx.vout.size(); @@ -52,7 +52,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran normaloutputs += mtx.vout[i].nValue; totaloutputs += mtx.vout[i].nValue; } - if ( (n= mtx.vin.size()) > 64 ) + if ( (n= mtx.vin.size()) > CC_MAXVINS ) { fprintf(stderr,"FinalizeCCTx: %d is too many vins\n",n); return("0"); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 9a5a1e6ef..ba238e755 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -18,6 +18,25 @@ /* Marmara CC is for the MARMARA project + 'R': two forms for initial issuance and for accepting existing + vins normal + vout0 approval to senderpk (issuer or owner of baton) + + 'I' + vin0 approval from 'R' + vins1+ normal + vout0 baton to 1st receiverpk + vout1 marker to Marmara so all issuances can be tracked (spent when loop is closed) + + 'T' + vin0 approval from 'R' + vin1 baton from 'I'/'T' + vins2+ normal + vout0 baton to next receiverpk (following the unspent baton back to original is the credit loop) + + 'S' + vins CC utxos from credit loop + */ // start of consensus code @@ -138,6 +157,29 @@ CScript MarmaraLoopOpret(uint8_t funcid,uint256 createtxid,CPubKey senderpk,int6 return(opret); } +uint8_t MarmaraDecodeLoopOpret(const CScript scriptPubKey,uint256 &createtxid,CPubKey &senderpk,int64_t &amount,int32_t &matures,std::string ¤cy) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> createtxid; ss >> senderpk; ss >> amount; ss >> matures; ss >> currency) != 0 ) + { + return(f); + } + return(0); +} + +int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid) +{ + CTransaction tx; uint256 hashBlock; int32_t numvouts,matures; std::string currency; CPubKey senderpk; int64_t amount; + if ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) == 'I' || funcid == 'T' ) + return(0); + } + return(-1); +} + CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { CTxOut ccvout; @@ -297,16 +339,51 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, return(totalinputs); } -UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid) +int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,struct CCcontract_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) +{ + char coinaddr[64]; CPubKey Marmarapk,senderpk; int64_t amount; uint256 createtxid,txid,hashBlock; CTransaction tx; int32_t numvouts,unlockht,ht,vout,matures,n=0; + std::vector > unspentOutputs; + Marmarapk = GetUnspendable(cp,0); + GetCCaddress(cp,coinaddr,Marmarapk); + SetCCunspents(unspentOutputs,coinaddr); + //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); + if ( vout == 1 && GetTransaction(txid,tx,hashBlock,false) != 0 ) + { + if ( tx.IsCoinBase() == 0 && (numvouts= tx.vout.size()) > 2 && tx.vout[numvouts - 1].nValue == 0 ) + { + if ( MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency) == 'I' ) + { + n++; + if ( currency == refcurrency && matures >= firstheight && matures <= lastheight && amount >= minamount && amount <= maxamount && (refpk.size() == 0 || senderpk == refpk) ) + { + issuances.push_back(txid); + totalamount += amount; + } + } + } + } else fprintf(stderr,"error getting tx\n"); + } + return(n); +} + +UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; int32_t needbaton = 0; + UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int32_t needbaton = 0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; // check for batonownership by senderpk and parameters match createtxid mypk = pubkey2pk(Mypubkey()); - if ( currency != "MARMARA" ) + memset(&createtxid,0,sizeof(createtxid)); + if ( batontxid != zeroid && MarmaraGetcreatetxid(createtxid,batontxid) < 0 ) + errorstr = (char *)"cant get createtxid from batontxid"; + else if ( currency != "MARMARA" ) errorstr = (char *)"for now, only MARMARA loops are supported"; else if ( amount < txfee ) errorstr = (char *)"amount must be for more than txfee"; @@ -346,16 +423,20 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri return(result); } -UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid) +UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; + UniValue result(UniValue::VOBJ); CPubKey mypk,Marmarapk; struct CCcontract_info *cp,C; std::string rawtx; uint256 createtxid; char *errorstr=0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; - // make sure if transfer that it is not too late + // make sure receiverpk is unique to creditloop + // make sure less than maxlength + Marmarapk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); - if ( currency != "MARMARA" ) + if ( MarmaraGetcreatetxid(createtxid,approvaltxid) < 0 ) + errorstr = (char *)"cant get createtxid from approvaltxid"; + else if ( currency != "MARMARA" ) errorstr = (char *)"for now, only MARMARA loops are supported"; else if ( amount < txfee ) errorstr = (char *)"amount must be for more than txfee"; @@ -363,10 +444,15 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a errorstr = (char *)"it must mature in the future"; if ( errorstr == 0 ) { - if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) + mtx.vin.push_back(CTxIn(approvaltxid,0,CScript())); + if ( funcid == 'T' ) + mtx.vin.push_back(CTxIn(batontxid,0,CScript())); + if ( funcid == 'I' || AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) { errorstr = (char *)"couldnt finalize CCtx"; mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,receiverpk)); + if ( funcid == 'I' ) + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,Marmarapk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret(funcid,createtxid,receiverpk,amount,matures,currency)); if ( rawtx.size() > 0 ) errorstr = 0; @@ -385,6 +471,9 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a char str[2]; str[0] = funcid, str[1] = 0; result.push_back(Pair("funcid",str)); result.push_back(Pair("createtxid",createtxid.GetHex())); + result.push_back(Pair("approvaltxid",approvaltxid.GetHex())); + if ( funcid == 'T' ) + result.push_back(Pair("batontxid",batontxid.GetHex())); result.push_back(Pair("receiverpk",HexStr(receiverpk))); result.push_back(Pair("amount",ValueFromAmount(amount))); result.push_back(Pair("matures",matures)); @@ -393,32 +482,64 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a return(result); } -std::string MarmaraFund(uint64_t txfee,int64_t funds) +// get creditloop pubkeys + +UniValue Marmara(uint64_t txfee,uint256 batontxid) { - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Marmarapk; CScript opret; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ); int64_t avail,amount,paid=0; int32_t i,n = 0; uint256 txid,*revcreditloop=0; CPubKey Marmarapk; struct CCcontract_info *cp,C; + result.push_back(Pair("result","success")); cp = CCinit(&C,EVAL_MARMARA); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) + txid = batontxid; + while ( txid.hasprev() != 0 ) { - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,funds,Marmarapk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); + txid = txid.prev(); + // check for unique, else error + revcreditloop[n++] = txid; } - return(""); + for (i=0; i= amount ) + { + change = (amount - paid); + break; + } + } + + return(result); } -UniValue MarmaraInfo() +UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { - UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey Marmarapk; struct CCcontract_info *cp,C; int64_t funding; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n; int64_t totalamount=0; std::vector issuances; + CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); - result.push_back(Pair("name","Marmara")); + if ( refpk.size() == 33 ) + result.push_back(Pair("issuer",HexStr(refpk))); + if ( currency.size() == 0 ) + currency = (char *)"MARMARA"; + if ( firstheight <= lastheight ) + firstheight = 0, lastheight = (1 << 30); + if ( minamount <= maxamount ) + minamount = 0, maxamount = (1LL << 60); + result.push_back(Pair("firstheight",firstheight)); + result.push_back(Pair("lastheight",lastheight)); + result.push_back(Pair("minamount",ValueFromAmount(minamount))); + result.push_back(Pair("maxamount",ValueFromAmount(maxamount))); + result.push_back(Pair("currency",currency)); cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); + if ( (n= MarmaraGetCreditloops(totalamount,issuances,cp,firstheight,lastheight,minamount,maxamount,refpk,currency)) > 0 ) + { + result.push_back(Pair("n",n)); + matches = (int32_t)issuances.size(); + result.push_back(Pair("matches",matches)); + for (i=0; i senderpub; int64_t amount; int32_t matures; std::string currency; + UniValue result(UniValue::VOBJ); uint256 batontxid; std::vector senderpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || (params.size() != 5 && params.size() != 4) ) { // 1st marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 - throw runtime_error("marmarareceive senderpk amount currency matures createtxid\n"); + throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - memset(&createtxid,0,sizeof(createtxid)); + memset(&batontxid,0,sizeof(batontxid)); senderpub = ParseHex(params[0].get_str().c_str()); if (senderpub.size()!= 33) { @@ -5570,17 +5570,17 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1; if ( params.size() == 5 ) - createtxid = Parseuint256((char *)params[4].get_str().c_str()); - return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,createtxid)); + batontxid = Parseuint256((char *)params[4].get_str().c_str()); + return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,batontxid)); } UniValue marmara_issue(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + UniValue result(UniValue::VOBJ); uint256 approvaltxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb - throw runtime_error("marmaraissue receiverpk amount currency matures createtxid\n"); + throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -5593,8 +5593,8 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()); - createtxid = Parseuint256((char *)params[4].get_str().c_str()); - return(MarmaraIssue(0,'I',pubkey2pk(receiverpub),amount,currency,matures,createtxid)); + approvaltxid = Parseuint256((char *)params[4].get_str().c_str()); + return(MarmaraIssue(0,'I',pubkey2pk(receiverpub),amount,currency,matures,approvaltxid,zeroid)); } UniValue marmara_transfer(const UniValue& params, bool fHelp) @@ -5603,7 +5603,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 5 ) { // marmaratransfer 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb - throw runtime_error("marmaratransfer receiverpk amount currency matures createtxid\n"); + throw runtime_error("marmaratransfer receiverpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -5616,8 +5616,53 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()); - createtxid = Parseuint256((char *)params[4].get_str().c_str()); - return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,createtxid)); + batontxid = Parseuint256((char *)params[4].get_str().c_str()); + if ( MarmaraGetcreatetxid(createtxid,batontxid) < 0 ) + throw runtime_error("invalid batontxid"); + return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,createtxid,batontxid)); +} + +UniValue marmara_info(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); CPubKey issuerpk; std::vector issuerpub; int64_t minamount,maxamount; int32_t firstheight,lastheight; std::string currency; + if ( fHelp || params.size() < 4 || params.size() > 6 ) + { + throw runtime_error("marmarainfo firstheight lastheight minamount maxamount [currency issuerpk]\n"); + } + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + firstheight = atol(params[0].get_str().c_str()); + lastheight = atol(params[1].get_str().c_str()); + minamount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; + maxamount = atof(params[3].get_str().c_str()) * COIN + 0.00000000499999; + if ( params.size() >= 5 ) + currency = params[4].get_str(); + if ( params.size() == 6 ) + { + issuerpub = ParseHex(params[5].get_str().c_str()); + if ( issuerpub.size()!= 33 ) + { + ERR_RESULT("invalid issuer pubkey"); + return result; + } + issuerpk = pubkey2pk(issuerpub); + } + result = MarmaraInfo(issuerpk,firstheight,lastheight,minamount,maxamount,currency); + return(result); +} + +UniValue marmara_creditloop(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + if ( fHelp || params.size() != 5 ) + { + // marmaratransfer 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + throw runtime_error("marmaratransfer receiverpk amount currency matures batontxid\n"); + } + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + //UniValue MarmaraCrediloop(uint256 batontxid); + return(result); } UniValue channelslist(const UniValue& params, bool fHelp) From fe0e9bd44ef146b8282b2d737543d3134ea581c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 21:26:39 -1100 Subject: [PATCH 1035/3904] Syntax --- src/cc/marmara.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ba238e755..1585bcc6b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -171,8 +171,8 @@ uint8_t MarmaraDecodeLoopOpret(const CScript scriptPubKey,uint256 &createtxid,CP int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid) { - CTransaction tx; uint256 hashBlock; int32_t numvouts,matures; std::string currency; CPubKey senderpk; int64_t amount; - if ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + CTransaction tx; uint256 hashBlock; uint8_t funcid; int32_t numvouts,matures; std::string currency; CPubKey senderpk; int64_t amount; + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) == 'I' || funcid == 'T' ) return(0); @@ -341,7 +341,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,struct CCcontract_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) { - char coinaddr[64]; CPubKey Marmarapk,senderpk; int64_t amount; uint256 createtxid,txid,hashBlock; CTransaction tx; int32_t numvouts,unlockht,ht,vout,matures,n=0; + char coinaddr[64]; CPubKey Marmarapk,senderpk; int64_t amount; uint256 createtxid,txid,hashBlock; CTransaction tx; int32_t numvouts,vout,matures,n=0; std::string currency; std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,Marmarapk); @@ -484,7 +484,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a // get creditloop pubkeys -UniValue Marmara(uint64_t txfee,uint256 batontxid) +/*UniValue Marmara(uint64_t txfee,uint256 batontxid) { UniValue result(UniValue::VOBJ); int64_t avail,amount,paid=0; int32_t i,n = 0; uint256 txid,*revcreditloop=0; CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); @@ -509,11 +509,11 @@ UniValue Marmara(uint64_t txfee,uint256 batontxid) } return(result); -} +}*/ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n; int64_t totalamount=0; std::vector issuances; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); if ( refpk.size() == 33 ) From 4f9ce5d4cc5fe824f6bb7c493042dd8d9f8e98bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 21:27:14 -1100 Subject: [PATCH 1036/3904] -ToString() --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 1585bcc6b..7188f510a 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -537,7 +537,7 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ matches = (int32_t)issuances.size(); result.push_back(Pair("matches",matches)); for (i=0; i Date: Mon, 14 Jan 2019 21:32:18 -1100 Subject: [PATCH 1037/3904] Fix --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f637f29b1..1c24547c2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5537,7 +5537,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) { // marmarapoolpayout 0.5 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000],["02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",100]]'; - marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' + //marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5599,7 +5599,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue marmara_transfer(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + UniValue result(UniValue::VOBJ); uint256 createtxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { // marmaratransfer 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb From 3246b4306b13162c3b922d628432bb4d229fbc89 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 22:07:24 -1100 Subject: [PATCH 1038/3904] Allow 'R' --- src/cc/marmara.cpp | 2 +- src/wallet/rpcwallet.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 7188f510a..b69807884 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -174,7 +174,7 @@ int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid) CTransaction tx; uint256 hashBlock; uint8_t funcid; int32_t numvouts,matures; std::string currency; CPubKey senderpk; int64_t amount; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { - if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) == 'I' || funcid == 'T' ) + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) == 'I' || funcid == 'T' || funcid == 'R' ) return(0); } return(-1); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1c24547c2..f5427fe70 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5553,8 +5553,8 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 batontxid; std::vector senderpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || (params.size() != 5 && params.size() != 4) ) { - // 1st marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 - // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 + // 1st marmarareceive 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1440 + // after marmarareceive 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1440 throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5579,7 +5579,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 approvaltxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3803 16e9d0571c9b9f0f885aabb432bdd68d7fce9c2af8aa56d09972f4c40b8435a1 throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) From 00ba2f442039eeed7978fb5e476212d260558d47 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 22:08:26 -1100 Subject: [PATCH 1039/3904] Set createtxid to txid for 'R" --- src/cc/marmara.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index b69807884..db60040fc 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -174,8 +174,13 @@ int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid) CTransaction tx; uint256 hashBlock; uint8_t funcid; int32_t numvouts,matures; std::string currency; CPubKey senderpk; int64_t amount; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { - if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) == 'I' || funcid == 'T' || funcid == 'R' ) + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) == 'I' || funcid == 'T' ) return(0); + else if ( funcid == 'R' ) + { + createtxid = txid; + return(0); + } } return(-1); } From 98a81709d70a4e07cf6d3662cb66b1cae64f42f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 22:13:46 -1100 Subject: [PATCH 1040/3904] Test --- src/cc/marmara.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index db60040fc..5eb40aebe 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -452,12 +452,12 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a mtx.vin.push_back(CTxIn(approvaltxid,0,CScript())); if ( funcid == 'T' ) mtx.vin.push_back(CTxIn(batontxid,0,CScript())); - if ( funcid == 'I' || AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) + if ( funcid == 'I' || AddNormalinputs(mtx,mypk,txfee,1) > 0 ) { errorstr = (char *)"couldnt finalize CCtx"; - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,receiverpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee/2,receiverpk)); if ( funcid == 'I' ) - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,Marmarapk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee/2,Marmarapk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret(funcid,createtxid,receiverpk,amount,matures,currency)); if ( rawtx.size() > 0 ) errorstr = 0; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f5427fe70..89ca92ce7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5579,7 +5579,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 approvaltxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3803 16e9d0571c9b9f0f885aabb432bdd68d7fce9c2af8aa56d09972f4c40b8435a1 + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3878 78d4bb8e70578ab28ddf60c0af93c6f459f525271864c9984ccbe14e25124dfc throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) From 5e4375ef81232be6714a2e7be9615304f9873c92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 22:23:31 -1100 Subject: [PATCH 1041/3904] 'R" to fund 'I' and 'T' --- src/cc/marmara.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5eb40aebe..29b57bbfd 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -379,7 +379,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int32_t needbaton = 0; + UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t amount; int32_t needbaton = 0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; @@ -396,13 +396,13 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri errorstr = (char *)"it must mature in the future"; if ( errorstr == 0 ) { - if ( createtxid == zeroid ) - needbaton = 1; - if ( AddNormalinputs(mtx,mypk,(1+needbaton)*txfee,1) > 0 ) + if ( batontxid != zeroid ) + amount = txfee; + else amount = 2*txfee; + if ( AddNormalinputs(mtx,mypk,amount + txfee,1) > 0 ) { errorstr = (char *)"couldnt finalize CCtx"; - if ( needbaton != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,senderpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,amount,senderpk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('R',createtxid,senderpk,amount,matures,currency)); if ( rawtx.size() > 0 ) errorstr = 0; @@ -455,9 +455,9 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a if ( funcid == 'I' || AddNormalinputs(mtx,mypk,txfee,1) > 0 ) { errorstr = (char *)"couldnt finalize CCtx"; - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee/2,receiverpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,receiverpk)); if ( funcid == 'I' ) - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee/2,Marmarapk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,Marmarapk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret(funcid,createtxid,receiverpk,amount,matures,currency)); if ( rawtx.size() > 0 ) errorstr = 0; From 54b98b84600ade58a2a3a8652d4ca1b3f16a3440 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 22:24:29 -1100 Subject: [PATCH 1042/3904] batonamount --- src/cc/marmara.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 29b57bbfd..35d465df1 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -379,7 +379,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t amount; int32_t needbaton = 0; + UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t batonamount; int32_t needbaton = 0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; @@ -397,9 +397,9 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri if ( errorstr == 0 ) { if ( batontxid != zeroid ) - amount = txfee; - else amount = 2*txfee; - if ( AddNormalinputs(mtx,mypk,amount + txfee,1) > 0 ) + batonamount = txfee; + else batonamount = 2*txfee; + if ( AddNormalinputs(mtx,mypk,batonamount + txfee,1) > 0 ) { errorstr = (char *)"couldnt finalize CCtx"; mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,amount,senderpk)); From a362c04ae941959ffcf60abab2a7292174f48500 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 22:26:31 -1100 Subject: [PATCH 1043/3904] Send baton amount --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 35d465df1..e5d5e9094 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -402,7 +402,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri if ( AddNormalinputs(mtx,mypk,batonamount + txfee,1) > 0 ) { errorstr = (char *)"couldnt finalize CCtx"; - mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,amount,senderpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,batonamount,senderpk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('R',createtxid,senderpk,amount,matures,currency)); if ( rawtx.size() > 0 ) errorstr = 0; From fccecf9b31b6a587ac5bd109662ce4bad6e30d50 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 22:54:40 -1100 Subject: [PATCH 1044/3904] Total amount --- src/cc/marmara.cpp | 1 + src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index e5d5e9094..89e5479c3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -544,6 +544,7 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ for (i=0; i receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3878 78d4bb8e70578ab28ddf60c0af93c6f459f525271864c9984ccbe14e25124dfc + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3903 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5602,7 +5602,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 createtxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaratransfer 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb throw runtime_error("marmaratransfer receiverpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements() < 0 ) From 52c163fe458e8bb7e63efc1724bdaef5555e6428 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 23:05:27 -1100 Subject: [PATCH 1045/3904] Dont increment matures on non-1st 'R' --- src/wallet/rpcwallet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f175192bd..f6c79826b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5554,7 +5554,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) if ( fHelp || (params.size() != 5 && params.size() != 4) ) { // 1st marmarareceive 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1440 - // after marmarareceive 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1440 + // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3903 bf6b4d42aa3ce974c853d73b06c78597dd3b5fb493d5d0d944f72c2017f561ad throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5568,9 +5568,11 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) } amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; currency = params[2].get_str(); - matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1; if ( params.size() == 5 ) + { + matures = atol(params[3].get_str().c_str()); batontxid = Parseuint256((char *)params[4].get_str().c_str()); + } else matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1; return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,batontxid)); } @@ -5602,7 +5604,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 createtxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb + // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 bf6b4d42aa3ce974c853d73b06c78597dd3b5fb493d5d0d944f72c2017f561ad throw runtime_error("marmaratransfer receiverpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements() < 0 ) From 3c03185b005d596c7cfa98793dd2ff66d528079c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 23:09:04 -1100 Subject: [PATCH 1046/3904] Add batontxid to transfer --- src/wallet/rpcwallet.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f6c79826b..a72518ac2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5601,11 +5601,11 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue marmara_transfer(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 createtxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; - if ( fHelp || params.size() != 5 ) + UniValue result(UniValue::VOBJ); uint256 batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + if ( fHelp || params.size() != 6 ) { - // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 bf6b4d42aa3ce974c853d73b06c78597dd3b5fb493d5d0d944f72c2017f561ad - throw runtime_error("marmaratransfer receiverpk amount currency matures batontxid\n"); + // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e + throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -5618,10 +5618,9 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()); - batontxid = Parseuint256((char *)params[4].get_str().c_str()); - if ( MarmaraGetcreatetxid(createtxid,batontxid) < 0 ) - throw runtime_error("invalid batontxid"); - return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,createtxid,batontxid)); + approvaltxid = Parseuint256((char *)params[4].get_str().c_str()); + batontxid = Parseuint256((char *)params[5].get_str().c_str()); + return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,approvaltxid,batontxid)); } UniValue marmara_info(const UniValue& params, bool fHelp) From cc839d6f773ae3312db3d92bae8edb7564cd1be6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 23:10:21 -1100 Subject: [PATCH 1047/3904] Approvaltxid --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a72518ac2..67f7fa054 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5601,10 +5601,10 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue marmara_transfer(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + UniValue result(UniValue::VOBJ); uint256 approvaltxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 6 ) { - // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e + // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e bf6b4d42aa3ce974c853d73b06c78597dd3b5fb493d5d0d944f72c2017f561ad throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) From 9755dbc647cb3ffe58abd56dddef1aaee384b205 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Jan 2019 23:25:17 -1100 Subject: [PATCH 1048/3904] Print batontxid --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 23 +++++++++++++++++++---- src/wallet/rpcwallet.cpp | 7 ++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 79372fa27..ef8cc678b 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -26,6 +26,7 @@ uint64_t komodo_block_prg(uint32_t nHeight); int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); +int32_t MarmaraGetbatontxid(uint256 &batontxid,uint256 txid); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 89e5479c3..c9976c75d 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -178,13 +178,26 @@ int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid) return(0); else if ( funcid == 'R' ) { - createtxid = txid; + if ( createtxid == zeroid ) + createtxid = txid; return(0); } } return(-1); } +int32_t MarmaraGetbatontxid(uint256 &batontxid,uint256 txid) +{ + uint256 createtxid; + memset(&batontxid,0,sizeof(batontxid)); + if ( MarmaraGetcreatetxid(createtxid,txid) == 0 ) + { + return(0); + } + return(-1); +} + + CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { CTxOut ccvout; @@ -420,6 +433,8 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri result.push_back(Pair("rawtx",rawtx)); result.push_back(Pair("funcid","R")); result.push_back(Pair("createtxid",createtxid.GetHex())); + if ( batontxid != zeroid ) + result.push_back(Pair("batontxid",batontxid.GetHex())); result.push_back(Pair("senderpk",HexStr(senderpk))); result.push_back(Pair("amount",ValueFromAmount(amount))); result.push_back(Pair("matures",matures)); @@ -445,8 +460,8 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a errorstr = (char *)"for now, only MARMARA loops are supported"; else if ( amount < txfee ) errorstr = (char *)"amount must be for more than txfee"; - else if ( matures <= chainActive.LastTip()->GetHeight() ) - errorstr = (char *)"it must mature in the future"; + //else if ( matures <= chainActive.LastTip()->GetHeight() ) + // errorstr = (char *)"it must mature in the future"; if ( errorstr == 0 ) { mtx.vin.push_back(CTxIn(approvaltxid,0,CScript())); @@ -544,7 +559,7 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ for (i=0; i receiverpub; int64_t amount; int32_t matures; std::string currency; - if ( fHelp || params.size() != 6 ) + if ( fHelp || params.size() != 5 ) { - // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e bf6b4d42aa3ce974c853d73b06c78597dd3b5fb493d5d0d944f72c2017f561ad + // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5619,7 +5619,8 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()); approvaltxid = Parseuint256((char *)params[4].get_str().c_str()); - batontxid = Parseuint256((char *)params[5].get_str().c_str()); + if ( MarmaraGetbatontxid(batontxid,approvaltxid) < 0 ) + throw runtime_error("couldnt find batontxid\n"); return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,approvaltxid,batontxid)); } From 6873cb6653db9457d860d02db6b4c6764bb4d0e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:09:07 -1100 Subject: [PATCH 1049/3904] Get credit loop --- src/cc/CCMarmara.h | 2 +- src/cc/CCinclude.h | 5 ++++- src/cc/CCtx.cpp | 34 ++++++++++++++++++++++++++++++++++ src/cc/marmara.cpp | 20 +++++++++++++++++--- src/wallet/rpcwallet.cpp | 4 ++-- 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index ef8cc678b..9904a663e 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -26,7 +26,7 @@ uint64_t komodo_block_prg(uint32_t nHeight); int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); -int32_t MarmaraGetbatontxid(uint256 &batontxid,uint256 txid); +int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 0744156a5..40028ee5c 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -105,15 +105,18 @@ struct oracleprice_info #ifdef ENABLE_WALLET extern CWallet* pwalletMain; #endif +//extern CCoinsViewCache *pcoinsTip; bool GetAddressUnspent(uint160 addressHash, int type,std::vector > &unspentOutputs); CBlockIndex *komodo_getblockindex(uint256 hash); int32_t komodo_nextheight(); +int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 txid,int32_t vout); + static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); int32_t is_hexstr(char *str,int32_t n); bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false); -//uint64_t myGettxout(uint256 hash,int32_t n); +int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag); bool myIsutxo_spentinmempool(uint256 txid,int32_t vout); bool mytxid_inmempool(uint256 txid); int32_t myIsutxo_spent(uint256 &spenttxid,uint256 txid,int32_t vout); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index a70d4f038..c73bead04 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -247,6 +247,40 @@ int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout) return(0); } +int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag) +{ + CCoins coins; + if ( mempoolflag != 0 ) + { + LOCK(mempool.cs); + CCoinsViewMemPool view(pcoinsTip, mempool); + if (!view.GetCoins(txid, coins)) + return(-1); + if ( myIsutxo_spentinmempool(txid,vout) != 0 ) + return(-1); + } + else + { + if (!pcoinsTip->GetCoins(hash, coins)) + return(-1); + } + if ( vout < coins.vout.size() ) + return(coins.vout[vout].nValue); + else return(-1); +} + +int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 txid,int32_t vout) +{ + CSpentIndexKey key(txid, vout); + CSpentIndexValue value; + if ( !GetSpentIndex(key, value) ) + return(-1); + spenttxid = value.txid; + vini = (int32_t)value.inputIndex; + height = value.blockHeight; + return(0); +} + int64_t CCaddress_balance(char *coinaddr) { int64_t sum = 0; std::vector > unspentOutputs; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index c9976c75d..cfbdbc798 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -186,13 +186,25 @@ int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid) return(-1); } -int32_t MarmaraGetbatontxid(uint256 &batontxid,uint256 txid) +int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid) { - uint256 createtxid; + uint256 createtxid,spenttxid; int64_t value; int32_t vini,height,vout = 0; memset(&batontxid,0,sizeof(batontxid)); if ( MarmaraGetcreatetxid(createtxid,txid) == 0 ) { - return(0); + txid = createtxid; + while ( CCgetspenttxid(spenttxid,vini,height,txid,vout) == 0 ) + { + if ( (value= CCgettxout(spenttxid,vout,1)) > 0 ) + { + batontxid = txid; + fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex(),(double)value/COIN); + return(0); + } + creditloop.push_back(spenttxid); + fprintf(stderr,"%s\n",spenttxid.GetHex()); + txid = spenttxid; + } } return(-1); } @@ -456,6 +468,8 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a mypk = pubkey2pk(Mypubkey()); if ( MarmaraGetcreatetxid(createtxid,approvaltxid) < 0 ) errorstr = (char *)"cant get createtxid from approvaltxid"; + else if ( batontxid == zeroid ) + errorstr = (char *)"null batontxid"; else if ( currency != "MARMARA" ) errorstr = (char *)"for now, only MARMARA loops are supported"; else if ( amount < txfee ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e22cdae0b..6ecf99204 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5601,7 +5601,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue marmara_transfer(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 approvaltxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + UniValue result(UniValue::VOBJ); uint256 approvaltxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; std::vector creditloop; if ( fHelp || params.size() != 5 ) { // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e @@ -5619,7 +5619,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()); approvaltxid = Parseuint256((char *)params[4].get_str().c_str()); - if ( MarmaraGetbatontxid(batontxid,approvaltxid) < 0 ) + if ( MarmaraGetbatontxid(creditloop,batontxid,approvaltxid) < 0 ) throw runtime_error("couldnt find batontxid\n"); return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,approvaltxid,batontxid)); } From 50cbe82c68e9904ccc784f54b92838129a06a26d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:13:48 -1100 Subject: [PATCH 1050/3904] Hash -> taxied --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index c73bead04..a80b3b3cf 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -261,7 +261,7 @@ int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag) } else { - if (!pcoinsTip->GetCoins(hash, coins)) + if (!pcoinsTip->GetCoins(txid, coins)) return(-1); } if ( vout < coins.vout.size() ) From 1cf607f70f3fd2e8dc8fe8f90a5c86c5318d7bd7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:16:16 -1100 Subject: [PATCH 1051/3904] c_str --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index cfbdbc798..60d827eca 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -198,7 +198,7 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, if ( (value= CCgettxout(spenttxid,vout,1)) > 0 ) { batontxid = txid; - fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex(),(double)value/COIN); + fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); return(0); } creditloop.push_back(spenttxid); From 9bf61c22593356c4fcca8386fcb5b61b417657f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:22:43 -1100 Subject: [PATCH 1052/3904] Tweak batontxid searching --- src/cc/marmara.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 60d827eca..67296f19c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -188,21 +188,23 @@ int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid) int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid) { - uint256 createtxid,spenttxid; int64_t value; int32_t vini,height,vout = 0; + uint256 createtxid,spenttxid; int64_t value; int32_t vini,height,n=0,vout = 0; memset(&batontxid,0,sizeof(batontxid)); if ( MarmaraGetcreatetxid(createtxid,txid) == 0 ) { txid = createtxid; + fprintf(stderr,"txid.%s -> createtxid %s\n",txid.GetHex().c_str(),createtxid.GetHex().c_str()); while ( CCgetspenttxid(spenttxid,vini,height,txid,vout) == 0 ) { + creditloop.push_back(txid); + fprintf(stderr,"%d: %s\n",n,txid.GetHex().c_str()); + n++; if ( (value= CCgettxout(spenttxid,vout,1)) > 0 ) { - batontxid = txid; + batontxid = spenttxid; fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); return(0); } - creditloop.push_back(spenttxid); - fprintf(stderr,"%s\n",spenttxid.GetHex()); txid = spenttxid; } } From 389e07d1fb5209669b382940747f10cd4d64ca9b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:46:27 -1100 Subject: [PATCH 1053/3904] marmara_creditloop --- src/cc/CCMarmara.h | 2 +- src/cc/marmara.cpp | 36 ++++++++++++++++++++++++++++++++---- src/wallet/rpcwallet.cpp | 9 +++++---- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 9904a663e..1d61a86d4 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -27,12 +27,12 @@ uint64_t komodo_block_prg(uint32_t nHeight); int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid); +UniValue MarmaraCreditloop(uint256 txid); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid); UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid); UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency); -UniValue MarmaraCrediloop(uint256 batontxid); bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 67296f19c..3ab1317c5 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -203,7 +203,7 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, { batontxid = spenttxid; fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); - return(0); + return(n); } txid = spenttxid; } @@ -211,7 +211,6 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, return(-1); } - CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { CTxOut ccvout; @@ -476,8 +475,8 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a errorstr = (char *)"for now, only MARMARA loops are supported"; else if ( amount < txfee ) errorstr = (char *)"amount must be for more than txfee"; - //else if ( matures <= chainActive.LastTip()->GetHeight() ) - // errorstr = (char *)"it must mature in the future"; + else if ( matures <= chainActive.LastTip()->GetHeight() ) + errorstr = (char *)"it must mature in the future"; if ( errorstr == 0 ) { mtx.vin.push_back(CTxIn(approvaltxid,0,CScript())); @@ -547,6 +546,35 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a return(result); }*/ +UniValue MarmaraCreditloop(uint256 txid) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid; uint8_t funcid; int32_t numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency; + if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) + { + for (i=0; i 1 ) + { + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) != 0 ) + { + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("txid",txid.GetHex())); + obj.push_back(Pair("createtxid",createtxid.GetHex())); + obj.push_back(Pair("senderpk",HexStr(senderpk))); + obj.push_back(Pair("amount",ValueFromAmount(amount))); + obj.push_back(Pair("matures",matures)); + obj.push_back(Pair("currency",currency)); + a.push_back(obj); + } + } + } + result.push_back(Pair("result",(char *)"success")); + result.push_back("creditloop",a); + } + + return(result); +} + UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6ecf99204..836380f1b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5656,14 +5656,15 @@ UniValue marmara_info(const UniValue& params, bool fHelp) UniValue marmara_creditloop(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; - if ( fHelp || params.size() != 5 ) + if ( fHelp || params.size() != 1 ) { - // marmaratransfer 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb - throw runtime_error("marmaratransfer receiverpk amount currency matures batontxid\n"); + // marmaracreditloop 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be + throw runtime_error("marmaracreditloop txid\n"); } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - //UniValue MarmaraCrediloop(uint256 batontxid); + txid = Parseuint256((char *)params[0].get_str().c_str()); + result = MarmaraCreditloop(txid); return(result); } From ba76bd2d7033c006dfd59570da936d390af7481c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:47:36 -1100 Subject: [PATCH 1054/3904] Declare vars --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 3ab1317c5..2b71f566b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -548,7 +548,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid; uint8_t funcid; int32_t numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,hashBlock; uint8_t funcid; int32_t numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency; CTransaction tx; if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { for (i=0; i Date: Tue, 15 Jan 2019 00:48:02 -1100 Subject: [PATCH 1055/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 2b71f566b..097983ebd 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -569,7 +569,7 @@ UniValue MarmaraCreditloop(uint256 txid) } } result.push_back(Pair("result",(char *)"success")); - result.push_back("creditloop",a); + result.push_back(Pair("creditloop",a)); } return(result); From e620f47e519a0a71daf7153791f63aa883f244c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:48:54 -1100 Subject: [PATCH 1056/3904] N --- src/cc/marmara.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 097983ebd..24bd3d6f3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -548,7 +548,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,hashBlock; uint8_t funcid; int32_t numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency; CTransaction tx; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency; CTransaction tx; if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { for (i=0; i Date: Tue, 15 Jan 2019 00:49:26 -1100 Subject: [PATCH 1057/3904] ) --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 24bd3d6f3..5c87d7bec 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -569,7 +569,7 @@ UniValue MarmaraCreditloop(uint256 txid) } } result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("n",n); + result.push_back(Pair("n",n)); result.push_back(Pair("creditloop",a)); } From 41ed37e9693eb2eeff036b9652e22cfaed01affe Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:50:18 -1100 Subject: [PATCH 1058/3904] Funcid --- src/cc/marmara.cpp | 1 + src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5c87d7bec..2629b7dfd 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -559,6 +559,7 @@ UniValue MarmaraCreditloop(uint256 txid) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid",txid.GetHex())); + obj.push_back(Pair("funcid",funcid)); obj.push_back(Pair("createtxid",createtxid.GetHex())); obj.push_back(Pair("senderpk",HexStr(senderpk))); obj.push_back(Pair("amount",ValueFromAmount(amount))); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 836380f1b..81b692dc0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5655,7 +5655,7 @@ UniValue marmara_info(const UniValue& params, bool fHelp) UniValue marmara_creditloop(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; + UniValue result(UniValue::VOBJ); uint256 txid; if ( fHelp || params.size() != 1 ) { // marmaracreditloop 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be From f03daaf2eb4df9da51c539cd07a4f015feec06a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 00:58:49 -1100 Subject: [PATCH 1059/3904] Baton address --- src/cc/marmara.cpp | 61 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 2629b7dfd..681689a6e 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -548,38 +548,63 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency; CTransaction tx; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char batonaddr[64]; if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { - for (i=0; i 1 ) { - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + result.push_back(Pair("result",(char *)"success")); + result.push_back(Pair("batontxid",batontxid.GetHex())); + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,senderpk,refamount,refmatures,refcurrency)) != 0 ) { - if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) != 0 ) + obj.push_back(Pair("funcid",funcid)); + obj.push_back(Pair("createtxid",createtxid.GetHex())); + obj.push_back(Pair("amount",ValueFromAmount(amount))); + obj.push_back(Pair("matures",matures)); + obj.push_back(Pair("currency",currency)); + GetScriptaddr(batonaddr,tx.vout[0].scriptPubKey); + obj.push_back(Pair("batonaddress",batonaddr)); + for (i=0; i 1 ) + { + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) != 0 ) + { + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("txid",txid.GetHex())); + obj.push_back(Pair("funcid",funcid)); + obj.push_back(Pair("senderpk",HexStr(senderpk))); + a.push_back(obj); + } + } } + result.push_back(Pair("n",n)); + result.push_back(Pair("creditloop",a)); + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get batontxid opret")); } } - result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("n",n)); - result.push_back(Pair("creditloop",a)); + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt find batontxid")); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get creditloop")); } - return(result); } UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; + + { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); if ( refpk.size() == 33 ) From 8f55cee678dce394ecb1e82d0734fc569723d9e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:02:12 -1100 Subject: [PATCH 1060/3904] Test --- src/cc/marmara.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 681689a6e..cf3d248e5 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -548,7 +548,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char batonaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64]; if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { if ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) @@ -557,13 +557,13 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("batontxid",batontxid.GetHex())); if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,senderpk,refamount,refmatures,refcurrency)) != 0 ) { - obj.push_back(Pair("funcid",funcid)); - obj.push_back(Pair("createtxid",createtxid.GetHex())); - obj.push_back(Pair("amount",ValueFromAmount(amount))); - obj.push_back(Pair("matures",matures)); - obj.push_back(Pair("currency",currency)); - GetScriptaddr(batonaddr,tx.vout[0].scriptPubKey); - obj.push_back(Pair("batonaddress",batonaddr)); + result.push_back(Pair("funcid",funcid)); + result.push_back(Pair("createtxid",createtxid.GetHex())); + result.push_back(Pair("amount",ValueFromAmount(amount))); + result.push_back(Pair("matures",matures)); + result.push_back(Pair("currency",currency)); + GetScriptaddr(coinaddr,tx.vout[0].scriptPubKey); + result.push_back(Pair("batonaddress",coinaddr)); for (i=0; i 1 ) @@ -574,6 +574,10 @@ UniValue MarmaraCreditloop(uint256 txid) obj.push_back(Pair("txid",txid.GetHex())); obj.push_back(Pair("funcid",funcid)); obj.push_back(Pair("senderpk",HexStr(senderpk))); + GetCCaddress(cp,coinaddr,senderpk); + obj.push_back(Pair("sender",coinaddr)); + GetScriptaddr(coinaddr,tx.vout[0].scriptPubKey); + obj.push_back(Pair("nextaddress",coinaddr)); a.push_back(obj); } } From c3d105361d60be8a4c7351970d768496110d7592 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:02:46 -1100 Subject: [PATCH 1061/3904] -{ --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index cf3d248e5..37afeec30 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -608,7 +608,7 @@ UniValue MarmaraCreditloop(uint256 txid) UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { - { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); if ( refpk.size() == 33 ) From fdfef30eb9864f90ebc13e5f8c41cc7cb6329307 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:04:54 -1100 Subject: [PATCH 1062/3904] Test --- src/cc/marmara.cpp | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 37afeec30..2c6b4d2d8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -52,44 +52,6 @@ int64_t IsMarmaravout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -/*bool MarmaraExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) -{ - static uint256 zerohash; - CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - for (i=0; iismyvin)(tx.vin[i].scriptSig) != 0 ) - { - //fprintf(stderr,"vini.%d check mempool\n",i); - if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) - return eval->Invalid("cant find vinTx"); - else - { - //fprintf(stderr,"vini.%d check hash and vout\n",i); - if ( hashBlock == zerohash ) - return eval->Invalid("cant Marmara from mempool"); - if ( (assetoshis= IsMarmaravout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) - inputs += assetoshis; - } - } - } - for (i=0; iInvalid("mismatched inputs != outputs + txfee"); - } - else return(true); -}*/ - int32_t MarmaraRandomize(uint32_t ind) { uint64_t val64; uint32_t val,range = (MARMARA_MAXLOCK - MARMARA_MINLOCK); @@ -548,7 +510,8 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64]; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { if ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) @@ -562,7 +525,7 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("amount",ValueFromAmount(amount))); result.push_back(Pair("matures",matures)); result.push_back(Pair("currency",currency)); - GetScriptaddr(coinaddr,tx.vout[0].scriptPubKey); + GetScriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); for (i=0; i issuances; CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); From 9ec06006d7c87c4223ba06b07ae81a0b2d273246 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:07:06 -1100 Subject: [PATCH 1063/3904] Getscriptaddress --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 2c6b4d2d8..e56f7fcc5 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -525,7 +525,7 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("amount",ValueFromAmount(amount))); result.push_back(Pair("matures",matures)); result.push_back(Pair("currency",currency)); - GetScriptaddress(coinaddr,tx.vout[0].scriptPubKey); + Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); for (i=0; i Date: Tue, 15 Jan 2019 01:15:36 -1100 Subject: [PATCH 1064/3904] Mypubkey() --- src/cc/marmara.cpp | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index e56f7fcc5..df41823cb 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -510,7 +510,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { @@ -520,13 +520,18 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("batontxid",batontxid.GetHex())); if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,senderpk,refamount,refmatures,refcurrency)) != 0 ) { - result.push_back(Pair("funcid",funcid)); - result.push_back(Pair("createtxid",createtxid.GetHex())); - result.push_back(Pair("amount",ValueFromAmount(amount))); - result.push_back(Pair("matures",matures)); - result.push_back(Pair("currency",currency)); + str[0] = funcid, str[1] = 0; + result.push_back(Pair("funcid",str)); + result.push_back(Pair("createtxid",refcreatetxid.GetHex())); + result.push_back(Pair("amount",ValueFromAmount(refamount))); + result.push_back(Pair("matures",refmatures)); + result.push_back(Pair("currency",refcurrency)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkeys[0])) << OP_CHECKSIG); + result.push_back(Pair("myaddress",coinaddr)); + GetCCaddress(cp,coinaddr,Mypubkey()); + result.push_back(Pair("myCCaddress",coinaddr)); for (i=0; i 1 ) @@ -534,13 +539,22 @@ UniValue MarmaraCreditloop(uint256 txid) if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) != 0 ) { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("txid",txid.GetHex())); - obj.push_back(Pair("funcid",funcid)); + obj.push_back(Pair("txid",creditloop[i].GetHex())); + str[0] = funcid, str[1] = 0; + obj.push_back(Pair("funcid",str)); obj.push_back(Pair("senderpk",HexStr(senderpk))); GetCCaddress(cp,coinaddr,senderpk); - obj.push_back(Pair("sender",coinaddr)); + obj.push_back(Pair("receiver",coinaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); obj.push_back(Pair("nextaddress",coinaddr)); + if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) + { + obj.push_back(Pair("objerror",(char *)"mismatched createtxid or amount or matures or currency"))); + obj.push_back(Pair("createtxid",createtxid.GetHex())); + obj.push_back(Pair("amount",ValueFromAmount(amount))); + obj.push_back(Pair("matures",matures)); + obj.push_back(Pair("currency",currency)); + } a.push_back(obj); } } @@ -570,9 +584,13 @@ UniValue MarmaraCreditloop(uint256 txid) UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; char coinaddr[64]; CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); + result.push_back(Pair("myaddress",coinaddr)); + GetCCaddress(cp,coinaddr,Mypubkey()); + result.push_back(Pair("myCCaddress",coinaddr)); if ( refpk.size() == 33 ) result.push_back(Pair("issuer",HexStr(refpk))); if ( currency.size() == 0 ) From e56e7dd8f822e437b3514bc0e38362c5b0554817 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:16:46 -1100 Subject: [PATCH 1065/3904] Fix --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index df41823cb..affa2a224 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -528,7 +528,7 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("currency",refcurrency)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkeys[0])) << OP_CHECKSIG); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); result.push_back(Pair("myaddress",coinaddr)); GetCCaddress(cp,coinaddr,Mypubkey()); result.push_back(Pair("myCCaddress",coinaddr)); From 0bf08eedd0e92eef7823868b219d94a62ac23312 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:17:30 -1100 Subject: [PATCH 1066/3904] - --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index affa2a224..c66a49ce3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -549,7 +549,7 @@ UniValue MarmaraCreditloop(uint256 txid) obj.push_back(Pair("nextaddress",coinaddr)); if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { - obj.push_back(Pair("objerror",(char *)"mismatched createtxid or amount or matures or currency"))); + obj.push_back(Pair("objerror",(char *)"mismatched createtxid or amount or matures or currency")); obj.push_back(Pair("createtxid",createtxid.GetHex())); obj.push_back(Pair("amount",ValueFromAmount(amount))); obj.push_back(Pair("matures",matures)); From e2a8009162d889da75fbfa87048af74da6df41c1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:29:54 -1100 Subject: [PATCH 1067/3904] numerrs --- src/cc/marmara.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index c66a49ce3..34efe2626 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -510,7 +510,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t err=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { @@ -522,6 +522,12 @@ UniValue MarmaraCreditloop(uint256 txid) { str[0] = funcid, str[1] = 0; result.push_back(Pair("funcid",str)); + if ( refcreatetxid != creditloop[0] ) + { + fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); + refcreatetxid = creditloop[0] + err++; + } result.push_back(Pair("createtxid",refcreatetxid.GetHex())); result.push_back(Pair("amount",ValueFromAmount(refamount))); result.push_back(Pair("matures",refmatures)); @@ -547,8 +553,11 @@ UniValue MarmaraCreditloop(uint256 txid) obj.push_back(Pair("receiver",coinaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); obj.push_back(Pair("nextaddress",coinaddr)); + if ( funcid == 'R' && createtxid == zeroid ) + createtxid = creditloop[i]; if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { + err++; obj.push_back(Pair("objerror",(char *)"mismatched createtxid or amount or matures or currency")); obj.push_back(Pair("createtxid",createtxid.GetHex())); obj.push_back(Pair("amount",ValueFromAmount(amount))); @@ -560,6 +569,7 @@ UniValue MarmaraCreditloop(uint256 txid) } } result.push_back(Pair("n",n)); + result.push_back(Pair("numerrors",errs)); result.push_back(Pair("creditloop",a)); } else From ac7814aa59e23753b86b25bc7d8a10d397923420 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:30:46 -1100 Subject: [PATCH 1068/3904] Numbers --- src/cc/marmara.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 34efe2626..beaccea21 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -510,7 +510,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t err=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { @@ -526,7 +526,7 @@ UniValue MarmaraCreditloop(uint256 txid) { fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); refcreatetxid = creditloop[0] - err++; + numerrs++; } result.push_back(Pair("createtxid",refcreatetxid.GetHex())); result.push_back(Pair("amount",ValueFromAmount(refamount))); @@ -557,7 +557,7 @@ UniValue MarmaraCreditloop(uint256 txid) createtxid = creditloop[i]; if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { - err++; + numerrs++; obj.push_back(Pair("objerror",(char *)"mismatched createtxid or amount or matures or currency")); obj.push_back(Pair("createtxid",createtxid.GetHex())); obj.push_back(Pair("amount",ValueFromAmount(amount))); @@ -569,7 +569,7 @@ UniValue MarmaraCreditloop(uint256 txid) } } result.push_back(Pair("n",n)); - result.push_back(Pair("numerrors",errs)); + result.push_back(Pair("numerrors",numerrs)); result.push_back(Pair("creditloop",a)); } else From 4ceddd6a93f5422db5959140bfe5b88f50adfb99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:31:35 -1100 Subject: [PATCH 1069/3904] ; --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index beaccea21..f7cad1fa9 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -525,7 +525,7 @@ UniValue MarmaraCreditloop(uint256 txid) if ( refcreatetxid != creditloop[0] ) { fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); - refcreatetxid = creditloop[0] + refcreatetxid = creditloop[0]; numerrs++; } result.push_back(Pair("createtxid",refcreatetxid.GetHex())); From 49ac671671802c40df7d4f2ea33d77b20cdad9d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:46:00 -1100 Subject: [PATCH 1070/3904] Test --- src/cc/marmara.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f7cad1fa9..48dc1f6ef 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -510,13 +510,17 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { if ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { result.push_back(Pair("result",(char *)"success")); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); + result.push_back(Pair("myaddress",coinaddr)); + GetCCaddress(cp,myCCaddr,Mypubkey()); + result.push_back(Pair("myCCaddress",myCCaddr)); result.push_back(Pair("batontxid",batontxid.GetHex())); if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,senderpk,refamount,refmatures,refcurrency)) != 0 ) { @@ -532,12 +536,15 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("amount",ValueFromAmount(refamount))); result.push_back(Pair("matures",refmatures)); result.push_back(Pair("currency",refcurrency)); + result.push_back(Pair("senderpk",HexStr(senderpk))); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk())) << OP_CHECKSIG); + obj.push_back(Pair("senderaddr",coinaddr)); + Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); - result.push_back(Pair("myaddress",coinaddr)); - GetCCaddress(cp,coinaddr,Mypubkey()); - result.push_back(Pair("myCCaddress",coinaddr)); + if ( strcmp(myCCaddr,coinaddr) == 0 ) + result.push_back(Pair("ismine",1)); + else result.push_back(Pair("ismine",0)); for (i=0; i 1 ) @@ -549,8 +556,8 @@ UniValue MarmaraCreditloop(uint256 txid) str[0] = funcid, str[1] = 0; obj.push_back(Pair("funcid",str)); obj.push_back(Pair("senderpk",HexStr(senderpk))); - GetCCaddress(cp,coinaddr,senderpk); - obj.push_back(Pair("receiver",coinaddr)); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk())) << OP_CHECKSIG); + obj.push_back(Pair("senderaddr",coinaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); obj.push_back(Pair("nextaddress",coinaddr)); if ( funcid == 'R' && createtxid == zeroid ) From 23093607b09f8ccf67cfbf1296da538b58023782 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:47:50 -1100 Subject: [PATCH 1071/3904] Test --- src/cc/marmara.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 48dc1f6ef..394d2d9d8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -537,9 +537,8 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("matures",refmatures)); result.push_back(Pair("currency",refcurrency)); result.push_back(Pair("senderpk",HexStr(senderpk))); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk())) << OP_CHECKSIG); - obj.push_back(Pair("senderaddr",coinaddr)); - + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk)) << OP_CHECKSIG); + result.push_back(Pair("senderaddr",coinaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); if ( strcmp(myCCaddr,coinaddr) == 0 ) @@ -556,7 +555,7 @@ UniValue MarmaraCreditloop(uint256 txid) str[0] = funcid, str[1] = 0; obj.push_back(Pair("funcid",str)); obj.push_back(Pair("senderpk",HexStr(senderpk))); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk())) << OP_CHECKSIG); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk)) << OP_CHECKSIG); obj.push_back(Pair("senderaddr",coinaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); obj.push_back(Pair("nextaddress",coinaddr)); From 76ff3a027510c9864887f371ca00d7a9d652ffb0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 01:56:17 -1100 Subject: [PATCH 1072/3904] Conditional recv/send pk --- src/cc/marmara.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 394d2d9d8..93f55799e 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -510,7 +510,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { @@ -522,7 +522,7 @@ UniValue MarmaraCreditloop(uint256 txid) GetCCaddress(cp,myCCaddr,Mypubkey()); result.push_back(Pair("myCCaddress",myCCaddr)); result.push_back(Pair("batontxid",batontxid.GetHex())); - if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,senderpk,refamount,refmatures,refcurrency)) != 0 ) + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) { str[0] = funcid, str[1] = 0; result.push_back(Pair("funcid",str)); @@ -536,9 +536,11 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("amount",ValueFromAmount(refamount))); result.push_back(Pair("matures",refmatures)); result.push_back(Pair("currency",refcurrency)); - result.push_back(Pair("senderpk",HexStr(senderpk))); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk)) << OP_CHECKSIG); - result.push_back(Pair("senderaddr",coinaddr)); + result.push_back(Pair("receiverpk",HexStr(pk))); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); + result.push_back(Pair("receiveraddr",coinaddr)); + GetCCaddress(cp,coinaddr,pk); + result.push_back(Pair("receiverCCaddr",coinaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); if ( strcmp(myCCaddr,coinaddr) == 0 ) @@ -548,19 +550,31 @@ UniValue MarmaraCreditloop(uint256 txid) { if ( GetTransaction(creditloop[i],tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { - if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) != 0 ) + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid",creditloop[i].GetHex())); str[0] = funcid, str[1] = 0; obj.push_back(Pair("funcid",str)); - obj.push_back(Pair("senderpk",HexStr(senderpk))); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(senderpk)) << OP_CHECKSIG); - obj.push_back(Pair("senderaddr",coinaddr)); + if ( funcid == 'R' && createtxid == zeroid ) + { + createtxid = creditloop[i]; + obj.push_back(Pair("senderpk",HexStr(pk))); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); + obj.push_back(Pair("senderaddr",coinaddr)); + GetCCaddress(cp,coinaddr,pk); + result.push_back(Pair("senderCCaddr",coinaddr)); + } + else + { + obj.push_back(Pair("receiverpk",HexStr(pk))); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); + obj.push_back(Pair("receiveraddr",coinaddr)); + GetCCaddress(cp,coinaddr,pk); + result.push_back(Pair("receiverCCaddr",coinaddr)); + } Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); obj.push_back(Pair("nextaddress",coinaddr)); - if ( funcid == 'R' && createtxid == zeroid ) - createtxid = creditloop[i]; if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { numerrs++; From a5f19e3399ecc232bf9494bcd98d3b64a1aedbe8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 02:01:28 -1100 Subject: [PATCH 1073/3904] Fix --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 93f55799e..7e054c369 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -563,7 +563,7 @@ UniValue MarmaraCreditloop(uint256 txid) Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); obj.push_back(Pair("senderaddr",coinaddr)); GetCCaddress(cp,coinaddr,pk); - result.push_back(Pair("senderCCaddr",coinaddr)); + obj.push_back(Pair("senderCCaddr",coinaddr)); } else { @@ -571,7 +571,7 @@ UniValue MarmaraCreditloop(uint256 txid) Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); obj.push_back(Pair("receiveraddr",coinaddr)); GetCCaddress(cp,coinaddr,pk); - result.push_back(Pair("receiverCCaddr",coinaddr)); + obj.push_back(Pair("receiverCCaddr",coinaddr)); } Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); obj.push_back(Pair("nextaddress",coinaddr)); From bad70de66a435485295afca0c2323e5e592a7de1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 02:02:23 -1100 Subject: [PATCH 1074/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 7e054c369..9097b618b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -574,7 +574,7 @@ UniValue MarmaraCreditloop(uint256 txid) obj.push_back(Pair("receiverCCaddr",coinaddr)); } Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); - obj.push_back(Pair("nextaddress",coinaddr)); + obj.push_back(Pair("nextCCaddress",coinaddr)); if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { numerrs++; From b41b4e3a4cc18a43c0a3a5b85d800b92eafe815a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 02:08:25 -1100 Subject: [PATCH 1075/3904] Test --- src/cc/marmara.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 9097b618b..941c25cb6 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -536,11 +536,11 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("amount",ValueFromAmount(refamount))); result.push_back(Pair("matures",refmatures)); result.push_back(Pair("currency",refcurrency)); - result.push_back(Pair("receiverpk",HexStr(pk))); + result.push_back(Pair("batonpk",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); - result.push_back(Pair("receiveraddr",coinaddr)); + result.push_back(Pair("batonaddr",coinaddr)); GetCCaddress(cp,coinaddr,pk); - result.push_back(Pair("receiverCCaddr",coinaddr)); + result.push_back(Pair("batonCCaddr",coinaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); result.push_back(Pair("batonaddress",coinaddr)); if ( strcmp(myCCaddr,coinaddr) == 0 ) @@ -559,11 +559,11 @@ UniValue MarmaraCreditloop(uint256 txid) if ( funcid == 'R' && createtxid == zeroid ) { createtxid = creditloop[i]; - obj.push_back(Pair("senderpk",HexStr(pk))); + obj.push_back(Pair("issuerpk",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); - obj.push_back(Pair("senderaddr",coinaddr)); + obj.push_back(Pair("issueraddr",coinaddr)); GetCCaddress(cp,coinaddr,pk); - obj.push_back(Pair("senderCCaddr",coinaddr)); + obj.push_back(Pair("issuerCCaddr",coinaddr)); } else { @@ -574,7 +574,7 @@ UniValue MarmaraCreditloop(uint256 txid) obj.push_back(Pair("receiverCCaddr",coinaddr)); } Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); - obj.push_back(Pair("nextCCaddress",coinaddr)); + obj.push_back(Pair("destCCaddress",coinaddr)); if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { numerrs++; From fba668fa077079b1928ee73d96d599d87686ef9f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 02:12:06 -1100 Subject: [PATCH 1076/3904] Test --- src/cc/marmara.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 941c25cb6..37ba74b5b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -510,7 +510,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { @@ -539,10 +539,14 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("batonpk",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); result.push_back(Pair("batonaddr",coinaddr)); - GetCCaddress(cp,coinaddr,pk); - result.push_back(Pair("batonCCaddr",coinaddr)); + GetCCaddress(cp,batonCCaddr,pk); + result.push_back(Pair("batonCCaddr",batonCCaddr)); Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); - result.push_back(Pair("batonaddress",coinaddr)); + if ( strcmp(coinaddr,batonCCaddr) != 0 ) + { + result.push_back(Pair("vout0address",coinaddr)); + numerrs++; + } if ( strcmp(myCCaddr,coinaddr) == 0 ) result.push_back(Pair("ismine",1)); else result.push_back(Pair("ismine",0)); @@ -573,8 +577,12 @@ UniValue MarmaraCreditloop(uint256 txid) GetCCaddress(cp,coinaddr,pk); obj.push_back(Pair("receiverCCaddr",coinaddr)); } - Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); - obj.push_back(Pair("destCCaddress",coinaddr)); + Getscriptaddress(destaddr,tx.vout[0].scriptPubKey); + if ( strcmp(destaddr,coinaddr) != 0 ) + { + obj.push_back(Pair("vout0address",destaddr)); + numerrs++; + } if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { numerrs++; From 4f194e605386633b3ced025198342d7f734b4972 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 02:14:52 -1100 Subject: [PATCH 1077/3904] Destaddr --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 37ba74b5b..1e16532d4 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -510,7 +510,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { From 6620e4cec288090746a3f2aa206bb25d54b36d96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:04:00 -1100 Subject: [PATCH 1078/3904] marmara_settlement skeleton --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 73 ++++++++++++++++++++++++++++------------ src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 15 +++++++++ 5 files changed, 70 insertions(+), 21 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 1d61a86d4..753f8edb6 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -28,6 +28,7 @@ uint64_t komodo_block_prg(uint32_t nHeight); int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid); UniValue MarmaraCreditloop(uint256 txid); +UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 1e16532d4..ff4d0dc32 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -479,34 +479,65 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a return(result); } -// get creditloop pubkeys - -/*UniValue Marmara(uint64_t txfee,uint256 batontxid) +UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid) { - UniValue result(UniValue::VOBJ); int64_t avail,amount,paid=0; int32_t i,n = 0; uint256 txid,*revcreditloop=0; CPubKey Marmarapk; struct CCcontract_info *cp,C; - result.push_back(Pair("result","success")); + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); - Marmarapk = GetUnspendable(cp,0); - txid = batontxid; - while ( txid.hasprev() != 0 ) + if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { - txid = txid.prev(); - // check for unique, else error - revcreditloop[n++] = txid; - } - for (i=0; i= amount ) + if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) { - change = (amount - paid); - break; + if ( (funcid= MarmaraDecodeLoopOpret(batontx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) + { + if ( refcreatetxid != creditloop[0] ) + { + fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); + refcreatetxid = creditloop[0]; + numerrs++; + } + GetCCaddress(cp,myCCaddr,Mypubkey()); + Getscriptaddress(batonCCaddr,batontx.vout[0].scriptPubKey); + if ( strcmp(myCCaddr,batonCCaddr) == 0 ) + { + for (i=0; i 1 ) + { + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) + { + GetCCaddress(cp,coinaddr,pk); + fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)CCaddress_balance(coinaddr)/COIN); + } + } + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"this node does not have the baton")); + result.push_back(Pair("myCCaddr",myCCaddr)); + result.push_back(Pair("batonCCaddr",batonCCaddr)); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get batontxid opret")); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt find batontxid")); } } - + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get creditloop")); + } return(result); -}*/ +} UniValue MarmaraCreditloop(uint256 txid) { diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index c8e2c4113..94403bcc0 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -449,6 +449,7 @@ static const CRPCCommand vRPCCommands[] = { "marmara", "marmaratransfer", &marmara_transfer, true }, { "marmara", "marmarainfo", &marmara_info, true }, { "marmara", "marmaracreditloop", &marmara_creditloop, true }, + { "marmara", "marmarasettlement", &marmara_settlement, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 1bc6bd582..920aac970 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -278,6 +278,7 @@ extern UniValue marmara_issue(const UniValue& params, bool fHelp); extern UniValue marmara_transfer(const UniValue& params, bool fHelp); extern UniValue marmara_info(const UniValue& params, bool fHelp); extern UniValue marmara_creditloop(const UniValue& params, bool fHelp); +extern UniValue marmara_settlement(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 81b692dc0..b9186f5c7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5668,6 +5668,21 @@ UniValue marmara_creditloop(const UniValue& params, bool fHelp) return(result); } +UniValue marmara_settlement(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); uint256 batontxid; + if ( fHelp || params.size() != 1 ) + { + // marmaracreditloop cc23bf81733556dc06db2fd9c9f4178cad44bdc237d6e62101cf0cdafb5195f7 + throw runtime_error("marmarasettlement batontxid\n"); + } + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + batontxid = Parseuint256((char *)params[0].get_str().c_str()); + result = MarmaraSettlement(batontxid); + return(result); +} + UniValue channelslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) From 422182a9d7c3525efb12e1b3ef1a8e93afabe892 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:05:14 -1100 Subject: [PATCH 1079/3904] Fix --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ff4d0dc32..959f2f68c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -483,7 +483,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); - if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) + if ( (n= MarmaraGetbatontxid(creditloop,batontxid,batontxid)) > 0 ) { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) { From b51a551dde03ba4df8580a0437a0d9ae667a0e0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:06:31 -1100 Subject: [PATCH 1080/3904] Refbatontxid --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 959f2f68c..07b8d5c5f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -479,11 +479,11 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a return(result); } -UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid) +UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); - if ( (n= MarmaraGetbatontxid(creditloop,batontxid,batontxid)) > 0 ) + if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 && batontxid == refbatontxid ) { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) { From e1e112fc248229e901480f553c7bedbc7467fdab Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:19:16 -1100 Subject: [PATCH 1081/3904] Set three --- src/cc/marmara.cpp | 2 ++ src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 07b8d5c5f..e644cbe36 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -482,6 +482,8 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; + if ( txfee == 0 ) + txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 && batontxid == refbatontxid ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b9186f5c7..02cb6afd3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5679,7 +5679,7 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); batontxid = Parseuint256((char *)params[0].get_str().c_str()); - result = MarmaraSettlement(batontxid); + result = MarmaraSettlement(0,batontxid); return(result); } From fa756027954860cd988a45a57f6f1df04121a024 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:24:30 -1100 Subject: [PATCH 1082/3904] Test --- src/cc/marmara.cpp | 4 ++-- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index e644cbe36..8f6350daa 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -509,8 +509,8 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { GetCCaddress(cp,coinaddr,pk); fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)CCaddress_balance(coinaddr)/COIN); - } - } + } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); + } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); } } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 02cb6afd3..63992bf4d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5673,7 +5673,7 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 batontxid; if ( fHelp || params.size() != 1 ) { - // marmaracreditloop cc23bf81733556dc06db2fd9c9f4178cad44bdc237d6e62101cf0cdafb5195f7 + // marmarasettlement cc23bf81733556dc06db2fd9c9f4178cad44bdc237d6e62101cf0cdafb5195f7 throw runtime_error("marmarasettlement batontxid\n"); } if ( ensure_CCrequirements() < 0 ) From f1971e0054885d83da5d56f117c511eafeb90288 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:26:59 -1100 Subject: [PATCH 1083/3904] Test --- src/cc/marmara.cpp | 2 +- src/wallet/rpcwallet.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8f6350daa..8386db2c5 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -485,7 +485,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); - if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 && batontxid == refbatontxid ) + if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 ) { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 63992bf4d..0dcaaa848 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5673,6 +5673,7 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 batontxid; if ( fHelp || params.size() != 1 ) { + // marmarasettlement 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be // marmarasettlement cc23bf81733556dc06db2fd9c9f4178cad44bdc237d6e62101cf0cdafb5195f7 throw runtime_error("marmarasettlement batontxid\n"); } From 6745e98d48baa6c6a547f289652f35bd13b0d964 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:30:37 -1100 Subject: [PATCH 1084/3904] GetCCaddress1of2 --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8386db2c5..d8e936839 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -507,7 +507,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { - GetCCaddress(cp,coinaddr,pk); + GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)CCaddress_balance(coinaddr)/COIN); } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); From 28d6643b3a4a409d2a847504c27d3fe8ca387533 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:32:23 -1100 Subject: [PATCH 1085/3904] -senderpk --- src/cc/marmara.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d8e936839..4eea7395d 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -481,10 +481,11 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey Marmarapk,pk; std::string currency,refcurrency; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); + Marmarapk = GetUnspendable(cp,0); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 ) { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) @@ -543,7 +544,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk,pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { From 7faabcef68d62f204b543ec0689d14dd9d0a6962 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:44:29 -1100 Subject: [PATCH 1086/3904] Mine to 1of2 CC addr --- src/cc/marmara.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 4eea7395d..39d8d01a7 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -175,9 +175,10 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { - CTxOut ccvout; + CTxOut ccvout; struct CCcontract_info *cp,C; CPubKey Marmarapk; + cp = CCinit(&C,EVAL_MARMARA); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) - ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); + ccvout = MakeCC1of2vout(EVAL_MARMARA,0,Marmarapk,pk); return(ccvout.scriptPubKey); } @@ -298,9 +299,10 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx,int32_t firstheight,CPubKey poolpk,int32_t maxinputs) { - char coinaddr[64]; CPubKey pk; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; + char coinaddr[64]; CPubKey Marmarapk,pk; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,poolpk); + Marmarapk = GetUnspendable(cp,0); + MakeCC1of2vout(cp,coinaddr,Marmarapk,poolpk); SetCCunspents(unspentOutputs,coinaddr); unlocks = MarmaraUnlockht(firstheight); //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); From 6206090faaef1f8e2e7c4a1e0c94e296ad44580b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:47:12 -1100 Subject: [PATCH 1087/3904] EVAL_MARMARA --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 39d8d01a7..587354ff2 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -302,7 +302,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, char coinaddr[64]; CPubKey Marmarapk,pk; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); - MakeCC1of2vout(cp,coinaddr,Marmarapk,poolpk); + MakeCC1of2vout(EVAL_MARMARA,coinaddr,Marmarapk,poolpk); SetCCunspents(unspentOutputs,coinaddr); unlocks = MarmaraUnlockht(firstheight); //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); From 6dc61c6bcf4f22ed3b2a74b8cb8135a27ee5609f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:49:21 -1100 Subject: [PATCH 1088/3904] GetCCaddress1of2 --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 587354ff2..8c2b5df0b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -302,7 +302,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, char coinaddr[64]; CPubKey Marmarapk,pk; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); - MakeCC1of2vout(EVAL_MARMARA,coinaddr,Marmarapk,poolpk); + GetCCaddress1of2(cp,coinaddr,Marmarapk,poolpk); SetCCunspents(unspentOutputs,coinaddr); unlocks = MarmaraUnlockht(firstheight); //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); From 3e2991000f29126325c05a7a48bcb1487b81a89f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:52:18 -1100 Subject: [PATCH 1089/3904] Fix --- src/cc/marmara.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8c2b5df0b..01ecaba83 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -195,6 +195,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); + Marmarapk = GetUnspendable(cp,0); if ( 0 ) { int32_t d,histo[365*2+30]; @@ -222,7 +223,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) if ( ht == height && MarmaraUnlockht(height) == unlockht ) { //fprintf(stderr,"ht.%d -> unlock.%d\n",ht,unlockht); - ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); + ccvout = MakeCC1of2vout(EVAL_MARMARA,0,Marmarapk,pk); if ( ccvout.scriptPubKey == tx.vout[0].scriptPubKey ) return(0); fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey\n",height); From f1046be9dcf72b532785977eba7f3c820271a437 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:53:16 -1100 Subject: [PATCH 1090/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 01ecaba83..3eab9e364 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -193,7 +193,7 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk) int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { - struct CCcontract_info *cp,C; CPubKey pk; int32_t ht,unlockht; CTxOut ccvout; + struct CCcontract_info *cp,C; CPubKey Marmarapk,pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); if ( 0 ) From 6e8e24cbc869cc62f099ea3e91b11e7b2a9cdcea Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 04:57:38 -1100 Subject: [PATCH 1091/3904] Init marmarapk --- src/cc/marmara.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 3eab9e364..39efecf2f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -177,6 +177,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { CTxOut ccvout; struct CCcontract_info *cp,C; CPubKey Marmarapk; cp = CCinit(&C,EVAL_MARMARA); + Marmarapk = GetUnspendable(cp,0); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) ccvout = MakeCC1of2vout(EVAL_MARMARA,0,Marmarapk,pk); return(ccvout.scriptPubKey); From 5e8d1a2d8734333b1ee732328f043d7c00fbb03f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:01:45 -1100 Subject: [PATCH 1092/3904] Test --- src/cc/marmara.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 39efecf2f..c0697a1ba 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -227,7 +227,10 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) ccvout = MakeCC1of2vout(EVAL_MARMARA,0,Marmarapk,pk); if ( ccvout.scriptPubKey == tx.vout[0].scriptPubKey ) return(0); - fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey\n",height); + char addr0[64],addr1[64]; + Getscriptaddress(addr0,ccvout.scriptPubKey); + Getscriptaddress(addr1,tx.vout[0].scriptPubKey); + fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey %s vs %s\n",height,addr0,addr1); } else fprintf(stderr,"ht.%d %d vs %d unlock.%d\n",height,MarmaraUnlockht(height),ht,unlockht); } else fprintf(stderr,"ht.%d error decoding coinbase opret\n",height); } From 32a6eb7ccecdbab87deb405563bce3f1c964fbe3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:04:43 -1100 Subject: [PATCH 1093/3904] Test --- src/cc/marmara.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index c0697a1ba..aa96ea20c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -179,7 +179,12 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) + { ccvout = MakeCC1of2vout(EVAL_MARMARA,0,Marmarapk,pk); + char coinaddr[64]; + Getscriptaddress(coinaddr,ccvout.scriptPubKey); + fprintf(stderr,"Marmara_scriptPubKey %s ht.%d -> %s\n",HexStr(pk),height,coinaddr); + } return(ccvout.scriptPubKey); } @@ -230,7 +235,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) char addr0[64],addr1[64]; Getscriptaddress(addr0,ccvout.scriptPubKey); Getscriptaddress(addr1,tx.vout[0].scriptPubKey); - fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey %s vs %s\n",height,addr0,addr1); + fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey %s vs %s pk %s\n",height,addr0,addr1,HexStr(pk)); } else fprintf(stderr,"ht.%d %d vs %d unlock.%d\n",height,MarmaraUnlockht(height),ht,unlockht); } else fprintf(stderr,"ht.%d error decoding coinbase opret\n",height); } From 503f753e7be090976bb993f09f02a68329634433 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:11:01 -1100 Subject: [PATCH 1094/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index aa96ea20c..6c6f824e7 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -235,7 +235,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) char addr0[64],addr1[64]; Getscriptaddress(addr0,ccvout.scriptPubKey); Getscriptaddress(addr1,tx.vout[0].scriptPubKey); - fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey %s vs %s pk %s\n",height,addr0,addr1,HexStr(pk)); + fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey %s vs %s pk.%d %s\n",height,addr0,addr1,(int32_t)pk.size(),HexStr(pk)); } else fprintf(stderr,"ht.%d %d vs %d unlock.%d\n",height,MarmaraUnlockht(height),ht,unlockht); } else fprintf(stderr,"ht.%d error decoding coinbase opret\n",height); } From 6617435e16d1dc4fdd02622375ae4768c0bb5134 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:12:15 -1100 Subject: [PATCH 1095/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 6c6f824e7..908f80b39 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -235,7 +235,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) char addr0[64],addr1[64]; Getscriptaddress(addr0,ccvout.scriptPubKey); Getscriptaddress(addr1,tx.vout[0].scriptPubKey); - fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey %s vs %s pk.%d %s\n",height,addr0,addr1,(int32_t)pk.size(),HexStr(pk)); + fprintf(stderr,"ht.%d mismatched CCvout scriptPubKey %s vs %s pk.%d %s\n",height,addr0,addr1,(int32_t)pk.size(),HexStr(pk).c_str()); } else fprintf(stderr,"ht.%d %d vs %d unlock.%d\n",height,MarmaraUnlockht(height),ht,unlockht); } else fprintf(stderr,"ht.%d error decoding coinbase opret\n",height); } From 3231c57262d45402f6c1f7fd3f773b92deebdb43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:13:57 -1100 Subject: [PATCH 1096/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 908f80b39..1afd97dc1 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -183,7 +183,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) ccvout = MakeCC1of2vout(EVAL_MARMARA,0,Marmarapk,pk); char coinaddr[64]; Getscriptaddress(coinaddr,ccvout.scriptPubKey); - fprintf(stderr,"Marmara_scriptPubKey %s ht.%d -> %s\n",HexStr(pk),height,coinaddr); + fprintf(stderr,"Marmara_scriptPubKey %s ht.%d -> %s\n",HexStr(pk).c_str(),height,coinaddr); } return(ccvout.scriptPubKey); } From 72e7bc73b82cdcb5dda6c6dc8b6f082129cc5079 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:20:20 -1100 Subject: [PATCH 1097/3904] Test --- src/miner.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index a44eb380c..ba2ceefb8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -545,6 +545,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // to transaction if so, cast for GTE operator if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) { + char checkaddr[64]; + Getscriptaddress(checkaddr,txNew.vout[0].scriptPubKey); + fprintf(stderr,"set mining coinbase -> %s\n",checkaddr); txNew.vout.resize(2); txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); From 97f40221f9334c930fda4882743042140de8b391 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:21:09 -1100 Subject: [PATCH 1098/3904] Test --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index ba2ceefb8..c6309d35e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -158,6 +158,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { From 1d946f881205172886ad209abc8317fdcc6c6c33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:30:48 -1100 Subject: [PATCH 1099/3904] Test --- src/cc/marmara.cpp | 6 +++--- src/miner.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 1afd97dc1..ce17c0bcb 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -181,9 +181,9 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) { ccvout = MakeCC1of2vout(EVAL_MARMARA,0,Marmarapk,pk); - char coinaddr[64]; - Getscriptaddress(coinaddr,ccvout.scriptPubKey); - fprintf(stderr,"Marmara_scriptPubKey %s ht.%d -> %s\n",HexStr(pk).c_str(),height,coinaddr); + //char coinaddr[64]; + //Getscriptaddress(coinaddr,ccvout.scriptPubKey); + //fprintf(stderr,"Marmara_scriptPubKey %s ht.%d -> %s\n",HexStr(pk).c_str(),height,coinaddr); } return(ccvout.scriptPubKey); } diff --git a/src/miner.cpp b/src/miner.cpp index c6309d35e..782716fcf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -548,7 +548,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { char checkaddr[64]; Getscriptaddress(checkaddr,txNew.vout[0].scriptPubKey); - fprintf(stderr,"set mining coinbase -> %s\n",checkaddr); + //`fprintf(stderr,"set mining coinbase -> %s\n",checkaddr); txNew.vout.resize(2); txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); From 2dc911558b0a9aa31b0e00356b799330f85261e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 05:40:47 -1100 Subject: [PATCH 1100/3904] -print --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ebc50fa62..fc302c545 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2176,7 +2176,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { - fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); + //fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); continue; } eligible = besttime; From c8af7b80f79b230f0ccaa9a6ac44effe87834ab5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 06:03:51 -1100 Subject: [PATCH 1101/3904] -print --- src/cc/marmara.cpp | 1 + src/miner.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ce17c0bcb..5c61ebeef 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -521,6 +521,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); + make tx here fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)CCaddress_balance(coinaddr)/COIN); } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); diff --git a/src/miner.cpp b/src/miner.cpp index 782716fcf..cbc033d47 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1609,7 +1609,7 @@ void static BitcoinMiner() int32_t percPoS,z; bool fNegative,fOverflow; HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - if ( ASSETCHAINS_STAKED < 100 ) + if ( ASSETCHAINS_STAKED < 100 && KOMODO_MININGTHREADS == 0 ) { for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); From 3d8083fb4d4a5de9b116fa9e37d0e7e0dabe853e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 06:05:05 -1100 Subject: [PATCH 1102/3904] -print --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5c61ebeef..6a9c78472 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -521,7 +521,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); - make tx here + //make tx here fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)CCaddress_balance(coinaddr)/COIN); } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); From 3dcde0ccf1d8d9cab1b0ecfcc26d18f070bcffe1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 06:07:36 -1100 Subject: [PATCH 1103/3904] +ht --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index cbc033d47..3a163c637 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1613,7 +1613,7 @@ void static BitcoinMiner() { for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); - fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED); + fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%% ht.%d\n",percPoS,(int32_t)ASSETCHAINS_STAKED,Mining_height); } } while (true) From 060986987449d2beca241a4fc14d7978a26251db Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 20:26:02 -1100 Subject: [PATCH 1104/3904] Ise fixes --- src/cc/CCtx.cpp | 2 +- src/komodo.h | 5 +++++ src/komodo_gateway.h | 2 +- src/komodo_jumblr.h | 10 +++++----- src/main.cpp | 2 ++ src/wallet/rpcwallet.cpp | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index a80b3b3cf..546c4cb6b 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -384,8 +384,8 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 { int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=64; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; #ifdef ENABLE_WALLET - const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); + const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos)); diff --git a/src/komodo.h b/src/komodo.h index 4c97a8171..7d2b17963 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -799,6 +799,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; + if ( pindex == 0 ) + { + fprintf(stderr,"komodo_connectblock null pindex\n"); + return; + } memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); KOMODO_INITDONE = (uint32_t)time(NULL); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e19d94915..02ab67407 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1388,7 +1388,7 @@ void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter,lastinterest; int32_t maxseconds = 10; - FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //CBlockIndex *pindex; + FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex; expired = 0; while ( KOMODO_INITDONE == 0 ) { diff --git a/src/komodo_jumblr.h b/src/komodo_jumblr.h index 5a5ad0885..fca7395e5 100755 --- a/src/komodo_jumblr.h +++ b/src/komodo_jumblr.h @@ -629,7 +629,7 @@ uint64_t jumblr_increment(uint8_t r,int32_t height,uint64_t total,uint64_t bigge void jumblr_iteration() { static int32_t lastheight; static uint32_t lasttime; - char *zaddr,*addr,*retstr,secretaddr[64]; cJSON *array; int32_t i,iter,height,acpublic,counter,chosen_one,n; uint64_t smallest,medium,biggest,amount=0,total=0; double fee; struct jumblr_item *ptr,*tmp; uint16_t r,s; + char *zaddr,*addr,*retstr=0,secretaddr[64]; cJSON *array; int32_t i,iter,height,acpublic,counter,chosen_one,n; uint64_t smallest,medium,biggest,amount=0,total=0; double fee; struct jumblr_item *ptr,*tmp; uint16_t r,s; acpublic = ASSETCHAINS_PUBLIC; if ( ASSETCHAINS_SYMBOL[0] == 0 && GetTime() >= KOMODO_SAPLING_DEADLINE ) acpublic = 1; @@ -648,7 +648,7 @@ void jumblr_iteration() } free_json(array); } - free(retstr); + free(retstr), retstr = 0; } } height = (int32_t)chainActive.LastTip()->GetHeight(); @@ -691,7 +691,7 @@ void jumblr_iteration() if ( amount > 0 && (retstr= jumblr_sendt_to_z(Jumblr_deposit,addr,dstr(amount))) != 0 ) { printf("sendt_to_z.(%s)\n",retstr); - free(retstr); + free(retstr), retstr = 0; } free(zaddr); } else printf("no zaddr from jumblr_zgetnewaddress\n"); @@ -723,7 +723,7 @@ void jumblr_iteration() if ( (retstr= jumblr_sendz_to_z(ptr->dest,addr,dstr(total))) != 0 ) { printf("n.%d counter.%d chosen_one.%d send z_to_z.(%s)\n",n,counter,chosen_one,retstr); - free(retstr); + free(retstr), retstr = 0; } ptr->spent = (uint32_t)time(NULL); free(zaddr); @@ -768,7 +768,7 @@ void jumblr_iteration() if ( (retstr= jumblr_sendz_to_t(ptr->dest,secretaddr,dstr(total))) != 0 ) { printf("%s send z_to_t.(%s)\n",secretaddr,retstr); - free(retstr); + free(retstr), retstr = 0; } else printf("null return from jumblr_sendz_to_t\n"); ptr->spent = (uint32_t)time(NULL); break; diff --git a/src/main.cpp b/src/main.cpp index 929ec9d5e..21b6b4eb0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3497,6 +3497,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CDiskBlockPos pos; if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40)) return error("ConnectBlock(): FindUndoPos failed"); + if ( pindex->pprev == 0 ) + fprintf(stderr,"ConnectBlock: unexpected null pprev\n"); if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart())) return AbortNode(state, "Failed to write undo data"); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0dcaaa848..5d15381c6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5094,8 +5094,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) if (!EnsureWalletIsAvailable(0)) return 0; - const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); + const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); utxovalue = 0; memset(&utxotxid,0,sizeof(utxotxid)); From 88e77b78515358e297f58be35567b801d250c527 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 20:56:41 -1100 Subject: [PATCH 1105/3904] Allow null batontxid for issue --- src/cc/marmara.cpp | 2 -- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 6a9c78472..94608e1a4 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -443,8 +443,6 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a mypk = pubkey2pk(Mypubkey()); if ( MarmaraGetcreatetxid(createtxid,approvaltxid) < 0 ) errorstr = (char *)"cant get createtxid from approvaltxid"; - else if ( batontxid == zeroid ) - errorstr = (char *)"null batontxid"; else if ( currency != "MARMARA" ) errorstr = (char *)"for now, only MARMARA loops are supported"; else if ( amount < txfee ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5d15381c6..2ce2435a7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5581,7 +5581,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 approvaltxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || params.size() != 5 ) { - // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3903 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1168 32da4cb3e886ee42de90b4a15042d71169077306badf909099c5c5c692df3f27 throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) From 8ef46649e55ecf00b4d04c5a828dfcc3498be0a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 21:02:23 -1100 Subject: [PATCH 1106/3904] Fix --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 94608e1a4..d37314e9e 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -669,6 +669,8 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; char coinaddr[64]; CPubKey Marmarapk; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_MARMARA); + Marmarapk = GetUnspendable(cp,0); result.push_back(Pair("result","success")); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); result.push_back(Pair("myaddress",coinaddr)); @@ -687,8 +689,6 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ result.push_back(Pair("minamount",ValueFromAmount(minamount))); result.push_back(Pair("maxamount",ValueFromAmount(maxamount))); result.push_back(Pair("currency",currency)); - cp = CCinit(&C,EVAL_MARMARA); - Marmarapk = GetUnspendable(cp,0); if ( (n= MarmaraGetCreditloops(totalamount,issuances,cp,firstheight,lastheight,minamount,maxamount,refpk,currency)) > 0 ) { result.push_back(Pair("n",n)); From e1037c704cef7aa5b8958ad38dbe851013dc80ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 23:22:00 -1100 Subject: [PATCH 1107/3904] Prepare to create settlement tx --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 176 +++++++++++++++++++++++++-------------- src/komodo_bitcoind.h | 65 ++++++++++----- src/wallet/rpcwallet.cpp | 6 +- 4 files changed, 158 insertions(+), 90 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 753f8edb6..d008095f7 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -24,6 +24,7 @@ #define MARMARA_MINLOCK (1440 * 3 * 30) #define MARMARA_MAXLOCK (1440 * 24 * 30) +extern uint8_t ASSETCHAINS_MARMARA; uint64_t komodo_block_prg(uint32_t nHeight); int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d37314e9e..c82a28f4c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -245,6 +245,8 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { std::vector vopret; CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid,*script; CPubKey pk,vpk; + if ( ASSETCHAINS_MARMARA == 0 ) + return eval->Invalid("-ac_marmara must be set for marmara CC"); numvins = tx.vin.size(); numvouts = tx.vout.size(); if ( numvouts < 1 ) @@ -344,6 +346,116 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, return(totalinputs); } +UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,change,avail; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; + if ( txfee == 0 ) + txfee = 10000; + cp = CCinit(&C,EVAL_MARMARA); + mypk = pubkey2pk(Mypubkey()); + Marmarapk = GetUnspendable(cp,0); + remaining = change = 0; + if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 ) + { + if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) + { + if ( (funcid= MarmaraDecodeLoopOpret(batontx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) + { + if ( refcreatetxid != creditloop[0] ) + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"invalid refcreatetxid, setting to creditloop[0]")); + return(result); + } + if ( chainActive.LastTip()->GetHeight() < refmatures ) + { + fprintf(stderr,"doesnt mature for another %d blocks\n",refmatures - chainActive.LastTip()->GetHeight())' + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"cant settle immature creditloop")); + return(result); + } + remaining = refamount; + GetCCaddress(cp,myCCaddr,Mypubkey()); + Getscriptaddress(batonCCaddr,batontx.vout[0].scriptPubKey); + if ( strcmp(myCCaddr,batonCCaddr) == 0 ) + { + mtx.vin.push_back(CTxIn(batontxid,0,CScript())); + for (i=0; i 1 ) + { + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) + { + GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); + avail = CCaddress_balance(coinaddr); + if ( avail > remaining ) + { + // add remaining + change = (avail - remaining); + mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + if ( change > txfee ) + mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency)); + result.push_back(Pair("result",(char *)"success")); + result.push_back(Pair("rawtx",rawtx)); + return(result); + } + else if ( avail > txfee ) + { + // add all utxos + remaining -= avail; + } + fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)avail/COIN); + } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); + } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); + } + if ( amount - remaining > 2*txfee ) + { + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker + if ( amount-remaining > 3*txfee ) + mtx.vout.push_back(CTxOut(amount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount-remaining,-remaining,currency)); + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"insufficient funds")); + result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("remaining",ValueFromAmount(remaining))); + } + else + { + // jl777: maybe fund a txfee to report no funds avail + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"no funds available at all")); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"this node does not have the baton")); + result.push_back(Pair("myCCaddr",myCCaddr)); + result.push_back(Pair("batonCCaddr",batonCCaddr)); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get batontxid opret")); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt find batontxid")); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get creditloop")); + } + return(result); +} + int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,struct CCcontract_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) { char coinaddr[64]; CPubKey Marmarapk,senderpk; int64_t amount; uint256 createtxid,txid,hashBlock; CTransaction tx; int32_t numvouts,vout,matures,n=0; std::string currency; @@ -489,70 +601,6 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a return(result); } -UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) -{ - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey Marmarapk,pk; std::string currency,refcurrency; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; - if ( txfee == 0 ) - txfee = 10000; - cp = CCinit(&C,EVAL_MARMARA); - Marmarapk = GetUnspendable(cp,0); - if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 ) - { - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) - { - if ( (funcid= MarmaraDecodeLoopOpret(batontx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) - { - if ( refcreatetxid != creditloop[0] ) - { - fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); - refcreatetxid = creditloop[0]; - numerrs++; - } - GetCCaddress(cp,myCCaddr,Mypubkey()); - Getscriptaddress(batonCCaddr,batontx.vout[0].scriptPubKey); - if ( strcmp(myCCaddr,batonCCaddr) == 0 ) - { - for (i=0; i 1 ) - { - if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) - { - GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); - //make tx here - fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)CCaddress_balance(coinaddr)/COIN); - } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); - } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); - } - } - else - { - result.push_back(Pair("result",(char *)"error")); - result.push_back(Pair("error",(char *)"this node does not have the baton")); - result.push_back(Pair("myCCaddr",myCCaddr)); - result.push_back(Pair("batonCCaddr",batonCCaddr)); - } - } - else - { - result.push_back(Pair("result",(char *)"error")); - result.push_back(Pair("error",(char *)"couldnt get batontxid opret")); - } - } - else - { - result.push_back(Pair("result",(char *)"error")); - result.push_back(Pair("error",(char *)"couldnt find batontxid")); - } - } - else - { - result.push_back(Pair("result",(char *)"error")); - result.push_back(Pair("error",(char *)"couldnt get creditloop")); - } - return(result); -} - UniValue MarmaraCreditloop(uint256 txid) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fc302c545..19a5f8103 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -643,6 +643,10 @@ int32_t komodo_isPoS(CBlock *pblock) { txid = pblock->vtx[n-1].vin[0].prevout.hash; vout = pblock->vtx[n-1].vin[0].prevout.n; + if ( ASSETCHAINS_MARMARA != 0 ) + { + // need to verify it was signed by the non-Marmarapk of the 1of2 + } txtime = komodo_txtime(&value,txid,vout,destaddr); if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) { @@ -2112,34 +2116,42 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt maxkp = numkp = 0; lasttime = 0; } - BOOST_FOREACH(const COutput& out, vecOutputs) + if ( ASSETCHAINS_MARMARA == 0 || 1 ) { - if ( (tipindex= chainActive.Tip()) == 0 || tipindex->GetHeight()+1 > nHeight ) + BOOST_FOREACH(const COutput& out, vecOutputs) { - fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); - return(0); - } - counter++; - if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) - { - fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); - continue; - } - CAmount nValue = out.tx->vout[out.i].nValue; - if ( nValue < COIN || !out.fSpendable ) - continue; - const CScript& pk = out.tx->vout[out.i].scriptPubKey; - if ( ExtractDestination(pk,address) != 0 ) - { - if ( IsMine(*pwalletMain,address) == 0 ) - continue; - if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) + if ( (tipindex= chainActive.Tip()) == 0 || tipindex->GetHeight()+1 > nHeight ) { - array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); - //fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); + fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); + return(0); + } + counter++; + if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) + { + fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + continue; + } + CAmount nValue = out.tx->vout[out.i].nValue; + if ( nValue < COIN || !out.fSpendable ) + continue; + const CScript& pk = out.tx->vout[out.i].scriptPubKey; + if ( ExtractDestination(pk,address) != 0 ) + { + if ( IsMine(*pwalletMain,address) == 0 ) + continue; + if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) + { + array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); + //fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); + } } } } + else + { + // calc 1of2 address + // iterate all unspents not spent in mempool and komodo_addutxo + } lasttime = (uint32_t)time(NULL); //fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } @@ -2218,7 +2230,14 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt txNew.vout[0].nValue = *utxovaluep - txfee; txNew.nLockTime = earliest; CTransaction txNewConst(txNew); - signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); + if ( ASSETCHAINS_MARMARA == 0 || 1 ) + { + signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); + } + else + { + // signSuccess = CCFinalizetx(...) + } if (!signSuccess) fprintf(stderr,"failed to create signature\n"); else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2ce2435a7..877342306 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5554,7 +5554,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) if ( fHelp || (params.size() != 5 && params.size() != 4) ) { // 1st marmarareceive 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1440 - // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 3903 bf6b4d42aa3ce974c853d73b06c78597dd3b5fb493d5d0d944f72c2017f561ad + // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1168 d72d87aa0d50436de695c93e2bf3d7273c63c92ef6307913aa01a6ee6a16548b throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5604,7 +5604,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 approvaltxid,batontxid; std::vector receiverpub; int64_t amount; int32_t matures; std::string currency; std::vector creditloop; if ( fHelp || params.size() != 5 ) { - // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e + // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1168 1506c774e4b2804a6e25260920840f4cfca8d1fb400e69fe6b74b8e593dbedc5 throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) @@ -5674,7 +5674,7 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) { // marmarasettlement 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be - // marmarasettlement cc23bf81733556dc06db2fd9c9f4178cad44bdc237d6e62101cf0cdafb5195f7 + // marmarasettlement ff3e259869196f3da9b5ea3f9e088a76c4fc063cf36ab586b652e121d441a603 throw runtime_error("marmarasettlement batontxid\n"); } if ( ensure_CCrequirements() < 0 ) From af6dae789e93c63272afd56f9bf8417dfeac504f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Jan 2019 23:23:10 -1100 Subject: [PATCH 1108/3904] syntax --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index c82a28f4c..9e921df6b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -349,7 +349,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,change,avail; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,change,avail; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; struct CCcontract_info *cp,C; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); @@ -370,7 +370,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) } if ( chainActive.LastTip()->GetHeight() < refmatures ) { - fprintf(stderr,"doesnt mature for another %d blocks\n",refmatures - chainActive.LastTip()->GetHeight())' + fprintf(stderr,"doesnt mature for another %d blocks\n",refmatures - chainActive.LastTip()->GetHeight()); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"cant settle immature creditloop")); return(result); From 400a0758c1cd785bcedc5864794084045849cf58 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 16 Jan 2019 20:27:35 +0800 Subject: [PATCH 1109/3904] Many bug fixes. VerusHash now works with PoS64 without special exemptions. Difficulty on new chains still behaves weridly, hoping resolves as chain ages. Also reduced CPU load on all staking. These changes should work better if you are not the only node staking. --- src/komodo_bitcoind.h | 29 ++++++++++++++++------------- src/komodo_globals.h | 4 +++- src/komodo_utils.h | 5 +++-- src/miner.cpp | 41 ++++++++++++++++++++++++++--------------- 4 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bb85ef1d1..662d0703c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1274,7 +1274,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( value < SATOSHIDEN ) return(0); value /= SATOSHIDEN; - mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; @@ -1342,11 +1342,12 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); + sum = arith_uint256(0); ave = sum; - easydiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + easydiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); for (i=n=m=0; i<100; i++) { ht = height - 100 + i; @@ -1372,8 +1373,10 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } + // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! + // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) - percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + percPoS = (percPoS*100) / (m+n); if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; @@ -1432,7 +1435,8 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); } } - else bnTarget = ave; // recent ave is perfect + else + bnTarget = ave; // recent ave is perfect return(bnTarget); } @@ -1468,7 +1472,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr,"komodo_is_PoSblock PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)pblock->nTime,(int32_t)(eligible - pblock->nTime)); - if ( slowflag != 0 && pindex != 0 && height > 100) + if ( slowflag != 0 && pindex != 0 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); @@ -1477,7 +1481,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else { isPoS = 2; // 2 means staking utxo validated - if ( slowflag != 0 && height > 100 ) + if ( slowflag != 0 ) { CTxDestination voutaddress; char voutaddr[64]; if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) @@ -1831,12 +1835,11 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } else { - // I think this means the block is valid PoW. We need to set the pindex->segid here. failed = 0; CBlockIndex *pindex; BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; - if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { + if ( pindex != 0 && pindex->segid == -2 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } @@ -2083,7 +2086,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt return 0; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); - mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); assert(pwalletMain != NULL); *utxovaluep = 0; @@ -2096,7 +2099,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; komodo_segids(hashbuf,nHeight-101,100); - if ( *blocktimep < tipindex->nTime+60 ) + if ( *blocktimep < tipindex->nTime+60) *blocktimep = tipindex->nTime+60; //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); @@ -2155,7 +2158,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt //fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } //fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); - block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; + block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; inTime+27,minage,hashbuf)) == 0 ) continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); -//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); + //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index ef7af0ba2..f2f6ed6b4 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -53,7 +53,7 @@ bool VERUS_MINTBLOCKS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_BEAMPORT,ASSETCHAINS_CODAPORT; -uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; +uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1,STAKING_MIN_DIFF; uint32_t ASSETCHAINS_MAGIC = 2387029918; int64_t ASSETCHAINS_GENESISTXVAL = 5000000000; @@ -80,6 +80,8 @@ uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff}; uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; +// min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375}; // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0ac40a48b..74e82f1e2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1684,13 +1684,13 @@ void komodo_args(char *argv0) IS_KOMODO_NOTARY = 1; KOMODO_MININGTHREADS = 1; mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - IS_STAKED_NOTARY = -1; + IS_STAKED_NOTARY = -1; fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); break; } } } - name = GetArg("-ac_name",""); + name = GetArg("-ac_name",""); if ( argv0 != 0 ) { len = (int32_t)strlen(argv0); @@ -1726,6 +1726,7 @@ void komodo_args(char *argv0) if (std::string(ASSETCHAINS_ALGORITHMS[i]) == selectedAlgo) { ASSETCHAINS_ALGO = i; + STAKING_MIN_DIFF = ASSETCHAINS_MINDIFF[i]; // only worth mentioning if it's not equihash if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) printf("ASSETCHAINS_ALGO, algorithm set to %s\n", selectedAlgo.c_str()); diff --git a/src/miner.cpp b/src/miner.cpp index e06a570c7..e90b22a5a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -531,6 +531,19 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); + // if you skip this check it will create a block too far into the future and not pass ProcessBlock or AcceptBlock. + // This has been moved from the mining loop to save CPU, and to also make ac_staked work with the verus miner. + while ( blocktime-57 > GetAdjustedTime() ) + { + sleep(1); + if ( (rand() % 100) < 1 ) + fprintf(stderr, "%u seconds until elegible, waiting.\n", blocktime-((uint32_t)GetAdjustedTime()+57)); + if ( chainActive.LastTip()->GetHeight() >= stakeHeight ) + { + fprintf(stderr, "Block Arrived, reset staking loop.\n"); + return(0); + } + } } if ( siglen > 0 ) @@ -546,7 +559,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); - + } // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); @@ -838,7 +851,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey); if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) isStake = true; - return CreateNewBlock(pubkey,scriptPubKey, gpucount, isStake); + return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); } void komodo_broadcast(CBlock *pblock,int32_t limit) @@ -1241,7 +1254,7 @@ void static BitcoinMiner_noeq() if ( ptr == 0 ) { static uint32_t counter; - if ( counter++ < 10 ) + if ( ASSETCHAINS_STAKED == 0 && counter++ < 10 ) fprintf(stderr,"created illegal block, retry\n"); continue; } @@ -1301,10 +1314,12 @@ void static BitcoinMiner_noeq() if ( ASSETCHAINS_STAKED != 0 ) { - int32_t percPoS,z; - hashTarget = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); + int32_t percPoS,z; bool fNegative,fOverflow; + HASHTarget_POW = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); + // We use equihash min diff here to make the verus miner instantly finds a blockhash, this saves CPU when staking. + HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); if ( ASSETCHAINS_STAKED < 100 ) - LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); + LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); } while (true) @@ -1319,6 +1334,9 @@ void static BitcoinMiner_noeq() vh.ClearExtra(); int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; + if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 ) + hashTarget = HASHTarget_POW; + else hashTarget = HASHTarget; // for speed check NONCEMASK at a time for (i = 0; i < count; i++) @@ -1414,7 +1432,6 @@ void static BitcoinMiner_noeq() printf("%lu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576); #endif break; - } } } @@ -1724,12 +1741,6 @@ void static BitcoinMiner() } else { - while ( B.nTime-57 > GetAdjustedTime() ) - { - sleep(1); - if ( chainActive.LastTip()->GetHeight() >= Mining_height ) - return(false); - } uint256 tmp = B.GetHash(); int32_t z; for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&tmp)[z]); @@ -1938,12 +1949,12 @@ void static BitcoinMiner() for (int i = 0; i < nThreads; i++) { #ifdef ENABLE_WALLET - if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH || (ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0) ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet)); else minerThreads->create_thread(boost::bind(&BitcoinMiner_noeq, pwallet)); #else - if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH || (ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0) ) + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) minerThreads->create_thread(&BitcoinMiner); else minerThreads->create_thread(&BitcoinMiner_noeq); From a4f197794fb89e670714516b130c0ae0acfe0e0a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 16 Jan 2019 21:16:30 +0800 Subject: [PATCH 1110/3904] Many bug fixes. VerusHash now works with PoS64 without special exemptions. Difficulty on new chains still behaves weridly, hoping resolves as chain ages. Also reduced CPU load on all staking. These changes should work better if you are not the only node staking. --- src/komodo_bitcoind.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 662d0703c..0fea33ee5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1342,6 +1342,12 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; + static bool new_rules, didinit; + if ( !didinit ) { + new_rules = is_STAKED(ASSETCHAINS_SYMBOL) != 0 && is_STAKED(ASSETCHAINS_SYMBOL) != 3 ? true : false; + didinit = true; + } + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); @@ -1353,6 +1359,9 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he ht = height - 100 + i; if ( ht <= 1 ) continue; + // never count the first 10 blocks, they are always PoW! Cant do this for old chains, so limit to LABS and LAB for now. + if ( new_rules && ht < 10 ) + continue; if ( (pindex= komodo_chainactive(ht)) != 0 ) { if ( komodo_segid(0,ht) >= 0 ) @@ -1376,7 +1385,12 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) - percPoS = (percPoS*100) / (m+n); + { + if ( new_rules) + percPoS = (percPoS*100) / (m+n); + else + percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + } if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; From d072863d6f047b99354d05e583cd85f005e54dc3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 17 Jan 2019 00:06:00 +0800 Subject: [PATCH 1111/3904] fix 100% chains. --- src/komodo_bitcoind.h | 2 +- src/miner.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0fea33ee5..1ffc68c62 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1457,7 +1457,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_uint256 bnTarget,arith_uint256 bhash) { CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; - if ( ASSETCHAINS_STAKED == 100 && height <= 10 ) + if ( ASSETCHAINS_STAKED == 100 && height <= 100 ) return(1); BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; diff --git a/src/miner.cpp b/src/miner.cpp index e90b22a5a..98bfa55a1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -132,7 +132,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" extern CCriticalSection cs_metrics; -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; @@ -1316,10 +1316,8 @@ void static BitcoinMiner_noeq() { int32_t percPoS,z; bool fNegative,fOverflow; HASHTarget_POW = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); - // We use equihash min diff here to make the verus miner instantly finds a blockhash, this saves CPU when staking. - HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - if ( ASSETCHAINS_STAKED < 100 ) - LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); + HASHTarget.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); + LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); } while (true) @@ -1334,7 +1332,7 @@ void static BitcoinMiner_noeq() vh.ClearExtra(); int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; - if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 ) + if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; else hashTarget = HASHTarget; From 024a9fd81e589daa708850afd12f99709fbb83d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:23:26 -1100 Subject: [PATCH 1112/3904] implemented marmarasettlement --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 55 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index d008095f7..6c81ed689 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -23,6 +23,7 @@ #define MARMARA_GROUPSIZE 60 #define MARMARA_MINLOCK (1440 * 3 * 30) #define MARMARA_MAXLOCK (1440 * 24 * 30) +#define MARMARA_VINS 16 extern uint8_t ASSETCHAINS_MARMARA; uint64_t komodo_block_prg(uint32_t nHeight); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 9e921df6b..ca11f276e 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -82,13 +82,13 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32 } if ( vopret.size() > 2 && script[0] == EVAL_MARMARA ) { - if ( script[1] == 'C' || script[1] == 'P' ) + if ( script[1] == 'C' || script[1] == 'P' || script[1] == 'L' ) { if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> height; ss >> unlockht) != 0 ) { return(script[1]); } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for %c\n",script[1]); - } else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d\n",script[1],'C','P'); + } else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d or 'L' %d\n",script[1],'C','P','L'); } else fprintf(stderr,"vopret.size() is %d\n",(int32_t)vopret.size()); return(0); } @@ -346,10 +346,39 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, return(totalinputs); } +int64_t AddMarmarainputs(CMutableTransaction &mtx,char *coinaddr,int64_t total,int32_t maxinputs) +{ + uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,vout,n = 0; uint8_t funcid; + std::vector > unspentOutputs; + SetCCunspents(unspentOutputs,coinaddr); + threshold = total/(maxinputs+1); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if ( it->second.satoshis < threshold ) + continue; + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht) == 'C' || funcid == 'P' || funcid == 'L' ) + { + char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f ht.%d unlockht.%d\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,ht,unlockht); + if ( total != 0 && maxinputs != 0 ) + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + totalinputs += it->second.satoshis; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) + break; + } else fprintf(stderr,"null funcid\n"); + } + } + return(totalinputs); +} + UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,change,avail; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; struct CCcontract_info *cp,C; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); @@ -388,25 +417,19 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); - avail = CCaddress_balance(coinaddr); - if ( avail > remaining ) + if ( (inputsum= AddMarmarainputs(mtx,coinaddr,remaining,MARMARA_VINS)) >= remaining ) { - // add remaining - change = (avail - remaining); + change = (inputsum - remaining); mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency)); + rawtx = FinalizeCCTx(0,cp,mtx,Marmarapk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency)); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); - } - else if ( avail > txfee ) - { - // add all utxos - remaining -= avail; - } - fprintf(stderr,"get locked funds of %s %.8f\n",coinaddr,(double)avail/COIN); + } else remaining -= inputsum; + if ( mtx.vin.size() >= CC_MAXVINS - MARMARA_VINS ) + break; } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); } @@ -415,7 +438,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker if ( amount-remaining > 3*txfee ) mtx.vout.push_back(CTxOut(amount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount-remaining,-remaining,currency)); + rawtx = FinalizeCCTx(0,cp,mtx,Marmarapk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount-remaining,-remaining,currency)); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); result.push_back(Pair("rawtx",rawtx)); From 62d50529edbba03c7af0234927d73fd6c2baef99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:24:53 -1100 Subject: [PATCH 1113/3904] Fix --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ca11f276e..81ae9cb29 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -348,7 +348,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, int64_t AddMarmarainputs(CMutableTransaction &mtx,char *coinaddr,int64_t total,int32_t maxinputs) { - uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,vout,n = 0; uint8_t funcid; + uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,vout,n = 0; uint8_t funcid; CPubKey pk; std::vector > unspentOutputs; SetCCunspents(unspentOutputs,coinaddr); threshold = total/(maxinputs+1); @@ -360,7 +360,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,char *coinaddr,int64_t total,i continue; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { - if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht) == 'C' || funcid == 'P' || funcid == 'L' ) + if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) { char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f ht.%d unlockht.%d\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,ht,unlockht); if ( total != 0 && maxinputs != 0 ) From c9b9d1f26f4beaa63477f176e873b1972581674b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:25:42 -1100 Subject: [PATCH 1114/3904] Unlockht --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 81ae9cb29..883e8f08c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -348,7 +348,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, int64_t AddMarmarainputs(CMutableTransaction &mtx,char *coinaddr,int64_t total,int32_t maxinputs) { - uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,vout,n = 0; uint8_t funcid; CPubKey pk; + uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,n = 0; uint8_t funcid; CPubKey pk; std::vector > unspentOutputs; SetCCunspents(unspentOutputs,coinaddr); threshold = total/(maxinputs+1); From a47537398fc07d60391790ac3989ab4f039a27b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:29:43 -1100 Subject: [PATCH 1115/3904] Sign with mypk --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 883e8f08c..290600ddd 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -423,7 +423,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,Marmarapk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency)); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); @@ -438,7 +438,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker if ( amount-remaining > 3*txfee ) mtx.vout.push_back(CTxOut(amount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,Marmarapk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount-remaining,-remaining,currency)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,amount-remaining,-remaining,currency)); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); result.push_back(Pair("rawtx",rawtx)); From 1f3dd2947c8030d7bf5d36f396050a6a08838b51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:42:08 -1100 Subject: [PATCH 1116/3904] Pubkeys vector --- src/cc/CCinclude.h | 2 +- src/cc/CCtx.cpp | 32 ++++++++++++++++++++++++++------ src/cc/marmara.cpp | 10 +++++++--- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 40028ee5c..871285ae8 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -179,7 +179,7 @@ int64_t CCduration(int32_t &numblocks,uint256 txid); bool komodo_txnotarizedconfirmed(uint256 txid); // CCtx bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); -std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret); +std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys=0); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); void SetCCtxids(std::vector > &addressIndex,char *coinaddr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 546c4cb6b..317b9549b 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -38,13 +38,14 @@ bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScrip return(false); } -std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret) +std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys) { auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; + CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; - int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64]; - uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; CC *mycond=0,*othercond=0,*othercond2=0,*othercond3=0,*cond; CPubKey unspendablepk; + int32_t i,flag,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64]; + uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; CC *mycond=0,*othercond=0,*othercond2=0,*othercond3=0,*othercond4=0,*cond; CPubKey unspendablepk; + globalpk = GetUnspendable(cp,0); n = mtx.vout.size(); for (i=0; iunspendablepriv; + if ( othercond4 != 0 ) + cc_free(othercond4); + othercond4 = MakeCCcond1of2(cp->evalcode,globalpk,pubkeys[i]); + cond = othercond4; + flag = 1; + } + } + if ( flag == 0 ) + { + fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr); + continue; + } } uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) @@ -190,6 +208,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cc_free(othercond2); if ( othercond3 != 0 ) cc_free(othercond3); + if ( othercond4 != 0 ) + cc_free(othercond4); std::string strHex = EncodeHexTx(mtx); if ( strHex.size() > 0 ) return(strHex); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 290600ddd..59ec3d73c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -346,7 +346,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, return(totalinputs); } -int64_t AddMarmarainputs(CMutableTransaction &mtx,char *coinaddr,int64_t total,int32_t maxinputs) +int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys,char *coinaddr,int64_t total,int32_t maxinputs) { uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,n = 0; uint8_t funcid; CPubKey pk; std::vector > unspentOutputs; @@ -364,7 +364,10 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,char *coinaddr,int64_t total,i { char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f ht.%d unlockht.%d\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,ht,unlockht); if ( total != 0 && maxinputs != 0 ) + { mtx.vin.push_back(CTxIn(txid,vout,CScript())); + pubkeys.push_back(pk); + } totalinputs += it->second.satoshis; n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) @@ -378,7 +381,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,char *coinaddr,int64_t total,i UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; std::vector pubkeys; struct CCcontract_info *cp,C; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); @@ -410,6 +413,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) if ( strcmp(myCCaddr,batonCCaddr) == 0 ) { mtx.vin.push_back(CTxIn(batontxid,0,CScript())); + pubkeys.push_back(mypk); for (i=0; i 1 ) @@ -417,7 +421,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); - if ( (inputsum= AddMarmarainputs(mtx,coinaddr,remaining,MARMARA_VINS)) >= remaining ) + if ( (inputsum= AddMarmarainputs(mtx,pubkeys,coinaddr,remaining,MARMARA_VINS)) >= remaining ) { change = (inputsum - remaining); mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); From dc737540cf6d67beb53e5fa636d8e09062d05009 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:43:20 -1100 Subject: [PATCH 1117/3904] NULL --- src/cc/CCinclude.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 871285ae8..197929277 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -179,7 +179,7 @@ int64_t CCduration(int32_t &numblocks,uint256 txid); bool komodo_txnotarizedconfirmed(uint256 txid); // CCtx bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); -std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys=0); +std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys=NULL); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); void SetCCtxids(std::vector > &addressIndex,char *coinaddr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); From 8ef1410d28e531d33fd3a76c461a08b5504d5a37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:46:39 -1100 Subject: [PATCH 1118/3904] Cast --- src/cc/CCinclude.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 197929277..43b851cc6 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -179,7 +179,7 @@ int64_t CCduration(int32_t &numblocks,uint256 txid); bool komodo_txnotarizedconfirmed(uint256 txid); // CCtx bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); -std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys=NULL); +std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = (std::vector)NULL); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); void SetCCtxids(std::vector > &addressIndex,char *coinaddr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); From d42000a83894c91f93964cd134112b58a7a99379 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:48:21 -1100 Subject: [PATCH 1119/3904] extern std::vector NULL_pubkeys; --- src/cc/CCinclude.h | 3 ++- src/cc/CCtx.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 43b851cc6..2dc3f0a51 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -179,7 +179,8 @@ int64_t CCduration(int32_t &numblocks,uint256 txid); bool komodo_txnotarizedconfirmed(uint256 txid); // CCtx bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); -std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = (std::vector)NULL); +extern std::vector NULL_pubkeys; +std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); void SetCCtxids(std::vector > &addressIndex,char *coinaddr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 317b9549b..9b3e9627c 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -16,6 +16,8 @@ #include "CCinclude.h" #include "key_io.h" +std::vector NULL_pubkeys; + /* FinalizeCCTx is a very useful function that will properly sign both CC and normal inputs, adds normal change and the opreturn. From 39a1f86d6887edaad2169ff4cfd1511282092177 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:49:31 -1100 Subject: [PATCH 1120/3904] CCpriv --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 9b3e9627c..4f5af7ac7 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -164,12 +164,12 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { flag = 0; - if ( pubkeys != 0 ) + if ( pubkeys != NULL_pubkeys ) { GetCCaddress1of2(cp,coinaddr,globalpk,pubkeys[i]); if ( strcmp(destaddr,coinaddr) == 0 ) { - privkey = cp->unspendablepriv; + privkey = cp->CCpriv; if ( othercond4 != 0 ) cc_free(othercond4); othercond4 = MakeCCcond1of2(cp->evalcode,globalpk,pubkeys[i]); From 770873156380ea5768c3626ccb44ef46a0040088 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:50:39 -1100 Subject: [PATCH 1121/3904] Coinaddr --- src/cc/CCtx.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 4f5af7ac7..1a97b4dc1 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -166,6 +166,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran flag = 0; if ( pubkeys != NULL_pubkeys ) { + char coinaddr[64]; GetCCaddress1of2(cp,coinaddr,globalpk,pubkeys[i]); if ( strcmp(destaddr,coinaddr) == 0 ) { From 9bbfa5e89ced283c807feff0f5d6e2cb676b89d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:56:08 -1100 Subject: [PATCH 1122/3904] Test --- src/cc/CCtx.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 1a97b4dc1..fe6af3f80 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -168,6 +168,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { char coinaddr[64]; GetCCaddress1of2(cp,coinaddr,globalpk,pubkeys[i]); + fprintf(stderr,"%s + %s -> %s vs %s\n",HexStr(globalpk).c_str(),HexStr(pubkeys[i]).c_str(),coinstr,destaddr); if ( strcmp(destaddr,coinaddr) == 0 ) { privkey = cp->CCpriv; From 0480189b29cc7249ae9284118a6a1d03aea24990 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:56:47 -1100 Subject: [PATCH 1123/3904] Coinaddr --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index fe6af3f80..c32a79d78 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -168,7 +168,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { char coinaddr[64]; GetCCaddress1of2(cp,coinaddr,globalpk,pubkeys[i]); - fprintf(stderr,"%s + %s -> %s vs %s\n",HexStr(globalpk).c_str(),HexStr(pubkeys[i]).c_str(),coinstr,destaddr); + fprintf(stderr,"%s + %s -> %s vs %s\n",HexStr(globalpk).c_str(),HexStr(pubkeys[i]).c_str(),coinaddr,destaddr); if ( strcmp(destaddr,coinaddr) == 0 ) { privkey = cp->CCpriv; From d4bdc4d79f7f003849598d5fdc5c40b844fbbd51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 21:58:39 -1100 Subject: [PATCH 1124/3904] Dont forget to pass in pubkeys --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 59ec3d73c..654cdd600 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -427,7 +427,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency),pubkeys); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); @@ -442,7 +442,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker if ( amount-remaining > 3*txfee ) mtx.vout.push_back(CTxOut(amount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,amount-remaining,-remaining,currency)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,amount-remaining,-remaining,currency),pubkeys); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); result.push_back(Pair("rawtx",rawtx)); From 41b29fcc3969313750db2b05983a92bf8cf90356 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 22:07:30 -1100 Subject: [PATCH 1125/3904] Automatic flag -> lsb of matures --- src/cc/CCMarmara.h | 2 +- src/cc/CCtx.cpp | 2 +- src/cc/marmara.cpp | 11 +++++++++-- src/wallet/rpcwallet.cpp | 3 ++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 6c81ed689..fe9f7f30b 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -33,7 +33,7 @@ UniValue MarmaraCreditloop(uint256 txid); UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] -UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid); +UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag); UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid); UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index c32a79d78..bb9e02fce 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -168,7 +168,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { char coinaddr[64]; GetCCaddress1of2(cp,coinaddr,globalpk,pubkeys[i]); - fprintf(stderr,"%s + %s -> %s vs %s\n",HexStr(globalpk).c_str(),HexStr(pubkeys[i]).c_str(),coinaddr,destaddr); + //fprintf(stderr,"%s + %s -> %s vs %s\n",HexStr(globalpk).c_str(),HexStr(pubkeys[i]).c_str(),coinaddr,destaddr); if ( strcmp(destaddr,coinaddr) == 0 ) { privkey = cp->CCpriv; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 654cdd600..fad9921c2 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -301,6 +301,10 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t { return(true); // iterate from issuer all remainder after maturity } + else if ( funcid == 'D' ) // collect -> automatically spend issuers locked funds, given 'I' + { + return(true); // iterate from issuer all remainder after maturity + } // staking only for locked utxo } return eval->Invalid("fall through error"); @@ -515,14 +519,17 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc return(n); } -UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid) +UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t batonamount; int32_t needbaton = 0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; - // check for batonownership by senderpk and parameters match createtxid + if ( automaticflag != 0 && (matures & 1) == 0 ) + matures++; + else if ( automaticflag == 0 && (matures & 1) != 0 ) + matures++; mypk = pubkey2pk(Mypubkey()); memset(&createtxid,0,sizeof(createtxid)); if ( batontxid != zeroid && MarmaraGetcreatetxid(createtxid,batontxid) < 0 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 877342306..899fe3099 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5553,6 +5553,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 batontxid; std::vector senderpub; int64_t amount; int32_t matures; std::string currency; if ( fHelp || (params.size() != 5 && params.size() != 4) ) { + // automatic flag -> lsb of matures // 1st marmarareceive 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1440 // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1168 d72d87aa0d50436de695c93e2bf3d7273c63c92ef6307913aa01a6ee6a16548b throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); @@ -5573,7 +5574,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) matures = atol(params[3].get_str().c_str()); batontxid = Parseuint256((char *)params[4].get_str().c_str()); } else matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1; - return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,batontxid)); + return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,batontxid,true)); } UniValue marmara_issue(const UniValue& params, bool fHelp) From 5415bbed425cd389b7defb96512b85b25b12ab00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 22:23:06 -1100 Subject: [PATCH 1126/3904] Print --- src/cc/marmara.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index fad9921c2..5496590c8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -404,13 +404,20 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) result.push_back(Pair("error",(char *)"invalid refcreatetxid, setting to creditloop[0]")); return(result); } - if ( chainActive.LastTip()->GetHeight() < refmatures ) + else if ( chainActive.LastTip()->GetHeight() < refmatures ) { fprintf(stderr,"doesnt mature for another %d blocks\n",refmatures - chainActive.LastTip()->GetHeight()); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"cant settle immature creditloop")); return(result); } + else if ( (refmatures & 1) == 0 ) + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"cant automatic settle even maturity heights")); + return(result); + } + fprintf(stderr,"refmatures.%d\n",refmatures); remaining = refamount; GetCCaddress(cp,myCCaddr,Mypubkey()); Getscriptaddress(batonCCaddr,batontx.vout[0].scriptPubKey); From 8099e3af55182e16b46b5e472a5c99a4423c868e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 22:46:45 -1100 Subject: [PATCH 1127/3904] Test --- src/cc/marmara.cpp | 23 +++++++++++++++++------ src/wallet/rpcwallet.cpp | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5496590c8..a945474f7 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -155,18 +155,23 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, if ( MarmaraGetcreatetxid(createtxid,txid) == 0 ) { txid = createtxid; - fprintf(stderr,"txid.%s -> createtxid %s\n",txid.GetHex().c_str(),createtxid.GetHex().c_str()); + //fprintf(stderr,"txid.%s -> createtxid %s\n",txid.GetHex().c_str(),createtxid.GetHex().c_str()); while ( CCgetspenttxid(spenttxid,vini,height,txid,vout) == 0 ) { creditloop.push_back(txid); - fprintf(stderr,"%d: %s\n",n,txid.GetHex().c_str()); + //fprintf(stderr,"%d: %s\n",n,txid.GetHex().c_str()); n++; - if ( (value= CCgettxout(spenttxid,vout,1)) > 0 ) + if ( (value= CCgettxout(spenttxid,vout,1)) == 10000 ) { batontxid = spenttxid; - fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); + //fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); return(n); } + else if ( value > 0 ) + { + fprintf(stderr,"got false baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); + break; + } txid = spenttxid; } } @@ -417,15 +422,21 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) result.push_back(Pair("error",(char *)"cant automatic settle even maturity heights")); return(result); } - fprintf(stderr,"refmatures.%d\n",refmatures); + else if ( n < 2 ) + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"creditloop too short")); + return(result); + } remaining = refamount; GetCCaddress(cp,myCCaddr,Mypubkey()); Getscriptaddress(batonCCaddr,batontx.vout[0].scriptPubKey); if ( strcmp(myCCaddr,batonCCaddr) == 0 ) { mtx.vin.push_back(CTxIn(batontxid,0,CScript())); + mtx.vin.push_back(CTxIn(creditloop[1],1,CScript())); // issuance marker pubkeys.push_back(mypk); - for (i=0; i 1 ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 899fe3099..577c5fcb6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5583,6 +5583,8 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 5 ) { // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1168 32da4cb3e886ee42de90b4a15042d71169077306badf909099c5c5c692df3f27 + // marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 700 MARMARA 2629 11fe8bf1de80c2ef69124d08907f259aef7f41e3a632ca2d48ad072a8c8f3078 -> 335df3a5dd6b92a3d020c9465d4d76e0d8242126106b83756dcecbad9813fdf3 + throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements() < 0 ) From 4ec27d22e8b1c0621ae419f54ddba3443f885e8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:13:21 -1100 Subject: [PATCH 1128/3904] +print --- src/cc/marmara.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index a945474f7..771b36610 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -35,6 +35,8 @@ vout0 baton to next receiverpk (following the unspent baton back to original is the credit loop) 'S' + vin0 'I' marker + vin1 baton vins CC utxos from credit loop */ @@ -169,9 +171,10 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, } else if ( value > 0 ) { - fprintf(stderr,"got false baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); - break; + fprintf(stderr,"got false baton %s/v%d %.8f\n",batontxid.GetHex().c_str(),vout,(double)value/COIN); + return(n); } + // get funcid txid = spenttxid; } } @@ -302,13 +305,13 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t { return(true); } - else if ( funcid == 'S' ) // collect -> automatically spend issuers locked funds, given 'I' + else if ( funcid == 'S' ) // settlement -> automatically spend issuers locked funds, given 'I' { - return(true); // iterate from issuer all remainder after maturity + return(true); } - else if ( funcid == 'D' ) // collect -> automatically spend issuers locked funds, given 'I' + else if ( funcid == 'D' ) // insufficient settlement { - return(true); // iterate from issuer all remainder after maturity + return(true); } // staking only for locked utxo } @@ -433,8 +436,9 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) Getscriptaddress(batonCCaddr,batontx.vout[0].scriptPubKey); if ( strcmp(myCCaddr,batonCCaddr) == 0 ) { - mtx.vin.push_back(CTxIn(batontxid,0,CScript())); mtx.vin.push_back(CTxIn(creditloop[1],1,CScript())); // issuance marker + pubkeys.push_back(Marmarapk); + mtx.vin.push_back(CTxIn(batontxid,0,CScript())); pubkeys.push_back(mypk); for (i=1; iGetHeight() ) errorstr = (char *)"it must mature in the future"; @@ -601,7 +605,6 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; - // make sure receiverpk is unique to creditloop // make sure less than maxlength Marmarapk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); @@ -609,7 +612,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a errorstr = (char *)"cant get createtxid from approvaltxid"; else if ( currency != "MARMARA" ) errorstr = (char *)"for now, only MARMARA loops are supported"; - else if ( amount < txfee ) + else if ( amount <= txfee ) errorstr = (char *)"amount must be for more than txfee"; else if ( matures <= chainActive.LastTip()->GetHeight() ) errorstr = (char *)"it must mature in the future"; @@ -888,3 +891,6 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * return(result); } +// MarmaraLock(uint64_t txfee,int64_t amount,int32_t refunlockht) +// scan all unlocked +// total capped at amount, change -> unlocked, if no change then scan all locked 'C' and 'P' for unlockht < refunlockht From ec2c6122061c2cdf69ea5abcf8fbe0ff65a9577c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:15:16 -1100 Subject: [PATCH 1129/3904] N --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 771b36610..66a36cab0 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -171,7 +171,7 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, } else if ( value > 0 ) { - fprintf(stderr,"got false baton %s/v%d %.8f\n",batontxid.GetHex().c_str(),vout,(double)value/COIN); + fprintf(stderr,"n.%d got false baton %s/v%d %.8f\n",n,batontxid.GetHex().c_str(),vout,(double)value/COIN); return(n); } // get funcid From 8d87e118df09455489d7bbd47ec953df2bbdf51e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:17:12 -1100 Subject: [PATCH 1130/3904] batontxid = spenttxid; --- src/cc/marmara.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 66a36cab0..ac8f4d8ce 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -171,6 +171,7 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, } else if ( value > 0 ) { + batontxid = spenttxid; fprintf(stderr,"n.%d got false baton %s/v%d %.8f\n",n,batontxid.GetHex().c_str(),vout,(double)value/COIN); return(n); } From 3d93fa24d9a91a8ebecf7fa86e43ff42ab830375 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:22:10 -1100 Subject: [PATCH 1131/3904] 'S' mode --- src/cc/marmara.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ac8f4d8ce..7ab5a55d4 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -673,32 +673,41 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("batontxid",batontxid.GetHex())); if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) { - str[0] = funcid, str[1] = 0; - result.push_back(Pair("funcid",str)); if ( refcreatetxid != creditloop[0] ) { fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); refcreatetxid = creditloop[0]; numerrs++; } + str[0] = funcid, str[1] = 0; + result.push_back(Pair("funcid",str)); result.push_back(Pair("createtxid",refcreatetxid.GetHex())); result.push_back(Pair("amount",ValueFromAmount(refamount))); result.push_back(Pair("matures",refmatures)); result.push_back(Pair("currency",refcurrency)); - result.push_back(Pair("batonpk",HexStr(pk))); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); - result.push_back(Pair("batonaddr",coinaddr)); - GetCCaddress(cp,batonCCaddr,pk); - result.push_back(Pair("batonCCaddr",batonCCaddr)); - Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); - if ( strcmp(coinaddr,batonCCaddr) != 0 ) + if ( funcid == 'S' ) { - result.push_back(Pair("vout0address",coinaddr)); - numerrs++; + result.push_back(Pair("settled",HexStr(pk))); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); + result.push_back(Pair("coinaddr",coinaddr)); + } + else + { + result.push_back(Pair("batonpk",HexStr(pk))); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); + result.push_back(Pair("batonaddr",coinaddr)); + GetCCaddress(cp,batonCCaddr,pk); + result.push_back(Pair("batonCCaddr",batonCCaddr)); + Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); + if ( strcmp(coinaddr,batonCCaddr) != 0 ) + { + result.push_back(Pair("vout0address",coinaddr)); + numerrs++; + } + if ( strcmp(myCCaddr,coinaddr) == 0 ) + result.push_back(Pair("ismine",1)); + else result.push_back(Pair("ismine",0)); } - if ( strcmp(myCCaddr,coinaddr) == 0 ) - result.push_back(Pair("ismine",1)); - else result.push_back(Pair("ismine",0)); for (i=0; i 1 ) From 5de16764e777ba2abaa35bd5df3c881314d5a660 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:26:24 -1100 Subject: [PATCH 1132/3904] Test --- src/cc/marmara.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 7ab5a55d4..146bbeb4f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -673,12 +673,6 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("batontxid",batontxid.GetHex())); if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) { - if ( refcreatetxid != creditloop[0] ) - { - fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); - refcreatetxid = creditloop[0]; - numerrs++; - } str[0] = funcid, str[1] = 0; result.push_back(Pair("funcid",str)); result.push_back(Pair("createtxid",refcreatetxid.GetHex())); @@ -690,9 +684,22 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("settled",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); result.push_back(Pair("coinaddr",coinaddr)); + obj.push_back(Pair("collected",ValueFromAmount(tx.vout[0].nValue))); + Getscriptaddress(destaddr,tx.vout[0].scriptPubKey); + if ( strcmp(coinaddr,destaddr) != 0 ) + { + result.push_back(Pair("destaddr",destaddr)); + numerrs++; + } } else { + if ( refcreatetxid != creditloop[0] ) + { + fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); + refcreatetxid = creditloop[0]; + numerrs++; + } result.push_back(Pair("batonpk",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); result.push_back(Pair("batonaddr",coinaddr)); From 80d27512be47b37af25f09258f1271e6d57fefb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:27:08 -1100 Subject: [PATCH 1133/3904] Result --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 146bbeb4f..6821b48a0 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -684,7 +684,7 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("settled",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); result.push_back(Pair("coinaddr",coinaddr)); - obj.push_back(Pair("collected",ValueFromAmount(tx.vout[0].nValue))); + result.push_back(Pair("collected",ValueFromAmount(tx.vout[0].nValue))); Getscriptaddress(destaddr,tx.vout[0].scriptPubKey); if ( strcmp(coinaddr,destaddr) != 0 ) { From fe514fd5b6ce42fe76412ff279638bdaf69c72a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:31:08 -1100 Subject: [PATCH 1134/3904] Tweak --- src/cc/marmara.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 6821b48a0..803c66e77 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -394,13 +394,14 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; std::vector pubkeys; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures,height; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; std::vector pubkeys; struct CCcontract_info *cp,C; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); remaining = change = 0; + height = chainActive.LastTip()->GetHeight(); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 ) { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) @@ -454,7 +455,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,matures,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,height,currency),pubkeys); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); @@ -469,7 +470,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker if ( amount-remaining > 3*txfee ) mtx.vout.push_back(CTxOut(amount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,amount-remaining,-remaining,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,height,currency),pubkeys); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); result.push_back(Pair("rawtx",rawtx)); @@ -691,6 +692,7 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("destaddr",destaddr)); numerrs++; } + refcreatetxid = creditloop[0]; } else { From d320e88b53dbd350fae36c6c37baee37a6ca4cf7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:35:14 -1100 Subject: [PATCH 1135/3904] Test --- src/cc/marmara.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 803c66e77..b59772f35 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -455,7 +455,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,amount,height,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,height,currency),pubkeys); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); @@ -676,12 +676,13 @@ UniValue MarmaraCreditloop(uint256 txid) { str[0] = funcid, str[1] = 0; result.push_back(Pair("funcid",str)); - result.push_back(Pair("createtxid",refcreatetxid.GetHex())); - result.push_back(Pair("amount",ValueFromAmount(refamount))); - result.push_back(Pair("matures",refmatures)); result.push_back(Pair("currency",refcurrency)); if ( funcid == 'S' ) { + refcreatetxid = creditloop[0]; + result.push_back(Pair("createtxid",refcreatetxid.GetHex())); + result.push_back(Pair("remainder",ValueFromAmount(refamount))); + result.push_back(Pair("height",refmatures)); result.push_back(Pair("settled",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); result.push_back(Pair("coinaddr",coinaddr)); @@ -692,10 +693,13 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("destaddr",destaddr)); numerrs++; } - refcreatetxid = creditloop[0]; + refamount = -1; } else { + result.push_back(Pair("createtxid",refcreatetxid.GetHex())); + result.push_back(Pair("amount",ValueFromAmount(refamount))); + result.push_back(Pair("matures",refmatures)); if ( refcreatetxid != creditloop[0] ) { fprintf(stderr,"invalid refcreatetxid, setting to creditloop[0]\n"); @@ -750,6 +754,11 @@ UniValue MarmaraCreditloop(uint256 txid) obj.push_back(Pair("vout0address",destaddr)); numerrs++; } + if ( i == 0 && refamount < 0 ) + { + refamount = amount; + refmatures = matures; + } if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { numerrs++; From f2a11ac0afb63db644d5479f19bc6bc7f3cce8d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:37:38 -1100 Subject: [PATCH 1136/3904] Settletxid --- src/cc/marmara.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index b59772f35..133a8c187 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -671,7 +671,6 @@ UniValue MarmaraCreditloop(uint256 txid) result.push_back(Pair("myaddress",coinaddr)); GetCCaddress(cp,myCCaddr,Mypubkey()); result.push_back(Pair("myCCaddress",myCCaddr)); - result.push_back(Pair("batontxid",batontxid.GetHex())); if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) { str[0] = funcid, str[1] = 0; @@ -680,10 +679,11 @@ UniValue MarmaraCreditloop(uint256 txid) if ( funcid == 'S' ) { refcreatetxid = creditloop[0]; + result.push_back(Pair("settletxid",batontxid.GetHex())); result.push_back(Pair("createtxid",refcreatetxid.GetHex())); result.push_back(Pair("remainder",ValueFromAmount(refamount))); - result.push_back(Pair("height",refmatures)); - result.push_back(Pair("settled",HexStr(pk))); + result.push_back(Pair("settled",refmatures)); + result.push_back(Pair("pubkey",HexStr(pk))); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); result.push_back(Pair("coinaddr",coinaddr)); result.push_back(Pair("collected",ValueFromAmount(tx.vout[0].nValue))); @@ -697,6 +697,7 @@ UniValue MarmaraCreditloop(uint256 txid) } else { + result.push_back(Pair("batontxid",batontxid.GetHex())); result.push_back(Pair("createtxid",refcreatetxid.GetHex())); result.push_back(Pair("amount",ValueFromAmount(refamount))); result.push_back(Pair("matures",refmatures)); From 4f0a54f26fdfc7d14ddcc335531c06f71df3987e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 16 Jan 2019 23:44:01 -1100 Subject: [PATCH 1137/3904] 'D' --- src/cc/marmara.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 133a8c187..215a55297 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -679,7 +679,7 @@ UniValue MarmaraCreditloop(uint256 txid) if ( funcid == 'S' ) { refcreatetxid = creditloop[0]; - result.push_back(Pair("settletxid",batontxid.GetHex())); + result.push_back(Pair("settlement",batontxid.GetHex())); result.push_back(Pair("createtxid",refcreatetxid.GetHex())); result.push_back(Pair("remainder",ValueFromAmount(refamount))); result.push_back(Pair("settled",refmatures)); @@ -695,6 +695,18 @@ UniValue MarmaraCreditloop(uint256 txid) } refamount = -1; } + else if ( funcid == 'D' ) + { + refcreatetxid = creditloop[0]; + result.push_back(Pair("settlement",batontxid.GetHex())); + result.push_back(Pair("createtxid",refcreatetxid.GetHex())); + result.push_back(Pair("remainder",ValueFromAmount(refamount))); + result.push_back(Pair("settled",refmatures)); + Getscriptaddress(destaddr,tx.vout[0].scriptPubKey); + result.push_back(Pair("txidaddr",destaddr)); + if ( tx.vout.size() > 1 ) + result.push_back(Pair("collected",ValueFromAmount(tx.vout[1].nValue))); + } else { result.push_back(Pair("batontxid",batontxid.GetHex())); @@ -759,6 +771,8 @@ UniValue MarmaraCreditloop(uint256 txid) { refamount = amount; refmatures = matures; + result.push_back(Pair("amount",ValueFromAmount(refamount))); + result.push_back(Pair("matures",refmatures)); } if ( createtxid != refcreatetxid || amount != refamount || matures != refmatures || currency != refcurrency ) { From a9369c2811ac35f02f6670e991838b328ddb9535 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Jan 2019 04:49:20 -1100 Subject: [PATCH 1138/3904] Handle short credit loop --- src/cc/marmara.cpp | 93 ++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 215a55297..1d115f557 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -39,6 +39,10 @@ vin1 baton vins CC utxos from credit loop + 'D' default/partial payment + + 'L' lockfunds + */ // start of consensus code @@ -427,7 +431,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) result.push_back(Pair("error",(char *)"cant automatic settle even maturity heights")); return(result); } - else if ( n < 2 ) + else if ( n < 1 ) { result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"creditloop too short")); @@ -438,7 +442,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) Getscriptaddress(batonCCaddr,batontx.vout[0].scriptPubKey); if ( strcmp(myCCaddr,batonCCaddr) == 0 ) { - mtx.vin.push_back(CTxIn(creditloop[1],1,CScript())); // issuance marker + mtx.vin.push_back(CTxIn(n == 1 ? batontxid : creditloop[1],1,CScript())); // issuance marker pubkeys.push_back(Marmarapk); mtx.vin.push_back(CTxIn(batontxid,0,CScript())); pubkeys.push_back(mypk); @@ -511,13 +515,14 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) return(result); } -int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,struct CCcontract_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) +int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,int64_t &totalclosed,std::vector &closed,struct CCcontract_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) { char coinaddr[64]; CPubKey Marmarapk,senderpk; int64_t amount; uint256 createtxid,txid,hashBlock; CTransaction tx; int32_t numvouts,vout,matures,n=0; std::string currency; std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,Marmarapk); SetCCunspents(unspentOutputs,coinaddr); + // do all txid, conditional on spent/unspent //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -810,43 +815,6 @@ UniValue MarmaraCreditloop(uint256 txid) } return(result); } - -UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) -{ - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; char coinaddr[64]; - CPubKey Marmarapk; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_MARMARA); - Marmarapk = GetUnspendable(cp,0); - result.push_back(Pair("result","success")); - Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); - result.push_back(Pair("myaddress",coinaddr)); - GetCCaddress(cp,coinaddr,Mypubkey()); - result.push_back(Pair("myCCaddress",coinaddr)); - if ( refpk.size() == 33 ) - result.push_back(Pair("issuer",HexStr(refpk))); - if ( currency.size() == 0 ) - currency = (char *)"MARMARA"; - if ( firstheight <= lastheight ) - firstheight = 0, lastheight = (1 << 30); - if ( minamount <= maxamount ) - minamount = 0, maxamount = (1LL << 60); - result.push_back(Pair("firstheight",firstheight)); - result.push_back(Pair("lastheight",lastheight)); - result.push_back(Pair("minamount",ValueFromAmount(minamount))); - result.push_back(Pair("maxamount",ValueFromAmount(maxamount))); - result.push_back(Pair("currency",currency)); - if ( (n= MarmaraGetCreditloops(totalamount,issuances,cp,firstheight,lastheight,minamount,maxamount,refpk,currency)) > 0 ) - { - result.push_back(Pair("n",n)); - matches = (int32_t)issuances.size(); - result.push_back(Pair("matches",matches)); - for (i=0; i unlocked, if no change then scan all locked 'C' and 'P' for unlockht < refunlockht + +// get all tx, constrain by vout, issuances[] and closed[] + +UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0; std::vector issuances,closed; char coinaddr[64]; + CPubKey Marmarapk; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_MARMARA); + Marmarapk = GetUnspendable(cp,0); + result.push_back(Pair("result","success")); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); + result.push_back(Pair("myaddress",coinaddr)); + GetCCaddress(cp,coinaddr,Mypubkey()); + result.push_back(Pair("myCCaddress",coinaddr)); + if ( refpk.size() == 33 ) + result.push_back(Pair("issuer",HexStr(refpk))); + if ( currency.size() == 0 ) + currency = (char *)"MARMARA"; + if ( firstheight <= lastheight ) + firstheight = 0, lastheight = (1 << 30); + if ( minamount <= maxamount ) + minamount = 0, maxamount = (1LL << 60); + result.push_back(Pair("firstheight",firstheight)); + result.push_back(Pair("lastheight",lastheight)); + result.push_back(Pair("minamount",ValueFromAmount(minamount))); + result.push_back(Pair("maxamount",ValueFromAmount(maxamount))); + result.push_back(Pair("currency",currency)); + if ( (n= MarmaraGetCreditloops(totalamount,issuances,totalclosed,closed,cp,firstheight,lastheight,minamount,maxamount,refpk,currency)) > 0 ) + { + result.push_back(Pair("n",n)); + matches = (int32_t)issuances.size(); + result.push_back(Pair("pending",matches)); + for (i=0; i Date: Thu, 17 Jan 2019 05:02:34 -1100 Subject: [PATCH 1139/3904] Ref amount --- src/cc/marmara.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 1d115f557..4cf1a2a42 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -469,11 +469,11 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) } else fprintf(stderr,"null funcid for creditloop[%d]\n",i); } else fprintf(stderr,"couldnt get creditloop[%d]\n",i); } - if ( amount - remaining > 2*txfee ) + if ( refamount - remaining > 2*txfee ) { mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker - if ( amount-remaining > 3*txfee ) - mtx.vout.push_back(CTxOut(amount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + if ( refamount-remaining > 3*txfee ) + mtx.vout.push_back(CTxOut(refamount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,height,currency),pubkeys); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); From 8e8a94404f2d58020637e1a73fa68bca723d6bef Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 7 Jan 2019 23:19:47 +0500 Subject: [PATCH 1140/3904] Split Asset contract into Tokens and Assets --- src/Makefile.am | 1 + src/cc/CCHeir.h | 25 +- src/cc/CCassets.h | 22 +- src/cc/CCassetsCore.cpp | 401 ++++++----- src/cc/CCassetstx.cpp | 435 ++++++++---- src/cc/CCcustom.cpp | 22 + src/cc/CCinclude.h | 17 +- src/cc/CCtokens.cpp | 487 +++++++++++++ src/cc/CCtokens.h | 76 ++ src/cc/CCtx.cpp | 13 +- src/cc/assets.cpp | 167 +++-- src/cc/eval.h | 3 +- src/cc/heir.cpp | 1426 +++++++++++++++++++++++++++++++++----- src/cc/heir_validate.h | 622 +++++++++++++++++ src/rpc/server.cpp | 15 +- src/rpc/server.h | 9 + src/wallet/rpcwallet.cpp | 441 +++++++++++- 17 files changed, 3591 insertions(+), 591 deletions(-) create mode 100644 src/cc/CCtokens.cpp create mode 100644 src/cc/CCtokens.h create mode 100644 src/cc/heir_validate.h diff --git a/src/Makefile.am b/src/Makefile.am index e6cc5d756..9588cfe44 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -290,6 +290,7 @@ libbitcoin_server_a_SOURCES = \ cc/CCcustom.cpp \ cc/CCtx.cpp \ cc/CCutils.cpp \ + cc/CCtokens.cpp \ cc/assets.cpp \ cc/faucet.cpp \ cc/rewards.cpp \ diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index 214b566c7..18d1f08bb 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -18,12 +18,33 @@ #define CC_HEIR_H #include "CCinclude.h" +#include "CCtokens.h" -#define EVAL_HEIR 0xea +//#define EVAL_HEIR 0xea bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +class CoinHelper; +class TokenHelper; + // CCcustom -UniValue HeirInfo(); + +// this would not link +//template std::string HeirFund(uint64_t txfee,int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); +//template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount); +//template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t nValue); + +std::string HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); +std::string HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); +UniValue HeirClaimCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); +UniValue HeirClaimTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); +UniValue HeirAddCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); +UniValue HeirAddTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); + +UniValue HeirInfo(uint256 fundingtxid); +UniValue HeirList(); +//std::string Heir_MakeBadTx(uint256 fundingtxid, uint8_t funcId, int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTime, uint32_t errMask); + +//bool HeirExactTokenAmounts(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 assetid, const CTransaction &tx); #endif diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 5e4441646..5a5ef2c82 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -30,12 +30,12 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx // CCassetsCore //CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk); -CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description); -CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,int64_t price,std::vector origpubkey); -bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); -uint8_t DecodeAssetOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &assetid2,int64_t &price,std::vector &origpubkey); +//CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description); +//CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector origpubkey); +//bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); +//uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); -int64_t IsAssetvout(int32_t maxAssetExactAmountDepth, struct CCcontract_info *cp, Eval* eval, int64_t &price,std::vector &origpubkey,const CTransaction& tx,int32_t v,uint256 refassetid); +int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateAskRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); @@ -44,18 +44,18 @@ bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValu bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); -bool AssetExactAmounts(int32_t maxDepth, struct CCcontract_info *cp,int64_t &inputs,int32_t starti,int64_t &outputs,Eval* eval,const CTransaction &tx,uint256 assetid); -//bool AssetExactAmounts(bool doValidateTx, struct CCcontract_info *cp, int64_t &inputs, int32_t starti, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid, std::vector &ccVinsTxs); +bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); // CCassetstx int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); -int64_t AddAssetInputs(CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); +int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); + UniValue AssetOrders(uint256 tokenid); UniValue AssetInfo(uint256 tokenid); UniValue AssetList(); -std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); -std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total); -std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode); +//std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); +//std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total); +//std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode); std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64_t pricetotal); std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 52f1ed28c..52c73d47f 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * + * Copyright © 2014-2018 The SuperNET Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -33,7 +33,7 @@ Yes, this is quite confusing... - In ValudateAssetRemainder the naming convention is nValue is the coin/asset with the offer on the books and "units" is what it is being paid in. The high level check is to make sure we didnt lose any coins or assets, the harder to validate is the actual price paid as the "orderbook" is in terms of the combined nValue for the combined totalunits. + In ValidateAssetRemainder the naming convention is nValue is the coin/asset with the offer on the books and "units" is what it is being paid in. The high level check is to make sure we didnt lose any coins or assets, the harder to validate is the actual price paid as the "orderbook" is in terms of the combined nValue for the combined totalunits. We assume that the effective unit cost in the orderbook is valid and that that amount was paid and also that any remainder will be close enough in effective unit cost to not matter. At the edge cases, this will probably be not true and maybe some orders wont be practically fillable when reduced to fractional state. However, the original pubkey that created the offer can always reclaim it. */ @@ -230,38 +230,45 @@ bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int6 return(true); } +/* use EncodeTokenCreateOpRet instead: CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description) { CScript opret; uint8_t evalcode = EVAL_ASSETS; opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description); return(opret); } +*/ -CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,int64_t price,std::vector origpubkey) +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector origpubkey) { - CScript opret; uint8_t evalcode = EVAL_ASSETS; - assetid = revuint256(assetid); - switch ( funcid ) + CScript opret; + uint8_t evalcode = EVAL_ASSETS; + uint8_t funcId = (uint8_t)'t'; + + tokenid = revuint256(tokenid); + switch ( assetFuncId ) { - case 't': case 'x': case 'o': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid); + //case 't': this cannot be here + case 'x': case 'o': + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << assetFuncId); break; case 's': case 'b': case 'S': case 'B': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << price << origpubkey); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << assetFuncId << price << origpubkey); break; case 'E': case 'e': assetid2 = revuint256(assetid2); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << assetid2 << price << origpubkey); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << assetFuncId << assetid2 << price << origpubkey); break; default: - fprintf(stderr,"EncodeOpRet: illegal funcid.%02x\n",funcid); + fprintf(stderr,"EncodeAssetOpRet: illegal funcid.%02x\n", assetFuncId); opret << OP_RETURN; break; } return(opret); } -bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description) +// it is for compatibility, do not use this for new contracts (use DecodeTokenCreateOpRet) +bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description) { std::vector vopret; uint8_t evalcode,funcid,*script; GetOpReturnData(scriptPubKey, vopret); @@ -274,59 +281,87 @@ bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &or return(0); } -uint8_t DecodeAssetOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &assetid2,int64_t &price,std::vector &origpubkey) +uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) { - std::vector vopret; uint8_t funcid=0,*script,e,f; - GetOpReturnData(scriptPubKey, vopret); + std::vector vopret; + uint8_t *script, funcId = 0, assetFuncId = 0, dummyEvalCode, dummyFuncId; + uint256 dummyTokenid; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); - memset(&assetid,0,sizeof(assetid)); - memset(&assetid2,0,sizeof(assetid2)); - price = 0; - if ( script != 0 && script[0] == EVAL_ASSETS ) - { - funcid = script[1]; - //fprintf(stderr,"decode.[%c]\n",funcid); - switch ( funcid ) + if (script == 0) { + std::cerr << "DecodeAssetOpRet() script is empty" << std::endl; + return (uint8_t)0; + } + + tokenid = zeroid; + assetid2 = zeroid; + price = 0; + + bool isEof = true; // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! + bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); + + if (!result && isEof) { // NOTE: 'result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' + std::cerr << "DecodeAssetOpRet() incorrect opret or no asset's payload" << std::endl; + return (uint8_t)0; + } + + tokenid = revuint256(tokenid); + + std::cerr << "DecodeAssetOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; + + if(evalCodeInOpret == EVAL_ASSETS) + { + //fprintf(stderr,"decode.[%c] assetFuncId.[%c]\n", funcId, assetFuncId); + switch( assetFuncId ) { - case 'c': return(funcid); - break; - case 't': case 'x': case 'o': - if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid) != 0 ) + /*case 'c': + return(funcid); + break; */ + /*case 't': + if (E_UNMARSHAL(vopret, ss >> evalCode; ss >> funcId; ss >> tokenid; isEof = ss.eof()) || !isEof) + { + assetid = revuint256(assetid); + return(funcid); + } + break; */ + + case 'x': case 'o': + if (isEof) // no data after 'assetFuncId' allowed { - assetid = revuint256(assetid); - return(funcid); + return(assetFuncId); } break; case 's': case 'b': case 'S': case 'B': - if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid; ss >> price; ss >> origpubkey) != 0 ) + if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> dummyTokenid; ss >> dummyFuncId; ss >> price; ss >> origpubkey) != 0) { - assetid = revuint256(assetid); //fprintf(stderr,"got price %llu\n",(long long)price); - return(funcid); + return(assetFuncId); } break; case 'E': case 'e': - if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) + if ( E_UNMARSHAL(vopret,ss >> dummyEvalCode; ss >> dummyFuncId; ss >> dummyTokenid; ss >> dummyFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) { //fprintf(stderr,"got price %llu\n",(long long)price); - assetid = revuint256(assetid); assetid2 = revuint256(assetid2); - return(funcid); + return(assetFuncId); } break; default: - fprintf(stderr,"DecodeAssetOpRet: illegal funcid.%02x\n",funcid); - funcid = 0; + fprintf(stderr,"DecodeAssetOpRet: illegal funcid.%02x\n", funcId); + funcId = 0; break; } } - return(funcid); + return(funcId); } bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx) { uint256 assetid,assetid2; - if ( tx.vout.size() > 0 && DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,assetid,assetid2,price,origpubkey) != 0 ) + uint8_t evalCode; + if ( tx.vout.size() > 0 && DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey) != 0 ) return(true); else return(false); } @@ -334,8 +369,10 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,const CTransaction& tx) { uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; CScript script; + uint8_t evalCode; + n = tx.vout.size(); - if ( n == 0 || (funcid= DecodeAssetOpRet(tx.vout[n-1].scriptPubKey,assetid,assetid2,price,origpubkey)) == 0 ) + if ( n == 0 || (funcid= DecodeAssetOpRet(tx.vout[n-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey)) == 0 ) return(false); if ( GetCCaddress(cp,CCaddr,pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr,CScript() << origpubkey << OP_CHECKSIG) != 0 ) return(true); @@ -343,76 +380,6 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,co } -// Checks if the vout is a really Asset CC vout -// if maxAssetExactAmountDepth > 0, it also validates the vin transaction itself: -// it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx -int64_t IsAssetvout(int32_t maxAssetExactAmountDepth, struct CCcontract_info *cp, Eval* eval, int64_t &price,std::vector &origpubkey,const CTransaction& tx,int32_t v,uint256 refassetid) -{ - uint256 assetid,assetid2; int64_t nValue=0; int32_t n; uint8_t funcid; - - if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) // maybe check address too? - { - - if (maxAssetExactAmountDepth > 0) { - //validate all tx - int64_t myCCVinsAmount = 0, myCCVoutsAmount = 0; - std::vector ccVinsTxs; - - //std::cerr << "IsAssetvout() validate=yes" << std::endl; - const bool validateVinTxs = false; - bool isEqualAmounts = AssetExactAmounts(maxAssetExactAmountDepth, cp, myCCVinsAmount, 0, myCCVoutsAmount, eval, tx, refassetid); - - // if ccInputs != ccOutputs and it is not the tokenbase tx means it is possibly fake tx (dimxy): - if (!isEqualAmounts && refassetid != tx.GetHash()) { // checking that this is the true tokenbase tx, by verifying that funcid=c, is done further in this function (dimxy) - std::cerr << "IsAssetvout() detected bad tx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx" << std::endl; - return 0; - } - } - - - n = tx.vout.size(); - if (v >= n - 1) { // just moved this up (dimxy) - std::cerr << "isAssetVout() internal err: (v >= n - 1), returning 0" << std::endl; - return(0); - } - nValue = tx.vout[v].nValue; - - // fprintf(stderr,"IsAssetvout() CC vout v.%d of n=%d amount=%.8f\n",v,n,(double)nValue/COIN); - - if ( (funcid= DecodeAssetOpRet(tx.vout[n-1].scriptPubKey,assetid,assetid2,price,origpubkey)) == 0 ) - { - fprintf(stderr,"IsAssetvout() null decodeopret v.%d\n",v); - return(0); - } - else if ( funcid == 'c' ) - { - if (refassetid == tx.GetHash() && v == 0) { - std::cerr << "isAssetVout() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning nValue=" << nValue << std::endl; - return(nValue); - } - } - else if ( (funcid == 'b' || funcid == 'B') && v == 0 ) // critical! 'b'/'B' vout0 is NOT asset - return(0); - else if ( funcid != 'E' ) - { - if ( assetid == refassetid ) - { - fprintf(stderr,"IsAssetvout() returning %.8f\n",(double)nValue/COIN); - return(nValue); - } - } - else if ( funcid == 'E' ) - { - if ( v < 2 && assetid == refassetid ) - return(nValue); - else if ( v == 2 && assetid2 == refassetid ) - return(nValue); - } - } - //fprintf(stderr,"Isassetvout: normal output v.%d %.8f\n",v,(double)tx.vout[v].nValue/COIN); - return(0); -} - int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) { uint256 hashBlock; char destaddr[64]; @@ -446,16 +413,16 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid) { - CTransaction vinTx; int64_t nValue; uint256 assetid,assetid2; uint8_t funcid; + CTransaction vinTx; int64_t nValue; uint256 assetid,assetid2; uint8_t funcid, evalCode; CCaddr[0] = origaddr[0] = 0; if ( (nValue= AssetValidateCCvin(cp,eval,CCaddr,origaddr,tx,1,vinTx)) == 0 ) - return(0); + return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout0 for buyvin"); else { //fprintf(stderr,"have %.8f checking assetid origaddr.(%s)\n",(double)nValue/COIN,origaddr); - if ( vinTx.vout.size() > 0 && (funcid= DecodeAssetOpRet(vinTx.vout[vinTx.vout.size()-1].scriptPubKey,assetid,assetid2,tmpprice,tmporigpubkey)) != 'b' && funcid != 'B' ) + if ( vinTx.vout.size() > 0 && (funcid= DecodeAssetOpRet(vinTx.vout[vinTx.vout.size()-1].scriptPubKey, evalCode, assetid,assetid2,tmpprice,tmporigpubkey)) != 'b' && funcid != 'B' ) return eval->Invalid("invalid opreturn for buyvin"); else if ( refassetid != assetid ) return eval->Invalid("invalid assetid for buyvin"); @@ -469,88 +436,162 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid) { CTransaction vinTx; int64_t nValue,assetoshis; - fprintf(stderr,"AssetValidateSellvin\n"); + //fprintf(stderr,"AssetValidateSellvin\n"); if ( (nValue= AssetValidateCCvin(cp,eval,CCaddr,origaddr,tx,1,vinTx)) == 0 ) return(0); - if ( (assetoshis= IsAssetvout(1, cp, NULL, tmpprice,tmporigpubkey,vinTx,0,assetid)) == 0 ) + if ( (assetoshis= IsAssetvout(cp, tmpprice, tmporigpubkey,vinTx,0,assetid)) == 0 ) return eval->Invalid("invalid missing CC vout0 for sellvin"); else return(assetoshis); } -// overload with additional params for deep tx validation (dimxy) -bool AssetExactAmounts(int maxDepth, struct CCcontract_info *cp, int64_t &inputs, int32_t starti, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid) +// validates opret for asset tx: +bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &price, std::vector &origpubkey) { + + uint256 assetidOpret, assetidOpret2; + uint8_t funcid, evalCode; + + // this is just for log messages indentation fur debugging recursive calls: + int32_t n = tx.vout.size(); + + if ((funcid = DecodeAssetOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey)) == 0) + { + std::cerr << "ValidateAssetOpret() DecodeOpret returned null for n-1=" << n - 1 << " txid=" << tx.GetHash().GetHex() << std::endl; + return(false); + } +/* it is now on token level: + else if (funcid == 'c') + { + if (assetid != zeroid && assetid == tx.GetHash() && v == 0) { + //std::cerr << "ValidateAssetOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; + return(true); + } + } + else if (funcid == 't') // TODO: check if this new block does not influence IsAssetVout + { + //std::cerr << "ValidateAssetOpret() assetid=" << assetid.GetHex() << " assetIdOpret=" << assetidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; + if (assetid != zeroid && assetid == assetidOpret) { + //std::cerr << "ValidateAssetOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; + return(true); + } + } */ + // TODO: hope this was unneeded!!! (dimxy) + else if ((funcid == 'b' || funcid == 'B') && v == 0) // critical! 'b'/'B' vout0 is NOT asset + return(false); + else if (funcid != 'E') + { + if (assetid != zeroid && assetidOpret == assetid) + { + //std::cerr << "ValidateAssetOpret() returns true for not 'E', funcid=" << (char)funcid << std::endl; + return(true); + } + } + else if (funcid == 'E') // NOTE: not implemented yet! + { + if (v < 2 && assetid != zeroid && assetidOpret == assetid) + return(true); + else if (v == 2 && assetid != zeroid && assetidOpret2 == assetid) + return(true); + } + + //std::cerr << "ValidateAssetOpret() return false funcid=" << (char)funcid << " assetid=" << assetid.GetHex() << " assetIdOpret=" << assetidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; + return false; +} + +// Checks if the vout is a really Asset CC vout +// compareTotals == true, the func also validates the passed transaction itself: +// it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx +int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid) { - CTransaction vinTx; uint256 hashBlock,id,id2; int32_t i,flag,numvins,numvouts; int64_t assetoshis; std::vector tmporigpubkey; int64_t tmpprice; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - inputs = outputs = 0; - maxDepth--; + //std::cerr << "IsAssetvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for assetid=" << refassetid.GetHex() << std::endl; - for (i=starti; iismyvin)(tx.vin[i].scriptSig) != 0 ) - { - //std::cerr << "AssetExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl; - // we are really not inside validation! -- dimxy - if ( (eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock)) ) - { - fprintf(stderr,"AssetExactAmounts() cannot read vintx i.%d starti.%d numvins.%d\n", i,starti,numvins); - return (!eval) ? false : eval->Invalid("always should find vin, but didnt"); + if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here + { + int32_t n = tx.vout.size(); + // just check boundaries: + if (v >= n - 1) { // just moved this up (dimxy) + std::cerr << "isAssetVout() internal err: (v >= n - 1), returning 0" << std::endl; + return(0); + } - } // false means 'don't go deeper' -- dimxy - else if ( (assetoshis= IsAssetvout( maxDepth, cp, eval, tmpprice,tmporigpubkey,vinTx,tx.vin[i].prevout.n,assetid)) != 0 ) - { - fprintf(stderr,"AssetExactAmounts() vin%d %llu, ",i,(long long)assetoshis); - inputs += assetoshis; - } - else - { - if ( vinTx.vout[i].scriptPubKey.IsPayToCryptoCondition() != 0 && DecodeAssetOpRet(vinTx.vout[vinTx.vout.size()-1].scriptPubKey,id,id2,tmpprice,tmporigpubkey) == 't' && id == assetid ) - { - assetoshis = vinTx.vout[i].nValue; - fprintf(stderr,"AssetExactAmounts() vin%d assetoshis=%llu special case, ",i,(long long)assetoshis); - inputs += assetoshis; - } - } - } - } + // moved opret checking to this new reusable func (dimxy): + const bool valOpret = ValidateAssetOpret(tx, v, refassetid, price, origpubkey); + //std::cerr << "IsAssetvout() ValidateAssetOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for assetid=" << refassetid.GetHex() << std::endl; + if (valOpret) { + //std::cerr << "IsAssetvout() ValidateAssetOpret returned true, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for assetid=" << refassetid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + //fprintf(stderr,"IsAssetvout() CC vout v.%d of n=%d amount=%.8f txid=%s\n",v,n,(double)0/COIN, tx.GetHash().GetHex().c_str()); + } + //fprintf(stderr,"IsAssetvout() normal output v.%d %.8f\n",v,(double)tx.vout[v].nValue/COIN); + return(0); +} - if ( DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,id,id2,tmpprice,tmporigpubkey) == 't' && id == assetid ) - flag = 1; - else flag = 0; +// sets cc inputs vs cc outputs and ensures they are equal: +bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid) +{ + CTransaction vinTx; uint256 hashBlock, id, id2; int32_t flag; int64_t assetoshis; std::vector tmporigpubkey; int64_t tmpprice; + int32_t numvins = tx.vin.size(); + int32_t numvouts = tx.vout.size(); + inputs = outputs = 0; - for (i=0; iismyvin)(tx.vin[i].scriptSig) || (*cpTokens->ismyvin)(tx.vin[i].scriptSig)) // || IsVinAllowed(tx.vin[i].scriptSig) != 0) + { + //std::cerr << indentStr << "AssetExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl; + // we are not inside the validation code -- dimxy + if ((eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) + { + std::cerr << "AssetExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl; + return (!eval) ? false : eval->Invalid("always should find vin tx, but didnt"); + } + else { + // validate vouts of vintx + //std::cerr << indentStr << "AssetExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; + assetoshis = IsAssetvout(cpAssets, tmpprice, tmporigpubkey, vinTx, tx.vin[i].prevout.n, assetid); + if (assetoshis != 0) + { + std::cerr << "AssetExactAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl; + inputs += assetoshis; + } + } + } + } + + // we do not use this flag anymore + //if ( DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,id,id2,tmpprice,tmporigpubkey) == 't' && id == assetid ) + //flag = 1; + //else + //flag = 0; + + for (int32_t i = 0; i ccVinsTxs; - - return AssetExactAmounts(true, cp, inputs, starti, outputs, eval, tx, assetid); -}*/ diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index fbc53406b..cae4b42bb 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -14,6 +14,8 @@ ******************************************************************************/ #include "CCassets.h" +//#include "CCtokens.h" + int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) { @@ -21,25 +23,31 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs!=0?maxinputs:64); + + threshold = total/(maxinputs!=0?maxinputs:64); // TODO: is maxinputs really not over 64, what if i want to calc total balance? + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; vout = (int32_t)it->first.index; - if ( it->second.satoshis < threshold ) + + if (it->second.satoshis < threshold) continue; + for (j=0; junspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) + if( strcmp(destaddr,coinaddr) != 0 && strcmp(destaddr,cp->unspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) continue; fprintf(stderr,"AddAssetInputs() check destaddress=%s vout amount=%.8f\n",destaddr,(double)vintx.vout[vout].nValue/COIN); - if ( (nValue= IsAssetvout(1, cp, NULL, price,origpubkey,vintx,vout,assetid)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if( (nValue = IsAssetvout(cp, price, origpubkey, vintx, vout, assetid)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -57,12 +65,13 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } + int64_t GetAssetBalance(CPubKey pk,uint256 tokenid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_ASSETS); - return(AddAssetInputs(cp,mtx,pk,tokenid,0,0)); + cp = CCinit(&C,EVAL_TOKENS); + return(AddTokenCCInputs(cp,mtx,pk,tokenid,0,0)); } UniValue AssetInfo(uint256 assetid) @@ -75,11 +84,11 @@ UniValue AssetInfo(uint256 assetid) result.push_back(Pair("error","cant find assetid")); return(result); } - if ( vintx.vout.size() > 0 && DecodeAssetCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) == 0 ) + if ( vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) == 0 ) { - fprintf(stderr,"assetid isnt assetcreation txid\n"); + fprintf(stderr,"assetid isnt token creation txid\n"); result.push_back(Pair("result","error")); - result.push_back(Pair("error","assetid isnt assetcreation txid")); + result.push_back(Pair("error","assetid isnt token creation txid")); } result.push_back(Pair("result","success")); result.push_back(Pair("tokenid",uint256_str(str,assetid))); @@ -92,15 +101,20 @@ UniValue AssetInfo(uint256 assetid) UniValue AssetList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; std::vector origpubkey; std::string name,description; char str[65]; - cp = CCinit(&C,EVAL_ASSETS); + UniValue result(UniValue::VARR); + std::vector > addressIndex; + struct CCcontract_info *cp,C; uint256 txid,hashBlock; + CTransaction vintx; std::vector origpubkey; + std::string name,description; char str[65]; + + cp = CCinit(&C,EVAL_TOKENS); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( vintx.vout.size() > 0 && DecodeAssetCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) != 0 ) + if ( vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) != 0 ) { result.push_back(uint256_str(str,txid)); } @@ -112,17 +126,33 @@ UniValue AssetList() UniValue AssetOrders(uint256 refassetid) { static uint256 zero; - int64_t price; uint256 txid,hashBlock,assetid,assetid2; std::vector origpubkey; CTransaction vintx; UniValue result(UniValue::VARR); std::vector > unspentOutputs; uint8_t funcid; char numstr[32],funcidstr[16],origaddr[64],assetidstr[65]; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_ASSETS); - SetCCunspents(unspentOutputs,(char *)cp->unspendableCCaddr); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { + UniValue result(UniValue::VARR); + std::vector > unspentOutputsTokens, unspentOutputsAssets; + + struct CCcontract_info *cpTokens, tokensC; + struct CCcontract_info *cpAssets, assetsC; + + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + cpAssets = CCinit(&assetsC, EVAL_ASSETS); + + auto addOrders = [&](struct CCcontract_info *cp, std::vector >::const_iterator it) + { + uint256 txid, hashBlock, assetid, assetid2; + int64_t price; + std::vector origpubkey; + CTransaction vintx; + uint8_t funcid, evalCode; + char numstr[32], funcidstr[16], origaddr[64], assetidstr[65]; + txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + //std::cerr << "addOrders txid" << txid.GetHex() << std::endl; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( vintx.vout.size() > 0 && (funcid= DecodeAssetOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,assetid,assetid2,price,origpubkey)) != 0 ) + funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); + //std::cerr << "addOrders vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << std::endl; + if (vintx.vout.size() > 0 && (funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) { - if ( refassetid != zero && assetid != refassetid ) + if (refassetid != zero && assetid != refassetid) { //int32_t z; //for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&txid)[z]); @@ -131,11 +161,13 @@ UniValue AssetOrders(uint256 refassetid) //fprintf(stderr," assetid\n"); //for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&refassetid)[z]); //fprintf(stderr," refassetid\n"); - continue; + return; } - if ( vintx.vout[it->first.index].nValue == 0 ) - continue; + if (vintx.vout[it->first.index].nValue == 0) + return; + UniValue item(UniValue::VOBJ); + funcidstr[0] = funcid; funcidstr[1] = 0; item.push_back(Pair("funcid", funcidstr)); @@ -157,8 +189,8 @@ UniValue AssetOrders(uint256 refassetid) } if ( origpubkey.size() == 33 ) { - GetCCaddress(cp,origaddr,pubkey2pk(origpubkey)); - item.push_back(Pair("origaddress",origaddr)); + GetCCaddress(cp, origaddr, pubkey2pk(origpubkey)); // TODO: what is this? is it asset or token?? + item.push_back(Pair("origaddress", origaddr)); } if ( assetid != zeroid ) item.push_back(Pair("tokenid",uint256_str(assetidstr,assetid))); @@ -184,11 +216,27 @@ UniValue AssetOrders(uint256 refassetid) //fprintf(stderr,"func.(%c) %s/v%d %.8f\n",funcid,uint256_str(assetidstr,txid),(int32_t)it->first.index,(double)vintx.vout[it->first.index].nValue/COIN); } } - } + }; + + + SetCCunspents(unspentOutputsTokens, (char *)cpTokens->unspendableCCaddr); + SetCCunspents(unspentOutputsAssets, (char *)cpAssets->unspendableCCaddr); + + for (std::vector >::const_iterator itTokens = unspentOutputsTokens.begin(); + itTokens != unspentOutputsTokens.end(); + itTokens++) + addOrders(cpTokens, itTokens); + + for (std::vector >::const_iterator itAssets = unspentOutputsAssets.begin(); + itAssets != unspentOutputsAssets.end(); + itAssets++) + addOrders(cpAssets, itAssets); + return(result); } -std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description) +// not used (use TokenCreate instead) +/* std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; struct CCcontract_info *cp,C; @@ -213,9 +261,10 @@ std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std:: return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetCreateOpRet('c',Mypubkey(),name,description))); } return(""); -} - -std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total) +} */ + +// not used (use TokenTransfer instead) +/* std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; uint64_t mask; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; @@ -230,11 +279,11 @@ std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector des mypk = pubkey2pk(Mypubkey()); if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) { - /*n = outputs.size(); - if ( n == amounts.size() ) - { - for (i=0; i 0 ) { @@ -254,9 +303,10 @@ std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector des //} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size()); } return(""); -} +} */ -std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode) +// deprecated +/* std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; @@ -281,76 +331,106 @@ std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector dest } else fprintf(stderr,"not enough CC asset inputs for %.8f\n",(double)total/COIN); } return(""); -} +} */ -std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64_t pricetotal) +// rpc tokenbid implementation, locks 'bidamount' coins for the 'pricetotal' of tokens +std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, int64_t pricetotal) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CCcontract_info *cp,C; uint256 hashBlock; CTransaction vintx; std::vector origpubkey; std::string name,description; - if ( bidamount < 0 || pricetotal < 0 ) + CPubKey mypk; + struct CCcontract_info *cpAssets, C; + uint256 hashBlock; + CTransaction vintx; + std::vector origpubkey; + std::string name,description; + int64_t inputs; + + std::cerr << "CreateBuyOffer() bidamount=" << bidamount << " numtokens(pricetotal)=" << pricetotal << std::endl; + + if (bidamount < 0 || pricetotal < 0) { - fprintf(stderr,"negative bidamount %lld, pricetotal %lld\n",(long long)bidamount,(long long)pricetotal); + fprintf(stderr,"negative bidamount %lld, pricetotal %lld\n", (long long)bidamount, (long long)pricetotal); return(""); } - if ( GetTransaction(assetid,vintx,hashBlock,false) == 0 ) + if (GetTransaction(assetid, vintx, hashBlock, false) == 0) { fprintf(stderr,"cant find assetid\n"); return(""); } - if ( vintx.vout.size() > 0 && DecodeAssetCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) == 0 ) + if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, origpubkey, name, description) == 0) { fprintf(stderr,"assetid isnt assetcreation txid\n"); return(""); } - cp = CCinit(&C,EVAL_ASSETS); - if ( txfee == 0 ) + + cpAssets = CCinit(&C,EVAL_ASSETS); // NOTE: assets here! + if (txfee == 0) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,bidamount+txfee,64) > 0 ) + + if ((inputs = AddNormalinputs(mtx, mypk, bidamount+txfee, 64)) > 0) { - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,bidamount,GetUnspendable(cp,0))); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('b',assetid,zeroid,pricetotal,Mypubkey()))); + std::cerr << "CreateBuyOffer() inputs=" << inputs << std::endl; + if (inputs < bidamount+txfee) { + std::cerr << "CreateBuyOffer(): insufficient coins to make buy offer" << std::endl; + CCerror = strprintf("insufficient coins to make buy offer"); + return (""); + } + + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount, GetUnspendable(cpAssets,0))); + return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('b', assetid, zeroid, pricetotal, Mypubkey()))); } + CCerror = strprintf("no coins found to make buy offer"); return(""); } +// rpc tokenask implementation, locks 'askamount' tokens for the 'pricetotal' std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t pricetotal) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk; + uint64_t mask; + int64_t inputs, CCchange; + CScript opret; + struct CCcontract_info *cp,C; //std::cerr << "CreateSell() askamount=" << askamount << " pricetotal=" << pricetotal << std::endl; - if ( askamount < 0 || pricetotal < 0 ) - { + if (askamount < 0 || pricetotal < 0) { fprintf(stderr,"negative askamount %lld, askamount %lld\n",(long long)pricetotal,(long long)askamount); return(""); } - cp = CCinit(&C,EVAL_ASSETS); + + cp = CCinit(&C, EVAL_TOKENS); // NOTE: tokens is here + if ( txfee == 0 ) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ( (inputs= AddAssetInputs(cp,mtx,mypk,assetid,askamount,60)) > 0 ) + if ((inputs = AddTokenCCInputs(cp, mtx, mypk, assetid, askamount, 60)) > 0) { if (inputs < askamount) { - //askamount = inputs; + //was: askamount = inputs; std::cerr << "CreateSell(): insufficient tokens for ask" << std::endl; + CCerror = strprintf("insufficient tokens for ask"); return (""); } - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,askamount,GetUnspendable(cp,0))); - if ( inputs > askamount ) + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,askamount, GetUnspendable(cp,0))); + if (inputs > askamount) CCchange = (inputs - askamount); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); - opret = EncodeAssetOpRet('s',assetid,zeroid,pricetotal,Mypubkey()); + if (CCchange != 0) + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); + + opret = EncodeAssetOpRet('s',assetid, zeroid, pricetotal, Mypubkey()); return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); } else { - fprintf(stderr, "need some assets to place ask\n"); + fprintf(stderr, "need some tokens to place ask\n"); } } else { // dimxy added 'else', because it was misleading message before @@ -363,34 +443,48 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; + + ////////////////////////////////////////// fprintf(stderr,"asset swaps disabled\n"); return(""); + ////////////////////////////////////////// + if ( askamount < 0 || pricetotal < 0 ) { fprintf(stderr,"negative askamount %lld, askamount %lld\n",(long long)pricetotal,(long long)askamount); return(""); } - cp = CCinit(&C,EVAL_ASSETS); + cp = CCinit(&C, EVAL_ASSETS); + if ( txfee == 0 ) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) + + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ( (inputs= AddAssetInputs(cp,mtx,mypk,assetid,askamount,60)) > 0 ) + if ((inputs = AddAssetInputs(cp, mtx, mypk, assetid, askamount, 60)) > 0) { - if ( inputs < askamount ) - askamount = inputs; - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,askamount,GetUnspendable(cp,0))); - if ( inputs > askamount ) + if (inputs < askamount) { + //was: askamount = inputs; + std::cerr << "CreateSwap(): insufficient tokens for ask" << std::endl; + CCerror = strprintf("insufficient tokens for ask"); + return (""); + } + + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, askamount, GetUnspendable(cp, 0))); + + if (inputs > askamount) CCchange = (inputs - askamount); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); - if ( assetid2 == zeroid ) - opret = EncodeAssetOpRet('s',assetid,zeroid,pricetotal,Mypubkey()); + if (CCchange != 0) + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); + + if (assetid2 == zeroid) + opret = EncodeAssetOpRet('s', assetid, zeroid, pricetotal, Mypubkey()); else { - opret = EncodeAssetOpRet('e',assetid,assetid2,pricetotal,Mypubkey()); + opret = EncodeAssetOpRet('e', assetid, assetid2, pricetotal, Mypubkey()); } return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); } @@ -405,146 +499,213 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a return(""); } +// unlocks coins std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t bidamount; CPubKey mypk; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_ASSETS); + CTransaction vintx; + uint64_t mask; + uint256 hashBlock; + int64_t bidamount; + CPubKey mypk; + struct CCcontract_info *cp,C; + + cp = CCinit(&C, EVAL_ASSETS); + if ( txfee == 0 ) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) + + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ( GetTransaction(bidtxid,vintx,hashBlock,false) != 0 ) + if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) { bidamount = vintx.vout[0].nValue; - mtx.vin.push_back(CTxIn(bidtxid,0,CScript())); + mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,EncodeAssetOpRet('o',assetid,zeroid,0,Mypubkey()))); + return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeAssetOpRet('o', assetid, zeroid, 0, Mypubkey()))); } } return(""); } +//unlocks tokens std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_ASSETS); + CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; + struct CCcontract_info *cp,C; + + cp = CCinit(&C, EVAL_TOKENS); + if ( txfee == 0 ) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) + + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ( GetTransaction(asktxid,vintx,hashBlock,false) != 0 ) + if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) { askamount = vintx.vout[0].nValue; - mtx.vin.push_back(CTxIn(asktxid,0,CScript())); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,askamount,mypk)); - return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,EncodeAssetOpRet('x',assetid,zeroid,0,Mypubkey()))); + mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); + return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, Mypubkey()))); } } return(""); } +//send tokens, receive coins: std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t fillamount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction vintx; uint256 hashBlock; CPubKey mypk; std::vector origpubkey; int32_t bidvout=0; uint64_t mask; int64_t origprice,bidamount,paid_amount,remaining_required,inputs,CCchange=0; struct CCcontract_info *cp,C; - if ( fillamount < 0 ) + CTransaction vintx; + uint256 hashBlock; + CPubKey mypk; + std::vector origpubkey; + int32_t bidvout=0; + uint64_t mask; + int64_t origprice, bidamount, paid_amount, remaining_required, inputs, CCchange=0; + struct CCcontract_info *cp,C; + + if (fillamount < 0) { - fprintf(stderr,"negative fillamount %lld\n",(long long)fillamount); + fprintf(stderr,"negative fillamount %lld\n", (long long)fillamount); return(""); } - cp = CCinit(&C,EVAL_ASSETS); - if ( txfee == 0 ) + cp = CCinit(&C, EVAL_TOKENS); + + if ( txfee == 0 ) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) + + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ( GetTransaction(bidtxid,vintx,hashBlock,false) != 0 ) + if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) { bidamount = vintx.vout[bidvout].nValue; - SetAssetOrigpubkey(origpubkey,origprice,vintx); - mtx.vin.push_back(CTxIn(bidtxid,bidvout,CScript())); - if ( (inputs= AddAssetInputs(cp,mtx,mypk,assetid,fillamount,60)) > 0 ) + SetAssetOrigpubkey(origpubkey, origprice, vintx); + + mtx.vin.push_back(CTxIn(bidtxid, bidvout, CScript())); + + if ((inputs = AddTokenCCInputs(cp, mtx, mypk, assetid, fillamount, 60)) > 0) { - if ( inputs < fillamount ) - fillamount = inputs; - SetBidFillamounts(paid_amount,remaining_required,bidamount,fillamount,origprice); - if ( inputs > fillamount ) + if (inputs < fillamount) { + std::cerr << "FillBuyOffer(): insufficient tokens to fill buy offer" << std::endl; + CCerror = strprintf("insufficient tokens to fill buy offer"); + return (""); + } + + SetBidFillamounts(paid_amount, remaining_required, bidamount, fillamount, origprice); + + if (inputs > fillamount) CCchange = (inputs - fillamount); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,bidamount - paid_amount,GetUnspendable(cp,0))); + + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, bidamount - paid_amount, GetUnspendable(cp,0))); // tokens mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,fillamount,pubkey2pk(origpubkey))); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); - fprintf(stderr,"remaining %llu -> origpubkey\n",(long long)remaining_required); - return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,EncodeAssetOpRet('B',assetid,zeroid,remaining_required,origpubkey))); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, fillamount, pubkey2pk(origpubkey))); // coins + + if (CCchange != 0) + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins + + fprintf(stderr,"remaining %llu -> origpubkey\n", (long long)remaining_required); + + return(FinalizeCCTx(mask,cp,mtx,mypk,txfee, EncodeAssetOpRet('B', assetid, zeroid, remaining_required, origpubkey))); } else return("dont have any assets to fill bid\n"); } } return("no normal coins left"); } + +// send coins, receive tokens std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 asktxid,int64_t fillunits) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction vintx,filltx; uint256 hashBlock; CPubKey mypk; std::vector origpubkey; double dprice; uint64_t mask; int32_t askvout=0; int64_t received_assetoshis,total_nValue,orig_assetoshis,paid_nValue,remaining_nValue,inputs,CCchange=0; struct CCcontract_info *cp,C; - if ( fillunits < 0 ) + CTransaction vintx,filltx; + uint256 hashBlock; + CPubKey mypk; + std::vector origpubkey; + double dprice; + uint64_t mask; + int32_t askvout=0; + int64_t received_assetoshis, total_nValue, orig_assetoshis, paid_nValue, remaining_nValue, inputs, CCchange=0; + struct CCcontract_info *cpTokens, tokensC; + struct CCcontract_info *cpAssets, assetsC; + + if (fillunits < 0) { CCerror = strprintf("negative fillunits %lld\n",(long long)fillunits); fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } - if ( assetid2 != zeroid ) + if (assetid2 != zeroid) { CCerror = "asset swaps disabled"; fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } - cp = CCinit(&C,EVAL_ASSETS); - if ( txfee == 0 ) + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + cpAssets = CCinit(&assetsC, EVAL_ASSETS); + + if (txfee == 0) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) + if (AddNormalinputs(mtx,mypk,txfee,3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ( GetTransaction(asktxid,vintx,hashBlock,false) != 0 ) + if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) { orig_assetoshis = vintx.vout[askvout].nValue; - SetAssetOrigpubkey(origpubkey,total_nValue,vintx); + SetAssetOrigpubkey(origpubkey, total_nValue, vintx); dprice = (double)total_nValue / orig_assetoshis; paid_nValue = dprice * fillunits; - mtx.vin.push_back(CTxIn(asktxid,askvout,CScript())); - if ( assetid2 != zeroid ) - inputs = AddAssetInputs(cp,mtx,mypk,assetid2,paid_nValue,60); + + mtx.vin.push_back(CTxIn(asktxid, askvout, CScript())); // NOTE: this is the reference to tokens -> send cpTokens for signing into FinalizeCCTx! + + if (assetid2 != zeroid) + inputs = AddAssetInputs(cpTokens, mtx, mypk, assetid2, paid_nValue, 60); else { - inputs = AddNormalinputs(mtx,mypk,paid_nValue,60); + inputs = AddNormalinputs(mtx, mypk, paid_nValue, 60); mask = ~((1LL << mtx.vin.size()) - 1); } - if ( inputs > 0 ) + if (inputs > 0) { - if ( inputs < paid_nValue ) - paid_nValue = inputs; - if ( assetid2 != zeroid ) - SetSwapFillamounts(received_assetoshis,remaining_nValue,orig_assetoshis,paid_nValue,total_nValue); - else SetAskFillamounts(received_assetoshis,remaining_nValue,orig_assetoshis,paid_nValue,total_nValue); - if ( assetid2 != zeroid && inputs > paid_nValue ) + if (inputs < paid_nValue) { + std::cerr << "FillSell(): insufficient coins to fill sell" << std::endl; + CCerror = strprintf("insufficient coins to fill sell"); + return (""); + } + + if (assetid2 != zeroid) + SetSwapFillamounts(received_assetoshis, remaining_nValue, orig_assetoshis, paid_nValue, total_nValue); + else + SetAskFillamounts(received_assetoshis, remaining_nValue, orig_assetoshis, paid_nValue, total_nValue); + + if (assetid2 != zeroid && inputs > paid_nValue) CCchange = (inputs - paid_nValue); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,orig_assetoshis - received_assetoshis,GetUnspendable(cp,0))); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,received_assetoshis,mypk)); - if ( assetid2 != zeroid ) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,paid_nValue,origpubkey)); - else mtx.vout.push_back(CTxOut(paid_nValue,CScript() << origpubkey << OP_CHECKSIG)); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); - return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,EncodeAssetOpRet(assetid2!=zeroid?'E':'S',assetid,assetid2,remaining_nValue,origpubkey))); + + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // coins + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); // tokens + + if (assetid2 != zeroid) + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); // tokens (not implemented correctly) + else + mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); // coins + + if (CCchange != 0) + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins + + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid, assetid2, remaining_nValue, origpubkey))); } else { CCerror = strprintf("filltx not enough utxos"); fprintf(stderr,"%s\n", CCerror.c_str()); diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 7fdd1b920..918ceb24a 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -30,6 +30,7 @@ #include "CCMarmara.h" #include "CCPayments.h" #include "CCGateways.h" +#include "CCtokens.h" /* CCcustom has most of the functions that need to be extended to create a new CC contract. @@ -222,6 +223,18 @@ uint8_t GatewaysCCpriv[32] = { 0xf7, 0x4b, 0x5b, 0xa2, 0x7a, 0x5e, 0x9c, 0xda, 0 #undef FUNCNAME #undef EVALCODE +// Tokens +#define FUNCNAME IsTokensInput +#define EVALCODE EVAL_TOKENS +const char *TokensCCaddr = "RAMvUfoyURBRxAdVeTMHxn3giJZCFWeha2"; +const char *TokensNormaladdr = "RCNgAngYAdrfzujYyPgfbjCGNVQZzCgTad"; +char TokensCChexstr[67] = { "03e6191c70c9c9a28f9fd87089b9488d0e6c02fb629df64979c9cdb6b2b4a68d95" }; +uint8_t TokensCCpriv[32] = { 0x1d, 0x0d, 0x0d, 0xce, 0x2d, 0xd2, 0xe1, 0x9d, 0xf5, 0xb6, 0x26, 0xd5, 0xad, 0xa0, 0xf0, 0x0a, 0xdd, 0x7a, 0x72, 0x7d, 0x17, 0x35, 0xb5, 0xe3, 0x2c, 0x6c, 0xa9, 0xa2, 0x03, 0x16, 0x4b, 0xcf }; +#include "CCcustom.inc" +#undef FUNCNAME +#undef EVALCODE + + struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) { cp->evalcode = evalcode; @@ -347,6 +360,15 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) cp->validate = GatewaysValidate; cp->ismyvin = IsGatewaysInput; break; + + case EVAL_TOKENS: + strcpy(cp->unspendableCCaddr, TokensCCaddr); + strcpy(cp->normaladdr, TokensNormaladdr); + strcpy(cp->CChexstr, TokensCChexstr); + memcpy(cp->CCpriv, TokensCCpriv, 32); + cp->validate = TokensValidate; + cp->ismyvin = IsTokensInput; + break; } return(cp); } diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 40028ee5c..56c4b27d5 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -133,13 +133,22 @@ int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char * uint8_t DecodeOraclesCreateOpRet(const CScript &scriptPubKey,std::string &name,std::string &description,std::string &format); uint256 OracleMerkle(int32_t height,uint256 reforacletxid,char *format,std::vectorpublishers); uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); -int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); + +//int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); + bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); -bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); -uint8_t DecodeAssetOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &assetid2,int64_t &price,std::vector &origpubkey); +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector origpubkey); +bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); +uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &vopretExtra); + +//uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid,uint256 &assetid2,int64_t &price,std::vector &origpubkey); uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t *data,int32_t offset,int32_t datalen); -CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,int64_t price,std::vector origpubkey); + + // CCcustom CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp new file mode 100644 index 000000000..c85297ddb --- /dev/null +++ b/src/cc/CCtokens.cpp @@ -0,0 +1,487 @@ +/****************************************************************************** + * Copyright © 2014-2018 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include "CCtokens.h" + +/* TODO: correct this: +----------------------------- + The SetTokenFillamounts() and ValidateTokenRemainder() work in tandem to calculate the vouts for a fill and to validate the vouts, respectively. + + This pair of functions are critical to make sure the trading is correct and is the trickiest part of the tokens contract. + + //vin.0: normal input + //vin.1: unspendable.(vout.0 from buyoffer) buyTx.vout[0] + //vin.2+: valid CC output satisfies buyoffer (*tx.vin[2])->nValue + //vout.0: remaining amount of bid to unspendable + //vout.1: vin.1 value to signer of vin.2 + //vout.2: vin.2 tokenoshis to original pubkey + //vout.3: CC output for tokenoshis change (if any) + //vout.4: normal output for change (if any) + //vout.n-1: opreturn [EVAL_ASSETS] ['B'] [tokenid] [remaining token required] [origpubkey] + ValidateTokenRemainder(remaining_price,tx.vout[0].nValue,nValue,tx.vout[1].nValue,tx.vout[2].nValue,totalunits); + + Yes, this is quite confusing... + + In ValudateTokenRemainder the naming convention is nValue is the coin/token with the offer on the books and "units" is what it is being paid in. The high level check is to make sure we didnt lose any coins or tokens, the harder to validate is the actual price paid as the "orderbook" is in terms of the combined nValue for the combined totalunits. + + We assume that the effective unit cost in the orderbook is valid and that that amount was paid and also that any remainder will be close enough in effective unit cost to not matter. At the edge cases, this will probably be not true and maybe some orders wont be practically fillable when reduced to fractional state. However, the original pubkey that created the offer can always reclaim it. + ------------------------------ +*/ + + +// NOTE: this inital tx won't be used by other contract +// for tokens to be used there should be at least one 't' tx with other contract's custom opret +CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description) +{ + CScript opret; uint8_t evalcode = EVAL_TOKENS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description); + return(opret); +} + +// this is for other contracts which use tokens and build customized extra payloads to token's opret: +CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector payload) +{ + CScript opret; + //uint8_t evalcode = EVAL_TOKENS; + tokenid = revuint256(tokenid); + //uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l'; + + opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); + return(opret); +} + +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description) +{ + std::vector vopret; uint8_t dummyEvalcode, funcid, *script; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( script != 0 && vopret.size() > 2 && script[0] == EVAL_TOKENS && script[1] == 'c' ) + { + if ( E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description) != 0 ) + return(funcid); + } + return (uint8_t)0; +} + +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &vopretExtra) +{ + std::vector vopret, extra, dummyPubkey; + uint8_t funcid=0, *script, e, dummyFuncId; + std::string dummyName; std::string dummyDescription; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + tokenid = zeroid; + + if (script != 0 /*enable all evals: && script[0] == EVAL_TOKENS*/) + { + bool isEof = true; + evalCode = script[0]; + funcid = script[1]; + //fprintf(stderr,"decode.[%c]\n",funcid); + switch ( funcid ) + { + case 'c': + return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription); + //break; + case 't': + //not used yet: case 'l': + if (E_UNMARSHAL(vopret, ss >> e; ss >> dummyFuncId; ss >> tokenid; isEof = ss.eof(); vopretExtra = std::vector(ss.begin(), ss.end())) || !isEof) + { + tokenid = revuint256(tokenid); + return(funcid); + } + std::cerr << "DecodeTokenOpRet() isEof=" << isEof << std::endl; + fprintf(stderr, "DecodeTokenOpRet() bad opret format\n"); // this may be just check, no error logging + return (uint8_t)0; + + default: + fprintf(stderr, "DecodeTokenOpRet() illegal funcid.%02x\n", funcid); + return (uint8_t)0; + } + } + return (uint8_t)0; +} + + + +// tx validation +bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn) +{ + static uint256 zero; + CTxDestination address; CTransaction vinTx, createTx; uint256 hashBlock, tokenid, tokenid2; + int32_t i, starti, numvins, numvouts, preventCCvins, preventCCvouts; + int64_t remaining_price, nValue, tokenoshis, outputs, inputs, tmpprice, totalunits, ignore; std::vector origpubkey, tmporigpubkey, ignorepubkey; + uint8_t funcid, evalCodeInOpret; + char destaddr[64], origaddr[64], CCaddr[64]; + + numvins = tx.vin.size(); + numvouts = tx.vout.size(); + outputs = inputs = 0; + preventCCvins = preventCCvouts = -1; + + if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, origpubkey)) == 0) + return eval->Invalid("TokenValidate: invalid opreturn payload"); + + fprintf(stderr, "TokensValidate (%c)\n", funcid); + + if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) + return eval->Invalid("cant find token create txid"); + else if (IsCCInput(tx.vin[0].scriptSig) != 0) + return eval->Invalid("illegal token vin0"); // why? (dimxy) + else if (numvouts < 1) + return eval->Invalid("no vouts"); + else if (funcid != 'c') + { + if (tokenid == zeroid) + return eval->Invalid("illegal tokenid"); + else if (!TokensExactAmounts(true, cp, inputs, outputs, eval, tx, tokenid)) { + if (!eval->Valid()) + return false; //TokenExactAmounts must call eval->Invalid()! + else + return eval->Invalid("tokens cc inputs != cc outputs"); + } + } + + // init for forwarding validation call + struct CCcontract_info *cpOther = NULL, C; + if (evalCodeInOpret != EVAL_TOKENS) + cpOther = CCinit(&C, evalCodeInOpret); + + switch (funcid) + { + case 'c': // create wont be called to be verified as it has no CC inputs + //vin.0: normal input + //vout.0: issuance tokenoshis to CC + //vout.1: normal output for change (if any) + //vout.n-1: opreturn EVAL_TOKENS 'c' + if (evalCodeInOpret != EVAL_TOKENS) + return eval->Invalid("unexpected TokenValidate for createtoken"); + else + return true; + + case 't': // transfer + //vin.0: normal input + //vin.1 .. vin.n-1: valid CC outputs + //vout.0 to n-2: tokenoshis output to CC + //vout.n-2: normal output for change (if any) + //vout.n-1: opreturn 't' tokenid + if (inputs == 0) + return eval->Invalid("no token inputs for transfer"); + + fprintf(stderr, "token transfer preliminarily validated %.8f -> %.8f (%d %d)\n", (double)inputs / COIN, (double)outputs / COIN, preventCCvins, preventCCvouts); + break; // breaking to other contract validation... + + default: + fprintf(stderr, "illegal tokens funcid.(%c)\n", funcid); + return eval->Invalid("unexpected token funcid"); + } + + // forward validation if evalcode in opret is not EVAL_TOKENS + if (cpOther) + return cpOther->validate(cpOther, eval, tx, nIn); + else + return eval->Invalid("unsupported evalcode in opret"); + + // what does this do? + // return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); +} + + + +// this is just for log messages indentation fur debugging recursive calls: +thread_local uint32_t tokenValIndentSize = 0; + +// validates opret for token tx: +bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &vopretExtra) { + + uint256 tokenidOpret, tokenidOpret2; + uint8_t funcid, evalCode; + + // this is just for log messages indentation fur debugging recursive calls: + std::string indentStr = std::string().append(tokenValIndentSize, '.'); + + int32_t n = tx.vout.size(); + + if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, tokenidOpret, vopretExtra)) == 0) + { + std::cerr << indentStr << "ValidateTokenOpret() DecodeOpret returned null for n-1=" << n - 1 << " txid=" << tx.GetHash().GetHex() << std::endl; + return(false); + } + else if (funcid == 'c') + { + if (tokenid != zeroid && tokenid == tx.GetHash() && v == 0) { + //std::cerr << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; + return(true); + } + } + else if (funcid == 't') + { + //std::cerr << indentStr << "ValidateTokenOpret() tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; + if (tokenid != zeroid && tokenid == tokenidOpret) { + //std::cerr << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; + return(true); + } + } + //std::cerr << indentStr << "ValidateTokenOpret() return false funcid=" << (char)funcid << " tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; + return false; +} + + +// Checks if the vout is a really Tokens CC vout +// compareTotals == true, the func also validates the passed transaction itself: +// it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx +int64_t IsTokensvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, std::vector &vopretExtra, const CTransaction& tx, int32_t v, uint256 reftokenid) +{ + + // this is just for log messages indentation fur debugging recursive calls: + std::string indentStr = std::string().append(tokenValIndentSize, '.'); + //std::cerr << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl; + + //TODO: validate cc vouts are EVAL_TOKENS! + if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here + { + int32_t n = tx.vout.size(); + // just check boundaries: + if (v >= n - 1) { // just moved this up (dimxy) + std::cerr << indentStr << "isTokensvout() internal err: (v >= n - 1), returning 0" << std::endl; + return(0); + } + + if (compareTotals) { + //std::cerr << indentStr << "IsTokensvout() maxTokenExactAmountDepth=" << maxTokenExactAmountDepth << std::endl; + //validate all tx + int64_t myCCVinsAmount = 0, myCCVoutsAmount = 0; + + tokenValIndentSize++; + // false --> because we already at the 1-st level ancestor tx and do not need to dereference ancestors of next levels + bool isEqual = TokensExactAmounts(false, cp, myCCVinsAmount, myCCVoutsAmount, eval, tx, reftokenid); + tokenValIndentSize--; + + if (!isEqual) { + // if ccInputs != ccOutputs and it is not the tokenbase tx + // this means it is possibly a fake tx (dimxy): + if (reftokenid != tx.GetHash()) { // checking that this is the true tokenbase tx, by verifying that funcid=c, is done further in this function (dimxy) + std::cerr << indentStr << "IsTokensvout() warning: for the verified tx detected a bad vintx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping the verified tx" << std::endl; + return 0; + } + } + } + + // moved opret checking to this new reusable func (dimxy): + const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, vopretExtra); + //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + if (valOpret) { + //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned true, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + + //std::cerr << indentStr; fprintf(stderr,"IsTokensvout() CC vout v.%d of n=%d amount=%.8f txid=%s\n",v,n,(double)0/COIN, tx.GetHash().GetHex().c_str()); + } + //std::cerr << indentStr; fprintf(stderr,"IsTokensvout() normal output v.%d %.8f\n",v,(double)tx.vout[v].nValue/COIN); + return(0); +} + +// compares cc inputs vs cc outputs (to prevent feeding vouts from normal inputs) +bool TokensExactAmounts(bool compareTotals, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) +{ + CTransaction vinTx; uint256 hashBlock, id, id2; int32_t flag; int64_t tokenoshis; std::vector tmporigpubkey; int64_t tmpprice; + int32_t numvins = tx.vin.size(); + int32_t numvouts = tx.vout.size(); + inputs = outputs = 0; + + // this is just for log messages indentation for debugging recursive calls: + std::string indentStr = std::string().append(tokenValIndentSize, '.'); + + for (int32_t i = 0; iismyvin)(tx.vin[i].scriptSig) /*|| IsVinAllowed(tx.vin[i].scriptSig) != 0*/) + { + //std::cerr << indentStr << "TokensExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl; + // we are not inside the validation code -- dimxy + if ((eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) + { + std::cerr << indentStr << "TokensExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl; + return (!eval) ? false : eval->Invalid("always should find vin tx, but didnt"); + + } + else { + tokenValIndentSize++; + // validate vouts of vintx + //std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; + tokenoshis = IsTokensvout(compareTotals, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid); + tokenValIndentSize--; + if (tokenoshis != 0) + { + std::cerr << indentStr << "TokensExactAmounts() vin i=" << i << " tokenoshis=" << tokenoshis << std::endl; + inputs += tokenoshis; + } + } + } + } + + + for (int32_t i = 0; iInvalid() here! + } + else + return true; +} + +// add inputs from token cc addr +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) +{ + char coinaddr[64], destaddr[64]; + int64_t threshold, nValue, price, totalinputs = 0; + uint256 txid, hashBlock; + std::vector vopretExtra; + CTransaction vintx; + int32_t j, vout, n = 0; + std::vector > unspentOutputs; + + GetCCaddress(cp, coinaddr, pk); + SetCCunspents(unspentOutputs, coinaddr); + + threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: is maxinputs really could not be over 64? what if i want to calc total balance? + + for (std::vector >::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if (it->second.satoshis < threshold) + continue; + for (j = 0; junspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) + continue; + fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); + if ((nValue = IsTokensvout(true, cp, NULL, vopretExtra, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + { + if (total != 0 && maxinputs != 0) + mtx.vin.push_back(CTxIn(txid, vout, CScript())); + nValue = it->second.satoshis; + totalinputs += nValue; + //std::cerr << "AddTokenInputs() adding input nValue=" << nValue << std::endl; + n++; + if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) + break; + } + } + } + + //std::cerr << "AddTokenInputs() found totalinputs=" << totalinputs << std::endl; + return(totalinputs); +} + + +std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; struct CCcontract_info *cp, C; + if (assetsupply < 0) + { + fprintf(stderr, "negative assetsupply %lld\n", (long long)assetsupply); + return(""); + } + + cp = CCinit(&C, EVAL_TOKENS); + if (name.size() > 32 || description.size() > 4096) + { + fprintf(stderr, "name.%d or description.%d is too big\n", (int32_t)name.size(), (int32_t)description.size()); + return(""); + } + if (txfee == 0) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + + if (AddNormalinputs(mtx, mypk, assetsupply + 2 * txfee, 64) > 0) + { + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, assetsupply, mypk)); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); + return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description))); + } + return(""); +} + + +std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; uint64_t mask; int64_t CCchange = 0, inputs = 0; struct CCcontract_info *cp, C; + std::vector emptyExtraOpret; + + if (total < 0) + { + fprintf(stderr, "negative total %lld\n", (long long)total); + return(""); + } + cp = CCinit(&C, EVAL_TOKENS); + if (txfee == 0) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + { + //n = outputs.size(); + //if ( n == amounts.size() ) + //{ + // for (i=0; i 0) + { + + if (inputs < total) { //added dimxy + std::cerr << "AssetTransfer(): insufficient funds" << std::endl; + return (""); + } + if (inputs > total) + CCchange = (inputs - total); + //for (i=0; i &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid); +std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); +std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); + +//this is in CCinclude.h int64_t AddTokenInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); + +//this is in CCinclude.h uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); + +/* +// CCassetsCore +CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description); +CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,int64_t price,std::vector origpubkey); +bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); +//uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); +bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); +int64_t IsAssetvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); +bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); +bool ValidateAskRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); +bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); +bool SetBidFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); +bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); +bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); +int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); +int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); +bool AssetExactAmounts(bool compareTotals, struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); + +// CCassetstx +int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); +int64_t AddAssetInputs(CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); +UniValue AssetOrders(uint256 tokenid); +UniValue AssetInfo(uint256 tokenid); +UniValue AssetList(); +std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); +std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total); +std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode); + +std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64_t pricetotal); +std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid); +std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t fillamount); +std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t pricetotal); +std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 assetid2,int64_t pricetotal); +std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid); +std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 asktxid,int64_t fillamount); +*/ + +#endif diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index a80b3b3cf..57a2a327b 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -144,9 +144,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { //fprintf(stderr,"matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; - if ( othercond2 == 0 && cp->evalcode != EVAL_CHANNELS && cp->evalcode != EVAL_HEIR ) + if ( othercond2 == 0 && cp->evalcode != EVAL_CHANNELS && cp->evalcode != EVAL_HEIR && cp->evalcode != EVAL_ASSETS && cp->evalcode != EVAL_TOKENS) othercond2 = MakeCCcond1(cp->evalcode2,cp->unspendablepk2); - else if ( othercond2 == 0 && (cp->evalcode == EVAL_CHANNELS || cp->evalcode == EVAL_HEIR) ) + else if ( othercond2 == 0 && (cp->evalcode == EVAL_CHANNELS || cp->evalcode == EVAL_HEIR || cp->evalcode == EVAL_ASSETS || cp->evalcode == EVAL_TOKENS) ) othercond2 = MakeCCcond1of2(cp->evalcode2,cp->unspendablepk2,cp->unspendablepk3); cond = othercond2; } @@ -297,7 +297,7 @@ int64_t CCfullsupply(uint256 tokenid) uint256 hashBlock; int32_t numvouts; CTransaction tx; std::vector origpubkey; std::string name,description; if ( GetTransaction(tokenid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { - if ( DecodeAssetCreateOpRet(tx.vout[numvouts-1].scriptPubKey,origpubkey,name,description) > 0 ) + if (DecodeTokenCreateOpRet(tx.vout[numvouts-1].scriptPubKey,origpubkey,name,description)) { return(tx.vout[0].nValue); } @@ -307,8 +307,11 @@ int64_t CCfullsupply(uint256 tokenid) int64_t CCtoken_balance(char *coinaddr,uint256 tokenid) { - int64_t price,sum = 0; int32_t numvouts; CTransaction tx; uint256 assetid,assetid2,txid,hashBlock; std::vector origpubkey; + int64_t price,sum = 0; int32_t numvouts; CTransaction tx; uint256 assetid,assetid2,txid,hashBlock; + std::vector vopretExtra; std::vector > unspentOutputs; + uint8_t evalCode; + SetCCunspents(unspentOutputs,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -316,7 +319,7 @@ int64_t CCtoken_balance(char *coinaddr,uint256 tokenid) if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { char str[65]; fprintf(stderr,"check %s %.8f\n",uint256_str(str,txid),(double)it->second.satoshis/COIN); - if ( DecodeAssetOpRet(tx.vout[numvouts-1].scriptPubKey,assetid,assetid2,price,origpubkey) != 0 && assetid == tokenid ) + if ( DecodeTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCode, assetid, vopretExtra) != 0 && assetid == tokenid ) { sum += it->second.satoshis; } diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index a1fa39192..47b9488c8 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -133,45 +133,63 @@ // tx validation -bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransaction &tx, uint32_t nIn) { static uint256 zero; - CTxDestination address; CTransaction vinTx,createTx; uint256 hashBlock,assetid,assetid2; int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts; int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector origpubkey,tmporigpubkey,ignorepubkey; uint8_t funcid; char destaddr[64],origaddr[64],CCaddr[64]; + CTxDestination address; CTransaction vinTx,createTx; uint256 hashBlock,assetid,assetid2; + int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts; + int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector origpubkey,tmporigpubkey,ignorepubkey; + uint8_t funcid, evalCodeInOpret; + char destaddr[64],origaddr[64],CCaddr[64]; + + // we need this for validating tokens' vins/vous: + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + numvins = tx.vin.size(); numvouts = tx.vout.size(); outputs = inputs = 0; preventCCvins = preventCCvouts = -1; - if ( (funcid= DecodeAssetOpRet(tx.vout[numvouts-1].scriptPubKey,assetid,assetid2,remaining_price,origpubkey)) == 0 ) - return eval->Invalid("Invalid opreturn payload"); + + if((funcid = DecodeAssetOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) + return eval->Invalid("AssetValidate: invalid opreturn payload"); + fprintf(stderr,"AssetValidate (%c)\n",funcid); - if ( funcid != 'o' && funcid != 'x' && eval->GetTxUnconfirmed(assetid,createTx,hashBlock) == 0 ) + + if( funcid != 'o' && funcid != 'x' && eval->GetTxUnconfirmed(assetid, createTx, hashBlock) == 0 ) return eval->Invalid("cant find asset create txid"); - else if ( funcid != 'o' && funcid != 'x' && assetid2 != zero && eval->GetTxUnconfirmed(assetid2,createTx,hashBlock) == 0 ) + else if( funcid != 'o' && funcid != 'x' && assetid2 != zero && eval->GetTxUnconfirmed(assetid2, createTx, hashBlock) == 0 ) return eval->Invalid("cant find asset2 create txid"); - else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + else if( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("illegal asset vin0"); - else if ( numvouts < 1 ) + else if( numvouts < 1 ) return eval->Invalid("no vouts"); - else if ( funcid != 'c' ) + else if( funcid != 'c' ) { - if ( funcid == 't' ) + /* if( funcid == 't' ) starti = 0; - else starti = 1; - if ( assetid == zero ) + else + starti = 1; */ + + if( assetid == zero ) return eval->Invalid("illegal assetid"); - else if ( AssetExactAmounts(2, cp,inputs,starti,outputs,eval,tx,assetid) == false ) - return eval->Invalid("asset inputs != outputs"); + + else if (!AssetExactAmounts(cpAssets, inputs, outputs, eval, tx, assetid)) { // Only set inputs and outputs. NOTE: we do not need to check cc inputs == cc outputs + return false; // returns false if some problems with reading vintxes + } } - - switch ( funcid ) + switch( funcid ) { case 'c': // create wont be called to be verified as it has no CC inputs //vin.0: normal input //vout.0: issuance assetoshis to CC //vout.1: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['c'] [{"":""}] - return eval->Invalid("unexpected AssetValidate for createasset"); + //if (evalCodeInOpret == EVAL_ASSETS) + // return eval->Invalid("unexpected AssetValidate for createasset"); + // return + return eval->Invalid("invalid asset funcid \'c\'"); break; case 't': // transfer //vin.0: normal input @@ -179,9 +197,10 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //vout.0 to n-2: assetoshis output to CC //vout.n-2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['t'] [assetid] - if ( inputs == 0 ) - return eval->Invalid("no asset inputs for transfer"); - fprintf(stderr,"transfer validated %.8f -> %.8f (%d %d)\n",(double)inputs/COIN,(double)outputs/COIN,preventCCvins,preventCCvouts); + //if (inputs == 0) + // return eval->Invalid("no asset inputs for transfer"); + //fprintf(stderr,"transfer preliminarily validated %.8f -> %.8f (%d %d)\n",(double)inputs/COIN,(double)outputs/COIN,preventCCvins,preventCCvouts); + return eval->Invalid("invalid asset funcid \'t\'"); break; case 'b': // buyoffer @@ -189,13 +208,13 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //vout.0: amount of bid to unspendable //vout.1: normal output for change (if any) // vout.n-1: opreturn [EVAL_ASSETS] ['b'] [assetid] [amount of asset required] [origpubkey] - if ( remaining_price == 0 ) + if( remaining_price == 0 ) return eval->Invalid("illegal null amount for buyoffer"); - else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,0) == 0 ) + else if( ConstrainVout(tx.vout[0],1,cpAssets->unspendableCCaddr,0) == 0 ) return eval->Invalid("invalid vout for buyoffer"); preventCCvins = 1; preventCCvouts = 1; - fprintf(stderr,"buy offer validated to destaddr.(%s)\n",cp->unspendableCCaddr); + fprintf(stderr,"buy offer validated to destaddr.(%s)\n",cpAssets->unspendableCCaddr); break; case 'o': // cancelbuy @@ -204,9 +223,9 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //vout.0: vin.1 value to original pubkey buyTx.vout[0].nValue -> [origpubkey] //vout.1: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['o'] - if ( (nValue= AssetValidateBuyvin(cp,eval,tmpprice,tmporigpubkey,CCaddr,origaddr,tx,assetid)) == 0 ) + if( (nValue= AssetValidateBuyvin(cpAssets, eval, tmpprice, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if ( ConstrainVout(tx.vout[0],0,origaddr,nValue) == 0 ) + else if( ConstrainVout(tx.vout[0],0, origaddr, nValue) == 0 ) return eval->Invalid("invalid refund for cancelbuy"); preventCCvins = 2; preventCCvouts = 0; @@ -224,32 +243,32 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //vout.4: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['B'] [assetid] [remaining asset required] [origpubkey] preventCCvouts = 4; - if ( (nValue= AssetValidateBuyvin(cp,eval,totalunits,tmporigpubkey,CCaddr,origaddr,tx,assetid)) == 0 ) + if( (nValue = AssetValidateBuyvin(cpAssets, eval, totalunits, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if ( numvouts < 3 ) + else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillbuy"); - else if ( tmporigpubkey != origpubkey ) + else if( tmporigpubkey != origpubkey ) return eval->Invalid("mismatched origpubkeys for fillbuy"); else { - if ( nValue != tx.vout[0].nValue+tx.vout[1].nValue ) + if( nValue != tx.vout[0].nValue + tx.vout[1].nValue ) return eval->Invalid("locked value doesnt match vout0+1 fillbuy"); - else if ( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) + else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if ( ConstrainVout(tx.vout[2],1,CCaddr,0) == 0 ) + if( ConstrainVout(tx.vout[2], 1, CCaddr, 0) == 0 ) return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); - else if ( inputs != tx.vout[2].nValue+tx.vout[3].nValue ) + else if ( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); } - else if ( ConstrainVout(tx.vout[2],1,CCaddr,inputs) == 0 ) + else if( ConstrainVout(tx.vout[2], 1, CCaddr, inputs) == 0 ) return eval->Invalid("vout2 doesnt match inputs fillbuy"); - else if ( ConstrainVout(tx.vout[1],0,0,0) == 0 ) + else if( ConstrainVout(tx.vout[1],0,0,0) == 0 ) return eval->Invalid("vout1 is CC for fillbuy"); - else if ( ValidateBidRemainder(remaining_price,tx.vout[0].nValue,nValue,tx.vout[1].nValue,tx.vout[2].nValue,totalunits) == false ) + else if( ValidateBidRemainder(remaining_price, tx.vout[0].nValue, nValue, tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillbuy"); - else if ( remaining_price != 0 ) + else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,0) == 0 ) + if( ConstrainVout(tx.vout[0], 1, cpAssets->unspendableCCaddr, 0) == 0 ) return eval->Invalid("mismatched vout0 AssetsCCaddr for fillbuy"); } } @@ -266,16 +285,17 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //'s'.vout.n-1: opreturn [EVAL_ASSETS] ['s'] [assetid] [amount of native coin required] [origpubkey] //'e'.vout.n-1: opreturn [EVAL_ASSETS] ['e'] [assetid] [assetid2] [amount of asset2 required] [origpubkey] preventCCvouts = 1; - if ( remaining_price == 0 ) + if( remaining_price == 0 ) return eval->Invalid("illegal null remaining_price for selloffer"); - if ( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() != 0 ) + if( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() != 0 ) { preventCCvouts++; - if ( ConstrainVout(tx.vout[0],1,(char *)cp->unspendableCCaddr,0) == 0 ) + if( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) return eval->Invalid("mismatched vout0 AssetsCCaddr for selloffer"); - else if ( tx.vout[0].nValue+tx.vout[1].nValue != inputs ) + else if( tx.vout[0].nValue + tx.vout[1].nValue != inputs ) return eval->Invalid("mismatched vout0+vout1 total for selloffer"); - } else if ( ConstrainVout(tx.vout[0],1,(char *)cp->unspendableCCaddr,inputs) == 0 ) + } + else if( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, inputs) == 0 ) return eval->Invalid("mismatched vout0 AssetsCCaddr for selloffer"); //fprintf(stderr,"remaining.%d for sell\n",(int32_t)remaining_price); break; @@ -286,9 +306,9 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //vout.0: vin.1 assetoshis to original pubkey CC sellTx/exchangeTx.vout[0].nValue -> [origpubkey] //vout.1: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] - if ( (assetoshis= AssetValidateSellvin(cp,eval,tmpprice,tmporigpubkey,CCaddr,origaddr,tx,assetid)) == 0 ) + if( (assetoshis= AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if ( ConstrainVout(tx.vout[0],1,CCaddr,assetoshis) == 0 ) + else if( ConstrainVout(tx.vout[0], 1, CCaddr, assetoshis) == 0 ) return eval->Invalid("invalid vout for cancel"); preventCCvins = 2; preventCCvouts = 1; @@ -303,25 +323,25 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //'S'.vout.2: vin.2 value to original pubkey [origpubkey] //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] - if ( (assetoshis= AssetValidateSellvin(cp,eval,totalunits,tmporigpubkey,CCaddr,origaddr,tx,assetid)) == 0 ) + if( (assetoshis = AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if ( numvouts < 3 ) + else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillask"); - else if ( tmporigpubkey != origpubkey ) + else if( tmporigpubkey != origpubkey ) return eval->Invalid("mismatched origpubkeys for fillask"); else { - if ( assetoshis != tx.vout[0].nValue+tx.vout[1].nValue ) + if( assetoshis != tx.vout[0].nValue + tx.vout[1].nValue ) return eval->Invalid("locked value doesnt match vout0+1 fillask"); - if ( ValidateAskRemainder(remaining_price,tx.vout[0].nValue,assetoshis,tx.vout[1].nValue,tx.vout[2].nValue,totalunits) == false ) + if( ValidateAskRemainder(remaining_price, tx.vout[0].nValue, assetoshis, tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillask"); - else if ( ConstrainVout(tx.vout[1],1,0,0) == 0 ) + else if( ConstrainVout(tx.vout[1], 1, 0, 0) == 0 ) return eval->Invalid("normal vout1 for fillask"); - else if ( ConstrainVout(tx.vout[2],0,origaddr,0) == 0 ) + else if( ConstrainVout(tx.vout[2], 0, origaddr, 0) == 0 ) return eval->Invalid("normal vout1 for fillask"); - else if ( remaining_price != 0 ) + else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0],1,(char *)cp->unspendableCCaddr,0) == 0 ) + if ( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr,0) == 0 ) return eval->Invalid("mismatched vout0 AssetsCCaddr for fill"); } } @@ -339,51 +359,58 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //vout.3: CC output for asset2 change (if any) //vout.3/4: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['E'] [assetid vin0+1] [assetid vin2] [remaining asset2 required] [origpubkey] - if ( AssetExactAmounts(1, cp,inputs,1,outputs,eval,tx,assetid2) == false ) - eval->Invalid("asset2 inputs != outputs"); - if ( (assetoshis= AssetValidateSellvin(cp,eval,totalunits,tmporigpubkey,CCaddr,origaddr,tx,assetid)) == 0 ) + + //if ( AssetExactAmounts(false, cp,inputs,outputs,eval,tx,assetid2) == false ) + // eval->Invalid("asset2 inputs != outputs"); + + if( (assetoshis= AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if ( numvouts < 3 ) + else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillex"); - else if ( tmporigpubkey != origpubkey ) + else if( tmporigpubkey != origpubkey ) return eval->Invalid("mismatched origpubkeys for fillex"); else { - if ( assetoshis != tx.vout[0].nValue+tx.vout[1].nValue ) + if( assetoshis != tx.vout[0].nValue + tx.vout[1].nValue ) return eval->Invalid("locked value doesnt match vout0+1 fillex"); - else if ( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) + else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if ( ConstrainVout(tx.vout[2],1,CCaddr,0) == 0 ) + if( ConstrainVout(tx.vout[2], 1, CCaddr, 0) == 0 ) return eval->Invalid("vout2 doesnt go to origpubkey fillex"); - else if ( inputs != tx.vout[2].nValue+tx.vout[3].nValue ) + else if( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) { fprintf(stderr,"inputs %.8f != %.8f + %.8f\n",(double)inputs/COIN,(double)tx.vout[2].nValue/COIN,(double)tx.vout[3].nValue/COIN); return eval->Invalid("asset inputs doesnt match vout2+3 fillex"); } } - else if ( ConstrainVout(tx.vout[2],1,CCaddr,inputs) == 0 ) + else if( ConstrainVout(tx.vout[2], 1, CCaddr, inputs) == 0 ) return eval->Invalid("vout2 doesnt match inputs fillex"); - else if ( ConstrainVout(tx.vout[1],0,0,0) == 0 ) + else if( ConstrainVout(tx.vout[1], 0, 0, 0) == 0 ) return eval->Invalid("vout1 is CC for fillex"); fprintf(stderr,"assets vout0 %llu, vin1 %llu, vout2 %llu -> orig, vout1 %llu, total %llu\n",(long long)tx.vout[0].nValue,(long long)assetoshis,(long long)tx.vout[2].nValue,(long long)tx.vout[1].nValue,(long long)totalunits); - if ( ValidateSwapRemainder(remaining_price,tx.vout[0].nValue,assetoshis,tx.vout[1].nValue,tx.vout[2].nValue,totalunits) == false ) + if( ValidateSwapRemainder(remaining_price, tx.vout[0].nValue, assetoshis,tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillex"); - else if ( ConstrainVout(tx.vout[1],1,0,0) == 0 ) + else if( ConstrainVout(tx.vout[1], 1, 0, 0) == 0 ) return eval->Invalid("normal vout1 for fillex"); - else if ( remaining_price != 0 ) + else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0],1,(char *)cp->unspendableCCaddr,0) == 0 ) + if( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) return eval->Invalid("mismatched vout0 AssetsCCaddr for fillex"); } } fprintf(stderr,"fill validated\n"); break; + default: fprintf(stderr,"illegal assets funcid.(%c)\n",funcid); return eval->Invalid("unexpected assets funcid"); - break; + //break; } - return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); + + // what does this do? + bool bPrevent = PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts); + std::cerr << "AssetsValidate() PreventCC returned=" << bPrevent << std::endl; + return (bPrevent); } diff --git a/src/cc/eval.h b/src/cc/eval.h index 87b98349b..de1636ab8 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -55,7 +55,8 @@ EVAL(EVAL_PEGS, 0xee) \ EVAL(EVAL_MARMARA, 0xef) \ EVAL(EVAL_PAYMENTS, 0xf0) \ - EVAL(EVAL_GATEWAYS, 0xf1) + EVAL(EVAL_GATEWAYS, 0xf1) \ + EVAL(EVAL_TOKENS, 0xf2) typedef uint8_t EvalCode; diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 44f01a8a4..81318ad1e 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -14,203 +14,1315 @@ ******************************************************************************/ #include "CCHeir.h" +#include "CCassets.h" + +#include "heir_validate.h" + +class CoinHelper; +class TokenHelper; /* The idea of Heir CC is to allow crypto inheritance. A special 1of2 CC address is created that is freely spendable by the creator. The heir is only allowed to spend after the specified amount of idle blocks. The idea is that if the address doesnt spend any funds for a year (or whatever amount set), then it is time to allow the heir to spend. The design requires the heir to spend all the funds at once */ -// start of consensus code +// tx validation code -int64_t IsHeirvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +// this is for indentation of debug log messages (in recursive calls): +//extern thread_local uint32_t assetValIndentSize; + +// check if vout is cc addr and also check sum(inputs) == sum(outputs) for the passed tx, if requested +int64_t IsHeirvout(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 tokenid, const CTransaction& tx, int32_t v) { - char destaddr[64]; - if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) - { - if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) - return(tx.vout[v].nValue); - } - return(0); + //std::string indentStr = std::string().append(assetValIndentSize, '.'); + + //std::cerr << indentStr << "IsHeirvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << std::boolalpha << " compareTotals=" << compareTotals << std::endl; + if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) + { + //std::cerr << indentStr << "IsHeirvout() IsPayToCryptoCondition=true for txid=" << tx.GetHash().GetHex() << std::endl; + /*if (compareTotals) { // totally there are only 2 levels actually + + // call recursively HeirExactTokenAmounts and compare ccinputs = ccoutputs for this tx: + assetValIndentSize++; + const bool isEqual = HeirExactTokenAmounts(false, cpHeir, eval, tokenid, tx); + assetValIndentSize--; + + if (!isEqual) { // ccInputs != ccOutputs means a problem + //std::cerr << indentStr << "IsHeirvout() warning: detected suspicious tx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs, checking further if it is the tokenbase tx" << std::endl; + // if ccInputs != ccOutputs and it is not the 'tokenbase' tx means it is possibly fake tx (dimxy): + if (tokenid != zeroid && tokenid != tx.GetHash()) { + std::cerr << indentStr << "IsHeirvout() warning: detected bad tx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping this tx" << std::endl; + return 0; + } + } + }*/ + + // TODO: add some validation here + + // lets check asset opreturn for this heir or assets tx (dimxy): + /* + int64_t dummyPrice; std::vector dummyOrigpubkey; + + const bool valOpret = ValidateAssetOpret(tx, v, tokenid, dummyPrice, dummyOrigpubkey); + //std::cerr << indentStr << "IsHeirvout() ValidateAssetOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << std::endl; + if (valOpret) { + std::cerr << indentStr << "IsHeirvout() opret is true, return value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << std::endl; + return(tx.vout[v].nValue); + }*/ + + return(tx.vout[v].nValue); + } + //std::cerr << indentStr << "IsHeirvout() return value=0" << std::endl; + return(0); } -bool HeirExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +// this function validates that tx cc outputs == cc inputs, +// that is there is no fake token supply from normal inputs (except the initial tokenbase tx) +// the cc inputs are allowed only from the Assets or Heir contracts +/*bool HeirExactTokenAmounts(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 tokenid, const CTransaction &tx) { - static uint256 zerohash; - CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - for (i=0; iismyvin)(tx.vin[i].scriptSig) != 0 ) - { - //fprintf(stderr,"vini.%d check mempool\n",i); - if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) - return eval->Invalid("cant find vinTx"); - else - { - //fprintf(stderr,"vini.%d check hash and vout\n",i); - if ( hashBlock == zerohash ) - return eval->Invalid("cant Heir from mempool"); - if ( (assetoshis= IsHeirvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) - inputs += assetoshis; - } - } - } - for (i=0; iInvalid("mismatched inputs != outputs + txfee"); - } - else return(true); + static uint256 zerohash; + CTransaction vinTx; + uint256 hashBlock, activehash; + int64_t inputs = 0, outputs = 0, assetoshis; + + struct CCcontract_info *cpAssets, cAssets; + cpAssets = CCinit(&cAssets, EVAL_ASSETS); // init also tokens CC contract to check its cc addresses too + + std::string indentStr = std::string().append(assetValIndentSize, '.'); + + int32_t numvins = tx.vin.size(); + int32_t numvouts = tx.vout.size(); + for (int32_t i = 0; i < numvins; i++) + { + //std::cerr << indentStr << "HeirExactTokenAmounts() vin i=" << i << " cpHeir->ismyvin()=" << std::boolalpha << (*cpHeir->ismyvin)(tx.vin[i].scriptSig) << " cpAssets->ismyvin()=" << (*cpAssets->ismyvin)(tx.vin[i].scriptSig) << std::endl; + + // checking that vin is either from heir or assets: + if ((*cpHeir->ismyvin)(tx.vin[i].scriptSig) || (*cpAssets->ismyvin)(tx.vin[i].scriptSig)) + { + //std::cerr << indentStr; fprintf(stderr,"vini.%d check mempool\n",i); + if ((eval && !eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock)) || !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock)) { + std::cerr << indentStr << "HeirExactTokenAmounts(): can't get vintx transaction txid=" << tx.vin[i].prevout.hash.GetHex() << std::endl; + return (eval) ? eval->Invalid("cant find vinTx") : false; + } + else + { + //std::cerr << indentStr; fprintf(stderr,"vini.%d check hash and vout\n",i); + if (hashBlock == zerohash) { + std::cerr << indentStr << "HeirExactTokenAmounts(): can't get vintx from mempool, txid=" << tx.vin[i].prevout.hash.GetHex() << std::endl; + return (eval) ? eval->Invalid("cant Heir from mempool") : false; + } + + std::string dummyRefcoin; uint256 dummyBindtxid, dummyDeposittxid; CPubKey dummyDestpub; int64_t dummyAmount; + uint256 dummyAssetid2; + std::vector dummyOrigpubkey; + + // Note: if tokenid is zeroid, it may mean we are on the first level and just called from HeirValidate, validating claim 't' tx, + // then let's find the tokenid ourselves: + if (tokenid == zeroid && DecodeAssetOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, dummyAssetid2, dummyAmount, dummyOrigpubkey) == 't') { + //std::cerr << indentStr << "HeirExactTokenAmounts() will check if this vinx is the tokenbase tokenid=" << tokenid.GetHex() << std::endl; + } + + // checking that the vout of the vintx (that is, referenced by this vin), in its turn, is fed by either from heir' or assets' cryptocondition address: + //std::cerr << indentStr << "HeirExactTokenAmounts() calling IsHeirvout for vintx i=" << i << " prevout.n=" << tx.vin[i].prevout.n << std::endl; + + assetValIndentSize++; + assetoshis = IsHeirvout(compareTotals, cpHeir, eval, tokenid, vinTx, tx.vin[i].prevout.n); + assetValIndentSize--; + if (assetoshis > 0) + inputs += assetoshis; + } + } + } + for (int32_t i = 0; iInvalid("mismatched inputs != outputs + txfee") : false; + } + else { + //std::cerr << indentStr << "HeirExactTokenAmounts() inputs=" << inputs << " vs outputs=" << outputs << " return true" << std::endl; + return(true); + } +}*/ + + +// claim coins tokens validation runner +// sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation() +template bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, bool isHeirSpendingBegan) +{ + int32_t numvins = tx.vin.size(); + int32_t numvouts = tx.vout.size(); + + // setup validation framework (please see its description in heir_validate.h): + // validation 'plans': + CInputValidationPlan vinPlan; + COutputValidationPlan voutPlan; + + // vin 'identifiers' + CNormalInputIdentifier normalInputIdentifier(cp); + CCCInputIdentifier ccInputIdentifier(cp); + + // vin and vout 'validators' + // always check coin inputs: + CMyPubkeyVoutValidator normalInputValidator(cp, fundingOpretScript, true); // check normal input for this opret cause this is first tx + //CMyPubkeyVoutValidator normalInputValidatorLast(cp, latestTxOpRetScript, true); // check normal input for latest opret. TODO: we may also check this opret + + CCC1of2AddressValidator cc1of2ValidatorThis(cp, fundingOpretScript, "checking this tx opreturn:"); // 1of2add validator with pubkeys from this tx opreturn + //CCC1of2AddressValidator cc1of2ValidatorLast(cp, latestTxOpRetScript, "checking last tx opreturn:"); // 1of2add validator with pubkeys from last tx opreturn + CHeirSpendValidator heirSpendValidator(cp, fundingOpretScript, latestTxid, isHeirSpendingBegan); // check if heir allowed to spend + + // only for tokens: + CMyPubkeyVoutValidator ownerCCaddrValidator(cp, fundingOpretScript, false); // check if this correct owner's cc user addr corresponding to opret + //CMyPubkeyVoutValidator ownerCCaddrValidatorLast(cp, latestTxOpRetScript, false); // check if this correct owner's cc user addr corresponding to lastest opret + // TODO: we may also check with current opret + COpRetValidator opRetValidator(cp, fundingOpretScript); // compare opRets in this and last tx + + switch (funcId) { + case 'F': // fund tokens + // vin validation plan: + // we need cast here this is casted inside + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &normalInputValidator); // txfee - see AddNormalInput parameter + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + + // vout validation plan: + voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding + // do not check change at this time + // no checking for opret yet + break; + + case 'A': // add tokens + // vin validation plan: + // we need cast here this is casted inside + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &normalInputValidator/*, &normalInputValidatorLast*/); // txfee - see AddNormalInput parameter + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + + // vout validation plan: + voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding + // do not check change at this time + voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A: + break; + + case 'C': + // vin validation plan: + // we need cast here this is casted inside + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &normalInputValidator/*&normalInputValidatorLast*/); // txfee - see AddNormalInput parameter + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &cc1of2ValidatorThis /*, &cc1of2ValidatorLast*/); // cc1of2 funding addr + + // vout validation plan: + voutPlan.pushValidators(0, &heirSpendValidator); // check if heir is allowed to spend + voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A + break; + } + + // call vin/vout validation + if (!vinPlan.validate(tx, eval)) + return false; + if (!voutPlan.validate(tx, eval)) + return false; + + return true; } -bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +/** + * Tx validation entry function + */ +bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint32_t nIn) { - int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return eval->Invalid("no validation yet"); - std::vector > txids; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - preventCCvins = preventCCvouts = -1; - if ( numvouts < 1 ) + int32_t numvins = tx.vin.size(); + int32_t numvouts = tx.vout.size(); + //int32_t preventCCvins = -1; + //int32_t preventCCvouts = -1; + + if (numvouts < 1) return eval->Invalid("no vouts"); - else - { - for (i=0; iInvalid("illegal normal vini"); - } + + if (chainActive.Height() < 741) + return true; + + uint8_t funcId; + uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, tokenid = zeroid; + + //CScript opRetScript = tx.vout[numvouts - 1].scriptPubKey; + + CScript fundingTxOpRetScript; + bool isHeirSpendingBegan = false; + + int32_t heirType = NOT_HEIR; + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, true); + if(funcId != 0) + heirType = HEIR_COINS; + else { + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, false); + if (funcId != 0) + heirType = HEIR_TOKENS; + } + + if (heirType == NOT_HEIR) + return eval->Invalid("invalid opreturn format"); + + if (funcId != 'F') { + if (fundingTxidInOpret == zeroid) { + return eval->Invalid("invalid tx opreturn format: no fundingtxid present"); } - //fprintf(stderr,"check amounts\n"); - if ( HeirExactAmounts(cp,eval,tx,1,10000) == false ) - { - fprintf(stderr,"Heirget invalid amount\n"); - return false; - } - else - { - txid = tx.GetHash(); - memcpy(hash,&txid,sizeof(hash)); - retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); - if ( retval != 0 ) - fprintf(stderr,"Heirget validated\n"); - else fprintf(stderr,"Heirget invalid\n"); - return(retval); + if (heirType == HEIR_COINS) + latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, isHeirSpendingBegan); + else + latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, isHeirSpendingBegan); + + if (latestTxid == zeroid) { + return eval->Invalid("invalid heir transaction: no funding tx found"); } + } + else { + fundingTxOpRetScript = tx.vout[numvouts - 1].scriptPubKey; + } + + // validate prev tx cc inputs = outputs: + /* if (heirType == HEIR_TOKENS && funcId == 't' && !HeirExactTokenAmounts(true, cp, eval, zeroid, tx)) { + std::cerr << "HeirValidate() this tx or some of its vin tx has invalid cc amounts" << std::endl; + return eval->Invalid("this tx or some of its vin tx has invalid cc amounts"); + } */ + + switch (funcId) { + case 'F': + // fund coins: + // vins.*: normal inputs + // ----------------------------- + // vout.0: funding CC 1of2 addr for the owner and heir + // vout.1: txfee for CC addr used as a marker + // vout.2: normal change + // vout.n-1: opreturn 'F' ownerpk heirpk inactivitytime heirname + + // fund tokens: + // vin.0: normal inputs txfee + // vins.1+: user's CC addr inputs + // ----------------------- + // vout.0: funding heir CC 1of2 addr for the owner and heir + // vout.1: txfee for CC addr used as a marker + // vout.2: normal change + // vout.n-1: opreturn 't' tokenid 'F' ownerpk heirpk inactivitytime heirname tokenid + if (heirType == HEIR_TOKENS) + return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + else + return eval->Invalid("unexpected HeirValidate for heirfund"); + // break; + + case 'A': + // add funding coins: + // vins.*: normal inputs + // ------------------------ + // vout.0: funding CC 1of2 addr for the owner and heir + // vout.1: normal change + // vout.n-1: opreturn 'A' ownerpk heirpk inactivitytime fundingtx + + // add funding tokens: + // vins.0: normal inputs txfee + // vins.1+: user's CC addr inputs + // ------------------------ + // vout.0: funding CC 1of2 addr for the owner and heir + // vout.1: normal change + // vout.n-1: opreturn 't' tokenid 'A' ownerpk heirpk inactivitytime fundingtx + if (heirType == HEIR_TOKENS) + return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + else + return eval->Invalid("unexpected HeirValidate for heiradd"); + //break; + + case 'C': + // claim coins: + // vin.0: normal input txfee + // vin.1+: input from CC 1of2 addr + // ------------------------------------- + // vout.0: normal output to owner or heir address + // vout.1: change to CC 1of2 addr + // vout.2: change to user's addr from txfee input if any + // vout.n-1: opreturn 'C' ownerpk heirpk inactivitytime fundingtx + + // claim tokens: + // vin.0: normal input txfee + // vin.1+: input from CC 1of2 addr + // -------------------------------------------- + // vout.0: output to user's cc address + // vout.1: change to CC 1of2 addr + // vout.2: change to normal from txfee input if any + // vout.n-1: opreturn 't' tokenid 'C' ownerpk heirpk inactivitytime fundingtx + if (heirType == HEIR_TOKENS) + return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + else + return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + // break; + + default: + std::cerr << "HeirValidate() illegal heir funcid=" << (char)funcId << std::endl; + return eval->Invalid("unexpected HeirValidate funcid"); + // break; } + return eval->Invalid("unexpected"); // (PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts)); } // end of consensus code -// helper functions for rpc calls in rpcwallet.cpp -int64_t AddHeirInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +// helper functions used in implementations of rpc calls (in rpcwallet.cpp) or validation code + +/** +* Checks if vout is to cryptocondition address +* @return vout value in satoshis +*/ +int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) { - // add threshold check - char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; - std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; + char destaddr[65], heirContractAddr[65]; + + GetCCaddress1of2(cp, heirContractAddr, ownerPubkey, heirPubkey); + if (tx.vout[voutIndex].scriptPubKey.IsPayToCryptoCondition() != 0) { + // NOTE: dimxy it was unsafe 'Getscriptaddress(destaddr,tx.vout[voutIndex].scriptPubKey) > 0' here: + if (Getscriptaddress(destaddr, tx.vout[voutIndex].scriptPubKey) && strcmp(destaddr, heirContractAddr) == 0) + return (tx.vout[voutIndex].nValue); + } + return (0); +} + +// not used +bool HeirExactAmounts(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, int32_t minage, uint64_t txfee) +{ + static uint256 zerohash; + CTransaction vinTx; + uint256 hashBlock, activehash; + int32_t i, numvins, numvouts; + int64_t inputs = 0, outputs = 0, assetoshis; + numvins = tx.vin.size(); + numvouts = tx.vout.size(); + for (i = 0; i < numvins; i++) { + //fprintf(stderr,"HeirExactAmounts() vini.%d\n",i); + if ((*cp->ismyvin)(tx.vin[i].scriptSig) != 0) { + //fprintf(stderr,"HeirExactAmounts() vini.%d check mempool\n",i); + if (eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) + return eval->Invalid("cant find vinTx"); + else { + //fprintf(stderr,"HeirExactAmounts() vini.%d check hash and vout\n",i); + if (hashBlock == zerohash) + return eval->Invalid("cant Heir from mempool"); + ////if ( (assetoshis= IsHeirCCvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) + //// inputs += assetoshis; + } + } + } + for (i = 0; i < numvouts; i++) { + //fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts); + ////if ( (assetoshis= IsHeirvout(cp,tx,i)) != 0 ) + //// outputs += assetoshis; + } + if (inputs != outputs + txfee) { + fprintf(stderr, "HeirExactAmounts() inputs %llu vs outputs %llu\n", (long long)inputs, (long long)outputs); + return eval->Invalid("mismatched inputs != outputs + txfee"); + } + else + return (true); +} + +// makes coin initial tx opret +CScript EncodeHeirCreateOpRet(uint8_t eval, uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) +{ + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); +} + +// makes coin additional tx opret +CScript EncodeHeirOpRet(uint8_t eval, uint8_t funcid, uint256 fundingtxid) +{ + fundingtxid = revuint256(fundingtxid); + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)funcid << fundingtxid); +} +// makes opret for tokens while they are inside Heir contract address space - initial funding +CScript EncodeHeirAssetsCreateOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) +{ + tokenid = revuint256(tokenid); + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)'t' << tokenid << (uint8_t)funcid << ownerPubkey << heirPubkey << inactivityTimeSec << hearName); +} +// makes opret for tokens while they are inside Heir contract address space - additional funding +CScript EncodeHeirAssetsOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, uint256 fundingtxid) +{ + tokenid = revuint256(tokenid); + fundingtxid = revuint256(fundingtxid); + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)'t' << tokenid << (uint8_t)funcid << fundingtxid); +} + +/** +* decode opret vout for Heir contract +*/ +template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, bool noLogging) +{ + std::vector vopret; + uint8_t opretEval = 0; + uint8_t funcId = 0; + + fundingTxidInOpret = zeroid; //to init + + GetOpReturnData(scriptPubKey, vopret); + + if (vopret.size() > 1) { + // NOTE: it unmarshals for all F, A and C + Helper::UnmarshalOpret(vopret, opretEval, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret); + + /* + std::cerr << "DecodeHeirOpRet() e=" << (int)e + << " funcId=" << (char)funcId + << " ownerPubkey=" << HexStr(ownerPubkey) + << " heirPubkey=" << HexStr(heirPubkey) + << " heirName=" << heirName << " inactivityTime=" << inactivityTime << '\n'; + */ + + //if (e == EVAL_HEIR && IS_CHARINSTR(funcId, "FAC")) + if (opretEval == EVAL_HEIR && Helper::isMyFuncId(funcId)) { + tokenid = revuint256(tokenid); + fundingTxidInOpret = revuint256(fundingTxidInOpret); + return funcId; + } + else + { + if(!noLogging) std::cerr << "DecodeHeirOpRet() warning unexpected OP_RETURN eval=" << (int)opretEval << " or field type=" << (char)(funcId ? funcId : ' ') << '\n'; + } + } + else { + std::cerr << "DecodeHeirOpRet() unmarshal error (vopret.size() == 0)" << '\n'; + } + return (uint8_t)0; +} + +/** +* overload for 'F' opret +*/ +template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) +{ + uint256 dummytxid; + + return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, noLogging); +} + +/** +* overload for A, C oprets and AddHeirContractInputs +*/ +template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxidInOpret, bool noLogging) +{ + CPubKey dummyOwnerPubkey, dummyHeirPubkey; + int64_t dummyInactivityTime; + std::string dummyHeirName; + + return _DecodeHeirOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, noLogging); +} + + + +/** + * find the latest funding tx: it may be the first F tx or one of A or C tx's + * Note: this function is also called from validation code (use non-locking calls) + */ +template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, bool &isHeirSpendingBegan) +{ + CTransaction fundingtx; + uint256 hashBlock; + const bool allowSlow = false; + + //char markeraddr[64]; + //CCtxidaddr(markeraddr, fundingtxid); + //SetCCunspents(unspentOutputs, markeraddr); + + isHeirSpendingBegan = false; //init the var + funcId = 0; //init the var + + // get initial funding tx and set it as initial lasttx: + if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { + uint256 dummytxid; + + // set ownerPubkey and heirPubkey: + if ((funcId = DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName)) != 0) { + // found at least funding tx! + std::cerr << "FindLatestFundingTx() lasttx currently is fundingtx, txid=" << fundingtxid.GetHex() << " opreturn type=" << (char)funcId << '\n'; + fundingOpretScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; + } else { + std::cerr << "FindLatestFundingTx() could not decode opreturn for fundingtxid=" << fundingtxid.GetHex() << '\n'; + return zeroid; + } + } else { + std::cerr << "FindLatestFundingTx() could not find funding tx for fundingtxid=" << fundingtxid.GetHex() << '\n'; + return zeroid; + } + + std::vector> unspentOutputs; + struct CCcontract_info *cp, C; + cp = CCinit(&C, Helper::getMyEval()); + char coinaddr[64]; + GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' + + SetCCunspents(unspentOutputs, coinaddr); // get vector with tx's with unspent vouts of 1of2pubkey address: + //std::cerr << "FindLatestFundingTx() using 1of2address=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + + int32_t maxBlockHeight = 0; // max block height + uint256 latesttxid = fundingtxid; + + // try to find the last funding or spending tx by checking fundingtxid in 'opreturn': + for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { + CTransaction regtx; + uint256 hash; + + uint256 txid = it->first.txhash; + //std::cerr << "FindLatestFundingTx() checking unspents for txid=" << txid.GetHex() << '\n'; + + int32_t blockHeight = (int32_t)it->second.blockHeight; + uint256 fundingTxidInOpret; + + //NOTE: maybe called from validation code: + if (myGetTransaction(txid, regtx, hash)) { + std::cerr << "FindLatestFundingTx() found tx for txid=" << txid.GetHex() << " blockHeight=" << blockHeight << " maxBlockHeight=" << maxBlockHeight << '\n'; + + { // debug code: + uint256 debAssetid; + uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, true); + std::cerr << "FindLatestFundingTx() regtx.vout.size()=" << regtx.vout.size() << " funcId=" << (char)(debfuncid ? debfuncid : ' ') << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << std::endl; + } + + uint256 dummyTokenid; // not to contaminate the tokenid from the params! + uint8_t tmpFuncId; + + if (regtx.vout.size() > 0 && + (tmpFuncId = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, true)) != 0 && + fundingtxid == fundingTxidInOpret) { + + // check if heir has begun spending: + if (Helper::isSpendingTx(tmpFuncId)) { // if 'C' or 't' opret + const CScript heirScriptPubkey = CScript() << ParseHex(HexStr(heirPubkey)) << OP_CHECKSIG; + + for (int32_t v = 0; v < regtx.vout.size() - 1; v++) { // do not check opret vout + if (heirScriptPubkey == regtx.vout[v].scriptPubKey) + isHeirSpendingBegan = true; + } + } + + if (blockHeight > maxBlockHeight) { + maxBlockHeight = blockHeight; + latesttxid = txid; + ///// fundingOpretScript = regtx.vout[regtx.vout.size() - 1].scriptPubKey; + funcId = tmpFuncId; + std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight << " opreturn type=" << (char)(funcId ? funcId : ' ') << " set as current lasttxid" << '\n'; + } + } + } + } + + return latesttxid; +} + +// overload for validation code +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, bool &isHeirSpendingBegan) +{ + uint8_t funcId; + CPubKey ownerPubkey; + CPubKey heirPubkey; + int64_t inactivityTime; + std::string heirName; + + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, isHeirSpendingBegan); +} + +// overload for transaction creation code +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool &isHeirSpendingBegan) +{ + CScript opRetScript; + + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, isHeirSpendingBegan); +} + +// add owner input in tokens +/*int64_t AddHeirTokenInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 refassetid, int64_t total, int32_t maxinputs) +{ + char coinaddr[64], destaddr[64]; int64_t threshold, nValue, price, totalinputs = 0; uint256 tokenid, txid, hashBlock; std::vector origpubkey; std::vector vopret; CTransaction vintx; int32_t j, vout, n = 0; uint8_t evalcode, funcid; + std::vector > unspentOutputs; + GetCCaddress(cp, coinaddr, pk); + SetCCunspents(unspentOutputs, coinaddr); + threshold = total / (maxinputs + 1); + + //fprintf(stderr,"AddHeirTokenInputs() check cc addr=%s for token inputs\n",coinaddr); + for (std::vector >::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + + if (it->second.satoshis < threshold) + continue; + for (j = 0; jsecond=" << it->second.satoshis << std::endl; + + if (strcmp(destaddr, coinaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) + continue; + GetOpReturnData(vintx.vout[vintx.vout.size() - 1].scriptPubKey, vopret); + + // NOTE: special opret decode: + // we should not check for E_UNMARSHAL return code because it returns false if not EOF, + // but we have our remainder after tokenid! + bool isEof = false; + bool unmarshalResult = E_UNMARSHAL(vopret, ss >> evalcode; ss >> funcid; ss >> tokenid; isEof=ss.eof()); + if (unmarshalResult || !isEof) + { + tokenid = revuint256(tokenid); // usually DecodeOpretXXX() funcs do this + + //std::cerr << "AddHeirTokenInputs() vout=" << vout << " evalcode=" << (int)evalcode << " cp->evalcode=" << (int)cp->evalcode << " funcid=" << (char)funcid << " check for refassetid=" << refassetid.GetHex() << " vs tokenid in opret=" << tokenid.GetHex() << " coins=" << (double)vintx.vout[vout].nValue / COIN << std::endl; + if (tokenid == refassetid && + IS_CHARINSTR(funcid, "tGB") && + (nValue = vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + { + std::cerr << "AddHeirTokenInputs() total=" << total << " maxinputs=" << maxinputs << " uxto value=" << it->second.satoshis << std::endl; + if (total != 0 && maxinputs != 0) + mtx.vin.push_back(CTxIn(txid, vout, CScript())); + //nValue = it->second.satoshis; + totalinputs += nValue; + n++; + if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) + break; + } + } + } + } + return(totalinputs); +}*/ + +// add inputs of 1 of 2 cc address +template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs) +{ + // TODO: add threshold check + int64_t nValue, voutValue, totalinputs = 0; + CTransaction vintx; + int32_t n = 0; + std::vector> unspentOutputs; + + char coinaddr[64]; + GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 pubkey of 2 pubkeys' + SetCCunspents(unspentOutputs, coinaddr); + + // char markeraddr[64]; + // CCtxidaddr(markeraddr, fundingtxid); + // SetCCunspents(unspentOutputs, markeraddr); + //std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + + for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { + uint256 txid = it->first.txhash; + uint256 hashBlock; + int32_t voutIndex = (int32_t)it->first.index; // no need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) - { - if ( (nValue= IsHeirvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) - { - if ( total != 0 && maxinputs != 0 ) - mtx.vin.push_back(CTxIn(txid,vout,CScript())); + // dimxy: maybe it is good to put tx's in cache? + if (GetTransaction(txid, vintx, hashBlock, false) != 0) { + uint256 tokenid; + uint256 fundingTxidInOpret; + + uint8_t funcId = DecodeHeirOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, true); + // note: it returns in in satoshis too... + if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && // we're spending only tx's in this funding plan + funcId != 0 && + Helper::isMyFuncId(funcId) && + // deep validation for tokens: + (typeid(Helper) == typeid(TokenHelper) && IsHeirvout(true, cp, nullptr, tokenid, vintx, voutIndex) > 0) && + (voutValue = IsHeirFundingVout(cp, vintx, voutIndex, ownerPubkey, heirPubkey)) > 0 && + !myIsutxo_spentinmempool(txid, voutIndex)) + { + std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; + if (total != 0 && maxinputs != 0) + mtx.vin.push_back(CTxIn(txid, voutIndex, CScript())); nValue = it->second.satoshis; totalinputs += nValue; n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) + if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; } } } - return(totalinputs); + return totalinputs; } -std::string HeirGet(uint64_t txfee,int64_t nValue) +/** + * enumerate all tx's sending to CCHeir 1of2address and calc total lifetime funds + */ +template int64_t LifetimeHeirContractFunds(struct CCcontract_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) { - CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Heirpk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; - cp = CCinit(&C,EVAL_HEIR); - if ( txfee == 0 ) - txfee = 10000; - Heirpk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddHeirInputs(cp,mtx,Heirpk,nValue+txfee,60)) > 0 ) - { - if ( inputs > nValue ) - CCchange = (inputs - nValue - txfee); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_HEIR,CCchange,Heirpk)); - mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - fprintf(stderr,"start at %u\n",(uint32_t)time(NULL)); - j = rand() & 0xfffffff; - for (i=0; i<1000000; i++,j++) - { - tmpmtx = mtx; - rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_HEIR << (uint8_t)'G' << j)); - if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 ) + char coinaddr[64]; + GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' + + std::vector> addressIndexes; + SetCCtxids(addressIndexes, coinaddr); + + //fprintf(stderr,"LifetimeHeirContractFunds() scan lifetime of %s\n",coinaddr); + int64_t total = 0; + for (std::vector>::const_iterator it = addressIndexes.begin(); it != addressIndexes.end(); it++) { + uint256 hashBlock; + uint256 txid = it->first.txhash; + CTransaction tx; + + if (GetTransaction(txid, tx, hashBlock, false) && tx.vout.size() > 0) { + uint8_t funcId; + uint256 tokenid; + uint256 fundingTxidInOpret; + const int32_t ivout = 0; + + funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, true); + + //std::cerr << "LifetimeHeirContractFunds() found tx=" << txid.GetHex() << " vout[0].nValue=" << subtx.vout[ccVoutIdx].nValue << " opreturn=" << (char)funcId << '\n'; + + if (funcId != 0 && (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && Helper::isMyFuncId(funcId) && !Helper::isSpendingTx(funcId) + /* && !myIsutxo_spentinmempool(txid, ccVoutIdx) */) // include also tx in mempool { - len >>= 1; - decode_hex(buf,len,(char *)rawhex.c_str()); - hash = bits256_doublesha256(0,buf,len); - if ( (hash.bytes[0] & 0xff) == 0 && (hash.bytes[31] & 0xff) == 0 ) - { - fprintf(stderr,"found valid txid after %d iterations %u\n",i,(uint32_t)time(NULL)); - return(rawhex); - } - //fprintf(stderr,"%02x%02x ",hash.bytes[0],hash.bytes[31]); + total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) + std::cerr << "LifetimeHeirContractFunds() added tx=" << txid.GetHex() << " it->second=" << it->second << " vout[0].nValue=" << tx.vout[ivout].nValue << " opreturn=" << (char)funcId << '\n'; } } - fprintf(stderr,"couldnt generate valid txid %u\n",(uint32_t)time(NULL)); - return(""); - } else fprintf(stderr,"cant find Heir inputs\n"); - return(""); -} - -std::string HeirFund(uint64_t txfee,int64_t funds) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Heirpk; CScript opret; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_HEIR); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - Heirpk = GetUnspendable(cp,0); - if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) - { - mtx.vout.push_back(MakeCC1vout(EVAL_HEIR,funds,Heirpk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); } - return(""); + return (total); } -UniValue HeirInfo() +/* rpc functions' implementation: */ + +/** + * heirfund rpc call implementation + * creates tx for initial funds deposit on cryptocondition address which locks funds for spending by either of address. + * and also for setting spending plan for the funds' owner and heir + * @return fundingtxid handle for subsequent references to this heir funding plan + */ +template std::string HeirFund(uint64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char numstr[64]; - CPubKey Heirpk; struct CCcontract_info *cp,C; int64_t funding; - result.push_back(Pair("result","success")); - result.push_back(Pair("name","Heir")); - cp = CCinit(&C,EVAL_HEIR); - Heirpk = GetUnspendable(cp,0); - funding = AddHeirInputs(cp,mtx,Heirpk,0,0); - sprintf(numstr,"%.8f",(double)funding/COIN); - result.push_back(Pair("funding",numstr)); - return(result); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + struct CCcontract_info *cp, C; + + cp = CCinit(&C, Helper::getMyEval()); + if (txfee == 0) + txfee = 10000; + + //std::cerr << "HeirFund() amount=" << amount << " txfee=" << txfee << " heirPubkey IsValid()=" << heirPubkey.IsValid() << " inactivityTime(sec)=" << inactivityTimeSec << " tokenid=" << tokenid.GetHex() << std::endl; + + if (!heirPubkey.IsValid()) { + std::cerr << "HeirFund() heirPubkey is not valid!" << std::endl; + return std::string(""); + } + + CPubKey myPubkey = pubkey2pk(Mypubkey()); + + if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners + int64_t inputs, change; + + if ((inputs=Helper::addOwnerInputs(cp, tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners + //mtx.vout.push_back(MakeCC1vout(EVAL_HEIR,amount,HeirCCpk)); + mtx.vout.push_back(MakeCC1of2vout(Helper::getMyEval(), amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk + + // add a marker for finding all plans in HeirList() + CPubKey HeirContractPubKey = GetUnspendable(cp, 0); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(HeirContractPubKey)) << OP_CHECKSIG)); // TODO: do we need this marker? + + // calc and add change vout: + if (inputs > amount) + change = (inputs - amount); // -txfee <-- txfee pays user + + //std::cerr << "HeirFund() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; + + if (change != 0) { // vout[1] + mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); + } + + // add change for txfee and opreturn vouts and sign tx: + return (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + // CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_HEIR << (uint8_t)'F' << myPubkey << heirPubkey << inactivityTimeSec << heirName))); + Helper::makeCreateOpRet(tokenid, myPubkey, heirPubkey, inactivityTimeSec, heirName))); + } + else // TODO: need result return unification with heiradd and claim + std::cerr << "HeirFund() could not find owner inputs" << std::endl; + + } + else + std::cerr << "HeirFund() could not find normal inputs" << std::endl; + return std::string(""); +} + +// if no these callers - it could not link +std::string HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ + return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); +} + +std::string HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { + return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); +} + +/** + * heiradd rpc call implementation + * creates tx to add more funds to cryptocondition address for spending by either funds' owner or heir + * @return result object with raw tx or error text + */ +template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount) +{ + UniValue result(UniValue::VOBJ); //, a(UniValue::VARR); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey ownerPubkey, heirPubkey; + int64_t inputs, CCchange = 0; + int64_t inactivityTimeSec; + struct CCcontract_info *cp, C; + std::string rawhex; + uint256 lasttxid, tokenid; + std::string heirName; + uint8_t funcId; + bool isHeirSpendingBegan = false; + + cp = CCinit(&C, Helper::getMyEval()); + if (txfee == 0) + txfee = 10000; + + if ((lasttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan)) != zeroid) { + int32_t numblocks; + + CPubKey myPubkey = pubkey2pk(Mypubkey()); + + // check if it is the owner + if (myPubkey != ownerPubkey) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "adding funds is only allowed for the owner of this contract")); + return result; + } + + if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners + + int64_t inputs, change; + + //if (AddNormalinputs(mtx, myPubkey, amount + 1 * txfee, 64) > 0) { // TODO: why 64 max inputs? + if ((inputs = Helper::addOwnerInputs(cp, tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? + + // we do not use markers anymore - storing data in opreturn is better + // add marker vout: + /* char markeraddr[64]; + CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners + std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ + + // add cryptocondition to spend this funded amount for either pk + mtx.vout.push_back(MakeCC1of2vout(Helper::getMyEval(), amount, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! + + // calc and add change vout: + if (inputs > amount) + change = (inputs - amount); // -txfee <-- txfee pays user + + //std::cerr << "HeirAdd() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; + + if (change != 0) { // vout[1] + mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); + } + + // add opreturn 'A' and sign tx: // this txfee ignored + std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeAddOpRet(tokenid, fundingtxid))); + + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd cannot find owner inputs" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find owner inputs")); + } + } + else { + std::cerr << "HeirAdd cannot find normal inputs for tx fee" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find normal inputs for tx fee")); + } + + } else { + fprintf(stderr, "HeirAdd() can't find any heir CC funding tx's\n"); + + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find any heir CC funding transactions")); + } + + return result; +} + + +UniValue HeirAddCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { + return HeirAdd(fundingtxid, txfee, amount); +} +UniValue HeirAddTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { + return HeirAdd(fundingtxid, txfee, amount); +} + + +/** + * heirclaim rpc call implementation + * creates tx to spend funds from cryptocondition address by either funds' owner or heir + * @return result object with raw tx or error text + */ +template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t amount) +{ + UniValue result(UniValue::VOBJ); //, a(UniValue::VARR); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey myPubkey, ownerPubkey, heirPubkey; + int64_t inputs, change = 0; + int64_t inactivityTimeSec; + struct CCcontract_info *cp, C; + + uint256 latesttxid, tokenid; + uint8_t funcId; + std::string heirName; + bool isHeirSpendingBegan = false; + + + cp = CCinit(&C, Helper::getMyEval()); + if (txfee == 0) + txfee = 10000; + + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan)) != zeroid) { + int32_t numblocks; + uint64_t durationSec = 0; + + // we do not need to find duration if spending already has begun + if (!isHeirSpendingBegan) { + durationSec = CCduration(numblocks, latesttxid); + std::cerr << "HeirClaim() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << std::endl; + } + + // spending is allowed if there is already spending tx or inactivity time + //bool isAllowedToHeir = (funcId == 'C' || durationSec > inactivityTimeSec) ? true : false; + bool isAllowedToHeir = (isHeirSpendingBegan || durationSec > inactivityTimeSec) ? true : false; + myPubkey = pubkey2pk(Mypubkey()); + + // if it is the heir, check if spending not allowed to heir yet + if (myPubkey == heirPubkey && !isAllowedToHeir) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "spending is not allowed yet for the heir")); + return result; + } + + // we do not use markers any more: + // we allow owner to spend funds at any time: + // if it is the owner, check if spending already allowed to heir + /* if (myPubkey == ownerPubkey && isAllowedToHeir) { + result.push_back(Pair("result", "spending is not already allowed for the owner")); + return result; + } */ + + // add spending txfee from the calling user + if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { + + // add spending from cc 1of2 address + if ((inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, amount, 60)) >= amount) // TODO: why only 60 inputs? + { + /*if (inputs < amount) { + std::cerr << "HeirClaim() cant find enough HeirCC 1of2 inputs, found=" << inputs << " required=" << amount << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find heir CC funding")); + + return result; + }*/ + + // add vout with amount to claiming address + mtx.vout.push_back(Helper::makeClaimerVout(amount, myPubkey)); // vout[0] + + // calc and add change vout: + if (inputs > amount) + change = (inputs - amount); // -txfee <-- txfee pays user + + //std::cerr << "HeirClaim() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; + + // change to 1of2 funding addr: + if (change != 0) { // vout[1] + mtx.vout.push_back(MakeCC1of2vout(Helper::getMyEval(), change, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! + } + + // add marker vout: + /*char markeraddr[64]; + CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); + // NOTE: amount = 0 is not working: causes error code: -26, error message : 64 : dust + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners + std::cerr << "HeirClaim() adding markeraddr=" << markeraddr << '\n'; */ + + uint8_t myprivkey[32]; + char coinaddr[64]; + // set priv key addresses in CC structure: + GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + Myprivkey(myprivkey); + + //fprintf(stderr,"HeirClaim() before setting unspendable CC addr2= (%s) addr3= (%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); + CCaddr2set(cp, Helper::getMyEval(), ownerPubkey, myprivkey, coinaddr); + CCaddr3set(cp, Helper::getMyEval(), heirPubkey, myprivkey, coinaddr); + + fprintf(stderr, "HeirClaim() after setting unspendable CC addr2=(%s) addr3=(%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); + + // add opreturn 'C' and sign tx: // this txfee will be ignored + std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeClaimOpRet(tokenid, fundingtxid)); + + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + + } else { + fprintf(stderr, "HeirClaim() cant find Heir CC inputs\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find heir CC funding")); + } + } else { + fprintf(stderr, "HeirClaim() cant find sufficient user inputs for tx fee\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find sufficient user inputs to pay transaction fee")); + } + } else { + fprintf(stderr, "HeirClaim() can't find any heir CC funding tx's\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find any heir CC funding transactions")); + } + + return result; +} + +UniValue HeirClaimCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { + return HeirClaim(fundingtxid, txfee, amount); +} +UniValue HeirClaimTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { + return HeirClaim(fundingtxid, txfee, amount); +} + + + +/** + * heirinfo rpc call implementation + * returns some information about heir CC contract plan by a handle of initial fundingtxid: + * plan name, owner and heir pubkeys, funds deposited and available, flag if spending is enabled for the heir + * @return heir info data + */ +UniValue HeirInfo(uint256 fundingtxid) +{ + UniValue result(UniValue::VOBJ); + + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey ownerPubkey, heirPubkey; + uint256 latestFundingTxid; + uint256 dummyTokenid, tokenid; + + std::string heirName; + uint8_t funcId; + int64_t inactivityTimeSec; + + CTransaction fundingtx; + uint256 hashBlock; + const bool allowSlow = false; + + //char markeraddr[64]; + //CCtxidaddr(markeraddr, fundingtxid); + //SetCCunspents(unspentOutputs, markeraddr); + + // get initial funding tx and set it as initial lasttx: + if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { + + int32_t heirType = NOT_HEIR; + if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true) == 'F') + heirType = HEIR_COINS; + else if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true) == 'F') + heirType = HEIR_TOKENS; + else + { + std::cerr << "HeirInfo() initial tx F not found for this fundingtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "initial tx F not found")); + return result; + } + + struct CCcontract_info *cp, C; + if (heirType == HEIR_COINS) + cp = CCinit(&C, CoinHelper::getMyEval()); + else + cp = CCinit(&C, TokenHelper::getMyEval()); + + bool isHeirSpendingBegan = false; + + if (heirType == HEIR_COINS) + latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan); + else + latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan); + + if (latestFundingTxid != zeroid) { + int32_t numblocks; + uint64_t durationSec = 0; + + std::cerr << "HeirInfo() latesttxid=" << latestFundingTxid.GetHex() << '\n'; + + std::ostringstream stream; + std::string msg; + + result.push_back(Pair("fundingtxid", fundingtxid.GetHex())); + result.push_back(Pair("name", heirName.c_str())); + + if (heirType == HEIR_TOKENS) { + stream << tokenid.GetHex(); + msg = "tokenid"; + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + } + + char hexbuf[67]; + stream << pubkey33_str(hexbuf, (uint8_t*)ownerPubkey.begin()); + result.push_back(Pair("owner", stream.str().c_str())); + stream.str(""); + stream.clear(); + + stream << pubkey33_str(hexbuf, (uint8_t*)heirPubkey.begin()); + result.push_back(Pair("heir", stream.str().c_str())); + stream.str(""); + stream.clear(); + + int64_t total; + if (heirType == HEIR_COINS) + total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); + else + total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); + + if (heirType == HEIR_COINS) { + msg = "funding total in coins"; + stream << (double)total / COIN; + } + else { + msg = "funding total in tokens"; + stream << total; + } + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + + int64_t inputs; + if (heirType == HEIR_COINS) + inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); //NOTE: amount = 0 means all unspent inputs + else + inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); + + if (heirType == HEIR_COINS) { + msg = "funding available in coins"; + stream << (double)inputs / COIN; + } + else { + msg = "funding available in tokens"; + stream << inputs; + } + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + + if (heirType == HEIR_TOKENS) { + int64_t ownerInputs = TokenHelper::addOwnerInputs(cp, tokenid, mtx, ownerPubkey, 0, (int32_t)64); + stream << ownerInputs; + msg = "owner funding available in tokens"; + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + } + + stream << inactivityTimeSec; + result.push_back(Pair("inactivity time setting", stream.str().c_str())); + stream.str(""); + stream.clear(); + + if (!isHeirSpendingBegan) { // we do not need find duration if the spending already has begun + durationSec = CCduration(numblocks, latestFundingTxid); + std::cerr << "HeirInfo() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << '\n'; + } + + stream << std::boolalpha << (isHeirSpendingBegan || durationSec > inactivityTimeSec); + result.push_back(Pair("spending allowed for the heir", stream.str().c_str())); + stream.str(""); + stream.clear(); + + result.push_back(Pair("result", "success")); + } + else { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find heir cc plan for this txid")); + } + } + else { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find heir cc plan for this txid (no initial tx)")); + } + return (result); +} + +/** + * heirlist rpc call implementation + * @return list of heir plan handles (fundingtxid) + */ + +template void _HeirList(struct CCcontract_info *cp, UniValue &result) +{ + std::vector> unspentOutputs; + char coinaddr[64]; + CPubKey ccPubKeyEmpty; + GetCCaddress(cp, coinaddr, ccPubKeyEmpty); + SetCCunspents(unspentOutputs, cp->normaladdr); + + std::cerr << "HeirList() finding heir marker from Heir contract addr=" << cp->normaladdr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + + // TODO: move marker to special cc addr to prevent checking all tokens + for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { + uint256 hashBlock; + uint256 txid = it->first.txhash; + uint256 tokenid; + int32_t vout = (int32_t)it->first.index; + + std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; + + CTransaction vintx; + if (GetTransaction(txid, vintx, hashBlock, false) != 0 && (vintx.vout.size() - 1) > 0) { + CPubKey ownerPubkey, heirPubkey; + std::string heirName; + int64_t inactivityTimeSec; + + uint8_t funcId = DecodeHeirOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + + // note: if it is not Heir token funcId would be equal to 0 + if (funcId == 'F') { + result.push_back(Pair("fundingtxid heirName", txid.GetHex() + std::string(" ") + (typeid(Helper) == typeid(TokenHelper) ? std::string("token") : std::string("coin")) + std::string(" ") + heirName)); + } + else { + fprintf(stderr, "HeirList() couldnt find initial transaction\n"); + } + } + else { + fprintf(stderr, "HeirList() couldnt load transaction\n"); + } + } +} + + +UniValue HeirList() +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result", "success")); + + struct CCcontract_info *cpHeir, *cpTokens, C; + + cpHeir = CCinit(&C, EVAL_HEIR); + cpTokens = CCinit(&C, EVAL_TOKENS); + + _HeirList(cpHeir, result); + _HeirList(cpTokens, result); + + return result; } diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h new file mode 100644 index 000000000..8b432e8e0 --- /dev/null +++ b/src/cc/heir_validate.h @@ -0,0 +1,622 @@ +#ifndef HEIR_VALIDATE_H +#define HEIR_VALIDATE_H + +#include "CCinclude.h" +#include "CCHeir.h" + +#define NOT_HEIR (-1) +#define HEIR_COINS 1 +#define HEIR_TOKENS 2 +#define IS_CHARINSTR(c, str) (std::string(str).find((char)(c)) != std::string::npos) + + +// makes coin initial tx opret +CScript EncodeHeirCreateOpRet(uint8_t eval, uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); +// makes coin additional tx opret +CScript EncodeHeirOpRet(uint8_t eval, uint8_t funcid, uint256 fundingtxid); + +CScript EncodeHeirAssetsCreateOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName); +CScript EncodeHeirAssetsOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, uint256 fundingtxid); +//CScript EncodeHeirConvertedAssetsOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 fundingtxid); + +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, bool &isHeirSpendingBegan); +template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxid, bool noLogging = false); +//template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); + +//int64_t AddHeirTokenInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 reftokenid, int64_t total, int32_t maxinputs); + + +// helper class to allow polymorphic behaviour for HeirXXX() functions in case of coins +class CoinHelper { +public: + + static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } + static uint8_t getMyEval() { return EVAL_HEIR; } + static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { + return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); + } + + static CScript makeCreateOpRet(uint256 dummyid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { + return EncodeHeirCreateOpRet((uint8_t)EVAL_HEIR, (uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + } + static CScript makeAddOpRet(uint256 dummyid, uint256 fundingtxid) { + return EncodeHeirOpRet((uint8_t)EVAL_HEIR, (uint8_t)'A', fundingtxid); + } + static CScript makeClaimOpRet(uint256 dummyid, uint256 fundingtxid) { + return EncodeHeirOpRet((uint8_t)EVAL_HEIR, (uint8_t)'C', fundingtxid); + } + + static void UnmarshalOpret(std::vector vopret, uint8_t &e, uint8_t &funcId, uint256 &dummytokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret) { + E_UNMARSHAL(vopret, { ss >> e; ss >> funcId; ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; if (IS_CHARINSTR(funcId, "F")) { ss >> heirName; } if (IS_CHARINSTR(funcId, "AC")) { ss >> fundingTxidInOpret; } }); + } + + static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } + + static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { + return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); + } + static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { + return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); + } +}; + +// helper class to allow polymorphic behaviour for HeirXXX() functions in case of tokens +class TokenHelper { +public: + + static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } + static uint8_t getMyEval() { return EVAL_TOKENS; } + static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { + return AddTokenCCInputs(cp, mtx, ownerPubkey, tokenid, total, maxinputs); + } + + static CScript makeCreateOpRet(uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { + return EncodeHeirAssetsCreateOpRet((uint8_t)EVAL_HEIR, (uint8_t)'F', tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + } + static CScript makeAddOpRet(uint256 tokenid, uint256 fundingtxid) { + return EncodeHeirAssetsOpRet((uint8_t)EVAL_HEIR, (uint8_t)'A', tokenid, fundingtxid); + } + static CScript makeClaimOpRet(uint256 tokenid, uint256 fundingtxid) { + return EncodeHeirAssetsOpRet((uint8_t)EVAL_HEIR, (uint8_t)'C', tokenid, fundingtxid); + } + + static void UnmarshalOpret(std::vector vopret, uint8_t &e, uint8_t &funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingtxidInOpret) { + uint8_t assetFuncId = '\0'; + bool result = E_UNMARSHAL(vopret, { ss >> e; ss >> assetFuncId; ss >> tokenid; ss >> funcId; if (IS_CHARINSTR(funcId, "F")) { ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; } if (IS_CHARINSTR(funcId, "AC")) { ss >> fundingtxidInOpret; } }); + if (!result /*|| assetFuncId != 't' -- any tx is ok*/) + funcId = 0; + } + static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } + + static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { + return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); + } + static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { + return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); + } +}; + +//#define OPTIONAL_VOUT 0 // if vout is optional then in a validation plan it will be skipped without error, if all validators return false + + + +/** +* Small framework for vins and vouts validation implementing a variation of 'chain of responsibility' pattern: +* It consists of two classes CInputValidationPlan and COutputValidationPlan which both are configured with an array of vectors of validators +* (These validators are derived from the class CValidatorBase). +* +* A example of a validator may verify for a vout if its public key corresponds to the public key which is stored in opreturn. +* Or, vin validator may check if this vin depicts correctly to the CC contract's address. +* +* For validating vins CInputValidator additionally is provided with an instance of a class derived from the CInputIdentifierBase class. +* this identifier class allows to select identical vins (for example, normal vins or cc input vins) and apply validators from the corresponding vector to it. +* Note: CInputValidator treats that at least one identified vin should be present, otherwise it returns eval->invalid() and false. +* +* For validating vouts COutputValidator is configured for each vector of validators with the vout index to which these validators are applied +* (see constructors of both CInputValidator and COutputValidator) +* +* +* Base class for all validators +*/ +/** + * base class for all validators + */ +class CValidatorBase +{ +public: + CValidatorBase(CCcontract_info* cp) : m_cp(cp) {} + virtual bool isVinValidator() const = 0; + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0; + virtual bool validateVout(CTxOut vout, std::string& message) const = 0; + +protected: + CCcontract_info * m_cp; +}; + + +/** + * Base class for classes which identify vins as normal or cc inputs + */ +class CInputIdentifierBase +{ +public: + CInputIdentifierBase(CCcontract_info* cp) : m_cp(cp) {} + virtual std::string inputName() const = 0; + virtual bool identifyInput(CTxIn vin) const = 0; +protected: + CCcontract_info * m_cp; +}; + + + + +/** +* Encapsulates an array containing rows of validators +* Each row is a vector of validators (zero is possible) for validating vins or prev tx's vouts +* this validation plan is used for validating tx inputs +*/ +template +class CInputValidationPlan +{ + using ValidatorsRow = std::vector; + +public: + + // Pushes a row of validators for validating a vin or vout + // @param CInputIdentifierBase* pointer to class-identifier which determines several identical adjacent vins (like in schema "vin.0+: normal inputs") + // @param pargs parameter pack of zero or more pointer to validator objects + // Why pointers? because we store the base class in validators' row and then call its virtual functions + template + void pushValidators(CInputIdentifierBase *identifier, ARGS*... pargs) // validators row passed as variadic arguments CValidatorX *val1, CValidatorY *val2 ... + { + ValidatorsRow vValidators({ (TValidatorBase*)pargs... }); + m_arrayValidators.push_back(std::make_pair(identifier, vValidators)); + } + + // validate tx inputs and corresponding prev tx vouts + bool validate(const CTransaction& tx, Eval* eval) + { + std::string message = ""; + //std::cerr << "CInputValidationPlan::validate() starting vins validation..." << std::endl; + + int32_t ival = 0; + int32_t iv = 0; + int32_t numv = tx.vin.size(); + int32_t numValidators = m_arrayValidators.size(); + + // run over vins: + while (iv < numv && ival < numValidators) { + + int32_t identifiedCount = 0; + CInputIdentifierBase *identifier = m_arrayValidators[ival].first; + // check if this is 'our' input: + while (iv < numv && identifier->identifyInput(tx.vin[iv])) { + + // get prev tx: + CTransaction prevTx, *pPrevTxOrNull = NULL; + uint256 hashBlock; + + if (!eval->GetTxUnconfirmed(tx.vin[iv].prevout.hash, prevTx, hashBlock)) { + std::ostringstream stream; + stream << "can't find vinTx for vin=" << iv << "."; + return eval->Invalid(stream.str().c_str()); + } + pPrevTxOrNull = &prevTx; // TODO: get prev tx only if it required (i.e. if vout validators are present) + + // exec 'validators' from validator row of ival index, for tx.vin[iv] + if (!execValidatorsInRow(&tx, pPrevTxOrNull, iv, ival, message)) { + std::ostringstream stream; + stream << "invalid tx vin[" << iv << "]:" << message; + return eval->Invalid(stream.str().c_str()); // ... if not, return 'invalid' + } + + identifiedCount++; // how many vins we identified + iv++; // advance to the next vin + } + + // CInputValidationPlan treats that there must be at least one identified vin for configured validators' row + // like in 'vin.0: normal input' + if (identifiedCount == 0) { + std::ostringstream stream; + stream << "can't find required vins for " << identifier->inputName() << "."; + return eval->Invalid(stream.str().c_str()); + } + + ival++; // advance to the next validator row + // and it will try the same vin with the new CInputIdentifierBase and validators row + } + + // validation is successful if all validators have been used (i.e. ival = numValidators) + if (ival < numValidators) { + std::cerr << "CInputValidationPlan::validate() incorrect tx" << " ival=" << ival << " numValidators=" << numValidators << std::endl; + return eval->Invalid("incorrect tx structure: not all required vins are present."); + } + + std::cerr << "CInputValidationPlan::validate() returns with true" << std::endl; + return true; + } + +private: + // Executes validators from the requested row of validators (selected by iValidators) for selected vin or vout (selected by iv) + bool execValidatorsInRow(const CTransaction* pTx, const CTransaction* pPrevTx, int32_t iv, int32_t ival, std::string& refMessage) const + { + // check boundaries: + if (ival < 0 || ival >= m_arrayValidators.size()) { + std::cerr << "CInputValidationPlan::execValidatorsInRow() internal error: incorrect param ival=" << ival << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param ival index"; + return false; + } + + if (iv < 0 || iv >= pTx->vin.size()) { + std::cerr << "CInputValidationPlan::execValidatorsInRow() internal error: incorrect param iv=" << iv << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param iv index"; + return false; + } + + // get requested row of validators: + ValidatorsRow vValidators = m_arrayValidators[ival].second; + + std::cerr << "CInputValidationPlan::execValidatorsInRow() calling validators" << " for vin iv=" << iv << " ival=" << ival << std::endl; + + for (auto v : vValidators) { + bool result; + + if (v->isVinValidator()) + // validate this vin and previous vout: + result = v->validateVin(pTx->vin[iv], pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); + else + // if it is vout validator pass the previous tx vout: + result = v->validateVout( pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); + if (!result) { + return result; + } + } + return true; // validation OK + } + + +private: + //std::map m_arrayValidators; + std::vector< std::pair > m_arrayValidators; + +}; + + +/** +* Encapsulates an array containing rows of validators +* Each row is a vector of validators (zero is possible) for validating vouts +* this validation plan is used for validating tx outputs +*/ +template +class COutputValidationPlan +{ + using ValidatorsRow = std::vector; + +public: + // Pushes a row of validators for validating a vout + // @param ivout index to vout to validate + // @param pargs parameter pack of zero or more pointer to validator objects + // Why pointers? because we store base class and call its virtual functions + + template + void pushValidators(int32_t ivout, ARGS*... pargs) // validators row passed as variadic arguments CValidatorX *val1, CValidatorY *val2 ... + { + ValidatorsRow vValidators({ (TValidatorBase*)pargs... }); + m_arrayValidators.push_back(std::make_pair(ivout, vValidators)); + } + + // validate tx outputs + bool validate(const CTransaction& tx, Eval* eval) + { + std::string message = ""; + //std::cerr << "COutputValidationPlan::validateOutputs() starting vouts validation..." << std::endl; + + int32_t ival = 0; + int32_t numVouts = tx.vout.size(); + int32_t numValidators = m_arrayValidators.size(); + + // run over vouts: + while (ival < numValidators) { + + int32_t ivout = m_arrayValidators[ival].first; + if (ivout >= numVouts) { + std::cerr << "COutputValidationPlan::validate() incorrect tx" << "for ival=" << ival << " in tx.vout no such ivout=" << ivout << std::endl; + return eval->Invalid("incorrect tx structure: not all required vouts are present."); + } + else + { + // exec 'validators' from validator row of ival index, for tx.vout[ivout] + if (!execValidatorsInRow(&tx, ivout, ival, message)) { + std::ostringstream stream; + stream << "invalid tx vout[" << ivout << "]:" << message; + return eval->Invalid(stream.str().c_str()); // ... if not, return 'invalid' + } + } + + ival++; // advance to the next vout + + } + + std::cerr << "COutputValidationPlan::validate() returns with true" << std::endl; + return true; + } + +private: + // Executes validators from the requested row of validators (selected by iValidators) for selected vin or vout (selected by iv) + bool execValidatorsInRow(const CTransaction* pTx, int32_t iv, int32_t ival, std::string& refMessage) const + { + // check boundaries: + if (ival < 0 || ival >= m_arrayValidators.size()) { + std::cerr << "COutputValidationPlan::execValidatorsInRow() internal error: incorrect param ival=" << ival << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param ival index"; + return false; + } + + if (iv < 0 || iv >= pTx->vout.size()) { + std::cerr << "COutputValidationPlan::execValidatorsInRow() internal error: incorrect param iv=" << iv << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param iv index"; + return false; + } + + // get requested row of validators: + ValidatorsRow vValidators = m_arrayValidators[ival].second; + + std::cerr << "COutputValidationPlan::execRow() calling validators" << " for vout iv=" << iv << " ival=" << ival << std::endl; + + for (auto v : vValidators) { + + if (!v->isVinValidator()) { + // if this is a 'in' validation plan then pass the previous tx vout: + bool result = v->validateVout(pTx->vout[iv], refMessage); + if (!result) + return result; + } + } + return true; // validation OK + } + + +private: + //std::map m_mapValidators; + std::vector< std::pair > m_arrayValidators; + +}; + + +class CNormalInputIdentifier : CInputIdentifierBase { +public: + CNormalInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + virtual std::string inputName() const { return std::string("normal input"); } + virtual bool identifyInput(CTxIn vin) const { + return !IsCCInput(vin.scriptSig); + } +}; + +class CCCInputIdentifier : CInputIdentifierBase { +public: + CCCInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + virtual std::string inputName() const { return std::string("CC input"); } + virtual bool identifyInput(CTxIn vin) const { + return IsCCInput(vin.scriptSig); + } +}; + + +/** +* Validates 1of2address for vout (may be used for either this or prev tx) +*/ +template class CCC1of2AddressValidator : CValidatorBase +{ +public: + CCC1of2AddressValidator(CCcontract_info* cp, CScript opRetScript, std::string customMessage = "") : + m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {} + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "CCC1of2AddressValidator::validateVout() entered" << std::endl; + uint8_t funcId; + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTime; + std::string heirName; + uint256 tokenid; + + if ((funcId = DecodeHeirOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName)) == 0) { + message = m_customMessage + std::string(" invalid opreturn format"); + std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; + return false; + } + + char shouldBeAddr[65], ccAddr[65]; + + GetCCaddress1of2(m_cp, shouldBeAddr, ownerPubkey, heirPubkey); + if (vout.scriptPubKey.IsPayToCryptoCondition()) { + if (Getscriptaddress(ccAddr, vout.scriptPubKey) && strcmp(shouldBeAddr, ccAddr) == 0) { + std::cerr << "CCC1of2AddressValidator::validateVout() exits with true" << std::endl; + return true; + } + else { + message = m_customMessage + std::string(" incorrect heir funding address: incorrect pubkey(s)"); + } + } + else { + message = m_customMessage + std::string(" incorrect heir funding address: not a 1of2addr"); + } + + std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; + return false; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return false; } + +private: + CScript m_fundingOpretScript; + std::string m_customMessage; +}; + + +/** +* Validates if this is vout to owner or heir from opret (funding or change) +*/ +template class CMyPubkeyVoutValidator : CValidatorBase +{ +public: + CMyPubkeyVoutValidator(CCcontract_info* cp, CScript opRetScript, bool checkNormals) + : m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { } + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "CMyPubkeyVoutValidator::validateVout() entered" << std::endl; + + uint8_t funcId; + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTime; + std::string heirName; + uint256 tokenid; + + ///std::cerr << "CMyPubkeyVoutValidator::validateVout() m_opRetScript=" << m_opRetScript.ToString() << std::endl; + // get both pubkeys: + if ((funcId = DecodeHeirOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName)) == 0) { + message = std::string("invalid opreturn format"); + return false; + } + + CScript ownerScript; + CScript heirScript; + if (m_checkNormals) { + ownerScript = CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; + heirScript = CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; + } + else { + ownerScript = Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; + heirScript = Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; + } + + //std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout=" << Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << std::endl; + + // recreate scriptPubKey for owner and heir and compare it with that of the vout to check: + if (vout.scriptPubKey == ownerScript || vout.scriptPubKey == heirScript) { + // this is vout to owner or heir addr: + std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with true" << std::endl; + return true; + + } + + std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with false (not the owner's or heir's addresses)" << std::endl; + return false; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + +private: + CScript m_fundingOpretScript; + //uint256 m_lasttxid; + bool m_checkNormals; +}; + +/** +* Check if the user is the heir and the heir is allowed to spend (duration > inactivityTime) +*/ +template class CHeirSpendValidator : CValidatorBase +{ +public: + CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, bool isHeirSpendingBegan) + : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "CHeirSpendValidator::validateVout() entered" << std::endl; + + uint8_t funcId; + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTime; + std::string heirName; + uint256 tokenid; + + + // get heir pubkey: + if ((funcId = DecodeHeirOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, false)) == 0) { + message = std::string("invalid opreturn format"); + return false; + } + + int32_t numblocks; + int64_t durationSec = CCduration(numblocks, m_latesttxid); + + // recreate scriptPubKey for heir and compare it with that of the vout: + if (vout.scriptPubKey == Helper::makeClaimerVout(vout.nValue, heirPubkey).scriptPubKey) { + // this is the heir is trying to spend + if (!m_isHeirSpendingBegan && durationSec <= inactivityTime) { + message = "heir is not allowed yet to spend funds"; + std::cerr << "CHeirSpendValidator::validateVout() heir is not allowed yet to spend funds" << std::endl; + return false; + } + else { + // heir is allowed to spend + return true; + } + } + + std::cerr << "CHeirSpendValidator::validateVout() exits with true" << std::endl; + + // this is not heir: + return true; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + +private: + CScript m_fundingOpretScript; + uint256 m_latesttxid; + bool m_isHeirSpendingBegan; +}; + +/** +* Validates this opreturn and compares it with the opreturn from the previous tx +*/ +template class COpRetValidator : CValidatorBase +{ +public: + COpRetValidator(CCcontract_info* cp, CScript opret) + : m_fundingOpretScript(opret), CValidatorBase(cp) {} + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "COpRetValidator::validateVout() entered" << std::endl; + + uint8_t funcId, initialFuncId; // do not check heir name + uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid, initialTokenid; + + if ((funcId = DecodeHeirOpRet(vout.scriptPubKey, tokenid, fundingTxidInOpret)) == 0) { + message = std::string("invalid opreturn format"); + return false; + } + if ((initialFuncId = DecodeHeirOpRet(m_fundingOpretScript, initialTokenid, dummyTxid)) == 0) { + message = std::string("invalid initial tx opreturn format"); + return false; + } + + // validation rules: + if (!Helper::isMyFuncId(funcId)) { + message = std::string("invalid funcid in opret"); + return false; + } + + if(tokenid != initialTokenid ) { + message = std::string("invalid tokenid in opret"); + return false; + } + + std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; + return true; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + +private: + CScript m_fundingOpretScript; +}; + + + +#endif \ No newline at end of file diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 94403bcc0..5c32b2f5a 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -406,8 +406,16 @@ static const CRPCCommand vRPCCommands[] = { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - // Heir - { "heir", "heiraddress", &heiraddress, true }, + // Heir + { "heir", "heiraddress", &heiraddress, true }, + { "heir", "heirfund", &heirfund, true }, + { "heir", "heiradd", &heiradd, true }, + { "heir", "heirclaim", &heirclaim, true }, + { "heir", "heirfundtokens", &heirfundtokens, true }, + { "heir", "heiraddtokens", &heiraddtokens, true }, + { "heir", "heirclaimtokens", &heirclaimtokens, true }, + { "heir", "heirinfo", &heirinfo, true }, + { "heir", "heirlist", &heirlist, true }, // Channels { "channels", "channelsaddress", &channelsaddress, true }, @@ -479,7 +487,8 @@ static const CRPCCommand vRPCCommands[] = { "dice", "dicestatus", &dicestatus, true }, { "dice", "diceaddress", &diceaddress, true }, - // tokens + // tokens & assets + { "tokens", "assetsaddress", &assetsaddress, true }, { "tokens", "tokeninfo", &tokeninfo, true }, { "tokens", "tokenlist", &tokenlist, true }, { "tokens", "tokenorders", &tokenorders, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 920aac970..7c85c43b6 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -242,6 +242,7 @@ extern UniValue tokeninfo(const UniValue& params, bool fHelp); extern UniValue tokenlist(const UniValue& params, bool fHelp); extern UniValue tokenorders(const UniValue& params, bool fHelp); extern UniValue tokenbalance(const UniValue& params, bool fHelp); +extern UniValue assetsaddress(const UniValue& params, bool fHelp); extern UniValue tokenaddress(const UniValue& params, bool fHelp); extern UniValue tokencreate(const UniValue& params, bool fHelp); extern UniValue tokentransfer(const UniValue& params, bool fHelp); @@ -253,6 +254,14 @@ extern UniValue tokencancelask(const UniValue& params, bool fHelp); extern UniValue tokenfillask(const UniValue& params, bool fHelp); extern UniValue tokenconvert(const UniValue& params, bool fHelp); extern UniValue heiraddress(const UniValue& params, bool fHelp); +extern UniValue heirfund(const UniValue& params, bool fHelp); +extern UniValue heiradd(const UniValue& params, bool fHelp); +extern UniValue heirclaim(const UniValue& params, bool fHelp); +extern UniValue heirfundtokens(const UniValue& params, bool fHelp); +extern UniValue heiraddtokens(const UniValue& params, bool fHelp); +extern UniValue heirclaimtokens(const UniValue& params, bool fHelp); +extern UniValue heirinfo(const UniValue& params, bool fHelp); +extern UniValue heirlist(const UniValue& params, bool fHelp); extern UniValue channelsaddress(const UniValue& params, bool fHelp); extern UniValue oraclesaddress(const UniValue& params, bool fHelp); extern UniValue oracleslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0dcaaa848..b39a19668 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5417,27 +5417,145 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) UniValue heiraddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector destPubkey; + /* + struct CCcontract_info *cp,C; std::vector pubkey; + cp = CCinit(&C,EVAL_HEIR); + if ( fHelp || params.size() > 1 ) + throw runtime_error("heiraddress [pubkey]\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + if ( params.size() == 1 ) + pubkey = ParseHex(params[0].get_str().c_str()); + return(CCaddress(cp,(char *)"Heir",pubkey)); + */ - cp = CCinit(&C,EVAL_HEIR); - if ( fHelp || (params.size() != 4 && params.size() != 3)) - throw runtime_error("heiraddress func txid amount [destpubkey]\n"); - if ( ensure_CCrequirements() < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - //if ( params.size() == 1 ) - // pubkey = ParseHex(params[0].get_str().c_str()); - char funcid = ((char *)params[0].get_str().c_str())[0]; - uint256 assetid = Parseuint256((char *)params[1].get_str().c_str()); - int64_t funds = atof(params[2].get_str().c_str()) * COIN ; - if(params.size() == 4) - destPubkey = ParseHex(params[3].get_str().c_str()); + // make fake token tx: + struct CCcontract_info *cp, C; - //return HeirFundBad(funcid, assetid, funds, destPubkey); + if (fHelp || (params.size() < 1)) + throw runtime_error("heiraddress A|G|H|T|R assetid|destpubkey amountcoins [heirpubkey] [fundingtxid]\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - return(CCaddress(cp,(char *)"Heir",destPubkey)); + char badKind = ((char *)params[0].get_str().c_str())[0]; + + if (badKind == 'A') { + std::vector destPubkey; + if (params.size() == 2) { + cp = CCinit(&C, EVAL_HEIR); + destPubkey = ParseHex(params[1].get_str().c_str()); + return(CCaddress(cp, (char *)"Heir", destPubkey)); + } + else + return std::string("bad params for A"); + } + + CPubKey myPubkey = pubkey2pk(Mypubkey()); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());; + + if (badKind != 'R') { + + if (badKind == 'G' && params.size() != 3) + return std::string("incorrect params for G"); + if (badKind == 'H' && params.size() != 5) + return std::string("incorrect params for H, = 5"); + if (badKind == 'T' && params.size() != 3) + return std::string("incorrect params for T, = 3"); + + + uint256 assetid = Parseuint256((char *)params[1].get_str().c_str()); + int64_t amount = atof(params[2].get_str().c_str()) * COIN; + + uint256 fundingtxid; + CPubKey heirPubkey; + + if (badKind == 'H') { + + std::vector heirPubkeyStr = ParseHex(params[3].get_str().c_str()); + heirPubkey = pubkey2pk(heirPubkeyStr); + + fundingtxid = Parseuint256((char *)params[4].get_str().c_str()); + } + + + + int64_t txfee = 10000; + + uint8_t evalCodeInOpret = (badKind == 'H') ? EVAL_HEIR : EVAL_GATEWAYS; + cp = CCinit(&C, EVAL_ASSETS); + + int64_t normalInputs = AddNormalinputs(mtx, myPubkey, txfee + amount, 60); + // int64_t ccInputs = 0; + + + if (badKind == 'T') { + // just empty fake token + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, amount, myPubkey)); //note you need destPubkey for sending to gateways + } + else if (badKind == 'H') { + // heir add funding tx + mtx.vout.push_back(MakeCC1of2vout(EVAL_ASSETS, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk + } + else { // if (badKind == 'G') + CPubKey gatewayContractPubKey = GetUnspendable(cp, 0); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(gatewayContractPubKey)) << OP_CHECKSIG)); + } + + int64_t change = (normalInputs - amount); + if (change != 0) { + mtx.vout.push_back(CTxOut(change, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG)); + } + std::cerr << "make fake token for contract=" << badKind << " added normalInputs=" << normalInputs << " change=" << change << std::endl; + + // note: it sets eval=EVAL_ASSETS in opreturn both for tokens and gateways cc addr + //script = EncodeAssetOpRet('t', assetid, zeroid, 0, (badKind == 'A' ? Mypubkey() : destPubkey)); // dimxy: are we sure about destPubkey here? it may be just pubkey of the author... + CScript opret; + assetid = revuint256(assetid); + fundingtxid = revuint256(fundingtxid); + if (badKind == 'T') + opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalCodeInOpret << (uint8_t)'t' << assetid ); + else if (badKind == 'H') + opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalCodeInOpret << (uint8_t)'t' << assetid << (uint8_t)'A' << myPubkey << heirPubkey << (int64_t)120 << fundingtxid); + else + opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalCodeInOpret << (uint8_t)'t' << assetid); // EVAL_GATEWAYS + + return(FinalizeCCTx(0, cp, mtx, myPubkey, txfee, opret)); // normal change added here + } + else + { + // move vout from user cc addr to gateways unspendable + CTransaction srctx; + + uint256 hashBlock; + const bool allowSlow = false; + uint256 srctxid = Parseuint256((char *)params[1].get_str().c_str()); + + struct CCcontract_info *cp, C; + cp = CCinit(&C, EVAL_GATEWAYS); + + uint64_t txfee = 10000; + CPubKey gatewayspk = GetUnspendable(cp, 0); + + if (myGetTransaction(srctxid, srctx, hashBlock) && srctx.vout.size() > 0) { + + int64_t normalInputs = AddNormalinputs(mtx, myPubkey, 2 * txfee, 4); + + mtx.vin.push_back(CTxIn(srctxid, 2, CScript())); // repaired src tx + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS, srctx.vout[2].nValue, gatewayspk)); + + CScript script = srctx.vout[srctx.vout.size() - 1].scriptPubKey; + + //mtx.fOverwintered = true; + + return(FinalizeCCTx(0, cp, mtx, myPubkey, txfee, script)); // normal change added here + } + } + return std::string("there has been some error"); } + + UniValue lottoaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; @@ -5518,17 +5636,30 @@ UniValue rewardsaddress(const UniValue& params, bool fHelp) return(CCaddress(cp,(char *)"Rewards",pubkey)); } +UniValue assetsaddress(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp, C; std::vector pubkey; + cp = CCinit(&C, EVAL_ASSETS); + if (fHelp || params.size() > 1) + throw runtime_error("assetsaddress [pubkey]\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + if (params.size() == 1) + pubkey = ParseHex(params[0].get_str().c_str()); + return(CCaddress(cp, (char *)"Assets", pubkey)); +} + UniValue tokenaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; - cp = CCinit(&C,EVAL_ASSETS); + cp = CCinit(&C,EVAL_TOKENS); if ( fHelp || params.size() > 1 ) throw runtime_error("tokenaddress [pubkey]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); - return(CCaddress(cp,(char *)"Assets",pubkey)); + return(CCaddress(cp,(char *)"Tokens", pubkey)); } UniValue marmara_poolpayout(const UniValue& params, bool fHelp) @@ -6895,7 +7026,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp) return(result); } } - hex = CreateAsset(0,supply,name,description); + hex = CreateToken(0,supply,name,description); if ( hex.size() > 0 ) { result.push_back(Pair("result", "success")); @@ -6927,7 +7058,7 @@ UniValue tokentransfer(const UniValue& params, bool fHelp) ERR_RESULT("amount must be positive"); return(result); } - hex = AssetTransfer(0,tokenid,pubkey,amount); + hex = TokenTransfer(0,tokenid,pubkey,amount); if (amount > 0) { if ( hex.size() > 0 ) { @@ -6964,7 +7095,11 @@ UniValue tokenconvert(const UniValue& params, bool fHelp) ERR_RESULT("amount must be positive"); return(result); } - hex = AssetConvert(0,tokenid,pubkey,amount,evalcode); + + ERR_RESULT("deprecated"); + return(result); + +/* hex = AssetConvert(0,tokenid,pubkey,amount,evalcode); if (amount > 0) { if ( hex.size() > 0 ) { @@ -6974,7 +7109,7 @@ UniValue tokenconvert(const UniValue& params, bool fHelp) } else { ERR_RESULT("amount must be positive"); } - return(result); + return(result); */ } UniValue tokenbid(const UniValue& params, bool fHelp) @@ -7271,6 +7406,270 @@ UniValue getbalance64(const UniValue& params, bool fHelp) return ret; } +// heir contract functions for coins +UniValue heirfund(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + //uint256 txid; + int64_t txfee; + int64_t amount; + int64_t inactivitytime; + std::string hex; + std::vector pubkey; + std::string name; + + //TODO: do we need this? + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() != 5) + throw runtime_error("heirfund fee funds heirname heirpubkey inactivitytime\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + + txfee = atof((char*)params[0].get_str().c_str()) * COIN; + amount = atof((char*)params[1].get_str().c_str()) * COIN; + name = params[2].get_str(); + pubkey = ParseHex(params[3].get_str().c_str()); + inactivitytime = atof((char*)params[4].get_str().c_str()); + + + hex = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, zeroid); + if (hex.size() > 0) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } + else + ERR_RESULT("couldn't create heir fund"); + + return result; +} + + +UniValue heiradd(const UniValue& params, bool fHelp) +{ + UniValue result; // UniValue result(UniValue::VOBJ); + uint256 fundingtxid; + uint64_t txfee; + int64_t amount; + int64_t inactivitytime; + std::string hex; + std::vector pubkey; + std::string name; + + // TODO: do we need this? + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() != 3) + throw runtime_error("heiradd fee funds fundingtxid\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + + txfee = atof((char*)params[0].get_str().c_str()) * COIN; + amount = atof((char*)params[1].get_str().c_str()) * COIN; + fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); + + result = HeirAddCoinCaller(fundingtxid, txfee, amount); + /* if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldn't claim heir fund"); */ + + + return result; +} + +UniValue heirclaim(const UniValue& params, bool fHelp) +{ + UniValue result; // result(UniValue::VOBJ); + uint256 fundingtxid; + uint64_t txfee; + int64_t amount; + int64_t inactivitytime; + std::string hex; + std::vector pubkey; + std::string name; + + // do we need this? + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() != 3) + throw runtime_error("heirclaim fee funds fundingtxid\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + + txfee = atof((char*)params[0].get_str().c_str()) * COIN; + amount = atof((char*)params[1].get_str().c_str()) * COIN; + fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); + + result = HeirClaimCoinCaller(fundingtxid, txfee, amount); + /* if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldn't claim heir fund"); */ + + return result; +} + +// same heir contract functions for tokens +UniValue heirfundtokens(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + uint256 assetid; + uint64_t txfee; + int64_t amount; + int64_t inactivitytime; + std::string hex; + std::vector pubkey; + std::string name; + + //TODO: do we need this (dimxy)? + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() != 6) + throw runtime_error("heirfundtokens fee funds heirname heirpubkey inactivitytime assetid\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + + txfee = atoll((char*)params[0].get_str().c_str()); + amount = atoll((char*)params[1].get_str().c_str()); + name = params[2].get_str(); + pubkey = ParseHex(params[3].get_str().c_str()); + inactivitytime = atof((char*)params[4].get_str().c_str()); + assetid = Parseuint256((char*)params[5].get_str().c_str()); + + + hex = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, assetid); + if (hex.size() > 0) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } + else + ERR_RESULT("couldn't create heir fund"); + + + return result; +} + + +UniValue heiraddtokens(const UniValue& params, bool fHelp) +{ + UniValue result; // UniValue result(UniValue::VOBJ); + uint256 fundingtxid; + uint64_t txfee; + int64_t amount; + int64_t inactivitytime; + std::string hex; + std::vector pubkey; + std::string name; + + // TODO: do we need this? + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() != 3) + throw runtime_error("heiraddtokens fee funds fundingtxid\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + + txfee = atoll((char*)params[0].get_str().c_str()); + amount = atoll((char*)params[1].get_str().c_str()); + fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); + + result = HeirAddTokenCaller(fundingtxid, txfee, amount); + /* if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldn't claim heir fund"); */ + + + return result; +} + +UniValue heirclaimtokens(const UniValue& params, bool fHelp) +{ + UniValue result; // result(UniValue::VOBJ); + uint256 fundingtxid; + int64_t txfee; + int64_t amount; + int64_t inactivitytime; + std::string hex; + std::vector pubkey; + std::string name; + + // do we need this? + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() != 3) + throw runtime_error("heirclaimtokens fee funds fundingtxid\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + + txfee = atoll((char*)params[0].get_str().c_str()); + amount = atoll((char*)params[1].get_str().c_str()); + fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); + + result = HeirClaimTokenCaller(fundingtxid, txfee, amount); + /* if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldn't claim heir fund"); */ + + return result; +} + +UniValue heirinfo(const UniValue& params, bool fHelp) +{ + uint256 fundingtxid; + if (fHelp || params.size() != 1) // or 0? + throw runtime_error("heirinfo fundingtxid\n"); + // if ( ensure_CCrequirements() < 0 ) + // throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + fundingtxid = Parseuint256((char*)params[0].get_str().c_str()); + return (HeirInfo(fundingtxid)); +} + +UniValue heirlist(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 0) // or 0? + throw runtime_error("heirlist\n"); + + // if ( ensure_CCrequirements() < 0 ) + // throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + return (HeirList()); +} + + + + extern UniValue dumpprivkey(const UniValue& params, bool fHelp); // in rpcdump.cpp extern UniValue importprivkey(const UniValue& params, bool fHelp); extern UniValue importaddress(const UniValue& params, bool fHelp); From be71d108b296df1a6ac540af90bee4996a3d947f Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 7 Jan 2019 23:21:57 +0500 Subject: [PATCH 1141/3904] Added CCaddr1of2set and FinalizeCCtx modified to support it (small test CCerror code added - temp) --- src/cc/CCassetstx.cpp | 65 +++++++++++++++++++++++----------------- src/cc/CCinclude.h | 28 +++++++++++++---- src/cc/CCtx.cpp | 24 +++++++++++---- src/cc/CCutils.cpp | 8 +++++ src/cc/heir.cpp | 9 +++--- src/wallet/rpcwallet.cpp | 8 +++++ 6 files changed, 100 insertions(+), 42 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index cae4b42bb..17c16bd6a 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -393,7 +393,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p uint64_t mask; int64_t inputs, CCchange; CScript opret; - struct CCcontract_info *cp,C; + struct CCcontract_info *cpTokens,C; //std::cerr << "CreateSell() askamount=" << askamount << " pricetotal=" << pricetotal << std::endl; @@ -402,16 +402,16 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return(""); } - cp = CCinit(&C, EVAL_TOKENS); // NOTE: tokens is here + cpTokens = CCinit(&C, EVAL_TOKENS); // NOTE: tokens is here - if ( txfee == 0 ) + if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ((inputs = AddTokenCCInputs(cp, mtx, mypk, assetid, askamount, 60)) > 0) + if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, askamount, 60)) > 0) { if (inputs < askamount) { //was: askamount = inputs; @@ -420,14 +420,14 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return (""); } - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,askamount, GetUnspendable(cp,0))); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,askamount, GetUnspendable(cpTokens,0))); if (inputs > askamount) CCchange = (inputs - askamount); if (CCchange != 0) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); opret = EncodeAssetOpRet('s',assetid, zeroid, pricetotal, Mypubkey()); - return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,opret)); } else { fprintf(stderr, "need some tokens to place ask\n"); @@ -439,6 +439,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return(""); } +////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 assetid2,int64_t pricetotal) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -497,7 +498,7 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a } return(""); -} +} ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// // unlocks coins std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) @@ -508,11 +509,11 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) uint256 hashBlock; int64_t bidamount; CPubKey mypk; - struct CCcontract_info *cp,C; + struct CCcontract_info *cpAssets, C; - cp = CCinit(&C, EVAL_ASSETS); + cpAssets = CCinit(&C, EVAL_ASSETS); - if ( txfee == 0 ) + if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -525,7 +526,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeAssetOpRet('o', assetid, zeroid, 0, Mypubkey()))); + return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('o', assetid, zeroid, 0, Mypubkey()))); } } return(""); @@ -536,11 +537,11 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; - struct CCcontract_info *cp,C; + struct CCcontract_info *cpTokens, C; - cp = CCinit(&C, EVAL_TOKENS); + cpTokens = CCinit(&C, EVAL_TOKENS); - if ( txfee == 0 ) + if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -553,7 +554,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); - return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, Mypubkey()))); + return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, Mypubkey()))); } } return(""); @@ -570,16 +571,18 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f int32_t bidvout=0; uint64_t mask; int64_t origprice, bidamount, paid_amount, remaining_required, inputs, CCchange=0; - struct CCcontract_info *cp,C; + struct CCcontract_info *cpTokens, tokensC; + struct CCcontract_info *cpAssets, assetsC; if (fillamount < 0) { fprintf(stderr,"negative fillamount %lld\n", (long long)fillamount); return(""); } - cp = CCinit(&C, EVAL_TOKENS); + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + cpAssets = CCinit(&assetsC, EVAL_ASSETS); - if ( txfee == 0 ) + if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -594,7 +597,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f mtx.vin.push_back(CTxIn(bidtxid, bidvout, CScript())); - if ((inputs = AddTokenCCInputs(cp, mtx, mypk, assetid, fillamount, 60)) > 0) + if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, fillamount, 60)) > 0) { if (inputs < fillamount) { std::cerr << "FillBuyOffer(): insufficient tokens to fill buy offer" << std::endl; @@ -607,16 +610,24 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f if (inputs > fillamount) CCchange = (inputs - fillamount); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, bidamount - paid_amount, GetUnspendable(cp,0))); // tokens + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, bidamount - paid_amount, GetUnspendable(cpTokens, NULL))); // tokens mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, fillamount, pubkey2pk(origpubkey))); // coins + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, fillamount, pubkey2pk(origpubkey))); // coins on assets if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins on assets fprintf(stderr,"remaining %llu -> origpubkey\n", (long long)remaining_required); - return(FinalizeCCTx(mask,cp,mtx,mypk,txfee, EncodeAssetOpRet('B', assetid, zeroid, remaining_required, origpubkey))); + // add additional unspendable addr from Assets: + char unspendableAssetsAddr[64]; + uint8_t unspendableAssetsPrivkey[32]; + + CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); + GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); + CCaddr2set(cpTokens, EVAL_ASSETS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); + + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, EncodeAssetOpRet('B', assetid, zeroid, remaining_required, origpubkey))); } else return("dont have any assets to fill bid\n"); } } @@ -694,16 +705,16 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt if (assetid2 != zeroid && inputs > paid_nValue) CCchange = (inputs - paid_nValue); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // coins + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // coins in Assets cc addr mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); // tokens if (assetid2 != zeroid) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); // tokens (not implemented correctly) + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); // tokens... (swap is not implemented yet) else - mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); // coins + mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); // coins normal if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins in Assets cc addr return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid, assetid2, remaining_nValue, origpubkey))); } else { diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 56c4b27d5..ec1557e2b 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -86,12 +86,27 @@ struct CC_meta struct CCcontract_info { - char unspendableCCaddr[64],CChexstr[72],normaladdr[64],unspendableaddr2[64],unspendableaddr3[64]; - uint8_t CCpriv[32],unspendablepriv2[32],unspendablepriv3[32]; - CPubKey unspendablepk2,unspendablepk3; - bool (*validate)(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn); - bool (*ismyvin)(CScript const& scriptSig); - uint8_t evalcode,evalcode2,evalcode3,didinit; + // this is for spending from 'unspendable' CC address + uint8_t evalcode; + char unspendableCCaddr[64], CChexstr[72], normaladdr[64]; + uint8_t CCpriv[32]; + + // this for 1of2 key spending condition (for this evalcode) + // NOTE: only one evalcode is allowed at this time + char unspendable1of2addr[64]; + CPubKey unspendable1of2pk[2]; + + // this is for spending from two additional 'unspendable' CC addresses of other eval codes + // (that is, for spending from several cc contract 'unspendable' addresses): + uint8_t evalcode2, evalcode3; + char unspendableaddr2[64], unspendableaddr3[64]; + uint8_t unspendablepriv2[32], unspendablepriv3[32]; + CPubKey unspendablepk2, unspendablepk3; + + bool (*validate)(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn); // cc contract tx validation callback + bool (*ismyvin)(CScript const& scriptSig); // checks if evalcode is present in the scriptSig param + + uint8_t didinit; }; struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode); @@ -164,6 +179,7 @@ CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2); CC* GetCryptoCondition(CScript const& scriptSig); void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); +void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); bool IsCCInput(CScript const& scriptSig); int32_t unstringbits(char *buf,uint64_t bits); uint64_t stringbits(char *str); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 57a2a327b..dc8b4788e 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -44,7 +44,10 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64]; - uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; CC *mycond=0,*othercond=0,*othercond2=0,*othercond3=0,*cond; CPubKey unspendablepk; + uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; + CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *cond; + CPubKey unspendablepk; + n = mtx.vout.size(); for (i=0; iunspendableaddr2) == 0) { //fprintf(stderr,"matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; - if ( othercond2 == 0 && cp->evalcode != EVAL_CHANNELS && cp->evalcode != EVAL_HEIR && cp->evalcode != EVAL_ASSETS && cp->evalcode != EVAL_TOKENS) - othercond2 = MakeCCcond1(cp->evalcode2,cp->unspendablepk2); - else if ( othercond2 == 0 && (cp->evalcode == EVAL_CHANNELS || cp->evalcode == EVAL_HEIR || cp->evalcode == EVAL_ASSETS || cp->evalcode == EVAL_TOKENS) ) - othercond2 = MakeCCcond1of2(cp->evalcode2,cp->unspendablepk2,cp->unspendablepk3); + if ( othercond2 == 0 ) //&& cp->evalcode != EVAL_CHANNELS && cp->evalcode != EVAL_HEIR && cp->evalcode != EVAL_ASSETS && cp->evalcode != EVAL_TOKENS) + othercond2 = MakeCCcond1(cp->evalcode2, cp->unspendablepk2); + //else if ( othercond2 == 0 && (cp->evalcode == EVAL_CHANNELS || cp->evalcode == EVAL_HEIR || cp->evalcode == EVAL_ASSETS || cp->evalcode == EVAL_TOKENS) ) + // othercond2 = MakeCCcond1of2(cp->evalcode2,cp->unspendablepk2,cp->unspendablepk3); cond = othercond2; } + // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { //fprintf(stderr,"matched %s unspendable3!\n",cp->unspendableaddr3); @@ -158,6 +163,15 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran othercond3 = MakeCCcond1(cp->evalcode3,cp->unspendablepk3); cond = othercond3; } + // check if this is spending from 1of2 cc addr: + else if (strcmp(cp->unspendable1of2addr, destaddr) == 0) + { + //fprintf(stderr,"matched %s unspendable1of2!\n",cp->unspendable1of2addr); + privkey = myprivkey; + if (othercond1of2 == 0) + othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->unspendable1of2pk[0], cp->unspendable1of2pk[1]); + cond = othercond1of2; + } else { fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index ed16805d7..c0fea0c9f 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -195,6 +195,14 @@ void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t * strcpy(cp->unspendableaddr3,coinaddr); } +// set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 cryptocondition vout: +void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +{ + cp->unspendable1of2pk[0] = pk1; + cp->unspendable1of2pk[1] = pk2; + strcpy(cp->unspendable1of2addr, coinaddr); +} + bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { CTxDestination address; txnouttype whichType; diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 81318ad1e..90557d7ac 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1061,11 +1061,12 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); Myprivkey(myprivkey); - //fprintf(stderr,"HeirClaim() before setting unspendable CC addr2= (%s) addr3= (%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); - CCaddr2set(cp, Helper::getMyEval(), ownerPubkey, myprivkey, coinaddr); - CCaddr3set(cp, Helper::getMyEval(), heirPubkey, myprivkey, coinaddr); + ////fprintf(stderr,"HeirClaim() before setting unspendable CC addr2= (%s) addr3= (%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); + //CCaddr2set(cp, Helper::getMyEval(), ownerPubkey, myprivkey, coinaddr); + //CCaddr3set(cp, Helper::getMyEval(), heirPubkey, myprivkey, coinaddr); + ////fprintf(stderr, "HeirClaim() after setting unspendable CC addr2=(%s) addr3=(%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); - fprintf(stderr, "HeirClaim() after setting unspendable CC addr2=(%s) addr3=(%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); + CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); // add opreturn 'C' and sign tx: // this txfee will be ignored std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b39a19668..1320da61c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6952,12 +6952,20 @@ UniValue tokenlist(const UniValue& params, bool fHelp) UniValue tokeninfo(const UniValue& params, bool fHelp) { +#ifdef TESTMODE + std::cerr << "is CCerror clear? CCerror=" << CCerror << std::endl; +#endif uint256 tokenid; if ( fHelp || params.size() != 1 ) throw runtime_error("tokeninfo tokenid\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); tokenid = Parseuint256((char *)params[0].get_str().c_str()); + +#ifdef TESTMODE + CCerror = "test error"; +#endif + return(AssetInfo(tokenid)); } From 675787d67658245c64c795433a28816b9a0e2552 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 7 Jan 2019 23:24:13 +0500 Subject: [PATCH 1142/3904] Asset contract modified to support the Tokens contract --- src/cc/CCassetsCore.cpp | 100 +++++++++++++++++------------- src/cc/CCassetstx.cpp | 113 ++++++++++++++++++++++------------ src/cc/CCinclude.h | 6 +- src/cc/CCtokens.cpp | 132 ++++++++++++++++++++++++++++++++-------- src/cc/CCtokens.h | 4 +- src/cc/CCtx.cpp | 3 +- src/cc/CCutils.cpp | 8 +-- src/cc/assets.cpp | 52 +++++++++------- src/cc/prices.cpp | 4 +- src/script/script.cpp | 14 +++++ src/script/script.h | 2 + 11 files changed, 303 insertions(+), 135 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 52c73d47f..837c4361e 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -239,25 +239,28 @@ CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,st } */ -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector origpubkey) +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey) { CScript opret; uint8_t evalcode = EVAL_ASSETS; uint8_t funcId = (uint8_t)'t'; + uint8_t ccType = 0; + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) + ccType = voutPubkeys.size(); tokenid = revuint256(tokenid); switch ( assetFuncId ) { //case 't': this cannot be here case 'x': case 'o': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << assetFuncId); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << ccType; if(ccType >= 1) ss << voutPubkeys[0]; if(ccType == 2) ss << voutPubkeys[1]; ss << assetFuncId); break; case 's': case 'b': case 'S': case 'B': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << assetFuncId << price << origpubkey); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << ccType; if(ccType >= 1) ss << voutPubkeys[0]; if(ccType == 2) ss << voutPubkeys[1]; ss << assetFuncId << price << origpubkey); break; case 'E': case 'e': assetid2 = revuint256(assetid2); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << assetFuncId << assetid2 << price << origpubkey); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << ccType; if(ccType >= 1) ss << voutPubkeys[0]; if(ccType == 2) ss << voutPubkeys[1]; ss << assetFuncId << assetid2 << price << origpubkey); break; default: fprintf(stderr,"EncodeAssetOpRet: illegal funcid.%02x\n", assetFuncId); @@ -283,33 +286,38 @@ bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &o uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) { - std::vector vopret; - uint8_t *script, funcId = 0, assetFuncId = 0, dummyEvalCode, dummyFuncId; + std::vector vopretExtra; + uint8_t *script, funcId = 0, assetFuncId = 0, dummyEvalCode, dummyAssetFuncId; uint256 dummyTokenid; - - GetOpReturnData(scriptPubKey, vopret); - - script = (uint8_t *)vopret.data(); - if (script == 0) { - std::cerr << "DecodeAssetOpRet() script is empty" << std::endl; - return (uint8_t)0; - } + std::vector voutPubkeysDummy; tokenid = zeroid; assetid2 = zeroid; price = 0; - bool isEof = true; // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! - bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); + // First - decode token opret: + funcId = DecodeTokenOpRet(scriptPubKey, evalCodeInOpret, tokenid, voutPubkeysDummy, vopretExtra); - if (!result && isEof) { // NOTE: 'result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' - std::cerr << "DecodeAssetOpRet() incorrect opret or no asset's payload" << std::endl; + + /*GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if (script == 0) { + std::cerr << "DecodeAssetOpRet() script is empty" << std::endl; + return (uint8_t)0; + }*/ + //bool isEof = true; // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! + //bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); + + if (funcId == 0 || vopretExtra.size() == 0) { + std::cerr << "DecodeAssetOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretExtra.size()=" << vopretExtra.size() << std::endl; return (uint8_t)0; } - tokenid = revuint256(tokenid); + ////tokenid = revuint256(tokenid); already done in DecodeToken! - std::cerr << "DecodeAssetOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; + assetFuncId = vopretExtra.begin()[0]; + + //std::cerr << "DecodeAssetOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; if(evalCodeInOpret == EVAL_ASSETS) { @@ -328,20 +336,20 @@ uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, break; */ case 'x': case 'o': - if (isEof) // no data after 'assetFuncId' allowed + if (vopretExtra.size() == 1) // no data after 'assetFuncId' allowed { return(assetFuncId); } break; case 's': case 'b': case 'S': case 'B': - if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> dummyTokenid; ss >> dummyFuncId; ss >> price; ss >> origpubkey) != 0) + if (E_UNMARSHAL(vopretExtra, ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) { //fprintf(stderr,"got price %llu\n",(long long)price); return(assetFuncId); } break; case 'E': case 'e': - if ( E_UNMARSHAL(vopret,ss >> dummyEvalCode; ss >> dummyFuncId; ss >> dummyTokenid; ss >> dummyFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) + if ( E_UNMARSHAL(vopretExtra, ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) { //fprintf(stderr,"got price %llu\n",(long long)price); assetid2 = revuint256(assetid2); @@ -349,34 +357,37 @@ uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, } break; default: - fprintf(stderr,"DecodeAssetOpRet: illegal funcid.%02x\n", funcId); - funcId = 0; + fprintf(stderr,"DecodeAssetOpRet: illegal assetFuncId.%02x\n", assetFuncId); + //funcId = 0; break; } } - return(funcId); + return (uint8_t)0; } bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx) { uint256 assetid,assetid2; uint8_t evalCode; - if ( tx.vout.size() > 0 && DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey) != 0 ) + if ( tx.vout.size() > 0 && DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey) != 0 ) return(true); - else return(false); + else + return(false); } bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,const CTransaction& tx) { - uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; CScript script; + uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; + CScript script; uint8_t evalCode; n = tx.vout.size(); if ( n == 0 || (funcid= DecodeAssetOpRet(tx.vout[n-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey)) == 0 ) return(false); - if ( GetCCaddress(cp,CCaddr,pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr,CScript() << origpubkey << OP_CHECKSIG) != 0 ) + if ( GetCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) return(true); - else return(false); + else + return(false); } @@ -398,7 +409,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch } else if ( Getscriptaddress(destaddr,vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || strcmp(destaddr,(char *)cp->unspendableCCaddr) != 0 ) { - fprintf(stderr,"%s vs %s\n",destaddr,(char *)cp->unspendableCCaddr); + fprintf(stderr,"AssetValidateCCvin cc addr %s is not evalcode 0x%02x unspendable %s\n", destaddr, (int)cp->evalcode, (char *)cp->unspendableCCaddr); return eval->Invalid("invalid vin AssetsCCaddr"); } //else if ( vinTx.vout[0].nValue < 10000 ) @@ -415,6 +426,8 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr { CTransaction vinTx; int64_t nValue; uint256 assetid,assetid2; uint8_t funcid, evalCode; CCaddr[0] = origaddr[0] = 0; + + // validate locked coins on Assets vin[1] if ( (nValue= AssetValidateCCvin(cp,eval,CCaddr,origaddr,tx,1,vinTx)) == 0 ) return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) @@ -441,7 +454,8 @@ int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpp return(0); if ( (assetoshis= IsAssetvout(cp, tmpprice, tmporigpubkey,vinTx,0,assetid)) == 0 ) return eval->Invalid("invalid missing CC vout0 for sellvin"); - else return(assetoshis); + else + return(assetoshis); } @@ -475,9 +489,8 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr return(true); } } */ - // TODO: hope this was unneeded!!! (dimxy) - else if ((funcid == 'b' || funcid == 'B') && v == 0) // critical! 'b'/'B' vout0 is NOT asset - return(false); + //else if ((funcid == 'b' || funcid == 'B') && v == 0) // critical! 'b'/'B' vout0 is NOT asset + // return(false); else if (funcid != 'E') { if (assetid != zeroid && assetidOpret == assetid) @@ -542,8 +555,8 @@ bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_ cpTokens = CCinit(&C, EVAL_TOKENS); for (int32_t i = 0; iismyvin)(tx.vin[i].scriptSig) || (*cpTokens->ismyvin)(tx.vin[i].scriptSig)) // || IsVinAllowed(tx.vin[i].scriptSig) != 0) + { // only tokens are relevant!! + if (/*(*cpAssets->ismyvin)(tx.vin[i].scriptSig)*/ (*cpTokens->ismyvin)(tx.vin[i].scriptSig) ) // || IsVinAllowed(tx.vin[i].scriptSig) != 0) { //std::cerr << indentStr << "AssetExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl; // we are not inside the validation code -- dimxy @@ -555,7 +568,10 @@ bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_ else { // validate vouts of vintx //std::cerr << indentStr << "AssetExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; - assetoshis = IsAssetvout(cpAssets, tmpprice, tmporigpubkey, vinTx, tx.vin[i].prevout.n, assetid); + //assetoshis = IsAssetvout(cpAssets, tmpprice, tmporigpubkey, vinTx, tx.vin[i].prevout.n, assetid); + std::vector vopretExtra; + std::vector vinPubkeysEmpty; + assetoshis = IsTokensvout(false, false, cpTokens, NULL, vopretExtra, vinTx, tx.vin[i].prevout.n, assetid, vinPubkeysEmpty); if (assetoshis != 0) { std::cerr << "AssetExactAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl; @@ -585,9 +601,11 @@ bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_ } } - //std::cerr << "AssetExactAmounts() inputs=" << inputs << " outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; + std::cerr << "AssetExactAmounts() inputs=" << inputs << " outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; - /* if (inputs != outputs) { + /* we do not verify inputs == outputs here, + it's done in Tokens: + if (inputs != outputs) { if (tx.GetHash() != assetid) { std::cerr << "AssetExactAmounts() unequal inputs=" << inputs << " vs outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; return (!eval) ? false : eval->Invalid("assets cc inputs != cc outputs"); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 17c16bd6a..fe86d58de 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -145,11 +145,11 @@ UniValue AssetOrders(uint256 refassetid) char numstr[32], funcidstr[16], origaddr[64], assetidstr[65]; txid = it->first.txhash; - //std::cerr << "addOrders txid" << txid.GetHex() << std::endl; + //std::cerr << "addOrders() txid=" << txid.GetHex() << std::endl; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); - //std::cerr << "addOrders vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << std::endl; + //std::cerr << "addOrders() vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl; if (vintx.vout.size() > 0 && (funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) { if (refassetid != zero && assetid != refassetid) @@ -163,6 +163,8 @@ UniValue AssetOrders(uint256 refassetid) //fprintf(stderr," refassetid\n"); return; } + + //std::cerr << "addOrders() it->first.index=" << it->first.index << " vintx.vout[it->first.index].nValue=" << vintx.vout[it->first.index].nValue << std::endl; if (vintx.vout[it->first.index].nValue == 0) return; @@ -213,7 +215,7 @@ UniValue AssetOrders(uint256 refassetid) } } result.push_back(item); - //fprintf(stderr,"func.(%c) %s/v%d %.8f\n",funcid,uint256_str(assetidstr,txid),(int32_t)it->first.index,(double)vintx.vout[it->first.index].nValue/COIN); + //fprintf(stderr,"addOrders() func.(%c) %s/v%d %.8f\n",funcid,uint256_str(assetidstr,txid),(int32_t)it->first.index,(double)vintx.vout[it->first.index].nValue/COIN); } } }; @@ -378,8 +380,12 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in return (""); } - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount, GetUnspendable(cpAssets,0))); - return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('b', assetid, zeroid, pricetotal, Mypubkey()))); + CPubKey unspendablePubkey = GetUnspendable(cpAssets, 0); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount, unspendablePubkey)); + + std::vector voutTokenPubkeys; // should be empty - no token vouts + + return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('b', assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()))); } CCerror = strprintf("no coins found to make buy offer"); return(""); @@ -420,13 +426,17 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return (""); } - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,askamount, GetUnspendable(cpTokens,0))); + CPubKey unspendablePubkey = GetUnspendable(cpTokens, 0); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, unspendablePubkey)); if (inputs > askamount) CCchange = (inputs - askamount); if (CCchange != 0) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); - opret = EncodeAssetOpRet('s',assetid, zeroid, pricetotal, Mypubkey()); + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(unspendablePubkey); + + opret = EncodeAssetOpRet('s',assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,opret)); } else { @@ -474,18 +484,22 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a return (""); } - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, askamount, GetUnspendable(cp, 0))); + CPubKey unspendablePubkey = GetUnspendable(cp, 0); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, askamount, unspendablePubkey)); if (inputs > askamount) CCchange = (inputs - askamount); if (CCchange != 0) mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); - if (assetid2 == zeroid) - opret = EncodeAssetOpRet('s', assetid, zeroid, pricetotal, Mypubkey()); - else - { - opret = EncodeAssetOpRet('e', assetid, assetid2, pricetotal, Mypubkey()); + + std::vector voutTokenPubkeys; // should be empty - no token vouts + + if (assetid2 == zeroid) { + opret = EncodeAssetOpRet('s', assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); + } + else { + opret = EncodeAssetOpRet('e', assetid, assetid2, pricetotal, voutTokenPubkeys, Mypubkey()); } return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); } @@ -524,9 +538,12 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) { bidamount = vintx.vout[0].nValue; - mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); + mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('o', assetid, zeroid, 0, Mypubkey()))); + + std::vector voutTokenPubkeys; // should be empty, no tokens vout + + return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('o', assetid, zeroid, 0, voutTokenPubkeys, Mypubkey()))); } } return(""); @@ -554,7 +571,11 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); - return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, Mypubkey()))); + + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(mypk); + + return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, voutTokenPubkeys, Mypubkey()))); } } return(""); @@ -595,7 +616,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f bidamount = vintx.vout[bidvout].nValue; SetAssetOrigpubkey(origpubkey, origprice, vintx); - mtx.vin.push_back(CTxIn(bidtxid, bidvout, CScript())); + mtx.vin.push_back(CTxIn(bidtxid, bidvout, CScript())); // Coins on Assets unspendable if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, fillamount, 60)) > 0) { @@ -610,25 +631,30 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f if (inputs > fillamount) CCchange = (inputs - fillamount); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, bidamount - paid_amount, GetUnspendable(cpTokens, NULL))); // tokens - mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, fillamount, pubkey2pk(origpubkey))); // coins on assets + CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); + uint8_t unspendableAssetsPrivkey[32]; + CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); + + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // 0 coins remainder + mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); // 1 coins to normal + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // 2 tokens paid if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins on assets + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // 3 change in tokens fprintf(stderr,"remaining %llu -> origpubkey\n", (long long)remaining_required); - // add additional unspendable addr from Assets: char unspendableAssetsAddr[64]; - uint8_t unspendableAssetsPrivkey[32]; - - CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); + // add additional unspendable addr from Assets: CCaddr2set(cpTokens, EVAL_ASSETS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, EncodeAssetOpRet('B', assetid, zeroid, remaining_required, origpubkey))); - } else return("dont have any assets to fill bid\n"); + // token vout verification pubkeys: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(unspendableTokensPk); + + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, EncodeAssetOpRet('B', assetid, zeroid, remaining_required, voutTokenPubkeys, origpubkey))); + } else return("dont have any assets to fill bid"); } } return("no normal coins left"); @@ -683,7 +709,7 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt mtx.vin.push_back(CTxIn(asktxid, askvout, CScript())); // NOTE: this is the reference to tokens -> send cpTokens for signing into FinalizeCCTx! if (assetid2 != zeroid) - inputs = AddAssetInputs(cpTokens, mtx, mypk, assetid2, paid_nValue, 60); + inputs = AddAssetInputs(cpTokens, mtx, mypk, assetid2, paid_nValue, 60); // not implemented yet else { inputs = AddNormalinputs(mtx, mypk, paid_nValue, 60); @@ -698,25 +724,36 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt } if (assetid2 != zeroid) - SetSwapFillamounts(received_assetoshis, remaining_nValue, orig_assetoshis, paid_nValue, total_nValue); + SetSwapFillamounts(received_assetoshis, remaining_nValue, orig_assetoshis, paid_nValue, total_nValue); //not implemented correctly yet else SetAskFillamounts(received_assetoshis, remaining_nValue, orig_assetoshis, paid_nValue, total_nValue); if (assetid2 != zeroid && inputs > paid_nValue) CCchange = (inputs - paid_nValue); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // coins in Assets cc addr - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); // tokens + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, orig_assetoshis - received_assetoshis, GetUnspendable(cpTokens, NULL))); // 0 tokens cc addr - ask remainder + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); //1 tokens to self - if (assetid2 != zeroid) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); // tokens... (swap is not implemented yet) - else - mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); // coins normal + if (assetid2 != zeroid) { + std::cerr << "FillSell() WARNING: asset swap not implemented yet! (paid_nValue)" << std::endl; + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //2 tokens... (swap is not implemented yet) + } + else { + //std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl; + mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //2 coins normal to whom who asked token + } - if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); // coins in Assets cc addr + // not implemented + if (CCchange != 0) { + std::cerr << "FillSell() WARNING: asset swap not implemented yet! (CCchange)" << std::endl; + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //3 coins in Assets cc addr + } - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid, assetid2, remaining_nValue, origpubkey))); + // vout verification pubkeys: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(mypk); + + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid, assetid2, remaining_nValue, voutTokenPubkeys, origpubkey))); } else { CCerror = strprintf("filltx not enough utxos"); fprintf(stderr,"%s\n", CCerror.c_str()); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index ec1557e2b..1b6e804fc 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -151,13 +151,15 @@ uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); //int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); + bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector origpubkey); +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey); bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &vopretExtra); +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra); //uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid,uint256 &assetid2,int64_t &price,std::vector &origpubkey); uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index c85297ddb..d9e689f85 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -76,11 +76,12 @@ uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector return (uint8_t)0; } -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &vopretExtra) +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { std::vector vopret, extra, dummyPubkey; - uint8_t funcid=0, *script, e, dummyFuncId; + uint8_t funcId=0, *script, dummyEvalCode, dummyFuncId, ccType; std::string dummyName; std::string dummyDescription; + CPubKey voutPubkey1, voutPubkey2; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -88,28 +89,45 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 if (script != 0 /*enable all evals: && script[0] == EVAL_TOKENS*/) { + // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! bool isEof = true; + evalCode = script[0]; - funcid = script[1]; - //fprintf(stderr,"decode.[%c]\n",funcid); - switch ( funcid ) + funcId = script[1]; + //fprintf(stderr,"decode.[%c]\n",funcId); + + switch ( funcId ) { case 'c': return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription); //break; case 't': //not used yet: case 'l': - if (E_UNMARSHAL(vopret, ss >> e; ss >> dummyFuncId; ss >> tokenid; isEof = ss.eof(); vopretExtra = std::vector(ss.begin(), ss.end())) || !isEof) + // NOTE: 'E_UNMARSHAL result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' + if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; if (ccType >= 1) ss >> voutPubkey1; if (ccType == 2) ss >> voutPubkey2; isEof = ss.eof(); vopretExtra = std::vector(ss.begin(), ss.end())) + || !isEof) { + + if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType + std::cerr << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << std::endl; + return (uint8_t)0; + } + + // add verification pubkeys: + voutPubkeys.clear(); + if (voutPubkey1.IsValid()) + voutPubkeys.push_back(voutPubkey1); + if (voutPubkey2.IsValid()) + voutPubkeys.push_back(voutPubkey2); + tokenid = revuint256(tokenid); - return(funcid); + return(funcId); } - std::cerr << "DecodeTokenOpRet() isEof=" << isEof << std::endl; - fprintf(stderr, "DecodeTokenOpRet() bad opret format\n"); // this may be just check, no error logging + std::cerr << "DecodeTokenOpRet() warning: bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl; return (uint8_t)0; default: - fprintf(stderr, "DecodeTokenOpRet() illegal funcid.%02x\n", funcid); + std::cerr << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl; return (uint8_t)0; } } @@ -124,16 +142,18 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & static uint256 zero; CTxDestination address; CTransaction vinTx, createTx; uint256 hashBlock, tokenid, tokenid2; int32_t i, starti, numvins, numvouts, preventCCvins, preventCCvouts; - int64_t remaining_price, nValue, tokenoshis, outputs, inputs, tmpprice, totalunits, ignore; std::vector origpubkey, tmporigpubkey, ignorepubkey; + int64_t remaining_price, nValue, tokenoshis, outputs, inputs, tmpprice, totalunits, ignore; + std::vector vopretExtra, tmporigpubkey, ignorepubkey; uint8_t funcid, evalCodeInOpret; char destaddr[64], origaddr[64], CCaddr[64]; + std::vector voutTokenPubkeys; numvins = tx.vin.size(); numvouts = tx.vout.size(); outputs = inputs = 0; preventCCvins = preventCCvouts = -1; - if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, origpubkey)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); fprintf(stderr, "TokensValidate (%c)\n", funcid); @@ -206,7 +226,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & thread_local uint32_t tokenValIndentSize = 0; // validates opret for token tx: -bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &vopretExtra) { +bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { uint256 tokenidOpret, tokenidOpret2; uint8_t funcid, evalCode; @@ -216,7 +236,7 @@ bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector int32_t n = tx.vout.size(); - if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, tokenidOpret, vopretExtra)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, tokenidOpret, voutPubkeys, vopretExtra)) == 0) { std::cerr << indentStr << "ValidateTokenOpret() DecodeOpret returned null for n-1=" << n - 1 << " txid=" << tx.GetHash().GetHex() << std::endl; return(false); @@ -241,18 +261,20 @@ bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector } + // Checks if the vout is a really Tokens CC vout // compareTotals == true, the func also validates the passed transaction itself: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx -int64_t IsTokensvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, std::vector &vopretExtra, const CTransaction& tx, int32_t v, uint256 reftokenid) +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &vopretExtra, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys) { // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); //std::cerr << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl; + //TODO: validate cc vouts are EVAL_TOKENS! - if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here + if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here { int32_t n = tx.vout.size(); // just check boundaries: @@ -261,7 +283,7 @@ int64_t IsTokensvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, return(0); } - if (compareTotals) { + if (goDeeper) { //std::cerr << indentStr << "IsTokensvout() maxTokenExactAmountDepth=" << maxTokenExactAmountDepth << std::endl; //validate all tx int64_t myCCVinsAmount = 0, myCCVoutsAmount = 0; @@ -282,11 +304,41 @@ int64_t IsTokensvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, } // moved opret checking to this new reusable func (dimxy): - const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, vopretExtra); + std::vector voutPubkeys; + const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (valOpret) { - //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned true, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; + //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned true" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + + if (checkPubkeys) { + // verify that the vout is within EVAL_TOKENS: + + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { + CTxOut testVout; + if (voutPubkeys.size() == 1) + testVout = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]); + else // voutPubkeys.size() == 2 + testVout = MakeCC1of2vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); + + if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + } + + // maybe it is change? + for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { + CTxOut testVout = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it); + + if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + } + } + else { + return tx.vout[v].nValue; + } } //std::cerr << indentStr; fprintf(stderr,"IsTokensvout() CC vout v.%d of n=%d amount=%.8f txid=%s\n",v,n,(double)0/COIN, tx.GetHash().GetHex().c_str()); @@ -296,9 +348,12 @@ int64_t IsTokensvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, } // compares cc inputs vs cc outputs (to prevent feeding vouts from normal inputs) -bool TokensExactAmounts(bool compareTotals, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) +bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) { CTransaction vinTx; uint256 hashBlock, id, id2; int32_t flag; int64_t tokenoshis; std::vector tmporigpubkey; int64_t tmpprice; + std::vector vinPubkeys, vinPubkeysEmpty; + CPubKey pubkey; + int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); inputs = outputs = 0; @@ -310,6 +365,33 @@ bool TokensExactAmounts(bool compareTotals, struct CCcontract_info *cpTokens, in { // check for additional contracts which may send tokens to the Tokens contract if ((*cpTokens->ismyvin)(tx.vin[i].scriptSig) /*|| IsVinAllowed(tx.vin[i].scriptSig) != 0*/) { + + // extract my vins pubkeys: + + auto findEval = [](CC *cond, struct CCVisitor _) { + bool r = false; //cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == EVAL_TOKENS; + + if (cc_typeId(cond) == CC_Secp256k1) { + *(CPubKey*)_.context = buf2pk(cond->publicKey); + std::cerr << "findEval found pubkey=" << HexStr(*(CPubKey*)_.context) << std::endl; + r = true; + } + // false for a match, true for continue + return r ? 0 : 1; + }; + + CC *cond = GetCryptoCondition(tx.vin[i].scriptSig); + + if (cond) { + CCVisitor visitor = { findEval, (uint8_t*)"", 0, &pubkey }; + bool out = !cc_visit(cond, visitor); + cc_free(cond); + + if (pubkey.IsValid()) + vinPubkeys.push_back(pubkey); + } + + //std::cerr << indentStr << "TokensExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl; // we are not inside the validation code -- dimxy if ((eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) @@ -322,7 +404,7 @@ bool TokensExactAmounts(bool compareTotals, struct CCcontract_info *cpTokens, in tokenValIndentSize++; // validate vouts of vintx //std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; - tokenoshis = IsTokensvout(compareTotals, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid); + tokenoshis = IsTokensvout(goDeeper, false/*<--do not have pubkeys*/, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeysEmpty); tokenValIndentSize--; if (tokenoshis != 0) { @@ -339,7 +421,7 @@ bool TokensExactAmounts(bool compareTotals, struct CCcontract_info *cpTokens, in tokenValIndentSize++; // Note: we pass in here 'false' because we don't need to call TokenExactAmounts() recursively from IsTokenvout // indeed, in this case we'll be checking this tx again - tokenoshis = IsTokensvout(false, cpTokens, eval, tmporigpubkey, tx, i, tokenid); + tokenoshis = IsTokensvout(false, true /*<--exclude non-tokens vouts*/, cpTokens, eval, tmporigpubkey, tx, i, tokenid, vinPubkeys); tokenValIndentSize--; if (tokenoshis != 0) @@ -393,7 +475,9 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C if (strcmp(destaddr, coinaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) continue; fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); - if ((nValue = IsTokensvout(true, cp, NULL, vopretExtra, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + + std::vector vinPubkeysEmpty; + if ((nValue = IsTokensvout(true, false, cp, NULL, vopretExtra, vintx, vout, tokenid, vinPubkeysEmpty)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) { if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, vout, CScript())); diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index 2dc9a8e56..8ecbc1094 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -27,8 +27,8 @@ // CCcustom bool TokensValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); -bool TokensExactAmounts(bool compareTotals, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); -int64_t IsTokensvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid); +bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); +//int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index dc8b4788e..3d95d0f17 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -333,7 +333,8 @@ int64_t CCtoken_balance(char *coinaddr,uint256 tokenid) if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { char str[65]; fprintf(stderr,"check %s %.8f\n",uint256_str(str,txid),(double)it->second.satoshis/COIN); - if ( DecodeTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCode, assetid, vopretExtra) != 0 && assetid == tokenid ) + std::vector voutTokenPubkeys; + if ( DecodeTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCode, assetid, voutTokenPubkeys, vopretExtra) != 0 && assetid == tokenid ) { sum += it->second.satoshis; } diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index c0fea0c9f..eef21c72a 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -307,17 +307,17 @@ bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubK return(destaddr[0] != 0); } -bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue) +bool ConstrainVout(CTxOut vout, int32_t CCflag, char *cmpaddr, int64_t nValue) { char destaddr[64]; if ( vout.scriptPubKey.IsPayToCryptoCondition() != CCflag ) { - fprintf(stderr,"constrain vout error isCC %d vs %d CCflag\n",vout.scriptPubKey.IsPayToCryptoCondition(),CCflag); + fprintf(stderr,"constrain vout error isCC %d vs %d CCflag\n", vout.scriptPubKey.IsPayToCryptoCondition(), CCflag); return(false); } - else if ( cmpaddr != 0 && (Getscriptaddress(destaddr,vout.scriptPubKey) == 0 || strcmp(destaddr,cmpaddr) != 0) ) + else if ( cmpaddr != 0 && (Getscriptaddress(destaddr, vout.scriptPubKey) == 0 || strcmp(destaddr, cmpaddr) != 0) ) { - fprintf(stderr,"constrain vout error addr %s vs %s\n",cmpaddr!=0?cmpaddr:"",destaddr!=0?destaddr:""); + fprintf(stderr,"constrain vout error addr %s vs %s\n", cmpaddr!=0?cmpaddr:"", destaddr!=0?destaddr:""); return(false); } else if ( nValue != 0 && nValue != vout.nValue ) //(nValue == 0 && vout.nValue < 10000) || ( diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 47b9488c8..3a62a526a 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -140,12 +140,16 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts; int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector origpubkey,tmporigpubkey,ignorepubkey; uint8_t funcid, evalCodeInOpret; - char destaddr[64],origaddr[64],CCaddr[64]; + char destaddr[64], origaddr[64], assetsCCaddr[64], tokensCCaddr[64]; // we need this for validating tokens' vins/vous: struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); + //CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); + //CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, NULL); + //GetCCaddress(cpTokens, tokensUnspendableCCaddr, unspendableTokensPk); + numvins = tx.vin.size(); numvouts = tx.vout.size(); outputs = inputs = 0; @@ -154,6 +158,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if((funcid = DecodeAssetOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) return eval->Invalid("AssetValidate: invalid opreturn payload"); + // find token user cc addr + GetCCaddress(cpTokens, tokensCCaddr, pubkey2pk(origpubkey)); + fprintf(stderr,"AssetValidate (%c)\n",funcid); if( funcid != 'o' && funcid != 'x' && eval->GetTxUnconfirmed(assetid, createTx, hashBlock) == 0 ) @@ -162,8 +169,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("cant find asset2 create txid"); else if( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("illegal asset vin0"); - else if( numvouts < 1 ) - return eval->Invalid("no vouts"); + else if( numvouts < 2 ) + return eval->Invalid("too few vouts"); // it was if(numvouts < 1) but it refers at least to vout[1] below else if( funcid != 'c' ) { /* if( funcid == 't' ) @@ -223,7 +230,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.0: vin.1 value to original pubkey buyTx.vout[0].nValue -> [origpubkey] //vout.1: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['o'] - if( (nValue= AssetValidateBuyvin(cpAssets, eval, tmpprice, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) + if( (nValue= AssetValidateBuyvin(cpAssets, eval, tmpprice, tmporigpubkey, assetsCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( ConstrainVout(tx.vout[0],0, origaddr, nValue) == 0 ) return eval->Invalid("invalid refund for cancelbuy"); @@ -243,7 +250,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.4: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['B'] [assetid] [remaining asset required] [origpubkey] preventCCvouts = 4; - if( (nValue = AssetValidateBuyvin(cpAssets, eval, totalunits, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) + + if( (nValue = AssetValidateBuyvin(cpAssets, eval, totalunits, tmporigpubkey, assetsCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillbuy"); @@ -255,12 +263,12 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("locked value doesnt match vout0+1 fillbuy"); else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if( ConstrainVout(tx.vout[2], 1, CCaddr, 0) == 0 ) + if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, 0) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); else if ( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); } - else if( ConstrainVout(tx.vout[2], 1, CCaddr, inputs) == 0 ) + else if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, inputs) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt match inputs fillbuy"); else if( ConstrainVout(tx.vout[1],0,0,0) == 0 ) return eval->Invalid("vout1 is CC for fillbuy"); @@ -268,7 +276,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("mismatched remainder for fillbuy"); else if( remaining_price != 0 ) { - if( ConstrainVout(tx.vout[0], 1, cpAssets->unspendableCCaddr, 0) == 0 ) + if( ConstrainVout(tx.vout[0], 1, cpAssets->unspendableCCaddr, 0) == 0 ) // coins on asset unspendable cc addr return eval->Invalid("mismatched vout0 AssetsCCaddr for fillbuy"); } } @@ -287,16 +295,16 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti preventCCvouts = 1; if( remaining_price == 0 ) return eval->Invalid("illegal null remaining_price for selloffer"); - if( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() != 0 ) + if( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() != 0 ) // is cc change present? { preventCCvouts++; - if( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) - return eval->Invalid("mismatched vout0 AssetsCCaddr for selloffer"); + if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, 0) == 0 ) // check also vout[0] + return eval->Invalid("mismatched vout0 TokensCCaddr for selloffer"); else if( tx.vout[0].nValue + tx.vout[1].nValue != inputs ) return eval->Invalid("mismatched vout0+vout1 total for selloffer"); } - else if( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, inputs) == 0 ) - return eval->Invalid("mismatched vout0 AssetsCCaddr for selloffer"); + else if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, inputs) == 0 ) // no cc change, just vout[0] + return eval->Invalid("mismatched vout0 TokensCCaddr for selloffer"); //fprintf(stderr,"remaining.%d for sell\n",(int32_t)remaining_price); break; @@ -306,9 +314,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.0: vin.1 assetoshis to original pubkey CC sellTx/exchangeTx.vout[0].nValue -> [origpubkey] //vout.1: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] - if( (assetoshis= AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis= AssetValidateSellvin(cpTokens, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if( ConstrainVout(tx.vout[0], 1, CCaddr, assetoshis) == 0 ) + else if( ConstrainVout(tx.vout[0], 1, tokensCCaddr, assetoshis) == 0 ) return eval->Invalid("invalid vout for cancel"); preventCCvins = 2; preventCCvouts = 1; @@ -323,7 +331,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //'S'.vout.2: vin.2 value to original pubkey [origpubkey] //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] - if( (assetoshis = AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis = AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillask"); @@ -341,8 +349,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr,0) == 0 ) - return eval->Invalid("mismatched vout0 AssetsCCaddr for fill"); + if ( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr,0) == 0 ) + return eval->Invalid("mismatched vout0 TokenCCaddr for fill"); } } fprintf(stderr,"fill validated\n"); @@ -363,7 +371,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //if ( AssetExactAmounts(false, cp,inputs,outputs,eval,tx,assetid2) == false ) // eval->Invalid("asset2 inputs != outputs"); - if( (assetoshis= AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, CCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillex"); @@ -375,7 +383,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("locked value doesnt match vout0+1 fillex"); else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if( ConstrainVout(tx.vout[2], 1, CCaddr, 0) == 0 ) + if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, 0) == 0 ) return eval->Invalid("vout2 doesnt go to origpubkey fillex"); else if( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) { @@ -383,7 +391,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("asset inputs doesnt match vout2+3 fillex"); } } - else if( ConstrainVout(tx.vout[2], 1, CCaddr, inputs) == 0 ) + else if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, inputs) == 0 ) return eval->Invalid("vout2 doesnt match inputs fillex"); else if( ConstrainVout(tx.vout[1], 0, 0, 0) == 0 ) return eval->Invalid("vout1 is CC for fillex"); @@ -394,7 +402,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillex"); else if( remaining_price != 0 ) { - if( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) + if( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) // TODO: unsure about this, but this is not impl yet anyway return eval->Invalid("mismatched vout0 AssetsCCaddr for fillex"); } } diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 5d919d6e8..9ba6d4a84 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -326,7 +326,9 @@ std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingt CCchange = (inputs - amount); mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,mypk)); // add addr2 - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',bettoken,zeroid,0,Mypubkey()))); + + std::vector voutTokenPubkeysEmpty; //TODO: add token vout pubkeys + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',bettoken,zeroid,0, voutTokenPubkeysEmpty, Mypubkey()))); } else { diff --git a/src/script/script.cpp b/src/script/script.cpp index 475acdfd5..ba3c7f78f 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -407,6 +407,20 @@ bool CScript::MayAcceptCryptoCondition() const cc_free(cond); return out; } +struct CC *CScript::GetCryptoCondition() const +{ + // Get the type mask of the condition + const_iterator pc = this->begin(); + vector data; + opcodetype opcode; + if (!this->GetOp(pc, opcode, data)) return NULL; + if (!(opcode > OP_0 && opcode < OP_PUSHDATA1)) return NULL; + struct CC *cond = cc_readConditionBinary(data.data(), data.size()); + if (!cond) return NULL; + //bool out = IsSupportedCryptoCondition(cond); + //cc_free(cond); + return cond; +} bool CScript::IsCoinImport() const { diff --git a/src/script/script.h b/src/script/script.h index b1294ab25..68757ef12 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -601,6 +601,8 @@ public: bool IsPayToCryptoCondition() const; bool IsCoinImport() const; bool MayAcceptCryptoCondition() const; + struct CC *GetCryptoCondition() const; + /** Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical). */ bool IsPushOnly() const; From da58ead2d35ed374fa24b867d65b75a4e1ecc84c Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Fri, 4 Jan 2019 16:06:37 +0100 Subject: [PATCH 1143/3904] Prevent sell and buy offers to be canceled by anybody (#9) - Prevent sell and buy offers to be canceled by anybody --- src/cc/CCassetsCore.cpp | 2 ++ src/cc/CCassetstx.cpp | 28 ++++++++++++------ src/cc/CCtx.cpp | 3 +- src/cc/assets.cpp | 63 ++++++++++++++++++----------------------- 4 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 837c4361e..f0afd2b84 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -432,6 +432,8 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout0 for buyvin"); + else if ( vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("invalid normal vout1 for buyvin"); else { //fprintf(stderr,"have %.8f checking assetid origaddr.(%s)\n",(double)nValue/COIN,origaddr); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index fe86d58de..a1ec8a816 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -371,7 +371,7 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in mypk = pubkey2pk(Mypubkey()); - if ((inputs = AddNormalinputs(mtx, mypk, bidamount+txfee, 64)) > 0) + if ((inputs = AddNormalinputs(mtx, mypk, bidamount+(2*txfee), 64)) > 0) { std::cerr << "CreateBuyOffer() inputs=" << inputs << std::endl; if (inputs < bidamount+txfee) { @@ -382,7 +382,7 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in CPubKey unspendablePubkey = GetUnspendable(cpAssets, 0); mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount, unspendablePubkey)); - + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); std::vector voutTokenPubkeys; // should be empty - no token vouts return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('b', assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()))); @@ -409,12 +409,12 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p } cpTokens = CCinit(&C, EVAL_TOKENS); // NOTE: tokens is here - + if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, askamount, 60)) > 0) @@ -428,13 +428,14 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p CPubKey unspendablePubkey = GetUnspendable(cpTokens, 0); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, unspendablePubkey)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); if (inputs > askamount) CCchange = (inputs - askamount); if (CCchange != 0) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(unspendablePubkey); + voutTokenPubkeys.push_back(unspendablePubkey); opret = EncodeAssetOpRet('s',assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,opret)); @@ -539,7 +540,9 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) { bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets + mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); std::vector voutTokenPubkeys; // should be empty, no tokens vout @@ -554,27 +557,36 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; - struct CCcontract_info *cpTokens, C; + struct CCcontract_info *cpTokens,*cpAssets,C,assetsC; cpTokens = CCinit(&C, EVAL_TOKENS); + cpAssets = CCinit(&assetsC, EVAL_ASSETS); if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) { askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); + mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); - + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(mypk); + char myCCaddr[65]; + uint8_t myPrivkey[32]; + Myprivkey(myPrivkey); + GetCCaddress(cpAssets, myCCaddr, mypk); + CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); + return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, voutTokenPubkeys, Mypubkey()))); } } diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 3d95d0f17..971ba160d 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -175,7 +175,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr); - continue; + return(""); } uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) @@ -192,6 +192,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { fprintf(stderr,"vini.%d has CC signing error address.(%s)\n",i,destaddr); + return(""); } } } else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str()); diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 3a62a526a..127a0e50a 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -45,32 +45,20 @@ valid CC output: create or transfer or buyoffer or selloffer or exchange or cancel or fill - create - vin.0: normal input - vout.0: issuance assetoshis to CC - vout.1: tag sent to normal address of AssetsCCaddress - vout.2: normal output for change (if any) - vout.n-1: opreturn [EVAL_ASSETS] ['c'] [origpubkey] "" "" - - transfer - vin.0: normal input - vin.1 .. vin.n-1: valid CC outputs - vout.0 to n-2: assetoshis output to CC - vout.n-2: normal output for change (if any) - vout.n-1: opreturn [EVAL_ASSETS] ['t'] [assetid] buyoffer: vins.*: normal inputs (bid + change) vout.0: amount of bid to unspendable - vout.1: normal output for change (if any) + vout.1: CC output for marker + vout.2: normal output for change (if any) vout.n-1: opreturn [EVAL_ASSETS] ['b'] [assetid] [amount of asset required] [origpubkey] cancelbuy: - vin.0: normal input - vin.1: unspendable.(vout.0 from buyoffer) buyTx.vout[0] + vin.0: unspendable.(vout.0 from buyoffer) buyTx.vout[0] + vin.1: CC marker from buyoffer for txfee vout.0: vin.1 value to original pubkey buyTx.vout[0].nValue -> [origpubkey] vout.1: normal output for change (if any) - vout.n-1: opreturn [EVAL_ASSETS] ['o'] [assetid] + vout.n-1: opreturn [EVAL_ASSETS] ['o'] [assetid] 0 0 [origpubkey] fillbuy: vin.0: normal input @@ -87,8 +75,9 @@ vin.0: normal input vin.1+: valid CC output for sale vout.0: vin.1 assetoshis output to CC to unspendable - vout.1: CC output for change (if any) - vout.2: normal output for change (if any) + vout.1: CC output for marker + vout.2: CC output for change (if any) + vout.3: normal output for change (if any) vout.n-1: opreturn [EVAL_ASSETS] ['s'] [assetid] [amount of native coin required] [origpubkey] exchange: @@ -100,8 +89,8 @@ vout.n-1: opreturn [EVAL_ASSETS] ['e'] [assetid] [assetid2] [amount of asset2 required] [origpubkey] cancel: - vin.0: normal input - vin.1: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx + vin.0: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx + vin.1: CC marker from selloffer for txfee vout.0: vin.1 assetoshis to original pubkey CC sellTx/exchangeTx.vout[0].nValue -> [origpubkey] vout.1: normal output for change (if any) vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] @@ -213,7 +202,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti case 'b': // buyoffer //vins.*: normal inputs (bid + change) //vout.0: amount of bid to unspendable - //vout.1: normal output for change (if any) + //vout.1: CC output for marker + //vout.2: normal output for change (if any) // vout.n-1: opreturn [EVAL_ASSETS] ['b'] [assetid] [amount of asset required] [origpubkey] if( remaining_price == 0 ) return eval->Invalid("illegal null amount for buyoffer"); @@ -225,8 +215,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti break; case 'o': // cancelbuy - //vin.0: normal input - //vin.1: unspendable.(vout.0 from buyoffer) buyTx.vout[0] + //vin.0: unspendable.(vout.0 from buyoffer) buyTx.vout[0] + //vin.1: CC marker from buyoffer for txfee //vout.0: vin.1 value to original pubkey buyTx.vout[0].nValue -> [origpubkey] //vout.1: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['o'] @@ -234,7 +224,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return(false); else if( ConstrainVout(tx.vout[0],0, origaddr, nValue) == 0 ) return eval->Invalid("invalid refund for cancelbuy"); - preventCCvins = 2; + preventCCvins = 3; preventCCvouts = 0; fprintf(stderr,"cancelbuy validated to origaddr.(%s)\n",origaddr); break; @@ -288,29 +278,32 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vin.0: normal input //vin.1+: valid CC output for sale //vout.0: vin.1 assetoshis output to CC to unspendable - //vout.1: CC output for change (if any) - //vout.2: normal output for change (if any) + //vout.1: CC output for marker + //vout.2: CC output for change (if any) + //vout.3: normal output for change (if any) //'s'.vout.n-1: opreturn [EVAL_ASSETS] ['s'] [assetid] [amount of native coin required] [origpubkey] //'e'.vout.n-1: opreturn [EVAL_ASSETS] ['e'] [assetid] [assetid2] [amount of asset2 required] [origpubkey] - preventCCvouts = 1; + preventCCvouts = 2; if( remaining_price == 0 ) return eval->Invalid("illegal null remaining_price for selloffer"); - if( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() != 0 ) // is cc change present? + if ( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("invalid normal vout1 for sellvin"); + if( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) { preventCCvouts++; if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, 0) == 0 ) // check also vout[0] return eval->Invalid("mismatched vout0 TokensCCaddr for selloffer"); - else if( tx.vout[0].nValue + tx.vout[1].nValue != inputs ) - return eval->Invalid("mismatched vout0+vout1 total for selloffer"); + else if( tx.vout[0].nValue + tx.vout[2].nValue != inputs ) + return eval->Invalid("mismatched vout0+vout2 total for selloffer"); } else if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, inputs) == 0 ) // no cc change, just vout[0] return eval->Invalid("mismatched vout0 TokensCCaddr for selloffer"); //fprintf(stderr,"remaining.%d for sell\n",(int32_t)remaining_price); break; - case 'x': // cancel - //vin.0: normal input - //vin.1: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx + case 'x': // cancel + //vin.0: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx + //vin.1: CC marker from selloffer for txfee //vout.0: vin.1 assetoshis to original pubkey CC sellTx/exchangeTx.vout[0].nValue -> [origpubkey] //vout.1: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] @@ -318,7 +311,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return(false); else if( ConstrainVout(tx.vout[0], 1, tokensCCaddr, assetoshis) == 0 ) return eval->Invalid("invalid vout for cancel"); - preventCCvins = 2; + preventCCvins = 3; preventCCvouts = 1; break; From 5c95c974fdc54d8071329e7372d02203e4d4dc2b Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Fri, 4 Jan 2019 16:13:47 +0100 Subject: [PATCH 1144/3904] Change vin.vout structure in comments --- src/cc/assets.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 127a0e50a..7c413d96a 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -54,10 +54,12 @@ vout.n-1: opreturn [EVAL_ASSETS] ['b'] [assetid] [amount of asset required] [origpubkey] cancelbuy: - vin.0: unspendable.(vout.0 from buyoffer) buyTx.vout[0] - vin.1: CC marker from buyoffer for txfee + vin.0: normal input + vin.1: unspendable.(vout.0 from buyoffer) buyTx.vout[0] + vin.2: CC marker from buyoffer for txfee vout.0: vin.1 value to original pubkey buyTx.vout[0].nValue -> [origpubkey] - vout.1: normal output for change (if any) + vout.1: vin.2 back to users pubkey + vout.2: normal output for change (if any) vout.n-1: opreturn [EVAL_ASSETS] ['o'] [assetid] 0 0 [origpubkey] fillbuy: @@ -89,10 +91,12 @@ vout.n-1: opreturn [EVAL_ASSETS] ['e'] [assetid] [assetid2] [amount of asset2 required] [origpubkey] cancel: - vin.0: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx - vin.1: CC marker from selloffer for txfee + vin.0: normal input + vin.1: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx + vin.2: CC marker from selloffer for txfee vout.0: vin.1 assetoshis to original pubkey CC sellTx/exchangeTx.vout[0].nValue -> [origpubkey] - vout.1: normal output for change (if any) + vout.1: vin.2 back to users pubkey + vout.2: normal output for change (if any) vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] fillsell: @@ -215,10 +219,12 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti break; case 'o': // cancelbuy - //vin.0: unspendable.(vout.0 from buyoffer) buyTx.vout[0] - //vin.1: CC marker from buyoffer for txfee + //vin.0: normal input + //vin.1: unspendable.(vout.0 from buyoffer) buyTx.vout[0] + //vin.2: CC marker from buyoffer for txfee //vout.0: vin.1 value to original pubkey buyTx.vout[0].nValue -> [origpubkey] - //vout.1: normal output for change (if any) + //vout.1: vin.2 back to users pubkey + //vout.2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['o'] if( (nValue= AssetValidateBuyvin(cpAssets, eval, tmpprice, tmporigpubkey, assetsCCaddr, origaddr, tx, assetid)) == 0 ) return(false); @@ -302,10 +308,12 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti break; case 'x': // cancel - //vin.0: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx - //vin.1: CC marker from selloffer for txfee + //vin.0: normal input + //vin.1: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx + //vin.2: CC marker from selloffer for txfee //vout.0: vin.1 assetoshis to original pubkey CC sellTx/exchangeTx.vout[0].nValue -> [origpubkey] - //vout.1: normal output for change (if any) + //vout.1: vin.2 back to users pubkey + //vout.2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] if( (assetoshis= AssetValidateSellvin(cpTokens, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); From a0fc5d6ae472cd5830f91a74fa1df6ed48de1108 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 7 Jan 2019 23:30:57 +0500 Subject: [PATCH 1145/3904] Corrected both Cancels, 'B' and TokenTransfer --- src/Makefile.am | 2 ++ src/cc/CCassetsCore.cpp | 4 +-- src/cc/CCassetstx.cpp | 34 ++++++++++++++++++-------- src/cc/CCtokens.cpp | 54 +++++++++++++++++++++++++++-------------- src/cc/CCtokens.h | 39 ++--------------------------- src/cc/assets.cpp | 2 ++ src/script/script.cpp | 14 ----------- src/script/script.h | 2 -- 8 files changed, 68 insertions(+), 83 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 9588cfe44..5e665cc3c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -384,6 +384,8 @@ libbitcoin_wallet_a_SOURCES = \ transaction_builder.cpp \ wallet/rpcdisclosure.cpp \ wallet/rpcdump.cpp \ + cc/CCtokens.cpp \ + cc/CCassetsCore.cpp \ cc/CCassetstx.cpp \ cc/CCtx.cpp \ wallet/rpcwallet.cpp \ diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index f0afd2b84..67e23837f 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -432,12 +432,12 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout0 for buyvin"); - else if ( vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ((funcid = DecodeAssetOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey)) == 'b' && vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) // marker is only in 'b'? return eval->Invalid("invalid normal vout1 for buyvin"); else { //fprintf(stderr,"have %.8f checking assetid origaddr.(%s)\n",(double)nValue/COIN,origaddr); - if ( vinTx.vout.size() > 0 && (funcid= DecodeAssetOpRet(vinTx.vout[vinTx.vout.size()-1].scriptPubKey, evalCode, assetid,assetid2,tmpprice,tmporigpubkey)) != 'b' && funcid != 'B' ) + if ( vinTx.vout.size() > 0 && funcid != 'b' && funcid != 'B' ) return eval->Invalid("invalid opreturn for buyvin"); else if ( refassetid != assetid ) return eval->Invalid("invalid assetid for buyvin"); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index a1ec8a816..6bf176f24 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -148,7 +148,7 @@ UniValue AssetOrders(uint256 refassetid) //std::cerr << "addOrders() txid=" << txid.GetHex() << std::endl; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); + // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); //std::cerr << "addOrders() vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl; if (vintx.vout.size() > 0 && (funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) { @@ -428,7 +428,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p CPubKey unspendablePubkey = GetUnspendable(cpTokens, 0); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, unspendablePubkey)); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); //marker if (inputs > askamount) CCchange = (inputs - askamount); if (CCchange != 0) @@ -526,6 +526,8 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) CPubKey mypk; struct CCcontract_info *cpAssets, C; + uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; + cpAssets = CCinit(&C, EVAL_ASSETS); if (txfee == 0) @@ -540,7 +542,11 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) { bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets - mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); + + if( DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 'b') + mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' (not 'B') + // TODO: spend it also in FillBuyOffer? + mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -559,6 +565,8 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; struct CCcontract_info *cpTokens,*cpAssets,C,assetsC; + uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; + cpTokens = CCinit(&C, EVAL_TOKENS); cpAssets = CCinit(&assetsC, EVAL_ASSETS); @@ -574,7 +582,11 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); - mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); + + if (DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 's') + mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' (not 'S') + // TODO: spend it also in FillSell? + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -663,7 +675,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f // token vout verification pubkeys: std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(unspendableTokensPk); + voutTokenPubkeys.push_back(pubkey2pk(origpubkey)); return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, EncodeAssetOpRet('B', assetid, zeroid, remaining_required, voutTokenPubkeys, origpubkey))); } else return("dont have any assets to fill bid"); @@ -743,22 +755,24 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt if (assetid2 != zeroid && inputs > paid_nValue) CCchange = (inputs - paid_nValue); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, orig_assetoshis - received_assetoshis, GetUnspendable(cpTokens, NULL))); // 0 tokens cc addr - ask remainder - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); //1 tokens to self + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, orig_assetoshis - received_assetoshis, GetUnspendable(cpTokens, NULL))); // vout.0 tokens cc addr - ask remainder + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); //vout.1 tokens to self + // NOTE: no marker here + if (assetid2 != zeroid) { std::cerr << "FillSell() WARNING: asset swap not implemented yet! (paid_nValue)" << std::endl; - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //2 tokens... (swap is not implemented yet) + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //vout.2 tokens... (swap is not implemented yet) } else { //std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl; - mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //2 coins normal to whom who asked token + mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //vout.2 coins normal to whom who asked token } // not implemented if (CCchange != 0) { std::cerr << "FillSell() WARNING: asset swap not implemented yet! (CCchange)" << std::endl; - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //3 coins in Assets cc addr + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //vout.3 coins in Assets cc addr } // vout verification pubkeys: diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index d9e689f85..8e5d98f47 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -51,14 +51,19 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector origpubkey,st } // this is for other contracts which use tokens and build customized extra payloads to token's opret: -CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector payload) +CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys) { CScript opret; + uint8_t ccType = 0; + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) + ccType = voutPubkeys.size(); + //uint8_t evalcode = EVAL_TOKENS; tokenid = revuint256(tokenid); //uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l'; - opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); + //opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); + opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; if (ccType >= 1) ss << voutPubkeys[0]; if (ccType == 2) ss << voutPubkeys[1];); return(opret); } @@ -148,6 +153,8 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & char destaddr[64], origaddr[64], CCaddr[64]; std::vector voutTokenPubkeys; + //return true; + numvins = tx.vin.size(); numvouts = tx.vout.size(); outputs = inputs = 0; @@ -161,7 +168,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); else if (IsCCInput(tx.vin[0].scriptSig) != 0) - return eval->Invalid("illegal token vin0"); // why? (dimxy) + return eval->Invalid("illegal token vin0"); else if (numvouts < 1) return eval->Invalid("no vouts"); else if (funcid != 'c') @@ -176,10 +183,6 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & } } - // init for forwarding validation call - struct CCcontract_info *cpOther = NULL, C; - if (evalCodeInOpret != EVAL_TOKENS) - cpOther = CCinit(&C, evalCodeInOpret); switch (funcid) { @@ -211,11 +214,17 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & } // forward validation if evalcode in opret is not EVAL_TOKENS - if (cpOther) - return cpOther->validate(cpOther, eval, tx, nIn); - else - return eval->Invalid("unsupported evalcode in opret"); + // init for forwarding validation call + if (evalCodeInOpret != EVAL_TOKENS) { // TODO: should we check also only allowed for tokens evalcodes, like EVAL_ASSETS, EVAL_GATEWAYS? + struct CCcontract_info *cpOther = NULL, C; + cpOther = CCinit(&C, evalCodeInOpret); + if (cpOther) + return cpOther->validate(cpOther, eval, tx, nIn); + else + return eval->Invalid("unsupported evalcode in opret"); + } + return true; // what does this do? // return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); } @@ -404,7 +413,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t tokenValIndentSize++; // validate vouts of vintx //std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; - tokenoshis = IsTokensvout(goDeeper, false/*<--do not have pubkeys*/, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeysEmpty); + tokenoshis = IsTokensvout(goDeeper, false/*<--do not have pubkeys for now*/, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeysEmpty); tokenValIndentSize--; if (tokenoshis != 0) { @@ -435,7 +444,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t if (inputs != outputs) { if (tx.GetHash() != tokenid) - std::cerr << indentStr << "TokenExactAmounts() found unequal inputs=" << inputs << " vs outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not create tx" << std::endl; + std::cerr << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl; return false; // do not call eval->Invalid() here! } else @@ -477,7 +486,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); std::vector vinPubkeysEmpty; - if ((nValue = IsTokensvout(true, false, cp, NULL, vopretExtra, vintx, vout, tokenid, vinPubkeysEmpty)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + if ((nValue = IsTokensvout(true, false/*<-- do not check spending outside EVAL_TOKENS for now */, cp, NULL, vopretExtra, vintx, vout, tokenid, vinPubkeysEmpty)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) { if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, vout, CScript())); @@ -559,13 +568,22 @@ std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector d if (inputs > total) CCchange = (inputs - total); //for (i=0; i voutTokenPubkeys; + voutTokenPubkeys.push_back(pubkey2pk(destpubkey)); // dest pubkey for validating vout + + return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet('t', EVAL_TOKENS, assetid, voutTokenPubkeys))); // By setting EVAL_TOKENS we're getting out from assets validation code + } + else { + fprintf(stderr, "not enough CC token inputs for %.8f\n", (double)total / COIN); } - else fprintf(stderr, "not enough CC asset inputs for %.8f\n", (double)total / COIN); //} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size()); } + else { + fprintf(stderr, "not enough normal inputs for txfee\n"); + } return(""); } \ No newline at end of file diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index 8ecbc1094..f65a56b41 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -31,46 +31,11 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t //int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); +CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys); -//this is in CCinclude.h int64_t AddTokenInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); +//this is in CCinclude.h int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); //this is in CCinclude.h uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); -/* -// CCassetsCore -CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description); -CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,int64_t price,std::vector origpubkey); -bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); -//uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); -bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); -int64_t IsAssetvout(bool compareTotals, struct CCcontract_info *cp, Eval* eval, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); -bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); -bool ValidateAskRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); -bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); -bool SetBidFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); -int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); -bool AssetExactAmounts(bool compareTotals, struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); - -// CCassetstx -int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); -int64_t AddAssetInputs(CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); -UniValue AssetOrders(uint256 tokenid); -UniValue AssetInfo(uint256 tokenid); -UniValue AssetList(); -std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); -std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total); -std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode); - -std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64_t pricetotal); -std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid); -std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t fillamount); -std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t pricetotal); -std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 assetid2,int64_t pricetotal); -std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid); -std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 asktxid,int64_t fillamount); -*/ #endif diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 7c413d96a..ea44453ff 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -135,6 +135,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti uint8_t funcid, evalCodeInOpret; char destaddr[64], origaddr[64], assetsCCaddr[64], tokensCCaddr[64]; + //return true; + // we need this for validating tokens' vins/vous: struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); diff --git a/src/script/script.cpp b/src/script/script.cpp index ba3c7f78f..475acdfd5 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -407,20 +407,6 @@ bool CScript::MayAcceptCryptoCondition() const cc_free(cond); return out; } -struct CC *CScript::GetCryptoCondition() const -{ - // Get the type mask of the condition - const_iterator pc = this->begin(); - vector data; - opcodetype opcode; - if (!this->GetOp(pc, opcode, data)) return NULL; - if (!(opcode > OP_0 && opcode < OP_PUSHDATA1)) return NULL; - struct CC *cond = cc_readConditionBinary(data.data(), data.size()); - if (!cond) return NULL; - //bool out = IsSupportedCryptoCondition(cond); - //cc_free(cond); - return cond; -} bool CScript::IsCoinImport() const { diff --git a/src/script/script.h b/src/script/script.h index 68757ef12..b1294ab25 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -601,8 +601,6 @@ public: bool IsPayToCryptoCondition() const; bool IsCoinImport() const; bool MayAcceptCryptoCondition() const; - struct CC *GetCryptoCondition() const; - /** Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical). */ bool IsPushOnly() const; From 90f682f022ba5284ae506e31d0522284e85045c2 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 7 Jan 2019 19:00:34 +0500 Subject: [PATCH 1146/3904] Heir corrected for Tokens contract --- src/cc/CCassetstx.cpp | 2 +- src/cc/heir.cpp | 89 ++++++++++++++++++++++++++++++++---------- src/cc/heir_validate.h | 43 ++++++++------------ 3 files changed, 85 insertions(+), 49 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 6bf176f24..1c2012534 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -597,7 +597,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) uint8_t myPrivkey[32]; Myprivkey(myPrivkey); GetCCaddress(cpAssets, myCCaddr, mypk); - CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); + CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); //do we need this? Seems FinalizeCCTx can attach to any evalcode cc addr by calling Getscriptaddress return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, voutTokenPubkeys, Mypubkey()))); } diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 90557d7ac..7512b54ed 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -14,7 +14,7 @@ ******************************************************************************/ #include "CCHeir.h" -#include "CCassets.h" +#include "CCtokens.h" #include "heir_validate.h" @@ -433,47 +433,79 @@ bool HeirExactAmounts(struct CCcontract_info* cp, Eval* eval, const CTransaction } // makes coin initial tx opret -CScript EncodeHeirCreateOpRet(uint8_t eval, uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) +CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); + uint8_t evalcode = EVAL_HEIR; + + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); } // makes coin additional tx opret -CScript EncodeHeirOpRet(uint8_t eval, uint8_t funcid, uint256 fundingtxid) +CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid) { + uint8_t evalcode = EVAL_HEIR; + fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)funcid << fundingtxid); + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)funcid << fundingtxid); } // makes opret for tokens while they are inside Heir contract address space - initial funding -CScript EncodeHeirAssetsCreateOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) +CScript EncodeHeirTokensCreateOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) { + uint8_t evalcode = EVAL_TOKENS; + uint8_t ccType = 0; + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) + ccType = voutPubkeys.size(); + tokenid = revuint256(tokenid); - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)'t' << tokenid << (uint8_t)funcid << ownerPubkey << heirPubkey << inactivityTimeSec << hearName); + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)'t' << tokenid << (uint8_t)funcid << ccType; if (ccType >= 1) ss << voutPubkeys[0]; if (ccType == 2) ss << voutPubkeys[1]; ss << ownerPubkey << heirPubkey << inactivityTimeSec << hearName); } // makes opret for tokens while they are inside Heir contract address space - additional funding -CScript EncodeHeirAssetsOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, uint256 fundingtxid) +CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid) { + uint8_t evalcode = EVAL_HEIR; + uint8_t ccType = 0; + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) + ccType = voutPubkeys.size(); + tokenid = revuint256(tokenid); fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)eval << (uint8_t)'t' << tokenid << (uint8_t)funcid << fundingtxid); + return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)'t' << tokenid << ccType; if (ccType >= 1) ss << voutPubkeys[0]; if (ccType == 2) ss << voutPubkeys[1]; ss << (uint8_t)funcid << fundingtxid); } +// helper for decode heir opret payload +// NOTE: Heir for coins has the same opret as Heir for tokens +uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret) { + uint8_t heirFuncId = 0; + + bool result = E_UNMARSHAL(vopretExtra, { ss >> heirFuncId; ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; if (IS_CHARINSTR(heirFuncId, "F")) { ss >> heirName; } if (IS_CHARINSTR(heirFuncId, "AC")) { ss >> fundingTxidInOpret; } }); + if (!result /*|| assetFuncId != 't' -- any tx is ok*/) + return (uint8_t)0; + + return heirFuncId; +} /** * decode opret vout for Heir contract */ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, bool noLogging) { - std::vector vopret; - uint8_t opretEval = 0; - uint8_t funcId = 0; + uint8_t evalCodeInOpret = 0; + + std::vector vopretExtra; + uint256 dummyTokenid; + std::vector voutPubkeysDummy; fundingTxidInOpret = zeroid; //to init + tokenid = zeroid; - GetOpReturnData(scriptPubKey, vopret); - if (vopret.size() > 1) { + // First - decode token opret: + uint8_t funcId = DecodeTokenOpRet(scriptPubKey, evalCodeInOpret, tokenid, voutPubkeysDummy, vopretExtra); + + //GetOpReturnData(scriptPubKey, vopret); + + if (funcId != 0 && vopretExtra.size() > 1) { // TODO: add this funcId cond in Assets too // NOTE: it unmarshals for all F, A and C - Helper::UnmarshalOpret(vopret, opretEval, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret); + uint8_t heirFuncId = _UnmarshalOpret(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret); /* std::cerr << "DecodeHeirOpRet() e=" << (int)e @@ -484,14 +516,14 @@ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 & */ //if (e == EVAL_HEIR && IS_CHARINSTR(funcId, "FAC")) - if (opretEval == EVAL_HEIR && Helper::isMyFuncId(funcId)) { + if (evalCodeInOpret == EVAL_HEIR && Helper::isMyFuncId(heirFuncId)) { tokenid = revuint256(tokenid); fundingTxidInOpret = revuint256(fundingTxidInOpret); - return funcId; + return heirFuncId; } else { - if(!noLogging) std::cerr << "DecodeHeirOpRet() warning unexpected OP_RETURN eval=" << (int)opretEval << " or field type=" << (char)(funcId ? funcId : ' ') << '\n'; + if(!noLogging) std::cerr << "DecodeHeirOpRet() warning unexpected OP_RETURN eval=" << (int)evalCodeInOpret << " or field type=" << (char)(heirFuncId ? heirFuncId : ' ') << '\n'; } } else { @@ -843,10 +875,15 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } + // add 1of2 vout validation pubkeys: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(myPubkey); + voutTokenPubkeys.push_back(heirPubkey); + // add change for txfee and opreturn vouts and sign tx: return (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, // CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_HEIR << (uint8_t)'F' << myPubkey << heirPubkey << inactivityTimeSec << heirName))); - Helper::makeCreateOpRet(tokenid, myPubkey, heirPubkey, inactivityTimeSec, heirName))); + Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName))); } else // TODO: need result return unification with heiradd and claim std::cerr << "HeirFund() could not find owner inputs" << std::endl; @@ -928,9 +965,14 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } + // add 1of2 vout validation pubkeys: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(ownerPubkey); + voutTokenPubkeys.push_back(heirPubkey); + // add opreturn 'A' and sign tx: // this txfee ignored std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeAddOpRet(tokenid, fundingtxid))); + Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid))); result.push_back(Pair("result", "success")); result.push_back(Pair("hextx", rawhextx)); @@ -1068,9 +1110,14 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + // add 1of2 vout validation pubkeys: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(ownerPubkey); + voutTokenPubkeys.push_back(heirPubkey); + // add opreturn 'C' and sign tx: // this txfee will be ignored std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeClaimOpRet(tokenid, fundingtxid)); + Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid)); result.push_back(Pair("result", "success")); result.push_back(Pair("hextx", rawhextx)); diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 8b432e8e0..108562e24 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -11,12 +11,12 @@ // makes coin initial tx opret -CScript EncodeHeirCreateOpRet(uint8_t eval, uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); +CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); // makes coin additional tx opret -CScript EncodeHeirOpRet(uint8_t eval, uint8_t funcid, uint256 fundingtxid); +CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid); -CScript EncodeHeirAssetsCreateOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName); -CScript EncodeHeirAssetsOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, uint256 fundingtxid); +CScript EncodeHeirTokensCreateOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName); +CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid); //CScript EncodeHeirConvertedAssetsOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 fundingtxid); template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, bool &isHeirSpendingBegan); @@ -37,18 +37,14 @@ public: return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); } - static CScript makeCreateOpRet(uint256 dummyid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return EncodeHeirCreateOpRet((uint8_t)EVAL_HEIR, (uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + static CScript makeCreateOpRet(uint256 dummyid, std::vector dummyPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { + return EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName); } - static CScript makeAddOpRet(uint256 dummyid, uint256 fundingtxid) { - return EncodeHeirOpRet((uint8_t)EVAL_HEIR, (uint8_t)'A', fundingtxid); + static CScript makeAddOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid) { + return EncodeHeirOpRet((uint8_t)'A', fundingtxid); } - static CScript makeClaimOpRet(uint256 dummyid, uint256 fundingtxid) { - return EncodeHeirOpRet((uint8_t)EVAL_HEIR, (uint8_t)'C', fundingtxid); - } - - static void UnmarshalOpret(std::vector vopret, uint8_t &e, uint8_t &funcId, uint256 &dummytokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret) { - E_UNMARSHAL(vopret, { ss >> e; ss >> funcId; ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; if (IS_CHARINSTR(funcId, "F")) { ss >> heirName; } if (IS_CHARINSTR(funcId, "AC")) { ss >> fundingTxidInOpret; } }); + static CScript makeClaimOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid) { + return EncodeHeirOpRet((uint8_t)'C', fundingtxid); } static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } @@ -64,29 +60,22 @@ public: // helper class to allow polymorphic behaviour for HeirXXX() functions in case of tokens class TokenHelper { public: - static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddTokenCCInputs(cp, mtx, ownerPubkey, tokenid, total, maxinputs); } - static CScript makeCreateOpRet(uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return EncodeHeirAssetsCreateOpRet((uint8_t)EVAL_HEIR, (uint8_t)'F', tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { + return EncodeHeirTokensCreateOpRet((uint8_t)'F', tokenid, voutTokenPubkeys, ownerPubkey, heirPubkey, inactivityTimeSec, heirName); } - static CScript makeAddOpRet(uint256 tokenid, uint256 fundingtxid) { - return EncodeHeirAssetsOpRet((uint8_t)EVAL_HEIR, (uint8_t)'A', tokenid, fundingtxid); + static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid) { + return EncodeHeirTokensOpRet((uint8_t)'A', tokenid, voutTokenPubkeys, fundingtxid); } - static CScript makeClaimOpRet(uint256 tokenid, uint256 fundingtxid) { - return EncodeHeirAssetsOpRet((uint8_t)EVAL_HEIR, (uint8_t)'C', tokenid, fundingtxid); + static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid) { + return EncodeHeirTokensOpRet((uint8_t)'C', tokenid, voutTokenPubkeys, fundingtxid); } - static void UnmarshalOpret(std::vector vopret, uint8_t &e, uint8_t &funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingtxidInOpret) { - uint8_t assetFuncId = '\0'; - bool result = E_UNMARSHAL(vopret, { ss >> e; ss >> assetFuncId; ss >> tokenid; ss >> funcId; if (IS_CHARINSTR(funcId, "F")) { ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; } if (IS_CHARINSTR(funcId, "AC")) { ss >> fundingtxidInOpret; } }); - if (!result /*|| assetFuncId != 't' -- any tx is ok*/) - funcId = 0; - } static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { From d1bd5b3b6c0cc645addf8889e7252baa9ca6b413 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 9 Jan 2019 16:58:52 +0500 Subject: [PATCH 1147/3904] Squashed commit of the following: commit 843168eddff34390f19fa661ac6315e1a51aafe2 Author: dimxy Date: Wed Jan 9 14:34:03 2019 +0500 logging improved for CCtokens.cpp commit 43c5b3a5c4e36e76a235f987e07fe893d941d95e Author: dimxy Date: Wed Jan 9 14:23:41 2019 +0500 more extra logging disabled for heir and token commit a3f7ca963a0042237f4c97d6d89852646b541c6c Author: dimxy Date: Wed Jan 9 14:13:58 2019 +0500 more extra logging disabled commit f4dec8f8ad733c5a61dd0fc9f3decd103dd7a0c3 Author: dimxy Date: Wed Jan 9 14:05:45 2019 +0500 more extra logging disabled commit eb9a41472004ccdacdacfc12b79880ac6da390ee Author: dimxy Date: Wed Jan 9 13:50:11 2019 +0500 extra logging disabled in heir and tokens commit 0fe01c8a7b52b03e0c0a3ba5d77f916862031d23 Author: dimxy Date: Wed Jan 9 13:15:08 2019 +0500 heir normal input validator changed to CNullValidator commit 3b86e87c83b6993d5a3b4c056c10120223e8c9ed Author: dimxy Date: Wed Jan 9 12:58:03 2019 +0500 enabled logiing in FinalizeCCtx commit 2ea87c1b3c7967b316d22e2e65fc3c0203cc4b03 Author: dimxy Date: Wed Jan 9 12:37:43 2019 +0500 corrected parameters for tests commit 216eb4ed84c6fd23e3fc22cd79509a09c8504c0c Author: dimxy Date: Wed Jan 9 12:22:30 2019 +0500 changed to eval_assets for test commit 2af850f06a4692200864a316208cdfc0709b1634 Author: dimxy Date: Wed Jan 9 02:42:43 2019 +0500 heiradd loggin vin commit 28e033d2b2a1a01b2bc9c2d51a81b61ae53f3a29 Author: dimxy Date: Wed Jan 9 02:04:33 2019 +0500 logging added commit ef1dbc504c5984a4997b5e06e736fa7b5b4e125d Author: dimxy Date: Wed Jan 9 01:29:46 2019 +0500 logging added and corrected commit 98c1e5a6896a97667c9d64f347c26b36c6a320a9 Author: dimxy Date: Wed Jan 9 01:05:17 2019 +0500 corrected isHeirSpendingBegan init in _UnmarshalOpret commit 6006f073bfc136ed06c1636b3e6ffa7b403ce1d9 Author: dimxy Date: Wed Jan 9 01:01:18 2019 +0500 corrected dummyIsHeirSpendingBegan using commit 9a95edf4e311a80538dd7b13aeeb201e97474ee8 Author: dimxy Date: Wed Jan 9 00:53:50 2019 +0500 isHeirSpendingBegan is put in opret commit 4bd210709626e2f8b99889e50410eb0f75b3dbda Author: dimxy Date: Tue Jan 8 20:16:20 2019 +0500 added logging to _FindLastextFundingTx for print C vouts commit 3603b49c1143b1efe82dd545b9d7dca43f5bcec0 Author: dimxy Date: Tue Jan 8 19:25:11 2019 +0500 corrected isHeirSpendingBegun calc commit e7d6923d4be080a5e98405634fafb175fa55f801 Author: dimxy Date: Tue Jan 8 18:43:35 2019 +0500 yet another cpToken correction in RunValidators commit e425dcc4497652a062b45d4a5ce4c137bd2caa3d Author: dimxy Date: Tue Jan 8 18:22:08 2019 +0500 changed cp param to cpTokens for heir tokens in validation commit a4420f30d42d93dbc2729db4a5b2895d4b16d22b Author: dimxy Date: Tue Jan 8 17:11:10 2019 +0500 corrected EVAL_HEIR in create opret commit 788d75263fd5aaa7b66417441622c9bb6603ab81 Author: dimxy Date: Tue Jan 8 16:41:07 2019 +0500 corrected opret forming for 'F', tokens commit 92bf6c53b36a5a4450b5c7079383792d634d61a7 Author: dimxy Date: Tue Jan 8 16:12:09 2019 +0500 _UnmarshalOpret corrected for non F commit e4eb26e875d44f3e4c1d45aff6df8a7026b3329a Author: dimxy Date: Tue Jan 8 15:26:34 2019 +0500 Revert "CCduration debug logging added" This reverts commit 5ffc2b0a8b49d387cd175754738d2c07701c7856. commit ce97ac88af0b87b304ad1fc9cb29db0803d0bd42 Author: dimxy Date: Tue Jan 8 15:17:10 2019 +0500 changed pindex to pindexTip in CCduration for better reading commit 5ffc2b0a8b49d387cd175754738d2c07701c7856 Author: dimxy Date: Tue Jan 8 14:43:07 2019 +0500 CCduration debug logging added commit 34afdd16f0f6b5b97da864f082dcd019a7566da7 Author: dimxy Date: Tue Jan 8 12:23:31 2019 +0500 corrected again order to DecodeOpRet call in heir commit bba6149969ea23aa4e3c6263a36bae0ba7fa6f5d Author: dimxy Date: Tue Jan 8 12:17:11 2019 +0500 logging added in IsHeirFundingVout commit 6c5d4b313ef3e54cb5eb2bf67b2fa78d9ffd0b04 Author: dimxy Date: Tue Jan 8 12:02:15 2019 +0500 logging added to Add1of2AddrInputs commit 40d6d84971a8ed764523567f08df4c74fda4f12d Author: dimxy Date: Tue Jan 8 11:36:23 2019 +0500 corrected vopretExtra getting for heir for coins commit 36061d25fb8992551915afc3dd0600878a64c540 Author: dimxy Date: Tue Jan 8 11:13:30 2019 +0500 corrected CCinit C-param separate commit 0a6710433868c315afe3f656c1bc5f5138fe5288 Author: dimxy Date: Tue Jan 8 10:58:19 2019 +0500 logging added in decodeheiropret commit 2503d8cb59b94b024a9ded43a0602f89800a9549 Author: dimxy Date: Tue Jan 8 10:39:21 2019 +0500 corrected decode opret for heir for coins --- src/cc/CCtokens.cpp | 19 +- src/cc/CCtx.cpp | 1 - src/cc/heir.cpp | 534 ++++++++++++++--------------------------- src/cc/heir_validate.h | 84 +++---- 4 files changed, 237 insertions(+), 401 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 8e5d98f47..4a2c6031e 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -92,7 +92,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 script = (uint8_t *)vopret.data(); tokenid = zeroid; - if (script != 0 /*enable all evals: && script[0] == EVAL_TOKENS*/) + if (script != 0 && vopret.size() > 2) { // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! bool isEof = true; @@ -114,7 +114,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 { if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType - std::cerr << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << std::endl; + std::cerr << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl; return (uint8_t)0; } @@ -128,7 +128,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 tokenid = revuint256(tokenid); return(funcId); } - std::cerr << "DecodeTokenOpRet() warning: bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl; + std::cerr << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl; return (uint8_t)0; default: @@ -136,6 +136,9 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 return (uint8_t)0; } } + else { + std::cerr << "DecodeTokenOpRet() empty opret, could not parse" << std::endl; + } return (uint8_t)0; } @@ -247,7 +250,7 @@ bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, tokenidOpret, voutPubkeys, vopretExtra)) == 0) { - std::cerr << indentStr << "ValidateTokenOpret() DecodeOpret returned null for n-1=" << n - 1 << " txid=" << tx.GetHash().GetHex() << std::endl; + std::cerr << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl; return(false); } else if (funcid == 'c') @@ -330,7 +333,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c testVout = MakeCC1of2vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { - std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } @@ -340,7 +343,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c CTxOut testVout = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { - std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } @@ -382,7 +385,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t if (cc_typeId(cond) == CC_Secp256k1) { *(CPubKey*)_.context = buf2pk(cond->publicKey); - std::cerr << "findEval found pubkey=" << HexStr(*(CPubKey*)_.context) << std::endl; + //std::cerr << "findEval found pubkey=" << HexStr(*(CPubKey*)_.context) << std::endl; r = true; } // false for a match, true for continue @@ -483,7 +486,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey); if (strcmp(destaddr, coinaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) continue; - fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); + //fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); std::vector vinPubkeysEmpty; if ((nValue = IsTokensvout(true, false/*<-- do not check spending outside EVAL_TOKENS for now */, cp, NULL, vopretExtra, vintx, vout, tokenid, vinPubkeysEmpty)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 971ba160d..79473b87a 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -135,7 +135,6 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = myprivkey; cond = mycond; - } else if ( strcmp(destaddr,unspendable) == 0 ) { diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 7512b54ed..d75580cec 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -23,145 +23,20 @@ class TokenHelper; /* The idea of Heir CC is to allow crypto inheritance. - A special 1of2 CC address is created that is freely spendable by the creator. The heir is only allowed to spend after the specified amount of idle blocks. The idea is that if the address doesnt spend any funds for a year (or whatever amount set), then it is time to allow the heir to spend. The design requires the heir to spend all the funds at once + A special 1of2 CC address is created that is freely spendable by the creator (funds owner). + The owner may add additional funds to this 1of2 address. + The heir is only allowed to spend after "the specified amount of idle blocks" (changed to "the owner inactivityTime"). + The idea is that if the address doesnt spend any funds for a year (or whatever amount set), then it is time to allow the heir to spend. + "The design requires the heir to spend all the funds at once" (this requirement was changed to "after the inactivity time both the heir and owner may freely spend available funds") + After the first heir spending a flag is set that spending is allowed for the heir whether the owner adds more funds or spends them. + This Heir contract supports both coins and tokens. */ // tx validation code -// this is for indentation of debug log messages (in recursive calls): -//extern thread_local uint32_t assetValIndentSize; - -// check if vout is cc addr and also check sum(inputs) == sum(outputs) for the passed tx, if requested -int64_t IsHeirvout(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 tokenid, const CTransaction& tx, int32_t v) -{ - //std::string indentStr = std::string().append(assetValIndentSize, '.'); - - //std::cerr << indentStr << "IsHeirvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << std::boolalpha << " compareTotals=" << compareTotals << std::endl; - if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) - { - //std::cerr << indentStr << "IsHeirvout() IsPayToCryptoCondition=true for txid=" << tx.GetHash().GetHex() << std::endl; - /*if (compareTotals) { // totally there are only 2 levels actually - - // call recursively HeirExactTokenAmounts and compare ccinputs = ccoutputs for this tx: - assetValIndentSize++; - const bool isEqual = HeirExactTokenAmounts(false, cpHeir, eval, tokenid, tx); - assetValIndentSize--; - - if (!isEqual) { // ccInputs != ccOutputs means a problem - //std::cerr << indentStr << "IsHeirvout() warning: detected suspicious tx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs, checking further if it is the tokenbase tx" << std::endl; - // if ccInputs != ccOutputs and it is not the 'tokenbase' tx means it is possibly fake tx (dimxy): - if (tokenid != zeroid && tokenid != tx.GetHash()) { - std::cerr << indentStr << "IsHeirvout() warning: detected bad tx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping this tx" << std::endl; - return 0; - } - } - }*/ - - // TODO: add some validation here - - // lets check asset opreturn for this heir or assets tx (dimxy): - /* - int64_t dummyPrice; std::vector dummyOrigpubkey; - - const bool valOpret = ValidateAssetOpret(tx, v, tokenid, dummyPrice, dummyOrigpubkey); - //std::cerr << indentStr << "IsHeirvout() ValidateAssetOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << std::endl; - if (valOpret) { - std::cerr << indentStr << "IsHeirvout() opret is true, return value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << std::endl; - return(tx.vout[v].nValue); - }*/ - - return(tx.vout[v].nValue); - } - //std::cerr << indentStr << "IsHeirvout() return value=0" << std::endl; - return(0); -} - -// this function validates that tx cc outputs == cc inputs, -// that is there is no fake token supply from normal inputs (except the initial tokenbase tx) -// the cc inputs are allowed only from the Assets or Heir contracts -/*bool HeirExactTokenAmounts(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 tokenid, const CTransaction &tx) -{ - static uint256 zerohash; - CTransaction vinTx; - uint256 hashBlock, activehash; - int64_t inputs = 0, outputs = 0, assetoshis; - - struct CCcontract_info *cpAssets, cAssets; - cpAssets = CCinit(&cAssets, EVAL_ASSETS); // init also tokens CC contract to check its cc addresses too - - std::string indentStr = std::string().append(assetValIndentSize, '.'); - - int32_t numvins = tx.vin.size(); - int32_t numvouts = tx.vout.size(); - for (int32_t i = 0; i < numvins; i++) - { - //std::cerr << indentStr << "HeirExactTokenAmounts() vin i=" << i << " cpHeir->ismyvin()=" << std::boolalpha << (*cpHeir->ismyvin)(tx.vin[i].scriptSig) << " cpAssets->ismyvin()=" << (*cpAssets->ismyvin)(tx.vin[i].scriptSig) << std::endl; - - // checking that vin is either from heir or assets: - if ((*cpHeir->ismyvin)(tx.vin[i].scriptSig) || (*cpAssets->ismyvin)(tx.vin[i].scriptSig)) - { - //std::cerr << indentStr; fprintf(stderr,"vini.%d check mempool\n",i); - if ((eval && !eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock)) || !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock)) { - std::cerr << indentStr << "HeirExactTokenAmounts(): can't get vintx transaction txid=" << tx.vin[i].prevout.hash.GetHex() << std::endl; - return (eval) ? eval->Invalid("cant find vinTx") : false; - } - else - { - //std::cerr << indentStr; fprintf(stderr,"vini.%d check hash and vout\n",i); - if (hashBlock == zerohash) { - std::cerr << indentStr << "HeirExactTokenAmounts(): can't get vintx from mempool, txid=" << tx.vin[i].prevout.hash.GetHex() << std::endl; - return (eval) ? eval->Invalid("cant Heir from mempool") : false; - } - - std::string dummyRefcoin; uint256 dummyBindtxid, dummyDeposittxid; CPubKey dummyDestpub; int64_t dummyAmount; - uint256 dummyAssetid2; - std::vector dummyOrigpubkey; - - // Note: if tokenid is zeroid, it may mean we are on the first level and just called from HeirValidate, validating claim 't' tx, - // then let's find the tokenid ourselves: - if (tokenid == zeroid && DecodeAssetOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, dummyAssetid2, dummyAmount, dummyOrigpubkey) == 't') { - //std::cerr << indentStr << "HeirExactTokenAmounts() will check if this vinx is the tokenbase tokenid=" << tokenid.GetHex() << std::endl; - } - - // checking that the vout of the vintx (that is, referenced by this vin), in its turn, is fed by either from heir' or assets' cryptocondition address: - //std::cerr << indentStr << "HeirExactTokenAmounts() calling IsHeirvout for vintx i=" << i << " prevout.n=" << tx.vin[i].prevout.n << std::endl; - - assetValIndentSize++; - assetoshis = IsHeirvout(compareTotals, cpHeir, eval, tokenid, vinTx, tx.vin[i].prevout.n); - assetValIndentSize--; - if (assetoshis > 0) - inputs += assetoshis; - } - } - } - for (int32_t i = 0; iInvalid("mismatched inputs != outputs + txfee") : false; - } - else { - //std::cerr << indentStr << "HeirExactTokenAmounts() inputs=" << inputs << " vs outputs=" << outputs << " return true" << std::endl; - return(true); - } -}*/ - - -// claim coins tokens validation runner -// sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation() -template bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, bool isHeirSpendingBegan) +// Plan validation runner, it may be called twice - for coins and tokens +// (sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation()...) +template bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t isHeirSpendingBegan) { int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); @@ -176,26 +51,20 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont CCCInputIdentifier ccInputIdentifier(cp); // vin and vout 'validators' - // always check coin inputs: - CMyPubkeyVoutValidator normalInputValidator(cp, fundingOpretScript, true); // check normal input for this opret cause this is first tx - //CMyPubkeyVoutValidator normalInputValidatorLast(cp, latestTxOpRetScript, true); // check normal input for latest opret. TODO: we may also check this opret - - CCC1of2AddressValidator cc1of2ValidatorThis(cp, fundingOpretScript, "checking this tx opreturn:"); // 1of2add validator with pubkeys from this tx opreturn - //CCC1of2AddressValidator cc1of2ValidatorLast(cp, latestTxOpRetScript, "checking last tx opreturn:"); // 1of2add validator with pubkeys from last tx opreturn + // not used, too strict for 2 pubkeys: CMyPubkeyVoutValidator normalInputValidator(cp, fundingOpretScript, true); // check normal input for this opret cause this is first tx + CCC1of2AddressValidator cc1of2ValidatorThis(cp, fundingOpretScript, "checking this tx opreturn:"); // 1of2add validator with pubkeys from this tx opreturn CHeirSpendValidator heirSpendValidator(cp, fundingOpretScript, latestTxid, isHeirSpendingBegan); // check if heir allowed to spend // only for tokens: - CMyPubkeyVoutValidator ownerCCaddrValidator(cp, fundingOpretScript, false); // check if this correct owner's cc user addr corresponding to opret - //CMyPubkeyVoutValidator ownerCCaddrValidatorLast(cp, latestTxOpRetScript, false); // check if this correct owner's cc user addr corresponding to lastest opret - // TODO: we may also check with current opret - COpRetValidator opRetValidator(cp, fundingOpretScript); // compare opRets in this and last tx + CMyPubkeyVoutValidator ownerCCaddrValidator(cp, fundingOpretScript, false); // check if this correct owner's cc user addr corresponding to opret + COpRetValidator opRetValidator(cp, fundingOpretScript); // compare opRets in this and last tx + CNullValidator nullValidator(cp); switch (funcId) { case 'F': // fund tokens // vin validation plan: - // we need cast here this is casted inside - vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &normalInputValidator); // txfee - see AddNormalInput parameter - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr // vout validation plan: voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding @@ -205,22 +74,20 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont case 'A': // add tokens // vin validation plan: - // we need cast here this is casted inside - vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &normalInputValidator/*, &normalInputValidatorLast*/); // txfee - see AddNormalInput parameter - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr - // vout validation plan: + // vout validation plan: voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding - // do not check change at this time - voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A: + // do not check change at this time + voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A: break; case 'C': // vin validation plan: - // we need cast here this is casted inside - vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &normalInputValidator/*&normalInputValidatorLast*/); // txfee - see AddNormalInput parameter - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &cc1of2ValidatorThis /*, &cc1of2ValidatorLast*/); // cc1of2 funding addr - + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &cc1of2ValidatorThis); // cc1of2 funding addr + // vout validation plan: voutPlan.pushValidators(0, &heirSpendValidator); // check if heir is allowed to spend voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A @@ -239,33 +106,34 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont /** * Tx validation entry function */ -bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint32_t nIn) +bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction& tx, uint32_t nIn) { int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); //int32_t preventCCvins = -1; //int32_t preventCCvouts = -1; + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + if (numvouts < 1) return eval->Invalid("no vouts"); - if (chainActive.Height() < 741) - return true; + //if (chainActive.Height() < 741) + // return true; uint8_t funcId; - uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, tokenid = zeroid; + uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenid = zeroid; - //CScript opRetScript = tx.vout[numvouts - 1].scriptPubKey; - CScript fundingTxOpRetScript; - bool isHeirSpendingBegan = false; + uint8_t isHeirSpendingBegan = 0, dummyIsHeirSpendingBegan; int32_t heirType = NOT_HEIR; - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, true); + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); if(funcId != 0) heirType = HEIR_COINS; else { - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, false); + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, false); if (funcId != 0) heirType = HEIR_TOKENS; } @@ -278,7 +146,7 @@ bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx return eval->Invalid("invalid tx opreturn format: no fundingtxid present"); } if (heirType == HEIR_COINS) - latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, isHeirSpendingBegan); + latestTxid = FindLatestFundingTx(fundingTxidInOpret, dummyTokenid, fundingTxOpRetScript, isHeirSpendingBegan); else latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, isHeirSpendingBegan); @@ -290,11 +158,7 @@ bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx fundingTxOpRetScript = tx.vout[numvouts - 1].scriptPubKey; } - // validate prev tx cc inputs = outputs: - /* if (heirType == HEIR_TOKENS && funcId == 't' && !HeirExactTokenAmounts(true, cp, eval, zeroid, tx)) { - std::cerr << "HeirValidate() this tx or some of its vin tx has invalid cc amounts" << std::endl; - return eval->Invalid("this tx or some of its vin tx has invalid cc amounts"); - } */ + std::cerr << "HeirValidate funcid=" << (char)funcId << std::endl; switch (funcId) { case 'F': @@ -315,7 +179,7 @@ bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx // vout.2: normal change // vout.n-1: opreturn 't' tokenid 'F' ownerpk heirpk inactivitytime heirname tokenid if (heirType == HEIR_TOKENS) - return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); else return eval->Invalid("unexpected HeirValidate for heirfund"); // break; @@ -336,7 +200,7 @@ bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx // vout.1: normal change // vout.n-1: opreturn 't' tokenid 'A' ownerpk heirpk inactivitytime fundingtx if (heirType == HEIR_TOKENS) - return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); else return eval->Invalid("unexpected HeirValidate for heiradd"); //break; @@ -360,9 +224,9 @@ bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx // vout.2: change to normal from txfee input if any // vout.n-1: opreturn 't' tokenid 'C' ownerpk heirpk inactivitytime fundingtx if (heirType == HEIR_TOKENS) - return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); else - return RunValidationPlans(funcId, cp, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpHeir, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); // break; default: @@ -383,13 +247,15 @@ bool HeirValidate(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx */ int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) { - char destaddr[65], heirContractAddr[65]; + char destaddr[65], heirFundingAddr[65]; - GetCCaddress1of2(cp, heirContractAddr, ownerPubkey, heirPubkey); + GetCCaddress1of2(cp, heirFundingAddr, ownerPubkey, heirPubkey); if (tx.vout[voutIndex].scriptPubKey.IsPayToCryptoCondition() != 0) { // NOTE: dimxy it was unsafe 'Getscriptaddress(destaddr,tx.vout[voutIndex].scriptPubKey) > 0' here: - if (Getscriptaddress(destaddr, tx.vout[voutIndex].scriptPubKey) && strcmp(destaddr, heirContractAddr) == 0) + if (Getscriptaddress(destaddr, tx.vout[voutIndex].scriptPubKey) && strcmp(destaddr, heirFundingAddr) == 0) return (tx.vout[voutIndex].nValue); + else + std::cerr << "IsHeirFundingVout() heirFundingAddr=" << heirFundingAddr << " not equal to destaddr=" << destaddr << std::endl; } return (0); } @@ -437,30 +303,19 @@ CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirP { uint8_t evalcode = EVAL_HEIR; - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); + return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); } // makes coin additional tx opret -CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid) +CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { uint8_t evalcode = EVAL_HEIR; fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)funcid << fundingtxid); + return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << isHeirSpendingBegan); } // makes opret for tokens while they are inside Heir contract address space - initial funding -CScript EncodeHeirTokensCreateOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) -{ - uint8_t evalcode = EVAL_TOKENS; - uint8_t ccType = 0; - if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) - ccType = voutPubkeys.size(); - - tokenid = revuint256(tokenid); - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)'t' << tokenid << (uint8_t)funcid << ccType; if (ccType >= 1) ss << voutPubkeys[0]; if (ccType == 2) ss << voutPubkeys[1]; ss << ownerPubkey << heirPubkey << inactivityTimeSec << hearName); -} -// makes opret for tokens while they are inside Heir contract address space - additional funding -CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid) +CScript EncodeHeirTokensCreateOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) { uint8_t evalcode = EVAL_HEIR; uint8_t ccType = 0; @@ -468,16 +323,43 @@ CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector= 1) ss << voutPubkeys[0]; \ + if (ccType == 2) ss << voutPubkeys[1]; \ + ss << heirFuncId << ownerPubkey << heirPubkey << inactivityTimeSec << hearName); +} +// makes opret for tokens while they are inside Heir contract address space - additional funding +CScript EncodeHeirTokensOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) +{ + uint8_t evalcode = EVAL_HEIR; + uint8_t ccType = 0; + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) + ccType = voutPubkeys.size(); + + tokenid = revuint256(tokenid); // for visualization in debug logs fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalcode << (uint8_t)'t' << tokenid << ccType; if (ccType >= 1) ss << voutPubkeys[0]; if (ccType == 2) ss << voutPubkeys[1]; ss << (uint8_t)funcid << fundingtxid); + return CScript() << OP_RETURN << + E_MARSHAL(ss << evalcode << (uint8_t)'t' << tokenid << ccType; \ + if (ccType >= 1) ss << voutPubkeys[0]; \ + if (ccType == 2) ss << voutPubkeys[1]; \ + ss << heirFuncId << fundingtxid << isHeirSpendingBegan); } // helper for decode heir opret payload // NOTE: Heir for coins has the same opret as Heir for tokens -uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret) { +uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &isHeirSpendingBegan) { uint8_t heirFuncId = 0; + isHeirSpendingBegan = 0; + + bool result = E_UNMARSHAL(vopretExtra, { ss >> heirFuncId; \ + if( heirFuncId == 'F') { \ + ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; \ + } else { \ + ss >> fundingTxidInOpret >> isHeirSpendingBegan; \ + } \ + }); - bool result = E_UNMARSHAL(vopretExtra, { ss >> heirFuncId; ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; if (IS_CHARINSTR(heirFuncId, "F")) { ss >> heirName; } if (IS_CHARINSTR(heirFuncId, "AC")) { ss >> fundingTxidInOpret; } }); if (!result /*|| assetFuncId != 't' -- any tx is ok*/) return (uint8_t)0; @@ -486,11 +368,11 @@ uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, /** * decode opret vout for Heir contract */ -template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, bool noLogging) +template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &isHeirSpendingBegan, bool noLogging) { - uint8_t evalCodeInOpret = 0; std::vector vopretExtra; + uint8_t evalCodeInOpret = 0; uint256 dummyTokenid; std::vector voutPubkeysDummy; @@ -498,36 +380,50 @@ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 & tokenid = zeroid; - // First - decode token opret: - uint8_t funcId = DecodeTokenOpRet(scriptPubKey, evalCodeInOpret, tokenid, voutPubkeysDummy, vopretExtra); + if (typeid(Helper) == typeid(TokenHelper)) { // if caller thinks it is a token - //GetOpReturnData(scriptPubKey, vopret); - - if (funcId != 0 && vopretExtra.size() > 1) { // TODO: add this funcId cond in Assets too - // NOTE: it unmarshals for all F, A and C - uint8_t heirFuncId = _UnmarshalOpret(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret); - - /* - std::cerr << "DecodeHeirOpRet() e=" << (int)e - << " funcId=" << (char)funcId - << " ownerPubkey=" << HexStr(ownerPubkey) - << " heirPubkey=" << HexStr(heirPubkey) - << " heirName=" << heirName << " inactivityTime=" << inactivityTime << '\n'; - */ - - //if (e == EVAL_HEIR && IS_CHARINSTR(funcId, "FAC")) - if (evalCodeInOpret == EVAL_HEIR && Helper::isMyFuncId(heirFuncId)) { - tokenid = revuint256(tokenid); - fundingTxidInOpret = revuint256(fundingTxidInOpret); - return heirFuncId; - } - else - { - if(!noLogging) std::cerr << "DecodeHeirOpRet() warning unexpected OP_RETURN eval=" << (int)evalCodeInOpret << " or field type=" << (char)(heirFuncId ? heirFuncId : ' ') << '\n'; + // First - decode token opret: + uint8_t tokenFuncId = DecodeTokenOpRet(scriptPubKey, evalCodeInOpret, tokenid, voutPubkeysDummy, vopretExtra); + if (tokenFuncId == 0) { + if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: not heir token opret, tokenFuncId=" << (int)tokenFuncId << std::endl; + return (uint8_t)0; } } else { - std::cerr << "DecodeHeirOpRet() unmarshal error (vopret.size() == 0)" << '\n'; + std::vector vopret; + + GetOpReturnData(scriptPubKey, vopret); + if (vopret.size() == 0) { + if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; + return (uint8_t)0; + } + evalCodeInOpret = vopret.begin()[0]; + vopretExtra = std::vector( vopret.begin()+1, vopret.end() ); // vopretExtra = vopret + 1, get it for futher parsing + } + + if (vopretExtra.size() > 1 && evalCodeInOpret == EVAL_HEIR) { + // NOTE: it unmarshals for all F, A and C + uint8_t heirFuncId = _UnmarshalOpret(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, isHeirSpendingBegan); + + /*std::cerr << "DecodeHeirOpRet()" + << " heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') + << " ownerPubkey=" << HexStr(ownerPubkey) + << " heirPubkey=" << HexStr(heirPubkey) + << " heirName=" << heirName << " inactivityTime=" << inactivityTime + << " isHeirSpendingBegan=" << (int)isHeirSpendingBegan << std::endl;*/ + + + //if (e == EVAL_HEIR && IS_CHARINSTR(funcId, "FAC")) + if (Helper::isMyFuncId(heirFuncId)) { + fundingTxidInOpret = revuint256(fundingTxidInOpret); + return heirFuncId; + } + else { + if(!noLogging) std::cerr << "DecodeHeirOpRet() error: unexpected opret, heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') << std::endl; + } + } + else { + if (!noLogging) std::cerr << "DecodeHeirOpRet() error: not a heir opret, vopretExtra.size() == 0 or not EVAL_HEIR evalcode=" << (int)evalCodeInOpret << std::endl; } return (uint8_t)0; } @@ -538,20 +434,21 @@ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 & template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { uint256 dummytxid; + uint8_t dummyIsHeirSpendingBegan; - return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, noLogging); + return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyIsHeirSpendingBegan, noLogging); } /** * overload for A, C oprets and AddHeirContractInputs */ -template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxidInOpret, bool noLogging) +template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxidInOpret, uint8_t &isHeirSpendingBegan, bool noLogging) { CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; std::string dummyHeirName; - return _DecodeHeirOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, noLogging); + return _DecodeHeirOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, isHeirSpendingBegan, noLogging); } @@ -560,7 +457,7 @@ template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &t * find the latest funding tx: it may be the first F tx or one of A or C tx's * Note: this function is also called from validation code (use non-locking calls) */ -template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, bool &isHeirSpendingBegan) +template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, uint8_t &isHeirSpendingBegan) { CTransaction fundingtx; uint256 hashBlock; @@ -570,8 +467,8 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ //CCtxidaddr(markeraddr, fundingtxid); //SetCCunspents(unspentOutputs, markeraddr); - isHeirSpendingBegan = false; //init the var - funcId = 0; //init the var + isHeirSpendingBegan = 0; + funcId = 0; // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { @@ -580,7 +477,7 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ // set ownerPubkey and heirPubkey: if ((funcId = DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName)) != 0) { // found at least funding tx! - std::cerr << "FindLatestFundingTx() lasttx currently is fundingtx, txid=" << fundingtxid.GetHex() << " opreturn type=" << (char)funcId << '\n'; + //std::cerr << "FindLatestFundingTx() lasttx currently is fundingtx, txid=" << fundingtxid.GetHex() << " opreturn type=" << (char)funcId << '\n'; fundingOpretScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; } else { std::cerr << "FindLatestFundingTx() could not decode opreturn for fundingtxid=" << fundingtxid.GetHex() << '\n'; @@ -616,37 +513,33 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ //NOTE: maybe called from validation code: if (myGetTransaction(txid, regtx, hash)) { - std::cerr << "FindLatestFundingTx() found tx for txid=" << txid.GetHex() << " blockHeight=" << blockHeight << " maxBlockHeight=" << maxBlockHeight << '\n'; + //std::cerr << "FindLatestFundingTx() found tx for txid=" << txid.GetHex() << " blockHeight=" << blockHeight << " maxBlockHeight=" << maxBlockHeight << '\n'; - { // debug code: + /*{ // debug code: uint256 debAssetid; - uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, true); - std::cerr << "FindLatestFundingTx() regtx.vout.size()=" << regtx.vout.size() << " funcId=" << (char)(debfuncid ? debfuncid : ' ') << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << std::endl; - } + uint8_t debIsHeirSpendingBegan; + uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, debIsHeirSpendingBegan, true); + + std::cerr << "FindLatestFundingTx() regtx.vout.size()=" << regtx.vout.size() << " funcId=" << (char)(debfuncid ? debfuncid : ' ') + << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << " debIsHeirSpendingBegan=" << (int)debIsHeirSpendingBegan << std::endl; + }*/ uint256 dummyTokenid; // not to contaminate the tokenid from the params! uint8_t tmpFuncId; + uint8_t tmpIsHeirSpendingBegan; if (regtx.vout.size() > 0 && - (tmpFuncId = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, true)) != 0 && + (tmpFuncId = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, tmpIsHeirSpendingBegan, true)) != 0 && fundingtxid == fundingTxidInOpret) { - // check if heir has begun spending: - if (Helper::isSpendingTx(tmpFuncId)) { // if 'C' or 't' opret - const CScript heirScriptPubkey = CScript() << ParseHex(HexStr(heirPubkey)) << OP_CHECKSIG; - - for (int32_t v = 0; v < regtx.vout.size() - 1; v++) { // do not check opret vout - if (heirScriptPubkey == regtx.vout[v].scriptPubKey) - isHeirSpendingBegan = true; - } - } - if (blockHeight > maxBlockHeight) { maxBlockHeight = blockHeight; latesttxid = txid; - ///// fundingOpretScript = regtx.vout[regtx.vout.size() - 1].scriptPubKey; funcId = tmpFuncId; - std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight << " opreturn type=" << (char)(funcId ? funcId : ' ') << " set as current lasttxid" << '\n'; + isHeirSpendingBegan = tmpIsHeirSpendingBegan; + + //std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight + // << " opreturn type=" << (char)(funcId ? funcId : ' ') << " isHeirSpendingBegan=" << (int)isHeirSpendingBegan << " - set as current lasttxid" << '\n'; } } } @@ -656,7 +549,7 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ } // overload for validation code -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, bool &isHeirSpendingBegan) +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan) { uint8_t funcId; CPubKey ownerPubkey; @@ -668,81 +561,19 @@ template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 } // overload for transaction creation code -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool &isHeirSpendingBegan) +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint8_t &isHeirSpendingBegan) { CScript opRetScript; return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, isHeirSpendingBegan); } -// add owner input in tokens -/*int64_t AddHeirTokenInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 refassetid, int64_t total, int32_t maxinputs) -{ - char coinaddr[64], destaddr[64]; int64_t threshold, nValue, price, totalinputs = 0; uint256 tokenid, txid, hashBlock; std::vector origpubkey; std::vector vopret; CTransaction vintx; int32_t j, vout, n = 0; uint8_t evalcode, funcid; - std::vector > unspentOutputs; - GetCCaddress(cp, coinaddr, pk); - SetCCunspents(unspentOutputs, coinaddr); - threshold = total / (maxinputs + 1); - - //fprintf(stderr,"AddHeirTokenInputs() check cc addr=%s for token inputs\n",coinaddr); - for (std::vector >::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - - if (it->second.satoshis < threshold) - continue; - for (j = 0; jsecond=" << it->second.satoshis << std::endl; - - if (strcmp(destaddr, coinaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) - continue; - GetOpReturnData(vintx.vout[vintx.vout.size() - 1].scriptPubKey, vopret); - - // NOTE: special opret decode: - // we should not check for E_UNMARSHAL return code because it returns false if not EOF, - // but we have our remainder after tokenid! - bool isEof = false; - bool unmarshalResult = E_UNMARSHAL(vopret, ss >> evalcode; ss >> funcid; ss >> tokenid; isEof=ss.eof()); - if (unmarshalResult || !isEof) - { - tokenid = revuint256(tokenid); // usually DecodeOpretXXX() funcs do this - - //std::cerr << "AddHeirTokenInputs() vout=" << vout << " evalcode=" << (int)evalcode << " cp->evalcode=" << (int)cp->evalcode << " funcid=" << (char)funcid << " check for refassetid=" << refassetid.GetHex() << " vs tokenid in opret=" << tokenid.GetHex() << " coins=" << (double)vintx.vout[vout].nValue / COIN << std::endl; - if (tokenid == refassetid && - IS_CHARINSTR(funcid, "tGB") && - (nValue = vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) - { - std::cerr << "AddHeirTokenInputs() total=" << total << " maxinputs=" << maxinputs << " uxto value=" << it->second.satoshis << std::endl; - if (total != 0 && maxinputs != 0) - mtx.vin.push_back(CTxIn(txid, vout, CScript())); - //nValue = it->second.satoshis; - totalinputs += nValue; - n++; - if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) - break; - } - } - } - } - return(totalinputs); -}*/ - // add inputs of 1 of 2 cc address template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs) { // TODO: add threshold check int64_t nValue, voutValue, totalinputs = 0; - CTransaction vintx; + CTransaction heirtx; int32_t n = 0; std::vector> unspentOutputs; @@ -753,7 +584,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, // char markeraddr[64]; // CCtxidaddr(markeraddr, fundingtxid); // SetCCunspents(unspentOutputs, markeraddr); - //std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + // std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << std::endl; for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { uint256 txid = it->first.txhash; @@ -761,21 +592,20 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, int32_t voutIndex = (int32_t)it->first.index; // no need to prevent dup // dimxy: maybe it is good to put tx's in cache? - if (GetTransaction(txid, vintx, hashBlock, false) != 0) { + if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { uint256 tokenid; uint256 fundingTxidInOpret; - - uint8_t funcId = DecodeHeirOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, true); - // note: it returns in in satoshis too... - if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && // we're spending only tx's in this funding plan - funcId != 0 && + uint8_t dummyIsHeirSpendingBegan; + + uint8_t funcId = DecodeHeirOpRet(heirtx.vout[heirtx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && + funcId != 0 && Helper::isMyFuncId(funcId) && - // deep validation for tokens: - (typeid(Helper) == typeid(TokenHelper) && IsHeirvout(true, cp, nullptr, tokenid, vintx, voutIndex) > 0) && - (voutValue = IsHeirFundingVout(cp, vintx, voutIndex, ownerPubkey, heirPubkey)) > 0 && + // (typeid(Helper) == typeid(TokenHelper) && IsHeirvout(true, cp, nullptr, tokenid, vintx, voutIndex) > 0) && // deep validation for tokens - not used anymore + (voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && !myIsutxo_spentinmempool(txid, voutIndex)) { - std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; + //std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, voutIndex, CScript())); nValue = it->second.satoshis; @@ -812,8 +642,9 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info uint256 tokenid; uint256 fundingTxidInOpret; const int32_t ivout = 0; + uint8_t dummyIsHeirSpendingBegan; - funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, true); + funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); //std::cerr << "LifetimeHeirContractFunds() found tx=" << txid.GetHex() << " vout[0].nValue=" << subtx.vout[ccVoutIdx].nValue << " opreturn=" << (char)funcId << '\n'; @@ -821,7 +652,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info /* && !myIsutxo_spentinmempool(txid, ccVoutIdx) */) // include also tx in mempool { total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) - std::cerr << "LifetimeHeirContractFunds() added tx=" << txid.GetHex() << " it->second=" << it->second << " vout[0].nValue=" << tx.vout[ivout].nValue << " opreturn=" << (char)funcId << '\n'; + //std::cerr << "LifetimeHeirContractFunds() added tx=" << txid.GetHex() << " it->second=" << it->second << " vout[0].nValue=" << tx.vout[ivout].nValue << " opreturn=" << (char)funcId << '\n'; } } } @@ -920,9 +751,10 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in uint256 lasttxid, tokenid; std::string heirName; uint8_t funcId; - bool isHeirSpendingBegan = false; + uint8_t isHeirSpendingBegan = 0; cp = CCinit(&C, Helper::getMyEval()); + if (txfee == 0) txfee = 10000; @@ -942,7 +774,6 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in int64_t inputs, change; - //if (AddNormalinputs(mtx, myPubkey, amount + 1 * txfee, 64) > 0) { // TODO: why 64 max inputs? if ((inputs = Helper::addOwnerInputs(cp, tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? // we do not use markers anymore - storing data in opreturn is better @@ -955,7 +786,6 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in // add cryptocondition to spend this funded amount for either pk mtx.vout.push_back(MakeCC1of2vout(Helper::getMyEval(), amount, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! - // calc and add change vout: if (inputs > amount) change = (inputs - amount); // -txfee <-- txfee pays user @@ -972,7 +802,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in // add opreturn 'A' and sign tx: // this txfee ignored std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid))); + Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, isHeirSpendingBegan))); result.push_back(Pair("result", "success")); result.push_back(Pair("hextx", rawhextx)); @@ -1025,7 +855,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee uint256 latesttxid, tokenid; uint8_t funcId; std::string heirName; - bool isHeirSpendingBegan = false; + uint8_t isHeirSpendingBegan = 0; cp = CCinit(&C, Helper::getMyEval()); @@ -1117,7 +947,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee // add opreturn 'C' and sign tx: // this txfee will be ignored std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid)); + Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : isHeirSpendingBegan)); // forward isHeirSpending to the next latest tx result.push_back(Pair("result", "success")); result.push_back(Pair("hextx", rawhextx)); @@ -1181,9 +1011,11 @@ UniValue HeirInfo(uint256 fundingtxid) if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { int32_t heirType = NOT_HEIR; - if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true) == 'F') + const bool noLogging = true; + + if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging) == 'F') heirType = HEIR_COINS; - else if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true) == 'F') + else if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging) == 'F') heirType = HEIR_TOKENS; else { @@ -1199,7 +1031,7 @@ UniValue HeirInfo(uint256 fundingtxid) else cp = CCinit(&C, TokenHelper::getMyEval()); - bool isHeirSpendingBegan = false; + uint8_t isHeirSpendingBegan = 0; if (heirType == HEIR_COINS) latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan); @@ -1210,7 +1042,7 @@ UniValue HeirInfo(uint256 fundingtxid) int32_t numblocks; uint64_t durationSec = 0; - std::cerr << "HeirInfo() latesttxid=" << latestFundingTxid.GetHex() << '\n'; + //std::cerr << "HeirInfo() latesttxid=" << latestFundingTxid.GetHex() << '\n'; std::ostringstream stream; std::string msg; @@ -1324,7 +1156,7 @@ template void _HeirList(struct CCcontract_info *cp, UniValue &r GetCCaddress(cp, coinaddr, ccPubKeyEmpty); SetCCunspents(unspentOutputs, cp->normaladdr); - std::cerr << "HeirList() finding heir marker from Heir contract addr=" << cp->normaladdr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + //std::cerr << "HeirList() finding heir marker from Heir contract addr=" << cp->normaladdr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; // TODO: move marker to special cc addr to prevent checking all tokens for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { @@ -1333,26 +1165,28 @@ template void _HeirList(struct CCcontract_info *cp, UniValue &r uint256 tokenid; int32_t vout = (int32_t)it->first.index; - std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; + //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; - CTransaction vintx; - if (GetTransaction(txid, vintx, hashBlock, false) != 0 && (vintx.vout.size() - 1) > 0) { + CTransaction inittx; + if (GetTransaction(txid, inittx, hashBlock, false) != 0 && (inittx.vout.size() - 1) > 0) { CPubKey ownerPubkey, heirPubkey; std::string heirName; int64_t inactivityTimeSec; + const bool noLogging = true; - uint8_t funcId = DecodeHeirOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + uint8_t funcId = DecodeHeirOpRet(inittx.vout[inittx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); // note: if it is not Heir token funcId would be equal to 0 if (funcId == 'F') { - result.push_back(Pair("fundingtxid heirName", txid.GetHex() + std::string(" ") + (typeid(Helper) == typeid(TokenHelper) ? std::string("token") : std::string("coin")) + std::string(" ") + heirName)); + //result.push_back(Pair("fundingtxid kind name", txid.GetHex() + std::string(" ") + (typeid(Helper) == typeid(TokenHelper) ? std::string("token") : std::string("coin")) + std::string(" ") + heirName)); + result.push_back( Pair("fundingtxid", txid.GetHex()) ); } else { - fprintf(stderr, "HeirList() couldnt find initial transaction\n"); + std::cerr << "HeirList() this is not the initial F transaction=" << txid.GetHex() << std::endl; } } else { - fprintf(stderr, "HeirList() couldnt load transaction\n"); + std::cerr << "HeirList() could not load transaction=" << txid.GetHex() << std::endl; } } } @@ -1363,10 +1197,10 @@ UniValue HeirList() UniValue result(UniValue::VOBJ); result.push_back(Pair("result", "success")); - struct CCcontract_info *cpHeir, *cpTokens, C; + struct CCcontract_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! - cpHeir = CCinit(&C, EVAL_HEIR); - cpTokens = CCinit(&C, EVAL_TOKENS); + cpHeir = CCinit(&heirC, EVAL_HEIR); + cpTokens = CCinit(&tokenC, EVAL_TOKENS); _HeirList(cpHeir, result); _HeirList(cpTokens, result); diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 108562e24..5b5df2110 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -12,21 +12,15 @@ // makes coin initial tx opret CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); -// makes coin additional tx opret -CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid); - +CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan); +// makes token opret CScript EncodeHeirTokensCreateOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName); -CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid); -//CScript EncodeHeirConvertedAssetsOpRet(uint8_t eval, uint8_t funcid, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 fundingtxid); +CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan); -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, bool &isHeirSpendingBegan); -template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxid, bool noLogging = false); -//template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); +template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); -//int64_t AddHeirTokenInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 reftokenid, int64_t total, int32_t maxinputs); - - // helper class to allow polymorphic behaviour for HeirXXX() functions in case of coins class CoinHelper { public: @@ -40,11 +34,11 @@ public: static CScript makeCreateOpRet(uint256 dummyid, std::vector dummyPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { return EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName); } - static CScript makeAddOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid) { - return EncodeHeirOpRet((uint8_t)'A', fundingtxid); + static CScript makeAddOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan); } - static CScript makeClaimOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid) { - return EncodeHeirOpRet((uint8_t)'C', fundingtxid); + static CScript makeClaimOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan); } static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } @@ -69,11 +63,11 @@ public: static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { return EncodeHeirTokensCreateOpRet((uint8_t)'F', tokenid, voutTokenPubkeys, ownerPubkey, heirPubkey, inactivityTimeSec, heirName); } - static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid) { - return EncodeHeirTokensOpRet((uint8_t)'A', tokenid, voutTokenPubkeys, fundingtxid); + static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeHeirTokensOpRet((uint8_t)'A', tokenid, voutTokenPubkeys, fundingtxid, isHeirSpendingBegan); } - static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid) { - return EncodeHeirTokensOpRet((uint8_t)'C', tokenid, voutTokenPubkeys, fundingtxid); + static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeHeirTokensOpRet((uint8_t)'C', tokenid, voutTokenPubkeys, fundingtxid, isHeirSpendingBegan); } static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } @@ -86,9 +80,6 @@ public: } }; -//#define OPTIONAL_VOUT 0 // if vout is optional then in a validation plan it will be skipped without error, if all validators return false - - /** * Small framework for vins and vouts validation implementing a variation of 'chain of responsibility' pattern: @@ -104,10 +95,8 @@ public: * * For validating vouts COutputValidator is configured for each vector of validators with the vout index to which these validators are applied * (see constructors of both CInputValidator and COutputValidator) -* -* -* Base class for all validators */ + /** * base class for all validators */ @@ -123,7 +112,6 @@ protected: CCcontract_info * m_cp; }; - /** * Base class for classes which identify vins as normal or cc inputs */ @@ -137,9 +125,6 @@ protected: CCcontract_info * m_cp; }; - - - /** * Encapsulates an array containing rows of validators * Each row is a vector of validators (zero is possible) for validating vins or prev tx's vouts @@ -222,7 +207,7 @@ public: return eval->Invalid("incorrect tx structure: not all required vins are present."); } - std::cerr << "CInputValidationPlan::validate() returns with true" << std::endl; + //std::cerr << "CInputValidationPlan::validate() returns with true" << std::endl; return true; } @@ -246,7 +231,7 @@ private: // get requested row of validators: ValidatorsRow vValidators = m_arrayValidators[ival].second; - std::cerr << "CInputValidationPlan::execValidatorsInRow() calling validators" << " for vin iv=" << iv << " ival=" << ival << std::endl; + //std::cerr << "CInputValidationPlan::execValidatorsInRow() calling validators" << " for vin iv=" << iv << " ival=" << ival << std::endl; for (auto v : vValidators) { bool result; @@ -327,7 +312,7 @@ public: } - std::cerr << "COutputValidationPlan::validate() returns with true" << std::endl; + //std::cerr << "COutputValidationPlan::validate() returns with true" << std::endl; return true; } @@ -351,7 +336,7 @@ private: // get requested row of validators: ValidatorsRow vValidators = m_arrayValidators[ival].second; - std::cerr << "COutputValidationPlan::execRow() calling validators" << " for vout iv=" << iv << " ival=" << ival << std::endl; + //std::cerr << "COutputValidationPlan::execRow() calling validators" << " for vout iv=" << iv << " ival=" << ival << std::endl; for (auto v : vValidators) { @@ -422,7 +407,7 @@ public: GetCCaddress1of2(m_cp, shouldBeAddr, ownerPubkey, heirPubkey); if (vout.scriptPubKey.IsPayToCryptoCondition()) { if (Getscriptaddress(ccAddr, vout.scriptPubKey) && strcmp(shouldBeAddr, ccAddr) == 0) { - std::cerr << "CCC1of2AddressValidator::validateVout() exits with true" << std::endl; + //std::cerr << "CCC1of2AddressValidator::validateVout() exits with true" << std::endl; return true; } else { @@ -476,23 +461,24 @@ public: if (m_checkNormals) { ownerScript = CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; heirScript = CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; + std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout(coin,owner)=" << CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << " makeUserVout(coin,heir)=" << CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey.ToString() << std::endl; } else { ownerScript = Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; heirScript = Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; + std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout(owner)=" << Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << " makeUserVout(heir)=" << Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey.ToString() << std::endl; } - //std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout=" << Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << std::endl; - // recreate scriptPubKey for owner and heir and compare it with that of the vout to check: if (vout.scriptPubKey == ownerScript || vout.scriptPubKey == heirScript) { // this is vout to owner or heir addr: - std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with true" << std::endl; + //std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with true" << std::endl; return true; } std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with false (not the owner's or heir's addresses)" << std::endl; + message = std::string("invalid pubkey"); return false; } virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } @@ -509,7 +495,7 @@ private: template class CHeirSpendValidator : CValidatorBase { public: - CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, bool isHeirSpendingBegan) + CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -547,7 +533,7 @@ public: } } - std::cerr << "CHeirSpendValidator::validateVout() exits with true" << std::endl; + //std::cerr << "CHeirSpendValidator::validateVout() exits with true" << std::endl; // this is not heir: return true; @@ -557,7 +543,7 @@ public: private: CScript m_fundingOpretScript; uint256 m_latesttxid; - bool m_isHeirSpendingBegan; + uint8_t m_isHeirSpendingBegan; }; /** @@ -576,12 +562,13 @@ public: uint8_t funcId, initialFuncId; // do not check heir name uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid, initialTokenid; + uint8_t dummyIsHeirSpendingBegan; - if ((funcId = DecodeHeirOpRet(vout.scriptPubKey, tokenid, fundingTxidInOpret)) == 0) { + if ((funcId = DecodeHeirOpRet(vout.scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan)) == 0) { message = std::string("invalid opreturn format"); return false; } - if ((initialFuncId = DecodeHeirOpRet(m_fundingOpretScript, initialTokenid, dummyTxid)) == 0) { + if ((initialFuncId = DecodeHeirOpRet(m_fundingOpretScript, initialTokenid, dummyTxid, dummyIsHeirSpendingBegan)) == 0) { message = std::string("invalid initial tx opreturn format"); return false; } @@ -606,6 +593,19 @@ private: CScript m_fundingOpretScript; }; +/** +* empty validator always returns true +*/ +template class CNullValidator : CValidatorBase +{ +public: + CNullValidator(CCcontract_info* cp) + : CValidatorBase(cp) { } + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } +}; #endif \ No newline at end of file From 8e8d4e0057313fb94ad0ee880faf0e21775a6504 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 9 Jan 2019 17:19:49 +0500 Subject: [PATCH 1148/3904] improved heir spending var name --- src/cc/heir.cpp | 110 ++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index d75580cec..ad71b3b2a 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -36,7 +36,7 @@ class TokenHelper; // Plan validation runner, it may be called twice - for coins and tokens // (sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation()...) -template bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t isHeirSpendingBegan) +template bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun) { int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); @@ -53,7 +53,7 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont // vin and vout 'validators' // not used, too strict for 2 pubkeys: CMyPubkeyVoutValidator normalInputValidator(cp, fundingOpretScript, true); // check normal input for this opret cause this is first tx CCC1of2AddressValidator cc1of2ValidatorThis(cp, fundingOpretScript, "checking this tx opreturn:"); // 1of2add validator with pubkeys from this tx opreturn - CHeirSpendValidator heirSpendValidator(cp, fundingOpretScript, latestTxid, isHeirSpendingBegan); // check if heir allowed to spend + CHeirSpendValidator heirSpendValidator(cp, fundingOpretScript, latestTxid, hasHeirSpendingBegun); // check if heir allowed to spend // only for tokens: CMyPubkeyVoutValidator ownerCCaddrValidator(cp, fundingOpretScript, false); // check if this correct owner's cc user addr corresponding to opret @@ -126,14 +126,14 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenid = zeroid; CScript fundingTxOpRetScript; - uint8_t isHeirSpendingBegan = 0, dummyIsHeirSpendingBegan; + uint8_t hasHeirSpendingBegun = 0, dummyhasHeirSpendingBegun; int32_t heirType = NOT_HEIR; - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, true); if(funcId != 0) heirType = HEIR_COINS; else { - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, false); + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, false); if (funcId != 0) heirType = HEIR_TOKENS; } @@ -146,9 +146,9 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction return eval->Invalid("invalid tx opreturn format: no fundingtxid present"); } if (heirType == HEIR_COINS) - latestTxid = FindLatestFundingTx(fundingTxidInOpret, dummyTokenid, fundingTxOpRetScript, isHeirSpendingBegan); + latestTxid = FindLatestFundingTx(fundingTxidInOpret, dummyTokenid, fundingTxOpRetScript, hasHeirSpendingBegun); else - latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, isHeirSpendingBegan); + latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, hasHeirSpendingBegun); if (latestTxid == zeroid) { return eval->Invalid("invalid heir transaction: no funding tx found"); @@ -179,7 +179,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction // vout.2: normal change // vout.n-1: opreturn 't' tokenid 'F' ownerpk heirpk inactivitytime heirname tokenid if (heirType == HEIR_TOKENS) - return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); else return eval->Invalid("unexpected HeirValidate for heirfund"); // break; @@ -200,7 +200,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction // vout.1: normal change // vout.n-1: opreturn 't' tokenid 'A' ownerpk heirpk inactivitytime fundingtx if (heirType == HEIR_TOKENS) - return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); else return eval->Invalid("unexpected HeirValidate for heiradd"); //break; @@ -224,9 +224,9 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction // vout.2: change to normal from txfee input if any // vout.n-1: opreturn 't' tokenid 'C' ownerpk heirpk inactivitytime fundingtx if (heirType == HEIR_TOKENS) - return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); else - return RunValidationPlans(funcId, cpHeir, eval, tx, latestTxid, fundingTxOpRetScript, isHeirSpendingBegan); + return RunValidationPlans(funcId, cpHeir, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); // break; default: @@ -307,12 +307,12 @@ CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirP } // makes coin additional tx opret -CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan) +CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpendingBegun) { uint8_t evalcode = EVAL_HEIR; fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << isHeirSpendingBegan); + return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); } // makes opret for tokens while they are inside Heir contract address space - initial funding CScript EncodeHeirTokensCreateOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) @@ -330,7 +330,7 @@ CScript EncodeHeirTokensCreateOpRet(uint8_t heirFuncId, uint256 tokenid, std::ve ss << heirFuncId << ownerPubkey << heirPubkey << inactivityTimeSec << hearName); } // makes opret for tokens while they are inside Heir contract address space - additional funding -CScript EncodeHeirTokensOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) +CScript EncodeHeirTokensOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t hasHeirSpendingBegun) { uint8_t evalcode = EVAL_HEIR; uint8_t ccType = 0; @@ -343,20 +343,20 @@ CScript EncodeHeirTokensOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector= 1) ss << voutPubkeys[0]; \ if (ccType == 2) ss << voutPubkeys[1]; \ - ss << heirFuncId << fundingtxid << isHeirSpendingBegan); + ss << heirFuncId << fundingtxid << hasHeirSpendingBegun); } // helper for decode heir opret payload // NOTE: Heir for coins has the same opret as Heir for tokens -uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &isHeirSpendingBegan) { +uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun) { uint8_t heirFuncId = 0; - isHeirSpendingBegan = 0; + hasHeirSpendingBegun = 0; bool result = E_UNMARSHAL(vopretExtra, { ss >> heirFuncId; \ if( heirFuncId == 'F') { \ ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; \ } else { \ - ss >> fundingTxidInOpret >> isHeirSpendingBegan; \ + ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ } \ }); @@ -368,7 +368,7 @@ uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, /** * decode opret vout for Heir contract */ -template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &isHeirSpendingBegan, bool noLogging) +template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { std::vector vopretExtra; @@ -403,14 +403,14 @@ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 & if (vopretExtra.size() > 1 && evalCodeInOpret == EVAL_HEIR) { // NOTE: it unmarshals for all F, A and C - uint8_t heirFuncId = _UnmarshalOpret(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, isHeirSpendingBegan); + uint8_t heirFuncId = _UnmarshalOpret(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, hasHeirSpendingBegun); /*std::cerr << "DecodeHeirOpRet()" << " heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') << " ownerPubkey=" << HexStr(ownerPubkey) << " heirPubkey=" << HexStr(heirPubkey) << " heirName=" << heirName << " inactivityTime=" << inactivityTime - << " isHeirSpendingBegan=" << (int)isHeirSpendingBegan << std::endl;*/ + << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << std::endl;*/ //if (e == EVAL_HEIR && IS_CHARINSTR(funcId, "FAC")) @@ -434,21 +434,21 @@ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 & template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { uint256 dummytxid; - uint8_t dummyIsHeirSpendingBegan; + uint8_t dummyhasHeirSpendingBegun; - return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyIsHeirSpendingBegan, noLogging); + return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyhasHeirSpendingBegun, noLogging); } /** * overload for A, C oprets and AddHeirContractInputs */ -template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxidInOpret, uint8_t &isHeirSpendingBegan, bool noLogging) +template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; std::string dummyHeirName; - return _DecodeHeirOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, isHeirSpendingBegan, noLogging); + return _DecodeHeirOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); } @@ -457,7 +457,7 @@ template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &t * find the latest funding tx: it may be the first F tx or one of A or C tx's * Note: this function is also called from validation code (use non-locking calls) */ -template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, uint8_t &isHeirSpendingBegan) +template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, uint8_t &hasHeirSpendingBegun) { CTransaction fundingtx; uint256 hashBlock; @@ -467,7 +467,7 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ //CCtxidaddr(markeraddr, fundingtxid); //SetCCunspents(unspentOutputs, markeraddr); - isHeirSpendingBegan = 0; + hasHeirSpendingBegun = 0; funcId = 0; // get initial funding tx and set it as initial lasttx: @@ -517,29 +517,29 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ /*{ // debug code: uint256 debAssetid; - uint8_t debIsHeirSpendingBegan; - uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, debIsHeirSpendingBegan, true); + uint8_t debhasHeirSpendingBegun; + uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, debhasHeirSpendingBegun, true); std::cerr << "FindLatestFundingTx() regtx.vout.size()=" << regtx.vout.size() << " funcId=" << (char)(debfuncid ? debfuncid : ' ') - << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << " debIsHeirSpendingBegan=" << (int)debIsHeirSpendingBegan << std::endl; + << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << " debhasHeirSpendingBegun=" << (int)debhasHeirSpendingBegun << std::endl; }*/ uint256 dummyTokenid; // not to contaminate the tokenid from the params! uint8_t tmpFuncId; - uint8_t tmpIsHeirSpendingBegan; + uint8_t tmphasHeirSpendingBegun; if (regtx.vout.size() > 0 && - (tmpFuncId = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, tmpIsHeirSpendingBegan, true)) != 0 && + (tmpFuncId = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, tmphasHeirSpendingBegun, true)) != 0 && fundingtxid == fundingTxidInOpret) { if (blockHeight > maxBlockHeight) { maxBlockHeight = blockHeight; latesttxid = txid; funcId = tmpFuncId; - isHeirSpendingBegan = tmpIsHeirSpendingBegan; + hasHeirSpendingBegun = tmphasHeirSpendingBegun; //std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight - // << " opreturn type=" << (char)(funcId ? funcId : ' ') << " isHeirSpendingBegan=" << (int)isHeirSpendingBegan << " - set as current lasttxid" << '\n'; + // << " opreturn type=" << (char)(funcId ? funcId : ' ') << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << " - set as current lasttxid" << '\n'; } } } @@ -549,7 +549,7 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ } // overload for validation code -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan) +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &hasHeirSpendingBegun) { uint8_t funcId; CPubKey ownerPubkey; @@ -557,15 +557,15 @@ template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 int64_t inactivityTime; std::string heirName; - return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, isHeirSpendingBegan); + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); } // overload for transaction creation code -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint8_t &isHeirSpendingBegan) +template uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint8_t &hasHeirSpendingBegun) { CScript opRetScript; - return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, isHeirSpendingBegan); + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); } // add inputs of 1 of 2 cc address @@ -595,9 +595,9 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { uint256 tokenid; uint256 fundingTxidInOpret; - uint8_t dummyIsHeirSpendingBegan; + uint8_t dummyhasHeirSpendingBegun; - uint8_t funcId = DecodeHeirOpRet(heirtx.vout[heirtx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + uint8_t funcId = DecodeHeirOpRet(heirtx.vout[heirtx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, true); if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && funcId != 0 && Helper::isMyFuncId(funcId) && @@ -642,9 +642,9 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info uint256 tokenid; uint256 fundingTxidInOpret; const int32_t ivout = 0; - uint8_t dummyIsHeirSpendingBegan; + uint8_t dummyhasHeirSpendingBegun; - funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, true); //std::cerr << "LifetimeHeirContractFunds() found tx=" << txid.GetHex() << " vout[0].nValue=" << subtx.vout[ccVoutIdx].nValue << " opreturn=" << (char)funcId << '\n'; @@ -751,14 +751,14 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in uint256 lasttxid, tokenid; std::string heirName; uint8_t funcId; - uint8_t isHeirSpendingBegan = 0; + uint8_t hasHeirSpendingBegun = 0; cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) txfee = 10000; - if ((lasttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan)) != zeroid) { + if ((lasttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { int32_t numblocks; CPubKey myPubkey = pubkey2pk(Mypubkey()); @@ -802,7 +802,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in // add opreturn 'A' and sign tx: // this txfee ignored std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, isHeirSpendingBegan))); + Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); result.push_back(Pair("result", "success")); result.push_back(Pair("hextx", rawhextx)); @@ -855,26 +855,26 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee uint256 latesttxid, tokenid; uint8_t funcId; std::string heirName; - uint8_t isHeirSpendingBegan = 0; + uint8_t hasHeirSpendingBegun = 0; cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) txfee = 10000; - if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan)) != zeroid) { + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { int32_t numblocks; uint64_t durationSec = 0; // we do not need to find duration if spending already has begun - if (!isHeirSpendingBegan) { + if (!hasHeirSpendingBegun) { durationSec = CCduration(numblocks, latesttxid); std::cerr << "HeirClaim() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << std::endl; } // spending is allowed if there is already spending tx or inactivity time //bool isAllowedToHeir = (funcId == 'C' || durationSec > inactivityTimeSec) ? true : false; - bool isAllowedToHeir = (isHeirSpendingBegan || durationSec > inactivityTimeSec) ? true : false; + bool isAllowedToHeir = (hasHeirSpendingBegun || durationSec > inactivityTimeSec) ? true : false; myPubkey = pubkey2pk(Mypubkey()); // if it is the heir, check if spending not allowed to heir yet @@ -947,7 +947,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee // add opreturn 'C' and sign tx: // this txfee will be ignored std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : isHeirSpendingBegan)); // forward isHeirSpending to the next latest tx + Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : hasHeirSpendingBegun)); // forward isHeirSpending to the next latest tx result.push_back(Pair("result", "success")); result.push_back(Pair("hextx", rawhextx)); @@ -1031,12 +1031,12 @@ UniValue HeirInfo(uint256 fundingtxid) else cp = CCinit(&C, TokenHelper::getMyEval()); - uint8_t isHeirSpendingBegan = 0; + uint8_t hasHeirSpendingBegun = 0; if (heirType == HEIR_COINS) - latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan); + latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); else - latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, isHeirSpendingBegan); + latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); if (latestFundingTxid != zeroid) { int32_t numblocks; @@ -1119,12 +1119,12 @@ UniValue HeirInfo(uint256 fundingtxid) stream.str(""); stream.clear(); - if (!isHeirSpendingBegan) { // we do not need find duration if the spending already has begun + if (!hasHeirSpendingBegun) { // we do not need find duration if the spending already has begun durationSec = CCduration(numblocks, latestFundingTxid); std::cerr << "HeirInfo() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << '\n'; } - stream << std::boolalpha << (isHeirSpendingBegan || durationSec > inactivityTimeSec); + stream << std::boolalpha << (hasHeirSpendingBegun || durationSec > inactivityTimeSec); result.push_back(Pair("spending allowed for the heir", stream.str().c_str())); stream.str(""); stream.clear(); From 6e353a59a453b1363e0c2c788718d024dbd1bd13 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 9 Jan 2019 17:28:34 +0500 Subject: [PATCH 1149/3904] more var name hasheirspendingbegun improved --- src/cc/heir.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index ad71b3b2a..7d5ea7cfe 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -126,14 +126,14 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenid = zeroid; CScript fundingTxOpRetScript; - uint8_t hasHeirSpendingBegun = 0, dummyhasHeirSpendingBegun; + uint8_t hasHeirSpendingBegun = 0, dummyHasHeirSpendingBegun; int32_t heirType = NOT_HEIR; - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, true); + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); if(funcId != 0) heirType = HEIR_COINS; else { - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, false); + funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, false); if (funcId != 0) heirType = HEIR_TOKENS; } @@ -434,9 +434,9 @@ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 & template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { uint256 dummytxid; - uint8_t dummyhasHeirSpendingBegun; + uint8_t dummyHasHeirSpendingBegun; - return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyhasHeirSpendingBegun, noLogging); + return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); } /** @@ -517,11 +517,11 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ /*{ // debug code: uint256 debAssetid; - uint8_t debhasHeirSpendingBegun; - uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, debhasHeirSpendingBegun, true); + uint8_t debHasHeirSpendingBegun; + uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, debHasHeirSpendingBegun, true); std::cerr << "FindLatestFundingTx() regtx.vout.size()=" << regtx.vout.size() << " funcId=" << (char)(debfuncid ? debfuncid : ' ') - << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << " debhasHeirSpendingBegun=" << (int)debhasHeirSpendingBegun << std::endl; + << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << " debHasHeirSpendingBegun=" << (int)debHasHeirSpendingBegun << std::endl; }*/ uint256 dummyTokenid; // not to contaminate the tokenid from the params! @@ -595,9 +595,9 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { uint256 tokenid; uint256 fundingTxidInOpret; - uint8_t dummyhasHeirSpendingBegun; + uint8_t dummyHasHeirSpendingBegun; - uint8_t funcId = DecodeHeirOpRet(heirtx.vout[heirtx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, true); + uint8_t funcId = DecodeHeirOpRet(heirtx.vout[heirtx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && funcId != 0 && Helper::isMyFuncId(funcId) && @@ -642,9 +642,9 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info uint256 tokenid; uint256 fundingTxidInOpret; const int32_t ivout = 0; - uint8_t dummyhasHeirSpendingBegun; + uint8_t dummyHasHeirSpendingBegun; - funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyhasHeirSpendingBegun, true); + funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); //std::cerr << "LifetimeHeirContractFunds() found tx=" << txid.GetHex() << " vout[0].nValue=" << subtx.vout[ccVoutIdx].nValue << " opreturn=" << (char)funcId << '\n'; From 884c58e3cf341763d8dbadcc844d75d894c4a72f Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 9 Jan 2019 18:04:15 +0500 Subject: [PATCH 1150/3904] removed test CCerror code --- src/wallet/rpcwallet.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1320da61c..b39a19668 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6952,20 +6952,12 @@ UniValue tokenlist(const UniValue& params, bool fHelp) UniValue tokeninfo(const UniValue& params, bool fHelp) { -#ifdef TESTMODE - std::cerr << "is CCerror clear? CCerror=" << CCerror << std::endl; -#endif uint256 tokenid; if ( fHelp || params.size() != 1 ) throw runtime_error("tokeninfo tokenid\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); tokenid = Parseuint256((char *)params[0].get_str().c_str()); - -#ifdef TESTMODE - CCerror = "test error"; -#endif - return(AssetInfo(tokenid)); } From 1f6d62e7c84a43cbf58a70e82cb1dcd5ec1f196d Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 13:40:21 +0500 Subject: [PATCH 1151/3904] MakeTokensCC1of2vout MakeTokensCCcond1of2 test code added gateways partially adapted for tokens --- src/cc/CCinclude.h | 18 ++++-- src/cc/CCtokens.cpp | 10 ++- src/cc/CCtokens.h | 1 - src/cc/CCtx.cpp | 31 +++++---- src/cc/CCutils.cpp | 47 +++++++++++++- src/cc/gateways.cpp | 153 ++++++++++++++++++++++++++++---------------- src/cc/heir.cpp | 2 +- 7 files changed, 182 insertions(+), 80 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 1b6e804fc..3e70ba380 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -91,10 +91,14 @@ struct CCcontract_info char unspendableCCaddr[64], CChexstr[72], normaladdr[64]; uint8_t CCpriv[32]; - // this for 1of2 key spending condition (for this evalcode) + // this for 1of2 keys coins cryptocondition (for this evalcode) // NOTE: only one evalcode is allowed at this time - char unspendable1of2addr[64]; - CPubKey unspendable1of2pk[2]; + char coins1of2addr[64]; + CPubKey coins1of2pk[2]; + + // the same for tokens 1of2 keys cc + char tokens1of2addr[64]; + CPubKey tokens1of2pk[2]; // this is for spending from two additional 'unspendable' CC addresses of other eval codes // (that is, for spending from several cc contract 'unspendable' addresses): @@ -153,15 +157,15 @@ uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); - bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey); bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); + +CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra); -//uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid,uint256 &assetid2,int64_t &price,std::vector &origpubkey); uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t *data,int32_t offset,int32_t datalen); @@ -182,6 +186,10 @@ CC* GetCryptoCondition(CScript const& scriptSig); void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); + +CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); +CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2); + bool IsCCInput(CScript const& scriptSig); int32_t unstringbits(char *buf,uint64_t bits); uint64_t stringbits(char *str); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 4a2c6031e..62fb1fa78 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -51,7 +51,7 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector origpubkey,st } // this is for other contracts which use tokens and build customized extra payloads to token's opret: -CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys) +CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload) { CScript opret; uint8_t ccType = 0; @@ -63,10 +63,14 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t //uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l'; //opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); - opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; if (ccType >= 1) ss << voutPubkeys[0]; if (ccType == 2) ss << voutPubkeys[1];); + opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ + if(ccType >= 1) ss << voutPubkeys[0]; \ + if(ccType == 2) ss << voutPubkeys[1]; \ + if(payload.size() > 0) ss << payload); return(opret); } + uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description) { std::vector vopret; uint8_t dummyEvalcode, funcid, *script; @@ -578,7 +582,7 @@ std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector d std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(pubkey2pk(destpubkey)); // dest pubkey for validating vout - return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet('t', EVAL_TOKENS, assetid, voutTokenPubkeys))); // By setting EVAL_TOKENS we're getting out from assets validation code + return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet('t', EVAL_TOKENS, assetid, voutTokenPubkeys, CScript()))); // By setting EVAL_TOKENS we're getting out from assets validation code } else { fprintf(stderr, "not enough CC token inputs for %.8f\n", (double)total / COIN); diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index f65a56b41..34223bc0b 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -31,7 +31,6 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t //int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); -CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys); //this is in CCinclude.h int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 79473b87a..ec0a24b3f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -45,7 +45,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64]; uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *cond; + CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond; CPubKey unspendablepk; n = mtx.vout.size(); @@ -130,7 +130,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - //fprintf(stderr,"vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); + //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); if ( strcmp(destaddr,myaddr) == 0 ) { privkey = myprivkey; @@ -140,37 +140,44 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"unspendable CC addr.(%s)\n",unspendable); + //fprintf(stderr,"FinalizeCCTx() unspendable CC addr.(%s)\n",unspendable); } // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr2) == 0) { - //fprintf(stderr,"matched %s unspendable2!\n",cp->unspendableaddr2); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; - if ( othercond2 == 0 ) //&& cp->evalcode != EVAL_CHANNELS && cp->evalcode != EVAL_HEIR && cp->evalcode != EVAL_ASSETS && cp->evalcode != EVAL_TOKENS) + if ( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->evalcode2, cp->unspendablepk2); - //else if ( othercond2 == 0 && (cp->evalcode == EVAL_CHANNELS || cp->evalcode == EVAL_HEIR || cp->evalcode == EVAL_ASSETS || cp->evalcode == EVAL_TOKENS) ) - // othercond2 = MakeCCcond1of2(cp->evalcode2,cp->unspendablepk2,cp->unspendablepk3); cond = othercond2; } // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { - //fprintf(stderr,"matched %s unspendable3!\n",cp->unspendableaddr3); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); privkey = cp->unspendablepriv3; if ( othercond3 == 0 ) othercond3 = MakeCCcond1(cp->evalcode3,cp->unspendablepk3); cond = othercond3; } - // check if this is spending from 1of2 cc addr: - else if (strcmp(cp->unspendable1of2addr, destaddr) == 0) + // check if this is spending from 1of2 cc coins addr: + else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - //fprintf(stderr,"matched %s unspendable1of2!\n",cp->unspendable1of2addr); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = myprivkey; if (othercond1of2 == 0) - othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->unspendable1of2pk[0], cp->unspendable1of2pk[1]); + othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); cond = othercond1of2; } + // check if this is spending from 1of2 cc tokens addr: + else if (strcmp(cp->tokens1of2addr, destaddr) == 0) + { + fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); + privkey = myprivkey; + if (othercond1of2tokens == 0) + othercond1of2tokens = MakeTokensCCcond1of2(cp->evalcode, cp->tokens1of2pk[0], cp->tokens1of2pk[1]); + cond = othercond1of2tokens; + } else { fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index eef21c72a..c07755c2a 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -76,6 +76,39 @@ CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk1,CPubKey pk2) return(vout); } +CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2) +{ + // make 1of2 sigs cond + std::vector pks; + pks.push_back(CCNewSecp256k1(pk1)); + pks.push_back(CCNewSecp256k1(pk2)); + CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); // this is eval cc + CC *cond1of2Sig = CCNewThreshold(1, pks); // this is 1 of 2 sigs cc + CC *cond1of2Threshold = CCNewThreshold(2, { condEvalCC, cond1of2Sig }); + + // make token cond + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); + + std::vector pksTokens; + pks.push_back(CCNewSecp256k1(unspendableTokensPk)); + CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval cc + CC *condUnspendableSig = CCNewThreshold(1, pksTokens); // this is 1 of 2 sigs cc + CC *condTopThreshold = CCNewThreshold(2, { condEvalTokensCC, condUnspendableSig }); + + return CCNewThreshold(2, { cond1of2Threshold, condTopThreshold }); +} + +CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2) +{ + CTxOut vout; + CC *payoutCond = MakeTokensCCcond1of2(evalcode, pk1, pk2); + vout = CTxOut(nValue, CCPubKey(payoutCond)); + cc_free(payoutCond); + return(vout); +} + CC* GetCryptoCondition(CScript const& scriptSig) { auto pc = scriptSig.begin(); @@ -198,9 +231,17 @@ void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t * // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 cryptocondition vout: void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) { - cp->unspendable1of2pk[0] = pk1; - cp->unspendable1of2pk[1] = pk2; - strcpy(cp->unspendable1of2addr, coinaddr); + cp->coins1of2pk[0] = pk1; + cp->coins1of2pk[1] = pk2; + strcpy(cp->coins1of2addr, coinaddr); +} + +// set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 tokens cryptocondition vout: +void CCaddr1of2setTokens(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +{ + cp->tokens1of2pk[0] = pk1; + cp->tokens1of2pk[1] = pk2; + strcpy(cp->tokens1of2addr, coinaddr); } bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 2768e9fbd..c64d56b80 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -132,14 +132,18 @@ Implementation Issues: - When thinking about validation, it is clear that we cant use EVAL_ASSETS for the locked coins as there wont be any enforcement of the gateways locking. This means we need a way to transfer assets into gateways outputs and back. It seems a tokenconvert rpc will be needed and hopefully that will be enough to make it all work properly. + -- When thinking about validation, it is clear that we cant use EVAL_ASSETS for the locked coins as there wont be any enforcement of the gateways locking. + -- This means we need a way to transfer assets into gateways outputs and back. It seems a tokenconvert rpc will be needed and hopefully that will be enough to make it all work properly. + ++ The use of tokenconvert has been changed to the use of the new Tokens contract which can enforce other contracts validation by forwarding eval->validate call to GatewaysValidate + ++ So all tokens remain within that Tokens contract eval code. - Care must be taken so that tokens are not lost and can be converted back. - - This changes the usage to require tokenconvert before doing the bind and also tokenconvert before doing a withdraw. EVAL_GATEWAYS has evalcode of 241 - - The gatewaysclaim automatically converts the deposit amount of tokens back to EVAL_ASSETS. + -- Care must be taken so that tokens are not lost and can be converted back. + -- This changes the usage to require tokenconvert before doing the bind and also tokenconvert before doing a withdraw. EVAL_GATEWAYS has evalcode of 241 + ++ tokenconvert now returns 'not implemented', no need to use it at all. + -- The gatewaysclaim automatically converts the deposit amount of tokens back to EVAL_ASSETS. + ++ The gatewaysclaim automatically transfers the deposit amount of tokens to depositor's address (within EVAL_TOKENS). + */ @@ -204,38 +208,42 @@ uint8_t DecodeGatewaysDepositOpRet(const CScript &scriptPubKey,std::string &coin return(0); } -CScript EncodeGatewaysClaimOpRet(uint8_t funcid,uint256 assetid,std::string refcoin,uint256 bindtxid,uint256 deposittxid,CPubKey destpub,int64_t amount) +// encodes payload for the token opret (needs to be added to the tail of it) +CScript EncodeGatewaysClaimOpRet(uint8_t funcid, std::string refcoin, uint256 bindtxid, uint256 deposittxid, CPubKey destpub, int64_t amount) { - CScript opret; uint8_t evalcode = EVAL_ASSETS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << refcoin << bindtxid << deposittxid << destpub << amount); + CScript opret; + + opret << OP_RETURN << E_MARSHAL(ss << funcid << refcoin << bindtxid << deposittxid << destpub << amount); return(opret); } -uint8_t DecodeGatewaysClaimOpRet(const CScript &scriptPubKey,uint256 &assetid,std::string &refcoin,uint256 &bindtxid,uint256 &deposittxid,CPubKey &destpub,int64_t &amount) +uint8_t DecodeGatewaysClaimOpRet(const CScript &scriptPubKey,uint256 &tokenid,std::string &refcoin,uint256 &bindtxid,uint256 &deposittxid,CPubKey &destpub,int64_t &amount) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid; ss >> refcoin; ss >> bindtxid; ss >> deposittxid; ss >> destpub; ss >> amount) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> tokenid; ss >> refcoin; ss >> bindtxid; ss >> deposittxid; ss >> destpub; ss >> amount) != 0 ) { return(f); } return(0); } -CScript EncodeGatewaysWithdrawOpRet(uint8_t funcid,uint256 assetid, std::string refcoin, CPubKey withdrawpub, int64_t amount) +CScript EncodeGatewaysWithdrawOpRet(uint8_t funcid, std::string refcoin, CPubKey withdrawpub, int64_t amount) { - CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << refcoin << withdrawpub << amount); + CScript opret; + opret << OP_RETURN << E_MARSHAL(ss << funcid << refcoin << withdrawpub << amount); return(opret); } -uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256 &assetid, std::string &refcoin, CPubKey &withdrawpub, int64_t &amount) +uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256 &tokenid, std::string &refcoin, CPubKey &withdrawpub, int64_t &amount) { std::vector vopret; uint8_t *script,e,f; + + GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid; ss >> refcoin; ss >> withdrawpub; ss >> amount) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> tokenid; ss >> refcoin; ss >> withdrawpub; ss >> amount) != 0 ) { return(f); } @@ -304,7 +312,7 @@ uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey) std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && (script[0] == EVAL_GATEWAYS || script[0] == EVAL_ASSETS) && E_UNMARSHAL(vopret,ss >> e; ss >> f) != 0 ) + if ( vopret.size() > 2 && (script[0] == EVAL_GATEWAYS || script[0] == EVAL_TOKENS) && E_UNMARSHAL(vopret,ss >> e; ss >> f) != 0 ) { if (f == 'B' && f == 'D' && f == 't' && f == 'W' && f == 'P' && f == 'M') return(f); @@ -512,7 +520,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],M,N,taddr,prefix,prefix2; char str[65],destaddr[64],depositaddr[65],validationError[512]; std::vector txids; std::vector pubkeys,publishers,tmppublishers; std::vector proof; int64_t totalsupply,amount,tmpamount; - uint256 hashblock,txid,bindtxid,deposittxid,assetid,oracletxid,tokenid,cointxid,tmptxid,tmpxtxid2,merkleroot,mhash; CTransaction bindtx,deposittx,oracletx; + uint256 hashblock,txid,bindtxid,deposittxid,tokenidClaim,oracletxid,tokenidBind,cointxid,tmptxid,tmpxtxid2,merkleroot,mhash; CTransaction bindtx,deposittx,oracletx; std::string refcoin,tmprefcoin,deposithex; CPubKey destpub,tmpdestpub; fprintf(stderr,"return true without gateways validation\n"); @@ -565,8 +573,8 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & //vin.2: CC input of marker from gatewaysdeposit tx //vout.0: CC vout of total tokens from deposit amount to asset eval code //(vout.1): CC vout if there is change of unused tokens back to owner of tokens (deposit amount less than available tokens) - //vout.n-1: opreturn - 't' assetid zeroid 0 mypubkey (NOTE: opreturn is with asset eval code) - if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysClaimOpRet(tx.vout[numvouts-1].scriptPubKey,assetid,refcoin,bindtxid,deposittxid,destpub,amount)==0) + //vout.n-1: opreturn - 't' tokenid zeroid 0 mypubkey (NOTE: opreturn is with asset eval code) + if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysClaimOpRet(tx.vout[numvouts-1].scriptPubKey,tokenidClaim,refcoin,bindtxid,deposittxid,destpub,amount)==0) return eval->Invalid("invalid gatewaysclaim OP_RETURN data!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("vin.0 is normal for gatewaysClaim!"); @@ -580,12 +588,12 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("vout.1 is CC for gatewaysClaim!"); else if (myGetTransaction(bindtxid,bindtx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); - else if ((numvouts=bindtx.vout.size()) > 0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenid,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + else if ((numvouts=bindtx.vout.size()) > 0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenidBind,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different in bind tx"); - else if (tokenid!=assetid) - return eval->Invalid("assetid does not match tokenid from gatewaysbind"); + else if (tokenidClaim!=tokenidBind) + return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); else if (komodo_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if (myGetTransaction(deposittxid,deposittx,hashblock) == 0) @@ -642,7 +650,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & //vout.1: normal vout txfee marker to withdraw destination pubkey //vout.2: CC vout txfee marker to gateways CC address //vout.n-2: CC vout if there is change of unused tokens back to owner of tokens (withdraw amount less than owner available tokens) - //vout.n-1: opreturn - 'W' assetid refcoin withdrawpub amount + //vout.n-1: opreturn - 'W' tokenid refcoin withdrawpub amount break; case 'P': //vin.0: normal input @@ -675,9 +683,9 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & // helper functions for rpc calls in rpcwallet.cpp -int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 refassetid,int64_t total,int32_t maxinputs) +int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 reftokenid,int64_t total,int32_t maxinputs) { - char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 assetid,txid,hashBlock; std::vector origpubkey; std::vector vopret; CTransaction vintx; int32_t j,vout,n = 0; uint8_t evalcode,funcid; + char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 tokenid,txid,hashBlock; std::vector origpubkey; std::vector vopret; CTransaction vintx; int32_t j,vout,n = 0; uint8_t evalcode,funcid; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); @@ -701,11 +709,11 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( strcmp(destaddr,coinaddr) != 0 && strcmp(destaddr,cp->unspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) continue; GetOpReturnData(vintx.vout[vintx.vout.size()-1].scriptPubKey, vopret); - if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> assetid) != 0 ) + if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> tokenid) != 0 ) { - assetid = revuint256(assetid); - char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)vintx.vout[vout].nValue/COIN); - if ( assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + tokenid = revuint256(tokenid); + char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for reftokenid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,reftokenid),uint256_str(str2,tokenid),(double)vintx.vout[vout].nValue/COIN); + if ( tokenid == reftokenid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { //fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); if ( total != 0 && maxinputs != 0 ) @@ -905,7 +913,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CCcontract_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; std::string coin, deposithex; std::vector msigpubkeys,publishers; int64_t totalsupply,depositamount,tmpamount,inputs,CCchange=0; int32_t numvouts,claimvout,height; std::vector proof; - uint256 hashBlock,assetid,oracletxid,tmptxid,cointxid; char str[65],depositaddr[64],coinaddr[64],destaddr[64]; std::vector txids; + uint256 hashBlock,tokenid,oracletxid,tmptxid,cointxid; char str[65],depositaddr[64],coinaddr[64],destaddr[64]; std::vector txids; cp = CCinit(&C,EVAL_GATEWAYS); if ( txfee == 0 ) @@ -917,7 +925,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,coin,assetid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) { fprintf(stderr,"invalid coin - bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); return(""); @@ -945,17 +953,24 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui //fprintf(stderr,"depositaddr.(%s) vs %s\n",depositaddr,cp->unspendableaddr2); if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) { - if ( (inputs= AddGatewaysInputs(cp,mtx,gatewayspk,assetid,amount,60)) > 0 ) + ///////// if ( (inputs= AddGatewaysInputs(cp,mtx,gatewayspk,tokenid,amount,60)) > 0 ) + if ((inputs = AddTokenCCInputs(cp, mtx, gatewayspk, tokenid, amount, 60)) > 0) { if ( inputs > amount ) CCchange = (inputs - amount); _GetCCaddress(destaddr,EVAL_GATEWAYS,mypk); //printf("expecting deposittxid/v0 to be to %s\n",destaddr); mtx.vin.push_back(CTxIn(deposittxid,0,CScript())); // triggers EVAL_GATEWAYS validation - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,amount,mypk)); // transfer back to normal token + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,amount,mypk)); // transfer back to normal token if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CCchange,gatewayspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysClaimOpRet('t',assetid,refcoin,bindtxid,deposittxid,destpub,amount))); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CCchange,gatewayspk)); + + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(mypk); // the pubkey where tokens are going (vout[0]) + + return(FinalizeCCTx(0,cp,mtx,mypk,txfee, + EncodeTokenOpRet('t', EVAL_GATEWAYS, tokenid, voutTokenPubkeys, + EncodeGatewaysClaimOpRet('t', refcoin, bindtxid, deposittxid, destpub, amount)))); // yes, 't' is passed twice } } CCerror = strprintf("cant find enough inputs or mismatched total"); @@ -966,39 +981,67 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; - uint256 assetid,hashBlock,oracletxid; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; + CTransaction tx; + CPubKey mypk, gatewayspk; + uint256 tokenid,hashBlock,oracletxid; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; - cp = CCinit(&C,EVAL_GATEWAYS); + struct CCcontract_info *cpGateways, gatewaysC; + struct CCcontract_info *cpTokens, tokensC; + + cpGateways = CCinit(&gatewaysC, EVAL_GATEWAYS); + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + if ( txfee == 0 ) txfee = 10000; + mypk = pubkey2pk(Mypubkey()); - gatewayspk = GetUnspendable(cp,0); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + gatewayspk = GetUnspendable(cpGateways, 0); + + if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,coin,assetid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) + if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) { fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); return(""); } - if ( AddNormalinputs(mtx,mypk,3*txfee,4) > 0 ) + if( AddNormalinputs(mtx, mypk, 3*txfee, 4) > 0 ) { - if ( (inputs= AddGatewaysInputs(cp,mtx,mypk,assetid,amount,60)) > 0 ) + /////if ( (inputs= AddGatewaysInputs(cp,mtx,mypk,tokenid,amount,60)) > 0 ) + if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, tokenid, amount, 60)) > 0) { if ( inputs > amount ) CCchange = (inputs - amount); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,amount,gatewayspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, amount, gatewayspk)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG)); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS, txfee, gatewayspk)); if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CCchange,mypk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysWithdrawOpRet('W',assetid,refcoin,withdrawpub,amount))); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); + + char unspendableGatewaysAddr[64]; + GetCCaddress(cpGateways, unspendableGatewaysAddr, gatewayspk); + + uint8_t unspendableGatewaysPrivkey[32]; + GetUnspendable(cpGateways, unspendableGatewaysPrivkey); + + // add additional unspendable addr from Gateways: + CCaddr2set(cpTokens, EVAL_GATEWAYS, gatewayspk, unspendableGatewaysPrivkey, unspendableGatewaysAddr); + + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(gatewayspk); // the pubkey where tokens are going vout[0] (and for checking the 'change' the Tokens contract will find pubkeys itself) + + return(FinalizeCCTx(0, cpTokens, mtx, mypk, txfee, + EncodeTokenOpRet('t', EVAL_GATEWAYS, tokenid, voutTokenPubkeys, + EncodeGatewaysWithdrawOpRet('W', refcoin, withdrawpub, amount)))); } + CCerror = strprintf("cant find enough token inputs or mismatched total"); + fprintf(stderr, "%s\n", CCerror.c_str()); + return(""); + } - CCerror = strprintf("cant find enough inputs or mismatched total"); + CCerror = strprintf("cant find enough normal inputs or mismatched total"); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } @@ -1073,7 +1116,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string tmprefcoin; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; - uint256 hashBlock,assetid,txid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; + uint256 hashBlock,tokenid,txid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; char depositaddr[64],coinaddr[64],destaddr[64],str[65],withaddr[64],numstr[32],txidaddr[64],cctxidaddr[64],signeraddr[64]; int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; std::vector > unspentOutputs; @@ -1087,7 +1130,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(result); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tmprefcoin,assetid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || tmprefcoin != refcoin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || tmprefcoin != refcoin ) { fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),tmprefcoin.c_str()); return(result); @@ -1108,7 +1151,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) nValue = (int64_t)it->second.satoshis; fprintf(stderr,"%s %d %ld\n",txid.ToString().c_str(),vout,(long)nValue); if ( vout == 2 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && - DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,assetid,tmprefcoin,withdrawpub,amount) == 'W' && myIsutxo_spentinmempool(txid,vout) == 0) + DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,withdrawpub,amount) == 'W' && myIsutxo_spentinmempool(txid,vout) == 0) { Getscriptaddress(destaddr,tx.vout[0].scriptPubKey); Getscriptaddress(withaddr,tx.vout[1].scriptPubKey); @@ -1141,7 +1184,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string tmprefcoin,hex; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; - uint256 withdrawtxid,hashBlock,txid,assetid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; + uint256 withdrawtxid,hashBlock,txid,tokenid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; char depositaddr[64],coinaddr[64],str[65],numstr[32],txidaddr[64],cctxidaddr[64],withaddr[64]; int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; std::vector > unspentOutputs; @@ -1155,7 +1198,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(result); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tmprefcoin,assetid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || tmprefcoin != refcoin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || tmprefcoin != refcoin ) { fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),tmprefcoin.c_str()); return(result); @@ -1178,7 +1221,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,tmprefcoin,withdrawtxid,hex) == 'C' && myIsutxo_spentinmempool(txid,vout) == 0) { - if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,assetid,tmprefcoin,withdrawpub,amount) == 'W') + if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,withdrawpub,amount) == 'W') { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid",uint256_str(str,txid))); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 7d5ea7cfe..fe93e7a5a 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -690,7 +690,7 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, if ((inputs=Helper::addOwnerInputs(cp, tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners //mtx.vout.push_back(MakeCC1vout(EVAL_HEIR,amount,HeirCCpk)); - mtx.vout.push_back(MakeCC1of2vout(Helper::getMyEval(), amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk + mtx.vout.push_back(MakeTokensCC1of2vout(/*Helper::getMyEval()*/EVAL_HEIR, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk // add a marker for finding all plans in HeirList() CPubKey HeirContractPubKey = GetUnspendable(cp, 0); From 53b30074c22beab4b229884ef558844122ec32ef Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 14:00:29 +0500 Subject: [PATCH 1152/3904] corrected vpayload serialisation to opret --- src/cc/CCtokens.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 62fb1fa78..8e4dc17ca 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -62,11 +62,14 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t tokenid = revuint256(tokenid); //uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l'; + std::vector vpayload; + GetOpReturnData(payload, vpayload); + //opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ if(ccType >= 1) ss << voutPubkeys[0]; \ if(ccType == 2) ss << voutPubkeys[1]; \ - if(payload.size() > 0) ss << payload); + if(payload.size() > 0) ss << vpayload); return(opret); } From 00968fd9cbc3353523ed909df5615014bb99760e Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 14:45:39 +0500 Subject: [PATCH 1153/3904] destaddr logging added --- src/cc/CCtx.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index ec0a24b3f..30c4c1e62 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -131,6 +131,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); + std::cerr << "FinalizeCCtx() destaddr=" << destaddr << " myaddr=" << myaddr << std::endl; if ( strcmp(destaddr,myaddr) == 0 ) { privkey = myprivkey; From c2942d60a487571a6d9c6a1d0a52d72e48fe84b4 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 15:23:07 +0500 Subject: [PATCH 1154/3904] Tokens CC cond test code added to HeirClaim TokenValidate --- src/cc/CCinclude.h | 2 ++ src/cc/CCtokens.cpp | 2 +- src/cc/CCutils.cpp | 14 +++++++++++++- src/cc/heir.cpp | 6 +++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 3e70ba380..2ebba82f7 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -189,6 +189,8 @@ void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *c CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2); +bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); +void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); bool IsCCInput(CScript const& scriptSig); int32_t unstringbits(char *buf,uint64_t bits); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 8e4dc17ca..362529a53 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -337,7 +337,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c if (voutPubkeys.size() == 1) testVout = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]); else // voutPubkeys.size() == 2 - testVout = MakeCC1of2vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); + testVout = MakeTokensCC1of2vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index c07755c2a..f677127a6 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -237,7 +237,7 @@ void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *c } // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 tokens cryptocondition vout: -void CCaddr1of2setTokens(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) { cp->tokens1of2pk[0] = pk1; cp->tokens1of2pk[1] = pk2; @@ -348,6 +348,18 @@ bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubK return(destaddr[0] != 0); } +bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2) +{ + CC *payoutCond; + destaddr[0] = 0; + if ((payoutCond = MakeTokensCCcond1of2(cp->evalcode, pk, pk2)) != 0) + { + Getscriptaddress(destaddr, CCPubKey(payoutCond)); + cc_free(payoutCond); + } + return(destaddr[0] != 0); +} + bool ConstrainVout(CTxOut vout, int32_t CCflag, char *cmpaddr, int64_t nValue) { char destaddr[64]; diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index fe93e7a5a..1d776a865 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -578,7 +578,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, std::vector> unspentOutputs; char coinaddr[64]; - GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 pubkey of 2 pubkeys' + GetTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 pubkey of 2 pubkeys' SetCCunspents(unspentOutputs, coinaddr); // char markeraddr[64]; @@ -930,7 +930,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee uint8_t myprivkey[32]; char coinaddr[64]; // set priv key addresses in CC structure: - GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + GetTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); Myprivkey(myprivkey); ////fprintf(stderr,"HeirClaim() before setting unspendable CC addr2= (%s) addr3= (%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); @@ -938,7 +938,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee //CCaddr3set(cp, Helper::getMyEval(), heirPubkey, myprivkey, coinaddr); ////fprintf(stderr, "HeirClaim() after setting unspendable CC addr2=(%s) addr3=(%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); - CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); // add 1of2 vout validation pubkeys: std::vector voutTokenPubkeys; From aa7c48f529c5154fbc6ecaba1cda140fb100e005 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 15:35:09 +0500 Subject: [PATCH 1155/3904] corrected EVAL_HEIR (test) in IsTokenVout --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 362529a53..644e9d414 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -337,7 +337,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c if (voutPubkeys.size() == 1) testVout = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]); else // voutPubkeys.size() == 2 - testVout = MakeTokensCC1of2vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); + testVout = MakeTokensCC1of2vout(EVAL_HEIR, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; From 732144ebb8078179fc8888d21591dfe63ab8729c Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 15:50:55 +0500 Subject: [PATCH 1156/3904] turn off HeirValidate temp --- src/cc/heir.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 1d776a865..fcea30f58 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -160,6 +160,9 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction std::cerr << "HeirValidate funcid=" << (char)funcId << std::endl; + //////////////// temp //////////////////////// + return true; + switch (funcId) { case 'F': // fund coins: From 37105d851ab083ab430674e16db64f0f8220c616 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 16:06:00 +0500 Subject: [PATCH 1157/3904] added logging in Add1of2addrinputs in heir --- src/cc/heir.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index fcea30f58..30143a2cf 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -587,7 +587,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, // char markeraddr[64]; // CCtxidaddr(markeraddr, fundingtxid); // SetCCunspents(unspentOutputs, markeraddr); - // std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << std::endl; + std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << std::endl; for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { uint256 txid = it->first.txhash; @@ -595,6 +595,9 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, int32_t voutIndex = (int32_t)it->first.index; // no need to prevent dup // dimxy: maybe it is good to put tx's in cache? + + std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl; + if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { uint256 tokenid; uint256 fundingTxidInOpret; @@ -608,7 +611,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, (voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && !myIsutxo_spentinmempool(txid, voutIndex)) { - //std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; + std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, voutIndex, CScript())); nValue = it->second.satoshis; From 092b4c987ab6c8deebd5a6af41ad2d001a777d66 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 16:12:09 +0500 Subject: [PATCH 1158/3904] eval_heir corrected temp in HeirClaim --- src/cc/heir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 30143a2cf..22268279b 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -864,7 +864,8 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee uint8_t hasHeirSpendingBegun = 0; - cp = CCinit(&C, Helper::getMyEval()); + //cp = CCinit(&C, Helper::getMyEval()); + cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) txfee = 10000; From 0177628e7dca790f24da6f3692e067dd96a62d5b Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 16:19:48 +0500 Subject: [PATCH 1159/3904] GetTokensCCaddress1of2 call corrected (test) in IsHeirFundingVout --- src/cc/heir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 22268279b..57d7c6a79 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -252,7 +252,7 @@ int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, in { char destaddr[65], heirFundingAddr[65]; - GetCCaddress1of2(cp, heirFundingAddr, ownerPubkey, heirPubkey); + GetTokensCCaddress1of2(cp, heirFundingAddr, ownerPubkey, heirPubkey); if (tx.vout[voutIndex].scriptPubKey.IsPayToCryptoCondition() != 0) { // NOTE: dimxy it was unsafe 'Getscriptaddress(destaddr,tx.vout[voutIndex].scriptPubKey) > 0' here: if (Getscriptaddress(destaddr, tx.vout[voutIndex].scriptPubKey) && strcmp(destaddr, heirFundingAddr) == 0) From d67ca1779af0e5446cab6ca978d126b4f793e1c5 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 21:28:13 +0500 Subject: [PATCH 1160/3904] MakeTokensCCcond1of2 corrrected and simplified --- src/cc/CCtokens.cpp | 2 +- src/cc/CCutils.cpp | 16 +++------------- src/cc/heir.cpp | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 644e9d414..0829623e6 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -173,7 +173,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); - fprintf(stderr, "TokensValidate (%c)\n", funcid); + fprintf(stderr, "TokensValidate (%c) evalcode=0x%0x\n", funcid, cp->evalcode); if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index f677127a6..93c82945e 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -83,21 +83,11 @@ CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2) pks.push_back(CCNewSecp256k1(pk1)); pks.push_back(CCNewSecp256k1(pk2)); CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); // this is eval cc + CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval token cc CC *cond1of2Sig = CCNewThreshold(1, pks); // this is 1 of 2 sigs cc - CC *cond1of2Threshold = CCNewThreshold(2, { condEvalCC, cond1of2Sig }); + CC *cond1of2Threshold = CCNewThreshold(3, { condEvalCC, condEvalTokensCC, cond1of2Sig }); - // make token cond - struct CCcontract_info *cpTokens, tokensC; - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); - - std::vector pksTokens; - pks.push_back(CCNewSecp256k1(unspendableTokensPk)); - CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval cc - CC *condUnspendableSig = CCNewThreshold(1, pksTokens); // this is 1 of 2 sigs cc - CC *condTopThreshold = CCNewThreshold(2, { condEvalTokensCC, condUnspendableSig }); - - return CCNewThreshold(2, { cond1of2Threshold, condTopThreshold }); + return cond1of2Threshold; } CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 57d7c6a79..9bb3f7f93 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -158,7 +158,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction fundingTxOpRetScript = tx.vout[numvouts - 1].scriptPubKey; } - std::cerr << "HeirValidate funcid=" << (char)funcId << std::endl; + std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << cpHeir->evalcode << std::endl; //////////////// temp //////////////////////// return true; From 805b3da0501341585d06c83fc94d1011023462fe Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 10 Jan 2019 21:42:10 +0500 Subject: [PATCH 1161/3904] heir evalcode logging added --- src/cc/heir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 9bb3f7f93..73d8b49aa 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -158,7 +158,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction fundingTxOpRetScript = tx.vout[numvouts - 1].scriptPubKey; } - std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << cpHeir->evalcode << std::endl; + std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << (int)cpHeir->evalcode << std::endl; //////////////// temp //////////////////////// return true; From 6d509d52931a155992c06711ac93f25350314a4a Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 11 Jan 2019 14:34:56 +0500 Subject: [PATCH 1162/3904] added MakeTokensCCcond1 and MakeTokensCCvout1 --- src/cc/CCinclude.h | 2 + src/cc/CCtokens.cpp | 102 +++++++++++++++++++++++++------------------- src/cc/CCutils.cpp | 19 +++++++++ src/cc/heir.cpp | 2 +- 4 files changed, 81 insertions(+), 44 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 2ebba82f7..0dc7f446d 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -188,7 +188,9 @@ void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t * void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); +CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2); +CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk); bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 0829623e6..2f9a50a93 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -239,23 +239,63 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & // return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); } +// helper funcs: +// extract my vins pubkeys: +bool ExtractVinPubkeys(struct CCcontract_info *cp, CTransaction tx, std::vector &vinPubkeys) { + + bool found = false; + CPubKey pubkey; + + for (int32_t i = 0; i < tx.vin.size(); i++) + { // check for additional contracts which may send tokens to the Tokens contract + if( (*cp->ismyvin)(tx.vin[i].scriptSig) ) + { + + auto findEval = [](CC *cond, struct CCVisitor _) { + bool r = false; //cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == EVAL_TOKENS; + + if (cc_typeId(cond) == CC_Secp256k1) { + *(CPubKey*)_.context = buf2pk(cond->publicKey); + //std::cerr << "findEval found pubkey=" << HexStr(*(CPubKey*)_.context) << std::endl; + r = true; + } + // false for a match, true for continue + return r ? 0 : 1; + }; + + CC *cond = GetCryptoCondition(tx.vin[i].scriptSig); + + if (cond) { + CCVisitor visitor = { findEval, (uint8_t*)"", 0, &pubkey }; + bool out = !cc_visit(cond, visitor); + cc_free(cond); + + if (pubkey.IsValid()) { + vinPubkeys.push_back(pubkey); + found = true; + } + } + } + } + return found; +} // this is just for log messages indentation fur debugging recursive calls: thread_local uint32_t tokenValIndentSize = 0; // validates opret for token tx: -bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { +bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, uint8_t &evalCodeInOpret, std::vector &voutPubkeys, std::vector &vopretExtra) { uint256 tokenidOpret, tokenidOpret2; - uint8_t funcid, evalCode; + uint8_t funcid; // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); int32_t n = tx.vout.size(); - if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, tokenidOpret, voutPubkeys, vopretExtra)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCodeInOpret, tokenidOpret, voutPubkeys, vopretExtra)) == 0) { std::cerr << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl; return(false); @@ -324,20 +364,20 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; - const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); + uint8_t evalCodeInOpret = 0; + const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, evalCodeInOpret, voutPubkeys, vopretExtra); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (valOpret) { //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned true" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - if (checkPubkeys) { - // verify that the vout is within EVAL_TOKENS: + if (checkPubkeys) { // verify that the vout is within EVAL_TOKENS: if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { CTxOut testVout; if (voutPubkeys.size() == 1) - testVout = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]); + testVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0]); else // voutPubkeys.size() == 2 - testVout = MakeTokensCC1of2vout(EVAL_HEIR, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); + testVout = MakeTokensCC1of2vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; @@ -345,9 +385,9 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c } } - // maybe it is change? + // maybe it is token change? for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { - CTxOut testVout = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it); + CTxOut testVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, *it); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; @@ -371,7 +411,6 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t { CTransaction vinTx; uint256 hashBlock, id, id2; int32_t flag; int64_t tokenoshis; std::vector tmporigpubkey; int64_t tmpprice; std::vector vinPubkeys, vinPubkeysEmpty; - CPubKey pubkey; int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); @@ -380,37 +419,12 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t // this is just for log messages indentation for debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); + ExtractVinPubkeys(cpTokens, tx, vinPubkeys); + for (int32_t i = 0; iismyvin)(tx.vin[i].scriptSig) /*|| IsVinAllowed(tx.vin[i].scriptSig) != 0*/) { - - // extract my vins pubkeys: - - auto findEval = [](CC *cond, struct CCVisitor _) { - bool r = false; //cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == EVAL_TOKENS; - - if (cc_typeId(cond) == CC_Secp256k1) { - *(CPubKey*)_.context = buf2pk(cond->publicKey); - //std::cerr << "findEval found pubkey=" << HexStr(*(CPubKey*)_.context) << std::endl; - r = true; - } - // false for a match, true for continue - return r ? 0 : 1; - }; - - CC *cond = GetCryptoCondition(tx.vin[i].scriptSig); - - if (cond) { - CCVisitor visitor = { findEval, (uint8_t*)"", 0, &pubkey }; - bool out = !cc_visit(cond, visitor); - cc_free(cond); - - if (pubkey.IsValid()) - vinPubkeys.push_back(pubkey); - } - - //std::cerr << indentStr << "TokensExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl; // we are not inside the validation code -- dimxy if ((eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) @@ -423,7 +437,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t tokenValIndentSize++; // validate vouts of vintx //std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; - tokenoshis = IsTokensvout(goDeeper, false/*<--do not have pubkeys for now*/, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeysEmpty); + tokenoshis = IsTokensvout(goDeeper, true, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeys); tokenValIndentSize--; if (tokenoshis != 0) { @@ -488,21 +502,23 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C break; if (j != mtx.vin.size()) continue; + if (GetTransaction(txid, vintx, hashBlock, false) != 0) { Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey); if (strcmp(destaddr, coinaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) continue; - //fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); + fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); - std::vector vinPubkeysEmpty; - if ((nValue = IsTokensvout(true, false/*<-- do not check spending outside EVAL_TOKENS for now */, cp, NULL, vopretExtra, vintx, vout, tokenid, vinPubkeysEmpty)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + std::vector vinPubkeys; + + if ((nValue = IsTokensvout(true, true/*<--add only checked uxtos */, cp, NULL, vopretExtra, vintx, vout, tokenid, vinPubkeys)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) { if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, vout, CScript())); nValue = it->second.satoshis; totalinputs += nValue; - //std::cerr << "AddTokenInputs() adding input nValue=" << nValue << std::endl; + std::cerr << "AddTokenInputs() adding input nValue=" << nValue << std::endl; n++; if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 93c82945e..82b74cc11 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -90,6 +90,16 @@ CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2) return cond1of2Threshold; } +CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk) +{ + std::vector pks; + pks.push_back(CCNewSecp256k1(pk)); + CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); + CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval token cc + CC *Sig = CCNewThreshold(1, pks); + return CCNewThreshold(3, { condEvalCC, condEvalTokensCC, Sig }); +} + CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2) { CTxOut vout; @@ -99,6 +109,15 @@ CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubK return(vout); } +CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk) +{ + CTxOut vout; + CC *payoutCond = MakeTokensCCcond1(evalcode, pk); + vout = CTxOut(nValue, CCPubKey(payoutCond)); + cc_free(payoutCond); + return(vout); +} + CC* GetCryptoCondition(CScript const& scriptSig) { auto pc = scriptSig.begin(); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 73d8b49aa..7d1d56006 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -161,7 +161,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << (int)cpHeir->evalcode << std::endl; //////////////// temp //////////////////////// - return true; + ///return true; switch (funcId) { case 'F': From c4c58b484ab83355debb181addf8cb04571f0a30 Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 11 Jan 2019 23:02:37 +0500 Subject: [PATCH 1163/3904] heir modified for two eval Tokens changed to new 2-opret format --- src/cc/CCinclude.h | 2 + src/cc/CCtokens.cpp | 43 ++++--- src/cc/CCtx.cpp | 22 +++- src/cc/CCutils.cpp | 25 ++++- src/cc/heir.cpp | 250 +++++++++++++++++++++++++---------------- src/cc/heir_validate.h | 159 +++++++++++++++++++------- 6 files changed, 342 insertions(+), 159 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 0dc7f446d..4b6b437b4 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -191,6 +191,8 @@ CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubK CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2); CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk); + +bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk); bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 2f9a50a93..0bd4dd991 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -201,10 +201,10 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & //vout.0: issuance tokenoshis to CC //vout.1: normal output for change (if any) //vout.n-1: opreturn EVAL_TOKENS 'c' - if (evalCodeInOpret != EVAL_TOKENS) - return eval->Invalid("unexpected TokenValidate for createtoken"); - else - return true; + //if (evalCodeInOpret != EVAL_TOKENS) + // return eval->Invalid("unexpected TokenValidate for createtoken"); + //else + return true; case 't': // transfer //vin.0: normal input @@ -225,15 +225,15 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & // forward validation if evalcode in opret is not EVAL_TOKENS // init for forwarding validation call - if (evalCodeInOpret != EVAL_TOKENS) { // TODO: should we check also only allowed for tokens evalcodes, like EVAL_ASSETS, EVAL_GATEWAYS? - struct CCcontract_info *cpOther = NULL, C; + //if (evalCodeInOpret != EVAL_TOKENS) { // TODO: should we check also only allowed for tokens evalcodes, like EVAL_ASSETS, EVAL_GATEWAYS? + // struct CCcontract_info *cpOther = NULL, C; - cpOther = CCinit(&C, evalCodeInOpret); - if (cpOther) - return cpOther->validate(cpOther, eval, tx, nIn); - else - return eval->Invalid("unsupported evalcode in opret"); - } + // cpOther = CCinit(&C, evalCodeInOpret); + // if (cpOther) + // return cpOther->validate(cpOther, eval, tx, nIn); + // else + // return eval->Invalid("unsupported evalcode in opret"); + //} return true; // what does this do? // return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); @@ -285,17 +285,18 @@ bool ExtractVinPubkeys(struct CCcontract_info *cp, CTransaction tx, std::vector< thread_local uint32_t tokenValIndentSize = 0; // validates opret for token tx: -bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, uint8_t &evalCodeInOpret, std::vector &voutPubkeys, std::vector &vopretExtra) { +bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { uint256 tokenidOpret, tokenidOpret2; uint8_t funcid; + uint8_t dummyEvalCode; // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); int32_t n = tx.vout.size(); - if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCodeInOpret, tokenidOpret, voutPubkeys, vopretExtra)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, dummyEvalCode, tokenidOpret, voutPubkeys, vopretExtra)) == 0) { std::cerr << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl; return(false); @@ -364,14 +365,24 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; - uint8_t evalCodeInOpret = 0; - const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, evalCodeInOpret, voutPubkeys, vopretExtra); + const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (valOpret) { //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned true" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (checkPubkeys) { // verify that the vout is within EVAL_TOKENS: + CScript contractScript = CScript(vopretExtra); + std::vector vcontractOpret; + + GetOpReturnData(contractScript, vcontractOpret); + if (vcontractOpret.size() == 0) { + std::cerr << "IsTokensvout() empty contract opret" << std::endl; + return 0; + } + + uint8_t evalCodeInOpret = vcontractOpret.begin()[0]; + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { CTxOut testVout; if (voutPubkeys.size() == 1) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 30c4c1e62..d85f59473 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -43,9 +43,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; - int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64]; + int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64],mytokensaddr[64]; uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond; + CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL; CPubKey unspendablepk; n = mtx.vout.size(); @@ -61,11 +61,17 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran return("0"); } Myprivkey(myprivkey); - unspendablepk = GetUnspendable(cp,unspendablepriv); + GetCCaddress(cp,myaddr,mypk); mycond = MakeCCcond1(cp->evalcode,mypk); + + GetTokensCCaddress(cp, myaddr, mypk); + mytokenscond = MakeTokensCCcond1(cp->evalcode, mypk); + + unspendablepk = GetUnspendable(cp,unspendablepriv); GetCCaddress(cp,unspendable,unspendablepk); - othercond = MakeCCcond1(cp->evalcode,unspendablepk); + othercond = MakeCCcond1(cp->evalcode,unspendablepk); + //Reorder vins so that for multiple normal vins all other except vin0 goes to the end //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. for (i=0; icoins1of2addr, destaddr) == 0) + else if (strcmp(cp->coins1of2addr, destaddr) == 0) { fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = myprivkey; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 82b74cc11..6d2d4a037 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -94,8 +94,8 @@ CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk) { std::vector pks; pks.push_back(CCNewSecp256k1(pk)); - CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); - CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval token cc + CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); // add eval cc + CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // add also eval token cc CC *Sig = CCNewThreshold(1, pks); return CCNewThreshold(3, { condEvalCC, condEvalTokensCC, Sig }); } @@ -345,6 +345,27 @@ bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk) return(_GetCCaddress(destaddr,cp->evalcode,pk)); } +bool _GetTokensCCaddress(char *destaddr, uint8_t evalcode, CPubKey pk) +{ + CC *payoutCond; + destaddr[0] = 0; + if ((payoutCond = MakeTokensCCcond1(evalcode, pk)) != 0) + { + Getscriptaddress(destaddr, CCPubKey(payoutCond)); + cc_free(payoutCond); + } + return(destaddr[0] != 0); +} + +bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk) +{ + destaddr[0] = 0; + if (pk.size() == 0) + pk = GetUnspendable(cp, 0); + return(_GetTokensCCaddress(destaddr, cp->evalcode, pk)); +} + + bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubKey pk2) { CC *payoutCond; diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 7d1d56006..784e0a88c 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -122,23 +122,27 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction //if (chainActive.Height() < 741) // return true; - uint8_t funcId; uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenid = zeroid; CScript fundingTxOpRetScript; uint8_t hasHeirSpendingBegun = 0, dummyHasHeirSpendingBegun; - int32_t heirType = NOT_HEIR; - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); - if(funcId != 0) - heirType = HEIR_COINS; - else { - funcId = DecodeHeirOpRet(tx.vout[numvouts - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, false); - if (funcId != 0) - heirType = HEIR_TOKENS; + + uint8_t evalCodeTokens = 0; + std::vector voutPubkeys; + std::vector vopretExtra; + + CScript heirScript = tx.vout[tx.vout.size() - 1].scriptPubKey; + int32_t heirType = HEIR_COINS; + + uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); + if (funcId != 0) { + heirScript = CScript(vopretExtra); + heirType = HEIR_TOKENS; } + funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); - if (heirType == NOT_HEIR) + if (funcId == 0) return eval->Invalid("invalid opreturn format"); if (funcId != 'F') { @@ -248,11 +252,11 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction * Checks if vout is to cryptocondition address * @return vout value in satoshis */ -int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) +template int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) { char destaddr[65], heirFundingAddr[65]; - GetTokensCCaddress1of2(cp, heirFundingAddr, ownerPubkey, heirPubkey); + Helper::GetCoinsOrTokensCCaddress1of2(cp, heirFundingAddr, ownerPubkey, heirPubkey); if (tx.vout[voutIndex].scriptPubKey.IsPayToCryptoCondition() != 0) { // NOTE: dimxy it was unsafe 'Getscriptaddress(destaddr,tx.vout[voutIndex].scriptPubKey) > 0' here: if (Getscriptaddress(destaddr, tx.vout[voutIndex].scriptPubKey) && strcmp(destaddr, heirFundingAddr) == 0) @@ -317,6 +321,8 @@ CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpe fundingtxid = revuint256(fundingtxid); return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); } + +/* // makes opret for tokens while they are inside Heir contract address space - initial funding CScript EncodeHeirTokensCreateOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) { @@ -348,10 +354,11 @@ CScript EncodeHeirTokensOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun) { +/*uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun) { uint8_t heirFuncId = 0; hasHeirSpendingBegun = 0; @@ -363,70 +370,66 @@ uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, } \ }); - if (!result /*|| assetFuncId != 't' -- any tx is ok*/) + if (!result )// || assetFuncId != 't' -- any tx is ok) return (uint8_t)0; return heirFuncId; -} +}*/ + /** * decode opret vout for Heir contract */ -template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) +uint8_t _DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { - - std::vector vopretExtra; + std::vector vopret; uint8_t evalCodeInOpret = 0; - uint256 dummyTokenid; - std::vector voutPubkeysDummy; + uint8_t heirFuncId = 0; fundingTxidInOpret = zeroid; //to init - tokenid = zeroid; - - if (typeid(Helper) == typeid(TokenHelper)) { // if caller thinks it is a token - - // First - decode token opret: - uint8_t tokenFuncId = DecodeTokenOpRet(scriptPubKey, evalCodeInOpret, tokenid, voutPubkeysDummy, vopretExtra); - if (tokenFuncId == 0) { - if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: not heir token opret, tokenFuncId=" << (int)tokenFuncId << std::endl; - return (uint8_t)0; - } + GetOpReturnData(scriptPubKey, vopret); + if (vopret.size() == 0) { + if (!noLogging) std::cerr << "_DecodeHeirOpRet() warning: empty opret" << std::endl; + return (uint8_t)0; } - else { - std::vector vopret; - - GetOpReturnData(scriptPubKey, vopret); - if (vopret.size() == 0) { - if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; - return (uint8_t)0; - } - evalCodeInOpret = vopret.begin()[0]; - vopretExtra = std::vector( vopret.begin()+1, vopret.end() ); // vopretExtra = vopret + 1, get it for futher parsing - } - - if (vopretExtra.size() > 1 && evalCodeInOpret == EVAL_HEIR) { + evalCodeInOpret = vopret.begin()[0]; + + if (vopret.size() > 1 && evalCodeInOpret == EVAL_HEIR) { // NOTE: it unmarshals for all F, A and C - uint8_t heirFuncId = _UnmarshalOpret(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, hasHeirSpendingBegun); - - /*std::cerr << "DecodeHeirOpRet()" + uint8_t heirFuncId = 0; + hasHeirSpendingBegun = 0; + + bool result = E_UNMARSHAL(vopret, { ss >> evalCodeInOpret; ss >> heirFuncId; \ + if (heirFuncId == 'F') { \ + ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; \ + } \ + else { \ + ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ + } \ + }); + + if (!result) { + if (!noLogging) std::cerr << "_DecodeHeirOpRet() could not unmarshal opret, evalCode=" << (int)evalCodeInOpret << std::endl; + return (uint8_t)0; + } + + /* std::cerr << "DecodeHeirOpRet()" << " heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') << " ownerPubkey=" << HexStr(ownerPubkey) << " heirPubkey=" << HexStr(heirPubkey) << " heirName=" << heirName << " inactivityTime=" << inactivityTime - << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << std::endl;*/ + << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << std::endl; */ - - //if (e == EVAL_HEIR && IS_CHARINSTR(funcId, "FAC")) - if (Helper::isMyFuncId(heirFuncId)) { + if (isMyFuncId(heirFuncId)) { fundingTxidInOpret = revuint256(fundingTxidInOpret); return heirFuncId; } else { - if(!noLogging) std::cerr << "DecodeHeirOpRet() error: unexpected opret, heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') << std::endl; + if(!noLogging) std::cerr << "_DecodeHeirOpRet() unexpected opret type, heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') << std::endl; } } else { - if (!noLogging) std::cerr << "DecodeHeirOpRet() error: not a heir opret, vopretExtra.size() == 0 or not EVAL_HEIR evalcode=" << (int)evalCodeInOpret << std::endl; + if (!noLogging) std::cerr << "_DecodeHeirOpRet() not a heir opret, vopretExtra.size() == 0 or not EVAL_HEIR evalcode=" << (int)evalCodeInOpret << std::endl; } return (uint8_t)0; } @@ -434,24 +437,24 @@ template uint8_t _DecodeHeirOpRet(CScript scriptPubKey, uint256 & /** * overload for 'F' opret */ -template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) +uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { uint256 dummytxid; uint8_t dummyHasHeirSpendingBegun; - return _DecodeHeirOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); + return _DecodeHeirOpRet(scriptPubKey, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); } /** * overload for A, C oprets and AddHeirContractInputs */ -template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) +uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; std::string dummyHeirName; - return _DecodeHeirOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); + return _DecodeHeirOpRet(scriptPubKey, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); } @@ -476,9 +479,22 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { uint256 dummytxid; + uint8_t evalCodeTokens = 0; + std::vector vopretExtra; + std::vector dummyVoutPubkeys; - // set ownerPubkey and heirPubkey: - if ((funcId = DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName)) != 0) { + CScript heirScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; + if (typeid(Helper) == typeid(TokenHelper)) { + if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { + heirScript = CScript(vopretExtra); + } + else { + std::cerr << "FindLatestFundingTx() could not decode token opreturn for fundingtxid=" << fundingtxid.GetHex() << '\n'; + return zeroid; + } + } + funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName); + if (funcId != 0) { // found at least funding tx! //std::cerr << "FindLatestFundingTx() lasttx currently is fundingtx, txid=" << fundingtxid.GetHex() << " opreturn type=" << (char)funcId << '\n'; fundingOpretScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; @@ -493,7 +509,7 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ std::vector> unspentOutputs; struct CCcontract_info *cp, C; - cp = CCinit(&C, Helper::getMyEval()); + cp = CCinit(&C, EVAL_HEIR); char coinaddr[64]; GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' @@ -531,9 +547,23 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ uint8_t tmpFuncId; uint8_t tmphasHeirSpendingBegun; - if (regtx.vout.size() > 0 && - (tmpFuncId = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, dummyTokenid, fundingTxidInOpret, tmphasHeirSpendingBegun, true)) != 0 && - fundingtxid == fundingTxidInOpret) { + uint8_t evalCodeTokens = 0; + std::vector vopretExtra; + std::vector dummyVoutPubkeys; + + CScript heirScript = regtx.vout[regtx.vout.size() - 1].scriptPubKey; + if (typeid(Helper) == typeid(TokenHelper)) { + if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { + heirScript = CScript(vopretExtra); + } + else { + std::cerr << "FindLatestFundingTx() could not decode token opreturn for fundingtxid=" << fundingtxid.GetHex() << '\n'; + return zeroid; + } + } + tmpFuncId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, tmphasHeirSpendingBegun, true); + + if (regtx.vout.size() > 0 && tmpFuncId != 0 && fundingtxid == fundingTxidInOpret) { if (blockHeight > maxBlockHeight) { maxBlockHeight = blockHeight; @@ -581,12 +611,13 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, std::vector> unspentOutputs; char coinaddr[64]; - GetTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 pubkey of 2 pubkeys' + Helper::GetCoinsOrTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 of 2 pubkeys' SetCCunspents(unspentOutputs, coinaddr); // char markeraddr[64]; // CCtxidaddr(markeraddr, fundingtxid); // SetCCunspents(unspentOutputs, markeraddr); + std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << std::endl; for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { @@ -602,13 +633,22 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint256 tokenid; uint256 fundingTxidInOpret; uint8_t dummyHasHeirSpendingBegun; + uint8_t evalCodeTokens = 0; + std::vector vopretExtra; + std::vector voutPubkeys; - uint8_t funcId = DecodeHeirOpRet(heirtx.vout[heirtx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); + CScript heirScript = heirtx.vout[heirtx.vout.size() - 1].scriptPubKey; + uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); + if (funcId != 0) { + heirScript = CScript(vopretExtra); + } + funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); + if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && funcId != 0 && - Helper::isMyFuncId(funcId) && + isMyFuncId(funcId) && // (typeid(Helper) == typeid(TokenHelper) && IsHeirvout(true, cp, nullptr, tokenid, vintx, voutIndex) > 0) && // deep validation for tokens - not used anymore - (voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && + (voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && !myIsutxo_spentinmempool(txid, voutIndex)) { std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; @@ -631,7 +671,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, template int64_t LifetimeHeirContractFunds(struct CCcontract_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) { char coinaddr[64]; - GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' + Helper::GetCoinsOrTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' std::vector> addressIndexes; SetCCtxids(addressIndexes, coinaddr); @@ -644,17 +684,24 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info CTransaction tx; if (GetTransaction(txid, tx, hashBlock, false) && tx.vout.size() > 0) { - uint8_t funcId; + uint8_t evalCodeTokens = 0; uint256 tokenid; uint256 fundingTxidInOpret; - const int32_t ivout = 0; + std::vector vopretExtra; + std::vector voutPubkeys; uint8_t dummyHasHeirSpendingBegun; - - funcId = DecodeHeirOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, tokenid, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); + const int32_t ivout = 0; + + CScript heirScript = tx.vout[tx.vout.size() - 1].scriptPubKey; + uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); + if (funcId != 0) { + heirScript = CScript(vopretExtra); + } + funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); //std::cerr << "LifetimeHeirContractFunds() found tx=" << txid.GetHex() << " vout[0].nValue=" << subtx.vout[ccVoutIdx].nValue << " opreturn=" << (char)funcId << '\n'; - if (funcId != 0 && (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && Helper::isMyFuncId(funcId) && !Helper::isSpendingTx(funcId) + if (funcId != 0 && (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && isMyFuncId(funcId) && !isSpendingTx(funcId) /* && !myIsutxo_spentinmempool(txid, ccVoutIdx) */) // include also tx in mempool { total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) @@ -678,7 +725,7 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); struct CCcontract_info *cp, C; - cp = CCinit(&C, Helper::getMyEval()); + cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) txfee = 10000; @@ -719,7 +766,6 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, // add change for txfee and opreturn vouts and sign tx: return (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - // CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_HEIR << (uint8_t)'F' << myPubkey << heirPubkey << inactivityTimeSec << heirName))); Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName))); } else // TODO: need result return unification with heiradd and claim @@ -759,7 +805,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in uint8_t funcId; uint8_t hasHeirSpendingBegun = 0; - cp = CCinit(&C, Helper::getMyEval()); + cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) txfee = 10000; @@ -790,7 +836,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ // add cryptocondition to spend this funded amount for either pk - mtx.vout.push_back(MakeCC1of2vout(Helper::getMyEval(), amount, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! + mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! if (inputs > amount) change = (inputs - amount); // -txfee <-- txfee pays user @@ -801,7 +847,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } - // add 1of2 vout validation pubkeys: + // add 1of2 vout validation pubkeys - needed only for tokens: std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(ownerPubkey); voutTokenPubkeys.push_back(heirPubkey); @@ -863,8 +909,6 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee std::string heirName; uint8_t hasHeirSpendingBegun = 0; - - //cp = CCinit(&C, Helper::getMyEval()); cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) txfee = 10000; @@ -924,7 +968,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee // change to 1of2 funding addr: if (change != 0) { // vout[1] - mtx.vout.push_back(MakeCC1of2vout(Helper::getMyEval(), change, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! + mtx.vout.push_back(Helper::make1of2Vout(change, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! } // add marker vout: @@ -937,7 +981,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee uint8_t myprivkey[32]; char coinaddr[64]; // set priv key addresses in CC structure: - GetTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + Helper::GetCoinsOrTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); Myprivkey(myprivkey); ////fprintf(stderr,"HeirClaim() before setting unspendable CC addr2= (%s) addr3= (%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); @@ -945,9 +989,9 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee //CCaddr3set(cp, Helper::getMyEval(), heirPubkey, myprivkey, coinaddr); ////fprintf(stderr, "HeirClaim() after setting unspendable CC addr2=(%s) addr3=(%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); - CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); - // add 1of2 vout validation pubkeys: + // add 1of2 vout validation pubkeys (this is for tokens): std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(ownerPubkey); voutTokenPubkeys.push_back(heirPubkey); @@ -1017,15 +1061,22 @@ UniValue HeirInfo(uint256 fundingtxid) // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { - int32_t heirType = NOT_HEIR; const bool noLogging = true; + uint8_t evalCodeTokens = 0; + std::vector voutPubkeys; + std::vector vopretExtra; - if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging) == 'F') - heirType = HEIR_COINS; - else if (DecodeHeirOpRet(fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging) == 'F') + CScript heirScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; + int32_t heirType = HEIR_COINS; + + uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); + if (funcId != 0) { + heirScript = CScript(vopretExtra); heirType = HEIR_TOKENS; - else - { + } + funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); + + if( funcId == 0 ) { std::cerr << "HeirInfo() initial tx F not found for this fundingtx" << std::endl; result.push_back(Pair("result", "error")); result.push_back(Pair("error", "initial tx F not found")); @@ -1033,10 +1084,7 @@ UniValue HeirInfo(uint256 fundingtxid) } struct CCcontract_info *cp, C; - if (heirType == HEIR_COINS) - cp = CCinit(&C, CoinHelper::getMyEval()); - else - cp = CCinit(&C, TokenHelper::getMyEval()); + cp = CCinit(&C, EVAL_HEIR); uint8_t hasHeirSpendingBegun = 0; @@ -1174,14 +1222,24 @@ template void _HeirList(struct CCcontract_info *cp, UniValue &r //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; - CTransaction inittx; - if (GetTransaction(txid, inittx, hashBlock, false) != 0 && (inittx.vout.size() - 1) > 0) { + CTransaction fundingtx; + if (GetTransaction(txid, fundingtx, hashBlock, false) != 0 && (fundingtx.vout.size() - 1) > 0) { CPubKey ownerPubkey, heirPubkey; std::string heirName; int64_t inactivityTimeSec; const bool noLogging = true; - uint8_t funcId = DecodeHeirOpRet(inittx.vout[inittx.vout.size() - 1].scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); + uint8_t evalCodeTokens = 0; + uint256 tokenid; + std::vector vopretExtra; + std::vector voutPubkeys; + + CScript heirScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; + uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); + if (funcId != 0) { + heirScript = CScript(vopretExtra); + } + funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); // note: if it is not Heir token funcId would be equal to 0 if (funcId == 'F') { diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 5b5df2110..0094f5f4c 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -14,19 +14,21 @@ CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan); // makes token opret -CScript EncodeHeirTokensCreateOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName); -CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan); +//CScript EncodeHeirTokensCreateOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName); +//CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan); template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); -template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); -template uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); +uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); + +inline static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } +inline static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } + // helper class to allow polymorphic behaviour for HeirXXX() functions in case of coins class CoinHelper { public: - static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } - static uint8_t getMyEval() { return EVAL_HEIR; } static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); } @@ -40,43 +42,58 @@ public: static CScript makeClaimOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { return EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan); } - - static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } - + static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { + return MakeCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); + } static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } + static bool GetCoinsOrTokensCCaddress1of2(struct CCcontract_info* cp, char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { + return GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + } + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info* cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + } }; // helper class to allow polymorphic behaviour for HeirXXX() functions in case of tokens class TokenHelper { public: - static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } - static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddTokenCCInputs(cp, mtx, ownerPubkey, tokenid, total, maxinputs); } static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return EncodeHeirTokensCreateOpRet((uint8_t)'F', tokenid, voutTokenPubkeys, ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + return EncodeTokenOpRet((uint8_t)'t', EVAL_TOKENS, tokenid, voutTokenPubkeys, + EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName)); } static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeHeirTokensOpRet((uint8_t)'A', tokenid, voutTokenPubkeys, fundingtxid, isHeirSpendingBegan); + return EncodeTokenOpRet((uint8_t)'t', EVAL_TOKENS, tokenid, voutTokenPubkeys, + EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan)); } static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeHeirTokensOpRet((uint8_t)'C', tokenid, voutTokenPubkeys, fundingtxid, isHeirSpendingBegan); + return EncodeTokenOpRet((uint8_t)'t', EVAL_TOKENS, tokenid, voutTokenPubkeys, + EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan)); } - static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } - + static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { + return MakeTokensCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); + } static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { - return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); + return MakeTokensCC1vout(EVAL_HEIR, amount, myPubkey); } static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { - return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); + return MakeTokensCC1vout(EVAL_HEIR, amount, myPubkey); + } + static bool GetCoinsOrTokensCCaddress1of2(struct CCcontract_info* cp, char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { + return GetTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + } + + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info* cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } }; @@ -307,11 +324,8 @@ public: return eval->Invalid(stream.str().c_str()); // ... if not, return 'invalid' } } - ival++; // advance to the next vout - } - //std::cerr << "COutputValidationPlan::validate() returns with true" << std::endl; return true; } @@ -350,14 +364,12 @@ private: return true; // validation OK } - private: //std::map m_mapValidators; std::vector< std::pair > m_arrayValidators; }; - class CNormalInputIdentifier : CInputIdentifierBase { public: CNormalInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} @@ -390,13 +402,28 @@ public: virtual bool validateVout(CTxOut vout, std::string& message) const { //std::cerr << "CCC1of2AddressValidator::validateVout() entered" << std::endl; - uint8_t funcId; CPubKey ownerPubkey, heirPubkey; int64_t inactivityTime; std::string heirName; uint256 tokenid; + + uint8_t evalCodeTokens = 0; + std::vector vopretExtra; + std::vector dummyVoutPubkeys; - if ((funcId = DecodeHeirOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName)) == 0) { + CScript heirScript = m_fundingOpretScript; + if (typeid(Helper) == typeid(TokenHelper)) { + if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { + heirScript = CScript(vopretExtra); + } + else { + message = m_customMessage + std::string(" invalid token opreturn format"); + std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; + return false; + } + } + uint8_t funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, false); + if (funcId == 0) { message = m_customMessage + std::string(" invalid opreturn format"); std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; return false; @@ -443,21 +470,35 @@ public: { //std::cerr << "CMyPubkeyVoutValidator::validateVout() entered" << std::endl; - uint8_t funcId; CPubKey ownerPubkey, heirPubkey; int64_t inactivityTime; std::string heirName; uint256 tokenid; ///std::cerr << "CMyPubkeyVoutValidator::validateVout() m_opRetScript=" << m_opRetScript.ToString() << std::endl; + + uint8_t evalCodeTokens = 0; + std::vector vopretExtra; + std::vector dummyVoutPubkeys; + + CScript ownerScript; + CScript heirScript = m_fundingOpretScript; + if (typeid(Helper) == typeid(TokenHelper)) { + if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { + heirScript = CScript(vopretExtra); + } + else { + message = std::string("invalid token opreturn format"); + return false; + } + } // get both pubkeys: - if ((funcId = DecodeHeirOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName)) == 0) { + uint8_t funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, false); + if (funcId == 0) { message = std::string("invalid opreturn format"); return false; } - CScript ownerScript; - CScript heirScript; if (m_checkNormals) { ownerScript = CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; heirScript = CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; @@ -474,7 +515,6 @@ public: // this is vout to owner or heir addr: //std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with true" << std::endl; return true; - } std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with false (not the owner's or heir's addresses)" << std::endl; @@ -503,15 +543,28 @@ public: { //std::cerr << "CHeirSpendValidator::validateVout() entered" << std::endl; - uint8_t funcId; CPubKey ownerPubkey, heirPubkey; int64_t inactivityTime; std::string heirName; uint256 tokenid; + uint8_t evalCodeTokens = 0; + std::vector vopretExtra; + std::vector dummyVoutPubkeys; + + CScript heirScript = m_fundingOpretScript; + if (typeid(Helper) == typeid(TokenHelper)) { + if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { + heirScript = CScript(vopretExtra); + } else { + message = std::string("invalid token opreturn format"); + return false; + } + } // get heir pubkey: - if ((funcId = DecodeHeirOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, false)) == 0) { + uint8_t funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, false); + if (funcId == 0) { message = std::string("invalid opreturn format"); return false; } @@ -560,28 +613,54 @@ public: { //std::cerr << "COpRetValidator::validateVout() entered" << std::endl; - uint8_t funcId, initialFuncId; // do not check heir name - uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid, initialTokenid; + uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; uint8_t dummyIsHeirSpendingBegan; - if ((funcId = DecodeHeirOpRet(vout.scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan)) == 0) { + uint8_t evalCodeTokens = 0; + std::vector vopretExtra; + std::vector dummyVoutPubkeys; + + CScript heirScript = vout.scriptPubKey; + if (typeid(Helper) == typeid(TokenHelper)) { + if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { + heirScript = CScript(vopretExtra); + } else { + message = std::string("invalid token opreturn format"); + return false; + } + } + uint8_t funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyIsHeirSpendingBegan); + if (funcId == 0) { message = std::string("invalid opreturn format"); return false; } - if ((initialFuncId = DecodeHeirOpRet(m_fundingOpretScript, initialTokenid, dummyTxid, dummyIsHeirSpendingBegan)) == 0) { + + heirScript = m_fundingOpretScript; + if (typeid(Helper) == typeid(TokenHelper)) { + if (DecodeTokenOpRet(heirScript, evalCodeTokens, initialTokenid, dummyVoutPubkeys, vopretExtra) != 0) { + heirScript = CScript(vopretExtra); + } else { + message = std::string("invalid initial token opreturn format"); + return false; + } + } + uint8_t initialFuncId = DecodeHeirOpRet(heirScript, dummyTxid, dummyIsHeirSpendingBegan); + if (initialFuncId == 0) { message = std::string("invalid initial tx opreturn format"); return false; } // validation rules: - if (!Helper::isMyFuncId(funcId)) { + if (!isMyFuncId(funcId)) { message = std::string("invalid funcid in opret"); return false; } - if(tokenid != initialTokenid ) { - message = std::string("invalid tokenid in opret"); - return false; + if (typeid(Helper) == typeid(TokenHelper)) { + if (tokenid != initialTokenid) { + message = std::string("invalid tokenid in opret"); + return false; + } } std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; From 6065a6dec46de16b29b271932e1b482cc56eef76 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 01:06:24 +0500 Subject: [PATCH 1164/3904] corrected -> no token vout pubkey validation for 'c' modified MakeTokenCCcond1 and 1of2 to eliminate duplicate evals --- src/cc/CCtokens.cpp | 22 +++++++++++----------- src/cc/CCutils.cpp | 24 +++++++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 0bd4dd991..5c848b081 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -285,7 +285,7 @@ bool ExtractVinPubkeys(struct CCcontract_info *cp, CTransaction tx, std::vector< thread_local uint32_t tokenValIndentSize = 0; // validates opret for token tx: -bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { +uint8_t ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { uint256 tokenidOpret, tokenidOpret2; uint8_t funcid; @@ -305,7 +305,7 @@ bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector { if (tokenid != zeroid && tokenid == tx.GetHash() && v == 0) { //std::cerr << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; - return(true); + return funcid; } } else if (funcid == 't') @@ -313,18 +313,18 @@ bool ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector //std::cerr << indentStr << "ValidateTokenOpret() tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; if (tokenid != zeroid && tokenid == tokenidOpret) { //std::cerr << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; - return(true); + return funcid; } } //std::cerr << indentStr << "ValidateTokenOpret() return false funcid=" << (char)funcid << " tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; - return false; + return (uint8_t)0; } - - // Checks if the vout is a really Tokens CC vout -// compareTotals == true, the func also validates the passed transaction itself: +// also checks tokenid in opret or txid if this is 'c' tx +// goDeeper is true: the func also validates amounts of the passed transaction: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx +// checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true! int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &vopretExtra, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys) { @@ -365,12 +365,12 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; - const bool valOpret = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); + const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - if (valOpret) { + if (funcId != 0) { //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned true" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - if (checkPubkeys) { // verify that the vout is within EVAL_TOKENS: + if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!): CScript contractScript = CScript(vopretExtra); std::vector vcontractOpret; @@ -605,7 +605,7 @@ std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector d if (inputs > total) CCchange = (inputs - total); //for (i=0; i pks; pks.push_back(CCNewSecp256k1(pk1)); pks.push_back(CCNewSecp256k1(pk2)); - CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); // this is eval cc - CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval token cc - CC *cond1of2Sig = CCNewThreshold(1, pks); // this is 1 of 2 sigs cc - CC *cond1of2Threshold = CCNewThreshold(3, { condEvalCC, condEvalTokensCC, cond1of2Sig }); - return cond1of2Threshold; + std::vector thresholds; + thresholds.push_back( CCNewEval(E_MARSHAL(ss << evalcode)) ); + if( evalcode != EVAL_TOKENS ) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1of2()! + thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc + thresholds.push_back(CCNewThreshold(1, pks)); // this is 1 of 2 sigs cc + + return CCNewThreshold(thresholds.size(), thresholds); } CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk) { std::vector pks; pks.push_back(CCNewSecp256k1(pk)); - CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); // add eval cc - CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // add also eval token cc - CC *Sig = CCNewThreshold(1, pks); - return CCNewThreshold(3, { condEvalCC, condEvalTokensCC, Sig }); + + std::vector thresholds; + thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode))); + if (evalcode != EVAL_TOKENS) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1()! + thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc + thresholds.push_back(CCNewThreshold(1, pks)); // signature + + return CCNewThreshold(thresholds.size(), thresholds); } CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2) From 0a76f9d8972b3a33eac9c0600c093982b85420f1 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 15:20:55 +0500 Subject: [PATCH 1165/3904] AssetXXX() changed to GetTokenBalance, TokenInfo, TokenList added processing of incorrect tokenid to GetTokenBalance --- src/cc/CCassets.h | 6 ++-- src/cc/CCassetstx.cpp | 57 --------------------------------- src/cc/CCtokens.cpp | 68 ++++++++++++++++++++++++++++++++++++++++ src/cc/CCtokens.h | 4 +++ src/wallet/rpcwallet.cpp | 29 ++++++++++++----- 5 files changed, 96 insertions(+), 68 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 5a5ef2c82..39644efc6 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -47,12 +47,12 @@ int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpp bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); // CCassetstx -int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); +//int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance() int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); UniValue AssetOrders(uint256 tokenid); -UniValue AssetInfo(uint256 tokenid); -UniValue AssetList(); +//UniValue AssetInfo(uint256 tokenid); +//UniValue AssetList(); //std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); //std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total); //std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 1c2012534..3047876f4 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -66,63 +66,6 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK } -int64_t GetAssetBalance(CPubKey pk,uint256 tokenid) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_TOKENS); - return(AddTokenCCInputs(cp,mtx,pk,tokenid,0,0)); -} - -UniValue AssetInfo(uint256 assetid) -{ - UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; std::vector origpubkey; std::string name,description; char str[67],numstr[65]; - if ( GetTransaction(assetid,vintx,hashBlock,false) == 0 ) - { - fprintf(stderr,"cant find assetid\n"); - result.push_back(Pair("result","error")); - result.push_back(Pair("error","cant find assetid")); - return(result); - } - if ( vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) == 0 ) - { - fprintf(stderr,"assetid isnt token creation txid\n"); - result.push_back(Pair("result","error")); - result.push_back(Pair("error","assetid isnt token creation txid")); - } - result.push_back(Pair("result","success")); - result.push_back(Pair("tokenid",uint256_str(str,assetid))); - result.push_back(Pair("owner",pubkey33_str(str,origpubkey.data()))); - result.push_back(Pair("name",name)); - result.push_back(Pair("supply",vintx.vout[0].nValue)); - result.push_back(Pair("description",description)); - return(result); -} - -UniValue AssetList() -{ - UniValue result(UniValue::VARR); - std::vector > addressIndex; - struct CCcontract_info *cp,C; uint256 txid,hashBlock; - CTransaction vintx; std::vector origpubkey; - std::string name,description; char str[65]; - - cp = CCinit(&C,EVAL_TOKENS); - SetCCtxids(addressIndex,cp->normaladdr); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - { - txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) - { - if ( vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) != 0 ) - { - result.push_back(uint256_str(str,txid)); - } - } - } - return(result); -} - UniValue AssetOrders(uint256 refassetid) { static uint256 zero; diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 5c848b081..613d4452f 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -623,4 +623,72 @@ std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector d fprintf(stderr, "not enough normal inputs for txfee\n"); } return(""); +} + + +int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) +{ + uint256 hashBlock; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction tokentx; + + if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) + { + fprintf(stderr, "cant find tokenid\n"); + CCerror = strprintf("cant find tokenid"); + return 0; + } + + struct CCcontract_info *cp, C; + cp = CCinit(&C, EVAL_TOKENS); + return(AddTokenCCInputs(cp, mtx, pk, tokenid, 0, 0)); +} + +UniValue TokenInfo(uint256 tokenid) +{ + UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; std::vector origpubkey; std::string name, description; char str[67], numstr[65]; + if (GetTransaction(tokenid, vintx, hashBlock, false) == 0) + { + fprintf(stderr, "cant find assetid\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "cant find tokenid")); + return(result); + } + if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) == 0) + { + fprintf(stderr, "assetid isnt token creation txid\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "assetid isnt token creation txid")); + } + result.push_back(Pair("result", "success")); + result.push_back(Pair("tokenid", uint256_str(str, tokenid))); + result.push_back(Pair("owner", pubkey33_str(str, origpubkey.data()))); + result.push_back(Pair("name", name)); + result.push_back(Pair("supply", vintx.vout[0].nValue)); + result.push_back(Pair("description", description)); + return(result); +} + +UniValue TokenList() +{ + UniValue result(UniValue::VARR); + std::vector > addressIndex; + struct CCcontract_info *cp, C; uint256 txid, hashBlock; + CTransaction vintx; std::vector origpubkey; + std::string name, description; char str[65]; + + cp = CCinit(&C, EVAL_TOKENS); + SetCCtxids(addressIndex, cp->normaladdr); + for (std::vector >::const_iterator it = addressIndex.begin(); it != addressIndex.end(); it++) + { + txid = it->first.txhash; + if (GetTransaction(txid, vintx, hashBlock, false) != 0) + { + if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) != 0) + { + result.push_back(uint256_str(str, txid)); + } + } + } + return(result); } \ No newline at end of file diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index 34223bc0b..e7bb62101 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -32,6 +32,10 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); +int64_t GetTokenBalance(CPubKey pk, uint256 tokenid); +UniValue TokenInfo(uint256 tokenid); +UniValue TokenList(); + //this is in CCinclude.h int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); //this is in CCinclude.h uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b39a19668..2cf195661 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6947,7 +6947,7 @@ UniValue tokenlist(const UniValue& params, bool fHelp) throw runtime_error("tokenlist\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - return(AssetList()); + return(TokenList()); } UniValue tokeninfo(const UniValue& params, bool fHelp) @@ -6958,7 +6958,7 @@ UniValue tokeninfo(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); tokenid = Parseuint256((char *)params[0].get_str().c_str()); - return(AssetInfo(tokenid)); + return(TokenInfo(tokenid)); } UniValue tokenorders(const UniValue& params, bool fHelp) @@ -6977,22 +6977,35 @@ UniValue tokenorders(const UniValue& params, bool fHelp) UniValue tokenbalance(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); char destaddr[64]; uint256 tokenid; uint64_t balance; std::vector pubkey; struct CCcontract_info *cp,C; + CCerror.clear(); + cp = CCinit(&C,EVAL_ASSETS); if ( fHelp || params.size() > 2 ) throw runtime_error("tokenbalance tokenid [pubkey]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - LOCK(cs_main); + + LOCK(cs_main); + tokenid = Parseuint256((char *)params[0].get_str().c_str()); if ( params.size() == 2 ) pubkey = ParseHex(params[1].get_str().c_str()); - else pubkey = Mypubkey(); + else + pubkey = Mypubkey(); result.push_back(Pair("result", "success")); - if ( GetCCaddress(cp,destaddr,pubkey2pk(pubkey)) != 0 ) + if (GetCCaddress(cp,destaddr,pubkey2pk(pubkey)) != 0) result.push_back(Pair("CCaddress",destaddr)); - balance = GetAssetBalance(pubkey2pk(pubkey),tokenid); - result.push_back(Pair("tokenid", params[0].get_str())); - result.push_back(Pair("balance", (int64_t)balance)); + + balance = GetTokenBalance(pubkey2pk(pubkey),tokenid); + + if (CCerror.empty()) { + result.push_back(Pair("tokenid", params[0].get_str())); + result.push_back(Pair("balance", (int64_t)balance)); + } + else { + ERR_RESULT(CCerror); + } + return(result); } From 15c71c69f1bb0351992a983cb0aa770ee2361f71 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 15:30:21 +0500 Subject: [PATCH 1166/3904] corrected GetCCaddress call in get TokenBalance --- src/wallet/rpcwallet.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2cf195661..847ddd921 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6976,7 +6976,7 @@ UniValue tokenorders(const UniValue& params, bool fHelp) UniValue tokenbalance(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); char destaddr[64]; uint256 tokenid; uint64_t balance; std::vector pubkey; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ); uint256 tokenid; uint64_t balance; std::vector pubkey; struct CCcontract_info *cp,C; CCerror.clear(); cp = CCinit(&C,EVAL_ASSETS); @@ -6992,13 +6992,17 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) pubkey = ParseHex(params[1].get_str().c_str()); else pubkey = Mypubkey(); - result.push_back(Pair("result", "success")); - if (GetCCaddress(cp,destaddr,pubkey2pk(pubkey)) != 0) - result.push_back(Pair("CCaddress",destaddr)); balance = GetTokenBalance(pubkey2pk(pubkey),tokenid); if (CCerror.empty()) { + char destaddr[64]; + + result.push_back(Pair("result", "success")); + + if (GetCCaddress(cp, destaddr, pubkey2pk(pubkey)) != 0) + result.push_back(Pair("CCaddress", destaddr)); + result.push_back(Pair("tokenid", params[0].get_str())); result.push_back(Pair("balance", (int64_t)balance)); } From 0d6eb9853a4a8c2a1262cdc669ad2129e9f907d0 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 15:48:45 +0500 Subject: [PATCH 1167/3904] added logging to IsTokenVout --- src/cc/CCtokens.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 613d4452f..167a0a241 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -366,9 +366,9 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); - //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << funcId << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { - //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned true" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!): @@ -391,7 +391,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c testVout = MakeTokensCC1of2vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } @@ -401,12 +401,13 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c CTxOut testVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, *it); if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } } else { + std::cerr << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } From bfce0c18b87635acdf856f4274ce90910156b56c Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 16:11:04 +0500 Subject: [PATCH 1168/3904] getMyEval() resurrection --- src/cc/CCtokens.cpp | 10 +++++----- src/cc/heir.cpp | 2 +- src/cc/heir_validate.h | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 167a0a241..939f1e7d7 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -108,7 +108,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 funcId = script[1]; //fprintf(stderr,"decode.[%c]\n",funcId); - switch ( funcId ) + switch( funcId ) { case 'c': return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription); @@ -366,7 +366,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); - std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << funcId << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; @@ -490,7 +490,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t // add inputs from token cc addr int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) { - char coinaddr[64], destaddr[64]; + char tokenaddr[64], destaddr[64]; int64_t threshold, nValue, price, totalinputs = 0; uint256 txid, hashBlock; std::vector vopretExtra; @@ -498,8 +498,8 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C int32_t j, vout, n = 0; std::vector > unspentOutputs; - GetCCaddress(cp, coinaddr, pk); - SetCCunspents(unspentOutputs, coinaddr); + GetTokensCCaddress(cp, tokenaddr, pk); + SetCCunspents(unspentOutputs, tokenaddr); threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: is maxinputs really could not be over 64? what if i want to calc total balance? diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 784e0a88c..5e9eb4362 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -725,7 +725,7 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); struct CCcontract_info *cp, C; - cp = CCinit(&C, EVAL_HEIR); + cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) txfee = 10000; diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 0094f5f4c..88d1d2745 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -29,6 +29,7 @@ inline static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } class CoinHelper { public: + static uint8_t getMyEval() { return EVAL_HEIR; } static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); } @@ -62,6 +63,7 @@ public: // helper class to allow polymorphic behaviour for HeirXXX() functions in case of tokens class TokenHelper { public: + static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddTokenCCInputs(cp, mtx, ownerPubkey, tokenid, total, maxinputs); } From 9f1c21c5b5729e3635cb221409e39da4d0a9210b Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 16:14:31 +0500 Subject: [PATCH 1169/3904] corr tokenaddr name --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 939f1e7d7..bc28f62ad 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -518,7 +518,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C if (GetTransaction(txid, vintx, hashBlock, false) != 0) { Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey); - if (strcmp(destaddr, coinaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) + if (strcmp(destaddr, tokenaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) continue; fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); From e1ddbcaf6c8b2ba00a8b824e34e534f50f3e8847 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 16:23:41 +0500 Subject: [PATCH 1170/3904] corr else if in FinalizeCCtx --- src/cc/CCtokens.cpp | 2 +- src/cc/CCtx.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index bc28f62ad..266035e08 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -366,7 +366,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); - std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index d85f59473..29e1fe0ab 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -138,16 +138,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); std::cerr << "FinalizeCCtx() destaddr=" << destaddr << " myaddr=" << myaddr << std::endl; - if ( strcmp(destaddr,myaddr) == 0 ) + if( strcmp(destaddr,myaddr) == 0 ) { privkey = myprivkey; cond = mycond; } - if (strcmp(destaddr, mytokensaddr) == 0) // if this is TokensCC1vout + else if (strcmp(destaddr, mytokensaddr) == 0) // if this is TokensCC1vout { privkey = myprivkey; cond = mytokenscond; - //fprintf(stderr,"FinalizeCCTx() matched TokensCC1vout CC addr.(%s)\n",mytokensaddr); + fprintf(stderr,"FinalizeCCTx() matched TokensCC1vout CC addr.(%s)\n",mytokensaddr); } else if ( strcmp(destaddr,unspendable) == 0 ) { From 034198730a9dc9a02d5e946824813409df97bc7b Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 16:44:49 +0500 Subject: [PATCH 1171/3904] changed vcontractOpret in IsTokensVout remove extra param from IsTokensVout --- src/cc/CCinclude.h | 2 +- src/cc/CCtokens.cpp | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 4b6b437b4..c42a4799e 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -155,7 +155,7 @@ uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); //int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector &origpubkey,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 266035e08..aca45fb70 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -365,17 +365,17 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; - const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); + std::vector vcontractOpret; + const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vcontractOpret); std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!): - CScript contractScript = CScript(vopretExtra); - std::vector vcontractOpret; + //CScript contractScript = CScript(vopretExtra); + //GetOpReturnData(contractScript, vcontractOpret); - GetOpReturnData(contractScript, vcontractOpret); if (vcontractOpret.size() == 0) { std::cerr << "IsTokensvout() empty contract opret" << std::endl; return 0; @@ -421,7 +421,11 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // compares cc inputs vs cc outputs (to prevent feeding vouts from normal inputs) bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) { - CTransaction vinTx; uint256 hashBlock, id, id2; int32_t flag; int64_t tokenoshis; std::vector tmporigpubkey; int64_t tmpprice; + CTransaction vinTx; + uint256 hashBlock; //, id, id2; + //int32_t flag; + int64_t tokenoshis; + // std::vector tmporigpubkey; int64_t tmpprice; std::vector vinPubkeys, vinPubkeysEmpty; int32_t numvins = tx.vin.size(); @@ -449,7 +453,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t tokenValIndentSize++; // validate vouts of vintx //std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; - tokenoshis = IsTokensvout(goDeeper, true, cpTokens, eval, tmporigpubkey, vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeys); + tokenoshis = IsTokensvout(goDeeper, true, cpTokens, eval, /*tmporigpubkey,*/ vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeys); tokenValIndentSize--; if (tokenoshis != 0) { @@ -464,9 +468,9 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t for (int32_t i = 0; i vopretExtra; + //std::vector vopretExtra; CTransaction vintx; int32_t j, vout, n = 0; std::vector > unspentOutputs; @@ -524,7 +528,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C std::vector vinPubkeys; - if ((nValue = IsTokensvout(true, true/*<--add only checked uxtos */, cp, NULL, vopretExtra, vintx, vout, tokenid, vinPubkeys)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + if ((nValue = IsTokensvout(true, true/*<--add only checked uxtos */, cp, NULL, /*vopretExtra,*/ vintx, vout, tokenid, vinPubkeys)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) { if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, vout, CScript())); From bdc2915f16d07b7e8fe28cc7f9810402078b646f Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 16:53:14 +0500 Subject: [PATCH 1172/3904] corrected call to IsTokensVout --- src/cc/CCassetsCore.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 67e23837f..72404878d 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -573,7 +573,9 @@ bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_ //assetoshis = IsAssetvout(cpAssets, tmpprice, tmporigpubkey, vinTx, tx.vin[i].prevout.n, assetid); std::vector vopretExtra; std::vector vinPubkeysEmpty; - assetoshis = IsTokensvout(false, false, cpTokens, NULL, vopretExtra, vinTx, tx.vin[i].prevout.n, assetid, vinPubkeysEmpty); + + // TODO: why is IsTokensVout here?? + assetoshis = IsTokensvout(false, false, cpTokens, NULL, /* vopretExtra,*/ vinTx, tx.vin[i].prevout.n, assetid, vinPubkeysEmpty); if (assetoshis != 0) { std::cerr << "AssetExactAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl; From d2119d8c45ddf893e502672327f0e255a404a035 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 17:05:47 +0500 Subject: [PATCH 1173/3904] corr IsTokensVout def - extra param --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index aca45fb70..833797417 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -325,7 +325,7 @@ uint8_t ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vec // goDeeper is true: the func also validates amounts of the passed transaction: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx // checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true! -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &vopretExtra, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys) +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector &vopretExtra,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys) { // this is just for log messages indentation fur debugging recursive calls: From 46d9219e2152beb3749dc199eb1fa4139a97dcc4 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 23:49:24 +0500 Subject: [PATCH 1174/3904] added second opret logging into IsTokenVout --- src/cc/CCtokens.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 833797417..f5716d866 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -365,7 +365,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; - std::vector vcontractOpret; + std::vector vcontractOpret, vcontractOpret2; const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vcontractOpret); std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { @@ -373,15 +373,18 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!): - //CScript contractScript = CScript(vopretExtra); - //GetOpReturnData(contractScript, vcontractOpret); + CScript contractScript = CScript(vcontractOpret); + GetOpReturnData(contractScript, vcontractOpret2); - if (vcontractOpret.size() == 0) { + std::cerr << "IsTokensvout() vcontractOpret=" << HexStr( vcontractOpret ); + std::cerr << "IsTokensvout() vcontractOpret2=" << HexStr(vcontractOpret2); + + if (vcontractOpret2.size() == 0) { std::cerr << "IsTokensvout() empty contract opret" << std::endl; return 0; } - uint8_t evalCodeInOpret = vcontractOpret.begin()[0]; + uint8_t evalCodeInOpret = vcontractOpret2.begin()[0]; if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { CTxOut testVout; From d6214fc9941848f768caac673e8f2ec4983ea727 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 00:12:23 +0500 Subject: [PATCH 1175/3904] corr second opret building/parsing --- src/cc/CCtokens.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index f5716d866..98199687f 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -62,14 +62,16 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t tokenid = revuint256(tokenid); //uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l'; - std::vector vpayload; - GetOpReturnData(payload, vpayload); + //std::vector vpayload; + //GetOpReturnData(payload, vpayload); //opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ - if(ccType >= 1) ss << voutPubkeys[0]; \ - if(ccType == 2) ss << voutPubkeys[1]; \ - if(payload.size() > 0) ss << vpayload); + if (ccType >= 1) ss << voutPubkeys[0]; \ + if (ccType == 2) ss << voutPubkeys[1];); + + if (payload.size() > 0) + opret << payload; return(opret); } @@ -365,26 +367,26 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; - std::vector vcontractOpret, vcontractOpret2; - const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vcontractOpret); + std::vector vopretExtra, vcontractOpret; + const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!): - CScript contractScript = CScript(vcontractOpret); - GetOpReturnData(contractScript, vcontractOpret2); + CScript contractScript = CScript(vopretExtra); + GetOpReturnData(contractScript, vcontractOpret); - std::cerr << "IsTokensvout() vcontractOpret=" << HexStr( vcontractOpret ); - std::cerr << "IsTokensvout() vcontractOpret2=" << HexStr(vcontractOpret2); + std::cerr << "IsTokensvout() vcontractOpret=" << HexStr(vopretExtra) << std::endl; + std::cerr << "IsTokensvout() vcontractOpret2=" << HexStr(vcontractOpret) << std::endl;; - if (vcontractOpret2.size() == 0) { + if (vcontractOpret.size() == 0) { std::cerr << "IsTokensvout() empty contract opret" << std::endl; return 0; } - uint8_t evalCodeInOpret = vcontractOpret2.begin()[0]; + uint8_t evalCodeInOpret = vcontractOpret.begin()[0]; if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { CTxOut testVout; From c78b88725f5781f43a58b616326fef131db8aa66 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 00:17:33 +0500 Subject: [PATCH 1176/3904] corrected opret concat --- src/cc/CCtokens.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 98199687f..2944b6649 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -71,8 +71,8 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t if (ccType == 2) ss << voutPubkeys[1];); if (payload.size() > 0) - opret << payload; - return(opret); + opret += payload; + return opret; } From fe0cc96584161585a737c2fd9799178f48e0776b Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 00:38:22 +0500 Subject: [PATCH 1177/3904] corr second opret building more --- src/cc/CCtokens.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 2944b6649..53f992520 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -62,16 +62,19 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t tokenid = revuint256(tokenid); //uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l'; - //std::vector vpayload; - //GetOpReturnData(payload, vpayload); + std::vector vpayload; + GetOpReturnData(payload, vpayload); //opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ if (ccType >= 1) ss << voutPubkeys[0]; \ if (ccType == 2) ss << voutPubkeys[1];); - - if (payload.size() > 0) - opret += payload; + + //add second opret: + opret << OP_RETURN << E_MARSHAL(ss << vpayload); + +// if (payload.size() > 0) +// opret += payload; return opret; } From e24039f137c6934a4da5fcdfe7b09e0268d7434c Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 00:44:57 +0500 Subject: [PATCH 1178/3904] corr concat opret1+opret2 --- src/cc/CCtokens.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 53f992520..20d8fbe59 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -53,7 +53,7 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector origpubkey,st // this is for other contracts which use tokens and build customized extra payloads to token's opret: CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload) { - CScript opret; + CScript opret1, opret2; uint8_t ccType = 0; if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) ccType = voutPubkeys.size(); @@ -66,16 +66,16 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t GetOpReturnData(payload, vpayload); //opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); - opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ + opret1 << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ if (ccType >= 1) ss << voutPubkeys[0]; \ if (ccType == 2) ss << voutPubkeys[1];); //add second opret: - opret << OP_RETURN << E_MARSHAL(ss << vpayload); + opret2 << OP_RETURN << E_MARSHAL(ss << vpayload); // if (payload.size() > 0) // opret += payload; - return opret; + return opret1 + opret2; } From 20bd5c88b72aa70fbda1f97e6ae27d40a8608d49 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 15:14:06 +0500 Subject: [PATCH 1179/3904] opret processing returned to the variant without OP_RETURN opcode (cause this caused validation err) --- src/cc/CCtokens.cpp | 46 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 20d8fbe59..63e2124ad 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -53,29 +53,32 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector origpubkey,st // this is for other contracts which use tokens and build customized extra payloads to token's opret: CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload) { - CScript opret1, opret2; + CScript opret; + + if (evalCodeInOpret != EVAL_TOKENS) { + std::cerr << "EncodeTokenOpRet() evalCode should be EVAL_TOKENS!" << std::endl; + return opret; // return empty + } + + tokenid = revuint256(tokenid); + uint8_t ccType = 0; if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) ccType = voutPubkeys.size(); - //uint8_t evalcode = EVAL_TOKENS; - tokenid = revuint256(tokenid); - //uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l'; - std::vector vpayload; GetOpReturnData(payload, vpayload); - //opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload); - opret1 << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ - if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1];); + opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ + if (ccType >= 1) ss << voutPubkeys[0]; \ + if (ccType == 2) ss << voutPubkeys[1]; \ + if (vpayload.size() > 0) ss << vpayload;); - //add second opret: - opret2 << OP_RETURN << E_MARSHAL(ss << vpayload); // if (payload.size() > 0) -// opret += payload; - return opret1 + opret2; +// opret += payload; --> "error 64: scriptpubkey" + + return opret; } @@ -370,7 +373,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; - std::vector vopretExtra, vcontractOpret; + std::vector vopretExtra; + //std::vector vcontractOpret; const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { @@ -378,18 +382,18 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!): - CScript contractScript = CScript(vopretExtra); - GetOpReturnData(contractScript, vcontractOpret); + //CScript contractScript = CScript(vopretExtra); + //GetOpReturnData(contractScript, vcontractOpret); - std::cerr << "IsTokensvout() vcontractOpret=" << HexStr(vopretExtra) << std::endl; - std::cerr << "IsTokensvout() vcontractOpret2=" << HexStr(vcontractOpret) << std::endl;; + std::cerr << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl; + //std::cerr << "IsTokensvout() vcontractOpret=" << HexStr(vcontractOpret) << std::endl;; - if (vcontractOpret.size() == 0) { - std::cerr << "IsTokensvout() empty contract opret" << std::endl; + if (vopretExtra.size() < 2 /*|| vopretExtra.size() != vopretExtra.begin()[0]*/) { + std::cerr << "IsTokensvout() empty or incorrect contract opret" << std::endl; return 0; } - uint8_t evalCodeInOpret = vcontractOpret.begin()[0]; + uint8_t evalCodeInOpret = vopretExtra.begin()[1]; if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { CTxOut testVout; From 9edec18b96bb00667daafa0958e307e47c7e41f2 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 15:38:05 +0500 Subject: [PATCH 1180/3904] heirinfo logging enabled --- src/cc/heir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 5e9eb4362..7ae5d0241 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1061,7 +1061,7 @@ UniValue HeirInfo(uint256 fundingtxid) // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { - const bool noLogging = true; + const bool noLogging = false; uint8_t evalCodeTokens = 0; std::vector voutPubkeys; std::vector vopretExtra; From 32469f37c1c40cb854248361cd474ea88a9c7269 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 16:47:28 +0500 Subject: [PATCH 1181/3904] Added DecodeHeirEitherOpret handy func corr serialization second opret via payload --- src/cc/CCtokens.cpp | 8 +-- src/cc/heir.cpp | 145 +++++++++++++++++------------------------ src/cc/heir_validate.h | 2 + 3 files changed, 65 insertions(+), 90 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 63e2124ad..553f61163 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -71,14 +71,14 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1]; \ - if (vpayload.size() > 0) ss << vpayload;); + if (ccType == 2) ss << voutPubkeys[1];); // \ + //if (vpayload.size() > 0) ss << vpayload;); // if (payload.size() > 0) // opret += payload; --> "error 64: scriptpubkey" - - return opret; + // TODO: check or serialization to vpayload! + return opret + payload; } diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 7ae5d0241..4276fee16 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -322,60 +322,6 @@ CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpe return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); } -/* -// makes opret for tokens while they are inside Heir contract address space - initial funding -CScript EncodeHeirTokensCreateOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName) -{ - uint8_t evalcode = EVAL_HEIR; - uint8_t ccType = 0; - if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) - ccType = voutPubkeys.size(); - - tokenid = revuint256(tokenid); - return CScript() << OP_RETURN << - E_MARSHAL(ss << evalcode << (uint8_t)'t' << tokenid << ccType; \ - if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1]; \ - ss << heirFuncId << ownerPubkey << heirPubkey << inactivityTimeSec << hearName); -} -// makes opret for tokens while they are inside Heir contract address space - additional funding -CScript EncodeHeirTokensOpRet(uint8_t heirFuncId, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t hasHeirSpendingBegun) -{ - uint8_t evalcode = EVAL_HEIR; - uint8_t ccType = 0; - if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) - ccType = voutPubkeys.size(); - - tokenid = revuint256(tokenid); // for visualization in debug logs - fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << - E_MARSHAL(ss << evalcode << (uint8_t)'t' << tokenid << ccType; \ - if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1]; \ - ss << heirFuncId << fundingtxid << hasHeirSpendingBegun); -} -*/ - -// helper for decode heir opret payload -// NOTE: Heir for coins has the same opret as Heir for tokens -/*uint8_t _UnmarshalOpret(std::vector vopretExtra, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun) { - uint8_t heirFuncId = 0; - hasHeirSpendingBegun = 0; - - bool result = E_UNMARSHAL(vopretExtra, { ss >> heirFuncId; \ - if( heirFuncId == 'F') { \ - ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; \ - } else { \ - ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ - } \ - }); - - if (!result )// || assetFuncId != 't' -- any tx is ok) - return (uint8_t)0; - - return heirFuncId; -}*/ - /** * decode opret vout for Heir contract */ @@ -457,7 +403,47 @@ uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8 return _DecodeHeirOpRet(scriptPubKey, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); } +// decode combined opret: +uint8_t _DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) +{ + uint8_t evalCodeTokens = 0; + std::vector voutPubkeys; + std::vector vopretExtra; + CScript heirScript = scriptPubKey; + int32_t heirType = HEIR_COINS; + + if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra) != 0) { + if (vopretExtra.size() > 1) { + // restore the second opret: + heirScript = CScript(); + std::vector vopretStripped = std::vector(vopretExtra.begin()+1, vopretExtra.end()); //strip string size + heirScript << OP_RETURN << E_MARSHAL(ss << vopretStripped); + heirType = HEIR_TOKENS; + } + else { + return (uint8_t)0; + } + } + return DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, noLogging); +} + +// overload to decode opret in fundingtxid: +uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { + uint256 dummyFundingTxidInOpret; + uint8_t dummyHasHeirSpendingBegun; + + return _DecodeHeirEitherOpret(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummyFundingTxidInOpret, dummyHasHeirSpendingBegun, noLogging); +} + +// overload to decode opret in A and C heir tx: +uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t hasHeirSpendingBegun, bool noLogging) { + CPubKey dummyOwnerPubkey, dummyHeirPubkey; + int64_t dummyInactivityTime; + std::string dummyHeirName; + + return _DecodeHeirEitherOpret(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); +} /** * find the latest funding tx: it may be the first F tx or one of A or C tx's @@ -1042,14 +1028,6 @@ UniValue HeirInfo(uint256 fundingtxid) UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey ownerPubkey, heirPubkey; - uint256 latestFundingTxid; - uint256 dummyTokenid, tokenid; - - std::string heirName; - uint8_t funcId; - int64_t inactivityTimeSec; - CTransaction fundingtx; uint256 hashBlock; const bool allowSlow = false; @@ -1061,23 +1039,18 @@ UniValue HeirInfo(uint256 fundingtxid) // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { + CPubKey ownerPubkey, heirPubkey; + uint256 latestFundingTxid; + uint256 dummyTokenid, tokenid = zeroid; + std::string heirName; + int64_t inactivityTimeSec; const bool noLogging = false; - uint8_t evalCodeTokens = 0; - std::vector voutPubkeys; - std::vector vopretExtra; - CScript heirScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; - int32_t heirType = HEIR_COINS; - uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); - if (funcId != 0) { - heirScript = CScript(vopretExtra); - heirType = HEIR_TOKENS; - } - funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); - - if( funcId == 0 ) { - std::cerr << "HeirInfo() initial tx F not found for this fundingtx" << std::endl; + CScript opret = fundingtx.vout.size() > 0 ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + uint8_t funcId = DecodeHeirEitherOpret(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); + if (funcId == 0) { + std::cerr << "HeirInfo() this fundingtx is incorrect" << std::endl; result.push_back(Pair("result", "error")); result.push_back(Pair("error", "initial tx F not found")); return result; @@ -1088,10 +1061,10 @@ UniValue HeirInfo(uint256 fundingtxid) uint8_t hasHeirSpendingBegun = 0; - if (heirType == HEIR_COINS) - latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - else - latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + if (tokenid == zeroid) // coins + latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + else // tokens + latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); if (latestFundingTxid != zeroid) { int32_t numblocks; @@ -1105,7 +1078,7 @@ UniValue HeirInfo(uint256 fundingtxid) result.push_back(Pair("fundingtxid", fundingtxid.GetHex())); result.push_back(Pair("name", heirName.c_str())); - if (heirType == HEIR_TOKENS) { + if (tokenid != zeroid) { // tokens stream << tokenid.GetHex(); msg = "tokenid"; result.push_back(Pair(msg, stream.str().c_str())); @@ -1125,12 +1098,12 @@ UniValue HeirInfo(uint256 fundingtxid) stream.clear(); int64_t total; - if (heirType == HEIR_COINS) + if (tokenid != zeroid) total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); else total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); - if (heirType == HEIR_COINS) { + if (tokenid == zeroid) { msg = "funding total in coins"; stream << (double)total / COIN; } @@ -1143,12 +1116,12 @@ UniValue HeirInfo(uint256 fundingtxid) stream.clear(); int64_t inputs; - if (heirType == HEIR_COINS) + if (tokenid == zeroid) inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); //NOTE: amount = 0 means all unspent inputs else inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); - if (heirType == HEIR_COINS) { + if (tokenid == zeroid) { msg = "funding available in coins"; stream << (double)inputs / COIN; } @@ -1160,7 +1133,7 @@ UniValue HeirInfo(uint256 fundingtxid) stream.str(""); stream.clear(); - if (heirType == HEIR_TOKENS) { + if (tokenid != zeroid) { int64_t ownerInputs = TokenHelper::addOwnerInputs(cp, tokenid, mtx, ownerPubkey, 0, (int32_t)64); stream << ownerInputs; msg = "owner funding available in tokens"; diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 88d1d2745..5f56514d5 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -20,6 +20,8 @@ CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpen template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t hasHeirSpendingBegun, bool noLogging = false); inline static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } inline static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } From 7b7b5bdbc0095f3a4f625a669412a0607d425f1e Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 17:09:11 +0500 Subject: [PATCH 1182/3904] corr encode token opret plus no opcode cscript --- src/cc/CCtokens.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 553f61163..abcae84cd 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -78,7 +78,9 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t // if (payload.size() > 0) // opret += payload; --> "error 64: scriptpubkey" // TODO: check or serialization to vpayload! - return opret + payload; + CScript opretPayloadNoOpcode(vpayload); + + return opret + opretPayloadNoOpcode; } From 400b798cd242ec110a34a4e82597ba6896681509 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 17:41:41 +0500 Subject: [PATCH 1183/3904] try to add second opret w/o serialization --- src/cc/CCtokens.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index abcae84cd..917487bbe 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -71,16 +71,25 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1];); // \ - //if (vpayload.size() > 0) ss << vpayload;); + if (ccType == 2) ss << voutPubkeys[1]; ); // \ + // if (vpayload.size() > 0) ss << vpayload;); -// if (payload.size() > 0) -// opret += payload; --> "error 64: scriptpubkey" - // TODO: check or serialization to vpayload! - CScript opretPayloadNoOpcode(vpayload); + // "error 64: scriptpubkey": + // if (payload.size() > 0) + // opret += payload; - return opret + opretPayloadNoOpcode; + // error 64: scriptpubkey: + // CScript opretPayloadNoOpcode(vpayload); + // return opret + opretPayloadNoOpcode; + + // how to attach payload without re-serialization: + opret.resize(opret.size() + vpayload.size()); + CScript::iterator it = opret.begin() + opret.size(); + for (int i = 0; i < vpayload.size(); i++) + *it = vpayload[i]; + + return opret; } From ab87b673eb692ea3ae897ca3902d28e21a4fd0e1 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 17:48:03 +0500 Subject: [PATCH 1184/3904] iterator increment corr --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 917487bbe..3bd94f19d 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -86,7 +86,7 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t // how to attach payload without re-serialization: opret.resize(opret.size() + vpayload.size()); CScript::iterator it = opret.begin() + opret.size(); - for (int i = 0; i < vpayload.size(); i++) + for (int i = 0; i < vpayload.size(); i++, it++) *it = vpayload[i]; return opret; From 39731c231f9728311a4ac382461cd8a5fa363d68 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 18:06:41 +0500 Subject: [PATCH 1185/3904] try to construct secod opret w/o serialization --- src/cc/CCtokens.cpp | 13 +++++++------ src/cc/heir.cpp | 15 ++++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 3bd94f19d..c759f3704 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -71,8 +71,8 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1]; ); // \ - // if (vpayload.size() > 0) ss << vpayload;); + if (ccType == 2) ss << voutPubkeys[1]; \ + if (vpayload.size() > 0) ss << vpayload;); // "error 64: scriptpubkey": @@ -84,10 +84,11 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t // return opret + opretPayloadNoOpcode; // how to attach payload without re-serialization: - opret.resize(opret.size() + vpayload.size()); - CScript::iterator it = opret.begin() + opret.size(); - for (int i = 0; i < vpayload.size(); i++, it++) - *it = vpayload[i]; + // sig_aborted: + // opret.resize(opret.size() + vpayload.size()); + // CScript::iterator it = opret.begin() + opret.size(); + // for (int i = 0; i < vpayload.size(); i++, it++) + // *it = vpayload[i]; return opret; } diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 4276fee16..bdc485c5d 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -408,18 +408,23 @@ uint8_t _DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& { uint8_t evalCodeTokens = 0; std::vector voutPubkeys; - std::vector vopretExtra; + std::vector vopretExtra, vopretStripped; CScript heirScript = scriptPubKey; - int32_t heirType = HEIR_COINS; if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra) != 0) { if (vopretExtra.size() > 1) { // restore the second opret: heirScript = CScript(); - std::vector vopretStripped = std::vector(vopretExtra.begin()+1, vopretExtra.end()); //strip string size - heirScript << OP_RETURN << E_MARSHAL(ss << vopretStripped); - heirType = HEIR_TOKENS; + + E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; }); // std::vector(vopretExtra.begin()+1, vopretExtra.end()); //strip string size + + heirScript << OP_RETURN; + uint32_t i = heirScript.size(); + heirScript << E_MARSHAL(ss << vopretStripped); + for (uint32_t iStripped = 0; iStripped < vopretStripped.size(); iStripped++) + heirScript[i] = vopretStripped[iStripped]; + heirScript.resize(heirScript.size()-1); } else { return (uint8_t)0; From 97a030d05ad7f5b92c33fa621ffdb18ec2646ed4 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 22:38:33 +0500 Subject: [PATCH 1186/3904] corrected passing vopretStripped to DecodeHeirOpRet (instead CScript) --- src/cc/heir.cpp | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index bdc485c5d..b0272542c 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -322,22 +322,15 @@ CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpe return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); } -/** -* decode opret vout for Heir contract -*/ -uint8_t _DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) + +// decode opret vout for Heir contract +uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { - std::vector vopret; uint8_t evalCodeInOpret = 0; uint8_t heirFuncId = 0; fundingTxidInOpret = zeroid; //to init - GetOpReturnData(scriptPubKey, vopret); - if (vopret.size() == 0) { - if (!noLogging) std::cerr << "_DecodeHeirOpRet() warning: empty opret" << std::endl; - return (uint8_t)0; - } evalCodeInOpret = vopret.begin()[0]; if (vopret.size() > 1 && evalCodeInOpret == EVAL_HEIR) { @@ -387,8 +380,14 @@ uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& hei { uint256 dummytxid; uint8_t dummyHasHeirSpendingBegun; + std::vector vopret; - return _DecodeHeirOpRet(scriptPubKey, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); + GetOpReturnData(scriptPubKey, vopret); + if (vopret.size() == 0) { + if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; + return (uint8_t)0; + } + return _DecodeHeirOpRet(vopret, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); } /** @@ -399,8 +398,15 @@ uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8 CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; std::string dummyHeirName; + std::vector vopret; - return _DecodeHeirOpRet(scriptPubKey, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); + GetOpReturnData(scriptPubKey, vopret); + if (vopret.size() == 0) { + if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; + return (uint8_t)0; + } + + return _DecodeHeirOpRet(vopret, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); } // decode combined opret: @@ -417,20 +423,17 @@ uint8_t _DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& // restore the second opret: heirScript = CScript(); - E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; }); // std::vector(vopretExtra.begin()+1, vopretExtra.end()); //strip string size - - heirScript << OP_RETURN; - uint32_t i = heirScript.size(); - heirScript << E_MARSHAL(ss << vopretStripped); - for (uint32_t iStripped = 0; iStripped < vopretStripped.size(); iStripped++) - heirScript[i] = vopretStripped[iStripped]; - heirScript.resize(heirScript.size()-1); + if (E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size + if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; + return (uint8_t)0; + } } else { + if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl; return (uint8_t)0; } } - return DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, noLogging); + return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } // overload to decode opret in fundingtxid: From d41cd8b99178036aeca822a3bd2cfe143b94a593 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 13 Jan 2019 23:07:31 +0500 Subject: [PATCH 1187/3904] corr unmarshal retcode proc in _DecodeHeirEitherOpRet GetTokenBalance returns error always, obsolete --- src/cc/CCtokens.cpp | 7 +++++-- src/cc/heir.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index c759f3704..70aa60d92 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -661,7 +661,10 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction tokentx; - if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) + CCerror = strprintf("obsolete, cannot return correct value without eval"); + return 0; + +/* if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) { fprintf(stderr, "cant find tokenid\n"); CCerror = strprintf("cant find tokenid"); @@ -670,7 +673,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_TOKENS); - return(AddTokenCCInputs(cp, mtx, pk, tokenid, 0, 0)); + return(AddTokenCCInputs(cp, mtx, pk, tokenid, 0, 0)); */ } UniValue TokenInfo(uint256 tokenid) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index b0272542c..1d74b4970 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -423,7 +423,7 @@ uint8_t _DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& // restore the second opret: heirScript = CScript(); - if (E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size + if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; return (uint8_t)0; } From 1a5999e0bdd0aeda5d42e4e14d274d696b5cea28 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 00:30:42 +0500 Subject: [PATCH 1188/3904] _DecodeHeirEitherOpRet corrected vopretStripped proc --- src/cc/heir.cpp | 84 ++++++++++++++----------------------------------- 1 file changed, 24 insertions(+), 60 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 1d74b4970..909d660d6 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -410,18 +410,15 @@ uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8 } // decode combined opret: -uint8_t _DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) +uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { uint8_t evalCodeTokens = 0; - std::vector voutPubkeys; + std::vector voutPubkeysDummy; std::vector vopretExtra, vopretStripped; - CScript heirScript = scriptPubKey; - - if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra) != 0) { + if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { if (vopretExtra.size() > 1) { // restore the second opret: - heirScript = CScript(); if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; @@ -433,24 +430,28 @@ uint8_t _DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& return (uint8_t)0; } } + else + GetOpReturnData(scriptPubKey, vopretStripped); + return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); + } // overload to decode opret in fundingtxid: -uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { +uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { uint256 dummyFundingTxidInOpret; uint8_t dummyHasHeirSpendingBegun; - return _DecodeHeirEitherOpret(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummyFundingTxidInOpret, dummyHasHeirSpendingBegun, noLogging); + return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummyFundingTxidInOpret, dummyHasHeirSpendingBegun, noLogging); } // overload to decode opret in A and C heir tx: -uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t hasHeirSpendingBegun, bool noLogging) { +uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t hasHeirSpendingBegun, bool noLogging) { CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; std::string dummyHeirName; - return _DecodeHeirEitherOpret(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); + return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } /** @@ -472,22 +473,9 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { - uint256 dummytxid; - uint8_t evalCodeTokens = 0; - std::vector vopretExtra; - std::vector dummyVoutPubkeys; - - CScript heirScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; - if (typeid(Helper) == typeid(TokenHelper)) { - if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { - heirScript = CScript(vopretExtra); - } - else { - std::cerr << "FindLatestFundingTx() could not decode token opreturn for fundingtxid=" << fundingtxid.GetHex() << '\n'; - return zeroid; - } - } - funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName); + CScript heirScript = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + + uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); if (funcId != 0) { // found at least funding tx! //std::cerr << "FindLatestFundingTx() lasttx currently is fundingtx, txid=" << fundingtxid.GetHex() << " opreturn type=" << (char)funcId << '\n'; @@ -522,48 +510,24 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ //std::cerr << "FindLatestFundingTx() checking unspents for txid=" << txid.GetHex() << '\n'; int32_t blockHeight = (int32_t)it->second.blockHeight; - uint256 fundingTxidInOpret; //NOTE: maybe called from validation code: if (myGetTransaction(txid, regtx, hash)) { //std::cerr << "FindLatestFundingTx() found tx for txid=" << txid.GetHex() << " blockHeight=" << blockHeight << " maxBlockHeight=" << maxBlockHeight << '\n'; - - /*{ // debug code: - uint256 debAssetid; - uint8_t debHasHeirSpendingBegun; - uint8_t debfuncid = DecodeHeirOpRet(regtx.vout[regtx.vout.size() - 1].scriptPubKey, debAssetid, fundingTxidInOpret, debHasHeirSpendingBegun, true); - - std::cerr << "FindLatestFundingTx() regtx.vout.size()=" << regtx.vout.size() << " funcId=" << (char)(debfuncid ? debfuncid : ' ') - << " tokenid=" << debAssetid.GetHex() << " fundingtxidInOpret=" << fundingTxidInOpret.GetHex() << " debHasHeirSpendingBegun=" << (int)debHasHeirSpendingBegun << std::endl; - }*/ - - uint256 dummyTokenid; // not to contaminate the tokenid from the params! + uint256 fundingTxidInOpret; + uint256 tokenidInOpret; // not to contaminate the tokenid from the params! uint8_t tmpFuncId; - uint8_t tmphasHeirSpendingBegun; + uint8_t hasHeirSpendingBegunInOpret; - uint8_t evalCodeTokens = 0; - std::vector vopretExtra; - std::vector dummyVoutPubkeys; - - CScript heirScript = regtx.vout[regtx.vout.size() - 1].scriptPubKey; - if (typeid(Helper) == typeid(TokenHelper)) { - if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { - heirScript = CScript(vopretExtra); - } - else { - std::cerr << "FindLatestFundingTx() could not decode token opreturn for fundingtxid=" << fundingtxid.GetHex() << '\n'; - return zeroid; - } - } - tmpFuncId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, tmphasHeirSpendingBegun, true); - - if (regtx.vout.size() > 0 && tmpFuncId != 0 && fundingtxid == fundingTxidInOpret) { + CScript heirScript = (regtx.vout.size() > 0) ? regtx.vout[regtx.vout.size() - 1].scriptPubKey : CScript(); + tmpFuncId = DecodeHeirEitherOpRet(heirScript, tokenidInOpret, fundingTxidInOpret, hasHeirSpendingBegunInOpret, true); + if (tmpFuncId != 0 && fundingtxid == fundingTxidInOpret && (tokenid == zeroid || tokenid == tokenidInOpret)) { // check tokenid also if (blockHeight > maxBlockHeight) { maxBlockHeight = blockHeight; latesttxid = txid; funcId = tmpFuncId; - hasHeirSpendingBegun = tmphasHeirSpendingBegun; + hasHeirSpendingBegun = hasHeirSpendingBegunInOpret; //std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight // << " opreturn type=" << (char)(funcId ? funcId : ' ') << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << " - set as current lasttxid" << '\n'; @@ -1049,14 +1013,14 @@ UniValue HeirInfo(uint256 fundingtxid) CPubKey ownerPubkey, heirPubkey; uint256 latestFundingTxid; - uint256 dummyTokenid, tokenid = zeroid; + uint256 dummyTokenid, tokenid = zeroid; // important to clear tokenid std::string heirName; int64_t inactivityTimeSec; const bool noLogging = false; CScript opret = fundingtx.vout.size() > 0 ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); - uint8_t funcId = DecodeHeirEitherOpret(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); + uint8_t funcId = DecodeHeirEitherOpret(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); if (funcId == 0) { std::cerr << "HeirInfo() this fundingtx is incorrect" << std::endl; result.push_back(Pair("result", "error")); @@ -1072,7 +1036,7 @@ UniValue HeirInfo(uint256 fundingtxid) if (tokenid == zeroid) // coins latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); else // tokens - latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid /*<-verify for tokens*/, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); if (latestFundingTxid != zeroid) { int32_t numblocks; From 42a48b9653241c07e60d821f2e79e89ae1c0947f Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 00:38:56 +0500 Subject: [PATCH 1189/3904] corrected call to DecodeHeirEitherOpRet in Heirinfo --- src/cc/heir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 909d660d6..a895c9cc2 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -446,7 +446,7 @@ uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& o } // overload to decode opret in A and C heir tx: -uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t hasHeirSpendingBegun, bool noLogging) { +uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; std::string dummyHeirName; @@ -1020,7 +1020,7 @@ UniValue HeirInfo(uint256 fundingtxid) CScript opret = fundingtx.vout.size() > 0 ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); - uint8_t funcId = DecodeHeirEitherOpret(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); if (funcId == 0) { std::cerr << "HeirInfo() this fundingtx is incorrect" << std::endl; result.push_back(Pair("result", "error")); From 5c35c03d60c68d9cb1db430c2f9492b4c537144d Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 01:27:45 +0500 Subject: [PATCH 1190/3904] added isTokenVout call to Add1of2address func in heir.cpp corrected ExtractTokensVinPubkeys call -> in isTokensVout --- src/cc/CCtokens.cpp | 16 +++++++++++----- src/cc/heir.cpp | 16 +++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 70aa60d92..9b110992b 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -262,14 +262,17 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & // helper funcs: // extract my vins pubkeys: -bool ExtractVinPubkeys(struct CCcontract_info *cp, CTransaction tx, std::vector &vinPubkeys) { +bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys) { bool found = false; CPubKey pubkey; + struct CCcontract_info *cpTokens, tokensC; + + cpTokens = CCinit(&tokensC, EVAL_TOKENS); for (int32_t i = 0; i < tx.vin.size(); i++) { // check for additional contracts which may send tokens to the Tokens contract - if( (*cp->ismyvin)(tx.vin[i].scriptSig) ) + if( (*cpTokens->ismyvin)(tx.vin[i].scriptSig) ) { auto findEval = [](CC *cond, struct CCVisitor _) { @@ -345,7 +348,7 @@ uint8_t ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vec // goDeeper is true: the func also validates amounts of the passed transaction: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx // checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true! -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector &vopretExtra,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys) +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector &vopretExtra,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys000) { // this is just for log messages indentation fur debugging recursive calls: @@ -421,6 +424,9 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c } // maybe it is token change? + std::vector vinPubkeys; + ExtractTokensVinPubkeys(tx, vinPubkeys); + for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { CTxOut testVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, *it); @@ -450,7 +456,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t //int32_t flag; int64_t tokenoshis; // std::vector tmporigpubkey; int64_t tmpprice; - std::vector vinPubkeys, vinPubkeysEmpty; + std::vector vinPubkeys; int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); @@ -459,7 +465,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t // this is just for log messages indentation for debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - ExtractVinPubkeys(cpTokens, tx, vinPubkeys); + ExtractTokensVinPubkeys(tx, vinPubkeys); for (int32_t i = 0; i int64_t Add1of2AddressInputs(struct CCcontract_info* cp, if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { uint256 tokenid; uint256 fundingTxidInOpret; - uint8_t dummyHasHeirSpendingBegun; - uint8_t evalCodeTokens = 0; - std::vector vopretExtra; - std::vector voutPubkeys; + uint8_t hasHeirSpendingBegunDummy; + std::vector vinPubkeysEmpty; - CScript heirScript = heirtx.vout[heirtx.vout.size() - 1].scriptPubKey; - uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); - if (funcId != 0) { - heirScript = CScript(vopretExtra); - } - funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); + CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); + uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && funcId != 0 && isMyFuncId(funcId) && - // (typeid(Helper) == typeid(TokenHelper) && IsHeirvout(true, cp, nullptr, tokenid, vintx, voutIndex) > 0) && // deep validation for tokens - not used anymore + (typeid(Helper) == typeid(TokenHelper) && IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid, vinPubkeysEmpty) > 0) && // deep validation for tokens - not used anymore (voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && !myIsutxo_spentinmempool(txid, voutIndex)) { From dbae803774c362b6e1f903970aadbd8adb1844ed Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 01:39:56 +0500 Subject: [PATCH 1191/3904] added loggin into isTokensVout --- src/cc/CCtokens.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 9b110992b..447bb96f6 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -353,7 +353,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - //std::cerr << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl; //TODO: validate cc vouts are EVAL_TOKENS! @@ -456,7 +456,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t //int32_t flag; int64_t tokenoshis; // std::vector tmporigpubkey; int64_t tmpprice; - std::vector vinPubkeys; + std::vector vinPubkeys000; int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); @@ -465,7 +465,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t // this is just for log messages indentation for debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - ExtractTokensVinPubkeys(tx, vinPubkeys); + //ExtractTokensVinPubkeys(tx, vinPubkeys); for (int32_t i = 0; iInvalid("always should find vin tx, but didnt"); - } else { tokenValIndentSize++; @@ -500,6 +501,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t tokenValIndentSize++; // Note: we pass in here 'false' because we don't need to call TokenExactAmounts() recursively from IsTokensvout // indeed, in this case we'll be checking this tx again + std::cerr << indentStr << "TokenExactAmounts() check vout i=" << i << " nValue=" << tx.vout[i].nValue << std::endl; tokenoshis = IsTokensvout(false, true /*<--exclude non-tokens vouts*/, cpTokens, eval,/* tmporigpubkey,*/ tx, i, tokenid, vinPubkeys000); tokenValIndentSize--; From d3c804c50c8e84e4ea1d1da0187f7a2272f09fe1 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 13:10:18 +0500 Subject: [PATCH 1193/3904] corr DecodeHeirEitherOpRet call in LifeTimeHeirContractFund restores !ismempool.. check --- src/cc/heir.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index dff407aac..9b78f2584 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -593,14 +593,14 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint8_t hasHeirSpendingBegunDummy; std::vector vinPubkeysEmpty; - CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); + CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && funcId != 0 && isMyFuncId(funcId) && - (typeid(Helper) == typeid(TokenHelper) && IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid, vinPubkeysEmpty) > 0) && // deep validation for tokens - not used anymore - (voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && + (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid, vinPubkeysEmpty) > 0) && // token validation logic + //(voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && // heir contract vout validation logic - not used since we moved to 2-eval vouts !myIsutxo_spentinmempool(txid, voutIndex)) { std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; @@ -633,28 +633,26 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info for (std::vector>::const_iterator it = addressIndexes.begin(); it != addressIndexes.end(); it++) { uint256 hashBlock; uint256 txid = it->first.txhash; - CTransaction tx; + CTransaction heirtx; - if (GetTransaction(txid, tx, hashBlock, false) && tx.vout.size() > 0) { - uint8_t evalCodeTokens = 0; + // TODO: check all funding tx should contain unspendable markers + if (GetTransaction(txid, heirtx, hashBlock, false) && heirtx.vout.size() > 0) { uint256 tokenid; uint256 fundingTxidInOpret; - std::vector vopretExtra; - std::vector voutPubkeys; - uint8_t dummyHasHeirSpendingBegun; + uint8_t hasHeirSpendingBegunDummy; + std::vector vinPubkeysEmpty; const int32_t ivout = 0; - CScript heirScript = tx.vout[tx.vout.size() - 1].scriptPubKey; - uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); - if (funcId != 0) { - heirScript = CScript(vopretExtra); - } - funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); + CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary + uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); //std::cerr << "LifetimeHeirContractFunds() found tx=" << txid.GetHex() << " vout[0].nValue=" << subtx.vout[ccVoutIdx].nValue << " opreturn=" << (char)funcId << '\n'; - if (funcId != 0 && (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && isMyFuncId(funcId) && !isSpendingTx(funcId) - /* && !myIsutxo_spentinmempool(txid, ccVoutIdx) */) // include also tx in mempool + if (funcId != 0 && + (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && + isMyFuncId(funcId) && !isSpendingTx(funcId) && + (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, ivout, tokenid, vinPubkeysEmpty) > 0) && + !myIsutxo_spentinmempool(txid, ivout)) // exclude tx in mempool { total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) //std::cerr << "LifetimeHeirContractFunds() added tx=" << txid.GetHex() << " it->second=" << it->second << " vout[0].nValue=" << tx.vout[ivout].nValue << " opreturn=" << (char)funcId << '\n'; From 08c0a5a8c6238e2f6770b98bfa82ab2b64d73165 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 13:23:08 +0500 Subject: [PATCH 1194/3904] corr "is token" check in HeirInfo --- src/cc/heir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 9b78f2584..6fd98d545 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -603,7 +603,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, //(voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && // heir contract vout validation logic - not used since we moved to 2-eval vouts !myIsutxo_spentinmempool(txid, voutIndex)) { - std::cerr << "Add1of2AddressInputs() voutValue=" << voutValue << " satoshis=" << it->second.satoshis << '\n'; + std::cerr << "Add1of2AddressInputs() satoshis=" << it->second.satoshis << std::endl; if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, voutIndex, CScript())); nValue = it->second.satoshis; @@ -1062,7 +1062,7 @@ UniValue HeirInfo(uint256 fundingtxid) stream.clear(); int64_t total; - if (tokenid != zeroid) + if (tokenid == zeroid) total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); else total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); From 1fb94e5a34c63ae306cc2741fe77a0314e03a9b8 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 17:26:42 +0500 Subject: [PATCH 1195/3904] corr DecodeHeirEitherOpRet in validators added EVAL_TOKENS check in DecodeTokenOpRet --- src/cc/CCtokens.cpp | 3 ++ src/cc/heir.cpp | 100 ++++++++--------------------------------- src/cc/heir_validate.h | 94 +++++--------------------------------- 3 files changed, 33 insertions(+), 164 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index a95ef2dd8..242b0a38e 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -125,6 +125,9 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 bool isEof = true; evalCode = script[0]; + if (evalCode != EVAL_TOKENS) + return (uint8_t)0; + funcId = script[1]; //fprintf(stderr,"decode.[%c]\n",funcId); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 6fd98d545..c982fb193 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -125,23 +125,10 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenid = zeroid; CScript fundingTxOpRetScript; - uint8_t hasHeirSpendingBegun = 0, dummyHasHeirSpendingBegun; + uint8_t hasHeirSpendingBegun = 0, hasHeirSpendingBegunDummy; - - uint8_t evalCodeTokens = 0; - std::vector voutPubkeys; - std::vector vopretExtra; - - CScript heirScript = tx.vout[tx.vout.size() - 1].scriptPubKey; - int32_t heirType = HEIR_COINS; - - uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); - if (funcId != 0) { - heirScript = CScript(vopretExtra); - heirType = HEIR_TOKENS; - } - funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyHasHeirSpendingBegun, true); - + CScript opret = (tx.vout.size() > 0) ? tx.vout[tx.vout.size() - 1].scriptPubKey : CScript(); // check boundary + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, true); if (funcId == 0) return eval->Invalid("invalid opreturn format"); @@ -149,7 +136,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction if (fundingTxidInOpret == zeroid) { return eval->Invalid("invalid tx opreturn format: no fundingtxid present"); } - if (heirType == HEIR_COINS) + if (tokenid == zeroid) latestTxid = FindLatestFundingTx(fundingTxidInOpret, dummyTokenid, fundingTxOpRetScript, hasHeirSpendingBegun); else latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, hasHeirSpendingBegun); @@ -159,7 +146,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction } } else { - fundingTxOpRetScript = tx.vout[numvouts - 1].scriptPubKey; + fundingTxOpRetScript = opret; } std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << (int)cpHeir->evalcode << std::endl; @@ -185,7 +172,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction // vout.1: txfee for CC addr used as a marker // vout.2: normal change // vout.n-1: opreturn 't' tokenid 'F' ownerpk heirpk inactivitytime heirname tokenid - if (heirType == HEIR_TOKENS) + if (tokenid != zeroid) return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); else return eval->Invalid("unexpected HeirValidate for heirfund"); @@ -206,7 +193,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction // vout.0: funding CC 1of2 addr for the owner and heir // vout.1: normal change // vout.n-1: opreturn 't' tokenid 'A' ownerpk heirpk inactivitytime fundingtx - if (heirType == HEIR_TOKENS) + if (tokenid != zeroid) return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); else return eval->Invalid("unexpected HeirValidate for heiradd"); @@ -230,7 +217,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction // vout.1: change to CC 1of2 addr // vout.2: change to normal from txfee input if any // vout.n-1: opreturn 't' tokenid 'C' ownerpk heirpk inactivitytime fundingtx - if (heirType == HEIR_TOKENS) + if (tokenid != zeroid) return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); else return RunValidationPlans(funcId, cpHeir, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); @@ -267,44 +254,6 @@ template int64_t IsHeirFundingVout(struct CCcontract_info* cp, co return (0); } -// not used -bool HeirExactAmounts(struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, int32_t minage, uint64_t txfee) -{ - static uint256 zerohash; - CTransaction vinTx; - uint256 hashBlock, activehash; - int32_t i, numvins, numvouts; - int64_t inputs = 0, outputs = 0, assetoshis; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - for (i = 0; i < numvins; i++) { - //fprintf(stderr,"HeirExactAmounts() vini.%d\n",i); - if ((*cp->ismyvin)(tx.vin[i].scriptSig) != 0) { - //fprintf(stderr,"HeirExactAmounts() vini.%d check mempool\n",i); - if (eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) - return eval->Invalid("cant find vinTx"); - else { - //fprintf(stderr,"HeirExactAmounts() vini.%d check hash and vout\n",i); - if (hashBlock == zerohash) - return eval->Invalid("cant Heir from mempool"); - ////if ( (assetoshis= IsHeirCCvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) - //// inputs += assetoshis; - } - } - } - for (i = 0; i < numvouts; i++) { - //fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts); - ////if ( (assetoshis= IsHeirvout(cp,tx,i)) != 0 ) - //// outputs += assetoshis; - } - if (inputs != outputs + txfee) { - fprintf(stderr, "HeirExactAmounts() inputs %llu vs outputs %llu\n", (long long)inputs, (long long)outputs); - return eval->Invalid("mismatched inputs != outputs + txfee"); - } - else - return (true); -} - // makes coin initial tx opret CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { @@ -373,9 +322,8 @@ uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPub return (uint8_t)0; } -/** -* overload for 'F' opret -*/ +/* not used, see DecodeHeirOpRet(vopret,...) +// overload for 'F' opret uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { uint256 dummytxid; @@ -388,11 +336,11 @@ uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& hei return (uint8_t)0; } return _DecodeHeirOpRet(vopret, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); -} +}*/ -/** -* overload for A, C oprets and AddHeirContractInputs -*/ + +/* not used, see DecodeHeirOpRet(vopret,...) +// overload for A, C oprets and AddHeirContractInputs uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { CPubKey dummyOwnerPubkey, dummyHeirPubkey; @@ -407,7 +355,7 @@ uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8 } return _DecodeHeirOpRet(vopret, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); -} +} */ // decode combined opret: uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) @@ -473,8 +421,8 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { - CScript heirScript = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + CScript heirScript = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); if (funcId != 0) { // found at least funding tx! @@ -979,8 +927,6 @@ UniValue HeirClaimTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amoun return HeirClaim(fundingtxid, txfee, amount); } - - /** * heirinfo rpc call implementation * returns some information about heir CC contract plan by a handle of initial fundingtxid: @@ -1160,23 +1106,15 @@ template void _HeirList(struct CCcontract_info *cp, UniValue &r //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; CTransaction fundingtx; - if (GetTransaction(txid, fundingtx, hashBlock, false) != 0 && (fundingtx.vout.size() - 1) > 0) { + if (GetTransaction(txid, fundingtx, hashBlock, false)) { CPubKey ownerPubkey, heirPubkey; std::string heirName; int64_t inactivityTimeSec; const bool noLogging = true; - - uint8_t evalCodeTokens = 0; uint256 tokenid; - std::vector vopretExtra; - std::vector voutPubkeys; - CScript heirScript = fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey; - uint8_t funcId = DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra); - if (funcId != 0) { - heirScript = CScript(vopretExtra); - } - funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, noLogging); + CScript opret = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); // note: if it is not Heir token funcId would be equal to 0 if (funcId == 'F') { diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 5f56514d5..2bcc96b9e 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -4,29 +4,21 @@ #include "CCinclude.h" #include "CCHeir.h" -#define NOT_HEIR (-1) -#define HEIR_COINS 1 -#define HEIR_TOKENS 2 #define IS_CHARINSTR(c, str) (std::string(str).find((char)(c)) != std::string::npos) - // makes coin initial tx opret CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan); -// makes token opret -//CScript EncodeHeirTokensCreateOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string hearName); -//CScript EncodeHeirTokensOpRet(uint8_t funcid, uint256 tokenid, std::vector voutPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan); template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); -uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); -uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); -uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); -uint8_t DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t hasHeirSpendingBegun, bool noLogging = false); +//uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); +//uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging = false); inline static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } inline static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } - // helper class to allow polymorphic behaviour for HeirXXX() functions in case of coins class CoinHelper { public: @@ -411,22 +403,7 @@ public: std::string heirName; uint256 tokenid; - uint8_t evalCodeTokens = 0; - std::vector vopretExtra; - std::vector dummyVoutPubkeys; - - CScript heirScript = m_fundingOpretScript; - if (typeid(Helper) == typeid(TokenHelper)) { - if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { - heirScript = CScript(vopretExtra); - } - else { - message = m_customMessage + std::string(" invalid token opreturn format"); - std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; - return false; - } - } - uint8_t funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, false); + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); if (funcId == 0) { message = m_customMessage + std::string(" invalid opreturn format"); std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; @@ -481,28 +458,15 @@ public: ///std::cerr << "CMyPubkeyVoutValidator::validateVout() m_opRetScript=" << m_opRetScript.ToString() << std::endl; - uint8_t evalCodeTokens = 0; - std::vector vopretExtra; - std::vector dummyVoutPubkeys; - - CScript ownerScript; - CScript heirScript = m_fundingOpretScript; - if (typeid(Helper) == typeid(TokenHelper)) { - if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { - heirScript = CScript(vopretExtra); - } - else { - message = std::string("invalid token opreturn format"); - return false; - } - } // get both pubkeys: - uint8_t funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, false); + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); if (funcId == 0) { message = std::string("invalid opreturn format"); return false; } + CScript ownerScript; + CScript heirScript; if (m_checkNormals) { ownerScript = CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; heirScript = CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; @@ -552,22 +516,8 @@ public: std::string heirName; uint256 tokenid; - uint8_t evalCodeTokens = 0; - std::vector vopretExtra; - std::vector dummyVoutPubkeys; - - CScript heirScript = m_fundingOpretScript; - if (typeid(Helper) == typeid(TokenHelper)) { - if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { - heirScript = CScript(vopretExtra); - } else { - message = std::string("invalid token opreturn format"); - return false; - } - } - // get heir pubkey: - uint8_t funcId = DecodeHeirOpRet(heirScript, ownerPubkey, heirPubkey, inactivityTime, heirName, false); + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); if (funcId == 0) { message = std::string("invalid opreturn format"); return false; @@ -620,35 +570,13 @@ public: uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; uint8_t dummyIsHeirSpendingBegan; - uint8_t evalCodeTokens = 0; - std::vector vopretExtra; - std::vector dummyVoutPubkeys; - - CScript heirScript = vout.scriptPubKey; - if (typeid(Helper) == typeid(TokenHelper)) { - if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, dummyVoutPubkeys, vopretExtra) != 0) { - heirScript = CScript(vopretExtra); - } else { - message = std::string("invalid token opreturn format"); - return false; - } - } - uint8_t funcId = DecodeHeirOpRet(heirScript, fundingTxidInOpret, dummyIsHeirSpendingBegan); + uint8_t funcId = DecodeHeirEitherOpRet(vout.scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); if (funcId == 0) { message = std::string("invalid opreturn format"); return false; } - heirScript = m_fundingOpretScript; - if (typeid(Helper) == typeid(TokenHelper)) { - if (DecodeTokenOpRet(heirScript, evalCodeTokens, initialTokenid, dummyVoutPubkeys, vopretExtra) != 0) { - heirScript = CScript(vopretExtra); - } else { - message = std::string("invalid initial token opreturn format"); - return false; - } - } - uint8_t initialFuncId = DecodeHeirOpRet(heirScript, dummyTxid, dummyIsHeirSpendingBegan); + uint8_t initialFuncId = DecodeHeirEitherOpRet(m_fundingOpretScript, initialTokenid, dummyTxid, dummyIsHeirSpendingBegan, true); if (initialFuncId == 0) { message = std::string("invalid initial tx opreturn format"); return false; From fd0c4b89789cd99fc94b1e962291737607e4ef07 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 21:42:37 +0500 Subject: [PATCH 1196/3904] corr CCinit in HeirAdd HeirClaim --- src/cc/heir.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index c982fb193..1ed652efd 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -640,12 +640,12 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, int64_t inputs, change; if ((inputs=Helper::addOwnerInputs(cp, tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners - //mtx.vout.push_back(MakeCC1vout(EVAL_HEIR,amount,HeirCCpk)); - mtx.vout.push_back(MakeTokensCC1of2vout(/*Helper::getMyEval()*/EVAL_HEIR, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk + //mtx.vout.push_back(MakeTokensCC1of2vout(/*Helper::getMyEval()*/EVAL_HEIR, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk + mtx.vout.push_back(Helper::make1of2Vout(amount, myPubkey, heirPubkey)); // add a marker for finding all plans in HeirList() - CPubKey HeirContractPubKey = GetUnspendable(cp, 0); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(HeirContractPubKey)) << OP_CHECKSIG)); // TODO: do we need this marker? + CPubKey heirUnspendablePubKey = GetUnspendable(cp, 0); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); // TODO: do we need this marker? // calc and add change vout: if (inputs > amount) @@ -703,7 +703,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in uint8_t funcId; uint8_t hasHeirSpendingBegun = 0; - cp = CCinit(&C, EVAL_HEIR); + cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! if (txfee == 0) txfee = 10000; @@ -734,7 +734,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ // add cryptocondition to spend this funded amount for either pk - mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! + mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); if (inputs > amount) change = (inputs - amount); // -txfee <-- txfee pays user @@ -807,8 +807,8 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee std::string heirName; uint8_t hasHeirSpendingBegun = 0; - cp = CCinit(&C, EVAL_HEIR); - if (txfee == 0) + cp = CCinit(&C, Helper::getMyEval()); + if (txfee == 0) txfee = 10000; if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { @@ -882,11 +882,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee Helper::GetCoinsOrTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); Myprivkey(myprivkey); - ////fprintf(stderr,"HeirClaim() before setting unspendable CC addr2= (%s) addr3= (%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); - //CCaddr2set(cp, Helper::getMyEval(), ownerPubkey, myprivkey, coinaddr); - //CCaddr3set(cp, Helper::getMyEval(), heirPubkey, myprivkey, coinaddr); - ////fprintf(stderr, "HeirClaim() after setting unspendable CC addr2=(%s) addr3=(%s)\n", cp->unspendableaddr2, cp->unspendableaddr3); - + // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); // add 1of2 vout validation pubkeys (this is for tokens): From 99c5484b66643a047356df01ff1a36832b0f214f Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 22:04:50 +0500 Subject: [PATCH 1197/3904] corr cp usage in helper funcs --- src/cc/heir.cpp | 18 +++++++++--------- src/cc/heir_validate.h | 32 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 1ed652efd..97c89582f 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -517,7 +517,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, std::vector> unspentOutputs; char coinaddr[64]; - Helper::GetCoinsOrTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 of 2 pubkeys' + Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 of 2 pubkeys' SetCCunspents(unspentOutputs, coinaddr); // char markeraddr[64]; @@ -571,7 +571,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, template int64_t LifetimeHeirContractFunds(struct CCcontract_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) { char coinaddr[64]; - Helper::GetCoinsOrTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' + Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' std::vector> addressIndexes; SetCCtxids(addressIndexes, coinaddr); @@ -639,7 +639,7 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners int64_t inputs, change; - if ((inputs=Helper::addOwnerInputs(cp, tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners + if ((inputs=Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners //mtx.vout.push_back(MakeTokensCC1of2vout(/*Helper::getMyEval()*/EVAL_HEIR, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk mtx.vout.push_back(Helper::make1of2Vout(amount, myPubkey, heirPubkey)); @@ -724,7 +724,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in int64_t inputs, change; - if ((inputs = Helper::addOwnerInputs(cp, tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? + if ((inputs = Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? // we do not use markers anymore - storing data in opreturn is better // add marker vout: @@ -758,9 +758,9 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in result.push_back(Pair("hextx", rawhextx)); } else { - std::cerr << "HeirAdd cannot find owner inputs" << std::endl; + std::cerr << "HeirAdd cannot find owner cc inputs" << std::endl; result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find owner inputs")); + result.push_back(Pair("error", "can't find owner cc inputs")); } } else { @@ -879,11 +879,11 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee uint8_t myprivkey[32]; char coinaddr[64]; // set priv key addresses in CC structure: - Helper::GetCoinsOrTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); Myprivkey(myprivkey); // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: - Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + Helper::CCaddrCoinsOrTokens1of2set(ownerPubkey, heirPubkey, coinaddr); // add 1of2 vout validation pubkeys (this is for tokens): std::vector voutTokenPubkeys; @@ -1040,7 +1040,7 @@ UniValue HeirInfo(uint256 fundingtxid) stream.clear(); if (tokenid != zeroid) { - int64_t ownerInputs = TokenHelper::addOwnerInputs(cp, tokenid, mtx, ownerPubkey, 0, (int32_t)64); + int64_t ownerInputs = TokenHelper::addOwnerInputs(tokenid, mtx, ownerPubkey, 0, (int32_t)64); stream << ownerInputs; msg = "owner funding available in tokens"; result.push_back(Pair(msg, stream.str().c_str())); diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 2bcc96b9e..8f08a1588 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -24,7 +24,7 @@ class CoinHelper { public: static uint8_t getMyEval() { return EVAL_HEIR; } - static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { + static int64_t addOwnerInputs(uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); } @@ -46,11 +46,15 @@ public: static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } - static bool GetCoinsOrTokensCCaddress1of2(struct CCcontract_info* cp, char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - return GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { + struct CCcontract_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info* cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { - CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + static void CCaddrCoinsOrTokens1of2set(CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + struct CCcontract_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + CCaddr1of2set(cpHeir, ownerPubkey, heirPubkey, coinaddr); } }; @@ -58,8 +62,10 @@ public: class TokenHelper { public: static uint8_t getMyEval() { return EVAL_TOKENS; } - static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { - return AddTokenCCInputs(cp, mtx, ownerPubkey, tokenid, total, maxinputs); + static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { + struct CCcontract_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); } static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { @@ -84,12 +90,16 @@ public: static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { return MakeTokensCC1vout(EVAL_HEIR, amount, myPubkey); } - static bool GetCoinsOrTokensCCaddress1of2(struct CCcontract_info* cp, char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - return GetTokensCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); + static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { + struct CCcontract_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info* cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { - CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + static void CCaddrCoinsOrTokens1of2set(CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + struct CCcontract_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + CCaddrTokens1of2set(cpHeir, ownerPubkey, heirPubkey, coinaddr); } }; From 849d60f4d975b03641909489a0555f7771555d69 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 14 Jan 2019 22:11:24 +0500 Subject: [PATCH 1198/3904] eval changed back to EVAL_HEIR in CCinit in HeirAdd --- src/cc/heir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 97c89582f..c87f8155d 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -437,6 +437,7 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ return zeroid; } + // TODO: correct cc addr: std::vector> unspentOutputs; struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_HEIR); @@ -703,7 +704,8 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in uint8_t funcId; uint8_t hasHeirSpendingBegun = 0; - cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! + //cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! + cp = CCinit(&C, EVAL_HEIR); // for tokens shoud be EVAL_TOKENS to sign it correctly! if (txfee == 0) txfee = 10000; From ec954480a871ce38801ad641d047764e51499c70 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 11:59:53 +0500 Subject: [PATCH 1199/3904] added more variants checking vouts in IsTokenVout corr vouts1 in Heir.cpp to single-eval token changed result type for HeirFund --- src/cc/CCHeir.h | 4 +-- src/cc/CCinclude.h | 1 + src/cc/CCtokens.cpp | 66 ++++++++++++++++++++++++++++------------ src/cc/heir.cpp | 55 +++++++++++++++++++++++---------- src/cc/heir_validate.h | 24 +++++++-------- src/wallet/rpcwallet.cpp | 12 ++++---- 6 files changed, 106 insertions(+), 56 deletions(-) diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index 18d1f08bb..8399474a7 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -34,8 +34,8 @@ class TokenHelper; //template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount); //template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t nValue); -std::string HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); -std::string HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); +UniValue HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); +UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); UniValue HeirClaimCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); UniValue HeirClaimTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); UniValue HeirAddCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index c42a4799e..14a500222 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -162,6 +162,7 @@ CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload); CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 242b0a38e..d1dcf0b1f 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -51,14 +51,11 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector origpubkey,st } // this is for other contracts which use tokens and build customized extra payloads to token's opret: -CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload) +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload) { CScript opret; - - if (evalCodeInOpret != EVAL_TOKENS) { - std::cerr << "EncodeTokenOpRet() evalCode should be EVAL_TOKENS!" << std::endl; - return opret; // return empty - } + uint8_t tokenFuncId = 't'; + uint8_t evalCodeInOpret = EVAL_TOKENS; tokenid = revuint256(tokenid); @@ -93,6 +90,11 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t return opret; } +// overload for compatibility +CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload) +{ + return EncodeTokenOpRet(tokenid, voutPubkeys, payload); +} uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description) { @@ -405,35 +407,59 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c std::cerr << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl; //std::cerr << "IsTokensvout() vcontractOpret=" << HexStr(vcontractOpret) << std::endl;; - if (vopretExtra.size() < 2 /*|| vopretExtra.size() != vopretExtra.begin()[0]*/) { + uint8_t evalCodeInOpret; + if (vopretExtra.size() >= 2 /*|| vopretExtra.size() != vopretExtra.begin()[0] <-- shold we check this?*/) { std::cerr << "IsTokensvout() empty or incorrect contract opret" << std::endl; - return 0; + evalCodeInOpret = vopretExtra.begin()[1]; + } + else { + // if payload is empty maybe it is a claim to non-payload-one-token-eval vout? + evalCodeInOpret = EVAL_TOKENS; } - uint8_t evalCodeInOpret = vopretExtra.begin()[1]; - - if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { - CTxOut testVout; + // maybe this is dual-eval 1 pubkey or 1of2 pubkey vout? + if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { + CTxOut testDualVout; if (voutPubkeys.size() == 1) - testVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0]); + testDualVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0]); else // voutPubkeys.size() == 2 - testVout = MakeTokensCC1of2vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); + testDualVout = MakeTokensCC1of2vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); - if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { - std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { + if(voutPubkeys.size() == 1) + std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout, eval2=" << evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + else + std::cerr << indentStr << "IsTokensvout() this is dual-eval token 1of2 vout or change, eval2=" << evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } - // maybe it is token change? + // maybe this is claim to single-eval token? + if (voutPubkeys.size() == 1) { + CTxOut testTokenVout1; + testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]); + + if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() this is single-eval token vout, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + } + + // maybe it is single-eval or dual-eval token change? std::vector vinPubkeys; ExtractTokensVinPubkeys(tx, vinPubkeys); for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { - CTxOut testVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, *it); + CTxOut testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it); + CTxOut testDualVout1 = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, *it); - if (tx.vout[v].scriptPubKey == testVout.scriptPubKey) { - std::cerr << indentStr << "IsTokensvout() vout is EVAL_TOKENS change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() this is single-eval token change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + + if (tx.vout[v].scriptPubKey == testDualVout1.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() this is dual-eval token change, vout eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index c87f8155d..a1f8adfd3 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -619,8 +619,9 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info * and also for setting spending plan for the funds' owner and heir * @return fundingtxid handle for subsequent references to this heir funding plan */ -template std::string HeirFund(uint64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) +template UniValue HeirFund(uint64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { + UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); struct CCcontract_info *cp, C; @@ -664,24 +665,38 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, voutTokenPubkeys.push_back(heirPubkey); // add change for txfee and opreturn vouts and sign tx: - return (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName))); + std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName)); + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "sign error")); + } + } + else { // TODO: need result return unification with heiradd and claim + std::cerr << "HeirFund() could not find owner cc inputs" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find owner cc inputs")); } - else // TODO: need result return unification with heiradd and claim - std::cerr << "HeirFund() could not find owner inputs" << std::endl; - } - else + else { std::cerr << "HeirFund() could not find normal inputs" << std::endl; - return std::string(""); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find normal inputs")); + } + return result; } // if no these callers - it could not link -std::string HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ +UniValue HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); } -std::string HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { +UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); } @@ -735,8 +750,8 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ - // add cryptocondition to spend this funded amount for either pk - mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); + // add cryptocondition to spend this funded amount for either pk + mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); if (inputs > amount) change = (inputs - amount); // -txfee <-- txfee pays user @@ -756,8 +771,16 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); - result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "sign error")); + } + } else { std::cerr << "HeirAdd cannot find owner cc inputs" << std::endl; @@ -772,7 +795,7 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in } } else { - fprintf(stderr, "HeirAdd() can't find any heir CC funding tx's\n"); + fprintf(stderr, "HeirAdd can't find any heir CC funding tx's\n"); result.push_back(Pair("result", "error")); result.push_back(Pair("error", "can't find any heir CC funding transactions")); @@ -858,7 +881,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee }*/ // add vout with amount to claiming address - mtx.vout.push_back(Helper::makeClaimerVout(amount, myPubkey)); // vout[0] + mtx.vout.push_back(Helper::makeUserVout(amount, myPubkey)); // vout[0] // calc and add change vout: if (inputs > amount) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 8f08a1588..e9710a471 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -43,9 +43,9 @@ public: static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } - static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { +/* static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); - } + } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); @@ -64,20 +64,20 @@ public: static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { struct CCcontract_info *cpHeir, heirC; - cpHeir = CCinit(&heirC, EVAL_HEIR); + cpHeir = CCinit(&heirC, EVAL_TOKENS); return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); } static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return EncodeTokenOpRet((uint8_t)'t', EVAL_TOKENS, tokenid, voutTokenPubkeys, + return EncodeTokenOpRet(tokenid, voutTokenPubkeys, EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName)); } static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeTokenOpRet((uint8_t)'t', EVAL_TOKENS, tokenid, voutTokenPubkeys, + return EncodeTokenOpRet(tokenid, voutTokenPubkeys, EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan)); } static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeTokenOpRet((uint8_t)'t', EVAL_TOKENS, tokenid, voutTokenPubkeys, + return EncodeTokenOpRet(tokenid, voutTokenPubkeys, EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan)); } @@ -85,11 +85,11 @@ public: return MakeTokensCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); } static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { - return MakeTokensCC1vout(EVAL_HEIR, amount, myPubkey); - } - static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { - return MakeTokensCC1vout(EVAL_HEIR, amount, myPubkey); + return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS } +/* static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { + return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS + } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); @@ -477,7 +477,7 @@ public: CScript ownerScript; CScript heirScript; - if (m_checkNormals) { + if (m_checkNormals) { //not used, incorrect check, too strict ownerScript = CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; heirScript = CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout(coin,owner)=" << CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << " makeUserVout(coin,heir)=" << CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey.ToString() << std::endl; @@ -537,7 +537,7 @@ public: int64_t durationSec = CCduration(numblocks, m_latesttxid); // recreate scriptPubKey for heir and compare it with that of the vout: - if (vout.scriptPubKey == Helper::makeClaimerVout(vout.nValue, heirPubkey).scriptPubKey) { + if (vout.scriptPubKey == Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey) { // this is the heir is trying to spend if (!m_isHeirSpendingBegan && durationSec <= inactivityTime) { message = "heir is not allowed yet to spend funds"; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 847ddd921..82870c941 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7454,13 +7454,13 @@ UniValue heirfund(const UniValue& params, bool fHelp) inactivitytime = atof((char*)params[4].get_str().c_str()); - hex = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, zeroid); - if (hex.size() > 0) { + result = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, zeroid); +/* if (hex.size() > 0) { result.push_back(Pair("result", "success")); result.push_back(Pair("hex", hex)); } else - ERR_RESULT("couldn't create heir fund"); + ERR_RESULT("couldn't create heir fund");*/ return result; } @@ -7573,13 +7573,13 @@ UniValue heirfundtokens(const UniValue& params, bool fHelp) assetid = Parseuint256((char*)params[5].get_str().c_str()); - hex = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, assetid); - if (hex.size() > 0) { + result = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, assetid); +/* if (hex.size() > 0) { result.push_back(Pair("result", "success")); result.push_back(Pair("hex", hex)); } else - ERR_RESULT("couldn't create heir fund"); + ERR_RESULT("couldn't create heir fund");*/ return result; From 9e7b0314666af5a18e3df54c7bb6604fc6ab7543 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 12:25:21 +0500 Subject: [PATCH 1200/3904] corr ccinit in HeirAdd --- src/cc/heir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index a1f8adfd3..f3a3913a3 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -719,8 +719,8 @@ template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, in uint8_t funcId; uint8_t hasHeirSpendingBegun = 0; - //cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! - cp = CCinit(&C, EVAL_HEIR); // for tokens shoud be EVAL_TOKENS to sign it correctly! + cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! + //cp = CCinit(&C, EVAL_HEIR); // for tokens shoud be EVAL_TOKENS to sign it correctly! if (txfee == 0) txfee = 10000; From 46406f3c25e7649c20df82e5d7d5b1882025874b Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 13:06:06 +0500 Subject: [PATCH 1201/3904] corr CCinit in HeirClaim --- src/cc/CCtokens.cpp | 4 ++-- src/cc/heir.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index d1dcf0b1f..e54919155 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -427,9 +427,9 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { if(voutPubkeys.size() == 1) - std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout, eval2=" << evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout, eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; else - std::cerr << indentStr << "IsTokensvout() this is dual-eval token 1of2 vout or change, eval2=" << evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() this is dual-eval token 1of2 vout or change, eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } } diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index f3a3913a3..8ee5d7e07 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -832,7 +832,8 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee std::string heirName; uint8_t hasHeirSpendingBegun = 0; - cp = CCinit(&C, Helper::getMyEval()); + //cp = CCinit(&C, Helper::getMyEval()); + cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) txfee = 10000; @@ -919,8 +920,15 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : hasHeirSpendingBegun)); // forward isHeirSpending to the next latest tx - result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "sign error")); + } } else { fprintf(stderr, "HeirClaim() cant find Heir CC inputs\n"); From 395fac417354e3e62bed3787a98c303743bcd908 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 14:09:50 +0500 Subject: [PATCH 1202/3904] corr cp param to ...addr1of2set --- src/cc/heir.cpp | 2 +- src/cc/heir_validate.h | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 8ee5d7e07..9769f6f87 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -909,7 +909,7 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee Myprivkey(myprivkey); // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: - Helper::CCaddrCoinsOrTokens1of2set(ownerPubkey, heirPubkey, coinaddr); + Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); // add 1of2 vout validation pubkeys (this is for tokens): std::vector voutTokenPubkeys; diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index e9710a471..2ad905808 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -51,10 +51,8 @@ public: cpHeir = CCinit(&heirC, EVAL_HEIR); return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { - struct CCcontract_info *cpHeir, heirC; - cpHeir = CCinit(&heirC, EVAL_HEIR); - CCaddr1of2set(cpHeir, ownerPubkey, heirPubkey, coinaddr); + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } }; @@ -96,10 +94,9 @@ public: return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { - struct CCcontract_info *cpHeir, heirC; - cpHeir = CCinit(&heirC, EVAL_HEIR); - CCaddrTokens1of2set(cpHeir, ownerPubkey, heirPubkey, coinaddr); + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + + CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } }; From 96a653004460b16c8850e065bff0699e2fa230b2 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 14:24:58 +0500 Subject: [PATCH 1203/3904] corr getting 1of2 addr in 1of2 validator --- src/cc/heir.cpp | 6 ++++-- src/cc/heir_validate.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 9769f6f87..9ec8729e3 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -902,10 +902,12 @@ template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners std::cerr << "HeirClaim() adding markeraddr=" << markeraddr << '\n'; */ - uint8_t myprivkey[32]; + // get address of 1of2 cond char coinaddr[64]; - // set priv key addresses in CC structure: Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); + + // retrieve priv key addresses for FinalizeCCtx: + uint8_t myprivkey[32]; Myprivkey(myprivkey); // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 2ad905808..f091e1381 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -419,7 +419,9 @@ public: char shouldBeAddr[65], ccAddr[65]; - GetCCaddress1of2(m_cp, shouldBeAddr, ownerPubkey, heirPubkey); + //GetCCaddress1of2(m_cp, shouldBeAddr, ownerPubkey, heirPubkey); + Helper::GetCoinsOrTokensCCaddress1of2(shouldBeAddr, ownerPubkey, heirPubkey); + if (vout.scriptPubKey.IsPayToCryptoCondition()) { if (Getscriptaddress(ccAddr, vout.scriptPubKey) && strcmp(shouldBeAddr, ccAddr) == 0) { //std::cerr << "CCC1of2AddressValidator::validateVout() exits with true" << std::endl; From 2d8027854d1e1523145d796020e119e4df0d943e Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 16:22:14 +0500 Subject: [PATCH 1204/3904] first changes in assets for 2-eval vouts --- src/cc/CCassetsCore.cpp | 45 +++++++++++++---------------------------- src/cc/CCassetstx.cpp | 6 +++--- src/cc/CCinclude.h | 4 ++-- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 72404878d..09d0d8058 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -239,28 +239,23 @@ CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,st } */ -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey) +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey) { CScript opret; uint8_t evalcode = EVAL_ASSETS; - uint8_t funcId = (uint8_t)'t'; - uint8_t ccType = 0; - if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) - ccType = voutPubkeys.size(); - tokenid = revuint256(tokenid); switch ( assetFuncId ) { //case 't': this cannot be here case 'x': case 'o': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << ccType; if(ccType >= 1) ss << voutPubkeys[0]; if(ccType == 2) ss << voutPubkeys[1]; ss << assetFuncId); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << assetFuncId); break; case 's': case 'b': case 'S': case 'B': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << ccType; if(ccType >= 1) ss << voutPubkeys[0]; if(ccType == 2) ss << voutPubkeys[1]; ss << assetFuncId << price << origpubkey); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << assetFuncId << price << origpubkey); break; case 'E': case 'e': assetid2 = revuint256(assetid2); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcId << tokenid << ccType; if(ccType >= 1) ss << voutPubkeys[0]; if(ccType == 2) ss << voutPubkeys[1]; ss << assetFuncId << assetid2 << price << origpubkey); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << assetFuncId << assetid2 << price << origpubkey); break; default: fprintf(stderr,"EncodeAssetOpRet: illegal funcid.%02x\n", assetFuncId); @@ -270,7 +265,7 @@ CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, return(opret); } -// it is for compatibility, do not use this for new contracts (use DecodeTokenCreateOpRet) +/* it is for compatibility, do not use this for new contracts (use DecodeTokenCreateOpRet) bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description) { std::vector vopret; uint8_t evalcode,funcid,*script; @@ -282,9 +277,9 @@ bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &o return(true); } return(0); -} +} */ -uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) +uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) { std::vector vopretExtra; uint8_t *script, funcId = 0, assetFuncId = 0, dummyEvalCode, dummyAssetFuncId; @@ -298,7 +293,6 @@ uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, // First - decode token opret: funcId = DecodeTokenOpRet(scriptPubKey, evalCodeInOpret, tokenid, voutPubkeysDummy, vopretExtra); - /*GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); if (script == 0) { @@ -308,14 +302,14 @@ uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, //bool isEof = true; // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! //bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); - if (funcId == 0 || vopretExtra.size() == 0) { + if (funcId == 0 || vopretExtra.size() < 2) { std::cerr << "DecodeAssetOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretExtra.size()=" << vopretExtra.size() << std::endl; return (uint8_t)0; } ////tokenid = revuint256(tokenid); already done in DecodeToken! - - assetFuncId = vopretExtra.begin()[0]; + evalCodeInOpret = vopretExtra.begin()[0]; + assetFuncId = vopretExtra.begin()[1]; //std::cerr << "DecodeAssetOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; @@ -324,17 +318,6 @@ uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, //fprintf(stderr,"decode.[%c] assetFuncId.[%c]\n", funcId, assetFuncId); switch( assetFuncId ) { - /*case 'c': - return(funcid); - break; */ - /*case 't': - if (E_UNMARSHAL(vopret, ss >> evalCode; ss >> funcId; ss >> tokenid; isEof = ss.eof()) || !isEof) - { - assetid = revuint256(assetid); - return(funcid); - } - break; */ - case 'x': case 'o': if (vopretExtra.size() == 1) // no data after 'assetFuncId' allowed { @@ -369,7 +352,7 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT { uint256 assetid,assetid2; uint8_t evalCode; - if ( tx.vout.size() > 0 && DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey) != 0 ) + if ( tx.vout.size() > 0 && DecodeAssetTokenOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey) != 0 ) return(true); else return(false); @@ -382,7 +365,7 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,co uint8_t evalCode; n = tx.vout.size(); - if ( n == 0 || (funcid= DecodeAssetOpRet(tx.vout[n-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey)) == 0 ) + if ( n == 0 || (funcid= DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey)) == 0 ) return(false); if ( GetCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) return(true); @@ -432,7 +415,7 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout0 for buyvin"); - else if ((funcid = DecodeAssetOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey)) == 'b' && vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) // marker is only in 'b'? + else if ((funcid = DecodeAssetTokenOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey)) == 'b' && vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) // marker is only in 'b'? return eval->Invalid("invalid normal vout1 for buyvin"); else { @@ -470,7 +453,7 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr // this is just for log messages indentation fur debugging recursive calls: int32_t n = tx.vout.size(); - if ((funcid = DecodeAssetOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey)) == 0) + if ((funcid = DecodeAssetTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey)) == 0) { std::cerr << "ValidateAssetOpret() DecodeOpret returned null for n-1=" << n - 1 << " txid=" << tx.GetHash().GetHex() << std::endl; return(false); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 3047876f4..1531f6893 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -93,7 +93,7 @@ UniValue AssetOrders(uint256 refassetid) { // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); //std::cerr << "addOrders() vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl; - if (vintx.vout.size() > 0 && (funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) + if (vintx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) { if (refassetid != zero && assetid != refassetid) { @@ -486,7 +486,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets - if( DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 'b') + if( DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 'b') mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' (not 'B') // TODO: spend it also in FillBuyOffer? @@ -526,7 +526,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); - if (DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 's') + if (DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 's') mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' (not 'S') // TODO: spend it also in FillSell? diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 14a500222..b90e4ff6f 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -159,8 +159,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey); -bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); -uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); +//bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); +uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload); CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload); From a7d7451c88da73a7da9e0da5473be99f5547c979 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 16:28:39 +0500 Subject: [PATCH 1205/3904] corr call to DecodeAssetTokenOpRet --- src/cc/assets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index ea44453ff..aab0a234f 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -150,7 +150,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti outputs = inputs = 0; preventCCvins = preventCCvouts = -1; - if((funcid = DecodeAssetOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) + if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) return eval->Invalid("AssetValidate: invalid opreturn payload"); // find token user cc addr From 41da2aed5f8d9071883c424730dd66ff089c163c Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 16:54:36 +0500 Subject: [PATCH 1206/3904] corr call to EncodeAssetOpRet --- src/cc/CCassetstx.cpp | 16 ++++++++-------- src/cc/CCinclude.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 1531f6893..2661b1f29 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -328,7 +328,7 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); std::vector voutTokenPubkeys; // should be empty - no token vouts - return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('b', assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()))); + return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('b', zeroid, pricetotal, voutTokenPubkeys, Mypubkey()))); } CCerror = strprintf("no coins found to make buy offer"); return(""); @@ -380,7 +380,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(unspendablePubkey); - opret = EncodeAssetOpRet('s',assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); + opret = EncodeAssetOpRet('s', zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,opret)); } else { @@ -440,10 +440,10 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a std::vector voutTokenPubkeys; // should be empty - no token vouts if (assetid2 == zeroid) { - opret = EncodeAssetOpRet('s', assetid, zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); + opret = EncodeAssetOpRet('s', zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); } else { - opret = EncodeAssetOpRet('e', assetid, assetid2, pricetotal, voutTokenPubkeys, Mypubkey()); + opret = EncodeAssetOpRet('e', assetid2, pricetotal, voutTokenPubkeys, Mypubkey()); } return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); } @@ -495,7 +495,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) std::vector voutTokenPubkeys; // should be empty, no tokens vout - return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('o', assetid, zeroid, 0, voutTokenPubkeys, Mypubkey()))); + return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('o', zeroid, 0, voutTokenPubkeys, Mypubkey()))); } } return(""); @@ -542,7 +542,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) GetCCaddress(cpAssets, myCCaddr, mypk); CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); //do we need this? Seems FinalizeCCTx can attach to any evalcode cc addr by calling Getscriptaddress - return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', assetid, zeroid, 0, voutTokenPubkeys, Mypubkey()))); + return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', zeroid, 0, voutTokenPubkeys, Mypubkey()))); } } return(""); @@ -620,7 +620,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(pubkey2pk(origpubkey)); - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, EncodeAssetOpRet('B', assetid, zeroid, remaining_required, voutTokenPubkeys, origpubkey))); + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, EncodeAssetOpRet('B', zeroid, remaining_required, voutTokenPubkeys, origpubkey))); } else return("dont have any assets to fill bid"); } } @@ -722,7 +722,7 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(mypk); - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid, assetid2, remaining_nValue, voutTokenPubkeys, origpubkey))); + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid2, remaining_nValue, voutTokenPubkeys, origpubkey))); } else { CCerror = strprintf("filltx not enough utxos"); fprintf(stderr,"%s\n", CCerror.c_str()); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index b90e4ff6f..170961340 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -158,7 +158,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector &origpubkey,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey); +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey); //bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); From 4379cffe74a0f19c078d4af9a865a27fcba84389 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 17:01:42 +0500 Subject: [PATCH 1207/3904] corr call to EncodeAssetOpet in prices.cpp --- src/cc/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 9ba6d4a84..bda7248ea 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -328,7 +328,7 @@ std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingt // add addr2 std::vector voutTokenPubkeysEmpty; //TODO: add token vout pubkeys - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',bettoken,zeroid,0, voutTokenPubkeysEmpty, Mypubkey()))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',/*bettoken,*/zeroid,0, voutTokenPubkeysEmpty, Mypubkey()))); } else { From 8d8b253138bba7d1f5820b372bf56eab3a12a808 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 20:55:26 +0500 Subject: [PATCH 1208/3904] first time changed eval usage and MakeTokenCCcond.. for assets --- src/cc/CCassetsCore.cpp | 2 +- src/cc/CCassetstx.cpp | 114 ++++++++++++++++++++++++---------------- src/cc/CCinclude.h | 2 +- src/cc/CCtx.cpp | 2 +- src/cc/heir.cpp | 1 + src/cc/prices.cpp | 4 +- 6 files changed, 77 insertions(+), 48 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 09d0d8058..9bd17cef8 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -239,7 +239,7 @@ CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,st } */ -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey) +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey) { CScript opret; uint8_t evalcode = EVAL_ASSETS; diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 2661b1f29..8dcde6e12 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -328,7 +328,9 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); std::vector voutTokenPubkeys; // should be empty - no token vouts - return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('b', zeroid, pricetotal, voutTokenPubkeys, Mypubkey()))); + return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, + EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('b', zeroid, pricetotal, Mypubkey())))); } CCerror = strprintf("no coins found to make buy offer"); return(""); @@ -342,7 +344,8 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p uint64_t mask; int64_t inputs, CCchange; CScript opret; - struct CCcontract_info *cpTokens,C; + struct CCcontract_info *cpAssets, assetsC; + struct CCcontract_info *cpTokens, tokensC; //std::cerr << "CreateSell() askamount=" << askamount << " pricetotal=" << pricetotal << std::endl; @@ -351,8 +354,8 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return(""); } - cpTokens = CCinit(&C, EVAL_TOKENS); // NOTE: tokens is here - + cpAssets = CCinit(&assetsC, EVAL_ASSETS); // NOTE: this is for signing + if (txfee == 0) txfee = 10000; @@ -360,6 +363,8 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); + // add single-eval tokens: + cpTokens = CCinit(&tokensC, EVAL_TOKENS); // NOTE: tokens is here if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, askamount, 60)) > 0) { if (inputs < askamount) { @@ -369,19 +374,20 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return (""); } - CPubKey unspendablePubkey = GetUnspendable(cpTokens, 0); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, unspendablePubkey)); + CPubKey unspendablePubkey = GetUnspendable(cpAssets, NULL); + mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, askamount, unspendablePubkey)); mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); //marker if (inputs > askamount) CCchange = (inputs - askamount); if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // change to single-eval token vout std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(unspendablePubkey); - opret = EncodeAssetOpRet('s', zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,opret)); + opret = EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('s', zeroid, pricetotal, Mypubkey())); + return(FinalizeCCTx(mask,cpAssets, mtx, mypk, txfee, opret)); } else { fprintf(stderr, "need some tokens to place ask\n"); @@ -399,10 +405,10 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; - ////////////////////////////////////////// + ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// fprintf(stderr,"asset swaps disabled\n"); return(""); - ////////////////////////////////////////// + ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// if ( askamount < 0 || pricetotal < 0 ) { @@ -413,7 +419,7 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a if ( txfee == 0 ) txfee = 10000; - + ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// mypk = pubkey2pk(Mypubkey()); if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) @@ -421,13 +427,14 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a mask = ~((1LL << mtx.vin.size()) - 1); if ((inputs = AddAssetInputs(cp, mtx, mypk, assetid, askamount, 60)) > 0) { + ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// if (inputs < askamount) { //was: askamount = inputs; std::cerr << "CreateSwap(): insufficient tokens for ask" << std::endl; CCerror = strprintf("insufficient tokens for ask"); return (""); } - + ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// CPubKey unspendablePubkey = GetUnspendable(cp, 0); mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, askamount, unspendablePubkey)); @@ -436,15 +443,18 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a if (CCchange != 0) mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); - + ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// std::vector voutTokenPubkeys; // should be empty - no token vouts if (assetid2 == zeroid) { - opret = EncodeAssetOpRet('s', zeroid, pricetotal, voutTokenPubkeys, Mypubkey()); + opret = EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('s', zeroid, pricetotal, Mypubkey())); } else { - opret = EncodeAssetOpRet('e', assetid2, pricetotal, voutTokenPubkeys, Mypubkey()); + opret = EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('e', assetid2, pricetotal, Mypubkey())); } + ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); } else { @@ -493,9 +503,11 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - std::vector voutTokenPubkeys; // should be empty, no tokens vout + std::vector voutTokenPubkeys; // should be empty, no token vouts - return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeAssetOpRet('o', zeroid, 0, voutTokenPubkeys, Mypubkey()))); + return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, + EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('o', zeroid, 0, Mypubkey())))); } } return(""); @@ -505,13 +517,15 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; - struct CCcontract_info *cpTokens,*cpAssets,C,assetsC; + CTransaction vintx; uint64_t mask; + uint256 hashBlock; + int64_t askamount; + CPubKey mypk; + struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; - cpTokens = CCinit(&C, EVAL_TOKENS); - cpAssets = CCinit(&assetsC, EVAL_ASSETS); + cpTokens = CCinit(&tokensC, EVAL_TOKENS); if (txfee == 0) txfee = 10000; @@ -530,7 +544,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' (not 'S') // TODO: spend it also in FillSell? - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); // one-eval token vout mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); std::vector voutTokenPubkeys; @@ -539,10 +553,15 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) char myCCaddr[65]; uint8_t myPrivkey[32]; Myprivkey(myPrivkey); + cpAssets = CCinit(&assetsC, EVAL_ASSETS); GetCCaddress(cpAssets, myCCaddr, mypk); - CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); //do we need this? Seems FinalizeCCTx can attach to any evalcode cc addr by calling Getscriptaddress - return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeAssetOpRet('x', zeroid, 0, voutTokenPubkeys, Mypubkey()))); + // this is only for unspendable addresses: + //CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); //do we need this? Seems FinalizeCCTx can attach to any evalcode cc addr by calling Getscriptaddress + + return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, + EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('x', zeroid, 0, Mypubkey())))); } } return(""); @@ -568,7 +587,6 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f return(""); } cpTokens = CCinit(&tokensC, EVAL_TOKENS); - cpAssets = CCinit(&assetsC, EVAL_ASSETS); if (txfee == 0) txfee = 10000; @@ -598,21 +616,24 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f if (inputs > fillamount) CCchange = (inputs - fillamount); - CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); + //CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); uint8_t unspendableAssetsPrivkey[32]; + cpTokens = CCinit(&assetsC, EVAL_ASSETS); CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // 0 coins remainder - mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); // 1 coins to normal - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // 2 tokens paid + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder + mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); // vout1 coins to normal + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // vout2 single-eval tokens paid if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // 3 change in tokens + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // vout3 change in single-eval tokens - fprintf(stderr,"remaining %llu -> origpubkey\n", (long long)remaining_required); + fprintf(stderr,"FillBuyOffer remaining %llu -> origpubkey\n", (long long)remaining_required); char unspendableAssetsAddr[64]; + cpAssets = CCinit(&assetsC, EVAL_ASSETS); GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); + // add additional unspendable addr from Assets: CCaddr2set(cpTokens, EVAL_ASSETS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); @@ -620,7 +641,9 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(pubkey2pk(origpubkey)); - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, EncodeAssetOpRet('B', zeroid, remaining_required, voutTokenPubkeys, origpubkey))); + return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, + EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('B', zeroid, remaining_required, origpubkey)))); } else return("dont have any assets to fill bid"); } } @@ -637,10 +660,10 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt CPubKey mypk; std::vector origpubkey; double dprice; - uint64_t mask; - int32_t askvout=0; + uint64_t mask = 0; + int32_t askvout = 0; int64_t received_assetoshis, total_nValue, orig_assetoshis, paid_nValue, remaining_nValue, inputs, CCchange=0; - struct CCcontract_info *cpTokens, tokensC; + //struct CCcontract_info *cpTokens, tokensC; struct CCcontract_info *cpAssets, assetsC; if (fillunits < 0) @@ -656,8 +679,7 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt return(""); } - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - cpAssets = CCinit(&assetsC, EVAL_ASSETS); + cpAssets = CCinit(&assetsC, EVAL_ASSETS); if (txfee == 0) txfee = 10000; @@ -676,7 +698,7 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt mtx.vin.push_back(CTxIn(asktxid, askvout, CScript())); // NOTE: this is the reference to tokens -> send cpTokens for signing into FinalizeCCTx! if (assetid2 != zeroid) - inputs = AddAssetInputs(cpTokens, mtx, mypk, assetid2, paid_nValue, 60); // not implemented yet + inputs = AddAssetInputs(cpAssets, mtx, mypk, assetid2, paid_nValue, 60); // not implemented yet else { inputs = AddNormalinputs(mtx, mypk, paid_nValue, 60); @@ -698,14 +720,15 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt if (assetid2 != zeroid && inputs > paid_nValue) CCchange = (inputs - paid_nValue); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, orig_assetoshis - received_assetoshis, GetUnspendable(cpTokens, NULL))); // vout.0 tokens cc addr - ask remainder - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); //vout.1 tokens to self + mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // vout.0 tokens cc addr - ask remainder + mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, received_assetoshis, mypk)); //vout.1 tokens to self // NOTE: no marker here if (assetid2 != zeroid) { std::cerr << "FillSell() WARNING: asset swap not implemented yet! (paid_nValue)" << std::endl; - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //vout.2 tokens... (swap is not implemented yet) + // TODO: change MakeCC1vout appropriately when implementing: + //mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //vout.2 tokens... (swap is not implemented yet) } else { //std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl; @@ -715,14 +738,17 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt // not implemented if (CCchange != 0) { std::cerr << "FillSell() WARNING: asset swap not implemented yet! (CCchange)" << std::endl; - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //vout.3 coins in Assets cc addr + // TODO: change MakeCC1vout appropriately when implementing: + //mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //vout.3 coins in Assets cc addr (swap not implemented) } // vout verification pubkeys: std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(mypk); - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee,EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid2, remaining_nValue, voutTokenPubkeys, origpubkey))); + return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, + EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid2, remaining_nValue, origpubkey)))); } else { CCerror = strprintf("filltx not enough utxos"); fprintf(stderr,"%s\n", CCerror.c_str()); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 170961340..03af2f92d 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -158,7 +158,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector &origpubkey,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector voutPubkeys, std::vector origpubkey); +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); //bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 29e1fe0ab..630f37dca 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -65,7 +65,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran GetCCaddress(cp,myaddr,mypk); mycond = MakeCCcond1(cp->evalcode,mypk); - GetTokensCCaddress(cp, myaddr, mypk); + GetTokensCCaddress(cp, mytokensaddr, mypk); mytokenscond = MakeTokensCCcond1(cp->evalcode, mypk); unspendablepk = GetUnspendable(cp,unspendablepriv); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 9ec8729e3..48dc543ab 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -646,6 +646,7 @@ template UniValue HeirFund(uint64_t txfee, int64_t amount, std mtx.vout.push_back(Helper::make1of2Vout(amount, myPubkey, heirPubkey)); // add a marker for finding all plans in HeirList() + // TODO: change marker either to cc or normal txidaddr unspendable CPubKey heirUnspendablePubKey = GetUnspendable(cp, 0); mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); // TODO: do we need this marker? diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index bda7248ea..369495b1a 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -328,7 +328,9 @@ std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingt // add addr2 std::vector voutTokenPubkeysEmpty; //TODO: add token vout pubkeys - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',/*bettoken,*/zeroid,0, voutTokenPubkeysEmpty, Mypubkey()))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee, + EncodeTokenOpRet(bettoken, voutTokenPubkeysEmpty, + EncodeAssetOpRet('t',/*bettoken,*/zeroid, 0, Mypubkey())))); } else { From ffba12b55b211edbececc3016e96a81d6c6ea5c2 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 21:17:51 +0500 Subject: [PATCH 1209/3904] added single-eval token cond to FinalizeCCtx --- src/cc/CCtx.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 630f37dca..7640b35bb 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -43,10 +43,12 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; - int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64],mytokensaddr[64]; - uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL; + int32_t i,utxovout,n,err = 0; + char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64]; + uint8_t *privkey, myprivkey[32], unspendablepriv[32], *msg32 = 0; + CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL; CPubKey unspendablepk; + struct CCcontract_info *cpTokens, tokensC; n = mtx.vout.size(); for (i=0; ievalcode, mypk); + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + GetCCaddress(cpTokens, mysingletokensaddr, mypk); + mysingletokenscond = MakeCCcond1(cpTokens->evalcode, mypk); + unspendablepk = GetUnspendable(cp,unspendablepriv); GetCCaddress(cp,unspendable,unspendablepk); othercond = MakeCCcond1(cp->evalcode,unspendablepk); @@ -149,6 +155,12 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cond = mytokenscond; fprintf(stderr,"FinalizeCCTx() matched TokensCC1vout CC addr.(%s)\n",mytokensaddr); } + else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout + { + privkey = myprivkey; + cond = mysingletokenscond; + fprintf(stderr, "FinalizeCCTx() matched single-eval TokensCC1vout CC addr.(%s)\n", mytokensaddr); + } else if ( strcmp(destaddr,unspendable) == 0 ) { privkey = unspendablepriv; From 114d7779d6402403971ec04e056f3263c4b0a1ae Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 23:23:49 +0500 Subject: [PATCH 1210/3904] added support for 2 check pubkeys in IsTokenVout --- src/cc/CCtokens.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index e54919155..7296beaf2 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -420,18 +420,28 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // maybe this is dual-eval 1 pubkey or 1of2 pubkey vout? if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { CTxOut testDualVout; - if (voutPubkeys.size() == 1) - testDualVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0]); - else // voutPubkeys.size() == 2 - testDualVout = MakeTokensCC1of2vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); - + // check dual-eval 1 pubkey vout with the first pubkey + testDualVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0]); if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { - if(voutPubkeys.size() == 1) - std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout, eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - else - std::cerr << indentStr << "IsTokensvout() this is dual-eval token 1of2 vout or change, eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() this is one-eval token vout (i=0), eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } + + if(voutPubkeys.size() == 2) { + // check dual eval 1of2 pubkeys vout + testDualVout = MakeTokensCC1of2vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); + if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() this is dual-eval token 1of2 vout, eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + + // check dual eval 1 pubkey vout with the second pubkey + testDualVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[1]); + if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout (i=1), eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + } } // maybe this is claim to single-eval token? From c66787ada63fee0274dcf14510f13faae4f65388 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 23:39:04 +0500 Subject: [PATCH 1211/3904] added support for 2 check pubkeys for single-eval token vouts --- src/cc/CCtokens.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 7296beaf2..5d25bdbaa 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -442,17 +442,23 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c return tx.vout[v].nValue; } } - } + - // maybe this is claim to single-eval token? - if (voutPubkeys.size() == 1) { + // maybe this is claim to single-eval token? CTxOut testTokenVout1; testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]); - if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) { - std::cerr << indentStr << "IsTokensvout() this is single-eval token vout, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() this is single-eval token vout (i=0), returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } + + if (voutPubkeys.size() == 2) { + testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[1]); + if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) { + std::cerr << indentStr << "IsTokensvout() this is single-eval token vout (i=1), returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + return tx.vout[v].nValue; + } + } } // maybe it is single-eval or dual-eval token change? From dddda4e32b7132f5354fd3e69788883ed05ef4c7 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 15 Jan 2019 23:44:13 +0500 Subject: [PATCH 1212/3904] corr logging in IsTokensVout --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 5d25bdbaa..48172971f 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -423,7 +423,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // check dual-eval 1 pubkey vout with the first pubkey testDualVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0]); if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { - std::cerr << indentStr << "IsTokensvout() this is one-eval token vout (i=0), eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout (i=0), eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; return tx.vout[v].nValue; } From ee848abde90130b90823e90e9b2e666d26748469 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 11:45:21 +0500 Subject: [PATCH 1213/3904] corr mysingletokenscond in FinalizeCCtx (corr err message in rpc call) --- src/cc/CCtx.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 7640b35bb..e3688b3bf 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -72,7 +72,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cpTokens = CCinit(&tokensC, EVAL_TOKENS); GetCCaddress(cpTokens, mysingletokensaddr, mypk); - mysingletokenscond = MakeCCcond1(cpTokens->evalcode, mypk); + mysingletokenscond = MakeCCcond1(EVAL_TOKENS, mypk); unspendablepk = GetUnspendable(cp,unspendablepriv); GetCCaddress(cp,unspendable,unspendablepk); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 82870c941..6bc267e0f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7346,7 +7346,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) result.push_back(Pair("result", "success")); result.push_back(Pair("hex", hex)); } else { - ERR_RESULT("couldnt fill bid"); + ERR_RESULT("couldnt fill ask"); } } else { ERR_RESULT("fillunits must be positive"); From a7833f272f420041f6fe2b331798410f6a9b23c8 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 12:12:41 +0500 Subject: [PATCH 1214/3904] added othertokenscond to FinalizeCCtx --- src/cc/CCassetstx.cpp | 11 ++++++++++- src/cc/CCtx.cpp | 21 +++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 8dcde6e12..69a1b0c6f 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -618,7 +618,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f //CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); uint8_t unspendableAssetsPrivkey[32]; - cpTokens = CCinit(&assetsC, EVAL_ASSETS); + cpTokens = CCinit(&assetsC, EVAL_ASSETS); //??? CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder @@ -742,6 +742,15 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt //mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //vout.3 coins in Assets cc addr (swap not implemented) } + uint8_t unspendableAssetsPrivkey[32]; + char unspendableAssetsAddr[64]; + // init 'unspenable' privkey and pubkey + CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); + GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); + + // add additional unspendable addr from Assets: + CCaddr2set(cpAssets, EVAL_ASSETS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); + // vout verification pubkeys: std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(mypk); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index e3688b3bf..46395815e 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -44,9 +44,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,utxovout,n,err = 0; - char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64]; + char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], tokensunspendable[64]; uint8_t *privkey, myprivkey[32], unspendablepriv[32], *msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL; + CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CPubKey unspendablepk; struct CCcontract_info *cpTokens, tokensC; @@ -74,9 +74,12 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran GetCCaddress(cpTokens, mysingletokensaddr, mypk); mysingletokenscond = MakeCCcond1(EVAL_TOKENS, mypk); - unspendablepk = GetUnspendable(cp,unspendablepriv); - GetCCaddress(cp,unspendable,unspendablepk); - othercond = MakeCCcond1(cp->evalcode,unspendablepk); + unspendablepk = GetUnspendable(cp, unspendablepriv); + GetCCaddress(cp, unspendable, unspendablepk); + othercond = MakeCCcond1(cp->evalcode, unspendablepk); + + GetTokensCCaddress(cp, tokensunspendable, unspendablepk); + othertokenscond = MakeTokensCCcond1(cp->evalcode, unspendablepk); //Reorder vins so that for multiple normal vins all other except vin0 goes to the end //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. @@ -165,8 +168,14 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"FinalizeCCTx() unspendable CC addr.(%s)\n",unspendable); + //fprintf(stderr,"FinalizeCCTx() matched unspendable CC addr.(%s)\n",unspendable); } + else if (strcmp(destaddr, tokensunspendable) == 0) + { + privkey = unspendablepriv; + cond = othertokenscond; + fprintf(stderr,"FinalizeCCTx() matched tokensunspendable CC addr.(%s)\n",unspendable); + } // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr2) == 0) { From 406fc539257e26d65206a66111538f189fc613a5 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 12:17:35 +0500 Subject: [PATCH 1215/3904] removed extra CCaddr2set --- src/cc/CCassetstx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 69a1b0c6f..fc026d158 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -742,14 +742,14 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt //mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //vout.3 coins in Assets cc addr (swap not implemented) } - uint8_t unspendableAssetsPrivkey[32]; + /* uint8_t unspendableAssetsPrivkey[32]; char unspendableAssetsAddr[64]; // init 'unspenable' privkey and pubkey CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); // add additional unspendable addr from Assets: - CCaddr2set(cpAssets, EVAL_ASSETS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); + CCaddr2set(cpAssets, EVAL_ASSETS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr);*/ // vout verification pubkeys: std::vector voutTokenPubkeys; From 4903298fc311fcacdca6f728e09a63ff21c8c013 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 14:11:29 +0500 Subject: [PATCH 1216/3904] corr tokesnunspenable priv and pk --- src/cc/CCtx.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 46395815e..56cc8a9ef 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -45,9 +45,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,utxovout,n,err = 0; char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], tokensunspendable[64]; - uint8_t *privkey, myprivkey[32], unspendablepriv[32], *msg32 = 0; + uint8_t *privkey, myprivkey[32], unspendablepriv[32], tokensunspendablepriv[32], *msg32 = 0; CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; - CPubKey unspendablepk; + CPubKey unspendablepk, tokensunspendablepk; struct CCcontract_info *cpTokens, tokensC; n = mtx.vout.size(); @@ -78,8 +78,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran GetCCaddress(cp, unspendable, unspendablepk); othercond = MakeCCcond1(cp->evalcode, unspendablepk); - GetTokensCCaddress(cp, tokensunspendable, unspendablepk); - othertokenscond = MakeTokensCCcond1(cp->evalcode, unspendablepk); + tokensunspendablepk = GetUnspendable(cpTokens, tokensunspendablepriv); + GetTokensCCaddress(cp, tokensunspendable, tokensunspendablepk); + othertokenscond = MakeTokensCCcond1(cp->evalcode, tokensunspendablepk); //Reorder vins so that for multiple normal vins all other except vin0 goes to the end //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. From a16e80dac45cfbcc7df7b1ed8f8458dba9d1dbaa Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 14:22:23 +0500 Subject: [PATCH 1217/3904] more corr in tokensunspendable --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 56cc8a9ef..0463bf7c3 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -79,7 +79,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran othercond = MakeCCcond1(cp->evalcode, unspendablepk); tokensunspendablepk = GetUnspendable(cpTokens, tokensunspendablepriv); - GetTokensCCaddress(cp, tokensunspendable, tokensunspendablepk); + GetCCaddress(cpTokens, tokensunspendable, tokensunspendablepk); othertokenscond = MakeTokensCCcond1(cp->evalcode, tokensunspendablepk); //Reorder vins so that for multiple normal vins all other except vin0 goes to the end From f67a849be0bfdb7f78116ab74f96a81ae016e1ba Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 14:27:45 +0500 Subject: [PATCH 1218/3904] corr CCaddr2set for tokens support in FillSell --- src/cc/CCassetstx.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index fc026d158..39a58146b 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -742,14 +742,14 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt //mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, CCchange, mypk)); //vout.3 coins in Assets cc addr (swap not implemented) } - /* uint8_t unspendableAssetsPrivkey[32]; + uint8_t unspendableAssetsPrivkey[32]; char unspendableAssetsAddr[64]; // init 'unspenable' privkey and pubkey CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); - // add additional unspendable addr from Assets: - CCaddr2set(cpAssets, EVAL_ASSETS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr);*/ + // add additional dual-eval (assets+tokens) unspendable assets address's privkey: + CCaddr2set(cpAssets, EVAL_TOKENS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); // vout verification pubkeys: std::vector voutTokenPubkeys; From 457b9aff54e581c4aaa24c305f37b535885dafec Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 14:41:39 +0500 Subject: [PATCH 1219/3904] more corr othertokenscond, set cp->unspendable --- src/cc/CCtx.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 0463bf7c3..2959ba7d7 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -47,7 +47,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], tokensunspendable[64]; uint8_t *privkey, myprivkey[32], unspendablepriv[32], tokensunspendablepriv[32], *msg32 = 0; CC *mycond=0, *othercond=0, *othercond2=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; - CPubKey unspendablepk, tokensunspendablepk; + CPubKey unspendablepk /*, tokensunspendablepk*/; struct CCcontract_info *cpTokens, tokensC; n = mtx.vout.size(); @@ -66,21 +66,27 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran GetCCaddress(cp,myaddr,mypk); mycond = MakeCCcond1(cp->evalcode,mypk); - + + // to spend from single-eval evalcode 'unspendable' + unspendablepk = GetUnspendable(cp, unspendablepriv); + GetCCaddress(cp, unspendable, unspendablepk); + othercond = MakeCCcond1(cp->evalcode, unspendablepk); + + // tokens support: + + // to spend from dual-eval mypk vout GetTokensCCaddress(cp, mytokensaddr, mypk); mytokenscond = MakeTokensCCcond1(cp->evalcode, mypk); + // to spend from single-eval EVAL_TOKENS mypk cpTokens = CCinit(&tokensC, EVAL_TOKENS); GetCCaddress(cpTokens, mysingletokensaddr, mypk); mysingletokenscond = MakeCCcond1(EVAL_TOKENS, mypk); - unspendablepk = GetUnspendable(cp, unspendablepriv); - GetCCaddress(cp, unspendable, unspendablepk); - othercond = MakeCCcond1(cp->evalcode, unspendablepk); - - tokensunspendablepk = GetUnspendable(cpTokens, tokensunspendablepriv); - GetCCaddress(cpTokens, tokensunspendable, tokensunspendablepk); - othertokenscond = MakeTokensCCcond1(cp->evalcode, tokensunspendablepk); + // to spend from dual-eval EVAL_TOKEN+evalcode 'unspendable' pk + //tokensunspendablepk = GetUnspendable(cpTokens, tokensunspendablepriv); + GetTokensCCaddress(cp, tokensunspendable, unspendablepk); + othertokenscond = MakeTokensCCcond1(cp->evalcode, unspendablepk); //Reorder vins so that for multiple normal vins all other except vin0 goes to the end //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. @@ -147,7 +153,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); - std::cerr << "FinalizeCCtx() destaddr=" << destaddr << " myaddr=" << myaddr << std::endl; + std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " myaddr=" << myaddr << std::endl; if( strcmp(destaddr,myaddr) == 0 ) { privkey = myprivkey; From 029d3af05aefdc04d8862ef8ea81afb0f1431638 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 15:16:30 +0500 Subject: [PATCH 1220/3904] add logging origpubkey to FillSell --- src/cc/CCassetstx.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 39a58146b..5b21fc1b1 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -652,7 +652,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f // send coins, receive tokens -std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 asktxid,int64_t fillunits) +std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 asktxid, int64_t fillunits) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction vintx,filltx; @@ -685,7 +685,7 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx,mypk,txfee,3) > 0) + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) @@ -731,7 +731,7 @@ std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 askt //mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //vout.2 tokens... (swap is not implemented yet) } else { - //std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl; + std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl; mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //vout.2 coins normal to whom who asked token } From b807d8eb29b8a0eb2b74e3bc2e32ba3456193c8e Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 15:29:39 +0500 Subject: [PATCH 1221/3904] corr dummy evalcode in DecodeAssetTokenOpRet --- src/cc/CCassetsCore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 9bd17cef8..09806a96c 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -325,14 +325,14 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOp } break; case 's': case 'b': case 'S': case 'B': - if (E_UNMARSHAL(vopretExtra, ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) + if (E_UNMARSHAL(vopretExtra, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) { //fprintf(stderr,"got price %llu\n",(long long)price); return(assetFuncId); } break; case 'E': case 'e': - if ( E_UNMARSHAL(vopretExtra, ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) + if ( E_UNMARSHAL(vopretExtra, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) { //fprintf(stderr,"got price %llu\n",(long long)price); assetid2 = revuint256(assetid2); From 830b54cf20fa8bd68436129a9128a2ed4079bff6 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 17:45:32 +0500 Subject: [PATCH 1222/3904] corr unmarshal vopretStripped --- src/cc/CCassetsCore.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 09806a96c..a7ca074db 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -281,7 +281,7 @@ bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &o uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) { - std::vector vopretExtra; + std::vector vopretExtra, vopretStripped; uint8_t *script, funcId = 0, assetFuncId = 0, dummyEvalCode, dummyAssetFuncId; uint256 dummyTokenid; std::vector voutPubkeysDummy; @@ -307,9 +307,14 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOp return (uint8_t)0; } + if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size + std::cerr << "DecodeAssetTokenOpRet() could not unmarshal vopretStripped" << std::endl; + return (uint8_t)0; + } + ////tokenid = revuint256(tokenid); already done in DecodeToken! - evalCodeInOpret = vopretExtra.begin()[0]; - assetFuncId = vopretExtra.begin()[1]; + evalCodeInOpret = vopretStripped.begin()[0]; + assetFuncId = vopretStripped.begin()[1]; //std::cerr << "DecodeAssetOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; @@ -319,7 +324,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOp switch( assetFuncId ) { case 'x': case 'o': - if (vopretExtra.size() == 1) // no data after 'assetFuncId' allowed + if (vopretExtra.size() == 2) // no data after 'evalcode assetFuncId' allowed { return(assetFuncId); } @@ -327,20 +332,20 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOp case 's': case 'b': case 'S': case 'B': if (E_UNMARSHAL(vopretExtra, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) { - //fprintf(stderr,"got price %llu\n",(long long)price); + //fprintf(stderr,"DecodeAssetTokenOpRet got price %llu\n",(long long)price); return(assetFuncId); } break; case 'E': case 'e': if ( E_UNMARSHAL(vopretExtra, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) { - //fprintf(stderr,"got price %llu\n",(long long)price); + //fprintf(stderr,"DecodeAssetTokenOpRet got price %llu\n",(long long)price); assetid2 = revuint256(assetid2); return(assetFuncId); } break; default: - fprintf(stderr,"DecodeAssetOpRet: illegal assetFuncId.%02x\n", assetFuncId); + fprintf(stderr,"DecodeAssetTokenOpRet: illegal assetFuncId.%02x\n", assetFuncId); //funcId = 0; break; } From dae431eaa52a4ca76024c3f35d8ede098d20a24d Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 17:58:46 +0500 Subject: [PATCH 1223/3904] corr vopretStripped use in DecodeAssetsTokenOpret --- src/cc/CCassetsCore.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index a7ca074db..7084b1483 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -324,20 +324,20 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOp switch( assetFuncId ) { case 'x': case 'o': - if (vopretExtra.size() == 2) // no data after 'evalcode assetFuncId' allowed + if (vopretStripped.size() == 2) // no data after 'evalcode assetFuncId' allowed { return(assetFuncId); } break; case 's': case 'b': case 'S': case 'B': - if (E_UNMARSHAL(vopretExtra, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) + if (E_UNMARSHAL(vopretStripped, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) { //fprintf(stderr,"DecodeAssetTokenOpRet got price %llu\n",(long long)price); return(assetFuncId); } break; case 'E': case 'e': - if ( E_UNMARSHAL(vopretExtra, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) + if ( E_UNMARSHAL(vopretStripped, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) { //fprintf(stderr,"DecodeAssetTokenOpRet got price %llu\n",(long long)price); assetid2 = revuint256(assetid2); From e23073fff52725a941a4bd6da8c71a57fd968353 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Wed, 16 Jan 2019 14:05:54 +0100 Subject: [PATCH 1224/3904] Channels adaptation to TokensCC (#3) * Initial changes * ChannelsCC adaptation * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Fix --- src/cc/CCchannels.h | 2 +- src/cc/CCinclude.h | 3 + src/cc/CCtokens.cpp | 8 +- src/cc/channels.cpp | 353 ++++++++++++++++++++++----------------- src/wallet/rpcwallet.cpp | 15 +- 5 files changed, 217 insertions(+), 164 deletions(-) diff --git a/src/cc/CCchannels.h b/src/cc/CCchannels.h index 49b4a7adf..10cb4d224 100644 --- a/src/cc/CCchannels.h +++ b/src/cc/CCchannels.h @@ -21,7 +21,7 @@ #define CHANNELS_MAXPAYMENTS 1000 bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); -std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64_t payment); +std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64_t payment,uint256 tokenid); std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint256 secret); std::string ChannelClose(uint64_t txfee,uint256 opentxid); std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 03af2f92d..d134d9037 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -59,6 +59,9 @@ extern std::string CCerror; #define CC_MAXVINS 1024 #define SMALLVAL 0.000000000000001 +#define SATOSHIDEN ((uint64_t)100000000L) +#define dstr(x) ((double)(x) / SATOSHIDEN) + #ifndef _BITS256 #define _BITS256 union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 48172971f..57aeb4369 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -714,10 +714,10 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction tokentx; - CCerror = strprintf("obsolete, cannot return correct value without eval"); - return 0; + // CCerror = strprintf("obsolete, cannot return correct value without eval"); + // return 0; -/* if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) + if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) { fprintf(stderr, "cant find tokenid\n"); CCerror = strprintf("cant find tokenid"); @@ -726,7 +726,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_TOKENS); - return(AddTokenCCInputs(cp, mtx, pk, tokenid, 0, 0)); */ + return(AddTokenCCInputs(cp, mtx, pk, tokenid, 0, 0)); } UniValue TokenInfo(uint256 tokenid) diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index d516d0144..2a7ebc931 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -64,15 +64,16 @@ Possible third iteration: int64_t IsChannelsvout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey srcpub, CPubKey destpub,int32_t v) { - char destaddr[65],channeladdr[65]; + char destaddr[65],channeladdr[65],tokenschanneladdr[65]; GetCCaddress1of2(cp,channeladdr,srcpub,destpub); + GetTokensCCaddress1of2(cp,tokenschanneladdr,srcpub,destpub); if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,channeladdr) == 0 ) + if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && (strcmp(destaddr,channeladdr) == 0 || strcmp(destaddr,tokenschanneladdr) == 0)) return(tx.vout[v].nValue); } - return(0); + return(0); } int64_t IsChannelsMarkervout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey pubkey,int32_t v) @@ -88,17 +89,31 @@ int64_t IsChannelsMarkervout(struct CCcontract_info *cp,const CTransaction& tx,C return(0); } -CScript EncodeChannelsOpRet(uint8_t funcid,uint256 opentxid,CPubKey srcpub,CPubKey destpub,int32_t numpayments,int64_t payment,uint256 hashchain) +CScript EncodeChannelsOpRet(uint8_t funcid,uint256 tokenid,uint256 opentxid,CPubKey srcpub,CPubKey destpub,int32_t numpayments,int64_t payment,uint256 hashchain) { CScript opret; uint8_t evalcode = EVAL_CHANNELS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << opentxid << srcpub << destpub << numpayments << payment << hashchain); + if (tokenid!=zeroid) + { + std::vector pks; + pks.push_back(srcpub); + pks.push_back(destpub); + return(EncodeTokenOpRet(tokenid,pks,opret)); + } return(opret); } -uint8_t DecodeChannelsOpRet(const CScript &scriptPubKey,uint256 &opentxid, CPubKey &srcpub,CPubKey &destpub,int32_t &numpayments,int64_t &payment,uint256 &hashchain) +uint8_t DecodeChannelsOpRet(const CScript &scriptPubKey, uint256 &tokenid, uint256 &opentxid, CPubKey &srcpub,CPubKey &destpub,int32_t &numpayments,int64_t &payment,uint256 &hashchain) { - std::vector vopret; uint8_t *script,e,f; - GetOpReturnData(scriptPubKey, vopret); + std::vector vopret; uint8_t *script,e,f,tokenevalcode; + std::vector pubkeys; std::vector vOpretExtra; + + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + { + if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + } + else GetOpReturnData(scriptPubKey, vopret); if ( vopret.size() > 2 ) { script = (uint8_t *)vopret.data(); @@ -115,46 +130,56 @@ uint8_t DecodeChannelsOpRet(const CScript &scriptPubKey,uint256 &opentxid, CPubK bool ChannelsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { - static uint256 zerohash; - uint256 txid,param3; + uint256 txid,param3,tokenid; CPubKey srcpub,destpub; - int32_t param1; int64_t param2; uint8_t funcid; - CTransaction vinTx; uint256 hashBlock; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); + int32_t param1,numvouts; int64_t param2; uint8_t funcid; + CTransaction vinTx; uint256 hashBlock; int64_t inputs=0,outputs=0; - if ((numvouts=tx.vout.size()) > 0 && DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, param1, param2, param3)!=0) - { - for (i=0; i 0 && (funcid=DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3))!=0) + { + switch (funcid) { - if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) - return eval->Invalid("cant find vinTx"); - else - { - inputs += vinTx.vout[tx.vin[i].prevout.n].nValue; - } + case 'O': + return (true); + case 'P': + if ( eval->GetTxUnconfirmed(tx.vin[1].prevout.hash,vinTx,hashBlock) == 0 ) + return eval->Invalid("cant find vinTx"); + inputs = vinTx.vout[tx.vin[1].prevout.n].nValue; + outputs = tx.vout[0].nValue + tx.vout[3].nValue; + break; + case 'C': + if ( eval->GetTxUnconfirmed(tx.vin[1].prevout.hash,vinTx,hashBlock) == 0 ) + return eval->Invalid("cant find vinTx"); + inputs = vinTx.vout[tx.vin[1].prevout.n].nValue; + outputs = tx.vout[0].nValue; + break; + case 'R': + if ( eval->GetTxUnconfirmed(tx.vin[1].prevout.hash,vinTx,hashBlock) == 0 ) + return eval->Invalid("cant find vinTx"); + inputs = vinTx.vout[tx.vin[1].prevout.n].nValue; + outputs = tx.vout[2].nValue; + break; + default: + return (false); } + if ( inputs != outputs ) + { + fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); + return eval->Invalid("mismatched inputs != outputs"); + } + else return (true); } else { return eval->Invalid("invalid op_return data"); } - for (i=0; iInvalid("mismatched inputs != outputs + txfee"); - } - else return(true); + return(false); } bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numpayments,p1,param1; bool retval; - uint256 txid,hashblock,p3,param3,opentxid,tmp_txid,genhashchain,hashchain; + uint256 txid,hashblock,p3,param3,opentxid,tmp_txid,genhashchain,hashchain,tokenid; uint8_t funcid,hash[32],hashdest[32]; int64_t p2,param2,payment; CPubKey srcpub, destpub; @@ -169,15 +194,13 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & { if (ChannelsExactAmounts(cp,eval,tx,1,10000) == false ) { - fprintf(stderr,"Channelsget invalid amount\n"); - return false; + return eval->Invalid("invalid channel inputs vs. outputs!"); } else { txid = tx.GetHash(); memcpy(hash,&txid,sizeof(hash)); - - if ( (funcid = DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey, opentxid, srcpub, destpub, param1, param2, param3)) != 0) + if ( (funcid = DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey, tokenid, opentxid, srcpub, destpub, param1, param2, param3)) != 0) { switch ( funcid ) { @@ -213,9 +236,13 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vout.1 is CC for channelPayment (marker to srcPub)!"); else if ( IsChannelsMarkervout(cp,tx,destpub,2)==0 ) return eval->Invalid("vout.2 is CC for channelPayment (marker to dstPub)!"); - else if ( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) + else if ( tokenid!=zeroid && tx.vout[3].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.3 is CC for channelPayment!"); + else if ( tokenid==zeroid && tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) return eval->Invalid("vout.3 is normal for channelPayment!"); - else if ( tx.vout[3].scriptPubKey!=CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG) + else if ( tokenid!=zeroid && tx.vout[3].scriptPubKey!=MakeCC1vout(EVAL_TOKENS,tx.vout[3].nValue,destpub).scriptPubKey) + return eval->Invalid("payment funds do not go to receiver!"); + else if ( tokenid==zeroid && tx.vout[3].scriptPubKey!=CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG) return eval->Invalid("payment funds do not go to receiver!"); else if ( param1 > CHANNELS_MAXPAYMENTS) return eval->Invalid("too many payment increments!"); @@ -223,7 +250,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & { if (myGetTransaction(opentxid,channelOpenTx,hashblock) != 0) { - if ((numvouts=channelOpenTx.vout.size()) > 0 && (funcid=DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tmp_txid, srcpub, destpub, numpayments, payment, hashchain)) != 0 && funcid!='O') + if ((numvouts=channelOpenTx.vout.size()) > 0 && (funcid=DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, numpayments, payment, hashchain)) != 0 && funcid!='O') return eval->Invalid("invalid channelopen OP_RETURN data!"); endiancpy(hash, (uint8_t * ) & param3, 32); for (i = 0; i < numpayments-param1; i++) @@ -239,7 +266,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & } if (myGetTransaction(tx.vin[1].prevout.hash,prevTx,hashblock) != 0) { - if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) + if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) return eval->Invalid("invalid previous tx OP_RETURN data!"); else if (tx.vout[1].scriptPubKey != prevTx.vout[1].scriptPubKey) return eval->Invalid("invalid destination for sender marker!"); @@ -279,13 +306,13 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("too many payment increments!"); else if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) return eval->Invalid("invalid open txid!"); - else if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tmp_txid, srcpub, destpub, numpayments, payment, hashchain) != 'O') + else if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, numpayments, payment, hashchain) != 'O') return eval->Invalid("invalid channelopen OP_RETURN data!"); else if (tx.vout[0].nValue != param1*payment) return eval->Invalid("vout amount does not match number_of_payments*payment!"); else if (myGetTransaction(tx.vin[1].prevout.hash,prevTx,hashblock) != 0) { - if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) + if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) return eval->Invalid("invalid previous tx OP_RETURN data!"); else if (tx.vout[1].scriptPubKey != prevTx.vout[1].scriptPubKey) return eval->Invalid("invalid destination for sender marker!"); @@ -318,19 +345,23 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vout.0 is CC for channelRefund (marker to srcPub)!"); else if ( IsChannelsMarkervout(cp,tx,destpub,1)==0 ) return eval->Invalid("vout.1 is CC for channelRefund (marker to dstPub)!"); - else if ( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) - return eval->Invalid("vout.2 is normal for channelRefund!"); - else if ( tx.vout[2].scriptPubKey!=CScript() << ParseHex(HexStr(srcpub)) << OP_CHECKSIG) + else if ( tokenid!=zeroid && tx.vout[2].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.2 is CC for channelPayment!"); + else if ( tokenid==zeroid && tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) + return eval->Invalid("vout.2 is normal for channelPayment!"); + else if ( tokenid!=zeroid && tx.vout[2].scriptPubKey!=MakeCC1vout(EVAL_TOKENS,tx.vout[2].nValue,srcpub).scriptPubKey) + return eval->Invalid("payment funds do not go to sender!"); + else if ( tokenid==zeroid && tx.vout[2].scriptPubKey!=CScript() << ParseHex(HexStr(srcpub)) << OP_CHECKSIG) return eval->Invalid("payment funds do not go to sender!"); else if ( param1 > CHANNELS_MAXPAYMENTS) return eval->Invalid("too many payment increments!"); else if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) return eval->Invalid("invalid open txid!"); - else if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tmp_txid, srcpub, destpub, numpayments, payment, hashchain) != 'O') + else if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, numpayments, payment, hashchain) != 'O') return eval->Invalid("invalid channelopen OP_RETURN data!"); else if (myGetTransaction(param3,channelCloseTx,hashblock) == 0) return eval->Invalid("invalid close txid!"); - else if ((numvouts=channelCloseTx.vout.size()) > 0 && DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey, tmp_txid, srcpub, destpub, param1, param2, param3) != 'C') + else if ((numvouts=channelCloseTx.vout.size()) > 0 && DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, param1, param2, param3) != 'C') return eval->Invalid("invalid channelclose OP_RETURN data!"); else if (tmp_txid!=opentxid) return eval->Invalid("invalid close tx, opentxid do not match on close and refund!"); @@ -338,7 +369,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vout amount does not match number_of_payments*payment!"); else if (myGetTransaction(tx.vin[1].prevout.hash,prevTx,hashblock) != 0) { - if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) + if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) return eval->Invalid("invalid previous tx OP_RETURN data!"); else if (tx.vout[0].scriptPubKey != prevTx.vout[1].scriptPubKey) return eval->Invalid("invalid destination for sender marker!"); @@ -351,9 +382,9 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & default: fprintf(stderr,"illegal channels funcid.(%c)\n",funcid); return eval->Invalid("unexpected channels funcid"); - break; } - } else return eval->Invalid("unexpected channels missing funcid"); + } + else return eval->Invalid("unexpected channels missing funcid"); retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) fprintf(stderr,"Channel tx validated\n"); @@ -368,14 +399,15 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, CTransaction openTx, uint256 &prevtxid, CPubKey mypk) { - char coinaddr[65]; int64_t param2,totalinputs = 0,numvouts; uint256 txid=zeroid,tmp_txid,hashBlock,param3; CTransaction tx; int32_t marker,param1; + char coinaddr[65]; int64_t param2,totalinputs = 0,numvouts; uint256 txid=zeroid,tmp_txid,hashBlock,param3,tokenid; CTransaction tx; int32_t marker,param1; std::vector > unspentOutputs; CPubKey srcpub,destpub; uint8_t myprivkey[32]; - if ((numvouts=openTx.vout.size()) > 0 && DecodeChannelsOpRet(openTx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3)=='O') + if ((numvouts=openTx.vout.size()) > 0 && DecodeChannelsOpRet(openTx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)=='O') { - GetCCaddress1of2(cp,coinaddr,srcpub,destpub); + if (tokenid!=zeroid) GetTokensCCaddress1of2(cp,coinaddr,srcpub,destpub); + else GetCCaddress1of2(cp,coinaddr,srcpub,destpub); SetCCunspents(unspentOutputs,coinaddr); } else @@ -389,7 +421,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C { if ( (int32_t)it->first.index==0 && GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0) { - if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && + if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) && (totalinputs=IsChannelsvout(cp,tx,srcpub,destpub,0)+IsChannelsMarkervout(cp,tx,srcpub,marker))>0) { @@ -407,7 +439,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C const CTransaction &txmempool = e.GetTx(); const uint256 &hash = txmempool.GetHash(); - if ((numvouts=txmempool.vout.size()) > 0 && DecodeChannelsOpRet(txmempool.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) != 0 && + if ((numvouts=txmempool.vout.size()) > 0 && DecodeChannelsOpRet(txmempool.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) != 0 && tmp_txid==openTx.GetHash() && param1 < mindepth) { txid=hash; @@ -421,19 +453,19 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C prevtxid=txid; mtx.vin.push_back(CTxIn(txid,0,CScript())); mtx.vin.push_back(CTxIn(txid,marker,CScript())); - Myprivkey(myprivkey); - CCaddr2set(cp,EVAL_CHANNELS,srcpub,myprivkey,coinaddr); - CCaddr3set(cp,EVAL_CHANNELS,destpub,myprivkey,coinaddr); + Myprivkey(myprivkey); + if (tokenid!=zeroid) CCaddrTokens1of2set(cp,srcpub,destpub,coinaddr); + else CCaddr1of2set(cp,srcpub,destpub,coinaddr); return totalinputs; } else return 0; } -std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64_t payment) +std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64_t payment, uint256 tokenid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - uint8_t hash[32],hashdest[32]; uint64_t funds; int32_t i; uint256 hashchain,entropy,hentropy; - CPubKey mypk; struct CCcontract_info *cp,C; + uint8_t hash[32],hashdest[32]; uint64_t amount,tokens=0,funds; int32_t i; uint256 hashchain,entropy,hentropy; + CPubKey mypk; struct CCcontract_info *cp,*cpTokens,C,CTokens; if ( numpayments <= 0 || payment <= 0 || numpayments > CHANNELS_MAXPAYMENTS ) { @@ -442,11 +474,18 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 return(""); } cp = CCinit(&C,EVAL_CHANNELS); + cpTokens = CCinit(&CTokens,EVAL_TOKENS); if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); funds = numpayments * payment; - if ( AddNormalinputs(mtx,mypk,funds+3*txfee,64) > 0 ) + if (tokenid!=zeroid) + { + amount=AddNormalinputs(mtx,mypk,3*txfee,5); + tokens=AddTokenCCInputs(cpTokens, mtx, mypk, tokenid, funds, 64); + } + else amount=AddNormalinputs(mtx,mypk,funds+3*txfee,64); + if (amount+tokens >= funds+2*txfee) { hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); endiancpy(hash,(uint8_t *)&hentropy,32); @@ -456,10 +495,12 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 memcpy(hash,hashdest,32); } endiancpy((uint8_t *)&hashchain,hashdest,32); - mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS,funds,mypk,destpub)); + if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS,funds,mypk,destpub)); + else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS,funds,mypk,destpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('O',zeroid,mypk,destpub,numpayments,payment,hashchain))); + if (tokenid!=zeroid && tokens>funds) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,tokens-funds,mypk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('O',tokenid,zeroid,mypk,destpub,numpayments,payment,hashchain))); } return(""); } @@ -467,7 +508,7 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint256 secret) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,srcpub,destpub; uint256 txid,hashchain,gensecret,hashblock,entropy,hentropy,prevtxid,param3; + CPubKey mypk,srcpub,destpub; uint256 txid,hashchain,gensecret,hashblock,entropy,hentropy,prevtxid,param3,tokenid; struct CCcontract_info *cp,C; int32_t i,funcid,prevdepth,numvouts,numpayments,totalnumpayments; int64_t payment,change,funds,param2; uint8_t hash[32],hashdest[32]; @@ -482,83 +523,85 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 fprintf(stderr, "invalid channel open txid\n"); return (""); } + if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, totalnumpayments, payment, hashchain)=='O') + { + if (mypk != srcpub && mypk != destpub) + { + fprintf(stderr,"this is not our channel\n"); + return(""); + } + else if (amount % payment != 0 || amount 0) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount-txfee)>=0) - { - if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, totalnumpayments, payment, hashchain)=='O') + { + numpayments=amount/payment; + if (GetTransaction(prevtxid,prevTx,hashblock,false) != 0 && (numvouts=prevTx.vout.size()) > 0 && + ((funcid = DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, prevdepth, param2, param3)) != 0) && + (funcid == 'P' || funcid=='O')) { - if (mypk != srcpub && mypk != destpub) + if (numpayments > prevdepth) { - fprintf(stderr,"this is not our channel\n"); - return(""); - } - else if (amount % payment != 0 || amount 0 && - ((funcid = DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, prevdepth, param2, param3)) != 0) && - (funcid == 'P' || funcid=='O')) + if (secret!=zeroid) { - if (numpayments > prevdepth) + endiancpy(hash, (uint8_t * ) & secret, 32); + for (i = 0; i < totalnumpayments-(prevdepth-numpayments); i++) { - fprintf(stderr,"not enough funds in channel for that amount\n"); - return (""); - } else if (numpayments == 0) - { - fprintf(stderr,"invalid amount\n"); - return (""); + vcalc_sha256(0, hashdest, hash, 32); + memcpy(hash, hashdest, 32); } - if (secret!=zeroid) + endiancpy((uint8_t * ) & gensecret, hashdest, 32); + if (gensecret!=hashchain) { - endiancpy(hash, (uint8_t * ) & secret, 32); - for (i = 0; i < totalnumpayments-(prevdepth-numpayments); i++) - { - vcalc_sha256(0, hashdest, hash, 32); - memcpy(hash, hashdest, 32); - } - endiancpy((uint8_t * ) & gensecret, hashdest, 32); - if (gensecret!=hashchain) - { - fprintf(stderr,"invalid secret supplied\n"); - return(""); - } - } - else - { - hentropy = DiceHashEntropy(entropy,channelOpenTx.vin[0].prevout.hash,channelOpenTx.vin[0].prevout.n,1); - if (prevdepth-numpayments) - { - endiancpy(hash, (uint8_t * ) & hentropy, 32); - for (i = 0; i < prevdepth-numpayments; i++) - { - vcalc_sha256(0, hashdest, hash, 32); - memcpy(hash, hashdest, 32); - } - endiancpy((uint8_t * ) & secret, hashdest, 32); - } - else endiancpy((uint8_t * ) & secret, (uint8_t * ) & hentropy, 32); + fprintf(stderr,"invalid secret supplied\n"); + return(""); } } else { - fprintf(stderr,"invalid previous tx\n"); - return(""); + hentropy = DiceHashEntropy(entropy,channelOpenTx.vin[0].prevout.hash,channelOpenTx.vin[0].prevout.n,1); + if (prevdepth-numpayments) + { + endiancpy(hash, (uint8_t * ) & hentropy, 32); + for (i = 0; i < prevdepth-numpayments; i++) + { + vcalc_sha256(0, hashdest, hash, 32); + memcpy(hash, hashdest, 32); + } + endiancpy((uint8_t * ) & secret, hashdest, 32); + } + else endiancpy((uint8_t * ) & secret, (uint8_t * ) & hentropy, 32); } } else { - fprintf(stderr, "invalid channel open tx\n"); - return (""); - } - mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); + fprintf(stderr,"invalid previous tx\n"); + return(""); + } + if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); + else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,srcpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - mtx.vout.push_back(CTxOut(amount, CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG)); - return (FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeChannelsOpRet('P', opentxid, srcpub, destpub, prevdepth-numpayments, numpayments, secret))); + if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, amount, destpub)); + else mtx.vout.push_back(CTxOut(amount, CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG)); + return (FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeChannelsOpRet('P', tokenid, opentxid, srcpub, destpub, prevdepth-numpayments, numpayments, secret))); } else { @@ -575,7 +618,7 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk,srcpub,destpub; struct CCcontract_info *cp,C; CTransaction channelOpenTx; - uint256 hashblock,tmp_txid,prevtxid,hashchain; + uint256 hashblock,tmp_txid,prevtxid,hashchain,tokenid; int32_t numvouts,numpayments; int64_t payment,funds; @@ -589,7 +632,7 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) fprintf(stderr, "invalid channel open txid\n"); return (""); } - if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,numpayments,payment,hashchain)!='O') + if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { fprintf(stderr, "invalid channel open tx\n"); return (""); @@ -603,10 +646,11 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) { - mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); + if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); + else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',opentxid,mypk,destpub,(funds-txfee)/payment,payment,zeroid))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',tokenid,opentxid,mypk,destpub,(funds-txfee)/payment,payment,zeroid))); } else { @@ -623,10 +667,9 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; struct CCcontract_info *cp,C; int64_t funds,payment,param2; int32_t i,numpayments,numvouts,param1; - uint256 hashchain,hashblock,txid,prevtxid,param3,entropy,hentropy,secret; + uint256 hashchain,hashblock,txid,prevtxid,param3,tokenid; CTransaction channelOpenTx,channelCloseTx,prevTx; CPubKey srcpub,destpub; - uint8_t funcid,hash[32],hashdest[32];; // verify stoptxid and origtxid match and are mine cp = CCinit(&C,EVAL_CHANNELS); @@ -638,7 +681,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) fprintf(stderr, "invalid channel close txid\n"); return (""); } - if ((numvouts=channelCloseTx.vout.size()) < 1 || DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey,txid,srcpub,destpub,param1,param2,param3)!='C') + if ((numvouts=channelCloseTx.vout.size()) < 1 || DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,param1,param2,param3)!='C') { fprintf(stderr, "invalid channel close tx\n"); return (""); @@ -653,7 +696,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) fprintf(stderr, "invalid channel open txid\n"); return (""); } - if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,txid,srcpub,destpub,numpayments,payment,hashchain)!='O') + if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { fprintf(stderr, "invalid channel open tx\n"); return (""); @@ -668,20 +711,13 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) { if ((GetTransaction(prevtxid,prevTx,hashblock,false) != 0) && (numvouts=prevTx.vout.size()) > 0 && - DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, param1, param2, param3) != 0) + DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3) != 0) { - hentropy = DiceHashEntropy(entropy, channelOpenTx.vin[0].prevout.hash, channelOpenTx.vin[0].prevout.n,1); - endiancpy(hash, (uint8_t * ) & hentropy, 32); - for (i = 0; i < param1; i++) - { - vcalc_sha256(0, hashdest, hash, 32); - memcpy(hash, hashdest, 32); - } - endiancpy((uint8_t * ) & secret, hashdest, 32); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - mtx.vout.push_back(CTxOut(funds-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',opentxid,mypk,destpub,param1,payment,closetxid))); + if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,funds-txfee,mypk)); + else mtx.vout.push_back(CTxOut(funds-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',tokenid,opentxid,mypk,destpub,param1,payment,closetxid))); } else { @@ -699,7 +735,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) } UniValue ChannelsList() { - UniValue result(UniValue::VOBJ); std::vector > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3; + UniValue result(UniValue::VOBJ); std::vector > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; CTransaction tx; char myCCaddr[65],addr[65],str[256]; CPubKey mypk,srcpub,destpub; int32_t vout,numvouts,param1; int64_t nValue,param2; @@ -716,7 +752,7 @@ UniValue ChannelsList() nValue = (int64_t)it->second; if ( (vout == 1 || vout == 2) && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { - if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') + if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') { GetCCaddress1of2(cp,addr,srcpub,destpub); sprintf(str,"%s - %lld payments of %lld satoshi",addr,(long long)param1,(long long)param2); @@ -729,16 +765,16 @@ UniValue ChannelsList() UniValue ChannelsInfo(uint256 channeltxid) { - UniValue result(UniValue::VOBJ),array(UniValue::VARR); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid; + UniValue result(UniValue::VOBJ),array(UniValue::VARR); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid,tokenid; struct CCcontract_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments; - int64_t nValue,param2,payment; CPubKey srcpub,destpub,mypk; + int64_t param2,payment; CPubKey srcpub,destpub,mypk; std::vector > addressIndex; std::vector txids; cp = CCinit(&C,EVAL_CHANNELS); mypk = pubkey2pk(Mypubkey()); if (GetTransaction(channeltxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && - (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'O')) + (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'O')) { GetCCaddress(cp,CCaddr,mypk); Getscriptaddress(addr,CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG); @@ -746,13 +782,22 @@ UniValue ChannelsInfo(uint256 channeltxid) result.push_back(Pair("Channel CC address",CCaddr)); result.push_back(Pair("Destination address",addr)); result.push_back(Pair("Number of payments",param1)); - result.push_back(Pair("Denomination",i64tostr(param2)+" satoshi")); - result.push_back(Pair("Amount",i64tostr(param1*param2)+" satoshi")); + if(tokenid!=zeroid) + { + result.push_back(Pair("Token id",tokenid.GetHex().data())); + result.push_back(Pair("Denomination (token satoshi)",i64tostr(param2))); + result.push_back(Pair("Amount (token satoshi)",i64tostr(param1*param2))); + } + else + { + result.push_back(Pair("Denomination (satoshi)",i64tostr(param2))); + result.push_back(Pair("Amount (satoshi)",i64tostr(param1*param2))); + } SetCCtxids(addressIndex,CCaddr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if (GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) - if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid)) + if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid)) txids.push_back(it->first.txhash); } BOOST_FOREACH(const CTxMemPoolEntry &e, mempool.mapTx) @@ -760,7 +805,7 @@ UniValue ChannelsInfo(uint256 channeltxid) const CTransaction &txmempool = e.GetTx(); const uint256 &hash = txmempool.GetHash(); - if ((numvouts=txmempool.vout.size()) > 0 && DecodeChannelsOpRet(txmempool.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'P' && tmp_txid==channeltxid) + if ((numvouts=txmempool.vout.size()) > 0 && DecodeChannelsOpRet(txmempool.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'P' && tmp_txid==channeltxid) txids.push_back(hash); } prevtxid=zeroid; @@ -770,14 +815,14 @@ UniValue ChannelsInfo(uint256 channeltxid) if (txid!=prevtxid && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { UniValue obj(UniValue::VOBJ); - if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid) + if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid) { obj.push_back(Pair("Open",txid.GetHex().data())); } - else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid) + else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid) { if (GetTransaction(opentxid,opentx,hashBlock,false) != 0 && (numvouts=opentx.vout.size()) > 0 && - DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O') + DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O') { Getscriptaddress(str,tx.vout[3].scriptPubKey); obj.push_back(Pair("Payment",txid.GetHex().data())); @@ -788,11 +833,11 @@ UniValue ChannelsInfo(uint256 channeltxid) obj.push_back(Pair("Payments left",param1)); } } - else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'C' && opentxid==channeltxid) + else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'C' && opentxid==channeltxid) { obj.push_back(Pair("Close",txid.GetHex().data())); } - else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'R' && opentxid==channeltxid) + else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'R' && opentxid==channeltxid) { Getscriptaddress(str,tx.vout[2].scriptPubKey); obj.push_back(Pair("Refund",txid.GetHex().data())); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6bc267e0f..6928f4361 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5840,8 +5840,10 @@ UniValue channelsinfo(const UniValue& params, bool fHelp) UniValue channelsopen(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); int32_t numpayments; int64_t payment; std::vector destpub; struct CCcontract_info *cp,C; std::string hex; + uint256 tokenid=zeroid; + cp = CCinit(&C,EVAL_CHANNELS); - if ( fHelp || params.size() != 3 ) + if ( fHelp || params.size() < 3 || params.size() > 4) throw runtime_error("channelsopen destpubkey numpayments payment\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -5865,7 +5867,11 @@ UniValue channelsopen(const UniValue& params, bool fHelp) ERR_RESULT("invalid payment amount, must be greater than 0"); return result; } - hex = ChannelOpen(0,pubkey2pk(destpub),numpayments,payment); + if (params.size()==4) + { + tokenid=Parseuint256((char *)params[3].get_str().c_str()); + } + hex = ChannelOpen(0,pubkey2pk(destpub),numpayments,payment,tokenid); if ( hex.size() > 0 ) { result.push_back(Pair("result", "success")); @@ -5878,7 +5884,7 @@ UniValue channelspayment(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid,secret=zeroid; int32_t n; int64_t amount; cp = CCinit(&C,EVAL_CHANNELS); - if ( fHelp || params.size() != 2 ) + if ( fHelp || params.size() < 2 || params.size() >3 ) throw runtime_error("channelspayment opentxid amount [secret]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -6979,7 +6985,6 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 tokenid; uint64_t balance; std::vector pubkey; struct CCcontract_info *cp,C; CCerror.clear(); - cp = CCinit(&C,EVAL_ASSETS); if ( fHelp || params.size() > 2 ) throw runtime_error("tokenbalance tokenid [pubkey]\n"); if ( ensure_CCrequirements() < 0 ) @@ -6999,7 +7004,7 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) char destaddr[64]; result.push_back(Pair("result", "success")); - + cp = CCinit(&C,EVAL_TOKENS); if (GetCCaddress(cp, destaddr, pubkey2pk(pubkey)) != 0) result.push_back(Pair("CCaddress", destaddr)); From 778bc04009daa6bda59498543f34b55a3c65cac6 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 18:37:51 +0500 Subject: [PATCH 1225/3904] corr cpAssets use for 'S' in AssetValidate --- src/cc/CCassets.h | 2 +- src/cc/CCassetsCore.cpp | 11 ++++++----- src/cc/assets.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 39644efc6..69fcfacbb 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -44,7 +44,7 @@ bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValu bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); -bool AssetExactAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); +bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); // CCassetstx //int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance() diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 7084b1483..4ea025c10 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -389,13 +389,14 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch return eval->Invalid("vin1 needs to be buyvin.vout[0]"); else if ( eval->GetTxUnconfirmed(tx.vin[vini].prevout.hash,vinTx,hashBlock) == 0 ) { - int32_t z; + /* int32_t z; for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&tx.vin[vini].prevout.hash)[z]); - fprintf(stderr," vini.%d\n",vini); + fprintf(stderr," vini.%d\n",vini); */ + std::cerr << "AssetValidateCCvin cannot load vintx for vin=" << vini << " vintx id=" << tx.vin[vini].prevout.hash.GetHex() << std::endl; return eval->Invalid("always should find CCvin, but didnt"); } - else if ( Getscriptaddress(destaddr,vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || strcmp(destaddr,(char *)cp->unspendableCCaddr) != 0 ) + else if ( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || strcmp(destaddr,(char *)cp->unspendableCCaddr) != 0 ) { fprintf(stderr,"AssetValidateCCvin cc addr %s is not evalcode 0x%02x unspendable %s\n", destaddr, (int)cp->evalcode, (char *)cp->unspendableCCaddr); return eval->Invalid("invalid vin AssetsCCaddr"); @@ -404,7 +405,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch // return eval->Invalid("invalid dust for buyvin"); else if ( GetAssetorigaddrs(cp,CCaddr,origaddr,vinTx) == 0 ) return eval->Invalid("couldnt get origaddr for buyvin"); - fprintf(stderr,"Got %.8f to origaddr.(%s)\n",(double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); + fprintf(stderr,"AssetValidateCCvin got %.8f to origaddr.(%s)\n",(double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); if ( vinTx.vout[0].nValue == 0 ) return eval->Invalid("null value CCvin"); return(vinTx.vout[0].nValue); @@ -533,7 +534,7 @@ int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector tmporigpubkey; int64_t tmpprice; int32_t numvins = tx.vin.size(); diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index aab0a234f..4a5202c44 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -176,7 +176,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( assetid == zero ) return eval->Invalid("illegal assetid"); - else if (!AssetExactAmounts(cpAssets, inputs, outputs, eval, tx, assetid)) { // Only set inputs and outputs. NOTE: we do not need to check cc inputs == cc outputs + else if (!AssetCalcAmounts(cpAssets, inputs, outputs, eval, tx, assetid)) { // Only set inputs and outputs. NOTE: we do not need to check cc inputs == cc outputs return false; // returns false if some problems with reading vintxes } } @@ -334,7 +334,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //'S'.vout.2: vin.2 value to original pubkey [origpubkey] //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] - if( (assetoshis = AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillask"); @@ -352,8 +352,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr,0) == 0 ) - return eval->Invalid("mismatched vout0 TokenCCaddr for fill"); + if ( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) + return eval->Invalid("mismatched vout0 assets unspendable CCaddr for fill sell"); } } fprintf(stderr,"fill validated\n"); From 401737d20804ee173c86df513d3054d9feeb609f Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 18:52:38 +0500 Subject: [PATCH 1226/3904] corr dualevalUnspendableAddr in AssetValidateCCvin --- src/cc/CCassetsCore.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 4ea025c10..ebb9ff262 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -381,8 +381,11 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,co int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) { - uint256 hashBlock; char destaddr[64]; + uint256 hashBlock; + char destaddr[64], dualEvalUnspendableAddr[64]; + origaddr[0] = destaddr[0] = CCaddr[0] = 0; + if ( tx.vin.size() < 2 ) return eval->Invalid("not enough for CC vins"); else if ( tx.vin[vini].prevout.n != 0 ) @@ -396,7 +399,9 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch std::cerr << "AssetValidateCCvin cannot load vintx for vin=" << vini << " vintx id=" << tx.vin[vini].prevout.hash.GetHex() << std::endl; return eval->Invalid("always should find CCvin, but didnt"); } - else if ( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || strcmp(destaddr,(char *)cp->unspendableCCaddr) != 0 ) + else if ( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || + !GetTokensCCaddress(cp, dualEvalUnspendableAddr, GetUnspendable(cp, NULL)) || + strcmp(destaddr, dualEvalUnspendableAddr) != 0 ) { fprintf(stderr,"AssetValidateCCvin cc addr %s is not evalcode 0x%02x unspendable %s\n", destaddr, (int)cp->evalcode, (char *)cp->unspendableCCaddr); return eval->Invalid("invalid vin AssetsCCaddr"); @@ -441,9 +446,9 @@ int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpp { CTransaction vinTx; int64_t nValue,assetoshis; //fprintf(stderr,"AssetValidateSellvin\n"); - if ( (nValue= AssetValidateCCvin(cp,eval,CCaddr,origaddr,tx,1,vinTx)) == 0 ) + if ( (nValue = AssetValidateCCvin(cp, eval, CCaddr, origaddr, tx, 1, vinTx)) == 0 ) return(0); - if ( (assetoshis= IsAssetvout(cp, tmpprice, tmporigpubkey,vinTx,0,assetid)) == 0 ) + if ( (assetoshis= IsAssetvout(cp, tmpprice, tmporigpubkey, vinTx, 0, assetid)) == 0 ) return eval->Invalid("invalid missing CC vout0 for sellvin"); else return(assetoshis); From 0588f5dc67a8c6de01690f48ac2960b72b41a527 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 19:21:41 +0500 Subject: [PATCH 1227/3904] corr unspendable addr for 'S' --- src/cc/CCassetsCore.cpp | 17 +++++++++-------- src/cc/assets.cpp | 5 ++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index ebb9ff262..34d773d28 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -365,14 +365,15 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,const CTransaction& tx) { - uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; + uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; + std::vector origpubkey; CScript script; uint8_t evalCode; n = tx.vout.size(); - if ( n == 0 || (funcid= DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey)) == 0 ) + if( n == 0 || (funcid= DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) == 0 ) return(false); - if ( GetCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) + if( GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) return(true); else return(false); @@ -386,11 +387,11 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch origaddr[0] = destaddr[0] = CCaddr[0] = 0; - if ( tx.vin.size() < 2 ) + if( tx.vin.size() < 2 ) return eval->Invalid("not enough for CC vins"); - else if ( tx.vin[vini].prevout.n != 0 ) + else if( tx.vin[vini].prevout.n != 0 ) return eval->Invalid("vin1 needs to be buyvin.vout[0]"); - else if ( eval->GetTxUnconfirmed(tx.vin[vini].prevout.hash,vinTx,hashBlock) == 0 ) + else if( eval->GetTxUnconfirmed(tx.vin[vini].prevout.hash, vinTx,hashBlock) == 0 ) { /* int32_t z; for (z=31; z>=0; z--) @@ -399,7 +400,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch std::cerr << "AssetValidateCCvin cannot load vintx for vin=" << vini << " vintx id=" << tx.vin[vini].prevout.hash.GetHex() << std::endl; return eval->Invalid("always should find CCvin, but didnt"); } - else if ( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || + else if( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || !GetTokensCCaddress(cp, dualEvalUnspendableAddr, GetUnspendable(cp, NULL)) || strcmp(destaddr, dualEvalUnspendableAddr) != 0 ) { @@ -408,7 +409,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch } //else if ( vinTx.vout[0].nValue < 10000 ) // return eval->Invalid("invalid dust for buyvin"); - else if ( GetAssetorigaddrs(cp,CCaddr,origaddr,vinTx) == 0 ) + else if( GetAssetorigaddrs(cp, CCaddr, origaddr, vinTx) == 0 ) return eval->Invalid("couldnt get origaddr for buyvin"); fprintf(stderr,"AssetValidateCCvin got %.8f to origaddr.(%s)\n",(double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); if ( vinTx.vout[0].nValue == 0 ) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 4a5202c44..4efd555b7 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -334,6 +334,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //'S'.vout.2: vin.2 value to original pubkey [origpubkey] //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] + char dualEvalUnspendableAddr[64]; + GetTokensCCaddress(cpAssets, dualEvalUnspendableAddr, GetUnspendable(cpAssets, NULL)); + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) @@ -352,7 +355,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) + if ( ConstrainVout(tx.vout[0], 1, dualEvalUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/, 0) == 0 ) return eval->Invalid("mismatched vout0 assets unspendable CCaddr for fill sell"); } } From 06e5d6fc6e2229867872ac536b4bc98c8038fec1 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 19:39:56 +0500 Subject: [PATCH 1228/3904] corr dualUnspendable use in AssetOrders --- src/cc/CCassetstx.cpp | 5 ++++- src/cc/assets.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 5b21fc1b1..5246f3d79 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -165,7 +165,10 @@ UniValue AssetOrders(uint256 refassetid) SetCCunspents(unspentOutputsTokens, (char *)cpTokens->unspendableCCaddr); - SetCCunspents(unspentOutputsAssets, (char *)cpAssets->unspendableCCaddr); + + char dualEvalUnspendableAddr[64]; + GetTokensCCaddress(cpAssets, dualEvalUnspendableAddr, GetUnspendable(cpAssets, NULL)); + SetCCunspents(unspentOutputsAssets, dualEvalUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/); for (std::vector >::const_iterator itTokens = unspentOutputsTokens.begin(); itTokens != unspentOutputsTokens.end(); diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 4efd555b7..d9e8ca7fb 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -356,12 +356,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti else if( remaining_price != 0 ) { if ( ConstrainVout(tx.vout[0], 1, dualEvalUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/, 0) == 0 ) - return eval->Invalid("mismatched vout0 assets unspendable CCaddr for fill sell"); + return eval->Invalid("mismatched vout0 assets dual unspendable CCaddr for fill sell"); } } fprintf(stderr,"fill validated\n"); break; case 'E': // fillexchange + ////////// not implemented yet //////////// return eval->Invalid("unexpected assets fillexchange funcid"); break; // disable asset swaps //vin.0: normal input @@ -377,6 +378,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //if ( AssetExactAmounts(false, cp,inputs,outputs,eval,tx,assetid2) == false ) // eval->Invalid("asset2 inputs != outputs"); + ////////// not implemented yet //////////// if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) @@ -412,6 +414,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("mismatched vout0 AssetsCCaddr for fillex"); } } + ////////// not implemented yet //////////// fprintf(stderr,"fill validated\n"); break; From c18a655baf63c1037a147d46d2c51e3850a119ef Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 21:14:36 +0500 Subject: [PATCH 1229/3904] corr uninited cpAssets var in FillBuyOffer --- src/cc/CCassetstx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 5246f3d79..fb6b5b6db 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -621,12 +621,12 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f //CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); uint8_t unspendableAssetsPrivkey[32]; - cpTokens = CCinit(&assetsC, EVAL_ASSETS); //??? + cpAssets = CCinit(&assetsC, EVAL_ASSETS); //??? CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); // vout1 coins to normal - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // vout2 single-eval tokens paid + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // vout2 single-eval tokens sent to the buyer if (CCchange != 0) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // vout3 change in single-eval tokens From 9293af0f1b1774e99dc166f07c3a62a5ba0a9119 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 22:10:25 +0500 Subject: [PATCH 1230/3904] added conditions for x S o B in AssetValidateCCvin --- src/cc/CCassetsCore.cpp | 57 ++++++++++++++++++++++++++++++----------- src/cc/assets.cpp | 6 +++-- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 34d773d28..0c01f52bb 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -371,7 +371,7 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,co uint8_t evalCode; n = tx.vout.size(); - if( n == 0 || (funcid= DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) == 0 ) + if( n == 0 || (funcid = DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) == 0 ) return(false); if( GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) return(true); @@ -382,11 +382,25 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,co int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) { - uint256 hashBlock; - char destaddr[64], dualEvalUnspendableAddr[64]; + uint256 hashBlock; + uint256 assetid, assetid2; + int64_t tmpprice; + std::vector tmporigpubkey; + uint8_t evalCode; + + char destaddr[64], unspendableAddr[64]; origaddr[0] = destaddr[0] = CCaddr[0] = 0; + uint8_t funcid = 0; + if (tx.vout.size() > 0) { + uint256 assetid, assetid2; + int64_t tmpprice; + std::vector tmporigpubkey; + uint8_t evalCode; + funcid = DecodeAssetTokenOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey); + } + if( tx.vin.size() < 2 ) return eval->Invalid("not enough for CC vins"); else if( tx.vin[vini].prevout.n != 0 ) @@ -400,13 +414,25 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch std::cerr << "AssetValidateCCvin cannot load vintx for vin=" << vini << " vintx id=" << tx.vin[vini].prevout.hash.GetHex() << std::endl; return eval->Invalid("always should find CCvin, but didnt"); } - else if( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || - !GetTokensCCaddress(cp, dualEvalUnspendableAddr, GetUnspendable(cp, NULL)) || - strcmp(destaddr, dualEvalUnspendableAddr) != 0 ) + // if fillSell or cancelSell --> to spend tokens from dual-eval token-assets unspendable addr + else if( (funcid == 'S' || funcid == 'x') && + (Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || + !GetTokensCCaddress(cp, unspendableAddr, GetUnspendable(cp, NULL)) || + strcmp(destaddr, unspendableAddr) != 0)) { - fprintf(stderr,"AssetValidateCCvin cc addr %s is not evalcode 0x%02x unspendable %s\n", destaddr, (int)cp->evalcode, (char *)cp->unspendableCCaddr); + fprintf(stderr,"AssetValidateCCvin cc addr %s is not dual token-evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr); return eval->Invalid("invalid vin AssetsCCaddr"); } + // if fillBuy or cancelBuy --> to spend coins from asset unspendable addr + else if ((funcid == 'B' || funcid == 'o') && + (Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || + !GetCCaddress(cp, unspendableAddr, GetUnspendable(cp, NULL)) || + strcmp(destaddr, unspendableAddr) != 0)) + { + fprintf(stderr, "AssetValidateCCvin cc addr %s is not evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr); + return eval->Invalid("invalid vin AssetsCCaddr"); + } + //else if ( vinTx.vout[0].nValue < 10000 ) // return eval->Invalid("invalid dust for buyvin"); else if( GetAssetorigaddrs(cp, CCaddr, origaddr, vinTx) == 0 ) @@ -423,11 +449,12 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr CCaddr[0] = origaddr[0] = 0; // validate locked coins on Assets vin[1] - if ( (nValue= AssetValidateCCvin(cp,eval,CCaddr,origaddr,tx,1,vinTx)) == 0 ) + if ( (nValue= AssetValidateCCvin(cp, eval, CCaddr, origaddr, tx, 1, vinTx)) == 0 ) return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout0 for buyvin"); - else if ((funcid = DecodeAssetTokenOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey)) == 'b' && vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) // marker is only in 'b'? + else if ((funcid = DecodeAssetTokenOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey)) == 'b' && + vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) // marker is only in 'b'? return eval->Invalid("invalid normal vout1 for buyvin"); else { @@ -467,7 +494,7 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr if ((funcid = DecodeAssetTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey)) == 0) { - std::cerr << "ValidateAssetOpret() DecodeOpret returned null for n-1=" << n - 1 << " txid=" << tx.GetHash().GetHex() << std::endl; + std::cerr << "ValidateAssetOpret() DecodeAssetTokenOpRet returned null for the opret for txid=" << tx.GetHash().GetHex() << std::endl; return(false); } /* it is now on token level: @@ -559,7 +586,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t // we are not inside the validation code -- dimxy if ((eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) { - std::cerr << "AssetExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl; + std::cerr << "AssetCalcAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl; return (!eval) ? false : eval->Invalid("always should find vin tx, but didnt"); } else { @@ -573,7 +600,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t assetoshis = IsTokensvout(false, false, cpTokens, NULL, /* vopretExtra,*/ vinTx, tx.vin[i].prevout.n, assetid, vinPubkeysEmpty); if (assetoshis != 0) { - std::cerr << "AssetExactAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl; + std::cerr << "AssetCalcAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl; inputs += assetoshis; } } @@ -595,18 +622,18 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t if (assetoshis != 0) { - std::cerr << "AssetExactAmounts() vout i=" << i << " assetoshis=" << assetoshis << std::endl; + std::cerr << "AssetCalcAmounts() vout i=" << i << " assetoshis=" << assetoshis << std::endl; outputs += assetoshis; } } - std::cerr << "AssetExactAmounts() inputs=" << inputs << " outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; + std::cerr << "AssetCalcAmounts() inputs=" << inputs << " outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; /* we do not verify inputs == outputs here, it's done in Tokens: if (inputs != outputs) { if (tx.GetHash() != assetid) { - std::cerr << "AssetExactAmounts() unequal inputs=" << inputs << " vs outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; + std::cerr << "AssetCalcAmounts() unequal inputs=" << inputs << " vs outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; return (!eval) ? false : eval->Invalid("assets cc inputs != cc outputs"); } } */ diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index d9e8ca7fb..8d9b696e6 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -261,12 +261,12 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("locked value doesnt match vout0+1 fillbuy"); else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, 0) == 0 ) // tokens on user cc addr + if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, 0) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); else if ( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); } - else if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, inputs) == 0 ) // tokens on user cc addr + else if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, inputs) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt match inputs fillbuy"); else if( ConstrainVout(tx.vout[1],0,0,0) == 0 ) return eval->Invalid("vout1 is CC for fillbuy"); @@ -390,6 +390,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( assetoshis != tx.vout[0].nValue + tx.vout[1].nValue ) return eval->Invalid("locked value doesnt match vout0+1 fillex"); else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) + ////////// not implemented yet //////////// { if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, 0) == 0 ) return eval->Invalid("vout2 doesnt go to origpubkey fillex"); @@ -399,6 +400,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("asset inputs doesnt match vout2+3 fillex"); } } + ////////// not implemented yet //////////// else if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, inputs) == 0 ) return eval->Invalid("vout2 doesnt match inputs fillex"); else if( ConstrainVout(tx.vout[1], 0, 0, 0) == 0 ) From a99fd7502d6ed0a2779f2b36f7bc110630609fad Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 22:39:21 +0500 Subject: [PATCH 1231/3904] added conds for ask/bid in GetAssetorigaddrs --- src/cc/CCassetsCore.cpp | 19 ++++++++++++++++--- src/cc/assets.cpp | 8 +++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 0c01f52bb..9df24b94a 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -353,6 +353,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOp return (uint8_t)0; } +// extract sell/buy owner's pubkey from the opret bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx) { uint256 assetid,assetid2; @@ -362,8 +363,9 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT else return(false); } - -bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,const CTransaction& tx) + +// Calculate sell/buy owner's source token/asset address from ask/bid tx +bool GetAssetorigaddrs(struct CCcontract_info *cp, char *CCaddr, char *destaddr, const CTransaction& tx) { uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; @@ -373,7 +375,18 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,co n = tx.vout.size(); if( n == 0 || (funcid = DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) == 0 ) return(false); - if( GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) + + bool bGetCCaddr = false; + if (funcid == 's' || funcid == 'S') + bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); + else if (funcid == 'b' || funcid == 'B') + bGetCCaddr = GetCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); + else { + std::cerr << "GetAssetorigaddrs incorrect funcid=" << (char)(funcid?funcid:' ') << std::endl; + return false; + } + + if( bGetCCaddr && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG)) return(true); else return(false); diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 8d9b696e6..074c617cb 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -334,8 +334,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //'S'.vout.2: vin.2 value to original pubkey [origpubkey] //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] - char dualEvalUnspendableAddr[64]; - GetTokensCCaddress(cpAssets, dualEvalUnspendableAddr, GetUnspendable(cpAssets, NULL)); + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); @@ -355,7 +354,10 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0], 1, dualEvalUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/, 0) == 0 ) + char tokensUnspendableAddr[64]; + GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); + + if ( ConstrainVout(tx.vout[0], 1, tokensUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/, 0) == 0 ) return eval->Invalid("mismatched vout0 assets dual unspendable CCaddr for fill sell"); } } From 9584d6db7fd47a268d527f223f23b495b251e586 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 22:56:30 +0500 Subject: [PATCH 1232/3904] corr cond (single tokens) for buy in GetAssetorigaddrs --- src/cc/CCassetsCore.cpp | 7 +++++-- src/cc/CCassetstx.cpp | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 9df24b94a..5c48837a1 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -379,8 +379,11 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp, char *CCaddr, char *destaddr, bool bGetCCaddr = false; if (funcid == 's' || funcid == 'S') bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); - else if (funcid == 'b' || funcid == 'B') - bGetCCaddr = GetCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); + else if (funcid == 'b' || funcid == 'B') { + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + bGetCCaddr = GetCCaddress(cpTokens, CCaddr, pubkey2pk(origpubkey)); + } else { std::cerr << "GetAssetorigaddrs incorrect funcid=" << (char)(funcid?funcid:' ') << std::endl; return false; diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index fb6b5b6db..e60ebf3e6 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -723,8 +723,8 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a if (assetid2 != zeroid && inputs > paid_nValue) CCchange = (inputs - paid_nValue); - mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // vout.0 tokens cc addr - ask remainder - mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, received_assetoshis, mypk)); //vout.1 tokens to self + mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // vout.0 tokens remainder to unspendable cc addr + mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, received_assetoshis, mypk)); //vout.1 purchased tokens to self // NOTE: no marker here @@ -735,7 +735,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a } else { std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl; - mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //vout.2 coins normal to whom who asked token + mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //vout.2 coins to tokens seller's normal addr } // not implemented From f79531a29a3e6f5272d4519eb94be8d78aa1d74b Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 23:50:42 +0500 Subject: [PATCH 1233/3904] corr asset unspents addr in AssetOrders --- src/cc/CCassetstx.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index e60ebf3e6..39153f28f 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -164,11 +164,13 @@ UniValue AssetOrders(uint256 refassetid) }; - SetCCunspents(unspentOutputsTokens, (char *)cpTokens->unspendableCCaddr); + char assetsUnspendableAddr[64]; + GetCCaddress(cpAssets, assetsUnspendableAddr, GetUnspendable(cpAssets, NULL)); + SetCCunspents(unspentOutputsAssets, assetsUnspendableAddr /*(char *)cpTokens->unspendableCCaddr*/); - char dualEvalUnspendableAddr[64]; - GetTokensCCaddress(cpAssets, dualEvalUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsAssets, dualEvalUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/); + char tokensUnspendableAddr[64]; + GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); + SetCCunspents(unspentOutputsAssets, tokensUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/); for (std::vector >::const_iterator itTokens = unspentOutputsTokens.begin(); itTokens != unspentOutputsTokens.end(); From 9657b5ce43473d979e8157f71f2978605a470978 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 00:19:33 +0500 Subject: [PATCH 1234/3904] added CCaddr2set to CancelSell --- src/cc/CCassetstx.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 39153f28f..6a66bfcb7 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -530,7 +530,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; - cpTokens = CCinit(&tokensC, EVAL_TOKENS); + cpAssets = CCinit(&assetsC, EVAL_ASSETS); if (txfee == 0) txfee = 10000; @@ -555,16 +555,25 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(mypk); - char myCCaddr[65]; + /* char myCCaddr[65]; uint8_t myPrivkey[32]; Myprivkey(myPrivkey); cpAssets = CCinit(&assetsC, EVAL_ASSETS); - GetCCaddress(cpAssets, myCCaddr, mypk); + GetCCaddress(cpAssets, myCCaddr, mypk); */ // this is only for unspendable addresses: //CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); //do we need this? Seems FinalizeCCTx can attach to any evalcode cc addr by calling Getscriptaddress - return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, + uint8_t unspendableAssetsPrivkey[32]; + char unspendableAssetsAddr[64]; + // init assets 'unspendable' privkey and pubkey + CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); + GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); + + // add additional eval-tokens unspendable assets privkey: + CCaddr2set(cpAssets, EVAL_TOKENS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); + + return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeTokenOpRet(assetid, voutTokenPubkeys, EncodeAssetOpRet('x', zeroid, 0, Mypubkey())))); } @@ -749,11 +758,11 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a uint8_t unspendableAssetsPrivkey[32]; char unspendableAssetsAddr[64]; - // init 'unspenable' privkey and pubkey + // init assets 'unspendable' privkey and pubkey CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey); GetCCaddress(cpAssets, unspendableAssetsAddr, unspendableAssetsPk); - // add additional dual-eval (assets+tokens) unspendable assets address's privkey: + // add additional eval-tokens unspendable assets privkey: CCaddr2set(cpAssets, EVAL_TOKENS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); // vout verification pubkeys: From 29052b079061d07c1a4a53c8ed0ab4ea90e96f35 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 12:46:01 +0500 Subject: [PATCH 1235/3904] corr 'x' validation code corr logging in FinalizeCCtx --- src/cc/CCtx.cpp | 10 +++++----- src/cc/assets.cpp | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 2959ba7d7..2116e350b 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -163,19 +163,19 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = myprivkey; cond = mytokenscond; - fprintf(stderr,"FinalizeCCTx() matched TokensCC1vout CC addr.(%s)\n",mytokensaddr); + fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout CC addr.(%s)\n",mytokensaddr); } else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout { privkey = myprivkey; cond = mysingletokenscond; - fprintf(stderr, "FinalizeCCTx() matched single-eval TokensCC1vout CC addr.(%s)\n", mytokensaddr); + fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout CC addr.(%s)\n", mytokensaddr); } else if ( strcmp(destaddr,unspendable) == 0 ) { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"FinalizeCCTx() matched unspendable CC addr.(%s)\n",unspendable); + fprintf(stderr,"FinalizeCCTx() matched unspendable CC addr.(%s)\n",unspendable); } else if (strcmp(destaddr, tokensunspendable) == 0) { @@ -186,7 +186,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr2) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; if ( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->evalcode2, cp->unspendablepk2); @@ -195,7 +195,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); privkey = cp->unspendablepriv3; if ( othercond3 == 0 ) othercond3 = MakeCCcond1(cp->evalcode3,cp->unspendablepk3); diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 074c617cb..ec3266c71 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -153,7 +153,11 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) return eval->Invalid("AssetValidate: invalid opreturn payload"); - // find token user cc addr + // find dual-eval tokens unspendable addr: + char tokensUnspendableAddr[64]; + GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); + + // find token user cc addr: GetCCaddress(cpTokens, tokensCCaddr, pubkey2pk(origpubkey)); fprintf(stderr,"AssetValidate (%c)\n",funcid); @@ -296,10 +300,10 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("illegal null remaining_price for selloffer"); if ( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout1 for sellvin"); - if( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) + if( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) // cc change { preventCCvouts++; - if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, 0) == 0 ) // check also vout[0] + if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, 0) == 0 ) // check also cc vout[0] return eval->Invalid("mismatched vout0 TokensCCaddr for selloffer"); else if( tx.vout[0].nValue + tx.vout[2].nValue != inputs ) return eval->Invalid("mismatched vout0+vout2 total for selloffer"); @@ -317,7 +321,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.1: vin.2 back to users pubkey //vout.2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] - if( (assetoshis= AssetValidateSellvin(cpTokens, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) + + if( (assetoshis= AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( ConstrainVout(tx.vout[0], 1, tokensCCaddr, assetoshis) == 0 ) return eval->Invalid("invalid vout for cancel"); @@ -335,7 +340,6 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] - if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) @@ -354,9 +358,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( remaining_price != 0 ) { - char tokensUnspendableAddr[64]; - GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - + //char tokensUnspendableAddr[64]; + //GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); if ( ConstrainVout(tx.vout[0], 1, tokensUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/, 0) == 0 ) return eval->Invalid("mismatched vout0 assets dual unspendable CCaddr for fill sell"); } @@ -411,6 +414,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( ValidateSwapRemainder(remaining_price, tx.vout[0].nValue, assetoshis,tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillex"); else if( ConstrainVout(tx.vout[1], 1, 0, 0) == 0 ) + ////////// not implemented yet //////////// return eval->Invalid("normal vout1 for fillex"); else if( remaining_price != 0 ) { From a645af7ee4efccaedd1f306b23904ccbe3987620 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 13:14:03 +0500 Subject: [PATCH 1236/3904] corrected user cc addr for 'x' --- src/cc/assets.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index ec3266c71..33798196f 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -133,14 +133,10 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts; int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector origpubkey,tmporigpubkey,ignorepubkey; uint8_t funcid, evalCodeInOpret; - char destaddr[64], origaddr[64], assetsCCaddr[64], tokensCCaddr[64]; + char destaddr[64], origaddr[64], assetsCCaddr[64], tokensCCaddr[64], signleEvalTokensCCaddr[64]; //return true; - // we need this for validating tokens' vins/vous: - struct CCcontract_info *cpTokens, tokensC; - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - //CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); //CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, NULL); //GetCCaddress(cpTokens, tokensUnspendableCCaddr, unspendableTokensPk); @@ -157,8 +153,12 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti char tokensUnspendableAddr[64]; GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - // find token user cc addr: - GetCCaddress(cpTokens, tokensCCaddr, pubkey2pk(origpubkey)); + // we need this for validating single-eval tokens' vins/vous: + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + + // find single-eval token user cc addr: + GetCCaddress(cpTokens, signleEvalTokensCCaddr, pubkey2pk(origpubkey)); fprintf(stderr,"AssetValidate (%c)\n",funcid); @@ -322,9 +322,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] - if( (assetoshis= AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) // NOTE: return(false); - else if( ConstrainVout(tx.vout[0], 1, tokensCCaddr, assetoshis) == 0 ) + else if( ConstrainVout(tx.vout[0], 1, signleEvalTokensCCaddr, assetoshis) == 0 ) return eval->Invalid("invalid vout for cancel"); preventCCvins = 3; preventCCvouts = 1; From 65dfecadf8c2125a5506b4426ac7444f0e87bc6f Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 15:05:55 +0500 Subject: [PATCH 1237/3904] corr userCCaddr calc --- src/cc/CCassetsCore.cpp | 12 ++++++++---- src/cc/CCutils.cpp | 2 +- src/cc/assets.cpp | 17 ++++++++++------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 5c48837a1..a99817d72 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -365,7 +365,7 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT } // Calculate sell/buy owner's source token/asset address from ask/bid tx -bool GetAssetorigaddrs(struct CCcontract_info *cp, char *CCaddr, char *destaddr, const CTransaction& tx) +bool GetAssetorigaddrs(struct CCcontract_info *cp, char *userCCaddr, char *destaddr, const CTransaction& tx) { uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; @@ -377,12 +377,16 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp, char *CCaddr, char *destaddr, return(false); bool bGetCCaddr = false; - if (funcid == 's' || funcid == 'S') - bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); + if (funcid == 's' || funcid == 'S') { + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); + //bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); + } else if (funcid == 'b' || funcid == 'B') { struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); - bGetCCaddr = GetCCaddress(cpTokens, CCaddr, pubkey2pk(origpubkey)); + bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); } else { std::cerr << "GetAssetorigaddrs incorrect funcid=" << (char)(funcid?funcid:' ') << std::endl; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index ed02a779c..5d72b6b53 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -406,7 +406,7 @@ bool ConstrainVout(CTxOut vout, int32_t CCflag, char *cmpaddr, int64_t nValue) } else if ( cmpaddr != 0 && (Getscriptaddress(destaddr, vout.scriptPubKey) == 0 || strcmp(destaddr, cmpaddr) != 0) ) { - fprintf(stderr,"constrain vout error addr %s vs %s\n", cmpaddr!=0?cmpaddr:"", destaddr!=0?destaddr:""); + fprintf(stderr,"constrain vout error: check addr %s vs script addr %s\n", cmpaddr!=0?cmpaddr:"", destaddr!=0?destaddr:""); return(false); } else if ( nValue != 0 && nValue != vout.nValue ) //(nValue == 0 && vout.nValue < 10000) || ( diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 33798196f..d2eaf39de 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -133,7 +133,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts; int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector origpubkey,tmporigpubkey,ignorepubkey; uint8_t funcid, evalCodeInOpret; - char destaddr[64], origaddr[64], assetsCCaddr[64], tokensCCaddr[64], signleEvalTokensCCaddr[64]; + char destaddr[64], origaddr[64], assetsCCaddr[64], userTokensCCaddr[64], signleEvalTokensCCaddr[64]; //return true; @@ -146,6 +146,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti outputs = inputs = 0; preventCCvins = preventCCvouts = -1; + if (numvouts == 0) + return eval->Invalid("AssetValidate: no vouts"); + if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) return eval->Invalid("AssetValidate: invalid opreturn payload"); @@ -322,9 +325,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] - if( (assetoshis = AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) // NOTE: + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) // NOTE: return(false); - else if( ConstrainVout(tx.vout[0], 1, signleEvalTokensCCaddr, assetoshis) == 0 ) + else if( ConstrainVout(tx.vout[0], 1, userTokensCCaddr, assetoshis) == 0 ) return eval->Invalid("invalid vout for cancel"); preventCCvins = 3; preventCCvouts = 1; @@ -340,7 +343,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] - if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillask"); @@ -384,7 +387,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti // eval->Invalid("asset2 inputs != outputs"); ////////// not implemented yet //////////// - if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillex"); @@ -397,7 +400,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) ////////// not implemented yet //////////// { - if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, 0) == 0 ) + if( ConstrainVout(tx.vout[2], 1, userTokensCCaddr, 0) == 0 ) return eval->Invalid("vout2 doesnt go to origpubkey fillex"); else if( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) { @@ -406,7 +409,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti } } ////////// not implemented yet //////////// - else if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, inputs) == 0 ) + else if( ConstrainVout(tx.vout[2], 1, userTokensCCaddr, inputs) == 0 ) return eval->Invalid("vout2 doesnt match inputs fillex"); else if( ConstrainVout(tx.vout[1], 0, 0, 0) == 0 ) return eval->Invalid("vout1 is CC for fillex"); From c51e2394005e6a98da0b0cd084d90090f0190a05 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 15:19:29 +0500 Subject: [PATCH 1238/3904] corr FillSell self now single-eval token addr --- src/cc/CCassetstx.cpp | 2 +- src/cc/assets.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 6a66bfcb7..ed5c28fd1 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -735,7 +735,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a CCchange = (inputs - paid_nValue); mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // vout.0 tokens remainder to unspendable cc addr - mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, received_assetoshis, mypk)); //vout.1 purchased tokens to self + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); //vout.1 purchased tokens to self single-eval addr // NOTE: no marker here diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index d2eaf39de..3ccafa34f 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -133,7 +133,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts; int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector origpubkey,tmporigpubkey,ignorepubkey; uint8_t funcid, evalCodeInOpret; - char destaddr[64], origaddr[64], assetsCCaddr[64], userTokensCCaddr[64], signleEvalTokensCCaddr[64]; + char destaddr[64], origaddr[64], assetsCCaddr[64], userTokensCCaddr[64]; //, signleEvalTokensCCaddr[64]; //return true; @@ -161,7 +161,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti cpTokens = CCinit(&tokensC, EVAL_TOKENS); // find single-eval token user cc addr: - GetCCaddress(cpTokens, signleEvalTokensCCaddr, pubkey2pk(origpubkey)); + //GetCCaddress(cpTokens, signleEvalTokensCCaddr, pubkey2pk(origpubkey)); fprintf(stderr,"AssetValidate (%c)\n",funcid); From 7c16ba9ca21d6b85a015b8e044338dcda80b0f90 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 18:36:03 +0500 Subject: [PATCH 1239/3904] some debug loggin removed --- src/cc/CCassetsCore.cpp | 13 +++---------- src/cc/CCtokens.cpp | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index a99817d72..f4293eb27 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -616,7 +616,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t std::vector vopretExtra; std::vector vinPubkeysEmpty; - // TODO: why is IsTokensVout here?? + // TODO: maybe we do not need call to IsTokensVout here, cause we've already selected token vins assetoshis = IsTokensvout(false, false, cpTokens, NULL, /* vopretExtra,*/ vinTx, tx.vin[i].prevout.n, assetid, vinPubkeysEmpty); if (assetoshis != 0) { @@ -627,15 +627,8 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t } } - // we do not use this flag anymore - //if ( DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,id,id2,tmpprice,tmporigpubkey) == 't' && id == assetid ) - //flag = 1; - //else - //flag = 0; - - for (int32_t i = 0; i vinPubkeys; - if ((nValue = IsTokensvout(true, true/*<--add only checked uxtos */, cp, NULL, /*vopretExtra,*/ vintx, vout, tokenid, vinPubkeys)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + if ((nValue = IsTokensvout(true, true/*<--add only checked token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) { if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, vout, CScript())); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 48dc543ab..2b882f95b 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -540,7 +540,6 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint256 tokenid; uint256 fundingTxidInOpret; uint8_t hasHeirSpendingBegunDummy; - std::vector vinPubkeysEmpty; CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); @@ -548,7 +547,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && funcId != 0 && isMyFuncId(funcId) && - (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid, vinPubkeysEmpty) > 0) && // token validation logic + (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid) > 0) && // token validation logic //(voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && // heir contract vout validation logic - not used since we moved to 2-eval vouts !myIsutxo_spentinmempool(txid, voutIndex)) { From 9dc403f33153695810fc59b8b5899cab6e53030f Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 19:42:02 +0500 Subject: [PATCH 1241/3904] corr call to IsTokenVout in heir --- src/cc/heir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 2b882f95b..76b2e5537 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -588,7 +588,6 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info uint256 tokenid; uint256 fundingTxidInOpret; uint8_t hasHeirSpendingBegunDummy; - std::vector vinPubkeysEmpty; const int32_t ivout = 0; CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary @@ -599,7 +598,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info if (funcId != 0 && (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && isMyFuncId(funcId) && !isSpendingTx(funcId) && - (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, ivout, tokenid, vinPubkeysEmpty) > 0) && + (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, ivout, tokenid) > 0) && !myIsutxo_spentinmempool(txid, ivout)) // exclude tx in mempool { total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) From 4b71e625573aff67c2661fb240e1f6741efe7770 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 20:27:19 +0500 Subject: [PATCH 1242/3904] disabled debug loggin in FinalizeCCtx --- src/cc/CCtx.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 2116e350b..1ca4fbf91 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -153,7 +153,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); - std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " myaddr=" << myaddr << std::endl; + //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " myaddr=" << myaddr << std::endl; if( strcmp(destaddr,myaddr) == 0 ) { privkey = myprivkey; @@ -163,30 +163,30 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = myprivkey; cond = mytokenscond; - fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout CC addr.(%s)\n",mytokensaddr); + //fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout CC addr.(%s)\n",mytokensaddr); } else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout { privkey = myprivkey; cond = mysingletokenscond; - fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout CC addr.(%s)\n", mytokensaddr); + //fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout CC addr.(%s)\n", mytokensaddr); } else if ( strcmp(destaddr,unspendable) == 0 ) { privkey = unspendablepriv; cond = othercond; - fprintf(stderr,"FinalizeCCTx() matched unspendable CC addr.(%s)\n",unspendable); + //fprintf(stderr,"FinalizeCCTx() matched unspendable CC addr.(%s)\n",unspendable); } else if (strcmp(destaddr, tokensunspendable) == 0) { privkey = unspendablepriv; cond = othertokenscond; - fprintf(stderr,"FinalizeCCTx() matched tokensunspendable CC addr.(%s)\n",unspendable); + //fprintf(stderr,"FinalizeCCTx() matched tokensunspendable CC addr.(%s)\n",unspendable); } // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr2) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; if ( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->evalcode2, cp->unspendablepk2); @@ -195,7 +195,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); privkey = cp->unspendablepriv3; if ( othercond3 == 0 ) othercond3 = MakeCCcond1(cp->evalcode3,cp->unspendablepk3); @@ -204,7 +204,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -213,7 +213,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc tokens addr: else if (strcmp(cp->tokens1of2addr, destaddr) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); + //fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); privkey = myprivkey; if (othercond1of2tokens == 0) othercond1of2tokens = MakeTokensCCcond1of2(cp->evalcode, cp->tokens1of2pk[0], cp->tokens1of2pk[1]); From 80a1ef04f2a2ffcddaa2712bedc49dd5c486894e Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 20:41:18 +0500 Subject: [PATCH 1243/3904] added proc of incorrect tokenid to tokenorders --- src/wallet/rpcwallet.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6928f4361..0710bc698 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6974,9 +6974,13 @@ UniValue tokenorders(const UniValue& params, bool fHelp) throw runtime_error("tokenorders [tokenid]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - if ( params.size() == 1 ) - tokenid = Parseuint256((char *)params[0].get_str().c_str()); - else memset(&tokenid,0,sizeof(tokenid)); + if (params.size() == 1) { + tokenid = Parseuint256((char *)params[0].get_str().c_str()); + if (tokenid == zeroid) + throw runtime_error("incorrect tokenid\n"); + } + else + memset(&tokenid,0,sizeof(tokenid)); return(AssetOrders(tokenid)); } From d63d43c8ef3d00c59871f7782dceee26099f029a Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 17 Jan 2019 22:20:11 +0500 Subject: [PATCH 1244/3904] heir funcs changed to one set --- src/cc/CCHeir.h | 17 +- src/cc/heir.cpp | 415 ++++++++++++++++++++------------------- src/cc/heir_validate.h | 2 +- src/rpc/server.cpp | 4 +- src/rpc/server.h | 3 - src/wallet/rpcwallet.cpp | 299 ++-------------------------- 6 files changed, 239 insertions(+), 501 deletions(-) diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index 8399474a7..ecaff9cdb 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -27,19 +27,10 @@ bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, class CoinHelper; class TokenHelper; -// CCcustom - -// this would not link -//template std::string HeirFund(uint64_t txfee,int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); -//template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount); -//template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t nValue); - -UniValue HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); -UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 assetid); -UniValue HeirClaimCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); -UniValue HeirClaimTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); -UniValue HeirAddCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); -UniValue HeirAddTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); +UniValue HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); +UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); +UniValue HeirClaimCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); +UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); UniValue HeirInfo(uint256 fundingtxid); UniValue HeirList(); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 76b2e5537..4a78c69ac 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -14,8 +14,6 @@ ******************************************************************************/ #include "CCHeir.h" -#include "CCtokens.h" - #include "heir_validate.h" class CoinHelper; @@ -122,27 +120,27 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction //if (chainActive.Height() < 741) // return true; - uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenid = zeroid; + uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenidThis, tokenid = zeroid; CScript fundingTxOpRetScript; uint8_t hasHeirSpendingBegun = 0, hasHeirSpendingBegunDummy; CScript opret = (tx.vout.size() > 0) ? tx.vout[tx.vout.size() - 1].scriptPubKey : CScript(); // check boundary - uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, true); + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenidThis, fundingTxidInOpret, hasHeirSpendingBegunDummy, true); if (funcId == 0) return eval->Invalid("invalid opreturn format"); if (funcId != 'F') { if (fundingTxidInOpret == zeroid) { - return eval->Invalid("invalid tx opreturn format: no fundingtxid present"); + return eval->Invalid("incorrect tx opreturn: no fundingtxid present"); } - if (tokenid == zeroid) - latestTxid = FindLatestFundingTx(fundingTxidInOpret, dummyTokenid, fundingTxOpRetScript, hasHeirSpendingBegun); - else - latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, hasHeirSpendingBegun); + latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, hasHeirSpendingBegun); + + if( tokenid != zeroid && tokenid != tokenidThis ) + return eval->Invalid("incorrect tx tokenid"); if (latestTxid == zeroid) { - return eval->Invalid("invalid heir transaction: no funding tx found"); + return eval->Invalid("no fundingtx found"); } } else { @@ -406,7 +404,7 @@ uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &f * find the latest funding tx: it may be the first F tx or one of A or C tx's * Note: this function is also called from validation code (use non-locking calls) */ -template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, uint8_t &hasHeirSpendingBegun) +uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, uint8_t &hasHeirSpendingBegun) { CTransaction fundingtx; uint256 hashBlock; @@ -489,7 +487,7 @@ template uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_ } // overload for validation code -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &hasHeirSpendingBegun) +uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &hasHeirSpendingBegun) { uint8_t funcId; CPubKey ownerPubkey; @@ -497,15 +495,15 @@ template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 int64_t inactivityTime; std::string heirName; - return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); } // overload for transaction creation code -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint8_t &hasHeirSpendingBegun) +uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint8_t &hasHeirSpendingBegun) { CScript opRetScript; - return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); } // add inputs of 1 of 2 cc address @@ -704,111 +702,115 @@ UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName * creates tx to add more funds to cryptocondition address for spending by either funds' owner or heir * @return result object with raw tx or error text */ -template UniValue HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount) +template UniValue _HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) { - UniValue result(UniValue::VOBJ); //, a(UniValue::VARR); + UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey ownerPubkey, heirPubkey; int64_t inputs, CCchange = 0; - int64_t inactivityTimeSec; struct CCcontract_info *cp, C; std::string rawhex; - uint256 lasttxid, tokenid; - std::string heirName; - uint8_t funcId; - uint8_t hasHeirSpendingBegun = 0; cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! - //cp = CCinit(&C, EVAL_HEIR); // for tokens shoud be EVAL_TOKENS to sign it correctly! if (txfee == 0) txfee = 10000; - if ((lasttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { - int32_t numblocks; + CPubKey myPubkey = pubkey2pk(Mypubkey()); - CPubKey myPubkey = pubkey2pk(Mypubkey()); + // check if it is the owner + if (myPubkey != ownerPubkey) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "adding funds is only allowed for the owner of this contract")); + return result; + } - // check if it is the owner - if (myPubkey != ownerPubkey) { - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "adding funds is only allowed for the owner of this contract")); - return result; - } + if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners - if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners + int64_t inputs, change; - int64_t inputs, change; + if ((inputs = Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? - if ((inputs = Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? + // we do not use markers anymore - storing data in opreturn is better + // add marker vout: + /* char markeraddr[64]; + CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners + std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ - // we do not use markers anymore - storing data in opreturn is better - // add marker vout: - /* char markeraddr[64]; - CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners - std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ + // add cryptocondition to spend this funded amount for either pk + mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); - // add cryptocondition to spend this funded amount for either pk - mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); + if (inputs > amount) + change = (inputs - amount); // -txfee <-- txfee pays user - if (inputs > amount) - change = (inputs - amount); // -txfee <-- txfee pays user + //std::cerr << "HeirAdd() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; - //std::cerr << "HeirAdd() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; - - if (change != 0) { // vout[1] - mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); - } - - // add 1of2 vout validation pubkeys - needed only for tokens: - std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(ownerPubkey); - voutTokenPubkeys.push_back(heirPubkey); - - // add opreturn 'A' and sign tx: // this txfee ignored - std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); - - if (!rawhextx.empty()) { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); - } - else { - std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "sign error")); - } - + if (change != 0) { // vout[1] + mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } - else { - std::cerr << "HeirAdd cannot find owner cc inputs" << std::endl; + + // add 1of2 vout validation pubkeys - needed only for tokens: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(ownerPubkey); + voutTokenPubkeys.push_back(heirPubkey); + + // add opreturn 'A' and sign tx: // this txfee ignored + std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); + + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find owner cc inputs")); + result.push_back(Pair("error", "sign error")); } + } else { - std::cerr << "HeirAdd cannot find normal inputs for tx fee" << std::endl; + std::cerr << "HeirAdd cannot find owner cc inputs" << std::endl; result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find normal inputs for tx fee")); + result.push_back(Pair("error", "can't find owner cc inputs")); } + } + else { + std::cerr << "HeirAdd cannot find normal inputs for tx fee" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find normal inputs for tx fee")); + } - } else { - fprintf(stderr, "HeirAdd can't find any heir CC funding tx's\n"); - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find any heir CC funding transactions")); - } return result; } -UniValue HeirAddCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { - return HeirAdd(fundingtxid, txfee, amount); -} -UniValue HeirAddTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { - return HeirAdd(fundingtxid, txfee, amount); +UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { + + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTimeSec; + + uint256 latesttxid, tokenid = zeroid; + uint8_t funcId; + std::string heirName; + uint8_t hasHeirSpendingBegun = 0; + + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { + if (tokenid == zeroid) + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + else + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + } + else { + UniValue result(UniValue::VOBJ); + + fprintf(stderr, "HeirAdd() can't find any heir CC funding tx's\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find any heir CC funding transactions")); + return result; + } } @@ -817,146 +819,155 @@ UniValue HeirAddTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) * creates tx to spend funds from cryptocondition address by either funds' owner or heir * @return result object with raw tx or error text */ -template UniValue HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t amount) +template UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) { - UniValue result(UniValue::VOBJ); //, a(UniValue::VARR); + UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey myPubkey, ownerPubkey, heirPubkey; + CPubKey myPubkey; int64_t inputs, change = 0; - int64_t inactivityTimeSec; struct CCcontract_info *cp, C; - uint256 latesttxid, tokenid; - uint8_t funcId; - std::string heirName; - uint8_t hasHeirSpendingBegun = 0; - - //cp = CCinit(&C, Helper::getMyEval()); cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) txfee = 10000; - if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { - int32_t numblocks; - uint64_t durationSec = 0; + int32_t numblocks; + uint64_t durationSec = 0; - // we do not need to find duration if spending already has begun - if (!hasHeirSpendingBegun) { - durationSec = CCduration(numblocks, latesttxid); - std::cerr << "HeirClaim() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << std::endl; - } + // we do not need to find duration if spending already has begun + if (!hasHeirSpendingBegun) { + durationSec = CCduration(numblocks, latesttxid); + std::cerr << "HeirClaim() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << std::endl; + } - // spending is allowed if there is already spending tx or inactivity time - //bool isAllowedToHeir = (funcId == 'C' || durationSec > inactivityTimeSec) ? true : false; - bool isAllowedToHeir = (hasHeirSpendingBegun || durationSec > inactivityTimeSec) ? true : false; - myPubkey = pubkey2pk(Mypubkey()); + // spending is allowed if there is already spending tx or inactivity time + //bool isAllowedToHeir = (funcId == 'C' || durationSec > inactivityTimeSec) ? true : false; + bool isAllowedToHeir = (hasHeirSpendingBegun || durationSec > inactivityTimeSec) ? true : false; + myPubkey = pubkey2pk(Mypubkey()); - // if it is the heir, check if spending not allowed to heir yet - if (myPubkey == heirPubkey && !isAllowedToHeir) { - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "spending is not allowed yet for the heir")); - return result; - } + // if it is the heir, check if spending not allowed to heir yet + if (myPubkey == heirPubkey && !isAllowedToHeir) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "spending is not allowed yet for the heir")); + return result; + } + + // we do not use markers any more: + // we allow owner to spend funds at any time: + // if it is the owner, check if spending already allowed to heir + /* if (myPubkey == ownerPubkey && isAllowedToHeir) { + result.push_back(Pair("result", "spending is not already allowed for the owner")); + return result; + } */ + + // add spending txfee from the calling user + if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { + + // add spending from cc 1of2 address + if ((inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, amount, 60)) >= amount) // TODO: why only 60 inputs? + { + /*if (inputs < amount) { + std::cerr << "HeirClaim() cant find enough HeirCC 1of2 inputs, found=" << inputs << " required=" << amount << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find heir CC funding")); - // we do not use markers any more: - // we allow owner to spend funds at any time: - // if it is the owner, check if spending already allowed to heir - /* if (myPubkey == ownerPubkey && isAllowedToHeir) { - result.push_back(Pair("result", "spending is not already allowed for the owner")); return result; - } */ + }*/ - // add spending txfee from the calling user - if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { + // add vout with amount to claiming address + mtx.vout.push_back(Helper::makeUserVout(amount, myPubkey)); // vout[0] - // add spending from cc 1of2 address - if ((inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, amount, 60)) >= amount) // TODO: why only 60 inputs? - { - /*if (inputs < amount) { - std::cerr << "HeirClaim() cant find enough HeirCC 1of2 inputs, found=" << inputs << " required=" << amount << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find heir CC funding")); + // calc and add change vout: + if (inputs > amount) + change = (inputs - amount); // -txfee <-- txfee pays user - return result; - }*/ + //std::cerr << "HeirClaim() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; - // add vout with amount to claiming address - mtx.vout.push_back(Helper::makeUserVout(amount, myPubkey)); // vout[0] - - // calc and add change vout: - if (inputs > amount) - change = (inputs - amount); // -txfee <-- txfee pays user - - //std::cerr << "HeirClaim() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; - - // change to 1of2 funding addr: - if (change != 0) { // vout[1] - mtx.vout.push_back(Helper::make1of2Vout(change, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! - } - - // add marker vout: - /*char markeraddr[64]; - CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); - // NOTE: amount = 0 is not working: causes error code: -26, error message : 64 : dust - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners - std::cerr << "HeirClaim() adding markeraddr=" << markeraddr << '\n'; */ - - // get address of 1of2 cond - char coinaddr[64]; - Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); - - // retrieve priv key addresses for FinalizeCCtx: - uint8_t myprivkey[32]; - Myprivkey(myprivkey); - - // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: - Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); - - // add 1of2 vout validation pubkeys (this is for tokens): - std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(ownerPubkey); - voutTokenPubkeys.push_back(heirPubkey); - - // add opreturn 'C' and sign tx: // this txfee will be ignored - std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : hasHeirSpendingBegun)); // forward isHeirSpending to the next latest tx - - if (!rawhextx.empty()) { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); - } - else { - std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "sign error")); - } - - } else { - fprintf(stderr, "HeirClaim() cant find Heir CC inputs\n"); - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find heir CC funding")); + // change to 1of2 funding addr: + if (change != 0) { // vout[1] + mtx.vout.push_back(Helper::make1of2Vout(change, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! } + + // add marker vout: + /*char markeraddr[64]; + CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); + // NOTE: amount = 0 is not working: causes error code: -26, error message : 64 : dust + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners + std::cerr << "HeirClaim() adding markeraddr=" << markeraddr << '\n'; */ + + // get address of 1of2 cond + char coinaddr[64]; + Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); + + // retrieve priv key addresses for FinalizeCCtx: + uint8_t myprivkey[32]; + Myprivkey(myprivkey); + + // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: + Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + + // add 1of2 vout validation pubkeys (this is for tokens): + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(ownerPubkey); + voutTokenPubkeys.push_back(heirPubkey); + + // add opreturn 'C' and sign tx: // this txfee will be ignored + std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : hasHeirSpendingBegun)); // forward isHeirSpending to the next latest tx + + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "sign error")); + } + } else { - fprintf(stderr, "HeirClaim() cant find sufficient user inputs for tx fee\n"); + fprintf(stderr, "HeirClaim() cant find Heir CC inputs\n"); result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find sufficient user inputs to pay transaction fee")); + result.push_back(Pair("error", "can't find heir CC funding")); } } else { - fprintf(stderr, "HeirClaim() can't find any heir CC funding tx's\n"); + fprintf(stderr, "HeirClaim() cant find sufficient user inputs for tx fee\n"); result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find any heir CC funding transactions")); + result.push_back(Pair("error", "can't find sufficient user inputs to pay transaction fee")); } + return result; } -UniValue HeirClaimCoinCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { - return HeirClaim(fundingtxid, txfee, amount); -} -UniValue HeirClaimTokenCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { - return HeirClaim(fundingtxid, txfee, amount); +UniValue HeirClaimCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { + + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTimeSec; + + uint256 latesttxid, tokenid = zeroid; + uint8_t funcId; + std::string heirName; + uint8_t hasHeirSpendingBegun = 0; + + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { + if( tokenid == zeroid ) + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + else + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + + } + else { + UniValue result(UniValue::VOBJ); + + fprintf(stderr, "HeirClaim() can't find any heir CC funding tx's\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find any heir CC funding transactions")); + return result; + } } + /** * heirinfo rpc call implementation * returns some information about heir CC contract plan by a handle of initial fundingtxid: @@ -980,32 +991,28 @@ UniValue HeirInfo(uint256 fundingtxid) if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { CPubKey ownerPubkey, heirPubkey; - uint256 latestFundingTxid; uint256 dummyTokenid, tokenid = zeroid; // important to clear tokenid std::string heirName; int64_t inactivityTimeSec; const bool noLogging = false; + uint8_t funcId; - - CScript opret = fundingtx.vout.size() > 0 ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + /*CScript opret = fundingtx.vout.size() > 0 ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); if (funcId == 0) { std::cerr << "HeirInfo() this fundingtx is incorrect" << std::endl; result.push_back(Pair("result", "error")); result.push_back(Pair("error", "initial tx F not found")); return result; - } + }*/ struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_HEIR); uint8_t hasHeirSpendingBegun = 0; - if (tokenid == zeroid) // coins - latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, dummyTokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - else // tokens - latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid /*<-verify for tokens*/, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - + uint256 latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + if (latestFundingTxid != zeroid) { int32_t numblocks; uint64_t durationSec = 0; diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index f091e1381..88c02f239 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -10,7 +10,7 @@ CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan); -template uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); +uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); //uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); //uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 5c32b2f5a..5761b5bf7 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -411,9 +411,9 @@ static const CRPCCommand vRPCCommands[] = { "heir", "heirfund", &heirfund, true }, { "heir", "heiradd", &heiradd, true }, { "heir", "heirclaim", &heirclaim, true }, - { "heir", "heirfundtokens", &heirfundtokens, true }, +/* { "heir", "heirfundtokens", &heirfundtokens, true }, { "heir", "heiraddtokens", &heiraddtokens, true }, - { "heir", "heirclaimtokens", &heirclaimtokens, true }, + { "heir", "heirclaimtokens", &heirclaimtokens, true },*/ { "heir", "heirinfo", &heirinfo, true }, { "heir", "heirlist", &heirlist, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 7c85c43b6..99b7e8678 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -257,9 +257,6 @@ extern UniValue heiraddress(const UniValue& params, bool fHelp); extern UniValue heirfund(const UniValue& params, bool fHelp); extern UniValue heiradd(const UniValue& params, bool fHelp); extern UniValue heirclaim(const UniValue& params, bool fHelp); -extern UniValue heirfundtokens(const UniValue& params, bool fHelp); -extern UniValue heiraddtokens(const UniValue& params, bool fHelp); -extern UniValue heirclaimtokens(const UniValue& params, bool fHelp); extern UniValue heirinfo(const UniValue& params, bool fHelp); extern UniValue heirlist(const UniValue& params, bool fHelp); extern UniValue channelsaddress(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0710bc698..538155331 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5417,7 +5417,6 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) UniValue heiraddress(const UniValue& params, bool fHelp) { - /* struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_HEIR); if ( fHelp || params.size() > 1 ) @@ -5427,131 +5426,6 @@ UniValue heiraddress(const UniValue& params, bool fHelp) if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Heir",pubkey)); - */ - - - // make fake token tx: - struct CCcontract_info *cp, C; - - if (fHelp || (params.size() < 1)) - throw runtime_error("heiraddress A|G|H|T|R assetid|destpubkey amountcoins [heirpubkey] [fundingtxid]\n"); - if (ensure_CCrequirements() < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - - char badKind = ((char *)params[0].get_str().c_str())[0]; - - if (badKind == 'A') { - std::vector destPubkey; - if (params.size() == 2) { - cp = CCinit(&C, EVAL_HEIR); - destPubkey = ParseHex(params[1].get_str().c_str()); - return(CCaddress(cp, (char *)"Heir", destPubkey)); - } - else - return std::string("bad params for A"); - } - - CPubKey myPubkey = pubkey2pk(Mypubkey()); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());; - - if (badKind != 'R') { - - if (badKind == 'G' && params.size() != 3) - return std::string("incorrect params for G"); - if (badKind == 'H' && params.size() != 5) - return std::string("incorrect params for H, = 5"); - if (badKind == 'T' && params.size() != 3) - return std::string("incorrect params for T, = 3"); - - - uint256 assetid = Parseuint256((char *)params[1].get_str().c_str()); - int64_t amount = atof(params[2].get_str().c_str()) * COIN; - - uint256 fundingtxid; - CPubKey heirPubkey; - - if (badKind == 'H') { - - std::vector heirPubkeyStr = ParseHex(params[3].get_str().c_str()); - heirPubkey = pubkey2pk(heirPubkeyStr); - - fundingtxid = Parseuint256((char *)params[4].get_str().c_str()); - } - - - - int64_t txfee = 10000; - - uint8_t evalCodeInOpret = (badKind == 'H') ? EVAL_HEIR : EVAL_GATEWAYS; - cp = CCinit(&C, EVAL_ASSETS); - - int64_t normalInputs = AddNormalinputs(mtx, myPubkey, txfee + amount, 60); - // int64_t ccInputs = 0; - - - if (badKind == 'T') { - // just empty fake token - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, amount, myPubkey)); //note you need destPubkey for sending to gateways - } - else if (badKind == 'H') { - // heir add funding tx - mtx.vout.push_back(MakeCC1of2vout(EVAL_ASSETS, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk - } - else { // if (badKind == 'G') - CPubKey gatewayContractPubKey = GetUnspendable(cp, 0); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(gatewayContractPubKey)) << OP_CHECKSIG)); - } - - int64_t change = (normalInputs - amount); - if (change != 0) { - mtx.vout.push_back(CTxOut(change, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG)); - } - std::cerr << "make fake token for contract=" << badKind << " added normalInputs=" << normalInputs << " change=" << change << std::endl; - - // note: it sets eval=EVAL_ASSETS in opreturn both for tokens and gateways cc addr - //script = EncodeAssetOpRet('t', assetid, zeroid, 0, (badKind == 'A' ? Mypubkey() : destPubkey)); // dimxy: are we sure about destPubkey here? it may be just pubkey of the author... - CScript opret; - assetid = revuint256(assetid); - fundingtxid = revuint256(fundingtxid); - if (badKind == 'T') - opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalCodeInOpret << (uint8_t)'t' << assetid ); - else if (badKind == 'H') - opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalCodeInOpret << (uint8_t)'t' << assetid << (uint8_t)'A' << myPubkey << heirPubkey << (int64_t)120 << fundingtxid); - else - opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)evalCodeInOpret << (uint8_t)'t' << assetid); // EVAL_GATEWAYS - - return(FinalizeCCTx(0, cp, mtx, myPubkey, txfee, opret)); // normal change added here - } - else - { - // move vout from user cc addr to gateways unspendable - CTransaction srctx; - - uint256 hashBlock; - const bool allowSlow = false; - uint256 srctxid = Parseuint256((char *)params[1].get_str().c_str()); - - struct CCcontract_info *cp, C; - cp = CCinit(&C, EVAL_GATEWAYS); - - uint64_t txfee = 10000; - CPubKey gatewayspk = GetUnspendable(cp, 0); - - if (myGetTransaction(srctxid, srctx, hashBlock) && srctx.vout.size() > 0) { - - int64_t normalInputs = AddNormalinputs(mtx, myPubkey, 2 * txfee, 4); - - mtx.vin.push_back(CTxIn(srctxid, 2, CScript())); // repaired src tx - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS, srctx.vout[2].nValue, gatewayspk)); - - CScript script = srctx.vout[srctx.vout.size() - 1].scriptPubKey; - - //mtx.fOverwintered = true; - - return(FinalizeCCTx(0, cp, mtx, myPubkey, txfee, script)); // normal change added here - } - } - return std::string("there has been some error"); } @@ -7432,53 +7306,12 @@ UniValue getbalance64(const UniValue& params, bool fHelp) return ret; } -// heir contract functions for coins + +// heir contract functions for coins and tokens UniValue heirfund(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); - //uint256 txid; - int64_t txfee; - int64_t amount; - int64_t inactivitytime; - std::string hex; - std::vector pubkey; - std::string name; - - //TODO: do we need this? - if (!EnsureWalletIsAvailable(fHelp)) - return NullUniValue; - - if (fHelp || params.size() != 5) - throw runtime_error("heirfund fee funds heirname heirpubkey inactivitytime\n"); - if (ensure_CCrequirements() < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - - txfee = atof((char*)params[0].get_str().c_str()) * COIN; - amount = atof((char*)params[1].get_str().c_str()) * COIN; - name = params[2].get_str(); - pubkey = ParseHex(params[3].get_str().c_str()); - inactivitytime = atof((char*)params[4].get_str().c_str()); - - - result = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, zeroid); -/* if (hex.size() > 0) { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } - else - ERR_RESULT("couldn't create heir fund");*/ - - return result; -} - - -UniValue heiradd(const UniValue& params, bool fHelp) -{ - UniValue result; // UniValue result(UniValue::VOBJ); - uint256 fundingtxid; + uint256 tokenid = zeroid; uint64_t txfee; int64_t amount; int64_t inactivitytime; @@ -7486,88 +7319,11 @@ UniValue heiradd(const UniValue& params, bool fHelp) std::vector pubkey; std::string name; - // TODO: do we need this? if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - if (fHelp || params.size() != 3) - throw runtime_error("heiradd fee funds fundingtxid\n"); - if (ensure_CCrequirements() < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - - txfee = atof((char*)params[0].get_str().c_str()) * COIN; - amount = atof((char*)params[1].get_str().c_str()) * COIN; - fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); - - result = HeirAddCoinCaller(fundingtxid, txfee, amount); - /* if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } else ERR_RESULT("couldn't claim heir fund"); */ - - - return result; -} - -UniValue heirclaim(const UniValue& params, bool fHelp) -{ - UniValue result; // result(UniValue::VOBJ); - uint256 fundingtxid; - uint64_t txfee; - int64_t amount; - int64_t inactivitytime; - std::string hex; - std::vector pubkey; - std::string name; - - // do we need this? - if (!EnsureWalletIsAvailable(fHelp)) - return NullUniValue; - - if (fHelp || params.size() != 3) - throw runtime_error("heirclaim fee funds fundingtxid\n"); - if (ensure_CCrequirements() < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - - txfee = atof((char*)params[0].get_str().c_str()) * COIN; - amount = atof((char*)params[1].get_str().c_str()) * COIN; - fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); - - result = HeirClaimCoinCaller(fundingtxid, txfee, amount); - /* if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } else ERR_RESULT("couldn't claim heir fund"); */ - - return result; -} - -// same heir contract functions for tokens -UniValue heirfundtokens(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); - uint256 assetid; - uint64_t txfee; - int64_t amount; - int64_t inactivitytime; - std::string hex; - std::vector pubkey; - std::string name; - - //TODO: do we need this (dimxy)? - if (!EnsureWalletIsAvailable(fHelp)) - return NullUniValue; - - if (fHelp || params.size() != 6) - throw runtime_error("heirfundtokens fee funds heirname heirpubkey inactivitytime assetid\n"); + if (fHelp || params.size() != 5 && params.size() != 6) + throw runtime_error("heirfundtokens fee funds heirname heirpubkey inactivitytime [tokenid]\n"); if (ensure_CCrequirements() < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -7578,26 +7334,27 @@ UniValue heirfundtokens(const UniValue& params, bool fHelp) amount = atoll((char*)params[1].get_str().c_str()); name = params[2].get_str(); pubkey = ParseHex(params[3].get_str().c_str()); + if( !pubkey2pk(pubkey).IsValid() ) + throw runtime_error("incorrect pubkey\n"); + inactivitytime = atof((char*)params[4].get_str().c_str()); - assetid = Parseuint256((char*)params[5].get_str().c_str()); - - - result = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, assetid); -/* if (hex.size() > 0) { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); + if (params.size() == 6) { + tokenid = Parseuint256((char*)params[5].get_str().c_str()); + if(tokenid == zeroid) + throw runtime_error("incorrect tokenid\n"); } - else - ERR_RESULT("couldn't create heir fund");*/ + if( tokenid == zeroid ) + result = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, zeroid); + else + result = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, tokenid); return result; } - -UniValue heiraddtokens(const UniValue& params, bool fHelp) +UniValue heiradd(const UniValue& params, bool fHelp) { - UniValue result; // UniValue result(UniValue::VOBJ); + UniValue result; uint256 fundingtxid; uint64_t txfee; int64_t amount; @@ -7606,7 +7363,6 @@ UniValue heiraddtokens(const UniValue& params, bool fHelp) std::vector pubkey; std::string name; - // TODO: do we need this? if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -7622,18 +7378,11 @@ UniValue heiraddtokens(const UniValue& params, bool fHelp) amount = atoll((char*)params[1].get_str().c_str()); fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); - result = HeirAddTokenCaller(fundingtxid, txfee, amount); - /* if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } else ERR_RESULT("couldn't claim heir fund"); */ - - + result = HeirAddCaller(fundingtxid, txfee, amount); return result; } -UniValue heirclaimtokens(const UniValue& params, bool fHelp) +UniValue heirclaim(const UniValue& params, bool fHelp) { UniValue result; // result(UniValue::VOBJ); uint256 fundingtxid; @@ -7660,13 +7409,7 @@ UniValue heirclaimtokens(const UniValue& params, bool fHelp) amount = atoll((char*)params[1].get_str().c_str()); fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); - result = HeirClaimTokenCaller(fundingtxid, txfee, amount); - /* if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } else ERR_RESULT("couldn't claim heir fund"); */ - + result = HeirClaimCaller(fundingtxid, txfee, amount); return result; } From d9de6b7cde33e0ca3987857c73cd4bf74b9370c1 Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 18 Jan 2019 00:47:01 +0500 Subject: [PATCH 1245/3904] extra logging disabled in validator --- src/cc/heir_validate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 88c02f239..d66777933 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -604,7 +604,7 @@ public: } } - std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; + //std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; return true; } virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } From 0b257f6dfac182abcf7b06490fbc2d19c1378867 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Jan 2019 21:49:55 -1100 Subject: [PATCH 1246/3904] Add 1of2 add and coin balances --- src/cc/marmara.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 4cf1a2a42..cf2382277 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -917,8 +917,16 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ result.push_back(Pair("result","success")); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); result.push_back(Pair("myaddress",coinaddr)); + result.push_back(Pair("normal",ValueFromAmount(CCaddress_balance(coinaddr)))); + + GetCCaddress1of2(cp,coinaddr,Marmarapk,Mypubkey()); + result.push_back(Pair("myCCactivated",coinaddr)); + result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr)))); + GetCCaddress(cp,coinaddr,Mypubkey()); result.push_back(Pair("myCCaddress",coinaddr)); + result.push_back(Pair("CCutxos",ValueFromAmount(CCaddress_balance(coinaddr)))); + if ( refpk.size() == 33 ) result.push_back(Pair("issuer",HexStr(refpk))); if ( currency.size() == 0 ) From 06ff993abd1f34ca8d9bc42d9a7f821679504541 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 18 Jan 2019 17:06:30 +0800 Subject: [PATCH 1247/3904] Fix rescan entire wallet when finding corrupt transaction on load. Now removes corrupt tx and re adds it with GetTransaction. --- src/wallet/walletdb.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 867bca08b..aae406de3 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -39,6 +39,7 @@ using namespace std; static uint64_t nAccountingEntryNumber = 0; +static list deadTxns; // // CWalletDB @@ -484,8 +485,11 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, CValidationState state; auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) + { + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + deadTxns.push_back(hash); return false; - + } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) { @@ -933,9 +937,6 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. - if (strType == "tx") - // Rescan if there is a bad transaction record: - SoftSetBoolArg("-rescan", true); } } if (!strErr.empty()) @@ -950,6 +951,24 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) result = DB_CORRUPT; } + if (!deadTxns.empty()) + { + int32_t reAdded = 0; + BOOST_FOREACH (uint256& hash, deadTxns) { + if (!EraseTx(hash)) + fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); + uint256 blockhash; CTransaction tx; + if (GetTransaction(hash,tx,blockhash,true)) + { + CWalletTx wtx(pwallet,tx); + pwallet->AddToWallet(wtx, true, NULL); + reAdded++; + } + } + fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",deadTxns.size(),reAdded); + deadTxns.clear(); + } + if (fNoncriticalErrors && result == DB_LOAD_OK) result = DB_NONCRITICAL_ERROR; From e555995f194aa978e77ea65bd87427f3faf477af Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Jan 2019 22:46:56 -1100 Subject: [PATCH 1248/3904] Marmaralock --- src/cc/CCMarmara.h | 1 + src/cc/marmara.cpp | 43 ++++++++++++++++++++++++++++++++++------ src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 14 +++++++++++++ 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index fe9f7f30b..65269df77 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -31,6 +31,7 @@ int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid); UniValue MarmaraCreditloop(uint256 txid); UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid); +UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height); UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag); diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index cf2382277..b57b156e1 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -395,6 +395,41 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, return(totalinputs); } +UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk; int64_t inputsum,change = 0; std::string rawtx,errorstr; + // scan all unlocked + // total capped at amount, change -> unlocked, if no change then scan all locked 'C' and 'P' for unlockht < refunlockht + if ( txfee == 0 ) + txfee = 10000; + cp = CCinit(&C,EVAL_MARMARA); + mypk = pubkey2pk(Mypubkey()); + Marmarapk = GetUnspendable(cp,0); + if ( (inputsum= AddNormalinputs(mtx,mypk,amount + txfee,1)) > 0 ) + { + if ( inputsum > amount+txfee ) + { + change = (inputsum - amount); + mtx.vout.push_back(CTxOut(change,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + } + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraCoinbaseOpret('L',height,mypk)); + if ( rawtx.size() == 0 ) + errorstr = (char *)"couldnt finalize CCtx"; + else + { + result.push_back(Pair("result",(char *)"success")); + result.push_back(Pair("rawtx",rawtx)); + return(result); + } + } + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",errorstr)); + return(result); +} + +// decide on what unlockht settlement change should have + UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -459,7 +494,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,height,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,unlockht,currency),pubkeys); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); @@ -474,7 +509,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker if ( refamount-remaining > 3*txfee ) mtx.vout.push_back(CTxOut(refamount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,height,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,unlockht,currency),pubkeys); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); result.push_back(Pair("rawtx",rawtx)); @@ -902,10 +937,6 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * return(result); } -// MarmaraLock(uint64_t txfee,int64_t amount,int32_t refunlockht) -// scan all unlocked -// total capped at amount, change -> unlocked, if no change then scan all locked 'C' and 'P' for unlockht < refunlockht - // get all tx, constrain by vout, issuances[] and closed[] UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 5761b5bf7..90f8fd6db 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -458,6 +458,7 @@ static const CRPCCommand vRPCCommands[] = { "marmara", "marmarainfo", &marmara_info, true }, { "marmara", "marmaracreditloop", &marmara_creditloop, true }, { "marmara", "marmarasettlement", &marmara_settlement, true }, + { "marmara", "marmaralock", &marmara_lock, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 99b7e8678..d5ebb56ab 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -285,6 +285,7 @@ extern UniValue marmara_transfer(const UniValue& params, bool fHelp); extern UniValue marmara_info(const UniValue& params, bool fHelp); extern UniValue marmara_creditloop(const UniValue& params, bool fHelp); extern UniValue marmara_settlement(const UniValue& params, bool fHelp); +extern UniValue marmara_lock(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a92cf4bf8..02cf85ee6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5692,6 +5692,20 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) return(result); } +UniValue marmara_lock(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); int64_t amount; int32_t height; + if ( fHelp || params.size() > 2 || params.size() == 0 ) + { + throw runtime_error("marmaralock amount unlockht\n"); + } + amount = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; + if ( params.size() == 2 ) + height = atol(params[1].get_str().c_str()); + else height = chainActive.LastTip()->GetHeight() + 1; + return(MarmaraLock(0,amount,height)); +} + UniValue channelslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) From 6e4d54fb7b83bdd5c91332e7da9d1c08d8df243d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Jan 2019 22:48:50 -1100 Subject: [PATCH 1249/3904] Refunlockht --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index b57b156e1..8f5701553 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -494,7 +494,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,unlockht,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,refunlockht,currency),pubkeys); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); @@ -509,7 +509,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker if ( refamount-remaining > 3*txfee ) mtx.vout.push_back(CTxOut(refamount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,unlockht,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,refunlockht,currency),pubkeys); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); result.push_back(Pair("rawtx",rawtx)); From bc04276465a8ae9f57843a11903a87e7d2b57a45 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Jan 2019 22:49:41 -1100 Subject: [PATCH 1250/3904] refmatures --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8f5701553..b43754cb3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -494,7 +494,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if ( change > txfee ) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,refunlockht,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,refmatures,currency),pubkeys); result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("rawtx",rawtx)); return(result); @@ -509,7 +509,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,createtxid))) << OP_CHECKSIG)); // failure marker if ( refamount-remaining > 3*txfee ) mtx.vout.push_back(CTxOut(refamount-remaining-2*txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,refunlockht,currency),pubkeys); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,refmatures,currency),pubkeys); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); result.push_back(Pair("rawtx",rawtx)); From 43be0a0e918c5d83a8be0492499f8c962d9b51d5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 18 Jan 2019 17:54:41 +0800 Subject: [PATCH 1251/3904] VerusHash fix. 100% PoW wasnt working, min diff is now much higher fixing PoW doing 1s blocks. --- src/komodo_bitcoind.h | 24 ++++++++---------------- src/komodo_globals.h | 4 +++- src/miner.cpp | 16 ++++++++++------ src/notaries_staked.cpp | 4 ++-- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1ffc68c62..2fea50e7b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1296,6 +1296,11 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + { + if ( blocktime+iter+segid*2 > prevtime+200 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+120)); + } if ( blocktime+iter+segid*2 > prevtime+480 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); coinage256 = arith_uint256(coinage+1); @@ -1339,14 +1344,9 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { - int32_t oldflag = 0,dispflag = 0; + int32_t oldflag = 0,dispflag = 1; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - static bool new_rules, didinit; - if ( !didinit ) { - new_rules = is_STAKED(ASSETCHAINS_SYMBOL) != 0 && is_STAKED(ASSETCHAINS_SYMBOL) != 3 ? true : false; - didinit = true; - } if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); @@ -1359,9 +1359,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he ht = height - 100 + i; if ( ht <= 1 ) continue; - // never count the first 10 blocks, they are always PoW! Cant do this for old chains, so limit to LABS and LAB for now. - if ( new_rules && ht < 10 ) - continue; if ( (pindex= komodo_chainactive(ht)) != 0 ) { if ( komodo_segid(0,ht) >= 0 ) @@ -1385,12 +1382,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) - { - if ( new_rules) - percPoS = (percPoS*100) / (m+n); - else - percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; - } + percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; @@ -1449,7 +1441,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); } } - else + else bnTarget = ave; // recent ave is perfect return(bnTarget); } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f2f6ed6b4..70d621756 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -81,7 +81,9 @@ uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375}; +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905}; + // nBits.486704888 -- too low? + // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS diff --git a/src/miner.cpp b/src/miner.cpp index 98bfa55a1..aac5164cb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1297,6 +1297,7 @@ void static BitcoinMiner_noeq() pblock->nSolution = solnPlaceholder; savebits = pblock->nBits; arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); + HASHTarget = arith_uint256().SetCompact(savebits); arith_uint256 mask(ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]); Mining_start = 0; @@ -1315,8 +1316,8 @@ void static BitcoinMiner_noeq() if ( ASSETCHAINS_STAKED != 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; - HASHTarget_POW = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); - HASHTarget.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); + HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); + HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); } @@ -1332,10 +1333,12 @@ void static BitcoinMiner_noeq() vh.ClearExtra(); int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; - if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) - hashTarget = HASHTarget_POW; - else hashTarget = HASHTarget; - + if ( ASSETCHAINS_STAKED != 0) + { + if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED < 100 ) + hashTarget = HASHTarget_POW; + else hashTarget = HASHTarget; + } // for speed check NONCEMASK at a time for (i = 0; i < count; i++) { @@ -1429,6 +1432,7 @@ void static BitcoinMiner_noeq() #else printf("%lu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576); #endif + pblock->nBits = savebits; break; } } diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ebee4868e..596c78b90 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -14,9 +14,9 @@ int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) + if ( (strcmp(chain_name, "LABMAIN") == 0) || (strncmp(chain_name, "LABT1", 4) == 0) ) STAKED = 1; - else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) + else if ( (strcmp(chain_name, "LABT2") == 0) || (strncmp(chain_name, "LABT2", 3) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; From 45dfd3a590a3cab4635f3262d9d8e3b06a3b5138 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 18 Jan 2019 17:55:20 +0800 Subject: [PATCH 1252/3904] fix back to LABS --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 596c78b90..ad1a2132f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -14,7 +14,7 @@ int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABMAIN") == 0) || (strncmp(chain_name, "LABT1", 4) == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; else if ( (strcmp(chain_name, "LABT2") == 0) || (strncmp(chain_name, "LABT2", 3) == 0) ) STAKED = 2; From 68597fa670091864e017f0c07a118251822a60f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Jan 2019 22:56:06 -1100 Subject: [PATCH 1253/3904] Add CC out --- src/cc/marmara.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index b43754cb3..f095c5da3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -408,6 +408,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); if ( (inputsum= AddNormalinputs(mtx,mypk,amount + txfee,1)) > 0 ) { + mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum > amount+txfee ) { change = (inputsum - amount); From 6915c400e38eac4d53022ccc0dc0f2ebb3d3576a Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Fri, 18 Jan 2019 11:14:40 +0100 Subject: [PATCH 1254/3904] Fix ChannelsPayment when destpub issues payment,add check_signing_pubkey --- src/cc/CCinclude.h | 1 + src/cc/CCutils.cpp | 31 +++++++++++++++++++++++++++++++ src/cc/channels.cpp | 9 +++++---- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 3f8d8f672..982f5aa77 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -222,6 +222,7 @@ std::vector Mypubkey(); bool Myprivkey(uint8_t myprivkey[]); int64_t CCduration(int32_t &numblocks,uint256 txid); bool komodo_txnotarizedconfirmed(uint256 txid); +CPubKey check_signing_pubkey(CScript scriptSig); // CCtx bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 5d72b6b53..e9c30acc1 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -599,3 +599,34 @@ bool komodo_txnotarizedconfirmed(uint256 txid) return (true); return (false); } + +CPubKey check_signing_pubkey(CScript scriptSig) +{ + + bool found = false; + CPubKey pubkey; + + auto findEval = [](CC *cond, struct CCVisitor _) { + bool r = false; + + if (cc_typeId(cond) == CC_Secp256k1) { + *(CPubKey*)_.context=buf2pk(cond->publicKey); + r = true; + } + // false for a match, true for continue + return r ? 0 : 1; + }; + + CC *cond = GetCryptoCondition(scriptSig); + + if (cond) { + CCVisitor visitor = { findEval, (uint8_t*)"", 0, &pubkey }; + bool out = !cc_visit(cond, visitor); + cc_free(cond); + + if (pubkey.IsValid()) { + return pubkey; + } + } + return CPubKey(); +} diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 2a7ebc931..824707520 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -222,6 +222,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & //vout.3: normal output of payment amount to receiver pubkey //vout.n-2: normal change //vout.n-1: opreturn - 'P' opentxid senderspubkey receiverspubkey depth numpayments secret + check_signing_pubkey(tx.vin[1].scriptSig); if (komodo_txnotarizedconfirmed(opentxid) == 0) return eval->Invalid("channelOpen is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) @@ -422,8 +423,8 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C if ( (int32_t)it->first.index==0 && GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0) { if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && - (tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) && - (totalinputs=IsChannelsvout(cp,tx,srcpub,destpub,0)+IsChannelsMarkervout(cp,tx,srcpub,marker))>0) + (tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) && IsChannelsMarkervout(cp,tx,marker==1?srcpub:destpub,marker)>0 && + (totalinputs=IsChannelsvout(cp,tx,srcpub,destpub,0))>0) { txid = it->first.txhash; break; @@ -443,7 +444,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C tmp_txid==openTx.GetHash() && param1 < mindepth) { txid=hash; - totalinputs=txmempool.vout[0].nValue+txmempool.vout[1].nValue; + totalinputs=txmempool.vout[0].nValue; mindepth=param1; } } @@ -543,7 +544,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 } if (AddNormalinputs(mtx,mypk,2*txfee,3) > 0) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount-txfee)>=0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0) { numpayments=amount/payment; if (GetTransaction(prevtxid,prevTx,hashblock,false) != 0 && (numvouts=prevTx.vout.size()) > 0 && From 6ab5254887ed1b88d82f1114d1b2a19498353caf Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Fri, 18 Jan 2019 11:18:38 +0100 Subject: [PATCH 1255/3904] Fix --- src/cc/channels.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 824707520..a375edbda 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -222,7 +222,6 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & //vout.3: normal output of payment amount to receiver pubkey //vout.n-2: normal change //vout.n-1: opreturn - 'P' opentxid senderspubkey receiverspubkey depth numpayments secret - check_signing_pubkey(tx.vin[1].scriptSig); if (komodo_txnotarizedconfirmed(opentxid) == 0) return eval->Invalid("channelOpen is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) From 901c7952044aaf1a45f0d75f031bf9853024341d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Jan 2019 23:22:46 -1100 Subject: [PATCH 1256/3904] Test --- src/cc/marmara.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f095c5da3..5260df2ae 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -398,15 +398,18 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk; int64_t inputsum,change = 0; std::string rawtx,errorstr; - // scan all unlocked - // total capped at amount, change -> unlocked, if no change then scan all locked 'C' and 'P' for unlockht < refunlockht + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk; int32_t unlockht; int64_t inputsum,change = 0; std::string rawtx,errorstr; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - if ( (inputsum= AddNormalinputs(mtx,mypk,amount + txfee,1)) > 0 ) + inputsum = AddNormalinputs(mtx,mypk,amount + txfee,1); + if ( inputsum < amount+txfee ) + { + unlockht = MarmaraUnlockht(height); + } + if ( inputsum > 0 ) { mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum > amount+txfee ) From 5a4fd8b15eb6e69edc56884cf06622b7a50873d3 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 18 Jan 2019 17:56:59 +0700 Subject: [PATCH 1257/3904] fixed token tests --- qa/rpc-tests/cryptoconditions_token.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 630d8f6e3..254868670 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -18,18 +18,29 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): rpc = self.nodes[0] result = rpc.tokenaddress() assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress']: + for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress']: assert_equal(result[x][0], 'R') result = rpc.tokenaddress(self.pubkey) assert_success(result) + for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress', 'CCaddress']: + assert_equal(result[x][0], 'R') + + result = rpc.assetsaddress() + assert_success(result) + for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress']: + assert_equal(result[x][0], 'R') + + result = rpc.assetsaddress(self.pubkey) + assert_success(result) for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress', 'CCaddress']: assert_equal(result[x][0], 'R') + # there are no tokens created yet result = rpc.tokenlist() assert_equal(result, []) - # trying to create token with negaive supply + # trying to create token with negative supply result = rpc.tokencreate("NUKE", "-1987420", "no bueno supply") assert_error(result) @@ -50,12 +61,9 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): result = rpc.tokenorders() assert_equal(result, []) - # getting token balance for pubkey + # getting token balance for non existing tokenid result = rpc.tokenbalance(self.pubkey) - assert_success(result) - assert_equal(result['balance'], 0) - assert_equal(result['CCaddress'], 'RCRsm3VBXz8kKTsYaXKpy7pSEzrtNNQGJC') - assert_equal(result['tokenid'], self.pubkey) + assert_error(result) # get token balance for token with pubkey result = rpc.tokenbalance(tokenid, self.pubkey) From 619958c2a40844cda9807f6c41a0528ba4bef6cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 00:59:14 -1100 Subject: [PATCH 1258/3904] Merge earlier to expire locked funds --- src/cc/marmara.cpp | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5260df2ae..ec41cc3e8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -398,20 +398,51 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk; int32_t unlockht; int64_t inputsum,change = 0; std::string rawtx,errorstr; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,ht,numvouts; int64_t nValue,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); inputsum = AddNormalinputs(mtx,mypk,amount + txfee,1); + mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { - unlockht = MarmaraUnlockht(height); + remains = (amount + txfee) - inputsum; + std::vector > unspentOutputs; + GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); + SetCCunspents(unspentOutputs,coinaddr); + threshold = remains / 16; + refunlockht = MarmaraUnlockht(height); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if ( (nValue= it->second.satoshis) < threshold ) + continue; + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) + { + if ( unlockht < refunlockht ) + { + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + fprintf(stderr,"merge CC vout %s/v%d %.8f unlockht.%d < ref.%d\n",txid.GetHex().c_str(),vout,(double)nValue/COIN,unlockht,refunlockht); + inputsum += nValue; + remains -= nValue; + if ( inputsum >= amount + txfee ) + { + fprintf(stderr,"inputsum %.8f >= amount %.8f, update amount\n",(double)inputsum/COIN,(double)amount/COIN); + amount = inputsum; + break; + } + } + } + } + } } - if ( inputsum > 0 ) + if ( inputsum >= amount+txfee ) { - mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum > amount+txfee ) { change = (inputsum - amount); @@ -426,13 +457,13 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) result.push_back(Pair("rawtx",rawtx)); return(result); } - } + } else errorstr = (char *)"insufficient funds"; result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",errorstr)); return(result); } -// decide on what unlockht settlement change should have +// jl777: decide on what unlockht settlement change should have UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { From 9419e1034f922cd92af4940e82f13a83a5fb25f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:02:06 -1100 Subject: [PATCH 1259/3904] top16 --- src/cc/marmara.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ec41cc3e8..b943c1519 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -398,7 +398,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,ht,numvouts; int64_t nValue,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); @@ -976,6 +976,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { + CMutableTransaction mtx; std::vector pubkeys; UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0; std::vector issuances,closed; char coinaddr[64]; CPubKey Marmarapk; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); @@ -988,6 +989,7 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ GetCCaddress1of2(cp,coinaddr,Marmarapk,Mypubkey()); result.push_back(Pair("myCCactivated",coinaddr)); result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,1LL << 60,16)))); GetCCaddress(cp,coinaddr,Mypubkey()); result.push_back(Pair("myCCaddress",coinaddr)); From 64726e1e217c56bfd208458a3fbfdcbce247089a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:04:09 -1100 Subject: [PATCH 1260/3904] activated16 --- src/cc/marmara.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index b943c1519..af1d0e496 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -977,7 +977,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { CMutableTransaction mtx; std::vector pubkeys; - UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0; std::vector issuances,closed; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0,val; std::vector issuances,closed; char coinaddr[64]; CPubKey Marmarapk; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); @@ -988,8 +988,9 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ GetCCaddress1of2(cp,coinaddr,Marmarapk,Mypubkey()); result.push_back(Pair("myCCactivated",coinaddr)); - result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr)))); - result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,1LL << 60,16)))); + val = CCaddress_balance(coinaddr); + result.push_back(Pair("activated",ValueFromAmount(val))); + result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,val,16)))); GetCCaddress(cp,coinaddr,Mypubkey()); result.push_back(Pair("myCCaddress",coinaddr)); From bb41418f23425e0478016bcffd110f625272dfba Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:06:25 -1100 Subject: [PATCH 1261/3904] Get total --- src/cc/marmara.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index af1d0e496..88f47be0b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -977,7 +977,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency) { CMutableTransaction mtx; std::vector pubkeys; - UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0,val; std::vector issuances,closed; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0; std::vector issuances,closed; char coinaddr[64]; CPubKey Marmarapk; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); @@ -988,9 +988,8 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ GetCCaddress1of2(cp,coinaddr,Marmarapk,Mypubkey()); result.push_back(Pair("myCCactivated",coinaddr)); - val = CCaddress_balance(coinaddr); - result.push_back(Pair("activated",ValueFromAmount(val))); - result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,val,16)))); + result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,0,16)))); GetCCaddress(cp,coinaddr,Mypubkey()); result.push_back(Pair("myCCaddress",coinaddr)); From 951c9af6ffd6b99e4dd4aeb4fbe6e4b21d5b5d17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:11:44 -1100 Subject: [PATCH 1262/3904] Test --- src/cc/marmara.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 88f47be0b..5c8bca482 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -373,6 +373,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, { txid = it->first.txhash; vout = (int32_t)it->first.index; + char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis < threshold ) continue; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) From 81df6aeabdca4f7cbcfbe77cbe054524ab38399e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:16:41 -1100 Subject: [PATCH 1263/3904] Sort utxo gals --- src/cc/marmara.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5c8bca482..17d1aa6c8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -365,7 +365,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys,char *coinaddr,int64_t total,int32_t maxinputs) { - uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,n = 0; uint8_t funcid; CPubKey pk; + uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,i,n = 0; uint8_t funcid; CPubKey pk; std::vector vals; std::vector > unspentOutputs; SetCCunspents(unspentOutputs,coinaddr); threshold = total/(maxinputs+1); @@ -373,7 +373,6 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, { txid = it->first.txhash; vout = (int32_t)it->first.index; - char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis < threshold ) continue; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) @@ -387,12 +386,20 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, pubkeys.push_back(pk); } totalinputs += it->second.satoshis; + vals.push_back(it->second.satoshis); n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; } else fprintf(stderr,"null funcid\n"); } } + if ( maxinputs != 0 && total == 0 ) + { + std::sort(vals.begin(), vals.end()); + totalinputs = 0; + for (i=0; i Date: Fri, 18 Jan 2019 01:19:19 -1100 Subject: [PATCH 1264/3904] Continue in special case --- src/cc/marmara.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 17d1aa6c8..bf18c82aa 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -379,7 +379,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, { if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) { - char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f ht.%d unlockht.%d\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,ht,unlockht); + //char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f ht.%d unlockht.%d\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,ht,unlockht); if ( total != 0 && maxinputs != 0 ) { mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -388,6 +388,8 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, totalinputs += it->second.satoshis; vals.push_back(it->second.satoshis); n++; + if ( maxinputs != 0 && total == 0 ) + continue; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; } else fprintf(stderr,"null funcid\n"); @@ -395,7 +397,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, } if ( maxinputs != 0 && total == 0 ) { - std::sort(vals.begin(), vals.end()); + std::sort(vals.begin(),vals.end()); totalinputs = 0; for (i=0; i Date: Fri, 18 Jan 2019 01:30:17 -1100 Subject: [PATCH 1265/3904] Test --- src/cc/marmara.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index bf18c82aa..d4e6fedd9 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -411,6 +411,8 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; + if ( (height & 1) != 0 ) + height++; cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); @@ -418,12 +420,14 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { + refunlockht = MarmaraUnlockht(height); + result.push_back(Pair("height",height)); + result.push_back(Pair("unlockht",refunlockht)); remains = (amount + txfee) - inputsum; std::vector > unspentOutputs; GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); SetCCunspents(unspentOutputs,coinaddr); - threshold = remains / 16; - refunlockht = MarmaraUnlockht(height); + threshold = remains / (MARMARA_VINS+1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -443,7 +447,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) if ( inputsum >= amount + txfee ) { fprintf(stderr,"inputsum %.8f >= amount %.8f, update amount\n",(double)inputsum/COIN,(double)amount/COIN); - amount = inputsum; + amount = inputsum - txfee; break; } } From 22441d1ed66338a23085a8f4970700ca998b4485 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:31:10 -1100 Subject: [PATCH 1266/3904] Test --- src/cc/marmara.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d4e6fedd9..8ac73189c 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -421,6 +421,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) if ( inputsum < amount+txfee ) { refunlockht = MarmaraUnlockht(height); + result.push_back(Pair("normalfunds",ValueFromAmount(inputsum))); result.push_back(Pair("height",height)); result.push_back(Pair("unlockht",refunlockht)); remains = (amount + txfee) - inputsum; From 810ae9fd08511d6e4e4b532b3b59ce2952707170 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:36:36 -1100 Subject: [PATCH 1267/3904] Add normal inputs --- src/cc/marmara.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8ac73189c..298241039 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -408,7 +408,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; if ( (height & 1) != 0 ) @@ -416,7 +416,8 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - inputsum = AddNormalinputs(mtx,mypk,amount + txfee,1); + val = AddNormalinputs(mtx,mypk,0,0); + inputsum = AddNormalinputs(mtx,mypk,val,MARMARA_VINS); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From b5bfaaed0fb91e9de39e381a52d688987fdcee6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:39:59 -1100 Subject: [PATCH 1268/3904] Test --- src/cc/marmara.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 298241039..d139f2090 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -407,7 +407,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; @@ -416,8 +416,9 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - val = AddNormalinputs(mtx,mypk,0,0); - inputsum = AddNormalinputs(mtx,mypk,val,MARMARA_VINS); + val = AddNormalinputs(tmpmtx,mypk,0,0); + fprintf(stderr,"normal inputs %.8f numvins.%d\n",(double)val/COIN,(int32_t)tmpmtx.vin.size()); + inputsum = AddNormalinputs(mtx,mypk,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From d3a0c0e897ed35d288810dcfb5e36caed2ac452a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:43:10 -1100 Subject: [PATCH 1269/3904] Normalinputs2 --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d139f2090..e99221a04 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -416,9 +416,9 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - val = AddNormalinputs(tmpmtx,mypk,0,0); + val = AddNormalinputs2(tmpmtx,mypk,0,0); fprintf(stderr,"normal inputs %.8f numvins.%d\n",(double)val/COIN,(int32_t)tmpmtx.vin.size()); - inputsum = AddNormalinputs(mtx,mypk,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); + inputsum = AddNormalinputs2(mtx,mypk,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From 5be35df3dfb452352ac6bb1b40ba1db33cbf6758 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:44:16 -1100 Subject: [PATCH 1270/3904] Test --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index e99221a04..2d99ae31f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -416,9 +416,9 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - val = AddNormalinputs2(tmpmtx,mypk,0,0); + val = AddNormalinputs2(tmpmtx,0,0); fprintf(stderr,"normal inputs %.8f numvins.%d\n",(double)val/COIN,(int32_t)tmpmtx.vin.size()); - inputsum = AddNormalinputs2(mtx,mypk,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); + inputsum = AddNormalinputs2(mtx,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From baefcb30c165eb76cfb7021e93cf6e6e5ec82740 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:51:13 -1100 Subject: [PATCH 1271/3904] mypk --- src/cc/marmara.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 2d99ae31f..6085981e1 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -416,7 +416,8 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - val = AddNormalinputs2(tmpmtx,0,0); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); + val = AddNormalinputs2(tmpmtx,CCaddressbalance(coinaddr),MARMARA_VINS); fprintf(stderr,"normal inputs %.8f numvins.%d\n",(double)val/COIN,(int32_t)tmpmtx.vin.size()); inputsum = AddNormalinputs2(mtx,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); From dce284a1d18da00a07c4455a30309b91b75d2d9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:52:05 -1100 Subject: [PATCH 1272/3904] _ --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 6085981e1..3109b5ee0 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -417,7 +417,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); - val = AddNormalinputs2(tmpmtx,CCaddressbalance(coinaddr),MARMARA_VINS); + val = AddNormalinputs2(tmpmtx,CCaddress_balance(coinaddr),MARMARA_VINS); fprintf(stderr,"normal inputs %.8f numvins.%d\n",(double)val/COIN,(int32_t)tmpmtx.vin.size()); inputsum = AddNormalinputs2(mtx,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); From 5f1790817271d975a7e2ac86c0a88498b5d7e6dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:55:30 -1100 Subject: [PATCH 1273/3904] Revert --- src/cc/marmara.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 3109b5ee0..75fa385b4 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -417,9 +417,8 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); - val = AddNormalinputs2(tmpmtx,CCaddress_balance(coinaddr),MARMARA_VINS); - fprintf(stderr,"normal inputs %.8f numvins.%d\n",(double)val/COIN,(int32_t)tmpmtx.vin.size()); - inputsum = AddNormalinputs2(mtx,val,tmpmtx.vin.size() < MARMARA_VINS ? tmpmtx.vin.size() : MARMARA_VINS); + inputsum = AddNormalinputs2(mtx,amount,MARMARA_VINS); + fprintf(stderr,"normal inputs %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From 04b11f66d4ed94af7cee7b16a465ebd971cffca4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:07:01 -1100 Subject: [PATCH 1274/3904] Test --- src/cc/marmara.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 75fa385b4..0a2a5e13b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -408,7 +408,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum=0,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; if ( (height & 1) != 0 ) @@ -417,8 +417,11 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); - inputsum = AddNormalinputs2(mtx,amount,MARMARA_VINS); - fprintf(stderr,"normal inputs %.8f\n",(double)inputsum/COIN); + if ( (val= CCaddress_balance(coinaddr)) < amount ) + val -= txfee; + if ( val > txfee ) + inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); + //fprintf(stderr,"normal inputs %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From d099a1b607aad1f6d460f9bc279bc4cb53787138 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:08:29 -1100 Subject: [PATCH 1275/3904] Vals --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 0a2a5e13b..da6b7d9c2 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -421,7 +421,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) val -= txfee; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); - //fprintf(stderr,"normal inputs %.8f\n",(double)inputsum/COIN); + fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From 0a669e79b2498ae0a0976f4943e5235d5fa715d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:10:47 -1100 Subject: [PATCH 1276/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index da6b7d9c2..8c848e3f0 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -418,7 +418,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) - val -= txfee; + val = (amount - txfee) / 2; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); From 220b23b70d09bec953ef09533642cd56bd784b93 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:13:19 -1100 Subject: [PATCH 1277/3904] Fix > case --- src/cc/marmara.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8c848e3f0..eb313c587 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -419,9 +419,10 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) val = (amount - txfee) / 2; + else val = amount; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); - fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); + //fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) { From d9b5673a14bc2e93b3527cf0bc2dcfe89e9df8a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:18:30 -1100 Subject: [PATCH 1278/3904] CCaddr2 --- src/cc/marmara.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index eb313c587..4a6d799cc 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -435,6 +435,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); SetCCunspents(unspentOutputs,coinaddr); threshold = remains / (MARMARA_VINS+1); + CCaddr2set(cp,EVAL_MARMARA,gatewayspk,cp->CCpriv,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -448,12 +449,12 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) if ( unlockht < refunlockht ) { mtx.vin.push_back(CTxIn(txid,vout,CScript())); - fprintf(stderr,"merge CC vout %s/v%d %.8f unlockht.%d < ref.%d\n",txid.GetHex().c_str(),vout,(double)nValue/COIN,unlockht,refunlockht); + //fprintf(stderr,"merge CC vout %s/v%d %.8f unlockht.%d < ref.%d\n",txid.GetHex().c_str(),vout,(double)nValue/COIN,unlockht,refunlockht); inputsum += nValue; remains -= nValue; if ( inputsum >= amount + txfee ) { - fprintf(stderr,"inputsum %.8f >= amount %.8f, update amount\n",(double)inputsum/COIN,(double)amount/COIN); + //fprintf(stderr,"inputsum %.8f >= amount %.8f, update amount\n",(double)inputsum/COIN,(double)amount/COIN); amount = inputsum - txfee; break; } From 28154f6212398ccaf412c8f7ffd883068261147d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:19:17 -1100 Subject: [PATCH 1279/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 4a6d799cc..7eb1675d5 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -435,7 +435,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); SetCCunspents(unspentOutputs,coinaddr); threshold = remains / (MARMARA_VINS+1); - CCaddr2set(cp,EVAL_MARMARA,gatewayspk,cp->CCpriv,coinaddr); + CCaddr2set(cp,EVAL_MARMARA,Marmarapk,cp->CCpriv,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 4227647cc2ebdcbc14af01a0304a830c49655b04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:22:03 -1100 Subject: [PATCH 1280/3904] CCaddrTokens1of2set --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 7eb1675d5..da0a5b5e3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -435,7 +435,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); SetCCunspents(unspentOutputs,coinaddr); threshold = remains / (MARMARA_VINS+1); - CCaddr2set(cp,EVAL_MARMARA,Marmarapk,cp->CCpriv,coinaddr); + CCaddrTokens1of2set(cp,Marmarapk,mypk,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 96cd77ae65bf68ec24aec12d03f8b29a574035f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:24:33 -1100 Subject: [PATCH 1281/3904] CCaddr1of2set --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index da0a5b5e3..8ac9b3094 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -435,7 +435,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); SetCCunspents(unspentOutputs,coinaddr); threshold = remains / (MARMARA_VINS+1); - CCaddrTokens1of2set(cp,Marmarapk,mypk,coinaddr); + CCaddr1of2set(cp,Marmarapk,mypk,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 71f6a35db9e3999f12037dc64e334724b5f76dda Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:27:08 -1100 Subject: [PATCH 1282/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8ac9b3094..208036cab 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -418,7 +418,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) - val = (amount - txfee) / 2; + val = 9*(amount - txfee) / 10; else val = amount; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); From 1bc00bf8223f11e9a97eff16adca900276a8956f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:28:55 -1100 Subject: [PATCH 1283/3904] 2/3 --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 208036cab..a46b67e29 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -418,7 +418,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) - val = 9*(amount - txfee) / 10; + val = 2*(amount - txfee) / 3; else val = amount; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); From 681177257d0a8868f2cac4cb2a9c4fc5ebb3a29e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:30:26 -1100 Subject: [PATCH 1284/3904] Test --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index a46b67e29..185e67d66 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -418,10 +418,10 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) - val = 2*(amount - txfee) / 3; + val = 9*(amount - txfee) / 10; else val = amount; if ( val > txfee ) - inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); + inputsum = AddNormalinputs2(mtx,val,CC_MAXVINS/2); //fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) From 7d4824b53458e3b40394d75965a78ce2d01f1c50 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:32:06 -1100 Subject: [PATCH 1285/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 185e67d66..d9efa583b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -418,7 +418,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) - val = 9*(amount - txfee) / 10; + val = 3*(amount - txfee) / 4; else val = amount; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,CC_MAXVINS/2); From 3b0a779f0d44782e29dca0466abffd1b70f380b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:35:10 -1100 Subject: [PATCH 1286/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d9efa583b..22962c94e 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -418,7 +418,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) - val = 3*(amount - txfee) / 4; + val = 2*(amount - txfee) / 3; else val = amount; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,CC_MAXVINS/2); From 21bd1c08e861d2dd690c9431f9d8f5c96c4007fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:36:53 -1100 Subject: [PATCH 1287/3904] Val -= txfee --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 22962c94e..795b95186 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -418,7 +418,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( (val= CCaddress_balance(coinaddr)) < amount ) - val = 2*(amount - txfee) / 3; + val -= txfee; else val = amount; if ( val > txfee ) inputsum = AddNormalinputs2(mtx,val,CC_MAXVINS/2); From 2a7ecf6e03a5c788eea625a60ae607a7dcc7513e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 00:06:17 -1100 Subject: [PATCH 1288/3904] Comments --- src/komodo_bitcoind.h | 1 + src/miner.cpp | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 19a5f8103..d24492317 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2236,6 +2236,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { + // add opreturn // signSuccess = CCFinalizetx(...) } if (!signSuccess) diff --git a/src/miner.cpp b/src/miner.cpp index 3a163c637..c71bc2461 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -541,9 +541,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[0].nValue += 5000; pblock->vtx[0] = txNew; - //fprintf(stderr,"ht.%d cmp.%d [%d %d %d %d %d]\n",nHeight,nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0,nHeight > 1,ASSETCHAINS_SYMBOL[0] != 0, (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1), ASSETCHAINS_COMMISSION != 0,(commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0); - // check if coinbase transactions must be time locked at current subsidy and prepend the time lock - // to transaction if so, cast for GTE operator if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) { char checkaddr[64]; From 539b6dd1a9228d8174dc8cb0de29aabfeb437afe Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 00:38:55 -1100 Subject: [PATCH 1289/3904] -ac_ccenable[] --- src/cc/CCinclude.h | 1 + src/cc/eval.cpp | 5 +++++ src/komodo_globals.h | 1 + src/komodo_utils.h | 19 ++++++++++++++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index d103f408d..d3acbd5e6 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -55,6 +55,7 @@ extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; extern char ASSETCHAINS_SYMBOL[]; extern std::string CCerror; +extern ASSETCHAINS_CCDISABLES[256]; #define CC_MAXVINS 1024 diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 9161f2007..b98982ecd 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -65,6 +65,11 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) return Invalid("empty-eval"); uint8_t ecode = cond->code[0]; + if ( ASSETCHAINS_CCDISABLES[ecode] != 0 ) + { + fprintf(stderr,"%s evalcode.%d %02x\n",txTo.GetHash().GetHex().c_str(),ecode,ecode); + return Invalid("disabled-code, -ac_ccenables didnt include this ecode"); + } cp = &CCinfos[(int32_t)ecode]; if ( cp->didinit == 0 ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f434674b7..4e1d0ef8d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -71,6 +71,7 @@ uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; uint32_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; +uint8_t ASSETCHAINS_CCENABLE[256],ASSETCHAINS_CCDISABLES[256]; #define _ASSETCHAINS_EQUIHASH 0 uint32_t ASSETCHAINS_NUMALGOS = 2; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 017a17eff..163b1c43a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1654,7 +1654,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); if ( GetBoolArg("-gen", false) != 0 ) @@ -1779,6 +1779,23 @@ void komodo_args(char *argv0) ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); + Split(GetArg("-ac_ccenable",""), ASSETCHAINS_CCENABLE, 0); + for (i=nonz=0; i<0x100; i++) + { + if ( ASSETCHAINS_CCENABLE[i] != 0 ) + { + nonz++; + fprintf(stderr,"%d ",ASSETCHAINS_CCENABLE[i]); + } + } + fprintf(stderr,"nonz.%d CCENABLES[]\n"); + if ( nonz > 0 ) + { + for (i=0; i<256; i++) + ASSETCHAINS_CCDISABLES[i] = 1; + for (i=0; i<256; i++) + ASSETCHAINS_CCDISABLES[ASSETCHAINS_CCENABLE[i]] = 0; + } if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { fprintf(stderr,"can only have one of -ac_beam or -ac_coda\n"); From 6e40c81b942c63ad43684ee6765accb92e5a41de Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 00:39:53 -1100 Subject: [PATCH 1290/3904] uint8_t --- src/cc/CCinclude.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index d3acbd5e6..7541dc3a4 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -55,7 +55,7 @@ extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; extern char ASSETCHAINS_SYMBOL[]; extern std::string CCerror; -extern ASSETCHAINS_CCDISABLES[256]; +extern uint8_t ASSETCHAINS_CCDISABLES[256]; #define CC_MAXVINS 1024 From 6e71c40201d247de410c7a12cb7f4e2ac87aa8c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 00:48:53 -1100 Subject: [PATCH 1291/3904] Ccenables --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 4e1d0ef8d..ba5e84135 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -71,7 +71,7 @@ uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; uint32_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; -uint8_t ASSETCHAINS_CCENABLE[256],ASSETCHAINS_CCDISABLES[256]; +uint8_t ASSETCHAINS_CCDISABLES[256]; #define _ASSETCHAINS_EQUIHASH 0 uint32_t ASSETCHAINS_NUMALGOS = 2; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 163b1c43a..e074bd4c0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1654,9 +1654,10 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); - + memset(ccenables,0,sizeof(ccenables)); + memset(disablebits,0,sizeof(disablebits)); if ( GetBoolArg("-gen", false) != 0 ) { KOMODO_MININGTHREADS = GetArg("-genproclimit",-1); @@ -1779,22 +1780,25 @@ void komodo_args(char *argv0) ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); - Split(GetArg("-ac_ccenable",""), ASSETCHAINS_CCENABLE, 0); + Split(GetArg("-ac_ccenable",""), ccenables, 0); for (i=nonz=0; i<0x100; i++) { - if ( ASSETCHAINS_CCENABLE[i] != 0 ) + if ( ccenables[i] != 0 ) { nonz++; - fprintf(stderr,"%d ",ASSETCHAINS_CCENABLE[i]); + fprintf(stderr,"%d ",ccenables[i]); } } - fprintf(stderr,"nonz.%d CCENABLES[]\n"); + fprintf(stderr,"nonz.%d ccenables[]\n",nonz); if ( nonz > 0 ) { for (i=0; i<256; i++) ASSETCHAINS_CCDISABLES[i] = 1; for (i=0; i<256; i++) - ASSETCHAINS_CCDISABLES[ASSETCHAINS_CCENABLE[i]] = 0; + { + SETBIT(disablebits,i); + ASSETCHAINS_CCDISABLES[ccenables[i] & 0xff] = 0; + } } if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { @@ -1880,7 +1884,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1956,6 +1960,11 @@ void komodo_args(char *argv0) extraptr[extralen++] = 'c'; if ( ASSETCHAINS_MARMARA != 0 ) extraptr[extralen++] = ASSETCHAINS_MARMARA; + if ( nonz > 0 ) + { + memcpy(&extraptr[extralen],disablebits,sizeof(disablebits)); + extralen += sizeof(disablebits); + } } addn = GetArg("-seednode",""); From 70fba21c4681a0d2a23166694ac4fc89f4f2db21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 00:50:51 -1100 Subject: [PATCH 1292/3904] SETBIT --- src/komodo_defs.h | 4 ++++ src/komodo_utils.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index bd516be61..91fcadddb 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -30,6 +30,10 @@ #define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019 #define _COINBASE_MATURITY 100 +#define SETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] |= (1 << ((bitoffset) & 7))) +#define GETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] & (1 << ((bitoffset) & 7))) +#define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7))) + extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e074bd4c0..cb2ea7a1e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1786,7 +1786,7 @@ void komodo_args(char *argv0) if ( ccenables[i] != 0 ) { nonz++; - fprintf(stderr,"%d ",ccenables[i]); + fprintf(stderr,"%d ",(uint8_t)(ccenables[i] & 0xff)); } } fprintf(stderr,"nonz.%d ccenables[]\n",nonz); From ac9bd541b4c32e8971d1a740813bda0ad08409d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 00:57:55 -1100 Subject: [PATCH 1293/3904] Require cc for ccenable --- src/komodo_utils.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index cb2ea7a1e..1352c5bf7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1780,24 +1780,27 @@ void komodo_args(char *argv0) ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); - Split(GetArg("-ac_ccenable",""), ccenables, 0); - for (i=nonz=0; i<0x100; i++) + if ( ASSETCHAINS_CC != 0 ) { - if ( ccenables[i] != 0 ) + Split(GetArg("-ac_ccenable",""), ccenables, 0); + for (i=nonz=0; i<0x100; i++) { - nonz++; - fprintf(stderr,"%d ",(uint8_t)(ccenables[i] & 0xff)); + if ( ccenables[i] != 0 ) + { + nonz++; + fprintf(stderr,"%d ",(uint8_t)(ccenables[i] & 0xff)); + } } - } - fprintf(stderr,"nonz.%d ccenables[]\n",nonz); - if ( nonz > 0 ) - { - for (i=0; i<256; i++) - ASSETCHAINS_CCDISABLES[i] = 1; - for (i=0; i<256; i++) + fprintf(stderr,"nonz.%d ccenables[]\n",nonz); + if ( nonz > 0 ) { - SETBIT(disablebits,i); - ASSETCHAINS_CCDISABLES[ccenables[i] & 0xff] = 0; + for (i=0; i<256; i++) + ASSETCHAINS_CCDISABLES[i] = 1; + for (i=0; i<256; i++) + { + SETBIT(disablebits,i); + ASSETCHAINS_CCDISABLES[ccenables[i] & 0xff] = 0; + } } } if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) From 3ab60f65c75e8d3ef3681920e8a21b3ba20cf54f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:00:51 -1100 Subject: [PATCH 1294/3904] Fix disable bits --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1352c5bf7..ea1741d5a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1798,7 +1798,7 @@ void komodo_args(char *argv0) ASSETCHAINS_CCDISABLES[i] = 1; for (i=0; i<256; i++) { - SETBIT(disablebits,i); + SETBIT(disablebits,(ccenables[i] & 0xff)); ASSETCHAINS_CCDISABLES[ccenables[i] & 0xff] = 0; } } From 37019a6438e46c6f247a2ff0990725381a93d1eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:02:53 -1100 Subject: [PATCH 1295/3904] Fix bits --- src/komodo_utils.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ea1741d5a..eb6134ffe 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1795,10 +1795,13 @@ void komodo_args(char *argv0) if ( nonz > 0 ) { for (i=0; i<256; i++) + { ASSETCHAINS_CCDISABLES[i] = 1; + SETBIT(disablebits,i); + } for (i=0; i<256; i++) { - SETBIT(disablebits,(ccenables[i] & 0xff)); + CLEARBIT(disablebits,(ccenables[i] & 0xff)); ASSETCHAINS_CCDISABLES[ccenables[i] & 0xff] = 0; } } From c5dcd3f8282288b2af851712b7d047f32b2761b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:20:27 -1100 Subject: [PATCH 1296/3904] cclib.so --- src/Makefile.am | 3 ++- src/cc/eval.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 5e665cc3c..96ab3f1fa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -571,7 +571,8 @@ komodod_LDADD += \ $(LIBBITCOIN_CRYPTO) \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ - $(LIBZCASH_LIBS) + $(LIBZCASH_LIBS) \ + cclib.so if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) diff --git a/src/cc/eval.h b/src/cc/eval.h index de1636ab8..be86629a0 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -59,6 +59,8 @@ EVAL(EVAL_TOKENS, 0xf2) +// evalcodes 0x10 to 0x7f are reserved for cclib dynamic CC + typedef uint8_t EvalCode; From 614c8a61d5c280dc6e76bef72cb6f475f7f46101 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:21:43 -1100 Subject: [PATCH 1297/3904] Win dll spot --- src/Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index 96ab3f1fa..327d32e3f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -572,7 +572,12 @@ komodod_LDADD += \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) \ +if TARGET_WINDOWS + +# add .dll somehow +else cclib.so +endif if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) From f93a96af0741da186fb9bf7933289a16f0abdc8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:22:54 -1100 Subject: [PATCH 1298/3904] -if --- src/Makefile.am | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 327d32e3f..b1e67cf2e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -572,12 +572,8 @@ komodod_LDADD += \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) \ -if TARGET_WINDOWS - -# add .dll somehow -else cclib.so -endif + if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) From b22c190e3c8b87f6551b62b5a1eb97bfaa165ca6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:33:06 -1100 Subject: [PATCH 1299/3904] cclib.cpp --- src/Makefile.am | 3 +++ src/cc/cclib.cpp | 2 ++ src/cc/eval.h | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 src/cc/cclib.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b1e67cf2e..46e03dc83 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -559,6 +559,9 @@ if ENABLE_WALLET komodod_LDADD += $(LIBBITCOIN_WALLET) endif +cclib.so: cclib.cpp + gcc -o cclib.so -c cclib.cpp + komodod_LDADD += \ $(BOOST_LIBS) \ $(BDB_LIBS) \ diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp new file mode 100644 index 000000000..5cd56f9eb --- /dev/null +++ b/src/cc/cclib.cpp @@ -0,0 +1,2 @@ + +char *CClib_name() { return("stub"); } diff --git a/src/cc/eval.h b/src/cc/eval.h index be86629a0..a42bbdb2f 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -60,6 +60,8 @@ // evalcodes 0x10 to 0x7f are reserved for cclib dynamic CC +#define EVAL_FIRSTUSER 0x10 +#define EVAL_LASTUSER 0x7f typedef uint8_t EvalCode; From b693dfd93c8659596d4c19091a7535562f0400e8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:35:21 -1100 Subject: [PATCH 1300/3904] Test --- src/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 46e03dc83..7de831f3b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -560,7 +560,6 @@ komodod_LDADD += $(LIBBITCOIN_WALLET) endif cclib.so: cclib.cpp - gcc -o cclib.so -c cclib.cpp komodod_LDADD += \ $(BOOST_LIBS) \ From 32d407e84e1729e829aae95d392265a55457c570 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:37:20 -1100 Subject: [PATCH 1301/3904] Char * --- src/Makefile.am | 2 -- src/cc/cclib.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7de831f3b..b1e67cf2e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -559,8 +559,6 @@ if ENABLE_WALLET komodod_LDADD += $(LIBBITCOIN_WALLET) endif -cclib.so: cclib.cpp - komodod_LDADD += \ $(BOOST_LIBS) \ $(BDB_LIBS) \ diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 5cd56f9eb..29ea4b787 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -1,2 +1,2 @@ -char *CClib_name() { return("stub"); } +char *CClib_name() { return((char *)"stub"); } From a22cc60e1a7c896d866f867cbc854076973310f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 01:42:22 -1100 Subject: [PATCH 1302/3904] Make --- src/Makefile.am | 1 - src/cc/makecclib | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100755 src/cc/makecclib diff --git a/src/Makefile.am b/src/Makefile.am index b1e67cf2e..96ab3f1fa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -574,7 +574,6 @@ komodod_LDADD += \ $(LIBZCASH_LIBS) \ cclib.so - if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) endif diff --git a/src/cc/makecclib b/src/cc/makecclib new file mode 100755 index 000000000..e90f0877b --- /dev/null +++ b/src/cc/makecclib @@ -0,0 +1 @@ +gcc -fPIC -shared -c -o ../cclib.so cclib.cpp From c310c7fa47e7048c98cb16b9e93beb93fd9e6975 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:05:51 -1100 Subject: [PATCH 1303/3904] CClib_Dispatch --- src/cc/cclib.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/cc/eval.cpp | 7 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 29ea4b787..f89301b34 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -1,2 +1,40 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include +#include + +#include "../primitives/block.h" +#include "../primitives/transaction.h" +#include "../script/cc.h" +#include "eval.h" +#include "utils.h" +#include "CCinclude.h" +#include "../main.h" +#include "../chain.h" +#include "../core_io.h" +#include "../crosschain.h" char *CClib_name() { return((char *)"stub"); } + +bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) +{ + uint8_t evalcode = cond->code[0]; + if ( evalcode >= EVAL_FIRSTUSER && evalcode <= EVAL_LASTUSER ) + { + + } + return eval->Invalid("cclib CC must have evalcode between 16 and 127"); +} diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index b98982ecd..e30ec263c 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -27,6 +27,7 @@ #include "core_io.h" #include "crosschain.h" +bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn); Eval* EVAL_TEST = 0; struct CCcontract_info CCinfos[0x100]; @@ -70,13 +71,17 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) fprintf(stderr,"%s evalcode.%d %02x\n",txTo.GetHash().GetHex().c_str(),ecode,ecode); return Invalid("disabled-code, -ac_ccenables didnt include this ecode"); } + std::vector vparams(cond->code+1, cond->code+cond->codeLength); + if ( ecode >= EVAL_FIRSTUSER && ecode <= EVAL_LASTUSER ) + { + return CClib_Dispatch(cond,this,vparams,txTo,nIn); + } cp = &CCinfos[(int32_t)ecode]; if ( cp->didinit == 0 ) { CCinit(cp,ecode); cp->didinit = 1; } - std::vector vparams(cond->code+1, cond->code+cond->codeLength); switch ( ecode ) { case EVAL_IMPORTPAYOUT: From 5a4c3ce5b3004bf27da6a1bb20d99baf9fd0b7f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:08:22 -1100 Subject: [PATCH 1304/3904] cryptoconditions.h --- src/cc/eval.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index e30ec263c..7c578c8c3 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -14,8 +14,8 @@ ******************************************************************************/ #include -#include +#include "../cryptoconditions/include/cryptoconditions.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "script/cc.h" From 8420bb5e96288bda4e29f868f9dd67b6ec920d42 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:09:06 -1100 Subject: [PATCH 1305/3904] Fix --- src/cc/cclib.cpp | 4 ++-- src/cc/eval.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f89301b34..cca7a812a 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -14,8 +14,8 @@ ******************************************************************************/ #include -#include - +//#include +#include "../cryptoconditions/include/cryptoconditions.h" #include "../primitives/block.h" #include "../primitives/transaction.h" #include "../script/cc.h" diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 7c578c8c3..e30ec263c 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -14,8 +14,8 @@ ******************************************************************************/ #include +#include -#include "../cryptoconditions/include/cryptoconditions.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "script/cc.h" From 05ffb90ab69cc52a65770af14644bccec2596251 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:10:35 -1100 Subject: [PATCH 1306/3904] Test --- src/cc/cclib.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index cca7a812a..d6e7a95fc 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -15,17 +15,17 @@ #include //#include -#include "../cryptoconditions/include/cryptoconditions.h" -#include "../primitives/block.h" -#include "../primitives/transaction.h" -#include "../script/cc.h" -#include "eval.h" -#include "utils.h" -#include "CCinclude.h" -#include "../main.h" -#include "../chain.h" -#include "../core_io.h" -#include "../crosschain.h" +#include "cryptoconditions/include/cryptoconditions.h" +#include "primitives/block.h" +#include "primitives/transaction.h" +#include "script/cc.h" +#include "cc/eval.h" +#include "cc/utils.h" +#include "cc/CCinclude.h" +#include "main.h" +#include "chain.h" +#include "core_io.h" +#include "crosschain.h" char *CClib_name() { return((char *)"stub"); } From afc693198f048820a3ec7af0200c8b1775f77632 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:14:25 -1100 Subject: [PATCH 1307/3904] Test --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index d6e7a95fc..bd66f5bda 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -15,7 +15,7 @@ #include //#include -#include "cryptoconditions/include/cryptoconditions.h" +#include "../cryptoconditions/include/cryptoconditions.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "script/cc.h" From a761d97300566eff6f68bad80843c1e924a28629 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:24:31 -1100 Subject: [PATCH 1308/3904] Makecclib --- src/cc/cclib.cpp | 4 ++-- src/cc/makecclib | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index bd66f5bda..036971666 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -14,8 +14,8 @@ ******************************************************************************/ #include -//#include -#include "../cryptoconditions/include/cryptoconditions.h" +#include + #include "primitives/block.h" #include "primitives/transaction.h" #include "script/cc.h" diff --git a/src/cc/makecclib b/src/cc/makecclib index e90f0877b..47aec377d 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1 +1 @@ -gcc -fPIC -shared -c -o ../cclib.so cclib.cpp +gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../cclib.so cclib.cpp From 33a2ac6e3bbeddabd72ea4da79facaa999d08eb7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:33:23 -1100 Subject: [PATCH 1309/3904] -ac_cclib --- src/cc/cclib.cpp | 15 ++++++++++++--- src/cc/eval.cpp | 4 +++- src/komodo_globals.h | 2 +- src/komodo_utils.h | 14 ++++++++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 036971666..24c6380bd 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -27,14 +27,23 @@ #include "core_io.h" #include "crosschain.h" -char *CClib_name() { return((char *)"stub"); } +#define MYCCLIBNAME ((char *)"stub") +extern std::string ASSETCHAINS_CCLIB; + +char *CClib_name() { return(MYCCLIBNAME); } bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { - uint8_t evalcode = cond->code[0]; + uint8_t evalcode; + if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) + { + fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB,MYCCLIBNAME); + return eval->Invalid("-ac_cclib name mismatches myname"); + } + evalcode = cond->code[0]; if ( evalcode >= EVAL_FIRSTUSER && evalcode <= EVAL_LASTUSER ) { - + return(true); } return eval->Invalid("cclib CC must have evalcode between 16 and 127"); } diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index e30ec263c..bd8c69a55 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -74,7 +74,9 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) std::vector vparams(cond->code+1, cond->code+cond->codeLength); if ( ecode >= EVAL_FIRSTUSER && ecode <= EVAL_LASTUSER ) { - return CClib_Dispatch(cond,this,vparams,txTo,nIn); + if ( ASSETCHAINS_CCLIB.size() > 0 && ASSETCHAINS_CCLIB == CClib_name() ) + return CClib_Dispatch(cond,this,vparams,txTo,nIn); + else return Invalid("mismatched -ac_cclib vs CClib_name"); } cp = &CCinfos[(int32_t)ecode]; if ( cp->didinit == 0 ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index ba5e84135..79b56cbbb 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -48,7 +48,7 @@ unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,ASSETCHAINS_SELFIMPORT; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; bool VERUS_MINTBLOCKS; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index eb6134ffe..289a84d7c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1782,6 +1782,7 @@ void komodo_args(char *argv0) ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); if ( ASSETCHAINS_CC != 0 ) { + ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); Split(GetArg("-ac_ccenable",""), ccenables, 0); for (i=nonz=0; i<0x100; i++) { @@ -1890,7 +1891,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1971,8 +1972,17 @@ void komodo_args(char *argv0) memcpy(&extraptr[extralen],disablebits,sizeof(disablebits)); extralen += sizeof(disablebits); } + if ( ASSETCHAINS_CCLIB.size() > 1 ) + { + for (i=0; i 0 ) ASSETCHAINS_SEED = 1; From cc1d11914488a18b78cedd4a22f33b9d313f775a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:34:33 -1100 Subject: [PATCH 1310/3904] Test --- src/cc/CCinclude.h | 2 +- src/cc/cclib.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 7541dc3a4..680e4ca5c 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -54,7 +54,7 @@ one other technical note is that komodod has the insight-explorer extensions bui extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; extern char ASSETCHAINS_SYMBOL[]; -extern std::string CCerror; +extern std::string CCerror,ASSETCHAINS_CCLIB; extern uint8_t ASSETCHAINS_CCDISABLES[256]; #define CC_MAXVINS 1024 diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 24c6380bd..9dc74e424 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -28,7 +28,6 @@ #include "crosschain.h" #define MYCCLIBNAME ((char *)"stub") -extern std::string ASSETCHAINS_CCLIB; char *CClib_name() { return(MYCCLIBNAME); } From 385c79357ff8204ead60d0d7b12887b18b85ecd2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:35:27 -1100 Subject: [PATCH 1311/3904] char *CClib_name() --- src/cc/eval.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index bd8c69a55..ca2703bff 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -28,6 +28,7 @@ #include "crosschain.h" bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn); +char *CClib_name(); Eval* EVAL_TEST = 0; struct CCcontract_info CCinfos[0x100]; From f31416834ae86490fbfe855ee2435d8d9348f936 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 02:40:24 -1100 Subject: [PATCH 1312/3904] Char * --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 9dc74e424..10a289459 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -36,7 +36,7 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co uint8_t evalcode; if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) { - fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB,MYCCLIBNAME); + fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME); return eval->Invalid("-ac_cclib name mismatches myname"); } evalcode = cond->code[0]; From c7002513e383907de706e1e6459370d6ac448afe Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 03:37:28 -1100 Subject: [PATCH 1313/3904] Height and from_mempool in club --- src/cc/cclib.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 10a289459..889c40d8c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -33,12 +33,22 @@ char *CClib_name() { return(MYCCLIBNAME); } bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { - uint8_t evalcode; + uint8_t evalcode; int32_t height,from_mempool; if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) { fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME); return eval->Invalid("-ac_cclib name mismatches myname"); } + height = KOMODO_CONNECTING; + if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation + return(true); + if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE ) + return eval->Invalid("CC are disabled or not active yet"); + if ( (KOMODO_CONNECTING & (1<<30)) != 0 ) + { + from_mempool = 1; + height &= ((1<<30) - 1); + } evalcode = cond->code[0]; if ( evalcode >= EVAL_FIRSTUSER && evalcode <= EVAL_LASTUSER ) { From 6692b4b0c6a2fe677aced9a40e821a67df6ac2cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 04:06:59 -1100 Subject: [PATCH 1314/3904] Locked staking --- src/komodo_bitcoind.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d24492317..4ac20713b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2149,8 +2149,26 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { - // calc 1of2 address - // iterate all unspents not spent in mempool and komodo_addutxo + struct CCcontract_info *cp,C; uint256 txid; int32_t vout; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk; + std::vector > unspentOutputs; + cp = CCinit(&C,EVAL_MARMARA); + mypk = pubkey2pk(Mypubkey()); + Marmarapk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if ( (nValue= it->second.satoshis) < COIN ) + continue; + if ( GetTransaction(txid,tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + const CScript &scriptPubKey = tx.vout[vout].scriptPubKey; + array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,txid,vout,coinaddr,hashbuf,(CScript)scriptPubKey); + fprintf(stderr,"addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp); + } + } } lasttime = (uint32_t)time(NULL); //fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); From 66198b83f0407e5487dd893d361a9279186f8d82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 04:07:41 -1100 Subject: [PATCH 1315/3904] Mypk --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4ac20713b..fbd73f59f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2154,7 +2154,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); + GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); SetCCunspents(unspentOutputs,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { From b08d57ca4828b1841284da986c218953c46451b7 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 19 Jan 2019 19:00:26 +0100 Subject: [PATCH 1316/3904] resolve conflict jl777:master->komodoplatform:master --- src/chainparams.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index af82f3a35..02b73f04b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -92,7 +92,8 @@ public: strNetworkID = "main"; strCurrencyUnits = "KMD"; - bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC) + bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md + consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800 consensus.nSubsidySlowStartInterval = 20000; consensus.nSubsidyHalvingInterval = 840000; From 240fdaa384fb247b2e352fb211916a51b24fead9 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 03:11:54 +0100 Subject: [PATCH 1317/3904] add cclib to makefile --- zcutil/build.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zcutil/build.sh b/zcutil/build.sh index 08517475c..68239e16e 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,6 +101,21 @@ eval "$MAKE" --version as --version ld -v +#BUILD CCLIB + +WD=$PWD +cd src/cc +echo $PWD + +if make "$@"; then + echo CCLIB BUILD SUCCESSFUL +else + echo CCLIB BUILD FAILED + exit 1 +fi + +cd $WD + HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh From 5fe3792aef1b662640e37d5c076e7793b3ac5445 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 03:13:21 +0100 Subject: [PATCH 1318/3904] create cclib Makefile --- src/cc/Makefile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/cc/Makefile diff --git a/src/cc/Makefile b/src/cc/Makefile new file mode 100644 index 000000000..5848d46dd --- /dev/null +++ b/src/cc/Makefile @@ -0,0 +1,19 @@ +SHELL = /bin/sh +CC = gcc +#CXXFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +DEBUGFLAGS = -O0 -D _DEBUG +RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program + +TARGET = ../cclib.so +SOURCES = cclib.cpp +#HEADERS = $(shell echo ../cryptoconditions/include/*.h) +all: $(TARGET) + +$(TARGET): $(SOURCES) + $(info Building cclib.so to src/) + $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) + +clean: + rm -rf $(TARGET) + From 4357791ede3f46e63fab14dfd3b12a321ebff2c9 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 05:04:14 +0100 Subject: [PATCH 1319/3904] [update] cclib multiOS Makefile --- src/cc/Makefile | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 5848d46dd..24d13690c 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -1,19 +1,32 @@ -SHELL = /bin/sh -CC = gcc -#CXXFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -DEBUGFLAGS = -O0 -D _DEBUG -RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program - +SHELL = /bin/sh +CC = gcc +CC_WIN = x86_64-w64-mingw32-gcc-posix +CFLAGS_DARWIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +DEBUGFLAGS = -O0 -D _DEBUG +RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program +$(info $(OS)) +OS := $(shell uname -s) +$(info $(OS)) TARGET = ../cclib.so +TARGET_WIN = ../cclib.dll SOURCES = cclib.cpp #HEADERS = $(shell echo ../cryptoconditions/include/*.h) + all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib.so to src/) +ifeq ($(OS),Darwin) + $(CC) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) +else ifeq ($(OS),Linux) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) +#else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host +else + $(info else) + #$(CC)_WIN $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) +endif clean: rm -rf $(TARGET) - From 1dbed5f02024e62783f3b8cf74652a0e9179fc45 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 05:06:51 +0100 Subject: [PATCH 1320/3904] [update] cclib multiOS Makefile --- src/cc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 24d13690c..3522a0c08 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -17,7 +17,7 @@ SOURCES = cclib.cpp all: $(TARGET) $(TARGET): $(SOURCES) - $(info Building cclib.so to src/) + $(info Building cclib to src/) ifeq ($(OS),Darwin) $(CC) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) else ifeq ($(OS),Linux) @@ -25,7 +25,7 @@ else ifeq ($(OS),Linux) #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host else $(info else) - #$(CC)_WIN $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) + #$(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) endif clean: From 12ebbabfd6b21b77400bddd933cb9f5b04db4481 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 05:11:14 +0100 Subject: [PATCH 1321/3904] [update] OSX Makefile --- zcutil/build-mac.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index 138508cb5..a3619111f 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -42,6 +42,21 @@ PREFIX="$(pwd)/depends/$TRIPLET" make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 +#BUILD CCLIB + +WD=$PWD +cd src/cc +echo $PWD + +if make "$@"; then + echo CCLIB BUILD SUCCESSFUL +else + echo CCLIB BUILD FAILED + exit 1 +fi + +cd $WD + ./autogen.sh CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \ CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ From bfd4917613ae58e6c4d49354f2efb9406aec141d Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 06:41:11 +0100 Subject: [PATCH 1322/3904] [update] cclib OSX makefile --- src/cc/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 3522a0c08..a3c54d81d 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -1,7 +1,8 @@ SHELL = /bin/sh CC = gcc +CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS_DARWIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG @@ -19,13 +20,13 @@ all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib to src/) ifeq ($(OS),Darwin) - $(CC) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) else ifeq ($(OS),Linux) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host else - $(info else) - #$(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) + $(info WINDOWS) + $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) endif clean: From 9307591c1435a0881e74a9f25073b3ff39f87cd7 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 06:45:59 +0100 Subject: [PATCH 1323/3904] [update] OSX cclib Makefile --- src/cc/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 3522a0c08..a3c54d81d 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -1,7 +1,8 @@ SHELL = /bin/sh CC = gcc +CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS_DARWIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG @@ -19,13 +20,13 @@ all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib to src/) ifeq ($(OS),Darwin) - $(CC) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) else ifeq ($(OS),Linux) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host else - $(info else) - #$(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) + $(info WINDOWS) + $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) endif clean: From 28195d218b86a35b4d61993ba0e72661c85bdef1 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 20 Jan 2019 07:11:58 +0100 Subject: [PATCH 1324/3904] [add] cclib README --- src/cc/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/cc/README.md diff --git a/src/cc/README.md b/src/cc/README.md new file mode 100644 index 000000000..d12a75c43 --- /dev/null +++ b/src/cc/README.md @@ -0,0 +1,7 @@ +## CCLIB +Please follow the below instructions to build the cryptoconditions library into the Komodo source directory `komodo/src` - supported operating systems are Linux, OSX and Windows (mingw crossbuild): + +``` +make clean +make +``` From 0139e3eedf9cf8b3515213017642c0d499d2996d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 20:18:36 -1100 Subject: [PATCH 1325/3904] test --- src/komodo.h | 13 ++++++++----- src/komodo_bitcoind.h | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7d2b17963..4a8bd7d96 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -947,12 +947,15 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) ) + if ( ASSETCHAINS_SYMBOL[0] != 0 || height < 100000 ) { - memset(&txhash,0,sizeof(txhash)); - komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); - printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); - } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); + if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) ) + { + memset(&txhash,0,sizeof(txhash)); + komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); + printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); + } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); + } } } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fbd73f59f..10c6ee4b8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -645,6 +645,7 @@ int32_t komodo_isPoS(CBlock *pblock) vout = pblock->vtx[n-1].vin[0].prevout.n; if ( ASSETCHAINS_MARMARA != 0 ) { + fprintf(stderr,"validate proper signature and unlockht preservation\n"); // need to verify it was signed by the non-Marmarapk of the 1of2 } txtime = komodo_txtime(&value,txid,vout,destaddr); @@ -2116,7 +2117,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt maxkp = numkp = 0; lasttime = 0; } - if ( ASSETCHAINS_MARMARA == 0 || 1 ) + if ( ASSETCHAINS_MARMARA == 0 ) { BOOST_FOREACH(const COutput& out, vecOutputs) { @@ -2248,12 +2249,13 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt txNew.vout[0].nValue = *utxovaluep - txfee; txNew.nLockTime = earliest; CTransaction txNewConst(txNew); - if ( ASSETCHAINS_MARMARA == 0 || 1 ) + if ( ASSETCHAINS_MARMARA == 0 ) { signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); } else { + fprintf(stderr,"add opreturn and CCFinalizetx\n"); // add opreturn // signSuccess = CCFinalizetx(...) } From e2bce726fa3f103878d275d05e72e619b87091a1 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Sun, 20 Jan 2019 15:08:42 +0700 Subject: [PATCH 1326/3904] bid/ask cancellation from node which not placed order --- qa/rpc-tests/cryptoconditions_token.py | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 254868670..5fd3256d6 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -15,7 +15,10 @@ from cryptoconditions import assert_success, assert_error, generate_random_strin class CryptoconditionsTokenTest(CryptoconditionsTestFramework): def run_token_tests(self): - rpc = self.nodes[0] + + rpc = self.nodes[0] + rpc1 = self.nodes[1] + result = rpc.tokenaddress() assert_success(result) for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress']: @@ -139,11 +142,24 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): # checking ask cancellation testorder = rpc.tokenask("100", tokenid, "7.77") testorderid = self.send_and_mine(testorder['hex'], rpc) + # from other node + rpc.sendtoaddress(rpc1.getnewaddress(), 1) + rpc.sendtoaddress(rpc1.getnewaddress(), 1) + rpc.generate(2) + self.sync_all() + result = rpc1.getbalance() + assert_greater_than(result, 0.1) + + result = rpc1.tokencancelask(tokenid, testorderid) + assert_error(result) + + # from valid node cancel = rpc.tokencancelask(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) result = rpc.tokenorders() assert_equal(result, []) + # invalid numtokens bid result = rpc.tokenbid("-1", tokenid, "1") assert_error(result) @@ -192,6 +208,15 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): # checking bid cancellation testorder = rpc.tokenbid("100", tokenid, "7.77") testorderid = self.send_and_mine(testorder['hex'], rpc) + + # from other node + result = rpc1.getbalance() + assert_greater_than(result, 0.1) + + result = rpc1.tokencancelbid(tokenid, testorderid) + assert_error(result) + + # from valid node cancel = rpc.tokencancelbid(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) result = rpc.tokenorders() From 6a696bdecf60fe51ee6c41824c1f0980c19caf75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 21:32:52 -1100 Subject: [PATCH 1327/3904] +print --- src/cc/CCutils.cpp | 2 +- src/cc/cclib.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index e9c30acc1..73f62825c 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -471,7 +471,7 @@ bool Myprivkey(uint8_t myprivkey[]) if ( pwalletMain->GetKey(keyID,vchSecret) != 0 ) { memcpy(myprivkey,vchSecret.begin(),32); - if ( 0 ) + if ( 1 ) { for (i=0; i<32; i++) fprintf(stderr,"0x%02x, ",myprivkey[i]); diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 889c40d8c..ed57b2194 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -27,6 +27,28 @@ #include "core_io.h" #include "crosschain.h" +#define FUNCNAME IsCClibInput +#define EVALCODE EVAL_FIRSTUSER +const char *CClibCCaddr = "RGLSRDnUqTB43bYtRtNVgmwSSd1sun2te8"; +const char *CClibNormaladdr = "RVVeUg43rNcq3mZFnvZ8yqagyzqFgUnq4u"; +char CClibCChexstr[67] = { "032447d97655da079729dc024c61088ea415b22f4c15d4810ddaf2069ac6468d2f" }; +uint8_t CClibCCpriv[32] = { 0x7c, 0x0b, 0x54, 0x9b, 0x65, 0xd4, 0x89, 0x57, 0xdf, 0x05, 0xfe, 0xa2, 0x62, 0x41, 0xa9, 0x09, 0x0f, 0x2a, 0x6b, 0x11, 0x2c, 0xbe, 0xbd, 0x06, 0x31, 0x8d, 0xc0, 0xb9, 0x96, 0x76, 0x3f, 0x24 }; +#include "CCcustom.inc" +#undef FUNCNAME +#undef EVALCODE + + +struct CClib_rpcinfo +{ + char *method,*help; + int32_t numrequiredargs,maxargs; // frontloaded with required + uint8_t evalcode; +} +CClib_rpcs[] = +{ + { "info", "", 0, 0, 0x10 }, +}; + #define MYCCLIBNAME ((char *)"stub") char *CClib_name() { return(MYCCLIBNAME); } From 10528424f92b912f35816b10ea30a743d0bb8648 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 22:48:46 -1100 Subject: [PATCH 1328/3904] CC_info * --- src/cc/CC made easy.md | 8 +-- src/cc/CCGateways.h | 2 +- src/cc/CCHeir.h | 4 +- src/cc/CCMarmara.h | 2 +- src/cc/CCOracles.h | 2 +- src/cc/CCPayments.h | 2 +- src/cc/CCPegs.h | 2 +- src/cc/CCPrices.h | 2 +- src/cc/CCassets.h | 12 ++-- src/cc/CCassetsCore.cpp | 18 +++--- src/cc/CCassetstx.cpp | 34 +++++------ src/cc/CCauction.h | 2 +- src/cc/CCchannels.h | 2 +- src/cc/CCcustom.cpp | 34 ++++++++++- src/cc/CCdice.h | 4 +- src/cc/CCfaucet.h | 2 +- src/cc/CCfsm.h | 2 +- src/cc/CCinclude.h | 34 ++++++----- src/cc/CClotto.h | 2 +- src/cc/CCrewards.h | 2 +- src/cc/CCtokens.cpp | 24 ++++---- src/cc/CCtokens.h | 8 +-- src/cc/CCtx.cpp | 4 +- src/cc/CCutils.cpp | 123 ++++++++++++++++++++++++++------------- src/cc/assets.cpp | 4 +- src/cc/auction.cpp | 14 ++--- src/cc/cclib.cpp | 91 ++++++++++++++++++----------- src/cc/channels.cpp | 22 +++---- src/cc/dice.cpp | 34 +++++------ src/cc/eval.cpp | 4 +- src/cc/eval.h | 4 +- src/cc/faucet.cpp | 14 ++--- src/cc/fsm.cpp | 12 ++-- src/cc/gateways.cpp | 36 ++++++------ src/cc/heir.cpp | 26 ++++----- src/cc/heir_validate.h | 12 ++-- src/cc/lotto.cpp | 20 +++---- src/cc/marmara.cpp | 26 ++++----- src/cc/oracles.cpp | 30 +++++----- src/cc/payments.cpp | 14 ++--- src/cc/pegs.cpp | 14 ++--- src/cc/prices.cpp | 14 ++--- src/cc/rewards.cpp | 24 ++++---- src/komodo_bitcoind.h | 2 +- src/rpc/server.cpp | 4 ++ src/rpc/server.h | 4 +- src/wallet/rpcwallet.cpp | 81 +++++++++++++++++++------- 47 files changed, 489 insertions(+), 348 deletions(-) diff --git a/src/cc/CC made easy.md b/src/cc/CC made easy.md index 453aa5467..f409efb2d 100644 --- a/src/cc/CC made easy.md +++ b/src/cc/CC made easy.md @@ -206,13 +206,13 @@ The idea is that people send funds to the faucet by locking it in faucet's globa There are only 7 functions in faucet.cpp, a bit over 200 lines including comments. The first three are for validation, the last four for the rpc calls to use. -int64_t IsFaucetvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsFaucetvout(struct CC_info *cp,const CTransaction& tx,int32_t v) -bool FaucetExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool FaucetExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) -bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) +bool FaucetValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx) -int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddFaucetInputs(struct CC_infoCC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) std::string FaucetGet(uint64_t txfee) diff --git a/src/cc/CCGateways.h b/src/cc/CCGateways.h index b629ade1f..0ffeced6e 100644 --- a/src/cc/CCGateways.h +++ b/src/cc/CCGateways.h @@ -20,7 +20,7 @@ #include "CCinclude.h" #include "../merkleblock.h" -bool GatewaysValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool GatewaysValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys); std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount); std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount); diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index ecaff9cdb..1e831e772 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -22,7 +22,7 @@ //#define EVAL_HEIR 0xea -bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool HeirValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); class CoinHelper; class TokenHelper; @@ -36,6 +36,6 @@ UniValue HeirInfo(uint256 fundingtxid); UniValue HeirList(); //std::string Heir_MakeBadTx(uint256 fundingtxid, uint8_t funcId, int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTime, uint32_t errMask); -//bool HeirExactTokenAmounts(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 assetid, const CTransaction &tx); +//bool HeirExactTokenAmounts(bool compareTotals, struct CC_info *cpHeir, Eval* eval, uint256 assetid, const CTransaction &tx); #endif diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 65269df77..567f43aa3 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -38,7 +38,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid); UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency); -bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool MarmaraValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue MarmaraInfo(); diff --git a/src/cc/CCOracles.h b/src/cc/CCOracles.h index 7f952e5f5..a46d0c311 100644 --- a/src/cc/CCOracles.h +++ b/src/cc/CCOracles.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool OraclesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string OracleCreate(int64_t txfee,std::string name,std::string description,std::string format); std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee); std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,int64_t amount); diff --git a/src/cc/CCPayments.h b/src/cc/CCPayments.h index 187d9c9ad..f229212fb 100644 --- a/src/cc/CCPayments.h +++ b/src/cc/CCPayments.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool PaymentsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue PaymentsInfo(); diff --git a/src/cc/CCPegs.h b/src/cc/CCPegs.h index 8d2a268f1..a7863a3ec 100644 --- a/src/cc/CCPegs.h +++ b/src/cc/CCPegs.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool PegsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue PegsInfo(); diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 1a68be7dd..fe625e31b 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool PricesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue PricesList(); diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 69fcfacbb..061e0f899 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -26,7 +26,7 @@ #include "CCinclude.h" // CCcustom -bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool AssetsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCassetsCore //CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk); @@ -35,20 +35,20 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); //uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); -int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); +int64_t IsAssetvout(struct CC_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateAskRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool SetBidFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); -int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); -bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); +int64_t AssetValidateBuyvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); +int64_t AssetValidateSellvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); +bool AssetCalcAmounts(struct CC_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); // CCassetstx //int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance() -int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); +int64_t AddAssetInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); UniValue AssetOrders(uint256 tokenid); //UniValue AssetInfo(uint256 tokenid); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 1b8e46189..45d3421be 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -365,7 +365,7 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT } // Calculate sell/buy owner's source token/asset address from ask/bid tx -bool GetAssetorigaddrs(struct CCcontract_info *cp, char *userCCaddr, char *destaddr, const CTransaction& tx) +bool GetAssetorigaddrs(struct CC_info *cp, char *userCCaddr, char *destaddr, const CTransaction& tx) { uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; @@ -378,13 +378,13 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp, char *userCCaddr, char *desta bool bGetCCaddr = false; if (funcid == 's' || funcid == 'S') { - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); //bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); } else if (funcid == 'b' || funcid == 'B') { - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); } @@ -400,7 +400,7 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp, char *userCCaddr, char *desta } -int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) +int64_t AssetValidateCCvin(struct CC_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) { uint256 hashBlock; uint256 assetid, assetid2; @@ -463,7 +463,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch return(vinTx.vout[0].nValue); } -int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid) +int64_t AssetValidateBuyvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid) { CTransaction vinTx; int64_t nValue; uint256 assetid,assetid2; uint8_t funcid, evalCode; CCaddr[0] = origaddr[0] = 0; @@ -490,7 +490,7 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr return(nValue); } -int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid) +int64_t AssetValidateSellvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid) { CTransaction vinTx; int64_t nValue,assetoshis; //fprintf(stderr,"AssetValidateSellvin\n"); @@ -558,7 +558,7 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr // Checks if the vout is a really Asset CC vout // compareTotals == true, the func also validates the passed transaction itself: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx -int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid) +int64_t IsAssetvout(struct CC_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid) { //std::cerr << "IsAssetvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for assetid=" << refassetid.GetHex() << std::endl; @@ -587,14 +587,14 @@ int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector tmporigpubkey; int64_t tmpprice; int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); inputs = outputs = 0; - struct CCcontract_info *cpTokens, C; + struct CC_info *cpTokens, C; cpTokens = CCinit(&C, EVAL_TOKENS); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 968775d38..dff279acd 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -17,7 +17,7 @@ //#include "CCtokens.h" -int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) +int64_t AddAssetInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) { char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t j,vout,n = 0; std::vector > unspentOutputs; @@ -72,13 +72,13 @@ UniValue AssetOrders(uint256 refassetid) UniValue result(UniValue::VARR); std::vector > unspentOutputsTokens, unspentOutputsAssets; - struct CCcontract_info *cpTokens, tokensC; - struct CCcontract_info *cpAssets, assetsC; + struct CC_info *cpTokens, tokensC; + struct CC_info *cpAssets, assetsC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); cpAssets = CCinit(&assetsC, EVAL_ASSETS); - auto addOrders = [&](struct CCcontract_info *cp, std::vector >::const_iterator it) + auto addOrders = [&](struct CC_info *cp, std::vector >::const_iterator it) { uint256 txid, hashBlock, assetid, assetid2; int64_t price; @@ -189,7 +189,7 @@ UniValue AssetOrders(uint256 refassetid) /* std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CCcontract_info *cp,C; + CPubKey mypk; struct CC_info *cp,C; if ( assetsupply < 0 ) { fprintf(stderr,"negative assetsupply %lld\n",(long long)assetsupply); @@ -217,7 +217,7 @@ UniValue AssetOrders(uint256 refassetid) /* std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; uint64_t mask; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; + CPubKey mypk; uint64_t mask; int64_t CCchange=0,inputs=0; struct CC_info *cp,C; if ( total < 0 ) { fprintf(stderr,"negative total %lld\n",(long long)total); @@ -259,7 +259,7 @@ UniValue AssetOrders(uint256 refassetid) /* std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; + CPubKey mypk; int64_t CCchange=0,inputs=0; struct CC_info *cp,C; if ( total < 0 ) { fprintf(stderr,"negative total %lld\n",(long long)total); @@ -288,7 +288,7 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; - struct CCcontract_info *cpAssets, C; + struct CC_info *cpAssets, C; uint256 hashBlock; CTransaction vintx; std::vector origpubkey; @@ -349,8 +349,8 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p uint64_t mask; int64_t inputs, CCchange; CScript opret; - struct CCcontract_info *cpAssets, assetsC; - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpAssets, assetsC; + struct CC_info *cpTokens, tokensC; //std::cerr << "CreateSell() askamount=" << askamount << " pricetotal=" << pricetotal << std::endl; @@ -408,7 +408,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 assetid2,int64_t pricetotal) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CC_info *cp,C; ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// fprintf(stderr,"asset swaps disabled\n"); @@ -482,7 +482,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) uint256 hashBlock; int64_t bidamount; CPubKey mypk; - struct CCcontract_info *cpAssets, C; + struct CC_info *cpAssets, C; uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; @@ -526,7 +526,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) uint256 hashBlock; int64_t askamount; CPubKey mypk; - struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; + struct CC_info *cpTokens, *cpAssets, tokensC, assetsC; uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; @@ -592,8 +592,8 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f int32_t bidvout=0; uint64_t mask; int64_t origprice, bidamount, paid_amount, remaining_required, inputs, CCchange=0; - struct CCcontract_info *cpTokens, tokensC; - struct CCcontract_info *cpAssets, assetsC; + struct CC_info *cpTokens, tokensC; + struct CC_info *cpAssets, assetsC; if (fillamount < 0) { @@ -676,8 +676,8 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a uint64_t mask = 0; int32_t askvout = 0; int64_t received_assetoshis, total_nValue, orig_assetoshis, paid_nValue, remaining_nValue, inputs, CCchange=0; - //struct CCcontract_info *cpTokens, tokensC; - struct CCcontract_info *cpAssets, assetsC; + //struct CC_info *cpTokens, tokensC; + struct CC_info *cpAssets, assetsC; if (fillunits < 0) { diff --git a/src/cc/CCauction.h b/src/cc/CCauction.h index cfcd615cc..13393d510 100644 --- a/src/cc/CCauction.h +++ b/src/cc/CCauction.h @@ -21,7 +21,7 @@ #define EVAL_AUCTION 0xe8 -bool AuctionValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool AuctionValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string AuctionPost(uint64_t txfee,uint256 itemhash,int64_t minbid,char *title,char *description); std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount); diff --git a/src/cc/CCchannels.h b/src/cc/CCchannels.h index 10cb4d224..76e0ab8cf 100644 --- a/src/cc/CCchannels.h +++ b/src/cc/CCchannels.h @@ -20,7 +20,7 @@ #include "CCinclude.h" #define CHANNELS_MAXPAYMENTS 1000 -bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool ChannelsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64_t payment,uint256 tokenid); std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint256 secret); std::string ChannelClose(uint64_t txfee,uint256 opentxid); diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 918ceb24a..c05210542 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -234,8 +234,36 @@ uint8_t TokensCCpriv[32] = { 0x1d, 0x0d, 0x0d, 0xce, 0x2d, 0xd2, 0xe1, 0x9d, 0xf #undef FUNCNAME #undef EVALCODE +#define FUNCNAME IsCClibInput +#define EVALCODE EVAL_FIRSTUSER +const char *CClibNormaladdr = "RVVeUg43rNcq3mZFnvZ8yqagyzqFgUnq4u"; +char CClibCChexstr[67] = { "032447d97655da079729dc024c61088ea415b22f4c15d4810ddaf2069ac6468d2f" }; +uint8_t CClibCCpriv[32] = { 0x57, 0xcf, 0x49, 0x71, 0x7d, 0xb4, 0x15, 0x1b, 0x4f, 0x98, 0xc5, 0x45, 0x8d, 0x26, 0x52, 0x4b, 0x7b, 0xe9, 0xbd, 0x55, 0xd8, 0x20, 0xd6, 0xc4, 0x82, 0x0f, 0xf5, 0xec, 0x6c, 0x1c, 0xa0, 0xc0 }; +#include "CCcustom.inc" +#undef FUNCNAME +#undef EVALCODE -struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) +int32_t CClib_initcp(struct CC_info *cp,uint8_t evalcode) +{ + CPubKey pk; uint8_t pub33[33]; char CCaddr[64]; + if ( evalcode == EVAL_FIRSTUSER ) // eventually make a hashchain for each evalcode + { + cp->evalcode = evalcode; + cp->ismyvin = IsCClibInput; + strcpy(cp->CChexstr,CClibCChexstr); + memcpy(cp->CCpriv,CClibCCpriv,32); + decode_hex(pub33,33,cp->CChexstr); + pk = buf2pk(pub33); + Getscriptaddress(cp->normaladdr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); + if ( strcmp(cp->normaladdr,CClibNormaladdr) != 0 ) + fprintf(stderr,"CClib_initcp addr mismatch %s vs %s\n",cp->normaladdr,CClibNormaladdr); + GetCCaddress(cp,cp->unspendableCCaddr,pk); + return(0); + } + return(-1); +} + +struct CC_info *CCinit(struct CC_info *cp, uint8_t evalcode) { cp->evalcode = evalcode; switch ( evalcode ) @@ -369,6 +397,10 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) cp->validate = TokensValidate; cp->ismyvin = IsTokensInput; break; + default: + if ( CClib_initcp(cp,evalcode) < 0 ) + return(0); + break; } return(cp); } diff --git a/src/cc/CCdice.h b/src/cc/CCdice.h index 363aad735..0de222c50 100644 --- a/src/cc/CCdice.h +++ b/src/cc/CCdice.h @@ -21,7 +21,7 @@ #define EVAL_DICE 0xe6 -bool DiceValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool DiceValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet,int32_t odds); std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout); @@ -30,6 +30,6 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount); UniValue DiceInfo(uint256 diceid); UniValue DiceList(); -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random); +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CC_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random); #endif diff --git a/src/cc/CCfaucet.h b/src/cc/CCfaucet.h index 3cb6c66e5..4bb2ae0d7 100644 --- a/src/cc/CCfaucet.h +++ b/src/cc/CCfaucet.h @@ -22,7 +22,7 @@ #define EVAL_FAUCET 0xe4 #define FAUCETSIZE (COIN / 10) -bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool FaucetValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom std::string FaucetFund(uint64_t txfee,int64_t funds); diff --git a/src/cc/CCfsm.h b/src/cc/CCfsm.h index 2bce35597..0690e4dd2 100644 --- a/src/cc/CCfsm.h +++ b/src/cc/CCfsm.h @@ -21,7 +21,7 @@ #define EVAL_FSM 0xe7 -bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool FSMValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string FSMList(); std::string FSMInfo(uint256 fsmtxid); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 680e4ca5c..0b537f3d3 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -88,7 +88,7 @@ struct CC_meta // followed by address destinations }; -struct CCcontract_info +struct CC_info { // this is for spending from 'unspendable' CC address uint8_t evalcode; @@ -111,12 +111,12 @@ struct CCcontract_info uint8_t unspendablepriv2[32], unspendablepriv3[32]; CPubKey unspendablepk2, unspendablepk3; - bool (*validate)(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn); // cc contract tx validation callback + bool (*validate)(struct CC_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn); // cc contract tx validation callback bool (*ismyvin)(CScript const& scriptSig); // checks if evalcode is present in the scriptSig param uint8_t didinit; }; -struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode); +struct CC_info *CCinit(struct CC_info *cp,uint8_t evalcode); struct oracleprice_info { @@ -134,6 +134,7 @@ CBlockIndex *komodo_getblockindex(uint256 hash); int32_t komodo_nextheight(); int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 txid,int32_t vout); +void CCclearvars(struct CC_info *cp); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); @@ -157,9 +158,9 @@ uint8_t DecodeOraclesCreateOpRet(const CScript &scriptPubKey,std::string &name,s uint256 OracleMerkle(int32_t height,uint256 reforacletxid,char *format,std::vectorpublishers); uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); -//int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); -int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid); +//int64_t AddAssetInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); +int64_t AddTokenCCInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CC_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); @@ -177,7 +178,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t // CCcustom -CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); +CPubKey GetUnspendable(struct CC_info *cp,uint8_t *unspendablepriv); // CCutils CPubKey buf2pk(uint8_t *buf33); @@ -188,18 +189,19 @@ CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2); CC *MakeCCcond1(uint8_t evalcode,CPubKey pk); CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2); CC* GetCryptoCondition(CScript const& scriptSig); -void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); -void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); -void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); +void CCaddr2set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); +void CCaddr3set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); +void CCaddr1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2); CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk); -bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk); -bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); -void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); +bool GetTokensCCaddress(struct CC_info *cp, char *destaddr, CPubKey pk); +bool GetTokensCCaddress1of2(struct CC_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); +void CCaddrTokens1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); +int32_t CClib_initcp(struct CC_info *cp,uint8_t evalcode); bool IsCCInput(CScript const& scriptSig); int32_t unstringbits(char *buf,uint64_t bits); @@ -214,8 +216,8 @@ int64_t CCfullsupply(uint256 tokenid); int64_t CCtoken_balance(char *destaddr,uint256 tokenid); int64_t CCtoken_balance2(char *destaddr,uint256 tokenid); bool _GetCCaddress(char *destaddr,uint8_t evalcode,CPubKey pk); -bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk); -bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubKey pk2); +bool GetCCaddress(struct CC_info *cp,char *destaddr,CPubKey pk); +bool GetCCaddress1of2(struct CC_info *cp,char *destaddr,CPubKey pk,CPubKey pk2); bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue); bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t numvins,int32_t preventCCvouts,int32_t numvouts); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); @@ -227,7 +229,7 @@ CPubKey check_signing_pubkey(CScript scriptSig); // CCtx bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); extern std::vector NULL_pubkeys; -std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); +std::string FinalizeCCTx(uint64_t skipmask,struct CC_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); void SetCCtxids(std::vector > &addressIndex,char *coinaddr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); diff --git a/src/cc/CClotto.h b/src/cc/CClotto.h index 2f0595371..4ef147cef 100644 --- a/src/cc/CClotto.h +++ b/src/cc/CClotto.h @@ -21,7 +21,7 @@ #define EVAL_LOTTO 0xe9 -bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool LottoValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); UniValue LottoInfo(uint256 lottoid); UniValue LottoList(); diff --git a/src/cc/CCrewards.h b/src/cc/CCrewards.h index 4d6cc80f9..41977f915 100644 --- a/src/cc/CCrewards.h +++ b/src/cc/CCrewards.h @@ -22,7 +22,7 @@ #define EVAL_REWARDS 0xe5 #define REWARDSCC_MAXAPR (COIN * 25) -bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool RewardsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); UniValue RewardsInfo(uint256 rewardid); UniValue RewardsList(); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 2961f6597..6620a9cd8 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -177,7 +177,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 // tx validation -bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn) +bool TokensValidate(struct CC_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn) { static uint256 zero; CTxDestination address; CTransaction vinTx, createTx; uint256 hashBlock, tokenid, tokenid2; @@ -251,7 +251,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & // forward validation if evalcode in opret is not EVAL_TOKENS // init for forwarding validation call //if (evalCodeInOpret != EVAL_TOKENS) { // TODO: should we check also only allowed for tokens evalcodes, like EVAL_ASSETS, EVAL_GATEWAYS? - // struct CCcontract_info *cpOther = NULL, C; + // struct CC_info *cpOther = NULL, C; // cpOther = CCinit(&C, evalCodeInOpret); // if (cpOther) @@ -271,7 +271,7 @@ bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys) bool found = false; CPubKey pubkey; - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); @@ -353,7 +353,7 @@ uint8_t ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vec // goDeeper is true: the func also validates amounts of the passed transaction: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx // checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true! -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid) +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CC_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid) { // this is just for log messages indentation fur debugging recursive calls: @@ -488,13 +488,13 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c } // compares cc inputs vs cc outputs (to prevent feeding vouts from normal inputs) -bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) +bool TokensExactAmounts(bool goDeeper, struct CC_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) { CTransaction vinTx; uint256 hashBlock; int64_t tokenoshis; - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); int32_t numvins = tx.vin.size(); @@ -559,7 +559,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu } // add inputs from token cc addr -int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) +int64_t AddTokenCCInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) { char tokenaddr[64], destaddr[64]; int64_t threshold, nValue, price, totalinputs = 0; @@ -617,7 +617,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CCcontract_info *cp, C; + CPubKey mypk; struct CC_info *cp, C; if (assetsupply < 0) { fprintf(stderr, "negative assetsupply %lld\n", (long long)assetsupply); @@ -647,7 +647,7 @@ std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, st std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; uint64_t mask; int64_t CCchange = 0, inputs = 0; struct CCcontract_info *cp, C; + CPubKey mypk; uint64_t mask; int64_t CCchange = 0, inputs = 0; struct CC_info *cp, C; std::vector emptyExtraOpret; if (total < 0) @@ -714,7 +714,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) return 0; } - struct CCcontract_info *cp, C; + struct CC_info *cp, C; cp = CCinit(&C, EVAL_TOKENS); return(AddTokenCCInputs(cp, mtx, pk, tokenid, 0, 0)); } @@ -748,7 +748,7 @@ UniValue TokenList() { UniValue result(UniValue::VARR); std::vector > addressIndex; - struct CCcontract_info *cp, C; uint256 txid, hashBlock; + struct CC_info *cp, C; uint256 txid, hashBlock; CTransaction vintx; std::vector origpubkey; std::string name, description; char str[65]; @@ -766,4 +766,4 @@ UniValue TokenList() } } return(result); -} \ No newline at end of file +} diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index e7bb62101..2eaffe31f 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -26,9 +26,9 @@ #include "CCinclude.h" // CCcustom -bool TokensValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); -bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); -//int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); +bool TokensValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool TokensExactAmounts(bool goDeeper, struct CC_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); +//int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CC_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); @@ -36,7 +36,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid); UniValue TokenInfo(uint256 tokenid); UniValue TokenList(); -//this is in CCinclude.h int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); +//this is in CCinclude.h int64_t AddTokenCCInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); //this is in CCinclude.h uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index ae7483f4d..307ac214f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -40,7 +40,7 @@ bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScrip return(false); } -std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys) +std::string FinalizeCCTx(uint64_t CCmask,struct CC_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys) { auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; @@ -50,7 +50,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran uint8_t *privkey, myprivkey[32], unspendablepriv[32], tokensunspendablepriv[32], *msg32 = 0; CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CPubKey unspendablepk /*, tokensunspendablepk*/; - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpTokens, tokensC; globalpk = GetUnspendable(cp,0); n = mtx.vout.size(); for (i=0; i pubkey) return(pk); } -void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) +void CCaddr2set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) { cp->evalcode2 = evalcode; cp->unspendablepk2 = pk; @@ -235,7 +235,7 @@ void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t * strcpy(cp->unspendableaddr2,coinaddr); } -void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) +void CCaddr3set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) { cp->evalcode3 = evalcode; cp->unspendablepk3 = pk; @@ -244,7 +244,7 @@ void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t * } // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 cryptocondition vout: -void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +void CCaddr1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) { cp->coins1of2pk[0] = pk1; cp->coins1of2pk[1] = pk2; @@ -252,7 +252,7 @@ void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *c } // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 tokens cryptocondition vout: -void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +void CCaddrTokens1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) { cp->tokens1of2pk[0] = pk1; cp->tokens1of2pk[1] = pk2; @@ -343,7 +343,7 @@ bool _GetCCaddress(char *destaddr,uint8_t evalcode,CPubKey pk) return(destaddr[0] != 0); } -bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk) +bool GetCCaddress(struct CC_info *cp,char *destaddr,CPubKey pk) { destaddr[0] = 0; if ( pk.size() == 0 ) @@ -363,7 +363,7 @@ bool _GetTokensCCaddress(char *destaddr, uint8_t evalcode, CPubKey pk) return(destaddr[0] != 0); } -bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk) +bool GetTokensCCaddress(struct CC_info *cp, char *destaddr, CPubKey pk) { destaddr[0] = 0; if (pk.size() == 0) @@ -372,7 +372,7 @@ bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk) } -bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubKey pk2) +bool GetCCaddress1of2(struct CC_info *cp,char *destaddr,CPubKey pk,CPubKey pk2) { CC *payoutCond; destaddr[0] = 0; @@ -384,7 +384,7 @@ bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubK return(destaddr[0] != 0); } -bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2) +bool GetTokensCCaddress1of2(struct CC_info *cp, char *destaddr, CPubKey pk, CPubKey pk2) { CC *payoutCond; destaddr[0] = 0; @@ -471,7 +471,7 @@ bool Myprivkey(uint8_t myprivkey[]) if ( pwalletMain->GetKey(keyID,vchSecret) != 0 ) { memcpy(myprivkey,vchSecret.begin(),32); - if ( 1 ) + if ( 0 ) { for (i=0; i<32; i++) fprintf(stderr,"0x%02x, ",myprivkey[i]); @@ -486,46 +486,17 @@ bool Myprivkey(uint8_t myprivkey[]) return(false); } -CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv) +CPubKey GetUnspendable(struct CC_info *cp,uint8_t *unspendablepriv) { if ( unspendablepriv != 0 ) memcpy(unspendablepriv,cp->CCpriv,32); return(pubkey2pk(ParseHex(cp->CChexstr))); } -bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector paramsNull,const CTransaction &ctx, unsigned int nIn) +void CCclearvars(struct CC_info *cp) { - CTransaction createTx; uint256 assetid,assetid2,hashBlock; uint8_t funcid; int32_t height,i,n,from_mempool = 0; int64_t amount; std::vector origpubkey; - height = KOMODO_CONNECTING; - if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation - return(true); - if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE ) - return eval->Invalid("CC are disabled or not active yet"); - if ( (KOMODO_CONNECTING & (1<<30)) != 0 ) - { - from_mempool = 1; - height &= ((1<<30) - 1); - } - //fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE); - // there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example - //txid = ctx.GetHash(); - //if ( txid == cp->prevtxid ) - // return(true); - //fprintf(stderr,"process CC %02x\n",cp->evalcode); cp->evalcode2 = cp->evalcode3 = 0; cp->unspendableaddr2[0] = cp->unspendableaddr3[0] = 0; - if ( paramsNull.size() != 0 ) // Don't expect params - return eval->Invalid("Cannot have params"); - //else if ( ctx.vout.size() == 0 ) // spend can go to z-addresses - // return eval->Invalid("no-vouts"); - else if ( (*cp->validate)(cp,eval,ctx,nIn) != 0 ) - { - //fprintf(stderr,"done CC %02x\n",cp->evalcode); - //cp->prevtxid = txid; - return(true); - } - //fprintf(stderr,"invalid CC %02x\n",cp->evalcode); - return(false); } int64_t CCduration(int32_t &numblocks,uint256 txid) @@ -630,3 +601,75 @@ CPubKey check_signing_pubkey(CScript scriptSig) } return CPubKey(); } + +bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull,const CTransaction &ctx, unsigned int nIn) +{ + CTransaction createTx; uint256 assetid,assetid2,hashBlock; uint8_t funcid; int32_t height,i,n,from_mempool = 0; int64_t amount; std::vector origpubkey; + height = KOMODO_CONNECTING; + if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation + return(true); + if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE ) + return eval->Invalid("CC are disabled or not active yet"); + if ( (KOMODO_CONNECTING & (1<<30)) != 0 ) + { + from_mempool = 1; + height &= ((1<<30) - 1); + } + //fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE); + // there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example + //txid = ctx.GetHash(); + //if ( txid == cp->prevtxid ) + // return(true); + //fprintf(stderr,"process CC %02x\n",cp->evalcode); + CCclearvars(cp); + if ( paramsNull.size() != 0 ) // Don't expect params + return eval->Invalid("Cannot have params"); + //else if ( ctx.vout.size() == 0 ) // spend can go to z-addresses + // return eval->Invalid("no-vouts"); + else if ( (*cp->validate)(cp,eval,ctx,nIn) != 0 ) + { + //fprintf(stderr,"done CC %02x\n",cp->evalcode); + //cp->prevtxid = txid; + return(true); + } + //fprintf(stderr,"invalid CC %02x\n",cp->evalcode); + return(false); +} + +bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) +{ + uint8_t evalcode; int32_t height,from_mempool; struct CCinfo *cp; + if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) + { + fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME); + return eval->Invalid("-ac_cclib name mismatches myname"); + } + height = KOMODO_CONNECTING; + if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation + return(true); + if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE ) + return eval->Invalid("CC are disabled or not active yet"); + if ( (KOMODO_CONNECTING & (1<<30)) != 0 ) + { + from_mempool = 1; + height &= ((1<<30) - 1); + } + evalcode = cond->code[0]; + if ( evalcode >= EVAL_FIRSTUSER && evalcode <= EVAL_LASTUSER ) + { + cp = &CCinfos[(int32_t)ecode]; + if ( cp->didinit == 0 ) + { + if ( CClib_initcp(cp,ecode) == 0 ) + cp->didinit = 1; + else return eval->Invalid("unsupported CClib evalcode"); + } + CCclearvars(cp); + if ( paramsNull.size() != 0 ) // Don't expect params + return eval->Invalid("Cannot have params"); + else if ( CClib_validate(cp,eval,ctx,nIn) != 0 ) + return(true); + return eval->Invalid("error in CClib_validate"); + } + return eval->Invalid("cclib CC must have evalcode between 16 and 127"); +} diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 3ccafa34f..7747fb61c 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -126,7 +126,7 @@ // tx validation -bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool AssetsValidate(struct CC_info *cpAssets,Eval* eval,const CTransaction &tx, uint32_t nIn) { static uint256 zero; CTxDestination address; CTransaction vinTx,createTx; uint256 hashBlock,assetid,assetid2; @@ -157,7 +157,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); // we need this for validating single-eval tokens' vins/vous: - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); // find single-eval token user cc addr: diff --git a/src/cc/auction.cpp b/src/cc/auction.cpp index 0858facfa..b3fe4aa86 100644 --- a/src/cc/auction.cpp +++ b/src/cc/auction.cpp @@ -21,7 +21,7 @@ // start of consensus code -int64_t IsAuctionvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsAuctionvout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -32,7 +32,7 @@ int64_t IsAuctionvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -bool AuctionExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool AuctionExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -70,7 +70,7 @@ bool AuctionExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransactio else return(true); } -bool AuctionValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool AuctionValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; return eval->Invalid("no validation yet"); @@ -118,7 +118,7 @@ bool AuctionValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t // helper functions for rpc calls in rpcwallet.cpp -int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddAuctionInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; @@ -151,7 +151,7 @@ int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; @@ -172,7 +172,7 @@ std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount) std::string AuctionDeliver(uint64_t txfee,uint256 itemhash,uint256 bidtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; @@ -193,7 +193,7 @@ std::string AuctionDeliver(uint64_t txfee,uint256 itemhash,uint256 bidtxid) std::string AuctionPost(uint64_t txfee,uint256 itemhash,int64_t minbid,char *title,char *description) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Auctionpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk,Auctionpk; int64_t funds = 0; CScript opret; struct CC_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index ed57b2194..c93d204df 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -27,54 +27,75 @@ #include "core_io.h" #include "crosschain.h" -#define FUNCNAME IsCClibInput -#define EVALCODE EVAL_FIRSTUSER -const char *CClibCCaddr = "RGLSRDnUqTB43bYtRtNVgmwSSd1sun2te8"; -const char *CClibNormaladdr = "RVVeUg43rNcq3mZFnvZ8yqagyzqFgUnq4u"; -char CClibCChexstr[67] = { "032447d97655da079729dc024c61088ea415b22f4c15d4810ddaf2069ac6468d2f" }; -uint8_t CClibCCpriv[32] = { 0x7c, 0x0b, 0x54, 0x9b, 0x65, 0xd4, 0x89, 0x57, 0xdf, 0x05, 0xfe, 0xa2, 0x62, 0x41, 0xa9, 0x09, 0x0f, 0x2a, 0x6b, 0x11, 0x2c, 0xbe, 0xbd, 0x06, 0x31, 0x8d, 0xc0, 0xb9, 0x96, 0x76, 0x3f, 0x24 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - - struct CClib_rpcinfo { char *method,*help; int32_t numrequiredargs,maxargs; // frontloaded with required - uint8_t evalcode; + uint8_t funcid; } -CClib_rpcs[] = +CClib_methods[] = { - { "info", "", 0, 0, 0x10 }, + { "faucet2_get", "", 0, 0, 'G' }, }; #define MYCCLIBNAME ((char *)"stub") char *CClib_name() { return(MYCCLIBNAME); } -bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) +std::string CClib_rawtxgen(struct CC_info *cp,uint8_t funcid,cJSON *params); + +UniValue CClib_info(struct CC_info *cp) { - uint8_t evalcode; int32_t height,from_mempool; - if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i; char str[2]; + result.push_back(Pair("result","success")); + result.push_back(Pair("CClib",CClib_name())); + for (i=0; iInvalid("-ac_cclib name mismatches myname"); + UniValue obj(UniValue::VOBJ); + if ( CClib_methods[i].funcid < ' ' || CClib_methods[i].funcid >= 128 ) + obj.push_back(Pair("funcid",CClib_methods[i].funcid)); + else + { + str[0] = CClib_methods[i].funcid; + str[1] = 0; + obj.push_back(Pair("funcid",str)); + } + obj.push_back(Pair("name",CClib_methods[i].method)); + obj.push_back(Pair("help",CClib_methods[i].help)); + obj.push_back(Pair("params_required",CClib_methods[i].numrequiredargs)); + obj.push_back(Pair("params_max",CClib_methods[i].maxargs)); + a.push_back(obj)); } - height = KOMODO_CONNECTING; - if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation - return(true); - if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE ) - return eval->Invalid("CC are disabled or not active yet"); - if ( (KOMODO_CONNECTING & (1<<30)) != 0 ) - { - from_mempool = 1; - height &= ((1<<30) - 1); - } - evalcode = cond->code[0]; - if ( evalcode >= EVAL_FIRSTUSER && evalcode <= EVAL_LASTUSER ) - { - return(true); - } - return eval->Invalid("cclib CC must have evalcode between 16 and 127"); + result.push_back(Pair("methods",a)); + return(result); +} + +UniValue CClib(struct CC_info *cp,char *method,cJSON *params) +{ + UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; + for (i=0; i > unspentOutputs; @@ -465,7 +465,7 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); uint8_t hash[32],hashdest[32]; uint64_t amount,tokens=0,funds; int32_t i; uint256 hashchain,entropy,hentropy; - CPubKey mypk; struct CCcontract_info *cp,*cpTokens,C,CTokens; + CPubKey mypk; struct CC_info *cp,*cpTokens,C,CTokens; if ( numpayments <= 0 || payment <= 0 || numpayments > CHANNELS_MAXPAYMENTS ) { @@ -509,7 +509,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk,srcpub,destpub; uint256 txid,hashchain,gensecret,hashblock,entropy,hentropy,prevtxid,param3,tokenid; - struct CCcontract_info *cp,C; int32_t i,funcid,prevdepth,numvouts,numpayments,totalnumpayments; + struct CC_info *cp,C; int32_t i,funcid,prevdepth,numvouts,numpayments,totalnumpayments; int64_t payment,change,funds,param2; uint8_t hash[32],hashdest[32]; CTransaction channelOpenTx,prevTx; @@ -616,7 +616,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 std::string ChannelClose(uint64_t txfee,uint256 opentxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,srcpub,destpub; struct CCcontract_info *cp,C; + CPubKey mypk,srcpub,destpub; struct CC_info *cp,C; CTransaction channelOpenTx; uint256 hashblock,tmp_txid,prevtxid,hashchain,tokenid; int32_t numvouts,numpayments; @@ -665,7 +665,7 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CCcontract_info *cp,C; int64_t funds,payment,param2; + CPubKey mypk; struct CC_info *cp,C; int64_t funds,payment,param2; int32_t i,numpayments,numvouts,param1; uint256 hashchain,hashblock,txid,prevtxid,param3,tokenid; CTransaction channelOpenTx,channelCloseTx,prevTx; @@ -735,7 +735,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) } UniValue ChannelsList() { - UniValue result(UniValue::VOBJ); std::vector > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; + UniValue result(UniValue::VOBJ); std::vector > txids; struct CC_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; CTransaction tx; char myCCaddr[65],addr[65],str[256]; CPubKey mypk,srcpub,destpub; int32_t vout,numvouts,param1; int64_t nValue,param2; @@ -766,7 +766,7 @@ UniValue ChannelsList() UniValue ChannelsInfo(uint256 channeltxid) { UniValue result(UniValue::VOBJ),array(UniValue::VARR); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid,tokenid; - struct CCcontract_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments; + struct CC_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments; int64_t param2,payment; CPubKey srcpub,destpub,mypk; std::vector > addressIndex; std::vector txids; diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 05dad9bf6..7a10913e7 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -322,7 +322,7 @@ void dicefinish_delete(struct dicefinish_info *ptr) void *dicefinish(void *_ptr) { - std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CPubKey dicepk; CTransaction betTx,finishTx,tx; + std::vector mypk; struct CC_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CPubKey dicepk; CTransaction betTx,finishTx,tx; mypk = Mypubkey(); pubkey2addr(coinaddr,mypk.data()); cp = CCinit(&C,EVAL_DICE); @@ -735,7 +735,7 @@ uint256 DiceGetEntropy(CTransaction tx,uint8_t reffuncid) else return(zeroid); } -uint64_t IsDicevout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) +uint64_t IsDicevout(struct CC_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) { char destaddr[64]; uint8_t funcid; int32_t numvouts; uint64_t sbits; uint256 fundingtxid,hash,proof; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -749,7 +749,7 @@ uint64_t IsDicevout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v, return(0); } -int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CCcontract_info *cp,Eval *eval,const CTransaction &tx,uint64_t refsbits,uint256 reffundingtxid) +int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CC_info *cp,Eval *eval,const CTransaction &tx,uint64_t refsbits,uint256 reffundingtxid) { CTransaction vinTx; uint256 hashBlock; int32_t i,numvins,numvouts; uint64_t assetoshis; numvins = tx.vin.size(); @@ -834,7 +834,7 @@ bool DiceVerifyTimeout(CTransaction &betTx,int32_t timeoutblocks) return(numblocks >= timeoutblocks); } -bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) +bool DiceValidate(struct CC_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) { uint256 txid,fundingtxid,vinfundingtxid,vinhentropy,vinproof,hashBlock,hash,proof,entropy; int64_t minbet,maxbet,maxodds,timeoutblocks,odds,winnings; uint64_t vinsbits,refsbits=0,sbits,amount,inputs,outputs,txfee=10000; int32_t numvins,entropyvout,numvouts,preventCCvins,preventCCvouts,i,iswin; uint8_t funcid; CScript fundingPubKey; CTransaction fundingTx,vinTx,vinofvinTx; char CCaddr[64]; numvins = tx.vin.size(); @@ -1046,7 +1046,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, return(true); } -uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) +uint64_t AddDiceInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) { char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hash,proof,hashBlock,fundingtxid; CTransaction tx; int32_t j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; @@ -1095,7 +1095,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CC_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,sum,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0,i=0,pendingbets=0; uint8_t funcid; std::vector > unspentOutputs; @@ -1215,7 +1215,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } -bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) +bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CC_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) { char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; @@ -1256,9 +1256,9 @@ bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontrac return(false); } -struct CCcontract_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,struct CCcontract_info *C,char *planstr,uint64_t &txfee,CPubKey &mypk,CPubKey &dicepk,uint64_t &sbits,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) +struct CC_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,struct CC_info *C,char *planstr,uint64_t &txfee,CPubKey &mypk,CPubKey &dicepk,uint64_t &sbits,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) { - struct CCcontract_info *cp; int32_t cmpflag; + struct CC_info *cp; int32_t cmpflag; cp = CCinit(C,EVAL_DICE); if ( txfee == 0 ) txfee = 10000; @@ -1278,7 +1278,7 @@ struct CCcontract_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,s UniValue DiceInfo(uint256 diceid) { - UniValue result(UniValue::VOBJ); CPubKey dicepk; uint256 hashBlock,entropytxid; CTransaction vintx; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t sbits,funding,entropyval; char str[67],numstr[65]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ); CPubKey dicepk; uint256 hashBlock,entropytxid; CTransaction vintx; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t sbits,funding,entropyval; char str[67],numstr[65]; struct CC_info *cp,C; if ( myGetTransaction(diceid,vintx,hashBlock) == 0 ) { fprintf(stderr,"cant find fundingtxid\n"); @@ -1314,7 +1314,7 @@ UniValue DiceInfo(uint256 diceid) UniValue DiceList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; cp = CCinit(&C,EVAL_DICE); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -1334,7 +1334,7 @@ UniValue DiceList() std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CCcontract_info *cp,C; + uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CC_info *cp,C; if ( funds < 0 || minbet < 0 || maxbet < 0 || maxodds < 1 || maxodds > 9999 || timeoutblocks < 0 || timeoutblocks > 1440 ) { CCerror = "invalid parameter error"; @@ -1369,7 +1369,7 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CCcontract_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; + CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CC_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; if ( amount < 0 ) { CCerror = "amount must be positive"; @@ -1413,7 +1413,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet,int32_t odds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; + CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CC_info *cp,C; if ( bet < 0 ) { CCerror = "bet must be positive"; @@ -1472,7 +1472,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout) { CMutableTransaction savemtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval=0,iswin=0; uint64_t entropyval,sbits; + CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CC_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval=0,iswin=0; uint64_t entropyval,sbits; entropyused = zeroid; *resultp = 0; funcid = 0; @@ -1653,7 +1653,7 @@ static uint256 dealer0_fundingtxid; void *dealer0_loop(void *_arg) { char *planstr = (char *)_arg; - CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 hashBlock,entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 hashBlock,entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CC_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); @@ -1749,7 +1749,7 @@ void *dealer0_loop(void *_arg) double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid) { static int32_t didinit; static char _planstr[64]; - CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,num,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; + CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CC_info *cp,C; int32_t i,entropyvout,flag,win,num,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { CCerror = "Diceinit error in status, is your transaction confirmed?"; diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index ca2703bff..5239b0d5b 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -31,7 +31,7 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co char *CClib_name(); Eval* EVAL_TEST = 0; -struct CCcontract_info CCinfos[0x100]; +struct CC_info CCinfos[0x100]; extern pthread_mutex_t KOMODO_CC_mutex; bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn) @@ -62,7 +62,7 @@ bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn) */ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) { - struct CCcontract_info *cp; + struct CC_info *cp; if (cond->codeLength == 0) return Invalid("empty-eval"); diff --git a/src/cc/eval.h b/src/cc/eval.h index a42bbdb2f..61fdb892d 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -286,8 +286,8 @@ typedef std::pair TxProof; uint256 GetMerkleRoot(const std::vector& vLeaves); -struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode); -bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector paramsNull, const CTransaction &tx, unsigned int nIn); +struct CC_info *CCinit(struct CC_info *cp,uint8_t evalcode); +bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull, const CTransaction &tx, unsigned int nIn); #endif /* CC_EVAL_H */ diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index 6e59b6c1a..be3ff8a2c 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -28,7 +28,7 @@ // start of consensus code -int64_t IsFaucetvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsFaucetvout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -39,7 +39,7 @@ int64_t IsFaucetvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v return(0); } -bool FaucetExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool FaucetExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -77,7 +77,7 @@ bool FaucetExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction else return(true); } -bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool FaucetValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; std::vector > txids; @@ -140,7 +140,7 @@ bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx // helper functions for rpc calls in rpcwallet.cpp -int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddFaucetInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; @@ -175,7 +175,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub std::string FaucetGet(uint64_t txfee) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,faucetpk; int64_t inputs,CCchange=0,nValue=FAUCETSIZE; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CPubKey mypk,faucetpk; int64_t inputs,CCchange=0,nValue=FAUCETSIZE; struct CC_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_FAUCET); if ( txfee == 0 ) txfee = 10000; @@ -216,7 +216,7 @@ std::string FaucetGet(uint64_t txfee) std::string FaucetFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,faucetpk; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk,faucetpk; CScript opret; struct CC_info *cp,C; cp = CCinit(&C,EVAL_FAUCET); if ( txfee == 0 ) txfee = 10000; @@ -234,7 +234,7 @@ UniValue FaucetInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey faucetpk; struct CCcontract_info *cp,C; int64_t funding; + CPubKey faucetpk; struct CC_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Faucet")); cp = CCinit(&C,EVAL_FAUCET); diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index 0bcc61a1b..573299665 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -23,7 +23,7 @@ // start of consensus code -int64_t IsFSMvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsFSMvout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -34,7 +34,7 @@ int64_t IsFSMvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool FSMExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool FSMExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -72,7 +72,7 @@ bool FSMExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &t else return(true); } -bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool FSMValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; return eval->Invalid("no validation yet"); @@ -120,7 +120,7 @@ bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, u // helper functions for rpc calls in rpcwallet.cpp -int64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddFSMInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; @@ -158,7 +158,7 @@ std::string FSMList() std::string FSMCreate(uint64_t txfee,std::string name,std::string states) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,fsmpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CPubKey mypk,fsmpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; cp = CCinit(&C,EVAL_FSM); if ( txfee == 0 ) txfee = 10000; @@ -179,7 +179,7 @@ std::string FSMCreate(uint64_t txfee,std::string name,std::string states) std::string FSMInfo(uint256 fsmtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,fsmpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk,fsmpk; int64_t funds = 0; CScript opret; struct CC_info *cp,C; cp = CCinit(&C,EVAL_FSM); mypk = pubkey2pk(Mypubkey()); fsmpk = GetUnspendable(cp,0); diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index c64d56b80..f00b1abfd 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -320,7 +320,7 @@ uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey) return(0); } -int64_t IsGatewaysvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsGatewaysvout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -331,7 +331,7 @@ int64_t IsGatewaysvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool GatewaysExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -429,7 +429,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u return(zeroid); } -int32_t GatewaysCointxidExists(struct CCcontract_info *cp,uint256 cointxid) // dont forget to check mempool! +int32_t GatewaysCointxidExists(struct CC_info *cp,uint256 cointxid) // dont forget to check mempool! { char txidaddr[64]; std::string coin; int32_t numvouts; uint256 hashBlock; std::vector > addressIndex; @@ -515,7 +515,7 @@ int64_t GatewaysDepositval(CTransaction tx,CPubKey mypk) return(0); } -bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) +bool GatewaysValidate(struct CC_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],M,N,taddr,prefix,prefix2; char str[65],destaddr[64],depositaddr[65],validationError[512]; @@ -683,7 +683,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & // helper functions for rpc calls in rpcwallet.cpp -int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 reftokenid,int64_t total,int32_t maxinputs) +int64_t AddGatewaysInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 reftokenid,int64_t total,int32_t maxinputs) { char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 tokenid,txid,hashBlock; std::vector origpubkey; std::vector vopret; CTransaction vintx; int32_t j,vout,n = 0; uint8_t evalcode,funcid; std::vector > unspentOutputs; @@ -730,7 +730,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP return(totalinputs); } -int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 reftokenid) // dont forget to check mempool! +int32_t GatewaysBindExists(struct CC_info *cp,CPubKey gatewayspk,uint256 reftokenid) // dont forget to check mempool! { char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; CTransaction tx; std::vector > addressIndex; @@ -757,7 +757,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CCcontract_info *cp,C; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],str[65],*fstr; + CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CC_info *cp,C; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],str[65],*fstr; cp = CCinit(&C,EVAL_GATEWAYS); if ( strcmp((char *)"KMD",coin.c_str()) == 0 ) { @@ -844,7 +844,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction bindtx; CPubKey mypk,gatewayspk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; - int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CCcontract_info *cp,C; + int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CC_info *cp,C; std::vector pubkeys,publishers; std::vectortxids; char str[67],depositaddr[64],txidaddr[64]; cp = CCinit(&C,EVAL_GATEWAYS); @@ -910,7 +910,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CCcontract_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; + CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CC_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; std::string coin, deposithex; std::vector msigpubkeys,publishers; int64_t totalsupply,depositamount,tmpamount,inputs,CCchange=0; int32_t numvouts,claimvout,height; std::vector proof; uint256 hashBlock,tokenid,oracletxid,tmptxid,cointxid; char str[65],depositaddr[64],coinaddr[64],destaddr[64]; std::vector txids; @@ -985,8 +985,8 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin CPubKey mypk, gatewayspk; uint256 tokenid,hashBlock,oracletxid; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; - struct CCcontract_info *cpGateways, gatewaysC; - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpGateways, gatewaysC; + struct CC_info *cpTokens, tokensC; cpGateways = CCinit(&gatewaysC, EVAL_GATEWAYS); cpTokens = CCinit(&tokensC, EVAL_TOKENS); @@ -1049,7 +1049,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string hex) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,txidaddrpk,signerpk; struct CCcontract_info *cp,C; CTransaction tx; + CPubKey mypk,txidaddrpk,signerpk; struct CC_info *cp,C; CTransaction tx; std::vector > unspentOutputs; char txidaddr[65]; int32_t maxK,K=0; uint256 tmptxid,parttxid,hashBlock; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1089,7 +1089,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string GatewaysCompleteSigning(uint64_t txfee,uint256 withdrawtxid,std::string refcoin,std::string hex) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; + CPubKey mypk,gatewayspk; struct CC_info *cp,C; char txidaddr[65]; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); @@ -1104,7 +1104,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 withdrawtxid,std::str std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; + CPubKey mypk,gatewayspk; struct CC_info *cp,C; char txidaddr[65]; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) @@ -1118,7 +1118,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string tmprefcoin; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; uint256 hashBlock,tokenid,txid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; char depositaddr[64],coinaddr[64],destaddr[64],str[65],withaddr[64],numstr[32],txidaddr[64],cctxidaddr[64],signeraddr[64]; - int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; + int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CC_info *cp,C; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1186,7 +1186,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string tmprefcoin,hex; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; uint256 withdrawtxid,hashBlock,txid,tokenid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; char depositaddr[64],coinaddr[64],str[65],numstr[32],txidaddr[64],cctxidaddr[64],withaddr[64]; - int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; + int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CC_info *cp,C; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1278,7 +1278,7 @@ UniValue GatewaysMultisig(char *cctxidaddr) UniValue GatewaysList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); SetCCtxids(addressIndex,cp->unspendableCCaddr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -1298,7 +1298,7 @@ UniValue GatewaysList() UniValue GatewaysInfo(uint256 bindtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaysassets[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t totalsupply,remaining; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaysassets[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CPubKey Gatewayspk; struct CC_info *cp,C; int32_t i; int64_t totalsupply,remaining; result.push_back(Pair("result","success")); result.push_back(Pair("name","Gateways")); cp = CCinit(&C,EVAL_GATEWAYS); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 4a78c69ac..499fb598d 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -34,7 +34,7 @@ class TokenHelper; // Plan validation runner, it may be called twice - for coins and tokens // (sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation()...) -template bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun) +template bool RunValidationPlans(uint8_t funcId, struct CC_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun) { int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); @@ -104,14 +104,14 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont /** * Tx validation entry function */ -bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction& tx, uint32_t nIn) +bool HeirValidate(struct CC_info* cpHeir, Eval* eval, const CTransaction& tx, uint32_t nIn) { int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); //int32_t preventCCvins = -1; //int32_t preventCCvouts = -1; - struct CCcontract_info *cpTokens, tokensC; + struct CC_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); if (numvouts < 1) @@ -237,7 +237,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction * Checks if vout is to cryptocondition address * @return vout value in satoshis */ -template int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) +template int64_t IsHeirFundingVout(struct CC_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) { char destaddr[65], heirFundingAddr[65]; @@ -437,7 +437,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke // TODO: correct cc addr: std::vector> unspentOutputs; - struct CCcontract_info *cp, C; + struct CC_info *cp, C; cp = CCinit(&C, EVAL_HEIR); char coinaddr[64]; GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' @@ -507,7 +507,7 @@ uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &token } // add inputs of 1 of 2 cc address -template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs) +template int64_t Add1of2AddressInputs(struct CC_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs) { // TODO: add threshold check int64_t nValue, voutValue, totalinputs = 0; @@ -566,7 +566,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, /** * enumerate all tx's sending to CCHeir 1of2address and calc total lifetime funds */ -template int64_t LifetimeHeirContractFunds(struct CCcontract_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) +template int64_t LifetimeHeirContractFunds(struct CC_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) { char coinaddr[64]; Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' @@ -619,7 +619,7 @@ template UniValue HeirFund(uint64_t txfee, int64_t amount, std { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CCcontract_info *cp, C; + struct CC_info *cp, C; cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) @@ -707,7 +707,7 @@ template UniValue _HeirAdd(uint256 fundingtxid, uint64_t txfee, i UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); int64_t inputs, CCchange = 0; - struct CCcontract_info *cp, C; + struct CC_info *cp, C; std::string rawhex; cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! @@ -825,7 +825,7 @@ template UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfe CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey myPubkey; int64_t inputs, change = 0; - struct CCcontract_info *cp, C; + struct CC_info *cp, C; cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) @@ -1006,7 +1006,7 @@ UniValue HeirInfo(uint256 fundingtxid) return result; }*/ - struct CCcontract_info *cp, C; + struct CC_info *cp, C; cp = CCinit(&C, EVAL_HEIR); uint8_t hasHeirSpendingBegun = 0; @@ -1123,7 +1123,7 @@ UniValue HeirInfo(uint256 fundingtxid) * @return list of heir plan handles (fundingtxid) */ -template void _HeirList(struct CCcontract_info *cp, UniValue &result) +template void _HeirList(struct CC_info *cp, UniValue &result) { std::vector> unspentOutputs; char coinaddr[64]; @@ -1174,7 +1174,7 @@ UniValue HeirList() UniValue result(UniValue::VOBJ); result.push_back(Pair("result", "success")); - struct CCcontract_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! + struct CC_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! cpHeir = CCinit(&heirC, EVAL_HEIR); cpTokens = CCinit(&tokenC, EVAL_TOKENS); diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index d66777933..39f6855ac 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -47,11 +47,11 @@ public: return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CCcontract_info *cpHeir, heirC; + struct CC_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } }; @@ -61,7 +61,7 @@ class TokenHelper { public: static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { - struct CCcontract_info *cpHeir, heirC; + struct CC_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_TOKENS); return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); } @@ -89,12 +89,12 @@ public: return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CCcontract_info *cpHeir, heirC; + struct CC_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } @@ -628,4 +628,4 @@ public: }; -#endif \ No newline at end of file +#endif diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index e9c263ff1..c52c9a072 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -63,7 +63,7 @@ It is possible to have a jackpot but miss out on it due to not claiming it. To m // start of consensus code -int64_t IsLottovout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsLottovout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -74,7 +74,7 @@ int64_t IsLottovout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool LottoExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool LottoExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -112,7 +112,7 @@ bool LottoExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction else return(true); } -bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool LottoValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; return eval->Invalid("no validation yet"); @@ -160,7 +160,7 @@ bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, // helper functions for rpc calls in rpcwallet.cpp -int64_t AddLottoInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddLottoInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; @@ -203,7 +203,7 @@ uint8_t DecodeLottoFundingOpRet(const CScript &scriptPubKey,uint64_t &sbits,int3 return(0); } -int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,uint256 reffundingtxid) +int64_t LottoPlanFunds(uint64_t refsbits,struct CC_info *cp,CPubKey pk,uint256 reffundingtxid) { char coinaddr[64]; uint64_t sbits; int64_t nValue,lockedfunds; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t vout; uint8_t funcid; std::vector > unspentOutputs; @@ -232,7 +232,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,u UniValue LottoInfo(uint256 lottoid) { - UniValue result(UniValue::VOBJ); uint256 hashBlock,hentropy; CTransaction vintx; uint64_t lockedfunds,sbits; int32_t ticketsize,odds,firstheight,period; CPubKey lottopk; struct CCcontract_info *cp,C; char str[67],numstr[65]; + UniValue result(UniValue::VOBJ); uint256 hashBlock,hentropy; CTransaction vintx; uint64_t lockedfunds,sbits; int32_t ticketsize,odds,firstheight,period; CPubKey lottopk; struct CC_info *cp,C; char str[67],numstr[65]; if ( GetTransaction(lottoid,vintx,hashBlock,false) == 0 ) { fprintf(stderr,"cant find lottoid\n"); @@ -264,7 +264,7 @@ UniValue LottoInfo(uint256 lottoid) UniValue LottoList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; cp = CCinit(&C,EVAL_LOTTO); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -284,7 +284,7 @@ UniValue LottoList() std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t ticketsize,int32_t odds,int32_t firstheight,int32_t period) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - uint256 entropy,hentropy; CPubKey mypk,lottopk; uint64_t sbits; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + uint256 entropy,hentropy; CPubKey mypk,lottopk; uint64_t sbits; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; @@ -303,7 +303,7 @@ std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t tic std::string LottoTicket(uint64_t txfee,uint256 lottoid,int64_t numtickets) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,lottopk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CPubKey mypk,lottopk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; @@ -324,7 +324,7 @@ std::string LottoTicket(uint64_t txfee,uint256 lottoid,int64_t numtickets) std::string LottoWinner(uint64_t txfee) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,lottopk; int64_t winnings = 0; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk,lottopk; int64_t winnings = 0; CScript opret; struct CC_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 795b95186..692c496b3 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -47,7 +47,7 @@ // start of consensus code -int64_t IsMarmaravout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsMarmaravout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -188,7 +188,7 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { - CTxOut ccvout; struct CCcontract_info *cp,C; CPubKey Marmarapk; + CTxOut ccvout; struct CC_info *cp,C; CPubKey Marmarapk; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) @@ -212,7 +212,7 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk) int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { - struct CCcontract_info *cp,C; CPubKey Marmarapk,pk; int32_t ht,unlockht; CTxOut ccvout; + struct CC_info *cp,C; CPubKey Marmarapk,pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); if ( 0 ) @@ -255,7 +255,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) return(-1); } -bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool MarmaraValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { std::vector vopret; CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid,*script; CPubKey pk,vpk; if ( ASSETCHAINS_MARMARA == 0 ) @@ -326,7 +326,7 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t // helper functions for rpc calls in rpcwallet.cpp -int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx,int32_t firstheight,CPubKey poolpk,int32_t maxinputs) +int64_t AddMarmaraCoinbases(struct CC_info *cp,CMutableTransaction &mtx,int32_t firstheight,CPubKey poolpk,int32_t maxinputs) { char coinaddr[64]; CPubKey Marmarapk,pk; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; std::vector > unspentOutputs; @@ -408,7 +408,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum=0,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; + UniValue result(UniValue::VOBJ); struct CC_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum=0,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; if ( (height & 1) != 0 ) @@ -490,7 +490,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures,height; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; std::vector pubkeys; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures,height; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; std::vector pubkeys; struct CC_info *cp,C; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); @@ -607,7 +607,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) return(result); } -int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,int64_t &totalclosed,std::vector &closed,struct CCcontract_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) +int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,int64_t &totalclosed,std::vector &closed,struct CC_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) { char coinaddr[64]; CPubKey Marmarapk,senderpk; int64_t amount; uint256 createtxid,txid,hashBlock; CTransaction tx; int32_t numvouts,vout,matures,n=0; std::string currency; std::vector > unspentOutputs; @@ -643,7 +643,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t batonamount; int32_t needbaton = 0; + UniValue result(UniValue::VOBJ); CPubKey mypk; struct CC_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t batonamount; int32_t needbaton = 0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; @@ -700,7 +700,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk,Marmarapk; struct CCcontract_info *cp,C; std::string rawtx; uint256 createtxid; char *errorstr=0; + UniValue result(UniValue::VOBJ); CPubKey mypk,Marmarapk; struct CC_info *cp,C; std::string rawtx; uint256 createtxid; char *errorstr=0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; @@ -757,7 +757,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CC_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { @@ -911,7 +911,7 @@ UniValue MarmaraCreditloop(uint256 txid) UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,poolfee=0,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,poolfee=0,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CC_info *cp,C; poolpk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; @@ -1000,7 +1000,7 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ { CMutableTransaction mtx; std::vector pubkeys; UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0; std::vector issuances,closed; char coinaddr[64]; - CPubKey Marmarapk; struct CCcontract_info *cp,C; + CPubKey Marmarapk; struct CC_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); result.push_back(Pair("result","success")); diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 66c0e1b9a..a64f65a18 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -163,7 +163,7 @@ uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint25 return(0); } -CPubKey OracleBatonPk(char *batonaddr,struct CCcontract_info *cp) +CPubKey OracleBatonPk(char *batonaddr,struct CC_info *cp) { static secp256k1_context *ctx; size_t clen = CPubKey::PUBLIC_KEY_SIZE; @@ -256,7 +256,7 @@ static uint256 myIs_baton_spentinmempool(uint256 batontxid,int32_t batonvout) return(batontxid); } -uint256 OracleBatonUtxo(uint64_t txfee,struct CCcontract_info *cp,uint256 reforacletxid,char *batonaddr,CPubKey publisher,std::vector &dataarg) +uint256 OracleBatonUtxo(uint64_t txfee,struct CC_info *cp,uint256 reforacletxid,char *batonaddr,CPubKey publisher,std::vector &dataarg) { uint256 txid,oracletxid,hashBlock,btxid,batontxid = zeroid; int64_t dfee; int32_t dheight=0,vout,height,numvouts; CTransaction tx; CPubKey pk; uint8_t *ptr; std::vector vopret,data; std::vector > unspentOutputs; @@ -302,7 +302,7 @@ uint256 OracleBatonUtxo(uint64_t txfee,struct CCcontract_info *cp,uint256 refora uint256 OraclesBatontxid(uint256 reforacletxid,CPubKey refpk) { std::vector > unspentOutputs; - CTransaction regtx; uint256 hash,txid,batontxid,oracletxid; CPubKey pk; int32_t numvouts,height,maxheight=0; int64_t datafee; char markeraddr[64],batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; + CTransaction regtx; uint256 hash,txid,batontxid,oracletxid; CPubKey pk; int32_t numvouts,height,maxheight=0; int64_t datafee; char markeraddr[64],batonaddr[64]; std::vector data; struct CC_info *cp,C; batontxid = zeroid; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,reforacletxid); @@ -528,7 +528,7 @@ int32_t oracleprice_add(std::vector &publishers,CPubKey int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format) { std::vector > unspentOutputs; - CTransaction regtx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; std::vector publishers; std::vector prices; + CTransaction regtx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CC_info *cp,C; std::vector publishers; std::vector prices; if ( format[0] != 'L' ) return(0); cp = CCinit(&C,EVAL_ORACLES); @@ -564,7 +564,7 @@ int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char * return(0); } -int64_t IsOraclesvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsOraclesvout(struct CC_info *cp,const CTransaction& tx,int32_t v) { //char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -575,7 +575,7 @@ int64_t IsOraclesvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -bool OraclesDataValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,uint256 oracletxid,CPubKey publisher,int64_t datafee) +bool OraclesDataValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx,uint256 oracletxid,CPubKey publisher,int64_t datafee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; CScript scriptPubKey; @@ -633,7 +633,7 @@ bool OraclesDataValidate(struct CCcontract_info *cp,Eval* eval,const CTransactio else return(true); } -bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool OraclesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { uint256 txid,oracletxid,batontxid; uint64_t txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts; uint8_t *script; std::vector vopret,data; CScript scriptPubKey; CPubKey publisher; numvins = tx.vin.size(); @@ -703,7 +703,7 @@ bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t // helper functions for rpc calls in rpcwallet.cpp -int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint256 oracletxid,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddOracleInputs(struct CC_info *cp,CMutableTransaction &mtx,uint256 oracletxid,CPubKey pk,int64_t total,int32_t maxinputs) { char coinaddr[64],funcid; int64_t nValue,price,totalinputs = 0; uint256 tmporacletxid,tmpbatontxid,txid,hashBlock; std::vector origpubkey,data; CTransaction vintx; int32_t numvouts,vout,n = 0; std::vector > unspentOutputs; CPubKey tmppk; int64_t tmpnum; @@ -741,7 +741,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint return(totalinputs); } -int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubKey publisher) +int64_t LifetimeOraclesFunds(struct CC_info *cp,uint256 oracletxid,CPubKey publisher) { char coinaddr[64]; CPubKey pk; int64_t total=0,num; uint256 txid,hashBlock,subtxid; CTransaction subtx; std::vector > addressIndex; @@ -765,7 +765,7 @@ int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubK std::string OracleCreate(int64_t txfee,std::string name,std::string description,std::string format) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Oraclespk; struct CCcontract_info *cp,C; char fmt; + CPubKey mypk,Oraclespk; struct CC_info *cp,C; char fmt; cp = CCinit(&C,EVAL_ORACLES); if ( name.size() > 32 || description.size() > 4096 || format.size() > 4096 ) @@ -805,7 +805,7 @@ std::string OracleCreate(int64_t txfee,std::string name,std::string description, std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,markerpubkey,batonpk; struct CCcontract_info *cp,C; char markeraddr[64],batonaddr[64]; + CPubKey mypk,markerpubkey,batonpk; struct CC_info *cp,C; char markeraddr[64],batonaddr[64]; cp = CCinit(&C,EVAL_ORACLES); if ( txfee == 0 ) txfee = 10000; @@ -832,7 +832,7 @@ std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee) std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,markerpubkey; struct CCcontract_info *cp,C; char markeraddr[64]; + CPubKey mypk,markerpubkey; struct CC_info *cp,C; char markeraddr[64]; cp = CCinit(&C,EVAL_ORACLES); if ( txfee == 0 ) txfee = 10000; @@ -852,7 +852,7 @@ std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,i std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector data) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript pubKey; CPubKey mypk,batonpk; int64_t offset,datafee,inputs,CCchange = 0; struct CCcontract_info *cp,C; uint256 batontxid,hashBlock; + CScript pubKey; CPubKey mypk,batonpk; int64_t offset,datafee,inputs,CCchange = 0; struct CC_info *cp,C; uint256 batontxid,hashBlock; char coinaddr[64],batonaddr[64]; std::vector prevdata; CTransaction tx; std::string name,description,format; int32_t len,numvouts; cp = CCinit(&C,EVAL_ORACLES); @@ -971,7 +971,7 @@ UniValue OracleInfo(uint256 origtxid) UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector > unspentOutputs; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; struct CCcontract_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; + CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; struct CC_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,origtxid); if ( GetTransaction(origtxid,tx,hashBlock,false) == 0 ) @@ -1025,7 +1025,7 @@ UniValue OracleInfo(uint256 origtxid) UniValue OraclesList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; cp = CCinit(&C,EVAL_ORACLES); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 859a5ba3f..c25842ea3 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -23,7 +23,7 @@ // start of consensus code -int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsPaymentsvout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -34,7 +34,7 @@ int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -bool PaymentsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool PaymentsExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -72,7 +72,7 @@ bool PaymentsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti else return(true); } -bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool PaymentsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; return eval->Invalid("no validation yet"); @@ -113,7 +113,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // helper functions for rpc calls in rpcwallet.cpp -int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddPaymentsInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -145,7 +145,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP std::string PaymentsGet(uint64_t txfee,int64_t nValue) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Paymentspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CPubKey mypk,Paymentspk; int64_t inputs,CCchange=0; struct CC_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_PAYMENTS); if ( txfee == 0 ) txfee = 10000; @@ -186,7 +186,7 @@ std::string PaymentsGet(uint64_t txfee,int64_t nValue) std::string PaymentsFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Paymentspk; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk,Paymentspk; CScript opret; struct CC_info *cp,C; cp = CCinit(&C,EVAL_PAYMENTS); if ( txfee == 0 ) txfee = 10000; @@ -204,7 +204,7 @@ UniValue PaymentsInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey Paymentspk; struct CCcontract_info *cp,C; int64_t funding; + CPubKey Paymentspk; struct CC_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Payments")); cp = CCinit(&C,EVAL_PAYMENTS); diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index e2893bec8..d137778a6 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -30,7 +30,7 @@ // start of consensus code -int64_t IsPegsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsPegsvout(struct CC_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -41,7 +41,7 @@ int64_t IsPegsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool PegsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool PegsExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -79,7 +79,7 @@ bool PegsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction & else return(true); } -bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool PegsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; return eval->Invalid("no validation yet"); @@ -120,7 +120,7 @@ bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, // helper functions for rpc calls in rpcwallet.cpp -int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddPegsInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -152,7 +152,7 @@ int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe std::string PegsGet(uint64_t txfee,int64_t nValue) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Pegspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CPubKey mypk,Pegspk; int64_t inputs,CCchange=0; struct CC_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_PEGS); if ( txfee == 0 ) txfee = 10000; @@ -193,7 +193,7 @@ std::string PegsGet(uint64_t txfee,int64_t nValue) std::string PegsFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Pegspk; CScript opret; struct CCcontract_info *cp,C; + CPubKey mypk,Pegspk; CScript opret; struct CC_info *cp,C; cp = CCinit(&C,EVAL_PEGS); if ( txfee == 0 ) txfee = 10000; @@ -211,7 +211,7 @@ UniValue PegsInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey Pegspk; struct CCcontract_info *cp,C; int64_t funding; + CPubKey Pegspk; struct CC_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Pegs")); cp = CCinit(&C,EVAL_PEGS); diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 369495b1a..6171e73a8 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -86,7 +86,7 @@ uint8_t DecodePricesFundingOpRet(CScript scriptPubKey,CPubKey &planpk,uint256 &o return(0); } -bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool PricesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; return eval->Invalid("no validation yet"); @@ -127,7 +127,7 @@ bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx // helper functions for rpc calls in rpcwallet.cpp -int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char *destaddr,uint256 tolenid,int64_t total,int32_t maxinputs) +int64_t AddTokensInputs(struct CC_info *cp,CMutableTransaction &mtx,char *destaddr,uint256 tolenid,int64_t total,int32_t maxinputs) { // add threshold check int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -158,7 +158,7 @@ int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char UniValue PricesList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint64_t mode; int32_t margin,maxleverage; std::vectorpubkeys; uint256 txid,hashBlock,oracletxid,longtoken,shorttoken,bettoken; CPubKey planpk,pricespk; char str[65]; CTransaction vintx; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint64_t mode; int32_t margin,maxleverage; std::vectorpubkeys; uint256 txid,hashBlock,oracletxid,longtoken,shorttoken,bettoken; CPubKey planpk,pricespk; char str[65]; CTransaction vintx; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); SetCCtxids(addressIndex,cp->normaladdr); @@ -183,7 +183,7 @@ UniValue PricesList() std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletxid,uint64_t margin,uint64_t mode,uint256 longtoken,uint256 shorttoken,int32_t maxleverage,int64_t funding,std::vector pubkeys) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CCcontract_info *cp,C; + CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CC_info *cp,C; if ( funding < 100*COIN || maxleverage <= 0 || maxleverage > 10000 ) { CCerror = "invalid parameter error"; @@ -246,7 +246,7 @@ std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletx UniValue PricesInfo(uint256 fundingtxid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); CPubKey pricespk,planpk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction vintx; int64_t balance,supply,exposure; uint64_t funding,mode; int32_t i,margin,maxleverage; char numstr[65],houseaddr[64],exposureaddr[64],str[65]; std::vectorpubkeys; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); CPubKey pricespk,planpk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction vintx; int64_t balance,supply,exposure; uint64_t funding,mode; int32_t i,margin,maxleverage; char numstr[65],houseaddr[64],exposureaddr[64],str[65]; std::vectorpubkeys; struct CC_info *cp,C; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); if ( GetTransaction(fundingtxid,vintx,hashBlock,false) == 0 ) @@ -295,7 +295,7 @@ UniValue PricesInfo(uint256 fundingtxid) std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,CCchange = 0; uint64_t funding,mode; int32_t margin,maxleverage; char houseaddr[64],myaddr[64]; std::vectorpubkeys; + struct CC_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,CCchange = 0; uint64_t funding,mode; int32_t margin,maxleverage; char houseaddr[64],myaddr[64]; std::vectorpubkeys; if ( amount < 10000 ) { CCerror = "amount must be positive"; @@ -350,7 +350,7 @@ std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingt std::string PricesBet(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount,int32_t leverage) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; + struct CC_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; if ( amount < 0 ) { amount = -amount; diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index bd5a6d919..c47fcf1c2 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -141,7 +141,7 @@ uint8_t DecodeRewardsOpRet(uint256 txid,const CScript &scriptPubKey,uint64_t &sb return(0); } -int64_t IsRewardsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) +int64_t IsRewardsvout(struct CC_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) { char destaddr[64]; uint64_t sbits; uint256 fundingtxid,txid; uint8_t funcid; int32_t numvouts; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 && (numvouts= (int32_t)tx.vout.size()) > 0 ) @@ -157,7 +157,7 @@ int64_t IsRewardsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -bool RewardsExactAmounts(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx,uint64_t txfee,uint64_t refsbits,uint256 reffundingtxid) +bool RewardsExactAmounts(struct CC_info *cp,Eval *eval,const CTransaction &tx,uint64_t txfee,uint64_t refsbits,uint256 reffundingtxid) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -192,7 +192,7 @@ bool RewardsExactAmounts(struct CCcontract_info *cp,Eval *eval,const CTransactio else return(true); } -bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool RewardsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { uint256 txid,fundingtxid,hashBlock,vinfundingtxid; uint64_t vinsbits,sbits,APR,minseconds,maxseconds,mindeposit,amount,reward,txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; uint8_t funcid; CScript scriptPubKey; CTransaction fundingTx,vinTx; numvins = tx.vin.size(); @@ -327,7 +327,7 @@ static uint64_t myIs_unlockedtx_inmempool(uint256 &txid,int32_t &vout,uint64_t r } // 'L' vs 'F' and 'A' -int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) +int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) { char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t numblocks,j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; @@ -387,7 +387,7 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcont return(totalinputs); } -int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,uint256 reffundingtxid) +int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CC_info *cp,CPubKey pk,uint256 reffundingtxid) { char coinaddr[64]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t vout; uint8_t funcid; std::vector > unspentOutputs; @@ -418,7 +418,7 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontra return(totalinputs); } -bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewardspk,uint64_t &APR,uint64_t &minseconds,uint64_t &maxseconds,uint64_t &mindeposit) +bool RewardsPlanExists(struct CC_info *cp,uint64_t refsbits,CPubKey rewardspk,uint64_t &APR,uint64_t &minseconds,uint64_t &maxseconds,uint64_t &mindeposit) { char CCaddr[64]; uint64_t sbits; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; @@ -443,7 +443,7 @@ bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewa UniValue RewardsInfo(uint256 rewardsid) { - UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; uint64_t lockedfunds,APR,minseconds,maxseconds,mindeposit,sbits,funding; CPubKey rewardspk; struct CCcontract_info *cp,C; char str[67],numstr[65]; + UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; uint64_t lockedfunds,APR,minseconds,maxseconds,mindeposit,sbits,funding; CPubKey rewardspk; struct CC_info *cp,C; char str[67],numstr[65]; if ( GetTransaction(rewardsid,vintx,hashBlock,false) == 0 ) { fprintf(stderr,"cant find fundingtxid\n"); @@ -481,7 +481,7 @@ UniValue RewardsInfo(uint256 rewardsid) UniValue RewardsList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; cp = CCinit(&C,EVAL_REWARDS); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -501,7 +501,7 @@ UniValue RewardsList() std::string RewardsCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t APR,int64_t minseconds,int64_t maxseconds,int64_t mindeposit) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; + CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CC_info *cp,C; if ( funds < COIN || mindeposit < 0 || minseconds < 0 || maxseconds < 0 ) { fprintf(stderr,"negative parameter error\n"); @@ -536,7 +536,7 @@ std::string RewardsCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int6 std::string RewardsAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; + CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CC_info *cp,C; if ( amount < 0 ) { fprintf(stderr,"negative parameter error\n"); @@ -571,7 +571,7 @@ std::string RewardsAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,i std::string RewardsLock(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t deposit) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,rewardspk; CScript opret; uint64_t lockedfunds,sbits,funding,APR,minseconds,maxseconds,mindeposit; struct CCcontract_info *cp,C; + CPubKey mypk,rewardspk; CScript opret; uint64_t lockedfunds,sbits,funding,APR,minseconds,maxseconds,mindeposit; struct CC_info *cp,C; if ( deposit < txfee ) { CCerror = "deposit amount less than txfee"; @@ -615,7 +615,7 @@ std::string RewardsLock(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 locktxid) { CMutableTransaction firstmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; char coinaddr[64]; CPubKey mypk,rewardspk; CScript scriptPubKey,ignore; uint256 hashBlock; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; int64_t funding,reward=0,amount=0,inputs,CCchange=0; struct CCcontract_info *cp,C; + CTransaction tx; char coinaddr[64]; CPubKey mypk,rewardspk; CScript scriptPubKey,ignore; uint256 hashBlock; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; int64_t funding,reward=0,amount=0,inputs,CCchange=0; struct CC_info *cp,C; cp = CCinit(&C,EVAL_REWARDS); if ( txfee == 0 ) txfee = 10000; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 10c6ee4b8..51b31c5c7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2150,7 +2150,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { - struct CCcontract_info *cp,C; uint256 txid; int32_t vout; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk; + struct CC_info *cp,C; uint256 txid; int32_t vout; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 90f8fd6db..24f0c5f98 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -463,6 +463,10 @@ static const CRPCCommand vRPCCommands[] = // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, + { "CClib", "cclibaddress", &cclibaddress, true }, + { "CClib", "cclibinfo", &cclibinfo, true }, + { "CClib", "cclib", &cclib, true }, + // Gateways { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index d5ebb56ab..92cbb5105 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -286,7 +286,9 @@ extern UniValue marmara_info(const UniValue& params, bool fHelp); extern UniValue marmara_creditloop(const UniValue& params, bool fHelp); extern UniValue marmara_settlement(const UniValue& params, bool fHelp); extern UniValue marmara_lock(const UniValue& params, bool fHelp); -extern UniValue paymentsaddress(const UniValue& params, bool fHelp); +extern UniValue cclibaddress(const UniValue& params, bool fHelp); +extern UniValue cclibinfo(const UniValue& params, bool fHelp); +extern UniValue cclib(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); extern UniValue gatewaysinfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 02cf85ee6..588706a41 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5197,7 +5197,7 @@ int32_t ensure_CCrequirements() #include "../cc/CCHeir.h" #include "../cc/CCMarmara.h" -UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector &pubkey) +UniValue CCaddress(struct CC_info *cp,char *name,std::vector &pubkey) { UniValue result(UniValue::VOBJ); char destaddr[64],str[64]; CPubKey pk; pk = GetUnspendable(cp,0); @@ -5302,7 +5302,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) UniValue channelsaddress(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector destpubkey; CPubKey pk,pk2; char destaddr[64]; + UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::vector destpubkey; CPubKey pk,pk2; char destaddr[64]; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 1 ) throw runtime_error("channelsaddress destpubkey\n"); @@ -5327,9 +5327,46 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +UniValue cclibaddress(const UniValue& params, bool fHelp) +{ + struct CC_info *cp,C; std::vector pubkey; + cp = CCinit(&C,EVAL_FIRSTUSER); + if ( fHelp || params.size() > 1 ) + throw runtime_error("cclibaddress [pubkey]\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + if ( params.size() == 1 ) + pubkey = ParseHex(params[0].get_str().c_str()); + return(CCaddress(cp,(char *)"CClib",pubkey)); +} + +UniValue cclibinfo(const UniValue& params, bool fHelp) +{ + struct CC_info *cp,C; + cp = CCinit(&C,EVAL_FIRSTUSER); + if ( fHelp || params.size() > 0 ) + throw runtime_error("cclibinfo\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + return(CClib_info(cp)); +} + +UniValue cclib(const UniValue& params, bool fHelp) +{ + struct CC_info *cp,C; char *method; cJSON *params; + cp = CCinit(&C,EVAL_FIRSTUSER); + if ( fHelp || params.size() > 2 ) + throw runtime_error("cclib method [JSON params]\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + method = params[0].get_str().c_str(); + params = cJSON_Parse(params[1].get_str().c_str()); + return(CClib(cp,method,params)); +} + UniValue oraclesaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_ORACLES); if ( fHelp || params.size() > 1 ) throw runtime_error("oraclesaddress [pubkey]\n"); @@ -5342,7 +5379,7 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp) UniValue pricesaddress(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C,*assetscp,C2; std::vector pubkey; CPubKey mypk,planpk,pricespk; char myaddr[64],houseaddr[64],exposureaddr[64]; + UniValue result(UniValue::VOBJ); struct CC_info *cp,C,*assetscp,C2; std::vector pubkey; CPubKey mypk,planpk,pricespk; char myaddr[64],houseaddr[64],exposureaddr[64]; cp = CCinit(&C,EVAL_PRICES); assetscp = CCinit(&C2,EVAL_PRICES); if ( fHelp || params.size() > 1 ) @@ -5365,7 +5402,7 @@ UniValue pricesaddress(const UniValue& params, bool fHelp) UniValue pegsaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_PEGS); if ( fHelp || params.size() > 1 ) throw runtime_error("pegssaddress [pubkey]\n"); @@ -5378,7 +5415,7 @@ UniValue pegsaddress(const UniValue& params, bool fHelp) UniValue marmaraaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_MARMARA); if ( fHelp || params.size() > 1 ) throw runtime_error("Marmaraaddress [pubkey]\n"); @@ -5391,7 +5428,7 @@ UniValue marmaraaddress(const UniValue& params, bool fHelp) UniValue paymentsaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_PAYMENTS); if ( fHelp || params.size() > 1 ) throw runtime_error("paymentsaddress [pubkey]\n"); @@ -5404,7 +5441,7 @@ UniValue paymentsaddress(const UniValue& params, bool fHelp) UniValue gatewaysaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_GATEWAYS); if ( fHelp || params.size() > 1 ) throw runtime_error("gatewaysaddress [pubkey]\n"); @@ -5417,7 +5454,7 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) UniValue heiraddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_HEIR); if ( fHelp || params.size() > 1 ) throw runtime_error("heiraddress [pubkey]\n"); @@ -5432,7 +5469,7 @@ UniValue heiraddress(const UniValue& params, bool fHelp) UniValue lottoaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_LOTTO); if ( fHelp || params.size() > 1 ) throw runtime_error("lottoaddress [pubkey]\n"); @@ -5445,7 +5482,7 @@ UniValue lottoaddress(const UniValue& params, bool fHelp) UniValue FSMaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_FSM); if ( fHelp || params.size() > 1 ) throw runtime_error("FSMaddress [pubkey]\n"); @@ -5458,7 +5495,7 @@ UniValue FSMaddress(const UniValue& params, bool fHelp) UniValue auctionaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_AUCTION); if ( fHelp || params.size() > 1 ) throw runtime_error("auctionaddress [pubkey]\n"); @@ -5471,7 +5508,7 @@ UniValue auctionaddress(const UniValue& params, bool fHelp) UniValue diceaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_DICE); if ( fHelp || params.size() > 1 ) throw runtime_error("diceaddress [pubkey]\n"); @@ -5484,7 +5521,7 @@ UniValue diceaddress(const UniValue& params, bool fHelp) UniValue faucetaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; int errno; cp = CCinit(&C,EVAL_FAUCET); if ( fHelp || params.size() > 1 ) @@ -5499,7 +5536,7 @@ UniValue faucetaddress(const UniValue& params, bool fHelp) UniValue rewardsaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_REWARDS); if ( fHelp || params.size() > 1 ) throw runtime_error("rewardsaddress [pubkey]\n"); @@ -5512,7 +5549,7 @@ UniValue rewardsaddress(const UniValue& params, bool fHelp) UniValue assetsaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp, C; std::vector pubkey; + struct CC_info *cp, C; std::vector pubkey; cp = CCinit(&C, EVAL_ASSETS); if (fHelp || params.size() > 1) throw runtime_error("assetsaddress [pubkey]\n"); @@ -5525,7 +5562,7 @@ UniValue assetsaddress(const UniValue& params, bool fHelp) UniValue tokenaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CC_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_TOKENS); if ( fHelp || params.size() > 1 ) throw runtime_error("tokenaddress [pubkey]\n"); @@ -5730,7 +5767,7 @@ UniValue channelsinfo(const UniValue& params, bool fHelp) UniValue channelsopen(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); int32_t numpayments; int64_t payment; std::vector destpub; struct CCcontract_info *cp,C; std::string hex; + UniValue result(UniValue::VOBJ); int32_t numpayments; int64_t payment; std::vector destpub; struct CC_info *cp,C; std::string hex; uint256 tokenid=zeroid; cp = CCinit(&C,EVAL_CHANNELS); @@ -5773,7 +5810,7 @@ UniValue channelsopen(const UniValue& params, bool fHelp) UniValue channelspayment(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid,secret=zeroid; int32_t n; int64_t amount; + UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::string hex; uint256 opentxid,secret=zeroid; int32_t n; int64_t amount; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() < 2 || params.size() >3 ) throw runtime_error("channelspayment opentxid amount [secret]\n"); @@ -5803,7 +5840,7 @@ UniValue channelspayment(const UniValue& params, bool fHelp) UniValue channelsclose(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid; + UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::string hex; uint256 opentxid; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 1 ) throw runtime_error("channelsclose opentxid\n"); @@ -5823,7 +5860,7 @@ UniValue channelsclose(const UniValue& params, bool fHelp) UniValue channelsrefund(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid,closetxid; + UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::string hex; uint256 opentxid,closetxid; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 2 ) throw runtime_error("channelsrefund opentxid closetxid\n"); @@ -6877,7 +6914,7 @@ UniValue tokenorders(const UniValue& params, bool fHelp) UniValue tokenbalance(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 tokenid; uint64_t balance; std::vector pubkey; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ); uint256 tokenid; uint64_t balance; std::vector pubkey; struct CC_info *cp,C; CCerror.clear(); if ( fHelp || params.size() > 2 ) From df2c10a6d7e0ca0add54826b9e6b97d63b2b175c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 22:50:26 -1100 Subject: [PATCH 1329/3904] CC_info --- src/cc/CCutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index b61fef840..9d4567322 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -638,7 +638,7 @@ bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull,co bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { - uint8_t evalcode; int32_t height,from_mempool; struct CCinfo *cp; + uint8_t evalcode; int32_t height,from_mempool; struct CC_info *cp; if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) { fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME); From 0b911c18ac9efdebbc96c97c631889b4a24a61ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 22:52:13 -1100 Subject: [PATCH 1330/3904] Fix --- src/cc/CCutils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 9d4567322..5a7ee53f0 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -636,6 +636,8 @@ bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull,co return(false); } +extern struct CC_info CCinfos[0x100]; + bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { uint8_t evalcode; int32_t height,from_mempool; struct CC_info *cp; @@ -657,17 +659,17 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co evalcode = cond->code[0]; if ( evalcode >= EVAL_FIRSTUSER && evalcode <= EVAL_LASTUSER ) { - cp = &CCinfos[(int32_t)ecode]; + cp = &CCinfos[(int32_t)evalcode]; if ( cp->didinit == 0 ) { - if ( CClib_initcp(cp,ecode) == 0 ) + if ( CClib_initcp(cp,evalcode) == 0 ) cp->didinit = 1; else return eval->Invalid("unsupported CClib evalcode"); } CCclearvars(cp); if ( paramsNull.size() != 0 ) // Don't expect params return eval->Invalid("Cannot have params"); - else if ( CClib_validate(cp,eval,ctx,nIn) != 0 ) + else if ( CClib_validate(cp,eval,txTo,nIn) != 0 ) return(true); return eval->Invalid("error in CClib_validate"); } From df02d14c651159937d65716b33fe22237e87fa08 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 22:53:15 -1100 Subject: [PATCH 1331/3904] Test --- src/cc/CCutils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 5a7ee53f0..d4f7b32bc 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -637,6 +637,8 @@ bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull,co } extern struct CC_info CCinfos[0x100]; +extern std::string MYCCLIBNAME; +bool CClib_validate(struct CC_info *cp,Eval *eval,const CTransaction &txTo,unsigned int nIn); bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { From b1ec7e5afa0887fbe117f02f014f6d9ac16d347a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 22:55:19 -1100 Subject: [PATCH 1332/3904] Test --- src/cc/CCutils.cpp | 2 +- src/cc/cclib.cpp | 2 +- src/cc/heir_validate.h | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index d4f7b32bc..aecca0dd7 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -645,7 +645,7 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co uint8_t evalcode; int32_t height,from_mempool; struct CC_info *cp; if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) { - fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME); + fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME.c_str()); return eval->Invalid("-ac_cclib name mismatches myname"); } height = KOMODO_CONNECTING; diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c93d204df..837a36024 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -38,7 +38,7 @@ CClib_methods[] = { "faucet2_get", "", 0, 0, 'G' }, }; -#define MYCCLIBNAME ((char *)"stub") +std::string MYCCLIBNAME = (char *)"stub"; char *CClib_name() { return(MYCCLIBNAME); } diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 39f6855ac..481947fe2 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -47,11 +47,11 @@ public: return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CC_info *cpHeir, heirC; + struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } }; @@ -61,7 +61,7 @@ class TokenHelper { public: static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { - struct CC_info *cpHeir, heirC; + struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_TOKENS); return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); } @@ -89,12 +89,12 @@ public: return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CC_info *cpHeir, heirC; + struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } From e1e740c18c988da13c6c1cf2d1339ba361d67a87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 22:56:33 -1100 Subject: [PATCH 1333/3904] CC_info --- src/cc/heir_validate.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 481947fe2..85f5b5c11 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -47,11 +47,11 @@ public: return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CCcontract_info *cpHeir, heirC; + struct CC_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } }; @@ -61,7 +61,7 @@ class TokenHelper { public: static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { - struct CCcontract_info *cpHeir, heirC; + struct CC_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_TOKENS); return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); } @@ -89,12 +89,12 @@ public: return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CCcontract_info *cpHeir, heirC; + struct CC_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } @@ -123,13 +123,13 @@ public: class CValidatorBase { public: - CValidatorBase(CCcontract_info* cp) : m_cp(cp) {} + CValidatorBase(CC_info* cp) : m_cp(cp) {} virtual bool isVinValidator() const = 0; virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0; virtual bool validateVout(CTxOut vout, std::string& message) const = 0; protected: - CCcontract_info * m_cp; + CC_info * m_cp; }; /** @@ -138,11 +138,11 @@ protected: class CInputIdentifierBase { public: - CInputIdentifierBase(CCcontract_info* cp) : m_cp(cp) {} + CInputIdentifierBase(CC_info* cp) : m_cp(cp) {} virtual std::string inputName() const = 0; virtual bool identifyInput(CTxIn vin) const = 0; protected: - CCcontract_info * m_cp; + CC_info * m_cp; }; /** @@ -375,7 +375,7 @@ private: class CNormalInputIdentifier : CInputIdentifierBase { public: - CNormalInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + CNormalInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} virtual std::string inputName() const { return std::string("normal input"); } virtual bool identifyInput(CTxIn vin) const { return !IsCCInput(vin.scriptSig); @@ -384,7 +384,7 @@ public: class CCCInputIdentifier : CInputIdentifierBase { public: - CCCInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + CCCInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} virtual std::string inputName() const { return std::string("CC input"); } virtual bool identifyInput(CTxIn vin) const { return IsCCInput(vin.scriptSig); @@ -398,7 +398,7 @@ public: template class CCC1of2AddressValidator : CValidatorBase { public: - CCC1of2AddressValidator(CCcontract_info* cp, CScript opRetScript, std::string customMessage = "") : + CCC1of2AddressValidator(CC_info* cp, CScript opRetScript, std::string customMessage = "") : m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -452,7 +452,7 @@ private: template class CMyPubkeyVoutValidator : CValidatorBase { public: - CMyPubkeyVoutValidator(CCcontract_info* cp, CScript opRetScript, bool checkNormals) + CMyPubkeyVoutValidator(CC_info* cp, CScript opRetScript, bool checkNormals) : m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } @@ -512,7 +512,7 @@ private: template class CHeirSpendValidator : CValidatorBase { public: - CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) + CHeirSpendValidator(CC_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -568,7 +568,7 @@ private: template class COpRetValidator : CValidatorBase { public: - COpRetValidator(CCcontract_info* cp, CScript opret) + COpRetValidator(CC_info* cp, CScript opret) : m_fundingOpretScript(opret), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -619,7 +619,7 @@ private: template class CNullValidator : CValidatorBase { public: - CNullValidator(CCcontract_info* cp) + CNullValidator(CC_info* cp) : CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } From 016548281c628b73107d3ebbe5d0f71885b2552c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:00:53 -1100 Subject: [PATCH 1334/3904] Payments address define --- src/rpc/server.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/server.h b/src/rpc/server.h index 92cbb5105..0166bca41 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -286,6 +286,7 @@ extern UniValue marmara_info(const UniValue& params, bool fHelp); extern UniValue marmara_creditloop(const UniValue& params, bool fHelp); extern UniValue marmara_settlement(const UniValue& params, bool fHelp); extern UniValue marmara_lock(const UniValue& params, bool fHelp); +extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue cclibaddress(const UniValue& params, bool fHelp); extern UniValue cclibinfo(const UniValue& params, bool fHelp); extern UniValue cclib(const UniValue& params, bool fHelp); From 3962a18c334c8062ab437abf9c1becb65ed8ff3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:04:59 -1100 Subject: [PATCH 1335/3904] CC --- src/script/sign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index b90ceafb5..cf44786b7 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -136,7 +136,7 @@ std::vector &GetCryptoConditions() return vCC; } -bool GetCCByUnspendableAddress(struct CCcontract_info *cp, char *addrstr) +bool GetCCByUnspendableAddress(struct CC_info *cp, char *addrstr) { std::vector &vCC = GetCryptoConditions(); bool found = false; From 607f47588b79c404bdde9b06fda4886595388552 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:06:02 -1100 Subject: [PATCH 1336/3904] x --- src/script/sign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index cf44786b7..641d0a4d2 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -153,7 +153,7 @@ bool GetCCByUnspendableAddress(struct CC_info *cp, char *addrstr) return found; } -bool CCinitLite(struct CCcontract_info *cp, uint8_t evalcode) +bool CCinitLite(struct CC_info *cp, uint8_t evalcode) { std::vector &vCC = GetCryptoConditions(); bool found = false; From 4223d927ad5f46cba54f64355e25cd006e9442ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:12:28 -1100 Subject: [PATCH 1337/3904] struct CC_info --- src/cc/heir_validate.h | 1028 ++++++++++++++++++++-------------------- src/script/sign.cpp | 327 ++++++------- 2 files changed, 678 insertions(+), 677 deletions(-) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 85f5b5c11..f8e66e3d5 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -22,100 +22,100 @@ inline static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } // helper class to allow polymorphic behaviour for HeirXXX() functions in case of coins class CoinHelper { public: - - static uint8_t getMyEval() { return EVAL_HEIR; } - static int64_t addOwnerInputs(uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { - return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); - } - - static CScript makeCreateOpRet(uint256 dummyid, std::vector dummyPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName); - } - static CScript makeAddOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan); - } - static CScript makeClaimOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan); - } - static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { - return MakeCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); - } - static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { - return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); - } -/* static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { - return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); - } */ - static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CC_info *cpHeir, heirC; - cpHeir = CCinit(&heirC, EVAL_HEIR); - return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); - } - static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { - CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); - } + + static uint8_t getMyEval() { return EVAL_HEIR; } + static int64_t addOwnerInputs(uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { + return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); + } + + static CScript makeCreateOpRet(uint256 dummyid, std::vector dummyPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { + return EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + } + static CScript makeAddOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan); + } + static CScript makeClaimOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan); + } + static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { + return MakeCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); + } + static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { + return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); + } + /* static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { + return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); + } */ + static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { + struct CC_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); + } + static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + } }; // helper class to allow polymorphic behaviour for HeirXXX() functions in case of tokens class TokenHelper { public: - static uint8_t getMyEval() { return EVAL_TOKENS; } - static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { - struct CC_info *cpHeir, heirC; - cpHeir = CCinit(&heirC, EVAL_TOKENS); - return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); - } - - static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return EncodeTokenOpRet(tokenid, voutTokenPubkeys, - EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName)); - } - static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeTokenOpRet(tokenid, voutTokenPubkeys, - EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan)); - } - static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeTokenOpRet(tokenid, voutTokenPubkeys, - EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan)); - } - - static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { - return MakeTokensCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); - } - static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { - return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS - } -/* static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { - return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS - } */ - static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CC_info *cpHeir, heirC; - cpHeir = CCinit(&heirC, EVAL_HEIR); - return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); - } - - static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { - - CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); - } + static uint8_t getMyEval() { return EVAL_TOKENS; } + static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { + struct CC_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_TOKENS); + return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); + } + + static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { + return EncodeTokenOpRet(tokenid, voutTokenPubkeys, + EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName)); + } + static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeTokenOpRet(tokenid, voutTokenPubkeys, + EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan)); + } + static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { + return EncodeTokenOpRet(tokenid, voutTokenPubkeys, + EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan)); + } + + static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { + return MakeTokensCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); + } + static CTxOut makeUserVout(int64_t amount, CPubKey myPubkey) { + return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS + } + /* static CTxOut makeClaimerVout(int64_t amount, CPubKey myPubkey) { + return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS + } */ + static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { + struct CC_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); + } + + static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + + CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + } }; /** -* Small framework for vins and vouts validation implementing a variation of 'chain of responsibility' pattern: -* It consists of two classes CInputValidationPlan and COutputValidationPlan which both are configured with an array of vectors of validators -* (These validators are derived from the class CValidatorBase). -* -* A example of a validator may verify for a vout if its public key corresponds to the public key which is stored in opreturn. -* Or, vin validator may check if this vin depicts correctly to the CC contract's address. -* -* For validating vins CInputValidator additionally is provided with an instance of a class derived from the CInputIdentifierBase class. -* this identifier class allows to select identical vins (for example, normal vins or cc input vins) and apply validators from the corresponding vector to it. -* Note: CInputValidator treats that at least one identified vin should be present, otherwise it returns eval->invalid() and false. -* -* For validating vouts COutputValidator is configured for each vector of validators with the vout index to which these validators are applied -* (see constructors of both CInputValidator and COutputValidator) -*/ + * Small framework for vins and vouts validation implementing a variation of 'chain of responsibility' pattern: + * It consists of two classes CInputValidationPlan and COutputValidationPlan which both are configured with an array of vectors of validators + * (These validators are derived from the class CValidatorBase). + * + * A example of a validator may verify for a vout if its public key corresponds to the public key which is stored in opreturn. + * Or, vin validator may check if this vin depicts correctly to the CC contract's address. + * + * For validating vins CInputValidator additionally is provided with an instance of a class derived from the CInputIdentifierBase class. + * this identifier class allows to select identical vins (for example, normal vins or cc input vins) and apply validators from the corresponding vector to it. + * Note: CInputValidator treats that at least one identified vin should be present, otherwise it returns eval->invalid() and false. + * + * For validating vouts COutputValidator is configured for each vector of validators with the vout index to which these validators are applied + * (see constructors of both CInputValidator and COutputValidator) + */ /** * base class for all validators @@ -123,13 +123,13 @@ public: class CValidatorBase { public: - CValidatorBase(CC_info* cp) : m_cp(cp) {} - virtual bool isVinValidator() const = 0; - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0; - virtual bool validateVout(CTxOut vout, std::string& message) const = 0; - + CValidatorBase(CCcontract_info* cp) : m_cp(cp) {} + virtual bool isVinValidator() const = 0; + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0; + virtual bool validateVout(CTxOut vout, std::string& message) const = 0; + protected: - CC_info * m_cp; + CCcontract_info * m_cp; }; /** @@ -138,493 +138,493 @@ protected: class CInputIdentifierBase { public: - CInputIdentifierBase(CC_info* cp) : m_cp(cp) {} - virtual std::string inputName() const = 0; - virtual bool identifyInput(CTxIn vin) const = 0; + CInputIdentifierBase(CCcontract_info* cp) : m_cp(cp) {} + virtual std::string inputName() const = 0; + virtual bool identifyInput(CTxIn vin) const = 0; protected: - CC_info * m_cp; + CCcontract_info * m_cp; }; /** -* Encapsulates an array containing rows of validators -* Each row is a vector of validators (zero is possible) for validating vins or prev tx's vouts -* this validation plan is used for validating tx inputs -*/ + * Encapsulates an array containing rows of validators + * Each row is a vector of validators (zero is possible) for validating vins or prev tx's vouts + * this validation plan is used for validating tx inputs + */ template class CInputValidationPlan { - using ValidatorsRow = std::vector; - + using ValidatorsRow = std::vector; + public: - - // Pushes a row of validators for validating a vin or vout - // @param CInputIdentifierBase* pointer to class-identifier which determines several identical adjacent vins (like in schema "vin.0+: normal inputs") - // @param pargs parameter pack of zero or more pointer to validator objects - // Why pointers? because we store the base class in validators' row and then call its virtual functions - template - void pushValidators(CInputIdentifierBase *identifier, ARGS*... pargs) // validators row passed as variadic arguments CValidatorX *val1, CValidatorY *val2 ... - { - ValidatorsRow vValidators({ (TValidatorBase*)pargs... }); - m_arrayValidators.push_back(std::make_pair(identifier, vValidators)); - } - - // validate tx inputs and corresponding prev tx vouts - bool validate(const CTransaction& tx, Eval* eval) - { - std::string message = ""; - //std::cerr << "CInputValidationPlan::validate() starting vins validation..." << std::endl; - - int32_t ival = 0; - int32_t iv = 0; - int32_t numv = tx.vin.size(); - int32_t numValidators = m_arrayValidators.size(); - - // run over vins: - while (iv < numv && ival < numValidators) { - - int32_t identifiedCount = 0; - CInputIdentifierBase *identifier = m_arrayValidators[ival].first; - // check if this is 'our' input: - while (iv < numv && identifier->identifyInput(tx.vin[iv])) { - - // get prev tx: - CTransaction prevTx, *pPrevTxOrNull = NULL; - uint256 hashBlock; - - if (!eval->GetTxUnconfirmed(tx.vin[iv].prevout.hash, prevTx, hashBlock)) { - std::ostringstream stream; - stream << "can't find vinTx for vin=" << iv << "."; - return eval->Invalid(stream.str().c_str()); - } - pPrevTxOrNull = &prevTx; // TODO: get prev tx only if it required (i.e. if vout validators are present) - - // exec 'validators' from validator row of ival index, for tx.vin[iv] - if (!execValidatorsInRow(&tx, pPrevTxOrNull, iv, ival, message)) { - std::ostringstream stream; - stream << "invalid tx vin[" << iv << "]:" << message; - return eval->Invalid(stream.str().c_str()); // ... if not, return 'invalid' - } - - identifiedCount++; // how many vins we identified - iv++; // advance to the next vin - } - - // CInputValidationPlan treats that there must be at least one identified vin for configured validators' row - // like in 'vin.0: normal input' - if (identifiedCount == 0) { - std::ostringstream stream; - stream << "can't find required vins for " << identifier->inputName() << "."; - return eval->Invalid(stream.str().c_str()); - } - - ival++; // advance to the next validator row - // and it will try the same vin with the new CInputIdentifierBase and validators row - } - - // validation is successful if all validators have been used (i.e. ival = numValidators) - if (ival < numValidators) { - std::cerr << "CInputValidationPlan::validate() incorrect tx" << " ival=" << ival << " numValidators=" << numValidators << std::endl; - return eval->Invalid("incorrect tx structure: not all required vins are present."); - } - - //std::cerr << "CInputValidationPlan::validate() returns with true" << std::endl; - return true; - } - + + // Pushes a row of validators for validating a vin or vout + // @param CInputIdentifierBase* pointer to class-identifier which determines several identical adjacent vins (like in schema "vin.0+: normal inputs") + // @param pargs parameter pack of zero or more pointer to validator objects + // Why pointers? because we store the base class in validators' row and then call its virtual functions + template + void pushValidators(CInputIdentifierBase *identifier, ARGS*... pargs) // validators row passed as variadic arguments CValidatorX *val1, CValidatorY *val2 ... + { + ValidatorsRow vValidators({ (TValidatorBase*)pargs... }); + m_arrayValidators.push_back(std::make_pair(identifier, vValidators)); + } + + // validate tx inputs and corresponding prev tx vouts + bool validate(const CTransaction& tx, Eval* eval) + { + std::string message = ""; + //std::cerr << "CInputValidationPlan::validate() starting vins validation..." << std::endl; + + int32_t ival = 0; + int32_t iv = 0; + int32_t numv = tx.vin.size(); + int32_t numValidators = m_arrayValidators.size(); + + // run over vins: + while (iv < numv && ival < numValidators) { + + int32_t identifiedCount = 0; + CInputIdentifierBase *identifier = m_arrayValidators[ival].first; + // check if this is 'our' input: + while (iv < numv && identifier->identifyInput(tx.vin[iv])) { + + // get prev tx: + CTransaction prevTx, *pPrevTxOrNull = NULL; + uint256 hashBlock; + + if (!eval->GetTxUnconfirmed(tx.vin[iv].prevout.hash, prevTx, hashBlock)) { + std::ostringstream stream; + stream << "can't find vinTx for vin=" << iv << "."; + return eval->Invalid(stream.str().c_str()); + } + pPrevTxOrNull = &prevTx; // TODO: get prev tx only if it required (i.e. if vout validators are present) + + // exec 'validators' from validator row of ival index, for tx.vin[iv] + if (!execValidatorsInRow(&tx, pPrevTxOrNull, iv, ival, message)) { + std::ostringstream stream; + stream << "invalid tx vin[" << iv << "]:" << message; + return eval->Invalid(stream.str().c_str()); // ... if not, return 'invalid' + } + + identifiedCount++; // how many vins we identified + iv++; // advance to the next vin + } + + // CInputValidationPlan treats that there must be at least one identified vin for configured validators' row + // like in 'vin.0: normal input' + if (identifiedCount == 0) { + std::ostringstream stream; + stream << "can't find required vins for " << identifier->inputName() << "."; + return eval->Invalid(stream.str().c_str()); + } + + ival++; // advance to the next validator row + // and it will try the same vin with the new CInputIdentifierBase and validators row + } + + // validation is successful if all validators have been used (i.e. ival = numValidators) + if (ival < numValidators) { + std::cerr << "CInputValidationPlan::validate() incorrect tx" << " ival=" << ival << " numValidators=" << numValidators << std::endl; + return eval->Invalid("incorrect tx structure: not all required vins are present."); + } + + //std::cerr << "CInputValidationPlan::validate() returns with true" << std::endl; + return true; + } + private: - // Executes validators from the requested row of validators (selected by iValidators) for selected vin or vout (selected by iv) - bool execValidatorsInRow(const CTransaction* pTx, const CTransaction* pPrevTx, int32_t iv, int32_t ival, std::string& refMessage) const - { - // check boundaries: - if (ival < 0 || ival >= m_arrayValidators.size()) { - std::cerr << "CInputValidationPlan::execValidatorsInRow() internal error: incorrect param ival=" << ival << " size=" << m_arrayValidators.size(); - refMessage = "internal error: incorrect param ival index"; - return false; - } - - if (iv < 0 || iv >= pTx->vin.size()) { - std::cerr << "CInputValidationPlan::execValidatorsInRow() internal error: incorrect param iv=" << iv << " size=" << m_arrayValidators.size(); - refMessage = "internal error: incorrect param iv index"; - return false; - } - - // get requested row of validators: - ValidatorsRow vValidators = m_arrayValidators[ival].second; - - //std::cerr << "CInputValidationPlan::execValidatorsInRow() calling validators" << " for vin iv=" << iv << " ival=" << ival << std::endl; - - for (auto v : vValidators) { - bool result; - - if (v->isVinValidator()) - // validate this vin and previous vout: - result = v->validateVin(pTx->vin[iv], pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); - else - // if it is vout validator pass the previous tx vout: - result = v->validateVout( pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); - if (!result) { - return result; - } - } - return true; // validation OK - } - - + // Executes validators from the requested row of validators (selected by iValidators) for selected vin or vout (selected by iv) + bool execValidatorsInRow(const CTransaction* pTx, const CTransaction* pPrevTx, int32_t iv, int32_t ival, std::string& refMessage) const + { + // check boundaries: + if (ival < 0 || ival >= m_arrayValidators.size()) { + std::cerr << "CInputValidationPlan::execValidatorsInRow() internal error: incorrect param ival=" << ival << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param ival index"; + return false; + } + + if (iv < 0 || iv >= pTx->vin.size()) { + std::cerr << "CInputValidationPlan::execValidatorsInRow() internal error: incorrect param iv=" << iv << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param iv index"; + return false; + } + + // get requested row of validators: + ValidatorsRow vValidators = m_arrayValidators[ival].second; + + //std::cerr << "CInputValidationPlan::execValidatorsInRow() calling validators" << " for vin iv=" << iv << " ival=" << ival << std::endl; + + for (auto v : vValidators) { + bool result; + + if (v->isVinValidator()) + // validate this vin and previous vout: + result = v->validateVin(pTx->vin[iv], pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); + else + // if it is vout validator pass the previous tx vout: + result = v->validateVout( pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); + if (!result) { + return result; + } + } + return true; // validation OK + } + + private: - //std::map m_arrayValidators; - std::vector< std::pair > m_arrayValidators; - + //std::map m_arrayValidators; + std::vector< std::pair > m_arrayValidators; + }; /** -* Encapsulates an array containing rows of validators -* Each row is a vector of validators (zero is possible) for validating vouts -* this validation plan is used for validating tx outputs -*/ + * Encapsulates an array containing rows of validators + * Each row is a vector of validators (zero is possible) for validating vouts + * this validation plan is used for validating tx outputs + */ template class COutputValidationPlan { - using ValidatorsRow = std::vector; - + using ValidatorsRow = std::vector; + public: - // Pushes a row of validators for validating a vout - // @param ivout index to vout to validate - // @param pargs parameter pack of zero or more pointer to validator objects - // Why pointers? because we store base class and call its virtual functions - - template - void pushValidators(int32_t ivout, ARGS*... pargs) // validators row passed as variadic arguments CValidatorX *val1, CValidatorY *val2 ... - { - ValidatorsRow vValidators({ (TValidatorBase*)pargs... }); - m_arrayValidators.push_back(std::make_pair(ivout, vValidators)); - } - - // validate tx outputs - bool validate(const CTransaction& tx, Eval* eval) - { - std::string message = ""; - //std::cerr << "COutputValidationPlan::validateOutputs() starting vouts validation..." << std::endl; - - int32_t ival = 0; - int32_t numVouts = tx.vout.size(); - int32_t numValidators = m_arrayValidators.size(); - - // run over vouts: - while (ival < numValidators) { - - int32_t ivout = m_arrayValidators[ival].first; - if (ivout >= numVouts) { - std::cerr << "COutputValidationPlan::validate() incorrect tx" << "for ival=" << ival << " in tx.vout no such ivout=" << ivout << std::endl; - return eval->Invalid("incorrect tx structure: not all required vouts are present."); - } - else - { - // exec 'validators' from validator row of ival index, for tx.vout[ivout] - if (!execValidatorsInRow(&tx, ivout, ival, message)) { - std::ostringstream stream; - stream << "invalid tx vout[" << ivout << "]:" << message; - return eval->Invalid(stream.str().c_str()); // ... if not, return 'invalid' - } - } - ival++; // advance to the next vout - } - //std::cerr << "COutputValidationPlan::validate() returns with true" << std::endl; - return true; - } - + // Pushes a row of validators for validating a vout + // @param ivout index to vout to validate + // @param pargs parameter pack of zero or more pointer to validator objects + // Why pointers? because we store base class and call its virtual functions + + template + void pushValidators(int32_t ivout, ARGS*... pargs) // validators row passed as variadic arguments CValidatorX *val1, CValidatorY *val2 ... + { + ValidatorsRow vValidators({ (TValidatorBase*)pargs... }); + m_arrayValidators.push_back(std::make_pair(ivout, vValidators)); + } + + // validate tx outputs + bool validate(const CTransaction& tx, Eval* eval) + { + std::string message = ""; + //std::cerr << "COutputValidationPlan::validateOutputs() starting vouts validation..." << std::endl; + + int32_t ival = 0; + int32_t numVouts = tx.vout.size(); + int32_t numValidators = m_arrayValidators.size(); + + // run over vouts: + while (ival < numValidators) { + + int32_t ivout = m_arrayValidators[ival].first; + if (ivout >= numVouts) { + std::cerr << "COutputValidationPlan::validate() incorrect tx" << "for ival=" << ival << " in tx.vout no such ivout=" << ivout << std::endl; + return eval->Invalid("incorrect tx structure: not all required vouts are present."); + } + else + { + // exec 'validators' from validator row of ival index, for tx.vout[ivout] + if (!execValidatorsInRow(&tx, ivout, ival, message)) { + std::ostringstream stream; + stream << "invalid tx vout[" << ivout << "]:" << message; + return eval->Invalid(stream.str().c_str()); // ... if not, return 'invalid' + } + } + ival++; // advance to the next vout + } + //std::cerr << "COutputValidationPlan::validate() returns with true" << std::endl; + return true; + } + private: - // Executes validators from the requested row of validators (selected by iValidators) for selected vin or vout (selected by iv) - bool execValidatorsInRow(const CTransaction* pTx, int32_t iv, int32_t ival, std::string& refMessage) const - { - // check boundaries: - if (ival < 0 || ival >= m_arrayValidators.size()) { - std::cerr << "COutputValidationPlan::execValidatorsInRow() internal error: incorrect param ival=" << ival << " size=" << m_arrayValidators.size(); - refMessage = "internal error: incorrect param ival index"; - return false; - } - - if (iv < 0 || iv >= pTx->vout.size()) { - std::cerr << "COutputValidationPlan::execValidatorsInRow() internal error: incorrect param iv=" << iv << " size=" << m_arrayValidators.size(); - refMessage = "internal error: incorrect param iv index"; - return false; - } - - // get requested row of validators: - ValidatorsRow vValidators = m_arrayValidators[ival].second; - - //std::cerr << "COutputValidationPlan::execRow() calling validators" << " for vout iv=" << iv << " ival=" << ival << std::endl; - - for (auto v : vValidators) { - - if (!v->isVinValidator()) { - // if this is a 'in' validation plan then pass the previous tx vout: - bool result = v->validateVout(pTx->vout[iv], refMessage); - if (!result) - return result; - } - } - return true; // validation OK - } - + // Executes validators from the requested row of validators (selected by iValidators) for selected vin or vout (selected by iv) + bool execValidatorsInRow(const CTransaction* pTx, int32_t iv, int32_t ival, std::string& refMessage) const + { + // check boundaries: + if (ival < 0 || ival >= m_arrayValidators.size()) { + std::cerr << "COutputValidationPlan::execValidatorsInRow() internal error: incorrect param ival=" << ival << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param ival index"; + return false; + } + + if (iv < 0 || iv >= pTx->vout.size()) { + std::cerr << "COutputValidationPlan::execValidatorsInRow() internal error: incorrect param iv=" << iv << " size=" << m_arrayValidators.size(); + refMessage = "internal error: incorrect param iv index"; + return false; + } + + // get requested row of validators: + ValidatorsRow vValidators = m_arrayValidators[ival].second; + + //std::cerr << "COutputValidationPlan::execRow() calling validators" << " for vout iv=" << iv << " ival=" << ival << std::endl; + + for (auto v : vValidators) { + + if (!v->isVinValidator()) { + // if this is a 'in' validation plan then pass the previous tx vout: + bool result = v->validateVout(pTx->vout[iv], refMessage); + if (!result) + return result; + } + } + return true; // validation OK + } + private: - //std::map m_mapValidators; - std::vector< std::pair > m_arrayValidators; - + //std::map m_mapValidators; + std::vector< std::pair > m_arrayValidators; + }; class CNormalInputIdentifier : CInputIdentifierBase { public: - CNormalInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} - virtual std::string inputName() const { return std::string("normal input"); } - virtual bool identifyInput(CTxIn vin) const { - return !IsCCInput(vin.scriptSig); - } + CNormalInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + virtual std::string inputName() const { return std::string("normal input"); } + virtual bool identifyInput(CTxIn vin) const { + return !IsCCInput(vin.scriptSig); + } }; class CCCInputIdentifier : CInputIdentifierBase { public: - CCCInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} - virtual std::string inputName() const { return std::string("CC input"); } - virtual bool identifyInput(CTxIn vin) const { - return IsCCInput(vin.scriptSig); - } + CCCInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + virtual std::string inputName() const { return std::string("CC input"); } + virtual bool identifyInput(CTxIn vin) const { + return IsCCInput(vin.scriptSig); + } }; /** -* Validates 1of2address for vout (may be used for either this or prev tx) -*/ + * Validates 1of2address for vout (may be used for either this or prev tx) + */ template class CCC1of2AddressValidator : CValidatorBase { public: - CCC1of2AddressValidator(CC_info* cp, CScript opRetScript, std::string customMessage = "") : - m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {} - - virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const - { - //std::cerr << "CCC1of2AddressValidator::validateVout() entered" << std::endl; - CPubKey ownerPubkey, heirPubkey; - int64_t inactivityTime; - std::string heirName; - uint256 tokenid; - - uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); - if (funcId == 0) { - message = m_customMessage + std::string(" invalid opreturn format"); - std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; - return false; - } - - char shouldBeAddr[65], ccAddr[65]; - - //GetCCaddress1of2(m_cp, shouldBeAddr, ownerPubkey, heirPubkey); - Helper::GetCoinsOrTokensCCaddress1of2(shouldBeAddr, ownerPubkey, heirPubkey); - - if (vout.scriptPubKey.IsPayToCryptoCondition()) { - if (Getscriptaddress(ccAddr, vout.scriptPubKey) && strcmp(shouldBeAddr, ccAddr) == 0) { - //std::cerr << "CCC1of2AddressValidator::validateVout() exits with true" << std::endl; - return true; - } - else { - message = m_customMessage + std::string(" incorrect heir funding address: incorrect pubkey(s)"); - } - } - else { - message = m_customMessage + std::string(" incorrect heir funding address: not a 1of2addr"); - } - - std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; - return false; - } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return false; } - + CCC1of2AddressValidator(CCcontract_info* cp, CScript opRetScript, std::string customMessage = "") : + m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {} + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "CCC1of2AddressValidator::validateVout() entered" << std::endl; + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTime; + std::string heirName; + uint256 tokenid; + + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + if (funcId == 0) { + message = m_customMessage + std::string(" invalid opreturn format"); + std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; + return false; + } + + char shouldBeAddr[65], ccAddr[65]; + + //GetCCaddress1of2(m_cp, shouldBeAddr, ownerPubkey, heirPubkey); + Helper::GetCoinsOrTokensCCaddress1of2(shouldBeAddr, ownerPubkey, heirPubkey); + + if (vout.scriptPubKey.IsPayToCryptoCondition()) { + if (Getscriptaddress(ccAddr, vout.scriptPubKey) && strcmp(shouldBeAddr, ccAddr) == 0) { + //std::cerr << "CCC1of2AddressValidator::validateVout() exits with true" << std::endl; + return true; + } + else { + message = m_customMessage + std::string(" incorrect heir funding address: incorrect pubkey(s)"); + } + } + else { + message = m_customMessage + std::string(" incorrect heir funding address: not a 1of2addr"); + } + + std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; + return false; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return false; } + private: - CScript m_fundingOpretScript; - std::string m_customMessage; + CScript m_fundingOpretScript; + std::string m_customMessage; }; /** -* Validates if this is vout to owner or heir from opret (funding or change) -*/ + * Validates if this is vout to owner or heir from opret (funding or change) + */ template class CMyPubkeyVoutValidator : CValidatorBase { public: - CMyPubkeyVoutValidator(CC_info* cp, CScript opRetScript, bool checkNormals) - : m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { } - - virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const - { - //std::cerr << "CMyPubkeyVoutValidator::validateVout() entered" << std::endl; - - CPubKey ownerPubkey, heirPubkey; - int64_t inactivityTime; - std::string heirName; - uint256 tokenid; - - ///std::cerr << "CMyPubkeyVoutValidator::validateVout() m_opRetScript=" << m_opRetScript.ToString() << std::endl; - - // get both pubkeys: - uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); - if (funcId == 0) { - message = std::string("invalid opreturn format"); - return false; - } - - CScript ownerScript; - CScript heirScript; - if (m_checkNormals) { //not used, incorrect check, too strict - ownerScript = CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; - heirScript = CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; - std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout(coin,owner)=" << CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << " makeUserVout(coin,heir)=" << CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey.ToString() << std::endl; - } - else { - ownerScript = Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; - heirScript = Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; - std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout(owner)=" << Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << " makeUserVout(heir)=" << Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey.ToString() << std::endl; - } - - // recreate scriptPubKey for owner and heir and compare it with that of the vout to check: - if (vout.scriptPubKey == ownerScript || vout.scriptPubKey == heirScript) { - // this is vout to owner or heir addr: - //std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with true" << std::endl; - return true; - } - - std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with false (not the owner's or heir's addresses)" << std::endl; - message = std::string("invalid pubkey"); - return false; - } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } - + CMyPubkeyVoutValidator(CCcontract_info* cp, CScript opRetScript, bool checkNormals) + : m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { } + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "CMyPubkeyVoutValidator::validateVout() entered" << std::endl; + + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTime; + std::string heirName; + uint256 tokenid; + + ///std::cerr << "CMyPubkeyVoutValidator::validateVout() m_opRetScript=" << m_opRetScript.ToString() << std::endl; + + // get both pubkeys: + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + if (funcId == 0) { + message = std::string("invalid opreturn format"); + return false; + } + + CScript ownerScript; + CScript heirScript; + if (m_checkNormals) { //not used, incorrect check, too strict + ownerScript = CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; + heirScript = CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; + std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout(coin,owner)=" << CoinHelper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << " makeUserVout(coin,heir)=" << CoinHelper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey.ToString() << std::endl; + } + else { + ownerScript = Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey; + heirScript = Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey; + std::cerr << "CMyPubkeyVoutValidator::validateVout() vout.scriptPubKey=" << vout.scriptPubKey.ToString() << " makeUserVout(owner)=" << Helper::makeUserVout(vout.nValue, ownerPubkey).scriptPubKey.ToString() << " makeUserVout(heir)=" << Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey.ToString() << std::endl; + } + + // recreate scriptPubKey for owner and heir and compare it with that of the vout to check: + if (vout.scriptPubKey == ownerScript || vout.scriptPubKey == heirScript) { + // this is vout to owner or heir addr: + //std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with true" << std::endl; + return true; + } + + std::cerr << "CMyPubkeyVoutValidator::validateVout() exits with false (not the owner's or heir's addresses)" << std::endl; + message = std::string("invalid pubkey"); + return false; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + private: - CScript m_fundingOpretScript; - //uint256 m_lasttxid; - bool m_checkNormals; + CScript m_fundingOpretScript; + //uint256 m_lasttxid; + bool m_checkNormals; }; /** -* Check if the user is the heir and the heir is allowed to spend (duration > inactivityTime) -*/ + * Check if the user is the heir and the heir is allowed to spend (duration > inactivityTime) + */ template class CHeirSpendValidator : CValidatorBase { public: - CHeirSpendValidator(CC_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) - : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} - - virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const - { - //std::cerr << "CHeirSpendValidator::validateVout() entered" << std::endl; - - CPubKey ownerPubkey, heirPubkey; - int64_t inactivityTime; - std::string heirName; - uint256 tokenid; - - // get heir pubkey: - uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); - if (funcId == 0) { - message = std::string("invalid opreturn format"); - return false; - } - - int32_t numblocks; - int64_t durationSec = CCduration(numblocks, m_latesttxid); - - // recreate scriptPubKey for heir and compare it with that of the vout: - if (vout.scriptPubKey == Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey) { - // this is the heir is trying to spend - if (!m_isHeirSpendingBegan && durationSec <= inactivityTime) { - message = "heir is not allowed yet to spend funds"; - std::cerr << "CHeirSpendValidator::validateVout() heir is not allowed yet to spend funds" << std::endl; - return false; - } - else { - // heir is allowed to spend - return true; - } - } - - //std::cerr << "CHeirSpendValidator::validateVout() exits with true" << std::endl; - - // this is not heir: - return true; - } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } - + CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) + : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "CHeirSpendValidator::validateVout() entered" << std::endl; + + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTime; + std::string heirName; + uint256 tokenid; + + // get heir pubkey: + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + if (funcId == 0) { + message = std::string("invalid opreturn format"); + return false; + } + + int32_t numblocks; + int64_t durationSec = CCduration(numblocks, m_latesttxid); + + // recreate scriptPubKey for heir and compare it with that of the vout: + if (vout.scriptPubKey == Helper::makeUserVout(vout.nValue, heirPubkey).scriptPubKey) { + // this is the heir is trying to spend + if (!m_isHeirSpendingBegan && durationSec <= inactivityTime) { + message = "heir is not allowed yet to spend funds"; + std::cerr << "CHeirSpendValidator::validateVout() heir is not allowed yet to spend funds" << std::endl; + return false; + } + else { + // heir is allowed to spend + return true; + } + } + + //std::cerr << "CHeirSpendValidator::validateVout() exits with true" << std::endl; + + // this is not heir: + return true; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + private: - CScript m_fundingOpretScript; - uint256 m_latesttxid; - uint8_t m_isHeirSpendingBegan; + CScript m_fundingOpretScript; + uint256 m_latesttxid; + uint8_t m_isHeirSpendingBegan; }; /** -* Validates this opreturn and compares it with the opreturn from the previous tx -*/ + * Validates this opreturn and compares it with the opreturn from the previous tx + */ template class COpRetValidator : CValidatorBase { public: - COpRetValidator(CC_info* cp, CScript opret) - : m_fundingOpretScript(opret), CValidatorBase(cp) {} - - virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const - { - //std::cerr << "COpRetValidator::validateVout() entered" << std::endl; - - uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; - uint8_t dummyIsHeirSpendingBegan; - - uint8_t funcId = DecodeHeirEitherOpRet(vout.scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); - if (funcId == 0) { - message = std::string("invalid opreturn format"); - return false; - } - - uint8_t initialFuncId = DecodeHeirEitherOpRet(m_fundingOpretScript, initialTokenid, dummyTxid, dummyIsHeirSpendingBegan, true); - if (initialFuncId == 0) { - message = std::string("invalid initial tx opreturn format"); - return false; - } - - // validation rules: - if (!isMyFuncId(funcId)) { - message = std::string("invalid funcid in opret"); - return false; - } - - if (typeid(Helper) == typeid(TokenHelper)) { - if (tokenid != initialTokenid) { - message = std::string("invalid tokenid in opret"); - return false; - } - } - - //std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; - return true; - } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } - + COpRetValidator(CCcontract_info* cp, CScript opret) + : m_fundingOpretScript(opret), CValidatorBase(cp) {} + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const + { + //std::cerr << "COpRetValidator::validateVout() entered" << std::endl; + + uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; + uint8_t dummyIsHeirSpendingBegan; + + uint8_t funcId = DecodeHeirEitherOpRet(vout.scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + if (funcId == 0) { + message = std::string("invalid opreturn format"); + return false; + } + + uint8_t initialFuncId = DecodeHeirEitherOpRet(m_fundingOpretScript, initialTokenid, dummyTxid, dummyIsHeirSpendingBegan, true); + if (initialFuncId == 0) { + message = std::string("invalid initial tx opreturn format"); + return false; + } + + // validation rules: + if (!isMyFuncId(funcId)) { + message = std::string("invalid funcid in opret"); + return false; + } + + if (typeid(Helper) == typeid(TokenHelper)) { + if (tokenid != initialTokenid) { + message = std::string("invalid tokenid in opret"); + return false; + } + } + + //std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; + return true; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + private: - CScript m_fundingOpretScript; + CScript m_fundingOpretScript; }; /** -* empty validator always returns true -*/ + * empty validator always returns true + */ template class CNullValidator : CValidatorBase { public: - CNullValidator(CC_info* cp) - : CValidatorBase(cp) { } - - virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const { return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + CNullValidator(CCcontract_info* cp) + : CValidatorBase(cp) { } + + virtual bool isVinValidator() const { return false; } + virtual bool validateVout(CTxOut vout, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } }; diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 641d0a4d2..f7f663db2 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -45,14 +45,14 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, key = *pprivKey; else if (!keystore || !keystore->GetKey(address, key)) return false; - + uint256 hash; try { hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, consensusBranchId); } catch (logic_error ex) { return false; } - + if (scriptCode.IsPayToCryptoCondition()) { CC *cc = (CC *)extraData; @@ -75,9 +75,9 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, return false; } } - + vchSig.push_back((unsigned char)nHashType); - + return true; } @@ -128,7 +128,7 @@ std::vector &GetCryptoConditions() static bool initialized = false; static std::vector vCC = std::vector(); CCcontract_info C; - + if (!initialized) { // this should initialize any desired auto-signed crypto-conditions @@ -140,7 +140,7 @@ bool GetCCByUnspendableAddress(struct CC_info *cp, char *addrstr) { std::vector &vCC = GetCryptoConditions(); bool found = false; - + for (int i = 0; i < vCC.size(); i++) { if (strcmp(addrstr, vCC[i].unspendableCCaddr) == 0) @@ -157,7 +157,7 @@ bool CCinitLite(struct CC_info *cp, uint8_t evalcode) { std::vector &vCC = GetCryptoConditions(); bool found = false; - + for (int i = 0; i < vCC.size(); i++) { if (vCC[i].evalcode == evalcode) @@ -172,7 +172,7 @@ bool CCinitLite(struct CC_info *cp, uint8_t evalcode) bool _Getscriptaddress(char *destaddr, const CScript &scriptPubKey) { - CTxDestination address; + CTxDestination address; txnouttype whichType; std::vector> vvch = std::vector>(); if (Solver(scriptPubKey, whichType, vvch) && vvch[0].size() == 20) @@ -199,10 +199,10 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip vector vPK; vector vParams = vector(); COptCCParams p; - + // get information to sign with CCcontract_info C; - + scriptPubKey.IsPayToCryptoCondition(&subScript, vParams); if (vParams.empty()) { @@ -219,12 +219,12 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip { p = COptCCParams(vParams[0]); } - + if (p.IsValid() && p.vKeys.size() >= p.n) { bool is1of2 = (p.m == 1 && p.n == 2); CKey privKey; - + // must be a valid cc eval code if (CCinitLite(&C, p.evalCode)) { @@ -232,7 +232,7 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip if (!is1of2) { bool havePriv = creator.KeyStore().GetKey(p.vKeys[0].GetID(), privKey); - + // if we don't have the private key, it must be the unspendable address if (!havePriv && (p.vKeys[0] == CPubKey(ParseHex(C.CChexstr)))) { @@ -240,9 +240,9 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip std::vector vch(&(C.CCpriv[0]), C.CCpriv + sizeof(C.CCpriv)); privKey.Set(vch.begin(), vch.end(), false); } - + CC *cc = CCcond1(p.evalCode, p.vKeys[0]); - + if (cc) { vector vch; @@ -254,7 +254,7 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip { fprintf(stderr,"vin has 1of1 CC signing error with address.(%s)\n", p.vKeys[0].GetID().ToString().c_str()); } - + cc_free(cc); return ret.size() != 0; } @@ -266,7 +266,7 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip { if (creator.IsKeystoreValid() && creator.KeyStore().GetKey(pk.GetID(), privKey) && privKey.IsValid()) break; - + if (pk == CPubKey(ParseHex(C.CChexstr))) { privKey = CKey(); @@ -275,12 +275,12 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip break; } } - + if (!privKey.IsValid()) return false; - + CC *cc = CCcond1of2(p.evalCode, p.vKeys[0], p.vKeys[1]); - + if (cc) { vector vch; @@ -292,7 +292,7 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip { fprintf(stderr,"vin has 1of2 CC signing error with addresses.(%s)\n(%s)\n", p.vKeys[0].GetID().ToString().c_str(), p.vKeys[1].GetID().ToString().c_str()); } - + cc_free(cc); return ret.size() != 0; } @@ -314,9 +314,9 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP CScript scriptRet; uint160 h160; ret.clear(); - + vector vSolutions; - + if (!Solver(scriptPubKey, whichTypeRet, vSolutions)) { // if this is a CLTV script, solve for the destination after CLTV @@ -324,10 +324,10 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP { uint8_t pushOp = scriptPubKey[0]; uint32_t scriptStart = pushOp + 3; - + // check post CLTV script CScript postfix = CScript(scriptPubKey.size() > scriptStart ? scriptPubKey.begin() + scriptStart : scriptPubKey.end(), scriptPubKey.end()); - + // check again with only postfix subscript if (!Solver(postfix, whichTypeRet, vSolutions)) return false; @@ -335,44 +335,44 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP else return false; } - + CKeyID keyID; - + switch (whichTypeRet) { - case TX_NONSTANDARD: - case TX_NULL_DATA: - return false; - case TX_PUBKEY: - keyID = CPubKey(vSolutions[0]).GetID(); - return Sign1(keyID, creator, scriptPubKey, ret, consensusBranchId); - case TX_PUBKEYHASH: - keyID = CKeyID(uint160(vSolutions[0])); - if (!Sign1(keyID, creator, scriptPubKey, ret, consensusBranchId)) + case TX_NONSTANDARD: + case TX_NULL_DATA: return false; - else - { - CPubKey vch; - creator.KeyStore().GetPubKey(keyID, vch); - ret.push_back(ToByteVector(vch)); - } - return true; - case TX_SCRIPTHASH: - if (creator.KeyStore().GetCScript(uint160(vSolutions[0]), scriptRet)) { - ret.push_back(std::vector(scriptRet.begin(), scriptRet.end())); + case TX_PUBKEY: + keyID = CPubKey(vSolutions[0]).GetID(); + return Sign1(keyID, creator, scriptPubKey, ret, consensusBranchId); + case TX_PUBKEYHASH: + keyID = CKeyID(uint160(vSolutions[0])); + if (!Sign1(keyID, creator, scriptPubKey, ret, consensusBranchId)) + return false; + else + { + CPubKey vch; + creator.KeyStore().GetPubKey(keyID, vch); + ret.push_back(ToByteVector(vch)); + } return true; - } - return false; - - case TX_CRYPTOCONDITION: - return SignStepCC(creator, scriptPubKey, vSolutions, ret, consensusBranchId); - - case TX_MULTISIG: - ret.push_back(valtype()); // workaround CHECKMULTISIG bug - return (SignN(vSolutions, creator, scriptPubKey, ret, consensusBranchId)); - - default: - return false; + case TX_SCRIPTHASH: + if (creator.KeyStore().GetCScript(uint160(vSolutions[0]), scriptRet)) { + ret.push_back(std::vector(scriptRet.begin(), scriptRet.end())); + return true; + } + return false; + + case TX_CRYPTOCONDITION: + return SignStepCC(creator, scriptPubKey, vSolutions, ret, consensusBranchId); + + case TX_MULTISIG: + ret.push_back(valtype()); // workaround CHECKMULTISIG bug + return (SignN(vSolutions, creator, scriptPubKey, ret, consensusBranchId)); + + default: + return false; } } @@ -399,7 +399,7 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu txnouttype whichType; solved = SignStep(creator, script, result, whichType, consensusBranchId); CScript subscript; - + if (solved && whichType == TX_SCRIPTHASH) { // Solver returns the subscript that needs to be evaluated; @@ -409,9 +409,9 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu solved = solved && SignStep(creator, script, result, whichType, consensusBranchId) && whichType != TX_SCRIPTHASH; result.push_back(std::vector(subscript.begin(), subscript.end())); } - + sigdata.scriptSig = PushAll(result); - + // Test solution return solved && VerifyScript(sigdata.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker(), consensusBranchId); } @@ -431,19 +431,19 @@ void UpdateTransaction(CMutableTransaction& tx, unsigned int nIn, const Signatur } bool SignSignature( - const CKeyStore &keystore, - const CScript& fromPubKey, - CMutableTransaction& txTo, - unsigned int nIn, - const CAmount& amount, - int nHashType, - uint32_t consensusBranchId) + const CKeyStore &keystore, + const CScript& fromPubKey, + CMutableTransaction& txTo, + unsigned int nIn, + const CAmount& amount, + int nHashType, + uint32_t consensusBranchId) { assert(nIn < txTo.vin.size()); - + CTransaction txToConst(txTo); TransactionSignatureCreator creator(&keystore, &txToConst, nIn, amount, nHashType); - + SignatureData sigdata; bool ret = ProduceSignature(creator, fromPubKey, sigdata, consensusBranchId); UpdateTransaction(txTo, nIn, sigdata); @@ -451,24 +451,24 @@ bool SignSignature( } bool SignSignature( - const CKeyStore &keystore, - const CTransaction& txFrom, - CMutableTransaction& txTo, - unsigned int nIn, - int nHashType, - uint32_t consensusBranchId) + const CKeyStore &keystore, + const CTransaction& txFrom, + CMutableTransaction& txTo, + unsigned int nIn, + int nHashType, + uint32_t consensusBranchId) { assert(nIn < txTo.vin.size()); CTxIn& txin = txTo.vin[nIn]; assert(txin.prevout.n < txFrom.vout.size()); const CTxOut& txout = txFrom.vout[txin.prevout.n]; - + return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, txout.nValue, nHashType, consensusBranchId); } static vector CombineMultisig(const CScript& scriptPubKey, const BaseSignatureChecker& checker, - const vector& vSolutions, - const vector& sigs1, const vector& sigs2, uint32_t consensusBranchId) + const vector& vSolutions, + const vector& sigs1, const vector& sigs2, uint32_t consensusBranchId) { // Combine all the signatures we've got: set allsigs; @@ -482,7 +482,7 @@ static vector CombineMultisig(const CScript& scriptPubKey, const BaseSi if (!v.empty()) allsigs.insert(v); } - + // Build a map of pubkey -> signature by matching sigs to pubkeys: assert(vSolutions.size() > 1); unsigned int nSigsRequired = vSolutions.front()[0]; @@ -495,7 +495,7 @@ static vector CombineMultisig(const CScript& scriptPubKey, const BaseSi const valtype& pubkey = vSolutions[i+1]; if (sigs.count(pubkey)) continue; // Already got a sig for this pubkey - + if (checker.CheckSig(sig, pubkey, scriptPubKey, consensusBranchId)) { sigs[pubkey] = sig; @@ -517,108 +517,108 @@ static vector CombineMultisig(const CScript& scriptPubKey, const BaseSi // Fill any missing with OP_0: for (unsigned int i = nSigsHave; i < nSigsRequired; i++) result.push_back(valtype()); - + return result; } namespace { -struct Stacks -{ - std::vector script; - - Stacks() {} - explicit Stacks(const std::vector& scriptSigStack_) : script(scriptSigStack_) {} - explicit Stacks(const SignatureData& data, uint32_t consensusBranchId) { - EvalScript(script, data.scriptSig, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), consensusBranchId); - } - - SignatureData Output() const { - SignatureData result; - result.scriptSig = PushAll(script); - return result; - } -}; + struct Stacks + { + std::vector script; + + Stacks() {} + explicit Stacks(const std::vector& scriptSigStack_) : script(scriptSigStack_) {} + explicit Stacks(const SignatureData& data, uint32_t consensusBranchId) { + EvalScript(script, data.scriptSig, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), consensusBranchId); + } + + SignatureData Output() const { + SignatureData result; + result.scriptSig = PushAll(script); + return result; + } + }; } static Stacks CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecker& checker, - const txnouttype txType, const vector& vSolutions, - Stacks sigs1, Stacks sigs2, uint32_t consensusBranchId) + const txnouttype txType, const vector& vSolutions, + Stacks sigs1, Stacks sigs2, uint32_t consensusBranchId) { switch (txType) { - case TX_NONSTANDARD: - case TX_NULL_DATA: - // Don't know anything about this, assume bigger one is correct: - if (sigs1.script.size() >= sigs2.script.size()) - return sigs1; - return sigs2; - case TX_PUBKEY: - case TX_PUBKEYHASH: - case TX_CRYPTOCONDITION: - // Signatures are bigger than placeholders or empty scripts: - if (sigs1.script.empty() || sigs1.script[0].empty()) + case TX_NONSTANDARD: + case TX_NULL_DATA: + // Don't know anything about this, assume bigger one is correct: + if (sigs1.script.size() >= sigs2.script.size()) + return sigs1; return sigs2; - return sigs1; - case TX_SCRIPTHASH: - if (sigs1.script.empty() || sigs1.script.back().empty()) - return sigs2; - else if (sigs2.script.empty() || sigs2.script.back().empty()) + case TX_PUBKEY: + case TX_PUBKEYHASH: + case TX_CRYPTOCONDITION: + // Signatures are bigger than placeholders or empty scripts: + if (sigs1.script.empty() || sigs1.script[0].empty()) + return sigs2; return sigs1; - else - { - // Recur to combine: - valtype spk = sigs1.script.back(); - CScript pubKey2(spk.begin(), spk.end()); - - txnouttype txType2; - vector > vSolutions2; - Solver(pubKey2, txType2, vSolutions2); - sigs1.script.pop_back(); - sigs2.script.pop_back(); - Stacks result = CombineSignatures(pubKey2, checker, txType2, vSolutions2, sigs1, sigs2, consensusBranchId); - result.script.push_back(spk); - return result; - } - case TX_MULTISIG: - return Stacks(CombineMultisig(scriptPubKey, checker, vSolutions, sigs1.script, sigs2.script, consensusBranchId)); - default: - return Stacks(); + case TX_SCRIPTHASH: + if (sigs1.script.empty() || sigs1.script.back().empty()) + return sigs2; + else if (sigs2.script.empty() || sigs2.script.back().empty()) + return sigs1; + else + { + // Recur to combine: + valtype spk = sigs1.script.back(); + CScript pubKey2(spk.begin(), spk.end()); + + txnouttype txType2; + vector > vSolutions2; + Solver(pubKey2, txType2, vSolutions2); + sigs1.script.pop_back(); + sigs2.script.pop_back(); + Stacks result = CombineSignatures(pubKey2, checker, txType2, vSolutions2, sigs1, sigs2, consensusBranchId); + result.script.push_back(spk); + return result; + } + case TX_MULTISIG: + return Stacks(CombineMultisig(scriptPubKey, checker, vSolutions, sigs1.script, sigs2.script, consensusBranchId)); + default: + return Stacks(); } } SignatureData CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecker& checker, - const SignatureData& scriptSig1, const SignatureData& scriptSig2, - uint32_t consensusBranchId) + const SignatureData& scriptSig1, const SignatureData& scriptSig2, + uint32_t consensusBranchId) { txnouttype txType; vector > vSolutions; Solver(scriptPubKey, txType, vSolutions); - + return CombineSignatures( - scriptPubKey, checker, txType, vSolutions, - Stacks(scriptSig1, consensusBranchId), - Stacks(scriptSig2, consensusBranchId), - consensusBranchId).Output(); + scriptPubKey, checker, txType, vSolutions, + Stacks(scriptSig1, consensusBranchId), + Stacks(scriptSig2, consensusBranchId), + consensusBranchId).Output(); } namespace { -/** Dummy signature checker which accepts all signatures. */ -class DummySignatureChecker : public BaseSignatureChecker -{ -public: - DummySignatureChecker() {} - - bool CheckSig( - const std::vector& scriptSig, - const std::vector& vchPubKey, - const CScript& scriptCode, - uint32_t consensusBranchId) const + /** Dummy signature checker which accepts all signatures. */ + class DummySignatureChecker : public BaseSignatureChecker { - return true; - } -}; -const DummySignatureChecker dummyChecker; + public: + DummySignatureChecker() {} + + bool CheckSig( + const std::vector& scriptSig, + const std::vector& vchPubKey, + const CScript& scriptCode, + uint32_t consensusBranchId) const + { + return true; + } + }; + const DummySignatureChecker dummyChecker; } const BaseSignatureChecker& DummySignatureCreator::Checker() const @@ -627,12 +627,12 @@ const BaseSignatureChecker& DummySignatureCreator::Checker() const } bool DummySignatureCreator::CreateSig( - std::vector& vchSig, - const CKeyID& keyid, - const CScript& scriptCode, - uint32_t consensusBranchId, - CKey *key, - void *extraData) const + std::vector& vchSig, + const CKeyID& keyid, + const CScript& scriptCode, + uint32_t consensusBranchId, + CKey *key, + void *extraData) const { // Create a dummy signature that is a valid DER-encoding vchSig.assign(72, '\000'); @@ -647,3 +647,4 @@ bool DummySignatureCreator::CreateSig( vchSig[6 + 33 + 32] = SIGHASH_ALL; return true; } + From 4ad5879f56900e1fe9de6b26c60a11e2892d8da2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:13:59 -1100 Subject: [PATCH 1338/3904] struct CC_info --- src/cc/heir.cpp | 1611 ++++++++++++++++++++++++----------------------- 1 file changed, 806 insertions(+), 805 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 499fb598d..7867032b6 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -21,14 +21,14 @@ class TokenHelper; /* The idea of Heir CC is to allow crypto inheritance. - A special 1of2 CC address is created that is freely spendable by the creator (funds owner). + A special 1of2 CC address is created that is freely spendable by the creator (funds owner). The owner may add additional funds to this 1of2 address. - The heir is only allowed to spend after "the specified amount of idle blocks" (changed to "the owner inactivityTime"). - The idea is that if the address doesnt spend any funds for a year (or whatever amount set), then it is time to allow the heir to spend. + The heir is only allowed to spend after "the specified amount of idle blocks" (changed to "the owner inactivityTime"). + The idea is that if the address doesnt spend any funds for a year (or whatever amount set), then it is time to allow the heir to spend. "The design requires the heir to spend all the funds at once" (this requirement was changed to "after the inactivity time both the heir and owner may freely spend available funds") After the first heir spending a flag is set that spending is allowed for the heir whether the owner adds more funds or spends them. This Heir contract supports both coins and tokens. -*/ + */ // tx validation code @@ -36,69 +36,69 @@ class TokenHelper; // (sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation()...) template bool RunValidationPlans(uint8_t funcId, struct CC_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun) { - int32_t numvins = tx.vin.size(); - int32_t numvouts = tx.vout.size(); - - // setup validation framework (please see its description in heir_validate.h): - // validation 'plans': - CInputValidationPlan vinPlan; - COutputValidationPlan voutPlan; - - // vin 'identifiers' - CNormalInputIdentifier normalInputIdentifier(cp); - CCCInputIdentifier ccInputIdentifier(cp); - - // vin and vout 'validators' - // not used, too strict for 2 pubkeys: CMyPubkeyVoutValidator normalInputValidator(cp, fundingOpretScript, true); // check normal input for this opret cause this is first tx - CCC1of2AddressValidator cc1of2ValidatorThis(cp, fundingOpretScript, "checking this tx opreturn:"); // 1of2add validator with pubkeys from this tx opreturn - CHeirSpendValidator heirSpendValidator(cp, fundingOpretScript, latestTxid, hasHeirSpendingBegun); // check if heir allowed to spend - - // only for tokens: - CMyPubkeyVoutValidator ownerCCaddrValidator(cp, fundingOpretScript, false); // check if this correct owner's cc user addr corresponding to opret - COpRetValidator opRetValidator(cp, fundingOpretScript); // compare opRets in this and last tx - CNullValidator nullValidator(cp); - - switch (funcId) { - case 'F': // fund tokens - // vin validation plan: - vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr - - // vout validation plan: - voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding - // do not check change at this time - // no checking for opret yet - break; - - case 'A': // add tokens - // vin validation plan: - vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr - - // vout validation plan: - voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding - // do not check change at this time - voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A: - break; - - case 'C': - // vin validation plan: - vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &cc1of2ValidatorThis); // cc1of2 funding addr - - // vout validation plan: - voutPlan.pushValidators(0, &heirSpendValidator); // check if heir is allowed to spend - voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A - break; - } - - // call vin/vout validation - if (!vinPlan.validate(tx, eval)) - return false; - if (!voutPlan.validate(tx, eval)) - return false; - - return true; + int32_t numvins = tx.vin.size(); + int32_t numvouts = tx.vout.size(); + + // setup validation framework (please see its description in heir_validate.h): + // validation 'plans': + CInputValidationPlan vinPlan; + COutputValidationPlan voutPlan; + + // vin 'identifiers' + CNormalInputIdentifier normalInputIdentifier(cp); + CCCInputIdentifier ccInputIdentifier(cp); + + // vin and vout 'validators' + // not used, too strict for 2 pubkeys: CMyPubkeyVoutValidator normalInputValidator(cp, fundingOpretScript, true); // check normal input for this opret cause this is first tx + CCC1of2AddressValidator cc1of2ValidatorThis(cp, fundingOpretScript, "checking this tx opreturn:"); // 1of2add validator with pubkeys from this tx opreturn + CHeirSpendValidator heirSpendValidator(cp, fundingOpretScript, latestTxid, hasHeirSpendingBegun); // check if heir allowed to spend + + // only for tokens: + CMyPubkeyVoutValidator ownerCCaddrValidator(cp, fundingOpretScript, false); // check if this correct owner's cc user addr corresponding to opret + COpRetValidator opRetValidator(cp, fundingOpretScript); // compare opRets in this and last tx + CNullValidator nullValidator(cp); + + switch (funcId) { + case 'F': // fund tokens + // vin validation plan: + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + + // vout validation plan: + voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding + // do not check change at this time + // no checking for opret yet + break; + + case 'A': // add tokens + // vin validation plan: + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + + // vout validation plan: + voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding + // do not check change at this time + voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A: + break; + + case 'C': + // vin validation plan: + vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &cc1of2ValidatorThis); // cc1of2 funding addr + + // vout validation plan: + voutPlan.pushValidators(0, &heirSpendValidator); // check if heir is allowed to spend + voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A + break; + } + + // call vin/vout validation + if (!vinPlan.validate(tx, eval)) + return false; + if (!voutPlan.validate(tx, eval)) + return false; + + return true; } /** @@ -110,121 +110,121 @@ bool HeirValidate(struct CC_info* cpHeir, Eval* eval, const CTransaction& tx, ui int32_t numvouts = tx.vout.size(); //int32_t preventCCvins = -1; //int32_t preventCCvouts = -1; - - struct CC_info *cpTokens, tokensC; - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - + + struct CC_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + if (numvouts < 1) return eval->Invalid("no vouts"); - - //if (chainActive.Height() < 741) - // return true; - + + //if (chainActive.Height() < 741) + // return true; + uint256 fundingTxidInOpret = zeroid, latestTxid = zeroid, dummyTokenid, tokenidThis, tokenid = zeroid; - CScript fundingTxOpRetScript; - uint8_t hasHeirSpendingBegun = 0, hasHeirSpendingBegunDummy; - - CScript opret = (tx.vout.size() > 0) ? tx.vout[tx.vout.size() - 1].scriptPubKey : CScript(); // check boundary - uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenidThis, fundingTxidInOpret, hasHeirSpendingBegunDummy, true); - if (funcId == 0) + CScript fundingTxOpRetScript; + uint8_t hasHeirSpendingBegun = 0, hasHeirSpendingBegunDummy; + + CScript opret = (tx.vout.size() > 0) ? tx.vout[tx.vout.size() - 1].scriptPubKey : CScript(); // check boundary + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenidThis, fundingTxidInOpret, hasHeirSpendingBegunDummy, true); + if (funcId == 0) return eval->Invalid("invalid opreturn format"); - + if (funcId != 'F') { if (fundingTxidInOpret == zeroid) { return eval->Invalid("incorrect tx opreturn: no fundingtxid present"); } - latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, hasHeirSpendingBegun); - - if( tokenid != zeroid && tokenid != tokenidThis ) - return eval->Invalid("incorrect tx tokenid"); - - if (latestTxid == zeroid) { + latestTxid = FindLatestFundingTx(fundingTxidInOpret, tokenid, fundingTxOpRetScript, hasHeirSpendingBegun); + + if( tokenid != zeroid && tokenid != tokenidThis ) + return eval->Invalid("incorrect tx tokenid"); + + if (latestTxid == zeroid) { return eval->Invalid("no fundingtx found"); } - } - else { - fundingTxOpRetScript = opret; - } - - std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << (int)cpHeir->evalcode << std::endl; - - //////////////// temp //////////////////////// - ///return true; - + } + else { + fundingTxOpRetScript = opret; + } + + std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << (int)cpHeir->evalcode << std::endl; + + //////////////// temp //////////////////////// + ///return true; + switch (funcId) { - case 'F': - // fund coins: - // vins.*: normal inputs - // ----------------------------- - // vout.0: funding CC 1of2 addr for the owner and heir - // vout.1: txfee for CC addr used as a marker - // vout.2: normal change - // vout.n-1: opreturn 'F' ownerpk heirpk inactivitytime heirname - - // fund tokens: - // vin.0: normal inputs txfee - // vins.1+: user's CC addr inputs - // ----------------------- - // vout.0: funding heir CC 1of2 addr for the owner and heir - // vout.1: txfee for CC addr used as a marker - // vout.2: normal change - // vout.n-1: opreturn 't' tokenid 'F' ownerpk heirpk inactivitytime heirname tokenid - if (tokenid != zeroid) - return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); - else - return eval->Invalid("unexpected HeirValidate for heirfund"); - // break; - - case 'A': - // add funding coins: - // vins.*: normal inputs - // ------------------------ - // vout.0: funding CC 1of2 addr for the owner and heir - // vout.1: normal change - // vout.n-1: opreturn 'A' ownerpk heirpk inactivitytime fundingtx - - // add funding tokens: - // vins.0: normal inputs txfee - // vins.1+: user's CC addr inputs - // ------------------------ - // vout.0: funding CC 1of2 addr for the owner and heir - // vout.1: normal change - // vout.n-1: opreturn 't' tokenid 'A' ownerpk heirpk inactivitytime fundingtx - if (tokenid != zeroid) - return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); - else - return eval->Invalid("unexpected HeirValidate for heiradd"); - //break; - - case 'C': - // claim coins: - // vin.0: normal input txfee - // vin.1+: input from CC 1of2 addr - // ------------------------------------- - // vout.0: normal output to owner or heir address - // vout.1: change to CC 1of2 addr - // vout.2: change to user's addr from txfee input if any - // vout.n-1: opreturn 'C' ownerpk heirpk inactivitytime fundingtx - - // claim tokens: - // vin.0: normal input txfee - // vin.1+: input from CC 1of2 addr - // -------------------------------------------- - // vout.0: output to user's cc address - // vout.1: change to CC 1of2 addr - // vout.2: change to normal from txfee input if any - // vout.n-1: opreturn 't' tokenid 'C' ownerpk heirpk inactivitytime fundingtx - if (tokenid != zeroid) - return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); - else - return RunValidationPlans(funcId, cpHeir, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); - // break; - - default: - std::cerr << "HeirValidate() illegal heir funcid=" << (char)funcId << std::endl; - return eval->Invalid("unexpected HeirValidate funcid"); - // break; + case 'F': + // fund coins: + // vins.*: normal inputs + // ----------------------------- + // vout.0: funding CC 1of2 addr for the owner and heir + // vout.1: txfee for CC addr used as a marker + // vout.2: normal change + // vout.n-1: opreturn 'F' ownerpk heirpk inactivitytime heirname + + // fund tokens: + // vin.0: normal inputs txfee + // vins.1+: user's CC addr inputs + // ----------------------- + // vout.0: funding heir CC 1of2 addr for the owner and heir + // vout.1: txfee for CC addr used as a marker + // vout.2: normal change + // vout.n-1: opreturn 't' tokenid 'F' ownerpk heirpk inactivitytime heirname tokenid + if (tokenid != zeroid) + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); + else + return eval->Invalid("unexpected HeirValidate for heirfund"); + // break; + + case 'A': + // add funding coins: + // vins.*: normal inputs + // ------------------------ + // vout.0: funding CC 1of2 addr for the owner and heir + // vout.1: normal change + // vout.n-1: opreturn 'A' ownerpk heirpk inactivitytime fundingtx + + // add funding tokens: + // vins.0: normal inputs txfee + // vins.1+: user's CC addr inputs + // ------------------------ + // vout.0: funding CC 1of2 addr for the owner and heir + // vout.1: normal change + // vout.n-1: opreturn 't' tokenid 'A' ownerpk heirpk inactivitytime fundingtx + if (tokenid != zeroid) + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); + else + return eval->Invalid("unexpected HeirValidate for heiradd"); + //break; + + case 'C': + // claim coins: + // vin.0: normal input txfee + // vin.1+: input from CC 1of2 addr + // ------------------------------------- + // vout.0: normal output to owner or heir address + // vout.1: change to CC 1of2 addr + // vout.2: change to user's addr from txfee input if any + // vout.n-1: opreturn 'C' ownerpk heirpk inactivitytime fundingtx + + // claim tokens: + // vin.0: normal input txfee + // vin.1+: input from CC 1of2 addr + // -------------------------------------------- + // vout.0: output to user's cc address + // vout.1: change to CC 1of2 addr + // vout.2: change to normal from txfee input if any + // vout.n-1: opreturn 't' tokenid 'C' ownerpk heirpk inactivitytime fundingtx + if (tokenid != zeroid) + return RunValidationPlans(funcId, cpTokens, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); + else + return RunValidationPlans(funcId, cpHeir, eval, tx, latestTxid, fundingTxOpRetScript, hasHeirSpendingBegun); + // break; + + default: + std::cerr << "HeirValidate() illegal heir funcid=" << (char)funcId << std::endl; + return eval->Invalid("unexpected HeirValidate funcid"); + // break; } return eval->Invalid("unexpected"); // (PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts)); } @@ -234,194 +234,194 @@ bool HeirValidate(struct CC_info* cpHeir, Eval* eval, const CTransaction& tx, ui // helper functions used in implementations of rpc calls (in rpcwallet.cpp) or validation code /** -* Checks if vout is to cryptocondition address -* @return vout value in satoshis -*/ + * Checks if vout is to cryptocondition address + * @return vout value in satoshis + */ template int64_t IsHeirFundingVout(struct CC_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) { - char destaddr[65], heirFundingAddr[65]; - - Helper::GetCoinsOrTokensCCaddress1of2(cp, heirFundingAddr, ownerPubkey, heirPubkey); - if (tx.vout[voutIndex].scriptPubKey.IsPayToCryptoCondition() != 0) { - // NOTE: dimxy it was unsafe 'Getscriptaddress(destaddr,tx.vout[voutIndex].scriptPubKey) > 0' here: - if (Getscriptaddress(destaddr, tx.vout[voutIndex].scriptPubKey) && strcmp(destaddr, heirFundingAddr) == 0) - return (tx.vout[voutIndex].nValue); - else - std::cerr << "IsHeirFundingVout() heirFundingAddr=" << heirFundingAddr << " not equal to destaddr=" << destaddr << std::endl; - } - return (0); + char destaddr[65], heirFundingAddr[65]; + + Helper::GetCoinsOrTokensCCaddress1of2(cp, heirFundingAddr, ownerPubkey, heirPubkey); + if (tx.vout[voutIndex].scriptPubKey.IsPayToCryptoCondition() != 0) { + // NOTE: dimxy it was unsafe 'Getscriptaddress(destaddr,tx.vout[voutIndex].scriptPubKey) > 0' here: + if (Getscriptaddress(destaddr, tx.vout[voutIndex].scriptPubKey) && strcmp(destaddr, heirFundingAddr) == 0) + return (tx.vout[voutIndex].nValue); + else + std::cerr << "IsHeirFundingVout() heirFundingAddr=" << heirFundingAddr << " not equal to destaddr=" << destaddr << std::endl; + } + return (0); } // makes coin initial tx opret CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - uint8_t evalcode = EVAL_HEIR; - - return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); + uint8_t evalcode = EVAL_HEIR; + + return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); } // makes coin additional tx opret CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpendingBegun) { - uint8_t evalcode = EVAL_HEIR; - - fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); + uint8_t evalcode = EVAL_HEIR; + + fundingtxid = revuint256(fundingtxid); + return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); } // decode opret vout for Heir contract uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { - uint8_t evalCodeInOpret = 0; - uint8_t heirFuncId = 0; - - fundingTxidInOpret = zeroid; //to init - - evalCodeInOpret = vopret.begin()[0]; - - if (vopret.size() > 1 && evalCodeInOpret == EVAL_HEIR) { - // NOTE: it unmarshals for all F, A and C - uint8_t heirFuncId = 0; - hasHeirSpendingBegun = 0; - - bool result = E_UNMARSHAL(vopret, { ss >> evalCodeInOpret; ss >> heirFuncId; \ - if (heirFuncId == 'F') { \ - ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; \ - } \ - else { \ - ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ - } \ - }); - - if (!result) { - if (!noLogging) std::cerr << "_DecodeHeirOpRet() could not unmarshal opret, evalCode=" << (int)evalCodeInOpret << std::endl; - return (uint8_t)0; - } - - /* std::cerr << "DecodeHeirOpRet()" - << " heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') - << " ownerPubkey=" << HexStr(ownerPubkey) - << " heirPubkey=" << HexStr(heirPubkey) - << " heirName=" << heirName << " inactivityTime=" << inactivityTime - << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << std::endl; */ - - if (isMyFuncId(heirFuncId)) { - fundingTxidInOpret = revuint256(fundingTxidInOpret); - return heirFuncId; - } - else { - if(!noLogging) std::cerr << "_DecodeHeirOpRet() unexpected opret type, heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') << std::endl; - } - } - else { - if (!noLogging) std::cerr << "_DecodeHeirOpRet() not a heir opret, vopretExtra.size() == 0 or not EVAL_HEIR evalcode=" << (int)evalCodeInOpret << std::endl; - } - return (uint8_t)0; + uint8_t evalCodeInOpret = 0; + uint8_t heirFuncId = 0; + + fundingTxidInOpret = zeroid; //to init + + evalCodeInOpret = vopret.begin()[0]; + + if (vopret.size() > 1 && evalCodeInOpret == EVAL_HEIR) { + // NOTE: it unmarshals for all F, A and C + uint8_t heirFuncId = 0; + hasHeirSpendingBegun = 0; + + bool result = E_UNMARSHAL(vopret, { ss >> evalCodeInOpret; ss >> heirFuncId; \ + if (heirFuncId == 'F') { \ + ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; \ + } \ + else { \ + ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ + } \ + }); + + if (!result) { + if (!noLogging) std::cerr << "_DecodeHeirOpRet() could not unmarshal opret, evalCode=" << (int)evalCodeInOpret << std::endl; + return (uint8_t)0; + } + + /* std::cerr << "DecodeHeirOpRet()" + << " heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') + << " ownerPubkey=" << HexStr(ownerPubkey) + << " heirPubkey=" << HexStr(heirPubkey) + << " heirName=" << heirName << " inactivityTime=" << inactivityTime + << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << std::endl; */ + + if (isMyFuncId(heirFuncId)) { + fundingTxidInOpret = revuint256(fundingTxidInOpret); + return heirFuncId; + } + else { + if(!noLogging) std::cerr << "_DecodeHeirOpRet() unexpected opret type, heirFuncId=" << (char)(heirFuncId ? heirFuncId : ' ') << std::endl; + } + } + else { + if (!noLogging) std::cerr << "_DecodeHeirOpRet() not a heir opret, vopretExtra.size() == 0 or not EVAL_HEIR evalcode=" << (int)evalCodeInOpret << std::endl; + } + return (uint8_t)0; } /* not used, see DecodeHeirOpRet(vopret,...) -// overload for 'F' opret -uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) -{ + // overload for 'F' opret + uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) + { uint256 dummytxid; uint8_t dummyHasHeirSpendingBegun; std::vector vopret; - + GetOpReturnData(scriptPubKey, vopret); if (vopret.size() == 0) { - if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; - return (uint8_t)0; + if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; + return (uint8_t)0; } return _DecodeHeirOpRet(vopret, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); -}*/ + }*/ /* not used, see DecodeHeirOpRet(vopret,...) -// overload for A, C oprets and AddHeirContractInputs -uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) -{ + // overload for A, C oprets and AddHeirContractInputs + uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) + { CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; std::string dummyHeirName; std::vector vopret; - + GetOpReturnData(scriptPubKey, vopret); if (vopret.size() == 0) { - if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; - return (uint8_t)0; + if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; + return (uint8_t)0; } - + return _DecodeHeirOpRet(vopret, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); -} */ + } */ // decode combined opret: uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { - uint8_t evalCodeTokens = 0; - std::vector voutPubkeysDummy; - std::vector vopretExtra, vopretStripped; - - if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { - if (vopretExtra.size() > 1) { - // restore the second opret: - - if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size - if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; - return (uint8_t)0; - } - } - else { - if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl; - return (uint8_t)0; - } - } - else - GetOpReturnData(scriptPubKey, vopretStripped); - - return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); - + uint8_t evalCodeTokens = 0; + std::vector voutPubkeysDummy; + std::vector vopretExtra, vopretStripped; + + if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { + if (vopretExtra.size() > 1) { + // restore the second opret: + + if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size + if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; + return (uint8_t)0; + } + } + else { + if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl; + return (uint8_t)0; + } + } + else + GetOpReturnData(scriptPubKey, vopretStripped); + + return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); + } // overload to decode opret in fundingtxid: uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { - uint256 dummyFundingTxidInOpret; - uint8_t dummyHasHeirSpendingBegun; - - return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummyFundingTxidInOpret, dummyHasHeirSpendingBegun, noLogging); + uint256 dummyFundingTxidInOpret; + uint8_t dummyHasHeirSpendingBegun; + + return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummyFundingTxidInOpret, dummyHasHeirSpendingBegun, noLogging); } // overload to decode opret in A and C heir tx: uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { - CPubKey dummyOwnerPubkey, dummyHeirPubkey; - int64_t dummyInactivityTime; - std::string dummyHeirName; - - return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); + CPubKey dummyOwnerPubkey, dummyHeirPubkey; + int64_t dummyInactivityTime; + std::string dummyHeirName; + + return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } /** - * find the latest funding tx: it may be the first F tx or one of A or C tx's - * Note: this function is also called from validation code (use non-locking calls) + * find the latest funding tx: it may be the first F tx or one of A or C tx's + * Note: this function is also called from validation code (use non-locking calls) */ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, uint8_t &hasHeirSpendingBegun) { - CTransaction fundingtx; - uint256 hashBlock; + CTransaction fundingtx; + uint256 hashBlock; const bool allowSlow = false; - + //char markeraddr[64]; //CCtxidaddr(markeraddr, fundingtxid); //SetCCunspents(unspentOutputs, markeraddr); - - hasHeirSpendingBegun = 0; - funcId = 0; - + + hasHeirSpendingBegun = 0; + funcId = 0; + // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { - - CScript heirScript = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); - uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + + CScript heirScript = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); if (funcId != 0) { // found at least funding tx! //std::cerr << "FindLatestFundingTx() lasttx currently is fundingtx, txid=" << fundingtxid.GetHex() << " opreturn type=" << (char)funcId << '\n'; @@ -434,55 +434,55 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke std::cerr << "FindLatestFundingTx() could not find funding tx for fundingtxid=" << fundingtxid.GetHex() << '\n'; return zeroid; } - - // TODO: correct cc addr: + + // TODO: correct cc addr: std::vector> unspentOutputs; struct CC_info *cp, C; cp = CCinit(&C, EVAL_HEIR); char coinaddr[64]; GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' - + SetCCunspents(unspentOutputs, coinaddr); // get vector with tx's with unspent vouts of 1of2pubkey address: //std::cerr << "FindLatestFundingTx() using 1of2address=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; - + int32_t maxBlockHeight = 0; // max block height uint256 latesttxid = fundingtxid; - + // try to find the last funding or spending tx by checking fundingtxid in 'opreturn': for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { CTransaction regtx; uint256 hash; - + uint256 txid = it->first.txhash; //std::cerr << "FindLatestFundingTx() checking unspents for txid=" << txid.GetHex() << '\n'; - + int32_t blockHeight = (int32_t)it->second.blockHeight; - - //NOTE: maybe called from validation code: - if (myGetTransaction(txid, regtx, hash)) { - //std::cerr << "FindLatestFundingTx() found tx for txid=" << txid.GetHex() << " blockHeight=" << blockHeight << " maxBlockHeight=" << maxBlockHeight << '\n'; - uint256 fundingTxidInOpret; - uint256 tokenidInOpret; // not to contaminate the tokenid from the params! - uint8_t tmpFuncId; - uint8_t hasHeirSpendingBegunInOpret; - - CScript heirScript = (regtx.vout.size() > 0) ? regtx.vout[regtx.vout.size() - 1].scriptPubKey : CScript(); - tmpFuncId = DecodeHeirEitherOpRet(heirScript, tokenidInOpret, fundingTxidInOpret, hasHeirSpendingBegunInOpret, true); + + //NOTE: maybe called from validation code: + if (myGetTransaction(txid, regtx, hash)) { + //std::cerr << "FindLatestFundingTx() found tx for txid=" << txid.GetHex() << " blockHeight=" << blockHeight << " maxBlockHeight=" << maxBlockHeight << '\n'; + uint256 fundingTxidInOpret; + uint256 tokenidInOpret; // not to contaminate the tokenid from the params! + uint8_t tmpFuncId; + uint8_t hasHeirSpendingBegunInOpret; + + CScript heirScript = (regtx.vout.size() > 0) ? regtx.vout[regtx.vout.size() - 1].scriptPubKey : CScript(); + tmpFuncId = DecodeHeirEitherOpRet(heirScript, tokenidInOpret, fundingTxidInOpret, hasHeirSpendingBegunInOpret, true); if (tmpFuncId != 0 && fundingtxid == fundingTxidInOpret && (tokenid == zeroid || tokenid == tokenidInOpret)) { // check tokenid also - + if (blockHeight > maxBlockHeight) { maxBlockHeight = blockHeight; latesttxid = txid; - funcId = tmpFuncId; - hasHeirSpendingBegun = hasHeirSpendingBegunInOpret; - - //std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight - // << " opreturn type=" << (char)(funcId ? funcId : ' ') << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << " - set as current lasttxid" << '\n'; + funcId = tmpFuncId; + hasHeirSpendingBegun = hasHeirSpendingBegunInOpret; + + //std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight + // << " opreturn type=" << (char)(funcId ? funcId : ' ') << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << " - set as current lasttxid" << '\n'; } } } } - + return latesttxid; } @@ -494,7 +494,7 @@ uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRe CPubKey heirPubkey; int64_t inactivityTime; std::string heirName; - + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); } @@ -502,7 +502,7 @@ uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRe uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint8_t &hasHeirSpendingBegun) { CScript opRetScript; - + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); } @@ -514,41 +514,41 @@ template int64_t Add1of2AddressInputs(struct CC_info* cp, uint256 CTransaction heirtx; int32_t n = 0; std::vector> unspentOutputs; - + char coinaddr[64]; - Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 of 2 pubkeys' + Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 of 2 pubkeys' SetCCunspents(unspentOutputs, coinaddr); - + // char markeraddr[64]; // CCtxidaddr(markeraddr, fundingtxid); // SetCCunspents(unspentOutputs, markeraddr); - + std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << std::endl; - + for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { uint256 txid = it->first.txhash; uint256 hashBlock; int32_t voutIndex = (int32_t)it->first.index; // no need to prevent dup // dimxy: maybe it is good to put tx's in cache? - - std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl; - + + std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl; + if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { - uint256 tokenid; + uint256 tokenid; uint256 fundingTxidInOpret; - uint8_t hasHeirSpendingBegunDummy; - - CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary - uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); - - if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && - funcId != 0 && - isMyFuncId(funcId) && - (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid) > 0) && // token validation logic + uint8_t hasHeirSpendingBegunDummy; + + CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary + uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); + + if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) && + funcId != 0 && + isMyFuncId(funcId) && + (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid) > 0) && // token validation logic //(voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && // heir contract vout validation logic - not used since we moved to 2-eval vouts - !myIsutxo_spentinmempool(txid, voutIndex)) - { + !myIsutxo_spentinmempool(txid, voutIndex)) + { std::cerr << "Add1of2AddressInputs() satoshis=" << it->second.satoshis << std::endl; if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, voutIndex, CScript())); @@ -564,42 +564,42 @@ template int64_t Add1of2AddressInputs(struct CC_info* cp, uint256 } /** - * enumerate all tx's sending to CCHeir 1of2address and calc total lifetime funds + * enumerate all tx's sending to CCHeir 1of2address and calc total lifetime funds */ template int64_t LifetimeHeirContractFunds(struct CC_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) { char coinaddr[64]; Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' - + std::vector> addressIndexes; SetCCtxids(addressIndexes, coinaddr); - + //fprintf(stderr,"LifetimeHeirContractFunds() scan lifetime of %s\n",coinaddr); int64_t total = 0; for (std::vector>::const_iterator it = addressIndexes.begin(); it != addressIndexes.end(); it++) { uint256 hashBlock; uint256 txid = it->first.txhash; CTransaction heirtx; - - // TODO: check all funding tx should contain unspendable markers + + // TODO: check all funding tx should contain unspendable markers if (GetTransaction(txid, heirtx, hashBlock, false) && heirtx.vout.size() > 0) { - uint256 tokenid; + uint256 tokenid; uint256 fundingTxidInOpret; - uint8_t hasHeirSpendingBegunDummy; + uint8_t hasHeirSpendingBegunDummy; const int32_t ivout = 0; - - CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary - uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); - + + CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary + uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false); + //std::cerr << "LifetimeHeirContractFunds() found tx=" << txid.GetHex() << " vout[0].nValue=" << subtx.vout[ccVoutIdx].nValue << " opreturn=" << (char)funcId << '\n'; - - if (funcId != 0 && - (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && - isMyFuncId(funcId) && !isSpendingTx(funcId) && - (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, ivout, tokenid) > 0) && - !myIsutxo_spentinmempool(txid, ivout)) // exclude tx in mempool + + if (funcId != 0 && + (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && + isMyFuncId(funcId) && !isSpendingTx(funcId) && + (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, ivout, tokenid) > 0) && + !myIsutxo_spentinmempool(txid, ivout)) // exclude tx in mempool { - total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) + total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) //std::cerr << "LifetimeHeirContractFunds() added tx=" << txid.GetHex() << " it->second=" << it->second << " vout[0].nValue=" << tx.vout[ivout].nValue << " opreturn=" << (char)funcId << '\n'; } } @@ -611,90 +611,90 @@ template int64_t LifetimeHeirContractFunds(struct CC_info* cp, ui /** * heirfund rpc call implementation - * creates tx for initial funds deposit on cryptocondition address which locks funds for spending by either of address. + * creates tx for initial funds deposit on cryptocondition address which locks funds for spending by either of address. * and also for setting spending plan for the funds' owner and heir * @return fundingtxid handle for subsequent references to this heir funding plan */ template UniValue HeirFund(uint64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { - UniValue result(UniValue::VOBJ); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CC_info *cp, C; - + UniValue result(UniValue::VOBJ); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + struct CC_info *cp, C; + cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) txfee = 10000; - + //std::cerr << "HeirFund() amount=" << amount << " txfee=" << txfee << " heirPubkey IsValid()=" << heirPubkey.IsValid() << " inactivityTime(sec)=" << inactivityTimeSec << " tokenid=" << tokenid.GetHex() << std::endl; - - if (!heirPubkey.IsValid()) { - std::cerr << "HeirFund() heirPubkey is not valid!" << std::endl; - return std::string(""); - } - + + if (!heirPubkey.IsValid()) { + std::cerr << "HeirFund() heirPubkey is not valid!" << std::endl; + return std::string(""); + } + CPubKey myPubkey = pubkey2pk(Mypubkey()); - - if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners - int64_t inputs, change; - - if ((inputs=Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners - //mtx.vout.push_back(MakeTokensCC1of2vout(/*Helper::getMyEval()*/EVAL_HEIR, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk - mtx.vout.push_back(Helper::make1of2Vout(amount, myPubkey, heirPubkey)); - - // add a marker for finding all plans in HeirList() - // TODO: change marker either to cc or normal txidaddr unspendable - CPubKey heirUnspendablePubKey = GetUnspendable(cp, 0); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); // TODO: do we need this marker? - - // calc and add change vout: - if (inputs > amount) - change = (inputs - amount); // -txfee <-- txfee pays user - - //std::cerr << "HeirFund() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; - - if (change != 0) { // vout[1] - mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); - } - - // add 1of2 vout validation pubkeys: - std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(myPubkey); - voutTokenPubkeys.push_back(heirPubkey); - - // add change for txfee and opreturn vouts and sign tx: - std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName)); - if (!rawhextx.empty()) { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); - } - else { - std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "sign error")); - } - } - else { // TODO: need result return unification with heiradd and claim - std::cerr << "HeirFund() could not find owner cc inputs" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "could not find owner cc inputs")); - } - } - else { - std::cerr << "HeirFund() could not find normal inputs" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "could not find normal inputs")); - } + + if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners + int64_t inputs, change; + + if ((inputs=Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners + //mtx.vout.push_back(MakeTokensCC1of2vout(/*Helper::getMyEval()*/EVAL_HEIR, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk + mtx.vout.push_back(Helper::make1of2Vout(amount, myPubkey, heirPubkey)); + + // add a marker for finding all plans in HeirList() + // TODO: change marker either to cc or normal txidaddr unspendable + CPubKey heirUnspendablePubKey = GetUnspendable(cp, 0); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); // TODO: do we need this marker? + + // calc and add change vout: + if (inputs > amount) + change = (inputs - amount); // -txfee <-- txfee pays user + + //std::cerr << "HeirFund() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; + + if (change != 0) { // vout[1] + mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); + } + + // add 1of2 vout validation pubkeys: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(myPubkey); + voutTokenPubkeys.push_back(heirPubkey); + + // add change for txfee and opreturn vouts and sign tx: + std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName)); + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "sign error")); + } + } + else { // TODO: need result return unification with heiradd and claim + std::cerr << "HeirFund() could not find owner cc inputs" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find owner cc inputs")); + } + } + else { + std::cerr << "HeirFund() could not find normal inputs" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find normal inputs")); + } return result; } -// if no these callers - it could not link +// if no these callers - it could not link UniValue HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ - return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); + return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); } UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { - return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); + return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); } /** @@ -704,113 +704,113 @@ UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName */ template UniValue _HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) { - UniValue result(UniValue::VOBJ); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); int64_t inputs, CCchange = 0; struct CC_info *cp, C; std::string rawhex; - - cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! - + + cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! + if (txfee == 0) txfee = 10000; - + CPubKey myPubkey = pubkey2pk(Mypubkey()); - + // check if it is the owner if (myPubkey != ownerPubkey) { result.push_back(Pair("result", "error")); result.push_back(Pair("error", "adding funds is only allowed for the owner of this contract")); return result; } - - if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners - - int64_t inputs, change; - - if ((inputs = Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? - - // we do not use markers anymore - storing data in opreturn is better - // add marker vout: - /* char markeraddr[64]; - CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners - std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ - - // add cryptocondition to spend this funded amount for either pk - mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); - - if (inputs > amount) - change = (inputs - amount); // -txfee <-- txfee pays user - - //std::cerr << "HeirAdd() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; - - if (change != 0) { // vout[1] - mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); - } - - // add 1of2 vout validation pubkeys - needed only for tokens: - std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(ownerPubkey); - voutTokenPubkeys.push_back(heirPubkey); - - // add opreturn 'A' and sign tx: // this txfee ignored - std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); - - if (!rawhextx.empty()) { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); - } - else { - std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "sign error")); - } - - } - else { - std::cerr << "HeirAdd cannot find owner cc inputs" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find owner cc inputs")); - } - } - else { - std::cerr << "HeirAdd cannot find normal inputs for tx fee" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find normal inputs for tx fee")); - } - - - + + if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners + + int64_t inputs, change; + + if ((inputs = Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, 64)) > 0) { // TODO: why 64 max inputs? + + // we do not use markers anymore - storing data in opreturn is better + // add marker vout: + /* char markeraddr[64]; + CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners + std::cerr << "HeirAdd() adding markeraddr=" << markeraddr << '\n'; */ + + // add cryptocondition to spend this funded amount for either pk + mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); + + if (inputs > amount) + change = (inputs - amount); // -txfee <-- txfee pays user + + //std::cerr << "HeirAdd() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; + + if (change != 0) { // vout[1] + mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); + } + + // add 1of2 vout validation pubkeys - needed only for tokens: + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(ownerPubkey); + voutTokenPubkeys.push_back(heirPubkey); + + // add opreturn 'A' and sign tx: // this txfee ignored + std::string rawhextx = (FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); + + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "sign error")); + } + + } + else { + std::cerr << "HeirAdd cannot find owner cc inputs" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find owner cc inputs")); + } + } + else { + std::cerr << "HeirAdd cannot find normal inputs for tx fee" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find normal inputs for tx fee")); + } + + + return result; } UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { - - CPubKey ownerPubkey, heirPubkey; - int64_t inactivityTimeSec; - - uint256 latesttxid, tokenid = zeroid; - uint8_t funcId; - std::string heirName; - uint8_t hasHeirSpendingBegun = 0; - - if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { - if (tokenid == zeroid) - return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - else - return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - } - else { - UniValue result(UniValue::VOBJ); - - fprintf(stderr, "HeirAdd() can't find any heir CC funding tx's\n"); - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find any heir CC funding transactions")); - return result; - } + + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTimeSec; + + uint256 latesttxid, tokenid = zeroid; + uint8_t funcId; + std::string heirName; + uint8_t hasHeirSpendingBegun = 0; + + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { + if (tokenid == zeroid) + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + else + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + } + else { + UniValue result(UniValue::VOBJ); + + fprintf(stderr, "HeirAdd() can't find any heir CC funding tx's\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find any heir CC funding transactions")); + return result; + } } @@ -821,110 +821,110 @@ UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { */ template UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) { - UniValue result(UniValue::VOBJ); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey myPubkey; + UniValue result(UniValue::VOBJ); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey myPubkey; int64_t inputs, change = 0; struct CC_info *cp, C; - - cp = CCinit(&C, EVAL_HEIR); - if (txfee == 0) + + cp = CCinit(&C, EVAL_HEIR); + if (txfee == 0) txfee = 10000; - + int32_t numblocks; uint64_t durationSec = 0; - - // we do not need to find duration if spending already has begun - if (!hasHeirSpendingBegun) { + + // we do not need to find duration if spending already has begun + if (!hasHeirSpendingBegun) { durationSec = CCduration(numblocks, latesttxid); std::cerr << "HeirClaim() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << std::endl; } - + // spending is allowed if there is already spending tx or inactivity time //bool isAllowedToHeir = (funcId == 'C' || durationSec > inactivityTimeSec) ? true : false; - bool isAllowedToHeir = (hasHeirSpendingBegun || durationSec > inactivityTimeSec) ? true : false; + bool isAllowedToHeir = (hasHeirSpendingBegun || durationSec > inactivityTimeSec) ? true : false; myPubkey = pubkey2pk(Mypubkey()); - + // if it is the heir, check if spending not allowed to heir yet if (myPubkey == heirPubkey && !isAllowedToHeir) { result.push_back(Pair("result", "error")); result.push_back(Pair("error", "spending is not allowed yet for the heir")); return result; } - - // we do not use markers any more: - // we allow owner to spend funds at any time: - // if it is the owner, check if spending already allowed to heir - /* if (myPubkey == ownerPubkey && isAllowedToHeir) { - result.push_back(Pair("result", "spending is not already allowed for the owner")); - return result; - } */ - - // add spending txfee from the calling user + + // we do not use markers any more: + // we allow owner to spend funds at any time: + // if it is the owner, check if spending already allowed to heir + /* if (myPubkey == ownerPubkey && isAllowedToHeir) { + result.push_back(Pair("result", "spending is not already allowed for the owner")); + return result; + } */ + + // add spending txfee from the calling user if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { - - // add spending from cc 1of2 address - if ((inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, amount, 60)) >= amount) // TODO: why only 60 inputs? + + // add spending from cc 1of2 address + if ((inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, amount, 60)) >= amount) // TODO: why only 60 inputs? { - /*if (inputs < amount) { - std::cerr << "HeirClaim() cant find enough HeirCC 1of2 inputs, found=" << inputs << " required=" << amount << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find heir CC funding")); - - return result; - }*/ - - // add vout with amount to claiming address - mtx.vout.push_back(Helper::makeUserVout(amount, myPubkey)); // vout[0] - + /*if (inputs < amount) { + std::cerr << "HeirClaim() cant find enough HeirCC 1of2 inputs, found=" << inputs << " required=" << amount << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find heir CC funding")); + + return result; + }*/ + + // add vout with amount to claiming address + mtx.vout.push_back(Helper::makeUserVout(amount, myPubkey)); // vout[0] + // calc and add change vout: if (inputs > amount) - change = (inputs - amount); // -txfee <-- txfee pays user - + change = (inputs - amount); // -txfee <-- txfee pays user + //std::cerr << "HeirClaim() inputs=" << inputs << " amount=" << amount << " txfee=" << txfee << " change=" << change << '\n'; - - // change to 1of2 funding addr: + + // change to 1of2 funding addr: if (change != 0) { // vout[1] mtx.vout.push_back(Helper::make1of2Vout(change, ownerPubkey, heirPubkey)); // using always pubkeys from OP_RETURN in order to not mixing them up! } - + // add marker vout: /*char markeraddr[64]; - CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); - // NOTE: amount = 0 is not working: causes error code: -26, error message : 64 : dust - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners - std::cerr << "HeirClaim() adding markeraddr=" << markeraddr << '\n'; */ - - // get address of 1of2 cond + CPubKey markerpubkey = CCtxidaddr(markeraddr, fundingtxid); + // NOTE: amount = 0 is not working: causes error code: -26, error message : 64 : dust + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); // txfee 1, txfee 2 - for miners + std::cerr << "HeirClaim() adding markeraddr=" << markeraddr << '\n'; */ + + // get address of 1of2 cond char coinaddr[64]; Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); - - // retrieve priv key addresses for FinalizeCCtx: - uint8_t myprivkey[32]; + + // retrieve priv key addresses for FinalizeCCtx: + uint8_t myprivkey[32]; Myprivkey(myprivkey); - - // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: - Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); - - // add 1of2 vout validation pubkeys (this is for tokens): - std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(ownerPubkey); - voutTokenPubkeys.push_back(heirPubkey); - + + // set pubkeys for finding 1of2 cc in FinalizeCCtx to sign it: + Helper::CCaddrCoinsOrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + + // add 1of2 vout validation pubkeys (this is for tokens): + std::vector voutTokenPubkeys; + voutTokenPubkeys.push_back(ownerPubkey); + voutTokenPubkeys.push_back(heirPubkey); + // add opreturn 'C' and sign tx: // this txfee will be ignored - std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : hasHeirSpendingBegun)); // forward isHeirSpending to the next latest tx - - if (!rawhextx.empty()) { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); - } - else { - std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "sign error")); - } - + std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, + Helper::makeClaimOpRet(tokenid, voutTokenPubkeys, fundingtxid, (myPubkey == heirPubkey) ? 1 : hasHeirSpendingBegun)); // forward isHeirSpending to the next latest tx + + if (!rawhextx.empty()) { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hextx", rawhextx)); + } + else { + std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "sign error")); + } + } else { fprintf(stderr, "HeirClaim() cant find Heir CC inputs\n"); result.push_back(Pair("result", "error")); @@ -935,187 +935,187 @@ template UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfe result.push_back(Pair("result", "error")); result.push_back(Pair("error", "can't find sufficient user inputs to pay transaction fee")); } - - + + return result; } UniValue HeirClaimCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { - - CPubKey ownerPubkey, heirPubkey; - int64_t inactivityTimeSec; - - uint256 latesttxid, tokenid = zeroid; - uint8_t funcId; - std::string heirName; - uint8_t hasHeirSpendingBegun = 0; - - if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { - if( tokenid == zeroid ) - return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - else - return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - - } - else { - UniValue result(UniValue::VOBJ); - - fprintf(stderr, "HeirClaim() can't find any heir CC funding tx's\n"); - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "can't find any heir CC funding transactions")); - return result; - } + + CPubKey ownerPubkey, heirPubkey; + int64_t inactivityTimeSec; + + uint256 latesttxid, tokenid = zeroid; + uint8_t funcId; + std::string heirName; + uint8_t hasHeirSpendingBegun = 0; + + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { + if( tokenid == zeroid ) + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + else + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + + } + else { + UniValue result(UniValue::VOBJ); + + fprintf(stderr, "HeirClaim() can't find any heir CC funding tx's\n"); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "can't find any heir CC funding transactions")); + return result; + } } /** * heirinfo rpc call implementation - * returns some information about heir CC contract plan by a handle of initial fundingtxid: + * returns some information about heir CC contract plan by a handle of initial fundingtxid: * plan name, owner and heir pubkeys, funds deposited and available, flag if spending is enabled for the heir * @return heir info data */ UniValue HeirInfo(uint256 fundingtxid) { UniValue result(UniValue::VOBJ); - - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction fundingtx; - uint256 hashBlock; - const bool allowSlow = false; - - //char markeraddr[64]; - //CCtxidaddr(markeraddr, fundingtxid); - //SetCCunspents(unspentOutputs, markeraddr); - - // get initial funding tx and set it as initial lasttx: - if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { - - CPubKey ownerPubkey, heirPubkey; - uint256 dummyTokenid, tokenid = zeroid; // important to clear tokenid - std::string heirName; - int64_t inactivityTimeSec; - const bool noLogging = false; - uint8_t funcId; - - /*CScript opret = fundingtx.vout.size() > 0 ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); - uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); - if (funcId == 0) { - std::cerr << "HeirInfo() this fundingtx is incorrect" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "initial tx F not found")); - return result; - }*/ - - struct CC_info *cp, C; - cp = CCinit(&C, EVAL_HEIR); - - uint8_t hasHeirSpendingBegun = 0; - - uint256 latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - - if (latestFundingTxid != zeroid) { - int32_t numblocks; - uint64_t durationSec = 0; - - //std::cerr << "HeirInfo() latesttxid=" << latestFundingTxid.GetHex() << '\n'; - - std::ostringstream stream; - std::string msg; - - result.push_back(Pair("fundingtxid", fundingtxid.GetHex())); - result.push_back(Pair("name", heirName.c_str())); - - if (tokenid != zeroid) { // tokens - stream << tokenid.GetHex(); - msg = "tokenid"; - result.push_back(Pair(msg, stream.str().c_str())); - stream.str(""); - stream.clear(); - } - - char hexbuf[67]; - stream << pubkey33_str(hexbuf, (uint8_t*)ownerPubkey.begin()); - result.push_back(Pair("owner", stream.str().c_str())); - stream.str(""); - stream.clear(); - - stream << pubkey33_str(hexbuf, (uint8_t*)heirPubkey.begin()); - result.push_back(Pair("heir", stream.str().c_str())); - stream.str(""); - stream.clear(); - - int64_t total; - if (tokenid == zeroid) - total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); - else - total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); - - if (tokenid == zeroid) { - msg = "funding total in coins"; - stream << (double)total / COIN; - } - else { - msg = "funding total in tokens"; - stream << total; - } - result.push_back(Pair(msg, stream.str().c_str())); - stream.str(""); - stream.clear(); - - int64_t inputs; - if (tokenid == zeroid) - inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); //NOTE: amount = 0 means all unspent inputs - else - inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); - - if (tokenid == zeroid) { - msg = "funding available in coins"; - stream << (double)inputs / COIN; - } - else { - msg = "funding available in tokens"; - stream << inputs; - } - result.push_back(Pair(msg, stream.str().c_str())); - stream.str(""); - stream.clear(); - - if (tokenid != zeroid) { - int64_t ownerInputs = TokenHelper::addOwnerInputs(tokenid, mtx, ownerPubkey, 0, (int32_t)64); - stream << ownerInputs; - msg = "owner funding available in tokens"; - result.push_back(Pair(msg, stream.str().c_str())); - stream.str(""); - stream.clear(); - } - - stream << inactivityTimeSec; - result.push_back(Pair("inactivity time setting", stream.str().c_str())); - stream.str(""); - stream.clear(); - - if (!hasHeirSpendingBegun) { // we do not need find duration if the spending already has begun - durationSec = CCduration(numblocks, latestFundingTxid); - std::cerr << "HeirInfo() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << '\n'; - } - - stream << std::boolalpha << (hasHeirSpendingBegun || durationSec > inactivityTimeSec); - result.push_back(Pair("spending allowed for the heir", stream.str().c_str())); - stream.str(""); - stream.clear(); - - result.push_back(Pair("result", "success")); - } - else { - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "could not find heir cc plan for this txid")); - } - } - else { - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "could not find heir cc plan for this txid (no initial tx)")); - } - return (result); + + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction fundingtx; + uint256 hashBlock; + const bool allowSlow = false; + + //char markeraddr[64]; + //CCtxidaddr(markeraddr, fundingtxid); + //SetCCunspents(unspentOutputs, markeraddr); + + // get initial funding tx and set it as initial lasttx: + if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { + + CPubKey ownerPubkey, heirPubkey; + uint256 dummyTokenid, tokenid = zeroid; // important to clear tokenid + std::string heirName; + int64_t inactivityTimeSec; + const bool noLogging = false; + uint8_t funcId; + + /*CScript opret = fundingtx.vout.size() > 0 ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); + if (funcId == 0) { + std::cerr << "HeirInfo() this fundingtx is incorrect" << std::endl; + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "initial tx F not found")); + return result; + }*/ + + struct CC_info *cp, C; + cp = CCinit(&C, EVAL_HEIR); + + uint8_t hasHeirSpendingBegun = 0; + + uint256 latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + + if (latestFundingTxid != zeroid) { + int32_t numblocks; + uint64_t durationSec = 0; + + //std::cerr << "HeirInfo() latesttxid=" << latestFundingTxid.GetHex() << '\n'; + + std::ostringstream stream; + std::string msg; + + result.push_back(Pair("fundingtxid", fundingtxid.GetHex())); + result.push_back(Pair("name", heirName.c_str())); + + if (tokenid != zeroid) { // tokens + stream << tokenid.GetHex(); + msg = "tokenid"; + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + } + + char hexbuf[67]; + stream << pubkey33_str(hexbuf, (uint8_t*)ownerPubkey.begin()); + result.push_back(Pair("owner", stream.str().c_str())); + stream.str(""); + stream.clear(); + + stream << pubkey33_str(hexbuf, (uint8_t*)heirPubkey.begin()); + result.push_back(Pair("heir", stream.str().c_str())); + stream.str(""); + stream.clear(); + + int64_t total; + if (tokenid == zeroid) + total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); + else + total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); + + if (tokenid == zeroid) { + msg = "funding total in coins"; + stream << (double)total / COIN; + } + else { + msg = "funding total in tokens"; + stream << total; + } + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + + int64_t inputs; + if (tokenid == zeroid) + inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); //NOTE: amount = 0 means all unspent inputs + else + inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); + + if (tokenid == zeroid) { + msg = "funding available in coins"; + stream << (double)inputs / COIN; + } + else { + msg = "funding available in tokens"; + stream << inputs; + } + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + + if (tokenid != zeroid) { + int64_t ownerInputs = TokenHelper::addOwnerInputs(tokenid, mtx, ownerPubkey, 0, (int32_t)64); + stream << ownerInputs; + msg = "owner funding available in tokens"; + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + } + + stream << inactivityTimeSec; + result.push_back(Pair("inactivity time setting", stream.str().c_str())); + stream.str(""); + stream.clear(); + + if (!hasHeirSpendingBegun) { // we do not need find duration if the spending already has begun + durationSec = CCduration(numblocks, latestFundingTxid); + std::cerr << "HeirInfo() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << '\n'; + } + + stream << std::boolalpha << (hasHeirSpendingBegun || durationSec > inactivityTimeSec); + result.push_back(Pair("spending allowed for the heir", stream.str().c_str())); + stream.str(""); + stream.clear(); + + result.push_back(Pair("result", "success")); + } + else { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find heir cc plan for this txid")); + } + } + else { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "could not find heir cc plan for this txid (no initial tx)")); + } + return (result); } /** @@ -1125,47 +1125,47 @@ UniValue HeirInfo(uint256 fundingtxid) template void _HeirList(struct CC_info *cp, UniValue &result) { - std::vector> unspentOutputs; - char coinaddr[64]; - CPubKey ccPubKeyEmpty; - GetCCaddress(cp, coinaddr, ccPubKeyEmpty); - SetCCunspents(unspentOutputs, cp->normaladdr); - - //std::cerr << "HeirList() finding heir marker from Heir contract addr=" << cp->normaladdr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; - - // TODO: move marker to special cc addr to prevent checking all tokens - for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { - uint256 hashBlock; - uint256 txid = it->first.txhash; - uint256 tokenid; - int32_t vout = (int32_t)it->first.index; - - //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; - - CTransaction fundingtx; - if (GetTransaction(txid, fundingtx, hashBlock, false)) { - CPubKey ownerPubkey, heirPubkey; - std::string heirName; - int64_t inactivityTimeSec; - const bool noLogging = true; - uint256 tokenid; - - CScript opret = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); - uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); - - // note: if it is not Heir token funcId would be equal to 0 - if (funcId == 'F') { - //result.push_back(Pair("fundingtxid kind name", txid.GetHex() + std::string(" ") + (typeid(Helper) == typeid(TokenHelper) ? std::string("token") : std::string("coin")) + std::string(" ") + heirName)); - result.push_back( Pair("fundingtxid", txid.GetHex()) ); - } - else { - std::cerr << "HeirList() this is not the initial F transaction=" << txid.GetHex() << std::endl; - } - } - else { - std::cerr << "HeirList() could not load transaction=" << txid.GetHex() << std::endl; - } - } + std::vector> unspentOutputs; + char coinaddr[64]; + CPubKey ccPubKeyEmpty; + GetCCaddress(cp, coinaddr, ccPubKeyEmpty); + SetCCunspents(unspentOutputs, cp->normaladdr); + + //std::cerr << "HeirList() finding heir marker from Heir contract addr=" << cp->normaladdr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + + // TODO: move marker to special cc addr to prevent checking all tokens + for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { + uint256 hashBlock; + uint256 txid = it->first.txhash; + uint256 tokenid; + int32_t vout = (int32_t)it->first.index; + + //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; + + CTransaction fundingtx; + if (GetTransaction(txid, fundingtx, hashBlock, false)) { + CPubKey ownerPubkey, heirPubkey; + std::string heirName; + int64_t inactivityTimeSec; + const bool noLogging = true; + uint256 tokenid; + + CScript opret = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); + + // note: if it is not Heir token funcId would be equal to 0 + if (funcId == 'F') { + //result.push_back(Pair("fundingtxid kind name", txid.GetHex() + std::string(" ") + (typeid(Helper) == typeid(TokenHelper) ? std::string("token") : std::string("coin")) + std::string(" ") + heirName)); + result.push_back( Pair("fundingtxid", txid.GetHex()) ); + } + else { + std::cerr << "HeirList() this is not the initial F transaction=" << txid.GetHex() << std::endl; + } + } + else { + std::cerr << "HeirList() could not load transaction=" << txid.GetHex() << std::endl; + } + } } @@ -1173,15 +1173,16 @@ UniValue HeirList() { UniValue result(UniValue::VOBJ); result.push_back(Pair("result", "success")); - + struct CC_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! - cpHeir = CCinit(&heirC, EVAL_HEIR); - cpTokens = CCinit(&tokenC, EVAL_TOKENS); - - _HeirList(cpHeir, result); - _HeirList(cpTokens, result); - - return result; + cpHeir = CCinit(&heirC, EVAL_HEIR); + cpTokens = CCinit(&tokenC, EVAL_TOKENS); + + _HeirList(cpHeir, result); + _HeirList(cpTokens, result); + + return result; } + From 557886b5914d6b39a1b5f3a34f0a1c3ae1f048c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:16:38 -1100 Subject: [PATCH 1339/3904] CC_info --- src/cc/heir_validate.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index f8e66e3d5..c41c38c09 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -123,13 +123,13 @@ public: class CValidatorBase { public: - CValidatorBase(CCcontract_info* cp) : m_cp(cp) {} + CValidatorBase(CC_info* cp) : m_cp(cp) {} virtual bool isVinValidator() const = 0; virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0; virtual bool validateVout(CTxOut vout, std::string& message) const = 0; protected: - CCcontract_info * m_cp; + CC_info * m_cp; }; /** @@ -138,11 +138,11 @@ protected: class CInputIdentifierBase { public: - CInputIdentifierBase(CCcontract_info* cp) : m_cp(cp) {} + CInputIdentifierBase(CC_info* cp) : m_cp(cp) {} virtual std::string inputName() const = 0; virtual bool identifyInput(CTxIn vin) const = 0; protected: - CCcontract_info * m_cp; + CC_info * m_cp; }; /** @@ -375,7 +375,7 @@ private: class CNormalInputIdentifier : CInputIdentifierBase { public: - CNormalInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + CNormalInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} virtual std::string inputName() const { return std::string("normal input"); } virtual bool identifyInput(CTxIn vin) const { return !IsCCInput(vin.scriptSig); @@ -384,7 +384,7 @@ public: class CCCInputIdentifier : CInputIdentifierBase { public: - CCCInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} + CCCInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} virtual std::string inputName() const { return std::string("CC input"); } virtual bool identifyInput(CTxIn vin) const { return IsCCInput(vin.scriptSig); @@ -398,7 +398,7 @@ public: template class CCC1of2AddressValidator : CValidatorBase { public: - CCC1of2AddressValidator(CCcontract_info* cp, CScript opRetScript, std::string customMessage = "") : + CCC1of2AddressValidator(CC_info* cp, CScript opRetScript, std::string customMessage = "") : m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -452,7 +452,7 @@ private: template class CMyPubkeyVoutValidator : CValidatorBase { public: - CMyPubkeyVoutValidator(CCcontract_info* cp, CScript opRetScript, bool checkNormals) + CMyPubkeyVoutValidator(CC_info* cp, CScript opRetScript, bool checkNormals) : m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } @@ -512,7 +512,7 @@ private: template class CHeirSpendValidator : CValidatorBase { public: - CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) + CHeirSpendValidator(CC_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -568,7 +568,7 @@ private: template class COpRetValidator : CValidatorBase { public: - COpRetValidator(CCcontract_info* cp, CScript opret) + COpRetValidator(CC_info* cp, CScript opret) : m_fundingOpretScript(opret), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -619,7 +619,7 @@ private: template class CNullValidator : CValidatorBase { public: - CNullValidator(CCcontract_info* cp) + CNullValidator(CC_info* cp) : CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } From c4d932a318885e2163474e5f0850ef2a80021011 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:23:08 -1100 Subject: [PATCH 1340/3904] Partial revert --- src/cc/CCinclude.h | 1 + src/cc/heir.cpp | 27 +++++++++++++-------------- src/cc/heir_validate.h | 32 ++++++++++++++++---------------- src/script/sign.cpp | 4 ++-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 0b537f3d3..eda543a66 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -116,6 +116,7 @@ struct CC_info uint8_t didinit; }; +typedef struct CC_info CCcontract_info; struct CC_info *CCinit(struct CC_info *cp,uint8_t evalcode); struct oracleprice_info diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 7867032b6..ccf9da1bf 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -34,7 +34,7 @@ class TokenHelper; // Plan validation runner, it may be called twice - for coins and tokens // (sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation()...) -template bool RunValidationPlans(uint8_t funcId, struct CC_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun) +template bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun) { int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); @@ -104,14 +104,14 @@ template bool RunValidationPlans(uint8_t funcId, struct CC_inf /** * Tx validation entry function */ -bool HeirValidate(struct CC_info* cpHeir, Eval* eval, const CTransaction& tx, uint32_t nIn) +bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction& tx, uint32_t nIn) { int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); //int32_t preventCCvins = -1; //int32_t preventCCvouts = -1; - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); if (numvouts < 1) @@ -237,7 +237,7 @@ bool HeirValidate(struct CC_info* cpHeir, Eval* eval, const CTransaction& tx, ui * Checks if vout is to cryptocondition address * @return vout value in satoshis */ -template int64_t IsHeirFundingVout(struct CC_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) +template int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey) { char destaddr[65], heirFundingAddr[65]; @@ -437,7 +437,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke // TODO: correct cc addr: std::vector> unspentOutputs; - struct CC_info *cp, C; + struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_HEIR); char coinaddr[64]; GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' @@ -507,7 +507,7 @@ uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &token } // add inputs of 1 of 2 cc address -template int64_t Add1of2AddressInputs(struct CC_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs) +template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs) { // TODO: add threshold check int64_t nValue, voutValue, totalinputs = 0; @@ -566,7 +566,7 @@ template int64_t Add1of2AddressInputs(struct CC_info* cp, uint256 /** * enumerate all tx's sending to CCHeir 1of2address and calc total lifetime funds */ -template int64_t LifetimeHeirContractFunds(struct CC_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) +template int64_t LifetimeHeirContractFunds(struct CCcontract_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey) { char coinaddr[64]; Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' @@ -619,7 +619,7 @@ template UniValue HeirFund(uint64_t txfee, int64_t amount, std { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CC_info *cp, C; + struct CCcontract_info *cp, C; cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) @@ -707,7 +707,7 @@ template UniValue _HeirAdd(uint256 fundingtxid, uint64_t txfee, i UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); int64_t inputs, CCchange = 0; - struct CC_info *cp, C; + struct CCcontract_info *cp, C; std::string rawhex; cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly! @@ -825,7 +825,7 @@ template UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfe CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey myPubkey; int64_t inputs, change = 0; - struct CC_info *cp, C; + struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_HEIR); if (txfee == 0) @@ -1006,7 +1006,7 @@ UniValue HeirInfo(uint256 fundingtxid) return result; }*/ - struct CC_info *cp, C; + struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_HEIR); uint8_t hasHeirSpendingBegun = 0; @@ -1123,7 +1123,7 @@ UniValue HeirInfo(uint256 fundingtxid) * @return list of heir plan handles (fundingtxid) */ -template void _HeirList(struct CC_info *cp, UniValue &result) +template void _HeirList(struct CCcontract_info *cp, UniValue &result) { std::vector> unspentOutputs; char coinaddr[64]; @@ -1174,7 +1174,7 @@ UniValue HeirList() UniValue result(UniValue::VOBJ); result.push_back(Pair("result", "success")); - struct CC_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! + struct CCcontract_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! cpHeir = CCinit(&heirC, EVAL_HEIR); cpTokens = CCinit(&tokenC, EVAL_TOKENS); @@ -1185,4 +1185,3 @@ UniValue HeirList() return result; } - diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index c41c38c09..c4bb7ea60 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -47,11 +47,11 @@ public: return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG); } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CC_info *cpHeir, heirC; + struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } }; @@ -61,7 +61,7 @@ class TokenHelper { public: static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { - struct CC_info *cpHeir, heirC; + struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_TOKENS); return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); } @@ -89,12 +89,12 @@ public: return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS } */ static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) { - struct CC_info *cpHeir, heirC; + struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr); } @@ -123,13 +123,13 @@ public: class CValidatorBase { public: - CValidatorBase(CC_info* cp) : m_cp(cp) {} + CValidatorBase(CCcontract_info* cp) : m_cp(cp) {} virtual bool isVinValidator() const = 0; virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0; virtual bool validateVout(CTxOut vout, std::string& message) const = 0; protected: - CC_info * m_cp; + CCcontract_info * m_cp; }; /** @@ -138,11 +138,11 @@ protected: class CInputIdentifierBase { public: - CInputIdentifierBase(CC_info* cp) : m_cp(cp) {} + CInputIdentifierBase(CCcontract_info* cp) : m_cp(cp) {} virtual std::string inputName() const = 0; virtual bool identifyInput(CTxIn vin) const = 0; protected: - CC_info * m_cp; + CCcontract_info * m_cp; }; /** @@ -375,7 +375,7 @@ private: class CNormalInputIdentifier : CInputIdentifierBase { public: - CNormalInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} + CNormalInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} virtual std::string inputName() const { return std::string("normal input"); } virtual bool identifyInput(CTxIn vin) const { return !IsCCInput(vin.scriptSig); @@ -384,7 +384,7 @@ public: class CCCInputIdentifier : CInputIdentifierBase { public: - CCCInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {} + CCCInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {} virtual std::string inputName() const { return std::string("CC input"); } virtual bool identifyInput(CTxIn vin) const { return IsCCInput(vin.scriptSig); @@ -398,7 +398,7 @@ public: template class CCC1of2AddressValidator : CValidatorBase { public: - CCC1of2AddressValidator(CC_info* cp, CScript opRetScript, std::string customMessage = "") : + CCC1of2AddressValidator(CCcontract_info* cp, CScript opRetScript, std::string customMessage = "") : m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -452,7 +452,7 @@ private: template class CMyPubkeyVoutValidator : CValidatorBase { public: - CMyPubkeyVoutValidator(CC_info* cp, CScript opRetScript, bool checkNormals) + CMyPubkeyVoutValidator(CCcontract_info* cp, CScript opRetScript, bool checkNormals) : m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } @@ -512,7 +512,7 @@ private: template class CHeirSpendValidator : CValidatorBase { public: - CHeirSpendValidator(CC_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) + CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan) : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -568,7 +568,7 @@ private: template class COpRetValidator : CValidatorBase { public: - COpRetValidator(CC_info* cp, CScript opret) + COpRetValidator(CCcontract_info* cp, CScript opret) : m_fundingOpretScript(opret), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } @@ -619,7 +619,7 @@ private: template class CNullValidator : CValidatorBase { public: - CNullValidator(CC_info* cp) + CNullValidator(CCcontract_info* cp) : CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } diff --git a/src/script/sign.cpp b/src/script/sign.cpp index f7f663db2..685018828 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -136,7 +136,7 @@ std::vector &GetCryptoConditions() return vCC; } -bool GetCCByUnspendableAddress(struct CC_info *cp, char *addrstr) +bool GetCCByUnspendableAddress(struct CCcontract_info *cp, char *addrstr) { std::vector &vCC = GetCryptoConditions(); bool found = false; @@ -153,7 +153,7 @@ bool GetCCByUnspendableAddress(struct CC_info *cp, char *addrstr) return found; } -bool CCinitLite(struct CC_info *cp, uint8_t evalcode) +bool CCinitLite(struct CCcontract_info *cp, uint8_t evalcode) { std::vector &vCC = GetCryptoConditions(); bool found = false; From 62322eb58954690d645b1006849f282384691af4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:31:12 -1100 Subject: [PATCH 1341/3904] struct CCcontract_info --- src/cc/CC made easy.md | 8 +++---- src/cc/CCGateways.h | 2 +- src/cc/CCHeir.h | 4 ++-- src/cc/CCMarmara.h | 2 +- src/cc/CCOracles.h | 2 +- src/cc/CCPayments.h | 2 +- src/cc/CCPegs.h | 2 +- src/cc/CCPrices.h | 2 +- src/cc/CCassets.h | 12 +++++----- src/cc/CCassetsCore.cpp | 18 +++++++-------- src/cc/CCassetstx.cpp | 34 +++++++++++++-------------- src/cc/CCauction.h | 2 +- src/cc/CCchannels.h | 2 +- src/cc/CCcustom.cpp | 4 ++-- src/cc/CCdice.h | 4 ++-- src/cc/CCfaucet.h | 2 +- src/cc/CCfsm.h | 2 +- src/cc/CCinclude.h | 37 +++++++++++++++-------------- src/cc/CClotto.h | 2 +- src/cc/CCrewards.h | 2 +- src/cc/CCtokens.cpp | 22 +++++++++--------- src/cc/CCtokens.h | 8 +++---- src/cc/CCtx.cpp | 4 ++-- src/cc/CCutils.cpp | 28 +++++++++++----------- src/cc/assets.cpp | 4 ++-- src/cc/auction.cpp | 14 +++++------ src/cc/cclib.cpp | 10 ++++---- src/cc/channels.cpp | 22 +++++++++--------- src/cc/dice.cpp | 34 +++++++++++++-------------- src/cc/eval.cpp | 4 ++-- src/cc/eval.h | 4 ++-- src/cc/faucet.cpp | 14 +++++------ src/cc/fsm.cpp | 12 +++++----- src/cc/gateways.cpp | 36 ++++++++++++++--------------- src/cc/lotto.cpp | 20 ++++++++-------- src/cc/marmara.cpp | 26 ++++++++++----------- src/cc/oracles.cpp | 30 ++++++++++++------------ src/cc/payments.cpp | 14 +++++------ src/cc/pegs.cpp | 14 +++++------ src/cc/prices.cpp | 14 +++++------ src/cc/rewards.cpp | 24 +++++++++---------- src/komodo_bitcoind.h | 2 +- src/wallet/rpcwallet.cpp | 50 ++++++++++++++++++++-------------------- 43 files changed, 277 insertions(+), 278 deletions(-) diff --git a/src/cc/CC made easy.md b/src/cc/CC made easy.md index f409efb2d..2d1081003 100644 --- a/src/cc/CC made easy.md +++ b/src/cc/CC made easy.md @@ -206,13 +206,13 @@ The idea is that people send funds to the faucet by locking it in faucet's globa There are only 7 functions in faucet.cpp, a bit over 200 lines including comments. The first three are for validation, the last four for the rpc calls to use. -int64_t IsFaucetvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsFaucetvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) -bool FaucetExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool FaucetExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) -bool FaucetValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx) +bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) -int64_t AddFaucetInputs(struct CC_infoCC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddFaucetInputs(struct CCcontract_infoCC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) std::string FaucetGet(uint64_t txfee) diff --git a/src/cc/CCGateways.h b/src/cc/CCGateways.h index 0ffeced6e..b629ade1f 100644 --- a/src/cc/CCGateways.h +++ b/src/cc/CCGateways.h @@ -20,7 +20,7 @@ #include "CCinclude.h" #include "../merkleblock.h" -bool GatewaysValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool GatewaysValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys); std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount); std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount); diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index 1e831e772..ecaff9cdb 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -22,7 +22,7 @@ //#define EVAL_HEIR 0xea -bool HeirValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); class CoinHelper; class TokenHelper; @@ -36,6 +36,6 @@ UniValue HeirInfo(uint256 fundingtxid); UniValue HeirList(); //std::string Heir_MakeBadTx(uint256 fundingtxid, uint8_t funcId, int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTime, uint32_t errMask); -//bool HeirExactTokenAmounts(bool compareTotals, struct CC_info *cpHeir, Eval* eval, uint256 assetid, const CTransaction &tx); +//bool HeirExactTokenAmounts(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 assetid, const CTransaction &tx); #endif diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 567f43aa3..65269df77 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -38,7 +38,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid); UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency); -bool MarmaraValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue MarmaraInfo(); diff --git a/src/cc/CCOracles.h b/src/cc/CCOracles.h index a46d0c311..7f952e5f5 100644 --- a/src/cc/CCOracles.h +++ b/src/cc/CCOracles.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool OraclesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string OracleCreate(int64_t txfee,std::string name,std::string description,std::string format); std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee); std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,int64_t amount); diff --git a/src/cc/CCPayments.h b/src/cc/CCPayments.h index f229212fb..187d9c9ad 100644 --- a/src/cc/CCPayments.h +++ b/src/cc/CCPayments.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool PaymentsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue PaymentsInfo(); diff --git a/src/cc/CCPegs.h b/src/cc/CCPegs.h index a7863a3ec..8d2a268f1 100644 --- a/src/cc/CCPegs.h +++ b/src/cc/CCPegs.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool PegsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue PegsInfo(); diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index fe625e31b..1a68be7dd 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -19,7 +19,7 @@ #include "CCinclude.h" -bool PricesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue PricesList(); diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 061e0f899..69fcfacbb 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -26,7 +26,7 @@ #include "CCinclude.h" // CCcustom -bool AssetsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCassetsCore //CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk); @@ -35,20 +35,20 @@ bool AssetsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32 //bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); //uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); -int64_t IsAssetvout(struct CC_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); +int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateAskRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool SetBidFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -int64_t AssetValidateBuyvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); -int64_t AssetValidateSellvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); -bool AssetCalcAmounts(struct CC_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); +int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); +int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); +bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); // CCassetstx //int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance() -int64_t AddAssetInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); +int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); UniValue AssetOrders(uint256 tokenid); //UniValue AssetInfo(uint256 tokenid); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 45d3421be..1b8e46189 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -365,7 +365,7 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT } // Calculate sell/buy owner's source token/asset address from ask/bid tx -bool GetAssetorigaddrs(struct CC_info *cp, char *userCCaddr, char *destaddr, const CTransaction& tx) +bool GetAssetorigaddrs(struct CCcontract_info *cp, char *userCCaddr, char *destaddr, const CTransaction& tx) { uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; @@ -378,13 +378,13 @@ bool GetAssetorigaddrs(struct CC_info *cp, char *userCCaddr, char *destaddr, con bool bGetCCaddr = false; if (funcid == 's' || funcid == 'S') { - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); //bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); } else if (funcid == 'b' || funcid == 'B') { - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); } @@ -400,7 +400,7 @@ bool GetAssetorigaddrs(struct CC_info *cp, char *userCCaddr, char *destaddr, con } -int64_t AssetValidateCCvin(struct CC_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) +int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) { uint256 hashBlock; uint256 assetid, assetid2; @@ -463,7 +463,7 @@ int64_t AssetValidateCCvin(struct CC_info *cp,Eval* eval,char *CCaddr,char *orig return(vinTx.vout[0].nValue); } -int64_t AssetValidateBuyvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid) +int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid) { CTransaction vinTx; int64_t nValue; uint256 assetid,assetid2; uint8_t funcid, evalCode; CCaddr[0] = origaddr[0] = 0; @@ -490,7 +490,7 @@ int64_t AssetValidateBuyvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std: return(nValue); } -int64_t AssetValidateSellvin(struct CC_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid) +int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid) { CTransaction vinTx; int64_t nValue,assetoshis; //fprintf(stderr,"AssetValidateSellvin\n"); @@ -558,7 +558,7 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr // Checks if the vout is a really Asset CC vout // compareTotals == true, the func also validates the passed transaction itself: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx -int64_t IsAssetvout(struct CC_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid) +int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid) { //std::cerr << "IsAssetvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for assetid=" << refassetid.GetHex() << std::endl; @@ -587,14 +587,14 @@ int64_t IsAssetvout(struct CC_info *cp, int64_t &price, std::vector &or } // sets cc inputs vs cc outputs and ensures they are equal: -bool AssetCalcAmounts(struct CC_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid) +bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid) { CTransaction vinTx; uint256 hashBlock, id, id2; int32_t flag; int64_t assetoshis; std::vector tmporigpubkey; int64_t tmpprice; int32_t numvins = tx.vin.size(); int32_t numvouts = tx.vout.size(); inputs = outputs = 0; - struct CC_info *cpTokens, C; + struct CCcontract_info *cpTokens, C; cpTokens = CCinit(&C, EVAL_TOKENS); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index dff279acd..968775d38 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -17,7 +17,7 @@ //#include "CCtokens.h" -int64_t AddAssetInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) +int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) { char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t j,vout,n = 0; std::vector > unspentOutputs; @@ -72,13 +72,13 @@ UniValue AssetOrders(uint256 refassetid) UniValue result(UniValue::VARR); std::vector > unspentOutputsTokens, unspentOutputsAssets; - struct CC_info *cpTokens, tokensC; - struct CC_info *cpAssets, assetsC; + struct CCcontract_info *cpTokens, tokensC; + struct CCcontract_info *cpAssets, assetsC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); cpAssets = CCinit(&assetsC, EVAL_ASSETS); - auto addOrders = [&](struct CC_info *cp, std::vector >::const_iterator it) + auto addOrders = [&](struct CCcontract_info *cp, std::vector >::const_iterator it) { uint256 txid, hashBlock, assetid, assetid2; int64_t price; @@ -189,7 +189,7 @@ UniValue AssetOrders(uint256 refassetid) /* std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CC_info *cp,C; + CPubKey mypk; struct CCcontract_info *cp,C; if ( assetsupply < 0 ) { fprintf(stderr,"negative assetsupply %lld\n",(long long)assetsupply); @@ -217,7 +217,7 @@ UniValue AssetOrders(uint256 refassetid) /* std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; uint64_t mask; int64_t CCchange=0,inputs=0; struct CC_info *cp,C; + CPubKey mypk; uint64_t mask; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; if ( total < 0 ) { fprintf(stderr,"negative total %lld\n",(long long)total); @@ -259,7 +259,7 @@ UniValue AssetOrders(uint256 refassetid) /* std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; int64_t CCchange=0,inputs=0; struct CC_info *cp,C; + CPubKey mypk; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; if ( total < 0 ) { fprintf(stderr,"negative total %lld\n",(long long)total); @@ -288,7 +288,7 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; - struct CC_info *cpAssets, C; + struct CCcontract_info *cpAssets, C; uint256 hashBlock; CTransaction vintx; std::vector origpubkey; @@ -349,8 +349,8 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p uint64_t mask; int64_t inputs, CCchange; CScript opret; - struct CC_info *cpAssets, assetsC; - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpAssets, assetsC; + struct CCcontract_info *cpTokens, tokensC; //std::cerr << "CreateSell() askamount=" << askamount << " pricetotal=" << pricetotal << std::endl; @@ -408,7 +408,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 assetid2,int64_t pricetotal) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CC_info *cp,C; + CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// fprintf(stderr,"asset swaps disabled\n"); @@ -482,7 +482,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) uint256 hashBlock; int64_t bidamount; CPubKey mypk; - struct CC_info *cpAssets, C; + struct CCcontract_info *cpAssets, C; uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; @@ -526,7 +526,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) uint256 hashBlock; int64_t askamount; CPubKey mypk; - struct CC_info *cpTokens, *cpAssets, tokensC, assetsC; + struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; @@ -592,8 +592,8 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f int32_t bidvout=0; uint64_t mask; int64_t origprice, bidamount, paid_amount, remaining_required, inputs, CCchange=0; - struct CC_info *cpTokens, tokensC; - struct CC_info *cpAssets, assetsC; + struct CCcontract_info *cpTokens, tokensC; + struct CCcontract_info *cpAssets, assetsC; if (fillamount < 0) { @@ -676,8 +676,8 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a uint64_t mask = 0; int32_t askvout = 0; int64_t received_assetoshis, total_nValue, orig_assetoshis, paid_nValue, remaining_nValue, inputs, CCchange=0; - //struct CC_info *cpTokens, tokensC; - struct CC_info *cpAssets, assetsC; + //struct CCcontract_info *cpTokens, tokensC; + struct CCcontract_info *cpAssets, assetsC; if (fillunits < 0) { diff --git a/src/cc/CCauction.h b/src/cc/CCauction.h index 13393d510..cfcd615cc 100644 --- a/src/cc/CCauction.h +++ b/src/cc/CCauction.h @@ -21,7 +21,7 @@ #define EVAL_AUCTION 0xe8 -bool AuctionValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool AuctionValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string AuctionPost(uint64_t txfee,uint256 itemhash,int64_t minbid,char *title,char *description); std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount); diff --git a/src/cc/CCchannels.h b/src/cc/CCchannels.h index 76e0ab8cf..10cb4d224 100644 --- a/src/cc/CCchannels.h +++ b/src/cc/CCchannels.h @@ -20,7 +20,7 @@ #include "CCinclude.h" #define CHANNELS_MAXPAYMENTS 1000 -bool ChannelsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64_t payment,uint256 tokenid); std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint256 secret); std::string ChannelClose(uint64_t txfee,uint256 opentxid); diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index c05210542..577332b63 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -243,7 +243,7 @@ uint8_t CClibCCpriv[32] = { 0x57, 0xcf, 0x49, 0x71, 0x7d, 0xb4, 0x15, 0x1b, 0x4f #undef FUNCNAME #undef EVALCODE -int32_t CClib_initcp(struct CC_info *cp,uint8_t evalcode) +int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) { CPubKey pk; uint8_t pub33[33]; char CCaddr[64]; if ( evalcode == EVAL_FIRSTUSER ) // eventually make a hashchain for each evalcode @@ -263,7 +263,7 @@ int32_t CClib_initcp(struct CC_info *cp,uint8_t evalcode) return(-1); } -struct CC_info *CCinit(struct CC_info *cp, uint8_t evalcode) +struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) { cp->evalcode = evalcode; switch ( evalcode ) diff --git a/src/cc/CCdice.h b/src/cc/CCdice.h index 0de222c50..363aad735 100644 --- a/src/cc/CCdice.h +++ b/src/cc/CCdice.h @@ -21,7 +21,7 @@ #define EVAL_DICE 0xe6 -bool DiceValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool DiceValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet,int32_t odds); std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout); @@ -30,6 +30,6 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount); UniValue DiceInfo(uint256 diceid); UniValue DiceList(); -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CC_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random); +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random); #endif diff --git a/src/cc/CCfaucet.h b/src/cc/CCfaucet.h index 4bb2ae0d7..3cb6c66e5 100644 --- a/src/cc/CCfaucet.h +++ b/src/cc/CCfaucet.h @@ -22,7 +22,7 @@ #define EVAL_FAUCET 0xe4 #define FAUCETSIZE (COIN / 10) -bool FaucetValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom std::string FaucetFund(uint64_t txfee,int64_t funds); diff --git a/src/cc/CCfsm.h b/src/cc/CCfsm.h index 0690e4dd2..2bce35597 100644 --- a/src/cc/CCfsm.h +++ b/src/cc/CCfsm.h @@ -21,7 +21,7 @@ #define EVAL_FSM 0xe7 -bool FSMValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string FSMList(); std::string FSMInfo(uint256 fsmtxid); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index eda543a66..82c9484d5 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -88,7 +88,7 @@ struct CC_meta // followed by address destinations }; -struct CC_info +struct CCcontract_info { // this is for spending from 'unspendable' CC address uint8_t evalcode; @@ -111,13 +111,12 @@ struct CC_info uint8_t unspendablepriv2[32], unspendablepriv3[32]; CPubKey unspendablepk2, unspendablepk3; - bool (*validate)(struct CC_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn); // cc contract tx validation callback + bool (*validate)(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn); // cc contract tx validation callback bool (*ismyvin)(CScript const& scriptSig); // checks if evalcode is present in the scriptSig param uint8_t didinit; }; -typedef struct CC_info CCcontract_info; -struct CC_info *CCinit(struct CC_info *cp,uint8_t evalcode); +struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode); struct oracleprice_info { @@ -135,7 +134,7 @@ CBlockIndex *komodo_getblockindex(uint256 hash); int32_t komodo_nextheight(); int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 txid,int32_t vout); -void CCclearvars(struct CC_info *cp); +void CCclearvars(struct CCcontract_info *cp); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); @@ -159,9 +158,9 @@ uint8_t DecodeOraclesCreateOpRet(const CScript &scriptPubKey,std::string &name,s uint256 OracleMerkle(int32_t height,uint256 reforacletxid,char *format,std::vectorpublishers); uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); -//int64_t AddAssetInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); -int64_t AddTokenCCInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CC_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid); +//int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); @@ -179,7 +178,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t // CCcustom -CPubKey GetUnspendable(struct CC_info *cp,uint8_t *unspendablepriv); +CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); // CCutils CPubKey buf2pk(uint8_t *buf33); @@ -190,19 +189,19 @@ CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2); CC *MakeCCcond1(uint8_t evalcode,CPubKey pk); CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2); CC* GetCryptoCondition(CScript const& scriptSig); -void CCaddr2set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); -void CCaddr3set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); -void CCaddr1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); +void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); +void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); +void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2); CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk); -bool GetTokensCCaddress(struct CC_info *cp, char *destaddr, CPubKey pk); -bool GetTokensCCaddress1of2(struct CC_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); -void CCaddrTokens1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); -int32_t CClib_initcp(struct CC_info *cp,uint8_t evalcode); +bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk); +bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); +void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); +int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode); bool IsCCInput(CScript const& scriptSig); int32_t unstringbits(char *buf,uint64_t bits); @@ -217,8 +216,8 @@ int64_t CCfullsupply(uint256 tokenid); int64_t CCtoken_balance(char *destaddr,uint256 tokenid); int64_t CCtoken_balance2(char *destaddr,uint256 tokenid); bool _GetCCaddress(char *destaddr,uint8_t evalcode,CPubKey pk); -bool GetCCaddress(struct CC_info *cp,char *destaddr,CPubKey pk); -bool GetCCaddress1of2(struct CC_info *cp,char *destaddr,CPubKey pk,CPubKey pk2); +bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk); +bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubKey pk2); bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue); bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t numvins,int32_t preventCCvouts,int32_t numvouts); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); @@ -230,7 +229,7 @@ CPubKey check_signing_pubkey(CScript scriptSig); // CCtx bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); extern std::vector NULL_pubkeys; -std::string FinalizeCCTx(uint64_t skipmask,struct CC_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); +std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); void SetCCtxids(std::vector > &addressIndex,char *coinaddr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); diff --git a/src/cc/CClotto.h b/src/cc/CClotto.h index 4ef147cef..2f0595371 100644 --- a/src/cc/CClotto.h +++ b/src/cc/CClotto.h @@ -21,7 +21,7 @@ #define EVAL_LOTTO 0xe9 -bool LottoValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); UniValue LottoInfo(uint256 lottoid); UniValue LottoList(); diff --git a/src/cc/CCrewards.h b/src/cc/CCrewards.h index 41977f915..4d6cc80f9 100644 --- a/src/cc/CCrewards.h +++ b/src/cc/CCrewards.h @@ -22,7 +22,7 @@ #define EVAL_REWARDS 0xe5 #define REWARDSCC_MAXAPR (COIN * 25) -bool RewardsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); UniValue RewardsInfo(uint256 rewardid); UniValue RewardsList(); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 6620a9cd8..bdb710afb 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -177,7 +177,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 // tx validation -bool TokensValidate(struct CC_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn) +bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn) { static uint256 zero; CTxDestination address; CTransaction vinTx, createTx; uint256 hashBlock, tokenid, tokenid2; @@ -251,7 +251,7 @@ bool TokensValidate(struct CC_info *cp, Eval* eval, const CTransaction &tx, uint // forward validation if evalcode in opret is not EVAL_TOKENS // init for forwarding validation call //if (evalCodeInOpret != EVAL_TOKENS) { // TODO: should we check also only allowed for tokens evalcodes, like EVAL_ASSETS, EVAL_GATEWAYS? - // struct CC_info *cpOther = NULL, C; + // struct CCcontract_info *cpOther = NULL, C; // cpOther = CCinit(&C, evalCodeInOpret); // if (cpOther) @@ -271,7 +271,7 @@ bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys) bool found = false; CPubKey pubkey; - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); @@ -353,7 +353,7 @@ uint8_t ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vec // goDeeper is true: the func also validates amounts of the passed transaction: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx // checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true! -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CC_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid) +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid) { // this is just for log messages indentation fur debugging recursive calls: @@ -488,13 +488,13 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CC_info *cp, Eval* } // compares cc inputs vs cc outputs (to prevent feeding vouts from normal inputs) -bool TokensExactAmounts(bool goDeeper, struct CC_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) +bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) { CTransaction vinTx; uint256 hashBlock; int64_t tokenoshis; - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); int32_t numvins = tx.vin.size(); @@ -559,7 +559,7 @@ bool TokensExactAmounts(bool goDeeper, struct CC_info *cp, int64_t &inputs, int6 } // add inputs from token cc addr -int64_t AddTokenCCInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) { char tokenaddr[64], destaddr[64]; int64_t threshold, nValue, price, totalinputs = 0; @@ -617,7 +617,7 @@ int64_t AddTokenCCInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey p std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CC_info *cp, C; + CPubKey mypk; struct CCcontract_info *cp, C; if (assetsupply < 0) { fprintf(stderr, "negative assetsupply %lld\n", (long long)assetsupply); @@ -647,7 +647,7 @@ std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, st std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; uint64_t mask; int64_t CCchange = 0, inputs = 0; struct CC_info *cp, C; + CPubKey mypk; uint64_t mask; int64_t CCchange = 0, inputs = 0; struct CCcontract_info *cp, C; std::vector emptyExtraOpret; if (total < 0) @@ -714,7 +714,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) return 0; } - struct CC_info *cp, C; + struct CCcontract_info *cp, C; cp = CCinit(&C, EVAL_TOKENS); return(AddTokenCCInputs(cp, mtx, pk, tokenid, 0, 0)); } @@ -748,7 +748,7 @@ UniValue TokenList() { UniValue result(UniValue::VARR); std::vector > addressIndex; - struct CC_info *cp, C; uint256 txid, hashBlock; + struct CCcontract_info *cp, C; uint256 txid, hashBlock; CTransaction vintx; std::vector origpubkey; std::string name, description; char str[65]; diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index 2eaffe31f..e7bb62101 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -26,9 +26,9 @@ #include "CCinclude.h" // CCcustom -bool TokensValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); -bool TokensExactAmounts(bool goDeeper, struct CC_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); -//int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CC_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); +bool TokensValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); +//int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); @@ -36,7 +36,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid); UniValue TokenInfo(uint256 tokenid); UniValue TokenList(); -//this is in CCinclude.h int64_t AddTokenCCInputs(struct CC_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); +//this is in CCinclude.h int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); //this is in CCinclude.h uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 307ac214f..ae7483f4d 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -40,7 +40,7 @@ bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScrip return(false); } -std::string FinalizeCCTx(uint64_t CCmask,struct CC_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys) +std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys) { auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; @@ -50,7 +50,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CC_info *cp,CMutableTransaction uint8_t *privkey, myprivkey[32], unspendablepriv[32], tokensunspendablepriv[32], *msg32 = 0; CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CPubKey unspendablepk /*, tokensunspendablepk*/; - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpTokens, tokensC; globalpk = GetUnspendable(cp,0); n = mtx.vout.size(); for (i=0; i pubkey) return(pk); } -void CCaddr2set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) +void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) { cp->evalcode2 = evalcode; cp->unspendablepk2 = pk; @@ -235,7 +235,7 @@ void CCaddr2set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,cha strcpy(cp->unspendableaddr2,coinaddr); } -void CCaddr3set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) +void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) { cp->evalcode3 = evalcode; cp->unspendablepk3 = pk; @@ -244,7 +244,7 @@ void CCaddr3set(struct CC_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,cha } // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 cryptocondition vout: -void CCaddr1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) { cp->coins1of2pk[0] = pk1; cp->coins1of2pk[1] = pk2; @@ -252,7 +252,7 @@ void CCaddr1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) } // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 tokens cryptocondition vout: -void CCaddrTokens1of2set(struct CC_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) { cp->tokens1of2pk[0] = pk1; cp->tokens1of2pk[1] = pk2; @@ -343,7 +343,7 @@ bool _GetCCaddress(char *destaddr,uint8_t evalcode,CPubKey pk) return(destaddr[0] != 0); } -bool GetCCaddress(struct CC_info *cp,char *destaddr,CPubKey pk) +bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk) { destaddr[0] = 0; if ( pk.size() == 0 ) @@ -363,7 +363,7 @@ bool _GetTokensCCaddress(char *destaddr, uint8_t evalcode, CPubKey pk) return(destaddr[0] != 0); } -bool GetTokensCCaddress(struct CC_info *cp, char *destaddr, CPubKey pk) +bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk) { destaddr[0] = 0; if (pk.size() == 0) @@ -372,7 +372,7 @@ bool GetTokensCCaddress(struct CC_info *cp, char *destaddr, CPubKey pk) } -bool GetCCaddress1of2(struct CC_info *cp,char *destaddr,CPubKey pk,CPubKey pk2) +bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubKey pk2) { CC *payoutCond; destaddr[0] = 0; @@ -384,7 +384,7 @@ bool GetCCaddress1of2(struct CC_info *cp,char *destaddr,CPubKey pk,CPubKey pk2) return(destaddr[0] != 0); } -bool GetTokensCCaddress1of2(struct CC_info *cp, char *destaddr, CPubKey pk, CPubKey pk2) +bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2) { CC *payoutCond; destaddr[0] = 0; @@ -486,14 +486,14 @@ bool Myprivkey(uint8_t myprivkey[]) return(false); } -CPubKey GetUnspendable(struct CC_info *cp,uint8_t *unspendablepriv) +CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv) { if ( unspendablepriv != 0 ) memcpy(unspendablepriv,cp->CCpriv,32); return(pubkey2pk(ParseHex(cp->CChexstr))); } -void CCclearvars(struct CC_info *cp) +void CCclearvars(struct CCcontract_info *cp) { cp->evalcode2 = cp->evalcode3 = 0; cp->unspendableaddr2[0] = cp->unspendableaddr3[0] = 0; @@ -602,7 +602,7 @@ CPubKey check_signing_pubkey(CScript scriptSig) return CPubKey(); } -bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull,const CTransaction &ctx, unsigned int nIn) +bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector paramsNull,const CTransaction &ctx, unsigned int nIn) { CTransaction createTx; uint256 assetid,assetid2,hashBlock; uint8_t funcid; int32_t height,i,n,from_mempool = 0; int64_t amount; std::vector origpubkey; height = KOMODO_CONNECTING; @@ -636,13 +636,13 @@ bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull,co return(false); } -extern struct CC_info CCinfos[0x100]; +extern struct CCcontract_info CCinfos[0x100]; extern std::string MYCCLIBNAME; -bool CClib_validate(struct CC_info *cp,Eval *eval,const CTransaction &txTo,unsigned int nIn); +bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction &txTo,unsigned int nIn); bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { - uint8_t evalcode; int32_t height,from_mempool; struct CC_info *cp; + uint8_t evalcode; int32_t height,from_mempool; struct CCcontract_info *cp; if ( ASSETCHAINS_CCLIB != MYCCLIBNAME ) { fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME.c_str()); diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 7747fb61c..3ccafa34f 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -126,7 +126,7 @@ // tx validation -bool AssetsValidate(struct CC_info *cpAssets,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransaction &tx, uint32_t nIn) { static uint256 zero; CTxDestination address; CTransaction vinTx,createTx; uint256 hashBlock,assetid,assetid2; @@ -157,7 +157,7 @@ bool AssetsValidate(struct CC_info *cpAssets,Eval* eval,const CTransaction &tx, GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); // we need this for validating single-eval tokens' vins/vous: - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); // find single-eval token user cc addr: diff --git a/src/cc/auction.cpp b/src/cc/auction.cpp index b3fe4aa86..0858facfa 100644 --- a/src/cc/auction.cpp +++ b/src/cc/auction.cpp @@ -21,7 +21,7 @@ // start of consensus code -int64_t IsAuctionvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsAuctionvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -32,7 +32,7 @@ int64_t IsAuctionvout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool AuctionExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool AuctionExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -70,7 +70,7 @@ bool AuctionExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,in else return(true); } -bool AuctionValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool AuctionValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; return eval->Invalid("no validation yet"); @@ -118,7 +118,7 @@ bool AuctionValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint3 // helper functions for rpc calls in rpcwallet.cpp -int64_t AddAuctionInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; @@ -151,7 +151,7 @@ int64_t AddAuctionInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk, std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; + CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; @@ -172,7 +172,7 @@ std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount) std::string AuctionDeliver(uint64_t txfee,uint256 itemhash,uint256 bidtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; + CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; @@ -193,7 +193,7 @@ std::string AuctionDeliver(uint64_t txfee,uint256 itemhash,uint256 bidtxid) std::string AuctionPost(uint64_t txfee,uint256 itemhash,int64_t minbid,char *title,char *description) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Auctionpk; int64_t funds = 0; CScript opret; struct CC_info *cp,C; + CPubKey mypk,Auctionpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 837a36024..0f201acc4 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -42,9 +42,9 @@ std::string MYCCLIBNAME = (char *)"stub"; char *CClib_name() { return(MYCCLIBNAME); } -std::string CClib_rawtxgen(struct CC_info *cp,uint8_t funcid,cJSON *params); +std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); -UniValue CClib_info(struct CC_info *cp) +UniValue CClib_info(struct CCcontract_info *cp) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i; char str[2]; result.push_back(Pair("result","success")); @@ -70,7 +70,7 @@ UniValue CClib_info(struct CC_info *cp) return(result); } -UniValue CClib(struct CC_info *cp,char *method,cJSON *params) +UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; for (i=0; i > unspentOutputs; @@ -465,7 +465,7 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); uint8_t hash[32],hashdest[32]; uint64_t amount,tokens=0,funds; int32_t i; uint256 hashchain,entropy,hentropy; - CPubKey mypk; struct CC_info *cp,*cpTokens,C,CTokens; + CPubKey mypk; struct CCcontract_info *cp,*cpTokens,C,CTokens; if ( numpayments <= 0 || payment <= 0 || numpayments > CHANNELS_MAXPAYMENTS ) { @@ -509,7 +509,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk,srcpub,destpub; uint256 txid,hashchain,gensecret,hashblock,entropy,hentropy,prevtxid,param3,tokenid; - struct CC_info *cp,C; int32_t i,funcid,prevdepth,numvouts,numpayments,totalnumpayments; + struct CCcontract_info *cp,C; int32_t i,funcid,prevdepth,numvouts,numpayments,totalnumpayments; int64_t payment,change,funds,param2; uint8_t hash[32],hashdest[32]; CTransaction channelOpenTx,prevTx; @@ -616,7 +616,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 std::string ChannelClose(uint64_t txfee,uint256 opentxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,srcpub,destpub; struct CC_info *cp,C; + CPubKey mypk,srcpub,destpub; struct CCcontract_info *cp,C; CTransaction channelOpenTx; uint256 hashblock,tmp_txid,prevtxid,hashchain,tokenid; int32_t numvouts,numpayments; @@ -665,7 +665,7 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CC_info *cp,C; int64_t funds,payment,param2; + CPubKey mypk; struct CCcontract_info *cp,C; int64_t funds,payment,param2; int32_t i,numpayments,numvouts,param1; uint256 hashchain,hashblock,txid,prevtxid,param3,tokenid; CTransaction channelOpenTx,channelCloseTx,prevTx; @@ -735,7 +735,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) } UniValue ChannelsList() { - UniValue result(UniValue::VOBJ); std::vector > txids; struct CC_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; + UniValue result(UniValue::VOBJ); std::vector > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; CTransaction tx; char myCCaddr[65],addr[65],str[256]; CPubKey mypk,srcpub,destpub; int32_t vout,numvouts,param1; int64_t nValue,param2; @@ -766,7 +766,7 @@ UniValue ChannelsList() UniValue ChannelsInfo(uint256 channeltxid) { UniValue result(UniValue::VOBJ),array(UniValue::VARR); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid,tokenid; - struct CC_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments; + struct CCcontract_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments; int64_t param2,payment; CPubKey srcpub,destpub,mypk; std::vector > addressIndex; std::vector txids; diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 7a10913e7..05dad9bf6 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -322,7 +322,7 @@ void dicefinish_delete(struct dicefinish_info *ptr) void *dicefinish(void *_ptr) { - std::vector mypk; struct CC_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CPubKey dicepk; CTransaction betTx,finishTx,tx; + std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CPubKey dicepk; CTransaction betTx,finishTx,tx; mypk = Mypubkey(); pubkey2addr(coinaddr,mypk.data()); cp = CCinit(&C,EVAL_DICE); @@ -735,7 +735,7 @@ uint256 DiceGetEntropy(CTransaction tx,uint8_t reffuncid) else return(zeroid); } -uint64_t IsDicevout(struct CC_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) +uint64_t IsDicevout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) { char destaddr[64]; uint8_t funcid; int32_t numvouts; uint64_t sbits; uint256 fundingtxid,hash,proof; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -749,7 +749,7 @@ uint64_t IsDicevout(struct CC_info *cp,const CTransaction& tx,int32_t v,uint64_t return(0); } -int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CC_info *cp,Eval *eval,const CTransaction &tx,uint64_t refsbits,uint256 reffundingtxid) +int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CCcontract_info *cp,Eval *eval,const CTransaction &tx,uint64_t refsbits,uint256 reffundingtxid) { CTransaction vinTx; uint256 hashBlock; int32_t i,numvins,numvouts; uint64_t assetoshis; numvins = tx.vin.size(); @@ -834,7 +834,7 @@ bool DiceVerifyTimeout(CTransaction &betTx,int32_t timeoutblocks) return(numblocks >= timeoutblocks); } -bool DiceValidate(struct CC_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) +bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) { uint256 txid,fundingtxid,vinfundingtxid,vinhentropy,vinproof,hashBlock,hash,proof,entropy; int64_t minbet,maxbet,maxodds,timeoutblocks,odds,winnings; uint64_t vinsbits,refsbits=0,sbits,amount,inputs,outputs,txfee=10000; int32_t numvins,entropyvout,numvouts,preventCCvins,preventCCvouts,i,iswin; uint8_t funcid; CScript fundingPubKey; CTransaction fundingTx,vinTx,vinofvinTx; char CCaddr[64]; numvins = tx.vin.size(); @@ -1046,7 +1046,7 @@ bool DiceValidate(struct CC_info *cp,Eval *eval,const CTransaction &tx, uint32_t return(true); } -uint64_t AddDiceInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) +uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) { char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hash,proof,hashBlock,fundingtxid; CTransaction tx; int32_t j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; @@ -1095,7 +1095,7 @@ uint64_t AddDiceInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,ui return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CC_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,sum,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0,i=0,pendingbets=0; uint8_t funcid; std::vector > unspentOutputs; @@ -1215,7 +1215,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } -bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CC_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) +bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) { char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; @@ -1256,9 +1256,9 @@ bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CC_info * return(false); } -struct CC_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,struct CC_info *C,char *planstr,uint64_t &txfee,CPubKey &mypk,CPubKey &dicepk,uint64_t &sbits,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) +struct CCcontract_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,struct CCcontract_info *C,char *planstr,uint64_t &txfee,CPubKey &mypk,CPubKey &dicepk,uint64_t &sbits,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) { - struct CC_info *cp; int32_t cmpflag; + struct CCcontract_info *cp; int32_t cmpflag; cp = CCinit(C,EVAL_DICE); if ( txfee == 0 ) txfee = 10000; @@ -1278,7 +1278,7 @@ struct CC_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,struct CC UniValue DiceInfo(uint256 diceid) { - UniValue result(UniValue::VOBJ); CPubKey dicepk; uint256 hashBlock,entropytxid; CTransaction vintx; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t sbits,funding,entropyval; char str[67],numstr[65]; struct CC_info *cp,C; + UniValue result(UniValue::VOBJ); CPubKey dicepk; uint256 hashBlock,entropytxid; CTransaction vintx; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t sbits,funding,entropyval; char str[67],numstr[65]; struct CCcontract_info *cp,C; if ( myGetTransaction(diceid,vintx,hashBlock) == 0 ) { fprintf(stderr,"cant find fundingtxid\n"); @@ -1314,7 +1314,7 @@ UniValue DiceInfo(uint256 diceid) UniValue DiceList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; cp = CCinit(&C,EVAL_DICE); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -1334,7 +1334,7 @@ UniValue DiceList() std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CC_info *cp,C; + uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CCcontract_info *cp,C; if ( funds < 0 || minbet < 0 || maxbet < 0 || maxodds < 1 || maxodds > 9999 || timeoutblocks < 0 || timeoutblocks > 1440 ) { CCerror = "invalid parameter error"; @@ -1369,7 +1369,7 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CC_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; + CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CCcontract_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; if ( amount < 0 ) { CCerror = "amount must be positive"; @@ -1413,7 +1413,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet,int32_t odds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CC_info *cp,C; + CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; if ( bet < 0 ) { CCerror = "bet must be positive"; @@ -1472,7 +1472,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout) { CMutableTransaction savemtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CC_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval=0,iswin=0; uint64_t entropyval,sbits; + CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval=0,iswin=0; uint64_t entropyval,sbits; entropyused = zeroid; *resultp = 0; funcid = 0; @@ -1653,7 +1653,7 @@ static uint256 dealer0_fundingtxid; void *dealer0_loop(void *_arg) { char *planstr = (char *)_arg; - CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 hashBlock,entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CC_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 hashBlock,entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); @@ -1749,7 +1749,7 @@ void *dealer0_loop(void *_arg) double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid) { static int32_t didinit; static char _planstr[64]; - CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CC_info *cp,C; int32_t i,entropyvout,flag,win,num,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; + CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,num,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { CCerror = "Diceinit error in status, is your transaction confirmed?"; diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 5239b0d5b..ca2703bff 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -31,7 +31,7 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co char *CClib_name(); Eval* EVAL_TEST = 0; -struct CC_info CCinfos[0x100]; +struct CCcontract_info CCinfos[0x100]; extern pthread_mutex_t KOMODO_CC_mutex; bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn) @@ -62,7 +62,7 @@ bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn) */ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) { - struct CC_info *cp; + struct CCcontract_info *cp; if (cond->codeLength == 0) return Invalid("empty-eval"); diff --git a/src/cc/eval.h b/src/cc/eval.h index 61fdb892d..a42bbdb2f 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -286,8 +286,8 @@ typedef std::pair TxProof; uint256 GetMerkleRoot(const std::vector& vLeaves); -struct CC_info *CCinit(struct CC_info *cp,uint8_t evalcode); -bool ProcessCC(struct CC_info *cp,Eval* eval, std::vector paramsNull, const CTransaction &tx, unsigned int nIn); +struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode); +bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector paramsNull, const CTransaction &tx, unsigned int nIn); #endif /* CC_EVAL_H */ diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index be3ff8a2c..6e59b6c1a 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -28,7 +28,7 @@ // start of consensus code -int64_t IsFaucetvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsFaucetvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -39,7 +39,7 @@ int64_t IsFaucetvout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool FaucetExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool FaucetExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -77,7 +77,7 @@ bool FaucetExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int else return(true); } -bool FaucetValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; std::vector > txids; @@ -140,7 +140,7 @@ bool FaucetValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32 // helper functions for rpc calls in rpcwallet.cpp -int64_t AddFaucetInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; @@ -175,7 +175,7 @@ int64_t AddFaucetInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,i std::string FaucetGet(uint64_t txfee) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,faucetpk; int64_t inputs,CCchange=0,nValue=FAUCETSIZE; struct CC_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CPubKey mypk,faucetpk; int64_t inputs,CCchange=0,nValue=FAUCETSIZE; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_FAUCET); if ( txfee == 0 ) txfee = 10000; @@ -216,7 +216,7 @@ std::string FaucetGet(uint64_t txfee) std::string FaucetFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,faucetpk; CScript opret; struct CC_info *cp,C; + CPubKey mypk,faucetpk; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_FAUCET); if ( txfee == 0 ) txfee = 10000; @@ -234,7 +234,7 @@ UniValue FaucetInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey faucetpk; struct CC_info *cp,C; int64_t funding; + CPubKey faucetpk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Faucet")); cp = CCinit(&C,EVAL_FAUCET); diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index 573299665..0bcc61a1b 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -23,7 +23,7 @@ // start of consensus code -int64_t IsFSMvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsFSMvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -34,7 +34,7 @@ int64_t IsFSMvout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool FSMExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool FSMExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -72,7 +72,7 @@ bool FSMExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_ else return(true); } -bool FSMValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; return eval->Invalid("no validation yet"); @@ -120,7 +120,7 @@ bool FSMValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t // helper functions for rpc calls in rpcwallet.cpp -int64_t AddFSMInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; @@ -158,7 +158,7 @@ std::string FSMList() std::string FSMCreate(uint64_t txfee,std::string name,std::string states) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,fsmpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; + CPubKey mypk,fsmpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_FSM); if ( txfee == 0 ) txfee = 10000; @@ -179,7 +179,7 @@ std::string FSMCreate(uint64_t txfee,std::string name,std::string states) std::string FSMInfo(uint256 fsmtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,fsmpk; int64_t funds = 0; CScript opret; struct CC_info *cp,C; + CPubKey mypk,fsmpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_FSM); mypk = pubkey2pk(Mypubkey()); fsmpk = GetUnspendable(cp,0); diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index f00b1abfd..c64d56b80 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -320,7 +320,7 @@ uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey) return(0); } -int64_t IsGatewaysvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsGatewaysvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -331,7 +331,7 @@ int64_t IsGatewaysvout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool GatewaysExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -429,7 +429,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u return(zeroid); } -int32_t GatewaysCointxidExists(struct CC_info *cp,uint256 cointxid) // dont forget to check mempool! +int32_t GatewaysCointxidExists(struct CCcontract_info *cp,uint256 cointxid) // dont forget to check mempool! { char txidaddr[64]; std::string coin; int32_t numvouts; uint256 hashBlock; std::vector > addressIndex; @@ -515,7 +515,7 @@ int64_t GatewaysDepositval(CTransaction tx,CPubKey mypk) return(0); } -bool GatewaysValidate(struct CC_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) +bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],M,N,taddr,prefix,prefix2; char str[65],destaddr[64],depositaddr[65],validationError[512]; @@ -683,7 +683,7 @@ bool GatewaysValidate(struct CC_info *cp,Eval *eval,const CTransaction &tx, uint // helper functions for rpc calls in rpcwallet.cpp -int64_t AddGatewaysInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 reftokenid,int64_t total,int32_t maxinputs) +int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 reftokenid,int64_t total,int32_t maxinputs) { char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 tokenid,txid,hashBlock; std::vector origpubkey; std::vector vopret; CTransaction vintx; int32_t j,vout,n = 0; uint8_t evalcode,funcid; std::vector > unspentOutputs; @@ -730,7 +730,7 @@ int64_t AddGatewaysInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk return(totalinputs); } -int32_t GatewaysBindExists(struct CC_info *cp,CPubKey gatewayspk,uint256 reftokenid) // dont forget to check mempool! +int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 reftokenid) // dont forget to check mempool! { char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; CTransaction tx; std::vector > addressIndex; @@ -757,7 +757,7 @@ int32_t GatewaysBindExists(struct CC_info *cp,CPubKey gatewayspk,uint256 reftoke std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CC_info *cp,C; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],str[65],*fstr; + CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CCcontract_info *cp,C; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],str[65],*fstr; cp = CCinit(&C,EVAL_GATEWAYS); if ( strcmp((char *)"KMD",coin.c_str()) == 0 ) { @@ -844,7 +844,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction bindtx; CPubKey mypk,gatewayspk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; - int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CC_info *cp,C; + int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CCcontract_info *cp,C; std::vector pubkeys,publishers; std::vectortxids; char str[67],depositaddr[64],txidaddr[64]; cp = CCinit(&C,EVAL_GATEWAYS); @@ -910,7 +910,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CC_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; + CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CCcontract_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; std::string coin, deposithex; std::vector msigpubkeys,publishers; int64_t totalsupply,depositamount,tmpamount,inputs,CCchange=0; int32_t numvouts,claimvout,height; std::vector proof; uint256 hashBlock,tokenid,oracletxid,tmptxid,cointxid; char str[65],depositaddr[64],coinaddr[64],destaddr[64]; std::vector txids; @@ -985,8 +985,8 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin CPubKey mypk, gatewayspk; uint256 tokenid,hashBlock,oracletxid; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; - struct CC_info *cpGateways, gatewaysC; - struct CC_info *cpTokens, tokensC; + struct CCcontract_info *cpGateways, gatewaysC; + struct CCcontract_info *cpTokens, tokensC; cpGateways = CCinit(&gatewaysC, EVAL_GATEWAYS); cpTokens = CCinit(&tokensC, EVAL_TOKENS); @@ -1049,7 +1049,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string hex) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,txidaddrpk,signerpk; struct CC_info *cp,C; CTransaction tx; + CPubKey mypk,txidaddrpk,signerpk; struct CCcontract_info *cp,C; CTransaction tx; std::vector > unspentOutputs; char txidaddr[65]; int32_t maxK,K=0; uint256 tmptxid,parttxid,hashBlock; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1089,7 +1089,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string GatewaysCompleteSigning(uint64_t txfee,uint256 withdrawtxid,std::string refcoin,std::string hex) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,gatewayspk; struct CC_info *cp,C; char txidaddr[65]; + CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); @@ -1104,7 +1104,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 withdrawtxid,std::str std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,gatewayspk; struct CC_info *cp,C; char txidaddr[65]; + CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) @@ -1118,7 +1118,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string tmprefcoin; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; uint256 hashBlock,tokenid,txid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; char depositaddr[64],coinaddr[64],destaddr[64],str[65],withaddr[64],numstr[32],txidaddr[64],cctxidaddr[64],signeraddr[64]; - int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CC_info *cp,C; + int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1186,7 +1186,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string tmprefcoin,hex; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; uint256 withdrawtxid,hashBlock,txid,tokenid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; char depositaddr[64],coinaddr[64],str[65],numstr[32],txidaddr[64],cctxidaddr[64],withaddr[64]; - int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CC_info *cp,C; + int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1278,7 +1278,7 @@ UniValue GatewaysMultisig(char *cctxidaddr) UniValue GatewaysList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); SetCCtxids(addressIndex,cp->unspendableCCaddr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -1298,7 +1298,7 @@ UniValue GatewaysList() UniValue GatewaysInfo(uint256 bindtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaysassets[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CPubKey Gatewayspk; struct CC_info *cp,C; int32_t i; int64_t totalsupply,remaining; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaysassets[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t totalsupply,remaining; result.push_back(Pair("result","success")); result.push_back(Pair("name","Gateways")); cp = CCinit(&C,EVAL_GATEWAYS); diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index c52c9a072..e9c263ff1 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -63,7 +63,7 @@ It is possible to have a jackpot but miss out on it due to not claiming it. To m // start of consensus code -int64_t IsLottovout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsLottovout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -74,7 +74,7 @@ int64_t IsLottovout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool LottoExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool LottoExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -112,7 +112,7 @@ bool LottoExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int3 else return(true); } -bool LottoValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; return eval->Invalid("no validation yet"); @@ -160,7 +160,7 @@ bool LottoValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_ // helper functions for rpc calls in rpcwallet.cpp -int64_t AddLottoInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddLottoInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; @@ -203,7 +203,7 @@ uint8_t DecodeLottoFundingOpRet(const CScript &scriptPubKey,uint64_t &sbits,int3 return(0); } -int64_t LottoPlanFunds(uint64_t refsbits,struct CC_info *cp,CPubKey pk,uint256 reffundingtxid) +int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,uint256 reffundingtxid) { char coinaddr[64]; uint64_t sbits; int64_t nValue,lockedfunds; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t vout; uint8_t funcid; std::vector > unspentOutputs; @@ -232,7 +232,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CC_info *cp,CPubKey pk,uint256 r UniValue LottoInfo(uint256 lottoid) { - UniValue result(UniValue::VOBJ); uint256 hashBlock,hentropy; CTransaction vintx; uint64_t lockedfunds,sbits; int32_t ticketsize,odds,firstheight,period; CPubKey lottopk; struct CC_info *cp,C; char str[67],numstr[65]; + UniValue result(UniValue::VOBJ); uint256 hashBlock,hentropy; CTransaction vintx; uint64_t lockedfunds,sbits; int32_t ticketsize,odds,firstheight,period; CPubKey lottopk; struct CCcontract_info *cp,C; char str[67],numstr[65]; if ( GetTransaction(lottoid,vintx,hashBlock,false) == 0 ) { fprintf(stderr,"cant find lottoid\n"); @@ -264,7 +264,7 @@ UniValue LottoInfo(uint256 lottoid) UniValue LottoList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; cp = CCinit(&C,EVAL_LOTTO); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -284,7 +284,7 @@ UniValue LottoList() std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t ticketsize,int32_t odds,int32_t firstheight,int32_t period) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - uint256 entropy,hentropy; CPubKey mypk,lottopk; uint64_t sbits; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; + uint256 entropy,hentropy; CPubKey mypk,lottopk; uint64_t sbits; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; @@ -303,7 +303,7 @@ std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t tic std::string LottoTicket(uint64_t txfee,uint256 lottoid,int64_t numtickets) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,lottopk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CC_info *cp,C; + CPubKey mypk,lottopk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; @@ -324,7 +324,7 @@ std::string LottoTicket(uint64_t txfee,uint256 lottoid,int64_t numtickets) std::string LottoWinner(uint64_t txfee) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,lottopk; int64_t winnings = 0; CScript opret; struct CC_info *cp,C; + CPubKey mypk,lottopk; int64_t winnings = 0; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 692c496b3..795b95186 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -47,7 +47,7 @@ // start of consensus code -int64_t IsMarmaravout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsMarmaravout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -188,7 +188,7 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { - CTxOut ccvout; struct CC_info *cp,C; CPubKey Marmarapk; + CTxOut ccvout; struct CCcontract_info *cp,C; CPubKey Marmarapk; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) @@ -212,7 +212,7 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk) int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) { - struct CC_info *cp,C; CPubKey Marmarapk,pk; int32_t ht,unlockht; CTxOut ccvout; + struct CCcontract_info *cp,C; CPubKey Marmarapk,pk; int32_t ht,unlockht; CTxOut ccvout; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); if ( 0 ) @@ -255,7 +255,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) return(-1); } -bool MarmaraValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { std::vector vopret; CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid,*script; CPubKey pk,vpk; if ( ASSETCHAINS_MARMARA == 0 ) @@ -326,7 +326,7 @@ bool MarmaraValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint3 // helper functions for rpc calls in rpcwallet.cpp -int64_t AddMarmaraCoinbases(struct CC_info *cp,CMutableTransaction &mtx,int32_t firstheight,CPubKey poolpk,int32_t maxinputs) +int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx,int32_t firstheight,CPubKey poolpk,int32_t maxinputs) { char coinaddr[64]; CPubKey Marmarapk,pk; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction vintx; int32_t unlockht,ht,vout,unlocks,n = 0; std::vector > unspentOutputs; @@ -408,7 +408,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CC_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum=0,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum=0,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; if ( (height & 1) != 0 ) @@ -490,7 +490,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures,height; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; std::vector pubkeys; struct CC_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures,height; int64_t amount,refamount,remaining,inputsum,change; CPubKey Marmarapk,mypk,pk; std::string currency,refcurrency,rawtx; CTransaction tx,batontx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2],txidaddr[64]; std::vector pubkeys; struct CCcontract_info *cp,C; if ( txfee == 0 ) txfee = 10000; cp = CCinit(&C,EVAL_MARMARA); @@ -607,7 +607,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) return(result); } -int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,int64_t &totalclosed,std::vector &closed,struct CC_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) +int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuances,int64_t &totalclosed,std::vector &closed,struct CCcontract_info *cp,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,CPubKey refpk,std::string refcurrency) { char coinaddr[64]; CPubKey Marmarapk,senderpk; int64_t amount; uint256 createtxid,txid,hashBlock; CTransaction tx; int32_t numvouts,vout,matures,n=0; std::string currency; std::vector > unspentOutputs; @@ -643,7 +643,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk; struct CC_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t batonamount; int32_t needbaton = 0; + UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t batonamount; int32_t needbaton = 0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; @@ -700,7 +700,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey mypk,Marmarapk; struct CC_info *cp,C; std::string rawtx; uint256 createtxid; char *errorstr=0; + UniValue result(UniValue::VOBJ); CPubKey mypk,Marmarapk; struct CCcontract_info *cp,C; std::string rawtx; uint256 createtxid; char *errorstr=0; cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; @@ -757,7 +757,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CC_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t numerrs=0,i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey pk; std::string currency,refcurrency; CTransaction tx; char coinaddr[64],myCCaddr[64],destaddr[64],batonCCaddr[64],str[2]; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { @@ -911,7 +911,7 @@ UniValue MarmaraCreditloop(uint256 txid) UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr) // [[pk0, shares0], [pk1, shares1], ...] { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,poolfee=0,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CC_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); cJSON *item,*array; std::string rawtx; int32_t i,n; uint8_t buf[33]; CPubKey Marmarapk,pk,poolpk; int64_t payout,poolfee=0,total,totalpayout=0; double poolshares,share,shares = 0.; char *pkstr,*errorstr=0; struct CCcontract_info *cp,C; poolpk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; @@ -1000,7 +1000,7 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ { CMutableTransaction mtx; std::vector pubkeys; UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); int32_t i,n,matches; int64_t totalclosed=0,totalamount=0; std::vector issuances,closed; char coinaddr[64]; - CPubKey Marmarapk; struct CC_info *cp,C; + CPubKey Marmarapk; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_MARMARA); Marmarapk = GetUnspendable(cp,0); result.push_back(Pair("result","success")); diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index a64f65a18..66c0e1b9a 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -163,7 +163,7 @@ uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint25 return(0); } -CPubKey OracleBatonPk(char *batonaddr,struct CC_info *cp) +CPubKey OracleBatonPk(char *batonaddr,struct CCcontract_info *cp) { static secp256k1_context *ctx; size_t clen = CPubKey::PUBLIC_KEY_SIZE; @@ -256,7 +256,7 @@ static uint256 myIs_baton_spentinmempool(uint256 batontxid,int32_t batonvout) return(batontxid); } -uint256 OracleBatonUtxo(uint64_t txfee,struct CC_info *cp,uint256 reforacletxid,char *batonaddr,CPubKey publisher,std::vector &dataarg) +uint256 OracleBatonUtxo(uint64_t txfee,struct CCcontract_info *cp,uint256 reforacletxid,char *batonaddr,CPubKey publisher,std::vector &dataarg) { uint256 txid,oracletxid,hashBlock,btxid,batontxid = zeroid; int64_t dfee; int32_t dheight=0,vout,height,numvouts; CTransaction tx; CPubKey pk; uint8_t *ptr; std::vector vopret,data; std::vector > unspentOutputs; @@ -302,7 +302,7 @@ uint256 OracleBatonUtxo(uint64_t txfee,struct CC_info *cp,uint256 reforacletxid, uint256 OraclesBatontxid(uint256 reforacletxid,CPubKey refpk) { std::vector > unspentOutputs; - CTransaction regtx; uint256 hash,txid,batontxid,oracletxid; CPubKey pk; int32_t numvouts,height,maxheight=0; int64_t datafee; char markeraddr[64],batonaddr[64]; std::vector data; struct CC_info *cp,C; + CTransaction regtx; uint256 hash,txid,batontxid,oracletxid; CPubKey pk; int32_t numvouts,height,maxheight=0; int64_t datafee; char markeraddr[64],batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; batontxid = zeroid; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,reforacletxid); @@ -528,7 +528,7 @@ int32_t oracleprice_add(std::vector &publishers,CPubKey int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format) { std::vector > unspentOutputs; - CTransaction regtx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CC_info *cp,C; std::vector publishers; std::vector prices; + CTransaction regtx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; std::vector publishers; std::vector prices; if ( format[0] != 'L' ) return(0); cp = CCinit(&C,EVAL_ORACLES); @@ -564,7 +564,7 @@ int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char * return(0); } -int64_t IsOraclesvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsOraclesvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { //char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -575,7 +575,7 @@ int64_t IsOraclesvout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool OraclesDataValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx,uint256 oracletxid,CPubKey publisher,int64_t datafee) +bool OraclesDataValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,uint256 oracletxid,CPubKey publisher,int64_t datafee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; CScript scriptPubKey; @@ -633,7 +633,7 @@ bool OraclesDataValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx,ui else return(true); } -bool OraclesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { uint256 txid,oracletxid,batontxid; uint64_t txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts; uint8_t *script; std::vector vopret,data; CScript scriptPubKey; CPubKey publisher; numvins = tx.vin.size(); @@ -703,7 +703,7 @@ bool OraclesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint3 // helper functions for rpc calls in rpcwallet.cpp -int64_t AddOracleInputs(struct CC_info *cp,CMutableTransaction &mtx,uint256 oracletxid,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint256 oracletxid,CPubKey pk,int64_t total,int32_t maxinputs) { char coinaddr[64],funcid; int64_t nValue,price,totalinputs = 0; uint256 tmporacletxid,tmpbatontxid,txid,hashBlock; std::vector origpubkey,data; CTransaction vintx; int32_t numvouts,vout,n = 0; std::vector > unspentOutputs; CPubKey tmppk; int64_t tmpnum; @@ -741,7 +741,7 @@ int64_t AddOracleInputs(struct CC_info *cp,CMutableTransaction &mtx,uint256 orac return(totalinputs); } -int64_t LifetimeOraclesFunds(struct CC_info *cp,uint256 oracletxid,CPubKey publisher) +int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubKey publisher) { char coinaddr[64]; CPubKey pk; int64_t total=0,num; uint256 txid,hashBlock,subtxid; CTransaction subtx; std::vector > addressIndex; @@ -765,7 +765,7 @@ int64_t LifetimeOraclesFunds(struct CC_info *cp,uint256 oracletxid,CPubKey publi std::string OracleCreate(int64_t txfee,std::string name,std::string description,std::string format) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Oraclespk; struct CC_info *cp,C; char fmt; + CPubKey mypk,Oraclespk; struct CCcontract_info *cp,C; char fmt; cp = CCinit(&C,EVAL_ORACLES); if ( name.size() > 32 || description.size() > 4096 || format.size() > 4096 ) @@ -805,7 +805,7 @@ std::string OracleCreate(int64_t txfee,std::string name,std::string description, std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,markerpubkey,batonpk; struct CC_info *cp,C; char markeraddr[64],batonaddr[64]; + CPubKey mypk,markerpubkey,batonpk; struct CCcontract_info *cp,C; char markeraddr[64],batonaddr[64]; cp = CCinit(&C,EVAL_ORACLES); if ( txfee == 0 ) txfee = 10000; @@ -832,7 +832,7 @@ std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee) std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,markerpubkey; struct CC_info *cp,C; char markeraddr[64]; + CPubKey mypk,markerpubkey; struct CCcontract_info *cp,C; char markeraddr[64]; cp = CCinit(&C,EVAL_ORACLES); if ( txfee == 0 ) txfee = 10000; @@ -852,7 +852,7 @@ std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,i std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector data) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CScript pubKey; CPubKey mypk,batonpk; int64_t offset,datafee,inputs,CCchange = 0; struct CC_info *cp,C; uint256 batontxid,hashBlock; + CScript pubKey; CPubKey mypk,batonpk; int64_t offset,datafee,inputs,CCchange = 0; struct CCcontract_info *cp,C; uint256 batontxid,hashBlock; char coinaddr[64],batonaddr[64]; std::vector prevdata; CTransaction tx; std::string name,description,format; int32_t len,numvouts; cp = CCinit(&C,EVAL_ORACLES); @@ -971,7 +971,7 @@ UniValue OracleInfo(uint256 origtxid) UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector > unspentOutputs; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; struct CC_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; + CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; struct CCcontract_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,origtxid); if ( GetTransaction(origtxid,tx,hashBlock,false) == 0 ) @@ -1025,7 +1025,7 @@ UniValue OracleInfo(uint256 origtxid) UniValue OraclesList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; cp = CCinit(&C,EVAL_ORACLES); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index c25842ea3..859a5ba3f 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -23,7 +23,7 @@ // start of consensus code -int64_t IsPaymentsvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -34,7 +34,7 @@ int64_t IsPaymentsvout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool PaymentsExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool PaymentsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -72,7 +72,7 @@ bool PaymentsExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,i else return(true); } -bool PaymentsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; return eval->Invalid("no validation yet"); @@ -113,7 +113,7 @@ bool PaymentsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint // helper functions for rpc calls in rpcwallet.cpp -int64_t AddPaymentsInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -145,7 +145,7 @@ int64_t AddPaymentsInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk std::string PaymentsGet(uint64_t txfee,int64_t nValue) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Paymentspk; int64_t inputs,CCchange=0; struct CC_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CPubKey mypk,Paymentspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_PAYMENTS); if ( txfee == 0 ) txfee = 10000; @@ -186,7 +186,7 @@ std::string PaymentsGet(uint64_t txfee,int64_t nValue) std::string PaymentsFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Paymentspk; CScript opret; struct CC_info *cp,C; + CPubKey mypk,Paymentspk; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_PAYMENTS); if ( txfee == 0 ) txfee = 10000; @@ -204,7 +204,7 @@ UniValue PaymentsInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey Paymentspk; struct CC_info *cp,C; int64_t funding; + CPubKey Paymentspk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Payments")); cp = CCinit(&C,EVAL_PAYMENTS); diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index d137778a6..e2893bec8 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -30,7 +30,7 @@ // start of consensus code -int64_t IsPegsvout(struct CC_info *cp,const CTransaction& tx,int32_t v) +int64_t IsPegsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -41,7 +41,7 @@ int64_t IsPegsvout(struct CC_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool PegsExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool PegsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -79,7 +79,7 @@ bool PegsExactAmounts(struct CC_info *cp,Eval* eval,const CTransaction &tx,int32 else return(true); } -bool PegsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; return eval->Invalid("no validation yet"); @@ -120,7 +120,7 @@ bool PegsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t // helper functions for rpc calls in rpcwallet.cpp -int64_t AddPegsInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) { // add threshold check char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -152,7 +152,7 @@ int64_t AddPegsInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int std::string PegsGet(uint64_t txfee,int64_t nValue) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Pegspk; int64_t inputs,CCchange=0; struct CC_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CPubKey mypk,Pegspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_PEGS); if ( txfee == 0 ) txfee = 10000; @@ -193,7 +193,7 @@ std::string PegsGet(uint64_t txfee,int64_t nValue) std::string PegsFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Pegspk; CScript opret; struct CC_info *cp,C; + CPubKey mypk,Pegspk; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_PEGS); if ( txfee == 0 ) txfee = 10000; @@ -211,7 +211,7 @@ UniValue PegsInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey Pegspk; struct CC_info *cp,C; int64_t funding; + CPubKey Pegspk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Pegs")); cp = CCinit(&C,EVAL_PEGS); diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 6171e73a8..369495b1a 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -86,7 +86,7 @@ uint8_t DecodePricesFundingOpRet(CScript scriptPubKey,CPubKey &planpk,uint256 &o return(0); } -bool PricesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; return eval->Invalid("no validation yet"); @@ -127,7 +127,7 @@ bool PricesValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32 // helper functions for rpc calls in rpcwallet.cpp -int64_t AddTokensInputs(struct CC_info *cp,CMutableTransaction &mtx,char *destaddr,uint256 tolenid,int64_t total,int32_t maxinputs) +int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char *destaddr,uint256 tolenid,int64_t total,int32_t maxinputs) { // add threshold check int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -158,7 +158,7 @@ int64_t AddTokensInputs(struct CC_info *cp,CMutableTransaction &mtx,char *destad UniValue PricesList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint64_t mode; int32_t margin,maxleverage; std::vectorpubkeys; uint256 txid,hashBlock,oracletxid,longtoken,shorttoken,bettoken; CPubKey planpk,pricespk; char str[65]; CTransaction vintx; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint64_t mode; int32_t margin,maxleverage; std::vectorpubkeys; uint256 txid,hashBlock,oracletxid,longtoken,shorttoken,bettoken; CPubKey planpk,pricespk; char str[65]; CTransaction vintx; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); SetCCtxids(addressIndex,cp->normaladdr); @@ -183,7 +183,7 @@ UniValue PricesList() std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletxid,uint64_t margin,uint64_t mode,uint256 longtoken,uint256 shorttoken,int32_t maxleverage,int64_t funding,std::vector pubkeys) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CC_info *cp,C; + CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CCcontract_info *cp,C; if ( funding < 100*COIN || maxleverage <= 0 || maxleverage > 10000 ) { CCerror = "invalid parameter error"; @@ -246,7 +246,7 @@ std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletx UniValue PricesInfo(uint256 fundingtxid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); CPubKey pricespk,planpk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction vintx; int64_t balance,supply,exposure; uint64_t funding,mode; int32_t i,margin,maxleverage; char numstr[65],houseaddr[64],exposureaddr[64],str[65]; std::vectorpubkeys; struct CC_info *cp,C; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); CPubKey pricespk,planpk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction vintx; int64_t balance,supply,exposure; uint64_t funding,mode; int32_t i,margin,maxleverage; char numstr[65],houseaddr[64],exposureaddr[64],str[65]; std::vectorpubkeys; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); if ( GetTransaction(fundingtxid,vintx,hashBlock,false) == 0 ) @@ -295,7 +295,7 @@ UniValue PricesInfo(uint256 fundingtxid) std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CC_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,CCchange = 0; uint64_t funding,mode; int32_t margin,maxleverage; char houseaddr[64],myaddr[64]; std::vectorpubkeys; + struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,CCchange = 0; uint64_t funding,mode; int32_t margin,maxleverage; char houseaddr[64],myaddr[64]; std::vectorpubkeys; if ( amount < 10000 ) { CCerror = "amount must be positive"; @@ -350,7 +350,7 @@ std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingt std::string PricesBet(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount,int32_t leverage) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CC_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; + struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; if ( amount < 0 ) { amount = -amount; diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index c47fcf1c2..bd5a6d919 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -141,7 +141,7 @@ uint8_t DecodeRewardsOpRet(uint256 txid,const CScript &scriptPubKey,uint64_t &sb return(0); } -int64_t IsRewardsvout(struct CC_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) +int64_t IsRewardsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid) { char destaddr[64]; uint64_t sbits; uint256 fundingtxid,txid; uint8_t funcid; int32_t numvouts; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 && (numvouts= (int32_t)tx.vout.size()) > 0 ) @@ -157,7 +157,7 @@ int64_t IsRewardsvout(struct CC_info *cp,const CTransaction& tx,int32_t v,uint64 return(0); } -bool RewardsExactAmounts(struct CC_info *cp,Eval *eval,const CTransaction &tx,uint64_t txfee,uint64_t refsbits,uint256 reffundingtxid) +bool RewardsExactAmounts(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx,uint64_t txfee,uint64_t refsbits,uint256 reffundingtxid) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -192,7 +192,7 @@ bool RewardsExactAmounts(struct CC_info *cp,Eval *eval,const CTransaction &tx,ui else return(true); } -bool RewardsValidate(struct CC_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { uint256 txid,fundingtxid,hashBlock,vinfundingtxid; uint64_t vinsbits,sbits,APR,minseconds,maxseconds,mindeposit,amount,reward,txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; uint8_t funcid; CScript scriptPubKey; CTransaction fundingTx,vinTx; numvins = tx.vin.size(); @@ -327,7 +327,7 @@ static uint64_t myIs_unlockedtx_inmempool(uint256 &txid,int32_t &vout,uint64_t r } // 'L' vs 'F' and 'A' -int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) +int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,uint64_t refsbits,uint256 reffundingtxid) { char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t numblocks,j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; @@ -387,7 +387,7 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CC_inf return(totalinputs); } -int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CC_info *cp,CPubKey pk,uint256 reffundingtxid) +int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,uint256 reffundingtxid) { char coinaddr[64]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t vout; uint8_t funcid; std::vector > unspentOutputs; @@ -418,7 +418,7 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CC_info return(totalinputs); } -bool RewardsPlanExists(struct CC_info *cp,uint64_t refsbits,CPubKey rewardspk,uint64_t &APR,uint64_t &minseconds,uint64_t &maxseconds,uint64_t &mindeposit) +bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewardspk,uint64_t &APR,uint64_t &minseconds,uint64_t &maxseconds,uint64_t &mindeposit) { char CCaddr[64]; uint64_t sbits; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; @@ -443,7 +443,7 @@ bool RewardsPlanExists(struct CC_info *cp,uint64_t refsbits,CPubKey rewardspk,ui UniValue RewardsInfo(uint256 rewardsid) { - UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; uint64_t lockedfunds,APR,minseconds,maxseconds,mindeposit,sbits,funding; CPubKey rewardspk; struct CC_info *cp,C; char str[67],numstr[65]; + UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; uint64_t lockedfunds,APR,minseconds,maxseconds,mindeposit,sbits,funding; CPubKey rewardspk; struct CCcontract_info *cp,C; char str[67],numstr[65]; if ( GetTransaction(rewardsid,vintx,hashBlock,false) == 0 ) { fprintf(stderr,"cant find fundingtxid\n"); @@ -481,7 +481,7 @@ UniValue RewardsInfo(uint256 rewardsid) UniValue RewardsList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CC_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; cp = CCinit(&C,EVAL_REWARDS); SetCCtxids(addressIndex,cp->normaladdr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -501,7 +501,7 @@ UniValue RewardsList() std::string RewardsCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t APR,int64_t minseconds,int64_t maxseconds,int64_t mindeposit) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CC_info *cp,C; + CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; if ( funds < COIN || mindeposit < 0 || minseconds < 0 || maxseconds < 0 ) { fprintf(stderr,"negative parameter error\n"); @@ -536,7 +536,7 @@ std::string RewardsCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int6 std::string RewardsAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CC_info *cp,C; + CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; if ( amount < 0 ) { fprintf(stderr,"negative parameter error\n"); @@ -571,7 +571,7 @@ std::string RewardsAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,i std::string RewardsLock(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t deposit) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,rewardspk; CScript opret; uint64_t lockedfunds,sbits,funding,APR,minseconds,maxseconds,mindeposit; struct CC_info *cp,C; + CPubKey mypk,rewardspk; CScript opret; uint64_t lockedfunds,sbits,funding,APR,minseconds,maxseconds,mindeposit; struct CCcontract_info *cp,C; if ( deposit < txfee ) { CCerror = "deposit amount less than txfee"; @@ -615,7 +615,7 @@ std::string RewardsLock(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 locktxid) { CMutableTransaction firstmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; char coinaddr[64]; CPubKey mypk,rewardspk; CScript scriptPubKey,ignore; uint256 hashBlock; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; int64_t funding,reward=0,amount=0,inputs,CCchange=0; struct CC_info *cp,C; + CTransaction tx; char coinaddr[64]; CPubKey mypk,rewardspk; CScript scriptPubKey,ignore; uint256 hashBlock; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; int64_t funding,reward=0,amount=0,inputs,CCchange=0; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_REWARDS); if ( txfee == 0 ) txfee = 10000; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 51b31c5c7..10c6ee4b8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2150,7 +2150,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { - struct CC_info *cp,C; uint256 txid; int32_t vout; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk; + struct CCcontract_info *cp,C; uint256 txid; int32_t vout; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 588706a41..2db63d83a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5197,7 +5197,7 @@ int32_t ensure_CCrequirements() #include "../cc/CCHeir.h" #include "../cc/CCMarmara.h" -UniValue CCaddress(struct CC_info *cp,char *name,std::vector &pubkey) +UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector &pubkey) { UniValue result(UniValue::VOBJ); char destaddr[64],str[64]; CPubKey pk; pk = GetUnspendable(cp,0); @@ -5302,7 +5302,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) UniValue channelsaddress(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::vector destpubkey; CPubKey pk,pk2; char destaddr[64]; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector destpubkey; CPubKey pk,pk2; char destaddr[64]; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 1 ) throw runtime_error("channelsaddress destpubkey\n"); @@ -5329,7 +5329,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) UniValue cclibaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_FIRSTUSER); if ( fHelp || params.size() > 1 ) throw runtime_error("cclibaddress [pubkey]\n"); @@ -5342,7 +5342,7 @@ UniValue cclibaddress(const UniValue& params, bool fHelp) UniValue cclibinfo(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; + struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_FIRSTUSER); if ( fHelp || params.size() > 0 ) throw runtime_error("cclibinfo\n"); @@ -5353,7 +5353,7 @@ UniValue cclibinfo(const UniValue& params, bool fHelp) UniValue cclib(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; char *method; cJSON *params; + struct CCcontract_info *cp,C; char *method; cJSON *params; cp = CCinit(&C,EVAL_FIRSTUSER); if ( fHelp || params.size() > 2 ) throw runtime_error("cclib method [JSON params]\n"); @@ -5366,7 +5366,7 @@ UniValue cclib(const UniValue& params, bool fHelp) UniValue oraclesaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_ORACLES); if ( fHelp || params.size() > 1 ) throw runtime_error("oraclesaddress [pubkey]\n"); @@ -5379,7 +5379,7 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp) UniValue pricesaddress(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CC_info *cp,C,*assetscp,C2; std::vector pubkey; CPubKey mypk,planpk,pricespk; char myaddr[64],houseaddr[64],exposureaddr[64]; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C,*assetscp,C2; std::vector pubkey; CPubKey mypk,planpk,pricespk; char myaddr[64],houseaddr[64],exposureaddr[64]; cp = CCinit(&C,EVAL_PRICES); assetscp = CCinit(&C2,EVAL_PRICES); if ( fHelp || params.size() > 1 ) @@ -5402,7 +5402,7 @@ UniValue pricesaddress(const UniValue& params, bool fHelp) UniValue pegsaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_PEGS); if ( fHelp || params.size() > 1 ) throw runtime_error("pegssaddress [pubkey]\n"); @@ -5415,7 +5415,7 @@ UniValue pegsaddress(const UniValue& params, bool fHelp) UniValue marmaraaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_MARMARA); if ( fHelp || params.size() > 1 ) throw runtime_error("Marmaraaddress [pubkey]\n"); @@ -5428,7 +5428,7 @@ UniValue marmaraaddress(const UniValue& params, bool fHelp) UniValue paymentsaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_PAYMENTS); if ( fHelp || params.size() > 1 ) throw runtime_error("paymentsaddress [pubkey]\n"); @@ -5441,7 +5441,7 @@ UniValue paymentsaddress(const UniValue& params, bool fHelp) UniValue gatewaysaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_GATEWAYS); if ( fHelp || params.size() > 1 ) throw runtime_error("gatewaysaddress [pubkey]\n"); @@ -5454,7 +5454,7 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) UniValue heiraddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_HEIR); if ( fHelp || params.size() > 1 ) throw runtime_error("heiraddress [pubkey]\n"); @@ -5469,7 +5469,7 @@ UniValue heiraddress(const UniValue& params, bool fHelp) UniValue lottoaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_LOTTO); if ( fHelp || params.size() > 1 ) throw runtime_error("lottoaddress [pubkey]\n"); @@ -5482,7 +5482,7 @@ UniValue lottoaddress(const UniValue& params, bool fHelp) UniValue FSMaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_FSM); if ( fHelp || params.size() > 1 ) throw runtime_error("FSMaddress [pubkey]\n"); @@ -5495,7 +5495,7 @@ UniValue FSMaddress(const UniValue& params, bool fHelp) UniValue auctionaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_AUCTION); if ( fHelp || params.size() > 1 ) throw runtime_error("auctionaddress [pubkey]\n"); @@ -5508,7 +5508,7 @@ UniValue auctionaddress(const UniValue& params, bool fHelp) UniValue diceaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_DICE); if ( fHelp || params.size() > 1 ) throw runtime_error("diceaddress [pubkey]\n"); @@ -5521,7 +5521,7 @@ UniValue diceaddress(const UniValue& params, bool fHelp) UniValue faucetaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; int errno; cp = CCinit(&C,EVAL_FAUCET); if ( fHelp || params.size() > 1 ) @@ -5536,7 +5536,7 @@ UniValue faucetaddress(const UniValue& params, bool fHelp) UniValue rewardsaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_REWARDS); if ( fHelp || params.size() > 1 ) throw runtime_error("rewardsaddress [pubkey]\n"); @@ -5549,7 +5549,7 @@ UniValue rewardsaddress(const UniValue& params, bool fHelp) UniValue assetsaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp, C; std::vector pubkey; + struct CCcontract_info *cp, C; std::vector pubkey; cp = CCinit(&C, EVAL_ASSETS); if (fHelp || params.size() > 1) throw runtime_error("assetsaddress [pubkey]\n"); @@ -5562,7 +5562,7 @@ UniValue assetsaddress(const UniValue& params, bool fHelp) UniValue tokenaddress(const UniValue& params, bool fHelp) { - struct CC_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_TOKENS); if ( fHelp || params.size() > 1 ) throw runtime_error("tokenaddress [pubkey]\n"); @@ -5767,7 +5767,7 @@ UniValue channelsinfo(const UniValue& params, bool fHelp) UniValue channelsopen(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); int32_t numpayments; int64_t payment; std::vector destpub; struct CC_info *cp,C; std::string hex; + UniValue result(UniValue::VOBJ); int32_t numpayments; int64_t payment; std::vector destpub; struct CCcontract_info *cp,C; std::string hex; uint256 tokenid=zeroid; cp = CCinit(&C,EVAL_CHANNELS); @@ -5810,7 +5810,7 @@ UniValue channelsopen(const UniValue& params, bool fHelp) UniValue channelspayment(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::string hex; uint256 opentxid,secret=zeroid; int32_t n; int64_t amount; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid,secret=zeroid; int32_t n; int64_t amount; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() < 2 || params.size() >3 ) throw runtime_error("channelspayment opentxid amount [secret]\n"); @@ -5840,7 +5840,7 @@ UniValue channelspayment(const UniValue& params, bool fHelp) UniValue channelsclose(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::string hex; uint256 opentxid; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 1 ) throw runtime_error("channelsclose opentxid\n"); @@ -5860,7 +5860,7 @@ UniValue channelsclose(const UniValue& params, bool fHelp) UniValue channelsrefund(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CC_info *cp,C; std::string hex; uint256 opentxid,closetxid; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid,closetxid; cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 2 ) throw runtime_error("channelsrefund opentxid closetxid\n"); @@ -6914,7 +6914,7 @@ UniValue tokenorders(const UniValue& params, bool fHelp) UniValue tokenbalance(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 tokenid; uint64_t balance; std::vector pubkey; struct CC_info *cp,C; + UniValue result(UniValue::VOBJ); uint256 tokenid; uint64_t balance; std::vector pubkey; struct CCcontract_info *cp,C; CCerror.clear(); if ( fHelp || params.size() > 2 ) From 5f0b70615fa80550e6304988706e4be360e0e6d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:37:48 -1100 Subject: [PATCH 1342/3904] Jsonparams --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2db63d83a..5231dae27 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5353,15 +5353,15 @@ UniValue cclibinfo(const UniValue& params, bool fHelp) UniValue cclib(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *method; cJSON *params; + struct CCcontract_info *cp,C; char *method; cJSON *jsonparams; cp = CCinit(&C,EVAL_FIRSTUSER); if ( fHelp || params.size() > 2 ) throw runtime_error("cclib method [JSON params]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); method = params[0].get_str().c_str(); - params = cJSON_Parse(params[1].get_str().c_str()); - return(CClib(cp,method,params)); + jsonparams = cJSON_Parse(params[1].get_str().c_str()); + return(CClib(cp,method,jsonparams)); } UniValue oraclesaddress(const UniValue& params, bool fHelp) From 01d2fa36a2997d57f30089bc4b46854b36cd023d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:38:48 -1100 Subject: [PATCH 1343/3904] UniValue CClib_info(struct CCcontract_info *cp) --- src/cc/CCinclude.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 82c9484d5..258d8b95b 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -135,6 +135,8 @@ int32_t komodo_nextheight(); int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 txid,int32_t vout); void CCclearvars(struct CCcontract_info *cp); +UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params); +UniValue CClib_info(struct CCcontract_info *cp); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); From b4e0b6bca4676407145b640f48101846ade1ee57 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:54:51 -1100 Subject: [PATCH 1344/3904] Faucet2 --- src/cc/cclib.cpp | 220 ++++++++++++++++++++++++++++++++++++++- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 219 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 0f201acc4..23f3d81c9 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -27,6 +27,8 @@ #include "core_io.h" #include "crosschain.h" +#define FAUCET2SIZE COIN + struct CClib_rpcinfo { char *method,*help; @@ -35,6 +37,7 @@ struct CClib_rpcinfo } CClib_methods[] = { + { "faucet2_fund", "amount", 1, 1, 'F' }, { "faucet2_get", "", 0, 0, 'G' }, }; @@ -90,12 +93,225 @@ UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) return(result); } +int64_t IsCClibvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +{ + char destaddr[64]; + if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) + { + if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) + return(tx.vout[v].nValue); + } + return(0); +} + +bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +{ + static uint256 zerohash; + CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; + numvins = tx.vin.size(); + numvouts = tx.vout.size(); + for (i=0; iismyvin)(tx.vin[i].scriptSig) != 0 ) + { + //fprintf(stderr,"vini.%d check mempool\n",i); + if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) + return eval->Invalid("cant find vinTx"); + else + { + //fprintf(stderr,"vini.%d check hash and vout\n",i); + if ( hashBlock == zerohash ) + return eval->Invalid("cant faucet2 from mempool"); + if ( (assetoshis= IsCClibvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) + inputs += assetoshis; + } + } + } + for (i=0; iInvalid("mismatched inputs != outputs + FAUCET2SIZE + txfee"); + } + else return(true); +} + bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction &txTo,unsigned int nIn) { - return(true); // for now + int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; + std::vector > txids; + numvins = tx.vin.size(); + numvouts = tx.vout.size(); + preventCCvins = preventCCvouts = -1; + if ( numvouts < 1 ) + return eval->Invalid("no vouts"); + else + { + for (i=0; iInvalid("illegal normal vini"); + } + } + //fprintf(stderr,"check amounts\n"); + if ( CClibExactAmounts(cp,eval,tx,1,10000) == false ) + { + fprintf(stderr,"faucetget invalid amount\n"); + return false; + } + else + { + preventCCvouts = 1; + if ( IsFaucetvout(cp,tx,0) != 0 ) + { + preventCCvouts++; + i = 1; + } else i = 0; + txid = tx.GetHash(); + memcpy(hash,&txid,sizeof(hash)); + fprintf(stderr,"check faucetget txid %s %02x/%02x\n",uint256_str(str,txid),hash[0],hash[31]); + if ( tx.vout[i].nValue != FAUCET2SIZE ) + return eval->Invalid("invalid faucet output"); + else if ( (hash[0] & 0xff) != 0 || (hash[31] & 0xff) != 0 ) + return eval->Invalid("invalid faucetget txid"); + Getscriptaddress(destaddr,tx.vout[i].scriptPubKey); + SetCCtxids(txids,destaddr); + for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + { + //int height = it->first.blockHeight; + if ( CCduration(numblocks,it->first.txhash) > 0 && numblocks > 3 ) + { + //fprintf(stderr,"would return error %s numblocks.%d ago\n",uint256_str(str,it->first.txhash),numblocks); + return eval->Invalid("faucet2 is only for brand new addresses"); + } + } + retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); + if ( retval != 0 ) + fprintf(stderr,"faucet2get validated\n"); + else fprintf(stderr,"faucet2get invalid\n"); + return(retval); + } + } +} + +int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +{ + char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; + std::vector > unspentOutputs; + GetCCaddress(cp,coinaddr,pk); + SetCCunspents(unspentOutputs,coinaddr); + threshold = total/(maxinputs+1); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if ( it->second.satoshis < threshold ) + continue; + //char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + // no need to prevent dup + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + { + if ( (nValue= IsCClibvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + if ( total != 0 && maxinputs != 0 ) + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + nValue = it->second.satoshis; + totalinputs += nValue; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) + break; + } else fprintf(stderr,"nValue too small or already spent in mempool\n"); + } else fprintf(stderr,"couldnt get tx\n"); + } + return(totalinputs); +} + + +std::string Faucet2Fund(struct CCcontract_info *cp,uint64_t txfee,int64_t funds) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,cclibpk; CScript opret; + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + cclibpk = GetUnspendable(cp,0); + if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,funds,cclibpk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); + } + return(""); +} + +UniValue FaucetInfo() +{ + UniValue result(UniValue::VOBJ); char numstr[64]; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey faucetpk; struct CCcontract_info *cp,C; int64_t funding; + result.push_back(Pair("result","success")); + result.push_back(Pair("name","Faucet")); + cp = CCinit(&C,EVAL_FAUCET); + faucetpk = GetUnspendable(cp,0); + funding = AddFaucetInputs(cp,mtx,faucetpk,0,0); + sprintf(numstr,"%.8f",(double)funding/COIN); + result.push_back(Pair("funding",numstr)); + return(result); } std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params) { - return((char *)"deadbeef"); + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,cclibpk; int64_t funds,txfee=0,inputs,CCchange=0,nValue=FAUCET2SIZE; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + if ( txfee == 0 ) + txfee = 10000; + if ( funcid == 'F' ) + { + if ( cJSON_GetArraySize(params) > 0 ) + { + funds = (int64_t)jdouble(jarrayi(params,0))*COIN + 0.0000000049; + return(Faucet2Fund(cp,0,funds)); + } else return(""); + } + else if ( funcid != 'G' ) + return(""); + cclibpk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + if ( (inputs= AddCClibInputs(cp,mtx,cclibpk,nValue+txfee,60)) > 0 ) + { + if ( inputs > nValue ) + CCchange = (inputs - nValue - txfee); + if ( CCchange != 0 ) + mtx.vout.push_back(MakeCC1vout(EVAL_FIRSTUSER,CCchange,cclibpk)); + mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + fprintf(stderr,"start at %u\n",(uint32_t)time(NULL)); + j = rand() & 0xfffffff; + for (i=0; i<1000000; i++,j++) + { + tmpmtx = mtx; + rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_FIRSTUSER << (uint8_t)'G' << j)); + if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 ) + { + len >>= 1; + decode_hex(buf,len,(char *)rawhex.c_str()); + hash = bits256_doublesha256(0,buf,len); + if ( (hash.bytes[0] & 0xff) == 0 && (hash.bytes[31] & 0xff) == 0 ) + { + fprintf(stderr,"found valid txid after %d iterations %u\n",i,(uint32_t)time(NULL)); + return(rawhex); + } + //fprintf(stderr,"%02x%02x ",hash.bytes[0],hash.bytes[31]); + } + } + fprintf(stderr,"couldnt generate valid txid %u\n",(uint32_t)time(NULL)); + return(""); + } else fprintf(stderr,"cant find faucet inputs\n"); + return(""); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5231dae27..174f447f0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5359,7 +5359,7 @@ UniValue cclib(const UniValue& params, bool fHelp) throw runtime_error("cclib method [JSON params]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - method = params[0].get_str().c_str(); + method = (char *)params[0].get_str().c_str(); jsonparams = cJSON_Parse(params[1].get_str().c_str()); return(CClib(cp,method,jsonparams)); } From 1cf8cec01899d993380d9c9631db3b63102d43a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Jan 2019 23:58:36 -1100 Subject: [PATCH 1345/3904] Item --- src/cc/CCutils.cpp | 2 +- src/cc/cclib.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 3670859cc..67ee7d5db 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -638,7 +638,7 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector param extern struct CCcontract_info CCinfos[0x100]; extern std::string MYCCLIBNAME; -bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction &txTo,unsigned int nIn); +bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction tx,unsigned int nIn); bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 23f3d81c9..d727dd8cd 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -37,13 +37,13 @@ struct CClib_rpcinfo } CClib_methods[] = { - { "faucet2_fund", "amount", 1, 1, 'F' }, - { "faucet2_get", "", 0, 0, 'G' }, + { (char *)"faucet2_fund", (char *)"amount", 1, 1, 'F' }, + { (char *)"faucet2_get", (char *)"", 0, 0, 'G' }, }; -std::string MYCCLIBNAME = (char *)"stub"; +std::string MYCCLIBNAME = (char *)"faucet2"; -char *CClib_name() { return(MYCCLIBNAME); } +char *CClib_name() { return(MYCCLIBNAME.c_str()); } std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); @@ -67,7 +67,7 @@ UniValue CClib_info(struct CCcontract_info *cp) obj.push_back(Pair("help",CClib_methods[i].help)); obj.push_back(Pair("params_required",CClib_methods[i].numrequiredargs)); obj.push_back(Pair("params_max",CClib_methods[i].maxargs)); - a.push_back(obj)); + a.push_back(obj); } result.push_back(Pair("methods",a)); return(result); @@ -134,7 +134,7 @@ bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction if ( (assetoshis= IsCClibvout(cp,tx,i)) != 0 ) outputs += assetoshis; } - if ( inputs != outputs+FAUCETSIZE+txfee ) + if ( inputs != outputs+FAUCET2SIZE+txfee ) { fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); return eval->Invalid("mismatched inputs != outputs + FAUCET2SIZE + txfee"); @@ -142,7 +142,7 @@ bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction else return(true); } -bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction &txTo,unsigned int nIn) +bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction tx,unsigned int nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; std::vector > txids; @@ -276,7 +276,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para { if ( cJSON_GetArraySize(params) > 0 ) { - funds = (int64_t)jdouble(jarrayi(params,0))*COIN + 0.0000000049; + funds = (int64_t)jdouble(jitem(params,0))*COIN + 0.0000000049; return(Faucet2Fund(cp,0,funds)); } else return(""); } From 887f6cb2ab2ab3b3f9d76bb47136241c9b906908 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 00:00:51 -1100 Subject: [PATCH 1346/3904] Test --- src/cc/CCinclude.h | 1 + src/cc/cclib.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 258d8b95b..451b87dd9 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -50,6 +50,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../komodo_defs.h" #include "../utlist.h" #include "../uthash.h" +#include "../cJSON.h" extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index d727dd8cd..7202dd7c6 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -43,7 +43,7 @@ CClib_methods[] = std::string MYCCLIBNAME = (char *)"faucet2"; -char *CClib_name() { return(MYCCLIBNAME.c_str()); } +char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); @@ -170,7 +170,7 @@ bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction tx, else { preventCCvouts = 1; - if ( IsFaucetvout(cp,tx,0) != 0 ) + if ( IsCClibvout(cp,tx,0) != 0 ) { preventCCvouts++; i = 1; @@ -251,7 +251,7 @@ std::string Faucet2Fund(struct CCcontract_info *cp,uint64_t txfee,int64_t funds) return(""); } -UniValue FaucetInfo() +/*UniValue FaucetInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -264,12 +264,12 @@ UniValue FaucetInfo() sprintf(numstr,"%.8f",(double)funding/COIN); result.push_back(Pair("funding",numstr)); return(result); -} +}*/ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,cclibpk; int64_t funds,txfee=0,inputs,CCchange=0,nValue=FAUCET2SIZE; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CPubKey mypk,cclibpk; int64_t funds,txfee=0,inputs,CCchange=0,nValue=FAUCET2SIZE; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; if ( txfee == 0 ) txfee = 10000; if ( funcid == 'F' ) From 0ceca4c74546eea83ee528dec75542f8b7f1afc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 00:01:18 -1100 Subject: [PATCH 1347/3904] komodo_cJSON.h --- src/cc/CCinclude.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 451b87dd9..4cb658681 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -50,7 +50,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../komodo_defs.h" #include "../utlist.h" #include "../uthash.h" -#include "../cJSON.h" +#include "../komodo_cJSON.h" extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; From 53b2d35da7d084ee3c28a8aa144183bd91a6f2af Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 00:03:36 -1100 Subject: [PATCH 1348/3904] Bit256 --- src/cc/CCinclude.h | 2 +- src/cc/cclib.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 4cb658681..1953fad34 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -50,7 +50,6 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../komodo_defs.h" #include "../utlist.h" #include "../uthash.h" -#include "../komodo_cJSON.h" extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; @@ -70,6 +69,7 @@ extern uint8_t ASSETCHAINS_CCDISABLES[256]; typedef union _bits256 bits256; #endif +#include "../komodo_cJSON.h" struct CC_utxo { diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 7202dd7c6..5a9c3b4af 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -276,7 +276,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para { if ( cJSON_GetArraySize(params) > 0 ) { - funds = (int64_t)jdouble(jitem(params,0))*COIN + 0.0000000049; + funds = (int64_t)jdouble(jitem(params,0),0)*COIN + 0.0000000049; return(Faucet2Fund(cp,0,funds)); } else return(""); } From f7b6af7b3faac79ba62a8d2bec410c4490de555a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 20 Jan 2019 19:11:31 +0800 Subject: [PATCH 1349/3904] ac_founders_reward test for Alright --- src/komodo_bitcoind.h | 13 +++++++++---- src/komodo_globals.h | 2 +- src/komodo_utils.h | 11 ++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4117347b6..e38436c71 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1151,7 +1151,12 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if ( ASSETCHAINS_FOUNDERS > 1 ) { if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) - commission = commission * ASSETCHAINS_FOUNDERS; + { + if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) + commission = commission * ASSETCHAINS_FOUNDERS; + else + commission = ASSETCHAINS_FOUNDERS_REWARD; + } else commission = 0; } } @@ -1820,15 +1825,15 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else { // I think this means the block is valid PoW. We need to set the pindex->segid here. - failed = 0; - CBlockIndex *pindex; + failed = 0; + CBlockIndex *pindex; BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } - } + } } } else if ( is_PoSblock < 0 ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 244655f5f..d5c6ca27e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -92,7 +92,7 @@ int32_t ASSETCHAINS_SAPLING = -1; int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS, ASSETCHAINS_FOUNDERS_REWARD; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 17e849338..a86c993e8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1777,6 +1777,7 @@ void komodo_args(char *argv0) MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; + ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); @@ -1809,7 +1810,7 @@ void komodo_args(char *argv0) } // else it can be gateway coin - + if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1835,13 +1836,17 @@ void komodo_args(char *argv0) decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); } - if ( ASSETCHAINS_COMMISSION == 0 ) + if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { - if (ASSETCHAINS_FOUNDERS != 0 ) + if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) { ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } + else + { + printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); + } /*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) { //ASSETCHAINS_OVERRIDE_PUBKEY.clear(); From fc506524584f7fa722fdce60f58d4855f6aec1fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 06:24:55 -1100 Subject: [PATCH 1350/3904] Change error handling --- src/cc/CCutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 67ee7d5db..58496333a 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -673,7 +673,7 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co return eval->Invalid("Cannot have params"); else if ( CClib_validate(cp,eval,txTo,nIn) != 0 ) return(true); - return eval->Invalid("error in CClib_validate"); + return(false); //eval->Invalid("error in CClib_validate"); } return eval->Invalid("cclib CC must have evalcode between 16 and 127"); } From 7bf38b4fdb2b9313c74c9866cf6844dc4b84368c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 06:54:59 -1100 Subject: [PATCH 1351/3904] Pass in height to cclib_validate --- src/cc/CCutils.cpp | 4 ++-- src/cc/cclib.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 58496333a..4eb6fbbc1 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -638,7 +638,7 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector param extern struct CCcontract_info CCinfos[0x100]; extern std::string MYCCLIBNAME; -bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction tx,unsigned int nIn); +bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx,unsigned int nIn); bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,const CTransaction &txTo,unsigned int nIn) { @@ -671,7 +671,7 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co CCclearvars(cp); if ( paramsNull.size() != 0 ) // Don't expect params return eval->Invalid("Cannot have params"); - else if ( CClib_validate(cp,eval,txTo,nIn) != 0 ) + else if ( CClib_validate(cp,height,eval,txTo,nIn) != 0 ) return(true); return(false); //eval->Invalid("error in CClib_validate"); } diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 5a9c3b4af..971258d90 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -142,7 +142,7 @@ bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction else return(true); } -bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction tx,unsigned int nIn) +bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx,unsigned int nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; std::vector > txids; From 0cea4b2d11058e61de123cabfb87dd657af54a7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 21:13:19 -1100 Subject: [PATCH 1352/3904] +print --- src/komodo_bitcoind.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 10c6ee4b8..d35683c93 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -643,15 +643,15 @@ int32_t komodo_isPoS(CBlock *pblock) { txid = pblock->vtx[n-1].vin[0].prevout.hash; vout = pblock->vtx[n-1].vin[0].prevout.n; - if ( ASSETCHAINS_MARMARA != 0 ) - { - fprintf(stderr,"validate proper signature and unlockht preservation\n"); - // need to verify it was signed by the non-Marmarapk of the 1of2 - } txtime = komodo_txtime(&value,txid,vout,destaddr); if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + if ( ASSETCHAINS_MARMARA != 0 ) + { + fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); + // need to verify it was signed by the non-Marmarapk of the 1of2 + } if ( strcmp(destaddr,voutaddr) == 0 && pblock->vtx[n-1].vout[0].nValue == value ) { //fprintf(stderr,"is PoS block!\n"); From c9a44be0b1276cda887df1a6ccb200d73c3d1b59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 21:58:23 -1100 Subject: [PATCH 1353/3904] Marmara PoS check --- src/cc/marmara.cpp | 15 ++++++++++++++ src/komodo_bitcoind.h | 47 +++++++++++++++++++++++++------------------ src/main.cpp | 6 +++--- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 795b95186..98e805c38 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -255,6 +255,21 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) return(-1); } +bool MarmaraPoScheck(char *destaddr,CScript opret,CScript scriptPubKey) +{ + CPubKey pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; + if ( opret == scriptPubKey ) + { + cp = CCinit(&C,EVAL_MARMARA); + funcid = DecodeMaramaraCoinbaseOpRet(opret,pk,height,unlockht); + Marmarapk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); + fprintf(stderr,"matched opret! funcid.%c ht.%d unlock.%d %s\n",funcid,height,unlockht,coinaddr); + return(strcmp(destaddr,coinaddr)); + } + return(0); +} + bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { std::vector vopret; CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid,*script; CPubKey pk,vpk; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d35683c93..67900ea27 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -557,9 +557,9 @@ uint64_t komodo_seed(int32_t height) return(seed); } -uint32_t komodo_txtime(uint64_t *valuep,uint256 hash, int32_t n, char *destaddr) +uint32_t komodo_txtime(CScript &opret,uint64_t *valuep,uint256 hash, int32_t n, char *destaddr) { - CTxDestination address; CTransaction tx; uint256 hashBlock; + CTxDestination address; CTransaction tx; uint256 hashBlock; int32_t numvouts; *valuep = 0; if (!GetTransaction(hash, tx, #ifndef KOMODO_ZCASH @@ -570,10 +570,12 @@ uint32_t komodo_txtime(uint64_t *valuep,uint256 hash, int32_t n, char *destaddr) //fprintf(stderr,"ERROR: %s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime); return(0); } + numvouts = tx.vout.size(); //fprintf(stderr,"%s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime); - if ( n < tx.vout.size() ) + if ( n < numvouts ) { *valuep = tx.vout[n].nValue; + opret = tx.vout[numvouts-1].scriptPubKey; if (ExtractDestination(tx.vout[n].scriptPubKey, address)) strcpy(destaddr,CBitcoinAddress(address).ToString().c_str()); } @@ -614,12 +616,12 @@ uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr) int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout) { - int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; + int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; CScript opret; if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 ) { txid = pblock->vtx[n-1].vin[0].prevout.hash; vout = pblock->vtx[n-1].vin[0].prevout.n; - txtime = komodo_txtime(&value,txid,vout,destaddr); + txtime = komodo_txtime(opret,&value,txid,vout,destaddr); if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); @@ -634,28 +636,33 @@ int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout) return(0); } -int32_t komodo_isPoS(CBlock *pblock) +bool MarmaraPoScheck(char *destaddr,CScript opret,CScript scriptPubKey); + +int32_t komodo_isPoS(CBlock *pblock,int32_t height) { - int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; + int32_t n,vout,numvouts; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; CScript opret; if ( ASSETCHAINS_STAKED != 0 ) { if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 ) { txid = pblock->vtx[n-1].vin[0].prevout.hash; vout = pblock->vtx[n-1].vin[0].prevout.n; - txtime = komodo_txtime(&value,txid,vout,destaddr); + txtime = komodo_txtime(opret,&value,txid,vout,destaddr); if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); - if ( ASSETCHAINS_MARMARA != 0 ) + if ( pblock->vtx[n-1].vout[0].nValue == value && strcmp(destaddr,voutaddr) == 0 ) { - fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); - // need to verify it was signed by the non-Marmarapk of the 1of2 - } - if ( strcmp(destaddr,voutaddr) == 0 && pblock->vtx[n-1].vout[0].nValue == value ) - { - //fprintf(stderr,"is PoS block!\n"); - return(1); + if ( ASSETCHAINS_MARMARA == 0 ) + return(1); + else + { + if ( pblock->vtx[n-1].vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 && (numvouts= pblock->vtx[n-1].vout.size()) > 1 ) + { +fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); + return(MarmaraPoScheck(destaddr,opret,pblock->vtx[n-1].vout[numvouts-1].scriptPubKey)); + } + } } } } @@ -1195,7 +1202,7 @@ uint32_t komodo_segid32(char *coinaddr) int8_t komodo_segid(int32_t nocache,int32_t height) { - CTxDestination voutaddress; CBlock block; CBlockIndex *pindex; uint64_t value; uint32_t txtime; char voutaddr[64],destaddr[64]; int32_t txn_count,vout; uint256 txid; int8_t segid = -1; + CTxDestination voutaddress; CBlock block; CBlockIndex *pindex; uint64_t value; uint32_t txtime; char voutaddr[64],destaddr[64]; int32_t txn_count,vout; uint256 txid; CScript opret; int8_t segid = -1; if ( height > 0 && (pindex= komodo_chainactive(height)) != 0 ) { if ( nocache == 0 && pindex->segid >= -1 ) @@ -1207,7 +1214,7 @@ int8_t komodo_segid(int32_t nocache,int32_t height) { txid = block.vtx[txn_count-1].vin[0].prevout.hash; vout = block.vtx[txn_count-1].vin[0].prevout.n; - txtime = komodo_txtime(&value,txid,vout,destaddr); + txtime = komodo_txtime(opret,&value,txid,vout,destaddr); if ( ExtractDestination(block.vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); @@ -1464,7 +1471,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ vout = pblock->vtx[txn_count-1].vin[0].prevout.n; if ( prevtime != 0 ) { - if ( komodo_isPoS(pblock) != 0 ) + if ( komodo_isPoS(pblock,height) != 0 ) { eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime+27,(char *)""); } @@ -1500,7 +1507,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ } if ( slowflag == 0 && isPoS == 0 ) // maybe previous block is not seen yet, do the best approx { - if ( komodo_isPoS(pblock) != 0 ) + if ( komodo_isPoS(pblock,height) != 0 ) isPoS = 1; } if ( slowflag != 0 && isPoS != 0 ) diff --git a/src/main.cpp b/src/main.cpp index 21b6b4eb0..614f13d44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3806,7 +3806,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { CValidationState stateDummy; // don't keep staking or invalid transactions - if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL)) + if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight()) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL)) { mempool.remove(tx, removed, true); } @@ -3837,7 +3837,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { { CTransaction &tx = block.vtx[i]; //if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))) - if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) + if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight()) != 0))) { EraseFromWallets(tx.GetHash()); } @@ -4734,7 +4734,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C CValidationState state; CTransaction Tx; const CTransaction &tx = (CTransaction)block.vtx[i]; - if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) + if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block,height) != 0))) continue; Tx = tx; if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync From 2aa12aad792dde6868db3fa4b46f3c4357ef2580 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 21:59:03 -1100 Subject: [PATCH 1354/3904] Marmarapk --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 98e805c38..ca216069a 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -257,7 +257,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraPoScheck(char *destaddr,CScript opret,CScript scriptPubKey) { - CPubKey pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; + CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; if ( opret == scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); From 9ff5e8de93d73f99f1d3380492412c122e9b4861 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 22:03:15 -1100 Subject: [PATCH 1355/3904] Test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 67900ea27..877a192f3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -661,7 +661,7 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) { fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); return(MarmaraPoScheck(destaddr,opret,pblock->vtx[n-1].vout[numvouts-1].scriptPubKey)); - } + } else fprintf(stderr,"reject ht.%d PoS block\n",height); } } } From 00151d02b037aaf9f6202fd7b5c90cf8c04b722e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:08:38 -1100 Subject: [PATCH 1356/3904] Allow old style --- src/komodo_bitcoind.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 877a192f3..77dfbf6ad 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -661,7 +661,12 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) { fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); return(MarmaraPoScheck(destaddr,opret,pblock->vtx[n-1].vout[numvouts-1].scriptPubKey)); - } else fprintf(stderr,"reject ht.%d PoS block\n",height); + } + else + { + fprintf(stderr,"reject ht.%d PoS block\n",height); + return(1); // allow until MTST3 + } } } } @@ -2174,7 +2179,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt { const CScript &scriptPubKey = tx.vout[vout].scriptPubKey; array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,txid,vout,coinaddr,hashbuf,(CScript)scriptPubKey); - fprintf(stderr,"addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp); + //fprintf(stderr,"addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp); } } } From 0a84522ad08ffdd67f44ce5b5d39dd42d1a26d3a Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 21 Jan 2019 11:08:59 +0100 Subject: [PATCH 1357/3904] Channel close fix. Adding CCError print to all RPCs. --- src/cc/channels.cpp | 92 +++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 32 deletions(-) diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index a375edbda..6cd379eed 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -502,6 +502,8 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 if (tokenid!=zeroid && tokens>funds) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,tokens-funds,mypk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('O',tokenid,zeroid,mypk,destpub,numpayments,payment,hashchain))); } + CCerror = strprintf("error adding funds"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } @@ -520,25 +522,29 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 mypk = pubkey2pk(Mypubkey()); if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel open txid\n"); - return (""); + CCerror = strprintf("invalid channel open txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); + return(""); } if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, totalnumpayments, payment, hashchain)=='O') { if (mypk != srcpub && mypk != destpub) { - fprintf(stderr,"this is not our channel\n"); + CCerror = strprintf("this is not our channel"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } else if (amount % payment != 0 || amount 0) @@ -552,11 +558,13 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 { if (numpayments > prevdepth) { - fprintf(stderr,"not enough funds in channel for that amount\n"); + CCerror = strprintf("not enough funds in channel for that amount"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } else if (numpayments == 0) { - fprintf(stderr,"invalid amount\n"); + CCerror = strprintf("invalid amount"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (secret!=zeroid) @@ -570,7 +578,8 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 endiancpy((uint8_t * ) & gensecret, hashdest, 32); if (gensecret!=hashchain) { - fprintf(stderr,"invalid secret supplied\n"); + CCerror = strprintf("invalid secret supplied"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } @@ -592,7 +601,8 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 } else { - fprintf(stderr,"invalid previous tx\n"); + CCerror = strprintf("invalid previous tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); @@ -605,11 +615,13 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 } else { - fprintf(stderr,"error adding CC inputs\n"); + CCerror = strprintf("error adding CC inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } - fprintf(stderr,"error adding normal inputs\n"); + CCerror = strprintf("error adding normal inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } @@ -629,36 +641,41 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) mypk = pubkey2pk(Mypubkey()); if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel open txid\n"); + CCerror = strprintf("invalid channel open txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { - fprintf(stderr, "invalid channel open tx\n"); + CCerror = strprintf("invalid channel open tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (mypk != srcpub) { - fprintf(stderr,"cannot close, you are not channel owner\n"); + CCerror = strprintf("cannot close, you are not channel owner"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) { - if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); - else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); + if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, funds, mypk, destpub)); + else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds, mypk, destpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',tokenid,opentxid,mypk,destpub,(funds-txfee)/payment,payment,zeroid))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',tokenid,opentxid,mypk,destpub,funds/payment,payment,zeroid))); } else { - fprintf(stderr,"error adding CC inputs\n"); + CCerror = strprintf("error adding CC inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } - fprintf(stderr,"error adding normal inputs\n"); + CCerror = strprintf("error adding normal inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } @@ -678,61 +695,72 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) mypk = pubkey2pk(Mypubkey()); if (GetTransaction(closetxid,channelCloseTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel close txid\n"); + CCerror = strprintf("invalid channel close txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if ((numvouts=channelCloseTx.vout.size()) < 1 || DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,param1,param2,param3)!='C') { - fprintf(stderr, "invalid channel close tx\n"); + CCerror = strprintf("invalid channel close tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (txid!=opentxid) { - fprintf(stderr, "open and close txid are not from same channel\n"); + CCerror = strprintf("open and close txid are not from same channel"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel open txid\n"); + CCerror = strprintf("invalid channel open txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { - fprintf(stderr, "invalid channel open tx\n"); + CCerror = strprintf("invalid channel open tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (mypk != srcpub) { - fprintf(stderr,"cannot refund, you are not the channel owenr\n"); + CCerror = strprintf("cannot refund, you are not the channel owner"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) { if ((GetTransaction(prevtxid,prevTx,hashblock,false) != 0) && (numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3) != 0) { mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,funds-txfee,mypk)); - else mtx.vout.push_back(CTxOut(funds-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',tokenid,opentxid,mypk,destpub,param1,payment,closetxid))); + if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,funds,mypk)); + else mtx.vout.push_back(CTxOut(funds,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',tokenid,opentxid,mypk,destpub,funds/payment,payment,closetxid))); } else { - fprintf(stderr,"previous tx is invalid\n"); + CCerror = strprintf("previous tx is invalid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } else { - fprintf(stderr,"error adding CC inputs\n"); + CCerror = strprintf("error adding CC inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } + CCerror = strprintf("error adding normal inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } + UniValue ChannelsList() { UniValue result(UniValue::VOBJ); std::vector > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; From 824325ac281b969cf3c70bdd0c719882be57d524 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:31:30 -1100 Subject: [PATCH 1358/3904] MarmaraSignature --- src/cc/marmara.cpp | 29 ++++++++++++++++++++++++++++- src/komodo_bitcoind.h | 23 ++++++++++++----------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ca216069a..906d268be 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -500,7 +500,34 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) return(result); } -// jl777: decide on what unlockht settlement change should have +int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew); +{ + uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector pubkeys; struct CCcontract_info *cp,C; uint64_t txfee + txfee = 10000; + vout = txNew.vin[0].prevout.n; + if ( GetTransaction(txNew.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) + { + cp = CCinit(&C,EVAL_MARMARA); + mypk = pubkey2pk(Mypubkey()); + mtx.vout.resize(2); + mtx.vout[1].scriptPubKey = tx.vout[numvouts - 1].scriptPubKey; + mtx.vout[1].nValue = 0; + pubkeys.push_back(mypk); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tx.vout[numvouts - 1].scriptPubKey,pubkeys); + if ( rawtx.size() > 0 ) + { + siglen = mtx.vin[0].scriptSig.size(); + ptr = mtx.vin[0].scriptSig.data(); + for (i=0; i from utxo making change UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 77dfbf6ad..383f4bf40 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2081,6 +2081,8 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod return(0); } +int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew); + int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) { static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; @@ -2264,22 +2266,21 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( ASSETCHAINS_MARMARA == 0 ) { signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); - } - else - { - fprintf(stderr,"add opreturn and CCFinalizetx\n"); - // add opreturn - // signSuccess = CCFinalizetx(...) - } - if (!signSuccess) - fprintf(stderr,"failed to create signature\n"); - else - { UpdateTransaction(txNew,0,sigdata); ptr = (uint8_t *)&sigdata.scriptSig[0]; siglen = sigdata.scriptSig.size(); for (i=0; i Date: Sun, 20 Jan 2019 23:32:13 -1100 Subject: [PATCH 1359/3904] -; --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 906d268be..30e4add97 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -500,7 +500,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) return(result); } -int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew); +int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew) { uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector pubkeys; struct CCcontract_info *cp,C; uint64_t txfee txfee = 10000; From 493b808298267b6be6b8f8aa89e88fb9d122222c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:33:00 -1100 Subject: [PATCH 1360/3904] syntax --- src/cc/marmara.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 30e4add97..f8934e406 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -500,9 +500,9 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) return(result); } -int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew) +int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) { - uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector pubkeys; struct CCcontract_info *cp,C; uint64_t txfee + uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector pubkeys; struct CCcontract_info *cp,C; uint64_t txfee; txfee = 10000; vout = txNew.vin[0].prevout.n; if ( GetTransaction(txNew.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) From 84b6f664cbd11a904767629a27b18581f0a0eb55 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:34:03 -1100 Subject: [PATCH 1361/3904] Test --- src/cc/marmara.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f8934e406..872f3d69f 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -504,8 +504,8 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) { uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector pubkeys; struct CCcontract_info *cp,C; uint64_t txfee; txfee = 10000; - vout = txNew.vin[0].prevout.n; - if ( GetTransaction(txNew.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) + vout = mtx.vin[0].prevout.n; + if ( GetTransaction(mtx.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) { cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); @@ -517,7 +517,7 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) if ( rawtx.size() > 0 ) { siglen = mtx.vin[0].scriptSig.size(); - ptr = mtx.vin[0].scriptSig.data(); + ptr = mtx.vin[0].scriptSig.ptr(); for (i=0; i Date: Sun, 20 Jan 2019 23:35:30 -1100 Subject: [PATCH 1362/3904] Print --- src/cc/marmara.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 872f3d69f..f3e715796 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -517,10 +517,13 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) if ( rawtx.size() > 0 ) { siglen = mtx.vin[0].scriptSig.size(); - ptr = mtx.vin[0].scriptSig.ptr(); + ptr = &(uint8_t *)&mtx.vin[0].scriptSig; for (i=0; i Date: Sun, 20 Jan 2019 23:37:07 -1100 Subject: [PATCH 1363/3904] Begin --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f3e715796..9d1a3fd9a 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -517,7 +517,7 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) if ( rawtx.size() > 0 ) { siglen = mtx.vin[0].scriptSig.size(); - ptr = &(uint8_t *)&mtx.vin[0].scriptSig; + ptr = mtx.vin[0].scriptSig.begin(); for (i=0; i Date: Sun, 20 Jan 2019 23:41:03 -1100 Subject: [PATCH 1364/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 9d1a3fd9a..d743746b2 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -517,7 +517,7 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) if ( rawtx.size() > 0 ) { siglen = mtx.vin[0].scriptSig.size(); - ptr = mtx.vin[0].scriptSig.begin(); + ptr = &mtx.vin[0].scriptSig[0]; for (i=0; i Date: Sun, 20 Jan 2019 23:44:24 -1100 Subject: [PATCH 1365/3904] Bigger utxosig --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c71bc2461..f8fb8ba5f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -487,7 +487,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(mempool.cs); - uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; + uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[512],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); if (ASSETCHAINS_LWMAPOS != 0) From b1f30fb7def9337d05a929efa63d7d9ed079d187 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:46:25 -1100 Subject: [PATCH 1366/3904] signSuccess --- src/cc/marmara.cpp | 4 ++-- src/komodo_bitcoind.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index d743746b2..97febf8e5 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -521,9 +521,9 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) for (i=0; i 0 ) + signSuccess = true; + else signSuccess = false; } if (!signSuccess) fprintf(stderr,"failed to create signature\n"); From 6b3ce154c037e668236ef1d9efedde60396c5c43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:47:14 -1100 Subject: [PATCH 1367/3904] Test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9a17a71a2..cf2ae585f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2275,7 +2275,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt else { siglen = MarmaraSignature(utxosig,txNew); - if ( signlen > 0 ) + if ( siglen > 0 ) signSuccess = true; else signSuccess = false; } From fe139f33637747c501fd7cd869db385f9359f0c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:50:32 -1100 Subject: [PATCH 1368/3904] +print --- src/cc/marmara.cpp | 2 +- src/komodo_bitcoind.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 97febf8e5..7fefb9eb6 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -523,7 +523,7 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) utxosig[i] = ptr[i]; //fprintf(stderr,"%02x",ptr[i]); } - //fprintf(stderr," got signed rawtx.%s siglen.%d\n",rawtx.c_str(),siglen); + fprintf(stderr," got signed rawtx.%s siglen.%d\n",rawtx.c_str(),siglen); return(siglen); } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index cf2ae585f..1d3926139 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -651,6 +651,7 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + fprintf(stderr,"voutaddr.%s vs destaddr.%s\n",voutaddr,destaddr); if ( pblock->vtx[n-1].vout[0].nValue == value && strcmp(destaddr,voutaddr) == 0 ) { if ( ASSETCHAINS_MARMARA == 0 ) From f8ca9c22b709c9eb64205665eb54a6aa3080e458 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:54:16 -1100 Subject: [PATCH 1369/3904] Test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1d3926139..df1a99a5d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -643,7 +643,7 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) int32_t n,vout,numvouts; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; CScript opret; if ( ASSETCHAINS_STAKED != 0 ) { - if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 ) + if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1+(ASSETCHAINS_MARMARA!=0) ) { txid = pblock->vtx[n-1].vin[0].prevout.hash; vout = pblock->vtx[n-1].vin[0].prevout.n; From a34fc260986882b86830afd2919c705a68f7e2d1 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 21 Jan 2019 11:57:52 +0100 Subject: [PATCH 1370/3904] Fix canceling partially filled orders by anyone. (#11) * Fix * Fix --- src/cc/CCassetstx.cpp | 46 +++++++++++++++++++++---------------------- src/cc/CCutils.cpp | 1 - src/cc/assets.cpp | 15 +++++++++----- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 968775d38..9d83beb2c 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -477,14 +477,10 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction vintx; - uint64_t mask; - uint256 hashBlock; - int64_t bidamount; - CPubKey mypk; - struct CCcontract_info *cpAssets, C; - - uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; + CTransaction vintx; uint64_t mask; + uint256 hashBlock; int64_t bidamount; + CPubKey mypk; struct CCcontract_info *cpAssets, C; + uint8_t funcid,dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; cpAssets = CCinit(&C, EVAL_ASSETS); @@ -501,9 +497,12 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets - if( DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 'b') - mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' (not 'B') - // TODO: spend it also in FillBuyOffer? + if((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) + { + + if (funcid == 's') mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' + else if (funcid=='S') mtx.vin.push_back(CTxIn(bidtxid, 3, CScript())); // spend marker if funcid='B' + } mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -523,12 +522,9 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction vintx; uint64_t mask; - uint256 hashBlock; - int64_t askamount; - CPubKey mypk; - struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; - - uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; + uint256 hashBlock; int64_t askamount; + CPubKey mypk; struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; + uint8_t funcid,dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; cpAssets = CCinit(&assetsC, EVAL_ASSETS); @@ -545,9 +541,11 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); - if (DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 's') - mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' (not 'S') - // TODO: spend it also in FillSell? + if ((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) + { + if (funcid == 's') mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' + else if (funcid=='S') mtx.vin.push_back(CTxIn(asktxid, 3, CScript())); // marker if funcid='S' + } mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); // one-eval token vout mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -607,7 +605,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) @@ -637,9 +635,10 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); // vout1 coins to normal mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // vout2 single-eval tokens sent to the buyer + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,txfee,origpubkey)); // vout3 marker to origpubkey if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // vout3 change in single-eval tokens + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // vout4 change in single-eval tokens fprintf(stderr,"FillBuyOffer remaining %llu -> origpubkey\n", (long long)remaining_required); @@ -698,7 +697,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) @@ -747,6 +746,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a //std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl; mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //vout.2 coins to tokens seller's normal addr } + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,txfee,origpubkey)); //vout.3 marker to origpubkey // not implemented if (CCchange != 0) { diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index e9c30acc1..07ce11154 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -602,7 +602,6 @@ bool komodo_txnotarizedconfirmed(uint256 txid) CPubKey check_signing_pubkey(CScript scriptSig) { - bool found = false; CPubKey pubkey; diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 3ccafa34f..2433473b9 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -153,8 +153,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("AssetValidate: invalid opreturn payload"); // find dual-eval tokens unspendable addr: - char tokensUnspendableAddr[64]; + char tokensUnspendableAddr[64],origpubkeyCCaddr[64]; GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); + GetCCaddress(cpAssets, origpubkeyCCaddr, origpubkey); // we need this for validating single-eval tokens' vins/vous: struct CCcontract_info *cpTokens, tokensC; @@ -258,7 +259,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( (nValue = AssetValidateBuyvin(cpAssets, eval, totalunits, tmporigpubkey, assetsCCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if( numvouts < 3 ) + else if( numvouts < 4 ) return eval->Invalid("not enough vouts for fillbuy"); else if( tmporigpubkey != origpubkey ) return eval->Invalid("mismatched origpubkeys for fillbuy"); @@ -266,17 +267,19 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti { if( nValue != tx.vout[0].nValue + tx.vout[1].nValue ) return eval->Invalid("locked value doesnt match vout0+1 fillbuy"); - else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) + else if( tx.vout[4].scriptPubKey.IsPayToCryptoCondition() != 0 ) { if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, 0) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); - else if ( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) + else if ( inputs != tx.vout[2].nValue + tx.vout[4].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); } else if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, inputs) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt match inputs fillbuy"); else if( ConstrainVout(tx.vout[1],0,0,0) == 0 ) return eval->Invalid("vout1 is CC for fillbuy"); + else if( ConstrainVout(tx.vout[3], 1, origpubkeyCCaddr, 10000) == 0 ) + return eval->Invalid("invalid marker for original pubkey"); else if( ValidateBidRemainder(remaining_price, tx.vout[0].nValue, nValue, tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillbuy"); else if( remaining_price != 0 ) @@ -345,7 +348,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if( numvouts < 3 ) + else if( numvouts < 4 ) return eval->Invalid("not enough vouts for fillask"); else if( tmporigpubkey != origpubkey ) return eval->Invalid("mismatched origpubkeys for fillask"); @@ -359,6 +362,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( ConstrainVout(tx.vout[2], 0, origaddr, 0) == 0 ) return eval->Invalid("normal vout1 for fillask"); + else if( ConstrainVout(tx.vout[3], 1, origpubkeyCCaddr, 10000) == 0 ) + return eval->Invalid("invalid marker for original pubkey"); else if( remaining_price != 0 ) { //char tokensUnspendableAddr[64]; From 0e7de7412cc16af55cbc33ef5b5d360b853d5479 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:00:04 -1100 Subject: [PATCH 1371/3904] +print --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index df1a99a5d..195267a78 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -643,7 +643,9 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) int32_t n,vout,numvouts; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; CScript opret; if ( ASSETCHAINS_STAKED != 0 ) { - if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1+(ASSETCHAINS_MARMARA!=0) ) + n = pblock->vtx.size(); + fprintf(stderr,"ht.%d check for PoS numtx.%d numvins.%d numvouts.%d\n",height,n,pblock->vtx[n-1].vin.size(),pblock->vtx[n-1].vout.size()); + if ( n > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1+(ASSETCHAINS_MARMARA!=0) ) { txid = pblock->vtx[n-1].vin[0].prevout.hash; vout = pblock->vtx[n-1].vin[0].prevout.n; From f4861bdf77e5fd28aa20d9e555f3525cbd5d4e87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:08:07 -1100 Subject: [PATCH 1372/3904] +print --- src/komodo_bitcoind.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 195267a78..d40baaf00 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1464,12 +1464,13 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && pindex->segid >= -1 ) { + fprintf(stderr,"isPoSblock segid.%d\n",pindex->segid); if ( pindex->segid == -1 ) return(0); else return(1); } txn_count = pblock->vtx.size(); - if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 ) + if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) { it = mapBlockIndex.find(pblock->hashPrevBlock); if ( it != mapBlockIndex.end() && (previndex = it->second) != NULL ) @@ -1784,6 +1785,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) bnTarget.SetCompact(pblock->nBits,&fNegative,&fOverflow); bhash = UintToArith256(hash); possible = komodo_block2pubkey33(pubkey33,pblock); +fprintf(stderr,"checkPoW ht.%d\n",height); if ( height == 0 ) { if ( slowflag != 0 ) @@ -1828,6 +1830,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } + fprintf(stderr,"ASSETCHAINS_STAKED.%d ht.%d\n",ASSETCHAINS_STAKED,height); if ( ASSETCHAINS_STAKED != 0 && height >= 2 ) // must PoS or have at least 16x better PoW { if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 ) From e8fd52a2b5adf4356056654bfcf1c0d54617f0b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:12:17 -1100 Subject: [PATCH 1373/3904] Test --- src/komodo_bitcoind.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d40baaf00..5e1ec7f66 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1470,6 +1470,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else return(1); } txn_count = pblock->vtx.size(); + fprintf(stderr,"checkblock n.%d vins.%d vouts.%d\n",txn_count,pblock->vtx[txn_count-1].vin.size(),pblock->vtx[txn_count-1].vout.size()); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) { it = mapBlockIndex.find(pblock->hashPrevBlock); From 7cfb6293c6b820426ed7184d4ee12c6cd8152d40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:31:14 -1100 Subject: [PATCH 1374/3904] komodo_defs a lot more --- src/cc/CCinclude.h | 5 ----- src/chainparams.cpp | 5 ----- src/komodo_bitcoind.h | 2 +- src/komodo_defs.h | 40 ++++++++++++++++++++++++++++++++++++++++ src/metrics.cpp | 3 +-- src/miner.cpp | 9 --------- src/pow.cpp | 5 ++--- src/primitives/block.cpp | 2 +- src/rpc/mining.cpp | 6 ++---- src/rpc/misc.cpp | 3 ++- src/wallet/rpcwallet.cpp | 3 +-- src/wallet/wallet.cpp | 6 ------ 12 files changed, 50 insertions(+), 39 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 1953fad34..66c001969 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -51,11 +51,6 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../utlist.h" #include "../uthash.h" -extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; -extern uint32_t ASSETCHAINS_CC; -extern char ASSETCHAINS_SYMBOL[]; -extern std::string CCerror,ASSETCHAINS_CCLIB; -extern uint8_t ASSETCHAINS_CCDISABLES[256]; #define CC_MAXVINS 1024 diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 47f4d48a8..c7232761b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -92,11 +92,6 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st void *chainparams_commandline(void *ptr); #include "komodo_defs.h" -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; -extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5e1ec7f66..9d0ea3228 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1470,7 +1470,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else return(1); } txn_count = pblock->vtx.size(); - fprintf(stderr,"checkblock n.%d vins.%d vouts.%d\n",txn_count,pblock->vtx[txn_count-1].vin.size(),pblock->vtx[txn_count-1].vout.size()); + fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,pblock->vtx[txn_count-1].vin.size(),pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(doube)pblock->vtx[txn_count-1].vout[1].nValue/COIN); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) { it = mapBlockIndex.find(pblock->hashPrevBlock); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 91fcadddb..47916d5c4 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -36,5 +36,45 @@ extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; +extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; +extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; +extern uint64_t ASSETCHAINS_SUPPLY; + +extern uint64_t ASSETCHAINS_TIMELOCKGTE; +extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH; + +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; +extern bool VERUS_MINTBLOCKS; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; +extern const char *ASSETCHAINS_ALGORITHMS[]; +extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH; +extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; +extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; + +extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_STAKED; +extern char ASSETCHAINS_SYMBOL[65]; +extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; + +extern int32_t ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS; + +extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; +extern uint32_t ASSETCHAINS_CC; +extern char ASSETCHAINS_SYMBOL[]; +extern std::string CCerror,ASSETCHAINS_CCLIB; +extern uint8_t ASSETCHAINS_CCDISABLES[256]; + +extern int32_t USE_EXTERNAL_PUBKEY; +extern std::string NOTARY_PUBKEY; +extern int32_t KOMODO_EXCHANGEWALLET; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern int32_t VERUS_MIN_STAKEAGE; +extern std::string DONATION_PUBKEY; +extern uint8_t ASSETCHAINS_PRIVATE; +extern int32_t USE_EXTERNAL_PUBKEY; #endif diff --git a/src/metrics.cpp b/src/metrics.cpp index a01d381a1..6b387f7dc 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -39,8 +39,7 @@ #endif #include -extern uint64_t ASSETCHAINS_TIMELOCKGTE; -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH; +#include "komodo_defs.h" int64_t komodo_block_unlocktime(uint32_t nHeight); void AtomicTimer::start() diff --git a/src/miner.cpp b/src/miner.cpp index f8fb8ba5f..78eb84e7b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -132,17 +132,8 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" extern CCriticalSection cs_metrics; -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; -extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; -extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; -extern const char *ASSETCHAINS_ALGORITHMS[]; -extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); -extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; uint32_t Mining_start,Mining_height; int32_t My_notaryid = -1; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); diff --git a/src/pow.cpp b/src/pow.cpp index b69c4fce6..cc2b0b7c2 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -37,9 +37,8 @@ #endif // ENABLE_RUST uint32_t komodo_chainactive_timestamp(); -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_STAKED; -extern char ASSETCHAINS_SYMBOL[65]; -extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; +#include "komodo_defs.h" + unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params); unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 00fc8cee9..bb3314760 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -24,8 +24,8 @@ #include "tinyformat.h" #include "utilstrencodings.h" #include "crypto/common.h" +#include "komodo_defs.h" -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH; // default hash algorithm for block uint256 (CBlockHeader::*CBlockHeader::hashFunction)() const = &CBlockHeader::GetSHA256DHash; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index a0643528d..ff9b1b4c4 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -48,10 +48,8 @@ using namespace std; -extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS; -extern uint64_t ASSETCHAINS_STAKED; -extern int32_t KOMODO_MININGTHREADS; -extern bool VERUS_MINTBLOCKS; +#include "komodo_defs.h" + arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); /** diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 0ebfa7b25..2491055d1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -77,7 +77,8 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_MAGIC; -extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY,ASSETCHAINS_LASTERA; +extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; +extern uint32_t ASSETCHAINS_LASTERA; extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING; extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 174f447f0..3acee9c1f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -57,6 +57,7 @@ #include +#include "komodo_defs.h" using namespace std; @@ -67,8 +68,6 @@ const std::string ADDR_TYPE_SPROUT = "sprout"; const std::string ADDR_TYPE_SAPLING = "sapling"; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); -extern uint8_t ASSETCHAINS_PRIVATE; -extern int32_t USE_EXTERNAL_PUBKEY; uint32_t komodo_segid32(char *coinaddr); int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); int32_t komodo_isnotaryvout(char *coinaddr); // from ac_private chains only diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0000f8d42..d171812c4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -59,13 +59,7 @@ bool fSendFreeTransactions = false; bool fPayAtLeastCustomFee = true; #include "komodo_defs.h" -extern int32_t USE_EXTERNAL_PUBKEY; -extern std::string NOTARY_PUBKEY; -extern int32_t KOMODO_EXCHANGEWALLET; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern int32_t VERUS_MIN_STAKEAGE; CBlockIndex *komodo_chainactive(int32_t height); -extern std::string DONATION_PUBKEY; /** * Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) From 2cb2b335d7d7826f508ab09991cfc97d0ceeaf60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:34:19 -1100 Subject: [PATCH 1375/3904] Prune inconsistent refs --- src/komodo_defs.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 47916d5c4..bfb49a973 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -45,22 +45,21 @@ extern uint64_t ASSETCHAINS_SUPPLY; extern uint64_t ASSETCHAINS_TIMELOCKGTE; extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH; -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; -extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH; -extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; +extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO; +extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_STAKED; +extern uint32_t ASSETCHAINS_ALGO; extern char ASSETCHAINS_SYMBOL[65]; -extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; +extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; -extern int32_t ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS; extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; From f22c02d1fddb9fed236c9750379724acc1b482a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:36:06 -1100 Subject: [PATCH 1376/3904] Test --- src/bitcoind.cpp | 3 ++- src/komodo_defs.h | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 86d3165cf..b2fa534a1 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -94,7 +94,8 @@ void WaitForShutdown(boost::thread_group* threadGroup) // // Start // -extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,ASSETCHAIN_INIT; +extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY; +extern uint32_t ASSETCHAIN_INIT; extern std::string NOTARY_PUBKEY; int32_t komodo_is_issuer(); void komodo_passport_iteration(); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index bfb49a973..b22b6279e 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -50,13 +50,12 @@ extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; -extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO; +extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; -extern uint32_t ASSETCHAINS_ALGO; extern char ASSETCHAINS_SYMBOL[65]; extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; From 51a6360f57b8a33e58284d319f6e24ef1c8c4df8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:41:59 -1100 Subject: [PATCH 1377/3904] Fix --- src/komodo_bitcoind.h | 6 +++--- src/komodo_defs.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9d0ea3228..cd12bb255 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -644,7 +644,7 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) if ( ASSETCHAINS_STAKED != 0 ) { n = pblock->vtx.size(); - fprintf(stderr,"ht.%d check for PoS numtx.%d numvins.%d numvouts.%d\n",height,n,pblock->vtx[n-1].vin.size(),pblock->vtx[n-1].vout.size()); + fprintf(stderr,"ht.%d check for PoS numtx.%d numvins.%d numvouts.%d\n",height,n,(int32_t)pblock->vtx[n-1].vin.size(),(int32_t)pblock->vtx[n-1].vout.size()); if ( n > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1+(ASSETCHAINS_MARMARA!=0) ) { txid = pblock->vtx[n-1].vin[0].prevout.hash; @@ -1470,7 +1470,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else return(1); } txn_count = pblock->vtx.size(); - fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,pblock->vtx[txn_count-1].vin.size(),pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(doube)pblock->vtx[txn_count-1].vout[1].nValue/COIN); + fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,pblock->vtx[txn_count-1].vin.size(),pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) { it = mapBlockIndex.find(pblock->hashPrevBlock); @@ -1831,7 +1831,7 @@ fprintf(stderr,"checkPoW ht.%d\n",height); return(-1); } } - fprintf(stderr,"ASSETCHAINS_STAKED.%d ht.%d\n",ASSETCHAINS_STAKED,height); + fprintf(stderr,"ASSETCHAINS_STAKED.%d ht.%d\n",(int32_t)ASSETCHAINS_STAKED,height); if ( ASSETCHAINS_STAKED != 0 && height >= 2 ) // must PoS or have at least 16x better PoW { if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 ) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index b22b6279e..0ea97d6db 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -43,9 +43,9 @@ extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, A extern uint64_t ASSETCHAINS_SUPPLY; extern uint64_t ASSETCHAINS_TIMELOCKGTE; -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH; +extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE; -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; From 92cf6d266736a5f37af3550167fd3f84cb891d4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:47:55 -1100 Subject: [PATCH 1378/3904] Fixes --- src/komodo_bitcoind.h | 2 +- src/rpc/misc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index cd12bb255..eb033f96a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1470,7 +1470,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else return(1); } txn_count = pblock->vtx.size(); - fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,pblock->vtx[txn_count-1].vin.size(),pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN); + fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,(int32_t)pblock->vtx[txn_count-1].vin.size(),(int32_t)pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) { it = mapBlockIndex.find(pblock->hashPrevBlock); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 2491055d1..e6d8025b1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -225,7 +225,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) } } if (ASSETCHAINS_LASTERA > 0) - obj.push_back(Pair("eras", ASSETCHAINS_LASTERA + 1)); + obj.push_back(Pair("eras", (int64_t)(ASSETCHAINS_LASTERA + 1))); obj.push_back(Pair("reward", acReward)); obj.push_back(Pair("halving", acHalving)); obj.push_back(Pair("decay", acDecay)); From 8caf315c91473a627e614b863dce2f9f0d201b1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:51:31 -1100 Subject: [PATCH 1379/3904] Test --- src/wallet/rpcwallet.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3acee9c1f..a47c18356 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5171,7 +5171,6 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits int32_t ensure_CCrequirements() { - extern uint8_t NOTARY_PUBKEY33[]; CCerror = ""; if ( NOTARY_PUBKEY33[0] == 0 ) return(-1); From e02762dfaad6847918991238b83f6b532b683957 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 00:52:36 -1100 Subject: [PATCH 1380/3904] Test --- src/wallet/rpcwallet.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a47c18356..8180c9239 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5260,8 +5260,6 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); From 089d2114466eb8543235c033688f7a661615ed01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:03:54 -1100 Subject: [PATCH 1381/3904] Test --- src/cc/marmara.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 7fefb9eb6..def21763a 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -509,9 +509,6 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) { cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); - mtx.vout.resize(2); - mtx.vout[1].scriptPubKey = tx.vout[numvouts - 1].scriptPubKey; - mtx.vout[1].nValue = 0; pubkeys.push_back(mypk); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tx.vout[numvouts - 1].scriptPubKey,pubkeys); if ( rawtx.size() > 0 ) From 923b87a6ecf93b294522207f668d3a3be5be75fc Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 21 Jan 2019 13:04:18 +0100 Subject: [PATCH 1382/3904] [add] dylib --- src/cc/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index a3c54d81d..92fbe0da9 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -2,7 +2,7 @@ SHELL = /bin/sh CC = gcc CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup +CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG @@ -10,8 +10,9 @@ RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) OS := $(shell uname -s) $(info $(OS)) -TARGET = ../cclib.so -TARGET_WIN = ../cclib.dll +TARGET = ../libcc.so +TARGET_DARWIN = ../libcc.dylib +TARGET_WIN = ../libcc.dll SOURCES = cclib.cpp #HEADERS = $(shell echo ../cryptoconditions/include/*.h) @@ -20,7 +21,7 @@ all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib to src/) ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) $(SOURCES) else ifeq ($(OS),Linux) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host From b516423fed2daea7f9ccd9166deffe274f6c5c9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:07:50 -1100 Subject: [PATCH 1383/3904] -print --- src/cc/marmara.cpp | 2 +- src/komodo_bitcoind.h | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index def21763a..db794c33b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -265,7 +265,7 @@ bool MarmaraPoScheck(char *destaddr,CScript opret,CScript scriptPubKey) Marmarapk = GetUnspendable(cp,0); GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); fprintf(stderr,"matched opret! funcid.%c ht.%d unlock.%d %s\n",funcid,height,unlockht,coinaddr); - return(strcmp(destaddr,coinaddr)); + return(strcmp(destaddr,coinaddr) == 0); } return(0); } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index eb033f96a..c2d2716c1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -644,7 +644,7 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) if ( ASSETCHAINS_STAKED != 0 ) { n = pblock->vtx.size(); - fprintf(stderr,"ht.%d check for PoS numtx.%d numvins.%d numvouts.%d\n",height,n,(int32_t)pblock->vtx[n-1].vin.size(),(int32_t)pblock->vtx[n-1].vout.size()); + //fprintf(stderr,"ht.%d check for PoS numtx.%d numvins.%d numvouts.%d\n",height,n,(int32_t)pblock->vtx[n-1].vin.size(),(int32_t)pblock->vtx[n-1].vout.size()); if ( n > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1+(ASSETCHAINS_MARMARA!=0) ) { txid = pblock->vtx[n-1].vin[0].prevout.hash; @@ -662,7 +662,7 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) { if ( pblock->vtx[n-1].vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 && (numvouts= pblock->vtx[n-1].vout.size()) > 1 ) { -fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); +//fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); return(MarmaraPoScheck(destaddr,opret,pblock->vtx[n-1].vout[numvouts-1].scriptPubKey)); } else @@ -1464,13 +1464,13 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && pindex->segid >= -1 ) { - fprintf(stderr,"isPoSblock segid.%d\n",pindex->segid); + //fprintf(stderr,"isPoSblock segid.%d\n",pindex->segid); if ( pindex->segid == -1 ) return(0); else return(1); } txn_count = pblock->vtx.size(); - fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,(int32_t)pblock->vtx[txn_count-1].vin.size(),(int32_t)pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN); + //fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,(int32_t)pblock->vtx[txn_count-1].vin.size(),(int32_t)pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) { it = mapBlockIndex.find(pblock->hashPrevBlock); @@ -1786,7 +1786,6 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) bnTarget.SetCompact(pblock->nBits,&fNegative,&fOverflow); bhash = UintToArith256(hash); possible = komodo_block2pubkey33(pubkey33,pblock); -fprintf(stderr,"checkPoW ht.%d\n",height); if ( height == 0 ) { if ( slowflag != 0 ) @@ -1831,7 +1830,7 @@ fprintf(stderr,"checkPoW ht.%d\n",height); return(-1); } } - fprintf(stderr,"ASSETCHAINS_STAKED.%d ht.%d\n",(int32_t)ASSETCHAINS_STAKED,height); + //fprintf(stderr,"ASSETCHAINS_STAKED.%d ht.%d\n",(int32_t)ASSETCHAINS_STAKED,height); if ( ASSETCHAINS_STAKED != 0 && height >= 2 ) // must PoS or have at least 16x better PoW { if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 ) From 7422ae2038221259712d378b976d979bbad0f788 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:24:16 -1100 Subject: [PATCH 1384/3904] +print --- src/cc/marmara.cpp | 7 +++++-- src/komodo_bitcoind.h | 8 ++++---- src/miner.cpp | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index db794c33b..3ddbac581 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -255,10 +255,13 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) return(-1); } -bool MarmaraPoScheck(char *destaddr,CScript opret,CScript scriptPubKey) +bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx) { CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; - if ( opret == scriptPubKey ) + UniValue result(UniValue::VOBJ); + TxToJSON(tx, uint256(), result); + fprintf(stderr,"%s\n",result.ToString()); + if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); funcid = DecodeMaramaraCoinbaseOpRet(opret,pk,height,unlockht); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c2d2716c1..bdcad8d7b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -636,7 +636,7 @@ int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout) return(0); } -bool MarmaraPoScheck(char *destaddr,CScript opret,CScript scriptPubKey); +bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx); int32_t komodo_isPoS(CBlock *pblock,int32_t height) { @@ -653,17 +653,17 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); - fprintf(stderr,"voutaddr.%s vs destaddr.%s\n",voutaddr,destaddr); + //fprintf(stderr,"voutaddr.%s vs destaddr.%s\n",voutaddr,destaddr); if ( pblock->vtx[n-1].vout[0].nValue == value && strcmp(destaddr,voutaddr) == 0 ) { if ( ASSETCHAINS_MARMARA == 0 ) return(1); else { - if ( pblock->vtx[n-1].vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 && (numvouts= pblock->vtx[n-1].vout.size()) > 1 ) + if ( pblock->vtx[n-1].vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 && (numvouts= pblock->vtx[n-1].vout.size()) == 2 ) { //fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr); - return(MarmaraPoScheck(destaddr,opret,pblock->vtx[n-1].vout[numvouts-1].scriptPubKey)); + return(MarmaraPoScheck(destaddr,opret,pblock->vtx[n-1])); } else { diff --git a/src/miner.cpp b/src/miner.cpp index 78eb84e7b..01ff9da0c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); +printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } // Create coinbase tx From dbb103571e4c4a463dbf9abb74a16a42d23e51fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:26:37 -1100 Subject: [PATCH 1385/3904] Test --- src/cc/marmara.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 3ddbac581..40d8b1efb 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -258,9 +258,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx) { CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; - UniValue result(UniValue::VOBJ); - TxToJSON(tx, uint256(), result); - fprintf(stderr,"%s\n",result.ToString()); + fprintf(stderr,"numvins.%d numvouts.%d\n",(int32_t)statketx.vin.size(),(int32_t)statketx.vout.size(),(double),(int32_t)statketx.vout[0].nValue/COIN); if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); From aa2ebd7fc41e9b1334bc9d14a0840c608f22910e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:27:19 -1100 Subject: [PATCH 1386/3904] staketx --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 40d8b1efb..c739a9203 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -258,7 +258,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx) { CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; - fprintf(stderr,"numvins.%d numvouts.%d\n",(int32_t)statketx.vin.size(),(int32_t)statketx.vout.size(),(double),(int32_t)statketx.vout[0].nValue/COIN); + fprintf(stderr,"numvins.%d numvouts.%d\n",(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double),(int32_t)staketx.vout[0].nValue/COIN); if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); From ee69d8f4f8d5a8f374899e0cf48470bde734fccb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:28:31 -1100 Subject: [PATCH 1387/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index c739a9203..8a5ead91b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -258,7 +258,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx) { CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; - fprintf(stderr,"numvins.%d numvouts.%d\n",(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double),(int32_t)staketx.vout[0].nValue/COIN); + fprintf(stderr,"numvins.%d numvouts.%d\n",(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN); if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); From 3c5385e0402551eb0c6732063a120ca4f8b322b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:29:19 -1100 Subject: [PATCH 1388/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8a5ead91b..de6018972 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -258,7 +258,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx) { CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; - fprintf(stderr,"numvins.%d numvouts.%d\n",(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN); + fprintf(stderr,"numvins.%d numvouts.%d %.8f\n",(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN); if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); From cae100974056d84a1c9845fc6fcc293d15b049b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:33:27 -1100 Subject: [PATCH 1389/3904] Test --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index de6018972..5adc12d43 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -258,7 +258,7 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx) { CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; - fprintf(stderr,"numvins.%d numvouts.%d %.8f\n",(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN); + fprintf(stderr,"%s numvins.%d numvouts.%d %.8f opret[%d]\n",staketx.GetHash().ToString().c_str(),(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN,(int32_t)opret.size()); if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); From d4520254969223ecc78cb02599f5d4b5d5c77902 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:39:45 -1100 Subject: [PATCH 1390/3904] Filter staking utxo --- src/komodo_bitcoind.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bdcad8d7b..39b905e86 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2170,7 +2170,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { - struct CCcontract_info *cp,C; uint256 txid; int32_t vout; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk; + struct CCcontract_info *cp,C; uint256 txid; int32_t vout,ht,unlockht; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk,pk; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); @@ -2186,8 +2186,12 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( GetTransaction(txid,tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { const CScript &scriptPubKey = tx.vout[vout].scriptPubKey; - array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,txid,vout,coinaddr,hashbuf,(CScript)scriptPubKey); - //fprintf(stderr,"addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp); + if ( DecodeMaramaraCoinbaseOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,pk,ht,unlockht) != 0 && pk == mypk ) + { + array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,txid,vout,coinaddr,hashbuf,(CScript)scriptPubKey); + } + else + fprintf(stderr,"SKIP addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp); } } } From 3dcea8bd51c323806123600f81af07bff993f654 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:40:51 -1100 Subject: [PATCH 1391/3904] Test --- src/komodo_bitcoind.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 39b905e86..09bc4b9fa 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2088,6 +2088,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod } int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew); +uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32_t &height,int32_t &unlockht); int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) { From c2e1da32786660f780c9f905ec36d7cb81e1a0e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:44:31 -1100 Subject: [PATCH 1392/3904] Allow coinbase spending --- src/cc/marmara.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5adc12d43..9062ab2b8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -334,6 +334,10 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t { return(true); } + else if ( funcid == 'C' ) // coinbase + { + return(true); + } // staking only for locked utxo } return eval->Invalid("fall through error"); From b9f15395d7fafeaf690672ad1445d14e86f134fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:46:48 -1100 Subject: [PATCH 1393/3904] -print --- src/cc/marmara.cpp | 8 ++++---- src/komodo_bitcoind.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 9062ab2b8..8f8de12e2 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -94,7 +94,7 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32 { return(script[1]); } else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for %c\n",script[1]); - } else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d or 'L' %d\n",script[1],'C','P','L'); + } //else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d or 'L' %d\n",script[1],'C','P','L'); } else fprintf(stderr,"vopret.size() is %d\n",(int32_t)vopret.size()); return(0); } @@ -258,14 +258,14 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx) { CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C; - fprintf(stderr,"%s numvins.%d numvouts.%d %.8f opret[%d]\n",staketx.GetHash().ToString().c_str(),(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN,(int32_t)opret.size()); + //fprintf(stderr,"%s numvins.%d numvouts.%d %.8f opret[%d]\n",staketx.GetHash().ToString().c_str(),(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN,(int32_t)opret.size()); if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey ) { cp = CCinit(&C,EVAL_MARMARA); funcid = DecodeMaramaraCoinbaseOpRet(opret,pk,height,unlockht); Marmarapk = GetUnspendable(cp,0); GetCCaddress1of2(cp,coinaddr,Marmarapk,pk); - fprintf(stderr,"matched opret! funcid.%c ht.%d unlock.%d %s\n",funcid,height,unlockht,coinaddr); + //fprintf(stderr,"matched opret! funcid.%c ht.%d unlock.%d %s\n",funcid,height,unlockht,coinaddr); return(strcmp(destaddr,coinaddr) == 0); } return(0); @@ -525,7 +525,7 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) utxosig[i] = ptr[i]; //fprintf(stderr,"%02x",ptr[i]); } - fprintf(stderr," got signed rawtx.%s siglen.%d\n",rawtx.c_str(),siglen); + //fprintf(stderr," got signed rawtx.%s siglen.%d\n",rawtx.c_str(),siglen); return(siglen); } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 09bc4b9fa..19ec0546b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2191,8 +2191,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt { array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,txid,vout,coinaddr,hashbuf,(CScript)scriptPubKey); } - else - fprintf(stderr,"SKIP addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp); + // else fprintf(stderr,"SKIP addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp); } } } From 7966cef9ec5805aab066420ab08154032c680353 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 01:55:29 -1100 Subject: [PATCH 1394/3904] MTST2 exemption --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 19ec0546b..c9a91d289 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -668,7 +668,7 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height) else { fprintf(stderr,"reject ht.%d PoS block\n",height); - return(1); // allow until MTST3 + return(strcmp(ASSETCHAINS_SYMBOL,"MTST2") == 0); // allow until MTST3 } } } From e9083421a8f9a2ba7d355f9b862670638a439d2f Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Mon, 21 Jan 2019 22:00:35 +0700 Subject: [PATCH 1395/3904] checking channelspayment case when opening node revealed secret in offline --- qa/rpc-tests/cryptoconditions_channels.py | 70 +++++++++++++++++++++++ qa/rpc-tests/cryptoconditions_token.py | 4 +- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index cec45687f..115c2228f 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -4,6 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. +import time from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ @@ -71,6 +72,32 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): result = rpc.channelsinfo(channel_txid) assert_equal(result["Transactions"][1]["Payment"], payment_tx_id) + # TODO: check if payment value really transferred + # TODO: check if information in channelinfo changed correct + + # TODO: try to drain channel (10 payment by 100000 satoshies in total) + + # have to check that second node have coins to cover txfee at least + rpc.sendtoaddress(rpc1.getnewaddress(), 1) + rpc.sendtoaddress(rpc1.getnewaddress(), 1) + rpc.generate(2) + self.sync_all() + result = rpc1.getbalance() + assert_greater_than(result, 0.1) + + # trying to initiate channels payment from node B without any secret + # TODO: have to add RPC validation + payment_hex = rpc1.channelspayment(channel_txid, "100000") + try: + result = rpc1.sendrawtransaction(payment_hex["hex"]) + except Exception as e: + pass + + # trying to initiate channels payment from node B with secret from previous payment + result = rpc1.channelspayment(channel_txid, "100000", rpc1.channelsinfo(channel_txid)["Transactions"][1]["Secret"]) + #result = rpc1.sendrawtransaction(payment_hex["hex"]) + assert_error(result) + # executing channel close result = rpc.channelsclose(channel_txid) assert_success(result) @@ -90,6 +117,49 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): refund_txid = self.send_and_mine(result["hex"], rpc) assert refund_txid, "got txid" + # TODO: check if it really refunded + + # creating new channel to test the case when node B initiate payment when node A revealed secret but + # secret revealing transaction not mined + # 10 payments, 100000 sat denomination channel opening with second node pubkey + new_channel_hex2 = rpc.channelsopen(self.pubkey1, "10", "100000") + assert_success(new_channel_hex) + channel2_txid = self.send_and_mine(new_channel_hex2["hex"], rpc) + assert channel2_txid, "got channel txid" + + rpc.generate(2) + self.sync_all() + + # disconnecting first node from network + rpc.setban("127.0.0.0/24","add") + assert_equal(rpc.getinfo()["connections"], 0) + + # sending one payment to mempool to reveal the secret but not mine it + payment_hex = rpc.channelspayment(channel2_txid, "100000") + result = rpc.sendrawtransaction(payment_hex["hex"]) + assert result, "got payment txid" + + secret = rpc.channelsinfo(channel2_txid)["Transactions"][1]["Secret"] + assert secret, "Secret revealed" + + # secret shouldn't be available for node B + secret_not_revealed = None + try: + rpc1.channelsinfo(channel2_txid)["Transactions"][1]["Secret"] + except Exception: + secret_not_revealed = True + assert_equal(secret_not_revealed, True) + + # trying to initiate payment from second node with revealed secret + assert_equal(rpc1.getinfo()["connections"], 0) + dc_payment_hex = rpc1.channelspayment(channel2_txid, "100000", secret) + assert_success(dc_payment_hex) + result = rpc1.sendrawtransaction(dc_payment_hex["hex"]) + assert result, "got channelspayment transaction id" + + + # TODO: have to connect nodes back to not corrupt other tests + def run_test(self): print("Mining blocks...") rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 5fd3256d6..97ed86f8d 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -142,7 +142,8 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): # checking ask cancellation testorder = rpc.tokenask("100", tokenid, "7.77") testorderid = self.send_and_mine(testorder['hex'], rpc) - # from other node + # from other node (ensuring that second node have enough balance to cover txfee + # to get the actual error - not "not enough balance" one rpc.sendtoaddress(rpc1.getnewaddress(), 1) rpc.sendtoaddress(rpc1.getnewaddress(), 1) rpc.generate(2) @@ -253,5 +254,6 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): rpc1.importprivkey(self.privkey1) self.run_token_tests() + if __name__ == '__main__': CryptoconditionsTokenTest().main() From 2c3247e8f1e8e9e9fe5336fb6b94353d7a98817b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 22 Jan 2019 00:12:05 +0800 Subject: [PATCH 1396/3904] Enable -ac_algo=verushash11 --- src/chainparams.cpp | 8 +++----- src/init.cpp | 8 +++++++- src/komodo_bitcoind.h | 6 ++---- src/komodo_globals.h | 18 +++++++++--------- src/komodo_utils.h | 5 +++-- src/metrics.cpp | 4 ++-- src/miner.cpp | 32 +++++++++++++++++++++++++------- src/primitives/block.cpp | 12 ++++++++++-- src/primitives/block.h | 1 + src/wallet-utility.cpp | 1 + 10 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6b0627d20..368e0eb50 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -94,11 +94,10 @@ void *chainparams_commandline(void *ptr); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; +extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; +extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO; -extern int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { @@ -269,8 +268,7 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); - - if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing diff --git a/src/init.cpp b/src/init.cpp index 3dd09ac50..6aca3ce1b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1177,7 +1177,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) globalVerifyHandle.reset(new ECCVerifyHandle()); // set the hash algorithm to use for this chain - extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH; + // Again likely better solution here, than using long IF ELSE. + extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; CVerusHash::init(); CVerusHashV2::init(); if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) @@ -1185,6 +1186,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // initialize VerusHash CBlockHeader::SetVerusHash(); } + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + { + // initialize VerusHashV2 + CBlockHeader::SetVerusHashV2(); + } // Sanity check if (!InitSanityCheck()) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2fea50e7b..b567c1488 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1296,11 +1296,11 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) { if ( blocktime+iter+segid*2 > prevtime+200 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+120)); - } + } if ( blocktime+iter+segid*2 > prevtime+480 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); coinage256 = arith_uint256(coinage+1); @@ -1379,8 +1379,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } - // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! - // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 70d621756..2c2d4e855 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -68,22 +68,22 @@ int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; -uint32_t ASSETCHAINS_LASTERA = 1; +uint64_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; #define _ASSETCHAINS_EQUIHASH 0 -uint32_t ASSETCHAINS_NUMALGOS = 2; +uint32_t ASSETCHAINS_NUMALGOS = 3; uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH; uint32_t ASSETCHAINS_VERUSHASH = 1; -const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash"}; -uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff}; -uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16}; -uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096}; +uint32_t ASSETCHAINS_VERUSHASHV2 = 2; +const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash", "verushash11"}; +uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff,0xfffffff}; +uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; +uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905}; - // nBits.486704888 -- too low? - +// VerusHash v1 and 1.1 use a custom tuned number or PoW blocks all are 1s. +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905,486648905}; // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 74e82f1e2..1fe4c012a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1742,9 +1742,10 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS ) { ASSETCHAINS_LASTERA = 1; - printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %u\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); + printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; + printf("ASSETCHAINS_LASTERA = %lu\n", ASSETCHAINS_LASTERA); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); @@ -2069,7 +2070,7 @@ void komodo_args(char *argv0) if ( strcmp("PIRATE",ASSETCHAINS_SYMBOL) == 0 && ASSETCHAINS_HALVING[0] == 77777 ) { ASSETCHAINS_HALVING[0] *= 5; - fprintf(stderr,"PIRATE halving changed to %d %.1f days ASSETCHAINS_LASTERA.%d\n",(int32_t)ASSETCHAINS_HALVING[0],(double)ASSETCHAINS_HALVING[0]/1440,ASSETCHAINS_LASTERA); + fprintf(stderr,"PIRATE halving changed to %d %.1f days ASSETCHAINS_LASTERA.%lu\n",(int32_t)ASSETCHAINS_HALVING[0],(double)ASSETCHAINS_HALVING[0]/1440,ASSETCHAINS_LASTERA); } else if ( strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 ) dpowconfs = 0; diff --git a/src/metrics.cpp b/src/metrics.cpp index a01d381a1..879765933 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -40,7 +40,7 @@ #include extern uint64_t ASSETCHAINS_TIMELOCKGTE; -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH; +extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; int64_t komodo_block_unlocktime(uint32_t nHeight); void AtomicTimer::start() @@ -137,7 +137,7 @@ int64_t GetUptime() double GetLocalSolPS() { - if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) { return miningTimer.rate(nHashCount); } diff --git a/src/miner.cpp b/src/miner.cpp index aac5164cb..66f1a263f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -137,7 +137,7 @@ extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; -extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; +extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],NOTARYADDRS[64][36]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); @@ -1324,26 +1324,44 @@ void static BitcoinMiner_noeq() while (true) { arith_uint256 arNonce = UintToArith256(pblock->nNonce); - + int64_t *extraPtr; + + // This seems to be a really bad way to do this, but its better than copy pasting the entire miner function at this stage. CVerusHashWriter ss = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION); ss << *((CBlockHeader *)pblock); - int64_t *extraPtr = ss.xI64p(); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + extraPtr = ss.xI64p(); CVerusHash &vh = ss.GetState(); uint256 hashResult = uint256(); vh.ClearExtra(); + + CVerusHashV2Writer ss2 = CVerusHashV2Writer(SER_GETHASH, PROTOCOL_VERSION); + ss2 << *((CBlockHeader *)pblock); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + extraPtr = ss2.xI64p(); + CVerusHashV2 &vh2 = ss2.GetState(); + vh2.ClearExtra(); + int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; - if ( ASSETCHAINS_STAKED != 0) + if ( ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 ) { - if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED < 100 ) + if ( KOMODO_MININGTHREADS > 0 ) hashTarget = HASHTarget_POW; - else hashTarget = HASHTarget; + else + hashTarget = HASHTarget; } + else if ( ASSETCHAINS_STAKED == 100 && Mining_height > 100 ) + hashTarget = HASHTarget; + // for speed check NONCEMASK at a time for (i = 0; i < count; i++) { *extraPtr = i; - vh.ExtraHash((unsigned char *)&hashResult); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + vh.ExtraHash((unsigned char *)&hashResult); + else if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + vh2.ExtraHash((unsigned char *)&hashResult); if ( UintToArith256(hashResult) <= hashTarget ) { diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 00fc8cee9..3c0dfdd37 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -46,8 +46,11 @@ uint256 CBlockHeader::GetVerusHash() const uint256 CBlockHeader::GetVerusV2Hash() const { - // no check for genesis block and use the optimized hash - return SerializeVerusHashV2(*this); + if (hashPrevBlock.IsNull()) + // always use SHA256D for genesis block + return SerializeHash(*this); + else + return SerializeVerusHashV2(*this); } void CBlockHeader::SetSHA256DHash() @@ -60,6 +63,11 @@ void CBlockHeader::SetVerusHash() CBlockHeader::hashFunction = &CBlockHeader::GetVerusHash; } +void CBlockHeader::SetVerusHashV2() +{ + CBlockHeader::hashFunction = &CBlockHeader::GetVerusV2Hash; +} + // returns false if unable to fast calculate the VerusPOSHash from the header. // if it returns false, value is set to 0, but it can still be calculated from the full block // in that case. the only difference between this and the POS hash for the contest is that it is not divided by the value out diff --git a/src/primitives/block.h b/src/primitives/block.h index 5cd0a72fe..6ef8e0633 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -106,6 +106,7 @@ public: uint256 GetVerusEntropyHash(int32_t nHeight) const; uint256 GetVerusV2Hash() const; + static void SetVerusHashV2(); int64_t GetBlockTime() const { diff --git a/src/wallet-utility.cpp b/src/wallet-utility.cpp index 7af2ca5bf..f4041dfbe 100644 --- a/src/wallet-utility.cpp +++ b/src/wallet-utility.cpp @@ -18,6 +18,7 @@ uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint32_t ASSETCHAINS_EQUIHASH = 0; uint32_t ASSETCHAINS_VERUSHASH = 1; +uint32_t ASSETCHAINS_VERUSHASHV2 = 2; uint32_t ASSETCHAINS_ALGO = 0; int32_t ASSETCHAINS_LWMAPOS = 0; int32_t VERUS_BLOCK_POSUNITS = 1000; From 8324e606cd99b240b812013fa3e5f43854d6a6e6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 22 Jan 2019 14:39:29 +0800 Subject: [PATCH 1397/3904] try to add PoS% to staking loop, to adjust staking difficulty --- src/chainparams.cpp | 14 ++- src/komodo_bitcoind.h | 220 +++++++++++++++++++++++------------------- src/komodo_globals.h | 5 +- src/pow.cpp | 2 + 4 files changed, 135 insertions(+), 106 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 368e0eb50..03a518d4b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -94,9 +94,9 @@ void *chainparams_commandline(void *ptr); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; +extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO; +extern uint64_t ASSETCHAINS_SUPPLY; const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); @@ -268,7 +268,7 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); - if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing @@ -276,6 +276,14 @@ void *chainparams_commandline(void *ptr) mainParams.consensus.nPowAveragingWindow = 45; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); } + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + { + // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: + // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing + mainParams.consensus.nLwmaAjustedWeight = 1350; + mainParams.consensus.nPowAveragingWindow = 45; + mainParams.consensus.powAlternate = uint256S("000000ff0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); + } if (ASSETCHAINS_LWMAPOS != 0) { diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b567c1488..d2c3b3b30 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1253,95 +1253,6 @@ uint32_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256 return(addrhash.uints[0]); } -uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr) -{ - bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t diff=0,segid,minage,i,iter=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; - txtime = komodo_txtime2(&value,txid,vout,address); - if ( validateflag == 0 ) - { - //fprintf(stderr,"blocktime.%u -> ",blocktime); - if ( blocktime < prevtime+3 ) - blocktime = prevtime+3; - if ( blocktime < GetAdjustedTime()-60 ) - blocktime = GetAdjustedTime()+30; - //fprintf(stderr,"blocktime.%u txtime.%u\n",blocktime,txtime); - } - if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) - { - //fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); - return(0); - } - if ( value < SATOSHIDEN ) - return(0); - value /= SATOSHIDEN; - mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); - ratio = (mindiff / bnTarget); - if ( (minage= nHeight*3) > 6000 ) // about 100 blocks - minage = 6000; - komodo_segids(hashbuf,nHeight-101,100); - segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); - segid = ((nHeight + segid32) & 0x3f); - for (iter=0; iter<600; iter++) - { - if ( blocktime+iter+segid*2 < txtime+minage ) - continue; - diff = (iter + blocktime - txtime - minage); - if ( diff < 0 ) - diff = 60; - else if ( diff > 3600*24*30 ) - { - //printf("diff.%d (iter.%d blocktime.%u txtime.%u minage.%d)\n",(int32_t)diff,iter,blocktime,txtime,(int32_t)minage); - diff = 3600*24*30; - } - if ( iter > 0 ) - diff += segid*2; - coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) - { - if ( blocktime+iter+segid*2 > prevtime+200 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+120)); - } - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); - coinage256 = arith_uint256(coinage+1); - hashval = ratio * (UintToArith256(hash) / coinage256); - if ( hashval <= bnTarget ) - { - winner = 1; - if ( validateflag == 0 ) - { - //fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); - blocktime += iter; - blocktime += segid * 2; - } - break; - } - if ( validateflag != 0 ) - { - /*for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," vs "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ - break; - } - } - //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( 0 && validateflag != 0 ) - { - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," vs "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d ht.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff,nHeight); - } - if ( nHeight < 10 ) - return(blocktime); - return(blocktime * winner); -} - arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { int32_t oldflag = 0,dispflag = 1; @@ -1380,7 +1291,17 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr," %d, ",percPoS); } if ( m+n < 100 ) - percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + { + // We do actual PoS % at the start. Requires coin distribution in first 10 blocks! + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + percPoS = (percPoS*100) / (m+n); + else + // This seems to be inverse. The actual PoS % is backwards in the first 100 blocks. + // I dont't understand the math here, or why its backwards, so I am just disabling it for VerusHash. + // No doubt this is probably wrong for equihash aswell, we may need to test an equihash chain with the rule above. + // Need to ask james what the deal is here! Seems to be causeing ALL the problems. + percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + } if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; @@ -1444,9 +1365,104 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he return(bnTarget); } +uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr,int32_t PoSperc) +{ + bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t diff=0,segid,minage,i,iter=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; + txtime = komodo_txtime2(&value,txid,vout,address); + if ( validateflag == 0 ) + { + //fprintf(stderr,"blocktime.%u -> ",blocktime); + if ( blocktime < prevtime+3 ) + blocktime = prevtime+3; + if ( blocktime < GetAdjustedTime()-60 ) + blocktime = GetAdjustedTime()+30; + //fprintf(stderr,"blocktime.%u txtime.%u\n",blocktime,txtime); + } + if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) + { + //fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); + return(0); + } + if ( value < SATOSHIDEN ) + return(0); + value /= SATOSHIDEN; + mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); + ratio = (mindiff / bnTarget); + if ( (minage= nHeight*3) > 6000 ) // about 100 blocks + minage = 6000; + komodo_segids(hashbuf,nHeight-101,100); + segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); + segid = ((nHeight + segid32) & 0x3f); + for (iter=0; iter<600; iter++) + { + if ( blocktime+iter+segid*2 < txtime+minage ) + continue; + diff = (iter + blocktime - txtime - minage); + if ( diff < 0 ) + diff = 60; + else if ( diff > 3600*24*30 ) + { + //printf("diff.%d (iter.%d blocktime.%u txtime.%u minage.%d)\n",(int32_t)diff,iter,blocktime,txtime,(int32_t)minage); + diff = 3600*24*30; + } + if ( iter > 0 ) + diff += segid*2; + coinage = (value * diff); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + { + fprintf(stderr, "PoS % is: %i% vs. %i% \n", PoSperc, ASSETCHAINS_STAKED); + if ( PoSperc < ASSETCHAINS_STAKED ) + { + // This means we are under PoS % required and we need some extra help getting an elegible utxo. + // Likley there is some math required here to make it work properly. But getting the data here is no1 priority. + coinage = coinage * 1000; + } + } + // leave this here for now... + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + coinage256 = arith_uint256(coinage+1); + hashval = ratio * (UintToArith256(hash) / coinage256); + if ( hashval <= bnTarget ) + { + winner = 1; + if ( validateflag == 0 ) + { + //fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); + blocktime += iter; + blocktime += segid * 2; + } + break; + } + if ( validateflag != 0 ) + { + /*for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," vs "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ + break; + } + } + //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); + if ( 0 && validateflag != 0 ) + { + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," vs "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d ht.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff,nHeight); + } + if ( nHeight < 10 ) + return(blocktime); + return(blocktime * winner); +} + int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_uint256 bnTarget,arith_uint256 bhash) { - CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; + CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; arith_uint256 POWTarget; if ( ASSETCHAINS_STAKED == 100 && height <= 100 ) return(1); BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); @@ -1457,6 +1473,8 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ return(0); else return(1); } + // Get PoSperc and POW Target. for later. + POWTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); txn_count = pblock->vtx.size(); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 ) { @@ -1470,7 +1488,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( komodo_isPoS(pblock) != 0 ) { - eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime+27,(char *)""); + eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime+27,(char *)"",PoSperc); } if ( eligible == 0 || eligible > pblock->nTime ) { @@ -1515,8 +1533,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ } else { - bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); - if ( bhash < bnTarget ) + if ( bhash < POWTarget ) { //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; @@ -2085,10 +2102,11 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) { static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; - set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; + int32_t PoSperc; + set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget,tmpTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; - + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); @@ -2100,6 +2118,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( (tipindex= chainActive.Tip()) == 0 ) return(0); nHeight = tipindex->GetHeight() + 1; + // Get the PoS% so we can pass it to komodo_stake, this is to adjust PoS dofficulty when it is under the target %! + tmpTarget = komodo_PoWtarget(&PoSperc,bnTarget,nHeight,ASSETCHAINS_STAKED); if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; komodo_segids(hashbuf,nHeight-101,100); @@ -2119,7 +2139,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } - if ( time(NULL) > lasttime+600 || array == 0 || resetstaker ) + if ( resetstaker || array == 0 || time(NULL) > lasttime+600 ) { LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); @@ -2175,14 +2195,14 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt kp = &array[i]; if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) continue; - eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); + eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address,PoSperc); //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; - if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address,PoSperc) ) { - while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address,PoSperc) ) { besttime = eligible; eligible--; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 2c2d4e855..cb1d9987d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -82,9 +82,8 @@ uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -// VerusHash v1 and 1.1 use a custom tuned number or PoW blocks all are 1s. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905,486648905}; - +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,503381775,503381775}; + // ^ wrong! // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS int32_t VERUS_BLOCK_POSUNITS = 1024; // one block is 1000 units diff --git a/src/pow.cpp b/src/pow.cpp index b69c4fce6..0e4b706a8 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -134,6 +134,8 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const bnLimit = UintToArith256(params.powAlternate); unsigned int nProofOfWorkLimit = bnLimit.GetCompact(); + + printf("PoWLimit: %u\n", nProofOfWorkLimit); // Find the first block in the averaging interval as we total the linearly weighted average const CBlockIndex* pindexFirst = pindexLast; From 3f64474f85ab93dee257c0182c870e4daa33e07e Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Tue, 22 Jan 2019 15:03:52 +0700 Subject: [PATCH 1398/3904] more channels tests --- qa/pull-tester/cc-tests.sh | 3 +- qa/rpc-tests/cryptoconditions_channels.py | 87 ++++++++++++++++++++--- 2 files changed, 80 insertions(+), 10 deletions(-) diff --git a/qa/pull-tester/cc-tests.sh b/qa/pull-tester/cc-tests.sh index f2abde883..9bc8c155d 100755 --- a/qa/pull-tester/cc-tests.sh +++ b/qa/pull-tester/cc-tests.sh @@ -13,12 +13,13 @@ export BITCOIND=${REAL_BITCOIND} testScripts=( 'cryptoconditions_faucet.py' - 'cryptoconditions_channels.py' 'cryptoconditions_dice.py' 'cryptoconditions_oracles.py' 'cryptoconditions_rewards.py' 'cryptoconditions_token.py' #'cryptoconditions_gateways.py' + # TODO: cant reconnect nodes back in channels test because of crash (seems regtest only specific) + 'cryptoconditions_channels.py' ); extArg="-extended" diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 115c2228f..b2a49b477 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -72,10 +72,36 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): result = rpc.channelsinfo(channel_txid) assert_equal(result["Transactions"][1]["Payment"], payment_tx_id) - # TODO: check if payment value really transferred - # TODO: check if information in channelinfo changed correct + # number of payments should be equal 1 (one denomination used) + result = rpc.channelsinfo(channel_txid)["Transactions"][1]["Number of payments"] + assert_equal(result, 1) + # payments left param should reduce 1 and be equal 9 now ( 10 - 1 = 9 ) + result = rpc.channelsinfo(channel_txid)["Transactions"][1]["Payments left"] + assert_equal(result, 9) - # TODO: try to drain channel (10 payment by 100000 satoshies in total) + # lets try payment with x2 amount to ensure that counters works correct + result = rpc.channelspayment(channel_txid, "200000") + assert_success(result) + payment_tx_id = self.send_and_mine(result["hex"], rpc) + assert payment_tx_id, "got txid" + + result = rpc.channelsinfo(channel_txid) + assert_equal(result["Transactions"][2]["Payment"], payment_tx_id) + + result = rpc.channelsinfo(channel_txid)["Transactions"][2]["Number of payments"] + assert_equal(result, 2) + + result = rpc.channelsinfo(channel_txid)["Transactions"][2]["Payments left"] + assert_equal(result, 7) + + # check if payment value really transferred + raw_transaction = rpc.getrawtransaction(payment_tx_id, 1) + + result = raw_transaction["vout"][3]["valueSat"] + assert_equal(result, 200000) + + result = rpc1.validateaddress(raw_transaction["vout"][3]["scriptPubKey"]["addresses"][0])["ismine"] + assert_equal(result, True) # have to check that second node have coins to cover txfee at least rpc.sendtoaddress(rpc1.getnewaddress(), 1) @@ -109,7 +135,7 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): # now in channelinfo closed flag should appear result = rpc.channelsinfo(channel_txid) - assert_equal(result["Transactions"][2]["Close"], channel_close_txid) + assert_equal(result["Transactions"][3]["Close"], channel_close_txid) # executing channel refund result = rpc.channelsrefund(channel_txid, channel_close_txid) @@ -117,10 +143,41 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): refund_txid = self.send_and_mine(result["hex"], rpc) assert refund_txid, "got txid" - # TODO: check if it really refunded + # TODO: check if it refunded to opener address + raw_transaction = rpc.getrawtransaction(refund_txid, 1) - # creating new channel to test the case when node B initiate payment when node A revealed secret but - # secret revealing transaction not mined + result = raw_transaction["vout"][2]["valueSat"] + assert_equal(result, 700000) + + result = rpc.validateaddress(raw_transaction["vout"][2]["scriptPubKey"]["addresses"][0])["ismine"] + assert_equal(result, True) + + + # creating and draining channel (10 payment by 100000 satoshies in total to fit full capacity) + new_channel_hex1 = rpc.channelsopen(self.pubkey1, "10", "100000") + assert_success(new_channel_hex1) + channel1_txid = self.send_and_mine(new_channel_hex1["hex"], rpc) + assert channel1_txid, "got channel txid" + + # need to have 2+ confirmations in the test mode + rpc.generate(2) + self.sync_all() + + for i in range(10): + result = rpc.channelspayment(channel1_txid, "100000") + assert_success(result) + payment_tx_id = self.send_and_mine(result["hex"], rpc) + assert payment_tx_id, "got txid" + + # last payment should indicate that 0 payments left + result = rpc.channelsinfo(channel1_txid)["Transactions"][10]["Payments left"] + assert_equal(result, 0) + + # no more payments possible + result = rpc.channelspayment(channel1_txid, "100000") + assert_error(result) + + # creating new channel to test the case when node B initiate payment when node A revealed secret in offline # 10 payments, 100000 sat denomination channel opening with second node pubkey new_channel_hex2 = rpc.channelsopen(self.pubkey1, "10", "100000") assert_success(new_channel_hex) @@ -133,6 +190,9 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): # disconnecting first node from network rpc.setban("127.0.0.0/24","add") assert_equal(rpc.getinfo()["connections"], 0) + assert_equal(rpc1.getinfo()["connections"], 0) + + rpc1.generate(1) # sending one payment to mempool to reveal the secret but not mine it payment_hex = rpc.channelspayment(channel2_txid, "100000") @@ -157,8 +217,17 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): result = rpc1.sendrawtransaction(dc_payment_hex["hex"]) assert result, "got channelspayment transaction id" - - # TODO: have to connect nodes back to not corrupt other tests + # TODO: it crash first node after block generating on mempools merging + # # restoring connection between nodes + # rpc.setban("127.0.0.0/24","remove") + # #rpc.generate(1) + # #rpc1.generate(1) + # sync_blocks(self.nodes) + # rpc.generate(1) + # sync_blocks(self.nodes) + # sync_mempools(self.nodes) + # assert_equal(rpc.getinfo()["connections"], 1) + # assert_equal(rpc1.getinfo()["connections"], 1) def run_test(self): print("Mining blocks...") From d8289cd12813f6f440559541e5f04d62ddfc8ae5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:13:58 -1100 Subject: [PATCH 1399/3904] Test --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index 01ff9da0c..ab0a770c1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1707,6 +1707,7 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); + break; return(false); } KOMODO_CHOSEN_ONE = 1; From ba46fa56d9734204ee7ae748980960130d504810 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:18:38 -1100 Subject: [PATCH 1400/3904] Got invalid --- src/miner.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ab0a770c1..05d324075 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1604,16 +1604,12 @@ void static BitcoinMiner() fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%% ht.%d\n",percPoS,(int32_t)ASSETCHAINS_STAKED,Mining_height); } } + int32_t gotinvalid = 0; while (true) { - /*if ( KOMODO_INSYNC == 0 ) - { - KOMODO_LONGESTCHAIN = komodo_longestchain(); - fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height); - if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN ) - KOMODO_INSYNC = Mining_height; - sleep(3); - }*/ + fprintf(stderr,"gotinvalid.%d\n",gotinvalid); + if ( gotinvalid != 0 ) + break; komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; @@ -1707,7 +1703,7 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); - break; + gotinvalid = 1; return(false); } KOMODO_CHOSEN_ONE = 1; From 8706511de79c1fe073f023390f03397562fd7507 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:19:29 -1100 Subject: [PATCH 1401/3904] Static --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 05d324075..9db051d78 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1604,7 +1604,7 @@ void static BitcoinMiner() fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%% ht.%d\n",percPoS,(int32_t)ASSETCHAINS_STAKED,Mining_height); } } - int32_t gotinvalid = 0; + static int32_t gotinvalid = 0; while (true) { fprintf(stderr,"gotinvalid.%d\n",gotinvalid); From c2d4129409d7c1de25d085372392ebb83e26b7c1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:36:41 -1100 Subject: [PATCH 1402/3904] Got invalid as global --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9db051d78..a6ef345bb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1396,6 +1396,8 @@ void static BitcoinMiner_noeq() miningTimer.stop(); } +int32_t gotinvalid; + #ifdef ENABLE_WALLET void static BitcoinMiner(CWallet *pwallet) #else @@ -1604,7 +1606,7 @@ void static BitcoinMiner() fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%% ht.%d\n",percPoS,(int32_t)ASSETCHAINS_STAKED,Mining_height); } } - static int32_t gotinvalid = 0; + gotinvalid = 0; while (true) { fprintf(stderr,"gotinvalid.%d\n",gotinvalid); From 6bfe8357db2a8d8c2d119b6cb07932d51115e4d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:40:36 -1100 Subject: [PATCH 1403/3904] -print --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index a6ef345bb..7ffcaebc2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1609,7 +1609,7 @@ void static BitcoinMiner() gotinvalid = 0; while (true) { - fprintf(stderr,"gotinvalid.%d\n",gotinvalid); + //fprintf(stderr,"gotinvalid.%d\n",gotinvalid); if ( gotinvalid != 0 ) break; komodo_longestchain(); From a84a48e48ffcc6d13998b91296949a52fdc1a63f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:43:01 -1100 Subject: [PATCH 1404/3904] Reset staker for marmara --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c9a91d289..1fe6af409 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2120,7 +2120,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt { CBlockIndex* pblockindex = chainActive[tipindex->GetHeight()]; CBlock block; CTxDestination addressout; - if( ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0 ) + if( ASSETCHAINS_MARMARA != 0 || ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0 ) { resetstaker = true; fprintf(stderr, "Reset ram staker after mining a block!\n"); From 7e6d9ff0650c24c7d7a672a83defd934aba2edf5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:43:38 -1100 Subject: [PATCH 1405/3904] () --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1fe6af409..26f010d1d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2120,7 +2120,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt { CBlockIndex* pblockindex = chainActive[tipindex->GetHeight()]; CBlock block; CTxDestination addressout; - if( ASSETCHAINS_MARMARA != 0 || ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0 ) + if( ASSETCHAINS_MARMARA != 0 || (ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0) ) { resetstaker = true; fprintf(stderr, "Reset ram staker after mining a block!\n"); From 8496dc63a4909ff47032ae227830c32284e5c773 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Jan 2019 23:44:38 -1100 Subject: [PATCH 1406/3904] -print --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 26f010d1d..c530db4fb 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2120,7 +2120,9 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt { CBlockIndex* pblockindex = chainActive[tipindex->GetHeight()]; CBlock block; CTxDestination addressout; - if( ASSETCHAINS_MARMARA != 0 || (ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0) ) + if ( ASSETCHAINS_MARMARA != 0 ) + resetstaker = true; + else if( ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0 ) { resetstaker = true; fprintf(stderr, "Reset ram staker after mining a block!\n"); From 50b9f4fe83b5c9c088b85a168bee7ef6f51d88f5 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 21 Jan 2019 14:01:25 +0500 Subject: [PATCH 1407/3904] test_ac added --- src/rpc/server.cpp | 2 ++ src/rpc/server.h | 2 ++ src/wallet/rpcwallet.cpp | 45 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 24f0c5f98..1eaabdbde 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -537,6 +537,8 @@ static const CRPCCommand vRPCCommands[] = { "util", "reconsiderblock", &reconsiderblock, true }, /* Not shown in help */ { "hidden", "setmocktime", &setmocktime, true }, + { "hidden", "test_ac", &test_ac, true }, + #ifdef ENABLE_WALLET /* Wallet */ { "wallet", "resendwallettransactions", &resendwallettransactions, true}, diff --git a/src/rpc/server.h b/src/rpc/server.h index 0166bca41..53bbd4c21 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -471,4 +471,6 @@ extern UniValue paxprices(const UniValue& params, bool fHelp); extern UniValue paxdeposit(const UniValue& params, bool fHelp); extern UniValue paxwithdraw(const UniValue& params, bool fHelp); +extern UniValue test_ac(const UniValue& params, bool fHelp); + #endif // BITCOIN_RPCSERVER_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8180c9239..8e304c167 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7581,3 +7581,48 @@ void RegisterWalletRPCCommands(CRPCTable &tableRPC) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]); } + +UniValue test_ac(const UniValue& params, bool fHelp) +{ + // make fake token tx: + struct CCcontract_info *cp, C; + + if (fHelp || (params.size() != 4)) + throw runtime_error("incorrect params\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + std::vector pubkey1; + std::vector pubkey2; + + pubkey1 = ParseHex(params[0].get_str().c_str()); + pubkey2 = ParseHex(params[1].get_str().c_str()); + + CPubKey pk1 = pubkey2pk(pubkey1); + CPubKey pk2 = pubkey2pk(pubkey2); + + if(!pk1.IsValid() || !pk2.IsValid()) + throw runtime_error("invalid pubkey\n"); + + int64_t txfee = 10000; + int64_t amount = atoll(params[2].get_str().c_str()) * COIN; + uint256 fundingtxid = Parseuint256((char *)params[3].get_str().c_str()); + + CPubKey myPubkey = pubkey2pk(Mypubkey()); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + + int64_t normalInputs = AddNormalinputs(mtx, myPubkey, txfee + amount, 60); + + if( normalInputs < txfee + amount) + throw runtime_error("not enough normals\n"); + + mtx.vout.push_back(MakeCC1of2vout(EVAL_HEIR, amount, pk1, pk2)); + + CScript opret; + fundingtxid = revuint256(fundingtxid); + + opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_HEIR << (uint8_t)'A' << fundingtxid << (uint8_t)0); + + cp = CCinit(&C, EVAL_HEIR); + return(FinalizeCCTx(0, cp, mtx, myPubkey, txfee, opret)); +} \ No newline at end of file From 9c526cce7d780ff18ec158e277553b162e3cfdff Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 21 Jan 2019 21:04:56 +0500 Subject: [PATCH 1408/3904] corr heir rpc coins -> satoshi conversion --- src/cc/CCHeir.h | 8 ++--- src/cc/heir.cpp | 72 +++++++++++++++++++++++++++++----------- src/wallet/rpcwallet.cpp | 46 ++++++++++++++++--------- 3 files changed, 87 insertions(+), 39 deletions(-) diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index ecaff9cdb..30334f6e1 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -27,10 +27,10 @@ bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, class CoinHelper; class TokenHelper; -UniValue HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); -UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); -UniValue HeirClaimCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); -UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount); +UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); +UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); +UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string amount); +UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string amount); UniValue HeirInfo(uint256 fundingtxid); UniValue HeirList(); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index ccf9da1bf..4ef143271 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -615,7 +615,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info * and also for setting spending plan for the funds' owner and heir * @return fundingtxid handle for subsequent references to this heir funding plan */ -template UniValue HeirFund(uint64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) +template UniValue HeirFund(int64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -629,7 +629,8 @@ template UniValue HeirFund(uint64_t txfee, int64_t amount, std if (!heirPubkey.IsValid()) { std::cerr << "HeirFund() heirPubkey is not valid!" << std::endl; - return std::string(""); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "invalid heir pubkey")); } CPubKey myPubkey = pubkey2pk(Mypubkey()); @@ -689,12 +690,12 @@ template UniValue HeirFund(uint64_t txfee, int64_t amount, std } // if no these callers - it could not link -UniValue HeirFundCoinCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ - return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); +UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ + return HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); } -UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { - return HeirFund(txfee, funds, heirName, heirPubkey, inactivityTimeSec, tokenid); +UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { + return HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); } /** @@ -702,7 +703,7 @@ UniValue HeirFundTokenCaller(uint64_t txfee, int64_t funds, std::string heirName * creates tx to add more funds to cryptocondition address for spending by either funds' owner or heir * @return result object with raw tx or error text */ -template UniValue _HeirAdd(uint256 fundingtxid, uint64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) +template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -781,13 +782,11 @@ template UniValue _HeirAdd(uint256 fundingtxid, uint64_t txfee, i result.push_back(Pair("error", "can't find normal inputs for tx fee")); } - - return result; } -UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { +UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string strAmount) { CPubKey ownerPubkey, heirPubkey; int64_t inactivityTimeSec; @@ -798,10 +797,27 @@ UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { uint8_t hasHeirSpendingBegun = 0; if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { - if (tokenid == zeroid) - return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - else - return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + if (tokenid == zeroid) { + int64_t amount = (int64_t)(atof(strAmount.c_str()) * COIN); + if (amount <= 0) { + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "invalid amount")); + return result; + } + + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + } + else { + int64_t amount = atoll(strAmount.c_str()); + if (amount <= 0) { + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "invalid amount")); + return result; + } + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + } } else { UniValue result(UniValue::VOBJ); @@ -819,7 +835,7 @@ UniValue HeirAddCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { * creates tx to spend funds from cryptocondition address by either funds' owner or heir * @return result object with raw tx or error text */ -template UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) +template UniValue _HeirClaim(uint256 fundingtxid, int64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -940,7 +956,7 @@ template UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfe return result; } -UniValue HeirClaimCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { +UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string strAmount) { CPubKey ownerPubkey, heirPubkey; int64_t inactivityTimeSec; @@ -951,10 +967,26 @@ UniValue HeirClaimCaller(uint256 fundingtxid, uint64_t txfee, int64_t amount) { uint8_t hasHeirSpendingBegun = 0; if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { - if( tokenid == zeroid ) - return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); - else - return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + if (tokenid == zeroid) { + int64_t amount = (int64_t)(atof(strAmount.c_str()) * COIN); + if (amount < 0) { + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "invalid amount")); + return result; + } + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + } + else { + int64_t amount = atoll(strAmount.c_str()); + if (amount <= 0) { + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "invalid amount")); + return result; + } + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + } } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8e304c167..35325e1e0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7362,7 +7362,7 @@ UniValue heirfund(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); uint256 tokenid = zeroid; - uint64_t txfee; + int64_t txfee; int64_t amount; int64_t inactivitytime; std::string hex; @@ -7373,21 +7373,34 @@ UniValue heirfund(const UniValue& params, bool fHelp) return NullUniValue; if (fHelp || params.size() != 5 && params.size() != 6) - throw runtime_error("heirfundtokens fee funds heirname heirpubkey inactivitytime [tokenid]\n"); + throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime [tokenid]\n"); if (ensure_CCrequirements() < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); - txfee = atoll((char*)params[0].get_str().c_str()); - amount = atoll((char*)params[1].get_str().c_str()); + txfee = atoll(params[0].get_str().c_str()); + if (txfee < 0) + throw runtime_error("incorrect txfee param\n"); + + if(params.size() == 6) // tokens in satoshis: + amount = atoll(params[1].get_str().c_str()); + else // coins: + amount = atof(params[1].get_str().c_str()) * COIN; + + if( amount <= 0 ) + throw runtime_error("incorrect amount\n"); + name = params[2].get_str(); pubkey = ParseHex(params[3].get_str().c_str()); if( !pubkey2pk(pubkey).IsValid() ) throw runtime_error("incorrect pubkey\n"); - inactivitytime = atof((char*)params[4].get_str().c_str()); + inactivitytime = atoll(params[4].get_str().c_str()); + if (inactivitytime <= 0) + throw runtime_error("incorrect inactivity time param\n"); + if (params.size() == 6) { tokenid = Parseuint256((char*)params[5].get_str().c_str()); if(tokenid == zeroid) @@ -7406,7 +7419,7 @@ UniValue heiradd(const UniValue& params, bool fHelp) { UniValue result; uint256 fundingtxid; - uint64_t txfee; + int64_t txfee; int64_t amount; int64_t inactivitytime; std::string hex; @@ -7417,18 +7430,20 @@ UniValue heiradd(const UniValue& params, bool fHelp) return NullUniValue; if (fHelp || params.size() != 3) - throw runtime_error("heiraddtokens fee funds fundingtxid\n"); + throw runtime_error("heiradd txfee funds fundingtxid\n"); if (ensure_CCrequirements() < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); - txfee = atoll((char*)params[0].get_str().c_str()); - amount = atoll((char*)params[1].get_str().c_str()); + txfee = atoll(params[0].get_str().c_str()); + if (txfee < 0) + throw runtime_error("incorrect txfee param\n"); + fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); - result = HeirAddCaller(fundingtxid, txfee, amount); + result = HeirAddCaller(fundingtxid, txfee, params[1].get_str()); return result; } @@ -7437,7 +7452,6 @@ UniValue heirclaim(const UniValue& params, bool fHelp) UniValue result; // result(UniValue::VOBJ); uint256 fundingtxid; int64_t txfee; - int64_t amount; int64_t inactivitytime; std::string hex; std::vector pubkey; @@ -7448,18 +7462,20 @@ UniValue heirclaim(const UniValue& params, bool fHelp) return NullUniValue; if (fHelp || params.size() != 3) - throw runtime_error("heirclaimtokens fee funds fundingtxid\n"); + throw runtime_error("heirclaim txfee funds fundingtxid\n"); if (ensure_CCrequirements() < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); - txfee = atoll((char*)params[0].get_str().c_str()); - amount = atoll((char*)params[1].get_str().c_str()); + txfee = atoll(params[0].get_str().c_str()); + if (txfee < 0) + throw runtime_error("incorrect txfee param\n"); + fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); - result = HeirClaimCaller(fundingtxid, txfee, amount); + result = HeirClaimCaller(fundingtxid, txfee, params[1].get_str()); return result; } From 21ad10ac1591779052b89d96bffd6b0db24c1051 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 21 Jan 2019 22:33:50 +0500 Subject: [PATCH 1409/3904] check of vin's owner pubkeys added --- src/cc/heir.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 4ef143271..3891a34f4 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -400,6 +400,7 @@ uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &f return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } + /** * find the latest funding tx: it may be the first F tx or one of A or C tx's * Note: this function is also called from validation code (use non-locking calls) @@ -471,10 +472,24 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke if (tmpFuncId != 0 && fundingtxid == fundingTxidInOpret && (tokenid == zeroid || tokenid == tokenidInOpret)) { // check tokenid also if (blockHeight > maxBlockHeight) { - maxBlockHeight = blockHeight; - latesttxid = txid; - funcId = tmpFuncId; - hasHeirSpendingBegun = hasHeirSpendingBegunInOpret; + + // check owner pubkey in vins + bool hasVinOwner = false; + for (auto vin : regtx.vin) { + CPubKey vinPubkey = check_signing_pubkey(vin.scriptSig); + if (vinPubkey.IsValid() && vinPubkey == ownerPubkey) { + hasVinOwner = true; + break; + } + } + + // we ignore 'donations' tx (non-owner fundings) for calculating if heir is allowed to spend: + if (hasVinOwner) { + hasHeirSpendingBegun = hasHeirSpendingBegunInOpret; + maxBlockHeight = blockHeight; + latesttxid = txid; + funcId = tmpFuncId; + } //std::cerr << "FindLatestFundingTx() txid=" << latesttxid.GetHex() << " at blockHeight=" << maxBlockHeight // << " opreturn type=" << (char)(funcId ? funcId : ' ') << " hasHeirSpendingBegun=" << (int)hasHeirSpendingBegun << " - set as current lasttxid" << '\n'; @@ -615,7 +630,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info * and also for setting spending plan for the funds' owner and heir * @return fundingtxid handle for subsequent references to this heir funding plan */ -template UniValue HeirFund(int64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) +template UniValue _HeirFund(int64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -656,6 +671,23 @@ template UniValue HeirFund(int64_t txfee, int64_t amount, std: if (change != 0) { // vout[1] mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } + + // check my pubkey in vins + bool notMypubkey = false; + for (auto vin : mtx.vin) { + CPubKey vinPubkey = check_signing_pubkey(vin.scriptSig); + if (vinPubkey.IsValid() && vinPubkey != myPubkey) { + notMypubkey = true; + break; + } + } + // do not allow to sign non-owner vin: + if (notMypubkey) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "not the owner's key in the wallet")); + return result; + } + // add 1of2 vout validation pubkeys: std::vector voutTokenPubkeys; @@ -691,11 +723,11 @@ template UniValue HeirFund(int64_t txfee, int64_t amount, std: // if no these callers - it could not link UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ - return HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); + return _HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); } UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { - return HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); + return _HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); } /** @@ -749,6 +781,22 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in if (change != 0) { // vout[1] mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } + + // check my pubkey in vins + bool notMypubkey = false; + for (auto vin : mtx.vin) { + CPubKey vinPubkey = check_signing_pubkey(vin.scriptSig); + if (vinPubkey.IsValid() && vinPubkey != myPubkey) { + notMypubkey = true; + break; + } + } + // do not allow to sign non-owner vin: + if (notMypubkey) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "not the owner's key in the wallet")); + return result; + } // add 1of2 vout validation pubkeys - needed only for tokens: std::vector voutTokenPubkeys; From 56d68d816638321b562f4bfe940fb894929b93aa Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 13:11:09 +0500 Subject: [PATCH 1410/3904] corr checking for owner pubkey in vins (is owner's or is other's) --- src/cc/heir.cpp | 86 ++++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 3891a34f4..2ebf4b490 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -400,6 +400,22 @@ uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &f return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } +// check if pubkey is in vins +void CheckVinPubkey(std::vector vins, CPubKey pubkey, bool &hasPubkey, bool &hasOtherPubkey) { + + hasPubkey = false; + hasOtherPubkey = false; + + for (auto vin : vins) { + CPubKey vinPubkey = check_signing_pubkey(vin.scriptSig); + if (vinPubkey.IsValid()) { + if (vinPubkey == pubkey) + hasPubkey = true; + if (vinPubkey != pubkey) + hasOtherPubkey = true; + } + } +} /** * find the latest funding tx: it may be the first F tx or one of A or C tx's @@ -474,17 +490,13 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke if (blockHeight > maxBlockHeight) { // check owner pubkey in vins - bool hasVinOwner = false; - for (auto vin : regtx.vin) { - CPubKey vinPubkey = check_signing_pubkey(vin.scriptSig); - if (vinPubkey.IsValid() && vinPubkey == ownerPubkey) { - hasVinOwner = true; - break; - } - } + bool isOwner = false; + bool isNonOwner = false; - // we ignore 'donations' tx (non-owner fundings) for calculating if heir is allowed to spend: - if (hasVinOwner) { + CheckVinPubkey(regtx.vin, ownerPubkey, isOwner, isNonOwner); + + // we ignore 'donations' tx (with non-owner inputs) for calculating if heir is allowed to spend: + if (isOwner && !isNonOwner) { hasHeirSpendingBegun = hasHeirSpendingBegunInOpret; maxBlockHeight = blockHeight; latesttxid = txid; @@ -672,23 +684,19 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } - // check my pubkey in vins - bool notMypubkey = false; - for (auto vin : mtx.vin) { - CPubKey vinPubkey = check_signing_pubkey(vin.scriptSig); - if (vinPubkey.IsValid() && vinPubkey != myPubkey) { - notMypubkey = true; - break; - } - } - // do not allow to sign non-owner vin: - if (notMypubkey) { + // check owner pubkey in vins + bool isMypubkey = false; + bool isNotMypubkey = false; + + CheckVinPubkey(mtx.vin, myPubkey, isMypubkey, isNotMypubkey); + + // for initial funding do not allow to sign by non-owner key: + if (isNotMypubkey) { result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "not the owner's key in the wallet")); + result.push_back(Pair("error", "using non-owner inputs not allowed")); return result; } - // add 1of2 vout validation pubkeys: std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(myPubkey); @@ -782,22 +790,28 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in mtx.vout.push_back(Helper::makeUserVout(change, myPubkey)); } - // check my pubkey in vins - bool notMypubkey = false; - for (auto vin : mtx.vin) { - CPubKey vinPubkey = check_signing_pubkey(vin.scriptSig); - if (vinPubkey.IsValid() && vinPubkey != myPubkey) { - notMypubkey = true; - break; - } - } - // do not allow to sign non-owner vin: - if (notMypubkey) { + // check owner pubkey in vins + bool isMypubkey = false; + bool isNotMypubkey = false; + + CheckVinPubkey(mtx.vin, myPubkey, isMypubkey, isNotMypubkey); + + // for additional funding do not allow to sign by both owner and non-owner keys (is this a donation or not?): + if (isMypubkey && isNotMypubkey) { result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "not the owner's key in the wallet")); + result.push_back(Pair("error", "using both owner and non-owner inputs is not allowed")); return result; } + // warn the user he's making a donation if this is all non-owner keys: + if (isNotMypubkey) { + result.push_back(Pair("result", "warning")); + result.push_back(Pair("warning", "you are about to make a donation to heir fund")); + } + else { + result.push_back(Pair("result", "success")); + } + // add 1of2 vout validation pubkeys - needed only for tokens: std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(ownerPubkey); @@ -808,11 +822,11 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); if (!rawhextx.empty()) { - result.push_back(Pair("result", "success")); result.push_back(Pair("hextx", rawhextx)); } else { std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; + result.clear(); result.push_back(Pair("result", "error")); result.push_back(Pair("error", "sign error")); } From e6f41e085ed727e9103816ed4b07d3e358973f5a Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 13:49:34 +0500 Subject: [PATCH 1411/3904] added real owner inactivity time in heirinfo --- src/cc/heir.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 2ebf4b490..bbc54e232 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1197,6 +1197,14 @@ UniValue HeirInfo(uint256 fundingtxid) result.push_back(Pair("spending allowed for the heir", stream.str().c_str())); stream.str(""); stream.clear(); + + // adding owner current inactivity time: + if (!hasHeirSpendingBegun && durationSec <= inactivityTimeSec) { + stream << durationSec; + result.push_back(Pair("owner inactivity time", stream.str().c_str())); + stream.str(""); + stream.clear(); + } result.push_back(Pair("result", "success")); } From bd2903762880424cb523d0340a1e852e085d1c24 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 13:59:39 +0500 Subject: [PATCH 1412/3904] string "sec" (seconds) added to heirinfo --- src/cc/heir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index bbc54e232..ff8d77209 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1184,13 +1184,13 @@ UniValue HeirInfo(uint256 fundingtxid) } stream << inactivityTimeSec; - result.push_back(Pair("inactivity time setting", stream.str().c_str())); + result.push_back(Pair("inactivity time setting, sec", stream.str().c_str())); stream.str(""); stream.clear(); if (!hasHeirSpendingBegun) { // we do not need find duration if the spending already has begun durationSec = CCduration(numblocks, latestFundingTxid); - std::cerr << "HeirInfo() duration=" << durationSec << " inactivityTime=" << inactivityTimeSec << " numblocks=" << numblocks << '\n'; + std::cerr << "HeirInfo() duration (sec)=" << durationSec << " inactivityTime (sec)=" << inactivityTimeSec << " numblocks=" << numblocks << '\n'; } stream << std::boolalpha << (hasHeirSpendingBegun || durationSec > inactivityTimeSec); @@ -1201,7 +1201,7 @@ UniValue HeirInfo(uint256 fundingtxid) // adding owner current inactivity time: if (!hasHeirSpendingBegun && durationSec <= inactivityTimeSec) { stream << durationSec; - result.push_back(Pair("owner inactivity time", stream.str().c_str())); + result.push_back(Pair("owner inactivity time, sec", stream.str().c_str())); stream.str(""); stream.clear(); } From a87816f5513a9bb52c7e8b1549ad2022cd144734 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 14:20:33 +0500 Subject: [PATCH 1413/3904] test rpc serialization Sleep added --- src/cc/heir.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index ff8d77209..c0f0c8124 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1116,6 +1116,8 @@ UniValue HeirInfo(uint256 fundingtxid) std::ostringstream stream; std::string msg; + Sleep(10000); + result.push_back(Pair("fundingtxid", fundingtxid.GetHex())); result.push_back(Pair("name", heirName.c_str())); From 92ab8dd7d8798bd054786070590e485a9f0b8590 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 14:25:17 +0500 Subject: [PATCH 1414/3904] linux sleep added --- src/cc/heir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index c0f0c8124..32e4195dc 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -16,6 +16,8 @@ #include "CCHeir.h" #include "heir_validate.h" +#include + class CoinHelper; class TokenHelper; @@ -1116,7 +1118,7 @@ UniValue HeirInfo(uint256 fundingtxid) std::ostringstream stream; std::string msg; - Sleep(10000); + sleep(10); result.push_back(Pair("fundingtxid", fundingtxid.GetHex())); result.push_back(Pair("name", heirName.c_str())); From 2d20276606de621c280333882bc171a0a9e7eef5 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 15:03:52 +0500 Subject: [PATCH 1415/3904] better var naming for check vin's pubkey algo --- src/cc/heir.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 32e4195dc..ffa07e2f5 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -687,13 +687,13 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std } // check owner pubkey in vins - bool isMypubkey = false; - bool isNotMypubkey = false; + bool hasMypubkey = false; + bool hasNotMypubkey = false; - CheckVinPubkey(mtx.vin, myPubkey, isMypubkey, isNotMypubkey); + CheckVinPubkey(mtx.vin, myPubkey, hasMypubkey, hasNotMypubkey); // for initial funding do not allow to sign by non-owner key: - if (isNotMypubkey) { + if (hasNotMypubkey) { result.push_back(Pair("result", "error")); result.push_back(Pair("error", "using non-owner inputs not allowed")); return result; @@ -793,20 +793,20 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in } // check owner pubkey in vins - bool isMypubkey = false; - bool isNotMypubkey = false; + bool hasMypubkey = false; + bool hasNotMypubkey = false; - CheckVinPubkey(mtx.vin, myPubkey, isMypubkey, isNotMypubkey); + CheckVinPubkey(mtx.vin, myPubkey, hasMypubkey, hasNotMypubkey); // for additional funding do not allow to sign by both owner and non-owner keys (is this a donation or not?): - if (isMypubkey && isNotMypubkey) { + if (hasMypubkey && hasNotMypubkey) { result.push_back(Pair("result", "error")); result.push_back(Pair("error", "using both owner and non-owner inputs is not allowed")); return result; } // warn the user he's making a donation if this is all non-owner keys: - if (isNotMypubkey) { + if (hasNotMypubkey) { result.push_back(Pair("result", "warning")); result.push_back(Pair("warning", "you are about to make a donation to heir fund")); } @@ -1118,7 +1118,7 @@ UniValue HeirInfo(uint256 fundingtxid) std::ostringstream stream; std::string msg; - sleep(10); + //sleep(10); result.push_back(Pair("fundingtxid", fundingtxid.GetHex())); result.push_back(Pair("name", heirName.c_str())); From 98c5280e6b95b37f2a704a6d5433533366dad263 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 18:31:03 +0500 Subject: [PATCH 1416/3904] corr marker to cc unspendable for F, added validation to prevent its spending added marker to prevent archiving for A --- src/cc/heir.cpp | 33 +++++++++++++---------- src/cc/heir_validate.h | 60 +++++++++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 29 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index ffa07e2f5..883b11da2 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -16,8 +16,6 @@ #include "CCHeir.h" #include "heir_validate.h" -#include - class CoinHelper; class TokenHelper; @@ -653,6 +651,8 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) txfee = 10000; + + int64_t markerfee = 10000; //std::cerr << "HeirFund() amount=" << amount << " txfee=" << txfee << " heirPubkey IsValid()=" << heirPubkey.IsValid() << " inactivityTime(sec)=" << inactivityTimeSec << " tokenid=" << tokenid.GetHex() << std::endl; @@ -664,17 +664,18 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std CPubKey myPubkey = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners + if (AddNormalinputs(mtx, myPubkey, markerfee, 3) > 0) { int64_t inputs, change; - if ((inputs=Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { // 2 x txfee: 1st for marker vout, 2nd to miners - //mtx.vout.push_back(MakeTokensCC1of2vout(/*Helper::getMyEval()*/EVAL_HEIR, amount, myPubkey, heirPubkey)); // add cryptocondition to spend amount for either pk - mtx.vout.push_back(Helper::make1of2Vout(amount, myPubkey, heirPubkey)); + if ((inputs=Helper::addOwnerInputs(tokenid, mtx, myPubkey, amount, (int32_t)64)) > 0) { + + mtx.vout.push_back(Helper::make1of2Vout(amount, myPubkey, heirPubkey)); // add a marker for finding all plans in HeirList() // TODO: change marker either to cc or normal txidaddr unspendable CPubKey heirUnspendablePubKey = GetUnspendable(cp, 0); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); // TODO: do we need this marker? + // mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); <-- bad marker cause it was spendable by anyone + MakeCC1vout(EVAL_HEIR, txfee, heirUnspendablePubKey); // this marker spending is disabled in the validation code // calc and add change vout: if (inputs > amount) @@ -782,7 +783,11 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in // add cryptocondition to spend this funded amount for either pk mtx.vout.push_back(Helper::make1of2Vout(amount, ownerPubkey, heirPubkey)); - + + char markeraddr[64]; + CPubKey markerPubkey = CCtxidaddr(markeraddr, fundingtxid); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerPubkey)) << OP_CHECKSIG)); // marker to prevent archiving of the funds add vouts + if (inputs > amount) change = (inputs - amount); // -txfee <-- txfee pays user @@ -1232,10 +1237,10 @@ UniValue HeirInfo(uint256 fundingtxid) template void _HeirList(struct CCcontract_info *cp, UniValue &result) { std::vector> unspentOutputs; - char coinaddr[64]; - CPubKey ccPubKeyEmpty; - GetCCaddress(cp, coinaddr, ccPubKeyEmpty); - SetCCunspents(unspentOutputs, cp->normaladdr); + char markeraddr[64]; + + GetCCaddress(cp, markeraddr, GetUnspendable(cp, NULL)); + SetCCunspents(unspentOutputs, markeraddr); //std::cerr << "HeirList() finding heir marker from Heir contract addr=" << cp->normaladdr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; @@ -1283,10 +1288,10 @@ UniValue HeirList() struct CCcontract_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! cpHeir = CCinit(&heirC, EVAL_HEIR); - cpTokens = CCinit(&tokenC, EVAL_TOKENS); + //cpTokens = CCinit(&tokenC, EVAL_TOKENS); _HeirList(cpHeir, result); - _HeirList(cpTokens, result); + //_HeirList(cpTokens, result); not used anymore return result; } diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index c4bb7ea60..7dd09a427 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -125,8 +125,8 @@ class CValidatorBase public: CValidatorBase(CCcontract_info* cp) : m_cp(cp) {} virtual bool isVinValidator() const = 0; - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0; - virtual bool validateVout(CTxOut vout, std::string& message) const = 0; + virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const = 0; + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const = 0; protected: CCcontract_info * m_cp; @@ -258,10 +258,10 @@ private: if (v->isVinValidator()) // validate this vin and previous vout: - result = v->validateVin(pTx->vin[iv], pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); + result = v->validateVin(pTx->vin[iv], pPrevTx->vout[pTx->vin[iv].prevout.n], pTx->vin[iv].prevout.n, refMessage); else // if it is vout validator pass the previous tx vout: - result = v->validateVout( pPrevTx->vout[pTx->vin[iv].prevout.n], refMessage); + result = v->validateVout( pPrevTx->vout[pTx->vin[iv].prevout.n], pTx->vin[iv].prevout.n, refMessage); if (!result) { return result; } @@ -359,7 +359,7 @@ private: if (!v->isVinValidator()) { // if this is a 'in' validation plan then pass the previous tx vout: - bool result = v->validateVout(pTx->vout[iv], refMessage); + bool result = v->validateVout(pTx->vout[iv], iv, refMessage); if (!result) return result; } @@ -402,7 +402,7 @@ public: m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { //std::cerr << "CCC1of2AddressValidator::validateVout() entered" << std::endl; CPubKey ownerPubkey, heirPubkey; @@ -438,7 +438,7 @@ public: std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; return false; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return false; } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return false; } private: CScript m_fundingOpretScript; @@ -456,7 +456,7 @@ public: : m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { //std::cerr << "CMyPubkeyVoutValidator::validateVout() entered" << std::endl; @@ -498,7 +498,7 @@ public: message = std::string("invalid pubkey"); return false; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } private: CScript m_fundingOpretScript; @@ -516,7 +516,7 @@ public: : m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { //std::cerr << "CHeirSpendValidator::validateVout() entered" << std::endl; @@ -554,7 +554,7 @@ public: // this is not heir: return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } private: CScript m_fundingOpretScript; @@ -572,7 +572,7 @@ public: : m_fundingOpretScript(opret), CValidatorBase(cp) {} virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { //std::cerr << "COpRetValidator::validateVout() entered" << std::endl; @@ -607,12 +607,42 @@ public: //std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } private: CScript m_fundingOpretScript; }; + +/* +** marker spending prevention validator, +** returns false if for tx with funcid=F vout.1 is being tried to spend +*/ +template class CMarkerValidator : CValidatorBase +{ +public: + CMarkerValidator(CCcontract_info* cp) + : CValidatorBase(cp) { } + + virtual bool isVinValidator() const { return false; } // this is vout validator + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { + + uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; + uint8_t dummyIsHeirSpendingBegan; + + uint8_t funcId = DecodeHeirEitherOpRet(m_opret, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + + if( funcId == 'F' && vout_n == 1 ) + return false; + + return true; + } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } + +private: + CScript m_fundingOpretScript; +}; + /** * empty validator always returns true */ @@ -623,8 +653,8 @@ public: : CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } - virtual bool validateVout(CTxOut vout, std::string& message) const { return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const { return true; } + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } }; From 426aa32dd50e7010eb1465032317b4b146dc5f3b Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 19:25:25 +0500 Subject: [PATCH 1417/3904] corr F tx marker protection validation code --- src/cc/heir.cpp | 1 + src/cc/heir_validate.h | 42 +++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 883b11da2..69bf1a757 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -56,6 +56,7 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont // only for tokens: CMyPubkeyVoutValidator ownerCCaddrValidator(cp, fundingOpretScript, false); // check if this correct owner's cc user addr corresponding to opret COpRetValidator opRetValidator(cp, fundingOpretScript); // compare opRets in this and last tx + CMarkerValidator markerValidator(cp); // initial tx marker spending protection CNullValidator nullValidator(cp); switch (funcId) { diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 7dd09a427..14e608bc2 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -125,7 +125,7 @@ class CValidatorBase public: CValidatorBase(CCcontract_info* cp) : m_cp(cp) {} virtual bool isVinValidator() const = 0; - virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const = 0; + virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const = 0; virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const = 0; protected: @@ -258,7 +258,7 @@ private: if (v->isVinValidator()) // validate this vin and previous vout: - result = v->validateVin(pTx->vin[iv], pPrevTx->vout[pTx->vin[iv].prevout.n], pTx->vin[iv].prevout.n, refMessage); + result = v->validateVin(pTx->vin[iv], pPrevTx->vout, pTx->vin[iv].prevout.n, refMessage); else // if it is vout validator pass the previous tx vout: result = v->validateVout( pPrevTx->vout[pTx->vin[iv].prevout.n], pTx->vin[iv].prevout.n, refMessage); @@ -438,7 +438,7 @@ public: std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; return false; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return false; } + virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const { return false; } private: CScript m_fundingOpretScript; @@ -498,7 +498,7 @@ public: message = std::string("invalid pubkey"); return false; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const { return true; } private: CScript m_fundingOpretScript; @@ -554,7 +554,7 @@ public: // this is not heir: return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const { return true; } private: CScript m_fundingOpretScript; @@ -607,17 +607,17 @@ public: //std::cerr << "COpRetValidator::validateVout() exits with true" << std::endl; return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const { return true; } private: CScript m_fundingOpretScript; }; -/* -** marker spending prevention validator, -** returns false if for tx with funcid=F vout.1 is being tried to spend -*/ +/** + * marker spending prevention validator, + * returns false if for tx with funcid=F vout.1 is being tried to spend + */ template class CMarkerValidator : CValidatorBase { public: @@ -625,22 +625,22 @@ public: : CValidatorBase(cp) { } virtual bool isVinValidator() const { return false; } // this is vout validator - virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { + virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const { uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; uint8_t dummyIsHeirSpendingBegan; - uint8_t funcId = DecodeHeirEitherOpRet(m_opret, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + if (prevVout.size() > 0) { - if( funcId == 'F' && vout_n == 1 ) - return false; - - return true; + // get funcId for prev tx: + uint8_t funcId = DecodeHeirEitherOpRet(prevVout[prevVout.size()-1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + if (funcId == 'F' && prevN == 1) // do not allow to spend 'F' marker's vout + return false; + } + + return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } - -private: - CScript m_fundingOpretScript; }; /** @@ -654,7 +654,7 @@ public: virtual bool isVinValidator() const { return false; } virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { return true; } - virtual bool validateVin(CTxIn vin, CTxOut prevVout, int32_t vout_n, std::string& message) const { return true; } + virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const { return true; } }; From 6c26e91376209daf8ff0b92ce57b3e658585186b Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 19:48:24 +0500 Subject: [PATCH 1418/3904] corr cpHeir init in _heirFund for marker enabled logging --- src/cc/heir.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 69bf1a757..a5533c0c1 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -674,7 +674,9 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std // add a marker for finding all plans in HeirList() // TODO: change marker either to cc or normal txidaddr unspendable - CPubKey heirUnspendablePubKey = GetUnspendable(cp, 0); + struct CCcontract_info *cpHeir, heirC; + cpHeir = CCinit(&heirC, EVAL_HEIR); + CPubKey heirUnspendablePubKey = GetUnspendable(cpHeir, 0); // mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); <-- bad marker cause it was spendable by anyone MakeCC1vout(EVAL_HEIR, txfee, heirUnspendablePubKey); // this marker spending is disabled in the validation code @@ -1235,7 +1237,7 @@ UniValue HeirInfo(uint256 fundingtxid) * @return list of heir plan handles (fundingtxid) */ -template void _HeirList(struct CCcontract_info *cp, UniValue &result) +void _HeirList(struct CCcontract_info *cp, UniValue &result) { std::vector> unspentOutputs; char markeraddr[64]; @@ -1243,7 +1245,7 @@ template void _HeirList(struct CCcontract_info *cp, UniValue &r GetCCaddress(cp, markeraddr, GetUnspendable(cp, NULL)); SetCCunspents(unspentOutputs, markeraddr); - //std::cerr << "HeirList() finding heir marker from Heir contract addr=" << cp->normaladdr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + std::cerr << "HeirList() finding heir marker from unspendable addr=" << markeraddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; // TODO: move marker to special cc addr to prevent checking all tokens for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { @@ -1252,7 +1254,7 @@ template void _HeirList(struct CCcontract_info *cp, UniValue &r uint256 tokenid; int32_t vout = (int32_t)it->first.index; - //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; + std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; CTransaction fundingtx; if (GetTransaction(txid, fundingtx, hashBlock, false)) { @@ -1291,7 +1293,7 @@ UniValue HeirList() cpHeir = CCinit(&heirC, EVAL_HEIR); //cpTokens = CCinit(&tokenC, EVAL_TOKENS); - _HeirList(cpHeir, result); + _HeirList(cpHeir, result); //_HeirList(cpTokens, result); not used anymore return result; From 28d090c05ea324444184a1e03b3f29151894782e Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 20:02:20 +0500 Subject: [PATCH 1419/3904] corr adding marker vout for F --- src/cc/heir.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index a5533c0c1..993c7bb5b 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -678,7 +678,7 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std cpHeir = CCinit(&heirC, EVAL_HEIR); CPubKey heirUnspendablePubKey = GetUnspendable(cpHeir, 0); // mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(heirUnspendablePubKey)) << OP_CHECKSIG)); <-- bad marker cause it was spendable by anyone - MakeCC1vout(EVAL_HEIR, txfee, heirUnspendablePubKey); // this marker spending is disabled in the validation code + mtx.vout.push_back(MakeCC1vout(EVAL_HEIR, markerfee, heirUnspendablePubKey)); // this marker spending is disabled in the validation code // calc and add change vout: if (inputs > amount) @@ -762,6 +762,8 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in if (txfee == 0) txfee = 10000; + int64_t markerfee = 10000; + CPubKey myPubkey = pubkey2pk(Mypubkey()); // check if it is the owner @@ -771,7 +773,7 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in return result; } - if (AddNormalinputs(mtx, myPubkey, txfee, 3) > 0) { // txfee for miners + if (AddNormalinputs(mtx, myPubkey, markerfee, 3) > 0) { // some for marker int64_t inputs, change; @@ -789,7 +791,7 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in char markeraddr[64]; CPubKey markerPubkey = CCtxidaddr(markeraddr, fundingtxid); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(markerPubkey)) << OP_CHECKSIG)); // marker to prevent archiving of the funds add vouts + mtx.vout.push_back(CTxOut(markerfee, CScript() << ParseHex(HexStr(markerPubkey)) << OP_CHECKSIG)); // marker to prevent archiving of the funds add vouts if (inputs > amount) change = (inputs - amount); // -txfee <-- txfee pays user From 3865cae643c701742cdb57c667bbd02248f8c85c Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 20:21:45 +0500 Subject: [PATCH 1420/3904] added test to try to spend heir marker F --- src/rpc/server.cpp | 1 + src/rpc/server.h | 2 ++ src/wallet/rpcwallet.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 1eaabdbde..82a400e71 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -538,6 +538,7 @@ static const CRPCCommand vRPCCommands[] = /* Not shown in help */ { "hidden", "setmocktime", &setmocktime, true }, { "hidden", "test_ac", &test_ac, true }, + { "hidden", "test_heirmarker", &test_heirmarker, true }, #ifdef ENABLE_WALLET /* Wallet */ diff --git a/src/rpc/server.h b/src/rpc/server.h index 53bbd4c21..3edc85ebf 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -471,6 +471,8 @@ extern UniValue paxprices(const UniValue& params, bool fHelp); extern UniValue paxdeposit(const UniValue& params, bool fHelp); extern UniValue paxwithdraw(const UniValue& params, bool fHelp); +// test rpc: extern UniValue test_ac(const UniValue& params, bool fHelp); +extern UniValue test_heirmarker(const UniValue& params, bool fHelp); #endif // BITCOIN_RPCSERVER_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 35325e1e0..76ca2cf8d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7641,4 +7641,31 @@ UniValue test_ac(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_HEIR); return(FinalizeCCTx(0, cp, mtx, myPubkey, txfee, opret)); +} + +UniValue test_heirmarker(const UniValue& params, bool fHelp) +{ + // make fake token tx: + struct CCcontract_info *cp, C; + + if (fHelp || (params.size() != 4)) + throw runtime_error("incorrect params\n"); + if (ensure_CCrequirements() < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + uint256 fundingtxid = Parseuint256((char *)params[3].get_str().c_str()); + + CPubKey myPubkey = pubkey2pk(Mypubkey()); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + + mtx.vin.push_back(CTxIn(fundingtxid, 1)); + mtx.vout.push_back(MakeCC1vout(EVAL_HEIR, 10000, myPubkey)); + + CScript opret; + fundingtxid = revuint256(fundingtxid); + + opret << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_HEIR << (uint8_t)'C' << fundingtxid << (uint8_t)0); + + cp = CCinit(&C, EVAL_HEIR); + return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); } \ No newline at end of file From 098ba877fb3a0d90cc83082bf20802d7aec7b402 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 20:37:41 +0500 Subject: [PATCH 1421/3904] corr test code for spending marker F --- src/cc/heir_validate.h | 5 +++-- src/wallet/rpcwallet.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 14e608bc2..fd414461e 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -635,10 +635,11 @@ public: // get funcId for prev tx: uint8_t funcId = DecodeHeirEitherOpRet(prevVout[prevVout.size()-1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); - if (funcId == 'F' && prevN == 1) // do not allow to spend 'F' marker's vout + if (funcId == 'F' && prevN == 1) { // do not allow to spend 'F' marker's vout + message = std::string("spending marker not allowed"); return false; + } } - return true; } }; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 76ca2cf8d..c1cf25b41 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7648,16 +7648,20 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) // make fake token tx: struct CCcontract_info *cp, C; - if (fHelp || (params.size() != 4)) + if (fHelp || (params.size() != 1)) throw runtime_error("incorrect params\n"); if (ensure_CCrequirements() < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - uint256 fundingtxid = Parseuint256((char *)params[3].get_str().c_str()); + uint256 fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); CPubKey myPubkey = pubkey2pk(Mypubkey()); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + int64_t normalInputs = AddNormalinputs(mtx, myPubkey, 10000, 60); + if (normalInputs < 10000) + throw runtime_error("not enough normals\n"); + mtx.vin.push_back(CTxIn(fundingtxid, 1)); mtx.vout.push_back(MakeCC1vout(EVAL_HEIR, 10000, myPubkey)); From 8a15610e445b1bc9db91bff96ae1807cf30eae3d Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 21:03:08 +0500 Subject: [PATCH 1422/3904] corr marker validator --- src/cc/heir.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 993c7bb5b..3070ed9ef 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -60,10 +60,10 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont CNullValidator nullValidator(cp); switch (funcId) { - case 'F': // fund tokens + case 'F': // fund tokens (only for tokens) // vin validation plan: vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &markerValidator, &ownerCCaddrValidator); // check cc owner addr // vout validation plan: voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding @@ -71,10 +71,10 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont // no checking for opret yet break; - case 'A': // add tokens + case 'A': // add tokens (only for tokens) // vin validation plan: vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &ownerCCaddrValidator); // check cc owner addr + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &markerValidator, &ownerCCaddrValidator); // check cc owner addr // vout validation plan: voutPlan.pushValidators(0, &cc1of2ValidatorThis); // check 1of2 addr funding @@ -82,10 +82,10 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont voutPlan.pushValidators(numvouts - 1, &opRetValidator); // opreturn check, NOTE: only for C or A: break; - case 'C': + case 'C': // spend coins or tokens // vin validation plan: vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &cc1of2ValidatorThis); // cc1of2 funding addr + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &markerValidator, &cc1of2ValidatorThis); // cc1of2 funding addr // vout validation plan: voutPlan.pushValidators(0, &heirSpendValidator); // check if heir is allowed to spend From 61f1d8771deeafd0fcc3855b153052910de4bbae Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 21:07:44 +0500 Subject: [PATCH 1423/3904] removed 1of2 validator for test marker spending --- src/cc/heir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 3070ed9ef..ce0445975 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -85,7 +85,7 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont case 'C': // spend coins or tokens // vin validation plan: vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &markerValidator, &cc1of2ValidatorThis); // cc1of2 funding addr + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &markerValidator/*, &cc1of2ValidatorThis*/); // cc1of2 funding addr // vout validation plan: voutPlan.pushValidators(0, &heirSpendValidator); // check if heir is allowed to spend From fb69b514b2d61d127635d8b021061a5a60373cb0 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 21:36:57 +0500 Subject: [PATCH 1424/3904] added logging to marker validator --- src/cc/heir_validate.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index fd414461e..0e4a04868 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -631,15 +631,21 @@ public: uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; uint8_t dummyIsHeirSpendingBegan; + std::cerr << "CMarkerValidator::validateVin() prevVout.size()=" << prevVout.size() << " prevN=" << prevN << std::endl; + if (prevVout.size() > 0) { // get funcId for prev tx: uint8_t funcId = DecodeHeirEitherOpRet(prevVout[prevVout.size()-1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); + + std::cerr << "CMarkerValidator::validateVin() funcId=" << (funcId?funcId:' ') << std::endl; + if (funcId == 'F' && prevN == 1) { // do not allow to spend 'F' marker's vout message = std::string("spending marker not allowed"); return false; } } + std::cerr << "CMarkerValidator::validateVin() exits with true" << std::endl; return true; } }; From da00a3d0217f4c7ea6c1dc5b35ac5a1dc111b008 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 21:47:31 +0500 Subject: [PATCH 1425/3904] isVinValidator flag corrected = true --- src/cc/heir_validate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 0e4a04868..6e4049896 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -624,7 +624,7 @@ public: CMarkerValidator(CCcontract_info* cp) : CValidatorBase(cp) { } - virtual bool isVinValidator() const { return false; } // this is vout validator + virtual bool isVinValidator() const { return true; } // this is vin validator virtual bool validateVout(CTxOut vout, int32_t vout_n, std::string& message) const { return true; } virtual bool validateVin(CTxIn vin, std::vector prevVout, int32_t prevN, std::string& message) const { From de8af6cc93d198ce2db3c18ca26efad349e8f0a5 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 21:54:47 +0500 Subject: [PATCH 1426/3904] debug logging disabled --- src/cc/heir.cpp | 4 ++-- src/cc/heir_validate.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index ce0445975..93a59f95f 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1247,7 +1247,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) GetCCaddress(cp, markeraddr, GetUnspendable(cp, NULL)); SetCCunspents(unspentOutputs, markeraddr); - std::cerr << "HeirList() finding heir marker from unspendable addr=" << markeraddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; + //std::cerr << "HeirList() finding heir marker from unspendable addr=" << markeraddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; // TODO: move marker to special cc addr to prevent checking all tokens for (std::vector>::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { @@ -1256,7 +1256,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) uint256 tokenid; int32_t vout = (int32_t)it->first.index; - std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; + //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; CTransaction fundingtx; if (GetTransaction(txid, fundingtx, hashBlock, false)) { diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 6e4049896..df58e3bf1 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -631,21 +631,20 @@ public: uint256 fundingTxidInOpret = zeroid, dummyTxid, tokenid = zeroid, initialTokenid = zeroid; uint8_t dummyIsHeirSpendingBegan; - std::cerr << "CMarkerValidator::validateVin() prevVout.size()=" << prevVout.size() << " prevN=" << prevN << std::endl; - + //std::cerr << "CMarkerValidator::validateVin() prevVout.size()=" << prevVout.size() << " prevN=" << prevN << std::endl; if (prevVout.size() > 0) { // get funcId for prev tx: uint8_t funcId = DecodeHeirEitherOpRet(prevVout[prevVout.size()-1].scriptPubKey, tokenid, fundingTxidInOpret, dummyIsHeirSpendingBegan, true); - std::cerr << "CMarkerValidator::validateVin() funcId=" << (funcId?funcId:' ') << std::endl; + //std::cerr << "CMarkerValidator::validateVin() funcId=" << (funcId?funcId:' ') << std::endl; if (funcId == 'F' && prevN == 1) { // do not allow to spend 'F' marker's vout message = std::string("spending marker not allowed"); return false; } } - std::cerr << "CMarkerValidator::validateVin() exits with true" << std::endl; + //std::cerr << "CMarkerValidator::validateVin() exits with true" << std::endl; return true; } }; From 6481576883e63756c37142f886868b8a1b67009a Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 22 Jan 2019 22:02:43 +0500 Subject: [PATCH 1427/3904] restored 1of2 validator for C (was off to test markerValidator) --- src/cc/heir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 93a59f95f..71ec9b040 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -85,7 +85,7 @@ template bool RunValidationPlans(uint8_t funcId, struct CCcont case 'C': // spend coins or tokens // vin validation plan: vinPlan.pushValidators((CInputIdentifierBase*)&normalInputIdentifier, &nullValidator); // txfee vin - vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &markerValidator/*, &cc1of2ValidatorThis*/); // cc1of2 funding addr + vinPlan.pushValidators((CInputIdentifierBase*)&ccInputIdentifier, &markerValidator, &cc1of2ValidatorThis); // cc1of2 funding addr // vout validation plan: voutPlan.pushValidators(0, &heirSpendValidator); // check if heir is allowed to spend From 7167793dbf4b776f6d4d8ae6daf7a6b150747c65 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 02:50:53 +0800 Subject: [PATCH 1428/3904] new version --- src/chainparams.cpp | 2 +- src/komodo_bitcoind.h | 54 +++++++++++++++++++++++------------------- src/komodo_globals.h | 5 ++-- src/komodo_utils.h | 2 +- src/main.cpp | 3 ++- src/miner.cpp | 8 +++---- src/pow.cpp | 4 ++-- src/rpc/blockchain.cpp | 2 +- src/rpc/mining.cpp | 3 +-- src/rpc/misc.cpp | 4 ++-- 10 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 03a518d4b..45824f22b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -282,7 +282,7 @@ void *chainparams_commandline(void *ptr) // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing mainParams.consensus.nLwmaAjustedWeight = 1350; mainParams.consensus.nPowAveragingWindow = 45; - mainParams.consensus.powAlternate = uint256S("000000ff0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); + mainParams.consensus.powAlternate = uint256S("0000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); } if (ASSETCHAINS_LWMAPOS != 0) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d2c3b3b30..b2b8011b5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1255,7 +1255,7 @@ uint32_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256 arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { - int32_t oldflag = 0,dispflag = 1; + int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; @@ -1367,7 +1367,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr,int32_t PoSperc) { - bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t diff=0,segid,minage,i,iter=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; + bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t segid,minage,i,iter=0; int64_t diff=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; txtime = komodo_txtime2(&value,txid,vout,address); if ( validateflag == 0 ) { @@ -1398,6 +1398,23 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( blocktime+iter+segid*2 < txtime+minage ) continue; diff = (iter + blocktime - txtime - minage); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + { + if ( PoSperc < ASSETCHAINS_STAKED ) + { + // Under PoS % target and we need to increase diff. + //fprintf(stderr, "PoS too low diff.%i changed to.",diff); + diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) ); + //fprintf(stderr, "%i \n",diff); + } + else if ( PoSperc > ASSETCHAINS_STAKED ) + { + // Over PoS target need to lower diff. + //fprintf(stderr, "PoS too high diff.%i changed to.",diff); + diff = diff / ( (PoSperc - ASSETCHAINS_STAKED + 1) * (PoSperc - ASSETCHAINS_STAKED + 1) ); + //fprintf(stderr, "%i \n",diff); + } + } if ( diff < 0 ) diff = 60; else if ( diff > 3600*24*30 ) @@ -1408,19 +1425,8 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) - { - fprintf(stderr, "PoS % is: %i% vs. %i% \n", PoSperc, ASSETCHAINS_STAKED); - if ( PoSperc < ASSETCHAINS_STAKED ) - { - // This means we are under PoS % required and we need some extra help getting an elegible utxo. - // Likley there is some math required here to make it work properly. But getting the data here is no1 priority. - coinage = coinage * 1000; - } - } - // leave this here for now... - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + if ( blocktime+iter+segid*2 > prevtime+128 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); coinage256 = arith_uint256(coinage+1); hashval = ratio * (UintToArith256(hash) / coinage256); if ( hashval <= bnTarget ) @@ -1441,7 +1447,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh fprintf(stderr," vs "); for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff); */ break; } } @@ -2048,7 +2054,8 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk return(array); } -arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) +// WHY IS THIS HERE! It does this in komodo_stake! WTF! +/*arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) { int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; diff = (iter + blocktime - kp->txtime - minage); @@ -2074,12 +2081,12 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod kp->hashval = UintToArith256(hash); segid = ((nHeight + kp->segid32) & 0x3f); hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - /*for (int i=31; i>=16; i--) + for (int i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs "); for (int i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime);*/ + fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); if ( hashval <= bnTarget ) { for (iter=0; iternTime+27,minage,hashbuf)) == 0 ) - continue; + // WTF! was this here for! + //if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) + // continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address,PoSperc); //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index cb1d9987d..dd51d9c93 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -82,7 +82,7 @@ uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,503381775,503381775}; +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375,487526159}; // ^ wrong! // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS @@ -95,7 +95,8 @@ int32_t ASSETCHAINS_SAPLING = -1; int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; +int32_t ASSETCHAINS_STAKED; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1fe4c012a..cb7275898 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1916,7 +1916,7 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LWMAPOS),(void *)&ASSETCHAINS_LWMAPOS); } - val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; + val = ASSETCHAINS_COMMISSION | (((int64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) { diff --git a/src/main.cpp b/src/main.cpp index c1cdc3935..5aaf69bfb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2216,8 +2216,9 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; extern uint32_t ASSETCHAINS_MAGIC; -extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; +extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; +extern int32_t ASSETCHAINS_STAKED; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { diff --git a/src/miner.cpp b/src/miner.cpp index 66f1a263f..4ce3bc37b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -132,8 +132,8 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" extern CCriticalSection cs_metrics; -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF; -extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF,ASSETCHAINS_STAKED; +extern uint64_t ASSETCHAINS_COMMISSION; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; @@ -558,9 +558,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nFees += txfees; pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); - } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); - + } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } + // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); txNew.vin.resize(1); diff --git a/src/pow.cpp b/src/pow.cpp index 0e4b706a8..3e7afa720 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -37,9 +37,9 @@ #endif // ENABLE_RUST uint32_t komodo_chainactive_timestamp(); -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_STAKED; +extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH; extern char ASSETCHAINS_SYMBOL[65]; -extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; +extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD,ASSETCHAINS_STAKED; unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params); unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bb46f47fb..147b94b61 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -622,7 +622,7 @@ UniValue getblockhash(const UniValue& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } -extern uint64_t ASSETCHAINS_STAKED; +extern int32_t ASSETCHAINS_STAKED; UniValue getlastsegidstakes(const UniValue& params, bool fHelp) { diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 3843529ac..44b0162ad 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -48,8 +48,7 @@ using namespace std; -extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS; -extern uint64_t ASSETCHAINS_STAKED; +extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS,ASSETCHAINS_STAKED; extern int32_t KOMODO_MININGTHREADS; extern bool VERUS_MINTBLOCKS; arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a174fedf7..4fa5c061c 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -80,8 +80,8 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_MAGIC; -extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY,ASSETCHAINS_LASTERA; -extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING; +extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY,ASSETCHAINS_LASTERA; +extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; From bbf756704f1bccfdeeae20643a034e53b5e7bfbf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 13:54:09 +0800 Subject: [PATCH 1429/3904] clean up --- src/komodo_bitcoind.h | 57 +------------------------------------------ 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b2b8011b5..ce7c0259a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2054,63 +2054,11 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk return(array); } -// WHY IS THIS HERE! It does this in komodo_stake! WTF! -/*arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) -{ - int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; - diff = (iter + blocktime - kp->txtime - minage); - if ( diff < 0 ) - diff = 60; - else if ( diff > 3600*24*30 ) - diff = 3600*24*30; - if ( iter > 0 ) - diff += segid*2; - coinage = ((uint64_t)kp->nValue * diff); - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); - coinage256 = arith_uint256(coinage+1); - hashval = ratio * (kp->hashval / coinage256); - return(hashval); -} - -uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komodo_staking *kp,int32_t nHeight,uint32_t blocktime,uint32_t prevtime,int32_t minage,uint8_t *hashbuf) -{ - int32_t maxiters = 600; uint256 hash; - int32_t segid,iter,diff; uint64_t coinage; arith_uint256 hashval,coinage256; - komodo_stakehash(&hash,kp->address,hashbuf,kp->txid,kp->vout); - kp->hashval = UintToArith256(hash); - segid = ((nHeight + kp->segid32) & 0x3f); - hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - for (int i=31; i>=16; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," vs "); - for (int i=31; i>=16; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - for (iter=0; itertxtime+minage ) - continue; - hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); - blocktime += iter; - blocktime += segid * 2; - return(blocktime); - } - } - } //else fprintf(stderr,"maxiters is not good enough\n"); - return(0); -}*/ - int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) { static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; int32_t PoSperc; - set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget,tmpTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; + set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget,tmpTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; @@ -2198,9 +2146,6 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt return(0); } kp = &array[i]; - // WTF! was this here for! - //if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) - // continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address,PoSperc); //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) From eb164bc03c99e78045391ceb3c7cf75bd13e9a02 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 13:57:04 +0800 Subject: [PATCH 1430/3904] ok --- src/komodo_bitcoind.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a7afe440b..86deb54be 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1867,14 +1867,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } else { -<<<<<<< HEAD - // I think this means the block is valid PoW. We need to set the pindex->segid here. - failed = 0; - CBlockIndex *pindex; -======= failed = 0; CBlockIndex *pindex; ->>>>>>> new_staker BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && pindex->segid == -2 ) { From e460f1aa57d1964965a7b0da629a268e5a4a2df5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 14:15:43 +0800 Subject: [PATCH 1431/3904] print --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index 3e7afa720..5c8baeada 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -135,7 +135,7 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const unsigned int nProofOfWorkLimit = bnLimit.GetCompact(); - printf("PoWLimit: %u\n", nProofOfWorkLimit); + //printf("PoWLimit: %u\n", nProofOfWorkLimit); // Find the first block in the averaging interval as we total the linearly weighted average const CBlockIndex* pindexFirst = pindexLast; From 81fc7ca05bd0f8e4b21f0eed6c9d4bb29694fc3b Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 23 Jan 2019 11:36:56 +0500 Subject: [PATCH 1432/3904] set fixed precision for coins for heirinfo --- src/cc/heir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 71ec9b040..0ba1d3d33 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -15,6 +15,7 @@ #include "CCHeir.h" #include "heir_validate.h" +#include class CoinHelper; class TokenHelper; @@ -1178,7 +1179,7 @@ UniValue HeirInfo(uint256 fundingtxid) if (tokenid == zeroid) { msg = "funding available in coins"; - stream << (double)inputs / COIN; + stream << std::fixed << std::setprecision(8) << (double)inputs / COIN; } else { msg = "funding available in tokens"; From 5f116e5d131c160f6ab390098f1df60cc9a98950 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 23 Jan 2019 11:38:56 +0500 Subject: [PATCH 1433/3904] removed incorrect debug logging in IsTokensvout --- src/cc/CCtokens.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index bdb710afb..d7db32b99 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -404,7 +404,6 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c uint8_t evalCodeInOpret; if (vopretExtra.size() >= 2 /*|| vopretExtra.size() != vopretExtra.begin()[0] <-- shold we check this?*/) { - std::cerr << "IsTokensvout() empty or incorrect contract opret" << std::endl; evalCodeInOpret = vopretExtra.begin()[1]; } else { From defe854383e3b1268157ddf3288e0dd3a9bb5b0b Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 23 Jan 2019 11:49:07 +0500 Subject: [PATCH 1434/3904] set fixed precision for total funds, too --- src/cc/heir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 0ba1d3d33..d00cab795 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1161,7 +1161,7 @@ UniValue HeirInfo(uint256 fundingtxid) if (tokenid == zeroid) { msg = "funding total in coins"; - stream << (double)total / COIN; + stream << std::fixed << std::setprecision(8) << (double)total / COIN; } else { msg = "funding total in tokens"; From a0427ebf79c35e1821631a3102c9427e5af44c06 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 15:01:08 +0800 Subject: [PATCH 1435/3904] ac_founders_reward fix --- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 10 +++++----- src/main.cpp | 2 +- src/miner.cpp | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 86deb54be..ddbadd527 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1739,7 +1739,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; - if ( ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 922179c2d..b66df3833 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1779,7 +1779,7 @@ void komodo_args(char *argv0) MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; - ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); + ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); @@ -1846,10 +1846,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else - { - printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); - } + else + { + printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); + } /*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) { //ASSETCHAINS_OVERRIDE_PUBKEY.clear(); diff --git a/src/main.cpp b/src/main.cpp index 5aaf69bfb..2894b8263 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3474,7 +3474,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->GetHeight(), chainparams.GetConsensus()) + sum; - if ( ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && + if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && { uint64_t checktoshis; if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->GetHeight())) != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 4ce3bc37b..f18b195da 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -133,7 +133,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern CCriticalSection cs_metrics; extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF,ASSETCHAINS_STAKED; -extern uint64_t ASSETCHAINS_COMMISSION; +extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_FOUNDERS_REWARD; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; @@ -587,7 +587,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); } - else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From de91bdf571a7adada58a5b98e4276883ff3ab4b7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 16:13:54 +0800 Subject: [PATCH 1436/3904] mutually exclusive founders reward and comission + magic value. --- src/komodo_utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b66df3833..b0642b53d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1787,6 +1787,11 @@ void komodo_args(char *argv0) ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); + if ( ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_FOUNDERS_REWARD != 0 ) + { + fprintf(stderr,"cannot use founders reward and commission on the same chain.\n"); + exit(0); + } if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { fprintf(stderr,"can only have one of -ac_beam or -ac_coda\n"); From 0c2aa0a6493203f6a89de5bb4d7388e33c2dea97 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 16:20:31 +0800 Subject: [PATCH 1437/3904] oops --- src/komodo_utils.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b0642b53d..5d05abd1e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1880,7 +1880,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1928,12 +1928,17 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((int64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); + if ( ASSETCHAINS_FOUNDERS != 0 ) { uint8_t tmp = 1; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp); if ( ASSETCHAINS_FOUNDERS > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + if ( ASSETCHAINS_FOUNDERS_REWARD != 0 ) + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD); + } } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { From 1fb9fd6ba7eed852cc5460b4a95df73204673ab9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 24 Jan 2019 00:08:04 +0800 Subject: [PATCH 1438/3904] fix equihash chain sync. --- src/komodo_bitcoind.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 545e7b241..a8af824d1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1454,8 +1454,16 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( blocktime+iter+segid*2 > prevtime+128 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + { + if ( blocktime+iter+segid*2 > prevtime+128 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); + } + else + { + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + } coinage256 = arith_uint256(coinage+1); hashval = ratio * (UintToArith256(hash) / coinage256); if ( hashval <= bnTarget ) From 088ea2bfb49f19ab83c8bd5ecc66f138f73d988e Mon Sep 17 00:00:00 2001 From: ca333 Date: Wed, 23 Jan 2019 19:02:05 +0100 Subject: [PATCH 1439/3904] update cclib to match autotools/libtools naming convention --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 96ab3f1fa..ad9842f09 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -572,7 +572,7 @@ komodod_LDADD += \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) \ - cclib.so + libcc.so if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) From 0d1effd93b42f2dcd8991ecd996a3c10fa410ca7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Jan 2019 22:04:21 -1100 Subject: [PATCH 1440/3904] Text --- src/sendalert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sendalert.cpp b/src/sendalert.cpp index 700146338..6525cb356 100644 --- a/src/sendalert.cpp +++ b/src/sendalert.cpp @@ -103,7 +103,7 @@ void ThreadSendAlert() // 4000 or higher will put the RPC into safe mode alert.nPriority = 4000; alert.strComment = ""; - alert.strStatusBar = "Your client version has degraded networking behavior. Please update to the most recent version of Verus (0.3.2 or later)."; + alert.strStatusBar = "Your client version has degraded networking behavior. Please update to the most recent version of Komodo (0.3.3 or later)."; alert.strRPCError = alert.strStatusBar; // Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done: From c3df1b8747750b8ef4a43738be8cfc28f8dffc88 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 24 Jan 2019 17:16:42 +0800 Subject: [PATCH 1441/3904] add auto purge of orphans from before notarisation. --- src/komodo.h | 2 ++ src/main.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.h | 2 +- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 4a8bd7d96..62310a0ed 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -707,6 +707,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); + if (RemoveOrphanedBlocks(*notarizedheightp)) + fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) diff --git a/src/main.cpp b/src/main.cpp index 614f13d44..a2980dea8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1979,6 +1979,72 @@ bool GetAddressUnspent(uint160 addressHash, int type, return true; } +struct CompareBlocksByHeightMain +{ + bool operator()(const CBlockIndex* a, const CBlockIndex* b) const + { + /* Make sure that unequal blocks with the same height do not compare + equal. Use the pointers themselves to make a distinction. */ + + if (a->GetHeight() != b->GetHeight()) + return (a->GetHeight() > b->GetHeight()); + + return a < b; + } +}; + +bool RemoveOrphanedBlocks(int32_t notarized_height) +{ + LOCK(cs_main); + std::vector prunedblocks; + std::set setTips; + int32_t n = 0; + // get notarised timestamp and use this as a backup incase the forked block has no height. + // we -600 to make sure the time is within future block constraints. + uint32_t notarized_timestamp = komodo_heightstamp(notarized_height)-600; + fprintf(stderr, "removing oprhans from before %d\n", notarized_height); + // Most of this code is a direct copy from GetChainTips RPC. Which gives a return of all + // blocks that are not in the main chain. + BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) + { + n++; + setTips.insert(item.second); + } + n = 0; + BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) + { + const CBlockIndex* pprev=0; + n++; + if ( item.second != 0 ) + pprev = item.second->pprev; + if (pprev) + setTips.erase(pprev); + } + const CBlockIndex *forked; + BOOST_FOREACH(const CBlockIndex* block, setTips) + { + // We skip anything over notarised height to avoid breaking normal consensus rules. + if ( block->GetHeight() > notarized_height || block->nTime > notarized_timestamp ) + continue; + // We can also check if the block is in the active chain as a backup test. + forked = chainActive.FindFork(block); + // Here we save each forked block to a vector for removal later. + if ( forked != 0 ) + prunedblocks.push_back(block); + } + if (pblocktree->EraseBatchSync(prunedblocks)) + { + // Blocks cleared from disk succesfully, using internal DB batch erase function. Which exists, but has never been used before. + // We need to try and clear the block index from mapBlockIndex now, otherwise node will need a restart. + BOOST_FOREACH(const CBlockIndex* block, prunedblocks) + { + mapBlockIndex.erase(block->GetBlockHash()); + } + return true; + } + return false; +} + /*uint64_t myGettxout(uint256 hash,int32_t n) { CCoins coins; diff --git a/src/main.h b/src/main.h index 463c91237..35c01c23a 100644 --- a/src/main.h +++ b/src/main.h @@ -806,7 +806,7 @@ bool GetAddressUnspent(uint160 addressHash, int type, bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart); bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,bool checkPOW); bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW); - +bool RemoveOrphanedBlocks(int32_t notarized_height); /** Functions for validating blocks and updating the block tree */ From effb3a2a10269cc627c80baf225375cd684f7cc4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Jan 2019 22:20:21 -1100 Subject: [PATCH 1442/3904] Tweak error check --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a2980dea8..1da977ab9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4658,7 +4658,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, *futureblockp = 0; if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60) { - CBlockIndex *tipindex; + /*CBlockIndex *tipindex; //fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetAdjustedTime()); if ( (tipindex= chainActive.Tip()) != 0 && tipindex->GetBlockHash() == blockhdr.hashPrevBlock && blockhdr.GetBlockTime() < GetAdjustedTime() + 60 + 5 ) { @@ -4667,9 +4667,9 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, sleep(1); //fprintf(stderr,"now its valid\n"); } - else + else*/ { - if (blockhdr.GetBlockTime() < GetAdjustedTime() + 600) + if (blockhdr.GetBlockTime() < GetAdjustedTime() + 300) *futureblockp = 1; //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new"); From 1a9476e844df4d83dfc4c33924333e0ae95bd782 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Jan 2019 22:22:52 -1100 Subject: [PATCH 1443/3904] +/- prints --- src/komodo.h | 4 +++- src/main.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 62310a0ed..35fee05ad 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -708,7 +708,9 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); if (RemoveOrphanedBlocks(*notarizedheightp)) - fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); + { + //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); + } if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) diff --git a/src/main.cpp b/src/main.cpp index 1da977ab9..be2317891 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1998,12 +1998,11 @@ bool RemoveOrphanedBlocks(int32_t notarized_height) LOCK(cs_main); std::vector prunedblocks; std::set setTips; - int32_t n = 0; + int32_t m=0,n = 0; // get notarised timestamp and use this as a backup incase the forked block has no height. // we -600 to make sure the time is within future block constraints. uint32_t notarized_timestamp = komodo_heightstamp(notarized_height)-600; - fprintf(stderr, "removing oprhans from before %d\n", notarized_height); - // Most of this code is a direct copy from GetChainTips RPC. Which gives a return of all + // Most of this code is a direct copy from GetChainTips RPC. Which gives a return of all // blocks that are not in the main chain. BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) { @@ -2038,8 +2037,10 @@ bool RemoveOrphanedBlocks(int32_t notarized_height) // We need to try and clear the block index from mapBlockIndex now, otherwise node will need a restart. BOOST_FOREACH(const CBlockIndex* block, prunedblocks) { + m++; mapBlockIndex.erase(block->GetBlockHash()); } + fprintf(stderr, "%s removed %d of %d orphans from before %d\n",ASSETCHAINS_SYMBOL,m,n, notarized_height); return true; } return false; From 2a36abaf5d0a50ad612a04ac7fab2f248a54e7e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Jan 2019 22:51:10 -1100 Subject: [PATCH 1444/3904] skip Zero pruned blocks --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index be2317891..4bd7ed3e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2031,7 +2031,7 @@ bool RemoveOrphanedBlocks(int32_t notarized_height) if ( forked != 0 ) prunedblocks.push_back(block); } - if (pblocktree->EraseBatchSync(prunedblocks)) + if (prunedblocks.size() > 0 && pblocktree->EraseBatchSync(prunedblocks)) { // Blocks cleared from disk succesfully, using internal DB batch erase function. Which exists, but has never been used before. // We need to try and clear the block index from mapBlockIndex now, otherwise node will need a restart. @@ -2040,7 +2040,7 @@ bool RemoveOrphanedBlocks(int32_t notarized_height) m++; mapBlockIndex.erase(block->GetBlockHash()); } - fprintf(stderr, "%s removed %d of %d orphans from before %d\n",ASSETCHAINS_SYMBOL,m,n, notarized_height); + fprintf(stderr, "%s removed %d orphans from %d blocks before %d\n",ASSETCHAINS_SYMBOL,m,n, notarized_height); return true; } return false; From d192f1d1f35db442f7a747288a51db671fd34701 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Jan 2019 23:46:45 -1100 Subject: [PATCH 1445/3904] Rawtx->hex for marmara --- src/cc/marmara.cpp | 12 ++++++------ src/main.cpp | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8f8de12e2..0e301ba97 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -496,7 +496,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) else { result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("hex",rawtx)); return(result); } } else errorstr = (char *)"insufficient funds"; @@ -600,7 +600,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,change,Marmarapk,pk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('S',createtxid,mypk,0,refmatures,currency),pubkeys); result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("hex",rawtx)); return(result); } else remaining -= inputsum; if ( mtx.vin.size() >= CC_MAXVINS - MARMARA_VINS ) @@ -616,7 +616,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('D',createtxid,mypk,-remaining,refmatures,currency),pubkeys); result.push_back(Pair("result",(char *)"error")); result.push_back(Pair("error",(char *)"insufficient funds")); - result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("hex",rawtx)); result.push_back(Pair("remaining",ValueFromAmount(remaining))); } else @@ -731,7 +731,7 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri else { result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("hex",rawtx)); result.push_back(Pair("funcid","R")); result.push_back(Pair("createtxid",createtxid.GetHex())); if ( batontxid != zeroid ) @@ -787,7 +787,7 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a else { result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("hex",rawtx)); char str[2]; str[0] = funcid, str[1] = 0; result.push_back(Pair("funcid",str)); result.push_back(Pair("createtxid",createtxid.GetHex())); @@ -1025,7 +1025,7 @@ UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char * else { result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("rawtx",rawtx)); + result.push_back(Pair("hex",rawtx)); if ( totalpayout > 0 && total > totalpayout-txfee ) { result.push_back(Pair("firstheight",firstheight)); diff --git a/src/main.cpp b/src/main.cpp index 4bd7ed3e3..b4f0acef0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5662,7 +5662,6 @@ bool static LoadBlockIndexDB() if (pindex->nStatus & BLOCK_HAVE_DATA) { setBlkDataFiles.insert(pindex->nFile); } - //komodo_pindex_init(pindex,(int32_t)pindex->GetHeight()); } //fprintf(stderr,"load blockindexDB %u\n",(uint32_t)time(NULL)); for (std::set::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++) From 0f6ee83311bad26912256c7e6b9080d66c5a9b05 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 01:44:20 -1100 Subject: [PATCH 1446/3904] Tmp files --- src/chain.h | 1 + src/main.cpp | 79 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 22 deletions(-) diff --git a/src/chain.h b/src/chain.h index 49b206480..45db77720 100644 --- a/src/chain.h +++ b/src/chain.h @@ -115,6 +115,7 @@ enum BlockStatus: uint32_t { BLOCK_FAILED_MASK = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD, BLOCK_ACTIVATES_UPGRADE = 128, //! block activates a network upgrade + BLOCK_IN_TMPFILE = 256 }; //! Short-hand for the highest consensus validity we implement. diff --git a/src/main.cpp b/src/main.cpp index b4f0acef0..29096308b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,6 +76,7 @@ using namespace std; * Global state */ +#define TMPFILE_START 100000000 CCriticalSection cs_main; extern uint8_t NOTARY_PUBKEY33[33]; extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CONNECTING,KOMODO_EXTRASATOSHI; @@ -182,8 +183,9 @@ namespace { multimap mapBlocksUnlinked; CCriticalSection cs_LastBlockFile; - std::vector vinfoBlockFile; + std::vector vinfoBlockFile,tmpBlockFiles; int nLastBlockFile = 0; + int nLastTmpFile = 0; /** Global flag to indicate we should check to see if there are * block/undo files that should be deleted. Set on startup * or if we allocate more file space when we're in prune mode @@ -3256,6 +3258,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return false; fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } + if ( (pindex->nStatus & BLOCK_IN_TMPFILE) != 0 ) + { + unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); + CDiskBlockPos blockPos; + if (!FindBlockPos(1,state, blockPos, nBlockSize+8, pindex->GetHeight(), block.GetBlockTime(),false)) + return error("ConnectBlock(): FindBlockPos failed"); + if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) + return error("ConnectBlock(): FindBlockPos failed"); + pindex->nStatus &= (~BLOCK_IN_TMPFILE); + fprintf(stderr,"added ht.%d copy of tmpfile\n",pindex->GetHeight()); + } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); if ( hashPrevBlock != view.GetBestBlock() ) @@ -4550,43 +4563,57 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl return true; } -bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false) +bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false) { + std::vector *ptr; int *lastfilep; LOCK(cs_LastBlockFile); - unsigned int nFile = fKnown ? pos.nFile : nLastBlockFile; - if (vinfoBlockFile.size() <= nFile) { - vinfoBlockFile.resize(nFile + 1); + unsigned int nFile; + if ( tmpflag != 0 ) + { + ptr = &tmpBlockFiles; + nFile = nLastTmpFile; + lastfilep = &nLastTmpFile; + } + else + { + ptr = &vinfoBlockFile; + lastfilep = &nLastBlockFile; + nFile = fKnown ? pos.nFile : nLastBlockFile; + if (vinfoBlockFile.size() <= nFile) { + vinfoBlockFile.resize(nFile + 1); + } } - if (!fKnown) { - while (vinfoBlockFile[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { + while ((*ptr)[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { nFile++; - if (vinfoBlockFile.size() <= nFile) { - vinfoBlockFile.resize(nFile + 1); + if ((*ptr).size() <= nFile) { + (*ptr).resize(nFile + 1); } } - pos.nFile = nFile; - pos.nPos = vinfoBlockFile[nFile].nSize; + pos.nFile = nFile + tmpflag*TMPFILE_START; + pos.nPos = (*ptr)[nFile].nSize; + if ( tmpflag != 0 ) + fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } - if (nFile != nLastBlockFile) { + if (nFile != *lastfilep) { if (!fKnown) { - LogPrintf("Leaving block file %i: %s\n", nFile, vinfoBlockFile[nFile].ToString()); + LogPrintf("Leaving block file %i: %s\n", nFile, (*ptr)[nFile].ToString()); } FlushBlockFile(!fKnown); - nLastBlockFile = nFile; + *lastfilep = nFile; } - vinfoBlockFile[nFile].AddBlock(nHeight, nTime); + (*ptr)[nFile].AddBlock(nHeight, nTime); if (fKnown) - vinfoBlockFile[nFile].nSize = std::max(pos.nPos + nAddSize, vinfoBlockFile[nFile].nSize); + (*ptr)[nFile].nSize = std::max(pos.nPos + nAddSize, (*ptr)[nFile].nSize); else - vinfoBlockFile[nFile].nSize += nAddSize; + (*ptr)[nFile].nSize += nAddSize; if (!fKnown) { unsigned int nOldChunks = (pos.nPos + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE; - unsigned int nNewChunks = (vinfoBlockFile[nFile].nSize + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE; + unsigned int nNewChunks = ((*ptr)[nFile].nSize + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE; if (nNewChunks > nOldChunks) { if (fPruneMode) fCheckForPruning = true; @@ -4603,12 +4630,17 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd } } - setDirtyFileInfo.insert(nFile); + setDirtyFileInfo.insert(nFile + tmpflag*TMPFILE_START); return true; } bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize) { + if ( nFile >= TMPFILE_START ) + { + fprintf(stderr,"FindUndoPos unexpected tmpfile %d\n",nFile); + return(false); + } pos.nFile = nFile; LOCK(cs_LastBlockFile); @@ -5171,13 +5203,14 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C CDiskBlockPos blockPos; if (dbp != NULL) blockPos = *dbp; - if (!FindBlockPos(state, blockPos, nBlockSize+8, nHeight, block.GetBlockTime(), dbp != NULL)) + if (!FindBlockPos(1,state, blockPos, nBlockSize+8, nHeight, block.GetBlockTime(), dbp != NULL)) return error("AcceptBlock(): FindBlockPos failed"); if (dbp == NULL) if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) AbortNode(state, "Failed to write block"); if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); + pindex->nStatus |= BLOCK_IN_TMPFILE; } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); } @@ -5495,7 +5528,7 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes) FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly) { - static int32_t didinit[64]; + static int32_t didinit[256]; if (pos.IsNull()) return NULL; boost::filesystem::path path = GetBlockPosFilename(pos, prefix); @@ -6002,6 +6035,7 @@ void UnloadBlockIndex() nSyncStarted = 0; mapBlocksUnlinked.clear(); vinfoBlockFile.clear(); + tmpBlockFiles.clear(); nLastBlockFile = 0; nBlockSequenceId = 1; mapBlockSource.clear(); @@ -6037,6 +6071,7 @@ bool LoadBlockIndex() bool InitBlockIndex() { const CChainParams& chainparams = Params(); LOCK(cs_main); + tmpBlockFiles.clear(); // Initialize global variables that cannot be constructed at startup. recentRejects.reset(new CRollingBloomFilter(120000, 0.000001)); @@ -6069,7 +6104,7 @@ bool InitBlockIndex() { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); CDiskBlockPos blockPos; CValidationState state; - if (!FindBlockPos(state, blockPos, nBlockSize+8, 0, block.GetBlockTime())) + if (!FindBlockPos(0,state, blockPos, nBlockSize+8, 0, block.GetBlockTime())) return error("LoadBlockIndex(): FindBlockPos failed"); if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) return error("LoadBlockIndex(): writing genesis block to disk failed"); From 82bc38fabf051317f9b1b6ca230c5ffa3cdb4e4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 01:51:33 -1100 Subject: [PATCH 1447/3904] Syntax --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 29096308b..9d4e1f243 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3226,6 +3226,7 @@ static int64_t nTimeConnect = 0; static int64_t nTimeIndex = 0; static int64_t nTimeCallbacks = 0; static int64_t nTimeTotal = 0; +bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { @@ -3264,7 +3265,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CDiskBlockPos blockPos; if (!FindBlockPos(1,state, blockPos, nBlockSize+8, pindex->GetHeight(), block.GetBlockTime(),false)) return error("ConnectBlock(): FindBlockPos failed"); - if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) + if (!WriteBlockToDisk((CBlock)block, blockPos, chainparams.MessageStart())) return error("ConnectBlock(): FindBlockPos failed"); pindex->nStatus &= (~BLOCK_IN_TMPFILE); fprintf(stderr,"added ht.%d copy of tmpfile\n",pindex->GetHeight()); From 669f5c4d391f112dc1c549703c8297547196f31d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 01:55:15 -1100 Subject: [PATCH 1448/3904] Const --- src/main.cpp | 4 ++-- src/main.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9d4e1f243..43cca5266 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2195,7 +2195,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock // CBlock and CBlockIndex // -bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart) +bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart) { // Open history file to append CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION); @@ -3265,7 +3265,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CDiskBlockPos blockPos; if (!FindBlockPos(1,state, blockPos, nBlockSize+8, pindex->GetHeight(), block.GetBlockTime(),false)) return error("ConnectBlock(): FindBlockPos failed"); - if (!WriteBlockToDisk((CBlock)block, blockPos, chainparams.MessageStart())) + if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) return error("ConnectBlock(): FindBlockPos failed"); pindex->nStatus &= (~BLOCK_IN_TMPFILE); fprintf(stderr,"added ht.%d copy of tmpfile\n",pindex->GetHeight()); diff --git a/src/main.h b/src/main.h index 35c01c23a..40170fa70 100644 --- a/src/main.h +++ b/src/main.h @@ -803,7 +803,7 @@ bool GetAddressUnspent(uint160 addressHash, int type, std::vector > &unspentOutputs); /** Functions for disk access for blocks */ -bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart); +bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart); bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,bool checkPOW); bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW); bool RemoveOrphanedBlocks(int32_t notarized_height); From 3c1e3aede1cfd767d6c7d6f25f328600de3e88c4 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Thu, 24 Jan 2019 19:55:55 +0700 Subject: [PATCH 1449/3904] initial heir tests --- qa/pull-tester/cc-tests.sh | 1 + qa/rpc-tests/cryptoconditions_heir.py | 121 ++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100755 qa/rpc-tests/cryptoconditions_heir.py diff --git a/qa/pull-tester/cc-tests.sh b/qa/pull-tester/cc-tests.sh index 9bc8c155d..742763f1d 100755 --- a/qa/pull-tester/cc-tests.sh +++ b/qa/pull-tester/cc-tests.sh @@ -18,6 +18,7 @@ testScripts=( 'cryptoconditions_rewards.py' 'cryptoconditions_token.py' #'cryptoconditions_gateways.py' + 'cryptoconditions_hair.py' # TODO: cant reconnect nodes back in channels test because of crash (seems regtest only specific) 'cryptoconditions_channels.py' ); diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py new file mode 100755 index 000000000..95b90b397 --- /dev/null +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +import time +from test_framework.test_framework import CryptoconditionsTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import assert_equal, assert_greater_than, \ + initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ + stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises +from cryptoconditions import assert_success, assert_error, generate_random_string + + +class CryptoconditionsHeirTest(CryptoconditionsTestFramework): + + def run_heir_tests(self): + + rpc = self.nodes[0] + rpc1 = self.nodes[1] + + result = rpc.heiraddress() + assert_success(result) + # verify all keys look like valid AC addrs, could be better + for x in ['myCCaddress', 'HeirCCaddress', 'Heirmarker', 'myaddress']: + assert_equal(result[x][0], 'R') + + result = rpc.heiraddress(self.pubkey) + assert_success(result) + # test that additional CCaddress key is returned + for x in ['myCCaddress', 'HeirCCaddress', 'Heirmarker', 'myaddress', 'CCaddress']: + assert_equal(result[x][0], 'R') + + # getting empty heir list + result = rpc.heirlist() + assert_equal(len(result), 1) + assert_success(result) + + # valid heirfund case with coins + result = rpc.heirfund("0", "1000", "UNITHEIR", self.pubkey1, "10") + assert_success(result) + + heir_fund_txid = self.send_and_mine(result["hextx"], rpc) + assert heir_fund_txid, "got heir funding txid" + + # heir fund txid should be in heirlist now + result = rpc.heirlist() + assert_equal(len(result), 2) + assert_success(result) + assert_equal(result["fundingtxid"], heir_fund_txid) + + # checking heirinfo + result = rpc.heirinfo(heir_fund_txid) + assert_success(result) + assert_equal(result["fundingtxid"], heir_fund_txid) + assert_equal(result["name"], "UNITHEIR") + assert_equal(result["owner"], self.pubkey) + assert_equal(result["heir"], self.pubkey1) + assert_equal(result["funding total in coins"], "1000.00000000") + assert_equal(result["funding available in coins"], "1000.00000000") + assert_equal(result["inactivity time setting, sec"], "10") + assert_equal(result["spending allowed for the heir"], "false") + + # TODO: heirlist keys are duplicating now + + # waiting for 11 seconds to be sure that needed time passed for heir claiming + time.sleep(11) + rpc.generate(1) + self.sync_all() + result = rpc.heirinfo(heir_fund_txid) + assert_equal(result["funding available in coins"], "1000.00000000") + assert_equal(result["spending allowed for the heir"], "true") + + # have to check that second node have coins to cover txfee at least + rpc.sendtoaddress(rpc1.getnewaddress(), 1) + rpc.sendtoaddress(rpc1.getnewaddress(), 1) + rpc.generate(2) + self.sync_all() + second_node_balance = rpc1.getbalance() + assert_greater_than(second_node_balance, 0.1) + + # let's claim whole heir sum from second node + result = rpc1.heirclaim("0", "1000", heir_fund_txid) + assert_success(result) + + heir_claim_txid = self.send_and_mine(result["hextx"], rpc1) + assert heir_claim_txid, "got claim txid" + + # balance of second node after heirclaim should increase for 1000 coins - txfees + # + get one block reward when broadcasted heir_claim_txid + result = round(rpc1.getbalance()) - round(second_node_balance) + assert_greater_than(result, 100999) + + self.sync_all() + + # no more funds should be available for claiming + result = rpc.heirinfo(heir_fund_txid) + assert_equal(result["funding available in coins"], "0.00000000") + + # TODO: valid heirfund case with tokens + + def run_test(self): + print("Mining blocks...") + rpc = self.nodes[0] + rpc1 = self.nodes[1] + # utxos from block 1 become mature in block 101 + if not self.options.noshutdown: + rpc.generate(101) + self.sync_all() + rpc.getinfo() + rpc1.getinfo() + # this corresponds to -pubkey above + print("Importing privkeys") + rpc.importprivkey(self.privkey) + rpc1.importprivkey(self.privkey1) + self.run_heir_tests() + + +if __name__ == '__main__': + CryptoconditionsHeirTest().main() From 9f663ad841dc2f3cde6bdf8465b370df8df23b8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 02:00:37 -1100 Subject: [PATCH 1450/3904] Remove fKnown = false --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 43cca5266..cef3e29ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4564,7 +4564,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl return true; } -bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false) +bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown) { std::vector *ptr; int *lastfilep; LOCK(cs_LastBlockFile); From 87a12db2d1e667f66ea78490c823e8c72f23046b Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Thu, 24 Jan 2019 20:11:42 +0700 Subject: [PATCH 1451/3904] Omg --- qa/pull-tester/cc-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/pull-tester/cc-tests.sh b/qa/pull-tester/cc-tests.sh index 742763f1d..d68671e12 100755 --- a/qa/pull-tester/cc-tests.sh +++ b/qa/pull-tester/cc-tests.sh @@ -18,7 +18,7 @@ testScripts=( 'cryptoconditions_rewards.py' 'cryptoconditions_token.py' #'cryptoconditions_gateways.py' - 'cryptoconditions_hair.py' + 'cryptoconditions_heir.py' # TODO: cant reconnect nodes back in channels test because of crash (seems regtest only specific) 'cryptoconditions_channels.py' ); From 2367a5cc0b78880dbdbec6f4b5e3e0a6c1f7c840 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 02:14:31 -1100 Subject: [PATCH 1452/3904] Create first entry for tmpBlockfiles --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index cef3e29ab..73f910d10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5673,6 +5673,7 @@ bool static LoadBlockIndexDB() // Load block file info pblocktree->ReadLastBlockFile(nLastBlockFile); vinfoBlockFile.resize(nLastBlockFile + 1); + tmpBlockFiles.resize(nLastTmpFile + 1); LogPrintf("%s: last block file = %i\n", __func__, nLastBlockFile); for (int nFile = 0; nFile <= nLastBlockFile; nFile++) { pblocktree->ReadBlockFileInfo(nFile, vinfoBlockFile[nFile]); From 420158a628c9c23be84487e6ae3d6514bf71004d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 02:29:23 -1100 Subject: [PATCH 1453/3904] Undo for tmp files --- src/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 73f910d10..fe1503434 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4637,18 +4637,18 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize) { + std::vector *ptr; int *lastfilep; + LOCK(cs_LastBlockFile); if ( nFile >= TMPFILE_START ) { - fprintf(stderr,"FindUndoPos unexpected tmpfile %d\n",nFile); - return(false); - } + nFile %= TMPFILE_START; + ptr = &tmpBlockFiles; + } else ptr = &vinfoBlockFile; + pos.nFile = nFile; - - LOCK(cs_LastBlockFile); - unsigned int nNewSize; - pos.nPos = vinfoBlockFile[nFile].nUndoSize; - nNewSize = vinfoBlockFile[nFile].nUndoSize += nAddSize; + pos.nPos = (*ptr)[nFile].nUndoSize; + nNewSize = (*ptr)[nFile].nUndoSize += nAddSize; setDirtyFileInfo.insert(nFile); unsigned int nOldChunks = (pos.nPos + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE; From 05371f93bd144fd85dffc622443b364388ca7196 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 02:30:39 -1100 Subject: [PATCH 1454/3904] +print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index fe1503434..d10166ab3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3268,7 +3268,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) return error("ConnectBlock(): FindBlockPos failed"); pindex->nStatus &= (~BLOCK_IN_TMPFILE); - fprintf(stderr,"added ht.%d copy of tmpfile\n",pindex->GetHeight()); + fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); From 86ee8f65502f3d039fa7165c97a383d47f3b7bec Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 02:33:21 -1100 Subject: [PATCH 1455/3904] Switch to main file from temp files --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d10166ab3..cc37ba316 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3263,7 +3263,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); CDiskBlockPos blockPos; - if (!FindBlockPos(1,state, blockPos, nBlockSize+8, pindex->GetHeight(), block.GetBlockTime(),false)) + if (!FindBlockPos(0,state, blockPos, nBlockSize+8, pindex->GetHeight(), block.GetBlockTime(),false)) return error("ConnectBlock(): FindBlockPos failed"); if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) return error("ConnectBlock(): FindBlockPos failed"); From f9e2487fdde647734b8417319f5fe05d1d6a1a0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 02:37:35 -1100 Subject: [PATCH 1456/3904] Mark new file as dirty --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cc37ba316..f243cef8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3268,7 +3268,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) return error("ConnectBlock(): FindBlockPos failed"); pindex->nStatus &= (~BLOCK_IN_TMPFILE); - fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); + setDirtyFileInfo.insert(blockPos.nFile); + //fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); @@ -4594,7 +4595,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u } pos.nFile = nFile + tmpflag*TMPFILE_START; pos.nPos = (*ptr)[nFile].nSize; - if ( tmpflag != 0 ) + if ( 0 && tmpflag != 0 ) fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } From b963af2269d4d0ee20305bff25aa29a6981bc8e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 02:41:08 -1100 Subject: [PATCH 1457/3904] Tmp undo file --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f243cef8e..3d5128de2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4640,13 +4640,13 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne { std::vector *ptr; int *lastfilep; LOCK(cs_LastBlockFile); + pos.nFile = nFile; if ( nFile >= TMPFILE_START ) { nFile %= TMPFILE_START; ptr = &tmpBlockFiles; } else ptr = &vinfoBlockFile; - pos.nFile = nFile; unsigned int nNewSize; pos.nPos = (*ptr)[nFile].nUndoSize; nNewSize = (*ptr)[nFile].nUndoSize += nAddSize; From 4c4c50cbd7bb543631045b6da911d19b47b0aa35 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:01:02 -1100 Subject: [PATCH 1458/3904] Receive transactions --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3d5128de2..945243351 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3230,6 +3230,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { + CDiskBlockPos blockPos; const CChainParams& chainparams = Params(); if ( KOMODO_STOPAT != 0 && pindex->GetHeight() > KOMODO_STOPAT ) return(false); @@ -3262,12 +3263,15 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if ( (pindex->nStatus & BLOCK_IN_TMPFILE) != 0 ) { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); - CDiskBlockPos blockPos; if (!FindBlockPos(0,state, blockPos, nBlockSize+8, pindex->GetHeight(), block.GetBlockTime(),false)) return error("ConnectBlock(): FindBlockPos failed"); if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) return error("ConnectBlock(): FindBlockPos failed"); pindex->nStatus &= (~BLOCK_IN_TMPFILE); + pindex->nFile = blockPos.nFile; + pindex->nPos = blockPos.nPos; + if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) + return error("AcceptBlock(): ReceivedBlockTransactions failed"); setDirtyFileInfo.insert(blockPos.nFile); //fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); } From f44e95a3f585169c01c833744db4cb7f68c9d640 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:02:21 -1100 Subject: [PATCH 1459/3904] nDataPos --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 945243351..850aa1c1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3269,7 +3269,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return error("ConnectBlock(): FindBlockPos failed"); pindex->nStatus &= (~BLOCK_IN_TMPFILE); pindex->nFile = blockPos.nFile; - pindex->nPos = blockPos.nPos; + pindex->nDataPos = blockPos.nPos; if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); setDirtyFileInfo.insert(blockPos.nFile); From eda67fa9d67d514587afa84680ef6d5922c1f840 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:04:10 -1100 Subject: [PATCH 1460/3904] bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos) --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 850aa1c1b..91d90aa14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3227,6 +3227,7 @@ static int64_t nTimeIndex = 0; static int64_t nTimeCallbacks = 0; static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); +bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { From df9d2ddc97eb80b7b3442eac7c4c91faf092b8cd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:11:31 -1100 Subject: [PATCH 1461/3904] Test --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 91d90aa14..bfb1a0535 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4648,6 +4648,8 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne pos.nFile = nFile; if ( nFile >= TMPFILE_START ) { + fprintf(stderr,"skip tmp undo\n"); + return(false); nFile %= TMPFILE_START; ptr = &tmpBlockFiles; } else ptr = &vinfoBlockFile; From f5ad6948fcb2690df7ca03c0872b0160b095df51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:28:26 -1100 Subject: [PATCH 1462/3904] -recvtx --- src/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bfb1a0535..71c04aa56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3274,7 +3274,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); setDirtyFileInfo.insert(blockPos.nFile); - //fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); + FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files + fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); @@ -5217,8 +5218,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if (dbp == NULL) if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) AbortNode(state, "Failed to write block"); - if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) - return error("AcceptBlock(): ReceivedBlockTransactions failed"); + //if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) + // return error("AcceptBlock(): ReceivedBlockTransactions failed"); pindex->nStatus |= BLOCK_IN_TMPFILE; } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); From d8611d936de13c7832efced30870a062b5fa3660 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:30:17 -1100 Subject: [PATCH 1463/3904] FlushStateMode --- src/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 71c04aa56..45ec46b45 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3229,6 +3229,14 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); + +enum FlushStateMode { + FLUSH_STATE_NONE, + FLUSH_STATE_IF_NEEDED, + FLUSH_STATE_PERIODIC, + FLUSH_STATE_ALWAYS +}; + bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3670,12 +3678,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; } -enum FlushStateMode { - FLUSH_STATE_NONE, - FLUSH_STATE_IF_NEEDED, - FLUSH_STATE_PERIODIC, - FLUSH_STATE_ALWAYS -}; /** * Update the on-disk chain state. From 10b7fff5bc24b0dc820380044f2feef73f14ec73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:32:22 -1100 Subject: [PATCH 1464/3904] Static --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 45ec46b45..4bd49b557 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3236,6 +3236,7 @@ enum FlushStateMode { FLUSH_STATE_PERIODIC, FLUSH_STATE_ALWAYS }; +bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode); bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { From d797bce94d35b61b108029a7d26ff0e41307f680 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:34:10 -1100 Subject: [PATCH 1465/3904] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4bd49b557..e9af9231f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5221,8 +5221,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if (dbp == NULL) if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) AbortNode(state, "Failed to write block"); - //if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) - // return error("AcceptBlock(): ReceivedBlockTransactions failed"); + if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) + return error("AcceptBlock(): ReceivedBlockTransactions failed"); pindex->nStatus |= BLOCK_IN_TMPFILE; } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); From d682dfd830f92659512847ed70bf793779c5b09c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 03:42:27 -1100 Subject: [PATCH 1466/3904] +print --- src/main.cpp | 16 ++++++---------- src/txdb.cpp | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e9af9231f..0198c046d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3229,15 +3229,6 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); - -enum FlushStateMode { - FLUSH_STATE_NONE, - FLUSH_STATE_IF_NEEDED, - FLUSH_STATE_PERIODIC, - FLUSH_STATE_ALWAYS -}; -bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode); - bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3283,7 +3274,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); setDirtyFileInfo.insert(blockPos.nFile); - FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); } // verify that the view's current state corresponds to the previous block @@ -3679,6 +3669,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; } +enum FlushStateMode { + FLUSH_STATE_NONE, + FLUSH_STATE_IF_NEEDED, + FLUSH_STATE_PERIODIC, + FLUSH_STATE_ALWAYS +}; /** * Update the on-disk chain state. diff --git a/src/txdb.cpp b/src/txdb.cpp index 164167c29..4d84b1cd2 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -686,7 +686,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; pindexNew->nSaplingValue = diskindex.nSaplingValue; - +fprintf(stderr,"loadguts ht.%d\n",pindexNew->GetHeight()); // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From ed73fd8423d455775f2b429f707011bae0caf830 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 04:16:01 -1100 Subject: [PATCH 1467/3904] Undo tmpfile --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0198c046d..adf445255 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5212,14 +5212,14 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C CDiskBlockPos blockPos; if (dbp != NULL) blockPos = *dbp; - if (!FindBlockPos(1,state, blockPos, nBlockSize+8, nHeight, block.GetBlockTime(), dbp != NULL)) + if (!FindBlockPos(0,state, blockPos, nBlockSize+8, nHeight, block.GetBlockTime(), dbp != NULL)) return error("AcceptBlock(): FindBlockPos failed"); if (dbp == NULL) if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) AbortNode(state, "Failed to write block"); if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); - pindex->nStatus |= BLOCK_IN_TMPFILE; + //pindex->nStatus |= BLOCK_IN_TMPFILE; } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); } From 1b53f34527a7cdeb986c7a26790e91781367fcae Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Jan 2019 04:18:54 -1100 Subject: [PATCH 1468/3904] Use tmp --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index adf445255..344224902 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5206,20 +5206,22 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } int nHeight = pindex->GetHeight(); + int32_t usetmp = 0; // Write block to history file try { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); CDiskBlockPos blockPos; if (dbp != NULL) blockPos = *dbp; - if (!FindBlockPos(0,state, blockPos, nBlockSize+8, nHeight, block.GetBlockTime(), dbp != NULL)) + if (!FindBlockPos(usetmp,state, blockPos, nBlockSize+8, nHeight, block.GetBlockTime(), dbp != NULL)) return error("AcceptBlock(): FindBlockPos failed"); if (dbp == NULL) if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) AbortNode(state, "Failed to write block"); if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); - //pindex->nStatus |= BLOCK_IN_TMPFILE; + if ( usetmp != 0 ) + pindex->nStatus |= BLOCK_IN_TMPFILE; } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); } From 03130a6856f234f17f98465e8ebeaa166db7debb Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Fri, 25 Jan 2019 01:52:24 +0300 Subject: [PATCH 1469/3904] OUR asset --- src/assetchains.json | 18 +++++++++++++++++- src/assetchains.old | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 1b23bc616..2775f5db3 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -224,5 +224,21 @@ "addnode": [ "37.187.225.231" ] - } + }, + { + "ac_name": "OUR", + "ac_reward": "1478310502", + "ac_halving": "525600", + "ac_cc": "42", + "ac_supply": "100000000", + "ac_perc": "77700", + "ac_staked": "93", + "ac_pubkey": "02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c", + "ac_public": "1", + "addnode": [ + "51.255.195.65", + "217.182.129.38", + "37.187.225.231" + ] + } ] diff --git a/src/assetchains.old b/src/assetchains.old index 136f7c709..cd4d194d3 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -46,3 +46,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=DION -ac_supply=3900000000 -ac_reward=22260000000 -ac_staked=100 -ac_cc=1 -ac_end=4300000000 -addnode=51.75.124.34 & ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & +./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 From 9bc086de8ee930cc70879651c364245c5b2e51ba Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Fri, 25 Jan 2019 01:52:45 +0300 Subject: [PATCH 1470/3904] OUR asset --- src/ac/our | 2 ++ src/fiat/our | 2 ++ 2 files changed, 4 insertions(+) create mode 100755 src/ac/our create mode 100755 src/fiat/our diff --git a/src/ac/our b/src/ac/our new file mode 100755 index 000000000..66c774476 --- /dev/null +++ b/src/ac/our @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/our b/src/fiat/our new file mode 100755 index 000000000..66c774476 --- /dev/null +++ b/src/fiat/our @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6 From ebf84f3055b8db8f6be4e0903dd1a4a796a47931 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Fri, 25 Jan 2019 01:54:33 +0300 Subject: [PATCH 1471/3904] OUR asset --- src/assetchains.old | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index cd4d194d3..41cbbdae1 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -46,4 +46,5 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=DION -ac_supply=3900000000 -ac_reward=22260000000 -ac_staked=100 -ac_cc=1 -ac_end=4300000000 -addnode=51.75.124.34 & ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & -./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 +./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & + From b984401e96ff970fb9c82bbf83c13e6da8aaa64c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:18:00 +0800 Subject: [PATCH 1472/3904] add ca333's Makefile, change depend to hardcoded berkely DB in depnds folder. Add exception for COINABSE_MATURITY =1 for all LABS chains. --- src/cc/Makefile | 13 +++++++------ src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 2 +- src/wallet/db.h | 2 +- zcutil/build.sh | 6 +++--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index a3c54d81d..f283f5865 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -1,17 +1,18 @@ SHELL = /bin/sh -CC = gcc +CC = gcc CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib +CFLAGS = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) OS := $(shell uname -s) $(info $(OS)) -TARGET = ../cclib.so -TARGET_WIN = ../cclib.dll +TARGET = ../libcc.so +TARGET_DARWIN = ../libcc.dylib +TARGET_WIN = ../libcc.dll SOURCES = cclib.cpp #HEADERS = $(shell echo ../cryptoconditions/include/*.h) @@ -20,7 +21,7 @@ all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib to src/) ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) $(SOURCES) else ifeq ($(OS),Linux) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a8af824d1..5fa5a3a6b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1288,7 +1288,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height < 100) ) return(target); sum = arith_uint256(0); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6ff7dd96e..4a821a5a6 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2055,7 +2055,7 @@ void komodo_args(char *argv0) if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1); - if (ASSETCHAINS_LASTERA == 0) + if (ASSETCHAINS_LASTERA == 0 || is_STAKED(ASSETCHAINS_SYMBOL) != 0) COINBASE_MATURITY = 1; //fprintf(stderr,"ASSETCHAINS_RPCPORT (%s) %u\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_RPCPORT); } diff --git a/src/wallet/db.h b/src/wallet/db.h index 19b9b6079..f7854fe2f 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -33,7 +33,7 @@ #include -#include +#include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" extern unsigned int nWalletDBUpdated; diff --git a/zcutil/build.sh b/zcutil/build.sh index 68239e16e..070c669fa 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,6 +101,9 @@ eval "$MAKE" --version as --version ld -v +HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 +./autogen.sh + #BUILD CCLIB WD=$PWD @@ -116,8 +119,5 @@ fi cd $WD -HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 -./autogen.sh - CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' "$MAKE" "$@" V=1 From 73e71d5e4e2b0b479fe2c27f2e2f57d1e690f4fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:42:50 +0800 Subject: [PATCH 1473/3904] fix --- zcutil/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zcutil/build.sh b/zcutil/build.sh index 070c669fa..5870f127a 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,6 +101,8 @@ eval "$MAKE" --version as --version ld -v +../src/cc/makecclib + HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh From 63eda9498a8d6f03e57ba0bc5d7fc314aeb0e74f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:50:15 +0800 Subject: [PATCH 1474/3904] test fix --- src/cc/Makefile | 34 ---------------------------------- zcutil/build.sh | 19 +++---------------- 2 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 src/cc/Makefile diff --git a/src/cc/Makefile b/src/cc/Makefile deleted file mode 100644 index f283f5865..000000000 --- a/src/cc/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -SHELL = /bin/sh -CC = gcc -CC_DARWIN = g++-6 -CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib -CFLAGS = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -DEBUGFLAGS = -O0 -D _DEBUG -RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program -$(info $(OS)) -OS := $(shell uname -s) -$(info $(OS)) -TARGET = ../libcc.so -TARGET_DARWIN = ../libcc.dylib -TARGET_WIN = ../libcc.dll -SOURCES = cclib.cpp -#HEADERS = $(shell echo ../cryptoconditions/include/*.h) - -all: $(TARGET) - -$(TARGET): $(SOURCES) - $(info Building cclib to src/) -ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) $(SOURCES) -else ifeq ($(OS),Linux) - $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) -#else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host -else - $(info WINDOWS) - $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) -endif - -clean: - rm -rf $(TARGET) diff --git a/zcutil/build.sh b/zcutil/build.sh index 5870f127a..131f67d0f 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,25 +101,12 @@ eval "$MAKE" --version as --version ld -v -../src/cc/makecclib +#BUILD CCLIB +cd src/cc/ +./makecclib HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh -#BUILD CCLIB - -WD=$PWD -cd src/cc -echo $PWD - -if make "$@"; then - echo CCLIB BUILD SUCCESSFUL -else - echo CCLIB BUILD FAILED - exit 1 -fi - -cd $WD - CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' "$MAKE" "$@" V=1 From fd1de72c60fd6feab14e98ad18c1f9c197511731 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:54:27 +0800 Subject: [PATCH 1475/3904] fixed --- zcutil/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index 131f67d0f..cd96e8890 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,12 +101,12 @@ eval "$MAKE" --version as --version ld -v -#BUILD CCLIB -cd src/cc/ -./makecclib - HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' +#BUILD CCLIB +cd src/cc/ +./makecclib +cd ../../ "$MAKE" "$@" V=1 From 4bda6bcac48d2b720b9687ce1689d11d14fced12 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 19:14:22 +0800 Subject: [PATCH 1476/3904] Change is_STAKED so that chains with a BR are 1 and chains with none are 2. Chains that are 255 are banned, and no notarisations can happen. --- src/komodo.h | 2 +- src/notaries_staked.cpp | 9 ++++----- src/notarisationdb.cpp | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0cf395c51..702de9d67 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -864,7 +864,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; i Date: Fri, 25 Jan 2019 00:57:40 -1100 Subject: [PATCH 1477/3904] Init nonz --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 289a84d7c..3701f5257 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1654,7 +1654,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); memset(ccenables,0,sizeof(ccenables)); memset(disablebits,0,sizeof(disablebits)); From d5b76cee9ddb66f846d01c59ac61e8bb9fa97636 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 19:59:42 +0800 Subject: [PATCH 1478/3904] try fix extralen bug. Add is_STAKED == 2 to have a consensus block reward of 0. --- src/komodo_bitcoind.h | 4 ++++ src/komodo_utils.h | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5fa5a3a6b..cd3ed6bc5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1165,6 +1165,10 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); uint64_t komodo_commission(const CBlock *pblock,int32_t height) { + // LABS fungible chains, cannot have any block reward! + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) + return(0); + int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4a821a5a6..fb236ab24 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1569,6 +1569,9 @@ int64_t komodo_max_money() uint64_t komodo_ac_block_subsidy(int nHeight) { + // LABS fungible chains, cannot have any block reward! + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) + return(0); // we have to find our era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; @@ -1655,7 +1658,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz = 0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_STAKED_NOTARY = GetArg("-stakednotary", -1); if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) { From 9dda24f9134a506c55cffb113ba4935be70f05f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 01:23:36 -1100 Subject: [PATCH 1479/3904] set nonz = 0 --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 289a84d7c..3701f5257 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1654,7 +1654,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); memset(ccenables,0,sizeof(ccenables)); memset(disablebits,0,sizeof(disablebits)); From 2246cd0c550c16ad7d6dab4a7ae57aa97b38fec2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 01:24:05 -1100 Subject: [PATCH 1480/3904] Nonz = 0 --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 289a84d7c..3701f5257 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1654,7 +1654,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); memset(ccenables,0,sizeof(ccenables)); memset(disablebits,0,sizeof(disablebits)); From a268218d115e53f0c8453a42fb3d17e3e6dee8e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 01:24:33 -1100 Subject: [PATCH 1481/3904] Nonz = 0 --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 289a84d7c..3701f5257 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1654,7 +1654,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); memset(ccenables,0,sizeof(ccenables)); memset(disablebits,0,sizeof(disablebits)); From 07a05ccd6b65afcf01e4683d06996e599a9864e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 01:27:55 -1100 Subject: [PATCH 1482/3904] -print --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 4d84b1cd2..c86ee9bfa 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -686,7 +686,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; pindexNew->nSaplingValue = diskindex.nSaplingValue; -fprintf(stderr,"loadguts ht.%d\n",pindexNew->GetHeight()); +//fprintf(stderr,"loadguts ht.%d\n",pindexNew->GetHeight()); // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From ef567651e34f3fca52fe1758967a649dfa597b9d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 20:51:57 +0800 Subject: [PATCH 1483/3904] fix block1 to allow an ac_aupply. --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fb236ab24..d9e1a7982 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1569,9 +1569,6 @@ int64_t komodo_max_money() uint64_t komodo_ac_block_subsidy(int nHeight) { - // LABS fungible chains, cannot have any block reward! - if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) - return(0); // we have to find our era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; @@ -1650,6 +1647,9 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } + else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) + return(0); + // LABS fungible chains, cannot have any block reward! return(subsidy); } From e9bd3e1d679f7124687c6b9b2b56cc568d6dbd91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 23:44:04 +0800 Subject: [PATCH 1484/3904] try change version --- src/komodo_bitcoind.h | 2 +- src/version.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index cd3ed6bc5..8760ef441 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1292,7 +1292,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height < 100) ) + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); sum = arith_uint256(0); diff --git a/src/version.h b/src/version.h index 09944cdf1..4056f105d 100644 --- a/src/version.h +++ b/src/version.h @@ -24,7 +24,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170007; +static const int PROTOCOL_VERSION = 170008; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -33,8 +33,8 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170002; -static const int STAKEDMIN_PEER_PROTO_VERSION = 170006; +static const int MIN_PEER_PROTO_VERSION = 170007; +static const int STAKEDMIN_PEER_PROTO_VERSION = 170007; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 2bff24cffec9fb47f213f3dc6a8aa7ca8424c3fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 00:58:17 +0800 Subject: [PATCH 1485/3904] fix LABST is not staked = 2. Will stop having any block reward. --- src/notaries_staked.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 5e52a0db1..9dcba0653 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -12,9 +12,11 @@ extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; + if ( chain_name[0] == 0 ) + return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "PAYME") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "PAYME") == 0) || (strcmp(chain_name, "LABST") == 0) ) STAKED = 1; else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; From 0875e0ecf1471384b88b761639c898466e274e0e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 02:52:54 +0800 Subject: [PATCH 1486/3904] fix setgenerate false --- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8760ef441..8a515507e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2211,8 +2211,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; iGetHeight()+1 > nHeight ) { fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); diff --git a/src/miner.cpp b/src/miner.cpp index d8b4e7a80..9a70fc113 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -535,6 +535,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Block Arrived, reset staking loop.\n"); return(0); } + if( !GetBoolArg("-gen",false ) + return(0); } } @@ -1563,6 +1565,13 @@ void static BitcoinMiner() #endif if ( ptr == 0 ) { + if ( !GetBoolArg("-gen",false)) + { + miningTimer.stop(); + c.disconnect(); + LogPrintf("KomodoMiner terminated\n"); + return; + } static uint32_t counter; if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 ) fprintf(stderr,"created illegal blockB, retry\n"); From 5131e12bd75bd10a26daf572b25cd866e26ec9b9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 03:00:57 +0800 Subject: [PATCH 1487/3904] sorrry --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9a70fc113..0aede35bb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -535,7 +535,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Block Arrived, reset staking loop.\n"); return(0); } - if( !GetBoolArg("-gen",false ) + if( !GetBoolArg("-gen",false) ) return(0); } } From a6e7da55e27cfac3bfb2f6f77c7109717cd9043d Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Sat, 26 Jan 2019 03:09:54 +0300 Subject: [PATCH 1488/3904] fix gcc-8 / g++-8 build --- src/chain.h | 2 +- src/consensus/params.h | 4 ++-- src/crypto/verus_hash.h | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chain.h b/src/chain.h index 0b6e2b046..d5310e4e5 100644 --- a/src/chain.h +++ b/src/chain.h @@ -335,7 +335,7 @@ public: nSolution = block.nSolution; } - int32_t SetHeight(int32_t height) + void SetHeight(int32_t height) { this->chainPower.nHeight = height; } diff --git a/src/consensus/params.h b/src/consensus/params.h index b7dc8b475..0ea5b1fff 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -115,8 +115,8 @@ struct Params { int64_t AveragingWindowTimespan() const { return nPowAveragingWindow * nPowTargetSpacing; } int64_t MinActualTimespan() const { return (AveragingWindowTimespan() * (100 - nPowMaxAdjustUp )) / 100; } int64_t MaxActualTimespan() const { return (AveragingWindowTimespan() * (100 + nPowMaxAdjustDown)) / 100; } - int32_t SetSaplingHeight(int32_t height) { vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height; } - int32_t SetOverwinterHeight(int32_t height) { vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = height; } + void SetSaplingHeight(int32_t height) { vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height; } + void SetOverwinterHeight(int32_t height) { vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = height; } uint256 nMinimumChainWork; }; } // namespace Consensus diff --git a/src/crypto/verus_hash.h b/src/crypto/verus_hash.h index 5ac49c209..2f1f2cd26 100644 --- a/src/crypto/verus_hash.h +++ b/src/crypto/verus_hash.h @@ -86,6 +86,7 @@ class CVerusHashV2 result = buf2; curPos = 0; std::fill(buf1, buf1 + sizeof(buf1), 0); + return *this; } int64_t *ExtraI64Ptr() { return (int64_t *)(curBuf + 32); } From 52cfb02f408de11c81a59bb1e0976e299491e2e0 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Sat, 26 Jan 2019 04:21:55 +0300 Subject: [PATCH 1489/3904] komodo_activate_sapling return value fix --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3d2f19b55..84f1b611a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3839,7 +3839,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { int32_t komodo_activate_sapling(CBlockIndex *pindex) { - uint32_t blocktime,prevtime; CBlockIndex *prev; int32_t i,transition=0,height,prevht,activation = 0; + uint32_t blocktime,prevtime; CBlockIndex *prev; int32_t i,transition=0,height,prevht; + int32_t activation = 0; if ( pindex == 0 ) { fprintf(stderr,"komodo_activate_sapling null pindex\n"); @@ -3897,6 +3898,7 @@ int32_t komodo_activate_sapling(CBlockIndex *pindex) fprintf(stderr,"%s sapling activation at %d\n",ASSETCHAINS_SYMBOL,activation); ASSETCHAINS_SAPLING = activation; } + return activation; } static int64_t nTimeReadFromDisk = 0; From 524342f7ba685dad74d2c4388c548b8680bfafb2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 16:43:57 -1100 Subject: [PATCH 1490/3904] Single #define _MAX_BLOCK_SIZE to set max block size --- src/chainparams.cpp | 2 +- src/net.h | 3 ++- src/util.h | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c7232761b..d01b9af1a 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -229,7 +229,7 @@ int32_t MAX_BLOCK_SIZE(int32_t height) // make sure to change MAX_PROTOCOL_MESSA { //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); if ( height <= 0 || (mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight > 0 && height >= mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) ) - return(4096 * 1024); + return(_MAX_BLOCK_SIZE); else return(2000000); } diff --git a/src/net.h b/src/net.h index 3f30175c3..ff47737d8 100644 --- a/src/net.h +++ b/src/net.h @@ -33,6 +33,7 @@ #include "sync.h" #include "uint256.h" #include "utilstrencodings.h" +#include "util.h" #include #include @@ -63,7 +64,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; // depends on MAX_BLOCK_SIZE +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = _MAX_BLOCK_SIZE; /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ diff --git a/src/util.h b/src/util.h index bd1a2542a..dc421092a 100644 --- a/src/util.h +++ b/src/util.h @@ -3,6 +3,21 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + /** * Server/client environment: argument handling, config file parsing, * logging, thread wrappers @@ -29,6 +44,8 @@ #include #include +#define _MAX_BLOCK_SIZE (4096 * 1024) // changing just _MAX_BLOCK_SIZE will hardfork to that size + static const bool DEFAULT_LOGTIMEMICROS = false; static const bool DEFAULT_LOGIPS = false; static const bool DEFAULT_LOGTIMESTAMPS = true; From 91f213c4b8209d5a91bee592ea97ff883c4fe83d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 16:54:42 -1100 Subject: [PATCH 1491/3904] +// --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 344224902..8c652350e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5220,7 +5220,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C AbortNode(state, "Failed to write block"); if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); - if ( usetmp != 0 ) + if ( usetmp != 0 ) // not during initialdownload or if futureflag==0 and contextchecks ok pindex->nStatus |= BLOCK_IN_TMPFILE; } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); From 352c93f2c4d58fd6bcb245fab1b3db67fd82868c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 16:59:55 -1100 Subject: [PATCH 1492/3904] -<<<<< HEAD --- src/net.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/net.h b/src/net.h index b3df42df7..ff47737d8 100644 --- a/src/net.h +++ b/src/net.h @@ -64,11 +64,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -<<<<<<< HEAD static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = _MAX_BLOCK_SIZE; -======= -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; ->>>>>>> origin/FSM /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From 932b3582437021f3c52c101f2d72f406dca0bc36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Jan 2019 17:15:56 -1100 Subject: [PATCH 1493/3904] +comments how to update to 8MB blocks --- src/chainparams.cpp | 25 +++++++++++++++++++++++-- src/net.h | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d01b9af1a..5c9efb276 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -225,11 +225,32 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat CChainParams::checkpointData = checkpointData; } -int32_t MAX_BLOCK_SIZE(int32_t height) // make sure to change MAX_PROTOCOL_MESSAGE_LENGTH also!!!! +/* + To change the max block size, all that needs to be updated is the #define _MAX_BLOCK_SIZE in utils.h + + However, doing that without any other changes will allow forking non-updated nodes by creating a larger block. So, make sure to height activate the new blocksize properly. + + Assuming it is 8MB, then: + #define _OLD_MAX_BLOCK_SIZE (4096 * 1024) + #define _MAX_BLOCK_SIZE (2 * 4096 * 1024) + + change the body of if: + { + if ( height < saplinght+1000000 ) // activates 8MB blocks 1 million blocks after saplinght + return(_OLD_MAX_BLOCK_SIZE); + else return(_MAX_BLOCK_SIZE); + } + +*/ + +int32_t MAX_BLOCK_SIZE(int32_t height) { + int32_t saplinght = mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); - if ( height <= 0 || (mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight > 0 && height >= mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) ) + if ( height <= 0 || (saplinght > 0 && height >= saplinght) ) + { return(_MAX_BLOCK_SIZE); + } else return(2000000); } diff --git a/src/net.h b/src/net.h index ff47737d8..3e06e9831 100644 --- a/src/net.h +++ b/src/net.h @@ -64,7 +64,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = _MAX_BLOCK_SIZE; +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = (_MAX_BLOCK_SIZE + 24); // 24 is msgheader size /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From 304de9777dff5ef59e34720cec6bc18fdc79085b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 12:57:05 +0800 Subject: [PATCH 1494/3904] fix getblocktemplate for PoW while staking --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index bccb43878..6bf1397ad 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -717,7 +717,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } #ifdef ENABLE_WALLET CReserveKey reservekey(pwalletMain); - pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->GetHeight()+1,KOMODO_MAXGPUCOUNT); + pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->GetHeight()+1,KOMODO_MAXGPUCOUNT,false); #else pblocktemplate = CreateNewBlockWithKey(); #endif From 80a8414b8364d9d105d2b4f8d9c9b864392ec819 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 14:37:11 +0800 Subject: [PATCH 1495/3904] fix lock up with staker when trying to startum mine and stake. --- src/miner.cpp | 2 -- src/rpc/mining.cpp | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0aede35bb..3814abbca 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -843,8 +843,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey); - if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) - isStake = true; return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 6bf1397ad..71c5aefa4 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -717,10 +717,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } #ifdef ENABLE_WALLET CReserveKey reservekey(pwalletMain); - pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->GetHeight()+1,KOMODO_MAXGPUCOUNT,false); + LEAVE_CRITICAL_SECTION(cs_main); + pblocktemplate = CreateNewBlockWithKey(reservekey,pindexPrevNew->GetHeight()+1,KOMODO_MAXGPUCOUNT,false); #else pblocktemplate = CreateNewBlockWithKey(); #endif + ENTER_CRITICAL_SECTION(cs_main); if (!pblocktemplate) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory or no available utxo for staking"); From 17b2d1ed0627b01970eab33aaa38f76bf607c8fd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 15:00:32 +0800 Subject: [PATCH 1496/3904] Fix staking output in getgenerate --- src/rpc/mining.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 71c5aefa4..09d7bf673 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -180,7 +180,10 @@ UniValue getgenerate(const UniValue& params, bool fHelp) LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("staking", VERUS_MINTBLOCKS)); + bool staking = VERUS_MINTBLOCKS; + if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 ) + staking = true; + obj.push_back(Pair("staking", staking)); obj.push_back(Pair("generate", GetBoolArg("-gen", false))); obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS)); return obj; From 9bf744ef26182d553c924bb8c6e968167735a0db Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 15:08:00 +0800 Subject: [PATCH 1497/3904] fix getgenerate better --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 09d7bf673..c1d45c6e7 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -184,7 +184,7 @@ UniValue getgenerate(const UniValue& params, bool fHelp) if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 ) staking = true; obj.push_back(Pair("staking", staking)); - obj.push_back(Pair("generate", GetBoolArg("-gen", false))); + obj.push_back(Pair("generate", GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) != 0 )); obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS)); return obj; } From 6d17cb5decebe65e1abb93827f71f7b9bf7b5c5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 16:00:03 +0800 Subject: [PATCH 1498/3904] oopps --- src/txdb.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index f36989028..b798599b7 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -689,15 +689,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; pindexNew->nSaplingValue = diskindex.nSaplingValue; -<<<<<<< HEAD - pindexNew->segid = diskindex.segid; - pindexNew->newcoins = diskindex.newcoins; - pindexNew->zfunds = diskindex.zfunds; - pindexNew->sproutfunds = diskindex.sproutfunds; - -======= //fprintf(stderr,"loadguts ht.%d\n",pindexNew->GetHeight()); ->>>>>>> b778dbef8e85f3f95e36223beb41d4d51eb6072e // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From 83387a82d3305aea9f761aef14dd89b3086cf28a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 16:32:56 +0800 Subject: [PATCH 1499/3904] wtf --- src/cc/Makefile | 2 +- zcutil/build.sh | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 92fbe0da9..2ba37ccb0 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -3,7 +3,7 @@ CC = gcc CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib -CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I../../depends/x86_64-unknown-linux-gnu/include -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program diff --git a/zcutil/build.sh b/zcutil/build.sh index cd96e8890..a70c97f63 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -42,21 +42,16 @@ if [ "x$*" = 'x--help' ] then cat < Date: Sat, 26 Jan 2019 13:08:29 +0100 Subject: [PATCH 1500/3904] add linux headers --- src/cc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 92fbe0da9..52db18fca 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -3,7 +3,7 @@ CC = gcc CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib -CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program From 18f8c77197aa9ba57fa6a62a16da11a392fa0c56 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 26 Jan 2019 13:09:27 +0100 Subject: [PATCH 1501/3904] update linux makefile --- zcutil/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index 68239e16e..dc312c8e8 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,6 +101,9 @@ eval "$MAKE" --version as --version ld -v + +HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 + #BUILD CCLIB WD=$PWD @@ -116,8 +119,6 @@ fi cd $WD -HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh - CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' "$MAKE" "$@" V=1 From 4b6b2a5540f0b4ac93b5322c45396c7e4908e113 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 26 Jan 2019 18:31:46 +0500 Subject: [PATCH 1502/3904] 'throw' changed to 'return result' on incorrect params tx hex name = 'hex' heirlist returns simple txid array now --- src/cc/heir.cpp | 16 ++++------- src/wallet/rpcwallet.cpp | 57 +++++++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index d00cab795..0e1c7d177 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -657,13 +657,7 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std int64_t markerfee = 10000; //std::cerr << "HeirFund() amount=" << amount << " txfee=" << txfee << " heirPubkey IsValid()=" << heirPubkey.IsValid() << " inactivityTime(sec)=" << inactivityTimeSec << " tokenid=" << tokenid.GetHex() << std::endl; - - if (!heirPubkey.IsValid()) { - std::cerr << "HeirFund() heirPubkey is not valid!" << std::endl; - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "invalid heir pubkey")); - } - + CPubKey myPubkey = pubkey2pk(Mypubkey()); if (AddNormalinputs(mtx, myPubkey, markerfee, 3) > 0) { @@ -714,7 +708,7 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName)); if (!rawhextx.empty()) { result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); + result.push_back(Pair("hex", rawhextx)); } else { std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; @@ -835,7 +829,7 @@ template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun))); if (!rawhextx.empty()) { - result.push_back(Pair("hextx", rawhextx)); + result.push_back(Pair("hex", rawhextx)); } else { std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; @@ -1008,7 +1002,7 @@ template UniValue _HeirClaim(uint256 fundingtxid, int64_t txfee if (!rawhextx.empty()) { result.push_back(Pair("result", "success")); - result.push_back(Pair("hextx", rawhextx)); + result.push_back(Pair("hex", rawhextx)); } else { std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl; @@ -1273,7 +1267,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) // note: if it is not Heir token funcId would be equal to 0 if (funcId == 'F') { //result.push_back(Pair("fundingtxid kind name", txid.GetHex() + std::string(" ") + (typeid(Helper) == typeid(TokenHelper) ? std::string("token") : std::string("coin")) + std::string(" ") + heirName)); - result.push_back( Pair("fundingtxid", txid.GetHex()) ); + result.push_back( txid.GetHex() ); } else { std::cerr << "HeirList() this is not the initial F transaction=" << txid.GetHex() << std::endl; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 14620aa0b..8a1dab638 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7382,30 +7382,45 @@ UniValue heirfund(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); txfee = atoll(params[0].get_str().c_str()); - if (txfee < 0) - throw runtime_error("incorrect txfee param\n"); + if (txfee < 0) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "incorrect txfee")); + return result; + } if(params.size() == 6) // tokens in satoshis: amount = atoll(params[1].get_str().c_str()); else // coins: amount = atof(params[1].get_str().c_str()) * COIN; - if( amount <= 0 ) - throw runtime_error("incorrect amount\n"); + if (amount <= 0) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "incorrect amount")); + return result; + } name = params[2].get_str(); pubkey = ParseHex(params[3].get_str().c_str()); - if( !pubkey2pk(pubkey).IsValid() ) - throw runtime_error("incorrect pubkey\n"); + if (!pubkey2pk(pubkey).IsValid()) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "incorrect pubkey")); + return result; + } inactivitytime = atoll(params[4].get_str().c_str()); - if (inactivitytime <= 0) - throw runtime_error("incorrect inactivity time param\n"); + if (inactivitytime <= 0) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "incorrect inactivity time")); + return result; + } if (params.size() == 6) { tokenid = Parseuint256((char*)params[5].get_str().c_str()); - if(tokenid == zeroid) - throw runtime_error("incorrect tokenid\n"); + if (tokenid == zeroid) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "incorrect tokenid")); + return result; + } } if( tokenid == zeroid ) @@ -7439,8 +7454,11 @@ UniValue heiradd(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); txfee = atoll(params[0].get_str().c_str()); - if (txfee < 0) - throw runtime_error("incorrect txfee param\n"); + if (txfee < 0) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "incorrect txfee")); + return result; + } fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); @@ -7450,7 +7468,7 @@ UniValue heiradd(const UniValue& params, bool fHelp) UniValue heirclaim(const UniValue& params, bool fHelp) { - UniValue result; // result(UniValue::VOBJ); + UniValue result; uint256 fundingtxid; int64_t txfee; int64_t inactivitytime; @@ -7458,7 +7476,6 @@ UniValue heirclaim(const UniValue& params, bool fHelp) std::vector pubkey; std::string name; - // do we need this? if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -7471,8 +7488,11 @@ UniValue heirclaim(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); txfee = atoll(params[0].get_str().c_str()); - if (txfee < 0) - throw runtime_error("incorrect txfee param\n"); + if (txfee < 0) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "incorrect txfee")); + return result; + } fundingtxid = Parseuint256((char*)params[2].get_str().c_str()); @@ -7483,8 +7503,9 @@ UniValue heirclaim(const UniValue& params, bool fHelp) UniValue heirinfo(const UniValue& params, bool fHelp) { uint256 fundingtxid; - if (fHelp || params.size() != 1) // or 0? + if (fHelp || params.size() != 1) throw runtime_error("heirinfo fundingtxid\n"); + // if ( ensure_CCrequirements() < 0 ) // throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -7494,7 +7515,7 @@ UniValue heirinfo(const UniValue& params, bool fHelp) UniValue heirlist(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 0) // or 0? + if (fHelp || params.size() != 0) throw runtime_error("heirlist\n"); // if ( ensure_CCrequirements() < 0 ) From 2ac92d7d6ec87469584e89d44b731bb5feb8a081 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 26 Jan 2019 19:10:46 +0500 Subject: [PATCH 1503/3904] result changed to VARR --- src/cc/heir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 0e1c7d177..a148cdc3f 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1282,7 +1282,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) UniValue HeirList() { - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VARR); result.push_back(Pair("result", "success")); struct CCcontract_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! From 9bad115496362250102962b221d40d5823b0f902 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 26 Jan 2019 20:18:00 +0500 Subject: [PATCH 1504/3904] in heirlist added list header --- src/cc/heir.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index a148cdc3f..2c4a85037 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1284,14 +1284,12 @@ UniValue HeirList() { UniValue result(UniValue::VARR); result.push_back(Pair("result", "success")); + result.push_back(Pair("name", "Heir List")); - struct CCcontract_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit! + struct CCcontract_info *cpHeir, heirC; cpHeir = CCinit(&heirC, EVAL_HEIR); - //cpTokens = CCinit(&tokenC, EVAL_TOKENS); - _HeirList(cpHeir, result); - //_HeirList(cpTokens, result); not used anymore return result; } From 82956c357a1ef0182638707789cfe1ae07986e8d Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 26 Jan 2019 20:31:48 +0500 Subject: [PATCH 1505/3904] removed heir list header - simply txid array --- src/cc/heir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 2c4a85037..5861d347a 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -1283,8 +1283,8 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) UniValue HeirList() { UniValue result(UniValue::VARR); - result.push_back(Pair("result", "success")); - result.push_back(Pair("name", "Heir List")); + //result.push_back(Pair("result", "success")); + //result.push_back(Pair("name", "Heir List")); struct CCcontract_info *cpHeir, heirC; From d963a55cc85003ac41a8d4528d9a560aae5b5b59 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Sun, 27 Jan 2019 03:16:53 +0700 Subject: [PATCH 1506/3904] added valid tokens heir case --- qa/rpc-tests/cryptoconditions_heir.py | 53 ++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index 95b90b397..3aa4ee69c 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -98,7 +98,58 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): result = rpc.heirinfo(heir_fund_txid) assert_equal(result["funding available in coins"], "0.00000000") - # TODO: valid heirfund case with tokens + # creating tokens which we put to heir contract + token_hex = rpc.tokencreate("TEST", "1", "TESTING") + token_txid = self.send_and_mine(token_hex["hex"], rpc) + assert token_txid, "got token txid" + + # checking possesion over the tokens and balance + result = rpc.tokenbalance(token_txid, self.pubkey)["balance"] + assert_equal(result, 100000000) + + # valid heir case with tokens + token_heir_hex = rpc.heirfund("0", "100000000", "UNITHEIR", self.pubkey1, "10", token_txid) + token_heir_txid = self.send_and_mine(token_heir_hex["hextx"], rpc) + assert token_heir_txid, "got txid of heirfund with tokens" + + self.sync_all() + + # checking heirinfo + result = rpc.heirinfo(token_heir_txid) + assert_success(result) + assert_equal(result["fundingtxid"], token_heir_txid) + assert_equal(result["name"], "UNITHEIR") + assert_equal(result["owner"], self.pubkey) + assert_equal(result["heir"], self.pubkey1) + assert_equal(result["funding total in tokens"], "100000000") + assert_equal(result["funding available in tokens"], "100000000") + assert_equal(result["inactivity time setting, sec"], "10") + assert_equal(result["spending allowed for the heir"], "false") + + # waiting for 11 seconds to be sure that needed time passed for heir claiming + time.sleep(11) + rpc.generate(1) + self.sync_all() + result = rpc.heirinfo(token_heir_txid) + assert_equal(result["funding available in tokens"], "100000000") + assert_equal(result["spending allowed for the heir"], "true") + + # let's claim whole heir sum from second node + result = rpc1.heirclaim("0", "100000000", token_heir_txid) + assert_success(result) + + heir_tokens_claim_txid = self.send_and_mine(result["hextx"], rpc1) + assert heir_tokens_claim_txid, "got claim txid" + + # claiming node should have correct token balance now + result = rpc1.tokenbalance(token_txid, self.pubkey1)["balance"] + assert_equal(result, 100000000) + + self.sync_all() + + # no more funds should be available for claiming + result = rpc.heirinfo(token_heir_txid) + assert_equal(result["funding available in tokens"], "0") def run_test(self): print("Mining blocks...") From 45d35fb971d50307fc4aa916ab0caf8e6c05e536 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Sun, 27 Jan 2019 03:21:16 +0700 Subject: [PATCH 1507/3904] actualize comment --- qa/rpc-tests/cryptoconditions_channels.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index b2a49b477..5ba15b572 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -26,6 +26,8 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] + # TODO: check channelsaddress + # getting empty channels list result = rpc.channelslist() assert_equal(len(result), 2) @@ -143,7 +145,7 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): refund_txid = self.send_and_mine(result["hex"], rpc) assert refund_txid, "got txid" - # TODO: check if it refunded to opener address + # checking if it refunded to opener address raw_transaction = rpc.getrawtransaction(refund_txid, 1) result = raw_transaction["vout"][2]["valueSat"] From dc510cdde4ea1adcdbc624840ffc4caf9b78a7a7 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Sun, 27 Jan 2019 03:32:24 +0700 Subject: [PATCH 1508/3904] checking channelsaddress --- qa/rpc-tests/cryptoconditions_channels.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 5ba15b572..722cce66e 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -26,7 +26,13 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] - # TODO: check channelsaddress + # checking channelsaddress call + + result = rpc.channelsaddress(self.pubkey) + assert_success(result) + # test that additional CCaddress key is returned + for x in ['myCCaddress', 'ChannelsCCaddress', 'Channelsmarker', 'myaddress', 'CCaddress']: + assert_equal(result[x][0], 'R') # getting empty channels list result = rpc.channelslist() From cdb64ae0e584ffa7d6817ab87ba49e94aaf8ae48 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 27 Jan 2019 08:54:47 +0800 Subject: [PATCH 1509/3904] fix verushash staker --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 245a1b2a9..a1af2c7bf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -497,7 +497,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t stakeHeight = chainActive.Height() + 1; - //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); + //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { LEAVE_CRITICAL_SECTION(cs_main); @@ -1239,7 +1239,7 @@ void static BitcoinMiner_noeq() miningTimer.start(); #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, 0, ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From 7609e7dcd5a70f457c9d87afe3736075718bcf37 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 27 Jan 2019 09:53:23 +0800 Subject: [PATCH 1510/3904] fix assetchains founders reward --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 02ab67407..08120dc83 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -699,7 +699,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } // we don't want these checks in VRSC, leave it at the Sapling upgrade if ( ASSETCHAINS_SYMBOL[0] == 0 || - (ASSETCHAINS_COMMISSION != 0 && height > 1) || + ((ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1) || NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) ) { n = block.vtx[0].vout.size(); @@ -761,7 +761,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim else { checktoshis = 0; - if ( ASSETCHAINS_COMMISSION != 0 && height > 1 ) + if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) { From 1a70313da07dfe825005559b99593fa2ddad768d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 27 Jan 2019 13:59:50 +0800 Subject: [PATCH 1511/3904] fix cclib fresh clone --- zcutil/build.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index a70c97f63..eb7a37157 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -96,6 +96,11 @@ eval "$MAKE" --version as --version ld -v +HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 +./autogen.sh + +CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' + #BUILD CCLIB WD=$PWD @@ -111,8 +116,4 @@ fi cd $WD -HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 -./autogen.sh - -CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' "$MAKE" "$@" V=1 From fdcc9d71c2c6e9fe4798f1e55256ee2b58cb96db Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 27 Jan 2019 17:03:38 +0500 Subject: [PATCH 1512/3904] heirinfo var names corrected memo field added --- src/cc/CCHeir.h | 8 +- src/cc/heir.cpp | 194 +++++++++++++++++---------------------- src/cc/heir_validate.h | 24 ++--- src/wallet/rpcwallet.cpp | 18 ++-- 4 files changed, 108 insertions(+), 136 deletions(-) diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index 30334f6e1..2943d747c 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -27,15 +27,11 @@ bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, class CoinHelper; class TokenHelper; -UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); -UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid); +UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo); +UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo, uint256 tokenid); UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string amount); UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string amount); - UniValue HeirInfo(uint256 fundingtxid); UniValue HeirList(); -//std::string Heir_MakeBadTx(uint256 fundingtxid, uint8_t funcId, int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTime, uint32_t errMask); - -//bool HeirExactTokenAmounts(bool compareTotals, struct CCcontract_info *cpHeir, Eval* eval, uint256 assetid, const CTransaction &tx); #endif diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 5861d347a..8e7f3f08b 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -255,11 +255,11 @@ template int64_t IsHeirFundingVout(struct CCcontract_info* cp, co } // makes coin initial tx opret -CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) +CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo) { uint8_t evalcode = EVAL_HEIR; - return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName); + return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName << memo); } // makes coin additional tx opret @@ -273,7 +273,7 @@ CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpe // decode opret vout for Heir contract -uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) +uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { uint8_t evalCodeInOpret = 0; uint8_t heirFuncId = 0; @@ -287,13 +287,13 @@ uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPub uint8_t heirFuncId = 0; hasHeirSpendingBegun = 0; - bool result = E_UNMARSHAL(vopret, { ss >> evalCodeInOpret; ss >> heirFuncId; \ - if (heirFuncId == 'F') { \ - ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; \ - } \ - else { \ - ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ - } \ + bool result = E_UNMARSHAL(vopret, { ss >> evalCodeInOpret; ss >> heirFuncId; \ + if (heirFuncId == 'F') { \ + ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; ss >> memo; \ + } \ + else { \ + ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ + } \ }); if (!result) { @@ -322,84 +322,49 @@ uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPub return (uint8_t)0; } -/* not used, see DecodeHeirOpRet(vopret,...) - // overload for 'F' opret - uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) - { - uint256 dummytxid; - uint8_t dummyHasHeirSpendingBegun; - std::vector vopret; - - GetOpReturnData(scriptPubKey, vopret); - if (vopret.size() == 0) { - if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; - return (uint8_t)0; - } - return _DecodeHeirOpRet(vopret, ownerPubkey, heirPubkey, inactivityTime, heirName, dummytxid, dummyHasHeirSpendingBegun, noLogging); - }*/ - - -/* not used, see DecodeHeirOpRet(vopret,...) - // overload for A, C oprets and AddHeirContractInputs - uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) - { - CPubKey dummyOwnerPubkey, dummyHeirPubkey; - int64_t dummyInactivityTime; - std::string dummyHeirName; - std::vector vopret; - - GetOpReturnData(scriptPubKey, vopret); - if (vopret.size() == 0) { - if (!noLogging) std::cerr << "DecodeHeirOpRet() warning: empty opret" << std::endl; - return (uint8_t)0; - } - - return _DecodeHeirOpRet(vopret, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingtxidInOpret, hasHeirSpendingBegun, noLogging); - } */ - // decode combined opret: -uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) +uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { - uint8_t evalCodeTokens = 0; - std::vector voutPubkeysDummy; - std::vector vopretExtra, vopretStripped; - - if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { - if (vopretExtra.size() > 1) { - // restore the second opret: - - if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size - if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; - return (uint8_t)0; - } - } - else { - if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl; - return (uint8_t)0; - } - } - else - GetOpReturnData(scriptPubKey, vopretStripped); - - return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); + uint8_t evalCodeTokens = 0; + std::vector voutPubkeysDummy; + std::vector vopretExtra, vopretStripped; + + if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { + if (vopretExtra.size() > 1) { + // restore the second opret: + + if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size + if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; + return (uint8_t)0; + } + } + else { + if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl; + return (uint8_t)0; + } + } + else { + GetOpReturnData(scriptPubKey, vopretStripped); + } + return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } // overload to decode opret in fundingtxid: -uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging) { +uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, bool noLogging) { uint256 dummyFundingTxidInOpret; uint8_t dummyHasHeirSpendingBegun; - return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, dummyFundingTxidInOpret, dummyHasHeirSpendingBegun, noLogging); + return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, dummyFundingTxidInOpret, dummyHasHeirSpendingBegun, noLogging); } // overload to decode opret in A and C heir tx: uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { CPubKey dummyOwnerPubkey, dummyHeirPubkey; int64_t dummyInactivityTime; - std::string dummyHeirName; + std::string dummyHeirName, dummyMemo; - return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); + return _DecodeHeirEitherOpRet(scriptPubKey, tokenid, dummyOwnerPubkey, dummyHeirPubkey, dummyInactivityTime, dummyHeirName, dummyMemo, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } // check if pubkey is in vins @@ -423,7 +388,7 @@ void CheckVinPubkey(std::vector vins, CPubKey pubkey, bool &hasPubkey, bo * find the latest funding tx: it may be the first F tx or one of A or C tx's * Note: this function is also called from validation code (use non-locking calls) */ -uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, CScript& fundingOpretScript, uint8_t &hasHeirSpendingBegun) +uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, CScript& fundingOpretScript, uint8_t &hasHeirSpendingBegun) { CTransaction fundingtx; uint256 hashBlock; @@ -440,7 +405,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { CScript heirScript = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); - uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, true); if (funcId != 0) { // found at least funding tx! //std::cerr << "FindLatestFundingTx() lasttx currently is fundingtx, txid=" << fundingtxid.GetHex() << " opreturn type=" << (char)funcId << '\n'; @@ -522,17 +487,17 @@ uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRe CPubKey ownerPubkey; CPubKey heirPubkey; int64_t inactivityTime; - std::string heirName; + std::string heirName, memo; - return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, opRetScript, hasHeirSpendingBegun); } // overload for transaction creation code -uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, uint8_t &hasHeirSpendingBegun) +uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, uint8_t &hasHeirSpendingBegun) { CScript opRetScript; - return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, opRetScript, hasHeirSpendingBegun); + return _FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, opRetScript, hasHeirSpendingBegun); } // add inputs of 1 of 2 cc address @@ -561,7 +526,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, // no need to prevent dup // dimxy: maybe it is good to put tx's in cache? - std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl; + //std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl; if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { uint256 tokenid; @@ -644,7 +609,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info * and also for setting spending plan for the funds' owner and heir * @return fundingtxid handle for subsequent references to this heir funding plan */ -template UniValue _HeirFund(int64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) +template UniValue _HeirFund(int64_t txfee, int64_t amount, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo, uint256 tokenid) { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -705,7 +670,7 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std // add change for txfee and opreturn vouts and sign tx: std::string rawhextx = FinalizeCCTx(0, cp, mtx, myPubkey, txfee, - Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName)); + Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName, memo)); if (!rawhextx.empty()) { result.push_back(Pair("result", "success")); result.push_back(Pair("hex", rawhextx)); @@ -731,12 +696,12 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std } // if no these callers - it could not link -UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid){ - return _HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); +UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo){ + return _HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, memo, zeroid); } -UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, uint256 tokenid) { - return _HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, tokenid); +UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo, uint256 tokenid) { + return _HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, memo, tokenid); } /** @@ -744,7 +709,7 @@ UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirNa * creates tx to add more funds to cryptocondition address for spending by either funds' owner or heir * @return result object with raw tx or error text */ -template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) +template UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, uint8_t hasHeirSpendingBegun) { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -862,10 +827,10 @@ UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string strAmount uint256 latesttxid, tokenid = zeroid; uint8_t funcId; - std::string heirName; + std::string heirName, memo; uint8_t hasHeirSpendingBegun = 0; - if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo, hasHeirSpendingBegun)) != zeroid) { if (tokenid == zeroid) { int64_t amount = (int64_t)(atof(strAmount.c_str()) * COIN); if (amount <= 0) { @@ -874,8 +839,7 @@ UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string strAmount result.push_back(Pair("error", "invalid amount")); return result; } - - return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, hasHeirSpendingBegun); } else { int64_t amount = atoll(strAmount.c_str()); @@ -885,7 +849,7 @@ UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string strAmount result.push_back(Pair("error", "invalid amount")); return result; } - return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + return _HeirAdd(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, hasHeirSpendingBegun); } } else { @@ -904,7 +868,7 @@ UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string strAmount * creates tx to spend funds from cryptocondition address by either funds' owner or heir * @return result object with raw tx or error text */ -template UniValue _HeirClaim(uint256 fundingtxid, int64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, uint8_t hasHeirSpendingBegun) +template UniValue _HeirClaim(uint256 fundingtxid, int64_t txfee, int64_t amount, uint256 latesttxid, uint8_t funcId, uint256 tokenid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, uint8_t hasHeirSpendingBegun) { UniValue result(UniValue::VOBJ); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -1032,10 +996,10 @@ UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string strAmou uint256 latesttxid, tokenid = zeroid; uint8_t funcId; - std::string heirName; + std::string heirName, memo; uint8_t hasHeirSpendingBegun = 0; - if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun)) != zeroid) { + if ((latesttxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo, hasHeirSpendingBegun)) != zeroid) { if (tokenid == zeroid) { int64_t amount = (int64_t)(atof(strAmount.c_str()) * COIN); if (amount < 0) { @@ -1044,7 +1008,7 @@ UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string strAmou result.push_back(Pair("error", "invalid amount")); return result; } - return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, hasHeirSpendingBegun); } else { int64_t amount = atoll(strAmount.c_str()); @@ -1054,7 +1018,7 @@ UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string strAmou result.push_back(Pair("error", "invalid amount")); return result; } - return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + return _HeirClaim(fundingtxid, txfee, amount, latesttxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, hasHeirSpendingBegun); } } @@ -1093,7 +1057,7 @@ UniValue HeirInfo(uint256 fundingtxid) CPubKey ownerPubkey, heirPubkey; uint256 dummyTokenid, tokenid = zeroid; // important to clear tokenid - std::string heirName; + std::string heirName, memo; int64_t inactivityTimeSec; const bool noLogging = false; uint8_t funcId; @@ -1112,7 +1076,7 @@ UniValue HeirInfo(uint256 fundingtxid) uint8_t hasHeirSpendingBegun = 0; - uint256 latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, hasHeirSpendingBegun); + uint256 latestFundingTxid = FindLatestFundingTx(fundingtxid, funcId, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo, hasHeirSpendingBegun); if (latestFundingTxid != zeroid) { int32_t numblocks; @@ -1153,12 +1117,22 @@ UniValue HeirInfo(uint256 fundingtxid) else total = LifetimeHeirContractFunds(cp, fundingtxid, ownerPubkey, heirPubkey); + msg = "type"; + if (tokenid == zeroid) { + stream << "coins"; + } + else { + stream << "tokens"; + } + result.push_back(Pair(msg, stream.str().c_str())); + stream.str(""); + stream.clear(); + + msg = "lifetime"; if (tokenid == zeroid) { - msg = "funding total in coins"; stream << std::fixed << std::setprecision(8) << (double)total / COIN; } else { - msg = "funding total in tokens"; stream << total; } result.push_back(Pair(msg, stream.str().c_str())); @@ -1171,12 +1145,11 @@ UniValue HeirInfo(uint256 fundingtxid) else inputs = Add1of2AddressInputs(cp, fundingtxid, mtx, ownerPubkey, heirPubkey, 0, 60); + msg = "available"; if (tokenid == zeroid) { - msg = "funding available in coins"; stream << std::fixed << std::setprecision(8) << (double)inputs / COIN; } else { - msg = "funding available in tokens"; stream << inputs; } result.push_back(Pair(msg, stream.str().c_str())); @@ -1186,14 +1159,14 @@ UniValue HeirInfo(uint256 fundingtxid) if (tokenid != zeroid) { int64_t ownerInputs = TokenHelper::addOwnerInputs(tokenid, mtx, ownerPubkey, 0, (int32_t)64); stream << ownerInputs; - msg = "owner funding available in tokens"; + msg = "OwnerRemainderTokens"; result.push_back(Pair(msg, stream.str().c_str())); stream.str(""); stream.clear(); } stream << inactivityTimeSec; - result.push_back(Pair("inactivity time setting, sec", stream.str().c_str())); + result.push_back(Pair("InactivityTimeSetting", stream.str().c_str())); stream.str(""); stream.clear(); @@ -1203,18 +1176,20 @@ UniValue HeirInfo(uint256 fundingtxid) } stream << std::boolalpha << (hasHeirSpendingBegun || durationSec > inactivityTimeSec); - result.push_back(Pair("spending allowed for the heir", stream.str().c_str())); + result.push_back(Pair("IsHeirSpendingAllowed", stream.str().c_str())); stream.str(""); stream.clear(); // adding owner current inactivity time: if (!hasHeirSpendingBegun && durationSec <= inactivityTimeSec) { stream << durationSec; - result.push_back(Pair("owner inactivity time, sec", stream.str().c_str())); + result.push_back(Pair("InactivityTime", stream.str().c_str())); stream.str(""); stream.clear(); } - + + result.push_back(Pair("memo", memo.c_str())); + result.push_back(Pair("result", "success")); } else { @@ -1256,13 +1231,13 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) CTransaction fundingtx; if (GetTransaction(txid, fundingtx, hashBlock, false)) { CPubKey ownerPubkey, heirPubkey; - std::string heirName; + std::string heirName, memo; int64_t inactivityTimeSec; const bool noLogging = true; uint256 tokenid; CScript opret = (fundingtx.vout.size() > 0) ? fundingtx.vout[fundingtx.vout.size() - 1].scriptPubKey : CScript(); - uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, true); + uint8_t funcId = DecodeHeirEitherOpRet(opret, tokenid, ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo, true); // note: if it is not Heir token funcId would be equal to 0 if (funcId == 'F') { @@ -1293,4 +1268,3 @@ UniValue HeirList() return result; } - diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index df58e3bf1..15ab133e4 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -7,13 +7,13 @@ #define IS_CHARINSTR(c, str) (std::string(str).find((char)(c)) != std::string::npos) // makes coin initial tx opret -CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName); +CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo); CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan); uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); //uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); //uint8_t DecodeHeirOpRet(CScript scriptPubKey, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); -uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, bool noLogging = false); +uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, bool noLogging = false); uint8_t DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, uint256 &fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging = false); inline static bool isMyFuncId(uint8_t funcid) { return IS_CHARINSTR(funcid, "FAC"); } @@ -28,8 +28,8 @@ public: return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); } - static CScript makeCreateOpRet(uint256 dummyid, std::vector dummyPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { - return EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName); + static CScript makeCreateOpRet(uint256 dummyid, std::vector dummyPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo) { + return EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo); } static CScript makeAddOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { return EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan); @@ -66,9 +66,9 @@ public: return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs); } - static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName) { + static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo) { return EncodeTokenOpRet(tokenid, voutTokenPubkeys, - EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName)); + EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo)); } static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { return EncodeTokenOpRet(tokenid, voutTokenPubkeys, @@ -407,10 +407,10 @@ public: //std::cerr << "CCC1of2AddressValidator::validateVout() entered" << std::endl; CPubKey ownerPubkey, heirPubkey; int64_t inactivityTime; - std::string heirName; + std::string heirName, memo; uint256 tokenid; - uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, true); if (funcId == 0) { message = m_customMessage + std::string(" invalid opreturn format"); std::cerr << "CCC1of2AddressValidator::validateVout() exits with false: " << message << std::endl; @@ -462,13 +462,13 @@ public: CPubKey ownerPubkey, heirPubkey; int64_t inactivityTime; - std::string heirName; + std::string heirName, memo; uint256 tokenid; ///std::cerr << "CMyPubkeyVoutValidator::validateVout() m_opRetScript=" << m_opRetScript.ToString() << std::endl; // get both pubkeys: - uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, true); if (funcId == 0) { message = std::string("invalid opreturn format"); return false; @@ -522,11 +522,11 @@ public: CPubKey ownerPubkey, heirPubkey; int64_t inactivityTime; - std::string heirName; + std::string heirName, memo; uint256 tokenid; // get heir pubkey: - uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, true); + uint8_t funcId = DecodeHeirEitherOpRet(m_fundingOpretScript, tokenid, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, true); if (funcId == 0) { message = std::string("invalid opreturn format"); return false; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8a1dab638..2adf931bb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7368,13 +7368,13 @@ UniValue heirfund(const UniValue& params, bool fHelp) int64_t inactivitytime; std::string hex; std::vector pubkey; - std::string name; + std::string name, memo; if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - if (fHelp || params.size() != 5 && params.size() != 6) - throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime [tokenid]\n"); + if (fHelp || params.size() != 6 && params.size() != 7) + throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime memo [tokenid]\n"); if (ensure_CCrequirements() < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -7392,7 +7392,6 @@ UniValue heirfund(const UniValue& params, bool fHelp) amount = atoll(params[1].get_str().c_str()); else // coins: amount = atof(params[1].get_str().c_str()) * COIN; - if (amount <= 0) { result.push_back(Pair("result", "error")); result.push_back(Pair("error", "incorrect amount")); @@ -7400,6 +7399,7 @@ UniValue heirfund(const UniValue& params, bool fHelp) } name = params[2].get_str(); + pubkey = ParseHex(params[3].get_str().c_str()); if (!pubkey2pk(pubkey).IsValid()) { result.push_back(Pair("result", "error")); @@ -7414,8 +7414,10 @@ UniValue heirfund(const UniValue& params, bool fHelp) return result; } - if (params.size() == 6) { - tokenid = Parseuint256((char*)params[5].get_str().c_str()); + memo = params[5].get_str(); + + if (params.size() == 7) { + tokenid = Parseuint256((char*)params[6].get_str().c_str()); if (tokenid == zeroid) { result.push_back(Pair("result", "error")); result.push_back(Pair("error", "incorrect tokenid")); @@ -7424,9 +7426,9 @@ UniValue heirfund(const UniValue& params, bool fHelp) } if( tokenid == zeroid ) - result = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, zeroid); + result = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, memo); else - result = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, tokenid); + result = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, memo, tokenid); return result; } From daf34e231501c55ce0b4009c2befd3196b71836b Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 27 Jan 2019 17:17:27 +0500 Subject: [PATCH 1513/3904] corrected rpc param size check --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2adf931bb..e111ad98a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7388,7 +7388,7 @@ UniValue heirfund(const UniValue& params, bool fHelp) return result; } - if(params.size() == 6) // tokens in satoshis: + if(params.size() == 7) // tokens in satoshis: amount = atoll(params[1].get_str().c_str()); else // coins: amount = atof(params[1].get_str().c_str()) * COIN; From 134534b3847fd0a229049b9569f0f9ae920f9f17 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 27 Jan 2019 17:56:08 +0500 Subject: [PATCH 1514/3904] var naming improved --- src/cc/CCHeir.h | 2 +- src/cc/heir.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h index 2943d747c..fa1f72263 100644 --- a/src/cc/CCHeir.h +++ b/src/cc/CCHeir.h @@ -27,7 +27,7 @@ bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, class CoinHelper; class TokenHelper; -UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo); +UniValue HeirFundCoinCaller(int64_t txfee, int64_t coins, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo); UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo, uint256 tokenid); UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string amount); UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string amount); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 8e7f3f08b..04866594d 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -696,8 +696,8 @@ template UniValue _HeirFund(int64_t txfee, int64_t amount, std } // if no these callers - it could not link -UniValue HeirFundCoinCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo){ - return _HeirFund(txfee, satoshis, heirName, heirPubkey, inactivityTimeSec, memo, zeroid); +UniValue HeirFundCoinCaller(int64_t txfee, int64_t coins, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo){ + return _HeirFund(txfee, coins, heirName, heirPubkey, inactivityTimeSec, memo, zeroid); } UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo, uint256 tokenid) { From fbd07edee2b011cb6fa62ebb09ec13d2e3ec9e05 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Jan 2019 04:51:48 -1100 Subject: [PATCH 1515/3904] Disable removeorphan --- src/komodo.h | 2 +- src/main.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 35fee05ad..d3cda4e22 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -707,7 +707,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); - if (RemoveOrphanedBlocks(*notarizedheightp)) + if ( 0 && RemoveOrphanedBlocks(*notarizedheightp)) { //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); } diff --git a/src/main.cpp b/src/main.cpp index 45989a4f1..f519cab9d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3254,6 +3254,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } + // check pindex->CONTEXT_VALIDATED flag if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019 { fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); From 6756fa3ad732d16be71499efff9c801c3e1dce70 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 27 Jan 2019 23:56:48 +0800 Subject: [PATCH 1516/3904] disable orphan purge --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 4a0a135a6..af4ea499c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -708,7 +708,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); - if (RemoveOrphanedBlocks(*notarizedheightp)) + if ( 0 && RemoveOrphanedBlocks(*notarizedheightp)) { //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); } From 7bd8f456c30bb2bcb500ea77e6687e8ce8deb3fb Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Mon, 28 Jan 2019 00:03:25 +0700 Subject: [PATCH 1517/3904] tests adjusted for heirCC json enhancement --- qa/rpc-tests/cryptoconditions_heir.py | 54 +++++++++++++-------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index 3aa4ee69c..b79ae7bba 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -34,21 +34,18 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): # getting empty heir list result = rpc.heirlist() - assert_equal(len(result), 1) - assert_success(result) + assert_equal(result, []) # valid heirfund case with coins - result = rpc.heirfund("0", "1000", "UNITHEIR", self.pubkey1, "10") + result = rpc.heirfund("0", "1000", "UNITHEIR", self.pubkey1, "10", "TESTMEMO") assert_success(result) - heir_fund_txid = self.send_and_mine(result["hextx"], rpc) + heir_fund_txid = self.send_and_mine(result["hex"], rpc) assert heir_fund_txid, "got heir funding txid" # heir fund txid should be in heirlist now result = rpc.heirlist() - assert_equal(len(result), 2) - assert_success(result) - assert_equal(result["fundingtxid"], heir_fund_txid) + assert_equal(result, [heir_fund_txid]) # checking heirinfo result = rpc.heirinfo(heir_fund_txid) @@ -57,20 +54,20 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): assert_equal(result["name"], "UNITHEIR") assert_equal(result["owner"], self.pubkey) assert_equal(result["heir"], self.pubkey1) - assert_equal(result["funding total in coins"], "1000.00000000") - assert_equal(result["funding available in coins"], "1000.00000000") - assert_equal(result["inactivity time setting, sec"], "10") - assert_equal(result["spending allowed for the heir"], "false") - - # TODO: heirlist keys are duplicating now + assert_equal(result["memo"], "TESTMEMO") + assert_equal(result["lifetime"], "1000.00000000") + assert_equal(result["type"], "coins") + assert_equal(result["InactivityTimeSetting"], "10") + assert_equal(result["InactivityTime"], "0") + assert_equal(result["IsHeirSpendingAllowed"], "false") # waiting for 11 seconds to be sure that needed time passed for heir claiming time.sleep(11) rpc.generate(1) self.sync_all() result = rpc.heirinfo(heir_fund_txid) - assert_equal(result["funding available in coins"], "1000.00000000") - assert_equal(result["spending allowed for the heir"], "true") + assert_equal(result["lifetime"], "1000.00000000") + assert_equal(result["IsHeirSpendingAllowed"], "true") # have to check that second node have coins to cover txfee at least rpc.sendtoaddress(rpc1.getnewaddress(), 1) @@ -84,7 +81,7 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): result = rpc1.heirclaim("0", "1000", heir_fund_txid) assert_success(result) - heir_claim_txid = self.send_and_mine(result["hextx"], rpc1) + heir_claim_txid = self.send_and_mine(result["hex"], rpc1) assert heir_claim_txid, "got claim txid" # balance of second node after heirclaim should increase for 1000 coins - txfees @@ -96,7 +93,8 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): # no more funds should be available for claiming result = rpc.heirinfo(heir_fund_txid) - assert_equal(result["funding available in coins"], "0.00000000") + assert_equal(result["lifetime"], "1000.00000000") + assert_equal(result["available"], "0.00000000") # creating tokens which we put to heir contract token_hex = rpc.tokencreate("TEST", "1", "TESTING") @@ -108,8 +106,8 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): assert_equal(result, 100000000) # valid heir case with tokens - token_heir_hex = rpc.heirfund("0", "100000000", "UNITHEIR", self.pubkey1, "10", token_txid) - token_heir_txid = self.send_and_mine(token_heir_hex["hextx"], rpc) + token_heir_hex = rpc.heirfund("0", "100000000", "UNITHEIR", self.pubkey1, "10", "TESTMEMO", token_txid) + token_heir_txid = self.send_and_mine(token_heir_hex["hex"], rpc) assert token_heir_txid, "got txid of heirfund with tokens" self.sync_all() @@ -121,24 +119,25 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): assert_equal(result["name"], "UNITHEIR") assert_equal(result["owner"], self.pubkey) assert_equal(result["heir"], self.pubkey1) - assert_equal(result["funding total in tokens"], "100000000") - assert_equal(result["funding available in tokens"], "100000000") - assert_equal(result["inactivity time setting, sec"], "10") - assert_equal(result["spending allowed for the heir"], "false") + assert_equal(result["lifetime"], "100000000") + assert_equal(result["type"], "tokens") + assert_equal(result["InactivityTimeSetting"], "10") + assert_equal(result["InactivityTime"], "0") + assert_equal(result["IsHeirSpendingAllowed"], "false") # waiting for 11 seconds to be sure that needed time passed for heir claiming time.sleep(11) rpc.generate(1) self.sync_all() result = rpc.heirinfo(token_heir_txid) - assert_equal(result["funding available in tokens"], "100000000") - assert_equal(result["spending allowed for the heir"], "true") + assert_equal(result["lifetime"], "100000000") + assert_equal(result["IsHeirSpendingAllowed"], "true") # let's claim whole heir sum from second node result = rpc1.heirclaim("0", "100000000", token_heir_txid) assert_success(result) - heir_tokens_claim_txid = self.send_and_mine(result["hextx"], rpc1) + heir_tokens_claim_txid = self.send_and_mine(result["hex"], rpc1) assert heir_tokens_claim_txid, "got claim txid" # claiming node should have correct token balance now @@ -149,7 +148,8 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): # no more funds should be available for claiming result = rpc.heirinfo(token_heir_txid) - assert_equal(result["funding available in tokens"], "0") + assert_equal(result["lifetime"], "100000000") + assert_equal(result["available"], "0") def run_test(self): print("Mining blocks...") From 4f212c841d09d258794c4d548288dacbedc302af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 28 Jan 2019 16:13:25 +0800 Subject: [PATCH 1518/3904] Fix floating point exception. Problem was POW target trying to calculate when not all blocks avalible. These changes leave us even more open to PoS attack, we need to get temp block file working as soon as we can. --- src/komodo_bitcoind.h | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2fe42041c..aaf560192 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1319,7 +1319,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he sum += UintToArith256(pindex->GetBlockHash()); m++; } - } + } //else fprintf(stderr, "pindex returned null ht.%i\n",ht); if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } @@ -1521,8 +1521,9 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ return(0); else return(1); } - // Get PoSperc and POW Target. for later. - POWTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); + // Get PoSperc and POW Target. slowflag only here, calling it when blocks out of order causes problems. + if ( slowflag != 0 ) + POWTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); txn_count = pblock->vtx.size(); //fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,(int32_t)pblock->vtx[txn_count-1].vin.size(),(int32_t)pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) @@ -1533,7 +1534,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ txid = pblock->vtx[txn_count-1].vin[0].prevout.hash; vout = pblock->vtx[txn_count-1].vin[0].prevout.n; - if ( prevtime != 0 ) + if ( slowflag != 0 && prevtime != 0 ) { if ( komodo_isPoS(pblock,height) != 0 ) { @@ -1543,7 +1544,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr,"komodo_is_PoSblock PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)pblock->nTime,(int32_t)(eligible - pblock->nTime)); - if ( slowflag != 0 && pindex != 0 ) + if ( pindex != 0 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); @@ -1552,23 +1553,20 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else { isPoS = 2; // 2 means staking utxo validated - if ( slowflag != 0 ) + CTxDestination voutaddress; char voutaddr[64]; + if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) { - CTxDestination voutaddress; char voutaddr[64]; - if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) - { - strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); - segid = komodo_segid32(voutaddr) & 0x3f; - } - if ( pindex != 0 && segid >= 0 ) - { - pindex->segid = segid; - //fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); - } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); + strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + segid = komodo_segid32(voutaddr) & 0x3f; } + if ( pindex != 0 && segid >= 0 ) + { + pindex->segid = segid; + //fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); + } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } - } - if ( slowflag == 0 && isPoS == 0 ) // maybe previous block is not seen yet, do the best approx + } + else if ( slowflag == 0 ) // previous blocks are not seen yet, do the best approx { if ( komodo_isPoS(pblock,height) != 0 ) isPoS = 1; @@ -1893,8 +1891,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); else { - if ( slowflag != 0 ) - bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); + bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash > bnTarget ) { for (i=31; i>=16; i--) From 59c67afa11e33705eb6aab1d3f75186f5d0aabb2 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 28 Jan 2019 13:22:29 +0100 Subject: [PATCH 1519/3904] Fixing FinalizeCCTx to return error if not possible to sign vin. --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index ae7483f4d..630a00d8f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -242,7 +242,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran if ( flag == 0 ) { fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr); - continue; + return(""); } } uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); From 463caf96ec1251afdee1939dc5359ba96e3e6bd5 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 28 Jan 2019 13:54:21 +0100 Subject: [PATCH 1520/3904] Gateways with new TokensCC (#15) - Adapting Gateways to new Tokens - Making withdraws serialized until solution for parallel is made --- src/cc/CCGateways.h | 3 +- src/cc/CCtx.cpp | 10 +- src/cc/dapps/oraclefeed.c | 184 +++----- src/cc/gateways.cpp | 970 ++++++++++++++++++++++++-------------- src/rpc/server.cpp | 4 +- src/rpc/server.h | 4 +- src/wallet/rpcwallet.cpp | 29 +- 7 files changed, 700 insertions(+), 504 deletions(-) diff --git a/src/cc/CCGateways.h b/src/cc/CCGateways.h index b629ade1f..7ecae2228 100644 --- a/src/cc/CCGateways.h +++ b/src/cc/CCGateways.h @@ -28,10 +28,9 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin std::string GatewaysPartialSign(uint64_t txfee,uint256 txidaddr,std::string refcoin,std::string hex); std::string GatewaysCompleteSigning(uint64_t txfee,uint256 txidaddr,std::string refcoin,std::string hex); std::string GatewaysMarkDone(uint64_t txfee,uint256 withdrawtxid,std::string refcoin); +UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin); UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin); UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin); -UniValue GatewaysMultisig(char *txidaddr); - // CCcustom UniValue GatewaysInfo(uint256 bindtxid); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 630a00d8f..a8d832661 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -390,9 +390,9 @@ int64_t CCfullsupply(uint256 tokenid) return(0); } -int64_t CCtoken_balance(char *coinaddr,uint256 tokenid) +int64_t CCtoken_balance(char *coinaddr,uint256 reftokenid) { - int64_t price,sum = 0; int32_t numvouts; CTransaction tx; uint256 assetid,assetid2,txid,hashBlock; + int64_t price,sum = 0; int32_t numvouts; CTransaction tx; uint256 tokenid,txid,hashBlock; std::vector vopretExtra; std::vector > unspentOutputs; uint8_t evalCode; @@ -401,11 +401,11 @@ int64_t CCtoken_balance(char *coinaddr,uint256 tokenid) for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) { - char str[65]; fprintf(stderr,"check %s %.8f\n",uint256_str(str,txid),(double)it->second.satoshis/COIN); + char str[65]; std::vector voutTokenPubkeys; - if ( DecodeTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCode, assetid, voutTokenPubkeys, vopretExtra) != 0 && assetid == tokenid ) + if ( reftokenid==txid || (DecodeTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCode, tokenid, voutTokenPubkeys, vopretExtra) != 0 && reftokenid == tokenid)) { sum += it->second.satoshis; } diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index 8a819a147..8f7ccb197 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -475,7 +475,7 @@ int32_t get_coinheader(char *refcoin,char *acname,bits256 *blockhashp,bits256 *m cJSON *get_gatewayspending(char *refcoin,char *acname,char *bindtxidstr) { cJSON *retjson; char *retstr; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspending",bindtxidstr,refcoin,"","")) != 0 ) + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspendingwithdraws",bindtxidstr,refcoin,"","")) != 0 ) { //printf("pending.(%s)\n",jprint(retjson,0)); return(retjson); @@ -588,13 +588,12 @@ void importaddress(char *refcoin,char *acname,char *depositaddr, char *label,int } } -void addmultisigaddress(char *refcoin,char *acname,int32_t M, char *pubkeys,char *bindtxidstr) +void addmultisigaddress(char *refcoin,char *acname,int32_t M, char *pubkeys) { cJSON *retjson; char *retstr,Mstr[10],tmp[128]; sprintf(Mstr,"%d",M); - sprintf(tmp,"\"%s\"",bindtxidstr); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"addmultisigaddress",Mstr,pubkeys,tmp,"")) != 0 ) + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"addmultisigaddress",Mstr,pubkeys,"","")) != 0 ) { fprintf(stderr,"unexpected addmultisigaddress json.(%s)\n",jprint(retjson,0)); free(retstr); @@ -644,7 +643,6 @@ char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawadd printf("createrawtx satoshis %.8f < txfee %.8f\n",(double)satoshis/SATOSHIDEN,(double)txfee/SATOSHIDEN); return(0); } - satoshis -= txfee; sprintf(array,"\'[\"%s\"]\'",depositaddr); if ( (retjson= get_komodocli(refcoin,&retstr,acname,"listunspent","1","99999999",array,"")) != 0 ) { @@ -699,7 +697,7 @@ cJSON *addsignature(char *refcoin,char *acname,char *rawtx) { if ( is_cJSON_True(jobj(retjson,"complete")) != 0 ) return(retjson); - else if ( (hexstr= jstr(retjson,"hex")) != 0 && strlen(hexstr) > strlen(rawtx) ) + else if ( (hexstr= jstr(retjson,"hex")) != 0 && strlen(hexstr) > strlen(rawtx) + 2 ) { jaddnum(retjson,"partialtx",1); return(retjson); @@ -714,32 +712,14 @@ cJSON *addsignature(char *refcoin,char *acname,char *rawtx) return(0); } -char *get_gatewaysmultisig(char *refcoin,char *acname,char *txidaddr,int32_t *K) -{ - char *retstr,*hexstr,*hex=0; cJSON *retjson; - if ( (retjson= get_komodocli("KMD",&retstr,acname,"gatewaysmultisig",txidaddr,"","","")) != 0 ) - { - if ((hexstr=jstr(retjson,"hex")) != 0 ) - { - if (strlen(hexstr)>0) hex = clonestr(hexstr); - } - *K=jint(retjson,"number_of_signs"); - free_json(retjson); - } - else if ( retstr != 0 ) - { - printf("error parsing gatewaysmultisig.(%s)\n",retstr); - free(retstr); - } - return(hex); -} - -bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *hex) +bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *coin,char *hex) { char str[65],*retstr; cJSON *retjson; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspartialsign",bits256_str(str,txid),refcoin,hex,"")) != 0 ) + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspartialsign",bits256_str(str,txid),coin,hex,"")) != 0 ) { - return(komodobroadcast(refcoin,acname,retjson)); + txid=komodobroadcast(refcoin,acname,retjson); + free(retjson); + return (txid); } else if ( retstr != 0 ) { @@ -749,36 +729,38 @@ bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *hex) return (zeroid); } -void gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char *coin,char *hex) +bits256 gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char *coin,char *hex) { - char str[65],str2[65],*retstr; cJSON *retjson; - printf("spend %s %s/v2 as marker\n",acname,bits256_str(str,withtxid)); + char str[65],str2[65],*retstr; cJSON *retjson; bits256 txid; if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayscompletesigning",bits256_str(str,withtxid),coin,hex,"")) != 0 ) { - komodobroadcast(refcoin,acname,retjson); - free_json(retjson); + txid=komodobroadcast(refcoin,acname,retjson); + free(retjson); + return (txid); } else if ( retstr != 0 ) { printf("error parsing gatewayscompletesigning.(%s)\n",retstr); free(retstr); } + return (zeroid); } -void gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid,char *coin) +bits256 gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid,char *coin) { - char str[65],str2[65],*retstr; cJSON *retjson; - printf("spend %s %s/v2 as marker\n",acname,bits256_str(str,withtxid)); + char str[65],str2[65],*retstr; cJSON *retjson; bits256 txid; if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewaysmarkdone",bits256_str(str,withtxid),coin,"","")) != 0 ) { - komodobroadcast(refcoin,acname,retjson); - free_json(retjson); + txid=komodobroadcast(refcoin,acname,retjson); + free(retjson); + return (txid); } else if ( retstr != 0 ) { printf("error parsing gatewaysmarkdone.(%s)\n",retstr); free(retstr); } + return (zeroid); } int32_t get_gatewaysinfo(char *refcoin,char *acname,char *depositaddr,int32_t *Mp,int32_t *Np,char *bindtxidstr,char *coin,char *oraclestr, char **pubkeys) @@ -882,55 +864,9 @@ int32_t markerexists(char *refcoin,char *acname,char *coinaddr) free_json(array); } } - fprintf(stderr,"Num=%d\n",num); return(num); } -int32_t markerfromthisnodeorunconfirmed(char *refcoin,char *acname,char *coinaddr) -{ - cJSON *array,*item,*rawtx,*vins,*vin; bits256 txid,tmptxid; int32_t i,n,m,num=0; char *retstr; - if ( (array= get_addressutxos(refcoin,acname,coinaddr)) != 0 ) - { - n=cJSON_GetArraySize(array); - for (i=0; i 0 ) - { - num = 1; - break; - } - } - } - free_json(array); - } else return(-1); - } - return(num); -} void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t M,int32_t N) { @@ -941,7 +877,9 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t /// if enough sigs, sendrawtransaction and when it confirms spend marker (txid.2) /// if not enough sigs, post partially signed to acname with marker2 // monitor marker2, for the partially signed withdraws - cJSON *retjson,*pending,*item,*clijson; char str[65],*rawtx,*coinstr,*txidaddr,*signeraddr,*depositaddr,*withdrawaddr; int32_t i,j,n,K,retval,processed = 0; bits256 txid,cointxid,origtxid; int64_t satoshis; + cJSON *retjson,*pending,*item,*clijson; char str[65],str1[65],str2[65],*rawtx,*coinstr,*txidaddr,*signeraddr,*depositaddr,*withdrawaddr; + int32_t i,j,n,K,retval,processed = 0; bits256 txid,cointxid,withdrawtxid,lasttxid,completetxid; int64_t satoshis; + memset(&zeroid,0,sizeof(zeroid)); if ( (retjson= get_gatewayspending("KMD",acname,bindtxidstr)) != 0 ) { @@ -954,52 +892,55 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t if ( processed != 0 ) // avoid out of utxo conditions break; item = jitem(pending,i); - origtxid = jbits256(item,"txid"); + withdrawtxid = jbits256(item,"withdrawtxid"); //process item.0 {"txid":"10ec8f4dad6903df6b249b361b879ac77b0617caad7629b97e10f29fa7e99a9b","txidaddr":"RMbite4TGugVmkGmu76ytPHDEQZQGSUjxz","withdrawaddr":"RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc","amount":"1.00000000","depositaddr":"RHV2As4rox97BuE3LK96vMeNY8VsGRTmBj","signeraddr":"RHV2As4rox97BuE3LK96vMeNY8VsGRTmBj"} - if ( (txidaddr= jstr(item,"txidaddr")) != 0 && (withdrawaddr= jstr(item,"withdrawaddr")) != 0 && (depositaddr= jstr(item,"depositaddr")) != 0 && (signeraddr= jstr(item,"signeraddr")) != 0 ) + if ( (txidaddr=jstr(item,"withdrawtxidaddr"))!= 0 && (withdrawaddr=jstr(item,"withdrawaddr")) != 0 && (depositaddr= jstr(item,"depositaddr")) != 0 && (signeraddr= jstr(item,"signeraddr")) != 0 ) { - if ( (satoshis= jdouble(item,"amount")*SATOSHIDEN) != 0 && is_cJSON_True(jobj(item,"confirmed_or_notarized")) != 0 && markerfromthisnodeorunconfirmed("KMD",acname,txidaddr) == 0) + if ( (satoshis= jdouble(item,"amount")*SATOSHIDEN) != 0 && is_cJSON_True(jobj(item,"confirmed_or_notarized")) != 0) { if ( strcmp(depositaddr,signeraddr) == 0 ) { rawtx = createrawtx(refcoin,"",depositaddr,withdrawaddr,txidaddr,satoshis); if ( rawtx != 0 ) { - if ( (clijson= addsignature(refcoin,"",rawtx)) != 0 && is_cJSON_True(jobj(clijson,"complete")) != 0) + if ( (clijson=addsignature(refcoin,"",rawtx)) != 0 && is_cJSON_True(jobj(clijson,"complete")) != 0) { - gatewayscompletesigning("KMD",acname,origtxid,refcoin,jstr(clijson,"hex")); - fprintf(stderr,"withdraw %.8f %s to %s processed\n",(double)satoshis/SATOSHIDEN,refcoin,withdrawaddr); + txid=gatewayscompletesigning("KMD",acname,withdrawtxid,refcoin,jstr(clijson,"hex")); + if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) complete signing tx sent - %s\n",bits256_str(str,withdrawtxid),bits256_str(str1,txid)); + else fprintf(stderr,"error broadcasting tx on %s",acname); free_json(clijson); - } - processed++; + processed++; + } free(rawtx); } else fprintf(stderr,"couldnt create rawtx\n"); } else { - if ( (rawtx= get_gatewaysmultisig(refcoin,acname,txidaddr,&K)) == 0) + lasttxid = jbits256(item,"last_txid"); + if ( lasttxid.txid==withdrawtxid.txid) { rawtx = createrawtx(refcoin,"",depositaddr,withdrawaddr,txidaddr,satoshis); } - if ( rawtx != 0 ) + else rawtx=jstr(item,"hex"); + K=jint(item,"number_of_signs"); + if ( (clijson= addsignature(refcoin,"",rawtx)) != 0 ) { - if ( (clijson= addsignature(refcoin,"",rawtx)) != 0 ) - { - if ( is_cJSON_True(jobj(clijson,"complete")) != 0 ) - { - gatewayscompletesigning("KMD",acname,origtxid,refcoin,jstr(clijson,"hex")); - fprintf(stderr,"withdraw %.8f %s M.%d N.%d to %s processed\n",(double)satoshis/SATOSHIDEN,refcoin,M,N,withdrawaddr); - } - else if ( jint(clijson,"partialtx") != 0 ) - { - txid=gatewayspartialsign(refcoin,acname,origtxid,jstr(clijson,"hex")); - fprintf(stderr,"%d sign(s) %dof%d partialtx %s sent\n",K+1,M,N,bits256_str(str,txid)); - } - free_json(clijson); + if ( is_cJSON_True(jobj(clijson,"complete")) != 0 ) + { + txid=gatewayscompletesigning("KMD",acname,lasttxid,refcoin,jstr(clijson,"hex")); + if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) complete signing tx (%dof%d) sent - %s\n",bits256_str(str,withdrawtxid),M,N,bits256_str(str1,txid)); + else fprintf(stderr,"error broadcasting tx on %s",acname); } + else if ( jint(clijson,"partialtx") != 0 ) + { + txid=gatewayspartialsign("KMD",acname,lasttxid,refcoin,jstr(clijson,"hex")); + if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) partial tx (%d/%dof%d) sent - %s\n",bits256_str(str,withdrawtxid),K+1,M,N,bits256_str(str1,txid)); + else fprintf(stderr,"error broadcasting tx on %s",acname); + } + free_json(clijson); processed++; - free(rawtx); - } else fprintf(stderr,"couldnt create msig rawtx\n"); + } + free(rawtx); } } } @@ -1012,24 +953,27 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t { if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 ) { - if ( (pending=jarray(&n,retjson,"processed")) != 0 ) + if ((pending=jarray(&n,retjson,"processed")) != 0) { for (i=0; i pubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2) +CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector gatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2) { - CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << prefix << prefix2 << taddr << tokenid << totalsupply << M << N << pubkeys << oracletxid); - return(opret); + CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; + std::vector pubkeys; + + cp = CCinit(&C,EVAL_GATEWAYS); + gatewayspk = GetUnspendable(cp,0); + pubkeys.push_back(gatewayspk); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << totalsupply << oracletxid << M << N << gatewaypubkeys << taddr << prefix << prefix2); + return(EncodeTokenOpRet(tokenid,pubkeys,opret)); } -uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,std::string &coin,uint256 &tokenid,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &pubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2) +uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2) { - std::vector vopret; uint8_t *script,e,f; - GetOpReturnData(scriptPubKey, vopret); + std::vector vopret; uint8_t *script,e,f,tokenevalcode; + std::vector vOpretExtra; std::vector pubkeys; + + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + { + if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + } + else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); depositaddr[0] = 0; - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> prefix; ss >> prefix2; ss >> taddr; ss >> tokenid; ss >> totalsupply; ss >> M; ss >> N; ss >> pubkeys; ss >> oracletxid) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> totalsupply; ss >> oracletxid; ss >> M; ss >> N; ss >> gatewaypubkeys; ss >> taddr; ss >> prefix; ss >> prefix2;) != 0 ) { if ( prefix == 60 ) { if ( N > 1 ) { - strcpy(depositaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,pubkeys))).ToString().c_str()); - //Getscriptaddress(depositaddr,GetScriptForMultisig(M,pubkeys)); - fprintf(stderr,"f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)pubkeys.size(),depositaddr); - } else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(pubkeys[0])) << OP_CHECKSIG); + strcpy(depositaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys))).ToString().c_str()); + //fprintf(stderr,"f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr); + } else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG); } else { @@ -189,118 +190,134 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,st return(0); } -CScript EncodeGatewaysDepositOpRet(uint8_t funcid,std::string coin,uint256 bindtxid,std::vector publishers,std::vectortxids,int32_t height,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount) +CScript EncodeGatewaysDepositOpRet(uint8_t funcid,uint256 bindtxid,std::string refcoin,std::vector publishers,std::vectortxids,int32_t height,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << bindtxid << publishers << txids << height << cointxid << claimvout << deposithex << proof << destpub << amount); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << refcoin << bindtxid << publishers << txids << height << cointxid << claimvout << deposithex << proof << destpub << amount); return(opret); } -uint8_t DecodeGatewaysDepositOpRet(const CScript &scriptPubKey,std::string &coin,uint256 &bindtxid,std::vector&publishers,std::vector&txids,int32_t &height,uint256 &cointxid, int32_t &claimvout,std::string &deposithex,std::vector &proof,CPubKey &destpub,int64_t &amount) +uint8_t DecodeGatewaysDepositOpRet(const CScript &scriptPubKey,uint256 &bindtxid,std::string &refcoin,std::vector&publishers,std::vector&txids,int32_t &height,uint256 &cointxid, int32_t &claimvout,std::string &deposithex,std::vector &proof,CPubKey &destpub,int64_t &amount) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> bindtxid; ss >> publishers; ss >> txids; ss >> height; ss >> cointxid; ss >> claimvout; ss >> deposithex; ss >> proof; ss >> destpub; ss >> amount) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> refcoin; ss >> bindtxid; ss >> publishers; ss >> txids; ss >> height; ss >> cointxid; ss >> claimvout; ss >> deposithex; ss >> proof; ss >> destpub; ss >> amount) != 0 ) { return(f); } return(0); } -// encodes payload for the token opret (needs to be added to the tail of it) -CScript EncodeGatewaysClaimOpRet(uint8_t funcid, std::string refcoin, uint256 bindtxid, uint256 deposittxid, CPubKey destpub, int64_t amount) +CScript EncodeGatewaysClaimOpRet(uint8_t funcid,uint256 tokenid,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount) { - CScript opret; + CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; + std::vector pubkeys; - opret << OP_RETURN << E_MARSHAL(ss << funcid << refcoin << bindtxid << deposittxid << destpub << amount); - return(opret); + pubkeys.push_back(destpub); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << bindtxid << refcoin << deposittxid << destpub << amount); + return(EncodeTokenOpRet(tokenid,pubkeys,opret)); } -uint8_t DecodeGatewaysClaimOpRet(const CScript &scriptPubKey,uint256 &tokenid,std::string &refcoin,uint256 &bindtxid,uint256 &deposittxid,CPubKey &destpub,int64_t &amount) +uint8_t DecodeGatewaysClaimOpRet(const CScript &scriptPubKey,uint256 &tokenid,uint256 &bindtxid,std::string &refcoin,uint256 &deposittxid,CPubKey &destpub,int64_t &amount) { - std::vector vopret; uint8_t *script,e,f; - GetOpReturnData(scriptPubKey, vopret); + std::vector vopret; uint8_t *script,e,f,tokenevalcode; + std::vector pubkeys; std::vector vOpretExtra; + + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + { + if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + } + else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> tokenid; ss >> refcoin; ss >> bindtxid; ss >> deposittxid; ss >> destpub; ss >> amount) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> bindtxid; ss >> refcoin; ss >> deposittxid; ss >> destpub; ss >> amount) != 0 ) { return(f); } return(0); } -CScript EncodeGatewaysWithdrawOpRet(uint8_t funcid, std::string refcoin, CPubKey withdrawpub, int64_t amount) +CScript EncodeGatewaysWithdrawOpRet(uint8_t funcid,uint256 tokenid,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount) { - CScript opret; - opret << OP_RETURN << E_MARSHAL(ss << funcid << refcoin << withdrawpub << amount); - return(opret); + CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; + std::vector pubkeys; + + cp = CCinit(&C,EVAL_GATEWAYS); + gatewayspk = GetUnspendable(cp,0); + pubkeys.push_back(gatewayspk); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << bindtxid << refcoin << withdrawpub << amount); + return(EncodeTokenOpRet(tokenid,pubkeys,opret)); } -uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256 &tokenid, std::string &refcoin, CPubKey &withdrawpub, int64_t &amount) +uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256& tokenid, uint256 &bindtxid, std::string &refcoin, CPubKey &withdrawpub, int64_t &amount) { - std::vector vopret; uint8_t *script,e,f; + std::vector vopret; uint8_t *script,e,f,tokenevalcode; + std::vector pubkeys; std::vector vOpretExtra; - - GetOpReturnData(scriptPubKey, vopret); + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + { + if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + } + else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> tokenid; ss >> refcoin; ss >> withdrawpub; ss >> amount) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> bindtxid; ss >> refcoin; ss >> withdrawpub; ss >> amount) != 0 ) { return(f); } return(0); } -CScript EncodeGatewaysPartialOpRet(uint8_t funcid,int32_t K, CPubKey signerpk, std::string refcoin,std::string hex) +CScript EncodeGatewaysPartialOpRet(uint8_t funcid, uint256 withdrawtxid,std::string refcoin,int32_t K, CPubKey signerpk,std::string hex) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << K << signerpk << refcoin << hex); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << K << signerpk << hex); return(opret); } -uint8_t DecodeGatewaysPartialOpRet(const CScript &scriptPubKey,int32_t &K, CPubKey &signerpk, std::string &refcoin,std::string &hex) +uint8_t DecodeGatewaysPartialOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,int32_t &K, CPubKey &signerpk,std::string &hex) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> K; ss >> signerpk; ss >> refcoin; ss >> hex) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> K; ss >> signerpk; ss >> hex) != 0 ) { return(f); } return(0); } -CScript EncodeGatewaysCompleteSigningOpRet(uint8_t funcid,std::string refcoin,uint256 withdrawtxid,std::string hex) +CScript EncodeGatewaysCompleteSigningOpRet(uint8_t funcid,uint256 withdrawtxid,std::string refcoin,std::string hex) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << refcoin << withdrawtxid << hex); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << hex); return(opret); } -uint8_t DecodeGatewaysCompleteSigningOpRet(const CScript &scriptPubKey, std::string &refcoin, uint256 &withdrawtxid,std::string &hex) +uint8_t DecodeGatewaysCompleteSigningOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,std::string &hex) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> refcoin; ss >> withdrawtxid; ss >> hex) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> hex) != 0 ) { return(f); } return(0); } -CScript EncodeGatewaysMarkDoneOpRet(uint8_t funcid,std::string refcoin,uint256 withdrawtxid) +CScript EncodeGatewaysMarkDoneOpRet(uint8_t funcid,std::string refcoin,uint256 completetxid,uint256 withdrawtxid) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << refcoin << withdrawtxid); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << refcoin << completetxid < vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> refcoin; ss >> withdrawtxid;) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> refcoin; ss >> completetxid; ss >> withdrawtxid;) != 0 ) { return(f); } @@ -309,12 +326,19 @@ uint8_t DecodeGatewaysMarkDoneOpRet(const CScript &scriptPubKey, std::string &re uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey) { - std::vector vopret; uint8_t *script,e,f; - GetOpReturnData(scriptPubKey, vopret); - script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && (script[0] == EVAL_GATEWAYS || script[0] == EVAL_TOKENS) && E_UNMARSHAL(vopret,ss >> e; ss >> f) != 0 ) + std::vector vopret; uint8_t *script,e,f,tokenevalcode; + std::vector pubkeys; std::vector vOpretExtra; uint256 tokenid; + + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { - if (f == 'B' && f == 'D' && f == 't' && f == 'W' && f == 'P' && f == 'M') + if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + } + else GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && script[0] == EVAL_GATEWAYS) + { + f=script[1]; + if (f == 'B' || f == 'D' || f == 'C' || f == 'W' || f == 'P' || f == 'S' || f == 'M') return(f); } return(0); @@ -429,7 +453,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u return(zeroid); } -int32_t GatewaysCointxidExists(struct CCcontract_info *cp,uint256 cointxid) // dont forget to check mempool! +int32_t GatewaysCointxidExists(struct CCcontract_info *cp,uint256 cointxid) { char txidaddr[64]; std::string coin; int32_t numvouts; uint256 hashBlock; std::vector > addressIndex; @@ -457,7 +481,9 @@ uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::ve int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 cointxid,const std::string deposithex,std::vectorproof,uint256 merkleroot,CPubKey destpub) { - std::vector txids; uint256 proofroot,hashBlock,txid = zeroid; CTransaction tx; std::string name,description,format; char destaddr[64],destpubaddr[64],claimaddr[64],str[65],str2[65]; int32_t i,numvouts; int64_t nValue = 0; + std::vector txids; uint256 proofroot,hashBlock,txid = zeroid; CTransaction tx; std::string name,description,format; + char destaddr[64],destpubaddr[64],claimaddr[64],str[65],str2[65]; int32_t i,numvouts; int64_t nValue = 0; + if ( myGetTransaction(oracletxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { fprintf(stderr,"GatewaysVerify cant find oracletxid %s\n",uint256_str(str,oracletxid)); @@ -505,7 +531,7 @@ int64_t GatewaysDepositval(CTransaction tx,CPubKey mypk) int32_t numvouts,claimvout,height; int64_t amount; std::string coin,deposithex; std::vector publishers; std::vectortxids; uint256 bindtxid,cointxid; std::vector proof; CPubKey claimpubkey; if ( (numvouts= tx.vout.size()) > 0 ) { - if ( DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,coin,bindtxid,publishers,txids,height,cointxid,claimvout,deposithex,proof,claimpubkey,amount) == 'D' && claimpubkey == mypk ) + if ( DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,claimpubkey,amount) == 'D' && claimpubkey == mypk ) { // coin, bindtxid, publishers fprintf(stderr,"need to validate deposittxid more\n"); @@ -574,74 +600,74 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & //vout.0: CC vout of total tokens from deposit amount to asset eval code //(vout.1): CC vout if there is change of unused tokens back to owner of tokens (deposit amount less than available tokens) //vout.n-1: opreturn - 't' tokenid zeroid 0 mypubkey (NOTE: opreturn is with asset eval code) - if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysClaimOpRet(tx.vout[numvouts-1].scriptPubKey,tokenidClaim,refcoin,bindtxid,deposittxid,destpub,amount)==0) - return eval->Invalid("invalid gatewaysclaim OP_RETURN data!"); - else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for gatewaysClaim!"); - else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for gatewaysClaim!"); - else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) - return eval->Invalid("vin.2 is CC for gatewaysClaim!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewaysClaim!"); - else if ( numvouts > 2 && tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.1 is CC for gatewaysClaim!"); - else if (myGetTransaction(bindtxid,bindtx,hashblock) == 0) - return eval->Invalid("invalid gatewaysbind txid!"); - else if ((numvouts=bindtx.vout.size()) > 0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenidBind,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') - return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); - else if (tmprefcoin!=refcoin) - return eval->Invalid("refcoin different in bind tx"); - else if (tokenidClaim!=tokenidBind) - return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); - else if (komodo_txnotarizedconfirmed(bindtxid) == false) - return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); - else if (myGetTransaction(deposittxid,deposittx,hashblock) == 0) - return eval->Invalid("invalid gatewaysdeposittxid!"); - else if ((numvouts=deposittx.vout.size()) > 0 && DecodeGatewaysDepositOpRet(deposittx.vout[numvouts-1].scriptPubKey,tmprefcoin,tmptxid,tmppublishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D') - return eval->Invalid("invalid gatewaysdeposit OP_RETURN data!"); - else if (tmprefcoin!=refcoin) - return eval->Invalid("refcoin different in deposit tx"); - else if (bindtxid!=tmptxid) - return eval->Invalid("bindtxid does not match to bindtxid from gatewaysdeposit"); - else if (tmpamount>totalsupply) - return eval->Invalid("deposit amount greater then bind total supply"); - else if (komodo_txnotarizedconfirmed(deposittxid) == false) - return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!"); - else if (amount>tmpamount) - return eval->Invalid("claimed amount greater then deposit amount"); - else if (destpub!=tmpdestpub) - return eval->Invalid("destination pubkey different than in deposit tx"); - else - { - int32_t m; - merkleroot = zeroid; - for (i=m=0; iInvalid(validationError); - } - if ( GatewaysCointxidExists(cp,cointxid) != 0 ) - { - sprintf(validationError,"cointxid.%s already exists\n",uint256_str(str,cointxid)); - return eval->Invalid(validationError); - } - if (GatewaysVerify(depositaddr,oracletxid,claimvout,tmprefcoin,cointxid,deposithex,proof,merkleroot,destpub)!=amount) - return eval->Invalid("deposittxid didnt validate\n"); - } + // if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysClaimOpRet(tx.vout[numvouts-1].scriptPubKey,tokenidClaim,refcoin,bindtxid,deposittxid,destpub,amount)==0) + // return eval->Invalid("invalid gatewaysclaim OP_RETURN data!"); + // else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + // return eval->Invalid("vin.0 is normal for gatewaysClaim!"); + // else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) + // return eval->Invalid("vin.1 is CC for gatewaysClaim!"); + // else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) + // return eval->Invalid("vin.2 is CC for gatewaysClaim!"); + // else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + // return eval->Invalid("vout.0 is CC for gatewaysClaim!"); + // else if ( numvouts > 2 && tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + // return eval->Invalid("vout.1 is CC for gatewaysClaim!"); + // else if (myGetTransaction(bindtxid,bindtx,hashblock) == 0) + // return eval->Invalid("invalid gatewaysbind txid!"); + // else if ((numvouts=bindtx.vout.size()) > 0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenidBind,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + // return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + // else if (tmprefcoin!=refcoin) + // return eval->Invalid("refcoin different in bind tx"); + // else if (tokenidClaim!=tokenidBind) + // return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); + // else if (komodo_txnotarizedconfirmed(bindtxid) == false) + // return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + // else if (myGetTransaction(deposittxid,deposittx,hashblock) == 0) + // return eval->Invalid("invalid gatewaysdeposittxid!"); + // else if ((numvouts=deposittx.vout.size()) > 0 && DecodeGatewaysDepositOpRet(deposittx.vout[numvouts-1].scriptPubKey,tmprefcoin,tmptxid,tmppublishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D') + // return eval->Invalid("invalid gatewaysdeposit OP_RETURN data!"); + // else if (tmprefcoin!=refcoin) + // return eval->Invalid("refcoin different in deposit tx"); + // else if (bindtxid!=tmptxid) + // return eval->Invalid("bindtxid does not match to bindtxid from gatewaysdeposit"); + // else if (tmpamount>totalsupply) + // return eval->Invalid("deposit amount greater then bind total supply"); + // else if (komodo_txnotarizedconfirmed(deposittxid) == false) + // return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!"); + // else if (amount>tmpamount) + // return eval->Invalid("claimed amount greater then deposit amount"); + // else if (destpub!=tmpdestpub) + // return eval->Invalid("destination pubkey different than in deposit tx"); + // else + // { + // int32_t m; + // merkleroot = zeroid; + // for (i=m=0; iInvalid(validationError); + // } + // if ( GatewaysCointxidExists(cp,cointxid) != 0 ) + // { + // sprintf(validationError,"cointxid.%s already exists\n",uint256_str(str,cointxid)); + // return eval->Invalid(validationError); + // } + // if (GatewaysVerify(depositaddr,oracletxid,claimvout,tmprefcoin,cointxid,deposithex,proof,merkleroot,destpub)!=amount) + // return eval->Invalid("deposittxid didnt validate\n"); + // } break; case 'W': //vin.0: normal input @@ -669,8 +695,6 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & break; } } - - retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) fprintf(stderr,"Gatewaysget validated\n"); @@ -683,65 +707,81 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & // helper functions for rpc calls in rpcwallet.cpp -int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 reftokenid,int64_t total,int32_t maxinputs) +int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 bindtxid,int64_t total,int32_t maxinputs) { - char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 tokenid,txid,hashBlock; std::vector origpubkey; std::vector vopret; CTransaction vintx; int32_t j,vout,n = 0; uint8_t evalcode,funcid; - std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); - //fprintf(stderr,"check %s for gateway inputs\n",coinaddr); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + char coinaddr[64],depositaddr[64]; int64_t threshold,nValue,price,totalinputs = 0,totalsupply,amount; + CTransaction vintx,bindtx; int32_t vout,numvouts,n = 0; uint8_t M,N,evalcode,funcid,taddr,prefix,prefix2; std::vector pubkeys; + std::vector > unspentOutputs; std::string refcoin,tmprefcoin; CPubKey withdrawpub,destpub; + uint256 tokenid,txid,oracletxid,tmpbindtxid,tmptokenid,deposittxid,hashBlock; + + if ( GetTransaction(bindtxid,bindtx,hashBlock,false) != 0 ) { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - if ( it->second.satoshis < threshold ) - continue; - for (j=0; jsecond.satoshis/COIN); - if ( strcmp(destaddr,coinaddr) != 0 && strcmp(destaddr,cp->unspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) - continue; - GetOpReturnData(vintx.vout[vintx.vout.size()-1].scriptPubKey, vopret); - if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> tokenid) != 0 ) + GetTokensCCaddress(cp,coinaddr,pk); + SetCCunspents(unspentOutputs,coinaddr); + threshold = total/(maxinputs+1); + fprintf(stderr,"check %s for gateway inputs\n",coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - tokenid = revuint256(tokenid); - char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for reftokenid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,reftokenid),uint256_str(str2,tokenid),(double)vintx.vout[vout].nValue/COIN); - if ( tokenid == reftokenid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if ( it->second.satoshis < threshold ) + continue; + // for (j=0; jsecond.satoshis/COIN); - if ( total != 0 && maxinputs != 0 ) + funcid=DecodeGatewaysOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey); + if (vout==0 && funcid=='B' && bindtxid==txid && total != 0 && maxinputs != 0) + { mtx.vin.push_back(CTxIn(txid,vout,CScript())); - //nValue = it->second.satoshis; - totalinputs += nValue; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) - break; + totalinputs += it->second.satoshis; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; + } + else if (vout==1 && funcid=='W' && DecodeGatewaysWithdrawOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,tmptokenid,tmpbindtxid,tmprefcoin,withdrawpub,amount) == 'W' && + tmpbindtxid==bindtxid && tmprefcoin==refcoin && tmptokenid==tokenid && total != 0 && maxinputs != 0) + { + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + totalinputs += it->second.satoshis; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; + } + else if (vout==1 && funcid=='C' && DecodeGatewaysClaimOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,tmptokenid,tmpbindtxid,tmprefcoin,deposittxid,destpub,amount) == 'C' && + tmpbindtxid==bindtxid && tmprefcoin==refcoin && tmptokenid==tokenid && total != 0 && maxinputs != 0) + { + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + totalinputs += it->second.satoshis; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; + } } } + return(totalinputs); } + else fprintf(stderr,"invalid GatewaysBind\n"); } - return(totalinputs); + else fprintf(stderr,"can't find GatewaysBind txid\n"); + return(0); } -int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 reftokenid) // dont forget to check mempool! +int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 reftokenid) { - char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; CTransaction tx; + char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; + uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; CTransaction tx; std::vector > addressIndex; + _GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk); - fprintf(stderr,"bind markeraddr.(%s) need to scan mempool also\n",markeraddr); SetCCtxids(addressIndex,markeraddr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if ( GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' ) { if ( tokenid == reftokenid ) { @@ -751,15 +791,29 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 } } } + BOOST_FOREACH(const CTxMemPoolEntry &e, mempool.mapTx) + { + const CTransaction &txmempool = e.GetTx(); + const uint256 &hash = txmempool.GetHash(); + + if ((numvouts=txmempool.vout.size()) > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' && + tokenid == reftokenid) + return(1); + } + return(0); } std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CCcontract_info *cp,C; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],str[65],*fstr; + CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; + struct CCcontract_info *cp,*cpTokens,C,CTokens; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; + char destaddr[64],coinaddr[64],myTokenCCaddr[64],str[65],*fstr; + cp = CCinit(&C,EVAL_GATEWAYS); - if ( strcmp((char *)"KMD",coin.c_str()) == 0 ) + cpTokens = CCinit(&CTokens,EVAL_TOKENS); + if (coin=="KMD") { taddr = 0; prefix = 60; @@ -794,20 +848,21 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); + _GetCCaddress(myTokenCCaddr,EVAL_TOKENS,mypk); gatewayspk = GetUnspendable(cp,0); if ( _GetCCaddress(destaddr,EVAL_GATEWAYS,gatewayspk) == 0 ) { fprintf(stderr,"Gateway bind.%s (%s) cant create globaladdr\n",coin.c_str(),uint256_str(str,tokenid)); return(""); } - if ( (fullsupply= CCfullsupply(tokenid)) != totalsupply ) + if ( (fullsupply=CCfullsupply(tokenid)) != totalsupply ) { fprintf(stderr,"Gateway bind.%s (%s) globaladdr.%s totalsupply %.8f != fullsupply %.8f\n",coin.c_str(),uint256_str(str,tokenid),cp->unspendableCCaddr,(double)totalsupply/COIN,(double)fullsupply/COIN); return(""); } - if ( CCtoken_balance(destaddr,tokenid) != totalsupply ) + if ( CCtoken_balance(myTokenCCaddr,tokenid) != totalsupply ) { - fprintf(stderr,"Gateway bind.%s (%s) destaddr.%s globaladdr.%s token balance %.8f != %.8f\n",coin.c_str(),uint256_str(str,tokenid),destaddr,cp->unspendableCCaddr,(double)CCtoken_balance(destaddr,tokenid)/COIN,(double)totalsupply/COIN); + fprintf(stderr,"token balance on %s %.8f != %.8f\n",myTokenCCaddr,(double)CCtoken_balance(myTokenCCaddr,tokenid)/COIN,(double)totalsupply/COIN); return(""); } if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) @@ -820,20 +875,24 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t fprintf(stderr,"mismatched oracle name %s != %s\n",name.c_str(),coin.c_str()); return(""); } - if ( (fstr= (char *)format.c_str()) == 0 || strncmp(fstr,"Ihh",3) != 0 ) + if ( (fstr=(char *)format.c_str()) == 0 || strncmp(fstr,"Ihh",3) != 0 ) { fprintf(stderr,"illegal format (%s) != (%s)\n",fstr,(char *)"Ihh"); return(""); } - if ( GatewaysBindExists(cp,gatewayspk,tokenid) != 0 ) // dont forget to check mempool! + if ( GatewaysBindExists(cp,gatewayspk,tokenid) != 0 ) { fprintf(stderr,"Gateway bind.%s (%s) already exists\n",coin.c_str(),uint256_str(str,tokenid)); return(""); } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gatewayspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysBindOpRet('B',coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2))); + if (AddTokenCCInputs(cpTokens, mtx, mypk, tokenid, totalsupply, 64)>0) + { + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,totalsupply,gatewayspk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gatewayspk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysBindOpRet('B',tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2))); + } } CCerror = strprintf("cant find enough inputs"); fprintf(stderr,"%s\n", CCerror.c_str() ); @@ -843,7 +902,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction bindtx; CPubKey mypk,gatewayspk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; + CTransaction bindtx; CPubKey mypk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CCcontract_info *cp,C; std::vector pubkeys,publishers; std::vectortxids; char str[67],depositaddr[64],txidaddr[64]; @@ -851,14 +910,13 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - gatewayspk = GetUnspendable(cp,0); //fprintf(stderr,"GatewaysDeposit ht.%d %s %.8f numpks.%d\n",height,refcoin.c_str(),(double)amount/COIN,(int32_t)pubkeys.size()); if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) { fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin ) + if ( DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin ) { fprintf(stderr,"invalid coin - bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); return(""); @@ -901,7 +959,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,destpub)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,cointxid))) << OP_CHECKSIG)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysDepositOpRet('D',coin,bindtxid,publishers,txids,height,cointxid,claimvout,deposithex,proof,destpub,amount))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysDepositOpRet('D',bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,destpub,amount))); } fprintf(stderr,"cant find enough inputs\n"); return(""); @@ -925,7 +983,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) { fprintf(stderr,"invalid coin - bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); return(""); @@ -935,7 +993,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui fprintf(stderr,"cant find deposittxid %s\n",uint256_str(str,bindtxid)); return(""); } - if (DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,coin,tmptxid,publishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D' || coin != refcoin) + if (DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmptxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D' || coin != refcoin) { fprintf(stderr,"invalid coin - deposittxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); return(""); @@ -945,32 +1003,20 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui fprintf(stderr,"different destination pubkey from desdeposittxid\n"); return(""); } - if ( (depositamount= GatewaysDepositval(tx,mypk)) != amount ) + if ( (depositamount=GatewaysDepositval(tx,mypk)) != amount ) { fprintf(stderr,"invalid Gateways deposittxid %s %.8f != %.8f\n",uint256_str(str,deposittxid),(double)depositamount/COIN,(double)amount/COIN); return(""); } - //fprintf(stderr,"depositaddr.(%s) vs %s\n",depositaddr,cp->unspendableaddr2); if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) { - ///////// if ( (inputs= AddGatewaysInputs(cp,mtx,gatewayspk,tokenid,amount,60)) > 0 ) - if ((inputs = AddTokenCCInputs(cp, mtx, gatewayspk, tokenid, amount, 60)) > 0) + if ((inputs=AddGatewaysInputs(cp, mtx, gatewayspk, bindtxid, amount, 60)) > 0) { - if ( inputs > amount ) - CCchange = (inputs - amount); - _GetCCaddress(destaddr,EVAL_GATEWAYS,mypk); - //printf("expecting deposittxid/v0 to be to %s\n",destaddr); - mtx.vin.push_back(CTxIn(deposittxid,0,CScript())); // triggers EVAL_GATEWAYS validation - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,amount,mypk)); // transfer back to normal token - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CCchange,gatewayspk)); - - std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(mypk); // the pubkey where tokens are going (vout[0]) - - return(FinalizeCCTx(0,cp,mtx,mypk,txfee, - EncodeTokenOpRet('t', EVAL_GATEWAYS, tokenid, voutTokenPubkeys, - EncodeGatewaysClaimOpRet('t', refcoin, bindtxid, deposittxid, destpub, amount)))); // yes, 't' is passed twice + if ( inputs > amount ) CCchange = (inputs - amount); + mtx.vin.push_back(CTxIn(deposittxid,0,CScript())); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,amount,destpub)); + if ( CCchange != 0 ) mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,CCchange,gatewayspk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysClaimOpRet('C',tokenid,bindtxid,refcoin,deposittxid,destpub,amount))); } } CCerror = strprintf("cant find enough inputs or mismatched total"); @@ -981,159 +1027,377 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; - CPubKey mypk, gatewayspk; - uint256 tokenid,hashBlock,oracletxid; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; - std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; - struct CCcontract_info *cpGateways, gatewaysC; - struct CCcontract_info *cpTokens, tokensC; - - cpGateways = CCinit(&gatewaysC, EVAL_GATEWAYS); - cpTokens = CCinit(&tokensC, EVAL_TOKENS); + CTransaction tx; CPubKey mypk,gatewayspk,signerpk; uint256 txid,tokenid,hashBlock,oracletxid,tmptokenid,tmpbindtxid,withdrawtxid; int32_t K,vout,numvouts; + int64_t nValue,totalsupply,inputs,CCchange=0; uint8_t funcid,M,N,taddr,prefix,prefix2; std::string coin,hex; + std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C,*cpTokens,CTokens; + std::vector > unspentOutputs; + cp = CCinit(&C,EVAL_GATEWAYS); + cpTokens = CCinit(&CTokens,EVAL_TOKENS); if ( txfee == 0 ) txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - gatewayspk = GetUnspendable(cpGateways, 0); + gatewayspk = GetUnspendable(cp, 0); if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(""); } - if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) + if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) { fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); return(""); } + _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + nValue = (int64_t)it->second.satoshis; + K=0; + if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P')) + { + if (funcid=='W' && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)=='W' + && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) + { + CCerror = strprintf("unable to create withdraw, another withdraw pending\n"); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + + else if (funcid=='P' && DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' && + GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)=='W' + && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) + { + CCerror = strprintf("unable to create withdraw, another withdraw pending\n"); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + } + } if( AddNormalinputs(mtx, mypk, 3*txfee, 4) > 0 ) { - /////if ( (inputs= AddGatewaysInputs(cp,mtx,mypk,tokenid,amount,60)) > 0 ) if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, tokenid, amount, 60)) > 0) { - if ( inputs > amount ) - CCchange = (inputs - amount); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, amount, gatewayspk)); - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG)); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS, txfee, gatewayspk)); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); - - char unspendableGatewaysAddr[64]; - GetCCaddress(cpGateways, unspendableGatewaysAddr, gatewayspk); - - uint8_t unspendableGatewaysPrivkey[32]; - GetUnspendable(cpGateways, unspendableGatewaysPrivkey); - - // add additional unspendable addr from Gateways: - CCaddr2set(cpTokens, EVAL_GATEWAYS, gatewayspk, unspendableGatewaysPrivkey, unspendableGatewaysAddr); - - std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(gatewayspk); // the pubkey where tokens are going vout[0] (and for checking the 'change' the Tokens contract will find pubkeys itself) - - return(FinalizeCCTx(0, cpTokens, mtx, mypk, txfee, - EncodeTokenOpRet('t', EVAL_GATEWAYS, tokenid, voutTokenPubkeys, - EncodeGatewaysWithdrawOpRet('W', refcoin, withdrawpub, amount)))); + if ( inputs > amount ) CCchange = (inputs - amount); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,amount,gatewayspk)); + //mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG)); + if ( CCchange != 0 ) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); + return(FinalizeCCTx(0, cpTokens, mtx, mypk, txfee,EncodeGatewaysWithdrawOpRet('W',tokenid,bindtxid,refcoin,withdrawpub,amount))); + } + else + { + CCerror = strprintf("not enough balance of tokens for withdraw"); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } - CCerror = strprintf("cant find enough token inputs or mismatched total"); - fprintf(stderr, "%s\n", CCerror.c_str()); - return(""); - } - CCerror = strprintf("cant find enough normal inputs or mismatched total"); + CCerror = strprintf("cant find enough normal inputs"); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } -std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string hex) +std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refcoin, std::string hex) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,txidaddrpk,signerpk; struct CCcontract_info *cp,C; CTransaction tx; - std::vector > unspentOutputs; char txidaddr[65]; - int32_t maxK,K=0; uint256 tmptxid,parttxid,hashBlock; + CPubKey mypk,withdrawpub,signerpk,gatewayspk; struct CCcontract_info *cp,C; CTransaction tx,bindtx; + std::vector > unspentOutputs; char funcid,str[65],depositaddr[64]; + int32_t numvouts,K=0; uint256 withdrawtxid,hashBlock,bindtxid,tokenid,oracletxid,tmptokenid; std::string coin,tmphex; int64_t amount,totalsupply; + uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; + cp = CCinit(&C,EVAL_GATEWAYS); if ( txfee == 0 ) - txfee = 5000; + txfee = 10000; mypk = pubkey2pk(Mypubkey()); - txidaddrpk=CCtxidaddr(txidaddr,txid); - SetCCunspents(unspentOutputs,txidaddr); - maxK=0; - if (unspentOutputs.size()==0) + gatewayspk = GetUnspendable(cp,0); + if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { - if (AddNormalinputs(mtx,mypk,2*txfee,3)==0) fprintf(stderr,"error adding funds for partialsign\n"); + CCerror = strprintf("can't find last tx %s\n",uint256_str(str,lasttxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } - else + if (funcid=='W') { - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + withdrawtxid=lasttxid; + if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { - tmptxid = it->first.txhash; - if (GetTransaction(tmptxid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && DecodeGatewaysPartialOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,K,signerpk,refcoin,hex) == 'P' && K>maxK ) - { - maxK=K; - parttxid=tmptxid; - } + CCerror = strprintf("invalid withdraw tx %s\n",uint256_str(str,lasttxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } - if (maxK>0) + else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) { - if (AddNormalinputs(mtx,mypk,txfee,3)==0) fprintf(stderr,"error adding funds for partialsign\n"); - mtx.vin.push_back(CTxIn(parttxid,0,CScript())); + CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + || refcoin!=coin || tokenid!=tmptokenid) + { + CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } - else fprintf(stderr,"Error finding previous partial tx\n"); } - - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,5000,txidaddrpk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysPartialOpRet('P',maxK+1,mypk,refcoin,hex))); + else if (funcid=='P') + { + if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) + { + CCerror = strprintf("cannot decode partialsign tx opret %s\n",uint256_str(str,lasttxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) + { + CCerror = strprintf("can't find withdraw tx %s\n",uint256_str(str,withdrawtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' + || refcoin!=coin) + { + CCerror = strprintf("invalid withdraw tx %s\n",uint256_str(str,lasttxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + || refcoin!=coin || tokenid!=tmptokenid) + { + CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + } + if (AddNormalinputs(mtx,mypk,txfee,3)==0) fprintf(stderr,"error adding funds for partialsign\n"); + mtx.vin.push_back(CTxIn(tx.GetHash(),0,CScript())); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysPartialOpRet('P',withdrawtxid,refcoin,K+1,mypk,hex))); } -std::string GatewaysCompleteSigning(uint64_t txfee,uint256 withdrawtxid,std::string refcoin,std::string hex) +std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string refcoin,std::string hex) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; + CPubKey mypk,gatewayspk,signerpk,withdrawpub; struct CCcontract_info *cp,C; char funcid,str[65],depositaddr[64]; int64_t amount,totalsupply; + std::string coin,tmphex; CTransaction tx,bindtx; uint256 withdrawtxid,hashBlock,tokenid,tmptokenid,bindtxid,oracletxid; int32_t K=0,numvouts; + uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; + cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); if ( txfee == 0 ) - txfee = 10000; - - mtx.vin.push_back(CTxIn(withdrawtxid,2,CScript())); + txfee = 10000; + if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) + { + CCerror = strprintf("invalid last txid %s\n",uint256_str(str,lasttxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + if (funcid=='W') + { + withdrawtxid=lasttxid; + if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + { + CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,lasttxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + || refcoin!=coin || tokenid!=tmptokenid) + { + CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + } + else if (funcid=='P') + { + if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) + { + CCerror = strprintf("cannot decode partialsign tx opret %s\n",uint256_str(str,lasttxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())==0) + { + CCerror = strprintf("invalid withdraw txid %s\n",uint256_str(str,withdrawtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + { + printf("aaaaaaaaaaa\n"); + CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + || refcoin!=coin || tokenid!=tmptokenid) + { + CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + } + if (AddNormalinputs(mtx,mypk,txfee,3)==0) fprintf(stderr,"error adding funds for completesigning\n"); + mtx.vin.push_back(CTxIn(lasttxid,0,CScript())); mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('C',refcoin,withdrawtxid,hex))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,hex))); } std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; + CPubKey mypk; struct CCcontract_info *cp,C; char str[65],depositaddr[64]; CTransaction tx,bindtx; int32_t numvouts; + uint256 withdrawtxid,bindtxid,oracletxid,tokenid,tmptokenid,hashBlock; std::string coin,hex; + uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; int64_t amount,totalsupply; CPubKey withdrawpub; + cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; + if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) + { + CCerror = strprintf("invalid completesigning txid %s\n",uint256_str(str,completetxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,hex)!='S' || refcoin!=coin) + { + CCerror = strprintf("cannot decode completesigning tx opret %s\n",uint256_str(str,completetxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) + { + CCerror = strprintf("invalid withdraw txid %s\n",uint256_str(str,withdrawtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + { + CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + || refcoin!=coin || tokenid!=tmptokenid) + { + CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } mtx.vin.push_back(CTxIn(completetxid,0,CScript())); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',refcoin,completetxid))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',refcoin,completetxid,withdrawtxid))); +} + +UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) +{ + UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string coin,hex,pub; + CPubKey mypk,gatewayspk,destpub; std::vector pubkeys,publishers; std::vector txids; + uint256 tmpbindtxid,hashBlock,txid,tokenid,oracletxid,cointxid; uint8_t M,N,taddr,prefix,prefix2; + char depositaddr[65],coinaddr[65],str[65],destaddr[65],txidaddr[65]; std::vector proof; + int32_t numvouts,vout,claimvout,height; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; + std::vector > unspentOutputs; + + cp = CCinit(&C,EVAL_GATEWAYS); + mypk = pubkey2pk(Mypubkey()); + gatewayspk = GetUnspendable(cp,0); + _GetCCaddress(coinaddr,EVAL_GATEWAYS,mypk); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin) + { + CCerror = strprintf("invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + nValue = (int64_t)it->second.satoshis; + if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,cointxid,claimvout,hex,proof,destpub,amount) == 'D' + && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(txid,vout) == 0) + { + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("cointxid",uint256_str(str,cointxid))); + obj.push_back(Pair("deposittxid",uint256_str(str,txid))); + CCtxidaddr(txidaddr,txid); + obj.push_back(Pair("deposittxidaddr",txidaddr)); + _GetCCaddress(destaddr,EVAL_TOKENS,destpub); + obj.push_back(Pair("tokens_destination_address",destaddr)); + pub=HexStr(destpub); + obj.push_back(Pair("claim_pubkey",pub)); + obj.push_back(Pair("amount",(double)amount/COIN)); + obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + pending.push_back(obj); + } + } + result.push_back(Pair("coin",refcoin)); + result.push_back(Pair("pending",pending)); + return(result); } UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) { - UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string tmprefcoin; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; - uint256 hashBlock,tokenid,txid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; - char depositaddr[64],coinaddr[64],destaddr[64],str[65],withaddr[64],numstr[32],txidaddr[64],cctxidaddr[64],signeraddr[64]; - int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; + UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string coin,hex; CPubKey mypk,gatewayspk,withdrawpub,signerpk; + std::vector msigpubkeys; uint256 hashBlock,tokenid,txid,tmpbindtxid,tmptokenid,oracletxid,withdrawtxid; uint8_t M,N,taddr,prefix,prefix2; + char funcid,depositaddr[65],coinaddr[65],tokensaddr[65],destaddr[65],str[65],withaddr[65],numstr[32],signeraddr[65],txidaddr[65]; + int32_t i,n,numvouts,vout,queueflag,K; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); + GetTokensCCaddress(cp,tokensaddr,gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); - return(result); + CCerror = strprintf("cant find bindtxid %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || tmprefcoin != refcoin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin ) { - fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),tmprefcoin.c_str()); - return(result); + CCerror = strprintf("invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } n = msigpubkeys.size(); queueflag = 0; @@ -1149,28 +1413,45 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - fprintf(stderr,"%s %d %ld\n",txid.ToString().c_str(),vout,(long)nValue); - if ( vout == 2 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && - DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,withdrawpub,amount) == 'W' && myIsutxo_spentinmempool(txid,vout) == 0) + K=0; + if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(txid,vout) == 0) { - Getscriptaddress(destaddr,tx.vout[0].scriptPubKey); - Getscriptaddress(withaddr,tx.vout[1].scriptPubKey); - if ( strcmp(destaddr,coinaddr) == 0 ) + if (funcid=='W') + { + if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)==0 || refcoin!=coin || tmptokenid!=tokenid || tmpbindtxid!=bindtxid) continue; + } + else if (funcid=='P') + { + if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || GetTransaction(withdrawtxid,tx,hashBlock,false)==0 + || (numvouts=tx.vout.size())<=0 || DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)!='W' + || refcoin!=coin || tmptokenid!=tokenid || tmpbindtxid!=bindtxid) + continue; + } + Getscriptaddress(destaddr,tx.vout[1].scriptPubKey); + Getscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG); + if ( strcmp(destaddr,tokensaddr) == 0 ) { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("txid",uint256_str(str,txid))); - _GetCCaddress(cctxidaddr,EVAL_GATEWAYS,CCtxidaddr(txidaddr,txid)); - obj.push_back(Pair("txidaddr",cctxidaddr)); + obj.push_back(Pair("withdrawtxid",uint256_str(str,tx.GetHash()))); + CCtxidaddr(txidaddr,tx.GetHash()); + obj.push_back(Pair("withdrawtxidaddr",txidaddr)); obj.push_back(Pair("withdrawaddr",withaddr)); - sprintf(numstr,"%.8f",(double)tx.vout[0].nValue/COIN); - obj.push_back(Pair("amount",numstr)); - obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); + obj.push_back(Pair("amount",numstr)); + obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(tx.GetHash()))); if ( queueflag != 0 ) { obj.push_back(Pair("depositaddr",depositaddr)); Getscriptaddress(signeraddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); obj.push_back(Pair("signeraddr",signeraddr)); } + if (N>1) + { + obj.push_back(Pair("number_of_signs",K)); + obj.push_back(Pair("last_txid",uint256_str(str,txid))); + if (K>0) obj.push_back(Pair("hex",hex)); + } pending.push_back(obj); } } @@ -1183,9 +1464,10 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) { - UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string tmprefcoin,hex; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; - uint256 withdrawtxid,hashBlock,txid,tokenid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; - char depositaddr[64],coinaddr[64],str[65],numstr[32],txidaddr[64],cctxidaddr[64],withaddr[64]; + UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string coin,hex; + CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; + uint256 withdrawtxid,hashBlock,txid,tokenid,tmptokenid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; + char depositaddr[65],coinaddr[65],str[65],numstr[32],withaddr[65],txidaddr[65]; int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; std::vector > unspentOutputs; @@ -1194,14 +1476,16 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) gatewayspk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) - { - fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); - return(result); + { + CCerror = strprintf("cant find bindtxid %s\n",uint256_str(str,bindtxid)); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenid,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || tmprefcoin != refcoin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin) { - fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),tmprefcoin.c_str()); - return(result); + CCerror = strprintf("invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); } n = msigpubkeys.size(); queueflag = 0; @@ -1217,20 +1501,21 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - //fprintf(stderr,"%s %d %ld\n",txid.ToString().c_str(),vout,(long)nValue); if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && - DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,tmprefcoin,withdrawtxid,hex) == 'C' && myIsutxo_spentinmempool(txid,vout) == 0) + DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(txid,vout) == 0) { - if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,withdrawpub,amount) == 'W') + if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 + && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin || tmptokenid!=tokenid) { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("txid",uint256_str(str,txid))); - obj.push_back(Pair("withdrawtxid",uint256_str(str,withdrawtxid))); - _GetCCaddress(cctxidaddr,EVAL_GATEWAYS,CCtxidaddr(txidaddr,withdrawtxid)); - obj.push_back(Pair("withdrawtxidaddr",cctxidaddr)); - Getscriptaddress(withaddr,tx.vout[1].scriptPubKey); + obj.push_back(Pair("completesigningtxid",uint256_str(str,txid))); + obj.push_back(Pair("withdrawtxid",uint256_str(str,withdrawtxid))); + CCtxidaddr(txidaddr,withdrawtxid); + obj.push_back(Pair("withdrawtxidaddr",txidaddr)); + Getscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG); obj.push_back(Pair("withdrawaddr",withaddr)); - obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); + obj.push_back(Pair("amount",numstr)); obj.push_back(Pair("hex",hex)); processed.push_back(obj); } @@ -1242,40 +1527,6 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) return(result); } -UniValue GatewaysMultisig(char *cctxidaddr) -{ - std::string parthex,hex,refcoin; uint256 txid,hashBlock; CTransaction tx; int32_t i,maxK,K,numvouts; CPubKey signerpk; - std::vector > unspentOutputs; UniValue result(UniValue::VOBJ); - - SetCCunspents(unspentOutputs,cctxidaddr); - maxK=0; - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - if (GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 && DecodeGatewaysPartialOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,K,signerpk,refcoin,hex) == 'P' && K>maxK ) - { - maxK=K; - parthex=hex; - } - } - - BOOST_FOREACH(const CTxMemPoolEntry &e, mempool.mapTx) - { - const CTransaction &txmempool = e.GetTx(); - const uint256 &hash = txmempool.GetHash(); - - if ((numvouts=txmempool.vout.size()) > 0 && DecodeGatewaysPartialOpRet(txmempool.vout[numvouts-1].scriptPubKey,K,signerpk,refcoin,hex) == 'P' && K>maxK) - { - maxK=K; - parthex=hex; - } - } - - result.push_back(Pair("hex",parthex)); - result.push_back(Pair("number_of_signs",maxK)); - return (result); -} - UniValue GatewaysList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; @@ -1286,7 +1537,7 @@ UniValue GatewaysList() txid = it->first.txhash; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 0 ) + if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 0 ) { result.push_back(uint256_str(str,txid)); } @@ -1298,16 +1549,19 @@ UniValue GatewaysList() UniValue GatewaysInfo(uint256 bindtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaysassets[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t totalsupply,remaining; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaystokens[64]; + uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; + CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t totalsupply,remaining; + result.push_back(Pair("result","success")); result.push_back(Pair("name","Gateways")); cp = CCinit(&C,EVAL_GATEWAYS); Gatewayspk = GetUnspendable(cp,0); - _GetCCaddress(gatewaysassets,EVAL_GATEWAYS,Gatewayspk); + GetTokensCCaddress(cp,gatewaystokens,Gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) { depositaddr[0] = 0; - if ( tx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[tx.vout.size()-1].scriptPubKey,coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 0 && M <= N && N > 0 ) + if ( tx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[tx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 0 && M <= N && N > 0 ) { if ( N > 1 ) { @@ -1326,7 +1580,7 @@ UniValue GatewaysInfo(uint256 bindtxid) result.push_back(Pair("tokenid",uint256_str(str,tokenid))); sprintf(numstr,"%.8f",(double)totalsupply/COIN); result.push_back(Pair("totalsupply",numstr)); - remaining = CCtoken_balance(gatewaysassets,tokenid); + remaining = CCtoken_balance(gatewaystokens,tokenid); sprintf(numstr,"%.8f",(double)remaining/COIN); result.push_back(Pair("remaining",numstr)); sprintf(numstr,"%.8f",(double)(totalsupply - remaining)/COIN); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 82a400e71..208b3cf02 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -478,9 +478,9 @@ static const CRPCCommand vRPCCommands[] = { "gateways", "gatewayspartialsign", &gatewayspartialsign, true }, { "gateways", "gatewayscompletesigning", &gatewayscompletesigning, true }, { "gateways", "gatewaysmarkdone", &gatewaysmarkdone, true }, - { "gateways", "gatewayspending", &gatewayspending, true }, + { "gateways", "gatewayspendingdeposits", &gatewayspendingdeposits, true }, + { "gateways", "gatewayspendingwithdraws", &gatewayspendingwithdraws, true }, { "gateways", "gatewaysprocessed", &gatewaysprocessed, true }, - { "gateways", "gatewaysmultisig", &gatewaysmultisig, true }, // dice { "dice", "dicelist", &dicelist, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 3edc85ebf..b812ccc9d 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -300,9 +300,9 @@ extern UniValue gatewayswithdraw(const UniValue& params, bool fHelp); extern UniValue gatewayspartialsign(const UniValue& params, bool fHelp); extern UniValue gatewayscompletesigning(const UniValue& params, bool fHelp); extern UniValue gatewaysmarkdone(const UniValue& params, bool fHelp); -extern UniValue gatewayspending(const UniValue& params, bool fHelp); +extern UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp); +extern UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp); extern UniValue gatewaysprocessed(const UniValue& params, bool fHelp); -extern UniValue gatewaysmultisig(const UniValue& params, bool fHelp); extern UniValue channelslist(const UniValue& params, bool fHelp); extern UniValue channelsinfo(const UniValue& params, bool fHelp); extern UniValue channelsopen(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e111ad98a..0ffc370e2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6263,11 +6263,23 @@ UniValue gatewaysmarkdone(const UniValue& params, bool fHelp) return(result); } -UniValue gatewayspending(const UniValue& params, bool fHelp) +UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp) { uint256 bindtxid; std::string coin; if ( fHelp || params.size() != 2 ) - throw runtime_error("gatewayspending bindtxid coin\n"); + throw runtime_error("gatewayspendingdeposits bindtxid coin\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + return(GatewaysPendingDeposits(bindtxid,coin)); +} + +UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; std::string coin; + if ( fHelp || params.size() != 2 ) + throw runtime_error("gatewayspendingwithdraws bindtxid coin\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6287,19 +6299,6 @@ UniValue gatewaysprocessed(const UniValue& params, bool fHelp) return(GatewaysProcessedWithdraws(bindtxid,coin)); } -UniValue gatewaysmultisig(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); std::string hex; char *txidaddr; - if ( fHelp || params.size() != 1 ) - throw runtime_error("gatewaysmultisig txidaddr\n"); - if ( ensure_CCrequirements() < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - txidaddr = (char *)params[0].get_str().c_str(); - return(GatewaysMultisig(txidaddr)); -} - UniValue oracleslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) From fef5683d7521da8cc6f2c8aa09f1c89b88c7f1dc Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 28 Jan 2019 14:52:19 +0100 Subject: [PATCH 1521/3904] Refactor CCaddress --- src/wallet/rpcwallet.cpp | 88 +++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0ffc370e2..5616ce5df 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5198,7 +5198,7 @@ int32_t ensure_CCrequirements() UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector &pubkey) { - UniValue result(UniValue::VOBJ); char destaddr[64],str[64]; CPubKey pk; + UniValue result(UniValue::VOBJ); char destaddr[64],str[64]; CPubKey mypk,pk; pk = GetUnspendable(cp,0); GetCCaddress(cp,destaddr,pk); if ( strcmp(destaddr,cp->unspendableCCaddr) != 0 ) @@ -5209,25 +5209,46 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vectorunspendableCCaddr,destaddr); } result.push_back(Pair("result", "success")); - sprintf(str,"%sCCaddress",name); + sprintf(str,"%sCCAddress",name); result.push_back(Pair(str,cp->unspendableCCaddr)); - sprintf(str,"%smarker",name); + sprintf(str,"%sNormalAddress",name); result.push_back(Pair(str,cp->normaladdr)); - result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40")); - if ( _GetCCaddress(destaddr,EVAL_ASSETS,pubkey2pk(pubkey)) > 0 ) + if (strcmp(name,"Gateways")==0) result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40")); + if ((strcmp(name,"Channels")==0 || strcmp(name,"Heir")==0) && pubkey.size() == 33) { - sprintf(str,"%sCCassets",name); + sprintf(str,"%sCC1of2Address",name); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,destaddr,mypk,pubkey2pk(pubkey)); result.push_back(Pair(str,destaddr)); + if (GetTokensCCaddress1of2(cp,destaddr,mypk,pubkey2pk(pubkey))>0) + { + sprintf(str,"%sCC1of2TokensAddress",name); + result.push_back(Pair(str,destaddr)); + } } + else if (strcmp(name,"Tokens")!=0) + { + if (GetTokensCCaddress(cp,destaddr,pk)>0) + { + sprintf(str,"%sCCTokensAddress",name); + result.push_back(Pair(str,destaddr)); + } + } + if ( Getscriptaddress(destaddr,(CScript() << Mypubkey() << OP_CHECKSIG)) != 0 ) + result.push_back(Pair("myAddress",destaddr)); + if ( GetCCaddress(cp,destaddr,pubkey2pk(Mypubkey())) != 0 ) + { + sprintf(str,"myCCAddress(%s)",name); + result.push_back(Pair(str,destaddr)); + } if ( pubkey.size() == 33 ) { if ( GetCCaddress(cp,destaddr,pubkey2pk(pubkey)) != 0 ) - result.push_back(Pair("CCaddress",destaddr)); + { + sprintf(str,"PubkeyCCaddress(%s)",name); + result.push_back(Pair(str,destaddr)); + } } - if ( GetCCaddress(cp,destaddr,pubkey2pk(Mypubkey())) != 0 ) - result.push_back(Pair("myCCaddress",destaddr)); - if ( Getscriptaddress(destaddr,(CScript() << Mypubkey() << OP_CHECKSIG)) != 0 ) - result.push_back(Pair("myaddress",destaddr)); return(result); } @@ -5299,29 +5320,15 @@ UniValue setpubkey(const UniValue& params, bool fHelp) UniValue channelsaddress(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector destpubkey; CPubKey pk,pk2; char destaddr[64]; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector pubkey; + cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 1 ) - throw runtime_error("channelsaddress destpubkey\n"); + throw runtime_error("channelsaddress pubkey\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - destpubkey = ParseHex(params[0].get_str().c_str()); - pk = pubkey2pk(Mypubkey()); - pk2 = pubkey2pk(destpubkey); - result = CCaddress(cp,(char *)"Channels",destpubkey); - result.push_back(Pair("otherpubkey", params[0].get_str())); - GetCCaddress1of2(cp,destaddr,pk,pk2); - result.push_back(Pair("channeladdress",destaddr)); - if ( 0 ) - { - int32_t i; - for (i=0; i<100; i++) - { - GetCCaddress1of2(cp,destaddr,pk,pk2); - fprintf(stderr,"i.%d %s\n",i,destaddr); - } - } - return(result); + pubkey = ParseHex(params[0].get_str().c_str()); + return(CCaddress(cp,(char *)"Channels",pubkey)); } UniValue cclibaddress(const UniValue& params, bool fHelp) @@ -5453,17 +5460,14 @@ UniValue heiraddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; cp = CCinit(&C,EVAL_HEIR); - if ( fHelp || params.size() > 1 ) - throw runtime_error("heiraddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - if ( params.size() == 1 ) - pubkey = ParseHex(params[0].get_str().c_str()); + if ( fHelp || params.size() > 1 ) + throw runtime_error("heiraddress pubkey\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Heir",pubkey)); } - - UniValue lottoaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; @@ -5519,13 +5523,13 @@ UniValue diceaddress(const UniValue& params, bool fHelp) UniValue faucetaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; - int errno; + int error; cp = CCinit(&C,EVAL_FAUCET); if ( fHelp || params.size() > 1 ) throw runtime_error("faucetaddress [pubkey]\n"); - errno = ensure_CCrequirements(); - if ( errno < 0 ) - throw runtime_error(strprintf("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet. ERR=%d\n", errno)); + error = ensure_CCrequirements(); + if ( error < 0 ) + throw runtime_error(strprintf("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet. ERR=%d\n", error)); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Faucet",pubkey)); From c14e0909c6459449464853a018943ef0f42bdd0e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 07:06:00 +0800 Subject: [PATCH 1522/3904] Fix using temp file for receiving blocks. --- src/main.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++--------- src/main.h | 4 +++- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cfa30f44a..86d4504a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3291,7 +3291,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); setDirtyFileInfo.insert(blockPos.nFile); - fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); + //fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); @@ -3754,7 +3754,8 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) { std::vector > vFiles; vFiles.reserve(setDirtyFileInfo.size()); for (set::iterator it = setDirtyFileInfo.begin(); it != setDirtyFileInfo.end(); ) { - vFiles.push_back(make_pair(*it, &vinfoBlockFile[*it])); + if ( *it < TMPFILE_START ) + vFiles.push_back(make_pair(*it, &vinfoBlockFile[*it])); setDirtyFileInfo.erase(it++); } std::vector vBlocks; @@ -4601,11 +4602,15 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u LOCK(cs_LastBlockFile); unsigned int nFile; + if ( tmpflag != 0 ) { ptr = &tmpBlockFiles; nFile = nLastTmpFile; lastfilep = &nLastTmpFile; + if (tmpBlockFiles.size() <= nFile) { + tmpBlockFiles.resize(nFile + 1); + } } else { @@ -4617,7 +4622,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u } } if (!fKnown) { - while ((*ptr)[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { + while ( (*ptr)[nFile].nSize + nAddSize >= ((tmpflag != 0) ? MAX_TEMPFILE_SIZE : MAX_BLOCKFILE_SIZE) ) { nFile++; if ((*ptr).size() <= nFile) { (*ptr).resize(nFile + 1); @@ -4628,13 +4633,39 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u if ( 0 && tmpflag != 0 ) fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } - + if (nFile != *lastfilep) { if (!fKnown) { LogPrintf("Leaving block file %i: %s\n", nFile, (*ptr)[nFile].ToString()); } FlushBlockFile(!fKnown); + fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); + if ( tmpflag != 0 && tmpBlockFiles.size() >= 4 ) + { + if ( nFile == 1 ) + { + PruneOneBlockFile(true,TMPFILE_START+2); + tmpBlockFiles[2].SetNull(); + LogPrintf("Reset tempfile 2\n"); sleep(15); + } + else if ( nFile == 2 ) + { + PruneOneBlockFile(true,TMPFILE_START+3); + tmpBlockFiles[3].SetNull(); + LogPrintf("Reset tempfile 3\n"); sleep(15); + } + } + if ( tmpflag != 0 && nFile == 3 ) + { + PruneOneBlockFile(true,TMPFILE_START); + tmpBlockFiles[0].SetNull(); + PruneOneBlockFile(true,TMPFILE_START+1); + tmpBlockFiles[1].SetNull(); + nFile = 0; + LogPrintf("Reset tempfile 0\n"); sleep(15); + } *lastfilep = nFile; + fprintf(stderr, "*lastfilep = %i\n",*lastfilep);sleep(15); } (*ptr)[nFile].AddBlock(nHeight, nTime); @@ -5232,7 +5263,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } int nHeight = pindex->GetHeight(); - int32_t usetmp = 0; + int32_t usetmp = 1; + // Write block to history file try { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); @@ -5463,8 +5495,9 @@ uint64_t CalculateCurrentUsage() } /* Prune a block file (modify associated database entries)*/ -void PruneOneBlockFile(const int fileNumber) +void PruneOneBlockFile(bool tempfile, const int fileNumber) { + fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { CBlockIndex* pindex = it->second; if (pindex && pindex->nFile == fileNumber) { @@ -5474,7 +5507,11 @@ void PruneOneBlockFile(const int fileNumber) pindex->nDataPos = 0; pindex->nUndoPos = 0; setDirtyBlockIndex.insert(pindex); - + if (pindex->nStatus & BLOCK_IN_TMPFILE != 0 ) + { + // We should be able to clear these blocks from the index as they are not in the main chains block files. + fprintf(stderr, "Block still in tempfile.%i\n",fileNumber); + } // Prune from mapBlocksUnlinked -- any block we prune would have // to be downloaded again in order to consider its chain, at which // point it would be considered as a candidate for @@ -5489,8 +5526,8 @@ void PruneOneBlockFile(const int fileNumber) } } } - - vinfoBlockFile[fileNumber].SetNull(); + if (!tempfile) + vinfoBlockFile[fileNumber].SetNull(); setDirtyFileInfo.insert(fileNumber); } @@ -5538,7 +5575,7 @@ void FindFilesToPrune(std::set& setFilesToPrune) if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) continue; - PruneOneBlockFile(fileNumber); + PruneOneBlockFile(false, fileNumber); // Queue up the files for removal setFilesToPrune.insert(fileNumber); nCurrentUsage -= nBytesToPrune; diff --git a/src/main.h b/src/main.h index d19e3aa17..35de3f4de 100644 --- a/src/main.h +++ b/src/main.h @@ -90,7 +90,8 @@ static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100; /** Default for -txexpirydelta, in number of blocks */ static const unsigned int DEFAULT_TX_EXPIRY_DELTA = 20; /** The maximum size of a blk?????.dat file (since 0.8) */ -static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB +static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB +static const unsigned int MAX_TEMPFILE_SIZE = 0x1000000; // 16 MiB 0x8000000 /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB /** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ @@ -807,6 +808,7 @@ bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHea bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,bool checkPOW); bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW); bool RemoveOrphanedBlocks(int32_t notarized_height); +void PruneOneBlockFile(bool tempfile, const int fileNumber); /** Functions for validating blocks and updating the block tree */ From 6b786278c9bbe5fd897ac1ab20d825cca0acc68b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 07:12:20 +0800 Subject: [PATCH 1523/3904] fix --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 86d4504a0..94b9adf73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4639,20 +4639,20 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u LogPrintf("Leaving block file %i: %s\n", nFile, (*ptr)[nFile].ToString()); } FlushBlockFile(!fKnown); - fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); + //fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); if ( tmpflag != 0 && tmpBlockFiles.size() >= 4 ) { if ( nFile == 1 ) { PruneOneBlockFile(true,TMPFILE_START+2); tmpBlockFiles[2].SetNull(); - LogPrintf("Reset tempfile 2\n"); sleep(15); + LogPrintf("Reset tempfile 2\n"); } else if ( nFile == 2 ) { PruneOneBlockFile(true,TMPFILE_START+3); tmpBlockFiles[3].SetNull(); - LogPrintf("Reset tempfile 3\n"); sleep(15); + LogPrintf("Reset tempfile 3\n"); } } if ( tmpflag != 0 && nFile == 3 ) @@ -4662,10 +4662,10 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u PruneOneBlockFile(true,TMPFILE_START+1); tmpBlockFiles[1].SetNull(); nFile = 0; - LogPrintf("Reset tempfile 0\n"); sleep(15); + LogPrintf("Reset tempfile 0 and 1\n"); } *lastfilep = nFile; - fprintf(stderr, "*lastfilep = %i\n",*lastfilep);sleep(15); + //fprintf(stderr, "*lastfilep = %i\n",*lastfilep); } (*ptr)[nFile].AddBlock(nHeight, nTime); From acf850831ef7e7faee40be71f0df55b2bd25df1b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 07:12:46 +0800 Subject: [PATCH 1524/3904] k --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 94b9adf73..24044b42f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5497,7 +5497,7 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ void PruneOneBlockFile(bool tempfile, const int fileNumber) { - fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); + //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { CBlockIndex* pindex = it->second; if (pindex && pindex->nFile == fileNumber) { From 041c74c0a6feaf6c9fc78d31bf0e4587c81bfa05 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 10:52:56 +0800 Subject: [PATCH 1525/3904] Add print and possible rejection of blocks based on valid/invalid notarisation! --- src/komodo.h | 28 ++++++++++++++++++++-------- src/main.cpp | 6 +++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index af4ea499c..2fd89df3c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -37,7 +37,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); -void komodo_connectblock(CBlockIndex *pindex,CBlock& block); +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_structs.h" #include "komodo_globals.h" @@ -695,6 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); + else + { + fprintf(stderr, "NOT VALID NOTARISATION\n"); + return (-2); + } if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -708,10 +713,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); - if ( 0 && RemoveOrphanedBlocks(*notarizedheightp)) - { - //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); - } + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -798,7 +800,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys return(-1); } -void komodo_connectblock(CBlockIndex *pindex,CBlock& block) +// int32_t ! +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; int32_t staked_era; static int32_t lastStakedEra; @@ -809,7 +812,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( pindex == 0 ) { fprintf(stderr,"komodo_connectblock null pindex\n"); - return; + return -1; } memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); @@ -817,7 +820,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) { fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); - return; + return -1; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) @@ -858,6 +861,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->GetHeight()); + int transaction = 0; if ( pindex != 0 ) { height = pindex->GetHeight(); @@ -913,6 +917,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } + transaction = i; printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; @@ -938,10 +943,13 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("%.8f ",dstr(block.vtx[i].vout[j].nValue)); len = block.vtx[i].vout[j].scriptPubKey.size(); + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); + if ( notaryid == -2 ) + return(-1); if ( 0 && i > 0 ) { for (k=0; kGetHeight()); + if (notarized = 1) + return(transaction); + else + return(-1); } diff --git a/src/main.cpp b/src/main.cpp index 24044b42f..e4690292e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3684,7 +3684,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); - komodo_connectblock(pindex,*(CBlock *)&block); + int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; + if ( tmp > 0 ) + { + printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),tmp); + } return true; } From ff22a1aedbc554b5036eafa25f987ff12fded467 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 21:30:42 -1100 Subject: [PATCH 1526/3904] Priv2addr --- src/cc/CCinclude.h | 2 + src/cc/CCutils.cpp | 24 ++- src/cc/sudoku.cpp | 476 +++++++++++++++++++++++++++++++++++++++++++++ src/key.cpp | 16 ++ src/key.h | 1 + 5 files changed, 517 insertions(+), 2 deletions(-) create mode 100644 src/cc/sudoku.cpp diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 66c001969..5d847800a 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -42,6 +42,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #include #include "../script/standard.h" #include "../base58.h" +#include "../key.h" #include "../core_io.h" #include "../script/sign.h" #include "../wallet/wallet.h" @@ -179,6 +180,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); // CCutils +bool priv2addr(char *coinaddr,uint8_t buf33[33],uint8_t priv32[32]); CPubKey buf2pk(uint8_t *buf33); void endiancpy(uint8_t *dest,uint8_t *src,int32_t len); uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t entropyvout,int32_t usevout); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 766ce1188..6dff5d3cd 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -442,6 +442,20 @@ bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t n return(true); } +bool priv2addr(char *coinaddr,uint8_t *buf33,uint8_t priv32[32]) +{ + CKey priv; CPubKey pk; int32_t i; uint8_t *src; + priv.SetKey32(priv32); + pk = priv.GetPubKey(); + if ( buf33 != 0 ) + { + src = (uint8_t *)pk.begin(); + for (i=0; i<33; i++) + buf33[i] = src[i]; + } + return(Getscriptaddress(coinaddr, CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG)); +} + std::vector Mypubkey() { extern uint8_t NOTARY_PUBKEY33[33]; @@ -456,7 +470,7 @@ std::vector Mypubkey() bool Myprivkey(uint8_t myprivkey[]) { - char coinaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; + char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33]; if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 ) { n = (int32_t)strlen(coinaddr); @@ -477,7 +491,13 @@ bool Myprivkey(uint8_t myprivkey[]) fprintf(stderr,"0x%02x, ",myprivkey[i]); fprintf(stderr," found privkey for %s!\n",dest); } - return(true); + if ( priv2addr(checkaddr,buf33,myprivkey) != 0 ) + { + if ( buf2pk(buf33) == Mypubkey() && strcmp(checkaddr,coinaddr) == 0 ) + return(true); + else printf("mismatched privkey -> addr %s vs %s\n",checkaddr,coinaddr); + } + return(false); } #endif } diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp new file mode 100644 index 000000000..a79e3d161 --- /dev/null +++ b/src/cc/sudoku.cpp @@ -0,0 +1,476 @@ + +// start https://github.com/mentalmove/SudokuGenerator +// +// main.c +// SudokuGenerator +// +// Malte Pagel +// + +#include +#include +#include +#include +#include + + +#define SMALL_LINE 3 +#define LINE 9 +#define TOTAL 81 + +#define LIMIT 16777216 + +#define SHOW_SOLVED 1 + + +struct dimensions_collection { + int row; + int column; + int small_square; +}; + + +static int indices[TOTAL]; +static int riddle[TOTAL]; +static int solved[TOTAL]; +static int unsolved[TOTAL]; +static int tries_to_set = 0; +static int taking_back; +static int global_unset_count = 0; + + +struct dimensions_collection get_collection(int); +int contains_element(int*, int, int); +void get_horizontal(int, int*); +void get_vertical(int, int*); +void get_square(int, int*); +int set_values(int, int); +void take_back(int); + +int show_solution(int*); + + +int show_solution (int* solution) { + + int i; + int counter = 0; + + printf( " -----------------------------------\n" ); + + for ( i = 0; i < TOTAL; i++ ) { + if ( i % LINE == 0 ) + printf( "|" ); + + if ( solution[i] ) { + printf( " %d ", solution[i]); + counter++; + } + else + printf( " "); + + if ( i % LINE == (LINE - 1) ) { + printf( "|\n" ); + if ( i != (TOTAL - 1) ) { + if ( i % (SMALL_LINE * LINE) == (SMALL_LINE * LINE - 1) ) + printf( "|-----------+-----------+-----------|\n" ); + else + printf( "|- - - - - -|- - - - - -|- - - - - -|\n" ); + } + } + else { + if ( i % SMALL_LINE == (SMALL_LINE - 1) ) + printf( "|"); + else + printf( ":" ); + } + } + + printf( " -----------------------------------" ); + + return counter; +} + + +/** + * Takes a position inside the large square and returns + * - the row number + * - the column number + * - the small square number + * where this position is situated in + */ +struct dimensions_collection get_collection (int index) { + struct dimensions_collection ret; + + ret.row = (int) (index / LINE); + ret.column = index % LINE; + ret.small_square = SMALL_LINE * (int) (ret.row / SMALL_LINE) + (int) (ret.column / SMALL_LINE); + + return ret; +} + +/** + * Is 'the_element' in 'the_array'? + */ +int contains_element (int* the_array, int the_element, int length) { + for ( int i = 0; i < length; i++ ) + if ( the_array[i] == the_element ) + return 1; + return 0; +} + +/** + * Sets all members of row 'row' + */ +void get_horizontal (int row, int* ret) { + int j = 0; + for ( int i = (row * LINE); i < (row * LINE) + LINE; i++ ) + ret[j++] = riddle[i]; +} +/** + * Sets all members of column 'col' + */ +void get_vertical (int col, int* ret) { + int j = 0; + for ( int i = col; i < TOTAL; i += LINE ) + ret[j++] = riddle[i]; +} +/** + * Sets all members of small square 'which' + */ +void get_square (int which, int* ret) { + for ( int i = 0; i < SMALL_LINE; i++ ) + for ( int j = 0; j < SMALL_LINE; j++ ) + ret[SMALL_LINE * i + j] = riddle[LINE * i + which * SMALL_LINE + j + ((int) (which / SMALL_LINE) * (SMALL_LINE - 1) * LINE)]; +} + +/** + * Recursive function: + * Try for each position the numbers from 1 to LINE + * (except 'forbidden_number' if given). + * If all numbers collide with already set numbers, move is bad. + * If a number doesn't collide with already set numbers, + * - move is bad if next move collides with the already set numbers + * (including actual one) + * - move is good if it's the last one + */ +int set_values (int index, int forbidden_number) { + + if ( taking_back && tries_to_set > (2 * LIMIT) ) + return 1; + + int real_index = indices[index]; + struct dimensions_collection blocks = get_collection(real_index); + int elements[LINE]; + + for ( int i = 1; i <= LINE; i++ ) { + if ( forbidden_number && i == forbidden_number ) + continue; + + tries_to_set++; + + get_horizontal(blocks.row, elements); + if ( contains_element(elements, i, LINE) ) + continue; + + get_vertical(blocks.column, elements); + if ( contains_element(elements, i, LINE) ) + continue; + + get_square(blocks.small_square, elements); + if ( contains_element(elements, i, LINE) ) + continue; + + riddle[real_index] = i; + + if ( index == (TOTAL - 1) || set_values((index + 1), 0) ) + return 1; + } + + riddle[real_index] = 0; + + return 0; +} + +/** + * Some steps to hide unnecessary numbers: + * a) Define last piece as 'special piece' + * b) Remember this piece's value + * c) Try to create riddle from this position on, + * but forbid the value of the special piece + * d) I) If operation fails, define the piece before the special piece + * as 'special piece' and continue with b) + * II) If operation is possible, reset 'special piece' + * and put it to start of list + * e) Stop if all pieces are tried or calculation limit is reached + */ +void take_back (int unset_count) { + + global_unset_count++; + + int i; + + int tmp = riddle[indices[TOTAL - unset_count]]; + int redundant = set_values((TOTAL - unset_count), tmp); + + if ( !redundant ) { + unsolved[indices[TOTAL - unset_count]] = 0; + take_back(++unset_count); + } + else { + riddle[indices[TOTAL - unset_count]] = tmp; + for ( i = 1; i < unset_count; i++ ) + riddle[indices[TOTAL - unset_count + i]] = 0; + + for ( i = (TOTAL - unset_count); i > 0; i-- ) + indices[i] = indices[i - 1]; + indices[0] = tmp; + + if ( global_unset_count < TOTAL && tries_to_set < LIMIT ) + take_back(unset_count); + } +} + + +int sudoku(uint8_t solved9[LINE][LINE],uint8_t unsolved9[LINE][LINE],uint32_t srandi) +{ + int i, j, random, small_rows, small_cols, tmp, redundant,ind; + int multi_raw[LINE][LINE]; + + memset(indices,0,sizeof(indices)); + memset(solved,0,sizeof(solved)); + memset(unsolved,0,sizeof(unsolved)); + tries_to_set = 0; + taking_back = 0; + global_unset_count = 0; + + //time_t t; + //time(&t); + srand(srandi); + + /** + * Initialization: + * Fields are set to 0 ( i.e. we dont' know the number yet) + */ + for ( i = 0; i < TOTAL; i++ ) + riddle[i] = 0; + + /** + * Second initialization: + * LINE times numbers from 0 to (LINE - 1), + * i.e. every square + */ + int big_rows_array[] = {0, 1, 2}; + int big_cols_array[] = {0, 1, 2}; + random = rand() % 4; + switch (random) { + case 1: + big_rows_array[0] = 2; + big_rows_array[1] = 1; + big_rows_array[2] = 0; + break; + case 2: + big_cols_array[0] = 2; + big_cols_array[1] = 1; + big_cols_array[2] = 0; + break; + case 3: + big_rows_array[0] = 2; + big_rows_array[1] = 1; + big_rows_array[2] = 0; + big_cols_array[0] = 2; + big_cols_array[1] = 1; + big_cols_array[2] = 0; + } + int big_rows, big_cols, big_rows_index, big_cols_index, start_value; + i = 0; + j = 0; + for ( big_rows_index = 0; big_rows_index < SMALL_LINE; big_rows_index++ ) { + big_rows = big_rows_array[big_rows_index]; + for ( big_cols_index = 0; big_cols_index < SMALL_LINE; big_cols_index++ ) { + big_cols = big_cols_array[big_cols_index]; + start_value = big_rows * LINE * SMALL_LINE + (big_cols * SMALL_LINE); + for ( small_rows = 0; small_rows < SMALL_LINE; small_rows++ ) + for ( small_cols = 0; small_cols < SMALL_LINE; small_cols++ ) + multi_raw[i][j++] = small_rows * LINE + small_cols + start_value; + i++; + j = 0; + } + } + + + /** + * Randomization for every element of multi_raw. + * Suffle only inside squares + */ + for ( i = 0; i < LINE; i++ ) { + for ( j = 0; j < LINE; j++ ) { + random = rand() % LINE; + if ( j == random ) + continue; + tmp = multi_raw[i][j]; + multi_raw[i][j] = multi_raw[i][random]; + multi_raw[i][random] = tmp; + } + } + + /** + * Linearization + */ + for ( i = 0; i < LINE; i++ ) + for ( j = 0; j < LINE; j++ ) + indices[i * LINE + j] = multi_raw[i][j]; + + + /** + * Setting numbers, start with the first one. + * Variable 'redundant' is needed only for formal reasons + */ + taking_back = 0; + redundant = set_values(0, 0); + + + memcpy(solved, riddle, (TOTAL * sizeof(int))); + memcpy(unsolved, riddle, (TOTAL * sizeof(int))); + + + /** + * Exchanging some (few) indices for more randomized game + */ + int random2; + for ( i = (LINE - 1); i > 0; i-- ) { + for ( j = 0; j < (int) (sqrt(i)); j++ ) { + + if ( !(rand() % ((int) (i * sqrt(i)))) || !(LINE - j) ) + continue; + + random = i * LINE + (int) (rand() % (LINE - j)); + random2 = rand() % TOTAL; + + if ( random == random2 ) + continue; + + tmp = indices[random]; + indices[random] = indices[random2]; + indices[random2] = tmp; + } + } + + + tries_to_set = 0; + taking_back = 1; + take_back(1); + + + if ( SHOW_SOLVED ) { + printf( "\n\n" ); + redundant = show_solution(solved); + } + + int counter = show_solution(unsolved); + printf( "\t *** %d numbers left *** \n", counter ); + ind = 0; + for (i=0; i=0; j--) + { + x *= 9; + x += vals9[i][j]-1; + } + if ( i < 8 ) + keyvals[i] = x; + else + { + for (j=0; j<8; j++) + keyvals[j] += SUDOKU_NINETH * (vals9[i][j]-1); + } + } + for (i=ind=0; i<8; i++) + { + privkey[ind++] = ((keyvals[i] >> 24) & 0xff); + privkey[ind++] = ((keyvals[i] >> 16) & 0xff); + privkey[ind++] = ((keyvals[i] >> 8) & 0xff); + privkey[ind++] = (keyvals[i] & 0xff); + } +} + +void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) +{ + uint8_t vals9[9][9],uniq9[9][9]; int32_t i,j; + sudoku(vals9,unsolved,srandi); + sudoku_privkey(key32,vals9); + sudoku_privkeydisp(key32); +} diff --git a/src/key.cpp b/src/key.cpp index 3b6fed81b..6e2370dc2 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -179,6 +179,22 @@ void CKey::MakeNewKey(bool fCompressedIn) { fCompressed = fCompressedIn; } +int32_t CKey::SetKey32(uint8_t Key32[32]) +{ + memcpy(vch,Key32,32); + fCompressed = true; + if ( Check(vch) == 0 ) + { + fValid = false; + return(-1); + } + else + { + fValid = true; + return(0); + } +} + bool CKey::SetPrivKey(const CPrivKey &privkey, bool fCompressedIn) { if (!ec_privkey_import_der(secp256k1_context_sign, (unsigned char*)begin(), &privkey[0], privkey.size())) return false; diff --git a/src/key.h b/src/key.h index c41208003..857e8a8ae 100644 --- a/src/key.h +++ b/src/key.h @@ -128,6 +128,7 @@ public: //! Generate a new private key using a cryptographic PRNG. void MakeNewKey(bool fCompressed); + int32_t SetKey32(uint8_t Key32[32]); /** * Convert the private key to a CPrivKey (serialized OpenSSL private key data). From c7fa58b74a2d212cb90baca5c34c18fcac230e40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 22:16:22 -1100 Subject: [PATCH 1527/3904] Check cclib addr --- src/cc/CCcustom.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 577332b63..7d6d80043 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -245,7 +245,7 @@ uint8_t CClibCCpriv[32] = { 0x57, 0xcf, 0x49, 0x71, 0x7d, 0xb4, 0x15, 0x1b, 0x4f int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) { - CPubKey pk; uint8_t pub33[33]; char CCaddr[64]; + CPubKey pk; uint8_t pub33[33],check33[33]; char CCaddr[64],checkaddr[64],str[67]; if ( evalcode == EVAL_FIRSTUSER ) // eventually make a hashchain for each evalcode { cp->evalcode = evalcode; @@ -258,7 +258,14 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) if ( strcmp(cp->normaladdr,CClibNormaladdr) != 0 ) fprintf(stderr,"CClib_initcp addr mismatch %s vs %s\n",cp->normaladdr,CClibNormaladdr); GetCCaddress(cp,cp->unspendableCCaddr,pk); - return(0); + if ( priv2addr(checkaddr,check33,myprivkey) != 0 ) + { + if ( buf2pk(check33) == pk && strcmp(checkaddr,cp->normaladdr) == 0 ) + { + fprinf(stderr,"verified evalcode.%d %s %s\n",cp->evalcode,checkaddr,pubkey33_str(str,pub33)); + return(0); + } else fprintf(stderr,"CClib_initcp mismatched privkey -> addr %s vs %s\n",checkaddr,cp->normaladdr); + } } return(-1); } From 980a5efbafaeddff9d33f8dae54636a612c0c40f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 22:22:54 -1100 Subject: [PATCH 1528/3904] Syntax --- src/cc/CCcustom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 7d6d80043..e60ed2997 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -258,11 +258,11 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) if ( strcmp(cp->normaladdr,CClibNormaladdr) != 0 ) fprintf(stderr,"CClib_initcp addr mismatch %s vs %s\n",cp->normaladdr,CClibNormaladdr); GetCCaddress(cp,cp->unspendableCCaddr,pk); - if ( priv2addr(checkaddr,check33,myprivkey) != 0 ) + if ( priv2addr(checkaddr,check33,cp->CCpriv) != 0 ) { if ( buf2pk(check33) == pk && strcmp(checkaddr,cp->normaladdr) == 0 ) { - fprinf(stderr,"verified evalcode.%d %s %s\n",cp->evalcode,checkaddr,pubkey33_str(str,pub33)); + fprintf(stderr,"verified evalcode.%d %s %s\n",cp->evalcode,checkaddr,pubkey33_str(str,pub33)); return(0); } else fprintf(stderr,"CClib_initcp mismatched privkey -> addr %s vs %s\n",checkaddr,cp->normaladdr); } From 886003602724ed4a3ae9ac8058f7013ac770b458 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 22:36:34 -1100 Subject: [PATCH 1529/3904] Autocalc all cclib cp --- src/cc/CCcustom.cpp | 24 ++++++++++++++++++++---- src/wallet/rpcwallet.cpp | 19 +++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index e60ed2997..e00b5a0a0 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -245,13 +245,13 @@ uint8_t CClibCCpriv[32] = { 0x57, 0xcf, 0x49, 0x71, 0x7d, 0xb4, 0x15, 0x1b, 0x4f int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) { - CPubKey pk; uint8_t pub33[33],check33[33]; char CCaddr[64],checkaddr[64],str[67]; + CPubKey pk; int32_t i; uint8_t pub33[33],check33[33],hash[32]; char CCaddr[64],checkaddr[64],str[67]; + cp->evalcode = evalcode; + cp->ismyvin = IsCClibInput; + memcpy(cp->CCpriv,CClibCCpriv,32); if ( evalcode == EVAL_FIRSTUSER ) // eventually make a hashchain for each evalcode { - cp->evalcode = evalcode; - cp->ismyvin = IsCClibInput; strcpy(cp->CChexstr,CClibCChexstr); - memcpy(cp->CCpriv,CClibCCpriv,32); decode_hex(pub33,33,cp->CChexstr); pk = buf2pk(pub33); Getscriptaddress(cp->normaladdr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); @@ -267,6 +267,22 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) } else fprintf(stderr,"CClib_initcp mismatched privkey -> addr %s vs %s\n",checkaddr,cp->normaladdr); } } + else + { + for (i=EVAL_FIRSTUSER; iCCpriv,32); + memcpy(cp->CCpriv,hash,32); + } + if ( priv2addr(cp->normaladdr,pub33,cp->CCpriv) != 0 ) + { + pk = buf2pk(pub33); + for (i=0; i<33; i++) + sprintf(&cp->CChexstr[i*2],"%02x",pub33[i]); + cp->CChexstr[i*2] = 0; + GetCCaddress(cp,cp->unspendableCCaddr,pk); + } + } return(-1); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0ffc370e2..b799c6672 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5327,13 +5327,20 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) UniValue cclibaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; - cp = CCinit(&C,EVAL_FIRSTUSER); - if ( fHelp || params.size() > 1 ) - throw runtime_error("cclibaddress [pubkey]\n"); + if ( fHelp || params.size() > 2 ) + throw runtime_error("cclibaddress [evalcode] [pubkey]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - if ( params.size() == 1 ) - pubkey = ParseHex(params[0].get_str().c_str()); + cp = CCinit(&C,EVAL_FIRSTUSER); + if ( params.size() >= 1 ) + { + evalcode = atoi(params[0].get_str().c_str()); + if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER ) + throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); + cp = CCinit(&C,evalcode); + if ( params.size() == 2 ) + pubkey = ParseHex(params[1].get_str().c_str()); + } return(CCaddress(cp,(char *)"CClib",pubkey)); } @@ -7695,4 +7702,4 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_HEIR); return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); -} \ No newline at end of file +} From 534c5ee516354074a029643cb48b3f4534cf5f4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 22:38:06 -1100 Subject: [PATCH 1530/3904] Err --- src/wallet/rpcwallet.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b799c6672..2d4ba25d7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5326,21 +5326,22 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) UniValue cclibaddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector pubkey; uint8_t evalcode = EVAL_FIRSTUSER; if ( fHelp || params.size() > 2 ) throw runtime_error("cclibaddress [evalcode] [pubkey]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - cp = CCinit(&C,EVAL_FIRSTUSER); if ( params.size() >= 1 ) { evalcode = atoi(params[0].get_str().c_str()); if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER ) throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); - cp = CCinit(&C,evalcode); if ( params.size() == 2 ) pubkey = ParseHex(params[1].get_str().c_str()); } + cp = CCinit(&C,evalcode); + if ( cp == 0 ) + throw runtime_error("error creating *cp\n"); return(CCaddress(cp,(char *)"CClib",pubkey)); } From 42a362165ff2f8a209ee74e2ca6f84ac2c047d3f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 22:43:52 -1100 Subject: [PATCH 1531/3904] Add [evalcode] to cclib roc --- src/cc/CCcustom.cpp | 1 + src/wallet/rpcwallet.cpp | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index e00b5a0a0..477487390 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -281,6 +281,7 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) sprintf(&cp->CChexstr[i*2],"%02x",pub33[i]); cp->CChexstr[i*2] = 0; GetCCaddress(cp,cp->unspendableCCaddr,pk); + return(0); } } return(-1); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2d4ba25d7..c6370d762 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5347,25 +5347,39 @@ UniValue cclibaddress(const UniValue& params, bool fHelp) UniValue cclibinfo(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_FIRSTUSER); + struct CCcontract_info *cp,C; uint8_t evalcode = EVAL_FIRSTUSER; if ( fHelp || params.size() > 0 ) throw runtime_error("cclibinfo\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + if ( params.size() >= 1 ) + { + evalcode = atoi(params[0].get_str().c_str()); + if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER ) + throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); + } + cp = CCinit(&C,evalcode); return(CClib_info(cp)); } UniValue cclib(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *method; cJSON *jsonparams; + struct CCcontract_info *cp,C; char *method; cJSON *jsonparams=0; uint8_t evalcode; cp = CCinit(&C,EVAL_FIRSTUSER); - if ( fHelp || params.size() > 2 ) - throw runtime_error("cclib method [JSON params]\n"); + if ( fHelp || params.size() > 3 ) + throw runtime_error("cclib method [evalcode] [JSON params]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); method = (char *)params[0].get_str().c_str(); - jsonparams = cJSON_Parse(params[1].get_str().c_str()); + if ( params.size() >= 1 ) + { + evalcode = atoi(params[1].get_str().c_str()); + if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER ) + throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); + if ( params.size() == 2 ) + jsonparams = cJSON_Parse(params[2].get_str().c_str()); + } + cp = CCinit(&C,evalcode); return(CClib(cp,method,jsonparams)); } From 087d590f36b5e62db7508f2807df9d6cca372e9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 23:35:17 -1100 Subject: [PATCH 1532/3904] Link in sudoku --- src/cc/Makefile | 2 +- src/cc/cclib.cpp | 79 ++++++++++++++++++++++++++++++++++++----------- src/cc/makecclib | 2 +- src/cc/sudoku.cpp | 52 +++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 20 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 52db18fca..97798e41e 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -13,7 +13,7 @@ $(info $(OS)) TARGET = ../libcc.so TARGET_DARWIN = ../libcc.dylib TARGET_WIN = ../libcc.dll -SOURCES = cclib.cpp +SOURCES = cclib.cpp sudoku.cpp #HEADERS = $(shell echo ../cryptoconditions/include/*.h) all: $(TARGET) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 971258d90..2875ce4b0 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -28,24 +28,63 @@ #include "crosschain.h" #define FAUCET2SIZE COIN +#defein EVAL_FAUCET2 EVAL_FIRSTUSER +#define EVAL_SUDOKU 17 + +std::string MYCCLIBNAME = (char *)"sudoku"; +char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } struct CClib_rpcinfo { - char *method,*help; + char *CCname,*method,*help; int32_t numrequiredargs,maxargs; // frontloaded with required - uint8_t funcid; + uint8_t funcid,evalcode; } CClib_methods[] = { - { (char *)"faucet2_fund", (char *)"amount", 1, 1, 'F' }, - { (char *)"faucet2_get", (char *)"", 0, 0, 'G' }, + { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, + { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, + { (char *)"sudoku", (char *)"gen", (char *)"amount", 1, 1, 'G', EVAL_SUDOKU }, + { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, + { (char *)"sudoku", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_SUDOKU }, + { (char *)"sudoku", (char *)"solution", (char *)"solution timestamps[]", 2, 2, 'S', EVAL_SUDOKU }, }; -std::string MYCCLIBNAME = (char *)"faucet2"; - -char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } - std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); +UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params); +UniValue sudoku_generate(struct CCcontract_info *cp,cJSON *params); +UniValue sudoku_solution(struct CCcontract_info *cp,cJSON *params); +UniValue sudoku_pending(struct CCcontract_info *cp,cJSON *params); + +UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + if ( cp->evalcode == EVAL_SUDOKU ) + { + if ( strcmp(method,"txidinfo") == 0 ) + return(sudoku_txidinfo(cp,params)); + else if ( strcmp(method,"gen") == 0 ) + return(sudoku_generate(cp,params)); + else if ( strcmp(method,"solution") == 0 ) + return(sudoku_solution(cp,params)); + else if ( strcmp(method,"pending") == 0 ) + return(sudoku_pending(cp,params)); + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid sudoku method")); + result.push_back(Pair("method",method)); + return(result); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","only sudoku supported for now")); + result.push_back(Pair("evalcode",(int)cp->evalcode)); + return(result); + } +} UniValue CClib_info(struct CCcontract_info *cp) { @@ -55,6 +94,7 @@ UniValue CClib_info(struct CCcontract_info *cp) for (i=0; i= 128 ) obj.push_back(Pair("funcid",CClib_methods[i].funcid)); else @@ -63,7 +103,8 @@ UniValue CClib_info(struct CCcontract_info *cp) str[1] = 0; obj.push_back(Pair("funcid",str)); } - obj.push_back(Pair("name",CClib_methods[i].method)); + obj.push_back(Pair("name",CClib_methods[i].CCname)); + obj.push_back(Pair("method",CClib_methods[i].method)); obj.push_back(Pair("help",CClib_methods[i].help)); obj.push_back(Pair("params_required",CClib_methods[i].numrequiredargs)); obj.push_back(Pair("params_max",CClib_methods[i].maxargs)); @@ -78,13 +119,16 @@ UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; for (i=0; ievalcode == CClib_methods[i].evalcode && strcmp(method,CClib_methods[i].method) == 0 ) { - result.push_back(Pair("result","success")); - result.push_back(Pair("method",CClib_methods[i].method)); - rawtx = CClib_rawtxgen(cp,CClib_methods[i].funcid,params); - result.push_back(Pair("rawtx",rawtx)); - return(result); + if ( cp->evalcode == EVAL_FAUCET2 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("method",CClib_methods[i].method)); + rawtx = CClib_rawtxgen(cp,CClib_methods[i].funcid,params); + result.push_back(Pair("rawtx",rawtx)); + return(result); + } else return(CClib_method(cp,method,params)); } } result.push_back(Pair("result","error")); @@ -234,7 +278,6 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } - std::string Faucet2Fund(struct CCcontract_info *cp,uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -289,14 +332,14 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para if ( inputs > nValue ) CCchange = (inputs - nValue - txfee); if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_FIRSTUSER,CCchange,cclibpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET2,CCchange,cclibpk)); mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); fprintf(stderr,"start at %u\n",(uint32_t)time(NULL)); j = rand() & 0xfffffff; for (i=0; i<1000000; i++,j++) { tmpmtx = mtx; - rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_FIRSTUSER << (uint8_t)'G' << j)); + rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_FAUCET2 << (uint8_t)'G' << j)); if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 ) { len >>= 1; diff --git a/src/cc/makecclib b/src/cc/makecclib index 47aec377d..6131148f1 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1 +1 @@ -gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../cclib.so cclib.cpp +gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../cclib.so cclib.cpp sudoku.cpp diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a79e3d161..6e54d0709 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -474,3 +474,55 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) sudoku_privkey(key32,vals9); sudoku_privkeydisp(key32); } + +//////////////////////// start of CClib interface +#include +#include + +#include "primitives/block.h" +#include "primitives/transaction.h" +#include "script/cc.h" +#include "cc/eval.h" +#include "cc/utils.h" +#include "cc/CCinclude.h" +#include "main.h" +#include "chain.h" +#include "core_io.h" +#include "crosschain.h" + +UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + if ( params != 0 ) + printf("params.(%s)\n",jprint(params,0)); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue sudoku_generate(struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + if ( params != 0 ) + printf("params.(%s)\n",jprint(params,0)); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue sudoku_solution(struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + if ( params != 0 ) + printf("params.(%s)\n",jprint(params,0)); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue sudoku_pending(struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + if ( params != 0 ) + printf("params.(%s)\n",jprint(params,0)); + result.push_back(Pair("result","success")); + return(result); +} + From 6999011a90e945a716cd9a1e96006a3cbd83e8d6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 23:37:17 -1100 Subject: [PATCH 1533/3904] #include sudoku.cpp as linker errors --- src/cc/Makefile | 2 +- src/cc/cclib.cpp | 3 +++ src/cc/makecclib | 2 +- src/cc/sudoku.cpp | 13 ------------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 97798e41e..3e988f279 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -13,7 +13,7 @@ $(info $(OS)) TARGET = ../libcc.so TARGET_DARWIN = ../libcc.dylib TARGET_WIN = ../libcc.dll -SOURCES = cclib.cpp sudoku.cpp +SOURCES = cclib.cpp #HEADERS = $(shell echo ../cryptoconditions/include/*.h) all: $(TARGET) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 2875ce4b0..06982fe92 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -358,3 +358,6 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para } else fprintf(stderr,"cant find faucet inputs\n"); return(""); } + +#include "sudoku.cpp" + diff --git a/src/cc/makecclib b/src/cc/makecclib index 6131148f1..47aec377d 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1 +1 @@ -gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../cclib.so cclib.cpp sudoku.cpp +gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../cclib.so cclib.cpp diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 6e54d0709..c5cbc1b31 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -476,19 +476,6 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) } //////////////////////// start of CClib interface -#include -#include - -#include "primitives/block.h" -#include "primitives/transaction.h" -#include "script/cc.h" -#include "cc/eval.h" -#include "cc/utils.h" -#include "cc/CCinclude.h" -#include "main.h" -#include "chain.h" -#include "core_io.h" -#include "crosschain.h" UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params) { From 2c7d564a908534530727dabf22f940c29f7e5afc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 23:38:14 -1100 Subject: [PATCH 1534/3904] Define --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 06982fe92..4405cda87 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -28,7 +28,7 @@ #include "crosschain.h" #define FAUCET2SIZE COIN -#defein EVAL_FAUCET2 EVAL_FIRSTUSER +#define EVAL_FAUCET2 EVAL_FIRSTUSER #define EVAL_SUDOKU 17 std::string MYCCLIBNAME = (char *)"sudoku"; From 72c4217d3904592f8bdbb4b4268ca208e49ddc53 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 23:54:41 -1100 Subject: [PATCH 1535/3904] +print --- src/wallet/rpcwallet.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c6370d762..1ea66bb5e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5174,11 +5174,20 @@ int32_t ensure_CCrequirements() { CCerror = ""; if ( NOTARY_PUBKEY33[0] == 0 ) + { + fprintf(stderr,"no -pubkey set\n"); return(-1); + } else if ( GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX) == 0 ) + { + fprintf(stderr,"no -addressindex\n"); return(-1); + } else if ( GetBoolArg("-spentindex", DEFAULT_SPENTINDEX) == 0 ) + { + fprintf(stderr,"no -spentindex\n"); return(-1); + } else return(0); } From 47294fb7362fc94b3c6cca6e93f4fda7bcf85a87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Jan 2019 23:59:13 -1100 Subject: [PATCH 1536/3904] -pubkey --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 96c9cd922..5b3a6cd39 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1671,6 +1671,7 @@ void komodo_args(char *argv0) KOMODO_DEALERNODE = GetArg("-dealer",0); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { + decode_hex(NOTARY_PUBKEY33,33,NOTARY_PUBKEY.c_str()); USE_EXTERNAL_PUBKEY = 1; if ( IS_KOMODO_NOTARY == 0 ) { From 7b24fb0d45cec28654833f7264cc50b4dc8848c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:00:17 -1100 Subject: [PATCH 1537/3904] (Char *) --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5b3a6cd39..bcd95e698 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1671,7 +1671,7 @@ void komodo_args(char *argv0) KOMODO_DEALERNODE = GetArg("-dealer",0); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { - decode_hex(NOTARY_PUBKEY33,33,NOTARY_PUBKEY.c_str()); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); USE_EXTERNAL_PUBKEY = 1; if ( IS_KOMODO_NOTARY == 0 ) { From 812d9235ebc476516c339b235c69d4e782facff9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:04:50 -1100 Subject: [PATCH 1538/3904] Test --- src/wallet/rpcwallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1ea66bb5e..bc10da7bc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5384,7 +5384,10 @@ UniValue cclib(const UniValue& params, bool fHelp) { evalcode = atoi(params[1].get_str().c_str()); if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER ) + { + printf("evalcode.%d vs (%d, %d)\n",evalcode,EVAL_FIRSTUSER,EVAL_LASTUSER); throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); + } if ( params.size() == 2 ) jsonparams = cJSON_Parse(params[2].get_str().c_str()); } From a614b0555fa02c176a570c007701b86f4ddbba0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:10:42 -1100 Subject: [PATCH 1539/3904] Prints --- src/cc/CCcustom.cpp | 1 + src/cc/sudoku.cpp | 4 ++++ src/wallet/rpcwallet.cpp | 10 ++-------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 477487390..0b150e6e0 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -281,6 +281,7 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) sprintf(&cp->CChexstr[i*2],"%02x",pub33[i]); cp->CChexstr[i*2] = 0; GetCCaddress(cp,cp->unspendableCCaddr,pk); + printf("evalcode.%d initialized\n",evalcode); return(0); } } diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index c5cbc1b31..6f9d2d1d1 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -483,6 +483,7 @@ UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("method","txidinfo")); return(result); } @@ -492,6 +493,7 @@ UniValue sudoku_generate(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("method","gen")); return(result); } @@ -501,6 +503,7 @@ UniValue sudoku_solution(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("method","solution")); return(result); } @@ -510,6 +513,7 @@ UniValue sudoku_pending(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("method","pending")); return(result); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bc10da7bc..c0fe4caa8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5361,20 +5361,13 @@ UniValue cclibinfo(const UniValue& params, bool fHelp) throw runtime_error("cclibinfo\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - if ( params.size() >= 1 ) - { - evalcode = atoi(params[0].get_str().c_str()); - if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER ) - throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); - } cp = CCinit(&C,evalcode); return(CClib_info(cp)); } UniValue cclib(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *method; cJSON *jsonparams=0; uint8_t evalcode; - cp = CCinit(&C,EVAL_FIRSTUSER); + struct CCcontract_info *cp,C; char *method; cJSON *jsonparams=0; uint8_t evalcode = EVAL_FIRSTUSER; if ( fHelp || params.size() > 3 ) throw runtime_error("cclib method [evalcode] [JSON params]\n"); if ( ensure_CCrequirements() < 0 ) @@ -5391,6 +5384,7 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( params.size() == 2 ) jsonparams = cJSON_Parse(params[2].get_str().c_str()); } + printf("evalcode.%d\n",evalcode); cp = CCinit(&C,evalcode); return(CClib(cp,method,jsonparams)); } From 946808ba40d1117372f39be7ac1c8767d1a81e6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:16:49 -1100 Subject: [PATCH 1540/3904] libcc.so --- src/cc/makecclib | 2 +- src/cc/sudoku.cpp | 4 ++++ src/wallet/rpcwallet.cpp | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 47aec377d..0aecab072 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1 +1 @@ -gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../cclib.so cclib.cpp +gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 6f9d2d1d1..62a7ea91c 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -483,6 +483,7 @@ UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","txidinfo")); return(result); } @@ -493,6 +494,7 @@ UniValue sudoku_generate(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","gen")); return(result); } @@ -503,6 +505,7 @@ UniValue sudoku_solution(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","solution")); return(result); } @@ -513,6 +516,7 @@ UniValue sudoku_pending(struct CCcontract_info *cp,cJSON *params) if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); result.push_back(Pair("result","success")); + result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","pending")); return(result); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c0fe4caa8..970dfa3cf 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5384,7 +5384,6 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( params.size() == 2 ) jsonparams = cJSON_Parse(params[2].get_str().c_str()); } - printf("evalcode.%d\n",evalcode); cp = CCinit(&C,evalcode); return(CClib(cp,method,jsonparams)); } From db4e2fc5380b5d520b481d64bde57ad103c3c743 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:20:14 -1100 Subject: [PATCH 1541/3904] Hex --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 62a7ea91c..f03fbd69b 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -496,6 +496,7 @@ UniValue sudoku_generate(struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","gen")); + result.push_back(Pair("hex","deadbeef")); return(result); } From ca2a5e048bb61857a2d630d6b906d35831e0d690 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:48:59 -1100 Subject: [PATCH 1542/3904] sudoku_gen --- src/cc/cclib.cpp | 18 +++++++++--------- src/cc/sudoku.cpp | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 4405cda87..8a7d054f7 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -51,24 +51,24 @@ CClib_methods[] = }; std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); -UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params); -UniValue sudoku_generate(struct CCcontract_info *cp,cJSON *params); -UniValue sudoku_solution(struct CCcontract_info *cp,cJSON *params); -UniValue sudoku_pending(struct CCcontract_info *cp,cJSON *params); +UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) { - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; if ( cp->evalcode == EVAL_SUDOKU ) { if ( strcmp(method,"txidinfo") == 0 ) - return(sudoku_txidinfo(cp,params)); + return(sudoku_txidinfo(txfee,cp,params)); else if ( strcmp(method,"gen") == 0 ) - return(sudoku_generate(cp,params)); + return(sudoku_generate(txfee,cp,params)); else if ( strcmp(method,"solution") == 0 ) - return(sudoku_solution(cp,params)); + return(sudoku_solution(txfee,cp,params)); else if ( strcmp(method,"pending") == 0 ) - return(sudoku_pending(cp,params)); + return(sudoku_pending(txfee,cp,params)); else { result.push_back(Pair("result","error")); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index f03fbd69b..5132d7c98 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -477,7 +477,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) //////////////////////// start of CClib interface -UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params) +UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); if ( params != 0 ) @@ -488,19 +488,43 @@ UniValue sudoku_txidinfo(struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue sudoku_generate(struct CCcontract_info *cp,cJSON *params) +CScript sudoku_genopret(uint8_t unsolved[9][9]) { - UniValue result(UniValue::VOBJ); + CScript opret; uint8_t evalcode = EVAL_SUDOKU; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << unsolved); + return(opret); +} + +UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64]; uint64_t inputsum,amount; std::string hex; if ( params != 0 ) + { printf("params.(%s)\n",jprint(params,0)); + amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; + } else amount = COIN; result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","gen")); - result.push_back(Pair("hex","deadbeef")); + hash = chainActive.LastTip()->GetHash(); + memcpy(&srandi,&hash,sizeof(srandi)) + srandi ^= (uint32_t)time(NULL); + sudoku_gen(privkey,unsolved,srandi); + priv2addr(coinaddr,pub33,privkey); + pk = buf2pk(pub33); + sudokupk = GetUnspendable(cp,0); + inputsum = amount + 2*txfee; + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,inputsum - 2*txfee,pk)); + rawtx = FinalizeCCTx(0,cp,mtx,sudokupk,txfee,sudoku_genopret(unsolved)); + result.push_back(Pair("srand",srandi)); + result.push_back(Pair("amount",ValueFromAmount(amount))); + result.push_back(Pair("hex",rawtx)); return(result); } -UniValue sudoku_solution(struct CCcontract_info *cp,cJSON *params) +UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); if ( params != 0 ) @@ -511,7 +535,7 @@ UniValue sudoku_solution(struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue sudoku_pending(struct CCcontract_info *cp,cJSON *params) +UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); if ( params != 0 ) From fb3246204be4c24a683b5666674c371bd69eae7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:50:17 -1100 Subject: [PATCH 1543/3904] Syntax --- src/cc/sudoku.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 5132d7c98..50a04e22e 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -498,7 +498,7 @@ CScript sudoku_genopret(uint8_t unsolved[9][9]) UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64]; uint64_t inputsum,amount; std::string hex; + UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64]; uint64_t inputsum,amount; std::string rawtx; if ( params != 0 ) { printf("params.(%s)\n",jprint(params,0)); @@ -508,7 +508,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","gen")); hash = chainActive.LastTip()->GetHash(); - memcpy(&srandi,&hash,sizeof(srandi)) + memcpy(&srandi,&hash,sizeof(srandi)); srandi ^= (uint32_t)time(NULL); sudoku_gen(privkey,unsolved,srandi); priv2addr(coinaddr,pub33,privkey); @@ -518,7 +518,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,inputsum - 2*txfee,pk)); rawtx = FinalizeCCTx(0,cp,mtx,sudokupk,txfee,sudoku_genopret(unsolved)); - result.push_back(Pair("srand",srandi)); + result.push_back(Pair("srand",(int)srandi)); result.push_back(Pair("amount",ValueFromAmount(amount))); result.push_back(Pair("hex",rawtx)); return(result); From d4e8f4afa9e99eb4f6f0fd79556b8ddde21f1385 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:51:00 -1100 Subject: [PATCH 1544/3904] GetBlockHash() --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 50a04e22e..770620565 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -507,7 +507,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","gen")); - hash = chainActive.LastTip()->GetHash(); + hash = chainActive.LastTip()->GetBlockHash(); memcpy(&srandi,&hash,sizeof(srandi)); srandi ^= (uint32_t)time(NULL); sudoku_gen(privkey,unsolved,srandi); From 91f3a0fcbd0dfb3eeb5c5aec9b45d507d3d6f1a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:52:52 -1100 Subject: [PATCH 1545/3904] Gen opret --- src/cc/sudoku.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 770620565..42f5791f8 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -490,8 +490,11 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params CScript sudoku_genopret(uint8_t unsolved[9][9]) { - CScript opret; uint8_t evalcode = EVAL_SUDOKU; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << unsolved); + CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::vector data; + for (i=0; i<9; i++) + for (j=0; j<9; j++) + data.push_back(unsolved[i][j]); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << data); return(opret); } From 0d81615f616b645f78fabe9634d79e69805a56d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 00:53:27 -1100 Subject: [PATCH 1546/3904] i,j --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 42f5791f8..20d11567a 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -490,7 +490,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params CScript sudoku_genopret(uint8_t unsolved[9][9]) { - CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::vector data; + CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::vector data; int32_t i,j; for (i=0; i<9; i++) for (j=0; j<9; j++) data.push_back(unsolved[i][j]); From 7e35f61a63bb7a7b92e66419e339d3be313f9f0c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 01:25:02 -1100 Subject: [PATCH 1547/3904] Gen tx --- src/cc/sudoku.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 20d11567a..adba75920 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -476,6 +476,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) } //////////////////////// start of CClib interface +// ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { @@ -517,13 +518,15 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params priv2addr(coinaddr,pub33,privkey); pk = buf2pk(pub33); sudokupk = GetUnspendable(cp,0); - inputsum = amount + 2*txfee; - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,inputsum - 2*txfee,pk)); - rawtx = FinalizeCCTx(0,cp,mtx,sudokupk,txfee,sudoku_genopret(unsolved)); result.push_back(Pair("srand",(int)srandi)); result.push_back(Pair("amount",ValueFromAmount(amount))); - result.push_back(Pair("hex",rawtx)); + if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16)) >= amount+2*txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,inputsum - 2*txfee,pk)); + rawtx = FinalizeCCTx(0,cp,mtx,sudokupk,txfee,sudoku_genopret(unsolved)); + result.push_back(Pair("hex",rawtx)); + } else result.push_back(Pair("error","not enough SUDOKU funds")); return(result); } From 89a9ce3b121332c92c0826dce8d51cea859bb675 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 01:29:19 -1100 Subject: [PATCH 1548/3904] +print --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8a7d054f7..7d5a26e42 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -257,9 +257,9 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK { txid = it->first.txhash; vout = (int32_t)it->first.index; + char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis < threshold ) continue; - //char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { From 21ee88562ce2b4fe2c8d7fff9197f83a070d1bdf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 01:39:10 -1100 Subject: [PATCH 1549/3904] CCbalance --- src/cc/cclib.cpp | 2 +- src/wallet/rpcwallet.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 7d5a26e42..83afb86ef 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -257,7 +257,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK { txid = it->first.txhash; vout = (int32_t)it->first.index; - char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis < threshold ) continue; // no need to prevent dup diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 970dfa3cf..fc1839de2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5220,6 +5220,7 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vectorunspendableCCaddr)); + result.push_back(Pair("CCbalance",ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr)))); sprintf(str,"%smarker",name); result.push_back(Pair(str,cp->normaladdr)); result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40")); @@ -5234,7 +5235,10 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector Date: Tue, 29 Jan 2019 01:45:41 -1100 Subject: [PATCH 1550/3904] Sudokupk signing --- src/cc/sudoku.cpp | 9 +++++++-- src/wallet/rpcwallet.cpp | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index adba75920..336edffcd 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -502,7 +502,7 @@ CScript sudoku_genopret(uint8_t unsolved[9][9]) UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64]; uint64_t inputsum,amount; std::string rawtx; + UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64]; uint64_t inputsum,amount,change=0; std::string rawtx; if ( params != 0 ) { printf("params.(%s)\n",jprint(params,0)); @@ -523,7 +523,12 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16)) >= amount+2*txfee ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,inputsum - 2*txfee,pk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,pk)); + if ( inputsum > amount + 2*txfee ) + change = (inputsum - amount - 2*txfee); + if ( change > txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); + CCaddr2set(cp,cp->evalcode,sudokupk,cp->CCpriv,cp->CCaddr); rawtx = FinalizeCCTx(0,cp,mtx,sudokupk,txfee,sudoku_genopret(unsolved)); result.push_back(Pair("hex",rawtx)); } else result.push_back(Pair("error","not enough SUDOKU funds")); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fc1839de2..3409710ad 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5240,7 +5240,10 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector Date: Tue, 29 Jan 2019 01:47:34 -1100 Subject: [PATCH 1551/3904] Test --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 336edffcd..d460b5fdd 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -522,6 +522,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("amount",ValueFromAmount(amount))); if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16)) >= amount+2*txfee ) { + printf("inputsum %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,pk)); if ( inputsum > amount + 2*txfee ) From d1389403787889dca59e51500adfcba76183e57c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 01:50:31 -1100 Subject: [PATCH 1552/3904] Test --- src/cc/cclib.cpp | 2 +- src/cc/sudoku.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 83afb86ef..77b9edcf6 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -257,7 +257,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK { txid = it->first.txhash; vout = (int32_t)it->first.index; - char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis < threshold ) continue; // no need to prevent dup diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index d460b5fdd..38b4e242f 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -529,7 +529,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params change = (inputsum - amount - 2*txfee); if ( change > txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); - CCaddr2set(cp,cp->evalcode,sudokupk,cp->CCpriv,cp->CCaddr); + CCaddr2set(cp,cp->evalcode,sudokupk,cp->CCpriv,cp->unspendableCCaddr); rawtx = FinalizeCCTx(0,cp,mtx,sudokupk,txfee,sudoku_genopret(unsolved)); result.push_back(Pair("hex",rawtx)); } else result.push_back(Pair("error","not enough SUDOKU funds")); From 1a7fbca0da6472493cc508085c63b550eeac477f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 01:55:20 -1100 Subject: [PATCH 1553/3904] Test --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index a8d832661..25e13df7f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -177,7 +177,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"FinalizeCCTx() matched unspendable CC addr.(%s)\n",unspendable); + fprintf(stderr,"FinalizeCCTx(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, tokensunspendable) == 0) { From 9de5df85e89e48324e4edc983e36cf28ae8fc20a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 01:59:32 -1100 Subject: [PATCH 1554/3904] Use mypk --- src/cc/CCtx.cpp | 2 +- src/cc/sudoku.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 25e13df7f..4fe4d9673 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -73,7 +73,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran unspendablepk = GetUnspendable(cp, unspendablepriv); GetCCaddress(cp, unspendable, unspendablepk); othercond = MakeCCcond1(cp->evalcode, unspendablepk); - +printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); // tokens support: // to spend from dual-eval mypk vout diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 38b4e242f..d97b81b0d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -530,7 +530,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( change > txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); CCaddr2set(cp,cp->evalcode,sudokupk,cp->CCpriv,cp->unspendableCCaddr); - rawtx = FinalizeCCTx(0,cp,mtx,sudokupk,txfee,sudoku_genopret(unsolved)); + rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_genopret(unsolved)); result.push_back(Pair("hex",rawtx)); } else result.push_back(Pair("error","not enough SUDOKU funds")); return(result); From 1aefc8dbff7167374dfeceb3280bde387ea31e4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:05:22 -1100 Subject: [PATCH 1555/3904] Default validation for sudoku --- src/cc/CCtx.cpp | 4 ++-- src/cc/cclib.cpp | 4 ++++ src/cc/sudoku.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 4fe4d9673..5228703ea 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -73,7 +73,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran unspendablepk = GetUnspendable(cp, unspendablepriv); GetCCaddress(cp, unspendable, unspendablepk); othercond = MakeCCcond1(cp->evalcode, unspendablepk); -printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); + //printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); // tokens support: // to spend from dual-eval mypk vout @@ -177,7 +177,7 @@ printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); { privkey = unspendablepriv; cond = othercond; - fprintf(stderr,"FinalizeCCTx(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); + //fprintf(stderr,"FinalizeCCTx(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, tokensunspendable) == 0) { diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 77b9edcf6..112fba5de 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -51,6 +51,8 @@ CClib_methods[] = }; std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); + +bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -190,6 +192,8 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; std::vector > txids; + if ( cp->evalcode != EVAL_FAUCET2 ) + return(sudoku_validate(cp,height,eval,tx)); numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index d97b81b0d..ccd5a913f 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -522,7 +522,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("amount",ValueFromAmount(amount))); if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16)) >= amount+2*txfee ) { - printf("inputsum %.8f\n",(double)inputsum/COIN); + //printf("inputsum %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,pk)); if ( inputsum > amount + 2*txfee ) @@ -558,3 +558,8 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } + +bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + return(true); +} From 66dc70b22804cb518ae049e6f2073e01cbc91585 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:10:38 -1100 Subject: [PATCH 1556/3904] Print --- src/cc/sudoku.cpp | 2 ++ src/wallet/rpcwallet.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index ccd5a913f..097a01d86 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -477,6 +477,8 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) //////////////////////// start of CClib interface // ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & +// cclib "gen" 17 "1" +// 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3409710ad..e09ddc89f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5389,7 +5389,10 @@ UniValue cclib(const UniValue& params, bool fHelp) throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); } if ( params.size() == 2 ) + { jsonparams = cJSON_Parse(params[2].get_str().c_str()); + printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); + } } cp = CCinit(&C,evalcode); return(CClib(cp,method,jsonparams)); From 220bf38e5de0ca7ee59f3dfcedef70f0124d8c50 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:14:30 -1100 Subject: [PATCH 1557/3904] Print --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e09ddc89f..34ee7ce95 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5380,6 +5380,7 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); method = (char *)params[0].get_str().c_str(); + printf("params.size() %d (%s)\n",(int32_t)params.size(),params[2].get_str().c_str()); if ( params.size() >= 1 ) { evalcode = atoi(params[1].get_str().c_str()); From 542e08db60d4e046df46897bffb722993f404449 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:16:59 -1100 Subject: [PATCH 1558/3904] Test --- src/wallet/rpcwallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 34ee7ce95..3104a5006 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5380,8 +5380,7 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); method = (char *)params[0].get_str().c_str(); - printf("params.size() %d (%s)\n",(int32_t)params.size(),params[2].get_str().c_str()); - if ( params.size() >= 1 ) + if ( params.size() >= 2 ) { evalcode = atoi(params[1].get_str().c_str()); if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER ) @@ -5389,7 +5388,7 @@ UniValue cclib(const UniValue& params, bool fHelp) printf("evalcode.%d vs (%d, %d)\n",evalcode,EVAL_FIRSTUSER,EVAL_LASTUSER); throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); } - if ( params.size() == 2 ) + if ( params.size() == 3 ) { jsonparams = cJSON_Parse(params[2].get_str().c_str()); printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); From 3f5b87742be1a0496f53fd590d0ea791d0afae67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:21:11 -1100 Subject: [PATCH 1559/3904] Print --- src/cc/sudoku.cpp | 9 +++++++++ src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 097a01d86..590cc9c9b 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -484,7 +484,16 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { UniValue result(UniValue::VOBJ); if ( params != 0 ) + { printf("params.(%s)\n",jprint(params,0)); + int32_t i,n = cJSON_GetArraySize(); + for (i=0; i EVAL_LASTUSER ) { - printf("evalcode.%d vs (%d, %d)\n",evalcode,EVAL_FIRSTUSER,EVAL_LASTUSER); + //printf("evalcode.%d vs (%d, %d)\n",evalcode,EVAL_FIRSTUSER,EVAL_LASTUSER); throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n"); } if ( params.size() == 3 ) { jsonparams = cJSON_Parse(params[2].get_str().c_str()); - printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); + //printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); } } cp = CCinit(&C,evalcode); From 7b2612734453d4e526ecbc032d81f4bc076c7247 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:22:11 -1100 Subject: [PATCH 1560/3904] +print --- src/cc/sudoku.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 590cc9c9b..26548ea0e 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -479,6 +479,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) // ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & // cclib "gen" 17 "1" // 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 +// cclib "txidinfo" 17 \"[5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432]\" UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { @@ -486,7 +487,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( params != 0 ) { printf("params.(%s)\n",jprint(params,0)); - int32_t i,n = cJSON_GetArraySize(); + cJSON *item; int32_t i,n = cJSON_GetArraySize(params); for (i=0; i Date: Tue, 29 Jan 2019 02:26:19 -1100 Subject: [PATCH 1561/3904] Prints --- src/cc/sudoku.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 26548ea0e..95cb05684 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -486,7 +486,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue result(UniValue::VOBJ); if ( params != 0 ) { - printf("params.(%s)\n",jprint(params,0)); + printf("%p params.(%s) is array.%d\n",params,jprint(params,0),is_cJSON_Array(params)); cJSON *item; int32_t i,n = cJSON_GetArraySize(params); for (i=0; i %p\n",params[2].get_str().c_str(),jsonparams); + printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); } } cp = CCinit(&C,evalcode); From caca5ec036fa5d370203ce6f9296995c3007e593 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:27:45 -1100 Subject: [PATCH 1562/3904] Test --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 95cb05684..20d18018c 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -395,6 +395,7 @@ int sudoku(uint8_t solved9[LINE][LINE],uint8_t unsolved9[LINE][LINE],uint32_t sr * * ******************************************************************************/ +#include "cJSON.h" #define SUDOKU_NINETH 387420489 void sudoku_rowdisp(uint32_t x) From 44cce95c52f89ee88c0af7fac6c178c23959aaa4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:30:05 -1100 Subject: [PATCH 1563/3904] Test --- src/cc/sudoku.cpp | 39 +++++++++++++++++++-------------------- src/wallet/rpcwallet.cpp | 3 ++- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 20d18018c..b60373e23 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -482,26 +482,6 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) // 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 // cclib "txidinfo" 17 \"[5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432]\" -UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - if ( params != 0 ) - { - printf("%p params.(%s) is array.%d\n",params,jprint(params,0),is_cJSON_Array(params)); - cJSON *item; int32_t i,n = cJSON_GetArraySize(params); - for (i=0; i data; int32_t i,j; @@ -549,6 +529,25 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(result); } +UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + if ( params != 0 ) + { + cJSON *item; int32_t i,n = cJSON_GetArraySize(params); + for (i=0; i %p\n",params[2].get_str().c_str(),jsonparams); + printf("%p params.(%s) is array.%d\n",params,jprint(params,0),is_cJSON_Array(params)); + //printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); } } cp = CCinit(&C,evalcode); From ccbbb3291c54b88fc8540c20d082b815d4d21b53 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:31:28 -1100 Subject: [PATCH 1564/3904] Test --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 39a88c9eb..5cea2f7ac 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5391,7 +5391,8 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( params.size() == 3 ) { jsonparams = cJSON_Parse(params[2].get_str().c_str()); - printf("%p params.(%s) is array.%d\n",params,jprint(params,0),is_cJSON_Array(params)); + if ( jsonparams != 0 ) + printf("%p params.(%s) is array.%d\n",jsonparams,jprint(jsonparams,0),is_cJSON_Array(params)); //printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); } } From e2a1c43d8a6fc81e9e9e4daff4460a613a770ad1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:33:01 -1100 Subject: [PATCH 1565/3904] Test --- src/cc/includes/cJSON.h | 4 ++-- src/cryptoconditions/src/include/cJSON.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/includes/cJSON.h b/src/cc/includes/cJSON.h index ed8c26b7f..d919a47a9 100755 --- a/src/cc/includes/cJSON.h +++ b/src/cc/includes/cJSON.h @@ -35,8 +35,8 @@ * * ******************************************************************************/ -#ifndef cJSON__h -#define cJSON__h +#ifndef cJSON__ccih +#define cJSON__ccih #include #include diff --git a/src/cryptoconditions/src/include/cJSON.h b/src/cryptoconditions/src/include/cJSON.h index 2a6139680..547dddad5 100644 --- a/src/cryptoconditions/src/include/cJSON.h +++ b/src/cryptoconditions/src/include/cJSON.h @@ -35,8 +35,8 @@ * * ******************************************************************************/ -#ifndef cJSON__h -#define cJSON__h +#ifndef cJSON__cch +#define cJSON__cch #ifdef __cplusplus extern "C" From 4123105b95e49de239884f9f071799091793d01b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:34:19 -1100 Subject: [PATCH 1566/3904] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5cea2f7ac..6a6f64237 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5392,7 +5392,7 @@ UniValue cclib(const UniValue& params, bool fHelp) { jsonparams = cJSON_Parse(params[2].get_str().c_str()); if ( jsonparams != 0 ) - printf("%p params.(%s) is array.%d\n",jsonparams,jprint(jsonparams,0),is_cJSON_Array(params)); + printf("%p params.(%s)\n",jsonparams,jprint(jsonparams,0)); //printf("Parse.(%s) -> %p\n",params[2].get_str().c_str(),jsonparams); } } From af6030a98b5d88e360ad581b3fbec23902e2ecd3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:38:12 -1100 Subject: [PATCH 1567/3904] Test --- src/cc/cclib.cpp | 2 ++ src/cc/sudoku.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 112fba5de..614fb8567 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -63,6 +63,7 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; if ( cp->evalcode == EVAL_SUDOKU ) { + printf("CClib_method params.%p\n",params); if ( strcmp(method,"txidinfo") == 0 ) return(sudoku_txidinfo(txfee,cp,params)); else if ( strcmp(method,"gen") == 0 ) @@ -119,6 +120,7 @@ UniValue CClib_info(struct CCcontract_info *cp) UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; + printf("CClib params.%p\n",params); for (i=0; ievalcode == CClib_methods[i].evalcode && strcmp(method,CClib_methods[i].method) == 0 ) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b60373e23..fdc70211a 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -498,7 +498,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64]; uint64_t inputsum,amount,change=0; std::string rawtx; if ( params != 0 ) { - printf("params.(%s)\n",jprint(params,0)); + printf("%p params.(%s)\n",params,jprint(params,0)); amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; } else amount = COIN; result.push_back(Pair("result","success")); From a4beca11a346d22b90fb12295218eceaba351b81 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:39:57 -1100 Subject: [PATCH 1568/3904] Test --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index fdc70211a..a820f2231 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -534,6 +534,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue result(UniValue::VOBJ); if ( params != 0 ) { + printf("%p params.(%s)\n",params,jprint(params,0)); cJSON *item; int32_t i,n = cJSON_GetArraySize(params); for (i=0; i Date: Tue, 29 Jan 2019 02:44:02 -1100 Subject: [PATCH 1569/3904] Test --- src/cc/sudoku.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a820f2231..a44b2d329 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -534,14 +534,20 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue result(UniValue::VOBJ); if ( params != 0 ) { - printf("%p params.(%s)\n",params,jprint(params,0)); - cJSON *item; int32_t i,n = cJSON_GetArraySize(params); - for (i=0; i Date: Tue, 29 Jan 2019 02:50:02 -1100 Subject: [PATCH 1570/3904] txid: --- src/cc/cclib.cpp | 4 ++-- src/cc/sudoku.cpp | 17 +++-------------- src/wallet/rpcwallet.cpp | 3 --- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 614fb8567..c1c3d9f24 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -63,7 +63,7 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; if ( cp->evalcode == EVAL_SUDOKU ) { - printf("CClib_method params.%p\n",params); + //printf("CClib_method params.%p\n",params); if ( strcmp(method,"txidinfo") == 0 ) return(sudoku_txidinfo(txfee,cp,params)); else if ( strcmp(method,"gen") == 0 ) @@ -120,7 +120,7 @@ UniValue CClib_info(struct CCcontract_info *cp) UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; - printf("CClib params.%p\n",params); + //printf("CClib params.%p\n",params); for (i=0; ievalcode == CClib_methods[i].evalcode && strcmp(method,CClib_methods[i].method) == 0 ) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a44b2d329..b2ca38321 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -534,20 +534,9 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue result(UniValue::VOBJ); if ( params != 0 ) { - char *jsonstr; cJSON *item; int32_t i,n; - jsonstr = jprint(params,0); - params = cJSON_Parse(jsonstr); - if ( params != 0 ) - { - n = cJSON_GetArraySize(params); - printf("%p params.(%s) <- (%s)\n",params,jprint(params,0),jsonstr); - for (i=0; i %p\n",params[2].get_str().c_str(),jsonparams); } } cp = CCinit(&C,evalcode); From 4fafbdeeadecc175395dacf4ab428fd1d8ba4768 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:52:05 -1100 Subject: [PATCH 1571/3904] Uint256 --- src/cc/sudoku.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b2ca38321..e77455352 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -480,7 +480,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) // ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & // cclib "gen" 17 "1" // 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 -// cclib "txidinfo" 17 \"[5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432]\" +// cclib "txidinfo" 17 \"{"txid":"5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432"}\" CScript sudoku_genopret(uint8_t unsolved[9][9]) { @@ -534,9 +534,10 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue result(UniValue::VOBJ); if ( params != 0 ) { - char str[65]; bits256 txid; - txid = jbits256(params,"txid"); - printf("txid.(%s)\n",bits256_str(str,txid)); + char str[65]; bits256 _txid; uint256 txid; + _txid = jbits256(params,(char *)"txid"); + memcpy(&txid,*_txid,sizeof(txid)); + printf("txid.(%s)\n",txid.GetHex().c_str()); } result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); From d1e3f85f54832e66d565ec8df17f94ad9c6cab1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:52:39 -1100 Subject: [PATCH 1572/3904] Test --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index e77455352..61b1eb389 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -536,7 +536,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { char str[65]; bits256 _txid; uint256 txid; _txid = jbits256(params,(char *)"txid"); - memcpy(&txid,*_txid,sizeof(txid)); + memcpy(&txid,&_txid,sizeof(txid)); printf("txid.(%s)\n",txid.GetHex().c_str()); } result.push_back(Pair("result","success")); From 26ca2c628bf6ba309b86a5f10287575f1e0ff550 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:55:04 -1100 Subject: [PATCH 1573/3904] Test --- src/cc/sudoku.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 61b1eb389..deee89023 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -534,10 +534,13 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue result(UniValue::VOBJ); if ( params != 0 ) { - char str[65]; bits256 _txid; uint256 txid; - _txid = jbits256(params,(char *)"txid"); - memcpy(&txid,&_txid,sizeof(txid)); - printf("txid.(%s)\n",txid.GetHex().c_str()); + char str[65],*txidstr; uint256 txid; + printf("params -> (%s)\n",jprint(params,0)); + if ( (txidstr= jstr(params,(char *)"txid")) != 0 ) + { + decode_hex((uint8_t *)&txid,32,txidstr); + printf("txid.(%s) <- %s\n",txid.GetHex().c_str(),txidstr); + } } result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); From 124ad45bc86e46394db88e020992d1fa684cf9b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 02:59:27 -1100 Subject: [PATCH 1574/3904] Test --- src/cc/sudoku.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index deee89023..8c30ad462 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -480,7 +480,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) // ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & // cclib "gen" 17 "1" // 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 -// cclib "txidinfo" 17 \"{"txid":"5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432"}\" +// cclib "txidinfo" 17 \"5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432\" CScript sudoku_genopret(uint8_t unsolved[9][9]) { @@ -535,9 +535,9 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( params != 0 ) { char str[65],*txidstr; uint256 txid; - printf("params -> (%s)\n",jprint(params,0)); - if ( (txidstr= jstr(params,(char *)"txid")) != 0 ) + if ( (txidstr= jprint(params,0)) != 0 ) { + printf("params -> (%s)\n",txidstr); decode_hex((uint8_t *)&txid,32,txidstr); printf("txid.(%s) <- %s\n",txid.GetHex().c_str(),txidstr); } From 08ee5412fae588bdd768204bf6dbced9aa957277 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 03:01:40 -1100 Subject: [PATCH 1575/3904] Test --- src/cc/sudoku.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 8c30ad462..af41ac9b0 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -537,7 +537,9 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params char str[65],*txidstr; uint256 txid; if ( (txidstr= jprint(params,0)) != 0 ) { - printf("params -> (%s)\n",txidstr); + if ( txidstr[0] == '"' ) + txidstr++; + //printf("params -> (%s)\n",txidstr); decode_hex((uint8_t *)&txid,32,txidstr); printf("txid.(%s) <- %s\n",txid.GetHex().c_str(),txidstr); } From 70fb39618932912de5b4b17460ead72fdde71736 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 03:04:20 -1100 Subject: [PATCH 1576/3904] Test --- src/cc/sudoku.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index af41ac9b0..34d3201c4 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -537,8 +537,11 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params char str[65],*txidstr; uint256 txid; if ( (txidstr= jprint(params,0)) != 0 ) { - if ( txidstr[0] == '"' ) + if ( txidstr[0] == '"' && txidstr[strlen(txidstr)-1] == '"' ) + { + txidstr[strlen(txidstr)-1] = 0; txidstr++; + } //printf("params -> (%s)\n",txidstr); decode_hex((uint8_t *)&txid,32,txidstr); printf("txid.(%s) <- %s\n",txid.GetHex().c_str(),txidstr); From b4dda82a701732e39815f42e74fe9849ed3dcdf7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 03:06:07 -1100 Subject: [PATCH 1577/3904] Revtxid --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 34d3201c4..a3f6ce525 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -544,6 +544,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } //printf("params -> (%s)\n",txidstr); decode_hex((uint8_t *)&txid,32,txidstr); + txid = revuint256(txid); printf("txid.(%s) <- %s\n",txid.GetHex().c_str(),txidstr); } } From a9dcf78e331f2486d175f62d6deb07fec96ee641 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 03:17:56 -1100 Subject: [PATCH 1578/3904] sudoku_txidinfo --- src/cc/CCcustom.cpp | 2 +- src/cc/sudoku.cpp | 48 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 0b150e6e0..8e878d37d 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -281,7 +281,7 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) sprintf(&cp->CChexstr[i*2],"%02x",pub33[i]); cp->CChexstr[i*2] = 0; GetCCaddress(cp,cp->unspendableCCaddr,pk); - printf("evalcode.%d initialized\n",evalcode); + //printf("evalcode.%d initialized\n",evalcode); return(0); } } diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a3f6ce525..cf382a518 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -492,6 +492,23 @@ CScript sudoku_genopret(uint8_t unsolved[9][9]) return(opret); } +uint8_t sudoku_genopreturndecode(char *unsolved,CScript scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; std::vector data; int32_t i; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> data) != 0 && e == EVAL_SUDOKU && f == 'G' ) + { + if ( data.size() == 81 ) + { + for (i=0; i<81; i++) + unsolved[i] = data[i] == 0 ? '-' : '0' + data[i]; + unsolved[i] = 0; + return(f); + } + } + return(0);} + UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -531,10 +548,10 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VOBJ); int32_t numvouts; char str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; char unsolved[82]; if ( params != 0 ) { - char str[65],*txidstr; uint256 txid; + result.push_back(Pair("result","success")); if ( (txidstr= jprint(params,0)) != 0 ) { if ( txidstr[0] == '"' && txidstr[strlen(txidstr)-1] == '"' ) @@ -545,10 +562,33 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params //printf("params -> (%s)\n",txidstr); decode_hex((uint8_t *)&txid,32,txidstr); txid = revuint256(txid); - printf("txid.(%s) <- %s\n",txid.GetHex().c_str(),txidstr); + result.push_back(Pair("txid",txid.GetHex())); + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue))); + result.push_back(Pair("unsolved",unsolved)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt extract sudoku_generate opreturn")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt find txid")); + } } } - result.push_back(Pair("result","success")); + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","missing txid in params")); + } result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","txidinfo")); return(result); From 7217c87e60a8e7ae0e479f766b79e099585157bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 03:25:46 -1100 Subject: [PATCH 1579/3904] sudoku_pending --- src/cc/sudoku.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index cf382a518..fdeac91fa 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -481,6 +481,15 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) // cclib "gen" 17 "1" // 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 // cclib "txidinfo" 17 \"5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432\" +/*{ + "result": "success", + "txid": "5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432", + "result": "success", + "amount": 1.00000000, + "unsolved": "46-8---15-75-61-3----4----8-1--75-----3--24----2-----6-4----------73----------36-", + "name": "sudoku", + "method": "txidinfo" +}*/ CScript sudoku_genopret(uint8_t unsolved[9][9]) { @@ -607,12 +616,31 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - if ( params != 0 ) - printf("params.(%s)\n",jprint(params,0)); + UniValue result(UniValue::VOBJ),a(UniValue::VARRAY); + char coinaddr[64],unsolved[82]; int64_t nValue; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; + std::vector > unspentOutputs; + GetCCaddress(cp,coinaddr,pk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( it->second.satoshis != txfee || vout != 0 ) + continue; + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( (nValue= IsCClibvout(cp,tx,vout)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + a.push_back(txid); + } + } + } result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","pending")); + result.push_back(Pair("pending",a)); return(result); } From b5aa0536c2f8d314101158444b7fa4375ffadcba Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 03:27:22 -1100 Subject: [PATCH 1580/3904] syntax --- src/cc/sudoku.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index fdeac91fa..268281eb7 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -616,10 +616,11 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARRAY); - char coinaddr[64],unsolved[82]; int64_t nValue; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); + char coinaddr[64],unsolved[82]; int64_t nValue; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; CPubKey sudokupk; std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,pk); + sudokupk = GetUnspendable(cp,0); + GetCCaddress(cp,coinaddr,sudokupk); SetCCunspents(unspentOutputs,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { From b60a712efbefda09e4657a230c18b8bda8aa81d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 03:28:05 -1100 Subject: [PATCH 1581/3904] GetHex() --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 268281eb7..9fa714665 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -634,7 +634,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( (nValue= IsCClibvout(cp,tx,vout)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) - a.push_back(txid); + a.push_back(txid.GetHex()); } } } From 43b78b093b946ddb9b30a97788ab5c5c6435e138 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 04:41:00 -1100 Subject: [PATCH 1582/3904] Jsonstr --- src/cc/sudoku.cpp | 59 +++++++++++++++++++++++++++++++------------- src/komodo_globals.h | 2 +- src/komodo_utils.h | 2 +- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 9fa714665..d0e5ad543 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -478,10 +478,12 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) //////////////////////// start of CClib interface // ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & -// cclib "gen" 17 "1" -// 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 -// cclib "txidinfo" 17 \"5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432\" -/*{ +/* cclib "gen" 17 "1" + 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 +*/ + +/* cclib "txidinfo" 17 \"5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432\" +{ "result": "success", "txid": "5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432", "result": "success", @@ -491,6 +493,16 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) "method": "txidinfo" }*/ +/* cclib "pending" 17 +{ + "result": "success", + "name": "sudoku", + "method": "pending", + "pending": [ + "5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432" + ] +}*/ + CScript sudoku_genopret(uint8_t unsolved[9][9]) { CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::vector data; int32_t i,j; @@ -516,7 +528,8 @@ uint8_t sudoku_genopreturndecode(char *unsolved,CScript scriptPubKey) return(f); } } - return(0);} + return(0); +} UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { @@ -548,7 +561,6 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params change = (inputsum - amount - 2*txfee); if ( change > txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); - CCaddr2set(cp,cp->evalcode,sudokupk,cp->CCpriv,cp->unspendableCCaddr); rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_genopret(unsolved)); result.push_back(Pair("hex",rawtx)); } else result.push_back(Pair("error","not enough SUDOKU funds")); @@ -603,17 +615,6 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(result); } -UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - if ( params != 0 ) - printf("params.(%s)\n",jprint(params,0)); - result.push_back(Pair("result","success")); - result.push_back(Pair("name","sudoku")); - result.push_back(Pair("method","solution")); - return(result); -} - UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); @@ -645,6 +646,30 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); char *jsonstr; + if ( params != 0 ) + { + if ( (jsonstr= jprint(params,0)) != 0 ) + { + if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) + { + jsonstr[strlen(jsonstr)-1] = 0; + jsonstr++; + } + params = cJSON_Parse(jsonstr); + free(jsonstr); + } + if ( params != 0 ) + printf("params.(%s)\n",jprint(params,0)); + } + CCaddr2set(cp,cp->evalcode,pk,priv32,coinaddr); + result.push_back(Pair("result","success")); + result.push_back(Pair("name","sudoku")); + result.push_back(Pair("method","solution")); + return(result); +} bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 79b56cbbb..c85c68451 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -173,7 +173,7 @@ int64_t komodo_current_supply(uint32_t nHeight) else if ( decay == SATOSHIDEN ) { int64_t lowestSubsidy, subsidyDifference, stepDifference, stepTriangle; - int64_t denominator, modulo; + int64_t denominator, modulo=1; int32_t sign = 1; if ( j == ASSETCHAINS_LASTERA ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index bcd95e698..862f0c6b0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1047,7 +1047,7 @@ uint64_t komodo_block_prg(uint32_t nHeight) { int i; uint8_t hashSrc[8]; - uint64_t result, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight; + uint64_t result=0, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight; bits256 hashResult; for ( i = 0; i < sizeof(hashSrc); i++ ) From 2781b296ef3b7af07b657efc649c95075df78bce Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 04:42:14 -1100 Subject: [PATCH 1583/3904] Syntax --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index d0e5ad543..e51703456 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -648,7 +648,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); char *jsonstr; + UniValue result(UniValue::VOBJ); char *jsonstr,coinaddr[64]; CPubKey pk; uint8_t priv32[32]; if ( params != 0 ) { if ( (jsonstr= jprint(params,0)) != 0 ) From 10b462a7db4b5ef2f447fc9f13c4bcd3a715b946 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 04:43:29 -1100 Subject: [PATCH 1584/3904] Test --- src/cc/sudoku.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index e51703456..698242aea 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -659,7 +659,6 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params jsonstr++; } params = cJSON_Parse(jsonstr); - free(jsonstr); } if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); From 145a386aab6358727969e4d632b683be23752585 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 04:45:08 -1100 Subject: [PATCH 1585/3904] Test --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 698242aea..76b148836 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -662,6 +662,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); + else printf("couldnt parse.(%s)\n",jsonstr); } CCaddr2set(cp,cp->evalcode,pk,priv32,coinaddr); result.push_back(Pair("result","success")); From 3c43c027a8de82d51ad5981d82141cc3941d5db9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 04:54:58 -1100 Subject: [PATCH 1586/3904] %22 conversion --- src/cc/sudoku.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 76b148836..ba5ed156c 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -648,7 +648,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); char *jsonstr,coinaddr[64]; CPubKey pk; uint8_t priv32[32]; + UniValue result(UniValue::VOBJ); int32_t i,j; char *jsonstr,*newstr,coinaddr[64]; CPubKey pk; uint8_t priv32[32]; if ( params != 0 ) { if ( (jsonstr= jprint(params,0)) != 0 ) @@ -658,7 +658,17 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params jsonstr[strlen(jsonstr)-1] = 0; jsonstr++; } - params = cJSON_Parse(jsonstr); + newstr = malloc(strlen(jsonstr)+1); + for (i=j=0; jsonstr[i]!=0; i++) + { + if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) + { + newstr[j++] = '"'; + i += 2; + } else newstr[j++] = jsonstr[i]; + } + newstr[j] = 0; + params = cJSON_Parse(newstr); } if ( params != 0 ) printf("params.(%s)\n",jprint(params,0)); From e2028c9616d04f365b874e12775f1edd3ad9454d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 04:56:44 -1100 Subject: [PATCH 1587/3904] (Char *) --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index ba5ed156c..95a2269f5 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -658,7 +658,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params jsonstr[strlen(jsonstr)-1] = 0; jsonstr++; } - newstr = malloc(strlen(jsonstr)+1); + newstr = (char *)malloc(strlen(jsonstr)+1); for (i=j=0; jsonstr[i]!=0; i++) { if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) From 127261626619af84296f02b0e898d5da74fe06b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:22:17 -1100 Subject: [PATCH 1588/3904] sudoku_solution --- src/cc/sudoku.cpp | 72 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 95a2269f5..35e947996 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -503,6 +503,10 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) ] }*/ +/* + cclib "solution" 17 \"[%22469823715875961234231457698914675823653182479782394156346219587528736941197548362%22,1548777525,1548777526,...]\" + */ + CScript sudoku_genopret(uint8_t unsolved[9][9]) { CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::vector data; int32_t i,j; @@ -513,6 +517,13 @@ CScript sudoku_genopret(uint8_t unsolved[9][9]) return(opret); } +CScript sudoku_solutionopret(char *solution,uint32_t timestamps[81]) +{ + CScript opret; uint8_t evalcode = EVAL_SUDOKU; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'S' << solution << timestamps); + return(opret); +} + uint8_t sudoku_genopreturndecode(char *unsolved,CScript scriptPubKey) { std::vector vopret; uint8_t *script,e,f; std::vector data; int32_t i; @@ -562,7 +573,9 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( change > txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_genopret(unsolved)); - result.push_back(Pair("hex",rawtx)); + if ( rawtx.size() > 0 ) + result.push_back(Pair("hex",rawtx)); + else result.push_back(Pair("error","couldnt finalize CCtx")); } else result.push_back(Pair("error","not enough SUDOKU funds")); return(result); } @@ -648,7 +661,12 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t i,j; char *jsonstr,*newstr,coinaddr[64]; CPubKey pk; uint8_t priv32[32]; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); int32_t i,j,ind,n; char *jsonstr,*newstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pubk33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawhex; + mypk = pubkey2pk(Mypubkey()); + memset(timestamps,0,sizeof(timestamps)); + result.push_back(Pair("name","sudoku")); + result.push_back(Pair("method","solution")); if ( params != 0 ) { if ( (jsonstr= jprint(params,0)) != 0 ) @@ -669,15 +687,53 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } newstr[j] = 0; params = cJSON_Parse(newstr); - } + } else params = 0; if ( params != 0 ) + { + if ( (n= cJSON_GetArraySize(params)) > 2 && n < (sizeof(timestamps)/sizeof(*timestamps))+1 ) + { + for (i=1; i= balance ) + { + mtx.vout.push_back(CTxOut(balance-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); + rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); + } + } + } + result.push_back(Pair("result","success")); + if ( rawtx.size() > 0 ) + result.push_back(Pair("hex",rawtx)); + else result.push_back(Pair("error","couldnt finalize CCtx")); printf("params.(%s)\n",jprint(params,0)); - else printf("couldnt parse.(%s)\n",jsonstr); + return(result); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parse parameters")); + result.push_back(Pair("parameters",newstr)); + return(result); + } } - CCaddr2set(cp,cp->evalcode,pk,priv32,coinaddr); - result.push_back(Pair("result","success")); - result.push_back(Pair("name","sudoku")); - result.push_back(Pair("method","solution")); + result.push_back(Pair("result","error")); + result.push_back(Pair("error","missing parameters")); return(result); } From 28973e71c4e8d02a021bcf93870e4e81c9083493 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:23:09 -1100 Subject: [PATCH 1589/3904] Test --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 35e947996..4d9443200 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -662,7 +662,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); int32_t i,j,ind,n; char *jsonstr,*newstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pubk33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawhex; + UniValue result(UniValue::VOBJ); int32_t i,j,ind,n; char *jsonstr,*newstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; mypk = pubkey2pk(Mypubkey()); memset(timestamps,0,sizeof(timestamps)); result.push_back(Pair("name","sudoku")); @@ -711,7 +711,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("amount",ValueFromAmount(balance))); if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16)) >= balance ) { - mtx.vout.push_back(CTxOut(balance-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(balance-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); } From 3b5218ccdf23e740019ccfb3b8f8c91837d4d9eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:25:27 -1100 Subject: [PATCH 1590/3904] Serialize timestamps --- src/cc/sudoku.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 4d9443200..5e5247acd 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -519,8 +519,15 @@ CScript sudoku_genopret(uint8_t unsolved[9][9]) CScript sudoku_solutionopret(char *solution,uint32_t timestamps[81]) { - CScript opret; uint8_t evalcode = EVAL_SUDOKU; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'S' << solution << timestamps); + CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::vector data; int32_t i; + for (i=0; i<81; i++) + { + data.push_back((timestamps[i] >> 24) & 0xff); + data.push_back((timestamps[i] >> 16) & 0xff); + data.push_back((timestamps[i] >> 8) & 0xff); + data.push_back(timestamps[i] & 0xff); + } + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'S' << solution << data); return(opret); } From 17ccb0fc88f621bc0bdcad1e22a74b671c1fe44f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:26:17 -1100 Subject: [PATCH 1591/3904] Test --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 5e5247acd..f1f0a1e89 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -519,7 +519,7 @@ CScript sudoku_genopret(uint8_t unsolved[9][9]) CScript sudoku_solutionopret(char *solution,uint32_t timestamps[81]) { - CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::vector data; int32_t i; + CScript opret; uint8_t evalcode = EVAL_SUDOKU; std::string str(solution); std::vector data; int32_t i; for (i=0; i<81; i++) { data.push_back((timestamps[i] >> 24) & 0xff); @@ -527,7 +527,7 @@ CScript sudoku_solutionopret(char *solution,uint32_t timestamps[81]) data.push_back((timestamps[i] >> 8) & 0xff); data.push_back(timestamps[i] & 0xff); } - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'S' << solution << data); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'S' << str << data); return(opret); } From 357d1979a9a0f0153b67cecf563b9ec154b6ed67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:31:49 -1100 Subject: [PATCH 1592/3904] Check privacy --- src/cc/sudoku.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index f1f0a1e89..e71c9df5a 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -708,8 +708,12 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { for (i=ind=0; i<9; i++) for (j=0; j<9; j++) - vals9[i][j] = solution[ind++]; + vals9[i][j] = solution[ind++] - '0'; sudoku_privkey(priv32,vals9); + // 0a760244c109bb5c9ef989126205f6585b9d4167afa0a2733fbab7fe74967049 privkey + for (i=0; i<32; i++) + printf("%02x",priv32[i]); + printf(" priv32\n"); priv2addr(coinaddr,pub33,priv32); pk = buf2pk(pub33); GetCCaddress(cp,CCaddr,pk); From 2cf210288737e6c5f047379c9502e4a4f3863d34 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 00:33:08 +0800 Subject: [PATCH 1593/3904] -ac_notarypay --- src/komodo.h | 28 +++++++--- src/komodo_bitcoind.h | 114 ++++++++++++++++++++++++++++++++++++++++ src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/komodo_utils.h | 7 ++- src/main.cpp | 17 +++++- src/miner.cpp | 71 ++++++++++++++++++++----- src/notaries_staked.cpp | 4 +- 8 files changed, 218 insertions(+), 27 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index af4ea499c..9978e8588 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -37,7 +37,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); -void komodo_connectblock(CBlockIndex *pindex,CBlock& block); +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_structs.h" #include "komodo_globals.h" @@ -695,6 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); + else + { + fprintf(stderr, "NOT matched NOTARISATION\n"); + return (-2); + } if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -708,10 +713,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); - if ( 0 && RemoveOrphanedBlocks(*notarizedheightp)) - { - //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); - } + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -798,7 +800,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys return(-1); } -void komodo_connectblock(CBlockIndex *pindex,CBlock& block) +// int32_t ! +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; int32_t staked_era; static int32_t lastStakedEra; @@ -809,7 +812,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( pindex == 0 ) { fprintf(stderr,"komodo_connectblock null pindex\n"); - return; + return -1; } memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); @@ -817,7 +820,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) { fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); - return; + return -1; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) @@ -858,6 +861,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->GetHeight()); + int transaction = 0; if ( pindex != 0 ) { height = pindex->GetHeight(); @@ -913,6 +917,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } + transaction = i; printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; @@ -938,10 +943,13 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("%.8f ",dstr(block.vtx[i].vout[j].nValue)); len = block.vtx[i].vout[j].scriptPubKey.size(); + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); + if ( notaryid == -2 ) + return(-1); if ( 0 && i > 0 ) { for (k=0; kGetHeight()); + if (notarized = 1) + return(transaction); + else + return(-1); } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index aaf560192..3187099c7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1772,6 +1772,96 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp) +{ + // fetch notary pubkey array. + uint64_t total = 0; + int32_t staked_era; int8_t numSN; + uint8_t staked_pubkeys[64][33]; + staked_era = STAKED_era(timestamp); + numSN = numStakedNotaries(staked_pubkeys,staked_era); + // resize coinbase vouts to number of notary nodes +1 for coinbase itself. + txNew.vout.resize(NotarisationNotaries.size()+1); + // loop over notarisation vins and add transaction to coinbase. + for (int8_t n = 0; n < NotarisationNotaries.size(); n++) + { + uint8_t *ptr; + txNew.vout[n+1].scriptPubKey.resize(35); + ptr = (uint8_t *)&txNew.vout[n+1].scriptPubKey[0]; + ptr[0] = 33; + for (int8_t i=0; i<33; i++) + { + ptr[i+1] = staked_pubkeys[NotarisationNotaries[n]][i]; + //fprintf(stderr,"%02x",ptr[i+1]); + } + ptr[34] = OP_CHECKSIG; + //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); + txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; // ASSETCHAINS_NOTARY_PAY + total += txNew.vout[n+1].nValue; + } + return(total); +} + +uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) +{ + std::vector NotarisationNotaries; + uint32_t timestamp = pblock->nTime; + int32_t staked_era; int8_t numSN; + uint8_t staked_pubkeys[64][33]; + staked_era = STAKED_era(timestamp); + numSN = numStakedNotaries(staked_pubkeys,staked_era); + + uint8_t *script; int32_t scriptlen; + // loop over notaries array and extract index of signers. + + BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin) + { + uint256 hash; CTransaction tx1; + if ( GetTransaction(txin.prevout.hash,tx1,hash,false) ) + { + for (int8_t i = 0; i < numSN; i++) + { + //tx1.vout[txin.prevout.n].scriptPubKey + script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; + scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + NotarisationNotaries.push_back(i); + } + } + } + const CChainParams& chainparams = Params(); + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, height); + uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); + int8_t n = 0, i = 0, matches = 0; + uint64_t total = 0; + //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); + BOOST_FOREACH(const CTxOut& txout, txNew.vout) + { + if ( n == 0 ) + { + n++; + continue; + } + script = (uint8_t *)&txout.scriptPubKey[0]; + scriptlen = (int32_t)txout.scriptPubKey.size(); + // ASSETCHAINS_NOTARY_PAY = nValue! + if ( txout.nValue == ASSETCHAINS_NOTARY_PAY && scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) + { + matches++; + total += txout.nValue; + fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + } + n++; + } + if ( matches = n && matches != 0 && total == totalsats ) + { + fprintf(stderr, "VALIDATED.\n" ); + return(totalsats); + } + return(-1); +} + int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; @@ -1952,6 +2042,30 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } + if( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() != 1 ) + { + if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) + { + fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); + return(0); + } + else + { + // Check the notarisation tx is to the crypto address and meets min sigs. + if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) + { + fprintf(stderr, "notarisation is not to crypto address.%i\n",height); + return(0); + } + // Check min sigs. + if ( pblock->vtx[1].vin.size() < num_notaries_STAKED[STAKED_era(pblock->nTime)] ) + { + fprintf(stderr, "block does not meet minsigs .%i\n",height); + return(0); + } + } + } + //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) return(-1); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index e60e9d3d5..32fb74dab 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -40,7 +40,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD; +extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD, ASSETCHAINS_NOTARY_PAY; extern uint64_t ASSETCHAINS_TIMELOCKGTE; extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a227b642c..13caee41d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -97,7 +97,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t ASSETCHAINS_STAKED; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_NOTARY_PAY; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 51c84a326..4dbf49637 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1895,6 +1895,9 @@ void komodo_args(char *argv0) } else { + ASSETCHAINS_NOTARY_PAY = GetArg("-ac_notarypay",0); + if ( ASSETCHAINS_NOTARY_PAY != 0 ) + printf("Assetchains NOTARY PAY set to %lu sats per notarisation per notary. Cannot work with ac_script or ac_pubkey!\n",ASSETCHAINS_NOTARY_PAY); if ( ASSETCHAINS_COMMISSION != 0 ) { ASSETCHAINS_COMMISSION = 0; @@ -1911,7 +1914,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -2006,6 +2009,8 @@ void komodo_args(char *argv0) } fprintf(stderr," <- CCLIB name\n"); } + if ( ASSETCHAINS_NOTARY_PAY != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY),(void *)&ASSETCHAINS_NOTARY_PAY); } addn = GetArg("-seednode",""); diff --git a/src/main.cpp b/src/main.cpp index 24044b42f..69790a72e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3572,6 +3572,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } + if ( ASSETCHAINS_NOTARY_PAY != 0 && block.vtx[0].vout.size() > 1 ) + { + uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); + if ( notarypaycheque > 0 ) + blockReward += notarypaycheque; + else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 4 && IS_STAKED_NOTARY > 0 ) + blockReward += 999999999999999; // Notaries can validate any block for now. + else + return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds coinbase (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), + REJECT_INVALID, "bad-cb-amount"); + } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) { return state.DoS(100, error("ConnectBlock(): coinbase for block 1 pays wrong amount (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), @@ -3684,7 +3695,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); - komodo_connectblock(pindex,*(CBlock *)&block); + int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; + if ( tmp > 0 ) + { + printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!",pindex->GetHeight(),tmp); + } return true; } diff --git a/src/miner.cpp b/src/miner.cpp index a1af2c7bf..4ad70912c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -55,6 +55,8 @@ #include "sodium.h" +#include "notaries_staked.h" + #include #include #ifdef ENABLE_MINING @@ -151,6 +153,7 @@ int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -170,6 +173,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } else pk = _pk; uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); + bool fNotarisationBlock = false; std::vector NotarisationNotaries; + //fprintf(stderr,"create new block\n"); // Create new block if ( gpucount < 0 ) @@ -239,6 +244,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } pblock->nTime = GetAdjustedTime(); + // Now we have the block time, we can get the active notaries. + int32_t staked_era; int8_t numSN; + uint8_t staked_pubkeys[64][33]; + staked_era = STAKED_era(pblock->nTime); + numSN = numStakedNotaries(staked_pubkeys,staked_era); CCoinsViewCache view(pcoinsTip); uint32_t expired; uint64_t commission; @@ -249,13 +259,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); + bool fPrintPriority = GetBoolArg("-printpriority", true); // This vector will be sorted into a priority queue: vector vecPriority; vecPriority.reserve(mempool.mapTx.size() + 1); // now add transactions from the mem pool + int32_t Notarisations = 0; for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) { @@ -329,22 +340,33 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nTotalIn += nValueIn; int nConf = nHeight - coins->nHeight; - - // This is to test is a tx is a notarisation and assign it max priotity. - if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + + uint8_t *script; int32_t scriptlen; uint256 hash; CTransaction tx1; + // loop over notaries array and extract index of signers. + if ( fToCryptoAddress && staked_pubkeys[0][0] != 0 && GetTransaction(txin.prevout.hash,tx1,hash,false) ) { - uint256 hash; CTransaction tx1; CTxDestination address; - if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) + for (int8_t i = 0; i < numSN; i++) { - for (int i = 0; i < NUM_NOTARIES; i++) - if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) - numNotaryVins++; + script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; + scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + { + numNotaryVins++; + if ( Notarisations == 0 ) + { + // Until we get a valid notarization this will always be 0. + // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. + NotarisationNotaries.push_back(i); + } + } } } dPriority += (double)nValueIn * nConf; } - if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) + if ( numSN != 0 && numNotaryVins >= numSN / 5 ) fNotarisation = true; + else + NotarisationNotaries.clear(); nTotalIn += tx.GetShieldedValueIn(); } @@ -360,16 +382,27 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if (fNotarisation) { + if (fNotarisation) + { dPriority = 1e16; - //fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); + Notarisations++; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation[%i] %s set to maximum priority\n",Notarisations,hash.ToString().c_str()); + } + else if ( dPriority == 1e16 ) + { + dPriority -= 10; + // make sure notarisation is tx[1] in block. + // Need to check this? Tried sapling tx and it was not set to max priotity, maybe missing something. } if (porphan) { porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else + else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0) + continue; // If we have added a notarisation already skip the next one. There can only be one per block. + else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } @@ -637,7 +670,17 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[0].scriptPubKey = CScriptExt().PayToScriptHash(CScriptID(opretScript)); txNew.vout[1].scriptPubKey = CScriptExt().OpReturnScript(opretScript, OPRETTYPE_TIMELOCK); txNew.vout[1].nValue = 0; - } // timelocks and commissions are currently incompatible due to validation complexity of the combination + // timelocks and commissions are currently incompatible due to validation complexity of the combination + } + else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 ) + { + // This block contains a valid notarisation as best as we can know. We cant check this 100% until we try to connect block. + // This assumes notaries are not going to collude to create invalid notarisations. + // If they did this, then the block would be invalid, and all kinds of werid things will happen. + // We can test this, and see what happens, if its unreliable, we will need to create a CC contract. + uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); + fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + } pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9dcba0653..23bc0f8fd 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -21,7 +21,9 @@ int8_t is_STAKED(const char *chain_name) { else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; + STAKED = 3; + else if ( (strcmp(chain_name, "NOTARYTEST") == 0) ) + STAKED = 4; else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) STAKED = 255; // This means that all notarisations for chains that are in 255 group are invalid. doneinit = 1; From f262751d437ff0d88865d12e6a7bf08f1cfad27e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:35:29 -1100 Subject: [PATCH 1594/3904] Prints --- src/cc/cclib.cpp | 4 ++-- src/cc/sudoku.cpp | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c1c3d9f24..adc17f54c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -263,7 +263,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK { txid = it->first.txhash; vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); if ( it->second.satoshis < threshold ) continue; // no need to prevent dup @@ -278,7 +278,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; - } else fprintf(stderr,"nValue too small or already spent in mempool\n"); + } else fprintf(stderr,"nValue %.8f too small or already spent in mempool\n",(double)nValue/COIN); } else fprintf(stderr,"couldnt get tx\n"); } return(totalinputs); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index e71c9df5a..7ff297004 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -710,10 +710,6 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params for (j=0; j<9; j++) vals9[i][j] = solution[ind++] - '0'; sudoku_privkey(priv32,vals9); - // 0a760244c109bb5c9ef989126205f6585b9d4167afa0a2733fbab7fe74967049 privkey - for (i=0; i<32; i++) - printf("%02x",priv32[i]); - printf(" priv32\n"); priv2addr(coinaddr,pub33,priv32); pk = buf2pk(pub33); GetCCaddress(cp,CCaddr,pk); From abb78c279fc40dfb45266a8607be4082503923d7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 00:39:16 +0800 Subject: [PATCH 1595/3904] fix min sigs --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3187099c7..e7677b25d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2047,7 +2047,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) { fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); - return(0); + return(0); // skip validation } else { @@ -2055,13 +2055,13 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) { fprintf(stderr, "notarisation is not to crypto address.%i\n",height); - return(0); + return(0); // skip validatiuon } // Check min sigs. - if ( pblock->vtx[1].vin.size() < num_notaries_STAKED[STAKED_era(pblock->nTime)] ) + if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) { fprintf(stderr, "block does not meet minsigs .%i\n",height); - return(0); + return(0); // skip validation } } } From 9195d9034aa4be0846fa77620bddb60358e1953a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:39:17 -1100 Subject: [PATCH 1596/3904] Cmpaddr as arg to IsCClibvout --- src/cc/cclib.cpp | 12 ++++++------ src/cc/sudoku.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index adc17f54c..d1817b2ce 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -141,12 +141,12 @@ UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) return(result); } -int64_t IsCClibvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsCClibvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v,char *cmpaddr) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) + if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cmpaddr) == 0 ) return(tx.vout[v].nValue); } return(0); @@ -171,7 +171,7 @@ bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction //fprintf(stderr,"vini.%d check hash and vout\n",i); if ( hashBlock == zerohash ) return eval->Invalid("cant faucet2 from mempool"); - if ( (assetoshis= IsCClibvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) + if ( (assetoshis= IsCClibvout(cp,vinTx,tx.vin[i].prevout.n,cp->unspendableCCaddr)) != 0 ) inputs += assetoshis; } } @@ -179,7 +179,7 @@ bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction for (i=0; iunspendableCCaddr)) != 0 ) outputs += assetoshis; } if ( inputs != outputs+FAUCET2SIZE+txfee ) @@ -220,7 +220,7 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C else { preventCCvouts = 1; - if ( IsCClibvout(cp,tx,0) != 0 ) + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) != 0 ) { preventCCvouts++; i = 1; @@ -269,7 +269,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsCClibvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsCClibvout(cp,vintx,vout,cp->unspendableCCaddr)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 7ff297004..87f66d751 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -652,7 +652,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) continue; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { - if ( (nValue= IsCClibvout(cp,tx,vout)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) a.push_back(txid.GetHex()); From b2435c8c1637d3aba2d1c666996123793b527527 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:41:26 -1100 Subject: [PATCH 1597/3904] Set cmpaddr --- src/cc/cclib.cpp | 6 +++--- src/cc/sudoku.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index d1817b2ce..036a7d119 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -252,7 +252,7 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } } -int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr) { char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; @@ -269,7 +269,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsCClibvout(cp,vintx,vout,cp->unspendableCCaddr)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -333,7 +333,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para return(""); cclibpk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddCClibInputs(cp,mtx,cclibpk,nValue+txfee,60)) > 0 ) + if ( (inputs= AddCClibInputs(cp,mtx,cclibpk,nValue+txfee,60,cp->unspendableCCaddr)) > 0 ) { if ( inputs > nValue ) CCchange = (inputs - nValue - txfee); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 87f66d751..b407c5c3a 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -570,7 +570,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params sudokupk = GetUnspendable(cp,0); result.push_back(Pair("srand",(int)srandi)); result.push_back(Pair("amount",ValueFromAmount(amount))); - if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16)) >= amount+2*txfee ) + if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16,cp->unspendableCCaddr)) >= amount+2*txfee ) { //printf("inputsum %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); @@ -716,7 +716,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("sudokuaddr",CCaddr)); balance = CCaddress_balance(CCaddr); result.push_back(Pair("amount",ValueFromAmount(balance))); - if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16)) >= balance ) + if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) { mtx.vout.push_back(CTxOut(balance-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); From eee12923bcbef17db21380d266a80001e3267666 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:49:54 -1100 Subject: [PATCH 1598/3904] jsonstr --- src/cc/cclib.cpp | 2 +- src/cc/sudoku.cpp | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 036a7d119..eb93a5042 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -263,7 +263,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK { txid = it->first.txhash; vout = (int32_t)it->first.index; - char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); if ( it->second.satoshis < threshold ) continue; // no need to prevent dup diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b407c5c3a..c3fa87c74 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -478,7 +478,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) //////////////////////// start of CClib interface // ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & -/* cclib "gen" 17 "1" +/* cclib "gen" 17 \"1\" 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 */ @@ -505,6 +505,14 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) /* cclib "solution" 17 \"[%22469823715875961234231457698914675823653182479782394156346219587528736941197548362%22,1548777525,1548777526,...]\" + { + "name": "sudoku", + "method": "solution", + "sudokuaddr": "RSeoPJvMUSLfUHM1BomB97geW9zPznwHXk", + "amount": 1.00000000, + "result": "success", + "hex": "0400008085202f8901328455ce926086f00be1b2adac0ba9adc22067a30948c71572f3da80adc1135d010000007b4c79a276a072a26ba067a565802102c57d40c1ddc92a5246a937bd7338823f1e8c916b137f2092d38cf250d74cb5ab8140f92d54f611aa3cb3d187eaadd56b06f3a8c0f5fba23956b26fdefc6038d9b6282de38525f72ebd8945a7994cef63ebca711ecf8fe6baeefcc218cf58efb59dc2a100af03800111a10001ffffffff02f0b9f505000000002321039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775ac0000000000000000fd9f016a4d9b01115351343639383233373135383735393631323334323331343537363938393134363735383233363533313832343739373832333934313536333436323139353837353238373336393431313937353438333632fd4401000000005c5078355c50783600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000" + } */ CScript sudoku_genopret(uint8_t unsolved[9][9]) @@ -552,12 +560,20 @@ uint8_t sudoku_genopreturndecode(char *unsolved,CScript scriptPubKey) UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64]; uint64_t inputsum,amount,change=0; std::string rawtx; + UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64],*jsonstr; uint64_t inputsum,amount,change=0; std::string rawtx; + amount = COIN; if ( params != 0 ) { - printf("%p params.(%s)\n",params,jprint(params,0)); - amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; - } else amount = COIN; + if ( (jsonstr= jprint(params,0)) != 0 ) + { + if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) + { + jsonstr[strlen(jsonstr)-1] = 0; + jsonstr++; + } + amount = atof(jsonstr) * COIN + 0.0000000049; + } + } result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","gen")); @@ -581,8 +597,16 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_genopret(unsolved)); if ( rawtx.size() > 0 ) + { + CTransaction tx; result.push_back(Pair("hex",rawtx)); - else result.push_back(Pair("error","couldnt finalize CCtx")); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + LOCK(cs_main); + if ( myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + } + } else result.push_back(Pair("error","couldnt finalize CCtx")); } else result.push_back(Pair("error","not enough SUDOKU funds")); return(result); } From 24136eae68cf48fa6178afa1bafe0d713eed620f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 05:52:18 -1100 Subject: [PATCH 1599/3904] Add taxied --- src/cc/sudoku.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index c3fa87c74..d767acab6 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -478,7 +478,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) //////////////////////// start of CClib interface // ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & -/* cclib "gen" 17 \"1\" +/* cclib "gen" 17 \"10\" 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 */ @@ -604,7 +604,10 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { LOCK(cs_main); if ( myAddtomempool(tx) != 0 ) + { RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + } } } else result.push_back(Pair("error","couldnt finalize CCtx")); } else result.push_back(Pair("error","not enough SUDOKU funds")); From 69aedc198169602fc42ac00971f24c6de3498c4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 06:14:29 -1100 Subject: [PATCH 1600/3904] Nun-ending --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index d767acab6..db2ea24bd 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -690,6 +690,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","pending")); result.push_back(Pair("pending",a)); + result.push_back(Pair("numpending",a.size())); return(result); } From a783c9d7f52c8e0cb0a59d6d2ccabeea63a76fb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:10:01 -1100 Subject: [PATCH 1601/3904] sudoku_captcha --- src/cc/sudoku.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index db2ea24bd..bdc47ea61 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -515,6 +515,46 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) } */ +int32_t sudoku_captcha(uint32_t timestamps[81]) +{ + int32_t i,solvetime,avetime,n = 0; uint64_t variance = 0; std::vector list; + for (i=0; i<81; i++) + { + if ( timestamps[i] != 0 ) + { + list.push_back(timestamps[i]); + n++; + } + } + if ( n > 81/2 ) + { + std::sort(list.begin(),list.end()); + solvetime = (list[0] - list[n-1]); + if ( list[0] < list[n-1] ) + return(-1); + else if ( list[0] > chainActive.LastTip()->nTime+200 ) + return(-1); + else if ( solvetime >= 777 ) + return(0); + else + { + avetime = (solvetime / (n-1)); + if ( avetime == 0 ) + return(-1); + for (i=0; i data; int32_t i,j; @@ -730,7 +770,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params for (i=1; i= balance ) + if ( sudoku_captcha(timestamps) < 0 ) { - mtx.vout.push_back(CTxOut(balance-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); - rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); + result.push_back(Pair("result","error")); + result.push_back(Pair("error","captcha failure")); + return(result); + } + else + { + if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) + { + mtx.vout.push_back(CTxOut(balance-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); + rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); + } } } } @@ -756,7 +805,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( rawtx.size() > 0 ) result.push_back(Pair("hex",rawtx)); else result.push_back(Pair("error","couldnt finalize CCtx")); - printf("params.(%s)\n",jprint(params,0)); + //printf("params.(%s)\n",jprint(params,0)); return(result); } else From 1c6dd009cf6807710dc048de06067bc1024ba1a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:11:46 -1100 Subject: [PATCH 1602/3904] Print --- src/cc/sudoku.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index bdc47ea61..d0db3db90 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -531,7 +531,10 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) std::sort(list.begin(),list.end()); solvetime = (list[0] - list[n-1]); if ( list[0] < list[n-1] ) + { + printf("list[0] %u vs list[%d-1] %u\n",list[0],list[n-1]); return(-1); + } else if ( list[0] > chainActive.LastTip()->nTime+200 ) return(-1); else if ( solvetime >= 777 ) @@ -543,7 +546,9 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) return(-1); for (i=0; i Date: Tue, 29 Jan 2019 07:12:46 -1100 Subject: [PATCH 1603/3904] N --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index d0db3db90..0be42cba5 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -532,7 +532,7 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) solvetime = (list[0] - list[n-1]); if ( list[0] < list[n-1] ) { - printf("list[0] %u vs list[%d-1] %u\n",list[0],list[n-1]); + printf("list[0] %u vs list[%d-1] %u\n",list[0],n,list[n-1]); return(-1); } else if ( list[0] > chainActive.LastTip()->nTime+200 ) From 82cf345e94de801e4dcec919932ff4d6ec33ad83 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:13:16 -1100 Subject: [PATCH 1604/3904] Diff --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 0be42cba5..0b45c8483 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -517,7 +517,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) int32_t sudoku_captcha(uint32_t timestamps[81]) { - int32_t i,solvetime,avetime,n = 0; uint64_t variance = 0; std::vector list; + int32_t i,solvetime,diff,avetime,n = 0; uint64_t variance = 0; std::vector list; for (i=0; i<81; i++) { if ( timestamps[i] != 0 ) From 2bc78f3998919bc7ec292480effa9629ef43ee6f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:16:17 -1100 Subject: [PATCH 1605/3904] N --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 0b45c8483..0696ec979 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -526,7 +526,7 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) n++; } } - if ( n > 81/2 ) + //if ( n > 81/2 ) { std::sort(list.begin(),list.end()); solvetime = (list[0] - list[n-1]); @@ -557,7 +557,7 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) return(-1 * 0); else return(0); } - } else return(-1); + } //else return(-1); } CScript sudoku_genopret(uint8_t unsolved[9][9]) From 03274df1f9fc444b7faa600620986ec4739078a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:18:13 -1100 Subject: [PATCH 1606/3904] Reverse polarity --- src/cc/sudoku.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 0696ec979..0fa750d6d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -529,13 +529,13 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) //if ( n > 81/2 ) { std::sort(list.begin(),list.end()); - solvetime = (list[0] - list[n-1]); - if ( list[0] < list[n-1] ) + solvetime = (list[n-1] - list[0]); + if ( list[0] >= list[n-1] ) { printf("list[0] %u vs list[%d-1] %u\n",list[0],n,list[n-1]); return(-1); } - else if ( list[0] > chainActive.LastTip()->nTime+200 ) + else if ( list[n-1] > chainActive.LastTip()->nTime+200 ) return(-1); else if ( solvetime >= 777 ) return(0); From 425d5ddbafe762f9629ce6b6fba915a550cf8deb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:20:02 -1100 Subject: [PATCH 1607/3904] Enable captcha --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 0fa750d6d..05450659a 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -526,7 +526,7 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) n++; } } - //if ( n > 81/2 ) + if ( n > 81/2 ) { std::sort(list.begin(),list.end()); solvetime = (list[n-1] - list[0]); @@ -557,7 +557,7 @@ int32_t sudoku_captcha(uint32_t timestamps[81]) return(-1 * 0); else return(0); } - } //else return(-1); + } else return(-1); } CScript sudoku_genopret(uint8_t unsolved[9][9]) From a7f14184a71fdd9437524a68ebfa9566272679db Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:21:58 -1100 Subject: [PATCH 1608/3904] Split gen --- src/cc/sudoku.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 05450659a..5e3801efb 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -639,7 +639,13 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( inputsum > amount + 2*txfee ) change = (inputsum - amount - 2*txfee); if ( change > txfee ) - mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); + { + if ( change > 10000*COIN ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,change/2,sudokupk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,change/2,sudokupk)); + } else mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,sudokupk)); + } rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_genopret(unsolved)); if ( rawtx.size() > 0 ) { From 16512daaaa1939c6977b9a653a062c6834a6ce4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:34:07 -1100 Subject: [PATCH 1609/3904] -print --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index eb93a5042..69d8d4aaa 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -278,7 +278,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; - } else fprintf(stderr,"nValue %.8f too small or already spent in mempool\n",(double)nValue/COIN); + } //else fprintf(stderr,"nValue %.8f too small or already spent in mempool\n",(double)nValue/COIN); } else fprintf(stderr,"couldnt get tx\n"); } return(totalinputs); From 6283d6dd284d62e2eb1b5c279154911dc3e6d043 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 07:36:23 -1100 Subject: [PATCH 1610/3904] Pending total --- src/cc/sudoku.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 5e3801efb..3e19ba964 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -716,7 +716,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); - char coinaddr[64],unsolved[82]; int64_t nValue; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; CPubKey sudokupk; + char coinaddr[64],unsolved[82]; int64_t nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; CPubKey sudokupk; std::vector > unspentOutputs; sudokupk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,sudokupk); @@ -733,7 +733,10 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { a.push_back(txid.GetHex()); + total += tx.vout[1].nValue; + } } } } @@ -742,6 +745,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("method","pending")); result.push_back(Pair("pending",a)); result.push_back(Pair("numpending",a.size())); + result.push_back(Pair("total",ValueFromAmount(total))); return(result); } From e66ebf2a862d754cf0bee59eca7e4e8c582f871e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:04:19 -1100 Subject: [PATCH 1611/3904] Add txid for solution --- src/cc/sudoku.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 3e19ba964..e7861fa97 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -504,7 +504,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) }*/ /* - cclib "solution" 17 \"[%22469823715875961234231457698914675823653182479782394156346219587528736941197548362%22,1548777525,1548777526,...]\" + cclib "solution" 17 \"[%22fdc9409741f2ede29307da1a06438da0ea6f8d885d2d5c3199c4ef541ec1b5fd%22,%22469823715875961234231457698914675823653182479782394156346219587528736941197548362%22,1548777525,1548777526,...]\" { "name": "sudoku", "method": "solution", @@ -752,7 +752,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); int32_t i,j,ind,n; char *jsonstr,*newstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; + UniValue result(UniValue::VOBJ); int32_t i,j,ind,n; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; mypk = pubkey2pk(Mypubkey()); memset(timestamps,0,sizeof(timestamps)); result.push_back(Pair("name","sudoku")); @@ -780,14 +780,21 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else params = 0; if ( params != 0 ) { - if ( (n= cJSON_GetArraySize(params)) > 2 && n < (sizeof(timestamps)/sizeof(*timestamps))+1 ) + if ( (n= cJSON_GetArraySize(params)) > 2 && n < (sizeof(timestamps)/sizeof(*timestamps))+2 ) { - for (i=1; i= balance ) { - mtx.vout.push_back(CTxOut(balance-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); } } } - } - result.push_back(Pair("result","success")); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","couldnt get all params")); if ( rawtx.size() > 0 ) result.push_back(Pair("hex",rawtx)); else result.push_back(Pair("error","couldnt finalize CCtx")); From 81f9d7046ed823231c2e4e473a484042f61a4139 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:04:49 -1100 Subject: [PATCH 1612/3904] Test --- src/cc/sudoku.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index e7861fa97..113ee11b5 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -782,13 +782,6 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { if ( (n= cJSON_GetArraySize(params)) > 2 && n < (sizeof(timestamps)/sizeof(*timestamps))+2 ) { - if ( (txidstr= jstri(params,0)) != 0 ) - { - decode_hex((uint8_t *)&txid,32,txidstr); - txid = revuint256(txid); - result.push_back(Pair("txid",txid.GetHex())); - // get tx and validate solution is for that txid - } for (i=2; i= balance ) { From b399529ec84274978dcb01c1154f141630caa69f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:08:29 -1100 Subject: [PATCH 1613/3904] Ignore --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 113ee11b5..3f0052d3b 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -803,9 +803,9 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { result.push_back(Pair("result","error")); result.push_back(Pair("error","captcha failure")); - return(result); + //return(result); } - else + //else { if ( (txidstr= jstri(params,0)) != 0 ) { From 07131cab6035386d141af0662c710509dc921e8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:12:05 -1100 Subject: [PATCH 1614/3904] Disable --- src/cc/sudoku.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 3f0052d3b..267504120 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -799,13 +799,13 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("sudokuaddr",CCaddr)); balance = CCaddress_balance(CCaddr); result.push_back(Pair("amount",ValueFromAmount(balance))); - if ( sudoku_captcha(timestamps) < 0 ) + if ( 0 && sudoku_captcha(timestamps) < 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","captcha failure")); - //return(result); + return(result); } - //else + else { if ( (txidstr= jstri(params,0)) != 0 ) { From 5cdd5f8722ace517a5283da7f22611ee35adf3ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:14:03 -1100 Subject: [PATCH 1615/3904] Reenable captcha --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 267504120..113ee11b5 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -799,7 +799,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("sudokuaddr",CCaddr)); balance = CCaddress_balance(CCaddr); result.push_back(Pair("amount",ValueFromAmount(balance))); - if ( 0 && sudoku_captcha(timestamps) < 0 ) + if ( sudoku_captcha(timestamps) < 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","captcha failure")); From 0a61cd4e2ec409f73655c0c254c4eebd6cd64624 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:20:29 -1100 Subject: [PATCH 1616/3904] +err print --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 113ee11b5..3024f821c 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -820,7 +820,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); - } + } else result.push_back(Pair("error","couldnt find funds in solution address")); } } result.push_back(Pair("result","success")); From 51721e30bb9c9d4f3788593f061a206bba60ca51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:28:21 -1100 Subject: [PATCH 1617/3904] Mixup errors --- src/cc/sudoku.cpp | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 3024f821c..c844e1591 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -752,11 +752,12 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); int32_t i,j,ind,n; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; + UniValue result(UniValue::VOBJ); int32_t i,j,good,ind,n,numvouts; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33],unsolved[81]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; uint256 hashBlock; mypk = pubkey2pk(Mypubkey()); memset(timestamps,0,sizeof(timestamps)); result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","solution")); + good = 0; if ( params != 0 ) { if ( (jsonstr= jprint(params,0)) != 0 ) @@ -812,21 +813,46 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params decode_hex((uint8_t *)&txid,32,txidstr); txid = revuint256(txid); result.push_back(Pair("txid",txid.GetHex())); - // get tx and validate solution is for that txid + if ( CCgettxout(txid,0,1) < 0 ) + result.push_back(Pair("error","already solved")); + else if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + for (i=0; i<81; i++) + { + if ( unsolved[i] == 0 ) + continue; + else if ( unsolved[i] != solution[i]-'0' ) + { + printf("i.%d %d != %d\n",i,unsolved[i],solution[i]-'0'); + result.push_back(Pair("error","wrong sudoku solved")); + break; + } + } + if ( i == 81 ) + good = 1; + } else result.push_back(Pair("error","cant decode sudoku")); + } else result.push_back(Pair("error","couldnt find sudoku")); } - mtx.vin.push_back(CTxIn(txid,0,CScript())); - if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) + if ( good != 0 ) { - mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); - rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); - } else result.push_back(Pair("error","couldnt find funds in solution address")); + mtx.vin.push_back(CTxIn(txid,0,CScript())); + if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) + { + mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); + rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); + } else result.push_back(Pair("error","couldnt find funds in solution address")); + } } } - result.push_back(Pair("result","success")); } else result.push_back(Pair("error","couldnt get all params")); if ( rawtx.size() > 0 ) + { + result.push_back(Pair("result","success")); result.push_back(Pair("hex",rawtx)); + } else result.push_back(Pair("error","couldnt finalize CCtx")); //printf("params.(%s)\n",jprint(params,0)); return(result); From 892d237b03b1f19c3ba355b4287f296cceba2c52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 08:30:04 -1100 Subject: [PATCH 1618/3904] ,unsolved[81] --- src/cc/sudoku.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index c844e1591..3cb9469f1 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -752,7 +752,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); int32_t i,j,good,ind,n,numvouts; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],CCaddr[64],*solution=0; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33],unsolved[81]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; uint256 hashBlock; + UniValue result(UniValue::VOBJ); int32_t i,j,good,ind,n,numvouts; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],CCaddr[64],*solution=0,unsolved[82]; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; uint256 hashBlock; mypk = pubkey2pk(Mypubkey()); memset(timestamps,0,sizeof(timestamps)); result.push_back(Pair("name","sudoku")); @@ -823,9 +823,9 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { if ( unsolved[i] == 0 ) continue; - else if ( unsolved[i] != solution[i]-'0' ) + else if ( unsolved[i] != solution[i] ) { - printf("i.%d %d != %d\n",i,unsolved[i],solution[i]-'0'); + printf("i.%d [%c] != [%c]\n",i,unsolved[i],solution[i]); result.push_back(Pair("error","wrong sudoku solved")); break; } From 84500049345ffe92dbd6affc60e49ce8202b6d21 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 12:14:51 +0800 Subject: [PATCH 1619/3904] limit some prints to -ac_notarypay --- src/komodo.h | 2 +- src/main.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 9978e8588..f8575ade8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,7 +695,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else + else if ( ASSETCHAINS_NOTARY_PAY != 0 ) { fprintf(stderr, "NOT matched NOTARISATION\n"); return (-2); diff --git a/src/main.cpp b/src/main.cpp index 69790a72e..098b8c388 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3696,9 +3696,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //FlushStateToDisk(); int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; - if ( tmp > 0 ) + if ( ASSETCHAINS_NOTARY_PAY != 0 && tmp > 0 ) { - printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!",pindex->GetHeight(),tmp); + printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!\n",pindex->GetHeight(),tmp); + if ( tmp != 1 ) + printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"; } return true; } From 87a1f9f0003c0b30c0315397e93b2e4c656d751e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 12:27:56 +0800 Subject: [PATCH 1620/3904] fix ) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 098b8c388..2d5134b4b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3700,7 +3700,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!\n",pindex->GetHeight(),tmp); if ( tmp != 1 ) - printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"; + printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"); } return true; } From 8592d0f436527b1fbe6992f8108ca3fafd7c7747 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 14:17:11 +0800 Subject: [PATCH 1621/3904] fix print --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 2fd89df3c..0816706bc 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,7 +695,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else + else if ( ASSETCHAINS_NOTARY_PAY != 0 ) { fprintf(stderr, "NOT VALID NOTARISATION\n"); return (-2); From f9284ad20a53cee2c01f27fa3a88afc3c5772f46 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 14:18:20 +0800 Subject: [PATCH 1622/3904] oops --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0816706bc..0d4be5d7e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,11 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else if ( ASSETCHAINS_NOTARY_PAY != 0 ) + /*else { fprintf(stderr, "NOT VALID NOTARISATION\n"); return (-2); - } + } */ if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; From 70df4c1acf569c5db05480d0a0a1987d37b08246 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 21:39:11 -1100 Subject: [PATCH 1623/3904] '-' --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 3cb9469f1..06bc35db6 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -821,7 +821,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { for (i=0; i<81; i++) { - if ( unsolved[i] == 0 ) + if ( unsolved[i] < '1' || unsolved[i] > '9') continue; else if ( unsolved[i] != solution[i] ) { From 3ba832b6bc8828594ad666ac84bafb781db2864a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 21:48:26 -1100 Subject: [PATCH 1624/3904] Pending object --- src/cc/CCinclude.h | 1 + src/cc/sudoku.cpp | 13 ++++++++++--- src/komodo_bitcoind.h | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 5d847800a..4da696547 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -134,6 +134,7 @@ int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 void CCclearvars(struct CCcontract_info *cp); UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params); UniValue CClib_info(struct CCcontract_info *cp); +CBlockIndex *komodo_blockindex(uint256 hash); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 06bc35db6..4b6a6e749 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -667,7 +667,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t numvouts; char str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; char unsolved[82]; + UniValue result(UniValue::VOBJ); int32_t numvouts; char str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; char unsolved[82]; CBlockIndex *pindex; if ( params != 0 ) { result.push_back(Pair("result","success")); @@ -687,6 +687,8 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { result.push_back(Pair("result","success")); + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + result.push_back(Pair("height",pindex->nHeight)); result.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue))); result.push_back(Pair("unsolved",unsolved)); } @@ -716,7 +718,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); - char coinaddr[64],unsolved[82]; int64_t nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; CPubKey sudokupk; + char coinaddr[64],unsolved[82]; int64_t nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; CPubKey sudokupk; CBlockIndex *pindex; std::vector > unspentOutputs; sudokupk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,sudokupk); @@ -734,7 +736,12 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { - a.push_back(txid.GetHex()); + UniValue obj(UniValue::VOBJ); + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + obj.push_back(Pair("height",pindex->nHeight)); + obj.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue))); + obj.push_back(Pair("txid",txid.GetHex())); + a.push_back(obj); total += tx.vout[1].nValue; } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c530db4fb..b3248d7d4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1033,6 +1033,14 @@ int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,in return(depth); } +CBlockIndex *komodo_blockindex(uint256 hash) +{ + BlockMap::const_iterator it; CBlockIndex *pindex = 0; + if ( (it = mapBlockIndex.find(hash)) != mapBlockIndex.end() ) + pindex = it->second; + return(pindex); +} + int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) { int32_t notarized_height,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; CBlockIndex *notary,*pindex; From 86aafb3761a8d86f8b87ae82bc550ace48d91061 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 21:49:05 -1100 Subject: [PATCH 1625/3904] GetHeight() --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 4b6a6e749..dea9cb007 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -688,7 +688,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { result.push_back(Pair("result","success")); if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) - result.push_back(Pair("height",pindex->nHeight)); + result.push_back(Pair("height",pindex->GetHeight())); result.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue))); result.push_back(Pair("unsolved",unsolved)); } @@ -738,7 +738,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue obj(UniValue::VOBJ); if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) - obj.push_back(Pair("height",pindex->nHeight)); + obj.push_back(Pair("height",pindex->GetHeight())); obj.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue))); obj.push_back(Pair("txid",txid.GetHex())); a.push_back(obj); From 14b64d13fea3e40a6e245d12a1bf3e61e25f72fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 16:55:04 +0800 Subject: [PATCH 1626/3904] assetchains_algo in getinfo --- src/rpc/misc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 5e919b9bb..180403e00 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -79,7 +79,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; -extern uint32_t ASSETCHAINS_MAGIC; +extern uint32_t ASSETCHAINS_MAGIC,ASSETCHAINS_ALGO; extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[]; @@ -319,6 +319,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("staked", ASSETCHAINS_STAKED)); if ( ASSETCHAINS_LWMAPOS != 0 ) obj.push_back(Pair("veruspos", ASSETCHAINS_LWMAPOS)); + if ( ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH ) + obj.push_back(Pair("algo",ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO])); } return obj; } From 1d4236867120cf28952c1f7287335ac6375f860f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 21:56:50 -1100 Subject: [PATCH 1627/3904] +print --- src/cc/sudoku.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index dea9cb007..10667461d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -850,18 +850,22 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,sudoku_solutionopret(solution,timestamps)); + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("hex",rawtx)); + } + else result.push_back(Pair("error","couldnt finalize CCtx")); } else result.push_back(Pair("error","couldnt find funds in solution address")); } } } - } else result.push_back(Pair("error","couldnt get all params")); - if ( rawtx.size() > 0 ) - { - result.push_back(Pair("result","success")); - result.push_back(Pair("hex",rawtx)); } - else result.push_back(Pair("error","couldnt finalize CCtx")); - //printf("params.(%s)\n",jprint(params,0)); + else + { + printf("n.%d params.(%s)\n",n,jprint(params,0)); + result.push_back(Pair("error","couldnt get all params")); + } return(result); } else From b006656f9f0171045ea9647ca205408ee9943241 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Jan 2019 21:58:04 -1100 Subject: [PATCH 1628/3904] Off by 1 --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 10667461d..59eb83309 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -788,7 +788,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else params = 0; if ( params != 0 ) { - if ( (n= cJSON_GetArraySize(params)) > 2 && n < (sizeof(timestamps)/sizeof(*timestamps))+2 ) + if ( (n= cJSON_GetArraySize(params)) > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 ) { for (i=2; i Date: Wed, 30 Jan 2019 01:15:44 -1100 Subject: [PATCH 1629/3904] Check address --- src/cc/sudoku.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 59eb83309..841a67d81 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -667,7 +667,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t numvouts; char str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; char unsolved[82]; CBlockIndex *pindex; + UniValue result(UniValue::VOBJ); int32_t numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; char unsolved[82]; CBlockIndex *pindex; if ( params != 0 ) { result.push_back(Pair("result","success")); @@ -689,6 +689,8 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("result","success")); if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) result.push_back(Pair("height",pindex->GetHeight())); + Getscriptaddress(CCaddr,tx.vout[1].scriptPubKey); + result.push_back(Pair("sudokuaddr",CCaddr)); result.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue))); result.push_back(Pair("unsolved",unsolved)); } @@ -759,7 +761,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); int32_t i,j,good,ind,n,numvouts; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],CCaddr[64],*solution=0,unsolved[82]; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; uint256 hashBlock; + UniValue result(UniValue::VOBJ); int32_t i,j,good,ind,n,numvouts; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],checkaddr[64],CCaddr[64],*solution=0,unsolved[82]; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; uint256 hashBlock; mypk = pubkey2pk(Mypubkey()); memset(timestamps,0,sizeof(timestamps)); result.push_back(Pair("name","sudoku")); @@ -804,6 +806,15 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params priv2addr(coinaddr,pub33,priv32); pk = buf2pk(pub33); GetCCaddress(cp,CCaddr,pk); + Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey); + if ( strcmp(checkaddr,CCaddr) != 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","wrong solution")); + result.push_back(Pair("yours",CCaddr)); + result.push_back(Pair("sudokuaddr",checkaddr)); + return(result); + } result.push_back(Pair("sudokuaddr",CCaddr)); balance = CCaddress_balance(CCaddr); result.push_back(Pair("amount",ValueFromAmount(balance))); From 15663f6fa93923676ab24c100ee2320b4dfb4a00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Jan 2019 02:34:33 -1100 Subject: [PATCH 1630/3904] Make sure sudoku has just one solution and set amount to difficulty score --- src/cc/cclib.cpp | 4 +- src/cc/sudoku.cpp | 2014 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 2012 insertions(+), 6 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 69d8d4aaa..dd79d22d9 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -44,10 +44,10 @@ CClib_methods[] = { { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, - { (char *)"sudoku", (char *)"gen", (char *)"amount", 1, 1, 'G', EVAL_SUDOKU }, + { (char *)"sudoku", (char *)"gen", (char *)"", 1, 1, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_SUDOKU }, - { (char *)"sudoku", (char *)"solution", (char *)"solution timestamps[]", 2, 2, 'S', EVAL_SUDOKU }, + { (char *)"sudoku", (char *)"solution", (char *)"txid solution timestamps[]", 2, 2, 'S', EVAL_SUDOKU }, }; std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 841a67d81..b34eccd39 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -1,3 +1,1997 @@ +// start https://github.com/attractivechaos/plb/blob/master/sudoku/incoming/sudoku_solver.c +/************************************************************************************/ +/* */ +/* Author: Bill DuPree */ +/* Name: sudoku_solver.c */ +/* Language: C */ +/* Date: Feb. 25, 2006 */ +/* Copyright (C) Feb. 25, 2006, All rights reserved. */ +/* */ +/* This is a program that solves Su Doku (aka Sudoku, Number Place, etc.) puzzles */ +/* primarily using deductive logic. It will only resort to trial-and-error and */ +/* backtracking approaches upon exhausting all of its deductive moves. */ +/* */ +/* Puzzles must be of the standard 9x9 variety using the (ASCII) characters '1' */ +/* through '9' for the puzzle solution set. Puzzles should be submitted as 81 */ +/* character strings which, when read left-to-right will fill a 9x9 Sudoku grid */ +/* from left-to-right and top-to-bottom. In the puzzle specification, the */ +/* characters 1 - 9 represent the puzzle "givens" or clues. Any other non-blank */ +/* character represents an unsolved cell. */ +/* */ +/* The puzzle solving algorithm is "home grown." I did not borrow any of the usual */ +/* techniques from the literature, e.g. Donald Knuth's "Dancing Links." Instead */ +/* I "rolled my own" from scratch. As such, its performance can only be blamed */ +/* on yours truly. Still, I feel it is quite fast. On a 333 MHz Pentium II Linux */ +/* box it solves typical medium force puzzles in approximately 800 microseconds or */ +/* about 1,200 puzzles per second, give or take. On an Athlon XP 3000 (Barton core) */ +/* it solves about 6,600 puzzles per sec. */ +/* */ +/* DESCRIPTION OF ALGORITHM: */ +/* */ +/* The puzzle algorithm initially assumes every unsolved cell can assume every */ +/* possible value. It then uses the placement of the givens to refine the choices */ +/* available to each cell. I call this the markup phase. */ +/* */ +/* After markup completes, the algorithm then looks for "singleton" cells with */ +/* values that, due to constraints imposed by the row, column, or 3x3 region, may */ +/* only assume one possible value. Once these cells are assigned values, the */ +/* algorithm returns to the markup phase to apply these changes to the remaining */ +/* candidate solutions. The markup/singleton phases alternate until either no more */ +/* changes occur, or the puzzle is solved. I call the markup/singleton elimination */ +/* loop the "Simple Solver" because in a large percentage of cases it solves the */ +/* puzzle. */ +/* */ +/* If the simple solver portion of the algorithm doesn't produce a solution, then */ +/* more advanced deductive rules are applied. I've implemented two additional rules */ +/* as part of the deductive puzzle solver. The first is subset elimination wherein */ +/* a row/column/region is scanned for X number of cells with X number of matching */ +/* candidate solutions. If such subsets are found in the row, column, or region, */ +/* then the candidates values from the subset may be eliminated from all other */ +/* unsolved cells within the row, column, or region, respectively. */ +/* */ +/* The second advanced deductive rule examines each region looking for candidate */ +/* values that exclusively align themselves along a single row or column, i.e. a */ +/* a vector. If such candidate values are found, then they may be eliminated from */ +/* the cells outside of the region that are part of the aligned row or column. */ +/* */ +/* Note that each of the advanced deductive rules calls all preceeding rules, in */ +/* order, if that advanced rule has effected a change in puzzle markup. */ +/* */ +/* Finally, if no solution is found after iteratively applying all deductive rules, */ +/* then we begin trial-and-error using recursion for backtracking. A working copy */ +/* is created from our puzzle, and using this copy the first cell with the */ +/* smallest number of candidate solutions is chosen. One of the solutions values is */ +/* assigned to that cell, and the solver algorithm is called using this working */ +/* copy as its starting point. Eventually, either a solution, or an impasse is */ +/* reached. */ +/* */ +/* If we reach an impasse, the recursion unwinds and the next trial solution is */ +/* attempted. If a solution is found (at any point) the values for the solution are */ +/* added to a list. Again, so long as we are examining all possibilities, the */ +/* recursion unwinds so that the next trial may be attempted. It is in this manner */ +/* that we enumerate puzzles with multiple solutions. */ +/* */ +/* Note that it is certainly possible to add to the list of applied deductive */ +/* rules. The techniques known as "X-Wing" and "Swordfish" come to mind. On the */ +/* other hand, adding these additional rules will, in all likelihood, slow the */ +/* solver down by adding to the computational burden while producing very few */ +/* results. I've seen the law of diminishing returns even in some of the existing */ +/* rules, e.g. in subset elimination I only look at two and three valued subsets */ +/* because taking it any further than that degraded performance. */ +/* */ +/* PROGRAM INVOCATION: */ +/* */ +/* This program is a console (or command line) based utility and has the following */ +/* usage: */ +/* */ +/* sudoku_solver {-p puzzle | -f } [-o ] */ +/* [-r ] [-1][-a][-c][-g][-l][-m][-n][-s] */ +/* */ +/* where: */ +/* */ +/* -1 Search for first solution, otherwise all solutions are returned */ +/* -a Requests that the answer (solution) be printed */ +/* -c Print a count of solutions for each puzzle */ +/* -d Print the recursive trial depth required to solve the puzzle */ +/* -e Print a step-by-step explanation of the solution(s) */ +/* -f Takes an argument which specifes an input file */ +/* containing one or more unsolved puzzles (default: stdin) */ +/* -G Print the puzzle solution(s) in a 9x9 grid format */ +/* -g Print the number of given clues */ +/* -l Print the recursive trial depth required to solve the puzzle */ +/* -m Print an octal mask for the puzzle givens */ +/* -n Number each result */ +/* -o Specifies an output file for the solutions (default: stdout) */ +/* -p Takes an argument giving a single inline puzzle to be solved */ +/* -r Specifies an output file for unsolvable puzzles */ +/* (default: stderr) */ +/* -s Print the puzzle's score or difficulty rating */ +/* -? Print usage information */ +/* */ +/* The return code is zero if all puzzles had unique solutions, */ +/* (or have one or more solutions when -1 is specified) and non-zero */ +/* when no unique solution exists. */ +/* */ +/* PUZZLE SCORING */ +/* */ +/* A word about puzzle scoring, i.e. rating a puzzle's difficulty, is in order. */ +/* Rating Sudoku puzzles is a rather subjective thing, and thus it is difficult to */ +/* really develop an objective puzzle rating system. I, however, have attempted */ +/* this feat (several times with varying degrees of success ;-) and I think the */ +/* heuristics I'm currently applying aren't too bad for rating the relative */ +/* difficulty of solving a puzzle. */ +/* */ +/* The following is a brief rundown of how it works. The initial puzzle markup is */ +/* a "free" operation, i.e. no points are scored for the first markup pass. I feel */ +/* this is appropriate because a person solving a puzzle will always have to do */ +/* their own eyeballing and scanning of the puzzle. Subsequent passes are */ +/* scored at one point per candidate eliminated because these passes indicate */ +/* that more deductive work is required. Secondly, the "reward" for solving a cell */ +/* is set to one point, and as long as the solution only requires simple markup */ +/* and elimination of singletons, this level of reward remains unchanged. */ +/* */ +/* This reward changes, however, when advanced solving rules are required. Puzzles */ +/* that remain unsolved after the first pass through the simple solver phase have */ +/* a higher "reward", i.e. it is incremented by two. Thus, if subset or vector */ +/* elimination is required, all subsequently solved cells score higher bounties. */ +/* In addition, the successful application of these deductive techniques score */ +/* their own penalties. */ +/* */ +/* Finally, if a trial-and-error approach is called for, then the "reward" is */ +/* incremented by another five points. Thus, the total penalty for each level of */ +/* recursion is an additional seven points per solved cell, i.e. */ +/* (recursive_depth * 7) + 1 points per solved cell. Trial solutions are also */ +/* penalized by a weighting factor that is based upon the number of unsolved cells */ +/* that remain upon reentry to the solver and the depth of recursion. (I've seen a */ +/* pathological puzzle from the "Minimum Sudoku" web site require 16 levels of */ +/* recursion and score a whopping 228,642 points using this scoring system!) */ +/* */ +/* And that brings me to this topic: What do all these points mean? */ +/* */ +/* Well, who knows? This is still subjective, and the weighting system I've chosen */ +/* for point scoring is is largely arbitrary. But based upon feedback from a number */ +/* of individuals, a rough scale of difficulty plays out as follows: */ +/* */ +/* DEGREE OF DIFFICULTY | SCORE */ +/* -------------------------+------------------------------------------ */ +/* TRIVIAL | 80 points or less */ +/* EASY | 81 - 150 points */ +/* MEDIUM | 151 - 250 points */ +/* HARD | 251 - 400 points */ +/* VERY HARD | 401 - 900 points */ +/* DIABOLICAL | 901 and up */ +/* */ +/* Experience shows that puzzles in the HARD category, in a few cases, will */ +/* require a small amount of trial-and-error. The VERY HARD puzzles will likely */ +/* require trial-and-error, and in some cases more than one level of trial-and- */ +/* error. As for the DIABOLICAL puzzles--why waste your time? These are best left */ +/* to masochists, savants and automated solvers. YMMV. */ +/* */ +/* LICENSE: */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2 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 General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* */ +/* CONTACT: */ +/* */ +/* Email: bdupree@techfinesse.com */ +/* Post: Bill DuPree, 609 Wenonah Ave, Oak Park, IL 60304 USA */ +/* */ +/************************************************************************************/ +/* */ +/* CHANGE LOG: */ +/* */ +/* Rev. Date Init. Description */ +/* -------------------------------------------------------------------------------- */ +/* 1.00 2006-02-25 WD Initial version. */ +/* 1.01 2006-03-13 WD Fixed return code calc. Added signon message. */ +/* 1.10 2006-03-20 WD Added explain option, add'l speed optimizations */ +/* 1.11 2006-03-23 WD More simple speed optimizations, cleanup, bug fixes */ +/* */ +/************************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#define VERSION "1.11" + +#define PUZZLE_ORDER 3 +#define PUZZLE_DIM (PUZZLE_ORDER*PUZZLE_ORDER) +#define PUZZLE_CELLS (PUZZLE_DIM*PUZZLE_DIM) + +/* Command line options */ +#ifdef EXPLAIN +#define OPTIONS "?1acdef:Ggmno:p:r:s" +#else +#define OPTIONS "?1acdf:Ggmno:p:r:s" +#endif +extern char *optarg; +extern int optind, opterr, optopt; + +static char *myname; /* Name that we were invoked under */ + +static FILE *solnfile, *rejects; + +/* This is the list of cell coordinates specified on a row basis */ + +static int const row[PUZZLE_DIM][PUZZLE_DIM] = { + { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, + { 9, 10, 11, 12, 13, 14, 15, 16, 17 }, + { 18, 19, 20, 21, 22, 23, 24, 25, 26 }, + { 27, 28, 29, 30, 31, 32, 33, 34, 35 }, + { 36, 37, 38, 39, 40, 41, 42, 43, 44 }, + { 45, 46, 47, 48, 49, 50, 51, 52, 53 }, + { 54, 55, 56, 57, 58, 59, 60, 61, 62 }, + { 63, 64, 65, 66, 67, 68, 69, 70, 71 }, + { 72, 73, 74, 75, 76, 77, 78, 79, 80 }}; + +/* This is the list of cell coordinates specified on a column basis */ + +static int const col[PUZZLE_DIM][PUZZLE_DIM] = { + { 0, 9, 18, 27, 36, 45, 54, 63, 72 }, + { 1, 10, 19, 28, 37, 46, 55, 64, 73 }, + { 2, 11, 20, 29, 38, 47, 56, 65, 74 }, + { 3, 12, 21, 30, 39, 48, 57, 66, 75 }, + { 4, 13, 22, 31, 40, 49, 58, 67, 76 }, + { 5, 14, 23, 32, 41, 50, 59, 68, 77 }, + { 6, 15, 24, 33, 42, 51, 60, 69, 78 }, + { 7, 16, 25, 34, 43, 52, 61, 70, 79 }, + { 8, 17, 26, 35, 44, 53, 62, 71, 80 }}; + +/* This is the list of cell coordinates specified on a 3x3 region basis */ + +static int const region[PUZZLE_DIM][PUZZLE_DIM] = { + { 0, 1, 2, 9, 10, 11, 18, 19, 20 }, + { 3, 4, 5, 12, 13, 14, 21, 22, 23 }, + { 6, 7, 8, 15, 16, 17, 24, 25, 26 }, + { 27, 28, 29, 36, 37, 38, 45, 46, 47 }, + { 30, 31, 32, 39, 40, 41, 48, 49, 50 }, + { 33, 34, 35, 42, 43, 44, 51, 52, 53 }, + { 54, 55, 56, 63, 64, 65, 72, 73, 74 }, + { 57, 58, 59, 66, 67, 68, 75, 76, 77 }, + { 60, 61, 62, 69, 70, 71, 78, 79, 80 }}; + +/* Flags for cellflags member */ +#define GIVEN 1 +#define FOUND 2 +#define STUCK 3 + +/* Return codes for funcs that modify puzzle markup */ +#define NOCHANGE 0 +#define CHANGE 1 + +typedef struct grd { + short cellflags[PUZZLE_CELLS]; + short solved[PUZZLE_CELLS]; + short cell[PUZZLE_CELLS]; + short tail, givens, exposed, maxlvl, inc, reward; + unsigned int score, solncount; + struct grd *next; +} grid; + +typedef int (*return_soln)(grid *g); + +static grid *soln_list = NULL; + +typedef struct { + short row, col, region; +} cellmap; + +/* Array structure to help map cell index back to row, column, and region */ +static cellmap const map[PUZZLE_CELLS] = { + { 0, 0, 0 }, + { 0, 1, 0 }, + { 0, 2, 0 }, + { 0, 3, 1 }, + { 0, 4, 1 }, + { 0, 5, 1 }, + { 0, 6, 2 }, + { 0, 7, 2 }, + { 0, 8, 2 }, + { 1, 0, 0 }, + { 1, 1, 0 }, + { 1, 2, 0 }, + { 1, 3, 1 }, + { 1, 4, 1 }, + { 1, 5, 1 }, + { 1, 6, 2 }, + { 1, 7, 2 }, + { 1, 8, 2 }, + { 2, 0, 0 }, + { 2, 1, 0 }, + { 2, 2, 0 }, + { 2, 3, 1 }, + { 2, 4, 1 }, + { 2, 5, 1 }, + { 2, 6, 2 }, + { 2, 7, 2 }, + { 2, 8, 2 }, + { 3, 0, 3 }, + { 3, 1, 3 }, + { 3, 2, 3 }, + { 3, 3, 4 }, + { 3, 4, 4 }, + { 3, 5, 4 }, + { 3, 6, 5 }, + { 3, 7, 5 }, + { 3, 8, 5 }, + { 4, 0, 3 }, + { 4, 1, 3 }, + { 4, 2, 3 }, + { 4, 3, 4 }, + { 4, 4, 4 }, + { 4, 5, 4 }, + { 4, 6, 5 }, + { 4, 7, 5 }, + { 4, 8, 5 }, + { 5, 0, 3 }, + { 5, 1, 3 }, + { 5, 2, 3 }, + { 5, 3, 4 }, + { 5, 4, 4 }, + { 5, 5, 4 }, + { 5, 6, 5 }, + { 5, 7, 5 }, + { 5, 8, 5 }, + { 6, 0, 6 }, + { 6, 1, 6 }, + { 6, 2, 6 }, + { 6, 3, 7 }, + { 6, 4, 7 }, + { 6, 5, 7 }, + { 6, 6, 8 }, + { 6, 7, 8 }, + { 6, 8, 8 }, + { 7, 0, 6 }, + { 7, 1, 6 }, + { 7, 2, 6 }, + { 7, 3, 7 }, + { 7, 4, 7 }, + { 7, 5, 7 }, + { 7, 6, 8 }, + { 7, 7, 8 }, + { 7, 8, 8 }, + { 8, 0, 6 }, + { 8, 1, 6 }, + { 8, 2, 6 }, + { 8, 3, 7 }, + { 8, 4, 7 }, + { 8, 5, 7 }, + { 8, 6, 8 }, + { 8, 7, 8 }, + { 8, 8, 8 } +}; + +static const short symtab[1<= '1') && (c <= '9'); } + +#if defined(DEBUG) +static void mypause() +{ + char buf[8]; + printf("\tPress enter -> "); + fgets(buf, 8, stdin); +} +#endif + +#if 0 +/* Generic (and slow) bitcount function */ +static int bitcount(short cell) +{ + int i, count, mask; + + mask = 1; + for (i = count = 0; i < 16; i++) { + if (mask & cell) count++; + mask <<= 1; + } + return count; +} +#endif + +/*****************************************************/ +/* Return the number of '1' bits in a cell. */ +/* Rather than count bits, do a quick table lookup. */ +/* Warning: Only valid for 9 low order bits. */ +/*****************************************************/ + +static inline short bitcount(short cell) +{ + static const short bcounts[512] = { + 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, + 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, + 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, + 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, + 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8, + 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, + 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8, + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, + 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8, + 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8, + 4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,5,6,6,7,6,7,7,8,6,7,7,8,7,8,8,9}; + + return bcounts[cell]; +} + +#ifdef EXPLAIN + +/**************************************************/ +/* Indent two spaces for each level of recursion. */ +/**************************************************/ +static inline void explain_indent(FILE *h) +{ + int i; + + for (i = 0; i < lvl-1; i++) fprintf(h, " "); +} + +/******************************************************************/ +/* Construct a string representing the possible values a cell may */ +/* contain according to current markup. */ +/******************************************************************/ +static char *clues(short cell) +{ + int i, m, multi, mask; + static char buf[64], *p; + + multi = m = bitcount(cell); + + if (!multi) return "NULL"; + + if (multi > 1) { + strcpy(buf, "tuple ("); + } + else { + strcpy(buf, "value "); + } + + p = buf + strlen(buf); + + for (mask = i = 1; i <= PUZZLE_DIM; i++) { + if (mask & cell) { + *p++ = symtab[mask]; + multi -= 1; + if (multi) { *p++ = ','; *p++ = ' '; } + } + mask <<= 1; + } + if (m > 1) *p++ = ')'; + *p = 0; + return buf; +} + +/*************************************************************/ +/* Explain removal of a candidate value from a changed cell. */ +/*************************************************************/ +static void explain_markup_elim(grid *g, int chgd, int clue) +{ + int chgd_row, chgd_col, clue_row, clue_col; + + chgd_row = map[chgd].row+1; + chgd_col = map[chgd].col+1; + clue_row = map[clue].row+1; + clue_col = map[clue].col+1; + + explain_indent(solnfile); + fprintf(solnfile, "Candidate %s removed from row %d, col %d because of cell at row %d, col %d\n", + clues(g->cell[clue]), chgd_row, chgd_col, clue_row, clue_col); +} + +/*****************************************/ +/* Dump the state of the current markup. */ +/*****************************************/ +static void explain_current_markup(grid *g) +{ + if (g->exposed >= PUZZLE_CELLS) return; + + fprintf(solnfile, "\n"); + explain_indent(solnfile); + fprintf(solnfile, "Current markup is as follows:"); + diagnostic_grid(g, solnfile); + fprintf(solnfile, "\n"); +} + +/****************************************/ +/* Explain the solving of a given cell. */ +/****************************************/ +static void explain_solve_cell(grid *g, int chgd) +{ + int chgd_row, chgd_col; + + chgd_row = map[chgd].row+1; + chgd_col = map[chgd].col+1; + + explain_indent(solnfile); + fprintf(solnfile, "Cell at row %d, col %d solved with %s\n", + chgd_row, chgd_col, clues(g->cell[chgd])); +} + +/******************************************************************/ +/* Explain the current impasse reached during markup elimination. */ +/******************************************************************/ +static void explain_markup_impasse(grid *g, int chgd, int clue) +{ + int chgd_row, chgd_col, clue_row, clue_col; + + chgd_row = map[chgd].row+1; + chgd_col = map[chgd].col+1; + clue_row = map[clue].row+1; + clue_col = map[clue].col+1; + + explain_indent(solnfile); + fprintf(solnfile, "Impasse for cell at row %d, col %d because cell at row %d, col %d removes last candidate\n", + chgd_row, chgd_col, clue_row, clue_col); + explain_current_markup(g); +} + +/****************************************/ +/* Explain naked and/or hidden singles. */ +/****************************************/ +static void explain_singleton(grid *g, int chgd, int mask, char *vdesc) +{ + int chgd_row, chgd_col, chgd_reg; + + chgd_row = map[chgd].row+1; + chgd_col = map[chgd].col+1; + chgd_reg = map[chgd].region+1; + + explain_indent(solnfile); + fprintf(solnfile, "Cell of region %d at row %d, col %d will only solve for %s in this %s\n", + chgd_reg, chgd_row, chgd_col, clues(mask), vdesc); + explain_solve_cell(g, chgd); +} + +/*********************************/ +/* Explain initial puzzle state. */ +/*********************************/ +static void explain_markup() +{ + fprintf(solnfile, "\n"); + explain_indent(solnfile); + fprintf(solnfile, "Assume all cells may contain any values in the range: [1 - 9]\n"); +} + +/************************/ +/* Explain given clues. */ +/************************/ +static void explain_given(int cell, char val) +{ + int cell_row, cell_col; + + cell_row = map[cell].row+1; + cell_col = map[cell].col+1; + + explain_indent(solnfile); + fprintf(solnfile, "Cell at row %d, col %d is given clue value %c\n", cell_row, cell_col, val); +} + +/*******************************************/ +/* Explain region/row/column interactions. */ +/*******************************************/ +static void explain_vector_elim(char *desc, int i, int cell, int val, int region) +{ + int cell_row, cell_col; + + cell_row = map[cell].row+1; + cell_col = map[cell].col+1; + + explain_indent(solnfile); + fprintf(solnfile, "Candidate %s removed from cell at row %d, col %d because it aligns along %s %d in region %d\n", + clues(val), cell_row, cell_col, desc, i+1, region+1); +} + +/******************************************************************/ +/* Explain the current impasse reached during vector elimination. */ +/******************************************************************/ +static void explain_vector_impasse(grid *g, char *desc, int i, int cell, int val, int region) +{ + int cell_row, cell_col; + + cell_row = map[cell].row+1; + cell_col = map[cell].col+1; + + explain_indent(solnfile); + fprintf(solnfile, "Impasse at cell at row %d, col %d because candidate %s aligns along %s %d in region %d\n", + cell_row, cell_col, clues(val), desc, i+1, region+1); + explain_current_markup(g); +} + +/*****************************************************************/ +/* Explain the current impasse reached during tuple elimination. */ +/*****************************************************************/ +static void explain_tuple_impasse(grid *g, char *desc, int elt, int tuple, int count, int bits) +{ + explain_indent(solnfile); + fprintf(solnfile, "Impasse in %s %d because too many (%d) cells have %d-valued %s\n", + desc, elt+1, count, bits, clues(tuple)); + explain_current_markup(g); +} + +/*********************************************************************/ +/* Explain the removal of a tuple of candidate solutions from a cell */ +/*********************************************************************/ +static void explain_tuple_elim(char *desc, int elt, int tuple, int cell) +{ + explain_indent(solnfile); + fprintf(solnfile, "Values of %s in %s %d removed from cell at row %d, col %d\n", + clues(tuple), desc, elt+1, map[cell].row+1, map[cell].col+1); + +} + +/**************************************************/ +/* Indicate that a viable solution has been found */ +/**************************************************/ +static void explain_soln_found(grid *g) +{ + char buf[90]; + + fprintf(solnfile, "\n"); + explain_indent(solnfile); + fprintf(solnfile, "Solution found: %s\n", format_answer(g, buf)); + print_grid(buf, solnfile); + fprintf(solnfile, "\n"); +} + +/***************************/ +/* Show the initial puzzle */ +/***************************/ +static void explain_grid(grid *g) +{ + char buf[90]; + + fprintf(solnfile, "Initial puzzle: %s\n", format_answer(g, buf)); + print_grid(buf, solnfile); + explain_current_markup(g); + fprintf(solnfile, "\n"); +} + +/*************************************************/ +/* Explain attempt at a trial and error solution */ +/*************************************************/ +static void explain_trial(int cell, int value) +{ + explain_indent(solnfile); + fprintf(solnfile, "Attempt trial where cell at row %d, col %d is assigned value %s\n", + map[cell].row+1, map[cell].col+1, clues(value)); +} + +/**********************************************/ +/* Explain back out of current trial solution */ +/**********************************************/ +static void explain_backtrack() +{ + if (lvl <= 1) return; + + explain_indent(solnfile); + fprintf(solnfile, "Backtracking\n\n"); +} + +#define EXPLAIN_MARKUP if (explain) explain_markup() +#define EXPLAIN_CURRENT_MARKUP(g) if (explain) explain_current_markup((g)) +#define EXPLAIN_GIVEN(cell, val) if (explain) explain_given((cell), (val)) +#define EXPLAIN_MARKUP_ELIM(g, chgd, clue) if (explain) explain_markup_elim((g), (chgd), (clue)) +#define EXPLAIN_MARKUP_SOLVE(g, cell) if (explain) explain_solve_cell((g), (cell)) +#define EXPLAIN_MARKUP_IMPASSE(g, chgd, clue) if (explain) explain_markup_impasse((g), (chgd), (clue)) +#define EXPLAIN_SINGLETON(g, chgd, mask, vdesc) if (explain) explain_singleton((g), (chgd), (mask), (vdesc)) +#define EXPLAIN_VECTOR_ELIM(desc, i, cell, v, r) if (explain) explain_vector_elim((desc), (i), (cell), (v), (r)) +#define EXPLAIN_VECTOR_IMPASSE(g, desc, i, cell, v, r) if (explain) explain_vector_impasse((g), (desc), (i), (cell), (v), (r)) +#define EXPLAIN_VECTOR_SOLVE(g, cell) if (explain) explain_solve_cell((g), (cell)) +#define EXPLAIN_TUPLE_IMPASSE(g, desc, j, c, count, i) if (explain) explain_tuple_impasse((g), (desc), (j), (c), (count), (i)) +#define EXPLAIN_TUPLE_ELIM(desc, j, c, cell) if (explain) explain_tuple_elim((desc), (j), (c), (cell)) +#define EXPLAIN_TUPLE_SOLVE(g, cell) if (explain) explain_solve_cell((g), (cell)) +#define EXPLAIN_SOLN_FOUND(g) if (explain) explain_soln_found((g)); +#define EXPLAIN_GRID(g) if (explain) explain_grid((g)); +#define EXPLAIN_TRIAL(cell, val) if (explain) explain_trial((cell), (val)); +#define EXPLAIN_BACKTRACK if (explain) explain_backtrack(); +#define EXPLAIN_INDENT(h) if (explain) explain_indent((h)) + +#else + +#define EXPLAIN_MARKUP +#define EXPLAIN_CURRENT_MARKUP(g) +#define EXPLAIN_GIVEN(cell, val) +#define EXPLAIN_MARKUP_ELIM(g, chgd, clue) +#define EXPLAIN_MARKUP_SOLVE(g, cell) +#define EXPLAIN_MARKUP_IMPASSE(g, chgd, clue) +#define EXPLAIN_SINGLETON(g, chgd, mask, vdesc); +#define EXPLAIN_VECTOR_ELIM(desc, i, cell, v, r) +#define EXPLAIN_VECTOR_IMPASSE(g, desc, i, cell, v, r) +#define EXPLAIN_VECTOR_SOLVE(g, cell) +#define EXPLAIN_TUPLE_IMPASSE(g, desc, j, c, count, i) +#define EXPLAIN_TUPLE_ELIM(desc, j, c, cell) +#define EXPLAIN_TUPLE_SOLVE(g, cell) +#define EXPLAIN_SOLN_FOUND(g) +#define EXPLAIN_GRID(g) +#define EXPLAIN_TRIAL(cell, val) +#define EXPLAIN_BACKTRACK +#define EXPLAIN_INDENT(h) + +#endif + + +/*****************************************************/ +/* Initialize a grid to an empty state. */ +/* At the start, all cells can have any value */ +/* so set all 9 lower order bits in each cell. */ +/* In effect, the 9x9 grid now has markup that */ +/* specifies that each cell can assume any value */ +/* of 1 through 9. */ +/*****************************************************/ + +static void init_grid(grid *g) +{ + int i; + + for (i = 0; i < PUZZLE_CELLS; i++) g->cell[i] = 0x01ff; + memset(g->cellflags, 0, PUZZLE_CELLS*sizeof(g->cellflags[0])); + g->exposed = 0; + g->givens = 0; + g->inc = 0; + g->maxlvl = 0; + g->score = 0; + g->solncount = 0; + g->reward = 1; + g->next = NULL; + g->tail = 0; + EXPLAIN_MARKUP; +} + +/*****************************************************/ +/* Convert a puzzle from the input format, */ +/* i.e. a string of 81 non-blank characters */ +/* with ASCII digits '1' thru '9' specified */ +/* for the givens, and non-numeric characters */ +/* for the remaining cells. The string, read */ +/* left-to-right fills the 9x9 Sudoku grid */ +/* in left-to-right, top-to-bottom order. */ +/*****************************************************/ + +static void cvt_to_grid(grid *g, char *game) +{ + int i; + + init_grid(g); + + for (i = 0; i < PUZZLE_CELLS; i++) { + if (is_given(game[i])) { + /* warning -- ASCII charset assumed */ + g->cell[i] = 1 << (game[i] - '1'); + g->cellflags[i] = GIVEN; + g->givens += 1; + g->solved[g->exposed++] = i; + EXPLAIN_GIVEN(i, game[i]); + } + } + EXPLAIN_GRID(g); +} + +/****************************************************************/ +/* Print the partially solved puzzle and all associated markup */ +/* in 9x9 fashion. */ +/****************************************************************/ + +static void diagnostic_grid(grid *g, FILE *h) +{ + int i, j, flag; + short c; + char line1[40], line2[40], line3[40], cbuf1[5], cbuf2[5], cbuf3[5], outbuf[PUZZLE_CELLS+1]; + + /* Sanity check */ + for (flag = 1, i = 0; flag && i < PUZZLE_CELLS; i++) { + if (bitcount(g->cell[i]) != 1) { + flag = 0; + } + } + + /* Don't need to print grid with diagnostic markup? */ + if (flag) { + format_answer(g, outbuf); + print_grid(outbuf, h); + fflush(h); + return; + } + + strcpy(cbuf1, " |"); + strcpy(cbuf2, cbuf1); + strcpy(cbuf3, cbuf1); + fprintf(h, "\n"); + + for (i = 0; i < PUZZLE_DIM; i++) { + + *line1 = *line2 = *line3 = 0; + + for (j = 0; j < PUZZLE_DIM; j++) { + + c = g->cell[row[i][j]]; + + if (bitcount(c) == 1) { + strcpy(cbuf1, " |"); + strcpy(cbuf2, cbuf1); + strcpy(cbuf3, cbuf1); + cbuf2[1] = symtab[c]; + } + else { + if (c & 1) cbuf1[0] = '*'; else cbuf1[0] = '.'; + if (c & 2) cbuf1[1] = '*'; else cbuf1[1] = '.'; + if (c & 4) cbuf1[2] = '*'; else cbuf1[2] = '.'; + if (c & 8) cbuf2[0] = '*'; else cbuf2[0] = '.'; + if (c & 16) cbuf2[1] = '*'; else cbuf2[1] = '.'; + if (c & 32) cbuf2[2] = '*'; else cbuf2[2] = '.'; + if (c & 64) cbuf3[0] = '*'; else cbuf3[0] = '.'; + if (c & 128) cbuf3[1] = '*'; else cbuf3[1] = '.'; + if (c & 256) cbuf3[2] = '*'; else cbuf3[2] = '.'; + } + + strcat(line1, cbuf1); + strcat(line2, cbuf2); + strcat(line3, cbuf3); + } + + EXPLAIN_INDENT(h); + fprintf(h, "+---+---+---+---+---+---+---+---+---+\n"); + EXPLAIN_INDENT(h); + fprintf(h, "|%s\n", line1); + EXPLAIN_INDENT(h); + fprintf(h, "|%s\n", line2); + EXPLAIN_INDENT(h); + fprintf(h, "|%s\n", line3); + } + EXPLAIN_INDENT(h); + fprintf(h, "+---+---+---+---+---+---+---+---+---+\n"); fflush(h); +} + +/***********************************************************************/ +/* Validate that a sudoku grid contains a valid solution. Return 1 if */ +/* true, 0 if false. If the verbose argument is non-zero, then print */ +/* reasons for invalidating the solution to stderr. */ +/***********************************************************************/ + +static int validate(grid *g, int verbose) +{ + int i, j, regmask, rowmask, colmask, flag = 1; + + /* Sanity check */ + for (i = 0; i < PUZZLE_CELLS; i++) { + if (bitcount(g->cell[i]) != 1) { + if (verbose) { + fprintf(rejects, "Cell %d at row %d, col %d has no unique soln.\n", 1+i, 1+map[i].row, 1+map[i].col); fflush(rejects); + flag = 0; + } else return 0; + } + } + + /* Check rows */ + for (i = 0; i < PUZZLE_DIM; i++) { + for (rowmask = j = 0; j < PUZZLE_DIM; j++) { + if (bitcount(g->cell[row[i][j]]) == 1) rowmask |= g->cell[row[i][j]]; + } + if (rowmask != 0x01ff) { + if (verbose) { + fprintf(rejects, "Row %d is inconsistent.\n", 1+i); fflush(rejects); + flag = 0; + } else return 0; + } + } + + /* Check columns */ + for (i = 0; i < PUZZLE_DIM; i++) { + for (colmask = j = 0; j < PUZZLE_DIM; j++) { + if (bitcount(g->cell[col[i][j]]) == 1) colmask |= g->cell[col[i][j]]; + } + if (colmask != 0x01ff) { + if (verbose) { + fprintf(rejects, "Column %d is inconsistent.\n", 1+i); fflush(rejects); + flag = 0; + } else return 0; + } + } + + /* Check 3x3 regions */ + for (i = 0; i < PUZZLE_DIM; i++) { + for (regmask = j = 0; j < PUZZLE_DIM; j++) { + if (bitcount(g->cell[region[i][j]]) == 1) regmask |= g->cell[region[i][j]]; + } + if (regmask != 0x01ff) { + if (verbose) { + fprintf(rejects, "Region %d is inconsistent.\n", 1+i); fflush(rejects); + flag = 0; + } else return 0; + } + } + + return flag; +} + +/********************************************************************************/ +/* This function uses the cells with unique values, i.e. the given */ +/* or subsequently discovered solution values, to eliminate said values */ +/* as candidates in other as yet unsolved cells in the associated */ +/* rows, columns, and 3x3 regions. */ +/* */ +/* The function has three possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified, and */ +/* STUCK - Markup results are invalid, i.e. a cell has no candidate values */ +/********************************************************************************/ + +static int mark_cells(grid *g) +{ + int i, chgflag, bc; + int const *r, *c, *reg; + short elt, mask, before; + + + chgflag = NOCHANGE; + + while (g->tail < g->exposed) { + + elt = g->solved[g->tail++]; + + r = row[map[elt].row]; + c = col[map[elt].col]; + reg = region[map[elt].region]; + + mask = ~g->cell[elt]; + + for (i = 0; i < PUZZLE_DIM; i++) { + + if (r[i] != elt) { + + /* Get the cell value */ + before = g->cell[r[i]]; + + /* Eliminate this candidate value whilst preserving other candidate values */ + g->cell[r[i]] &= mask; + + /* Did the cell change value? */ + if (before != g->cell[r[i]]) { + + chgflag |= CHANGE; /* Flag that puzzle markup was changed */ + g->score += g->inc; /* More work means higher scoring */ + + if (!(bc = bitcount(g->cell[r[i]]))) { + EXPLAIN_MARKUP_IMPASSE(g, r[i], elt); + return STUCK; /* Crap out if no candidates remain */ + } + + EXPLAIN_MARKUP_ELIM(g, r[i], elt); + + /* Check if we solved for this cell, i.e. bit count indicates a unique value */ + if (bc == 1) { + g->cellflags[r[i]] = FOUND; /* Mark cell as found */ + g->score += g->reward; /* Add to puzzle score */ + g->solved[g->exposed++] = r[i]; + EXPLAIN_MARKUP_SOLVE(g, r[i]); + } + } + } + + if (c[i] != elt) { + + /* Get the cell value */ + before = g->cell[c[i]]; + + /* Eliminate this candidate value whilst preserving other candidate values */ + g->cell[c[i]] &= mask; + + /* Did the cell change value? */ + if (before != g->cell[c[i]]) { + + chgflag |= CHANGE; /* Flag that puzzle markup was changed */ + g->score += g->inc; /* More work means higher scoring */ + + if (!(bc = bitcount(g->cell[c[i]]))) { + EXPLAIN_MARKUP_IMPASSE(g, c[i], elt); + return STUCK; /* Crap out if no candidates remain */ + } + + EXPLAIN_MARKUP_ELIM(g, c[i], elt); + + /* Check if we solved for this cell, i.e. bit count indicates a unique value */ + if (bc == 1) { + g->cellflags[c[i]] = FOUND; /* Mark cell as found */ + g->score += g->reward; /* Add to puzzle score */ + g->solved[g->exposed++] = c[i]; + EXPLAIN_MARKUP_SOLVE(g, c[i]); + } + } + } + + if (reg[i] != elt) { + + /* Get the cell value */ + before = g->cell[reg[i]]; + + /* Eliminate this candidate value whilst preserving other candidate values */ + g->cell[reg[i]] &= mask; + + /* Did the cell change value? */ + if (before != g->cell[reg[i]]) { + + chgflag |= CHANGE; /* Flag that puzzle markup was changed */ + g->score += g->inc; /* More work means higher scoring */ + + if (!(bc = bitcount(g->cell[reg[i]]))) { + EXPLAIN_MARKUP_IMPASSE(g, reg[i], elt); + return STUCK; /* Crap out if no candidates remain */ + } + + EXPLAIN_MARKUP_ELIM(g, reg[i], elt); + + /* Check if we solved for this cell, i.e. bit count indicates a unique value */ + if (bc == 1) { + g->cellflags[reg[i]] = FOUND; /* Mark cell as found */ + g->score += g->reward; /* Add to puzzle score */ + g->solved[g->exposed++] = reg[i]; + EXPLAIN_MARKUP_SOLVE(g, reg[i]); + } + } + } + + } + } + + return chgflag; +} + + +/*******************************************************************/ +/* Identify and "solve" all cells that, by reason of their markup, */ +/* can only assume one specific value, i.e. the cell is the only */ +/* one in a row/column/region (specified by vector) that is */ +/* able to assume a particular value. */ +/* */ +/* The function has two possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified. */ +/*******************************************************************/ + +static int find_singletons(grid *g, int const *vector, char *vdesc) +{ + int i, j, mask, hist[PUZZLE_DIM], value[PUZZLE_DIM], found = NOCHANGE; + + /* We are going to create a histogram of cell candidate values */ + /* for the specified cell vector (row/column/region). */ + /* First set all buckets to zero. */ + memset(hist, 0, sizeof(hist[0])*PUZZLE_DIM); + + /* For each cell in the vector... */ + for (i = 0; i < PUZZLE_DIM; i++) { + + /* For each possible candidate value... */ + for (mask = 1, j = 0; j < PUZZLE_DIM; j++) { + + /* If the cell may possibly assume this value... */ + if (g->cell[vector[i]] & mask) { + + value[j] = vector[i]; /* Save the cell coordinate */ + hist[j] += 1; /* Bump bucket in histogram */ + } + + mask <<= 1; /* Next candidate value */ + } + } + + /* Examine each bucket in the histogram... */ + for (mask = 1, i = 0; i < PUZZLE_DIM; i++) { + + /* If the bucket == 1 and the cell is not already solved, */ + /* then the cell has a unique solution specified by "mask" */ + if (hist[i] == 1 && !g->cellflags[value[i]]) { + + found = CHANGE; /* Indicate that markup has been changed */ + g->cell[value[i]] = mask; /* Assign solution value to cell */ + g->cellflags[value[i]] = FOUND; /* Mark cell as solved */ + g->score += g->reward; /* Bump puzzle score */ + g->solved[g->exposed++] = value[i]; + EXPLAIN_SINGLETON(g, value[i], mask, vdesc); + } + + mask <<= 1; /* Get next candidate value */ + } + + return found; +} + + +/*******************************************************************/ +/* Find all cells with unique solutions (according to markup) */ +/* and mark them as found. Do this for each row, column, and */ +/* region. */ +/* */ +/* The function has two possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified. */ +/*******************************************************************/ + +static int eliminate_singles(grid *g) +{ + int i, found = NOCHANGE; + + /* Do rows */ + for (i = 0; i < PUZZLE_DIM; i++) { + found |= find_singletons(g, row[i], "row"); + } + + /* Do columns */ + for (i = 0; i < PUZZLE_DIM; i++) { + found |= find_singletons(g, col[i], "column"); + } + + /* Do regions */ + for (i = 0; i < PUZZLE_DIM; i++) { + found |= find_singletons(g, region[i], "region"); + } + + return found; +} + +/********************************************************************************/ +/* Solves simple puzzles, i.e. single elimination */ +/* */ +/* The function has three possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified, and */ +/* STUCK - Markup results are invalid, i.e. a cell has no candidate values */ +/********************************************************************************/ +static int simple_solver(grid *g) +{ + int flag = NOCHANGE; + + /* Mark the unsolved cells with candidate solutions based upon the current set of "givens" and solved cells */ + while ((flag |= mark_cells(g)) == CHANGE) { + + g->inc = 1; /* After initial markup, we start scoring for additional markup work */ + + EXPLAIN_CURRENT_MARKUP(g); + + /* Continue to eliminate cells with unique candidate solutions from the game until */ + /* elimination and repeated markup efforts produce no changes in the remaining */ + /* candidate solutions. */ + if (eliminate_singles(g) == NOCHANGE) break; + + EXPLAIN_CURRENT_MARKUP(g); + } + + return flag; +} + +/************************************************************************************/ +/* Test a region to see if the candidate solutions for a paticular number */ +/* are confined to one row or column, and if so, eliminate */ +/* their occurences in the remainder of the given row or column. */ +/* */ +/* The function has three possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified, and */ +/* STUCK - Markup results are invalid, i.e. a cell has no candidate values */ +/************************************************************************************/ + +static int region_vector_elim(grid *g, int region_no, int num) +{ + int i, j, r, c, mask, t, found; + short rowhist[PUZZLE_DIM], colhist[PUZZLE_DIM]; + + /* Init */ + found = NOCHANGE; + memset(rowhist, 0, sizeof(rowhist[0])*PUZZLE_DIM); + memset(colhist, 0, sizeof(colhist[0])*PUZZLE_DIM); + + mask = 1 << num; + + /* Create histograms for row and column placements for the value being checked */ + for (i = 0; i < PUZZLE_DIM; i++) { + j = region[region_no][i]; + if ((g->cell[j] & mask)) { + rowhist[map[j].row] += 1; + colhist[map[j].col] += 1; + } + } + + /* Figure out if this number lies in only one row or column */ + + /* Check rows first*/ + r = c = -1; + for (i = 0; i < PUZZLE_DIM; i++) { + if (rowhist[i]) { + if (r < 0) { + r = i; + } + else { + r = -1; + break; + } + } + } + + /* Now check columns */ + for (i = 0; i < PUZZLE_DIM; i++) { + if (colhist[i]) { + if (c < 0) { + c = i; + } + else { + c = -1; + break; + } + } + } + + /* If the number is only in one row, then eliminate this number from the cells in the row outside of this region */ + if (r >= 0) { + for (i = 0; i < PUZZLE_DIM; i++) { + j = row[r][i]; + if (map[j].region != region_no && !g->cellflags[j]) { + t = g->cell[j]; + if ((g->cell[j] &= ~mask) == 0) { + EXPLAIN_VECTOR_IMPASSE(g, "row", r, j, mask, region_no); + g->score += 10; + return STUCK; + } + if (t != g->cell[j]) { + found = CHANGE; + g->score += g->inc; + EXPLAIN_VECTOR_ELIM("row", r, j, mask, region_no); + if (bitcount(g->cell[j]) == 1) { + g->cellflags[j] = FOUND; + g->score += g->reward; + g->solved[g->exposed++] = j; + EXPLAIN_VECTOR_SOLVE(g, j); + } + } + } + } + } + + /* If the number is only in one column, then eliminate this number from the cells in the column outside of this region */ + else if (c >= 0) { + for (i = 0; i < PUZZLE_DIM; i++) { + j = col[c][i]; + if (map[j].region != region_no && !g->cellflags[j]) { + t = g->cell[j]; + if ((g->cell[j] &= ~mask) == 0) { + EXPLAIN_VECTOR_IMPASSE(g, "column", c, j, mask, region_no); + g->score += 10; + return STUCK; + } + if (t != g->cell[j]) { + found = CHANGE; + g->score += g->inc; + EXPLAIN_VECTOR_ELIM("column", c, j, mask, region_no); + if (bitcount(g->cell[j]) == 1) { + g->cellflags[j] = FOUND; + g->score += g->reward; + g->solved[g->exposed++] = j; + EXPLAIN_VECTOR_SOLVE(g, j); + } + } + } + } + } + + if (found == CHANGE) { + g->score += 10; /* Bump score for sucessfully invoking this rule */ + } + + return found; +} + +/**********************************************************************************/ +/* Test all regions to see if the possibilities for a number */ +/* are confined to specific rows or columns, and if so, eliminate */ +/* the occurence of candidate solutions from the remainder of the */ +/* specified row or column. */ +/* */ +/* The function has three possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified, and */ +/* STUCK - Markup results are invalid, i.e. a cell has no candidate values */ +/**********************************************************************************/ + +static int vector_elimination(grid *g) +{ + int i, j, rc; + + /* For each region... */ + for (rc = NOCHANGE, i = 0; i < PUZZLE_DIM && rc != STUCK; i++) { + + /* For each digit... */ + for (j = 0; j < PUZZLE_DIM && rc != STUCK; j++) { + + /* Eliminate candidates outside of regions when a particular */ + /* candidate value aligns itself to a row or column within */ + /* a 3x3 region. */ + rc |= region_vector_elim(g, i, j); + } + } + + return rc; +} + +/**********************************************************************************/ +/* This function implements the rule that when a subset of cells */ +/* in a row/column/region contain matching subsets of candidate */ +/* solutions, i.e. 2 matching possibilities for 2 cells, 3 */ +/* matching possibilities for 3 cells, etc., then those */ +/* candidates may be eliminated from the other cells in the */ +/* row, column, or region. */ +/* */ +/* The function has three possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified, and */ +/* STUCK - Markup results are invalid, i.e. a cell has no candidate values */ +/**********************************************************************************/ + +static int elim_matches(grid *g, int const *cell_list, char *desc, int ndx) +{ + int i, j, k, e, count, rc, flag; + short c, mask, tmp, elts[PUZZLE_DIM], eliminated[PUZZLE_DIM]; + static int counts[1<cell[k]; /* Copy original cell candidates */ + + if (bitcount(g->cell[k]) == i) { + counts[g->cell[k]] += 1; /* The bucket records the number of cells with this subset */ + } + } + + /* For each cell in the list... */ + for (e = j = 0; j < PUZZLE_DIM; j++) { + + c = g->cell[cell_list[j]]; /* Get cell's candidates */ + + /* Check to see if we've already eliminated this subset */ + for (k = 0; k < e; k++) + if (c == eliminated[k]) break; + if (e && k < e) continue; + + /* Get count from histogram bucket */ + count = (int) (counts[c]); + + /* If too few solution candidates for the number of cells, then we're stuck */ + if (count > i) { + EXPLAIN_TUPLE_IMPASSE(g, desc, ndx, c, count, i); + /* Clean up static array */ + for (k = 0; k < 9; k++) counts[elts[k]] = 0; + g->score += 10; + return STUCK; + } + + /* Do candidate and cell counts match? */ + if (count == i) { + + /* Compute mask used to eliminate candidates from other cells */ + mask = ~c; + + /* Record (for later) the values being eliminated */ + eliminated[e++] = c; + + /* Eliminate candidates from the other cells in the list */ + + /* For each cell... */ + for (k = 0; k < PUZZLE_DIM; k++) { + + /* If the cell candidates do not exactly match the current subset... */ + if (c != g->cell[cell_list[k]] && !g->cellflags[cell_list[k]]) { + + /* Get cell candidates */ + tmp = g->cell[cell_list[k]]; + + /* Eliminate candidates with our mask */ + g->cell[cell_list[k]] &= mask; + + /* Did the elimination change the candidates? */ + if (tmp != g->cell[cell_list[k]]) { + + /* Note the change and bump the score */ + flag = CHANGE; + g->score += i; + + EXPLAIN_TUPLE_ELIM(desc, ndx, c, cell_list[k]); + + /* Did we solve the cell under consideration? */ + if (bitcount(g->cell[cell_list[k]]) == 1) { + + /* Mark cell as found and bump the score */ + g->cellflags[cell_list[k]] = FOUND; + g->score += g->reward; + g->solved[g->exposed++] = cell_list[k]; + EXPLAIN_TUPLE_SOLVE(g, cell_list[k]); + } + } + } + } + } + } + + /* Cleanup the static histogram array */ + for (j = 0; j < PUZZLE_DIM; j++) counts[elts[j]] = 0; + + rc |= flag; + } + + return rc; +} + +/**********************************************************************************/ +/* Eliminate subsets from rows, columns, and regions. */ +/* */ +/* The function has three possible return values: */ +/* NOCHANGE - Markup did not change during the last pass, */ +/* CHANGE - Markup was modified, and */ +/* STUCK - Markup results are invalid, i.e. a cell has no candidate values */ +/**********************************************************************************/ + +static int mult_elimination(grid *g) +{ + int i, rc = NOCHANGE; + + /* Eliminate subsets from rows */ + for (i = 0; i < PUZZLE_DIM; i++) { + rc |= elim_matches(g, row[i], "row", i); + } + + /* Eliminate subsets from columns */ + for (i = 0; i < PUZZLE_DIM; i++) { + rc |= elim_matches(g, col[i], "column", i); + } + + /* Eliminate subsets from regions */ + for (i = 0; i < PUZZLE_DIM; i++) { + rc |= elim_matches(g, region[i], "region", i); + } + + return rc; +} + +/**************************************************/ +/* Entry point to the recursive solver algorithm. */ +/**************************************************/ +static int rsolve(grid *g, return_soln soln_callback) +{ + int i, j, min, c, weight, mask, flag = 0; + grid mygrid; + + /* Keep track of recursive depth */ + lvl += 1; + if (lvl > g->maxlvl) g->maxlvl = lvl; + + for (;;) { + + /* Attempt a simple solution */ + if (simple_solver(g) == STUCK) break; + + /* Check for solution */ + if (g->exposed >= PUZZLE_CELLS) break; + + g->reward += 2; /* Bump reward as we graduate to more "advanced" solving techniques */ + + /* Eliminate tuples */ + if ((flag = mult_elimination(g)) == CHANGE) { + EXPLAIN_CURRENT_MARKUP(g); + continue; + } + + /* Check if impasse */ + if (flag == STUCK) break; + + /* Check for solution */ + if (g->exposed >= PUZZLE_CELLS) break; + + /* Eliminate clues aligned within regions from exterior cells in rows or columns */ + if ((flag = vector_elimination(g)) == CHANGE) { + EXPLAIN_CURRENT_MARKUP(g); + continue; + } + + /* Check if impasse */ + if (flag == STUCK) break; + + /* Check for solution */ + if (g->exposed >= PUZZLE_CELLS) break; + + g->reward += 5; /* Bump reward as we are about to start trial soutions */ + + /* Attempt a trial solution */ + memcpy(&mygrid, g, sizeof(grid)); /* Make working copy of puzzle */ + + /* Find the first cell with the smallest number of alternatives */ + for (weight= 0, c = -1, min = PUZZLE_DIM, i = 0; i < PUZZLE_CELLS; i++) { + if (!mygrid.cellflags[i]) { + j = bitcount(mygrid.cell[i]); + weight += 1; + if (j < min) { + min = j; + c = i; + } + } + } + + mygrid.score += weight; /* Add penalty to score */ + + /* Cell at index 'c' will be our starting point */ + if (c >= 0) for (mask = 1, i = 0; i < PUZZLE_DIM; i++) { + + /* Is this a candidate? */ + if (mask & g->cell[c]) { + + EXPLAIN_TRIAL(c, mask); + + mygrid.score += (int)(((50.0 * lvl * weight) / (double)(PUZZLE_CELLS)) + 0.5); /* Add'l penalty */ + + /* Try one of the possible candidates for this cell */ + mygrid.cell[c] = mask; + mygrid.cellflags[c] = FOUND; + mygrid.solved[mygrid.exposed++] = c; + + EXPLAIN_CURRENT_MARKUP(&mygrid); + flag = rsolve(&mygrid, soln_callback); /* Recurse with working copy of puzzle */ + + /* Did we find a solution? */ + if (flag == FOUND && !enumerate_all) { + EXPLAIN_BACKTRACK; + lvl -= 1; + return FOUND; + } + + /* Preserve score, solution count and recursive depth as we back out of recursion */ + g->score = mygrid.score; + g->solncount = mygrid.solncount; + g->maxlvl = mygrid.maxlvl; + memcpy(&mygrid, g, sizeof(grid)); + } + mask <<= 1; /* Get next possible candidate */ + } + + break; + } + + if (g->exposed == PUZZLE_CELLS && validate(g, 0)) { + soln_callback(g); + g->solncount += 1; + EXPLAIN_SOLN_FOUND(g); + EXPLAIN_BACKTRACK; + lvl -= 1; + flag = FOUND; + } else { + EXPLAIN_BACKTRACK; + lvl -= 1; + flag = STUCK; + if (!lvl && !g->solncount) validate(g, 1); /* Print verbose diagnostic for insoluble puzzle */ + } + + return flag; +} + +/*****************************************************************/ +/* Add a puzzle solution to the singly linked list of solutions. */ +/* Crap out if no memory available. */ +/*****************************************************************/ + +static int add_soln(grid *g) +{ + grid *tmp; + + if ((tmp = malloc(sizeof(grid))) == NULL) { + fprintf(stderr, "Out of memory.\n"); + exit(1); + } + memcpy(tmp, g, sizeof(grid)); + tmp->next = soln_list; + soln_list = tmp; + return 0; +} + +/************************************/ +/* Print hints as to command usage. */ +/************************************/ + +static void usage() +{ + fprintf(stderr, "Usage:\n\t%s {-p puzzle | -f } [-o ]\n", myname); + fprintf(stderr, "\t\t[-r ] [-1][-a][-c][-G][-g][-l][-m][-n][-s]\n"); + fprintf(stderr, "where:\n\t-1\tSearch for first solution, otherwise all solutions are returned\n" + "\t-a\tRequests that the answer (solution) be printed\n" + "\t-c\tPrint a count of solutions for each puzzle\n" + "\t-d\tPrint the recursive trial depth required to solve the puzzle\n" +#ifdef EXPLAIN + "\t-e\tPrint a step-by-step explanation of the solution(s)\n" +#endif + "\t-f\tTakes an argument which specifes an input file\n\t\tcontaining one or more unsolved puzzles (default: stdin)\n" + "\t-G\tPrint the puzzle solution(s) in a 9x9 grid format\n" + "\t-g\tPrint the number of given clues\n" + "\t-m\tPrint an octal mask for the puzzle givens\n" + "\t-n\tNumber each result\n" + "\t-o\tSpecifies an output file for the solutions (default: stdout)\n" + "\t-p\tTakes an argument giving a single inline puzzle to be solved\n" + "\t-r\tSpecifies an output file for unsolvable puzzles\n\t\t(default: stderr)\n" + "\t-s\tPrint the puzzle's score or difficulty rating\n" + "\t-?\tPrint usage information\n\n"); + fprintf(stderr, "The return code is zero if all puzzles had unique solutions,\n" + "(or have one or more solutions when -1 is specified) and non-zero\n" + "when no unique solution exists.\n"); +} + +/********************************************************/ +/* Print the puzzle as an 81 character string of digits */ +/********************************************************/ + +static char *format_answer(grid *g, char *outbuf) +{ + int i; + + for (i = 0; i < PUZZLE_CELLS; i++) + outbuf[i] = symtab[g->cell[i]]; + outbuf[i] = 0; + + return outbuf; +} + +/*******************************************/ +/* Print the puzzle as a standard 9x9 grid */ +/*******************************************/ + +static void print_grid(char *sud, FILE *h) +{ + + fprintf(h, "\n"); + EXPLAIN_INDENT(h); + fprintf(h, "+---+---+---+\n"); + + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud, PUZZLE_ORDER, PUZZLE_ORDER, sud+3, PUZZLE_ORDER, PUZZLE_ORDER, sud+6); + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+9, PUZZLE_ORDER, PUZZLE_ORDER, sud+12, PUZZLE_ORDER, PUZZLE_ORDER, sud+15); + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+18, PUZZLE_ORDER, PUZZLE_ORDER, sud+21, PUZZLE_ORDER, PUZZLE_ORDER, sud+24); + + EXPLAIN_INDENT(h); + fprintf(h, "+---+---+---+\n"); + + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+27, PUZZLE_ORDER, PUZZLE_ORDER, sud+30, PUZZLE_ORDER, PUZZLE_ORDER, sud+33); + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+36, PUZZLE_ORDER, PUZZLE_ORDER, sud+39, PUZZLE_ORDER, PUZZLE_ORDER, sud+42); + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+45, PUZZLE_ORDER, PUZZLE_ORDER, sud+48, PUZZLE_ORDER, PUZZLE_ORDER, sud+51); + + EXPLAIN_INDENT(h); + fprintf(h, "+---+---+---+\n"); + + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+54, PUZZLE_ORDER, PUZZLE_ORDER, sud+57, PUZZLE_ORDER, PUZZLE_ORDER, sud+60); + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+63, PUZZLE_ORDER, PUZZLE_ORDER, sud+66, PUZZLE_ORDER, PUZZLE_ORDER, sud+69); + EXPLAIN_INDENT(h); + fprintf(h, "|%*.*s|%*.*s|%*.*s|\n", PUZZLE_ORDER, PUZZLE_ORDER, sud+72, PUZZLE_ORDER, PUZZLE_ORDER, sud+75, PUZZLE_ORDER, PUZZLE_ORDER, sud+78); + + EXPLAIN_INDENT(h); + fprintf(h, "+---+---+---+\n"); +} + +/*****************************************************/ +/* Based upon the Left-to-Right-Top-to-Bottom puzzle */ +/* presented in "sbuf", create a 27 octal digit */ +/* mask of the givens in the 28 character buffer */ +/* pointed to by "mbuf." Return a pointer to mbuf. */ +/*****************************************************/ + +static char *cvt_to_mask(char *mbuf, char *sbuf) +{ + char *mask_buf = mbuf; + static const char *maskchar = "01234567"; + int i, m; + + mask_buf[PUZZLE_DIM*3] = 0; + for (i = 0; i < PUZZLE_CELLS; i += 3) { + m = 0; + if (is_given(sbuf[i])) { + m |= 4; + } + else { + sbuf[i] = '0'; + } + if (is_given(sbuf[i+1])) { + m |= 2; + } + else { + sbuf[i+1] = '0'; + } + if (is_given(sbuf[i+2])) { + m |= 1; + } + else { + sbuf[i+2] = '0'; + } + *mask_buf++ = maskchar[m]; + } + return mbuf; +} + +/*******************/ +/* Mainline logic. */ +/*******************/ + +int dupree_solver(int32_t *scorep,char *puzzle) +{ + int argc; char *argv[4]; + int i, rc, bog, count, solved, unsolved, solncount=0, flag, prt_count, prt_num, prt_score, prt_answer, prt_depth, prt_grid, prt_mask, prt_givens, prt, len; + char *infile=0, *outfile=0, *rejectfile=0, inbuf[128], outbuf[128], mbuf[28]; + grid g, *s=0; + FILE *h=0; + soln_list = NULL; + /* Get our command name from invoking command line */ + if ((myname = strrchr(argv[0], '/')) == NULL) + myname = argv[0]; + else + myname++; + /*argc = 3; + argv[1] = "-p"; + argv[2] = puzzle; + argv[3] = 0;*/ + /* Print sign-on message to console */ + //fprintf(stderr, "%s version %s\n", myname, VERSION); fflush(stderr); + argc = 1; + /* Init */ + h = 0;//stdin; + solnfile = stdout; + rejects = stderr; + rejectfile = infile = outfile = NULL; + rc = bog = prt_mask = prt_grid = prt_score = prt_depth = prt_answer = prt_count = prt_num = prt_givens = 0; + *inbuf = 0; +#ifdef skip + /* Parse command line options */ + while ((opt = getopt(argc, argv, OPTIONS)) != -1) { + switch (opt) { + case '1': + enumerate_all = 0; /* only find first soln */ + break; + case 'a': + prt_answer = 1; /* print solution */ + break; + case 'c': + prt_count = 1; /* number solutions */ + break; + case 'd': + prt_depth = 1; + break; +#ifdef EXPLAIN + case 'e': + explain = 1; + break; +#endif + case 'f': + if (*inbuf) { // -p and -f options are mutually exclusive + fprintf(stderr, "The -p and -f options are mutually exclusive\n"); + usage(); + exit(1); + } + infile = optarg; // get name of input file + break; + case 'G': + prt_grid = 1; + break; + case 'g': + prt_givens = 1; + break; + case 'm': + prt_mask = 1; + break; + case 'n': + prt_num = 1; + break; + case 'o': + outfile = optarg; + break; + case 'p': + if (infile) { + fprintf(stderr, "The -p and -f options are mutually exclusive\n"); + usage(); + exit(1); + } + if (strlen(optarg) == PUZZLE_CELLS) { + strcpy(inbuf, optarg); + } + else { + fprintf(stderr, "Invalid puzzle specified: %s\n", optarg); + usage(); + exit(1); + } + h = NULL; + break; + case 'r': + rejectfile = optarg; + break; + case 's': + prt_score = 1; + break; + default: + case '?': + usage(); + exit(1); + } + } +#endif + prt_answer = 1; /* print solution */ + //prt_count = 1; /* number solutions */ + prt_score = 1; + prt_givens = 1; + prt_num = 1; + /* Set prt flag if we're printing anything at all */ + prt = prt_mask | prt_grid | prt_score | prt_depth | prt_answer | prt_num | prt_givens; + + /* Anthing else on the command line is bogus */ + if (argc > optind) { + fprintf(stderr, "Extraneous args: "); + for (i = optind; i < argc; i++) { + fprintf(stderr, "%s ", argv[i]); + } + fprintf(stderr, "\n\n"); + usage(); + exit(1); + } + + if (!enumerate_all && prt_score) { + fprintf(stderr, "Scoring is meaningless when multi-solution mode is disabled.\n"); + } + + if (rejectfile && !(rejects = fopen(rejectfile, "w"))) { + fprintf(stderr, "Failed to open reject output file: %s\n", rejectfile); + exit(1); + } + + if (outfile && !(solnfile = fopen(outfile, "w"))) { + fprintf(stderr, "Failed to open solution output file: %s\n", outfile); + exit(1); + } + + /*if (infile && strcmp(infile, "-") && !(h = fopen(infile, "r"))) { + fprintf(stderr, "Failed to open input game file: %s\n", infile); + exit(1); + } + if (h) fgets(inbuf, 128, h);*/ + strcpy(inbuf,puzzle); + count = solved = unsolved = 0; + //printf("inbuf.(%s)\n",inbuf); + while (*inbuf) { + + if ((len = (int32_t)strlen(inbuf)) && inbuf[len-1] == '\n') { + len -= 1; + inbuf[len] = 0; + } + + count += 1; + if (len != PUZZLE_CELLS) { + fprintf(rejects, "%d: %s bogus puzzle format\n", count, inbuf); fflush(rejects); + *inbuf = 0; + bog += 1; + if (h) fgets(inbuf, 128, h); + continue; + } + + cvt_to_grid(&g, inbuf); + if (g.givens < 17) { + fprintf(rejects, "%d: %*.*s bogus puzzle has less than 17 givens\n", count, PUZZLE_CELLS, PUZZLE_CELLS, inbuf); fflush(rejects); + *inbuf = 0; + bog += 1; + if (h) fgets(inbuf, 128, h); + continue; + } + + for (s = soln_list; s;) { + s = soln_list->next; + free(soln_list); + soln_list = s; + } + + flag = rsolve(&g, add_soln); + if (soln_list) { + solved++; + for (solncount = 0, s = soln_list; s; s = s->next) { + solncount += 1; + if (prt_num) { + char nbuf[32]; + if (!enumerate_all) + sprintf(nbuf, "%d: ", count); + else + sprintf(nbuf, "%d:%d ", count, solncount); + fprintf(solnfile, "%-s", nbuf); + } + if (solncount > 1 || !enumerate_all) g.score = 0; + if (prt_score) fprintf(solnfile, "score: %-7d ", g.score); + if (prt_depth) fprintf(solnfile, "depth: %-3d ", g.maxlvl); + if (prt_answer || prt_grid) format_answer(s, outbuf); + if (prt_answer) fprintf(solnfile, "%s", outbuf); + if (prt_mask) fprintf(solnfile, " %s", cvt_to_mask(mbuf, inbuf)); + if (prt_givens) fprintf(solnfile, " %d", g.givens); + if (prt_grid) print_grid(outbuf, solnfile); + if (prt) fprintf(solnfile, "\n"); + if (s->next == NULL && prt_count) fprintf(solnfile, "count: %d\n", solncount); + } + if (solncount > 1 && enumerate_all) { + rc |= 1; + } + } + else { + unsolved++; + rc |= 1; + fprintf(rejects, "%d: %*.*s unsolved\n", count, PUZZLE_CELLS, PUZZLE_CELLS, inbuf); fflush(rejects); + diagnostic_grid(&g, rejects); +#if defined(DEBUG) + mypause(); +#endif + } + + *inbuf = 0; + if (h) fgets(inbuf, 128, h); + } + + //if (prt) fprintf(solnfile, "\nPuzzles: %d, Solved: %d, Unsolved: %d, Bogus: %d\n", count, solved, unsolved, bog); + *scorep = g.score; + return solncount; +} +// end https://github.com/attractivechaos/plb/blob/master/sudoku/incoming/sudoku_solver.c // start https://github.com/mentalmove/SudokuGenerator // @@ -605,9 +2599,9 @@ uint8_t sudoku_genopreturndecode(char *unsolved,CScript scriptPubKey) UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; uint256 hash; char coinaddr[64],*jsonstr; uint64_t inputsum,amount,change=0; std::string rawtx; + UniValue result(UniValue::VOBJ); CPubKey sudokupk,pk; uint8_t privkey[32],unsolved[9][9],pub33[33]; uint32_t srandi; int32_t i,score; uint256 hash; char coinaddr[64],str[82],*jsonstr; uint64_t inputsum,amount,change=0; std::string rawtx; amount = COIN; - if ( params != 0 ) + /*if ( params != 0 ) { if ( (jsonstr= jprint(params,0)) != 0 ) { @@ -618,14 +2612,26 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } amount = atof(jsonstr) * COIN + 0.0000000049; } - } + }*/ result.push_back(Pair("result","success")); result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","gen")); hash = chainActive.LastTip()->GetBlockHash(); memcpy(&srandi,&hash,sizeof(srandi)); srandi ^= (uint32_t)time(NULL); - sudoku_gen(privkey,unsolved,srandi); + while ( 1 ) + { + sudoku_gen(privkey,unsolved,srandi); + for (i=0; i Date: Wed, 30 Jan 2019 02:36:44 -1100 Subject: [PATCH 1631/3904] syntax --- src/cc/sudoku.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b34eccd39..02c47ef97 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -1160,17 +1160,17 @@ static int eliminate_singles(grid *g) /* Do rows */ for (i = 0; i < PUZZLE_DIM; i++) { - found |= find_singletons(g, row[i], "row"); + found |= find_singletons(g, row[i], (char *)"row"); } /* Do columns */ for (i = 0; i < PUZZLE_DIM; i++) { - found |= find_singletons(g, col[i], "column"); + found |= find_singletons(g, col[i], (char *)"column"); } /* Do regions */ for (i = 0; i < PUZZLE_DIM; i++) { - found |= find_singletons(g, region[i], "region"); + found |= find_singletons(g, region[i], (char *)"region"); } return found; @@ -1489,17 +1489,17 @@ static int mult_elimination(grid *g) /* Eliminate subsets from rows */ for (i = 0; i < PUZZLE_DIM; i++) { - rc |= elim_matches(g, row[i], "row", i); + rc |= elim_matches(g, row[i], (char *)"row", i); } /* Eliminate subsets from columns */ for (i = 0; i < PUZZLE_DIM; i++) { - rc |= elim_matches(g, col[i], "column", i); + rc |= elim_matches(g, col[i], (char *)"column", i); } /* Eliminate subsets from regions */ for (i = 0; i < PUZZLE_DIM; i++) { - rc |= elim_matches(g, region[i], "region", i); + rc |= elim_matches(g, region[i], (char *)"region", i); } return rc; @@ -1633,7 +1633,7 @@ static int add_soln(grid *g) { grid *tmp; - if ((tmp = malloc(sizeof(grid))) == NULL) { + if ((tmp = (grid *)malloc(sizeof(grid))) == NULL) { fprintf(stderr, "Out of memory.\n"); exit(1); } @@ -2623,7 +2623,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { sudoku_gen(privkey,unsolved,srandi); for (i=0; i Date: Wed, 30 Jan 2019 03:35:35 -1100 Subject: [PATCH 1632/3904] Check for illegal solution --- src/cc/cclib.cpp | 6 +++--- src/cc/sudoku.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index dd79d22d9..000245e56 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -37,17 +37,17 @@ char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } struct CClib_rpcinfo { char *CCname,*method,*help; - int32_t numrequiredargs,maxargs; // frontloaded with required + int32_t numrequiredargs,maxargs; uint8_t funcid,evalcode; } CClib_methods[] = { { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, - { (char *)"sudoku", (char *)"gen", (char *)"", 1, 1, 'G', EVAL_SUDOKU }, + { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_SUDOKU }, - { (char *)"sudoku", (char *)"solution", (char *)"txid solution timestamps[]", 2, 2, 'S', EVAL_SUDOKU }, + { (char *)"sudoku", (char *)"solution", (char *)"txid solution timestamps[81]", 83, 83, 'S', EVAL_SUDOKU }, }; std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 02c47ef97..e3cf7095d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2807,7 +2807,15 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { for (i=ind=0; i<9; i++) for (j=0; j<9; j++) + { + if ( solution[ind] < '1' || solution[ind] > '9' ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","illegal solution")); + return(result); + } vals9[i][j] = solution[ind++] - '0'; + } sudoku_privkey(priv32,vals9); priv2addr(coinaddr,pub33,priv32); pk = buf2pk(pub33); From a4055d478a079721e2b43a9d31578478ff03e9a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Jan 2019 03:45:50 -1100 Subject: [PATCH 1633/3904] Move sudokuaddr check --- src/cc/sudoku.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index e3cf7095d..5968f59d9 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2507,6 +2507,8 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) "result": "success", "hex": "0400008085202f8901328455ce926086f00be1b2adac0ba9adc22067a30948c71572f3da80adc1135d010000007b4c79a276a072a26ba067a565802102c57d40c1ddc92a5246a937bd7338823f1e8c916b137f2092d38cf250d74cb5ab8140f92d54f611aa3cb3d187eaadd56b06f3a8c0f5fba23956b26fdefc6038d9b6282de38525f72ebd8945a7994cef63ebca711ecf8fe6baeefcc218cf58efb59dc2a100af03800111a10001ffffffff02f0b9f505000000002321039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775ac0000000000000000fd9f016a4d9b01115351343639383233373135383735393631323334323331343537363938393134363735383233363533313832343739373832333934313536333436323139353837353238373336393431313937353438333632fd4401000000005c5078355c50783600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000" } + + cclib solution 17 \"[%224d50336780d5a300a1f01b12fe36f46a82f3b9935bb115e01e0113dc4f337aae%22,%22234791685716258943589643712865934127341827596927516438492375861178462359653189274%22,0,0,1548859143,1548859146,0,1548859146,0,1548859148,1548859149,0,1548859151,1548859152,0,1548859154,1548859155,1548859158,1548859159,0,0,0,1548859161,1548859163,0,1548859164,1548859168,0,1548859168,1548859170,1548859172,1548859172,1548859175,0,0,1548859176,0,0,1548859178,1548859178,0,0,1548859180,1548859181,1548859183,1548859184,1548859185,1548859186,1548859188,1548859190,1548859191,1548859192,1548859192,0,0,1548859195,1548859196,1548859197,1548859198,0,0,1548859199,1548859202,1548859202,0,1548859204,1548859205,1548859206,1548859209,1548859210,1548859211,1548859212,0,1548859214,1548859216,0,1548859217,1548859218,1548859219,1548859220,0,1548859222,1548859222]\" */ int32_t sudoku_captcha(uint32_t timestamps[81]) @@ -2820,15 +2822,6 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params priv2addr(coinaddr,pub33,priv32); pk = buf2pk(pub33); GetCCaddress(cp,CCaddr,pk); - Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey); - if ( strcmp(checkaddr,CCaddr) != 0 ) - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","wrong solution")); - result.push_back(Pair("yours",CCaddr)); - result.push_back(Pair("sudokuaddr",checkaddr)); - return(result); - } result.push_back(Pair("sudokuaddr",CCaddr)); balance = CCaddress_balance(CCaddr); result.push_back(Pair("amount",ValueFromAmount(balance))); @@ -2849,6 +2842,14 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("error","already solved")); else if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { + Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey); + if ( strcmp(checkaddr,CCaddr) != 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","wrong solution")); + result.push_back(Pair("yours",CCaddr)); + return(result); + } if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { for (i=0; i<81; i++) From 2ad90b9bd0c0a37a90c7d3bda6df5b4e2ace755b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Jan 2019 21:42:29 -1100 Subject: [PATCH 1634/3904] Skip staking utxo for ac_perc chains that stake --- src/komodo_bitcoind.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b3248d7d4..f638afa8a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1190,6 +1190,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && n == 1 ) + break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) total += pblock->vtx[i].vout[j].nValue; From 093635e9a8c750ecb8e5f93d321d94e5eb97e48f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Jan 2019 23:15:44 -1100 Subject: [PATCH 1635/3904] Initial validation skeleton --- src/cc/rewards.cpp | 2 +- src/cc/sudoku.cpp | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index bd5a6d919..b9f4677be 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -203,7 +203,7 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t else { txid = tx.GetHash(); - if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[numvouts-1].scriptPubKey,sbits,fundingtxid)) != 0 ) + if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[numvouts-1].scriptPubKey,sbits,fundingtxid)) != 0 ) { if ( eval->GetTxUnconfirmed(fundingtxid,fundingTx,hashBlock) == 0 ) return eval->Invalid("cant find fundingtxid"); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 5968f59d9..9d52728a3 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2909,5 +2909,36 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - return(true); + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t score,numvouts; char unsolved[82]; + if ( (numvouts= tx.vout.size()) > 1 ) + { + scriptPubKey = tx.vout[numvouts-1].scriptPubKey; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 ) + { + script = (uint8_t *)vopret.data(); + if ( script[0] == EVAL_SUDOKU ) + { + switch ( script[1] ) + { + case 'G': + if ( sudoku_genopreturndecode(unsolved,scriptPubKey) == 'G' ) + { + if ( dupree_solver(&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) + { + fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString()); + } + } + return(true); + case 'S': + fprintf(stderr,"SOLVED ht.%d %.8f %s\n",height,score,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString()); + return(true); + default: return eval->Invalid("invalid funcid"); + } + } else return eval->Invalid("invalid evalcode"); + + } + } + return eval->Invalid("not enough vouts"); } + From d6104a35c5c9200bed91806bbe41e2f40d8c9886 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Jan 2019 23:17:34 -1100 Subject: [PATCH 1636/3904] Fix --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 9d52728a3..4dd096082 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2926,12 +2926,12 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const { if ( dupree_solver(&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) { - fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString()); + fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); } } return(true); case 'S': - fprintf(stderr,"SOLVED ht.%d %.8f %s\n",height,score,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString()); + fprintf(stderr,"SOLVED ht.%d %.8f %s\n",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); return(true); default: return eval->Invalid("invalid funcid"); } From c738557c58f90a3e166ca2a3b7b9ccdbe5dd44ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Jan 2019 23:38:17 -1100 Subject: [PATCH 1637/3904] Test --- src/cc/sudoku.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 4dd096082..b55024036 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -1781,12 +1781,13 @@ int dupree_solver(int32_t *scorep,char *puzzle) grid g, *s=0; FILE *h=0; soln_list = NULL; - /* Get our command name from invoking command line */ + myname = "internal"; + /* Get our command name from invoking command line if ((myname = strrchr(argv[0], '/')) == NULL) myname = argv[0]; else myname++; - /*argc = 3; + argc = 3; argv[1] = "-p"; argv[2] = puzzle; argv[3] = 0;*/ @@ -2924,6 +2925,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const case 'G': if ( sudoku_genopreturndecode(unsolved,scriptPubKey) == 'G' ) { + fprintf(stderr,"unsolved.(%s)\n",unsolved); if ( dupree_solver(&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) { fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); From 1856fca69c89a52a597cd0ea7929c661cccb3258 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Jan 2019 23:57:06 -1100 Subject: [PATCH 1638/3904] Free mem in solver --- src/cc/sudoku.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b55024036..ad6927b6b 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -1773,7 +1773,7 @@ static char *cvt_to_mask(char *mbuf, char *sbuf) /* Mainline logic. */ /*******************/ -int dupree_solver(int32_t *scorep,char *puzzle) +int dupree_solver(int32_t dispflag,int32_t *scorep,char *puzzle) { int argc; char *argv[4]; int i, rc, bog, count, solved, unsolved, solncount=0, flag, prt_count, prt_num, prt_score, prt_answer, prt_depth, prt_grid, prt_mask, prt_givens, prt, len; @@ -1781,7 +1781,7 @@ int dupree_solver(int32_t *scorep,char *puzzle) grid g, *s=0; FILE *h=0; soln_list = NULL; - myname = "internal"; + myname = (char *)"internal"; /* Get our command name from invoking command line if ((myname = strrchr(argv[0], '/')) == NULL) myname = argv[0]; @@ -1873,15 +1873,6 @@ int dupree_solver(int32_t *scorep,char *puzzle) exit(1); } } -#endif - prt_answer = 1; /* print solution */ - //prt_count = 1; /* number solutions */ - prt_score = 1; - prt_givens = 1; - prt_num = 1; - /* Set prt flag if we're printing anything at all */ - prt = prt_mask | prt_grid | prt_score | prt_depth | prt_answer | prt_num | prt_givens; - /* Anthing else on the command line is bogus */ if (argc > optind) { fprintf(stderr, "Extraneous args: "); @@ -1912,6 +1903,15 @@ int dupree_solver(int32_t *scorep,char *puzzle) exit(1); } if (h) fgets(inbuf, 128, h);*/ +#endif + prt_answer = dispflag; /* print solution */ + //prt_count = dispflag; /* number solutions */ + prt_score = dispflag; + prt_givens = dispflag; + prt_num = dispflag; + /* Set prt flag if we're printing anything at all */ + prt = prt_mask | prt_grid | prt_score | prt_depth | prt_answer | prt_num | prt_givens; + strcpy(inbuf,puzzle); count = solved = unsolved = 0; //printf("inbuf.(%s)\n",inbuf); @@ -1927,7 +1927,7 @@ int dupree_solver(int32_t *scorep,char *puzzle) fprintf(rejects, "%d: %s bogus puzzle format\n", count, inbuf); fflush(rejects); *inbuf = 0; bog += 1; - if (h) fgets(inbuf, 128, h); + //if (h) fgets(inbuf, 128, h); continue; } @@ -1936,7 +1936,7 @@ int dupree_solver(int32_t *scorep,char *puzzle) fprintf(rejects, "%d: %*.*s bogus puzzle has less than 17 givens\n", count, PUZZLE_CELLS, PUZZLE_CELLS, inbuf); fflush(rejects); *inbuf = 0; bog += 1; - if (h) fgets(inbuf, 128, h); + //if (h) fgets(inbuf, 128, h); continue; } @@ -1973,6 +1973,11 @@ int dupree_solver(int32_t *scorep,char *puzzle) if (solncount > 1 && enumerate_all) { rc |= 1; } + for (s = soln_list; s;) { + s = soln_list->next; + free(soln_list); + soln_list = s; + } } else { unsolved++; @@ -1985,7 +1990,7 @@ int dupree_solver(int32_t *scorep,char *puzzle) } *inbuf = 0; - if (h) fgets(inbuf, 128, h); + //if (h) fgets(inbuf, 128, h); } //if (prt) fprintf(solnfile, "\nPuzzles: %d, Solved: %d, Unsolved: %d, Bogus: %d\n", count, solved, unsolved, bog); @@ -2629,7 +2634,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params str[i] = '0' + unsolved[i/9][i%9]; str[i] = 0; printf("solve: %s\n",str); - if ( dupree_solver(&score,str) == 1 ) + if ( dupree_solver(1,&score,str) == 1 ) { amount = score * COIN; break; @@ -2926,7 +2931,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const if ( sudoku_genopreturndecode(unsolved,scriptPubKey) == 'G' ) { fprintf(stderr,"unsolved.(%s)\n",unsolved); - if ( dupree_solver(&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) + if ( dupree_solver(0,&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) { fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); } From 71e47834e2bbcc8eacb15cb2b35a15c467fa3d21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:01:19 -1100 Subject: [PATCH 1639/3904] Enforce score == payout --- src/cc/sudoku.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index ad6927b6b..10485ec2d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2930,10 +2930,12 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const case 'G': if ( sudoku_genopreturndecode(unsolved,scriptPubKey) == 'G' ) { - fprintf(stderr,"unsolved.(%s)\n",unsolved); + //fprintf(stderr,"unsolved.(%s)\n",unsolved); if ( dupree_solver(0,&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) { fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); + if ( ht > 2000 ) + return eval->Invalid("mismatched sudoku value vs score"); } } return(true); From a5833d00f701966efeb6adf04fd0555a48ef46b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:04:51 -1100 Subject: [PATCH 1640/3904] Height --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 10485ec2d..395fac577 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2934,7 +2934,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const if ( dupree_solver(0,&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) { fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); - if ( ht > 2000 ) + if ( height > 2000 ) return eval->Invalid("mismatched sudoku value vs score"); } } From d97754614d9365f9aa3a1e575e9ed8048f2069e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:40:38 -1100 Subject: [PATCH 1641/3904] Check solution I-return --- src/cc/sudoku.cpp | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 395fac577..6a0f97583 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2586,6 +2586,35 @@ CScript sudoku_solutionopret(char *solution,uint32_t timestamps[81]) return(opret); } +uint8_t sudoku_solutionopreturndecode(char solution[82],uint32_t timestamps[81],CScript scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; std::string str; std::vector data; int32_t i,ind; uint32_t x; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> str; ss >> data) != 0 && e == EVAL_SUDOKU && f == 'S' ) + { + if ( data.size() == 81*sizeof(uint32_t) && strlen(solution) == 81 ) + { + for (i=ind=0; i<81; i++) + { + if ( solution[i] < '1' || solution[i] > '9' ) + break; + x = data[ind++]; + x <<= 8, x |= (data[ind++] & 0xff); + x <<= 8, x |= (data[ind++] & 0xff); + x <<= 8, x |= (data[ind++] & 0xff); + timestamps[i] = x; + } + if ( i == 81 ) + { + strcpy(solution,str.c_str()); + return(f); + } + } + } + return(0); +} + uint8_t sudoku_genopreturndecode(char *unsolved,CScript scriptPubKey) { std::vector vopret; uint8_t *script,e,f; std::vector data; int32_t i; @@ -2915,7 +2944,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t score,numvouts; char unsolved[82]; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t score,numvouts; char unsolved[82],solution[82]; uint32_t timestamps[81]; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -2936,12 +2965,19 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); if ( height > 2000 ) return eval->Invalid("mismatched sudoku value vs score"); - } + } else return(true); } - return(true); + return eval->Invalid("invalid generate opreturn"); case 'S': fprintf(stderr,"SOLVED ht.%d %.8f %s\n",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); - return(true); + if ( sudoku_solutionopreturndecode(solution,timestamps,scriptPubKey) == 'S' ) + { + for (i=0; i<81; i++) + fprintf(stderr,"%u ",timestamps[i]); + fprintf(stderr,"%s\n",solution); + return(true); + } + return eval->Invalid("invalid solution opreturn"); default: return eval->Invalid("invalid funcid"); } } else return eval->Invalid("invalid evalcode"); From 4aa8fce7d2f79f3282c7c3899deaab2dd18af01a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:41:15 -1100 Subject: [PATCH 1642/3904] Declare I --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 6a0f97583..4f8702c0a 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2944,7 +2944,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t score,numvouts; char unsolved[82],solution[82]; uint32_t timestamps[81]; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,score,numvouts; char unsolved[82],solution[82]; uint32_t timestamps[81]; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; From 503ef504482963e300722d60d0e52a3957d984b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:45:08 -1100 Subject: [PATCH 1643/3904] Exempt height 123 --- src/cc/sudoku.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 4f8702c0a..c83cf3464 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2967,6 +2967,8 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return eval->Invalid("mismatched sudoku value vs score"); } else return(true); } + else if ( height == 123 ) // early version invalid gen + return(true); return eval->Invalid("invalid generate opreturn"); case 'S': fprintf(stderr,"SOLVED ht.%d %.8f %s\n",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); From 0a0d310f7f2c296caa124cbf38aa0e4c362f1682 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:47:23 -1100 Subject: [PATCH 1644/3904] Print --- src/cc/sudoku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index c83cf3464..878d9a86d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2969,6 +2969,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const } else if ( height == 123 ) // early version invalid gen return(true); + fprintf(stderr,"height.%d txid.%s\n",height,tx.GetHash().ToString().c_str()); return eval->Invalid("invalid generate opreturn"); case 'S': fprintf(stderr,"SOLVED ht.%d %.8f %s\n",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); From d23000ccf5290756fa5bd899a49b2bccc188c7ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:48:57 -1100 Subject: [PATCH 1645/3904] Add return true path --- src/cc/sudoku.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 878d9a86d..49b23a367 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2965,10 +2965,9 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); if ( height > 2000 ) return eval->Invalid("mismatched sudoku value vs score"); + else return(true); } else return(true); } - else if ( height == 123 ) // early version invalid gen - return(true); fprintf(stderr,"height.%d txid.%s\n",height,tx.GetHash().ToString().c_str()); return eval->Invalid("invalid generate opreturn"); case 'S': From 7fc53be997b90353e56e377e7ff9fb8adef828c1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:51:32 -1100 Subject: [PATCH 1646/3904] Bad solution ? --- src/cc/sudoku.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 49b23a367..87570e7e2 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2963,7 +2963,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const if ( dupree_solver(0,&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) { fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); - if ( height > 2000 ) + if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 || height > 2000 ) return eval->Invalid("mismatched sudoku value vs score"); else return(true); } else return(true); @@ -2979,6 +2979,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"%s\n",solution); return(true); } + fprintf(stderr,"solution ht.%d %s bad opret\n",height,tx.GetHash().ToString().c_str()); return eval->Invalid("invalid solution opreturn"); default: return eval->Invalid("invalid funcid"); } From 8dc9205db0e5604e647f19d8305ec794608fa48e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:52:53 -1100 Subject: [PATCH 1647/3904] Ht 236 exemption --- src/cc/sudoku.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 87570e7e2..097153d40 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2980,6 +2980,8 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return(true); } fprintf(stderr,"solution ht.%d %s bad opret\n",height,tx.GetHash().ToString().c_str()); + if ( height == 236 && strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") == 0 ) + return(true); return eval->Invalid("invalid solution opreturn"); default: return eval->Invalid("invalid funcid"); } From 03bad588edf2836a8629429174a2336d4068a6c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 00:57:52 -1100 Subject: [PATCH 1648/3904] 1220 exemption --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 097153d40..57a88707e 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2980,7 +2980,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return(true); } fprintf(stderr,"solution ht.%d %s bad opret\n",height,tx.GetHash().ToString().c_str()); - if ( height == 236 && strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") == 0 ) + if ( (height == 236 || height == 1220) && strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") == 0 ) return(true); return eval->Invalid("invalid solution opreturn"); default: return eval->Invalid("invalid funcid"); From 16be17121fba408c7674f4a34a9f487ea4de9812 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 01:01:30 -1100 Subject: [PATCH 1649/3904] str.size()! --- src/cc/sudoku.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 57a88707e..2624fc54c 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2593,7 +2593,7 @@ uint8_t sudoku_solutionopreturndecode(char solution[82],uint32_t timestamps[81], script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> str; ss >> data) != 0 && e == EVAL_SUDOKU && f == 'S' ) { - if ( data.size() == 81*sizeof(uint32_t) && strlen(solution) == 81 ) + if ( data.size() == 81*sizeof(uint32_t) && str.size() == 81 ) { for (i=ind=0; i<81; i++) { @@ -2610,7 +2610,7 @@ uint8_t sudoku_solutionopreturndecode(char solution[82],uint32_t timestamps[81], strcpy(solution,str.c_str()); return(f); } - } + } else fprintf(stderr,"datasize %d sol[%d]\n",(int32_t)data.size(),(int32_t)str.size()); } return(0); } @@ -2982,7 +2982,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"solution ht.%d %s bad opret\n",height,tx.GetHash().ToString().c_str()); if ( (height == 236 || height == 1220) && strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") == 0 ) return(true); - return eval->Invalid("invalid solution opreturn"); + return true; //eval->Invalid("invalid solution opreturn"); default: return eval->Invalid("invalid funcid"); } } else return eval->Invalid("invalid evalcode"); From c0e2024b3c46888aa66c12792bab734433076737 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 01:03:29 -1100 Subject: [PATCH 1650/3904] Dont use uninitialized variables --- src/cc/sudoku.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 2624fc54c..c151e25fc 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2595,6 +2595,7 @@ uint8_t sudoku_solutionopreturndecode(char solution[82],uint32_t timestamps[81], { if ( data.size() == 81*sizeof(uint32_t) && str.size() == 81 ) { + strcpy(solution,str.c_str()); for (i=ind=0; i<81; i++) { if ( solution[i] < '1' || solution[i] > '9' ) @@ -2606,10 +2607,7 @@ uint8_t sudoku_solutionopreturndecode(char solution[82],uint32_t timestamps[81], timestamps[i] = x; } if ( i == 81 ) - { - strcpy(solution,str.c_str()); return(f); - } } else fprintf(stderr,"datasize %d sol[%d]\n",(int32_t)data.size(),(int32_t)str.size()); } return(0); From 9b966a4e725f584e7b031bc79275a42cd6766bc6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 01:06:30 -1100 Subject: [PATCH 1651/3904] filter prints --- src/cc/sudoku.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index c151e25fc..585f4fb3d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2942,7 +2942,8 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,score,numvouts; char unsolved[82],solution[82]; uint32_t timestamps[81]; + static char laststr[512]; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -2960,7 +2961,12 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const //fprintf(stderr,"unsolved.(%s)\n",unsolved); if ( dupree_solver(0,&score,unsolved) != 1 || score*COIN != tx.vout[1].nValue ) { - fprintf(stderr,"ht.%d score.%d vs %.8f %s\n",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); + sprintf(str,"ht.%d score.%d vs %.8f %s",height,score,(double)tx.vout[1].nValue/COIN,tx.GetHash().ToString().c_str()); + if ( strcmp(str,laststr) != 0 ) + { + strcpy(laststr,str); + fprintf(stderr,"%s\n",str); + } if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 || height > 2000 ) return eval->Invalid("mismatched sudoku value vs score"); else return(true); @@ -2969,7 +2975,12 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"height.%d txid.%s\n",height,tx.GetHash().ToString().c_str()); return eval->Invalid("invalid generate opreturn"); case 'S': - fprintf(stderr,"SOLVED ht.%d %.8f %s\n",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); + sprintf(str,"SOLVED ht.%d %.8f %s\n",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); + if ( strcmp(str,laststr) != 0 ) + { + strcpy(laststr,str); + fprintf(stderr,"%s\n",str); + } if ( sudoku_solutionopreturndecode(solution,timestamps,scriptPubKey) == 'S' ) { for (i=0; i<81; i++) From 31e3cba48be4a0da0f0accae6dd64721b856fa0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 01:07:27 -1100 Subject: [PATCH 1652/3904] Prints --- src/cc/sudoku.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 585f4fb3d..7fcfedb52 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2943,7 +2943,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static char laststr[512]; - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -2980,18 +2980,20 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const { strcpy(laststr,str); fprintf(stderr,"%s\n",str); - } + dispflag = 1; + } else dispflag = 0; if ( sudoku_solutionopreturndecode(solution,timestamps,scriptPubKey) == 'S' ) { - for (i=0; i<81; i++) - fprintf(stderr,"%u ",timestamps[i]); - fprintf(stderr,"%s\n",solution); + if ( dispflag != 0 ) + { + for (i=0; i<81; i++) + fprintf(stderr,"%u ",timestamps[i]); + fprintf(stderr,"%s\n",solution); + } return(true); } fprintf(stderr,"solution ht.%d %s bad opret\n",height,tx.GetHash().ToString().c_str()); - if ( (height == 236 || height == 1220) && strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") == 0 ) - return(true); - return true; //eval->Invalid("invalid solution opreturn"); + return eval->Invalid("invalid solution opreturn"); default: return eval->Invalid("invalid funcid"); } } else return eval->Invalid("invalid evalcode"); From 75834b5beb2c78cfb4b040e6a04b5058008c4d28 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 01:21:21 -1100 Subject: [PATCH 1653/3904] Print captcha data --- src/cc/sudoku.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 7fcfedb52..3457a5840 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2517,7 +2517,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) cclib solution 17 \"[%224d50336780d5a300a1f01b12fe36f46a82f3b9935bb115e01e0113dc4f337aae%22,%22234791685716258943589643712865934127341827596927516438492375861178462359653189274%22,0,0,1548859143,1548859146,0,1548859146,0,1548859148,1548859149,0,1548859151,1548859152,0,1548859154,1548859155,1548859158,1548859159,0,0,0,1548859161,1548859163,0,1548859164,1548859168,0,1548859168,1548859170,1548859172,1548859172,1548859175,0,0,1548859176,0,0,1548859178,1548859178,0,0,1548859180,1548859181,1548859183,1548859184,1548859185,1548859186,1548859188,1548859190,1548859191,1548859192,1548859192,0,0,1548859195,1548859196,1548859197,1548859198,0,0,1548859199,1548859202,1548859202,0,1548859204,1548859205,1548859206,1548859209,1548859210,1548859211,1548859212,0,1548859214,1548859216,0,1548859217,1548859218,1548859219,1548859220,0,1548859222,1548859222]\" */ -int32_t sudoku_captcha(uint32_t timestamps[81]) +int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height) { int32_t i,solvetime,diff,avetime,n = 0; uint64_t variance = 0; std::vector list; for (i=0; i<81; i++) @@ -2858,7 +2858,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("sudokuaddr",CCaddr)); balance = CCaddress_balance(CCaddr); result.push_back(Pair("amount",ValueFromAmount(balance))); - if ( sudoku_captcha(timestamps) < 0 ) + if ( sudoku_captcha(timestamps,komodo_nextheight()) < 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","captcha failure")); @@ -2975,11 +2975,11 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"height.%d txid.%s\n",height,tx.GetHash().ToString().c_str()); return eval->Invalid("invalid generate opreturn"); case 'S': - sprintf(str,"SOLVED ht.%d %.8f %s\n",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); + sprintf(str,"SOLVED ht.%d %.8f %s",height,(double)tx.vout[0].nValue/COIN,tx.GetHash().ToString().c_str()); if ( strcmp(str,laststr) != 0 ) { strcpy(laststr,str); - fprintf(stderr,"%s\n",str); + fprintf(stderr,"\n%s\n",str); dispflag = 1; } else dispflag = 0; if ( sudoku_solutionopreturndecode(solution,timestamps,scriptPubKey) == 'S' ) @@ -2989,6 +2989,8 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const for (i=0; i<81; i++) fprintf(stderr,"%u ",timestamps[i]); fprintf(stderr,"%s\n",solution); + if ( sudoku_captcha(timestamps,height) < 0 ) + return eval->Invalid("failed captcha"); } return(true); } From 0b297c6c859dd4bc6d854706a86fc43605fb90b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 01:26:08 -1100 Subject: [PATCH 1654/3904] Test --- src/cc/sudoku.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 3457a5840..613a38e8b 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2519,7 +2519,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height) { - int32_t i,solvetime,diff,avetime,n = 0; uint64_t variance = 0; std::vector list; + int32_t i,solvetime,diff,avetime,n = 0,retval = 0; uint64_t variance = 0; std::vector list; for (i=0; i<81; i++) { if ( timestamps[i] != 0 ) @@ -2535,17 +2535,17 @@ int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height) if ( list[0] >= list[n-1] ) { printf("list[0] %u vs list[%d-1] %u\n",list[0],n,list[n-1]); - return(-1); + retval = -1; } else if ( list[n-1] > chainActive.LastTip()->nTime+200 ) - return(-1); + retval = -2; else if ( solvetime >= 777 ) - return(0); + retval = 0; else { avetime = (solvetime / (n-1)); if ( avetime == 0 ) - return(-1); + retval = -3; for (i=0; i Date: Thu, 31 Jan 2019 01:54:33 -1100 Subject: [PATCH 1655/3904] More validation --- src/cc/sudoku.cpp | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 613a38e8b..426d46971 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2948,7 +2948,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static char laststr[512]; - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; CTransaction vintx; uint256 hashBlock; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -2989,15 +2989,33 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const } else dispflag = 0; if ( sudoku_solutionopreturndecode(solution,timestamps,scriptPubKey) == 'S' ) { - if ( dispflag != 0 ) + if ( tx.vin.size() > 1 && tx.vin[0].prevout.hash == tx.vin[1].prevout.hash && tx.vin[0].prevout.n == 0 && tx.vin[1].prevout.n == 1 && myGetTransaction(tx.vin[0].prevout.hash,vintx,hashBlock) != 0 ) { - for (i=0; i<81; i++) - fprintf(stderr,"%u ",timestamps[i]); - fprintf(stderr,"%s\n",solution); - if ( sudoku_captcha(timestamps,height) < 0 ) - return eval->Invalid("failed captcha"); - } - return(true); + if ( vintx.vout.size() > 1 && sudoku_genopreturndecode(unsolved,vintx.vout[vintx.vout.size()-1].scriptPubKey) == 'G' ) + { + if ( dispflag != 0 ) + { + for (i=0; i<81; i++) + { + fprintf(stderr,"%u ",timestamps[i]); + if ( (timestamps[i] == 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] != 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) + { + fprintf(stderr,"i.%d invalid timestamp vs unsolved.[%c]\n",i,unsolved[i]); + return eval->Invalid("invalid timestamp vs unsolved"); + } + } + if ( dupree_solver(0,&score,unsolved) != 1 ) + { + fprintf(stderr,"non-unique sudoku at ht.%d\n",height); + return eval->Invalid("invalid sudoku with multiple solutions"); + } + fprintf(stderr,"%s score.%d\n",solution,score); + } + if ( sudoku_captcha(timestamps,height) < 0 ) + return eval->Invalid("failed captcha"); + return(true); + } else return eval->Invalid("invalid solution opret"); + } else return eval->Invalid("invalid solution vin"); } fprintf(stderr,"solution ht.%d %s bad opret\n",height,tx.GetHash().ToString().c_str()); return eval->Invalid("invalid solution opreturn"); From 40f628504af4e5412add4cdf5cef5fae0d344a6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 01:56:57 -1100 Subject: [PATCH 1656/3904] Test --- src/cc/sudoku.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 426d46971..86f61ee0a 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -3015,7 +3015,10 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return eval->Invalid("failed captcha"); return(true); } else return eval->Invalid("invalid solution opret"); - } else return eval->Invalid("invalid solution vin"); + } + else if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") == 0 && height == 236 ) + return(true); + else return eval->Invalid("invalid solution vin"); } fprintf(stderr,"solution ht.%d %s bad opret\n",height,tx.GetHash().ToString().c_str()); return eval->Invalid("invalid solution opreturn"); From 6b3d8f710dcef2b95d6795ebb4fbc74cbfe7052e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:00:11 -1100 Subject: [PATCH 1657/3904] 1220 exemption --- src/cc/sudoku.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 86f61ee0a..b8cdb88e5 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -3000,8 +3000,9 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"%u ",timestamps[i]); if ( (timestamps[i] == 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] != 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) { - fprintf(stderr,"i.%d invalid timestamp vs unsolved.[%c]\n",i,unsolved[i]); - return eval->Invalid("invalid timestamp vs unsolved"); + fprintf(stderr,"i.%d invalid timestamp vs unsolved.[%c] %s\n",i,unsolved[i],unsolved); + if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 || height != 1220 ) + return eval->Invalid("invalid timestamp vs unsolved"); } } if ( dupree_solver(0,&score,unsolved) != 1 ) From ba0a1b5ae4bcf64b0359dca7a8696f2649956517 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:04:06 -1100 Subject: [PATCH 1658/3904] Test --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b8cdb88e5..4f283b69d 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -3000,9 +3000,9 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"%u ",timestamps[i]); if ( (timestamps[i] == 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] != 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) { - fprintf(stderr,"i.%d invalid timestamp vs unsolved.[%c] %s\n",i,unsolved[i],unsolved); - if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 || height != 1220 ) + if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 || (height != 1220 && height != 1383) ) return eval->Invalid("invalid timestamp vs unsolved"); + else fprintf(stderr,"i.%d invalid timestamp vs unsolved.[%c] %s\n",i,unsolved[i],unsolved); } } if ( dupree_solver(0,&score,unsolved) != 1 ) From de547e23accdc55e803faaf9a37a8061cf35b99d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:09:21 -1100 Subject: [PATCH 1659/3904] Unsolved print --- src/cc/sudoku.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 4f283b69d..a31bf4d60 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2948,7 +2948,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static char laststr[512]; - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; CTransaction vintx; uint256 hashBlock; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,errflag,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; CTransaction vintx; uint256 hashBlock; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -2993,25 +2993,28 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const { if ( vintx.vout.size() > 1 && sudoku_genopreturndecode(unsolved,vintx.vout[vintx.vout.size()-1].scriptPubKey) == 'G' ) { - if ( dispflag != 0 ) + for (i=errflag=0; i<81; i++) { - for (i=0; i<81; i++) - { + if ( dispflag != 0 ) fprintf(stderr,"%u ",timestamps[i]); - if ( (timestamps[i] == 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] != 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) - { - if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 || (height != 1220 && height != 1383) ) - return eval->Invalid("invalid timestamp vs unsolved"); - else fprintf(stderr,"i.%d invalid timestamp vs unsolved.[%c] %s\n",i,unsolved[i],unsolved); - } - } - if ( dupree_solver(0,&score,unsolved) != 1 ) - { - fprintf(stderr,"non-unique sudoku at ht.%d\n",height); - return eval->Invalid("invalid sudoku with multiple solutions"); - } - fprintf(stderr,"%s score.%d\n",solution,score); + if ( (timestamps[i] == 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] != 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) + errflag++; } + if ( errflag != 0 ) + { + if ( dispflag != 0 ) + fprintf(stderr,"errflag.%d %s\n",height,errflag,unsolved); + if ( (height != 1220 && height != 1383) || strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 ) + return eval->Invalid("invalid timestamp vs unsolved"); + } + if ( dupree_solver(0,&score,unsolved) != 1 ) + { + if ( dispflag != 0 ) + fprintf(stderr,"non-unique sudoku at ht.%d\n",height); + return eval->Invalid("invalid sudoku with multiple solutions"); + } + if ( dispflag != 0 ) + fprintf(stderr,"%s score.%d\n",solution,score); if ( sudoku_captcha(timestamps,height) < 0 ) return eval->Invalid("failed captcha"); return(true); From cc8fadd7c554d1b342ad9485553dadd741a65cf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:09:52 -1100 Subject: [PATCH 1660/3904] Fix print --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a31bf4d60..228ccc095 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -3003,7 +3003,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const if ( errflag != 0 ) { if ( dispflag != 0 ) - fprintf(stderr,"errflag.%d %s\n",height,errflag,unsolved); + fprintf(stderr,"ht.%d errflag.%d %s\n",height,errflag,unsolved); if ( (height != 1220 && height != 1383) || strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 ) return eval->Invalid("invalid timestamp vs unsolved"); } From d9a8323b60a7305008e7ddab4ff05576409d01ed Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:11:52 -1100 Subject: [PATCH 1661/3904] Reverse polarity --- src/cc/sudoku.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 228ccc095..0d1a33e07 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2997,7 +2997,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const { if ( dispflag != 0 ) fprintf(stderr,"%u ",timestamps[i]); - if ( (timestamps[i] == 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] != 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) + if ( (timestamps[i] != 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] == 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) errflag++; } if ( errflag != 0 ) @@ -3014,7 +3014,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return eval->Invalid("invalid sudoku with multiple solutions"); } if ( dispflag != 0 ) - fprintf(stderr,"%s score.%d\n",solution,score); + fprintf(stderr,"%s score.%d %s\n",solution,score,unsolved); if ( sudoku_captcha(timestamps,height) < 0 ) return eval->Invalid("failed captcha"); return(true); From e37fd6ef9081e3b8a1fc63f6e6c47e489d98fbc6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:19:27 -1100 Subject: [PATCH 1662/3904] Scores convergence --- src/cc/sudoku.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 0d1a33e07..dc8fb2f42 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -3017,6 +3017,20 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"%s score.%d %s\n",solution,score,unsolved); if ( sudoku_captcha(timestamps,height) < 0 ) return eval->Invalid("failed captcha"); + for (i=0; i<81; i++) + { + if ( (ind= sudoku_minval(timestamps)) >= 0 ) + { + unsolved[ind] = solution[ind]; + if ( dupree_solver(0,&score,unsolved) != 1 ) + fprintf(stderr,"i.%d ind.%d non-unique\n",i,ind); + if ( dispflag != 0 ) + fprintf(stderr,"%d ",score); + timestamps[ind] = 0; + } else break; + } + if ( dispflag != 0 ) + fprintf(stderr,"scores convergence\n"); return(true); } else return eval->Invalid("invalid solution opret"); } From 9e9f33d00c62ef874cef3a3ec52e681e638b065a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:22:04 -1100 Subject: [PATCH 1663/3904] mintimestamp --- src/cc/sudoku.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index dc8fb2f42..b69081065 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2945,6 +2945,15 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(result); } +sudoku_minval(uint32_t timestamps[81]) +{ + int32_t i,ind = -1; uint32_t mintimestamp = 0xffffffff; + for (i=0; i<81; i++) + if ( timestamps[i] != 0 && timestamps[i] < mintimestamp ) + mintimestamp = timestamps[i], ind = i; + return(ind); +} + bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static char laststr[512]; From fea0e3f845bebe93438fe12dcf0ec13b6c2ee968 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:22:51 -1100 Subject: [PATCH 1664/3904] Ind --- src/cc/sudoku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b69081065..ff48af50c 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2957,7 +2957,7 @@ sudoku_minval(uint32_t timestamps[81]) bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static char laststr[512]; - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,errflag,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; CTransaction vintx; uint256 hashBlock; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; CTransaction vintx; uint256 hashBlock; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; From 94f4c7c7de1a29a4befcd3147ce1cea34bb07dcf Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:25:46 -1100 Subject: [PATCH 1665/3904] sudoku_minval --- src/cc/sudoku.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index ff48af50c..af404807f 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2945,12 +2945,16 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(result); } -sudoku_minval(uint32_t timestamps[81]) +int32_t sudoku_minval(uint32_t timestamps[81]) { int32_t i,ind = -1; uint32_t mintimestamp = 0xffffffff; for (i=0; i<81; i++) if ( timestamps[i] != 0 && timestamps[i] < mintimestamp ) + { mintimestamp = timestamps[i], ind = i; + fprintf(stderr,"%d ",i); + } + fprintf(stderr,"mintimestamp.%u\n",mintimestamp); return(ind); } From 7ed14754e59909bbf0519404304f42a199379fe8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:27:52 -1100 Subject: [PATCH 1666/3904] -print --- src/cc/sudoku.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index af404807f..ca2eddd91 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2952,9 +2952,9 @@ int32_t sudoku_minval(uint32_t timestamps[81]) if ( timestamps[i] != 0 && timestamps[i] < mintimestamp ) { mintimestamp = timestamps[i], ind = i; - fprintf(stderr,"%d ",i); + //fprintf(stderr,"%d ",i); } - fprintf(stderr,"mintimestamp.%u\n",mintimestamp); + //fprintf(stderr,"mintimestamp.%u\n",mintimestamp); return(ind); } @@ -3035,11 +3035,11 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const if ( (ind= sudoku_minval(timestamps)) >= 0 ) { unsolved[ind] = solution[ind]; + timestamps[ind] = 0; if ( dupree_solver(0,&score,unsolved) != 1 ) fprintf(stderr,"i.%d ind.%d non-unique\n",i,ind); if ( dispflag != 0 ) fprintf(stderr,"%d ",score); - timestamps[ind] = 0; } else break; } if ( dispflag != 0 ) From b79e7c623192f22f833527994d2625341138b343 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:31:35 -1100 Subject: [PATCH 1667/3904] Time diffs --- src/cc/sudoku.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index ca2eddd91..b650b1d00 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2961,7 +2961,7 @@ int32_t sudoku_minval(uint32_t timestamps[81]) bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static char laststr[512]; - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; CTransaction vintx; uint256 hashBlock; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t lasttime,timestamps[81]; CTransaction vintx; uint256 hashBlock; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -3030,16 +3030,19 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"%s score.%d %s\n",solution,score,unsolved); if ( sudoku_captcha(timestamps,height) < 0 ) return eval->Invalid("failed captcha"); - for (i=0; i<81; i++) + for (i=lasttime=0; i<81; i++) { if ( (ind= sudoku_minval(timestamps)) >= 0 ) { unsolved[ind] = solution[ind]; - timestamps[ind] = 0; + if ( lasttime == 0 ) + lasttime = timestamps[ind]; if ( dupree_solver(0,&score,unsolved) != 1 ) fprintf(stderr,"i.%d ind.%d non-unique\n",i,ind); if ( dispflag != 0 ) - fprintf(stderr,"%d ",score); + fprintf(stderr,"%d.%d ",score,timestamps[ind]-lasttime); + lasttime = timestamps[ind]; + timestamps[ind] = 0; } else break; } if ( dispflag != 0 ) From 7cb34662f7d9ccb569637b57eafad9b90bf094b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:41:53 -1100 Subject: [PATCH 1668/3904] Errcheck --- src/cc/sudoku.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index b650b1d00..01016de81 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2555,13 +2555,13 @@ int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height) } variance /= (n - 1); printf("solvetime.%d n.%d avetime.%d variance.%llu vs ave2 %d\n",solvetime,n,avetime,(long long)variance,avetime*avetime); - if ( variance < avetime*avetime ) - return(-1 * 0); + if ( variance < avetime ) + retval = -5; else return(0); } - } else retval = -5; + } else retval = -6; if ( retval != 0 ) - fprintf(stderr,"retval.%d\n",retval); + fprintf(stderr,"ERR >>>>>>>>>>>>>>> ht.%d retval.%d\n",height,retval); if ( height < 2000 ) return(0); else return(retval); @@ -2961,7 +2961,7 @@ int32_t sudoku_minval(uint32_t timestamps[81]) bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static char laststr[512]; - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t lasttime,timestamps[81]; CTransaction vintx; uint256 hashBlock; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; char unsolved[82],solution[82],str[512]; uint32_t timestamps[81]; CTransaction vintx; uint256 hashBlock; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -2997,7 +2997,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const if ( strcmp(str,laststr) != 0 ) { strcpy(laststr,str); - fprintf(stderr,"\n%s\n",str); + fprintf(stderr,"%s\n",str); dispflag = 1; } else dispflag = 0; if ( sudoku_solutionopreturndecode(solution,timestamps,scriptPubKey) == 'S' ) @@ -3008,7 +3008,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const { for (i=errflag=0; i<81; i++) { - if ( dispflag != 0 ) + if ( 0 && dispflag != 0 ) fprintf(stderr,"%u ",timestamps[i]); if ( (timestamps[i] != 0 && unsolved[i] >= '1' && unsolved[i] <= '9') || (timestamps[i] == 0 && (unsolved[i] < '1' || unsolved[i] > '9')) ) errflag++; @@ -3030,7 +3030,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const fprintf(stderr,"%s score.%d %s\n",solution,score,unsolved); if ( sudoku_captcha(timestamps,height) < 0 ) return eval->Invalid("failed captcha"); - for (i=lasttime=0; i<81; i++) + /*for (i=lasttime=0; i<81; i++) { if ( (ind= sudoku_minval(timestamps)) >= 0 ) { @@ -3046,7 +3046,7 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const } else break; } if ( dispflag != 0 ) - fprintf(stderr,"scores convergence\n"); + fprintf(stderr,"scores convergence\n");*/ return(true); } else return eval->Invalid("invalid solution opret"); } From 659a5dda2a99090d67fc8d4de8a2d315ca600497 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 02:50:29 -1100 Subject: [PATCH 1669/3904] Initial validation --- src/cc/sudoku.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 01016de81..7cff6b280 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2517,7 +2517,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) cclib solution 17 \"[%224d50336780d5a300a1f01b12fe36f46a82f3b9935bb115e01e0113dc4f337aae%22,%22234791685716258943589643712865934127341827596927516438492375861178462359653189274%22,0,0,1548859143,1548859146,0,1548859146,0,1548859148,1548859149,0,1548859151,1548859152,0,1548859154,1548859155,1548859158,1548859159,0,0,0,1548859161,1548859163,0,1548859164,1548859168,0,1548859168,1548859170,1548859172,1548859172,1548859175,0,0,1548859176,0,0,1548859178,1548859178,0,0,1548859180,1548859181,1548859183,1548859184,1548859185,1548859186,1548859188,1548859190,1548859191,1548859192,1548859192,0,0,1548859195,1548859196,1548859197,1548859198,0,0,1548859199,1548859202,1548859202,0,1548859204,1548859205,1548859206,1548859209,1548859210,1548859211,1548859212,0,1548859214,1548859216,0,1548859217,1548859218,1548859219,1548859220,0,1548859222,1548859222]\" */ -int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height) +int32_t sudoku_captcha(int32_t dispflag,uint32_t timestamps[81],int32_t height) { int32_t i,solvetime,diff,avetime,n = 0,retval = 0; uint64_t variance = 0; std::vector list; for (i=0; i<81; i++) @@ -2549,20 +2549,22 @@ int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height) for (i=0; i>>>>>>>>>>>>>> ht.%d retval.%d\n",height,retval); - if ( height < 2000 ) + if ( height <= 2036 ) return(0); else return(retval); } @@ -2863,7 +2865,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("sudokuaddr",CCaddr)); balance = CCaddress_balance(CCaddr); result.push_back(Pair("amount",ValueFromAmount(balance))); - if ( sudoku_captcha(timestamps,komodo_nextheight()) < 0 ) + if ( sudoku_captcha(1,timestamps,komodo_nextheight()) < 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","captcha failure")); @@ -3024,11 +3026,12 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const { if ( dispflag != 0 ) fprintf(stderr,"non-unique sudoku at ht.%d\n",height); - return eval->Invalid("invalid sudoku with multiple solutions"); + if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 ) + return eval->Invalid("invalid sudoku with multiple solutions"); } if ( dispflag != 0 ) fprintf(stderr,"%s score.%d %s\n",solution,score,unsolved); - if ( sudoku_captcha(timestamps,height) < 0 ) + if ( sudoku_captcha(dispflag,timestamps,height) < 0 ) return eval->Invalid("failed captcha"); /*for (i=lasttime=0; i<81; i++) { From 38c2c935099ef364e6ff0915f2d05f1f19b3953c Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Thu, 31 Jan 2019 18:44:36 +0100 Subject: [PATCH 1670/3904] Gateways validation (#16) - Validation implemented and enabled - Fixed partial sign spending marker - OracleFeed fixes --- src/cc/CCtx.cpp | 4 +- src/cc/dapps/oraclefeed.c | 16 +- src/cc/gateways.cpp | 496 ++++++++++++++++++++++++-------------- 3 files changed, 332 insertions(+), 184 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 5228703ea..48b5927a5 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -380,7 +380,7 @@ int64_t CCaddress_balance(char *coinaddr) int64_t CCfullsupply(uint256 tokenid) { uint256 hashBlock; int32_t numvouts; CTransaction tx; std::vector origpubkey; std::string name,description; - if ( GetTransaction(tokenid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + if ( myGetTransaction(tokenid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) { if (DecodeTokenCreateOpRet(tx.vout[numvouts-1].scriptPubKey,origpubkey,name,description)) { @@ -401,7 +401,7 @@ int64_t CCtoken_balance(char *coinaddr,uint256 reftokenid) for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 ) { char str[65]; std::vector voutTokenPubkeys; diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index 8f7ccb197..d6cf753f9 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -320,13 +320,13 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char { if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 ) printf("unexpected: refcoin.(%s) acname.(%s)\n",refcoin,acname); - sprintf(cmdstr,"./komodo-cli -ac_name=%s %s %s %s %s %s > %s\n",acname,method,arg0,arg1,arg2,arg3,fname); + sprintf(cmdstr,"./komodo-cli -ac_name=%s %s %s %s %s %s > %s 2>/tmp/oraclefeed.error\n",acname,method,arg0,arg1,arg2,arg3,fname); } else if ( strcmp(refcoin,"KMD") == 0 ) - sprintf(cmdstr,"./komodo-cli %s %s %s %s %s > %s\n",method,arg0,arg1,arg2,arg3,fname); + sprintf(cmdstr,"./komodo-cli %s %s %s %s %s > %s 2>/tmp/oraclefeed.error\n",method,arg0,arg1,arg2,arg3,fname); else if ( REFCOIN_CLI != 0 && REFCOIN_CLI[0] != 0 ) { - sprintf(cmdstr,"%s %s %s %s %s %s > %s\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,fname); + sprintf(cmdstr,"%s %s %s %s %s %s > %s 2>/tmp/oraclefeed.error\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,fname); printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); } #ifdef TESTMODE @@ -590,7 +590,7 @@ void importaddress(char *refcoin,char *acname,char *depositaddr, char *label,int void addmultisigaddress(char *refcoin,char *acname,int32_t M, char *pubkeys) { - cJSON *retjson; char *retstr,Mstr[10],tmp[128]; + cJSON *retjson; char *retstr,Mstr[10],addr[64]; sprintf(Mstr,"%d",M); if ( (retjson= get_komodocli(refcoin,&retstr,acname,"addmultisigaddress",Mstr,pubkeys,"","")) != 0 ) @@ -600,6 +600,8 @@ void addmultisigaddress(char *refcoin,char *acname,int32_t M, char *pubkeys) } else if ( retstr != 0 ) { + sprintf(addr,"\"%s\"",retstr); + get_komodocli(refcoin,&retstr,acname,"importaddress",addr,"\"\"","false",""); printf("addmultisigaddress.(%s)\n",retstr); free_json(retjson); } @@ -678,7 +680,7 @@ char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawadd free(argB); } else printf("not enough funds to create withdraw tx\n"); - } + } free_json(retjson); } else if ( retstr != 0 ) @@ -697,7 +699,7 @@ cJSON *addsignature(char *refcoin,char *acname,char *rawtx) { if ( is_cJSON_True(jobj(retjson,"complete")) != 0 ) return(retjson); - else if ( (hexstr= jstr(retjson,"hex")) != 0 && strlen(hexstr) > strlen(rawtx) + 2 ) + else if ((hexstr=jstr(retjson,"hex"))!= 0 && strlen(hexstr) > strlen(rawtx) + 2 ) { jaddnum(retjson,"partialtx",1); return(retjson); @@ -923,7 +925,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t } else rawtx=jstr(item,"hex"); K=jint(item,"number_of_signs"); - if ( (clijson= addsignature(refcoin,"",rawtx)) != 0 ) + if ( rawtx!=0 && (clijson= addsignature(refcoin,"",rawtx)) != 0 ) { if ( is_cJSON_True(jobj(clijson,"complete")) != 0 ) { diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index a16c2cf32..4e2f64184 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -267,14 +267,14 @@ uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256& tokeni return(0); } -CScript EncodeGatewaysPartialOpRet(uint8_t funcid, uint256 withdrawtxid,std::string refcoin,int32_t K, CPubKey signerpk,std::string hex) +CScript EncodeGatewaysPartialOpRet(uint8_t funcid, uint256 withdrawtxid,std::string refcoin,uint8_t K, CPubKey signerpk,std::string hex) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << K << signerpk << hex); return(opret); } -uint8_t DecodeGatewaysPartialOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,int32_t &K, CPubKey &signerpk,std::string &hex) +uint8_t DecodeGatewaysPartialOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,uint8_t &K,CPubKey &signerpk,std::string &hex) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); @@ -286,38 +286,38 @@ uint8_t DecodeGatewaysPartialOpRet(const CScript &scriptPubKey,uint256 &withdraw return(0); } -CScript EncodeGatewaysCompleteSigningOpRet(uint8_t funcid,uint256 withdrawtxid,std::string refcoin,std::string hex) +CScript EncodeGatewaysCompleteSigningOpRet(uint8_t funcid,uint256 withdrawtxid,std::string refcoin,uint8_t K,std::string hex) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << hex); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << K << hex); return(opret); } -uint8_t DecodeGatewaysCompleteSigningOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,std::string &hex) +uint8_t DecodeGatewaysCompleteSigningOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,uint8_t &K,std::string &hex) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> hex) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> K; ss >> hex) != 0 ) { return(f); } return(0); } -CScript EncodeGatewaysMarkDoneOpRet(uint8_t funcid,std::string refcoin,uint256 completetxid,uint256 withdrawtxid) +CScript EncodeGatewaysMarkDoneOpRet(uint8_t funcid,uint256 withdrawtxid,std::string refcoin,uint256 completetxid) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << refcoin << completetxid < vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> refcoin; ss >> completetxid; ss >> withdrawtxid;) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> completetxid;) != 0 ) { return(f); } @@ -541,16 +541,52 @@ int64_t GatewaysDepositval(CTransaction tx,CPubKey mypk) return(0); } +int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 reftokenid) +{ + char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; + uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; CTransaction tx; + std::vector > addressIndex; + + _GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk); + SetCCtxids(addressIndex,markeraddr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) + { + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' ) + { + if ( tokenid == reftokenid ) + { + fprintf(stderr,"trying to bind an existing tokenid\n"); + return(1); + } + } + } + } + BOOST_FOREACH(const CTxMemPoolEntry &e, mempool.mapTx) + { + const CTransaction &txmempool = e.GetTx(); + const uint256 &hash = txmempool.GetHash(); + + if ((numvouts=txmempool.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B') + if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' && + tokenid == reftokenid) + return(1); + } + + return(0); +} + bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) { - int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],M,N,taddr,prefix,prefix2; + int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],K,M,N,taddr,prefix,prefix2; char str[65],destaddr[64],depositaddr[65],validationError[512]; - std::vector txids; std::vector pubkeys,publishers,tmppublishers; std::vector proof; int64_t totalsupply,amount,tmpamount; - uint256 hashblock,txid,bindtxid,deposittxid,tokenidClaim,oracletxid,tokenidBind,cointxid,tmptxid,tmpxtxid2,merkleroot,mhash; CTransaction bindtx,deposittx,oracletx; - std::string refcoin,tmprefcoin,deposithex; CPubKey destpub,tmpdestpub; + std::vector txids; std::vector pubkeys,publishers,tmppublishers; std::vector proof; int64_t fullsupply,totalsupply,amount,tmpamount; + uint256 hashblock,txid,bindtxid,deposittxid,withdrawtxid,completetxid,tokenid,tmptokenid,oracletxid,bindtokenid,cointxid,tmptxid,merkleroot,mhash; CTransaction bindtx,tmptx; + std::string refcoin,tmprefcoin,hex,name,description,format; CPubKey pubkey,tmppubkey,gatewayspk; - fprintf(stderr,"return true without gateways validation\n"); - return(true); + // fprintf(stderr,"return true without gateways validation\n"); + // return(true); numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; @@ -573,8 +609,9 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & // } // else // { - txid = tx.GetHash(); - memcpy(hash,&txid,sizeof(hash)); + // txid = tx.GetHash(); + // memcpy(hash,&txid,sizeof(hash)); + gatewayspk = GetUnspendable(cp,0); if ( (funcid = DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)) != 0) { @@ -582,116 +619,261 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & { case 'B': //vin.0: normal input - //vout.0: CC vout txfee marker - //vout.n-1: opreturn - 'B' coin tokenid totalsupply oracletxid M N pubkeys taddr prefix prefix2 + //vin.1: CC input of tokens + //vout.0: CC vout of gateways tokens to gateways tokens CC address + //vout.1: CC vout txfee marker + //vout.n-1: opreturn - 'B' tokenid coin totalsupply oracletxid M N pubkeys taddr prefix prefix2 return eval->Invalid("unexpected GatewaysValidate for gatewaysbind!"); break; case 'D': //vin.0: normal input //vout.0: CC vout txfee marker to destination pubkey //vout.1: normal output txfee marker to txidaddr - //vout.n-1: opreturn - 'D' coin bindtxid publishers txids height cointxid deposithex proof destpub amount + //vout.n-1: opreturn - 'D' bindtxid coin publishers txids height cointxid claimvout deposithex proof destpub amount return eval->Invalid("unexpected GatewaysValidate for gatewaysdeposit!"); break; - case 't': + case 'C': //vin.0: normal input - //vin.1: CC input of converted token to gateways eval code + //vin.1: CC input of gateways tokens //vin.2: CC input of marker from gatewaysdeposit tx - //vout.0: CC vout of total tokens from deposit amount to asset eval code - //(vout.1): CC vout if there is change of unused tokens back to owner of tokens (deposit amount less than available tokens) - //vout.n-1: opreturn - 't' tokenid zeroid 0 mypubkey (NOTE: opreturn is with asset eval code) - // if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysClaimOpRet(tx.vout[numvouts-1].scriptPubKey,tokenidClaim,refcoin,bindtxid,deposittxid,destpub,amount)==0) - // return eval->Invalid("invalid gatewaysclaim OP_RETURN data!"); - // else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - // return eval->Invalid("vin.0 is normal for gatewaysClaim!"); - // else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - // return eval->Invalid("vin.1 is CC for gatewaysClaim!"); - // else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) - // return eval->Invalid("vin.2 is CC for gatewaysClaim!"); - // else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - // return eval->Invalid("vout.0 is CC for gatewaysClaim!"); - // else if ( numvouts > 2 && tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) - // return eval->Invalid("vout.1 is CC for gatewaysClaim!"); - // else if (myGetTransaction(bindtxid,bindtx,hashblock) == 0) - // return eval->Invalid("invalid gatewaysbind txid!"); - // else if ((numvouts=bindtx.vout.size()) > 0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tmprefcoin,tokenidBind,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') - // return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); - // else if (tmprefcoin!=refcoin) - // return eval->Invalid("refcoin different in bind tx"); - // else if (tokenidClaim!=tokenidBind) - // return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); - // else if (komodo_txnotarizedconfirmed(bindtxid) == false) - // return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); - // else if (myGetTransaction(deposittxid,deposittx,hashblock) == 0) - // return eval->Invalid("invalid gatewaysdeposittxid!"); - // else if ((numvouts=deposittx.vout.size()) > 0 && DecodeGatewaysDepositOpRet(deposittx.vout[numvouts-1].scriptPubKey,tmprefcoin,tmptxid,tmppublishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D') - // return eval->Invalid("invalid gatewaysdeposit OP_RETURN data!"); - // else if (tmprefcoin!=refcoin) - // return eval->Invalid("refcoin different in deposit tx"); - // else if (bindtxid!=tmptxid) - // return eval->Invalid("bindtxid does not match to bindtxid from gatewaysdeposit"); - // else if (tmpamount>totalsupply) - // return eval->Invalid("deposit amount greater then bind total supply"); - // else if (komodo_txnotarizedconfirmed(deposittxid) == false) - // return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!"); - // else if (amount>tmpamount) - // return eval->Invalid("claimed amount greater then deposit amount"); - // else if (destpub!=tmpdestpub) - // return eval->Invalid("destination pubkey different than in deposit tx"); - // else - // { - // int32_t m; - // merkleroot = zeroid; - // for (i=m=0; iInvalid(validationError); - // } - // if ( GatewaysCointxidExists(cp,cointxid) != 0 ) - // { - // sprintf(validationError,"cointxid.%s already exists\n",uint256_str(str,cointxid)); - // return eval->Invalid(validationError); - // } - // if (GatewaysVerify(depositaddr,oracletxid,claimvout,tmprefcoin,cointxid,deposithex,proof,merkleroot,destpub)!=amount) - // return eval->Invalid("deposittxid didnt validate\n"); - // } + //vout.0: CC vout of tokens from deposit amount to destinatoin pubkey + //vout.1: CC vout change of gateways tokens to gateways tokens CC address (if any) + //vout.n-1: opreturn - 'C' tokenid bindtxid coin deposittxid destpub amount + if ((numvouts=tx.vout.size()) < 1 || DecodeGatewaysClaimOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,refcoin,deposittxid,pubkey,amount)!='C') + return eval->Invalid("invalid gatewaysClaim OP_RETURN data!"); + else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysClaim!"); + else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysClaim!"); + else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) + return eval->Invalid("vin.2 is CC for gatewaysClaim!"); + else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.0 is CC for gatewaysClaim!"); + else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysbind txid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (tmptokenid!=tokenid) + return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); + else if ( N == 0 || N > 15 || M > N ) + return eval->Invalid("invalid MofN in gatewaysbind"); + else if (pubkeys.size()!=N) + { + sprintf(validationError,"not enough pubkeys(%ld) for N.%d gatewaysbind ",pubkeys.size(),N); + return eval->Invalid(validationError); + } + else if ( (fullsupply=CCfullsupply(tokenid)) != totalsupply ) + { + sprintf(validationError,"Gateway bind.%s (%s) globaladdr.%s totalsupply %.8f != fullsupply %.8f\n",refcoin.c_str(),uint256_str(str,tokenid),cp->unspendableCCaddr,(double)totalsupply/COIN,(double)fullsupply/COIN); + return eval->Invalid(validationError); + } + else if (myGetTransaction(oracletxid,tmptx,hashblock) == 0 || (numvouts=tmptx.vout.size()) <= 0 ) + { + sprintf(validationError,"cant find oracletxid %s\n",uint256_str(str,oracletxid)); + return eval->Invalid(validationError); + } + else if ( DecodeOraclesCreateOpRet(tmptx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' ) + { + sprintf(validationError,"mismatched oracle name %s != %s\n",name.c_str(),refcoin.c_str()); + return eval->Invalid(validationError); + } + else if (format.size()!=3 || strncmp(format.c_str(),"Ihh",3)!=0) + { + sprintf(validationError,"illegal format %s != Ihh\n",format.c_str()); + return eval->Invalid(validationError); + } + else if (komodo_txnotarizedconfirmed(bindtxid) == false) + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(deposittxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysdeposittxid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysDepositOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptxid,tmprefcoin,tmppublishers,txids,height,cointxid,claimvout,hex,proof,tmppubkey,tmpamount) != 'D') + return eval->Invalid("invalid gatewaysdeposit OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in deposit tx"); + else if (bindtxid!=tmptxid) + return eval->Invalid("bindtxid does not match to bindtxid from gatewaysdeposit"); + else if (tmpamount>totalsupply) + return eval->Invalid("deposit amount greater then bind total supply"); + else if (komodo_txnotarizedconfirmed(deposittxid) == false) + return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!"); + else if (amount!=tmpamount) + return eval->Invalid("claimed amount different then deposit amount"); + else if (tx.vout[0].nValue!=amount) + return eval->Invalid("claim amount not matching amount in opret"); + else if (pubkey!=tmppubkey) + return eval->Invalid("claim destination pubkey different than in deposit tx"); + else + { + int32_t m; + merkleroot = zeroid; + for (i=m=0; iInvalid(validationError); + } + else if (GatewaysVerify(depositaddr,oracletxid,claimvout,tmprefcoin,cointxid,hex,proof,merkleroot,pubkey)!=amount) + return eval->Invalid("external deposit not verified\n"); + } break; case 'W': //vin.0: normal input - //vin.1: CC input of converted token back to gateways eval code - //vout.0: CC vout of tokens back to gateways CC address - //vout.1: normal vout txfee marker to withdraw destination pubkey - //vout.2: CC vout txfee marker to gateways CC address - //vout.n-2: CC vout if there is change of unused tokens back to owner of tokens (withdraw amount less than owner available tokens) - //vout.n-1: opreturn - 'W' tokenid refcoin withdrawpub amount + //vin.1: CC input of tokens + //vout.0: CC vout txfee marker to gateways CC address + //vout.1: CC vout of gateways tokens back to gateways tokens CC address + //vout.2: CC vout change of tokens back to owners pubkey (if any) + //vout.n-1: opreturn - 'W' tokenid bindtxid refcoin withdrawpub amount + return eval->Invalid("unexpected GatewaysValidate for gatewaysWithdraw!"); break; case 'P': //vin.0: normal input - //(vin.1): CC input form previous marker of gatewayspartialsign tx (if exists) - //vout.0: CC vout 5k sat marker to senders pubKey - //vout.n-1: opreturn - 'P' number_of_signs mypk refcoin hex + //vin.1: CC input of marker from previous tx (withdraw or partialsing) + //vout.0: CC vout txfee marker to gateways CC address + //vout.n-1: opreturn - 'P' withdrawtxid refcoin number_of_signs mypk hex + if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,K,pubkey,hex)!='P') + return eval->Invalid("invalid gatewaysPartialSign OP_RETURN data!"); + else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysPartialSign!"); + else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysPartialSign!"); + else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.0 is CC for gatewaysPartialSign!"); + else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid withdraw txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,tmprefcoin,pubkey,amount)!='W') + return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); + else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); + else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.0 is CC for gatewaysWithdraw!"); + else if ( tmptx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.1 is CC for gatewaysWithdraw!"); + else if (tmptx.vout[1].nValue!=amount) + return eval->Invalid("amount in opret not matching tx tokens amount!"); + else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysbind txid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (tmptokenid!=tokenid) + return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); + else if (komodo_txnotarizedconfirmed(bindtxid) == false) + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (K>M) + return eval->Invalid("invalid number of signs!"); break; - case 'C': - //vin.0: CC input from gatewayswithdraw tx marker to gateways CC address + case 'S': + //vin.0: normal input + //vin.1: CC input of marker from previous tx (withdraw or partialsing) //vout.0: CC vout txfee marker to gateways CC address - //vout.n-1: opreturn - 'C' refcoin cointxid external_tx_hex + //vout.n-1: opreturn - 'S' withdrawtxid refcoin hex + if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,K,hex)!='S') + return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); + else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); + else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewayscompletesigning!"); + else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.0 is CC for gatewayscompletesigning!"); + else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid withdraw txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,tmprefcoin,pubkey,amount)!='W') + return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); + else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); + else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.0 is CC for gatewaysWithdraw!"); + else if ( tmptx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.1 is CC for gatewaysWithdraw!"); + else if (tmptx.vout[1].nValue!=amount) + return eval->Invalid("amount in opret not matching tx tokens amount!"); + else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysbind txid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (tmptokenid!=tokenid) + return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); + else if (komodo_txnotarizedconfirmed(bindtxid) == false) + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (K!=M) + return eval->Invalid("invalid number of signs!"); break; case 'M': - //vin.0: CC input from gatewayscompletesigning tx marker to gateways CC address - //vout.0: opreturn - 'M' refcoin cointxid + //vin.0: CC input of gatewayscompletesigning tx marker to gateways CC address + //vout.0: opreturn - 'M' withdrawtxid refcoin completetxid + if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysMarkDoneOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,completetxid)!='M') + return eval->Invalid("invalid gatewaysmarkdone OP_RETURN data!"); + else if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) + return eval->Invalid("vin.0 is CC for gatewaysmarkdone!"); + else if (myGetTransaction(completetxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaygatewayscompletesigning txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S') + return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); + else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewayscompletesigning!"); + else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.0 is CC for gatewayscompletesigning!"); + else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid withdraw txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,tmprefcoin,pubkey,amount)!='W') + return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); + else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); + else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.0 is CC for gatewaysWithdraw!"); + else if ( tmptx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + return eval->Invalid("vout.1 is CC for gatewaysWithdraw!"); + else if ( tmptx.vout[1].nValue!=amount) + return eval->Invalid("amount in opret not matching tx tokens amount!"); + else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysbind txid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (tmptokenid!=tokenid) + return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); + else if (komodo_txnotarizedconfirmed(bindtxid) == false) + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (K!=M) + return eval->Invalid("invalid number of signs!"); break; } } @@ -769,41 +951,6 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP return(0); } -int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 reftokenid) -{ - char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; - uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; CTransaction tx; - std::vector > addressIndex; - - _GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk); - SetCCtxids(addressIndex,markeraddr); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - { - if ( GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) - { - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' ) - { - if ( tokenid == reftokenid ) - { - fprintf(stderr,"trying to bind an existing tokenid\n"); - return(1); - } - } - } - } - BOOST_FOREACH(const CTxMemPoolEntry &e, mempool.mapTx) - { - const CTransaction &txmempool = e.GetTx(); - const uint256 &hash = txmempool.GetHash(); - - if ((numvouts=txmempool.vout.size()) > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' && - tokenid == reftokenid) - return(1); - } - - return(0); -} - std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -1027,8 +1174,8 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; CPubKey mypk,gatewayspk,signerpk; uint256 txid,tokenid,hashBlock,oracletxid,tmptokenid,tmpbindtxid,withdrawtxid; int32_t K,vout,numvouts; - int64_t nValue,totalsupply,inputs,CCchange=0; uint8_t funcid,M,N,taddr,prefix,prefix2; std::string coin,hex; + CTransaction tx; CPubKey mypk,gatewayspk,signerpk; uint256 txid,tokenid,hashBlock,oracletxid,tmptokenid,tmpbindtxid,withdrawtxid; int32_t vout,numvouts; + int64_t nValue,totalsupply,inputs,CCchange=0; uint8_t funcid,K,M,N,taddr,prefix,prefix2; std::string coin,hex; std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C,*cpTokens,CTokens; std::vector > unspentOutputs; @@ -1084,8 +1231,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin { if ( inputs > amount ) CCchange = (inputs - amount); mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); - mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,amount,gatewayspk)); - //mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG)); + mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,amount,gatewayspk)); if ( CCchange != 0 ) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); return(FinalizeCCTx(0, cpTokens, mtx, mypk, txfee,EncodeGatewaysWithdrawOpRet('W',tokenid,bindtxid,refcoin,withdrawpub,amount))); } @@ -1104,10 +1250,10 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refcoin, std::string hex) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,withdrawpub,signerpk,gatewayspk; struct CCcontract_info *cp,C; CTransaction tx,bindtx; + CPubKey mypk,withdrawpub,signerpk,gatewayspk; struct CCcontract_info *cp,C; CTransaction tx,tmptx; std::vector > unspentOutputs; char funcid,str[65],depositaddr[64]; - int32_t numvouts,K=0; uint256 withdrawtxid,hashBlock,bindtxid,tokenid,oracletxid,tmptokenid; std::string coin,tmphex; int64_t amount,totalsupply; - uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; + int32_t numvouts; uint256 withdrawtxid,hashBlock,bindtxid,tokenid,oracletxid,tmptokenid; std::string coin,tmphex; int64_t amount,totalsupply; + uint8_t K=0,M,N,taddr,prefix,prefix2; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); if ( txfee == 0 ) @@ -1130,13 +1276,13 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); @@ -1152,26 +1298,26 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) + else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) { CCerror = strprintf("can't find withdraw tx %s\n",uint256_str(str,withdrawtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' + else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { CCerror = strprintf("invalid withdraw tx %s\n",uint256_str(str,lasttxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); @@ -1189,8 +1335,8 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk,gatewayspk,signerpk,withdrawpub; struct CCcontract_info *cp,C; char funcid,str[65],depositaddr[64]; int64_t amount,totalsupply; - std::string coin,tmphex; CTransaction tx,bindtx; uint256 withdrawtxid,hashBlock,tokenid,tmptokenid,bindtxid,oracletxid; int32_t K=0,numvouts; - uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; + std::string coin,tmphex; CTransaction tx,tmptx; uint256 withdrawtxid,hashBlock,tokenid,tmptokenid,bindtxid,oracletxid; int32_t numvouts; + uint8_t K=0,M,N,taddr,prefix,prefix2; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); @@ -1213,13 +1359,13 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); @@ -1235,26 +1381,26 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())==0) + else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) { CCerror = strprintf("invalid withdraw txid %s\n",uint256_str(str,withdrawtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { printf("aaaaaaaaaaa\n"); CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); @@ -1265,15 +1411,15 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string if (AddNormalinputs(mtx,mypk,txfee,3)==0) fprintf(stderr,"error adding funds for completesigning\n"); mtx.vin.push_back(CTxIn(lasttxid,0,CScript())); mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,hex))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,K+1,hex))); } std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk; struct CCcontract_info *cp,C; char str[65],depositaddr[64]; CTransaction tx,bindtx; int32_t numvouts; + CPubKey mypk; struct CCcontract_info *cp,C; char str[65],depositaddr[64]; CTransaction tx; int32_t numvouts; uint256 withdrawtxid,bindtxid,oracletxid,tokenid,tmptokenid,hashBlock; std::string coin,hex; - uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; int64_t amount,totalsupply; CPubKey withdrawpub; + uint8_t K,M,N,taddr,prefix,prefix2; std::vector pubkeys; int64_t amount,totalsupply; CPubKey withdrawpub; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); @@ -1285,7 +1431,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,hex)!='S' || refcoin!=coin) + else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex)!='S' || refcoin!=coin) { CCerror = strprintf("cannot decode completesigning tx opret %s\n",uint256_str(str,completetxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); @@ -1303,13 +1449,13 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (GetTransaction(bindtxid,bindtx,hashBlock,false)==0 || (numvouts=bindtx.vout.size())<=0) + else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); @@ -1317,7 +1463,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref return(""); } mtx.vin.push_back(CTxIn(completetxid,0,CScript())); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',refcoin,completetxid,withdrawtxid))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',withdrawtxid,refcoin,completetxid))); } UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) @@ -1377,9 +1523,9 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string coin,hex; CPubKey mypk,gatewayspk,withdrawpub,signerpk; - std::vector msigpubkeys; uint256 hashBlock,tokenid,txid,tmpbindtxid,tmptokenid,oracletxid,withdrawtxid; uint8_t M,N,taddr,prefix,prefix2; + std::vector msigpubkeys; uint256 hashBlock,tokenid,txid,tmpbindtxid,tmptokenid,oracletxid,withdrawtxid; uint8_t K,M,N,taddr,prefix,prefix2; char funcid,depositaddr[65],coinaddr[65],tokensaddr[65],destaddr[65],str[65],withaddr[65],numstr[32],signeraddr[65],txidaddr[65]; - int32_t i,n,numvouts,vout,queueflag,K; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; + int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; std::vector > unspentOutputs; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1466,7 +1612,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string coin,hex; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; - uint256 withdrawtxid,hashBlock,txid,tokenid,tmptokenid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; + uint256 withdrawtxid,hashBlock,txid,tokenid,tmptokenid,oracletxid; uint8_t K,M,N,taddr,prefix,prefix2; char depositaddr[65],coinaddr[65],str[65],numstr[32],withaddr[65],txidaddr[65]; int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; std::vector > unspentOutputs; @@ -1502,7 +1648,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && - DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(txid,vout) == 0) + DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(txid,vout) == 0) { if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin || tmptokenid!=tokenid) From 8ceece2007059e47d1a1e11128c19e18848ce6fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 08:32:06 -1100 Subject: [PATCH 1671/3904] Marmaralock fix --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 0e301ba97..f10e88924 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -441,7 +441,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) val -= txfee; else val = amount; if ( val > txfee ) - inputsum = AddNormalinputs2(mtx,val,CC_MAXVINS/2); + inputsum = AddNormalinputs(mtx,val,CC_MAXVINS/2); //fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) From 02398a92e58380bf71731eebe2c58ad4e111c0f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 08:35:23 -1100 Subject: [PATCH 1672/3904] Addnormalinputs --- src/cc/marmara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f10e88924..be3c02432 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -441,7 +441,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) val -= txfee; else val = amount; if ( val > txfee ) - inputsum = AddNormalinputs(mtx,val,CC_MAXVINS/2); + inputsum = AddNormalinputs(mtx,mypk,val,CC_MAXVINS/2); //fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) From 7f042611e4f21d0d40722448b8d120e8e8bcb4dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 08:59:09 -1100 Subject: [PATCH 1673/3904] Add rpcwallet locks --- src/cc/marmara.cpp | 2 +- src/wallet/rpcwallet.cpp | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index be3c02432..0e301ba97 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -441,7 +441,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) val -= txfee; else val = amount; if ( val > txfee ) - inputsum = AddNormalinputs(mtx,mypk,val,CC_MAXVINS/2); + inputsum = AddNormalinputs2(mtx,val,CC_MAXVINS/2); //fprintf(stderr,"normal inputs %.8f val %.8f\n",(double)inputsum/COIN,(double)val/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 74733e08c..f8fe7de20 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5390,6 +5390,8 @@ UniValue cclib(const UniValue& params, bool fHelp) throw runtime_error("cclib method [evalcode] [JSON params]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); method = (char *)params[0].get_str().c_str(); if ( params.size() >= 2 ) { @@ -5625,6 +5627,8 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); perc = atof(params[0].get_str().c_str()) / 100.; firstheight = atol(params[1].get_str().c_str()); jsonstr = (char *)params[2].get_str().c_str(); @@ -5643,6 +5647,8 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); memset(&batontxid,0,sizeof(batontxid)); senderpub = ParseHex(params[0].get_str().c_str()); if (senderpub.size()!= 33) @@ -5672,6 +5678,8 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); receiverpub = ParseHex(params[0].get_str().c_str()); if (receiverpub.size()!= 33) { @@ -5701,6 +5709,8 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) ERR_RESULT("invalid receiverpub pubkey"); return result; } + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; currency = params[2].get_str(); matures = atol(params[3].get_str().c_str()); @@ -5719,6 +5729,8 @@ UniValue marmara_info(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); firstheight = atol(params[0].get_str().c_str()); lastheight = atol(params[1].get_str().c_str()); minamount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; @@ -5749,6 +5761,8 @@ UniValue marmara_creditloop(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); result = MarmaraCreditloop(txid); return(result); @@ -5765,6 +5779,8 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); batontxid = Parseuint256((char *)params[0].get_str().c_str()); result = MarmaraSettlement(0,batontxid); return(result); @@ -5777,6 +5793,8 @@ UniValue marmara_lock(const UniValue& params, bool fHelp) { throw runtime_error("marmaralock amount unlockht\n"); } + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); amount = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; if ( params.size() == 2 ) height = atol(params[1].get_str().c_str()); @@ -5790,6 +5808,8 @@ UniValue channelslist(const UniValue& params, bool fHelp) throw runtime_error("channelsinfo\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); return(ChannelsList()); } @@ -5800,6 +5820,8 @@ UniValue channelsinfo(const UniValue& params, bool fHelp) throw runtime_error("channelsinfo [opentxid]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); opentxid=zeroid; if (params.size() > 0 && !params[0].isNull() && !params[0].get_str().empty()) opentxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6089,6 +6111,8 @@ UniValue rewardslist(const UniValue& params, bool fHelp) throw runtime_error("rewardslist\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); return(RewardsList()); } @@ -6099,6 +6123,8 @@ UniValue rewardsinfo(const UniValue& params, bool fHelp) throw runtime_error("rewardsinfo fundingtxid\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); return(RewardsInfo(fundingtxid)); } @@ -6109,6 +6135,8 @@ UniValue gatewayslist(const UniValue& params, bool fHelp) throw runtime_error("gatewayslist\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); return(GatewaysList()); } @@ -6119,6 +6147,8 @@ UniValue gatewaysinfo(const UniValue& params, bool fHelp) throw runtime_error("gatewaysinfo bindtxid\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); return(GatewaysInfo(txid)); } @@ -6314,6 +6344,8 @@ UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp) throw runtime_error("gatewayspendingdeposits bindtxid coin\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); return(GatewaysPendingDeposits(bindtxid,coin)); @@ -6326,6 +6358,8 @@ UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp) throw runtime_error("gatewayspendingwithdraws bindtxid coin\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); return(GatewaysPendingWithdraws(bindtxid,coin)); @@ -6338,6 +6372,8 @@ UniValue gatewaysprocessed(const UniValue& params, bool fHelp) throw runtime_error("gatewaysprocessed bindtxid coin\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); return(GatewaysProcessedWithdraws(bindtxid,coin)); @@ -6349,6 +6385,8 @@ UniValue oracleslist(const UniValue& params, bool fHelp) throw runtime_error("oracleslist\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); return(OraclesList()); } @@ -6359,6 +6397,8 @@ UniValue oraclesinfo(const UniValue& params, bool fHelp) throw runtime_error("oraclesinfo oracletxid\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); return(OracleInfo(txid)); } @@ -6414,6 +6454,8 @@ UniValue oraclessamples(const UniValue& params, bool fHelp) throw runtime_error("oraclessamples oracletxid batonutxo num\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); batontxid = Parseuint256((char *)params[1].get_str().c_str()); num = atoi((char *)params[2].get_str().c_str()); @@ -6931,6 +6973,8 @@ UniValue tokeninfo(const UniValue& params, bool fHelp) throw runtime_error("tokeninfo tokenid\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); return(TokenInfo(tokenid)); } @@ -6942,6 +6986,8 @@ UniValue tokenorders(const UniValue& params, bool fHelp) throw runtime_error("tokenorders [tokenid]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); if (params.size() == 1) { tokenid = Parseuint256((char *)params[0].get_str().c_str()); if (tokenid == zeroid) From cce73b01a767aed3d4cb31757e6c1d0863433940 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 1 Feb 2019 04:01:16 +0800 Subject: [PATCH 1674/3904] new tempfile rotation. --- src/komodo_utils.h | 1 - src/main.cpp | 150 ++++++++++++++++++++++++++++++++------------- src/main.h | 2 +- 3 files changed, 109 insertions(+), 44 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4dbf49637..fd312e527 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1749,7 +1749,6 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; - printf("ASSETCHAINS_LASTERA = %lu\n", ASSETCHAINS_LASTERA); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); diff --git a/src/main.cpp b/src/main.cpp index 2d5134b4b..074ad81ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -187,6 +187,8 @@ namespace { std::vector vinfoBlockFile,tmpBlockFiles; int nLastBlockFile = 0; int nLastTmpFile = 0; + unsigned int maxTempFileSize0 = MAX_TEMPFILE_SIZE; + unsigned int maxTempFileSize1 = MAX_TEMPFILE_SIZE; /** Global flag to indicate we should check to see if there are * block/undo files that should be deleted. Set on startup * or if we allocate more file space when we're in prune mode @@ -3639,7 +3641,15 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin setDirtyBlockIndex.insert(pindex); } - ConnectNotarisations(block, pindex->GetHeight()); + ConnectNotarisations(block, pindex->GetHeight()); // MoMoM notarisation DB. + + int notarisationTx = komodo_connectblock(pindex,*(CBlock *)&block); // dPoW state update. + if ( ASSETCHAINS_NOTARY_PAY != 0 && notarisationTx > 0 ) + { + printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),notarisationTx); + if ( notarisationTx != 1 ) + printf("INVALID: notarisation tx is not in vtx[1].\n"); + } if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) @@ -3695,13 +3705,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); - int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; - if ( ASSETCHAINS_NOTARY_PAY != 0 && tmp > 0 ) - { - printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!\n",pindex->GetHeight(),tmp); - if ( tmp != 1 ) - printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"); - } return true; } @@ -4618,7 +4621,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u std::vector *ptr; int *lastfilep; LOCK(cs_LastBlockFile); - unsigned int nFile; + unsigned int nFile,maxTempFileSize; if ( tmpflag != 0 ) { @@ -4628,6 +4631,10 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u if (tmpBlockFiles.size() <= nFile) { tmpBlockFiles.resize(nFile + 1); } + if ( nFile == 0 ) + maxTempFileSize = maxTempFileSize0; + else if ( nFile == 1 ) + maxTempFileSize = maxTempFileSize1; } else { @@ -4638,49 +4645,86 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u vinfoBlockFile.resize(nFile + 1); } } + if (!fKnown) { - while ( (*ptr)[nFile].nSize + nAddSize >= ((tmpflag != 0) ? MAX_TEMPFILE_SIZE : MAX_BLOCKFILE_SIZE) ) { + bool tmpfileflag = false; + while ( (*ptr)[nFile].nSize + nAddSize >= ((tmpflag != 0) ? maxTempFileSize : MAX_BLOCKFILE_SIZE) ) { + if ( tmpflag != 0 && tmpfileflag ) + break; nFile++; if ((*ptr).size() <= nFile) { (*ptr).resize(nFile + 1); } + tmpfileflag = true; } pos.nFile = nFile + tmpflag*TMPFILE_START; pos.nPos = (*ptr)[nFile].nSize; - if ( 0 && tmpflag != 0 ) - fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } - if (nFile != *lastfilep) { if (!fKnown) { LogPrintf("Leaving block file %i: %s\n", nFile, (*ptr)[nFile].ToString()); } FlushBlockFile(!fKnown); - //fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); - if ( tmpflag != 0 && tmpBlockFiles.size() >= 4 ) + //fprintf(stderr, "nFile = %i size.%li maxTempFileSize0.%u maxTempFileSize1.%u\n",nFile,tmpBlockFiles.size(),maxTempFileSize0,maxTempFileSize1); + if ( tmpflag != 0 && tmpBlockFiles.size() >= 3 ) { - if ( nFile == 1 ) + if ( nFile == 1 ) // Trying to get to second temp file. { - PruneOneBlockFile(true,TMPFILE_START+2); - tmpBlockFiles[2].SetNull(); - LogPrintf("Reset tempfile 2\n"); + if (!PruneOneBlockFile(true,TMPFILE_START+1)) + { + // file 1 is not ready to be used yet increase file 0's size. + fprintf(stderr, "Cant clear file 1!\n"); + // We will reset the position to the end of the first file, even if its over max size. + nFile = 0; + pos.nFile = TMPFILE_START; + pos.nPos = (*ptr)[0].nSize; + // Increase temp file one's max size by a chunk, so we wait a reasonable time to recheck the other file. + maxTempFileSize0 += BLOCKFILE_CHUNK_SIZE; + } + else + { + // The file 1 is able to be used now. Reset max size, and set nfile to use file 1. + fprintf(stderr, "CLEARED file 1!\n"); + maxTempFileSize0 = MAX_TEMPFILE_SIZE; + nFile = 1; + tmpBlockFiles[1].SetNull(); + pos.nFile = TMPFILE_START+1; + pos.nPos = (*ptr)[1].nSize; + boost::filesystem::remove(GetBlockPosFilename(pos, "blk")); + LogPrintf("Prune: deleted temp blk (%05u)\n",nFile); + } + if ( 0 && tmpflag != 0 ) + fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } - else if ( nFile == 2 ) + else if ( nFile == 2 ) // Trying to get to third temp file. { - PruneOneBlockFile(true,TMPFILE_START+3); - tmpBlockFiles[3].SetNull(); - LogPrintf("Reset tempfile 3\n"); + if (!PruneOneBlockFile(true,TMPFILE_START)) + { + fprintf(stderr, "Cant clear file 0!\n"); + // We will reset the position to the end of the second block file, even if its over max size. + nFile = 1; + pos.nFile = TMPFILE_START+1; + pos.nPos = (*ptr)[1].nSize; + // Increase temp file one's max size by a chunk, so we wait a reasonable time to recheck the other file. + maxTempFileSize1 += BLOCKFILE_CHUNK_SIZE; + } + else + { + // The file 0 is able to be used now. Reset max size, and set nfile to use file 0. + fprintf(stderr, "CLEARED file 0!\n"); + maxTempFileSize1 = MAX_TEMPFILE_SIZE; + nFile = 0; + tmpBlockFiles[0].SetNull(); + pos.nFile = TMPFILE_START; + pos.nPos = (*ptr)[0].nSize; + boost::filesystem::remove(GetBlockPosFilename(pos, "blk")); + LogPrintf("Prune: deleted temp blk (%05u)\n",nFile); + } + if ( 0 && tmpflag != 0 ) + fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } } - if ( tmpflag != 0 && nFile == 3 ) - { - PruneOneBlockFile(true,TMPFILE_START); - tmpBlockFiles[0].SetNull(); - PruneOneBlockFile(true,TMPFILE_START+1); - tmpBlockFiles[1].SetNull(); - nFile = 0; - LogPrintf("Reset tempfile 0 and 1\n"); - } + //fprintf(stderr, "nFile = %i size.%li maxTempFileSize0.%u maxTempFileSize1.%u\n",nFile,tmpBlockFiles.size(),maxTempFileSize0,maxTempFileSize1); sleep(30); *lastfilep = nFile; //fprintf(stderr, "*lastfilep = %i\n",*lastfilep); } @@ -5512,32 +5556,53 @@ uint64_t CalculateCurrentUsage() } /* Prune a block file (modify associated database entries)*/ -void PruneOneBlockFile(bool tempfile, const int fileNumber) +bool PruneOneBlockFile(bool tempfile, const int fileNumber) { + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); - for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { + for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) + { CBlockIndex* pindex = it->second; - if (pindex && pindex->nFile == fileNumber) { + if (pindex && pindex->nFile == fileNumber) + { + if ( tempfile && (pindex->nStatus & BLOCK_IN_TMPFILE != 0) ) + { + if ( chainActive.Contains(pindex) ) + { + // Block is in main chain so we cant clear this file! + return(false); + } + if ( pindex->GetHeight() > notarized_height ) // Need to check this, does an invalid block have a height? + { + // This blocks height is not older than last notarization so it can be reorged into the main chain. + // We cant clear this file! + return(false); + } + else + { + // Block is not in main chain and is older than last notarised block so its safe for removal. + fprintf(stderr, "Block [%i] in tempfile.%i We can clear this block!\n",pindex->GetHeight(),fileNumber); + // Add index to list and remove after loop? + } + } pindex->nStatus &= ~BLOCK_HAVE_DATA; pindex->nStatus &= ~BLOCK_HAVE_UNDO; pindex->nFile = 0; pindex->nDataPos = 0; pindex->nUndoPos = 0; setDirtyBlockIndex.insert(pindex); - if (pindex->nStatus & BLOCK_IN_TMPFILE != 0 ) - { - // We should be able to clear these blocks from the index as they are not in the main chains block files. - fprintf(stderr, "Block still in tempfile.%i\n",fileNumber); - } // Prune from mapBlocksUnlinked -- any block we prune would have // to be downloaded again in order to consider its chain, at which // point it would be considered as a candidate for // mapBlocksUnlinked or setBlockIndexCandidates. std::pair::iterator, std::multimap::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev); - while (range.first != range.second) { + while (range.first != range.second) + { std::multimap::iterator it = range.first; range.first++; - if (it->second == pindex) { + if (it->second == pindex) + { mapBlocksUnlinked.erase(it); } } @@ -5546,6 +5611,7 @@ void PruneOneBlockFile(bool tempfile, const int fileNumber) if (!tempfile) vinfoBlockFile[fileNumber].SetNull(); setDirtyFileInfo.insert(fileNumber); + return(true); } diff --git a/src/main.h b/src/main.h index 35de3f4de..f12bcb8cd 100644 --- a/src/main.h +++ b/src/main.h @@ -808,7 +808,7 @@ bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHea bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,bool checkPOW); bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW); bool RemoveOrphanedBlocks(int32_t notarized_height); -void PruneOneBlockFile(bool tempfile, const int fileNumber); +bool PruneOneBlockFile(bool tempfile, const int fileNumber); /** Functions for validating blocks and updating the block tree */ From 6d4d25ca102b4cb55d582b0c8d07413c1ceb8300 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 09:15:14 -1100 Subject: [PATCH 1675/3904] Test --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 48b5927a5..c9af64e59 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -579,7 +579,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput vout = (int32_t)it->first.index; if ( it->second.satoshis < threshold ) continue; - if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 ) + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 ) { //fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout); if ( mtx.vin.size() > 0 ) From f3a93ed84b602d5db45e3ca5444be5d17f4a0d59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 31 Jan 2019 09:18:28 -1100 Subject: [PATCH 1676/3904] CC_MAXVINS --- src/cc/CCtx.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index c9af64e59..d93185ca4 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -471,7 +471,7 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs) { - int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=64; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; + int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=CC_MAXVINS; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; #ifdef ENABLE_WALLET assert(pwalletMain != NULL); const CKeyStore& keystore = *pwalletMain; @@ -564,7 +564,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs) { - int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=64; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; + int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=CC_MAXVINS; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos)); threshold = total/(maxinputs+1); @@ -579,7 +579,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput vout = (int32_t)it->first.index; if ( it->second.satoshis < threshold ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 ) { //fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout); if ( mtx.vin.size() > 0 ) From 1f62670ea2224c942d86a28a972e6b7f96ec2522 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 1 Feb 2019 16:47:43 +0800 Subject: [PATCH 1677/3904] See comment for test plan. Adds Validation --- src/komodo_bitcoind.h | 21 +++++++++++---------- src/main.cpp | 7 +++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e7677b25d..e679c4084 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1775,6 +1775,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp) { // fetch notary pubkey array. + // Need a better/safer way for notaries era, should really be height based rather than timestamp? uint64_t total = 0; int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; @@ -1783,6 +1784,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); // loop over notarisation vins and add transaction to coinbase. + // Commented prints here can be used to verify manually the pubkeys match. for (int8_t n = 0; n < NotarisationNotaries.size(); n++) { uint8_t *ptr; @@ -1796,7 +1798,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar } ptr[34] = OP_CHECKSIG; //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); - txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; // ASSETCHAINS_NOTARY_PAY + txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; total += txNew.vout[n+1].nValue; } return(total); @@ -1812,8 +1814,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) numSN = numStakedNotaries(staked_pubkeys,staked_era); uint8_t *script; int32_t scriptlen; - // loop over notaries array and extract index of signers. - + // Loop notarisation, and create the coinbase tx, with the same function the miner uses. BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin) { uint256 hash; CTransaction tx1; @@ -1836,6 +1837,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) int8_t n = 0, i = 0, matches = 0; uint64_t total = 0; //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); + // Check the created coinbase is equal to the coinbase the miner submitted in the block. BOOST_FOREACH(const CTxOut& txout, txNew.vout) { if ( n == 0 ) @@ -1845,7 +1847,6 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } script = (uint8_t *)&txout.scriptPubKey[0]; scriptlen = (int32_t)txout.scriptPubKey.size(); - // ASSETCHAINS_NOTARY_PAY = nValue! if ( txout.nValue == ASSETCHAINS_NOTARY_PAY && scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) { matches++; @@ -2047,25 +2048,25 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) { fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); - return(0); // skip validation + return(-1); } else { - // Check the notarisation tx is to the crypto address and meets min sigs. + // Check the notarisation tx is to the crypto address. if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) { fprintf(stderr, "notarisation is not to crypto address.%i\n",height); - return(0); // skip validatiuon + return(-1); } // Check min sigs. if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) { - fprintf(stderr, "block does not meet minsigs .%i\n",height); - return(0); // skip validation + fprintf(stderr, "block notarization does not meet minsigs .%i\n",height); + return(-1); } } } - + //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) return(-1); diff --git a/src/main.cpp b/src/main.cpp index 074ad81ac..99fb44147 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3579,10 +3579,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); if ( notarypaycheque > 0 ) blockReward += notarypaycheque; - else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 4 && IS_STAKED_NOTARY > 0 ) - blockReward += 999999999999999; // Notaries can validate any block for now. else - return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds coinbase (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), + return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds the amount allowed! (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), REJECT_INVALID, "bad-cb-amount"); } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) @@ -3648,7 +3646,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),notarisationTx); if ( notarisationTx != 1 ) - printf("INVALID: notarisation tx is not in vtx[1].\n"); + return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + REJECT_INVALID, "bad-notarization-position"); } if (fTxIndex) From f82808e03641d1b6787887a8e1abf2914c1d3ee6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 1 Feb 2019 18:38:55 +0800 Subject: [PATCH 1678/3904] z_mergetoaddress changes to enable merge of coinbase's, while skipping iguana utxos. --- src/wallet/rpcwallet.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 50aeb2f27..70696d4f5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4777,7 +4777,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d Sprout or %d Sapling Notes", MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT, MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores p2pk utxo!\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores 10,000 sat p2pk utxo that iguana uses, and merges coinbase utxo.\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4960,7 +4960,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (useAnyUTXO || taddrs.size() > 0) { // Get available utxos vector vecOutputs; - pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, false); + pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, maximum_utxo_size != 0 ? true : false); // Find unspent utxos and update estimated size for (const COutput& out : vecOutputs) { @@ -4981,14 +4981,13 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; - if (maximum_utxo_size != 0) { - if (nValue > maximum_utxo_size) { - continue; - } else { - if (out.tx->vout[out.i].scriptPubKey.size() == 35 && nValue == 10000) { - continue; - } - } + if (maximum_utxo_size != 0) + { + //fprintf(stderr, "utxo txid.%s vout.%i nValue.%li scriptpubkeylength.%i\n",out.tx->GetHash().ToString().c_str(),out.i,nValue,out.tx->vout[out.i].scriptPubKey.size()); + if (nValue > maximum_utxo_size) + continue; + if (nValue == 10000 && out.tx->vout[out.i].scriptPubKey.size() == 35) + continue; } utxoCounter++; @@ -5093,10 +5092,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numUtxos = utxoInputs.size(); size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); + fprintf(stderr, "num utxos.%li\n", numUtxos); if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } - + // Sanity check: Don't do anything if: // - We only have one from address // - It's equal to toaddress From 6fc97c61e33c0d01c47d26d66acf0ec9dae8a3df Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Fri, 1 Feb 2019 13:46:49 +0100 Subject: [PATCH 1679/3904] Add support for dual opret with Token opret. --- src/rpc/misc.cpp | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index e6d8025b1..1b522293e 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -29,6 +29,7 @@ #include "txmempool.h" #include "util.h" #include "cc/eval.h" +#include "cc/CCinclude.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #include "wallet/walletdb.h" @@ -1343,17 +1344,17 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp) UniValue decodeccopret(const UniValue& params, bool fHelp) { - CTransaction tx; uint256 txid,hashBlock; - std::vector vopret; uint8_t *script; - UniValue result(UniValue::VOBJ); + CTransaction tx; uint256 tokenid,txid,hashblock; + std::vector vopret,vOpretExtra; uint8_t *script,tokenevalcode; + UniValue result(UniValue::VOBJ),array(UniValue::VARR); std::vector pubkeys; if (fHelp || params.size() < 1 || params.size() > 1) { - string msg = "decodeccopret hex\n" + string msg = "decodeccopret scriptPubKey\n" "\nReturns eval code and function id for CC OP RETURN data.\n" "\nArguments:\n" - "1. txid (string, required) Transaction id.\n" + "1. scriptPubKey (string, required) Hex of scriptPubKey with OP_RETURN data.\n" "\nResult:\n" "{\n" @@ -1363,21 +1364,38 @@ UniValue decodeccopret(const UniValue& params, bool fHelp) ; throw runtime_error(msg); } - txid = uint256S((char *)params[0].get_str().c_str()); + std::vector hex(ParseHex(params[0].get_str())); + CScript scripthex(hex.begin(),hex.end()); + if (DecodeTokenOpRet(scripthex,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { - LOCK(cs_main); - if (!GetTransaction(txid, tx, hashBlock, true)) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); + UniValue obj(UniValue::VOBJ); + GetOpReturnData(scripthex,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 1) + { + char func[5]; + sprintf(func,"%c",script[1]); + obj.push_back(Pair("eval_code", EvalToStr(script[0]))); + obj.push_back(Pair("function", func)); + } + else + { + obj.push_back(Pair("error", "invalid or no CC opret data for Token OP_RETURN")); + } + array.push_back(obj); + if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); } - GetOpReturnData(tx.vout[tx.vout.size()-1].scriptPubKey,vopret); + else GetOpReturnData(scripthex,vopret); script = (uint8_t *)vopret.data(); if ( vopret.size() > 1) { - char func[5]; - sprintf(func,"%c",script[1]); + char func[5]; UniValue obj(UniValue::VOBJ); result.push_back(Pair("result", "success")); - result.push_back(Pair("eval_code", EvalToStr(script[0]))); - result.push_back(Pair("function", func)); + sprintf(func,"%c",script[1]); + obj.push_back(Pair("eval_code", EvalToStr(script[0]))); + obj.push_back(Pair("function", func)); + array.push_back(obj); + result.push_back(Pair("OpRets",array)); } else { From 00f7f545c90fb88addeb94cf4491ec00db71f5d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Feb 2019 10:27:47 -1100 Subject: [PATCH 1680/3904] Fix skip code for ac_perc --- src/cc/cclib.cpp | 31 ++++++++++++++++++++++++++++++- src/cc/makecclib | 2 +- src/komodo_bitcoind.h | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 000245e56..8a0f0aeca 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -29,9 +29,16 @@ #define FAUCET2SIZE COIN #define EVAL_FAUCET2 EVAL_FIRSTUSER -#define EVAL_SUDOKU 17 +#ifdef BUILD_ROGUE +#define EVAL_ROGUE 17 +std::string MYCCLIBNAME = (char *)"rogue"; +#else + +#define EVAL_SUDOKU 17 std::string MYCCLIBNAME = (char *)"sudoku"; +#endif + char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } struct CClib_rpcinfo @@ -44,23 +51,34 @@ CClib_methods[] = { { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, +#ifdef BUILD_ROGUE +#else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"solution", (char *)"txid solution timestamps[81]", 83, 83, 'S', EVAL_SUDOKU }, +#endif }; std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); +#ifdef BUILD_ROGUE +#else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +#endif UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) { UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; +#ifdef BUILD_ROGUE + if ( cp->evalcode == EVAL_ROGUE ) + { + } +#else if ( cp->evalcode == EVAL_SUDOKU ) { //printf("CClib_method params.%p\n",params); @@ -80,6 +98,7 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(result); } } +#endif else { result.push_back(Pair("result","error")); @@ -195,7 +214,14 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; std::vector > txids; if ( cp->evalcode != EVAL_FAUCET2 ) + { +#ifdef BUILD_ROGUE + //return(rogue_validate(cp,height,eval,tx)); + return(false); +#else return(sudoku_validate(cp,height,eval,tx)); +#endif + } numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; @@ -365,5 +391,8 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para return(""); } +#ifdef BUILD_ROGUE +#else #include "sudoku.cpp" +#endif diff --git a/src/cc/makecclib b/src/cc/makecclib index 0aecab072..b9a50a892 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1 +1 @@ -gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +gcc -std=c++11 $1 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f638afa8a..b0d299090 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1190,7 +1190,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && n == 1 ) + if ( height > 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == 1 ) break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) From 71742e5d5639d91a8dcdc8484b72268caadd2fb8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Feb 2019 10:28:25 -1100 Subject: [PATCH 1681/3904] J == n-1 --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b0d299090..f6756e676 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1190,7 +1190,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == 1 ) + if ( height > 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) From 9dd98002290e757088c1e7cb3c687c2aa273b808 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:06:32 -1100 Subject: [PATCH 1682/3904] Initial rogue libcc --- src/cc/makecclib | 2 +- src/cc/makerogue | 2 + src/cc/rogue/LICENSE.TXT | 93 ++ src/cc/rogue/Makefile.std | 158 +++ src/cc/rogue/armor.c | 89 ++ src/cc/rogue/chase.c | 541 +++++++++ src/cc/rogue/command.c | 820 +++++++++++++ src/cc/rogue/config.guess | 1500 ++++++++++++++++++++++++ src/cc/rogue/config.h | 270 +++++ src/cc/rogue/config.h.in | 269 +++++ src/cc/rogue/config.sub | 1608 ++++++++++++++++++++++++++ src/cc/rogue/configure.ac | 246 ++++ src/cc/rogue/daemon.c | 181 +++ src/cc/rogue/daemons.c | 294 +++++ src/cc/rogue/extern.c | 391 +++++++ src/cc/rogue/extern.h | 181 +++ src/cc/rogue/fight.c | 686 +++++++++++ src/cc/rogue/init.c | 447 ++++++++ src/cc/rogue/install-sh | 323 ++++++ src/cc/rogue/io.c | 327 ++++++ src/cc/rogue/list.c | 113 ++ src/cc/rogue/mach_dep.c | 457 ++++++++ src/cc/rogue/main.c | 49 + src/cc/rogue/mdport.c | 1432 +++++++++++++++++++++++ src/cc/rogue/misc.c | 597 ++++++++++ src/cc/rogue/monsters.c | 252 ++++ src/cc/rogue/move.c | 425 +++++++ src/cc/rogue/new_level.c | 231 ++++ src/cc/rogue/options.c | 501 ++++++++ src/cc/rogue/pack.c | 503 ++++++++ src/cc/rogue/passages.c | 424 +++++++ src/cc/rogue/potions.c | 375 ++++++ src/cc/rogue/rings.c | 204 ++++ src/cc/rogue/rip.c | 449 ++++++++ src/cc/rogue/rogue.6 | 96 ++ src/cc/rogue/rogue.6.in | 96 ++ src/cc/rogue/rogue.777.0 | 1 + src/cc/rogue/rogue.777.1 | 1 + src/cc/rogue/rogue.777.2 | 1 + src/cc/rogue/rogue.777.3 | 0 src/cc/rogue/rogue.c | 534 +++++++++ src/cc/rogue/rogue.cat | 61 + src/cc/rogue/rogue.cat.in | 61 + src/cc/rogue/rogue.desktop | 11 + src/cc/rogue/rogue.doc | 858 ++++++++++++++ src/cc/rogue/rogue.doc.in | 858 ++++++++++++++ src/cc/rogue/rogue.h | 785 +++++++++++++ src/cc/rogue/rogue.html | 1060 +++++++++++++++++ src/cc/rogue/rogue.html.in | 1060 +++++++++++++++++ src/cc/rogue/rogue.me | 892 +++++++++++++++ src/cc/rogue/rogue.me.in | 892 +++++++++++++++ src/cc/rogue/rogue.png | Bin 0 -> 1005 bytes src/cc/rogue/rogue.spec | 107 ++ src/cc/rogue/rogue54.sln | 19 + src/cc/rogue/rogue54.vcproj | 396 +++++++ src/cc/rogue/rooms.c | 472 ++++++++ src/cc/rogue/save.c | 400 +++++++ src/cc/rogue/score.h | 26 + src/cc/rogue/scrolls.c | 329 ++++++ src/cc/rogue/state.c | 2148 +++++++++++++++++++++++++++++++++++ src/cc/rogue/sticks.c | 431 +++++++ src/cc/rogue/test.zip | Bin 0 -> 5451 bytes src/cc/rogue/things.c | 713 ++++++++++++ src/cc/rogue/vers.c | 17 + src/cc/rogue/weapons.c | 288 +++++ src/cc/rogue/wizard.c | 284 +++++ src/cc/rogue/xcrypt.c | 707 ++++++++++++ 67 files changed, 28043 insertions(+), 1 deletion(-) create mode 100755 src/cc/makerogue create mode 100644 src/cc/rogue/LICENSE.TXT create mode 100755 src/cc/rogue/Makefile.std create mode 100644 src/cc/rogue/armor.c create mode 100644 src/cc/rogue/chase.c create mode 100644 src/cc/rogue/command.c create mode 100755 src/cc/rogue/config.guess create mode 100644 src/cc/rogue/config.h create mode 100644 src/cc/rogue/config.h.in create mode 100755 src/cc/rogue/config.sub create mode 100644 src/cc/rogue/configure.ac create mode 100644 src/cc/rogue/daemon.c create mode 100644 src/cc/rogue/daemons.c create mode 100644 src/cc/rogue/extern.c create mode 100644 src/cc/rogue/extern.h create mode 100644 src/cc/rogue/fight.c create mode 100644 src/cc/rogue/init.c create mode 100755 src/cc/rogue/install-sh create mode 100644 src/cc/rogue/io.c create mode 100644 src/cc/rogue/list.c create mode 100644 src/cc/rogue/mach_dep.c create mode 100644 src/cc/rogue/main.c create mode 100644 src/cc/rogue/mdport.c create mode 100644 src/cc/rogue/misc.c create mode 100644 src/cc/rogue/monsters.c create mode 100644 src/cc/rogue/move.c create mode 100644 src/cc/rogue/new_level.c create mode 100644 src/cc/rogue/options.c create mode 100644 src/cc/rogue/pack.c create mode 100644 src/cc/rogue/passages.c create mode 100644 src/cc/rogue/potions.c create mode 100644 src/cc/rogue/rings.c create mode 100644 src/cc/rogue/rip.c create mode 100644 src/cc/rogue/rogue.6 create mode 100644 src/cc/rogue/rogue.6.in create mode 100644 src/cc/rogue/rogue.777.0 create mode 100644 src/cc/rogue/rogue.777.1 create mode 100644 src/cc/rogue/rogue.777.2 create mode 100644 src/cc/rogue/rogue.777.3 create mode 100644 src/cc/rogue/rogue.c create mode 100644 src/cc/rogue/rogue.cat create mode 100644 src/cc/rogue/rogue.cat.in create mode 100644 src/cc/rogue/rogue.desktop create mode 100644 src/cc/rogue/rogue.doc create mode 100644 src/cc/rogue/rogue.doc.in create mode 100644 src/cc/rogue/rogue.h create mode 100644 src/cc/rogue/rogue.html create mode 100644 src/cc/rogue/rogue.html.in create mode 100644 src/cc/rogue/rogue.me create mode 100644 src/cc/rogue/rogue.me.in create mode 100644 src/cc/rogue/rogue.png create mode 100644 src/cc/rogue/rogue.spec create mode 100644 src/cc/rogue/rogue54.sln create mode 100644 src/cc/rogue/rogue54.vcproj create mode 100644 src/cc/rogue/rooms.c create mode 100644 src/cc/rogue/save.c create mode 100644 src/cc/rogue/score.h create mode 100644 src/cc/rogue/scrolls.c create mode 100644 src/cc/rogue/state.c create mode 100644 src/cc/rogue/sticks.c create mode 100644 src/cc/rogue/test.zip create mode 100644 src/cc/rogue/things.c create mode 100644 src/cc/rogue/vers.c create mode 100644 src/cc/rogue/weapons.c create mode 100644 src/cc/rogue/wizard.c create mode 100644 src/cc/rogue/xcrypt.c diff --git a/src/cc/makecclib b/src/cc/makecclib index b9a50a892..0aecab072 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1 +1 @@ -gcc -std=c++11 $1 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp diff --git a/src/cc/makerogue b/src/cc/makerogue new file mode 100755 index 000000000..c9e55c28c --- /dev/null +++ b/src/cc/makerogue @@ -0,0 +1,2 @@ +cd rogue; make; cd .. +gcc -DROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp rogue/rogue.so diff --git a/src/cc/rogue/LICENSE.TXT b/src/cc/rogue/LICENSE.TXT new file mode 100644 index 000000000..ae3f4715b --- /dev/null +++ b/src/cc/rogue/LICENSE.TXT @@ -0,0 +1,93 @@ +Rogue: Exploring the Dungeons of Doom +Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name(s) of the author(s) nor the names of other contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +=========================================================================== + +Portions of this software (state.c, mdport.c) are based on the work +of Nicholas J. Kisseberth. Used under license: + +Copyright (C) 1999, 2000, 2005 Nicholas J. Kisseberth +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name(s) of the author(s) nor the names of other contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +=========================================================================== + +Portions of this software (xcrypt.c) are based on the work +of David Burren. Used under license: + +FreeSec: libcrypt + +Copyright (C) 1994 David Burren +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name(s) of the author(s) nor the names of other contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. diff --git a/src/cc/rogue/Makefile.std b/src/cc/rogue/Makefile.std new file mode 100755 index 000000000..923c74672 --- /dev/null +++ b/src/cc/rogue/Makefile.std @@ -0,0 +1,158 @@ +# +# Makefile for rogue +# @(#)Makefile 4.21 (Berkeley) 02/04/99 +# +# Rogue: Exploring the Dungeons of Doom +# Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman +# All rights reserved. +# +# See the file LICENSE.TXT for full copyright and licensing information. +# + +DISTNAME = rogue5.4.4 +PROGRAM = rogue54 +O = o +HDRS = rogue.h extern.h score.h +OBJS1 = vers.$(O) extern.$(O) armor.$(O) chase.$(O) command.$(O) \ + daemon.$(O) daemons.$(O) fight.$(O) init.$(O) io.$(O) list.$(O) \ + mach_dep.$(O) main.$(O) mdport.$(O) misc.$(O) monsters.$(O) \ + move.$(O) new_level.$(O) +OBJS2 = options.$(O) pack.$(O) passages.$(O) potions.$(O) rings.$(O) \ + rip.$(O) rooms.$(O) save.$(O) scrolls.$(O) state.$(O) sticks.$(O) \ + things.$(O) weapons.$(O) wizard.$(O) xcrypt.$(O) +OBJS = $(OBJS1) $(OBJS2) +CFILES = vers.c extern.c armor.c chase.c command.c daemon.c \ + daemons.c fight.c init.c io.c list.c mach_dep.c \ + main.c mdport.c misc.c monsters.c move.c new_level.c \ + options.c pack.c passages.c potions.c rings.c rip.c \ + rooms.c save.c scrolls.c state.c sticks.c things.c \ + weapons.c wizard.c xcrypt.c +MISC_C = findpw.c scedit.c scmisc.c +DOCSRC = rogue.me.in rogue.6.in rogue.doc.in rogue.html.in rogue.cat.in +DOCS = $(PROGRAM).doc $(PROGRAM).html $(PROGRAM).cat $(PROGRAM).me \ + $(PROGRAM).6 +AFILES = configure Makefile.in configure.ac config.h.in config.sub config.guess \ + install-sh rogue.6.in rogue.me.in rogue.html.in rogue.doc.in rogue.cat.in +MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ + rogue.png rogue.desktop +CC = gcc +FEATURES = -DALLSCORES -DSCOREFILE=\"$(SCOREFILE)\" -DLOCKFILE=\"$(LOCKFILE)\" +CPPFLAGS = +CFLAGS = -O3 +LDFLAGS = +LIBS = -lcurses +RM = rm -f +MAKEFILE = -f Makefile.std +SCOREFILE= $(PROGRAM).scr +LOCKFILE = $(PROGRAM).lck +OUTFLAG = -o +EXE = + +.SUFFIXES: .obj + +.c.obj: + $(CC) $(CFLAGS) $(CPPFLAGS) $(FEATURES) /c $*.c + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) $(FEATURES) -c $*.c + +$(PROGRAM): $(HDRS) $(OBJS) fixdocs + $(CC) $(LDFLAGS) $(OBJS) $(LIBS) $(OUTFLAG)$@$(EXE) + +clean: + $(RM) $(OBJS1) + $(RM) $(OBJS2) + $(RM) core a.exe a.out a.exe.stackdump $(PROGRAM) $(PROGRAM).exe $(PROGRAM).lck + $(RM) $(PROGRAM).tar $(PROGRAM).tar.gz $(PROGRAM).zip + $(RM) $(DISTNAME)/* + +dist.src: + $(MAKE) $(MAKEFILE) clean + mkdir $(DISTNAME) + cp $(CFILES) $(HDRS) $(MISC) $(AFILES) $(DISTNAME) + tar cf $(DISTNAME)-src.tar $(DISTNAME) + gzip -f $(DISTNAME)-src.tar + rm -fr $(DISTNAME) + +findpw: findpw.c xcrypt.o mdport.o xcrypt.o + $(CC) -s -o findpw findpw.c xcrypt.o mdport.o -lcurses + +scedit: scedit.o scmisc.o vers.o mdport.o xcrypt.o + $(CC) -s -o scedit vers.o scedit.o scmisc.o mdport.o xcrypt.o -lcurses + +scmisc.o scedit.o: + $(CC) -O -c $(SF) $*.c + +doc.nroff: + tbl rogue.me | nroff -me | colcrt - > rogue.doc + nroff -man rogue.6 | colcrt - > rogue.cat + +doc.groff: + groff -P-c -t -me -Tascii rogue.me | sed -e 's/.\x08//g' > rogue.doc + groff -man rogue.6 | sed -e 's/.\x08//g' > rogue.cat + +fixdocs: + sed -e 's/@PROGRAM@/$(PROGRAM)/' -e 's/@SCOREFILE@/$(SCOREFILE)/' rogue.6.in > $(PROGRAM).6 + sed -e 's/@PROGRAM@/$(PROGRAM)/' -e 's/@SCOREFILE@/$(SCOREFILE)/' rogue.me.in > $(PROGRAM).me + sed -e 's/@PROGRAM@/$(PROGRAM)/' -e 's/@SCOREFILE@/$(SCOREFILE)/' rogue.html.in > $(PROGRAM).html + sed -e 's/@PROGRAM@/$(PROGRAM)/' -e 's/@SCOREFILE@/$(SCOREFILE)/' rogue.doc.in > $(PROGRAM).doc + sed -e 's/@PROGRAM@/$(PROGRAM)/' -e 's/@SCOREFILE@/$(SCOREFILE)/' rogue.cat.in > $(PROGRAM).cat + +dist.irix: + $(MAKE) $(MAKEFILE) clean + $(MAKE) $(MAKEFILE) CC=cc $(PROGRAM) + tar cf $(DISTNAME)-irix.tar $(PROGRAM) LICENSE.TXT $(DOCS) + gzip -f $(DISTNAME)-irix.tar + +dist.aix: + $(MAKE) $(MAKEFILE) clean + $(MAKE) $(MAKEFILE) CC=xlc CFLAGS="-qmaxmem=16768 -O3 -qstrict" $(PROGRAM) + tar cf $(DISTNAME)-aix.tar $(PROGRAM) LICENSE.TXT $(DOCS) + gzip -f $(DISTNAME)-aix.tar + +dist.linux: + $(MAKE) $(MAKEFILE) clean + $(MAKE) $(MAKEFILE) $(PROGRAM) + tar cf $(DISTNAME)-linux.tar $(PROGRAM) LICENSE.TXT $(DOCS) + gzip -f $(DISTNAME)-linux.tar + +dist.interix: + @$(MAKE) $(MAKEFILE) clean + @$(MAKE) $(MAKEFILE) CFLAGS="-ansi" $(PROGRAM) + tar cf $(DISTNAME)-interix.tar $(PROGRAM) LICENSE.TXT $(DOCS) + gzip -f $(DISTNAME)-interix.tar + +dist.cygwin: + @$(MAKE) $(MAKEFILE) --no-print-directory clean + @$(MAKE) $(MAKEFILE) CPPFLAGS="-I/usr/include/ncurses" --no-print-directory $(PROGRAM) + tar cf $(DISTNAME)-cygwin.tar $(PROGRAM).exe LICENSE.TXT $(DOCS) + gzip -f $(DISTNAME)-cygwin.tar + +# +# Use MINGW32-MAKE to build this target +# +dist.mingw32: + @$(MAKE) $(MAKEFILE) --no-print-directory RM="cmd /c del" clean + @$(MAKE) $(MAKEFILE) --no-print-directory CPPFLAGS="-I../pdcurses" LIBS="../pdcurses/pdcurses.a" $(PROGRAM) + cmd /c del $(DISTNAME)-mingw32.zip + zip $(DISTNAME)-mingw32.zip $(PROGRAM).exe LICENSE.TXT $(DOCS) + +dist.djgpp: + @$(MAKE) $(MAKEFILE) --no-print-directory clean + @$(MAKE) $(MAKEFILE) --no-print-directory LDFLAGS="-L$(DJDIR)/LIB" \ + LIBS="-lpdcurses" $(PROGRAM) + rm -f $(DISTNAME)-djgpp.zip + zip $(DISTNAME)-djgpp.zip $(PROGRAM) LICENSE.TXT $(DOCS) + +# +# Use NMAKE to build this targer +# + +dist.win32: + @$(MAKE) $(MAKEFILE) /NOLOGO O="obj" RM="-del" clean + @$(MAKE) $(MAKEFILE) /NOLOGO O="obj" CC="CL" \ + LIBS="..\pdcurses\pdcurses.lib shell32.lib user32.lib Advapi32.lib" \ + EXE=".exe" OUTFLAG="/Fe" CPPFLAGS="-I..\pdcurses" \ + CFLAGS="-nologo -Ox -wd4033 -wd4716" $(PROGRAM) + -del $(DISTNAME)-win32.zip + zip $(DISTNAME)-win32.zip $(PROGRAM).exe LICENSE.TXT $(DOCS) diff --git a/src/cc/rogue/armor.c b/src/cc/rogue/armor.c new file mode 100644 index 000000000..5244628b1 --- /dev/null +++ b/src/cc/rogue/armor.c @@ -0,0 +1,89 @@ +/* + * This file contains misc functions for dealing with armor + * @(#)armor.c 4.14 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include "rogue.h" + +/* + * wear: + * The player wants to wear something, so let him/her put it on. + */ +void +wear(struct rogue_state *rs) +{ + register THING *obj; + register char *sp; + + if ((obj = get_item(rs,"wear", ARMOR)) == NULL) + return; + if (cur_armor != NULL) + { + addmsg(rs,"you are already wearing some"); + if (!terse) + addmsg(rs,". You'll have to take it off first"); + endmsg(rs); + after = FALSE; + return; + } + if (obj->o_type != ARMOR) + { + msg(rs,"you can't wear that"); + return; + } + waste_time(rs); + obj->o_flags |= ISKNOW; + sp = inv_name(obj, TRUE); + cur_armor = obj; + if (!terse) + addmsg(rs,"you are now "); + msg(rs,"wearing %s", sp); +} + +/* + * take_off: + * Get the armor off of the players back + */ +void +take_off(struct rogue_state *rs) +{ + register THING *obj; + + if ((obj = cur_armor) == NULL) + { + after = FALSE; + if (terse) + msg(rs,"not wearing armor"); + else + msg(rs,"you aren't wearing any armor"); + return; + } + if (!dropcheck(rs,cur_armor)) + return; + cur_armor = NULL; + if (terse) + addmsg(rs,"was"); + else + addmsg(rs,"you used to be"); + msg(rs," wearing %c) %s", obj->o_packch, inv_name(obj, TRUE)); +} + +/* + * waste_time: + * Do nothing but let other things happen + */ +void +waste_time(struct rogue_state *rs) +{ + do_daemons(rs,BEFORE); + do_fuses(rs,BEFORE); + do_daemons(rs,AFTER); + do_fuses(rs,AFTER); +} diff --git a/src/cc/rogue/chase.c b/src/cc/rogue/chase.c new file mode 100644 index 000000000..168993edb --- /dev/null +++ b/src/cc/rogue/chase.c @@ -0,0 +1,541 @@ +/* + * Code for one creature to chase another + * + * @(#)chase.c 4.57 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +#define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */ + +static coord ch_ret; /* Where chasing takes you */ + +/* + * runners: + * Make all the running monsters move. + */ +void +runners(struct rogue_state *rs,int arg) +{ + register THING *tp; + THING *next; + bool wastarget; + static coord orig_pos; + + for (tp = mlist; tp != NULL; tp = next) + { + /* remember this in case the monster's "next" is changed */ + next = next(tp); + if (!on(*tp, ISHELD) && on(*tp, ISRUN)) + { + orig_pos = tp->t_pos; + wastarget = on(*tp, ISTARGET); + if (move_monst(rs,tp) == -1) + continue; + if (on(*tp, ISFLY) && dist_cp(&hero, &tp->t_pos) >= 3) + move_monst(rs,tp); + if (wastarget && !ce(orig_pos, tp->t_pos)) + { + tp->t_flags &= ~ISTARGET; + to_death = FALSE; + } + } + } + if (has_hit) + { + endmsg(rs); + has_hit = FALSE; + } +} + +/* + * move_monst: + * Execute a single turn of running for a monster + */ +int +move_monst(struct rogue_state *rs,THING *tp) +{ + if (!on(*tp, ISSLOW) || tp->t_turn) + if (do_chase(rs,tp) == -1) + return(-1); + if (on(*tp, ISHASTE)) + if (do_chase(rs,tp) == -1) + return(-1); + tp->t_turn ^= TRUE; + return(0); +} + +/* + * relocate: + * Make the monster's new location be the specified one, updating + * all the relevant state. + */ +void +relocate(struct rogue_state *rs,THING *th, coord *new_loc) +{ + struct room *oroom; + + if (!ce(*new_loc, th->t_pos)) + { + mvaddch(th->t_pos.y, th->t_pos.x, th->t_oldch); + th->t_room = roomin(rs,new_loc); + set_oldch(th, new_loc); + oroom = th->t_room; + moat(th->t_pos.y, th->t_pos.x) = NULL; + + if (oroom != th->t_room) + th->t_dest = find_dest(rs,th); + th->t_pos = *new_loc; + moat(new_loc->y, new_loc->x) = th; + } + move(new_loc->y, new_loc->x); + if (see_monst(th)) + addch(th->t_disguise); + else if (on(player, SEEMONST)) + { + standout(); + addch(th->t_type); + standend(); + } +} + +/* + * do_chase: + * Make one thing chase another. + */ +int +do_chase(struct rogue_state *rs,THING *th) +{ + register coord *cp; + register struct room *rer, *ree; /* room of chaser, room of chasee */ + register int mindist = 32767, curdist; + register bool stoprun = FALSE; /* TRUE means we are there */ + register bool door; + register THING *obj; + static coord this; /* Temporary destination for chaser */ + + rer = th->t_room; /* Find room of chaser */ + if (on(*th, ISGREED) && rer->r_goldval == 0) + th->t_dest = &hero; /* If gold has been taken, run after hero */ + if (th->t_dest == &hero) /* Find room of chasee */ + ree = proom; + else + ree = roomin(rs,th->t_dest); + /* + * We don't count doors as inside rooms for this routine + */ + door = (chat(th->t_pos.y, th->t_pos.x) == DOOR); + /* + * If the object of our desire is in a different room, + * and we are not in a corridor, run to the door nearest to + * our goal. + */ +over: + if (rer != ree) + { + for (cp = rer->r_exit; cp < &rer->r_exit[rer->r_nexits]; cp++) + { + curdist = dist_cp(th->t_dest, cp); + if (curdist < mindist) + { + this = *cp; + mindist = curdist; + } + } + if (door) + { + rer = &passages[flat(th->t_pos.y, th->t_pos.x) & F_PNUM]; + door = FALSE; + goto over; + } + } + else + { + this = *th->t_dest; + /* + * For dragons check and see if (a) the hero is on a straight + * line from it, and (b) that it is within shooting distance, + * but outside of striking range. + */ + if (th->t_type == 'D' && (th->t_pos.y == hero.y || th->t_pos.x == hero.x + || abs(th->t_pos.y - hero.y) == abs(th->t_pos.x - hero.x)) + && dist_cp(&th->t_pos, &hero) <= BOLT_LENGTH * BOLT_LENGTH + && !on(*th, ISCANC) && rnd(DRAGONSHOT) == 0) + { + delta.y = sign(hero.y - th->t_pos.y); + delta.x = sign(hero.x - th->t_pos.x); + if (has_hit) + endmsg(rs); + fire_bolt(rs,&th->t_pos, &delta, "flame"); + running = FALSE; + count = 0; + quiet = 0; + if (to_death && !on(*th, ISTARGET)) + { + to_death = FALSE; + kamikaze = FALSE; + } + return(0); + } + } + /* + * This now contains what we want to run to this time + * so we run to it. If we hit it we either want to fight it + * or stop running + */ + if (!chase(th, &this)) + { + if (ce(this, hero)) + { + return( attack(rs,th) ); + } + else if (ce(this, *th->t_dest)) + { + for (obj = lvl_obj; obj != NULL; obj = next(obj)) + if (th->t_dest == &obj->o_pos) + { + detach(lvl_obj, obj); + attach(th->t_pack, obj); + chat(obj->o_pos.y, obj->o_pos.x) = + (th->t_room->r_flags & ISGONE) ? PASSAGE : FLOOR; + th->t_dest = find_dest(rs,th); + break; + } + if (th->t_type != 'F') + stoprun = TRUE; + } + } + else + { + if (th->t_type == 'F') + return(0); + } + relocate(rs,th, &ch_ret); + /* + * And stop running if need be + */ + if (stoprun && ce(th->t_pos, *(th->t_dest))) + th->t_flags &= ~ISRUN; + return(0); +} + +/* + * set_oldch: + * Set the oldch character for the monster + */ +void +set_oldch(THING *tp, coord *cp) +{ + char sch; + + if (ce(tp->t_pos, *cp)) + return; + + sch = tp->t_oldch; + tp->t_oldch = CCHAR( mvinch(cp->y,cp->x) ); + if (!on(player, ISBLIND)) + { + if ((sch == FLOOR || tp->t_oldch == FLOOR) && + (tp->t_room->r_flags & ISDARK)) + tp->t_oldch = ' '; + else if (dist_cp(cp, &hero) <= LAMPDIST && see_floor) + tp->t_oldch = chat(cp->y, cp->x); + } +} + +/* + * see_monst: + * Return TRUE if the hero can see the monster + */ +bool +see_monst(THING *mp) +{ + int y, x; + + if (on(player, ISBLIND)) + return FALSE; + if (on(*mp, ISINVIS) && !on(player, CANSEE)) + return FALSE; + y = mp->t_pos.y; + x = mp->t_pos.x; + if (dist(y, x, hero.y, hero.x) < LAMPDIST) + { + if (y != hero.y && x != hero.x && + !step_ok(chat(y, hero.x)) && !step_ok(chat(hero.y, x))) + return FALSE; + return TRUE; + } + if (mp->t_room != proom) + return FALSE; + return ((bool)!(mp->t_room->r_flags & ISDARK)); +} + +/* + * runto: + * Set a monster running after the hero. + */ +void +runto(struct rogue_state *rs,coord *runner) +{ + register THING *tp; + + /* + * If we couldn't find him, something is funny + */ +#ifdef MASTER + if ((tp = moat(runner->y, runner->x)) == NULL) + msg(rs,"couldn't find monster in runto at (%d,%d)", runner->y, runner->x); +#else + tp = moat(runner->y, runner->x); +#endif + /* + * Start the beastie running + */ + tp->t_flags |= ISRUN; + tp->t_flags &= ~ISHELD; + tp->t_dest = find_dest(rs,tp); +} + +/* + * chase: + * Find the spot for the chaser(er) to move closer to the + * chasee(ee). Returns TRUE if we want to keep on chasing later + * FALSE if we reach the goal. + */ +bool +chase(THING *tp, coord *ee) +{ + register THING *obj; + register int x, y; + register int curdist, thisdist; + register coord *er = &tp->t_pos; + register char ch; + register int plcnt = 1; + static coord tryp; + + /* + * If the thing is confused, let it move randomly. Invisible + * Stalkers are slightly confused all of the time, and bats are + * quite confused all the time + */ + if ((on(*tp, ISHUH) && rnd(5) != 0) || (tp->t_type == 'P' && rnd(5) == 0) + || (tp->t_type == 'B' && rnd(2) == 0)) + { + /* + * get a valid random move + */ + ch_ret = *rndmove(tp); + curdist = dist_cp(&ch_ret, ee); + /* + * Small chance that it will become un-confused + */ + if (rnd(20) == 0) + tp->t_flags &= ~ISHUH; + } + /* + * Otherwise, find the empty spot next to the chaser that is + * closest to the chasee. + */ + else + { + register int ey, ex; + /* + * This will eventually hold where we move to get closer + * If we can't find an empty spot, we stay where we are. + */ + curdist = dist_cp(er, ee); + ch_ret = *er; + + ey = er->y + 1; + if (ey >= NUMLINES - 1) + ey = NUMLINES - 2; + ex = er->x + 1; + if (ex >= NUMCOLS) + ex = NUMCOLS - 1; + + for (x = er->x - 1; x <= ex; x++) + { + if (x < 0) + continue; + tryp.x = x; + for (y = er->y - 1; y <= ey; y++) + { + tryp.y = y; + if (!diag_ok(er, &tryp)) + continue; + ch = winat(y, x); + if (step_ok(ch)) + { + /* + * If it is a scroll, it might be a scare monster scroll + * so we need to look it up to see what type it is. + */ + if (ch == SCROLL) + { + for (obj = lvl_obj; obj != NULL; obj = next(obj)) + { + if (y == obj->o_pos.y && x == obj->o_pos.x) + break; + } + if (obj != NULL && obj->o_which == S_SCARE) + continue; + } + /* + * It can also be a Xeroc, which we shouldn't step on + */ + if ((obj = moat(y, x)) != NULL && obj->t_type == 'X') + continue; + /* + * If we didn't find any scrolls at this place or it + * wasn't a scare scroll, then this place counts + */ + thisdist = dist(y, x, ee->y, ee->x); + if (thisdist < curdist) + { + plcnt = 1; + ch_ret = tryp; + curdist = thisdist; + } + else if (thisdist == curdist && rnd(++plcnt) == 0) + { + ch_ret = tryp; + curdist = thisdist; + } + } + } + } + } + return (bool)(curdist != 0 && !ce(ch_ret, hero)); +} + +/* + * roomin: + * Find what room some coordinates are in. NULL means they aren't + * in any room. + */ +struct room * +roomin(struct rogue_state *rs,coord *cp) +{ + register struct room *rp; + register char *fp; + + + fp = &flat(cp->y, cp->x); + if (*fp & F_PASS) + return &passages[*fp & F_PNUM]; + + for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) + if (cp->x <= rp->r_pos.x + rp->r_max.x && rp->r_pos.x <= cp->x + && cp->y <= rp->r_pos.y + rp->r_max.y && rp->r_pos.y <= cp->y) + return rp; + + msg(rs,"in some bizarre place (%d, %d)", unc(*cp)); +#ifdef MASTER + abort(); + return NULL; +#else + return NULL; +#endif +} + +/* + * diag_ok: + * Check to see if the move is legal if it is diagonal + */ +bool +diag_ok(coord *sp, coord *ep) +{ + if (ep->x < 0 || ep->x >= NUMCOLS || ep->y <= 0 || ep->y >= NUMLINES - 1) + return FALSE; + if (ep->x == sp->x || ep->y == sp->y) + return TRUE; + return (bool)(step_ok(chat(ep->y, sp->x)) && step_ok(chat(sp->y, ep->x))); +} + +/* + * cansee: + * Returns true if the hero can see a certain coordinate. + */ +bool +cansee(struct rogue_state *rs,int y, int x) +{ + register struct room *rer; + static coord tp; + + if (on(player, ISBLIND)) + return FALSE; + if (dist(y, x, hero.y, hero.x) < LAMPDIST) + { + if (flat(y, x) & F_PASS) + if (y != hero.y && x != hero.x && + !step_ok(chat(y, hero.x)) && !step_ok(chat(hero.y, x))) + return FALSE; + return TRUE; + } + /* + * We can only see if the hero in the same room as + * the coordinate and the room is lit or if it is close. + */ + tp.y = y; + tp.x = x; + return (bool)((rer = roomin(rs,&tp)) == proom && !(rer->r_flags & ISDARK)); +} + +/* + * find_dest: + * find the proper destination for the monster + */ +coord * +find_dest(struct rogue_state *rs,THING *tp) +{ + register THING *obj; + register int prob; + + if ((prob = monsters[tp->t_type - 'A'].m_carry) <= 0 || tp->t_room == proom + || see_monst(tp)) + return &hero; + for (obj = lvl_obj; obj != NULL; obj = next(obj)) + { + if (obj->o_type == SCROLL && obj->o_which == S_SCARE) + continue; + if (roomin(rs,&obj->o_pos) == tp->t_room && rnd(100) < prob) + { + for (tp = mlist; tp != NULL; tp = next(tp)) + if (tp->t_dest == &obj->o_pos) + break; + if (tp == NULL) + return &obj->o_pos; + } + } + return &hero; +} + +/* + * dist: + * Calculate the "distance" between to points. Actually, + * this calculates d^2, not d, but that's good enough for + * our purposes, since it's only used comparitively. + */ +int +dist(int y1, int x1, int y2, int x2) +{ + return ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); +} + +/* + * dist_cp: + * Call dist() with appropriate arguments for coord pointers + */ +int +dist_cp(coord *c1, coord *c2) +{ + return dist(c1->y, c1->x, c2->y, c2->x); +} diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c new file mode 100644 index 000000000..ce02da076 --- /dev/null +++ b/src/cc/rogue/command.c @@ -0,0 +1,820 @@ +/* + * Read and execute the user commands + * + * @(#)command.c 4.73 (Berkeley) 08/06/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include "rogue.h" + +/* + * command: + * Process the user commands + */ +void +command(struct rogue_state *rs) +{ + register char ch; + register int ntimes = 1; /* Number of player moves */ + char *fp; + THING *mp; + static char countch, direction, newcount = FALSE; + + if (on(player, ISHASTE)) + ntimes++; + /* + * Let the daemons start up + */ + do_daemons(rs,BEFORE); + do_fuses(rs,BEFORE); + while (ntimes--) + { + again = FALSE; + if (has_hit) + { + endmsg(rs); + has_hit = FALSE; + } + /* + * these are illegal things for the player to be, so if any are + * set, someone's been poking in memeory + */ + if (on(player, ISSLOW|ISGREED|ISINVIS|ISREGEN|ISTARGET)) + exit(1); + + look(rs,TRUE); + if (!running) + door_stop = FALSE; + status(rs); + lastscore = purse; + move(hero.y, hero.x); + if (!((running || count) && jump)) + refresh(); /* Draw screen */ + take = 0; + after = TRUE; + /* + * Read command or continue run + */ +#ifdef MASTER + if (wizard) + noscore = TRUE; +#endif + if (!no_command) + { + if (running || to_death) + ch = runch; + else if (count) + ch = countch; + else + { + ch = readchar(rs); + move_on = FALSE; + if (mpos != 0) /* Erase message if its there */ + msg(rs,""); + } + } + else + ch = '.'; + if (no_command) + { + if (--no_command == 0) + { + player.t_flags |= ISRUN; + msg(rs,"you can move again"); + } + } + else + { + /* + * check for prefixes + */ + newcount = FALSE; + if (isdigit(ch)) + { + count = 0; + newcount = TRUE; + while (isdigit(ch)) + { + count = count * 10 + (ch - '0'); + if (count > 255) + count = 255; + ch = readchar(rs); + } + countch = ch; + /* + * turn off count for commands which don't make sense + * to repeat + */ + switch (ch) + { + case CTRL('B'): case CTRL('H'): case CTRL('J'): + case CTRL('K'): case CTRL('L'): case CTRL('N'): + case CTRL('U'): case CTRL('Y'): + case '.': case 'a': case 'b': case 'h': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'q': + case 'r': case 's': case 't': case 'u': case 'y': + case 'z': case 'B': case 'C': case 'H': case 'I': + case 'J': case 'K': case 'L': case 'N': case 'U': + case 'Y': +#ifdef MASTER + case CTRL('D'): case CTRL('A'): +#endif + break; + default: + count = 0; + } + } + /* + * execute a command + */ + if (count && !running) + count--; + if (ch != 'a' && ch != ESCAPE && !(running || count || to_death)) + { + l_last_comm = last_comm; + l_last_dir = last_dir; + l_last_pick = last_pick; + last_comm = ch; + last_dir = '\0'; + last_pick = NULL; + } +over: + switch (ch) + { + case ',': { + THING *obj = NULL; + int found = 0; + for (obj = lvl_obj; obj != NULL; obj = next(obj)) + { + if (obj->o_pos.y == hero.y && obj->o_pos.x == hero.x) + { + found=1; + break; + } + } + + if (found) { + if (levit_check(rs)) + ; + else + pick_up(rs,(char)obj->o_type); + } + else { + if (!terse) + addmsg(rs,"there is "); + addmsg(rs,"nothing here"); + if (!terse) + addmsg(rs," to pick up"); + endmsg(rs); + } + } + when '!': shell(rs); + when 'h': do_move(rs,0, -1); + when 'j': do_move(rs,1, 0); + when 'k': do_move(rs,-1, 0); + when 'l': do_move(rs,0, 1); + when 'y': do_move(rs,-1, -1); + when 'u': do_move(rs,-1, 1); + when 'b': do_move(rs,1, -1); + when 'n': do_move(rs,1, 1); + when 'H': do_run('h'); + when 'J': do_run('j'); + when 'K': do_run('k'); + when 'L': do_run('l'); + when 'Y': do_run('y'); + when 'U': do_run('u'); + when 'B': do_run('b'); + when 'N': do_run('n'); + when CTRL('H'): case CTRL('J'): case CTRL('K'): case CTRL('L'): + case CTRL('Y'): case CTRL('U'): case CTRL('B'): case CTRL('N'): + { + if (!on(player, ISBLIND)) + { + door_stop = TRUE; + firstmove = TRUE; + } + if (count && !newcount) + ch = direction; + else + { + ch += ('A' - CTRL('A')); + direction = ch; + } + goto over; + } + when 'F': + kamikaze = TRUE; + /* FALLTHROUGH */ + case 'f': + if (!get_dir(rs)) + { + after = FALSE; + break; + } + delta.y += hero.y; + delta.x += hero.x; + if ( ((mp = moat(delta.y, delta.x)) == NULL) + || ((!see_monst(mp)) && !on(player, SEEMONST))) + { + if (!terse) + addmsg(rs,"I see "); + msg(rs,"no monster there"); + after = FALSE; + } + else if (diag_ok(&hero, &delta)) + { + to_death = TRUE; + max_hit = 0; + mp->t_flags |= ISTARGET; + runch = ch = dir_ch; + goto over; + } + when 't': + if (!get_dir(rs)) + after = FALSE; + else + missile(rs,delta.y, delta.x); + when 'a': + if (last_comm == '\0') + { + msg(rs,"you haven't typed a command yet"); + after = FALSE; + } + else + { + ch = last_comm; + again = TRUE; + goto over; + } + when 'q': quaff(rs); + when 'Q': + after = FALSE; + q_comm = TRUE; + quit(0); + q_comm = FALSE; + when 'i': after = FALSE; inventory(rs,pack, 0); + when 'I': after = FALSE; picky_inven(rs); + when 'd': drop(rs); + when 'r': read_scroll(rs); + when 'e': eat(rs); + when 'w': wield(rs); + when 'W': wear(rs); + when 'T': take_off(rs); + when 'P': ring_on(rs); + when 'R': ring_off(rs); + when 'o': option(rs); after = FALSE; + when 'c': call(rs); after = FALSE; + when '>': after = FALSE; d_level(rs); + when '<': after = FALSE; u_level(rs); + when '?': after = FALSE; help(rs); + when '/': after = FALSE; identify(rs); + when 's': search(rs); + when 'z': + if (get_dir(rs)) + do_zap(rs); + else + after = FALSE; + when 'D': after = FALSE; discovered(rs); + when CTRL('P'): after = FALSE; msg(rs,huh); + when CTRL('R'): + after = FALSE; + clearok(curscr,TRUE); + wrefresh(curscr); + when 'v': + after = FALSE; + msg(rs,"version %s. (mctesq was here)", release); + when 'S': + after = FALSE; + save_game(rs); + when '.': ; /* Rest command */ + when ' ': after = FALSE; /* "Legal" illegal command */ + when '^': + after = FALSE; + if (get_dir(rs)) { + delta.y += hero.y; + delta.x += hero.x; + fp = &flat(delta.y, delta.x); + if (!terse) + addmsg(rs,"You have found "); + if (chat(delta.y, delta.x) != TRAP) + msg(rs,"no trap there"); + else if (on(player, ISHALU)) + msg(rs,tr_name[rnd(NTRAPS)]); + else { + msg(rs,tr_name[*fp & F_TMASK]); + *fp |= F_SEEN; + } + } +#ifdef MASTER + when '+': + after = FALSE; + if (wizard) + { + wizard = FALSE; + turn_see(TRUE); + msg(rs,"not wizard any more"); + } + else + { + wizard = passwd(); + if (wizard) + { + noscore = TRUE; + turn_see(FALSE); + msg(rs,"you are suddenly as smart as Ken Arnold in dungeon #%d", dnum); + } + else + msg(rs,"sorry"); + } +#endif + when ESCAPE: /* Escape */ + door_stop = FALSE; + count = 0; + after = FALSE; + again = FALSE; + when 'm': + move_on = TRUE; + if (!get_dir(rs)) + after = FALSE; + else + { + ch = dir_ch; + countch = dir_ch; + goto over; + } + when ')': current(rs,cur_weapon, "wielding", NULL); + when ']': current(rs,cur_armor, "wearing", NULL); + when '=': + current(rs,cur_ring[LEFT], "wearing", + terse ? "(L)" : "on left hand"); + current(rs,cur_ring[RIGHT], "wearing", + terse ? "(R)" : "on right hand"); + when '@': + stat_msg = TRUE; + status(rs); + stat_msg = FALSE; + after = FALSE; + otherwise: + after = FALSE; +#ifdef MASTER + if (wizard) switch (ch) + { + case '|': msg(rs,"@ %d,%d", hero.y, hero.x); + when 'C': create_obj(); + when '$': msg(rs,"inpack = %d", inpack); + when CTRL('G'): inventory(rs,lvl_obj, 0); + when CTRL('W'): whatis(rs,FALSE, 0); + when CTRL('D'): level++; new_level(); + when CTRL('A'): level--; new_level(); + when CTRL('F'): show_map(); + when CTRL('T'): teleport(); + when CTRL('E'): msg(rs,"food left: %d", food_left); + when CTRL('C'): add_pass(); + when CTRL('X'): turn_see(on(player, SEEMONST)); + when CTRL('~'): + { + THING *item; + + if ((item = get_item(rs,"charge", STICK)) != NULL) + item->o_charges = 10000; + } + when CTRL('I'): + { + int i; + THING *obj; + + for (i = 0; i < 9; i++) + raise_level(rs); + /* + * Give him a sword (+1,+1) + */ + obj = new_item(); + init_weapon(obj, TWOSWORD); + obj->o_hplus = 1; + obj->o_dplus = 1; + add_pack(rs,obj, TRUE); + cur_weapon = obj; + /* + * And his suit of armor + */ + obj = new_item(); + obj->o_type = ARMOR; + obj->o_which = PLATE_MAIL; + obj->o_arm = -5; + obj->o_flags |= ISKNOW; + obj->o_count = 1; + obj->o_group = 0; + cur_armor = obj; + add_pack(rs,obj, TRUE); + } + when '*' : + pr_list(); + otherwise: + illcom(rs,ch); + } + else +#endif + illcom(rs,ch); + } + /* + * turn off flags if no longer needed + */ + if (!running) + door_stop = FALSE; + } + /* + * If he ran into something to take, let him pick it up. + */ + if (take != 0) + pick_up(rs,take); + if (!running) + door_stop = FALSE; + if (!after) + ntimes++; + } + do_daemons(rs,AFTER); + do_fuses(rs,AFTER); + if (ISRING(LEFT, R_SEARCH)) + search(rs); + else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) + teleport(rs); + if (ISRING(RIGHT, R_SEARCH)) + search(rs); + else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) + teleport(rs); +} + +/* + * illcom: + * What to do with an illegal command + */ +void +illcom(struct rogue_state *rs,int ch) +{ + save_msg = FALSE; + count = 0; + msg(rs,"illegal command '%s'", unctrl(ch)); + save_msg = TRUE; +} + +/* + * search: + * player gropes about him to find hidden things. + */ +void +search(struct rogue_state *rs) +{ + register int y, x; + register char *fp; + register int ey, ex; + int probinc; + bool found; + + ey = hero.y + 1; + ex = hero.x + 1; + probinc = (on(player, ISHALU) ? 3 : 0); + probinc += (on(player, ISBLIND) ? 2 : 0); + found = FALSE; + for (y = hero.y - 1; y <= ey; y++) + for (x = hero.x - 1; x <= ex; x++) + { + if (y == hero.y && x == hero.x) + continue; + fp = &flat(y, x); + if (!(*fp & F_REAL)) + switch (chat(y, x)) + { + case '|': + case '-': + if (rnd(5 + probinc) != 0) + break; + chat(y, x) = DOOR; + msg(rs,"a secret door"); +foundone: + found = TRUE; + *fp |= F_REAL; + count = FALSE; + running = FALSE; + break; + case FLOOR: + if (rnd(2 + probinc) != 0) + break; + chat(y, x) = TRAP; + if (!terse) + addmsg(rs,"you found "); + if (on(player, ISHALU)) + msg(rs,tr_name[rnd(NTRAPS)]); + else { + msg(rs,tr_name[*fp & F_TMASK]); + *fp |= F_SEEN; + } + goto foundone; + break; + case ' ': + if (rnd(3 + probinc) != 0) + break; + chat(y, x) = PASSAGE; + goto foundone; + } + } + if (found) + look(rs,FALSE); +} + +/* + * help: + * Give single character help, or the whole mess if he wants it + */ +void +help(struct rogue_state *rs) +{ + register struct h_list *strp; + register char helpch; + register int numprint, cnt; + msg(rs,"character you want help for (* for all): "); + helpch = readchar(rs); + mpos = 0; + /* + * If its not a *, print the right help string + * or an error if he typed a funny character. + */ + if (helpch != '*') + { + move(0, 0); + for (strp = helpstr; strp->h_desc != NULL; strp++) + if (strp->h_ch == helpch) + { + lower_msg = TRUE; + msg(rs,"%s%s", unctrl(strp->h_ch), strp->h_desc); + lower_msg = FALSE; + return; + } + msg(rs,"unknown character '%s'", unctrl(helpch)); + return; + } + /* + * Here we print help for everything. + * Then wait before we return to command mode + */ + numprint = 0; + for (strp = helpstr; strp->h_desc != NULL; strp++) + if (strp->h_print) + numprint++; + if (numprint & 01) /* round odd numbers up */ + numprint++; + numprint /= 2; + if (numprint > LINES - 1) + numprint = LINES - 1; + + wclear(hw); + cnt = 0; + for (strp = helpstr; strp->h_desc != NULL; strp++) + if (strp->h_print) + { + wmove(hw, cnt % numprint, cnt >= numprint ? COLS / 2 : 0); + if (strp->h_ch) + waddstr(hw, unctrl(strp->h_ch)); + waddstr(hw, strp->h_desc); + if (++cnt >= numprint * 2) + break; + } + wmove(hw, LINES - 1, 0); + waddstr(hw, "--Press space to continue--"); + wrefresh(hw); + wait_for(rs,' '); + clearok(stdscr, TRUE); +/* + refresh(); +*/ + msg(rs,""); + touchwin(stdscr); + wrefresh(stdscr); +} + +/* + * identify: + * Tell the player what a certain thing is. + */ +void +identify(struct rogue_state *rs) +{ + register int ch; + register struct h_list *hp; + register char *str; + static struct h_list ident_list[] = { + {'|', "wall of a room", FALSE}, + {'-', "wall of a room", FALSE}, + {GOLD, "gold", FALSE}, + {STAIRS, "a staircase", FALSE}, + {DOOR, "door", FALSE}, + {FLOOR, "room floor", FALSE}, + {PLAYER, "you", FALSE}, + {PASSAGE, "passage", FALSE}, + {TRAP, "trap", FALSE}, + {POTION, "potion", FALSE}, + {SCROLL, "scroll", FALSE}, + {FOOD, "food", FALSE}, + {WEAPON, "weapon", FALSE}, + {' ', "solid rock", FALSE}, + {ARMOR, "armor", FALSE}, + {AMULET, "the Amulet of Yendor", FALSE}, + {RING, "ring", FALSE}, + {STICK, "wand or staff", FALSE}, + {'\0'} + }; + + msg(rs,"what do you want identified? "); + ch = readchar(rs); + mpos = 0; + if (ch == ESCAPE) + { + msg(rs,""); + return; + } + if (isupper(ch)) + str = monsters[ch-'A'].m_name; + else + { + str = "unknown character"; + for (hp = ident_list; hp->h_ch != '\0'; hp++) + if (hp->h_ch == ch) + { + str = hp->h_desc; + break; + } + } + msg(rs,"'%s': %s", unctrl(ch), str); +} + +/* + * d_level: + * He wants to go down a level + */ +void +d_level(struct rogue_state *rs) +{ + if (levit_check(rs)) + return; + if (chat(hero.y, hero.x) != STAIRS) + msg(rs,"I see no way down"); + else + { + level++; + seenstairs = FALSE; + new_level(rs); + } +} + +/* + * u_level: + * He wants to go up a level + */ +void +u_level(struct rogue_state *rs) +{ + if (levit_check(rs)) + return; + if (chat(hero.y, hero.x) == STAIRS) + if (amulet) + { + level--; + if (level == 0) + total_winner(rs); + new_level(rs); + msg(rs,"you feel a wrenching sensation in your gut"); + } + else + msg(rs,"your way is magically blocked"); + else + msg(rs,"I see no way up"); +} + +/* + * levit_check: + * Check to see if she's levitating, and if she is, print an + * appropriate message. + */ +bool +levit_check(struct rogue_state *rs) +{ + if (!on(player, ISLEVIT)) + return FALSE; + msg(rs,"You can't. You're floating off the ground!"); + return TRUE; +} + +/* + * call: + * Allow a user to call a potion, scroll, or ring something + */ +void +call(struct rogue_state *rs) +{ + register THING *obj; + register struct obj_info *op = NULL; + register char **guess, *elsewise = NULL; + register bool *know; + + obj = get_item(rs,"call", CALLABLE); + /* + * Make certain that it is somethings that we want to wear + */ + if (obj == NULL) + return; + switch (obj->o_type) + { + case RING: + op = &ring_info[obj->o_which]; + elsewise = r_stones[obj->o_which]; + goto norm; + when POTION: + op = &pot_info[obj->o_which]; + elsewise = p_colors[obj->o_which]; + goto norm; + when SCROLL: + op = &scr_info[obj->o_which]; + elsewise = s_names[obj->o_which]; + goto norm; + when STICK: + op = &ws_info[obj->o_which]; + elsewise = ws_made[obj->o_which]; +norm: + know = &op->oi_know; + guess = &op->oi_guess; + if (*guess != NULL) + elsewise = *guess; + when FOOD: + msg(rs,"you can't call that anything"); + return; + otherwise: + guess = &obj->o_label; + know = NULL; + elsewise = obj->o_label; + } + if (know != NULL && *know) + { + msg(rs,"that has already been identified"); + return; + } + if (elsewise != NULL && elsewise == *guess) + { + if (!terse) + addmsg(rs,"Was "); + msg(rs,"called \"%s\"", elsewise); + } + if (terse) + msg(rs,"call it: "); + else + msg(rs,"what do you want to call it? "); + + if (elsewise == NULL) + strcpy(prbuf, ""); + else + strcpy(prbuf, elsewise); + if (get_str(rs,prbuf, stdscr) == NORM) + { + if (*guess != NULL) + free(*guess); + *guess = malloc((unsigned int) strlen(prbuf) + 1); + strcpy(*guess, prbuf); + } +} + +/* + * current: + * Print the current weapon/armor + */ +void +current(struct rogue_state *rs,THING *cur, char *how, char *where) +{ + after = FALSE; + if (cur != NULL) + { + if (!terse) + addmsg(rs,"you are %s (", how); + inv_describe = FALSE; + addmsg(rs,"%c) %s", cur->o_packch, inv_name(cur, TRUE)); + inv_describe = TRUE; + if (where) + addmsg(rs," %s", where); + endmsg(rs); + } + else + { + if (!terse) + addmsg(rs,"you are "); + addmsg(rs,"%s nothing", how); + if (where) + addmsg(rs," %s", where); + endmsg(rs); + } +} diff --git a/src/cc/rogue/config.guess b/src/cc/rogue/config.guess new file mode 100755 index 000000000..396482d6c --- /dev/null +++ b/src/cc/rogue/config.guess @@ -0,0 +1,1500 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. + +timestamp='2006-07-02' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 +# General Public License for more details. +# +# You should have received a copy of the GNU 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[3456]*) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T:Interix*:[3456]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/cc/rogue/config.h b/src/cc/rogue/config.h new file mode 100644 index 000000000..558ae3ba1 --- /dev/null +++ b/src/cc/rogue/config.h @@ -0,0 +1,270 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if scorefile is top scores, not top players */ +#define ALLSCORES 1 + +/* Define if checktime feature should be enabled */ +/* #undef CHECKTIME */ + +/* Define to group owner of setgid executable */ +/* #undef GROUPOWNER */ + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if libcurses is requested */ +#define HAVE_CURSES_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* Define to 1 if you have the `erasechar' function. */ +#define HAVE_ERASECHAR 1 + +/* Define if ncurses has ESCDELAY variable */ +#define HAVE_ESCDELAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `getgid' function. */ +#define HAVE_GETGID 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getpass' function. */ +#define HAVE_GETPASS 1 + +/* Define to 1 if you have the `getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the `getuid' function. */ +#define HAVE_GETUID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `killchar' function. */ +#define HAVE_KILLCHAR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the `loadav' function. */ +/* #undef HAVE_LOADAV */ + +/* Define to 1 if `lstat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if libncurses is requested */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_TERM_H */ + +/* Define to 1 if you have the `nlist' function. */ +/* #undef HAVE_NLIST */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NLIST_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +/* #undef HAVE_SETRESGID */ + +/* Define to 1 if you have the `setresuid' function. */ +/* #undef HAVE_SETRESUID */ + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `spawnl' function. */ +/* #undef HAVE_SPAWNL */ + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef HAVE_STAT_EMPTY_STRING_BUG */ + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTMP_H 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VFORK_H */ + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if `fork' works. */ +#define HAVE_WORKING_FORK 1 + +/* Define to 1 if `vfork' works. */ +#define HAVE_WORKING_VFORK 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Define to 1 if you have the `_spawnl' function. */ +/* #undef HAVE__SPAWNL */ + +/* define if we should use program's load average function instead of system + */ +/* #undef LOADAV */ + +/* Define to file to use for scoreboard lockfile */ +#define LOCKFILE "rogue.lck" + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */ + +/* Define to include wizard mode */ +/* #undef MASTER */ + +/* Define if maxusers feature should be enabled */ +/* #undef MAXLOAD */ + +/* Define if maxusers feature should be enabled */ +/* #undef MAXUSERS */ + +/* kernel file to pass to nlist() when reading load average (unlikely to work) + */ +/* #undef NAMELIST */ + +/* word for the number of scores to store in scoreboard */ +#define NUMNAME "Ten" + +/* number of scores to store in scoreboard */ +#define NUMSCORES 10 + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "yendor@rogueforge.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "Rogue" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "Rogue 5.4.4" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "rogue" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "5.4.4" + +/* Define crypt(3) wizard mode password */ +/* #undef PASSWD */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to file to use for scoreboard */ +#define SCOREFILE "rogue.scr" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* define if we should use program's user counting function instead of + system's */ +/* #undef UCOUNT */ + +/* utmp like file to pass to ucount() when counting online users (unlikely to + work) */ +/* #undef UTMP */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define as `fork' if `vfork' does not work. */ +/* #undef vfork */ diff --git a/src/cc/rogue/config.h.in b/src/cc/rogue/config.h.in new file mode 100644 index 000000000..54f9b7cba --- /dev/null +++ b/src/cc/rogue/config.h.in @@ -0,0 +1,269 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if scorefile is top scores, not top players */ +#undef ALLSCORES + +/* Define if checktime feature should be enabled */ +#undef CHECKTIME + +/* Define to group owner of setgid executable */ +#undef GROUPOWNER + +/* Define to 1 if you have the `alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if libcurses is requested */ +#undef HAVE_CURSES_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the `erasechar' function. */ +#undef HAVE_ERASECHAR + +/* Define if ncurses has ESCDELAY variable */ +#undef HAVE_ESCDELAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + +/* Define to 1 if you have the `getgid' function. */ +#undef HAVE_GETGID + +/* Define to 1 if you have the `getloadavg' function. */ +#undef HAVE_GETLOADAVG + +/* Define to 1 if you have the `getpass' function. */ +#undef HAVE_GETPASS + +/* Define to 1 if you have the `getpwuid' function. */ +#undef HAVE_GETPWUID + +/* Define to 1 if you have the `getuid' function. */ +#undef HAVE_GETUID + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `killchar' function. */ +#undef HAVE_KILLCHAR + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the `loadav' function. */ +#undef HAVE_LOADAV + +/* Define to 1 if `lstat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_LSTAT_EMPTY_STRING_BUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if libncurses is requested */ +#undef HAVE_NCURSES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NCURSES_TERM_H + +/* Define to 1 if you have the `nlist' function. */ +#undef HAVE_NLIST + +/* Define to 1 if you have the header file. */ +#undef HAVE_NLIST_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PROCESS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PWD_H + +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the `setgid' function. */ +#undef HAVE_SETGID + +/* Define to 1 if you have the `setregid' function. */ +#undef HAVE_SETREGID + +/* Define to 1 if you have the `setresgid' function. */ +#undef HAVE_SETRESGID + +/* Define to 1 if you have the `setresuid' function. */ +#undef HAVE_SETRESUID + +/* Define to 1 if you have the `setreuid' function. */ +#undef HAVE_SETREUID + +/* Define to 1 if you have the `setuid' function. */ +#undef HAVE_SETUID + +/* Define to 1 if you have the `spawnl' function. */ +#undef HAVE_SPAWNL + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_STAT_EMPTY_STRING_BUG + +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UTSNAME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UTMP_H + +/* Define to 1 if you have the `vfork' function. */ +#undef HAVE_VFORK + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFORK_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if `fork' works. */ +#undef HAVE_WORKING_FORK + +/* Define to 1 if `vfork' works. */ +#undef HAVE_WORKING_VFORK + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Define to 1 if you have the `_spawnl' function. */ +#undef HAVE__SPAWNL + +/* define if we should use program's load average function instead of system + */ +#undef LOADAV + +/* Define to file to use for scoreboard lockfile */ +#undef LOCKFILE + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +#undef LSTAT_FOLLOWS_SLASHED_SYMLINK + +/* Define to include wizard mode */ +#undef MASTER + +/* Define if maxusers feature should be enabled */ +#undef MAXLOAD + +/* Define if maxusers feature should be enabled */ +#undef MAXUSERS + +/* kernel file to pass to nlist() when reading load average (unlikely to work) + */ +#undef NAMELIST + +/* word for the number of scores to store in scoreboard */ +#undef NUMNAME + +/* number of scores to store in scoreboard */ +#undef NUMSCORES + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define crypt(3) wizard mode password */ +#undef PASSWD + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* Define to file to use for scoreboard */ +#undef SCOREFILE + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* define if we should use program's user counting function instead of + system's */ +#undef UCOUNT + +/* utmp like file to pass to ucount() when counting online users (unlikely to + work) */ +#undef UTMP + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define as `fork' if `vfork' does not work. */ +#undef vfork diff --git a/src/cc/rogue/config.sub b/src/cc/rogue/config.sub new file mode 100755 index 000000000..387c18d1a --- /dev/null +++ b/src/cc/rogue/config.sub @@ -0,0 +1,1608 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. + +timestamp='2006-07-02' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/cc/rogue/configure.ac b/src/cc/rogue/configure.ac new file mode 100644 index 000000000..15c9cc7e4 --- /dev/null +++ b/src/cc/rogue/configure.ac @@ -0,0 +1,246 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.56) +AC_INIT([Rogue],[5.4.4], [yendor@rogueforge.net]) +AC_CONFIG_SRCDIR([armor.c]) +AC_CONFIG_HEADER([config.h]) +AC_CONFIG_FILES([Makefile rogue.6 rogue.cat rogue.doc rogue.html rogue.me]) +AC_CANONICAL_SYSTEM([]) + +# Checks for programs. +AC_PROG_CC + +# Checks for libraries. + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([arpa/inet.h sys/utsname.h pwd.h fcntl.h limits.h nlist.h stdlib.h string.h sys/ioctl.h termios.h unistd.h utmp.h term.h ncurses/term.h process.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST +AC_TYPE_UID_T +AC_TYPE_SIZE_T +AC_STRUCT_TM +MP_WITH_CURSES +# Checks for library functions. +AC_FUNC_FORK +AC_PROG_GCC_TRADITIONAL +AC_FUNC_LSTAT +AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK +AC_TYPE_SIGNAL +AC_FUNC_STAT +AC_FUNC_VPRINTF +AC_CHECK_FUNCS([erasechar killchar alarm getpass memset setenv strchr nlist _spawnl spawnl getpwuid loadav getloadavg strerror setresgid setregid setgid setresuid setreuid setuid getuid getgid]) + +AC_CHECK_PROG([NROFF], [nroff], [nroff],) +AC_CHECK_PROG([GROFF], [groff], [groff],) +AC_CHECK_PROG([COLCRT], [colcrt], [colcrt],) +AC_CHECK_PROG([TBL], [tbl], [tbl],) +AC_CHECK_PROG([SED], [sed], [sed],) + +AC_ARG_WITH(program-name, AC_HELP_STRING([--with-program-name=NAME],[alternate executable name]),[progname="$withval" ], [progname="rogue"] ) +PROGRAM=$progname +AC_SUBST(PROGRAM) + +AC_ARG_ENABLE(setgid, AC_HELP_STRING([--enable-setgid=NAME],[install executable as setgid with group ownership of NAME @<:@default=no@:>@])],[],[]) +AC_MSG_CHECKING([if using setgid execute bit]) +if test "x$enable_setgid" = "xno" ; then +GROUPOWNER= +elif test "x$enable_setgid" = "xyes" ; then +GROUPOWNER=games +elif test "x$enable_setgid" = "x" ; then +GROUPOWNER= +else +GROUPOWNER=$enable_setgid +fi + +if test "x$GROUPOWNER" != "x" ; then +AC_DEFINE_UNQUOTED([GROUPOWNER],[$GROUPOWNER], [Define to group owner of setgid executable]) +AC_MSG_RESULT([$GROUPOWNER]) +else +AC_MSG_RESULT([no]) +fi + +AC_SUBST(GROUPOWNER) + +AC_ARG_ENABLE([scorefile],[AC_HELP_STRING([--enable-scorefile=SCOREFILE], [enable scoreboard with given filename])],[],[]) +AC_MSG_CHECKING([for scoreboard file]) +if test "x$enable_scorefile" = "xno" ; then +SCOREFILE= +elif test "x$enable_scorefile" = "xyes" ; then +SCOREFILE=$progname.scr +elif test "x$enable_scorefile" = "x" ; then +SCOREFILE=$progname.scr +else +SCOREFILE=$enable_scorefile +fi + +if test "x$SCOREFILE" != "x" ; then +AC_DEFINE_UNQUOTED([SCOREFILE], ["$SCOREFILE"], [Define to file to use for scoreboard]) +AC_MSG_RESULT([$SCOREFILE]) +else +AC_MSG_RESULT([disabled]) +fi + +AC_SUBST(SCOREFILE) + +AC_ARG_ENABLE([lockfile],[AC_HELP_STRING([--enable-lockfile=LOCKFILE], [enable scoreboard lockfile with given filename])],[],[]) +AC_MSG_CHECKING([for scoreboard lockfile file]) +if test "x$enable_lockfile" = "xno" ; then +LOCKFILE= +elif test "x$enable_lockfile" = "xyes" ; then +LOCKFILE=$progname.lck +elif test "x$enable_lockfile" = "x" ; then +LOCKFILE=$progname.lck +else +LOCKFILE=$enable_lockfile +fi + +if test "x$LOCKFILE" != "x" ; then +AC_DEFINE_UNQUOTED([LOCKFILE], ["$LOCKFILE"], [Define to file to use for scoreboard lockfile]) +AC_MSG_RESULT([$LOCKFILE]) +else +AC_MSG_RESULT([disabled]) +fi + +AC_SUBST(LOCKFILE) + +AC_ARG_ENABLE([wizardmode],[AC_HELP_STRING([--enable-wizardmode], [enable availability of wizard mode @<:@default=no@:>@])],[],[]) +AC_MSG_CHECKING([if wizard mode is enabled]) +if test "x$enable_wizardmode" = "xno" ; then +AC_MSG_RESULT([no]) +elif test "x$enable_wizardmode" = "x" ; then +AC_MSG_RESULT([no]) +else +AC_DEFINE([MASTER], [], [Define to include wizard mode]) +if test "x$enable_wizardmode" != "xyes" ; then +AC_DEFINE_UNQUOTED([PASSWD],[$enable_wizardmode], [Define crypt(3) wizard mode password]) +fi +AC_MSG_RESULT([yes]) +fi + +AC_ARG_ENABLE([allscores],[AC_HELP_STRING([--enable-allscores], [enable scoreboard to show top scores, not just top players @<:@default=yes@:>@])],[],[enable_allscores=yes]) +AC_MSG_CHECKING([if allscores is enabled]) +if test "x$enable_allscores" = "xyes" ; then +AC_DEFINE([ALLSCORES], [1], [Define if scorefile is top scores, not top players]) +AC_MSG_RESULT([yes]) +else +AC_MSG_RESULT([no]) +fi + +AC_ARG_ENABLE([checktime],[AC_HELP_STRING([--enable-checktime], [enable checktime @<:@default=no@:>@])],[],[]) +AC_MSG_CHECKING([if checktime is enabled]) +if test "x$enable_checktime" = "xyes" ; then +AC_DEFINE([CHECKTIME], [1], [Define if checktime feature should be enabled]) +AC_MSG_RESULT([yes]) +else +AC_MSG_RESULT([no]) +fi + +AC_ARG_ENABLE([maxload],[AC_HELP_STRING([--enable-maxload], [enable maxload @<:@default=no@:>@])],[],[]) +AC_MSG_CHECKING([runtime execution limit (maximum system load average)]) +if test "x$enable_maxload" = "xyes" ; then +AC_DEFINE([MAXLOAD], [100], [Define if maxload feature should be enabled]) +AC_MSG_RESULT([100]) +elif test "x$enable_maxload" = "x" ; then +AC_MSG_RESULT([unlimited]) +elif test "x$enable_maxload" = "xno" ; then +AC_MSG_RESULT([unlimited]) +else +AC_DEFINE_UNQUOTED([MAXLOAD], [$enable_maxload], [Define if maxload feature should be enabled]) +AC_MSG_RESULT([$enable_maxload]) +fi + +AC_ARG_ENABLE([maxusers],[AC_HELP_STRING([--enable-maxusers], [enable maxuser @<:@default=no@:>@])],[],[]) +AC_MSG_CHECKING([runtime execution limit (maximum online system users)]) +if test "x$enable_maxusers" = "xyes" ; then +AC_DEFINE([MAXUSERS], [100], [Define if maxusers feature should be enabled]) +AC_MSG_RESULT([100]) +elif test "x$enable_maxusers" = "x" ; then +AC_MSG_RESULT([unlimited]) +elif test "x$enable_maxload" = "xno" ; then +AC_MSG_RESULT([unlimited]) +else +AC_DEFINE_UNQUOTED([MAXLOAD], [$enable_maxusers], [Define if maxusers feature should be enabled]) +AC_MSG_RESULT([$enable_maxusers]) +fi + +AC_ARG_ENABLE([numscores],[AC_HELP_STRING([--enable-numscores], [number of scores to store in scoreboard @<:@default=10@:>@])],[],[]) +AC_MSG_CHECKING([what the number of scores to store in scoreboard is]) +if test "x$numscores" = "xyes" ; then +AC_DEFINE([NUMSCORES], [10], [number of scores to store in scoreboard]) +AC_MSG_RESULT([10]) +elif test "x$enable_numscores" = "x" ; then +AC_DEFINE([NUMSCORES], [10], [number of scores to store in scoreboard]) +AC_MSG_RESULT([10]) +elif test "x$enable_numscores" = "xno" ; then +AC_DEFINE([NUMSCORES], [10], [number of scores to store in scoreboard]) +AC_MSG_RESULT([10]) +else +AC_DEFINE_UNQUOTED([NUMSCORES], [$enable_numscores], [number of scores to store in scoreboard]) +AC_MSG_RESULT([$enable_numscores]) +fi + +AC_ARG_ENABLE([numname],[AC_HELP_STRING([--enable-numname], [word for number of scores to store in scoreboard @<:@default=Ten@:>@])],[],[]) +AC_MSG_CHECKING([word for the number of scores to store in scoreboard is]) +if test "x$enable_numname" = "xyes" ; then +AC_DEFINE([NUMNAME], ["Ten"], [word for the number of scores to store in scoreboard]) +AC_MSG_RESULT([Ten]) +elif test "x$enable_numname" = "x" ; then +AC_DEFINE([NUMNAME], ["Ten"], [word for the number of scores to store in scoreboard]) +AC_MSG_RESULT([Ten]) +elif test "x$enable_numname" = "xno" ; then +AC_DEFINE([NUMNAME], ["Ten"], [word for the number of scores to store in scoreboard]) +AC_MSG_RESULT([Ten]) +else +AC_DEFINE_UNQUOTED([NUMNAME], ["$enable_numname"], [word for the number of scores to store in scoreboard]) +AC_MSG_RESULT([$enable_numname]) +fi + +AC_ARG_ENABLE([loadav],[AC_HELP_STRING([--enable-loadav=NAMELIST], [use program's load average function (unlikely to work) @<:@default=no@:>@])],[],[]) +AC_MSG_CHECKING([whether to use program's built in load average function]) +if test "x$enable_loadav" = "xyes" ; then +AC_DEFINE([LOADAV], [], [define if we should use program's load average function instead of system]) +AC_DEFINE([NAMELIST], [/vmunix], [kernel file to pass to nlist() when reading load average (unlikely to work)]) +AC_MSG_RESULT([/vmunix]) +elif test "x$enable_loadav" = "x" ; then +AC_MSG_RESULT([no]) +elif test "x$enable_loadav" = "xno" ; then +AC_MSG_RESULT([no]) +else +AC_DEFINE([LOADAV], [], [define if we should use program's load average function instead of system]) +AC_DEFINE_UNQUOTED([NAMELIST], [$enable_loadav], [kernel file to pass to nlist() when reading load average (unlikely to work)]) +AC_MSG_RESULT([$enable_loadav]) +fi + +AC_ARG_ENABLE([ucount],[AC_HELP_STRING([--enable-ucount=UTMPFILE], [use program's own function to count users (unlikely to work) @<:@default=no@:>@])],[],[]) +AC_MSG_CHECKING([whether to use program's built in user counting function]) +if test "x$enable_ucount" = "xyes" ; then +AC_DEFINE([UCOUNT], [], [define if we should use program's user counting function instead of system's]) +AC_DEFINE([UTMP], [/etc/utmp], [utmp like file to pass to ucount() when counting online users (unlikely to work)]) +AC_MSG_RESULT([/etc/utmp]) +elif test "x$enable_ucount" = "x" ; then +AC_MSG_RESULT([no]) +elif test "x$enable_count" = "xno" ; then +AC_MSG_RESULT([no]) +else +AC_DEFINE([UCOUNT], [], [define if we should use program's user counting function instead of system's]) +AC_DEFINE_UNQUOTED([UTMP], [$enable_ucount], [utmp like file to pass to ucount() when counting online users (unlikely to work)]) +AC_MSG_RESULT([$enable_ucount]) +fi + +TARGET=$target +AC_SUBST(TARGET) + +AC_MSG_CHECKING([whether to docdir is defined]) +if test "x$docdir" = "x" ; then +AC_MSG_RESULT([docdir undefined]) +docdir=\${datadir}/doc/\${PACKAGE_TARNAME} +AC_SUBST(docdir) +else +AC_MSG_RESULT([docdir defined]) +fi + +AC_OUTPUT diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c new file mode 100644 index 000000000..8309dc642 --- /dev/null +++ b/src/cc/rogue/daemon.c @@ -0,0 +1,181 @@ +/* + * Contains functions for dealing with things that happen in the + * future. + * + * @(#)daemon.c 4.7 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include "rogue.h" + +#define EMPTY 0 +#define DAEMON -1 +#define MAXDAEMONS 20 + +#define _X_ { EMPTY } + +struct delayed_action d_list[MAXDAEMONS] = { + _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, + _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, +}; + +/* + * d_slot: + * Find an empty slot in the daemon/fuse list + */ +struct delayed_action * +d_slot() +{ + register struct delayed_action *dev; + + for (dev = d_list; dev <= &d_list[MAXDAEMONS-1]; dev++) + if (dev->d_type == EMPTY) + return dev; +#ifdef MASTER + debug("Ran out of fuse slots"); +#endif + return NULL; +} + +/* + * find_slot: + * Find a particular slot in the table + */ +struct delayed_action * +find_slot(void (*func)(struct rogue_state *rs,int)) +{ + register struct delayed_action *dev; + + for (dev = d_list; dev <= &d_list[MAXDAEMONS-1]; dev++) + if (dev->d_type != EMPTY && func == dev->d_func) + return dev; + return NULL; +} + +/* + * start_daemon: + * Start a daemon, takes a function. + */ +void +start_daemon(void (*func)(struct rogue_state *rs,int), int arg, int type) +{ + register struct delayed_action *dev; + + dev = d_slot(); + dev->d_type = type; + dev->d_func = func; + dev->d_arg = arg; + dev->d_time = DAEMON; +} + +/* + * kill_daemon: + * Remove a daemon from the list + */ +void +kill_daemon(void (*func)(struct rogue_state *rs,int)) +{ + register struct delayed_action *dev; + + if ((dev = find_slot(func)) == NULL) + return; + /* + * Take it out of the list + */ + dev->d_type = EMPTY; +} + +/* + * do_daemons: + * Run all the daemons that are active with the current flag, + * passing the argument to the function. + */ +void +do_daemons(struct rogue_state *rs,int flag) +{ + register struct delayed_action *dev; + + /* + * Loop through the devil list + */ + for (dev = d_list; dev <= &d_list[MAXDAEMONS-1]; dev++) + /* + * Executing each one, giving it the proper arguments + */ + if (dev->d_type == flag && dev->d_time == DAEMON) + (*dev->d_func)(rs,dev->d_arg); +} + +/* + * fuse: + * Start a fuse to go off in a certain number of turns + */ +void +fuse(void (*func)(struct rogue_state *rs,int), int arg, int time, int type) +{ + register struct delayed_action *wire; + + wire = d_slot(); + wire->d_type = type; + wire->d_func = func; + wire->d_arg = arg; + wire->d_time = time; +} + +/* + * lengthen: + * Increase the time until a fuse goes off + */ +void +lengthen(void (*func)(struct rogue_state *rs,int), int xtime) +{ + register struct delayed_action *wire; + + if ((wire = find_slot(func)) == NULL) + return; + wire->d_time += xtime; +} + +/* + * extinguish: + * Put out a fuse + */ +void +extinguish(void (*func)(struct rogue_state *rs,int)) +{ + register struct delayed_action *wire; + + if ((wire = find_slot(func)) == NULL) + return; + wire->d_type = EMPTY; +} + +/* + * do_fuses: + * Decrement counters and start needed fuses + */ +void +do_fuses(struct rogue_state *rs,int flag) +{ + register struct delayed_action *wire; + + /* + * Step though the list + */ + for (wire = d_list; wire <= &d_list[MAXDAEMONS-1]; wire++) + /* + * Decrementing counters and starting things we want. We also need + * to remove the fuse from the list once it has gone off. + */ + if (flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0) + { + wire->d_type = EMPTY; + (*wire->d_func)(rs,wire->d_arg); + } +} diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c new file mode 100644 index 000000000..75d544cda --- /dev/null +++ b/src/cc/rogue/daemons.c @@ -0,0 +1,294 @@ +/* + * All the daemon and fuse functions are in here + * + * @(#)daemons.c 4.24 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include "rogue.h" + +/* + * doctor: + * A healing daemon that restors hit points after rest + */ +void +doctor(struct rogue_state *rs,int arg) +{ + register int lv, ohp; + + lv = pstats.s_lvl; + ohp = pstats.s_hpt; + quiet++; + if (lv < 8) + { + if (quiet + (lv << 1) > 20) + pstats.s_hpt++; + } + else + if (quiet >= 3) + pstats.s_hpt += rnd(lv - 7) + 1; + if (ISRING(LEFT, R_REGEN)) + pstats.s_hpt++; + if (ISRING(RIGHT, R_REGEN)) + pstats.s_hpt++; + if (ohp != pstats.s_hpt) + { + if (pstats.s_hpt > max_hp) + pstats.s_hpt = max_hp; + quiet = 0; + } +} + +/* + * Swander: + * Called when it is time to start rolling for wandering monsters + */ +void +swander(struct rogue_state *rs,int arg) +{ + start_daemon(rollwand, 0, BEFORE); +} + +/* + * rollwand: + * Called to roll to see if a wandering monster starts up + */ +int between = 0; +void +rollwand(struct rogue_state *rs,int arg) +{ + if (++between >= 4) + { + if (roll(1, 6) == 4) + { + wanderer(rs); + kill_daemon(rollwand); + fuse(swander, 0, WANDERTIME, BEFORE); + } + between = 0; + } +} + +/* + * unconfuse: + * Release the poor player from his confusion + */ +void +unconfuse(struct rogue_state *rs,int arg) +{ + player.t_flags &= ~ISHUH; + msg(rs,"you feel less %s now", choose_str("trippy", "confused")); +} + +/* + * unsee: + * Turn off the ability to see invisible + */ +void +unsee(struct rogue_state *rs,int arg) +{ + register THING *th; + + for (th = mlist; th != NULL; th = next(th)) + if (on(*th, ISINVIS) && see_monst(th)) + mvaddch(th->t_pos.y, th->t_pos.x, th->t_oldch); + player.t_flags &= ~CANSEE; +} + +/* + * sight: + * He gets his sight back + */ +void +sight(struct rogue_state *rs,int arg) +{ + if (on(player, ISBLIND)) + { + extinguish(sight); + player.t_flags &= ~ISBLIND; + if (!(proom->r_flags & ISGONE)) + enter_room(rs,&hero); + msg(rs,choose_str("far out! Everything is all cosmic again", + "the veil of darkness lifts")); + } +} + +/* + * nohaste: + * End the hasting + */ +void +nohaste(struct rogue_state *rs,int arg) +{ + player.t_flags &= ~ISHASTE; + msg(rs,"you feel yourself slowing down"); +} + +/* + * stomach: + * Digest the hero's food + */ +void +stomach(struct rogue_state *rs,int arg) +{ + register int oldfood; + int orig_hungry = hungry_state; + + if (food_left <= 0) + { + if (food_left-- < -STARVETIME) + death('s'); + /* + * the hero is fainting + */ + if (no_command || rnd(5) != 0) + return; + no_command += rnd(8) + 4; + hungry_state = 3; + if (!terse) + addmsg(rs,choose_str("the munchies overpower your motor capabilities. ", + "you feel too weak from lack of food. ")); + msg(rs,choose_str("You freak out", "You faint")); + } + else + { + oldfood = food_left; + food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet; + + if (food_left < MORETIME && oldfood >= MORETIME) + { + hungry_state = 2; + msg(rs,choose_str("the munchies are interfering with your motor capabilites", + "you are starting to feel weak")); + } + else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) + { + hungry_state = 1; + if (terse) + msg(rs,choose_str("getting the munchies", "getting hungry")); + else + msg(rs,choose_str("you are getting the munchies", + "you are starting to get hungry")); + } + } + if (hungry_state != orig_hungry) { + player.t_flags &= ~ISRUN; + running = FALSE; + to_death = FALSE; + count = 0; + } +} + +/* + * come_down: + * Take the hero down off her acid trip. + */ +void +come_down(struct rogue_state *rs,int arg) +{ + register THING *tp; + register bool seemonst; + + if (!on(player, ISHALU)) + return; + + kill_daemon(visuals); + player.t_flags &= ~ISHALU; + + if (on(player, ISBLIND)) + return; + + /* + * undo the things + */ + for (tp = lvl_obj; tp != NULL; tp = next(tp)) + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); + + /* + * undo the monsters + */ + seemonst = on(player, SEEMONST); + for (tp = mlist; tp != NULL; tp = next(tp)) + { + move(tp->t_pos.y, tp->t_pos.x); + if (cansee(rs,tp->t_pos.y, tp->t_pos.x)) + if (!on(*tp, ISINVIS) || on(player, CANSEE)) + addch(tp->t_disguise); + else + addch(chat(tp->t_pos.y, tp->t_pos.x)); + else if (seemonst) + { + standout(); + addch(tp->t_type); + standend(); + } + } + msg(rs,"Everything looks SO boring now."); +} + +/* + * visuals: + * change the characters for the player + */ +void +visuals(struct rogue_state *rs,int arg) +{ + register THING *tp; + register bool seemonst; + + if (!after || (running && jump)) + return; + /* + * change the things + */ + for (tp = lvl_obj; tp != NULL; tp = next(tp)) + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); + + /* + * change the stairs + */ + if (!seenstairs && cansee(rs,stairs.y, stairs.x)) + mvaddch(stairs.y, stairs.x, rnd_thing()); + + /* + * change the monsters + */ + seemonst = on(player, SEEMONST); + for (tp = mlist; tp != NULL; tp = next(tp)) + { + move(tp->t_pos.y, tp->t_pos.x); + if (see_monst(tp)) + { + if (tp->t_type == 'X' && tp->t_disguise != 'X') + addch(rnd_thing()); + else + addch(rnd(26) + 'A'); + } + else if (seemonst) + { + standout(); + addch(rnd(26) + 'A'); + standend(); + } + } +} + +/* + * land: + * Land from a levitation potion + */ +void +land(struct rogue_state *rs,int arg) +{ + player.t_flags &= ~ISLEVIT; + msg(rs,choose_str("bummer! You've hit the ground", + "you float gently to the ground")); +} diff --git a/src/cc/rogue/extern.c b/src/cc/rogue/extern.c new file mode 100644 index 000000000..fb732dfde --- /dev/null +++ b/src/cc/rogue/extern.c @@ -0,0 +1,391 @@ +/* + * global variable initializaton + * + * @(#)extern.c 4.82 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include "rogue.h" + +bool after; /* True if we want after daemons */ +bool again; /* Repeating the last command */ +int noscore; /* Was a wizard sometime */ +bool seenstairs; /* Have seen the stairs (for lsd) */ +bool amulet = FALSE; /* He found the amulet */ +bool door_stop = FALSE; /* Stop running when we pass a door */ +bool fight_flush = FALSE; /* True if toilet input */ +bool firstmove = FALSE; /* First move after setting door_stop */ +bool got_ltc = FALSE; /* We have gotten the local tty chars */ +bool has_hit = FALSE; /* Has a "hit" message pending in msg */ +bool in_shell = FALSE; /* True if executing a shell */ +bool inv_describe = TRUE; /* Say which way items are being used */ +bool jump = FALSE; /* Show running as series of jumps */ +bool kamikaze = FALSE; /* to_death really to DEATH */ +bool lower_msg = FALSE; /* Messages should start w/lower case */ +bool move_on = FALSE; /* Next move shouldn't pick up items */ +bool msg_esc = FALSE; /* Check for ESC from msg's --More-- */ +bool passgo = FALSE; /* Follow passages */ +bool playing = TRUE; /* True until he quits */ +bool q_comm = FALSE; /* Are we executing a 'Q' command? */ +bool running = FALSE; /* True if player is running */ +bool save_msg = TRUE; /* Remember last msg */ +bool see_floor = TRUE; /* Show the lamp illuminated floor */ +bool stat_msg = FALSE; /* Should status() print as a msg() */ +bool terse = FALSE; /* True if we should be short */ +bool to_death = FALSE; /* Fighting is to the death! */ +bool tombstone = TRUE; /* Print out tombstone at end */ +#ifdef MASTER +int wizard = FALSE; /* True if allows wizard commands */ +#endif +bool pack_used[26] = { /* Is the character used in the pack? */ + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE +}; + +char dir_ch; /* Direction from last get_dir() call */ +char file_name[MAXSTR]; /* Save file name */ +char huh[MAXSTR]; /* The last message printed */ +char *p_colors[MAXPOTIONS]; /* Colors of the potions */ +char prbuf[2*MAXSTR]; /* buffer for sprintfs */ +char *r_stones[MAXRINGS]; /* Stone settings of the rings */ +char runch; /* Direction player is running */ +char *s_names[MAXSCROLLS]; /* Names of the scrolls */ +char take; /* Thing she is taking */ +char whoami[MAXSTR]; /* Name of player */ +char *ws_made[MAXSTICKS]; /* What sticks are made of */ +char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */ +int orig_dsusp; /* Original dsusp char */ +char fruit[MAXSTR] = /* Favorite fruit */ + { 's', 'l', 'i', 'm', 'e', '-', 'm', 'o', 'l', 'd', '\0' }; +char home[MAXSTR] = { '\0' }; /* User's home directory */ +char *inv_t_name[] = { + "Overwrite", + "Slow", + "Clear" +}; +char l_last_comm = '\0'; /* Last last_comm */ +char l_last_dir = '\0'; /* Last last_dir */ +char last_comm = '\0'; /* Last command typed */ +char last_dir = '\0'; /* Last direction given */ +char *tr_name[] = { /* Names of the traps */ + "a trapdoor", + "an arrow trap", + "a sleeping gas trap", + "a beartrap", + "a teleport trap", + "a poison dart trap", + "a rust trap", + "a mysterious trap" +}; + + +int n_objs; /* # items listed in inventory() call */ +int ntraps; /* Number of traps on this level */ +int hungry_state = 0; /* How hungry is he */ +int inpack = 0; /* Number of things in pack */ +int inv_type = 0; /* Type of inventory to use */ +int level = 1; /* What level she is on */ +int max_hit; /* Max damage done to her in to_death */ +int max_level; /* Deepest player has gone */ +int mpos = 0; /* Where cursor is on top line */ +int no_food = 0; /* Number of levels without food */ +int a_class[MAXARMORS] = { /* Armor class for each armor type */ + 8, /* LEATHER */ + 7, /* RING_MAIL */ + 7, /* STUDDED_LEATHER */ + 6, /* SCALE_MAIL */ + 5, /* CHAIN_MAIL */ + 4, /* SPLINT_MAIL */ + 4, /* BANDED_MAIL */ + 3, /* PLATE_MAIL */ +}; + +int count = 0; /* Number of times to repeat command */ +FILE *scoreboard = NULL; /* File descriptor for score file */ +int food_left; /* Amount of food in hero's stomach */ +int lastscore = -1; /* Score before this turn */ +int no_command = 0; /* Number of turns asleep */ +int no_move = 0; /* Number of turns held in place */ +int purse = 0; /* How much gold he has */ +int quiet = 0; /* Number of quiet turns */ +int vf_hit = 0; /* Number of time flytrap has hit */ + +int dnum; /* Dungeon number */ +uint64_t seed; /* Random number seed */ +int e_levels[] = { + 10L, + 20L, + 40L, + 80L, + 160L, + 320L, + 640L, + 1300L, + 2600L, + 5200L, + 13000L, + 26000L, + 50000L, + 100000L, + 200000L, + 400000L, + 800000L, + 2000000L, + 4000000L, + 8000000L, + 0L +}; + +coord delta; /* Change indicated to get_dir() */ +coord oldpos; /* Position before last look() call */ +coord stairs; /* Location of staircase */ + +PLACE places[MAXLINES*MAXCOLS]; /* level map */ + +THING *cur_armor; /* What he is wearing */ +THING *cur_ring[2]; /* Which rings are being worn */ +THING *cur_weapon; /* Which weapon he is weilding */ +THING *l_last_pick = NULL; /* Last last_pick */ +THING *last_pick = NULL; /* Last object picked in get_item() */ +THING *lvl_obj = NULL; /* List of objects on this level */ +THING *mlist = NULL; /* List of monsters on the level */ +THING player; /* His stats */ + /* restart of game */ + +WINDOW *hw = NULL; /* used as a scratch window */ + +#define INIT_STATS { 16, 0, 1, 10, 12, "1x4", 12 } + +struct stats max_stats = INIT_STATS; /* The maximum for the player */ + +struct room *oldrp; /* Roomin(&oldpos) */ +struct room rooms[MAXROOMS]; /* One for each room -- A level */ +struct room passages[MAXPASS] = /* One for each passage */ +{ + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, + { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} } +}; + +#define ___ 1 +#define XX 10 +struct monster monsters[26] = + { +/* Name CARRY FLAG str, exp, lvl, amr, hpt, dmg */ +{ "aquator", 0, ISMEAN, { XX, 20, 5, 2, ___, "0x0/0x0" } }, +{ "bat", 0, ISFLY, { XX, 1, 1, 3, ___, "1x2" } }, +{ "centaur", 15, 0, { XX, 17, 4, 4, ___, "1x2/1x5/1x5" } }, +{ "dragon", 100, ISMEAN, { XX,5000, 10, -1, ___, "1x8/1x8/3x10" } }, +{ "emu", 0, ISMEAN, { XX, 2, 1, 7, ___, "1x2" } }, +{ "venus flytrap", 0, ISMEAN, { XX, 80, 8, 3, ___, "%%%x0" } }, + /* NOTE: the damage is %%% so that xstr won't merge this */ + /* string with others, since it is written on in the program */ +{ "griffin", 20, ISMEAN|ISFLY|ISREGEN, { XX,2000, 13, 2, ___, "4x3/3x5" } }, +{ "hobgoblin", 0, ISMEAN, { XX, 3, 1, 5, ___, "1x8" } }, +{ "ice monster", 0, 0, { XX, 5, 1, 9, ___, "0x0" } }, +{ "jabberwock", 70, 0, { XX,3000, 15, 6, ___, "2x12/2x4" } }, +{ "kestrel", 0, ISMEAN|ISFLY, { XX, 1, 1, 7, ___, "1x4" } }, +{ "leprechaun", 0, 0, { XX, 10, 3, 8, ___, "1x1" } }, +{ "medusa", 40, ISMEAN, { XX,200, 8, 2, ___, "3x4/3x4/2x5" } }, +{ "nymph", 100, 0, { XX, 37, 3, 9, ___, "0x0" } }, +{ "orc", 15, ISGREED,{ XX, 5, 1, 6, ___, "1x8" } }, +{ "phantom", 0, ISINVIS,{ XX,120, 8, 3, ___, "4x4" } }, +{ "quagga", 0, ISMEAN, { XX, 15, 3, 3, ___, "1x5/1x5" } }, +{ "rattlesnake", 0, ISMEAN, { XX, 9, 2, 3, ___, "1x6" } }, +{ "snake", 0, ISMEAN, { XX, 2, 1, 5, ___, "1x3" } }, +{ "troll", 50, ISREGEN|ISMEAN,{ XX, 120, 6, 4, ___, "1x8/1x8/2x6" } }, +{ "black unicorn", 0, ISMEAN, { XX,190, 7, -2, ___, "1x9/1x9/2x9" } }, +{ "vampire", 20, ISREGEN|ISMEAN,{ XX,350, 8, 1, ___, "1x10" } }, +{ "wraith", 0, 0, { XX, 55, 5, 4, ___, "1x6" } }, +{ "xeroc", 30, 0, { XX,100, 7, 7, ___, "4x4" } }, +{ "yeti", 30, 0, { XX, 50, 4, 6, ___, "1x6/1x6" } }, +{ "zombie", 0, ISMEAN, { XX, 6, 2, 8, ___, "1x8" } } + }; +#undef ___ +#undef XX + +struct obj_info things[NUMTHINGS] = { + { 0, 26 }, /* potion */ + { 0, 36 }, /* scroll */ + { 0, 16 }, /* food */ + { 0, 7 }, /* weapon */ + { 0, 7 }, /* armor */ + { 0, 4 }, /* ring */ + { 0, 4 }, /* stick */ +}; + +struct obj_info arm_info[MAXARMORS] = { + { "leather armor", 20, 20, NULL, FALSE }, + { "ring mail", 15, 25, NULL, FALSE }, + { "studded leather armor", 15, 20, NULL, FALSE }, + { "scale mail", 13, 30, NULL, FALSE }, + { "chain mail", 12, 75, NULL, FALSE }, + { "splint mail", 10, 80, NULL, FALSE }, + { "banded mail", 10, 90, NULL, FALSE }, + { "plate mail", 5, 150, NULL, FALSE }, +}; +struct obj_info pot_info[MAXPOTIONS] = { + { "confusion", 7, 5, NULL, FALSE }, + { "hallucination", 8, 5, NULL, FALSE }, + { "poison", 8, 5, NULL, FALSE }, + { "gain strength", 13, 150, NULL, FALSE }, + { "see invisible", 3, 100, NULL, FALSE }, + { "healing", 13, 130, NULL, FALSE }, + { "monster detection", 6, 130, NULL, FALSE }, + { "magic detection", 6, 105, NULL, FALSE }, + { "raise level", 2, 250, NULL, FALSE }, + { "extra healing", 5, 200, NULL, FALSE }, + { "haste self", 5, 190, NULL, FALSE }, + { "restore strength", 13, 130, NULL, FALSE }, + { "blindness", 5, 5, NULL, FALSE }, + { "levitation", 6, 75, NULL, FALSE }, +}; +struct obj_info ring_info[MAXRINGS] = { + { "protection", 9, 400, NULL, FALSE }, + { "add strength", 9, 400, NULL, FALSE }, + { "sustain strength", 5, 280, NULL, FALSE }, + { "searching", 10, 420, NULL, FALSE }, + { "see invisible", 10, 310, NULL, FALSE }, + { "adornment", 1, 10, NULL, FALSE }, + { "aggravate monster", 10, 10, NULL, FALSE }, + { "dexterity", 8, 440, NULL, FALSE }, + { "increase damage", 8, 400, NULL, FALSE }, + { "regeneration", 4, 460, NULL, FALSE }, + { "slow digestion", 9, 240, NULL, FALSE }, + { "teleportation", 5, 30, NULL, FALSE }, + { "stealth", 7, 470, NULL, FALSE }, + { "maintain armor", 5, 380, NULL, FALSE }, +}; +struct obj_info scr_info[MAXSCROLLS] = { + { "monster confusion", 7, 140, NULL, FALSE }, + { "magic mapping", 4, 150, NULL, FALSE }, + { "hold monster", 2, 180, NULL, FALSE }, + { "sleep", 3, 5, NULL, FALSE }, + { "enchant armor", 7, 160, NULL, FALSE }, + { "identify potion", 10, 80, NULL, FALSE }, + { "identify scroll", 10, 80, NULL, FALSE }, + { "identify weapon", 6, 80, NULL, FALSE }, + { "identify armor", 7, 100, NULL, FALSE }, + { "identify ring, wand or staff", 10, 115, NULL, FALSE }, + { "scare monster", 3, 200, NULL, FALSE }, + { "food detection", 2, 60, NULL, FALSE }, + { "teleportation", 5, 165, NULL, FALSE }, + { "enchant weapon", 8, 150, NULL, FALSE }, + { "create monster", 4, 75, NULL, FALSE }, + { "remove curse", 7, 105, NULL, FALSE }, + { "aggravate monsters", 3, 20, NULL, FALSE }, + { "protect armor", 2, 250, NULL, FALSE }, +}; +struct obj_info weap_info[MAXWEAPONS + 1] = { + { "mace", 11, 8, NULL, FALSE }, + { "long sword", 11, 15, NULL, FALSE }, + { "short bow", 12, 15, NULL, FALSE }, + { "arrow", 12, 1, NULL, FALSE }, + { "dagger", 8, 3, NULL, FALSE }, + { "two handed sword", 10, 75, NULL, FALSE }, + { "dart", 12, 2, NULL, FALSE }, + { "shuriken", 12, 5, NULL, FALSE }, + { "spear", 12, 5, NULL, FALSE }, + { NULL, 0 }, /* DO NOT REMOVE: fake entry for dragon's breath */ +}; +struct obj_info ws_info[MAXSTICKS] = { + { "light", 12, 250, NULL, FALSE }, + { "invisibility", 6, 5, NULL, FALSE }, + { "lightning", 3, 330, NULL, FALSE }, + { "fire", 3, 330, NULL, FALSE }, + { "cold", 3, 330, NULL, FALSE }, + { "polymorph", 15, 310, NULL, FALSE }, + { "magic missile", 10, 170, NULL, FALSE }, + { "haste monster", 10, 5, NULL, FALSE }, + { "slow monster", 11, 350, NULL, FALSE }, + { "drain life", 9, 300, NULL, FALSE }, + { "nothing", 1, 5, NULL, FALSE }, + { "teleport away", 6, 340, NULL, FALSE }, + { "teleport to", 6, 50, NULL, FALSE }, + { "cancellation", 5, 280, NULL, FALSE }, +}; + +struct h_list helpstr[] = { + {'?', " prints help", TRUE}, + {'/', " identify object", TRUE}, + {'h', " left", TRUE}, + {'j', " down", TRUE}, + {'k', " up", TRUE}, + {'l', " right", TRUE}, + {'y', " up & left", TRUE}, + {'u', " up & right", TRUE}, + {'b', " down & left", TRUE}, + {'n', " down & right", TRUE}, + {'H', " run left", FALSE}, + {'J', " run down", FALSE}, + {'K', " run up", FALSE}, + {'L', " run right", FALSE}, + {'Y', " run up & left", FALSE}, + {'U', " run up & right", FALSE}, + {'B', " run down & left", FALSE}, + {'N', " run down & right", FALSE}, + {CTRL('H'), " run left until adjacent", FALSE}, + {CTRL('J'), " run down until adjacent", FALSE}, + {CTRL('K'), " run up until adjacent", FALSE}, + {CTRL('L'), " run right until adjacent", FALSE}, + {CTRL('Y'), " run up & left until adjacent", FALSE}, + {CTRL('U'), " run up & right until adjacent", FALSE}, + {CTRL('B'), " run down & left until adjacent", FALSE}, + {CTRL('N'), " run down & right until adjacent", FALSE}, + {'\0', " : run that way", TRUE}, + {'\0', " : run till adjacent", TRUE}, + {'f', " fight till death or near death", TRUE}, + {'t', " throw something", TRUE}, + {'m', " move onto without picking up", TRUE}, + {'z', " zap a wand in a direction", TRUE}, + {'^', " identify trap type", TRUE}, + {'s', " search for trap/secret door", TRUE}, + {'>', " go down a staircase", TRUE}, + {'<', " go up a staircase", TRUE}, + {'.', " rest for a turn", TRUE}, + {',', " pick something up", TRUE}, + {'i', " inventory", TRUE}, + {'I', " inventory single item", TRUE}, + {'q', " quaff potion", TRUE}, + {'r', " read scroll", TRUE}, + {'e', " eat food", TRUE}, + {'w', " wield a weapon", TRUE}, + {'W', " wear armor", TRUE}, + {'T', " take armor off", TRUE}, + {'P', " put on ring", TRUE}, + {'R', " remove ring", TRUE}, + {'d', " drop object", TRUE}, + {'c', " call object", TRUE}, + {'a', " repeat last command", TRUE}, + {')', " print current weapon", TRUE}, + {']', " print current armor", TRUE}, + {'=', " print current rings", TRUE}, + {'@', " print current stats", TRUE}, + {'D', " recall what's been discovered", TRUE}, + {'o', " examine/set options", TRUE}, + {CTRL('R'), " redraw screen", TRUE}, + {CTRL('P'), " repeat last message", TRUE}, + {ESCAPE, " cancel command", TRUE}, + {'S', " save game", TRUE}, + {'Q', " quit", TRUE}, + {'!', " shell escape", TRUE}, + {'F', " fight till either of you dies", TRUE}, + {'v', " print version number", TRUE}, + {0, NULL } +}; diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h new file mode 100644 index 000000000..e8c13d27d --- /dev/null +++ b/src/cc/rogue/extern.h @@ -0,0 +1,181 @@ +/* + * Defines for things used in mach_dep.c + * + * @(#)extern.h 4.35 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + + +#ifdef HAVE_CONFIG_H +#ifdef PDCURSES +#undef HAVE_UNISTD_H +#undef HAVE_LIMITS_H +#undef HAVE_MEMORY_H +#undef HAVE_STRING_H +#endif +#include "config.h" +#elif defined(__DJGPP__) +#define HAVE_SYS_TYPES_H 1 +#define HAVE_PROCESS_H 1 +#define HAVE_PWD_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_SETGID 1 +#define HAVE_GETGID 1 +#define HAVE_SETUID 1 +#define HAVE_GETUID 1 +#define HAVE_GETPASS 1 +#define HAVE_SPAWNL 1 +#define HAVE_ALARM 1 +#define HAVE_ERASECHAR 1 +#define HAVE_KILLCHAR 1 +#elif defined(_WIN32) +#define HAVE_CURSES_H +#define HAVE_TERM_H +#define HAVE__SPAWNL +#define HAVE_SYS_TYPES_H +#define HAVE_PROCESS_H +#define HAVE_ERASECHAR 1 +#define HAVE_KILLCHAR 1 +#elif defined(__CYGWIN__) +#define HAVE_SYS_TYPES_H 1 +#define HAVE_PWD_H 1 +#define HAVE_PWD_H 1 +#define HAVE_SYS_UTSNAME_H 1 +#define HAVE_ARPA_INET_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_NCURSES_TERM_H 1 +#define HAVE_ESCDELAY +#define HAVE_SETGID 1 +#define HAVE_GETGID 1 +#define HAVE_SETUID 1 +#define HAVE_GETUID 1 +#define HAVE_GETPASS 1 +#define HAVE_GETPWUID 1 +#define HAVE_WORKING_FORK 1 +#define HAVE_ALARM 1 +#define HAVE_SPAWNL 1 +#define HAVE__SPAWNL 1 +#define HAVE_ERASECHAR 1 +#define HAVE_KILLCHAR 1 +#else /* POSIX */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_PWD_H 1 +#define HAVE_PWD_H 1 +#define HAVE_SYS_UTSNAME_H 1 +#define HAVE_ARPA_INET_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_TERM_H 1 +#define HAVE_SETGID 1 +#define HAVE_GETGID 1 +#define HAVE_SETUID 1 +#define HAVE_GETUID 1 +#define HAVE_SETREUID 1 +#define HAVE_SETREGID 1 +#define HAVE_GETPASS 1 +#define HAVE_GETPWUID 1 +#define HAVE_WORKING_FORK 1 +#define HAVE_ERASECHAR 1 +#define HAVE_KILLCHAR 1 +#ifndef _AIX +#define HAVE_GETLOADAVG 1 +#endif +#define HAVE_ALARM 1 +#endif + +#ifdef __DJGPP__ +#undef HAVE_GETPWUID /* DJGPP's limited version doesn't even work as documented */ +#endif + +/* + * Don't change the constants, since they are used for sizes in many + * places in the program. + */ + +#include +#include + +#undef SIGTSTP + +#define MAXSTR 1024 /* maximum length of strings */ +#define MAXLINES 32 /* maximum number of screen lines used */ +#define MAXCOLS 80 /* maximum number of screen columns used */ + +#define RN ((int32_t)((seed = seed*11109+13849) >> 16) & 0xffff) +#ifdef CTRL +#undef CTRL +#endif +#define CTRL(c) (c & 037) + +/* + * Now all the global variables + */ + +extern bool got_ltc, in_shell; +extern int wizard; +extern char fruit[], prbuf[], whoami[]; +extern int orig_dsusp; +extern FILE *scoreboard; + +/* + * Function types + */ + +void auto_save(int); +void endit(int sig); +void fatal(char *); +void getltchars(void); +void leave(int); +void my_exit(int st); +void playltchars(void); +void quit(int); +void resetltchars(void); +void set_order(int *order, int numthings); +void tstp(int ignored); + +char *killname(char monst, bool doart); +char *nothing(char type); +char *type_name(int type); + +#ifdef CHECKTIME +int checkout(void); +#endif + +int md_chmod(char *filename, int mode); +char *md_crypt(char *key, char *salt); +int md_dsuspchar(void); +int md_erasechar(void); +char *md_gethomedir(void); +char *md_getusername(void); +int md_getuid(void); +char *md_getpass(char *prompt); +int md_getpid(void); +char *md_getrealname(int uid); +void md_init(void); +int md_killchar(void); +void md_normaluser(void); +void md_raw_standout(void); +void md_raw_standend(void); +int md_readchar(void); +int md_setdsuspchar(int c); +int md_shellescape(void); +void md_sleep(int s); +int md_suspchar(void); +int md_hasclreol(void); +int md_unlink(char *file); +int md_unlink_open_file(char *file, FILE *inf); +void md_tstpsignal(void); +void md_tstphold(void); +void md_tstpresume(void); +void md_ignoreallsignals(void); +void md_onsignal_autosave(void); +void md_onsignal_exit(void); +void md_onsignal_default(void); +int md_issymlink(char *sp); + diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c new file mode 100644 index 000000000..ba1c9112e --- /dev/null +++ b/src/cc/rogue/fight.c @@ -0,0 +1,686 @@ +/* + * All the fighting gets done here + * + * @(#)fight.c 4.67 (Berkeley) 09/06/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include "rogue.h" + +#define EQSTR(a, b) (strcmp(a, b) == 0) + +char *h_names[] = { /* strings for hitting */ + " scored an excellent hit on ", + " hit ", + " have injured ", + " swing and hit ", + " scored an excellent hit on ", + " hit ", + " has injured ", + " swings and hits " +}; + +char *m_names[] = { /* strings for missing */ + " miss", + " swing and miss", + " barely miss", + " don't hit", + " misses", + " swings and misses", + " barely misses", + " doesn't hit", +}; + +/* + * adjustments to hit probabilities due to strength + */ +static int str_plus[] = { + -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, +}; + +/* + * adjustments to damage done due to strength + */ +static int add_dam[] = { + -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, + 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6 +}; + +/* + * fight: + * The player attacks the monster. + */ +int +fight(struct rogue_state *rs,coord *mp, THING *weap, bool thrown) +{ + register THING *tp; + register bool did_hit = TRUE; + register char *mname, ch; + + /* + * Find the monster we want to fight + */ +#ifdef MASTER + if ((tp = moat(mp->y, mp->x)) == NULL) + debug("Fight what @ %d,%d", mp->y, mp->x); +#else + tp = moat(mp->y, mp->x); +#endif + /* + * Since we are fighting, things are not quiet so no healing takes + * place. + */ + count = 0; + quiet = 0; + runto(rs,mp); + /* + * Let him know it was really a xeroc (if it was one). + */ + ch = '\0'; + if (tp->t_type == 'X' && tp->t_disguise != 'X' && !on(player, ISBLIND)) + { + tp->t_disguise = 'X'; + if (on(player, ISHALU)) { + ch = (char)(rnd(26) + 'A'); + mvaddch(tp->t_pos.y, tp->t_pos.x, ch); + } + msg(rs,choose_str("heavy! That's a nasty critter!", + "wait! That's a xeroc!")); + if (!thrown) + return FALSE; + } + mname = set_mname(tp); + did_hit = FALSE; + has_hit = (terse && !to_death); + if (roll_em(&player, tp, weap, thrown)) + { + did_hit = FALSE; + if (thrown) + thunk(rs,weap, mname, terse); + else + hit(rs,(char *) NULL, mname, terse); + if (on(player, CANHUH)) + { + did_hit = TRUE; + tp->t_flags |= ISHUH; + player.t_flags &= ~CANHUH; + endmsg(rs); + has_hit = FALSE; + msg(rs,"your hands stop glowing %s", pick_color("red")); + } + if (tp->t_stats.s_hpt <= 0) + killed(rs,tp, TRUE); + else if (did_hit && !on(player, ISBLIND)) + msg(rs,"%s appears confused", mname); + did_hit = TRUE; + } + else + if (thrown) + bounce(rs,weap, mname, terse); + else + miss(rs,(char *) NULL, mname, terse); + return did_hit; +} + +/* + * attack: + * The monster attacks the player + */ +int +attack(struct rogue_state *rs,THING *mp) +{ + register char *mname; + register int oldhp; + + /* + * Since this is an attack, stop running and any healing that was + * going on at the time. + */ + running = FALSE; + count = 0; + quiet = 0; + if (to_death && !on(*mp, ISTARGET)) + { + to_death = FALSE; + kamikaze = FALSE; + } + if (mp->t_type == 'X' && mp->t_disguise != 'X' && !on(player, ISBLIND)) + { + mp->t_disguise = 'X'; + if (on(player, ISHALU)) + mvaddch(mp->t_pos.y, mp->t_pos.x, rnd(26) + 'A'); + } + mname = set_mname(mp); + oldhp = pstats.s_hpt; + if (roll_em(mp, &player, (THING *) NULL, FALSE)) + { + if (mp->t_type != 'I') + { + if (has_hit) + addmsg(rs,". "); + hit(rs,mname, (char *) NULL, FALSE); + } + else + if (has_hit) + endmsg(rs); + has_hit = FALSE; + if (pstats.s_hpt <= 0) + death(mp->t_type); /* Bye bye life ... */ + else if (!kamikaze) + { + oldhp -= pstats.s_hpt; + if (oldhp > max_hit) + max_hit = oldhp; + if (pstats.s_hpt <= max_hit) + to_death = FALSE; + } + if (!on(*mp, ISCANC)) + switch (mp->t_type) + { + case 'A': + /* + * If an aquator hits, you can lose armor class. + */ + rust_armor(rs,cur_armor); + when 'I': + /* + * The ice monster freezes you + */ + player.t_flags &= ~ISRUN; + if (!no_command) + { + addmsg(rs,"you are frozen"); + if (!terse) + addmsg(rs," by the %s", mname); + endmsg(rs); + } + no_command += rnd(2) + 2; + if (no_command > BORE_LEVEL) + death('h'); + when 'R': + /* + * Rattlesnakes have poisonous bites + */ + if (!save(VS_POISON)) + { + if (!ISWEARING(R_SUSTSTR)) + { + chg_str(-1); + if (!terse) + msg(rs,"you feel a bite in your leg and now feel weaker"); + else + msg(rs,"a bite has weakened you"); + } + else if (!to_death) + { + if (!terse) + msg(rs,"a bite momentarily weakens you"); + else + msg(rs,"bite has no effect"); + } + } + when 'W': + case 'V': + /* + * Wraiths might drain energy levels, and Vampires + * can steal max_hp + */ + if (rnd(100) < (mp->t_type == 'W' ? 15 : 30)) + { + register int fewer; + + if (mp->t_type == 'W') + { + if (pstats.s_exp == 0) + death('W'); /* All levels gone */ + if (--pstats.s_lvl == 0) + { + pstats.s_exp = 0; + pstats.s_lvl = 1; + } + else + pstats.s_exp = e_levels[pstats.s_lvl-1]+1; + fewer = roll(1, 10); + } + else + fewer = roll(1, 3); + pstats.s_hpt -= fewer; + max_hp -= fewer; + if (pstats.s_hpt <= 0) + pstats.s_hpt = 1; + if (max_hp <= 0) + death(mp->t_type); + msg(rs,"you suddenly feel weaker"); + } + when 'F': + /* + * Venus Flytrap stops the poor guy from moving + */ + player.t_flags |= ISHELD; + sprintf(monsters['F'-'A'].m_stats.s_dmg,"%dx1", ++vf_hit); + if (--pstats.s_hpt <= 0) + death('F'); + when 'L': + { + /* + * Leperachaun steals some gold + */ + register int lastpurse; + + lastpurse = purse; + purse -= GOLDCALC; + if (!save(VS_MAGIC)) + purse -= GOLDCALC + GOLDCALC + GOLDCALC + GOLDCALC; + if (purse < 0) + purse = 0; + remove_mon(rs,&mp->t_pos, mp, FALSE); + mp=NULL; + if (purse != lastpurse) + msg(rs,"your purse feels lighter"); + } + when 'N': + { + register THING *obj, *steal; + register int nobj; + + /* + * Nymph's steal a magic item, look through the pack + * and pick out one we like. + */ + steal = NULL; + for (nobj = 0, obj = pack; obj != NULL; obj = next(obj)) + if (obj != cur_armor && obj != cur_weapon + && obj != cur_ring[LEFT] && obj != cur_ring[RIGHT] + && is_magic(obj) && rnd(++nobj) == 0) + steal = obj; + if (steal != NULL) + { + remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); + mp=NULL; + leave_pack(rs,steal, FALSE, FALSE); + msg(rs,"she stole %s!", inv_name(steal, TRUE)); + discard(steal); + } + } + otherwise: + break; + } + } + else if (mp->t_type != 'I') + { + if (has_hit) + { + addmsg(rs,". "); + has_hit = FALSE; + } + if (mp->t_type == 'F') + { + pstats.s_hpt -= vf_hit; + if (pstats.s_hpt <= 0) + death(mp->t_type); /* Bye bye life ... */ + } + miss(rs,mname, (char *) NULL, FALSE); + } + if (fight_flush && !to_death) + flush_type(); + count = 0; + status(rs); + if (mp == NULL) + return(-1); + else + return(0); +} + +/* + * set_mname: + * return the monster name for the given monster + */ +char * +set_mname(THING *tp) +{ + int ch; + char *mname; + static char tbuf[MAXSTR] = { 't', 'h', 'e', ' ' }; + + if (!see_monst(tp) && !on(player, SEEMONST)) + return (terse ? "it" : "something"); + else if (on(player, ISHALU)) + { + move(tp->t_pos.y, tp->t_pos.x); + ch = toascii(inch()); + if (!isupper(ch)) + ch = rnd(26); + else + ch -= 'A'; + mname = monsters[ch].m_name; + } + else + mname = monsters[tp->t_type - 'A'].m_name; + strcpy(&tbuf[4], mname); + return tbuf; +} + +/* + * swing: + * Returns true if the swing hits + */ +int +swing(int at_lvl, int op_arm, int wplus) +{ + int res = rnd(20); + int need = (20 - at_lvl) - op_arm; + + return (res + wplus >= need); +} + +/* + * roll_em: + * Roll several attacks + */ +bool +roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl) +{ + register struct stats *att, *def; + register char *cp; + register int ndice, nsides, def_arm; + register bool did_hit = FALSE; + register int hplus; + register int dplus; + register int damage; + + att = &thatt->t_stats; + def = &thdef->t_stats; + if (weap == NULL) + { + cp = att->s_dmg; + dplus = 0; + hplus = 0; + } + else + { + hplus = (weap == NULL ? 0 : weap->o_hplus); + dplus = (weap == NULL ? 0 : weap->o_dplus); + if (weap == cur_weapon) + { + if (ISRING(LEFT, R_ADDDAM)) + dplus += cur_ring[LEFT]->o_arm; + else if (ISRING(LEFT, R_ADDHIT)) + hplus += cur_ring[LEFT]->o_arm; + if (ISRING(RIGHT, R_ADDDAM)) + dplus += cur_ring[RIGHT]->o_arm; + else if (ISRING(RIGHT, R_ADDHIT)) + hplus += cur_ring[RIGHT]->o_arm; + } + cp = weap->o_damage; + if (hurl) + { + if ((weap->o_flags&ISMISL) && cur_weapon != NULL && + cur_weapon->o_which == weap->o_launch) + { + cp = weap->o_hurldmg; + hplus += cur_weapon->o_hplus; + dplus += cur_weapon->o_dplus; + } + else if (weap->o_launch < 0) + cp = weap->o_hurldmg; + } + } + /* + * If the creature being attacked is not running (alseep or held) + * then the attacker gets a plus four bonus to hit. + */ + if (!on(*thdef, ISRUN)) + hplus += 4; + def_arm = def->s_arm; + if (def == &pstats) + { + if (cur_armor != NULL) + def_arm = cur_armor->o_arm; + if (ISRING(LEFT, R_PROTECT)) + def_arm -= cur_ring[LEFT]->o_arm; + if (ISRING(RIGHT, R_PROTECT)) + def_arm -= cur_ring[RIGHT]->o_arm; + } + while(cp != NULL && *cp != '\0') + { + ndice = atoi(cp); + if ((cp = strchr(cp, 'x')) == NULL) + break; + nsides = atoi(++cp); + if (swing(att->s_lvl, def_arm, hplus + str_plus[att->s_str])) + { + int proll; + + proll = roll(ndice, nsides); +#ifdef MASTER + if (ndice + nsides > 0 && proll <= 0) + debug("Damage for %dx%d came out %d, dplus = %d, add_dam = %d, def_arm = %d", ndice, nsides, proll, dplus, add_dam[att->s_str], def_arm); +#endif + damage = dplus + proll + add_dam[att->s_str]; + def->s_hpt -= max(0, damage); + did_hit = TRUE; + } + if ((cp = strchr(cp, '/')) == NULL) + break; + cp++; + } + return did_hit; +} + +/* + * prname: + * The print name of a combatant + */ +char * +prname(char *mname, bool upper) +{ + static char tbuf[MAXSTR]; + + *tbuf = '\0'; + if (mname == 0) + strcpy(tbuf, "you"); + else + strcpy(tbuf, mname); + if (upper) + *tbuf = (char) toupper(*tbuf); + return tbuf; +} + +/* + * thunk: + * A missile hits a monster + */ +void +thunk(struct rogue_state *rs,THING *weap, char *mname, bool noend) +{ + if (to_death) + return; + if (weap->o_type == WEAPON) + addmsg(rs,"the %s hits ", weap_info[weap->o_which].oi_name); + else + addmsg(rs,"you hit "); + addmsg(rs,"%s", mname); + if (!noend) + endmsg(rs); +} + +/* + * hit: + * Print a message to indicate a succesful hit + */ + +void +hit(struct rogue_state *rs,char *er, char *ee, bool noend) +{ + int i; + char *s; + extern char *h_names[]; + + if (to_death) + return; + addmsg(rs,prname(er, TRUE)); + if (terse) + s = " hit"; + else + { + i = rnd(4); + if (er != NULL) + i += 4; + s = h_names[i]; + } + addmsg(rs,s); + if (!terse) + addmsg(rs,prname(ee, FALSE)); + if (!noend) + endmsg(rs); +} + +/* + * miss: + * Print a message to indicate a poor swing + */ +void +miss(struct rogue_state *rs,char *er, char *ee, bool noend) +{ + int i; + extern char *m_names[]; + + if (to_death) + return; + addmsg(rs,prname(er, TRUE)); + if (terse) + i = 0; + else + i = rnd(4); + if (er != NULL) + i += 4; + addmsg(rs,m_names[i]); + if (!terse) + addmsg(rs," %s", prname(ee, FALSE)); + if (!noend) + endmsg(rs); +} + +/* + * bounce: + * A missile misses a monster + */ +void +bounce(struct rogue_state *rs,THING *weap, char *mname, bool noend) +{ + if (to_death) + return; + if (weap->o_type == WEAPON) + addmsg(rs,"the %s misses ", weap_info[weap->o_which].oi_name); + else + addmsg(rs,"you missed "); + addmsg(rs,mname); + if (!noend) + endmsg(rs); +} + +/* + * remove_mon: + * Remove a monster from the screen + */ +void +remove_mon(struct rogue_state *rs,coord *mp, THING *tp, bool waskill) +{ + register THING *obj, *nexti; + + for (obj = tp->t_pack; obj != NULL; obj = nexti) + { + nexti = next(obj); + obj->o_pos = tp->t_pos; + detach(tp->t_pack, obj); + if (waskill) + fall(rs,obj, FALSE); + else + discard(obj); + } + moat(mp->y, mp->x) = NULL; + mvaddch(mp->y, mp->x, tp->t_oldch); + detach(mlist, tp); + if (on(*tp, ISTARGET)) + { + kamikaze = FALSE; + to_death = FALSE; + if (fight_flush) + flush_type(); + } + discard(tp); +} + +/* + * killed: + * Called to put a monster to death + */ +void +killed(struct rogue_state *rs,THING *tp, bool pr) +{ + char *mname; + + pstats.s_exp += tp->t_stats.s_exp; + + /* + * If the monster was a venus flytrap, un-hold him + */ + switch (tp->t_type) + { + case 'F': + player.t_flags &= ~ISHELD; + vf_hit = 0; + strcpy(monsters['F'-'A'].m_stats.s_dmg, "000x0"); + when 'L': + { + THING *gold; + + if (fallpos(&tp->t_pos, &tp->t_room->r_gold) && level >= max_level) + { + gold = new_item(); + gold->o_type = GOLD; + gold->o_goldval = GOLDCALC; + if (save(VS_MAGIC)) + gold->o_goldval += GOLDCALC + GOLDCALC + + GOLDCALC + GOLDCALC; + attach(tp->t_pack, gold); + } + } + } + /* + * Get rid of the monster. + */ + mname = set_mname(tp); + remove_mon(rs,&tp->t_pos, tp, TRUE); + if (pr) + { + if (has_hit) + { + addmsg(rs,". Defeated "); + has_hit = FALSE; + } + else + { + if (!terse) + addmsg(rs,"you have "); + addmsg(rs,"defeated "); + } + msg(rs,mname); + } + /* + * Do adjustments if he went up a level + */ + check_level(rs); + if (fight_flush) + flush_type(); +} diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c new file mode 100644 index 000000000..51a9d2d51 --- /dev/null +++ b/src/cc/rogue/init.c @@ -0,0 +1,447 @@ +/* + * global variable initializaton + * + * @(#)init.c 4.31 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include "rogue.h" + +/* + * init_player: + * Roll her up + */ +void +init_player(struct rogue_state *rs) +{ + register THING *obj; + + pstats = max_stats; + food_left = HUNGERTIME; + /* + * Give him some food + */ + obj = new_item(); + obj->o_type = FOOD; + obj->o_count = 1; + add_pack(rs,obj, TRUE); + /* + * And his suit of armor + */ + obj = new_item(); + obj->o_type = ARMOR; + obj->o_which = RING_MAIL; + obj->o_arm = a_class[RING_MAIL] - 1; + obj->o_flags |= ISKNOW; + obj->o_count = 1; + cur_armor = obj; + add_pack(rs,obj, TRUE); + /* + * Give him his weaponry. First a mace. + */ + obj = new_item(); + init_weapon(obj, MACE); + obj->o_hplus = 1; + obj->o_dplus = 1; + obj->o_flags |= ISKNOW; + add_pack(rs,obj, TRUE); + cur_weapon = obj; + /* + * Now a +1 bow + */ + obj = new_item(); + init_weapon(obj, BOW); + obj->o_hplus = 1; + obj->o_flags |= ISKNOW; + add_pack(rs,obj, TRUE); + /* + * Now some arrows + */ + obj = new_item(); + init_weapon(obj, ARROW); + obj->o_count = rnd(15) + 25; + obj->o_flags |= ISKNOW; + add_pack(rs,obj, TRUE); +} + +/* + * Contains defintions and functions for dealing with things like + * potions and scrolls + */ + +char *rainbow[] = { + "amber", + "aquamarine", + "black", + "blue", + "brown", + "clear", + "crimson", + "cyan", + "ecru", + "gold", + "green", + "grey", + "magenta", + "orange", + "pink", + "plaid", + "purple", + "red", + "silver", + "tan", + "tangerine", + "topaz", + "turquoise", + "vermilion", + "violet", + "white", + "yellow", +}; + +#define NCOLORS (sizeof rainbow / sizeof (char *)) +int cNCOLORS = NCOLORS; + +static char *sylls[] = { + "a", "ab", "ag", "aks", "ala", "an", "app", "arg", "arze", "ash", + "bek", "bie", "bit", "bjor", "blu", "bot", "bu", "byt", "comp", + "con", "cos", "cre", "dalf", "dan", "den", "do", "e", "eep", "el", + "eng", "er", "ere", "erk", "esh", "evs", "fa", "fid", "fri", "fu", + "gan", "gar", "glen", "gop", "gre", "ha", "hyd", "i", "ing", "ip", + "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech", + "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur", "nej", + "nelg", "nep", "ner", "nes", "nes", "nih", "nin", "o", "od", "ood", + "org", "orn", "ox", "oxy", "pay", "ple", "plu", "po", "pot", + "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol", "sa", + "san", "sat", "sef", "seh", "shu", "ski", "sna", "sne", "snik", + "sno", "so", "sol", "sri", "sta", "sun", "ta", "tab", "tem", + "ther", "ti", "tox", "trol", "tue", "turs", "u", "ulk", "um", "un", + "uni", "ur", "val", "viv", "vly", "vom", "wah", "wed", "werg", + "wex", "whon", "wun", "xo", "y", "yot", "yu", "zant", "zeb", "zim", + "zok", "zon", "zum", +}; + +STONE stones[] = { + { "agate", 25}, + { "alexandrite", 40}, + { "amethyst", 50}, + { "carnelian", 40}, + { "diamond", 300}, + { "emerald", 300}, + { "germanium", 225}, + { "granite", 5}, + { "garnet", 50}, + { "jade", 150}, + { "kryptonite", 300}, + { "lapis lazuli", 50}, + { "moonstone", 50}, + { "obsidian", 15}, + { "onyx", 60}, + { "opal", 200}, + { "pearl", 220}, + { "peridot", 63}, + { "ruby", 350}, + { "sapphire", 285}, + { "stibotantalite", 200}, + { "tiger eye", 50}, + { "topaz", 60}, + { "turquoise", 70}, + { "taaffeite", 300}, + { "zircon", 80}, +}; + +#define NSTONES (sizeof stones / sizeof (STONE)) +int cNSTONES = NSTONES; + +char *wood[] = { + "avocado wood", + "balsa", + "bamboo", + "banyan", + "birch", + "cedar", + "cherry", + "cinnibar", + "cypress", + "dogwood", + "driftwood", + "ebony", + "elm", + "eucalyptus", + "fall", + "hemlock", + "holly", + "ironwood", + "kukui wood", + "mahogany", + "manzanita", + "maple", + "oaken", + "persimmon wood", + "pecan", + "pine", + "poplar", + "redwood", + "rosewood", + "spruce", + "teak", + "walnut", + "zebrawood", +}; + +#define NWOOD (sizeof wood / sizeof (char *)) +int cNWOOD = NWOOD; + +char *metal[] = { + "aluminum", + "beryllium", + "bone", + "brass", + "bronze", + "copper", + "electrum", + "gold", + "iron", + "lead", + "magnesium", + "mercury", + "nickel", + "pewter", + "platinum", + "steel", + "silver", + "silicon", + "tin", + "titanium", + "tungsten", + "zinc", +}; + +#define NMETAL (sizeof metal / sizeof (char *)) +int cNMETAL = NMETAL; +#define MAX3(a,b,c) (a > b ? (a > c ? a : c) : (b > c ? b : c)) + +static bool used[MAX3(NCOLORS, NSTONES, NWOOD)]; + +/* + * init_colors: + * Initialize the potion color scheme for this time + */ +void +init_colors() +{ + register int i, j; + + for (i = 0; i < NCOLORS; i++) + used[i] = FALSE; + for (i = 0; i < MAXPOTIONS; i++) + { + do + j = rnd(NCOLORS); + until (!used[j]); + used[j] = TRUE; + p_colors[i] = rainbow[j]; + } +} + +/* + * init_names: + * Generate the names of the various scrolls + */ +#define MAXNAME 40 /* Max number of characters in a name */ + +void +init_names() +{ + register int nsyl; + register char *cp, *sp; + register int i, nwords; + + for (i = 0; i < MAXSCROLLS; i++) + { + cp = prbuf; + nwords = rnd(3) + 2; + while (nwords--) + { + nsyl = rnd(3) + 1; + while (nsyl--) + { + sp = sylls[rnd((sizeof sylls) / (sizeof (char *)))]; + if (&cp[strlen(sp)] > &prbuf[MAXNAME]) + break; + while (*sp) + *cp++ = *sp++; + } + *cp++ = ' '; + } + *--cp = '\0'; + s_names[i] = (char *) malloc((unsigned) strlen(prbuf)+1); + strcpy(s_names[i], prbuf); + } +} + +/* + * init_stones: + * Initialize the ring stone setting scheme for this time + */ +void +init_stones() +{ + register int i, j; + + for (i = 0; i < NSTONES; i++) + used[i] = FALSE; + for (i = 0; i < MAXRINGS; i++) + { + do + j = rnd(NSTONES); + until (!used[j]); + used[j] = TRUE; + r_stones[i] = stones[j].st_name; + ring_info[i].oi_worth += stones[j].st_value; + } +} + +/* + * init_materials: + * Initialize the construction materials for wands and staffs + */ +void +init_materials() +{ + register int i, j; + register char *str; + static bool metused[NMETAL]; + + for (i = 0; i < NWOOD; i++) + used[i] = FALSE; + for (i = 0; i < NMETAL; i++) + metused[i] = FALSE; + for (i = 0; i < MAXSTICKS; i++) + { + for (;;) + if (rnd(2) == 0) + { + j = rnd(NMETAL); + if (!metused[j]) + { + ws_type[i] = "wand"; + str = metal[j]; + metused[j] = TRUE; + break; + } + } + else + { + j = rnd(NWOOD); + if (!used[j]) + { + ws_type[i] = "staff"; + str = wood[j]; + used[j] = TRUE; + break; + } + } + ws_made[i] = str; + } +} + +#ifdef MASTER +# define NT NUMTHINGS, "things" +# define MP MAXPOTIONS, "potions" +# define MS MAXSCROLLS, "scrolls" +# define MR MAXRINGS, "rings" +# define MWS MAXSTICKS, "sticks" +# define MW MAXWEAPONS, "weapons" +# define MA MAXARMORS, "armor" +#else +# define NT NUMTHINGS +# define MP MAXPOTIONS +# define MS MAXSCROLLS +# define MR MAXRINGS +# define MWS MAXSTICKS +# define MW MAXWEAPONS +# define MA MAXARMORS +#endif + +/* + * sumprobs: + * Sum up the probabilities for items appearing + */ +void +sumprobs(struct obj_info *info, int bound +#ifdef MASTER + , char *name +#endif +) +{ +#ifdef MASTER + struct obj_info *start = info; +#endif + struct obj_info *endp; + + endp = info + bound; + while (++info < endp) + info->oi_prob += (info - 1)->oi_prob; +#ifdef MASTER + badcheck(name, start, bound); +#endif +} + +/* + * init_probs: + * Initialize the probabilities for the various items + */ +void +init_probs() +{ + sumprobs(things, NT); + sumprobs(pot_info, MP); + sumprobs(scr_info, MS); + sumprobs(ring_info, MR); + sumprobs(ws_info, MWS); + sumprobs(weap_info, MW); + sumprobs(arm_info, MA); +} + +#ifdef MASTER +/* + * badcheck: + * Check to see if a series of probabilities sums to 100 + */ +void +badcheck(char *name, struct obj_info *info, int bound) +{ + register struct obj_info *end; + + if (info[bound - 1].oi_prob == 100) + return; + printf("\nBad percentages for %s (bound = %d):\n", name, bound); + for (end = &info[bound]; info < end; info++) + printf("%3d%% %s\n", info->oi_prob, info->oi_name); + printf("[hit RETURN to continue]"); + fflush(stdout); + while (getchar() != '\n') + continue; +} +#endif + +/* + * pick_color: + * If he is halucinating, pick a random color name and return it, + * otherwise return the given color. + */ +char * +pick_color(char *col) +{ + return (on(player, ISHALU) ? rainbow[rnd(NCOLORS)] : col); +} diff --git a/src/cc/rogue/install-sh b/src/cc/rogue/install-sh new file mode 100755 index 000000000..4d4a9519e --- /dev/null +++ b/src/cc/rogue/install-sh @@ -0,0 +1,323 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2005-05-14.22 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= +dstarg= +no_target_directory= + +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -c) shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit $?;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t) dstarg=$2 + shift + shift + continue;; + + -T) no_target_directory=true + shift + continue;; + + --version) echo "$0 $scriptversion"; exit $?;; + + *) # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + test -n "$dir_arg$dstarg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + mkdircmd=: + chmodcmd= + else + mkdircmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dstarg: Is a directory" >&2 + exit 1 + fi + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + shift + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test -d "$pathcomp" || exit + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $mkdircmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Copy the file name to the temp name. + $doit $cpprog "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit 1 + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit 1; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit 0 +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c new file mode 100644 index 000000000..0e9347a70 --- /dev/null +++ b/src/cc/rogue/io.c @@ -0,0 +1,327 @@ +/* + * Various input/output functions + * + * @(#)io.c 4.32 (Berkeley) 02/05/99 + */ + +#include +#include +#include +#include +#include "rogue.h" + +/* + * msg: + * Display a message at the top of the screen. + */ +#define MAXMSG (NUMCOLS - sizeof "--More--") + +static char msgbuf[2*MAXMSG+1]; +static int newpos = 0; + +/* VARARGS1 */ +int +msg(struct rogue_state *rs,char *fmt, ...) +{ + va_list args; + + /* + * if the string is "", just clear the line + */ + if (*fmt == '\0') + { + move(0, 0); + clrtoeol(); + mpos = 0; + return ~ESCAPE; + } + /* + * otherwise add to the message and flush it out + */ + va_start(args, fmt); + doadd(rs,fmt, args); + va_end(args); + return endmsg(rs); +} + +/* + * addmsg: + * Add things to the current message + */ +/* VARARGS1 */ +void +addmsg(struct rogue_state *rs,char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + doadd(rs,fmt, args); + va_end(args); +} + +/* + * endmsg: + * Display a new msg (giving him a chance to see the previous one + * if it is up there with the --More--) + */ +int +endmsg(struct rogue_state *rs) +{ + char ch; + + if (save_msg) + strcpy(huh, msgbuf); + if (mpos) + { + look(rs,FALSE); + mvaddstr(0, mpos, "--More--"); + refresh(); + if (!msg_esc) + wait_for(rs,' '); + else + { + while ((ch = readchar(rs)) != ' ') + if (ch == ESCAPE) + { + msgbuf[0] = '\0'; + mpos = 0; + newpos = 0; + msgbuf[0] = '\0'; + return ESCAPE; + } + } + } + /* + * All messages should start with uppercase, except ones that + * start with a pack addressing character + */ + if (islower(msgbuf[0]) && !lower_msg && msgbuf[1] != ')') + msgbuf[0] = (char) toupper(msgbuf[0]); + mvaddstr(0, 0, msgbuf); + clrtoeol(); + mpos = newpos; + newpos = 0; + msgbuf[0] = '\0'; + refresh(); + return ~ESCAPE; +} + +/* + * doadd: + * Perform an add onto the message buffer + */ +void +doadd(struct rogue_state *rs,char *fmt, va_list args) +{ + static char buf[MAXSTR]; + + /* + * Do the printf into buf + */ + vsprintf(buf, fmt, args); + if (strlen(buf) + newpos >= MAXMSG) + endmsg(rs); + strcat(msgbuf, buf); + newpos = (int) strlen(msgbuf); +} + +/* + * step_ok: + * Returns true if it is ok to step on ch + */ +int +step_ok(int ch) +{ + switch (ch) + { + case ' ': + case '|': + case '-': + return FALSE; + default: + return (!isalpha(ch)); + } +} + +/* + * readchar: + * Reads and returns a character, checking for gross input errors + */ +char +readchar(struct rogue_state *rs) +{ + char ch = -1; + if ( rs != 0 && rs->guiflag == 0 ) + { + if ( rs->ind < rs->numkeys ) + { + if ( rs->ind == rs->numkeys-1 ) + rs->replaydone = (uint32_t)time(NULL); + return(rs->keystrokes[rs->ind++]); + } + fatal("replay finished but readchar called\n"); + return(' '); + } + if ( rs == 0 || rs->guiflag != 0 ) + { + ch = (char) md_readchar(); + + if (ch == 3) + { + quit(0); + return(27); + } + if ( rs != 0 && rs->guiflag != 0 ) + { + if (rs->num < sizeof(rs->buffered) ) + { + rs->buffered[rs->num++] = ch; + if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + } else fprintf(stderr,"buffer filled without flushed\n"); + } + } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); + return(ch); +} + +/*char readchar() +{ + static FILE *keystrokefp; int c; + + if ( keystrokefp == 0 ) + keystrokefp = fopen("keystrokes","rb"); + if ( keystrokefp != 0 ) + { + if ( (c= fgetc(keystrokefp)) == EOF ) + eofflag = 1; + else return(c); + } else eofflag = 1; + ch = (char) md_readchar(); + + if (ch == 3) + { + quit(0); + return(27); + } + { + static FILE *replayfp; + if ( replayfp == 0 ) + replayfp = fopen("replay","wb"); + if ( replayfp != 0 ) + fputc(ch,replayfp), fflush(replayfp); + } + return(ch); +}*/ + +/* + * status: + * Display the important stats line. Keep the cursor where it was. + */ +void +status(struct rogue_state *rs) +{ + register int oy, ox, temp; + static int hpwidth = 0; + static int s_hungry = 0; + static int s_lvl = 0; + static int s_pur = -1; + static int s_hp = 0; + static int s_arm = 0; + static str_t s_str = 0; + static int s_exp = 0; + static char *state_name[] = + { + "", "Hungry", "Weak", "Faint" + }; + + /* + * If nothing has changed since the last status, don't + * bother. + */ + temp = (cur_armor != NULL ? cur_armor->o_arm : pstats.s_arm); + if (s_hp == pstats.s_hpt && s_exp == pstats.s_exp && s_pur == purse + && s_arm == temp && s_str == pstats.s_str && s_lvl == level + && s_hungry == hungry_state + && !stat_msg + ) + return; + + s_arm = temp; + + getyx(stdscr, oy, ox); + if (s_hp != max_hp) + { + temp = max_hp; + s_hp = max_hp; + for (hpwidth = 0; temp; hpwidth++) + temp /= 10; + } + + /* + * Save current status + */ + s_lvl = level; + s_pur = purse; + s_hp = pstats.s_hpt; + s_str = pstats.s_str; + s_exp = pstats.s_exp; + s_hungry = hungry_state; + + if (stat_msg) + { + move(0, 0); + msg(rs,"Level: %d Gold: %-5d Hp: %*d(%*d) Str: %2d(%d) Arm: %-2d Exp: %d/%ld %s", + level, purse, hpwidth, pstats.s_hpt, hpwidth, max_hp, pstats.s_str, + max_stats.s_str, 10 - s_arm, pstats.s_lvl, pstats.s_exp, + state_name[hungry_state]); + } + else + { + move(STATLINE, 0); + + printw("Level: %d Gold: %-5d Hp: %*d(%*d) Str: %2d(%d) Arm: %-2d Exp: %d/%d %s", + level, purse, hpwidth, pstats.s_hpt, hpwidth, max_hp, pstats.s_str, + max_stats.s_str, 10 - s_arm, pstats.s_lvl, pstats.s_exp, + state_name[hungry_state]); + } + + clrtoeol(); + move(oy, ox); +} + +/* + * wait_for + * Sit around until the guy types the right key + */ +void +wait_for(struct rogue_state *rs,int ch) +{ + register char c; + + if (ch == '\n') + while ((c = readchar(rs)) != '\n' && c != '\r') + continue; + else + while (readchar(rs) != ch) + continue; +} + +/* + * show_win: + * Function used to display a window and wait before returning + */ +void +show_win(struct rogue_state *rs,char *message) +{ + WINDOW *win; + + win = hw; + wmove(win, 0, 0); + waddstr(win, message); + touchwin(win); + wmove(win, hero.y, hero.x); + wrefresh(win); + wait_for(rs,' '); + clearok(curscr, TRUE); + touchwin(stdscr); +} diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c new file mode 100644 index 000000000..6c069d06e --- /dev/null +++ b/src/cc/rogue/list.c @@ -0,0 +1,113 @@ +/* + * Functions for dealing with linked lists of goodies + * + * @(#)list.c 4.12 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +#ifdef MASTER +int total = 0; /* total dynamic memory bytes */ +#endif + +/* + * detach: + * takes an item out of whatever linked list it might be in + */ + +void +_detach(THING **list, THING *item) +{ + if (*list == item) + *list = next(item); + if (prev(item) != NULL) + item->l_prev->l_next = next(item); + if (next(item) != NULL) + item->l_next->l_prev = prev(item); + item->l_next = NULL; + item->l_prev = NULL; +} + +/* + * _attach: + * add an item to the head of a list + */ + +void +_attach(THING **list, THING *item) +{ + if (*list != NULL) + { + item->l_next = *list; + (*list)->l_prev = item; + item->l_prev = NULL; + } + else + { + item->l_next = NULL; + item->l_prev = NULL; + } + *list = item; +} + +/* + * _free_list: + * Throw the whole blamed thing away + */ + +void +_free_list(THING **ptr) +{ + THING *item; + + while (*ptr != NULL) + { + item = *ptr; + *ptr = next(item); + discard(item); + } +} + +/* + * discard: + * Free up an item + */ + +void +discard(THING *item) +{ +#ifdef MASTER + total--; +#endif + free((char *) item); +} + +/* + * new_item + * Get a new item with a specified size + */ +THING * +new_item(void) +{ + THING *item; + +#ifdef MASTER + if ((item = calloc(1, sizeof *item)) == NULL) + msg(rs,"ran out of memory after %d items", total); + else + total++; +#else + item = calloc(1, sizeof *item); +#endif + item->l_next = NULL; + item->l_prev = NULL; + return item; +} diff --git a/src/cc/rogue/mach_dep.c b/src/cc/rogue/mach_dep.c new file mode 100644 index 000000000..7f1af9c67 --- /dev/null +++ b/src/cc/rogue/mach_dep.c @@ -0,0 +1,457 @@ +/* + * Various installation dependent routines + * + * @(#)mach_dep.c 4.37 (Berkeley) 05/23/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +/* + * The various tuneable defines are: + * + * SCOREFILE Where/if the score file should live. + * ALLSCORES Score file is top ten scores, not top ten + * players. This is only useful when only a few + * people will be playing; otherwise the score file + * gets hogged by just a few people. + * NUMSCORES Number of scores in the score file (default 10). + * NUMNAME String version of NUMSCORES (first character + * should be capitalized) (default "Ten"). + * MAXLOAD What (if any) the maximum load average should be + * when people are playing. Since it is divided + * by 10, to specify a load limit of 4.0, MAXLOAD + * should be "40". If defined, then + * LOADAV Should it use it's own routine to get + * the load average? + * NAMELIST If so, where does the system namelist + * hide? + * MAXUSERS What (if any) the maximum user count should be + * when people are playing. If defined, then + * UCOUNT Should it use it's own routine to count + * users? + * UTMP If so, where does the user list hide? + * CHECKTIME How often/if it should check during the game + * for high load average. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "extern.h" + +#define NOOP(x) (x += 0) + +# ifndef NUMSCORES +# define NUMSCORES 10 +# define NUMNAME "Ten" +# endif + +unsigned int numscores = NUMSCORES; +char *Numname = NUMNAME; + +# ifdef ALLSCORES +bool allscore = TRUE; +# else /* ALLSCORES */ +bool allscore = FALSE; +# endif /* ALLSCORES */ + +#ifdef CHECKTIME +static int num_checks; /* times we've gone over in checkout() */ +#endif /* CHECKTIME */ + +/* + * init_check: + * Check out too see if it is proper to play the game now + */ + +void +init_check() +{ +#if defined(MAXLOAD) || defined(MAXUSERS) + if (too_much()) + { + printf("Sorry, %s, but the system is too loaded now.\n", whoami); + printf("Try again later. Meanwhile, why not enjoy a%s %s?\n", + vowelstr(fruit), fruit); + if (author()) + printf("However, since you're a good guy, it's up to you\n"); + else + exit(1); + } +#endif +} + +/* + * open_score: + * Open up the score file for future use + */ + +void +open_score() +{ +#ifdef SCOREFILE + char *scorefile = SCOREFILE; + /* + * We drop setgid privileges after opening the score file, so subsequent + * open()'s will fail. Just reuse the earlier filehandle. + */ + + if (scoreboard != NULL) { + rewind(scoreboard); + return; + } + + scoreboard = fopen(scorefile, "r+"); + + if ((scoreboard == NULL) && (errno == ENOENT)) + { + scoreboard = fopen(scorefile, "w+"); + md_chmod(scorefile,0664); + } + + if (scoreboard == NULL) { + fprintf(stderr, "Could not open %s for writing: %s\n", scorefile, strerror(errno)); + fflush(stderr); + } +#else + scoreboard = NULL; +#endif +} + +/* + * setup: + * Get starting setup for all games + */ + +void +setup() +{ +#ifdef CHECKTIME + int checkout(); +#endif + +#ifdef DUMP + md_onsignal_autosave(); +#else + md_onsignal_default(); +#endif + +#ifdef CHECKTIME + md_start_checkout_timer(CHECKTIME*60); + num_checks = 0; +#endif + + raw(); /* Raw mode */ + noecho(); /* Echo off */ + keypad(stdscr,1); + getltchars(); /* get the local tty chars */ +} + +/* + * getltchars: + * Get the local tty chars for later use + */ + +void +getltchars() +{ + got_ltc = TRUE; + orig_dsusp = md_dsuspchar(); + md_setdsuspchar( md_suspchar() ); +} + +/* + * resetltchars: + * Reset the local tty chars to original values. + */ +void +resetltchars(void) +{ + if (got_ltc) { + md_setdsuspchar(orig_dsusp); + } +} + +/* + * playltchars: + * Set local tty chars to the values we use when playing. + */ +void +playltchars(void) +{ + if (got_ltc) { + md_setdsuspchar( md_suspchar() ); + } +} + +/* + * start_score: + * Start the scoring sequence + */ + +void +start_score() +{ +#ifdef CHECKTIME + md_stop_checkout_timer(); +#endif +} + +/* + * is_symlink: + * See if the file has a symbolic link + */ +bool +is_symlink(char *sp) +{ +#ifdef S_IFLNK + struct stat sbuf2; + + if (lstat(sp, &sbuf2) < 0) + return FALSE; + else + return ((sbuf2.st_mode & S_IFMT) != S_IFREG); +#else + NOOP(sp); + return FALSE; +#endif +} + +#if defined(MAXLOAD) || defined(MAXUSERS) +/* + * too_much: + * See if the system is being used too much for this game + */ +bool +too_much() +{ +#ifdef MAXLOAD + double avec[3]; +#else + int cnt; +#endif + +#ifdef MAXLOAD + md_loadav(avec); + if (avec[1] > (MAXLOAD / 10.0)) + return TRUE; +#endif +#ifdef MAXUSERS + if (ucount() > MAXUSERS) + return TRUE; +#endif + return FALSE; +} + +/* + * author: + * See if a user is an author of the program + */ +bool +author() +{ +#ifdef MASTER + if (wizard) + return TRUE; +#endif + switch (md_getuid()) + { + case -1: + return TRUE; + default: + return FALSE; + } +} +#endif + +#ifdef CHECKTIME +/* + * checkout: + * Check each CHECKTIME seconds to see if the load is too high + */ + +checkout(struct rogue_state *rs,int sig) +{ + static char *msgs[] = { + "The load is too high to be playing. Please leave in %0.1f minutes", + "Please save your game. You have %0.1f minutes", + "Last warning. You have %0.1f minutes to leave", + }; + int checktime; + + if (too_much()) + { + if (author()) + { + num_checks = 1; + chmsg(rs,"The load is rather high, O exaulted one"); + } + else if (num_checks++ == 3) + fatal("Sorry. You took too long. You are dead\n"); + checktime = (CHECKTIME * 60) / num_checks; + chmsg(rs,msgs[num_checks - 1], ((double) checktime / 60.0)); + } + else + { + if (num_checks) + { + num_checks = 0; + chmsg(rs,"The load has dropped back down. You have a reprieve"); + } + checktime = (CHECKTIME * 60); + } + + md_start_checkout_timer(checktime); +} + +/* + * chmsg: + * checkout()'s version of msg. If we are in the middle of a + * shell, do a printf instead of a msg to a the refresh. + */ +/* VARARGS1 */ + +chmsg(struct rogue_state *rs,char *fmt, int arg) +{ + if (!in_shell) + msg(rs,fmt, arg); + else + { + printf(fmt, arg); + putchar('\n'); + fflush(stdout); + } +} +#endif + +#ifdef UCOUNT +/* + * ucount: + * count number of users on the system + */ +#include + +struct utmp buf; + +int +ucount() +{ + struct utmp *up; + FILE *utmp; + int count; + + if ((utmp = fopen(UTMP, "r")) == NULL) + return 0; + + up = &buf; + count = 0; + + while (fread(up, 1, sizeof (*up), utmp) > 0) + if (buf.ut_name[0] != '\0') + count++; + fclose(utmp); + return count; +} +#endif + +/* + * lock_sc: + * lock the score file. If it takes too long, ask the user if + * they care to wait. Return TRUE if the lock is successful. + */ +static FILE *lfd = NULL; +bool +lock_sc() +{ +#if defined(SCOREFILE) && defined(LOCKFILE) + int cnt; + static struct stat sbuf; + char *lockfile = LOCKFILE; + +over: + if ((lfd=fopen(lockfile, "w+")) != NULL) + return TRUE; + for (cnt = 0; cnt < 5; cnt++) + { + md_sleep(1); + if ((lfd=fopen(lockfile, "w+")) != NULL) + return TRUE; + } + if (stat(lockfile, &sbuf) < 0) + { + lfd=fopen(lockfile, "w+"); + return TRUE; + } + if (time(NULL) - sbuf.st_mtime > 10) + { + if (md_unlink(lockfile) < 0) + return FALSE; + goto over; + } + else + { + printf("The score file is very busy. Do you want to wait longer\n"); + printf("for it to become free so your score can get posted?\n"); + printf("If so, type \"y\"\n"); + (void) fgets(prbuf, MAXSTR, stdin); + if (prbuf[0] == 'y') + for (;;) + { + if ((lfd=fopen(lockfile, "w+")) != 0) + return TRUE; + if (stat(lockfile, &sbuf) < 0) + { + lfd=fopen(lockfile, "w+"); + return TRUE; + } + if (time(NULL) - sbuf.st_mtime > 10) + { + if (md_unlink(lockfile) < 0) + return FALSE; + } + md_sleep(1); + } + else + return FALSE; + } +#else + return TRUE; +#endif +} + +/* + * unlock_sc: + * Unlock the score file + */ + +void +unlock_sc() +{ +#if defined(SCOREFILE) && defined(LOCKFILE) + if (lfd != NULL) + fclose(lfd); + lfd = NULL; + md_unlink(LOCKFILE); +#endif +} + +/* + * flush_type: + * Flush typeahead for traps, etc. + */ + +void +flush_type() +{ + flushinp(); +} diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c new file mode 100644 index 000000000..681d51e31 --- /dev/null +++ b/src/cc/rogue/main.c @@ -0,0 +1,49 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + + + +// creategame, register (inventory + baton + buyin), progress (events + statehash + [compr state]?), claimwin +// create game buyin, newbie flag, 10 blocks registration seed is starting blockhash! +// inheritance of items across games! +// binding tokens to specific items to allow for built in market +// pubkey token inventory creates items can be used for a specific campaign +// player wins buyins + ingame gold -> ROGUE + ingame items -> tokens via 1 vout per item to be spent into a token opreturn + +#include +#include +#include + +int32_t rogue_replay(uint64_t seed); +int rogue(int argc, char **argv, char **envp); + +int main(int argc, char **argv, char **envp) +{ + uint64_t seed; FILE *fp = 0; + if ( argc > 1 && (fp=fopen(argv[1],"rb")) == 0 ) + { + seed = atol(argv[1]); + fprintf(stderr,"replay %llu\n",(long long)seed); + return(rogue_replay(seed)); + } + else + { + if ( fp != 0 ) + fclose(fp); + return(rogue(argc,argv,envp)); + } +} + + diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c new file mode 100644 index 000000000..72fdbb75e --- /dev/null +++ b/src/cc/rogue/mdport.c @@ -0,0 +1,1432 @@ +/* + mdport.c - Machine Dependent Code for Porting Unix/Curses games + + Copyright (C) 2005 Nicholas J. Kisseberth + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name(s) of the author(s) nor the names of other contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include + +#if defined(_WIN32) +#include +#include +#include +#include +#pragma warning( disable: 4201 ) +#include +#pragma warning( default: 4201 ) +#include +#undef MOUSE_MOVED +#endif + +#include +#include "extern.h" + +#if defined(HAVE_SYS_TYPES) +#include +#endif + +#if defined(HAVE_PROCESS_H) +#include +#endif + +#if defined(HAVE_PWD_H) +#include +#endif + +#if defined(HAVE_SYS_UTSNAME) +#include +#endif + +#if defined(HAVE_ARPA_INET_H) +#include /* Solaris 2.8 required this for htonl() and ntohl() */ +#endif + +#if defined(HAVE_TERMIOS_H) +#include +#endif + +#if defined(HAVE_UNISTD_H) +#ifndef __USE_GNU +#define __USE_GNU +#include +#undef __USE_GNU +#else +#include +#endif +#endif + +#include /* AIX requires curses.h be included before term.h */ + +#if defined(HAVE_TERM_H) +#include +#elif defined(HAVE_NCURSES_TERM_H) +#include +#endif + +#if defined(HAVE_WORKING_FORK) +#include +#endif + +#include +#include +#include +#include +#include +#include "extern.h" + +#if !defined(PATH_MAX) && defined(_MAX_PATH) +#define PATH_MAX _MAX_PATH +#endif + +#if !defined(PATH_MAX) && defined(_PATH_MAX) +#define PATH_MAX _PATH_MAX +#endif + +#define NOOP(x) (x += 0) + +void +md_init() +{ +#if defined(__INTERIX) + char *term; + + term = getenv("TERM"); + + if (term == NULL) + setenv("TERM","interix"); +#elif defined(__DJGPP__) + _fmode = _O_BINARY; +#elif defined(_WIN32) + _fmode = _O_BINARY; +#endif + +#if defined(HAVE_ESCDELAY) || defined(NCURSES_VERSION) + ESCDELAY=64; +#endif + +#if defined(DUMP) + md_onsignal_default(); +#else + md_onsignal_exit(); +#endif +} + +void +md_onsignal_default() +{ +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif +#ifdef SIGQUIT + signal(SIGQUIT, SIG_DFL); +#endif +#ifdef SIGILL + signal(SIGILL, SIG_DFL); +#endif +#ifdef SIGTRAP + signal(SIGTRAP, SIG_DFL); +#endif +#ifdef SIGIOT + signal(SIGIOT, SIG_DFL); +#endif +#ifdef SIGEMT + signal(SIGEMT, SIG_DFL); +#endif +#ifdef SIGFPE + signal(SIGFPE, SIG_DFL); +#endif +#ifdef SIGBUS + signal(SIGBUS, SIG_DFL); +#endif +#ifdef SIGSEGV + signal(SIGSEGV, SIG_DFL); +#endif +#ifdef SIGSYS + signal(SIGSYS, SIG_DFL); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_DFL); +#endif +} + +void +md_onsignal_exit() +{ +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif +#ifdef SIGQUIT + signal(SIGQUIT, exit); +#endif +#ifdef SIGILL + signal(SIGILL, exit); +#endif +#ifdef SIGTRAP + signal(SIGTRAP, exit); +#endif +#ifdef SIGIOT + signal(SIGIOT, exit); +#endif +#ifdef SIGEMT + signal(SIGEMT, exit); +#endif +#ifdef SIGFPE + signal(SIGFPE, exit); +#endif +#ifdef SIGBUS + signal(SIGBUS, exit); +#endif +#ifdef SIGSEGV + signal(SIGSEGV, exit); +#endif +#ifdef SIGSYS + signal(SIGSYS, exit); +#endif +#ifdef SIGTERM + signal(SIGTERM, exit); +#endif +} + +void +md_onsignal_autosave() +{ +#ifdef SIGHUP + signal(SIGHUP, auto_save); +#endif +#ifdef SIGQUIT + signal(SIGQUIT, endit); +#endif +#ifdef SIGILL + signal(SIGILL, auto_save); +#endif +#ifdef SIGTRAP + signal(SIGTRAP, auto_save); +#endif +#ifdef SIGIOT + signal(SIGIOT, auto_save); +#endif +#ifdef SIGEMT + signal(SIGEMT, auto_save); +#endif +#ifdef SIGFPE + signal(SIGFPE, auto_save); +#endif +#ifdef SIGBUS + signal(SIGBUS, auto_save); +#endif +#ifdef SIGSEGV + signal(SIGSEGV, auto_save); +#endif +#ifdef SIGSYS + signal(SIGSYS, auto_save); +#endif +#ifdef SIGTERM + signal(SIGTERM, auto_save); +#endif +#ifdef SIGINT + signal(SIGINT, quit); +#endif +} + +int +md_hasclreol() +{ +#if defined(clr_eol) +#ifdef NCURSES_VERSION + if (cur_term == NULL) + return(0); + if (cur_term->type.Strings == NULL) + return(0); +#endif + return((clr_eol != NULL) && (*clr_eol != 0)); +#elif defined(__PDCURSES__) + return(TRUE); +#else + return((CE != NULL) && (*CE != 0)); +#endif +} + +void +md_putchar(int c) +{ + putchar(c); +} + +#ifdef _WIN32 +static int md_standout_mode = 0; +#endif + +void +md_raw_standout() +{ +#ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + HANDLE hStdout; + WORD fgattr,bgattr; + + if (md_standout_mode == 0) + { + hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + GetConsoleScreenBufferInfo(hStdout, &csbiInfo); + fgattr = (csbiInfo.wAttributes & 0xF); + bgattr = (csbiInfo.wAttributes & 0xF0); + SetConsoleTextAttribute(hStdout,(fgattr << 4) | (bgattr >> 4)); + md_standout_mode = 1; + } +#elif defined(SO) + tputs(SO,0,md_putchar); + fflush(stdout); +#endif +} + +void +md_raw_standend() +{ +#ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + HANDLE hStdout; + WORD fgattr,bgattr; + + if (md_standout_mode == 1) + { + hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + GetConsoleScreenBufferInfo(hStdout, &csbiInfo); + fgattr = (csbiInfo.wAttributes & 0xF); + bgattr = (csbiInfo.wAttributes & 0xF0); + SetConsoleTextAttribute(hStdout,(fgattr << 4) | (bgattr >> 4)); + md_standout_mode = 0; + } +#elif defined(SE) + tputs(SE,0,md_putchar); + fflush(stdout); +#endif +} + +int +md_unlink_open_file(char *file, FILE *inf) +{ +#ifdef _WIN32 + fclose(inf); + _chmod(file, 0600); + return( _unlink(file) ); +#else + return(unlink(file)); +#endif +} + +int +md_unlink(char *file) +{ +#ifdef _WIN32 + _chmod(file, 0600); + return( _unlink(file) ); +#else + return(unlink(file)); +#endif +} + +int +md_chmod(char *filename, int mode) +{ +#ifdef _WIN32 + return( _chmod(filename, mode) ); +#else + return( chmod(filename, mode) ); +#endif +} + +void +md_normaluser() +{ +#if defined(HAVE_GETGID) && defined(HAVE_GETUID) + gid_t realgid = getgid(); + uid_t realuid = getuid(); + +#if defined(HAVE_SETRESGID) + if (setresgid(-1, realgid, realgid) != 0) { +#elif defined (HAVE_SETREGID) + if (setregid(realgid, realgid) != 0) { +#elif defined (HAVE_SETGID) + if (setgid(realgid) != 0) { +#else + if (0) { +#endif + perror("Could not drop setgid privileges. Aborting."); + exit(1); + } + +#if defined(HAVE_SETRESUID) + if (setresuid(-1, realuid, realuid) != 0) { +#elif defined(HAVE_SETREUID) + if (setreuid(realuid, realuid) != 0) { +#elif defined(HAVE_SETUID) + if (setuid(realuid) != 0) { +#else + if (0) { +#endif + perror("Could not drop setuid privileges. Aborting."); + exit(1); + } +#endif +} + +int +md_getuid() +{ +#ifdef HAVE_GETUID + return( getuid() ); +#else + return(42); +#endif +} + +int +md_getpid() +{ +#ifdef _WIN32 + return( _getpid() ); +#else + return( getpid() ); +#endif +} + +char * +md_getusername() +{ + static char login[80]; + char *l = NULL; +#ifdef _WIN32 + LPSTR mybuffer; + DWORD size = UNLEN + 1; + TCHAR buffer[UNLEN + 1]; + + mybuffer = buffer; + GetUserName(mybuffer,&size); + l = mybuffer; +#elif defined(HAVE_GETPWUID)&& !defined(__DJGPP__) + struct passwd *pw; + + pw = getpwuid(getuid()); + + l = pw->pw_name; +#endif + + if ((l == NULL) || (*l == '\0')) + if ( (l = getenv("USERNAME")) == NULL ) + if ( (l = getenv("LOGNAME")) == NULL ) + if ( (l = getenv("USER")) == NULL ) + l = "nobody"; + + strncpy(login,l,80); + login[79] = 0; + + return(login); +} + +char * +md_gethomedir() +{ + static char homedir[PATH_MAX]; + char *h = NULL; + size_t len; +#if defined(_WIN32) + TCHAR szPath[PATH_MAX]; +#endif +#if defined(_WIN32) || defined(DJGPP) + char slash = '\\'; +#else + char slash = '/'; + struct passwd *pw; + pw = getpwuid(getuid()); + + h = pw->pw_dir; + + if (strcmp(h,"/") == 0) + h = NULL; +#endif + homedir[0] = 0; +#ifdef _WIN32 + if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, szPath))) + h = szPath; +#endif + + if ( (h == NULL) || (*h == '\0') ) + { + if ( (h = getenv("HOME")) == NULL ) + { + if ( (h = getenv("HOMEDRIVE")) == NULL) + h = ""; + else + { + strncpy(homedir,h,PATH_MAX-1); + homedir[PATH_MAX-1] = 0; + + if ( (h = getenv("HOMEPATH")) == NULL) + h = ""; + } + } + } + + + len = strlen(homedir); + strncat(homedir,h,PATH_MAX-len-1); + len = strlen(homedir); + + if ((len > 0) && (homedir[len-1] != slash)) { + homedir[len] = slash; + homedir[len+1] = 0; + } + + return(homedir); +} + +void +md_sleep(int s) +{ +#ifdef _WIN32 + Sleep(s); +#else + sleep(s); +#endif +} + +char * +md_getshell() +{ + static char shell[PATH_MAX]; + char *s = NULL; +#ifdef _WIN32 + char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE"; +#elif defined(__DJGPP__) + char *def = "C:\\COMMAND.COM"; +#else + char *def = "/bin/sh"; + struct passwd *pw; + pw = getpwuid(getuid()); + s = pw->pw_shell; +#endif + if ((s == NULL) || (*s == '\0')) + if ( (s = getenv("COMSPEC")) == NULL) + if ( (s = getenv("SHELL")) == NULL) + if ( (s = getenv("SystemRoot")) == NULL) + s = def; + + strncpy(shell,s,PATH_MAX); + shell[PATH_MAX-1] = 0; + + return(shell); +} + +int +md_shellescape() +{ +#if defined(HAVE_WORKING_FORK) + int ret_status; + int pid; + void (*myquit)(int); + void (*myend)(int); + char *sh; + + sh = md_getshell(); + + while((pid = fork()) < 0) + sleep(1); + + if (pid == 0) /* Shell Process */ + { + /* + * Set back to original user, just in case + */ + md_normaluser(); + execl(sh == NULL ? "/bin/sh" : sh, "shell", "-i", NULL); + perror("No shelly"); + _exit(-1); + } + else /* Application */ + { + myend = signal(SIGINT, SIG_IGN); +#ifdef SIGQUIT + myquit = signal(SIGQUIT, SIG_IGN); +#endif + while (wait(&ret_status) != pid) + continue; + + signal(SIGINT, myquit); +#ifdef SIGQUIT + signal(SIGQUIT, myend); +#endif + } + return(ret_status); +#elif defined(HAVE__SPAWNL) + return((int)_spawnl(_P_WAIT,md_getshell(),"shell",NULL,0)); +#elif defined(HAVE_SPAWNL) + return ( spawnl(P_WAIT,md_getshell(),"shell",NULL,0) ); +#else + return(0); +#endif +} + +int +directory_exists(char *dirname) +{ + struct stat sb; + + if (stat(dirname, &sb) == 0) /* path exists */ + return (sb.st_mode & S_IFDIR); + + return(0); +} + +char * +md_getrealname(int uid) +{ + static char uidstr[20]; +#if !defined(_WIN32) && !defined(DJGPP) + struct passwd *pp; + + if ((pp = getpwuid(uid)) == NULL) + { + sprintf(uidstr,"%d", uid); + return(uidstr); + } + else + return(pp->pw_name); +#else + sprintf(uidstr,"%d", uid); + return(uidstr); +#endif +} + +extern char *xcrypt(char *key, char *salt); + +char * +md_crypt(char *key, char *salt) +{ + return( xcrypt(key,salt) ); +} + +char * +md_getpass(char *prompt) +{ +#ifndef HAVE_GETPASS + static char password_buffer[9]; + char *p = password_buffer; + int c, count = 0; + int max_length = 9; + + fflush(stdout); + /* If we can't prompt, abort */ + if (fputs(prompt, stderr) < 0) + { + *p = '\0'; + return NULL; + } + + for(;;) + { + /* Get a character with no echo */ + c = _getch(); + + /* Exit on interrupt (^c or ^break) */ + if (c == '\003' || c == 0x100) + exit(1); + + /* Terminate on end of line or file (^j, ^m, ^d, ^z) */ + if (c == '\r' || c == '\n' || c == '\004' || c == '\032') + break; + + /* Back up on backspace */ + if (c == '\b') + { + if (count) + count--; + else if (p > password_buffer) + p--; + continue; + } + + /* Ignore DOS extended characters */ + if ((c & 0xff) != c) + continue; + + /* Add to password if it isn't full */ + if (p < password_buffer + max_length - 1) + *p++ = (char) c; + else + count++; + } + *p = '\0'; + + fputc('\n', stderr); + + return password_buffer; +#else + return( (char *) getpass(prompt) ); +#endif +} + +int +md_erasechar() +{ +#ifdef HAVE_ERASECHAR + return( erasechar() ); /* process erase character */ +#elif defined(VERASE) + return(_tty.c_cc[VERASE]); /* process erase character */ +#else + return(_tty.sg_erase); /* process erase character */ +#endif +} + +int +md_killchar() +{ +#ifdef HAVE_KILLCHAR + return( killchar() ); +#elif defined(VKILL) + return(_tty.c_cc[VKILL]); +#else + return(_tty.sg_kill); +#endif +} + +int +md_dsuspchar() +{ +#if defined(VDSUSP) /* POSIX has priority */ + struct termios attr; + tcgetattr(STDIN_FILENO, &attr); + return( attr.c_cc[VDSUSP] ); +#elif defined(TIOCGLTC) + struct ltchars ltc; + ioctl(1, TIOCGLTC, <c); + return(ltc.t_dsuspc); +#elif defined(_POSIX_VDISABLE) + return(_POSIX_VDISABLE); +#else + return(0); +#endif +} + +int +md_setdsuspchar(int c) +{ +#if defined(VDSUSP) /* POSIX has priority */ + struct termios attr; + tcgetattr(STDIN_FILENO, &attr); + attr.c_cc[VDSUSP] = c; + tcgetattr(STDIN_FILENO, &attr); +#elif defined(TIOCSLTC) + struct ltchars ltc; + ioctl(1, TIOCGLTC, <c); + ltc.t_dsuspc = c; + ioctl(1, TIOCSLTC, <c); +#else + NOOP(c); +#endif + return(0); +} + +int +md_suspchar() +{ +#if defined(VSUSP) /* POSIX has priority */ + struct termios attr; + tcgetattr(STDIN_FILENO, &attr); + return( attr.c_cc[VSUSP] ); +#elif defined(TIOCGLTC) + struct ltchars ltc; + ioctl(1, TIOCGLTC, <c); + return(ltc.t_suspc); +#elif defined(_POSIX_VDISABLE) + return(_POSIX_VDISABLE); +#else + return(0); +#endif +} + +int +md_setsuspchar(int c) +{ +#if defined(VSUSP) /* POSIX has priority */ + struct termios attr; + tcgetattr(STDIN_FILENO, &attr); + attr.c_cc[VSUSP] = c; + tcgetattr(STDIN_FILENO, &attr); +#elif defined(TIOCSLTC) + struct ltchars ltc; + ioctl(1, TIOCGLTC, <c); + ltc.t_suspc = c; + ioctl(1, TIOCSLTC, <c); +#else + NOOP(c); +#endif + + return(0); +} + +/* + Cursor/Keypad Support + + Sadly Cursor/Keypad support is less straightforward than it should be. + + The various terminal emulators/consoles choose to differentiate the + cursor and keypad keys (with modifiers) in different ways (if at all!). + Furthermore they use different code set sequences for each key only + a subset of which the various curses libraries recognize. Partly due + to incomplete termcap/terminfo entries and partly due to inherent + limitations of those terminal capability databases. + + I give curses first crack at decoding the sequences. If it fails to decode + it we check for common ESC-prefixed sequences. + + All cursor/keypad results are translated into standard rogue movement + commands. + + Unmodified keys are translated to walk commands: hjklyubn + Modified (shift,control,alt) are translated to run commands: HJKLYUBN + + Console and supported (differentiated) keys + Interix: Cursor Keys, Keypad, Ctl-Keypad + Cygwin: Cursor Keys, Keypad, Alt-Cursor Keys + MSYS: Cursor Keys, Keypad, Ctl-Cursor Keys, Ctl-Keypad + Win32: Cursor Keys, Keypad, Ctl/Shift/Alt-Cursor Keys, Ctl/Alt-Keypad + DJGPP: Cursor Keys, Keypad, Ctl/Shift/Alt-Cursor Keys, Ctl/Alt-Keypad + + Interix Console (raw, ncurses) + ============================== + normal shift ctrl alt + ESC [D, ESC F^, ESC [D, ESC [D /# Left #/ + ESC [C, ESC F$, ESC [C, ESC [C /# Right #/ + ESC [A, ESC F-, local win, ESC [A /# Up #/ + ESC [B, ESC F+, local win, ESC [B /# Down #/ + ESC [H, ESC [H, ESC [H, ESC [H /# Home #/ + ESC [S, local win, ESC [S, ESC [S /# Page Up #/ + ESC [T, local win, ESC [T, ESC [T /# Page Down #/ + ESC [U, ESC [U, ESC [U, ESC [U /# End #/ + ESC [D, ESC F^, ESC [D, O /# Keypad Left #/ + ESC [C, ESC F$, ESC [C, O /# Keypad Right #/ + ESC [A, ESC [A, ESC [-1, O /# Keypad Up #/ + ESC [B, ESC [B, ESC [-2, O /# Keypad Down #/ + ESC [H, ESC [H, ESC [-263, O /# Keypad Home #/ + ESC [S, ESC [S, ESC [-19, O /# Keypad PgUp #/ + ESC [T, ESC [T, ESC [-20, O /# Keypad PgDn #/ + ESC [U, ESC [U, ESC [-21, O /# Keypad End #/ + nothing, nothing, nothing, O /# Kaypad 5 #/ + + Interix Console (term=interix, ncurses) + ============================== + KEY_LEFT, ESC F^, KEY_LEFT, KEY_LEFT /# Left #/ + KEY_RIGHT, ESC F$, KEY_RIGHT, KEY_RIGHT /# Right #/ + KEY_UP, 0x146, local win, KEY_UP /# Up #/ + KEY_DOWN, 0x145, local win, KEY_DOWN /# Down #/ + ESC [H, ESC [H, ESC [H, ESC [H /# Home #/ + KEY_PPAGE, local win, KEY_PPAGE, KEY_PPAGE /# Page Up #/ + KEY_NPAGE, local win, KEY_NPAGE, KEY_NPAGE /# Page Down #/ + KEY_LL, KEY_LL, KEY_LL, KEY_LL /# End #/ + KEY_LEFT, ESC F^, ESC [-4, O /# Keypad Left #/ + KEY_RIGHT, ESC F$, ESC [-3, O /# Keypad Right #/ + KEY_UP, KEY_UP, ESC [-1, O /# Keypad Up #/ + KEY_DOWN, KEY_DOWN, ESC [-2, O /# Keypad Down #/ + ESC [H, ESC [H, ESC [-263, O /# Keypad Home #/ + KEY_PPAGE, KEY_PPAGE, ESC [-19, O /# Keypad PgUp #/ + KEY_NPAGE, KEY_NPAGE, ESC [-20, O /# Keypad PgDn #/ + KEY_LL, KEY_LL, ESC [-21, O /# Keypad End #/ + nothing, nothing, nothing, O /# Keypad 5 #/ + + Cygwin Console (raw, ncurses) + ============================== + normal shift ctrl alt + ESC [D, ESC [D, ESC [D, ESC ESC [D /# Left #/ + ESC [C, ESC [C, ESC [C, ESC ESC [C /# Rght #/ + ESC [A, ESC [A, ESC [A, ESC ESC [A /# Up #/ + ESC [B, ESC [B, ESC [B, ESC ESC [B /# Down #/ + ESC [1~, ESC [1~, ESC [1~, ESC ESC [1~ /# Home #/ + ESC [5~, ESC [5~, ESC [5~, ESC ESC [5~ /# Page Up #/ + ESC [6~, ESC [6~, ESC [6~, ESC ESC [6~ /# Page Down #/ + ESC [4~, ESC [4~, ESC [4~, ESC ESC [4~ /# End #/ + ESC [D, ESC [D, ESC [D, ESC ESC [D,O /# Keypad Left #/ + ESC [C, ESC [C, ESC [C, ESC ESC [C,O /# Keypad Right #/ + ESC [A, ESC [A, ESC [A, ESC ESC [A,O /# Keypad Up #/ + ESC [B, ESC [B, ESC [B, ESC ESC [B,O /# Keypad Down #/ + ESC [1~, ESC [1~, ESC [1~, ESC ESC [1~,O /# Keypad Home #/ + ESC [5~, ESC [5~, ESC [5~, ESC ESC [5~,O /# Keypad PgUp #/ + ESC [6~, ESC [6~, ESC [6~, ESC ESC [6~,O /# Keypad PgDn #/ + ESC [4~, ESC [4~, ESC [4~, ESC ESC [4~,O /# Keypad End #/ + ESC [-71, nothing, nothing, O /# Keypad 5 #/ + + Cygwin Console (term=cygwin, ncurses) + ============================== + KEY_LEFT, KEY_LEFT, KEY_LEFT, ESC-260 /# Left #/ + KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, ESC-261 /# Rght #/ + KEY_UP, KEY_UP, KEY_UP, ESC-259 /# Up #/ + KEY_DOWN, KEY_DOWN, KEY_DOWN, ESC-258 /# Down #/ + KEY_HOME, KEY_HOME, KEY_HOME, ESC-262 /# Home #/ + KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, ESC-339 /# Page Up #/ + KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, ESC-338 /# Page Down #/ + KEY_END, KEY_END, KEY_END, ESC-360 /# End #/ + KEY_LEFT, KEY_LEFT, KEY_LEFT, ESC-260,O /# Keypad Left #/ + KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, ESC-261,O /# Keypad Right #/ + KEY_UP, KEY_UP, KEY_UP, ESC-259,O /# Keypad Up #/ + KEY_DOWN, KEY_DOWN, KEY_DOWN, ESC-258,O /# Keypad Down #/ + KEY_HOME, KEY_HOME, KEY_HOME, ESC-262,O /# Keypad Home #/ + KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, ESC-339,O /# Keypad PgUp #/ + KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, ESC-338,O /# Keypad PgDn #/ + KEY_END, KEY_END, KEY_END, ESC-360,O /# Keypad End #/ + ESC [G, nothing, nothing, O /# Keypad 5 #/ + + MSYS Console (raw, ncurses) + ============================== + normal shift ctrl alt + ESC OD, ESC [d, ESC Od nothing /# Left #/ + ESC OE, ESC [e, ESC Oe, nothing /# Right #/ + ESC OA, ESC [a, ESC Oa, nothing /# Up #/ + ESC OB, ESC [b, ESC Ob, nothing /# Down #/ + ESC [7~, ESC [7$, ESC [7^, nothing /# Home #/ + ESC [5~, local window, ESC [5^, nothing /# Page Up #/ + ESC [6~, local window, ESC [6^, nothing /# Page Down #/ + ESC [8~, ESC [8$, ESC [8^, nothing /# End #/ + ESC OD, ESC [d, ESC Od O /# Keypad Left #/ + ESC OE, ESC [c, ESC Oc, O /# Keypad Right #/ + ESC OA, ESC [a, ESC Oa, O /# Keypad Up #/ + ESC OB, ESC [b, ESC Ob, O /# Keypad Down #/ + ESC [7~, ESC [7$, ESC [7^, O /# Keypad Home #/ + ESC [5~, local window, ESC [5^, O /# Keypad PgUp #/ + ESC [6~, local window, ESC [6^, O /# Keypad PgDn #/ + ESC [8~, ESC [8$, ESC [8^, O /# Keypad End #/ + 11, 11, 11, O /# Keypad 5 #/ + + MSYS Console (term=rxvt, ncurses) + ============================== + normal shift ctrl alt + KEY_LEFT, KEY_SLEFT, 514 nothing /# Left #/ + KEY_RIGHT, KEY_SRIGHT, 516, nothing /# Right #/ + KEY_UP, 518, 519, nothing /# Up #/ + KEY_DOWN, 511, 512, nothing /# Down #/ + KEY_HOME, KEY_SHOME, ESC [7^, nothing /# Home #/ + KEY_PPAGE, local window, ESC [5^, nothing /# Page Up #/ + KEY_NPAGE, local window, ESC [6^, nothing /# Page Down #/ + KEY_END, KEY_SEND, KEY_EOL, nothing /# End #/ + KEY_LEFT, KEY_SLEFT, 514 O /# Keypad Left #/ + KEY_RIGHT, KEY_SRIGHT, 516, O /# Keypad Right #/ + KEY_UP, 518, 519, O /# Keypad Up #/ + KEY_DOWN, 511, 512, O /# Keypad Down #/ + KEY_HOME, KEY_SHOME, ESC [7^, O /# Keypad Home #/ + KEY_PPAGE, local window, ESC [5^, O /# Keypad PgUp #/ + KEY_NPAGE, local window, ESC [6^, O /# Keypad PgDn #/ + KEY_END, KEY_SEND, KEY_EOL, O /# Keypad End #/ + 11, 11, 11, O /# Keypad 5 #/ + + Win32 Console (raw, pdcurses) + DJGPP Console (raw, pdcurses) + ============================== + normal shift ctrl alt + 260, 391, 443, 493 /# Left #/ + 261, 400, 444, 492 /# Right #/ + 259, 547, 480, 490 /# Up #/ + 258, 548, 481, 491 /# Down #/ + 262, 388, 447, 524 /# Home #/ + 339, 396, 445, 526 /# Page Up #/ + 338, 394, 446, 520 /# Page Down #/ + 358, 384, 448, 518 /# End #/ + 452, 52('4'), 511, 521 /# Keypad Left #/ + 454, 54('6'), 513, 523 /# Keypad Right #/ + 450, 56('8'), 515, 525 /# Keypad Up #/ + 456, 50('2'), 509, 519 /# Keypad Down #/ + 449, 55('7'), 514, 524 /# Keypad Home #/ + 451, 57('9'), 516, 526 /# Keypad PgUp #/ + 457, 51('3'), 510, 520 /# Keypad PgDn #/ + 455, 49('1'), 508, 518 /# Keypad End #/ + 453, 53('5'), 512, 522 /# Keypad 5 #/ + + Win32 Console (pdcurses, MSVC/MingW32) + DJGPP Console (pdcurses) + ============================== + normal shift ctrl alt + KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT /# Left #/ + KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT /# Right #/ + KEY_UP, KEY_SUP, CTL_UP, ALT_UP /# Up #/ + KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN /# Down #/ + KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME /# Home #/ + KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP /# Page Up #/ + KEY_NPAGE, KEY_SNEXTE, CTL_PGDN, ALT_PGDN /# Page Down #/ + KEY_END, KEY_SEND, CTL_END, ALT_END /# End #/ + KEY_B1, 52('4'), CTL_PAD4, ALT_PAD4 /# Keypad Left #/ + KEY_B3, 54('6'), CTL_PAD6, ALT_PAD6 /# Keypad Right #/ + KEY_A2, 56('8'), CTL_PAD8, ALT_PAD8 /# Keypad Up #/ + KEY_C2, 50('2'), CTL_PAD2, ALT_PAD2 /# Keypad Down #/ + KEY_A1, 55('7'), CTL_PAD7, ALT_PAD7 /# Keypad Home #/ + KEY_A3, 57('9'), CTL_PAD9, ALT_PAD9 /# Keypad PgUp #/ + KEY_C3, 51('3'), CTL_PAD3, ALT_PAD3 /# Keypad PgDn #/ + KEY_C1, 49('1'), CTL_PAD1, ALT_PAD1 /# Keypad End #/ + KEY_B2, 53('5'), CTL_PAD5, ALT_PAD5 /# Keypad 5 #/ + + Windows Telnet (raw) + ============================== + normal shift ctrl alt + ESC [D, ESC [D, ESC [D, ESC [D /# Left #/ + ESC [C, ESC [C, ESC [C, ESC [C /# Right #/ + ESC [A, ESC [A, ESC [A, ESC [A /# Up #/ + ESC [B, ESC [B, ESC [B, ESC [B /# Down #/ + ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Home #/ + ESC [5~, ESC [5~, ESC [5~, ESC [5~ /# Page Up #/ + ESC [6~, ESC [6~, ESC [6~, ESC [6~ /# Page Down #/ + ESC [4~, ESC [4~, ESC [4~, ESC [4~ /# End #/ + ESC [D, ESC [D, ESC [D, ESC [D /# Keypad Left #/ + ESC [C, ESC [C, ESC [C, ESC [C /# Keypad Right #/ + ESC [A, ESC [A, ESC [A, ESC [A /# Keypad Up #/ + ESC [B, ESC [B, ESC [B, ESC [B /# Keypad Down #/ + ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Keypad Home #/ + ESC [5~, ESC [5~, ESC [5~, ESC [5~ /# Keypad PgUp #/ + ESC [6~, ESC [6~, ESC [6~, ESC [6~ /# Keypad PgDn #/ + ESC [4~, ESC [4~, ESC [4~, ESC [4~ /# Keypad End #/ + nothing, nothing, nothing, nothing /# Keypad 5 #/ + + Windows Telnet (term=xterm) + ============================== + normal shift ctrl alt + KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT /# Left #/ + KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT /# Right #/ + KEY_UP, KEY_UP, KEY_UP, KEY_UP /# Up #/ + KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN /# Down #/ + ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Home #/ + KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, KEY_PPAGE /# Page Up #/ + KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, KEY_NPAGE /# Page Down #/ + ESC [4~, ESC [4~, ESC [4~, ESC [4~ /# End #/ + KEY_LEFT, KEY_LEFT, KEY_LEFT, O /# Keypad Left #/ + KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, O /# Keypad Right #/ + KEY_UP, KEY_UP, KEY_UP, O /# Keypad Up #/ + KEY_DOWN, KEY_DOWN, KEY_DOWN, O /# Keypad Down #/ + ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Keypad Home #/ + KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, KEY_PPAGE /# Keypad PgUp #/ + KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, KEY_NPAGE /# Keypad PgDn #/ + ESC [4~, ESC [4~, ESC [4~, O /# Keypad End #/ + ESC [-71, nothing, nothing, O /# Keypad 5 #/ + + PuTTY + ============================== + normal shift ctrl alt + ESC [D, ESC [D, ESC OD, ESC [D /# Left #/ + ESC [C, ESC [C, ESC OC, ESC [C /# Right #/ + ESC [A, ESC [A, ESC OA, ESC [A /# Up #/ + ESC [B, ESC [B, ESC OB, ESC [B /# Down #/ + ESC [1~, ESC [1~, local win, ESC [1~ /# Home #/ + ESC [5~, local win, local win, ESC [5~ /# Page Up #/ + ESC [6~, local win, local win, ESC [6~ /# Page Down #/ + ESC [4~, ESC [4~, local win, ESC [4~ /# End #/ + ESC [D, ESC [D, ESC [D, O /# Keypad Left #/ + ESC [C, ESC [C, ESC [C, O /# Keypad Right #/ + ESC [A, ESC [A, ESC [A, O /# Keypad Up #/ + ESC [B, ESC [B, ESC [B, O /# Keypad Down #/ + ESC [1~, ESC [1~, ESC [1~, O /# Keypad Home #/ + ESC [5~, ESC [5~, ESC [5~, O /# Keypad PgUp #/ + ESC [6~, ESC [6~, ESC [6~, O /# Keypad PgDn #/ + ESC [4~, ESC [4~, ESC [4~, O /# Keypad End #/ + nothing, nothing, nothing, O /# Keypad 5 #/ + + PuTTY + ============================== + normal shift ctrl alt + KEY_LEFT, KEY_LEFT, ESC OD, ESC KEY_LEFT /# Left #/ + KEY_RIGHT KEY_RIGHT, ESC OC, ESC KEY_RIGHT /# Right #/ + KEY_UP, KEY_UP, ESC OA, ESC KEY_UP /# Up #/ + KEY_DOWN, KEY_DOWN, ESC OB, ESC KEY_DOWN /# Down #/ + ESC [1~, ESC [1~, local win, ESC ESC [1~ /# Home #/ + KEY_PPAGE local win, local win, ESC KEY_PPAGE /# Page Up #/ + KEY_NPAGE local win, local win, ESC KEY_NPAGE /# Page Down #/ + ESC [4~, ESC [4~, local win, ESC ESC [4~ /# End #/ + ESC Ot, ESC Ot, ESC Ot, O /# Keypad Left #/ + ESC Ov, ESC Ov, ESC Ov, O /# Keypad Right #/ + ESC Ox, ESC Ox, ESC Ox, O /# Keypad Up #/ + ESC Or, ESC Or, ESC Or, O /# Keypad Down #/ + ESC Ow, ESC Ow, ESC Ow, O /# Keypad Home #/ + ESC Oy, ESC Oy, ESC Oy, O /# Keypad PgUp #/ + ESC Os, ESC Os, ESC Os, O /# Keypad PgDn #/ + ESC Oq, ESC Oq, ESC Oq, O /# Keypad End #/ + ESC Ou, ESC Ou, ESC Ou, O /# Keypad 5 #/ +*/ + +#define M_NORMAL 0 +#define M_ESC 1 +#define M_KEYPAD 2 +#define M_TRAIL 3 + +int +md_readchar() +{ + int ch = 0; + int lastch = 0; + int mode = M_NORMAL; + int mode2 = M_NORMAL; + + for(;;) + { + ch = getch(); + + if (ch == ERR) /* timed out waiting for valid sequence */ + { /* flush input so far and start over */ + mode = M_NORMAL; + nocbreak(); + raw(); + ch = 27; + break; + } + + if (mode == M_TRAIL) + { + if (ch == '^') /* msys console : 7,5,6,8: modified*/ + ch = CTRL( toupper(lastch) ); + + if (ch == '~') /* cygwin console: 1,5,6,4: normal */ + ch = tolower(lastch); /* windows telnet: 1,5,6,4: normal */ + /* msys console : 7,5,6,8: normal */ + + if (mode2 == M_ESC) /* cygwin console: 1,5,6,4: modified*/ + ch = CTRL( toupper(ch) ); + + break; + } + + if (mode == M_ESC) + { + if (ch == 27) + { + mode2 = M_ESC; + continue; + } + + if ((ch == 'F') || (ch == 'O') || (ch == '[')) + { + mode = M_KEYPAD; + continue; + } + + + switch(ch) + { + /* Cygwin Console */ + /* PuTTY */ + case KEY_LEFT : ch = CTRL('H'); break; + case KEY_RIGHT: ch = CTRL('L'); break; + case KEY_UP : ch = CTRL('K'); break; + case KEY_DOWN : ch = CTRL('J'); break; + case KEY_HOME : ch = CTRL('Y'); break; + case KEY_PPAGE: ch = CTRL('U'); break; + case KEY_NPAGE: ch = CTRL('N'); break; + case KEY_END : ch = CTRL('B'); break; + + default: break; + } + + break; + } + + if (mode == M_KEYPAD) + { + switch(ch) + { + /* ESC F - Interix Console codes */ + case '^': ch = CTRL('H'); break; /* Shift-Left */ + case '$': ch = CTRL('L'); break; /* Shift-Right */ + + /* ESC [ - Interix Console codes */ + case 'H': ch = 'y'; break; /* Home */ + case 1: ch = CTRL('K'); break; /* Ctl-Keypad Up */ + case 2: ch = CTRL('J'); break; /* Ctl-Keypad Down */ + case 3: ch = CTRL('L'); break; /* Ctl-Keypad Right */ + case 4: ch = CTRL('H'); break; /* Ctl-Keypad Left */ + case 263: ch = CTRL('Y'); break; /* Ctl-Keypad Home */ + case 19: ch = CTRL('U'); break; /* Ctl-Keypad PgUp */ + case 20: ch = CTRL('N'); break; /* Ctl-Keypad PgDn */ + case 21: ch = CTRL('B'); break; /* Ctl-Keypad End */ + + /* ESC [ - Cygwin Console codes */ + case 'G': ch = '.'; break; /* Keypad 5 */ + case '7': lastch = 'Y'; mode=M_TRAIL; break; /* Ctl-Home */ + case '5': lastch = 'U'; mode=M_TRAIL; break; /* Ctl-PgUp */ + case '6': lastch = 'N'; mode=M_TRAIL; break; /* Ctl-PgDn */ + + /* ESC [ - Win32 Telnet, PuTTY */ + case '1': lastch = 'y'; mode=M_TRAIL; break; /* Home */ + case '4': lastch = 'b'; mode=M_TRAIL; break; /* End */ + + /* ESC O - PuTTY */ + case 'D': ch = CTRL('H'); break; + case 'C': ch = CTRL('L'); break; + case 'A': ch = CTRL('K'); break; + case 'B': ch = CTRL('J'); break; + case 't': ch = 'h'; break; + case 'v': ch = 'l'; break; + case 'x': ch = 'k'; break; + case 'r': ch = 'j'; break; + case 'w': ch = 'y'; break; + case 'y': ch = 'u'; break; + case 's': ch = 'n'; break; + case 'q': ch = 'b'; break; + case 'u': ch = '.'; break; + } + + if (mode != M_KEYPAD) + continue; + } + + if (ch == 27) + { + halfdelay(1); + mode = M_ESC; + continue; + } + + switch(ch) + { + case KEY_LEFT : ch = 'h'; break; + case KEY_DOWN : ch = 'j'; break; + case KEY_UP : ch = 'k'; break; + case KEY_RIGHT : ch = 'l'; break; + case KEY_HOME : ch = 'y'; break; + case KEY_PPAGE : ch = 'u'; break; + case KEY_END : ch = 'b'; break; +#ifdef KEY_LL + case KEY_LL : ch = 'b'; break; +#endif + case KEY_NPAGE : ch = 'n'; break; + +#ifdef KEY_B1 + case KEY_B1 : ch = 'h'; break; + case KEY_C2 : ch = 'j'; break; + case KEY_A2 : ch = 'k'; break; + case KEY_B3 : ch = 'l'; break; +#endif + case KEY_A1 : ch = 'y'; break; + case KEY_A3 : ch = 'u'; break; + case KEY_C1 : ch = 'b'; break; + case KEY_C3 : ch = 'n'; break; + /* next should be '.', but for problem with putty/linux */ + case KEY_B2 : ch = 'u'; break; + +#ifdef KEY_SLEFT + case KEY_SRIGHT : ch = CTRL('L'); break; + case KEY_SLEFT : ch = CTRL('H'); break; +#ifdef KEY_SUP + case KEY_SUP : ch = CTRL('K'); break; + case KEY_SDOWN : ch = CTRL('J'); break; +#endif + case KEY_SHOME : ch = CTRL('Y'); break; + case KEY_SPREVIOUS:ch = CTRL('U'); break; + case KEY_SEND : ch = CTRL('B'); break; + case KEY_SNEXT : ch = CTRL('N'); break; +#endif + case 0x146 : ch = CTRL('K'); break; /* Shift-Up */ + case 0x145 : ch = CTRL('J'); break; /* Shift-Down */ + + +#ifdef CTL_RIGHT + case CTL_RIGHT : ch = CTRL('L'); break; + case CTL_LEFT : ch = CTRL('H'); break; + case CTL_UP : ch = CTRL('K'); break; + case CTL_DOWN : ch = CTRL('J'); break; + case CTL_HOME : ch = CTRL('Y'); break; + case CTL_PGUP : ch = CTRL('U'); break; + case CTL_END : ch = CTRL('B'); break; + case CTL_PGDN : ch = CTRL('N'); break; +#endif +#ifdef KEY_EOL + case KEY_EOL : ch = CTRL('B'); break; +#endif + +#ifndef CTL_PAD1 + /* MSYS rxvt console */ + case 511 : ch = CTRL('J'); break; /* Shift Dn */ + case 512 : ch = CTRL('J'); break; /* Ctl Down */ + case 514 : ch = CTRL('H'); break; /* Ctl Left */ + case 516 : ch = CTRL('L'); break; /* Ctl Right*/ + case 518 : ch = CTRL('K'); break; /* Shift Up */ + case 519 : ch = CTRL('K'); break; /* Ctl Up */ +#endif + +#ifdef CTL_PAD1 + case CTL_PAD1 : ch = CTRL('B'); break; + case CTL_PAD2 : ch = CTRL('J'); break; + case CTL_PAD3 : ch = CTRL('N'); break; + case CTL_PAD4 : ch = CTRL('H'); break; + case CTL_PAD5 : ch = '.'; break; + case CTL_PAD6 : ch = CTRL('L'); break; + case CTL_PAD7 : ch = CTRL('Y'); break; + case CTL_PAD8 : ch = CTRL('K'); break; + case CTL_PAD9 : ch = CTRL('U'); break; +#endif + +#ifdef ALT_RIGHT + case ALT_RIGHT : ch = CTRL('L'); break; + case ALT_LEFT : ch = CTRL('H'); break; + case ALT_DOWN : ch = CTRL('J'); break; + case ALT_HOME : ch = CTRL('Y'); break; + case ALT_PGUP : ch = CTRL('U'); break; + case ALT_END : ch = CTRL('B'); break; + case ALT_PGDN : ch = CTRL('N'); break; +#endif + +#ifdef ALT_PAD1 + case ALT_PAD1 : ch = CTRL('B'); break; + case ALT_PAD2 : ch = CTRL('J'); break; + case ALT_PAD3 : ch = CTRL('N'); break; + case ALT_PAD4 : ch = CTRL('H'); break; + case ALT_PAD5 : ch = '.'; break; + case ALT_PAD6 : ch = CTRL('L'); break; + case ALT_PAD7 : ch = CTRL('Y'); break; + case ALT_PAD8 : ch = CTRL('K'); break; + case ALT_PAD9 : ch = CTRL('U'); break; +#endif +#ifdef KEY_BACKSPACE /* NCURSES in Keypad mode sends this for Ctrl-H */ + case KEY_BACKSPACE: ch = CTRL('H'); break; +#endif + } + + break; + } + + nocbreak(); /* disable halfdelay mode if on */ + raw(); + + return(ch & 0x7F); +} + +#if defined(LOADAV) && defined(HAVE_NLIST_H) && defined(HAVE_NLIST) +/* + * loadav: + * Looking up load average in core (for system where the loadav() + * system call isn't defined + */ + +#include + +struct nlist avenrun = { + "_avenrun" +}; + +void +md_loadav(double *avg) +{ + int kmem; + + if ((kmem = open("/dev/kmem", 0)) < 0) + goto bad; + nlist(NAMELIST, &avenrun); + if (avenrun.n_type == 0) + { + close(kmem); +bad: + avg[0] = 0.0; + avg[1] = 0.0; + avg[2] = 0.0; + return; + } + + lseek(kmem, avenrun.n_value, 0); + read(kmem, (char *) avg, 3 * sizeof (double)); + close(kmem); +} +#else +void +md_loadav(double *avg) +{ +#if defined(HAVE_LOADAV) + loadav(avg); +#elif defined(HAVE_GETLOADAVG) + getloadavg(avg,3); +#else + avg[0] = avg[1] = avg[2] = 0; +#endif +} +#endif + +#ifndef NSIG +#define NSIG 32 +#endif + +void +md_ignoreallsignals() +{ + int i; + + for (i = 0; i < NSIG; i++) + signal(i, SIG_IGN); +} + +void +md_tstphold() +{ +#ifdef SIGTSTP + /* + * If a process can be suspended, this code wouldn't work + */ +# ifdef SIG_HOLD + signal(SIGTSTP, SIG_HOLD); +# else + signal(SIGTSTP, SIG_IGN); +# endif +#endif +} + +void +md_tstpresume() +{ +#ifdef SIGTSTP + signal(SIGTSTP, tstp); +#endif +} + +void +md_tstpsignal() +{ +#ifdef SIGTSTP + kill(0, SIGTSTP); /* send actual signal and suspend process */ +#endif +} + +#if defined(CHECKTIME) +void +md_start_checkout_timer(int time) +{ + int checkout(); + +#if defined(HAVE_ALARM) && defined(SIGALRM) + signal(SIGALRM, checkout); + alarm(time); +#endif +} + +void +md_stop_checkout_timer() +{ +#if defined(SIGALRM) + signal(SIGALRM, SIG_IGN); +#endif +} + +#endif diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c new file mode 100644 index 000000000..87bc40b4d --- /dev/null +++ b/src/cc/rogue/misc.c @@ -0,0 +1,597 @@ +/* + * All sorts of miscellaneous routines + * + * @(#)misc.c 4.66 (Berkeley) 08/06/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include "rogue.h" + +/* + * look: + * A quick glance all around the player + */ +#undef DEBUG + + +void +look(struct rogue_state *rs,bool wakeup) +{ + int x, y; + int ch; + THING *tp; + PLACE *pp; + struct room *rp; + int ey, ex; + int passcount; + char pfl, *fp, pch; + int sy, sx, sumhero = 0, diffhero = 0; +# ifdef DEBUG + static bool done = FALSE; + + if (done) + return; + done = TRUE; +# endif /* DEBUG */ + passcount = 0; + rp = proom; + if (!ce(oldpos, hero)) + { + erase_lamp(&oldpos, oldrp); + oldpos = hero; + oldrp = rp; + } + ey = hero.y + 1; + ex = hero.x + 1; + sx = hero.x - 1; + sy = hero.y - 1; + if (door_stop && !firstmove && running) + { + sumhero = hero.y + hero.x; + diffhero = hero.y - hero.x; + } + pp = INDEX(hero.y, hero.x); + pch = pp->p_ch; + pfl = pp->p_flags; + + for (y = sy; y <= ey; y++) + if (y > 0 && y < NUMLINES - 1) for (x = sx; x <= ex; x++) + { + if (x < 0 || x >= NUMCOLS) + continue; + if (!on(player, ISBLIND)) + { + if (y == hero.y && x == hero.x) + continue; + } + + pp = INDEX(y, x); + ch = pp->p_ch; + if (ch == ' ') /* nothing need be done with a ' ' */ + continue; + fp = &pp->p_flags; + if (pch != DOOR && ch != DOOR) + if ((pfl & F_PASS) != (*fp & F_PASS)) + continue; + if (((*fp & F_PASS) || ch == DOOR) && + ((pfl & F_PASS) || pch == DOOR)) + { + if (hero.x != x && hero.y != y && + !step_ok(chat(y, hero.x)) && !step_ok(chat(hero.y, x))) + continue; + } + + if ((tp = pp->p_monst) == NULL) + ch = trip_ch(y, x, ch); + else + if (on(player, SEEMONST) && on(*tp, ISINVIS)) + { + if (door_stop && !firstmove) + running = FALSE; + continue; + } + else + { + if (wakeup) + wake_monster(rs,y, x); + if (see_monst(tp)) + { + if (on(player, ISHALU)) + ch = rnd(26) + 'A'; + else + ch = tp->t_disguise; + } + } + if (on(player, ISBLIND) && (y != hero.y || x != hero.x)) + continue; + + move(y, x); + + if ((proom->r_flags & ISDARK) && !see_floor && ch == FLOOR) + ch = ' '; + + if (tp != NULL || ch != CCHAR( inch() )) + addch(ch); + + if (door_stop && !firstmove && running) + { + switch (runch) + { + case 'h': + if (x == ex) + continue; + when 'j': + if (y == sy) + continue; + when 'k': + if (y == ey) + continue; + when 'l': + if (x == sx) + continue; + when 'y': + if ((y + x) - sumhero >= 1) + continue; + when 'u': + if ((y - x) - diffhero >= 1) + continue; + when 'n': + if ((y + x) - sumhero <= -1) + continue; + when 'b': + if ((y - x) - diffhero <= -1) + continue; + } + switch (ch) + { + case DOOR: + if (x == hero.x || y == hero.y) + running = FALSE; + break; + case PASSAGE: + if (x == hero.x || y == hero.y) + passcount++; + break; + case FLOOR: + case '|': + case '-': + case ' ': + break; + default: + running = FALSE; + break; + } + } + } + if (door_stop && !firstmove && passcount > 1) + running = FALSE; + if (!running || !jump) + mvaddch(hero.y, hero.x, PLAYER); +# ifdef DEBUG + done = FALSE; +# endif /* DEBUG */ +} + +/* + * trip_ch: + * Return the character appropriate for this space, taking into + * account whether or not the player is tripping. + */ +int +trip_ch(int y, int x, int ch) +{ + if (on(player, ISHALU) && after) + switch (ch) + { + case FLOOR: + case ' ': + case PASSAGE: + case '-': + case '|': + case DOOR: + case TRAP: + break; + default: + if (y != stairs.y || x != stairs.x || !seenstairs) + ch = rnd_thing(); + break; + } + return ch; +} + +/* + * erase_lamp: + * Erase the area shown by a lamp in a dark room. + */ + +void +erase_lamp(coord *pos, struct room *rp) +{ + int y, x, ey, sy, ex; + + if (!(see_floor && (rp->r_flags & (ISGONE|ISDARK)) == ISDARK + && !on(player,ISBLIND))) + return; + + ey = pos->y + 1; + ex = pos->x + 1; + sy = pos->y - 1; + for (x = pos->x - 1; x <= ex; x++) + for (y = sy; y <= ey; y++) + { + if (y == hero.y && x == hero.x) + continue; + move(y, x); + if (inch() == FLOOR) + addch(' '); + } +} + +/* + * show_floor: + * Should we show the floor in her room at this time? + */ +bool +show_floor() +{ + if ((proom->r_flags & (ISGONE|ISDARK)) == ISDARK && !on(player, ISBLIND)) + return see_floor; + else + return TRUE; +} + +/* + * find_obj: + * Find the unclaimed object at y, x + */ +THING * +find_obj(struct rogue_state *rs,int y, int x) +{ + THING *obj; + + for (obj = lvl_obj; obj != NULL; obj = next(obj)) + { + if (obj->o_pos.y == y && obj->o_pos.x == x) + return obj; + } +#ifdef MASTER + sprintf(prbuf, "Non-object %d,%d", y, x); + msg(rs,prbuf); + return NULL; +#else + /* NOTREACHED */ + return NULL; +#endif +} + +/* + * eat: + * She wants to eat something, so let her try + */ + +void +eat(struct rogue_state *rs) +{ + THING *obj; + + if ((obj = get_item(rs,"eat", FOOD)) == NULL) + return; + if (obj->o_type != FOOD) + { + if (!terse) + msg(rs,"ugh, you would get ill if you ate that"); + else + msg(rs,"that's Inedible!"); + return; + } + if (food_left < 0) + food_left = 0; + if ((food_left += HUNGERTIME - 200 + rnd(400)) > STOMACHSIZE) + food_left = STOMACHSIZE; + hungry_state = 0; + if (obj == cur_weapon) + cur_weapon = NULL; + if (obj->o_which == 1) + msg(rs,"my, that was a yummy %s", fruit); + else + if (rnd(100) > 70) + { + pstats.s_exp++; + msg(rs,"%s, this food tastes awful", choose_str("bummer", "yuk")); + check_level(rs); + } + else + msg(rs,"%s, that tasted good", choose_str("oh, wow", "yum")); + leave_pack(rs,obj, FALSE, FALSE); +} + +/* + * check_level: + * Check to see if the guy has gone up a level. + */ + +void +check_level(struct rogue_state *rs) +{ + int i, add, olevel; + + for (i = 0; e_levels[i] != 0; i++) + if (e_levels[i] > pstats.s_exp) + break; + i++; + olevel = pstats.s_lvl; + pstats.s_lvl = i; + if (i > olevel) + { + add = roll(i - olevel, 10); + max_hp += add; + pstats.s_hpt += add; + msg(rs,"welcome to level %d", i); + } +} + +/* + * chg_str: + * used to modify the playes strength. It keeps track of the + * highest it has been, just in case + */ + +void +chg_str(int amt) +{ + auto str_t comp; + + if (amt == 0) + return; + add_str(&pstats.s_str, amt); + comp = pstats.s_str; + if (ISRING(LEFT, R_ADDSTR)) + add_str(&comp, -cur_ring[LEFT]->o_arm); + if (ISRING(RIGHT, R_ADDSTR)) + add_str(&comp, -cur_ring[RIGHT]->o_arm); + if (comp > max_stats.s_str) + max_stats.s_str = comp; +} + +/* + * add_str: + * Perform the actual add, checking upper and lower bound limits + */ +void +add_str(str_t *sp, int amt) +{ + if ((*sp += amt) < 3) + *sp = 3; + else if (*sp > 31) + *sp = 31; +} + +/* + * add_haste: + * Add a haste to the player + */ +bool +add_haste(struct rogue_state *rs,bool potion) +{ + if (on(player, ISHASTE)) + { + no_command += rnd(8); + player.t_flags &= ~(ISRUN|ISHASTE); + extinguish(nohaste); + msg(rs,"you faint from exhaustion"); + return FALSE; + } + else + { + player.t_flags |= ISHASTE; + if (potion) + fuse(nohaste, 0, rnd(4)+4, AFTER); + return TRUE; + } +} + +/* + * aggravate: + * Aggravate all the monsters on this level + */ + +void +aggravate(struct rogue_state *rs) +{ + THING *mp; + + for (mp = mlist; mp != NULL; mp = next(mp)) + runto(rs,&mp->t_pos); +} + +/* + * vowelstr: + * For printfs: if string starts with a vowel, return "n" for an + * "an". + */ +char * +vowelstr(char *str) +{ + switch (*str) + { + case 'a': case 'A': + case 'e': case 'E': + case 'i': case 'I': + case 'o': case 'O': + case 'u': case 'U': + return "n"; + default: + return ""; + } +} + +/* + * is_current: + * See if the object is one of the currently used items + */ +bool +is_current(struct rogue_state *rs,THING *obj) +{ + if (obj == NULL) + return FALSE; + if (obj == cur_armor || obj == cur_weapon || obj == cur_ring[LEFT] + || obj == cur_ring[RIGHT]) + { + if (!terse) + addmsg(rs,"That's already "); + msg(rs,"in use"); + return TRUE; + } + return FALSE; +} + +/* + * get_dir: + * Set up the direction co_ordinate for use in varios "prefix" + * commands + */ +bool +get_dir(struct rogue_state *rs) +{ + char *prompt; + bool gotit; + static coord last_delt= {0,0}; + + if (again && last_dir != '\0') + { + delta.y = last_delt.y; + delta.x = last_delt.x; + dir_ch = last_dir; + } + else + { + if (!terse) + msg(rs,prompt = "which direction? "); + else + prompt = "direction: "; + do + { + gotit = TRUE; + switch (dir_ch = readchar(rs)) + { + case 'h': case'H': delta.y = 0; delta.x = -1; + when 'j': case'J': delta.y = 1; delta.x = 0; + when 'k': case'K': delta.y = -1; delta.x = 0; + when 'l': case'L': delta.y = 0; delta.x = 1; + when 'y': case'Y': delta.y = -1; delta.x = -1; + when 'u': case'U': delta.y = -1; delta.x = 1; + when 'b': case'B': delta.y = 1; delta.x = -1; + when 'n': case'N': delta.y = 1; delta.x = 1; + when ESCAPE: last_dir = '\0'; reset_last(); return FALSE; + otherwise: + mpos = 0; + msg(rs,prompt); + gotit = FALSE; + } + } until (gotit); + if (isupper(dir_ch)) + dir_ch = (char) tolower(dir_ch); + last_dir = dir_ch; + last_delt.y = delta.y; + last_delt.x = delta.x; + } + if (on(player, ISHUH) && rnd(5) == 0) + do + { + delta.y = rnd(3) - 1; + delta.x = rnd(3) - 1; + } while (delta.y == 0 && delta.x == 0); + mpos = 0; + return TRUE; +} + +/* + * sign: + * Return the sign of the number + */ +int +sign(int nm) +{ + if (nm < 0) + return -1; + else + return (nm > 0); +} + +/* + * spread: + * Give a spread around a given number (+/- 20%) + */ +int +spread(int nm) +{ + return nm - nm / 20 + rnd(nm / 10); +} + +/* + * call_it: + * Call an object something after use. + */ + +void +call_it(struct rogue_state *rs,struct obj_info *info) +{ + if (info->oi_know) + { + if (info->oi_guess) + { + free(info->oi_guess); + info->oi_guess = NULL; + } + } + else if (!info->oi_guess) + { + msg(rs,terse ? "call it: " : "what do you want to call it? "); + if (get_str(rs,prbuf, stdscr) == NORM) + { + if (info->oi_guess != NULL) + free(info->oi_guess); + info->oi_guess = malloc((unsigned int) strlen(prbuf) + 1); + strcpy(info->oi_guess, prbuf); + } + } +} + +/* + * rnd_thing: + * Pick a random thing appropriate for this level + */ +char +rnd_thing() +{ + int i; + static char thing_list[] = { + POTION, SCROLL, RING, STICK, FOOD, WEAPON, ARMOR, STAIRS, GOLD, AMULET + }; + + if (level >= AMULETLEVEL) + i = rnd(sizeof thing_list / sizeof (char)); + else + i = rnd(sizeof thing_list / sizeof (char) - 1); + return thing_list[i]; +} + +/* + str str: + * Choose the first or second string depending on whether it the + * player is tripping + */ +char * +choose_str(char *ts, char *ns) +{ + return (on(player, ISHALU) ? ts : ns); +} diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c new file mode 100644 index 000000000..c9441efa3 --- /dev/null +++ b/src/cc/rogue/monsters.c @@ -0,0 +1,252 @@ +/* + * File with various monster functions in it + * + * @(#)monsters.c 4.46 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" +#include + +/* + * List of monsters in rough order of vorpalness + */ +static char lvl_mons[] = { + 'K', 'E', 'B', 'S', 'H', 'I', 'R', 'O', 'Z', 'L', 'C', 'Q', 'A', + 'N', 'Y', 'F', 'T', 'W', 'P', 'X', 'U', 'M', 'V', 'G', 'J', 'D' +}; + +static char wand_mons[] = { + 'K', 'E', 'B', 'S', 'H', 0, 'R', 'O', 'Z', 0, 'C', 'Q', 'A', + 0, 'Y', 0, 'T', 'W', 'P', 0, 'U', 'M', 'V', 'G', 'J', 0 +}; + +/* + * randmonster: + * Pick a monster to show up. The lower the level, + * the meaner the monster. + */ +char +randmonster(bool wander) +{ + int d; + char *mons; + + mons = (wander ? wand_mons : lvl_mons); + do + { + d = level + (rnd(10) - 6); + if (d < 0) + d = rnd(5); + if (d > 25) + d = rnd(5) + 21; + } while (mons[d] == 0); + return mons[d]; +} + +/* + * new_monster: + * Pick a new monster and add it to the list + */ + +void +new_monster(struct rogue_state *rs,THING *tp, char type, coord *cp) +{ + struct monster *mp; + int lev_add; + + if ((lev_add = level - AMULETLEVEL) < 0) + lev_add = 0; + attach(mlist, tp); + tp->t_type = type; + tp->t_disguise = type; + tp->t_pos = *cp; + move(cp->y, cp->x); + tp->t_oldch = CCHAR( inch() ); + tp->t_room = roomin(rs,cp); + moat(cp->y, cp->x) = tp; + mp = &monsters[tp->t_type-'A']; + tp->t_stats.s_lvl = mp->m_stats.s_lvl + lev_add; + tp->t_stats.s_maxhp = tp->t_stats.s_hpt = roll(tp->t_stats.s_lvl, 8); + tp->t_stats.s_arm = mp->m_stats.s_arm - lev_add; + strcpy(tp->t_stats.s_dmg,mp->m_stats.s_dmg); + tp->t_stats.s_str = mp->m_stats.s_str; + tp->t_stats.s_exp = mp->m_stats.s_exp + lev_add * 10 + exp_add(tp); + tp->t_flags = mp->m_flags; + if (level > 29) + tp->t_flags |= ISHASTE; + tp->t_turn = TRUE; + tp->t_pack = NULL; + if (ISWEARING(R_AGGR)) + runto(rs,cp); + if (type == 'X') + tp->t_disguise = rnd_thing(); +} + +/* + * expadd: + * Experience to add for this monster's level/hit points + */ +int +exp_add(THING *tp) +{ + int mod; + + if (tp->t_stats.s_lvl == 1) + mod = tp->t_stats.s_maxhp / 8; + else + mod = tp->t_stats.s_maxhp / 6; + if (tp->t_stats.s_lvl > 9) + mod *= 20; + else if (tp->t_stats.s_lvl > 6) + mod *= 4; + return mod; +} + +/* + * wanderer: + * Create a new wandering monster and aim it at the player + */ + +void +wanderer(struct rogue_state *rs) +{ + THING *tp; + static coord cp; + + tp = new_item(); + do + { + find_floor((struct room *) NULL, &cp, FALSE, TRUE); + } while (roomin(rs,&cp) == proom); + new_monster(rs,tp, randmonster(TRUE), &cp); + if (on(player, SEEMONST)) + { + standout(); + if (!on(player, ISHALU)) + addch(tp->t_type); + else + addch(rnd(26) + 'A'); + standend(); + } + runto(rs,&tp->t_pos); +#ifdef MASTER + if (wizard) + msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); +#endif +} + +/* + * wake_monster: + * What to do when the hero steps next to a monster + */ +THING * +wake_monster(struct rogue_state *rs,int y, int x) +{ + THING *tp; + struct room *rp; + char ch, *mname; + +#ifdef MASTER + if ((tp = moat(y, x)) == NULL) + msg(rs,"can't find monster in wake_monster"); +#else + tp = moat(y, x); + if (tp == NULL) + endwin(), abort(); +#endif + ch = tp->t_type; + /* + * Every time he sees mean monster, it might start chasing him + */ + if (!on(*tp, ISRUN) && rnd(3) != 0 && on(*tp, ISMEAN) && !on(*tp, ISHELD) + && !ISWEARING(R_STEALTH) && !on(player, ISLEVIT)) + { + tp->t_dest = &hero; + tp->t_flags |= ISRUN; + } + if (ch == 'M' && !on(player, ISBLIND) && !on(player, ISHALU) + && !on(*tp, ISFOUND) && !on(*tp, ISCANC) && on(*tp, ISRUN)) + { + rp = proom; + if ((rp != NULL && !(rp->r_flags & ISDARK)) + || dist(y, x, hero.y, hero.x) < LAMPDIST) + { + tp->t_flags |= ISFOUND; + if (!save(VS_MAGIC)) + { + if (on(player, ISHUH)) + lengthen(unconfuse, spread(HUHDURATION)); + else + fuse(unconfuse, 0, spread(HUHDURATION), AFTER); + player.t_flags |= ISHUH; + mname = set_mname(tp); + addmsg(rs,"%s", mname); + if (strcmp(mname, "it") != 0) + addmsg(rs,"'"); + msg(rs,"s gaze has confused you"); + } + } + } + /* + * Let greedy ones guard gold + */ + if (on(*tp, ISGREED) && !on(*tp, ISRUN)) + { + tp->t_flags |= ISRUN; + if (proom->r_goldval) + tp->t_dest = &proom->r_gold; + else + tp->t_dest = &hero; + } + return tp; +} + +/* + * give_pack: + * Give a pack to a monster if it deserves one + */ + +void +give_pack(struct rogue_state *rs,THING *tp) +{ + if (level >= max_level && rnd(100) < monsters[tp->t_type-'A'].m_carry) + attach(tp->t_pack, new_thing(rs)); +} + +/* + * save_throw: + * See if a creature save against something + */ +int +save_throw(int which, THING *tp) +{ + int need; + + need = 14 + which - tp->t_stats.s_lvl / 2; + return (roll(1, 20) >= need); +} + +/* + * save: + * See if he saves against various nasty things + */ +int +save(int which) +{ + if (which == VS_MAGIC) + { + if (ISRING(LEFT, R_PROTECT)) + which -= cur_ring[LEFT]->o_arm; + if (ISRING(RIGHT, R_PROTECT)) + which -= cur_ring[RIGHT]->o_arm; + } + return save_throw(which, &player); +} diff --git a/src/cc/rogue/move.c b/src/cc/rogue/move.c new file mode 100644 index 000000000..b402f4fa1 --- /dev/null +++ b/src/cc/rogue/move.c @@ -0,0 +1,425 @@ +/* + * hero movement commands + * + * @(#)move.c 4.49 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +/* + * used to hold the new hero position + */ + +coord nh; + +/* + * do_run: + * Start the hero running + */ + +void +do_run(char ch) +{ + running = TRUE; + after = FALSE; + runch = ch; +} + +/* + * do_move: + * Check to see that a move is legal. If it is handle the + * consequences (fighting, picking up, etc.) + */ + +void +do_move(struct rogue_state *rs,int dy, int dx) +{ + char ch, fl; + + firstmove = FALSE; + if (no_move) + { + no_move--; + msg(rs,"you are still stuck in the bear trap"); + return; + } + /* + * Do a confused move (maybe) + */ + if (on(player, ISHUH) && rnd(5) != 0) + { + nh = *rndmove(&player); + if (ce(nh, hero)) + { + after = FALSE; + running = FALSE; + to_death = FALSE; + return; + } + } + else + { +over: + nh.y = hero.y + dy; + nh.x = hero.x + dx; + } + + /* + * Check if he tried to move off the screen or make an illegal + * diagonal move, and stop him if he did. + */ + if (nh.x < 0 || nh.x >= NUMCOLS || nh.y <= 0 || nh.y >= NUMLINES - 1) + goto hit_bound; + if (!diag_ok(&hero, &nh)) + { + after = FALSE; + running = FALSE; + return; + } + if (running && ce(hero, nh)) + after = running = FALSE; + fl = flat(nh.y, nh.x); + ch = winat(nh.y, nh.x); + if (!(fl & F_REAL) && ch == FLOOR) + { + if (!on(player, ISLEVIT)) + { + chat(nh.y, nh.x) = ch = TRAP; + flat(nh.y, nh.x) |= F_REAL; + } + } + else if (on(player, ISHELD) && ch != 'F') + { + msg(rs,"you are being held"); + return; + } + switch (ch) + { + case ' ': + case '|': + case '-': +hit_bound: + if (passgo && running && (proom->r_flags & ISGONE) + && !on(player, ISBLIND)) + { + bool b1, b2; + + switch (runch) + { + case 'h': + case 'l': + b1 = (bool)(hero.y != 1 && turn_ok(hero.y - 1, hero.x)); + b2 = (bool)(hero.y != NUMLINES - 2 && turn_ok(hero.y + 1, hero.x)); + if (!(b1 ^ b2)) + break; + if (b1) + { + runch = 'k'; + dy = -1; + } + else + { + runch = 'j'; + dy = 1; + } + dx = 0; + turnref(); + goto over; + case 'j': + case 'k': + b1 = (bool)(hero.x != 0 && turn_ok(hero.y, hero.x - 1)); + b2 = (bool)(hero.x != NUMCOLS - 1 && turn_ok(hero.y, hero.x + 1)); + if (!(b1 ^ b2)) + break; + if (b1) + { + runch = 'h'; + dx = -1; + } + else + { + runch = 'l'; + dx = 1; + } + dy = 0; + turnref(); + goto over; + } + } + running = FALSE; + after = FALSE; + break; + case DOOR: + running = FALSE; + if (flat(hero.y, hero.x) & F_PASS) + enter_room(rs,&nh); + goto move_stuff; + case TRAP: + ch = be_trapped(rs,&nh); + if (ch == T_DOOR || ch == T_TELEP) + return; + goto move_stuff; + case PASSAGE: + /* + * when you're in a corridor, you don't know if you're in + * a maze room or not, and there ain't no way to find out + * if you're leaving a maze room, so it is necessary to + * always recalculate proom. + */ + proom = roomin(rs,&hero); + goto move_stuff; + case FLOOR: + if (!(fl & F_REAL)) + be_trapped(rs,&hero); + goto move_stuff; + case STAIRS: + seenstairs = TRUE; + /* FALLTHROUGH */ + default: + running = FALSE; + if (isupper(ch) || moat(nh.y, nh.x)) + fight(rs,&nh, cur_weapon, FALSE); + else + { + if (ch != STAIRS) + take = ch; +move_stuff: + mvaddch(hero.y, hero.x, floor_at()); + if ((fl & F_PASS) && chat(oldpos.y, oldpos.x) == DOOR) + leave_room(rs,&nh); + hero = nh; + } + } +} + +/* + * turn_ok: + * Decide whether it is legal to turn onto the given space + */ +bool +turn_ok(int y, int x) +{ + PLACE *pp; + + pp = INDEX(y, x); + return (pp->p_ch == DOOR + || (pp->p_flags & (F_REAL|F_PASS)) == (F_REAL|F_PASS)); +} + +/* + * turnref: + * Decide whether to refresh at a passage turning or not + */ + +void +turnref() +{ + PLACE *pp; + + pp = INDEX(hero.y, hero.x); + if (!(pp->p_flags & F_SEEN)) + { + if (jump) + { + leaveok(stdscr, TRUE); + refresh(); + leaveok(stdscr, FALSE); + } + pp->p_flags |= F_SEEN; + } +} + +/* + * door_open: + * Called to illuminate a room. If it is dark, remove anything + * that might move. + */ + +void +door_open(struct rogue_state *rs,struct room *rp) +{ + int y, x; + + if (!(rp->r_flags & ISGONE)) + for (y = rp->r_pos.y; y < rp->r_pos.y + rp->r_max.y; y++) + for (x = rp->r_pos.x; x < rp->r_pos.x + rp->r_max.x; x++) + if (isupper(winat(y, x))) + wake_monster(rs,y, x); +} + +/* + * be_trapped: + * The guy stepped on a trap.... Make him pay. + */ +char +be_trapped(struct rogue_state *rs,coord *tc) +{ + PLACE *pp; + THING *arrow; + char tr; + + if (on(player, ISLEVIT)) + return T_RUST; /* anything that's not a door or teleport */ + running = FALSE; + count = FALSE; + pp = INDEX(tc->y, tc->x); + pp->p_ch = TRAP; + tr = pp->p_flags & F_TMASK; + pp->p_flags |= F_SEEN; + switch (tr) + { + case T_DOOR: + level++; + new_level(rs); + msg(rs,"you fell into a trap!"); + when T_BEAR: + no_move += BEARTIME; + msg(rs,"you are caught in a bear trap"); + when T_MYST: + switch(rnd(11)) + { + case 0: msg(rs,"you are suddenly in a parallel dimension"); + when 1: msg(rs,"the light in here suddenly seems %s", rainbow[rnd(cNCOLORS)]); + when 2: msg(rs,"you feel a sting in the side of your neck"); + when 3: msg(rs,"multi-colored lines swirl around you, then fade"); + when 4: msg(rs,"a %s light flashes in your eyes", rainbow[rnd(cNCOLORS)]); + when 5: msg(rs,"a spike shoots past your ear!"); + when 6: msg(rs,"%s sparks dance across your armor", rainbow[rnd(cNCOLORS)]); + when 7: msg(rs,"you suddenly feel very thirsty"); + when 8: msg(rs,"you feel time speed up suddenly"); + when 9: msg(rs,"time now seems to be going slower"); + when 10: msg(rs,"you pack turns %s!", rainbow[rnd(cNCOLORS)]); + } + when T_SLEEP: + no_command += SLEEPTIME; + player.t_flags &= ~ISRUN; + msg(rs,"a strange white mist envelops you and you fall asleep"); + when T_ARROW: + if (swing(pstats.s_lvl - 1, pstats.s_arm, 1)) + { + pstats.s_hpt -= roll(1, 6); + if (pstats.s_hpt <= 0) + { + msg(rs,"an arrow killed you"); + death('a'); + } + else + msg(rs,"oh no! An arrow shot you"); + } + else + { + arrow = new_item(); + init_weapon(arrow, ARROW); + arrow->o_count = 1; + arrow->o_pos = hero; + fall(rs,arrow, FALSE); + msg(rs,"an arrow shoots past you"); + } + when T_TELEP: + /* + * since the hero's leaving, look() won't put a TRAP + * down for us, so we have to do it ourself + */ + teleport(rs); + mvaddch(tc->y, tc->x, TRAP); + when T_DART: + if (!swing(pstats.s_lvl+1, pstats.s_arm, 1)) + msg(rs,"a small dart whizzes by your ear and vanishes"); + else + { + pstats.s_hpt -= roll(1, 4); + if (pstats.s_hpt <= 0) + { + msg(rs,"a poisoned dart killed you"); + death('d'); + } + if (!ISWEARING(R_SUSTSTR) && !save(VS_POISON)) + chg_str(-1); + msg(rs,"a small dart just hit you in the shoulder"); + } + when T_RUST: + msg(rs,"a gush of water hits you on the head"); + rust_armor(rs,cur_armor); + } + flush_type(); + return tr; +} + +/* + * rndmove: + * Move in a random direction if the monster/person is confused + */ +coord * +rndmove(THING *who) +{ + THING *obj; + int x, y; + char ch; + static coord ret; /* what we will be returning */ + + y = ret.y = who->t_pos.y + rnd(3) - 1; + x = ret.x = who->t_pos.x + rnd(3) - 1; + /* + * Now check to see if that's a legal move. If not, don't move. + * (I.e., bump into the wall or whatever) + */ + if (y == who->t_pos.y && x == who->t_pos.x) + return &ret; + if (!diag_ok(&who->t_pos, &ret)) + goto bad; + else + { + ch = winat(y, x); + if (!step_ok(ch)) + goto bad; + if (ch == SCROLL) + { + for (obj = lvl_obj; obj != NULL; obj = next(obj)) + if (y == obj->o_pos.y && x == obj->o_pos.x) + break; + if (obj != NULL && obj->o_which == S_SCARE) + goto bad; + } + } + return &ret; + +bad: + ret = who->t_pos; + return &ret; +} + +/* + * rust_armor: + * Rust the given armor, if it is a legal kind to rust, and we + * aren't wearing a magic ring. + */ + +void +rust_armor(struct rogue_state *rs,THING *arm) +{ + if (arm == NULL || arm->o_type != ARMOR || arm->o_which == LEATHER || + arm->o_arm >= 9) + return; + + if ((arm->o_flags & ISPROT) || ISWEARING(R_SUSTARM)) + { + if (!to_death) + msg(rs,"the rust vanishes instantly"); + } + else + { + arm->o_arm++; + if (!terse) + msg(rs,"your armor appears to be weaker now. Oh my!"); + else + msg(rs,"your armor weakens"); + } +} diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c new file mode 100644 index 000000000..2c0ae7b51 --- /dev/null +++ b/src/cc/rogue/new_level.c @@ -0,0 +1,231 @@ +/* + * new_level: + * Dig and draw a new level + * + * @(#)new_level.c 4.38 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +#define TREAS_ROOM 20 /* one chance in TREAS_ROOM for a treasure room */ +#define MAXTREAS 10 /* maximum number of treasures in a treasure room */ +#define MINTREAS 2 /* minimum number of treasures in a treasure room */ + +void +new_level(struct rogue_state *rs) +{ + THING *tp; + PLACE *pp; + char *sp; + int i; + + player.t_flags &= ~ISHELD; /* unhold when you go down just in case */ + if (level > max_level) + max_level = level; + /* + * Clean things off from last level + */ + for (pp = places; pp < &places[MAXCOLS*MAXLINES]; pp++) + { + pp->p_ch = ' '; + pp->p_flags = F_REAL; + pp->p_monst = NULL; + } + clear(); + /* + * Free up the monsters on the last level + */ + for (tp = mlist; tp != NULL; tp = next(tp)) + free_list(tp->t_pack); + free_list(mlist); + /* + * Throw away stuff left on the previous level (if anything) + */ + free_list(lvl_obj); + do_rooms(rs); /* Draw rooms */ + do_passages(rs); /* Draw passages */ + no_food++; + put_things(rs); /* Place objects (if any) */ + /* + * Place the traps + */ + if (rnd(10) < level) + { + ntraps = rnd(level / 4) + 1; + if (ntraps > MAXTRAPS) + ntraps = MAXTRAPS; + i = ntraps; + while (i--) + { + /* + * not only wouldn't it be NICE to have traps in mazes + * (not that we care about being nice), since the trap + * number is stored where the passage number is, we + * can't actually do it. + */ + do + { + find_floor((struct room *) NULL, &stairs, FALSE, FALSE); + } while (chat(stairs.y, stairs.x) != FLOOR); + sp = &flat(stairs.y, stairs.x); + *sp &= ~F_REAL; + *sp |= rnd(NTRAPS); + } + } + /* + * Place the staircase down. + */ + find_floor((struct room *) NULL, &stairs, FALSE, FALSE); + chat(stairs.y, stairs.x) = STAIRS; + seenstairs = FALSE; + + for (tp = mlist; tp != NULL; tp = next(tp)) + tp->t_room = roomin(rs,&tp->t_pos); + + find_floor((struct room *) NULL, &hero, FALSE, TRUE); + enter_room(rs,&hero); + mvaddch(hero.y, hero.x, PLAYER); + if (on(player, SEEMONST)) + turn_see(FALSE); + if (on(player, ISHALU)) + visuals(rs,0); +} + +/* + * rnd_room: + * Pick a room that is really there + */ +int +rnd_room() +{ + int rm; + + do + { + rm = rnd(MAXROOMS); + } while (rooms[rm].r_flags & ISGONE); + return rm; +} + +/* + * put_things: + * Put potions and scrolls on this level + */ + +void +put_things(struct rogue_state *rs) +{ + int i; + THING *obj; + + /* + * Once you have found the amulet, the only way to get new stuff is + * go down into the dungeon. + */ + if (amulet && level < max_level) + return; + /* + * check for treasure rooms, and if so, put it in. + */ + if (rnd(TREAS_ROOM) == 0) + treas_room(rs); + /* + * Do MAXOBJ attempts to put things on a level + */ + for (i = 0; i < MAXOBJ; i++) + if (rnd(100) < 36) + { + /* + * Pick a new object and link it in the list + */ + obj = new_thing(rs); + attach(lvl_obj, obj); + /* + * Put it somewhere + */ + find_floor((struct room *) NULL, &obj->o_pos, FALSE, FALSE); + chat(obj->o_pos.y, obj->o_pos.x) = (char) obj->o_type; + } + /* + * If he is really deep in the dungeon and he hasn't found the + * amulet yet, put it somewhere on the ground + */ + if (level >= AMULETLEVEL && !amulet) + { + obj = new_item(); + attach(lvl_obj, obj); + obj->o_hplus = 0; + obj->o_dplus = 0; + strncpy(obj->o_damage,"0x0",sizeof(obj->o_damage)); + strncpy(obj->o_hurldmg,"0x0",sizeof(obj->o_hurldmg)); + obj->o_arm = 11; + obj->o_type = AMULET; + /* + * Put it somewhere + */ + find_floor((struct room *) NULL, &obj->o_pos, FALSE, FALSE); + chat(obj->o_pos.y, obj->o_pos.x) = AMULET; + } +} + +/* + * treas_room: + * Add a treasure room + */ +#define MAXTRIES 10 /* max number of tries to put down a monster */ + + +void +treas_room(struct rogue_state *rs) +{ + int nm; + THING *tp; + struct room *rp; + int spots, num_monst; + static coord mp; + + rp = &rooms[rnd_room()]; + spots = (rp->r_max.y - 2) * (rp->r_max.x - 2) - MINTREAS; + if (spots > (MAXTREAS - MINTREAS)) + spots = (MAXTREAS - MINTREAS); + num_monst = nm = rnd(spots) + MINTREAS; + while (nm--) + { + find_floor(rp, &mp, 2 * MAXTRIES, FALSE); + tp = new_thing(rs); + tp->o_pos = mp; + attach(lvl_obj, tp); + chat(mp.y, mp.x) = (char) tp->o_type; + } + + /* + * fill up room with monsters from the next level down + */ + + if ((nm = rnd(spots) + MINTREAS) < num_monst + 2) + nm = num_monst + 2; + spots = (rp->r_max.y - 2) * (rp->r_max.x - 2); + if (nm > spots) + nm = spots; + level++; + while (nm--) + { + spots = 0; + if (find_floor(rp, &mp, MAXTRIES, TRUE)) + { + tp = new_item(); + new_monster(rs,tp, randmonster(FALSE), &mp); + tp->t_flags |= ISMEAN; /* no sloughers in THIS room */ + give_pack(rs,tp); + } + } + level--; +} diff --git a/src/cc/rogue/options.c b/src/cc/rogue/options.c new file mode 100644 index 000000000..667d83248 --- /dev/null +++ b/src/cc/rogue/options.c @@ -0,0 +1,501 @@ +/* + * This file has all the code for the option command. I would rather + * this command were not necessary, but it is the only way to keep the + * wolves off of my back. + * + * @(#)options.c 4.24 (Berkeley) 05/10/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include "rogue.h" + +#define EQSTR(a, b, c) (strncmp(a, b, c) == 0) + +#define NUM_OPTS (sizeof optlist / sizeof (OPTION)) + +/* + * description of an option and what to do with it + */ +struct optstruct { + char *o_name; /* option name */ + char *o_prompt; /* prompt for interactive entry */ + void *o_opt; /* pointer to thing to set */ + /* function to print value */ + void (*o_putfunc)(void *opt); + /* function to get value interactively */ + int (*o_getfunc)(struct rogue_state *rs,void *opt, WINDOW *win); +}; + +typedef struct optstruct OPTION; + +void pr_optname(OPTION *op); + +OPTION optlist[] = { + {"terse", "Terse output", + &terse, put_bool, get_bool }, + {"flush", "Flush typeahead during battle", + &fight_flush, put_bool, get_bool }, + {"jump", "Show position only at end of run", + &jump, put_bool, get_bool }, + {"seefloor", "Show the lamp-illuminated floor", + &see_floor, put_bool, get_sf }, + {"passgo", "Follow turnings in passageways", + &passgo, put_bool, get_bool }, + {"tombstone", "Print out tombstone when killed", + &tombstone, put_bool, get_bool }, + {"inven", "Inventory style", + &inv_type, put_inv_t, get_inv_t }, + {"name", "Name", + whoami, put_str, get_str }, + {"fruit", "Fruit", + fruit, put_str, get_str }, + {"file", "Save file", + file_name, put_str, get_str } +}; + +/* + * option: + * Print and then set options from the terminal + */ + +void +option(struct rogue_state *rs) +{ + OPTION *op; + int retval; + + wclear(hw); + /* + * Display current values of options + */ + for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++) + { + pr_optname(op); + (*op->o_putfunc)(op->o_opt); + waddch(hw, '\n'); + } + /* + * Set values + */ + wmove(hw, 0, 0); + for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++) + { + pr_optname(op); + retval = (*op->o_getfunc)(rs,op->o_opt, hw); + if (retval) + { + if (retval == QUIT) + break; + else if (op > optlist) { /* MINUS */ + wmove(hw, (int)(op - optlist) - 1, 0); + op -= 2; + } + else /* trying to back up beyond the top */ + { + putchar('\007'); + wmove(hw, 0, 0); + op--; + } + } + } + /* + * Switch back to original screen + */ + wmove(hw, LINES - 1, 0); + waddstr(hw, "--Press space to continue--"); + wrefresh(hw); + wait_for(rs,' '); + clearok(curscr, TRUE); + touchwin(stdscr); + after = FALSE; +} + +/* + * pr_optname: + * Print out the option name prompt + */ + +void +pr_optname(OPTION *op) +{ + wprintw(hw, "%s (\"%s\"): ", op->o_prompt, op->o_name); +} + +/* + * put_bool + * Put out a boolean + */ + +void +put_bool(void *b) +{ + waddstr(hw, *(bool *) b ? "True" : "False"); +} + +/* + * put_str: + * Put out a string + */ + +void +put_str(void *str) +{ + waddstr(hw, (char *) str); +} + +/* + * put_inv_t: + * Put out an inventory type + */ + +void +put_inv_t(void *ip) +{ + waddstr(hw, inv_t_name[*(int *) ip]); +} + +/* + * get_bool: + * Allow changing a boolean option and print it out + */ +int +get_bool(struct rogue_state *rs,void *vp, WINDOW *win) +{ + bool *bp = (bool *) vp; + int oy, ox; + bool op_bad; + + op_bad = TRUE; + getyx(win, oy, ox); + waddstr(win, *bp ? "True" : "False"); + while (op_bad) + { + wmove(win, oy, ox); + wrefresh(win); + switch (readchar(rs)) + { + case 't': + case 'T': + *bp = TRUE; + op_bad = FALSE; + break; + case 'f': + case 'F': + *bp = FALSE; + op_bad = FALSE; + break; + case '\n': + case '\r': + op_bad = FALSE; + break; + case ESCAPE: + return QUIT; + case '-': + return MINUS; + default: + wmove(win, oy, ox + 10); + waddstr(win, "(T or F)"); + } + } + wmove(win, oy, ox); + waddstr(win, *bp ? "True" : "False"); + waddch(win, '\n'); + return NORM; +} + +/* + * get_sf: + * Change value and handle transition problems from see_floor to + * !see_floor. + */ +int +get_sf(struct rogue_state *rs,void *vp, WINDOW *win) +{ + bool *bp = (bool *) vp; + bool was_sf; + int retval; + + was_sf = see_floor; + retval = get_bool(rs,bp, win); + if (retval == QUIT) return(QUIT); + if (was_sf != see_floor) + { + if (!see_floor) { + see_floor = TRUE; + erase_lamp(&hero, proom); + see_floor = FALSE; + } + else + look(rs,FALSE); + } + return(NORM); +} + +/* + * get_str: + * Set a string option + */ +#define MAXINP 50 /* max string to read from terminal or environment */ + +int +get_str(struct rogue_state *rs,void *vopt, WINDOW *win) +{ + char *opt = (char *) vopt; + char *sp; + int oy, ox; + int i; + signed char c; + static char buf[MAXSTR]; + + getyx(win, oy, ox); + wrefresh(win); + /* + * loop reading in the string, and put it in a temporary buffer + */ + for (sp = buf; (c = readchar(rs)) != '\n' && c != '\r' && c != ESCAPE; + wclrtoeol(win), wrefresh(win)) + { + if (c == -1) + continue; + else if (c == erasechar()) /* process erase character */ + { + if (sp > buf) + { + sp--; + for (i = (int) strlen(unctrl(*sp)); i; i--) + waddch(win, '\b'); + } + continue; + } + else if (c == killchar()) /* process kill character */ + { + sp = buf; + wmove(win, oy, ox); + continue; + } + else if (sp == buf) + { + if (c == '-' && win != stdscr) + break; + else if (c == '~') + { + strcpy(buf, home); + waddstr(win, home); + sp += strlen(home); + continue; + } + } + if (sp >= &buf[MAXINP] || !(isprint(c) || c == ' ')) + putchar(CTRL('G')); + else + { + *sp++ = c; + waddstr(win, unctrl(c)); + } + } + *sp = '\0'; + if (sp > buf) /* only change option if something has been typed */ + strucpy(opt, buf, (int) strlen(buf)); + mvwprintw(win, oy, ox, "%s\n", opt); + wrefresh(win); + if (win == stdscr) + mpos += (int)(sp - buf); + if (c == '-') + return MINUS; + else if (c == ESCAPE) + return QUIT; + else + return NORM; +} + +/* + * get_inv_t + * Get an inventory type name + */ +int +get_inv_t(struct rogue_state *rs,void *vp, WINDOW *win) +{ + int *ip = (int *) vp; + int oy, ox; + bool op_bad; + + op_bad = TRUE; + getyx(win, oy, ox); + waddstr(win, inv_t_name[*ip]); + while (op_bad) + { + wmove(win, oy, ox); + wrefresh(win); + switch (readchar(rs)) + { + case 'o': + case 'O': + *ip = INV_OVER; + op_bad = FALSE; + break; + case 's': + case 'S': + *ip = INV_SLOW; + op_bad = FALSE; + break; + case 'c': + case 'C': + *ip = INV_CLEAR; + op_bad = FALSE; + break; + case '\n': + case '\r': + op_bad = FALSE; + break; + case ESCAPE: + return QUIT; + case '-': + return MINUS; + default: + wmove(win, oy, ox + 15); + waddstr(win, "(O, S, or C)"); + } + } + mvwprintw(win, oy, ox, "%s\n", inv_t_name[*ip]); + return NORM; +} + + +#ifdef MASTER +/* + * get_num: + * Get a numeric option + */ +int +get_num(struct rogue_state *rs,void *vp, WINDOW *win) +{ + short *opt = (short *) vp; + int i; + static char buf[MAXSTR]; + + if ((i = get_str(rs,buf, win)) == NORM) + *opt = (short) atoi(buf); + return i; +} +#endif + +/* + * parse_opts: + * Parse options from string, usually taken from the environment. + * The string is a series of comma seperated values, with booleans + * being stated as "name" (true) or "noname" (false), and strings + * being "name=....", with the string being defined up to a comma + * or the end of the entire option string. + */ + +void +parse_opts(char *str) +{ + char *sp; + OPTION *op; + int len; + char **i; + char *start; + + while (*str) + { + /* + * Get option name + */ + for (sp = str; isalpha(*sp); sp++) + continue; + len = (int)(sp - str); + /* + * Look it up and deal with it + */ + for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++) + if (EQSTR(str, op->o_name, len)) + { + if (op->o_putfunc == put_bool) /* if option is a boolean */ + *(bool *)op->o_opt = TRUE; /* NOSTRICT */ + else /* string option */ + { + /* + * Skip to start of string value + */ + for (str = sp + 1; *str == '='; str++) + continue; + if (*str == '~') + { + strcpy((char *) op->o_opt, home); /* NOSTRICT */ + start = (char *) op->o_opt + strlen(home);/* NOSTRICT */ + while (*++str == '/') + continue; + } + else + start = (char *) op->o_opt; /* NOSTRICT */ + /* + * Skip to end of string value + */ + for (sp = str + 1; *sp && *sp != ','; sp++) + continue; + /* + * check for type of inventory + */ + if (op->o_putfunc == put_inv_t) + { + if (islower(*str)) + *str = (char) toupper(*str); + for (i = inv_t_name; i <= &inv_t_name[INV_CLEAR]; i++) + if (strncmp(str, *i, sp - str) == 0) + { + inv_type = (int)(i - inv_t_name); + break; + } + } + else + strucpy(start, str, (int)(sp - str)); + } + break; + } + /* + * check for "noname" for booleans + */ + else if (op->o_putfunc == put_bool + && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) + { + *(bool *)op->o_opt = FALSE; /* NOSTRICT */ + break; + } + + /* + * skip to start of next option name + */ + while (*sp && !isalpha(*sp)) + sp++; + str = sp; + } +} + +/* + * strucpy: + * Copy string using unctrl for things + */ + +void +strucpy(char *s1, char *s2, int len) +{ + if (len > MAXINP) + len = MAXINP; + while (len--) + { + if (isprint(*s2) || *s2 == ' ') + *s1++ = *s2; + s2++; + } + *s1 = '\0'; +} diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c new file mode 100644 index 000000000..8c92718b5 --- /dev/null +++ b/src/cc/rogue/pack.c @@ -0,0 +1,503 @@ +/* + * Routines to deal with the pack + * + * @(#)pack.c 4.40 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include "rogue.h" + +/* + * add_pack: + * Pick up an object and add it to the pack. If the argument is + * non-null use it as the linked_list pointer instead of gettting + * it off the ground. + */ + +void +add_pack(struct rogue_state *rs,THING *obj, bool silent) +{ + THING *op, *lp; + bool from_floor; + + from_floor = FALSE; + if (obj == NULL) + { + if ((obj = find_obj(rs,hero.y, hero.x)) == NULL) + return; + from_floor = TRUE; + } + + /* + * Check for and deal with scare monster scrolls + */ + if (obj->o_type == SCROLL && obj->o_which == S_SCARE) + if (obj->o_flags & ISFOUND) + { + detach(lvl_obj, obj); + mvaddch(hero.y, hero.x, floor_ch()); + chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR; + discard(obj); + msg(rs,"the scroll turns to dust as you pick it up"); + return; + } + + if (pack == NULL) + { + pack = obj; + obj->o_packch = pack_char(); + inpack++; + } + else + { + lp = NULL; + for (op = pack; op != NULL; op = next(op)) + { + if (op->o_type != obj->o_type) + lp = op; + else + { + while (op->o_type == obj->o_type && op->o_which != obj->o_which) + { + lp = op; + if (next(op) == NULL) + break; + else + op = next(op); + } + if (op->o_type == obj->o_type && op->o_which == obj->o_which) + { + if (ISMULT(op->o_type)) + { + if (!pack_room(rs,from_floor, obj)) + return; + op->o_count++; +dump_it: + discard(obj); + obj = op; + lp = NULL; + goto out; + } + else if (obj->o_group) + { + lp = op; + while (op->o_type == obj->o_type + && op->o_which == obj->o_which + && op->o_group != obj->o_group) + { + lp = op; + if (next(op) == NULL) + break; + else + op = next(op); + } + if (op->o_type == obj->o_type + && op->o_which == obj->o_which + && op->o_group == obj->o_group) + { + op->o_count += obj->o_count; + inpack--; + if (!pack_room(rs,from_floor, obj)) + return; + goto dump_it; + } + } + else + lp = op; + } +out: + break; + } + } + + if (lp != NULL) + { + if (!pack_room(rs,from_floor, obj)) + return; + else + { + obj->o_packch = pack_char(); + next(obj) = next(lp); + prev(obj) = lp; + if (next(lp) != NULL) + prev(next(lp)) = obj; + next(lp) = obj; + } + } + } + + obj->o_flags |= ISFOUND; + + /* + * If this was the object of something's desire, that monster will + * get mad and run at the hero. + */ + for (op = mlist; op != NULL; op = next(op)) + if (op->t_dest == &obj->o_pos) + op->t_dest = &hero; + + if (obj->o_type == AMULET) + amulet = TRUE; + /* + * Notify the user + */ + if (!silent) + { + if (!terse) + addmsg(rs,"you now have "); + msg(rs,"%s (%c)", inv_name(obj, !terse), obj->o_packch); + } +} + +/* + * pack_room: + * See if there's room in the pack. If not, print out an + * appropriate message + */ +bool +pack_room(struct rogue_state *rs,bool from_floor, THING *obj) +{ + if (++inpack > MAXPACK) + { + if (!terse) + addmsg(rs,"there's "); + addmsg(rs,"no room"); + if (!terse) + addmsg(rs," in your pack"); + endmsg(rs); + if (from_floor) + move_msg(rs,obj); + inpack = MAXPACK; + return FALSE; + } + + if (from_floor) + { + detach(lvl_obj, obj); + mvaddch(hero.y, hero.x, floor_ch()); + chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR; + } + + return TRUE; +} + +/* + * leave_pack: + * take an item out of the pack + */ +THING * +leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all) +{ + THING *nobj; + + inpack--; + nobj = obj; + if (obj->o_count > 1 && !all) + { + last_pick = obj; + obj->o_count--; + if (obj->o_group) + inpack++; + if (newobj) + { + nobj = new_item(); + *nobj = *obj; + next(nobj) = NULL; + prev(nobj) = NULL; + nobj->o_count = 1; + } + } + else + { + last_pick = NULL; + pack_used[obj->o_packch - 'a'] = FALSE; + detach(pack, obj); + } + return nobj; +} + +/* + * pack_char: + * Return the next unused pack character. + */ +char +pack_char() +{ + bool *bp; + + for (bp = pack_used; *bp; bp++) + continue; + *bp = TRUE; + return (char)((int)(bp - pack_used) + 'a'); +} + +/* + * inventory: + * List what is in the pack. Return TRUE if there is something of + * the given type. + */ +bool +inventory(struct rogue_state *rs,THING *list, int type) +{ + static char inv_temp[MAXSTR]; + + n_objs = 0; + for (; list != NULL; list = next(list)) + { + if (type && type != list->o_type && !(type == CALLABLE && + list->o_type != FOOD && list->o_type != AMULET) && + !(type == R_OR_S && (list->o_type == RING || list->o_type == STICK))) + continue; + n_objs++; +#ifdef MASTER + if (!list->o_packch) + strcpy(inv_temp, "%s"); + else +#endif + sprintf(inv_temp, "%c) %%s", list->o_packch); + msg_esc = TRUE; + if (add_line(rs,inv_temp, inv_name(list, FALSE)) == ESCAPE) + { + msg_esc = FALSE; + msg(rs,""); + return TRUE; + } + msg_esc = FALSE; + } + if (n_objs == 0) + { + if (terse) + msg(rs,type == 0 ? "empty handed" : + "nothing appropriate"); + else + msg(rs,type == 0 ? "you are empty handed" : + "you don't have anything appropriate"); + return FALSE; + } + end_line(rs); + return TRUE; +} + +/* + * pick_up: + * Add something to characters pack. + */ + +void +pick_up(struct rogue_state *rs,char ch) +{ + THING *obj; + + if (on(player, ISLEVIT)) + return; + + obj = find_obj(rs,hero.y, hero.x); + if (move_on) + move_msg(rs,obj); + else + switch (ch) + { + case GOLD: + if (obj == NULL) + return; + money(rs,obj->o_goldval); + detach(lvl_obj, obj); + discard(obj); + proom->r_goldval = 0; + break; + default: +#ifdef MASTER + debug("Where did you pick a '%s' up???", unctrl(ch)); +#endif + case ARMOR: + case POTION: + case FOOD: + case WEAPON: + case SCROLL: + case AMULET: + case RING: + case STICK: + add_pack(rs,(THING *) NULL, FALSE); + break; + } +} + +/* + * move_msg: + * Print out the message if you are just moving onto an object + */ + +void +move_msg(struct rogue_state *rs,THING *obj) +{ + if (!terse) + addmsg(rs,"you "); + msg(rs,"moved onto %s", inv_name(obj, TRUE)); +} + +/* + * picky_inven: + * Allow player to inventory a single item + */ + +void +picky_inven(struct rogue_state *rs) +{ + THING *obj; + char mch; + + if (pack == NULL) + msg(rs,"you aren't carrying anything"); + else if (next(pack) == NULL) + msg(rs,"a) %s", inv_name(pack, FALSE)); + else + { + msg(rs,terse ? "item: " : "which item do you wish to inventory: "); + mpos = 0; + if ((mch = readchar(rs)) == ESCAPE) + { + msg(rs,""); + return; + } + for (obj = pack; obj != NULL; obj = next(obj)) + if (mch == obj->o_packch) + { + msg(rs,"%c) %s", mch, inv_name(obj, FALSE)); + return; + } + msg(rs,"'%s' not in pack", unctrl(mch)); + } +} + +/* + * get_item: + * Pick something out of a pack for a purpose + */ +THING * +get_item(struct rogue_state *rs,char *purpose, int type) +{ + THING *obj; + char ch; + + if (pack == NULL) + msg(rs,"you aren't carrying anything"); + else if (again) + if (last_pick) + return last_pick; + else + msg(rs,"you ran out"); + else + { + for (;;) + { + if (!terse) + addmsg(rs,"which object do you want to "); + addmsg(rs,purpose); + if (terse) + addmsg(rs," what"); + msg(rs,"? (* for list): "); + ch = readchar(rs); + mpos = 0; + /* + * Give the poor player a chance to abort the command + */ + if (ch == ESCAPE) + { + reset_last(); + after = FALSE; + msg(rs,""); + return NULL; + } + n_objs = 1; /* normal case: person types one char */ + if (ch == '*') + { + mpos = 0; + if (inventory(rs,pack, type) == 0) + { + after = FALSE; + return NULL; + } + continue; + } + for (obj = pack; obj != NULL; obj = next(obj)) + if (obj->o_packch == ch) + break; + if (obj == NULL) + { + msg(rs,"'%s' is not a valid item",unctrl(ch)); + continue; + } + else + return obj; + } + } + return NULL; +} + +/* + * money: + * Add or subtract gold from the pack + */ + +void +money(struct rogue_state *rs,int value) +{ + purse += value; + mvaddch(hero.y, hero.x, floor_ch()); + chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR; + if (value > 0) + { + if (!terse) + addmsg(rs,"you found "); + msg(rs,"%d gold pieces", value); + } +} + +/* + * floor_ch: + * Return the appropriate floor character for her room + */ +char +floor_ch() +{ + if (proom->r_flags & ISGONE) + return PASSAGE; + return (show_floor() ? FLOOR : ' '); +} + +/* + * floor_at: + * Return the character at hero's position, taking see_floor + * into account + */ +char +floor_at() +{ + char ch; + + ch = chat(hero.y, hero.x); + if (ch == FLOOR) + ch = floor_ch(); + return ch; +} + +/* + * reset_last: + * Reset the last command when the current one is aborted + */ + +void +reset_last() +{ + last_comm = l_last_comm; + last_dir = l_last_dir; + last_pick = l_last_pick; +} diff --git a/src/cc/rogue/passages.c b/src/cc/rogue/passages.c new file mode 100644 index 000000000..6d9cd17b1 --- /dev/null +++ b/src/cc/rogue/passages.c @@ -0,0 +1,424 @@ +/* + * Draw the connecting passages + * + * @(#)passages.c 4.22 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +/* + * do_passages: + * Draw all the passages on a level. + */ + +void +do_passages(struct rogue_state *rs) +{ + struct rdes *r1, *r2 = NULL; + int i, j; + int roomcount; + static struct rdes + { + bool conn[MAXROOMS]; /* possible to connect to room i? */ + bool isconn[MAXROOMS]; /* connection been made to room i? */ + bool ingraph; /* this room in graph already? */ + } rdes[MAXROOMS] = { + { { 0, 1, 0, 1, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 1, 0, 1, 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 0, 1, 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 1, 0, 0, 0, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 0, 1, 0, 1, 0, 1, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 0, 0, 1, 0, 1, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 0, 0, 0, 1, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 0, 0, 0, 0, 1, 0, 1, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { { 0, 0, 0, 0, 0, 1, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + }; + + /* + * reinitialize room graph description + */ + for (r1 = rdes; r1 <= &rdes[MAXROOMS-1]; r1++) + { + for (j = 0; j < MAXROOMS; j++) + r1->isconn[j] = FALSE; + r1->ingraph = FALSE; + } + + /* + * starting with one room, connect it to a random adjacent room and + * then pick a new room to start with. + */ + roomcount = 1; + r1 = &rdes[rnd(MAXROOMS)]; + r1->ingraph = TRUE; + do + { + /* + * find a room to connect with + */ + j = 0; + for (i = 0; i < MAXROOMS; i++) + if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0) + r2 = &rdes[i]; + /* + * if no adjacent rooms are outside the graph, pick a new room + * to look from + */ + if (j == 0) + { + do + r1 = &rdes[rnd(MAXROOMS)]; + until (r1->ingraph); + } + /* + * otherwise, connect new room to the graph, and draw a tunnel + * to it + */ + else + { + r2->ingraph = TRUE; + i = (int)(r1 - rdes); + j = (int)(r2 - rdes); + conn(rs,i, j); + r1->isconn[j] = TRUE; + r2->isconn[i] = TRUE; + roomcount++; + } + } while (roomcount < MAXROOMS); + + /* + * attempt to add passages to the graph a random number of times so + * that there isn't always just one unique passage through it. + */ + for (roomcount = rnd(5); roomcount > 0; roomcount--) + { + r1 = &rdes[rnd(MAXROOMS)]; /* a random room to look from */ + /* + * find an adjacent room not already connected + */ + j = 0; + for (i = 0; i < MAXROOMS; i++) + if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0) + r2 = &rdes[i]; + /* + * if there is one, connect it and look for the next added + * passage + */ + if (j != 0) + { + i = (int)(r1 - rdes); + j = (int)(r2 - rdes); + conn(rs,i, j); + r1->isconn[j] = TRUE; + r2->isconn[i] = TRUE; + } + } + passnum(); +} + +/* + * conn: + * Draw a corridor from a room in a certain direction. + */ + +void +conn(struct rogue_state *rs,int r1, int r2) +{ + struct room *rpf, *rpt = NULL; + int rmt; + int distance = 0, turn_spot, turn_distance = 0; + int rm; + char direc; + static coord del, curr, turn_delta, spos, epos; + + if (r1 < r2) + { + rm = r1; + if (r1 + 1 == r2) + direc = 'r'; + else + direc = 'd'; + } + else + { + rm = r2; + if (r2 + 1 == r1) + direc = 'r'; + else + direc = 'd'; + } + rpf = &rooms[rm]; + /* + * Set up the movement variables, in two cases: + * first drawing one down. + */ + if (direc == 'd') + { + rmt = rm + 3; /* room # of dest */ + rpt = &rooms[rmt]; /* room pointer of dest */ + del.x = 0; /* direction of move */ + del.y = 1; + spos.x = rpf->r_pos.x; /* start of move */ + spos.y = rpf->r_pos.y; + epos.x = rpt->r_pos.x; /* end of move */ + epos.y = rpt->r_pos.y; + if (!(rpf->r_flags & ISGONE)) /* if not gone pick door pos */ + do + { + spos.x = rpf->r_pos.x + rnd(rpf->r_max.x - 2) + 1; + spos.y = rpf->r_pos.y + rpf->r_max.y - 1; + } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); + if (!(rpt->r_flags & ISGONE)) + do + { + epos.x = rpt->r_pos.x + rnd(rpt->r_max.x - 2) + 1; + } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); + distance = abs(spos.y - epos.y) - 1; /* distance to move */ + turn_delta.y = 0; /* direction to turn */ + turn_delta.x = (spos.x < epos.x ? 1 : -1); + turn_distance = abs(spos.x - epos.x); /* how far to turn */ + } + else if (direc == 'r') /* setup for moving right */ + { + rmt = rm + 1; + rpt = &rooms[rmt]; + del.x = 1; + del.y = 0; + spos.x = rpf->r_pos.x; + spos.y = rpf->r_pos.y; + epos.x = rpt->r_pos.x; + epos.y = rpt->r_pos.y; + if (!(rpf->r_flags & ISGONE)) + do + { + spos.x = rpf->r_pos.x + rpf->r_max.x - 1; + spos.y = rpf->r_pos.y + rnd(rpf->r_max.y - 2) + 1; + } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); + if (!(rpt->r_flags & ISGONE)) + do + { + epos.y = rpt->r_pos.y + rnd(rpt->r_max.y - 2) + 1; + } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); + distance = abs(spos.x - epos.x) - 1; + turn_delta.y = (spos.y < epos.y ? 1 : -1); + turn_delta.x = 0; + turn_distance = abs(spos.y - epos.y); + } +#ifdef MASTER + else + debug("error in connection tables"); +#endif + + turn_spot = rnd(distance - 1) + 1; /* where turn starts */ + + /* + * Draw in the doors on either side of the passage or just put #'s + * if the rooms are gone. + */ + if (!(rpf->r_flags & ISGONE)) + door(rpf, &spos); + else + putpass(&spos); + if (!(rpt->r_flags & ISGONE)) + door(rpt, &epos); + else + putpass(&epos); + /* + * Get ready to move... + */ + curr.x = spos.x; + curr.y = spos.y; + while (distance > 0) + { + /* + * Move to new position + */ + curr.x += del.x; + curr.y += del.y; + /* + * Check if we are at the turn place, if so do the turn + */ + if (distance == turn_spot) + while (turn_distance--) + { + putpass(&curr); + curr.x += turn_delta.x; + curr.y += turn_delta.y; + } + /* + * Continue digging along + */ + putpass(&curr); + distance--; + } + curr.x += del.x; + curr.y += del.y; + if (!ce(curr, epos)) + msg(rs,"warning, connectivity problem on this level"); +} + +/* + * putpass: + * add a passage character or secret passage here + */ + +void +putpass(coord *cp) +{ + PLACE *pp; + + pp = INDEX(cp->y, cp->x); + pp->p_flags |= F_PASS; + if (rnd(10) + 1 < level && rnd(40) == 0) + pp->p_flags &= ~F_REAL; + else + pp->p_ch = PASSAGE; +} + +/* + * door: + * Add a door or possibly a secret door. Also enters the door in + * the exits array of the room. + */ + +void +door(struct room *rm, coord *cp) +{ + PLACE *pp; + + rm->r_exit[rm->r_nexits++] = *cp; + + if (rm->r_flags & ISMAZE) + return; + + pp = INDEX(cp->y, cp->x); + if (rnd(10) + 1 < level && rnd(5) == 0) + { + if (cp->y == rm->r_pos.y || cp->y == rm->r_pos.y + rm->r_max.y - 1) + pp->p_ch = '-'; + else + pp->p_ch = '|'; + pp->p_flags &= ~F_REAL; + } + else + pp->p_ch = DOOR; +} + +#ifdef MASTER +/* + * add_pass: + * Add the passages to the current window (wizard command) + */ + +void +add_pass() +{ + PLACE *pp; + int y, x; + char ch; + + for (y = 1; y < NUMLINES - 1; y++) + for (x = 0; x < NUMCOLS; x++) + { + pp = INDEX(y, x); + if ((pp->p_flags & F_PASS) || pp->p_ch == DOOR || + (!(pp->p_flags&F_REAL) && (pp->p_ch == '|' || pp->p_ch == '-'))) + { + ch = pp->p_ch; + if (pp->p_flags & F_PASS) + ch = PASSAGE; + pp->p_flags |= F_SEEN; + move(y, x); + if (pp->p_monst != NULL) + pp->p_monst->t_oldch = pp->p_ch; + else if (pp->p_flags & F_REAL) + addch(ch); + else + { + standout(); + addch((pp->p_flags & F_PASS) ? PASSAGE : DOOR); + standend(); + } + } + } +} +#endif + +/* + * passnum: + * Assign a number to each passageway + */ +static int pnum; +static bool newpnum; + + +void +passnum() +{ + struct room *rp; + int i; + + pnum = 0; + newpnum = FALSE; + for (rp = passages; rp < &passages[MAXPASS]; rp++) + rp->r_nexits = 0; + for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) + for (i = 0; i < rp->r_nexits; i++) + { + newpnum++; + numpass(rp->r_exit[i].y, rp->r_exit[i].x); + } +} + +/* + * numpass: + * Number a passageway square and its brethren + */ + +void +numpass(int y, int x) +{ + char *fp; + struct room *rp; + char ch; + + if (x >= NUMCOLS || x < 0 || y >= NUMLINES || y <= 0) + return; + fp = &flat(y, x); + if (*fp & F_PNUM) + return; + if (newpnum) + { + pnum++; + newpnum = FALSE; + } + /* + * check to see if it is a door or secret door, i.e., a new exit, + * or a numerable type of place + */ + if ((ch = chat(y, x)) == DOOR || + (!(*fp & F_REAL) && (ch == '|' || ch == '-'))) + { + rp = &passages[pnum]; + rp->r_exit[rp->r_nexits].y = y; + rp->r_exit[rp->r_nexits++].x = x; + } + else if (!(*fp & F_PASS)) + return; + *fp |= pnum; + /* + * recurse on the surrounding places + */ + numpass(y + 1, x); + numpass(y - 1, x); + numpass(y, x + 1); + numpass(y, x - 1); +} diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c new file mode 100644 index 000000000..9839319ee --- /dev/null +++ b/src/cc/rogue/potions.c @@ -0,0 +1,375 @@ +/* + * Function(s) for dealing with potions + * + * @(#)potions.c 4.46 (Berkeley) 06/07/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +typedef struct +{ + int pa_flags; + void (*pa_daemon)(struct rogue_state *rs,int); + int pa_time; + char *pa_high, *pa_straight; +} PACT; + +static PACT p_actions[] = +{ + { ISHUH, unconfuse, HUHDURATION, /* P_CONFUSE */ + "what a tripy feeling!", + "wait, what's going on here. Huh? What? Who?" }, + { ISHALU, come_down, SEEDURATION, /* P_LSD */ + "Oh, wow! Everything seems so cosmic!", + "Oh, wow! Everything seems so cosmic!" }, + { 0, NULL, 0 }, /* P_POISON */ + { 0, NULL, 0 }, /* P_STRENGTH */ + { CANSEE, unsee, SEEDURATION, /* P_SEEINVIS */ + prbuf, + prbuf }, + { 0, NULL, 0 }, /* P_HEALING */ + { 0, NULL, 0 }, /* P_MFIND */ + { 0, NULL, 0 }, /* P_TFIND */ + { 0, NULL, 0 }, /* P_RAISE */ + { 0, NULL, 0 }, /* P_XHEAL */ + { 0, NULL, 0 }, /* P_HASTE */ + { 0, NULL, 0 }, /* P_RESTORE */ + { ISBLIND, sight, SEEDURATION, /* P_BLIND */ + "oh, bummer! Everything is dark! Help!", + "a cloak of darkness falls around you" }, + { ISLEVIT, land, HEALTIME, /* P_LEVIT */ + "oh, wow! You're floating in the air!", + "you start to float in the air" } +}; + +/* + * quaff: + * Quaff a potion from the pack + */ + +void +quaff(struct rogue_state *rs) +{ + THING *obj, *tp, *mp; + bool discardit = FALSE; + bool show, trip; + + obj = get_item(rs,"quaff", POTION); + /* + * Make certain that it is somethings that we want to drink + */ + if (obj == NULL) + return; + if (obj->o_type != POTION) + { + if (!terse) + msg(rs,"yuk! Why would you want to drink that?"); + else + msg(rs,"that's undrinkable"); + return; + } + if (obj == cur_weapon) + cur_weapon = NULL; + + /* + * Calculate the effect it has on the poor guy. + */ + trip = on(player, ISHALU); + discardit = (bool)(obj->o_count == 1); + leave_pack(rs,obj, FALSE, FALSE); + switch (obj->o_which) + { + case P_CONFUSE: + do_pot(rs,P_CONFUSE, !trip); + when P_POISON: + pot_info[P_POISON].oi_know = TRUE; + if (ISWEARING(R_SUSTSTR)) + msg(rs,"you feel momentarily sick"); + else + { + chg_str(-(rnd(3) + 1)); + msg(rs,"you feel very sick now"); + come_down(rs,0); + } + when P_HEALING: + pot_info[P_HEALING].oi_know = TRUE; + if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp) + pstats.s_hpt = ++max_hp; + sight(rs,0); + msg(rs,"you begin to feel better"); + when P_STRENGTH: + pot_info[P_STRENGTH].oi_know = TRUE; + chg_str(1); + msg(rs,"you feel stronger, now. What bulging muscles!"); + when P_MFIND: + player.t_flags |= SEEMONST; + fuse((void(*)(struct rogue_state *rs,int))turn_see, TRUE, HUHDURATION, AFTER); + if (!turn_see(FALSE)) + msg(rs,"you have a %s feeling for a moment, then it passes", + choose_str("normal", "strange")); + when P_TFIND: + /* + * Potion of magic detection. Show the potions and scrolls + */ + show = FALSE; + if (lvl_obj != NULL) + { + wclear(hw); + for (tp = lvl_obj; tp != NULL; tp = next(tp)) + { + if (is_magic(tp)) + { + show = TRUE; + wmove(hw, tp->o_pos.y, tp->o_pos.x); + waddch(hw, MAGIC); + pot_info[P_TFIND].oi_know = TRUE; + } + } + for (mp = mlist; mp != NULL; mp = next(mp)) + { + for (tp = mp->t_pack; tp != NULL; tp = next(tp)) + { + if (is_magic(tp)) + { + show = TRUE; + wmove(hw, mp->t_pos.y, mp->t_pos.x); + waddch(hw, MAGIC); + } + } + } + } + if (show) + { + pot_info[P_TFIND].oi_know = TRUE; + show_win(rs,"You sense the presence of magic on this level.--More--"); + } + else + msg(rs,"you have a %s feeling for a moment, then it passes", + choose_str("normal", "strange")); + when P_LSD: + if (!trip) + { + if (on(player, SEEMONST)) + turn_see(FALSE); + start_daemon(visuals, 0, BEFORE); + seenstairs = seen_stairs(); + } + do_pot(rs,P_LSD, TRUE); + when P_SEEINVIS: + sprintf(prbuf, "this potion tastes like %s juice", fruit); + show = on(player, CANSEE); + do_pot(rs,P_SEEINVIS, FALSE); + if (!show) + invis_on(); + sight(rs,0); + when P_RAISE: + pot_info[P_RAISE].oi_know = TRUE; + msg(rs,"you suddenly feel much more skillful"); + raise_level(rs); + when P_XHEAL: + pot_info[P_XHEAL].oi_know = TRUE; + if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp) + { + if (pstats.s_hpt > max_hp + pstats.s_lvl + 1) + ++max_hp; + pstats.s_hpt = ++max_hp; + } + sight(rs,0); + come_down(rs,0); + msg(rs,"you begin to feel much better"); + when P_HASTE: + pot_info[P_HASTE].oi_know = TRUE; + after = FALSE; + if (add_haste(rs,TRUE)) + msg(rs,"you feel yourself moving much faster"); + when P_RESTORE: + if (ISRING(LEFT, R_ADDSTR)) + add_str(&pstats.s_str, -cur_ring[LEFT]->o_arm); + if (ISRING(RIGHT, R_ADDSTR)) + add_str(&pstats.s_str, -cur_ring[RIGHT]->o_arm); + if (pstats.s_str < max_stats.s_str) + pstats.s_str = max_stats.s_str; + if (ISRING(LEFT, R_ADDSTR)) + add_str(&pstats.s_str, cur_ring[LEFT]->o_arm); + if (ISRING(RIGHT, R_ADDSTR)) + add_str(&pstats.s_str, cur_ring[RIGHT]->o_arm); + msg(rs,"hey, this tastes great. It make you feel warm all over"); + when P_BLIND: + do_pot(rs,P_BLIND, TRUE); + when P_LEVIT: + do_pot(rs,P_LEVIT, TRUE); +#ifdef MASTER + otherwise: + msg(rs,"what an odd tasting potion!"); + return; +#endif + } + status(rs); + /* + * Throw the item away + */ + + call_it(rs,&pot_info[obj->o_which]); + + if (discardit) + discard(obj); + return; +} + +/* + * is_magic: + * Returns true if an object radiates magic + */ +bool +is_magic(THING *obj) +{ + switch (obj->o_type) + { + case ARMOR: + return (bool)((obj->o_flags&ISPROT) || obj->o_arm != a_class[obj->o_which]); + case WEAPON: + return (bool)(obj->o_hplus != 0 || obj->o_dplus != 0); + case POTION: + case SCROLL: + case STICK: + case RING: + case AMULET: + return TRUE; + } + return FALSE; +} + +/* + * invis_on: + * Turn on the ability to see invisible + */ + +void +invis_on() +{ + THING *mp; + + player.t_flags |= CANSEE; + for (mp = mlist; mp != NULL; mp = next(mp)) + if (on(*mp, ISINVIS) && see_monst(mp) && !on(player, ISHALU)) + mvaddch(mp->t_pos.y, mp->t_pos.x, mp->t_disguise); +} + +/* + * turn_see: + * Put on or off seeing monsters on this level + */ +bool +turn_see(bool turn_off) +{ + THING *mp; + bool can_see, add_new; + + add_new = FALSE; + for (mp = mlist; mp != NULL; mp = next(mp)) + { + move(mp->t_pos.y, mp->t_pos.x); + can_see = see_monst(mp); + if (turn_off) + { + if (!can_see) + addch(mp->t_oldch); + } + else + { + if (!can_see) + standout(); + if (!on(player, ISHALU)) + addch(mp->t_type); + else + addch(rnd(26) + 'A'); + if (!can_see) + { + standend(); + add_new++; + } + } + } + if (turn_off) + player.t_flags &= ~SEEMONST; + else + player.t_flags |= SEEMONST; + return add_new; +} + +/* + * seen_stairs: + * Return TRUE if the player has seen the stairs + */ +bool +seen_stairs() +{ + THING *tp; + + move(stairs.y, stairs.x); + if (inch() == STAIRS) /* it's on the map */ + return TRUE; + if (ce(hero, stairs)) /* It's under him */ + return TRUE; + + /* + * if a monster is on the stairs, this gets hairy + */ + if ((tp = moat(stairs.y, stairs.x)) != NULL) + { + if (see_monst(tp) && on(*tp, ISRUN)) /* if it's visible and awake */ + return TRUE; /* it must have moved there */ + + if (on(player, SEEMONST) /* if she can detect monster */ + && tp->t_oldch == STAIRS) /* and there once were stairs */ + return TRUE; /* it must have moved there */ + } + return FALSE; +} + +/* + * raise_level: + * The guy just magically went up a level. + */ + +void +raise_level(struct rogue_state *rs) +{ + pstats.s_exp = e_levels[pstats.s_lvl-1] + 1L; + check_level(rs); +} + +/* + * do_pot: + * Do a potion with standard setup. This means it uses a fuse and + * turns on a flag + */ + +void +do_pot(struct rogue_state *rs,int type, bool knowit) +{ + PACT *pp; + int t; + + pp = &p_actions[type]; + if (!pot_info[type].oi_know) + pot_info[type].oi_know = knowit; + t = spread(pp->pa_time); + if (!on(player, pp->pa_flags)) + { + player.t_flags |= pp->pa_flags; + fuse(pp->pa_daemon, 0, t, AFTER); + look(rs,FALSE); + } + else + lengthen(pp->pa_daemon, t); + msg(rs,choose_str(pp->pa_high, pp->pa_straight)); +} diff --git a/src/cc/rogue/rings.c b/src/cc/rogue/rings.c new file mode 100644 index 000000000..56f7a0294 --- /dev/null +++ b/src/cc/rogue/rings.c @@ -0,0 +1,204 @@ +/* + * Routines dealing specifically with rings + * + * @(#)rings.c 4.19 (Berkeley) 05/29/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include "rogue.h" + +/* + * ring_on: + * Put a ring on a hand + */ + +void +ring_on(struct rogue_state *rs) +{ + THING *obj; + int ring; + + obj = get_item(rs,"put on", RING); + /* + * Make certain that it is somethings that we want to wear + */ + if (obj == NULL) + return; + if (obj->o_type != RING) + { + if (!terse) + msg(rs,"it would be difficult to wrap that around a finger"); + else + msg(rs,"not a ring"); + return; + } + + /* + * find out which hand to put it on + */ + if (is_current(rs,obj)) + return; + + if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) + { + if ((ring = gethand(rs)) < 0) + return; + } + else if (cur_ring[LEFT] == NULL) + ring = LEFT; + else if (cur_ring[RIGHT] == NULL) + ring = RIGHT; + else + { + if (!terse) + msg(rs,"you already have a ring on each hand"); + else + msg(rs,"wearing two"); + return; + } + cur_ring[ring] = obj; + + /* + * Calculate the effect it has on the poor guy. + */ + switch (obj->o_which) + { + case R_ADDSTR: + chg_str(obj->o_arm); + break; + case R_SEEINVIS: + invis_on(); + break; + case R_AGGR: + aggravate(rs); + break; + } + + if (!terse) + addmsg(rs,"you are now wearing "); + msg(rs,"%s (%c)", inv_name(obj, TRUE), obj->o_packch); +} + +/* + * ring_off: + * take off a ring + */ + +void +ring_off(struct rogue_state *rs) +{ + int ring; + THING *obj; + + if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) + { + if (terse) + msg(rs,"no rings"); + else + msg(rs,"you aren't wearing any rings"); + return; + } + else if (cur_ring[LEFT] == NULL) + ring = RIGHT; + else if (cur_ring[RIGHT] == NULL) + ring = LEFT; + else + if ((ring = gethand(rs)) < 0) + return; + mpos = 0; + obj = cur_ring[ring]; + if (obj == NULL) + { + msg(rs,"not wearing such a ring"); + return; + } + if (dropcheck(rs,obj)) + msg(rs,"was wearing %s(%c)", inv_name(obj, TRUE), obj->o_packch); +} + +/* + * gethand: + * Which hand is the hero interested in? + */ +int +gethand(struct rogue_state *rs) +{ + int c; + + for (;;) + { + if (terse) + msg(rs,"left or right ring? "); + else + msg(rs,"left hand or right hand? "); + if ((c = readchar(rs)) == ESCAPE) + return -1; + mpos = 0; + if (c == 'l' || c == 'L') + return LEFT; + else if (c == 'r' || c == 'R') + return RIGHT; + if (terse) + msg(rs,"L or R"); + else + msg(rs,"please type L or R"); + } +} + +/* + * ring_eat: + * How much food does this ring use up? + */ +int +ring_eat(int hand) +{ + THING *ring; + int eat; + static int uses[] = { + 1, /* R_PROTECT */ 1, /* R_ADDSTR */ + 1, /* R_SUSTSTR */ -3, /* R_SEARCH */ + -5, /* R_SEEINVIS */ 0, /* R_NOP */ + 0, /* R_AGGR */ -3, /* R_ADDHIT */ + -3, /* R_ADDDAM */ 2, /* R_REGEN */ + -2, /* R_DIGEST */ 0, /* R_TELEPORT */ + 1, /* R_STEALTH */ 1 /* R_SUSTARM */ + }; + + if ((ring = cur_ring[hand]) == NULL) + return 0; + if ((eat = uses[ring->o_which]) < 0) + eat = (rnd(-eat) == 0); + if (ring->o_which == R_DIGEST) + eat = -eat; + return eat; +} + +/* + * ring_num: + * Print ring bonuses + */ +char * +ring_num(THING *obj) +{ + static char buf[10]; + + if (!(obj->o_flags & ISKNOW)) + return ""; + switch (obj->o_which) + { + case R_PROTECT: + case R_ADDSTR: + case R_ADDDAM: + case R_ADDHIT: + sprintf(buf, " [%s]", num(obj->o_arm, 0, RING)); + otherwise: + return ""; + } + return buf; +} diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c new file mode 100644 index 000000000..6f2793615 --- /dev/null +++ b/src/cc/rogue/rip.c @@ -0,0 +1,449 @@ +/* + * File for the fun ends + * Death or a total win + * + * @(#)rip.c 4.57 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "rogue.h" +#include "score.h" + +static char *rip[] = { +" __________\n", +" / \\\n", +" / REST \\\n", +" / IN \\\n", +" / PEACE \\\n", +" / \\\n", +" | |\n", +" | |\n", +" | killed by a |\n", +" | |\n", +" | 1980 |\n", +" *| * * * | *\n", +" ________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______\n", + 0 +}; + +/* + * score: + * Figure score and post it. + */ +/* VARARGS2 */ + +void +score(int amount, int flags, char monst) +{ + SCORE *scp; + int i; + SCORE *sc2; + SCORE *top_ten, *endp; +# ifdef MASTER + int prflags = 0; +# endif + void (*fp)(int); + unsigned int uid; + static char *reason[] = { + "killed", + "quit", + "A total winner", + "killed with Amulet" + }; + + start_score(); + + if (flags >= 0 +#ifdef MASTER + || wizard +#endif + ) + { + mvaddstr(LINES - 1, 0 , "[Press return to continue]"); + refresh(); + wgetnstr(stdscr,prbuf,80); + endwin(); + printf("\n"); + resetltchars(); + /* + * free up space to "guarantee" there is space for the top_ten + */ + delwin(stdscr); + delwin(curscr); + if (hw != NULL) + delwin(hw); + } + + top_ten = (SCORE *) malloc(numscores * sizeof (SCORE)); + endp = &top_ten[numscores]; + for (scp = top_ten; scp < endp; scp++) + { + scp->sc_score = 0; + for (i = 0; i < MAXSTR; i++) + scp->sc_name[i] = (unsigned char) rnd(255); + scp->sc_flags = RN; + scp->sc_level = RN; + scp->sc_monster = (unsigned short) RN; + scp->sc_uid = RN; + } + + signal(SIGINT, SIG_DFL); + +#ifdef MASTER + if (wizard) + if (strcmp(prbuf, "names") == 0) + prflags = 1; + else if (strcmp(prbuf, "edit") == 0) + prflags = 2; +#endif + rd_score(top_ten); + /* + * Insert her in list if need be + */ + sc2 = NULL; + if (!noscore) + { + uid = md_getuid(); + for (scp = top_ten; scp < endp; scp++) + if (amount > scp->sc_score) + break; + else if (!allscore && /* only one score per nowin uid */ + flags != 2 && scp->sc_uid == uid && scp->sc_flags != 2) + scp = endp; + if (scp < endp) + { + if (flags != 2 && !allscore) + { + for (sc2 = scp; sc2 < endp; sc2++) + { + if (sc2->sc_uid == uid && sc2->sc_flags != 2) + break; + } + if (sc2 >= endp) + sc2 = endp - 1; + } + else + sc2 = endp - 1; + while (sc2 > scp) + { + *sc2 = sc2[-1]; + sc2--; + } + scp->sc_score = amount; + strncpy(scp->sc_name, whoami, MAXSTR); + scp->sc_flags = flags; + if (flags == 2) + scp->sc_level = max_level; + else + scp->sc_level = level; + scp->sc_monster = monst; + scp->sc_uid = uid; + sc2 = scp; + } + } + /* + * Print the list + */ + if (flags != -1) + putchar('\n'); + printf("Top %s %s:\n", Numname, allscore ? "Scores" : "Rogueists"); + printf(" Score Name\n"); + for (scp = top_ten; scp < endp; scp++) + { + if (scp->sc_score) { + if (sc2 == scp) + md_raw_standout(); + printf("%2d %5d %s: %s on level %d", (int) (scp - top_ten + 1), + scp->sc_score, scp->sc_name, reason[scp->sc_flags], + scp->sc_level); + if (scp->sc_flags == 0 || scp->sc_flags == 3) + printf(" by %s", killname((char) scp->sc_monster, TRUE)); +#ifdef MASTER + if (prflags == 1) + { + printf(" (%s)", md_getrealname(scp->sc_uid)); + } + else if (prflags == 2) + { + fflush(stdout); + (void) fgets(prbuf,10,stdin); + if (prbuf[0] == 'd') + { + for (sc2 = scp; sc2 < endp - 1; sc2++) + *sc2 = *(sc2 + 1); + sc2 = endp - 1; + sc2->sc_score = 0; + for (i = 0; i < MAXSTR; i++) + sc2->sc_name[i] = (char) rnd(255); + sc2->sc_flags = RN; + sc2->sc_level = RN; + sc2->sc_monster = (unsigned short) RN; + scp--; + } + } + else +#endif /* MASTER */ + printf("."); + if (sc2 == scp) + md_raw_standend(); + putchar('\n'); + } + else + break; + } + /* + * Update the list file + */ + if (sc2 != NULL) + { + if (lock_sc()) + { + fp = signal(SIGINT, SIG_IGN); + wr_score(top_ten); + unlock_sc(); + signal(SIGINT, fp); + } + } +} + +/* + * death: + * Do something really fun when he dies + */ + +void +death(char monst) +{ + char **dp, *killer; + struct tm *lt; + static time_t date; + //struct tm *localtime(const time_t *); + + signal(SIGINT, SIG_IGN); + purse -= purse / 10; + signal(SIGINT, leave); + clear(); + killer = killname(monst, FALSE); + if (!tombstone) + { + mvprintw(LINES - 2, 0, "Killed by "); + killer = killname(monst, FALSE); + if (monst != 's' && monst != 'h') + printw("a%s ", vowelstr(killer)); + printw("%s with %d gold", killer, purse); + } + else + { + time(&date); + lt = localtime(&date); + move(8, 0); + dp = rip; + while (*dp) + addstr(*dp++); + mvaddstr(17, center(killer), killer); + if (monst == 's' || monst == 'h') + mvaddch(16, 32, ' '); + else + mvaddstr(16, 33, vowelstr(killer)); + mvaddstr(14, center(whoami), whoami); + sprintf(prbuf, "%d Au", purse); + move(15, center(prbuf)); + addstr(prbuf); + sprintf(prbuf, "%4d", 1900+lt->tm_year); + mvaddstr(18, 26, prbuf); + } + move(LINES - 1, 0); + refresh(); + score(purse, amulet ? 3 : 0, monst); + printf("[Press return to continue]"); + fflush(stdout); + (void) fgets(prbuf,10,stdin); + my_exit(0); +} + +/* + * center: + * Return the index to center the given string + */ +int +center(char *str) +{ + return 28 - (((int)strlen(str) + 1) / 2); +} + +/* + * total_winner: + * Code for a winner + */ + +void +total_winner(struct rogue_state *rs) +{ + THING *obj; + struct obj_info *op; + int worth = 0; + int oldpurse; + + clear(); + standout(); + addstr(" \n"); + addstr(" @ @ @ @ @ @@@ @ @ \n"); + addstr(" @ @ @@ @@ @ @ @ @ \n"); + addstr(" @ @ @@@ @ @ @ @ @ @@@ @@@@ @@@ @ @@@ @ \n"); + addstr(" @@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ \n"); + addstr(" @ @ @ @ @ @ @ @@@@ @ @ @@@@@ @ @ @ \n"); + addstr(" @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ \n"); + addstr(" @@@ @@@ @@ @ @ @ @@@@ @@@@ @@@ @@@ @@ @ \n"); + addstr(" \n"); + addstr(" Congratulations, you have made it to the light of day! \n"); + standend(); + addstr("\nYou have joined the elite ranks of those who have escaped the\n"); + addstr("Dungeons of Doom alive. You journey home and sell all your loot at\n"); + addstr("a great profit and are admitted to the Fighters' Guild.\n"); + mvaddstr(LINES - 1, 0, "--Press space to continue--"); + refresh(); + wait_for(rs,' '); + clear(); + mvaddstr(0, 0, " Worth Item\n"); + oldpurse = purse; + for (obj = pack; obj != NULL; obj = next(obj)) + { + switch (obj->o_type) + { + case FOOD: + worth = 2 * obj->o_count; + when WEAPON: + worth = weap_info[obj->o_which].oi_worth; + worth *= 3 * (obj->o_hplus + obj->o_dplus) + obj->o_count; + obj->o_flags |= ISKNOW; + when ARMOR: + worth = arm_info[obj->o_which].oi_worth; + worth += (9 - obj->o_arm) * 100; + worth += (10 * (a_class[obj->o_which] - obj->o_arm)); + obj->o_flags |= ISKNOW; + when SCROLL: + worth = scr_info[obj->o_which].oi_worth; + worth *= obj->o_count; + op = &scr_info[obj->o_which]; + if (!op->oi_know) + worth /= 2; + op->oi_know = TRUE; + when POTION: + worth = pot_info[obj->o_which].oi_worth; + worth *= obj->o_count; + op = &pot_info[obj->o_which]; + if (!op->oi_know) + worth /= 2; + op->oi_know = TRUE; + when RING: + op = &ring_info[obj->o_which]; + worth = op->oi_worth; + if (obj->o_which == R_ADDSTR || obj->o_which == R_ADDDAM || + obj->o_which == R_PROTECT || obj->o_which == R_ADDHIT) + { + if (obj->o_arm > 0) + worth += obj->o_arm * 100; + else + worth = 10; + } + if (!(obj->o_flags & ISKNOW)) + worth /= 2; + obj->o_flags |= ISKNOW; + op->oi_know = TRUE; + when STICK: + op = &ws_info[obj->o_which]; + worth = op->oi_worth; + worth += 20 * obj->o_charges; + if (!(obj->o_flags & ISKNOW)) + worth /= 2; + obj->o_flags |= ISKNOW; + op->oi_know = TRUE; + when AMULET: + worth = 1000; + } + if (worth < 0) + worth = 0; + printw("%c) %5d %s\n", obj->o_packch, worth, inv_name(obj, FALSE)); + purse += worth; + } + printw(" %5d Gold Pieces ", oldpurse); + refresh(); + score(purse, 2, ' '); + my_exit(0); +} + +/* + * killname: + * Convert a code to a monster name + */ +char * +killname(char monst, bool doart) +{ + struct h_list *hp; + char *sp; + bool article; + static struct h_list nlist[] = { + {'a', "arrow", TRUE}, + {'b', "bolt", TRUE}, + {'d', "dart", TRUE}, + {'h', "hypothermia", FALSE}, + {'s', "starvation", FALSE}, + {'\0'} + }; + + if (isupper(monst)) + { + sp = monsters[monst-'A'].m_name; + article = TRUE; + } + else + { + sp = "Wally the Wonder Badger"; + article = FALSE; + for (hp = nlist; hp->h_ch; hp++) + if (hp->h_ch == monst) + { + sp = hp->h_desc; + article = hp->h_print; + break; + } + } + if (doart && article) + sprintf(prbuf, "a%s ", vowelstr(sp)); + else + prbuf[0] = '\0'; + strcat(prbuf, sp); + return prbuf; +} + +/* + * death_monst: + * Return a monster appropriate for a random death. + */ +char +death_monst() +{ + static char poss[] = + { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'h', 'd', 's', + ' ' /* This is provided to generate the "Wally the Wonder Badger" + message for killer */ + }; + + return poss[rnd(sizeof poss / sizeof (char))]; +} diff --git a/src/cc/rogue/rogue.6 b/src/cc/rogue/rogue.6 new file mode 100644 index 000000000..6b63252ab --- /dev/null +++ b/src/cc/rogue/rogue.6 @@ -0,0 +1,96 @@ +.\" +.\" @(#)rogue.6 6.2 (Berkeley) 5/6/86 +.\" +.\" Rogue: Exploring the Dungeons of Doom +.\" Copyright (C) 1980-1983, 1985, 1986 Michael Toy, Ken Arnold and Glenn Wichman +.\" All rights reserved. +.\" +.\" See the file LICENSE.TXT for full copyright and licensing information. +.\" +.TH ROGUE 6 "May 6, 1986" +.UC 4 +.SH NAME +rogue \- Exploring The Dungeons of Doom +.SH SYNOPSIS +.B rogue +[ +.B \-r +] +[ +.I save_file +] +[ +.B \-s +] +[ +.B \-d +] +.SH DESCRIPTION +.PP +.I Rogue +is a computer fantasy game with a new twist. It is crt oriented and the +object of the game is to survive the attacks of various monsters and get +a lot of gold, rather than the puzzle solving orientation of most computer +fantasy games. +.PP +To get started you really only need to know two commands. The command +.B ? +will give you a list of the available commands and the command +.B / +will identify the things you see on the screen. +.PP +To win the game (as opposed to merely playing to beat other people's high +scores) you must locate the Amulet of Yendor which is somewhere below +the 20th level of the dungeon and get it out. Nobody has achieved this +yet and if somebody does, they will probably go down in history as a hero +among heroes. +.PP +When the game ends, either by your death, when you quit, or if you (by +some miracle) manage to win, +.I rogue +will give you a list of the top-ten scorers. The scoring is based entirely +upon how much gold you get. There is a 10% penalty for getting yourself +killed. +.PP +If +.I save_file +is specified, +rogue will be restored from the specified saved game file. +If the +.B \-r +option is used, the save game file is presumed to be the default. +.PP +The +.B \-s +option will print out the list of scores. +.PP +The +.B \-d +option will kill you and try to add you to the score file. +.PP +For more detailed directions, read the document +.I "A Guide to the Dungeons of Doom." +.SH AUTHORS +Michael C. Toy, +Kenneth C. R. C. Arnold, +Glenn Wichman +.SH FILES +.DT +.ta \w'rogue.scr\ \ \ 'u +rogue.scr Score file +.br +\fB~\fP/rogue.save Default save file +.SH SEE ALSO +Michael C. Toy +and +Kenneth C. R. C. Arnold, +.I "A guide to the Dungeons of Doom" +.SH BUGS +.PP +Probably infinite +(although countably infinite). +However, +that Ice Monsters sometimes transfix you permanently is +.I not +a bug. +It's a feature. diff --git a/src/cc/rogue/rogue.6.in b/src/cc/rogue/rogue.6.in new file mode 100644 index 000000000..a9d6d9903 --- /dev/null +++ b/src/cc/rogue/rogue.6.in @@ -0,0 +1,96 @@ +.\" +.\" @(#)rogue.6 6.2 (Berkeley) 5/6/86 +.\" +.\" Rogue: Exploring the Dungeons of Doom +.\" Copyright (C) 1980-1983, 1985, 1986 Michael Toy, Ken Arnold and Glenn Wichman +.\" All rights reserved. +.\" +.\" See the file LICENSE.TXT for full copyright and licensing information. +.\" +.TH ROGUE 6 "May 6, 1986" +.UC 4 +.SH NAME +rogue \- Exploring The Dungeons of Doom +.SH SYNOPSIS +.B @PROGRAM@ +[ +.B \-r +] +[ +.I save_file +] +[ +.B \-s +] +[ +.B \-d +] +.SH DESCRIPTION +.PP +.I Rogue +is a computer fantasy game with a new twist. It is crt oriented and the +object of the game is to survive the attacks of various monsters and get +a lot of gold, rather than the puzzle solving orientation of most computer +fantasy games. +.PP +To get started you really only need to know two commands. The command +.B ? +will give you a list of the available commands and the command +.B / +will identify the things you see on the screen. +.PP +To win the game (as opposed to merely playing to beat other people's high +scores) you must locate the Amulet of Yendor which is somewhere below +the 20th level of the dungeon and get it out. Nobody has achieved this +yet and if somebody does, they will probably go down in history as a hero +among heroes. +.PP +When the game ends, either by your death, when you quit, or if you (by +some miracle) manage to win, +.I rogue +will give you a list of the top-ten scorers. The scoring is based entirely +upon how much gold you get. There is a 10% penalty for getting yourself +killed. +.PP +If +.I save_file +is specified, +rogue will be restored from the specified saved game file. +If the +.B \-r +option is used, the save game file is presumed to be the default. +.PP +The +.B \-s +option will print out the list of scores. +.PP +The +.B \-d +option will kill you and try to add you to the score file. +.PP +For more detailed directions, read the document +.I "A Guide to the Dungeons of Doom." +.SH AUTHORS +Michael C. Toy, +Kenneth C. R. C. Arnold, +Glenn Wichman +.SH FILES +.DT +.ta \w'@SCOREFILE@\ \ \ 'u +@SCOREFILE@ Score file +.br +\fB~\fP/rogue.save Default save file +.SH SEE ALSO +Michael C. Toy +and +Kenneth C. R. C. Arnold, +.I "A guide to the Dungeons of Doom" +.SH BUGS +.PP +Probably infinite +(although countably infinite). +However, +that Ice Monsters sometimes transfix you permanently is +.I not +a bug. +It's a feature. diff --git a/src/cc/rogue/rogue.777.0 b/src/cc/rogue/rogue.777.0 new file mode 100644 index 000000000..e56f7b148 --- /dev/null +++ b/src/cc/rogue/rogue.777.0 @@ -0,0 +1 @@ +llllljhhl jllllllllllllllllllkkllllklllljllljjllllllllllll \ No newline at end of file diff --git a/src/cc/rogue/rogue.777.1 b/src/cc/rogue/rogue.777.1 new file mode 100644 index 000000000..68b8ab099 --- /dev/null +++ b/src/cc/rogue/rogue.777.1 @@ -0,0 +1 @@ +hhhhhhhhhhkkhhhhhhhhhhhhhjjhhhhhhhhjjjjjjjjjlllllllllllllk \ No newline at end of file diff --git a/src/cc/rogue/rogue.777.2 b/src/cc/rogue/rogue.777.2 new file mode 100644 index 000000000..93a664d1e --- /dev/null +++ b/src/cc/rogue/rogue.777.2 @@ -0,0 +1 @@ +lllljjllllll l ll lll l lll l ll l ljjj j j jhhhhhjjllllll \ No newline at end of file diff --git a/src/cc/rogue/rogue.777.3 b/src/cc/rogue/rogue.777.3 new file mode 100644 index 000000000..e69de29bb diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c new file mode 100644 index 000000000..d463ddc49 --- /dev/null +++ b/src/cc/rogue/rogue.c @@ -0,0 +1,534 @@ +/* + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + * + * @(#)main.c 4.22 (Berkeley) 02/05/99 + */ + +#include +#include +#include +#include +#include +#include +#include "rogue.h" + +/* + * main: + * The main program, of course + */ +struct rogue_state globalR; + +void rogueiterate(struct rogue_state *rs) +{ + seed = rs->seed; + + initscr(); /* Start up cursor package */ + init_probs(); /* Set up prob tables for objects */ + init_player(rs); /* Set up initial player stats */ + init_names(); /* Set up names of scrolls */ + init_colors(); /* Set up colors of potions */ + init_stones(); /* Set up stone settings of rings */ + init_materials(); /* Set up materials of wands */ + setup(); + + /* + * The screen must be at least NUMLINES x NUMCOLS + */ + if (LINES < NUMLINES || COLS < NUMCOLS) + { + printf("\nSorry, the screen must be at least %dx%d\n", NUMLINES, NUMCOLS); + endwin(); + my_exit(1); + } + // Set up windows + hw = newwin(LINES, COLS, 0, 0); + idlok(stdscr, TRUE); + idlok(hw, TRUE); +#ifdef MASTER + noscore = wizard; +#endif + new_level(rs); // Draw current level + // Start up daemons and fuses + start_daemon(runners, 0, AFTER); + start_daemon(doctor, 0, AFTER); + fuse(swander, 0, WANDERTIME, AFTER); + start_daemon(stomach, 0, AFTER); + playit(rs); +} + +int32_t roguefname(char *fname,uint64_t seed,int32_t counter) +{ + sprintf(fname,"rogue.%llu.%d",(long long)seed,counter); + return(0); +} + +int32_t flushkeystrokes(struct rogue_state *rs) +{ + char fname[1024]; FILE *fp; int32_t i,retflag = -1; + roguefname(fname,rs->seed,rs->counter); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num ) + { + rs->counter++; + rs->num = 0; + retflag = 0; + fclose(fp); + if ( (fp= fopen("savefile","wb")) != 0 ) + { + save_file(fp,0); + if ( 0 && (fp= fopen("savefile","rb")) != 0 ) + { + for (i=0; i<0x150; i++) + fprintf(stderr,"%02x",fgetc(fp)); + fprintf(stderr," first part rnd.%d\n",rnd(1000)); + fclose(fp); + } + roguefname(fname,rs->seed,rs->counter); + if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file + fclose(fp); + //fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag); + } + } else fprintf(stderr,"error writing (%s)\n",fname); + } else fprintf(stderr,"error creating (%s)\n",fname); + return(retflag); +} + +long get_filesize(FILE *fp) +{ + long fsize,fpos = ftell(fp); + fseek(fp,0,SEEK_END); + fsize = ftell(fp); + fseek(fp,fpos,SEEK_SET); + return(fsize); +} + +int32_t rogue_replay(uint64_t seed) +{ + FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; + while ( 1 ) + { + roguefname(fname,seed,counter); + if ( (fp= fopen(fname,"rb")) == 0 ) + break; + if ( (fsize= get_filesize(fp)) <= 0 ) + { + fclose(fp); + break; + } + if ( (keystrokes= (char *)realloc(keystrokes,num+fsize)) == 0 ) + { + fprintf(stderr,"error reallocating keystrokes\n"); + fclose(fp); + return(-1); + } + if ( fread(&keystrokes[num],1,fsize,fp) != fsize ) + { + fprintf(stderr,"error reading keystrokes from (%s)\n",fname); + fclose(fp); + return(-1); + } + fclose(fp); + num += fsize; + counter++; + fprintf(stderr,"loaded %ld from (%s) total %ld\n",fsize,fname,num); + } + if ( num > 0 ) + { + rs = calloc(1,sizeof(*rs)); + rs->seed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rogueiterate(rs); + if ( (fp= fopen("checkfile","wb")) != 0 ) + { + save_file(fp,0); + fclose(fp); + if ( 0 && (fp= fopen("checkfile","rb")) != 0 ) + { + for (i=0; i<0x150; i++) + fprintf(stderr,"%02x",fgetc(fp)); + fprintf(stderr," first part rnd.%d\n",rnd(1000)); + fclose(fp); + } + } + fatal("finished replay\n"); + } + if ( keystrokes != 0 ) + free(keystrokes); + return(num); +} + +int rogue(int argc, char **argv, char **envp) +{ + char *env; int lowtime; struct rogue_state *rs = &globalR; + memset(rs,0,sizeof(*rs)); + rs->seed = 777; + rs->guiflag = 1; + md_init(); + +#ifdef MASTER + /* + * Check to see if he is a wizard + */ + if (argc >= 2 && argv[1][0] == '\0') + if (strcmp(PASSWD, md_crypt(md_getpass("wizard's password: "), "mT")) == 0) + { + wizard = TRUE; + player.t_flags |= SEEMONST; + argv++; + argc--; + } + +#endif + + /* + * get home and options from environment + */ + + strncpy(home, md_gethomedir(), MAXSTR); + + strcpy(file_name, home); + strcat(file_name, "rogue.save"); + + if ((env = getenv("ROGUEOPTS")) != NULL) + parse_opts(env); + if (env == NULL || whoami[0] == '\0') + strucpy(whoami, md_getusername(), (int) strlen(md_getusername())); + lowtime = (int) time(NULL); +#ifdef MASTER + if (wizard && getenv("SEED") != NULL) + dnum = atoi(getenv("SEED")); + else +#endif + dnum = lowtime + md_getpid(); + if ( rs != 0 ) + seed = rs->seed; + else seed = 777; + dnum = (int)seed; + + open_score(); + + /* + * Drop setuid/setgid after opening the scoreboard file. + */ + + md_normaluser(); + + /* + * check for print-score option + */ + + md_normaluser(); /* we drop any setgid/setuid priveldges here */ + + if (argc == 2) + { + if (strcmp(argv[1], "-s") == 0) + { + noscore = TRUE; + score(0, -1, 0); + exit(0); + } + else if (strcmp(argv[1], "-d") == 0) + { + dnum = rnd(100); /* throw away some rnd()s to break patterns */ + while (--dnum) + rnd(100); + purse = rnd(100) + 1; + level = rnd(100) + 1; + initscr(); + getltchars(); + death(death_monst()); + exit(0); + } + } + + init_check(); /* check for legal startup */ + if (argc == 2) + if (!restore(rs,argv[1], envp)) /* Note: restore will never return */ + my_exit(1); +#ifdef MASTER + if (wizard) + printf("Hello %s, welcome to dungeon #%d", whoami, dnum); + else +#endif + printf("Hello %s, just a moment while I dig the dungeon... seed.%llu", whoami,(long long)rs->seed); + fflush(stdout); + + rogueiterate(rs); + return(0); +} + +/* + * endit: + * Exit the program abnormally. + */ + +void +endit(int sig) +{ + NOOP(sig); + fatal("Okay, bye bye!\n"); +} + +/* + * fatal: + * Exit the program, printing a message. + */ + +void +fatal(char *s) +{ + mvaddstr(LINES - 2, 0, s); + refresh(); + endwin(); + my_exit(0); +} + +/* + * rnd: + * Pick a very random number. + */ +int +rnd(int range) +{ + return range == 0 ? 0 : abs((int) RN) % range; +} + +/* + * roll: + * Roll a number of dice + */ +int +roll(int number, int sides) +{ + int dtotal = 0; + + while (number--) + dtotal += rnd(sides)+1; + return dtotal; +} + +/* + * tstp: + * Handle stop and start signals + */ + +void +tstp(int ignored) +{ + int y, x; + int oy, ox; + + NOOP(ignored); + + /* + * leave nicely + */ + getyx(curscr, oy, ox); + mvcur(0, COLS - 1, LINES - 1, 0); + endwin(); + resetltchars(); + fflush(stdout); + md_tstpsignal(); + + /* + * start back up again + */ + md_tstpresume(); + raw(); + noecho(); + keypad(stdscr,1); + playltchars(); + clearok(curscr, TRUE); + wrefresh(curscr); + getyx(curscr, y, x); + mvcur(y, x, oy, ox); + fflush(stdout); + //wmove(curscr,oy,ox); +#ifndef __APPLE__ + curscr->_cury = oy; + curscr->_curx = ox; +#endif +} + +/* + * playit: + * The main loop of the program. Loop until the game is over, + * refreshing things and looking at the proper times. + */ + +void +playit(struct rogue_state *rs) +{ + char *opts; + + /* + * set up defaults for slow terminals + */ + + if (baudrate() <= 1200) + { + terse = TRUE; + jump = TRUE; + see_floor = FALSE; + } + + if (md_hasclreol()) + inv_type = INV_CLEAR; + + /* + * parse environment declaration of options + */ + if ((opts = getenv("ROGUEOPTS")) != NULL) + parse_opts(opts); + + + oldpos = hero; + oldrp = roomin(rs,&hero); + while (playing) + { + command(rs); // Command execution + if ( rs->guiflag == 0 ) + { + if ( rs->replaydone != 0 ) + { + //fprintf(stderr,"replaydone\n"); sleep(3); + return; + } + //usleep(100000); + } + else + { + if ( rs->needflush != 0 ) + { + if ( flushkeystrokes(rs) == 0 ) + rs->needflush = 0; + } + } + } + endit(0); +} + +/* + * quit: + * Have player make certain, then exit. + */ + +void +quit(int sig) +{ + struct rogue_state *rs = &globalR; + int oy, ox; + + NOOP(sig); + + /* + * Reset the signal in case we got here via an interrupt + */ + if (!q_comm) + mpos = 0; + getyx(curscr, oy, ox); + msg(rs,"really quit?"); + if (readchar(rs) == 'y') + { + signal(SIGINT, leave); + clear(); + mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse); + move(LINES - 1, 0); + refresh(); + score(purse, 1, 0); + my_exit(0); + } + else + { + move(0, 0); + clrtoeol(); + status(rs); + move(oy, ox); + refresh(); + mpos = 0; + count = 0; + to_death = FALSE; + } +} + +/* + * leave: + * Leave quickly, but curteously + */ + +void +leave(int sig) +{ + static char buf[BUFSIZ]; + + NOOP(sig); + + setbuf(stdout, buf); /* throw away pending output */ + + if (!isendwin()) + { + mvcur(0, COLS - 1, LINES - 1, 0); + endwin(); + } + + putchar('\n'); + my_exit(0); +} + +/* + * shell: + * Let them escape for a while + */ + +void +shell(struct rogue_state *rs) +{ + if ( rs != 0 && rs->guiflag != 0 ) + { + /* + * Set the terminal back to original mode + */ + move(LINES-1, 0); + refresh(); + endwin(); + resetltchars(); + putchar('\n'); + in_shell = TRUE; + after = FALSE; + fflush(stdout); + /* + * Fork and do a shell + */ + md_shellescape(); + + printf("\n[Press return to continue]"); + fflush(stdout); + noecho(); + raw(); + keypad(stdscr,1); + playltchars(); + in_shell = FALSE; + wait_for(rs,'\n'); + clearok(stdscr, TRUE); + } + else fprintf(stderr,"no shell in the blockchain\n"); +} + +/* + * my_exit: + * Leave the process properly + */ + +void +my_exit(int st) +{ + resetltchars(); + exit(st); +} + diff --git a/src/cc/rogue/rogue.cat b/src/cc/rogue/rogue.cat new file mode 100644 index 000000000..66d9605a2 --- /dev/null +++ b/src/cc/rogue/rogue.cat @@ -0,0 +1,61 @@ +ROGUE(6) ROGUE(6) + + + +NAME + rogue - Exploring The Dungeons of Doom + +SYNOPSIS + rogue [ -r ] [ save_file ] [ -s ] [ -d ] + +DESCRIPTION + Rogue is a computer fantasy game with a new twist. It is crt oriented + and the object of the game is to survive the attacks of various mon- + sters and get a lot of gold, rather than the puzzle solving orientation + of most computer fantasy games. + + To get started you really only need to know two commands. The command + ? will give you a list of the available commands and the command / + will identify the things you see on the screen. + + To win the game (as opposed to merely playing to beat other people's + high scores) you must locate the Amulet of Yendor which is somewhere + below the 20th level of the dungeon and get it out. Nobody has + achieved this yet and if somebody does, they will probably go down in + history as a hero among heroes. + + When the game ends, either by your death, when you quit, or if you (by + some miracle) manage to win, rogue will give you a list of the top-ten + scorers. The scoring is based entirely upon how much gold you get. + There is a 10% penalty for getting yourself killed. + + If save_file is specified, rogue will be restored from the specified + saved game file. If the -r option is used, the save game file is pre- + sumed to be the default. + + The -s option will print out the list of scores. + + The -d option will kill you and try to add you to the score file. + + For more detailed directions, read the document A Guide to the Dungeons + of Doom. + +AUTHORS + Michael C. Toy, Kenneth C. R. C. Arnold, Glenn Wichman + +FILES + rogue.scr Score file + ~/rogue.save Default save file + +SEE ALSO + Michael C. Toy and Kenneth C. R. C. Arnold, A guide to the Dungeons of + Doom + +BUGS + Probably infinite (although countably infinite). However, that Ice + Monsters sometimes transfix you permanently is not a bug. It's a fea- + ture. + + + +4th Berkeley Distribution May 6, 1986 ROGUE(6) diff --git a/src/cc/rogue/rogue.cat.in b/src/cc/rogue/rogue.cat.in new file mode 100644 index 000000000..8dbef73c1 --- /dev/null +++ b/src/cc/rogue/rogue.cat.in @@ -0,0 +1,61 @@ +ROGUE(6) ROGUE(6) + + + +NAME + rogue - Exploring The Dungeons of Doom + +SYNOPSIS + @PROGRAM@ [ -r ] [ save_file ] [ -s ] [ -d ] + +DESCRIPTION + Rogue is a computer fantasy game with a new twist. It is crt oriented + and the object of the game is to survive the attacks of various mon- + sters and get a lot of gold, rather than the puzzle solving orientation + of most computer fantasy games. + + To get started you really only need to know two commands. The command + ? will give you a list of the available commands and the command / + will identify the things you see on the screen. + + To win the game (as opposed to merely playing to beat other people's + high scores) you must locate the Amulet of Yendor which is somewhere + below the 20th level of the dungeon and get it out. Nobody has + achieved this yet and if somebody does, they will probably go down in + history as a hero among heroes. + + When the game ends, either by your death, when you quit, or if you (by + some miracle) manage to win, rogue will give you a list of the top-ten + scorers. The scoring is based entirely upon how much gold you get. + There is a 10% penalty for getting yourself killed. + + If save_file is specified, rogue will be restored from the specified + saved game file. If the -r option is used, the save game file is pre- + sumed to be the default. + + The -s option will print out the list of scores. + + The -d option will kill you and try to add you to the score file. + + For more detailed directions, read the document A Guide to the Dungeons + of Doom. + +AUTHORS + Michael C. Toy, Kenneth C. R. C. Arnold, Glenn Wichman + +FILES + @SCOREFILE@ Score file + ~/rogue.save Default save file + +SEE ALSO + Michael C. Toy and Kenneth C. R. C. Arnold, A guide to the Dungeons of + Doom + +BUGS + Probably infinite (although countably infinite). However, that Ice + Monsters sometimes transfix you permanently is not a bug. It's a fea- + ture. + + + +4th Berkeley Distribution May 6, 1986 ROGUE(6) diff --git a/src/cc/rogue/rogue.desktop b/src/cc/rogue/rogue.desktop new file mode 100644 index 000000000..74f9518c7 --- /dev/null +++ b/src/cc/rogue/rogue.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Rogue +GenericName=Rogue +Comment=The original curses-based adventure game +Exec=rogue +Icon=rogue.png +Terminal=true +Type=Application +Categories=Game;RolePlaying; +Version=1.0 diff --git a/src/cc/rogue/rogue.doc b/src/cc/rogue/rogue.doc new file mode 100644 index 000000000..684738d11 --- /dev/null +++ b/src/cc/rogue/rogue.doc @@ -0,0 +1,858 @@ + + + + + + + + A Guide to the Dungeons of Doom + + + Michael C. Toy + Kenneth C. R. C. Arnold + + + Computer Systems Research Group + Department of Electrical Engineering and Computer Science + University of California + Berkeley, California 94720 + + + + + ABSTRACT + + Rogue is a visual CRT based fantasy game which runs + under the UNIX timesharing system. This paper de- + scribes how to play rogue, and gives a few hints for + those who might otherwise get lost in the Dungeons + of Doom. + + + + +1. Introduction + + You have just finished your years as a student at the +local fighter's guild. After much practice and sweat you +have finally completed your training and are ready to embark +upon a perilous adventure. As a test of your skills, the +local guildmasters have sent you into the Dungeons of Doom. +Your task is to return with the Amulet of Yendor. Your +reward for the completion of this task will be a full mem- +bership in the local guild. In addition, you are allowed to +keep all the loot you bring back from the dungeons. + + In preparation for your journey, you are given an +enchanted mace, a bow, and a quiver of arrows taken from a +dragon's hoard in the far off Dark Mountains. You are also +outfitted with elf-crafted armor and given enough food to +reach the dungeons. You say goodbye to family and friends +for what may be the last time and head up the road. + + You set out on your way to the dungeons and after sev- +eral days of uneventful travel, you see the ancient ruins +that mark the entrance to the Dungeons of Doom. It is late +at night, so you make camp at the entrance and spend the +____________________ + UNIX is a trademark of Bell Laboratories + + + + + + + + + + + + +USD:33-2 A Guide to the Dungeons of Doom + + +night sleeping under the open skies. In the morning you +gather your weapons, put on your armor, eat what is almost +your last food, and enter the dungeons. + +2. What is going on here? + + You have just begun a game of rogue. Your goal is to +grab as much treasure as you can, find the Amulet of Yendor, +and get out of the Dungeons of Doom alive. On the screen, a +map of where you have been and what you have seen on the +current dungeon level is kept. As you explore more of the +level, it appears on the screen in front of you. + + Rogue differs from most computer fantasy games in that +it is screen oriented. Commands are all one or two +keystrokes1 and the results of your commands are displayed +graphically on the screen rather than being explained in +words.2 + + Another major difference between rogue and other com- +puter fantasy games is that once you have solved all the +puzzles in a standard fantasy game, it has lost most of its +excitement and it ceases to be fun. Rogue, on the other +hand, generates a new dungeon every time you play it and +even the author finds it an entertaining and exciting game. + +3. What do all those things on the screen mean? + + In order to understand what is going on in rogue you +have to first get some grasp of what rogue is doing with the +screen. The rogue screen is intended to replace the "You +can see ..." descriptions of standard fantasy games. Figure +1 is a sample of what a rogue screen might look like. + +3.1. The bottom line + + At the bottom line of the screen are a few pieces of +cryptic information describing your current status. Here is +an explanation of what these things mean: + +Level This number indicates how deep you have gone in the + dungeon. It starts at one and goes up as you go + deeper into the dungeon. + +Gold The number of gold pieces you have managed to find + and keep with you so far. +____________________ + 1 As opposed to pseudo English sentences. + 2 A minimum screen size of 24 lines by 80 columns is re- +quired. If the screen is larger, only the 24x80 section +will be used for the map. + + + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-3 + + + +____________________________________________________________ + + + ------------ + |..........+ + |..@....]..| + |....B.....| + |..........| + -----+------ + + + +Level: 1 Gold: 0 Hp: 12(12) Str: 16(16) Arm: 4 Exp: 1/0 + + Figure 1 +____________________________________________________________ + + +Hp Your current and maximum health points. Health + points indicate how much damage you can take before + you die. The more you get hit in a fight, the lower + they get. You can regain health points by resting. + The number in parentheses is the maximum number your + health points can reach. + +Str Your current strength and maximum ever strength. + This can be any integer less than or equal to 31, or + greater than or equal to three. The higher the num- + ber, the stronger you are. The number in the paren- + theses is the maximum strength you have attained so + far this game. + +Arm Your current armor protection. This number indicates + how effective your armor is in stopping blows from + unfriendly creatures. The higher this number is, the + more effective the armor. + +Exp These two numbers give your current experience level + and experience points. As you do things, you gain + experience points. At certain experience point + totals, you gain an experience level. The more expe- + rienced you are, the better you are able to fight and + to withstand magical attacks. + +3.2. The top line + + The top line of the screen is reserved for printing +messages that describe things that are impossible to repre- +sent visually. If you see a "--More--" on the top line, +this means that rogue wants to print another message on the +screen, but it wants to make certain that you have read the +one that is there first. To read the next message, just + + + + + + + + + + +USD:33-4 A Guide to the Dungeons of Doom + + +type a space. + +3.3. The rest of the screen + + The rest of the screen is the map of the level as you +have explored it so far. Each symbol on the screen repre- +sents something. Here is a list of what the various symbols +mean: + +@ This symbol represents you, the adventurer. + +-| These symbols represent the walls of rooms. + ++ A door to/from a room. + +. The floor of a room. + +# The floor of a passage between rooms. + +* A pile or pot of gold. + +) A weapon of some sort. + +] A piece of armor. + +! A flask containing a magic potion. + +? A piece of paper, usually a magic scroll. + += A ring with magic properties + +/ A magical staff or wand + +^ A trap, watch out for these. + +% A staircase to other levels + +: A piece of food. + +A-Z The uppercase letters represent the various inhabitants + of the Dungeons of Doom. Watch out, they can be nasty + and vicious. + +4. Commands + + Commands are given to rogue by typing one or two char- +acters. Most commands can be preceded by a count to repeat +them (e.g. typing "10s" will do ten searches). Commands for +which counts make no sense have the count ignored. To can- +cel a count or a prefix, type . The list of com- +mands is rather long, but it can be read at any time during +the game with the "?" command. Here it is for reference, +with a short explanation of each command. + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-5 + + +? The help command. Asks for a character to give help + on. If you type a "*", it will list all the commands, + otherwise it will explain what the character you typed + does. + +/ This is the "What is that on the screen?" command. A + "/" followed by any character that you see on the + level, will tell you what that character is. For + instance, typing "/@" will tell you that the "@" symbol + represents you, the player. + +h, H, ^H + Move left. You move one space to the left. If you use + upper case "h", you will continue to move left until + you run into something. This works for all movement + commands (e.g. "L" means run in direction "l") If you + use the "control" "h", you will continue moving in the + specified direction until you pass something interest- + ing or run into a wall. You should experiment with + this, since it is a very useful command, but very dif- + ficult to describe. This also works for all movement + commands. + +j Move down. + +k Move up. + +l Move right. + +y Move diagonally up and left. + +u Move diagonally up and right. + +b Move diagonally down and left. + +n Move diagonally down and right. + +t Throw an object. This is a prefix command. When fol- + lowed with a direction it throws an object in the spec- + ified direction. (e.g. type "th" to throw something to + the left.) + +f Fight until someone dies. When followed with a direc- + tion this will force you to fight the creature in that + direction until either you or it bites the big one. + +m Move onto something without picking it up. This will + move you one space in the direction you specify and, if + there is an object there you can pick up, it won't do + it. + +z Zap prefix. Point a staff or wand in a given direction + and fire it. Even non-directional staves must be + + + + + + + + + + +USD:33-6 A Guide to the Dungeons of Doom + + + pointed in some direction to be used. + +^ Identify trap command. If a trap is on your map and + you can't remember what type it is, you can get rogue + to remind you by getting next to it and typing "^" fol- + lowed by the direction that would move you on top of + it. + +s Search for traps and secret doors. Examine each space + immediately adjacent to you for the existence of a trap + or secret door. There is a large chance that even if + there is something there, you won't find it, so you + might have to search a while before you find something. + +> Climb down a staircase to the next level. Not surpris- + ingly, this can only be done if you are standing on + staircase. + +< Climb up a staircase to the level above. This can't be + done without the Amulet of Yendor in your possession. + +. Rest. This is the "do nothing" command. This is good + for waiting and healing. + +, Pick up something. This picks up whatever you are cur- + rently standing on, if you are standing on anything at + all. + +i Inventory. List what you are carrying in your pack. + +I Selective inventory. Tells you what a single item in + your pack is. + +q Quaff one of the potions you are carrying. + +r Read one of the scrolls in your pack. + +e Eat food from your pack. + +w Wield a weapon. Take a weapon out of your pack and + carry it for use in combat, replacing the one you are + currently using (if any). + +W Wear armor. You can only wear one suit of armor at a + time. This takes extra time. + +T Take armor off. You can't remove armor that is cursed. + This takes extra time. + +P Put on a ring. You can wear only two rings at a time + (one on each hand). If you aren't wearing any rings, + this command will ask you which hand you want to wear + it on, otherwise, it will place it on the unused hand. + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-7 + + + The program assumes that you wield your sword in your + right hand. + +R Remove a ring. If you are only wearing one ring, this + command takes it off. If you are wearing two, it will + ask you which one you wish to remove, + +d Drop an object. Take something out of your pack and + leave it lying on the floor. Only one object can + occupy each space. You cannot drop a cursed object at + all if you are wielding or wearing it. + +c Call an object something. If you have a type of object + in your pack which you wish to remember something + about, you can use the call command to give a name to + that type of object. This is usually used when you + figure out what a potion, scroll, ring, or staff is + after you pick it up, or when you want to remember + which of those swords in your pack you were wielding. + +D Print out which things you've discovered something + about. This command will ask you what type of thing + you are interested in. If you type the character for a + given type of object (e.g. "!" for potion) it will + tell you which kinds of that type of object you've dis- + covered (i.e., figured out what they are). This com- + mand works for potions, scrolls, rings, and staves and + wands. + +o Examine and set options. This command is further + explained in the section on options. + +^R Redraws the screen. Useful if spurious messages or + transmission errors have messed up the display. + +^P Print last message. Useful when a message disappears + before you can read it. This only repeats the last + message that was not a mistyped command so that you + don't loose anything by accidentally typing the wrong + character instead of ^P. + + + Cancel a command, prefix, or count. + +! Escape to a shell for some commands. + +Q Quit. Leave the game. + +S Save the current game in a file. It will ask you + whether you wish to use the default save file. Caveat: + Rogue won't let you start up a copy of a saved game, + and it removes the save file as soon as you start up a + restored game. This is to prevent people from saving a + + + + + + + + + + +USD:33-8 A Guide to the Dungeons of Doom + + + game just before a dangerous position and then restart- + ing it if they die. To restore a saved game, give the + file name as an argument to rogue. As in + % rogue save_file + + To restart from the default save file (see below), run + % rogue -r + +v Prints the program version number. + +) Print the weapon you are currently wielding + +] Print the armor you are currently wearing + += Print the rings you are currently wearing + +@ Reprint the status line on the message line + +5. Rooms + + Rooms in the dungeons are either lit or dark. If you +walk into a lit room, the entire room will be drawn on the +screen as soon as you enter. If you walk into a dark room, +it will only be displayed as you explore it. Upon leaving a +room, all monsters inside the room are erased from the +screen. In the darkness you can only see one space in all +directions around you. A corridor is always dark. + +6. Fighting + + If you see a monster and you wish to fight it, just +attempt to run into it. Many times a monster you find will +mind its own business unless you attack it. It is often the +case that discretion is the better part of valor. + +7. Objects you can find + + When you find something in the dungeon, it is common to +want to pick the object up. This is accomplished in rogue +by walking over the object (unless you use the "m" prefix, +see above). If you are carrying too many things, the pro- +gram will tell you and it won't pick up the object, other- +wise it will add it to your pack and tell you what you just +picked up. + + Many of the commands that operate on objects must +prompt you to find out which object you want to use. If you +change your mind and don't want to do that command after +all, just type an and the command will be aborted. + + Some objects, like armor and weapons, are easily dif- +ferentiated. Others, like scrolls and potions, are given +labels which vary according to type. During a game, any two + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-9 + + +of the same kind of object with the same label are the same +type. However, the labels will vary from game to game. + + When you use one of these labeled objects, if its +effect is obvious, rogue will remember what it is for you. +If it's effect isn't extremely obvious you will be asked +what you want to scribble on it so you will recognize it +later, or you can use the "call" command (see above). + +7.1. Weapons + + Some weapons, like arrows, come in bunches, but most +come one at a time. In order to use a weapon, you must +wield it. To fire an arrow out of a bow, you must first +wield the bow, then throw the arrow. You can only wield one +weapon at a time, but you can't change weapons if the one +you are currently wielding is cursed. The commands to use +weapons are "w" (wield) and "t" (throw). + +7.2. Armor + + There are various sorts of armor lying around in the +dungeon. Some of it is enchanted, some is cursed, and some +is just normal. Different armor types have different armor +protection. The higher the armor protection, the more pro- +tection the armor affords against the blows of monsters. +Here is a list of the various armor types and their normal +armor protection: + + + +-----------------------------------------+ + | Type Protection | + |None 0 | + |Leather armor 2 | + |Studded leather / Ring mail 3 | + |Scale mail 4 | + |Chain mail 5 | + |Banded mail / Splint mail 6 | + |Plate mail 7 | + +-----------------------------------------+ + + +If a piece of armor is enchanted, its armor protection will +be higher than normal. If a suit of armor is cursed, its +armor protection will be lower, and you will not be able to +remove it. However, not all armor with a protection that is +lower than normal is cursed. + + The commands to use weapons are "W" (wear) and "T" +(take off). + + + + + + + + + + + + + +USD:33-10 A Guide to the Dungeons of Doom + + +7.3. Scrolls + + Scrolls come with titles in an unknown tongue3. After +you read a scroll, it disappears from your pack. The com- +mand to use a scroll is "r" (read). + +7.4. Potions + + Potions are labeled by the color of the liquid inside +the flask. They disappear after being quaffed. The command +to use a scroll is "q" (quaff). + +7.5. Staves and Wands + + Staves and wands do the same kinds of things. Staves +are identified by a type of wood; wands by a type of metal +or bone. They are generally things you want to do to some- +thing over a long distance, so you must point them at what +you wish to affect to use them. Some staves are not +affected by the direction they are pointed, though. Staves +come with multiple magic charges, the number being random, +and when they are used up, the staff is just a piece of wood +or metal. + + The command to use a wand or staff is "z" (zap) + +7.6. Rings + + Rings are very useful items, since they are relatively +permanent magic, unlike the usually fleeting effects of +potions, scrolls, and staves. Of course, the bad rings are +also more powerful. Most rings also cause you to use up +food more rapidly, the rate varying with the type of ring. +Rings are differentiated by their stone settings. The com- +mands to use rings are "P" (put on) and "R" (remove). + +7.7. Food + + Food is necessary to keep you going. If you go too +long without eating you will faint, and eventually die of +starvation. The command to use food is "e" (eat). + +8. Options + + Due to variations in personal tastes and conceptions of +the way rogue should do things, there are a set of options +you can set that cause rogue to behave in various different +____________________ + 3 Actually, it's a dialect spoken only by the twenty-sev- +en members of a tribe in Outer Mongolia, but you're not sup- +posed to know that. + + + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-11 + + +ways. + +8.1. Setting the options + + There are two ways to set the options. The first is +with the "o" command of rogue; the second is with the +"ROGUEOPTS" environment variable4. + +8.1.1. Using the `o' command + + When you type "o" in rogue, it clears the screen and +displays the current settings for all the options. It then +places the cursor by the value of the first option and waits +for you to type. You can type a which means to go +to the next option, a "-" which means to go to the previous +option, an which means to return to the game, or +you can give the option a value. For boolean options this +merely involves typing "t" for true or "f" for false. For +string options, type the new value followed by a . + +8.1.2. Using the ROGUEOPTS variable + + The ROGUEOPTS variable is a string containing a comma +separated list of initial values for the various options. +Boolean variables can be turned on by listing their name or +turned off by putting a "no" in front of the name. Thus to +set up an environment variable so that jump is on, terse is +off, and the name is set to "Blue Meanie", use the command + % setenv ROGUEOPTS "jump,noterse,name=Blue Meanie"5 + +8.2. Option list + + Here is a list of the options and an explanation of +what each one is for. The default value for each is +enclosed in square brackets. For character string options, +input over fifty characters will be ignored. + +terse [noterse] + Useful for those who are tired of the sometimes lengthy + messages of rogue. This is a useful option for playing + on slow terminals, so this option defaults to terse if + you are on a slow (1200 baud or under) terminal. + + +____________________ + 4 On Version 6 systems, there is no equivalent of the +ROGUEOPTS feature. + 5 For those of you who use the Bourne shell sh (1), the +commands would be + $ ROGUEOPTS="jump,noterse,name=Blue Meanie" + $ export ROGUEOPTS + + + + + + + + + + + + +USD:33-12 A Guide to the Dungeons of Doom + + +jump [nojump] + If this option is set, running moves will not be dis- + played until you reach the end of the move. This saves + considerable cpu and display time. This option + defaults to jump if you are using a slow terminal. + +flush [noflush] + All typeahead is thrown away after each round of bat- + tle. This is useful for those who type far ahead and + then watch in dismay as a Bat kills them. + +seefloor [seefloor] + Display the floor around you on the screen as you move + through dark rooms. Due to the amount of characters + generated, this option defaults to noseefloor if you + are using a slow terminal. + +passgo [nopassgo] + Follow turnings in passageways. If you run in a pas- + sage and you run into stone or a wall, rogue will see + if it can turn to the right or left. If it can only + turn one way, it will turn that way. If it can turn + either or neither, it will stop. This algorithm can + sometimes lead to slightly confusing occurrences which + is why it defaults to nopassgo. + +tombstone [tombstone] + Print out the tombstone at the end if you get killed. + This is nice but slow, so you can turn it off if you + like. + +inven [overwrite] + Inventory type. This can have one of three values: + overwrite, slow, or clear. With overwrite the top + lines of the map are overwritten with the list when + inventory is requested or when "Which item do you wish + to . . .? " questions are answered with a "*". How- + ever, if the list is longer than a screenful, the + screen is cleared. With slow, lists are displayed one + item at a time on the top of the screen, and with + clear, the screen is cleared, the list is displayed, + and then the dungeon level is re-displayed. Due to + speed considerations, clear is the default for termi- + nals without clear-to-end-of-line capabilities. + +name [account name] + This is the name of your character. It is used if you + get on the top ten scorer's list. + +fruit [slime-mold] + This should hold the name of a fruit that you enjoy + eating. It is basically a whimsey that rogue uses in a + couple of places. + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-13 + + +file [~/rogue.save] + The default file name for saving the game. If your + phone is hung up by accident, rogue will automatically + save the game in this file. The file name may start + with the special character "~" which expands to be your + home directory. + +9. Scoring + + Rogue usually maintains a list of the top scoring peo- +ple or scores on your machine. Depending on how it is set +up, it can post either the top scores or the top players. +In the latter case, each account on the machine can post +only one non-winning score on this list. If you score +higher than someone else on this list, or better your previ- +ous score on the list, you will be inserted in the proper +place under your current name. How many scores are kept can +also be set up by whoever installs it on your machine. + + If you quit the game, you get out with all of your gold +intact. If, however, you get killed in the Dungeons of +Doom, your body is forwarded to your next-of-kin, along with +90% of your gold; ten percent of your gold is kept by the +Dungeons' wizard as a fee6. This should make you consider +whether you want to take one last hit at that monster and +possibly live, or quit and thus stop with whatever you have. +If you quit, you do get all your gold, but if you swing and +live, you might find more. + + If you just want to see what the current top play- +ers/games list is, you can type + % rogue -s + +10. Acknowledgements + + Rogue was originally conceived of by Glenn Wichman and +Michael Toy. Ken Arnold and Michael Toy then smoothed out +the user interface, and added jillions of new features. We +would like to thank Bob Arnold, Michelle Busch, Andy +Hatcher, Kipp Hickman, Mark Horton, Daniel Jensen, Bill Joy, +Joe Kalash, Steve Maurer, Marty McNary, Jan Miller, and +Scott Nelson for their ideas and assistance; and also the +teeming multitudes who graciously ignored work, school, and +social life to play rogue and send us bugs, complaints, sug- +gestions, and just plain flames. And also Mom. + + + +____________________ + 6 The Dungeon's wizard is named Wally the Wonder Badger. +Invocations should be accompanied by a sizable donation. + + + + + + + + diff --git a/src/cc/rogue/rogue.doc.in b/src/cc/rogue/rogue.doc.in new file mode 100644 index 000000000..3031d0d24 --- /dev/null +++ b/src/cc/rogue/rogue.doc.in @@ -0,0 +1,858 @@ + + + + + + + + A Guide to the Dungeons of Doom + + + Michael C. Toy + Kenneth C. R. C. Arnold + + + Computer Systems Research Group + Department of Electrical Engineering and Computer Science + University of California + Berkeley, California 94720 + + + + + ABSTRACT + + Rogue is a visual CRT based fantasy game which runs + under the UNIX timesharing system. This paper de- + scribes how to play rogue, and gives a few hints for + those who might otherwise get lost in the Dungeons + of Doom. + + + + +1. Introduction + + You have just finished your years as a student at the +local fighter's guild. After much practice and sweat you +have finally completed your training and are ready to embark +upon a perilous adventure. As a test of your skills, the +local guildmasters have sent you into the Dungeons of Doom. +Your task is to return with the Amulet of Yendor. Your +reward for the completion of this task will be a full mem- +bership in the local guild. In addition, you are allowed to +keep all the loot you bring back from the dungeons. + + In preparation for your journey, you are given an +enchanted mace, a bow, and a quiver of arrows taken from a +dragon's hoard in the far off Dark Mountains. You are also +outfitted with elf-crafted armor and given enough food to +reach the dungeons. You say goodbye to family and friends +for what may be the last time and head up the road. + + You set out on your way to the dungeons and after sev- +eral days of uneventful travel, you see the ancient ruins +that mark the entrance to the Dungeons of Doom. It is late +at night, so you make camp at the entrance and spend the +____________________ + UNIX is a trademark of Bell Laboratories + + + + + + + + + + + + +USD:33-2 A Guide to the Dungeons of Doom + + +night sleeping under the open skies. In the morning you +gather your weapons, put on your armor, eat what is almost +your last food, and enter the dungeons. + +2. What is going on here? + + You have just begun a game of rogue. Your goal is to +grab as much treasure as you can, find the Amulet of Yendor, +and get out of the Dungeons of Doom alive. On the screen, a +map of where you have been and what you have seen on the +current dungeon level is kept. As you explore more of the +level, it appears on the screen in front of you. + + Rogue differs from most computer fantasy games in that +it is screen oriented. Commands are all one or two +keystrokes1 and the results of your commands are displayed +graphically on the screen rather than being explained in +words.2 + + Another major difference between rogue and other com- +puter fantasy games is that once you have solved all the +puzzles in a standard fantasy game, it has lost most of its +excitement and it ceases to be fun. Rogue, on the other +hand, generates a new dungeon every time you play it and +even the author finds it an entertaining and exciting game. + +3. What do all those things on the screen mean? + + In order to understand what is going on in rogue you +have to first get some grasp of what rogue is doing with the +screen. The rogue screen is intended to replace the "You +can see ..." descriptions of standard fantasy games. Figure +1 is a sample of what a rogue screen might look like. + +3.1. The bottom line + + At the bottom line of the screen are a few pieces of +cryptic information describing your current status. Here is +an explanation of what these things mean: + +Level This number indicates how deep you have gone in the + dungeon. It starts at one and goes up as you go + deeper into the dungeon. + +Gold The number of gold pieces you have managed to find + and keep with you so far. +____________________ + 1 As opposed to pseudo English sentences. + 2 A minimum screen size of 24 lines by 80 columns is re- +quired. If the screen is larger, only the 24x80 section +will be used for the map. + + + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-3 + + + +____________________________________________________________ + + + ------------ + |..........+ + |..@....]..| + |....B.....| + |..........| + -----+------ + + + +Level: 1 Gold: 0 Hp: 12(12) Str: 16(16) Arm: 4 Exp: 1/0 + + Figure 1 +____________________________________________________________ + + +Hp Your current and maximum health points. Health + points indicate how much damage you can take before + you die. The more you get hit in a fight, the lower + they get. You can regain health points by resting. + The number in parentheses is the maximum number your + health points can reach. + +Str Your current strength and maximum ever strength. + This can be any integer less than or equal to 31, or + greater than or equal to three. The higher the num- + ber, the stronger you are. The number in the paren- + theses is the maximum strength you have attained so + far this game. + +Arm Your current armor protection. This number indicates + how effective your armor is in stopping blows from + unfriendly creatures. The higher this number is, the + more effective the armor. + +Exp These two numbers give your current experience level + and experience points. As you do things, you gain + experience points. At certain experience point + totals, you gain an experience level. The more expe- + rienced you are, the better you are able to fight and + to withstand magical attacks. + +3.2. The top line + + The top line of the screen is reserved for printing +messages that describe things that are impossible to repre- +sent visually. If you see a "--More--" on the top line, +this means that rogue wants to print another message on the +screen, but it wants to make certain that you have read the +one that is there first. To read the next message, just + + + + + + + + + + +USD:33-4 A Guide to the Dungeons of Doom + + +type a space. + +3.3. The rest of the screen + + The rest of the screen is the map of the level as you +have explored it so far. Each symbol on the screen repre- +sents something. Here is a list of what the various symbols +mean: + +@ This symbol represents you, the adventurer. + +-| These symbols represent the walls of rooms. + ++ A door to/from a room. + +. The floor of a room. + +# The floor of a passage between rooms. + +* A pile or pot of gold. + +) A weapon of some sort. + +] A piece of armor. + +! A flask containing a magic potion. + +? A piece of paper, usually a magic scroll. + += A ring with magic properties + +/ A magical staff or wand + +^ A trap, watch out for these. + +% A staircase to other levels + +: A piece of food. + +A-Z The uppercase letters represent the various inhabitants + of the Dungeons of Doom. Watch out, they can be nasty + and vicious. + +4. Commands + + Commands are given to rogue by typing one or two char- +acters. Most commands can be preceded by a count to repeat +them (e.g. typing "10s" will do ten searches). Commands for +which counts make no sense have the count ignored. To can- +cel a count or a prefix, type . The list of com- +mands is rather long, but it can be read at any time during +the game with the "?" command. Here it is for reference, +with a short explanation of each command. + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-5 + + +? The help command. Asks for a character to give help + on. If you type a "*", it will list all the commands, + otherwise it will explain what the character you typed + does. + +/ This is the "What is that on the screen?" command. A + "/" followed by any character that you see on the + level, will tell you what that character is. For + instance, typing "/@" will tell you that the "@" symbol + represents you, the player. + +h, H, ^H + Move left. You move one space to the left. If you use + upper case "h", you will continue to move left until + you run into something. This works for all movement + commands (e.g. "L" means run in direction "l") If you + use the "control" "h", you will continue moving in the + specified direction until you pass something interest- + ing or run into a wall. You should experiment with + this, since it is a very useful command, but very dif- + ficult to describe. This also works for all movement + commands. + +j Move down. + +k Move up. + +l Move right. + +y Move diagonally up and left. + +u Move diagonally up and right. + +b Move diagonally down and left. + +n Move diagonally down and right. + +t Throw an object. This is a prefix command. When fol- + lowed with a direction it throws an object in the spec- + ified direction. (e.g. type "th" to throw something to + the left.) + +f Fight until someone dies. When followed with a direc- + tion this will force you to fight the creature in that + direction until either you or it bites the big one. + +m Move onto something without picking it up. This will + move you one space in the direction you specify and, if + there is an object there you can pick up, it won't do + it. + +z Zap prefix. Point a staff or wand in a given direction + and fire it. Even non-directional staves must be + + + + + + + + + + +USD:33-6 A Guide to the Dungeons of Doom + + + pointed in some direction to be used. + +^ Identify trap command. If a trap is on your map and + you can't remember what type it is, you can get rogue + to remind you by getting next to it and typing "^" fol- + lowed by the direction that would move you on top of + it. + +s Search for traps and secret doors. Examine each space + immediately adjacent to you for the existence of a trap + or secret door. There is a large chance that even if + there is something there, you won't find it, so you + might have to search a while before you find something. + +> Climb down a staircase to the next level. Not surpris- + ingly, this can only be done if you are standing on + staircase. + +< Climb up a staircase to the level above. This can't be + done without the Amulet of Yendor in your possession. + +. Rest. This is the "do nothing" command. This is good + for waiting and healing. + +, Pick up something. This picks up whatever you are cur- + rently standing on, if you are standing on anything at + all. + +i Inventory. List what you are carrying in your pack. + +I Selective inventory. Tells you what a single item in + your pack is. + +q Quaff one of the potions you are carrying. + +r Read one of the scrolls in your pack. + +e Eat food from your pack. + +w Wield a weapon. Take a weapon out of your pack and + carry it for use in combat, replacing the one you are + currently using (if any). + +W Wear armor. You can only wear one suit of armor at a + time. This takes extra time. + +T Take armor off. You can't remove armor that is cursed. + This takes extra time. + +P Put on a ring. You can wear only two rings at a time + (one on each hand). If you aren't wearing any rings, + this command will ask you which hand you want to wear + it on, otherwise, it will place it on the unused hand. + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-7 + + + The program assumes that you wield your sword in your + right hand. + +R Remove a ring. If you are only wearing one ring, this + command takes it off. If you are wearing two, it will + ask you which one you wish to remove, + +d Drop an object. Take something out of your pack and + leave it lying on the floor. Only one object can + occupy each space. You cannot drop a cursed object at + all if you are wielding or wearing it. + +c Call an object something. If you have a type of object + in your pack which you wish to remember something + about, you can use the call command to give a name to + that type of object. This is usually used when you + figure out what a potion, scroll, ring, or staff is + after you pick it up, or when you want to remember + which of those swords in your pack you were wielding. + +D Print out which things you've discovered something + about. This command will ask you what type of thing + you are interested in. If you type the character for a + given type of object (e.g. "!" for potion) it will + tell you which kinds of that type of object you've dis- + covered (i.e., figured out what they are). This com- + mand works for potions, scrolls, rings, and staves and + wands. + +o Examine and set options. This command is further + explained in the section on options. + +^R Redraws the screen. Useful if spurious messages or + transmission errors have messed up the display. + +^P Print last message. Useful when a message disappears + before you can read it. This only repeats the last + message that was not a mistyped command so that you + don't loose anything by accidentally typing the wrong + character instead of ^P. + + + Cancel a command, prefix, or count. + +! Escape to a shell for some commands. + +Q Quit. Leave the game. + +S Save the current game in a file. It will ask you + whether you wish to use the default save file. Caveat: + Rogue won't let you start up a copy of a saved game, + and it removes the save file as soon as you start up a + restored game. This is to prevent people from saving a + + + + + + + + + + +USD:33-8 A Guide to the Dungeons of Doom + + + game just before a dangerous position and then restart- + ing it if they die. To restore a saved game, give the + file name as an argument to rogue. As in + % rogue save_file + + To restart from the default save file (see below), run + % rogue -r + +v Prints the program version number. + +) Print the weapon you are currently wielding + +] Print the armor you are currently wearing + += Print the rings you are currently wearing + +@ Reprint the status line on the message line + +5. Rooms + + Rooms in the dungeons are either lit or dark. If you +walk into a lit room, the entire room will be drawn on the +screen as soon as you enter. If you walk into a dark room, +it will only be displayed as you explore it. Upon leaving a +room, all monsters inside the room are erased from the +screen. In the darkness you can only see one space in all +directions around you. A corridor is always dark. + +6. Fighting + + If you see a monster and you wish to fight it, just +attempt to run into it. Many times a monster you find will +mind its own business unless you attack it. It is often the +case that discretion is the better part of valor. + +7. Objects you can find + + When you find something in the dungeon, it is common to +want to pick the object up. This is accomplished in rogue +by walking over the object (unless you use the "m" prefix, +see above). If you are carrying too many things, the pro- +gram will tell you and it won't pick up the object, other- +wise it will add it to your pack and tell you what you just +picked up. + + Many of the commands that operate on objects must +prompt you to find out which object you want to use. If you +change your mind and don't want to do that command after +all, just type an and the command will be aborted. + + Some objects, like armor and weapons, are easily dif- +ferentiated. Others, like scrolls and potions, are given +labels which vary according to type. During a game, any two + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-9 + + +of the same kind of object with the same label are the same +type. However, the labels will vary from game to game. + + When you use one of these labeled objects, if its +effect is obvious, rogue will remember what it is for you. +If it's effect isn't extremely obvious you will be asked +what you want to scribble on it so you will recognize it +later, or you can use the "call" command (see above). + +7.1. Weapons + + Some weapons, like arrows, come in bunches, but most +come one at a time. In order to use a weapon, you must +wield it. To fire an arrow out of a bow, you must first +wield the bow, then throw the arrow. You can only wield one +weapon at a time, but you can't change weapons if the one +you are currently wielding is cursed. The commands to use +weapons are "w" (wield) and "t" (throw). + +7.2. Armor + + There are various sorts of armor lying around in the +dungeon. Some of it is enchanted, some is cursed, and some +is just normal. Different armor types have different armor +protection. The higher the armor protection, the more pro- +tection the armor affords against the blows of monsters. +Here is a list of the various armor types and their normal +armor protection: + + + +-----------------------------------------+ + | Type Protection | + |None 0 | + |Leather armor 2 | + |Studded leather / Ring mail 3 | + |Scale mail 4 | + |Chain mail 5 | + |Banded mail / Splint mail 6 | + |Plate mail 7 | + +-----------------------------------------+ + + +If a piece of armor is enchanted, its armor protection will +be higher than normal. If a suit of armor is cursed, its +armor protection will be lower, and you will not be able to +remove it. However, not all armor with a protection that is +lower than normal is cursed. + + The commands to use weapons are "W" (wear) and "T" +(take off). + + + + + + + + + + + + + +USD:33-10 A Guide to the Dungeons of Doom + + +7.3. Scrolls + + Scrolls come with titles in an unknown tongue3. After +you read a scroll, it disappears from your pack. The com- +mand to use a scroll is "r" (read). + +7.4. Potions + + Potions are labeled by the color of the liquid inside +the flask. They disappear after being quaffed. The command +to use a scroll is "q" (quaff). + +7.5. Staves and Wands + + Staves and wands do the same kinds of things. Staves +are identified by a type of wood; wands by a type of metal +or bone. They are generally things you want to do to some- +thing over a long distance, so you must point them at what +you wish to affect to use them. Some staves are not +affected by the direction they are pointed, though. Staves +come with multiple magic charges, the number being random, +and when they are used up, the staff is just a piece of wood +or metal. + + The command to use a wand or staff is "z" (zap) + +7.6. Rings + + Rings are very useful items, since they are relatively +permanent magic, unlike the usually fleeting effects of +potions, scrolls, and staves. Of course, the bad rings are +also more powerful. Most rings also cause you to use up +food more rapidly, the rate varying with the type of ring. +Rings are differentiated by their stone settings. The com- +mands to use rings are "P" (put on) and "R" (remove). + +7.7. Food + + Food is necessary to keep you going. If you go too +long without eating you will faint, and eventually die of +starvation. The command to use food is "e" (eat). + +8. Options + + Due to variations in personal tastes and conceptions of +the way rogue should do things, there are a set of options +you can set that cause rogue to behave in various different +____________________ + 3 Actually, it's a dialect spoken only by the twenty-sev- +en members of a tribe in Outer Mongolia, but you're not sup- +posed to know that. + + + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-11 + + +ways. + +8.1. Setting the options + + There are two ways to set the options. The first is +with the "o" command of rogue; the second is with the +"ROGUEOPTS" environment variable4. + +8.1.1. Using the `o' command + + When you type "o" in rogue, it clears the screen and +displays the current settings for all the options. It then +places the cursor by the value of the first option and waits +for you to type. You can type a which means to go +to the next option, a "-" which means to go to the previous +option, an which means to return to the game, or +you can give the option a value. For boolean options this +merely involves typing "t" for true or "f" for false. For +string options, type the new value followed by a . + +8.1.2. Using the ROGUEOPTS variable + + The ROGUEOPTS variable is a string containing a comma +separated list of initial values for the various options. +Boolean variables can be turned on by listing their name or +turned off by putting a "no" in front of the name. Thus to +set up an environment variable so that jump is on, terse is +off, and the name is set to "Blue Meanie", use the command + % setenv ROGUEOPTS "jump,noterse,name=Blue Meanie"5 + +8.2. Option list + + Here is a list of the options and an explanation of +what each one is for. The default value for each is +enclosed in square brackets. For character string options, +input over fifty characters will be ignored. + +terse [noterse] + Useful for those who are tired of the sometimes lengthy + messages of rogue. This is a useful option for playing + on slow terminals, so this option defaults to terse if + you are on a slow (1200 baud or under) terminal. + + +____________________ + 4 On Version 6 systems, there is no equivalent of the +ROGUEOPTS feature. + 5 For those of you who use the Bourne shell sh (1), the +commands would be + $ ROGUEOPTS="jump,noterse,name=Blue Meanie" + $ export ROGUEOPTS + + + + + + + + + + + + +USD:33-12 A Guide to the Dungeons of Doom + + +jump [nojump] + If this option is set, running moves will not be dis- + played until you reach the end of the move. This saves + considerable cpu and display time. This option + defaults to jump if you are using a slow terminal. + +flush [noflush] + All typeahead is thrown away after each round of bat- + tle. This is useful for those who type far ahead and + then watch in dismay as a Bat kills them. + +seefloor [seefloor] + Display the floor around you on the screen as you move + through dark rooms. Due to the amount of characters + generated, this option defaults to noseefloor if you + are using a slow terminal. + +passgo [nopassgo] + Follow turnings in passageways. If you run in a pas- + sage and you run into stone or a wall, rogue will see + if it can turn to the right or left. If it can only + turn one way, it will turn that way. If it can turn + either or neither, it will stop. This algorithm can + sometimes lead to slightly confusing occurrences which + is why it defaults to nopassgo. + +tombstone [tombstone] + Print out the tombstone at the end if you get killed. + This is nice but slow, so you can turn it off if you + like. + +inven [overwrite] + Inventory type. This can have one of three values: + overwrite, slow, or clear. With overwrite the top + lines of the map are overwritten with the list when + inventory is requested or when "Which item do you wish + to . . .? " questions are answered with a "*". How- + ever, if the list is longer than a screenful, the + screen is cleared. With slow, lists are displayed one + item at a time on the top of the screen, and with + clear, the screen is cleared, the list is displayed, + and then the dungeon level is re-displayed. Due to + speed considerations, clear is the default for termi- + nals without clear-to-end-of-line capabilities. + +name [account name] + This is the name of your character. It is used if you + get on the top ten scorer's list. + +fruit [slime-mold] + This should hold the name of a fruit that you enjoy + eating. It is basically a whimsey that rogue uses in a + couple of places. + + + + + + + + + + +A Guide to the Dungeons of Doom USD:33-13 + + +file [~/rogue.save] + The default file name for saving the game. If your + phone is hung up by accident, rogue will automatically + save the game in this file. The file name may start + with the special character "~" which expands to be your + home directory. + +9. Scoring + + Rogue usually maintains a list of the top scoring peo- +ple or scores on your machine. Depending on how it is set +up, it can post either the top scores or the top players. +In the latter case, each account on the machine can post +only one non-winning score on this list. If you score +higher than someone else on this list, or better your previ- +ous score on the list, you will be inserted in the proper +place under your current name. How many scores are kept can +also be set up by whoever installs it on your machine. + + If you quit the game, you get out with all of your gold +intact. If, however, you get killed in the Dungeons of +Doom, your body is forwarded to your next-of-kin, along with +90% of your gold; ten percent of your gold is kept by the +Dungeons' wizard as a fee6. This should make you consider +whether you want to take one last hit at that monster and +possibly live, or quit and thus stop with whatever you have. +If you quit, you do get all your gold, but if you swing and +live, you might find more. + + If you just want to see what the current top play- +ers/games list is, you can type + % @PROGRAM@ -s + +10. Acknowledgements + + Rogue was originally conceived of by Glenn Wichman and +Michael Toy. Ken Arnold and Michael Toy then smoothed out +the user interface, and added jillions of new features. We +would like to thank Bob Arnold, Michelle Busch, Andy +Hatcher, Kipp Hickman, Mark Horton, Daniel Jensen, Bill Joy, +Joe Kalash, Steve Maurer, Marty McNary, Jan Miller, and +Scott Nelson for their ideas and assistance; and also the +teeming multitudes who graciously ignored work, school, and +social life to play rogue and send us bugs, complaints, sug- +gestions, and just plain flames. And also Mom. + + + +____________________ + 6 The Dungeon's wizard is named Wally the Wonder Badger. +Invocations should be accompanied by a sizable donation. + + + + + + + + diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h new file mode 100644 index 000000000..ae834eb7a --- /dev/null +++ b/src/cc/rogue/rogue.h @@ -0,0 +1,785 @@ +/* + * Rogue definitions and variable declarations + * + * @(#)rogue.h 5.42 (Berkeley) 08/06/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include "extern.h" + +#undef lines + +#define NOOP(x) (x += 0) +#define CCHAR(x) ( (char) (x & A_CHARTEXT) ) +/* + * Maximum number of different things + */ +#define MAXROOMS 9 +#define MAXTHINGS 9 +#define MAXOBJ 9 +#define MAXPACK 23 +#define MAXTRAPS 10 +#define AMULETLEVEL 26 +#define NUMTHINGS 7 /* number of types of things */ +#define MAXPASS 13 /* upper limit on number of passages */ +#define NUMLINES 24 +#define NUMCOLS 80 +#define STATLINE (NUMLINES - 1) +#define BORE_LEVEL 50 + +/* + * return values for get functions + */ +#define NORM 0 /* normal exit */ +#define QUIT 1 /* quit option setting */ +#define MINUS 2 /* back up one option */ + +/* + * inventory types + */ +#define INV_OVER 0 +#define INV_SLOW 1 +#define INV_CLEAR 2 + +/* + * All the fun defines + */ +#define when break;case +#define otherwise break;default +#define until(expr) while(!(expr)) +#define next(ptr) (*ptr).l_next +#define prev(ptr) (*ptr).l_prev +#define winat(y,x) (moat(y,x) != NULL ? moat(y,x)->t_disguise : chat(y,x)) +#define ce(a,b) ((a).x == (b).x && (a).y == (b).y) +#define hero player.t_pos +#define pstats player.t_stats +#define pack player.t_pack +#define proom player.t_room +#define max_hp player.t_stats.s_maxhp +#define attach(a,b) _attach(&a,b) +#define detach(a,b) _detach(&a,b) +#define free_list(a) _free_list(&a) +#undef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#define on(thing,flag) ((bool)(((thing).t_flags & (flag)) != 0)) +#define GOLDCALC (rnd(50 + 10 * level) + 2) +#define ISRING(h,r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r) +#define ISWEARING(r) (ISRING(LEFT, r) || ISRING(RIGHT, r)) +#define ISMULT(type) (type == POTION || type == SCROLL || type == FOOD) +#define INDEX(y,x) (&places[((x) << 5) + (y)]) +#define chat(y,x) (places[((x) << 5) + (y)].p_ch) +#define flat(y,x) (places[((x) << 5) + (y)].p_flags) +#define moat(y,x) (places[((x) << 5) + (y)].p_monst) +#define unc(cp) (cp).y, (cp).x +#ifdef MASTER +#define debug if (wizard) msg +#endif + +/* + * things that appear on the screens + */ +#define PASSAGE '#' +#define DOOR '+' +#define FLOOR '.' +#define PLAYER '@' +#define TRAP '^' +#define STAIRS '%' +#define GOLD '*' +#define POTION '!' +#define SCROLL '?' +#define MAGIC '$' +#define FOOD ':' +#define WEAPON ')' +#define ARMOR ']' +#define AMULET ',' +#define RING '=' +#define STICK '/' +#define CALLABLE -1 +#define R_OR_S -2 + +/* + * Various constants + */ +#define BEARTIME spread(3) +#define SLEEPTIME spread(5) +#define HOLDTIME spread(2) +#define WANDERTIME spread(70) +#define BEFORE spread(1) +#define AFTER spread(2) +#define HEALTIME 30 +#define HUHDURATION 20 +#define SEEDURATION 850 +#define HUNGERTIME 1300 +#define MORETIME 150 +#define STOMACHSIZE 2000 +#define STARVETIME 850 +#define ESCAPE 27 +#define LEFT 0 +#define RIGHT 1 +#define BOLT_LENGTH 6 +#define LAMPDIST 3 +#ifdef MASTER +#ifndef PASSWD +#define PASSWD "mTBellIQOsLNA" +#endif +#endif + +/* + * Save against things + */ +#define VS_POISON 00 +#define VS_PARALYZATION 00 +#define VS_DEATH 00 +#define VS_BREATH 02 +#define VS_MAGIC 03 + +/* + * Various flag bits + */ +/* flags for rooms */ +#define ISDARK 0000001 /* room is dark */ +#define ISGONE 0000002 /* room is gone (a corridor) */ +#define ISMAZE 0000004 /* room is gone (a corridor) */ + +/* flags for objects */ +#define ISCURSED 000001 /* object is cursed */ +#define ISKNOW 0000002 /* player knows details about the object */ +#define ISMISL 0000004 /* object is a missile type */ +#define ISMANY 0000010 /* object comes in groups */ +/* ISFOUND 0000020 ...is used for both objects and creatures */ +#define ISPROT 0000040 /* armor is permanently protected */ + +/* flags for creatures */ +#define CANHUH 0000001 /* creature can confuse */ +#define CANSEE 0000002 /* creature can see invisible creatures */ +#define ISBLIND 0000004 /* creature is blind */ +#define ISCANC 0000010 /* creature has special qualities cancelled */ +#define ISLEVIT 0000010 /* hero is levitating */ +#define ISFOUND 0000020 /* creature has been seen (used for objects) */ +#define ISGREED 0000040 /* creature runs to protect gold */ +#define ISHASTE 0000100 /* creature has been hastened */ +#define ISTARGET 000200 /* creature is the target of an 'f' command */ +#define ISHELD 0000400 /* creature has been held */ +#define ISHUH 0001000 /* creature is confused */ +#define ISINVIS 0002000 /* creature is invisible */ +#define ISMEAN 0004000 /* creature can wake when player enters room */ +#define ISHALU 0004000 /* hero is on acid trip */ +#define ISREGEN 0010000 /* creature can regenerate */ +#define ISRUN 0020000 /* creature is running at the player */ +#define SEEMONST 040000 /* hero can detect unseen monsters */ +#define ISFLY 0040000 /* creature can fly */ +#define ISSLOW 0100000 /* creature has been slowed */ + +/* + * Flags for level map + */ +#define F_PASS 0x80 /* is a passageway */ +#define F_SEEN 0x40 /* have seen this spot before */ +#define F_DROPPED 0x20 /* object was dropped here */ +#define F_LOCKED 0x20 /* door is locked */ +#define F_REAL 0x10 /* what you see is what you get */ +#define F_PNUM 0x0f /* passage number mask */ +#define F_TMASK 0x07 /* trap number mask */ + +/* + * Trap types + */ +#define T_DOOR 00 +#define T_ARROW 01 +#define T_SLEEP 02 +#define T_BEAR 03 +#define T_TELEP 04 +#define T_DART 05 +#define T_RUST 06 +#define T_MYST 07 +#define NTRAPS 8 + +/* + * Potion types + */ +#define P_CONFUSE 0 +#define P_LSD 1 +#define P_POISON 2 +#define P_STRENGTH 3 +#define P_SEEINVIS 4 +#define P_HEALING 5 +#define P_MFIND 6 +#define P_TFIND 7 +#define P_RAISE 8 +#define P_XHEAL 9 +#define P_HASTE 10 +#define P_RESTORE 11 +#define P_BLIND 12 +#define P_LEVIT 13 +#define MAXPOTIONS 14 + +/* + * Scroll types + */ +#define S_CONFUSE 0 +#define S_MAP 1 +#define S_HOLD 2 +#define S_SLEEP 3 +#define S_ARMOR 4 +#define S_ID_POTION 5 +#define S_ID_SCROLL 6 +#define S_ID_WEAPON 7 +#define S_ID_ARMOR 8 +#define S_ID_R_OR_S 9 +#define S_SCARE 10 +#define S_FDET 11 +#define S_TELEP 12 +#define S_ENCH 13 +#define S_CREATE 14 +#define S_REMOVE 15 +#define S_AGGR 16 +#define S_PROTECT 17 +#define MAXSCROLLS 18 + +/* + * Weapon types + */ +#define MACE 0 +#define SWORD 1 +#define BOW 2 +#define ARROW 3 +#define DAGGER 4 +#define TWOSWORD 5 +#define DART 6 +#define SHIRAKEN 7 +#define SPEAR 8 +#define FLAME 9 /* fake entry for dragon breath (ick) */ +#define MAXWEAPONS 9 /* this should equal FLAME */ + +/* + * Armor types + */ +#define LEATHER 0 +#define RING_MAIL 1 +#define STUDDED_LEATHER 2 +#define SCALE_MAIL 3 +#define CHAIN_MAIL 4 +#define SPLINT_MAIL 5 +#define BANDED_MAIL 6 +#define PLATE_MAIL 7 +#define MAXARMORS 8 + +/* + * Ring types + */ +#define R_PROTECT 0 +#define R_ADDSTR 1 +#define R_SUSTSTR 2 +#define R_SEARCH 3 +#define R_SEEINVIS 4 +#define R_NOP 5 +#define R_AGGR 6 +#define R_ADDHIT 7 +#define R_ADDDAM 8 +#define R_REGEN 9 +#define R_DIGEST 10 +#define R_TELEPORT 11 +#define R_STEALTH 12 +#define R_SUSTARM 13 +#define MAXRINGS 14 + +/* + * Rod/Wand/Staff types + */ +#define WS_LIGHT 0 +#define WS_INVIS 1 +#define WS_ELECT 2 +#define WS_FIRE 3 +#define WS_COLD 4 +#define WS_POLYMORPH 5 +#define WS_MISSILE 6 +#define WS_HASTE_M 7 +#define WS_SLOW_M 8 +#define WS_DRAIN 9 +#define WS_NOP 10 +#define WS_TELAWAY 11 +#define WS_TELTO 12 +#define WS_CANCEL 13 +#define MAXSTICKS 14 + +/* + * Now we define the structures and types + */ +struct rogue_state +{ + uint64_t seed; + char *keystrokes; + uint32_t needflush,replaydone; + int32_t numkeys,ind,num,guiflag,counter; + char buffered[64]; +}; + +int rogue(int argc, char **argv, char **envp); +void rogueiterate(struct rogue_state *rs); +int32_t roguefname(char *fname,uint64_t seed,int32_t counter); +int32_t flushkeystrokes(struct rogue_state *rs); + +/* + * Help list + */ +struct h_list { + char h_ch; + char *h_desc; + bool h_print; +}; + +/* + * Coordinate data type + */ +typedef struct { + int x; + int y; +} coord; + +typedef unsigned int str_t; + +/* + * Stuff about objects + */ +struct obj_info { + char *oi_name; + int oi_prob; + int oi_worth; + char *oi_guess; + bool oi_know; +}; + +/* + * Room structure + */ +struct room { + coord r_pos; /* Upper left corner */ + coord r_max; /* Size of room */ + coord r_gold; /* Where the gold is */ + int r_goldval; /* How much the gold is worth */ + short r_flags; /* info about the room */ + int r_nexits; /* Number of exits */ + coord r_exit[12]; /* Where the exits are */ +}; + +/* + * Structure describing a fighting being + */ +struct stats { + str_t s_str; /* Strength */ + int s_exp; /* Experience */ + int s_lvl; /* level of mastery */ + int s_arm; /* Armor class */ + int s_hpt; /* Hit points */ + char s_dmg[13]; /* String describing damage done */ + int s_maxhp; /* Max hit points */ +}; + +/* + * Structure for monsters and player + */ +union thing { + struct { + union thing *_l_next, *_l_prev; /* Next pointer in link */ + coord _t_pos; /* Position */ + bool _t_turn; /* If slowed, is it a turn to move */ + char _t_type; /* What it is */ + char _t_disguise; /* What mimic looks like */ + char _t_oldch; /* Character that was where it was */ + coord *_t_dest; /* Where it is running to */ + short _t_flags; /* State word */ + struct stats _t_stats; /* Physical description */ + struct room *_t_room; /* Current room for thing */ + union thing *_t_pack; /* What the thing is carrying */ + int _t_reserved; + } _t; + struct { + union thing *_l_next, *_l_prev; /* Next pointer in link */ + int _o_type; /* What kind of object it is */ + coord _o_pos; /* Where it lives on the screen */ + char *_o_text; /* What it says if you read it */ + int _o_launch; /* What you need to launch it */ + char _o_packch; /* What character it is in the pack */ + char _o_damage[8]; /* Damage if used like sword */ + char _o_hurldmg[8]; /* Damage if thrown */ + int _o_count; /* count for plural objects */ + int _o_which; /* Which object of a type it is */ + int _o_hplus; /* Plusses to hit */ + int _o_dplus; /* Plusses to damage */ + int _o_arm; /* Armor protection */ + int _o_flags; /* information about objects */ + int _o_group; /* group number for this object */ + char *_o_label; /* Label for object */ + } _o; +}; + +typedef union thing THING; + +#define l_next _t._l_next +#define l_prev _t._l_prev +#define t_pos _t._t_pos +#define t_turn _t._t_turn +#define t_type _t._t_type +#define t_disguise _t._t_disguise +#define t_oldch _t._t_oldch +#define t_dest _t._t_dest +#define t_flags _t._t_flags +#define t_stats _t._t_stats +#define t_pack _t._t_pack +#define t_room _t._t_room +#define t_reserved _t._t_reserved +#define o_type _o._o_type +#define o_pos _o._o_pos +#define o_text _o._o_text +#define o_launch _o._o_launch +#define o_packch _o._o_packch +#define o_damage _o._o_damage +#define o_hurldmg _o._o_hurldmg +#define o_count _o._o_count +#define o_which _o._o_which +#define o_hplus _o._o_hplus +#define o_dplus _o._o_dplus +#define o_arm _o._o_arm +#define o_charges o_arm +#define o_goldval o_arm +#define o_flags _o._o_flags +#define o_group _o._o_group +#define o_label _o._o_label + +/* + * describe a place on the level map + */ +typedef struct { + char p_ch; + char p_flags; + THING *p_monst; +} PLACE; + +/* + * Array containing information on all the various types of monsters + */ +struct monster { + char *m_name; /* What to call the monster */ + int m_carry; /* Probability of carrying something */ + short m_flags; /* things about the monster */ + struct stats m_stats; /* Initial stats */ +}; + +/* + * External variables + */ + +extern bool after, again, allscore, amulet, door_stop, fight_flush, + firstmove, has_hit, inv_describe, jump, kamikaze, + lower_msg, move_on, msg_esc, pack_used[], + passgo, playing, q_comm, running, save_msg, see_floor, + seenstairs, stat_msg, terse, to_death, tombstone; + +extern char dir_ch, file_name[], home[], huh[], *inv_t_name[], + l_last_comm, l_last_dir, last_comm, last_dir, *Numname, + outbuf[], *p_colors[], *r_stones[], *release, runch, + *s_names[], take, *tr_name[], *ws_made[], *ws_type[]; + +extern int a_class[], count, food_left, hungry_state, inpack, + inv_type, lastscore, level, max_hit, max_level, mpos, + n_objs, no_command, no_food, no_move, noscore, ntraps, purse, + quiet, vf_hit; + +extern unsigned int numscores; + +extern int dnum, e_levels[]; +extern uint64_t seed; + +extern WINDOW *hw; + +extern coord delta, oldpos, stairs; + +extern PLACE places[]; + +extern THING *cur_armor, *cur_ring[], *cur_weapon, *l_last_pick, + *last_pick, *lvl_obj, *mlist, player; + +extern struct h_list helpstr[]; + +extern struct room *oldrp, passages[], rooms[]; + +extern struct stats max_stats; + +extern struct monster monsters[]; + +extern struct obj_info arm_info[], pot_info[], ring_info[], + scr_info[], things[], ws_info[], weap_info[]; + +/* + * Function types + */ +void _attach(THING **list, THING *item); +void _detach(THING **list, THING *item); +void _free_list(THING **ptr); +void addmsg(struct rogue_state *rs,char *fmt, ...); +bool add_haste(struct rogue_state *rs,bool potion); +char add_line(struct rogue_state *rs,char *fmt, char *arg); +void add_pack(struct rogue_state *rs,THING *obj, bool silent); +void add_pass(void); +void add_str(str_t *sp, int amt); +void accnt_maze(int y, int x, int ny, int nx); +void aggravate(struct rogue_state *rs); +int attack(struct rogue_state *rs,THING *mp); +void badcheck(char *name, struct obj_info *info, int bound); +void bounce(struct rogue_state *rs,THING *weap, char *mname, bool noend); +void call(struct rogue_state *rs); +void call_it(struct rogue_state *rs,struct obj_info *info); +bool cansee(struct rogue_state *rs,int y, int x); +int center(char *str); +void chg_str(int amt); +void check_level(struct rogue_state *rs); +void conn(struct rogue_state *rs,int r1, int r2); +void command(struct rogue_state *rs); +void create_obj(struct rogue_state *rs); + +void current(struct rogue_state *rs,THING *cur, char *how, char *where); +void d_level(struct rogue_state *rs); +void death(char monst); +char death_monst(void); +void dig(int y, int x); +void discard(THING *item); +void discovered(struct rogue_state *rs); +int dist(int y1, int x1, int y2, int x2); +int dist_cp(coord *c1, coord *c2); +int do_chase(struct rogue_state *rs,THING *th); +void do_daemons(struct rogue_state *rs,int flag); +void do_fuses(struct rogue_state *rs,int flag); +void do_maze(struct room *rp); +void do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta); +void do_move(struct rogue_state *rs,int dy, int dx); +void do_passages(struct rogue_state *rs); +void do_pot(struct rogue_state *rs,int type, bool knowit); +void do_rooms(struct rogue_state *rs); +void do_run(char ch); +void do_zap(struct rogue_state *rs); +void doadd(struct rogue_state *rs,char *fmt, va_list args); +void door(struct room *rm, coord *cp); +void door_open(struct rogue_state *rs,struct room *rp); +void drain(struct rogue_state *rs); +void draw_room(struct room *rp); +void drop(struct rogue_state *rs); +void eat(struct rogue_state *rs); +size_t encread(char *start, size_t size, FILE *inf); +size_t encwrite(char *start, size_t size, FILE *outf); +int endmsg(struct rogue_state *rs); +void enter_room(struct rogue_state *rs,coord *cp); +void erase_lamp(coord *pos, struct room *rp); +int exp_add(THING *tp); +void extinguish(void (*func)(struct rogue_state *rs,int)); +void fall(struct rogue_state *rs,THING *obj, bool pr); +void fire_bolt(struct rogue_state *rs,coord *start, coord *dir, char *name); +char floor_at(void); +void flush_type(void); +int fight(struct rogue_state *rs,coord *mp, THING *weap, bool thrown); +void fix_stick(THING *cur); +void fuse(void (*func)(struct rogue_state *rs,int), int arg, int time, int type); +bool get_dir(struct rogue_state *rs); +int gethand(struct rogue_state *rs); +void give_pack(struct rogue_state *rs,THING *tp); +void help(struct rogue_state *rs); +void hit(struct rogue_state *rs,char *er, char *ee, bool noend); +void horiz(struct room *rp, int starty); +void leave_room(struct rogue_state *rs,coord *cp); +void lengthen(void (*func)(struct rogue_state *rs,int), int xtime); +void look(struct rogue_state *rs,bool wakeup); +int hit_monster(struct rogue_state *rs,int y, int x, THING *obj); +void identify(struct rogue_state *rs); +void illcom(struct rogue_state *rs,int ch); +void init_check(void); +void init_colors(void); +void init_materials(void); +void init_names(void); +void init_player(struct rogue_state *rs); +void init_probs(void); +void init_stones(void); +void init_weapon(THING *weap, int which); +bool inventory(struct rogue_state *rs,THING *list, int type); +void invis_on(void); +void killed(struct rogue_state *rs,THING *tp, bool pr); +void kill_daemon(void (*func)(struct rogue_state *rs,int)); +bool lock_sc(void); +void miss(struct rogue_state *rs,char *er, char *ee, bool noend); +void missile(struct rogue_state *rs,int ydelta, int xdelta); +void money(struct rogue_state *rs,int value); +int move_monst(struct rogue_state *rs,THING *tp); +void move_msg(struct rogue_state *rs,THING *obj); +int msg(struct rogue_state *rs,char *fmt, ...); +void nameit(THING *obj, char *type, char *which, struct obj_info *op, char *(*prfunc)(THING *)); +void new_level(struct rogue_state *rs); +void new_monster(struct rogue_state *rs,THING *tp, char type, coord *cp); +void numpass(int y, int x); +void option(struct rogue_state *rs); +void open_score(void); +void parse_opts(char *str); +void passnum(void); +char *pick_color(char *col); +int pick_one(struct rogue_state *rs,struct obj_info *info, int nitems); +void pick_up(struct rogue_state *rs,char ch); +void picky_inven(struct rogue_state *rs); +void pr_spec(struct obj_info *info, int nitems); +void pr_list(void); +void put_bool(void *b); +void put_inv_t(void *ip); +void put_str(void *str); +void put_things(struct rogue_state *rs); +void putpass(coord *cp); +void print_disc(struct rogue_state *rs,char); +void quaff(struct rogue_state *rs); +void raise_level(struct rogue_state *rs); +char randmonster(bool wander); +void read_scroll(struct rogue_state *rs); +void relocate(struct rogue_state *rs,THING *th, coord *new_loc); +void remove_mon(struct rogue_state *rs,coord *mp, THING *tp, bool waskill); +void reset_last(void); +bool restore(struct rogue_state *rs,char *file, char **envp); +int ring_eat(int hand); +void ring_on(struct rogue_state *rs); +void ring_off(struct rogue_state *rs); +int rnd(int range); +int rnd_room(void); +int roll(int number, int sides); +int rs_save_file(FILE *savef); +int rs_restore_file(FILE *inf); +void runto(struct rogue_state *rs,coord *runner); +void rust_armor(struct rogue_state *rs,THING *arm); +int save(int which); +void save_file(FILE *savef,int32_t guiflag); +void save_game(struct rogue_state *rs); +int save_throw(int which, THING *tp); +void score(int amount, int flags, char monst); +void search(struct rogue_state *rs); +void set_know(THING *obj, struct obj_info *info); +void set_oldch(THING *tp, coord *cp); +void setup(void); +void shell(struct rogue_state *rs); +bool show_floor(void); +void show_map(void); +void show_win(struct rogue_state *rs,char *message); +int sign(int nm); +int spread(int nm); +void start_daemon(void (*func)(struct rogue_state *rs,int), int arg, int type); +void start_score(void); +void status(struct rogue_state *rs); +int step_ok(int ch); +void strucpy(char *s1, char *s2, int len); +int swing(int at_lvl, int op_arm, int wplus); +void take_off(struct rogue_state *rs); +void teleport(struct rogue_state *rs); +void total_winner(struct rogue_state *rs); +void thunk(struct rogue_state *rs,THING *weap, char *mname, bool noend); +void treas_room(struct rogue_state *rs); +void turnref(void); +void u_level(struct rogue_state *rs); +void uncurse(THING *obj); +void unlock_sc(void); +void vert(struct room *rp, int startx); +void wait_for(struct rogue_state *rs,int ch); +THING *wake_monster(struct rogue_state *rs,int y, int x); +void wanderer(struct rogue_state *rs); +void waste_time(struct rogue_state *rs); +void wear(struct rogue_state *rs); +void whatis(struct rogue_state *rs,bool insist, int type); +void wield(struct rogue_state *rs); + +bool chase(THING *tp, coord *ee); +bool diag_ok(coord *sp, coord *ep); +bool dropcheck(struct rogue_state *rs,THING *obj); +bool fallpos(coord *pos, coord *newpos); +bool find_floor(struct room *rp, coord *cp, int limit, bool monst); +bool is_magic(THING *obj); +bool is_symlink(char *sp); +bool levit_check(struct rogue_state *rs); +bool pack_room(struct rogue_state *rs,bool from_floor, THING *obj); +bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl); +bool see_monst(THING *mp); +bool seen_stairs(void); +bool turn_ok(int y, int x); +bool turn_see(bool turn_off); +bool is_current(struct rogue_state *rs,THING *obj); +int passwd(void); + +char be_trapped(struct rogue_state *rs,coord *tc); +char floor_ch(void); +char pack_char(void); +char readchar(struct rogue_state *rs); +char rnd_thing(void); + +char *charge_str(THING *obj); +char *choose_str(char *ts, char *ns); +char *inv_name(THING *obj, bool drop); +char *nullstr(THING *ignored); +char *num(int n1, int n2, char type); +char *ring_num(THING *obj); +char *set_mname(THING *tp); +char *vowelstr(char *str); + +int get_bool(struct rogue_state *rs,void *vp, WINDOW *win); +int get_inv_t(struct rogue_state *rs,void *vp, WINDOW *win); +int get_num(struct rogue_state *rs,void *vp, WINDOW *win); +int get_sf(struct rogue_state *rs,void *vp, WINDOW *win); +int get_str(struct rogue_state *rs,void *vopt, WINDOW *win); +int trip_ch(int y, int x, int ch); + +coord *find_dest(struct rogue_state *rs,THING *tp); +coord *rndmove(THING *who); + +THING *find_obj(struct rogue_state *rs,int y, int x); +THING *get_item(struct rogue_state *rs,char *purpose, int type); +THING *leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all); +THING *new_item(void); +THING *new_thing(struct rogue_state *rs); +void end_line(struct rogue_state *rs); + +void runners(struct rogue_state *rs,int); +void land(struct rogue_state *rs,int); +void visuals(struct rogue_state *rs,int); +void come_down(struct rogue_state *rs,int); +void stomach(struct rogue_state *rs,int); +void nohaste(struct rogue_state *rs,int); +void sight(struct rogue_state *rs,int); +void unconfuse(struct rogue_state *rs,int); +void rollwand(struct rogue_state *rs,int); +void unsee(struct rogue_state *rs,int); +void swander(struct rogue_state *rs,int); +void doctor(struct rogue_state *rs,int); + +void playit(struct rogue_state *rs); + +struct room *roomin(struct rogue_state *rs,coord *cp); + +#define MAXDAEMONS 20 + +extern struct delayed_action { + int d_type; + void (*d_func)(struct rogue_state *rs,int); + int d_arg; + int d_time; +} d_list[MAXDAEMONS]; + +typedef struct { + char *st_name; + int st_value; +} STONE; + +extern int total; +extern int between; +extern int group; +extern coord nh; +extern char *rainbow[]; +extern int cNCOLORS; +extern STONE stones[]; +extern int cNSTONES; +extern char *wood[]; +extern int cNWOOD; +extern char *metal[]; +extern int cNMETAL; diff --git a/src/cc/rogue/rogue.html b/src/cc/rogue/rogue.html new file mode 100644 index 000000000..00dab46bf --- /dev/null +++ b/src/cc/rogue/rogue.html @@ -0,0 +1,1060 @@ + + + + + + + + + + +

A Guide to the Dungeons of Doom

+ +

Michael C. Toy
+Kenneth C. R. C. Arnold

+ +

Computer Systems Research +Group
+Department of Electrical Engineering and Computer +Science
+University of California
+Berkeley, California 94720

+ + +

ABSTRACT

+ +
+
+

Rogue is a visual CRT based fantasy game which runs under the + UNIX† timesharing system. This paper describes how + to play rogue, and gives a few hints for those who might otherwise get + lost in the Dungeons of Doom.

+
+
+ +

1. Introduction

+ +

You have just finished your years as a +student at the local fighter’s guild. After much +practice and sweat you have finally completed your training +and are ready to embark upon a perilous adventure. As a test +of your skills, the local guildmasters have sent you into +the Dungeons of Doom. Your task is to return with the Amulet +of Yendor. Your reward for the completion of this task will +be a full membership in the local guild. In addition, you +are allowed to keep all the loot you bring back from the +dungeons.

+ +

In preparation for your journey, you are +given an enchanted mace, a bow, and a quiver of arrows taken +from a dragon’s hoard in the far off Dark Mountains. +You are also outfitted with elf-crafted armor and given +enough food to reach the dungeons. You say goodbye to family +and friends for what may be the last time and head up the +road.

+ +

You set out on your way to the dungeons and +after several days of uneventful travel, you see the +ancient ruins that mark the entrance to the Dungeons of +Doom. It is late at night, so you make camp at the entrance +and spend the night sleeping under the open skies. In the +morning you gather your weapons, put on your armor, eat what +is almost your last food, and enter the +dungeons.

+ +

2. What is going on here?

+

You have just begun a game of rogue. Your +goal is to grab as much treasure as you can, find the Amulet +of Yendor, and get out of the Dungeons of Doom alive. On the +screen, a map of where you have been and what you have seen +on the current dungeon level is kept. As you explore more of +the level, it appears on the screen in front of +you.

+

Rogue differs from most computer fantasy +games in that it is screen oriented. Commands are all one or +two keystrokes1 and the +results of your commands are displayed graphically on the +screen rather than being explained in words2.

+

Another major difference between rogue and other computer fantasy games is that once you have solved +all the puzzles in a standard fantasy game, it has lost most +of its excitement and it ceases to be fun. Rogue, on the +other hand, generates a new dungeon every time you play it +and even the author finds it an entertaining and exciting +game.

+ +

3. What do all those things on the screen mean?

+

In order to understand what is going on in +rogue you have to first get some grasp of what rogue is +doing with the screen. The rogue screen is intended to +replace the “You can see ...” descriptions of +standard fantasy games. Figure 1 is a sample of what a +rogue screen might look like.

+ +
+ +
+
+____________________________________________________________
+
+
+                        ------------
+                        |..........+
+                        |..@....]..|
+                        |....B.....|
+                        |..........|
+                        -----+------
+
+
+
+Level: 1  Gold: 0      Hp: 12(12)  Str: 16(16)  Arm: 4  Exp: 1/0
+
+                          Figure 1
+____________________________________________________________
+
+
+
+

3.1. The bottom line

+

At the bottom line of the screen are a few +pieces of cryptic information describing your current +status. Here is an explanation of what these things +mean:

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Level

+

This number indicates how deep you +have gone in the dungeon. It starts at one and goes up as +you go deeper into the dungeon.

+

Gold

+

The number of gold pieces you have managed to find and keep with you + so far.

+

Hp

+

Your current and maximum health points. +Health points indicate how much damage you can take before +you die. The more you get hit in a fight, the lower they +get. You can regain health points by resting. The number in +parentheses is the maximum number your health points can +reach.

+ +
+

Str

+ +

Your current strength and maximum ever +strength. This can be any integer less than or equal to 31, +or greater than or equal to three. The higher the num- ber, +the stronger you are. The number in the parentheses is the +maximum strength you have attained so far this +game.

+ +
+

Arm

+

Your current armor protection. This +number indicates how effective your armor is in stopping +blows from unfriendly creatures. The higher this number is, +the more effective the armor.

+ +
+

Exp

+

These two numbers give your current +experience level and experience points. As you do things, +you gain experience points. At certain experience point +totals, you gain an experience level. The more experienced +you are, the better you are able to fight and to withstand +magical attacks.

+ +
+ +

 

+ +

3.2. The top line

+

The top line of the screen is reserved for +printing messages that describe things that are impossible +to represent visually. If you see a “--More--” +on the top line, this means that rogue wants to print +another message on the screen, but it wants to make certain +that you have read the one that is there first. To read the +next message, just type a space.

+ + +

3.3. The rest of the screen

+

The rest of the screen is the map of the +level as you have explored it so far. Each symbol on the +screen repre- sents something. Here is a list of what the +various symbols mean:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

@

+

This symbol represents you, the adventurer.

+

- |

+

These symbols represent the walls of rooms.

+

+

+

A door to/from a room.

+

.

+

The floor of a room.

+

#

+

The floor of a passage between rooms.

+

*

+

A pile or pot of gold.

+

)

+

A weapon of some sort.

+

]

+

A piece of armor.

+

!

+

A flask containing a magic potion.

+

?

+

A piece of paper, usually a magic scroll.

+

=

+

A ring with magic properties

+

/

+

A magical staff or wand

+

^

+

A trap, watch out for these.

+

%

+

A staircase to other levels

+

:

+

A piece of food.

+

A-Z

+

The uppercase letters represent the various + inhabitants of the Dungeons of Doom. Watch out, they can be nasty and + vicious.

+ + +

4. Commands

+

Commands are given to rogue by typing one or two characters. +Most commands can be preceded by a count to repeat them (e.g. typing “10s” will +do ten searches). Commands for which counts make no sense have the count +ignored. To cancel a count or a prefix, type <ESCAPE> . The list of commands is +rather long, but it can be read at any time during the game +with the “?” command. Here it is for reference, +with a short explanation of each +command.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

?

+

The help command. Asks for a character to give help + on. If you type a “*”, it will list all the commands, otherwise it will + explain what the character you typed does.

+

/

+

This is the “What is that on the screen?” command. A + “/” followed by any character that you see on the level, will tell you + what that character is. For instance, typing “/@” will tell you that the + “@” symbol represents you, the player.

+

h, H, ^H

+   +

Move left. You move one space to the left. If you use + upper case “h”, you will continue to move left until you run into + something. This works for all movement commands (e.g. “L” means run in + direction “l”) If you use the “control” “h”, you will continue moving in + the specified direction until you pass something interesting or run into + a wall. You should experiment with this, since it is a very useful + command, but very difficult to describe. This also works for all movement +commands.

+

j

+

Move down.

+

k

+

Move up.

+

l

+

Move right.

+

y

+

Move diagonally up and left.

+

u

+

Move diagonally up and right.

+

b

+

Move diagonally down and left.

+

n

+

Move diagonally down and right.

+

t

+

Throw an object. This is a prefix command. When followed with a + direction it throws an object in the specified direction. (e.g. type +“th” to throw something to the +left.)

+

f

+

Fight until someone dies. When followed with a direction this will force you to fight the creature +in that direction until either you or it bites the big +one.

+

m

+

Move onto something without picking it up. This will move you one + space in the direction you specify and, if there is an object there you + can pick up, it won’t do it.

+

z

+

Zap prefix. Point a staff or wand in a given direction and fire it. + Even non-directional staves must be pointed in some direction to be + used.

+

^

+

Identify trap command. If a trap is on your map and you can’t + remember what type it is, you can get rogue to remind you by getting + next to it and typing “^” followed by the direction that would move +you on top of it.

+

s

+

Search for traps and secret doors. Examine each space immediately + adjacent to you for the existence of a trap or secret door. There is a + large chance that even if there is something there, you won’t find it, + so you might have to search a while before you find something.

+

>

+

Climb down a staircase to the next level. Not surprisingly, this can only be done if you are +standing on staircase.

+

<

+

Climb up a staircase to the level above. This can’t be done without + the Amulet of Yendor +in your possession.

+

.

+

Rest. This is the “do nothing” command. This is good for waiting and + healing.

+

,

+

Pick up something. This picks up whatever you are currently standing on, if you are +standing on anything at all.

+

i

+

Inventory. List what you are carrying in +your pack.

+

I

+

Selective inventory. Tells you what a single item in your pack is.

+

q

+

Quaff one of the potions you are carrying.

+

r

+

Read one of the scrolls in your pack.

+

e

+

Eat food from your pack.

+

w

+

Wield a weapon. Take a weapon out of your pack and carry it for use + in combat, replacing the one you are currently using (if any).

+

W

+

Wear armor. You can only wear one suit of armor at a time. This + takes extra time.

+

T

+

Take armor off. You can’t remove armor that is cursed. This takes + extra time.

+

P

+

Put on a ring. You can wear only two rings at a time (one on each + hand). If you aren’t wearing any rings, this command will ask you which + hand you want to wear it on, otherwise, it will place it on the unused + hand. The program assumes that you wield your sword in your right hand.

+

R

+

Remove a ring. If you are only wearing one ring, this command takes + it off. If you are wearing two, it will ask you which one you wish to + remove,

+

d

+

Drop an object. Take something out of your pack and leave it lying + on the floor. Only one object can occupy each space. You cannot drop a + cursed object at all if you are wielding or wearing it.

+

c

+

Call an object something. If you have a type of object in your pack + which you wish to remember something about, you can use the call command + to give a name to that type of object. This is usually used when you + figure out what a potion, scroll, ring, or staff is after you pick it + up, or when you want to remember which of those swords in your pack you + were wielding.

+

D

+

Print out which things you’ve discovered something about. This + command will ask you what type of thing you are interested in. If you + type the character for a given type of object (e.g. +“!” for potion) it will tell you which kinds of +that type of object you’ve discovered (i.e., figured out what they + are). This command works for +potions, scrolls, rings, and staves and +wands.

+

o

+

Examine and set options. This command is further explained in the + section on options.

+

^R

+

Redraws the screen. Useful if spurious messages or transmission + errors have messed up the display.

+

^P

+

Print last message. Useful when a message disappears before you can + read it. This only repeats the last message that was not a mistyped + command so that you don’t loose anything by accidentally typing the + wrong character instead of ^P.

+

<ESCAPE>

+   + Cancel a command, prefix, or count.
+

!

+

Escape to a shell for some commands.

+

Q

+

Quit. Leave the game.

+

S

+

Save the current game in a file. It will ask you whether you wish to + use the default save file. +Caveat: Rogue won’t let you start up a copy of +a saved game, and it removes the save file as soon as you +start up a restored game. This is to prevent people from +saving a game just before a dangerous position and then +restart- ing it if they die. To restore a saved game, give +the file name as an argument to rogue. As +in

+

% rogue +save_file

+

To restart from the default save file (see below), run

+

% rogue -r

+

v

+

Prints the program version number.

+

)

+

Print the weapon you are currently wielding

+

]

+

Print the armor you are currently wearing

+

=

+

Print the rings you are currently wearing

+

@

+

Reprint the status line on the message line

+ +
+ +

5. Rooms

+

Rooms in the dungeons are either lit or +dark. If you walk into a lit room, the entire room will be +drawn on the screen as soon as you enter. If you walk into a +dark room, it will only be displayed as you explore it. Upon +leaving a room, all monsters inside the room are erased from +the screen. In the darkness you can only see one space in +all directions around you. A corridor is always +dark.

+ +

6. Fighting

+

If you see a monster and you wish to fight +it, just attempt to run into it. Many times a monster you +find will mind its own business unless you attack it. It is +often the case that discretion is the better part of +valor.

+ +

7. Objects you can find

+

When you find something in the dungeon, it +is common to want to pick the object up. This is +accomplished in rogue by walking over the object (unless you +use the “m” prefix, see above). If you are +carrying too many things, the pro- gram will tell you and it +won’t pick up the object, other- wise it will add it +to your pack and tell you what you just picked +up.

+ +

Many of the commands that operate on +objects must prompt you to find out which object you want to +use. If you change your mind and don’t want to do that +command after all, just type an +<ESCAPE> and the command will be +aborted.

+ +

Some objects, like armor and weapons, are +easily dif- ferentiated. Others, like scrolls and potions, +are given labels which vary according to type. During a +game, any two of the same kind of object with the same label +are the same type. However, the labels will vary from game +to game.

+ +

When you use one of these labeled objects, +if its effect is obvious, rogue will remember what it is for +you. If it’s effect isn’t extremely obvious you +will be asked what you want to scribble on it so you will +recognize it later, or you can use the “call” +command (see above).

+ +

7.1. Weapons

+

Some weapons, like arrows, come in bunches, +but most come one at a time. In order to use a weapon, you +must wield it. To fire an arrow out of a bow, you must first +wield the bow, then throw the arrow. You can only wield one +weapon at a time, but you can’t change weapons if the +one you are currently wielding is cursed. The commands to +use weapons are “w” (wield) and “t” +(throw).

+ +

7.2. Armor

+ +

There are various sorts of armor lying around in the dungeon. Some of it is +enchanted, some is cursed, and some is just normal. Different armor types have +different armor protection. The higher the armor protection, the more protection the armor affords against the blows of +monsters. Here is a list of the various armor types and +their normal armor protection:

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeProtection
None0
Leather armor2
Studded leather / Ring mail3
Scale mail 4
Chain mail  5
Banded mail / Splint mail6
Plate mail     7
+

 

+

+If a piece of armor is enchanted, its +armor protection will be higher than normal. If a suit of +armor is cursed, its armor protection will be lower, and you +will not be able to remove it. However, not all armor with a +protection that is lower than normal is +cursed. + +

+ +

The commands to use weapons are +“W” (wear) and “T” (take +off).

+ +

+ +7.3. Scrolls

+

Scrolls come with titles in an unknown tongue3. After you read a scroll, it +disappears from your pack. The com mand to use a +scroll is “r” (read).

+ +

+ +7.4. Potions + +

+ +

Potions are labeled by the color of the +liquid inside the flask. They disappear after being quaffed. +The command to use a scroll is “q” +(quaff).

+ +

7.5. Staves and Wands

+

Staves and wands do the same kinds of +things. Staves are identified by a type of wood; wands by a +type of metal or bone. They are generally things you want to +do to some- thing over a long distance, so you must point +them at what you wish to affect to use them. Some staves are +not affected by the direction they are pointed, though. +Staves come with multiple magic charges, the number being +random, and when they are used up, the staff is just a piece +of wood or metal.

+ +

The command to use a wand or staff is +“z” (zap)

+ +

7.6. Rings

+ +

Rings are very useful items, since they are +relatively permanent magic, unlike the usually fleeting +effects of potions, scrolls, and staves. Of course, the bad +rings are also more powerful. Most rings also cause you to +use up food more rapidly, the rate varying with the type of +ring. Rings are differentiated by their stone settings. The +com- mands to use rings are “P” (put on) and +“R” (remove).

+ +

7.7. Food

+ +

Food is necessary to keep you going. If you +go too long without eating you will faint, and eventually +die of starvation. The command to use food is +“e” (eat).

+ +

8. Options

+

Due to variations in personal tastes and +conceptions of the way rogue should do things, there are a +set of options you can set that cause rogue to behave in +various different ways.

+ +

8.1 Setting the options

+ +

There are two ways to set the options. The +first is with the “o” command of rogue; the +second is with the “ROGUEOPTS” environment +variable.

+ +

8.1.1. Using the ‘o’ command

+ +

When you type “o” in rogue, it +clears the screen and displays the current settings for all +the options. It then places the cursor by the value of the +first option and waits for you to type. You can type a +<RETURN> which means to go to the next +option, a “−” which means to go to the +previous option, an <ESCAPE> which +means to return to the game, or you can give the option a +value. For boolean options this merely involves typing +“t” for true or “f” for false. For +string options, type the new value followed by a +<RETURN> .

+ +

8.1.2. Using the ROGUEOPTS variable

+ +

The ROGUEOPTS variable is a string +containing a comma separated list of initial values for the +various options. Boolean variables can be turned on by +listing their name or turned off by putting a +“no” in front of the name. Thus to set up an +environment variable so that jump is on, terse +is off, and the name is set to “Blue +Meanie”, use the command

+ +

% setenv ROGUEOPTS +"jump,noterse,name=Blue Meanie"4

+ +

8.2. Option list

+ +

Here is a list of the options and an +explanation of what each one is for. The default value for +each is enclosed in square brackets. For character string +options, input over fifty characters will be +ignored.

+ +

terse +[noterse]

+
+

+ Useful for those who are tired of the +sometimes lengthy messages of rogue. This is a useful option +for playing on slow terminals, so this option defaults to +terse if you are on a slow (1200 baud or under) +terminal.

+
+ +

jump +[nojump]

+
+

If this option is set, running moves will +not be displayed until you reach the end of the move. This +saves considerable cpu and display time. This option +defaults to jump if you are using a slow +terminal.

+
+

flush +[noflush]

+
+

All typeahead is thrown away after each round of battle. This is useful for those who type far +ahead and then watch in dismay as a Bat kills +them.

+
+

seefloor +[seefloor]

+
+

Display the floor around you on the screen +as you move through dark rooms. Due to the amount of +characters generated, this option defaults to +noseefloor if you are using a slow +terminal.

+
+

passgo +[nopassgo]

+
+

Follow turnings in passageways. If you run +in a pas- sage and you run into stone or a wall, rogue will +see if it can turn to the right or left. If it can only turn +one way, it will turn that way. If it can turn either or +neither, it will stop. This algorithm can sometimes lead to +slightly confusing occurrences which is why it defaults to +nopassgo.

+
+

tombstone +[tombstone]

+
+

Print out the tombstone at the end if you +get killed. This is nice but slow, so you can turn it off if +you like.

+
+

inven +[overwrite]

+
+

Inventory type. This can have one of three +values: overwrite, slow, or clear. With +overwrite the top lines of the map are overwritten +with the list when inventory is requested or when +“Which item do you wish to . . .? ” +questions are answered with a “*”. How- ever, if +the list is longer than a screenful, the screen is cleared. +With slow, lists are displayed one item at a time on +the top of the screen, and with clear, the screen is +cleared, the list is displayed, and then the dungeon level +is re-displayed. Due to speed considerations, clear +is the default for terminals without clear-to-end-of-line +capabilities.

+
+

name [account +name]

+
+

This is the name of your character. It is +used if you get on the top ten scorer’s +list.

+
+

fruit +[slime-mold]

+
+

This should hold the name of a fruit that +you enjoy eating. It is basically a whimsy that rogue uses +in a couple of places.

+
+

file +[~/rogue.save]

+
+

The default file name for saving the game. +If your phone is hung up by accident, rogue will +automatically save the game in this file. The file name may +start with the special character “~” which +expands to be your home directory.

+
+

9. Scoring

+ +

Rogue usually maintains a list of the top +scoring people or scores on your machine. Depending on how +it is set up, it can post either the top scores or the top +players. In the latter case, each account on the machine can +post only one non-winning score on this list. If you score +higher than someone else on this list, or better your previous score on the list, you will be inserted in the proper +place under your current name. How many scores are kept can +also be set up by whoever installs it on your +machine.

+ +

If you quit the game, you get out with all +of your gold intact. If, however, you get killed in the +Dungeons of Doom, your body is forwarded to your +next-of-kin, along with 90% of your gold; ten percent of +your gold is kept by the Dungeons’ wizard as a fee5. This should make you +consider whether you want to take one last hit at that +monster and possibly live, or quit and thus stop with +whatever you have. If you quit, you do get all your gold, +but if you swing and live, you might find +more.

+ +

If you just want to see what the current top players/games list is, you can +type

+

% rogue −s

+ +

10. Acknowledgements

+ +

Rogue was originally conceived of by Glenn +Wichman and Michael Toy. Ken Arnold and Michael Toy then +smoothed out the user interface, and added jillions of new +features. We would like to thank Bob Arnold, Michelle Busch, +Andy Hatcher, Kipp Hickman, Mark Horton, Daniel Jensen, Bill +Joy, Joe Kalash, Steve Maurer, Marty McNary, Jan Miller, and +Scott Nelson for their ideas and assistance; and also the +teeming multitudes who graciously ignored work, school, and +social life to play rogue and send us bugs, complaints, suggestions, and just plain flames. And also +Mom.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
UNIX is a registered trademark of The Open Group
1As opposed to pseudo English sentences.
2A minimum screen size of 24 lines by 80 columns is required. If the + screen is larger, only the 24x80 section +will be used for the map.
3Actually, it's a dialect spoken only by the twenty-seven members of + a tribe in Outer Mongolia, but you're not supposed to know that.
4For those of you who use the Bourne shell sh (1), the commands would be

$ ROGUEOPTS="jump,noterse,name=Blue Meanie"
+$ export ROGUEOPTS

5The Dungeon's wizard is named Wally the Wonder Badger. Invocations + should be accompanied by a sizable donation.
+ + diff --git a/src/cc/rogue/rogue.html.in b/src/cc/rogue/rogue.html.in new file mode 100644 index 000000000..260cb7a4d --- /dev/null +++ b/src/cc/rogue/rogue.html.in @@ -0,0 +1,1060 @@ + + + + + + + + + + +

A Guide to the Dungeons of Doom

+ +

Michael C. Toy
+Kenneth C. R. C. Arnold

+ +

Computer Systems Research +Group
+Department of Electrical Engineering and Computer +Science
+University of California
+Berkeley, California 94720

+ + +

ABSTRACT

+ +
+
+

Rogue is a visual CRT based fantasy game which runs under the + UNIX† timesharing system. This paper describes how + to play rogue, and gives a few hints for those who might otherwise get + lost in the Dungeons of Doom.

+
+
+ +

1. Introduction

+ +

You have just finished your years as a +student at the local fighter’s guild. After much +practice and sweat you have finally completed your training +and are ready to embark upon a perilous adventure. As a test +of your skills, the local guildmasters have sent you into +the Dungeons of Doom. Your task is to return with the Amulet +of Yendor. Your reward for the completion of this task will +be a full membership in the local guild. In addition, you +are allowed to keep all the loot you bring back from the +dungeons.

+ +

In preparation for your journey, you are +given an enchanted mace, a bow, and a quiver of arrows taken +from a dragon’s hoard in the far off Dark Mountains. +You are also outfitted with elf-crafted armor and given +enough food to reach the dungeons. You say goodbye to family +and friends for what may be the last time and head up the +road.

+ +

You set out on your way to the dungeons and +after several days of uneventful travel, you see the +ancient ruins that mark the entrance to the Dungeons of +Doom. It is late at night, so you make camp at the entrance +and spend the night sleeping under the open skies. In the +morning you gather your weapons, put on your armor, eat what +is almost your last food, and enter the +dungeons.

+ +

2. What is going on here?

+

You have just begun a game of rogue. Your +goal is to grab as much treasure as you can, find the Amulet +of Yendor, and get out of the Dungeons of Doom alive. On the +screen, a map of where you have been and what you have seen +on the current dungeon level is kept. As you explore more of +the level, it appears on the screen in front of +you.

+

Rogue differs from most computer fantasy +games in that it is screen oriented. Commands are all one or +two keystrokes1 and the +results of your commands are displayed graphically on the +screen rather than being explained in words2.

+

Another major difference between rogue and other computer fantasy games is that once you have solved +all the puzzles in a standard fantasy game, it has lost most +of its excitement and it ceases to be fun. Rogue, on the +other hand, generates a new dungeon every time you play it +and even the author finds it an entertaining and exciting +game.

+ +

3. What do all those things on the screen mean?

+

In order to understand what is going on in +rogue you have to first get some grasp of what rogue is +doing with the screen. The rogue screen is intended to +replace the “You can see ...” descriptions of +standard fantasy games. Figure 1 is a sample of what a +rogue screen might look like.

+ +
+ +
+
+____________________________________________________________
+
+
+                        ------------
+                        |..........+
+                        |..@....]..|
+                        |....B.....|
+                        |..........|
+                        -----+------
+
+
+
+Level: 1  Gold: 0      Hp: 12(12)  Str: 16(16)  Arm: 4  Exp: 1/0
+
+                          Figure 1
+____________________________________________________________
+
+
+
+

3.1. The bottom line

+

At the bottom line of the screen are a few +pieces of cryptic information describing your current +status. Here is an explanation of what these things +mean:

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Level

+

This number indicates how deep you +have gone in the dungeon. It starts at one and goes up as +you go deeper into the dungeon.

+

Gold

+

The number of gold pieces you have managed to find and keep with you + so far.

+

Hp

+

Your current and maximum health points. +Health points indicate how much damage you can take before +you die. The more you get hit in a fight, the lower they +get. You can regain health points by resting. The number in +parentheses is the maximum number your health points can +reach.

+ +
+

Str

+ +

Your current strength and maximum ever +strength. This can be any integer less than or equal to 31, +or greater than or equal to three. The higher the num- ber, +the stronger you are. The number in the parentheses is the +maximum strength you have attained so far this +game.

+ +
+

Arm

+

Your current armor protection. This +number indicates how effective your armor is in stopping +blows from unfriendly creatures. The higher this number is, +the more effective the armor.

+ +
+

Exp

+

These two numbers give your current +experience level and experience points. As you do things, +you gain experience points. At certain experience point +totals, you gain an experience level. The more experienced +you are, the better you are able to fight and to withstand +magical attacks.

+ +
+ +

 

+ +

3.2. The top line

+

The top line of the screen is reserved for +printing messages that describe things that are impossible +to represent visually. If you see a “--More--” +on the top line, this means that rogue wants to print +another message on the screen, but it wants to make certain +that you have read the one that is there first. To read the +next message, just type a space.

+ + +

3.3. The rest of the screen

+

The rest of the screen is the map of the +level as you have explored it so far. Each symbol on the +screen repre- sents something. Here is a list of what the +various symbols mean:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

@

+

This symbol represents you, the adventurer.

+

- |

+

These symbols represent the walls of rooms.

+

+

+

A door to/from a room.

+

.

+

The floor of a room.

+

#

+

The floor of a passage between rooms.

+

*

+

A pile or pot of gold.

+

)

+

A weapon of some sort.

+

]

+

A piece of armor.

+

!

+

A flask containing a magic potion.

+

?

+

A piece of paper, usually a magic scroll.

+

=

+

A ring with magic properties

+

/

+

A magical staff or wand

+

^

+

A trap, watch out for these.

+

%

+

A staircase to other levels

+

:

+

A piece of food.

+

A-Z

+

The uppercase letters represent the various + inhabitants of the Dungeons of Doom. Watch out, they can be nasty and + vicious.

+ + +

4. Commands

+

Commands are given to rogue by typing one or two characters. +Most commands can be preceded by a count to repeat them (e.g. typing “10s” will +do ten searches). Commands for which counts make no sense have the count +ignored. To cancel a count or a prefix, type <ESCAPE> . The list of commands is +rather long, but it can be read at any time during the game +with the “?” command. Here it is for reference, +with a short explanation of each +command.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

?

+

The help command. Asks for a character to give help + on. If you type a “*”, it will list all the commands, otherwise it will + explain what the character you typed does.

+

/

+

This is the “What is that on the screen?” command. A + “/” followed by any character that you see on the level, will tell you + what that character is. For instance, typing “/@” will tell you that the + “@” symbol represents you, the player.

+

h, H, ^H

+   +

Move left. You move one space to the left. If you use + upper case “h”, you will continue to move left until you run into + something. This works for all movement commands (e.g. “L” means run in + direction “l”) If you use the “control” “h”, you will continue moving in + the specified direction until you pass something interesting or run into + a wall. You should experiment with this, since it is a very useful + command, but very difficult to describe. This also works for all movement +commands.

+

j

+

Move down.

+

k

+

Move up.

+

l

+

Move right.

+

y

+

Move diagonally up and left.

+

u

+

Move diagonally up and right.

+

b

+

Move diagonally down and left.

+

n

+

Move diagonally down and right.

+

t

+

Throw an object. This is a prefix command. When followed with a + direction it throws an object in the specified direction. (e.g. type +“th” to throw something to the +left.)

+

f

+

Fight until someone dies. When followed with a direction this will force you to fight the creature +in that direction until either you or it bites the big +one.

+

m

+

Move onto something without picking it up. This will move you one + space in the direction you specify and, if there is an object there you + can pick up, it won’t do it.

+

z

+

Zap prefix. Point a staff or wand in a given direction and fire it. + Even non-directional staves must be pointed in some direction to be + used.

+

^

+

Identify trap command. If a trap is on your map and you can’t + remember what type it is, you can get rogue to remind you by getting + next to it and typing “^” followed by the direction that would move +you on top of it.

+

s

+

Search for traps and secret doors. Examine each space immediately + adjacent to you for the existence of a trap or secret door. There is a + large chance that even if there is something there, you won’t find it, + so you might have to search a while before you find something.

+

>

+

Climb down a staircase to the next level. Not surprisingly, this can only be done if you are +standing on staircase.

+

<

+

Climb up a staircase to the level above. This can’t be done without + the Amulet of Yendor +in your possession.

+

.

+

Rest. This is the “do nothing” command. This is good for waiting and + healing.

+

,

+

Pick up something. This picks up whatever you are currently standing on, if you are +standing on anything at all.

+

i

+

Inventory. List what you are carrying in +your pack.

+

I

+

Selective inventory. Tells you what a single item in your pack is.

+

q

+

Quaff one of the potions you are carrying.

+

r

+

Read one of the scrolls in your pack.

+

e

+

Eat food from your pack.

+

w

+

Wield a weapon. Take a weapon out of your pack and carry it for use + in combat, replacing the one you are currently using (if any).

+

W

+

Wear armor. You can only wear one suit of armor at a time. This + takes extra time.

+

T

+

Take armor off. You can’t remove armor that is cursed. This takes + extra time.

+

P

+

Put on a ring. You can wear only two rings at a time (one on each + hand). If you aren’t wearing any rings, this command will ask you which + hand you want to wear it on, otherwise, it will place it on the unused + hand. The program assumes that you wield your sword in your right hand.

+

R

+

Remove a ring. If you are only wearing one ring, this command takes + it off. If you are wearing two, it will ask you which one you wish to + remove,

+

d

+

Drop an object. Take something out of your pack and leave it lying + on the floor. Only one object can occupy each space. You cannot drop a + cursed object at all if you are wielding or wearing it.

+

c

+

Call an object something. If you have a type of object in your pack + which you wish to remember something about, you can use the call command + to give a name to that type of object. This is usually used when you + figure out what a potion, scroll, ring, or staff is after you pick it + up, or when you want to remember which of those swords in your pack you + were wielding.

+

D

+

Print out which things you’ve discovered something about. This + command will ask you what type of thing you are interested in. If you + type the character for a given type of object (e.g. +“!” for potion) it will tell you which kinds of +that type of object you’ve discovered (i.e., figured out what they + are). This command works for +potions, scrolls, rings, and staves and +wands.

+

o

+

Examine and set options. This command is further explained in the + section on options.

+

^R

+

Redraws the screen. Useful if spurious messages or transmission + errors have messed up the display.

+

^P

+

Print last message. Useful when a message disappears before you can + read it. This only repeats the last message that was not a mistyped + command so that you don’t loose anything by accidentally typing the + wrong character instead of ^P.

+

<ESCAPE>

+   + Cancel a command, prefix, or count.
+

!

+

Escape to a shell for some commands.

+

Q

+

Quit. Leave the game.

+

S

+

Save the current game in a file. It will ask you whether you wish to + use the default save file. +Caveat: Rogue won’t let you start up a copy of +a saved game, and it removes the save file as soon as you +start up a restored game. This is to prevent people from +saving a game just before a dangerous position and then +restart- ing it if they die. To restore a saved game, give +the file name as an argument to rogue. As +in

+

% rogue +save_file

+

To restart from the default save file (see below), run

+

% rogue -r

+

v

+

Prints the program version number.

+

)

+

Print the weapon you are currently wielding

+

]

+

Print the armor you are currently wearing

+

=

+

Print the rings you are currently wearing

+

@

+

Reprint the status line on the message line

+ +
+ +

5. Rooms

+

Rooms in the dungeons are either lit or +dark. If you walk into a lit room, the entire room will be +drawn on the screen as soon as you enter. If you walk into a +dark room, it will only be displayed as you explore it. Upon +leaving a room, all monsters inside the room are erased from +the screen. In the darkness you can only see one space in +all directions around you. A corridor is always +dark.

+ +

6. Fighting

+

If you see a monster and you wish to fight +it, just attempt to run into it. Many times a monster you +find will mind its own business unless you attack it. It is +often the case that discretion is the better part of +valor.

+ +

7. Objects you can find

+

When you find something in the dungeon, it +is common to want to pick the object up. This is +accomplished in rogue by walking over the object (unless you +use the “m” prefix, see above). If you are +carrying too many things, the pro- gram will tell you and it +won’t pick up the object, other- wise it will add it +to your pack and tell you what you just picked +up.

+ +

Many of the commands that operate on +objects must prompt you to find out which object you want to +use. If you change your mind and don’t want to do that +command after all, just type an +<ESCAPE> and the command will be +aborted.

+ +

Some objects, like armor and weapons, are +easily dif- ferentiated. Others, like scrolls and potions, +are given labels which vary according to type. During a +game, any two of the same kind of object with the same label +are the same type. However, the labels will vary from game +to game.

+ +

When you use one of these labeled objects, +if its effect is obvious, rogue will remember what it is for +you. If it’s effect isn’t extremely obvious you +will be asked what you want to scribble on it so you will +recognize it later, or you can use the “call” +command (see above).

+ +

7.1. Weapons

+

Some weapons, like arrows, come in bunches, +but most come one at a time. In order to use a weapon, you +must wield it. To fire an arrow out of a bow, you must first +wield the bow, then throw the arrow. You can only wield one +weapon at a time, but you can’t change weapons if the +one you are currently wielding is cursed. The commands to +use weapons are “w” (wield) and “t” +(throw).

+ +

7.2. Armor

+ +

There are various sorts of armor lying around in the dungeon. Some of it is +enchanted, some is cursed, and some is just normal. Different armor types have +different armor protection. The higher the armor protection, the more protection the armor affords against the blows of +monsters. Here is a list of the various armor types and +their normal armor protection:

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeProtection
None0
Leather armor2
Studded leather / Ring mail3
Scale mail 4
Chain mail  5
Banded mail / Splint mail6
Plate mail     7
+

 

+

+If a piece of armor is enchanted, its +armor protection will be higher than normal. If a suit of +armor is cursed, its armor protection will be lower, and you +will not be able to remove it. However, not all armor with a +protection that is lower than normal is +cursed. + +

+ +

The commands to use weapons are +“W” (wear) and “T” (take +off).

+ +

+ +7.3. Scrolls

+

Scrolls come with titles in an unknown tongue3. After you read a scroll, it +disappears from your pack. The com mand to use a +scroll is “r” (read).

+ +

+ +7.4. Potions + +

+ +

Potions are labeled by the color of the +liquid inside the flask. They disappear after being quaffed. +The command to use a scroll is “q” +(quaff).

+ +

7.5. Staves and Wands

+

Staves and wands do the same kinds of +things. Staves are identified by a type of wood; wands by a +type of metal or bone. They are generally things you want to +do to some- thing over a long distance, so you must point +them at what you wish to affect to use them. Some staves are +not affected by the direction they are pointed, though. +Staves come with multiple magic charges, the number being +random, and when they are used up, the staff is just a piece +of wood or metal.

+ +

The command to use a wand or staff is +“z” (zap)

+ +

7.6. Rings

+ +

Rings are very useful items, since they are +relatively permanent magic, unlike the usually fleeting +effects of potions, scrolls, and staves. Of course, the bad +rings are also more powerful. Most rings also cause you to +use up food more rapidly, the rate varying with the type of +ring. Rings are differentiated by their stone settings. The +com- mands to use rings are “P” (put on) and +“R” (remove).

+ +

7.7. Food

+ +

Food is necessary to keep you going. If you +go too long without eating you will faint, and eventually +die of starvation. The command to use food is +“e” (eat).

+ +

8. Options

+

Due to variations in personal tastes and +conceptions of the way rogue should do things, there are a +set of options you can set that cause rogue to behave in +various different ways.

+ +

8.1 Setting the options

+ +

There are two ways to set the options. The +first is with the “o” command of rogue; the +second is with the “ROGUEOPTS” environment +variable.

+ +

8.1.1. Using the ‘o’ command

+ +

When you type “o” in rogue, it +clears the screen and displays the current settings for all +the options. It then places the cursor by the value of the +first option and waits for you to type. You can type a +<RETURN> which means to go to the next +option, a “−” which means to go to the +previous option, an <ESCAPE> which +means to return to the game, or you can give the option a +value. For boolean options this merely involves typing +“t” for true or “f” for false. For +string options, type the new value followed by a +<RETURN> .

+ +

8.1.2. Using the ROGUEOPTS variable

+ +

The ROGUEOPTS variable is a string +containing a comma separated list of initial values for the +various options. Boolean variables can be turned on by +listing their name or turned off by putting a +“no” in front of the name. Thus to set up an +environment variable so that jump is on, terse +is off, and the name is set to “Blue +Meanie”, use the command

+ +

% setenv ROGUEOPTS +"jump,noterse,name=Blue Meanie"4

+ +

8.2. Option list

+ +

Here is a list of the options and an +explanation of what each one is for. The default value for +each is enclosed in square brackets. For character string +options, input over fifty characters will be +ignored.

+ +

terse +[noterse]

+
+

+ Useful for those who are tired of the +sometimes lengthy messages of rogue. This is a useful option +for playing on slow terminals, so this option defaults to +terse if you are on a slow (1200 baud or under) +terminal.

+
+ +

jump +[nojump]

+
+

If this option is set, running moves will +not be displayed until you reach the end of the move. This +saves considerable cpu and display time. This option +defaults to jump if you are using a slow +terminal.

+
+

flush +[noflush]

+
+

All typeahead is thrown away after each round of battle. This is useful for those who type far +ahead and then watch in dismay as a Bat kills +them.

+
+

seefloor +[seefloor]

+
+

Display the floor around you on the screen +as you move through dark rooms. Due to the amount of +characters generated, this option defaults to +noseefloor if you are using a slow +terminal.

+
+

passgo +[nopassgo]

+
+

Follow turnings in passageways. If you run +in a pas- sage and you run into stone or a wall, rogue will +see if it can turn to the right or left. If it can only turn +one way, it will turn that way. If it can turn either or +neither, it will stop. This algorithm can sometimes lead to +slightly confusing occurrences which is why it defaults to +nopassgo.

+
+

tombstone +[tombstone]

+
+

Print out the tombstone at the end if you +get killed. This is nice but slow, so you can turn it off if +you like.

+
+

inven +[overwrite]

+
+

Inventory type. This can have one of three +values: overwrite, slow, or clear. With +overwrite the top lines of the map are overwritten +with the list when inventory is requested or when +“Which item do you wish to . . .? ” +questions are answered with a “*”. How- ever, if +the list is longer than a screenful, the screen is cleared. +With slow, lists are displayed one item at a time on +the top of the screen, and with clear, the screen is +cleared, the list is displayed, and then the dungeon level +is re-displayed. Due to speed considerations, clear +is the default for terminals without clear-to-end-of-line +capabilities.

+
+

name [account +name]

+
+

This is the name of your character. It is +used if you get on the top ten scorer’s +list.

+
+

fruit +[slime-mold]

+
+

This should hold the name of a fruit that +you enjoy eating. It is basically a whimsy that rogue uses +in a couple of places.

+
+

file +[~/rogue.save]

+
+

The default file name for saving the game. +If your phone is hung up by accident, rogue will +automatically save the game in this file. The file name may +start with the special character “~” which +expands to be your home directory.

+
+

9. Scoring

+ +

Rogue usually maintains a list of the top +scoring people or scores on your machine. Depending on how +it is set up, it can post either the top scores or the top +players. In the latter case, each account on the machine can +post only one non-winning score on this list. If you score +higher than someone else on this list, or better your previous score on the list, you will be inserted in the proper +place under your current name. How many scores are kept can +also be set up by whoever installs it on your +machine.

+ +

If you quit the game, you get out with all +of your gold intact. If, however, you get killed in the +Dungeons of Doom, your body is forwarded to your +next-of-kin, along with 90% of your gold; ten percent of +your gold is kept by the Dungeons’ wizard as a fee5. This should make you +consider whether you want to take one last hit at that +monster and possibly live, or quit and thus stop with +whatever you have. If you quit, you do get all your gold, +but if you swing and live, you might find +more.

+ +

If you just want to see what the current top players/games list is, you can +type

+

% @PROGRAM@ −s

+ +

10. Acknowledgements

+ +

Rogue was originally conceived of by Glenn +Wichman and Michael Toy. Ken Arnold and Michael Toy then +smoothed out the user interface, and added jillions of new +features. We would like to thank Bob Arnold, Michelle Busch, +Andy Hatcher, Kipp Hickman, Mark Horton, Daniel Jensen, Bill +Joy, Joe Kalash, Steve Maurer, Marty McNary, Jan Miller, and +Scott Nelson for their ideas and assistance; and also the +teeming multitudes who graciously ignored work, school, and +social life to play rogue and send us bugs, complaints, suggestions, and just plain flames. And also +Mom.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
UNIX is a registered trademark of The Open Group
1As opposed to pseudo English sentences.
2A minimum screen size of 24 lines by 80 columns is required. If the + screen is larger, only the 24x80 section +will be used for the map.
3Actually, it's a dialect spoken only by the twenty-seven members of + a tribe in Outer Mongolia, but you're not supposed to know that.
4For those of you who use the Bourne shell sh (1), the commands would be

$ ROGUEOPTS="jump,noterse,name=Blue Meanie"
+$ export ROGUEOPTS

5The Dungeon's wizard is named Wally the Wonder Badger. Invocations + should be accompanied by a sizable donation.
+ + diff --git a/src/cc/rogue/rogue.me b/src/cc/rogue/rogue.me new file mode 100644 index 000000000..1a2568477 --- /dev/null +++ b/src/cc/rogue/rogue.me @@ -0,0 +1,892 @@ +.\" +.\" @(#)rogue.me 6.2 (Berkeley) 4/28/86 +.\" +.\" Rogue: Exploring the Dungeons of Doom +.\" Copyright (C) 1980-1983, 1985, 1986 Michael Toy, Ken Arnold and Glenn Wichman +.\" All rights reserved. +.\" +.\" See the file LICENSE.TXT for full copyright and licensing information. +.\" +.ds E \s-2\s0 +.ds R \s-2\s0 +.ds U \s-2UNIX\s0 +.ie t .ds _ \d\(mi\u +.el .ds _ _ +.de Cs +\&\\$3\*(lq\\$1\*(rq\\$2 +.. +.sp 5 +.ce 1000 +.ps +4 +.vs +4p +.b +A Guide to the Dungeons of Doom +.r +.vs +.ps +.sp 2 +.i +Michael C. Toy +Kenneth C. R. C. Arnold +.r +.sp 2 +Computer Systems Research Group +Department of Electrical Engineering and Computer Science +University of California +Berkeley, California 94720 +.sp 4 +.i ABSTRACT +.ce 0 +.(b I F +.bi Rogue +is a visual CRT based fantasy game +which runs under the \*U\(dg timesharing system. +.(f +\fR\(dg\*U is a trademark of Bell Laboratories\fP +.)f +This paper describes how to play rogue, +and gives a few hints +for those who might otherwise get lost in the Dungeons of Doom. +.)b +\".he '''\fBA Guide to the Dungeons of Doom\fP' +\" .fo ''- % -'' +.eh 'USD:33-%''A Guide to the Dungeons of Doom' +.oh 'A Guide to the Dungeons of Doom''USD:33-%' +.sh 1 Introduction +.pp +You have just finished your years as a student at the local fighter's guild. +After much practice and sweat you have finally completed your training +and are ready to embark upon a perilous adventure. +As a test of your skills, +the local guildmasters have sent you into the Dungeons of Doom. +Your task is to return with the Amulet of Yendor. +Your reward for the completion of this task +will be a full membership in the local guild. +In addition, +you are allowed to keep all the loot you bring back from the dungeons. +.pp +In preparation for your journey, +you are given an enchanted mace, +a bow, and a quiver of arrows +taken from a dragon's hoard in the far off Dark Mountains. +You are also outfitted with elf-crafted armor +and given enough food to reach the dungeons. +You say goodbye to family and friends for what may be the last time +and head up the road. +.pp +You set out on your way to the dungeons +and after several days of uneventful travel, +you see the ancient ruins +that mark the entrance to the Dungeons of Doom. +It is late at night, +so you make camp at the entrance +and spend the night sleeping under the open skies. +In the morning you gather your weapons, +put on your armor, +eat what is almost your last food, +and enter the dungeons. +.sh 1 "What is going on here?" +.pp +You have just begun a game of rogue. +Your goal is to grab as much treasure as you can, +find the Amulet of Yendor, +and get out of the Dungeons of Doom alive. +On the screen, +a map of where you have been +and what you have seen on the current dungeon level is kept. +As you explore more of the level, +it appears on the screen in front of you. +.pp +Rogue differs from most computer fantasy games in that it is screen oriented. +Commands are all one or two keystrokes\** +.(f +\** As opposed to pseudo English sentences. +.)f +and the results of your commands +are displayed graphically on the screen rather +than being explained in words.\** +.(f +\** A minimum screen size of 24 lines by 80 columns is required. +If the screen is larger, only the 24x80 section will be used +for the map. +.)f +.pp +Another major difference between rogue and other computer fantasy games +is that once you have solved all the puzzles in a standard fantasy game, +it has lost most of its excitement and it ceases to be fun. +Rogue, +on the other hand, +generates a new dungeon every time you play it +and even the author finds it an entertaining and exciting game. +.sh 1 "What do all those things on the screen mean?" +.pp +In order to understand what is going on in rogue +you have to first get some grasp of what rogue is doing with the screen. +The rogue screen is intended +to replace the \*(lqYou can see ...\*(rq descriptions +of standard fantasy games. +Figure 1 is a sample of what a rogue screen might look like. +.(z +.hl +.nf +.TS +center; +ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce. +- - - - - - - - - - - - +| . . . . . . . . . . + +| . . @ . . . . ] . . | +| . . . . B . . . . . | +| . . . . . . . . . . | +- - - - - + - - - - - - +.TE + + +.ce 1000 +Level: 1 Gold: 0 Hp: 12(12) Str: 16(16) Arm: 4 Exp: 1/0 + +Figure 1 +.ce +.hl +.)z +.sh 2 "The bottom line" +.pp +At the bottom line of the screen +are a few pieces of cryptic information +describing your current status. +Here is an explanation of what these things mean: +.ip Level \w'Level\ \ 'u +This number indicates how deep you have gone in the dungeon. +It starts at one and goes up as you go deeper into the dungeon. +.ip Gold \w'Level\ \ 'u +The number of gold pieces you have managed to find +and keep with you so far. +.ip Hp \w'Level\ \ 'u +Your current and maximum health points. +Health points indicate how much damage you can take before you die. +The more you get hit in a fight, +the lower they get. +You can regain health points by resting. +The number in parentheses +is the maximum number your health points can reach. +.ip Str \w'Level\ \ 'u +Your current strength and maximum ever strength. +This can be any integer less than or equal to 31, +or greater than or equal to three. +The higher the number, +the stronger you are. +The number in the parentheses +is the maximum strength you have attained so far this game. +.ip Arm \w'Level\ \ 'u +Your current armor protection. +This number indicates how effective your armor is +in stopping blows from unfriendly creatures. +The higher this number is, +the more effective the armor. +.ip Exp \w'Level\ \ 'u +These two numbers give your current experience level +and experience points. +As you do things, +you gain experience points. +At certain experience point totals, +you gain an experience level. +The more experienced you are, +the better you are able to fight and to withstand magical attacks. +.sh 2 "The top line" +.pp +The top line of the screen is reserved +for printing messages that describe things +that are impossible to represent visually. +If you see a \*(lq--More--\*(rq on the top line, +this means that rogue wants to print another message on the screen, +but it wants to make certain +that you have read the one that is there first. +To read the next message, +just type a space. +.sh 2 "The rest of the screen" +.pp +The rest of the screen is the map of the level +as you have explored it so far. +Each symbol on the screen represents something. +Here is a list of what the various symbols mean: +.ip @ +This symbol represents you, the adventurer. +.ip "-\^|" +These symbols represent the walls of rooms. +.ip + +A door to/from a room. +.ip . +The floor of a room. +.ip # +The floor of a passage between rooms. +.ip * +A pile or pot of gold. +.ip ) +A weapon of some sort. +.ip ] +A piece of armor. +.ip ! +A flask containing a magic potion. +.ip ? +A piece of paper, usually a magic scroll. +.ip = +A ring with magic properties +.ip / +A magical staff or wand +.ip ^ +A trap, watch out for these. +.ip % +A staircase to other levels +.ip : +A piece of food. +.ip A-Z +The uppercase letters +represent the various inhabitants of the Dungeons of Doom. +Watch out, they can be nasty and vicious. +.sh 1 Commands +.pp +Commands are given to rogue by typing one or two characters. +Most commands can be preceded by a count to repeat them +(e.g. typing +.Cs 10s +will do ten searches). +Commands for which counts make no sense +have the count ignored. +To cancel a count or a prefix, +type \*E. +The list of commands is rather long, +but it can be read at any time during the game with the +.Cs ? +command. +Here it is for reference, +with a short explanation of each command. +.ip ? +The help command. +Asks for a character to give help on. +If you type a +.Cs * , +it will list all the commands, +otherwise it will explain what the character you typed does. +.ip / +This is the \*(lqWhat is that on the screen?\*(rq command. +A +.Cs / +followed by any character that you see on the level, +will tell you what that character is. +For instance, +typing +.Cs /@ +will tell you that the +.Cs @ +symbol represents you, the player. +.ip "h, H, ^H" +Move left. +You move one space to the left. +If you use upper case +.Cs h , +you will continue to move left until you run into something. +This works for all movement commands +(e.g. +.Cs L +means run in direction +.Cs l ) +If you use the \*(lqcontrol\*(rq +.Cs h , +you will continue moving in the specified direction +until you pass something interesting or run into a wall. +You should experiment with this, +since it is a very useful command, +but very difficult to describe. +This also works for all movement commands. +.ip j +Move down. +.ip k +Move up. +.ip l +Move right. +.ip y +Move diagonally up and left. +.ip u +Move diagonally up and right. +.ip b +Move diagonally down and left. +.ip n +Move diagonally down and right. +.ip t +Throw an object. +This is a prefix command. +When followed with a direction +it throws an object in the specified direction. +(e.g. type +.Cs th +to throw +something to the left.) +.ip f +Fight until someone dies. +When followed with a direction +this will force you to fight the creature in that direction +until either you or it bites the big one. +.ip m +Move onto something without picking it up. +This will move you one space in the direction you specify and, +if there is an object there you can pick up, +it won't do it. +.ip z +Zap prefix. +Point a staff or wand in a given direction +and fire it. +Even non-directional staves must be pointed in some direction +to be used. +.ip ^ +Identify trap command. +If a trap is on your map +and you can't remember what type it is, +you can get rogue to remind you +by getting next to it and typing +.Cs ^ +followed by the direction that would move you on top of it. +.ip s +Search for traps and secret doors. +Examine each space immediately adjacent to you +for the existence of a trap or secret door. +There is a large chance that even if there is something there, +you won't find it, +so you might have to search a while before you find something. +.ip > +Climb down a staircase to the next level. +Not surprisingly, this can only be done if you are standing on staircase. +.ip < +Climb up a staircase to the level above. +This can't be done without the Amulet of Yendor in your possession. +.ip "." +Rest. +This is the \*(lqdo nothing\*(rq command. +This is good for waiting and healing. +.ip , +Pick up something. +This picks up whatever you are currently standing on, +if you are standing on anything at all. +.ip i +Inventory. +List what you are carrying in your pack. +.ip I +Selective inventory. +Tells you what a single item in your pack is. +.ip q +Quaff one of the potions you are carrying. +.ip r +Read one of the scrolls in your pack. +.ip e +Eat food from your pack. +.ip w +Wield a weapon. +Take a weapon out of your pack and carry it for use in combat, +replacing the one you are currently using (if any). +.ip W +Wear armor. +You can only wear one suit of armor at a time. +This takes extra time. +.ip T +Take armor off. +You can't remove armor that is cursed. +This takes extra time. +.ip P +Put on a ring. +You can wear only two rings at a time +(one on each hand). +If you aren't wearing any rings, +this command will ask you which hand you want to wear it on, +otherwise, it will place it on the unused hand. +The program assumes that you wield your sword in your right hand. +.ip R +Remove a ring. +If you are only wearing one ring, +this command takes it off. +If you are wearing two, +it will ask you which one you wish to remove, +.ip d +Drop an object. +Take something out of your pack and leave it lying on the floor. +Only one object can occupy each space. +You cannot drop a cursed object at all +if you are wielding or wearing it. +.ip c +Call an object something. +If you have a type of object in your pack +which you wish to remember something about, +you can use the call command to give a name to that type of object. +This is usually used when you figure out what a +potion, scroll, ring, or staff is +after you pick it up, +or when you want to remember +which of those swords in your pack you were wielding. +.ip D +Print out which things you've discovered something about. +This command will ask you what type of thing you are interested in. +If you type the character for a given type of object +(\fIe.g.\fP +.Cs ! +for potion) +it will tell you which kinds of that type of object you've discovered +(\fIi.e.\fP, figured out what they are). +This command works for potions, scrolls, rings, and staves and wands. +.ip o +Examine and set options. +This command is further explained in the section on options. +.ip ^R +Redraws the screen. +Useful if spurious messages or transmission errors +have messed up the display. +.ip ^P +Print last message. +Useful when a message disappears before you can read it. +This only repeats the last message +that was not a mistyped command +so that you don't loose anything by accidentally typing +the wrong character instead of ^P. +.ip \*E +Cancel a command, prefix, or count. +.ip ! +Escape to a shell for some commands. +.ip Q +Quit. +Leave the game. +.ip S +Save the current game in a file. +It will ask you whether you wish to use the default save file. +.i Caveat : +Rogue won't let you start up a copy of a saved game, +and it removes the save file as soon as you start up a restored game. +This is to prevent people from saving a game just before a dangerous position +and then restarting it if they die. +To restore a saved game, +give the file name as an argument to rogue. +As in +.ti +1i +.nf +% rogue \fIsave\*_file\fP +.ip +To restart from the default save file (see below), +run +.ti +1i +.nf +% rogue \-r +.ip v +Prints the program version number. +.ip ) +Print the weapon you are currently wielding +.ip ] +Print the armor you are currently wearing +.ip = +Print the rings you are currently wearing +.ip @ +Reprint the status line on the message line +.sh 1 Rooms +.pp +Rooms in the dungeons are either lit or dark. +If you walk into a lit room, +the entire room will be drawn on the screen as soon as you enter. +If you walk into a dark room, +it will only be displayed as you explore it. +Upon leaving a room, +all monsters inside the room +are erased from the screen. +In the darkness you can only see one space +in all directions around you. +A corridor is always dark. +.sh 1 Fighting +.pp +If you see a monster and you wish to fight it, +just attempt to run into it. +Many times a monster you find will mind its own business +unless you attack it. +It is often the case that discretion is the better part of valor. +.sh 1 "Objects you can find" +.pp +When you find something in the dungeon, +it is common to want to pick the object up. +This is accomplished in rogue by walking over the object +(unless you use the +.Cs m +prefix, see above). +If you are carrying too many things, +the program will tell you and it won't pick up the object, +otherwise it will add it to your pack +and tell you what you just picked up. +.pp +Many of the commands that operate on objects must prompt you +to find out which object you want to use. +If you change your mind and don't want to do that command after all, +just type an \*E and the command will be aborted. +.pp +Some objects, like armor and weapons, +are easily differentiated. +Others, like scrolls and potions, +are given labels which vary according to type. +During a game, +any two of the same kind of object +with the same label +are the same type. +However, +the labels will vary from game to game. +.pp +When you use one of these labeled objects, +if its effect is obvious, +rogue will remember what it is for you. +If it's effect isn't extremely obvious +you will be asked what you want to scribble on it +so you will recognize it later, +or you can use the +.Cs call +command +(see above). +.sh 2 Weapons +.pp +Some weapons, +like arrows, +come in bunches, +but most come one at a time. +In order to use a weapon, +you must wield it. +To fire an arrow out of a bow, +you must first wield the bow, +then throw the arrow. +You can only wield one weapon at a time, +but you can't change weapons if the one +you are currently wielding is cursed. +The commands to use weapons are +.Cs w +(wield) +and +.Cs t +(throw). +.sh 2 Armor +.pp +There are various sorts of armor lying around in the dungeon. +Some of it is enchanted, +some is cursed, +and some is just normal. +Different armor types have different armor protection. +The higher the armor protection, +the more protection the armor affords against the blows of monsters. +Here is a list of the various armor types and their normal armor protection: +.(b +.TS +box center; +l r. +\ \ \fIType Protection\fP +None 0 +Leather armor 2 +Studded leather / Ring mail 3 +Scale mail 4 +Chain mail 5 +Banded mail / Splint mail 6 +Plate mail 7 +.TE +.)b +.lp +If a piece of armor is enchanted, +its armor protection will be higher than normal. +If a suit of armor is cursed, +its armor protection will be lower, +and you will not be able to remove it. +However, not all armor with a protection that is lower than normal is cursed. +.pp +The commands to use weapons are +.Cs W +(wear) +and +.Cs T +(take off). +.sh 2 Scrolls +.pp +Scrolls come with titles in an unknown tongue\**. +.(f +\** Actually, it's a dialect spoken only by the twenty-seven members +of a tribe in Outer Mongolia, +but you're not supposed to +.i know +that. +.)f +After you read a scroll, +it disappears from your pack. +The command to use a scroll is +.Cs r +(read). +.sh 2 Potions +.pp +Potions are labeled by the color of the liquid inside the flask. +They disappear after being quaffed. +The command to use a scroll is +.Cs q +(quaff). +.sh 2 "Staves and Wands" +.pp +Staves and wands do the same kinds of things. +Staves are identified by a type of wood; +wands by a type of metal or bone. +They are generally things you want to do to something +over a long distance, +so you must point them at what you wish to affect +to use them. +Some staves are not affected by the direction they are pointed, though. +Staves come with multiple magic charges, +the number being random, +and when they are used up, +the staff is just a piece of wood or metal. +.pp +The command to use a wand or staff is +.Cs z +(zap) +.sh 2 Rings +.pp +Rings are very useful items, +since they are relatively permanent magic, +unlike the usually fleeting effects of potions, scrolls, and staves. +Of course, +the bad rings are also more powerful. +Most rings also cause you to use up food more rapidly, +the rate varying with the type of ring. +Rings are differentiated by their stone settings. +The commands to use rings are +.Cs P +(put on) +and +.Cs R +(remove). +.sh 2 Food +.pp +Food is necessary to keep you going. +If you go too long without eating you will faint, +and eventually die of starvation. +The command to use food is +.Cs e +(eat). +.sh 1 Options +.pp +Due to variations in personal tastes +and conceptions of the way rogue should do things, +there are a set of options you can set +that cause rogue to behave in various different ways. +.sh 2 "Setting the options" +.pp +There are two ways to set the options. +The first is with the +.Cs o +command of rogue; +the second is with the +.Cs ROGUEOPTS +environment variable\**. +.(f +\** On Version 6 systems, +there is no equivalent of the ROGUEOPTS feature. +.br +.)f +.br +.sh 3 "Using the `o' command" +.pp +When you type +.Cs o +in rogue, +it clears the screen +and displays the current settings for all the options. +It then places the cursor by the value of the first option +and waits for you to type. +You can type a \*R +which means to go to the next option, +a +.Cs \- +which means to go to the previous option, +an \*E +which means to return to the game, +or you can give the option a value. +For boolean options this merely involves typing +.Cs t +for true or +.Cs f +for false. +For string options, +type the new value followed by a \*R. +.sh 3 "Using the ROGUEOPTS variable" +.pp +The ROGUEOPTS variable is a string +containing a comma separated list of initial values +for the various options. +Boolean variables can be turned on by listing their name +or turned off by putting a +.Cs no +in front of the name. +Thus to set up an environment variable so that +.b jump +is on, +.b terse +is off, +and the +.b name +is set to \*(lqBlue Meanie\*(rq, +use the command +.nf +.ti +3n +% setenv ROGUEOPTS "jump,noterse,name=Blue Meanie"\** +.fi +.(f +\** +For those of you who use the Bourne shell sh (1), the commands would be +.in +3 +.nf +$ ROGUEOPTS="jump,noterse,name=Blue Meanie" +$ export ROGUEOPTS +.fi +.in +0 +.)f +.sh 2 "Option list" +.pp +Here is a list of the options +and an explanation of what each one is for. +The default value for each is enclosed in square brackets. +For character string options, +input over fifty characters will be ignored. +.ip "\fBterse\fP [\fI\^noterse\^\fP]" +Useful for those who are tired of the sometimes lengthy messages of rogue. +This is a useful option for playing on slow terminals, +so this option defaults to +.i terse +if you +are on a slow (1200 baud or under) terminal. +.ip "\fBjump\fP [\fI\^nojump\^\fP]" +If this option is set, +running moves will not be displayed +until you reach the end of the move. +This saves considerable cpu and display time. +This option defaults to +.i jump +if you are using a slow terminal. +.ip "\fBflush\fP [\fI\^noflush\^\fP]" +All typeahead is thrown away after each round of battle. +This is useful for those who type far ahead +and then watch in dismay as a Bat kills them. +.ip "\fBseefloor\fP [\fI\^seefloor\^\fP]" +Display the floor around you on the screen +as you move through dark rooms. +Due to the amount of characters generated, +this option defaults to +.i noseefloor +if you are using a slow terminal. +.ip "\fBpassgo\fP [\fI\^nopassgo\^\fP]" +Follow turnings in passageways. +If you run in a passage +and you run into stone or a wall, +rogue will see if it can turn to the right or left. +If it can only turn one way, +it will turn that way. +If it can turn either or neither, +it will stop. +This algorithm can sometimes lead to slightly confusing occurrences +which is why it defaults to \fInopassgo\fP. +.ip "\fBtombstone\fP [\fI\^tombstone\^\fP]" +Print out the tombstone at the end if you get killed. +This is nice but slow, so you can turn it off if you like. +.ip "\fBinven\fP [\fI\^overwrite\^\fP]" +Inventory type. +This can have one of three values: +.i overwrite , +.i slow , +or +.i clear . +With +.i overwrite +the top lines of the map are overwritten +with the list +when inventory is requested +or when +\*(lqWhich item do you wish to \fB. . .\fP? \*(rq questions +are answered with a +.Cs * . +However, if the list is longer than a screenful, +the screen is cleared. +With +.i slow , +lists are displayed one item at a time on the top of the screen, +and with +.i clear , +the screen is cleared, +the list is displayed, +and then the dungeon level is re-displayed. +Due to speed considerations, +.i clear +is the default for terminals without +clear-to-end-of-line capabilities. +.ip "\fBname\fP [account name]" +This is the name of your character. +It is used if you get on the top ten scorer's list. +.ip "\fBfruit\fP [\fI\^slime-mold\^\fP]" +This should hold the name of a fruit that you enjoy eating. +It is basically a whimsey that rogue uses in a couple of places. +.ip "\fBfile\fP [\fI\^~/rogue.save\^\fP]" +The default file name for saving the game. +If your phone is hung up by accident, +rogue will automatically save the game in this file. +The file name may start with the special character +.Cs ~ +which expands to be your home directory. +.sh 1 Scoring +.pp +Rogue usually maintains a list +of the top scoring people or scores on your machine. +Depending on how it is set up, +it can post either the top scores +or the top players. +In the latter case, +each account on the machine +can post only one non-winning score on this list. +If you score higher than someone else on this list, +or better your previous score on the list, +you will be inserted in the proper place +under your current name. +How many scores are kept +can also be set up by whoever installs it on your machine. +.pp +If you quit the game, you get out with all of your gold intact. +If, however, you get killed in the Dungeons of Doom, +your body is forwarded to your next-of-kin, +along with 90% of your gold; +ten percent of your gold is kept by the Dungeons' wizard as a fee\**. +.(f +\** The Dungeon's wizard is named Wally the Wonder Badger. +Invocations should be accompanied by a sizable donation. +.)f +This should make you consider whether you want to take one last hit +at that monster and possibly live, +or quit and thus stop with whatever you have. +If you quit, you do get all your gold, +but if you swing and live, you might find more. +.pp +If you just want to see what the current top players/games list is, +you can type +.ti +1i +.nf +% rogue \-s +.br +.sh 1 Acknowledgements +.pp +Rogue was originally conceived of by Glenn Wichman and Michael Toy. +Ken Arnold and Michael Toy then smoothed out the user interface, +and added jillions of new features. +We would like to thank +Bob Arnold, +Michelle Busch, +Andy Hatcher, +Kipp Hickman, +Mark Horton, +Daniel Jensen, +Bill Joy, +Joe Kalash, +Steve Maurer, +Marty McNary, +Jan Miller, +and +Scott Nelson +for their ideas and assistance; +and also the teeming multitudes +who graciously ignored work, school, and social life to play rogue +and send us bugs, complaints, suggestions, and just plain flames. +And also Mom. diff --git a/src/cc/rogue/rogue.me.in b/src/cc/rogue/rogue.me.in new file mode 100644 index 000000000..a73d1504e --- /dev/null +++ b/src/cc/rogue/rogue.me.in @@ -0,0 +1,892 @@ +.\" +.\" @(#)rogue.me 6.2 (Berkeley) 4/28/86 +.\" +.\" Rogue: Exploring the Dungeons of Doom +.\" Copyright (C) 1980-1983, 1985, 1986 Michael Toy, Ken Arnold and Glenn Wichman +.\" All rights reserved. +.\" +.\" See the file LICENSE.TXT for full copyright and licensing information. +.\" +.ds E \s-2\s0 +.ds R \s-2\s0 +.ds U \s-2UNIX\s0 +.ie t .ds _ \d\(mi\u +.el .ds _ _ +.de Cs +\&\\$3\*(lq\\$1\*(rq\\$2 +.. +.sp 5 +.ce 1000 +.ps +4 +.vs +4p +.b +A Guide to the Dungeons of Doom +.r +.vs +.ps +.sp 2 +.i +Michael C. Toy +Kenneth C. R. C. Arnold +.r +.sp 2 +Computer Systems Research Group +Department of Electrical Engineering and Computer Science +University of California +Berkeley, California 94720 +.sp 4 +.i ABSTRACT +.ce 0 +.(b I F +.bi Rogue +is a visual CRT based fantasy game +which runs under the \*U\(dg timesharing system. +.(f +\fR\(dg\*U is a trademark of Bell Laboratories\fP +.)f +This paper describes how to play rogue, +and gives a few hints +for those who might otherwise get lost in the Dungeons of Doom. +.)b +\".he '''\fBA Guide to the Dungeons of Doom\fP' +\" .fo ''- % -'' +.eh 'USD:33-%''A Guide to the Dungeons of Doom' +.oh 'A Guide to the Dungeons of Doom''USD:33-%' +.sh 1 Introduction +.pp +You have just finished your years as a student at the local fighter's guild. +After much practice and sweat you have finally completed your training +and are ready to embark upon a perilous adventure. +As a test of your skills, +the local guildmasters have sent you into the Dungeons of Doom. +Your task is to return with the Amulet of Yendor. +Your reward for the completion of this task +will be a full membership in the local guild. +In addition, +you are allowed to keep all the loot you bring back from the dungeons. +.pp +In preparation for your journey, +you are given an enchanted mace, +a bow, and a quiver of arrows +taken from a dragon's hoard in the far off Dark Mountains. +You are also outfitted with elf-crafted armor +and given enough food to reach the dungeons. +You say goodbye to family and friends for what may be the last time +and head up the road. +.pp +You set out on your way to the dungeons +and after several days of uneventful travel, +you see the ancient ruins +that mark the entrance to the Dungeons of Doom. +It is late at night, +so you make camp at the entrance +and spend the night sleeping under the open skies. +In the morning you gather your weapons, +put on your armor, +eat what is almost your last food, +and enter the dungeons. +.sh 1 "What is going on here?" +.pp +You have just begun a game of rogue. +Your goal is to grab as much treasure as you can, +find the Amulet of Yendor, +and get out of the Dungeons of Doom alive. +On the screen, +a map of where you have been +and what you have seen on the current dungeon level is kept. +As you explore more of the level, +it appears on the screen in front of you. +.pp +Rogue differs from most computer fantasy games in that it is screen oriented. +Commands are all one or two keystrokes\** +.(f +\** As opposed to pseudo English sentences. +.)f +and the results of your commands +are displayed graphically on the screen rather +than being explained in words.\** +.(f +\** A minimum screen size of 24 lines by 80 columns is required. +If the screen is larger, only the 24x80 section will be used +for the map. +.)f +.pp +Another major difference between rogue and other computer fantasy games +is that once you have solved all the puzzles in a standard fantasy game, +it has lost most of its excitement and it ceases to be fun. +Rogue, +on the other hand, +generates a new dungeon every time you play it +and even the author finds it an entertaining and exciting game. +.sh 1 "What do all those things on the screen mean?" +.pp +In order to understand what is going on in rogue +you have to first get some grasp of what rogue is doing with the screen. +The rogue screen is intended +to replace the \*(lqYou can see ...\*(rq descriptions +of standard fantasy games. +Figure 1 is a sample of what a rogue screen might look like. +.(z +.hl +.nf +.TS +center; +ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce0 ce. +- - - - - - - - - - - - +| . . . . . . . . . . + +| . . @ . . . . ] . . | +| . . . . B . . . . . | +| . . . . . . . . . . | +- - - - - + - - - - - - +.TE + + +.ce 1000 +Level: 1 Gold: 0 Hp: 12(12) Str: 16(16) Arm: 4 Exp: 1/0 + +Figure 1 +.ce +.hl +.)z +.sh 2 "The bottom line" +.pp +At the bottom line of the screen +are a few pieces of cryptic information +describing your current status. +Here is an explanation of what these things mean: +.ip Level \w'Level\ \ 'u +This number indicates how deep you have gone in the dungeon. +It starts at one and goes up as you go deeper into the dungeon. +.ip Gold \w'Level\ \ 'u +The number of gold pieces you have managed to find +and keep with you so far. +.ip Hp \w'Level\ \ 'u +Your current and maximum health points. +Health points indicate how much damage you can take before you die. +The more you get hit in a fight, +the lower they get. +You can regain health points by resting. +The number in parentheses +is the maximum number your health points can reach. +.ip Str \w'Level\ \ 'u +Your current strength and maximum ever strength. +This can be any integer less than or equal to 31, +or greater than or equal to three. +The higher the number, +the stronger you are. +The number in the parentheses +is the maximum strength you have attained so far this game. +.ip Arm \w'Level\ \ 'u +Your current armor protection. +This number indicates how effective your armor is +in stopping blows from unfriendly creatures. +The higher this number is, +the more effective the armor. +.ip Exp \w'Level\ \ 'u +These two numbers give your current experience level +and experience points. +As you do things, +you gain experience points. +At certain experience point totals, +you gain an experience level. +The more experienced you are, +the better you are able to fight and to withstand magical attacks. +.sh 2 "The top line" +.pp +The top line of the screen is reserved +for printing messages that describe things +that are impossible to represent visually. +If you see a \*(lq--More--\*(rq on the top line, +this means that rogue wants to print another message on the screen, +but it wants to make certain +that you have read the one that is there first. +To read the next message, +just type a space. +.sh 2 "The rest of the screen" +.pp +The rest of the screen is the map of the level +as you have explored it so far. +Each symbol on the screen represents something. +Here is a list of what the various symbols mean: +.ip @ +This symbol represents you, the adventurer. +.ip "-\^|" +These symbols represent the walls of rooms. +.ip + +A door to/from a room. +.ip . +The floor of a room. +.ip # +The floor of a passage between rooms. +.ip * +A pile or pot of gold. +.ip ) +A weapon of some sort. +.ip ] +A piece of armor. +.ip ! +A flask containing a magic potion. +.ip ? +A piece of paper, usually a magic scroll. +.ip = +A ring with magic properties +.ip / +A magical staff or wand +.ip ^ +A trap, watch out for these. +.ip % +A staircase to other levels +.ip : +A piece of food. +.ip A-Z +The uppercase letters +represent the various inhabitants of the Dungeons of Doom. +Watch out, they can be nasty and vicious. +.sh 1 Commands +.pp +Commands are given to rogue by typing one or two characters. +Most commands can be preceded by a count to repeat them +(e.g. typing +.Cs 10s +will do ten searches). +Commands for which counts make no sense +have the count ignored. +To cancel a count or a prefix, +type \*E. +The list of commands is rather long, +but it can be read at any time during the game with the +.Cs ? +command. +Here it is for reference, +with a short explanation of each command. +.ip ? +The help command. +Asks for a character to give help on. +If you type a +.Cs * , +it will list all the commands, +otherwise it will explain what the character you typed does. +.ip / +This is the \*(lqWhat is that on the screen?\*(rq command. +A +.Cs / +followed by any character that you see on the level, +will tell you what that character is. +For instance, +typing +.Cs /@ +will tell you that the +.Cs @ +symbol represents you, the player. +.ip "h, H, ^H" +Move left. +You move one space to the left. +If you use upper case +.Cs h , +you will continue to move left until you run into something. +This works for all movement commands +(e.g. +.Cs L +means run in direction +.Cs l ) +If you use the \*(lqcontrol\*(rq +.Cs h , +you will continue moving in the specified direction +until you pass something interesting or run into a wall. +You should experiment with this, +since it is a very useful command, +but very difficult to describe. +This also works for all movement commands. +.ip j +Move down. +.ip k +Move up. +.ip l +Move right. +.ip y +Move diagonally up and left. +.ip u +Move diagonally up and right. +.ip b +Move diagonally down and left. +.ip n +Move diagonally down and right. +.ip t +Throw an object. +This is a prefix command. +When followed with a direction +it throws an object in the specified direction. +(e.g. type +.Cs th +to throw +something to the left.) +.ip f +Fight until someone dies. +When followed with a direction +this will force you to fight the creature in that direction +until either you or it bites the big one. +.ip m +Move onto something without picking it up. +This will move you one space in the direction you specify and, +if there is an object there you can pick up, +it won't do it. +.ip z +Zap prefix. +Point a staff or wand in a given direction +and fire it. +Even non-directional staves must be pointed in some direction +to be used. +.ip ^ +Identify trap command. +If a trap is on your map +and you can't remember what type it is, +you can get rogue to remind you +by getting next to it and typing +.Cs ^ +followed by the direction that would move you on top of it. +.ip s +Search for traps and secret doors. +Examine each space immediately adjacent to you +for the existence of a trap or secret door. +There is a large chance that even if there is something there, +you won't find it, +so you might have to search a while before you find something. +.ip > +Climb down a staircase to the next level. +Not surprisingly, this can only be done if you are standing on staircase. +.ip < +Climb up a staircase to the level above. +This can't be done without the Amulet of Yendor in your possession. +.ip "." +Rest. +This is the \*(lqdo nothing\*(rq command. +This is good for waiting and healing. +.ip , +Pick up something. +This picks up whatever you are currently standing on, +if you are standing on anything at all. +.ip i +Inventory. +List what you are carrying in your pack. +.ip I +Selective inventory. +Tells you what a single item in your pack is. +.ip q +Quaff one of the potions you are carrying. +.ip r +Read one of the scrolls in your pack. +.ip e +Eat food from your pack. +.ip w +Wield a weapon. +Take a weapon out of your pack and carry it for use in combat, +replacing the one you are currently using (if any). +.ip W +Wear armor. +You can only wear one suit of armor at a time. +This takes extra time. +.ip T +Take armor off. +You can't remove armor that is cursed. +This takes extra time. +.ip P +Put on a ring. +You can wear only two rings at a time +(one on each hand). +If you aren't wearing any rings, +this command will ask you which hand you want to wear it on, +otherwise, it will place it on the unused hand. +The program assumes that you wield your sword in your right hand. +.ip R +Remove a ring. +If you are only wearing one ring, +this command takes it off. +If you are wearing two, +it will ask you which one you wish to remove, +.ip d +Drop an object. +Take something out of your pack and leave it lying on the floor. +Only one object can occupy each space. +You cannot drop a cursed object at all +if you are wielding or wearing it. +.ip c +Call an object something. +If you have a type of object in your pack +which you wish to remember something about, +you can use the call command to give a name to that type of object. +This is usually used when you figure out what a +potion, scroll, ring, or staff is +after you pick it up, +or when you want to remember +which of those swords in your pack you were wielding. +.ip D +Print out which things you've discovered something about. +This command will ask you what type of thing you are interested in. +If you type the character for a given type of object +(\fIe.g.\fP +.Cs ! +for potion) +it will tell you which kinds of that type of object you've discovered +(\fIi.e.\fP, figured out what they are). +This command works for potions, scrolls, rings, and staves and wands. +.ip o +Examine and set options. +This command is further explained in the section on options. +.ip ^R +Redraws the screen. +Useful if spurious messages or transmission errors +have messed up the display. +.ip ^P +Print last message. +Useful when a message disappears before you can read it. +This only repeats the last message +that was not a mistyped command +so that you don't loose anything by accidentally typing +the wrong character instead of ^P. +.ip \*E +Cancel a command, prefix, or count. +.ip ! +Escape to a shell for some commands. +.ip Q +Quit. +Leave the game. +.ip S +Save the current game in a file. +It will ask you whether you wish to use the default save file. +.i Caveat : +Rogue won't let you start up a copy of a saved game, +and it removes the save file as soon as you start up a restored game. +This is to prevent people from saving a game just before a dangerous position +and then restarting it if they die. +To restore a saved game, +give the file name as an argument to rogue. +As in +.ti +1i +.nf +% rogue \fIsave\*_file\fP +.ip +To restart from the default save file (see below), +run +.ti +1i +.nf +% rogue \-r +.ip v +Prints the program version number. +.ip ) +Print the weapon you are currently wielding +.ip ] +Print the armor you are currently wearing +.ip = +Print the rings you are currently wearing +.ip @ +Reprint the status line on the message line +.sh 1 Rooms +.pp +Rooms in the dungeons are either lit or dark. +If you walk into a lit room, +the entire room will be drawn on the screen as soon as you enter. +If you walk into a dark room, +it will only be displayed as you explore it. +Upon leaving a room, +all monsters inside the room +are erased from the screen. +In the darkness you can only see one space +in all directions around you. +A corridor is always dark. +.sh 1 Fighting +.pp +If you see a monster and you wish to fight it, +just attempt to run into it. +Many times a monster you find will mind its own business +unless you attack it. +It is often the case that discretion is the better part of valor. +.sh 1 "Objects you can find" +.pp +When you find something in the dungeon, +it is common to want to pick the object up. +This is accomplished in rogue by walking over the object +(unless you use the +.Cs m +prefix, see above). +If you are carrying too many things, +the program will tell you and it won't pick up the object, +otherwise it will add it to your pack +and tell you what you just picked up. +.pp +Many of the commands that operate on objects must prompt you +to find out which object you want to use. +If you change your mind and don't want to do that command after all, +just type an \*E and the command will be aborted. +.pp +Some objects, like armor and weapons, +are easily differentiated. +Others, like scrolls and potions, +are given labels which vary according to type. +During a game, +any two of the same kind of object +with the same label +are the same type. +However, +the labels will vary from game to game. +.pp +When you use one of these labeled objects, +if its effect is obvious, +rogue will remember what it is for you. +If it's effect isn't extremely obvious +you will be asked what you want to scribble on it +so you will recognize it later, +or you can use the +.Cs call +command +(see above). +.sh 2 Weapons +.pp +Some weapons, +like arrows, +come in bunches, +but most come one at a time. +In order to use a weapon, +you must wield it. +To fire an arrow out of a bow, +you must first wield the bow, +then throw the arrow. +You can only wield one weapon at a time, +but you can't change weapons if the one +you are currently wielding is cursed. +The commands to use weapons are +.Cs w +(wield) +and +.Cs t +(throw). +.sh 2 Armor +.pp +There are various sorts of armor lying around in the dungeon. +Some of it is enchanted, +some is cursed, +and some is just normal. +Different armor types have different armor protection. +The higher the armor protection, +the more protection the armor affords against the blows of monsters. +Here is a list of the various armor types and their normal armor protection: +.(b +.TS +box center; +l r. +\ \ \fIType Protection\fP +None 0 +Leather armor 2 +Studded leather / Ring mail 3 +Scale mail 4 +Chain mail 5 +Banded mail / Splint mail 6 +Plate mail 7 +.TE +.)b +.lp +If a piece of armor is enchanted, +its armor protection will be higher than normal. +If a suit of armor is cursed, +its armor protection will be lower, +and you will not be able to remove it. +However, not all armor with a protection that is lower than normal is cursed. +.pp +The commands to use weapons are +.Cs W +(wear) +and +.Cs T +(take off). +.sh 2 Scrolls +.pp +Scrolls come with titles in an unknown tongue\**. +.(f +\** Actually, it's a dialect spoken only by the twenty-seven members +of a tribe in Outer Mongolia, +but you're not supposed to +.i know +that. +.)f +After you read a scroll, +it disappears from your pack. +The command to use a scroll is +.Cs r +(read). +.sh 2 Potions +.pp +Potions are labeled by the color of the liquid inside the flask. +They disappear after being quaffed. +The command to use a scroll is +.Cs q +(quaff). +.sh 2 "Staves and Wands" +.pp +Staves and wands do the same kinds of things. +Staves are identified by a type of wood; +wands by a type of metal or bone. +They are generally things you want to do to something +over a long distance, +so you must point them at what you wish to affect +to use them. +Some staves are not affected by the direction they are pointed, though. +Staves come with multiple magic charges, +the number being random, +and when they are used up, +the staff is just a piece of wood or metal. +.pp +The command to use a wand or staff is +.Cs z +(zap) +.sh 2 Rings +.pp +Rings are very useful items, +since they are relatively permanent magic, +unlike the usually fleeting effects of potions, scrolls, and staves. +Of course, +the bad rings are also more powerful. +Most rings also cause you to use up food more rapidly, +the rate varying with the type of ring. +Rings are differentiated by their stone settings. +The commands to use rings are +.Cs P +(put on) +and +.Cs R +(remove). +.sh 2 Food +.pp +Food is necessary to keep you going. +If you go too long without eating you will faint, +and eventually die of starvation. +The command to use food is +.Cs e +(eat). +.sh 1 Options +.pp +Due to variations in personal tastes +and conceptions of the way rogue should do things, +there are a set of options you can set +that cause rogue to behave in various different ways. +.sh 2 "Setting the options" +.pp +There are two ways to set the options. +The first is with the +.Cs o +command of rogue; +the second is with the +.Cs ROGUEOPTS +environment variable\**. +.(f +\** On Version 6 systems, +there is no equivalent of the ROGUEOPTS feature. +.br +.)f +.br +.sh 3 "Using the `o' command" +.pp +When you type +.Cs o +in rogue, +it clears the screen +and displays the current settings for all the options. +It then places the cursor by the value of the first option +and waits for you to type. +You can type a \*R +which means to go to the next option, +a +.Cs \- +which means to go to the previous option, +an \*E +which means to return to the game, +or you can give the option a value. +For boolean options this merely involves typing +.Cs t +for true or +.Cs f +for false. +For string options, +type the new value followed by a \*R. +.sh 3 "Using the ROGUEOPTS variable" +.pp +The ROGUEOPTS variable is a string +containing a comma separated list of initial values +for the various options. +Boolean variables can be turned on by listing their name +or turned off by putting a +.Cs no +in front of the name. +Thus to set up an environment variable so that +.b jump +is on, +.b terse +is off, +and the +.b name +is set to \*(lqBlue Meanie\*(rq, +use the command +.nf +.ti +3n +% setenv ROGUEOPTS "jump,noterse,name=Blue Meanie"\** +.fi +.(f +\** +For those of you who use the Bourne shell sh (1), the commands would be +.in +3 +.nf +$ ROGUEOPTS="jump,noterse,name=Blue Meanie" +$ export ROGUEOPTS +.fi +.in +0 +.)f +.sh 2 "Option list" +.pp +Here is a list of the options +and an explanation of what each one is for. +The default value for each is enclosed in square brackets. +For character string options, +input over fifty characters will be ignored. +.ip "\fBterse\fP [\fI\^noterse\^\fP]" +Useful for those who are tired of the sometimes lengthy messages of rogue. +This is a useful option for playing on slow terminals, +so this option defaults to +.i terse +if you +are on a slow (1200 baud or under) terminal. +.ip "\fBjump\fP [\fI\^nojump\^\fP]" +If this option is set, +running moves will not be displayed +until you reach the end of the move. +This saves considerable cpu and display time. +This option defaults to +.i jump +if you are using a slow terminal. +.ip "\fBflush\fP [\fI\^noflush\^\fP]" +All typeahead is thrown away after each round of battle. +This is useful for those who type far ahead +and then watch in dismay as a Bat kills them. +.ip "\fBseefloor\fP [\fI\^seefloor\^\fP]" +Display the floor around you on the screen +as you move through dark rooms. +Due to the amount of characters generated, +this option defaults to +.i noseefloor +if you are using a slow terminal. +.ip "\fBpassgo\fP [\fI\^nopassgo\^\fP]" +Follow turnings in passageways. +If you run in a passage +and you run into stone or a wall, +rogue will see if it can turn to the right or left. +If it can only turn one way, +it will turn that way. +If it can turn either or neither, +it will stop. +This algorithm can sometimes lead to slightly confusing occurrences +which is why it defaults to \fInopassgo\fP. +.ip "\fBtombstone\fP [\fI\^tombstone\^\fP]" +Print out the tombstone at the end if you get killed. +This is nice but slow, so you can turn it off if you like. +.ip "\fBinven\fP [\fI\^overwrite\^\fP]" +Inventory type. +This can have one of three values: +.i overwrite , +.i slow , +or +.i clear . +With +.i overwrite +the top lines of the map are overwritten +with the list +when inventory is requested +or when +\*(lqWhich item do you wish to \fB. . .\fP? \*(rq questions +are answered with a +.Cs * . +However, if the list is longer than a screenful, +the screen is cleared. +With +.i slow , +lists are displayed one item at a time on the top of the screen, +and with +.i clear , +the screen is cleared, +the list is displayed, +and then the dungeon level is re-displayed. +Due to speed considerations, +.i clear +is the default for terminals without +clear-to-end-of-line capabilities. +.ip "\fBname\fP [account name]" +This is the name of your character. +It is used if you get on the top ten scorer's list. +.ip "\fBfruit\fP [\fI\^slime-mold\^\fP]" +This should hold the name of a fruit that you enjoy eating. +It is basically a whimsey that rogue uses in a couple of places. +.ip "\fBfile\fP [\fI\^~/rogue.save\^\fP]" +The default file name for saving the game. +If your phone is hung up by accident, +rogue will automatically save the game in this file. +The file name may start with the special character +.Cs ~ +which expands to be your home directory. +.sh 1 Scoring +.pp +Rogue usually maintains a list +of the top scoring people or scores on your machine. +Depending on how it is set up, +it can post either the top scores +or the top players. +In the latter case, +each account on the machine +can post only one non-winning score on this list. +If you score higher than someone else on this list, +or better your previous score on the list, +you will be inserted in the proper place +under your current name. +How many scores are kept +can also be set up by whoever installs it on your machine. +.pp +If you quit the game, you get out with all of your gold intact. +If, however, you get killed in the Dungeons of Doom, +your body is forwarded to your next-of-kin, +along with 90% of your gold; +ten percent of your gold is kept by the Dungeons' wizard as a fee\**. +.(f +\** The Dungeon's wizard is named Wally the Wonder Badger. +Invocations should be accompanied by a sizable donation. +.)f +This should make you consider whether you want to take one last hit +at that monster and possibly live, +or quit and thus stop with whatever you have. +If you quit, you do get all your gold, +but if you swing and live, you might find more. +.pp +If you just want to see what the current top players/games list is, +you can type +.ti +1i +.nf +% @PROGRAM@ \-s +.br +.sh 1 Acknowledgements +.pp +Rogue was originally conceived of by Glenn Wichman and Michael Toy. +Ken Arnold and Michael Toy then smoothed out the user interface, +and added jillions of new features. +We would like to thank +Bob Arnold, +Michelle Busch, +Andy Hatcher, +Kipp Hickman, +Mark Horton, +Daniel Jensen, +Bill Joy, +Joe Kalash, +Steve Maurer, +Marty McNary, +Jan Miller, +and +Scott Nelson +for their ideas and assistance; +and also the teeming multitudes +who graciously ignored work, school, and social life to play rogue +and send us bugs, complaints, suggestions, and just plain flames. +And also Mom. diff --git a/src/cc/rogue/rogue.png b/src/cc/rogue/rogue.png new file mode 100644 index 0000000000000000000000000000000000000000..fc3779e83223dbb46ec33f8c1d936e6db202eb86 GIT binary patch literal 1005 zcmVWFU8GbZ8({Xk{QrNlj4iWF>9@00U7;L_t(o!`0VYjGa>y z2k_rGt+py1)hR8ZqY@&nbx+ZVh>{5LU|uwR5FrvTgb00*z7V8O8YD#GiMU4*f+q=? zc6dPyQW`bN(90M#opOek^~uW4cg}n>m56_`bJqU$UVE>-?uY*vJ+t6B0_Wgj^kYe! zGlm~9h#~CxHwB%CtMMd$#b48mNj#4mLf}KfaoB{>1{arOAD+O9*_hxkoR8o;2)+xi ze-US5b(m;v>{*Vt(s|oDoc9kl6l%M%##vY6i(+3JA7V%3gs~71u1))X!}Z;w;;XcI zYt5c(;?>iI;Qn+`557!mo4dt)e%0N@`uv*6*c@7$D!vcnti=0NVb)pFP- zU}IW;rx4&}EJ*8jq_v-NvdQRA^sX2cPQZ0(J`}I2@O^RCUKW^L9AurSdR#S1RO;Yqmn3f?mkJ%X=`^iyj0E25;|p60{&q*ESPlVWwe2)iw5 z?b~?O`yI02XSf;nM{AbT_4;mgpce-c!=|)$YZRSMsduVDdVZ}iWi4JUTB_x#v_4*Q z(PR{%%ke@7LB``TeNAfk`f!wr`N0$oOYv}+U^1GPyHW@qAKlP!M8jUZf}4sQ(-lkc zMiO8Qch)#;Q!Ky*cr40tBV18b#oggl^Jj2z3+Lk5&{$Ok8~+!%r)VtOkzfX*%r1^_ z>xth!oD!YTy^(C%g)g*mWz)92H&p*X@qHp1lAY0X{1HB~DBAKB!CRg^il?K0*fkRy zuB&N6nvMgZwT+>%S)qkf!@GAhym(L8ejQHC<@ZqkoVKE>t-@)M8|Fl190_L|j8c5i b{{epk<~&Tog&~z@00000NkvXXu0mjfa>>^0 literal 0 HcmV?d00001 diff --git a/src/cc/rogue/rogue.spec b/src/cc/rogue/rogue.spec new file mode 100644 index 000000000..6c8770fdc --- /dev/null +++ b/src/cc/rogue/rogue.spec @@ -0,0 +1,107 @@ +Name: rogue +Version: 5.4.4 +Release: 1%{?dist} +Summary: The original graphical adventure game + +Group: Amusements/Games +License: BSD +URL: http://rogue.rogueforge.net/ +Source0: http://rogue.rogueforge.net/files/rogue5.4/rogue5.4.4-src.tar.gz +Source1: rogue.desktop +Source2: rogue.png +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: desktop-file-utils +BuildRequires: ncurses-devel + +%description +The one, the only, the original graphical adventure game that spawned +an entire genre. + +%prep +%setup -q -n %{name}%{version} + + +%build +%configure --enable-setgid=games --enable-scorefile=%{_var}/games/roguelike/rogue54.scr --enable-lockfile=%{_var}/games/roguelike/rogue54.lck +make %{_smp_mflags} + + +%install +rm -rf $RPM_BUILD_ROOT + +make install DESTDIR=$RPM_BUILD_ROOT + +desktop-file-install --vendor fedora \ + --dir ${RPM_BUILD_ROOT}%{_datadir}/applications \ + %{SOURCE1} +mkdir -p $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/32x32/apps/ +install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/32x32/apps/ + + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +touch --no-create %{_datadir}/icons/hicolor || : +if [ -x %{_bindir}/gtk-update-icon-cache ]; then + %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || : +fi + +%postun +touch --no-create %{_datadir}/icons/hicolor || : +if [ -x %{_bindir}/gtk-update-icon-cache ]; then + %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || : +fi + + +%files +%defattr(-,root,root,-) +%attr(2755,games,games) %{_bindir}/rogue +%{_mandir}/man6/rogue.6.gz +%{_datadir}/applications/fedora-%{name}.desktop +%{_datadir}/icons/hicolor/32x32/apps/rogue.png +%dir %attr(0775,games,games) %{_var}/games/roguelike +%config(noreplace) %attr(0664,games,games) %{_var}/games/roguelike/rogue54.scr +%doc %{_docdir}/%{name}-%{version} + + +%changelog +* Sun Sep 2 2007 Wart 5.4.4-1 +- Update to 5.4.4 + +* Mon Aug 20 2007 Wart 5.4.3-1 +- Update to 5.4.3 + +* Sun Jul 15 2007 Wart 5.4.2-9 +- New upstream home page and download URL +- Add patch when reading long values from the save file on 64-bit arch + (BZ #248283) +- Add patch removing many compiler warnings +- Use proper version in the .desktop file + +* Sat Mar 3 2007 Wart 5.4.2-8 +- Use better sourceforge download url +- Use more precise desktop file categories + +* Mon Aug 28 2006 Wart 5.4.2-7 +- Rebuild for Fedora Extras + +* Tue May 16 2006 Wart 5.4.2-6 +- Added empty initial scoreboard file. + +* Mon May 15 2006 Wart 5.4.2-5 +- Better setuid/setgid handling (again) (BZ #187392) + +* Thu Mar 30 2006 Wart 5.4.2-4 +- Better setuid/setgid handling (BZ #187392) +- Resize desktop icon to match directory name + +* Mon Mar 13 2006 Wart 5.4.2-3 +- Added icon for .desktop file. + +* Sun Mar 12 2006 Wart 5.4.2-2 +- Added missing BR: ncurses-devel, desktop-file-utils + +* Sat Feb 25 2006 Wart 5.4.2-1 +- Initial spec file. diff --git a/src/cc/rogue/rogue54.sln b/src/cc/rogue/rogue54.sln new file mode 100644 index 000000000..da1c58f07 --- /dev/null +++ b/src/cc/rogue/rogue54.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.ActiveCfg = Debug|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.Build.0 = Debug|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.ActiveCfg = Release|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/cc/rogue/rogue54.vcproj b/src/cc/rogue/rogue54.vcproj new file mode 100644 index 000000000..7e39b98dd --- /dev/null +++ b/src/cc/rogue/rogue54.vcproj @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c new file mode 100644 index 000000000..1dcf3019a --- /dev/null +++ b/src/cc/rogue/rooms.c @@ -0,0 +1,472 @@ +/* + * Create the layout for the new level + * + * @(#)rooms.c 4.45 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +typedef struct spot { /* position matrix for maze positions */ + int nexits; + coord exits[4]; + int used; +} SPOT; + +#define GOLDGRP 1 + +/* + * do_rooms: + * Create rooms and corridors with a connectivity graph + */ + +void +do_rooms(struct rogue_state *rs) +{ + int i; + struct room *rp; + THING *tp; + int left_out; + static coord top; + coord bsze; /* maximum room size */ + coord mp; + + bsze.x = NUMCOLS / 3; + bsze.y = NUMLINES / 3; + /* + * Clear things for a new level + */ + for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) + { + rp->r_goldval = 0; + rp->r_nexits = 0; + rp->r_flags = 0; + } + /* + * Put the gone rooms, if any, on the level + */ + left_out = rnd(4); + for (i = 0; i < left_out; i++) + rooms[rnd_room()].r_flags |= ISGONE; + /* + * dig and populate all the rooms on the level + */ + for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++) + { + /* + * Find upper left corner of box that this room goes in + */ + top.x = (i % 3) * bsze.x + 1; + top.y = (i / 3) * bsze.y; + if (rp->r_flags & ISGONE) + { + /* + * Place a gone room. Make certain that there is a blank line + * for passage drawing. + */ + do + { + rp->r_pos.x = top.x + rnd(bsze.x - 2) + 1; + rp->r_pos.y = top.y + rnd(bsze.y - 2) + 1; + rp->r_max.x = -NUMCOLS; + rp->r_max.y = -NUMLINES; + } until (rp->r_pos.y > 0 && rp->r_pos.y < NUMLINES-1); + continue; + } + /* + * set room type + */ + if (rnd(10) < level - 1) + { + rp->r_flags |= ISDARK; /* dark room */ + if (rnd(15) == 0) + rp->r_flags = ISMAZE; /* maze room */ + } + /* + * Find a place and size for a random room + */ + if (rp->r_flags & ISMAZE) + { + rp->r_max.x = bsze.x - 1; + rp->r_max.y = bsze.y - 1; + if ((rp->r_pos.x = top.x) == 1) + rp->r_pos.x = 0; + if ((rp->r_pos.y = top.y) == 0) + { + rp->r_pos.y++; + rp->r_max.y--; + } + } + else + do + { + rp->r_max.x = rnd(bsze.x - 4) + 4; + rp->r_max.y = rnd(bsze.y - 4) + 4; + rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x); + rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y); + } until (rp->r_pos.y != 0); + draw_room(rp); + /* + * Put the gold in + */ + if (rnd(2) == 0 && (!amulet || level >= max_level)) + { + THING *gold; + + gold = new_item(); + gold->o_goldval = rp->r_goldval = GOLDCALC; + find_floor(rp, &rp->r_gold, FALSE, FALSE); + gold->o_pos = rp->r_gold; + chat(rp->r_gold.y, rp->r_gold.x) = GOLD; + gold->o_flags = ISMANY; + gold->o_group = GOLDGRP; + gold->o_type = GOLD; + attach(lvl_obj, gold); + } + /* + * Put the monster in + */ + if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25)) + { + tp = new_item(); + find_floor(rp, &mp, FALSE, TRUE); + new_monster(rs,tp, randmonster(FALSE), &mp); + give_pack(rs,tp); + } + } +} + +/* + * draw_room: + * Draw a box around a room and lay down the floor for normal + * rooms; for maze rooms, draw maze. + */ + +void +draw_room(struct room *rp) +{ + int y, x; + + if (rp->r_flags & ISMAZE) + do_maze(rp); + else + { + vert(rp, rp->r_pos.x); /* Draw left side */ + vert(rp, rp->r_pos.x + rp->r_max.x - 1); /* Draw right side */ + horiz(rp, rp->r_pos.y); /* Draw top */ + horiz(rp, rp->r_pos.y + rp->r_max.y - 1); /* Draw bottom */ + + /* + * Put the floor down + */ + for (y = rp->r_pos.y + 1; y < rp->r_pos.y + rp->r_max.y - 1; y++) + for (x = rp->r_pos.x + 1; x < rp->r_pos.x + rp->r_max.x - 1; x++) + chat(y, x) = FLOOR; + } +} + +/* + * vert: + * Draw a vertical line + */ + +void +vert(struct room *rp, int startx) +{ + int y; + + for (y = rp->r_pos.y + 1; y <= rp->r_max.y + rp->r_pos.y - 1; y++) + chat(y, startx) = '|'; +} + +/* + * horiz: + * Draw a horizontal line + */ + +void +horiz(struct room *rp, int starty) +{ + int x; + + for (x = rp->r_pos.x; x <= rp->r_pos.x + rp->r_max.x - 1; x++) + chat(starty, x) = '-'; +} + +/* + * do_maze: + * Dig a maze + */ + +static int Maxy, Maxx, Starty, Startx; + +static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1]; + + +void +do_maze(struct room *rp) +{ + SPOT *sp; + int starty, startx; + static coord pos; + + for (sp = &maze[0][0]; sp <= &maze[NUMLINES / 3][NUMCOLS / 3]; sp++) + { + sp->used = FALSE; + sp->nexits = 0; + } + + Maxy = rp->r_max.y; + Maxx = rp->r_max.x; + Starty = rp->r_pos.y; + Startx = rp->r_pos.x; + starty = (rnd(rp->r_max.y) / 2) * 2; + startx = (rnd(rp->r_max.x) / 2) * 2; + pos.y = starty + Starty; + pos.x = startx + Startx; + putpass(&pos); + dig(starty, startx); +} + +/* + * dig: + * Dig out from around where we are now, if possible + */ + +void +dig(int y, int x) +{ + coord *cp; + int cnt, newy, newx, nexty = 0, nextx = 0; + static coord pos; + static coord del[4] = { + {2, 0}, {-2, 0}, {0, 2}, {0, -2} + }; + + for (;;) + { + cnt = 0; + for (cp = del; cp <= &del[3]; cp++) + { + newy = y + cp->y; + newx = x + cp->x; + if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) + continue; + if (flat(newy + Starty, newx + Startx) & F_PASS) + continue; + if (rnd(++cnt) == 0) + { + nexty = newy; + nextx = newx; + } + } + if (cnt == 0) + return; + accnt_maze(y, x, nexty, nextx); + accnt_maze(nexty, nextx, y, x); + if (nexty == y) + { + pos.y = y + Starty; + if (nextx - x < 0) + pos.x = nextx + Startx + 1; + else + pos.x = nextx + Startx - 1; + } + else + { + pos.x = x + Startx; + if (nexty - y < 0) + pos.y = nexty + Starty + 1; + else + pos.y = nexty + Starty - 1; + } + putpass(&pos); + pos.y = nexty + Starty; + pos.x = nextx + Startx; + putpass(&pos); + dig(nexty, nextx); + } +} + +/* + * accnt_maze: + * Account for maze exits + */ + +void +accnt_maze(int y, int x, int ny, int nx) +{ + SPOT *sp; + coord *cp; + + sp = &maze[y][x]; + for (cp = sp->exits; cp < &sp->exits[sp->nexits]; cp++) + if (cp->y == ny && cp->x == nx) + return; + cp->y = ny; + cp->x = nx; +} + +/* + * rnd_pos: + * Pick a random spot in a room + */ + +void +rnd_pos(struct room *rp, coord *cp) +{ + cp->x = rp->r_pos.x + rnd(rp->r_max.x - 2) + 1; + cp->y = rp->r_pos.y + rnd(rp->r_max.y - 2) + 1; +} + +/* + * find_floor: + * Find a valid floor spot in this room. If rp is NULL, then + * pick a new room each time around the loop. + */ +bool +find_floor(struct room *rp, coord *cp, int limit, bool monst) +{ + PLACE *pp; + int cnt; + char compchar = 0; + bool pickroom; + + pickroom = (bool)(rp == NULL); + + if (!pickroom) + compchar = ((rp->r_flags & ISMAZE) ? PASSAGE : FLOOR); + cnt = limit; + for (;;) + { + if (limit && cnt-- == 0) + return FALSE; + if (pickroom) + { + rp = &rooms[rnd_room()]; + compchar = ((rp->r_flags & ISMAZE) ? PASSAGE : FLOOR); + } + rnd_pos(rp, cp); + pp = INDEX(cp->y, cp->x); + if (monst) + { + if (pp->p_monst == NULL && step_ok(pp->p_ch)) + return TRUE; + } + else if (pp->p_ch == compchar) + return TRUE; + } +} + +/* + * enter_room: + * Code that is executed whenver you appear in a room + */ + +void +enter_room(struct rogue_state *rs,coord *cp) +{ + struct room *rp; + THING *tp; + int y, x; + char ch; + + rp = proom = roomin(rs,cp); + door_open(rs,rp); + if (!(rp->r_flags & ISDARK) && !on(player, ISBLIND)) + for (y = rp->r_pos.y; y < rp->r_max.y + rp->r_pos.y; y++) + { + move(y, rp->r_pos.x); + for (x = rp->r_pos.x; x < rp->r_max.x + rp->r_pos.x; x++) + { + tp = moat(y, x); + ch = chat(y, x); + if (tp == NULL) + if (CCHAR(inch()) != ch) + addch(ch); + else + move(y, x + 1); + else + { + tp->t_oldch = ch; + if (!see_monst(tp)) + if (on(player, SEEMONST)) + { + standout(); + addch(tp->t_disguise); + standend(); + } + else + addch(ch); + else + addch(tp->t_disguise); + } + } + } +} + +/* + * leave_room: + * Code for when we exit a room + */ + +void +leave_room(struct rogue_state *rs,coord *cp) +{ + PLACE *pp; + struct room *rp; + int y, x; + char floor; + char ch; + + rp = proom; + + if (rp->r_flags & ISMAZE) + return; + + if (rp->r_flags & ISGONE) + floor = PASSAGE; + else if (!(rp->r_flags & ISDARK) || on(player, ISBLIND)) + floor = FLOOR; + else + floor = ' '; + + proom = &passages[flat(cp->y, cp->x) & F_PNUM]; + for (y = rp->r_pos.y; y < rp->r_max.y + rp->r_pos.y; y++) + for (x = rp->r_pos.x; x < rp->r_max.x + rp->r_pos.x; x++) + { + move(y, x); + switch ( ch = CCHAR(inch()) ) + { + case FLOOR: + if (floor == ' ' && ch != ' ') + addch(' '); + break; + default: + /* + * to check for monster, we have to strip out + * standout bit + */ + if (isupper(toascii(ch))) + { + if (on(player, SEEMONST)) + { + standout(); + addch(ch); + standend(); + break; + } + pp = INDEX(y,x); + addch(pp->p_ch == DOOR ? DOOR : floor); + } + } + } + door_open(rs,rp); +} diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c new file mode 100644 index 000000000..e12d14ea9 --- /dev/null +++ b/src/cc/rogue/save.c @@ -0,0 +1,400 @@ +/* + * save and restore routines + * + * @(#)save.c 4.33 (Berkeley) 06/01/83 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "rogue.h" +#include "score.h" + +typedef struct stat STAT; + +extern char version[], encstr[]; + +static STAT sbuf; + +/* + * save_game: + * Implement the "save game" command + */ + +void +save_game(struct rogue_state *rs) +{ + FILE *savef; + int c; + auto char buf[MAXSTR]; + + /* + * get file name + */ + mpos = 0; +over: + if (file_name[0] != '\0') + { + for (;;) + { + msg(rs,"save file (%s)? ", file_name); + c = readchar(rs); + mpos = 0; + if (c == ESCAPE) + { + msg(rs,""); + return; + } + else if (c == 'n' || c == 'N' || c == 'y' || c == 'Y') + break; + else + msg(rs,"please answer Y or N"); + } + if (c == 'y' || c == 'Y') + { + addstr("Yes\n"); + refresh(); + strcpy(buf, file_name); + goto gotfile; + } + } + + do + { + mpos = 0; + msg(rs,"file name: "); + buf[0] = '\0'; + if (get_str(rs,buf, stdscr) == QUIT) + { +quit_it: + msg(rs,""); + return; + } + mpos = 0; +gotfile: + /* + * test to see if the file exists + */ + if (stat(buf, &sbuf) >= 0) + { + for (;;) + { + msg(rs,"File exists. Do you wish to overwrite it?"); + mpos = 0; + if ((c = readchar(rs)) == ESCAPE) + goto quit_it; + if (c == 'y' || c == 'Y') + break; + else if (c == 'n' || c == 'N') + goto over; + else + msg(rs,"Please answer Y or N"); + } + msg(rs,"file name: %s", buf); + md_unlink(file_name); + } + strcpy(file_name, buf); + if ((savef = fopen(file_name, "w")) == NULL) + msg(rs,strerror(errno)); + } while (savef == NULL); + + save_file(savef,1); + /* NOTREACHED */ +} + +/* + * auto_save: + * Automatically save a file. This is used if a HUP signal is + * recieved + */ + +void +auto_save(int sig) +{ + FILE *savef; + NOOP(sig); + + md_ignoreallsignals(); + if (file_name[0] != '\0' && ((savef = fopen(file_name, "w")) != NULL || + (md_unlink_open_file(file_name, savef) >= 0 && (savef = fopen(file_name, "w")) != NULL))) + save_file(savef,1); + exit(0); +} + +/* + * save_file: + * Write the saved game on the file + */ + +void +save_file(FILE *savef,int32_t guiflag) +{ + char buf[80]; + mvcur(0, COLS - 1, LINES - 1, 0); + putchar('\n'); + endwin(); + resetltchars(); + md_chmod(file_name, 0400); + if ( guiflag != 0 ) + { + encwrite(version, strlen(version)+1, savef); + sprintf(buf,"%d x %d\n", LINES, COLS); + encwrite(buf,80,savef); + } + rs_save_file(savef); + fflush(savef); + fclose(savef); + if ( guiflag != 0 ) + exit(0); +} + +/* + * restore: + * Restore a saved game from a file with elaborate checks for file + * integrity from cheaters + */ +bool +restore(struct rogue_state *rs,char *file, char **envp) +{ + FILE *inf; + int syml; + extern char **environ; + auto char buf[MAXSTR]; + auto STAT sbuf2; + int lines, cols; + + if (strcmp(file, "-r") == 0) + file = file_name; + + md_tstphold(); + + if ((inf = fopen(file,"r")) == NULL) + { + perror(file); + return FALSE; + } + stat(file, &sbuf2); + syml = is_symlink(file); + + fflush(stdout); + encread(buf, (unsigned) strlen(version) + 1, inf); + if (strcmp(buf, version) != 0) + { + printf("Sorry, saved game is out of date.\n"); + return FALSE; + } + encread(buf,80,inf); + sscanf(buf,"%d x %d\n", &lines, &cols); + + initscr(); /* Start up cursor package */ + keypad(stdscr, 1); + + if (lines > LINES) + { + endwin(); + printf("Sorry, original game was played on a screen with %d lines.\n",lines); + printf("Current screen only has %d lines. Unable to restore game\n",LINES); + return(FALSE); + } + if (cols > COLS) + { + endwin(); + printf("Sorry, original game was played on a screen with %d columns.\n",cols); + printf("Current screen only has %d columns. Unable to restore game\n",COLS); + return(FALSE); + } + + hw = newwin(LINES, COLS, 0, 0); + setup(); + + rs_restore_file(inf); + /* + * we do not close the file so that we will have a hold of the + * inode for as long as possible + */ + + if ( +#ifdef MASTER + !wizard && +#endif + md_unlink_open_file(file, inf) < 0) + { + printf("Cannot unlink file\n"); + return FALSE; + } + mpos = 0; +/* printw(0, 0, "%s: %s", file, ctime(&sbuf2.st_mtime)); */ +/* + printw("%s: %s", file, ctime(&sbuf2.st_mtime)); +*/ + clearok(stdscr,TRUE); + /* + * defeat multiple restarting from the same place + */ +#ifdef MASTER + if (!wizard) +#endif + if (sbuf2.st_nlink != 1 || syml) + { + endwin(); + printf("\nCannot restore from a linked file\n"); + return FALSE; + } + + if (pstats.s_hpt <= 0) + { + endwin(); + printf("\n\"He's dead, Jim\"\n"); + return FALSE; + } + + md_tstpresume(); + + environ = envp; + strcpy(file_name, file); + clearok(curscr, TRUE); + srand((int32_t)rs->seed);//md_getpid()); + msg(rs,"file name: %s", file); + playit(rs); + /*NOTREACHED*/ + return(0); +} + +/* + * encwrite: + * Perform an encrypted write + */ +#define CRYPT_ENABLE 0 + +size_t +encwrite(char *start, size_t size, FILE *outf) +{ + char *e1, *e2, fb; + int temp; + extern char statlist[]; + size_t o_size = size; + e1 = encstr; + e2 = statlist; + fb = 0; + + while(size) + { + if ( CRYPT_ENABLE ) + { + if (putc(*start++ ^ *e1 ^ *e2 ^ fb, outf) == EOF) + break; + + temp = *e1++; + fb = fb + ((char) (temp * *e2++)); + if (*e1 == '\0') + e1 = encstr; + if (*e2 == '\0') + e2 = statlist; + } + else if ( putc(*start++,outf) == EOF ) + break; + size--; + } + + return(o_size - size); +} + +/* + * encread: + * Perform an encrypted read + */ +size_t +encread(char *start, size_t size, FILE *inf) +{ + char *e1, *e2, fb; + int temp; + size_t read_size; + extern char statlist[]; + + fb = 0; + + if ((read_size = fread(start,1,size,inf)) == 0 || read_size == -1) + return(read_size); + if ( CRYPT_ENABLE ) + { + e1 = encstr; + e2 = statlist; + while (size--) + { + *start++ ^= *e1 ^ *e2 ^ fb; + temp = *e1++; + fb = fb + (char)(temp * *e2++); + if (*e1 == '\0') + e1 = encstr; + if (*e2 == '\0') + e2 = statlist; + } + } + return(read_size); +} + +static char scoreline[100]; +/* + * read_scrore + * Read in the score file + */ +void +rd_score(SCORE *top_ten) +{ + unsigned int i; + + if (scoreboard == NULL) + return; + + rewind(scoreboard); + + for(i = 0; i < numscores; i++) + { + encread(top_ten[i].sc_name, MAXSTR, scoreboard); + encread(scoreline, 100, scoreboard); + sscanf(scoreline, " %u %d %u %hu %d %x \n", + &top_ten[i].sc_uid, &top_ten[i].sc_score, + &top_ten[i].sc_flags, &top_ten[i].sc_monster, + &top_ten[i].sc_level, &top_ten[i].sc_time); + } + + rewind(scoreboard); +} + +/* + * write_scrore + * Read in the score file + */ +void +wr_score(SCORE *top_ten) +{ + unsigned int i; + + if (scoreboard == NULL) + return; + + rewind(scoreboard); + + for(i = 0; i < numscores; i++) + { + memset(scoreline,0,100); + encwrite(top_ten[i].sc_name, MAXSTR, scoreboard); + sprintf(scoreline, " %u %d %u %hu %d %x \n", + top_ten[i].sc_uid, top_ten[i].sc_score, + top_ten[i].sc_flags, top_ten[i].sc_monster, + top_ten[i].sc_level, top_ten[i].sc_time); + encwrite(scoreline,100,scoreboard); + } + + rewind(scoreboard); +} diff --git a/src/cc/rogue/score.h b/src/cc/rogue/score.h new file mode 100644 index 000000000..fb51bf8bc --- /dev/null +++ b/src/cc/rogue/score.h @@ -0,0 +1,26 @@ +/* + * Score file structure + * + * @(#)score.h 4.6 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +struct sc_ent { + unsigned int sc_uid; + int sc_score; + unsigned int sc_flags; + unsigned short sc_monster; + char sc_name[MAXSTR]; + int sc_level; + unsigned int sc_time; +}; + +typedef struct sc_ent SCORE; + +void rd_score(SCORE *top_ten); +void wr_score(SCORE *top_ten); diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c new file mode 100644 index 000000000..b6854ab07 --- /dev/null +++ b/src/cc/rogue/scrolls.c @@ -0,0 +1,329 @@ +/* + * Read a scroll and let it happen + * + * @(#)scrolls.c 4.44 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include "rogue.h" + +/* + * read_scroll: + * Read a scroll from the pack and do the appropriate thing + */ + +void +read_scroll(struct rogue_state *rs) +{ + THING *obj; + PLACE *pp; + int y, x; + char ch; + int i; + bool discardit = FALSE; + struct room *cur_room; + THING *orig_obj; + static coord mp; + + obj = get_item(rs,"read", SCROLL); + if (obj == NULL) + return; + if (obj->o_type != SCROLL) + { + if (!terse) + msg(rs,"there is nothing on it to read"); + else + msg(rs,"nothing to read"); + return; + } + /* + * Calculate the effect it has on the poor guy. + */ + if (obj == cur_weapon) + cur_weapon = NULL; + /* + * Get rid of the thing + */ + discardit = (bool)(obj->o_count == 1); + leave_pack(rs,obj, FALSE, FALSE); + orig_obj = obj; + + switch (obj->o_which) + { + case S_CONFUSE: + /* + * Scroll of monster confusion. Give him that power. + */ + player.t_flags |= CANHUH; + msg(rs,"your hands begin to glow %s", pick_color("red")); + when S_ARMOR: + if (cur_armor != NULL) + { + cur_armor->o_arm--; + cur_armor->o_flags &= ~ISCURSED; + msg(rs,"your armor glows %s for a moment", pick_color("silver")); + } + when S_HOLD: + /* + * Hold monster scroll. Stop all monsters within two spaces + * from chasing after the hero. + */ + + ch = 0; + for (x = hero.x - 2; x <= hero.x + 2; x++) + if (x >= 0 && x < NUMCOLS) + for (y = hero.y - 2; y <= hero.y + 2; y++) + if (y >= 0 && y <= NUMLINES - 1) + if ((obj = moat(y, x)) != NULL && on(*obj, ISRUN)) + { + obj->t_flags &= ~ISRUN; + obj->t_flags |= ISHELD; + ch++; + } + if (ch) + { + addmsg(rs,"the monster"); + if (ch > 1) + addmsg(rs,"s around you"); + addmsg(rs," freeze"); + if (ch == 1) + addmsg(rs,"s"); + endmsg(rs); + scr_info[S_HOLD].oi_know = TRUE; + } + else + msg(rs,"you feel a strange sense of loss"); + when S_SLEEP: + /* + * Scroll which makes you fall asleep + */ + scr_info[S_SLEEP].oi_know = TRUE; + no_command += rnd(SLEEPTIME) + 4; + player.t_flags &= ~ISRUN; + msg(rs,"you fall asleep"); + when S_CREATE: + /* + * Create a monster: + * First look in a circle around him, next try his room + * otherwise give up + */ + i = 0; + for (y = hero.y - 1; y <= hero.y + 1; y++) + for (x = hero.x - 1; x <= hero.x + 1; x++) + /* + * Don't put a monster in top of the player. + */ + if (y == hero.y && x == hero.x) + continue; + /* + * Or anything else nasty + */ + else if (step_ok(ch = winat(y, x))) + { + if (ch == SCROLL + && find_obj(rs,y, x)->o_which == S_SCARE) + continue; + else if (rnd(++i) == 0) + { + mp.y = y; + mp.x = x; + } + } + if (i == 0) + msg(rs,"you hear a faint cry of anguish in the distance"); + else + { + obj = new_item(); + new_monster(rs,obj, randmonster(FALSE), &mp); + } + when S_ID_POTION: + case S_ID_SCROLL: + case S_ID_WEAPON: + case S_ID_ARMOR: + case S_ID_R_OR_S: + { + static char id_type[S_ID_R_OR_S + 1] = + { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; + /* + * Identify, let him figure something out + */ + scr_info[obj->o_which].oi_know = TRUE; + msg(rs,"this scroll is an %s scroll", scr_info[obj->o_which].oi_name); + whatis(rs,TRUE, id_type[obj->o_which]); + } + when S_MAP: + /* + * Scroll of magic mapping. + */ + scr_info[S_MAP].oi_know = TRUE; + msg(rs,"oh, now this scroll has a map on it"); + /* + * take all the things we want to keep hidden out of the window + */ + for (y = 1; y < NUMLINES - 1; y++) + for (x = 0; x < NUMCOLS; x++) + { + pp = INDEX(y, x); + switch (ch = pp->p_ch) + { + case DOOR: + case STAIRS: + break; + + case '-': + case '|': + if (!(pp->p_flags & F_REAL)) + { + ch = pp->p_ch = DOOR; + pp->p_flags |= F_REAL; + } + break; + + case ' ': + if (pp->p_flags & F_REAL) + goto def; + pp->p_flags |= F_REAL; + ch = pp->p_ch = PASSAGE; + /* FALLTHROUGH */ + + case PASSAGE: +pass: + if (!(pp->p_flags & F_REAL)) + pp->p_ch = PASSAGE; + pp->p_flags |= (F_SEEN|F_REAL); + ch = PASSAGE; + break; + + case FLOOR: + if (pp->p_flags & F_REAL) + ch = ' '; + else + { + ch = TRAP; + pp->p_ch = TRAP; + pp->p_flags |= (F_SEEN|F_REAL); + } + break; + + default: +def: + if (pp->p_flags & F_PASS) + goto pass; + ch = ' '; + break; + } + if (ch != ' ') + { + if ((obj = pp->p_monst) != NULL) + obj->t_oldch = ch; + if (obj == NULL || !on(player, SEEMONST)) + mvaddch(y, x, ch); + } + } + when S_FDET: + /* + * Potion of gold detection + */ + ch = FALSE; + wclear(hw); + for (obj = lvl_obj; obj != NULL; obj = next(obj)) + if (obj->o_type == FOOD) + { + ch = TRUE; + wmove(hw, obj->o_pos.y, obj->o_pos.x); + waddch(hw, FOOD); + } + if (ch) + { + scr_info[S_FDET].oi_know = TRUE; + show_win(rs,"Your nose tingles and you smell food.--More--"); + } + else + msg(rs,"your nose tingles"); + when S_TELEP: + /* + * Scroll of teleportation: + * Make him dissapear and reappear + */ + { + cur_room = proom; + teleport(rs); + if (cur_room != proom) + scr_info[S_TELEP].oi_know = TRUE; + } + when S_ENCH: + if (cur_weapon == NULL || cur_weapon->o_type != WEAPON) + msg(rs,"you feel a strange sense of loss"); + else + { + cur_weapon->o_flags &= ~ISCURSED; + if (rnd(2) == 0) + cur_weapon->o_hplus++; + else + cur_weapon->o_dplus++; + msg(rs,"your %s glows %s for a moment", + weap_info[cur_weapon->o_which].oi_name, pick_color("blue")); + } + when S_SCARE: + /* + * Reading it is a mistake and produces laughter at her + * poor boo boo. + */ + msg(rs,"you hear maniacal laughter in the distance"); + when S_REMOVE: + uncurse(cur_armor); + uncurse(cur_weapon); + uncurse(cur_ring[LEFT]); + uncurse(cur_ring[RIGHT]); + msg(rs,choose_str("you feel in touch with the Universal Onenes", + "you feel as if somebody is watching over you")); + when S_AGGR: + /* + * This scroll aggravates all the monsters on the current + * level and sets them running towards the hero + */ + aggravate(rs); + msg(rs,"you hear a high pitched humming noise"); + when S_PROTECT: + if (cur_armor != NULL) + { + cur_armor->o_flags |= ISPROT; + msg(rs,"your armor is covered by a shimmering %s shield", + pick_color("gold")); + } + else + msg(rs,"you feel a strange sense of loss"); +#ifdef MASTER + otherwise: + msg(rs,"what a puzzling scroll!"); + return; +#endif + } + obj = orig_obj; + look(rs,TRUE); /* put the result of the scroll on the screen */ + status(rs); + + call_it(rs,&scr_info[obj->o_which]); + + if (discardit) + discard(obj); +} + +/* + * uncurse: + * Uncurse an item + */ + +void +uncurse(THING *obj) +{ + if (obj != NULL) + obj->o_flags &= ~ISCURSED; +} diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c new file mode 100644 index 000000000..60a83c333 --- /dev/null +++ b/src/cc/rogue/state.c @@ -0,0 +1,2148 @@ +/* + state.c - Portable Rogue Save State Code + + Copyright (C) 1999, 2000, 2005 Nicholas J. Kisseberth + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name(s) of the author(s) nor the names of other contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include +#include "rogue.h" + +/************************************************************************/ +/* Save State Code */ +/************************************************************************/ + +#define RSID_STATS 0xABCD0001 +#define RSID_THING 0xABCD0002 +#define RSID_THING_NULL 0xDEAD0002 +#define RSID_OBJECT 0xABCD0003 +#define RSID_MAGICITEMS 0xABCD0004 +#define RSID_KNOWS 0xABCD0005 +#define RSID_GUESSES 0xABCD0006 +#define RSID_OBJECTLIST 0xABCD0007 +#define RSID_BAGOBJECT 0xABCD0008 +#define RSID_MONSTERLIST 0xABCD0009 +#define RSID_MONSTERSTATS 0xABCD000A +#define RSID_MONSTERS 0xABCD000B +#define RSID_TRAP 0xABCD000C +#define RSID_WINDOW 0xABCD000D +#define RSID_DAEMONS 0xABCD000E +#define RSID_IWEAPS 0xABCD000F +#define RSID_IARMOR 0xABCD0010 +#define RSID_SPELLS 0xABCD0011 +#define RSID_ILIST 0xABCD0012 +#define RSID_HLIST 0xABCD0013 +#define RSID_DEATHTYPE 0xABCD0014 +#define RSID_CTYPES 0XABCD0015 +#define RSID_COORDLIST 0XABCD0016 +#define RSID_ROOMS 0XABCD0017 + +#define READSTAT (format_error || read_error ) +#define WRITESTAT (write_error) + +static int read_error = FALSE; +static int write_error = FALSE; +static int format_error = FALSE; +static int endian = 0x01020304; +#define big_endian ( *((char *)&endian) == 0x01 ) + +int +rs_write(FILE *savef, void *ptr, size_t size) +{ + if (write_error) + return(WRITESTAT); + + if (encwrite(ptr, size, savef) != size) + write_error = 1; + + return(WRITESTAT); +} + +int +rs_read(FILE *inf, void *ptr, size_t size) +{ + if (read_error || format_error) + return(READSTAT); + + if (encread(ptr, size, inf) != size) + read_error = 1; + + return(READSTAT); +} + +int +rs_write_int(FILE *savef, int c) +{ + unsigned char bytes[4]; + unsigned char *buf = (unsigned char *) &c; + + if (write_error) + return(WRITESTAT); + + if (big_endian) + { + bytes[3] = buf[0]; + bytes[2] = buf[1]; + bytes[1] = buf[2]; + bytes[0] = buf[3]; + buf = bytes; + } + + rs_write(savef, buf, 4); + + return(WRITESTAT); +} + +int +rs_read_int(FILE *inf, int *i) +{ + unsigned char bytes[4]; + int input = 0; + unsigned char *buf = (unsigned char *)&input; + + if (read_error || format_error) + return(READSTAT); + + rs_read(inf, &input, 4); + + if (big_endian) + { + bytes[3] = buf[0]; + bytes[2] = buf[1]; + bytes[1] = buf[2]; + bytes[0] = buf[3]; + buf = bytes; + } + + *i = *((int *) buf); + + return(READSTAT); +} + +int +rs_write_char(FILE *savef, char c) +{ + if (write_error) + return(WRITESTAT); + + rs_write(savef, &c, 1); + + return(WRITESTAT); +} + +int +rs_read_char(FILE *inf, char *c) +{ + if (read_error || format_error) + return(READSTAT); + + rs_read(inf, c, 1); + + return(READSTAT); +} + +int +rs_write_chars(FILE *savef, char *c, int count) +{ + if (write_error) + return(WRITESTAT); + + rs_write_int(savef, count); + rs_write(savef, c, count); + + return(WRITESTAT); +} + +int +rs_read_chars(FILE *inf, char *i, int count) +{ + int value = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &value); + + if (value != count) + format_error = TRUE; + + rs_read(inf, i, count); + + return(READSTAT); +} + +int +rs_write_ints(FILE *savef, int *c, int count) +{ + int n = 0; + + if (write_error) + return(WRITESTAT); + + rs_write_int(savef, count); + + for(n = 0; n < count; n++) + if( rs_write_int(savef,c[n]) != 0) + break; + + return(WRITESTAT); +} + +int +rs_read_ints(FILE *inf, int *i, int count) +{ + int n, value; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf,&value); + + if (value != count) + format_error = TRUE; + + for(n = 0; n < count; n++) + if (rs_read_int(inf, &i[n]) != 0) + break; + + return(READSTAT); +} + +int +rs_write_boolean(FILE *savef, int c) +{ + unsigned char buf = (c == 0) ? 0 : 1; + + if (write_error) + return(WRITESTAT); + + rs_write(savef, &buf, 1); + + return(WRITESTAT); +} + +int +rs_read_boolean(FILE *inf, bool *i) +{ + unsigned char buf = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read(inf, &buf, 1); + + *i = (buf != 0); + + return(READSTAT); +} + +int +rs_write_booleans(FILE *savef, bool *c, int count) +{ + int n = 0; + + if (write_error) + return(WRITESTAT); + + rs_write_int(savef, count); + + for(n = 0; n < count; n++) + if (rs_write_boolean(savef, c[n]) != 0) + break; + + return(WRITESTAT); +} + +int +rs_read_booleans(FILE *inf, bool *i, int count) +{ + int n = 0, value = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf,&value); + + if (value != count) + format_error = TRUE; + + for(n = 0; n < count; n++) + if (rs_read_boolean(inf, &i[n]) != 0) + break; + + return(READSTAT); +} + +int +rs_write_short(FILE *savef, short c) +{ + unsigned char bytes[2]; + unsigned char *buf = (unsigned char *) &c; + + if (write_error) + return(WRITESTAT); + + if (big_endian) + { + bytes[1] = buf[0]; + bytes[0] = buf[1]; + buf = bytes; + } + + rs_write(savef, buf, 2); + + return(WRITESTAT); +} + +int +rs_read_short(FILE *inf, short *i) +{ + unsigned char bytes[2]; + short input; + unsigned char *buf = (unsigned char *)&input; + + if (read_error || format_error) + return(READSTAT); + + rs_read(inf, &input, 2); + + if (big_endian) + { + bytes[1] = buf[0]; + bytes[0] = buf[1]; + buf = bytes; + } + + *i = *((short *) buf); + + return(READSTAT); +} + +int +rs_write_shorts(FILE *savef, short *c, int count) +{ + int n = 0; + + if (write_error) + return(WRITESTAT); + + rs_write_int(savef, count); + + for(n = 0; n < count; n++) + if (rs_write_short(savef, c[n]) != 0) + break; + + return(WRITESTAT); +} + +int +rs_read_shorts(FILE *inf, short *i, int count) +{ + int n = 0, value = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf,&value); + + if (value != count) + format_error = TRUE; + + for(n = 0; n < value; n++) + if (rs_read_short(inf, &i[n]) != 0) + break; + + return(READSTAT); +} + +int +rs_write_ushort(FILE *savef, unsigned short c) +{ + unsigned char bytes[2]; + unsigned char *buf = (unsigned char *) &c; + + if (write_error) + return(WRITESTAT); + + if (big_endian) + { + bytes[1] = buf[0]; + bytes[0] = buf[1]; + buf = bytes; + } + + rs_write(savef, buf, 2); + + return(WRITESTAT); +} + +int +rs_read_ushort(FILE *inf, unsigned short *i) +{ + unsigned char bytes[2]; + unsigned short input; + unsigned char *buf = (unsigned char *)&input; + + if (read_error || format_error) + return(READSTAT); + + rs_read(inf, &input, 2); + + if (big_endian) + { + bytes[1] = buf[0]; + bytes[0] = buf[1]; + buf = bytes; + } + + *i = *((unsigned short *) buf); + + return(READSTAT); +} + +int +rs_write_uint(FILE *savef, unsigned int c) +{ + unsigned char bytes[4]; + unsigned char *buf = (unsigned char *) &c; + + if (write_error) + return(WRITESTAT); + + if (big_endian) + { + bytes[3] = buf[0]; + bytes[2] = buf[1]; + bytes[1] = buf[2]; + bytes[0] = buf[3]; + buf = bytes; + } + + rs_write(savef, buf, 4); + + return(WRITESTAT); +} + +int +rs_read_uint(FILE *inf, unsigned int *i) +{ + unsigned char bytes[4]; + int input; + unsigned char *buf = (unsigned char *)&input; + + if (read_error || format_error) + return(READSTAT); + + rs_read(inf, &input, 4); + + if (big_endian) + { + bytes[3] = buf[0]; + bytes[2] = buf[1]; + bytes[1] = buf[2]; + bytes[0] = buf[3]; + buf = bytes; + } + + *i = *((unsigned int *) buf); + + return(READSTAT); +} + +int +rs_write_marker(FILE *savef, int id) +{ + if (write_error) + return(WRITESTAT); + + rs_write_int(savef, id); + + return(WRITESTAT); +} + +int +rs_read_marker(FILE *inf, int id) +{ + int nid; + + if (read_error || format_error) + return(READSTAT); + + if (rs_read_int(inf, &nid) == 0) + if (id != nid) + format_error = 1; + + return(READSTAT); +} + + + +/******************************************************************************/ + +int +rs_write_string(FILE *savef, char *s) +{ + int len = 0; + + if (write_error) + return(WRITESTAT); + + len = (s == NULL) ? 0 : (int) strlen(s) + 1; + + rs_write_int(savef, len); + rs_write_chars(savef, s, len); + + return(WRITESTAT); +} + +int +rs_read_string(FILE *inf, char *s, int max) +{ + int len = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &len); + + if (len > max) + format_error = TRUE; + + rs_read_chars(inf, s, len); + + return(READSTAT); +} + +int +rs_read_new_string(FILE *inf, char **s) +{ + int len=0; + char *buf=0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &len); + + if (len == 0) + buf = NULL; + else + { + buf = malloc(len); + + if (buf == NULL) + read_error = TRUE; + } + + rs_read_chars(inf, buf, len); + + *s = buf; + + return(READSTAT); +} + +int +rs_write_strings(FILE *savef, char *s[], int count) +{ + int n = 0; + + if (write_error) + return(WRITESTAT); + + rs_write_int(savef, count); + + for(n = 0; n < count; n++) + if (rs_write_string(savef, s[n]) != 0) + break; + + return(WRITESTAT); +} + +int +rs_read_strings(FILE *inf, char **s, int count, int max) +{ + int n = 0; + int value = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &value); + + if (value != count) + format_error = TRUE; + + for(n = 0; n < count; n++) + if (rs_read_string(inf, s[n], max) != 0) + break; + + return(READSTAT); +} + +int +rs_read_new_strings(FILE *inf, char **s, int count) +{ + int n = 0; + int value = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &value); + + if (value != count) + format_error = TRUE; + + for(n = 0; n < count; n++) + if (rs_read_new_string(inf, &s[n]) != 0) + break; + + return(READSTAT); +} + +int +rs_write_string_index(FILE *savef, char *master[], int max, const char *str) +{ + int i; + + if (write_error) + return(WRITESTAT); + + for(i = 0; i < max; i++) + if (str == master[i]) + return( rs_write_int(savef, i) ); + + return( rs_write_int(savef,-1) ); +} + +int +rs_read_string_index(FILE *inf, char *master[], int maxindex, char **str) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &i); + + if (i > maxindex) + format_error = TRUE; + else if (i >= 0) + *str = master[i]; + else + *str = NULL; + + return(READSTAT); +} + +int +rs_write_str_t(FILE *savef, str_t st) +{ + if (write_error) + return(WRITESTAT); + + rs_write_uint(savef, st); + + return( WRITESTAT ); +} + +int +rs_read_str_t(FILE *inf, str_t *st) +{ + if (read_error || format_error) + return(READSTAT); + + rs_read_uint(inf, st); + + return(READSTAT); +} + +int +rs_write_coord(FILE *savef, coord c) +{ + if (write_error) + return(WRITESTAT); + + rs_write_int(savef, c.x); + rs_write_int(savef, c.y); + + return(WRITESTAT); +} + +int +rs_read_coord(FILE *inf, coord *c) +{ + coord in; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf,&in.x); + rs_read_int(inf,&in.y); + + if (READSTAT == 0) + { + c->x = in.x; + c->y = in.y; + } + + return(READSTAT); +} + +int +rs_write_window(FILE *savef, WINDOW *win) +{ + int row,col,height,width; + + if (write_error) + return(WRITESTAT); + + width = getmaxx(win); + height = getmaxy(win); + + rs_write_marker(savef,RSID_WINDOW); + rs_write_int(savef,height); + rs_write_int(savef,width); + + for(row=0;rowl_next) + if (count == i) + return(l); + + return(NULL); +} + +int +find_list_ptr(THING *l, void *ptr) +{ + int count; + + for(count = 0; l != NULL; count++, l = l->l_next) + if (l == ptr) + return(count); + + return(-1); +} + +int +list_size(THING *l) +{ + int count; + + for(count = 0; l != NULL; count++, l = l->l_next) + ; + + return(count); +} + +/******************************************************************************/ + +int +rs_write_stats(FILE *savef, struct stats *s) +{ + if (write_error) + return(WRITESTAT); + + rs_write_marker(savef, RSID_STATS); + rs_write_str_t(savef, s->s_str); + rs_write_int(savef, s->s_exp); + rs_write_int(savef, s->s_lvl); + rs_write_int(savef, s->s_arm); + rs_write_int(savef, s->s_hpt); + rs_write_chars(savef, s->s_dmg, sizeof(s->s_dmg)); + rs_write_int(savef,s->s_maxhp); + + return(WRITESTAT); +} + +int +rs_read_stats(FILE *inf, struct stats *s) +{ + if (read_error || format_error) + return(READSTAT); + + rs_read_marker(inf, RSID_STATS); + rs_read_str_t(inf,&s->s_str); + rs_read_int(inf,&s->s_exp); + rs_read_int(inf,&s->s_lvl); + rs_read_int(inf,&s->s_arm); + rs_read_int(inf,&s->s_hpt); + rs_read_chars(inf,s->s_dmg,sizeof(s->s_dmg)); + rs_read_int(inf,&s->s_maxhp); + + return(READSTAT); +} + +int +rs_write_stone_index(FILE *savef, STONE master[], int max, const char *str) +{ + int i; + + if (write_error) + return(WRITESTAT); + + for(i = 0; i < max; i++) + if (str == master[i].st_name) + { + rs_write_int(savef,i); + return(WRITESTAT); + } + + rs_write_int(savef,-1); + + return(WRITESTAT); +} + +int +rs_read_stone_index(FILE *inf, STONE master[], int maxindex, char **str) +{ + int i = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf,&i); + + if (i > maxindex) + format_error = TRUE; + else if (i >= 0) + *str = master[i].st_name; + else + *str = NULL; + + return(READSTAT); +} + +int +rs_write_scrolls(FILE *savef) +{ + int i; + + if (write_error) + return(WRITESTAT); + + for(i = 0; i < MAXSCROLLS; i++) + rs_write_string(savef, s_names[i]); + + return(READSTAT); +} + +int +rs_read_scrolls(FILE *inf) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + for(i = 0; i < MAXSCROLLS; i++) + rs_read_new_string(inf, &s_names[i]); + + return(READSTAT); +} + +int +rs_write_potions(FILE *savef) +{ + int i; + + if (write_error) + return(WRITESTAT); + + for(i = 0; i < MAXPOTIONS; i++) + rs_write_string_index(savef, rainbow, cNCOLORS, p_colors[i]); + + return(WRITESTAT); +} + +int +rs_read_potions(FILE *inf) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + for(i = 0; i < MAXPOTIONS; i++) + rs_read_string_index(inf, rainbow, cNCOLORS, &p_colors[i]); + + return(READSTAT); +} + +int +rs_write_rings(FILE *savef) +{ + int i; + + if (write_error) + return(WRITESTAT); + + for(i = 0; i < MAXRINGS; i++) + rs_write_stone_index(savef, stones, cNSTONES, r_stones[i]); + + return(WRITESTAT); +} + +int +rs_read_rings(FILE *inf) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + for(i = 0; i < MAXRINGS; i++) + rs_read_stone_index(inf, stones, cNSTONES, &r_stones[i]); + + return(READSTAT); +} + +int +rs_write_sticks(FILE *savef) +{ + int i; + + if (write_error) + return(WRITESTAT); + + for (i = 0; i < MAXSTICKS; i++) + { + if (strcmp(ws_type[i],"staff") == 0) + { + rs_write_int(savef,0); + rs_write_string_index(savef, wood, cNWOOD, ws_made[i]); + } + else + { + rs_write_int(savef,1); + rs_write_string_index(savef, metal, cNMETAL, ws_made[i]); + } + } + + return(WRITESTAT); +} + +int +rs_read_sticks(FILE *inf) +{ + int i = 0, list = 0; + + if (read_error || format_error) + return(READSTAT); + + for(i = 0; i < MAXSTICKS; i++) + { + rs_read_int(inf,&list); + + if (list == 0) + { + rs_read_string_index(inf, wood, cNWOOD, &ws_made[i]); + ws_type[i] = "staff"; + } + else + { + rs_read_string_index(inf, metal, cNMETAL, &ws_made[i]); + ws_type[i] = "wand"; + } + } + + return(READSTAT); +} + +int +rs_write_daemons(FILE *savef, struct delayed_action *d_list, int count) +{ + int i = 0; + int func = 0; + + if (write_error) + return(WRITESTAT); + + rs_write_marker(savef, RSID_DAEMONS); + rs_write_int(savef, count); + + for(i = 0; i < count; i++) + { + if (d_list[i].d_func == rollwand) + func = 1; + else if (d_list[i].d_func == doctor) + func = 2; + else if (d_list[i].d_func == stomach) + func = 3; + else if (d_list[i].d_func == runners) + func = 4; + else if (d_list[i].d_func == swander) + func = 5; + else if (d_list[i].d_func == nohaste) + func = 6; + else if (d_list[i].d_func == unconfuse) + func = 7; + else if (d_list[i].d_func == unsee) + func = 8; + else if (d_list[i].d_func == sight) + func = 9; + else if (d_list[i].d_func == NULL) + func = 0; + else + func = -1; + + rs_write_int(savef, d_list[i].d_type); + rs_write_int(savef, func); + rs_write_int(savef, d_list[i].d_arg); + rs_write_int(savef, d_list[i].d_time); + } + + return(WRITESTAT); +} + +int +rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count) +{ + int i = 0; + int func = 0; + int value = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_marker(inf, RSID_DAEMONS); + rs_read_int(inf, &value); + + if (value > count) + format_error = TRUE; + + for(i=0; i < count; i++) + { + func = 0; + rs_read_int(inf, &d_list[i].d_type); + rs_read_int(inf, &func); + rs_read_int(inf, &d_list[i].d_arg); + rs_read_int(inf, &d_list[i].d_time); + + switch(func) + { + case 1: d_list[i].d_func = rollwand; + break; + case 2: d_list[i].d_func = doctor; + break; + case 3: d_list[i].d_func = stomach; + break; + case 4: d_list[i].d_func = runners; + break; + case 5: d_list[i].d_func = swander; + break; + case 6: d_list[i].d_func = nohaste; + break; + case 7: d_list[i].d_func = unconfuse; + break; + case 8: d_list[i].d_func = unsee; + break; + case 9: d_list[i].d_func = sight; + break; + default:d_list[i].d_func = NULL; + break; + } + } + + if (d_list[i].d_func == NULL) + { + d_list[i].d_type = 0; + d_list[i].d_arg = 0; + d_list[i].d_time = 0; + } + + return(READSTAT); +} + +int +rs_write_obj_info(FILE *savef, struct obj_info *i, int count) +{ + int n; + + if (write_error) + return(WRITESTAT); + + rs_write_marker(savef, RSID_MAGICITEMS); + rs_write_int(savef, count); + + for(n = 0; n < count; n++) + { + /* mi_name is constant, defined at compile time in all cases */ + rs_write_int(savef,i[n].oi_prob); + rs_write_int(savef,i[n].oi_worth); + rs_write_string(savef,i[n].oi_guess); + rs_write_boolean(savef,i[n].oi_know); + } + + return(WRITESTAT); +} + +int +rs_read_obj_info(FILE *inf, struct obj_info *mi, int count) +{ + int n; + int value; + + if (read_error || format_error) + return(READSTAT); + + rs_read_marker(inf, RSID_MAGICITEMS); + + rs_read_int(inf, &value); + + if (value > count) + format_error = TRUE; + + for(n = 0; n < value; n++) + { + /* mi_name is const, defined at compile time in all cases */ + rs_read_int(inf,&mi[n].oi_prob); + rs_read_int(inf,&mi[n].oi_worth); + rs_read_new_string(inf,&mi[n].oi_guess); + rs_read_boolean(inf,&mi[n].oi_know); + } + + return(READSTAT); +} + +int +rs_write_room(FILE *savef, struct room *r) +{ + if (write_error) + return(WRITESTAT); + + rs_write_coord(savef, r->r_pos); + rs_write_coord(savef, r->r_max); + rs_write_coord(savef, r->r_gold); + rs_write_int(savef, r->r_goldval); + rs_write_short(savef, r->r_flags); + rs_write_int(savef, r->r_nexits); + rs_write_coord(savef, r->r_exit[0]); + rs_write_coord(savef, r->r_exit[1]); + rs_write_coord(savef, r->r_exit[2]); + rs_write_coord(savef, r->r_exit[3]); + rs_write_coord(savef, r->r_exit[4]); + rs_write_coord(savef, r->r_exit[5]); + rs_write_coord(savef, r->r_exit[6]); + rs_write_coord(savef, r->r_exit[7]); + rs_write_coord(savef, r->r_exit[8]); + rs_write_coord(savef, r->r_exit[9]); + rs_write_coord(savef, r->r_exit[10]); + rs_write_coord(savef, r->r_exit[11]); + + return(WRITESTAT); +} + +int +rs_read_room(FILE *inf, struct room *r) +{ + if (read_error || format_error) + return(READSTAT); + + rs_read_coord(inf,&r->r_pos); + rs_read_coord(inf,&r->r_max); + rs_read_coord(inf,&r->r_gold); + rs_read_int(inf,&r->r_goldval); + rs_read_short(inf,&r->r_flags); + rs_read_int(inf,&r->r_nexits); + rs_read_coord(inf,&r->r_exit[0]); + rs_read_coord(inf,&r->r_exit[1]); + rs_read_coord(inf,&r->r_exit[2]); + rs_read_coord(inf,&r->r_exit[3]); + rs_read_coord(inf,&r->r_exit[4]); + rs_read_coord(inf,&r->r_exit[5]); + rs_read_coord(inf,&r->r_exit[6]); + rs_read_coord(inf,&r->r_exit[7]); + rs_read_coord(inf,&r->r_exit[8]); + rs_read_coord(inf,&r->r_exit[9]); + rs_read_coord(inf,&r->r_exit[10]); + rs_read_coord(inf,&r->r_exit[11]); + + return(READSTAT); +} + +int +rs_write_rooms(FILE *savef, struct room r[], int count) +{ + int n = 0; + + if (write_error) + return(WRITESTAT); + //fprintf(stderr,"rooms %ld -> ",ftell(savef)); + rs_write_int(savef, count); + + for(n = 0; n < count; n++) + rs_write_room(savef, &r[n]); + //fprintf(stderr,"%ld\n",ftell(savef)); + + return(WRITESTAT); +} + +int +rs_read_rooms(FILE *inf, struct room *r, int count) +{ + int value = 0, n = 0; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf,&value); + + if (value > count) + format_error = TRUE; + + for(n = 0; n < value; n++) + rs_read_room(inf,&r[n]); + + return(READSTAT); +} + +int +rs_write_room_reference(FILE *savef, struct room *rp) +{ + int i, room = -1; + + if (write_error) + return(WRITESTAT); + + for (i = 0; i < MAXROOMS; i++) + if (&rooms[i] == rp) + room = i; + + rs_write_int(savef, room); + + return(WRITESTAT); +} + +int +rs_read_room_reference(FILE *inf, struct room **rp) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &i); + + *rp = &rooms[i]; + + return(READSTAT); +} + +int +rs_write_monsters(FILE *savef, struct monster *m, int count) +{ + int n; + + if (write_error) + return(WRITESTAT); + + rs_write_marker(savef, RSID_MONSTERS); + rs_write_int(savef, count); + + for(n=0;n ",ftell(savef)); + + rs_write_marker(savef, RSID_OBJECT); + rs_write_int(savef, o->_o._o_type); + rs_write_coord(savef, o->_o._o_pos); + rs_write_int(savef, o->_o._o_launch); + rs_write_char(savef, o->_o._o_packch); + rs_write_chars(savef, o->_o._o_damage, sizeof(o->_o._o_damage)); + rs_write_chars(savef, o->_o._o_hurldmg, sizeof(o->_o._o_hurldmg)); + rs_write_int(savef, o->_o._o_count); + rs_write_int(savef, o->_o._o_which); + rs_write_int(savef, o->_o._o_hplus); + rs_write_int(savef, o->_o._o_dplus); + rs_write_int(savef, o->_o._o_arm); + rs_write_int(savef, o->_o._o_flags); + rs_write_int(savef, o->_o._o_group); + rs_write_string(savef, o->_o._o_label); + //fprintf(stderr,"%ld\n",ftell(savef)); + return(WRITESTAT); +} + +int +rs_read_object(FILE *inf, THING *o) +{ + if (read_error || format_error) + return(READSTAT); + + rs_read_marker(inf, RSID_OBJECT); + rs_read_int(inf, &o->_o._o_type); + rs_read_coord(inf, &o->_o._o_pos); + rs_read_int(inf, &o->_o._o_launch); + rs_read_char(inf, &o->_o._o_packch); + rs_read_chars(inf, o->_o._o_damage, sizeof(o->_o._o_damage)); + rs_read_chars(inf, o->_o._o_hurldmg, sizeof(o->_o._o_hurldmg)); + rs_read_int(inf, &o->_o._o_count); + rs_read_int(inf, &o->_o._o_which); + rs_read_int(inf, &o->_o._o_hplus); + rs_read_int(inf, &o->_o._o_dplus); + rs_read_int(inf, &o->_o._o_arm); + rs_read_int(inf, &o->_o._o_flags); + rs_read_int(inf, &o->_o._o_group); + rs_read_new_string(inf, &o->_o._o_label); + + return(READSTAT); +} + +int +rs_write_object_list(FILE *savef, THING *l) +{ + if (write_error) + return(WRITESTAT); + //fprintf(stderr,"list %ld -> ",ftell(savef)); + + rs_write_marker(savef, RSID_OBJECTLIST); + rs_write_int(savef, list_size(l)); + + for( ;l != NULL; l = l->l_next) + rs_write_object(savef, l); + //fprintf(stderr,"%ld\n",ftell(savef)); + + return(WRITESTAT); +} + +int +rs_read_object_list(FILE *inf, THING **list) +{ + int i, cnt; + THING *l = NULL, *previous = NULL, *head = NULL; + + if (read_error || format_error) + return(READSTAT); + + rs_read_marker(inf, RSID_OBJECTLIST); + rs_read_int(inf, &cnt); + + for (i = 0; i < cnt; i++) + { + l = new_item();//,sizeof(THING)); + + memset(l,0,sizeof(THING)); + + l->l_prev = previous; + + if (previous != NULL) + previous->l_next = l; + + rs_read_object(inf,l); + + if (previous == NULL) + head = l; + + previous = l; + } + + if (l != NULL) + l->l_next = NULL; + + *list = head; + + return(READSTAT); +} + +int +rs_write_object_reference(FILE *savef, THING *list, THING *item) +{ + int i; + + if (write_error) + return(WRITESTAT); + + i = find_list_ptr(list, item); + + rs_write_int(savef, i); + + return(WRITESTAT); +} + +int +rs_read_object_reference(FILE *inf, THING *list, THING **item) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &i); + + *item = get_list_item(list,i); + + return(READSTAT); +} + +int +find_room_coord(struct room *rmlist, coord *c, int n) +{ + int i = 0; + + for(i = 0; i < n; i++) + if(&rmlist[i].r_gold == c) + return(i); + + return(-1); +} + +int +find_thing_coord(THING *monlist, coord *c) +{ + THING *mitem; + THING *tp; + int i = 0; + + for(mitem = monlist; mitem != NULL; mitem = mitem->l_next) + { + tp = mitem; + + if (c == &tp->t_pos) + return(i); + + i++; + } + + return(-1); +} + +int +find_object_coord(THING *objlist, coord *c) +{ + THING *oitem; + THING *obj; + int i = 0; + + for(oitem = objlist; oitem != NULL; oitem = oitem->l_next) + { + obj = oitem; + + if (c == &obj->o_pos) + return(i); + + i++; + } + + return(-1); +} + +int +rs_write_thing(FILE *savef, THING *t) +{ + int i = -1; + + if (write_error) + return(WRITESTAT); + //fprintf(stderr,"thing %ld -> ",ftell(savef)); + + rs_write_marker(savef, RSID_THING); + + if (t == NULL) + { + rs_write_int(savef, 0); + return(WRITESTAT); + } + + rs_write_int(savef, 1); + rs_write_coord(savef, t->_t._t_pos); + rs_write_boolean(savef, t->_t._t_turn); + rs_write_char(savef, t->_t._t_type); + rs_write_char(savef, t->_t._t_disguise); + rs_write_char(savef, t->_t._t_oldch); + + /* + t_dest can be: + 0,0: NULL + 0,1: location of hero + 1,i: location of a thing (monster) + 2,i: location of an object + 3,i: location of gold in a room + + We need to remember what we are chasing rather than + the current location of what we are chasing. + */ + + if (t->t_dest == &hero) + { + rs_write_int(savef,0); + rs_write_int(savef,1); + } + else if (t->t_dest != NULL) + { + i = find_thing_coord(mlist, t->t_dest); + + if (i >=0 ) + { + rs_write_int(savef,1); + rs_write_int(savef,i); + } + else + { + i = find_object_coord(lvl_obj, t->t_dest); + + if (i >= 0) + { + rs_write_int(savef,2); + rs_write_int(savef,i); + } + else + { + i = find_room_coord(rooms, t->t_dest, MAXROOMS); + + if (i >= 0) + { + rs_write_int(savef,3); + rs_write_int(savef,i); + } + else + { + rs_write_int(savef, 0); + rs_write_int(savef,1); /* chase the hero anyway */ + } + } + } + } + else + { + rs_write_int(savef,0); + rs_write_int(savef,0); + } + + rs_write_short(savef, t->_t._t_flags); + rs_write_stats(savef, &t->_t._t_stats); + rs_write_room_reference(savef, t->_t._t_room); + rs_write_object_list(savef, t->_t._t_pack); + //fprintf(stderr,"%ld\n",ftell(savef)); + + return(WRITESTAT); +} + +int +rs_read_thing(FILE *inf, THING *t) +{ + int listid = 0, index = -1; + THING *item; + + if (read_error || format_error) + return(READSTAT); + + rs_read_marker(inf, RSID_THING); + + rs_read_int(inf, &index); + + if (index == 0) + return(READSTAT); + + rs_read_coord(inf,&t->_t._t_pos); + rs_read_boolean(inf,&t->_t._t_turn); + rs_read_char(inf,&t->_t._t_type); + rs_read_char(inf,&t->_t._t_disguise); + rs_read_char(inf,&t->_t._t_oldch); + + /* + t_dest can be (listid,index): + 0,0: NULL + 0,1: location of hero + 1,i: location of a thing (monster) + 2,i: location of an object + 3,i: location of gold in a room + + We need to remember what we are chasing rather than + the current location of what we are chasing. + */ + + rs_read_int(inf, &listid); + rs_read_int(inf, &index); + t->_t._t_reserved = -1; + + if (listid == 0) /* hero or NULL */ + { + if (index == 1) + t->_t._t_dest = &hero; + else + t->_t._t_dest = NULL; + } + else if (listid == 1) /* monster/thing */ + { + t->_t._t_dest = NULL; + t->_t._t_reserved = index; + } + else if (listid == 2) /* object */ + { + THING *obj; + + item = get_list_item(lvl_obj, index); + + if (item != NULL) + { + obj = item; + t->_t._t_dest = &obj->o_pos; + } + } + else if (listid == 3) /* gold */ + { + t->_t._t_dest = &rooms[index].r_gold; + } + else + t->_t._t_dest = NULL; + + rs_read_short(inf,&t->_t._t_flags); + rs_read_stats(inf,&t->_t._t_stats); + rs_read_room_reference(inf, &t->_t._t_room); + rs_read_object_list(inf,&t->_t._t_pack); + + return(READSTAT); +} + +void +rs_fix_thing(THING *t) +{ + THING *item; + THING *tp; + + if (t->t_reserved < 0) + return; + + item = get_list_item(mlist,t->t_reserved); + + if (item != NULL) + { + tp = item; + t->t_dest = &tp->t_pos; + } +} + +int +rs_write_thing_list(FILE *savef, THING *l) +{ + int cnt = 0; + + if (write_error) + return(WRITESTAT); + + rs_write_marker(savef, RSID_MONSTERLIST); + + cnt = list_size(l); + + rs_write_int(savef, cnt); + + if (cnt < 1) + return(WRITESTAT); + + while (l != NULL) { + rs_write_thing(savef, l); + l = l->l_next; + } + + return(WRITESTAT); +} + +int +rs_read_thing_list(FILE *inf, THING **list) +{ + int i, cnt; + THING *l = NULL, *previous = NULL, *head = NULL; + + if (read_error || format_error) + return(READSTAT); + + rs_read_marker(inf, RSID_MONSTERLIST); + + rs_read_int(inf, &cnt); + + for (i = 0; i < cnt; i++) + { + l = new_item(); + + l->l_prev = previous; + + if (previous != NULL) + previous->l_next = l; + + rs_read_thing(inf,l); + + if (previous == NULL) + head = l; + + previous = l; + } + + if (l != NULL) + l->l_next = NULL; + + *list = head; + + return(READSTAT); +} + +void +rs_fix_thing_list(THING *list) +{ + THING *item; + + for(item = list; item != NULL; item = item->l_next) + rs_fix_thing(item); +} + +int +rs_write_thing_reference(FILE *savef, THING *list, THING *item) +{ + int i; + + if (write_error) + return(WRITESTAT); + + if (item == NULL) + rs_write_int(savef,-1); + else + { + i = find_list_ptr(list, item); + + rs_write_int(savef, i); + } + + return(WRITESTAT); +} + +int +rs_read_thing_reference(FILE *inf, THING *list, THING **item) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + rs_read_int(inf, &i); + + if (i == -1) + *item = NULL; + else + *item = get_list_item(list,i); + + return(READSTAT); +} + +int +rs_write_thing_references(FILE *savef, THING *list, THING *items[], int count) +{ + int i; + + if (write_error) + return(WRITESTAT); + + for(i = 0; i < count; i++) + rs_write_thing_reference(savef,list,items[i]); + + return(WRITESTAT); +} + +int +rs_read_thing_references(FILE *inf, THING *list, THING *items[], int count) +{ + int i; + + if (read_error || format_error) + return(READSTAT); + + for(i = 0; i < count; i++) + rs_read_thing_reference(inf,list,&items[i]); + + return(WRITESTAT); +} + +int +rs_write_places(FILE *savef, PLACE *places, int count) +{ + int i = 0; + //fprintf(stderr,"places %ld -> ",ftell(savef)); + + if (write_error) + return(WRITESTAT); + + for(i = 0; i < count; i++) + { + rs_write_char(savef, places[i].p_ch); + rs_write_char(savef, places[i].p_flags); + rs_write_thing_reference(savef, mlist, places[i].p_monst); + } + //fprintf(stderr,"%ld\n",ftell(savef)); + + return(WRITESTAT); +} + +int +rs_read_places(FILE *inf, PLACE *places, int count) +{ + int i = 0; + + if (read_error || format_error) + return(READSTAT); + + for(i = 0; i < count; i++) + { + rs_read_char(inf,&places[i].p_ch); + rs_read_char(inf,&places[i].p_flags); + rs_read_thing_reference(inf, mlist, &places[i].p_monst); + } + + return(READSTAT); +} + +int +rs_save_file(FILE *savef) +{ + if (write_error) + return(WRITESTAT); + + rs_write_boolean(savef, after); /* 1 */ /* extern.c */ + rs_write_boolean(savef, again); /* 2 */ + rs_write_int(savef, noscore); /* 3 */ + rs_write_boolean(savef, seenstairs); /* 4 */ + rs_write_boolean(savef, amulet); /* 5 */ + rs_write_boolean(savef, door_stop); /* 6 */ + rs_write_boolean(savef, fight_flush); /* 7 */ + rs_write_boolean(savef, firstmove); /* 8 */ + rs_write_boolean(savef, got_ltc); /* 9 */ + rs_write_boolean(savef, has_hit); /* 10 */ + rs_write_boolean(savef, in_shell); /* 11 */ + rs_write_boolean(savef, inv_describe); /* 12 */ + rs_write_boolean(savef, jump); /* 13 */ + rs_write_boolean(savef, kamikaze); /* 14 */ + rs_write_boolean(savef, lower_msg); /* 15 */ + rs_write_boolean(savef, move_on); /* 16 */ + rs_write_boolean(savef, msg_esc); /* 17 */ + rs_write_boolean(savef, passgo); /* 18 */ + rs_write_boolean(savef, playing); /* 19 */ + rs_write_boolean(savef, q_comm); /* 20 */ + rs_write_boolean(savef, running); /* 21 */ + rs_write_boolean(savef, save_msg); /* 22 */ + rs_write_boolean(savef, see_floor); /* 23 */ + rs_write_boolean(savef, stat_msg); /* 24 */ + rs_write_boolean(savef, terse); /* 25 */ + rs_write_boolean(savef, to_death); /* 26 */ + rs_write_boolean(savef, tombstone); /* 27 */ +#ifdef MASTER + rs_write_int(savef, wizard); /* 28 */ +#else + rs_write_int(savef, 0); /* 28 */ +#endif + rs_write_booleans(savef, pack_used, 26); /* 29 */ + rs_write_char(savef, dir_ch); + //rs_write_chars(savef, file_name, MAXSTR); + //rs_write_chars(savef, huh, MAXSTR); + rs_write_potions(savef); + //rs_write_chars(savef,prbuf,2*MAXSTR); + rs_write_rings(savef); + rs_write_string(savef,release); + rs_write_char(savef, runch); + rs_write_scrolls(savef); + rs_write_char(savef, take); + //rs_write_chars(savef, whoami, MAXSTR); + rs_write_sticks(savef); + rs_write_int(savef,orig_dsusp); + rs_write_chars(savef, fruit, MAXSTR); + //rs_write_chars(savef, home, MAXSTR); + rs_write_strings(savef,inv_t_name,3); + rs_write_char(savef,l_last_comm); + rs_write_char(savef,l_last_dir); + rs_write_char(savef,last_comm); + rs_write_char(savef,last_dir); + rs_write_strings(savef,tr_name,8); + rs_write_int(savef,n_objs); + rs_write_int(savef, ntraps); + rs_write_int(savef, hungry_state); + rs_write_int(savef, inpack); + rs_write_int(savef, inv_type); + rs_write_int(savef, level); + rs_write_int(savef, max_level); + rs_write_int(savef, mpos); + rs_write_int(savef, no_food); + rs_write_ints(savef,a_class,MAXARMORS); + rs_write_int(savef, count); + rs_write_int(savef, food_left); + rs_write_int(savef, lastscore); + rs_write_int(savef, no_command); + rs_write_int(savef, no_move); + rs_write_int(savef, purse); + rs_write_int(savef, quiet); + rs_write_int(savef, vf_hit); + //rs_write_int(savef, dnum); + rs_write_int(savef, (int32_t)(seed&0xffffffff)); + rs_write_int(savef, (int32_t)((seed>>32)&0xffffffff)); + rs_write_ints(savef, e_levels, 21); + rs_write_coord(savef, delta); + rs_write_coord(savef, oldpos); + rs_write_coord(savef, stairs); + rs_write_thing(savef, &player); + rs_write_object_reference(savef, player.t_pack, cur_armor); + rs_write_object_reference(savef, player.t_pack, cur_ring[0]); + rs_write_object_reference(savef, player.t_pack, cur_ring[1]); + rs_write_object_reference(savef, player.t_pack, cur_weapon); + rs_write_object_reference(savef, player.t_pack, l_last_pick); + rs_write_object_reference(savef, player.t_pack, last_pick); + + rs_write_object_list(savef, lvl_obj); + rs_write_thing_list(savef, mlist); + + rs_write_places(savef,places,MAXLINES*MAXCOLS); + + rs_write_stats(savef,&max_stats); + rs_write_rooms(savef, rooms, MAXROOMS); + rs_write_room_reference(savef, oldrp); + rs_write_rooms(savef, passages, MAXPASS); + + rs_write_monsters(savef,monsters,26); + rs_write_obj_info(savef, things, NUMTHINGS); + rs_write_obj_info(savef, arm_info, MAXARMORS); + rs_write_obj_info(savef, pot_info, MAXPOTIONS); + rs_write_obj_info(savef, ring_info, MAXRINGS); + rs_write_obj_info(savef, scr_info, MAXSCROLLS); + rs_write_obj_info(savef, weap_info, MAXWEAPONS+1); + rs_write_obj_info(savef, ws_info, MAXSTICKS); + + + rs_write_daemons(savef, &d_list[0], 20); /* 5.4-daemon.c */ +#ifdef MASTER + rs_write_int(savef,total); /* 5.4-list.c */ +#else + rs_write_int(savef, 0); +#endif + rs_write_int(savef,between); /* 5.4-daemons.c*/ + rs_write_coord(savef, nh); /* 5.4-move.c */ + rs_write_int(savef, group); /* 5.4-weapons.c */ + //fprintf(stderr,"fifth %ld\n",ftell(savef)); + + rs_write_window(savef,stdscr); + //fprintf(stderr,"done %ld\n",ftell(savef)); + + return(WRITESTAT); +} + +int +rs_restore_file(FILE *inf) +{ + int dummyint; + + if (read_error || format_error) + return(READSTAT); + + rs_read_boolean(inf, &after); /* 1 */ /* extern.c */ + rs_read_boolean(inf, &again); /* 2 */ + rs_read_int(inf, &noscore); /* 3 */ + rs_read_boolean(inf, &seenstairs); /* 4 */ + rs_read_boolean(inf, &amulet); /* 5 */ + rs_read_boolean(inf, &door_stop); /* 6 */ + rs_read_boolean(inf, &fight_flush); /* 7 */ + rs_read_boolean(inf, &firstmove); /* 8 */ + rs_read_boolean(inf, &got_ltc); /* 9 */ + rs_read_boolean(inf, &has_hit); /* 10 */ + rs_read_boolean(inf, &in_shell); /* 11 */ + rs_read_boolean(inf, &inv_describe); /* 12 */ + rs_read_boolean(inf, &jump); /* 13 */ + rs_read_boolean(inf, &kamikaze); /* 14 */ + rs_read_boolean(inf, &lower_msg); /* 15 */ + rs_read_boolean(inf, &move_on); /* 16 */ + rs_read_boolean(inf, &msg_esc); /* 17 */ + rs_read_boolean(inf, &passgo); /* 18 */ + rs_read_boolean(inf, &playing); /* 19 */ + rs_read_boolean(inf, &q_comm); /* 20 */ + rs_read_boolean(inf, &running); /* 21 */ + rs_read_boolean(inf, &save_msg); /* 22 */ + rs_read_boolean(inf, &see_floor); /* 23 */ + rs_read_boolean(inf, &stat_msg); /* 24 */ + rs_read_boolean(inf, &terse); /* 25 */ + rs_read_boolean(inf, &to_death); /* 26 */ + rs_read_boolean(inf, &tombstone); /* 27 */ +#ifdef MASTER + rs_read_int(inf, &wizard); /* 28 */ +#else + rs_read_int(inf, &dummyint); /* 28 */ +#endif + rs_read_booleans(inf, pack_used, 26); /* 29 */ + rs_read_char(inf, &dir_ch); + //rs_read_chars(inf, file_name, MAXSTR); + //rs_read_chars(inf, huh, MAXSTR); + rs_read_potions(inf); + //rs_read_chars(inf, prbuf, 2*MAXSTR); + rs_read_rings(inf); + rs_read_new_string(inf,&release); + rs_read_char(inf, &runch); + rs_read_scrolls(inf); + rs_read_char(inf, &take); + //rs_read_chars(inf, whoami, MAXSTR); + rs_read_sticks(inf); + rs_read_int(inf,&orig_dsusp); + rs_read_chars(inf, fruit, MAXSTR); + //rs_read_chars(inf, home, MAXSTR); + rs_read_new_strings(inf,inv_t_name,3); + rs_read_char(inf, &l_last_comm); + rs_read_char(inf, &l_last_dir); + rs_read_char(inf, &last_comm); + rs_read_char(inf, &last_dir); + rs_read_new_strings(inf,tr_name,8); + rs_read_int(inf, &n_objs); + rs_read_int(inf, &ntraps); + rs_read_int(inf, &hungry_state); + rs_read_int(inf, &inpack); + rs_read_int(inf, &inv_type); + rs_read_int(inf, &level); + rs_read_int(inf, &max_level); + rs_read_int(inf, &mpos); + rs_read_int(inf, &no_food); + rs_read_ints(inf,a_class,MAXARMORS); + rs_read_int(inf, &count); + rs_read_int(inf, &food_left); + rs_read_int(inf, &lastscore); + rs_read_int(inf, &no_command); + rs_read_int(inf, &no_move); + rs_read_int(inf, &purse); + rs_read_int(inf, &quiet); + rs_read_int(inf, &vf_hit); + //rs_read_int(inf, &dnum); + int32_t lownum,highnum; + rs_read_int(inf, &lownum); + rs_read_int(inf, &highnum); + seed = ((uint64_t)highnum<<32) | (lownum&0xffffffff); + rs_read_ints(inf,e_levels,21); + rs_read_coord(inf, &delta); + rs_read_coord(inf, &oldpos); + rs_read_coord(inf, &stairs); + + rs_read_thing(inf, &player); + rs_read_object_reference(inf, player.t_pack, &cur_armor); + rs_read_object_reference(inf, player.t_pack, &cur_ring[0]); + rs_read_object_reference(inf, player.t_pack, &cur_ring[1]); + rs_read_object_reference(inf, player.t_pack, &cur_weapon); + rs_read_object_reference(inf, player.t_pack, &l_last_pick); + rs_read_object_reference(inf, player.t_pack, &last_pick); + + rs_read_object_list(inf, &lvl_obj); + rs_read_thing_list(inf, &mlist); + rs_fix_thing(&player); + rs_fix_thing_list(mlist); + + rs_read_places(inf,places,MAXLINES*MAXCOLS); + + rs_read_stats(inf, &max_stats); + rs_read_rooms(inf, rooms, MAXROOMS); + rs_read_room_reference(inf, &oldrp); + rs_read_rooms(inf, passages, MAXPASS); + + rs_read_monsters(inf,monsters,26); + rs_read_obj_info(inf, things, NUMTHINGS); + rs_read_obj_info(inf, arm_info, MAXARMORS); + rs_read_obj_info(inf, pot_info, MAXPOTIONS); + rs_read_obj_info(inf, ring_info, MAXRINGS); + rs_read_obj_info(inf, scr_info, MAXSCROLLS); + rs_read_obj_info(inf, weap_info, MAXWEAPONS+1); + rs_read_obj_info(inf, ws_info, MAXSTICKS); + + rs_read_daemons(inf, d_list, 20); /* 5.4-daemon.c */ + rs_read_int(inf,&dummyint); /* total */ /* 5.4-list.c */ + rs_read_int(inf,&between); /* 5.4-daemons.c */ + rs_read_coord(inf, &nh); /* 5.4-move.c */ + rs_read_int(inf,&group); /* 5.4-weapons.c */ + + rs_read_window(inf,stdscr); + + return(READSTAT); +} diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c new file mode 100644 index 000000000..7b01fe34c --- /dev/null +++ b/src/cc/rogue/sticks.c @@ -0,0 +1,431 @@ +/* + * Functions to implement the various sticks one might find + * while wandering around the dungeon. + * + * @(#)sticks.c 4.39 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include "rogue.h" + +/* + * fix_stick: + * Set up a new stick + */ + +void +fix_stick(THING *cur) +{ + if (strcmp(ws_type[cur->o_which], "staff") == 0) + strncpy(cur->o_damage,"2x3",sizeof(cur->o_damage)); + else + strncpy(cur->o_damage,"1x1",sizeof(cur->o_damage)); + strncpy(cur->o_hurldmg,"1x1",sizeof(cur->o_hurldmg)); + + switch (cur->o_which) + { + case WS_LIGHT: + cur->o_charges = rnd(10) + 10; + otherwise: + cur->o_charges = rnd(5) + 3; + } +} + +/* + * do_zap: + * Perform a zap with a wand + */ + +void +do_zap(struct rogue_state *rs) +{ + THING *obj, *tp; + int y, x; + char *name; + char monster, oldch; + static THING bolt; + + if ((obj = get_item(rs,"zap with", STICK)) == NULL) + return; + if (obj->o_type != STICK) + { + after = FALSE; + msg(rs,"you can't zap with that!"); + return; + } + if (obj->o_charges == 0) + { + msg(rs,"nothing happens"); + return; + } + switch (obj->o_which) + { + case WS_LIGHT: + /* + * Reddy Kilowat wand. Light up the room + */ + ws_info[WS_LIGHT].oi_know = TRUE; + if (proom->r_flags & ISGONE) + msg(rs,"the corridor glows and then fades"); + else + { + proom->r_flags &= ~ISDARK; + /* + * Light the room and put the player back up + */ + enter_room(rs,&hero); + addmsg(rs,"the room is lit"); + if (!terse) + addmsg(rs," by a shimmering %s light", pick_color("blue")); + endmsg(rs); + } + when WS_DRAIN: + /* + * take away 1/2 of hero's hit points, then take it away + * evenly from the monsters in the room (or next to hero + * if he is in a passage) + */ + if (pstats.s_hpt < 2) + { + msg(rs,"you are too weak to use it"); + return; + } + else + drain(rs); + when WS_INVIS: + case WS_POLYMORPH: + case WS_TELAWAY: + case WS_TELTO: + case WS_CANCEL: + y = hero.y; + x = hero.x; + while (step_ok(winat(y, x))) + { + y += delta.y; + x += delta.x; + } + if ((tp = moat(y, x)) != NULL) + { + monster = tp->t_type; + if (monster == 'F') + player.t_flags &= ~ISHELD; + switch (obj->o_which) { + case WS_INVIS: + tp->t_flags |= ISINVIS; + if (cansee(rs,y, x)) + mvaddch(y, x, tp->t_oldch); + break; + case WS_POLYMORPH: + { + THING *pp; + + pp = tp->t_pack; + detach(mlist, tp); + if (see_monst(tp)) + mvaddch(y, x, chat(y, x)); + oldch = tp->t_oldch; + delta.y = y; + delta.x = x; + new_monster(rs,tp, monster = (char)(rnd(26) + 'A'), &delta); + if (see_monst(tp)) + mvaddch(y, x, monster); + tp->t_oldch = oldch; + tp->t_pack = pp; + ws_info[WS_POLYMORPH].oi_know |= see_monst(tp); + break; + } + case WS_CANCEL: + tp->t_flags |= ISCANC; + tp->t_flags &= ~(ISINVIS|CANHUH); + tp->t_disguise = tp->t_type; + if (see_monst(tp)) + mvaddch(y, x, tp->t_disguise); + break; + case WS_TELAWAY: + case WS_TELTO: + { + coord new_pos; + + if (obj->o_which == WS_TELAWAY) + { + do + { + find_floor(NULL, &new_pos, FALSE, TRUE); + } while (ce(new_pos, hero)); + } + else + { + new_pos.y = hero.y + delta.y; + new_pos.x = hero.x + delta.x; + } + tp->t_dest = &hero; + tp->t_flags |= ISRUN; + relocate(rs,tp, &new_pos); + } + } + } + when WS_MISSILE: + ws_info[WS_MISSILE].oi_know = TRUE; + bolt.o_type = '*'; + strncpy(bolt.o_hurldmg,"1x4",sizeof(bolt.o_hurldmg)); + bolt.o_hplus = 100; + bolt.o_dplus = 1; + bolt.o_flags = ISMISL; + if (cur_weapon != NULL) + bolt.o_launch = cur_weapon->o_which; + do_motion(rs,&bolt, delta.y, delta.x); + if ((tp = moat(bolt.o_pos.y, bolt.o_pos.x)) != NULL + && !save_throw(VS_MAGIC, tp)) + hit_monster(rs,unc(bolt.o_pos), &bolt); + else if (terse) + msg(rs,"missle vanishes"); + else + msg(rs,"the missle vanishes with a puff of smoke"); + when WS_HASTE_M: + case WS_SLOW_M: + y = hero.y; + x = hero.x; + while (step_ok(winat(y, x))) + { + y += delta.y; + x += delta.x; + } + if ((tp = moat(y, x)) != NULL) + { + if (obj->o_which == WS_HASTE_M) + { + if (on(*tp, ISSLOW)) + tp->t_flags &= ~ISSLOW; + else + tp->t_flags |= ISHASTE; + } + else + { + if (on(*tp, ISHASTE)) + tp->t_flags &= ~ISHASTE; + else + tp->t_flags |= ISSLOW; + tp->t_turn = TRUE; + } + delta.y = y; + delta.x = x; + runto(rs,&delta); + } + when WS_ELECT: + case WS_FIRE: + case WS_COLD: + if (obj->o_which == WS_ELECT) + name = "bolt"; + else if (obj->o_which == WS_FIRE) + name = "flame"; + else + name = "ice"; + fire_bolt(rs,&hero, &delta, name); + ws_info[obj->o_which].oi_know = TRUE; + when WS_NOP: + break; +#ifdef MASTER + otherwise: + msg(rs,"what a bizarre schtick!"); +#endif + } + obj->o_charges--; +} + +/* + * drain: + * Do drain hit points from player shtick + */ + +void +drain(struct rogue_state *rs) +{ + THING *mp; + struct room *corp; + THING **dp; + int cnt; + bool inpass; + static THING *drainee[40]; + + /* + * First cnt how many things we need to spread the hit points among + */ + cnt = 0; + if (chat(hero.y, hero.x) == DOOR) + corp = &passages[flat(hero.y, hero.x) & F_PNUM]; + else + corp = NULL; + inpass = (bool)(proom->r_flags & ISGONE); + dp = drainee; + for (mp = mlist; mp != NULL; mp = next(mp)) + if (mp->t_room == proom || mp->t_room == corp || + (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && + &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) + *dp++ = mp; + if ((cnt = (int)(dp - drainee)) == 0) + { + msg(rs,"you have a tingling feeling"); + return; + } + *dp = NULL; + pstats.s_hpt /= 2; + cnt = pstats.s_hpt / cnt; + /* + * Now zot all of the monsters + */ + for (dp = drainee; *dp; dp++) + { + mp = *dp; + if ((mp->t_stats.s_hpt -= cnt) <= 0) + killed(rs,mp, see_monst(mp)); + else + runto(rs,&mp->t_pos); + } +} + +/* + * fire_bolt: + * Fire a bolt in a given direction from a specific starting place + */ + +void +fire_bolt(struct rogue_state *rs,coord *start, coord *dir, char *name) +{ + coord *c1, *c2; + THING *tp; + char dirch = 0, ch; + bool hit_hero, used, changed; + static coord pos; + static coord spotpos[BOLT_LENGTH]; + THING bolt; + + bolt.o_type = WEAPON; + bolt.o_which = FLAME; + strncpy(bolt.o_hurldmg,"6x6",sizeof(bolt.o_hurldmg)); + bolt.o_hplus = 100; + bolt.o_dplus = 0; + weap_info[FLAME].oi_name = name; + switch (dir->y + dir->x) + { + case 0: dirch = '/'; + when 1: case -1: dirch = (dir->y == 0 ? '-' : '|'); + when 2: case -2: dirch = '\\'; + } + pos = *start; + hit_hero = (bool)(start != &hero); + used = FALSE; + changed = FALSE; + for (c1 = spotpos; c1 <= &spotpos[BOLT_LENGTH-1] && !used; c1++) + { + pos.y += dir->y; + pos.x += dir->x; + *c1 = pos; + ch = winat(pos.y, pos.x); + switch (ch) + { + case DOOR: + /* + * this code is necessary if the hero is on a door + * and he fires at the wall the door is in, it would + * otherwise loop infinitely + */ + if (ce(hero, pos)) + goto def; + /* FALLTHROUGH */ + case '|': + case '-': + case ' ': + if (!changed) + hit_hero = !hit_hero; + changed = FALSE; + dir->y = -dir->y; + dir->x = -dir->x; + c1--; + msg(rs,"the %s bounces", name); + break; + default: +def: + if (!hit_hero && (tp = moat(pos.y, pos.x)) != NULL) + { + hit_hero = TRUE; + changed = !changed; + tp->t_oldch = chat(pos.y, pos.x); + if (!save_throw(VS_MAGIC, tp)) + { + bolt.o_pos = pos; + used = TRUE; + if (tp->t_type == 'D' && strcmp(name, "flame") == 0) + { + addmsg(rs,"the flame bounces"); + if (!terse) + addmsg(rs," off the dragon"); + endmsg(rs); + } + else + hit_monster(rs,unc(pos), &bolt); + } + else if (ch != 'M' || tp->t_disguise == 'M') + { + if (start == &hero) + runto(rs,&pos); + if (terse) + msg(rs,"%s misses", name); + else + msg(rs,"the %s whizzes past %s", name, set_mname(tp)); + } + } + else if (hit_hero && ce(pos, hero)) + { + hit_hero = FALSE; + changed = !changed; + if (!save(VS_MAGIC)) + { + if ((pstats.s_hpt -= roll(6, 6)) <= 0) + { + if (start == &hero) + death('b'); + else + death(moat(start->y, start->x)->t_type); + } + used = TRUE; + if (terse) + msg(rs,"the %s hits", name); + else + msg(rs,"you are hit by the %s", name); + } + else + msg(rs,"the %s whizzes by you", name); + } + mvaddch(pos.y, pos.x, dirch); + refresh(); + } + } + for (c2 = spotpos; c2 < c1; c2++) + mvaddch(c2->y, c2->x, chat(c2->y, c2->x)); +} + +/* + * charge_str: + * Return an appropriate string for a wand charge + */ +char * +charge_str(THING *obj) +{ + static char buf[20]; + + if (!(obj->o_flags & ISKNOW)) + buf[0] = '\0'; + else if (terse) + sprintf(buf, " [%d]", obj->o_charges); + else + sprintf(buf, " [%d charges]", obj->o_charges); + return buf; +} diff --git a/src/cc/rogue/test.zip b/src/cc/rogue/test.zip new file mode 100644 index 0000000000000000000000000000000000000000..b0c54f6d0403f64cc535b2bc756a3d75da122cae GIT binary patch literal 5451 zcmZ{oRa6uVw}yup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8u91n9&otVJfL!`EzsPhqTa3=V z1jB$gSr2$Em|sLTiQCio(yZwvfCm7PPm3+E5wGLL^smQO$eKjHw8)%vR%`@C?h%7* z1^eylw1s+&ff>QFlQXYqcqV)Cd!jS#6hjI8`IgHCuX!0=D&*TWs0;~T5h&Ih^?1U_ zsxfeM@K=bI9f%~$=Z4WvVKNE8`dpk!)kMT_+v>g(6uj-#adHpu^}8P@+^1s%1OoXB z&Pmv3GNQaVUNR~OhTExyyh*^JTusk@i=_3+Bbo<#R&63S)2YL_NbLLWj_Twlv%;kq zp3uJVVZdsqg01Ct)4i9P`E%E2A=)aHz?8lb9J`9UeA$9Ut&6>h7wy2YwMcz-e&p}^ z_51iVT6O{joWSeKkiNRk4M2m{oWX`PM7w zCjLljv+tVj@!zzm)LRBUO$ +#include +#include +#include "rogue.h" + +/* + * inv_name: + * Return the name of something as it would appear in an + * inventory. + */ +char * +inv_name(THING *obj, bool drop) +{ + char *pb; + struct obj_info *op; + char *sp; + int which; + + pb = prbuf; + which = obj->o_which; + switch (obj->o_type) + { + case POTION: + nameit(obj, "potion", p_colors[which], &pot_info[which], nullstr); + when RING: + nameit(obj, "ring", r_stones[which], &ring_info[which], ring_num); + when STICK: + nameit(obj, ws_type[which], ws_made[which], &ws_info[which], charge_str); + when SCROLL: + if (obj->o_count == 1) + { + strcpy(pb, "A scroll "); + pb = &prbuf[9]; + } + else + { + sprintf(pb, "%d scrolls ", obj->o_count); + pb = &prbuf[strlen(prbuf)]; + } + op = &scr_info[which]; + if (op->oi_know) + sprintf(pb, "of %s", op->oi_name); + else if (op->oi_guess) + sprintf(pb, "called %s", op->oi_guess); + else + sprintf(pb, "titled '%s'", s_names[which]); + when FOOD: + if (which == 1) + if (obj->o_count == 1) + sprintf(pb, "A%s %s", vowelstr(fruit), fruit); + else + sprintf(pb, "%d %ss", obj->o_count, fruit); + else + if (obj->o_count == 1) + strcpy(pb, "Some food"); + else + sprintf(pb, "%d rations of food", obj->o_count); + when WEAPON: + sp = weap_info[which].oi_name; + if (obj->o_count > 1) + sprintf(pb, "%d ", obj->o_count); + else + sprintf(pb, "A%s ", vowelstr(sp)); + pb = &prbuf[strlen(prbuf)]; + if (obj->o_flags & ISKNOW) + sprintf(pb, "%s %s", num(obj->o_hplus,obj->o_dplus,WEAPON), sp); + else + sprintf(pb, "%s", sp); + if (obj->o_count > 1) + strcat(pb, "s"); + if (obj->o_label != NULL) + { + pb = &prbuf[strlen(prbuf)]; + sprintf(pb, " called %s", obj->o_label); + } + when ARMOR: + sp = arm_info[which].oi_name; + if (obj->o_flags & ISKNOW) + { + sprintf(pb, "%s %s [", + num(a_class[which] - obj->o_arm, 0, ARMOR), sp); + if (!terse) + strcat(pb, "protection "); + pb = &prbuf[strlen(prbuf)]; + sprintf(pb, "%d]", 10 - obj->o_arm); + } + else + sprintf(pb, "%s", sp); + if (obj->o_label != NULL) + { + pb = &prbuf[strlen(prbuf)]; + sprintf(pb, " called %s", obj->o_label); + } + when AMULET: + strcpy(pb, "The Amulet of Yendor"); + when GOLD: + sprintf(prbuf, "%d Gold pieces", obj->o_goldval); +#ifdef MASTER + otherwise: + debug("Picked up something funny %s", unctrl(obj->o_type)); + sprintf(pb, "Something bizarre %s", unctrl(obj->o_type)); +#endif + } + if (inv_describe) + { + if (obj == cur_armor) + strcat(pb, " (being worn)"); + if (obj == cur_weapon) + strcat(pb, " (weapon in hand)"); + if (obj == cur_ring[LEFT]) + strcat(pb, " (on left hand)"); + else if (obj == cur_ring[RIGHT]) + strcat(pb, " (on right hand)"); + } + if (drop && isupper(prbuf[0])) + prbuf[0] = (char) tolower(prbuf[0]); + else if (!drop && islower(*prbuf)) + *prbuf = (char) toupper(*prbuf); + prbuf[MAXSTR-1] = '\0'; + return prbuf; +} + +/* + * drop: + * Put something down + */ + +void +drop(struct rogue_state *rs) +{ + char ch; + THING *obj; + + ch = chat(hero.y, hero.x); + if (ch != FLOOR && ch != PASSAGE) + { + after = FALSE; + msg(rs,"there is something there already"); + return; + } + if ((obj = get_item(rs,"drop", 0)) == NULL) + return; + if (!dropcheck(rs,obj)) + return; + obj = leave_pack(rs,obj, TRUE, (bool)!ISMULT(obj->o_type)); + /* + * Link it into the level object list + */ + attach(lvl_obj, obj); + chat(hero.y, hero.x) = (char) obj->o_type; + flat(hero.y, hero.x) |= F_DROPPED; + obj->o_pos = hero; + if (obj->o_type == AMULET) + amulet = FALSE; + msg(rs,"dropped %s", inv_name(obj, TRUE)); +} + +/* + * dropcheck: + * Do special checks for dropping or unweilding|unwearing|unringing + */ +bool +dropcheck(struct rogue_state *rs,THING *obj) +{ + if (obj == NULL) + return TRUE; + if (obj != cur_armor && obj != cur_weapon + && obj != cur_ring[LEFT] && obj != cur_ring[RIGHT]) + return TRUE; + if (obj->o_flags & ISCURSED) + { + msg(rs,"you can't. It appears to be cursed"); + return FALSE; + } + if (obj == cur_weapon) + cur_weapon = NULL; + else if (obj == cur_armor) + { + waste_time(rs); + cur_armor = NULL; + } + else + { + cur_ring[obj == cur_ring[LEFT] ? LEFT : RIGHT] = NULL; + switch (obj->o_which) + { + case R_ADDSTR: + chg_str(-obj->o_arm); + break; + case R_SEEINVIS: + unsee(rs,0); + extinguish(unsee); + break; + } + } + return TRUE; +} + +/* + * new_thing: + * Return a new thing + */ +THING * +new_thing(struct rogue_state *rs) +{ + THING *cur; + int r; + + cur = new_item(); + cur->o_hplus = 0; + cur->o_dplus = 0; + strncpy(cur->o_damage, "0x0", sizeof(cur->o_damage)); + strncpy(cur->o_hurldmg, "0x0", sizeof(cur->o_hurldmg)); + cur->o_arm = 11; + cur->o_count = 1; + cur->o_group = 0; + cur->o_flags = 0; + /* + * Decide what kind of object it will be + * If we haven't had food for a while, let it be food. + */ + switch (no_food > 3 ? 2 : pick_one(rs,things, NUMTHINGS)) + { + case 0: + cur->o_type = POTION; + cur->o_which = pick_one(rs,pot_info, MAXPOTIONS); + when 1: + cur->o_type = SCROLL; + cur->o_which = pick_one(rs,scr_info, MAXSCROLLS); + when 2: + cur->o_type = FOOD; + no_food = 0; + if (rnd(10) != 0) + cur->o_which = 0; + else + cur->o_which = 1; + when 3: + init_weapon(cur, pick_one(rs,weap_info, MAXWEAPONS)); + if ((r = rnd(100)) < 10) + { + cur->o_flags |= ISCURSED; + cur->o_hplus -= rnd(3) + 1; + } + else if (r < 15) + cur->o_hplus += rnd(3) + 1; + when 4: + cur->o_type = ARMOR; + cur->o_which = pick_one(rs,arm_info, MAXARMORS); + cur->o_arm = a_class[cur->o_which]; + if ((r = rnd(100)) < 20) + { + cur->o_flags |= ISCURSED; + cur->o_arm += rnd(3) + 1; + } + else if (r < 28) + cur->o_arm -= rnd(3) + 1; + when 5: + cur->o_type = RING; + cur->o_which = pick_one(rs,ring_info, MAXRINGS); + switch (cur->o_which) + { + case R_ADDSTR: + case R_PROTECT: + case R_ADDHIT: + case R_ADDDAM: + if ((cur->o_arm = rnd(3)) == 0) + { + cur->o_arm = -1; + cur->o_flags |= ISCURSED; + } + when R_AGGR: + case R_TELEPORT: + cur->o_flags |= ISCURSED; + } + when 6: + cur->o_type = STICK; + cur->o_which = pick_one(rs,ws_info, MAXSTICKS); + fix_stick(cur); +#ifdef MASTER + otherwise: + debug("Picked a bad kind of object"); + wait_for(rs,' '); +#endif + } + return cur; +} + +/* + * pick_one: + * Pick an item out of a list of nitems possible objects + */ +int +pick_one(struct rogue_state *rs,struct obj_info *info, int nitems) +{ + struct obj_info *end; + struct obj_info *start; + int i; + + start = info; + for (end = &info[nitems], i = rnd(100); info < end; info++) + if (i < info->oi_prob) + break; + if (info == end) + { +#ifdef MASTER + if (wizard) + { + msg(rs,"bad pick_one: %d from %d items", i, nitems); + for (info = start; info < end; info++) + msg(rs,"%s: %d%%", info->oi_name, info->oi_prob); + } +#endif + info = start; + } + return (int)(info - start); +} + +/* + * discovered: + * list what the player has discovered in this game of a certain type + */ +static int line_cnt = 0; + +static bool newpage = FALSE; + +static char *lastfmt, *lastarg; + + +void +discovered(struct rogue_state *rs) +{ + char ch; + bool disc_list; + + do { + disc_list = FALSE; + if (!terse) + addmsg(rs,"for "); + addmsg(rs,"what type"); + if (!terse) + addmsg(rs," of object do you want a list"); + msg(rs,"? (* for all)"); + ch = readchar(rs); + switch (ch) + { + case ESCAPE: + msg(rs,""); + return; + case POTION: + case SCROLL: + case RING: + case STICK: + case '*': + disc_list = TRUE; + break; + default: + if (terse) + msg(rs,"Not a type"); + else + msg(rs,"Please type one of %c%c%c%c (ESCAPE to quit)", POTION, SCROLL, RING, STICK); + } + } while (!disc_list); + if (ch == '*') + { + print_disc(rs,POTION); + add_line(rs,"", NULL); + print_disc(rs,SCROLL); + add_line(rs,"", NULL); + print_disc(rs,RING); + add_line(rs,"", NULL); + print_disc(rs,STICK); + end_line(rs); + } + else + { + print_disc(rs,ch); + end_line(rs); + } +} + +/* + * print_disc: + * Print what we've discovered of type 'type' + */ + +#define MAX4(a,b,c,d) (a > b ? (a > c ? (a > d ? a : d) : (c > d ? c : d)) : (b > c ? (b > d ? b : d) : (c > d ? c : d))) + + +void +print_disc(struct rogue_state *rs,char type) +{ + struct obj_info *info = NULL; + int i, maxnum = 0, num_found; + static THING obj; + static int order[MAX4(MAXSCROLLS, MAXPOTIONS, MAXRINGS, MAXSTICKS)]; + + switch (type) + { + case SCROLL: + maxnum = MAXSCROLLS; + info = scr_info; + break; + case POTION: + maxnum = MAXPOTIONS; + info = pot_info; + break; + case RING: + maxnum = MAXRINGS; + info = ring_info; + break; + case STICK: + maxnum = MAXSTICKS; + info = ws_info; + break; + } + set_order(order, maxnum); + obj.o_count = 1; + obj.o_flags = 0; + num_found = 0; + for (i = 0; i < maxnum; i++) + if (info[order[i]].oi_know || info[order[i]].oi_guess) + { + obj.o_type = type; + obj.o_which = order[i]; + add_line(rs,"%s", inv_name(&obj, FALSE)); + num_found++; + } + if (num_found == 0) + add_line(rs,nothing(type), NULL); +} + +/* + * set_order: + * Set up order for list + */ + +void +set_order(int *order, int numthings) +{ + int i, r, t; + + for (i = 0; i< numthings; i++) + order[i] = i; + + for (i = numthings; i > 0; i--) + { + r = rnd(i); + t = order[i - 1]; + order[i - 1] = order[r]; + order[r] = t; + } +} + +/* + * add_line: + * Add a line to the list of discoveries + */ +/* VARARGS1 */ +char +add_line(struct rogue_state *rs,char *fmt, char *arg) +{ + WINDOW *tw, *sw; + int x, y; + char *prompt = "--Press space to continue--"; + static int maxlen = -1; + + if (line_cnt == 0) + { + wclear(hw); + if (inv_type == INV_SLOW) + mpos = 0; + } + if (inv_type == INV_SLOW) + { + if (*fmt != '\0') + if (msg(rs,fmt, arg) == ESCAPE) + return ESCAPE; + line_cnt++; + } + else + { + if (maxlen < 0) + maxlen = (int) strlen(prompt); + if (line_cnt >= LINES - 1 || fmt == NULL) + { + if (inv_type == INV_OVER && fmt == NULL && !newpage) + { + msg(rs,""); + refresh(); + tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); + sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); + for (y = 0; y <= line_cnt; y++) + { + wmove(sw, y, 0); + for (x = 0; x <= maxlen; x++) + waddch(sw, mvwinch(hw, y, x)); + } + wmove(tw, line_cnt, 1); + waddstr(tw, prompt); + /* + * if there are lines below, use 'em + */ + if (LINES > NUMLINES) + { + if (NUMLINES + line_cnt > LINES) + mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); + else + mvwin(tw, NUMLINES, 0); + } + touchwin(tw); + wrefresh(tw); + wait_for(rs,' '); + if (md_hasclreol()) + { + werase(tw); + leaveok(tw, TRUE); + wrefresh(tw); + } + delwin(tw); + touchwin(stdscr); + } + else + { + wmove(hw, LINES - 1, 0); + waddstr(hw, prompt); + wrefresh(hw); + wait_for(rs,' '); + clearok(curscr, TRUE); + wclear(hw); + touchwin(stdscr); + } + newpage = TRUE; + line_cnt = 0; + maxlen = (int) strlen(prompt); + } + if (fmt != NULL && !(line_cnt == 0 && *fmt == '\0')) + { + mvwprintw(hw, line_cnt++, 0, fmt, arg); + getyx(hw, y, x); + if (maxlen < x) + maxlen = x; + lastfmt = fmt; + lastarg = arg; + } + } + return ~ESCAPE; +} + +/* + * end_line: + * End the list of lines + */ + +void +end_line(struct rogue_state *rs) +{ + if (inv_type != INV_SLOW) + { + if (line_cnt == 1 && !newpage) + { + mpos = 0; + msg(rs,lastfmt, lastarg); + } + else + add_line(rs,(char *) NULL, NULL); + } + line_cnt = 0; + newpage = FALSE; +} + +/* + * nothing: + * Set up prbuf so that message for "nothing found" is there + */ +char * +nothing(char type) +{ + char *sp, *tystr = NULL; + + if (terse) + sprintf(prbuf, "Nothing"); + else + sprintf(prbuf, "Haven't discovered anything"); + if (type != '*') + { + sp = &prbuf[strlen(prbuf)]; + switch (type) + { + case POTION: tystr = "potion"; + when SCROLL: tystr = "scroll"; + when RING: tystr = "ring"; + when STICK: tystr = "stick"; + } + sprintf(sp, " about any %ss", tystr); + } + return prbuf; +} + +/* + * nameit: + * Give the proper name to a potion, stick, or ring + */ + +void +nameit(THING *obj, char *type, char *which, struct obj_info *op, + char *(*prfunc)(THING *)) +{ + char *pb; + + if (op->oi_know || op->oi_guess) + { + if (obj->o_count == 1) + sprintf(prbuf, "A %s ", type); + else + sprintf(prbuf, "%d %ss ", obj->o_count, type); + pb = &prbuf[strlen(prbuf)]; + if (op->oi_know) + sprintf(pb, "of %s%s(%s)", op->oi_name, (*prfunc)(obj), which); + else if (op->oi_guess) + sprintf(pb, "called %s%s(%s)", op->oi_guess, (*prfunc)(obj), which); + } + else if (obj->o_count == 1) + sprintf(prbuf, "A%s %s %s", vowelstr(which), which, type); + else + sprintf(prbuf, "%d %s %ss", obj->o_count, which, type); +} + +/* + * nullstr: + * Return a pointer to a null-length string + */ +char * +nullstr(THING *ignored) +{ + NOOP(ignored); + return ""; +} + +# ifdef MASTER +/* + * pr_list: + * List possible potions, scrolls, etc. for wizard. + */ + +void +pr_list(struct rogue_state *rs) +{ + int ch; + + if (!terse) + addmsg(rs,"for "); + addmsg(rs,"what type"); + if (!terse) + addmsg(rs," of object do you want a list"); + msg(rs,"? "); + ch = readchar(rs); + switch (ch) + { + case POTION: + pr_spec(pot_info, MAXPOTIONS); + when SCROLL: + pr_spec(scr_info, MAXSCROLLS); + when RING: + pr_spec(ring_info, MAXRINGS); + when STICK: + pr_spec(ws_info, MAXSTICKS); + when ARMOR: + pr_spec(arm_info, MAXARMORS); + when WEAPON: + pr_spec(weap_info, MAXWEAPONS); + otherwise: + return; + } +} + +/* + * pr_spec: + * Print specific list of possible items to choose from + */ + +void +pr_spec(struct rogue_state *rs,struct obj_info *info, int nitems) +{ + struct obj_info *endp; + int i, lastprob; + + endp = &info[nitems]; + lastprob = 0; + for (i = '0'; info < endp; i++) + { + if (i == '9' + 1) + i = 'a'; + sprintf(prbuf, "%c: %%s (%d%%%%)", i, info->oi_prob - lastprob); + lastprob = info->oi_prob; + add_line(rs,prbuf, info->oi_name); + info++; + } + end_line(rs); +} +# endif /* MASTER */ diff --git a/src/cc/rogue/vers.c b/src/cc/rogue/vers.c new file mode 100644 index 000000000..dcca986b1 --- /dev/null +++ b/src/cc/rogue/vers.c @@ -0,0 +1,17 @@ +/* + * Version number. Whenever a new version number is desired, use sccs + * to get vers.c. encstr is declared here to force it to be loaded + * before the version number, and therefore not to be written in saved + * games. + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +char *release = "5.4.4"; +char encstr[] = "\300k||`\251Y.'\305\321\201+\277~r\"]\240_\223=1\341)\222\212\241t;\t$\270\314/<#\201\254"; +char statlist[] = "\355kl{+\204\255\313idJ\361\214=4:\311\271\341wK<\312\321\213,,7\271/Rk%\b\312\f\246"; +char version[] = "rogue (rogueforge) 09/05/07"; diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c new file mode 100644 index 000000000..51a4b7730 --- /dev/null +++ b/src/cc/rogue/weapons.c @@ -0,0 +1,288 @@ +/* + * Functions for dealing with problems brought about by weapons + * + * @(#)weapons.c 4.34 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include "rogue.h" + +#define NO_WEAPON -1 + +int group = 2; + +static struct init_weaps { + char *iw_dam; /* Damage when wielded */ + char *iw_hrl; /* Damage when thrown */ + char iw_launch; /* Launching weapon */ + int iw_flags; /* Miscellaneous flags */ +} init_dam[MAXWEAPONS] = { + { "2x4", "1x3", NO_WEAPON, 0, }, /* Mace */ + { "3x4", "1x2", NO_WEAPON, 0, }, /* Long sword */ + { "1x1", "1x1", NO_WEAPON, 0, }, /* Bow */ + { "1x1", "2x3", BOW, ISMANY|ISMISL, }, /* Arrow */ + { "1x6", "1x4", NO_WEAPON, ISMISL|ISMISL, }, /* Dagger */ + { "4x4", "1x2", NO_WEAPON, 0, }, /* 2h sword */ + { "1x1", "1x3", NO_WEAPON, ISMANY|ISMISL, }, /* Dart */ + { "1x2", "2x4", NO_WEAPON, ISMANY|ISMISL, }, /* Shuriken */ + { "2x3", "1x6", NO_WEAPON, ISMISL, }, /* Spear */ +}; + +/* + * missile: + * Fire a missile in a given direction + */ + +void +missile(struct rogue_state *rs,int ydelta, int xdelta) +{ + THING *obj; + + /* + * Get which thing we are hurling + */ + if ((obj = get_item(rs,"throw", WEAPON)) == NULL) + return; + if (!dropcheck(rs,obj) || is_current(rs,obj)) + return; + obj = leave_pack(rs,obj, TRUE, FALSE); + do_motion(rs,obj, ydelta, xdelta); + /* + * AHA! Here it has hit something. If it is a wall or a door, + * or if it misses (combat) the monster, put it on the floor + */ + if (moat(obj->o_pos.y, obj->o_pos.x) == NULL || + !hit_monster(rs,unc(obj->o_pos), obj)) + fall(rs,obj, TRUE); +} + +/* + * do_motion: + * Do the actual motion on the screen done by an object traveling + * across the room + */ + +void +do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta) +{ + int ch; + + /* + * Come fly with us ... + */ + obj->o_pos = hero; + for (;;) + { + /* + * Erase the old one + */ + if (!ce(obj->o_pos, hero) && cansee(rs,unc(obj->o_pos)) && !terse) + { + ch = chat(obj->o_pos.y, obj->o_pos.x); + if (ch == FLOOR && !show_floor()) + ch = ' '; + mvaddch(obj->o_pos.y, obj->o_pos.x, ch); + } + /* + * Get the new position + */ + obj->o_pos.y += ydelta; + obj->o_pos.x += xdelta; + if (step_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR) + { + /* + * It hasn't hit anything yet, so display it + * If it alright. + */ + if (cansee(rs,unc(obj->o_pos)) && !terse) + { + mvaddch(obj->o_pos.y, obj->o_pos.x, obj->o_type); + refresh(); + } + continue; + } + break; + } +} + +/* + * fall: + * Drop an item someplace around here. + */ + +void +fall(struct rogue_state *rs,THING *obj, bool pr) +{ + PLACE *pp; + static coord fpos; + + if (fallpos(&obj->o_pos, &fpos)) + { + pp = INDEX(fpos.y, fpos.x); + pp->p_ch = (char) obj->o_type; + obj->o_pos = fpos; + if (cansee(rs,fpos.y, fpos.x)) + { + if (pp->p_monst != NULL) + pp->p_monst->t_oldch = (char) obj->o_type; + else + mvaddch(fpos.y, fpos.x, obj->o_type); + } + attach(lvl_obj, obj); + return; + } + if (pr) + { + if (has_hit) + { + endmsg(rs); + has_hit = FALSE; + } + msg(rs,"the %s vanishes as it hits the ground", + weap_info[obj->o_which].oi_name); + } + discard(obj); +} + +/* + * init_weapon: + * Set up the initial goodies for a weapon + */ + +void +init_weapon(THING *weap, int which) +{ + struct init_weaps *iwp; + + weap->o_type = WEAPON; + weap->o_which = which; + iwp = &init_dam[which]; + strncpy(weap->o_damage, iwp->iw_dam, sizeof(weap->o_damage)); + strncpy(weap->o_hurldmg,iwp->iw_hrl, sizeof(weap->o_hurldmg)); + weap->o_launch = iwp->iw_launch; + weap->o_flags = iwp->iw_flags; + weap->o_hplus = 0; + weap->o_dplus = 0; + if (which == DAGGER) + { + weap->o_count = rnd(4) + 2; + weap->o_group = group++; + } + else if (weap->o_flags & ISMANY) + { + weap->o_count = rnd(8) + 8; + weap->o_group = group++; + } + else + { + weap->o_count = 1; + weap->o_group = 0; + } +} + +/* + * hit_monster: + * Does the missile hit the monster? + */ +int +hit_monster(struct rogue_state *rs,int y, int x, THING *obj) +{ + static coord mp; + + mp.y = y; + mp.x = x; + return fight(rs,&mp, obj, TRUE); +} + +/* + * num: + * Figure out the plus number for armor/weapons + */ +char * +num(int n1, int n2, char type) +{ + static char numbuf[10]; + + sprintf(numbuf, n1 < 0 ? "%d" : "+%d", n1); + if (type == WEAPON) + sprintf(&numbuf[strlen(numbuf)], n2 < 0 ? ",%d" : ",+%d", n2); + return numbuf; +} + +/* + * wield: + * Pull out a certain weapon + */ + +void +wield(struct rogue_state *rs) +{ + THING *obj, *oweapon; + char *sp; + + oweapon = cur_weapon; + if (!dropcheck(rs,cur_weapon)) + { + cur_weapon = oweapon; + return; + } + cur_weapon = oweapon; + if ((obj = get_item(rs,"wield", WEAPON)) == NULL) + { +bad: + after = FALSE; + return; + } + + if (obj->o_type == ARMOR) + { + msg(rs,"you can't wield armor"); + goto bad; + } + if (is_current(rs,obj)) + goto bad; + + sp = inv_name(obj, TRUE); + cur_weapon = obj; + if (!terse) + addmsg(rs,"you are now "); + msg(rs,"wielding %s (%c)", sp, obj->o_packch); +} + +/* + * fallpos: + * Pick a random position around the give (y, x) coordinates + */ +bool +fallpos(coord *pos, coord *newpos) +{ + int y, x, cnt, ch; + + cnt = 0; + for (y = pos->y - 1; y <= pos->y + 1; y++) + for (x = pos->x - 1; x <= pos->x + 1; x++) + { + /* + * check to make certain the spot is empty, if it is, + * put the object there, set it in the level list + * and re-draw the room if he can see it + */ + if (y == hero.y && x == hero.x) + continue; + if (((ch = chat(y, x)) == FLOOR || ch == PASSAGE) + && rnd(++cnt) == 0) + { + newpos->y = y; + newpos->x = x; + } + } + return (bool)(cnt != 0); +} diff --git a/src/cc/rogue/wizard.c b/src/cc/rogue/wizard.c new file mode 100644 index 000000000..e56928d33 --- /dev/null +++ b/src/cc/rogue/wizard.c @@ -0,0 +1,284 @@ +/* + * Special wizard commands (some of which are also non-wizard commands + * under strange circumstances) + * + * @(#)wizard.c 4.30 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include +#include +#include +#include +#include "rogue.h" + +/* + * whatis: + * What a certin object is + */ + +void +whatis(struct rogue_state *rs,bool insist, int type) +{ + THING *obj; + + if (pack == NULL) + { + msg(rs,"you don't have anything in your pack to identify"); + return; + } + + for (;;) + { + obj = get_item(rs,"identify", type); + if (insist) + { + if (n_objs == 0) + return; + else if (obj == NULL) + msg(rs,"you must identify something"); + else if (type && obj->o_type != type && + !(type == R_OR_S && (obj->o_type == RING || obj->o_type == STICK)) ) + msg(rs,"you must identify a %s", type_name(type)); + else + break; + } + else + break; + } + + if (obj == NULL) + return; + + switch (obj->o_type) + { + case SCROLL: + set_know(obj, scr_info); + when POTION: + set_know(obj, pot_info); + when STICK: + set_know(obj, ws_info); + when WEAPON: + case ARMOR: + obj->o_flags |= ISKNOW; + when RING: + set_know(obj, ring_info); + } + msg(rs,inv_name(obj, FALSE)); +} + +/* + * set_know: + * Set things up when we really know what a thing is + */ + +void +set_know(THING *obj, struct obj_info *info) +{ + char **guess; + + info[obj->o_which].oi_know = TRUE; + obj->o_flags |= ISKNOW; + guess = &info[obj->o_which].oi_guess; + if (*guess) + { + free(*guess); + *guess = NULL; + } +} + +/* + * type_name: + * Return a pointer to the name of the type + */ +char * +type_name(int type) +{ + struct h_list *hp; + static struct h_list tlist[] = { + {POTION, "potion", FALSE}, + {SCROLL, "scroll", FALSE}, + {FOOD, "food", FALSE}, + {R_OR_S, "ring, wand or staff", FALSE}, + {RING, "ring", FALSE}, + {STICK, "wand or staff", FALSE}, + {WEAPON, "weapon", FALSE}, + {ARMOR, "suit of armor", FALSE}, + }; + + for (hp = tlist; hp->h_ch; hp++) + if (type == hp->h_ch) + return hp->h_desc; + /* NOTREACHED */ + return(0); +} + +#ifdef MASTER +/* + * create_obj: + * wizard command for getting anything he wants + */ + +void +create_obj(struct rogue_state *rs) +{ + THING *obj; + char ch, bless; + + obj = new_item(); + msg(rs,"type of item: "); + obj->o_type = readchar(rs); + mpos = 0; + msg(rs,"which %c do you want? (0-f)", obj->o_type); + obj->o_which = (isdigit((ch = readchar(rs))) ? ch - '0' : ch - 'a' + 10); + obj->o_group = 0; + obj->o_count = 1; + mpos = 0; + if (obj->o_type == WEAPON || obj->o_type == ARMOR) + { + msg(rs,"blessing? (+,-,n)"); + bless = readchar(rs); + mpos = 0; + if (bless == '-') + obj->o_flags |= ISCURSED; + if (obj->o_type == WEAPON) + { + init_weapon(obj, obj->o_which); + if (bless == '-') + obj->o_hplus -= rnd(3)+1; + if (bless == '+') + obj->o_hplus += rnd(3)+1; + } + else + { + obj->o_arm = a_class[obj->o_which]; + if (bless == '-') + obj->o_arm += rnd(3)+1; + if (bless == '+') + obj->o_arm -= rnd(3)+1; + } + } + else if (obj->o_type == RING) + switch (obj->o_which) + { + case R_PROTECT: + case R_ADDSTR: + case R_ADDHIT: + case R_ADDDAM: + msg(rs,"blessing? (+,-,n)"); + bless = readchar(rs); + mpos = 0; + if (bless == '-') + obj->o_flags |= ISCURSED; + obj->o_arm = (bless == '-' ? -1 : rnd(2) + 1); + when R_AGGR: + case R_TELEPORT: + obj->o_flags |= ISCURSED; + } + else if (obj->o_type == STICK) + fix_stick(obj); + else if (obj->o_type == GOLD) + { + msg(rs,"how much?"); + get_num(&obj->o_goldval, stdscr); + } + add_pack(rs,obj, FALSE); +} +#endif + +/* + * telport: + * Bamf the hero someplace else + */ + +void +teleport(struct rogue_state *rs) +{ + static coord c; + + mvaddch(hero.y, hero.x, floor_at()); + find_floor((struct room *) NULL, &c, FALSE, TRUE); + if (roomin(rs,&c) != proom) + { + leave_room(rs,&hero); + hero = c; + enter_room(rs,&hero); + } + else + { + hero = c; + look(rs,TRUE); + } + mvaddch(hero.y, hero.x, PLAYER); + /* + * turn off ISHELD in case teleportation was done while fighting + * a Flytrap + */ + if (on(player, ISHELD)) { + player.t_flags &= ~ISHELD; + vf_hit = 0; + strcpy(monsters['F'-'A'].m_stats.s_dmg, "000x0"); + } + no_move = 0; + count = 0; + running = FALSE; + flush_type(); +} + +#ifdef MASTER +/* + * passwd: + * See if user knows password + */ +int +passwd(struct rogue_state *rs) +{ + char *sp, c; + static char buf[MAXSTR]; + + msg(rs,"wizard's Password:"); + mpos = 0; + sp = buf; + while ((c = readchar(rs)) != '\n' && c != '\r' && c != ESCAPE) + if (c == md_killchar()) + sp = buf; + else if (c == md_erasechar() && sp > buf) + sp--; + else + *sp++ = c; + if (sp == buf) + return FALSE; + *sp = '\0'; + return (strcmp(PASSWD, md_crypt(buf, "mT")) == 0); +} + +/* + * show_map: + * Print out the map for the wizard + */ + +void +show_map(struct rogue_state *rs) +{ + int y, x, real; + + wclear(hw); + for (y = 1; y < NUMLINES - 1; y++) + for (x = 0; x < NUMCOLS; x++) + { + real = flat(y, x); + if (!(real & F_REAL)) + wstandout(hw); + wmove(hw, y, x); + waddch(hw, chat(y, x)); + if (!real) + wstandend(hw); + } + show_win(rs,"---More (level map)---"); +} +#endif diff --git a/src/cc/rogue/xcrypt.c b/src/cc/rogue/xcrypt.c new file mode 100644 index 000000000..bbf5d76ac --- /dev/null +++ b/src/cc/rogue/xcrypt.c @@ -0,0 +1,707 @@ +/* + * FreeSec: libcrypt + * + * Copyright (C) 1994 David Burren + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name(s) of the author(s) nor the names of other contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * This is an original implementation of the DES and the crypt(3) interfaces + * by David Burren . + * + * An excellent reference on the underlying algorithm (and related + * algorithms) is: + * + * B. Schneier, Applied Cryptography: protocols, algorithms, + * and source code in C, John Wiley & Sons, 1994. + * + * Note that in that book's description of DES the lookups for the initial, + * pbox, and final permutations are inverted (this has been brought to the + * attention of the author). A list of errata for this book has been + * posted to the sci.crypt newsgroup by the author and is available for FTP. + * + * NOTE: + * This file has a static version of des_setkey() so that crypt.o exports + * only the crypt() interface. This is required to make binaries linked + * against crypt.o exportable or re-exportable from the USA. + */ + +#include +#include + +unsigned int md_endian = 0x01020304; + +unsigned int +xntohl(unsigned int x) +{ + if ( *((char *)&md_endian) == 0x01 ) + return(x); + else + return( ((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24) ); +} + +unsigned +xhtonl(unsigned int x) +{ + if ( *((char *)&md_endian) == 0x01 ) + return(x); + else + return( ((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24) ); +} + +#define _PASSWORD_EFMT1 '_' + +static unsigned char IP[64] = { + 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, + 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, + 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, + 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 +}; + +static unsigned char inv_key_perm[64]; +static unsigned char key_perm[56] = { + 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, + 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, + 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, + 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 +}; + +static unsigned char key_shifts[16] = { + 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 +}; + +static unsigned char inv_comp_perm[56]; +static unsigned char comp_perm[48] = { + 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 +}; + +/* + * No E box is used, as it's replaced by some ANDs, shifts, and ORs. + */ + +static unsigned char u_sbox[8][64]; +static unsigned char sbox[8][64] = { + { + 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, + 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, + 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, + 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 + }, + { + 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, + 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, + 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, + 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 + }, + { + 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, + 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, + 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 + }, + { + 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, + 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, + 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, + 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 + }, + { + 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, + 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, + 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, + 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 + }, + { + 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, + 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, + 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, + 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 + }, + { + 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, + 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, + 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, + 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 + }, + { + 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, + 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, + 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, + 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 + } +}; + +static unsigned char un_pbox[32]; +static unsigned char pbox[32] = { + 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, + 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 +}; + +static unsigned int bits32[32] = +{ + 0x80000000, 0x40000000, 0x20000000, 0x10000000, + 0x08000000, 0x04000000, 0x02000000, 0x01000000, + 0x00800000, 0x00400000, 0x00200000, 0x00100000, + 0x00080000, 0x00040000, 0x00020000, 0x00010000, + 0x00008000, 0x00004000, 0x00002000, 0x00001000, + 0x00000800, 0x00000400, 0x00000200, 0x00000100, + 0x00000080, 0x00000040, 0x00000020, 0x00000010, + 0x00000008, 0x00000004, 0x00000002, 0x00000001 +}; + +static unsigned char bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + +static unsigned int saltbits; +static int old_salt; +static unsigned int *bits28, *bits24; +static unsigned char init_perm[64], final_perm[64]; +static unsigned int en_keysl[16], en_keysr[16]; +static unsigned int de_keysl[16], de_keysr[16]; +static int des_initialised = 0; +static unsigned char m_sbox[4][4096]; +static unsigned int psbox[4][256]; +static unsigned int ip_maskl[8][256], ip_maskr[8][256]; +static unsigned int fp_maskl[8][256], fp_maskr[8][256]; +static unsigned int key_perm_maskl[8][128], key_perm_maskr[8][128]; +static unsigned int comp_maskl[8][128], comp_maskr[8][128]; +static unsigned int old_rawkey0, old_rawkey1; + +static unsigned char ascii64[] = + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +/* 0000000000111111111122222222223333333333444444444455555555556666 */ +/* 0123456789012345678901234567890123456789012345678901234567890123 */ + +static __inline int +ascii_to_bin(char ch) +{ + if (ch > 'z') + return(0); + if (ch >= 'a') + return(ch - 'a' + 38); + if (ch > 'Z') + return(0); + if (ch >= 'A') + return(ch - 'A' + 12); + if (ch > '9') + return(0); + if (ch >= '.') + return(ch - '.'); + return(0); +} + +static void +des_init() +{ + int i, j, b, k, inbit, obit; + unsigned int *p, *il, *ir, *fl, *fr; + + old_rawkey0 = old_rawkey1 = 0; + saltbits = 0; + old_salt = 0; + bits24 = (bits28 = bits32 + 4) + 4; + + /* + * Invert the S-boxes, reordering the input bits. + */ + for (i = 0; i < 8; i++) + for (j = 0; j < 64; j++) { + b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf); + u_sbox[i][j] = sbox[i][b]; + } + + /* + * Convert the inverted S-boxes into 4 arrays of 8 bits. + * Each will handle 12 bits of the S-box input. + */ + for (b = 0; b < 4; b++) + for (i = 0; i < 64; i++) + for (j = 0; j < 64; j++) + m_sbox[b][(i << 6) | j] = + (u_sbox[(b << 1)][i] << 4) | + u_sbox[(b << 1) + 1][j]; + + /* + * Set up the initial & final permutations into a useful form, and + * initialise the inverted key permutation. + */ + for (i = 0; i < 64; i++) { + init_perm[final_perm[i] = IP[i] - 1] = (unsigned char) i; + inv_key_perm[i] = 255; + } + + /* + * Invert the key permutation and initialise the inverted key + * compression permutation. + */ + for (i = 0; i < 56; i++) { + inv_key_perm[key_perm[i] - 1] = (unsigned char) i; + inv_comp_perm[i] = 255; + } + + /* + * Invert the key compression permutation. + */ + for (i = 0; i < 48; i++) { + inv_comp_perm[comp_perm[i] - 1] = (unsigned char) i; + } + + /* + * Set up the OR-mask arrays for the initial and final permutations, + * and for the key initial and compression permutations. + */ + for (k = 0; k < 8; k++) { + for (i = 0; i < 256; i++) { + *(il = &ip_maskl[k][i]) = 0; + *(ir = &ip_maskr[k][i]) = 0; + *(fl = &fp_maskl[k][i]) = 0; + *(fr = &fp_maskr[k][i]) = 0; + for (j = 0; j < 8; j++) { + inbit = 8 * k + j; + if (i & bits8[j]) { + if ((obit = init_perm[inbit]) < 32) + *il |= bits32[obit]; + else + *ir |= bits32[obit-32]; + if ((obit = final_perm[inbit]) < 32) + *fl |= bits32[obit]; + else + *fr |= bits32[obit - 32]; + } + } + } + for (i = 0; i < 128; i++) { + *(il = &key_perm_maskl[k][i]) = 0; + *(ir = &key_perm_maskr[k][i]) = 0; + for (j = 0; j < 7; j++) { + inbit = 8 * k + j; + if (i & bits8[j + 1]) { + if ((obit = inv_key_perm[inbit]) == 255) + continue; + if (obit < 28) + *il |= bits28[obit]; + else + *ir |= bits28[obit - 28]; + } + } + *(il = &comp_maskl[k][i]) = 0; + *(ir = &comp_maskr[k][i]) = 0; + for (j = 0; j < 7; j++) { + inbit = 7 * k + j; + if (i & bits8[j + 1]) { + if ((obit=inv_comp_perm[inbit]) == 255) + continue; + if (obit < 24) + *il |= bits24[obit]; + else + *ir |= bits24[obit - 24]; + } + } + } + } + + /* + * Invert the P-box permutation, and convert into OR-masks for + * handling the output of the S-box arrays setup above. + */ + for (i = 0; i < 32; i++) + un_pbox[pbox[i] - 1] = (unsigned char) i; + + for (b = 0; b < 4; b++) + for (i = 0; i < 256; i++) { + *(p = &psbox[b][i]) = 0; + for (j = 0; j < 8; j++) { + if (i & bits8[j]) + *p |= bits32[un_pbox[8 * b + j]]; + } + } + + des_initialised = 1; +} + +static void +setup_salt(int salt) +{ + unsigned int obit, saltbit; + int i; + + if (salt == old_salt) + return; + old_salt = salt; + + saltbits = 0; + saltbit = 1; + obit = 0x800000; + for (i = 0; i < 24; i++) { + if (salt & saltbit) + saltbits |= obit; + saltbit <<= 1; + obit >>= 1; + } +} + +static int +des_setkey(const char *key) +{ + unsigned int k0, k1, rawkey0, rawkey1; + int shifts, round; + + if (!des_initialised) + des_init(); + + rawkey0 = xntohl(*(unsigned int *) key); + rawkey1 = xntohl(*(unsigned int *) (key + 4)); + + if ((rawkey0 | rawkey1) + && rawkey0 == old_rawkey0 + && rawkey1 == old_rawkey1) { + /* + * Already setup for this key. + * This optimisation fails on a zero key (which is weak and + * has bad parity anyway) in order to simplify the starting + * conditions. + */ + return(0); + } + old_rawkey0 = rawkey0; + old_rawkey1 = rawkey1; + + /* + * Do key permutation and split into two 28-bit subkeys. + */ + k0 = key_perm_maskl[0][rawkey0 >> 25] + | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f] + | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f] + | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f] + | key_perm_maskl[4][rawkey1 >> 25] + | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f] + | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f] + | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f]; + k1 = key_perm_maskr[0][rawkey0 >> 25] + | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f] + | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f] + | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f] + | key_perm_maskr[4][rawkey1 >> 25] + | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f] + | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f] + | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f]; + /* + * Rotate subkeys and do compression permutation. + */ + shifts = 0; + for (round = 0; round < 16; round++) { + unsigned int t0, t1; + + shifts += key_shifts[round]; + + t0 = (k0 << shifts) | (k0 >> (28 - shifts)); + t1 = (k1 << shifts) | (k1 >> (28 - shifts)); + + de_keysl[15 - round] = + en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f] + | comp_maskl[1][(t0 >> 14) & 0x7f] + | comp_maskl[2][(t0 >> 7) & 0x7f] + | comp_maskl[3][t0 & 0x7f] + | comp_maskl[4][(t1 >> 21) & 0x7f] + | comp_maskl[5][(t1 >> 14) & 0x7f] + | comp_maskl[6][(t1 >> 7) & 0x7f] + | comp_maskl[7][t1 & 0x7f]; + + de_keysr[15 - round] = + en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f] + | comp_maskr[1][(t0 >> 14) & 0x7f] + | comp_maskr[2][(t0 >> 7) & 0x7f] + | comp_maskr[3][t0 & 0x7f] + | comp_maskr[4][(t1 >> 21) & 0x7f] + | comp_maskr[5][(t1 >> 14) & 0x7f] + | comp_maskr[6][(t1 >> 7) & 0x7f] + | comp_maskr[7][t1 & 0x7f]; + } + return(0); +} + +static int +do_des(unsigned int l_in, unsigned int r_in, unsigned int *l_out, + unsigned int *r_out, int count) +{ + /* + * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. + */ + unsigned int l, r, *kl, *kr, *kl1, *kr1; + unsigned int f = 0, r48l, r48r; + int round; + + if (count == 0) { + return(1); + } else if (count > 0) { + /* + * Encrypting + */ + kl1 = en_keysl; + kr1 = en_keysr; + } else { + /* + * Decrypting + */ + count = -count; + kl1 = de_keysl; + kr1 = de_keysr; + } + + /* + * Do initial permutation (IP). + */ + l = ip_maskl[0][l_in >> 24] + | ip_maskl[1][(l_in >> 16) & 0xff] + | ip_maskl[2][(l_in >> 8) & 0xff] + | ip_maskl[3][l_in & 0xff] + | ip_maskl[4][r_in >> 24] + | ip_maskl[5][(r_in >> 16) & 0xff] + | ip_maskl[6][(r_in >> 8) & 0xff] + | ip_maskl[7][r_in & 0xff]; + r = ip_maskr[0][l_in >> 24] + | ip_maskr[1][(l_in >> 16) & 0xff] + | ip_maskr[2][(l_in >> 8) & 0xff] + | ip_maskr[3][l_in & 0xff] + | ip_maskr[4][r_in >> 24] + | ip_maskr[5][(r_in >> 16) & 0xff] + | ip_maskr[6][(r_in >> 8) & 0xff] + | ip_maskr[7][r_in & 0xff]; + + while (count--) { + /* + * Do each round. + */ + kl = kl1; + kr = kr1; + round = 16; + while (round--) { + /* + * Expand R to 48 bits (simulate the E-box). + */ + r48l = ((r & 0x00000001) << 23) + | ((r & 0xf8000000) >> 9) + | ((r & 0x1f800000) >> 11) + | ((r & 0x01f80000) >> 13) + | ((r & 0x001f8000) >> 15); + + r48r = ((r & 0x0001f800) << 7) + | ((r & 0x00001f80) << 5) + | ((r & 0x000001f8) << 3) + | ((r & 0x0000001f) << 1) + | ((r & 0x80000000) >> 31); + /* + * Do salting for crypt() and friends, and + * XOR with the permuted key. + */ + f = (r48l ^ r48r) & saltbits; + r48l ^= f ^ *kl++; + r48r ^= f ^ *kr++; + /* + * Do sbox lookups (which shrink it back to 32 bits) + * and do the pbox permutation at the same time. + */ + f = psbox[0][m_sbox[0][r48l >> 12]] + | psbox[1][m_sbox[1][r48l & 0xfff]] + | psbox[2][m_sbox[2][r48r >> 12]] + | psbox[3][m_sbox[3][r48r & 0xfff]]; + /* + * Now that we've permuted things, complete f(). + */ + f ^= l; + l = r; + r = f; + } + r = l; + l = f; + } + /* + * Do final permutation (inverse of IP). + */ + *l_out = fp_maskl[0][l >> 24] + | fp_maskl[1][(l >> 16) & 0xff] + | fp_maskl[2][(l >> 8) & 0xff] + | fp_maskl[3][l & 0xff] + | fp_maskl[4][r >> 24] + | fp_maskl[5][(r >> 16) & 0xff] + | fp_maskl[6][(r >> 8) & 0xff] + | fp_maskl[7][r & 0xff]; + *r_out = fp_maskr[0][l >> 24] + | fp_maskr[1][(l >> 16) & 0xff] + | fp_maskr[2][(l >> 8) & 0xff] + | fp_maskr[3][l & 0xff] + | fp_maskr[4][r >> 24] + | fp_maskr[5][(r >> 16) & 0xff] + | fp_maskr[6][(r >> 8) & 0xff] + | fp_maskr[7][r & 0xff]; + return(0); +} + +static int +des_cipher(const char *in, char *out, int salt, int count) +{ + unsigned int l_out, r_out, rawl, rawr; + unsigned int x[2]; + int retval; + + if (!des_initialised) + des_init(); + + setup_salt(salt); + + memcpy(x, in, sizeof x); + rawl = xntohl(x[0]); + rawr = xntohl(x[1]); + retval = do_des(rawl, rawr, &l_out, &r_out, count); + + x[0] = xhtonl(l_out); + x[1] = xhtonl(r_out); + memcpy(out, x, sizeof x); + return(retval); +} + +char * +xcrypt(const char *key, const char *setting) +{ + int i; + unsigned int count, salt, l, r0, r1, keybuf[2]; + unsigned char *p, *q; + static unsigned char output[21]; + + if (!des_initialised) + des_init(); + + /* + * Copy the key, shifting each character up by one bit + * and padding with zeros. + */ + q = (unsigned char *) keybuf; + while ((q - (unsigned char *) keybuf) < sizeof(keybuf)) { + if ((*q++ = *key << 1)) + key++; + } + if (des_setkey((const char *) keybuf)) + return(NULL); + + if (*setting == _PASSWORD_EFMT1) { + /* + * "new"-style: + * setting - underscore, 4 bytes of count, 4 bytes of salt + * key - unlimited characters + */ + for (i = 1, count = 0; i < 5; i++) + count |= ascii_to_bin(setting[i]) << (i - 1) * 6; + + for (i = 5, salt = 0; i < 9; i++) + salt |= ascii_to_bin(setting[i]) << (i - 5) * 6; + + while (*key) { + /* + * Encrypt the key with itself. + */ + if (des_cipher((const char*)keybuf, (char*)keybuf, 0, 1)) + return(NULL); + /* + * And XOR with the next 8 characters of the key. + */ + q = (unsigned char *) keybuf; + while (((q - (unsigned char *) keybuf) < sizeof(keybuf)) && + *key) + *q++ ^= *key++ << 1; + + if (des_setkey((const char *) keybuf)) + return(NULL); + } + strncpy((char *)output, setting, 9); + + /* + * Double check that we weren't given a short setting. + * If we were, the above code will probably have created + * wierd values for count and salt, but we don't really care. + * Just make sure the output string doesn't have an extra + * NUL in it. + */ + output[9] = '\0'; + p = output + strlen((const char *)output); + } else { + /* + * "old"-style: + * setting - 2 bytes of salt + * key - up to 8 characters + */ + count = 25; + + salt = (ascii_to_bin(setting[1]) << 6) + | ascii_to_bin(setting[0]); + + output[0] = setting[0]; + /* + * If the encrypted password that the salt was extracted from + * is only 1 character long, the salt will be corrupted. We + * need to ensure that the output string doesn't have an extra + * NUL in it! + */ + output[1] = setting[1] ? setting[1] : output[0]; + + p = output + 2; + } + setup_salt(salt); + /* + * Do it. + */ + if (do_des(0, 0, &r0, &r1, count)) + return(NULL); + /* + * Now encode the result... + */ + l = (r0 >> 8); + *p++ = ascii64[(l >> 18) & 0x3f]; + *p++ = ascii64[(l >> 12) & 0x3f]; + *p++ = ascii64[(l >> 6) & 0x3f]; + *p++ = ascii64[l & 0x3f]; + + l = (r0 << 16) | ((r1 >> 16) & 0xffff); + *p++ = ascii64[(l >> 18) & 0x3f]; + *p++ = ascii64[(l >> 12) & 0x3f]; + *p++ = ascii64[(l >> 6) & 0x3f]; + *p++ = ascii64[l & 0x3f]; + + l = r1 << 2; + *p++ = ascii64[(l >> 12) & 0x3f]; + *p++ = ascii64[(l >> 6) & 0x3f]; + *p++ = ascii64[l & 0x3f]; + *p = 0; + + return((char *)output); +} From 9b9bae114e2dae045b8402d7c93a7674b56d138c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:09:51 -1100 Subject: [PATCH 1683/3904] Configuration --- .gitignore | 4 +- src/cc/rogue/Makefile.in | 220 ++ src/cc/rogue/configure | 7511 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 7733 insertions(+), 2 deletions(-) create mode 100644 src/cc/rogue/Makefile.in create mode 100755 src/cc/rogue/configure diff --git a/.gitignore b/.gitignore index cd2641c22..47f490f20 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ src/test/test_bitcoin *zcashTest.vk # autoreconf -Makefile.in +#Makefile.in aclocal.m4 autom4te.cache/ build-aux/config.guess @@ -29,7 +29,7 @@ build-aux/compile build-aux/test-driver config.log config.status -configure +#configure libtool src/config/bitcoin-config.h src/config/bitcoin-config.h.in diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in new file mode 100644 index 000000000..c2f4e551a --- /dev/null +++ b/src/cc/rogue/Makefile.in @@ -0,0 +1,220 @@ +############################################################################### +# +# Makefile for rogue +# +# Rogue: Exploring the Dungeons of Doom +# Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman +# All rights reserved. +# +# See the file LICENSE.TXT for full copyright and licensing information. +# +############################################################################### + +############################################################################### +# Site configuration occurs beneath this comment +# Typically ./configure (autoconf tools) configures this section +# This section could be manually configured if autoconf/configure fails +############################################################################### + +DISTNAME=@PACKAGE_TARNAME@@PACKAGE_VERSION@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@-@PACKAGE_VERSION@ +PROGRAM=@PROGRAM@ + +O=o + +#CC=gcc +CC = @CC@ + +#CFLAGS=-O2 +CFLAGS= @CFLAGS@ -fPIC + +#LIBS=-lcurses +LIBS = @LIBS@ + +#RM=rm -f +RM = rm -f + +#GROFF=groff +GROFF = @GROFF@ + +#NROFF=nroff +NROFF = @NROFF@ + +#TBL=tbl +TBL = @TBL@ + +#COLCRT=colcrt +COLCRT = @COLCRT@ + +#SED=sed +SED = @SED@ + +#SCOREFILE=rogue54.scr +SCOREFILE = @SCOREFILE@ + +#LOCKFILE=rogue54.lck +LOCKFILE = @LOCKFILE@ + +#GROUPOWNER=games +GROUPOWNER = @GROUPOWNER@ + +#CPPFLAGS=-DHAVE_CONFIG_H +CPPFLAGS =@DEFS@ @CPPFLAGS@ + +#DISTFILE = $(PROGRAM) +DISTFILE = $(DISTNAME)-@TARGET@ + +INSTALL=./install-sh + +#INSTGROUP=-g games +INSTGROUP= +#INSTOWNER=-u root +INSTOWNER= + +CHGRP=chgrp + +MKDIR=mkdir + +TOUCH=touch + +RMDIR=rmdir + +CHMOD=chmod + +DESTDIR= + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +datarootdir=@datarootdir@ +datadir=@datadir@ +bindir=@bindir@ +mandir=@mandir@ +docdir=@docdir@ +man6dir = $(mandir)/man6 + +############################################################################### +# Site configuration occurs above this comment +# It should not be necessary to change anything below this comment +############################################################################### + +HDRS = rogue.h extern.h score.h +OBJS1 = vers.$(O) extern.$(O) armor.$(O) chase.$(O) command.$(O) \ + daemon.$(O) daemons.$(O) fight.$(O) init.$(O) io.$(O) list.$(O) \ + mach_dep.$(O) rogue.$(O) mdport.$(O) misc.$(O) monsters.$(O) \ + move.$(O) new_level.$(O) +OBJS2 = options.$(O) pack.$(O) passages.$(O) potions.$(O) rings.$(O) \ + rip.$(O) rooms.$(O) save.$(O) scrolls.$(O) state.$(O) sticks.$(O) \ + things.$(O) weapons.$(O) wizard.$(O) xcrypt.$(O) +OBJS = main.$(O) $(OBJS1) $(OBJS2) +CFILES = vers.c extern.c armor.c chase.c command.c daemon.c \ + daemons.c fight.c init.c io.c list.c mach_dep.c \ + main.c mdport.c misc.c monsters.c move.c new_level.c \ + options.c pack.c passages.c potions.c rings.c rip.c \ + rooms.c save.c scrolls.c state.c sticks.c things.c \ + weapons.c wizard.c xcrypt.c +MISC_C = findpw.c scedit.c scmisc.c +DOCSRC = rogue.me.in rogue.6.in rogue.doc.in rogue.html.in rogue.cat.in +DOCS = $(PROGRAM).doc $(PROGRAM).html $(PROGRAM).cat $(PROGRAM).me \ + $(PROGRAM).6 +AFILES = configure Makefile.in configure.ac config.h.in config.sub config.guess \ + install-sh rogue.6.in rogue.me.in rogue.html.in rogue.doc.in rogue.cat.in +MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ + rogue.png rogue.desktop + +.SUFFIXES: .obj + +.c.obj: + $(CC) $(CFLAGS) $(CPPFLAGS) /c $*.c + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c + +$(PROGRAM): $(HDRS) $(OBJS) + $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2) -lcurses; $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + +clean: + $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so + $(RM) $(OBJS2) + $(RM) core a.exe a.out a.exe.stackdump $(PROGRAM) $(PROGRAM).exe + $(RM) $(PROGRAM).tar $(PROGRAM).tar.gz $(PROGRAM).zip + $(RM) $(DISTNAME)/* + -rmdir $(DISTNAME) + +maintainer-clean: + $(RM) config.h + $(RM) Makefile + $(RM) config.status + $(RM) -r autom4te.cache + $(RM) config.log + $(RM) $(PROGRAM).scr $(PROGRAM).lck + +stddocs: + sed -e 's/@PROGRAM@/rogue/' -e 's/@SCOREFILE@/rogue.scr/' rogue.6.in > rogue.6 + sed -e 's/@PROGRAM@/rogue/' -e 's/@SCOREFILE@/rogue.scr/' rogue.me.in > rogue.me + sed -e 's/@PROGRAM@/rogue/' -e 's/@SCOREFILE@/rogue.scr/' rogue.html.in > rogue,html + sed -e 's/@PROGRAM@/rogue/' -e 's/@SCOREFILE@/rogue.scr/' rogue.doc.in > rogue.doc + sed -e 's/@PROGRAM@/rogue/' -e 's/@SCOREFILE@/rogue.scr/' rogue.cat.in > rogue.cat + +dist.src: + $(MAKE) $(MAKEFILE) clean + mkdir $(DISTNAME) + cp $(CFILES) $(HDRS) $(MISC) $(AFILES) $(DISTNAME) + tar cf $(DISTNAME)-src.tar $(DISTNAME) + gzip -f $(DISTNAME)-src.tar + rm -fr $(DISTNAME) + +findpw: findpw.c xcrypt.o mdport.o xcrypt.o + $(CC) -s -o findpw findpw.c xcrypt.o mdport.o -lcurses + +scedit: scedit.o scmisc.o vers.o mdport.o xcrypt.o + $(CC) -s -o scedit vers.o scedit.o scmisc.o mdport.o xcrypt.o -lcurses + +scmisc.o scedit.o: + $(CC) -O -c $(SF) $*.c + +$(PROGRAM).doc: rogue.me + if test "x$(GROFF)" != "x" -a "x$(SED)" != "x" ; then \ + $(GROFF) -P-c -t -me -Tascii rogue.me | $(SED) -e 's/.\x08//g' > $(PROGRAM).doc ;\ + elif test "x$(NROFF)" != "x" -a "x$(TBL)" != "x" -a "x$(COLCRT)" != "x" ; then \ + tbl rogue.me | $(NROFF) -me | colcrt - > $(PROGRAM).doc ;\ + fi + +$(PROGRAM).cat: rogue.6 + if test "x$(GROFF)" != "x" -a "x$(SED)" != "x" ; then \ + $(GROFF) -Tascii -man rogue.6 | $(SED) -e 's/.\x08//g' > $(PROGRAM).cat ;\ + elif test "x$(NROFF)" != "x" -a "x$(TBL)" != "x" -a "x$(COLCRT)" != "x" ; then \ + $(NROFF) -man rogue.6 | $(COLCRT) - > $(PROGRAM).cat ;\ + fi + +dist: clean $(PROGRAM) + tar cf $(DISTFILE).tar $(PROGRAM) LICENSE.TXT $(DOCS) + gzip -f $(DISTFILE).tar + +install: $(PROGRAM) + -$(TOUCH) test + -if test ! -f $(DESTDIR)$(SCOREFILE) ; then $(INSTALL) -m 0664 test $(DESTDIR)$(SCOREFILE) ; fi + -$(INSTALL) -m 0755 $(PROGRAM) $(DESTDIR)$(bindir)/$(PROGRAM) + -if test "x$(GROUPOWNER)" != "x" ; then \ + $(CHGRP) $(GROUPOWNER) $(DESTDIR)$(SCOREFILE) ; \ + $(CHGRP) $(GROUPOWNER) $(DESTDIR)$(bindir)/$(PROGRAM) ; \ + $(CHMOD) 02755 $(DESTDIR)$(bindir)/$(PROGRAM) ; \ + $(CHMOD) 0464 $(DESTDIR)$(SCOREFILE) ; \ + fi + -if test -d $(man6dir) ; then $(INSTALL) -m 0644 rogue.6 $(DESTDIR)$(man6dir)/$(PROGRAM).6 ; fi + -if test ! -d $(man6dir) ; then $(INSTALL) -m 0644 rogue.6 $(DESTDIR)$(mandir)/$(PROGRAM).6 ; fi + -$(INSTALL) -m 0644 rogue.doc $(DESTDIR)$(docdir)/$(PROGRAM).doc + -$(INSTALL) -m 0644 rogue.html $(DESTDIR)$(docdir)/$(PROGRAM).html + -$(INSTALL) -m 0644 rogue.cat $(DESTDIR)$(docdir)/$(PROGRAM).cat + -$(INSTALL) -m 0644 LICENSE.TXT $(DESTDIR)$(docdir)/LICENSE.TXT + -$(INSTALL) -m 0644 rogue.me $(DESTDIR)$(docdir)/$(PROGRAM).me + -if test ! -f $(DESTDIR)$(LOCKFILE) ; then $(INSTALL) -m 0666 test $(DESTDIR)$(LOCKFILE) ; $(RM) $(DESTDIR)$(LOCKFILE) ; fi + -$(RM) test + +uninstall: + -$(RM) $(DESTDIR)$(bindir)/$(PROGRAM) + -$(RM) $(DESTDIR)$(man6dir)/$(PROGRAM).6 + -$(RM) $(DESTDIR)$(docdir)$(PROGRAM)/$(PROGRAM).doc + -$(RM) $(DESTDIR)$(LOCKFILE) + -$(RMDIR) $(DESTDIR)$(docdir)$(PROGRAM) + +reinstall: uninstall install diff --git a/src/cc/rogue/configure b/src/cc/rogue/configure new file mode 100755 index 000000000..a7b95e78d --- /dev/null +++ b/src/cc/rogue/configure @@ -0,0 +1,7511 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61 for Rogue 5.4.4. +# +# Report bugs to . +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='Rogue' +PACKAGE_TARNAME='rogue' +PACKAGE_VERSION='5.4.4' +PACKAGE_STRING='Rogue 5.4.4' +PACKAGE_BUGREPORT='yendor@rogueforge.net' + +ac_unique_file="armor.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +build +build_cpu +build_vendor +build_os +host +host_cpu +host_vendor +host_os +target +target_cpu +target_vendor +target_os +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +CPP +GREP +EGREP +LIBOBJS +NROFF +GROFF +COLCRT +TBL +SED +PROGRAM +GROUPOWNER +SCOREFILE +LOCKFILE +TARGET +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures Rogue 5.4.4 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/rogue] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of Rogue 5.4.4:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-setgid=NAME install executable as setgid with group ownership of + NAME [default=no]] + --enable-scorefile=SCOREFILE + enable scoreboard with given filename + --enable-lockfile=LOCKFILE + enable scoreboard lockfile with given filename + --enable-wizardmode enable availability of wizard mode [default=no] + --enable-allscores enable scoreboard to show top scores, not just top + players [default=yes] + --enable-checktime enable checktime [default=no] + --enable-maxload enable maxload [default=no] + --enable-maxusers enable maxuser [default=no] + --enable-numscores number of scores to store in scoreboard [default=10] + --enable-numname word for number of scores to store in scoreboard + [default=Ten] + --enable-loadav=NAMELIST + use program's load average function (unlikely to + work) [default=no] + --enable-ucount=UTMPFILE + use program's own function to count users (unlikely + to work) [default=no] + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-ncurses Force the use of ncurses over curses + --with-program-name=NAME + alternate executable name + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +Rogue configure 5.4.4 +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by Rogue $as_me 5.4.4, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers config.h" + +ac_config_files="$ac_config_files Makefile rogue.6 rogue.cat rogue.doc rogue.html rogue.me" + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6; } +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +echo "$as_me: error: invalid value of canonical target" >&2;} + { (exit 1); exit 1; }; };; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Checks for libraries. + +# Checks for header files. + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + + + + + + + + + + +for ac_header in arpa/inet.h sys/utsname.h pwd.h fcntl.h limits.h nlist.h stdlib.h string.h sys/ioctl.h termios.h unistd.h utmp.h term.h ncurses/term.h process.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ------------------------------------ ## +## Report this to yendor@rogueforge.net ## +## ------------------------------------ ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +{ echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 +echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } +if test "${ac_cv_header_stdbool_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#ifndef bool + "error: bool is not defined" +#endif +#ifndef false + "error: false is not defined" +#endif +#if false + "error: false is not 0" +#endif +#ifndef true + "error: true is not defined" +#endif +#if true != 1 + "error: true is not 1" +#endif +#ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" +#endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + bool e = &s; + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; +# if defined __xlc__ || defined __GNUC__ + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a runtime + test, and that would make cross-compilation harder. + Let us hope that IBM fixes the xlc bug, and also adds + support for this kind of constant expression. In the + meantime, this test will reject xlc, which is OK, since + our stdbool.h substitute should suffice. We also test + this with GCC, where it should work, to detect more + quickly whether someone messes up the test in the + future. */ + char digs[] = "0123456789"; + int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); +# endif + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + +int +main () +{ + + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdbool_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdbool_h=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 +echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; } +{ echo "$as_me:$LINENO: checking for _Bool" >&5 +echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; } +if test "${ac_cv_type__Bool+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef _Bool ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type__Bool=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type__Bool=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 +echo "${ECHO_T}$ac_cv_type__Bool" >&6; } +if test $ac_cv_type__Bool = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + +if test $ac_cv_header_stdbool_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STDBOOL_H 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5 +echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6; } +if test "${ac_cv_type_uid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "uid_t" >/dev/null 2>&1; then + ac_cv_type_uid_t=yes +else + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 +echo "${ECHO_T}$ac_cv_type_uid_t" >&6; } +if test $ac_cv_type_uid_t = no; then + +cat >>confdefs.h <<\_ACEOF +#define uid_t int +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define gid_t int +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef size_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_size_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6; } +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 +echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6; } +if test "${ac_cv_struct_tm+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm tm; + int *p = &tm.tm_sec; + return !p; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_struct_tm=time.h +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_struct_tm=sys/time.h +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 +echo "${ECHO_T}$ac_cv_struct_tm" >&6; } +if test $ac_cv_struct_tm = sys/time.h; then + +cat >>confdefs.h <<\_ACEOF +#define TM_IN_SYS_TIME 1 +_ACEOF + +fi + + +# Check whether --with-ncurses was given. +if test "${with_ncurses+set}" = set; then + withval=$with_ncurses; +fi + + mp_save_LIBS="$LIBS" + CURSES_LIB="" + if test "$with_ncurses" != yes + then + { echo "$as_me:$LINENO: checking for working curses" >&5 +echo $ECHO_N "checking for working curses... $ECHO_C" >&6; } +if test "${mp_cv_curses+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + LIBS="$LIBS -lcurses" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + mp_cv_curses=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + mp_cv_curses=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $mp_cv_curses" >&5 +echo "${ECHO_T}$mp_cv_curses" >&6; } + if test "$mp_cv_curses" = yes + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CURSES_H 1 +_ACEOF + + #AC_DEFINE(HAVE_CURSES_H) + CURSES_LIB="-lcurses" + fi + fi + if test ! "$CURSES_LIB" + then + { echo "$as_me:$LINENO: checking for working ncurses" >&5 +echo $ECHO_N "checking for working ncurses... $ECHO_C" >&6; } +if test "${mp_cv_ncurses+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + LIBS="$mp_save_LIBS -lncurses" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + mp_cv_ncurses=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + mp_cv_ncurses=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $mp_cv_ncurses" >&5 +echo "${ECHO_T}$mp_cv_ncurses" >&6; } + if test "$mp_cv_ncurses" = yes + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_NCURSES_H 1 +_ACEOF + + CURSES_LIB="-lncurses" + fi + fi + if test ! "$CURSES_LIB" + then + { echo "$as_me:$LINENO: checking for working pdcurses" >&5 +echo $ECHO_N "checking for working pdcurses... $ECHO_C" >&6; } +if test "${mp_cv_pdcurses+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + LIBS="$mp_save_LIBS -lpdcurses" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + mp_cv_pdcurses=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + mp_cv_pdcurses=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $mp_cv_pdcurses" >&5 +echo "${ECHO_T}$mp_cv_pdcurses" >&6; } + if test "$mp_cv_pdcurses" = yes + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CURSES_H 1 +_ACEOF + + CURSES_LIB="-lpdcurses" + fi + fi + if test ! "$CURSES_LIB" + then + { echo "$as_me:$LINENO: checking for working pdcur" >&5 +echo $ECHO_N "checking for working pdcur... $ECHO_C" >&6; } +if test "${mp_cv_pdcur+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + LIBS="$mp_save_LIBS -lpdcur" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + mp_cv_pdcur=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + mp_cv_pdcur=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $mp_cv_pdcur" >&5 +echo "${ECHO_T}$mp_cv_pdcur" >&6; } + if test "$mp_cv_pdcur" = yes + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CURSES_H 1 +_ACEOF + + CURSES_LIB="-lpdcur" + fi + fi + if test ! "$CURSES_LIB" + then + { echo "$as_me:$LINENO: checking for working peer pdcurses" >&5 +echo $ECHO_N "checking for working peer pdcurses... $ECHO_C" >&6; } +if test "${mp_cv_lpdcurses+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + LIBS="$mp_save_LIBS ../pdcurses/pdcurses.a" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include "../pdcurses/curses.h" +int +main () +{ +chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + mp_cv_lpdcurses=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + mp_cv_lpdcurses=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $mp_cv_lpdcurses" >&5 +echo "${ECHO_T}$mp_cv_lpdcurses" >&6; } + if test "$mp_cv_lpdcurses" = yes + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CURSES_H 1 +_ACEOF + + CURSES_LIB="../pdcurses/pdcurses.a" + + if test "x$CPPFLAGS" = "x"; then + test "x$silent" != "xyes" && echo " setting CPPFLAGS to \""-I../pdcurses"\"" + CPPFLAGS=""-I../pdcurses"" + else + apr_addto_bugger=""-I../pdcurses"" + for i in $apr_addto_bugger; do + apr_addto_duplicate="0" + for j in $CPPFLAGS; do + if test "x$i" = "x$j"; then + apr_addto_duplicate="1" + break + fi + done + if test $apr_addto_duplicate = "0"; then + test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" + CPPFLAGS="$CPPFLAGS $i" + fi + done + fi + + fi + fi + { echo "$as_me:$LINENO: checking for ESCDELAY variable" >&5 +echo $ECHO_N "checking for ESCDELAY variable... $ECHO_C" >&6; } +if test "${mc_cv_ncurses_escdelay+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + extern int ESCDELAY; + ESCDELAY = 0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + mc_cv_ncurses_escdelay=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + mc_cv_ncurses_escdelay=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ echo "$as_me:$LINENO: result: $mc_cv_ncurses_escdelay" >&5 +echo "${ECHO_T}$mc_cv_ncurses_escdelay" >&6; } + if test "$mc_cv_ncurses_escdelay" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ESCDELAY 1 +_ACEOF + + fi + if test ! "$CURSES_LIB" ; then + LIBS="$mp_save_LIBS" + fi + +# Checks for library functions. +{ echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } +if test "${ac_cv_type_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef pid_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_pid_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_pid_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6; } +if test $ac_cv_type_pid_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + + +for ac_header in vfork.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ------------------------------------ ## +## Report this to yendor@rogueforge.net ## +## ------------------------------------ ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_func in fork vfork +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +if test "x$ac_cv_func_fork" = xyes; then + { echo "$as_me:$LINENO: checking for working fork" >&5 +echo $ECHO_N "checking for working fork... $ECHO_C" >&6; } +if test "${ac_cv_func_fork_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_fork_works=cross +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* By Ruediger Kuhlmann. */ + return fork () < 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_fork_works=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_fork_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5 +echo "${ECHO_T}$ac_cv_func_fork_works" >&6; } + +else + ac_cv_func_fork_works=$ac_cv_func_fork +fi +if test "x$ac_cv_func_fork_works" = xcross; then + case $host in + *-*-amigaos* | *-*-msdosdjgpp*) + # Override, as these systems have only a dummy fork() stub + ac_cv_func_fork_works=no + ;; + *) + ac_cv_func_fork_works=yes + ;; + esac + { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 +echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} +fi +ac_cv_func_vfork_works=$ac_cv_func_vfork +if test "x$ac_cv_func_vfork" = xyes; then + { echo "$as_me:$LINENO: checking for working vfork" >&5 +echo $ECHO_N "checking for working vfork... $ECHO_C" >&6; } +if test "${ac_cv_func_vfork_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_vfork_works=cross +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Thanks to Paul Eggert for this test. */ +$ac_includes_default +#include +#ifdef HAVE_VFORK_H +# include +#endif +/* On some sparc systems, changes by the child to local and incoming + argument registers are propagated back to the parent. The compiler + is told about this with #include , but some compilers + (e.g. gcc -O) don't grok . Test for this by using a + static variable whose address is put into a register that is + clobbered by the vfork. */ +static void +#ifdef __cplusplus +sparc_address_test (int arg) +# else +sparc_address_test (arg) int arg; +#endif +{ + static pid_t child; + if (!child) { + child = vfork (); + if (child < 0) { + perror ("vfork"); + _exit(2); + } + if (!child) { + arg = getpid(); + write(-1, "", 0); + _exit (arg); + } + } +} + +int +main () +{ + pid_t parent = getpid (); + pid_t child; + + sparc_address_test (0); + + child = vfork (); + + if (child == 0) { + /* Here is another test for sparc vfork register problems. This + test uses lots of local variables, at least as many local + variables as main has allocated so far including compiler + temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris + 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should + reuse the register of parent for one of the local variables, + since it will think that parent can't possibly be used any more + in this routine. Assigning to the local variable will thus + munge parent in the parent process. */ + pid_t + p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), + p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); + /* Convince the compiler that p..p7 are live; otherwise, it might + use the same hardware register for all 8 local variables. */ + if (p != p1 || p != p2 || p != p3 || p != p4 + || p != p5 || p != p6 || p != p7) + _exit(1); + + /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent + from child file descriptors. If the child closes a descriptor + before it execs or exits, this munges the parent's descriptor + as well. Test for this by closing stdout in the child. */ + _exit(close(fileno(stdout)) != 0); + } else { + int status; + struct stat st; + + while (wait(&status) != child) + ; + return ( + /* Was there some problem with vforking? */ + child < 0 + + /* Did the child fail? (This shouldn't happen.) */ + || status + + /* Did the vfork/compiler bug occur? */ + || parent != getpid() + + /* Did the file descriptor bug occur? */ + || fstat(fileno(stdout), &st) != 0 + ); + } +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_vfork_works=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_vfork_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5 +echo "${ECHO_T}$ac_cv_func_vfork_works" >&6; } + +fi; +if test "x$ac_cv_func_fork_works" = xcross; then + ac_cv_func_vfork_works=$ac_cv_func_vfork + { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 +echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} +fi + +if test "x$ac_cv_func_vfork_works" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WORKING_VFORK 1 +_ACEOF + +else + +cat >>confdefs.h <<\_ACEOF +#define vfork fork +_ACEOF + +fi +if test "x$ac_cv_func_fork_works" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WORKING_FORK 1 +_ACEOF + +fi + +if test $ac_cv_c_compiler_gnu = yes; then + { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 +echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; } +if test "${ac_cv_prog_gcc_traditional+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_pattern="Autoconf.*'x'" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 +echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; } + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + +{ echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 +echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; } +if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f conftest.sym conftest.file +echo >conftest.file +if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then + if test "$cross_compiling" = yes; then + ac_cv_func_lstat_dereferences_slashed_symlink=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + /* Linux will dereference the symlink and fail. + That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ + return lstat ("conftest.sym/", &sbuf) == 0; + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_lstat_dereferences_slashed_symlink=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +else + # If the `ln -s' command failed, then we probably don't even + # have an lstat function. + ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f conftest.sym conftest.file + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 +echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } + +test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && + +cat >>confdefs.h <<_ACEOF +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 +_ACEOF + + +if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then + case " $LIBOBJS " in + *" lstat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS lstat.$ac_objext" + ;; +esac + +fi + +{ echo "$as_me:$LINENO: checking whether lstat accepts an empty string" >&5 +echo $ECHO_N "checking whether lstat accepts an empty string... $ECHO_C" >&6; } +if test "${ac_cv_func_lstat_empty_string_bug+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_lstat_empty_string_bug=yes +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + return lstat ("", &sbuf) == 0; + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_lstat_empty_string_bug=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_lstat_empty_string_bug=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_lstat_empty_string_bug" >&5 +echo "${ECHO_T}$ac_cv_func_lstat_empty_string_bug" >&6; } +if test $ac_cv_func_lstat_empty_string_bug = yes; then + case " $LIBOBJS " in + *" lstat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS lstat.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<_ACEOF +#define HAVE_LSTAT_EMPTY_STRING_BUG 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 +echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; } +if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f conftest.sym conftest.file +echo >conftest.file +if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then + if test "$cross_compiling" = yes; then + ac_cv_func_lstat_dereferences_slashed_symlink=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + /* Linux will dereference the symlink and fail. + That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ + return lstat ("conftest.sym/", &sbuf) == 0; + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_lstat_dereferences_slashed_symlink=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +else + # If the `ln -s' command failed, then we probably don't even + # have an lstat function. + ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f conftest.sym conftest.file + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 +echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } + +test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && + +cat >>confdefs.h <<_ACEOF +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 +_ACEOF + + +if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then + case " $LIBOBJS " in + *" lstat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS lstat.$ac_objext" + ;; +esac + +fi + +{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_signal=int +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_signal=void +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + +{ echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 +echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } +if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_stat_empty_string_bug=yes +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + return stat ("", &sbuf) == 0; + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_stat_empty_string_bug=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_stat_empty_string_bug=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 +echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } +if test $ac_cv_func_stat_empty_string_bug = yes; then + case " $LIBOBJS " in + *" stat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS stat.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<_ACEOF +#define HAVE_STAT_EMPTY_STRING_BUG 1 +_ACEOF + +fi + + +for ac_func in vprintf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +{ echo "$as_me:$LINENO: checking for _doprnt" >&5 +echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6; } +if test "${ac_cv_func__doprnt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define _doprnt to an innocuous variant, in case declares _doprnt. + For example, HP-UX 11i declares gettimeofday. */ +#define _doprnt innocuous__doprnt + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char _doprnt (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef _doprnt + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char _doprnt (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub__doprnt || defined __stub____doprnt +choke me +#endif + +int +main () +{ +return _doprnt (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func__doprnt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func__doprnt=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 +echo "${ECHO_T}$ac_cv_func__doprnt" >&6; } +if test $ac_cv_func__doprnt = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DOPRNT 1 +_ACEOF + +fi + +fi +done + + + + + + + + + + + + + + + + + + + + + + + + +for ac_func in erasechar killchar alarm getpass memset setenv strchr nlist _spawnl spawnl getpwuid loadav getloadavg strerror setresgid setregid setgid setresuid setreuid setuid getuid getgid +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +# Extract the first word of "nroff", so it can be a program name with args. +set dummy nroff; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_NROFF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$NROFF"; then + ac_cv_prog_NROFF="$NROFF" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_NROFF="nroff" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +NROFF=$ac_cv_prog_NROFF +if test -n "$NROFF"; then + { echo "$as_me:$LINENO: result: $NROFF" >&5 +echo "${ECHO_T}$NROFF" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +# Extract the first word of "groff", so it can be a program name with args. +set dummy groff; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_GROFF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$GROFF"; then + ac_cv_prog_GROFF="$GROFF" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_GROFF="groff" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +GROFF=$ac_cv_prog_GROFF +if test -n "$GROFF"; then + { echo "$as_me:$LINENO: result: $GROFF" >&5 +echo "${ECHO_T}$GROFF" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +# Extract the first word of "colcrt", so it can be a program name with args. +set dummy colcrt; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_COLCRT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$COLCRT"; then + ac_cv_prog_COLCRT="$COLCRT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_COLCRT="colcrt" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +COLCRT=$ac_cv_prog_COLCRT +if test -n "$COLCRT"; then + { echo "$as_me:$LINENO: result: $COLCRT" >&5 +echo "${ECHO_T}$COLCRT" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +# Extract the first word of "tbl", so it can be a program name with args. +set dummy tbl; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_TBL+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$TBL"; then + ac_cv_prog_TBL="$TBL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_TBL="tbl" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +TBL=$ac_cv_prog_TBL +if test -n "$TBL"; then + { echo "$as_me:$LINENO: result: $TBL" >&5 +echo "${ECHO_T}$TBL" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +# Extract the first word of "sed", so it can be a program name with args. +set dummy sed; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_SED+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$SED"; then + ac_cv_prog_SED="$SED" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_SED="sed" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +SED=$ac_cv_prog_SED +if test -n "$SED"; then + { echo "$as_me:$LINENO: result: $SED" >&5 +echo "${ECHO_T}$SED" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + + +# Check whether --with-program-name was given. +if test "${with_program_name+set}" = set; then + withval=$with_program_name; progname="$withval" +else + progname="rogue" +fi + +PROGRAM=$progname + + +# Check whether --enable-setgid was given. +if test "${enable_setgid+set}" = set; then + enableval=$enable_setgid; +fi + +{ echo "$as_me:$LINENO: checking if using setgid execute bit" >&5 +echo $ECHO_N "checking if using setgid execute bit... $ECHO_C" >&6; } +if test "x$enable_setgid" = "xno" ; then +GROUPOWNER= +elif test "x$enable_setgid" = "xyes" ; then +GROUPOWNER=games +elif test "x$enable_setgid" = "x" ; then +GROUPOWNER= +else +GROUPOWNER=$enable_setgid +fi + +if test "x$GROUPOWNER" != "x" ; then + +cat >>confdefs.h <<_ACEOF +#define GROUPOWNER $GROUPOWNER +_ACEOF + +{ echo "$as_me:$LINENO: result: $GROUPOWNER" >&5 +echo "${ECHO_T}$GROUPOWNER" >&6; } +else +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + +# Check whether --enable-scorefile was given. +if test "${enable_scorefile+set}" = set; then + enableval=$enable_scorefile; +fi + +{ echo "$as_me:$LINENO: checking for scoreboard file" >&5 +echo $ECHO_N "checking for scoreboard file... $ECHO_C" >&6; } +if test "x$enable_scorefile" = "xno" ; then +SCOREFILE= +elif test "x$enable_scorefile" = "xyes" ; then +SCOREFILE=$progname.scr +elif test "x$enable_scorefile" = "x" ; then +SCOREFILE=$progname.scr +else +SCOREFILE=$enable_scorefile +fi + +if test "x$SCOREFILE" != "x" ; then + +cat >>confdefs.h <<_ACEOF +#define SCOREFILE "$SCOREFILE" +_ACEOF + +{ echo "$as_me:$LINENO: result: $SCOREFILE" >&5 +echo "${ECHO_T}$SCOREFILE" >&6; } +else +{ echo "$as_me:$LINENO: result: disabled" >&5 +echo "${ECHO_T}disabled" >&6; } +fi + + + +# Check whether --enable-lockfile was given. +if test "${enable_lockfile+set}" = set; then + enableval=$enable_lockfile; +fi + +{ echo "$as_me:$LINENO: checking for scoreboard lockfile file" >&5 +echo $ECHO_N "checking for scoreboard lockfile file... $ECHO_C" >&6; } +if test "x$enable_lockfile" = "xno" ; then +LOCKFILE= +elif test "x$enable_lockfile" = "xyes" ; then +LOCKFILE=$progname.lck +elif test "x$enable_lockfile" = "x" ; then +LOCKFILE=$progname.lck +else +LOCKFILE=$enable_lockfile +fi + +if test "x$LOCKFILE" != "x" ; then + +cat >>confdefs.h <<_ACEOF +#define LOCKFILE "$LOCKFILE" +_ACEOF + +{ echo "$as_me:$LINENO: result: $LOCKFILE" >&5 +echo "${ECHO_T}$LOCKFILE" >&6; } +else +{ echo "$as_me:$LINENO: result: disabled" >&5 +echo "${ECHO_T}disabled" >&6; } +fi + + + +# Check whether --enable-wizardmode was given. +if test "${enable_wizardmode+set}" = set; then + enableval=$enable_wizardmode; +fi + +{ echo "$as_me:$LINENO: checking if wizard mode is enabled" >&5 +echo $ECHO_N "checking if wizard mode is enabled... $ECHO_C" >&6; } +if test "x$enable_wizardmode" = "xno" ; then +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +elif test "x$enable_wizardmode" = "x" ; then +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +else + +cat >>confdefs.h <<\_ACEOF +#define MASTER +_ACEOF + +if test "x$enable_wizardmode" != "xyes" ; then + +cat >>confdefs.h <<_ACEOF +#define PASSWD $enable_wizardmode +_ACEOF + +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +fi + +# Check whether --enable-allscores was given. +if test "${enable_allscores+set}" = set; then + enableval=$enable_allscores; +else + enable_allscores=yes +fi + +{ echo "$as_me:$LINENO: checking if allscores is enabled" >&5 +echo $ECHO_N "checking if allscores is enabled... $ECHO_C" >&6; } +if test "x$enable_allscores" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define ALLSCORES 1 +_ACEOF + +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + +# Check whether --enable-checktime was given. +if test "${enable_checktime+set}" = set; then + enableval=$enable_checktime; +fi + +{ echo "$as_me:$LINENO: checking if checktime is enabled" >&5 +echo $ECHO_N "checking if checktime is enabled... $ECHO_C" >&6; } +if test "x$enable_checktime" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define CHECKTIME 1 +_ACEOF + +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + +# Check whether --enable-maxload was given. +if test "${enable_maxload+set}" = set; then + enableval=$enable_maxload; +fi + +{ echo "$as_me:$LINENO: checking runtime execution limit (maximum system load average)" >&5 +echo $ECHO_N "checking runtime execution limit (maximum system load average)... $ECHO_C" >&6; } +if test "x$enable_maxload" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define MAXLOAD 100 +_ACEOF + +{ echo "$as_me:$LINENO: result: 100" >&5 +echo "${ECHO_T}100" >&6; } +elif test "x$enable_maxload" = "x" ; then +{ echo "$as_me:$LINENO: result: unlimited" >&5 +echo "${ECHO_T}unlimited" >&6; } +elif test "x$enable_maxload" = "xno" ; then +{ echo "$as_me:$LINENO: result: unlimited" >&5 +echo "${ECHO_T}unlimited" >&6; } +else + +cat >>confdefs.h <<_ACEOF +#define MAXLOAD $enable_maxload +_ACEOF + +{ echo "$as_me:$LINENO: result: $enable_maxload" >&5 +echo "${ECHO_T}$enable_maxload" >&6; } +fi + +# Check whether --enable-maxusers was given. +if test "${enable_maxusers+set}" = set; then + enableval=$enable_maxusers; +fi + +{ echo "$as_me:$LINENO: checking runtime execution limit (maximum online system users)" >&5 +echo $ECHO_N "checking runtime execution limit (maximum online system users)... $ECHO_C" >&6; } +if test "x$enable_maxusers" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define MAXUSERS 100 +_ACEOF + +{ echo "$as_me:$LINENO: result: 100" >&5 +echo "${ECHO_T}100" >&6; } +elif test "x$enable_maxusers" = "x" ; then +{ echo "$as_me:$LINENO: result: unlimited" >&5 +echo "${ECHO_T}unlimited" >&6; } +elif test "x$enable_maxload" = "xno" ; then +{ echo "$as_me:$LINENO: result: unlimited" >&5 +echo "${ECHO_T}unlimited" >&6; } +else + +cat >>confdefs.h <<_ACEOF +#define MAXLOAD $enable_maxusers +_ACEOF + +{ echo "$as_me:$LINENO: result: $enable_maxusers" >&5 +echo "${ECHO_T}$enable_maxusers" >&6; } +fi + +# Check whether --enable-numscores was given. +if test "${enable_numscores+set}" = set; then + enableval=$enable_numscores; +fi + +{ echo "$as_me:$LINENO: checking what the number of scores to store in scoreboard is" >&5 +echo $ECHO_N "checking what the number of scores to store in scoreboard is... $ECHO_C" >&6; } +if test "x$numscores" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define NUMSCORES 10 +_ACEOF + +{ echo "$as_me:$LINENO: result: 10" >&5 +echo "${ECHO_T}10" >&6; } +elif test "x$enable_numscores" = "x" ; then + +cat >>confdefs.h <<\_ACEOF +#define NUMSCORES 10 +_ACEOF + +{ echo "$as_me:$LINENO: result: 10" >&5 +echo "${ECHO_T}10" >&6; } +elif test "x$enable_numscores" = "xno" ; then + +cat >>confdefs.h <<\_ACEOF +#define NUMSCORES 10 +_ACEOF + +{ echo "$as_me:$LINENO: result: 10" >&5 +echo "${ECHO_T}10" >&6; } +else + +cat >>confdefs.h <<_ACEOF +#define NUMSCORES $enable_numscores +_ACEOF + +{ echo "$as_me:$LINENO: result: $enable_numscores" >&5 +echo "${ECHO_T}$enable_numscores" >&6; } +fi + +# Check whether --enable-numname was given. +if test "${enable_numname+set}" = set; then + enableval=$enable_numname; +fi + +{ echo "$as_me:$LINENO: checking word for the number of scores to store in scoreboard is" >&5 +echo $ECHO_N "checking word for the number of scores to store in scoreboard is... $ECHO_C" >&6; } +if test "x$enable_numname" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define NUMNAME "Ten" +_ACEOF + +{ echo "$as_me:$LINENO: result: Ten" >&5 +echo "${ECHO_T}Ten" >&6; } +elif test "x$enable_numname" = "x" ; then + +cat >>confdefs.h <<\_ACEOF +#define NUMNAME "Ten" +_ACEOF + +{ echo "$as_me:$LINENO: result: Ten" >&5 +echo "${ECHO_T}Ten" >&6; } +elif test "x$enable_numname" = "xno" ; then + +cat >>confdefs.h <<\_ACEOF +#define NUMNAME "Ten" +_ACEOF + +{ echo "$as_me:$LINENO: result: Ten" >&5 +echo "${ECHO_T}Ten" >&6; } +else + +cat >>confdefs.h <<_ACEOF +#define NUMNAME "$enable_numname" +_ACEOF + +{ echo "$as_me:$LINENO: result: $enable_numname" >&5 +echo "${ECHO_T}$enable_numname" >&6; } +fi + +# Check whether --enable-loadav was given. +if test "${enable_loadav+set}" = set; then + enableval=$enable_loadav; +fi + +{ echo "$as_me:$LINENO: checking whether to use program's built in load average function" >&5 +echo $ECHO_N "checking whether to use program's built in load average function... $ECHO_C" >&6; } +if test "x$enable_loadav" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define LOADAV +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define NAMELIST /vmunix +_ACEOF + +{ echo "$as_me:$LINENO: result: /vmunix" >&5 +echo "${ECHO_T}/vmunix" >&6; } +elif test "x$enable_loadav" = "x" ; then +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +elif test "x$enable_loadav" = "xno" ; then +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +else + +cat >>confdefs.h <<\_ACEOF +#define LOADAV +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define NAMELIST $enable_loadav +_ACEOF + +{ echo "$as_me:$LINENO: result: $enable_loadav" >&5 +echo "${ECHO_T}$enable_loadav" >&6; } +fi + +# Check whether --enable-ucount was given. +if test "${enable_ucount+set}" = set; then + enableval=$enable_ucount; +fi + +{ echo "$as_me:$LINENO: checking whether to use program's built in user counting function" >&5 +echo $ECHO_N "checking whether to use program's built in user counting function... $ECHO_C" >&6; } +if test "x$enable_ucount" = "xyes" ; then + +cat >>confdefs.h <<\_ACEOF +#define UCOUNT +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define UTMP /etc/utmp +_ACEOF + +{ echo "$as_me:$LINENO: result: /etc/utmp" >&5 +echo "${ECHO_T}/etc/utmp" >&6; } +elif test "x$enable_ucount" = "x" ; then +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +elif test "x$enable_count" = "xno" ; then +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +else + +cat >>confdefs.h <<\_ACEOF +#define UCOUNT +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define UTMP $enable_ucount +_ACEOF + +{ echo "$as_me:$LINENO: result: $enable_ucount" >&5 +echo "${ECHO_T}$enable_ucount" >&6; } +fi + +TARGET=$target + + +{ echo "$as_me:$LINENO: checking whether to docdir is defined" >&5 +echo $ECHO_N "checking whether to docdir is defined... $ECHO_C" >&6; } +if test "x$docdir" = "x" ; then +{ echo "$as_me:$LINENO: result: docdir undefined" >&5 +echo "${ECHO_T}docdir undefined" >&6; } +docdir=\${datadir}/doc/\${PACKAGE_TARNAME} + +else +{ echo "$as_me:$LINENO: result: docdir defined" >&5 +echo "${ECHO_T}docdir defined" >&6; } +fi + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by Rogue $as_me 5.4.4, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +Rogue config.status 5.4.4 +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "rogue.6") CONFIG_FILES="$CONFIG_FILES rogue.6" ;; + "rogue.cat") CONFIG_FILES="$CONFIG_FILES rogue.cat" ;; + "rogue.doc") CONFIG_FILES="$CONFIG_FILES rogue.doc" ;; + "rogue.html") CONFIG_FILES="$CONFIG_FILES rogue.html" ;; + "rogue.me") CONFIG_FILES="$CONFIG_FILES rogue.me" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +target!$target$ac_delim +target_cpu!$target_cpu$ac_delim +target_vendor!$target_vendor$ac_delim +target_os!$target_os$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +NROFF!$NROFF$ac_delim +GROFF!$GROFF$ac_delim +COLCRT!$COLCRT$ac_delim +TBL!$TBL$ac_delim +SED!$SED$ac_delim +PROGRAM!$PROGRAM$ac_delim +GROUPOWNER!$GROUPOWNER$ac_delim +SCOREFILE!$SCOREFILE$ac_delim +LOCKFILE!$LOCKFILE$ac_delim +TARGET!$TARGET$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 71; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then replace #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF + if test x"$ac_file" != x-; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f $ac_file + mv "$tmp/config.h" $ac_file + fi + else + echo "/* $configure_input */" + cat "$ac_result" + fi + rm -f "$tmp/out12" + ;; + + + esac + +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + From e25d05fd85ebda1e4e49990641899f147fe99e50 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:19:52 -1100 Subject: [PATCH 1684/3904] Fixes --- src/cc/rogue/mach_dep.c | 3 ++- src/cc/rogue/rip.c | 6 ++++-- src/cc/rogue/rogue.c | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/mach_dep.c b/src/cc/rogue/mach_dep.c index 7f1af9c67..34e502816 100644 --- a/src/cc/rogue/mach_dep.c +++ b/src/cc/rogue/mach_dep.c @@ -403,7 +403,8 @@ over: printf("The score file is very busy. Do you want to wait longer\n"); printf("for it to become free so your score can get posted?\n"); printf("If so, type \"y\"\n"); - (void) fgets(prbuf, MAXSTR, stdin); + if (fgets(prbuf, MAXSTR, stdin) != 0 ) + ; if (prbuf[0] == 'y') for (;;) { diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index 6f2793615..dc22566e9 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -179,7 +179,8 @@ score(int amount, int flags, char monst) else if (prflags == 2) { fflush(stdout); - (void) fgets(prbuf,10,stdin); + if ( fgets(prbuf,10,stdin) != 0 ) + fprintf(stderr,"fgets error\n"); if (prbuf[0] == 'd') { for (sc2 = scp; sc2 < endp - 1; sc2++) @@ -270,7 +271,8 @@ death(char monst) score(purse, amulet ? 3 : 0, monst); printf("[Press return to continue]"); fflush(stdout); - (void) fgets(prbuf,10,stdin); + if ( fgets(prbuf,10,stdin) != 0 ) + ; my_exit(0); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index d463ddc49..a496426dd 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -147,7 +147,6 @@ int32_t rogue_replay(uint64_t seed) if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(fp,0); - fclose(fp); if ( 0 && (fp= fopen("checkfile","rb")) != 0 ) { for (i=0; i<0x150; i++) From d7da31e4d775ecfdd3d92cc6716b96cf3badcd72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:30:41 -1100 Subject: [PATCH 1685/3904] Rogue rpc skeleton --- src/cc/cclib.cpp | 15 +++++++++++++-- src/cc/makerogue | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8a0f0aeca..c05fc11b9 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -47,11 +47,18 @@ struct CClib_rpcinfo int32_t numrequiredargs,maxargs; uint8_t funcid,evalcode; } +// creategame, register (inventory + baton + buyin), progress (events + statehash + [compr state]?), claimwin + CClib_methods[] = { { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, #ifdef BUILD_ROGUE + { (char *)"rogue", (char *)"newgame", (char *)"buyin", 0, 1, 'N', EVAL_ROGUE }, + { (char *)"rogue", (char *)"register", (char *)"txid [inventory]", 1, 2, 'R', EVAL_ROGUE }, + { (char *)"rogue", (char *)"progress", (char *)"txid fname", 2, 2, 'P', EVAL_ROGUE }, + { (char *)"rogue", (char *)"claimwin", (char *)"txid", 1, 1, 'W', EVAL_ROGUE }, + { (char *)"rogue", (char *)"extract", (char *)"txid item", 2, 2, 'X', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -63,6 +70,11 @@ CClib_methods[] = std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); #ifdef BUILD_ROGUE +bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + return(true); +} + #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -216,8 +228,7 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( cp->evalcode != EVAL_FAUCET2 ) { #ifdef BUILD_ROGUE - //return(rogue_validate(cp,height,eval,tx)); - return(false); + return(rogue_validate(cp,height,eval,tx)); #else return(sudoku_validate(cp,height,eval,tx)); #endif diff --git a/src/cc/makerogue b/src/cc/makerogue index c9e55c28c..ea02e7fb1 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,2 +1,2 @@ cd rogue; make; cd .. -gcc -DROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp rogue/rogue.so +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp rogue/rogue.so From ffc1aac7008841c8ca09bb05856537c14e6f421e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:32:08 -1100 Subject: [PATCH 1686/3904] Make rogue --- src/cc/makerogue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/makerogue b/src/cc/makerogue index ea02e7fb1..f0e495014 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,2 +1,3 @@ cd rogue; make; cd .. gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp rogue/rogue.so +gcc -DROGUE -std=c++11 -fPIC -shared -o ../libcc.so cclib.o rogue/rogue.so From ad8e1789ed1f3a2dc91bb29afc93a8f726bc8bda Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:34:00 -1100 Subject: [PATCH 1687/3904] makecclib --- src/cc/makerogue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index f0e495014..059b0ae4a 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,3 +1,4 @@ cd rogue; make; cd .. gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp rogue/rogue.so -gcc -DROGUE -std=c++11 -fPIC -shared -o ../libcc.so cclib.o rogue/rogue.so +gcc -fPIC -shared -o librogue.so cclib.o rogue/rogue.so +cp librogue.so ../libcc.so From 47c926b373552c6a6e1f79a0e74c5fa234412c38 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:35:01 -1100 Subject: [PATCH 1688/3904] Fix --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 059b0ae4a..651e3683a 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,4 +1,4 @@ cd rogue; make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp rogue/rogue.so +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp gcc -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From a3745c01d47340dc8a6189d1fd3d7dcc1b55054c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:35:45 -1100 Subject: [PATCH 1689/3904] Fix --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 651e3683a..6882139ff 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,4 +1,4 @@ cd rogue; make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c cclib.cpp gcc -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From 779826611a2c2cc1358d69b5fb069171153a9de7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:40:28 -1100 Subject: [PATCH 1690/3904] Stdint --- src/cc/rogue/extern.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index e8c13d27d..eb95789e3 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -18,6 +18,7 @@ #undef HAVE_MEMORY_H #undef HAVE_STRING_H #endif +#include "" #include "config.h" #elif defined(__DJGPP__) #define HAVE_SYS_TYPES_H 1 From d338544e8665e1a286ef1c5f9cd7fe668f5a6ece Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:41:03 -1100 Subject: [PATCH 1691/3904] Add confgure --- src/cc/makerogue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 6882139ff..7bb1fb18a 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,4 +1,6 @@ -cd rogue; make; cd .. +cd rogue; +./configure # only need this first time +make; cd .. gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c cclib.cpp gcc -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From 205ec791c5cf4b5a5bc5b65e5ea0cbf5776d735d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:42:27 -1100 Subject: [PATCH 1692/3904] -"" --- src/cc/rogue/extern.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index eb95789e3..2946c540f 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -18,7 +18,7 @@ #undef HAVE_MEMORY_H #undef HAVE_STRING_H #endif -#include "" +#include #include "config.h" #elif defined(__DJGPP__) #define HAVE_SYS_TYPES_H 1 From 791cfd2b701d18f74b469623b79c3a9583a1830e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:48:38 -1100 Subject: [PATCH 1693/3904] -std=c++11 --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 7bb1fb18a..cfd72fd3d 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -2,5 +2,5 @@ cd rogue; ./configure # only need this first time make; cd .. gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c cclib.cpp -gcc -fPIC -shared -o librogue.so cclib.o rogue/rogue.so +gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From eaa3bcb4939ca06aa961aa5ccc6ed7ee3c46c9b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 03:57:08 -1100 Subject: [PATCH 1694/3904] Directly link .so --- src/cc/makerogue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index cfd72fd3d..1b9568265 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,6 +1,7 @@ cd rogue; ./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c cclib.cpp -gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp +#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so + From 70664f4be5ac7258acb4d12370c9bfea734533a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:13:53 -1100 Subject: [PATCH 1695/3904] Build via include --- src/cc/cclib.cpp | 34 ++++++++++++++++++++++++++++++++++ src/cc/rogue/extern.h | 3 +++ src/cc/rogue/rogue.h | 5 +++++ src/cc/rogue/score.h | 3 +++ 4 files changed, 45 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c05fc11b9..a637de5f9 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -403,6 +403,40 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para } #ifdef BUILD_ROGUE +#include "rogue/vers.c" +#include "rogue/extern.c" +#include "rogue/armor.c" +#include "rogue/chase.c" +#include "rogue/command.c" +#include "rogue/daemon.c" +#include "rogue/daemons.c" +#include "rogue/fight.c" +#include "rogue/init.c" +#include "rogue/io.c" +#include "rogue/list.c" +#include "rogue/mach_dep.c" +#include "rogue/rogue.c" +#include "rogue/mdport.c" +#include "rogue/misc.c" +#include "rogue/monsters.c" +#include "rogue/move.c" +#include "rogue/new_level.c" +#include "rogue/options.c" +#include "rogue/pack.c" +#include "rogue/passages.c" +#include "rogue/potions.c" +#include "rogue/rings.c" +#include "rogue/rip.c" +#include "rogue/rooms.c" +#include "rogue/save.c" +#include "rogue/scrolls.c" +#include "rogue/state.c" +#include "rogue/sticks.c" +#include "rogue/things.c" +#include "rogue/weapons.c" +#include "rogue/wizard.c" +#include "rogue/xcrypt.c" + #else #include "sudoku.cpp" #endif diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 2946c540f..1516ebb12 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -10,6 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#ifndef H_EXTERN_ROGUE_H +#define H_EXTERN_ROGUE_H #ifdef HAVE_CONFIG_H #ifdef PDCURSES @@ -179,4 +181,5 @@ void md_onsignal_autosave(void); void md_onsignal_exit(void); void md_onsignal_default(void); int md_issymlink(char *sp); +#endif diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index ae834eb7a..040c9a97d 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -10,6 +10,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#ifndef H_ROGUE_H +#define H_ROGUE_H + #include "extern.h" #undef lines @@ -783,3 +786,5 @@ extern char *wood[]; extern int cNWOOD; extern char *metal[]; extern int cNMETAL; +#endif + diff --git a/src/cc/rogue/score.h b/src/cc/rogue/score.h index fb51bf8bc..a5897b482 100644 --- a/src/cc/rogue/score.h +++ b/src/cc/rogue/score.h @@ -9,6 +9,8 @@ * * See the file LICENSE.TXT for full copyright and licensing information. */ +#ifndef H_SCORE_H +#define H_SCORE_H struct sc_ent { unsigned int sc_uid; @@ -24,3 +26,4 @@ typedef struct sc_ent SCORE; void rd_score(SCORE *top_ten); void wr_score(SCORE *top_ten); +#endif From 53659cea89161f50bec232c98896dae0023c283b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:16:07 -1100 Subject: [PATCH 1696/3904] Make sure included --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index a637de5f9..d4a3ad74b 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -412,6 +412,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/daemons.c" #include "rogue/fight.c" #include "rogue/init.c" +xx #include "rogue/io.c" #include "rogue/list.c" #include "rogue/mach_dep.c" From fac2456a5d872446cfb60a1e7496960448e6bb06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:17:05 -1100 Subject: [PATCH 1697/3904] Revert --- src/cc/cclib.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index d4a3ad74b..a637de5f9 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -412,7 +412,6 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/daemons.c" #include "rogue/fight.c" #include "rogue/init.c" -xx #include "rogue/io.c" #include "rogue/list.c" #include "rogue/mach_dep.c" From a3e938ac02512992c2d4df3c7b55758b5b2c37c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:20:13 -1100 Subject: [PATCH 1698/3904] Test --- src/cc/cclib.cpp | 4 ++-- src/cc/makerogue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index a637de5f9..982431c8c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -403,7 +403,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para } #ifdef BUILD_ROGUE -#include "rogue/vers.c" +/*#include "rogue/vers.c" #include "rogue/extern.c" #include "rogue/armor.c" #include "rogue/chase.c" @@ -435,7 +435,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/things.c" #include "rogue/weapons.c" #include "rogue/wizard.c" -#include "rogue/xcrypt.c" +#include "rogue/xcrypt.c"*/ #else #include "sudoku.cpp" diff --git a/src/cc/makerogue b/src/cc/makerogue index 1b9568265..a12acb7cd 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; -./configure # only need this first time +#./configure # only need this first time make; cd .. gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so +gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o cp librogue.so ../libcc.so From bab1da339a9b0181ad433be6b963f80fef612221 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:21:16 -1100 Subject: [PATCH 1699/3904] Test --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index a12acb7cd..167c16700 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c cclib.cpp #-o librogue.so gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o cp librogue.so ../libcc.so From 7df876952a9ebccf4a03d4e693b75e41718a6a21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:22:05 -1100 Subject: [PATCH 1700/3904] Test --- src/cc/makerogue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 167c16700..46c2141cb 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c cclib.cpp #-o librogue.so -gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp rogue/rogue.o +//gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o cp librogue.so ../libcc.so From 4b74b07b2f2db75bdb375f6d8666818ee2ba2253 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:23:45 -1100 Subject: [PATCH 1701/3904] rogue_replay --- src/cc/cclib.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 982431c8c..b3a95a418 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -70,6 +70,8 @@ CClib_methods[] = std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); #ifdef BUILD_ROGUE +extern "C" int32_t rogue_replay(uint64_t seed); + bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true); @@ -89,6 +91,7 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) #ifdef BUILD_ROGUE if ( cp->evalcode == EVAL_ROGUE ) { + rogue_replay(777); } #else if ( cp->evalcode == EVAL_SUDOKU ) From 84622a7f931dd786188659baad20312fc9afeb9a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:25:48 -1100 Subject: [PATCH 1702/3904] rogue.so --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 46c2141cb..18f43591d 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp rogue/rogue.o +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so cclib.cpp rogue/rogue.so //gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o cp librogue.so ../libcc.so From 5603e44b65dfe56e2d8ca0abcebdbe5553667581 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:26:57 -1100 Subject: [PATCH 1703/3904] Test --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 18f43591d..bc5d9dd77 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -2,6 +2,6 @@ cd rogue; #./configure # only need this first time make; cd .. gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so cclib.cpp rogue/rogue.so -//gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o +#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o cp librogue.so ../libcc.so From c99266e25773b19db796c5782cbd8418bdb36972 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:28:00 -1100 Subject: [PATCH 1704/3904] Need to include --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index bc5d9dd77..4c8fb7f2b 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so cclib.cpp rogue/rogue.so +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so cclib.cpp #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o cp librogue.so ../libcc.so From c4ea0147a27195b4ac5bf8fe2fd37944c6687287 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:28:51 -1100 Subject: [PATCH 1705/3904] -c --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 4c8fb7f2b..30d3fe6a3 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so cclib.cpp +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o -c librogue.so cclib.cpp #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o cp librogue.so ../libcc.so From da4ffad51987f855d0a0a7e58674d0b0075ba8b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:29:45 -1100 Subject: [PATCH 1706/3904] Revert --- src/cc/makerogue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 30d3fe6a3..4fcbee14f 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o -c librogue.so cclib.cpp -#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.o +gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp +#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From eb0eeed0dd4d9ccd549e00bcd92f93b26f22545c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:31:00 -1100 Subject: [PATCH 1707/3904] Incremental c files --- src/cc/cclib.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b3a95a418..7706058ba 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -70,7 +70,7 @@ CClib_methods[] = std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); #ifdef BUILD_ROGUE -extern "C" int32_t rogue_replay(uint64_t seed); +int32_t rogue_replay(uint64_t seed); bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { @@ -406,10 +406,10 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para } #ifdef BUILD_ROGUE -/*#include "rogue/vers.c" +#include "rogue/vers.c" #include "rogue/extern.c" #include "rogue/armor.c" -#include "rogue/chase.c" +/*#include "rogue/chase.c" #include "rogue/command.c" #include "rogue/daemon.c" #include "rogue/daemons.c" From 10f9393196f31a33b1960a223fcbd04f83dd7eb0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:33:21 -1100 Subject: [PATCH 1708/3904] -Wno --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 4fcbee14f..c7b62e259 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp +gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From 6d73c8c032e4e7e0c9e71b1835b47a068562704c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:34:07 -1100 Subject: [PATCH 1709/3904] More files --- src/cc/cclib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 7706058ba..53add03be 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -409,7 +409,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/vers.c" #include "rogue/extern.c" #include "rogue/armor.c" -/*#include "rogue/chase.c" +#include "rogue/chase.c" #include "rogue/command.c" #include "rogue/daemon.c" #include "rogue/daemons.c" @@ -417,7 +417,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/init.c" #include "rogue/io.c" #include "rogue/list.c" -#include "rogue/mach_dep.c" +/*#include "rogue/mach_dep.c" #include "rogue/rogue.c" #include "rogue/mdport.c" #include "rogue/misc.c" From 046de189811c5dc130cd09c795889acbe11ed933 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:36:12 -1100 Subject: [PATCH 1710/3904] -this --- src/cc/rogue/chase.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/chase.c b/src/cc/rogue/chase.c index 168993edb..73d53e1fd 100644 --- a/src/cc/rogue/chase.c +++ b/src/cc/rogue/chase.c @@ -120,7 +120,7 @@ do_chase(struct rogue_state *rs,THING *th) register bool stoprun = FALSE; /* TRUE means we are there */ register bool door; register THING *obj; - static coord this; /* Temporary destination for chaser */ + static coord DEST; /* Temporary destination for chaser */ rer = th->t_room; /* Find room of chaser */ if (on(*th, ISGREED) && rer->r_goldval == 0) @@ -146,7 +146,7 @@ over: curdist = dist_cp(th->t_dest, cp); if (curdist < mindist) { - this = *cp; + DEST = *cp; mindist = curdist; } } @@ -159,7 +159,7 @@ over: } else { - this = *th->t_dest; + DEST = *th->t_dest; /* * For dragons check and see if (a) the hero is on a straight * line from it, and (b) that it is within shooting distance, @@ -191,13 +191,13 @@ over: * so we run to it. If we hit it we either want to fight it * or stop running */ - if (!chase(th, &this)) + if (!chase(th, &DEST)) { - if (ce(this, hero)) + if (ce(DEST, hero)) { return( attack(rs,th) ); } - else if (ce(this, *th->t_dest)) + else if (ce(DEST, *th->t_dest)) { for (obj = lvl_obj; obj != NULL; obj = next(obj)) if (th->t_dest == &obj->o_pos) From 46b235b2cc38e72b4e063d66869f25ac13a391e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:39:26 -1100 Subject: [PATCH 1711/3904] syntax --- src/cc/rogue/command.c | 6 +++--- src/cc/rogue/fight.c | 2 +- src/cc/rogue/list.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index ce02da076..34a49a70b 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -355,9 +355,9 @@ over: when ']': current(rs,cur_armor, "wearing", NULL); when '=': current(rs,cur_ring[LEFT], "wearing", - terse ? "(L)" : "on left hand"); + terse ? (char *)"(L)" : (char *)"on left hand"); current(rs,cur_ring[RIGHT], "wearing", - terse ? "(R)" : "on right hand"); + terse ? (char *)"(R)" : (char *)"on right hand"); when '@': stat_msg = TRUE; status(rs); @@ -784,7 +784,7 @@ norm: { if (*guess != NULL) free(*guess); - *guess = malloc((unsigned int) strlen(prbuf) + 1); + *guess = (char *)malloc((unsigned int) strlen(prbuf) + 1); strcpy(*guess, prbuf); } } diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index ba1c9112e..31c29c62c 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -353,7 +353,7 @@ set_mname(THING *tp) static char tbuf[MAXSTR] = { 't', 'h', 'e', ' ' }; if (!see_monst(tp) && !on(player, SEEMONST)) - return (terse ? "it" : "something"); + return (terse ? (char *)"it" : (char *)"something"); else if (on(player, ISHALU)) { move(tp->t_pos.y, tp->t_pos.x); diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 6c069d06e..8dc5a5359 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -100,7 +100,7 @@ new_item(void) THING *item; #ifdef MASTER - if ((item = calloc(1, sizeof *item)) == NULL) + if ((item = (THING *)calloc(1, sizeof *item)) == NULL) msg(rs,"ran out of memory after %d items", total); else total++; From a55cc1761ece689ebd061cb9892afae4d3e7a280 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:40:48 -1100 Subject: [PATCH 1712/3904] More c files --- src/cc/cclib.cpp | 4 ++-- src/cc/rogue/list.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 53add03be..8d1d7d379 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -417,12 +417,12 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/init.c" #include "rogue/io.c" #include "rogue/list.c" -/*#include "rogue/mach_dep.c" +#include "rogue/mach_dep.c" #include "rogue/rogue.c" #include "rogue/mdport.c" #include "rogue/misc.c" #include "rogue/monsters.c" -#include "rogue/move.c" +/*#include "rogue/move.c" #include "rogue/new_level.c" #include "rogue/options.c" #include "rogue/pack.c" diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 8dc5a5359..f571be628 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -105,7 +105,7 @@ new_item(void) else total++; #else - item = calloc(1, sizeof *item); + item = (THING *)calloc(1, sizeof *item); #endif item->l_next = NULL; item->l_prev = NULL; From d9f3929917acf6571e0d20b6f5dc025cab313b73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:43:54 -1100 Subject: [PATCH 1713/3904] Test --- src/cc/rogue/misc.c | 8 ++++---- src/cc/rogue/rogue.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 87bc40b4d..f3aadae73 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -348,10 +348,10 @@ check_level(struct rogue_state *rs) void chg_str(int amt) { - auto str_t comp; + auto str_t comp = 0; if (amt == 0) - return; + return; add_str(&pstats.s_str, amt); comp = pstats.s_str; if (ISRING(LEFT, R_ADDSTR)) @@ -555,12 +555,12 @@ call_it(struct rogue_state *rs,struct obj_info *info) } else if (!info->oi_guess) { - msg(rs,terse ? "call it: " : "what do you want to call it? "); + msg(rs,terse ? (char *)"call it: " : (char *)"what do you want to call it? "); if (get_str(rs,prbuf, stdscr) == NORM) { if (info->oi_guess != NULL) free(info->oi_guess); - info->oi_guess = malloc((unsigned int) strlen(prbuf) + 1); + info->oi_guess = (char *)malloc((unsigned int) strlen(prbuf) + 1); strcpy(info->oi_guess, prbuf); } } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index a496426dd..902e71aeb 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -139,7 +139,7 @@ int32_t rogue_replay(uint64_t seed) } if ( num > 0 ) { - rs = calloc(1,sizeof(*rs)); + rs = (struct rogue_state *)calloc(1,sizeof(*rs)); rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; From e968da8ecb421451284b4d5d05f368c02c308c87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:46:14 -1100 Subject: [PATCH 1714/3904] -auto --- src/cc/rogue/misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index f3aadae73..21460dbde 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -348,7 +348,8 @@ check_level(struct rogue_state *rs) void chg_str(int amt) { - auto str_t comp = 0; + //auto + str_t comp; if (amt == 0) return; From 830ecc52b827d3e7588489f82a0b68a53b5bb98a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:47:42 -1100 Subject: [PATCH 1715/3904] More files --- src/cc/cclib.cpp | 4 ++-- src/cc/rogue/misc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8d1d7d379..e1bc4bea6 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -422,7 +422,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/mdport.c" #include "rogue/misc.c" #include "rogue/monsters.c" -/*#include "rogue/move.c" +#include "rogue/move.c" #include "rogue/new_level.c" #include "rogue/options.c" #include "rogue/pack.c" @@ -431,7 +431,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/rings.c" #include "rogue/rip.c" #include "rogue/rooms.c" -#include "rogue/save.c" +/*#include "rogue/save.c" #include "rogue/scrolls.c" #include "rogue/state.c" #include "rogue/sticks.c" diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 21460dbde..775878450 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -348,7 +348,7 @@ check_level(struct rogue_state *rs) void chg_str(int amt) { - //auto + //auto jl777: strange compiler error str_t comp; if (amt == 0) From daf4cfbe0c3d685cd263af5b8a343952a3f7c417 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:51:07 -1100 Subject: [PATCH 1716/3904] Fix --- src/cc/rogue/fight.c | 2 +- src/cc/rogue/pack.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 31c29c62c..6985b6d35 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -16,7 +16,7 @@ #include #include "rogue.h" -#define EQSTR(a, b) (strcmp(a, b) == 0) +//#define EQSTR(a, b) (strcmp(a, b) == 0) char *h_names[] = { /* strings for hitting */ " scored an excellent hit on ", diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 8c92718b5..6776654fe 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -275,11 +275,9 @@ inventory(struct rogue_state *rs,THING *list, int type) if (n_objs == 0) { if (terse) - msg(rs,type == 0 ? "empty handed" : - "nothing appropriate"); + msg(rs,type == 0 ? (char *)"empty handed" : (char *)"nothing appropriate"); else - msg(rs,type == 0 ? "you are empty handed" : - "you don't have anything appropriate"); + msg(rs,type == 0 ? (char *)"you are empty handed" : (char *)"you don't have anything appropriate"); return FALSE; } end_line(rs); From 6c436c81c18b65b1b5eb05bcca05303d197b6284 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:52:03 -1100 Subject: [PATCH 1717/3904] Enable all files --- src/cc/cclib.cpp | 4 ++-- src/cc/rogue/pack.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e1bc4bea6..d0365b18b 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -431,14 +431,14 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/rings.c" #include "rogue/rip.c" #include "rogue/rooms.c" -/*#include "rogue/save.c" +#include "rogue/save.c" #include "rogue/scrolls.c" #include "rogue/state.c" #include "rogue/sticks.c" #include "rogue/things.c" #include "rogue/weapons.c" #include "rogue/wizard.c" -#include "rogue/xcrypt.c"*/ +#include "rogue/xcrypt.c" #else #include "sudoku.cpp" diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 6776654fe..8385f95dd 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -358,7 +358,7 @@ picky_inven(struct rogue_state *rs) msg(rs,"a) %s", inv_name(pack, FALSE)); else { - msg(rs,terse ? "item: " : "which item do you wish to inventory: "); + msg(rs,terse ? (char *)"item: " : (char *)"which item do you wish to inventory: "); mpos = 0; if ((mch = readchar(rs)) == ESCAPE) { From e838265e564f7b42ff0ff784a0014cfcb06ef408 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:53:36 -1100 Subject: [PATCH 1718/3904] -auto --- src/cc/rogue/save.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index e12d14ea9..4fdc1a495 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -36,7 +36,8 @@ save_game(struct rogue_state *rs) { FILE *savef; int c; - auto char buf[MAXSTR]; + //auto + char buf[MAXSTR]; /* * get file name @@ -169,8 +170,10 @@ restore(struct rogue_state *rs,char *file, char **envp) FILE *inf; int syml; extern char **environ; - auto char buf[MAXSTR]; - auto STAT sbuf2; + //auto + char buf[MAXSTR]; + //auto + STAT sbuf2; int lines, cols; if (strcmp(file, "-r") == 0) From 007271afc07e92718338f6682c55cf2ae883afa9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:56:02 -1100 Subject: [PATCH 1719/3904] Test --- src/cc/rogue/save.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 4fdc1a495..50de2069a 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -168,13 +168,12 @@ bool restore(struct rogue_state *rs,char *file, char **envp) { FILE *inf; - int syml; + int syml,lines, cols; extern char **environ; //auto char buf[MAXSTR]; //auto STAT sbuf2; - int lines, cols; if (strcmp(file, "-r") == 0) file = file_name; From 5429a5057b18bcc1ed67e78763d8943e3a9a6741 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 04:57:26 -1100 Subject: [PATCH 1720/3904] L --- src/cc/rogue/save.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 50de2069a..8dcb65194 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -168,7 +168,7 @@ bool restore(struct rogue_state *rs,char *file, char **envp) { FILE *inf; - int syml,lines, cols; + int syml,l, cols; extern char **environ; //auto char buf[MAXSTR]; @@ -196,15 +196,15 @@ restore(struct rogue_state *rs,char *file, char **envp) return FALSE; } encread(buf,80,inf); - sscanf(buf,"%d x %d\n", &lines, &cols); + sscanf(buf,"%d x %d\n", &l, &cols); initscr(); /* Start up cursor package */ keypad(stdscr, 1); - if (lines > LINES) + if (l > LINES) { endwin(); - printf("Sorry, original game was played on a screen with %d lines.\n",lines); + printf("Sorry, original game was played on a screen with %d lines.\n",l); printf("Current screen only has %d lines. Unable to restore game\n",LINES); return(FALSE); } From 4ccb3b5d9c365f1ec8ffc50eb1d7aeba794f3d87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:02:03 -1100 Subject: [PATCH 1721/3904] THING * --- src/cc/rogue/state.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 60a83c333..f18ee1e5f 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -78,7 +78,7 @@ rs_write(FILE *savef, void *ptr, size_t size) if (write_error) return(WRITESTAT); - if (encwrite(ptr, size, savef) != size) + if (encwrite((char *)ptr, size, savef) != size) write_error = 1; return(WRITESTAT); @@ -90,7 +90,7 @@ rs_read(FILE *inf, void *ptr, size_t size) if (read_error || format_error) return(READSTAT); - if (encread(ptr, size, inf) != size) + if (encread((char *)ptr, size, inf) != size) read_error = 1; return(READSTAT); @@ -554,7 +554,7 @@ rs_read_new_string(FILE *inf, char **s) buf = NULL; else { - buf = malloc(len); + buf = (char *)malloc(len); if (buf == NULL) read_error = TRUE; @@ -1468,7 +1468,7 @@ rs_read_object_reference(FILE *inf, THING *list, THING **item) rs_read_int(inf, &i); - *item = get_list_item(list,i); + *item = (THING *)get_list_item(list,i); return(READSTAT); } @@ -1670,7 +1670,7 @@ rs_read_thing(FILE *inf, THING *t) { THING *obj; - item = get_list_item(lvl_obj, index); + item = (THING *)get_list_item(lvl_obj, index); if (item != NULL) { @@ -1702,7 +1702,7 @@ rs_fix_thing(THING *t) if (t->t_reserved < 0) return; - item = get_list_item(mlist,t->t_reserved); + item = (THING *)get_list_item(mlist,t->t_reserved); if (item != NULL) { @@ -1816,7 +1816,7 @@ rs_read_thing_reference(FILE *inf, THING *list, THING **item) if (i == -1) *item = NULL; else - *item = get_list_item(list,i); + *item = (THING *)get_list_item(list,i); return(READSTAT); } From 1b34dade6682612b9365e0d77e883ea35b281780 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:04:42 -1100 Subject: [PATCH 1722/3904] Lcurses --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index ad9842f09..303adf657 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,7 +100,7 @@ EXTRA_LIBRARIES += \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_CLI) \ - libzcash.a + libzcash.a -lcurses if ENABLE_WALLET BITCOIN_INCLUDES += $(BDB_CPPFLAGS) EXTRA_LIBRARIES += $(LIBBITCOIN_WALLET) From cc89099ff7284677ac8fdbf1ba9157543f89bf5c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:08:52 -1100 Subject: [PATCH 1723/3904] libcurses.a --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 303adf657..39844c80a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,7 +100,7 @@ EXTRA_LIBRARIES += \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_CLI) \ - libzcash.a -lcurses + libzcash.a libcurses.a if ENABLE_WALLET BITCOIN_INCLUDES += $(BDB_CPPFLAGS) EXTRA_LIBRARIES += $(LIBBITCOIN_WALLET) From 495c41f313100c3ac6a9a10280aac6c8dce577ed Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:11:37 -1100 Subject: [PATCH 1724/3904] -lcurses --- src/Makefile.am | 2 +- src/cc/makerogue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 39844c80a..ad9842f09 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,7 +100,7 @@ EXTRA_LIBRARIES += \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_CLI) \ - libzcash.a libcurses.a + libzcash.a if ENABLE_WALLET BITCOIN_INCLUDES += $(BDB_CPPFLAGS) EXTRA_LIBRARIES += $(LIBBITCOIN_WALLET) diff --git a/src/cc/makerogue b/src/cc/makerogue index c7b62e259..2ac20e6e6 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp +gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lcurses #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From 23408a86efcd71e6ee36c0ea14fb14f625c953b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:15:40 -1100 Subject: [PATCH 1725/3904] Nurses --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 2ac20e6e6..f7ee26669 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; #./configure # only need this first time make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lcurses +gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From fe86924f94239b1a983209a0348e622a021b0637 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:17:06 -1100 Subject: [PATCH 1726/3904] -lncurses --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index ad9842f09..8503ebb56 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -572,7 +572,7 @@ komodod_LDADD += \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) \ - libcc.so + libcc.so -lncurses if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) From 00a3970bef861feaf1d5f7b34bf670a41b812038 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:19:46 -1100 Subject: [PATCH 1727/3904] #include "rogue/xcrypt.c" --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index d0365b18b..41dfe8cc1 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -419,6 +419,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/list.c" #include "rogue/mach_dep.c" #include "rogue/rogue.c" +#include "rogue/xcrypt.c" #include "rogue/mdport.c" #include "rogue/misc.c" #include "rogue/monsters.c" @@ -438,7 +439,6 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #include "rogue/things.c" #include "rogue/weapons.c" #include "rogue/wizard.c" -#include "rogue/xcrypt.c" #else #include "sudoku.cpp" From ff22edb4db7e716112d1db26cd1036d0c2194781 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:20:34 -1100 Subject: [PATCH 1728/3904] Test --- src/cc/rogue/xcrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/xcrypt.c b/src/cc/rogue/xcrypt.c index bbf5d76ac..b8a1adc03 100644 --- a/src/cc/rogue/xcrypt.c +++ b/src/cc/rogue/xcrypt.c @@ -590,7 +590,7 @@ des_cipher(const char *in, char *out, int salt, int count) memcpy(out, x, sizeof x); return(retval); } - +xxxx char * xcrypt(const char *key, const char *setting) { From 9b5f5ca0ada6e4ad7ba55bc2697e9544beceb316 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:22:39 -1100 Subject: [PATCH 1729/3904] -const --- src/cc/rogue/xcrypt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/xcrypt.c b/src/cc/rogue/xcrypt.c index b8a1adc03..671e20718 100644 --- a/src/cc/rogue/xcrypt.c +++ b/src/cc/rogue/xcrypt.c @@ -590,9 +590,9 @@ des_cipher(const char *in, char *out, int salt, int count) memcpy(out, x, sizeof x); return(retval); } -xxxx + char * -xcrypt(const char *key, const char *setting) +xcrypt( char *key, char *setting) { int i; unsigned int count, salt, l, r0, r1, keybuf[2]; From 171d73ed67486673520dd78cb9dff981237ebd4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:28:39 -1100 Subject: [PATCH 1730/3904] Ignores --- .gitignore | 6 ++++++ src/cc/rogue/test.zip | Bin 5451 -> 0 bytes 2 files changed, 6 insertions(+) delete mode 100644 src/cc/rogue/test.zip diff --git a/.gitignore b/.gitignore index 47f490f20..ebaa71f4d 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,9 @@ src/komodo-tx.exe src/cryptoconditions/compile + +src/cc/rogue/rogue + +src/cc/rogue/rogue.so + +src/cc/rogue/test.zip diff --git a/src/cc/rogue/test.zip b/src/cc/rogue/test.zip deleted file mode 100644 index b0c54f6d0403f64cc535b2bc756a3d75da122cae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5451 zcmZ{oRa6uVw}yup7)lUH>FzFR0qI6M1VtEhC<%vdq@|JWmJZ3Gr3M(fO9|-~7zUX0 zedoVB>-_s>?|t#U@7>;OJ$jm0*kk|z00gjTk=Oa+dD9s8&+1tT0FVJ_0Y>h2Zten3 zZ*2wKT)>`o{O)f*+Zh?+0kGas8Cnuh8(MmL5dbi-uQ33C|8+UG!jmC$q7n#mAh7RfkNucsgzRU=kJ;{Y06`TD>HRzsviWuu-W! zTP)yVBg22!I}h1CBy-u>*r@9+jC6mX{E}cLpQgM{$WlY*@SN9l?=n7drAzva0TG3y zRE;w;ZO46X8U93to24b$i`9ft7|RlypFk}x68jI^i6<0J41(LitV=)N6rBgT&HNQG z@fP2!XZW+J?b!J^C@x>Or(U=)y!k6x#Qy^ODCiNyhfa`Hgi}a~Kf%Pfe=7ah zu{mP1!W%HG?VORivC!N>fN9h}p3Jc_q?PZcyLL7JU+RvVRZBNq(<@OwC#iS{BUlP$ zG}!-UJ~lBQojVNRC^tM)YOXXaMt@wKd3XpE`o*98?AF0j)KOHWh! z0-AR{R!qG%l-5-#6N0|YkCrQ#2|=A+9`Kg2{qdl1L#tI zga~+jy0(pi0?B(jvb+ab+2f>8a;6h5%iGfEq$7IrTW70JSw4fib5n439}IIPr3Gs- zajU|*PnD>u=y0J%^?_l3$$Hg~OU;i)63MqV{>M3&lG-|X{VvEY8v5FeKo+ezm9sG< zxpwYfPv>?NSb~Zq=gNg#3)UT!T;(UMMvbyAvBJ`FP z==0;jX7hYt*%tQ#ANP7RlaeNcb|h*3D%`?3Y4ytzh%gK0_~XoQ`K#@>5#Uswef#@k z$|LVmB&?YqE!q;a z)l>Sdmv}XIlVi+SC7pQ#KO8UA7wFSJQtd^Wb-is_lgQihW+s!?T2n5%0I*v@b?y9xl(&&#AY$RY{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&oZuDnSPiDZa>jyG5C}-7y&Cf@jP)5G$xnR0f<9Wlv(RYLrkEmlK&0+Xfz@}wv`a{@WW%Obqwuug= zxy|g9qiF=i**lBzC~`F$AoC&;6K8{(FFl^lPmm_8u91n9&otVJfL!`EzsPhqTa3=V z1jB$gSr2$Em|sLTiQCio(yZwvfCm7PPm3+E5wGLL^smQO$eKjHw8)%vR%`@C?h%7* z1^eylw1s+&ff>QFlQXYqcqV)Cd!jS#6hjI8`IgHCuX!0=D&*TWs0;~T5h&Ih^?1U_ zsxfeM@K=bI9f%~$=Z4WvVKNE8`dpk!)kMT_+v>g(6uj-#adHpu^}8P@+^1s%1OoXB z&Pmv3GNQaVUNR~OhTExyyh*^JTusk@i=_3+Bbo<#R&63S)2YL_NbLLWj_Twlv%;kq zp3uJVVZdsqg01Ct)4i9P`E%E2A=)aHz?8lb9J`9UeA$9Ut&6>h7wy2YwMcz-e&p}^ z_51iVT6O{joWSeKkiNRk4M2m{oWX`PM7w zCjLljv+tVj@!zzm)LRBUO$ Date: Sat, 2 Feb 2019 05:29:34 -1100 Subject: [PATCH 1731/3904] Delay replay --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 902e71aeb..c810a313d 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -399,7 +399,7 @@ playit(struct rogue_state *rs) //fprintf(stderr,"replaydone\n"); sleep(3); return; } - //usleep(100000); + usleep(50000); } else { From faf6323ad4c2e03d4f754b4784dc2c8b70a75a9d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:33:47 -1100 Subject: [PATCH 1732/3904] Bigger buffer --- src/cc/rogue/rogue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 040c9a97d..fff9203a0 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -319,7 +319,7 @@ struct rogue_state char *keystrokes; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter; - char buffered[64]; + char buffered[8192]; }; int rogue(int argc, char **argv, char **envp); From 405e1e0c1707665e7cfb8f7e4549e8ae92222974 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:39:05 -1100 Subject: [PATCH 1733/3904] Gui mode for seed --- src/cc/rogue/main.c | 2 +- src/cc/rogue/rogue.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 681d51e31..68dca0e98 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -32,7 +32,7 @@ int rogue(int argc, char **argv, char **envp); int main(int argc, char **argv, char **envp) { uint64_t seed; FILE *fp = 0; - if ( argc > 1 && (fp=fopen(argv[1],"rb")) == 0 ) + if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { seed = atol(argv[1]); fprintf(stderr,"replay %llu\n",(long long)seed); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index c810a313d..010b66c9f 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -166,7 +166,9 @@ int rogue(int argc, char **argv, char **envp) { char *env; int lowtime; struct rogue_state *rs = &globalR; memset(rs,0,sizeof(*rs)); - rs->seed = 777; + if ( argc == 3 && strcmp(argv[2],"gui") == 0 ) + rs->seed = atol(argv[1]); + else rs->seed = 777; rs->guiflag = 1; md_init(); From 6ecbc31948e3425f38b590981fbe7d6d0ff1890c Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 2 Feb 2019 21:41:40 +0500 Subject: [PATCH 1734/3904] added skipping asset validation for SEC chain --- src/cc/assets.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 2433473b9..968659470 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -146,6 +146,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti outputs = inputs = 0; preventCCvins = preventCCvouts = -1; + if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() < 144073) + return true; + if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); From 71225aaa3f0e8e3c5f1e4c03597ef817b89a230a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 05:43:37 -1100 Subject: [PATCH 1735/3904] Reduce buffer size --- src/cc/rogue/rogue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index fff9203a0..472b2755a 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -319,7 +319,7 @@ struct rogue_state char *keystrokes; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter; - char buffered[8192]; + char buffered[512]; }; int rogue(int argc, char **argv, char **envp); From 43f5b8c00fd74a9e733eb6710398466594233c03 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 2 Feb 2019 21:56:22 +0500 Subject: [PATCH 1736/3904] added MGNX chain old token support --- src/cc/assets.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 968659470..6aae09dd3 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -146,7 +146,11 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti outputs = inputs = 0; preventCCvins = preventCCvouts = -1; - if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() < 144073) + // add specific chains exceptions for old token support: + if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) + return true; + + if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) return true; if (numvouts == 0) From dbc619112f89f3ecab70bac745bec8ac141a98b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:43:40 -1100 Subject: [PATCH 1737/3904] rogue: newgame, txidinfo, pending roc --- src/cc/cclib.cpp | 25 +++ src/cc/rogue_rpc.cpp | 398 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 423 insertions(+) create mode 100644 src/cc/rogue_rpc.cpp diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 41dfe8cc1..b6ba2eb93 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -55,6 +55,8 @@ CClib_methods[] = { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, #ifdef BUILD_ROGUE { (char *)"rogue", (char *)"newgame", (char *)"buyin", 0, 1, 'N', EVAL_ROGUE }, + { (char *)"rogue", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_ROGUE }, + { (char *)"rogue", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_ROGUE }, { (char *)"rogue", (char *)"register", (char *)"txid [inventory]", 1, 2, 'R', EVAL_ROGUE }, { (char *)"rogue", (char *)"progress", (char *)"txid fname", 2, 2, 'P', EVAL_ROGUE }, { (char *)"rogue", (char *)"claimwin", (char *)"txid", 1, 1, 'W', EVAL_ROGUE }, @@ -76,6 +78,11 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { return(true); } +UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_progress(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_claimwin(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -92,6 +99,23 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) if ( cp->evalcode == EVAL_ROGUE ) { rogue_replay(777); + if ( strcmp(method,"newgame") == 0 ) + return(rogue_newgame(txfee,cp,params)); + else if ( strcmp(method,"register") == 0 ) + return(rogue_register(txfee,cp,params)); + else if ( strcmp(method,"progress") == 0 ) + return(rogue_progress(txfee,cp,params)); + else if ( strcmp(method,"claimwin") == 0 ) + return(rogue_claimwin(txfee,cp,params)); + else if ( strcmp(method,"extract") == 0 ) + return(rogue_extract(txfee,cp,params)); + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid rogue method")); + result.push_back(Pair("method",method)); + return(result); + } } #else if ( cp->evalcode == EVAL_SUDOKU ) @@ -406,6 +430,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para } #ifdef BUILD_ROGUE +#include "rogue_rpc.cpp" #include "rogue/vers.c" #include "rogue/extern.c" #include "rogue/armor.c" diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp new file mode 100644 index 000000000..536b6e590 --- /dev/null +++ b/src/cc/rogue_rpc.cpp @@ -0,0 +1,398 @@ + +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include "cJSON.h" + + +//////////////////////// start of CClib interface + + +CScript rogue_newgameopret(int64_t buyin) +{ + CScript opret; uint8_t evalcode = EVAL_ROGUE; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << buyin); + return(opret); +} + +/*CScript rogue_solutionopret(char *solution,uint32_t timestamps[81]) +{ + CScript opret; uint8_t evalcode = EVAL_ROGUE; std::string str(solution); std::vector data; int32_t i; + for (i=0; i<81; i++) + { + data.push_back((timestamps[i] >> 24) & 0xff); + data.push_back((timestamps[i] >> 16) & 0xff); + data.push_back((timestamps[i] >> 8) & 0xff); + data.push_back(timestamps[i] & 0xff); + } + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'S' << str << data); + return(opret); +} + +uint8_t rogue_solutionopreturndecode(char solution[82],uint32_t timestamps[81],CScript scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; std::string str; std::vector data; int32_t i,ind; uint32_t x; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> str; ss >> data) != 0 && e == EVAL_ROGUE && f == 'S' ) + { + if ( data.size() == 81*sizeof(uint32_t) && str.size() == 81 ) + { + strcpy(solution,str.c_str()); + for (i=ind=0; i<81; i++) + { + if ( solution[i] < '1' || solution[i] > '9' ) + break; + x = data[ind++]; + x <<= 8, x |= (data[ind++] & 0xff); + x <<= 8, x |= (data[ind++] & 0xff); + x <<= 8, x |= (data[ind++] & 0xff); + timestamps[i] = x; + } + if ( i == 81 ) + return(f); + } else fprintf(stderr,"datasize %d sol[%d]\n",(int32_t)data.size(),(int32_t)str.size()); + } + return(0); +}*/ + +uint8_t rogue_newgameopreturndecode(int64_t &buyin,CScript scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin) != 0 && e == EVAL_ROGUE && f == 'G' ) + { + return(f); + } + return(0); +} + +UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,amount = 0; + if ( params != 0 ) + { + if ( (jsonstr= jprint(params,0)) != 0 ) + { + if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) + { + jsonstr[strlen(jsonstr)-1] = 0; + jsonstr++; + } + amount = atof(jsonstr) * COIN + 0.0000000049; + free(jsonstr); + } + } + mypk = pubkey2pk(Mypubkey()); + roguepk = GetUnspendable(cp,0); + result.push_back(Pair("result","success")); + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method","newgame")); + if ( amount == 0 ) + result.push_back(Pair("type","newbie")); + else result.push_back(Pair("type","buyin")); + result.push_back(Pair("amount",ValueFromAmount(amount))); + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,3*txfee,16,cp->unspendableCCaddr)) >= 3*txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(amount)); + if ( rawtx.size() > 0 ) + { + CTransaction tx; + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + result.push_back(Pair("txid",tx.GetHash().ToString())); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + } + return(result); +} + +UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + +UniValue rogue_progress(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + +UniValue rogue_claimwin(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + +UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + +UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); int32_t numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; uint64_t amount; CBlockIndex *pindex; + if ( params != 0 ) + { + result.push_back(Pair("result","success")); + if ( (txidstr= jprint(params,0)) != 0 ) + { + if ( txidstr[0] == '"' && txidstr[strlen(txidstr)-1] == '"' ) + { + txidstr[strlen(txidstr)-1] = 0; + txidstr++; + } + //printf("params -> (%s)\n",txidstr); + decode_hex((uint8_t *)&txid,32,txidstr); + txid = revuint256(txid); + result.push_back(Pair("txid",txid.GetHex())); + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( rogue_newgameopreturndecode(buyin,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + result.push_back(Pair("result","success")); + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + result.push_back(Pair("height",pindex->GetHeight())); + Getscriptaddress(CCaddr,tx.vout[1].scriptPubKey); + result.push_back(Pair("rogueaddr",CCaddr)); + result.push_back(Pair("buyin",ValueFromAmount(buyin))); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt extract rogue_generate opreturn")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt find txid")); + } + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","missing txid in params")); + } + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method","txidinfo")); + return(result); +} + +UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); + char coinaddr[64]; uint64_t seed; int64_t nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t ht,vout,numvouts; CPubKey roguepk; CBlockIndex *pindex; + std::vector > unspentOutputs; + roguepk = GetUnspendable(cp,0); + GetCCaddress(cp,coinaddr,roguepk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( it->second.satoshis != txfee || vout != 0 ) + continue; + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) + { + if ( rogue_newgameopreturndecode(amount,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + UniValue obj(UniValue::VOBJ); + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + ht = pindex->GetHeight(); + obj.push_back(Pair("height",ht)); + obj.push_back(Pair("start",ht+10)); + if ( komodo_nextheight() > ht+10 ) + { + if ( pindex= komodo_chainactive(ht+10)) != 0 ) + { + hashBlock = pindex->GetBlockHash(); + obj.push_back(Pair("starthash",hashBlock.ToString().c_str())); + memset(&seed,&hashBlock,sizeof(seed)); + seed &= (1LL << 63) - 1; + obj.push_back(Pair("seed",(int64_t)seed)); + } + } + } + obj.push_back(Pair("buyin",ValueFromAmount(amount))); + obj.push_back(Pair("txid",txid.GetHex())); + a.push_back(obj); + total += amount; + } + } + } + } + result.push_back(Pair("result","success")); + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method","pending")); + result.push_back(Pair("pending",a)); + result.push_back(Pair("numpending",a.size())); + result.push_back(Pair("total",ValueFromAmount(total))); + return(result); +} + +#ifdef notyest +UniValue rogue_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); int32_t i,j,good,ind,n,numvouts; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],checkaddr[64],CCaddr[64],*solution=0,unsolved[82]; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; uint256 hashBlock; + mypk = pubkey2pk(Mypubkey()); + memset(timestamps,0,sizeof(timestamps)); + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method","solution")); + good = 0; + if ( params != 0 ) + { + if ( (jsonstr= jprint(params,0)) != 0 ) + { + if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) + { + jsonstr[strlen(jsonstr)-1] = 0; + jsonstr++; + } + newstr = (char *)malloc(strlen(jsonstr)+1); + for (i=j=0; jsonstr[i]!=0; i++) + { + if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) + { + newstr[j++] = '"'; + i += 2; + } else newstr[j++] = jsonstr[i]; + } + newstr[j] = 0; + params = cJSON_Parse(newstr); + } else params = 0; + if ( params != 0 ) + { + if ( (n= cJSON_GetArraySize(params)) > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 ) + { + for (i=2; i '9' ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","illegal solution")); + return(result); + } + vals9[i][j] = solution[ind++] - '0'; + } + rogue_privkey(priv32,vals9); + priv2addr(coinaddr,pub33,priv32); + pk = buf2pk(pub33); + GetCCaddress(cp,CCaddr,pk); + result.push_back(Pair("rogueaddr",CCaddr)); + balance = CCaddress_balance(CCaddr); + result.push_back(Pair("amount",ValueFromAmount(balance))); + if ( rogue_captcha(1,timestamps,komodo_nextheight()) < 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","captcha failure")); + return(result); + } + else + { + if ( (txidstr= jstri(params,0)) != 0 ) + { + decode_hex((uint8_t *)&txid,32,txidstr); + txid = revuint256(txid); + result.push_back(Pair("txid",txid.GetHex())); + if ( CCgettxout(txid,0,1) < 0 ) + result.push_back(Pair("error","already solved")); + else if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey); + if ( strcmp(checkaddr,CCaddr) != 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","wrong solution")); + result.push_back(Pair("yours",CCaddr)); + return(result); + } + if ( rogue_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + for (i=0; i<81; i++) + { + if ( unsolved[i] < '1' || unsolved[i] > '9') + continue; + else if ( unsolved[i] != solution[i] ) + { + printf("i.%d [%c] != [%c]\n",i,unsolved[i],solution[i]); + result.push_back(Pair("error","wrong rogue solved")); + break; + } + } + if ( i == 81 ) + good = 1; + } else result.push_back(Pair("error","cant decode rogue")); + } else result.push_back(Pair("error","couldnt find rogue")); + } + if ( good != 0 ) + { + mtx.vin.push_back(CTxIn(txid,0,CScript())); + if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) + { + mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); + rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,rogue_solutionopret(solution,timestamps)); + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("hex",rawtx)); + } + else result.push_back(Pair("error","couldnt finalize CCtx")); + } else result.push_back(Pair("error","couldnt find funds in solution address")); + } + } + } + } + else + { + printf("n.%d params.(%s)\n",n,jprint(params,0)); + result.push_back(Pair("error","couldnt get all params")); + } + return(result); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parse parameters")); + result.push_back(Pair("parameters",newstr)); + return(result); + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","missing parameters")); + return(result); +} +#endif + From 65c54049a915ea5db9a4f2b7dee0ae3b5172de35 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:44:41 -1100 Subject: [PATCH 1738/3904] Syntax --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 536b6e590..b3f13777c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -83,7 +83,7 @@ uint8_t rogue_newgameopreturndecode(int64_t &buyin,CScript scriptPubKey) UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,amount = 0; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,amount = 0; if ( params != 0 ) { if ( (jsonstr= jprint(params,0)) != 0 ) From 06d45f433b9b1e340b109cb7058b66e63a09da99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:45:43 -1100 Subject: [PATCH 1739/3904] CBlockIndex *komodo_chainactive(int32_t height) --- src/cc/CCinclude.h | 1 + src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 4da696547..07c5e9491 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -135,6 +135,7 @@ void CCclearvars(struct CCcontract_info *cp); UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params); UniValue CClib_info(struct CCcontract_info *cp); CBlockIndex *komodo_blockindex(uint256 hash); +CBlockIndex *komodo_chainactive(int32_t height); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b3f13777c..91429cafe 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -200,7 +200,7 @@ UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); - char coinaddr[64]; uint64_t seed; int64_t nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t ht,vout,numvouts; CPubKey roguepk; CBlockIndex *pindex; + char coinaddr[64]; uint64_t seed; int64_t amount,nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t ht,vout,numvouts; CPubKey roguepk; CBlockIndex *pindex; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,roguepk); From 73445259d1d556c064f0412df2d679d17726183b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:46:08 -1100 Subject: [PATCH 1740/3904] ( --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 91429cafe..c1a6102d0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -226,7 +226,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) obj.push_back(Pair("start",ht+10)); if ( komodo_nextheight() > ht+10 ) { - if ( pindex= komodo_chainactive(ht+10)) != 0 ) + if ( (pindex= komodo_chainactive(ht+10)) != 0 ) { hashBlock = pindex->GetBlockHash(); obj.push_back(Pair("starthash",hashBlock.ToString().c_str())); From fa2851ccfabefb147e051841c5aff3f9055051b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:47:56 -1100 Subject: [PATCH 1741/3904] Test --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c1a6102d0..50335be72 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -148,7 +148,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; uint64_t amount; CBlockIndex *pindex; + UniValue result(UniValue::VOBJ); int32_t numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; uint64_t buyin; CBlockIndex *pindex; if ( params != 0 ) { result.push_back(Pair("result","success")); @@ -230,8 +230,8 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { hashBlock = pindex->GetBlockHash(); obj.push_back(Pair("starthash",hashBlock.ToString().c_str())); - memset(&seed,&hashBlock,sizeof(seed)); - seed &= (1LL << 63) - 1; + memcpy(&seed,&hashBlock,sizeof(seed)); + seed &= (1LL << 62) - 1; obj.push_back(Pair("seed",(int64_t)seed)); } } From 381c067e04488a647ffed45277b62426bfaa5af2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:49:07 -1100 Subject: [PATCH 1742/3904] U --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 50335be72..2ed5236b9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -148,7 +148,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; uint64_t buyin; CBlockIndex *pindex; + UniValue result(UniValue::VOBJ); int32_t numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; int64_t buyin; CBlockIndex *pindex; if ( params != 0 ) { result.push_back(Pair("result","success")); From 078f999bc462e7a70729ea842cac1649ccd9f548 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:54:25 -1100 Subject: [PATCH 1743/3904] Support txidinfo and pending --- src/cc/cclib.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b6ba2eb93..2c20bfcc0 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -54,11 +54,11 @@ CClib_methods[] = { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, #ifdef BUILD_ROGUE - { (char *)"rogue", (char *)"newgame", (char *)"buyin", 0, 1, 'N', EVAL_ROGUE }, - { (char *)"rogue", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_ROGUE }, - { (char *)"rogue", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_ROGUE }, + { (char *)"rogue", (char *)"newgame", (char *)"buyin", 0, 1, 'G', EVAL_ROGUE }, + { (char *)"rogue", (char *)"txidinfo", (char *)"txid", 1, 1, 'I', EVAL_ROGUE }, + { (char *)"rogue", (char *)"pending", (char *)"", 0, 0, 'P', EVAL_ROGUE }, { (char *)"rogue", (char *)"register", (char *)"txid [inventory]", 1, 2, 'R', EVAL_ROGUE }, - { (char *)"rogue", (char *)"progress", (char *)"txid fname", 2, 2, 'P', EVAL_ROGUE }, + { (char *)"rogue", (char *)"progress", (char *)"txid fname", 2, 2, 'K', EVAL_ROGUE }, { (char *)"rogue", (char *)"claimwin", (char *)"txid", 1, 1, 'W', EVAL_ROGUE }, { (char *)"rogue", (char *)"extract", (char *)"txid item", 2, 2, 'X', EVAL_ROGUE }, #else @@ -101,6 +101,10 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) rogue_replay(777); if ( strcmp(method,"newgame") == 0 ) return(rogue_newgame(txfee,cp,params)); + else if ( strcmp(method,"pending") == 0 ) + return(rogue_pending(txfee,cp,params)); + else if ( strcmp(method,"txidinfo") == 0 ) + return(rogue_txidinfo(txfee,cp,params)); else if ( strcmp(method,"register") == 0 ) return(rogue_register(txfee,cp,params)); else if ( strcmp(method,"progress") == 0 ) From 9e70589b1ec09f34e9fddae8813460e111eeee8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:55:50 -1100 Subject: [PATCH 1744/3904] UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); --- src/cc/cclib.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 2c20bfcc0..549db5848 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -79,6 +79,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(true); } UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_progress(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_claimwin(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); From 5683411a18af427b5607def39627817b66c06b1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:58:35 -1100 Subject: [PATCH 1745/3904] More txidinfo --- src/cc/rogue_rpc.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2ed5236b9..81c2b0ba1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -148,7 +148,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; int64_t buyin; CBlockIndex *pindex; + UniValue result(UniValue::VOBJ); int32_t ht,numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; uint64_t seed; int64_t buyin; CBlockIndex *pindex; if ( params != 0 ) { result.push_back(Pair("result","success")); @@ -169,7 +169,22 @@ UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("result","success")); if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) - result.push_back(Pair("height",pindex->GetHeight())); + { + ht = pindex->GetHeight(); + obj.push_back(Pair("height",ht)); + obj.push_back(Pair("start",ht+10)); + if ( komodo_nextheight() > ht+10 ) + { + if ( (pindex= komodo_chainactive(ht+10)) != 0 ) + { + hashBlock = pindex->GetBlockHash(); + obj.push_back(Pair("starthash",hashBlock.ToString().c_str())); + memcpy(&seed,&hashBlock,sizeof(seed)); + seed &= (1LL << 62) - 1; + obj.push_back(Pair("seed",(int64_t)seed)); + } + } + } Getscriptaddress(CCaddr,tx.vout[1].scriptPubKey); result.push_back(Pair("rogueaddr",CCaddr)); result.push_back(Pair("buyin",ValueFromAmount(buyin))); From 5567a8498db410ad664cdf049c85d97928749c22 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 06:59:24 -1100 Subject: [PATCH 1746/3904] result --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 81c2b0ba1..b6b12f64b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -171,17 +171,17 @@ UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); - obj.push_back(Pair("height",ht)); - obj.push_back(Pair("start",ht+10)); + result.push_back(Pair("height",ht)); + result.push_back(Pair("start",ht+10)); if ( komodo_nextheight() > ht+10 ) { if ( (pindex= komodo_chainactive(ht+10)) != 0 ) { hashBlock = pindex->GetBlockHash(); - obj.push_back(Pair("starthash",hashBlock.ToString().c_str())); + result.push_back(Pair("starthash",hashBlock.ToString().c_str())); memcpy(&seed,&hashBlock,sizeof(seed)); seed &= (1LL << 62) - 1; - obj.push_back(Pair("seed",(int64_t)seed)); + result.push_back(Pair("seed",(int64_t)seed)); } } } From 98fc13a132d311e1f4efd65d669784e6d79e87f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:01:24 -1100 Subject: [PATCH 1747/3904] Fix --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b6b12f64b..f9c05220c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -18,6 +18,9 @@ //////////////////////// start of CClib interface +// cclib newgame 17 +// cclib pending 17 +// cclib txidinfo 17 \"35e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f\" CScript rogue_newgameopret(int64_t buyin) @@ -151,7 +154,6 @@ UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); int32_t ht,numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; uint64_t seed; int64_t buyin; CBlockIndex *pindex; if ( params != 0 ) { - result.push_back(Pair("result","success")); if ( (txidstr= jprint(params,0)) != 0 ) { if ( txidstr[0] == '"' && txidstr[strlen(txidstr)-1] == '"' ) From ec7419b6f9507e1a98c7f6d5eeb514268f931ce4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:11:33 -1100 Subject: [PATCH 1748/3904] ROGUE_REGISTRATION --- src/cc/rogue_rpc.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f9c05220c..763408258 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -16,12 +16,15 @@ #include "cJSON.h" +#define ROGUE_REGISTRATION 5 //////////////////////// start of CClib interface +//./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & + // cclib newgame 17 // cclib pending 17 // cclib txidinfo 17 \"35e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f\" - +// ./rogue gui -> creates keystroke files CScript rogue_newgameopret(int64_t buyin) { @@ -127,6 +130,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); return(result); } @@ -174,10 +178,10 @@ UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { ht = pindex->GetHeight(); result.push_back(Pair("height",ht)); - result.push_back(Pair("start",ht+10)); - if ( komodo_nextheight() > ht+10 ) + result.push_back(Pair("start",ht+ROGUE_REGISTRATION)); + if ( komodo_nextheight() > ht+ROGUE_REGISTRATION ) { - if ( (pindex= komodo_chainactive(ht+10)) != 0 ) + if ( (pindex= komodo_chainactive(ht+ROGUE_REGISTRATION)) != 0 ) { hashBlock = pindex->GetBlockHash(); result.push_back(Pair("starthash",hashBlock.ToString().c_str())); @@ -240,10 +244,10 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { ht = pindex->GetHeight(); obj.push_back(Pair("height",ht)); - obj.push_back(Pair("start",ht+10)); - if ( komodo_nextheight() > ht+10 ) + obj.push_back(Pair("start",ht+ROGUE_REGISTRATION)); + if ( komodo_nextheight() > ht+ROGUE_REGISTRATION ) { - if ( (pindex= komodo_chainactive(ht+10)) != 0 ) + if ( (pindex= komodo_chainactive(ht+ROGUE_REGISTRATION)) != 0 ) { hashBlock = pindex->GetBlockHash(); obj.push_back(Pair("starthash",hashBlock.ToString().c_str())); From ad50ae416b368fe80875d310f4a1f5eedb246b0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:18:52 -1100 Subject: [PATCH 1749/3904] Update --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 0e9347a70..5a9a9daa8 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -173,7 +173,7 @@ readchar(struct rogue_state *rs) } if ( rs != 0 && rs->guiflag != 0 ) { - if (rs->num < sizeof(rs->buffered) ) + if ( rs->num < sizeof(rs->buffered) ) { rs->buffered[rs->num++] = ch; if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) From 8aec87e0204fa157d075bf2ee29e9c149cdc0f0c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:21:14 -1100 Subject: [PATCH 1750/3904] Sleep --- src/cc/rogue/io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 5a9a9daa8..19f49d68e 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -177,7 +177,11 @@ readchar(struct rogue_state *rs) { rs->buffered[rs->num++] = ch; if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) + { rs->needflush = (uint32_t)time(NULL); + fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); + sleep(3); + } } else fprintf(stderr,"buffer filled without flushed\n"); } } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); From 9c8b30a918b2f37190d2181b33ca0e7403ecf682 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:29:41 -1100 Subject: [PATCH 1751/3904] Flush on downlevel --- src/cc/rogue/command.c | 4 +++- src/cc/rogue/io.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 34a49a70b..fd7d22178 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -273,7 +273,9 @@ over: when 'R': ring_off(rs); when 'o': option(rs); after = FALSE; when 'c': call(rs); after = FALSE; - when '>': after = FALSE; d_level(rs); + when '>': after = FALSE; d_level(rs); + if ( rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); when '<': after = FALSE; u_level(rs); when '?': after = FALSE; help(rs); when '/': after = FALSE; identify(rs); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 19f49d68e..bdf3c515c 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -179,8 +179,8 @@ readchar(struct rogue_state *rs) if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) { rs->needflush = (uint32_t)time(NULL); - fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); - sleep(3); + //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); + //sleep(3); } } else fprintf(stderr,"buffer filled without flushed\n"); } From 2cf3d519aa54e23d544a99b56c780dfacb642422 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:30:13 -1100 Subject: [PATCH 1752/3904] Flush on level change --- src/cc/rogue/command.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index fd7d22178..fa10d2b3a 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -273,10 +273,15 @@ over: when 'R': ring_off(rs); when 'o': option(rs); after = FALSE; when 'c': call(rs); after = FALSE; + when '>': after = FALSE; d_level(rs); if ( rs->needflush == 0 ) rs->needflush = (uint32_t)time(NULL); + when '<': after = FALSE; u_level(rs); + if ( rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + when '?': after = FALSE; help(rs); when '/': after = FALSE; identify(rs); when 's': search(rs); From 0ee5e12f0810dd211bb8868fb7f192136b9ed46e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 02:37:04 +0800 Subject: [PATCH 1753/3904] New method of ac_notarypay --- src/komodo.h | 75 ++++++++++++++----------- src/komodo_bitcoind.h | 128 ++++++++++++++++++++++++++++++++++-------- src/main.cpp | 46 +++++++++------ src/miner.cpp | 18 +++--- 4 files changed, 187 insertions(+), 80 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index f8575ade8..7860863d2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -37,7 +37,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); -int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block); +int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block); #include "komodo_structs.h" #include "komodo_globals.h" @@ -531,7 +531,7 @@ int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height) } else return(1); } -int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp) +int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp) { static uint256 zero; static FILE *signedfp; int32_t opretlen,nid,offset,k,MoMdepth,matched,len = 0; uint256 MoM,srchash,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; @@ -616,7 +616,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( j == 1 && opretlen >= len+offset-opoffset ) { memset(&MoMoMdata,0,sizeof(MoMoMdata)); - if ( matched == 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) + if ( matched == 0 && signedmask != 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) notarized = 1; if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 ) notarized = 1; @@ -685,7 +685,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - if ( matched != 0 ) + if ( !fJustCheck && matched != 0 ) printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) @@ -695,13 +695,10 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else if ( ASSETCHAINS_NOTARY_PAY != 0 ) - { - fprintf(stderr, "NOT matched NOTARISATION\n"); - return (-2); - } if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { + if ( fJustCheck ) + return(-2); sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; @@ -744,7 +741,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { - if ( notaryid >= 0 && notaryid < 64 ) + if ( !fJustCheck && notaryid >= 0 && notaryid < 64 ) komodo_paxpricefeed(height,&scriptbuf[len],opretlen); } else if ( matched != 0 ) @@ -801,18 +798,18 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys } // int32_t ! -int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) +int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; int32_t staked_era; static int32_t lastStakedEra; - + std::vector notarisations; uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; if ( pindex == 0 ) { fprintf(stderr,"komodo_connectblock null pindex\n"); - return -1; + return(0); } memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); @@ -820,13 +817,13 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) { fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); - return -1; + return(0); } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); - if ( staked_era != lastStakedEra ) + if ( !fJustCheck && staked_era != lastStakedEra ) { uint8_t tmp_pubkeys[64][33]; int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); @@ -842,8 +839,8 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d MIN_TX_VALUE.%lu \n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era,MIN_RECV_SATS); } } + lastStakedEra = staked_era; } - lastStakedEra = staked_era; } numnotaries = komodo_notaries(pubkeys,pindex->GetHeight(),pindex->GetBlockTime()); calc_rmd160_sha256(rmd160,pubkeys[0],33); @@ -857,11 +854,13 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_purge_ccdata((int32_t)pindex->GetHeight()); hwmheight = pindex->GetHeight(); } - komodo_event_rewind(sp,symbol,pindex->GetHeight()); - komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); + if (!fJustCheck) + { + komodo_event_rewind(sp,symbol,pindex->GetHeight()); + komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); + } } komodo_currentheight_set(chainActive.LastTip()->GetHeight()); - int transaction = 0; if ( pindex != 0 ) { height = pindex->GetHeight(); @@ -869,9 +868,12 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; i 1) + break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; @@ -900,7 +902,7 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0) + if ( !fJustCheck && ASSETCHAINS_SYMBOL[0] != 0) { static FILE *signedfp; if ( signedfp == 0 ) @@ -917,7 +919,6 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - transaction = i; printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; @@ -947,9 +948,13 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); - notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); - if ( notaryid == -2 ) - return(-1); + notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); + if ( fJustCheck && notaryid == -2 ) + { + // We see a valid notarisation here, save its location. + notarisations.push_back(i); + } + //fprintf(stderr, "notaryid.%i\n",notaryid); if ( 0 && i > 0 ) { for (k=0; kGetHeight() == hwmheight ) + if ( !fJustCheck && pindex->GetHeight() == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); //KOMODO_INITDONE = (uint32_t)time(NULL); //fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->GetHeight()); - if (notarized = 1) - return(transaction); - else - return(-1); + if (fJustCheck) + { + if (notarisations.size() == 0) + return(0); + if ( notarisations.size() == 1 && notarisations[0] == 1 ) + return(1); + else + return(-1); + } + else return(0); } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e679c4084..a139adf90 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1772,17 +1772,67 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); + +uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) +{ + if ( numnotaries == 0 ) + return(0); + // fetch notarised height + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + uint64_t AmountToPay=0,ret=0; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + // dont think this can happen, just sanity check. + if ( height == notarizedht ) + return(0); + // how many block since last notarisation. + int32_t n = height - notarizedht; + fprintf(stderr, "blocks since last notarisation: %i\n",n); + // multiply the amount possible to be used for each block by the amount of blocks passed + // to get the total posible to be paid for this notarisation. + AmountToPay = ASSETCHAINS_NOTARY_PAY*n; + //fprintf(stderr, "AmountToPay.%lu\n",AmountToPay); + ret = AmountToPay / numnotaries; + fprintf(stderr, "payment per notary.%lu\n",ret); + return(ret); +} + +int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); + +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len) { // fetch notary pubkey array. // Need a better/safer way for notaries era, should really be height based rather than timestamp? - uint64_t total = 0; + uint64_t total = 0, AmountToPay = 0; int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); numSN = numStakedNotaries(staked_pubkeys,staked_era); // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); + + // Check the notarisation is valid, and extract notarised height. + uint64_t voutmask; + uint8_t scriptbuf[10001]; + int32_t isratification,specialtx,notarizedheight; + + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) + { + memcpy(scriptbuf,script,len); + if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) + { + fprintf(stderr, "VALID NOTARIZATION ht.%i\n",notarizedheight); + } + else + { + fprintf(stderr, "INVALID NOTARIZATION ht.%i\n",notarizedheight); + return(0); + } + } else return(0); + + // Calcualte the amount to pay. + AmountToPay = komodo_notarypayamount(notarizedheight,NotarisationNotaries.size()); + // loop over notarisation vins and add transaction to coinbase. // Commented prints here can be used to verify manually the pubkeys match. for (int8_t n = 0; n < NotarisationNotaries.size(); n++) @@ -1798,7 +1848,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar } ptr[34] = OP_CHECKSIG; //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); - txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; + txNew.vout[n+1].nValue = AmountToPay; total += txNew.vout[n+1].nValue; } return(total); @@ -1832,35 +1882,69 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } const CChainParams& chainparams = Params(); const Consensus::Params &consensusParams = chainparams.GetConsensus(); + uint64_t totalsats = 0; CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, height); - uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); - int8_t n = 0, i = 0, matches = 0; - uint64_t total = 0; - //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); - // Check the created coinbase is equal to the coinbase the miner submitted in the block. - BOOST_FOREACH(const CTxOut& txout, txNew.vout) + if ( pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) { - if ( n == 0 ) + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) + { + totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, height, script, scriptlen); + } + else + { + fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); + return(-1); + } + } + + // if notarypay fails, because the notarisation is not valid, exit now as txNew was not created. + if ( totalsats == 0 ) + { + fprintf(stderr, "notary pay RETURNED 0!\n"); + return(-1); + } + + int8_t n = 0, i = 0, matches = 0; + uint64_t total = 0, AmountToPay = 0; + + // get the pay amount from the created tx. + AmountToPay = txNew.vout[1].nValue; + + //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); + // Check the created coinbase pays the correct notaries. + BOOST_FOREACH(const CTxOut& txout, pblock->vtx[0].vout) + { + // skip the coinbase + if ( n == 0 ) { n++; continue; } + // Check the pubkeys match the pubkeys in the notarisation. script = (uint8_t *)&txout.scriptPubKey[0]; scriptlen = (int32_t)txout.scriptPubKey.size(); - if ( txout.nValue == ASSETCHAINS_NOTARY_PAY && scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) { - matches++; - total += txout.nValue; - fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + // check the value is correct + if ( pblock->vtx[0].vout[n].nValue == AmountToPay ) + { + matches++; + total += txout.nValue; + fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + } + else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]); } - n++; + n++; } - if ( matches = n && matches != 0 && total == totalsats ) + if ( matches != 0 && matches == NotarisationNotaries.size() && totalsats == total ) { fprintf(stderr, "VALIDATED.\n" ); return(totalsats); } - return(-1); + return(0); } int64_t komodo_checkcommission(CBlock *pblock,int32_t height) @@ -2043,14 +2127,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } - if( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() != 1 ) + if ( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() > 1 ) { - if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) - { - fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); - return(-1); - } - else + // We check the full validation in ConnectBlock directly to get the amount for coinbase. So just approx here. + if ( slowflag == 0 ) { // Check the notarisation tx is to the crypto address. if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) diff --git a/src/main.cpp b/src/main.cpp index 99fb44147..ec79fafbc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3574,14 +3574,32 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } - if ( ASSETCHAINS_NOTARY_PAY != 0 && block.vtx[0].vout.size() > 1 ) + bool sleepflag = false; + if ( ASSETCHAINS_NOTARY_PAY != 0 ) { - uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); - if ( notarypaycheque > 0 ) - blockReward += notarypaycheque; - else - return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds the amount allowed! (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), - REJECT_INVALID, "bad-cb-amount"); + // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. + // if notarisation in the block, must be position 1 and the coinbase must pay notaries. + int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); + // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. + if ( notarisationTx == -1 ) + return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + REJECT_INVALID, "bad-notarization-position"); + // 1 means this block contains a valid notarisation + if ( notarisationTx == 1 ) + { + // Check if the notaries have been paid. + if ( block.vtx[0].vout.size() == 1 ) + return state.DoS(100, error("ConnectBlock(): Notary has not been paid!"), + REJECT_INVALID, "bad-cb-amount"); + // calculate the notaries compensation and validate the amounts and pubkeys are correct. + uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); + fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); + if ( notarypaycheque > 0 ) + blockReward += notarypaycheque; + else + return state.DoS(100, error("ConnectBlock(): Notary pay Validation Failed!"), + REJECT_INVALID, "bad-cb-amount"); + } } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) { @@ -3592,6 +3610,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->GetHeight() >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { + //fprintf(stderr, "coinbase pays too much\n"); + //sleepflag = true; return state.DoS(100, error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), @@ -3641,15 +3661,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin ConnectNotarisations(block, pindex->GetHeight()); // MoMoM notarisation DB. - int notarisationTx = komodo_connectblock(pindex,*(CBlock *)&block); // dPoW state update. - if ( ASSETCHAINS_NOTARY_PAY != 0 && notarisationTx > 0 ) - { - printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),notarisationTx); - if ( notarisationTx != 1 ) - return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), - REJECT_INVALID, "bad-notarization-position"); - } - if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) return AbortNode(state, "Failed to write transaction index"); @@ -3704,6 +3715,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); + komodo_connectblock(false,pindex,*(CBlock *)&block); // dPoW state update. + if (sleepflag) + sleep(30); return true; } diff --git a/src/miner.cpp b/src/miner.cpp index 4ad70912c..6476a7b48 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -153,7 +153,7 @@ int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); -uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp); +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -672,14 +672,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; // timelocks and commissions are currently incompatible due to validation complexity of the combination } - else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 ) + else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) { - // This block contains a valid notarisation as best as we can know. We cant check this 100% until we try to connect block. - // This assumes notaries are not going to collude to create invalid notarisations. - // If they did this, then the block would be invalid, and all kinds of werid things will happen. - // We can test this, and see what happens, if its unreliable, we will need to create a CC contract. - uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); - fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) + { + uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); + fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + } else fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); } pblock->vtx[0] = txNew; From 4ffdae4135793c0a121257fa1a4997475eec932a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:40:55 -1100 Subject: [PATCH 1754/3904] Handle qui quit --- src/cc/cclib.cpp | 10 +++++++--- src/cc/rogue/command.c | 2 ++ src/cc/rogue/rogue.c | 38 ++++++++++++++++++++------------------ src/cc/rogue/rogue.h | 2 +- src/cc/rogue_rpc.cpp | 6 ++++++ 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 549db5848..6d1f1a2fb 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -58,9 +58,10 @@ CClib_methods[] = { (char *)"rogue", (char *)"txidinfo", (char *)"txid", 1, 1, 'I', EVAL_ROGUE }, { (char *)"rogue", (char *)"pending", (char *)"", 0, 0, 'P', EVAL_ROGUE }, { (char *)"rogue", (char *)"register", (char *)"txid [inventory]", 1, 2, 'R', EVAL_ROGUE }, - { (char *)"rogue", (char *)"progress", (char *)"txid fname", 2, 2, 'K', EVAL_ROGUE }, - { (char *)"rogue", (char *)"claimwin", (char *)"txid", 1, 1, 'W', EVAL_ROGUE }, - { (char *)"rogue", (char *)"extract", (char *)"txid item", 2, 2, 'X', EVAL_ROGUE }, + { (char *)"rogue", (char *)"progress", (char *)"regtxid fname", 2, 2, 'K', EVAL_ROGUE }, + { (char *)"rogue", (char *)"saveandquit", (char *)"ptxid", 1, 1, 'Q', EVAL_ROGUE }, + { (char *)"rogue", (char *)"claimwin", (char *)"ptxid", 1, 1, 'W', EVAL_ROGUE }, + { (char *)"rogue", (char *)"extract", (char *)"wtxid item", 2, 2, 'X', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -83,6 +84,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_progress(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_saveandquit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_claimwin(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -111,6 +113,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(rogue_register(txfee,cp,params)); else if ( strcmp(method,"progress") == 0 ) return(rogue_progress(txfee,cp,params)); + else if ( strcmp(method,"saveandquit") == 0 ) + return(rogue_saveandquit(txfee,cp,params)); else if ( strcmp(method,"claimwin") == 0 ) return(rogue_claimwin(txfee,cp,params)); else if ( strcmp(method,"extract") == 0 ) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index fa10d2b3a..d6f834dbc 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -260,6 +260,8 @@ over: after = FALSE; q_comm = TRUE; quit(0); + if ( rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); q_comm = FALSE; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 010b66c9f..0a2fbbeb6 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -410,6 +410,8 @@ playit(struct rogue_state *rs) if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; } + if ( rs->didquit != 0 ) + my_exit(0); } } endit(0); @@ -425,36 +427,36 @@ quit(int sig) { struct rogue_state *rs = &globalR; int oy, ox; - + NOOP(sig); - + /* * Reset the signal in case we got here via an interrupt */ if (!q_comm) - mpos = 0; + mpos = 0; getyx(curscr, oy, ox); msg(rs,"really quit?"); if (readchar(rs) == 'y') { - signal(SIGINT, leave); - clear(); - mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse); - move(LINES - 1, 0); - refresh(); - score(purse, 1, 0); - my_exit(0); + signal(SIGINT, leave); + clear(); + mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse); + move(LINES - 1, 0); + refresh(); + score(purse, 1, 0); + rs->didquit = (uint32_t)time(NULL); } else { - move(0, 0); - clrtoeol(); - status(rs); - move(oy, ox); - refresh(); - mpos = 0; - count = 0; - to_death = FALSE; + move(0, 0); + clrtoeol(); + status(rs); + move(oy, ox); + refresh(); + mpos = 0; + count = 0; + to_death = FALSE; } } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 472b2755a..80200fb23 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -317,7 +317,7 @@ struct rogue_state { uint64_t seed; char *keystrokes; - uint32_t needflush,replaydone; + uint32_t needflush,replaydone,didquit; int32_t numkeys,ind,num,guiflag,counter; char buffered[512]; }; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 763408258..8761ffc70 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -147,6 +147,12 @@ UniValue rogue_claimwin(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue rogue_saveandquit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); From c6e5b70f23db45a5d5458e9577e784669d960119 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 02:44:17 +0800 Subject: [PATCH 1755/3904] fix --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a139adf90..2bd97fa68 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1904,7 +1904,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) if ( totalsats == 0 ) { fprintf(stderr, "notary pay RETURNED 0!\n"); - return(-1); + return(0); } int8_t n = 0, i = 0, matches = 0; From f46e63403ee514ebb28c1d9256289e07d8033c86 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:46:24 -1100 Subject: [PATCH 1756/3904] Test --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index bdf3c515c..4d25cf69a 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -171,7 +171,7 @@ readchar(struct rogue_state *rs) quit(0); return(27); } - if ( rs != 0 && rs->guiflag != 0 ) + if ( rs != 0 && rs->guiflag != 0 && rs->didquit == 0 ) { if ( rs->num < sizeof(rs->buffered) ) { From a30ff35a243a6a4ffdf0b0655e213edc35233ea0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:50:17 -1100 Subject: [PATCH 1757/3904] my_exit(0); --- src/cc/rogue/rogue.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 0a2fbbeb6..d856f2587 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -410,9 +410,9 @@ playit(struct rogue_state *rs) if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; } - if ( rs->didquit != 0 ) - my_exit(0); } + if ( rs->didquit != 0 ) + my_exit(0); } endit(0); } @@ -445,7 +445,9 @@ quit(int sig) move(LINES - 1, 0); refresh(); score(purse, 1, 0); - rs->didquit = (uint32_t)time(NULL); + flushkeystrokes(rs); + //rs->didquit = (uint32_t)time(NULL); + my_exit(0); } else { From 7c6b1856d358e27033de865d846ca8cdaa14dbeb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 07:52:41 -1100 Subject: [PATCH 1758/3904] -didquit --- src/cc/rogue/io.c | 2 +- src/cc/rogue/rogue.c | 3 --- src/cc/rogue/rogue.h | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 4d25cf69a..bdf3c515c 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -171,7 +171,7 @@ readchar(struct rogue_state *rs) quit(0); return(27); } - if ( rs != 0 && rs->guiflag != 0 && rs->didquit == 0 ) + if ( rs != 0 && rs->guiflag != 0 ) { if ( rs->num < sizeof(rs->buffered) ) { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index d856f2587..5be126ca8 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -411,8 +411,6 @@ playit(struct rogue_state *rs) rs->needflush = 0; } } - if ( rs->didquit != 0 ) - my_exit(0); } endit(0); } @@ -446,7 +444,6 @@ quit(int sig) refresh(); score(purse, 1, 0); flushkeystrokes(rs); - //rs->didquit = (uint32_t)time(NULL); my_exit(0); } else diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 80200fb23..472b2755a 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -317,7 +317,7 @@ struct rogue_state { uint64_t seed; char *keystrokes; - uint32_t needflush,replaydone,didquit; + uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter; char buffered[512]; }; From 9281de5d77f233340ba60fb3d35e35162f61853b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 08:13:22 -1100 Subject: [PATCH 1759/3904] Remove ++ from bool --- src/cc/rogue/passages.c | 2 +- src/cc/rogue/potions.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/passages.c b/src/cc/rogue/passages.c index 6d9cd17b1..79b3706aa 100644 --- a/src/cc/rogue/passages.c +++ b/src/cc/rogue/passages.c @@ -373,7 +373,7 @@ passnum() for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) for (i = 0; i < rp->r_nexits; i++) { - newpnum++; + newpnum ^= 1;//newpnum++; numpass(rp->r_exit[i].y, rp->r_exit[i].x); } } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 9839319ee..de09efb9b 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -293,8 +293,8 @@ turn_see(bool turn_off) addch(rnd(26) + 'A'); if (!can_see) { - standend(); - add_new++; + standend(); + add_new ^= 1;//add_new++; } } } From dabceb5d375f60f7593a25293f5c00897d12ad4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 08:18:07 -1100 Subject: [PATCH 1760/3904] -# --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index f7ee26669..08c86dee8 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,5 +1,5 @@ cd rogue; -#./configure # only need this first time +./configure # only need this first time make; cd .. gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so From b319a87bef20c3f434997a8ca29c3c2d01355698 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 08:37:03 -1100 Subject: [PATCH 1761/3904] Remove direct access of ncurses struct --- src/cc/rogue/mdport.c | 6 +++--- src/cc/rogue/rogue.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 72fdbb75e..acd257617 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -260,9 +260,9 @@ md_hasclreol() #if defined(clr_eol) #ifdef NCURSES_VERSION if (cur_term == NULL) - return(0); - if (cur_term->type.Strings == NULL) - return(0); + return(0); + //if (cur_term->type.Strings == NULL) + return(0); #endif return((clr_eol != NULL) && (*clr_eol != 0)); #elif defined(__PDCURSES__) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 5be126ca8..221d7ca97 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -380,7 +380,7 @@ playit(struct rogue_state *rs) } if (md_hasclreol()) - inv_type = INV_CLEAR; + inv_type = INV_CLEAR; /* * parse environment declaration of options From 45be9c6188e508992461884211b36eb592c31b91 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 08:45:17 -1100 Subject: [PATCH 1762/3904] Avoid seed of 0 --- src/cc/rogue/rogue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 221d7ca97..6d7971e98 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -110,6 +110,8 @@ long get_filesize(FILE *fp) int32_t rogue_replay(uint64_t seed) { FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; + if ( seed == 0 ) + seed = 777; while ( 1 ) { roguefname(fname,seed,counter); From 5e7e41735efaafef51a8c501bbc60957bb10977f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 08:50:12 -1100 Subject: [PATCH 1763/3904] Sleeptime var --- src/cc/cclib.cpp | 4 ++-- src/cc/rogue/main.c | 4 ++-- src/cc/rogue/rogue.c | 6 ++++-- src/cc/rogue/rogue.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 6d1f1a2fb..e71171b71 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -73,7 +73,7 @@ CClib_methods[] = std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); #ifdef BUILD_ROGUE -int32_t rogue_replay(uint64_t seed); +int32_t rogue_replay(uint64_t seed,int32_t sleeptime); bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { @@ -102,7 +102,7 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) #ifdef BUILD_ROGUE if ( cp->evalcode == EVAL_ROGUE ) { - rogue_replay(777); + rogue_replay(777,0); if ( strcmp(method,"newgame") == 0 ) return(rogue_newgame(txfee,cp,params)); else if ( strcmp(method,"pending") == 0 ) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 68dca0e98..4fa5ec95e 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -26,7 +26,7 @@ #include #include -int32_t rogue_replay(uint64_t seed); +int32_t rogue_replay(uint64_t seed,int32_t sleeptime); int rogue(int argc, char **argv, char **envp); int main(int argc, char **argv, char **envp) @@ -36,7 +36,7 @@ int main(int argc, char **argv, char **envp) { seed = atol(argv[1]); fprintf(stderr,"replay %llu\n",(long long)seed); - return(rogue_replay(seed)); + return(rogue_replay(seed,50000)); } else { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6d7971e98..79d6b2470 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -107,7 +107,7 @@ long get_filesize(FILE *fp) return(fsize); } -int32_t rogue_replay(uint64_t seed) +int32_t rogue_replay(uint64_t seed,int32_t sleeptime) { FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; if ( seed == 0 ) @@ -145,6 +145,7 @@ int32_t rogue_replay(uint64_t seed) rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; + rs->sleeptime = sleeptime; rogueiterate(rs); if ( (fp= fopen("checkfile","wb")) != 0 ) { @@ -403,7 +404,8 @@ playit(struct rogue_state *rs) //fprintf(stderr,"replaydone\n"); sleep(3); return; } - usleep(50000); + if ( rs->sleeptime != 0 ) + usleep(rs->sleeptime); } else { diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 472b2755a..3c500439c 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -318,7 +318,7 @@ struct rogue_state uint64_t seed; char *keystrokes; uint32_t needflush,replaydone; - int32_t numkeys,ind,num,guiflag,counter; + int32_t numkeys,ind,num,guiflag,counter,sleeptime; char buffered[512]; }; From 52f7cc2caf7d35b6065ec0af09ee2b501fb8a69a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 12:10:26 +0800 Subject: [PATCH 1764/3904] Add some better prints/comments, move ac_notarypay validation to before temp file fix, to aviod possible attack vector. --- src/komodo_bitcoind.h | 35 ++++++++++++++++--------- src/main.cpp | 60 +++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2bd97fa68..6fd3b47b3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1807,6 +1807,9 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); + // No point going further, no notaries can be paid. + if ( staked_era == 0 ) + return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); @@ -1821,11 +1824,11 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar memcpy(scriptbuf,script,len); if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) { - fprintf(stderr, "VALID NOTARIZATION ht.%i\n",notarizedheight); + fprintf(stderr, "notarypay found VALID NOTARIZATION ht.%i\n",notarizedheight); } else { - fprintf(stderr, "INVALID NOTARIZATION ht.%i\n",notarizedheight); + fprintf(stderr, "notarypay found INVALID NOTARIZATION ht.%i\n",notarizedheight); return(0); } } else return(0); @@ -1861,10 +1864,13 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); + // No point going further, no notaries can be paid. + if ( staked_era == 0 ) + return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); uint8_t *script; int32_t scriptlen; - // Loop notarisation, and create the coinbase tx, with the same function the miner uses. + // Loop over the notarisation and extract the position of the participating notaries in the array of pukeys for this era. BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin) { uint256 hash; CTransaction tx1; @@ -1872,7 +1878,6 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { for (int8_t i = 0; i < numSN; i++) { - //tx1.vout[txin.prevout.n].scriptPubKey script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) @@ -1891,19 +1896,22 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { + // Create the coinbase tx again, using the extracted data, this is the same function the miner uses, with the same data. + // This allows us to know exactly that the coinbase is correct. totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, height, script, scriptlen); } else { fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); - return(-1); + return(0); } } // if notarypay fails, because the notarisation is not valid, exit now as txNew was not created. + // This should never happen, as the notarisation is checked before this function is called. if ( totalsats == 0 ) { - fprintf(stderr, "notary pay RETURNED 0!\n"); + fprintf(stderr, "notary pay returned 0!\n"); return(0); } @@ -1913,11 +1921,10 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) // get the pay amount from the created tx. AmountToPay = txNew.vout[1].nValue; - //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); // Check the created coinbase pays the correct notaries. BOOST_FOREACH(const CTxOut& txout, pblock->vtx[0].vout) { - // skip the coinbase + // skip the coinbase paid to the miner. if ( n == 0 ) { n++; @@ -1933,7 +1940,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { matches++; total += txout.nValue; - fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]); } else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]); } @@ -1941,7 +1948,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } if ( matches != 0 && matches == NotarisationNotaries.size() && totalsats == total ) { - fprintf(stderr, "VALIDATED.\n" ); + fprintf(stderr, "Validated coinbase matches notarisation in tx position 1.\n" ); return(totalsats); } return(0); @@ -2127,6 +2134,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } + // Consensus rule to force miners to mine the notary coinbase payment happens in ConnectBlock + // the default daemon miner, checks the actual vins so the only way this will fail, is if someone changes the miner, + // and then creates txs to the crypto address meeting min sigs and puts it in tx position 1. + // If they go through this effort, the block will still fail at connect block, and will be auto purged by the temp file fix. if ( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() > 1 ) { // We check the full validation in ConnectBlock directly to get the amount for coinbase. So just approx here. @@ -2135,13 +2146,13 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) // Check the notarisation tx is to the crypto address. if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) { - fprintf(stderr, "notarisation is not to crypto address.%i\n",height); + fprintf(stderr, "notarisation is not to crypto address ht.%i\n",height); return(-1); } // Check min sigs. if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) { - fprintf(stderr, "block notarization does not meet minsigs .%i\n",height); + fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,(num_notaries_STAKED[STAKED_era(pblock->nTime)]/5),pblock->vtx[1].vin.size()); return(-1); } } diff --git a/src/main.cpp b/src/main.cpp index ec79fafbc..656cc0a96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3267,6 +3267,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin auto verifier = libzcash::ProofVerifier::Strict(); auto disabledVerifier = libzcash::ProofVerifier::Disabled(); int32_t futureblock; + CAmount blockReward = 0; // Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in if (!CheckBlock(&futureblock,pindex->GetHeight(),pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck) || futureblock != 0 ) { @@ -3280,6 +3281,34 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return false; fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } + // Do this here before the block is moved to the main block files. + if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() != 0 ) + { + // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. + // if notarisation in the block, must be position 1 and the coinbase must pay notaries. + int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); + // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. + if ( notarisationTx == -1 ) + return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + REJECT_INVALID, "bad-notarization-position"); + // 1 means this block contains a valid notarisation + if ( notarisationTx == 1 ) + { + // Check if the notaries have been paid. + if ( block.vtx[0].vout.size() == 1 ) + return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), + REJECT_INVALID, "bad-cb-amount"); + // calculate the notaries compensation and validate the amounts and pubkeys are correct. + uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); + fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); + if ( notarypaycheque > 0 ) + blockReward += notarypaycheque; + else + return state.DoS(100, error("ConnectBlock(): Notary pay validation failed!"), + REJECT_INVALID, "bad-cb-amount"); + } + } + // Move the block to the main block file, we need this to create the TxIndex in the following loop. if ( (pindex->nStatus & BLOCK_IN_TMPFILE) != 0 ) { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); @@ -3562,7 +3591,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime1 = GetTimeMicros(); nTimeConnect += nTime1 - nTimeStart; LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); - CAmount blockReward = nFees + GetBlockSubsidy(pindex->GetHeight(), chainparams.GetConsensus()) + sum; + blockReward += nFees + GetBlockSubsidy(pindex->GetHeight(), chainparams.GetConsensus()) + sum; if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && { uint64_t checktoshis; @@ -3574,33 +3603,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } - bool sleepflag = false; - if ( ASSETCHAINS_NOTARY_PAY != 0 ) - { - // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. - // if notarisation in the block, must be position 1 and the coinbase must pay notaries. - int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); - // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. - if ( notarisationTx == -1 ) - return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), - REJECT_INVALID, "bad-notarization-position"); - // 1 means this block contains a valid notarisation - if ( notarisationTx == 1 ) - { - // Check if the notaries have been paid. - if ( block.vtx[0].vout.size() == 1 ) - return state.DoS(100, error("ConnectBlock(): Notary has not been paid!"), - REJECT_INVALID, "bad-cb-amount"); - // calculate the notaries compensation and validate the amounts and pubkeys are correct. - uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); - fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); - if ( notarypaycheque > 0 ) - blockReward += notarypaycheque; - else - return state.DoS(100, error("ConnectBlock(): Notary pay Validation Failed!"), - REJECT_INVALID, "bad-cb-amount"); - } - } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) { return state.DoS(100, error("ConnectBlock(): coinbase for block 1 pays wrong amount (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), @@ -3716,8 +3718,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //FlushStateToDisk(); komodo_connectblock(false,pindex,*(CBlock *)&block); // dPoW state update. - if (sleepflag) - sleep(30); return true; } From a36c15efffad5f07ba14100a834c6fd4ba394947 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 17:15:01 -1100 Subject: [PATCH 1765/3904] Change for new game --- src/cc/rogue/main.c | 8 -------- src/cc/rogue_rpc.cpp | 12 +++++++++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 4fa5ec95e..7efdebc8d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -14,14 +14,6 @@ ******************************************************************************/ - -// creategame, register (inventory + baton + buyin), progress (events + statehash + [compr state]?), claimwin -// create game buyin, newbie flag, 10 blocks registration seed is starting blockhash! -// inheritance of items across games! -// binding tokens to specific items to allow for built in market -// pubkey token inventory creates items can be used for a specific campaign -// player wins buyins + ingame gold -> ROGUE + ingame items -> tokens via 1 vout per item to be spent into a token opreturn - #include #include #include diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8761ffc70..cf7ebeb70 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -15,6 +15,12 @@ ******************************************************************************/ #include "cJSON.h" +// creategame, register (inventory + baton + buyin), progress (seed + firsthash + statehash + events), claimwin +// create game buyin, newbie flag, 10 blocks registration seed is starting blockhash! +// inheritance of items across games! +// binding tokens to specific items to allow for built in market +// pubkey token inventory creates items can be used for a specific campaign +// player wins buyins + ingame gold -> ROGUE + ingame items -> tokens via 1 vout per item to be spent into a token opreturn #define ROGUE_REGISTRATION 5 @@ -25,6 +31,8 @@ // cclib pending 17 // cclib txidinfo 17 \"35e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f\" // ./rogue gui -> creates keystroke files +// cclib register 17 \"35e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f\" [items] +// cclib pending 17 \"\" starthash endhash keystrokes CScript rogue_newgameopret(int64_t buyin) { @@ -89,7 +97,7 @@ uint8_t rogue_newgameopreturndecode(int64_t &buyin,CScript scriptPubKey) UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,amount = 0; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,amount = 0; if ( params != 0 ) { if ( (jsonstr= jprint(params,0)) != 0 ) @@ -116,6 +124,8 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); + if ( (change= inputsum-3*txfee) >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,roguepk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(amount)); if ( rawtx.size() > 0 ) { From f59e25fea6444139a23312d6c08c6e1df2cc7bc5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 17:23:43 -1100 Subject: [PATCH 1766/3904] Free mem at end of replay --- src/cc/rogue/rogue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 79d6b2470..437bf11e9 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -158,7 +158,10 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) fclose(fp); } } - fatal("finished replay\n"); + free(rs); + mvaddstr(LINES - 2, 0, s); + refresh(); + endwin(); } if ( keystrokes != 0 ) free(keystrokes); From a622fd1cb0ce4d9d019f1ed5a061a553d1a88051 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Feb 2019 17:24:28 -1100 Subject: [PATCH 1767/3904] Char * --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 437bf11e9..8acdf8844 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -159,7 +159,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } } free(rs); - mvaddstr(LINES - 2, 0, s); + mvaddstr(LINES - 2, 0, (char *)"replay completed"); refresh(); endwin(); } From 1b504fe06681235f5b28bbd2ff25e7ce48ed963e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 13:42:54 +0800 Subject: [PATCH 1768/3904] Change ERA to 3 at: (GMT): Sunday, 3 February 2019 9:00:00 AM --- src/notaries_staked.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index b407e6412..2941fd9ac 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1604222222, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549184400, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = @@ -78,20 +78,22 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, // RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu + {"smk762", "029f6c1f38c4d6825acb3b4b5147f7992e943b617cdaa0f4f5f36187e239d52d5a" }, // RPy6Xj2LWrxNoEW9YyREDgBZDZZ5qURXBU + {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s + {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p + {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf + {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t + {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 + {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q + {"gcharang", "03336ca9db27cb6e882830e20dc525884e27dc94d557a5e68b972a5cbf9e8c62a8" }, // RJYiWn3FRCSSLf9Pe5RJcbrKQYosaMburP + {"computergenie", "03448ce28fb21748e8b05bbe32d6b1e758b589ac1eb359e5d552f8868f2b75dc92" }, // RGeniexxkjnR34hg7ZnCf36kmfuJusf6rE + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, // + {"SHossain", "02791f5c215b8a19c143a98e3371ff03b5613df9ac430c4a331ca55fed5761c800" }, // RKdLoHkyeorXmMtj91B1AAnAGiwsdt9MdF + {"Nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, // RRwCLPZDzpHEFJnLev4phy51e2stHRUAaU }, { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x @@ -114,7 +116,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = } }; -static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 17, 17 }; +static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 19, 17 }; int8_t is_STAKED(const char *chain_name); int32_t STAKED_era(int timestamp); From 2c88bb70b6237ba884ca36ed5bec815d3b669d13 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 16:05:37 +0800 Subject: [PATCH 1769/3904] disable temp file on initial block sync, extend era2 by 1 hour. --- src/main.cpp | 4 ++++ src/notaries_staked.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 656cc0a96..b904e10e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4736,6 +4736,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u if ( 0 && tmpflag != 0 ) fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } + //sleep(30); } //fprintf(stderr, "nFile = %i size.%li maxTempFileSize0.%u maxTempFileSize1.%u\n",nFile,tmpBlockFiles.size(),maxTempFileSize0,maxTempFileSize1); sleep(30); *lastfilep = nFile; @@ -5338,6 +5339,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C int nHeight = pindex->GetHeight(); int32_t usetmp = 1; + if ( IsInitialBlockDownload() ) + usetmp = 0; // Write block to history file try { @@ -5586,6 +5589,7 @@ bool PruneOneBlockFile(bool tempfile, const int fileNumber) // Block is in main chain so we cant clear this file! return(false); } + fprintf(stderr, "pindex height.%i notarized height.%i \n", pindex->GetHeight(), notarized_height); if ( pindex->GetHeight() > notarized_height ) // Need to check this, does an invalid block have a height? { // This blocks height is not older than last notarization so it can be reorged into the main chain. diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 2941fd9ac..468b7b7ca 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549184400, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549188000, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = From 2863dbc6d4e703192efaa04a064ac02dce67145b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 4 Feb 2019 10:06:54 +0800 Subject: [PATCH 1770/3904] Stop miner trying to mine invalid block. --- src/komodo_bitcoind.h | 5 +++-- src/main.cpp | 17 +++++++++++++++++ src/miner.cpp | 7 ++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6fd3b47b3..0a72903da 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1811,8 +1811,6 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar if ( staked_era == 0 ) return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); - // resize coinbase vouts to number of notary nodes +1 for coinbase itself. - txNew.vout.resize(NotarisationNotaries.size()+1); // Check the notarisation is valid, and extract notarised height. uint64_t voutmask; @@ -1833,6 +1831,9 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar } } else return(0); + // resize coinbase vouts to number of notary nodes +1 for coinbase itself. + txNew.vout.resize(NotarisationNotaries.size()+1); + // Calcualte the amount to pay. AmountToPay = komodo_notarypayamount(notarizedheight,NotarisationNotaries.size()); diff --git a/src/main.cpp b/src/main.cpp index b904e10e2..b9c66c2ca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -282,6 +282,9 @@ namespace { bool fCurrentlyConnected; //! Accumulated misbehaviour score for this peer. int nMisbehavior; + // count blocks seen. + //int8_t nBlocksinARow; + //int8_t nBlocksinARow2; //! Whether this peer should be disconnected and banned (unless whitelisted). bool fShouldBan; //! String name of this peer (debugging/logging purposes). @@ -5469,6 +5472,20 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool checked; uint256 hash; int32_t futureblock=0; auto verifier = libzcash::ProofVerifier::Disabled(); hash = pblock->GetHash(); + /*pfrom->nBlocksinARow += 1; + if ( pfrom->nBlocksinARow >= 6 ) + { + pfrom->nBlocksinARow2 += 1; + if ( pfrom->nBlocksinARow2 > 3 ) + { + pfrom->nBlocksinARow = 0; + pfrom->nBlocksinARow2 = 0; + } + else + { + return(false); + } + }*/ //fprintf(stderr,"ProcessBlock %d\n",(int32_t)chainActive.LastTip()->GetHeight()); { LOCK(cs_main); diff --git a/src/miner.cpp b/src/miner.cpp index 6476a7b48..da5fcd91f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -680,7 +680,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( script[0] == OP_RETURN ) { uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); - fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + if ( totalsats == 0 ) + { + fprintf(stderr, "Could not create notary payment, trying again.\n"); + return(0); + } + fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); } else fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); } From bd6949b98718fb0228809efc52d372bff18bbd7a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 4 Feb 2019 11:51:02 +0800 Subject: [PATCH 1771/3904] disable notarisation priority for non staked chains. --- src/miner.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index da5fcd91f..5f1afa874 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -246,9 +246,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblock->nTime = GetAdjustedTime(); // Now we have the block time, we can get the active notaries. int32_t staked_era; int8_t numSN; - uint8_t staked_pubkeys[64][33]; - staked_era = STAKED_era(pblock->nTime); - numSN = numStakedNotaries(staked_pubkeys,staked_era); + uint8_t staked_pubkeys[64][33] = {0}; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + staked_era = STAKED_era(pblock->nTime); + numSN = numStakedNotaries(staked_pubkeys,staked_era); + } CCoinsViewCache view(pcoinsTip); uint32_t expired; uint64_t commission; From 0539f67ceb95c9a55ce68d763f7e87b105b92e67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Feb 2019 20:18:57 -1100 Subject: [PATCH 1772/3904] Fix migrate --- src/cc/dapps/zmigrate.c | 62 ----------------------------------------- 1 file changed, 62 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 37a2bc7ca..86626b699 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -700,23 +700,6 @@ int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname,char *typestr) return(retval); } -int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname,char *typestr) -{ - cJSON *retjson; char *retstr; int64_t amount=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","")) != 0 ) - { - fprintf(stderr,"z_getnewaddress.(%s) %s returned json!\n",refcoin,acname); - free_json(retjson); - return(-1); - } - else if ( retstr != 0 ) - { - strcpy(coinaddr,retstr); - free(retstr); - return(0); - } -} - int64_t find_onetime_amount(char *coinstr,char *coinaddr) { cJSON *array,*item; int32_t i,n; char *addr; int64_t amount = 0; @@ -812,53 +795,8 @@ int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr { cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; sprintf(addr,"[\\\"ANY_SPROUT\\\"]"); - //printf("z_sendmany from.(%s) -> %s\n",addr,destaddr); if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) { - /*{ - "remainingUTXOs": 0, - "remainingTransparentValue": 0.00000000, - "remainingNotes": 222, - "remainingShieldedValue": 5413.39093055, - "mergingUTXOs": 0, - "mergingTransparentValue": 0.00000000, - "mergingNotes": 10, - "mergingShieldedValue": 822.47447172, - "opid": "opid-f28f6261-4120-436c-aca5-859870a40a70" - }*/ - if ( (opstr= jstr(retjson,"opid")) != 0 ) - strcpy(opidstr,opstr); - retval = jint(retjson,"remainingNotes"); - fprintf(stderr,"%s\n",jprint(retjson,0)); - free_json(retjson); - } - else if ( retstr != 0 ) - { - fprintf(stderr,"z_mergetoaddress.(%s) -> opid.(%s)\n",coinstr,retstr); - strcpy(opidstr,retstr); - free(retstr); - } - return(retval); -} - -int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr) -{ - cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; - sprintf(addr,"[\\\"ANY_SPROUT\\\"]"); - //printf("z_sendmany from.(%s) -> %s\n",addr,destaddr); - if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) - { - /*{ - "remainingUTXOs": 0, - "remainingTransparentValue": 0.00000000, - "remainingNotes": 222, - "remainingShieldedValue": 5413.39093055, - "mergingUTXOs": 0, - "mergingTransparentValue": 0.00000000, - "mergingNotes": 10, - "mergingShieldedValue": 822.47447172, - "opid": "opid-f28f6261-4120-436c-aca5-859870a40a70" - }*/ if ( (opstr= jstr(retjson,"opid")) != 0 ) strcpy(opidstr,opstr); retval = jint(retjson,"remainingNotes"); From 042756499f8b99d3fd590de5ea1ffa043336fe33 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 4 Feb 2019 16:40:47 +0800 Subject: [PATCH 1773/3904] fix better --- src/miner.cpp | 10 +++++----- src/notaries_staked.cpp | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5f1afa874..10bdb643f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -245,7 +245,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } pblock->nTime = GetAdjustedTime(); // Now we have the block time, we can get the active notaries. - int32_t staked_era; int8_t numSN; + int32_t staked_era = 0; int8_t numSN = 0; uint8_t staked_pubkeys[64][33] = {0}; if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { @@ -303,7 +303,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { int numNotaryVins = 0; bool fToCryptoAddress = false; - if ( komodo_is_notarytx(tx) == 1 ) + if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; BOOST_FOREACH(const CTxIn& txin, tx.vin) @@ -346,7 +346,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint8_t *script; int32_t scriptlen; uint256 hash; CTransaction tx1; // loop over notaries array and extract index of signers. - if ( fToCryptoAddress && staked_pubkeys[0][0] != 0 && GetTransaction(txin.prevout.hash,tx1,hash,false) ) + if ( fToCryptoAddress && GetTransaction(txin.prevout.hash,tx1,hash,false) ) { for (int8_t i = 0; i < numSN; i++) { @@ -403,7 +403,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0) + else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) continue; // If we have added a notarisation already skip the next one. There can only be one per block. else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); @@ -1720,7 +1720,7 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; - + if ( ASSETCHAINS_STAKED > 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 23bc0f8fd..cdaffa7a2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -10,7 +10,8 @@ extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; -int8_t is_STAKED(const char *chain_name) { +int8_t is_STAKED(const char *chain_name) +{ static int8_t STAKED,doneinit; if ( chain_name[0] == 0 ) return(0); @@ -22,7 +23,7 @@ int8_t is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - else if ( (strcmp(chain_name, "NOTARYTEST") == 0) ) + else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) STAKED = 4; else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) STAKED = 255; // This means that all notarisations for chains that are in 255 group are invalid. From 587cab8f0d625bb047ad4137b7fd4d669bd8c6e6 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 4 Feb 2019 18:08:14 +0100 Subject: [PATCH 1774/3904] Gateways fixes (#17) - Oraclefeed crash fix - Wrong amount bug - Switching to LogPrint in Gateways for filtering debug output - Adding CCerror to all RPCs --- src/cc/dapps/oraclefeed.c | 55 +++-- src/cc/gateways.cpp | 451 +++++++++++++++++++++++--------------- 2 files changed, 301 insertions(+), 205 deletions(-) diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index d6cf753f9..d97df1cd9 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -236,7 +236,7 @@ void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) { fclose(fp); *lenp = 0; - printf("loadfile null size.(%s)\n",fname); + //printf("loadfile null size.(%s)\n",fname); return(0); } if ( filesize > buflen ) @@ -340,10 +340,12 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char #ifdef TESTMODE fprintf(stderr,"jsonstr.(%s)\n",jsonstr); #endif // TESTMODE - if ( (jsonstr[0] != '{' && jsonstr[0] != '[') || (retjson= cJSON_Parse(jsonstr)) == 0 ) + if ( (jsonstr[0] != '{' && jsonstr[0] != '[') || (retjson= cJSON_Parse(jsonstr)) == 0) *retstrp = jsonstr; else free(jsonstr); } + else if ( (jsonstr= filestr(&fsize,"/tmp/oraclefeed.error")) != 0 ) + *retstrp = jsonstr; return(retjson); } @@ -355,7 +357,7 @@ bits256 komodobroadcast(char *refcoin,char *acname,cJSON *hexjson) { if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendrawtransaction",hexstr,"","","")) != 0 ) { - //fprintf(stderr,"broadcast.(%s)\n",jprint(retjson,0)); + if (strcmp("error",jstr(retjson,"result"))==0) printf("%s\n",jstr(retjson,"error")); free_json(retjson); } else if ( retstr != 0 ) @@ -533,7 +535,7 @@ cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr) } else if ( retstr != 0 ) { - fprintf(stderr,"get_addressutxos.(%s) error.(%s)\n",acname,retstr); + //fprintf(stderr,"get_addressutxos.(%s) error.(%s)\n",acname,retstr); free(retstr); } return(0); @@ -692,14 +694,14 @@ char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawadd return(txstr); } -cJSON *addsignature(char *refcoin,char *acname,char *rawtx) +cJSON *addsignature(char *refcoin,char *acname,char *rawtx, int M) { char *retstr,*hexstr; cJSON *retjson; if ( (retjson= get_komodocli(refcoin,&retstr,acname,"signrawtransaction",rawtx,"","","")) != 0 ) { if ( is_cJSON_True(jobj(retjson,"complete")) != 0 ) return(retjson); - else if ((hexstr=jstr(retjson,"hex"))!= 0 && strlen(hexstr) > strlen(rawtx) + 2 ) + else if ((hexstr=jstr(retjson,"hex"))!= 0 && strlen(hexstr) > strlen(rawtx) + (M*2) + 1) { jaddnum(retjson,"partialtx",1); return(retjson); @@ -719,7 +721,8 @@ bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *coin,c char str[65],*retstr; cJSON *retjson; if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspartialsign",bits256_str(str,txid),coin,hex,"")) != 0 ) { - txid=komodobroadcast(refcoin,acname,retjson); + if (strcmp("error",jstr(retjson,"result"))!=0) txid=komodobroadcast(refcoin,acname,retjson); + else printf("%s\n",jstr(retjson,"error")); free(retjson); return (txid); } @@ -733,10 +736,11 @@ bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *coin,c bits256 gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char *coin,char *hex) { - char str[65],str2[65],*retstr; cJSON *retjson; bits256 txid; + char str[65],*retstr; cJSON *retjson; bits256 txid; if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayscompletesigning",bits256_str(str,withtxid),coin,hex,"")) != 0 ) { - txid=komodobroadcast(refcoin,acname,retjson); + if (strcmp("error",jstr(retjson,"result"))!=0) txid=komodobroadcast(refcoin,acname,retjson); + else printf("%s\n",jstr(retjson,"error")); free(retjson); return (txid); } @@ -753,7 +757,8 @@ bits256 gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid,char *coin) char str[65],str2[65],*retstr; cJSON *retjson; bits256 txid; if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewaysmarkdone",bits256_str(str,withtxid),coin,"","")) != 0 ) { - txid=komodobroadcast(refcoin,acname,retjson); + if (strcmp("error",jstr(retjson,"result"))!=0) txid=komodobroadcast(refcoin,acname,retjson); + else printf("%s\n",jstr(retjson,"error")); free(retjson); return (txid); } @@ -905,7 +910,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t rawtx = createrawtx(refcoin,"",depositaddr,withdrawaddr,txidaddr,satoshis); if ( rawtx != 0 ) { - if ( (clijson=addsignature(refcoin,"",rawtx)) != 0 && is_cJSON_True(jobj(clijson,"complete")) != 0) + if ( (clijson=addsignature(refcoin,"",rawtx,M)) != 0 && is_cJSON_True(jobj(clijson,"complete")) != 0) { txid=gatewayscompletesigning("KMD",acname,withdrawtxid,refcoin,jstr(clijson,"hex")); if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) complete signing tx sent - %s\n",bits256_str(str,withdrawtxid),bits256_str(str1,txid)); @@ -925,26 +930,26 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t } else rawtx=jstr(item,"hex"); K=jint(item,"number_of_signs"); - if ( rawtx!=0 && (clijson= addsignature(refcoin,"",rawtx)) != 0 ) + if ( rawtx!=0 && (clijson=addsignature(refcoin,"",rawtx,M)) != 0 ) { if ( is_cJSON_True(jobj(clijson,"complete")) != 0 ) { txid=gatewayscompletesigning("KMD",acname,lasttxid,refcoin,jstr(clijson,"hex")); - if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) complete signing tx (%dof%d) sent - %s\n",bits256_str(str,withdrawtxid),M,N,bits256_str(str1,txid)); - else fprintf(stderr,"error broadcasting tx on %s",acname); + if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s %dof%d\n",bits256_str(str,withdrawtxid),K+1,N); + else fprintf(stderr,"### SIGNING error broadcasting tx on %s\n",acname); } else if ( jint(clijson,"partialtx") != 0 ) { txid=gatewayspartialsign("KMD",acname,lasttxid,refcoin,jstr(clijson,"hex")); - if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) partial tx (%d/%dof%d) sent - %s\n",bits256_str(str,withdrawtxid),K+1,M,N,bits256_str(str1,txid)); - else fprintf(stderr,"error broadcasting tx on %s",acname); + if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s %d/%dof%d\n",bits256_str(str,withdrawtxid),K+1,M,N); + else fprintf(stderr,"### SIGNING error broadcasting tx on %s\n",acname); } free_json(clijson); processed++; - } - free(rawtx); - } - } + if ( lasttxid.txid==withdrawtxid.txid) free(rawtx); + } + } + } } } } @@ -966,20 +971,22 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t double amount = jdouble(item,"amount"); if (validateaddress(refcoin,"",txidaddr,"iswatchonly")==0 && validateaddress(refcoin,"",txidaddr,"ismine")==0) importaddress(refcoin,"",txidaddr,jstr(item,"withdrawtxid"),0); - if (txidaddr != 0 && markerexists(refcoin,"",txidaddr)==0) + if (is_cJSON_True(jobj(item,"confirmed_or_notarized")) && txidaddr != 0 && markerexists(refcoin,"",txidaddr)==0) { cointxid = komodobroadcast(refcoin,"",item); if ( bits256_nonz(cointxid) != 0 ) { - withdrawaddr = jstr(item,"withdrawaddr"); + withdrawaddr = jstr(item,"withdrawaddr"); + fprintf(stderr,"### WITHDRAW %.8f %s sent to %s\n",amount,refcoin,withdrawaddr); txid=gatewaysmarkdone("KMD",acname,completetxid,refcoin); - if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) markdone tx sent %s - %.8f %s to %s broadcasted on %s (%s)\n",bits256_str(str,withdrawtxid),bits256_str(str1,txid),amount,refcoin,withdrawaddr,refcoin,bits256_str(str2,cointxid)); + if (txid.txid!=zeroid.txid) fprintf(stderr,"### MARKDONE withdraw %s\n",bits256_str(str,withdrawtxid)); } - else fprintf(stderr,"error broadcasting tx on %s",refcoin); + else fprintf(stderr,"### WITHDRAW error broadcasting tx on %s\n",refcoin); } } } } + free_json(retjson); } } diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 4e2f64184..5c8de254d 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -178,15 +178,15 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui if ( N > 1 ) { strcpy(depositaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys))).ToString().c_str()); - //fprintf(stderr,"f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr); + //LogPrint("gatewayscc","f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr); } else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG); } else { - fprintf(stderr,"need to generate non-KMD addresses prefix.%d\n",prefix); + LogPrint("gatewayscc","need to generate non-KMD addresses prefix.%d\n",prefix); } return(f); - } else fprintf(stderr,"error decoding bind opret\n"); + } else LogPrint("gatewayscc","error decoding bind opret\n"); return(0); } @@ -363,15 +363,15 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti numvouts = tx.vout.size(); for (i=0; iismyvin)(tx.vin[i].scriptSig) != 0 ) { - //fprintf(stderr,"vini.%d check mempool\n",i); + //LogPrint("gatewayscc","vini.%d check mempool\n",i); if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) return eval->Invalid("cant find vinTx"); else { - //fprintf(stderr,"vini.%d check hash and vout\n",i); + //LogPrint("gatewayscc","vini.%d check hash and vout\n",i); if ( hashBlock == zerohash ) return eval->Invalid("cant Gateways from mempool"); if ( (assetoshis= IsGatewaysvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) @@ -381,13 +381,13 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti } for (i=0; iInvalid("mismatched inputs != outputs + txfee"); } else return(true); @@ -407,7 +407,7 @@ static int32_t myIs_coinaddr_inmempoolvout(char *coinaddr) Getscriptaddress(destaddr,tx.vout[i].scriptPubKey); if ( strcmp(destaddr,coinaddr) == 0 ) { - fprintf(stderr,"found (%s) vout in mempool\n",coinaddr); + LogPrint("gatewayscc","found (%s) vout in mempool\n",coinaddr); return(1); } } @@ -421,35 +421,35 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int32_t len,len2,numvouts; int64_t val,merkleht; CPubKey pk; std::vectordata; txid = zeroid; char str[65]; - //fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); + //LogPrint("gatewayscc","start reverse scan %s\n",uint256_str(str,batontxid)); while ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) { - //fprintf(stderr,"check %s\n",uint256_str(str,batontxid)); + //LogPrint("gatewayscc","check %s\n",uint256_str(str,batontxid)); if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid ) { - //fprintf(stderr,"decoded %s\n",uint256_str(str,batontxid)); + //LogPrint("gatewayscc","decoded %s\n",uint256_str(str,batontxid)); if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) { len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()); len2 = oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()); - char str2[65]; fprintf(stderr,"found merkleht.%d len.%d len2.%d %s %s\n",(int32_t)merkleht,len,len2,uint256_str(str,hash),uint256_str(str2,mhash)); + char str2[65]; LogPrint("gatewayscc","found merkleht.%d len.%d len2.%d %s %s\n",(int32_t)merkleht,len,len2,uint256_str(str,hash),uint256_str(str2,mhash)); if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid ) { txid = batontxid; - //fprintf(stderr,"set txid\n"); + //LogPrint("gatewayscc","set txid\n"); return(mhash); } else { - //fprintf(stderr,"missing hash\n"); + //LogPrint("gatewayscc","missing hash\n"); return(zeroid); } - } //else fprintf(stderr,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); + } //else LogPrint("gatewayscc","height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); batontxid = bhash; - //fprintf(stderr,"new hash %s\n",uint256_str(str,batontxid)); + //LogPrint("gatewayscc","new hash %s\n",uint256_str(str,batontxid)); } else break; } - fprintf(stderr,"end of loop\n"); + LogPrint("gatewayscc","end of loop\n"); return(zeroid); } @@ -486,20 +486,25 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout if ( myGetTransaction(oracletxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - fprintf(stderr,"GatewaysVerify cant find oracletxid %s\n",uint256_str(str,oracletxid)); + LogPrint("gatewayscc","GatewaysVerify cant find oracletxid %s\n",uint256_str(str,oracletxid)); return(0); } if ( DecodeOraclesCreateOpRet(tx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' || name != refcoin ) { - fprintf(stderr,"GatewaysVerify mismatched oracle name %s != %s\n",name.c_str(),refcoin.c_str()); + LogPrint("gatewayscc","GatewaysVerify mismatched oracle name %s != %s\n",name.c_str(),refcoin.c_str()); return(0); } proofroot = BitcoinGetProofMerkleRoot(proof,txids); if ( proofroot != merkleroot ) { - fprintf(stderr,"GatewaysVerify mismatched merkleroot %s != %s\n",uint256_str(str,proofroot),uint256_str(str2,merkleroot)); + LogPrint("gatewayscc","GatewaysVerify mismatched merkleroot %s != %s\n",uint256_str(str,proofroot),uint256_str(str2,merkleroot)); return(0); } + if (std::find(txids.begin(), txids.end(), cointxid) == txids.end()) + { + LogPrint("gatewayscc", "GatewaysVerify invalid proof for this cointxid\n"); + return 0; + } if ( DecodeHexTx(tx,deposithex) != 0 ) { Getscriptaddress(claimaddr,tx.vout[claimvout].scriptPubKey); @@ -516,13 +521,13 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout break; } } - } else fprintf(stderr,"claimaddr.(%s) != destpubaddr.(%s)\n",claimaddr,destpubaddr); + } else LogPrint("gatewayscc","claimaddr.(%s) != destpubaddr.(%s)\n",claimaddr,destpubaddr); } if ( txid == cointxid ) { - fprintf(stderr,"verified proof for cointxid in merkleroot\n"); + LogPrint("gatewayscc","verified proof for cointxid in merkleroot\n"); return(nValue); - } else fprintf(stderr,"(%s) != (%s) or txid %s mismatch.%d or script mismatch\n",refdepositaddr,destaddr,uint256_str(str,txid),txid != cointxid); + } else LogPrint("gatewayscc","(%s) != (%s) or txid %s mismatch.%d or script mismatch\n",refdepositaddr,destaddr,uint256_str(str,txid),txid != cointxid); return(0); } @@ -534,7 +539,7 @@ int64_t GatewaysDepositval(CTransaction tx,CPubKey mypk) if ( DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,claimpubkey,amount) == 'D' && claimpubkey == mypk ) { // coin, bindtxid, publishers - fprintf(stderr,"need to validate deposittxid more\n"); + //LogPrint("gatewayscc","need to validate deposittxid more\n"); return(amount); } } @@ -557,7 +562,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 { if ( tokenid == reftokenid ) { - fprintf(stderr,"trying to bind an existing tokenid\n"); + LogPrint("gatewayscc","trying to bind an existing tokenid\n"); return(1); } } @@ -585,8 +590,6 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & uint256 hashblock,txid,bindtxid,deposittxid,withdrawtxid,completetxid,tokenid,tmptokenid,oracletxid,bindtokenid,cointxid,tmptxid,merkleroot,mhash; CTransaction bindtx,tmptx; std::string refcoin,tmprefcoin,hex,name,description,format; CPubKey pubkey,tmppubkey,gatewayspk; - // fprintf(stderr,"return true without gateways validation\n"); - // return(true); numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; @@ -594,25 +597,15 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("no vouts"); else { - // for (i=0; iInvalid("illegal normal vini"); - // } - // } - //fprintf(stderr,"check amounts\n"); + //LogPrint("gatewayscc","check amounts\n"); // if ( GatewaysExactAmounts(cp,eval,tx,1,10000) == false ) // { - // fprintf(stderr,"Gatewaysget invalid amount\n"); + // LogPrint("gatewayscc","Gatewaysget invalid amount\n"); // return false; // } // else // { - // txid = tx.GetHash(); - // memcpy(hash,&txid,sizeof(hash)); - gatewayspk = GetUnspendable(cp,0); - + gatewayspk = GetUnspendable(cp,0); if ( (funcid = DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)) != 0) { switch ( funcid ) @@ -710,7 +703,6 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & merkleroot = zeroid; for (i=m=0; iInvalid("tokenid does not match tokenid from gatewaysbind"); else if (komodo_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); - else if (K!=M) + else if (KInvalid("invalid number of signs!"); break; case 'M': @@ -832,34 +824,24 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & //vout.0: opreturn - 'M' withdrawtxid refcoin completetxid if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysMarkDoneOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,completetxid)!='M') return eval->Invalid("invalid gatewaysmarkdone OP_RETURN data!"); - else if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) - return eval->Invalid("vin.0 is CC for gatewaysmarkdone!"); + else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysmarkdone!"); + else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysmarkdone!"); + else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 ) + return eval->Invalid("vout.0 is normal for gatewaysmarkdone!"); else if (myGetTransaction(completetxid,tmptx,hashblock) == 0) - return eval->Invalid("invalid gatewaygatewayscompletesigning txid!"); + return eval->Invalid("invalid gatewayscompletesigning txid!"); else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S') return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); - else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); - else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for gatewayscompletesigning!"); - else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewayscompletesigning!"); + else if (komodo_txnotarizedconfirmed(completetxid) == false) + return eval->Invalid("gatewayscompletesigning tx is not yet confirmed(notarised)!"); else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid withdraw txid!"); else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,tmprefcoin,pubkey,amount)!='W') return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); else if (tmprefcoin!=refcoin) - return eval->Invalid("refcoin different than in bind tx"); - else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); - else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); - else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewaysWithdraw!"); - else if ( tmptx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.1 is CC for gatewaysWithdraw!"); - else if ( tmptx.vout[1].nValue!=amount) - return eval->Invalid("amount in opret not matching tx tokens amount!"); + return eval->Invalid("refcoin different than in bind tx"); else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) @@ -872,15 +854,15 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); else if (komodo_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); - else if (K!=M) + else if (KInvalid("invalid number of signs!"); break; } } retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) - fprintf(stderr,"Gatewaysget validated\n"); - else fprintf(stderr,"Gatewaysget invalid\n"); + fprintf(stderr,"Gateways tx validated\n"); + else fprintf(stderr,"Gateways tx invalid\n"); return(retval); // } } @@ -903,7 +885,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP GetTokensCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); threshold = total/(maxinputs+1); - fprintf(stderr,"check %s for gateway inputs\n",coinaddr); + LogPrint("gatewayscc","check %s for gateway inputs\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -945,9 +927,9 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP } return(totalinputs); } - else fprintf(stderr,"invalid GatewaysBind\n"); + else LogPrint("gatewayscc","invalid GatewaysBind\n"); } - else fprintf(stderr,"can't find GatewaysBind txid\n"); + else LogPrint("gatewayscc","can't find GatewaysBind txid\n"); return(0); } @@ -968,19 +950,21 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t } else { - fprintf(stderr,"set taddr, prefix, prefix2 for %s\n",coin.c_str()); + LogPrint("gatewayscc","set taddr, prefix, prefix2 for %s\n",coin.c_str()); taddr = 0; prefix = 60; prefix2 = 85; } if ( N == 0 || N > 15 || M > N ) { - fprintf(stderr,"illegal M.%d or N.%d\n",M,N); + CCerror = strprintf("illegal M.%d or N.%d",M,N); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( pubkeys.size() != N ) { - fprintf(stderr,"M.%d N.%d but pubkeys[%d]\n",M,N,(int32_t)pubkeys.size()); + CCerror = strprintf("M.%d N.%d but pubkeys[%d]",M,N,(int32_t)pubkeys.size()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } for (i=0; iunspendableCCaddr,(double)totalsupply/COIN,(double)fullsupply/COIN); + CCerror = strprintf("Gateway bind.%s (%s) globaladdr.%s totalsupply %.8f != fullsupply %.8f",coin.c_str(),uint256_str(str,tokenid),cp->unspendableCCaddr,(double)totalsupply/COIN,(double)fullsupply/COIN); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( CCtoken_balance(myTokenCCaddr,tokenid) != totalsupply ) { - fprintf(stderr,"token balance on %s %.8f != %.8f\n",myTokenCCaddr,(double)CCtoken_balance(myTokenCCaddr,tokenid)/COIN,(double)totalsupply/COIN); + CCerror = strprintf("token balance on %s %.8f != %.8f",myTokenCCaddr,(double)CCtoken_balance(myTokenCCaddr,tokenid)/COIN,(double)totalsupply/COIN); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) { - fprintf(stderr,"cant find oracletxid %s\n",uint256_str(str,oracletxid)); + CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' ) { - fprintf(stderr,"mismatched oracle name %s != %s\n",name.c_str(),coin.c_str()); + CCerror = strprintf("mismatched oracle name %s != %s",name.c_str(),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( (fstr=(char *)format.c_str()) == 0 || strncmp(fstr,"Ihh",3) != 0 ) { - fprintf(stderr,"illegal format (%s) != (%s)\n",fstr,(char *)"Ihh"); + CCerror = strprintf("illegal format (%s) != (%s)",fstr,(char *)"Ihh"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( GatewaysBindExists(cp,gatewayspk,tokenid) != 0 ) { - fprintf(stderr,"Gateway bind.%s (%s) already exists\n",coin.c_str(),uint256_str(str,tokenid)); + CCerror = strprintf("Gateway bind.%s (%s) already exists",coin.c_str(),uint256_str(str,tokenid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) @@ -1042,7 +1034,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t } } CCerror = strprintf("cant find enough inputs"); - fprintf(stderr,"%s\n", CCerror.c_str() ); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } @@ -1057,22 +1049,30 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - //fprintf(stderr,"GatewaysDeposit ht.%d %s %.8f numpks.%d\n",height,refcoin.c_str(),(double)amount/COIN,(int32_t)pubkeys.size()); + //LogPrint("gatewayscc","GatewaysDeposit ht.%d %s %.8f numpks.%d\n",height,refcoin.c_str(),(double)amount/COIN,(int32_t)pubkeys.size()); if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) { - fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin ) { - fprintf(stderr,"invalid coin - bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); + CCerror = strprintf("invalid coin - bindtxid %s coin.%n",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if (komodo_txnotarizedconfirmed(bindtxid)==false) + { + CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } n = (int32_t)pubkeys.size(); merkleroot = zeroid; for (i=m=0; i 0 ) @@ -1108,7 +1111,8 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,cointxid))) << OP_CHECKSIG)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysDepositOpRet('D',bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,destpub,amount))); } - fprintf(stderr,"cant find enough inputs\n"); + CCerror = strprintf("cant find enough inputs"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } @@ -1127,32 +1131,50 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui gatewayspk = GetUnspendable(cp,0); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) { - fprintf(stderr,"invalid coin - bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); + CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if (komodo_txnotarizedconfirmed(bindtxid)==false) + { + CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( GetTransaction(deposittxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - fprintf(stderr,"cant find deposittxid %s\n",uint256_str(str,bindtxid)); + CCerror = strprintf("cant find deposittxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if (DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmptxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D' || coin != refcoin) { - fprintf(stderr,"invalid coin - deposittxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); + CCerror = strprintf("invalid coin - deposittxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if (komodo_txnotarizedconfirmed(deposittxid)==false) + { + CCerror = strprintf("gatewaysdeposit tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if (tmpdestpub!=destpub) { - fprintf(stderr,"different destination pubkey from desdeposittxid\n"); + CCerror = strprintf("different destination pubkey from desdeposit tx"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( (depositamount=GatewaysDepositval(tx,mypk)) != amount ) { - fprintf(stderr,"invalid Gateways deposittxid %s %.8f != %.8f\n",uint256_str(str,deposittxid),(double)depositamount/COIN,(double)amount/COIN); + CCerror = strprintf("invalid Gateways deposittxid %s %.8f != %.8f",uint256_str(str,deposittxid),(double)depositamount/COIN,(double)amount/COIN); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) @@ -1167,7 +1189,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui } } CCerror = strprintf("cant find enough inputs or mismatched total"); - fprintf(stderr,"%s\n", CCerror.c_str() ); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } @@ -1175,7 +1197,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction tx; CPubKey mypk,gatewayspk,signerpk; uint256 txid,tokenid,hashBlock,oracletxid,tmptokenid,tmpbindtxid,withdrawtxid; int32_t vout,numvouts; - int64_t nValue,totalsupply,inputs,CCchange=0; uint8_t funcid,K,M,N,taddr,prefix,prefix2; std::string coin,hex; + int64_t nValue,totalsupply,inputs,CCchange=0,tmpamount; uint8_t funcid,K,M,N,taddr,prefix,prefix2; std::string coin,hex; std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C,*cpTokens,CTokens; std::vector > unspentOutputs; @@ -1188,12 +1210,20 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) { - fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if (komodo_txnotarizedconfirmed(bindtxid)==false) + { + CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); @@ -1207,20 +1237,20 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P')) { - if (funcid=='W' && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)=='W' + if (funcid=='W' && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) { - CCerror = strprintf("unable to create withdraw, another withdraw pending\n"); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("unable to create withdraw, another withdraw pending"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (funcid=='P' && DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' && - GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)=='W' + GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) { - CCerror = strprintf("unable to create withdraw, another withdraw pending\n"); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("unable to create withdraw, another withdraw pending"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } } @@ -1238,12 +1268,12 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin else { CCerror = strprintf("not enough balance of tokens for withdraw"); - fprintf(stderr,"%s\n", CCerror.c_str() ); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } } CCerror = strprintf("cant find enough normal inputs"); - fprintf(stderr,"%s\n", CCerror.c_str() ); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } @@ -1263,8 +1293,8 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { - CCerror = strprintf("can't find last tx %s\n",uint256_str(str,lasttxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if (funcid=='W') @@ -1272,21 +1302,27 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc withdrawtxid=lasttxid; if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { - CCerror = strprintf("invalid withdraw tx %s\n",uint256_str(str,lasttxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { - CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { - CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } } @@ -1294,41 +1330,52 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc { if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) { - CCerror = strprintf("cannot decode partialsign tx opret %s\n",uint256_str(str,lasttxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) { - CCerror = strprintf("can't find withdraw tx %s\n",uint256_str(str,withdrawtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { - CCerror = strprintf("invalid withdraw tx %s\n",uint256_str(str,lasttxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { - CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { - CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } } - if (AddNormalinputs(mtx,mypk,txfee,3)==0) fprintf(stderr,"error adding funds for partialsign\n"); - mtx.vin.push_back(CTxIn(tx.GetHash(),0,CScript())); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysPartialOpRet('P',withdrawtxid,refcoin,K+1,mypk,hex))); + if (AddNormalinputs(mtx,mypk,txfee,3)!=0) + { + mtx.vin.push_back(CTxIn(tx.GetHash(),0,CScript())); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysPartialOpRet('P',withdrawtxid,refcoin,K+1,mypk,hex))); + } + CCerror = strprintf("error adding funds for partialsign"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); } std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string refcoin,std::string hex) @@ -1346,8 +1393,8 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { - CCerror = strprintf("invalid last txid %s\n",uint256_str(str,lasttxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if (funcid=='W') @@ -1355,21 +1402,27 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string withdrawtxid=lasttxid; if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { - CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,lasttxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,lasttxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { - CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { - CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } } @@ -1377,41 +1430,51 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string { if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) { - CCerror = strprintf("cannot decode partialsign tx opret %s\n",uint256_str(str,lasttxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) { - CCerror = strprintf("invalid withdraw txid %s\n",uint256_str(str,withdrawtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { - printf("aaaaaaaaaaa\n"); - CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,withdrawtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { - CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { - CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } } - if (AddNormalinputs(mtx,mypk,txfee,3)==0) fprintf(stderr,"error adding funds for completesigning\n"); - mtx.vin.push_back(CTxIn(lasttxid,0,CScript())); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,K+1,hex))); + if (AddNormalinputs(mtx,mypk,txfee,3)!=0) + { + mtx.vin.push_back(CTxIn(lasttxid,0,CScript())); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,K+1,hex))); + } + CCerror = strprintf("error adding funds for completesigning"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); } std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin) @@ -1427,43 +1490,56 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref txfee = 10000; if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) { - CCerror = strprintf("invalid completesigning txid %s\n",uint256_str(str,completetxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex)!='S' || refcoin!=coin) { - CCerror = strprintf("cannot decode completesigning tx opret %s\n",uint256_str(str,completetxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cannot decode completesigning tx opret %s",uint256_str(str,completetxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if (komodo_txnotarizedconfirmed(completetxid)==false) + { + CCerror = strprintf("gatewayscompletesigning tx not yet confirmed/notarized"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) { - CCerror = strprintf("invalid withdraw txid %s\n",uint256_str(str,withdrawtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) { - CCerror = strprintf("can't find bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { - CCerror = strprintf("invalid bind tx %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - mtx.vin.push_back(CTxIn(completetxid,0,CScript())); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',withdrawtxid,refcoin,completetxid))); + if (AddNormalinputs(mtx,mypk,txfee,3)!=0) + { + mtx.vin.push_back(CTxIn(completetxid,0,CScript())); + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',withdrawtxid,refcoin,completetxid))); + } + CCerror = strprintf("error adding funds for markdone"); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); } UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) @@ -1481,14 +1557,14 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) _GetCCaddress(coinaddr,EVAL_GATEWAYS,mypk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - CCerror = strprintf("cant find bindtxid %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin) { - CCerror = strprintf("invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } SetCCunspents(unspentOutputs,coinaddr); @@ -1535,14 +1611,14 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) GetTokensCCaddress(cp,tokensaddr,gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - CCerror = strprintf("cant find bindtxid %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin ) { - CCerror = strprintf("invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } n = msigpubkeys.size(); @@ -1623,14 +1699,14 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - CCerror = strprintf("cant find bindtxid %s\n",uint256_str(str,bindtxid)); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin) { - CCerror = strprintf("invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); - fprintf(stderr,"%s\n", CCerror.c_str() ); + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } n = msigpubkeys.size(); @@ -1660,6 +1736,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) obj.push_back(Pair("withdrawtxidaddr",txidaddr)); Getscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG); obj.push_back(Pair("withdrawaddr",withaddr)); + obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); obj.push_back(Pair("amount",numstr)); obj.push_back(Pair("hex",hex)); @@ -1697,15 +1774,27 @@ UniValue GatewaysInfo(uint256 bindtxid) CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaystokens[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; - CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t totalsupply,remaining; + CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t numvouts,totalsupply,remaining; std::vector msigpubkeys; - result.push_back(Pair("result","success")); - result.push_back(Pair("name","Gateways")); cp = CCinit(&C,EVAL_GATEWAYS); Gatewayspk = GetUnspendable(cp,0); GetTokensCCaddress(cp,gatewaystokens,Gatewayspk); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B') + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) { + result.push_back(Pair("result","success")); + result.push_back(Pair("name","Gateways")); depositaddr[0] = 0; if ( tx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[tx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 0 && M <= N && N > 0 ) { From b9779b671c58466c299bb7df5bb1eb83edbd2a91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 13:31:02 +0800 Subject: [PATCH 1775/3904] add LABST2 to block reward chains. Add exeption to verushash staker to increase staking diff in first 50 bocks. --- src/komodo_bitcoind.h | 2 +- src/notaries_staked.cpp | 14 +++++++------- src/notaries_staked.h | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0a72903da..a40a174b1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1437,7 +1437,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh { // Under PoS % target and we need to increase diff. //fprintf(stderr, "PoS too low diff.%i changed to.",diff); - diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) ); + diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) * ( nHeight < 50 ? 1000 : 1)); //fprintf(stderr, "%i \n",diff); } else if ( PoSperc > ASSETCHAINS_STAKED ) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index cdaffa7a2..6e6912256 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,16 +17,16 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "PAYME") == 0) || (strcmp(chain_name, "LABST") == 0) ) - STAKED = 1; - else if ( (strncmp(chain_name, "LABS", 4) == 0) ) - STAKED = 2; + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABST2") == 0) ) + STAKED = 1; // These chains are allowed coin emissions. + else if ( (strncmp(chain_name, "LABS", 4) == 0) ) + STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; + STAKED = 3; // These chains have no speical rules at all. else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; + STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant ot be actually used for anything important. else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) - STAKED = 255; // This means that all notarisations for chains that are in 255 group are invalid. + STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. doneinit = 1; return(STAKED); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 468b7b7ca..ed195bf48 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -24,6 +24,7 @@ static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549188000, 1604233333, 1604244444}; +static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 19, 17 }; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = @@ -116,8 +117,6 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = } }; -static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 19, 17 }; - int8_t is_STAKED(const char *chain_name); int32_t STAKED_era(int timestamp); int8_t updateStakedNotary(); From dd8f2697b7200077b228b74742200ace828ab682 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:25:32 -1100 Subject: [PATCH 1776/3904] Many changes --- src/cc/CCassetstx.cpp | 2 +- src/cc/CCinclude.h | 4 +- src/cc/CCtokens.cpp | 2 +- src/cc/CCtx.cpp | 6 +- src/cc/cclib.cpp | 83 ++-- src/cc/channels.cpp | 2 +- src/cc/dice.cpp | 10 +- src/cc/faucet.cpp | 2 +- src/cc/gateways.cpp | 6 +- src/cc/heir.cpp | 4 +- src/cc/marmara.cpp | 6 +- src/cc/oracles.cpp | 4 +- src/cc/payments.cpp | 2 +- src/cc/pegs.cpp | 2 +- src/cc/prices.cpp | 2 +- src/cc/rewards.cpp | 4 +- src/cc/rogue/main.c | 1 - src/cc/rogue_rpc.cpp | 890 ++++++++++++++++++++++++--------------- src/cc/sudoku.cpp | 27 +- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 10 +- src/rpc/blockchain.cpp | 8 +- src/wallet/rpcwallet.cpp | 207 ++++----- 23 files changed, 759 insertions(+), 527 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 9d83beb2c..1ed43eb28 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -47,7 +47,7 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK if( strcmp(destaddr,coinaddr) != 0 && strcmp(destaddr,cp->unspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) continue; fprintf(stderr,"AddAssetInputs() check destaddress=%s vout amount=%.8f\n",destaddr,(double)vintx.vout[vout].nValue/COIN); - if( (nValue = IsAssetvout(cp, price, origpubkey, vintx, vout, assetid)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if( (nValue = IsAssetvout(cp, price, origpubkey, vintx, vout, assetid)) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 07c5e9491..52f2d7c1f 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -138,11 +138,13 @@ CBlockIndex *komodo_blockindex(uint256 hash); CBlockIndex *komodo_chainactive(int32_t height); static const uint256 zeroid; +static uint256 ignoretxid; +static int32_t ignorevin; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); int32_t is_hexstr(char *str,int32_t n); bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false); int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag); -bool myIsutxo_spentinmempool(uint256 txid,int32_t vout); +bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout); bool mytxid_inmempool(uint256 txid); int32_t myIsutxo_spent(uint256 &spenttxid,uint256 txid,int32_t vout); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index d7db32b99..61b8d6dd1 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -594,7 +594,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C std::vector vinPubkeys; - if ((nValue = IsTokensvout(true, true/*<--add only checked token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + if ((nValue = IsTokensvout(true, true/*<--add only checked token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid, vout) == 0) { if (total != 0 && maxinputs != 0) mtx.vin.push_back(CTxIn(txid, vout, CScript())); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index d93185ca4..630c887f0 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -341,7 +341,7 @@ int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag) CCoinsViewMemPool view(pcoinsTip, mempool); if (!view.GetCoins(txid, coins)) return(-1); - if ( myIsutxo_spentinmempool(txid,vout) != 0 ) + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) return(-1); } else @@ -507,7 +507,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 if ( i != n ) continue; } - if ( myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { up = &utxos[n++]; up->txid = txid; @@ -598,7 +598,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput if ( i != n ) continue; } - if ( myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { up = &utxos[n++]; up->txid = txid; diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e71171b71..aa7a9e1ff 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -47,21 +47,20 @@ struct CClib_rpcinfo int32_t numrequiredargs,maxargs; uint8_t funcid,evalcode; } -// creategame, register (inventory + baton + buyin), progress (events + statehash + [compr state]?), claimwin CClib_methods[] = { { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, #ifdef BUILD_ROGUE - { (char *)"rogue", (char *)"newgame", (char *)"buyin", 0, 1, 'G', EVAL_ROGUE }, - { (char *)"rogue", (char *)"txidinfo", (char *)"txid", 1, 1, 'I', EVAL_ROGUE }, + { (char *)"rogue", (char *)"newgame", (char *)"maxplayers buyin", 0, 2, 'G', EVAL_ROGUE }, + { (char *)"rogue", (char *)"gameinfo", (char *)"gametxid", 1, 1, 'T', EVAL_ROGUE }, { (char *)"rogue", (char *)"pending", (char *)"", 0, 0, 'P', EVAL_ROGUE }, - { (char *)"rogue", (char *)"register", (char *)"txid [inventory]", 1, 2, 'R', EVAL_ROGUE }, - { (char *)"rogue", (char *)"progress", (char *)"regtxid fname", 2, 2, 'K', EVAL_ROGUE }, - { (char *)"rogue", (char *)"saveandquit", (char *)"ptxid", 1, 1, 'Q', EVAL_ROGUE }, - { (char *)"rogue", (char *)"claimwin", (char *)"ptxid", 1, 1, 'W', EVAL_ROGUE }, - { (char *)"rogue", (char *)"extract", (char *)"wtxid item", 2, 2, 'X', EVAL_ROGUE }, + { (char *)"rogue", (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_ROGUE }, + { (char *)"rogue", (char *)"keystrokes", (char *)"gametxid keystrokes", 2, 2, 'K', EVAL_ROGUE }, + { (char *)"rogue", (char *)"bailout", (char *)"baton finalhash", 2, 2, 'Q', EVAL_ROGUE }, + { (char *)"rogue", (char *)"highlander", (char *)"baton finalhash", 2, 2, 'H', EVAL_ROGUE }, + { (char *)"rogue", (char *)"playerinfo", (char *)"playertxid", 1, 1, 'I', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -81,12 +80,12 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue rogue_progress(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue rogue_saveandquit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue rogue_claimwin(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -102,23 +101,22 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) #ifdef BUILD_ROGUE if ( cp->evalcode == EVAL_ROGUE ) { - rogue_replay(777,0); if ( strcmp(method,"newgame") == 0 ) return(rogue_newgame(txfee,cp,params)); else if ( strcmp(method,"pending") == 0 ) return(rogue_pending(txfee,cp,params)); - else if ( strcmp(method,"txidinfo") == 0 ) - return(rogue_txidinfo(txfee,cp,params)); + else if ( strcmp(method,"gameinfo") == 0 ) + return(rogue_gameinfo(txfee,cp,params)); else if ( strcmp(method,"register") == 0 ) return(rogue_register(txfee,cp,params)); - else if ( strcmp(method,"progress") == 0 ) - return(rogue_progress(txfee,cp,params)); - else if ( strcmp(method,"saveandquit") == 0 ) + else if ( strcmp(method,"keystrokes") == 0 ) + return(rogue_keystrokes(txfee,cp,params)); + else if ( strcmp(method,"bailout") == 0 ) return(rogue_saveandquit(txfee,cp,params)); - else if ( strcmp(method,"claimwin") == 0 ) + else if ( strcmp(method,"highlander") == 0 ) + return(rogue_claimwin(txfee,cp,params)); + else if ( strcmp(method,"playerinfo") == 0 ) return(rogue_claimwin(txfee,cp,params)); - else if ( strcmp(method,"extract") == 0 ) - return(rogue_extract(txfee,cp,params)); else { result.push_back(Pair("result","error")); @@ -328,7 +326,7 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr) { - char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; + char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0,txfee = 10000; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); @@ -338,12 +336,12 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK txid = it->first.txhash; vout = (int32_t)it->first.index; //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); - if ( it->second.satoshis < threshold ) + if ( it->second.satoshis < threshold || it->second.satoshis == txfee ) continue; // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) >= 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -439,6 +437,41 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para return(""); } +UniValue cclib_error(UniValue &result,const char *errorstr) +{ + result.push_back(Pair("status","error")); + result.push_back(Pair("error",errorstr)); + return(result); +} + +cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will be freed by caller +{ + cJSON *params; char *jsonstr,*newstr; int32_t i,j; + if ( (jsonstr= jprint(origparams,0)) != 0 ) + { + if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) + { + jsonstr[strlen(jsonstr)-1] = 0; + jsonstr++; + } + newstr = (char *)malloc(strlen(jsonstr)+1); + for (i=j=0; jsonstr[i]!=0; i++) + { + if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) + { + newstr[j++] = '"'; + i += 2; + } else newstr[j++] = jsonstr[i]; + } + newstr[j] = 0; + params = cJSON_Parse(newstr); + free(newstr); + *nump = cJSON_GetArraySize(params); + //free(origparams); + } else params = 0; + return(params); +} + #ifdef BUILD_ROGUE #include "rogue_rpc.cpp" #include "rogue/vers.c" diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 6cd379eed..e6f4b48c6 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -430,7 +430,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C } } } - if (txid!=zeroid && myIsutxo_spentinmempool(txid,0) != 0) + if (txid!=zeroid && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) != 0) { txid=zeroid; int32_t mindepth=CHANNELS_MAXPAYMENTS; diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 05dad9bf6..1bb44af18 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -269,7 +269,7 @@ int32_t dicefinish_utxosget(int32_t &total,struct dicefinish_utxo *utxos,int32_t LOCK(mempool.cs); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - if ( myIsutxo_spentinmempool(it->first.txhash,(int32_t)it->first.index) == 0 ) + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,it->first.txhash,(int32_t)it->first.index) == 0 ) { if ( it->second.satoshis < threshold || it->second.satoshis > 10*threshold ) continue; @@ -302,7 +302,7 @@ int32_t dice_betspent(char *debugstr,uint256 bettxid) } { //LOCK(mempool.cs); - if ( myIsutxo_spentinmempool(bettxid,0) != 0 || myIsutxo_spentinmempool(bettxid,1) != 0 ) + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,bettxid,0) != 0 || myIsutxo_spentinmempool(ignoretxid,ignorevin,bettxid,1) != 0 ) { fprintf(stderr,"%s bettxid.%s already spent in mempool\n",debugstr,bettxid.GetHex().c_str()); return(-1); @@ -1067,7 +1067,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK break; if ( j != mtx.vin.size() ) continue; - if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( (funcid= DecodeDiceOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof)) != 0 ) { @@ -1176,7 +1176,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit continue; } } - if ( myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { entropytxid = txid; entropyval = tx.vout[0].nValue; @@ -1447,7 +1447,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CCerror = "Your dealer is broke, find a new casino."; return(""); } - if ( myIsutxo_spentinmempool(entropytxid,0) != 0 ) + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,entropytxid,0) != 0 ) { CCerror = "entropy txid is spent"; return(""); diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index 6e59b6c1a..b44337461 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -157,7 +157,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsFaucetvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsFaucetvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 4e2f64184..cc7e062dc 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -1499,7 +1499,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) nValue = (int64_t)it->second.satoshis; if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,cointxid,claimvout,hex,proof,destpub,amount) == 'D' - && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(txid,vout) == 0) + && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("cointxid",uint256_str(str,cointxid))); @@ -1561,7 +1561,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) nValue = (int64_t)it->second.satoshis; K=0; if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && - (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(txid,vout) == 0) + (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { if (funcid=='W') { @@ -1648,7 +1648,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && - DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(txid,vout) == 0) + DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin || tmptokenid!=tokenid) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 04866594d..4fea0be1e 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -541,7 +541,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, isMyFuncId(funcId) && (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid) > 0) && // token validation logic //(voutValue = IsHeirFundingVout(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && // heir contract vout validation logic - not used since we moved to 2-eval vouts - !myIsutxo_spentinmempool(txid, voutIndex)) + !myIsutxo_spentinmempool(ignoretxid,ignorevin,txid, voutIndex)) { std::cerr << "Add1of2AddressInputs() satoshis=" << it->second.satoshis << std::endl; if (total != 0 && maxinputs != 0) @@ -591,7 +591,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info (txid == fundingtxid || fundingTxidInOpret == fundingtxid) && isMyFuncId(funcId) && !isSpendingTx(funcId) && (typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, ivout, tokenid) > 0) && - !myIsutxo_spentinmempool(txid, ivout)) // exclude tx in mempool + !myIsutxo_spentinmempool(ignoretxid,ignorevin,txid, ivout)) // exclude tx in mempool { total += it->second; // dont do this: tx.vout[ivout].nValue; // in vin[0] always is the pay to 1of2 addr (funding or change) //std::cerr << "LifetimeHeirContractFunds() added tx=" << txid.GetHex() << " it->second=" << it->second << " vout[0].nValue=" << tx.vout[ivout].nValue << " opreturn=" << (char)funcId << '\n'; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 0e301ba97..8bb306d9b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -366,7 +366,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, { if ( DecodeMaramaraCoinbaseOpRet(vintx.vout[1].scriptPubKey,pk,ht,unlockht) == 'C' && unlockht == unlocks && pk == poolpk && ht >= firstheight ) { - if ( (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -395,7 +395,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, vout = (int32_t)it->first.index; if ( it->second.satoshis < threshold ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) { @@ -462,7 +462,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) vout = (int32_t)it->first.index; if ( (nValue= it->second.satoshis) < threshold ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) { diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 66c0e1b9a..bf3bf444a 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -294,7 +294,7 @@ uint256 OracleBatonUtxo(uint64_t txfee,struct CCcontract_info *cp,uint256 refora } } } - while ( myIsutxo_spentinmempool(batontxid,1) != 0 ) + while ( myIsutxo_spentinmempool(ignoretxid,ignorevin,batontxid,1) != 0 ) batontxid = myIs_baton_spentinmempool(batontxid,1); return(batontxid); } @@ -724,7 +724,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint else if (tmporacletxid==oracletxid) { // get valid CC payments - if ( (nValue= IsOraclesvout(cp,vintx,vout)) >= 10000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsOraclesvout(cp,vintx,vout)) >= 10000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 859a5ba3f..c4f476cfb 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -127,7 +127,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsPaymentsvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsPaymentsvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index e2893bec8..c435d9920 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -134,7 +134,7 @@ int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsPegsvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsPegsvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 369495b1a..df1b5e18e 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -141,7 +141,7 @@ int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && vout < vintx.vout.size() ) { // need to verify assetid - if ( (nValue= vintx.vout[vout].nValue) >= 10000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= vintx.vout[vout].nValue) >= 10000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index b9f4677be..c201869b0 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -310,7 +310,7 @@ static uint64_t myIs_unlockedtx_inmempool(uint256 &txid,int32_t &vout,uint64_t r if ( tx.vout.size() > 0 && tx.vout[0].nValue >= needed ) { const uint256 &hash = tx.GetHash(); - if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(hash,0) == 0 ) + if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,hash,0) == 0 ) { if ( (funcid= DecodeRewardsOpRet(hash,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) == 'U' && sbits == refsbits && fundingtxid == reffundingtxid ) { @@ -346,7 +346,7 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcont break; if ( j != mtx.vin.size() ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) != 0 ) { diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 7efdebc8d..d2805ed73 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -13,7 +13,6 @@ * * ******************************************************************************/ - #include #include #include diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cf7ebeb70..4fb850ef0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -15,229 +15,600 @@ ******************************************************************************/ #include "cJSON.h" -// creategame, register (inventory + baton + buyin), progress (seed + firsthash + statehash + events), claimwin -// create game buyin, newbie flag, 10 blocks registration seed is starting blockhash! -// inheritance of items across games! -// binding tokens to specific items to allow for built in market -// pubkey token inventory creates items can be used for a specific campaign -// player wins buyins + ingame gold -> ROGUE + ingame items -> tokens via 1 vout per item to be spent into a token opreturn #define ROGUE_REGISTRATION 5 +#define ROGUE_REGISTRATIONSIZE (100 * 10000) +#define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching +#defein ROGUE_MAXKEYSTROKESGAP 60 + +/* + the idea is that you creategame and get a txid, you specify the maxplayers and buyin for the game. the tx will have maxplayers of vouts. You must have a non-zero buyin to be able to use a preexisting character. + + creategame + vout0 -> txfee highlander vout TCBOO creation + vout1 -> txfee highlander vout TCBOO playerdata used + vout2 to vout.maxplayers -> 1of2 registration ROGUE_REGISTRATIONSIZE batons + + registration + vin0 -> ROGUE_REGISTRATIONSIZE 1of2 registration baton from creategame + vin1 -> optional nonfungible character vout @ + vin2 -> original creation TCBOO playerdata used + vin3+ -> buyin + vout0 -> keystrokes/completion baton + + keystrokes + vin0 -> txfee 1of2 baton from registration or previous keystrokes + opret -> user input chars + + bailout: must be within 777 blocks of last keystrokes + vin0 -> keystrokes baton of completed game with Q + vout0 -> 1% ingame gold + + highlander + vin0 -> txfee highlander vout from creategame TCBOO creation + vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 777 blocks since last keystrokes, it is forfeit + vins -> rest of unspent registration utxo so all newgame vouts are spent + vout0 -> nonfungible character with pack @ + vout1 -> 1% ingame gold and all the buyins + + + then to register you need to spend one of the vouts and also provide the buyin + once you register the gui mode is making automatic keystrokes tx with the raw chars in opreturn. + if during the registration, you provide a character as an input, your gameplay starts with that character instead of the default + + each keystrokes tx spends a baton vout that you had in your register tx + + so from the creategame tx, you can trace the maxplayers vouts to find all the registrations and all the keystrokes to get the keyboard events + + If you quit out of the game, then the in game gold that you earned can be converted to ROGUE coins, but unless you are the last one remaining, any character you input, is permanently spent + + so you can win a multiplayer by being the last player to quit or the first one to win. In either case, you would need to spend a special highlander vout in the original creategame tx. having this as an input allows to create a tx that has the character as the nonfungible token, collect all the buyin and of course the ingame gold + + once you have a non-fungible token, ownership of it can be transferred or traded or spent in a game + */ + //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & -// cclib newgame 17 +// cclib newgame 17 \"[maxplayers,buyin]\" // cclib pending 17 -// cclib txidinfo 17 \"35e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f\" +// cclib txidinfo 17 \"[%2235e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"35e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f\" [items] -// cclib pending 17 \"\" starthash endhash keystrokes +// cclib register 17 \"[%2235e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f%22,%22%22]\" +// cclib keystrokes 17 \"[]\" -CScript rogue_newgameopret(int64_t buyin) +CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { CScript opret; uint8_t evalcode = EVAL_ROGUE; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << buyin); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << buyin << maxplayers); return(opret); } -/*CScript rogue_solutionopret(char *solution,uint32_t timestamps[81]) +CScript rogue_registeropret(uint256 gametxid,uint256 playertxid) { - CScript opret; uint8_t evalcode = EVAL_ROGUE; std::string str(solution); std::vector data; int32_t i; - for (i=0; i<81; i++) - { - data.push_back((timestamps[i] >> 24) & 0xff); - data.push_back((timestamps[i] >> 16) & 0xff); - data.push_back((timestamps[i] >> 8) & 0xff); - data.push_back(timestamps[i] & 0xff); - } - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'S' << str << data); + CScript opret; uint8_t evalcode = EVAL_ROGUE; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'R' << gametxid << playertxid); return(opret); } -uint8_t rogue_solutionopreturndecode(char solution[82],uint32_t timestamps[81],CScript scriptPubKey) +CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std::vectorkeystrokes) { - std::vector vopret; uint8_t *script,e,f; std::string str; std::vector data; int32_t i,ind; uint32_t x; - GetOpReturnData(scriptPubKey,vopret); - script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> str; ss >> data) != 0 && e == EVAL_ROGUE && f == 'S' ) - { - if ( data.size() == 81*sizeof(uint32_t) && str.size() == 81 ) - { - strcpy(solution,str.c_str()); - for (i=ind=0; i<81; i++) - { - if ( solution[i] < '1' || solution[i] > '9' ) - break; - x = data[ind++]; - x <<= 8, x |= (data[ind++] & 0xff); - x <<= 8, x |= (data[ind++] & 0xff); - x <<= 8, x |= (data[ind++] & 0xff); - timestamps[i] = x; - } - if ( i == 81 ) - return(f); - } else fprintf(stderr,"datasize %d sol[%d]\n",(int32_t)data.size(),(int32_t)str.size()); - } - return(0); -}*/ + CScript opret; uint8_t evalcode = EVAL_ROGUE; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << batontxid << pk << keystrokes); + return(opret); +} -uint8_t rogue_newgameopreturndecode(int64_t &buyin,CScript scriptPubKey) +CScript rogue_highlanderopret(uint256 gametxid,uint256 registertxid,CPubKey pk,std::vectorplayerdata) +{ + CScript opret; uint8_t evalcode = EVAL_ROGUE; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << registertxid << pk << playerdata); + return(opret); +} + +uint8_t rogue_highlanderopretdecode(uint256 &gametxid,uint256 ®istertxid,CPubKey &pk,std::vector &playerdata,CSript scriptPubKey) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin) != 0 && e == EVAL_ROGUE && f == 'G' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> registertxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && f == 'H' ) { return(f); } return(0); } +uint8_t rogue_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey &pk,std::vector &keystrokes,CScript scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> batontxid; ss >> pk; ss >> keystrokes) != 0 && e == EVAL_ROGUE && f == 'K' ) + { + return(f); + } + return(0); +} + +uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &playertxid,CScript scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) + { + return(f); + } + return(0); +} + +uint8_t rogue_newgameopreturndecode(int64_t &buyin,int32_t &maxplayers,CScript scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin; ss >> mayplayers) != 0 && e == EVAL_ROGUE && f == 'G' ) + { + return(f); + } + return(0); +} + +void rogue_univalue(UniValue &result,const char *method,int64_t maxplayers,int64_t buyin) +{ + if ( method != 0 ) + { + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method",method)); + } + if ( maxplayers > 0 ) + result.push_back(Pair("maxplayers",maxplayers)); + if ( buyin >= 0 ) + { + result.push_back(Pair("buyin",ValueFromAmount(buyin))); + if ( buyin == 0 ) + result.push_back(Pair("type","newbie")); + else result.push_back(Pair("type","buyin")); + } +} + +void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin) +{ + CBlockIndex *pindex; int32_t ht; uint64_t seed; char cmd[512]; + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + ht = pindex->GetHeight(); + obj.push_back(Pair("height",ht)); + obj.push_back(Pair("start",ht+ROGUE_REGISTRATION)); + if ( komodo_nextheight() > ht+ROGUE_REGISTRATION ) + { + if ( (pindex= komodo_chainactive(ht+ROGUE_REGISTRATION)) != 0 ) + { + hashBlock = pindex->GetBlockHash(); + obj.push_back(Pair("starthash",hashBlock.ToString())); + memcpy(&seed,&hashBlock,sizeof(seed)); + seed &= (1LL << 62) - 1; + obj.push_back(Pair("seed",(int64_t)seed)); + sprintf(cmd,"./rogue %llu gui",(long long)seed); + obj.push_back(Pair("run",cmd)); + } + } + } + obj.push_back(Pair("maxplayers",maxplayers)); + obj.push_back(Pair("buyin",ValueFromAmount(buyin))); +} + +int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid) +{ + uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; + buyin = maxplayers = 0; + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) + { + if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + if ( numvouts > maxplayers+2 ) + { + for (i=0; i playerdata) +{ + obj.push_back("raw",playerdata.ToString()); + // convert to scrolls, etc. + return(obj); +} + +int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once +{ + uint256 spenttxid,txid = firsttxid; int32_t spentvini,vout = 0; + while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) + { + txid = spenttxid; + } + if ( txid == lasttxid ) + return(0); + else + { + fprintf(stderr,"firsttxid.%s -> %s != last.%s\n",firsttxid.ToString(),txid.ToString(),lasttxid.ToString()); + return(-1); + } +} + +/* + playertxid is whoever owns the nonfungible satoshi and it might have been bought and sold many times. + highlander is the game winning tx with the player data and is the only place where the unique player data exists + origplayergame is the gametxid that ends up being won by the highlander and they are linked directly as the highlander tx spends gametxid.vout0 + 'S' is for sell, but will need to change to accomodate assets + */ + +int32_t rogue_playerdata(uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) +{ + uint256 origplayertxid,hashBlock,highlander,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,maxplayers; int64_t buyin; + if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) + { + GetOpReturnData(scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'S') ) + { + memcpy(&highlander,script+2,sizeof(highlander)); + highlander = revuint256(highlander); + fprintf(stderr,"got highlander.%s\n",highlander.ToString().c_str()); + if ( rogue_iterateplayer(highlander,playertxid) == 0 ) + { + if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) + { + if ( rogue_highlanderopretdecode(origplayergame,registertxid,pk,playerdata,highlandertx.vout[numvouts-1].scriptPubKey) == 'H' ) + { + if ( highlandertx.vin[0].prev.hash == prigplayergame && highlandertx.vin[0].prev.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) + return(0); + else return(-3); + } + } + } else return(-2); + } + } + return(-1); +} + +int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint256 origplayergame) +{ + int64_t txfee = 10000; + if ( CCgettxout(playertxid,0,1) == txfee && CCgettxout(origplayergame,1,1) == txfee ) + { + mtx.vin.push_back(playertxid,0,CScript()); + mtx.vin.push_back(origplayergame,1,CScript()); + return(0); + } else return(-1); +} + +int32_t rogue_findbaton(std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,CScript scriptPubKey) +{ + int32_t i,numvouts,spentvini,matches = 0; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; + for (i=0; i= 0 ) + { + if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && tx.vout.size() > 0 ) + { + if ( spenttx.vout[0].scriptPubKey == scriptPubKey ) + { + matches++; + matchtx = spenttx; + } + } + } + } + if ( matches == 1 ) + { + numvouts = matchtx.vout.size(); + if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) + { + if ( playertxid == zeroid || rogue_playerdata(origplayergame,playerdata,playertxid) == 0 ) + { + txid = spenttxid; + while ( CCgettxout(txid,0,1) > 0 ) + { + spenttxid = zeroid; + spentvinit = -1; + if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvin,txid,0) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + return(-2); + } + if ( spentvini != 0 ) + return(-3); + } + batontxid = txid; + batonvout = 0; // not vini + // how to detect timeout, bailedout, highlander + hashBlock = zeroid; + if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 0 ) + { + if ( hashBlock == zeroid ) + batonht = komodo_nextheight(); + else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) + return(-4); + else batonht = pindex->nHeight; + return(0); + } + } + } + } + return(-1); +} + +void rogue_gameplayerinfo(UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) +{ + // identify if bailout or quit or timed out + uint256 batontxid; int32_t batonvout,batonht; int64_t batonvalue; std::vector playerdata; + obj.push_back(Pair("slot",(int64_t)vout-2)); + if ( rogue_findbaton(playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gametx.vout[vout].scriptPubKey) == 0 ) + { + obj.push_back(Pair("baton",batontxid.ToString())); + obj.push_back(Pair("batonvout",(int64_t)batonvout)); + obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); + obj.push_back(Pair("batonht",(int64_t)batonht)); + if ( playerdata.size() > 0 ) + { + UniValue pobj(UniValue:VOBJ); + obj.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); + } + } +} + +int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTransaction gametx,int32_t maxplayers) +{ + int32_t vout,j,r; int64_t nValue; + if ( tx.vout.size() > maxplayers+2 ) + { + r = rand() % maxplayers; + for (j=0; j 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,amount = 0; - if ( params != 0 ) + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0,amount = 0; int32_t i,n,maxplayers = 1; + if ( txfee == 0 ) + txfee = 10000; + if ( (params= cclib_reparse(&n,params)) != 0 ) { - if ( (jsonstr= jprint(params,0)) != 0 ) + if ( n > 1 ) { - if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) - { - jsonstr[strlen(jsonstr)-1] = 0; - jsonstr++; - } - amount = atof(jsonstr) * COIN + 0.0000000049; - free(jsonstr); + maxplayers = juint(jitem(params,0),0); + if ( n > 2 ) + buyin = jdouble(jitem(params,1),0) * COIN + 0.0000000049; } } + if ( maxplayers < 1 || maxplayers > ROGUE_MAXPLAYERS ) + return(cclib_error(result,"illegal maxplayers")); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); - result.push_back(Pair("result","success")); - result.push_back(Pair("name","rogue")); - result.push_back(Pair("method","newgame")); - if ( amount == 0 ) - result.push_back(Pair("type","newbie")); - else result.push_back(Pair("type","buyin")); - result.push_back(Pair("amount",ValueFromAmount(amount))); - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,3*txfee,16,cp->unspendableCCaddr)) >= 3*txfee ) + rogue_univalue(result,"newgame",maxplayers,buyin); + required = (3*txfee + maxplayers*ROGUE_REGISTRATIONSIZE); + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,required,16,cp->unspendableCCaddr)) >= required ) { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); - if ( (change= inputsum-3*txfee) >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO creation + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO used + for (i=0; ievalcode,ROGUE_REGISTRATIONSIZE,roguepk,roguepk)); + if ( (change= inputsum - required) >= txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,roguepk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(amount)); - if ( rawtx.size() > 0 ) - { - CTransaction tx; - result.push_back(Pair("hex",rawtx)); - if ( DecodeHexTx(tx,rawtx) != 0 ) - result.push_back(Pair("txid",tx.GetHash().ToString())); - } else result.push_back(Pair("error","couldnt finalize CCtx")); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(amount,maxplayers)); + return(rogue_rawtxresult(result,rawtx,0)); } + else return(cclib_error(result,"illegal maxplayers")); return(result); } +UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,origplayergame;std::vector playerdata; int32_t n; + result.push_back(Pair("result","success")); + rogue_univalue(result,"playerinfo",-1,-1); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n > 0 ) + { + UniValue pobj(UniValue:VOBJ); + playertxid = jbits256(jitem(params,0),0); + if ( rogue_playerdata(origplayergame,playerdata,playertxid) < 0 ) + return(cclib_error(result,"invalid playerdata")); + result.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); + } else return(cclib_error(result,"no playertxid")); + return(result); + } else return(cclib_error(result,"couldnt reparse params")); +} + UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { + // vin0 -> ROGUE_REGISTRATIONSIZE 1of2 registration baton from creategame + // vin1 -> optional nonfungible character vout @ + // vin2 -> original creation TCBOO playerdata used + // vin3+ -> buyin + // vout0 -> keystrokes/completion baton + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); uint256 gametxid,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + roguepk = GetUnspendable(cp,0); + rogue_univalue(result,"register",-1,-1); + playertxid = zeroid; + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n > 0 ) + { + gametxid = jbits256(jitem(params,0),0); + if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) + { + if ( n > 1 && maxplayers > 1 ) + { + playertxid = jbits256(jitem(params,0),0); + if ( rogue_playerdata(origplayergame,playerdata,playertxid) < 0 ) + return(cclib_error(result,"couldnt extract valid playerdata")); + } + rogue_univalue(result,0,maxplayers,buyin); + if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) + return(cclib_error(result,"couldnt find available registration baton")); + else if ( playertxid != zeroid && rogue_playerdataspend(mtx,playertxid,origplayergame) < 0 ) + return(cclib_error(result,"couldnt find playerdata to spend")); + else if ( buyin > 0 && AddNormalInputs(mtx,mypk,buyin,64) < buyin ) + return(cclib_error(result,"couldnt find enough normal funds for buyin")); + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,inputsum-txfee,roguepk,mypk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_registeropret(gametxid,playertxid)); + return(rogue_rawtxresult(result,rawtx,0)); + } else return(cclib_error(result,"invalid gametxid")); + } else return(cclib_error(result,"no gametxid")); + } else return(cclib_error(result,"couldnt reparse params")); +} + +UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + // vin0 -> baton from registration or previous keystrokes + // vout0 -> new baton + // opret -> user input chars + // being killed should auto broadcast (possible to be suppressed?) + // respawn to be prevented by including timestamps + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr; + if ( txfee == 0 ) + txfee = 10000; + rogue_univalue(result,"keystrokes",-1,-1); + if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) + { + gametxid = jbits256(jitem(params,0),0); + keystrokes = ParseHex(keystrokestr); + mypk = pubkey2pk(Mypubkey()); + roguepk = GetUnspendable(cp,0); + txout = MakeCC1of2vout(cp->evalcode,0,roguepk,mypk); + if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) + { + if ( rogue_findbaton(playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,txout.scriptPubKey) == 0 ) + { + if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) + { + mtx.vin.push_back(batontxid,batonvout,CScript()); + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,roguepk,mypk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_keystrokesopret(gametxid,batontxid,mypk,keystrokes)); + return(rogue_rawtxresult(result,rawtx,1)); + } else return(cclib_error(result,"keystrokes tx was too late")); + } else return(cclib_error(result,"couldnt find batontxid")); + } else return(cclib_error(result,"invalid gametxid")); + } else return(cclib_error(result,"couldnt reparse params")); +} + +UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + //vin0 -> highlander vout from creategame TCBOO + //vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 60 blocks since last keystrokes, it is forfeit + //vins2+ -> rest of unspent registration utxo so all newgame vouts are spent + //vout0 -> nonfungible character with pack @ + //vout1 -> 1% ingame gold and all the buyins CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue rogue_progress(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue rogue_claimwin(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue rogue_saveandquit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue rogue_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); int32_t ht,numvouts; char CCaddr[64],str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; uint64_t seed; int64_t buyin; CBlockIndex *pindex; - if ( params != 0 ) - { - if ( (txidstr= jprint(params,0)) != 0 ) - { - if ( txidstr[0] == '"' && txidstr[strlen(txidstr)-1] == '"' ) - { - txidstr[strlen(txidstr)-1] = 0; - txidstr++; - } - //printf("params -> (%s)\n",txidstr); - decode_hex((uint8_t *)&txid,32,txidstr); - txid = revuint256(txid); - result.push_back(Pair("txid",txid.GetHex())); - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - if ( rogue_newgameopreturndecode(buyin,tx.vout[numvouts-1].scriptPubKey) == 'G' ) - { - result.push_back(Pair("result","success")); - if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) - { - ht = pindex->GetHeight(); - result.push_back(Pair("height",ht)); - result.push_back(Pair("start",ht+ROGUE_REGISTRATION)); - if ( komodo_nextheight() > ht+ROGUE_REGISTRATION ) - { - if ( (pindex= komodo_chainactive(ht+ROGUE_REGISTRATION)) != 0 ) - { - hashBlock = pindex->GetBlockHash(); - result.push_back(Pair("starthash",hashBlock.ToString().c_str())); - memcpy(&seed,&hashBlock,sizeof(seed)); - seed &= (1LL << 62) - 1; - result.push_back(Pair("seed",(int64_t)seed)); - } - } - } - Getscriptaddress(CCaddr,tx.vout[1].scriptPubKey); - result.push_back(Pair("rogueaddr",CCaddr)); - result.push_back(Pair("buyin",ValueFromAmount(buyin))); - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt extract rogue_generate opreturn")); - } - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt find txid")); - } - } - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","missing txid in params")); - } + if ( txfee == 0 ) + txfee = 10000; + // make sure no highlander and it is an actual ingame win + result.push_back(Pair("result","success")); result.push_back(Pair("name","rogue")); - result.push_back(Pair("method","txidinfo")); + result.push_back(Pair("method","highlander")); + return(result); +} + +UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + // detect if last to bailout + // vin0 -> kestrokes baton of completed game with Q + // vout0 -> 1% ingame gold + // get any playerdata, get all keystrokes, replay game and compare final state + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); + if ( txfee == 0 ) + txfee = 10000; + // make sure no highlander yet + result.push_back(Pair("result","success")); + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method","bailout")); + return(result); +} + +UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method","gameinfo")); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n > 0 ) + { + txid = jbits256(jitem(params,0),0); + result.push_back(Pair("txid",txid.GetHex())); + if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) + { + result.push_back(Pair("result","success")); + rogue_gamefields(result,maxplayers,buyin); + for (i=0; i > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,roguepk); @@ -247,189 +618,14 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) txid = it->first.txhash; vout = (int32_t)it->first.index; //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( it->second.satoshis != txfee || vout != 0 ) + if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) - { - if ( rogue_newgameopreturndecode(amount,tx.vout[numvouts-1].scriptPubKey) == 'G' ) - { - UniValue obj(UniValue::VOBJ); - if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) - { - ht = pindex->GetHeight(); - obj.push_back(Pair("height",ht)); - obj.push_back(Pair("start",ht+ROGUE_REGISTRATION)); - if ( komodo_nextheight() > ht+ROGUE_REGISTRATION ) - { - if ( (pindex= komodo_chainactive(ht+ROGUE_REGISTRATION)) != 0 ) - { - hashBlock = pindex->GetBlockHash(); - obj.push_back(Pair("starthash",hashBlock.ToString().c_str())); - memcpy(&seed,&hashBlock,sizeof(seed)); - seed &= (1LL << 62) - 1; - obj.push_back(Pair("seed",(int64_t)seed)); - } - } - } - obj.push_back(Pair("buyin",ValueFromAmount(amount))); - obj.push_back(Pair("txid",txid.GetHex())); - a.push_back(obj); - total += amount; - } - } - } + if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) + a.push_back(txid.GetHex()); } result.push_back(Pair("result","success")); - result.push_back(Pair("name","rogue")); - result.push_back(Pair("method","pending")); + rogue_univalue(result,"pending",-1,-1); result.push_back(Pair("pending",a)); result.push_back(Pair("numpending",a.size())); - result.push_back(Pair("total",ValueFromAmount(total))); return(result); } - -#ifdef notyest -UniValue rogue_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); int32_t i,j,good,ind,n,numvouts; uint256 txid; char *jsonstr,*newstr,*txidstr,coinaddr[64],checkaddr[64],CCaddr[64],*solution=0,unsolved[82]; CPubKey pk,mypk; uint8_t vals9[9][9],priv32[32],pub33[33]; uint32_t timestamps[81]; uint64_t balance,inputsum; std::string rawtx; CTransaction tx; uint256 hashBlock; - mypk = pubkey2pk(Mypubkey()); - memset(timestamps,0,sizeof(timestamps)); - result.push_back(Pair("name","rogue")); - result.push_back(Pair("method","solution")); - good = 0; - if ( params != 0 ) - { - if ( (jsonstr= jprint(params,0)) != 0 ) - { - if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) - { - jsonstr[strlen(jsonstr)-1] = 0; - jsonstr++; - } - newstr = (char *)malloc(strlen(jsonstr)+1); - for (i=j=0; jsonstr[i]!=0; i++) - { - if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) - { - newstr[j++] = '"'; - i += 2; - } else newstr[j++] = jsonstr[i]; - } - newstr[j] = 0; - params = cJSON_Parse(newstr); - } else params = 0; - if ( params != 0 ) - { - if ( (n= cJSON_GetArraySize(params)) > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 ) - { - for (i=2; i '9' ) - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","illegal solution")); - return(result); - } - vals9[i][j] = solution[ind++] - '0'; - } - rogue_privkey(priv32,vals9); - priv2addr(coinaddr,pub33,priv32); - pk = buf2pk(pub33); - GetCCaddress(cp,CCaddr,pk); - result.push_back(Pair("rogueaddr",CCaddr)); - balance = CCaddress_balance(CCaddr); - result.push_back(Pair("amount",ValueFromAmount(balance))); - if ( rogue_captcha(1,timestamps,komodo_nextheight()) < 0 ) - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","captcha failure")); - return(result); - } - else - { - if ( (txidstr= jstri(params,0)) != 0 ) - { - decode_hex((uint8_t *)&txid,32,txidstr); - txid = revuint256(txid); - result.push_back(Pair("txid",txid.GetHex())); - if ( CCgettxout(txid,0,1) < 0 ) - result.push_back(Pair("error","already solved")); - else if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey); - if ( strcmp(checkaddr,CCaddr) != 0 ) - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","wrong solution")); - result.push_back(Pair("yours",CCaddr)); - return(result); - } - if ( rogue_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) - { - for (i=0; i<81; i++) - { - if ( unsolved[i] < '1' || unsolved[i] > '9') - continue; - else if ( unsolved[i] != solution[i] ) - { - printf("i.%d [%c] != [%c]\n",i,unsolved[i],solution[i]); - result.push_back(Pair("error","wrong rogue solved")); - break; - } - } - if ( i == 81 ) - good = 1; - } else result.push_back(Pair("error","cant decode rogue")); - } else result.push_back(Pair("error","couldnt find rogue")); - } - if ( good != 0 ) - { - mtx.vin.push_back(CTxIn(txid,0,CScript())); - if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) - { - mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); - rawtx = FinalizeCCTx(0,cp,mtx,pubkey2pk(Mypubkey()),txfee,rogue_solutionopret(solution,timestamps)); - if ( rawtx.size() > 0 ) - { - result.push_back(Pair("result","success")); - result.push_back(Pair("hex",rawtx)); - } - else result.push_back(Pair("error","couldnt finalize CCtx")); - } else result.push_back(Pair("error","couldnt find funds in solution address")); - } - } - } - } - else - { - printf("n.%d params.(%s)\n",n,jprint(params,0)); - result.push_back(Pair("error","couldnt get all params")); - } - return(result); - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt parse parameters")); - result.push_back(Pair("parameters",newstr)); - return(result); - } - } - result.push_back(Pair("result","error")); - result.push_back(Pair("error","missing parameters")); - return(result); -} -#endif - diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 7cff6b280..7571d22e4 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2782,7 +2782,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) continue; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { - if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { @@ -2801,7 +2801,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("name","sudoku")); result.push_back(Pair("method","pending")); result.push_back(Pair("pending",a)); - result.push_back(Pair("numpending",a.size())); + result.push_back(Pair("numpending",(int64_t)a.size())); result.push_back(Pair("total",ValueFromAmount(total))); return(result); } @@ -2817,28 +2817,9 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params good = 0; if ( params != 0 ) { - if ( (jsonstr= jprint(params,0)) != 0 ) + if ( (params= cclib_reparse(&n,params)) != 0 ) { - if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) - { - jsonstr[strlen(jsonstr)-1] = 0; - jsonstr++; - } - newstr = (char *)malloc(strlen(jsonstr)+1); - for (i=j=0; jsonstr[i]!=0; i++) - { - if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) - { - newstr[j++] = '"'; - i += 2; - } else newstr[j++] = jsonstr[i]; - } - newstr[j] = 0; - params = cJSON_Parse(newstr); - } else params = 0; - if ( params != 0 ) - { - if ( (n= cJSON_GetArraySize(params)) > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 ) + if ( n > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 ) { for (i=2; ifirst.index; if ( (nValue= it->second.satoshis) < COIN ) continue; - if ( GetTransaction(txid,tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { const CScript &scriptPubKey = tx.vout[vout].scriptPubKey; if ( DecodeMaramaraCoinbaseOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,pk,ht,unlockht) != 0 && pk == mypk ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 862f0c6b0..f492173a7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1782,7 +1782,6 @@ void komodo_args(char *argv0) ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); if ( ASSETCHAINS_CC != 0 ) { - ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); Split(GetArg("-ac_ccenable",""), ccenables, 0); for (i=nonz=0; i<0x100; i++) { @@ -1806,6 +1805,15 @@ void komodo_args(char *argv0) ASSETCHAINS_CCDISABLES[ccenables[i] & 0xff] = 0; } } + ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); + /*if ( ASSETCHAINS_CCLIB.size() > 0 ) + { + for (i=first; i<=last; i++) + { + CLEARBIT(disablebits,i); + ASSETCHAINS_CCDISABLES[i] = 0; + } + }*/ } if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c210e3099..cf324d1f1 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -380,10 +380,11 @@ UniValue getdifficulty(const UniValue& params, bool fHelp) return GetNetworkDifficulty(); } -bool myIsutxo_spentinmempool(uint256 txid,int32_t vout) +bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout) { //char *uint256_str(char *str,uint256); char str[65]; //LOCK(mempool.cs); + int32_t vini = 0; BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) { const CTransaction &tx = e.GetTx(); @@ -392,7 +393,12 @@ bool myIsutxo_spentinmempool(uint256 txid,int32_t vout) { //fprintf(stderr,"%s/v%d ",uint256_str(str,txin.prevout.hash),txin.prevout.n); if ( txin.prevout.n == vout && txin.prevout.hash == txid ) + { + spenttxid = hash; + spentvini = vini; return(true); + } + vini++; } //fprintf(stderr,"are vins for %s\n",uint256_str(str,hash)); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f8fe7de20..12a4b47db 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5170,9 +5170,14 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits return pwalletMain->VerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig, pk); } -int32_t ensure_CCrequirements() +int32_t ensure_CCrequirements(uint8_t evalcode) { CCerror = ""; + if ( ASSETCHAINS_CCDISABLES[evalcode] != 0 || evalcode == EVAL_MARMARA && ASSETCHAINS_MARMARA == 0 ) + { + fprintf(stderr,"evalcode %d disabled\n",evalcode); + return(-1); + } if ( NOTARY_PUBKEY33[0] == 0 ) { fprintf(stderr,"no -pubkey set\n"); @@ -5345,7 +5350,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 1 ) throw runtime_error("channelsaddress pubkey\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Channels",pubkey)); @@ -5356,7 +5361,7 @@ UniValue cclibaddress(const UniValue& params, bool fHelp) struct CCcontract_info *cp,C; std::vector pubkey; uint8_t evalcode = EVAL_FIRSTUSER; if ( fHelp || params.size() > 2 ) throw runtime_error("cclibaddress [evalcode] [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() >= 1 ) { @@ -5377,7 +5382,7 @@ UniValue cclibinfo(const UniValue& params, bool fHelp) struct CCcontract_info *cp,C; uint8_t evalcode = EVAL_FIRSTUSER; if ( fHelp || params.size() > 0 ) throw runtime_error("cclibinfo\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); cp = CCinit(&C,evalcode); return(CClib_info(cp)); @@ -5388,7 +5393,9 @@ UniValue cclib(const UniValue& params, bool fHelp) struct CCcontract_info *cp,C; char *method; cJSON *jsonparams=0; uint8_t evalcode = EVAL_FIRSTUSER; if ( fHelp || params.size() > 3 ) throw runtime_error("cclib method [evalcode] [JSON params]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ASSETCHAINS_CCLIB.size() == 0 ) + throw runtime_error("no -ac_cclib= specified\n"); + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5416,7 +5423,7 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_ORACLES); if ( fHelp || params.size() > 1 ) throw runtime_error("oraclesaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5430,7 +5437,7 @@ UniValue pricesaddress(const UniValue& params, bool fHelp) assetscp = CCinit(&C2,EVAL_PRICES); if ( fHelp || params.size() > 1 ) throw runtime_error("pricesaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5452,7 +5459,7 @@ UniValue pegsaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_PEGS); if ( fHelp || params.size() > 1 ) throw runtime_error("pegssaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5465,7 +5472,7 @@ UniValue marmaraaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_MARMARA); if ( fHelp || params.size() > 1 ) throw runtime_error("Marmaraaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5478,7 +5485,7 @@ UniValue paymentsaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_PAYMENTS); if ( fHelp || params.size() > 1 ) throw runtime_error("paymentsaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5491,7 +5498,7 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_GATEWAYS); if ( fHelp || params.size() > 1 ) throw runtime_error("gatewaysaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5504,7 +5511,7 @@ UniValue heiraddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_HEIR); if ( fHelp || params.size() > 1 ) throw runtime_error("heiraddress pubkey\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Heir",pubkey)); @@ -5516,7 +5523,7 @@ UniValue lottoaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_LOTTO); if ( fHelp || params.size() > 1 ) throw runtime_error("lottoaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5529,7 +5536,7 @@ UniValue FSMaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_FSM); if ( fHelp || params.size() > 1 ) throw runtime_error("FSMaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5542,7 +5549,7 @@ UniValue auctionaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_AUCTION); if ( fHelp || params.size() > 1 ) throw runtime_error("auctionaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5555,7 +5562,7 @@ UniValue diceaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_DICE); if ( fHelp || params.size() > 1 ) throw runtime_error("diceaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5569,7 +5576,7 @@ UniValue faucetaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_FAUCET); if ( fHelp || params.size() > 1 ) throw runtime_error("faucetaddress [pubkey]\n"); - error = ensure_CCrequirements(); + error = ensure_CCrequirements(0); if ( error < 0 ) throw runtime_error(strprintf("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet. ERR=%d\n", error)); if ( params.size() == 1 ) @@ -5583,7 +5590,7 @@ UniValue rewardsaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_REWARDS); if ( fHelp || params.size() > 1 ) throw runtime_error("rewardsaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5596,7 +5603,7 @@ UniValue assetsaddress(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_ASSETS); if (fHelp || params.size() > 1) throw runtime_error("assetsaddress [pubkey]\n"); - if (ensure_CCrequirements() < 0) + if (ensure_CCrequirements(0) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if (params.size() == 1) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5609,7 +5616,7 @@ UniValue tokenaddress(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_TOKENS); if ( fHelp || params.size() > 1 ) throw runtime_error("tokenaddress [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(0) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); @@ -5625,7 +5632,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) //marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5645,7 +5652,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) // after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1168 d72d87aa0d50436de695c93e2bf3d7273c63c92ef6307913aa01a6ee6a16548b throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); } - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5676,7 +5683,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5701,7 +5708,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) // marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1168 1506c774e4b2804a6e25260920840f4cfca8d1fb400e69fe6b74b8e593dbedc5 throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n"); } - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); receiverpub = ParseHex(params[0].get_str().c_str()); if (receiverpub.size()!= 33) @@ -5727,7 +5734,7 @@ UniValue marmara_info(const UniValue& params, bool fHelp) { throw runtime_error("marmarainfo firstheight lastheight minamount maxamount [currency issuerpk]\n"); } - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5759,7 +5766,7 @@ UniValue marmara_creditloop(const UniValue& params, bool fHelp) // marmaracreditloop 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be throw runtime_error("marmaracreditloop txid\n"); } - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5777,7 +5784,7 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) // marmarasettlement ff3e259869196f3da9b5ea3f9e088a76c4fc063cf36ab586b652e121d441a603 throw runtime_error("marmarasettlement batontxid\n"); } - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5806,7 +5813,7 @@ UniValue channelslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) throw runtime_error("channelsinfo\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5818,7 +5825,7 @@ UniValue channelsinfo(const UniValue& params, bool fHelp) uint256 opentxid; if ( fHelp || params.size() > 1 ) throw runtime_error("channelsinfo [opentxid]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5836,7 +5843,7 @@ UniValue channelsopen(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() < 3 || params.size() > 4) throw runtime_error("channelsopen destpubkey numpayments payment\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5877,7 +5884,7 @@ UniValue channelspayment(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() < 2 || params.size() >3 ) throw runtime_error("channelspayment opentxid amount [secret]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5907,7 +5914,7 @@ UniValue channelsclose(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 1 ) throw runtime_error("channelsclose opentxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5927,7 +5934,7 @@ UniValue channelsrefund(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_CHANNELS); if ( fHelp || params.size() != 2 ) throw runtime_error("channelsrefund opentxid closetxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -5947,7 +5954,7 @@ UniValue rewardscreatefunding(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); char *name; int64_t funds,APR,minseconds,maxseconds,mindeposit; std::string hex; if ( fHelp || params.size() > 6 || params.size() < 2 ) throw runtime_error("rewardscreatefunding name amount APR mindays maxdays mindeposit\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6016,7 +6023,7 @@ UniValue rewardslock(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid; int64_t amount; std::string hex; if ( fHelp || params.size() != 3 ) throw runtime_error("rewardslock name fundingtxid amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6046,7 +6053,7 @@ UniValue rewardsaddfunding(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid; int64_t amount; std::string hex; if ( fHelp || params.size() != 3 ) throw runtime_error("rewardsaddfunding name fundingtxid amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6081,7 +6088,7 @@ UniValue rewardsunlock(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; char *name; uint256 fundingtxid,txid; if ( fHelp || params.size() > 3 || params.size() < 2 ) throw runtime_error("rewardsunlock name fundingtxid [txid]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6109,7 +6116,7 @@ UniValue rewardslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) throw runtime_error("rewardslist\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6121,7 +6128,7 @@ UniValue rewardsinfo(const UniValue& params, bool fHelp) uint256 fundingtxid; if ( fHelp || params.size() != 1 ) throw runtime_error("rewardsinfo fundingtxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6133,7 +6140,7 @@ UniValue gatewayslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) throw runtime_error("gatewayslist\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6145,7 +6152,7 @@ UniValue gatewaysinfo(const UniValue& params, bool fHelp) uint256 txid; if ( fHelp || params.size() != 1 ) throw runtime_error("gatewaysinfo bindtxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6158,7 +6165,7 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 tokenid,oracletxid; int32_t i; int64_t totalsupply; std::vector pubkeys; uint8_t M,N; std::string hex,coin; std::vector pubkey; if ( fHelp || params.size() < 6 ) throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s)\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6194,7 +6201,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int32_t i,claimvout,height; int64_t amount; std::string hex,coin,deposithex; uint256 bindtxid,cointxid; std::vectorproof,destpub,pubkey; if ( fHelp || params.size() != 9 ) throw runtime_error("gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6227,7 +6234,7 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex,coin; uint256 bindtxid,deposittxid; std::vectordestpub; int64_t amount; if ( fHelp || params.size() != 5 ) throw runtime_error("gatewaysclaim bindtxid coin deposittxid destpub amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6253,7 +6260,7 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 bindtxid; int64_t amount; std::string hex,coin; std::vector withdrawpub; if ( fHelp || params.size() != 4 ) throw runtime_error("gatewayswithdraw bindtxid coin withdrawpub amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6278,7 +6285,7 @@ UniValue gatewayspartialsign(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string coin,parthex,hex; uint256 txid; if ( fHelp || params.size() != 3 ) throw runtime_error("gatewayspartialsign txidaddr refcoin hex\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6299,7 +6306,7 @@ UniValue gatewayscompletesigning(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 withdrawtxid; std::string txhex,hex,coin; if ( fHelp || params.size() != 3 ) throw runtime_error("gatewayscompletesigning withdrawtxid coin hex\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6321,7 +6328,7 @@ UniValue gatewaysmarkdone(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 completetxid; std::string hex,coin; if ( fHelp || params.size() != 2 ) throw runtime_error("gatewaysmarkdone completesigningtx coin\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6342,7 +6349,7 @@ UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp) uint256 bindtxid; std::string coin; if ( fHelp || params.size() != 2 ) throw runtime_error("gatewayspendingdeposits bindtxid coin\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6356,7 +6363,7 @@ UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp) uint256 bindtxid; std::string coin; if ( fHelp || params.size() != 2 ) throw runtime_error("gatewayspendingwithdraws bindtxid coin\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6370,7 +6377,7 @@ UniValue gatewaysprocessed(const UniValue& params, bool fHelp) uint256 bindtxid; std::string coin; if ( fHelp || params.size() != 2 ) throw runtime_error("gatewaysprocessed bindtxid coin\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6383,7 +6390,7 @@ UniValue oracleslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) throw runtime_error("oracleslist\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6395,7 +6402,7 @@ UniValue oraclesinfo(const UniValue& params, bool fHelp) uint256 txid; if ( fHelp || params.size() != 1 ) throw runtime_error("oraclesinfo oracletxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6408,7 +6415,7 @@ UniValue oraclesregister(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 txid; int64_t datafee; std::string hex; if ( fHelp || params.size() != 2 ) throw runtime_error("oraclesregister oracletxid datafee\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6430,7 +6437,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 txid; int64_t amount; std::string hex; std::vector pubkey; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessubscribe oracletxid publisher amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6452,7 +6459,7 @@ UniValue oraclessamples(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessamples oracletxid batonutxo num\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6467,7 +6474,7 @@ UniValue oraclesdata(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 txid; std::vector data; std::string hex; if ( fHelp || params.size() != 2 ) throw runtime_error("oraclesdata oracletxid hexstr\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6488,7 +6495,7 @@ UniValue oraclescreate(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string name,description,format,hex; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclescreate name description format\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6525,7 +6532,7 @@ UniValue FSMcreate(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string name,states,hex; if ( fHelp || params.size() != 2 ) throw runtime_error("FSMcreate name states\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_FSM) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6545,7 +6552,7 @@ UniValue FSMlist(const UniValue& params, bool fHelp) uint256 tokenid; if ( fHelp || params.size() > 0 ) throw runtime_error("FSMlist\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_FSM) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); return(FSMList()); } @@ -6555,7 +6562,7 @@ UniValue FSMinfo(const UniValue& params, bool fHelp) uint256 FSMtxid; if ( fHelp || params.size() != 1 ) throw runtime_error("FSMinfo fundingtxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_FSM) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); FSMtxid = Parseuint256((char *)params[0].get_str().c_str()); return(FSMInfo(FSMtxid)); @@ -6566,7 +6573,7 @@ UniValue faucetinfo(const UniValue& params, bool fHelp) uint256 fundingtxid; if ( fHelp || params.size() != 0 ) throw runtime_error("faucetinfo\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); return(FaucetInfo()); } @@ -6576,7 +6583,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t funds; std::string hex; if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6597,7 +6604,7 @@ UniValue faucetget(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; if ( fHelp || params.size() > 0 ) throw runtime_error("faucetget\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6613,7 +6620,7 @@ UniValue priceslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) throw runtime_error("priceslist\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); return(PricesList()); } @@ -6623,7 +6630,7 @@ UniValue pricesinfo(const UniValue& params, bool fHelp) uint256 fundingtxid; if ( fHelp || params.size() != 1 ) throw runtime_error("pricesinfo fundingtxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); return(PricesInfo(fundingtxid)); @@ -6634,7 +6641,7 @@ UniValue pricescreate(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint64_t mode; int64_t funding; int32_t i,n,margin,maxleverage; std::string hex; uint256 oracletxid,longtoken,shorttoken,bettoken; std::vector pubkeys; std::vectorpubkey; if ( fHelp || params.size() < 8 ) throw runtime_error("pricescreate bettoken oracletxid margin mode longtoken shorttoken maxleverage funding N [pubkeys]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6675,7 +6682,7 @@ UniValue pricesaddfunding(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; uint256 fundingtxid,bettoken; int64_t amount; if ( fHelp || params.size() != 3 ) throw runtime_error("pricesaddfunding fundingtxid bettoken amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6700,7 +6707,7 @@ UniValue pricesbet(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; uint256 fundingtxid,bettoken; int64_t amount; int32_t leverage; if ( fHelp || params.size() != 4 ) throw runtime_error("pricesbet fundingtxid bettoken amount leverage\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6726,7 +6733,7 @@ UniValue pricesstatus(const UniValue& params, bool fHelp) uint256 fundingtxid,bettxid,bettoken; if ( fHelp || params.size() != 3 ) throw runtime_error("pricesstatus fundingtxid bettoken bettxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); bettoken = Parseuint256((char *)params[1].get_str().c_str()); @@ -6739,7 +6746,7 @@ UniValue pricesfinish(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 fundingtxid,bettxid,bettoken; std::string hex; if ( fHelp || params.size() != 3 ) throw runtime_error("pricesfinish fundingtxid bettoken bettxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6764,7 +6771,7 @@ UniValue dicefund(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t funds,minbet,maxbet,maxodds,timeoutblocks; std::string hex; char *name; if ( fHelp || params.size() != 6 ) throw runtime_error("dicefund name funds minbet maxbet maxodds timeoutblocks\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_DICE) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6797,7 +6804,7 @@ UniValue diceaddfunds(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid; int64_t amount; std::string hex; if ( fHelp || params.size() != 3 ) throw runtime_error("diceaddfunds name fundingtxid amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_DICE) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6825,7 +6832,7 @@ UniValue dicebet(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex,error; uint256 fundingtxid; int64_t amount,odds; char *name; if ( fHelp || params.size() != 4 ) throw runtime_error("dicebet name fundingtxid amount odds\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_DICE) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6857,7 +6864,7 @@ UniValue dicefinish(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint8_t funcid; char *name; uint256 entropyused,fundingtxid,bettxid; std::string hex; int32_t r,entropyvout; if ( fHelp || params.size() != 3 ) throw runtime_error("dicefinish name fundingtxid bettxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_DICE) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6892,7 +6899,7 @@ UniValue dicestatus(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid,bettxid; std::string status,error; double winnings; if ( fHelp || (params.size() != 2 && params.size() != 3) ) throw runtime_error("dicestatus name fundingtxid bettxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_DICE) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6940,7 +6947,7 @@ UniValue dicelist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) throw runtime_error("dicelist\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_DICE) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); return(DiceList()); } @@ -6950,7 +6957,7 @@ UniValue diceinfo(const UniValue& params, bool fHelp) uint256 fundingtxid; if ( fHelp || params.size() != 1 ) throw runtime_error("diceinfo fundingtxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_DICE) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); return(DiceInfo(fundingtxid)); @@ -6961,7 +6968,7 @@ UniValue tokenlist(const UniValue& params, bool fHelp) uint256 tokenid; if ( fHelp || params.size() > 0 ) throw runtime_error("tokenlist\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); return(TokenList()); } @@ -6971,7 +6978,7 @@ UniValue tokeninfo(const UniValue& params, bool fHelp) uint256 tokenid; if ( fHelp || params.size() != 1 ) throw runtime_error("tokeninfo tokenid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6984,7 +6991,7 @@ UniValue tokenorders(const UniValue& params, bool fHelp) uint256 tokenid; if ( fHelp || params.size() > 1 ) throw runtime_error("tokenorders [tokenid]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7005,7 +7012,7 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 2 ) throw runtime_error("tokenbalance tokenid [pubkey]\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); LOCK(cs_main); @@ -7041,7 +7048,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string name,description,hex; uint64_t supply; if ( fHelp || params.size() > 3 || params.size() < 2 ) throw runtime_error("tokencreate name supply description\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7080,7 +7087,7 @@ UniValue tokentransfer(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; int64_t amount; uint256 tokenid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokentransfer tokenid destpubkey amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7116,7 +7123,7 @@ UniValue tokenconvert(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; int32_t evalcode; int64_t amount; uint256 tokenid; if ( fHelp || params.size() != 4 ) throw runtime_error("tokenconvert evalcode tokenid pubkey amount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7157,7 +7164,7 @@ UniValue tokenbid(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t bidamount,numtokens; std::string hex; double price; uint256 tokenid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenbid numtokens tokenid price\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7199,7 +7206,7 @@ UniValue tokencancelbid(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; int32_t i; uint256 tokenid,bidtxid; if ( fHelp || params.size() != 2 ) throw runtime_error("tokencancelbid tokenid bidtxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7224,7 +7231,7 @@ UniValue tokenfillbid(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t fillamount; std::string hex; uint256 tokenid,bidtxid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenfillbid tokenid bidtxid fillamount\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7256,7 +7263,7 @@ UniValue tokenask(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t askamount,numtokens; std::string hex; double price; uint256 tokenid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenask numtokens tokenid price\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7290,7 +7297,7 @@ UniValue tokenswapask(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t askamount,numtokens; std::string hex; double price; uint256 tokenid,otherid; if ( fHelp || params.size() != 4 ) throw runtime_error("tokenswapask numtokens tokenid otherid price\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7318,7 +7325,7 @@ UniValue tokencancelask(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; int32_t i; uint256 tokenid,asktxid; if ( fHelp || params.size() != 2 ) throw runtime_error("tokencancelask tokenid asktxid\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7343,7 +7350,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t fillunits; std::string hex; uint256 tokenid,asktxid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenfillask tokenid asktxid fillunits\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7383,7 +7390,7 @@ UniValue tokenfillswap(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t fillunits; std::string hex; uint256 tokenid,otherid,asktxid; if ( fHelp || params.size() != 4 ) throw runtime_error("tokenfillswap tokenid otherid asktxid fillunits\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7464,7 +7471,7 @@ UniValue heirfund(const UniValue& params, bool fHelp) if (fHelp || params.size() != 6 && params.size() != 7) throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime memo [tokenid]\n"); - if (ensure_CCrequirements() < 0) + if (ensure_CCrequirements(EVAL_HEIR) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -7538,7 +7545,7 @@ UniValue heiradd(const UniValue& params, bool fHelp) if (fHelp || params.size() != 3) throw runtime_error("heiradd txfee funds fundingtxid\n"); - if (ensure_CCrequirements() < 0) + if (ensure_CCrequirements(EVAL_HEIR) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -7572,7 +7579,7 @@ UniValue heirclaim(const UniValue& params, bool fHelp) if (fHelp || params.size() != 3) throw runtime_error("heirclaim txfee funds fundingtxid\n"); - if (ensure_CCrequirements() < 0) + if (ensure_CCrequirements(EVAL_HEIR) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -7597,7 +7604,7 @@ UniValue heirinfo(const UniValue& params, bool fHelp) if (fHelp || params.size() != 1) throw runtime_error("heirinfo fundingtxid\n"); - // if ( ensure_CCrequirements() < 0 ) + // if ( ensure_CCrequirements(EVAL_HEIR) < 0 ) // throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); fundingtxid = Parseuint256((char*)params[0].get_str().c_str()); @@ -7609,7 +7616,7 @@ UniValue heirlist(const UniValue& params, bool fHelp) if (fHelp || params.size() != 0) throw runtime_error("heirlist\n"); - // if ( ensure_CCrequirements() < 0 ) + // if ( ensure_CCrequirements(EVAL_HEIR) < 0 ) // throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); return (HeirList()); @@ -7718,7 +7725,7 @@ UniValue test_ac(const UniValue& params, bool fHelp) if (fHelp || (params.size() != 4)) throw runtime_error("incorrect params\n"); - if (ensure_CCrequirements() < 0) + if (ensure_CCrequirements(EVAL_HEIR) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); std::vector pubkey1; @@ -7763,7 +7770,7 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) if (fHelp || (params.size() != 1)) throw runtime_error("incorrect params\n"); - if (ensure_CCrequirements() < 0) + if (ensure_CCrequirements(EVAL_HEIR) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); uint256 fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); From db37d3c6e9b6035ec3576d421a6de0e7ed3c26f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:34:53 -1100 Subject: [PATCH 1777/3904] 0xef --- src/cc/CCMarmara.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 65269df77..208c370d4 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -24,6 +24,7 @@ #define MARMARA_MINLOCK (1440 * 3 * 30) #define MARMARA_MAXLOCK (1440 * 24 * 30) #define MARMARA_VINS 16 +#define EVAL_MARMARA 0xef extern uint8_t ASSETCHAINS_MARMARA; uint64_t komodo_block_prg(uint32_t nHeight); From 2465250ba081145b610bfadef536f963b6c3f245 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:37:47 -1100 Subject: [PATCH 1778/3904] EVAL_MARMARA --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 12a4b47db..3fadd3859 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5173,7 +5173,7 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits int32_t ensure_CCrequirements(uint8_t evalcode) { CCerror = ""; - if ( ASSETCHAINS_CCDISABLES[evalcode] != 0 || evalcode == EVAL_MARMARA && ASSETCHAINS_MARMARA == 0 ) + if ( ASSETCHAINS_CCDISABLES[evalcode] != 0 || (evalcode == EVAL_MARMARA && ASSETCHAINS_MARMARA == 0) ) { fprintf(stderr,"evalcode %d disabled\n",evalcode); return(-1); From 99ff6ff5ec91b7c2907a8a3f44112ccad4b69f18 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:40:19 -1100 Subject: [PATCH 1779/3904] Fix include file --- src/cc/CCMarmara.h | 4 ++-- src/wallet/rpcwallet.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h index 208c370d4..85f9175d1 100644 --- a/src/cc/CCMarmara.h +++ b/src/cc/CCMarmara.h @@ -14,8 +14,8 @@ ******************************************************************************/ -#ifndef CC_TRIGGERS_H -#define CC_TRIGGERS_H +#ifndef CC_MARMARA_H +#define CC_MARMARA_H #include "CCinclude.h" #include "../komodo_cJSON.h" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3fadd3859..7523738ca 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6968,7 +6968,7 @@ UniValue tokenlist(const UniValue& params, bool fHelp) uint256 tokenid; if ( fHelp || params.size() > 0 ) throw runtime_error("tokenlist\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); return(TokenList()); } @@ -6978,7 +6978,7 @@ UniValue tokeninfo(const UniValue& params, bool fHelp) uint256 tokenid; if ( fHelp || params.size() != 1 ) throw runtime_error("tokeninfo tokenid\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7012,7 +7012,7 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 2 ) throw runtime_error("tokenbalance tokenid [pubkey]\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); LOCK(cs_main); @@ -7048,7 +7048,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string name,description,hex; uint64_t supply; if ( fHelp || params.size() > 3 || params.size() < 2 ) throw runtime_error("tokencreate name supply description\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7087,7 +7087,7 @@ UniValue tokentransfer(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; int64_t amount; uint256 tokenid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokentransfer tokenid destpubkey amount\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); From 19cfdd02f9d253062a6d24f78e97bd215b3113fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:42:21 -1100 Subject: [PATCH 1780/3904] Reorder code --- src/wallet/rpcwallet.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7523738ca..8fe4c669a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5170,6 +5170,21 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits return pwalletMain->VerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig, pk); } + +#include "../cc/CCfaucet.h" +#include "../cc/CCassets.h" +#include "../cc/CCrewards.h" +#include "../cc/CCdice.h" +#include "../cc/CCfsm.h" +#include "../cc/CCauction.h" +#include "../cc/CClotto.h" +#include "../cc/CCchannels.h" +#include "../cc/CCOracles.h" +#include "../cc/CCGateways.h" +#include "../cc/CCPrices.h" +#include "../cc/CCHeir.h" +#include "../cc/CCMarmara.h" + int32_t ensure_CCrequirements(uint8_t evalcode) { CCerror = ""; @@ -5196,20 +5211,6 @@ int32_t ensure_CCrequirements(uint8_t evalcode) else return(0); } -#include "../cc/CCfaucet.h" -#include "../cc/CCassets.h" -#include "../cc/CCrewards.h" -#include "../cc/CCdice.h" -#include "../cc/CCfsm.h" -#include "../cc/CCauction.h" -#include "../cc/CClotto.h" -#include "../cc/CCchannels.h" -#include "../cc/CCOracles.h" -#include "../cc/CCGateways.h" -#include "../cc/CCPrices.h" -#include "../cc/CCHeir.h" -#include "../cc/CCMarmara.h" - UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector &pubkey) { UniValue result(UniValue::VOBJ); char destaddr[64],str[64]; CPubKey mypk,pk; From 47615e789795095e5c2ff9128fa8e501cd05a0ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:50:06 -1100 Subject: [PATCH 1781/3904] playerinfo --- src/cc/cclib.cpp | 6 +++--- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index aa7a9e1ff..cede1a450 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -112,11 +112,11 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) else if ( strcmp(method,"keystrokes") == 0 ) return(rogue_keystrokes(txfee,cp,params)); else if ( strcmp(method,"bailout") == 0 ) - return(rogue_saveandquit(txfee,cp,params)); + return(rogue_bailout(txfee,cp,params)); else if ( strcmp(method,"highlander") == 0 ) - return(rogue_claimwin(txfee,cp,params)); + return(rogue_highlander(txfee,cp,params)); else if ( strcmp(method,"playerinfo") == 0 ) - return(rogue_claimwin(txfee,cp,params)); + return(rogue_playerinfo(txfee,cp,params)); else { result.push_back(Pair("result","error")); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4fb850ef0..7aef339f0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -92,14 +92,14 @@ CScript rogue_registeropret(uint256 gametxid,uint256 playertxid) return(opret); } -CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std::vectorkeystrokes) +CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std::vectorkeystrokes) { CScript opret; uint8_t evalcode = EVAL_ROGUE; opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << batontxid << pk << keystrokes); return(opret); } -CScript rogue_highlanderopret(uint256 gametxid,uint256 registertxid,CPubKey pk,std::vectorplayerdata) +CScript rogue_highlanderopret(uint256 gametxid,uint256 registertxid,CPubKey pk,std::vectorplayerdata) { CScript opret; uint8_t evalcode = EVAL_ROGUE; opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << registertxid << pk << playerdata); From f3c01d0a81ed08a67558fbc69dd18297f0a4d968 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:55:03 -1100 Subject: [PATCH 1782/3904] Syntax --- src/cc/rogue_rpc.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7aef339f0..ec4e56aee 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -19,7 +19,7 @@ #define ROGUE_REGISTRATION 5 #define ROGUE_REGISTRATIONSIZE (100 * 10000) #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching -#defein ROGUE_MAXKEYSTROKESGAP 60 +#define ROGUE_MAXKEYSTROKESGAP 60 /* the idea is that you creategame and get a txid, you specify the maxplayers and buyin for the game. the tx will have maxplayers of vouts. You must have a non-zero buyin to be able to use a preexisting character. @@ -106,7 +106,7 @@ CScript rogue_highlanderopret(uint256 gametxid,uint256 registertxid,CPubKey pk,s return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid,uint256 ®istertxid,CPubKey &pk,std::vector &playerdata,CSript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid,uint256 ®istertxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey,vopret); @@ -147,7 +147,7 @@ uint8_t rogue_newgameopreturndecode(int64_t &buyin,int32_t &maxplayers,CScript s std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin; ss >> mayplayers) != 0 && e == EVAL_ROGUE && f == 'G' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin; ss >> maxplayers) != 0 && e == EVAL_ROGUE && f == 'G' ) { return(f); } @@ -174,7 +174,7 @@ void rogue_univalue(UniValue &result,const char *method,int64_t maxplayers,int64 void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin) { - CBlockIndex *pindex; int32_t ht; uint64_t seed; char cmd[512]; + CBlockIndex *pindex; int32_t ht; uint256 hashBlock; uint64_t seed; char cmd[512]; if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); @@ -200,7 +200,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin) int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid) { - uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; + uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { @@ -241,7 +241,7 @@ int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace p return(0); else { - fprintf(stderr,"firsttxid.%s -> %s != last.%s\n",firsttxid.ToString(),txid.ToString(),lasttxid.ToString()); + fprintf(stderr,"firsttxid.%s -> %s != last.%s\n",firsttxid.ToString().c_str(),txid.ToString().c_str(),lasttxid.ToString().c_str()); return(-1); } } @@ -253,12 +253,12 @@ int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace p 'S' is for sell, but will need to change to accomodate assets */ -int32_t rogue_playerdata(uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) +int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { uint256 origplayertxid,hashBlock,highlander,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { - GetOpReturnData(scriptPubKey,vopret); + GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'S') ) { @@ -271,7 +271,7 @@ int32_t rogue_playerdata(uint256 &origplayergame,CPubKey &pk,std::vector 1 ) + if ( highlandertx.vin[0].prevout.hash == prigplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) return(0); else return(-3); } @@ -315,7 +315,7 @@ int32_t rogue_findbaton(std::vector &playerdata,uint256 &batontxid,int3 numvouts = matchtx.vout.size(); if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { - if ( playertxid == zeroid || rogue_playerdata(origplayergame,playerdata,playertxid) == 0 ) + if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,playerdata,playertxid) == 0 ) { txid = spenttxid; while ( CCgettxout(txid,0,1) > 0 ) @@ -453,7 +453,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { UniValue pobj(UniValue:VOBJ); playertxid = jbits256(jitem(params,0),0); - if ( rogue_playerdata(origplayergame,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); result.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); } else return(cclib_error(result,"no playertxid")); @@ -486,7 +486,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 1 && maxplayers > 1 ) { playertxid = jbits256(jitem(params,0),0); - if ( rogue_playerdata(origplayergame,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,playerdata,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); } rogue_univalue(result,0,maxplayers,buyin); From 5e5f9d0054cc56c0167a5674eb63f37001dab9d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 19:57:15 -1100 Subject: [PATCH 1783/3904] CTxIn( --- src/cc/rogue_rpc.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ec4e56aee..418c5100c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -225,7 +225,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &b UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) { - obj.push_back("raw",playerdata.ToString()); + obj.push_back("raw",playerdata.GetHex().ToString()); // convert to scrolls, etc. return(obj); } @@ -255,7 +255,7 @@ int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace p int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,highlander,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,highlander,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); @@ -271,7 +271,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { if ( rogue_highlanderopretdecode(origplayergame,registertxid,pk,playerdata,highlandertx.vout[numvouts-1].scriptPubKey) == 'H' ) { - if ( highlandertx.vin[0].prevout.hash == prigplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) + if ( highlandertx.vin[0].prevout.hash == origplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) return(0); else return(-3); } @@ -287,8 +287,8 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 int64_t txfee = 10000; if ( CCgettxout(playertxid,0,1) == txfee && CCgettxout(origplayergame,1,1) == txfee ) { - mtx.vin.push_back(playertxid,0,CScript()); - mtx.vin.push_back(origplayergame,1,CScript()); + mtx.vin.push_back(CTxIn(playertxid,0,CScript())); + mtx.vin.push_back(CTxIn(origplayergame,1,CScript())); return(0); } else return(-1); } @@ -381,7 +381,7 @@ int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTrans vout = (r + j) % maxplayers; if ( CCgettxout(gametxid,vout,1) == ROGUE_REGISTRATIONSIZE ) { - mtx.vin.push_back(gametxid,vout,CScript()); + mtx.vin.push_back(CTxIn(gametxid,vout,CScript())); return(ROGUE_REGISTRATIONSIZE); } } @@ -530,7 +530,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { - mtx.vin.push_back(batontxid,batonvout,CScript()); + mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,roguepk,mypk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_keystrokesopret(gametxid,batontxid,mypk,keystrokes)); return(rogue_rawtxresult(result,rawtx,1)); From dcfd8c570536675942d487e82253619d3ca4360c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 20:03:48 -1100 Subject: [PATCH 1784/3904] struct CCcontract_info *cp, --- src/cc/rogue_rpc.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 418c5100c..ec914a4d2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -225,7 +225,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &b UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) { - obj.push_back("raw",playerdata.GetHex().ToString()); + obj.push_back("raw",""); // convert to scrolls, etc. return(obj); } @@ -293,14 +293,14 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 } else return(-1); } -int32_t rogue_findbaton(std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,CScript scriptPubKey) +int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,CScript scriptPubKey) { int32_t i,numvouts,spentvini,matches = 0; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; for (i=0; i= 0 ) { - if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && tx.vout.size() > 0 ) + if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) { if ( spenttx.vout[0].scriptPubKey == scriptPubKey ) { @@ -321,10 +321,10 @@ int32_t rogue_findbaton(std::vector &playerdata,uint256 &batontxid,int3 while ( CCgettxout(txid,0,1) > 0 ) { spenttxid = zeroid; - spentvinit = -1; + spentvini = -1; if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) txid = spenttxid; - else if ( myIsutxo_spentinmempool(spenttxid,spentvin,txid,0) == 0 || spenttxid == zeroid ) + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) { fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); return(-2); @@ -342,7 +342,7 @@ int32_t rogue_findbaton(std::vector &playerdata,uint256 &batontxid,int3 batonht = komodo_nextheight(); else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) return(-4); - else batonht = pindex->nHeight; + else batonht = pindex->GetHeight(); return(0); } } @@ -351,12 +351,12 @@ int32_t rogue_findbaton(std::vector &playerdata,uint256 &batontxid,int3 return(-1); } -void rogue_gameplayerinfo(UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) +void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out uint256 batontxid; int32_t batonvout,batonht; int64_t batonvalue; std::vector playerdata; obj.push_back(Pair("slot",(int64_t)vout-2)); - if ( rogue_findbaton(playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gametx.vout[vout].scriptPubKey) == 0 ) + if ( rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gametx.vout[vout].scriptPubKey) == 0 ) { obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonvout",(int64_t)batonvout)); @@ -364,7 +364,7 @@ void rogue_gameplayerinfo(UniValue &obj,uint256 gametxid,CTransaction gametx,int obj.push_back(Pair("batonht",(int64_t)batonht)); if ( playerdata.size() > 0 ) { - UniValue pobj(UniValue:VOBJ); + UniValue pobj(UniValue::VOBJ); obj.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); } } @@ -373,7 +373,7 @@ void rogue_gameplayerinfo(UniValue &obj,uint256 gametxid,CTransaction gametx,int int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTransaction gametx,int32_t maxplayers) { int32_t vout,j,r; int64_t nValue; - if ( tx.vout.size() > maxplayers+2 ) + if ( gametx.vout.size() > maxplayers+2 ) { r = rand() % maxplayers; for (j=0; j 0 ) { - UniValue pobj(UniValue:VOBJ); + UniValue pobj(UniValue::VOBJ); playertxid = jbits256(jitem(params,0),0); if ( rogue_playerdata(cp,origplayergame,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); @@ -469,7 +469,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); uint256 gametxid,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; + UniValue result(UniValue::VOBJ); uint256 gametxid,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -526,7 +526,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param txout = MakeCC1of2vout(cp->evalcode,0,roguepk,mypk); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,txout.scriptPubKey) == 0 ) + if ( rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,txout.scriptPubKey) == 0 ) { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { @@ -595,7 +595,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( CCgettxout(txid,i+2,1) == 0 ) { UniValue obj(UniValue::VOBJ); - rogue_gameplayerinfo(obj,txid,tx,i+2,maxplayers); + rogue_gameplayerinfo(cp,obj,txid,tx,i+2,maxplayers); a.push_back(obj); } } From 0c8f7886af5c297cd0ba49efc564e5eb621ec68d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 20:06:21 -1100 Subject: [PATCH 1785/3904] struct CCcontract_info *cp, --- src/cc/rogue_rpc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ec914a4d2..0146775dd 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -225,7 +225,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &b UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) { - obj.push_back("raw",""); + obj.push_back(Pair("raw",playerdata.ToString())); // convert to scrolls, etc. return(obj); } @@ -295,7 +295,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,CScript scriptPubKey) { - int32_t i,numvouts,spentvini,matches = 0; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; + int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; for (i=0; i= 0 ) @@ -315,7 +315,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd numvouts = matchtx.vout.size(); if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { - if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,playerdata,playertxid) == 0 ) + if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { txid = spenttxid; while ( CCgettxout(txid,0,1) > 0 ) @@ -444,7 +444,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,origplayergame;std::vector playerdata; int32_t n; + UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,origplayergame;std::vector playerdata; int32_t n; CPubKey pk; result.push_back(Pair("result","success")); rogue_univalue(result,"playerinfo",-1,-1); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -453,7 +453,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { UniValue pobj(UniValue::VOBJ); playertxid = jbits256(jitem(params,0),0); - if ( rogue_playerdata(cp,origplayergame,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); result.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); } else return(cclib_error(result,"no playertxid")); @@ -486,7 +486,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 1 && maxplayers > 1 ) { playertxid = jbits256(jitem(params,0),0); - if ( rogue_playerdata(cp,origplayergame,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); } rogue_univalue(result,0,maxplayers,buyin); From afd20ae4c12c2381fdf27f90dfd0378880f69555 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 20:14:18 -1100 Subject: [PATCH 1786/3904] Bits256 --- src/cc/rogue_rpc.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0146775dd..8ed303582 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -225,7 +225,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &b UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) { - obj.push_back(Pair("raw",playerdata.ToString())); + obj.push_back(Pair("raw","")); // convert to scrolls, etc. return(obj); } @@ -285,7 +285,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint256 origplayergame) { int64_t txfee = 10000; - if ( CCgettxout(playertxid,0,1) == txfee && CCgettxout(origplayergame,1,1) == txfee ) + if ( CCgettxout(playertxid,0,1) == txfee && CCgettxout(origplayergame,1,1) == txfee ) // not sure if this is enough validation { mtx.vin.push_back(CTxIn(playertxid,0,CScript())); mtx.vin.push_back(CTxIn(origplayergame,1,CScript())); @@ -444,7 +444,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,origplayergame;std::vector playerdata; int32_t n; CPubKey pk; + UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,origplayergame;int32_t n; CPubKey pk; bits256 t; result.push_back(Pair("result","success")); rogue_univalue(result,"playerinfo",-1,-1); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -452,7 +452,8 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( n > 0 ) { UniValue pobj(UniValue::VOBJ); - playertxid = jbits256(jitem(params,0),0); + t = jbits256(jitem(params,0),0); + memcpy(&playertxid,t,sizeof(playertxid));; if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); result.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); @@ -469,7 +470,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); uint256 gametxid,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; + UniValue result(UniValue::VOBJ); uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -480,12 +481,14 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( n > 0 ) { - gametxid = jbits256(jitem(params,0),0); + t = jbits256(jitem(params,0),0); + memcpy(&gametxid,t,sizeof(gametxid)); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { if ( n > 1 && maxplayers > 1 ) { - playertxid = jbits256(jitem(params,0),0); + t = jbits256(jitem(params,0),0); + memcpy(&playertxid,t,sizeof(playertxid)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); } @@ -513,13 +516,14 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { - gametxid = jbits256(jitem(params,0),0); + t = jbits256(jitem(params,0),0); + memcpy(&gametxid,t,sizeof(gametxid)); keystrokes = ParseHex(keystrokestr); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); @@ -577,14 +581,15 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; bits256 t; result.push_back(Pair("name","rogue")); result.push_back(Pair("method","gameinfo")); if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { - txid = jbits256(jitem(params,0),0); + t = jbits256(jitem(params,0),0); + memcpy(&txid,t,sizeof(txid)); result.push_back(Pair("txid",txid.GetHex())); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) { From 5754d4cca6377debcfc2922b278f25d8f5b5e2ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 20:16:01 -1100 Subject: [PATCH 1787/3904] & --- src/cc/rogue_rpc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8ed303582..446701ca3 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -453,7 +453,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { UniValue pobj(UniValue::VOBJ); t = jbits256(jitem(params,0),0); - memcpy(&playertxid,t,sizeof(playertxid));; + memcpy(&playertxid,&t,sizeof(playertxid));; if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); result.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); @@ -482,13 +482,13 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 0 ) { t = jbits256(jitem(params,0),0); - memcpy(&gametxid,t,sizeof(gametxid)); + memcpy(&gametxid,&t,sizeof(gametxid)); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { if ( n > 1 && maxplayers > 1 ) { t = jbits256(jitem(params,0),0); - memcpy(&playertxid,t,sizeof(playertxid)); + memcpy(&playertxid,&t,sizeof(playertxid)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); } @@ -497,7 +497,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find available registration baton")); else if ( playertxid != zeroid && rogue_playerdataspend(mtx,playertxid,origplayergame) < 0 ) return(cclib_error(result,"couldnt find playerdata to spend")); - else if ( buyin > 0 && AddNormalInputs(mtx,mypk,buyin,64) < buyin ) + else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,inputsum-txfee,roguepk,mypk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_registeropret(gametxid,playertxid)); @@ -523,7 +523,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { t = jbits256(jitem(params,0),0); - memcpy(&gametxid,t,sizeof(gametxid)); + memcpy(&gametxid,&t,sizeof(gametxid)); keystrokes = ParseHex(keystrokestr); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); @@ -589,7 +589,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 0 ) { t = jbits256(jitem(params,0),0); - memcpy(&txid,t,sizeof(txid)); + memcpy(&txid,&t,sizeof(txid)); result.push_back(Pair("txid",txid.GetHex())); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) { From 1728ffabdc43a08cbaf1d4077c4b9a4953de3472 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 15:30:54 +0800 Subject: [PATCH 1788/3904] minsigs =2 --- src/main.cpp | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b9c66c2ca..7ec88830b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3285,7 +3285,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() != 0 ) + if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() > 10 ) { // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ed195bf48..af7632b28 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int32_t iguanaPort = 9997; static const int8_t BTCminsigs = 13; -static const int8_t overrideMinSigs = 0; +static const int8_t overrideMinSigs = 2; static const char *iguanaSeeds[8][1] = { {"80.240.17.222"}, From 5f780b0325749d251cf002a0812d001c01c49c08 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 15:35:20 +0800 Subject: [PATCH 1789/3904] fix --- src/notaries_staked.h | 2 +- src/rpc/misc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index af7632b28..ed195bf48 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int32_t iguanaPort = 9997; static const int8_t BTCminsigs = 13; -static const int8_t overrideMinSigs = 2; +static const int8_t overrideMinSigs = 0; static const char *iguanaSeeds[8][1] = { {"80.240.17.222"}, diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 180403e00..1e0e33c27 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -128,7 +128,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) json.push_back(Pair("port",iguanaPort)); json.push_back(Pair("BTCminsigs",BTCminsigs)); - json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("minsigs",2)); json.push_back(Pair("seeds", seeds)); json.push_back(Pair("notaries",notaries)); return json; From 64b55a0891dedae251dd57d76cdc6900707d56de Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 20:39:47 -1100 Subject: [PATCH 1790/3904] Print --- src/cc/cclib.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index cede1a450..c72074717 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -465,6 +465,8 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will } newstr[j] = 0; params = cJSON_Parse(newstr); + if ( params != 0 ) + printf("new.(%s) -> %s\n",newstr,jprint(params,0)); free(newstr); *nump = cJSON_GetArraySize(params); //free(origparams); From ef94a1d13d0ea7813153ea5d45b8525268c0e7db Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 20:43:16 -1100 Subject: [PATCH 1791/3904] Off by 1 in parsing --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 446701ca3..499b4d48c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -414,10 +414,10 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) txfee = 10000; if ( (params= cclib_reparse(&n,params)) != 0 ) { - if ( n > 1 ) + if ( n > 0 ) { maxplayers = juint(jitem(params,0),0); - if ( n > 2 ) + if ( n > 1 ) buyin = jdouble(jitem(params,1),0) * COIN + 0.0000000049; } } From 022a5903b8ce9ae49ccf3761e7184ad4012f7e98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 21:04:19 -1100 Subject: [PATCH 1792/3904] juint256 --- src/cc/cclib.cpp | 7 + src/cc/rogue/command.c | 177 +++++++++++------------ src/cc/rogue/extern.c | 295 ++++++++++++++++++++++++++++----------- src/cc/rogue/extern.h | 1 + src/cc/rogue/fight.c | 17 +-- src/cc/rogue/init.c | 225 ++++++++++++++++------------- src/cc/rogue/io.c | 81 ++++------- src/cc/rogue/list.c | 38 +++++ src/cc/rogue/main.c | 1 + src/cc/rogue/misc.c | 8 +- src/cc/rogue/monsters.c | 5 +- src/cc/rogue/move.c | 3 +- src/cc/rogue/new_level.c | 67 ++++----- src/cc/rogue/options.c | 2 +- src/cc/rogue/pack.c | 34 ++--- src/cc/rogue/rip.c | 1 + src/cc/rogue/rogue.c | 81 +++++++++-- src/cc/rogue/rogue.h | 58 +++++--- src/cc/rogue/rooms.c | 170 +++++++++++----------- src/cc/rogue/save.c | 62 +++++++- src/cc/rogue/state.c | 145 ++++++++++++------- src/cc/rogue/sticks.c | 3 +- src/cc/rogue/things.c | 8 +- src/cc/rogue/weapons.c | 4 +- src/cc/rogue_rpc.cpp | 19 +-- 25 files changed, 933 insertions(+), 579 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c72074717..f192fc20a 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -444,6 +444,13 @@ UniValue cclib_error(UniValue &result,const char *errorstr) return(result); } +uint256 juint256(cJSON *obj) +{ + uint256 tmp; bits256 t = jbits256(obj,0); + memcpy(&tmp,&t,sizeof(tmp)); + return(revuint256(tmp)); +} + cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will be freed by caller { cJSON *params; char *jsonstr,*newstr; int32_t i,j; diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d6f834dbc..bdbf37b76 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -28,9 +28,9 @@ command(struct rogue_state *rs) char *fp; THING *mp; static char countch, direction, newcount = FALSE; - + if (on(player, ISHASTE)) - ntimes++; + ntimes++; /* * Let the daemons start up */ @@ -38,82 +38,85 @@ command(struct rogue_state *rs) do_fuses(rs,BEFORE); while (ntimes--) { - again = FALSE; - if (has_hit) - { - endmsg(rs); - has_hit = FALSE; - } - /* - * these are illegal things for the player to be, so if any are - * set, someone's been poking in memeory - */ - if (on(player, ISSLOW|ISGREED|ISINVIS|ISREGEN|ISTARGET)) - exit(1); - - look(rs,TRUE); - if (!running) - door_stop = FALSE; - status(rs); - lastscore = purse; - move(hero.y, hero.x); - if (!((running || count) && jump)) - refresh(); /* Draw screen */ - take = 0; - after = TRUE; - /* - * Read command or continue run - */ + again = FALSE; + if (has_hit) + { + endmsg(rs); + has_hit = FALSE; + } + /* + * these are illegal things for the player to be, so if any are + * set, someone's been poking in memeory + */ + if (on(player, ISSLOW|ISGREED|ISINVIS|ISREGEN|ISTARGET)) + exit(1); + + look(rs,TRUE); + if (!running) + door_stop = FALSE; + status(rs); + lastscore = purse; + move(hero.y, hero.x); + if ( rs->sleeptime != 0 ) + { + if (!((running || count) && jump)) + refresh(); /* Draw screen */ + } + take = 0; + after = TRUE; + /* + * Read command or continue run + */ #ifdef MASTER - if (wizard) - noscore = TRUE; + if (wizard) + noscore = TRUE; #endif - if (!no_command) - { - if (running || to_death) - ch = runch; - else if (count) - ch = countch; - else - { - ch = readchar(rs); - move_on = FALSE; - if (mpos != 0) /* Erase message if its there */ - msg(rs,""); - } - } - else - ch = '.'; - if (no_command) - { - if (--no_command == 0) - { - player.t_flags |= ISRUN; - msg(rs,"you can move again"); - } - } - else - { - /* - * check for prefixes - */ - newcount = FALSE; - if (isdigit(ch)) - { - count = 0; - newcount = TRUE; - while (isdigit(ch)) - { - count = count * 10 + (ch - '0'); - if (count > 255) - count = 255; - ch = readchar(rs); - } - countch = ch; - /* - * turn off count for commands which don't make sense - * to repeat - */ + if (!no_command) + { + if (running || to_death) + ch = runch; + else if (count) + ch = countch; + else + { + ch = readchar(rs); + move_on = FALSE; + if (mpos != 0) /* Erase message if its there */ + msg(rs,""); + } + } + else + ch = '.'; + if (no_command) + { + if (--no_command == 0) + { + player.t_flags |= ISRUN; + msg(rs,"you can move again"); + } + } + else + { + /* + * check for prefixes + */ + newcount = FALSE; + if (isdigit(ch)) + { + count = 0; + newcount = TRUE; + while (isdigit(ch)) + { + count = count * 10 + (ch - '0'); + if (count > 255) + count = 255; + ch = readchar(rs); + } + countch = ch; + /* + * turn off count for commands which don't make sense + * to repeat + */ switch (ch) { case CTRL('B'): case CTRL('H'): case CTRL('J'): @@ -317,9 +320,9 @@ over: if (chat(delta.y, delta.x) != TRAP) msg(rs,"no trap there"); else if (on(player, ISHALU)) - msg(rs,tr_name[rnd(NTRAPS)]); + msg(rs,(char *)tr_name[rnd(NTRAPS)]); else { - msg(rs,tr_name[*fp & F_TMASK]); + msg(rs,(char *)tr_name[*fp & F_TMASK]); *fp |= F_SEEN; } } @@ -521,9 +524,9 @@ foundone: if (!terse) addmsg(rs,"you found "); if (on(player, ISHALU)) - msg(rs,tr_name[rnd(NTRAPS)]); + msg(rs,(char *)tr_name[rnd(NTRAPS)]); else { - msg(rs,tr_name[*fp & F_TMASK]); + msg(rs,(char *)tr_name[*fp & F_TMASK]); *fp |= F_SEEN; } goto foundone; @@ -546,7 +549,7 @@ foundone: void help(struct rogue_state *rs) { - register struct h_list *strp; + register const struct h_list *strp; register char helpch; register int numprint, cnt; msg(rs,"character you want help for (* for all): "); @@ -617,9 +620,9 @@ void identify(struct rogue_state *rs) { register int ch; - register struct h_list *hp; + register const struct h_list *hp; register char *str; - static struct h_list ident_list[] = { + static const struct h_list ident_list[] = { {'|', "wall of a room", FALSE}, {'-', "wall of a room", FALSE}, {GOLD, "gold", FALSE}, @@ -729,9 +732,9 @@ void call(struct rogue_state *rs) { register THING *obj; - register struct obj_info *op = NULL; - register char **guess, *elsewise = NULL; - register bool *know; + register const struct obj_info *op = NULL; + register char **guess; const char *elsewise = NULL; + register const bool *know; obj = get_item(rs,"call", CALLABLE); /* @@ -758,7 +761,7 @@ call(struct rogue_state *rs) elsewise = ws_made[obj->o_which]; norm: know = &op->oi_know; - guess = &op->oi_guess; + guess = (char **)&op->oi_guess; if (*guess != NULL) elsewise = *guess; when FOOD: diff --git a/src/cc/rogue/extern.c b/src/cc/rogue/extern.c index fb732dfde..b84e6fa7b 100644 --- a/src/cc/rogue/extern.c +++ b/src/cc/rogue/extern.c @@ -13,6 +13,8 @@ #include #include "rogue.h" + + bool after; /* True if we want after daemons */ bool again; /* Repeating the last command */ int noscore; /* Was a wizard sometime */ @@ -50,41 +52,21 @@ bool pack_used[26] = { /* Is the character used in the pack? */ }; char dir_ch; /* Direction from last get_dir() call */ +char runch; /* Direction player is running */ +char take; /* Thing she is taking */ + +int orig_dsusp; /* Original dsusp char */ char file_name[MAXSTR]; /* Save file name */ char huh[MAXSTR]; /* The last message printed */ -char *p_colors[MAXPOTIONS]; /* Colors of the potions */ char prbuf[2*MAXSTR]; /* buffer for sprintfs */ -char *r_stones[MAXRINGS]; /* Stone settings of the rings */ -char runch; /* Direction player is running */ -char *s_names[MAXSCROLLS]; /* Names of the scrolls */ -char take; /* Thing she is taking */ char whoami[MAXSTR]; /* Name of player */ -char *ws_made[MAXSTICKS]; /* What sticks are made of */ -char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */ -int orig_dsusp; /* Original dsusp char */ char fruit[MAXSTR] = /* Favorite fruit */ { 's', 'l', 'i', 'm', 'e', '-', 'm', 'o', 'l', 'd', '\0' }; char home[MAXSTR] = { '\0' }; /* User's home directory */ -char *inv_t_name[] = { - "Overwrite", - "Slow", - "Clear" -}; char l_last_comm = '\0'; /* Last last_comm */ char l_last_dir = '\0'; /* Last last_dir */ char last_comm = '\0'; /* Last command typed */ char last_dir = '\0'; /* Last direction given */ -char *tr_name[] = { /* Names of the traps */ - "a trapdoor", - "an arrow trap", - "a sleeping gas trap", - "a beartrap", - "a teleport trap", - "a poison dart trap", - "a rust trap", - "a mysterious trap" -}; - int n_objs; /* # items listed in inventory() call */ int ntraps; /* Number of traps on this level */ @@ -96,19 +78,8 @@ int max_hit; /* Max damage done to her in to_death */ int max_level; /* Deepest player has gone */ int mpos = 0; /* Where cursor is on top line */ int no_food = 0; /* Number of levels without food */ -int a_class[MAXARMORS] = { /* Armor class for each armor type */ - 8, /* LEATHER */ - 7, /* RING_MAIL */ - 7, /* STUDDED_LEATHER */ - 6, /* SCALE_MAIL */ - 5, /* CHAIN_MAIL */ - 4, /* SPLINT_MAIL */ - 4, /* BANDED_MAIL */ - 3, /* PLATE_MAIL */ -}; int count = 0; /* Number of times to repeat command */ -FILE *scoreboard = NULL; /* File descriptor for score file */ int food_left; /* Amount of food in hero's stomach */ int lastscore = -1; /* Score before this turn */ int no_command = 0; /* Number of turns asleep */ @@ -117,31 +88,9 @@ int purse = 0; /* How much gold he has */ int quiet = 0; /* Number of quiet turns */ int vf_hit = 0; /* Number of time flytrap has hit */ -int dnum; /* Dungeon number */ + +//int dnum; /* Dungeon number */ uint64_t seed; /* Random number seed */ -int e_levels[] = { - 10L, - 20L, - 40L, - 80L, - 160L, - 320L, - 640L, - 1300L, - 2600L, - 5200L, - 13000L, - 26000L, - 50000L, - 100000L, - 200000L, - 400000L, - 800000L, - 2000000L, - 4000000L, - 8000000L, - 0L -}; coord delta; /* Change indicated to get_dir() */ coord oldpos; /* Position before last look() call */ @@ -149,6 +98,11 @@ coord stairs; /* Location of staircase */ PLACE places[MAXLINES*MAXCOLS]; /* level map */ +const char *p_colors[MAXPOTIONS]; /* Colors of the potions */ +const char *r_stones[MAXRINGS]; /* Stone settings of the rings */ +const char *ws_made[MAXSTICKS]; /* What sticks are made of */ +const char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */ + THING *cur_armor; /* What he is wearing */ THING *cur_ring[2]; /* Which rings are being worn */ THING *cur_weapon; /* Which weapon he is weilding */ @@ -156,18 +110,36 @@ THING *l_last_pick = NULL; /* Last last_pick */ THING *last_pick = NULL; /* Last object picked in get_item() */ THING *lvl_obj = NULL; /* List of objects on this level */ THING *mlist = NULL; /* List of monsters on the level */ +struct room *oldrp; /* Roomin(&oldpos) */ THING player; /* His stats */ - /* restart of game */ - WINDOW *hw = NULL; /* used as a scratch window */ +char *s_names[MAXSCROLLS]; /* Names of the scrolls */ +FILE *scoreboard = NULL; /* File descriptor for score file */ #define INIT_STATS { 16, 0, 1, 10, 12, "1x4", 12 } struct stats max_stats = INIT_STATS; /* The maximum for the player */ +struct stats orig_max_stats = INIT_STATS; -struct room *oldrp; /* Roomin(&oldpos) */ -struct room rooms[MAXROOMS]; /* One for each room -- A level */ -struct room passages[MAXPASS] = /* One for each passage */ +struct monster monsters[26]; +struct room passages[MAXPASS],rooms[MAXROOMS]; /* One for each room -- A level */ +struct obj_info things[NUMTHINGS],ring_info[MAXRINGS],pot_info[MAXPOTIONS],arm_info[MAXARMORS],scr_info[MAXSCROLLS],weap_info[MAXWEAPONS + 1],ws_info[MAXSTICKS]; + +////////////// constants +#define ___ 1 +#define XX 10 + +const struct obj_info origthings[NUMTHINGS] = { + { 0, 26 }, /* potion */ + { 0, 36 }, /* scroll */ + { 0, 16 }, /* food */ + { 0, 7 }, /* weapon */ + { 0, 7 }, /* armor */ + { 0, 4 }, /* ring */ + { 0, 4 }, /* stick */ +}; + +const struct room origpassages[MAXPASS] = /* One for each passage */ { { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, @@ -182,10 +154,7 @@ struct room passages[MAXPASS] = /* One for each passage */ { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }, { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} } }; - -#define ___ 1 -#define XX 10 -struct monster monsters[26] = +const struct monster origmonsters[26] = { /* Name CARRY FLAG str, exp, lvl, amr, hpt, dmg */ { "aquator", 0, ISMEAN, { XX, 20, 5, 2, ___, "0x0/0x0" } }, @@ -220,17 +189,7 @@ struct monster monsters[26] = #undef ___ #undef XX -struct obj_info things[NUMTHINGS] = { - { 0, 26 }, /* potion */ - { 0, 36 }, /* scroll */ - { 0, 16 }, /* food */ - { 0, 7 }, /* weapon */ - { 0, 7 }, /* armor */ - { 0, 4 }, /* ring */ - { 0, 4 }, /* stick */ -}; - -struct obj_info arm_info[MAXARMORS] = { +const struct obj_info origarm_info[MAXARMORS] = { { "leather armor", 20, 20, NULL, FALSE }, { "ring mail", 15, 25, NULL, FALSE }, { "studded leather armor", 15, 20, NULL, FALSE }, @@ -240,7 +199,7 @@ struct obj_info arm_info[MAXARMORS] = { { "banded mail", 10, 90, NULL, FALSE }, { "plate mail", 5, 150, NULL, FALSE }, }; -struct obj_info pot_info[MAXPOTIONS] = { +const struct obj_info origpot_info[MAXPOTIONS] = { { "confusion", 7, 5, NULL, FALSE }, { "hallucination", 8, 5, NULL, FALSE }, { "poison", 8, 5, NULL, FALSE }, @@ -256,7 +215,7 @@ struct obj_info pot_info[MAXPOTIONS] = { { "blindness", 5, 5, NULL, FALSE }, { "levitation", 6, 75, NULL, FALSE }, }; -struct obj_info ring_info[MAXRINGS] = { +const struct obj_info origring_info[MAXRINGS] = { { "protection", 9, 400, NULL, FALSE }, { "add strength", 9, 400, NULL, FALSE }, { "sustain strength", 5, 280, NULL, FALSE }, @@ -272,7 +231,7 @@ struct obj_info ring_info[MAXRINGS] = { { "stealth", 7, 470, NULL, FALSE }, { "maintain armor", 5, 380, NULL, FALSE }, }; -struct obj_info scr_info[MAXSCROLLS] = { +const struct obj_info origscr_info[MAXSCROLLS] = { { "monster confusion", 7, 140, NULL, FALSE }, { "magic mapping", 4, 150, NULL, FALSE }, { "hold monster", 2, 180, NULL, FALSE }, @@ -292,7 +251,7 @@ struct obj_info scr_info[MAXSCROLLS] = { { "aggravate monsters", 3, 20, NULL, FALSE }, { "protect armor", 2, 250, NULL, FALSE }, }; -struct obj_info weap_info[MAXWEAPONS + 1] = { +const struct obj_info origweap_info[MAXWEAPONS + 1] = { { "mace", 11, 8, NULL, FALSE }, { "long sword", 11, 15, NULL, FALSE }, { "short bow", 12, 15, NULL, FALSE }, @@ -304,7 +263,7 @@ struct obj_info weap_info[MAXWEAPONS + 1] = { { "spear", 12, 5, NULL, FALSE }, { NULL, 0 }, /* DO NOT REMOVE: fake entry for dragon's breath */ }; -struct obj_info ws_info[MAXSTICKS] = { +const struct obj_info origws_info[MAXSTICKS] = { { "light", 12, 250, NULL, FALSE }, { "invisibility", 6, 5, NULL, FALSE }, { "lightning", 3, 330, NULL, FALSE }, @@ -321,7 +280,7 @@ struct obj_info ws_info[MAXSTICKS] = { { "cancellation", 5, 280, NULL, FALSE }, }; -struct h_list helpstr[] = { +const struct h_list helpstr[] = { {'?', " prints help", TRUE}, {'/', " identify object", TRUE}, {'h', " left", TRUE}, @@ -389,3 +348,169 @@ struct h_list helpstr[] = { {'v', " print version number", TRUE}, {0, NULL } }; + +const char *inv_t_name[] = { + "Overwrite", + "Slow", + "Clear" +}; + +const char *tr_name[] = { /* Names of the traps */ + "a trapdoor", + "an arrow trap", + "a sleeping gas trap", + "a beartrap", + "a teleport trap", + "a poison dart trap", + "a rust trap", + "a mysterious trap" +}; + +const int32_t a_class[MAXARMORS] = { /* Armor class for each armor type */ + 8, /* LEATHER */ + 7, /* RING_MAIL */ + 7, /* STUDDED_LEATHER */ + 6, /* SCALE_MAIL */ + 5, /* CHAIN_MAIL */ + 4, /* SPLINT_MAIL */ + 4, /* BANDED_MAIL */ + 3, /* PLATE_MAIL */ +}; + +const int32_t e_levels[] = { + 10L, + 20L, + 40L, + 80L, + 160L, + 320L, + 640L, + 1300L, + 2600L, + 5200L, + 13000L, + 26000L, + 50000L, + 100000L, + 200000L, + 400000L, + 800000L, + 2000000L, + 4000000L, + 8000000L, + 0L +}; + +#include +extern int between; +extern int group; +extern coord nh; + +void externs_clear() +{ + int i; + after = 0; /* True if we want after daemons */ + again = 0; /* Repeating the last command */ + noscore = 0; /* Was a wizard sometime */ + seenstairs = 0; /* Have seen the stairs (for lsd) */ + amulet = FALSE; /* He found the amulet */ + door_stop = FALSE; /* Stop running when we pass a door */ + fight_flush = FALSE; /* True if toilet input */ + firstmove = FALSE; /* First move after setting door_stop */ + got_ltc = FALSE; /* We have gotten the local tty chars */ + has_hit = FALSE; /* Has a "hit" message pending in msg */ + in_shell = FALSE; /* True if executing a shell */ + inv_describe = TRUE; /* Say which way items are being used */ + jump = FALSE; /* Show running as series of jumps */ + kamikaze = FALSE; /* to_death really to DEATH */ + lower_msg = FALSE; /* Messages should start w/lower case */ + move_on = FALSE; /* Next move shouldn't pick up items */ + msg_esc = FALSE; /* Check for ESC from msg's --More-- */ + passgo = FALSE; /* Follow passages */ + playing = TRUE; /* True until he quits */ + q_comm = FALSE; /* Are we executing a 'Q' command? */ + running = FALSE; /* True if player is running */ + save_msg = TRUE; /* Remember last msg */ + see_floor = TRUE; /* Show the lamp illuminated floor */ + stat_msg = FALSE; /* Should status() print as a msg() */ + terse = FALSE; /* True if we should be short */ + to_death = FALSE; /* Fighting is to the death! */ + tombstone = TRUE; /* Print out tombstone at end */ +#ifdef MASTER + int wizard = FALSE; /* True if allows wizard commands */ +#endif + for (i=0; i<26; i++) + pack_used[i] = FALSE; + for (i=0; io_type = FOOD; - obj->o_count = 1; - add_pack(rs,obj, TRUE); - /* - * And his suit of armor - */ - obj = new_item(); - obj->o_type = ARMOR; - obj->o_which = RING_MAIL; - obj->o_arm = a_class[RING_MAIL] - 1; - obj->o_flags |= ISKNOW; - obj->o_count = 1; - cur_armor = obj; - add_pack(rs,obj, TRUE); - /* - * Give him his weaponry. First a mace. - */ - obj = new_item(); - init_weapon(obj, MACE); - obj->o_hplus = 1; - obj->o_dplus = 1; - obj->o_flags |= ISKNOW; - add_pack(rs,obj, TRUE); - cur_weapon = obj; - /* - * Now a +1 bow - */ - obj = new_item(); - init_weapon(obj, BOW); - obj->o_hplus = 1; - obj->o_flags |= ISKNOW; - add_pack(rs,obj, TRUE); - /* - * Now some arrows - */ - obj = new_item(); - init_weapon(obj, ARROW); - obj->o_count = rnd(15) + 25; - obj->o_flags |= ISKNOW; - add_pack(rs,obj, TRUE); + + if ( 0 && rogue_restorepack(rs) == 0 ) + { + //rs->P.gold = purse; + max_hp = rs->P.hitpoints; + max_stats.s_str = rs->P.strength; + pstats.s_lvl = rs->P.level; + pstats.s_exp = rs->P.experience; + for (i=0; iP.packsize; i++) + { + obj = new_item(); + rogue_restoreobject(obj,&rs->P.roguepack[i]); + add_pack(rs,obj,TRUE); + } + // duplicate rng usage of normal case + obj = new_item(); + init_weapon(obj, MACE); + init_weapon(obj, BOW); + init_weapon(obj, ARROW); + obj->o_count = rnd(15) + 25; + free(obj); + } + else + { + /* + * Give him some food + */ + obj = new_item(); + obj->o_type = FOOD; + obj->o_count = 1; + add_pack(rs,obj, TRUE); + /* + * And his suit of armor + */ + obj = new_item(); + obj->o_type = ARMOR; + obj->o_which = RING_MAIL; + obj->o_arm = a_class[RING_MAIL] - 1; + obj->o_flags |= ISKNOW; + obj->o_count = 1; + cur_armor = obj; + add_pack(rs,obj, TRUE); + /* + * Give him his weaponry. First a mace. + */ + obj = new_item(); + init_weapon(obj, MACE); + obj->o_hplus = 1; + obj->o_dplus = 1; + obj->o_flags |= ISKNOW; + add_pack(rs,obj, TRUE); + cur_weapon = obj; + /* + * Now a +1 bow + */ + obj = new_item(); + init_weapon(obj, BOW); + obj->o_hplus = 1; + obj->o_flags |= ISKNOW; + add_pack(rs,obj, TRUE); + /* + * Now some arrows + */ + obj = new_item(); + init_weapon(obj, ARROW); + obj->o_count = rnd(15) + 25; + obj->o_flags |= ISKNOW; + add_pack(rs,obj, TRUE); + //fprintf(stderr,"initial o_count.%d\n",obj->o_count); sleep(3); + } } /* @@ -78,7 +105,7 @@ init_player(struct rogue_state *rs) * potions and scrolls */ -char *rainbow[] = { +const char *rainbow[] = { "amber", "aquamarine", "black", @@ -111,7 +138,7 @@ char *rainbow[] = { #define NCOLORS (sizeof rainbow / sizeof (char *)) int cNCOLORS = NCOLORS; -static char *sylls[] = { +static const char *sylls[] = { "a", "ab", "ag", "aks", "ala", "an", "app", "arg", "arze", "ash", "bek", "bie", "bit", "bjor", "blu", "bot", "bu", "byt", "comp", "con", "cos", "cre", "dalf", "dan", "den", "do", "e", "eep", "el", @@ -130,7 +157,7 @@ static char *sylls[] = { "zok", "zon", "zum", }; -STONE stones[] = { +const STONE stones[] = { { "agate", 25}, { "alexandrite", 40}, { "amethyst", 50}, @@ -162,7 +189,7 @@ STONE stones[] = { #define NSTONES (sizeof stones / sizeof (STONE)) int cNSTONES = NSTONES; -char *wood[] = { +const char *wood[] = { "avocado wood", "balsa", "bamboo", @@ -201,7 +228,7 @@ char *wood[] = { #define NWOOD (sizeof wood / sizeof (char *)) int cNWOOD = NWOOD; -char *metal[] = { +const char *metal[] = { "aluminum", "beryllium", "bone", @@ -240,16 +267,16 @@ void init_colors() { register int i, j; - + memset(used,0,sizeof(used)); for (i = 0; i < NCOLORS; i++) - used[i] = FALSE; + used[i] = FALSE; for (i = 0; i < MAXPOTIONS; i++) { - do - j = rnd(NCOLORS); - until (!used[j]); - used[j] = TRUE; - p_colors[i] = rainbow[j]; + do + j = rnd(NCOLORS); + until (!used[j]); + used[j] = TRUE; + p_colors[i] = rainbow[j]; } } @@ -263,7 +290,7 @@ void init_names() { register int nsyl; - register char *cp, *sp; + register char *cp; const char *sp; register int i, nwords; for (i = 0; i < MAXSCROLLS; i++) @@ -297,17 +324,16 @@ void init_stones() { register int i, j; - for (i = 0; i < NSTONES; i++) - used[i] = FALSE; + used[i] = FALSE; for (i = 0; i < MAXRINGS; i++) { - do - j = rnd(NSTONES); - until (!used[j]); - used[j] = TRUE; - r_stones[i] = stones[j].st_name; - ring_info[i].oi_worth += stones[j].st_value; + do + j = rnd(NSTONES); + until (!used[j]); + used[j] = TRUE; + r_stones[i] = stones[j].st_name; + ring_info[i].oi_worth += stones[j].st_value; } } @@ -319,39 +345,39 @@ void init_materials() { register int i, j; - register char *str; + register const char *str; static bool metused[NMETAL]; - + memset(metused,0,sizeof(metused)); for (i = 0; i < NWOOD; i++) - used[i] = FALSE; + used[i] = FALSE; for (i = 0; i < NMETAL; i++) - metused[i] = FALSE; + metused[i] = FALSE; for (i = 0; i < MAXSTICKS; i++) { - for (;;) - if (rnd(2) == 0) - { - j = rnd(NMETAL); - if (!metused[j]) - { - ws_type[i] = "wand"; - str = metal[j]; - metused[j] = TRUE; - break; - } - } - else - { - j = rnd(NWOOD); - if (!used[j]) - { - ws_type[i] = "staff"; - str = wood[j]; - used[j] = TRUE; - break; - } - } - ws_made[i] = str; + for (;;) + if (rnd(2) == 0) + { + j = rnd(NMETAL); + if (!metused[j]) + { + ws_type[i] = "wand"; + str = metal[j]; + metused[j] = TRUE; + break; + } + } + else + { + j = rnd(NWOOD); + if (!used[j]) + { + ws_type[i] = "staff"; + str = wood[j]; + used[j] = TRUE; + break; + } + } + ws_made[i] = str; } } @@ -380,18 +406,17 @@ init_materials() void sumprobs(struct obj_info *info, int bound #ifdef MASTER - , char *name + , char *name #endif ) { #ifdef MASTER - struct obj_info *start = info; + struct obj_info *start = info; #endif struct obj_info *endp; - endp = info + bound; while (++info < endp) - info->oi_prob += (info - 1)->oi_prob; + info->oi_prob += (info - 1)->oi_prob; #ifdef MASTER badcheck(name, start, bound); #endif @@ -443,5 +468,5 @@ badcheck(char *name, struct obj_info *info, int bound) char * pick_color(char *col) { - return (on(player, ISHALU) ? rainbow[rnd(NCOLORS)] : col); + return (on(player, ISHALU) ? (char *)rainbow[rnd(NCOLORS)] : col); } diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index bdf3c515c..f4a859b38 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -24,16 +24,16 @@ int msg(struct rogue_state *rs,char *fmt, ...) { va_list args; - + /* * if the string is "", just clear the line */ if (*fmt == '\0') { - move(0, 0); - clrtoeol(); - mpos = 0; - return ~ESCAPE; + move(0, 0); + clrtoeol(); + mpos = 0; + return ~ESCAPE; } /* * otherwise add to the message and flush it out @@ -70,39 +70,41 @@ endmsg(struct rogue_state *rs) char ch; if (save_msg) - strcpy(huh, msgbuf); + strcpy(huh, msgbuf); if (mpos) { - look(rs,FALSE); - mvaddstr(0, mpos, "--More--"); - refresh(); - if (!msg_esc) - wait_for(rs,' '); - else - { - while ((ch = readchar(rs)) != ' ') - if (ch == ESCAPE) - { - msgbuf[0] = '\0'; - mpos = 0; - newpos = 0; - msgbuf[0] = '\0'; - return ESCAPE; - } - } + look(rs,FALSE); + mvaddstr(0, mpos, "--More--"); + if ( rs->sleeptime != 0 ) + refresh(); + if (!msg_esc) + wait_for(rs,' '); + else + { + while ((ch = readchar(rs)) != ' ') + if (ch == ESCAPE) + { + msgbuf[0] = '\0'; + mpos = 0; + newpos = 0; + msgbuf[0] = '\0'; + return ESCAPE; + } + } } /* * All messages should start with uppercase, except ones that * start with a pack addressing character */ if (islower(msgbuf[0]) && !lower_msg && msgbuf[1] != ')') - msgbuf[0] = (char) toupper(msgbuf[0]); + msgbuf[0] = (char) toupper(msgbuf[0]); mvaddstr(0, 0, msgbuf); clrtoeol(); mpos = newpos; newpos = 0; msgbuf[0] = '\0'; - refresh(); + if ( rs->sleeptime != 0 ) + refresh(); return ~ESCAPE; } @@ -188,35 +190,6 @@ readchar(struct rogue_state *rs) return(ch); } -/*char readchar() -{ - static FILE *keystrokefp; int c; - - if ( keystrokefp == 0 ) - keystrokefp = fopen("keystrokes","rb"); - if ( keystrokefp != 0 ) - { - if ( (c= fgetc(keystrokefp)) == EOF ) - eofflag = 1; - else return(c); - } else eofflag = 1; - ch = (char) md_readchar(); - - if (ch == 3) - { - quit(0); - return(27); - } - { - static FILE *replayfp; - if ( replayfp == 0 ) - replayfp = fopen("replay","wb"); - if ( replayfp != 0 ) - fputc(ch,replayfp), fflush(replayfp); - } - return(ch); -}*/ - /* * status: * Display the important stats line. Keep the cursor where it was. diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index f571be628..6affc662c 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -12,6 +12,7 @@ #include #include +#include #include "rogue.h" #ifdef MASTER @@ -81,19 +82,50 @@ _free_list(THING **ptr) * Free up an item */ +int32_t itemcounter; +THING *thingptrs[100000]; +int32_t numptrs; + void discard(THING *item) { #ifdef MASTER total--; #endif + if ( 0 ) + { + int32_t i; + for (i=0; i_t._t_type,thingptrs[i]->o_type,thingptrs[i]->o_type); + free(thingptrs[i]); + } + memset(thingptrs,0,sizeof(thingptrs)); + numptrs = 0; +} + /* * new_item * Get a new item with a specified size */ + THING * new_item(void) { @@ -107,6 +139,12 @@ new_item(void) #else item = (THING *)calloc(1, sizeof *item); #endif + if ( 0 ) + { + thingptrs[numptrs++] = item; + if ( (++itemcounter % 100) == 0 ) + fprintf(stderr,"itemcounter.%d\n",itemcounter); + } item->l_next = NULL; item->l_prev = NULL; return item; diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index d2805ed73..7efdebc8d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -13,6 +13,7 @@ * * ******************************************************************************/ + #include #include #include diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 775878450..168886b6b 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -350,17 +350,17 @@ chg_str(int amt) { //auto jl777: strange compiler error str_t comp; - + if (amt == 0) return; add_str(&pstats.s_str, amt); comp = pstats.s_str; if (ISRING(LEFT, R_ADDSTR)) - add_str(&comp, -cur_ring[LEFT]->o_arm); + add_str(&comp, -cur_ring[LEFT]->o_arm); if (ISRING(RIGHT, R_ADDSTR)) - add_str(&comp, -cur_ring[RIGHT]->o_arm); + add_str(&comp, -cur_ring[RIGHT]->o_arm); if (comp > max_stats.s_str) - max_stats.s_str = comp; + max_stats.s_str = comp; } /* diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index c9441efa3..4649de9a2 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -218,7 +218,10 @@ void give_pack(struct rogue_state *rs,THING *tp) { if (level >= max_level && rnd(100) < monsters[tp->t_type-'A'].m_carry) - attach(tp->t_pack, new_thing(rs)); + { + //fprintf(stderr,"give_pack\n"); + attach(tp->t_pack, new_thing(rs)); + } } /* diff --git a/src/cc/rogue/move.c b/src/cc/rogue/move.c index b402f4fa1..87276e8e2 100644 --- a/src/cc/rogue/move.c +++ b/src/cc/rogue/move.c @@ -230,7 +230,8 @@ turnref() if (jump) { leaveok(stdscr, TRUE); - refresh(); + if ( globalR.sleeptime != 0 ) + refresh(); leaveok(stdscr, FALSE); } pp->p_flags |= F_SEEN; diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index 2c0ae7b51..9b2348b3f 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -26,25 +26,25 @@ new_level(struct rogue_state *rs) PLACE *pp; char *sp; int i; - + player.t_flags &= ~ISHELD; /* unhold when you go down just in case */ if (level > max_level) - max_level = level; + max_level = level; /* * Clean things off from last level */ for (pp = places; pp < &places[MAXCOLS*MAXLINES]; pp++) { - pp->p_ch = ' '; - pp->p_flags = F_REAL; - pp->p_monst = NULL; + pp->p_ch = ' '; + pp->p_flags = F_REAL; + pp->p_monst = NULL; } clear(); /* * Free up the monsters on the last level */ for (tp = mlist; tp != NULL; tp = next(tp)) - free_list(tp->t_pack); + free_list(tp->t_pack); free_list(mlist); /* * Throw away stuff left on the previous level (if anything) @@ -53,32 +53,33 @@ new_level(struct rogue_state *rs) do_rooms(rs); /* Draw rooms */ do_passages(rs); /* Draw passages */ no_food++; + //fprintf(stderr,"new_level.%d\n",level); put_things(rs); /* Place objects (if any) */ /* * Place the traps */ if (rnd(10) < level) { - ntraps = rnd(level / 4) + 1; - if (ntraps > MAXTRAPS) - ntraps = MAXTRAPS; - i = ntraps; - while (i--) - { - /* - * not only wouldn't it be NICE to have traps in mazes - * (not that we care about being nice), since the trap - * number is stored where the passage number is, we - * can't actually do it. - */ - do - { - find_floor((struct room *) NULL, &stairs, FALSE, FALSE); - } while (chat(stairs.y, stairs.x) != FLOOR); - sp = &flat(stairs.y, stairs.x); - *sp &= ~F_REAL; - *sp |= rnd(NTRAPS); - } + ntraps = rnd(level / 4) + 1; + if (ntraps > MAXTRAPS) + ntraps = MAXTRAPS; + i = ntraps; + while (i--) + { + /* + * not only wouldn't it be NICE to have traps in mazes + * (not that we care about being nice), since the trap + * number is stored where the passage number is, we + * can't actually do it. + */ + do + { + find_floor((struct room *) NULL, &stairs, FALSE, FALSE); + } while (chat(stairs.y, stairs.x) != FLOOR); + sp = &flat(stairs.y, stairs.x); + *sp &= ~F_REAL; + *sp |= rnd(NTRAPS); + } } /* * Place the staircase down. @@ -86,17 +87,17 @@ new_level(struct rogue_state *rs) find_floor((struct room *) NULL, &stairs, FALSE, FALSE); chat(stairs.y, stairs.x) = STAIRS; seenstairs = FALSE; - + for (tp = mlist; tp != NULL; tp = next(tp)) - tp->t_room = roomin(rs,&tp->t_pos); - + tp->t_room = roomin(rs,&tp->t_pos); + find_floor((struct room *) NULL, &hero, FALSE, TRUE); enter_room(rs,&hero); mvaddch(hero.y, hero.x, PLAYER); if (on(player, SEEMONST)) - turn_see(FALSE); + turn_see(FALSE); if (on(player, ISHALU)) - visuals(rs,0); + visuals(rs,0); } /* @@ -147,7 +148,8 @@ put_things(struct rogue_state *rs) * Pick a new object and link it in the list */ obj = new_thing(rs); - attach(lvl_obj, obj); + //fprintf(stderr,"put_things i.%d obj.%p\n",i,obj); + attach(lvl_obj, obj); /* * Put it somewhere */ @@ -200,6 +202,7 @@ treas_room(struct rogue_state *rs) while (nm--) { find_floor(rp, &mp, 2 * MAXTRIES, FALSE); + //fprintf(stderr,"treas_room\n"); tp = new_thing(rs); tp->o_pos = mp; attach(lvl_obj, tp); diff --git a/src/cc/rogue/options.c b/src/cc/rogue/options.c index 667d83248..6907da598 100644 --- a/src/cc/rogue/options.c +++ b/src/cc/rogue/options.c @@ -403,7 +403,7 @@ parse_opts(char *str) char *sp; OPTION *op; int len; - char **i; + const char **i; char *start; while (*str) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 8385f95dd..ee628b4f0 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -252,25 +252,25 @@ inventory(struct rogue_state *rs,THING *list, int type) n_objs = 0; for (; list != NULL; list = next(list)) { - if (type && type != list->o_type && !(type == CALLABLE && - list->o_type != FOOD && list->o_type != AMULET) && - !(type == R_OR_S && (list->o_type == RING || list->o_type == STICK))) - continue; - n_objs++; + if (type && type != list->o_type && !(type == CALLABLE && + list->o_type != FOOD && list->o_type != AMULET) && + !(type == R_OR_S && (list->o_type == RING || list->o_type == STICK))) + continue; + n_objs++; #ifdef MASTER - if (!list->o_packch) - strcpy(inv_temp, "%s"); - else + if (!list->o_packch) + strcpy(inv_temp, "%s"); + else #endif - sprintf(inv_temp, "%c) %%s", list->o_packch); - msg_esc = TRUE; - if (add_line(rs,inv_temp, inv_name(list, FALSE)) == ESCAPE) - { - msg_esc = FALSE; - msg(rs,""); - return TRUE; - } - msg_esc = FALSE; + sprintf(inv_temp, "%c) %%s", list->o_packch); + msg_esc = TRUE; + if (add_line(rs,inv_temp, inv_name(list, FALSE)) == ESCAPE) + { + msg_esc = FALSE; + msg(rs,""); + return TRUE; + } + msg_esc = FALSE; } if (n_objs == 0) { diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index dc22566e9..69eb89751 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -218,6 +218,7 @@ score(int amount, int flags, char monst) signal(SIGINT, fp); } } + free(top_ten); } /* diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 8acdf8844..554c0ae4e 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -21,10 +21,48 @@ * The main program, of course */ struct rogue_state globalR; +void garbage_collect(); + +void purge_obj_guess(struct obj_info *array,int32_t n) +{ + int32_t i; + for (i=0; iseed; + //clear(); + purge_obj_guess(things,NUMTHINGS); + purge_obj_guess(ring_info,MAXRINGS); + purge_obj_guess(pot_info,MAXPOTIONS); + purge_obj_guess(arm_info,MAXARMORS); + purge_obj_guess(scr_info,MAXSCROLLS); + purge_obj_guess(weap_info,MAXWEAPONS + 1); + purge_obj_guess(ws_info,MAXSTICKS); + free_list(player._t._t_pack); + for (tp = mlist; tp != NULL; tp = next(tp)) + free_list(tp->t_pack); + free_list(mlist); + free_list(lvl_obj); + garbage_collect(); + + externs_clear(); + memset(d_list,0,sizeof(d_list)); + + memcpy(passages,origpassages,sizeof(passages)); + memcpy(monsters,origmonsters,sizeof(monsters)); + memcpy(things,origthings,sizeof(things)); + + memcpy(ring_info,origring_info,sizeof(ring_info)); + memcpy(pot_info,origpot_info,sizeof(pot_info)); + memcpy(arm_info,origarm_info,sizeof(arm_info)); + memcpy(scr_info,origscr_info,sizeof(scr_info)); + memcpy(weap_info,origweap_info,sizeof(weap_info)); + memcpy(ws_info,origws_info,sizeof(ws_info)); initscr(); /* Start up cursor package */ init_probs(); /* Set up prob tables for objects */ @@ -45,7 +83,8 @@ void rogueiterate(struct rogue_state *rs) my_exit(1); } // Set up windows - hw = newwin(LINES, COLS, 0, 0); + if ( hw == NULL ) + hw = newwin(LINES, COLS, 0, 0); idlok(stdscr, TRUE); idlok(hw, TRUE); #ifdef MASTER @@ -80,7 +119,7 @@ int32_t flushkeystrokes(struct rogue_state *rs) fclose(fp); if ( (fp= fopen("savefile","wb")) != 0 ) { - save_file(fp,0); + save_file(rs,fp,0); if ( 0 && (fp= fopen("savefile","rb")) != 0 ) { for (i=0; i<0x150; i++) @@ -145,11 +184,27 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; - rs->sleeptime = sleeptime; + rs->sleeptime = 1; + uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); + sleep(2); + + starttime = (uint32_t)time(NULL); + for (i=0; i<2000; i++) + { + memset(rs,0,sizeof(*rs)); + rs->seed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = 0; + rogueiterate(rs); + } + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); + sleep(1); if ( (fp= fopen("checkfile","wb")) != 0 ) { - save_file(fp,0); + save_file(rs,fp,0); if ( 0 && (fp= fopen("checkfile","rb")) != 0 ) { for (i=0; i<0x150; i++) @@ -160,7 +215,6 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } free(rs); mvaddstr(LINES - 2, 0, (char *)"replay completed"); - refresh(); endwin(); } if ( keystrokes != 0 ) @@ -176,6 +230,7 @@ int rogue(int argc, char **argv, char **envp) rs->seed = atol(argv[1]); else rs->seed = 777; rs->guiflag = 1; + rs->sleeptime = 1; // non-zero to allow refresh() md_init(); #ifdef MASTER @@ -209,14 +264,14 @@ int rogue(int argc, char **argv, char **envp) lowtime = (int) time(NULL); #ifdef MASTER if (wizard && getenv("SEED") != NULL) - dnum = atoi(getenv("SEED")); + rs->seed = atoi(getenv("SEED")); else #endif - dnum = lowtime + md_getpid(); + //dnum = lowtime + md_getpid(); if ( rs != 0 ) seed = rs->seed; else seed = 777; - dnum = (int)seed; + //dnum = (int)seed; open_score(); @@ -242,8 +297,8 @@ int rogue(int argc, char **argv, char **envp) } else if (strcmp(argv[1], "-d") == 0) { - dnum = rnd(100); /* throw away some rnd()s to break patterns */ - while (--dnum) + rs->seed = rnd(100); /* throw away some rnd()s to break patterns */ + while (--rs->seed) rnd(100); purse = rnd(100) + 1; level = rnd(100) + 1; @@ -448,7 +503,8 @@ quit(int sig) clear(); mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse); move(LINES - 1, 0); - refresh(); + if ( rs->sleeptime != 0 ) + refresh(); score(purse, 1, 0); flushkeystrokes(rs); my_exit(0); @@ -459,7 +515,8 @@ quit(int sig) clrtoeol(); status(rs); move(oy, ox); - refresh(); + if ( rs->sleeptime != 0 ) + refresh(); mpos = 0; count = 0; to_death = FALSE; diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 3c500439c..e66362a10 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -313,19 +313,35 @@ /* * Now we define the structures and types */ +struct rogue_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; + +struct rogue_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize; + struct rogue_packitem roguepack[MAXPACK]; +}; + struct rogue_state { uint64_t seed; char *keystrokes; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime; + struct rogue_player P; char buffered[512]; }; +extern struct rogue_state globalR; + int rogue(int argc, char **argv, char **envp); void rogueiterate(struct rogue_state *rs); int32_t roguefname(char *fname,uint64_t seed,int32_t counter); int32_t flushkeystrokes(struct rogue_state *rs); +int32_t rogue_restorepack(struct rogue_state *rs); /* * Help list @@ -476,6 +492,18 @@ struct monster { /* * External variables */ +extern const char *tr_name[],*inv_t_name[]; +extern const int32_t a_class[], e_levels[]; +extern const struct h_list helpstr[]; +extern const char *h_names[],*m_names[]; + + +extern const struct monster origmonsters[26]; +extern const struct room origpassages[MAXPASS]; +extern const struct obj_info origthings[NUMTHINGS],origring_info[MAXRINGS],origpot_info[MAXPOTIONS],origarm_info[MAXARMORS],origscr_info[MAXSCROLLS],origws_info[MAXSTICKS],origweap_info[MAXWEAPONS + 1]; +extern struct monster monsters[26]; +extern struct room passages[MAXPASS]; +extern struct obj_info things[NUMTHINGS],ring_info[MAXRINGS],pot_info[MAXPOTIONS],arm_info[MAXARMORS],scr_info[MAXSCROLLS],weap_info[MAXWEAPONS + 1],ws_info[MAXSTICKS]; extern bool after, again, allscore, amulet, door_stop, fight_flush, firstmove, has_hit, inv_describe, jump, kamikaze, @@ -483,19 +511,18 @@ extern bool after, again, allscore, amulet, door_stop, fight_flush, passgo, playing, q_comm, running, save_msg, see_floor, seenstairs, stat_msg, terse, to_death, tombstone; -extern char dir_ch, file_name[], home[], huh[], *inv_t_name[], +extern char dir_ch, file_name[], home[], huh[], l_last_comm, l_last_dir, last_comm, last_dir, *Numname, - outbuf[], *p_colors[], *r_stones[], *release, runch, - *s_names[], take, *tr_name[], *ws_made[], *ws_type[]; + outbuf[], *release, *s_names[], runch, take; +extern const char *ws_made[], *r_stones[], *p_colors[], *ws_type[]; -extern int a_class[], count, food_left, hungry_state, inpack, +extern int count, food_left, hungry_state, inpack, inv_type, lastscore, level, max_hit, max_level, mpos, n_objs, no_command, no_food, no_move, noscore, ntraps, purse, quiet, vf_hit; extern unsigned int numscores; -extern int dnum, e_levels[]; extern uint64_t seed; extern WINDOW *hw; @@ -507,16 +534,11 @@ extern PLACE places[]; extern THING *cur_armor, *cur_ring[], *cur_weapon, *l_last_pick, *last_pick, *lvl_obj, *mlist, player; -extern struct h_list helpstr[]; -extern struct room *oldrp, passages[], rooms[]; +extern struct room *oldrp, rooms[]; extern struct stats max_stats; -extern struct monster monsters[]; - -extern struct obj_info arm_info[], pot_info[], ring_info[], - scr_info[], things[], ws_info[], weap_info[]; /* * Function types @@ -617,7 +639,7 @@ void money(struct rogue_state *rs,int value); int move_monst(struct rogue_state *rs,THING *tp); void move_msg(struct rogue_state *rs,THING *obj); int msg(struct rogue_state *rs,char *fmt, ...); -void nameit(THING *obj, char *type, char *which, struct obj_info *op, char *(*prfunc)(THING *)); +void nameit(THING *obj, const char *type, const char *which, struct obj_info *op, char *(*prfunc)(THING *)); void new_level(struct rogue_state *rs); void new_monster(struct rogue_state *rs,THING *tp, char type, coord *cp); void numpass(int y, int x); @@ -651,12 +673,12 @@ void ring_off(struct rogue_state *rs); int rnd(int range); int rnd_room(void); int roll(int number, int sides); -int rs_save_file(FILE *savef); +int rs_save_file(struct rogue_state *rs,FILE *savef); int rs_restore_file(FILE *inf); void runto(struct rogue_state *rs,coord *runner); void rust_armor(struct rogue_state *rs,THING *arm); int save(int which); -void save_file(FILE *savef,int32_t guiflag); +void save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag); void save_game(struct rogue_state *rs); int save_throw(int which, THING *tp); void score(int amount, int flags, char monst); @@ -778,13 +800,13 @@ extern int total; extern int between; extern int group; extern coord nh; -extern char *rainbow[]; +extern const char *rainbow[]; extern int cNCOLORS; -extern STONE stones[]; +extern const STONE stones[]; extern int cNSTONES; -extern char *wood[]; +extern const char *wood[]; extern int cNWOOD; -extern char *metal[]; +extern const char *metal[]; extern int cNMETAL; #endif diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index 1dcf3019a..31991b08f 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -37,7 +37,7 @@ do_rooms(struct rogue_state *rs) static coord top; coord bsze; /* maximum room size */ coord mp; - + bsze.x = NUMCOLS / 3; bsze.y = NUMLINES / 3; /* @@ -45,101 +45,101 @@ do_rooms(struct rogue_state *rs) */ for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) { - rp->r_goldval = 0; - rp->r_nexits = 0; - rp->r_flags = 0; + rp->r_goldval = 0; + rp->r_nexits = 0; + rp->r_flags = 0; } /* * Put the gone rooms, if any, on the level */ left_out = rnd(4); for (i = 0; i < left_out; i++) - rooms[rnd_room()].r_flags |= ISGONE; + rooms[rnd_room()].r_flags |= ISGONE; /* * dig and populate all the rooms on the level */ for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++) { - /* - * Find upper left corner of box that this room goes in - */ - top.x = (i % 3) * bsze.x + 1; - top.y = (i / 3) * bsze.y; - if (rp->r_flags & ISGONE) - { - /* - * Place a gone room. Make certain that there is a blank line - * for passage drawing. - */ - do - { - rp->r_pos.x = top.x + rnd(bsze.x - 2) + 1; - rp->r_pos.y = top.y + rnd(bsze.y - 2) + 1; - rp->r_max.x = -NUMCOLS; - rp->r_max.y = -NUMLINES; - } until (rp->r_pos.y > 0 && rp->r_pos.y < NUMLINES-1); - continue; - } - /* - * set room type - */ - if (rnd(10) < level - 1) - { - rp->r_flags |= ISDARK; /* dark room */ - if (rnd(15) == 0) - rp->r_flags = ISMAZE; /* maze room */ - } - /* - * Find a place and size for a random room - */ - if (rp->r_flags & ISMAZE) - { - rp->r_max.x = bsze.x - 1; - rp->r_max.y = bsze.y - 1; - if ((rp->r_pos.x = top.x) == 1) - rp->r_pos.x = 0; - if ((rp->r_pos.y = top.y) == 0) - { - rp->r_pos.y++; - rp->r_max.y--; - } - } - else - do - { - rp->r_max.x = rnd(bsze.x - 4) + 4; - rp->r_max.y = rnd(bsze.y - 4) + 4; - rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x); - rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y); - } until (rp->r_pos.y != 0); - draw_room(rp); - /* - * Put the gold in - */ - if (rnd(2) == 0 && (!amulet || level >= max_level)) - { - THING *gold; - - gold = new_item(); - gold->o_goldval = rp->r_goldval = GOLDCALC; - find_floor(rp, &rp->r_gold, FALSE, FALSE); - gold->o_pos = rp->r_gold; - chat(rp->r_gold.y, rp->r_gold.x) = GOLD; - gold->o_flags = ISMANY; - gold->o_group = GOLDGRP; - gold->o_type = GOLD; - attach(lvl_obj, gold); - } - /* - * Put the monster in - */ - if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25)) - { - tp = new_item(); - find_floor(rp, &mp, FALSE, TRUE); - new_monster(rs,tp, randmonster(FALSE), &mp); - give_pack(rs,tp); - } + /* + * Find upper left corner of box that this room goes in + */ + top.x = (i % 3) * bsze.x + 1; + top.y = (i / 3) * bsze.y; + if (rp->r_flags & ISGONE) + { + /* + * Place a gone room. Make certain that there is a blank line + * for passage drawing. + */ + do + { + rp->r_pos.x = top.x + rnd(bsze.x - 2) + 1; + rp->r_pos.y = top.y + rnd(bsze.y - 2) + 1; + rp->r_max.x = -NUMCOLS; + rp->r_max.y = -NUMLINES; + } until (rp->r_pos.y > 0 && rp->r_pos.y < NUMLINES-1); + continue; + } + /* + * set room type + */ + if (rnd(10) < level - 1) + { + rp->r_flags |= ISDARK; /* dark room */ + if (rnd(15) == 0) + rp->r_flags = ISMAZE; /* maze room */ + } + /* + * Find a place and size for a random room + */ + if (rp->r_flags & ISMAZE) + { + rp->r_max.x = bsze.x - 1; + rp->r_max.y = bsze.y - 1; + if ((rp->r_pos.x = top.x) == 1) + rp->r_pos.x = 0; + if ((rp->r_pos.y = top.y) == 0) + { + rp->r_pos.y++; + rp->r_max.y--; + } + } + else + do + { + rp->r_max.x = rnd(bsze.x - 4) + 4; + rp->r_max.y = rnd(bsze.y - 4) + 4; + rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x); + rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y); + } until (rp->r_pos.y != 0); + draw_room(rp); + /* + * Put the gold in + */ + if (rnd(2) == 0 && (!amulet || level >= max_level)) + { + THING *gold; + + gold = new_item(); + gold->o_goldval = rp->r_goldval = GOLDCALC; + find_floor(rp, &rp->r_gold, FALSE, FALSE); + gold->o_pos = rp->r_gold; + chat(rp->r_gold.y, rp->r_gold.x) = GOLD; + gold->o_flags = ISMANY; + gold->o_group = GOLDGRP; + gold->o_type = GOLD; + attach(lvl_obj, gold); + } + /* + * Put the monster in + */ + if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25)) + { + tp = new_item(); + find_floor(rp, &mp, FALSE, TRUE); + new_monster(rs,tp, randmonster(FALSE), &mp); + give_pack(rs,tp); + } } } diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 8dcb65194..eec85b930 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -64,7 +64,8 @@ over: if (c == 'y' || c == 'Y') { addstr("Yes\n"); - refresh(); + if ( rs->sleeptime != 0 ) + refresh(); strcpy(buf, file_name); goto gotfile; } @@ -109,7 +110,7 @@ gotfile: msg(rs,strerror(errno)); } while (savef == NULL); - save_file(savef,1); + save_file(rs,savef,1); /* NOTREACHED */ } @@ -128,7 +129,7 @@ auto_save(int sig) md_ignoreallsignals(); if (file_name[0] != '\0' && ((savef = fopen(file_name, "w")) != NULL || (md_unlink_open_file(file_name, savef) >= 0 && (savef = fopen(file_name, "w")) != NULL))) - save_file(savef,1); + save_file(&globalR,savef,1); exit(0); } @@ -137,10 +138,17 @@ auto_save(int sig) * Write the saved game on the file */ -void -save_file(FILE *savef,int32_t guiflag) +char *rogue_packfname(struct rogue_state *rs,char *fname) { - char buf[80]; + sprintf(fname,"rogue.%llu.pack",(long long)rs->seed); + return(fname); +} + +void +save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) +{ + char buf[80],fname[512]; int32_t i,n,nonz,histo[0x100]; FILE *fp; + memset(&rs->P,0,sizeof(rs->P)); mvcur(0, COLS - 1, LINES - 1, 0); putchar('\n'); endwin(); @@ -152,13 +160,53 @@ save_file(FILE *savef,int32_t guiflag) sprintf(buf,"%d x %d\n", LINES, COLS); encwrite(buf,80,savef); } - rs_save_file(savef); + rs_save_file(rs,savef); + n = sizeof(rs->P) - sizeof(rs->P.roguepack) + sizeof(rs->P.roguepack[0])*rs->P.packsize; + memset(histo,0,sizeof(histo)); + for (i=0; iP)[i]); + histo[((uint8_t *)&rs->P)[i]]++; + } + fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n); + if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 ) + { + fwrite(&rs->P,1,n,fp); + fclose(fp); + } + for (i=nonz=0; i<0x100; i++) + if ( histo[i] != 0 ) + fprintf(stderr,"(%d %d) ",i,histo[i]), nonz++; + fprintf(stderr,"nonz.%d\n",nonz); fflush(savef); fclose(savef); if ( guiflag != 0 ) exit(0); } +int32_t rogue_restorepack(struct rogue_state *rs) +{ + FILE *fp; char fname[512]; int32_t retflag = -1; + memset(&rs->P,0,sizeof(rs->P)); + if ( (fp= fopen(rogue_packfname(rs,fname),"rb")) != 0 ) + { + if ( fread(&rs->P,1,sizeof(rs->P) - sizeof(rs->P.roguepack),fp) == sizeof(rs->P) - sizeof(rs->P.roguepack) ) + { + if ( rs->P.packsize > 0 && rs->P.packsize <= MAXPACK ) + { + if ( fread(&rs->P.roguepack,1,rs->P.packsize*sizeof(rs->P.roguepack[0]),fp) == rs->P.packsize*sizeof(rs->P.roguepack[0]) ) + { + fprintf(stderr,"roguepack[%d] restored\n",rs->P.packsize); + retflag = 0; + } + } + } + } + if ( retflag < 0 ) + memset(&rs->P,0,sizeof(rs->P)); + return(retflag); +} + /* * restore: * Restore a saved game from a file with elaborate checks for file diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index f18ee1e5f..d99f1b0dc 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -97,7 +97,7 @@ rs_read(FILE *inf, void *ptr, size_t size) } int -rs_write_int(FILE *savef, int c) +rs_write_int(FILE *savef, int32_t c) { unsigned char bytes[4]; unsigned char *buf = (unsigned char *) &c; @@ -120,7 +120,7 @@ rs_write_int(FILE *savef, int c) } int -rs_read_int(FILE *inf, int *i) +rs_read_int(FILE *inf, int32_t *i) { unsigned char bytes[4]; int input = 0; @@ -198,7 +198,7 @@ rs_read_chars(FILE *inf, char *i, int count) } int -rs_write_ints(FILE *savef, int *c, int count) +rs_write_ints(FILE *savef, int32_t *c, int count) { int n = 0; @@ -215,7 +215,7 @@ rs_write_ints(FILE *savef, int *c, int count) } int -rs_read_ints(FILE *inf, int *i, int count) +rs_read_ints(FILE *inf, int32_t *i, int count) { int n, value; @@ -300,7 +300,7 @@ rs_read_booleans(FILE *inf, bool *i, int count) } int -rs_write_short(FILE *savef, short c) +rs_write_short(FILE *savef, int16_t c) { unsigned char bytes[2]; unsigned char *buf = (unsigned char *) &c; @@ -321,7 +321,7 @@ rs_write_short(FILE *savef, short c) } int -rs_read_short(FILE *inf, short *i) +rs_read_short(FILE *inf, int16_t *i) { unsigned char bytes[2]; short input; @@ -345,7 +345,7 @@ rs_read_short(FILE *inf, short *i) } int -rs_write_shorts(FILE *savef, short *c, int count) +rs_write_shorts(FILE *savef, int16_t *c, int count) { int n = 0; @@ -362,7 +362,7 @@ rs_write_shorts(FILE *savef, short *c, int count) } int -rs_read_shorts(FILE *inf, short *i, int count) +rs_read_shorts(FILE *inf, int16_t *i, int count) { int n = 0, value = 0; @@ -382,7 +382,7 @@ rs_read_shorts(FILE *inf, short *i, int count) } int -rs_write_ushort(FILE *savef, unsigned short c) +rs_write_ushort(FILE *savef, uint16_t c) { unsigned char bytes[2]; unsigned char *buf = (unsigned char *) &c; @@ -403,7 +403,7 @@ rs_write_ushort(FILE *savef, unsigned short c) } int -rs_read_ushort(FILE *inf, unsigned short *i) +rs_read_ushort(FILE *inf, uint16_t *i) { unsigned char bytes[2]; unsigned short input; @@ -427,7 +427,7 @@ rs_read_ushort(FILE *inf, unsigned short *i) } int -rs_write_uint(FILE *savef, unsigned int c) +rs_write_uint(FILE *savef, uint32_t c) { unsigned char bytes[4]; unsigned char *buf = (unsigned char *) &c; @@ -450,7 +450,7 @@ rs_write_uint(FILE *savef, unsigned int c) } int -rs_read_uint(FILE *inf, unsigned int *i) +rs_read_uint(FILE *inf, uint32_t *i) { unsigned char bytes[4]; int input; @@ -476,7 +476,7 @@ rs_read_uint(FILE *inf, unsigned int *i) } int -rs_write_marker(FILE *savef, int id) +rs_write_marker(FILE *savef, int32_t id) { if (write_error) return(WRITESTAT); @@ -487,7 +487,7 @@ rs_write_marker(FILE *savef, int id) } int -rs_read_marker(FILE *inf, int id) +rs_read_marker(FILE *inf, int32_t id) { int nid; @@ -891,7 +891,7 @@ rs_write_scrolls(FILE *savef) return(WRITESTAT); for(i = 0; i < MAXSCROLLS; i++) - rs_write_string(savef, s_names[i]); + rs_write_string(savef, (char *)s_names[i]); return(READSTAT); } @@ -905,7 +905,7 @@ rs_read_scrolls(FILE *inf) return(READSTAT); for(i = 0; i < MAXSCROLLS; i++) - rs_read_new_string(inf, &s_names[i]); + rs_read_new_string(inf, (char **)&s_names[i]); return(READSTAT); } @@ -919,7 +919,7 @@ rs_write_potions(FILE *savef) return(WRITESTAT); for(i = 0; i < MAXPOTIONS; i++) - rs_write_string_index(savef, rainbow, cNCOLORS, p_colors[i]); + rs_write_string_index(savef, (char **)rainbow, cNCOLORS, (char *)p_colors[i]); return(WRITESTAT); } @@ -933,7 +933,7 @@ rs_read_potions(FILE *inf) return(READSTAT); for(i = 0; i < MAXPOTIONS; i++) - rs_read_string_index(inf, rainbow, cNCOLORS, &p_colors[i]); + rs_read_string_index(inf, (char **)rainbow, cNCOLORS, (char **)&p_colors[i]); return(READSTAT); } @@ -947,7 +947,7 @@ rs_write_rings(FILE *savef) return(WRITESTAT); for(i = 0; i < MAXRINGS; i++) - rs_write_stone_index(savef, stones, cNSTONES, r_stones[i]); + rs_write_stone_index(savef, (STONE *)stones, cNSTONES, (char *)r_stones[i]); return(WRITESTAT); } @@ -961,7 +961,7 @@ rs_read_rings(FILE *inf) return(READSTAT); for(i = 0; i < MAXRINGS; i++) - rs_read_stone_index(inf, stones, cNSTONES, &r_stones[i]); + rs_read_stone_index(inf, (STONE *)stones, cNSTONES, (char **)&r_stones[i]); return(READSTAT); } @@ -979,12 +979,12 @@ rs_write_sticks(FILE *savef) if (strcmp(ws_type[i],"staff") == 0) { rs_write_int(savef,0); - rs_write_string_index(savef, wood, cNWOOD, ws_made[i]); + rs_write_string_index(savef, (char **)wood, cNWOOD, (char *)ws_made[i]); } else { rs_write_int(savef,1); - rs_write_string_index(savef, metal, cNMETAL, ws_made[i]); + rs_write_string_index(savef, (char **)metal, cNMETAL, (char *)ws_made[i]); } } @@ -1005,12 +1005,12 @@ rs_read_sticks(FILE *inf) if (list == 0) { - rs_read_string_index(inf, wood, cNWOOD, &ws_made[i]); + rs_read_string_index(inf, (char **)wood, cNWOOD, (char **)&ws_made[i]); ws_type[i] = "staff"; } else { - rs_read_string_index(inf, metal, cNMETAL, &ws_made[i]); + rs_read_string_index(inf, (char **)metal, cNMETAL, (char **)&ws_made[i]); ws_type[i] = "wand"; } } @@ -1336,13 +1336,65 @@ rs_read_monsters(FILE *inf, struct monster *m, int count) return(READSTAT); } -int -rs_write_object(FILE *savef, THING *o) +void rogue_restoreobject(THING *o,struct rogue_packitem *item) { + o->_o._o_type = item->type; + o->_o._o_launch = item->launch; + memcpy(o->_o._o_damage,item->damage,sizeof(item->damage)); + memcpy(o->_o._o_hurldmg,item->hurldmg,sizeof(item->hurldmg)); + o->_o._o_count = item->count; + o->_o._o_which = item->which; + o->_o._o_hplus = item->hplus; + o->_o._o_dplus = item->dplus; + o->_o._o_arm = item->arm; + o->_o._o_flags = item->flags; + o->_o._o_group = item->group; +} + +int32_t packsave(struct rogue_packitem *item,int32_t type,int32_t launch,char *damage,int32_t damagesize,char *hurldmg,int32_t hurlsize,int32_t count,int32_t which,int32_t hplus,int32_t dplus,int32_t arm,int32_t flags,int32_t group) +{ + if ( damagesize != 8 || hurlsize != 8 ) + { + fprintf(stderr,"unexpected damagesize.%d or hurlsize.%d != 8\n",damagesize,hurlsize); + return(-1); + } + item->type = type; + item->launch = launch; + memcpy(item->damage,damage,damagesize); + memcpy(item->hurldmg,hurldmg,hurlsize); + item->count = count; + item->which = which; + item->hplus = hplus; + item->dplus = dplus; + item->arm = arm; + item->flags = flags; + item->group = group; + return(0); +} + +int +rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) +{ + struct rogue_packitem *item; if (write_error) return(WRITESTAT); - //fprintf(stderr,"object %ld -> ",ftell(savef)); - + if ( o->_o._o_packch != 0 ) + { + item = &rs->P.roguepack[rs->P.packsize]; + if ( rs->P.packsize++ == 0 ) + { + rs->P.gold = purse; + rs->P.hitpoints = max_hp; + rs->P.strength = max_stats.s_str; + rs->P.level = pstats.s_lvl; + rs->P.experience = pstats.s_exp; + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp); + }; + fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); + if ( rs->P.packsize < MAXPACK ) + packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); + } + rs_write_marker(savef, RSID_OBJECT); rs_write_int(savef, o->_o._o_type); rs_write_coord(savef, o->_o._o_pos); @@ -1358,7 +1410,6 @@ rs_write_object(FILE *savef, THING *o) rs_write_int(savef, o->_o._o_flags); rs_write_int(savef, o->_o._o_group); rs_write_string(savef, o->_o._o_label); - //fprintf(stderr,"%ld\n",ftell(savef)); return(WRITESTAT); } @@ -1388,7 +1439,7 @@ rs_read_object(FILE *inf, THING *o) } int -rs_write_object_list(FILE *savef, THING *l) +rs_write_object_list(struct rogue_state *rs,FILE *savef, THING *l) { if (write_error) return(WRITESTAT); @@ -1398,7 +1449,7 @@ rs_write_object_list(FILE *savef, THING *l) rs_write_int(savef, list_size(l)); for( ;l != NULL; l = l->l_next) - rs_write_object(savef, l); + rs_write_object(rs,savef, l); //fprintf(stderr,"%ld\n",ftell(savef)); return(WRITESTAT); @@ -1526,7 +1577,7 @@ find_object_coord(THING *objlist, coord *c) } int -rs_write_thing(FILE *savef, THING *t) +rs_write_thing(struct rogue_state *rs,FILE *savef, THING *t) { int i = -1; @@ -1610,7 +1661,7 @@ rs_write_thing(FILE *savef, THING *t) rs_write_short(savef, t->_t._t_flags); rs_write_stats(savef, &t->_t._t_stats); rs_write_room_reference(savef, t->_t._t_room); - rs_write_object_list(savef, t->_t._t_pack); + rs_write_object_list(rs,savef, t->_t._t_pack); //fprintf(stderr,"%ld\n",ftell(savef)); return(WRITESTAT); @@ -1712,7 +1763,7 @@ rs_fix_thing(THING *t) } int -rs_write_thing_list(FILE *savef, THING *l) +rs_write_thing_list(struct rogue_state *rs,FILE *savef, THING *l) { int cnt = 0; @@ -1729,7 +1780,7 @@ rs_write_thing_list(FILE *savef, THING *l) return(WRITESTAT); while (l != NULL) { - rs_write_thing(savef, l); + rs_write_thing(rs,savef, l); l = l->l_next; } @@ -1888,7 +1939,7 @@ rs_read_places(FILE *inf, PLACE *places, int count) } int -rs_save_file(FILE *savef) +rs_save_file(struct rogue_state *rs,FILE *savef) { if (write_error) return(WRITESTAT); @@ -1941,12 +1992,12 @@ rs_save_file(FILE *savef) rs_write_int(savef,orig_dsusp); rs_write_chars(savef, fruit, MAXSTR); //rs_write_chars(savef, home, MAXSTR); - rs_write_strings(savef,inv_t_name,3); + rs_write_strings(savef,(char **)inv_t_name,3); rs_write_char(savef,l_last_comm); rs_write_char(savef,l_last_dir); rs_write_char(savef,last_comm); rs_write_char(savef,last_dir); - rs_write_strings(savef,tr_name,8); + rs_write_strings(savef,(char **)tr_name,8); rs_write_int(savef,n_objs); rs_write_int(savef, ntraps); rs_write_int(savef, hungry_state); @@ -1956,7 +2007,7 @@ rs_save_file(FILE *savef) rs_write_int(savef, max_level); rs_write_int(savef, mpos); rs_write_int(savef, no_food); - rs_write_ints(savef,a_class,MAXARMORS); + rs_write_ints(savef,(int32_t *)a_class,MAXARMORS); rs_write_int(savef, count); rs_write_int(savef, food_left); rs_write_int(savef, lastscore); @@ -1968,11 +2019,11 @@ rs_save_file(FILE *savef) //rs_write_int(savef, dnum); rs_write_int(savef, (int32_t)(seed&0xffffffff)); rs_write_int(savef, (int32_t)((seed>>32)&0xffffffff)); - rs_write_ints(savef, e_levels, 21); + rs_write_ints(savef, (int32_t *)e_levels, 21); rs_write_coord(savef, delta); rs_write_coord(savef, oldpos); rs_write_coord(savef, stairs); - rs_write_thing(savef, &player); + rs_write_thing(rs,savef, &player); rs_write_object_reference(savef, player.t_pack, cur_armor); rs_write_object_reference(savef, player.t_pack, cur_ring[0]); rs_write_object_reference(savef, player.t_pack, cur_ring[1]); @@ -1980,8 +2031,8 @@ rs_save_file(FILE *savef) rs_write_object_reference(savef, player.t_pack, l_last_pick); rs_write_object_reference(savef, player.t_pack, last_pick); - rs_write_object_list(savef, lvl_obj); - rs_write_thing_list(savef, mlist); + rs_write_object_list(rs,savef, lvl_obj); + rs_write_thing_list(rs,savef, mlist); rs_write_places(savef,places,MAXLINES*MAXCOLS); @@ -2073,12 +2124,12 @@ rs_restore_file(FILE *inf) rs_read_int(inf,&orig_dsusp); rs_read_chars(inf, fruit, MAXSTR); //rs_read_chars(inf, home, MAXSTR); - rs_read_new_strings(inf,inv_t_name,3); + rs_read_new_strings(inf,(char **)inv_t_name,3); rs_read_char(inf, &l_last_comm); rs_read_char(inf, &l_last_dir); rs_read_char(inf, &last_comm); rs_read_char(inf, &last_dir); - rs_read_new_strings(inf,tr_name,8); + rs_read_new_strings(inf,(char **)tr_name,8); rs_read_int(inf, &n_objs); rs_read_int(inf, &ntraps); rs_read_int(inf, &hungry_state); @@ -2088,7 +2139,7 @@ rs_restore_file(FILE *inf) rs_read_int(inf, &max_level); rs_read_int(inf, &mpos); rs_read_int(inf, &no_food); - rs_read_ints(inf,a_class,MAXARMORS); + rs_read_ints(inf,(int32_t *)a_class,MAXARMORS); rs_read_int(inf, &count); rs_read_int(inf, &food_left); rs_read_int(inf, &lastscore); @@ -2102,7 +2153,7 @@ rs_restore_file(FILE *inf) rs_read_int(inf, &lownum); rs_read_int(inf, &highnum); seed = ((uint64_t)highnum<<32) | (lownum&0xffffffff); - rs_read_ints(inf,e_levels,21); + rs_read_ints(inf,(int32_t *)e_levels,21); rs_read_coord(inf, &delta); rs_read_coord(inf, &oldpos); rs_read_coord(inf, &stairs); diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index 7b01fe34c..7f9dc6ec2 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -405,7 +405,8 @@ def: msg(rs,"the %s whizzes by you", name); } mvaddch(pos.y, pos.x, dirch); - refresh(); + if ( rs->sleeptime != 0 ) + refresh(); } } for (c2 = spotpos; c2 < c1; c2++) diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 2247c67e8..660e0720e 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -220,6 +220,7 @@ new_thing(struct rogue_state *rs) int r; cur = new_item(); + // 7th new_thing orphaned fprintf(stderr,"new_thing.%p\n",cur); cur->o_hplus = 0; cur->o_dplus = 0; strncpy(cur->o_damage, "0x0", sizeof(cur->o_damage)); @@ -499,7 +500,8 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) if (inv_type == INV_OVER && fmt == NULL && !newpage) { msg(rs,""); - refresh(); + if ( rs->sleeptime != 0 ) + refresh(); tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); for (y = 0; y <= line_cnt; y++) @@ -615,7 +617,7 @@ nothing(char type) */ void -nameit(THING *obj, char *type, char *which, struct obj_info *op, +nameit(THING *obj, const char *type,const char *which, struct obj_info *op, char *(*prfunc)(THING *)) { char *pb; @@ -633,7 +635,7 @@ nameit(THING *obj, char *type, char *which, struct obj_info *op, sprintf(pb, "called %s%s(%s)", op->oi_guess, (*prfunc)(obj), which); } else if (obj->o_count == 1) - sprintf(prbuf, "A%s %s %s", vowelstr(which), which, type); + sprintf(prbuf, "A%s %s %s", vowelstr((char *)which), which, type); else sprintf(prbuf, "%d %s %ss", obj->o_count, which, type); } diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 51a4b7730..6693f0814 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -105,7 +105,8 @@ do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta) if (cansee(rs,unc(obj->o_pos)) && !terse) { mvaddch(obj->o_pos.y, obj->o_pos.x, obj->o_type); - refresh(); + if ( rs->sleeptime != 0 ) + refresh(); } continue; } @@ -161,7 +162,6 @@ void init_weapon(THING *weap, int which) { struct init_weaps *iwp; - weap->o_type = WEAPON; weap->o_which = which; iwp = &init_dam[which]; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 499b4d48c..b5538d87a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -71,9 +71,9 @@ //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & -// cclib newgame 17 \"[maxplayers,buyin]\" +// cclib newgame 17 \"[3,100]\" // cclib pending 17 -// cclib txidinfo 17 \"[%2235e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f%22]\" +// cclib gameinfo 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22]\" // ./rogue gui -> creates keystroke files // cclib register 17 \"[%2235e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f%22,%22%22]\" // cclib keystrokes 17 \"[]\" @@ -452,8 +452,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( n > 0 ) { UniValue pobj(UniValue::VOBJ); - t = jbits256(jitem(params,0),0); - memcpy(&playertxid,&t,sizeof(playertxid));; + playertxid = juint256(jitem(params,0)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); result.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); @@ -481,14 +480,12 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( n > 0 ) { - t = jbits256(jitem(params,0),0); - memcpy(&gametxid,&t,sizeof(gametxid)); + gametxid = juint256(jitem(params,0)); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { if ( n > 1 && maxplayers > 1 ) { - t = jbits256(jitem(params,0),0); - memcpy(&playertxid,&t,sizeof(playertxid)); + playertxid = juint256(jitem(params,1)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); } @@ -522,8 +519,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param rogue_univalue(result,"keystrokes",-1,-1); if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { - t = jbits256(jitem(params,0),0); - memcpy(&gametxid,&t,sizeof(gametxid)); + gametxid = juint256(jitem(params,0)); keystrokes = ParseHex(keystrokestr); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); @@ -588,8 +584,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( n > 0 ) { - t = jbits256(jitem(params,0),0); - memcpy(&txid,&t,sizeof(txid)); + txid = juint256(jitem(params,0)); result.push_back(Pair("txid",txid.GetHex())); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) { From afc2af57d59fdf795f35fae029c2b76aa7c0d2d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 21:11:29 -1100 Subject: [PATCH 1793/3904] Txid for gameinfo --- src/cc/rogue_rpc.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b5538d87a..3470a36c7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -74,6 +74,7 @@ // cclib newgame 17 \"[3,100]\" // cclib pending 17 // cclib gameinfo 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22]\" +// cclib register 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22]\" // ./rogue gui -> creates keystroke files // cclib register 17 \"[%2235e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f%22,%22%22]\" // cclib keystrokes 17 \"[]\" @@ -172,10 +173,10 @@ void rogue_univalue(UniValue &result,const char *method,int64_t maxplayers,int64 } } -void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin) +void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 txid) { CBlockIndex *pindex; int32_t ht; uint256 hashBlock; uint64_t seed; char cmd[512]; - if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + if ( (pindex= komodo_blockindex(txid)) != 0 ) { ht = pindex->GetHeight(); obj.push_back(Pair("height",ht)); @@ -409,7 +410,7 @@ UniValue rogue_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0,amount = 0; int32_t i,n,maxplayers = 1; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1; if ( txfee == 0 ) txfee = 10000; if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -435,7 +436,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,ROGUE_REGISTRATIONSIZE,roguepk,roguepk)); if ( (change= inputsum - required) >= txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,roguepk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(amount,maxplayers)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(buyin,maxplayers)); return(rogue_rawtxresult(result,rawtx,0)); } else return(cclib_error(result,"illegal maxplayers")); @@ -589,7 +590,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) { result.push_back(Pair("result","success")); - rogue_gamefields(result,maxplayers,buyin); + rogue_gamefields(result,maxplayers,buyin,txid); for (i=0; i Date: Tue, 5 Feb 2019 21:13:36 -1100 Subject: [PATCH 1794/3904] Get hashBlock --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3470a36c7..0c9b9d70a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -175,8 +175,8 @@ void rogue_univalue(UniValue &result,const char *method,int64_t maxplayers,int64 void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 txid) { - CBlockIndex *pindex; int32_t ht; uint256 hashBlock; uint64_t seed; char cmd[512]; - if ( (pindex= komodo_blockindex(txid)) != 0 ) + CBlockIndex *pindex; int32_t ht; uint256 hashBlock; uint64_t seed; char cmd[512]; CTransaction tx; + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); obj.push_back(Pair("height",ht)); From 2fcf3f3f0f7c05a7fa285b22f90ffab140f1be43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 21:29:18 -1100 Subject: [PATCH 1795/3904] 1of2 signing --- src/cc/CCinclude.h | 4 ++-- src/cc/CCtx.cpp | 2 +- src/cc/CCutils.cpp | 5 +++-- src/cc/channels.cpp | 2 +- src/cc/heir_validate.h | 7 +++++-- src/cc/marmara.cpp | 4 +++- src/cc/rogue_rpc.cpp | 17 +++++++++++++---- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 52f2d7c1f..bc5ed20ed 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -95,7 +95,7 @@ struct CCcontract_info // this for 1of2 keys coins cryptocondition (for this evalcode) // NOTE: only one evalcode is allowed at this time char coins1of2addr[64]; - CPubKey coins1of2pk[2]; + CPubKey coins1of2pk[2]; uint8_t coins1of2priv[32]; // the same for tokens 1of2 keys cc char tokens1of2addr[64]; @@ -195,7 +195,7 @@ CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2); CC* GetCryptoCondition(CScript const& scriptSig); void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); -void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); +void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2,uint8_t *priv,char *coinaddr); CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 630c887f0..932677e20 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -207,7 +207,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else if (strcmp(cp->coins1of2addr, destaddr) == 0) { //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); - privkey = myprivkey; + privkey = cp->coins1of2priv;//myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); cond = othercond1of2; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 6dff5d3cd..88231fcd9 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -244,11 +244,12 @@ void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t * } // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 cryptocondition vout: -void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2,uint8_t *priv,char *coinaddr) { cp->coins1of2pk[0] = pk1; cp->coins1of2pk[1] = pk2; - strcpy(cp->coins1of2addr, coinaddr); + memcpy(cp->coins1of2priv,priv,32); + strcpy(cp->coins1of2addr,coinaddr); } // set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 tokens cryptocondition vout: diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index e6f4b48c6..ca069ee57 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -455,7 +455,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C mtx.vin.push_back(CTxIn(txid,marker,CScript())); Myprivkey(myprivkey); if (tokenid!=zeroid) CCaddrTokens1of2set(cp,srcpub,destpub,coinaddr); - else CCaddr1of2set(cp,srcpub,destpub,coinaddr); + else CCaddr1of2set(cp,srcpub,destpub,myprivkey,coinaddr); return totalinputs; } else return 0; diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 15ab133e4..890e2b710 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -51,8 +51,11 @@ public: cpHeir = CCinit(&heirC, EVAL_HEIR); return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey); } - static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) { - CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr); + static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) + { + uint8_t mypriv[32]; + Myprivkey(mypriv); + CCaddr1of2set(cp, ownerPubkey, heirPubkey,mypriv, coinaddr); } }; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 8bb306d9b..f43f3a559 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -455,7 +455,9 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); SetCCunspents(unspentOutputs,coinaddr); threshold = remains / (MARMARA_VINS+1); - CCaddr1of2set(cp,Marmarapk,mypk,coinaddr); + uint8_t mypriv[32]; + Myprivkey(mypriv); + CCaddr1of2set(cp,Marmarapk,mypk,mypriv,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0c9b9d70a..9ef8e7814 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -173,10 +173,15 @@ void rogue_univalue(UniValue &result,const char *method,int64_t maxplayers,int64 } } -void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 txid) +int32_t rogue_iamregistered(CTransaction tx) +{ + return(0); +} + +void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid) { CBlockIndex *pindex; int32_t ht; uint256 hashBlock; uint64_t seed; char cmd[512]; CTransaction tx; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + if ( GetTransaction(gametxid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); obj.push_back(Pair("height",ht)); @@ -190,7 +195,9 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 txi memcpy(&seed,&hashBlock,sizeof(seed)); seed &= (1LL << 62) - 1; obj.push_back(Pair("seed",(int64_t)seed)); - sprintf(cmd,"./rogue %llu gui",(long long)seed); + if ( rogue_iamregistered(tx) > 0 ) + sprintf(cmd,"./rogue %llu gui",(long long)seed); + else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register \\\"[%22%s%22]\\\" %d",ASSETCHAINS_SYMBOL,gametxid.ToString().c_str(),EVAL_ROGUE); obj.push_back(Pair("run",cmd)); } } @@ -470,7 +477,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -498,6 +505,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,inputsum-txfee,roguepk,mypk)); + GetCCaddress1of2(cp,destaddr,roguepk,roguepk); + CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_registeropret(gametxid,playertxid)); return(rogue_rawtxresult(result,rawtx,0)); } else return(cclib_error(result,"invalid gametxid")); From 0314166aebe24921267ea8d40ccedfcbf86157f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 21:31:03 -1100 Subject: [PATCH 1796/3904] %% --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9ef8e7814..89e2f451e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -197,7 +197,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam obj.push_back(Pair("seed",(int64_t)seed)); if ( rogue_iamregistered(tx) > 0 ) sprintf(cmd,"./rogue %llu gui",(long long)seed); - else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register \\\"[%22%s%22]\\\" %d",ASSETCHAINS_SYMBOL,gametxid.ToString().c_str(),EVAL_ROGUE); + else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register \\\"[%%22%s%%22]\\\" %d",ASSETCHAINS_SYMBOL,gametxid.ToString().c_str(),EVAL_ROGUE); obj.push_back(Pair("run",cmd)); } } From 06260a75e9aadf49ffdb37be49dde3f15be1b365 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 21:47:57 -1100 Subject: [PATCH 1797/3904] Fast registration for single player --- src/cc/rogue_rpc.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 89e2f451e..3d487d456 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -180,15 +180,16 @@ int32_t rogue_iamregistered(CTransaction tx) void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid) { - CBlockIndex *pindex; int32_t ht; uint256 hashBlock; uint64_t seed; char cmd[512]; CTransaction tx; + CBlockIndex *pindex; int32_t ht,delay; uint256 hashBlock; uint64_t seed; char cmd[512]; CTransaction tx; if ( GetTransaction(gametxid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); + delay = ROGUE_REGISTRATION * (maxplayers > 1); obj.push_back(Pair("height",ht)); - obj.push_back(Pair("start",ht+ROGUE_REGISTRATION)); - if ( komodo_nextheight() > ht+ROGUE_REGISTRATION ) + obj.push_back(Pair("start",ht+delay)); + if ( komodo_nextheight() > ht+delay ) { - if ( (pindex= komodo_chainactive(ht+ROGUE_REGISTRATION)) != 0 ) + if ( (pindex= komodo_chainactive(ht+delay)) != 0 ) { hashBlock = pindex->GetBlockHash(); obj.push_back(Pair("starthash",hashBlock.ToString())); @@ -197,7 +198,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam obj.push_back(Pair("seed",(int64_t)seed)); if ( rogue_iamregistered(tx) > 0 ) sprintf(cmd,"./rogue %llu gui",(long long)seed); - else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register \\\"[%%22%s%%22]\\\" %d",ASSETCHAINS_SYMBOL,gametxid.ToString().c_str(),EVAL_ROGUE); + else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,gametxid.ToString().c_str(),EVAL_ROGUE); obj.push_back(Pair("run",cmd)); } } @@ -602,7 +603,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) rogue_gamefields(result,maxplayers,buyin,txid); for (i=0; i Date: Tue, 5 Feb 2019 21:49:25 -1100 Subject: [PATCH 1798/3904] Switch order --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3d487d456..b59efef81 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -198,7 +198,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam obj.push_back(Pair("seed",(int64_t)seed)); if ( rogue_iamregistered(tx) > 0 ) sprintf(cmd,"./rogue %llu gui",(long long)seed); - else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,gametxid.ToString().c_str(),EVAL_ROGUE); + else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str()); obj.push_back(Pair("run",cmd)); } } From 7c4b531e65f5a30b24a3d0c89242579889b88c65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 21:51:07 -1100 Subject: [PATCH 1799/3904] Offset by 2 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b59efef81..0770edd72 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -387,7 +387,7 @@ int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTrans r = rand() % maxplayers; for (j=0; j Date: Wed, 6 Feb 2019 17:00:21 +0800 Subject: [PATCH 1800/3904] Check for double signs on notarisation checks. revert minsigs to normal value. --- src/komodo_bitcoind.h | 6 ++++++ src/miner.cpp | 9 ++++++++- src/rpc/misc.cpp | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a40a174b1..a476e70e5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1886,6 +1886,12 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } } } + // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) + std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); + if ( checkdupes.size() != NotarisationNotaries.size() ) { + fprintf(stderr, "Possible notarisation is signed multiple times by same notary. It is invalid.\n"); + return(0); + } const CChainParams& chainparams = Params(); const Consensus::Params &consensusParams = chainparams.GetConsensus(); uint64_t totalsats = 0; diff --git a/src/miner.cpp b/src/miner.cpp index 10bdb643f..e3eb8d262 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -367,7 +367,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 dPriority += (double)nValueIn * nConf; } if ( numSN != 0 && numNotaryVins >= numSN / 5 ) - fNotarisation = true; + { + // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) + std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); + if ( checkdupes.size() != NotarisationNotaries.size() ) { + NotarisationNotaries.clear(); + fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); + } else fNotarisation = true; + } else NotarisationNotaries.clear(); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 1e0e33c27..b60809da1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -128,8 +128,8 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) json.push_back(Pair("port",iguanaPort)); json.push_back(Pair("BTCminsigs",BTCminsigs)); - json.push_back(Pair("minsigs",2)); - json.push_back(Pair("seeds", seeds)); + json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("seeds",seeds)); json.push_back(Pair("notaries",notaries)); return json; } From 8d3e3a72a8ee747b8fa64554d08bcb49f819a97c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 22:06:47 -1100 Subject: [PATCH 1801/3904] +prints --- src/cc/rogue_rpc.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0770edd72..5a1721018 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -173,12 +173,12 @@ void rogue_univalue(UniValue &result,const char *method,int64_t maxplayers,int64 } } -int32_t rogue_iamregistered(CTransaction tx) +int32_t rogue_iamregistered(CTransaction tx,char *myrogueaddr) { return(0); } -void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid) +void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) { CBlockIndex *pindex; int32_t ht,delay; uint256 hashBlock; uint64_t seed; char cmd[512]; CTransaction tx; if ( GetTransaction(gametxid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) @@ -196,7 +196,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam memcpy(&seed,&hashBlock,sizeof(seed)); seed &= (1LL << 62) - 1; obj.push_back(Pair("seed",(int64_t)seed)); - if ( rogue_iamregistered(tx) > 0 ) + if ( rogue_iamregistered(tx,myrogueaddr) > 0 ) sprintf(cmd,"./rogue %llu gui",(long long)seed); else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str()); obj.push_back(Pair("run",cmd)); @@ -315,18 +315,20 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd { matches++; matchtx = spenttx; - } - } - } + } else fprintf(stderr,"%d+2 doesnt match scriptPubKey\n",i); + } else fprintf(stderr,"%d+2 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } else fprintf(stderr,"%d+2 unspent\n",i); } if ( matches == 1 ) { numvouts = matchtx.vout.size(); + fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { txid = spenttxid; + fprintf(stderr,"scan forward\n"); while ( CCgettxout(txid,0,1) > 0 ) { spenttxid = zeroid; @@ -341,6 +343,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd if ( spentvini != 0 ) return(-3); } + fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -355,7 +358,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd return(0); } } - } + }else fprintf(stderr,"opret erro\n"); } return(-1); } @@ -363,9 +366,9 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid; int32_t batonvout,batonht; int64_t batonvalue; std::vector playerdata; + uint256 batontxid; int32_t batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; obj.push_back(Pair("slot",(int64_t)vout-2)); - if ( rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gametx.vout[vout].scriptPubKey) == 0 ) + if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gametx.vout[vout].scriptPubKey)) == 0 ) { obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonvout",(int64_t)batonvout)); @@ -376,7 +379,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet UniValue pobj(UniValue::VOBJ); obj.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); } - } + } else fprintf(stderr,"findbaton err.%d\n",retval); } int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTransaction gametx,int32_t maxplayers) @@ -478,7 +481,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -499,6 +502,10 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt extract valid playerdata")); } rogue_univalue(result,0,maxplayers,buyin); + GetCCaddress1of2(cp,coinaddr,roguepk,mypk); + fprintf(stderr,"check %s\n",coinaddr); + if ( rogue_iamregistered(tx,coinaddr) > 1 ) + return(cclib_error(result,"already registered")); if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) return(cclib_error(result,"couldnt find available registration baton")); else if ( playertxid != zeroid && rogue_playerdataspend(mtx,playertxid,origplayergame) < 0 ) @@ -588,7 +595,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; bits256 t; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; result.push_back(Pair("name","rogue")); result.push_back(Pair("method","gameinfo")); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -600,7 +607,11 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) { result.push_back(Pair("result","success")); - rogue_gamefields(result,maxplayers,buyin,txid); + mypk = pubkey2pk(Mypubkey()); + roguepk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); + fprintf(stderr,"myrogueaddr.%s\n",myrogueaddr); + rogue_gamefields(result,maxplayers,buyin,txid,myrogueaddr); for (i=0; i Date: Tue, 5 Feb 2019 22:16:32 -1100 Subject: [PATCH 1802/3904] gametx.vout[vout].scriptPubKey --- src/cc/rogue_rpc.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5a1721018..8f751e15f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -302,20 +302,21 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 } else return(-1); } -int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,CScript scriptPubKey) +int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr) { - int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; + int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64]; for (i=0; i= 0 ) { if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) { - if ( spenttx.vout[0].scriptPubKey == scriptPubKey ) + GetScriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); + if ( strcmp(destaddr,ccaddr) == 0 ) { matches++; matchtx = spenttx; - } else fprintf(stderr,"%d+2 doesnt match scriptPubKey\n",i); + } else fprintf(stderr,"%d+2 doesnt match %s vs %s\n",i,ccaddr,destaddr); } else fprintf(stderr,"%d+2 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); } else fprintf(stderr,"%d+2 unspent\n",i); } @@ -366,9 +367,10 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid; int32_t batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; + uint256 batontxid; int32_t batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + GetScriptaddress(destaddr,gametx.vout[vout].scriptPubKey); obj.push_back(Pair("slot",(int64_t)vout-2)); - if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gametx.vout[vout].scriptPubKey)) == 0 ) + if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) { obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonvout",(int64_t)batonvout)); @@ -531,7 +533,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -541,10 +543,10 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param keystrokes = ParseHex(keystrokestr); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); - txout = MakeCC1of2vout(cp->evalcode,0,roguepk,mypk); + GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,txout.scriptPubKey) == 0 ) + if ( rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr) == 0 ) { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { From 27bb4fd785c1d2aa44b3957ed31d146871ac8332 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 22:19:41 -1100 Subject: [PATCH 1803/3904] Getscriptaddress --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8f751e15f..8d84ea754 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -311,7 +311,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd { if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) { - GetScriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); + Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(destaddr,ccaddr) == 0 ) { matches++; @@ -368,7 +368,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet { // identify if bailout or quit or timed out uint256 batontxid; int32_t batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; - GetScriptaddress(destaddr,gametx.vout[vout].scriptPubKey); + Getscriptaddress(destaddr,gametx.vout[vout].scriptPubKey); obj.push_back(Pair("slot",(int64_t)vout-2)); if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) { From 2fc422528b13e767dedfeb942b2c9793e2499754 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 22:27:54 -1100 Subject: [PATCH 1804/3904] Recall destaddr --- src/cc/rogue_rpc.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8d84ea754..c1afabaae 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -367,8 +367,13 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid; int32_t batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; - Getscriptaddress(destaddr,gametx.vout[vout].scriptPubKey); + uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + destaddr[0] = 0; + if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) + { + if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); + } obj.push_back(Pair("slot",(int64_t)vout-2)); if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) { From 4ddcfc2a041f83fb436614e11fded8024b1b1f8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 22:36:10 -1100 Subject: [PATCH 1805/3904] Destaddr --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c1afabaae..89c4547e8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -372,7 +372,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) - Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); + Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-2)); if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) From 6e8418cf0331dccc2af5ea01f3213542f9ed96c1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 22:40:50 -1100 Subject: [PATCH 1806/3904] Reverse polarity --- src/cc/rogue_rpc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 89c4547e8..b372bd0a7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -317,20 +317,20 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd matches++; matchtx = spenttx; } else fprintf(stderr,"%d+2 doesnt match %s vs %s\n",i,ccaddr,destaddr); - } else fprintf(stderr,"%d+2 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); - } else fprintf(stderr,"%d+2 unspent\n",i); + } //else fprintf(stderr,"%d+2 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"%d+2 unspent\n",i); } if ( matches == 1 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); + //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { txid = spenttxid; - fprintf(stderr,"scan forward\n"); - while ( CCgettxout(txid,0,1) > 0 ) + fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),spenttxid.GetHex().c_str()); + while ( CCgettxout(txid,0,1) < 0 ) { spenttxid = zeroid; spentvini = -1; From 895825f3db3a9a16b24cc1dc586f17eb3675fc3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 22:46:10 -1100 Subject: [PATCH 1807/3904] Test --- src/cc/makerogue | 2 +- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 08c86dee8..f7ee26669 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,5 +1,5 @@ cd rogue; -./configure # only need this first time +#./configure # only need this first time make; cd .. gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b372bd0a7..5d5c1bd00 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -328,8 +328,8 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd { if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { - txid = spenttxid; - fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),spenttxid.GetHex().c_str()); + txid = matchtx.GetHash(); + fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); while ( CCgettxout(txid,0,1) < 0 ) { spenttxid = zeroid; From d14201d023e8445952c5589f74eab9486fe4f6ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 22:59:21 -1100 Subject: [PATCH 1808/3904] rogue_iamregistered --- src/cc/rogue_rpc.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5d5c1bd00..ff6de1971 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -173,8 +173,23 @@ void rogue_univalue(UniValue &result,const char *method,int64_t maxplayers,int64 } } -int32_t rogue_iamregistered(CTransaction tx,char *myrogueaddr) +int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx,char *myrogueaddr) { + int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; char destaddr[64]; + for (i=0; i= 0 ) + { + if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + { + Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); + if ( strcmp(myrogueaddr,destaddr) == 0 ) + return(1); + } + } + } return(0); } @@ -196,7 +211,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam memcpy(&seed,&hashBlock,sizeof(seed)); seed &= (1LL << 62) - 1; obj.push_back(Pair("seed",(int64_t)seed)); - if ( rogue_iamregistered(tx,myrogueaddr) > 0 ) + if ( rogue_iamregistered(maxplayers,gametxid,tx,myrogueaddr) > 0 ) sprintf(cmd,"./rogue %llu gui",(long long)seed); else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str()); obj.push_back(Pair("run",cmd)); @@ -356,6 +371,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) return(-4); else batonht = pindex->GetHeight(); + batonvalue = batontx.vout[0].nValue; return(0); } } @@ -378,6 +394,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) { obj.push_back(Pair("baton",batontxid.ToString())); + obj.push_back(Pair("batonaddr",destaddr)); obj.push_back(Pair("batonvout",(int64_t)batonvout)); obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); obj.push_back(Pair("batonht",(int64_t)batonht)); @@ -511,7 +528,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); fprintf(stderr,"check %s\n",coinaddr); - if ( rogue_iamregistered(tx,coinaddr) > 1 ) + if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 1 ) return(cclib_error(result,"already registered")); if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) return(cclib_error(result,"couldnt find available registration baton")); From e28b2d84b7c0e4a0d5d28545ef36f239a159a768 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 23:18:50 -1100 Subject: [PATCH 1809/3904] Off by 1 --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ff6de1971..f9a3e7904 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -187,8 +187,9 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(myrogueaddr,destaddr) == 0 ) return(1); - } - } + else fprintf(stderr,"myaddr.%s vs %s\n",myrogueaddr,destaddr); + } else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); + } else fprintf(stderr,"vout %d is unspent\n",vout); } return(0); } @@ -528,7 +529,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); fprintf(stderr,"check %s\n",coinaddr); - if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 1 ) + if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) return(cclib_error(result,"already registered")); if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) return(cclib_error(result,"couldnt find available registration baton")); From 406a017b2bdce93251dc6162de2aa59f677c441c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 23:42:01 -1100 Subject: [PATCH 1810/3904] Flush keystrokes --- src/cc/rogue/rogue.c | 12 ++++++++++++ src/cc/rogue/rogue.h | 2 +- src/cc/rogue_rpc.cpp | 34 ++++++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 554c0ae4e..56316808c 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -105,6 +105,7 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter) return(0); } +#ifdef test int32_t flushkeystrokes(struct rogue_state *rs) { char fname[1024]; FILE *fp; int32_t i,retflag = -1; @@ -136,6 +137,17 @@ int32_t flushkeystrokes(struct rogue_state *rs) } else fprintf(stderr,"error creating (%s)\n",fname); return(retflag); } +#else + +int32_t flushkeystrokes(struct rogue_state *rs) +{ + rogue_progress(rs->seed,rs->buffered,rs->num); + memset(rs->buffered,0,sizeof(rs->buffered)); + rs->counter++; + rs->num = 0; + return(0); +} +#endif long get_filesize(FILE *fp) { diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index e66362a10..6502ed775 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -332,7 +332,7 @@ struct rogue_state uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime; struct rogue_player P; - char buffered[512]; + char buffered[8192]; }; extern struct rogue_state globalR; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f9a3e7904..f8c575c4c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -21,6 +21,8 @@ #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching #define ROGUE_MAXKEYSTROKESGAP 60 +uint256 Gametxid; + /* the idea is that you creategame and get a txid, you specify the maxplayers and buyin for the game. the tx will have maxplayers of vouts. You must have a non-zero buyin to be able to use a preexisting character. @@ -76,8 +78,8 @@ // cclib gameinfo 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22]\" // cclib register 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%2235e99df53c981a937bfa2ce7bfb303cea0249dba34831592c140d1cb729cb19f%22,%22%22]\" -// cclib keystrokes 17 \"[]\" +// cclib register 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22,%22%22]\" +// cclib keystrokes 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22,%22deadbeef%22]\" CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { @@ -186,10 +188,13 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, { Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(myrogueaddr,destaddr) == 0 ) + { + Gametxid = gametxid; return(1); - else fprintf(stderr,"myaddr.%s vs %s\n",myrogueaddr,destaddr); - } else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); - } else fprintf(stderr,"vout %d is unspent\n",vout); + } + //else fprintf(stderr,"myaddr.%s vs %s\n",myrogueaddr,destaddr); + } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"vout %d is unspent\n",vout); } return(0); } @@ -528,7 +533,6 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); - fprintf(stderr,"check %s\n",coinaddr); if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) return(cclib_error(result,"already registered")); if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) @@ -556,7 +560,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -575,14 +579,28 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,roguepk,mypk)); + Myprivkey(mypriv); + CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_keystrokesopret(gametxid,batontxid,mypk,keystrokes)); - return(rogue_rawtxresult(result,rawtx,1)); + fprintf(stderr,"KEYSTROKES.(%s)\n",rawtx.c_str()); + return(rogue_rawtxresult(result,rawtx,0)); } else return(cclib_error(result,"keystrokes tx was too late")); } else return(cclib_error(result,"couldnt find batontxid")); } else return(cclib_error(result,"invalid gametxid")); } else return(cclib_error(result,"couldnt reparse params")); } +void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) +{ + char cmd[32768],hexstr[32768]; int32_t i; + for (i=0; i highlander vout from creategame TCBOO From 1a6dcc079fb03e8a6e83b24062d1d689e8227196 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 23:50:34 -1100 Subject: [PATCH 1811/3904] -gametxid --- src/cc/rogue/rogue.c | 18 ++++++++++++++++-- src/cc/rogue_rpc.cpp | 15 +-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 56316808c..f43b81a68 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -22,6 +22,7 @@ */ struct rogue_state globalR; void garbage_collect(); +char Gametxidstr[67]; void purge_obj_guess(struct obj_info *array,int32_t n) { @@ -139,6 +140,17 @@ int32_t flushkeystrokes(struct rogue_state *rs) } #else +void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to lookup gametxid +{ + char cmd[32768],hexstr[32768]; int32_t i; + for (i=0; iseed,rs->buffered,rs->num); @@ -238,9 +250,11 @@ int rogue(int argc, char **argv, char **envp) { char *env; int lowtime; struct rogue_state *rs = &globalR; memset(rs,0,sizeof(*rs)); - if ( argc == 3 && strcmp(argv[2],"gui") == 0 ) + if ( argc == 3 && strlen(argv[2]) == 64 ) + { rs->seed = atol(argv[1]); - else rs->seed = 777; + strcpy(Gametxidstr,argv[2]); + } else rs->seed = 777; rs->guiflag = 1; rs->sleeptime = 1; // non-zero to allow refresh() md_init(); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f8c575c4c..10d509b9b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -21,8 +21,6 @@ #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching #define ROGUE_MAXKEYSTROKESGAP 60 -uint256 Gametxid; - /* the idea is that you creategame and get a txid, you specify the maxplayers and buyin for the game. the tx will have maxplayers of vouts. You must have a non-zero buyin to be able to use a preexisting character. @@ -218,7 +216,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam seed &= (1LL << 62) - 1; obj.push_back(Pair("seed",(int64_t)seed)); if ( rogue_iamregistered(maxplayers,gametxid,tx,myrogueaddr) > 0 ) - sprintf(cmd,"./rogue %llu gui",(long long)seed); + sprintf(cmd,"./rogue %llu %s",(long long)seed,gametxid.ToString().c_str()); else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str()); obj.push_back(Pair("run",cmd)); } @@ -590,17 +588,6 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) -{ - char cmd[32768],hexstr[32768]; int32_t i; - for (i=0; i highlander vout from creategame TCBOO From b103d5215256651b81a223fabe7fe80ac61cce3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Feb 2019 23:52:04 -1100 Subject: [PATCH 1812/3904] Fix system call --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f43b81a68..7b1c63ba5 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -146,7 +146,7 @@ void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to l for (i=0; i Date: Tue, 5 Feb 2019 23:52:51 -1100 Subject: [PATCH 1813/3904] -Gametxid --- src/cc/rogue_rpc.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 10d509b9b..432c4ed1d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -186,10 +186,7 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, { Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(myrogueaddr,destaddr) == 0 ) - { - Gametxid = gametxid; return(1); - } //else fprintf(stderr,"myaddr.%s vs %s\n",myrogueaddr,destaddr); } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); } //else fprintf(stderr,"vout %d is unspent\n",vout); From 20b1d0df88759c9b7c2e00d67946f7974d32884a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 00:01:30 -1100 Subject: [PATCH 1814/3904] Test keystrokes --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 7b1c63ba5..1a09d13b9 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -146,7 +146,7 @@ void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to l for (i=0; i Date: Wed, 6 Feb 2019 19:10:48 +0800 Subject: [PATCH 1815/3904] jorians ip --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ed195bf48..c30c8f17e 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -14,7 +14,7 @@ static const char *iguanaSeeds[8][1] = {"103.6.12.112"}, {"18.224.176.46"}, {"45.76.120.247"}, - {"103.6.12.112"}, + {"185.62.57.32"}, {"103.6.12.112"}, {"103.6.12.112"}, {"103.6.12.112"}, From 61aa40edf483a8edfbba6ae8e48aa8dbccf7a21d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 19:41:44 +0800 Subject: [PATCH 1816/3904] fix miner LOCK UP --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e3eb8d262..c437a19d6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -692,7 +692,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); if ( totalsats == 0 ) { - fprintf(stderr, "Could not create notary payment, trying again.\n"); + fprintf(stderr, "Could not create notary payment, trying again.\n"); + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); return(0); } fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); From f515c4b9ac841773f77d6103a02445f9732b5d60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 01:05:04 -1100 Subject: [PATCH 1817/3904] Test --- src/cc/cclib.cpp | 2 +- src/cc/rogue_rpc.cpp | 70 +++++++++++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f192fc20a..dd0aef00f 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -472,7 +472,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will } newstr[j] = 0; params = cJSON_Parse(newstr); - if ( params != 0 ) + if ( 0 && params != 0 ) printf("new.(%s) -> %s\n",newstr,jprint(params,0)); free(newstr); *nump = cJSON_GetArraySize(params); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b2b4dbc71..0d415f4cb 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -19,7 +19,7 @@ #define ROGUE_REGISTRATION 5 #define ROGUE_REGISTRATIONSIZE (100 * 10000) #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching -#define ROGUE_MAXKEYSTROKESGAP 777 +#define ROGUE_MAXKEYSTROKESGAP 60 /* the idea is that you creategame and get a txid, you specify the maxplayers and buyin for the game. the tx will have maxplayers of vouts. You must have a non-zero buyin to be able to use a preexisting character. @@ -71,13 +71,13 @@ //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & -// cclib newgame 17 \"[3,100]\" +// cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22]\" -// cclib register 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22]\" +// cclib gameinfo 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" +// cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22,%22%22]\" -// cclib keystrokes 17 \"[%22783369750c2c7003d3dcee327b830025c560b594f65648c0abbac733a661ea39%22,%22deadbeef%22]\" +// cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22%22]\" +// cclib keystrokes 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22deadbeef%22]\" CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { @@ -213,7 +213,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam seed &= (1LL << 62) - 1; obj.push_back(Pair("seed",(int64_t)seed)); if ( rogue_iamregistered(maxplayers,gametxid,tx,myrogueaddr) > 0 ) - sprintf(cmd,"./rogue %llu %s",(long long)seed,gametxid.ToString().c_str()); + sprintf(cmd,"cc/rogue/rogue %llu %s",(long long)seed,gametxid.ToString().c_str()); else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str()); obj.push_back(Pair("run",cmd)); } @@ -318,9 +318,10 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 } else return(-1); } -int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr) +int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &numkeys,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr) { int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64]; + numkeys = 0; for (i=0; i= 0 ) @@ -345,7 +346,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); while ( CCgettxout(txid,0,1) < 0 ) { spenttxid = zeroid; @@ -359,8 +360,19 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd } if ( spentvini != 0 ) return(-3); + if ( keystrokesp != 0 && GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() == 2 ) + { + uint256 g,b; CPubKey p; std::vector k; + if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[1].scriptPubKey) == 'K' ) + { + keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()/2); + decode_hex((uint8_t *)&keystrokes[numkeys],(int32_t)k.size()/2,&k[0]); + numkeys += (int32_t)k.size()/2; + (*keystrokesp) = keystrokes; + } + } } - fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -373,10 +385,11 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; + printf("keystrokes[%d]\n",numkeys); return(0); } } - }else fprintf(stderr,"opret erro\n"); + } else fprintf(stderr,"findbaton opret error\n"); } return(-1); } @@ -384,7 +397,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,std::vector &playerd void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { @@ -392,7 +405,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-2)); - if ( (retval= rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) + if ( (retval= rogue_findbaton(cp,0,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) { obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonaddr",destaddr)); @@ -555,7 +568,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numkeys,batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -568,7 +581,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr) == 0 ) + if ( rogue_findbaton(cp,0,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr) == 0 ) { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { @@ -610,13 +623,30 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VOBJ); CTransaction gametx; int64_t batonvalue; int32_t n,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; if ( txfee == 0 ) txfee = 10000; - // make sure no highlander yet - result.push_back(Pair("result","success")); + mypk = pubkey2pk(Mypubkey()); + roguepk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","bailout")); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",txid.GetHex())); + if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) + { + if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 ) + { + + } + result.push_back(Pair("result","success")); + } + } + } return(result); } @@ -630,14 +660,14 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 0 ) { txid = juint256(jitem(params,0)); - result.push_back(Pair("txid",txid.GetHex())); + result.push_back(Pair("gametxid",txid.GetHex())); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) { result.push_back(Pair("result","success")); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); - fprintf(stderr,"myrogueaddr.%s\n",myrogueaddr); + //fprintf(stderr,"myrogueaddr.%s\n",myrogueaddr); rogue_gamefields(result,maxplayers,buyin,txid,myrogueaddr); for (i=0; i Date: Wed, 6 Feb 2019 01:06:34 -1100 Subject: [PATCH 1818/3904] Keystrokes --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0d415f4cb..770ea058b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -320,7 +320,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &numkeys,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr) { - int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64]; + int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = 0; for (i=0; i 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CTransaction gametx; int64_t batonvalue; int32_t n,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; + UniValue result(UniValue::VOBJ); CTransaction gametx; int64_t buyin,batonvalue; int32_t n,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -636,8 +636,8 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 0 ) { gametxid = juint256(jitem(params,0)); - result.push_back(Pair("gametxid",txid.GetHex())); - if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) + result.push_back(Pair("gametxid",gametxid.GetHex())); + if ( rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid) == 0 ) { if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 ) { From 94f104121e09c12e8e3d89e251952c3713758e7c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 01:09:47 -1100 Subject: [PATCH 1819/3904] +print --- src/cc/rogue_rpc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 770ea058b..d00d48fb1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -78,6 +78,7 @@ // ./rogue gui -> creates keystroke files // cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22%22]\" // cclib keystrokes 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22deadbeef%22]\" +// cclib bailout 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { @@ -366,7 +367,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[1].scriptPubKey) == 'K' ) { keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()/2); - decode_hex((uint8_t *)&keystrokes[numkeys],(int32_t)k.size()/2,&k[0]); + decode_hex((uint8_t *)&keystrokes[numkeys],(int32_t)k.size()/2,(char *)&k[0]); numkeys += (int32_t)k.size()/2; (*keystrokesp) = keystrokes; } @@ -641,7 +642,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 ) { - + fprintf(stderr,"found baton %s numkeys.%d\n",batontxid.ToString().c_str(),numkeys); } result.push_back(Pair("result","success")); } From 694ba9a62943f85a3c59e048354987ab8a4e4cc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 01:20:44 -1100 Subject: [PATCH 1820/3904] Replay2 --- src/cc/rogue/rogue.c | 66 +++++++++++++++++++++----------------------- src/cc/rogue_rpc.cpp | 6 +++- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 1a09d13b9..073dbf3cd 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -159,6 +159,37 @@ int32_t flushkeystrokes(struct rogue_state *rs) rs->num = 0; return(0); } + +int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num) +{ + struct rogue_state *rs; FILE *fp; int32_t i; + rs = (struct rogue_state *)calloc(1,sizeof(*rs)); + rs->seed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = 1; + uint32_t starttime = (uint32_t)time(NULL); + rogueiterate(rs); + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); + sleep(2); + + starttime = (uint32_t)time(NULL); + for (i=0; i<100; i++) + { + memset(rs,0,sizeof(*rs)); + rs->seed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = 0; + rogueiterate(rs); + } + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); + sleep(1); + if ( (fp= fopen("checkfile","wb")) != 0 ) + save_file(rs,fp,0); + free(rs); + return(0); +} #endif long get_filesize(FILE *fp) @@ -204,40 +235,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } if ( num > 0 ) { - rs = (struct rogue_state *)calloc(1,sizeof(*rs)); - rs->seed = seed; - rs->keystrokes = keystrokes; - rs->numkeys = num; - rs->sleeptime = 1; - uint32_t starttime = (uint32_t)time(NULL); - rogueiterate(rs); - fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); - sleep(2); - - starttime = (uint32_t)time(NULL); - for (i=0; i<2000; i++) - { - memset(rs,0,sizeof(*rs)); - rs->seed = seed; - rs->keystrokes = keystrokes; - rs->numkeys = num; - rs->sleeptime = 0; - rogueiterate(rs); - } - fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); - sleep(1); - if ( (fp= fopen("checkfile","wb")) != 0 ) - { - save_file(rs,fp,0); - if ( 0 && (fp= fopen("checkfile","rb")) != 0 ) - { - for (i=0; i<0x150; i++) - fprintf(stderr,"%02x",fgetc(fp)); - fprintf(stderr," first part rnd.%d\n",rnd(1000)); - fclose(fp); - } - } - free(rs); + rogue_replay2(seed,keystrokes,num); mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d00d48fb1..019e0c728 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -617,6 +617,8 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(result); } +int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num); + UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { // detect if last to bailout @@ -640,9 +642,11 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 ) + if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 ) { fprintf(stderr,"found baton %s numkeys.%d\n",batontxid.ToString().c_str(),numkeys); + rogue_replay2(4419709268196762041,keystrokes,numkeys); + free(keystrokes); } result.push_back(Pair("result","success")); } From cedc9465e64d93abde01719e35cf66c37c3ab0f9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 20:29:27 +0800 Subject: [PATCH 1821/3904] Make miner not flag invalid notarisation for coinbase createion. --- src/miner.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c437a19d6..87f92559b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -174,6 +174,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarisationBlock = false; std::vector NotarisationNotaries; + static std::string invalidnotarisation; //fprintf(stderr,"create new block\n"); // Create new block @@ -370,10 +371,18 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); - if ( checkdupes.size() != NotarisationNotaries.size() ) { + if ( tx.GetHash().ToString() == invalidnotarisation ) + { + NotarisationNotaries.clear(); + fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); + } + else if ( checkdupes.size() != NotarisationNotaries.size() ) + { NotarisationNotaries.clear(); fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); - } else fNotarisation = true; + } + else + fNotarisation = true; } else NotarisationNotaries.clear(); @@ -693,6 +702,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); + invalidnotarisation = pblock->vtx[1].GetHash().ToString(); LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(mempool.cs); return(0); From ba6a35728361ac6577de20d9b5585adabd96e3a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 01:31:25 -1100 Subject: [PATCH 1822/3904] Suppress exit --- src/cc/rogue/rogue.c | 10 ++++++---- src/cc/rogue/save.c | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 073dbf3cd..1927f159b 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -167,10 +167,10 @@ int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num) rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; - rs->sleeptime = 1; + rs->sleeptime = 0; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); - fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); + /*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); sleep(2); starttime = (uint32_t)time(NULL); @@ -184,7 +184,7 @@ int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num) rogueiterate(rs); } fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); - sleep(1); + sleep(1);*/ if ( (fp= fopen("checkfile","wb")) != 0 ) save_file(rs,fp,0); free(rs); @@ -619,6 +619,8 @@ void my_exit(int st) { resetltchars(); - exit(st); + if ( globalR.guiflag != 0 ) + exit(st); + else fprintf(stderr,"would have exit.(%d)\n",st); } diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index eec85b930..57811176a 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -130,7 +130,7 @@ auto_save(int sig) if (file_name[0] != '\0' && ((savef = fopen(file_name, "w")) != NULL || (md_unlink_open_file(file_name, savef) >= 0 && (savef = fopen(file_name, "w")) != NULL))) save_file(&globalR,savef,1); - exit(0); + my_exit(0); } /* @@ -181,7 +181,7 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) fflush(savef); fclose(savef); if ( guiflag != 0 ) - exit(0); + my_exit(0); } int32_t rogue_restorepack(struct rogue_state *rs) From dc7bc76dd626fdac4805ab3a1d1592a37d7d60f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 01:36:09 -1100 Subject: [PATCH 1823/3904] Test --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 1927f159b..aeb509832 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -167,7 +167,7 @@ int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num) rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; - rs->sleeptime = 0; + rs->sleeptime = 50000; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); /*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); From fde8e549a3047df05bc2f2ea22ae398ec293af3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 01:46:55 -1100 Subject: [PATCH 1824/3904] Dont decode keystrokes --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 019e0c728..b39845c81 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -366,9 +366,10 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n uint256 g,b; CPubKey p; std::vector k; if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[1].scriptPubKey) == 'K' ) { - keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()/2); - decode_hex((uint8_t *)&keystrokes[numkeys],(int32_t)k.size()/2,(char *)&k[0]); - numkeys += (int32_t)k.size()/2; + keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); + for (i=0; i Date: Wed, 6 Feb 2019 21:09:43 +0800 Subject: [PATCH 1825/3904] try fix --- src/miner.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 87f92559b..94766388f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -371,21 +371,22 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); - if ( tx.GetHash().ToString() == invalidnotarisation ) - { - NotarisationNotaries.clear(); - fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); - } - else if ( checkdupes.size() != NotarisationNotaries.size() ) + if ( checkdupes.size() != NotarisationNotaries.size() ) { NotarisationNotaries.clear(); fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); - } + } + else if ( tx.GetHash().ToString() == invalidnotarisation ) + { + // check if the last notarisation we tried was flagged as invalid. + // then clear it, in case next time it is seen as valid. + NotarisationNotaries.clear(); + invalidnotarisation = ""; + fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); + } else fNotarisation = true; - } - else - NotarisationNotaries.clear(); + } else NotarisationNotaries.clear(); nTotalIn += tx.GetShieldedValueIn(); } From 6c1d59e8a2912ba2346fbed722f149b74c77f8ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 02:25:28 -1100 Subject: [PATCH 1826/3904] Opreturn player data --- src/cc/rogue/rogue.c | 8 ++++++-- src/cc/rogue/rogue.h | 5 +++-- src/cc/rogue/save.c | 2 ++ src/cc/rogue/state.c | 3 ++- src/cc/rogue_rpc.cpp | 41 +++++++++++++++++++++++++++-------------- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index aeb509832..6ea858493 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -160,7 +160,7 @@ int32_t flushkeystrokes(struct rogue_state *rs) return(0); } -int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num) +int32_t rogue_replay2(uint8_t *player,uint64_t seed,char *keystrokes,int32_t num) { struct rogue_state *rs; FILE *fp; int32_t i; rs = (struct rogue_state *)calloc(1,sizeof(*rs)); @@ -186,9 +186,13 @@ int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num) fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); sleep(1);*/ if ( (fp= fopen("checkfile","wb")) != 0 ) + { save_file(rs,fp,0); + if ( rs->playersize > 0 ) + memcpy(player,rs->playerdata,rs->playersize); + } free(rs); - return(0); + return(rs->playersize); } #endif diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 6502ed775..4dcee238d 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -321,7 +321,7 @@ struct rogue_packitem struct rogue_player { - int32_t gold,hitpoints,strength,level,experience,packsize; + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; @@ -330,9 +330,10 @@ struct rogue_state uint64_t seed; char *keystrokes; uint32_t needflush,replaydone; - int32_t numkeys,ind,num,guiflag,counter,sleeptime; + int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize; struct rogue_player P; char buffered[8192]; + uint8_t playerdata[10000]; }; extern struct rogue_state globalR; diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 57811176a..8a40a9fb8 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -167,7 +167,9 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) { fprintf(stderr,"%02x",((uint8_t *)&rs->P)[i]); histo[((uint8_t *)&rs->P)[i]]++; + rs->playerdata[i] = ((uint8_t *)&rs->P)[i]; } + rs->playersize = n; fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n); if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 ) { diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index d99f1b0dc..226392e83 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1388,7 +1388,8 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.strength = max_stats.s_str; rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp); + rs->P.dungeonlevel = level; + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); }; fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b39845c81..c2afade28 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -101,19 +101,19 @@ CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std: return(opret); } -CScript rogue_highlanderopret(uint256 gametxid,uint256 registertxid,CPubKey pk,std::vectorplayerdata) +CScript rogue_highlanderopret(uint256 gametxid,CPubKey pk,std::vectorplayerdata) { CScript opret; uint8_t evalcode = EVAL_ROGUE; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << registertxid << pk << playerdata); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << pk << playerdata); return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid,uint256 ®istertxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> registertxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && f == 'H' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) { return(f); } @@ -195,9 +195,9 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } -void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) +uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) { - CBlockIndex *pindex; int32_t ht,delay; uint256 hashBlock; uint64_t seed; char cmd[512]; CTransaction tx; + CBlockIndex *pindex; int32_t ht,delay; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; if ( GetTransaction(gametxid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); @@ -222,6 +222,7 @@ void rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gam } obj.push_back(Pair("maxplayers",maxplayers)); obj.push_back(Pair("buyin",ValueFromAmount(buyin))); + return(seed); } int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid) @@ -286,7 +287,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'S') ) + if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&highlander,script+2,sizeof(highlander)); highlander = revuint256(highlander); @@ -295,7 +296,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) { - if ( rogue_highlanderopretdecode(origplayergame,registertxid,pk,playerdata,highlandertx.vout[numvouts-1].scriptPubKey) == 'H' ) + if ( (f= rogue_highlanderopretdecode(origplayergame,registertxid,pk,playerdata,highlandertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { if ( highlandertx.vin[0].prevout.hash == origplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) return(0); @@ -592,8 +593,8 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_keystrokesopret(gametxid,batontxid,mypk,keystrokes)); - fprintf(stderr,"KEYSTROKES.(%s)\n",rawtx.c_str()); - return(rogue_rawtxresult(result,rawtx,0)); + //fprintf(stderr,"KEYSTROKES.(%s)\n",rawtx.c_str()); + return(rogue_rawtxresult(result,rawtx,1)); } else return(cclib_error(result,"keystrokes tx was too late")); } else return(cclib_error(result,"couldnt find batontxid")); } else return(cclib_error(result,"invalid gametxid")); @@ -618,7 +619,7 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(result); } -int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num); +int32_t rogue_replay2(uint8_t *player,uint64_t seed,char *keystrokes,int32_t num); UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { @@ -627,7 +628,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CTransaction gametx; int64_t buyin,batonvalue; int32_t n,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; int64_t buyin,batonvalue; int32_t n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -645,9 +646,21 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 ) { - fprintf(stderr,"found baton %s numkeys.%d\n",batontxid.ToString().c_str(),numkeys); - rogue_replay2(4419709268196762041,keystrokes,numkeys); + UniValue obj; + seed = uint64_t rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); + fprintf(stderr,"found baton %s numkeys.%d seed.%llu\n",batontxid.ToString().c_str(),numkeys,(long long)seed); + num = rogue_replay2(player,seed,keystrokes,numkeys); //4419709268196762041 free(keystrokes); + newdata.resize(num); + for (i=0; ievalcode,batonvalue-txfee,roguepk)); + Myprivkey(mypriv); + CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(gametxid,mypk,newdata)); + return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); } From acb3d796abd0a4fc4cd4c0f84edb50a647ac9398 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 02:54:46 -1100 Subject: [PATCH 1827/3904] Player data --- src/cc/rogue/init.c | 32 ++++++++++++++++++-------------- src/cc/rogue/rogue.c | 12 ++++++++---- src/cc/rogue/rogue.h | 4 +++- src/cc/rogue_rpc.cpp | 29 ++++++++++++++++++++++------- 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index ff3243ae8..9635ab37b 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -22,26 +22,30 @@ */ void rogue_restoreobject(THING *o,struct rogue_packitem *item); -void -init_player(struct rogue_state *rs) +void restore_player(struct rogue_state *rs) +{ + int32_t i; + //rs->P.gold = purse; + max_hp = rs->P.hitpoints; + max_stats.s_str = rs->P.strength; + pstats.s_lvl = rs->P.level; + pstats.s_exp = rs->P.experience; + for (i=0; iP.packsize; i++) + { + obj = new_item(); + rogue_restoreobject(obj,&rs->P.roguepack[i]); + add_pack(rs,obj,TRUE); + } +} + +void init_player(struct rogue_state *rs) { register THING *obj; int32_t i; pstats = max_stats; food_left = HUNGERTIME; - if ( 0 && rogue_restorepack(rs) == 0 ) + if ( rs->restoring != 0 ) { - //rs->P.gold = purse; - max_hp = rs->P.hitpoints; - max_stats.s_str = rs->P.strength; - pstats.s_lvl = rs->P.level; - pstats.s_exp = rs->P.experience; - for (i=0; iP.packsize; i++) - { - obj = new_item(); - rogue_restoreobject(obj,&rs->P.roguepack[i]); - add_pack(rs,obj,TRUE); - } // duplicate rng usage of normal case obj = new_item(); init_weapon(obj, MACE); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6ea858493..68f77a0cb 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -97,6 +97,8 @@ void rogueiterate(struct rogue_state *rs) start_daemon(doctor, 0, AFTER); fuse(swander, 0, WANDERTIME, AFTER); start_daemon(stomach, 0, AFTER); + if ( rs->restoring != 0 ) + restore_player(rs); playit(rs); } @@ -160,7 +162,7 @@ int32_t flushkeystrokes(struct rogue_state *rs) return(0); } -int32_t rogue_replay2(uint8_t *player,uint64_t seed,char *keystrokes,int32_t num) +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player) { struct rogue_state *rs; FILE *fp; int32_t i; rs = (struct rogue_state *)calloc(1,sizeof(*rs)); @@ -168,6 +170,8 @@ int32_t rogue_replay2(uint8_t *player,uint64_t seed,char *keystrokes,int32_t num rs->keystrokes = keystrokes; rs->numkeys = num; rs->sleeptime = 50000; + if ( player != 0 ) + rs->P = *player; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); /*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); @@ -188,8 +192,8 @@ int32_t rogue_replay2(uint8_t *player,uint64_t seed,char *keystrokes,int32_t num if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(rs,fp,0); - if ( rs->playersize > 0 ) - memcpy(player,rs->playerdata,rs->playersize); + if ( newdata != 0 && rs->playersize > 0 ) + memcpy(newdata,rs->playerdata,rs->playersize); } free(rs); return(rs->playersize); @@ -239,7 +243,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } if ( num > 0 ) { - rogue_replay2(seed,keystrokes,num); + rogue_replay2(0,seed,keystrokes,num,0); mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 4dcee238d..34df75058 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -330,7 +330,7 @@ struct rogue_state uint64_t seed; char *keystrokes; uint32_t needflush,replaydone; - int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize; + int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring; struct rogue_player P; char buffered[8192]; uint8_t playerdata[10000]; @@ -343,6 +343,8 @@ void rogueiterate(struct rogue_state *rs); int32_t roguefname(char *fname,uint64_t seed,int32_t counter); int32_t flushkeystrokes(struct rogue_state *rs); int32_t rogue_restorepack(struct rogue_state *rs); +void restore_player(struct rogue_state *rs); +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); /* * Help list diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c2afade28..5298c1354 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -69,7 +69,7 @@ //////////////////////// start of CClib interface -//./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & +//./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & // cclib newgame 17 \"[3,10]\" // cclib pending 17 @@ -619,7 +619,7 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(result); } -int32_t rogue_replay2(uint8_t *player,uint64_t seed,char *keystrokes,int32_t num); +#include "rogue/rogue.h" UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { @@ -646,17 +646,32 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 ) { - UniValue obj; + UniValue obj; struct rogue_player P; seed = uint64_t rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); fprintf(stderr,"found baton %s numkeys.%d seed.%llu\n",batontxid.ToString().c_str(),numkeys,(long long)seed); - num = rogue_replay2(player,seed,keystrokes,numkeys); //4419709268196762041 + if ( playerdata.size() > 0 ) + { + for (i=0; ievalcode,batonvalue-txfee,roguepk)); + if ( num == sizeof(P) ) + { + newdata.resize(num); + for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); + } Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(gametxid,mypk,newdata)); From f68beb7072880d28b80ec0b783cf3d3b57f67e19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 02:56:45 -1100 Subject: [PATCH 1828/3904] Simplify --- src/cc/rogue/init.c | 2 +- src/cc/rogue_rpc.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 9635ab37b..1f63e1d51 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -24,7 +24,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item); void restore_player(struct rogue_state *rs) { - int32_t i; + int32_t i; THING *obj; //rs->P.gold = purse; max_hp = rs->P.hitpoints; max_stats.s_str = rs->P.strength; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5298c1354..61441d31a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -619,7 +619,18 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(result); } -#include "rogue/rogue.h" +#define MAXPACK 23 +struct rogue_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; +struct rogue_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; + struct rogue_packitem roguepack[MAXPACK]; +}; +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { @@ -647,7 +658,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 ) { UniValue obj; struct rogue_player P; - seed = uint64_t rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); + seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); fprintf(stderr,"found baton %s numkeys.%d seed.%llu\n",batontxid.ToString().c_str(),numkeys,(long long)seed); if ( playerdata.size() > 0 ) { From 5ffb4153f7573e32b2f9c31c3e3d0f1139a84964 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 02:57:07 -1100 Subject: [PATCH 1829/3904] I --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 61441d31a..823d374b5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -639,7 +639,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; int64_t buyin,batonvalue; int32_t n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; int64_t buyin,batonvalue; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); From 125dee848047d36e26db49b74909637de1f9ad37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:00:52 -1100 Subject: [PATCH 1830/3904] Fixes --- src/cc/rogue/rogue.h | 5 ++++- src/cc/rogue_rpc.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 34df75058..189884f26 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -313,17 +313,20 @@ /* * Now we define the structures and types */ +#ifndef rogue_packitem struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; char damage[8],hurldmg[8]; }; - +#endif +#ifndef rogue_player struct rogue_player { int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; +#endif struct rogue_state { diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 823d374b5..28cdf7964 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -282,7 +282,7 @@ int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace p int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,highlander,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,highlander; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); @@ -296,7 +296,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) { - if ( (f= rogue_highlanderopretdecode(origplayergame,registertxid,pk,playerdata,highlandertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,highlandertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { if ( highlandertx.vin[0].prevout.hash == origplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) return(0); @@ -639,7 +639,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; int64_t buyin,batonvalue; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char destaddr[64],myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -678,7 +678,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d %d dl.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel); mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); From c72396684216faa146a853f02e7c9d0acce30e67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:01:54 -1100 Subject: [PATCH 1831/3904] Ifdef --- src/cc/rogue/rogue.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 189884f26..32bd608d4 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -313,14 +313,12 @@ /* * Now we define the structures and types */ -#ifndef rogue_packitem +#ifndef ROGUE struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; char damage[8],hurldmg[8]; }; -#endif -#ifndef rogue_player struct rogue_player { int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; From 4fe5b4096f5f9044e2184106f3bf91d15e466fe1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:03:02 -1100 Subject: [PATCH 1832/3904] BUILD_ROGUE --- src/cc/rogue/rogue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 32bd608d4..24c3a4546 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -313,7 +313,7 @@ /* * Now we define the structures and types */ -#ifndef ROGUE +#ifdef BUILD_ROGUE struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; From 6e7fb4b198ae0fbc52588b13f388b05fbf2390da Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:04:21 -1100 Subject: [PATCH 1833/3904] Test --- src/cc/rogue/extern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/extern.c b/src/cc/rogue/extern.c index b84e6fa7b..1205b8407 100644 --- a/src/cc/rogue/extern.c +++ b/src/cc/rogue/extern.c @@ -11,7 +11,7 @@ */ #include -#include "rogue.h" +//#include "rogue.h" From 919cf02a5cdfea70dbcda44c2adacda09a829af5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:05:56 -1100 Subject: [PATCH 1834/3904] ROGUE_DECLARED_PACK --- src/cc/rogue/extern.c | 2 +- src/cc/rogue/rogue.h | 3 ++- src/cc/rogue_rpc.cpp | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/extern.c b/src/cc/rogue/extern.c index 1205b8407..b84e6fa7b 100644 --- a/src/cc/rogue/extern.c +++ b/src/cc/rogue/extern.c @@ -11,7 +11,7 @@ */ #include -//#include "rogue.h" +#include "rogue.h" diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 24c3a4546..fa18c424f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -313,7 +313,7 @@ /* * Now we define the structures and types */ -#ifdef BUILD_ROGUE +#ifndef ROGUE_DECLARED_PACK struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; @@ -324,6 +324,7 @@ struct rogue_player int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; +#define ROGUE_DECLARED_PACK #endif struct rogue_state diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 28cdf7964..d51cd8335 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -631,6 +631,7 @@ struct rogue_player struct rogue_packitem roguepack[MAXPACK]; }; int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); +#define ROGUE_DECLARED_PACK UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { From b02bc22f4fc11999006661a5b4631954f7a62193 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:10:38 -1100 Subject: [PATCH 1835/3904] extraction --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 68f77a0cb..62a8a2e1c 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -169,7 +169,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; - rs->sleeptime = 50000; + rs->sleeptime = 0; if ( player != 0 ) rs->P = *player; uint32_t starttime = (uint32_t)time(NULL); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d51cd8335..7c01a7439 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -679,7 +679,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"\n$$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel); mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); @@ -687,6 +687,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(gametxid,mypk,newdata)); + fprintf(stderr,"bailout.(%s)\n",rawtx.c_str()); return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); From 7d0d4ab892bf28a45164c2cef3b3ade88faf94d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:12:49 -1100 Subject: [PATCH 1836/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7c01a7439..5b21348b7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -680,7 +680,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ((uint8_t *)&P)[i] = player[i]; } fprintf(stderr,"\n$$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel); - mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + //mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); } From 4970ed8a70f3ddb123ae59206e486298a9840153 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:15:03 -1100 Subject: [PATCH 1837/3904] Test --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5b21348b7..ef1ad7d92 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -640,7 +640,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char destaddr[64],myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -680,12 +680,12 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ((uint8_t *)&P)[i] = player[i]; } fprintf(stderr,"\n$$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel); - //mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); } Myprivkey(mypriv); - CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); + CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(gametxid,mypk,newdata)); fprintf(stderr,"bailout.(%s)\n",rawtx.c_str()); return(rogue_rawtxresult(result,rawtx,0)); From f657ea839fab50f4659188386380f2009204e622 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:17:37 -1100 Subject: [PATCH 1838/3904] Resize --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ef1ad7d92..810aed574 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -671,7 +671,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); // also need a vin from gametx mtx.vout.push_back(MakeCC1vout(cp->evalcode,batonvalue-txfee,roguepk)); - if ( num == sizeof(P) ) + if ( num > 0 ) { newdata.resize(num); for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); From 7fca64253c863dbef4cb3b6e6da9b559486741eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:24:51 -1100 Subject: [PATCH 1839/3904] Fund gold extraction --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 810aed574..3cbe37de1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -640,7 +640,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,CCchange=0; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -670,7 +670,6 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) free(keystrokes); mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); // also need a vin from gametx - mtx.vout.push_back(MakeCC1vout(cp->evalcode,batonvalue-txfee,roguepk)); if ( num > 0 ) { newdata.resize(num); @@ -679,15 +678,17 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,(uint64_t)P.gold*1000000,16,cp->unspendableCCaddr)) >= (uint64_t)P.gold*1000000+txfee ) + CCchange = (inputsum - (uint64_t)P.gold*1000000 - txfee); fprintf(stderr,"\n$$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); } + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(gametxid,mypk,newdata)); - fprintf(stderr,"bailout.(%s)\n",rawtx.c_str()); return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); From f31e50fdc4bdfbbf0a642aaf5e9c208828d021af Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:25:45 -1100 Subject: [PATCH 1840/3904] Inputs --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3cbe37de1..e7b0c1541 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -640,7 +640,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,CCchange=0; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,CCchange=0; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); From 60b2785c9c3bef31fc0402364e764e4ff2419d40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:29:09 -1100 Subject: [PATCH 1841/3904] Extraction --- src/cc/rogue_rpc.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e7b0c1541..d2bbcd356 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -79,6 +79,19 @@ // cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22%22]\" // cclib keystrokes 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22deadbeef%22]\" // cclib bailout 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" +/* + gold.218 hp.20 strength.16 level.3 exp.22 2 +object (Some food) x.0 y.0 type.58 pack.(a:97) +object (+1 ring mail [protection 4] (being worn)) x.0 y.0 type.93 pack.(b:98) +object (A +1,+1 mace (weapon in hand)) x.0 y.0 type.41 pack.(c:99) +object (A +1,+0 short bow) x.0 y.0 type.41 pack.(d:100) +object (28 +0,+0 arrows) x.0 y.0 type.41 pack.(e:101) +object (A scroll titled 'eeptanelg eep agitwhon wunayot') x.9 y.13 type.63 pack.(f:102) +object (A scroll titled 'aks snodo') x.13 y.3 type.63 pack.(g:103) +object (A scroll titled 'itenejbot lechlech') x.35 y.13 type.63 pack.(h:104) +da000000140000001000000003000000160000000800000002000000000000003a0000000000000001000000000000000000000000000000000000001000000000000000000000000000000000000000000000005d00000000000000010000000100000000000000000000000600000012000000000000000000000000000000000000000000000029000000ffffffff010000000000000001000000010000000000000012000000000000003278340000000000317833000000000029000000ffffffff010000000200000001000000000000000000000012000000000000003178310000000000317831000000000029000000020000001c000000030000000000000000000000000000001e00000000000000317831000000000032783300000000003f00000000000000010000000c00000000000000000000000b0000001000000000000000307830000000000030783000000000003f00000000000000010000000300000000000000000000000b0000001000000000000000307830000000000030783000000000003f00000000000000010000000000000000000000000000000b000000100000000000000030783000000000003078300000000000 packsize.8 n.448 + +$$$gold.218 hp.20 strength.16 level.3 exp.22 dl.2 n.1 size.1228*/ CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { @@ -678,9 +691,9 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,(uint64_t)P.gold*1000000,16,cp->unspendableCCaddr)) >= (uint64_t)P.gold*1000000+txfee ) - CCchange = (inputsum - (uint64_t)P.gold*1000000 - txfee); - fprintf(stderr,"\n$$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,(uint64_t)P.gold*1000000,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*1000000 ) + CCchange = (inputsum - (uint64_t)P.gold*1000000); + fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); From 3ac7cbd35c3eabf536c40f696c1fc25e637bee49 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:42:54 -1100 Subject: [PATCH 1842/3904] Marker for all registrations --- src/cc/rogue_rpc.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d2bbcd356..071287fb0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -91,7 +91,9 @@ object (A scroll titled 'aks snodo') x.13 y.3 type.63 pack.(g:103) object (A scroll titled 'itenejbot lechlech') x.35 y.13 type.63 pack.(h:104) da000000140000001000000003000000160000000800000002000000000000003a0000000000000001000000000000000000000000000000000000001000000000000000000000000000000000000000000000005d00000000000000010000000100000000000000000000000600000012000000000000000000000000000000000000000000000029000000ffffffff010000000000000001000000010000000000000012000000000000003278340000000000317833000000000029000000ffffffff010000000200000001000000000000000000000012000000000000003178310000000000317831000000000029000000020000001c000000030000000000000000000000000000001e00000000000000317831000000000032783300000000003f00000000000000010000000c00000000000000000000000b0000001000000000000000307830000000000030783000000000003f00000000000000010000000300000000000000000000000b0000001000000000000000307830000000000030783000000000003f00000000000000010000000000000000000000000000000b000000100000000000000030783000000000003078300000000000 packsize.8 n.448 -$$$gold.218 hp.20 strength.16 level.3 exp.22 dl.2 n.1 size.1228*/ +$$$gold.218 hp.20 strength.16 level.3 exp.22 dl.2 n.1 size.1228 + ca995aa934b5365e9b86d3db97919e3c26ea03ee6e3045bfc9b05a079ab8b130 + */ CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { @@ -251,8 +253,12 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &b if ( numvouts > maxplayers+2 ) { for (i=0; i &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr) +int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr) { int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = 0; @@ -347,6 +353,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n if ( strcmp(destaddr,ccaddr) == 0 ) { matches++; + regslot = i; matchtx = spenttx; } else fprintf(stderr,"%d+2 doesnt match %s vs %s\n",i,ccaddr,destaddr); } //else fprintf(stderr,"%d+2 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); @@ -413,7 +420,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { @@ -421,7 +428,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-2)); - if ( (retval= rogue_findbaton(cp,0,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) + if ( (retval= rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) { obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonaddr",destaddr)); @@ -499,6 +506,8 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO used for (i=0; ievalcode,ROGUE_REGISTRATIONSIZE,roguepk,roguepk)); + for (i=0; ievalcode,txfee,roguepk,roguepk)); if ( (change= inputsum - required) >= txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,roguepk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(buyin,maxplayers)); @@ -584,7 +593,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numkeys,batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t regslot,numkeys,batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -597,7 +606,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,0,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr) == 0 ) + if ( rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr) == 0 ) { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { @@ -650,10 +659,11 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { // detect if last to bailout // vin0 -> kestrokes baton of completed game with Q + // vout0 -> playerdata marker // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,CCchange=0; int32_t i,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,CCchange=0; int32_t i,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -669,7 +679,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 ) + if ( rogue_findbaton(cp,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 ) { UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); @@ -682,7 +692,8 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P); //4419709268196762041 free(keystrokes); mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); - // also need a vin from gametx + mtx.vin.push_back(CTxIn(gametxid,2+maxplayers+slot,CScript())); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); if ( num > 0 ) { newdata.resize(num); @@ -698,7 +709,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); } - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-txfee),roguepk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(gametxid,mypk,newdata)); From 3369acbc7d2382be15dca4d650ed3a7aadbbbc46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 03:51:10 -1100 Subject: [PATCH 1843/3904] Set of gametxid vouts for bailouts --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 071287fb0..f5745c314 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -692,7 +692,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P); //4419709268196762041 free(keystrokes); mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); - mtx.vin.push_back(CTxIn(gametxid,2+maxplayers+slot,CScript())); + mtx.vin.push_back(CTxIn(gametxid,2+maxplayers+regslot,CScript())); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); if ( num > 0 ) { From cfef67c59bfb38ff9e16be8739761fde68cfacc2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 7 Feb 2019 00:00:11 +0800 Subject: [PATCH 1844/3904] fix possible to choose more than 1 notarisation --- src/komodo_bitcoind.h | 8 +++++++- src/miner.cpp | 16 ++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a476e70e5..d22ac895f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1777,14 +1777,20 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 * uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) { if ( numnotaries == 0 ) + { + fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); + } // fetch notarised height int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); // dont think this can happen, just sanity check. if ( height == notarizedht ) + { + fprintf(stderr, "komodo_notarypayamount failed notarized height = height\n"); return(0); + } // how many block since last notarisation. int32_t n = height - notarizedht; fprintf(stderr, "blocks since last notarisation: %i\n",n); @@ -1851,7 +1857,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar //fprintf(stderr,"%02x",ptr[i+1]); } ptr[34] = OP_CHECKSIG; - //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); + //fprintf(stderr," set notary %i PUBKEY33 into vout[%i] amount.%lu\n",NotarisationNotaries[n],n+1,AmountToPay); txNew.vout[n+1].nValue = AmountToPay; total += txNew.vout[n+1].nValue; } diff --git a/src/miner.cpp b/src/miner.cpp index 94766388f..8f1792f83 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -303,7 +303,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { - int numNotaryVins = 0; bool fToCryptoAddress = false; + //int numNotaryVins = 0; + bool fToCryptoAddress = false; if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; @@ -355,19 +356,19 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) { - numNotaryVins++; + //numNotaryVins++; if ( Notarisations == 0 ) { // Until we get a valid notarization this will always be 0. // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. NotarisationNotaries.push_back(i); - } + } } } } dPriority += (double)nValueIn * nConf; } - if ( numSN != 0 && numNotaryVins >= numSN / 5 ) + if ( numSN != 0 && NotarisationNotaries.size() >= numSN / 5 ) { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); @@ -704,8 +705,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { fprintf(stderr, "Could not create notary payment, trying again.\n"); invalidnotarisation = pblock->vtx[1].GetHash().ToString(); - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } return(0); } fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); From d7338fa770d6a385def8f75cc1ab0ac0ea645f67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 06:29:43 -1100 Subject: [PATCH 1845/3904] 'H' command --- src/cc/rogue_rpc.cpp | 166 ++++++++++++++++++++++++++++++++----------- 1 file changed, 125 insertions(+), 41 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f5745c314..5c1fa9cba 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -22,14 +22,61 @@ #define ROGUE_MAXKEYSTROKESGAP 60 /* - the idea is that you creategame and get a txid, you specify the maxplayers and buyin for the game. the tx will have maxplayers of vouts. You must have a non-zero buyin to be able to use a preexisting character. + Roguelander - using highlander competition between rogue players + + anybody can create a game by specifying maxplayers and buyin. Buyin of 0.00 ROGUE is for newbies and a good way to get experience. All players will start in the identical level, but each level after that will be unique to each player. + There are two different modes that is based on the maxplayers. If maxplayers is one, then it is basically a practice/farming game where there are no time limits. Also, the gold -> ROGUE conversion rate is cut in half. You can start a single player game as soon as the newgame tx is confirmed. + + If maxplayers is more than one, then it goes into highlander mode. There can only be one winner. Additionally, multiplayer mode adds a timelimit of ROGUE_MAXKEYSTROKESGAP (60) blocks between keystrokes updates. That is approx. one hour and every level it does an automatic update, so as long as you are actively playing, it wont be a problem. The is ROGUE_REGISTRATION blocks waiting period before any of the players can start. The random seed for the game is based on the future blockhash so that way, nobody is able to start before the others. + + rogue is not an easy game to win, so it could be that the winner for a specific group is simply the last one standing. If you bailout of a game you cant win, but you can convert all the ingame gold you gathered at 0.001 ROGUE each. [In the event that there arent enough globally locked funds to payout the ROGUE, you will have to wait until there is. Since 10% of all economic activity creates more globally locked funds, it is just a matter of time before there will be enough funds to payout. Also, you can help speed this up by encouraging others to transact in ROGUE] + + Of course, the most direct way to win, is to get the amulet and come back out of the dungeon. The winner will get all of the buyins from all the players in addition to 0.01 ROGUE for every ingame gold. + + The above alone is enough to make the timeless classic solitaire game into a captivating multiplayer game, where real coins are at stake. However, there is an even better aspect to ROGUE! Whenever your player survives a game, even when you bailout, the entire player and his pack is preserved on the blockchain and becomes a nonfungible asset that you can trade for ROGUE. + + Additionally, instead of just being a collectors item with unique characteristics, the rogue playerdata can be used in any ROGUE game. Just specify the txid that created your character when you register and your character is restored. The better your characteristics your playerdata has, the more likely you are to win in multiplayer mode to win all the buyins. So there is definite economic value to a strong playerdata. + + You can farm characters in single player mode to earn ROGUE or to make competitive playerdata sets. You can purchase existing playerdata for collecting, or for using in battle. + + Here is how to play: + + ./komodo-cli -ac_name=ROGUE cclib newgame 17 \"[3,10]\" -> this will create a hex transaction that when broadcast with sendrawtransaction will get a gametxid onto the blockchain. This specific command was for 3 players and a buyin of 10 ROGUE. Lets assume the gametxid is 4fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a, most all the other commands will need the gametxid. + + you can always find all the existing games with: + + ./komodo-cli -ac_name=ROGUE cclib pending 17 + + and info about a specific game with: + + ./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" + + due to quirks of various parsing at the shell, rpc and internal level, the above convention is used where %22 is added where " should be. also all fields are separated by , without any space. + + When you do a gameinfo command it will show a "run" field and that will tell you if you are registered for the game or not. If not, the "run" field shows the register syntax you need to do, if you are registered, it will show the command line to start the rogue game that is playing the registered game. + +./komodo-cli -ac_name=ROGUE cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22playerdata_txid%22]\" + + If you want to cash in your ingame gold and preserve your character for another battle, do the bailout: + +./komodo-cli -ac_name=ROGUE cclib bailout 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" + + If you won your game before anybody else did or if you are the last one left who didnt bailout, you can claim the prize: + + ./komodo-cli -ac_name=ROGUE cclib highlander 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" + + The txid you get from the bailout or highlander transactions is the "playerdata_txid" that you can use in future games. + + + Transaction details creategame vout0 -> txfee highlander vout TCBOO creation - vout1 -> txfee highlander vout TCBOO playerdata used - vout2 to vout.maxplayers -> 1of2 registration ROGUE_REGISTRATIONSIZE batons + vout1 -> txfee highlander vout TCBOO playerdata used (deprecated) + vout2 to vout.maxplayers+2 -> 1of2 registration ROGUE_REGISTRATIONSIZE batons + vout2+maxplayers to vout.2*maxplayers+2 -> 1of2 registration txfee batons for game completion - registration + register vin0 -> ROGUE_REGISTRATIONSIZE 1of2 registration baton from creategame vin1 -> optional nonfungible character vout @ vin2 -> original creation TCBOO playerdata used @@ -40,13 +87,13 @@ vin0 -> txfee 1of2 baton from registration or previous keystrokes opret -> user input chars - bailout: must be within 777 blocks of last keystrokes + bailout: must be within ROGUE_MAXKEYSTROKESGAP blocks of last keystrokes vin0 -> keystrokes baton of completed game with Q vout0 -> 1% ingame gold highlander vin0 -> txfee highlander vout from creategame TCBOO creation - vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 777 blocks since last keystrokes, it is forfeit + vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than ROGUE_MAXKEYSTROKESGAP blocks since last keystrokes, it is forfeit vins -> rest of unspent registration utxo so all newgame vouts are spent vout0 -> nonfungible character with pack @ vout1 -> 1% ingame gold and all the buyins @@ -235,6 +282,8 @@ uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 } } } + obj.push_back(Pair("alive",rogue_playersalive(numplayers,gametxid,maxplayers))); + obj.push_back(Pair("numplayers",numplayers)); obj.push_back(Pair("maxplayers",maxplayers)); obj.push_back(Pair("buyin",ValueFromAmount(buyin))); return(seed); @@ -328,6 +377,23 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub return(-1); } +int32_t rogue_playersalive(int32_t &numplayers,uint256 gametxid,int32_t maxplayers) +{ + int32_t i,alive = 0; + numplayers = 0; + for (i=0; i &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr) +int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) { int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; - numkeys = 0; + numkeys = numplayers = 0; for (i=0; i= 0 ) { if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) { + numplayers++; Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(destaddr,ccaddr) == 0 ) { matches++; regslot = i; matchtx = spenttx; - } else fprintf(stderr,"%d+2 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } //else fprintf(stderr,"%d+2 doesnt match %s vs %s\n",i,ccaddr,destaddr); } //else fprintf(stderr,"%d+2 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); } //else fprintf(stderr,"%d+2 unspent\n",i); } @@ -420,7 +487,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { @@ -428,7 +495,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-2)); - if ( (retval= rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr)) == 0 ) + if ( (retval= rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) { obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonaddr",destaddr)); @@ -574,7 +641,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find playerdata to spend")); else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,inputsum-txfee,roguepk,mypk)); + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_registeropret(gametxid,playertxid)); @@ -593,7 +660,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t regslot,numkeys,batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -606,7 +673,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr) == 0 ) + if ( rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers) == 0 ) { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { @@ -623,24 +690,6 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - //vin0 -> highlander vout from creategame TCBOO - //vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 60 blocks since last keystrokes, it is forfeit - //vins2+ -> rest of unspent registration utxo so all newgame vouts are spent - //vout0 -> nonfungible character with pack @ - //vout1 -> 1% ingame gold and all the buyins - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); - if ( txfee == 0 ) - txfee = 10000; - // make sure no highlander and it is an actual ingame win - result.push_back(Pair("result","success")); - result.push_back(Pair("name","rogue")); - result.push_back(Pair("method","highlander")); - return(result); -} - #define MAXPACK 23 struct rogue_packitem { @@ -655,22 +704,38 @@ struct rogue_player int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); #define ROGUE_DECLARED_PACK -UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,char *method) { + //vin0 -> highlander vout from creategame TCBOO + //vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 60 blocks since last keystrokes, it is forfeit + //vins2+ -> rest of unspent registration utxo so all newgame vouts are spent + //vout0 -> nonfungible character with pack @ + //vout1 -> 1% ingame gold and all the buyins + // detect if last to bailout // vin0 -> kestrokes baton of completed game with Q // vout0 -> playerdata marker // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,CCchange=0; int32_t i,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32]; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); result.push_back(Pair("name","rogue")); - result.push_back(Pair("method","bailout")); + result.push_back(Pair("method",method)); + if ( strcmp(method,"bailout") == 0 ) + { + funcid = 'Q'; + mult = 100000; + } + else + { + funcid = 'H'; + mult = 1000000; + } if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) @@ -679,7 +744,9 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 ) + if ( maxplayers == 1 ) + mult /= 2; + if ( rogue_findbaton(cp,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 && keystrokes != 0 ) { UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); @@ -689,7 +756,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; iunspendableCCaddr)) > (uint64_t)P.gold*1000000 ) - CCchange = (inputsum - (uint64_t)P.gold*1000000); fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); - mtx.vout.push_back(CTxOut(P.gold*1000000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + cashout = (uint64_t)P.gold * mult; + if ( funcid == 'H' ) + { + if ( (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1 && (P.dungeonlevel > 1 || P.gold < 10000 || P.level < 20) ) + return(cclib_error(result,"highlander must be a winner or last one standing")); + cashout += numplayers * buyin; + } + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) + CCchange = (inputsum - cashout); + mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); } mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(gametxid,mypk,newdata)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(funcid,gametxid,mypk,newdata)); return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); @@ -722,6 +796,16 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + return(rogue_finishgame(txfee,cp,params,"bailout")); +} + +UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + return(rogue_finishgame(txfee,cp,params,"highlander")); +} + UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; From c48d0cabcaf57ff3613911e245a4b124e7314710 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 06:40:01 -1100 Subject: [PATCH 1846/3904] Syntax --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5c1fa9cba..d647163bc 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -163,10 +163,10 @@ CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std: return(opret); } -CScript rogue_highlanderopret(uint256 gametxid,CPubKey pk,std::vectorplayerdata) +CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,CPubKey pk,std::vectorplayerdata) { CScript opret; uint8_t evalcode = EVAL_ROGUE; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << pk << playerdata); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << pk << playerdata); return(opret); } @@ -259,7 +259,7 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) { - CBlockIndex *pindex; int32_t ht,delay; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; + CBlockIndex *pindex; int32_t ht,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; if ( GetTransaction(gametxid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); @@ -379,7 +379,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub int32_t rogue_playersalive(int32_t &numplayers,uint256 gametxid,int32_t maxplayers) { - int32_t i,alive = 0; + int32_t i,alive = 0; uint64_t txfee = 10000; numplayers = 0; for (i=0; i Date: Wed, 6 Feb 2019 06:40:52 -1100 Subject: [PATCH 1847/3904] Reorder --- src/cc/rogue_rpc.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d647163bc..f6fd057a0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -257,6 +257,22 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } +int32_t rogue_playersalive(int32_t &numplayers,uint256 gametxid,int32_t maxplayers) +{ + int32_t i,alive = 0; uint64_t txfee = 10000; + numplayers = 0; + for (i=0; i Date: Wed, 6 Feb 2019 06:44:00 -1100 Subject: [PATCH 1848/3904] Allocate enough for new game --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f6fd057a0..5501c2a1e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -565,7 +565,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); rogue_univalue(result,"newgame",maxplayers,buyin); - required = (3*txfee + maxplayers*ROGUE_REGISTRATIONSIZE); + required = (3*txfee + maxplayers*(ROGUE_REGISTRATIONSIZE+txfee)); if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,required,16,cp->unspendableCCaddr)) >= required ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO creation From 22d3a27d5e12e1a4668f2357ebe29f2220b89311 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:01:17 -1100 Subject: [PATCH 1849/3904] [] -> * --- src/cc/rogue/save.c | 2 +- src/cc/rogue_rpc.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 8a40a9fb8..c96aa6b13 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -22,7 +22,7 @@ typedef struct stat STAT; -extern char version[], encstr[]; +extern char *version, *encstr; static STAT sbuf; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5501c2a1e..7a54366ae 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -120,12 +120,12 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" -// cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" +// cclib gameinfo 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22]\" +// cclib register 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22%22]\" -// cclib keystrokes 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\" +// cclib register 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22%22]\" +// cclib keystrokes 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22deadbeef%22]\" +// cclib bailout 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22]\" /* gold.218 hp.20 strength.16 level.3 exp.22 2 object (Some food) x.0 y.0 type.58 pack.(a:97) From fee10112f01153b1ef542357c034e0f5ff746a29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:02:11 -1100 Subject: [PATCH 1850/3904] * --- src/cc/rogue/vers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/vers.c b/src/cc/rogue/vers.c index dcca986b1..b6c5237d1 100644 --- a/src/cc/rogue/vers.c +++ b/src/cc/rogue/vers.c @@ -12,6 +12,6 @@ */ char *release = "5.4.4"; -char encstr[] = "\300k||`\251Y.'\305\321\201+\277~r\"]\240_\223=1\341)\222\212\241t;\t$\270\314/<#\201\254"; +char *encstr = "\300k||`\251Y.'\305\321\201+\277~r\"]\240_\223=1\341)\222\212\241t;\t$\270\314/<#\201\254"; char statlist[] = "\355kl{+\204\255\313idJ\361\214=4:\311\271\341wK<\312\321\213,,7\271/Rk%\b\312\f\246"; -char version[] = "rogue (rogueforge) 09/05/07"; +char *version = "rogue (rogueforge) 09/05/07"; From 518f11f77d83880cdac383aa623eb97bcbf9f8c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:02:48 -1100 Subject: [PATCH 1851/3904] Statlist --- src/cc/rogue/save.c | 4 ++-- src/cc/rogue/vers.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index c96aa6b13..adec30e2e 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -333,7 +333,7 @@ encwrite(char *start, size_t size, FILE *outf) { char *e1, *e2, fb; int temp; - extern char statlist[]; + extern char *statlist; size_t o_size = size; e1 = encstr; e2 = statlist; @@ -371,7 +371,7 @@ encread(char *start, size_t size, FILE *inf) char *e1, *e2, fb; int temp; size_t read_size; - extern char statlist[]; + extern char *statlist; fb = 0; diff --git a/src/cc/rogue/vers.c b/src/cc/rogue/vers.c index b6c5237d1..6fbf7be87 100644 --- a/src/cc/rogue/vers.c +++ b/src/cc/rogue/vers.c @@ -13,5 +13,5 @@ char *release = "5.4.4"; char *encstr = "\300k||`\251Y.'\305\321\201+\277~r\"]\240_\223=1\341)\222\212\241t;\t$\270\314/<#\201\254"; -char statlist[] = "\355kl{+\204\255\313idJ\361\214=4:\311\271\341wK<\312\321\213,,7\271/Rk%\b\312\f\246"; +char *statlist = "\355kl{+\204\255\313idJ\361\214=4:\311\271\341wK<\312\321\213,,7\271/Rk%\b\312\f\246"; char *version = "rogue (rogueforge) 09/05/07"; From fdec90dc57e09df4a21a28e6e43d22fe225eb135 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:41:13 -1100 Subject: [PATCH 1852/3904] condCC2 --- src/cc/CCtx.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 932677e20..111fc11ad 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -46,9 +46,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,flag,utxovout,n,err = 0; - char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], tokensunspendable[64]; + char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], tokensunspendable[64],CC1of2CCaddr[64]; uint8_t *privkey, myprivkey[32], unspendablepriv[32], tokensunspendablepriv[32], *msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; + CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CPubKey unspendablepk /*, tokensunspendablepk*/; struct CCcontract_info *cpTokens, tokensC; globalpk = GetUnspendable(cp,0); @@ -73,6 +73,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran unspendablepk = GetUnspendable(cp, unspendablepriv); GetCCaddress(cp, unspendable, unspendablepk); othercond = MakeCCcond1(cp->evalcode, unspendablepk); + + CCaddr1of2set(cp,unspendablepk,unspendablepk,unspendablepriv,CC1of2CCaddr); + //printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); // tokens support: @@ -212,6 +215,13 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); cond = othercond1of2; } + else if ( strcmp(CC1of2CCaddr,destaddr) == 0 ) + { + privkey = unspendablepriv; + if (condCC2 == 0) + condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk); + cond = condCC2; + } // check if this is spending from 1of2 cc tokens addr: else if (strcmp(cp->tokens1of2addr, destaddr) == 0) { @@ -267,6 +277,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } if ( mycond != 0 ) cc_free(mycond); + if ( condCC2 != 0 ) + cc_free(condCC2); if ( othercond != 0 ) cc_free(othercond); if ( othercond2 != 0 ) From da2b3e31f80b98108bd69b7b79957c9079a3619a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:45:01 -1100 Subject: [PATCH 1853/3904] +print --- src/cc/CCtx.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 111fc11ad..cd78ef045 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -209,7 +209,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = cp->coins1of2priv;//myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -217,6 +217,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } else if ( strcmp(CC1of2CCaddr,destaddr) == 0 ) { + fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); privkey = unspendablepriv; if (condCC2 == 0) condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk); From 373fd28f64ccc1a1bfffd1594957cc8e1dc9b2ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:48:37 -1100 Subject: [PATCH 1854/3904] +print --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7a54366ae..46df85078 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -725,6 +725,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); result.push_back(Pair("name","rogue")); result.push_back(Pair("method",method)); + result.push_back(Pair("myrogueaddr",myrogueaddr)); if ( strcmp(method,"bailout") == 0 ) { funcid = 'Q'; From b70e4824481c26947065cac5bac851caac4dc50b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:51:16 -1100 Subject: [PATCH 1855/3904] Fix condCC2 --- src/cc/CCtx.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index cd78ef045..b0cea19e1 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -73,8 +73,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran unspendablepk = GetUnspendable(cp, unspendablepriv); GetCCaddress(cp, unspendable, unspendablepk); othercond = MakeCCcond1(cp->evalcode, unspendablepk); - - CCaddr1of2set(cp,unspendablepk,unspendablepk,unspendablepriv,CC1of2CCaddr); + GetCCaddress1of2(cp,CC1of2CCaddr,unspendablepk,unspendablepk); //printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); // tokens support: From 0abced67cab4d3fc912fbe4169c4873e5a54f497 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 07:56:57 -1100 Subject: [PATCH 1856/3904] Fix 'H' edgewise --- src/cc/rogue_rpc.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 46df85078..d48a50b65 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -114,6 +114,9 @@ once you have a non-fungible token, ownership of it can be transferred or traded or spent in a game */ +// todo: +// verify playerdata is usable +// verify keystrokes tx is confirmed //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -126,19 +129,20 @@ // cclib register 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22%22]\" // cclib keystrokes 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22deadbeef%22]\" // cclib bailout 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22]\" +// eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd /* - gold.218 hp.20 strength.16 level.3 exp.22 2 -object (Some food) x.0 y.0 type.58 pack.(a:97) -object (+1 ring mail [protection 4] (being worn)) x.0 y.0 type.93 pack.(b:98) -object (A +1,+1 mace (weapon in hand)) x.0 y.0 type.41 pack.(c:99) -object (A +1,+0 short bow) x.0 y.0 type.41 pack.(d:100) -object (28 +0,+0 arrows) x.0 y.0 type.41 pack.(e:101) -object (A scroll titled 'eeptanelg eep agitwhon wunayot') x.9 y.13 type.63 pack.(f:102) -object (A scroll titled 'aks snodo') x.13 y.3 type.63 pack.(g:103) -object (A scroll titled 'itenejbot lechlech') x.35 y.13 type.63 pack.(h:104) -da000000140000001000000003000000160000000800000002000000000000003a0000000000000001000000000000000000000000000000000000001000000000000000000000000000000000000000000000005d00000000000000010000000100000000000000000000000600000012000000000000000000000000000000000000000000000029000000ffffffff010000000000000001000000010000000000000012000000000000003278340000000000317833000000000029000000ffffffff010000000200000001000000000000000000000012000000000000003178310000000000317831000000000029000000020000001c000000030000000000000000000000000000001e00000000000000317831000000000032783300000000003f00000000000000010000000c00000000000000000000000b0000001000000000000000307830000000000030783000000000003f00000000000000010000000300000000000000000000000b0000001000000000000000307830000000000030783000000000003f00000000000000010000000000000000000000000000000b000000100000000000000030783000000000003078300000000000 packsize.8 n.448 - -$$$gold.218 hp.20 strength.16 level.3 exp.22 dl.2 n.1 size.1228 + 2409 gold.209 hp.17 strength.16 level.3 exp.22 3 + object (2 rations of food) x.0 y.0 type.58 pack.(a:97) + object (+1 ring mail [protection 4] (being worn)) x.0 y.0 type.93 pack.(b:98) + object (A +1,+1 mace (weapon in hand)) x.0 y.0 type.41 pack.(c:99) + object (A +1,+0 short bow) x.0 y.0 type.41 pack.(d:100) + object (25 +0,+0 arrows) x.0 y.0 type.41 pack.(e:101) + object (A scroll titled 'zokkli ta grebot sristael') x.61 y.12 type.63 pack.(f:102) + object (A scroll titled 'val riip') x.42 y.18 type.63 pack.(g:103) + d1000000110000001000000003000000160000000700000003000000000000003a0000000000000002000000000000000000000000000000000000001000000000000000000000000000000000000000000000005d00000000000000010000000100000000000000000000000600000012000000000000000000000000000000000000000000000029000000ffffffff010000000000000001000000010000000000000012000000000000003278340000000000317833000000000029000000ffffffff0100000002000000010000000000000000000000120000000000000031783100000000003178310000000000290000000200000019000000030000000000000000000000000000001e00000000000000317831000000000032783300000000003f00000000000000010000000000000000000000000000000b0000001000000000000000307830000000000030783000000000003f00000000000000010000000800000000000000000000000b000000100000000000000030783000000000003078300000000000 packsize.7 n.396 + (0 319) (1 9) (2 3) (3 3) (6 1) (7 1) (8 1) (11 2) (16 4) (17 1) (18 3) (22 1) (25 1) (30 1) (41 3) (48 8) (49 7) (50 2) (51 2) (52 1) (58 1) (63 2) (93 1) (120 10) (209 1) (255 8) nonz.26 + + extracted $$$gold.209 hp.17 strength.16 level.3 exp.22 dl.3 n.1 size.1228 ca995aa934b5365e9b86d3db97919e3c26ea03ee6e3045bfc9b05a079ab8b130 */ @@ -771,9 +775,9 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); cashout = (uint64_t)P.gold * mult; - if ( funcid == 'H' ) + if ( funcid == 'H' && maxplayers > 1 ) { - if ( (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1 && (P.dungeonlevel > 1 || P.gold < 10000 || P.level < 20) ) + if ( numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1 && (P.dungeonlevel > 1 || P.gold < 10000 || P.level < 20) ) return(cclib_error(result,"highlander must be a winner or last one standing")); cashout += numplayers * buyin; } From 0b96f2004aae5e7bf491bfc8256dba9345e15758 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 08:01:04 -1100 Subject: [PATCH 1857/3904] Alive/finished status --- src/cc/rogue_rpc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d48a50b65..25aeca57a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -143,7 +143,7 @@ (0 319) (1 9) (2 3) (3 3) (6 1) (7 1) (8 1) (11 2) (16 4) (17 1) (18 3) (22 1) (25 1) (30 1) (41 3) (48 8) (49 7) (50 2) (51 2) (52 1) (58 1) (63 2) (93 1) (120 10) (209 1) (255 8) nonz.26 extracted $$$gold.209 hp.17 strength.16 level.3 exp.22 dl.3 n.1 size.1228 - ca995aa934b5365e9b86d3db97919e3c26ea03ee6e3045bfc9b05a079ab8b130 + */ CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) @@ -500,6 +500,9 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet obj.push_back(Pair("slot",(int64_t)vout-2)); if ( (retval= rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) { + if ( CCgettxout(gametxid,2+maxplayers+i,1) == txfee ) + obj.push_back(Pair("status","alive")); + else obj.push_back(Pair("status","finished")); obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonaddr",destaddr)); obj.push_back(Pair("batonvout",(int64_t)batonvout)); From 47bf729f9caa3fb7a4018cb03a64cb526d2032da Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 08:02:46 -1100 Subject: [PATCH 1858/3904] Fix --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 25aeca57a..aef95c041 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -500,7 +500,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet obj.push_back(Pair("slot",(int64_t)vout-2)); if ( (retval= rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) { - if ( CCgettxout(gametxid,2+maxplayers+i,1) == txfee ) + if ( CCgettxout(gametxid,maxplayers+vout,1) == txfee ) obj.push_back(Pair("status","alive")); else obj.push_back(Pair("status","finished")); obj.push_back(Pair("baton",batontxid.ToString())); From 0166734f1dc78ba284947ac773cea16708d21591 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 08:03:44 -1100 Subject: [PATCH 1859/3904] Three --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index aef95c041..1fb00530c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -500,7 +500,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet obj.push_back(Pair("slot",(int64_t)vout-2)); if ( (retval= rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) { - if ( CCgettxout(gametxid,maxplayers+vout,1) == txfee ) + if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) obj.push_back(Pair("status","alive")); else obj.push_back(Pair("status","finished")); obj.push_back(Pair("baton",batontxid.ToString())); From 5df7d49d5c3403c588aa0ee4e68386d26a83e39a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Feb 2019 19:08:49 -1100 Subject: [PATCH 1860/3904] Enable ./configure --- src/cc/makerogue | 2 +- src/cc/rogue_rpc.cpp | 9 +++++++-- src/komodo_utils.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index f7ee26669..08c86dee8 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,5 +1,5 @@ cd rogue; -#./configure # only need this first time +./configure # only need this first time make; cd .. gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1fb00530c..777b02f80 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -116,10 +116,15 @@ // todo: // verify playerdata is usable -// verify keystrokes tx is confirmed +// verify keystrokes tx is in mempool and confirmed +// check that bailout is legal, ie. proper gametxid vin +// verify amulet possession in pack +// display playerdata (user comments?, or fully decode) +// verify playerdata can be used and has same initial level +// prevent running gui mode when keystrokes txid already there //////////////////////// start of CClib interface -//./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & +//./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & // cclib newgame 17 \"[3,10]\" // cclib pending 17 diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f492173a7..f5c92cf84 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1782,6 +1782,7 @@ void komodo_args(char *argv0) ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); if ( ASSETCHAINS_CC != 0 ) { + ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); Split(GetArg("-ac_ccenable",""), ccenables, 0); for (i=nonz=0; i<0x100; i++) { @@ -1805,7 +1806,6 @@ void komodo_args(char *argv0) ASSETCHAINS_CCDISABLES[ccenables[i] & 0xff] = 0; } } - ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); /*if ( ASSETCHAINS_CCLIB.size() > 0 ) { for (i=first; i<=last; i++) From 170ca55e4648ad7d2ac129eada38e414a566083d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 7 Feb 2019 17:07:49 +0800 Subject: [PATCH 1861/3904] New miner, some prints. YUse equihash difficulty algo for VerusHash and PoS64 --- src/komodo_bitcoind.h | 77 ++++++++++++++++++++++----------------- src/miner.cpp | 84 ++++++++++++++++++++++++++----------------- src/pow.cpp | 17 +++++++-- 3 files changed, 111 insertions(+), 67 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d22ac895f..fc4c66eb5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1433,14 +1433,15 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh diff = (iter + blocktime - txtime - minage); if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) { - if ( PoSperc < ASSETCHAINS_STAKED ) + /*if ( PoSperc < ASSETCHAINS_STAKED ) { // Under PoS % target and we need to increase diff. //fprintf(stderr, "PoS too low diff.%i changed to.",diff); diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) * ( nHeight < 50 ? 1000 : 1)); //fprintf(stderr, "%i \n",diff); } - else if ( PoSperc > ASSETCHAINS_STAKED ) + else */ + if ( PoSperc > ASSETCHAINS_STAKED ) { // Over PoS target need to lower diff. //fprintf(stderr, "PoS too high diff.%i changed to.",diff); @@ -1460,14 +1461,17 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh coinage = (value * diff); if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) { - if ( blocktime+iter+segid*2 > prevtime+128 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); - } - else - { - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + if ( PoSperc < ASSETCHAINS_STAKED ) + { + // Under PoS % target and we need to increase diff. + //fprintf(stderr, "PoS too low diff.%i changed to.",diff); + if ( blocktime+iter+segid*2 > prevtime+128 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); + //fprintf(stderr, "%i \n",diff); + } } + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); coinage256 = arith_uint256(coinage+1); hashval = ratio * (UintToArith256(hash) / coinage256); if ( hashval <= bnTarget ) @@ -1774,9 +1778,9 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); -uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) +uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) { - if ( numnotaries == 0 ) + if ( notarycount == 0 ) { fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); @@ -1793,18 +1797,41 @@ uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) } // how many block since last notarisation. int32_t n = height - notarizedht; - fprintf(stderr, "blocks since last notarisation: %i\n",n); + fprintf(stderr, "blocks since last notarization: %i\n",n); // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. AmountToPay = ASSETCHAINS_NOTARY_PAY*n; //fprintf(stderr, "AmountToPay.%lu\n",AmountToPay); - ret = AmountToPay / numnotaries; + ret = AmountToPay / notarycount; fprintf(stderr, "payment per notary.%lu\n",ret); return(ret); } int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); +int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len) +{ + // Check the notarisation is valid, and extract notarised height. + uint64_t voutmask; + uint8_t scriptbuf[10001]; + int32_t isratification,specialtx,notarizedheight; + + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) + { + memcpy(scriptbuf,script,len); + if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) + { + fprintf(stderr, ">>>>>>VALID NOTARIZATION ht.%i\n",notarizedheight); + } + else + { + fprintf(stderr, "<<<<< &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len) { // fetch notary pubkey array. @@ -1818,25 +1845,11 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); - // Check the notarisation is valid, and extract notarised height. - uint64_t voutmask; - uint8_t scriptbuf[10001]; - int32_t isratification,specialtx,notarizedheight; - - if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) - { - memcpy(scriptbuf,script,len); - if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) - { - fprintf(stderr, "notarypay found VALID NOTARIZATION ht.%i\n",notarizedheight); - } - else - { - fprintf(stderr, "notarypay found INVALID NOTARIZATION ht.%i\n",notarizedheight); - return(0); - } - } else return(0); - + // Check the notarisation is valid and get the notarized height to calcualte the payment. + int32_t notarizedheight = komodo_getnotarizedheight(timestamp, height, script, len); + if ( notarizedheight == 0 ) + return(0); + // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); diff --git a/src/miner.cpp b/src/miner.cpp index 8f1792f83..0b0e12895 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,6 +154,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); +int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -174,7 +175,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarisationBlock = false; std::vector NotarisationNotaries; - static std::string invalidnotarisation; //fprintf(stderr,"create new block\n"); // Create new block @@ -233,6 +233,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetAdjustedTime(); + + int32_t last_notarizedheight = 0; + if (proposedTime == nMedianTimePast) { // too fast or stuck, this addresses the too fast issue, while moving @@ -297,6 +300,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CAmount nTotalIn = 0; bool fMissingInputs = false; bool fNotarisation = false; + std::vector TMP_NotarisationNotaries = {0}; if (tx.IsCoinImport()) { CAmount nValueIn = GetCoinImportValue(tx); // burn amount @@ -304,6 +308,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { //int numNotaryVins = 0; + TMP_NotarisationNotaries.clear(); bool fToCryptoAddress = false; if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; @@ -356,39 +361,22 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) { - //numNotaryVins++; - if ( Notarisations == 0 ) - { - // Until we get a valid notarization this will always be 0. - // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. - NotarisationNotaries.push_back(i); - } + // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. + TMP_NotarisationNotaries.push_back(i); } } } dPriority += (double)nValueIn * nConf; } - if ( numSN != 0 && NotarisationNotaries.size() >= numSN / 5 ) + if ( numSN != 0 && TMP_NotarisationNotaries.size() >= numSN / 5 ) { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) - std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); - if ( checkdupes.size() != NotarisationNotaries.size() ) + std::set checkdupes( TMP_NotarisationNotaries.begin(), TMP_NotarisationNotaries.end() ); + if ( checkdupes.size() != TMP_NotarisationNotaries.size() ) { - NotarisationNotaries.clear(); fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); - } - else if ( tx.GetHash().ToString() == invalidnotarisation ) - { - // check if the last notarisation we tried was flagged as invalid. - // then clear it, in case next time it is seen as valid. - NotarisationNotaries.clear(); - invalidnotarisation = ""; - fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); - } - else - fNotarisation = true; - } else NotarisationNotaries.clear(); - + } else fNotarisation = true; + } nTotalIn += tx.GetShieldedValueIn(); } @@ -405,10 +393,43 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (fNotarisation) { - dPriority = 1e16; - Notarisations++; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation[%i] %s set to maximum priority\n",Notarisations,hash.ToString().c_str()); + // check if the notarization found is actually valid. + if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) + { + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) + { + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) + { + if ( last_notarizedheight == 0 ) + { + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + last_notarizedheight = notarizedheight; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + } + else if ( notarizedheight > last_notarizedheight ) + continue; // leave this notarisation for the next block, it will be valid! + else + { + // we need to remove the last seen notarzation from block + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& Tx = *(vecPriority.front().get<2>()); + // add this one as its valid before the other one. + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); + } + } + } + } } else if ( dPriority == 1e16 ) { @@ -421,8 +442,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - continue; // If we have added a notarisation already skip the next one. There can only be one per block. else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } @@ -700,11 +719,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { + fprintf(stderr, ">>>>>MINER NotarisationNotaries.%li\n",NotarisationNotaries.size()); uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); - invalidnotarisation = pblock->vtx[1].GetHash().ToString(); + // invalidnotarisation = pblock->vtx[1].GetHash().ToString(); if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) { LEAVE_CRITICAL_SECTION(cs_main); diff --git a/src/pow.cpp b/src/pow.cpp index d36357800..1716099ee 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -44,10 +44,15 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) + if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0) return lwmaGetNextWorkRequired(pindexLast, pblock, params); - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); + arith_uint256 bnLimit; + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) + bnLimit = UintToArith256(params.powLimit); + else + bnLimit = UintToArith256(params.powAlternate); + unsigned int nProofOfWorkLimit = bnLimit.GetCompact(); // Genesis block if (pindexLast == NULL ) return nProofOfWorkLimit; @@ -102,7 +107,13 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, nActualTimespan = params.MaxActualTimespan(); // Retarget - const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); + arith_uint256 bnLimit; + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) + bnLimit = UintToArith256(params.powLimit); + else + bnLimit = UintToArith256(params.powAlternate); + + const arith_uint256 bnPowLimit = bnLimit; //UintToArith256(params.powLimit); arith_uint256 bnNew {bnAvg}; bnNew /= params.AveragingWindowTimespan(); bnNew *= nActualTimespan; From f40a353e088d1191265a7bc722e6528c660eb3d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Feb 2019 07:27:00 -1100 Subject: [PATCH 1862/3904] >> keystrokes.log --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 62a8a2e1c..c52002447 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -148,7 +148,7 @@ void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to l for (i=0; i> keystrokes.log",Gametxidstr,hexstr); if ( system(cmd) != 0 ) fprintf(stderr,"error issuing (%s)\n",cmd); } From e5198d57b2ca8a68ca67c3cde35c255a9ba0ed55 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Feb 2019 07:31:00 -1100 Subject: [PATCH 1863/3904] -print --- src/cc/CCtx.cpp | 4 ++-- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index b0cea19e1..93bed32f7 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -208,7 +208,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = cp->coins1of2priv;//myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -216,7 +216,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } else if ( strcmp(CC1of2CCaddr,destaddr) == 0 ) { - fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); + //fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); privkey = unspendablepriv; if (condCC2 == 0) condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 777b02f80..1c149e9b1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -483,7 +483,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("keystrokes[%d]\n",numkeys); + //printf("keystrokes[%d]\n",numkeys); return(0); } } From f62017f83e6ec8902305af387235a8bd3fe2e327 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 8 Feb 2019 11:52:43 +0800 Subject: [PATCH 1864/3904] try fix --- src/miner.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0b0e12895..e8245b710 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -415,12 +415,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } else if ( notarizedheight > last_notarizedheight ) continue; // leave this notarisation for the next block, it will be valid! - else + else if ( notarizedheight == last_notarizedheight ) + continue; // this shouldnt happen :S + else { // we need to remove the last seen notarzation from block - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); const CTransaction& Tx = *(vecPriority.front().get<2>()); + TxPriorityCompare comparer(0); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); // add this one as its valid before the other one. NotarisationNotaries = TMP_NotarisationNotaries; dPriority = 1e16; From 35daec70b12fddc51aa752f9ec5539b31d32085d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 01:20:00 -1100 Subject: [PATCH 1865/3904] ReacceptWalletTransactions don't remove from wallet if initial block download --- src/cc/rogue_rpc.cpp | 1 + src/wallet/wallet.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1c149e9b1..a7702d244 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -116,6 +116,7 @@ // todo: // verify playerdata is usable +// detect playerdeath/quit to prevent illegal keystrokes vector // verify keystrokes tx is in mempool and confirmed // check that bailout is legal, ie. proper gametxid vin // verify amulet possession in pack diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d171812c4..47b6e6df4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2810,9 +2810,12 @@ void CWallet::ReacceptWalletTransactions() } } } - for (auto hash : vwtxh) + if ( IsInitialBlockDownload() == 0 ) { - EraseFromWallet(hash); + for (auto hash : vwtxh) + { + EraseFromWallet(hash); + } } } From 54c02fe3abcdf89c369e3d26714b512f8c5d30b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 01:59:53 -1100 Subject: [PATCH 1866/3904] +print --- src/cc/rogue_rpc.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a7702d244..20c2a077e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -129,12 +129,12 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22]\" -// cclib register 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22]\" +// cclib gameinfo 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" +// cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22%22]\" -// cclib keystrokes 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22]\" +// cclib register 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd%22]\" +// cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" +// cclib bailout 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" // eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd /* 2409 gold.209 hp.17 strength.16 level.3 exp.22 3 @@ -381,6 +381,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); + fprintf(stderr,"player data [%d] [%c]\n",script[0],script[1]); if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&highlander,script+2,sizeof(highlander)); From 652f1dc199b3d2d89bf6e788b098339ab35c18bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 02:09:22 -1100 Subject: [PATCH 1867/3904] Skip rev --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 20c2a077e..08a5351d7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -385,7 +385,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&highlander,script+2,sizeof(highlander)); - highlander = revuint256(highlander); + //highlander = revuint256(highlander); fprintf(stderr,"got highlander.%s\n",highlander.ToString().c_str()); if ( rogue_iterateplayer(highlander,playertxid) == 0 ) { From 4fa5d896590d4ab3e63cb19a1f1934b175d008c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 02:23:39 -1100 Subject: [PATCH 1868/3904] Test --- src/cc/rogue_rpc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 08a5351d7..53288ffe0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -386,8 +386,10 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { memcpy(&highlander,script+2,sizeof(highlander)); //highlander = revuint256(highlander); - fprintf(stderr,"got highlander.%s\n",highlander.ToString().c_str()); - if ( rogue_iterateplayer(highlander,playertxid) == 0 ) + fprintf(stderr,"got vin.%s \n",playertx.vin[1].prevout.hash.ToString().c_str()); + // verify highlander is a valid gametxid, verify playertxid is linked to it + //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) + if ( playertx.vin[1].prevout.hash == highlander ) { if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) { From 97bc919d2fabffe0623d29af352dae82c4be843a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 02:26:11 -1100 Subject: [PATCH 1869/3904] Test --- src/cc/rogue_rpc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 53288ffe0..5dbf3d860 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -381,7 +381,6 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - fprintf(stderr,"player data [%d] [%c]\n",script[0],script[1]); if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&highlander,script+2,sizeof(highlander)); @@ -389,7 +388,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub fprintf(stderr,"got vin.%s \n",playertx.vin[1].prevout.hash.ToString().c_str()); // verify highlander is a valid gametxid, verify playertxid is linked to it //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) - if ( playertx.vin[1].prevout.hash == highlander ) + //if ( playertx.vin[1].prevout.hash == highlander ) { if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) { From c71dc476b552f01a95552645a7387b5c707d9524 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 02:26:41 -1100 Subject: [PATCH 1870/3904] - --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5dbf3d860..13128d3c3 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -399,7 +399,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub else return(-3); } } - } else return(-2); + } //else return(-2); } } return(-1); From edd1b42590e98e96246e947b30894f69de45e594 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 02:29:46 -1100 Subject: [PATCH 1871/3904] Test --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 13128d3c3..342379036 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -390,13 +390,13 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) //if ( playertx.vin[1].prevout.hash == highlander ) { - if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) + //if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) { - if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,highlandertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { - if ( highlandertx.vin[0].prevout.hash == origplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) + //if ( highlandertx.vin[0].prevout.hash == origplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) return(0); - else return(-3); + //else return(-3); } } } //else return(-2); From 411df1eb9f73906148289603c182279649cd32f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Feb 2019 02:35:00 -1100 Subject: [PATCH 1872/3904] test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 342379036..5ca5a069a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -132,7 +132,7 @@ // cclib gameinfo 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" // cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%22e7d75f0b2bf0716ad0df87ee331bf52b41e0823e126654c7ec8bac5a15f6d869%22,%22eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd%22]\" +// cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" // cclib bailout 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" // eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd @@ -639,7 +639,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gametxid = juint256(jitem(params,0)); if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( n > 1 && maxplayers > 1 ) + if ( n > 1 ) { playertxid = juint256(jitem(params,1)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) From 528f39542eb3aee516ef0853903d2ee47ec599cd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 9 Feb 2019 00:08:28 +0800 Subject: [PATCH 1873/3904] fix reorg problem --- src/komodo.h | 12 +++++++----- src/komodo_bitcoind.h | 13 +++++++------ src/komodo_notary.h | 3 ++- src/komodo_structs.h | 2 +- src/main.cpp | 12 ++++++------ src/miner.cpp | 2 +- src/rpc/misc.cpp | 6 +++--- src/wallet/wallet.cpp | 2 ++ 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3e9d0946f..b97e4d205 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,15 +695,17 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - /*else - { - fprintf(stderr, "NOT VALID NOTARISATION\n"); - return (-2); - } */ + + // If we are checking a reorged notarisation tx we need to return true. So the coinbase can be recreated, otherwise notaries are not paid, + // if a notarisation TX is reorged before the next notarization happens! + if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) + return(-2); + if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { if ( fJustCheck ) return(-2); + sp->prevNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fc4c66eb5..caa2c4460 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,7 +1776,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) { @@ -1786,14 +1786,15 @@ uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) return(0); } // fetch notarised height - int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + int32_t notarizedht,prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - // dont think this can happen, just sanity check. + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); + // if this is the current checkpoint we will use the previous height. + // incase of reorgs, we still need to create the notary payment. if ( height == notarizedht ) { - fprintf(stderr, "komodo_notarypayamount failed notarized height = height\n"); - return(0); + notarizedht = prevnotarizedht; + fprintf(stderr, "using the current checkpoint, calculating based on previous notarized height!\n"); } // how many block since last notarisation. int32_t n = height - notarizedht; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c4984cee2..dcd99bea1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,13 +452,14 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { *hashp = sp->NOTARIZED_HASH; *txidp = sp->NOTARIZED_DESTTXID; + *prevNotarizedHt = sp->prevNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 6b7c316b6..2f8ba0850 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,prevNOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index 7ec88830b..30b569c3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3909,8 +3909,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t prevMoMheight; uint256 notarizedhash,txid; - komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + int32_t prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; + komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4244,8 +4244,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + int32_t notarizedht,prevnotarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5591,8 +5591,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/miner.cpp b/src/miner.cpp index e8245b710..a0934ce96 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -416,7 +416,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 else if ( notarizedheight > last_notarizedheight ) continue; // leave this notarisation for the next block, it will be valid! else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen :S + continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! else { // we need to remove the last seen notarzation from block diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index b60809da1..d0dd65c41 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a8246903c..330fcb9be 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2836,6 +2836,8 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) void CWallet::ReacceptWalletTransactions() { + if ( IsInitialBlockDownload() ) + return; // If transactions aren't being broadcasted, don't let them into local mempool either if (!fBroadcastTransactions) return; From 3dbbf8cafd4352416bf923bba3c321d98e7d00b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 9 Feb 2019 03:22:57 +0800 Subject: [PATCH 1874/3904] try --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index b97e4d205..5c6e84b98 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -701,7 +701,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) return(-2); - if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( matched != 0 && *notarizedheightp >= sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { if ( fJustCheck ) return(-2); From 0ac9828870f4f68f2c788821a6b827935667dbe4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 9 Feb 2019 03:34:52 +0800 Subject: [PATCH 1875/3904] what --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 5c6e84b98..b97e4d205 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -701,7 +701,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) return(-2); - if ( matched != 0 && *notarizedheightp >= sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { if ( fJustCheck ) return(-2); From be6279d62dec354a3105ec4cab60c995cfc82047 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 03:44:03 -1100 Subject: [PATCH 1876/3904] ASSETCHAINS_BLOCKTIME --- src/chainparams.cpp | 5 +++++ src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/komodo_utils.h | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5c9efb276..177d7604f 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -276,6 +276,11 @@ void *chainparams_commandline(void *ptr) //fprintf(stderr,">>>>>>>> port.%u\n",ASSETCHAINS_P2PPORT); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { + if ( ASSETCHAINS_BLOCKTIME != 60 ) + { + consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks + consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + } mainParams.SetDefaultPort(ASSETCHAINS_P2PPORT); if ( ASSETCHAINS_RPCPORT == 0 ) ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1; diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 0ea97d6db..9f33c6036 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -38,7 +38,7 @@ extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; +extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC,ASSETCHAINS_BLOCKTIME; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; extern uint64_t ASSETCHAINS_SUPPLY; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c85c68451..8215a6b6e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -69,7 +69,7 @@ int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; -uint32_t ASSETCHAINS_LASTERA = 1; +uint32_t ASSETCHAINS_BLOCKTIME = 60,ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; uint8_t ASSETCHAINS_CCDISABLES[256]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f5c92cf84..469cbd21b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1707,6 +1707,7 @@ void komodo_args(char *argv0) WITNESS_CACHE_SIZE = MAX_REORG_LENGTH+10; ASSETCHAINS_CC = GetArg("-ac_cc",0); KOMODO_CCACTIVATE = GetArg("-ac_ccactivate",0); + ASSETCHAINS_BLOCKTIME = GetArg("-ac_blocktime",60); ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); ASSETCHAINS_PRIVATE = GetArg("-ac_private",0); if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) @@ -1899,7 +1900,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_BLOCKTIME != 60 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1989,6 +1990,8 @@ void komodo_args(char *argv0) } fprintf(stderr," <- CCLIB name\n"); } + if ( ASSETCHAINS_BLOCKTIME != 60 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME); } addn = GetArg("-seednode",""); From cec11785df0b14d7404e5fa9cc3a66efa48dcec7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 03:50:42 -1100 Subject: [PATCH 1877/3904] consensusParams --- src/chainparams.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 177d7604f..785ff412c 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -278,8 +278,8 @@ void *chainparams_commandline(void *ptr) { if ( ASSETCHAINS_BLOCKTIME != 60 ) { - consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks - consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + consensusParams.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks + consensusParams.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; } mainParams.SetDefaultPort(ASSETCHAINS_P2PPORT); if ( ASSETCHAINS_RPCPORT == 0 ) From d103970fedbce5210809f4719b3e268cbdd9ad04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 03:51:36 -1100 Subject: [PATCH 1878/3904] mainParams --- src/chainparams.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 785ff412c..655dc8e87 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -278,8 +278,8 @@ void *chainparams_commandline(void *ptr) { if ( ASSETCHAINS_BLOCKTIME != 60 ) { - consensusParams.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks - consensusParams.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + mainParams.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks + mainParams.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; } mainParams.SetDefaultPort(ASSETCHAINS_P2PPORT); if ( ASSETCHAINS_RPCPORT == 0 ) From eae8207fe870adea099f9e1ecb31ef2fa3d6fedb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 03:56:03 -1100 Subject: [PATCH 1879/3904] mainParams.consensus. --- src/chainparams.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 655dc8e87..4c307a6b8 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -278,8 +278,8 @@ void *chainparams_commandline(void *ptr) { if ( ASSETCHAINS_BLOCKTIME != 60 ) { - mainParams.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks - mainParams.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + mainParams.consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks + mainParams.consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; } mainParams.SetDefaultPort(ASSETCHAINS_P2PPORT); if ( ASSETCHAINS_RPCPORT == 0 ) From a68d3a00a2394e007b5bfdcc8305ae10ecc54f1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 04:01:39 -1100 Subject: [PATCH 1880/3904] Move to chainparams.cpp --- src/chainparams.cpp | 2 +- src/komodo_globals.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 4c307a6b8..a47c7fea3 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -91,7 +91,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st */ void *chainparams_commandline(void *ptr); #include "komodo_defs.h" - +uint32_t ASSETCHAINS_BLOCKTIME = 60; const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 8215a6b6e..c85c68451 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -69,7 +69,7 @@ int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; -uint32_t ASSETCHAINS_BLOCKTIME = 60,ASSETCHAINS_LASTERA = 1; +uint32_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; uint8_t ASSETCHAINS_CCDISABLES[256]; From 1f5b5b739458e43bfce8b229c35cbf14575b2a27 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 20:25:52 -1100 Subject: [PATCH 1881/3904] Player data extraction --- src/cc/rogue_rpc.cpp | 101 +++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5ca5a069a..18e312aa5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -384,7 +384,6 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&highlander,script+2,sizeof(highlander)); - //highlander = revuint256(highlander); fprintf(stderr,"got vin.%s \n",playertx.vin[1].prevout.hash.ToString().c_str()); // verify highlander is a valid gametxid, verify playertxid is linked to it //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) @@ -392,7 +391,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { //if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) { - if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' ) { //if ( highlandertx.vin[0].prevout.hash == origplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) return(0); @@ -439,58 +438,67 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n } if ( matches == 1 ) { - numvouts = matchtx.vout.size(); - //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); - if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) + if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+2) < 0 ) { - if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) + numvouts = matchtx.vout.size(); + //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); + if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { - txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); - while ( CCgettxout(txid,0,1) < 0 ) + fprintf(stderr,"playertxid.%s\n",playertxid.ToString().c_str()); + if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { - spenttxid = zeroid; - spentvini = -1; - if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) - txid = spenttxid; - else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + txid = matchtx.GetHash(); + //fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); + while ( CCgettxout(txid,0,1) < 0 ) { - fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); - return(-2); - } - if ( spentvini != 0 ) - return(-3); - if ( keystrokesp != 0 && GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() == 2 ) - { - uint256 g,b; CPubKey p; std::vector k; - if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[1].scriptPubKey) == 'K' ) + spenttxid = zeroid; + spentvini = -1; + if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) { - keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); - for (i=0; i k; + if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[1].scriptPubKey) == 'K' ) + { + keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); + for (i=0; i 0 ) + { + if ( hashBlock == zeroid ) + batonht = komodo_nextheight(); + else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) + return(-4); + else batonht = pindex->GetHeight(); + batonvalue = batontx.vout[0].nValue; + //printf("keystrokes[%d]\n",numkeys); + return(0); + } } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); - batontxid = txid; - batonvout = 0; // not vini - // how to detect timeout, bailedout, highlander - hashBlock = zeroid; - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 0 ) - { - if ( hashBlock == zeroid ) - batonht = komodo_nextheight(); - else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) - return(-4); - else batonht = pindex->GetHeight(); - batonvalue = batontx.vout[0].nValue; - //printf("keystrokes[%d]\n",numkeys); - return(0); - } - } - } else fprintf(stderr,"findbaton opret error\n"); + } else fprintf(stderr,"findbaton opret error\n"); + } + else + { + fprintf(stderr,"already played\n"); + return(-5); + } } return(-1); } @@ -775,6 +783,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param free(keystrokes); mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); mtx.vin.push_back(CTxIn(gametxid,2+maxplayers+regslot,CScript())); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,1,mypk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); if ( num > 0 ) { From defb298184ff3c481d3d52b7f2662de775e69572 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 21:34:30 -1100 Subject: [PATCH 1882/3904] Players rpc call --- src/cc/cclib.cpp | 4 +++ src/cc/rogue/state.c | 9 +++++ src/cc/rogue_rpc.cpp | 85 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 79 insertions(+), 19 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index dd0aef00f..78332c576 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -61,6 +61,7 @@ CClib_methods[] = { (char *)"rogue", (char *)"bailout", (char *)"baton finalhash", 2, 2, 'Q', EVAL_ROGUE }, { (char *)"rogue", (char *)"highlander", (char *)"baton finalhash", 2, 2, 'H', EVAL_ROGUE }, { (char *)"rogue", (char *)"playerinfo", (char *)"playertxid", 1, 1, 'I', EVAL_ROGUE }, + { (char *)"rogue", (char *)"players", (char *)"playertxid", 1, 1, 'D', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -86,6 +87,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -117,6 +119,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(rogue_highlander(txfee,cp,params)); else if ( strcmp(method,"playerinfo") == 0 ) return(rogue_playerinfo(txfee,cp,params)); + else if ( strcmp(method,"players") == 0 ) + return(rogue_players(txfee,cp,params)); else { result.push_back(Pair("result","error")); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 226392e83..60d8648bd 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1349,6 +1349,15 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) o->_o._o_arm = item->arm; o->_o._o_flags = item->flags; o->_o._o_group = item->group; + o->o_flags |= ISKNOW; +} + +void rogue_packitemstr(*packitemstr,struct rogue_packitem *item); +{ + THING *obj = new_item(); + rogue_restoreobject(obj,item); + strcpy(packitemstr,inv_name(o,FALSE)); + free(obj); } int32_t packsave(struct rogue_packitem *item,int32_t type,int32_t launch,char *damage,int32_t damagesize,char *hurldmg,int32_t hurlsize,int32_t count,int32_t which,int32_t hplus,int32_t dplus,int32_t arm,int32_t flags,int32_t group) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 18e312aa5..cff2aafc0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -152,6 +152,22 @@ */ + +#define MAXPACK 23 +struct rogue_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; +struct rogue_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; + struct rogue_packitem roguepack[MAXPACK]; +}; +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); +#define ROGUE_DECLARED_PACK +void rogue_packitemstr(*packitemstr,struct rogue_packitem *item); + CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { CScript opret; uint8_t evalcode = EVAL_ROGUE; @@ -185,7 +201,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q' || f == 'S') ) { return(f); } @@ -346,7 +362,26 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &b UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) { - obj.push_back(Pair("raw","")); + int32_t i; struct rogue_player P; char packitemstr[512]; UniValue a(UniValue::VARR); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i 0 ) { UniValue pobj(UniValue::VOBJ); - obj.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); + obj.push_back(Pair("player",rogue_playerobj(pobj,playerdata))); } } else fprintf(stderr,"findbaton err.%d\n",retval); } @@ -619,7 +654,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param playertxid = juint256(jitem(params,0)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); - result.push_back(Pair("rogue",rogue_playerobj(pobj,playerdata))); + result.push_back(Pair("player",rogue_playerobj(pobj,playerdata))); } else return(cclib_error(result,"no playertxid")); return(result); } else return(cclib_error(result,"couldnt reparse params")); @@ -712,20 +747,6 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -#define MAXPACK 23 -struct rogue_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; -struct rogue_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; - struct rogue_packitem roguepack[MAXPACK]; -}; -int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); -#define ROGUE_DECLARED_PACK - UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,char *method) { //vin0 -> highlander vout from creategame TCBOO @@ -774,13 +795,15 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); fprintf(stderr,"found baton %s numkeys.%d seed.%llu\n",batontxid.ToString().c_str(),numkeys,(long long)seed); + memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { for (i=0; ievalcode,1,mypk)); @@ -888,3 +911,27 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("numpending",a.size())); return(result); } + +UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; + std::vector > unspentOutputs; + roguepk = GetUnspendable(cp,0); + GetCCaddress(cp,coinaddr,mypk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( it->second.satoshis != 1 || vout != 0 ) + continue; + if ( rogue_playerdata(cp,gametxid,pk,playerdata,playertxid) == 0 && pk == mypk ) + a.push_back(Pair("player",rogue_playerobj(pobj,playerdata))); + } + result.push_back(Pair("result","success")); + rogue_univalue(result,"players",-1,-1); + result.push_back(Pair("players",a)); + result.push_back(Pair("numpending",a.size())); + return(result); +} From 7c68ae4363df1c1a39165ae850402bd57b2208a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 21:35:43 -1100 Subject: [PATCH 1883/3904] Char --- src/cc/rogue/state.c | 2 +- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 60d8648bd..777981ae3 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1352,7 +1352,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) o->o_flags |= ISKNOW; } -void rogue_packitemstr(*packitemstr,struct rogue_packitem *item); +void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); { THING *obj = new_item(); rogue_restoreobject(obj,item); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cff2aafc0..e51c47442 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -166,7 +166,7 @@ struct rogue_player }; int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); #define ROGUE_DECLARED_PACK -void rogue_packitemstr(*packitemstr,struct rogue_packitem *item); +void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { From 6584d3c4773b5b5ab5358a3b463b803326870457 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 21:36:24 -1100 Subject: [PATCH 1884/3904] - ; --- src/cc/rogue/state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 777981ae3..861aceadd 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1352,7 +1352,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) o->o_flags |= ISKNOW; } -void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); +void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) { THING *obj = new_item(); rogue_restoreobject(obj,item); From dbb7d7f6e7354c063b56fe523ebd5c0a3bffea57 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 21:38:43 -1100 Subject: [PATCH 1885/3904] syntax --- src/cc/rogue/state.c | 2 +- src/cc/rogue_rpc.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 861aceadd..20288f59a 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1356,7 +1356,7 @@ void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) { THING *obj = new_item(); rogue_restoreobject(obj,item); - strcpy(packitemstr,inv_name(o,FALSE)); + strcpy(packitemstr,inv_name(obj,FALSE)); free(obj); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e51c47442..18be911f8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -926,8 +926,11 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != 1 || vout != 0 ) continue; - if ( rogue_playerdata(cp,gametxid,pk,playerdata,playertxid) == 0 && pk == mypk ) - a.push_back(Pair("player",rogue_playerobj(pobj,playerdata))); + if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) + { + UniValue obj(UniValue::VOBJ); + a.push_back(Pair("player",rogue_playerobj(obj,playerdata))); + } } result.push_back(Pair("result","success")); rogue_univalue(result,"players",-1,-1); From cb5f7eaaa1d68577b5cf81c480425f2d01e878bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 21:55:50 -1100 Subject: [PATCH 1886/3904] Auto broadcast rogue rpc tx --- src/cc/CCinclude.h | 1 + src/cc/rogue_rpc.cpp | 39 +++++++++++++++++++++------------------ src/komodo_bitcoind.h | 11 +++++++++++ 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index bc5ed20ed..948a5c1ae 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -136,6 +136,7 @@ UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params); UniValue CClib_info(struct CCcontract_info *cp); CBlockIndex *komodo_blockindex(uint256 hash); CBlockIndex *komodo_chainactive(int32_t height); +int32_t komodo_blockheight(uint256 hash); static const uint256 zeroid; static uint256 ignoretxid; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 18be911f8..c8af82062 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -129,8 +129,8 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" -// cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" +// cclib gameinfo 17 \"[%22d8bc6445bfec15ea761c8e91e26d162f47856dba1fc8c8ec508cac83b95d7433%22]\" +// cclib register 17 \"[%22d8bc6445bfec15ea761c8e91e26d162f47856dba1fc8c8ec508cac83b95d7433%22]\" // ./rogue gui -> creates keystroke files // cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" @@ -331,12 +331,13 @@ uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 return(seed); } -int32_t rogue_isvalidgame(struct CCcontract_info *cp,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid) +int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid) { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { + gameheight = komodo_blockheight(hashBlock); if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) @@ -635,7 +636,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( (change= inputsum - required) >= txfee ) mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,roguepk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_newgameopret(buyin,maxplayers)); - return(rogue_rawtxresult(result,rawtx,0)); + return(rogue_rawtxresult(result,rawtx,1)); } else return(cclib_error(result,"illegal maxplayers")); return(result); @@ -668,7 +669,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -680,7 +681,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 0 ) { gametxid = juint256(jitem(params,0)); - if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { if ( n > 1 ) { @@ -702,7 +703,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_registeropret(gametxid,playertxid)); - return(rogue_rawtxresult(result,rawtx,0)); + return(rogue_rawtxresult(result,rawtx,1)); } else return(cclib_error(result,"invalid gametxid")); } else return(cclib_error(result,"no gametxid")); } else return(cclib_error(result,"couldnt reparse params")); @@ -717,7 +718,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -728,7 +729,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,destaddr,roguepk,mypk); - if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,gametxid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { if ( rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers) == 0 ) { @@ -761,7 +762,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -786,7 +787,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); - if ( rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { if ( maxplayers == 1 ) mult /= 2; @@ -834,7 +835,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(funcid,gametxid,mypk,newdata)); - return(rogue_rawtxresult(result,rawtx,0)); + return(rogue_rawtxresult(result,rawtx,1)); } result.push_back(Pair("result","success")); } @@ -855,7 +856,7 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; result.push_back(Pair("name","rogue")); result.push_back(Pair("method","gameinfo")); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -864,9 +865,10 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { txid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",txid.GetHex())); - if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 ) { result.push_back(Pair("result","success")); + result.push_back(Pair("gameheight",(int64_t)gameheight)); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); @@ -890,11 +892,12 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t maxplayers,vout,numvouts; CPubKey roguepk; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t maxplayers,gameheight,nextheight,vout,numvouts; CPubKey roguepk; char coinaddr[64]; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,roguepk); SetCCunspents(unspentOutputs,coinaddr); + nextheight = komodo_nextheight(); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -902,7 +905,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers continue; - if ( rogue_isvalidgame(cp,tx,buyin,maxplayers,txid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && gameheight > nextheight-777 ) a.push_back(txid.GetHex()); } result.push_back(Pair("result","success")); @@ -934,7 +937,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } result.push_back(Pair("result","success")); rogue_univalue(result,"players",-1,-1); - result.push_back(Pair("players",a)); - result.push_back(Pair("numpending",a.size())); + result.push_back(Pair("playerdata",a)); + result.push_back(Pair("numplayerdata",a.size())); return(result); } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f6dcc0efe..68250e6cf 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1041,6 +1041,17 @@ CBlockIndex *komodo_blockindex(uint256 hash) return(pindex); } +int32_t komodo_blockheight(uint256 hash) +{ + BlockMap::const_iterator it; CBlockIndex *pindex = 0; + if ( (it = mapBlockIndex.find(hash)) != mapBlockIndex.end() ) + { + if ( (pindex= it->second) != 0 ) + return(pindex->GetHeight()); + } + return(0); +} + int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) { int32_t notarized_height,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; CBlockIndex *notary,*pindex; From 5cda0241b45284cfa811c4d795ed36c4c3d7e840 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 22:07:32 -1100 Subject: [PATCH 1887/3904] +print --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c8af82062..ef5949042 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -134,7 +134,7 @@ // ./rogue gui -> creates keystroke files // cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22]\" +// cclib bailout 17 \"[%22d8bc6445bfec15ea761c8e91e26d162f47856dba1fc8c8ec508cac83b95d7433%22]\" // eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd /* 2409 gold.209 hp.17 strength.16 level.3 exp.22 3 @@ -921,6 +921,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,mypk); + fprintf(stderr,"search (%s)\n",coinaddr); SetCCunspents(unspentOutputs,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { From d5db98b42c51fdf6ba2b9707d4d1d46e785dfc04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 22:14:53 -1100 Subject: [PATCH 1888/3904] mypk = pubkey2pk(Mypubkey()); --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ef5949042..b631c1956 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -920,6 +920,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); GetCCaddress(cp,coinaddr,mypk); fprintf(stderr,"search (%s)\n",coinaddr); SetCCunspents(unspentOutputs,coinaddr); From 564a7aece8231396482431498d4287a600a18d34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 22:25:09 -1100 Subject: [PATCH 1889/3904] Make sure item strings are there --- src/cc/rogue/state.c | 9 +++++++++ src/cc/rogue_rpc.cpp | 7 +++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 20288f59a..67be65430 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1354,6 +1354,15 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) { + static int32_t didinit; + if ( didinit == 0 ) + { + init_names(); /* Set up names of scrolls */ + init_colors(); /* Set up colors of potions */ + init_stones(); /* Set up stone settings of rings */ + init_materials(); /* Set up materials of wands */ + didinit = 1; + } THING *obj = new_item(); rogue_restoreobject(obj,item); strcpy(packitemstr,inv_name(obj,FALSE)); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b631c1956..d51c0c399 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -412,15 +412,15 @@ int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace p int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,highlander; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,gametxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { - memcpy(&highlander,script+2,sizeof(highlander)); - fprintf(stderr,"got vin.%s \n",playertx.vin[1].prevout.hash.ToString().c_str()); + memcpy(&gametxid,script+2,sizeof(gametxid)); + fprintf(stderr,"got vin.%s gametxid.%s\n",playertx.vin[1].prevout.hash.ToString().c_str(),gametxid.ToString().c_str()); // verify highlander is a valid gametxid, verify playertxid is linked to it //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) //if ( playertx.vin[1].prevout.hash == highlander ) @@ -922,7 +922,6 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress(cp,coinaddr,mypk); - fprintf(stderr,"search (%s)\n",coinaddr); SetCCunspents(unspentOutputs,coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { From f16510e7c2b3069f062cf5a221730f3de31f4baf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 22:32:55 -1100 Subject: [PATCH 1890/3904] Rogue iterate --- src/cc/rogue/state.c | 7 +++---- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 67be65430..23b6d7b27 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1357,10 +1357,9 @@ void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) static int32_t didinit; if ( didinit == 0 ) { - init_names(); /* Set up names of scrolls */ - init_colors(); /* Set up colors of potions */ - init_stones(); /* Set up stone settings of rings */ - init_materials(); /* Set up materials of wands */ + struct rogue_state R; + memset(&R,0,sizeof(R)); + rogueiterate(&R); didinit = 1; } THING *obj = new_item(); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d51c0c399..85c050ec8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -420,10 +420,10 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&gametxid,script+2,sizeof(gametxid)); - fprintf(stderr,"got vin.%s gametxid.%s\n",playertx.vin[1].prevout.hash.ToString().c_str(),gametxid.ToString().c_str()); + fprintf(stderr,"got vin.%s gametxid.%s iterate.%d valid.%d\n",playertx.vin[1].prevout.hash.ToString().c_str(),gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n,playertxid),rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid)); // verify highlander is a valid gametxid, verify playertxid is linked to it //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) - //if ( playertx.vin[1].prevout.hash == highlander ) + if ( playertx.vin[1].prevout.hash == gametxid ) { //if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) { From ddf8f6a0dd8cf33fac9faf672885cbaa93b49d1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 22:34:43 -1100 Subject: [PATCH 1891/3904] Syntax --- src/cc/rogue_rpc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 85c050ec8..8e9cee736 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -387,12 +387,13 @@ UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) return(obj); } -int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once +int32_t rogue_iterateplayer(uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once { - uint256 spenttxid,txid = firsttxid; int32_t spentvini,vout = 0; + uint256 spenttxid,txid = firsttxid; int32_t spentvini,vout = firstvout; while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) { txid = spenttxid; + vout = spentvini; } if ( txid == lasttxid ) return(0); @@ -412,7 +413,7 @@ int32_t rogue_iterateplayer(uint256 firsttxid,uint256 lasttxid) // retrace p int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,gametxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,gametxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); @@ -420,7 +421,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&gametxid,script+2,sizeof(gametxid)); - fprintf(stderr,"got vin.%s gametxid.%s iterate.%d valid.%d\n",playertx.vin[1].prevout.hash.ToString().c_str(),gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n,playertxid),rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid)); + fprintf(stderr,"got vin.%s gametxid.%s iterate.%d valid.%d\n",playertx.vin[1].prevout.hash.ToString().c_str(),gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n,playertxid),rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)); // verify highlander is a valid gametxid, verify playertxid is linked to it //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) if ( playertx.vin[1].prevout.hash == gametxid ) From 612cabbfea4e712c01be7cb8b4c6f0868458dca5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 22:38:02 -1100 Subject: [PATCH 1892/3904] 'Q' 'y' --- src/cc/rogue/state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 23b6d7b27..a9aa109f0 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1357,8 +1357,13 @@ void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) static int32_t didinit; if ( didinit == 0 ) { - struct rogue_state R; + struct rogue_state R; char keystrokes[3]; memset(&R,0,sizeof(R)); + keystrokes[0] = 'Q'; + keystrokes[1] = 'y'; + keystrokes[2] = 0; + R.keystrokes = keystrokes; + R.numkeys = 2; rogueiterate(&R); didinit = 1; } From 3cc3c3abedbab6f93f9db4d00dafb36d470d3ff4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 22:48:41 -1100 Subject: [PATCH 1893/3904] Details print --- src/cc/rogue/state.c | 1 + src/cc/rogue_rpc.cpp | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index a9aa109f0..50d995c79 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1370,6 +1370,7 @@ void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) THING *obj = new_item(); rogue_restoreobject(obj,item); strcpy(packitemstr,inv_name(obj,FALSE)); + fprintf(stderr,"packitem.(%s)\n",packitemstr); free(obj); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8e9cee736..83a556a80 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -390,6 +390,8 @@ UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) int32_t rogue_iterateplayer(uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once { uint256 spenttxid,txid = firsttxid; int32_t spentvini,vout = firstvout; + if ( vout < 0 ) + return(-1); while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) { txid = spenttxid; @@ -399,7 +401,7 @@ int32_t rogue_iterateplayer(uint256 firsttxid,int32_t firstvout,uint256 lasttxid return(0); else { - fprintf(stderr,"firsttxid.%s -> %s != last.%s\n",firsttxid.ToString().c_str(),txid.ToString().c_str(),lasttxid.ToString().c_str()); + fprintf(stderr,"firsttxid.%s/v%d -> %s != last.%s\n",firsttxid.ToString().c_str(),firstvout,txid.ToString().c_str(),lasttxid.ToString().c_str()); return(-1); } } @@ -421,21 +423,16 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) { memcpy(&gametxid,script+2,sizeof(gametxid)); - fprintf(stderr,"got vin.%s gametxid.%s iterate.%d valid.%d\n",playertx.vin[1].prevout.hash.ToString().c_str(),gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n,playertxid),rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)); - // verify highlander is a valid gametxid, verify playertxid is linked to it - //if ( rogue_iterateplayer(highlander,playertx.vin[1].prevout.n,playertxid) == 0 ) - if ( playertx.vin[1].prevout.hash == gametxid ) + if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - //if ( GetTransaction(highlander,highlandertx,hashBlock,false) != 0 && (numvouts= highlandertx.vout.size()) > 0 ) + fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d valid.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + if ( playertx.vin[1].prevout.hash == gametxid ) { if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' ) - { - //if ( highlandertx.vin[0].prevout.hash == origplayergame && highlandertx.vin[0].prevout.n == 0 && rogue_isvalidgame(cp,gametx,buyin,maxplayers,origplayergame) == 0 && maxplayers > 1 ) - return(0); - //else return(-3); - } - } - } //else return(-2); + return(0); + else fprintf(stderr,"f is %c/%d\n",f,f); + } else fprintf(stderr,"hash mismatch or illegale gametxid\n"); + } } } return(-1); From 3c5c8f35999ffc2874dde51b68c388d9d26ee2a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 23:06:57 -1100 Subject: [PATCH 1894/3904] oi_know --- src/cc/rogue/state.c | 20 +++++++++++++++++ src/cc/rogue/things.c | 52 +++++++++++++++++++++---------------------- src/cc/rogue_rpc.cpp | 24 +++++++------------- 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 50d995c79..def3fb859 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1338,6 +1338,7 @@ rs_read_monsters(FILE *inf, struct monster *m, int count) void rogue_restoreobject(THING *o,struct rogue_packitem *item) { + int32_t i; o->_o._o_type = item->type; o->_o._o_launch = item->launch; memcpy(o->_o._o_damage,item->damage,sizeof(item->damage)); @@ -1350,6 +1351,25 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) o->_o._o_flags = item->flags; o->_o._o_group = item->group; o->o_flags |= ISKNOW; + switch ( item->type ) + { + case SCROLL: + if ( item->which < MAXSCROLLS ) + scr_info[item->which].oi_know = TRUE; + break; + case POTION: + if ( item->which < MAXPOTIONS ) + pot_info[item->which].oi_know = TRUE; + break; + case RING: + if ( item->which < MAXRINGS ) + ring_info[item->which].oi_know = TRUE; + break; + case STICK: + if ( item->which < MAXSTICKS ) + ws_info[item->which].oi_know = TRUE; + break; + } } void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 660e0720e..4e572c60b 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -432,15 +432,15 @@ print_disc(struct rogue_state *rs,char type) obj.o_flags = 0; num_found = 0; for (i = 0; i < maxnum; i++) - if (info[order[i]].oi_know || info[order[i]].oi_guess) - { - obj.o_type = type; - obj.o_which = order[i]; - add_line(rs,"%s", inv_name(&obj, FALSE)); - num_found++; - } + if (info[order[i]].oi_know || info[order[i]].oi_guess) + { + obj.o_type = type; + obj.o_which = order[i]; + add_line(rs,"%s", inv_name(&obj, FALSE)); + num_found++; + } if (num_found == 0) - add_line(rs,nothing(type), NULL); + add_line(rs,nothing(type), NULL); } /* @@ -452,16 +452,16 @@ void set_order(int *order, int numthings) { int i, r, t; - + for (i = 0; i< numthings; i++) - order[i] = i; - + order[i] = i; + for (i = numthings; i > 0; i--) { - r = rnd(i); - t = order[i - 1]; - order[i - 1] = order[r]; - order[r] = t; + r = rnd(i); + t = order[i - 1]; + order[i - 1] = order[r]; + order[r] = t; } } @@ -624,20 +624,20 @@ nameit(THING *obj, const char *type,const char *which, struct obj_info *op, if (op->oi_know || op->oi_guess) { - if (obj->o_count == 1) - sprintf(prbuf, "A %s ", type); - else - sprintf(prbuf, "%d %ss ", obj->o_count, type); - pb = &prbuf[strlen(prbuf)]; - if (op->oi_know) - sprintf(pb, "of %s%s(%s)", op->oi_name, (*prfunc)(obj), which); - else if (op->oi_guess) - sprintf(pb, "called %s%s(%s)", op->oi_guess, (*prfunc)(obj), which); + if (obj->o_count == 1) + sprintf(prbuf, "A %s ", type); + else + sprintf(prbuf, "%d %ss ", obj->o_count, type); + pb = &prbuf[strlen(prbuf)]; + if (op->oi_know) + sprintf(pb, "of %s%s(%s)", op->oi_name, (*prfunc)(obj), which); + else if (op->oi_guess) + sprintf(pb, "called %s%s(%s)", op->oi_guess, (*prfunc)(obj), which); } else if (obj->o_count == 1) - sprintf(prbuf, "A%s %s %s", vowelstr((char *)which), which, type); + sprintf(prbuf, "A%s %s %s", vowelstr((char *)which), which, type); else - sprintf(prbuf, "%d %s %ss", obj->o_count, which, type); + sprintf(prbuf, "%d %s %ss", obj->o_count, which, type); } /* diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 83a556a80..b15925869 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -361,9 +361,9 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } -UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) +UniValue rogue_playerobj(std::vector playerdata) { - int32_t i; struct rogue_player P; char packitemstr[512]; UniValue a(UniValue::VARR); + int32_t i; struct rogue_player P; char packitemstr[512]; UniValue obj(UniValue:VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -383,7 +383,6 @@ UniValue rogue_playerobj(UniValue &obj,std::vector playerdata) obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); - // convert to scrolls, etc. return(obj); } @@ -425,13 +424,13 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub memcpy(&gametxid,script+2,sizeof(gametxid)); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d valid.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); - if ( playertx.vin[1].prevout.hash == gametxid ) + fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' ) return(0); else fprintf(stderr,"f is %c/%d\n",f,f); - } else fprintf(stderr,"hash mismatch or illegale gametxid\n"); + } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); } } } @@ -559,10 +558,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); obj.push_back(Pair("batonht",(int64_t)batonht)); if ( playerdata.size() > 0 ) - { - UniValue pobj(UniValue::VOBJ); - obj.push_back(Pair("player",rogue_playerobj(pobj,playerdata))); - } + obj.push_back(Pair("player",rogue_playerobj(playerdata))); } else fprintf(stderr,"findbaton err.%d\n",retval); } @@ -649,11 +645,10 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { if ( n > 0 ) { - UniValue pobj(UniValue::VOBJ); playertxid = juint256(jitem(params,0)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); - result.push_back(Pair("player",rogue_playerobj(pobj,playerdata))); + result.push_back(Pair("player",rogue_playerobj(playerdata))); } else return(cclib_error(result,"no playertxid")); return(result); } else return(cclib_error(result,"couldnt reparse params")); @@ -929,10 +924,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( it->second.satoshis != 1 || vout != 0 ) continue; if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) - { - UniValue obj(UniValue::VOBJ); - a.push_back(Pair("player",rogue_playerobj(obj,playerdata))); - } + a.push_back(Pair("player",rogue_playerobj(playerdata))); } result.push_back(Pair("result","success")); rogue_univalue(result,"players",-1,-1); From 5e21713f8f0ae651899972a6916e9db67230dff9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 23:08:31 -1100 Subject: [PATCH 1895/3904] :: --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b15925869..3dcfa820a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -363,7 +363,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa UniValue rogue_playerobj(std::vector playerdata) { - int32_t i; struct rogue_player P; char packitemstr[512]; UniValue obj(UniValue:VOBJ),a(UniValue::VARR); + int32_t i; struct rogue_player P; char packitemstr[512]; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { From e34d070c2984b4a85dafd63987f8b9b34ee7663c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 23:11:49 -1100 Subject: [PATCH 1896/3904] Double print --- src/cc/rogue_rpc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3dcfa820a..424c958e0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -916,6 +916,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); GetCCaddress(cp,coinaddr,mypk); SetCCunspents(unspentOutputs,coinaddr); + rogue_univalue(result,"players",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -924,10 +925,11 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( it->second.satoshis != 1 || vout != 0 ) continue; if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) + { a.push_back(Pair("player",rogue_playerobj(playerdata))); + result.push_back(Pair("playerdata",rogue_playerobj(playerdata))); + } } - result.push_back(Pair("result","success")); - rogue_univalue(result,"players",-1,-1); result.push_back(Pair("playerdata",a)); result.push_back(Pair("numplayerdata",a.size())); return(result); From b94b392d05e8b9ef3f030be89ce106e175358a70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 23:14:31 -1100 Subject: [PATCH 1897/3904] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 424c958e0..e0edb1658 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -926,8 +926,8 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) continue; if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) { - a.push_back(Pair("player",rogue_playerobj(playerdata))); - result.push_back(Pair("playerdata",rogue_playerobj(playerdata))); + a.push_back(rogue_playerobj(playerdata)); + //result.push_back(Pair("playerdata",rogue_playerobj(playerdata))); } } result.push_back(Pair("playerdata",a)); From de6477bd52a8ddf31b15c0765dcfe49e8d995b68 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 23:18:21 -1100 Subject: [PATCH 1898/3904] Playertxid --- src/cc/rogue_rpc.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e0edb1658..1a4ffab13 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -361,7 +361,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } -UniValue rogue_playerobj(std::vector playerdata) +UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid) { int32_t i; struct rogue_player P; char packitemstr[512]; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); @@ -376,6 +376,7 @@ UniValue rogue_playerobj(std::vector playerdata) rogue_packitemstr(packitemstr,&P.roguepack[i]); a.push_back(packitemstr); } + obj.push_back(Pair("playertxid",playertxid.GetHex())); obj.push_back(Pair("pack",a)); obj.push_back(Pair("packsize",(int64_t)P.packsize)); obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); @@ -448,10 +449,11 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 } else return(-1); } -int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) +int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) { - int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,playertxid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = numplayers = 0; + playertxid = zeroid; for (i=0; i= 0 ) @@ -477,7 +479,6 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { - fprintf(stderr,"playertxid.%s\n",playertxid.ToString().c_str()); if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { txid = matchtx.GetHash(); @@ -539,7 +540,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,char **keystrokesp,int32_t &n void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,hashBlock; CTransaction spenttx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + uint256 batontxid,spenttxid,hashBlock,playertxid; CTransaction spenttx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { @@ -547,7 +548,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-2)); - if ( (retval= rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) + if ( (retval= rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) { if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) obj.push_back(Pair("status","alive")); @@ -558,7 +559,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); obj.push_back(Pair("batonht",(int64_t)batonht)); if ( playerdata.size() > 0 ) - obj.push_back(Pair("player",rogue_playerobj(playerdata))); + obj.push_back(Pair("player",rogue_playerobj(playerdata,playertxid))); } else fprintf(stderr,"findbaton err.%d\n",retval); } @@ -648,7 +649,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param playertxid = juint256(jitem(params,0)); if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); - result.push_back(Pair("player",rogue_playerobj(playerdata))); + result.push_back(Pair("player",rogue_playerobj(playerdata,playertxid))); } else return(cclib_error(result,"no playertxid")); return(result); } else return(cclib_error(result,"couldnt reparse params")); @@ -711,7 +712,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -724,7 +725,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers) == 0 ) + if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers) == 0 ) { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { @@ -755,7 +756,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -784,7 +785,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { if ( maxplayers == 1 ) mult /= 2; - if ( rogue_findbaton(cp,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 && keystrokes != 0 ) + if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 && keystrokes != 0 ) { UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); @@ -926,7 +927,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) continue; if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) { - a.push_back(rogue_playerobj(playerdata)); + a.push_back(rogue_playerobj(playerdata,txid)); //result.push_back(Pair("playerdata",rogue_playerobj(playerdata))); } } From 071e83e28b16d67c345c20869d0d21f485bba82d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Feb 2019 23:26:31 -1100 Subject: [PATCH 1899/3904] Remove second vout for new game --- src/cc/rogue_rpc.cpp | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1a4ffab13..e69fb75a9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -72,9 +72,8 @@ Transaction details creategame vout0 -> txfee highlander vout TCBOO creation - vout1 -> txfee highlander vout TCBOO playerdata used (deprecated) - vout2 to vout.maxplayers+2 -> 1of2 registration ROGUE_REGISTRATIONSIZE batons - vout2+maxplayers to vout.2*maxplayers+2 -> 1of2 registration txfee batons for game completion + vout1 to vout.maxplayers+1 -> 1of2 registration ROGUE_REGISTRATIONSIZE batons + vout2+maxplayers to vout.2*maxplayers+1 -> 1of2 registration txfee batons for game completion register vin0 -> ROGUE_REGISTRATIONSIZE 1of2 registration baton from creategame @@ -268,7 +267,7 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, for (i=0; i= 0 ) { if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) @@ -289,10 +288,10 @@ int32_t rogue_playersalive(int32_t &numplayers,uint256 gametxid,int32_t maxplaye numplayers = 0; for (i=0; i maxplayers+2 ) + if ( numvouts > maxplayers+1 ) { for (i=0; i= 0 ) + if ( myIsutxo_spent(spenttxid,gametxid,i+1) >= 0 ) { if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) { @@ -467,13 +466,13 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke matches++; regslot = i; matchtx = spenttx; - } //else fprintf(stderr,"%d+2 doesnt match %s vs %s\n",i,ccaddr,destaddr); - } //else fprintf(stderr,"%d+2 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); - } //else fprintf(stderr,"%d+2 unspent\n",i); + } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"%d+1 unspent\n",i); } if ( matches == 1 ) { - if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+2) < 0 ) + if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); @@ -547,7 +546,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } - obj.push_back(Pair("slot",(int64_t)vout-2)); + obj.push_back(Pair("slot",(int64_t)vout-1)); if ( (retval= rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) { if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) @@ -566,12 +565,12 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTransaction gametx,int32_t maxplayers) { int32_t vout,j,r; int64_t nValue; - if ( gametx.vout.size() > maxplayers+2 ) + if ( gametx.vout.size() > maxplayers+1 ) { r = rand() % maxplayers; for (j=0; junspendableCCaddr)) >= required ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO creation - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO used for (i=0; ievalcode,ROGUE_REGISTRATIONSIZE,roguepk,roguepk)); for (i=0; ievalcode,1,mypk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); if ( num > 0 ) { newdata.resize(num); @@ -870,10 +867,10 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) rogue_gamefields(result,maxplayers,buyin,txid,myrogueaddr); for (i=0; i Date: Sun, 10 Feb 2019 00:13:42 -1100 Subject: [PATCH 1900/3904] Not pending if all slots filled --- src/cc/rogue_rpc.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e69fb75a9..d8f003651 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -128,12 +128,12 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%22d8bc6445bfec15ea761c8e91e26d162f47856dba1fc8c8ec508cac83b95d7433%22]\" -// cclib register 17 \"[%22d8bc6445bfec15ea761c8e91e26d162f47856dba1fc8c8ec508cac83b95d7433%22]\" +// cclib gameinfo 17 \"[%2284d3c1b598c9e2b3891a6b33468ec526cfaa9c7024c578025cdaff24b5ea3d20%22]\" +// cclib register 17 \"[%2284d3c1b598c9e2b3891a6b33468ec526cfaa9c7024c578025cdaff24b5ea3d20%22]\" // ./rogue gui -> creates keystroke files // cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%22d8bc6445bfec15ea761c8e91e26d162f47856dba1fc8c8ec508cac83b95d7433%22]\" +// cclib bailout 17 \"[%2284d3c1b598c9e2b3891a6b33468ec526cfaa9c7024c578025cdaff24b5ea3d20%22]\" // eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd /* 2409 gold.209 hp.17 strength.16 level.3 exp.22 3 @@ -799,6 +799,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param free(keystrokes); mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); mtx.vin.push_back(CTxIn(gametxid,1+maxplayers+regslot,CScript())); + if ( funcid == 'H' ) + mtx.vin.push_back(CTxIn(gametxid,0,CScript())); mtx.vout.push_back(MakeCC1vout(cp->evalcode,1,mypk)); if ( num > 0 ) { @@ -883,7 +885,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t maxplayers,gameheight,nextheight,vout,numvouts; CPubKey roguepk; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t maxplayers,numplayers,gameheight,nextheight,vout,numvouts; CPubKey roguepk; char coinaddr[64]; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,roguepk); @@ -897,7 +899,11 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers continue; if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && gameheight > nextheight-777 ) - a.push_back(txid.GetHex()); + { + rogue_playersalive(numplayers,txid,maxplayers); + if ( numplayers < maxplayers ) + a.push_back(txid.GetHex()); + } } result.push_back(Pair("result","success")); rogue_univalue(result,"pending",-1,-1); From 3bf01610b98bb7e63212c95cb5e652086e7bf0cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 00:23:10 -1100 Subject: [PATCH 1901/3904] Registered state --- src/cc/rogue_rpc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d8f003651..b85df7966 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -539,7 +539,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) { // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,hashBlock,playertxid; CTransaction spenttx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + uint256 batontxid,spenttxid,gtxid,ptxid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { @@ -550,8 +550,14 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet if ( (retval= rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) { if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) - obj.push_back(Pair("status","alive")); - else obj.push_back(Pair("status","finished")); + { + if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.size() > 1 ) + { + if ( rogue_registeropretdecode(gtxid,ptxid,batontx.vout[batontx.size()-1].scriptPubKey) == 'R' && gtxid == gametxid && ptxid == playertxid ) + obj.push_back(Pair("status","registered")); + else obj.push_back(Pair("status","alive")); + } else obj.push_back(Pair("status","error")); + } else obj.push_back(Pair("status","finished")); obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonaddr",destaddr)); obj.push_back(Pair("batonvout",(int64_t)batonvout)); From 2e9f18d3dcbb87c7a00647ad8225c90eaa69ec52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 00:25:30 -1100 Subject: [PATCH 1902/3904] vout.size() --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b85df7966..24d6a87fc 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -551,9 +551,9 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet { if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) { - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.size() > 1 ) + if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 1 ) { - if ( rogue_registeropretdecode(gtxid,ptxid,batontx.vout[batontx.size()-1].scriptPubKey) == 'R' && gtxid == gametxid && ptxid == playertxid ) + if ( rogue_registeropretdecode(gtxid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && gtxid == gametxid && ptxid == playertxid ) obj.push_back(Pair("status","registered")); else obj.push_back(Pair("status","alive")); } else obj.push_back(Pair("status","error")); From 666935b93692860407228c05e667cf5253818f4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 00:28:01 -1100 Subject: [PATCH 1903/3904] Add normal input to use playerdata --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 24d6a87fc..bc6580a29 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -697,6 +697,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find playerdata to spend")); else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); + if ( playertxid != zeroid ) + AddNormalInputs2(mtx,txfee,10); mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); From 144b37028a0d1677c9779661700b5e9dbba36276 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 00:31:31 -1100 Subject: [PATCH 1904/3904] Fix --- src/cc/rogue_rpc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index bc6580a29..800337827 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -386,15 +386,18 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid) return(obj); } -int32_t rogue_iterateplayer(uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once +int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once { uint256 spenttxid,txid = firsttxid; int32_t spentvini,vout = firstvout; + registertxid = zeroid; if ( vout < 0 ) return(-1); while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) { txid = spenttxid; vout = spentvini; + if ( registertxid == zeroid ) + registertxid = txid; } if ( txid == lasttxid ) return(0); @@ -414,7 +417,7 @@ int32_t rogue_iterateplayer(uint256 firsttxid,int32_t firstvout,uint256 lasttxid int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,gametxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,gameheight,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); @@ -425,10 +428,13 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); - if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) + if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' ) + { + // if registertxid has vin from pk, it can be used return(0); + } else fprintf(stderr,"f is %c/%d\n",f,f); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); } From 5e6c99ebeca5893d687674cbe894d98485a5db83 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 00:32:33 -1100 Subject: [PATCH 1905/3904] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 800337827..5489b75f6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -427,7 +427,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub memcpy(&gametxid,script+2,sizeof(gametxid)); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' ) @@ -704,7 +704,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); if ( playertxid != zeroid ) - AddNormalInputs2(mtx,txfee,10); + AddNormalinputs2(mtx,txfee,10); mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); From 14f1da959c1c0e79f21a0e895e85af04b045a86d Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 7 Feb 2019 11:34:26 +0500 Subject: [PATCH 1906/3904] non-fungible tokens support (three-eval token vouts) added in CCtokens (additional opret data) non-fungible tokens support added in assets logging changed in CCtokens.cpp for bitcon LogPrintStr with -debug= support --- src/cc/CCassets.h | 7 +- src/cc/CCassetsCore.cpp | 244 +++++++++-------- src/cc/CCassetstx.cpp | 191 +++++++------ src/cc/CCcustom.cpp | 3 + src/cc/CCinclude.h | 44 ++- src/cc/CCtokens.cpp | 563 +++++++++++++++++++++++++-------------- src/cc/CCtokens.h | 5 +- src/cc/CCtx.cpp | 57 ++-- src/cc/CCutils.cpp | 74 +++-- src/cc/assets.cpp | 97 ++++--- src/cc/oracles.cpp | 2 +- src/cc/prices.cpp | 4 + src/wallet/rpcwallet.cpp | 88 +++--- 13 files changed, 851 insertions(+), 528 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 69fcfacbb..c4623ccbb 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -29,11 +29,8 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCassetsCore -//CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk); -//CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description); -//CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 tokenid, uint256 assetid2, int64_t price, std::vector origpubkey); -//bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); -//uint8_t DecodeAssetOpRet(const CScript &scriptPubKey, uint8_t &evalCode, uint256 &assetid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); +CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); +uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey, std::vector &vopretNonfungible); bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 1b8e46189..f14de3956 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -43,17 +43,17 @@ bool ValidateBidRemainder(int64_t remaining_units,int64_t remaining_nValue,int64 int64_t unitprice,recvunitprice,newunitprice=0; if ( orig_nValue == 0 || received_nValue == 0 || paidunits == 0 || totalunits == 0 ) { - fprintf(stderr,"ValidateAssetRemainder: orig_nValue == %llu || received_nValue == %llu || paidunits == %llu || totalunits == %llu\n",(long long)orig_nValue,(long long)received_nValue,(long long)paidunits,(long long)totalunits); + fprintf(stderr,"ValidateAssetRemainder() orig_nValue == %llu || received_nValue == %llu || paidunits == %llu || totalunits == %llu\n",(long long)orig_nValue,(long long)received_nValue,(long long)paidunits,(long long)totalunits); return(false); } else if ( totalunits != (remaining_units + paidunits) ) { - fprintf(stderr,"ValidateAssetRemainder: totalunits %llu != %llu (remaining_units %llu + %llu paidunits)\n",(long long)totalunits,(long long)(remaining_units + paidunits),(long long)remaining_units,(long long)paidunits); + fprintf(stderr,"ValidateAssetRemainder() totalunits %llu != %llu (remaining_units %llu + %llu paidunits)\n",(long long)totalunits,(long long)(remaining_units + paidunits),(long long)remaining_units,(long long)paidunits); return(false); } else if ( orig_nValue != (remaining_nValue + received_nValue) ) { - fprintf(stderr,"ValidateAssetRemainder: orig_nValue %llu != %llu (remaining_nValue %llu + %llu received_nValue)\n",(long long)orig_nValue,(long long)(remaining_nValue - received_nValue),(long long)remaining_nValue,(long long)received_nValue); + fprintf(stderr,"ValidateAssetRemainder() orig_nValue %llu != %llu (remaining_nValue %llu + %llu received_nValue)\n",(long long)orig_nValue,(long long)(remaining_nValue - received_nValue),(long long)remaining_nValue,(long long)received_nValue); return(false); } else @@ -68,10 +68,10 @@ bool ValidateBidRemainder(int64_t remaining_units,int64_t remaining_nValue,int64 newunitprice = (remaining_nValue / remaining_units); if ( recvunitprice < unitprice ) { - fprintf(stderr,"error recvunitprice %.8f < %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/(COIN),(double)unitprice/(COIN),(double)newunitprice/(COIN)); + fprintf(stderr,"ValidateAssetRemainder() error recvunitprice %.8f < %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/(COIN),(double)unitprice/(COIN),(double)newunitprice/(COIN)); return(false); } - fprintf(stderr,"orig %llu total %llu, recv %llu paid %llu,recvunitprice %.8f >= %.8f unitprice, new unitprice %.8f\n",(long long)orig_nValue,(long long)totalunits,(long long)received_nValue,(long long)paidunits,(double)recvunitprice/(COIN),(double)unitprice/(COIN),(double)newunitprice/(COIN)); + fprintf(stderr,"ValidateAssetRemainder() orig %llu total %llu, recv %llu paid %llu,recvunitprice %.8f >= %.8f unitprice, new unitprice %.8f\n",(long long)orig_nValue,(long long)totalunits,(long long)received_nValue,(long long)paidunits,(double)recvunitprice/(COIN),(double)unitprice/(COIN),(double)newunitprice/(COIN)); } return(true); } @@ -89,7 +89,7 @@ bool SetBidFillamounts(int64_t &received_nValue,int64_t &remaining_units,int64_t paidunits = totalunits; received_nValue = orig_nValue; remaining_units = 0; - fprintf(stderr,"totally filled!\n"); + fprintf(stderr,"SetBidFillamounts() bid order totally filled!\n"); return(true); } remaining_units = (totalunits - paidunits); @@ -100,7 +100,7 @@ bool SetBidFillamounts(int64_t &received_nValue,int64_t &remaining_units,int64_t if ( unitprice > 0 && received_nValue > 0 && received_nValue <= orig_nValue ) { remaining_nValue = (orig_nValue - received_nValue); - printf("total.%llu - paid.%llu, remaining %llu <- %llu (%llu - %llu)\n",(long long)totalunits,(long long)paidunits,(long long)remaining_nValue,(long long)(orig_nValue - received_nValue),(long long)orig_nValue,(long long)received_nValue); + printf("SetBidFillamounts() total.%llu - paid.%llu, remaining %llu <- %llu (%llu - %llu)\n",(long long)totalunits,(long long)paidunits,(long long)remaining_nValue,(long long)(orig_nValue - received_nValue),(long long)orig_nValue,(long long)received_nValue); return(ValidateBidRemainder(remaining_units,remaining_nValue,orig_nValue,received_nValue,paidunits,totalunits)); } else return(false); } @@ -118,14 +118,14 @@ bool SetAskFillamounts(int64_t &received_assetoshis,int64_t &remaining_nValue,in paid_nValue = total_nValue; received_assetoshis = orig_assetoshis; remaining_nValue = 0; - fprintf(stderr,"totally filled!\n"); + fprintf(stderr,"SetAskFillamounts() ask order totally filled!\n"); return(true); } remaining_nValue = (total_nValue - paid_nValue); dunitprice = ((double)total_nValue / orig_assetoshis); received_assetoshis = (paid_nValue / dunitprice); - fprintf(stderr,"remaining_nValue %.8f (%.8f - %.8f)\n",(double)remaining_nValue/COIN,(double)total_nValue/COIN,(double)paid_nValue/COIN); - fprintf(stderr,"unitprice %.8f received_assetoshis %llu orig %llu\n",dunitprice/COIN,(long long)received_assetoshis,(long long)orig_assetoshis); + fprintf(stderr,"SetAskFillamounts() remaining_nValue %.8f (%.8f - %.8f)\n",(double)remaining_nValue/COIN,(double)total_nValue/COIN,(double)paid_nValue/COIN); + fprintf(stderr,"SetAskFillamounts() unitprice %.8f received_assetoshis %llu orig %llu\n",dunitprice/COIN,(long long)received_assetoshis,(long long)orig_assetoshis); if ( fabs(dunitprice) > SMALLVAL && received_assetoshis > 0 && received_assetoshis <= orig_assetoshis ) { remaining_assetoshis = (orig_assetoshis - received_assetoshis); @@ -138,17 +138,17 @@ bool ValidateAskRemainder(int64_t remaining_nValue,int64_t remaining_assetoshis, int64_t unitprice,recvunitprice,newunitprice=0; if ( orig_assetoshis == 0 || received_assetoshis == 0 || paid_nValue == 0 || total_nValue == 0 ) { - fprintf(stderr,"ValidateAssetRemainder: orig_assetoshis == %llu || received_assetoshis == %llu || paid_nValue == %llu || total_nValue == %llu\n",(long long)orig_assetoshis,(long long)received_assetoshis,(long long)paid_nValue,(long long)total_nValue); + fprintf(stderr,"ValidateAssetRemainder() orig_assetoshis == %llu || received_assetoshis == %llu || paid_nValue == %llu || total_nValue == %llu\n",(long long)orig_assetoshis,(long long)received_assetoshis,(long long)paid_nValue,(long long)total_nValue); return(false); } else if ( total_nValue != (remaining_nValue + paid_nValue) ) { - fprintf(stderr,"ValidateAssetRemainder: total_nValue %llu != %llu (remaining_nValue %llu + %llu paid_nValue)\n",(long long)total_nValue,(long long)(remaining_nValue + paid_nValue),(long long)remaining_nValue,(long long)paid_nValue); + fprintf(stderr,"ValidateAssetRemainder() total_nValue %llu != %llu (remaining_nValue %llu + %llu paid_nValue)\n",(long long)total_nValue,(long long)(remaining_nValue + paid_nValue),(long long)remaining_nValue,(long long)paid_nValue); return(false); } else if ( orig_assetoshis != (remaining_assetoshis + received_assetoshis) ) { - fprintf(stderr,"ValidateAssetRemainder: orig_assetoshis %llu != %llu (remaining_nValue %llu + %llu received_nValue)\n",(long long)orig_assetoshis,(long long)(remaining_assetoshis - received_assetoshis),(long long)remaining_assetoshis,(long long)received_assetoshis); + fprintf(stderr,"ValidateAssetRemainder() orig_assetoshis %llu != %llu (remaining_nValue %llu + %llu received_nValue)\n",(long long)orig_assetoshis,(long long)(remaining_assetoshis - received_assetoshis),(long long)remaining_assetoshis,(long long)received_assetoshis); return(false); } else @@ -159,10 +159,10 @@ bool ValidateAskRemainder(int64_t remaining_nValue,int64_t remaining_assetoshis, newunitprice = (remaining_nValue / remaining_assetoshis); if ( recvunitprice < unitprice ) { - fprintf(stderr,"error recvunitprice %.8f < %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/COIN,(double)unitprice/COIN,(double)newunitprice/COIN); + fprintf(stderr,"ValidateAskRemainder() error recvunitprice %.8f < %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/COIN,(double)unitprice/COIN,(double)newunitprice/COIN); return(false); } - fprintf(stderr,"got recvunitprice %.8f >= %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/COIN,(double)unitprice/COIN,(double)newunitprice/COIN); + fprintf(stderr,"ValidateAskRemainder() got recvunitprice %.8f >= %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/COIN,(double)unitprice/COIN,(double)newunitprice/COIN); } return(true); } @@ -172,7 +172,7 @@ bool SetSwapFillamounts(int64_t &received_assetoshis,int64_t &remaining_assetosh int64_t remaining_assetoshis; double dunitprice; if ( total_assetoshis2 == 0 ) { - fprintf(stderr,"total_assetoshis2.0 origsatoshis.%llu paid_assetoshis2.%llu\n",(long long)orig_assetoshis,(long long)paid_assetoshis2); + fprintf(stderr,"SetSwapFillamounts() total_assetoshis2.0 origsatoshis.%llu paid_assetoshis2.%llu\n",(long long)orig_assetoshis,(long long)paid_assetoshis2); received_assetoshis = remaining_assetoshis2 = paid_assetoshis2 = 0; return(false); } @@ -181,14 +181,14 @@ bool SetSwapFillamounts(int64_t &received_assetoshis,int64_t &remaining_assetosh paid_assetoshis2 = total_assetoshis2; received_assetoshis = orig_assetoshis; remaining_assetoshis2 = 0; - fprintf(stderr,"totally filled!\n"); + fprintf(stderr,"SetSwapFillamounts() swap order totally filled!\n"); return(true); } remaining_assetoshis2 = (total_assetoshis2 - paid_assetoshis2); dunitprice = ((double)total_assetoshis2 / orig_assetoshis); received_assetoshis = (paid_assetoshis2 / dunitprice); - fprintf(stderr,"remaining_assetoshis2 %llu (%llu - %llu)\n",(long long)remaining_assetoshis2/COIN,(long long)total_assetoshis2/COIN,(long long)paid_assetoshis2/COIN); - fprintf(stderr,"unitprice %.8f received_assetoshis %llu orig %llu\n",dunitprice/COIN,(long long)received_assetoshis,(long long)orig_assetoshis); + fprintf(stderr,"SetSwapFillamounts() remaining_assetoshis2 %llu (%llu - %llu)\n",(long long)remaining_assetoshis2/COIN,(long long)total_assetoshis2/COIN,(long long)paid_assetoshis2/COIN); + fprintf(stderr,"SetSwapFillamounts() unitprice %.8f received_assetoshis %llu orig %llu\n",dunitprice/COIN,(long long)received_assetoshis,(long long)orig_assetoshis); if ( fabs(dunitprice) > SMALLVAL && received_assetoshis > 0 && received_assetoshis <= orig_assetoshis ) { remaining_assetoshis = (orig_assetoshis - received_assetoshis); @@ -201,17 +201,17 @@ bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int6 int64_t unitprice,recvunitprice,newunitprice=0; if ( orig_nValue == 0 || received_nValue == 0 || paidunits == 0 || totalunits == 0 ) { - fprintf(stderr,"ValidateAssetRemainder: orig_nValue == %llu || received_nValue == %llu || paidunits == %llu || totalunits == %llu\n",(long long)orig_nValue,(long long)received_nValue,(long long)paidunits,(long long)totalunits); + fprintf(stderr,"ValidateAssetRemainder() orig_nValue == %llu || received_nValue == %llu || paidunits == %llu || totalunits == %llu\n",(long long)orig_nValue,(long long)received_nValue,(long long)paidunits,(long long)totalunits); return(false); } else if ( totalunits != (remaining_price + paidunits) ) { - fprintf(stderr,"ValidateAssetRemainder: totalunits %llu != %llu (remaining_price %llu + %llu paidunits)\n",(long long)totalunits,(long long)(remaining_price + paidunits),(long long)remaining_price,(long long)paidunits); + fprintf(stderr,"ValidateAssetRemainder() totalunits %llu != %llu (remaining_price %llu + %llu paidunits)\n",(long long)totalunits,(long long)(remaining_price + paidunits),(long long)remaining_price,(long long)paidunits); return(false); } else if ( orig_nValue != (remaining_nValue + received_nValue) ) { - fprintf(stderr,"ValidateAssetRemainder: orig_nValue %llu != %llu (remaining_nValue %llu + %llu received_nValue)\n",(long long)orig_nValue,(long long)(remaining_nValue - received_nValue),(long long)remaining_nValue,(long long)received_nValue); + fprintf(stderr,"ValidateAssetRemainder() orig_nValue %llu != %llu (remaining_nValue %llu + %llu received_nValue)\n",(long long)orig_nValue,(long long)(remaining_nValue - received_nValue),(long long)remaining_nValue,(long long)received_nValue); return(false); } else @@ -222,10 +222,10 @@ bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int6 newunitprice = (remaining_nValue * COIN) / remaining_price; if ( recvunitprice < unitprice ) { - fprintf(stderr,"error recvunitprice %.8f < %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/(COIN*COIN),(double)unitprice/(COIN*COIN),(double)newunitprice/(COIN*COIN)); + fprintf(stderr,"ValidateAssetRemainder() error recvunitprice %.8f < %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/(COIN*COIN),(double)unitprice/(COIN*COIN),(double)newunitprice/(COIN*COIN)); return(false); } - fprintf(stderr,"recvunitprice %.8f >= %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/(COIN*COIN),(double)unitprice/(COIN*COIN),(double)newunitprice/(COIN*COIN)); + fprintf(stderr,"ValidateAssetRemainder() recvunitprice %.8f >= %.8f unitprice, new unitprice %.8f\n",(double)recvunitprice/(COIN*COIN),(double)unitprice/(COIN*COIN),(double)newunitprice/(COIN*COIN)); } return(true); } @@ -279,19 +279,35 @@ bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &o return(0); } */ -uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) +uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey, std::vector &vopretNonfungible) { - std::vector vopretExtra, vopretStripped; - uint8_t *script, funcId = 0, assetFuncId = 0, dummyEvalCode, dummyAssetFuncId; + std::vector vopret1, vopret2; + std::vector vopretAssets; //, vopretAssetsStripped; + uint8_t *script, funcId = 0, assetsFuncId = 0, dummyEvalCode, dummyAssetFuncId; uint256 dummyTokenid; std::vector voutPubkeysDummy; tokenid = zeroid; assetid2 = zeroid; price = 0; + assetsEvalCode = 0; + assetsFuncId = 0; // First - decode token opret: - funcId = DecodeTokenOpRet(scriptPubKey, evalCodeInOpret, tokenid, voutPubkeysDummy, vopretExtra); + funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, vopret1, vopret2); + std::cerr << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl; + + if (!vopret2.empty()) { + // if there are both oprets then order is like this: + vopretNonfungible = vopret1; + vopretAssets = vopret2; + } + else { + // if only one opret - it is assets opret: + vopretNonfungible.clear(); + vopretAssets = vopret1; + } + /*GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -302,54 +318,59 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOp //bool isEof = true; // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! //bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); - if (funcId == 0 || vopretExtra.size() < 2) { - std::cerr << "DecodeAssetOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretExtra.size()=" << vopretExtra.size() << std::endl; + if (funcId == 0 || vopretAssets.size() < 2) { + std::cerr << "DecodeAssetTokenOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << std::endl; return (uint8_t)0; } - if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size - std::cerr << "DecodeAssetTokenOpRet() could not unmarshal vopretStripped" << std::endl; - return (uint8_t)0; - } + //if (!E_UNMARSHAL(vopretAssets, { ss >> vopretAssetsStripped; })) { //strip string size + // std::cerr << "DecodeAssetTokenOpRet() could not unmarshal vopretAssetsStripped" << std::endl; + // return (uint8_t)0; + //} - ////tokenid = revuint256(tokenid); already done in DecodeToken! - evalCodeInOpret = vopretStripped.begin()[0]; - assetFuncId = vopretStripped.begin()[1]; + // additional check to prevent crash + if (vopretAssets.size() >= 2) { - //std::cerr << "DecodeAssetOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; + assetsEvalCode = vopretAssets.begin()[0]; + assetsFuncId = vopretAssets.begin()[1]; - if(evalCodeInOpret == EVAL_ASSETS) - { - //fprintf(stderr,"decode.[%c] assetFuncId.[%c]\n", funcId, assetFuncId); - switch( assetFuncId ) + //std::cerr << "DecodeAssetTokenOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; + + if (assetsEvalCode == EVAL_ASSETS) { - case 'x': case 'o': - if (vopretStripped.size() == 2) // no data after 'evalcode assetFuncId' allowed + //fprintf(stderr,"DecodeAssetTokenOpRet() decode.[%c] assetFuncId.[%c]\n", funcId, assetFuncId); + switch (assetsFuncId) + { + case 'x': case 'o': + if (vopretAssets.size() == 2) // no data after 'evalcode assetFuncId' allowed { - return(assetFuncId); + return(assetsFuncId); } break; case 's': case 'b': case 'S': case 'B': - if (E_UNMARSHAL(vopretStripped, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) + if (E_UNMARSHAL(vopretAssets, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> price; ss >> origpubkey) != 0) { - //fprintf(stderr,"DecodeAssetTokenOpRet got price %llu\n",(long long)price); - return(assetFuncId); + //fprintf(stderr,"DecodeAssetTokenOpRet() got price %llu\n",(long long)price); + return(assetsFuncId); } break; case 'E': case 'e': - if ( E_UNMARSHAL(vopretStripped, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) + if (E_UNMARSHAL(vopretAssets, ss >> dummyEvalCode; ss >> dummyAssetFuncId; ss >> assetid2; ss >> price; ss >> origpubkey) != 0) { - //fprintf(stderr,"DecodeAssetTokenOpRet got price %llu\n",(long long)price); + //fprintf(stderr,"DecodeAssetTokenOpRet() got price %llu\n",(long long)price); assetid2 = revuint256(assetid2); - return(assetFuncId); + return(assetsFuncId); } break; default: - fprintf(stderr,"DecodeAssetTokenOpRet: illegal assetFuncId.%02x\n", assetFuncId); + fprintf(stderr, "DecodeAssetTokenOpRet() illegal assetFuncId.%02x\n", assetsFuncId); //funcId = 0; break; + } } } + + std::cerr << "DecodeAssetTokenOpRet() no asset's payload or incorrect assets evalcode" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << " assetsEvalCode=" << assetsEvalCode << " assetsFuncId=" << assetsFuncId << std::endl; return (uint8_t)0; } @@ -358,49 +379,55 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT { uint256 assetid,assetid2; uint8_t evalCode; - if ( tx.vout.size() > 0 && DecodeAssetTokenOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey) != 0 ) + std::vector vopretNonfungibleDummy; + + if ( tx.vout.size() > 0 && DecodeAssetTokenOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey, vopretNonfungibleDummy) != 0 ) return(true); else return(false); } -// Calculate sell/buy owner's source token/asset address from ask/bid tx -bool GetAssetorigaddrs(struct CCcontract_info *cp, char *userCCaddr, char *destaddr, const CTransaction& tx) +// Calculate seller/buyer's dest cc address from ask/bid tx funcid +bool GetAssetorigaddrs(struct CCcontract_info *cp, char *origCCaddr, char *origNormalAddr, const CTransaction& vintx) { - uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; + uint256 assetid, assetid2; + int64_t price,nValue=0; + int32_t n; + uint8_t vintxFuncId; std::vector origpubkey; CScript script; uint8_t evalCode; + std::vector vopretNonfungibleDummy; - n = tx.vout.size(); - if( n == 0 || (funcid = DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) == 0 ) + n = vintx.vout.size(); + if( n == 0 || (vintxFuncId = DecodeAssetTokenOpRet(vintx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey, vopretNonfungibleDummy)) == 0 ) return(false); bool bGetCCaddr = false; - if (funcid == 's' || funcid == 'S') { - struct CCcontract_info *cpTokens, tokensC; - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); - //bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)); + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + + if (vintxFuncId == 's' || vintxFuncId == 'S') { + // bGetCCaddr = GetCCaddress(cpTokens, origCCaddr, pubkey2pk(origpubkey)); + cpTokens->additionalTokensEvalcode2 = cp->additionalTokensEvalcode2; // add non-fungible if present + bGetCCaddr = GetTokensCCaddress(cpTokens, origCCaddr, pubkey2pk(origpubkey)); // tokens to single-eval token or token+nonfungible } - else if (funcid == 'b' || funcid == 'B') { - struct CCcontract_info *cpTokens, tokensC; - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey)); + else if (vintxFuncId == 'b' || vintxFuncId == 'B') { + cpTokens->additionalTokensEvalcode2 = cp->additionalTokensEvalcode2; // add non-fungible if present + bGetCCaddr = GetTokensCCaddress(cpTokens, origCCaddr, pubkey2pk(origpubkey)); // tokens to single-eval token or token+nonfungible } else { - std::cerr << "GetAssetorigaddrs incorrect funcid=" << (char)(funcid?funcid:' ') << std::endl; + std::cerr << "GetAssetorigaddrs incorrect vintx funcid=" << (char)(vintxFuncId?vintxFuncId:' ') << std::endl; return false; } - - if( bGetCCaddr && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG)) + if( bGetCCaddr && Getscriptaddress(origNormalAddr, CScript() << origpubkey << OP_CHECKSIG)) return(true); else return(false); } -int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) +int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *origCCaddr,char *origaddr,const CTransaction &tx,int32_t vini,CTransaction &vinTx) { uint256 hashBlock; uint256 assetid, assetid2; @@ -410,7 +437,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch char destaddr[64], unspendableAddr[64]; - origaddr[0] = destaddr[0] = CCaddr[0] = 0; + origaddr[0] = destaddr[0] = origCCaddr[0] = 0; uint8_t funcid = 0; if (tx.vout.size() > 0) { @@ -418,7 +445,9 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch int64_t tmpprice; std::vector tmporigpubkey; uint8_t evalCode; - funcid = DecodeAssetTokenOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey); + std::vector vopretNonfungibleDummy; + + funcid = DecodeAssetTokenOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey, vopretNonfungibleDummy); } if( tx.vin.size() < 2 ) @@ -427,45 +456,48 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch return eval->Invalid("vin1 needs to be buyvin.vout[0]"); else if( eval->GetTxUnconfirmed(tx.vin[vini].prevout.hash, vinTx,hashBlock) == 0 ) { - /* int32_t z; - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&tx.vin[vini].prevout.hash)[z]); - fprintf(stderr," vini.%d\n",vini); */ - std::cerr << "AssetValidateCCvin cannot load vintx for vin=" << vini << " vintx id=" << tx.vin[vini].prevout.hash.GetHex() << std::endl; + std::cerr << "AssetValidateCCvin() cannot load vintx for vin=" << vini << " vintx id=" << tx.vin[vini].prevout.hash.GetHex() << std::endl; return eval->Invalid("always should find CCvin, but didnt"); } - // if fillSell or cancelSell --> to spend tokens from dual-eval token-assets unspendable addr + // check source cc unspendable cc address: + // if fillSell or cancelSell --> should spend tokens from dual-eval token-assets unspendable addr else if( (funcid == 'S' || funcid == 'x') && (Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || !GetTokensCCaddress(cp, unspendableAddr, GetUnspendable(cp, NULL)) || strcmp(destaddr, unspendableAddr) != 0)) { - fprintf(stderr,"AssetValidateCCvin cc addr %s is not dual token-evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr); - return eval->Invalid("invalid vin AssetsCCaddr"); + fprintf(stderr,"AssetValidateCCvin() cc addr %s is not dual token-evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr); + return eval->Invalid("invalid vin assets CCaddr"); } - // if fillBuy or cancelBuy --> to spend coins from asset unspendable addr + // if fillBuy or cancelBuy --> should spend coins from asset unspendable addr else if ((funcid == 'B' || funcid == 'o') && (Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || !GetCCaddress(cp, unspendableAddr, GetUnspendable(cp, NULL)) || strcmp(destaddr, unspendableAddr) != 0)) { - fprintf(stderr, "AssetValidateCCvin cc addr %s is not evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr); - return eval->Invalid("invalid vin AssetsCCaddr"); + fprintf(stderr, "AssetValidateCCvin() cc addr %s is not evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr); + return eval->Invalid("invalid vin assets CCaddr"); } - + // end of check source unspendable cc address //else if ( vinTx.vout[0].nValue < 10000 ) // return eval->Invalid("invalid dust for buyvin"); - else if( GetAssetorigaddrs(cp, CCaddr, origaddr, vinTx) == 0 ) + // get user dest cc and normal addresses: + else if( GetAssetorigaddrs(cp, origCCaddr, origaddr, vinTx) == 0 ) return eval->Invalid("couldnt get origaddr for buyvin"); - fprintf(stderr,"AssetValidateCCvin got %.8f to origaddr.(%s)\n",(double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); + + fprintf(stderr,"AssetValidateCCvin() got %.8f to origaddr.(%s)\n", (double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); + if ( vinTx.vout[0].nValue == 0 ) return eval->Invalid("null value CCvin"); + return(vinTx.vout[0].nValue); } int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid) { CTransaction vinTx; int64_t nValue; uint256 assetid,assetid2; uint8_t funcid, evalCode; + std::vector vopretNonfungibleDummy; + CCaddr[0] = origaddr[0] = 0; // validate locked coins on Assets vin[1] @@ -473,7 +505,7 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout0 for buyvin"); - else if ((funcid = DecodeAssetTokenOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey)) == 'b' && + else if ((funcid = DecodeAssetTokenOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey, vopretNonfungibleDummy)) == 'b' && vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) // marker is only in 'b'? return eval->Invalid("invalid normal vout1 for buyvin"); else @@ -493,7 +525,7 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid) { CTransaction vinTx; int64_t nValue,assetoshis; - //fprintf(stderr,"AssetValidateSellvin\n"); + //fprintf(stderr,"AssetValidateSellvin()\n"); if ( (nValue = AssetValidateCCvin(cp, eval, CCaddr, origaddr, tx, 1, vinTx)) == 0 ) return(0); if ( (assetoshis= IsAssetvout(cp, tmpprice, tmporigpubkey, vinTx, 0, assetid)) == 0 ) @@ -508,13 +540,14 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr uint256 assetidOpret, assetidOpret2; uint8_t funcid, evalCode; + std::vector vopretNonfungibleDummy; // this is just for log messages indentation fur debugging recursive calls: int32_t n = tx.vout.size(); - if ((funcid = DecodeAssetTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey)) == 0) + if ((funcid = DecodeAssetTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey, vopretNonfungibleDummy)) == 0) { - std::cerr << "ValidateAssetOpret() DecodeAssetTokenOpRet returned null for the opret for txid=" << tx.GetHash().GetHex() << std::endl; + std::cerr << "ValidateAssetOpret() DecodeAssetTokenOpRet returned funcId=0 for opret from txid=" << tx.GetHash().GetHex() << std::endl; return(false); } /* it is now on token level: @@ -556,22 +589,20 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr } // Checks if the vout is a really Asset CC vout -// compareTotals == true, the func also validates the passed transaction itself: -// it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid) { //std::cerr << "IsAssetvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for assetid=" << refassetid.GetHex() << std::endl; + int32_t n = tx.vout.size(); + // just check boundaries: + if (v >= n - 1) { // just moved this up (dimxy) + std::cerr << "isAssetVout() internal err: (v >= n - 1), returning 0" << std::endl; + return(0); + } + if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here { - int32_t n = tx.vout.size(); - // just check boundaries: - if (v >= n - 1) { // just moved this up (dimxy) - std::cerr << "isAssetVout() internal err: (v >= n - 1), returning 0" << std::endl; - return(0); - } - // moved opret checking to this new reusable func (dimxy): const bool valOpret = ValidateAssetOpret(tx, v, refassetid, price, origpubkey); //std::cerr << "IsAssetvout() ValidateAssetOpret returned=" << std::boolalpha << valOpret << " for txid=" << tx.GetHash().GetHex() << " for assetid=" << refassetid.GetHex() << std::endl; @@ -627,12 +658,9 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t } } - for (int32_t i = 0; i < numvouts; i++) + for (int32_t i = 0; i < numvouts-1; i++) { - // Note: we pass in here 'false' because we don't need to call AssetExactAmounts() recursively from IsAssetvout - // indeed, in this case we'll be checking this tx again assetoshis = IsAssetvout(cpAssets, tmpprice, tmporigpubkey, tx, i, assetid); - if (assetoshis != 0) { std::cerr << "AssetCalcAmounts() vout i=" << i << " assetoshis=" << assetoshis << std::endl; @@ -643,12 +671,6 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t //std::cerr << "AssetCalcAmounts() inputs=" << inputs << " outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; /* we do not verify inputs == outputs here, - it's done in Tokens: - if (inputs != outputs) { - if (tx.GetHash() != assetid) { - std::cerr << "AssetCalcAmounts() unequal inputs=" << inputs << " vs outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << std::endl; - return (!eval) ? false : eval->Invalid("assets cc inputs != cc outputs"); - } - } */ + it's now done in Tokens */ return(true); } diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 9d83beb2c..c057237f9 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -14,9 +14,9 @@ ******************************************************************************/ #include "CCassets.h" -//#include "CCtokens.h" - +#include "CCtokens.h" +/* use AddTokenCCInputs instead int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) { char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t j,vout,n = 0; @@ -64,25 +64,19 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK //std::cerr << "AddAssetInputs() found totalinputs=" << totalinputs << std::endl; return(totalinputs); } - +*/ UniValue AssetOrders(uint256 refassetid) { static uint256 zero; UniValue result(UniValue::VARR); - std::vector > unspentOutputsTokens, unspentOutputsAssets; - - struct CCcontract_info *cpTokens, tokensC; - struct CCcontract_info *cpAssets, assetsC; - - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - cpAssets = CCinit(&assetsC, EVAL_ASSETS); auto addOrders = [&](struct CCcontract_info *cp, std::vector >::const_iterator it) { uint256 txid, hashBlock, assetid, assetid2; int64_t price; std::vector origpubkey; + std::vector vopretNonfungible; CTransaction vintx; uint8_t funcid, evalCode; char numstr[32], funcidstr[16], origaddr[64], assetidstr[65]; @@ -93,7 +87,7 @@ UniValue AssetOrders(uint256 refassetid) { // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); //std::cerr << "addOrders() vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl; - if (vintx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) + if (vintx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey, vopretNonfungible)) != 0) { if (refassetid != zero && assetid != refassetid) { @@ -163,25 +157,35 @@ UniValue AssetOrders(uint256 refassetid) } }; + std::vector > unspentOutputsTokens, unspentOutputsCoins; + struct CCcontract_info *cpAssets, assetsC; + + cpAssets = CCinit(&assetsC, EVAL_ASSETS); char assetsUnspendableAddr[64]; GetCCaddress(cpAssets, assetsUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsAssets, assetsUnspendableAddr /*(char *)cpTokens->unspendableCCaddr*/); + SetCCunspents(unspentOutputsCoins, assetsUnspendableAddr); - char tokensUnspendableAddr[64]; - GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsAssets, tokensUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/); + char assetsTokensUnspendableAddr[64]; + std::vector vopretNonfungible; + GetNonfungibleData(refassetid, vopretNonfungible); + if (vopretNonfungible.size() > 0) + cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + GetTokensCCaddress(cpAssets, assetsTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); + SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr); - for (std::vector >::const_iterator itTokens = unspentOutputsTokens.begin(); + // tokenasks: + for (std::vector >::const_iterator itCoins = unspentOutputsCoins.begin(); + itCoins != unspentOutputsCoins.end(); + itCoins++) + addOrders(cpAssets, itCoins); + + // tokenbids: + for (std::vector >::const_iterator itTokens = unspentOutputsTokens.begin(); itTokens != unspentOutputsTokens.end(); itTokens++) - addOrders(cpTokens, itTokens); + addOrders(cpAssets, itTokens); - for (std::vector >::const_iterator itAssets = unspentOutputsAssets.begin(); - itAssets != unspentOutputsAssets.end(); - itAssets++) - addOrders(cpAssets, itAssets); - return(result); } @@ -328,14 +332,14 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in return (""); } - CPubKey unspendablePubkey = GetUnspendable(cpAssets, 0); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount, unspendablePubkey)); + CPubKey unspendableAssetsPubkey = GetUnspendable(cpAssets, 0); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount, unspendableAssetsPubkey)); mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); std::vector voutTokenPubkeys; // should be empty - no token vouts return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, - EncodeAssetOpRet('b', zeroid, pricetotal, Mypubkey())))); + EncodeTokenOpRet(assetid, voutTokenPubkeys, // TODO: actually this tx is not 'tokens', maybe it is better not to have token opret here but only asset opret. + EncodeAssetOpRet('b', zeroid, pricetotal, Mypubkey())))); // But still such token opret should not make problems because no token eval in these vouts } CCerror = strprintf("no coins found to make buy offer"); return(""); @@ -348,7 +352,6 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p CPubKey mypk; uint64_t mask; int64_t inputs, CCchange; - CScript opret; struct CCcontract_info *cpAssets, assetsC; struct CCcontract_info *cpTokens, tokensC; @@ -359,7 +362,8 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return(""); } - cpAssets = CCinit(&assetsC, EVAL_ASSETS); // NOTE: this is for signing + cpAssets = CCinit(&assetsC, EVAL_ASSETS); // NOTE: for signing + if (txfee == 0) txfee = 10000; @@ -367,10 +371,11 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p mypk = pubkey2pk(Mypubkey()); if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { + std::vector vopretNonfungible; mask = ~((1LL << mtx.vin.size()) - 1); - // add single-eval tokens: - cpTokens = CCinit(&tokensC, EVAL_TOKENS); // NOTE: tokens is here - if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, askamount, 60)) > 0) + // add single-eval tokens (or non-fungible tokens): + cpTokens = CCinit(&tokensC, EVAL_TOKENS); // NOTE: adding inputs only from EVAL_TOKENS cc + if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, askamount, 60, vopretNonfungible)) > 0) { if (inputs < askamount) { //was: askamount = inputs; @@ -379,20 +384,26 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return (""); } - CPubKey unspendablePubkey = GetUnspendable(cpAssets, NULL); - mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, askamount, unspendablePubkey)); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); //marker + // if this is non-fungible tokens: + if( !vopretNonfungible.empty() ) + // set its evalcode + cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + + CPubKey unspendableAssetsPubkey = GetUnspendable(cpAssets, NULL); + mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, cpAssets->additionalTokensEvalcode2, askamount, unspendableAssetsPubkey)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); //marker (seems, it is not for tokenorders) if (inputs > askamount) CCchange = (inputs - askamount); if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // change to single-eval token vout + // change to single-eval or non-fungible token vout (although for non-fungible token change currently is not possible) + mtx.vout.push_back(MakeTokensCC1vout((cpAssets->additionalTokensEvalcode2) ? cpAssets->additionalTokensEvalcode2 : EVAL_TOKENS, CCchange, mypk)); std::vector voutTokenPubkeys; - voutTokenPubkeys.push_back(unspendablePubkey); + voutTokenPubkeys.push_back(unspendableAssetsPubkey); - opret = EncodeTokenOpRet(assetid, voutTokenPubkeys, - EncodeAssetOpRet('s', zeroid, pricetotal, Mypubkey())); - return(FinalizeCCTx(mask,cpAssets, mtx, mypk, txfee, opret)); + return FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, + EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, + EncodeAssetOpRet('s', zeroid, pricetotal, Mypubkey()))); } else { fprintf(stderr, "need some tokens to place ask\n"); @@ -430,7 +441,7 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if ((inputs = AddAssetInputs(cp, mtx, mypk, assetid, askamount, 60)) > 0) + /*if ((inputs = AddAssetInputs(cp, mtx, mypk, assetid, askamount, 60)) > 0) { ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// if (inputs < askamount) { @@ -458,13 +469,13 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a else { opret = EncodeTokenOpRet(assetid, voutTokenPubkeys, EncodeAssetOpRet('e', assetid2, pricetotal, Mypubkey())); - } + } ////////////////////////// NOT IMPLEMENTED YET///////////////////////////////// return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); } else { fprintf(stderr, "need some assets to place ask\n"); - } + } */ } else { // dimxy added 'else', because it was misleading message before fprintf(stderr,"need some native coins to place ask\n"); @@ -494,12 +505,13 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) { + std::vector vopretNonfungible; + bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets - if((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) + if((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey, vopretNonfungible))!=0) { - if (funcid == 's') mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' else if (funcid=='S') mtx.vin.push_back(CTxIn(bidtxid, 3, CScript())); // spend marker if funcid='B' } @@ -510,7 +522,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) std::vector voutTokenPubkeys; // should be empty, no token vouts return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, EncodeAssetOpRet('o', zeroid, 0, Mypubkey())))); } } @@ -523,8 +535,12 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; - CPubKey mypk; struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; - uint8_t funcid,dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; + CPubKey mypk; + struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; + uint8_t funcid, dummyEvalCode; + uint256 dummyAssetid, dummyAssetid2; + int64_t dummyPrice; + std::vector dummyOrigpubkey; cpAssets = CCinit(&assetsC, EVAL_ASSETS); @@ -538,27 +554,27 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) { + std::vector vopretNonfungible; askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); - if ((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) + if ((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey, vopretNonfungible))!=0) { - if (funcid == 's') mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' - else if (funcid=='S') mtx.vin.push_back(CTxIn(asktxid, 3, CScript())); // marker if funcid='S' + if (funcid == 's') + mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' + else if (funcid=='S') + mtx.vin.push_back(CTxIn(asktxid, 3, CScript())); // marker if funcid='S' } - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); // one-eval token vout + if (vopretNonfungible.size() > 0) + cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + + mtx.vout.push_back(MakeTokensCC1vout(cpAssets->additionalTokensEvalcode2 == 0 ? EVAL_TOKENS : cpAssets->additionalTokensEvalcode2, askamount, mypk)); // one-eval token vout mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(mypk); - /* char myCCaddr[65]; - uint8_t myPrivkey[32]; - Myprivkey(myPrivkey); - cpAssets = CCinit(&assetsC, EVAL_ASSETS); - GetCCaddress(cpAssets, myCCaddr, mypk); */ - // this is only for unspendable addresses: //CCaddr2set(cpTokens, EVAL_ASSETS, mypk, myPrivkey, myCCaddr); //do we need this? Seems FinalizeCCTx can attach to any evalcode cc addr by calling Getscriptaddress @@ -572,7 +588,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) CCaddr2set(cpAssets, EVAL_TOKENS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, EncodeAssetOpRet('x', zeroid, 0, Mypubkey())))); } } @@ -614,8 +630,9 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f SetAssetOrigpubkey(origpubkey, origprice, vintx); mtx.vin.push_back(CTxIn(bidtxid, bidvout, CScript())); // Coins on Assets unspendable - - if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, fillamount, 60)) > 0) + + std::vector vopretNonfungible; + if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, assetid, fillamount, 60, vopretNonfungible)) > 0) { if (inputs < fillamount) { std::cerr << "FillBuyOffer(): insufficient tokens to fill buy offer" << std::endl; @@ -624,6 +641,10 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f } SetBidFillamounts(paid_amount, remaining_required, bidamount, fillamount, origprice); + + uint8_t additionalTokensEvalcode2 = 0; + if (vopretNonfungible.size() > 0) + additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; if (inputs > fillamount) CCchange = (inputs - fillamount); @@ -634,13 +655,13 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); // vout1 coins to normal - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // vout2 single-eval tokens sent to the buyer - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,txfee,origpubkey)); // vout3 marker to origpubkey + mtx.vout.push_back(MakeTokensCC1vout(additionalTokensEvalcode2 == 0 ? EVAL_TOKENS : additionalTokensEvalcode2, fillamount, pubkey2pk(origpubkey))); // vout2 single-eval tokens sent to the originator + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, origpubkey)); // vout3 marker to origpubkey if (CCchange != 0) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // vout4 change in single-eval tokens - fprintf(stderr,"FillBuyOffer remaining %llu -> origpubkey\n", (long long)remaining_required); + fprintf(stderr,"FillBuyOffer() remaining %llu -> origpubkey\n", (long long)remaining_required); char unspendableAssetsAddr[64]; cpAssets = CCinit(&assetsC, EVAL_ASSETS); @@ -653,8 +674,8 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(pubkey2pk(origpubkey)); - return(FinalizeCCTx(mask,cpTokens,mtx,mypk,txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, + return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, + EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, EncodeAssetOpRet('B', zeroid, remaining_required, origpubkey)))); } else return("dont have any assets to fill bid"); } @@ -691,15 +712,21 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a return(""); } + std::vector vopretNonfungible; + uint8_t additionalTokensEvalcode2 = 0; + GetNonfungibleData(assetid, vopretNonfungible); + if (vopretNonfungible.size() > 0) + additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + cpAssets = CCinit(&assetsC, EVAL_ASSETS); if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) - { - mask = ~((1LL << mtx.vin.size()) - 1); + //if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) + //{ + //mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) { orig_assetoshis = vintx.vout[askvout].nValue; @@ -707,13 +734,12 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a dprice = (double)total_nValue / orig_assetoshis; paid_nValue = dprice * fillunits; - mtx.vin.push_back(CTxIn(asktxid, askvout, CScript())); // NOTE: this is the reference to tokens -> send cpTokens for signing into FinalizeCCTx! - - if (assetid2 != zeroid) - inputs = AddAssetInputs(cpAssets, mtx, mypk, assetid2, paid_nValue, 60); // not implemented yet + if (assetid2 != zeroid) { + inputs = 0; // = AddAssetInputs(cpAssets, mtx, mypk, assetid2, paid_nValue, 60); // not implemented yet + } else { - inputs = AddNormalinputs(mtx, mypk, paid_nValue, 60); + inputs = AddNormalinputs(mtx, mypk, 2 * txfee + paid_nValue, 60); // Better to use single AddNormalinputs() to allow payment if user has only single utxo with normal funds mask = ~((1LL << mtx.vin.size()) - 1); } if (inputs > 0) @@ -723,7 +749,10 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a CCerror = strprintf("insufficient coins to fill sell"); return (""); } - + + // cc vin should be after normal vin + mtx.vin.push_back(CTxIn(asktxid, askvout, CScript())); + if (assetid2 != zeroid) SetSwapFillamounts(received_assetoshis, remaining_nValue, orig_assetoshis, paid_nValue, total_nValue); //not implemented correctly yet else @@ -732,11 +761,11 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a if (assetid2 != zeroid && inputs > paid_nValue) CCchange = (inputs - paid_nValue); - mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); // vout.0 tokens remainder to unspendable cc addr - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, received_assetoshis, mypk)); //vout.1 purchased tokens to self single-eval addr + // vout.0 tokens remainder to unspendable cc addr: + mtx.vout.push_back(MakeTokensCC1vout(EVAL_ASSETS, additionalTokensEvalcode2, orig_assetoshis - received_assetoshis, GetUnspendable(cpAssets, NULL))); + //vout.1 purchased tokens to self token single-eval or dual-eval token+nonfungible cc addr: + mtx.vout.push_back(MakeTokensCC1vout(additionalTokensEvalcode2 == 0 ? EVAL_TOKENS : additionalTokensEvalcode2, received_assetoshis, mypk)); - // NOTE: no marker here - if (assetid2 != zeroid) { std::cerr << "FillSell() WARNING: asset swap not implemented yet! (paid_nValue)" << std::endl; // TODO: change MakeCC1vout appropriately when implementing: @@ -768,14 +797,16 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(mypk); + cpAssets->additionalTokensEvalcode2 = additionalTokensEvalcode2; + return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid2, remaining_nValue, origpubkey)))); } else { CCerror = strprintf("filltx not enough utxos"); fprintf(stderr,"%s\n", CCerror.c_str()); } } - } + //} return(""); } diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 8e878d37d..d2cb811cd 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -290,6 +290,9 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) { + // important to clear because not all members are always initialized! + memset(cp, '\0', sizeof(*cp)); + cp->evalcode = evalcode; switch ( evalcode ) { diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 4da696547..1cb141a16 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -89,6 +89,7 @@ struct CCcontract_info { // this is for spending from 'unspendable' CC address uint8_t evalcode; + uint8_t additionalTokensEvalcode2; // this is for making three-eval-token vouts (EVAL_TOKENS + evalcode + additionalEvalcode2) char unspendableCCaddr[64], CChexstr[72], normaladdr[64]; uint8_t CCpriv[32]; @@ -103,7 +104,7 @@ struct CCcontract_info // this is for spending from two additional 'unspendable' CC addresses of other eval codes // (that is, for spending from several cc contract 'unspendable' addresses): - uint8_t evalcode2, evalcode3; + uint8_t unspendableEvalcode2, unspendableEvalcode3; // changed evalcodeN to unspendableEvalcodeN for not mixing up with additionalEvalcodeN char unspendableaddr2[64], unspendableaddr3[64]; uint8_t unspendablepriv2[32], unspendablepriv3[32]; CPubKey unspendablepk2, unspendablepk3; @@ -160,17 +161,19 @@ uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); //int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs, std::vector &vopretNonfungible); int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); -//bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); -uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &evalCodeInOpret, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); +CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector vopretNonfungible); +CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload); //old version CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload); -CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload); +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector vpayloadNonfungible, CScript payload); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector &vopretNonfungible); uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra); +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2); uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t *data,int32_t offset,int32_t datalen); @@ -193,12 +196,14 @@ CC* GetCryptoCondition(CScript const& scriptSig); void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); - CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); +CTxOut MakeTokensCC1of2vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk1, CPubKey pk2); CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); +CTxOut MakeTokensCC1vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk); +CC *MakeTokensCCcond1of2(uint8_t evalcode, uint8_t evalcode2, CPubKey pk1, CPubKey pk2); CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2); CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk); - +CC *MakeTokensCCcond1(uint8_t evalcode, uint8_t evalcode2, CPubKey pk); bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk); bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); @@ -245,4 +250,29 @@ void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uin bits256 bits256_doublesha256(char *deprecated,uint8_t *data,int32_t datalen); UniValue ValueFromAmount(const CAmount& amount); + +// bitcoin LogPrintStr with category "-debug" cmdarg support for C++ ostringstream: +#define CCLOG_INFO 0 +#define CCLOG_DEBUG1 1 +#define CCLOG_DEBUG2 2 +#define CCLOG_DEBUG3 3 +template +inline void CCLogPrintStream(char *category, int level, T print_to_stream) +{ + std::ostringstream stream; + print_to_stream(stream); + if (level < 0) + level = 0; + if (level > 3) + level = 3; + for (int i = 0; i < level; i++) + if (LogAcceptCategory((std::string(category) + (level > 0 ? std::string("-") + std::to_string(level) : std::string(""))).c_str())) { + LogPrintStr(stream.str()); + break; + } +} + +#define LOGSTREAM(category, level, logoperator) CCLogPrintStream( category, level, [=](std::ostringstream &stream) {logoperator;} ) + + #endif diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index d7db32b99..23a4fda50 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -43,15 +43,25 @@ // NOTE: this inital tx won't be used by other contract // for tokens to be used there should be at least one 't' tx with other contract's custom opret -CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description) +CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector vopretNonfungible ) { - CScript opret; uint8_t evalcode = EVAL_TOKENS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description); + CScript opret; + uint8_t evalcode = EVAL_TOKENS; + funcid = 'c'; // override the param + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description; \ + if(!vopretNonfungible.empty()) ss << vopretNonfungible ); return(opret); } // this is for other contracts which use tokens and build customized extra payloads to token's opret: CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload) +{ + std::vector vpayloadNonfungibleEmpty; + return EncodeTokenOpRet(tokenid, voutPubkeys, vpayloadNonfungibleEmpty, payload); +} + +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector vpayloadNonfungible, CScript payload) { CScript opret; uint8_t tokenFuncId = 't'; @@ -60,17 +70,20 @@ CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScr tokenid = revuint256(tokenid); uint8_t ccType = 0; - if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) + if (voutPubkeys.size() >= 0 && voutPubkeys.size() <= 2) ccType = voutPubkeys.size(); + else { + LOGSTREAM("tokens", CCLOG_INFO, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); + } std::vector vpayload; GetOpReturnData(payload, vpayload); - opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ - if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1]; \ - if (vpayload.size() > 0) ss << vpayload;); - + opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ + if (ccType >= 1) ss << voutPubkeys[0]; \ + if (ccType == 2) ss << voutPubkeys[1]; \ + if (vpayloadNonfungible.size() > 0) ss << vpayloadNonfungible; \ + if (vpayload.size() > 0) ss << vpayload); // "error 64: scriptpubkey": // if (payload.size() > 0) @@ -96,21 +109,50 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t return EncodeTokenOpRet(tokenid, voutPubkeys, payload); } -uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description) +// overload for fungible: +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description) { + std::vector vopretNonfungibleDummy; + return DecodeTokenCreateOpRet(scriptPubKey, origpubkey, name, description, vopretNonfungibleDummy); +} + +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description, std::vector &vopretNonfungible) { std::vector vopret; uint8_t dummyEvalcode, funcid, *script; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); + if ( script != 0 && vopret.size() > 2 && script[0] == EVAL_TOKENS && script[1] == 'c' ) { - if ( E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description) != 0 ) + if( E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description; \ + // we suppose in 'c' opret it might be only non-fungible payload and not any assets/heir/etc payloads + if(!ss.eof()) ss >> vopretNonfungible ) ) return(funcid); } return (uint8_t)0; } -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) +// overload for compatibility allows only usual fungible tokens: +// warning: it makes vopret marshalling to CScript because this is what caller would expect +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { + std::vector vopret1, vopret2; + uint8_t funcId = DecodeTokenOpRet(scriptPubKey, evalCode, tokenid, voutPubkeys, vopret1, vopret2); + + CScript opretExtra; + vopretExtra.clear(); + + // make marshalling for compatibility + // callers of this func expect length of full array at the beginning (and they will make 'vopretStripped' from vopretExtra) + if (vopret2.empty()) + opretExtra << OP_RETURN << E_MARSHAL(ss << vopret1); // if first opret (or no oprets) + else + opretExtra << OP_RETURN << E_MARSHAL(ss << vopret2); // if both oprets present, return assets/heir/gateways/... opret (dump non-fungible opret) + + GetOpReturnData(opretExtra, vopretExtra); + return funcId; +} + +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2) { std::vector vopret, extra, dummyPubkey; uint8_t funcId=0, *script, dummyEvalCode, dummyFuncId, ccType; @@ -121,32 +163,39 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 script = (uint8_t *)vopret.data(); tokenid = zeroid; - if (script != 0 && vopret.size() > 2) + if (script != NULL && vopret.size() > 2) { // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! bool isEof = true; - evalCode = script[0]; - if (evalCode != EVAL_TOKENS) + evalCodeTokens = script[0]; + if (evalCodeTokens != EVAL_TOKENS) return (uint8_t)0; funcId = script[1]; - //fprintf(stderr,"decode.[%c]\n",funcId); + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); switch( funcId ) { case 'c': - return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription); + return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription, vopret1); //break; case 't': //not used yet: case 'l': // NOTE: 'E_UNMARSHAL result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' - if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; if (ccType >= 1) ss >> voutPubkey1; if (ccType == 2) ss >> voutPubkey2; isEof = ss.eof(); vopretExtra = std::vector(ss.begin(), ss.end())) - || !isEof) + if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; \ + if (ccType >= 1) ss >> voutPubkey1; \ + if (ccType == 2) ss >> voutPubkey2; \ + isEof = ss.eof(); \ + if (!isEof) ss >> vopret1; \ + isEof = ss.eof(); \ + if (!isEof) { ss >> vopret2; } \ + // if something else remains -> bad format + isEof = ss.eof()) || !isEof) { if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType - std::cerr << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl; + LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); return (uint8_t)0; } @@ -160,22 +209,20 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 tokenid = revuint256(tokenid); return(funcId); } - std::cerr << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl; + LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); return (uint8_t)0; default: - std::cerr << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl; + LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl); return (uint8_t)0; } } else { - std::cerr << "DecodeTokenOpRet() empty opret, could not parse" << std::endl; + LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() empty opret, could not parse" << std::endl); } return (uint8_t)0; } - - // tx validation bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn) { @@ -183,7 +230,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & CTxDestination address; CTransaction vinTx, createTx; uint256 hashBlock, tokenid, tokenid2; int32_t i, starti, numvins, numvouts, preventCCvins, preventCCvouts; int64_t remaining_price, nValue, tokenoshis, outputs, inputs, tmpprice, totalunits, ignore; - std::vector vopretExtra, tmporigpubkey, ignorepubkey; + std::vector vopret1, vopret2, tmporigpubkey, ignorepubkey; uint8_t funcid, evalCodeInOpret; char destaddr[64], origaddr[64], CCaddr[64]; std::vector voutTokenPubkeys; @@ -195,10 +242,10 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & outputs = inputs = 0; preventCCvins = preventCCvouts = -1; - if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopret1, vopret2)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); - fprintf(stderr, "TokensValidate (%c) evalcode=0x%0x\n", funcid, cp->evalcode); + LOGSTREAM("tokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode); if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); @@ -218,6 +265,12 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & } } + // non-fungible tokens validation: + std::vector vopretNonfungible; + GetNonfungibleData(tokenid, vopretNonfungible); + if (vopretNonfungible.size() > 0 && vopretNonfungible != vopret1) // assuming tx vopretNonfungible in vopret1 + return eval->Invalid("incorrect or empty non-fungible data"); + switch (funcid) { @@ -240,11 +293,11 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (inputs == 0) return eval->Invalid("no token inputs for transfer"); - fprintf(stderr, "token transfer preliminarily validated %.8f -> %.8f (%d %d)\n", (double)inputs / COIN, (double)outputs / COIN, preventCCvins, preventCCvouts); + LOGSTREAM("tokens", CCLOG_INFO, stream << "token transfer preliminarily validated inputs=" << inputs << "->outputs=" << outputs << " preventCCvins=" << preventCCvins<< " preventCCvouts=" << preventCCvouts << std::endl); break; // breaking to other contract validation... default: - fprintf(stderr, "illegal tokens funcid.(%c)\n", funcid); + LOGSTREAM("tokens", CCLOG_INFO, stream << "illegal tokens funcid=" << (char)(funcid?funcid:' ') << std::endl); return eval->Invalid("unexpected token funcid"); } @@ -266,7 +319,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & // helper funcs: -// extract my vins pubkeys: +// extract cc token vins' pubkeys: bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys) { bool found = false; @@ -276,12 +329,13 @@ bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys) cpTokens = CCinit(&tokensC, EVAL_TOKENS); for (int32_t i = 0; i < tx.vin.size(); i++) - { // check for additional contracts which may send tokens to the Tokens contract + { + // check for cc token vins: if( (*cpTokens->ismyvin)(tx.vin[i].scriptSig) ) { auto findEval = [](CC *cond, struct CCVisitor _) { - bool r = false; //cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == EVAL_TOKENS; + bool r = false; if (cc_typeId(cond) == CC_Secp256k1) { *(CPubKey*)_.context = buf2pk(cond->publicKey); @@ -313,38 +367,49 @@ bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys) thread_local uint32_t tokenValIndentSize = 0; // validates opret for token tx: -uint8_t ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { +uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { - uint256 tokenidOpret, tokenidOpret2; + uint256 tokenidOpret = zeroid; uint8_t funcid; uint8_t dummyEvalCode; + std::vector voutPubkeysDummy; + std::vector vopretExtraDummy; // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - int32_t n = tx.vout.size(); + if (tx.vout.size() == 0) + return (uint8_t)0; - if ((funcid = DecodeTokenOpRet(tx.vout[n - 1].scriptPubKey, dummyEvalCode, tokenidOpret, voutPubkeys, vopretExtra)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenidOpret, voutPubkeysDummy, vopretExtraDummy)) == 0) { - std::cerr << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl; - return(false); + LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl); + return (uint8_t)0; } else if (funcid == 'c') { - if (tokenid != zeroid && tokenid == tx.GetHash() && v == 0) { - //std::cerr << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; + if (tokenid != zeroid && tokenid == tx.GetHash()) { + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); return funcid; } + else { + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenbase txid=" << tx.GetHash().GetHex() << std::endl); + } } else if (funcid == 't') { //std::cerr << indentStr << "ValidateTokenOpret() tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; if (tokenid != zeroid && tokenid == tokenidOpret) { - //std::cerr << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " vout=" << v << " returning true" << std::endl; + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); return funcid; } + else { + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenid=" << tokenidOpret.GetHex() << std::endl); + } } - //std::cerr << indentStr << "ValidateTokenOpret() return false funcid=" << (char)funcid << " tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; + else { + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not supported funcid=" << (char)funcid << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl); + } return (uint8_t)0; } @@ -358,20 +423,20 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - //std::cerr << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl; + + LOGSTREAM("tokens", CCLOG_DEBUG2, stream << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl); + + int32_t n = tx.vout.size(); + // just check boundaries: + if (n == 0 || v < 0 || v >= n-1) { + LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "isTokensvout() incorrect params: (n == 0 or v < 0 or v >= n-1)" << " v=" << v << " n=" << n << " returning 0" << std::endl); + return(0); + } //TODO: validate cc vouts are EVAL_TOKENS! if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here { - int32_t n = tx.vout.size(); - // just check boundaries: - if (v >= n - 1) { // just moved this up (dimxy) - std::cerr << indentStr << "isTokensvout() internal err: (v >= n - 1), returning 0" << std::endl; - return(0); - } - if (goDeeper) { - //std::cerr << indentStr << "IsTokensvout() maxTokenExactAmountDepth=" << maxTokenExactAmountDepth << std::endl; //validate all tx int64_t myCCVinsAmount = 0, myCCVoutsAmount = 0; @@ -384,98 +449,109 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // if ccInputs != ccOutputs and it is not the tokenbase tx // this means it is possibly a fake tx (dimxy): if (reftokenid != tx.GetHash()) { // checking that this is the true tokenbase tx, by verifying that funcid=c, is done further in this function (dimxy) - std::cerr << indentStr << "IsTokensvout() warning: for the verified tx detected a bad vintx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping the verified tx" << std::endl; + LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() warning: for the verified tx detected a bad vintx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping the verified tx" << std::endl); return 0; } } } - // moved opret checking to this new reusable func (dimxy): - std::vector voutPubkeys; - std::vector vopretExtra; - const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); + // token opret most important checks (tokenid == reftokenid, tokenid is non-zero, tx is 'tokenbase'): + const uint8_t funcId = ValidateTokenOpret(tx, reftokenid); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { - //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null funcId=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); - if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!): + uint8_t dummyEvalCode; + uint256 tokenIdOpret; + std::vector voutPubkeys; + std::vector vopret1; + std::vector vopret2; + DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeys, vopret1, vopret2); - //std::cerr << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl; - - uint8_t evalCodeInOpret; - if (vopretExtra.size() >= 2 /*|| vopretExtra.size() != vopretExtra.begin()[0] <-- shold we check this?*/) { - evalCodeInOpret = vopretExtra.begin()[1]; - } - else { - // if payload is empty maybe it is a claim to non-payload-one-token-eval vout? - evalCodeInOpret = EVAL_TOKENS; - } + if (checkPubkeys && funcId != 'c') { // for 'c' there is no pubkeys + // verify that the vout is token by constructing vouts with the pubkeys in the opret: + LOGSTREAM("tokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret1=" << HexStr(vopret1) << std::endl); + LOGSTREAM("tokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret2=" << HexStr(vopret2) << std::endl); + + uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim + uint8_t evalCode2 = 0; // will be checked if zero or not + + // NOTE: evalcode order in vouts is important: + // non-fungible-eval -> EVAL_TOKENS -> assets-eval + if (vopret1.size() > 0) { + evalCode = vopret1.begin()[0]; + } + if (vopret2.size() > 0) { + evalCode2 = vopret2.begin()[0]; + } + + // checking vouts for possible token use-cases: + std::vector> testVouts; // maybe this is dual-eval 1 pubkey or 1of2 pubkey vout? if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { - CTxOut testDualVout; - // check dual-eval 1 pubkey vout with the first pubkey - testDualVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0]); - if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout (i=0), eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; - } - - if(voutPubkeys.size() == 2) { - // check dual eval 1of2 pubkeys vout - testDualVout = MakeTokensCC1of2vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]); - if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() this is dual-eval token 1of2 vout, eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; - } + // check dual/three-eval 1 pubkey vout with the first pubkey + testVouts.push_back( std::make_pair(MakeTokensCC1vout(evalCode, evalCode2, tx.vout[v].nValue, voutPubkeys[0]), std::string("three-eval cc1 pk[0]")) ); + if (evalCode2 != 0) + // also check in backward evalcode order + testVouts.push_back( std::make_pair(MakeTokensCC1vout(evalCode2, evalCode, tx.vout[v].nValue, voutPubkeys[0]), std::string("three-eval cc1 pk[0] backward-eval")) ); - // check dual eval 1 pubkey vout with the second pubkey - testDualVout = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, voutPubkeys[1]); - if (tx.vout[v].scriptPubKey == testDualVout.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() this is dual-eval token vout (i=1), eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; - } + if(voutPubkeys.size() == 2) { + // check dual/three eval 1of2 pubkeys vout + testVouts.push_back( std::make_pair(MakeTokensCC1of2vout(evalCode, evalCode2, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]), std::string("three-eval cc1of2")) ); + // check dual/three eval 1 pubkey vout with the second pubkey + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode, evalCode2, tx.vout[v].nValue, voutPubkeys[1]), std::string("three-eval cc1 pk[1]"))); + if (evalCode2 != 0) { + // also check in backward evalcode order: + // check dual/three eval 1of2 pubkeys vout + testVouts.push_back(std::make_pair(MakeTokensCC1of2vout(evalCode2, evalCode, tx.vout[v].nValue, voutPubkeys[0], voutPubkeys[1]), std::string("three-eval cc1of2 backward-eval"))); + // check dual/three eval 1 pubkey vout with the second pubkey + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode2, evalCode, tx.vout[v].nValue, voutPubkeys[1]), std::string("three-eval cc1 pk[1] backward-eval"))); + } } - // maybe this is claim to single-eval token? - CTxOut testTokenVout1; - testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]); - if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() this is single-eval token vout (i=0), returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; - } + // maybe this is like gatewayclaim to single-eval token? + testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]), std::string("single-eval cc1 pk[0]"))); + // maybe this is like FillSell for non-fungible token? + if( evalCode != 0 ) + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode, tx.vout[v].nValue, voutPubkeys[0]), std::string("dual-eval-token cc1 pk[0]"))); + if( evalCode2 != 0 ) + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode2, tx.vout[v].nValue, voutPubkeys[0]), std::string("dual-eval2-token cc1 pk[0]"))); if (voutPubkeys.size() == 2) { - testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[1]); - if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() this is single-eval token vout (i=1), returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; - } + // the same for pk[1]: + testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[1]), std::string("single-eval cc1 pk[1]"))); + if (evalCode != 0) + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode, tx.vout[v].nValue, voutPubkeys[1]), std::string("dual-eval-token cc1 pk[1]"))); + if (evalCode2 != 0) + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode2, tx.vout[v].nValue, voutPubkeys[1]), std::string("dual-eval2-token cc1 pk[1]"))); } } - // maybe it is single-eval or dual-eval token change? + // maybe it is single-eval or dual/three-eval token change? std::vector vinPubkeys; ExtractTokensVinPubkeys(tx, vinPubkeys); - for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { - CTxOut testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it); - CTxOut testDualVout1 = MakeTokensCC1vout(evalCodeInOpret, tx.vout[v].nValue, *it); + testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it), std::string("single-eval cc1 self vin pk"))); + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode, evalCode2, tx.vout[v].nValue, *it), std::string("three-eval cc1 self vin pk"))); - if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() this is single-eval token change, returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; - } - - if (tx.vout[v].scriptPubKey == testDualVout1.scriptPubKey) { - //std::cerr << indentStr << "IsTokensvout() this is dual-eval token change, vout eval2=" << (int)evalCodeInOpret << ", returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - return tx.vout[v].nValue; - } + if (evalCode2 != 0) + // also check in backward evalcode order: + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode2, evalCode, tx.vout[v].nValue, *it), std::string("three-eval cc1 self vin pk backward-eval"))); } + + // try all test vouts: + for (auto t : testVouts) { + if (t.first == tx.vout[v]) { + LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() valid amount=" << tx.vout[v].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); + return tx.vout[v].nValue; + } + } + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() no valid vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); } else { - //std::cerr << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); return tx.vout[v].nValue; } } @@ -487,7 +563,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c } // compares cc inputs vs cc outputs (to prevent feeding vouts from normal inputs) -bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid) +bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 reftokenid) { CTransaction vinTx; uint256 hashBlock; @@ -503,6 +579,8 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu // this is just for log messages indentation for debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); + LOGSTREAM("tokens", CCLOG_DEBUG2, stream << indentStr << "TokensExactAmounts() entered for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + for (int32_t i = 0; iismyvin)(tx.vin[i].scriptSig) /*|| IsVinAllowed(tx.vin[i].scriptSig) != 0*/) @@ -511,37 +589,38 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu // we are not inside the validation code -- dimxy if ((eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) { - std::cerr << indentStr << "TokensExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl; + LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "TokensExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl); return (!eval) ? false : eval->Invalid("always should find vin tx, but didnt"); } else { - tokenValIndentSize++; - // validate vouts of vintx - //std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl; - tokenoshis = IsTokensvout(goDeeper, true, cpTokens, eval, vinTx, tx.vin[i].prevout.n, tokenid); + LOGSTREAM("tokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() checking vintx.vout for tx.vin[" << i << "] nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl); + + // validate vouts of vintx + tokenValIndentSize++; + tokenoshis = IsTokensvout(goDeeper, true, cpTokens, eval, vinTx, tx.vin[i].prevout.n, reftokenid); tokenValIndentSize--; if (tokenoshis != 0) { - std::cerr << indentStr << "TokensExactAmounts() vin i=" << i << " tokenoshis=" << tokenoshis << std::endl; + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding vintx.vout for tx.vin[" << i << "] tokenoshis=" << tokenoshis << std::endl); inputs += tokenoshis; } } } } - - for (int32_t i = 0; iInvalid() here! } else return true; } -// add inputs from token cc addr -int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) +// get non-fungible data from 'tokenbase' tx (the data might be empty) +void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible) +{ + CTransaction tokenbasetx; + uint256 hashBlock; + + if (!myGetTransaction(tokenid, tokenbasetx, hashBlock)) { + LOGSTREAM("tokens", CCLOG_INFO, stream << "SetNonfungibleEvalCode() cound not load token creation tx=" << tokenid.GetHex() << std::endl); + return; + } + + vopretNonfungible.clear(); + // check if it is non-fungible tx and get its second evalcode from non-fungible payload + if (tokenbasetx.vout.size() > 0) { + uint8_t dummyEvalCode; + uint256 tokenIdOpret; + std::vector voutPubkeys; + std::vector vopretExtra; + DecodeTokenOpRet(tokenbasetx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeys, vopretNonfungible, vopretExtra); + } +} + + +// overload, adds inputs from token cc addr +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) { + std::vector vopretNonfungibleDummy; + return AddTokenCCInputs(cp, mtx, pk, tokenid, total, maxinputs, vopretNonfungibleDummy); +} + +// adds inputs from token cc addr and returns non-fungible opret payload if present +// also sets evalcode in cp, if needed +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs, std::vector &vopretNonfungible) { char tokenaddr[64], destaddr[64]; - int64_t threshold, nValue, price, totalinputs = 0; - uint256 txid, hashBlock; - //std::vector vopretExtra; - CTransaction vintx; - int32_t j, vout, n = 0; + int64_t threshold, nValue, price, totalinputs = 0; + int32_t n = 0; std::vector > unspentOutputs; + GetNonfungibleData(tokenid, vopretNonfungible); + if (vopretNonfungible.size() > 0) + cp->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + GetTokensCCaddress(cp, tokenaddr, pk); SetCCunspents(unspentOutputs, tokenaddr); - threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: is maxinputs really could not be over 64? what if i want to calc total balance? + if (unspentOutputs.empty()) { + LOGSTREAM("tokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); + } + + threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: maxinputs really could not be over 64? what if i want to calc total balance for all available uxtos? + // maybe it is better to add all uxtos if maxinputs == 0 for (std::vector >::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - if (it->second.satoshis < threshold) - continue; - for (j = 0; jfirst.txhash; + int32_t vout = (int32_t)it->first.index; + + if (it->second.satoshis < threshold) // this should work also for non-fungible tokens (there should be only 1 satoshi for non-fungible token issue) continue; - if (GetTransaction(txid, vintx, hashBlock, false) != 0) + int32_t ivin; + for (ivin = 0; ivin < mtx.vin.size(); ivin ++) + if (vintxid == mtx.vin[ivin].prevout.hash && vout == mtx.vin[ivin].prevout.n) + break; + if (ivin != mtx.vin.size()) // that is, the tx.vout is already added to mtx.vin (in some previous calls) + continue; + + if (GetTransaction(vintxid, vintx, hashBlock, false) != 0) { Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey); - if (strcmp(destaddr, tokenaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0) + if (strcmp(destaddr, tokenaddr) != 0 && + strcmp(destaddr, cp->unspendableCCaddr) != 0 && // TODO: check why this. Should not we add token inputs from unspendable cc addr if mypubkey is used? + strcmp(destaddr, cp->unspendableaddr2) != 0) // or the logic is to allow to spend all available tokens (what about unspendableaddr3)? continue; - //fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN); - - std::vector vinPubkeys; - if ((nValue = IsTokensvout(true, true/*<--add only checked token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0) + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() check vintx vout destaddress=" << destaddr << " amount=" << vintx.vout[vout].nValue << std::endl); + + if ((nValue = IsTokensvout(true, true/*<--add only valid token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(vintxid, vout) == 0) { - if (total != 0 && maxinputs != 0) - mtx.vin.push_back(CTxIn(txid, vout, CScript())); + //for non-fungible tokens check payload: + if (!vopretNonfungible.empty()) { + std::vector vopret; + + // check if it is non-fungible token: + GetNonfungibleData(tokenid, vopret); + if (vopret != vopretNonfungible) { + LOGSTREAM("tokens", CCLOG_INFO, stream << "AddTokenCCInputs() found incorrect non-fungible opret payload for vintxid=" << vintxid.GetHex() << std::endl); + continue; + } + + // non-fungible evalCode2 cc contract should also check if there exists only one non-fungible vout with amount = 1 + } + + + if (total != 0 && maxinputs != 0) // if it is not just to calc amount... + mtx.vin.push_back(CTxIn(vintxid, vout, CScript())); + nValue = it->second.satoshis; totalinputs += nValue; - std::cerr << "AddTokenInputs() adding input nValue=" << nValue << std::endl; + LOGSTREAM("tokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() adding input nValue=" << nValue << std::endl); n++; + if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; } } } - //std::cerr << "AddTokenInputs() found totalinputs=" << totalinputs << std::endl; + //std::cerr << "AddTokenCCInputs() found totalinputs=" << totalinputs << std::endl; return(totalinputs); } -std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description) +std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, std::string description, std::vector nonfungibleData) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; struct CCcontract_info *cp, C; - if (assetsupply < 0) + if (tokensupply < 0) { - fprintf(stderr, "negative assetsupply %lld\n", (long long)assetsupply); - return(""); + LOGSTREAM("tokens", CCLOG_INFO, stream << "CreateToken() negative tokensupply=" << tokensupply << std::endl); + return std::string(""); } + if (!nonfungibleData.empty() && tokensupply != 1) { + LOGSTREAM("tokens", CCLOG_INFO, stream << "CreateToken() for non-fungible tokens tokensupply should be equal to 1" << std::endl); + CCerror = "for non-fungible tokens tokensupply should be equal to 1"; + return std::string(""); + } + cp = CCinit(&C, EVAL_TOKENS); - if (name.size() > 32 || description.size() > 4096) + if (name.size() > 32 || description.size() > 4096) // this is also checked on rpc level { - fprintf(stderr, "name.%d or description.%d is too big\n", (int32_t)name.size(), (int32_t)description.size()); + LOGSTREAM("tokens", CCLOG_INFO, stream << "name of=" << name.size() << " or description of=" << description.size() << " is too big" << std::endl); + CCerror = "name should be < 32, description should be < 4096"; return(""); } if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, assetsupply + 2 * txfee, 64) > 0) + if (AddNormalinputs(mtx, mypk, tokensupply + 2 * txfee, 64) > 0) { - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, assetsupply, mypk)); + uint8_t destEvalCode = EVAL_TOKENS; + if( nonfungibleData.size() > 0 ) + destEvalCode = nonfungibleData.begin()[0]; + + mtx.vout.push_back(MakeTokensCC1vout(destEvalCode, tokensupply, mypk)); mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); - return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description))); + return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } - return(""); + + LOGSTREAM("tokens", CCLOG_INFO, stream << "cant find normal inputs" << std::endl); + CCerror = "cant find normal inputs"; + return std::string(""); } - -std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total) +// transfer tokens to another pubkey +// param additionalEvalCode allows transfer of dual-eval non-fungible tokens +std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector destpubkey, int64_t total) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; uint64_t mask; int64_t CCchange = 0, inputs = 0; struct CCcontract_info *cp, C; - std::vector emptyExtraOpret; + std::vector vopretNonfungible; - if (total < 0) - { - fprintf(stderr, "negative total %lld\n", (long long)total); + if (total < 0) { + LOGSTREAM("tokens", CCLOG_INFO, stream << "negative total=" << total << std::endl); return(""); } + cp = CCinit(&C, EVAL_TOKENS); + if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { - //n = outputs.size(); - //if ( n == amounts.size() ) - //{ - // for (i=0; i 0) + mask = ~((1LL << mtx.vin.size()) - 1); // seems, mask is not used anymore + + if ((inputs = AddTokenCCInputs(cp, mtx, mypk, tokenid, total, 60, vopretNonfungible)) > 0) // NOTE: AddTokenCCInputs might set cp->additionalEvalCode which is used in FinalizeCCtx! { - if (inputs < total) { //added dimxy - std::cerr << "AssetTransfer(): insufficient funds" << std::endl; - return (""); + LOGSTREAM("tokens", CCLOG_INFO, stream << "TokenTransfer(): insufficient token funds" << std::endl); + CCerror = strprintf("insufficient token inputs"); + return std::string(""); } + + uint8_t destEvalCode = EVAL_TOKENS; + if (vopretNonfungible.size() > 0) + destEvalCode = vopretNonfungible.begin()[0]; + if (inputs > total) CCchange = (inputs - total); - //for (i=0; i voutTokenPubkeys; voutTokenPubkeys.push_back(pubkey2pk(destpubkey)); // dest pubkey for validating vout - return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet('t', EVAL_TOKENS, assetid, voutTokenPubkeys, CScript()))); // By setting EVAL_TOKENS we're getting out from assets validation code + return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutTokenPubkeys, vopretNonfungible, CScript()))); } else { - fprintf(stderr, "not enough CC token inputs for %.8f\n", (double)total / COIN); + LOGSTREAM("tokens", CCLOG_INFO, stream << "not enough CC token inputs for amount=" << total << std::endl); + CCerror = strprintf("no token inputs"); } //} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size()); } else { - fprintf(stderr, "not enough normal inputs for txfee\n"); + LOGSTREAM("tokens", CCLOG_INFO, stream << "not enough normal inputs for txfee" << std::endl); + CCerror = strprintf("insufficient normal inputs"); } return(""); } @@ -708,7 +864,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) { - fprintf(stderr, "cant find tokenid\n"); + LOGSTREAM("tokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl); CCerror = strprintf("cant find tokenid"); return 0; } @@ -720,26 +876,35 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) UniValue TokenInfo(uint256 tokenid) { - UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; std::vector origpubkey; std::string name, description; char str[67], numstr[65]; + UniValue result(UniValue::VOBJ); + uint256 hashBlock; + CTransaction vintx; + std::vector origpubkey; + std::vector vopretNonfungible; + std::string name, description; + if (GetTransaction(tokenid, vintx, hashBlock, false) == 0) { - fprintf(stderr, "cant find assetid\n"); + fprintf(stderr, "TokenInfo() cant find tokenid\n"); result.push_back(Pair("result", "error")); result.push_back(Pair("error", "cant find tokenid")); return(result); } - if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) == 0) + if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description, vopretNonfungible) == 0) { - fprintf(stderr, "assetid isnt token creation txid\n"); + LOGSTREAM("tokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "assetid isnt token creation txid")); + result.push_back(Pair("error", "tokenid isnt token creation txid")); } result.push_back(Pair("result", "success")); - result.push_back(Pair("tokenid", uint256_str(str, tokenid))); - result.push_back(Pair("owner", pubkey33_str(str, origpubkey.data()))); + result.push_back(Pair("tokenid", tokenid.GetHex())); + result.push_back(Pair("owner", HexStr(origpubkey))); result.push_back(Pair("name", name)); result.push_back(Pair("supply", vintx.vout[0].nValue)); result.push_back(Pair("description", description)); + if( !vopretNonfungible.empty() ) + result.push_back(Pair("data", HexStr(vopretNonfungible))); + return(result); } diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index e7bb62101..4637ba6c9 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -28,14 +28,15 @@ // CCcustom bool TokensValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); -//int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector vinPubkeys); -std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description); +std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description, std::vector nonfungibleData); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); int64_t GetTokenBalance(CPubKey pk, uint256 tokenid); UniValue TokenInfo(uint256 tokenid); UniValue TokenList(); +void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible); + //this is in CCinclude.h int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); //this is in CCinclude.h uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index d93185ca4..6536fdee3 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -46,8 +46,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,flag,utxovout,n,err = 0; - char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], tokensunspendable[64]; - uint8_t *privkey, myprivkey[32], unspendablepriv[32], tokensunspendablepriv[32], *msg32 = 0; + char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], unspendabletokensaddr[64]; + uint8_t *privkey, myprivkey[32], unspendablepriv[32], /*tokensunspendablepriv[32],*/ *msg32 = 0; CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CPubKey unspendablepk /*, tokensunspendablepk*/; struct CCcontract_info *cpTokens, tokensC; @@ -69,26 +69,26 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran GetCCaddress(cp,myaddr,mypk); mycond = MakeCCcond1(cp->evalcode,mypk); - // to spend from single-eval evalcode 'unspendable' + // to spend from single-eval evalcode 'unspendable' cc addr unspendablepk = GetUnspendable(cp, unspendablepriv); GetCCaddress(cp, unspendable, unspendablepk); othercond = MakeCCcond1(cp->evalcode, unspendablepk); //printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); - // tokens support: - // to spend from dual-eval mypk vout + // tokens support: + // to spend from dual/three-eval mypk vout GetTokensCCaddress(cp, mytokensaddr, mypk); - mytokenscond = MakeTokensCCcond1(cp->evalcode, mypk); + // NOTE: if additionalEvalcode2 is not set it is a dual-eval (not three-eval) cc cond: + mytokenscond = MakeTokensCCcond1(cp->evalcode, cp->additionalTokensEvalcode2, mypk); // to spend from single-eval EVAL_TOKENS mypk cpTokens = CCinit(&tokensC, EVAL_TOKENS); GetCCaddress(cpTokens, mysingletokensaddr, mypk); mysingletokenscond = MakeCCcond1(EVAL_TOKENS, mypk); - // to spend from dual-eval EVAL_TOKEN+evalcode 'unspendable' pk - //tokensunspendablepk = GetUnspendable(cpTokens, tokensunspendablepriv); - GetTokensCCaddress(cp, tokensunspendable, unspendablepk); - othertokenscond = MakeTokensCCcond1(cp->evalcode, unspendablepk); + // to spend from dual/three-eval EVAL_TOKEN+evalcode 'unspendable' pk: + GetTokensCCaddress(cp, unspendabletokensaddr, unspendablepk); // it may be a three-eval cc, if cp->additionalEvalcode2 is set + othertokenscond = MakeTokensCCcond1(cp->evalcode, cp->additionalTokensEvalcode2, unspendablepk); //Reorder vins so that for multiple normal vins all other except vin0 goes to the end //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. @@ -155,9 +155,10 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); - //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " myaddr=" << myaddr << std::endl; - if( strcmp(destaddr,myaddr) == 0 ) + std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; + if( strcmp(destaddr, myaddr) == 0 ) { + fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); privkey = myprivkey; cond = mycond; } @@ -165,48 +166,48 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = myprivkey; cond = mytokenscond; - //fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout CC addr.(%s)\n",mytokensaddr); + fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); } else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout { privkey = myprivkey; cond = mysingletokenscond; - //fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout CC addr.(%s)\n", mytokensaddr); + fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); } else if ( strcmp(destaddr,unspendable) == 0 ) { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"FinalizeCCTx(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); + fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } - else if (strcmp(destaddr, tokensunspendable) == 0) + else if (strcmp(destaddr, unspendabletokensaddr) == 0) { privkey = unspendablepriv; cond = othertokenscond; - //fprintf(stderr,"FinalizeCCTx() matched tokensunspendable CC addr.(%s)\n",unspendable); + fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); } // check if this is the 2nd additional evalcode + 'unspendable' cc addr: - else if ( strcmp(destaddr,cp->unspendableaddr2) == 0) + else if ( strcmp(destaddr, cp->unspendableaddr2) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; - if ( othercond2 == 0 ) - othercond2 = MakeCCcond1(cp->evalcode2, cp->unspendablepk2); + if( othercond2 == 0 ) + othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2); cond = othercond2; } // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); privkey = cp->unspendablepriv3; - if ( othercond3 == 0 ) - othercond3 = MakeCCcond1(cp->evalcode3,cp->unspendablepk3); + if( othercond3 == 0 ) + othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3); cond = othercond3; } // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -215,10 +216,12 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc tokens addr: else if (strcmp(cp->tokens1of2addr, destaddr) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); + fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); privkey = myprivkey; if (othercond1of2tokens == 0) - othercond1of2tokens = MakeTokensCCcond1of2(cp->evalcode, cp->tokens1of2pk[0], cp->tokens1of2pk[1]); + // NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc + // TODO: verify evalcodes order if additionalEvalcode2 is not 0 + othercond1of2tokens = MakeTokensCCcond1of2(cp->evalcode, cp->additionalTokensEvalcode2, cp->tokens1of2pk[0], cp->tokens1of2pk[1]); cond = othercond1of2tokens; } else diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 6dff5d3cd..6892f6fab 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -76,7 +76,8 @@ CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk1,CPubKey pk2) return(vout); } -CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2) +// make three-eval (token+evalcode+evalcode2) 1of2 cryptocondition: +CC *MakeTokensCCcond1of2(uint8_t evalcode, uint8_t evalcode2, CPubKey pk1, CPubKey pk2) { // make 1of2 sigs cond std::vector pks; @@ -85,44 +86,68 @@ CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2) std::vector thresholds; thresholds.push_back( CCNewEval(E_MARSHAL(ss << evalcode)) ); - if( evalcode != EVAL_TOKENS ) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1of2()! - thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc - thresholds.push_back(CCNewThreshold(1, pks)); // this is 1 of 2 sigs cc + if( evalcode != EVAL_TOKENS ) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1of2()! + thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc + if( evalcode2 != 0 ) + thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode2))); // add optional additional evalcode + thresholds.push_back(CCNewThreshold(1, pks)); // this is 1 of 2 sigs cc return CCNewThreshold(thresholds.size(), thresholds); } +// overload to make two-eval (token+evalcode) 1of2 cryptocondition: +CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2) { + return MakeTokensCCcond1of2(evalcode, 0, pk1, pk2); +} -CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk) +// make three-eval (token+evalcode+evalcode2) cryptocondition: +CC *MakeTokensCCcond1(uint8_t evalcode, uint8_t evalcode2, CPubKey pk) { std::vector pks; pks.push_back(CCNewSecp256k1(pk)); std::vector thresholds; thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode))); - if (evalcode != EVAL_TOKENS) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1()! - thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc - thresholds.push_back(CCNewThreshold(1, pks)); // signature + if (evalcode != EVAL_TOKENS) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1()! + thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc + if (evalcode2 != 0) + thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode2))); // add optional additional evalcode + thresholds.push_back(CCNewThreshold(1, pks)); // signature return CCNewThreshold(thresholds.size(), thresholds); } +// overload to make two-eval (token+evalcode) cryptocondition: +CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk) { + return MakeTokensCCcond1(evalcode, 0, pk); +} -CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2) +// make three-eval (token+evalcode+evalcode2) 1of2 cc vout: +CTxOut MakeTokensCC1of2vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk1, CPubKey pk2) { CTxOut vout; - CC *payoutCond = MakeTokensCCcond1of2(evalcode, pk1, pk2); + CC *payoutCond = MakeTokensCCcond1of2(evalcode, evalcode2, pk1, pk2); vout = CTxOut(nValue, CCPubKey(payoutCond)); cc_free(payoutCond); return(vout); } +// overload to make two-eval (token+evalcode) 1of2 cc vout: +CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2) { + return MakeTokensCC1of2vout(evalcode, 0, nValue, pk1, pk2); +} -CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk) +// make three-eval (token+evalcode+evalcode2) cc vout: +CTxOut MakeTokensCC1vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk) { CTxOut vout; - CC *payoutCond = MakeTokensCCcond1(evalcode, pk); + CC *payoutCond = MakeTokensCCcond1(evalcode, evalcode2, pk); vout = CTxOut(nValue, CCPubKey(payoutCond)); cc_free(payoutCond); return(vout); } +// overload to make two-eval (token+evalcode) cc vout: +CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk) { + return MakeTokensCC1vout(evalcode, 0, nValue, pk); +} + CC* GetCryptoCondition(CScript const& scriptSig) { @@ -227,17 +252,19 @@ CPubKey pubkey2pk(std::vector pubkey) return(pk); } +// set additional 'unspendable' addr void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) { - cp->evalcode2 = evalcode; + cp->unspendableEvalcode2 = evalcode; cp->unspendablepk2 = pk; memcpy(cp->unspendablepriv2,priv,32); strcpy(cp->unspendableaddr2,coinaddr); } +// set yet another additional 'unspendable' addr void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) { - cp->evalcode3 = evalcode; + cp->unspendableEvalcode3 = evalcode; cp->unspendablepk3 = pk; memcpy(cp->unspendablepriv3,priv,32); strcpy(cp->unspendableaddr3,coinaddr); @@ -251,12 +278,13 @@ void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *c strcpy(cp->coins1of2addr, coinaddr); } -// set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 tokens cryptocondition vout: -void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr) +// set pubkeys, myprivkey and 1of2 cc addr for spending from 1of2 token cryptocondition vout +// to get tokenaddr use GetTokensCCaddress() +void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *tokenaddr) { cp->tokens1of2pk[0] = pk1; cp->tokens1of2pk[1] = pk2; - strcpy(cp->tokens1of2addr, coinaddr); + strcpy(cp->tokens1of2addr, tokenaddr); } bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) @@ -351,11 +379,11 @@ bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk) return(_GetCCaddress(destaddr,cp->evalcode,pk)); } -bool _GetTokensCCaddress(char *destaddr, uint8_t evalcode, CPubKey pk) +bool _GetTokensCCaddress(char *destaddr, uint8_t evalcode, uint8_t evalcode2, CPubKey pk) { CC *payoutCond; destaddr[0] = 0; - if ((payoutCond = MakeTokensCCcond1(evalcode, pk)) != 0) + if ((payoutCond = MakeTokensCCcond1(evalcode, evalcode2, pk)) != 0) { Getscriptaddress(destaddr, CCPubKey(payoutCond)); cc_free(payoutCond); @@ -363,12 +391,13 @@ bool _GetTokensCCaddress(char *destaddr, uint8_t evalcode, CPubKey pk) return(destaddr[0] != 0); } +// get scriptPubKey adddress for three/dual eval token cc vout bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk) { destaddr[0] = 0; if (pk.size() == 0) pk = GetUnspendable(cp, 0); - return(_GetTokensCCaddress(destaddr, cp->evalcode, pk)); + return(_GetTokensCCaddress(destaddr, cp->evalcode, cp->additionalTokensEvalcode2, pk)); } @@ -384,11 +413,12 @@ bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubK return(destaddr[0] != 0); } +// get scriptPubKey adddress for three/dual eval token 1of2 cc vout bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2) { CC *payoutCond; destaddr[0] = 0; - if ((payoutCond = MakeTokensCCcond1of2(cp->evalcode, pk, pk2)) != 0) + if ((payoutCond = MakeTokensCCcond1of2(cp->evalcode, cp->additionalTokensEvalcode2, pk, pk2)) != 0) // if additionalTokensEvalcode2 not set then it is dual-eval cc else three-eval cc { Getscriptaddress(destaddr, CCPubKey(payoutCond)); cc_free(payoutCond); @@ -515,7 +545,7 @@ CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv) void CCclearvars(struct CCcontract_info *cp) { - cp->evalcode2 = cp->evalcode3 = 0; + cp->unspendableEvalcode2 = cp->unspendableEvalcode3 = 0; cp->unspendableaddr2[0] = cp->unspendableaddr3[0] = 0; } diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 6aae09dd3..97b01302c 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -14,6 +14,7 @@ ******************************************************************************/ #include "CCassets.h" +#include "CCtokens.h" /* Assets can be created or transferred. @@ -129,21 +130,21 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransaction &tx, uint32_t nIn) { static uint256 zero; - CTxDestination address; CTransaction vinTx,createTx; uint256 hashBlock,assetid,assetid2; - int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts; - int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector origpubkey,tmporigpubkey,ignorepubkey; + CTxDestination address; + CTransaction vinTx, createTx; + uint256 hashBlock, assetid, assetid2; + int32_t i,starti, numvins, numvouts, preventCCvins, preventCCvouts; + int64_t remaining_price, nValue, assetoshis, outputsDummy,inputs,tmpprice,totalunits,ignore; + std::vector origpubkey, tmporigpubkey, ignorepubkey, vopretNonfungible, vopretNonfungibleDummy; uint8_t funcid, evalCodeInOpret; - char destaddr[64], origaddr[64], assetsCCaddr[64], userTokensCCaddr[64]; //, signleEvalTokensCCaddr[64]; + char destaddr[64], origNormalAddr[64], origTokensCCaddr[64], origCCaddrDummy[64]; + char tokensDualEvalUnspendableCCaddr[64], origAssetsCCaddr[64]; //return true; - //CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL); - //CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, NULL); - //GetCCaddress(cpTokens, tokensUnspendableCCaddr, unspendableTokensPk); - numvins = tx.vin.size(); numvouts = tx.vout.size(); - outputs = inputs = 0; + outputsDummy = inputs = 0; preventCCvins = preventCCvouts = -1; // add specific chains exceptions for old token support: @@ -156,13 +157,18 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); - if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) + if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey, vopretNonfungibleDummy)) == 0 ) return eval->Invalid("AssetValidate: invalid opreturn payload"); + // non-fungible tokens support: + GetNonfungibleData(assetid, vopretNonfungible); + if (vopretNonfungible.size() > 0) + cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + // find dual-eval tokens unspendable addr: - char tokensUnspendableAddr[64],origpubkeyCCaddr[64]; - GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - GetCCaddress(cpAssets, origpubkeyCCaddr, origpubkey); + GetTokensCCaddress(cpAssets, tokensDualEvalUnspendableCCaddr, GetUnspendable(cpAssets, NULL)); + // this is for marker validation: + GetCCaddress(cpAssets, origAssetsCCaddr, origpubkey); // we need this for validating single-eval tokens' vins/vous: struct CCcontract_info *cpTokens, tokensC; @@ -177,7 +183,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("cant find asset create txid"); else if( funcid != 'o' && funcid != 'x' && assetid2 != zero && eval->GetTxUnconfirmed(assetid2, createTx, hashBlock) == 0 ) return eval->Invalid("cant find asset2 create txid"); - else if( IsCCInput(tx.vin[0].scriptSig) != 0 ) + else if( IsCCInput(tx.vin[0].scriptSig) != 0 ) // vin0 should be normal vin return eval->Invalid("illegal asset vin0"); else if( numvouts < 2 ) return eval->Invalid("too few vouts"); // it was if(numvouts < 1) but it refers at least to vout[1] below @@ -191,7 +197,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( assetid == zero ) return eval->Invalid("illegal assetid"); - else if (!AssetCalcAmounts(cpAssets, inputs, outputs, eval, tx, assetid)) { // Only set inputs and outputs. NOTE: we do not need to check cc inputs == cc outputs + else if (!AssetCalcAmounts(cpAssets, inputs, outputsDummy/*outputsDummy is calculated incorrectly but not used*/, eval, tx, assetid)) { // Only set inputs and outputs. NOTE: we do not need to check cc inputs == cc outputs return false; // returns false if some problems with reading vintxes } } @@ -226,9 +232,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.1: CC output for marker //vout.2: normal output for change (if any) // vout.n-1: opreturn [EVAL_ASSETS] ['b'] [assetid] [amount of asset required] [origpubkey] + + // as we don't use tokenconvert we should not be here: + return eval->Invalid("invalid asset funcid (b)"); + if( remaining_price == 0 ) return eval->Invalid("illegal null amount for buyoffer"); - else if( ConstrainVout(tx.vout[0],1,cpAssets->unspendableCCaddr,0) == 0 ) + else if( ConstrainVout(tx.vout[0], 1, cpAssets->unspendableCCaddr,0) == 0 ) // coins to assets unspendable cc addr return eval->Invalid("invalid vout for buyoffer"); preventCCvins = 1; preventCCvouts = 1; @@ -243,13 +253,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.1: vin.2 back to users pubkey //vout.2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['o'] - if( (nValue= AssetValidateBuyvin(cpAssets, eval, tmpprice, tmporigpubkey, assetsCCaddr, origaddr, tx, assetid)) == 0 ) + if( (nValue= AssetValidateBuyvin(cpAssets, eval, tmpprice, tmporigpubkey, origCCaddrDummy, origNormalAddr, tx, assetid)) == 0 ) return(false); - else if( ConstrainVout(tx.vout[0],0, origaddr, nValue) == 0 ) + else if( ConstrainVout(tx.vout[0],0, origNormalAddr, nValue) == 0 ) return eval->Invalid("invalid refund for cancelbuy"); preventCCvins = 3; preventCCvouts = 0; - fprintf(stderr,"cancelbuy validated to origaddr.(%s)\n",origaddr); + fprintf(stderr,"cancelbuy validated to origaddr.(%s)\n",origNormalAddr); break; case 'B': // fillbuy: @@ -264,7 +274,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.n-1: opreturn [EVAL_ASSETS] ['B'] [assetid] [remaining asset required] [origpubkey] preventCCvouts = 4; - if( (nValue = AssetValidateBuyvin(cpAssets, eval, totalunits, tmporigpubkey, assetsCCaddr, origaddr, tx, assetid)) == 0 ) + if( (nValue = AssetValidateBuyvin(cpAssets, eval, totalunits, tmporigpubkey, origTokensCCaddr, origNormalAddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 4 ) return eval->Invalid("not enough vouts for fillbuy"); @@ -274,24 +284,24 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti { if( nValue != tx.vout[0].nValue + tx.vout[1].nValue ) return eval->Invalid("locked value doesnt match vout0+1 fillbuy"); - else if( tx.vout[4].scriptPubKey.IsPayToCryptoCondition() != 0 ) + else if( tx.vout[4].scriptPubKey.IsPayToCryptoCondition() != 0 ) // if cc change present { - if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, 0) == 0 ) // tokens on user cc addr + if( ConstrainVout(tx.vout[2], 1, origTokensCCaddr, 0) == 0 ) // tokens to originator cc addr (tokens+nonfungible evals) return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); else if ( inputs != tx.vout[2].nValue + tx.vout[4].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); } - else if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, inputs) == 0 ) // tokens on user cc addr + else if( ConstrainVout(tx.vout[2], 1, origTokensCCaddr, inputs) == 0 ) // tokens to originator cc addr (tokens+nonfungible evals) return eval->Invalid("vout2 doesnt match inputs fillbuy"); - else if( ConstrainVout(tx.vout[1],0,0,0) == 0 ) + else if( ConstrainVout(tx.vout[1], 0, NULL, 0) == 0 ) return eval->Invalid("vout1 is CC for fillbuy"); - else if( ConstrainVout(tx.vout[3], 1, origpubkeyCCaddr, 10000) == 0 ) + else if( ConstrainVout(tx.vout[3], 1, origAssetsCCaddr, 10000) == 0 ) // marker to asset cc addr return eval->Invalid("invalid marker for original pubkey"); else if( ValidateBidRemainder(remaining_price, tx.vout[0].nValue, nValue, tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillbuy"); else if( remaining_price != 0 ) { - if( ConstrainVout(tx.vout[0], 1, cpAssets->unspendableCCaddr, 0) == 0 ) // coins on asset unspendable cc addr + if( ConstrainVout(tx.vout[0], 1, cpAssets->unspendableCCaddr, 0) == 0 ) // coins to asset unspendable cc addr return eval->Invalid("mismatched vout0 AssetsCCaddr for fillbuy"); } } @@ -308,25 +318,30 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.3: normal output for change (if any) //'s'.vout.n-1: opreturn [EVAL_ASSETS] ['s'] [assetid] [amount of native coin required] [origpubkey] //'e'.vout.n-1: opreturn [EVAL_ASSETS] ['e'] [assetid] [assetid2] [amount of asset2 required] [origpubkey] + + // as we don't use tokenconvert we should not be here: + return eval->Invalid("invalid asset funcid (s)"); + preventCCvouts = 2; if( remaining_price == 0 ) return eval->Invalid("illegal null remaining_price for selloffer"); if ( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout1 for sellvin"); - if( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) // cc change + if( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) // if cc change presents { preventCCvouts++; - if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, 0) == 0 ) // check also cc vout[0] + if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, 0) == 0 ) // tokens to tokens unspendable cc addr. TODO: this in incorrect, should be assets if we got here! return eval->Invalid("mismatched vout0 TokensCCaddr for selloffer"); else if( tx.vout[0].nValue + tx.vout[2].nValue != inputs ) return eval->Invalid("mismatched vout0+vout2 total for selloffer"); } - else if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, inputs) == 0 ) // no cc change, just vout[0] + // no cc change: + else if( ConstrainVout(tx.vout[0], 1, (char *)cpTokens->unspendableCCaddr, inputs) == 0 ) // tokens to tokens unspendable cc addr TODO: this in incorrect, should be assets if got here! return eval->Invalid("mismatched vout0 TokensCCaddr for selloffer"); //fprintf(stderr,"remaining.%d for sell\n",(int32_t)remaining_price); break; - case 'x': // cancel + case 'x': // cancel sell //vin.0: normal input //vin.1: unspendable.(vout.0 from exchange or selloffer) sellTx/exchangeTx.vout[0] inputTx //vin.2: CC marker from selloffer for txfee @@ -335,9 +350,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.2: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid] - if( (assetoshis = AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) // NOTE: + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, origTokensCCaddr, origNormalAddr, tx, assetid)) == 0 ) // NOTE: return(false); - else if( ConstrainVout(tx.vout[0], 1, userTokensCCaddr, assetoshis) == 0 ) + else if( ConstrainVout(tx.vout[0], 1, origTokensCCaddr, assetoshis) == 0 ) // tokens returning to originator cc addr return eval->Invalid("invalid vout for cancel"); preventCCvins = 3; preventCCvouts = 1; @@ -353,7 +368,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] - if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, origTokensCCaddr, origNormalAddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 4 ) return eval->Invalid("not enough vouts for fillask"); @@ -365,17 +380,15 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("locked value doesnt match vout0+1 fillask"); if( ValidateAskRemainder(remaining_price, tx.vout[0].nValue, assetoshis, tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillask"); - else if( ConstrainVout(tx.vout[1], 1, 0, 0) == 0 ) + else if( ConstrainVout(tx.vout[1], 1, NULL, 0) == 0 ) // do not check token buyer's cc addr return eval->Invalid("normal vout1 for fillask"); - else if( ConstrainVout(tx.vout[2], 0, origaddr, 0) == 0 ) + else if( ConstrainVout(tx.vout[2], 0, origNormalAddr, 0) == 0 ) // coins to originator normal addr return eval->Invalid("normal vout1 for fillask"); - else if( ConstrainVout(tx.vout[3], 1, origpubkeyCCaddr, 10000) == 0 ) + else if( ConstrainVout(tx.vout[3], 1, origAssetsCCaddr, 10000) == 0 ) // marker to originator asset cc addr return eval->Invalid("invalid marker for original pubkey"); else if( remaining_price != 0 ) { - //char tokensUnspendableAddr[64]; - //GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - if ( ConstrainVout(tx.vout[0], 1, tokensUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/, 0) == 0 ) + if ( ConstrainVout(tx.vout[0], 1, tokensDualEvalUnspendableCCaddr, 0) == 0 ) return eval->Invalid("mismatched vout0 assets dual unspendable CCaddr for fill sell"); } } @@ -399,7 +412,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti // eval->Invalid("asset2 inputs != outputs"); ////////// not implemented yet //////////// - if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) + if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, origTokensCCaddr, origNormalAddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) return eval->Invalid("not enough vouts for fillex"); @@ -412,7 +425,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) ////////// not implemented yet //////////// { - if( ConstrainVout(tx.vout[2], 1, userTokensCCaddr, 0) == 0 ) + if( ConstrainVout(tx.vout[2], 1, origTokensCCaddr, 0) == 0 ) return eval->Invalid("vout2 doesnt go to origpubkey fillex"); else if( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) { @@ -421,7 +434,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti } } ////////// not implemented yet //////////// - else if( ConstrainVout(tx.vout[2], 1, userTokensCCaddr, inputs) == 0 ) + else if( ConstrainVout(tx.vout[2], 1, origTokensCCaddr, inputs) == 0 ) return eval->Invalid("vout2 doesnt match inputs fillex"); else if( ConstrainVout(tx.vout[1], 0, 0, 0) == 0 ) return eval->Invalid("vout1 is CC for fillex"); diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 66c0e1b9a..a1d349c12 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -171,7 +171,7 @@ CPubKey OracleBatonPk(char *batonaddr,struct CCcontract_info *cp) if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); Myprivkey(priv); - cp->evalcode2 = EVAL_ORACLES; + cp->unspendableEvalcode2 = EVAL_ORACLES; for (i=0; i<32; i++) cp->unspendablepriv2[i] = (priv[i] ^ cp->CCpriv[i]); while ( secp256k1_ec_seckey_verify(ctx,cp->unspendablepriv2) == 0 ) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 369495b1a..03a4d2b9c 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -13,6 +13,7 @@ * * ******************************************************************************/ +#include "CCassets.h" #include "CCPrices.h" /* @@ -89,6 +90,9 @@ uint8_t DecodePricesFundingOpRet(CScript scriptPubKey,CPubKey &planpk,uint256 &o bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; + + return true; // TODO remove, for test dual-evals + return eval->Invalid("no validation yet"); std::vector > txids; numvins = tx.vin.size(); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f8fe7de20..abd0b9696 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7038,75 +7038,98 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) UniValue tokencreate(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); std::string name,description,hex; uint64_t supply; - if ( fHelp || params.size() > 3 || params.size() < 2 ) - throw runtime_error("tokencreate name supply description\n"); + UniValue result(UniValue::VOBJ); + std::string name, description, hextx; + std::vector nonfungibleData; + int64_t supply; // changed from uin64_t to int64_t for this 'if ( supply <= 0 )' to work as expected + + CCerror.clear(); + + if ( fHelp || params.size() > 4 || params.size() < 2 ) + throw runtime_error("tokencreate name supply [description][data]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); + name = params[0].get_str(); - supply = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; // what for is this '+0.00000000499999'? it will be lost while converting double to int64_t (dimxy) - if ( name.size() == 0 || name.size() > 32) - { + if (name.size() == 0 || name.size() > 32) { ERR_RESULT("Token name must not be empty and up to 32 characters"); return(result); } - if ( supply <= 0 ) - { + + supply = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; // what for is this '+0.00000000499999'? it will be lost while converting double to int64_t (dimxy) + if (supply <= 0) { ERR_RESULT("Token supply must be positive"); return(result); } - if ( params.size() == 3 ) - { + + if (params.size() >= 3) { description = params[2].get_str(); - if ( description.size() > 4096 ) - { + if (description.size() > 4096) { ERR_RESULT("Token description must be <= 4096 characters"); return(result); } } - hex = CreateToken(0,supply,name,description); - if ( hex.size() > 0 ) - { + + if (params.size() == 4) { + nonfungibleData = ParseHex(params[3].get_str()); + if (nonfungibleData.size() > 10000) // opret limit + { + ERR_RESULT("Non-fungible data must be <= 10000"); + return(result); + } + } + + hextx = CreateToken(0, supply, name, description, nonfungibleData); + if( hextx.size() > 0 ) { result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } else ERR_RESULT("couldnt create transaction"); + result.push_back(Pair("hex", hextx)); + } + else + ERR_RESULT(CCerror); return(result); } UniValue tokentransfer(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); std::string hex; int64_t amount; uint256 tokenid; - if ( fHelp || params.size() != 3 ) + UniValue result(UniValue::VOBJ); + std::string hex; + int64_t amount; + uint256 tokenid; + + CCerror.clear(); + + if ( fHelp || params.size() != 3) throw runtime_error("tokentransfer tokenid destpubkey amount\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); + tokenid = Parseuint256((char *)params[0].get_str().c_str()); std::vector pubkey(ParseHex(params[1].get_str().c_str())); //amount = atol(params[2].get_str().c_str()); amount = atoll(params[2].get_str().c_str()); // dimxy changed to prevent loss of significance - if ( tokenid == zeroid ) - { + if( tokenid == zeroid ) { ERR_RESULT("invalid tokenid"); return(result); } - if ( amount <= 0 ) - { + if( amount <= 0 ) { ERR_RESULT("amount must be positive"); return(result); } - hex = TokenTransfer(0,tokenid,pubkey,amount); - if (amount > 0) { - if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } else ERR_RESULT("couldnt transfer assets"); - } else { - ERR_RESULT("amount must be positive"); + + hex = TokenTransfer(0, tokenid, pubkey, amount); + + if( !CCerror.empty() ) { + ERR_RESULT(CCerror); + } + else { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); } return(result); } @@ -7786,3 +7809,4 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_HEIR); return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); } + From 9919b39bce506841dc71b6068949d91733e25bc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 01:15:06 -1100 Subject: [PATCH 1907/3904] Remove gametxid.vout[1] usage --- src/cc/rogue/new_level.c | 2 +- src/cc/rogue_rpc.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index 9b2348b3f..9dc0d761f 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -167,7 +167,7 @@ put_things(struct rogue_state *rs) obj->o_hplus = 0; obj->o_dplus = 0; strncpy(obj->o_damage,"0x0",sizeof(obj->o_damage)); - strncpy(obj->o_hurldmg,"0x0",sizeof(obj->o_hurldmg)); + strncpy(obj->o_hurldmg,"0x0",sizeof(obj->o_hurldmg)); obj->o_arm = 11; obj->o_type = AMULET; /* diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5489b75f6..59f3beee6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -128,12 +128,12 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%2284d3c1b598c9e2b3891a6b33468ec526cfaa9c7024c578025cdaff24b5ea3d20%22]\" -// cclib register 17 \"[%2284d3c1b598c9e2b3891a6b33468ec526cfaa9c7024c578025cdaff24b5ea3d20%22]\" +// cclib gameinfo 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22]\" +// cclib register 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd%22]\" +// cclib register 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22,%2233d52f92980ceaa81556093171ee224e085fd384690d83460d6fbbad96fe0e7e%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%2284d3c1b598c9e2b3891a6b33468ec526cfaa9c7024c578025cdaff24b5ea3d20%22]\" +// cclib bailout 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22]\" // eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd /* 2409 gold.209 hp.17 strength.16 level.3 exp.22 3 @@ -446,10 +446,9 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint256 origplayergame) { int64_t txfee = 10000; - if ( CCgettxout(playertxid,0,1) == txfee && CCgettxout(origplayergame,1,1) == txfee ) // not sure if this is enough validation + if ( CCgettxout(playertxid,0,1) == 1 ) // not sure if this is enough validation { mtx.vin.push_back(CTxIn(playertxid,0,CScript())); - mtx.vin.push_back(CTxIn(origplayergame,1,CScript())); return(0); } else return(-1); } From a98a2413e88d462c065c15f395683e0b28a8e07a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 01:24:51 -1100 Subject: [PATCH 1908/3904] Ismine and datastr --- src/cc/rogue_rpc.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 59f3beee6..47b166ce2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -362,12 +362,17 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid) { - int32_t i; struct rogue_player P; char packitemstr[512]; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); + int32_t i; struct rogue_player P; char packitemstr[512],*datastr; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { + datastr = (char *)malloc(playerdata.size()*2+1); for (i=0; i playerdata,uint256 playertxid) a.push_back(packitemstr); } obj.push_back(Pair("playertxid",playertxid.GetHex())); + obj.push_back(Pair("data",datastr)); + free(datastr); obj.push_back(Pair("pack",a)); obj.push_back(Pair("packsize",(int64_t)P.packsize)); obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); @@ -541,7 +548,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-1); } -void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers) +void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *myrogueaddr) { // identify if bailout or quit or timed out uint256 batontxid,spenttxid,gtxid,ptxid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; @@ -565,6 +572,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet } else obj.push_back(Pair("status","finished")); obj.push_back(Pair("baton",batontxid.ToString())); obj.push_back(Pair("batonaddr",destaddr)); + obj.push_back(Pair("ismine",strcmp(myrogueaddr,destaddr)==0)); obj.push_back(Pair("batonvout",(int64_t)batonvout)); obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); obj.push_back(Pair("batonht",(int64_t)batonht)); @@ -885,7 +893,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( CCgettxout(txid,i+1,1) < 0 ) { UniValue obj(UniValue::VOBJ); - rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers); + rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr); a.push_back(obj); } } From a42b9198df6654ffa4381b2b52d9c5e64bd587b6 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 10 Feb 2019 17:48:24 +0500 Subject: [PATCH 1909/3904] logging param changed to "cctokens" "ccassets" --- src/cc/CCassetsCore.cpp | 11 +++-- src/cc/CCtokens.cpp | 92 ++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index f14de3956..1aa654a89 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -295,7 +295,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo // First - decode token opret: funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, vopret1, vopret2); - std::cerr << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl; + LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl); if (!vopret2.empty()) { // if there are both oprets then order is like this: @@ -319,7 +319,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo //bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); if (funcId == 0 || vopretAssets.size() < 2) { - std::cerr << "DecodeAssetTokenOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << std::endl; + LOGSTREAM("ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << std::endl); return (uint8_t)0; } @@ -334,7 +334,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo assetsEvalCode = vopretAssets.begin()[0]; assetsFuncId = vopretAssets.begin()[1]; - //std::cerr << "DecodeAssetTokenOpRet() evalCodeInOpret=" << (int)evalCodeInOpret << " funcId=" << (char)(funcId ? funcId : ' ') << " assetFuncId=" << (char)(assetFuncId ? assetFuncId : ' ') << std::endl; + LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() assetsEvalCode=" << (int)assetsEvalCode << " funcId=" << (char)(funcId ? funcId : ' ') << " assetsFuncId=" << (char)(assetsFuncId ? assetsFuncId : ' ') << std::endl); if (assetsEvalCode == EVAL_ASSETS) { @@ -363,14 +363,13 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo } break; default: - fprintf(stderr, "DecodeAssetTokenOpRet() illegal assetFuncId.%02x\n", assetsFuncId); - //funcId = 0; + LOGSTREAM("ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() illegal assetFuncId=" << (int)funcId << std::endl); break; } } } - std::cerr << "DecodeAssetTokenOpRet() no asset's payload or incorrect assets evalcode" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << " assetsEvalCode=" << assetsEvalCode << " assetsFuncId=" << assetsFuncId << std::endl; + LOGSTREAM("ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() no asset's payload or incorrect assets evalcode" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << " assetsEvalCode=" << assetsEvalCode << " assetsFuncId=" << assetsFuncId << std::endl); return (uint8_t)0; } diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 23a4fda50..6cbe9496f 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -73,7 +73,7 @@ CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std: if (voutPubkeys.size() >= 0 && voutPubkeys.size() <= 2) ccType = voutPubkeys.size(); else { - LOGSTREAM("tokens", CCLOG_INFO, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); } std::vector vpayload; @@ -173,7 +173,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui return (uint8_t)0; funcId = script[1]; - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); switch( funcId ) { @@ -195,7 +195,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui { if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType - LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); return (uint8_t)0; } @@ -209,16 +209,16 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui tokenid = revuint256(tokenid); return(funcId); } - LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); return (uint8_t)0; default: - LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl); return (uint8_t)0; } } else { - LOGSTREAM("tokens", CCLOG_INFO, stream << "DecodeTokenOpRet() empty opret, could not parse" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() empty opret, could not parse" << std::endl); } return (uint8_t)0; } @@ -245,7 +245,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopret1, vopret2)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); - LOGSTREAM("tokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); @@ -293,11 +293,11 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (inputs == 0) return eval->Invalid("no token inputs for transfer"); - LOGSTREAM("tokens", CCLOG_INFO, stream << "token transfer preliminarily validated inputs=" << inputs << "->outputs=" << outputs << " preventCCvins=" << preventCCvins<< " preventCCvouts=" << preventCCvouts << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "token transfer preliminarily validated inputs=" << inputs << "->outputs=" << outputs << " preventCCvins=" << preventCCvins<< " preventCCvouts=" << preventCCvouts << std::endl); break; // breaking to other contract validation... default: - LOGSTREAM("tokens", CCLOG_INFO, stream << "illegal tokens funcid=" << (char)(funcid?funcid:' ') << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "illegal tokens funcid=" << (char)(funcid?funcid:' ') << std::endl); return eval->Invalid("unexpected token funcid"); } @@ -383,32 +383,32 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { if ((funcid = DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenidOpret, voutPubkeysDummy, vopretExtraDummy)) == 0) { - LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl); return (uint8_t)0; } else if (funcid == 'c') { if (tokenid != zeroid && tokenid == tx.GetHash()) { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); return funcid; } else { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenbase txid=" << tx.GetHash().GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenbase txid=" << tx.GetHash().GetHex() << std::endl); } } else if (funcid == 't') { //std::cerr << indentStr << "ValidateTokenOpret() tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; if (tokenid != zeroid && tokenid == tokenidOpret) { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); return funcid; } else { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenid=" << tokenidOpret.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenid=" << tokenidOpret.GetHex() << std::endl); } } else { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not supported funcid=" << (char)funcid << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not supported funcid=" << (char)funcid << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl); } return (uint8_t)0; } @@ -424,12 +424,12 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - LOGSTREAM("tokens", CCLOG_DEBUG2, stream << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl); int32_t n = tx.vout.size(); // just check boundaries: if (n == 0 || v < 0 || v >= n-1) { - LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "isTokensvout() incorrect params: (n == 0 or v < 0 or v >= n-1)" << " v=" << v << " n=" << n << " returning 0" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "isTokensvout() incorrect params: (n == 0 or v < 0 or v >= n-1)" << " v=" << v << " n=" << n << " returning 0" << std::endl); return(0); } @@ -449,7 +449,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // if ccInputs != ccOutputs and it is not the tokenbase tx // this means it is possibly a fake tx (dimxy): if (reftokenid != tx.GetHash()) { // checking that this is the true tokenbase tx, by verifying that funcid=c, is done further in this function (dimxy) - LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() warning: for the verified tx detected a bad vintx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping the verified tx" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() warning: for the verified tx detected a bad vintx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping the verified tx" << std::endl); return 0; } } @@ -459,7 +459,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c const uint8_t funcId = ValidateTokenOpret(tx, reftokenid); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null funcId=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null funcId=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); uint8_t dummyEvalCode; uint256 tokenIdOpret; @@ -471,8 +471,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c if (checkPubkeys && funcId != 'c') { // for 'c' there is no pubkeys // verify that the vout is token by constructing vouts with the pubkeys in the opret: - LOGSTREAM("tokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret1=" << HexStr(vopret1) << std::endl); - LOGSTREAM("tokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret2=" << HexStr(vopret2) << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret1=" << HexStr(vopret1) << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret2=" << HexStr(vopret2) << std::endl); uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim uint8_t evalCode2 = 0; // will be checked if zero or not @@ -544,14 +544,14 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // try all test vouts: for (auto t : testVouts) { if (t.first == tx.vout[v]) { - LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() valid amount=" << tx.vout[v].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() valid amount=" << tx.vout[v].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); return tx.vout[v].nValue; } } - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() no valid vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() no valid vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); } else { - LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); return tx.vout[v].nValue; } } @@ -579,7 +579,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu // this is just for log messages indentation for debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - LOGSTREAM("tokens", CCLOG_DEBUG2, stream << indentStr << "TokensExactAmounts() entered for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "TokensExactAmounts() entered for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); for (int32_t i = 0; iGetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) { - LOGSTREAM("tokens", CCLOG_INFO, stream << indentStr << "TokensExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "TokensExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl); return (!eval) ? false : eval->Invalid("always should find vin tx, but didnt"); } else { - LOGSTREAM("tokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() checking vintx.vout for tx.vin[" << i << "] nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() checking vintx.vout for tx.vin[" << i << "] nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl); // validate vouts of vintx tokenValIndentSize++; @@ -601,7 +601,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu tokenValIndentSize--; if (tokenoshis != 0) { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding vintx.vout for tx.vin[" << i << "] tokenoshis=" << tokenoshis << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding vintx.vout for tx.vin[" << i << "] tokenoshis=" << tokenoshis << std::endl); inputs += tokenoshis; } } @@ -610,7 +610,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu for (int32_t i = 0; i < numvouts-1; i ++) // 'numvouts-1' <-- do not check opret { - LOGSTREAM("tokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() recursively checking tx.vout[" << i << "] nValue=" << tx.vout[i].nValue << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() recursively checking tx.vout[" << i << "] nValue=" << tx.vout[i].nValue << std::endl); // Note: we pass in here IsTokenvout(false,...) because we don't need to call TokenExactAmounts() recursively from IsTokensvout here // indeed, if we pass 'true' we'll be checking this tx vout again @@ -620,7 +620,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu if (tokenoshis != 0) { - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding tx.vout[" << i << "] tokenoshis=" << tokenoshis << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding tx.vout[" << i << "] tokenoshis=" << tokenoshis << std::endl); outputs += tokenoshis; } } @@ -629,7 +629,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu if (inputs != outputs) { if (tx.GetHash() != reftokenid) - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl); return false; // do not call eval->Invalid() here! } else @@ -643,7 +643,7 @@ void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible uint256 hashBlock; if (!myGetTransaction(tokenid, tokenbasetx, hashBlock)) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "SetNonfungibleEvalCode() cound not load token creation tx=" << tokenid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "SetNonfungibleEvalCode() cound not load token creation tx=" << tokenid.GetHex() << std::endl); return; } @@ -682,7 +682,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C SetCCunspents(unspentOutputs, tokenaddr); if (unspentOutputs.empty()) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); } threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: maxinputs really could not be over 64? what if i want to calc total balance for all available uxtos? @@ -713,7 +713,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C strcmp(destaddr, cp->unspendableaddr2) != 0) // or the logic is to allow to spend all available tokens (what about unspendableaddr3)? continue; - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() check vintx vout destaddress=" << destaddr << " amount=" << vintx.vout[vout].nValue << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() check vintx vout destaddress=" << destaddr << " amount=" << vintx.vout[vout].nValue << std::endl); if ((nValue = IsTokensvout(true, true/*<--add only valid token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(vintxid, vout) == 0) { @@ -724,7 +724,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C // check if it is non-fungible token: GetNonfungibleData(tokenid, vopret); if (vopret != vopretNonfungible) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "AddTokenCCInputs() found incorrect non-fungible opret payload for vintxid=" << vintxid.GetHex() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() found incorrect non-fungible opret payload for vintxid=" << vintxid.GetHex() << std::endl); continue; } @@ -737,7 +737,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C nValue = it->second.satoshis; totalinputs += nValue; - LOGSTREAM("tokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() adding input nValue=" << nValue << std::endl); + LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() adding input nValue=" << nValue << std::endl); n++; if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) @@ -757,11 +757,11 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st CPubKey mypk; struct CCcontract_info *cp, C; if (tokensupply < 0) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "CreateToken() negative tokensupply=" << tokensupply << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "CreateToken() negative tokensupply=" << tokensupply << std::endl); return std::string(""); } if (!nonfungibleData.empty() && tokensupply != 1) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "CreateToken() for non-fungible tokens tokensupply should be equal to 1" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "CreateToken() for non-fungible tokens tokensupply should be equal to 1" << std::endl); CCerror = "for non-fungible tokens tokensupply should be equal to 1"; return std::string(""); } @@ -770,7 +770,7 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st cp = CCinit(&C, EVAL_TOKENS); if (name.size() > 32 || description.size() > 4096) // this is also checked on rpc level { - LOGSTREAM("tokens", CCLOG_INFO, stream << "name of=" << name.size() << " or description of=" << description.size() << " is too big" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "name of=" << name.size() << " or description of=" << description.size() << " is too big" << std::endl); CCerror = "name should be < 32, description should be < 4096"; return(""); } @@ -789,7 +789,7 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } - LOGSTREAM("tokens", CCLOG_INFO, stream << "cant find normal inputs" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "cant find normal inputs" << std::endl); CCerror = "cant find normal inputs"; return std::string(""); } @@ -803,7 +803,7 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d std::vector vopretNonfungible; if (total < 0) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "negative total=" << total << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "negative total=" << total << std::endl); return(""); } @@ -819,7 +819,7 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d if ((inputs = AddTokenCCInputs(cp, mtx, mypk, tokenid, total, 60, vopretNonfungible)) > 0) // NOTE: AddTokenCCInputs might set cp->additionalEvalCode which is used in FinalizeCCtx! { if (inputs < total) { //added dimxy - LOGSTREAM("tokens", CCLOG_INFO, stream << "TokenTransfer(): insufficient token funds" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "TokenTransfer(): insufficient token funds" << std::endl); CCerror = strprintf("insufficient token inputs"); return std::string(""); } @@ -840,13 +840,13 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutTokenPubkeys, vopretNonfungible, CScript()))); } else { - LOGSTREAM("tokens", CCLOG_INFO, stream << "not enough CC token inputs for amount=" << total << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "not enough CC token inputs for amount=" << total << std::endl); CCerror = strprintf("no token inputs"); } //} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size()); } else { - LOGSTREAM("tokens", CCLOG_INFO, stream << "not enough normal inputs for txfee" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "not enough normal inputs for txfee" << std::endl); CCerror = strprintf("insufficient normal inputs"); } return(""); @@ -864,7 +864,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl); CCerror = strprintf("cant find tokenid"); return 0; } @@ -892,7 +892,7 @@ UniValue TokenInfo(uint256 tokenid) } if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description, vopretNonfungible) == 0) { - LOGSTREAM("tokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); result.push_back(Pair("result", "error")); result.push_back(Pair("error", "tokenid isnt token creation txid")); } From fdd1d04b1065e7f76634819206b919f6d9a93ab2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:17:59 -1100 Subject: [PATCH 1910/3904] dapp loading player data --- src/cc/rogue/rogue.c | 38 ++++++++++++++++++++++++++++++++++++++ src/cc/rogue/state.c | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index c52002447..91d638e12 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -142,6 +142,43 @@ int32_t flushkeystrokes(struct rogue_state *rs) } #else +uint8_t *OS_fileptr(long *allocsizep,char *fname); + +void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) +{ + char cmd[32768]; int32_t i,n; char *filestr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + sprintf(fname,"%s.gameinfo",gametxidstr); + sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + else + { + filestr = (char *)OS_fileptr(&allocsize,fname); + if ( (retjson= cJSON_Parse(filestr)) != 0 ) + { + if ( (array= jarray(&n,retjson,"players")) != 0 ) + { + for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); + fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); + rs->restoring = 1; + } + } + } + } + free_json(retjson); + } + free(filestr); + } +} + void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to lookup gametxid { char cmd[32768],hexstr[32768]; int32_t i; @@ -260,6 +297,7 @@ int rogue(int argc, char **argv, char **envp) { rs->seed = atol(argv[1]); strcpy(Gametxidstr,argv[2]); + rogue_setplayerdata(rs,Gametxidstr); } else rs->seed = 777; rs->guiflag = 1; rs->sleeptime = 1; // non-zero to allow refresh() diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index def3fb859..68686b255 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1390,7 +1390,7 @@ void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) THING *obj = new_item(); rogue_restoreobject(obj,item); strcpy(packitemstr,inv_name(obj,FALSE)); - fprintf(stderr,"packitem.(%s)\n",packitemstr); + //fprintf(stderr,"packitem.(%s)\n",packitemstr); free(obj); } From 366ade08a03369e6fc10262d5d41359ba2d5aca8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:28:14 -1100 Subject: [PATCH 1911/3904] Merge nonfungible --- src/cc/CCinclude.h | 5 ----- src/cc/CCtokens.cpp | 6 +----- src/cc/CCtx.cpp | 15 ++------------- src/wallet/rpcwallet.cpp | 11 ++--------- 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 87813c8fd..89e6343b9 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -199,12 +199,7 @@ CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2); CC* GetCryptoCondition(CScript const& scriptSig); void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); -<<<<<<< HEAD void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2,uint8_t *priv,char *coinaddr); - -======= -void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, char *coinaddr); ->>>>>>> FSM CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); CTxOut MakeTokensCC1of2vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk1, CPubKey pk2); CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 98c92e674..499d9e7b0 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -713,13 +713,9 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C strcmp(destaddr, cp->unspendableaddr2) != 0) // or the logic is to allow to spend all available tokens (what about unspendableaddr3)? continue; -<<<<<<< HEAD - if ((nValue = IsTokensvout(true, true/*<--add only checked token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid, vout) == 0) -======= LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() check vintx vout destaddress=" << destaddr << " amount=" << vintx.vout[vout].nValue << std::endl); - if ((nValue = IsTokensvout(true, true/*<--add only valid token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(vintxid, vout) == 0) ->>>>>>> FSM + if ((nValue = IsTokensvout(true, true/*<--add only valid token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,vintxid, vout) == 0) { //for non-fungible tokens check payload: if (!vopretNonfungible.empty()) { diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index d2a040412..af5535591 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -46,15 +46,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int32_t i,flag,utxovout,n,err = 0; -<<<<<<< HEAD - char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], tokensunspendable[64],CC1of2CCaddr[64]; - uint8_t *privkey, myprivkey[32], unspendablepriv[32], tokensunspendablepriv[32], *msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; -======= - char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], unspendabletokensaddr[64]; + char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], unspendabletokensaddr[64],CC1of2CCaddr[64]; uint8_t *privkey, myprivkey[32], unspendablepriv[32], /*tokensunspendablepriv[32],*/ *msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; ->>>>>>> FSM + CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CPubKey unspendablepk /*, tokensunspendablepk*/; struct CCcontract_info *cpTokens, tokensC; globalpk = GetUnspendable(cp,0); @@ -215,13 +209,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { -<<<<<<< HEAD //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = cp->coins1of2priv;//myprivkey; -======= - fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); - privkey = myprivkey; ->>>>>>> FSM if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); cond = othercond1of2; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8cc051a44..0087abf58 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7046,13 +7046,7 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) UniValue tokencreate(const UniValue& params, bool fHelp) { -<<<<<<< HEAD - UniValue result(UniValue::VOBJ); std::string name,description,hex; uint64_t supply; - if ( fHelp || params.size() > 3 || params.size() < 2 ) - throw runtime_error("tokencreate name supply description\n"); - if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) -======= - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VOBJ); std::string name, description, hextx; std::vector nonfungibleData; int64_t supply; // changed from uin64_t to int64_t for this 'if ( supply <= 0 )' to work as expected @@ -7061,8 +7055,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 4 || params.size() < 2 ) throw runtime_error("tokencreate name supply [description][data]\n"); - if ( ensure_CCrequirements() < 0 ) ->>>>>>> FSM + if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; From 26adb60f2a2edea4adccc10fff9edc9c6e22cd66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:29:25 -1100 Subject: [PATCH 1912/3904] Missing funds --- src/cc/rogue/rogue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 91d638e12..4f66c770f 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -154,7 +154,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) else { filestr = (char *)OS_fileptr(&allocsize,fname); - if ( (retjson= cJSON_Parse(filestr)) != 0 ) + /*if ( (retjson= cJSON_Parse(filestr)) != 0 ) { if ( (array= jarray(&n,retjson,"players")) != 0 ) { @@ -174,7 +174,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } } free_json(retjson); - } + }*/ free(filestr); } } From 1ae1b3953c0a4d78de4ad81a0564e6a1c2d47800 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:30:03 -1100 Subject: [PATCH 1913/3904] -cJSON --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 4f66c770f..970844da0 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -146,7 +146,7 @@ uint8_t *OS_fileptr(long *allocsizep,char *fname); void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { - char cmd[32768]; int32_t i,n; char *filestr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + char cmd[32768]; int32_t i,n; char *filestr,*datastr,fname[128]; long allocsize; //cJSON *retjson,*array,*item; sprintf(fname,"%s.gameinfo",gametxidstr); sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); if ( system(cmd) != 0 ) From ffc96c9674c3d29b1ed7e9f7763f1c14cf4c5f73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:36:32 -1100 Subject: [PATCH 1914/3904] (char *) --- src/cc/CCassetsCore.cpp | 10 ++--- src/cc/CCtokens.cpp | 92 ++++++++++++++++++++--------------------- src/cc/rogue/main.c | 47 +++++++++++++++++++++ 3 files changed, 98 insertions(+), 51 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 1aa654a89..fa8b1df71 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -295,7 +295,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo // First - decode token opret: funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, vopret1, vopret2); - LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl); + LOGSTREAM((char *)"ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl); if (!vopret2.empty()) { // if there are both oprets then order is like this: @@ -319,7 +319,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo //bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); if (funcId == 0 || vopretAssets.size() < 2) { - LOGSTREAM("ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << std::endl); + LOGSTREAM((char *)"ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << std::endl); return (uint8_t)0; } @@ -334,7 +334,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo assetsEvalCode = vopretAssets.begin()[0]; assetsFuncId = vopretAssets.begin()[1]; - LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() assetsEvalCode=" << (int)assetsEvalCode << " funcId=" << (char)(funcId ? funcId : ' ') << " assetsFuncId=" << (char)(assetsFuncId ? assetsFuncId : ' ') << std::endl); + LOGSTREAM((char *)"ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() assetsEvalCode=" << (int)assetsEvalCode << " funcId=" << (char)(funcId ? funcId : ' ') << " assetsFuncId=" << (char)(assetsFuncId ? assetsFuncId : ' ') << std::endl); if (assetsEvalCode == EVAL_ASSETS) { @@ -363,13 +363,13 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo } break; default: - LOGSTREAM("ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() illegal assetFuncId=" << (int)funcId << std::endl); + LOGSTREAM((char *)"ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() illegal assetFuncId=" << (int)funcId << std::endl); break; } } } - LOGSTREAM("ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() no asset's payload or incorrect assets evalcode" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << " assetsEvalCode=" << assetsEvalCode << " assetsFuncId=" << assetsFuncId << std::endl); + LOGSTREAM((char *)"ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() no asset's payload or incorrect assets evalcode" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << " assetsEvalCode=" << assetsEvalCode << " assetsFuncId=" << assetsFuncId << std::endl); return (uint8_t)0; } diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 499d9e7b0..df1733173 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -73,7 +73,7 @@ CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std: if (voutPubkeys.size() >= 0 && voutPubkeys.size() <= 2) ccType = voutPubkeys.size(); else { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); } std::vector vpayload; @@ -173,7 +173,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui return (uint8_t)0; funcId = script[1]; - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); switch( funcId ) { @@ -195,7 +195,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui { if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType - LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); return (uint8_t)0; } @@ -209,16 +209,16 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui tokenid = revuint256(tokenid); return(funcId); } - LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); return (uint8_t)0; default: - LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl); return (uint8_t)0; } } else { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() empty opret, could not parse" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() empty opret, could not parse" << std::endl); } return (uint8_t)0; } @@ -245,7 +245,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopret1, vopret2)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); - LOGSTREAM("cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); @@ -293,11 +293,11 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (inputs == 0) return eval->Invalid("no token inputs for transfer"); - LOGSTREAM("cctokens", CCLOG_INFO, stream << "token transfer preliminarily validated inputs=" << inputs << "->outputs=" << outputs << " preventCCvins=" << preventCCvins<< " preventCCvouts=" << preventCCvouts << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "token transfer preliminarily validated inputs=" << inputs << "->outputs=" << outputs << " preventCCvins=" << preventCCvins<< " preventCCvouts=" << preventCCvouts << std::endl); break; // breaking to other contract validation... default: - LOGSTREAM("cctokens", CCLOG_INFO, stream << "illegal tokens funcid=" << (char)(funcid?funcid:' ') << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "illegal tokens funcid=" << (char)(funcid?funcid:' ') << std::endl); return eval->Invalid("unexpected token funcid"); } @@ -383,32 +383,32 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { if ((funcid = DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenidOpret, voutPubkeysDummy, vopretExtraDummy)) == 0) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl); return (uint8_t)0; } else if (funcid == 'c') { if (tokenid != zeroid && tokenid == tx.GetHash()) { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); return funcid; } else { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenbase txid=" << tx.GetHash().GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenbase txid=" << tx.GetHash().GetHex() << std::endl); } } else if (funcid == 't') { //std::cerr << indentStr << "ValidateTokenOpret() tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; if (tokenid != zeroid && tokenid == tokenidOpret) { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is a transfer 't' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); return funcid; } else { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenid=" << tokenidOpret.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenid=" << tokenidOpret.GetHex() << std::endl); } } else { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not supported funcid=" << (char)funcid << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not supported funcid=" << (char)funcid << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl); } return (uint8_t)0; } @@ -424,12 +424,12 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl); int32_t n = tx.vout.size(); // just check boundaries: if (n == 0 || v < 0 || v >= n-1) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "isTokensvout() incorrect params: (n == 0 or v < 0 or v >= n-1)" << " v=" << v << " n=" << n << " returning 0" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "isTokensvout() incorrect params: (n == 0 or v < 0 or v >= n-1)" << " v=" << v << " n=" << n << " returning 0" << std::endl); return(0); } @@ -449,7 +449,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // if ccInputs != ccOutputs and it is not the tokenbase tx // this means it is possibly a fake tx (dimxy): if (reftokenid != tx.GetHash()) { // checking that this is the true tokenbase tx, by verifying that funcid=c, is done further in this function (dimxy) - LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() warning: for the verified tx detected a bad vintx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping the verified tx" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() warning: for the verified tx detected a bad vintx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx, skipping the verified tx" << std::endl); return 0; } } @@ -459,7 +459,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c const uint8_t funcId = ValidateTokenOpret(tx, reftokenid); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null funcId=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null funcId=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); uint8_t dummyEvalCode; uint256 tokenIdOpret; @@ -471,8 +471,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c if (checkPubkeys && funcId != 'c') { // for 'c' there is no pubkeys // verify that the vout is token by constructing vouts with the pubkeys in the opret: - LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret1=" << HexStr(vopret1) << std::endl); - LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret2=" << HexStr(vopret2) << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret1=" << HexStr(vopret1) << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret2=" << HexStr(vopret2) << std::endl); uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim uint8_t evalCode2 = 0; // will be checked if zero or not @@ -544,14 +544,14 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // try all test vouts: for (auto t : testVouts) { if (t.first == tx.vout[v]) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() valid amount=" << tx.vout[v].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() valid amount=" << tx.vout[v].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); return tx.vout[v].nValue; } } - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() no valid vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() no valid vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); } else { - LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); return tx.vout[v].nValue; } } @@ -579,7 +579,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu // this is just for log messages indentation for debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); - LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "TokensExactAmounts() entered for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << indentStr << "TokensExactAmounts() entered for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); for (int32_t i = 0; iGetTxUnconfirmed(tx.vin[i].prevout.hash, vinTx, hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock))) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << indentStr << "TokensExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "TokensExactAmounts() cannot read vintx for i." << i << " numvins." << numvins << std::endl); return (!eval) ? false : eval->Invalid("always should find vin tx, but didnt"); } else { - LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() checking vintx.vout for tx.vin[" << i << "] nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() checking vintx.vout for tx.vin[" << i << "] nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl); // validate vouts of vintx tokenValIndentSize++; @@ -601,7 +601,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu tokenValIndentSize--; if (tokenoshis != 0) { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding vintx.vout for tx.vin[" << i << "] tokenoshis=" << tokenoshis << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding vintx.vout for tx.vin[" << i << "] tokenoshis=" << tokenoshis << std::endl); inputs += tokenoshis; } } @@ -610,7 +610,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu for (int32_t i = 0; i < numvouts-1; i ++) // 'numvouts-1' <-- do not check opret { - LOGSTREAM("cctokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() recursively checking tx.vout[" << i << "] nValue=" << tx.vout[i].nValue << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << indentStr << "TokenExactAmounts() recursively checking tx.vout[" << i << "] nValue=" << tx.vout[i].nValue << std::endl); // Note: we pass in here IsTokenvout(false,...) because we don't need to call TokenExactAmounts() recursively from IsTokensvout here // indeed, if we pass 'true' we'll be checking this tx vout again @@ -620,7 +620,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu if (tokenoshis != 0) { - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding tx.vout[" << i << "] tokenoshis=" << tokenoshis << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "TokensExactAmounts() adding tx.vout[" << i << "] tokenoshis=" << tokenoshis << std::endl); outputs += tokenoshis; } } @@ -629,7 +629,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu if (inputs != outputs) { if (tx.GetHash() != reftokenid) - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl); return false; // do not call eval->Invalid() here! } else @@ -643,7 +643,7 @@ void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible uint256 hashBlock; if (!myGetTransaction(tokenid, tokenbasetx, hashBlock)) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "SetNonfungibleEvalCode() cound not load token creation tx=" << tokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "SetNonfungibleEvalCode() cound not load token creation tx=" << tokenid.GetHex() << std::endl); return; } @@ -682,7 +682,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C SetCCunspents(unspentOutputs, tokenaddr); if (unspentOutputs.empty()) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); } threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: maxinputs really could not be over 64? what if i want to calc total balance for all available uxtos? @@ -713,7 +713,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C strcmp(destaddr, cp->unspendableaddr2) != 0) // or the logic is to allow to spend all available tokens (what about unspendableaddr3)? continue; - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() check vintx vout destaddress=" << destaddr << " amount=" << vintx.vout[vout].nValue << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() check vintx vout destaddress=" << destaddr << " amount=" << vintx.vout[vout].nValue << std::endl); if ((nValue = IsTokensvout(true, true/*<--add only valid token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,vintxid, vout) == 0) { @@ -724,7 +724,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C // check if it is non-fungible token: GetNonfungibleData(tokenid, vopret); if (vopret != vopretNonfungible) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() found incorrect non-fungible opret payload for vintxid=" << vintxid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() found incorrect non-fungible opret payload for vintxid=" << vintxid.GetHex() << std::endl); continue; } @@ -737,7 +737,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C nValue = it->second.satoshis; totalinputs += nValue; - LOGSTREAM("cctokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() adding input nValue=" << nValue << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "AddTokenCCInputs() adding input nValue=" << nValue << std::endl); n++; if ((total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) @@ -757,11 +757,11 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st CPubKey mypk; struct CCcontract_info *cp, C; if (tokensupply < 0) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "CreateToken() negative tokensupply=" << tokensupply << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "CreateToken() negative tokensupply=" << tokensupply << std::endl); return std::string(""); } if (!nonfungibleData.empty() && tokensupply != 1) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "CreateToken() for non-fungible tokens tokensupply should be equal to 1" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "CreateToken() for non-fungible tokens tokensupply should be equal to 1" << std::endl); CCerror = "for non-fungible tokens tokensupply should be equal to 1"; return std::string(""); } @@ -770,7 +770,7 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st cp = CCinit(&C, EVAL_TOKENS); if (name.size() > 32 || description.size() > 4096) // this is also checked on rpc level { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "name of=" << name.size() << " or description of=" << description.size() << " is too big" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "name of=" << name.size() << " or description of=" << description.size() << " is too big" << std::endl); CCerror = "name should be < 32, description should be < 4096"; return(""); } @@ -789,7 +789,7 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } - LOGSTREAM("cctokens", CCLOG_INFO, stream << "cant find normal inputs" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "cant find normal inputs" << std::endl); CCerror = "cant find normal inputs"; return std::string(""); } @@ -803,7 +803,7 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d std::vector vopretNonfungible; if (total < 0) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "negative total=" << total << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "negative total=" << total << std::endl); return(""); } @@ -819,7 +819,7 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d if ((inputs = AddTokenCCInputs(cp, mtx, mypk, tokenid, total, 60, vopretNonfungible)) > 0) // NOTE: AddTokenCCInputs might set cp->additionalEvalCode which is used in FinalizeCCtx! { if (inputs < total) { //added dimxy - LOGSTREAM("cctokens", CCLOG_INFO, stream << "TokenTransfer(): insufficient token funds" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenTransfer(): insufficient token funds" << std::endl); CCerror = strprintf("insufficient token inputs"); return std::string(""); } @@ -840,13 +840,13 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutTokenPubkeys, vopretNonfungible, CScript()))); } else { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "not enough CC token inputs for amount=" << total << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "not enough CC token inputs for amount=" << total << std::endl); CCerror = strprintf("no token inputs"); } //} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size()); } else { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "not enough normal inputs for txfee" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "not enough normal inputs for txfee" << std::endl); CCerror = strprintf("insufficient normal inputs"); } return(""); @@ -864,7 +864,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl); CCerror = strprintf("cant find tokenid"); return 0; } @@ -892,7 +892,7 @@ UniValue TokenInfo(uint256 tokenid) } if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description, vopretNonfungible) == 0) { - LOGSTREAM("cctokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); result.push_back(Pair("result", "error")); result.push_back(Pair("error", "tokenid isnt token creation txid")); } diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 7efdebc8d..95d4fea72 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -17,10 +17,57 @@ #include #include #include +#include "../../cJSON.c" int32_t rogue_replay(uint64_t seed,int32_t sleeptime); int rogue(int argc, char **argv, char **envp); +void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) +{ + FILE *fp; + long filesize,buflen = *allocsizep; + uint8_t *buf = *bufp; + *lenp = 0; + if ( (fp= fopen(fname,"rb")) != 0 ) + { + fseek(fp,0,SEEK_END); + filesize = ftell(fp); + if ( filesize == 0 ) + { + fclose(fp); + *lenp = 0; + printf("OS_loadfile null size.(%s)\n",fname); + return(0); + } + if ( filesize > buflen ) + { + *allocsizep = filesize; + *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); + } + rewind(fp); + if ( buf == 0 ) + printf("Null buf ???\n"); + else + { + if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) + printf("error reading filesize.%ld\n",(long)filesize); + buf[filesize] = 0; + } + fclose(fp); + *lenp = filesize; + //printf("loaded.(%s)\n",buf); + } //else printf("OS_loadfile couldnt load.(%s)\n",fname); + return(buf); +} + +uint8_t *OS_fileptr(long *allocsizep,char *fname) +{ + long filesize = 0; uint8_t *buf = 0; void *retptr; + *allocsizep = 0; + retptr = OS_loadfile(fname,&buf,&filesize,allocsizep); + return((uint8_t *)retptr); +} + int main(int argc, char **argv, char **envp) { uint64_t seed; FILE *fp = 0; From 263b0e09ed3d2895b653f49ed26decf35de7e23e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:39:36 -1100 Subject: [PATCH 1915/3904] Boolean --- src/cc/rogue/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 95d4fea72..7e7e0209c 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -17,6 +17,9 @@ #include #include #include + +#define true 1 +#define false 0 #include "../../cJSON.c" int32_t rogue_replay(uint64_t seed,int32_t sleeptime); From 53ac13e3f0f68eb1c8b897638be27da4bf9bf872 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:41:10 -1100 Subject: [PATCH 1916/3904] komodo_cJSON.h --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 7e7e0209c..df04da7c6 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -20,7 +20,7 @@ #define true 1 #define false 0 -#include "../../cJSON.c" +#include "../../komodo_cJSON.c" int32_t rogue_replay(uint64_t seed,int32_t sleeptime); int rogue(int argc, char **argv, char **envp); From 14570c6eb3f3cbd0e0fa352084b10793e9c01d02 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:43:20 -1100 Subject: [PATCH 1917/3904] Compact --- src/cc/rogue/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index df04da7c6..426a69b40 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -18,6 +18,16 @@ #include #include +#define SMALLVAL 0.000000000000001 +#define SATOSHIDEN ((uint64_t)100000000L) +#define dstr(x) ((double)(x) / SATOSHIDEN) + +#ifndef _BITS256 +#define _BITS256 +union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; +typedef union _bits256 bits256; +#endif + #define true 1 #define false 0 #include "../../komodo_cJSON.c" From 8328842ff068c506fe0410a64061c17f45585765 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 10 Feb 2019 21:44:06 +0800 Subject: [PATCH 1918/3904] Disable getblocktemplate flag --- src/rpc/mining.cpp | 16 +++++++++++++++- src/rpc/misc.cpp | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c1d45c6e7..975154cdf 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -218,7 +218,18 @@ UniValue generate(const UniValue& params, bool fHelp) #endif } if (!Params().MineBlocksOnDemand()) - throw JSONRPCError(RPC_METHOD_NOT_FOUND, "This method can only be used on regtest"); + { + if ( params[0].get_int() == 1 ) + { + mapArgs["disablemining"] = "1"; + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Mining Disabled"); + } + else + { + mapArgs["disablemining"] = "0"; + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Mining Enabled"); + } + } int nHeightStart = 0; int nHeightEnd = 0; @@ -576,6 +587,9 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "komodod compiled without wallet and -mineraddress not set"); #endif } + + if ( GetArg("disablemining",false) ) + throw JSONRPCError(RPC_TYPE_ERROR, "Mining is Disabled"); UniValue lpval = NullUniValue; // TODO: Re-enable coinbasevalue once a specification has been written diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index d0dd65c41..bda9da062 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -119,7 +119,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) notaries.push_back(notary); } - // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. + // get the min sigs .. this always rounds UP so min sigs in iguana is +1 min sigs in komodod, due to some rounding error. int minsigs; if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) minsigs = (num_notaries_STAKED[era] / 5) + 1; From 1c41e45351dd3997a265521d8b86602b84eaff9b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:45:47 -1100 Subject: [PATCH 1919/3904] Utils --- src/cc/rogue/main.c | 137 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 426a69b40..00d31fde4 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -28,6 +28,143 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif +int32_t _unhex(char c) +{ + if ( c >= '0' && c <= '9' ) + return(c - '0'); + else if ( c >= 'a' && c <= 'f' ) + return(c - 'a' + 10); + else if ( c >= 'A' && c <= 'F' ) + return(c - 'A' + 10); + return(-1); +} + +int32_t is_hexstr(char *str,int32_t n) +{ + int32_t i; + if ( str == 0 || str[0] == 0 ) + return(0); + for (i=0; str[i]!=0; i++) + { + if ( n > 0 && i >= n ) + break; + if ( _unhex(str[i]) < 0 ) + break; + } + if ( n == 0 ) + return(i); + return(i == n); +} + +int32_t unhex(char c) +{ + int32_t hex; + if ( (hex= _unhex(c)) < 0 ) + { + //printf("unhex: illegal hexchar.(%c)\n",c); + } + return(hex); +} + +unsigned char _decode_hex(char *hex) { return((unhex(hex[0])<<4) | unhex(hex[1])); } + +int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) +{ + int32_t adjust,i = 0; + //printf("decode.(%s)\n",hex); + if ( is_hexstr(hex,n) <= 0 ) + { + memset(bytes,0,n); + return(n); + } + if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) + hex[--n] = 0; + if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) ) + { + if ( n > 0 ) + { + bytes[0] = unhex(hex[0]); + printf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex)); + } + bytes++; + hex++; + adjust = 1; + } else adjust = 0; + if ( n > 0 ) + { + for (i=0; i>4) & 0xf); + hexbytes[i*2 + 1] = hexbyte(message[i] & 0xf); + //printf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]); + } + hexbytes[len*2] = 0; + //printf("len.%ld\n",len*2+1); + return((int32_t)len*2+1); +} + +char *bits256_str(char hexstr[65],bits256 x) +{ + init_hexbytes_noT(hexstr,x.bytes,sizeof(x)); + return(hexstr); +} + +long _stripwhite(char *buf,int accept) +{ + int32_t i,j,c; + if ( buf == 0 || buf[0] == 0 ) + return(0); + for (i=j=0; buf[i]!=0; i++) + { + buf[j] = c = buf[i]; + if ( c == accept || (c != ' ' && c != '\n' && c != '\r' && c != '\t' && c != '\b') ) + j++; + } + buf[j] = 0; + return(j); +} + +char *clonestr(char *str) +{ + char *clone; + if ( str == 0 || str[0] == 0 ) + { + printf("warning cloning nullstr.%p\n",str); +#ifdef __APPLE__ + while ( 1 ) sleep(1); +#endif + str = (char *)""; + } + clone = (char *)malloc(strlen(str)+16); + strcpy(clone,str); + return(clone); +} + #define true 1 #define false 0 #include "../../komodo_cJSON.c" From 6a71231e174f1131c259794544b9c62aff0a5f84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:46:25 -1100 Subject: [PATCH 1920/3904] Memory and string --- src/cc/rogue/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 00d31fde4..aabb2562a 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) From 4a30b0a8bc99dffef69a451d756f5c8571102742 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:47:56 -1100 Subject: [PATCH 1921/3904] Safecopy --- src/cc/rogue/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index aabb2562a..a41e51dc3 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -166,6 +166,27 @@ char *clonestr(char *str) strcpy(clone,str); return(clone); } +int32_t safecopy(char *dest,char *src,long len) +{ + int32_t i = -1; + if ( src != 0 && dest != 0 && src != dest ) + { + if ( dest != 0 ) + memset(dest,0,len); + for (i=0; i Date: Sun, 10 Feb 2019 02:50:08 -1100 Subject: [PATCH 1922/3904] int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) --- src/cc/rogue/extern.h | 3 +++ src/cc/rogue/rogue.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 109ea0d49..486d85ff1 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -182,5 +182,8 @@ void md_onsignal_autosave(void); void md_onsignal_exit(void); void md_onsignal_default(void); int md_issymlink(char *sp); + +int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); + #endif diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 970844da0..e49163f74 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -15,6 +15,7 @@ #include #include #include "rogue.h" +#include "../../komodo_cJSON.h" /* * main: @@ -146,7 +147,7 @@ uint8_t *OS_fileptr(long *allocsizep,char *fname); void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { - char cmd[32768]; int32_t i,n; char *filestr,*datastr,fname[128]; long allocsize; //cJSON *retjson,*array,*item; + char cmd[32768]; int32_t i,n; char *filestr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; sprintf(fname,"%s.gameinfo",gametxidstr); sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); if ( system(cmd) != 0 ) @@ -154,7 +155,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) else { filestr = (char *)OS_fileptr(&allocsize,fname); - /*if ( (retjson= cJSON_Parse(filestr)) != 0 ) + if ( (retjson= cJSON_Parse(filestr)) != 0 ) { if ( (array= jarray(&n,retjson,"players")) != 0 ) { @@ -174,7 +175,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } } free_json(retjson); - }*/ + } free(filestr); } } From a15a77963dd8e8b37c542cedb0fb19a9e32c8138 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:51:06 -1100 Subject: [PATCH 1923/3904] Bits256 --- src/cc/rogue/main.c | 9 --------- src/cc/rogue/rogue.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index a41e51dc3..98cf4c304 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -20,15 +20,6 @@ #include #include -#define SMALLVAL 0.000000000000001 -#define SATOSHIDEN ((uint64_t)100000000L) -#define dstr(x) ((double)(x) / SATOSHIDEN) - -#ifndef _BITS256 -#define _BITS256 -union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; -typedef union _bits256 bits256; -#endif int32_t _unhex(char c) { diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index fa18c424f..ab7eba4b3 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -313,6 +313,18 @@ /* * Now we define the structures and types */ + +#define SMALLVAL 0.000000000000001 +#define SATOSHIDEN ((uint64_t)100000000L) +#define dstr(x) ((double)(x) / SATOSHIDEN) + +#ifndef _BITS256 +#define _BITS256 +union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; +typedef union _bits256 bits256; +#endif + + #ifndef ROGUE_DECLARED_PACK struct rogue_packitem { From 841588a109cec749bfb70b1b41a27e9f7067fa75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:52:21 -1100 Subject: [PATCH 1924/3904] is --- src/cc/rogue/main.c | 9 +++++++++ src/cc/rogue/rogue.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 98cf4c304..a41e51dc3 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -20,6 +20,15 @@ #include #include +#define SMALLVAL 0.000000000000001 +#define SATOSHIDEN ((uint64_t)100000000L) +#define dstr(x) ((double)(x) / SATOSHIDEN) + +#ifndef _BITS256 +#define _BITS256 +union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; +typedef union _bits256 bits256; +#endif int32_t _unhex(char c) { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index e49163f74..f7a4a8da0 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -162,7 +162,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) for (i=0; i Date: Sun, 10 Feb 2019 02:53:45 -1100 Subject: [PATCH 1925/3904] is_cJSON_True --- src/cc/rogue/rogue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f7a4a8da0..6bb9d8f83 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -144,6 +144,7 @@ int32_t flushkeystrokes(struct rogue_state *rs) #else uint8_t *OS_fileptr(long *allocsizep,char *fname); +#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { @@ -167,7 +168,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) fprintf(stderr,"found ismine:true\n"); if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 ) { - decode_hex(&rs->P,(int32_t)strlen(datastr)/2,datastr); + decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr); fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); rs->restoring = 1; } From 175ac9275dc0715c231f78fc0f5329d09a04e33e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 02:56:19 -1100 Subject: [PATCH 1926/3904] Delay to see --- src/cc/rogue/rogue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6bb9d8f83..5fc5bd7a9 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -166,11 +166,13 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) if ( is_cJSON_True(jobj(item,"ismine")) != 0 ) { fprintf(stderr,"found ismine:true\n"); + sleep(2); if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 ) { decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr); fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); rs->restoring = 1; + sleep(5); } } } From 8737db6f84116e86e653a79b0f6914d7b62a5e95 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:00:42 -1100 Subject: [PATCH 1927/3904] +print --- src/cc/rogue/rogue.c | 4 ++++ src/cc/rogue/state.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 5fc5bd7a9..27c4a9b20 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -99,7 +99,11 @@ void rogueiterate(struct rogue_state *rs) fuse(swander, 0, WANDERTIME, AFTER); start_daemon(stomach, 0, AFTER); if ( rs->restoring != 0 ) + { + fprintf(stderr,"restore player\n"); restore_player(rs); + sleep(3); + } playit(rs); } diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 68686b255..250010fe4 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1370,6 +1370,9 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) ws_info[item->which].oi_know = TRUE; break; } + char packitemstr[256]; + strcpy(packitemstr,inv_name(obj,FALSE)); + fprintf(stderr,"packitem.(%s)\n",packitemstr); } void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) From 7ac4a4f99fcb9cea61a46d7003692901890ec208 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:01:18 -1100 Subject: [PATCH 1928/3904] Obj -> o --- src/cc/rogue/state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 250010fe4..abbcdbdb7 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1371,7 +1371,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) break; } char packitemstr[256]; - strcpy(packitemstr,inv_name(obj,FALSE)); + strcpy(packitemstr,inv_name(o,FALSE)); fprintf(stderr,"packitem.(%s)\n",packitemstr); } From 59b2c324d5ec92a37fc43fcadb8b8b90f7be12af Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:06:17 -1100 Subject: [PATCH 1929/3904] Test --- src/cc/rogue/state.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index abbcdbdb7..46d789f87 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1351,6 +1351,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) o->_o._o_flags = item->flags; o->_o._o_group = item->group; o->o_flags |= ISKNOW; + o->o_flags &= ~ISFOUND; switch ( item->type ) { case SCROLL: @@ -1370,9 +1371,9 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) ws_info[item->which].oi_know = TRUE; break; } - char packitemstr[256]; - strcpy(packitemstr,inv_name(o,FALSE)); - fprintf(stderr,"packitem.(%s)\n",packitemstr); + //char packitemstr[256]; + //strcpy(packitemstr,inv_name(o,FALSE)); + //fprintf(stderr,"packitem.(%s)\n",packitemstr); } void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) From 37dfb49e4ebb90f2d42d6e929a0d3ff4f39edba9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:08:32 -1100 Subject: [PATCH 1930/3904] -prints -sleeps --- src/cc/rogue/rogue.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 27c4a9b20..c2f8c667b 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -99,11 +99,7 @@ void rogueiterate(struct rogue_state *rs) fuse(swander, 0, WANDERTIME, AFTER); start_daemon(stomach, 0, AFTER); if ( rs->restoring != 0 ) - { - fprintf(stderr,"restore player\n"); restore_player(rs); - sleep(3); - } playit(rs); } @@ -169,14 +165,11 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) item = jitem(array,i); if ( is_cJSON_True(jobj(item,"ismine")) != 0 ) { - fprintf(stderr,"found ismine:true\n"); - sleep(2); if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 ) { decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr); - fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); + //fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); rs->restoring = 1; - sleep(5); } } } From b50a9670ce7cdaa6cb927cf48706b4b316ae760a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:21:25 -1100 Subject: [PATCH 1931/3904] Restore --- src/cc/rogue/rogue.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index c2f8c667b..4aaab985c 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -146,9 +146,9 @@ int32_t flushkeystrokes(struct rogue_state *rs) uint8_t *OS_fileptr(long *allocsizep,char *fname); #define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) -void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) +int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { - char cmd[32768]; int32_t i,n; char *filestr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; sprintf(fname,"%s.gameinfo",gametxidstr); sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); if ( system(cmd) != 0 ) @@ -163,13 +163,17 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); - //fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); - rs->restoring = 1; + retval = 0; + if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 ) + { + decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr); + //fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); + rs->restoring = 1; + } } } } @@ -178,6 +182,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } free(filestr); } + return(retval); } void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to lookup gametxid @@ -209,7 +214,11 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->numkeys = num; rs->sleeptime = 0; if ( player != 0 ) + { rs->P = *player; + rs->restoring = 1; + fprintf(stderr,"restore player\n"); + } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); /*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); @@ -298,7 +307,11 @@ int rogue(int argc, char **argv, char **envp) { rs->seed = atol(argv[1]); strcpy(Gametxidstr,argv[2]); - rogue_setplayerdata(rs,Gametxidstr); + if ( rogue_setplayerdata(rs,Gametxidstr) < 0 ) + { + fprintf(stderr,"invalid gametxid, or already started\n"); + return(-1); + } } else rs->seed = 777; rs->guiflag = 1; rs->sleeptime = 1; // non-zero to allow refresh() From 3b32174da75cee49d66c15b961cfd305f6f832d6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:29:02 -1100 Subject: [PATCH 1932/3904] Test --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 47b166ce2..ebfd32620 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -808,8 +808,9 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); - fprintf(stderr,"found baton %s numkeys.%d seed.%llu\n",batontxid.ToString().c_str(),numkeys,(long long)seed); + fprintf(stderr,"found baton %s numkeys.%d seed.%llu playerdata.%d\n",batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); + sleep(60); if ( playerdata.size() > 0 ) { for (i=0; i Date: Sun, 10 Feb 2019 03:32:42 -1100 Subject: [PATCH 1933/3904] +prints --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue/state.c | 6 +++--- src/cc/rogue_rpc.cpp | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 4aaab985c..65a6ae605 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -217,7 +217,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu { rs->P = *player; rs->restoring = 1; - fprintf(stderr,"restore player\n"); + fprintf(stderr,"restore player packsize.%d\n",rp->P.packsize); } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 46d789f87..b97c5035f 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1371,9 +1371,9 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) ws_info[item->which].oi_know = TRUE; break; } - //char packitemstr[256]; - //strcpy(packitemstr,inv_name(o,FALSE)); - //fprintf(stderr,"packitem.(%s)\n",packitemstr); + char packitemstr[256]; + strcpy(packitemstr,inv_name(o,FALSE)); + fprintf(stderr,"packitem.(%s)\n",packitemstr); } void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ebfd32620..28fd07f6a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -810,7 +810,6 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); fprintf(stderr,"found baton %s numkeys.%d seed.%llu playerdata.%d\n",batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); - sleep(60); if ( playerdata.size() > 0 ) { for (i=0; i Date: Sun, 10 Feb 2019 03:34:08 -1100 Subject: [PATCH 1934/3904] Rs --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 65a6ae605..d7bc45fb6 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -217,7 +217,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu { rs->P = *player; rs->restoring = 1; - fprintf(stderr,"restore player packsize.%d\n",rp->P.packsize); + fprintf(stderr,"restore player packsize.%d\n",rs->P.packsize); } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); From 502195f02dfc87698342b8d2db9796420acdac30 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 10 Feb 2019 19:37:01 +0500 Subject: [PATCH 1935/3904] changed vout0 for tokens, added token opret with non-fungible data --- src/cc/rogue_rpc.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 47b166ce2..6923d5a56 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -822,7 +822,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vin.push_back(CTxIn(gametxid,1+maxplayers+regslot,CScript())); if ( funcid == 'H' ) mtx.vin.push_back(CTxIn(gametxid,0,CScript())); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,1,mypk)); + //mtx.vout.push_back(MakeCC1vout(cp->evalcode,1,mypk)); + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, mypk)); if ( num > 0 ) { newdata.resize(num); @@ -848,7 +849,14 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(funcid,gametxid,mypk,newdata)); + //rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(funcid,gametxid,mypk,newdata)); + + CScript opret = rogue_highlanderopret(funcid, gametxid, mypk, newdata); + + std::vector vopretNonfungible; + GetOpReturnData(opret, vopretNonfungible); + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string("???"), std::string("??????"), vopretNonfungible)); + return(rogue_rawtxresult(result,rawtx,1)); } result.push_back(Pair("result","success")); From 91d0ed149b5c8427b6a39f2633cad62f6b0e0459 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:37:46 -1100 Subject: [PATCH 1936/3904] Sleeps --- src/cc/rogue/rogue.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index d7bc45fb6..002912509 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -99,7 +99,10 @@ void rogueiterate(struct rogue_state *rs) fuse(swander, 0, WANDERTIME, AFTER); start_daemon(stomach, 0, AFTER); if ( rs->restoring != 0 ) + { restore_player(rs); + sleep(3); + } playit(rs); } @@ -218,6 +221,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->P = *player; rs->restoring = 1; fprintf(stderr,"restore player packsize.%d\n",rs->P.packsize); + sleep(3); } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); From 1c1ae17c10f85ebca93094364d5d638fdda3d3f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:42:35 -1100 Subject: [PATCH 1937/3904] replaydone --- src/cc/rogue/rogue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 002912509..91b09b0a3 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -99,10 +99,7 @@ void rogueiterate(struct rogue_state *rs) fuse(swander, 0, WANDERTIME, AFTER); start_daemon(stomach, 0, AFTER); if ( rs->restoring != 0 ) - { restore_player(rs); - sleep(3); - } playit(rs); } @@ -221,7 +218,6 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->P = *player; rs->restoring = 1; fprintf(stderr,"restore player packsize.%d\n",rs->P.packsize); - sleep(3); } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); @@ -682,9 +678,14 @@ shell(struct rogue_state *rs) void my_exit(int st) { + uint32_t counter; resetltchars(); if ( globalR.guiflag != 0 ) exit(st); - else fprintf(stderr,"would have exit.(%d)\n",st); + else if ( counter++ < 10 ) + { + fprintf(stderr,"would have exit.(%d)\n",st); + rs->replaydone = 1; + } } From 8f9182c45e58413dc62ef62103681838cf889155 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:43:20 -1100 Subject: [PATCH 1938/3904] globalR. --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 91b09b0a3..f56371815 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -685,7 +685,7 @@ my_exit(int st) else if ( counter++ < 10 ) { fprintf(stderr,"would have exit.(%d)\n",st); - rs->replaydone = 1; + globalR.replaydone = 1; } } From ff50eb0c7c1d7b7d9325db89780c1fe042db577e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 03:54:53 -1100 Subject: [PATCH 1939/3904] ESCAPE --- src/cc/rogue/io.c | 17 +++++++++++++---- src/cc/rogue/rogue.c | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index f4a859b38..f52b206ce 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -161,8 +161,9 @@ readchar(struct rogue_state *rs) rs->replaydone = (uint32_t)time(NULL); return(rs->keystrokes[rs->ind++]); } - fatal("replay finished but readchar called\n"); - return(' '); + //fatal("replay finished but readchar called\n"); + rs->replaydone = (uint32_t)time(NULL); + return(ESCAPE); } if ( rs == 0 || rs->guiflag != 0 ) { @@ -277,10 +278,18 @@ wait_for(struct rogue_state *rs,int ch) if (ch == '\n') while ((c = readchar(rs)) != '\n' && c != '\r') - continue; + { + if ( rs->replaydone != 0 ) + return; + continue; + } else while (readchar(rs) != ch) - continue; + { + if ( rs->replaydone != 0 ) + return; + continue; + } } /* diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f56371815..3d4e012ac 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -543,7 +543,7 @@ playit(struct rogue_state *rs) { if ( rs->replaydone != 0 ) { - //fprintf(stderr,"replaydone\n"); sleep(3); + fprintf(stderr,"replaydone\n"); sleep(3); return; } if ( rs->sleeptime != 0 ) From 2297cbdfac40207204c0a551d357c72fb398086c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:00:02 -1100 Subject: [PATCH 1940/3904] Test --- src/cc/rogue/io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index f52b206ce..ee8aaebbb 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -159,9 +159,10 @@ readchar(struct rogue_state *rs) { if ( rs->ind == rs->numkeys-1 ) rs->replaydone = (uint32_t)time(NULL); + fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } - //fatal("replay finished but readchar called\n"); + fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); return(ESCAPE); } From 9ea6248655d51434880cbbb62967c52cbaf8bcd7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:08:13 -1100 Subject: [PATCH 1941/3904] Test --- src/cc/rogue/command.c | 2 ++ src/cc/rogue/io.c | 6 +++--- src/cc/rogue/rogue.c | 48 +++++++++++++++++++++++++----------------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index bdbf37b76..3414bfe3b 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -117,6 +117,8 @@ command(struct rogue_state *rs) * turn off count for commands which don't make sense * to repeat */ + if ( rs->guiflag == 0 && rs->replaydone != 0 ) + ch = 'Q'; switch (ch) { case CTRL('B'): case CTRL('H'): case CTRL('J'): diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index ee8aaebbb..c64b9c8b0 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -157,14 +157,14 @@ readchar(struct rogue_state *rs) { if ( rs->ind < rs->numkeys ) { - if ( rs->ind == rs->numkeys-1 ) - rs->replaydone = (uint32_t)time(NULL); + //if ( rs->ind == rs->numkeys-1 ) + // rs->replaydone = (uint32_t)time(NULL); fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); - return(ESCAPE); + return('y'); } if ( rs == 0 || rs->guiflag != 0 ) { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 3d4e012ac..cbabaff3b 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -571,27 +571,37 @@ quit(int sig) { struct rogue_state *rs = &globalR; int oy, ox; - - NOOP(sig); - - /* - * Reset the signal in case we got here via an interrupt - */ - if (!q_comm) - mpos = 0; - getyx(curscr, oy, ox); - msg(rs,"really quit?"); + fprintf(stder,"inside quit(%d)\n",sig); + if ( rs->guiflag != 0 ) + { + NOOP(sig); + + /* + * Reset the signal in case we got here via an interrupt + */ + if (!q_comm) + mpos = 0; + getyx(curscr, oy, ox); + msg(rs,"really quit?"); + } if (readchar(rs) == 'y') { - signal(SIGINT, leave); - clear(); - mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse); - move(LINES - 1, 0); - if ( rs->sleeptime != 0 ) - refresh(); - score(purse, 1, 0); - flushkeystrokes(rs); - my_exit(0); + if ( rs->guiflag != 0 ) + { + signal(SIGINT, leave); + clear(); + mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse); + move(LINES - 1, 0); + if ( rs->sleeptime != 0 ) + refresh(); + score(purse, 1, 0); + flushkeystrokes(rs); + my_exit(0); + } + else + { + score(purse, 1, 0); + } } else { From 4680ae91da1338da41820c965bcddfe5574554b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:08:42 -1100 Subject: [PATCH 1942/3904] Stderr --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index cbabaff3b..46b3f5c33 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -571,7 +571,7 @@ quit(int sig) { struct rogue_state *rs = &globalR; int oy, ox; - fprintf(stder,"inside quit(%d)\n",sig); + fprintf(stderr,"inside quit(%d)\n",sig); if ( rs->guiflag != 0 ) { NOOP(sig); From 92ba9815e8beaa063fb3aca589814e4b4adc24c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:14:17 -1100 Subject: [PATCH 1943/3904] Prints --- src/cc/rogue/command.c | 6 +++--- src/cc/rogue/rogue.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 3414bfe3b..6d1520321 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -265,7 +265,7 @@ over: after = FALSE; q_comm = TRUE; quit(0); - if ( rs->needflush == 0 ) + if ( rs->guiflag != 0 && rs->needflush == 0 ) rs->needflush = (uint32_t)time(NULL); q_comm = FALSE; when 'i': after = FALSE; inventory(rs,pack, 0); @@ -282,11 +282,11 @@ over: when 'c': call(rs); after = FALSE; when '>': after = FALSE; d_level(rs); - if ( rs->needflush == 0 ) + if ( rs->guiflag != 0 && rs->needflush == 0 ) rs->needflush = (uint32_t)time(NULL); when '<': after = FALSE; u_level(rs); - if ( rs->needflush == 0 ) + if ( rs->guiflag != 0 && rs->needflush == 0 ) rs->needflush = (uint32_t)time(NULL); when '?': after = FALSE; help(rs); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 46b3f5c33..b2bd485b2 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -600,6 +600,7 @@ quit(int sig) } else { + fprintf(stderr,"done!\n"); score(purse, 1, 0); } } From a4a93eb86284fbc81ae664263281b122e776dd8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:19:02 -1100 Subject: [PATCH 1944/3904] Hard return --- src/cc/rogue/command.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 6d1520321..0b7618df6 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -38,6 +38,8 @@ command(struct rogue_state *rs) do_fuses(rs,BEFORE); while (ntimes--) { + if ( rs->replaydone != 0 ) + return; again = FALSE; if (has_hit) { @@ -268,6 +270,7 @@ over: if ( rs->guiflag != 0 && rs->needflush == 0 ) rs->needflush = (uint32_t)time(NULL); q_comm = FALSE; + return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); when 'd': drop(rs); @@ -448,23 +451,23 @@ over: /* * If he ran into something to take, let him pick it up. */ - if (take != 0) - pick_up(rs,take); - if (!running) - door_stop = FALSE; - if (!after) - ntimes++; + if (take != 0) + pick_up(rs,take); + if (!running) + door_stop = FALSE; + if (!after) + ntimes++; } do_daemons(rs,AFTER); do_fuses(rs,AFTER); if (ISRING(LEFT, R_SEARCH)) - search(rs); + search(rs); else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) - teleport(rs); + teleport(rs); if (ISRING(RIGHT, R_SEARCH)) - search(rs); + search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) - teleport(rs); + teleport(rs); } /* From 73a696f00835a5f3be2812bc44f5cd138e8a63ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:23:23 -1100 Subject: [PATCH 1945/3904] Test --- src/cc/CCtx.cpp | 2 +- src/cc/rogue/io.c | 6 ++++-- src/cc/rogue_rpc.cpp | 11 +++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index af5535591..3e36c681a 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -157,7 +157,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); - std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; + //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index c64b9c8b0..38252fafd 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -159,12 +159,14 @@ readchar(struct rogue_state *rs) { //if ( rs->ind == rs->numkeys-1 ) // rs->replaydone = (uint32_t)time(NULL); - fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); + //fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); - return('y'); + if ( (rand() & 1) == 0 ) + return(ESCAPE); + else return('y'); } if ( rs == 0 || rs->guiflag != 0 ) { diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 28fd07f6a..ff8ab88c2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -839,9 +839,12 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(cclib_error(result,"highlander must be a winner or last one standing")); cashout += numplayers * buyin; } - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) - CCchange = (inputsum - cashout); - mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + if ( cashout >= txfee ) + { + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) + CCchange = (inputsum - cashout); + mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + } //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); } @@ -849,7 +852,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(funcid,gametxid,mypk,newdata)); - return(rogue_rawtxresult(result,rawtx,1)); + return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); } From 9342d3f7429351bddf5e5f5ec4a70d270e8e71fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:40:58 -1100 Subject: [PATCH 1946/3904] Token support --- src/cc/CCinclude.h | 1 + src/cc/rogue_rpc.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 89e6343b9..70069cad8 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -186,6 +186,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t // CCcustom CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2); // CCutils bool priv2addr(char *coinaddr,uint8_t buf33[33],uint8_t priv32[32]); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f4bf294ee..f35ad1629 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -197,12 +197,14 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,CPubKey pk,std::ve uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) { - std::vector vopret; uint8_t *script,e,f; - GetOpReturnData(scriptPubKey,vopret); - script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q' || f == 'S') ) + std::vector vopret,vpopret2; uint8_t *script,e,f; uint256 tokenid; std::vector voutPubkeys + if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { - return(f); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + { + return(f); + } } return(0); } @@ -419,7 +421,6 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs playertxid is whoever owns the nonfungible satoshi and it might have been bought and sold many times. highlander is the game winning tx with the player data and is the only place where the unique player data exists origplayergame is the gametxid that ends up being won by the highlander and they are linked directly as the highlander tx spends gametxid.vout0 - 'S' is for sell, but will need to change to accomodate assets */ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) @@ -429,7 +430,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q' || script[1] == 'S') ) + if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q') ) { memcpy(&gametxid,script+2,sizeof(gametxid)); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) @@ -437,7 +438,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { - if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' ) + if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { // if registertxid has vin from pk, it can be used return(0); @@ -860,7 +861,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetOpReturnData(opret, vopretNonfungible); rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string("???"), std::string("??????"), vopretNonfungible)); - return(rogue_rawtxresult(result,rawtx,1)); + return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); } From 544bc5c89a37464dce19a98ca949d6ca2c457b74 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:42:01 -1100 Subject: [PATCH 1947/3904] ; --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f35ad1629..2a3f2dd3a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -197,7 +197,7 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,CPubKey pk,std::ve uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) { - std::vector vopret,vpopret2; uint8_t *script,e,f; uint256 tokenid; std::vector voutPubkeys + std::vector vopret,vpopret2; uint8_t *script,e,f; uint256 tokenid; std::vector voutPubkeys; if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { script = (uint8_t *)vopret.data(); From be683c1f1302422a602634558787bbc923275e30 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 04:44:08 -1100 Subject: [PATCH 1948/3904] Vopret2 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2a3f2dd3a..79d47f647 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -197,7 +197,7 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,CPubKey pk,std::ve uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) { - std::vector vopret,vpopret2; uint8_t *script,e,f; uint256 tokenid; std::vector voutPubkeys; + std::vector vopret,vopret2; uint8_t *script,e,f; uint256 tokenid; std::vector voutPubkeys; if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { script = (uint8_t *)vopret.data(); From 43f0a2ba92d2a976aaf2cbe762ddd959465f8445 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 05:03:39 -1100 Subject: [PATCH 1949/3904] Hardcode address --- src/cc/CCtx.cpp | 16 ++++++++-------- src/cc/rogue_rpc.cpp | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 3e36c681a..63f104896 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -160,7 +160,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { - fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); + //fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); privkey = myprivkey; cond = mycond; } @@ -168,30 +168,30 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = myprivkey; cond = mytokenscond; - fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); + //fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); } else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout { privkey = myprivkey; cond = mysingletokenscond; - fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); + //fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); } else if ( strcmp(destaddr,unspendable) == 0 ) { privkey = unspendablepriv; cond = othercond; - fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); + //fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, unspendabletokensaddr) == 0) { privkey = unspendablepriv; cond = othertokenscond; - fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); + //fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); } // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr, cp->unspendableaddr2) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; if( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2); @@ -200,7 +200,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); privkey = cp->unspendablepriv3; if( othercond3 == 0 ) othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3); @@ -226,7 +226,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc tokens addr: else if (strcmp(cp->tokens1of2addr, destaddr) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); + //fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); privkey = myprivkey; if (othercond1of2tokens == 0) // NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 79d47f647..981de91ae 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -128,12 +128,12 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22]\" -// cclib register 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22]\" +// cclib gameinfo 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22]\" +// cclib register 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22,%2233d52f92980ceaa81556093171ee224e085fd384690d83460d6fbbad96fe0e7e%22]\" +// cclib register 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22,%2233d52f92980ceaa81556093171ee224e085fd384690d83460d6fbbad96fe0e7e%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%2250ad0155ea102f94949d51cc911e1d41ac03d24caf1a79cf5e0a4d9cc05ed836%22]\" +// cclib bailout 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22]\" // eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd /* 2409 gold.209 hp.17 strength.16 level.3 exp.22 3 @@ -952,7 +952,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress(cp,coinaddr,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,"RLxgD7gu5XEbzPkFWVLDV38CrfXwqfz73z");//coinaddr); rogue_univalue(result,"players",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { From 3b9b9191f3f12cdddde25fd739298ea416ccba88 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 05:08:45 -1100 Subject: [PATCH 1950/3904] Dont do raw data access --- src/cc/rogue_rpc.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 981de91ae..7c2869fc6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -428,22 +428,19 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { - GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); - script = (uint8_t *)vopret.data(); - if ( vopret.size() > 34 && script[0] == EVAL_ROGUE && (script[1] == 'H' || script[1] == 'Q') ) + //GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); + //script = (uint8_t *)vopret.data(); + if ( (f= rogue_highlanderopretdecode(gametxid,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { - memcpy(&gametxid,script+2,sizeof(gametxid)); + fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); + //memcpy(&gametxid,script+2,sizeof(gametxid)); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { - if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) - { - // if registertxid has vin from pk, it can be used - return(0); - } - else fprintf(stderr,"f is %c/%d\n",f,f); + // if registertxid has vin from pk, it can be used + return(0); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); } } @@ -958,7 +955,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { txid = it->first.txhash; vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != 1 || vout != 0 ) continue; if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) From 24c390a0cda4bd6d36fec262927e29010c2f08a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 05:15:22 -1100 Subject: [PATCH 1951/3904] -sleep --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b2bd485b2..0d7c47fda 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -543,7 +543,7 @@ playit(struct rogue_state *rs) { if ( rs->replaydone != 0 ) { - fprintf(stderr,"replaydone\n"); sleep(3); + //fprintf(stderr,"replaydone\n"); sleep(3); return; } if ( rs->sleeptime != 0 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7c2869fc6..0421ed8d1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -948,8 +948,8 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); - GetCCaddress(cp,coinaddr,mypk); - SetCCunspents(unspentOutputs,"RLxgD7gu5XEbzPkFWVLDV38CrfXwqfz73z");//coinaddr); + GetTokensCCaddress(cp,coinaddr,mypk); + SetCCunspents(unspentOutputs,coinaddr); rogue_univalue(result,"players",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { From 8d7234bf220b2bb521a4e0445ead6ceab8064b0b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 11 Feb 2019 01:10:27 +0800 Subject: [PATCH 1952/3904] Test fix to stop nodes forceing an attacking chain onto others. --- src/main.cpp | 36 +++++++++++++++++++----------------- src/net.h | 3 +++ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 30b569c3e..054313a21 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -282,9 +282,6 @@ namespace { bool fCurrentlyConnected; //! Accumulated misbehaviour score for this peer. int nMisbehavior; - // count blocks seen. - //int8_t nBlocksinARow; - //int8_t nBlocksinARow2; //! Whether this peer should be disconnected and banned (unless whitelisted). bool fShouldBan; //! String name of this peer (debugging/logging purposes). @@ -5472,20 +5469,6 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool checked; uint256 hash; int32_t futureblock=0; auto verifier = libzcash::ProofVerifier::Disabled(); hash = pblock->GetHash(); - /*pfrom->nBlocksinARow += 1; - if ( pfrom->nBlocksinARow >= 6 ) - { - pfrom->nBlocksinARow2 += 1; - if ( pfrom->nBlocksinARow2 > 3 ) - { - pfrom->nBlocksinARow = 0; - pfrom->nBlocksinARow2 = 0; - } - else - { - return(false); - } - }*/ //fprintf(stderr,"ProcessBlock %d\n",(int32_t)chainActive.LastTip()->GetHeight()); { LOCK(cs_main); @@ -5493,6 +5476,25 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo komodo_currentheight_set(chainActive.LastTip()->GetHeight()); checked = CheckBlock(&futureblock,height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0); bool fRequested = MarkBlockAsReceived(hash); + if ( pfrom && !fRequested && vNodes.size() > 1 ) + { + pfrom->nBlocksinARow += 1; + if ( pfrom->nBlocksinARow >= 10 ) + { + pfrom->nBlocksinARow2 += 1; + if ( pfrom->nBlocksinARow2 > 5 ) + { + pfrom->nBlocksinARow = 0; + pfrom->nBlocksinARow2 = 0; + //fprintf(stderr, "reset node.%i\n",(int32_t)pfrom->GetId()); + } + else + { + //fprintf(stderr, "Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",(int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2); + return(false); + } + } + } fRequested |= fForceProcessing; if ( checked != 0 && komodo_checkPOW(0,pblock,height) < 0 ) //from_miner && ASSETCHAINS_STAKED == 0 { diff --git a/src/net.h b/src/net.h index 3e06e9831..b7975bfec 100644 --- a/src/net.h +++ b/src/net.h @@ -293,6 +293,9 @@ public: bool fNetworkNode; bool fSuccessfullyConnected; bool fDisconnect; + // count blocks seen. + int8_t nBlocksinARow; + int8_t nBlocksinARow2; // We use fRelayTxes for two purposes - // a) it allows us to not relay tx invs before receiving the peer's version message // b) the peer may tell us in its version message that we should not relay tx invs From 6fdf25af762fb3975b5b6608a2864080241f7015 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 07:11:30 -1100 Subject: [PATCH 1953/3904] Fix cclibinfo for rogue --- src/cc/CCcustom.cpp | 2 +- src/cc/cclib.cpp | 6 +++--- src/cc/rogue/daemons.c | 2 +- src/cc/rogue/fight.c | 12 ++++++------ src/cc/rogue/move.c | 4 ++-- src/cc/rogue/rip.c | 9 +++++++-- src/cc/rogue/rogue.c | 2 +- src/cc/rogue/rogue.h | 2 +- src/cc/rogue/sticks.c | 4 ++-- src/cc/rogue_rpc.cpp | 15 ++++++--------- 10 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index d2cb811cd..3a00e0c98 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -262,7 +262,7 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) { if ( buf2pk(check33) == pk && strcmp(checkaddr,cp->normaladdr) == 0 ) { - fprintf(stderr,"verified evalcode.%d %s %s\n",cp->evalcode,checkaddr,pubkey33_str(str,pub33)); + //fprintf(stderr,"verified evalcode.%d %s %s\n",cp->evalcode,checkaddr,pubkey33_str(str,pub33)); return(0); } else fprintf(stderr,"CClib_initcp mismatched privkey -> addr %s vs %s\n",checkaddr,cp->normaladdr); } diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 78332c576..ea39bbc41 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -58,10 +58,10 @@ CClib_methods[] = { (char *)"rogue", (char *)"pending", (char *)"", 0, 0, 'P', EVAL_ROGUE }, { (char *)"rogue", (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_ROGUE }, { (char *)"rogue", (char *)"keystrokes", (char *)"gametxid keystrokes", 2, 2, 'K', EVAL_ROGUE }, - { (char *)"rogue", (char *)"bailout", (char *)"baton finalhash", 2, 2, 'Q', EVAL_ROGUE }, - { (char *)"rogue", (char *)"highlander", (char *)"baton finalhash", 2, 2, 'H', EVAL_ROGUE }, + { (char *)"rogue", (char *)"bailout", (char *)"gametxid", 1, 1, 'Q', EVAL_ROGUE }, + { (char *)"rogue", (char *)"highlander", (char *)"gametxid", 1, 1, 'H', EVAL_ROGUE }, { (char *)"rogue", (char *)"playerinfo", (char *)"playertxid", 1, 1, 'I', EVAL_ROGUE }, - { (char *)"rogue", (char *)"players", (char *)"playertxid", 1, 1, 'D', EVAL_ROGUE }, + { (char *)"rogue", (char *)"players", (char *)"", 0, 0, 'D', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 75d544cda..436aa004d 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -143,7 +143,7 @@ stomach(struct rogue_state *rs,int arg) if (food_left <= 0) { if (food_left-- < -STARVETIME) - death('s'); + death(rs,'s'); /* * the hero is fainting */ diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 6f5fc00b4..7f4aad587 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -175,7 +175,7 @@ attack(struct rogue_state *rs,THING *mp) endmsg(rs); has_hit = FALSE; if (pstats.s_hpt <= 0) - death(mp->t_type); /* Bye bye life ... */ + death(rs,mp->t_type); /* Bye bye life ... */ else if (!kamikaze) { oldhp -= pstats.s_hpt; @@ -206,7 +206,7 @@ attack(struct rogue_state *rs,THING *mp) } no_command += rnd(2) + 2; if (no_command > BORE_LEVEL) - death('h'); + death(rs,'h'); when 'R': /* * Rattlesnakes have poisonous bites @@ -242,7 +242,7 @@ attack(struct rogue_state *rs,THING *mp) if (mp->t_type == 'W') { if (pstats.s_exp == 0) - death('W'); /* All levels gone */ + death(rs,'W'); /* All levels gone */ if (--pstats.s_lvl == 0) { pstats.s_exp = 0; @@ -259,7 +259,7 @@ attack(struct rogue_state *rs,THING *mp) if (pstats.s_hpt <= 0) pstats.s_hpt = 1; if (max_hp <= 0) - death(mp->t_type); + death(rs,mp->t_type); msg(rs,"you suddenly feel weaker"); } when 'F': @@ -269,7 +269,7 @@ attack(struct rogue_state *rs,THING *mp) player.t_flags |= ISHELD; sprintf(monsters['F'-'A'].m_stats.s_dmg,"%dx1", ++vf_hit); if (--pstats.s_hpt <= 0) - death('F'); + death(rs,'F'); when 'L': { /* @@ -327,7 +327,7 @@ attack(struct rogue_state *rs,THING *mp) { pstats.s_hpt -= vf_hit; if (pstats.s_hpt <= 0) - death(mp->t_type); /* Bye bye life ... */ + death(rs,mp->t_type); /* Bye bye life ... */ } miss(rs,mname, (char *) NULL, FALSE); } diff --git a/src/cc/rogue/move.c b/src/cc/rogue/move.c index 87276e8e2..3bdf90d37 100644 --- a/src/cc/rogue/move.c +++ b/src/cc/rogue/move.c @@ -310,7 +310,7 @@ be_trapped(struct rogue_state *rs,coord *tc) if (pstats.s_hpt <= 0) { msg(rs,"an arrow killed you"); - death('a'); + death(rs,'a'); } else msg(rs,"oh no! An arrow shot you"); @@ -340,7 +340,7 @@ be_trapped(struct rogue_state *rs,coord *tc) if (pstats.s_hpt <= 0) { msg(rs,"a poisoned dart killed you"); - death('d'); + death(rs,'d'); } if (!ISWEARING(R_SUSTSTR) && !save(VS_POISON)) chg_str(-1); diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index 69eb89751..4e3a349a8 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -227,13 +227,18 @@ score(int amount, int flags, char monst) */ void -death(char monst) +death(struct rogue_state *rs,char monst) { char **dp, *killer; struct tm *lt; static time_t date; //struct tm *localtime(const time_t *); - + if ( rs->guiflag == 0 ) + { + fprintf(stderr,"death during replay\n"); + rs->replaydone = (uint32_t)time(NULL); + return; + } signal(SIGINT, SIG_IGN); purse -= purse / 10; signal(SIGINT, leave); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 0d7c47fda..57b63eb25 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -388,7 +388,7 @@ int rogue(int argc, char **argv, char **envp) level = rnd(100) + 1; initscr(); getltchars(); - death(death_monst()); + death(rs,death_monst()); exit(0); } } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index ab7eba4b3..6543976da 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -586,7 +586,7 @@ void create_obj(struct rogue_state *rs); void current(struct rogue_state *rs,THING *cur, char *how, char *where); void d_level(struct rogue_state *rs); -void death(char monst); +void death(struct rogue_state *rs,char monst); char death_monst(void); void dig(int y, int x); void discard(THING *item); diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index 7f9dc6ec2..39e098339 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -391,9 +391,9 @@ def: if ((pstats.s_hpt -= roll(6, 6)) <= 0) { if (start == &hero) - death('b'); + death(rs,'b'); else - death(moat(start->y, start->x)->t_type); + death(rs,moat(start->y, start->x)->t_type); } used = TRUE; if (terse) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0421ed8d1..0ba5bc6ae 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -114,26 +114,23 @@ */ // todo: -// verify playerdata is usable -// detect playerdeath/quit to prevent illegal keystrokes vector +// -detect playerdeath/quit to prevent illegal keystrokes vector // verify keystrokes tx is in mempool and confirmed // check that bailout is legal, ie. proper gametxid vin // verify amulet possession in pack -// display playerdata (user comments?, or fully decode) -// verify playerdata can be used and has same initial level -// prevent running gui mode when keystrokes txid already there +// -verify playerdata can be used and has same initial level //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22]\" -// cclib register 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22]\" +// cclib gameinfo 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22]\" +// cclib register 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22,%2233d52f92980ceaa81556093171ee224e085fd384690d83460d6fbbad96fe0e7e%22]\" +// cclib register 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22,%22f3a4a61cfa0dd43733b06d1368c199594258e0f3db983dc1b9b10768a5671909%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%22f60167a973fc4a5ff08b378bff78bfbfa2f7fae04d603e8deb9acdb1551e0d10%22]\" +// cclib bailout 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22]\" // eef1d0091a88d85bdac1ede9d31db8504bc466a6695fdf259dac623fce09e0dd /* 2409 gold.209 hp.17 strength.16 level.3 exp.22 3 From 82b8ae689a41b3ec32708a15a6a79b1de49b6a3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 07:33:44 -1100 Subject: [PATCH 1954/3904] Player death -> loss of player data --- src/cc/rogue/state.c | 38 +++++++++++++++++--------- src/cc/rogue_rpc.cpp | 63 +++++++++++++++++++++++++------------------- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index b97c5035f..b47b83faf 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1428,21 +1428,33 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) if ( o->_o._o_packch != 0 ) { item = &rs->P.roguepack[rs->P.packsize]; - if ( rs->P.packsize++ == 0 ) + if ( pstats.s_hpt <= 0 ) { - rs->P.gold = purse; - rs->P.hitpoints = max_hp; - rs->P.strength = max_stats.s_str; - rs->P.level = pstats.s_lvl; - rs->P.experience = pstats.s_exp; - rs->P.dungeonlevel = level; - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); - }; - fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); - if ( rs->P.packsize < MAXPACK ) - packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); + fprintf(stderr,"KILLED\n"); + rs->P.gold = -1; + rs->P.hitpoints = -1; + rs->P.strength = -1; + rs->P.level = -1; + rs->P.experience = -1; + rs->P.dungeonlevel = -1; + } + else + { + if ( rs->P.packsize++ == 0 ) + { + rs->P.gold = purse; + rs->P.hitpoints = max_hp; + rs->P.strength = max_stats.s_str; + rs->P.level = pstats.s_lvl; + rs->P.experience = pstats.s_exp; + rs->P.dungeonlevel = level; + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); + } + fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); + if ( rs->P.packsize < MAXPACK ) + packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); + } } - rs_write_marker(savef, RSID_OBJECT); rs_write_int(savef, o->_o._o_type); rs_write_coord(savef, o->_o._o_pos); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0ba5bc6ae..11c2d28ae 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -194,10 +194,12 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,CPubKey pk,std::ve uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) { - std::vector vopret,vopret2; uint8_t *script,e,f; uint256 tokenid; std::vector voutPubkeys; - if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) + std::vector vopret,vopret2; uint8_t e,f; uint256 tokenid; std::vector voutPubkeys; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + return(f); + else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { - script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) { return(f); @@ -208,9 +210,8 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector &keystrokes,CScript scriptPubKey) { - std::vector vopret; uint8_t *script,e,f; + std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> batontxid; ss >> pk; ss >> keystrokes) != 0 && e == EVAL_ROGUE && f == 'K' ) { return(f); @@ -220,9 +221,8 @@ uint8_t rogue_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &playertxid,CScript scriptPubKey) { - std::vector vopret; uint8_t *script,e,f; + std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) { return(f); @@ -232,9 +232,8 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &playertxid,CScript uint8_t rogue_newgameopreturndecode(int64_t &buyin,int32_t &maxplayers,CScript scriptPubKey) { - std::vector vopret; uint8_t *script,e,f; + std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin; ss >> maxplayers) != 0 && e == EVAL_ROGUE && f == 'G' ) { return(f); @@ -817,7 +816,6 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vin.push_back(CTxIn(gametxid,1+maxplayers+regslot,CScript())); if ( funcid == 'H' ) mtx.vin.push_back(CTxIn(gametxid,0,CScript())); - //mtx.vout.push_back(MakeCC1vout(cp->evalcode,1,mypk)); mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, mypk)); if ( num > 0 ) { @@ -827,19 +825,27 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); - cashout = (uint64_t)P.gold * mult; - if ( funcid == 'H' && maxplayers > 1 ) + if ( P.gold < 0 || P.hitpoints < 0 || P.strength < 0 || P.level < 0 || P.experience < 0 || P.dungeonlevel < 0 ) { - if ( numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1 && (P.dungeonlevel > 1 || P.gold < 10000 || P.level < 20) ) - return(cclib_error(result,"highlander must be a winner or last one standing")); - cashout += numplayers * buyin; + fprintf(stderr,"was killed -> no playerdata\n"); + newdata.resize(0); } - if ( cashout >= txfee ) + else { - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) - CCchange = (inputsum - cashout); - mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + cashout = (uint64_t)P.gold * mult; + if ( funcid == 'H' && maxplayers > 1 ) + { + if ( numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1 && (P.dungeonlevel > 1 || P.gold < 10000 || P.level < 20) ) + return(cclib_error(result,"highlander must be a winner or last one standing")); + cashout += numplayers * buyin; + } + if ( cashout >= txfee ) + { + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) + CCchange = (inputsum - cashout); + mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + } } //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); @@ -847,14 +853,17 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); - //rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_highlanderopret(funcid,gametxid,mypk,newdata)); - CScript opret = rogue_highlanderopret(funcid, gametxid, mypk, newdata); - - std::vector vopretNonfungible; - GetOpReturnData(opret, vopretNonfungible); - rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string("???"), std::string("??????"), vopretNonfungible)); - + if ( newdata.size() == 0 ) + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); + else + { + char seedstr[32]; + sprintf(seedstr,"%llu",(long long)seed); + std::vector vopretNonfungible; + GetOpReturnData(opret, vopretNonfungible); + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string(seedstr), gametxid.GetHex(), vopretNonfungible)); + } return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); From 8919dd65236a41f976919fb1f2e097d75276d3f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 07:42:52 -1100 Subject: [PATCH 1955/3904] Auto bailout on quit or death --- src/cc/rogue/command.c | 1 + src/cc/rogue/extern.h | 1 + src/cc/rogue/rip.c | 1 + src/cc/rogue/rogue.c | 13 ++++++++++++- src/cc/rogue_rpc.cpp | 16 ---------------- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 0b7618df6..a6cf50724 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -270,6 +270,7 @@ over: if ( rs->guiflag != 0 && rs->needflush == 0 ) rs->needflush = (uint32_t)time(NULL); q_comm = FALSE; + rogue_bailout(); return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 486d85ff1..0791702d6 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -184,6 +184,7 @@ void md_onsignal_default(void); int md_issymlink(char *sp); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +void rogue_bailout(void); #endif diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index 4e3a349a8..56f2453a4 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -275,6 +275,7 @@ death(struct rogue_state *rs,char monst) move(LINES - 1, 0); refresh(); score(purse, amulet ? 3 : 0, monst); + rogue_bailout(); printf("[Press return to continue]"); fflush(stdout); if ( fgets(prbuf,10,stdin) != 0 ) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 57b63eb25..2d89cbc67 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -185,7 +185,18 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) return(retval); } -void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to lookup gametxid +void rogue_bailout() +{ + char cmd[32768],hexstr[32768]; int32_t i; + for (i=0; i> keystrokes.log",Gametxidstr); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); +} + +void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) { char cmd[32768],hexstr[32768]; int32_t i; for (i=0; i Date: Sun, 10 Feb 2019 07:44:17 -1100 Subject: [PATCH 1956/3904] Zero value character --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e80635ba9..6e2c1b1b5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -809,9 +809,9 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - if ( P.gold < 0 || P.hitpoints < 0 || P.strength < 0 || P.level < 0 || P.experience < 0 || P.dungeonlevel < 0 ) + if ( P.gold <= 0 || P.hitpoints <= 0 || P.strength <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) { - fprintf(stderr,"was killed -> no playerdata\n"); + fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } else From 8ac5fd8e8e49f8c58f79639056eaaeb01f4ba163 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 07:45:31 -1100 Subject: [PATCH 1957/3904] Bailout --- src/cc/rogue/rogue.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 2d89cbc67..e6ae6bc8c 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -187,10 +187,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) void rogue_bailout() { - char cmd[32768],hexstr[32768]; int32_t i; - for (i=0; i> keystrokes.log",Gametxidstr); if ( system(cmd) != 0 ) fprintf(stderr,"error issuing (%s)\n",cmd); From 55a946be4bbc75ba56770a7717853d6e363d68dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 07:54:02 -1100 Subject: [PATCH 1958/3904] Regslot saved --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index e6ae6bc8c..0eca62c7f 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -188,7 +188,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) void rogue_bailout() { char cmd[512]; - sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr); + sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr); if ( system(cmd) != 0 ) fprintf(stderr,"error issuing (%s)\n",cmd); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6e2c1b1b5..a80ac3b79 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -169,22 +169,22 @@ CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std: return(opret); } -CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,CPubKey pk,std::vectorplayerdata) +CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata) { CScript opret; uint8_t evalcode = EVAL_ROGUE; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << pk << playerdata); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata); return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid,int32_t ®slot,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) { std::vector vopret,vopret2; uint8_t e,f; uint256 tokenid; std::vector voutPubkeys; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) return(f); else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) { return(f); } @@ -405,12 +405,12 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,gameheight,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { //GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); //script = (uint8_t *)vopret.data(); - if ( (f= rogue_highlanderopretdecode(gametxid,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(gametxid,regslot,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); //memcpy(&gametxid,script+2,sizeof(gametxid)); @@ -782,7 +782,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { if ( maxplayers == 1 ) mult /= 2; - if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 && keystrokes != 0 ) + if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 ) { UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); @@ -793,14 +793,16 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param for (i=0; ievalcode, 1, mypk)); if ( num > 0 ) { newdata.resize(num); @@ -816,6 +818,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else { + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); cashout = (uint64_t)P.gold * mult; if ( funcid == 'H' && maxplayers > 1 ) @@ -837,7 +840,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); - CScript opret = rogue_highlanderopret(funcid, gametxid, mypk, newdata); + CScript opret = rogue_highlanderopret(funcid, gametxid, regslot,mypk, newdata); if ( newdata.size() == 0 ) rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); else From f86c6a07e82a57ad0334df0c66360f2c7812e1d1 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sun, 10 Feb 2019 23:54:08 +0500 Subject: [PATCH 1959/3904] added token support in register tx --- src/cc/rogue_rpc.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0ba5bc6ae..9605d721e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -710,7 +710,13 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,rogue_registeropret(gametxid,playertxid)); + + std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; + DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2); + + CScript opretRegister = rogue_registeropret(gametxid, playertxid); + rawtx = FinalizeCCTx(0,cp,mtx,CPubKey()/*=null pubkey*/,txfee, + EncodeTokenOpRet(tokenid, voutPubkeysEmpty, vopretFinish /*=non-fungible*/, opretRegister)); return(rogue_rawtxresult(result,rawtx,1)); } else return(cclib_error(result,"invalid gametxid")); } else return(cclib_error(result,"no gametxid")); From 4c3e9226b63042d89f3442a21d723f248f0f3bee Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 11 Feb 2019 00:16:53 +0500 Subject: [PATCH 1960/3904] corrected for both token and no token vintx --- src/cc/rogue_rpc.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9605d721e..fe886e745 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -711,12 +711,18 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, mypk)); + std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; - DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2); - CScript opretRegister = rogue_registeropret(gametxid, playertxid); - rawtx = FinalizeCCTx(0,cp,mtx,CPubKey()/*=null pubkey*/,txfee, - EncodeTokenOpRet(tokenid, voutPubkeysEmpty, vopretFinish /*=non-fungible*/, opretRegister)); + if (DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) { // if token in the opret + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, + EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); + } + else { + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister); + } + return(rogue_rawtxresult(result,rawtx,1)); } else return(cclib_error(result,"invalid gametxid")); } else return(cclib_error(result,"no gametxid")); From 917501e7c027187fece95cca66e7b1c76b1b5e1b Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 11 Feb 2019 00:19:29 +0500 Subject: [PATCH 1961/3904] token vout changed to empty pk --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index fe886e745..d6eb540a8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -711,7 +711,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); - mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, mypk)); + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, CPubKey() /*nullpk*/)); std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; CScript opretRegister = rogue_registeropret(gametxid, playertxid); From 3483c0ac9ab77616960fc850e7b1fb96dcade2b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 08:28:43 -1100 Subject: [PATCH 1962/3904] Prevent restoring amulet --- src/cc/rogue/state.c | 76 ++++++++++++++++++++++++-------------------- src/cc/rogue_rpc.cpp | 5 ++- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index b47b83faf..dd54afe25 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1339,41 +1339,44 @@ rs_read_monsters(FILE *inf, struct monster *m, int count) void rogue_restoreobject(THING *o,struct rogue_packitem *item) { int32_t i; - o->_o._o_type = item->type; - o->_o._o_launch = item->launch; - memcpy(o->_o._o_damage,item->damage,sizeof(item->damage)); - memcpy(o->_o._o_hurldmg,item->hurldmg,sizeof(item->hurldmg)); - o->_o._o_count = item->count; - o->_o._o_which = item->which; - o->_o._o_hplus = item->hplus; - o->_o._o_dplus = item->dplus; - o->_o._o_arm = item->arm; - o->_o._o_flags = item->flags; - o->_o._o_group = item->group; - o->o_flags |= ISKNOW; - o->o_flags &= ~ISFOUND; - switch ( item->type ) + if ( item->type != AMULET ) { - case SCROLL: - if ( item->which < MAXSCROLLS ) - scr_info[item->which].oi_know = TRUE; - break; - case POTION: - if ( item->which < MAXPOTIONS ) - pot_info[item->which].oi_know = TRUE; - break; - case RING: - if ( item->which < MAXRINGS ) - ring_info[item->which].oi_know = TRUE; - break; - case STICK: - if ( item->which < MAXSTICKS ) - ws_info[item->which].oi_know = TRUE; - break; + o->_o._o_type = item->type; + o->_o._o_launch = item->launch; + memcpy(o->_o._o_damage,item->damage,sizeof(item->damage)); + memcpy(o->_o._o_hurldmg,item->hurldmg,sizeof(item->hurldmg)); + o->_o._o_count = item->count; + o->_o._o_which = item->which; + o->_o._o_hplus = item->hplus; + o->_o._o_dplus = item->dplus; + o->_o._o_arm = item->arm; + o->_o._o_flags = item->flags; + o->_o._o_group = item->group; + o->o_flags |= ISKNOW; + o->o_flags &= ~ISFOUND; + switch ( item->type ) + { + case SCROLL: + if ( item->which < MAXSCROLLS ) + scr_info[item->which].oi_know = TRUE; + break; + case POTION: + if ( item->which < MAXPOTIONS ) + pot_info[item->which].oi_know = TRUE; + break; + case RING: + if ( item->which < MAXRINGS ) + ring_info[item->which].oi_know = TRUE; + break; + case STICK: + if ( item->which < MAXSTICKS ) + ws_info[item->which].oi_know = TRUE; + break; + } + char packitemstr[256]; + strcpy(packitemstr,inv_name(o,FALSE)); + fprintf(stderr,"packitem.(%s)\n",packitemstr); } - char packitemstr[256]; - strcpy(packitemstr,inv_name(o,FALSE)); - fprintf(stderr,"packitem.(%s)\n",packitemstr); } void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) @@ -1440,7 +1443,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) } else { - if ( rs->P.packsize++ == 0 ) + if ( rs->P.packsize == 0 ) { rs->P.gold = purse; rs->P.hitpoints = max_hp; @@ -1451,8 +1454,11 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); - if ( rs->P.packsize < MAXPACK ) + if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) + { packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); + rs->P.packsize++; + } } } rs_write_marker(savef, RSID_OBJECT); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 988df05eb..66326b20d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -114,11 +114,10 @@ */ // todo: -// -detect playerdeath/quit to prevent illegal keystrokes vector +// make register a token burn +// convert playertxid to the original playertxid // verify keystrokes tx is in mempool and confirmed -// check that bailout is legal, ie. proper gametxid vin // verify amulet possession in pack -// -verify playerdata can be used and has same initial level //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & From a6d1adbc2336d12acba909514c80ed461b142f80 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 08:34:16 -1100 Subject: [PATCH 1963/3904] +print --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 0eca62c7f..f6bc9b727 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -579,7 +579,7 @@ quit(int sig) { struct rogue_state *rs = &globalR; int oy, ox; - fprintf(stderr,"inside quit(%d)\n",sig); + //fprintf(stderr,"inside quit(%d)\n",sig); if ( rs->guiflag != 0 ) { NOOP(sig); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 66326b20d..b0161180e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -129,7 +129,7 @@ // ./rogue gui -> creates keystroke files // cclib register 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22,%22f3a4a61cfa0dd43733b06d1368c199594258e0f3db983dc1b9b10768a5671909%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" -// cclib bailout 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22]\" +// ./c cclib bailout 17 \"[%226de8a1650bf696aaa515e38a858bd0f40eab8c02bcb75169b2cfe99b8a2ce1f0%22]\" #define MAXPACK 23 @@ -455,22 +455,22 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke matches++; regslot = i; matchtx = spenttx; - } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); - } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); - } //else fprintf(stderr,"%d+1 unspent\n",i); + } else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } else fprintf(stderr,"%d+1 unspent\n",i); } if ( matches == 1 ) { if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); + fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); while ( CCgettxout(txid,0,1) < 0 ) { spenttxid = zeroid; @@ -497,7 +497,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } } } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -791,6 +791,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { + fprintf(stderr,"validgame\n"); if ( maxplayers == 1 ) mult /= 2; if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 ) From 553e49207d30036b6cf888751b4e407b25d4f239 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 08:39:46 -1100 Subject: [PATCH 1964/3904] Set players --- src/cc/rogue_rpc.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b0161180e..847528e65 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -657,7 +657,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -692,18 +692,24 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); - mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, CPubKey() /*nullpk*/)); - std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; + std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; CScript opretRegister = rogue_registeropret(gametxid, playertxid); - if (DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) { // if token in the opret - rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, - EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); + if ( playertxid != zeroid ) + { + if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) + { + if ( DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) + { // if token in the opret + didtx = 1; + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, + EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); + } + } } - else { + if ( didtx == 0 ) rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister); - } return(rogue_rawtxresult(result,rawtx,1)); } else return(cclib_error(result,"invalid gametxid")); From ca500eb217f684d0d59c5e23cd1b2c469478e354 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 08:43:09 -1100 Subject: [PATCH 1965/3904] +print --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 847528e65..c07508e47 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -872,8 +872,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); - } - } + } else printf(stderr,"illegal game\n"); + } else printf(stderr,"n.%d\n",n); } return(result); } From fcbd4d53c051e1df2a319ede0298c9d04d5d02a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 08:43:39 -1100 Subject: [PATCH 1966/3904] fprintf --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c07508e47..36853e95c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -872,8 +872,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); - } else printf(stderr,"illegal game\n"); - } else printf(stderr,"n.%d\n",n); + } else fprintf(stderr,"illegal game\n"); + } else fprintf(stderr,"n.%d\n",n); } return(result); } From c8f901bfbf8b77a210995df6ff0d9109c396cc32 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 08:46:43 -1100 Subject: [PATCH 1967/3904] Err --- src/cc/rogue_rpc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 36853e95c..b8651a0f1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -657,7 +657,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -669,7 +669,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 0 ) { gametxid = juint256(jitem(params,0)); - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid)) == 0 ) { if ( n > 1 ) { @@ -770,7 +770,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -795,7 +795,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); - if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { fprintf(stderr,"validgame\n"); if ( maxplayers == 1 ) @@ -872,7 +872,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(rogue_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","success")); - } else fprintf(stderr,"illegal game\n"); + } else fprintf(stderr,"illegal game err.%d\n",err); } else fprintf(stderr,"n.%d\n",n); } return(result); From 280bc8b88c11202e3613eaea8879f6ef6853afa9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 08:56:24 -1100 Subject: [PATCH 1968/3904] Look at replay --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f6bc9b727..79b2c1956 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -220,7 +220,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; - rs->sleeptime = 0; + rs->sleeptime = 50000; if ( player != 0 ) { rs->P = *player; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b8651a0f1..446b3f224 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -129,7 +129,7 @@ // ./rogue gui -> creates keystroke files // cclib register 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22,%22f3a4a61cfa0dd43733b06d1368c199594258e0f3db983dc1b9b10768a5671909%22]\" // cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" -// ./c cclib bailout 17 \"[%226de8a1650bf696aaa515e38a858bd0f40eab8c02bcb75169b2cfe99b8a2ce1f0%22]\" +// ./c cclib bailout 17 \"[%228fd5b29b77ef90d7b7747c779530a8b005f7c236ea0ddb1fe68a392ea3b6cdf1%22]\" #define MAXPACK 23 @@ -318,7 +318,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) { gameheight = komodo_blockheight(hashBlock); - if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) >= txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { From e084210351e9a3788f3eca5e3cf1ab8d86d024c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:01:36 -1100 Subject: [PATCH 1969/3904] Test --- src/cc/rogue/io.c | 7 ++++--- src/cc/rogue/rogue.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 38252fafd..30795f2ad 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -164,9 +164,10 @@ readchar(struct rogue_state *rs) } fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); - if ( (rand() & 1) == 0 ) - return(ESCAPE); - else return('y'); + //if ( (rand() & 1) == 0 ) + // return(ESCAPE); + //else + return('y'); } if ( rs == 0 || rs->guiflag != 0 ) { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 79b2c1956..a0278f38a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -220,7 +220,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; - rs->sleeptime = 50000; + rs->sleeptime = 0*50000; if ( player != 0 ) { rs->P = *player; From 80a610cdaa53487f5a0d7effab8a87ec817bf1f1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:07:44 -1100 Subject: [PATCH 1970/3904] -score --- src/cc/rogue/rip.c | 8 +++++--- src/cc/rogue/rogue.c | 6 +++--- src/cc/rogue/rogue.h | 2 +- src/cc/rogue_rpc.cpp | 7 +++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index 56f2453a4..032cc1b6d 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -46,12 +46,14 @@ static char *rip[] = { /* VARARGS2 */ void -score(int amount, int flags, char monst) +score(struct rogue_state *rs,int amount, int flags, char monst) { SCORE *scp; int i; SCORE *sc2; SCORE *top_ten, *endp; + if ( rs->guiflag == 0 ) + return; # ifdef MASTER int prflags = 0; # endif @@ -274,7 +276,7 @@ death(struct rogue_state *rs,char monst) } move(LINES - 1, 0); refresh(); - score(purse, amulet ? 3 : 0, monst); + score(rs,purse, amulet ? 3 : 0, monst); rogue_bailout(); printf("[Press return to continue]"); fflush(stdout); @@ -390,7 +392,7 @@ total_winner(struct rogue_state *rs) } printw(" %5d Gold Pieces ", oldpurse); refresh(); - score(purse, 2, ' '); + score(rs,purse, 2, ' '); my_exit(0); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index a0278f38a..8db8cabca 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -384,7 +384,7 @@ int rogue(int argc, char **argv, char **envp) if (strcmp(argv[1], "-s") == 0) { noscore = TRUE; - score(0, -1, 0); + score(rs,0, -1, 0); exit(0); } else if (strcmp(argv[1], "-d") == 0) @@ -602,14 +602,14 @@ quit(int sig) move(LINES - 1, 0); if ( rs->sleeptime != 0 ) refresh(); - score(purse, 1, 0); + score(rs,purse, 1, 0); flushkeystrokes(rs); my_exit(0); } else { fprintf(stderr,"done!\n"); - score(purse, 1, 0); + score(rs,purse, 1, 0); } } else diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 6543976da..6e9a6600f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -698,7 +698,7 @@ int save(int which); void save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag); void save_game(struct rogue_state *rs); int save_throw(int which, THING *tp); -void score(int amount, int flags, char monst); +void score(struct rogue_state *rs,int amount, int flags, char monst); void search(struct rogue_state *rs); void set_know(THING *obj, struct obj_info *info); void set_oldch(THING *tp, coord *cp); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 446b3f224..fe898e363 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -464,13 +464,13 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); + //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); if ( rogue_registeropretdecode(txid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward playertxid.%s spenttxid.%s\n",playertxid.GetHex().c_str(),txid.GetHex().c_str()); while ( CCgettxout(txid,0,1) < 0 ) { spenttxid = zeroid; @@ -497,7 +497,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } } } - fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -797,7 +797,6 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("gametxid",gametxid.GetHex())); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { - fprintf(stderr,"validgame\n"); if ( maxplayers == 1 ) mult /= 2; if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 ) From cf3a8e6e9a2e89e8540fa0c8453c01bb86184c0b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:10:40 -1100 Subject: [PATCH 1971/3904] Skip bailout for replay --- src/cc/rogue/command.c | 3 ++- src/cc/rogue/rogue.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index a6cf50724..b2ce396ab 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -270,7 +270,8 @@ over: if ( rs->guiflag != 0 && rs->needflush == 0 ) rs->needflush = (uint32_t)time(NULL); q_comm = FALSE; - rogue_bailout(); + if ( rs->guiflag != 0 ) + rogue_bailout(); return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 8db8cabca..307baab5f 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -608,8 +608,8 @@ quit(int sig) } else { - fprintf(stderr,"done!\n"); score(rs,purse, 1, 0); + fprintf(stderr,"done!\n"); } } else From 505dc7520dd20e2bf78bf875053508294d38417f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:27:26 -1100 Subject: [PATCH 1972/3904] Change to myGetTransaction --- src/cc/CCtokens.cpp | 3 ++- src/cc/rogue_rpc.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index df1733173..3ee2be457 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -247,7 +247,8 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); - if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) + //if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) + if (myGetTransacton(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("illegal token vin0"); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index fe898e363..aa2920126 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -124,11 +124,12 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// cclib gameinfo 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22]\" -// cclib register 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22]\" +// ./c cclib gameinfo 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" +// cclib register 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" // ./rogue gui -> creates keystroke files -// cclib register 17 \"[%22a49f90d6b5a226132a8615c9b55b254629611565c69246ea58f7a02059b847bf%22,%22f3a4a61cfa0dd43733b06d1368c199594258e0f3db983dc1b9b10768a5671909%22]\" -// cclib keystrokes 17 \"[%220a4ecb345ca3090f4acad63f889c3668e46e245cb00ca4b8b57c4677b1ee95b2%22,%22deadbeef%22]\" +// ./c cclib register 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22,%226c88eb35f1f9eadabb0fb00c5b25b44cc60e99013ec9ce6871acd8ed7541de93%22]\" +// cclib keystrokes 17 \"[%22./c cclib gameinfo 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" +%22,%22deadbeef%22]\" // ./c cclib bailout 17 \"[%228fd5b29b77ef90d7b7747c779530a8b005f7c236ea0ddb1fe68a392ea3b6cdf1%22]\" From ee444194be91432f93e951186df40eae2797fed6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:28:36 -1100 Subject: [PATCH 1973/3904] -\ --- src/cc/rogue_rpc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index aa2920126..f685fdc64 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -128,8 +128,6 @@ // cclib register 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" // ./rogue gui -> creates keystroke files // ./c cclib register 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22,%226c88eb35f1f9eadabb0fb00c5b25b44cc60e99013ec9ce6871acd8ed7541de93%22]\" -// cclib keystrokes 17 \"[%22./c cclib gameinfo 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" -%22,%22deadbeef%22]\" // ./c cclib bailout 17 \"[%228fd5b29b77ef90d7b7747c779530a8b005f7c236ea0ddb1fe68a392ea3b6cdf1%22]\" From abec8d30fb47fbee2f899652abb6e8bbb1d90467 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:29:58 -1100 Subject: [PATCH 1974/3904] Test --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 3ee2be457..1318d8bc8 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -248,7 +248,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); //if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) - if (myGetTransacton(tokenid, createTx, hashBlock) == 0) + if (myGetTransaction(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("illegal token vin0"); From b488b0b270e494bde65c99e926a9e3b63469e6ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:33:20 -1100 Subject: [PATCH 1975/3904] +print --- src/cc/CCtokens.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 1318d8bc8..12f3f8d36 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -247,9 +247,12 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); - //if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) - if (myGetTransaction(tokenid, createTx, hashBlock) == 0) + if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) + //if (myGetTransaction(tokenid, createTx, hashBlock) == 0) + { + fprintf(stderr,"tokenid.%s\n",tokenid.GetHex()); return eval->Invalid("cant find token create txid"); + } else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("illegal token vin0"); else if (numvouts < 1) From 012e7cdf83585e59a695b481ff9142d95daf1c8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:37:43 -1100 Subject: [PATCH 1976/3904] 2 prints --- src/cc/CCtokens.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 12f3f8d36..326a8c6b1 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -250,7 +250,9 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) //if (myGetTransaction(tokenid, createTx, hashBlock) == 0) { - fprintf(stderr,"tokenid.%s\n",tokenid.GetHex()); + fprintf(stderr,"tokenid.%s\n",tokenid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s\n",tokenid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s\n",tokenid.GetHex().c_str()); return eval->Invalid("cant find token create txid"); } else if (IsCCInput(tx.vin[0].scriptSig) != 0) From 9d00a3f5a8c084cb5148adffb9dcdb2b47e05ea3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:43:19 -1100 Subject: [PATCH 1977/3904] -print --- src/cc/CCtokens.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 326a8c6b1..4e6906685 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -248,13 +248,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) - //if (myGetTransaction(tokenid, createTx, hashBlock) == 0) - { - fprintf(stderr,"tokenid.%s\n",tokenid.GetHex().c_str()); - fprintf(stderr,"tokenid.%s\n",tokenid.GetHex().c_str()); - fprintf(stderr,"tokenid.%s\n",tokenid.GetHex().c_str()); return eval->Invalid("cant find token create txid"); - } else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("illegal token vin0"); else if (numvouts < 1) From f5f11ea56d360d814ff0686346a9d7ec3d4e4cde Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:49:25 -1100 Subject: [PATCH 1978/3904] Set token --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f685fdc64..351304956 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -697,6 +697,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { + tokenid = playertxid; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { if ( DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) From 88eb8db62e926fd86aa909382275ea2b7583e03d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 09:51:18 -1100 Subject: [PATCH 1979/3904] Set tokenid in right place --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 351304956..7903d2929 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -697,12 +697,12 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { - tokenid = playertxid; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { if ( DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) { // if token in the opret didtx = 1; + tokenid = playertxid; rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); } From 365c053dc5e1569039e13896d586e748f1952865 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:02:52 -1100 Subject: [PATCH 1980/3904] Guard tokenid setting --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7903d2929..43754edd4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -702,7 +702,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) { // if token in the opret didtx = 1; - tokenid = playertxid; + if ( tokenid == zeroid ) + tokenid = playertxid; rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); } From 68e95fde75febe68cd175686ff5901508cff1fd2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:05:55 -1100 Subject: [PATCH 1981/3904] Remove check for normal input --- src/cc/CCtokens.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 4e6906685..c434b34fe 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -249,8 +249,8 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); - else if (IsCCInput(tx.vin[0].scriptSig) != 0) - return eval->Invalid("illegal token vin0"); + //else if (IsCCInput(tx.vin[0].scriptSig) != 0) + // return eval->Invalid("illegal token vin0"); else if (numvouts < 1) return eval->Invalid("no vouts"); else if (funcid != 'c') From 986fabaa3adbb9f3bc3cc1a0fff422aa1cb68c0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:09:26 -1100 Subject: [PATCH 1982/3904] +print --- src/cc/CCtokens.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index c434b34fe..ce9d1f9b5 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -630,6 +630,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu if (inputs != outputs) { if (tx.GetHash() != reftokenid) LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl); + fprintf(stderr,"inputs %.8f vs outputs %.8f\n",(long long)inputs,(long long)outputs); return false; // do not call eval->Invalid() here! } else From 2c30681b73a03842e02ff8ca1a0511e17fe5d359 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:11:28 -1100 Subject: [PATCH 1983/3904] Flu --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index ce9d1f9b5..c6f493026 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -630,7 +630,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu if (inputs != outputs) { if (tx.GetHash() != reftokenid) LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl); - fprintf(stderr,"inputs %.8f vs outputs %.8f\n",(long long)inputs,(long long)outputs); + fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); return false; // do not call eval->Invalid() here! } else From b083d687d6f07a13f11256669528884d436a4cec Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:17:13 -1100 Subject: [PATCH 1984/3904] Test sending to self --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 43754edd4..3d17080b5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -691,7 +691,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); - mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, CPubKey() /*nullpk*/)); + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, mypk));//CPubKey() /*nullpk*/)); std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; CScript opretRegister = rogue_registeropret(gametxid, playertxid); From 197ae4c0e9b43adc62682aa048965a7be7149159 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:19:54 -1100 Subject: [PATCH 1985/3904] voutpubkeysempty --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3d17080b5..1e52b8aa1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -697,6 +697,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { + voutPubkeysEmpty.push_back(mypk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { if ( DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) From 3795785a381299d69c218a018ae14d4effd71cd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:37:55 -1100 Subject: [PATCH 1986/3904] -print --- src/cc/CCinclude.h | 2 +- src/cc/CCtokens.cpp | 2 +- src/cc/rogue_rpc.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 70069cad8..57f42f064 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -52,7 +52,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../utlist.h" #include "../uthash.h" - +#define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" #define CC_MAXVINS 1024 #define SMALLVAL 0.000000000000001 diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index c6f493026..fedc78151 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -630,7 +630,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu if (inputs != outputs) { if (tx.GetHash() != reftokenid) LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "TokenExactAmounts() found unequal token cc inputs=" << inputs << " vs cc outputs=" << outputs << " for txid=" << tx.GetHash().GetHex() << " and this is not the create tx" << std::endl); - fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); + //fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); return false; // do not call eval->Invalid() here! } else diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1e52b8aa1..f4a57dede 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -656,10 +656,11 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); + burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY)); roguepk = GetUnspendable(cp,0); rogue_univalue(result,"register",-1,-1); playertxid = zeroid; @@ -691,13 +692,13 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); - mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, mypk));//CPubKey() /*nullpk*/)); + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { - voutPubkeysEmpty.push_back(mypk); + voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { if ( DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) From 296cc4a243ec3b4d24ed5a0a0c200e76ff34a26f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:56:04 -1100 Subject: [PATCH 1987/3904] obj.push_back(Pair("baton",batontxid.ToString())); --- src/cc/rogue_rpc.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f4a57dede..3aa27fe42 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -201,14 +201,22 @@ uint8_t rogue_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey return(0); } -uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &playertxid,CScript scriptPubKey) +uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &playertxid,CScript scriptPubKey) { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); + tokenid = zeroid; if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) { return(f); } + else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) + { + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R') ) + { + return(f); + } + } return(0); } @@ -438,7 +446,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) { - int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = numplayers = 0; playertxid = zeroid; for (i=0; i playerdata; char destaddr[64]; + uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { @@ -541,12 +551,13 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 1 ) { - if ( rogue_registeropretdecode(gtxid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && gtxid == gametxid && ptxid == playertxid ) + if ( rogue_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && gtxid == gametxid && ptxid == playertxid ) obj.push_back(Pair("status","registered")); else obj.push_back(Pair("status","alive")); } else obj.push_back(Pair("status","error")); } else obj.push_back(Pair("status","finished")); obj.push_back(Pair("baton",batontxid.ToString())); + obj.push_back(Pair("tokenid",tokenid.ToString())); obj.push_back(Pair("batonaddr",destaddr)); obj.push_back(Pair("ismine",strcmp(myrogueaddr,destaddr)==0)); obj.push_back(Pair("batonvout",(int64_t)batonvout)); From 2c02d35fb119d8cdb09ec6354166713d510f4b46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 10:57:52 -1100 Subject: [PATCH 1988/3904] std::vector voutPubkeys; --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3aa27fe42..7015d52b1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -203,7 +203,7 @@ uint8_t rogue_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &playertxid,CScript scriptPubKey) { - std::vector vopret; uint8_t e,f; + std::vector vopret,vopret2; uint8_t e,f; std::vector voutPubkeys; GetOpReturnData(scriptPubKey,vopret); tokenid = zeroid; if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) From 5ec161a477ed370f217e6ea5597398c1b6dfdbab Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:01:37 -1100 Subject: [PATCH 1989/3904] Test --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7015d52b1..06fd2ed15 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -212,6 +212,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl } else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { + fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R') ) { return(f); From d76a5c448a3b9465f77d8a460615be987d878b69 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:02:36 -1100 Subject: [PATCH 1990/3904] -) --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 06fd2ed15..e78132934 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -213,7 +213,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) { return(f); } From ce7900940563cfde7631971895ecb8b842b7f1ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:04:41 -1100 Subject: [PATCH 1991/3904] +priont --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e78132934..57fbf0db1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -217,6 +217,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl { return(f); } + fprintf(stderr,"e.%d vs %d, f %c, gametxid.%s player.%s\n",e,EVAL_ROGUE,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); } return(0); } From a9a9a9723a1897b09e68606f07cdad87387c80d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:14:42 -1100 Subject: [PATCH 1992/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 57fbf0db1..f86897f04 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -473,7 +473,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matches.%d numvouts.%d\n",matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex(),c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( tokenid != zeroid ) From 5cad17c68b2dd2c98d14512cc72204316d3bfaff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:15:25 -1100 Subject: [PATCH 1993/3904] . --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f86897f04..2cf292bf4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -473,7 +473,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex(),c_str(),matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( tokenid != zeroid ) From 5ae21d9b1f06db4abbd05f3ef6e629e03bc0e00e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:29:43 -1100 Subject: [PATCH 1994/3904] Test --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2cf292bf4..3a3885250 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -711,6 +711,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { + fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { @@ -727,7 +728,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( didtx == 0 ) rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister); - return(rogue_rawtxresult(result,rawtx,1)); + return(rogue_rawtxresult(result,rawtx,0)); } else return(cclib_error(result,"invalid gametxid")); } else return(cclib_error(result,"no gametxid")); } else return(cclib_error(result,"couldnt reparse params")); From 6ccee6c03624def16dd9949b41e4b200d917d112 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:33:50 -1100 Subject: [PATCH 1995/3904] Test --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3a3885250..6016201f5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -156,6 +156,7 @@ CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) CScript rogue_registeropret(uint256 gametxid,uint256 playertxid) { CScript opret; uint8_t evalcode = EVAL_ROGUE; + fprintf(stderr,"opret.(%s %s).R\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'R' << gametxid << playertxid); return(opret); } @@ -692,6 +693,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); + CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) return(cclib_error(result,"already registered")); if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) @@ -708,7 +710,6 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; - CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); From 79ce5721dd651d05ca709e21f46c93ecf881f50d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:42:26 -1100 Subject: [PATCH 1996/3904] Test --- src/cc/rogue_rpc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6016201f5..a9dccc911 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -156,7 +156,7 @@ CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) CScript rogue_registeropret(uint256 gametxid,uint256 playertxid) { CScript opret; uint8_t evalcode = EVAL_ROGUE; - fprintf(stderr,"opret.(%s %s).R\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"opret.(%s %s).R\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'R' << gametxid << playertxid); return(opret); } @@ -214,7 +214,8 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) + playertxid = tokenid; + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && (f == 'Q' || f == 'R') ) { return(f); } @@ -693,7 +694,6 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); - CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) return(cclib_error(result,"already registered")); if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) @@ -710,6 +710,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; + CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); @@ -721,6 +722,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) didtx = 1; if ( tokenid == zeroid ) tokenid = playertxid; + vopretFinish.resize(0); rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); } From d4015ad408af3ae508f051ab9971de02bea74cbc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:48:28 -1100 Subject: [PATCH 1997/3904] Qr --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a9dccc911..d5fe86b1d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -709,7 +709,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); - std::vector vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; + std::vector vopretFinish, vopret2; uint8_t e, funcid; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { @@ -717,10 +717,10 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { - if ( DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) + if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2)) != 0) { // if token in the opret didtx = 1; - if ( tokenid == zeroid ) + if ( funcid == 'c' ) tokenid = playertxid; vopretFinish.resize(0); rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, From 6e131475ba8fc91d72a8177840374e52aad17c07 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:51:50 -1100 Subject: [PATCH 1998/3904] Test --- src/cc/rogue_rpc.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d5fe86b1d..06ec8ff59 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -214,12 +214,13 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); - playertxid = tokenid; - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && (f == 'Q' || f == 'R') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) { return(f); } + playertxid = tokenid; fprintf(stderr,"e.%d vs %d, f %c, gametxid.%s player.%s\n",e,EVAL_ROGUE,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + return('R'); } return(0); } @@ -466,16 +467,16 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke matches++; regslot = i; matchtx = spenttx; - } else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); - } else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); - } else fprintf(stderr,"%d+1 unspent\n",i); + } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"%d+1 unspent\n",i); } if ( matches == 1 ) { if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( tokenid != zeroid ) From 55ef02f69cbee7864c608fd66fc28479fb74642f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 11:54:47 -1100 Subject: [PATCH 1999/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 06ec8ff59..e348c7d6e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -477,7 +477,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke { numvouts = matchtx.vout.size(); //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); - if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) + if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { if ( tokenid != zeroid ) playertxid = tokenid; From bff1e7162b77318a3079642d0628db3abe717bd5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 12:00:42 -1100 Subject: [PATCH 2000/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e348c7d6e..f4ba31ee9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -556,7 +556,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 1 ) { - if ( rogue_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && gtxid == gametxid && ptxid == playertxid ) + if ( rogue_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid )//&& gtxid == gametxid ) obj.push_back(Pair("status","registered")); else obj.push_back(Pair("status","alive")); } else obj.push_back(Pair("status","error")); From 937aaea32b280d6b40b06ae4649d446dc26458e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 12:16:11 -1100 Subject: [PATCH 2001/3904] Add back nonfungible data --- src/cc/rogue_rpc.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f4ba31ee9..3e75fbbe5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -124,11 +124,11 @@ // cclib newgame 17 \"[3,10]\" // cclib pending 17 -// ./c cclib gameinfo 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" +// ./c cclib gameinfo 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22]\" // cclib register 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" // ./rogue gui -> creates keystroke files -// ./c cclib register 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22,%226c88eb35f1f9eadabb0fb00c5b25b44cc60e99013ec9ce6871acd8ed7541de93%22]\" -// ./c cclib bailout 17 \"[%228fd5b29b77ef90d7b7747c779530a8b005f7c236ea0ddb1fe68a392ea3b6cdf1%22]\" +// ./c cclib register 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22,%222475182f9d5169d8a3249d17640e4eccd90f4ee43ab04791129b0fa3f177b14a%22]\" +// ./c cclib bailout 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" #define MAXPACK 23 @@ -213,14 +213,14 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl } else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { - fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); + //fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) { return(f); } playertxid = tokenid; fprintf(stderr,"e.%d vs %d, f %c, gametxid.%s player.%s\n",e,EVAL_ROGUE,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); - return('R'); + return(0); } return(0); } @@ -423,11 +423,10 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub //script = (uint8_t *)vopret.data(); if ( (f= rogue_highlanderopretdecode(gametxid,regslot,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { - fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); //memcpy(&gametxid,script+2,sizeof(gametxid)); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used @@ -477,7 +476,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke { numvouts = matchtx.vout.size(); //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); - if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) + if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) { if ( tokenid != zeroid ) playertxid = tokenid; @@ -556,7 +555,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet { if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 1 ) { - if ( rogue_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid )//&& gtxid == gametxid ) + if ( rogue_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) obj.push_back(Pair("status","registered")); else obj.push_back(Pair("status","alive")); } else obj.push_back(Pair("status","error")); @@ -714,7 +713,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { - fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); + //fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { @@ -723,7 +722,6 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) didtx = 1; if ( funcid == 'c' ) tokenid = playertxid; - vopretFinish.resize(0); rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); } From a515539d8499e477be187fc1174d6f2f49b16f60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 12:18:04 -1100 Subject: [PATCH 2002/3904] Vopret2 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3e75fbbe5..ead68eb73 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -214,7 +214,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) { //fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) + if ( vopret2.size() > 2 && E_UNMARSHAL(vopret2,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) { return(f); } From 7fbf26c93ed9d95f01f83be0e6b1a28bc6b7caab Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 12:29:27 -1100 Subject: [PATCH 2003/3904] Auto broadcast tx --- src/cc/rogue_rpc.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ead68eb73..be4435056 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -114,10 +114,8 @@ */ // todo: -// make register a token burn // convert playertxid to the original playertxid // verify keystrokes tx is in mempool and confirmed -// verify amulet possession in pack //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -730,7 +728,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( didtx == 0 ) rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister); - return(rogue_rawtxresult(result,rawtx,0)); + return(rogue_rawtxresult(result,rawtx,1)); } else return(cclib_error(result,"invalid gametxid")); } else return(cclib_error(result,"no gametxid")); } else return(cclib_error(result,"couldnt reparse params")); @@ -887,7 +885,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetOpReturnData(opret, vopretNonfungible); rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string(seedstr), gametxid.GetHex(), vopretNonfungible)); } - return(rogue_rawtxresult(result,rawtx,0)); + return(rogue_rawtxresult(result,rawtx,1)); } result.push_back(Pair("result","success")); } else fprintf(stderr,"illegal game err.%d\n",err); From fdaca7e5e5d4929f2144447153e1a19591aa3032 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 19:28:32 -1100 Subject: [PATCH 2004/3904] Auto bailout --- src/cc/cclib.cpp | 4 ---- src/cc/rogue/command.c | 2 +- src/cc/rogue/extern.h | 1 - src/cc/rogue/rip.c | 2 +- src/cc/rogue/rogue.c | 30 ++++++++++++++++++------------ src/cc/rogue/rogue.h | 1 + src/cc/rogue_rpc.cpp | 10 +++++++--- 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index ea39bbc41..441b43ccf 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -75,10 +75,6 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #ifdef BUILD_ROGUE int32_t rogue_replay(uint64_t seed,int32_t sleeptime); -bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) -{ - return(true); -} UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index b2ce396ab..e78e6b055 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -271,7 +271,7 @@ over: rs->needflush = (uint32_t)time(NULL); q_comm = FALSE; if ( rs->guiflag != 0 ) - rogue_bailout(); + rogue_bailout(rs); return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 0791702d6..486d85ff1 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -184,7 +184,6 @@ void md_onsignal_default(void); int md_issymlink(char *sp); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); -void rogue_bailout(void); #endif diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index 032cc1b6d..a5b3e7208 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -277,7 +277,7 @@ death(struct rogue_state *rs,char monst) move(LINES - 1, 0); refresh(); score(rs,purse, amulet ? 3 : 0, monst); - rogue_bailout(); + rogue_bailout(rs); printf("[Press return to continue]"); fflush(stdout); if ( fgets(prbuf,10,stdin) != 0 ) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 307baab5f..305ae2b64 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -185,14 +185,6 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) return(retval); } -void rogue_bailout() -{ - char cmd[512]; - sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); -} - void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) { char cmd[32768],hexstr[32768]; int32_t i; @@ -206,13 +198,27 @@ void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) int32_t flushkeystrokes(struct rogue_state *rs) { - rogue_progress(rs->seed,rs->buffered,rs->num); - memset(rs->buffered,0,sizeof(rs->buffered)); - rs->counter++; - rs->num = 0; + if ( rs->num > 0 ) + { + rogue_progress(rs->seed,rs->buffered,rs->num); + memset(rs->buffered,0,sizeof(rs->buffered)); + rs->counter++; + rs->num = 0; + } return(0); } +void rogue_bailout(struct rogue_state *rs) +{ + char cmd[512]; + flushkeystrokes(rs); + sleep(5); + fprintf(stderr,"bailing out\n"); + sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); +} + int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player) { struct rogue_state *rs; FILE *fp; int32_t i; diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 6e9a6600f..5eccb2e8c 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -359,6 +359,7 @@ int32_t flushkeystrokes(struct rogue_state *rs); int32_t rogue_restorepack(struct rogue_state *rs); void restore_player(struct rogue_state *rs); int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); +void rogue_bailout(struct rogue_state *rs); /* * Help list diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index be4435056..9c7504e5f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -126,7 +126,7 @@ // cclib register 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" // ./rogue gui -> creates keystroke files // ./c cclib register 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22,%222475182f9d5169d8a3249d17640e4eccd90f4ee43ab04791129b0fa3f177b14a%22]\" -// ./c cclib bailout 17 \"[%22aa81321d8889f881fe3d7c68c905b7447d9143832b0abbef6c2cab49dff8b0cc%22]\" +// ./c cclib bailout 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22]\" #define MAXPACK 23 @@ -868,8 +868,6 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } } - //for (i=0; i_o._o_type,o->_o._o_packch,o->_o._o_packch); } mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); Myprivkey(mypriv); @@ -995,3 +993,9 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("numplayerdata",a.size())); return(result); } + +bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + return(true); +} + From c888efeef541011833a29cdf2b576f98f896ef62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Feb 2019 19:43:43 -1100 Subject: [PATCH 2005/3904] bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 441b43ccf..04ad7a66d 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -74,6 +74,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para #ifdef BUILD_ROGUE int32_t rogue_replay(uint64_t seed,int32_t sleeptime); +bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); From d69be73aece5cbc5021186ead88559e665372cdb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 11 Feb 2019 17:25:51 +0800 Subject: [PATCH 2006/3904] Change eras activation code. Fix reindex with ac_notarypay! --- src/init.cpp | 2 ++ src/notaries_staked.cpp | 72 +++++++++-------------------------------- 2 files changed, 18 insertions(+), 56 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 6aca3ce1b..ea8286cd0 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1554,6 +1554,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (fReindex) { + boost::filesystem::remove(GetDataDir() / "komodostate"); + boost::filesystem::remove(GetDataDir() / "signedmasks"); pblocktree->WriteReindexing(true); //If we're reindexing in prune mode, wipe away unusable block files and all undo data files if (fPruneMode) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 6e6912256..422d0da18 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -70,8 +70,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int i; int8_t retval = 0; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; + static uint8_t staked_pubkeys[NUM_STAKED_ERAS][64][33],didinit[NUM_STAKED_ERAS]; static char ChainName[65]; if ( ChainName[0] == 0 ) @@ -82,65 +81,26 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { strcpy(ChainName,ASSETCHAINS_SYMBOL); } - if ( era != 0 ) { - switch (era) { - case 1: - if ( didstaked1 == 0 ) - { - for (i=0; i Date: Mon, 11 Feb 2019 19:52:17 +0800 Subject: [PATCH 2007/3904] fix error --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 70696d4f5..c6bf320a2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5092,8 +5092,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numUtxos = utxoInputs.size(); size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); - fprintf(stderr, "num utxos.%li\n", numUtxos); - if (numUtxos < 2 && numNotes == 0) { + //fprintf(stderr, "num utxos.%li\n", numUtxos); + if (numUtxos < 1 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From d7f1ab8365df292153c133d826d825a3af18dfff Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 01:33:02 -1100 Subject: [PATCH 2008/3904] Remove flush from bailout --- src/cc/rogue/rogue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 305ae2b64..f5003c78a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -211,8 +211,8 @@ int32_t flushkeystrokes(struct rogue_state *rs) void rogue_bailout(struct rogue_state *rs) { char cmd[512]; - flushkeystrokes(rs); - sleep(5); + //flushkeystrokes(rs); + //sleep(5); fprintf(stderr,"bailing out\n"); sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr); if ( system(cmd) != 0 ) From 7a05f1eef3d0482651e23e65505087f5a4d9bb3c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 01:49:56 -1100 Subject: [PATCH 2009/3904] Disable auto bailout --- src/cc/rogue/rogue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f5003c78a..e82b514e0 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -213,6 +213,7 @@ void rogue_bailout(struct rogue_state *rs) char cmd[512]; //flushkeystrokes(rs); //sleep(5); + return; fprintf(stderr,"bailing out\n"); sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr); if ( system(cmd) != 0 ) From e8b79633567ab84bb35540d46947afcf536702f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 02:30:21 -1100 Subject: [PATCH 2010/3904] SEC and MGNX exemption --- src/cc/assets.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 2433473b9..8d133701c 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -145,6 +145,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti numvouts = tx.vout.size(); outputs = inputs = 0; preventCCvins = preventCCvouts = -1; + + // add specific chains exceptions for old token support: + if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) + return true; + + if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) + return true; if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); From e583658d144ae7b1fdcb9a64477f5760b169c860 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 11 Feb 2019 19:04:52 +0500 Subject: [PATCH 2011/3904] removed non-fungible data from 't' opret added fieldId for non-fungible data in 'c' opret changed to cc marker int tokencreate, added in rogue_finishgame (tokenlist supports old and new markers) --- src/cc/CCassets.h | 2 +- src/cc/CCassetsCore.cpp | 44 ++------- src/cc/CCassetstx.cpp | 24 ++--- src/cc/CCinclude.h | 17 ++-- src/cc/CCtokens.cpp | 214 +++++++++++++++++++++++----------------- src/cc/CCtokens.h | 7 -- src/cc/assets.cpp | 2 +- src/cc/rogue_rpc.cpp | 35 +++++-- 8 files changed, 180 insertions(+), 165 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index c4623ccbb..82fbcb961 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -30,7 +30,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx // CCassetsCore CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); -uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey, std::vector &vopretNonfungible); +uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index fa8b1df71..62d57e71c 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -279,9 +279,8 @@ bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &o return(0); } */ -uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey, std::vector &vopretNonfungible) +uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) { - std::vector vopret1, vopret2; std::vector vopretAssets; //, vopretAssetsStripped; uint8_t *script, funcId = 0, assetsFuncId = 0, dummyEvalCode, dummyAssetFuncId; uint256 dummyTokenid; @@ -294,30 +293,9 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo assetsFuncId = 0; // First - decode token opret: - funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, vopret1, vopret2); + funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, vopretAssets); LOGSTREAM((char *)"ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl); - if (!vopret2.empty()) { - // if there are both oprets then order is like this: - vopretNonfungible = vopret1; - vopretAssets = vopret2; - } - else { - // if only one opret - it is assets opret: - vopretNonfungible.clear(); - vopretAssets = vopret1; - } - - - /*GetOpReturnData(scriptPubKey, vopret); - script = (uint8_t *)vopret.data(); - if (script == 0) { - std::cerr << "DecodeAssetOpRet() script is empty" << std::endl; - return (uint8_t)0; - }*/ - //bool isEof = true; // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! - //bool result = E_UNMARSHAL(vopret, ss >> evalCodeInOpret; ss >> funcId; ss >> tokenid; ss >> assetFuncId; isEof = ss.eof()); - if (funcId == 0 || vopretAssets.size() < 2) { LOGSTREAM((char *)"ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() incorrect opret or no asset's payload" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << std::endl); return (uint8_t)0; @@ -363,13 +341,12 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo } break; default: - LOGSTREAM((char *)"ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() illegal assetFuncId=" << (int)funcId << std::endl); break; } } } - LOGSTREAM((char *)"ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() no asset's payload or incorrect assets evalcode" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << " assetsEvalCode=" << assetsEvalCode << " assetsFuncId=" << assetsFuncId << std::endl); + LOGSTREAM((char *)"ccassets", CCLOG_INFO, stream << "DecodeAssetTokenOpRet() no asset's payload or incorrect assets funcId or evalcode" << " funcId=" << (int)funcId << " vopretAssets.size()=" << vopretAssets.size() << " assetsEvalCode=" << assetsEvalCode << " assetsFuncId=" << assetsFuncId << std::endl); return (uint8_t)0; } @@ -378,9 +355,8 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT { uint256 assetid,assetid2; uint8_t evalCode; - std::vector vopretNonfungibleDummy; - if ( tx.vout.size() > 0 && DecodeAssetTokenOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey, vopretNonfungibleDummy) != 0 ) + if ( tx.vout.size() > 0 && DecodeAssetTokenOpRet(tx.vout[tx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey) != 0 ) return(true); else return(false); @@ -396,10 +372,9 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp, char *origCCaddr, char *origN std::vector origpubkey; CScript script; uint8_t evalCode; - std::vector vopretNonfungibleDummy; n = vintx.vout.size(); - if( n == 0 || (vintxFuncId = DecodeAssetTokenOpRet(vintx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey, vopretNonfungibleDummy)) == 0 ) + if( n == 0 || (vintxFuncId = DecodeAssetTokenOpRet(vintx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) == 0 ) return(false); bool bGetCCaddr = false; @@ -444,9 +419,8 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *origCCadd int64_t tmpprice; std::vector tmporigpubkey; uint8_t evalCode; - std::vector vopretNonfungibleDummy; - funcid = DecodeAssetTokenOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey, vopretNonfungibleDummy); + funcid = DecodeAssetTokenOpRet(tx.vout[tx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey); } if( tx.vin.size() < 2 ) @@ -495,7 +469,6 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *origCCadd int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid) { CTransaction vinTx; int64_t nValue; uint256 assetid,assetid2; uint8_t funcid, evalCode; - std::vector vopretNonfungibleDummy; CCaddr[0] = origaddr[0] = 0; @@ -504,7 +477,7 @@ int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmppr return(0); else if ( vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) return eval->Invalid("invalid normal vout0 for buyvin"); - else if ((funcid = DecodeAssetTokenOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey, vopretNonfungibleDummy)) == 'b' && + else if ((funcid = DecodeAssetTokenOpRet(vinTx.vout[vinTx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, tmpprice, tmporigpubkey)) == 'b' && vinTx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) // marker is only in 'b'? return eval->Invalid("invalid normal vout1 for buyvin"); else @@ -539,12 +512,11 @@ bool ValidateAssetOpret(CTransaction tx, int32_t v, uint256 assetid, int64_t &pr uint256 assetidOpret, assetidOpret2; uint8_t funcid, evalCode; - std::vector vopretNonfungibleDummy; // this is just for log messages indentation fur debugging recursive calls: int32_t n = tx.vout.size(); - if ((funcid = DecodeAssetTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey, vopretNonfungibleDummy)) == 0) + if ((funcid = DecodeAssetTokenOpRet(tx.vout[n - 1].scriptPubKey, evalCode, assetidOpret, assetidOpret2, price, origpubkey)) == 0) { std::cerr << "ValidateAssetOpret() DecodeAssetTokenOpRet returned funcId=0 for opret from txid=" << tx.GetHash().GetHex() << std::endl; return(false); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 79a8fb77a..7673724f1 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -76,18 +76,17 @@ UniValue AssetOrders(uint256 refassetid) uint256 txid, hashBlock, assetid, assetid2; int64_t price; std::vector origpubkey; - std::vector vopretNonfungible; CTransaction vintx; uint8_t funcid, evalCode; char numstr[32], funcidstr[16], origaddr[64], assetidstr[65]; txid = it->first.txhash; //std::cerr << "addOrders() txid=" << txid.GetHex() << std::endl; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( GetTransaction(txid, vintx, hashBlock, false) != 0 ) { // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); //std::cerr << "addOrders() vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl; - if (vintx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey, vopretNonfungible)) != 0) + if (vintx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) { if (refassetid != zero && assetid != refassetid) { @@ -402,7 +401,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p voutTokenPubkeys.push_back(unspendableAssetsPubkey); return FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, + EncodeTokenOpRet(assetid, voutTokenPubkeys, EncodeAssetOpRet('s', zeroid, pricetotal, Mypubkey()))); } else { @@ -506,11 +505,12 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) { std::vector vopretNonfungible; + GetNonfungibleData(assetid, vopretNonfungible); bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets - if((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey, vopretNonfungible))!=0) + if((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) { if (funcid == 's') mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' else if (funcid=='S') mtx.vin.push_back(CTxIn(bidtxid, 3, CScript())); // spend marker if funcid='B' @@ -522,8 +522,8 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) std::vector voutTokenPubkeys; // should be empty, no token vouts return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, - EncodeAssetOpRet('o', zeroid, 0, Mypubkey())))); + EncodeTokenOpRet(assetid, voutTokenPubkeys, + EncodeAssetOpRet('o', zeroid, 0, Mypubkey())))); } } return(""); @@ -555,10 +555,12 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) { std::vector vopretNonfungible; + GetNonfungibleData(assetid, vopretNonfungible); + askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); - if ((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey, vopretNonfungible))!=0) + if ((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) { if (funcid == 's') mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' @@ -588,7 +590,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) CCaddr2set(cpAssets, EVAL_TOKENS, unspendableAssetsPk, unspendableAssetsPrivkey, unspendableAssetsAddr); return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, + EncodeTokenOpRet(assetid, voutTokenPubkeys, EncodeAssetOpRet('x', zeroid, 0, Mypubkey())))); } } @@ -675,7 +677,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f voutTokenPubkeys.push_back(pubkey2pk(origpubkey)); return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, + EncodeTokenOpRet(assetid, voutTokenPubkeys, EncodeAssetOpRet('B', zeroid, remaining_required, origpubkey)))); } else return("dont have any assets to fill bid"); } @@ -800,7 +802,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a cpAssets->additionalTokensEvalcode2 = additionalTokensEvalcode2; return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, - EncodeTokenOpRet(assetid, voutTokenPubkeys, vopretNonfungible, + EncodeTokenOpRet(assetid, voutTokenPubkeys, EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid2, remaining_nValue, origpubkey)))); } else { CCerror = strprintf("filltx not enough utxos"); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 57f42f064..6018114a0 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -67,6 +67,12 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../komodo_cJSON.h" +// opret data block ids: + enum { + OPRETID_NONFUNGIBLEDATA = 0x11 + // TODO: OPRETID_ASSETSDATA = 0x12 +}; + struct CC_utxo { uint256 txid; @@ -173,11 +179,10 @@ bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector vopretNonfungible); CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload); //old version CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload); -CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector vpayloadNonfungible, CScript payload); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); -uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector &vopretNonfungible); -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra); -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2); +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector &vopretNonfungible); +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra); +void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible); uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t *data,int32_t offset,int32_t datalen); @@ -186,7 +191,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t // CCcustom CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2); +//uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2); // CCutils bool priv2addr(char *coinaddr,uint8_t buf33[33],uint8_t priv32[32]); @@ -262,7 +267,7 @@ UniValue ValueFromAmount(const CAmount& amount); #define CCLOG_DEBUG2 2 #define CCLOG_DEBUG3 3 template -inline void CCLogPrintStream(char *category, int level, T print_to_stream) +inline void CCLogPrintStream(const char *category, int level, T print_to_stream) { std::ostringstream stream; print_to_stream(stream); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index fedc78151..f5eda7d31 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -50,18 +50,15 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, funcid = 'c'; // override the param opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description; \ - if(!vopretNonfungible.empty()) ss << vopretNonfungible ); + if (!vopretNonfungible.empty()) { \ + ss << (uint8_t)OPRETID_NONFUNGIBLEDATA; \ + ss << vopretNonfungible; \ + }); return(opret); } -// this is for other contracts which use tokens and build customized extra payloads to token's opret: -CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload) -{ - std::vector vpayloadNonfungibleEmpty; - return EncodeTokenOpRet(tokenid, voutPubkeys, vpayloadNonfungibleEmpty, payload); -} -CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector vpayloadNonfungible, CScript payload) +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload) { CScript opret; uint8_t tokenFuncId = 't'; @@ -73,7 +70,7 @@ CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std: if (voutPubkeys.size() >= 0 && voutPubkeys.size() <= 2) ccType = voutPubkeys.size(); else { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); } std::vector vpayload; @@ -82,10 +79,11 @@ CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std: opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ if (ccType >= 1) ss << voutPubkeys[0]; \ if (ccType == 2) ss << voutPubkeys[1]; \ - if (vpayloadNonfungible.size() > 0) ss << vpayloadNonfungible; \ if (vpayload.size() > 0) ss << vpayload); - // "error 64: scriptpubkey": + // bad opret cases (retries to attach payload without re-serialization): + + // "error 64: scriptpubkey": // if (payload.size() > 0) // opret += payload; @@ -93,8 +91,7 @@ CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std: // CScript opretPayloadNoOpcode(vpayload); // return opret + opretPayloadNoOpcode; - // how to attach payload without re-serialization: - // sig_aborted: + // error sig_aborted: // opret.resize(opret.size() + vpayload.size()); // CScript::iterator it = opret.begin() + opret.size(); // for (int i = 0; i < vpayload.size(); i++, it++) @@ -117,16 +114,20 @@ uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description, std::vector &vopretNonfungible) { - std::vector vopret; uint8_t dummyEvalcode, funcid, *script; + std::vector vopret; uint8_t dummyEvalcode, funcid, *script, fieldId = 0; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); if ( script != 0 && vopret.size() > 2 && script[0] == EVAL_TOKENS && script[1] == 'c' ) { - if( E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description; \ + if (E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description; \ // we suppose in 'c' opret it might be only non-fungible payload and not any assets/heir/etc payloads - if(!ss.eof()) ss >> vopretNonfungible ) ) + if (!ss.eof()) { \ + ss >> fieldId; \ + if( fieldId == OPRETID_NONFUNGIBLEDATA) \ + ss >> vopretNonfungible; \ + })) return(funcid); } return (uint8_t)0; @@ -134,7 +135,7 @@ uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector // overload for compatibility allows only usual fungible tokens: // warning: it makes vopret marshalling to CScript because this is what caller would expect -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { +/*uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { std::vector vopret1, vopret2; uint8_t funcId = DecodeTokenOpRet(scriptPubKey, evalCode, tokenid, voutPubkeys, vopret1, vopret2); @@ -150,12 +151,12 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 GetOpReturnData(opretExtra, vopretExtra); return funcId; -} +} */ -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2) +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { - std::vector vopret, extra, dummyPubkey; - uint8_t funcId=0, *script, dummyEvalCode, dummyFuncId, ccType; + std::vector vopret, extra, dummyPubkey, vnonfungibleDummy; + uint8_t funcId=0, *script, dummyEvalCode, dummyFuncId, ccType, fieldId = 0; std::string dummyName; std::string dummyDescription; CPubKey voutPubkey1, voutPubkey2; @@ -178,7 +179,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui switch( funcId ) { case 'c': - return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription, vopret1); + return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription, vnonfungibleDummy); //break; case 't': //not used yet: case 'l': @@ -187,9 +188,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui if (ccType >= 1) ss >> voutPubkey1; \ if (ccType == 2) ss >> voutPubkey2; \ isEof = ss.eof(); \ - if (!isEof) ss >> vopret1; \ - isEof = ss.eof(); \ - if (!isEof) { ss >> vopret2; } \ + if (!isEof) ss >> vopretExtra; \ // if something else remains -> bad format isEof = ss.eof()) || !isEof) { @@ -230,7 +229,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & CTxDestination address; CTransaction vinTx, createTx; uint256 hashBlock, tokenid, tokenid2; int32_t i, starti, numvins, numvouts, preventCCvins, preventCCvouts; int64_t remaining_price, nValue, tokenoshis, outputs, inputs, tmpprice, totalunits, ignore; - std::vector vopret1, vopret2, tmporigpubkey, ignorepubkey; + std::vector vopretExtra, tmporigpubkey, ignorepubkey; uint8_t funcid, evalCodeInOpret; char destaddr[64], origaddr[64], CCaddr[64]; std::vector voutTokenPubkeys; @@ -242,7 +241,11 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & outputs = inputs = 0; preventCCvins = preventCCvouts = -1; - if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopret1, vopret2)) == 0) + // check boundaries: + if (numvouts < 1) + return eval->Invalid("no vouts"); + + if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); @@ -250,13 +253,11 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); //else if (IsCCInput(tx.vin[0].scriptSig) != 0) - // return eval->Invalid("illegal token vin0"); - else if (numvouts < 1) - return eval->Invalid("no vouts"); + // return eval->Invalid("illegal token vin0"); // this validation was removed because some token tx might not have normal vins else if (funcid != 'c') { - if (tokenid == zeroid) - return eval->Invalid("illegal tokenid"); + if (tokenid == zeroid) + return eval->Invalid("illegal tokenid"); else if (!TokensExactAmounts(true, cp, inputs, outputs, eval, tx, tokenid)) { if (!eval->Valid()) return false; //TokenExactAmounts must call eval->Invalid()! @@ -265,14 +266,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & } } - // non-fungible tokens validation: - std::vector vopretNonfungible; - GetNonfungibleData(tokenid, vopretNonfungible); - if (vopretNonfungible.size() > 0 && vopretNonfungible != vopret1) // assuming tx vopretNonfungible in vopret1 - return eval->Invalid("incorrect or empty non-fungible data"); - - - switch (funcid) + switch (funcid) { case 'c': // create wont be called to be verified as it has no CC inputs //vin.0: normal input @@ -418,7 +412,7 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { // goDeeper is true: the func also validates amounts of the passed transaction: // it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx // checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true! -int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid) +int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true*/, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid) { // this is just for log messages indentation fur debugging recursive calls: @@ -458,36 +452,41 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // token opret most important checks (tokenid == reftokenid, tokenid is non-zero, tx is 'tokenbase'): const uint8_t funcId = ValidateTokenOpret(tx, reftokenid); //std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; - if (funcId != 0) { - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null funcId=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + if (funcId != 0) { + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null funcId=" << (char)(funcId ? funcId : ' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); uint8_t dummyEvalCode; uint256 tokenIdOpret; std::vector voutPubkeys; - std::vector vopret1; - std::vector vopret2; - DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeys, vopret1, vopret2); + std::vector vopretExtra, vopretNonfungible; - if (checkPubkeys && funcId != 'c') { // for 'c' there is no pubkeys + uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim + uint8_t evalCode2 = 0; // will be checked if zero or not + + // test vouts for possible token use-cases: + std::vector> testVouts; + + DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeys, vopretExtra); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl); + + GetNonfungibleData(reftokenid, vopretNonfungible); + + // NOTE: evalcode order in vouts is important: + // non-fungible-eval -> EVAL_TOKENS -> assets-eval + + if (vopretNonfungible.size() > 0) + evalCode = vopretNonfungible.begin()[0]; + if (vopretExtra.size() > 0) + evalCode2 = vopretExtra.begin()[0]; + + if (evalCode == EVAL_TOKENS && evalCode2 != 0) { + evalCode = evalCode2; + evalCode2 = 0; + } + + if( /*checkPubkeys &&*/ funcId != 'c' ) { // for 'c' there is no pubkeys // verify that the vout is token by constructing vouts with the pubkeys in the opret: - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret1=" << HexStr(vopret1) << std::endl); - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopret2=" << HexStr(vopret2) << std::endl); - - uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim - uint8_t evalCode2 = 0; // will be checked if zero or not - - // NOTE: evalcode order in vouts is important: - // non-fungible-eval -> EVAL_TOKENS -> assets-eval - if (vopret1.size() > 0) { - evalCode = vopret1.begin()[0]; - } - if (vopret2.size() > 0) { - evalCode2 = vopret2.begin()[0]; - } - - // checking vouts for possible token use-cases: - std::vector> testVouts; // maybe this is dual-eval 1 pubkey or 1of2 pubkey vout? if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) { // check dual/three-eval 1 pubkey vout with the first pubkey @@ -541,19 +540,36 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode2, evalCode, tx.vout[v].nValue, *it), std::string("three-eval cc1 self vin pk backward-eval"))); } - // try all test vouts: - for (auto t : testVouts) { - if (t.first == tx.vout[v]) { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() valid amount=" << tx.vout[v].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); - return tx.vout[v].nValue; - } - } - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() no valid vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); } else { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() returns without pubkey check value=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); - return tx.vout[v].nValue; + CPubKey origPubkey; + std::vector vorigPubkey; + std::string dummyName, dummyDescription; + std::vector vopret1; + + if (DecodeTokenCreateOpRet(tx.vout.back().scriptPubKey, vorigPubkey, dummyName, dummyDescription, vopret1) == 0) { + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() could not decode create opret" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + return 0; + } + + origPubkey = pubkey2pk(vorigPubkey); + + // for 'c' recognize the tokens only to token originator pubkey (but not to unspendable <-- closed sec violation) + // maybe this is like gatewayclaim to single-eval token? + testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, origPubkey), std::string("single-eval cc1 orig-pk"))); + // maybe this is like FillSell for non-fungible token? + if (evalCode != 0) + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode, tx.vout[v].nValue, origPubkey), std::string("dual-eval-token cc1 orig-pk"))); } + + // try all test vouts: + for (auto t : testVouts) { + if (t.first == tx.vout[v]) { + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() valid amount=" << tx.vout[v].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); + return tx.vout[v].nValue; + } + } + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "IsTokensvout() no valid vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); } //std::cerr << indentStr; fprintf(stderr,"IsTokensvout() CC vout v.%d of n=%d amount=%.8f txid=%s\n",v,n,(double)0/COIN, tx.GetHash().GetHex().c_str()); @@ -637,6 +653,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu return true; } + // get non-fungible data from 'tokenbase' tx (the data might be empty) void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible) { @@ -644,18 +661,18 @@ void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible uint256 hashBlock; if (!myGetTransaction(tokenid, tokenbasetx, hashBlock)) { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "SetNonfungibleEvalCode() cound not load token creation tx=" << tokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "GetNonfungibleData() cound not load token creation tx=" << tokenid.GetHex() << std::endl); return; } vopretNonfungible.clear(); // check if it is non-fungible tx and get its second evalcode from non-fungible payload if (tokenbasetx.vout.size() > 0) { - uint8_t dummyEvalCode; - uint256 tokenIdOpret; - std::vector voutPubkeys; + std::vector origpubkey; + std::string name, description; std::vector vopretExtra; - DecodeTokenOpRet(tokenbasetx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeys, vopretNonfungible, vopretExtra); + if (DecodeTokenCreateOpRet(tokenbasetx.vout.back().scriptPubKey, origpubkey, name, description, vopretExtra) == 'c') + vopretNonfungible = vopretExtra; } } @@ -786,7 +803,9 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st destEvalCode = nonfungibleData.begin()[0]; mtx.vout.push_back(MakeTokensCC1vout(destEvalCode, tokensupply, mypk)); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); + //mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); // old marker (non-burnable because spending could not be validated) + // NOTE: we should prevent spending fake-tokens from this marker in IsTokenvout(): + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to cc addr, burnable and validated return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } @@ -838,7 +857,7 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(pubkey2pk(destpubkey)); // dest pubkey for validating vout - return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutTokenPubkeys, vopretNonfungible, CScript()))); + return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutTokenPubkeys, CScript()))); } else { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "not enough CC token inputs for amount=" << total << std::endl); @@ -913,22 +932,31 @@ UniValue TokenList() { UniValue result(UniValue::VARR); std::vector > addressIndex; + std::vector > addressIndexCCMarker; + struct CCcontract_info *cp, C; uint256 txid, hashBlock; CTransaction vintx; std::vector origpubkey; - std::string name, description; char str[65]; + std::string name, description; cp = CCinit(&C, EVAL_TOKENS); - SetCCtxids(addressIndex, cp->normaladdr); - for (std::vector >::const_iterator it = addressIndex.begin(); it != addressIndex.end(); it++) - { - txid = it->first.txhash; - if (GetTransaction(txid, vintx, hashBlock, false) != 0) - { - if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) != 0) - { - result.push_back(uint256_str(str, txid)); - } - } + + auto addTokenId = [&](uint256 txid) { + if (GetTransaction(txid, vintx, hashBlock, false) != 0) { + if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) != 0) { + result.push_back(txid.GetHex()); + } + } + }; + + SetCCtxids(addressIndex, cp->normaladdr); // find by old normal addr marker + for (std::vector >::const_iterator it = addressIndex.begin(); it != addressIndex.end(); it++) { + addTokenId(it->first.txhash); } + + SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr); // find by burnable validated cc addr marker + for (std::vector >::const_iterator it = addressIndexCCMarker.begin(); it != addressIndexCCMarker.end(); it++) { + addTokenId(it->first.txhash); + } + return(result); } diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index 4637ba6c9..231b64ac9 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -35,11 +35,4 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid); UniValue TokenInfo(uint256 tokenid); UniValue TokenList(); -void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible); - -//this is in CCinclude.h int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); - -//this is in CCinclude.h uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); - - #endif diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 97b01302c..6f93da01b 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -157,7 +157,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); - if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey, vopretNonfungibleDummy)) == 0 ) + if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 ) return eval->Invalid("AssetValidate: invalid opreturn payload"); // non-fungible tokens support: diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9c7504e5f..5a1ef60b5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -15,6 +15,7 @@ ******************************************************************************/ #include "cJSON.h" +#include "CCinclude.h" #define ROGUE_REGISTRATION 5 #define ROGUE_REGISTRATIONSIZE (100 * 10000) @@ -173,19 +174,27 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CP return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid,int32_t ®slot,CPubKey &pk,std::vector &playerdata,CScript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, CScript scriptPubKey) { - std::vector vopret,vopret2; uint8_t e,f; uint256 tokenid; std::vector voutPubkeys; - GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + std::string name, description; + std::vector vorigPubkey; + std::vector vopretNonfungible, vopret, vopretDummy; + uint8_t e, f; uint256 tokenid; std::vector voutPubkeys; + + GetOpReturnData(scriptPubKey, vopret); + // try no tokens case: + if (vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q')) return(f); - else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) - { - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + else if (f = DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy) != 0) { // it is tokens + if (f != 'c') + GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx + + if (vopretNonfungible.size() > 2 && E_UNMARSHAL(vopretNonfungible, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q')) { return(f); } } + return(0); } @@ -670,6 +679,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; + if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -707,7 +717,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); - std::vector vopretFinish, vopret2; uint8_t e, funcid; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; + std::vector vopretExtra; uint8_t e, funcid; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { @@ -715,13 +725,13 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { - if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2)) != 0) + if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretExtra)) != 0) { // if token in the opret didtx = 1; if ( funcid == 'c' ) tokenid = playertxid; rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, - EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister)); + EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, opretRegister)); } } } @@ -788,6 +798,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + struct CCcontract_info *cpTokens, tokensC; + if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); @@ -870,6 +882,9 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } } mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens, NULL))); // marker to token cc addr, burnable and validated + Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); CScript opret = rogue_highlanderopret(funcid, gametxid, regslot,mypk, newdata); From e7516e10a98e0a18c2a5126bde306b4bca1158f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 03:43:00 -1100 Subject: [PATCH 2012/3904] Flushkeystrokes every 4kb --- src/cc/rogue/rogue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index e82b514e0..fffa6203d 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -187,7 +187,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) { - char cmd[32768],hexstr[32768]; int32_t i; + char cmd[16384],hexstr[16384]; int32_t i; for (i=0; ineedflush != 0 ) + if ( rs->needflush != 0 && rs->num > 4096 ) { if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; From 08be0457e6619121959b9d60cbcf54e3e3a9fdff Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 11 Feb 2019 20:04:50 +0500 Subject: [PATCH 2013/3904] corr call to DecodeTokenOpRet --- src/cc/CCtokens.cpp | 36 +++++++++++++++++++++++++++++------- src/cc/rogue_rpc.cpp | 6 +++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index f5eda7d31..eb802b65d 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -125,7 +125,7 @@ uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector // we suppose in 'c' opret it might be only non-fungible payload and not any assets/heir/etc payloads if (!ss.eof()) { \ ss >> fieldId; \ - if( fieldId == OPRETID_NONFUNGIBLEDATA) \ + if( fieldId == OPRETID_NONFUNGIBLEDATA ) \ ss >> vopretNonfungible; \ })) return(funcid); @@ -153,6 +153,9 @@ uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector return funcId; } */ +// decodes token opret: +// for 't' returns all data from opret, vopretExtra contains other contract's data (currently only assets'). +// for 'c' returns only funcid. NOTE: nonfungible data is not returned uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { std::vector vopret, extra, dummyPubkey, vnonfungibleDummy; @@ -163,6 +166,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); tokenid = zeroid; + vopretExtra.clear(); if (script != NULL && vopret.size() > 2) { @@ -174,7 +178,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui return (uint8_t)0; funcId = script[1]; - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); switch( funcId ) { @@ -407,6 +411,20 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { return (uint8_t)0; } +// remove token->unspendablePk (it is only for marker usage) +std::vector FilterOutTokensUnspendablePk(std::vector sourcePubkeys) { + struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + CPubKey tokensUnspendablePk = GetUnspendable(cpTokens, NULL); + std::vector destPubkeys; + + for (auto pk : sourcePubkeys) + if (pk != tokensUnspendablePk) + destPubkeys.push_back(pk); + + return destPubkeys; +} + // Checks if the vout is a really Tokens CC vout // also checks tokenid in opret or txid if this is 'c' tx // goDeeper is true: the func also validates amounts of the passed transaction: @@ -457,7 +475,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true uint8_t dummyEvalCode; uint256 tokenIdOpret; - std::vector voutPubkeys; + std::vector voutPubkeys, voutPubkeysInOpret; std::vector vopretExtra, vopretNonfungible; uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim @@ -466,11 +484,13 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true // test vouts for possible token use-cases: std::vector> testVouts; - DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeys, vopretExtra); + DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeysInOpret, vopretExtra); LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl); GetNonfungibleData(reftokenid, vopretNonfungible); + voutPubkeys = FilterOutTokensUnspendablePk(voutPubkeysInOpret); + // NOTE: evalcode order in vouts is important: // non-fungible-eval -> EVAL_TOKENS -> assets-eval @@ -529,8 +549,10 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true } // maybe it is single-eval or dual/three-eval token change? - std::vector vinPubkeys; - ExtractTokensVinPubkeys(tx, vinPubkeys); + std::vector vinPubkeys, vinPubkeysUnfiltered; + ExtractTokensVinPubkeys(tx, vinPubkeysUnfiltered); + vinPubkeys = FilterOutTokensUnspendablePk(vinPubkeysUnfiltered); + for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it), std::string("single-eval cc1 self vin pk"))); testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode, evalCode2, tx.vout[v].nValue, *it), std::string("three-eval cc1 self vin pk"))); @@ -805,7 +827,7 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st mtx.vout.push_back(MakeTokensCC1vout(destEvalCode, tokensupply, mypk)); //mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); // old marker (non-burnable because spending could not be validated) // NOTE: we should prevent spending fake-tokens from this marker in IsTokenvout(): - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to cc addr, burnable and validated + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to token cc addr, burnable and validated return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5a1ef60b5..603e776b8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -218,7 +218,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl { return(f); } - else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret,vopret2)) == 'c' || f == 't' ) + else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret)) == 'c' || f == 't' ) { //fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); if ( vopret2.size() > 2 && E_UNMARSHAL(vopret2,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) @@ -731,7 +731,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( funcid == 'c' ) tokenid = playertxid; rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, - EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, opretRegister)); + EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, opretRegister)); } } } @@ -881,7 +881,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } } } - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-2*txfee),roguepk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens, NULL))); // marker to token cc addr, burnable and validated From 0edf474beb3ae206c0d6f03a2cb937768a023572 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 11 Feb 2019 16:37:28 +0100 Subject: [PATCH 2014/3904] Multi coin support for GatewaysCC (#18) - Added support for other cions - New RPC for getting address for a pubkey on external chain and for dumping private key in external chain format --- src/base58.cpp | 78 ++++++++++++++++ src/base58.h | 31 +++++- src/cc/CCGateways.h | 4 +- src/cc/CCinclude.h | 2 + src/cc/CCutils.cpp | 22 +++++ src/cc/dapps/oraclefeed.c | 92 +++++++++--------- src/cc/gateways.cpp | 192 +++++++++++++++++++++++++------------- src/key_io.cpp | 13 +++ src/key_io.h | 1 + src/rpc/server.cpp | 2 + src/rpc/server.h | 2 + src/wallet/rpcwallet.cpp | 55 ++++++++++- 12 files changed, 372 insertions(+), 122 deletions(-) diff --git a/src/base58.cpp b/src/base58.cpp index 9d10b7e6a..33b43d745 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -336,6 +336,84 @@ bool CBitcoinAddress::IsScript() const return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS); } +bool CCustomBitcoinAddress::Set(const CKeyID& id) +{ + SetData(base58Prefixes[0], &id, 20); + return true; +} + +bool CCustomBitcoinAddress::Set(const CPubKey& key) +{ + CKeyID id = key.GetID(); + SetData(base58Prefixes[0], &id, 20); + return true; +} + +bool CCustomBitcoinAddress::Set(const CScriptID& id) +{ + SetData(base58Prefixes[1], &id, 20); + return true; +} + +bool CCustomBitcoinAddress::Set(const CTxDestination& dest) +{ + return boost::apply_visitor(CBitcoinAddressVisitor(this), dest); +} + +bool CCustomBitcoinAddress::IsValid() const +{ + bool fCorrectSize = vchData.size() == 20; + bool fKnownVersion = vchVersion == base58Prefixes[0] || + vchVersion == base58Prefixes[1]; + return fCorrectSize && fKnownVersion; +} + +bool CCustomBitcoinAddress::GetKeyID(CKeyID& keyID) const +{ + if (!IsValid() || vchVersion != base58Prefixes[0]) + return false; + uint160 id; + memcpy(&id, &vchData[0], 20); + keyID = CKeyID(id); + return true; +} + +CTxDestination CCustomBitcoinAddress::Get() const +{ + if (!IsValid()) + return CNoDestination(); + uint160 id; + memcpy(&id, &vchData[0], 20); + if (vchVersion == base58Prefixes[0]) + return CKeyID(id); + else if (vchVersion == base58Prefixes[1]) + return CScriptID(id); + else + return CNoDestination(); +} + +bool CCustomBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type) const +{ + if (!IsValid()) { + return false; + } else if (vchVersion == base58Prefixes[0]) { + memcpy(&hashBytes, &vchData[0], 20); + type = 1; + return true; + } else if (vchVersion == base58Prefixes[1]) { + memcpy(&hashBytes, &vchData[0], 20); + type = 2; + return true; + } + + return false; +} + +bool CCustomBitcoinAddress::IsScript() const +{ + return IsValid() && vchVersion == base58Prefixes[1]; +} + void CBitcoinSecret::SetKey(const CKey& vchSecret) { assert(vchSecret.IsValid()); diff --git a/src/base58.h b/src/base58.h index 4decb4922..52b3ac5f3 100644 --- a/src/base58.h +++ b/src/base58.h @@ -130,9 +130,9 @@ public: */ class CBitcoinAddress : public CBase58Data { public: - bool Set(const CKeyID &id); - bool Set(const CPubKey &key); - bool Set(const CScriptID &id); + virtual bool Set(const CKeyID &id); + virtual bool Set(const CPubKey &key); + virtual bool Set(const CScriptID &id); bool Set(const CTxDestination &dest); bool IsValid() const; bool IsValid(const CChainParams ¶ms) const; @@ -151,6 +151,31 @@ public: bool IsScript() const; }; +class CCustomBitcoinAddress : public CBitcoinAddress { + std::vector base58Prefixes[2]; +public: + bool Set(const CKeyID &id); + bool Set(const CPubKey &key); + bool Set(const CScriptID &id); + bool Set(const CTxDestination &dest); + bool IsValid() const; + + CCustomBitcoinAddress() {} + CCustomBitcoinAddress(const CTxDestination &dest,uint8_t taddr,uint8_t pubkey_prefix,uint8_t script_prefix) + { + if (taddr!=0) base58Prefixes[0].push_back(taddr); + base58Prefixes[0].push_back(pubkey_prefix); + base58Prefixes[1].push_back(script_prefix); + Set(dest); + } + + CTxDestination Get() const; + bool GetKeyID(CKeyID &keyID) const; + bool GetKeyID_NoCheck(CKeyID& keyID) const; + bool GetIndexKey(uint160& hashBytes, int& type) const; + bool IsScript() const; +}; + /** * A base58-encoded secret key */ diff --git a/src/cc/CCGateways.h b/src/cc/CCGateways.h index 7ecae2228..1f594e38b 100644 --- a/src/cc/CCGateways.h +++ b/src/cc/CCGateways.h @@ -21,7 +21,7 @@ #include "../merkleblock.h" bool GatewaysValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); -std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys); +std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys,uint8_t p1,uint8_t p2,uint8_t p3,uint8_t p4); std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount); std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount); std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount); @@ -34,6 +34,8 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin); // CCcustom UniValue GatewaysInfo(uint256 bindtxid); +UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey); +UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey privkey); UniValue GatewaysList(); #endif diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 1cb141a16..11af54b66 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -151,6 +151,7 @@ int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t * CScript GetScriptForMultisig(int nRequired, const std::vector& keys); int64_t CCaddress_balance(char *coinaddr); CPubKey CCtxidaddr(char *txidaddr,uint256 txid); +CPubKey CCCustomtxidaddr(char *txidaddr,uint256 txid,uint8_t taddr,uint8_t prefix,uint8_t prefix2); bool GetCCParams(Eval* eval, const CTransaction &tx, uint32_t nIn, CTransaction &txOut, std::vector> &preConditions, std::vector> ¶ms); @@ -227,6 +228,7 @@ bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubK bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue); bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t numvins,int32_t preventCCvouts,int32_t numvouts); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); +bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix,uint8_t prefix2); std::vector Mypubkey(); bool Myprivkey(uint8_t myprivkey[]); int64_t CCduration(int32_t &numblocks,uint256 txid); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 6892f6fab..1ee191444 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -299,6 +299,18 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) return(false); } +bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix, uint8_t prefix2) +{ + CTxDestination address; txnouttype whichType; + if ( ExtractDestination(scriptPubKey,address) != 0 ) + { + strcpy(destaddr,(char *)CCustomBitcoinAddress(address,taddr,prefix,prefix2).ToString().c_str()); + return(true); + } + //fprintf(stderr,"ExtractDestination failed\n"); + return(false); +} + bool GetCCParams(Eval* eval, const CTransaction &tx, uint32_t nIn, CTransaction &txOut, std::vector> &preConditions, std::vector> ¶ms) { @@ -359,6 +371,16 @@ CPubKey CCtxidaddr(char *txidaddr,uint256 txid) return(pk); } +CPubKey CCCustomtxidaddr(char *txidaddr,uint256 txid,uint8_t taddr,uint8_t prefix,uint8_t prefix2) +{ + uint8_t buf33[33]; CPubKey pk; + buf33[0] = 0x02; + endiancpy(&buf33[1],(uint8_t *)&txid,32); + pk = buf2pk(buf33); + GetCustomscriptaddress(txidaddr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG,taddr,prefix,prefix2); + return(pk); +} + bool _GetCCaddress(char *destaddr,uint8_t evalcode,CPubKey pk) { CC *payoutCond; diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index d97df1cd9..cc6b45037 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -312,22 +312,20 @@ uint64_t get_btcusd() char *REFCOIN_CLI; -cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char *arg0,char *arg1,char *arg2,char *arg3) +cJSON *get_cli(char *refcoin,char **retstrp,char *acname,char *method,char *arg0,char *arg1,char *arg2,char *arg3) { long fsize; cJSON *retjson = 0; char cmdstr[32768],*jsonstr,fname[256]; sprintf(fname,"/tmp/oraclefeed.%s",method); if ( acname[0] != 0 ) { - if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 ) - printf("unexpected: refcoin.(%s) acname.(%s)\n",refcoin,acname); + if ( refcoin[0] == 0 ) + printf("must supply reference coin\n"); sprintf(cmdstr,"./komodo-cli -ac_name=%s %s %s %s %s %s > %s 2>/tmp/oraclefeed.error\n",acname,method,arg0,arg1,arg2,arg3,fname); } - else if ( strcmp(refcoin,"KMD") == 0 ) - sprintf(cmdstr,"./komodo-cli %s %s %s %s %s > %s 2>/tmp/oraclefeed.error\n",method,arg0,arg1,arg2,arg3,fname); else if ( REFCOIN_CLI != 0 && REFCOIN_CLI[0] != 0 ) { sprintf(cmdstr,"%s %s %s %s %s %s > %s 2>/tmp/oraclefeed.error\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,fname); - printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); + //printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); } #ifdef TESTMODE fprintf(stderr,"cmd: %s\n",cmdstr); @@ -349,13 +347,13 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char return(retjson); } -bits256 komodobroadcast(char *refcoin,char *acname,cJSON *hexjson) +bits256 broadcasttx(char *refcoin,char *acname,cJSON *hexjson) { char *hexstr,*retstr,str[65]; cJSON *retjson; bits256 txid; memset(txid.bytes,0,sizeof(txid)); if ( (hexstr= jstr(hexjson,"hex")) != 0 ) { - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendrawtransaction",hexstr,"","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"sendrawtransaction",hexstr,"","","")) != 0 ) { if (strcmp("error",jstr(retjson,"result"))==0) printf("%s\n",jstr(retjson,"error")); free_json(retjson); @@ -379,9 +377,9 @@ bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis char numstr[32],*retstr,str[65]; cJSON *retjson; bits256 txid; memset(txid.bytes,0,sizeof(txid)); sprintf(numstr,"%.8f",(double)satoshis/SATOSHIDEN); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"","")) != 0 ) { - fprintf(stderr,"unexpected sendrawtransaction json.(%s)\n",jprint(retjson,0)); + fprintf(stderr,"unexpected sendtoaddress json.(%s)\n",jprint(retjson,0)); free_json(retjson); } else if ( retstr != 0 ) @@ -400,10 +398,11 @@ bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis int32_t get_coinheight(char *refcoin,char *acname) { cJSON *retjson; char *retstr; int32_t height=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockchaininfo","","","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"getblockchaininfo","","","","")) != 0 ) { height = jint(retjson,"blocks"); free_json(retjson); + } else if ( retstr != 0 ) { @@ -418,7 +417,7 @@ bits256 get_coinblockhash(char *refcoin,char *acname,int32_t height) cJSON *retjson; char *retstr,heightstr[32]; bits256 hash; memset(hash.bytes,0,sizeof(hash)); sprintf(heightstr,"%d",height); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","")) != 0 ) { fprintf(stderr,"unexpected blockhash json.(%s)\n",jprint(retjson,0)); free_json(retjson); @@ -439,7 +438,7 @@ bits256 get_coinmerkleroot(char *refcoin,char *acname,bits256 blockhash) { cJSON *retjson; char *retstr,str[65]; bits256 merkleroot; memset(merkleroot.bytes,0,sizeof(merkleroot)); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","")) != 0 ) { merkleroot = jbits256(retjson,"merkleroot"); //fprintf(stderr,"got merkleroot.(%s)\n",bits256_str(str,merkleroot)); @@ -477,7 +476,7 @@ int32_t get_coinheader(char *refcoin,char *acname,bits256 *blockhashp,bits256 *m cJSON *get_gatewayspending(char *refcoin,char *acname,char *bindtxidstr) { cJSON *retjson; char *retstr; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspendingwithdraws",bindtxidstr,refcoin,"","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewayspendingwithdraws",bindtxidstr,refcoin,"","")) != 0 ) { //printf("pending.(%s)\n",jprint(retjson,0)); return(retjson); @@ -493,7 +492,7 @@ cJSON *get_gatewayspending(char *refcoin,char *acname,char *bindtxidstr) cJSON *get_gatewaysprocessed(char *refcoin,char *acname,char *bindtxidstr) { cJSON *retjson; char *retstr; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewaysprocessed",bindtxidstr,refcoin,"","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewaysprocessed",bindtxidstr,refcoin,"","")) != 0 ) { //printf("pending.(%s)\n",jprint(retjson,0)); return(retjson); @@ -509,7 +508,7 @@ cJSON *get_gatewaysprocessed(char *refcoin,char *acname,char *bindtxidstr) cJSON *get_rawmempool(char *refcoin,char *acname) { cJSON *retjson; char *retstr; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawmempool","","","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"getrawmempool","","","","")) != 0 ) { //printf("mempool.(%s)\n",jprint(retjson,0)); return(retjson); @@ -528,7 +527,7 @@ cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr) if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 ) printf("warning: assumes %s has addressindex enabled\n",refcoin); sprintf(jsonbuf,"{\\\"addresses\\\":[\\\"%s\\\"]}",coinaddr); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","")) != 0 ) { //printf("addressutxos.(%s)\n",jprint(retjson,0)); return(retjson); @@ -544,7 +543,7 @@ cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr) cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid) { cJSON *retjson; char *retstr,str[65]; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","")) != 0 ) { return(retjson); } @@ -559,7 +558,7 @@ cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid) int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* compare) { cJSON *retjson; char *retstr; int32_t res=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 ) { if (is_cJSON_True(jobj(retjson,compare)) != 0 ) res=1; free_json(retjson); @@ -578,7 +577,7 @@ void importaddress(char *refcoin,char *acname,char *depositaddr, char *label,int cJSON *retjson; char *retstr; char rescanstr[10]; if (rescan) strcpy(rescanstr,"true"); else strcpy(rescanstr,"false"); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"importaddress",depositaddr,label,rescanstr,"")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"importaddress",depositaddr,label,rescanstr,"")) != 0 ) { printf("importaddress.(%s)\n",jprint(retjson,0)); free_json(retjson); @@ -595,7 +594,7 @@ void addmultisigaddress(char *refcoin,char *acname,int32_t M, char *pubkeys) cJSON *retjson; char *retstr,Mstr[10],addr[64]; sprintf(Mstr,"%d",M); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"addmultisigaddress",Mstr,pubkeys,"","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"addmultisigaddress",Mstr,pubkeys,"","")) != 0 ) { fprintf(stderr,"unexpected addmultisigaddress json.(%s)\n",jprint(retjson,0)); free(retstr); @@ -603,7 +602,7 @@ void addmultisigaddress(char *refcoin,char *acname,int32_t M, char *pubkeys) else if ( retstr != 0 ) { sprintf(addr,"\"%s\"",retstr); - get_komodocli(refcoin,&retstr,acname,"importaddress",addr,"\"\"","false",""); + get_cli(refcoin,&retstr,acname,"importaddress",addr,"\"\"","false",""); printf("addmultisigaddress.(%s)\n",retstr); free_json(retjson); } @@ -648,7 +647,7 @@ char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawadd return(0); } sprintf(array,"\'[\"%s\"]\'",depositaddr); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"listunspent","1","99999999",array,"")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"listunspent","1","99999999",array,"")) != 0 ) { //createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,...} if ( (vins= getinputarray(&total,retjson,satoshis)) != 0 ) @@ -669,7 +668,7 @@ char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawadd char *argB=malloc(sizeof(char) * (strlen(tmpB)+3)); sprintf(argA,"\'%s\'",tmpA); sprintf(argB,"\'%s\'",tmpB); - if ( (retjson2= get_komodocli(refcoin,&txstr,acname,"createrawtransaction",argA,argB,"","")) != 0 ) + if ( (retjson2= get_cli(refcoin,&txstr,acname,"createrawtransaction",argA,argB,"","")) != 0 ) { printf("createrawtx: unexpected JSON2.(%s)\n",jprint(retjson2,0)); free_json(retjson2); @@ -697,7 +696,7 @@ char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawadd cJSON *addsignature(char *refcoin,char *acname,char *rawtx, int M) { char *retstr,*hexstr; cJSON *retjson; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"signrawtransaction",rawtx,"","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"signrawtransaction",rawtx,"","","")) != 0 ) { if ( is_cJSON_True(jobj(retjson,"complete")) != 0 ) return(retjson); @@ -716,12 +715,12 @@ cJSON *addsignature(char *refcoin,char *acname,char *rawtx, int M) return(0); } -bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *coin,char *hex) +bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *hex) { char str[65],*retstr; cJSON *retjson; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspartialsign",bits256_str(str,txid),coin,hex,"")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewayspartialsign",bits256_str(str,txid),refcoin,hex,"")) != 0 ) { - if (strcmp("error",jstr(retjson,"result"))!=0) txid=komodobroadcast(refcoin,acname,retjson); + if (strcmp("error",jstr(retjson,"result"))!=0) txid=broadcasttx(refcoin,acname,retjson); else printf("%s\n",jstr(retjson,"error")); free(retjson); return (txid); @@ -734,12 +733,12 @@ bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *coin,c return (zeroid); } -bits256 gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char *coin,char *hex) +bits256 gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char *hex) { char str[65],*retstr; cJSON *retjson; bits256 txid; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayscompletesigning",bits256_str(str,withtxid),coin,hex,"")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewayscompletesigning",bits256_str(str,withtxid),refcoin,hex,"")) != 0 ) { - if (strcmp("error",jstr(retjson,"result"))!=0) txid=komodobroadcast(refcoin,acname,retjson); + if (strcmp("error",jstr(retjson,"result"))!=0) txid=broadcasttx(refcoin,acname,retjson); else printf("%s\n",jstr(retjson,"error")); free(retjson); return (txid); @@ -752,12 +751,12 @@ bits256 gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char return (zeroid); } -bits256 gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid,char *coin) +bits256 gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid) { char str[65],str2[65],*retstr; cJSON *retjson; bits256 txid; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewaysmarkdone",bits256_str(str,withtxid),coin,"","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewaysmarkdone",bits256_str(str,withtxid),refcoin,"","")) != 0 ) { - if (strcmp("error",jstr(retjson,"result"))!=0) txid=komodobroadcast(refcoin,acname,retjson); + if (strcmp("error",jstr(retjson,"result"))!=0) txid=broadcasttx(refcoin,acname,retjson); else printf("%s\n",jstr(retjson,"error")); free(retjson); return (txid); @@ -773,7 +772,7 @@ bits256 gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid,char *coin) int32_t get_gatewaysinfo(char *refcoin,char *acname,char *depositaddr,int32_t *Mp,int32_t *Np,char *bindtxidstr,char *coin,char *oraclestr, char **pubkeys) { char *oracle,*retstr,*name,*deposit,temp[128]; cJSON *retjson,*pubarray; int32_t n; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewaysinfo",bindtxidstr,"","","")) != 0 ) + if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewaysinfo",bindtxidstr,"","","")) != 0 ) { if ( (oracle= jstr(retjson,"oracletxid")) != 0 && strcmp(oracle,oraclestr) == 0 && (deposit= jstr(retjson,"deposit")) != 0 ) { @@ -888,7 +887,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t int32_t i,j,n,K,retval,processed = 0; bits256 txid,cointxid,withdrawtxid,lasttxid,completetxid; int64_t satoshis; memset(&zeroid,0,sizeof(zeroid)); - if ( (retjson= get_gatewayspending("KMD",acname,bindtxidstr)) != 0 ) + if ( (retjson= get_gatewayspending(refcoin,acname,bindtxidstr)) != 0 ) { if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 ) { @@ -912,7 +911,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t { if ( (clijson=addsignature(refcoin,"",rawtx,M)) != 0 && is_cJSON_True(jobj(clijson,"complete")) != 0) { - txid=gatewayscompletesigning("KMD",acname,withdrawtxid,refcoin,jstr(clijson,"hex")); + txid=gatewayscompletesigning(refcoin,acname,withdrawtxid,jstr(clijson,"hex")); if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) complete signing tx sent - %s\n",bits256_str(str,withdrawtxid),bits256_str(str1,txid)); else fprintf(stderr,"error broadcasting tx on %s",acname); free_json(clijson); @@ -934,13 +933,13 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t { if ( is_cJSON_True(jobj(clijson,"complete")) != 0 ) { - txid=gatewayscompletesigning("KMD",acname,lasttxid,refcoin,jstr(clijson,"hex")); + txid=gatewayscompletesigning(refcoin,acname,lasttxid,jstr(clijson,"hex")); if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s %dof%d\n",bits256_str(str,withdrawtxid),K+1,N); else fprintf(stderr,"### SIGNING error broadcasting tx on %s\n",acname); } else if ( jint(clijson,"partialtx") != 0 ) { - txid=gatewayspartialsign("KMD",acname,lasttxid,refcoin,jstr(clijson,"hex")); + txid=gatewayspartialsign(refcoin,acname,lasttxid,jstr(clijson,"hex")); if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s %d/%dof%d\n",bits256_str(str,withdrawtxid),K+1,M,N); else fprintf(stderr,"### SIGNING error broadcasting tx on %s\n",acname); } @@ -956,7 +955,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t } free_json(retjson); } - if ( (retjson= get_gatewaysprocessed("KMD",acname,bindtxidstr)) != 0 ) + if ( (retjson= get_gatewaysprocessed(refcoin,acname,bindtxidstr)) != 0 ) { if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 ) { @@ -973,12 +972,12 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t importaddress(refcoin,"",txidaddr,jstr(item,"withdrawtxid"),0); if (is_cJSON_True(jobj(item,"confirmed_or_notarized")) && txidaddr != 0 && markerexists(refcoin,"",txidaddr)==0) { - cointxid = komodobroadcast(refcoin,"",item); + cointxid = broadcasttx(refcoin,"",item); if ( bits256_nonz(cointxid) != 0 ) { withdrawaddr = jstr(item,"withdrawaddr"); fprintf(stderr,"### WITHDRAW %.8f %s sent to %s\n",amount,refcoin,withdrawaddr); - txid=gatewaysmarkdone("KMD",acname,completetxid,refcoin); + txid=gatewaysmarkdone(refcoin,acname,completetxid); if (txid.txid!=zeroid.txid) fprintf(stderr,"### MARKDONE withdraw %s\n",bits256_str(str,withdrawtxid)); } else fprintf(stderr,"### WITHDRAW error broadcasting tx on %s\n",refcoin); @@ -1073,7 +1072,7 @@ int32_t main(int32_t argc,char **argv) while ( 1 ) { retstr = 0; - if ( (refcoin[0] == 0 || prevheight < (get_coinheight(refcoin,"") - 10)) && (clijson= get_komodocli("KMD",&retstr,acname,"oraclesinfo",oraclestr,"","","")) != 0 ) + if ( (refcoin[0] == 0 || prevheight < (get_coinheight(refcoin,"") - 10)) && (clijson= get_cli(refcoin,&retstr,acname,"oraclesinfo",oraclestr,"","","")) != 0 ) { if ( refcoin[0] == 0 && jstr(clijson,"name") != 0 ) { @@ -1084,7 +1083,7 @@ int32_t main(int32_t argc,char **argv) exit(0); } pubkeys=0; - if ( get_gatewaysinfo("KMD",acname,depositaddr,&M,&N,bindtxidstr,refcoin,oraclestr,&pubkeys) < 0 ) + if ( get_gatewaysinfo(refcoin,acname,depositaddr,&M,&N,bindtxidstr,refcoin,oraclestr,&pubkeys) < 0 ) { printf("cant find bindtxid.(%s)\n",bindtxidstr); exit(0); @@ -1106,10 +1105,9 @@ int32_t main(int32_t argc,char **argv) { if ( (height= get_oracledata(refcoin,"",prevheight,hexstr,sizeof(hexstr),"Ihh")) != 0 ) { - if ( (clijson2= get_komodocli("KMD",&retstr2,acname,"oraclesdata",oraclestr,hexstr,"","")) != 0 ) + if ( (clijson2= get_cli(refcoin,&retstr2,acname,"oraclesdata",oraclestr,hexstr,"","")) != 0 ) { - //printf("data.(%s)\n",jprint(clijson2,0)); - txid = komodobroadcast("KMD",acname,clijson2); + txid = broadcasttx(refcoin,acname,clijson2); if ( bits256_nonz(txid) != 0 ) { prevheight = height; diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 5c8de254d..af9038f81 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -14,6 +14,7 @@ ******************************************************************************/ #include "CCGateways.h" +#include "key_io.h" /* prevent duplicate bindtxid via mempool scan @@ -147,7 +148,7 @@ */ // start of consensus code -CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector gatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2) +CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector gatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; std::vector pubkeys; @@ -155,11 +156,11 @@ CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin, cp = CCinit(&C,EVAL_GATEWAYS); gatewayspk = GetUnspendable(cp,0); pubkeys.push_back(gatewayspk); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << totalsupply << oracletxid << M << N << gatewaypubkeys << taddr << prefix << prefix2); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << totalsupply << oracletxid << M << N << gatewaypubkeys << taddr << prefix << prefix2 << wiftype); return(EncodeTokenOpRet(tokenid,pubkeys,opret)); } -uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2) +uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t wiftype) { std::vector vopret; uint8_t *script,e,f,tokenevalcode; std::vector vOpretExtra; std::vector pubkeys; @@ -171,7 +172,7 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); depositaddr[0] = 0; - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> totalsupply; ss >> oracletxid; ss >> M; ss >> N; ss >> gatewaypubkeys; ss >> taddr; ss >> prefix; ss >> prefix2;) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> totalsupply; ss >> oracletxid; ss >> M; ss >> N; ss >> gatewaypubkeys; ss >> taddr; ss >> prefix; ss >> prefix2; ss >> wiftype) != 0 ) { if ( prefix == 60 ) { @@ -181,6 +182,11 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui //LogPrint("gatewayscc","f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr); } else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG); } + else if (prefix == 28 && prefix2 == 50) + { + if ( N > 1 ) strcpy(depositaddr,CCustomBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys)),taddr,prefix,prefix2).ToString().c_str()); + else GetCustomscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG,taddr,prefix,prefix2); + } else { LogPrint("gatewayscc","need to generate non-KMD addresses prefix.%d\n",prefix); @@ -446,7 +452,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u } } //else LogPrint("gatewayscc","height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); batontxid = bhash; - //LogPrint("gatewayscc","new hash %s\n",uint256_str(str,batontxid)); + // LogPrint("gatewayscc","new hash %s\n",uint256_str(str,batontxid)); } else break; } LogPrint("gatewayscc","end of loop\n"); @@ -479,7 +485,7 @@ uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::ve return merkleBlock.txn.ExtractMatches(txids); } -int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 cointxid,const std::string deposithex,std::vectorproof,uint256 merkleroot,CPubKey destpub) +int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 cointxid,const std::string deposithex,std::vectorproof,uint256 merkleroot,CPubKey destpub,uint8_t taddr,uint8_t prefix,uint8_t prefix2) { std::vector txids; uint256 proofroot,hashBlock,txid = zeroid; CTransaction tx; std::string name,description,format; char destaddr[64],destpubaddr[64],claimaddr[64],str[65],str2[65]; int32_t i,numvouts; int64_t nValue = 0; @@ -507,13 +513,13 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout } if ( DecodeHexTx(tx,deposithex) != 0 ) { - Getscriptaddress(claimaddr,tx.vout[claimvout].scriptPubKey); - Getscriptaddress(destpubaddr,CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG); + GetCustomscriptaddress(claimaddr,tx.vout[claimvout].scriptPubKey,taddr,prefix,prefix2); + GetCustomscriptaddress(destpubaddr,CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG,taddr,prefix,prefix2); if ( strcmp(claimaddr,destpubaddr) == 0 ) { for (i=0; i pubkeys; CTransaction tx; + uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; CTransaction tx; std::vector > addressIndex; _GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk); @@ -558,7 +564,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 { if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) { - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' ) { if ( tokenid == reftokenid ) { @@ -574,7 +580,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 const uint256 &hash = txmempool.GetHash(); if ((numvouts=txmempool.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B') - if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B' && + if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' && tokenid == reftokenid) return(1); } @@ -584,7 +590,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) { - int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],K,M,N,taddr,prefix,prefix2; + int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],K,M,N,taddr,prefix,prefix2,wiftype; char str[65],destaddr[64],depositaddr[65],validationError[512]; std::vector txids; std::vector pubkeys,publishers,tmppublishers; std::vector proof; int64_t fullsupply,totalsupply,amount,tmpamount; uint256 hashblock,txid,bindtxid,deposittxid,withdrawtxid,completetxid,tokenid,tmptokenid,oracletxid,bindtokenid,cointxid,tmptxid,merkleroot,mhash; CTransaction bindtx,tmptx; @@ -615,7 +621,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & //vin.1: CC input of tokens //vout.0: CC vout of gateways tokens to gateways tokens CC address //vout.1: CC vout txfee marker - //vout.n-1: opreturn - 'B' tokenid coin totalsupply oracletxid M N pubkeys taddr prefix prefix2 + //vout.n-1: opreturn - 'B' tokenid coin totalsupply oracletxid M N pubkeys taddr prefix prefix2 wiftype return eval->Invalid("unexpected GatewaysValidate for gatewaysbind!"); break; case 'D': @@ -644,7 +650,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("vout.0 is CC for gatewaysClaim!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); - else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); @@ -718,7 +724,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & sprintf(validationError,"couldnt find merkleroot for ht.%d %s oracle.%s m.%d vs n.%d\n",height,tmprefcoin.c_str(),uint256_str(str,oracletxid),m,N); return eval->Invalid(validationError); } - else if (GatewaysVerify(depositaddr,oracletxid,claimvout,tmprefcoin,cointxid,hex,proof,merkleroot,pubkey)!=amount) + else if (GatewaysVerify(depositaddr,oracletxid,claimvout,tmprefcoin,cointxid,hex,proof,merkleroot,pubkey,taddr,prefix,prefix2)!=amount) return eval->Invalid("external deposit not verified\n"); } break; @@ -764,7 +770,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); - else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); @@ -808,7 +814,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); - else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); @@ -846,7 +852,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); - else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B') + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); @@ -874,13 +880,13 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 bindtxid,int64_t total,int32_t maxinputs) { char coinaddr[64],depositaddr[64]; int64_t threshold,nValue,price,totalinputs = 0,totalsupply,amount; - CTransaction vintx,bindtx; int32_t vout,numvouts,n = 0; uint8_t M,N,evalcode,funcid,taddr,prefix,prefix2; std::vector pubkeys; + CTransaction vintx,bindtx; int32_t vout,numvouts,n = 0; uint8_t M,N,evalcode,funcid,taddr,prefix,prefix2,wiftype; std::vector pubkeys; std::vector > unspentOutputs; std::string refcoin,tmprefcoin; CPubKey withdrawpub,destpub; uint256 tokenid,txid,oracletxid,tmpbindtxid,tmptokenid,deposittxid,hashBlock; if ( GetTransaction(bindtxid,bindtx,hashBlock,false) != 0 ) { - if ((numvouts=bindtx.vout.size())!=0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,refcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) == 'B') + if ((numvouts=bindtx.vout.size())!=0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,refcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B') { GetTokensCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); @@ -933,10 +939,10 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP return(0); } -std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys) +std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys,uint8_t p1,uint8_t p2,uint8_t p3,uint8_t p4) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; + CTransaction oracletx; uint8_t taddr,prefix,prefix2,wiftype; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CCcontract_info *cp,*cpTokens,C,CTokens; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],myTokenCCaddr[64],str[65],*fstr; @@ -944,16 +950,18 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t cpTokens = CCinit(&CTokens,EVAL_TOKENS); if (coin=="KMD") { - taddr = 0; prefix = 60; prefix2 = 85; + wiftype = 188; + taddr = 0; } else { - LogPrint("gatewayscc","set taddr, prefix, prefix2 for %s\n",coin.c_str()); - taddr = 0; - prefix = 60; - prefix2 = 85; + prefix = p1; + prefix2 = p2; + wiftype = p3; + taddr = p4; + LogPrint("gatewayscc","set prefix %d, prefix2 %d, wiftype %d for %s\n",prefix,prefix2,wiftype,coin.c_str()); } if ( N == 0 || N > 15 || M > N ) { @@ -1030,7 +1038,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t { mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,totalsupply,gatewayspk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gatewayspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysBindOpRet('B',tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysBindOpRet('B',tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype))); } } CCerror = strprintf("cant find enough inputs"); @@ -1042,7 +1050,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction bindtx; CPubKey mypk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; - int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CCcontract_info *cp,C; + int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::string coin; struct CCcontract_info *cp,C; std::vector pubkeys,publishers; std::vectortxids; char str[67],depositaddr[64],txidaddr[64]; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1056,9 +1064,9 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin ) + if ( DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) { - CCerror = strprintf("invalid coin - bindtxid %s coin.%n",uint256_str(str,bindtxid),coin.c_str()); + CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } @@ -1099,7 +1107,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if ( GatewaysVerify(depositaddr,oracletxid,claimvout,coin,cointxid,deposithex,proof,merkleroot,destpub) != amount ) + if ( GatewaysVerify(depositaddr,oracletxid,claimvout,coin,cointxid,deposithex,proof,merkleroot,destpub,taddr,prefix,prefix2) != amount ) { CCerror = strprintf("deposittxid didnt validate"); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); @@ -1119,7 +1127,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CCcontract_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; + CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CCcontract_info *cp,C; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::string coin, deposithex; std::vector msigpubkeys,publishers; int64_t totalsupply,depositamount,tmpamount,inputs,CCchange=0; int32_t numvouts,claimvout,height; std::vector proof; uint256 hashBlock,tokenid,oracletxid,tmptxid,cointxid; char str[65],depositaddr[64],coinaddr[64],destaddr[64]; std::vector txids; @@ -1135,7 +1143,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || coin != refcoin ) { CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); @@ -1197,7 +1205,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction tx; CPubKey mypk,gatewayspk,signerpk; uint256 txid,tokenid,hashBlock,oracletxid,tmptokenid,tmpbindtxid,withdrawtxid; int32_t vout,numvouts; - int64_t nValue,totalsupply,inputs,CCchange=0,tmpamount; uint8_t funcid,K,M,N,taddr,prefix,prefix2; std::string coin,hex; + int64_t nValue,totalsupply,inputs,CCchange=0,tmpamount; uint8_t funcid,K,M,N,taddr,prefix,prefix2,wiftype; std::string coin,hex; std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C,*cpTokens,CTokens; std::vector > unspentOutputs; @@ -1214,7 +1222,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || coin != refcoin ) + if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || coin != refcoin ) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); @@ -1283,7 +1291,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc CPubKey mypk,withdrawpub,signerpk,gatewayspk; struct CCcontract_info *cp,C; CTransaction tx,tmptx; std::vector > unspentOutputs; char funcid,str[65],depositaddr[64]; int32_t numvouts; uint256 withdrawtxid,hashBlock,bindtxid,tokenid,oracletxid,tmptokenid; std::string coin,tmphex; int64_t amount,totalsupply; - uint8_t K=0,M,N,taddr,prefix,prefix2; std::vector pubkeys; + uint8_t K=0,M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); if ( txfee == 0 ) @@ -1318,7 +1326,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); @@ -1359,7 +1367,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); @@ -1383,7 +1391,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk,gatewayspk,signerpk,withdrawpub; struct CCcontract_info *cp,C; char funcid,str[65],depositaddr[64]; int64_t amount,totalsupply; std::string coin,tmphex; CTransaction tx,tmptx; uint256 withdrawtxid,hashBlock,tokenid,tmptokenid,bindtxid,oracletxid; int32_t numvouts; - uint8_t K=0,M,N,taddr,prefix,prefix2; std::vector pubkeys; + uint8_t K=0,M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); @@ -1418,7 +1426,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); @@ -1458,7 +1466,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); @@ -1482,7 +1490,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; struct CCcontract_info *cp,C; char str[65],depositaddr[64]; CTransaction tx; int32_t numvouts; uint256 withdrawtxid,bindtxid,oracletxid,tokenid,tmptokenid,hashBlock; std::string coin,hex; - uint8_t K,M,N,taddr,prefix,prefix2; std::vector pubkeys; int64_t amount,totalsupply; CPubKey withdrawpub; + uint8_t K,M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; int64_t amount,totalsupply; CPubKey withdrawpub; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); @@ -1524,7 +1532,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - else if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' + else if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); @@ -1546,7 +1554,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string coin,hex,pub; CPubKey mypk,gatewayspk,destpub; std::vector pubkeys,publishers; std::vector txids; - uint256 tmpbindtxid,hashBlock,txid,tokenid,oracletxid,cointxid; uint8_t M,N,taddr,prefix,prefix2; + uint256 tmpbindtxid,hashBlock,txid,tokenid,oracletxid,cointxid; uint8_t M,N,taddr,prefix,prefix2,wiftype; char depositaddr[65],coinaddr[65],str[65],destaddr[65],txidaddr[65]; std::vector proof; int32_t numvouts,vout,claimvout,height; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; std::vector > unspentOutputs; @@ -1561,7 +1569,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); @@ -1583,6 +1591,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) CCtxidaddr(txidaddr,txid); obj.push_back(Pair("deposittxidaddr",txidaddr)); _GetCCaddress(destaddr,EVAL_TOKENS,destpub); + obj.push_back(Pair("depositaddr",depositaddr)); obj.push_back(Pair("tokens_destination_address",destaddr)); pub=HexStr(destpub); obj.push_back(Pair("claim_pubkey",pub)); @@ -1599,7 +1608,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string coin,hex; CPubKey mypk,gatewayspk,withdrawpub,signerpk; - std::vector msigpubkeys; uint256 hashBlock,tokenid,txid,tmpbindtxid,tmptokenid,oracletxid,withdrawtxid; uint8_t K,M,N,taddr,prefix,prefix2; + std::vector msigpubkeys; uint256 hashBlock,tokenid,txid,tmpbindtxid,tmptokenid,oracletxid,withdrawtxid; uint8_t K,M,N,taddr,prefix,prefix2,wiftype; char funcid,depositaddr[65],coinaddr[65],tokensaddr[65],destaddr[65],str[65],withaddr[65],numstr[32],signeraddr[65],txidaddr[65]; int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,amount,nValue; struct CCcontract_info *cp,C; std::vector > unspentOutputs; @@ -1615,7 +1624,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin ) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); @@ -1651,12 +1660,12 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) continue; } Getscriptaddress(destaddr,tx.vout[1].scriptPubKey); - Getscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG); + GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2); if ( strcmp(destaddr,tokensaddr) == 0 ) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("withdrawtxid",uint256_str(str,tx.GetHash()))); - CCtxidaddr(txidaddr,tx.GetHash()); + CCCustomtxidaddr(txidaddr,tx.GetHash(),taddr,prefix,prefix2); obj.push_back(Pair("withdrawtxidaddr",txidaddr)); obj.push_back(Pair("withdrawaddr",withaddr)); sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); @@ -1665,7 +1674,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) if ( queueflag != 0 ) { obj.push_back(Pair("depositaddr",depositaddr)); - Getscriptaddress(signeraddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); + GetCustomscriptaddress(signeraddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG,taddr,prefix,prefix2); obj.push_back(Pair("signeraddr",signeraddr)); } if (N>1) @@ -1688,7 +1697,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string coin,hex; CPubKey mypk,gatewayspk,withdrawpub; std::vector msigpubkeys; - uint256 withdrawtxid,hashBlock,txid,tokenid,tmptokenid,oracletxid; uint8_t K,M,N,taddr,prefix,prefix2; + uint256 withdrawtxid,hashBlock,txid,tokenid,tmptokenid,oracletxid; uint8_t K,M,N,taddr,prefix,prefix2,wiftype; char depositaddr[65],coinaddr[65],str[65],numstr[32],withaddr[65],txidaddr[65]; int32_t i,n,numvouts,vout,queueflag; int64_t totalsupply,nValue,amount; struct CCcontract_info *cp,C; std::vector > unspentOutputs; @@ -1703,7 +1712,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B' || refcoin != coin) + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); @@ -1732,9 +1741,9 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) UniValue obj(UniValue::VOBJ); obj.push_back(Pair("completesigningtxid",uint256_str(str,txid))); obj.push_back(Pair("withdrawtxid",uint256_str(str,withdrawtxid))); - CCtxidaddr(txidaddr,withdrawtxid); + CCCustomtxidaddr(txidaddr,withdrawtxid,taddr,prefix,prefix2); obj.push_back(Pair("withdrawtxidaddr",txidaddr)); - Getscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG); + GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2); obj.push_back(Pair("withdrawaddr",withaddr)); obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); @@ -1752,7 +1761,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) UniValue GatewaysList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2; std::vector pubkeys; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); SetCCtxids(addressIndex,cp->unspendableCCaddr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) @@ -1760,7 +1769,7 @@ UniValue GatewaysList() txid = it->first.txhash; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 0 ) + if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) { result.push_back(uint256_str(str,txid)); } @@ -1769,11 +1778,60 @@ UniValue GatewaysList() return(result); } +UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey) +{ + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction tx; + std::string coin; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; + + cp = CCinit(&C,EVAL_GATEWAYS); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + GetCustomscriptaddress(addr,CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG,taddr,prefix,prefix2); + result.push_back(Pair("result","success")); + result.push_back(Pair("address",addr)); + return(result); +} + +UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key) +{ + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction tx; + std::string coin,priv; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; + + cp = CCinit(&C,EVAL_GATEWAYS); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + return(""); + } + + priv=EncodeCustomSecret(key,wiftype); + result.push_back(Pair("result","success")); + result.push_back(Pair("address",priv.c_str())); + return(result); +} + UniValue GatewaysInfo(uint256 bindtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaystokens[64]; - uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; + uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2,wiftype; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t numvouts,totalsupply,remaining; std::vector msigpubkeys; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1785,7 +1843,7 @@ UniValue GatewaysInfo(uint256 bindtxid) LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); } - if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2) != 'B') + if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); @@ -1796,7 +1854,7 @@ UniValue GatewaysInfo(uint256 bindtxid) result.push_back(Pair("result","success")); result.push_back(Pair("name","Gateways")); depositaddr[0] = 0; - if ( tx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[tx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2) != 0 && M <= N && N > 0 ) + if ( tx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[tx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 && M <= N && N > 0 ) { if ( N > 1 ) { diff --git a/src/key_io.cpp b/src/key_io.cpp index f04c4da04..1953d9623 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -206,6 +206,19 @@ std::string EncodeSecret(const CKey& key) return ret; } +std::string EncodeCustomSecret(const CKey& key,uint8_t secret_key) +{ + assert(key.IsValid()); + std::vector data = std::vector(1,secret_key);; + data.insert(data.end(), key.begin(), key.end()); + if (key.IsCompressed()) { + data.push_back(1); + } + std::string ret = EncodeBase58Check(data); + memory_cleanse(data.data(), data.size()); + return ret; +} + CExtPubKey DecodeExtPubKey(const std::string& str) { CExtPubKey key; diff --git a/src/key_io.h b/src/key_io.h index 3606ad09f..72823d57e 100644 --- a/src/key_io.h +++ b/src/key_io.h @@ -18,6 +18,7 @@ CKey DecodeSecret(const std::string& str); std::string EncodeSecret(const CKey& key); +std::string EncodeCustomSecret(const CKey& key,uint8_t secret_key); CExtKey DecodeExtKey(const std::string& str); std::string EncodeExtKey(const CExtKey& extkey); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 208b3cf02..96e58b3af 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -470,6 +470,8 @@ static const CRPCCommand vRPCCommands[] = // Gateways { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, + { "gateways", "gatewaysexternaladdress", &gatewaysexternaladdress, true }, + { "gateways", "gatewaysdumpprivkey", &gatewaysdumpprivkey, true }, { "gateways", "gatewaysinfo", &gatewaysinfo, true }, { "gateways", "gatewaysbind", &gatewaysbind, true }, { "gateways", "gatewaysdeposit", &gatewaysdeposit, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index b812ccc9d..3abc6748c 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -293,6 +293,8 @@ extern UniValue cclib(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); extern UniValue gatewaysinfo(const UniValue& params, bool fHelp); +extern UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp); +extern UniValue gatewaysexternaladdress(const UniValue& params, bool fHelp); extern UniValue gatewaysbind(const UniValue& params, bool fHelp); extern UniValue gatewaysdeposit(const UniValue& params, bool fHelp); extern UniValue gatewaysclaim(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index abd0b9696..b0bdd6bdd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6140,6 +6140,47 @@ UniValue gatewayslist(const UniValue& params, bool fHelp) return(GatewaysList()); } +UniValue gatewaysexternaladdress(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; CPubKey pubkey; + + if ( fHelp || params.size() != 2) + throw runtime_error("gatewaysexternaladdress bindtxid pubkey\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + pubkey = ParseHex(params[1].get_str().c_str()); + return(GatewaysExternalAddress(bindtxid,pubkey)); +} + +UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; + + if ( fHelp || params.size() != 2) + throw runtime_error("gatewaysexternaladdress bindtxid address\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + LOCK2(cs_main, pwalletMain->cs_wallet); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + std::string strAddress = params[1].get_str(); + CTxDestination dest = DecodeDestination(strAddress); + if (!IsValidDestination(dest)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid transparent address"); + } + const CKeyID *keyID = boost::get(&dest); + if (!keyID) { + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); + } + CKey vchSecret; + if (!pwalletMain->GetKey(*keyID, vchSecret)) { + throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); + } + return(GatewaysDumpPrivKey(bindtxid,vchSecret)); +} + UniValue gatewaysinfo(const UniValue& params, bool fHelp) { uint256 txid; @@ -6155,9 +6196,11 @@ UniValue gatewaysinfo(const UniValue& params, bool fHelp) UniValue gatewaysbind(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 tokenid,oracletxid; int32_t i; int64_t totalsupply; std::vector pubkeys; uint8_t M,N; std::string hex,coin; std::vector pubkey; - if ( fHelp || params.size() < 6 ) - throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s)\n"); + UniValue result(UniValue::VOBJ); uint256 tokenid,oracletxid; int32_t i; int64_t totalsupply; std::vector pubkeys; + uint8_t M,N,p1,p2,p3,p4=0; std::string hex,coin; std::vector pubkey; + + if ( fHelp || params.size() < 9 ) + throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s) pubtype p2shtype wiftype [taddr]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -6179,7 +6222,11 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp) throw runtime_error("invalid destination pubkey"); pubkeys.push_back(pubkey2pk(pubkey)); } - hex = GatewaysBind(0,coin,tokenid,totalsupply,oracletxid,M,N,pubkeys); + p1 = atoi((char *)params[6+N].get_str().c_str()); + p2 = atoi((char *)params[6+N+1].get_str().c_str()); + p3 = atoi((char *)params[6+N+2].get_str().c_str()); + if (params.size() == 9+N) p4 = atoi((char *)params[6+N+3].get_str().c_str()); + hex = GatewaysBind(0,coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,p1,p2,p3,p4); RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) { From af628f2706020eaaead58eb903d6f8178480e314 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 05:13:16 -1100 Subject: [PATCH 2015/3904] The owner doesn't need to be the creator --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 603e776b8..53a505a12 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -995,10 +995,10 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { txid = it->first.txhash; vout = (int32_t)it->first.index; - char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != 1 || vout != 0 ) continue; - if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) + if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 )//&& pk == mypk ) { a.push_back(rogue_playerobj(playerdata,txid)); //result.push_back(Pair("playerdata",rogue_playerobj(playerdata))); From ba863048dca89eb0e133857e0eef9815abc0a11b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 05:17:47 -1100 Subject: [PATCH 2016/3904] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 53a505a12..8a6f1530f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -433,13 +433,13 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub //memcpy(&gametxid,script+2,sizeof(gametxid)); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used return(0); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); - } + } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); } } return(-1); From 5ad59bf6146c75a3816c9632db991a67a69aa9af Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 05:22:24 -1100 Subject: [PATCH 2017/3904] Missing () --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8a6f1530f..b9ea82d65 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -185,10 +185,10 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, int32_t ®slot, CPubKey // try no tokens case: if (vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q')) return(f); - else if (f = DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy) != 0) { // it is tokens + else if ( (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0) + { if (f != 'c') GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx - if (vopretNonfungible.size() > 2 && E_UNMARSHAL(vopretNonfungible, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q')) { return(f); From 17a8707c624f0c1b92e1f8878c17db476ab39929 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 05:26:44 -1100 Subject: [PATCH 2018/3904] Test --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b9ea82d65..42246f190 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -187,12 +187,14 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, int32_t ®slot, CPubKey return(f); else if ( (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0) { + fprintf(stderr,"f %c %d\n",f,f); if (f != 'c') GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx if (vopretNonfungible.size() > 2 && E_UNMARSHAL(vopretNonfungible, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q')) { return(f); } + fprintf(stderr,"e.%d f.%c game.%s slot.%dВыходи и жди ,ок\n",e,f,gametxid.GetHex().c_str(),regslot); } return(0); From 785b17d3991cec88a4169392e5f44cc88416ae90 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 11 Feb 2019 17:42:34 +0100 Subject: [PATCH 2019/3904] GatewaysCC code cleanup --- src/cc/dapps/oraclefeed.c | 32 +++------------- src/cc/gateways.cpp | 78 +++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 68 deletions(-) diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index cc6b45037..cf7a2eacb 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -372,29 +372,6 @@ bits256 broadcasttx(char *refcoin,char *acname,cJSON *hexjson) return(txid); } -bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis) -{ - char numstr[32],*retstr,str[65]; cJSON *retjson; bits256 txid; - memset(txid.bytes,0,sizeof(txid)); - sprintf(numstr,"%.8f",(double)satoshis/SATOSHIDEN); - if ( (retjson= get_cli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"","")) != 0 ) - { - fprintf(stderr,"unexpected sendtoaddress json.(%s)\n",jprint(retjson,0)); - free_json(retjson); - } - else if ( retstr != 0 ) - { - if ( strlen(retstr) >= 64 ) - { - retstr[64] = 0; - decode_hex(txid.bytes,32,retstr); - } - fprintf(stderr,"sendtoaddress %s %.8f txid.(%s)\n",destaddr,(double)satoshis/SATOSHIDEN,bits256_str(str,txid)); - free(retstr); - } - return(txid); -} - int32_t get_coinheight(char *refcoin,char *acname) { cJSON *retjson; char *retstr; int32_t height=0; @@ -643,7 +620,7 @@ char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawadd else txfee = 10000; if ( satoshis < txfee ) { - printf("createrawtx satoshis %.8f < txfee %.8f\n",(double)satoshis/SATOSHIDEN,(double)txfee/SATOSHIDEN); + printf("createrawtx: satoshis %.8f < txfee %.8f\n",(double)satoshis/SATOSHIDEN,(double)txfee/SATOSHIDEN); return(0); } sprintf(array,"\'[\"%s\"]\'",depositaddr); @@ -912,8 +889,8 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t if ( (clijson=addsignature(refcoin,"",rawtx,M)) != 0 && is_cJSON_True(jobj(clijson,"complete")) != 0) { txid=gatewayscompletesigning(refcoin,acname,withdrawtxid,jstr(clijson,"hex")); - if (txid.txid!=zeroid.txid) fprintf(stderr,"#WITHDRAW (%s) complete signing tx sent - %s\n",bits256_str(str,withdrawtxid),bits256_str(str1,txid)); - else fprintf(stderr,"error broadcasting tx on %s",acname); + if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s 1of1\n",bits256_str(str,withdrawtxid)); + else fprintf(stderr,"### SIGNING error broadcasting tx on %s",acname); free_json(clijson); processed++; } @@ -978,7 +955,8 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t withdrawaddr = jstr(item,"withdrawaddr"); fprintf(stderr,"### WITHDRAW %.8f %s sent to %s\n",amount,refcoin,withdrawaddr); txid=gatewaysmarkdone(refcoin,acname,completetxid); - if (txid.txid!=zeroid.txid) fprintf(stderr,"### MARKDONE withdraw %s\n",bits256_str(str,withdrawtxid)); + if (txid.txid!=zeroid.txid) fprintf(stderr,"### MARKDONE withdraw %s\n",bits256_str(str,withdrawtxid)); + else fprintf(stderr,"### MARKDONE error broadcasting tx on %s\n",refcoin); } else fprintf(stderr,"### WITHDRAW error broadcasting tx on %s\n",refcoin); } diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index af9038f81..02e30940f 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -148,6 +148,11 @@ */ // start of consensus code +#define KMD_PUBTYPE 60 +#define KMD_P2SHTYPE 85 +#define KMD_WIFTYPE 188 +#define KMD_TADDR 0 + CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector gatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; @@ -174,31 +179,28 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui depositaddr[0] = 0; if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> totalsupply; ss >> oracletxid; ss >> M; ss >> N; ss >> gatewaypubkeys; ss >> taddr; ss >> prefix; ss >> prefix2; ss >> wiftype) != 0 ) { - if ( prefix == 60 ) + if ( prefix == KMD_PUBTYPE && prefix2 == KMD_P2SHTYPE ) { if ( N > 1 ) { strcpy(depositaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys))).ToString().c_str()); - //LogPrint("gatewayscc","f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr); + LogPrint("gatewayscc-1","f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr); } else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG); } - else if (prefix == 28 && prefix2 == 50) + else { if ( N > 1 ) strcpy(depositaddr,CCustomBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys)),taddr,prefix,prefix2).ToString().c_str()); else GetCustomscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG,taddr,prefix,prefix2); } - else - { - LogPrint("gatewayscc","need to generate non-KMD addresses prefix.%d\n",prefix); - } return(f); - } else LogPrint("gatewayscc","error decoding bind opret\n"); + } else LogPrint("gatewayscc-1","error decoding bind opret\n"); return(0); } CScript EncodeGatewaysDepositOpRet(uint8_t funcid,uint256 bindtxid,std::string refcoin,std::vector publishers,std::vectortxids,int32_t height,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << refcoin << bindtxid << publishers << txids << height << cointxid << claimvout << deposithex << proof << destpub << amount); return(opret); } @@ -206,6 +208,7 @@ CScript EncodeGatewaysDepositOpRet(uint8_t funcid,uint256 bindtxid,std::string r uint8_t DecodeGatewaysDepositOpRet(const CScript &scriptPubKey,uint256 &bindtxid,std::string &refcoin,std::vector&publishers,std::vector&txids,int32_t &height,uint256 &cointxid, int32_t &claimvout,std::string &deposithex,std::vector &proof,CPubKey &destpub,int64_t &amount) { std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> refcoin; ss >> bindtxid; ss >> publishers; ss >> txids; ss >> height; ss >> cointxid; ss >> claimvout; ss >> deposithex; ss >> proof; ss >> destpub; ss >> amount) != 0 ) @@ -276,6 +279,7 @@ uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256& tokeni CScript EncodeGatewaysPartialOpRet(uint8_t funcid, uint256 withdrawtxid,std::string refcoin,uint8_t K, CPubKey signerpk,std::string hex) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << K << signerpk << hex); return(opret); } @@ -302,6 +306,7 @@ CScript EncodeGatewaysCompleteSigningOpRet(uint8_t funcid,uint256 withdrawtxid,s uint8_t DecodeGatewaysCompleteSigningOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,uint8_t &K,std::string &hex) { std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> K; ss >> hex) != 0 ) @@ -314,6 +319,7 @@ uint8_t DecodeGatewaysCompleteSigningOpRet(const CScript &scriptPubKey,uint256 & CScript EncodeGatewaysMarkDoneOpRet(uint8_t funcid,uint256 withdrawtxid,std::string refcoin,uint256 completetxid) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << completetxid); return(opret); } @@ -321,6 +327,7 @@ CScript EncodeGatewaysMarkDoneOpRet(uint8_t funcid,uint256 withdrawtxid,std::str uint8_t DecodeGatewaysMarkDoneOpRet(const CScript &scriptPubKey, uint256 &withdrawtxid, std::string &refcoin, uint256 &completetxid) { std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> completetxid;) != 0 ) @@ -353,6 +360,7 @@ uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey) int64_t IsGatewaysvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; + if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) { if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) @@ -365,6 +373,7 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; + numvins = tx.vin.size(); numvouts = tx.vout.size(); for (i=0; idata; txid = zeroid; char str[65]; - //LogPrint("gatewayscc","start reverse scan %s\n",uint256_str(str,batontxid)); + LogPrint("gatewayscc-2","start reverse scan %s\n",uint256_str(str,batontxid)); while ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) { - //LogPrint("gatewayscc","check %s\n",uint256_str(str,batontxid)); + LogPrint("gatewayscc-2","check %s\n",uint256_str(str,batontxid)); if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid ) { - //LogPrint("gatewayscc","decoded %s\n",uint256_str(str,batontxid)); + LogPrint("gatewayscc-2","decoded %s\n",uint256_str(str,batontxid)); if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) { len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()); @@ -442,20 +451,20 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid ) { txid = batontxid; - //LogPrint("gatewayscc","set txid\n"); + LogPrint("gatewayscc-2","set txid\n"); return(mhash); } else { - //LogPrint("gatewayscc","missing hash\n"); + LogPrint("gatewayscc-2","missing hash\n"); return(zeroid); } - } //else LogPrint("gatewayscc","height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); + } else LogPrint("gatewayscc-2","height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); batontxid = bhash; - // LogPrint("gatewayscc","new hash %s\n",uint256_str(str,batontxid)); + LogPrint("gatewayscc-2","new hash %s\n",uint256_str(str,batontxid)); } else break; } - LogPrint("gatewayscc","end of loop\n"); + LogPrint("gatewayscc-2","end of loop\n"); return(zeroid); } @@ -529,7 +538,7 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout } if ( txid == cointxid ) { - LogPrint("gatewayscc","verified proof for cointxid in merkleroot\n"); + LogPrint("gatewayscc-1","verified proof for cointxid in merkleroot\n"); return(nValue); } else LogPrint("gatewayscc","(%s) != (%s) or txid %s mismatch.%d or script mismatch\n",refdepositaddr,destaddr,uint256_str(str,txid),txid != cointxid); } else LogPrint("gatewayscc","claimaddr.(%s) != destpubaddr.(%s)\n",claimaddr,destpubaddr); @@ -544,8 +553,6 @@ int64_t GatewaysDepositval(CTransaction tx,CPubKey mypk) { if ( DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,claimpubkey,amount) == 'D' && claimpubkey == mypk ) { - // coin, bindtxid, publishers - //LogPrint("gatewayscc","need to validate deposittxid more\n"); return(amount); } } @@ -603,11 +610,10 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("no vouts"); else { - //LogPrint("gatewayscc","check amounts\n"); + //LogPrint("gatewayscc-1","check amounts\n"); // if ( GatewaysExactAmounts(cp,eval,tx,1,10000) == false ) // { - // LogPrint("gatewayscc","Gatewaysget invalid amount\n"); - // return false; + // return eval->Invalid("invalid inputs vs. outputs!"); // } // else // { @@ -867,7 +873,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & } retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) - fprintf(stderr,"Gateways tx validated\n"); + LogPrint("gatewayscc","Gateways tx validated\n"); else fprintf(stderr,"Gateways tx invalid\n"); return(retval); // } @@ -891,18 +897,11 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP GetTokensCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); threshold = total/(maxinputs+1); - LogPrint("gatewayscc","check %s for gateway inputs\n",coinaddr); + LogPrint("gatewayscc-1","check %s for gateway inputs\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; vout = (int32_t)it->first.index; - if ( it->second.satoshis < threshold ) - continue; - // for (j=0; j 15 || M > N ) { @@ -1057,7 +1056,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - //LogPrint("gatewayscc","GatewaysDeposit ht.%d %s %.8f numpks.%d\n",height,refcoin.c_str(),(double)amount/COIN,(int32_t)pubkeys.size()); + LogPrint("gatewayscc-1","GatewaysDeposit ht.%d %s %.8f numpks.%d\n",height,refcoin.c_str(),(double)amount/COIN,(int32_t)pubkeys.size()); if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); @@ -1094,9 +1093,6 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: LogPrint("gatewayscc","cointxid.%s m.%d of n.%d\n",uint256_str(str,cointxid),m,n); if ( merkleroot == zeroid || m < n/2 ) { - //uint256 tmp; - //decode_hex((uint8_t *)&tmp,32,(char *)"90aedc2f19200afc9aca2e351438d011ebae8264a58469bf225883045f61917f"); - //merkleroot = revuint256(tmp); CCerror = strprintf("couldnt find merkleroot for ht.%d %s oracle.%s m.%d vs n.%d",height,coin.c_str(),uint256_str(str,oracletxid),m,n); LogPrint("gatewayscc","%s\n", CCerror.c_str() ); return(""); From 972618e4fdc987c888552de9f1a8022586280cf1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 06:14:18 -1100 Subject: [PATCH 2020/3904] Fix rogue_highlanderopretdecode --- src/cc/rogue_rpc.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 42246f190..e6ccc3352 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -176,27 +176,25 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CP uint8_t rogue_highlanderopretdecode(uint256 &gametxid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, CScript scriptPubKey) { - std::string name, description; - std::vector vorigPubkey; - std::vector vopretNonfungible, vopret, vopretDummy; - uint8_t e, f; uint256 tokenid; std::vector voutPubkeys; + std::string name, description; std::vector vorigPubkey; + std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; + uint8_t e, f,*script; uint256 tokenid; std::vector voutPubkeys; GetOpReturnData(scriptPubKey, vopret); - // try no tokens case: - if (vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q')) - return(f); - else if ( (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0) + script = (uint8_t *)vopret.data(); + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,vopretNonfungible)) == 'c' ) { - fprintf(stderr,"f %c %d\n",f,f); - if (f != 'c') - GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx - if (vopretNonfungible.size() > 2 && E_UNMARSHAL(vopretNonfungible, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q')) - { - return(f); - } - fprintf(stderr,"e.%d f.%c game.%s slot.%dВыходи и жди ,ок\n",e,f,gametxid.GetHex().c_str(),regslot); + vopret = vopretNonfungible; } - + else if ( script[1] == 't' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) + { + GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx + } + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + { + return(f); + } + fprintf(stderr,"e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); return(0); } @@ -889,7 +887,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); - CScript opret = rogue_highlanderopret(funcid, gametxid, regslot,mypk, newdata); + CScript opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, newdata); if ( newdata.size() == 0 ) rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); else From 8537216d9ac5fab92a58270ca0a3ab6d3517048b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 06:36:14 -1100 Subject: [PATCH 2021/3904] Suppress special chars --- src/cc/rogue/state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index dd54afe25..96d576501 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1381,7 +1381,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) { - static int32_t didinit; + static int32_t didinit; int32_t i; if ( didinit == 0 ) { struct rogue_state R; char keystrokes[3]; @@ -1397,6 +1397,9 @@ void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) THING *obj = new_item(); rogue_restoreobject(obj,item); strcpy(packitemstr,inv_name(obj,FALSE)); + for (i=0; packitemstr[i]!=0; i++) + if ( packitemstr[i] < ' ' || (uint8_t)packitemstr[i] >= 0x80 ) + packitemstr[i] = ' '; //fprintf(stderr,"packitem.(%s)\n",packitemstr); free(obj); } From 7a48d681ed49a5c208fa0fc3522a0256e70fef18 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 07:11:17 -1100 Subject: [PATCH 2022/3904] vopret = vopretNonfungible; --- src/cc/rogue/state.c | 3 --- src/cc/rogue_rpc.cpp | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 96d576501..817993c17 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1397,9 +1397,6 @@ void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) THING *obj = new_item(); rogue_restoreobject(obj,item); strcpy(packitemstr,inv_name(obj,FALSE)); - for (i=0; packitemstr[i]!=0; i++) - if ( packitemstr[i] < ' ' || (uint8_t)packitemstr[i] >= 0x80 ) - packitemstr[i] = ' '; //fprintf(stderr,"packitem.(%s)\n",packitemstr); free(obj); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e6ccc3352..f33d4d583 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -189,6 +189,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, int32_t ®slot, CPubKey else if ( script[1] == 't' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) { GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx + vopret = vopretNonfungible; } if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) { From 73c33eb2a3e383f6b91f649aa5f8e2b037b19b17 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 11 Feb 2019 22:53:08 +0500 Subject: [PATCH 2023/3904] added burned non-fungible tokens validation --- src/cc/CCtokens.cpp | 96 +++++++++++++++++++++++++++++++++++++++++---- src/cc/CCtokens.h | 2 + 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index eb802b65d..bcebb1a09 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -236,7 +236,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & std::vector vopretExtra, tmporigpubkey, ignorepubkey; uint8_t funcid, evalCodeInOpret; char destaddr[64], origaddr[64], CCaddr[64]; - std::vector voutTokenPubkeys; + std::vector voutTokenPubkeys, vinTokenPubkeys; //return true; @@ -257,7 +257,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); //else if (IsCCInput(tx.vin[0].scriptSig) != 0) - // return eval->Invalid("illegal token vin0"); // this validation was removed because some token tx might not have normal vins + // return eval->Invalid("illegal token vin0"); // <-- this validation was removed because some token tx might not have normal vins else if (funcid != 'c') { if (tokenid == zeroid) @@ -270,6 +270,18 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & } } + // validate spending from token cc addr: allowed only for burned non-fungible tokens: + if (ExtractTokensVinPubkeys(tx, vinTokenPubkeys) && std::find(vinTokenPubkeys.begin(), vinTokenPubkeys.end(), GetUnspendable(cp, NULL)) != vinTokenPubkeys.end()) { + // validate spending from token unspendable cc addr: + int64_t burnedAmount = HasBurnedTokensvouts(cp, eval, tx, tokenid); + if (burnedAmount > 0) { + std::vector vopretNonfungible; + GetNonfungibleData(tokenid, vopretNonfungible); + if( vopretNonfungible.empty() ) + return eval->Invalid("spending cc marker not supported for fungible tokens"); + } + } + switch (funcid) { case 'c': // create wont be called to be verified as it has no CC inputs @@ -445,8 +457,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true return(0); } - //TODO: validate cc vouts are EVAL_TOKENS! - if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here + if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) { if (goDeeper) { //validate all tx @@ -489,7 +500,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true GetNonfungibleData(reftokenid, vopretNonfungible); - voutPubkeys = FilterOutTokensUnspendablePk(voutPubkeysInOpret); + voutPubkeys = FilterOutTokensUnspendablePk(voutPubkeysInOpret); // cannot send tokens to token unspendable cc addr (only marker is allowed there) // NOTE: evalcode order in vouts is important: // non-fungible-eval -> EVAL_TOKENS -> assets-eval @@ -551,7 +562,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true // maybe it is single-eval or dual/three-eval token change? std::vector vinPubkeys, vinPubkeysUnfiltered; ExtractTokensVinPubkeys(tx, vinPubkeysUnfiltered); - vinPubkeys = FilterOutTokensUnspendablePk(vinPubkeysUnfiltered); + vinPubkeys = FilterOutTokensUnspendablePk(vinPubkeysUnfiltered); // cannot send tokens to token unspendable cc addr (only marker is allowed there) for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it), std::string("single-eval cc1 self vin pk"))); @@ -767,7 +778,6 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() found incorrect non-fungible opret payload for vintxid=" << vintxid.GetHex() << std::endl); continue; } - // non-fungible evalCode2 cc contract should also check if there exists only one non-fungible vout with amount = 1 } @@ -790,6 +800,78 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C return(totalinputs); } +// checks if any token vouts are sent to 'dead' pubkey +int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, uint256 reftokenid) +{ + uint8_t dummyEvalCode; + uint256 tokenIdOpret; + std::vector voutPubkeys, voutPubkeysDummy; + std::vector vopretExtra, vopretNonfungible; + + uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim + uint8_t evalCode2 = 0; // will be checked if zero or not + + // test vouts for possible token use-cases: + std::vector> testVouts; + + int32_t n = tx.vout.size(); + // just check boundaries: + if (n == 0) { + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "HasBurnedTokensvouts() incorrect params: tx.vout.size() == 0, txid=" << tx.GetHash().GetHex() << std::endl); + return(0); + } + + + if (DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeysDummy, vopretExtra) == 0) { + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "HasBurnedTokensvouts() cannot parse opret DecodeTokenOpRet returned 0, txid=" << tx.GetHash().GetHex() << std::endl); + return 0; + } + + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "HasBurnedTokensvouts() vopretExtra=" << HexStr(vopretExtra) << std::endl); + + GetNonfungibleData(reftokenid, vopretNonfungible); + + if (vopretNonfungible.size() > 0) + evalCode = vopretNonfungible.begin()[0]; + if (vopretExtra.size() > 0) + evalCode2 = vopretExtra.begin()[0]; + + if (evalCode == EVAL_TOKENS && evalCode2 != 0) { + evalCode = evalCode2; + evalCode2 = 0; + } + + voutPubkeys.push_back(pubkey2pk(ParseHex(CC_BURNPUBKEY))); + + int64_t burnedAmount = 0; + + for (int i = 0; i < tx.vout.size(); i++) { + + if (tx.vout[i].scriptPubKey.IsPayToCryptoCondition()) + { + // make all possible token vouts for dead pk: + for (std::vector::iterator it = voutPubkeys.begin(); it != voutPubkeys.end(); it++) { + testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[i].nValue, *it), std::string("single-eval cc1 burn pk"))); + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode, evalCode2, tx.vout[i].nValue, *it), std::string("three-eval cc1 burn pk"))); + + if (evalCode2 != 0) + // also check in backward evalcode order: + testVouts.push_back(std::make_pair(MakeTokensCC1vout(evalCode2, evalCode, tx.vout[i].nValue, *it), std::string("three-eval cc1 burn pk backward-eval"))); + } + + // try all test vouts: + for (auto t : testVouts) { + if (t.first == tx.vout[i]) { + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "HasBurnedTokensvouts() burned amount=" << tx.vout[i].nValue << " msg=" << t.second << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " txid=" << tx.GetHash().GetHex() << " tokenid=" << reftokenid.GetHex() << std::endl); + burnedAmount += tx.vout[i].nValue; + } + } + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "HasBurnedTokensvouts() no burned vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + } + } + + return burnedAmount; +} std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, std::string description, std::vector nonfungibleData) { diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index 231b64ac9..791107648 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -30,6 +30,8 @@ bool TokensValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description, std::vector nonfungibleData); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); +bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys); +int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, uint256 reftokenid); int64_t GetTokenBalance(CPubKey pk, uint256 tokenid); UniValue TokenInfo(uint256 tokenid); From 672b3939f6eafed26ae00bf2047e603c88eb66a0 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 11 Feb 2019 23:27:39 +0500 Subject: [PATCH 2024/3904] added cc marker spending in rogue_register --- src/cc/CCtokens.cpp | 2 +- src/cc/rogue_rpc.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index bcebb1a09..cb8c65342 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -909,7 +909,7 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st mtx.vout.push_back(MakeTokensCC1vout(destEvalCode, tokensupply, mypk)); //mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); // old marker (non-burnable because spending could not be validated) // NOTE: we should prevent spending fake-tokens from this marker in IsTokenvout(): - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to token cc addr, burnable and validated + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to token cc addr, burnable and validated, this vout must be=1 return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e6ccc3352..14d6f4a09 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -712,6 +712,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find enough normal funds for buyin")); if ( playertxid != zeroid ) AddNormalinputs2(mtx,txfee,10); + mtx.vin.push_back(CTxIn(playertxid, 1)); // spending cc marker as token is being burned mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); From cb0db91e9fbc4a327efd2f3f40ac987095c5aa30 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 11 Feb 2019 23:31:37 +0500 Subject: [PATCH 2025/3904] added playertxid check for non zero --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 14d6f4a09..8ee7a0528 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -712,7 +712,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find enough normal funds for buyin")); if ( playertxid != zeroid ) AddNormalinputs2(mtx,txfee,10); - mtx.vin.push_back(CTxIn(playertxid, 1)); // spending cc marker as token is being burned + if (playertxid != zeroid) + mtx.vin.push_back(CTxIn(playertxid, 1)); // spending cc marker as token is being burned mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); From 9494baa69b1970fa4dde1cfcf1ae027bec2bee61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 07:40:11 -1100 Subject: [PATCH 2026/3904] Tokens exemption --- src/cc/assets.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 6f93da01b..9b859e54c 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -153,7 +153,10 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) return true; - + + if (strcmp(ASSETCHAINS_SYMBOL, "ROGUE") == 0 && chainActive.Height() <= 12500) + return true; + if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); From 9c47a23df909ec31b36289b193cdd4b539a2eae2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:03:28 -1100 Subject: [PATCH 2027/3904] Print --- src/cc/rogue_rpc.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f33d4d583..e8d6cd574 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -174,20 +174,21 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CP return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, CScript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, CScript scriptPubKey) { std::string name, description; std::vector vorigPubkey; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; - uint8_t e, f,*script; uint256 tokenid; std::vector voutPubkeys; - + uint8_t e, f,*script; std::vector voutPubkeys; + tokenid = zeroid; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,vopretNonfungible)) == 'c' ) { vopret = vopretNonfungible; } - else if ( script[1] == 't' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) + else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) { + fprintf(stderr,"decode opret %c\n",script[1]); GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; } @@ -424,14 +425,11 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,tokenid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { - //GetOpReturnData(playertx.vout[numvouts-1].scriptPubKey,vopret); - //script = (uint8_t *)vopret.data(); - if ( (f= rogue_highlanderopretdecode(gametxid,regslot,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { - //memcpy(&gametxid,script+2,sizeof(gametxid)); if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); @@ -442,7 +440,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); } - } + } else fprintf(stderr,"couldnt get playertxid.%s\n",playertxid.GetHex().c_str()); return(-1); } From 183a5e465bc5405136a0daf4de342d845b28ccd3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:06:53 -1100 Subject: [PATCH 2028/3904] +print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e8d6cd574..776636e12 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -188,7 +188,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t } else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) { - fprintf(stderr,"decode opret %c\n",script[1]); + fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; } From 533d95de182391d72fa4d692990dcba957a4fe5e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:11:35 -1100 Subject: [PATCH 2029/3904] Test resin --- src/cc/assets.cpp | 4 ++-- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 9b859e54c..bba952782 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -154,8 +154,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) return true; - if (strcmp(ASSETCHAINS_SYMBOL, "ROGUE") == 0 && chainActive.Height() <= 12500) - return true; + //if (strcmp(ASSETCHAINS_SYMBOL, "ROGUE") == 0 && chainActive.Height() <= 12500) + // return true; if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 776636e12..09027d9f1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -433,7 +433,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); - if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) + if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used return(0); From 7a4072b4f1496f52f013d68d3ea1dd2a9679ba11 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 12 Feb 2019 00:14:08 +0500 Subject: [PATCH 2030/3904] test_burntx added --- src/rpc/server.cpp | 2 ++ src/rpc/server.h | 2 ++ src/wallet/rpcwallet.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 208b3cf02..77c714531 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -539,6 +539,8 @@ static const CRPCCommand vRPCCommands[] = { "hidden", "setmocktime", &setmocktime, true }, { "hidden", "test_ac", &test_ac, true }, { "hidden", "test_heirmarker", &test_heirmarker, true }, + { "hidden", "test_burntx", &test_burntx, true }, + #ifdef ENABLE_WALLET /* Wallet */ diff --git a/src/rpc/server.h b/src/rpc/server.h index b812ccc9d..9682cbf5c 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -474,5 +474,7 @@ extern UniValue paxwithdraw(const UniValue& params, bool fHelp); // test rpc: extern UniValue test_ac(const UniValue& params, bool fHelp); extern UniValue test_heirmarker(const UniValue& params, bool fHelp); +extern UniValue test_burntx(const UniValue& params, bool fHelp); + #endif // BITCOIN_RPCSERVER_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0087abf58..f20b1cb5c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7818,3 +7818,33 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); } +UniValue test_burntx(const UniValue& params, bool fHelp) +{ + // make fake token tx: + struct CCcontract_info *cp, C; + + if (fHelp || (params.size() != 1)) + throw runtime_error("incorrect params\n"); + if (ensure_CCrequirements(EVAL_TOKENS) < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + + uint256 tokenid = Parseuint256((char *)params[0].get_str().c_str()); + + CPubKey myPubkey = pubkey2pk(Mypubkey()); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + + int64_t normalInputs = AddNormalinputs(mtx, myPubkey, 10000, 60); + if (normalInputs < 10000) + throw runtime_error("not enough normals\n"); + + CPubKey burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY)); + + mtx.vin.push_back(CTxIn(tokenid, 1)); + mtx.vout.push_back(MakeTokensCC1vout(EVAL_TOKENS, 1, burnpk)); + + std::vector voutPubkeys; + voutPubkeys.push_back(burnpk); + + cp = CCinit(&C, EVAL_TOKENS); + return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, EncodeTokenOpRet(tokenid, voutPubkeys, CScript()))); +} From 706d798676c223b72ca750d6b4e27fc41916ea5d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:18:26 -1100 Subject: [PATCH 2031/3904] Restore exemption --- src/cc/assets.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index bba952782..9b859e54c 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -154,8 +154,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) return true; - //if (strcmp(ASSETCHAINS_SYMBOL, "ROGUE") == 0 && chainActive.Height() <= 12500) - // return true; + if (strcmp(ASSETCHAINS_SYMBOL, "ROGUE") == 0 && chainActive.Height() <= 12500) + return true; if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); From 431562b77d4c76c0115035737474f4ee7682c767 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:24:41 -1100 Subject: [PATCH 2032/3904] Rogue exemption in tokens --- src/cc/CCtokens.cpp | 3 ++- src/cc/assets.cpp | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index eb802b65d..e15cdbeb9 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -238,7 +238,8 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & char destaddr[64], origaddr[64], CCaddr[64]; std::vector voutTokenPubkeys; - //return true; + if (strcmp(ASSETCHAINS_SYMBOL, "ROGUE") == 0 && chainActive.Height() <= 12500) + return true; numvins = tx.vin.size(); numvouts = tx.vout.size(); diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 9b859e54c..18f93f903 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -153,10 +153,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) return true; - - if (strcmp(ASSETCHAINS_SYMBOL, "ROGUE") == 0 && chainActive.Height() <= 12500) - return true; - + if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); From 1754fb8821a73fc057d000a9f1ca64b0a100315c Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 12 Feb 2019 00:47:19 +0500 Subject: [PATCH 2033/3904] added CCaddr2set for test_burntx --- src/wallet/rpcwallet.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f20b1cb5c..e10ba621c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7846,5 +7846,11 @@ UniValue test_burntx(const UniValue& params, bool fHelp) voutPubkeys.push_back(burnpk); cp = CCinit(&C, EVAL_TOKENS); + + uint8_t tokenpriv[33]; + char unspendableTokenAddr[64]; + CPubKey unspPk = GetUnspendable(cp, tokenpriv); + GetCCaddress(cp, unspendableTokenAddr, unspPk); + CCaddr2set(cp, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, EncodeTokenOpRet(tokenid, voutPubkeys, CScript()))); } From 520074335a37b662d2ed03b2eb4885d0cd300b5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:47:53 -1100 Subject: [PATCH 2034/3904] 'T' in out 1 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 09027d9f1..61e70547f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -995,7 +995,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) txid = it->first.txhash; vout = (int32_t)it->first.index; //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( it->second.satoshis != 1 || vout != 0 ) + if ( it->second.satoshis != 1 || vout < 2 ) continue; if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 )//&& pk == mypk ) { From d4fd4ac5f1290f17f2ac125798adf199f619f15e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:49:47 -1100 Subject: [PATCH 2035/3904] >1 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 61e70547f..be66eb4f8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -995,7 +995,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) txid = it->first.txhash; vout = (int32_t)it->first.index; //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( it->second.satoshis != 1 || vout < 2 ) + if ( it->second.satoshis != 1 || vout > 1 ) continue; if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 )//&& pk == mypk ) { From 5e6965b60ad848f233eca87071e7bf750bfae3d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 08:56:03 -1100 Subject: [PATCH 2036/3904] Deference tokenid --- src/cc/rogue_rpc.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index be66eb4f8..68eed4439 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -430,6 +430,15 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub { if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { + if ( tokenid != zeroid ) + { + playertxid = tokenid; + if ( GetTransaction(playertxid,playertx,hashBlock,false) == 0 || (numvouts= playertx.vout.size()) <= 0 ) + { + fprintf(stderr,"couldnt get tokenid.%s\n",playertxid.GetHex().c_str()); + return(-2); + } + } if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); From 34b91c2d43f5a8bf787a323553a68f6b70a6bf64 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 09:01:20 -1100 Subject: [PATCH 2037/3904] Tokenid --- src/cc/rogue_rpc.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 68eed4439..03f073ecb 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -362,7 +362,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } -UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid) +UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid) { int32_t i; struct rogue_player P; char packitemstr[512],*datastr; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); @@ -383,6 +383,8 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid) a.push_back(packitemstr); } obj.push_back(Pair("playertxid",playertxid.GetHex())); + if ( tokenid != zeroid ) + obj.push_back(Pair("tokenid",tokenid.GetHex())); obj.push_back(Pair("data",datastr)); free(datastr); obj.push_back(Pair("pack",a)); @@ -423,9 +425,9 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs origplayergame is the gametxid that ends up being won by the highlander and they are linked directly as the highlander tx spends gametxid.vout0 */ -int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPubKey &pk,std::vector &playerdata,uint256 playertxid) +int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,tokenid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) @@ -465,7 +467,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint25 int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) { - int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 tid,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = numplayers = 0; playertxid = zeroid; for (i=0; i 0 ) - obj.push_back(Pair("player",rogue_playerobj(playerdata,playertxid))); + obj.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid))); } else fprintf(stderr,"findbaton err.%d\n",retval); } @@ -662,7 +664,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,origplayergame;int32_t n; CPubKey pk; bits256 t; + UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; result.push_back(Pair("result","success")); rogue_univalue(result,"playerinfo",-1,-1); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -670,9 +672,9 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( n > 0 ) { playertxid = juint256(jitem(params,0)); - if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); - result.push_back(Pair("player",rogue_playerobj(playerdata,playertxid))); + result.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid))); } else return(cclib_error(result,"no playertxid")); return(result); } else return(cclib_error(result,"couldnt reparse params")); @@ -686,7 +688,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; @@ -705,7 +707,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 1 ) { playertxid = juint256(jitem(params,1)); - if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); } rogue_univalue(result,0,maxplayers,buyin); @@ -992,7 +994,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); @@ -1006,9 +1008,9 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != 1 || vout > 1 ) continue; - if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 )//&& pk == mypk ) + if ( rogue_playerdata(cp,gametxid,tokenid,pk,playerdata,txid) == 0 )//&& pk == mypk ) { - a.push_back(rogue_playerobj(playerdata,txid)); + a.push_back(rogue_playerobj(playerdata,txid,tokenid)); //result.push_back(Pair("playerdata",rogue_playerobj(playerdata))); } } From e15764f36293ac7a1bdc8b92a86b7ab3bfeb0d24 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 12 Feb 2019 01:20:21 +0500 Subject: [PATCH 2038/3904] added vin for vout0 in test_burntx --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e10ba621c..a8bcf2660 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7839,6 +7839,7 @@ UniValue test_burntx(const UniValue& params, bool fHelp) CPubKey burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY)); + mtx.vin.push_back(CTxIn(tokenid, 0)); mtx.vin.push_back(CTxIn(tokenid, 1)); mtx.vout.push_back(MakeTokensCC1vout(EVAL_TOKENS, 1, burnpk)); From 1fce79e677c1a5c78a91d2d2abb4c356d3f815ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 09:20:22 -1100 Subject: [PATCH 2039/3904] Test --- src/cc/rogue_rpc.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 03f073ecb..cd035f6f7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -115,8 +115,8 @@ */ // todo: -// convert playertxid to the original playertxid // verify keystrokes tx is in mempool and confirmed +// chaining when mempool tx sometimes infinite loops //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -128,7 +128,7 @@ // ./rogue gui -> creates keystroke files // ./c cclib register 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22,%222475182f9d5169d8a3249d17640e4eccd90f4ee43ab04791129b0fa3f177b14a%22]\" // ./c cclib bailout 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22]\" - +// ./komodo-cli -ac_name=ROGUE cclib register 17 \"[%22a898f4ceef7647ba113b9f3c24ef045f5d134935a3b09bdd1a997b9d474f4c1b%22,%22f11d0cb4e2e4c21f029a1146f8e5926f11456885b7ab7d665096f5efedec8ea0%22]\" #define MAXPACK 23 struct rogue_packitem @@ -455,12 +455,12 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint return(-1); } -int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,uint256 origplayergame) +int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_t vout,uint256 origplayergame) { int64_t txfee = 10000; - if ( CCgettxout(playertxid,0,1) == 1 ) // not sure if this is enough validation + if ( CCgettxout(playertxid,vout,1) == 1 ) // not sure if this is enough validation { - mtx.vin.push_back(CTxIn(playertxid,0,CScript())); + mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); return(0); } else return(-1); } @@ -688,7 +688,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=0; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; @@ -696,7 +696,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY)); roguepk = GetUnspendable(cp,0); rogue_univalue(result,"register",-1,-1); - playertxid = zeroid; + playertxid = tokenid = zeroid; if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) @@ -709,6 +709,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) playertxid = juint256(jitem(params,1)); if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); + if ( tokenid != zeroid ) + vout = 1; } rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); @@ -716,7 +718,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"already registered")); if ( (inputsum= rogue_registrationbaton(mtx,gametxid,tx,maxplayers)) != ROGUE_REGISTRATIONSIZE ) return(cclib_error(result,"couldnt find available registration baton")); - else if ( playertxid != zeroid && rogue_playerdataspend(mtx,playertxid,origplayergame) < 0 ) + else if ( playertxid != zeroid && rogue_playerdataspend(mtx,playertxid,vout,origplayergame) < 0 ) return(cclib_error(result,"couldnt find playerdata to spend")); else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); @@ -727,21 +729,21 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); - std::vector vopretExtra; uint8_t e, funcid; uint256 tokenid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; + std::vector vopretExtra; uint8_t e, funcid; uint256 tid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { //fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); voutPubkeysEmpty.push_back(burnpk); - if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) + if ( GetTransaction(tokenid == zeroid ? playertxid : tokenid,playertx,hashBlock,false) != 0 ) { - if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretExtra)) != 0) + if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, vopretExtra)) != 0) { // if token in the opret didtx = 1; if ( funcid == 'c' ) - tokenid = playertxid; + tid = tokenid == zeroid ? playertxid : tokenid; rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, - EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, opretRegister)); + EncodeTokenOpRet(tid, voutPubkeysEmpty /*=never spent*/, opretRegister)); } } } From 0a9f2e0b8e3ea2f41e0791fda7ffd285cb18c902 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 12 Feb 2019 01:29:49 +0500 Subject: [PATCH 2040/3904] added additionalEvalcode2 in test_burntx --- src/wallet/rpcwallet.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a8bcf2660..51d7cb6ad 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7848,6 +7848,11 @@ UniValue test_burntx(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_TOKENS); + std::vector vopret; + GetNonfungibleData(tokenid, vopret); + if (vopret.size() > 0) + cp->additionalTokensEvalcode2 = vopret.begin()[0]; + uint8_t tokenpriv[33]; char unspendableTokenAddr[64]; CPubKey unspPk = GetUnspendable(cp, tokenpriv); From d889948d52be7f825d978cf8161b396ef21e4aa7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 09:31:07 -1100 Subject: [PATCH 2041/3904] Fix rogue_registeropretdecode --- src/cc/rogue_rpc.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cd035f6f7..273042685 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -188,7 +188,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t } else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) { - fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); + //fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; } @@ -213,7 +213,29 @@ uint8_t rogue_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &playertxid,CScript scriptPubKey) { - std::vector vopret,vopret2; uint8_t e,f; std::vector voutPubkeys; + std::string name, description; std::vector vorigPubkey; + std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; + uint8_t e, f,*script; std::vector voutPubkeys; + tokenid = zeroid; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,vopretNonfungible)) == 'c' ) + { + vopret = vopretNonfungible; + } + else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) + { + //fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); + GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx + vopret = vopretNonfungible; + } + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) + { + return(f); + } + fprintf(stderr,"e.%d f.%c game.%s playertxid.%s\n",e,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + + /*std::vector vopret,vopret2; uint8_t e,f; std::vector voutPubkeys; GetOpReturnData(scriptPubKey,vopret); tokenid = zeroid; if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) @@ -230,7 +252,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl playertxid = tokenid; fprintf(stderr,"e.%d vs %d, f %c, gametxid.%s player.%s\n",e,EVAL_ROGUE,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); return(0); - } + }*/ return(0); } @@ -443,7 +465,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint } if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used From d2e4067fad7c54c67316b6aab0e1521ddee7a27d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 09:36:11 -1100 Subject: [PATCH 2042/3904] Gametxid --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 273042685..b93e146ce 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -515,8 +515,9 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke { numvouts = matchtx.vout.size(); //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); - if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' && txid == gametxid ) + if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s\n",token.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str()); if ( tokenid != zeroid ) playertxid = tokenid; if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,playertxid) == 0 ) From 70f6fe55d4eced7db597950f8e631a2ccaa9f615 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 09:37:23 -1100 Subject: [PATCH 2043/3904] Tokens --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b93e146ce..3b615aabf 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -517,7 +517,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s\n",token.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str()); if ( tokenid != zeroid ) playertxid = tokenid; if ( playertxid == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,playertxid) == 0 ) From 0b8fffc5010fbcb7b50cd2aca0c9d65dfd4ebda0 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 12 Feb 2019 01:40:59 +0500 Subject: [PATCH 2044/3904] logging corrected --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index cb8c65342..6e1afbf33 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -866,7 +866,7 @@ int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTran burnedAmount += tx.vout[i].nValue; } } - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "HasBurnedTokensvouts() no burned vouts evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "HasBurnedTokensvouts() total burned=" << burnedAmount << " evalCode=" << (int)evalCode << " evalCode2=" << (int)evalCode2 << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); } } From 9fdb634a4ea378e4887cb73ea2b09c2e3c7dede5 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 12 Feb 2019 02:01:52 +0500 Subject: [PATCH 2045/3904] cc log levels corr --- src/cc/CCinclude.h | 9 +++++---- src/cc/CCtokens.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 6018114a0..a2d782c3f 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -266,6 +266,7 @@ UniValue ValueFromAmount(const CAmount& amount); #define CCLOG_DEBUG1 1 #define CCLOG_DEBUG2 2 #define CCLOG_DEBUG3 3 +#define CCLOG_MAXLEVEL 3 template inline void CCLogPrintStream(const char *category, int level, T print_to_stream) { @@ -273,10 +274,10 @@ inline void CCLogPrintStream(const char *category, int level, T print_to_stream) print_to_stream(stream); if (level < 0) level = 0; - if (level > 3) - level = 3; - for (int i = 0; i < level; i++) - if (LogAcceptCategory((std::string(category) + (level > 0 ? std::string("-") + std::to_string(level) : std::string(""))).c_str())) { + if (level > CCLOG_MAXLEVEL) + level = CCLOG_MAXLEVEL; + for (int i = level; i <= CCLOG_MAXLEVEL; i++) + if (LogAcceptCategory((std::string(category) + (i > 0 ? std::string("-") + std::to_string(i) : std::string(""))).c_str())) { LogPrintStr(stream.str()); break; } diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 6e1afbf33..c6e2498cf 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -178,7 +178,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui return (uint8_t)0; funcId = script[1]; - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ')); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ') << std::endl); switch( funcId ) { From f50b207e6203d0151740995f9fd4d502001e4c29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 13:55:43 -1100 Subject: [PATCH 2046/3904] Spend right playertxid vout --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 75966ce70..f85c07319 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -225,7 +225,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl } else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) { - //fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); + fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; } @@ -747,8 +747,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find enough normal funds for buyin")); if ( playertxid != zeroid ) AddNormalinputs2(mtx,txfee,10); - if (playertxid != zeroid) - mtx.vin.push_back(CTxIn(playertxid, 1)); // spending cc marker as token is being burned + if (playertxid != zeroid ) + mtx.vin.push_back(CTxIn(playertxid, vout)); // spending cc marker as token is being burned mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); @@ -760,7 +760,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { //fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); voutPubkeysEmpty.push_back(burnpk); - if ( GetTransaction(tokenid == zeroid ? playertxid : tokenid,playertx,hashBlock,false) != 0 ) + if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, vopretExtra)) != 0) { // if token in the opret From be2a5fd6bc2f7381ddd9df1f0ef5fd5544138498 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 13:59:02 -1100 Subject: [PATCH 2047/3904] Resolve conflict --- src/wallet/rpcwallet.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0077b198d..a2a66a610 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6204,19 +6204,12 @@ UniValue gatewaysinfo(const UniValue& params, bool fHelp) UniValue gatewaysbind(const UniValue& params, bool fHelp) { -<<<<<<< HEAD - UniValue result(UniValue::VOBJ); uint256 tokenid,oracletxid; int32_t i; int64_t totalsupply; std::vector pubkeys; uint8_t M,N; std::string hex,coin; std::vector pubkey; - if ( fHelp || params.size() < 6 ) - throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s)\n"); - if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) -======= UniValue result(UniValue::VOBJ); uint256 tokenid,oracletxid; int32_t i; int64_t totalsupply; std::vector pubkeys; uint8_t M,N,p1,p2,p3,p4=0; std::string hex,coin; std::vector pubkey; if ( fHelp || params.size() < 9 ) throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s) pubtype p2shtype wiftype [taddr]\n"); - if ( ensure_CCrequirements() < 0 ) ->>>>>>> FSM + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); From 6c21d8affa6c20e0e953c65373639843f729e2c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 14:08:52 -1100 Subject: [PATCH 2048/3904] EVAL_GATEWAYS --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a2a66a610..c0f9dc297 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6154,7 +6154,7 @@ UniValue gatewaysexternaladdress(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2) throw runtime_error("gatewaysexternaladdress bindtxid pubkey\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -6169,7 +6169,7 @@ UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2) throw runtime_error("gatewaysexternaladdress bindtxid address\n"); - if ( ensure_CCrequirements() < 0 ) + if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); From 10320c4db1cb864adfa000b481468abd6578464e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 14:46:32 -1100 Subject: [PATCH 2049/3904] Revert out change --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f85c07319..9dbd52070 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -746,9 +746,10 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); if ( playertxid != zeroid ) - AddNormalinputs2(mtx,txfee,10); - if (playertxid != zeroid ) - mtx.vin.push_back(CTxIn(playertxid, vout)); // spending cc marker as token is being burned + { + // AddNormalinputs2(mtx,txfee,10); + mtx.vin.push_back(CTxIn(playertxid,1)); // spending cc marker as token is being burned + } mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); From 510c6d807cc289f938c8521c68c03d71b891b074 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 14:52:32 -1100 Subject: [PATCH 2050/3904] Move around bouts --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9dbd52070..bf7ba7702 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -711,7 +711,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=0; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=1; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; if ( txfee == 0 ) txfee = 10000; @@ -748,7 +748,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( playertxid != zeroid ) { // AddNormalinputs2(mtx,txfee,10); - mtx.vin.push_back(CTxIn(playertxid,1)); // spending cc marker as token is being burned + mtx.vin.push_back(CTxIn(playertxid,0)); // spending cc marker as token is being burned } mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); @@ -902,6 +902,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else { + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens, NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); cashout = (uint64_t)P.gold * mult; @@ -920,8 +922,6 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } } mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens, NULL))); // marker to token cc addr, burnable and validated Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); From 7bd0acd56c33ca45ec5b00e3e6680d9e3f8c7b3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 15:13:16 -1100 Subject: [PATCH 2051/3904] Spend burn marker --- src/cc/rogue_rpc.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index bf7ba7702..03045a4b9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -747,8 +747,13 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find enough normal funds for buyin")); if ( playertxid != zeroid ) { - // AddNormalinputs2(mtx,txfee,10); - mtx.vin.push_back(CTxIn(playertxid,0)); // spending cc marker as token is being burned + mtx.vin.push_back(CTxIn(playertxid,0)); // spending cc marker as token is burned + char unspendableTokenAddr[64]; uint8_t tokenpriv[32]; struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + CPubKey unspPk = GetUnspendable(cpTokens, tokenpriv); + GetCCaddress(cpTokens, unspendableTokenAddr, unspPk); + CCaddr2set(cpTokens, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); + fprintf(stderr,"destaddr.(%s)\n",destaddr); } mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); @@ -903,7 +908,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param else { cpTokens = CCinit(&tokensC, EVAL_TOKENS); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens, NULL))); // marker to token cc addr, burnable and validated + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); cashout = (uint64_t)P.gold * mult; From ad65f834dd82b9fbf3ee2ca9fbd47003deb59584 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 15:15:51 -1100 Subject: [PATCH 2052/3904] +print --- src/cc/CCtx.cpp | 2 +- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 63f104896..82c12c37f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -191,7 +191,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr, cp->unspendableaddr2) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; if( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 03045a4b9..bf9611215 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -753,7 +753,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CPubKey unspPk = GetUnspendable(cpTokens, tokenpriv); GetCCaddress(cpTokens, unspendableTokenAddr, unspPk); CCaddr2set(cpTokens, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); - fprintf(stderr,"destaddr.(%s)\n",destaddr); + fprintf(stderr,"destaddr.(%s)\n",unspendableTokenAddr); } mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); From 4ceb869bef508c61ab0abbb63ccbf979de14cdad Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 15:20:54 -1100 Subject: [PATCH 2053/3904] Test --- src/cc/CCtx.cpp | 2 +- src/cc/rogue_rpc.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 82c12c37f..198fb0908 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -156,7 +156,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr); + fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index bf9611215..9c99528ce 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -752,8 +752,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) cpTokens = CCinit(&tokensC, EVAL_TOKENS); CPubKey unspPk = GetUnspendable(cpTokens, tokenpriv); GetCCaddress(cpTokens, unspendableTokenAddr, unspPk); - CCaddr2set(cpTokens, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); - fprintf(stderr,"destaddr.(%s)\n",unspendableTokenAddr); + CCaddr2set(cp, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); } mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,roguepk,mypk)); GetCCaddress1of2(cp,destaddr,roguepk,roguepk); From 5a8b054ede1fa4903c99387a378383c3ac45561c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 15:27:49 -1100 Subject: [PATCH 2054/3904] Map R --- src/cc/CCtx.cpp | 4 ++-- src/cc/rogue_rpc.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 198fb0908..0f7e103f9 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -156,7 +156,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); + //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { @@ -191,7 +191,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr, cp->unspendableaddr2) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; if( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9c99528ce..d6660dbfa 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -215,7 +215,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl { std::string name, description; std::vector vorigPubkey; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; - uint8_t e, f,*script; std::vector voutPubkeys; + uint8_t e, f,*script,flag = 0; std::vector voutPubkeys; tokenid = zeroid; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -228,8 +228,9 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; + flag = 1; } - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && (flag != 0 || f == 'R') ) { return(f); } From 27341371d440dc468d538ad7649d00b2a111ec5c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 15:36:12 -1100 Subject: [PATCH 2055/3904] Test --- src/cc/rogue_rpc.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d6660dbfa..53d18eff9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -215,7 +215,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl { std::string name, description; std::vector vorigPubkey; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; - uint8_t e, f,*script,flag = 0; std::vector voutPubkeys; + uint8_t e, f,*script; std::vector voutPubkeys; tokenid = zeroid; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -226,11 +226,10 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) { fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); - GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx - vopret = vopretNonfungible; - flag = 1; + //GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx + vopret = vopretDummy; } - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && (flag != 0 || f == 'R') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) { return(f); } @@ -764,7 +763,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { - //fprintf(stderr,"playertxid.%s\n",playertxid.GetHex().c_str()); + fprintf(stderr,"gametxid.%s playertxid.%s opR.%d\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)opretRegister.size()); voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { From 2cdb6f10e76928223c2b231c34b6fad1ba0e5d7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 15:50:11 -1100 Subject: [PATCH 2056/3904] -print --- src/cc/rogue/state.c | 1 + src/cc/rogue_rpc.cpp | 23 +---------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 817993c17..1779bcbcc 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1372,6 +1372,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) if ( item->which < MAXSTICKS ) ws_info[item->which].oi_know = TRUE; break; + // cur_armor and cur_weapon should be set } char packitemstr[256]; strcpy(packitemstr,inv_name(o,FALSE)); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 53d18eff9..0b6a00c43 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -225,8 +225,6 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl } else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) { - fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); - //GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretDummy; } if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) @@ -234,25 +232,6 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl return(f); } fprintf(stderr,"e.%d f.%c game.%s playertxid.%s\n",e,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); - - /*std::vector vopret,vopret2; uint8_t e,f; std::vector voutPubkeys; - GetOpReturnData(scriptPubKey,vopret); - tokenid = zeroid; - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) - { - return(f); - } - else if ( (f= DecodeTokenOpRet(scriptPubKey,e,tokenid,voutPubkeys,vopret)) == 'c' || f == 't' ) - { - //fprintf(stderr,"got valid token opret %s e.%d vs %d\n",tokenid.GetHex().c_str(),e,EVAL_TOKENS); - if ( vopret2.size() > 2 && E_UNMARSHAL(vopret2,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) - { - return(f); - } - playertxid = tokenid; - fprintf(stderr,"e.%d vs %d, f %c, gametxid.%s player.%s\n",e,EVAL_ROGUE,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); - return(0); - }*/ return(0); } @@ -763,7 +742,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { - fprintf(stderr,"gametxid.%s playertxid.%s opR.%d\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)opretRegister.size()); + //fprintf(stderr,"gametxid.%s playertxid.%s opR.%d\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)opretRegister.size()); voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { From 00d27436f39c7d35e2c178d472c6d0250958806f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 15:54:11 -1100 Subject: [PATCH 2057/3904] +skip --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0b6a00c43..0c29322ee 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -196,7 +196,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t { return(f); } - fprintf(stderr,"e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); + fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); return(0); } From 5aee2381b08acc6b6deef21273813c63a8818bdf Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 11 Feb 2019 21:55:37 -1100 Subject: [PATCH 2058/3904] Disp playertxid for tokens for 'c' tx --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0c29322ee..2ba2dd980 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -386,6 +386,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("playertxid",playertxid.GetHex())); if ( tokenid != zeroid ) obj.push_back(Pair("tokenid",tokenid.GetHex())); + else obj.push_back(Pair("tokenid",playertxid.GetHex())); obj.push_back(Pair("data",datastr)); free(datastr); obj.push_back(Pair("pack",a)); From 9eed81089bf15c859f116fccdee32ae5193d82a3 Mon Sep 17 00:00:00 2001 From: dimxy Date: Tue, 12 Feb 2019 13:07:31 +0500 Subject: [PATCH 2059/3904] corr check for non-existing eval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in CCLogPrintStream -debug=cat-0 added declr corrected comment added to check for non supported eval added check if eval not supported СCLogPrintStream moved to CCutils.cpp --- src/cc/CCinclude.h | 13 +++++++------ src/cc/CCtokens.cpp | 2 +- src/cc/CCutils.cpp | 5 ++++- src/cc/eval.cpp | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index e4d74ba76..eb9297a36 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -270,21 +270,22 @@ UniValue ValueFromAmount(const CAmount& amount); #define CCLOG_DEBUG3 3 #define CCLOG_MAXLEVEL 3 template -inline void CCLogPrintStream(const char *category, int level, T print_to_stream) +void CCLogPrintStream(const char *category, int level, T print_to_stream) { - std::ostringstream stream; + std::ostringstream stream; print_to_stream(stream); - if (level < 0) - level = 0; + if (level < 0) + level = 0; if (level > CCLOG_MAXLEVEL) level = CCLOG_MAXLEVEL; for (int i = level; i <= CCLOG_MAXLEVEL; i++) - if (LogAcceptCategory((std::string(category) + (i > 0 ? std::string("-") + std::to_string(i) : std::string(""))).c_str())) { + if( LogAcceptCategory((std::string(category) + std::string("-") + std::to_string(i)).c_str()) || // '-debug=cctokens-0', '-debug=cctokens-1',... + i == 0 && LogAcceptCategory(std::string(category).c_str()) ) { // also supporting '-debug=cctokens' for CCLOG_INFO LogPrintStr(stream.str()); break; } } - +// use: LOGSTREAM("yourcategory", your-debug-level, stream << "some log data" << data2 << data3 << ... << std::endl); #define LOGSTREAM(category, level, logoperator) CCLogPrintStream( category, level, [=](std::ostringstream &stream) {logoperator;} ) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 5b6c148e8..e5b9eeb78 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -253,7 +253,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << std::hex << (int)cp->evalcode << std::endl); if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0) return eval->Invalid("cant find token create txid"); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index a9e9b74c6..d79f1d7f6 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -687,6 +687,9 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector param from_mempool = 1; height &= ((1<<30) - 1); } + if (cp->validate == NULL) + return eval->Invalid("validation not supported for eval code"); + //fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE); // there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example //txid = ctx.GetHash(); @@ -748,4 +751,4 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co return(false); //eval->Invalid("error in CClib_validate"); } return eval->Invalid("cclib CC must have evalcode between 16 and 127"); -} +} \ No newline at end of file diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index ca2703bff..405f02cc4 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -85,6 +85,7 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) CCinit(cp,ecode); cp->didinit = 1; } + switch ( ecode ) { case EVAL_IMPORTPAYOUT: From f6a51145f59315d8303fdb47709aabdaf4943a06 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 12 Feb 2019 23:28:13 +0800 Subject: [PATCH 2060/3904] New notary pay mechanisim... --- src/komodo.h | 17 +++++++++++------ src/komodo_bitcoind.h | 42 +++++++++++++++++++++++------------------ src/komodo_notary.h | 5 +++-- src/komodo_structs.h | 2 +- src/main.cpp | 20 +++++++++++--------- src/miner.cpp | 8 ++++++-- src/notaries_staked.cpp | 4 ++-- src/rpc/misc.cpp | 6 +++--- 8 files changed, 61 insertions(+), 43 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index b97e4d205..d88b53c2a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -266,7 +266,10 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; } + sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; + sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth); + printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT); } else if ( func == 'U' ) // deprecated { @@ -697,7 +700,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar komodo_rwccdata((char *)"KMD",1,&ccdata,0); // If we are checking a reorged notarisation tx we need to return true. So the coinbase can be recreated, otherwise notaries are not paid, - // if a notarisation TX is reorged before the next notarization happens! + // if a notarisation TX is reorged before the next notarization happens! if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) return(-2); @@ -705,7 +708,8 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar { if ( fJustCheck ) return(-2); - sp->prevNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; + sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; + sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; @@ -716,7 +720,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar } komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); + printf("[%s] ht.%d NUM_NPOINTS.%d NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,sp->NUM_NPOINTS,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { @@ -742,7 +746,8 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0); } } - } + } else if ( fJustCheck ) + return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one! } else if ( opretlen != 149 && height > 600000 && matched != 0 ) printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } @@ -958,7 +963,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); - if ( fJustCheck && notaryid == -2 ) + if ( fJustCheck && (notaryid == -2 || notaryid == -3) ) { // We see a valid notarisation here, save its location. notarisations.push_back(i); @@ -1025,7 +1030,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { if (notarisations.size() == 0) return(0); - if ( notarisations.size() == 1 && notarisations[0] == 1 ) + if ( notarisations.size() >= 1 && notarisations[0] == 1 ) return(1); else return(-1); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index caa2c4460..e3e99d7c4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,35 +1776,39 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); -uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) +uint64_t komodo_notarypayamount(int64_t notarycount) { if ( notarycount == 0 ) { fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); } - // fetch notarised height - int32_t notarizedht,prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; + // fetch notarised height, the previous, and the one before that. + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); - // if this is the current checkpoint we will use the previous height. - // incase of reorgs, we still need to create the notary payment. - if ( height == notarizedht ) + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); + //fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d \n",notarizedht,prevnotarizedht,pprevnotarizedht); + + // We cannot pay out if 3 notarisation's have not yet happened! + if ( pprevnotarizedht == 0 ) { - notarizedht = prevnotarizedht; - fprintf(stderr, "using the current checkpoint, calculating based on previous notarized height!\n"); + fprintf(stderr, "need 3 notarizations to happen before notaries can be paid.\n"); + return(0); } - // how many block since last notarisation. - int32_t n = height - notarizedht; + if ( prevnotarizedht == pprevnotarizedht ) + return(0); // cant happen, sanity check. + + // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, + // are them selves actually notarised and cannot be reorged. + int32_t n = prevnotarizedht - pprevnotarizedht; + fprintf(stderr, "blocks since last notarization: %i\n",n); // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. AmountToPay = ASSETCHAINS_NOTARY_PAY*n; - //fprintf(stderr, "AmountToPay.%lu\n",AmountToPay); ret = AmountToPay / notarycount; - fprintf(stderr, "payment per notary.%lu\n",ret); return(ret); } @@ -1846,7 +1850,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); - // Check the notarisation is valid and get the notarized height to calcualte the payment. + // Check the notarisation is valid. int32_t notarizedheight = komodo_getnotarizedheight(timestamp, height, script, len); if ( notarizedheight == 0 ) return(0); @@ -1854,8 +1858,10 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); - // Calcualte the amount to pay. - AmountToPay = komodo_notarypayamount(notarizedheight,NotarisationNotaries.size()); + // Calcualte the amount to pay. If 0, means not enough notarizations to calcuate amount. + AmountToPay = komodo_notarypayamount(NotarisationNotaries.size()); + if ( AmountToPay == 0 ) + return(0); // loop over notarisation vins and add transaction to coinbase. // Commented prints here can be used to verify manually the pubkeys match. @@ -1932,7 +1938,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); return(0); } - } + } else return(0); // if notarypay fails, because the notarisation is not valid, exit now as txNew was not created. // This should never happen, as the notarisation is checked before this function is called. diff --git a/src/komodo_notary.h b/src/komodo_notary.h index dcd99bea1..88a079348 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,14 +452,15 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { *hashp = sp->NOTARIZED_HASH; *txidp = sp->NOTARIZED_DESTTXID; - *prevNotarizedHt = sp->prevNOTARIZED_HEIGHT; + *prevNotarizedHt = sp->PNOTARIZED_HEIGHT; + *ppNotarizedHt = sp->PPNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 2f8ba0850..b7a0ddd24 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,prevNOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index 054313a21..283e8ee38 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3284,14 +3284,16 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Do this here before the block is moved to the main block files. if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() > 10 ) { - // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. + // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); - // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. + // -1 means that the valid notarization isnt in position 1. if ( notarisationTx == -1 ) return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), REJECT_INVALID, "bad-notarization-position"); - // 1 means this block contains a valid notarisation + // 1 means this block contains a valid notarisation and its in position 1. + // its no longer possible for any attempted notarization to be in a block with a valid one! + // if notaries create a notarisation even if its not in this chain it will need to be mined inside its own block! if ( notarisationTx == 1 ) { // Check if the notaries have been paid. @@ -3906,8 +3908,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; - komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); + int32_t prevMoMheight,prevnotarizedht,prevNotarizedHt; uint256 notarizedhash,txid; + komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4241,8 +4243,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevnotarizedht,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); + int32_t notarizedht,prevnotarizedht,prevNotarizedHt,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5593,8 +5595,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/miner.cpp b/src/miner.cpp index a0934ce96..36ef947d3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -432,6 +432,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } } + else if ( fNotarisationBlock == true ) + { + // Any attempted notarization needs to be in its own block! + // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. + continue; + } } } } @@ -723,12 +729,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { - fprintf(stderr, ">>>>>MINER NotarisationNotaries.%li\n",NotarisationNotaries.size()); uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); - // invalidnotarisation = pblock->vtx[1].GetHash().ToString(); if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) { LEAVE_CRITICAL_SECTION(cs_main); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 422d0da18..868956f8a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,14 +17,14 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABST2") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; // These chains have no speical rules at all. else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant ot be actually used for anything important. + STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. doneinit = 1; diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index bda9da062..15386d42a 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); From d9ad59f566a33e2d0dba5079704856258a0ec441 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 12 Feb 2019 23:36:31 +0800 Subject: [PATCH 2061/3904] fix --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index d88b53c2a..0ec83579c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -1030,7 +1030,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { if (notarisations.size() == 0) return(0); - if ( notarisations.size() >= 1 && notarisations[0] == 1 ) + if ( notarisations.size() == 1 && notarisations[0] == 1 ) return(1); else return(-1); From fb00eedf6c50f789d3e6e9ce2a1470c042f41aba Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 07:59:16 -1100 Subject: [PATCH 2062/3904] Two possible reasons for hang --- src/cc/rogue_rpc.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2ba2dd980..ba0161faa 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -21,6 +21,7 @@ #define ROGUE_REGISTRATIONSIZE (100 * 10000) #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching #define ROGUE_MAXKEYSTROKESGAP 60 +#define ROGUE_MAXLEN 777 /* Roguelander - using highlander competition between rogue players @@ -401,16 +402,22 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once { - uint256 spenttxid,txid = firsttxid; int32_t spentvini,vout = firstvout; + uint256 spenttxid,txid = firsttxid; int32_t spentvini,n,vout = firstvout; registertxid = zeroid; if ( vout < 0 ) return(-1); + n = 0; while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) { txid = spenttxid; vout = spentvini; if ( registertxid == zeroid ) registertxid = txid; + if ( ++n >= ROGUE_MAXLENGTH ) + { + fprintf(stderr,"rogue_iterateplayer n.%d, seems something is wrong\n",n); + break; + } } if ( txid == lasttxid ) return(0); @@ -469,7 +476,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) { - int32_t i,numvouts,spentvini,matches = 0; CPubKey pk; uint256 tid,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = numplayers = 0; playertxid = zeroid; for (i=0; i= 2 ) { uint256 g,b; CPubKey p; std::vector k; - if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[1].scriptPubKey) == 'K' ) + if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) { keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); for (i=0; i= ROGUE_MAXLENGTH ) + { + fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); + break; + } } //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; From 69ccb69983bd4fcd7b631145881dd96e4480eb1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 08:00:26 -1100 Subject: [PATCH 2063/3904] ROGUE_MAXITERATIONS --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ba0161faa..d81755570 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -21,7 +21,7 @@ #define ROGUE_REGISTRATIONSIZE (100 * 10000) #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching #define ROGUE_MAXKEYSTROKESGAP 60 -#define ROGUE_MAXLEN 777 +#define ROGUE_MAXITERATIONS 777 /* Roguelander - using highlander competition between rogue players @@ -413,7 +413,7 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs vout = spentvini; if ( registertxid == zeroid ) registertxid = txid; - if ( ++n >= ROGUE_MAXLENGTH ) + if ( ++n >= ROGUE_MAXITERATIONS ) { fprintf(stderr,"rogue_iterateplayer n.%d, seems something is wrong\n",n); break; @@ -538,7 +538,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke (*keystrokesp) = keystrokes; } } - if ( ++n >= ROGUE_MAXLENGTH ) + if ( ++n >= ROGUE_MAXITERATIONS ) { fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); break; From 072093c628a7fb2f241ed52e14c029cd51835395 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 08:01:04 -1100 Subject: [PATCH 2064/3904] Return negative --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d81755570..6fceb497b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -416,7 +416,7 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs if ( ++n >= ROGUE_MAXITERATIONS ) { fprintf(stderr,"rogue_iterateplayer n.%d, seems something is wrong\n",n); - break; + return(-2); } } if ( txid == lasttxid ) @@ -541,7 +541,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( ++n >= ROGUE_MAXITERATIONS ) { fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); - break; + retyrn(-5); } } //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); From 44b3739ae0f8fe8376f224dec3aeb184237ba417 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 08:01:55 -1100 Subject: [PATCH 2065/3904] Return --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6fceb497b..526c48c6a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -541,7 +541,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( ++n >= ROGUE_MAXITERATIONS ) { fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); - retyrn(-5); + return(-5); } } //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); From ded4d20f988864928a2420e5f226650192ba4596 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 08:44:20 -1100 Subject: [PATCH 2066/3904] Spend the tokenid v0 to burn it --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 526c48c6a..450e40470 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -739,9 +739,9 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"couldnt find playerdata to spend")); else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) return(cclib_error(result,"couldnt find enough normal funds for buyin")); - if ( playertxid != zeroid ) + if ( tokenid != zeroid ) { - mtx.vin.push_back(CTxIn(playertxid,0)); // spending cc marker as token is burned + mtx.vin.push_back(CTxIn(tokenid,0)); // spending cc marker as token is burned char unspendableTokenAddr[64]; uint8_t tokenpriv[32]; struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); CPubKey unspPk = GetUnspendable(cpTokens, tokenpriv); From c6e8ba4a71020d03a5759259d43e6d4d140296c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 09:02:42 -1100 Subject: [PATCH 2067/3904] Games rpc call --- src/cc/cclib.cpp | 4 ++++ src/cc/rogue_rpc.cpp | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 04ad7a66d..f5a3d092e 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -62,6 +62,7 @@ CClib_methods[] = { (char *)"rogue", (char *)"highlander", (char *)"gametxid", 1, 1, 'H', EVAL_ROGUE }, { (char *)"rogue", (char *)"playerinfo", (char *)"playertxid", 1, 1, 'I', EVAL_ROGUE }, { (char *)"rogue", (char *)"players", (char *)"", 0, 0, 'D', EVAL_ROGUE }, + { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -85,6 +86,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -118,6 +120,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(rogue_playerinfo(txfee,cp,params)); else if ( strcmp(method,"players") == 0 ) return(rogue_players(txfee,cp,params)); + else if ( strcmp(method,"games") == 0 ) + return(rogue_games(txfee,cp,params)); else { result.push_back(Pair("result","error")); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 450e40470..f1b21598a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -757,7 +757,6 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { - //fprintf(stderr,"gametxid.%s playertxid.%s opR.%d\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)opretRegister.size()); voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { @@ -1045,6 +1044,28 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; + roguepk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,coinaddr,roguepk,mypk); + SetCCunspents(unspentOutputs,coinaddr); + rogue_univalue(result,"games",-1,-1); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( vout == 0 ) + { + a.push_back(txid.GetHex()); + } + } + result.push_back(Pair("games",a)); + result.push_back(Pair("numgames",a.size())); +} + bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true); From 20d2b07d982529d84c540670e657c99048a40079 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 09:03:02 -1100 Subject: [PATCH 2068/3904] Return result --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f1b21598a..2fe2f6269 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1064,6 +1064,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } result.push_back(Pair("games",a)); result.push_back(Pair("numgames",a.size())); + return(result); } bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) From a757607bb75329fc7fe1b8f2ed5c82d6c0a2df65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 09:16:29 -1100 Subject: [PATCH 2069/3904] +print --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2fe2f6269..a3d0fda0c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1052,11 +1052,12 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetCCaddress1of2(cp,coinaddr,roguepk,mypk); SetCCunspents(unspentOutputs,coinaddr); rogue_univalue(result,"games",-1,-1); + fprintf(stderr,"rogue_games\n"); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( vout == 0 ) { a.push_back(txid.GetHex()); From 60da8f511b1fdcb0893300303d4f128f87e76477 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 09:21:16 -1100 Subject: [PATCH 2070/3904] Declare inspects --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a3d0fda0c..fbd512c5a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1046,13 +1046,13 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid; int32_t vout; CPubKey roguepk,mypk; char coinaddr[64]; + std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); SetCCunspents(unspentOutputs,coinaddr); rogue_univalue(result,"games",-1,-1); - fprintf(stderr,"rogue_games\n"); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 37eba17f16425ab6f16ac1b6b4765f0ec1f2b27c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 09:30:31 -1100 Subject: [PATCH 2071/3904] Limit to 'R' --- src/cc/rogue_rpc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index fbd512c5a..0e6c6011a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1046,7 +1046,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid; int32_t vout; CPubKey roguepk,mypk; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid,gametxid,tokenid,playertxid; int32_t vout; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); @@ -1057,10 +1057,16 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { txid = it->first.txhash; vout = (int32_t)it->first.index; - char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( vout == 0 ) { - a.push_back(txid.GetHex()); + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + a.push_back(gametxid.GetHex()); + } + } } } result.push_back(Pair("games",a)); From 891e89f4fd5e88eb21aa8aa9fa5038830b19954c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 09:31:35 -1100 Subject: [PATCH 2072/3904] Vars --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0e6c6011a..a9393af28 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1046,7 +1046,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid,gametxid,tokenid,playertxid; int32_t vout; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); From 5425e6a040f213079f9aa17b2268bd3941cc6d37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 09:50:21 -1100 Subject: [PATCH 2073/3904] Prints --- src/cc/rogue_rpc.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a9393af28..20418bb84 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -476,7 +476,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) { - int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = numplayers = 0; playertxid = zeroid; for (i=0; i 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) @@ -922,11 +923,16 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); - CScript opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, newdata); + CScript opret; if ( newdata.size() == 0 ) + { + opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, nodata); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); + fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx); + } else { + opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, newdata); char seedstr[32]; sprintf(seedstr,"%llu",(long long)seed); std::vector vopretNonfungible; From 7d485369b27b4f202ec69f465587133312a3a9bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 10:07:35 -1100 Subject: [PATCH 2074/3904] All taxis for games --- src/cc/rogue/state.c | 6 +++--- src/cc/rogue_rpc.cpp | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 1779bcbcc..3db54a319 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1374,9 +1374,9 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item) break; // cur_armor and cur_weapon should be set } - char packitemstr[256]; - strcpy(packitemstr,inv_name(o,FALSE)); - fprintf(stderr,"packitem.(%s)\n",packitemstr); + //char packitemstr[256]; + //strcpy(packitemstr,inv_name(o,FALSE)); + //fprintf(stderr,"packitem.(%s)\n",packitemstr); } } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 20418bb84..2563b8e83 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -504,7 +504,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; @@ -928,7 +928,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, nodata); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); - fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx); + fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx.c_str()); } else { @@ -1053,11 +1053,13 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; - std::vector > unspentOutputs; + std::vector > &addressIndex; + //std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); - SetCCunspents(unspentOutputs,coinaddr); + //SetCCunspents(unspentOutputs,coinaddr); + SetCCtxids(addressIndex,coinaddr); rogue_univalue(result,"games",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { From e895ba68d23facc31a9ff9865695e058675399f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 10:11:24 -1100 Subject: [PATCH 2075/3904] Fix --- src/cc/rogue_rpc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2563b8e83..a54f81036 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1053,7 +1053,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; - std::vector > &addressIndex; + std::vector > addressIndex; //std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); @@ -1061,7 +1061,8 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //SetCCunspents(unspentOutputs,coinaddr); SetCCtxids(addressIndex,coinaddr); rogue_univalue(result,"games",-1,-1); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; vout = (int32_t)it->first.index; From b86fa74a48e647cd4316307dc234bf61d0bb95f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 10:15:42 -1100 Subject: [PATCH 2076/3904] Pastgames --- src/cc/rogue_rpc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a54f81036..ec2f571ee 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -232,7 +232,7 @@ uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &pl { return(f); } - fprintf(stderr,"e.%d f.%c game.%s playertxid.%s\n",e,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"e.%d f.%c game.%s playertxid.%s\n",e,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); return(0); } @@ -1052,7 +1052,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; std::vector > addressIndex; //std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); @@ -1073,13 +1073,16 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) { - a.push_back(gametxid.GetHex()); + if ( CCgettxout(txid,vout,1) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); } } } } + result.push_back(Pair("pastgames",b)); result.push_back(Pair("games",a)); - result.push_back(Pair("numgames",a.size())); + result.push_back(Pair("numgames",a.size()+b.size())); return(result); } From f41d60a399eac2e6c9c2c9645c192d84ec05996d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 10:20:24 -1100 Subject: [PATCH 2077/3904] Filter out invalid games --- src/cc/rogue_rpc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ec2f571ee..49a61bd67 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1052,7 +1052,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; std::vector > addressIndex; //std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); @@ -1073,9 +1073,12 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) { - if ( CCgettxout(txid,vout,1) < 0 ) - b.push_back(gametxid.GetHex()); - else a.push_back(gametxid.GetHex()); + if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) + { + if ( CCgettxout(txid,vout,1) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); + } } } } From 06058a25ffc2be34327af04d1980d4e10ff91ccf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 17:51:04 -1100 Subject: [PATCH 2078/3904] -prints --- src/cc/rogue/rogue.c | 17 +++++++++++------ src/cc/rogue_rpc.cpp | 7 ++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index fffa6203d..8442e9997 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -149,6 +149,8 @@ uint8_t *OS_fileptr(long *allocsizep,char *fname); int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + if ( gametxidstr == 0 || *gametxidstr == 0 ) + return(retval); sprintf(fname,"%s.gameinfo",gametxidstr); sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); if ( system(cmd) != 0 ) @@ -188,12 +190,15 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) { char cmd[16384],hexstr[16384]; int32_t i; - for (i=0; i> keystrokes.log",Gametxidstr,hexstr); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); + if ( Gametxidstr[0] != 0 ) + { + for (i=0; i> keystrokes.log",Gametxidstr,hexstr); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + } } int32_t flushkeystrokes(struct rogue_state *rs) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 49a61bd67..e012746e4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -117,7 +117,8 @@ // todo: // verify keystrokes tx is in mempool and confirmed -// chaining when mempool tx sometimes infinite loops +// chaining when mempool tx sometimes infinite loops? +// bailout stealing, is it possible? //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -1041,8 +1042,8 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) continue; if ( rogue_playerdata(cp,gametxid,tokenid,pk,playerdata,txid) == 0 )//&& pk == mypk ) { - a.push_back(rogue_playerobj(playerdata,txid,tokenid)); - //result.push_back(Pair("playerdata",rogue_playerobj(playerdata))); + a.push_back(txid.GetHex()); + //a.push_back(Pair("playerdata",rogue_playerobj(playerdata))); } } result.push_back(Pair("playerdata",a)); From 12a4822a0b0dc45f2a4b5332b483496726a2c86d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 17:56:02 -1100 Subject: [PATCH 2079/3904] Add ASSETCHAINS_SYMBOL to player data --- src/cc/rogue_rpc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e012746e4..40c5eab84 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -172,11 +172,11 @@ CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std: CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata) { CScript opret; uint8_t evalcode = EVAL_ROGUE; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata << ASSETCHAINS_SYMBOL); return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, CScript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol,CScript scriptPubKey) { std::string name, description; std::vector vorigPubkey; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; @@ -194,7 +194,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; } - if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata; ss >> symbol) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) { return(f); } @@ -437,10 +437,10 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,uint256 playertxid) { - uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; + uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; std::string symbol; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { - if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { if ( tokenid != zeroid ) { From cf92af5fcaff447426b5b6b9edf14a73f8549e9d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 17:57:15 -1100 Subject: [PATCH 2080/3904] Symbol --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 40c5eab84..b6635a016 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -171,8 +171,8 @@ CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std: CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata) { - CScript opret; uint8_t evalcode = EVAL_ROGUE; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata << ASSETCHAINS_SYMBOL); + CScript opret; uint8_t evalcode = EVAL_ROGUE; std::string symbol(ASSETCHAINS_SYMBOL); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata << symbol); return(opret); } From e3b6e77eb6eab458cd077b4eaafd7038d573cb76 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 18:25:57 -1100 Subject: [PATCH 2081/3904] Fred --- src/cc/rogue_rpc.cpp | 56 ++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b6635a016..ce6f0889f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -169,14 +169,14 @@ CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std: return(opret); } -CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata) +CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata,std::string pname) { CScript opret; uint8_t evalcode = EVAL_ROGUE; std::string symbol(ASSETCHAINS_SYMBOL); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata << symbol); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata << symbol << pname); return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol,CScript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol,std::string &pname,CScript scriptPubKey) { std::string name, description; std::vector vorigPubkey; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; @@ -194,7 +194,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; } - if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata; ss >> symbol) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata; ss >> symbol; ss >> pname) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) { return(f); } @@ -365,7 +365,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } -UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid) +UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname) { int32_t i; struct rogue_player P; char packitemstr[512],*datastr; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); @@ -398,6 +398,8 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); + obj.push_back(Pair("chain",symbol)); + obj.push_back(Pair("name",pname)); return(obj); } @@ -435,12 +437,12 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs origplayergame is the gametxid that ends up being won by the highlander and they are linked directly as the highlander tx spends gametxid.vout0 */ -int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,uint256 playertxid) +int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,std::string &symbol,std::string &pname,uint256 playertxid) { - uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; std::string symbol; + uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { - if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { if ( tokenid != zeroid ) { @@ -475,7 +477,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_ } else return(-1); } -int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers) +int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) { int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; numkeys = numplayers = 0; @@ -509,7 +511,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( tokenid != zeroid ) active = tokenid; else active = playertxid; - if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,active) == 0 ) + if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); @@ -577,7 +579,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *myrogueaddr) { // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; + uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; std::string symbol,pname; destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { @@ -585,7 +587,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-1)); - if ( (retval= rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers)) == 0 ) + if ( (retval= rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers,symbol,pname)) == 0 ) { if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) { @@ -604,7 +606,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); obj.push_back(Pair("batonht",(int64_t)batonht)); if ( playerdata.size() > 0 ) - obj.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid))); + obj.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid,symbol,pname))); } else fprintf(stderr,"findbaton err.%d\n",retval); } @@ -683,7 +685,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; + UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; std::string symbol,pname; result.push_back(Pair("result","success")); rogue_univalue(result,"playerinfo",-1,-1); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -691,9 +693,9 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( n > 0 ) { playertxid = juint256(jitem(params,0)); - if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); - result.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid))); + result.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid,symbol,pname))); } else return(cclib_error(result,"no playertxid")); return(result); } else return(cclib_error(result,"couldnt reparse params")); @@ -707,7 +709,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vin3+ -> buyin // vout0 -> keystrokes/completion baton CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=1; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx; bits256 t; + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=1; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,roguepk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx,symbol,pname; bits256 t; if ( txfee == 0 ) txfee = 10000; @@ -726,7 +728,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n > 1 ) { playertxid = juint256(jitem(params,1)); - if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,playertxid) < 0 ) + if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); if ( tokenid != zeroid ) vout = 1; @@ -790,7 +792,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // respawn to be prevented by including timestamps int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx; bits256 t; uint8_t mypriv[32]; + UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); @@ -803,7 +805,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { - if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers) == 0 ) + if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) { if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { @@ -834,7 +836,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) @@ -865,9 +867,11 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { if ( maxplayers == 1 ) mult /= 2; - if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers) == 0 ) + if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 ) { UniValue obj; struct rogue_player P; + if ( pname.size() == 0 ) + pname = "fred"; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); fprintf(stderr,"found baton %s numkeys.%d seed.%llu playerdata.%d\n",batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); @@ -927,13 +931,13 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param CScript opret; if ( newdata.size() == 0 ) { - opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, nodata); + opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, nodata,pname); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx.c_str()); } else { - opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, newdata); + opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, newdata,pname); char seedstr[32]; sprintf(seedstr,"%llu",(long long)seed); std::vector vopretNonfungible; @@ -1026,7 +1030,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; std::string symbol,pname; char coinaddr[64]; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); @@ -1040,7 +1044,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != 1 || vout > 1 ) continue; - if ( rogue_playerdata(cp,gametxid,tokenid,pk,playerdata,txid) == 0 )//&& pk == mypk ) + if ( rogue_playerdata(cp,gametxid,tokenid,pk,playerdata,symbol,pname,txid) == 0 )//&& pk == mypk ) { a.push_back(txid.GetHex()); //a.push_back(Pair("playerdata",rogue_playerobj(playerdata))); From 382af721ebe0d270134d8f8441f7149378bec68c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 18:27:00 -1100 Subject: [PATCH 2082/3904] Symbol --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ce6f0889f..328e2b628 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -442,7 +442,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) { - if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { if ( tokenid != zeroid ) { From a672e859cf092e8b1458474cf3fe5752e18a8440 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 18:39:02 -1100 Subject: [PATCH 2083/3904] Test --- src/cc/CCassetsCore.cpp | 6 +++--- src/cc/assets.cpp | 6 +++--- src/cc/rogue/rogue.c | 4 +++- src/cc/rogue_rpc.cpp | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 62d57e71c..63c94d920 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -458,7 +458,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *origCCadd else if( GetAssetorigaddrs(cp, origCCaddr, origaddr, vinTx) == 0 ) return eval->Invalid("couldnt get origaddr for buyvin"); - fprintf(stderr,"AssetValidateCCvin() got %.8f to origaddr.(%s)\n", (double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); + //fprintf(stderr,"AssetValidateCCvin() got %.8f to origaddr.(%s)\n", (double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); if ( vinTx.vout[0].nValue == 0 ) return eval->Invalid("null value CCvin"); @@ -622,7 +622,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t assetoshis = IsTokensvout(false, false, cpTokens, NULL, vinTx, tx.vin[i].prevout.n, assetid); if (assetoshis != 0) { - std::cerr << "AssetCalcAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl; + //std::cerr << "AssetCalcAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl; inputs += assetoshis; } } @@ -634,7 +634,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t assetoshis = IsAssetvout(cpAssets, tmpprice, tmporigpubkey, tx, i, assetid); if (assetoshis != 0) { - std::cerr << "AssetCalcAmounts() vout i=" << i << " assetoshis=" << assetoshis << std::endl; + //std::cerr << "AssetCalcAmounts() vout i=" << i << " assetoshis=" << assetoshis << std::endl; outputs += assetoshis; } } diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 18f93f903..28adf9be6 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -392,7 +392,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("mismatched vout0 assets dual unspendable CCaddr for fill sell"); } } - fprintf(stderr,"fill validated\n"); + //fprintf(stderr,"fill validated\n"); break; case 'E': // fillexchange ////////// not implemented yet //////////// @@ -451,7 +451,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti } } ////////// not implemented yet //////////// - fprintf(stderr,"fill validated\n"); + //fprintf(stderr,"fill validated\n"); break; default: @@ -462,7 +462,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti // what does this do? bool bPrevent = PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts); - std::cerr << "AssetsValidate() PreventCC returned=" << bPrevent << std::endl; + //std::cerr << "AssetsValidate() PreventCC returned=" << bPrevent << std::endl; return (bPrevent); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 8442e9997..b05992ac5 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -148,7 +148,7 @@ uint8_t *OS_fileptr(long *allocsizep,char *fname); int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { - char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; if ( gametxidstr == 0 || *gametxidstr == 0 ) return(retval); sprintf(fname,"%s.gameinfo",gametxidstr); @@ -170,6 +170,8 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) if ( strcmp(statusstr,"registered") == 0 ) { retval = 0; + if ( (pname= jstr(item,"pname")) != 0 && strlen(pname) < MAXSTR-1 ) + strcpy(whoami,pname); if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 ) { decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 328e2b628..66e056b08 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -198,7 +198,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t { return(f); } - fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); + fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d (%s) (%s)\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size(),symbol,pname); return(0); } @@ -462,7 +462,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint return(0); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); - } + } else fprintf(stderr,"invalid player funcid.%c\n",funcid); } else fprintf(stderr,"couldnt get playertxid.%s\n",playertxid.GetHex().c_str()); return(-1); } From 616989f8ada2c7019dffb55c96546fe861064736 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 18:40:05 -1100 Subject: [PATCH 2084/3904] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 66e056b08..41b84ba27 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -198,7 +198,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t { return(f); } - fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d (%s) (%s)\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size(),symbol,pname); + fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d (%s) (%s)\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size(),symbol.c_str(),pname.c_str()); return(0); } @@ -462,7 +462,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint return(0); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); - } else fprintf(stderr,"invalid player funcid.%c\n",funcid); + } else fprintf(stderr,"invalid player funcid.%c\n",f); } else fprintf(stderr,"couldnt get playertxid.%s\n",playertxid.GetHex().c_str()); return(-1); } From 13a3898082917ed1ac28830e69b5886513e5a33d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 18:46:12 -1100 Subject: [PATCH 2085/3904] Test --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 41b84ba27..522ea842a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -172,11 +172,11 @@ CScript rogue_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std: CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata,std::string pname) { CScript opret; uint8_t evalcode = EVAL_ROGUE; std::string symbol(ASSETCHAINS_SYMBOL); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << regslot << pk << playerdata << symbol << pname); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << symbol << pname << regslot << pk << playerdata ); return(opret); } -uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol,std::string &pname,CScript scriptPubKey) +uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol, std::string &pname,CScript scriptPubKey) { std::string name, description; std::vector vorigPubkey; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; @@ -194,11 +194,11 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx vopret = vopretNonfungible; } - if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> regslot; ss >> pk; ss >> playerdata; ss >> symbol; ss >> pname) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> symbol; ss >> pname; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_ROGUE && (f == 'H' || f == 'Q') ) { return(f); } - fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d (%s) (%s)\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size(),symbol.c_str(),pname.c_str()); + fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); return(0); } From a12fe67278557f179395a97cf8f6ce87c422e17f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 19:11:09 -1100 Subject: [PATCH 2086/3904] Use name in game --- src/cc/rogue/rogue.c | 4 ++-- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b05992ac5..b4b1b7d15 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -170,10 +170,10 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) if ( strcmp(statusstr,"registered") == 0 ) { retval = 0; - if ( (pname= jstr(item,"pname")) != 0 && strlen(pname) < MAXSTR-1 ) - strcpy(whoami,pname); if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 ) { + if ( (pname= jstr(item,"pname")) != 0 && strlen(pname) < MAXSTR-1 ) + strcpy(whoami,pname); decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr); //fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); rs->restoring = 1; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 522ea842a..7fdc4f53a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -462,7 +462,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint return(0); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); - } else fprintf(stderr,"invalid player funcid.%c\n",f); + } //else fprintf(stderr,"invalid player funcid.%c\n",f); } else fprintf(stderr,"couldnt get playertxid.%s\n",playertxid.GetHex().c_str()); return(-1); } @@ -933,7 +933,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, nodata,pname); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); - fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx.c_str()); + //fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx.c_str()); } else { From 5eb4336781883f1367d02aa76871bc6e1d76eab1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 19:17:41 -1100 Subject: [PATCH 2087/3904] Set name roc --- src/cc/cclib.cpp | 4 ++++ src/cc/rogue_rpc.cpp | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f5a3d092e..c13f55ce4 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -63,6 +63,7 @@ CClib_methods[] = { (char *)"rogue", (char *)"playerinfo", (char *)"playertxid", 1, 1, 'I', EVAL_ROGUE }, { (char *)"rogue", (char *)"players", (char *)"", 0, 0, 'D', EVAL_ROGUE }, { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, + { (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -87,6 +88,7 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -122,6 +124,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(rogue_players(txfee,cp,params)); else if ( strcmp(method,"games") == 0 ) return(rogue_games(txfee,cp,params)); + else if ( strcmp(method,"setname") == 0 ) + return(rogue_setname(txfee,cp,params)); else { result.push_back(Pair("result","error")); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7fdc4f53a..4f287333e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1094,6 +1094,27 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); char *namestr = 0; + rogue_univalue(result,"setname",-1,-1); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n > 0 ) + { + if ( (namestr= jstri(params,0)) != 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("name",namestr)); + return(result); + } + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt get name")); + return(result); +} + bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true); From e87a92b347eb24c902d79593d5b569f09f53bbdf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 19:20:33 -1100 Subject: [PATCH 2088/3904] Rogue_pname --- src/cc/rogue_rpc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4f287333e..d19b24fd6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -22,6 +22,7 @@ #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 +std::string Rogue_pname = "fred"; /* Roguelander - using highlander competition between rogue players @@ -871,9 +872,9 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { UniValue obj; struct rogue_player P; if ( pname.size() == 0 ) - pname = "fred"; + pname = Rogue_pname; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); - fprintf(stderr,"found baton %s numkeys.%d seed.%llu playerdata.%d\n",batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname,batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { From e543773eb1614c94d88cab67afad6fa4f0c8c8bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 19:21:45 -1100 Subject: [PATCH 2089/3904] Syntax --- src/cc/rogue_rpc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d19b24fd6..f37d587ea 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -874,7 +874,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( pname.size() == 0 ) pname = Rogue_pname; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname,batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -1097,7 +1097,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); char *namestr = 0; + UniValue result(UniValue::VOBJ); int32_t n; char *namestr = 0; rogue_univalue(result,"setname",-1,-1); if ( (params= cclib_reparse(&n,params)) != 0 ) { @@ -1107,6 +1107,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("result","success")); result.push_back(Pair("name",namestr)); + Rogue_pname = namestr; return(result); } } From 25fc96b97fbc55a257fdced3cf37838e8894e464 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 19:38:13 -1100 Subject: [PATCH 2090/3904] In game whom --- src/cc/rogue/command.c | 5 +++-- src/cc/rogue/extern.c | 2 +- src/cc/rogue/rogue.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index e78e6b055..9446d704f 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -312,8 +312,9 @@ over: after = FALSE; msg(rs,"version %s. (mctesq was here)", release); when 'S': - after = FALSE; - save_game(rs); + msg(rs,"Saving is disabled, use bailout rpc"); + after = FALSE; + //save_game(rs); when '.': ; /* Rest command */ when ' ': after = FALSE; /* "Legal" illegal command */ when '^': diff --git a/src/cc/rogue/extern.c b/src/cc/rogue/extern.c index b84e6fa7b..39a48b23f 100644 --- a/src/cc/rogue/extern.c +++ b/src/cc/rogue/extern.c @@ -452,7 +452,7 @@ void externs_clear() memset(p_colors,0,sizeof(p_colors)); memset(prbuf,0,sizeof(prbuf)); memset(r_stones,0,sizeof(r_stones)); - memset(whoami,0,sizeof(whoami)); + //memset(whoami,0,sizeof(whoami)); memset(ws_made,0,sizeof(ws_made)); memset(ws_type,0,sizeof(ws_type)); runch = 0; /* Direction player is running */ diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b4b1b7d15..038ce3b0b 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -365,8 +365,8 @@ int rogue(int argc, char **argv, char **envp) if ((env = getenv("ROGUEOPTS")) != NULL) parse_opts(env); - if (env == NULL || whoami[0] == '\0') - strucpy(whoami, md_getusername(), (int) strlen(md_getusername())); + //if (env == NULL || whoami[0] == '\0') + // strucpy(whoami, md_getusername(), (int) strlen(md_getusername())); lowtime = (int) time(NULL); #ifdef MASTER if (wizard && getenv("SEED") != NULL) From 9db89931776503735286f012168f723f8e25151f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 20:19:46 -1100 Subject: [PATCH 2091/3904] STANDALONE --- src/cc/rogue/main.c | 4 ++++ src/cc/rogue/rogue.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index a41e51dc3..21c52deab 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -190,7 +190,11 @@ int32_t safecopy(char *dest,char *src,long len) #define true 1 #define false 0 +#ifdef STANDALONE +#include "../komodo/src/komodo_cJSON.c" +#else #include "../../komodo_cJSON.c" +#endif int32_t rogue_replay(uint64_t seed,int32_t sleeptime); int rogue(int argc, char **argv, char **envp); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 038ce3b0b..00cda9426 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -15,7 +15,11 @@ #include #include #include "rogue.h" +#ifdef STANDALONE +#include "../komodo/src/komodo_cJSON.h" +#else #include "../../komodo_cJSON.h" +#endif /* * main: @@ -175,7 +179,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) if ( (pname= jstr(item,"pname")) != 0 && strlen(pname) < MAXSTR-1 ) strcpy(whoami,pname); decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr); - //fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr)); + fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0)); rs->restoring = 1; } } From 3774bde4bb8e15db494dc62c9949df257d2eea2c Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 13 Feb 2019 13:15:10 +0500 Subject: [PATCH 2092/3904] added mytokenorders rpc --- src/cc/CCassets.h | 2 +- src/cc/CCassetstx.cpp | 130 ++++++++++++++++++++------------------- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 38 ++++++++---- 5 files changed, 96 insertions(+), 76 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 82fbcb961..036ba1340 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -47,7 +47,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t //int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance() int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); -UniValue AssetOrders(uint256 tokenid); +UniValue AssetOrders(uint256 tokenid, CPubKey pubkey); //UniValue AssetInfo(uint256 tokenid); //UniValue AssetList(); //std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 7673724f1..2b77e99bb 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -66,100 +66,102 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK } */ -UniValue AssetOrders(uint256 refassetid) +UniValue AssetOrders(uint256 refassetid, CPubKey pk) { static uint256 zero; UniValue result(UniValue::VARR); + struct CCcontract_info *cpAssets, assetsC; + struct CCcontract_info *cpTokens, tokensC; + + cpAssets = CCinit(&assetsC, EVAL_ASSETS); + cpTokens = CCinit(&assetsC, EVAL_TOKENS); + auto addOrders = [&](struct CCcontract_info *cp, std::vector >::const_iterator it) { uint256 txid, hashBlock, assetid, assetid2; int64_t price; std::vector origpubkey; - CTransaction vintx; + CTransaction ordertx; uint8_t funcid, evalCode; - char numstr[32], funcidstr[16], origaddr[64], assetidstr[65]; + char numstr[32], funcidstr[16], origaddr[64], origtokenaddr[64], assetidstr[65]; txid = it->first.txhash; //std::cerr << "addOrders() txid=" << txid.GetHex() << std::endl; - if ( GetTransaction(txid, vintx, hashBlock, false) != 0 ) + if ( GetTransaction(txid, ordertx, hashBlock, false) != 0 ) { // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); - //std::cerr << "addOrders() vintx.vout.size()=" << vintx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl; - if (vintx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) + if (ordertx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(ordertx.vout[ordertx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) { - if (refassetid != zero && assetid != refassetid) - { - //int32_t z; - //for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&txid)[z]); - //fprintf(stderr," txid\n"); - //for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&assetid)[z]); - //fprintf(stderr," assetid\n"); - //for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&refassetid)[z]); - //fprintf(stderr," refassetid\n"); - return; - } + LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() checking ordertx.vout.size()=" << ordertx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl); - //std::cerr << "addOrders() it->first.index=" << it->first.index << " vintx.vout[it->first.index].nValue=" << vintx.vout[it->first.index].nValue << std::endl; - if (vintx.vout[it->first.index].nValue == 0) - return; + if (refassetid != zero && assetid != refassetid || + pk.IsValid() && pk == pubkey2pk(origpubkey) && (funcid == 'S' || funcid == 's')) + { - UniValue item(UniValue::VOBJ); + LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() it->first.index=" << it->first.index << " ordertx.vout[it->first.index].nValue=" << ordertx.vout[it->first.index].nValue << std::endl); + if (ordertx.vout[it->first.index].nValue == 0) { + LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() order with value=0 skipped" << std::endl); + return; + } - funcidstr[0] = funcid; - funcidstr[1] = 0; - item.push_back(Pair("funcid", funcidstr)); - item.push_back(Pair("txid", uint256_str(assetidstr,txid))); - item.push_back(Pair("vout", (int64_t)it->first.index)); - if ( funcid == 'b' || funcid == 'B' ) - { - sprintf(numstr,"%.8f",(double)vintx.vout[it->first.index].nValue/COIN); - item.push_back(Pair("amount",numstr)); - sprintf(numstr,"%.8f",(double)vintx.vout[0].nValue/COIN); - item.push_back(Pair("bidamount",numstr)); - } - else - { - sprintf(numstr,"%llu",(long long)vintx.vout[it->first.index].nValue); - item.push_back(Pair("amount",numstr)); - sprintf(numstr,"%llu",(long long)vintx.vout[0].nValue); - item.push_back(Pair("askamount",numstr)); - } - if ( origpubkey.size() == 33 ) - { - GetCCaddress(cp, origaddr, pubkey2pk(origpubkey)); // TODO: what is this? is it asset or token?? - item.push_back(Pair("origaddress", origaddr)); - } - if ( assetid != zeroid ) - item.push_back(Pair("tokenid",uint256_str(assetidstr,assetid))); - if ( assetid2 != zeroid ) - item.push_back(Pair("otherid",uint256_str(assetidstr,assetid2))); - if ( price > 0 ) - { - if ( funcid == 's' || funcid == 'S' || funcid == 'e' || funcid == 'e' ) + UniValue item(UniValue::VOBJ); + + funcidstr[0] = funcid; + funcidstr[1] = 0; + item.push_back(Pair("funcid", funcidstr)); + item.push_back(Pair("txid", uint256_str(assetidstr, txid))); + item.push_back(Pair("vout", (int64_t)it->first.index)); + if (funcid == 'b' || funcid == 'B') { - sprintf(numstr,"%.8f",(double)price / COIN); - item.push_back(Pair("totalrequired", numstr)); - sprintf(numstr,"%.8f",(double)price / (COIN * vintx.vout[0].nValue)); - item.push_back(Pair("price", numstr)); + sprintf(numstr, "%.8f", (double)ordertx.vout[it->first.index].nValue / COIN); + item.push_back(Pair("amount", numstr)); + sprintf(numstr, "%.8f", (double)ordertx.vout[0].nValue / COIN); + item.push_back(Pair("bidamount", numstr)); } else { - item.push_back(Pair("totalrequired", (int64_t)price)); - sprintf(numstr,"%.8f",(double)vintx.vout[0].nValue / (price * COIN)); - item.push_back(Pair("price",numstr)); + sprintf(numstr, "%llu", (long long)ordertx.vout[it->first.index].nValue); + item.push_back(Pair("amount", numstr)); + sprintf(numstr, "%llu", (long long)ordertx.vout[0].nValue); + item.push_back(Pair("askamount", numstr)); } + if (origpubkey.size() == 33) + { + GetCCaddress(cp, origaddr, pubkey2pk(origpubkey)); + item.push_back(Pair("origaddress", origaddr)); + GetTokensCCaddress(cpTokens, origtokenaddr, pubkey2pk(origpubkey)); + item.push_back(Pair("origtokenaddress", origtokenaddr)); + + } + if (assetid != zeroid) + item.push_back(Pair("tokenid", uint256_str(assetidstr, assetid))); + if (assetid2 != zeroid) + item.push_back(Pair("otherid", uint256_str(assetidstr, assetid2))); + if (price > 0) + { + if (funcid == 's' || funcid == 'S' || funcid == 'e' || funcid == 'e') + { + sprintf(numstr, "%.8f", (double)price / COIN); + item.push_back(Pair("totalrequired", numstr)); + sprintf(numstr, "%.8f", (double)price / (COIN * ordertx.vout[0].nValue)); + item.push_back(Pair("price", numstr)); + } + else + { + item.push_back(Pair("totalrequired", (int64_t)price)); + sprintf(numstr, "%.8f", (double)ordertx.vout[0].nValue / (price * COIN)); + item.push_back(Pair("price", numstr)); + } + } + result.push_back(item); + LOGSTREAM("ccassets", CCLOG_DEBUG1, stream << "addOrders() added order funcId=" << (char)(funcid ? funcid : ' ') << " it->first.index=" << it->first.index << " ordertx.vout[it->first.index].nValue=" << ordertx.vout[it->first.index].nValue << " tokenid=" << assetid.GetHex() << std::endl); } - result.push_back(item); - //fprintf(stderr,"addOrders() func.(%c) %s/v%d %.8f\n",funcid,uint256_str(assetidstr,txid),(int32_t)it->first.index,(double)vintx.vout[it->first.index].nValue/COIN); } } }; std::vector > unspentOutputsTokens, unspentOutputsCoins; - struct CCcontract_info *cpAssets, assetsC; - - cpAssets = CCinit(&assetsC, EVAL_ASSETS); char assetsUnspendableAddr[64]; GetCCaddress(cpAssets, assetsUnspendableAddr, GetUnspendable(cpAssets, NULL)); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index d870e627c..98b5deccc 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -499,6 +499,7 @@ static const CRPCCommand vRPCCommands[] = { "tokens", "tokeninfo", &tokeninfo, true }, { "tokens", "tokenlist", &tokenlist, true }, { "tokens", "tokenorders", &tokenorders, true }, + { "tokens", "mytokenorders", &mytokenorders, true }, { "tokens", "tokenaddress", &tokenaddress, true }, { "tokens", "tokenbalance", &tokenbalance, true }, { "tokens", "tokencreate", &tokencreate, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index a2aba895b..9cacce8ac 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -241,6 +241,7 @@ extern UniValue coinsupply(const UniValue& params, bool fHelp); extern UniValue tokeninfo(const UniValue& params, bool fHelp); extern UniValue tokenlist(const UniValue& params, bool fHelp); extern UniValue tokenorders(const UniValue& params, bool fHelp); +extern UniValue mytokenorders(const UniValue& params, bool fHelp); extern UniValue tokenbalance(const UniValue& params, bool fHelp); extern UniValue assetsaddress(const UniValue& params, bool fHelp); extern UniValue tokenaddress(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c0f9dc297..643381648 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7038,8 +7038,8 @@ UniValue tokenorders(const UniValue& params, bool fHelp) { uint256 tokenid; if ( fHelp || params.size() > 1 ) - throw runtime_error("tokenorders [tokenid]\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + throw runtime_error("tokenorders tokenid\n"); + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7048,9 +7048,25 @@ UniValue tokenorders(const UniValue& params, bool fHelp) if (tokenid == zeroid) throw runtime_error("incorrect tokenid\n"); } - else - memset(&tokenid,0,sizeof(tokenid)); - return(AssetOrders(tokenid)); + else { + // memset(&tokenid, 0, sizeof(tokenid)); + throw runtime_error("no tokenid\n"); + } + return(AssetOrders(tokenid, CPubKey())); +} + + +UniValue mytokenorders(const UniValue& params, bool fHelp) +{ + uint256 tokenid; + if (fHelp || params.size() > 1) + throw runtime_error("mytokenorders\n"); + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + + return(AssetOrders(zeroid, Mypubkey())); } UniValue tokenbalance(const UniValue& params, bool fHelp) @@ -7235,7 +7251,7 @@ UniValue tokenbid(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t bidamount,numtokens; std::string hex; double price; uint256 tokenid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenbid numtokens tokenid price\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7277,7 +7293,7 @@ UniValue tokencancelbid(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; int32_t i; uint256 tokenid,bidtxid; if ( fHelp || params.size() != 2 ) throw runtime_error("tokencancelbid tokenid bidtxid\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7302,7 +7318,7 @@ UniValue tokenfillbid(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t fillamount; std::string hex; uint256 tokenid,bidtxid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenfillbid tokenid bidtxid fillamount\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7334,7 +7350,7 @@ UniValue tokenask(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t askamount,numtokens; std::string hex; double price; uint256 tokenid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenask numtokens tokenid price\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7396,7 +7412,7 @@ UniValue tokencancelask(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); std::string hex; int32_t i; uint256 tokenid,asktxid; if ( fHelp || params.size() != 2 ) throw runtime_error("tokencancelask tokenid asktxid\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7421,7 +7437,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t fillunits; std::string hex; uint256 tokenid,asktxid; if ( fHelp || params.size() != 3 ) throw runtime_error("tokenfillask tokenid asktxid fillunits\n"); - if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) + if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); From ea78447b3bd67821848a88016cabc533de403baa Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 13 Feb 2019 13:49:04 +0500 Subject: [PATCH 2093/3904] corr if selecting ordertx --- src/cc/CCassetstx.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 2b77e99bb..872fd1b72 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -87,7 +87,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk) char numstr[32], funcidstr[16], origaddr[64], origtokenaddr[64], assetidstr[65]; txid = it->first.txhash; - //std::cerr << "addOrders() txid=" << txid.GetHex() << std::endl; + LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() checking txid=" << txid.GetHex() << std::endl); if ( GetTransaction(txid, ordertx, hashBlock, false) != 0 ) { // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); @@ -95,8 +95,8 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk) { LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() checking ordertx.vout.size()=" << ordertx.vout.size() << " funcid=" << (char)(funcid ? funcid : ' ') << " assetid=" << assetid.GetHex() << std::endl); - if (refassetid != zero && assetid != refassetid || - pk.IsValid() && pk == pubkey2pk(origpubkey) && (funcid == 'S' || funcid == 's')) + if (refassetid != zero && assetid == refassetid || + pk != CPubKey() && pk == pubkey2pk(origpubkey) && (funcid == 'S' || funcid == 's')) { LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() it->first.index=" << it->first.index << " ordertx.vout[it->first.index].nValue=" << ordertx.vout[it->first.index].nValue << std::endl); From 1446f33ba8e7692ca0f3692cc1a1695955e741c9 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 13 Feb 2019 14:36:15 +0500 Subject: [PATCH 2094/3904] corr cp init --- src/cc/CCassetstx.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 872fd1b72..dde7666ab 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -75,7 +75,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk) struct CCcontract_info *cpTokens, tokensC; cpAssets = CCinit(&assetsC, EVAL_ASSETS); - cpTokens = CCinit(&assetsC, EVAL_TOKENS); + cpTokens = CCinit(&tokensC, EVAL_TOKENS); auto addOrders = [&](struct CCcontract_info *cp, std::vector >::const_iterator it) { @@ -169,9 +169,11 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk) char assetsTokensUnspendableAddr[64]; std::vector vopretNonfungible; - GetNonfungibleData(refassetid, vopretNonfungible); - if (vopretNonfungible.size() > 0) - cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + if (refassetid != zeroid) { + GetNonfungibleData(refassetid, vopretNonfungible); + if (vopretNonfungible.size() > 0) + cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; + } GetTokensCCaddress(cpAssets, assetsTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr); From 0b16f3942c979e01593930ef822aeca1b6580dea Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 13 Feb 2019 17:34:31 +0500 Subject: [PATCH 2095/3904] added non-fungible eval code param --- src/cc/CCassets.h | 2 +- src/cc/CCassetstx.cpp | 23 ++++++++++++++++++----- src/wallet/rpcwallet.cpp | 12 ++++++++---- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 036ba1340..af9ec5bd1 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -47,7 +47,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t //int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance() int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs); -UniValue AssetOrders(uint256 tokenid, CPubKey pubkey); +UniValue AssetOrders(uint256 tokenid, CPubKey pubkey, uint8_t additionalEvalCode); //UniValue AssetInfo(uint256 tokenid); //UniValue AssetList(); //std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index dde7666ab..14be084b4 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -66,7 +66,7 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK } */ -UniValue AssetOrders(uint256 refassetid, CPubKey pk) +UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) { static uint256 zero; UniValue result(UniValue::VARR); @@ -161,7 +161,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk) } }; - std::vector > unspentOutputsTokens, unspentOutputsCoins; + std::vector > unspentOutputsTokens, unspentOutputsDualEvalTokens, unspentOutputsCoins; char assetsUnspendableAddr[64]; GetCCaddress(cpAssets, assetsUnspendableAddr, GetUnspendable(cpAssets, NULL)); @@ -177,18 +177,31 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk) GetTokensCCaddress(cpAssets, assetsTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr); - // tokenasks: + // tokenbids: for (std::vector >::const_iterator itCoins = unspentOutputsCoins.begin(); itCoins != unspentOutputsCoins.end(); itCoins++) addOrders(cpAssets, itCoins); - // tokenbids: + // tokenasks: for (std::vector >::const_iterator itTokens = unspentOutputsTokens.begin(); itTokens != unspentOutputsTokens.end(); itTokens++) addOrders(cpAssets, itTokens); - + + if (additionalEvalCode != 0) { //this would be mytokenorders + char assetsDualEvalTokensUnspendableAddr[64]; + + // try also dual eval tokenasks (and we do not need bids): + cpAssets->additionalTokensEvalcode2 = additionalEvalCode; + GetTokensCCaddress(cpAssets, assetsDualEvalTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); + SetCCunspents(unspentOutputsDualEvalTokens, assetsDualEvalTokensUnspendableAddr); + + for (std::vector >::const_iterator itDualEvalTokens = unspentOutputsDualEvalTokens.begin(); + itDualEvalTokens != unspentOutputsDualEvalTokens.end(); + itDualEvalTokens++) + addOrders(cpAssets, itDualEvalTokens); + } return(result); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 643381648..220b1e30d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7052,21 +7052,25 @@ UniValue tokenorders(const UniValue& params, bool fHelp) // memset(&tokenid, 0, sizeof(tokenid)); throw runtime_error("no tokenid\n"); } - return(AssetOrders(tokenid, CPubKey())); + return AssetOrders(tokenid, CPubKey(), 0); } UniValue mytokenorders(const UniValue& params, bool fHelp) { uint256 tokenid; - if (fHelp || params.size() > 1) - throw runtime_error("mytokenorders\n"); + if (fHelp || params.size() > 2) + throw runtime_error("mytokenorders [evalcode]\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); - return(AssetOrders(zeroid, Mypubkey())); + uint8_t additionalEvalCode = 0; + if (params.size() == 1) + additionalEvalCode = atoi(params[0].get_str().c_str()); + + return AssetOrders(zeroid, Mypubkey(), additionalEvalCode); } UniValue tokenbalance(const UniValue& params, bool fHelp) From 9e855f8224e50ef6989c0bbe552aa274bee68892 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 13 Feb 2019 17:57:22 +0500 Subject: [PATCH 2096/3904] changed to strtol in mytokenorders --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 220b1e30d..5564c2000 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7068,7 +7068,7 @@ UniValue mytokenorders(const UniValue& params, bool fHelp) uint8_t additionalEvalCode = 0; if (params.size() == 1) - additionalEvalCode = atoi(params[0].get_str().c_str()); + additionalEvalCode = strtol(params[0].get_str().c_str(), NULL, 0); // supports also 0xEE-like values return AssetOrders(zeroid, Mypubkey(), additionalEvalCode); } From 1917708467bb4fa454ae191596c3353a08791d41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Feb 2019 06:35:56 -1100 Subject: [PATCH 2097/3904] Fix edge case --- src/cc/rogue/command.c | 7 +++++-- src/cc/rogue/main.c | 1 + src/cc/rogue/rogue.h | 10 ++++++++++ src/cc/rogue_rpc.cpp | 31 +++++++++++++++++-------------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 9446d704f..63aed25be 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -312,9 +312,12 @@ over: after = FALSE; msg(rs,"version %s. (mctesq was here)", release); when 'S': - msg(rs,"Saving is disabled, use bailout rpc"); after = FALSE; - //save_game(rs); +#ifdef STANDALONE + save_game(rs); +#else + msg(rs,"Saving is disabled, use bailout rpc"); +#endif when '.': ; /* Rest command */ when ' ': after = FALSE; /* "Legal" illegal command */ when '^': diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 21c52deab..c3484eafe 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -19,6 +19,7 @@ #include #include #include +#include #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 5eccb2e8c..a407ae8a6 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -17,6 +17,16 @@ #undef lines +#ifdef LINES +#undef LINES +#endif +#ifdef COLS +#undef COLS +#endif + +#define LINES 24 +#define COLS 80 + #define NOOP(x) (x += 0) #define CCHAR(x) ( (char) (x & A_CHARTEXT) ) /* diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f37d587ea..86a633212 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -22,6 +22,23 @@ #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 + +#define MAXPACK 23 +struct rogue_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; +struct rogue_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; + struct rogue_packitem roguepack[MAXPACK]; +}; +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); +#define ROGUE_DECLARED_PACK +void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); + + std::string Rogue_pname = "fred"; /* @@ -133,20 +150,6 @@ std::string Rogue_pname = "fred"; // ./c cclib bailout 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22]\" // ./komodo-cli -ac_name=ROGUE cclib register 17 \"[%22a898f4ceef7647ba113b9f3c24ef045f5d134935a3b09bdd1a997b9d474f4c1b%22,%22f11d0cb4e2e4c21f029a1146f8e5926f11456885b7ab7d665096f5efedec8ea0%22]\" -#define MAXPACK 23 -struct rogue_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; -struct rogue_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; - struct rogue_packitem roguepack[MAXPACK]; -}; -int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); -#define ROGUE_DECLARED_PACK -void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers) { From f993140b2d52a537c8ad45c66f390aa503b19213 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 12:25:01 +0800 Subject: [PATCH 2098/3904] ORKL --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 868956f8a..c2f902c82 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,7 +17,7 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "ORKL") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. From abf36fd1e4527a162cd33372ab0810094631f7bd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 12:25:29 +0800 Subject: [PATCH 2099/3904] ORKL --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 422d0da18..78ab4b11b 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,7 +17,7 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABST2") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "ORKL") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. From 498e6154a592dd43afecda118bb1a49fc065ba47 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 16:46:15 +0800 Subject: [PATCH 2100/3904] Add notarypay to eras, for main chain. --- src/komodo.h | 2 +- src/komodo_bitcoind.h | 29 +++++++++++++++++++++-------- src/komodo_defs.h | 4 ++-- src/komodo_globals.h | 4 ++-- src/komodo_utils.h | 24 ++++++++++++++++-------- src/main.cpp | 2 +- src/miner.cpp | 2 +- 7 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0ec83579c..17c98f203 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -885,7 +885,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) break; } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. - if ( !fJustCheck && ASSETCHAINS_NOTARY_PAY != 0 && i > 1) + if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e3e99d7c4..1bf909cf6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1778,8 +1778,21 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); -uint64_t komodo_notarypayamount(int64_t notarycount) +uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) { + int8_t curEra = 0; + // if we have an end block in the first era, find our current era + if ( ASSETCHAINS_ENDSUBSIDY[0] > 1 ) + { + for ( curEra = 0; curEra <= ASSETCHAINS_LASTERA; curEra++ ) + { + if ( ASSETCHAINS_ENDSUBSIDY[curEra] > nHeight || ASSETCHAINS_ENDSUBSIDY[curEra] == 0 ) + break; + } + } + if ( curEra > ASSETCHAINS_LASTERA ) + return(0); + if ( notarycount == 0 ) { fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); @@ -1798,16 +1811,16 @@ uint64_t komodo_notarypayamount(int64_t notarycount) return(0); } if ( prevnotarizedht == pprevnotarizedht ) - return(0); // cant happen, sanity check. + return(0); // cant happen, sanity check. // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, - // are them selves actually notarised and cannot be reorged. + // are them selves actually notarised and cannot be reorged. int32_t n = prevnotarizedht - pprevnotarizedht; - fprintf(stderr, "blocks since last notarization: %i\n",n); // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. - AmountToPay = ASSETCHAINS_NOTARY_PAY*n; + AmountToPay = ASSETCHAINS_NOTARY_PAY[curEra]*n; + fprintf(stderr, "era.%i paying total of %lu for %i blocks\n",curEra,AmountToPay,n); ret = AmountToPay / notarycount; return(ret); } @@ -1859,7 +1872,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar txNew.vout.resize(NotarisationNotaries.size()+1); // Calcualte the amount to pay. If 0, means not enough notarizations to calcuate amount. - AmountToPay = komodo_notarypayamount(NotarisationNotaries.size()); + AmountToPay = komodo_notarypayamount(height,NotarisationNotaries.size()); if ( AmountToPay == 0 ) return(0); @@ -1973,7 +1986,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { matches++; total += txout.nValue; - fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]); + //fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]); } else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]); } @@ -2171,7 +2184,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) // the default daemon miner, checks the actual vins so the only way this will fail, is if someone changes the miner, // and then creates txs to the crypto address meeting min sigs and puts it in tx position 1. // If they go through this effort, the block will still fail at connect block, and will be auto purged by the temp file fix. - if ( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() > 1 ) + if ( failed == 0 && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[0].vout.size() > 1 ) { // We check the full validation in ConnectBlock directly to get the amount for coinbase. So just approx here. if ( slowflag == 0 ) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 32fb74dab..09490f3f0 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -40,7 +40,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD, ASSETCHAINS_NOTARY_PAY; +extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD; extern uint64_t ASSETCHAINS_TIMELOCKGTE; extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE; @@ -48,7 +48,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 13caee41d..c00247da5 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -69,7 +69,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; uint64_t ASSETCHAINS_LASTERA = 1; -uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; +uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; uint8_t ASSETCHAINS_CCDISABLES[256]; #define _ASSETCHAINS_EQUIHASH 0 @@ -97,7 +97,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t ASSETCHAINS_STAKED; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_NOTARY_PAY; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fd312e527..6e4a09546 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1764,6 +1764,7 @@ void komodo_args(char *argv0) Split(GetArg("-ac_reward",""), ASSETCHAINS_REWARD, 0); Split(GetArg("-ac_halving",""), ASSETCHAINS_HALVING, 0); Split(GetArg("-ac_decay",""), ASSETCHAINS_DECAY, 0); + Split(GetArg("-ac_notarypay",""), ASSETCHAINS_NOTARY_PAY, 0); for ( int i = 0; i < ASSETCHAINS_MAX_ERAS; i++ ) { @@ -1777,6 +1778,11 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY[i] = 0; printf("ERA%u: ASSETCHAINS_DECAY cant be more than 100000000\n", i); } + if ( ASSETCHAINS_NOTARY_PAY[i] < 64 ) + { + ASSETCHAINS_NOTARY_PAY[i] = 64; + printf("ERA%u: ASSETCHAINS_NOTARY_PAY cant be less than 64. Set to 64.\n", i); + } } MAX_BLOCK_SIGOPS = 60000; @@ -1869,6 +1875,11 @@ void komodo_args(char *argv0) } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) + { + printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n"); + exit(0); + } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) { decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); @@ -1894,9 +1905,6 @@ void komodo_args(char *argv0) } else { - ASSETCHAINS_NOTARY_PAY = GetArg("-ac_notarypay",0); - if ( ASSETCHAINS_NOTARY_PAY != 0 ) - printf("Assetchains NOTARY PAY set to %lu sats per notarisation per notary. Cannot work with ac_script or ac_pubkey!\n",ASSETCHAINS_NOTARY_PAY); if ( ASSETCHAINS_COMMISSION != 0 ) { ASSETCHAINS_COMMISSION = 0; @@ -1913,7 +1921,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1922,17 +1930,19 @@ void komodo_args(char *argv0) // if we have one era, this should create the same data structure as it used to, same if we increase _MAX_ERAS for ( int i = 0; i <= ASSETCHAINS_LASTERA; i++ ) { - printf("ERA%u: end.%llu reward.%llu halving.%llu decay.%llu\n", i, + printf("ERA%u: end.%llu reward.%llu halving.%llu decay.%llu notarypay.%llu\n", i, (long long)ASSETCHAINS_ENDSUBSIDY[i], (long long)ASSETCHAINS_REWARD[i], (long long)ASSETCHAINS_HALVING[i], - (long long)ASSETCHAINS_DECAY[i]); + (long long)ASSETCHAINS_DECAY[i], + (long long)ASSETCHAINS_NOTARY_PAY[i]); // TODO: Verify that we don't overrun extrabuf here, which is a 256 byte buffer extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY[i]),(void *)&ASSETCHAINS_ENDSUBSIDY[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]); + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); } if (ASSETCHAINS_LASTERA > 0) @@ -2008,8 +2018,6 @@ void komodo_args(char *argv0) } fprintf(stderr," <- CCLIB name\n"); } - if ( ASSETCHAINS_NOTARY_PAY != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY),(void *)&ASSETCHAINS_NOTARY_PAY); } addn = GetArg("-seednode",""); diff --git a/src/main.cpp b/src/main.cpp index 283e8ee38..cd42e109a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3282,7 +3282,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() > 10 ) + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) { // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. diff --git a/src/miner.cpp b/src/miner.cpp index 36ef947d3..ba946fe58 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -722,7 +722,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; // timelocks and commissions are currently incompatible due to validation complexity of the combination } - else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) + else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; From b9b3afcbe67759298bcacb309dcd3505a7d5cd12 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 17:37:37 +0800 Subject: [PATCH 2101/3904] notarypay in getinfo --- src/rpc/misc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 15386d42a..2c8d17138 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -82,7 +82,7 @@ extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_MAGIC,ASSETCHAINS_ALGO; extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; -extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[]; +extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[],ASSETCHAINS_NOTARY_PAY[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; int32_t getera(int now) @@ -287,7 +287,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_LASTERA > 0 ) { - std::string acReward = "", acHalving = "", acDecay = "", acEndSubsidy = ""; + std::string acReward = "", acHalving = "", acDecay = "", acEndSubsidy = "", acNotaryPay = ""; for (int i = 0; i <= ASSETCHAINS_LASTERA; i++) { if (i == 0) @@ -296,6 +296,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) acHalving = std::to_string(ASSETCHAINS_HALVING[i]); acDecay = std::to_string(ASSETCHAINS_DECAY[i]); acEndSubsidy = std::to_string(ASSETCHAINS_ENDSUBSIDY[i]); + acNotaryPay = std::to_string(ASSETCHAINS_NOTARY_PAY[i]); } else { @@ -303,6 +304,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) acHalving += "," + std::to_string(ASSETCHAINS_HALVING[i]); acDecay += "," + std::to_string(ASSETCHAINS_DECAY[i]); acEndSubsidy += "," + std::to_string(ASSETCHAINS_ENDSUBSIDY[i]); + acNotaryPay += "," + std::to_string(ASSETCHAINS_NOTARY_PAY[i]); } } if (ASSETCHAINS_LASTERA > 0) @@ -311,6 +313,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("halving", acHalving)); obj.push_back(Pair("decay", acDecay)); obj.push_back(Pair("endsubsidy", acEndSubsidy)); + obj.push_back(Pair("notarypay", acNotaryPay)); } if ( ASSETCHAINS_COMMISSION != 0 ) From 5740e8605efb0ce939b0d5458f0a88ce6e2cc2ac Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 14 Feb 2019 12:01:18 +0100 Subject: [PATCH 2102/3904] add depends include os specific dependency headers --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 08c86dee8..c4fc45dd7 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,7 @@ cd rogue; ./configure # only need this first time make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses +gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From 497302dc75ed5ee52466b928a5fb8d02e3ccd4b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:04:28 +0800 Subject: [PATCH 2103/3904] Fix not being able to mine first 3 notarizations. --- src/main.cpp | 20 +++++++++++++++++++- src/miner.cpp | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cd42e109a..eafde8df6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3248,6 +3248,24 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); +bool check_pprevnotarizedht() +{ + static bool init; + if ( init ) + return(true); + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; + uint64_t AmountToPay=0,ret=0; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); + if ( pprevnotarizedht > 0 ) + { + init = true; + return(true); + } + else + return(false); +} + + bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3282,7 +3300,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 && check_pprevnotarizedht() ) { // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. diff --git a/src/miner.cpp b/src/miner.cpp index ba946fe58..a0174a884 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -393,6 +393,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (fNotarisation) { + // Can't make payment until 3 notarizations have happened. + if ( !check_pprevnotarizedht() ) + fNotarisation = false; // check if the notarization found is actually valid. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { From dc343dfd97ea0c4bda74bf7505862f3ac4673eae Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:06:11 +0800 Subject: [PATCH 2104/3904] fix --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index a0174a884..00270dcd8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,6 +155,7 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); +bool check_pprevnotarizedht(); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { From 2b86a48372ffc41e37200735cdc9422ded6a93bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:19:13 +0800 Subject: [PATCH 2105/3904] fix --- src/komodo.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 17c98f203..45dc80948 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -38,6 +38,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block); +bool check_pprevnotarizedht(); #include "komodo_structs.h" #include "komodo_globals.h" @@ -885,7 +886,8 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) break; } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. - if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) + // make sure for first 3 notarizations, that we check all tx in block! + if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 && check_pprevnotarizedht() ) break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); From 695eb871bb8cb0bb7b5bbbabab2f844019cedb8c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:52:58 +0800 Subject: [PATCH 2106/3904] Fix miner --- src/komodo_bitcoind.h | 1 + src/miner.cpp | 82 +++++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1bf909cf6..91ffc9043 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1805,6 +1805,7 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) //fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d \n",notarizedht,prevnotarizedht,pprevnotarizedht); // We cannot pay out if 3 notarisation's have not yet happened! + // redundant now... should never happen. if ( pprevnotarizedht == 0 ) { fprintf(stderr, "need 3 notarizations to happen before notaries can be paid.\n"); diff --git a/src/miner.cpp b/src/miner.cpp index 00270dcd8..60c4086dd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -396,52 +396,58 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { // Can't make payment until 3 notarizations have happened. if ( !check_pprevnotarizedht() ) - fNotarisation = false; - // check if the notarization found is actually valid. - if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { - // Get the OP_RETURN for the notarisation - uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; - int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); - if ( script[0] == OP_RETURN ) + fNotarisation = false; + fNotarisationBlock = false; + } + else + { + // check if the notarization found is actually valid. + if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { - int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); - if ( notarizedheight != 0 ) + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) { - if ( last_notarizedheight == 0 ) + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) { - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - last_notarizedheight = notarizedheight; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + if ( last_notarizedheight == 0 ) + { + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + last_notarizedheight = notarizedheight; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + } + else if ( notarizedheight > last_notarizedheight ) + continue; // leave this notarisation for the next block, it will be valid! + else if ( notarizedheight == last_notarizedheight ) + continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! + else + { + // we need to remove the last seen notarzation from block + const CTransaction& Tx = *(vecPriority.front().get<2>()); + TxPriorityCompare comparer(0); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + // add this one as its valid before the other one. + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); + } } - else if ( notarizedheight > last_notarizedheight ) - continue; // leave this notarisation for the next block, it will be valid! - else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else + else if ( fNotarisationBlock == true ) { - // we need to remove the last seen notarzation from block - const CTransaction& Tx = *(vecPriority.front().get<2>()); - TxPriorityCompare comparer(0); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - // add this one as its valid before the other one. - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); + // Any attempted notarization needs to be in its own block! + // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. + continue; } } - else if ( fNotarisationBlock == true ) - { - // Any attempted notarization needs to be in its own block! - // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. - continue; - } } } } From 52450bf20292f572bd7759f944850725d1a36abe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 21:59:05 +0800 Subject: [PATCH 2107/3904] fix miner better --- src/komodo.h | 4 +++ src/miner.cpp | 85 +++++++++++++++++++++++---------------------------- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 45dc80948..1e69504d0 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -709,6 +709,10 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar { if ( fJustCheck ) return(-2); + // On the first notarization initilise previous previous to 0. + if ( sp->NUM_NPOINTS == 1 ) + sp->PPNOTARIZED_HEIGHT = 0; + sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; diff --git a/src/miner.cpp b/src/miner.cpp index 60c4086dd..e10ba290c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -392,62 +392,53 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if (fNotarisation) + if ( fNotarisation && check_pprevnotarizedht() ) { - // Can't make payment until 3 notarizations have happened. - if ( !check_pprevnotarizedht() ) + // check if the notarization found is actually valid. + if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { - fNotarisation = false; - fNotarisationBlock = false; - } - else - { - // check if the notarization found is actually valid. - if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) { - // Get the OP_RETURN for the notarisation - uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; - int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); - if ( script[0] == OP_RETURN ) + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) { - int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); - if ( notarizedheight != 0 ) + if ( last_notarizedheight == 0 ) { - if ( last_notarizedheight == 0 ) - { - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - last_notarizedheight = notarizedheight; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); - } - else if ( notarizedheight > last_notarizedheight ) - continue; // leave this notarisation for the next block, it will be valid! - else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else - { - // we need to remove the last seen notarzation from block - const CTransaction& Tx = *(vecPriority.front().get<2>()); - TxPriorityCompare comparer(0); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - // add this one as its valid before the other one. - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); - } + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + last_notarizedheight = notarizedheight; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); } - else if ( fNotarisationBlock == true ) + else if ( notarizedheight > last_notarizedheight ) + continue; // leave this notarisation for the next block, it will be valid! + else if ( notarizedheight == last_notarizedheight ) + continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! + else { - // Any attempted notarization needs to be in its own block! - // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. - continue; + // we need to remove the last seen notarzation from block + const CTransaction& Tx = *(vecPriority.front().get<2>()); + TxPriorityCompare comparer(0); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + // add this one as its valid before the other one. + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } } + else if ( fNotarisationBlock == true ) + { + // Any attempted notarization needs to be in its own block! + // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. + continue; + } } } } From d7a122c548c01b9eaa7e4b58694ef332b84c4e94 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 00:13:48 +0800 Subject: [PATCH 2108/3904] fix reorged notarisation to use the same data points --- src/komodo.h | 8 +++++--- src/komodo_bitcoind.h | 30 +++++++++++++++++++----------- src/komodo_notary.h | 3 ++- src/komodo_structs.h | 2 +- src/main.cpp | 19 +++++++++---------- src/rpc/misc.cpp | 6 +++--- 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 1e69504d0..34051f173 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -267,10 +267,11 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; } + sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth); - printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT); + printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d PPPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,sp->PPPNOTARIZED_HEIGHT); } else if ( func == 'U' ) // deprecated { @@ -711,8 +712,9 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar return(-2); // On the first notarization initilise previous previous to 0. if ( sp->NUM_NPOINTS == 1 ) - sp->PPNOTARIZED_HEIGHT = 0; - + sp->PPPNOTARIZED_HEIGHT = 0; + + sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 91ffc9043..ce6d03076 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,7 +1776,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) { @@ -1799,24 +1799,32 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) return(0); } // fetch notarised height, the previous, and the one before that. - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; + int32_t notarizedht=0,prevMoMheight,prevnotarizedht=0,pprevnotarizedht=0,ppprevnotarizedht=0,n=0; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); - //fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d \n",notarizedht,prevnotarizedht,pprevnotarizedht); + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d ppprevnotarizedht.%d\n",notarizedht,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht); - // We cannot pay out if 3 notarisation's have not yet happened! + // We cannot pay out if 4 notarisation's have not yet happened! // redundant now... should never happen. - if ( pprevnotarizedht == 0 ) + if ( ppprevnotarizedht == 0 ) { - fprintf(stderr, "need 3 notarizations to happen before notaries can be paid.\n"); + fprintf(stderr, "need 4 notarizations to happen before notaries can be paid.\n"); return(0); } if ( prevnotarizedht == pprevnotarizedht ) return(0); // cant happen, sanity check. - - // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, - // are them selves actually notarised and cannot be reorged. - int32_t n = prevnotarizedht - pprevnotarizedht; + + if ( notarizedht == nHeight ) + { + // we need to use the previous previous previous notarized heights, to make sure the payment is the same, if trying to use a reorged nota. + n = ppprevnotarizedht - pprevnotarizedht; + } + else + { + // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, + // are them selves actually notarised and cannot be reorged. + n = prevnotarizedht - pprevnotarizedht; + } // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 88a079348..5c3372193 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,7 +452,7 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) @@ -461,6 +461,7 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 * *txidp = sp->NOTARIZED_DESTTXID; *prevNotarizedHt = sp->PNOTARIZED_HEIGHT; *ppNotarizedHt = sp->PPNOTARIZED_HEIGHT; + *pppNotarizedHt = sp->PPPNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index b7a0ddd24..793957756 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,PPPNOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index eafde8df6..b31a1be80 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3253,10 +3253,9 @@ bool check_pprevnotarizedht() static bool init; if ( init ) return(true); - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; - uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); - if ( pprevnotarizedht > 0 ) + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + if ( ppprevnotarizedht > 0 ) { init = true; return(true); @@ -3926,8 +3925,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t prevMoMheight,prevnotarizedht,prevNotarizedHt; uint256 notarizedhash,txid; - komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4261,8 +4260,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevnotarizedht,prevNotarizedHt,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5613,8 +5612,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 2c8d17138..9bc2c0785 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); From 3c605c86a027f5880335211c09cb07b8b999caa0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 00:19:27 +0800 Subject: [PATCH 2109/3904] fix mergetoaddress --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c6bf320a2..5996eb870 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5093,7 +5093,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); //fprintf(stderr, "num utxos.%li\n", numUtxos); - if (numUtxos < 1 && numNotes == 0) { + if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From 2172cb6742dcda47fa1c5b6a653c5be0fde1f9ac Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 00:32:44 +0800 Subject: [PATCH 2110/3904] fix --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e10ba290c..540aee622 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 continue; // leave this notarisation for the next block, it will be valid! else if ( notarizedheight == last_notarizedheight ) continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else + else if ( notarizedheight < last_notarizedheight ) { // we need to remove the last seen notarzation from block const CTransaction& Tx = *(vecPriority.front().get<2>()); @@ -433,12 +433,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } } - else if ( fNotarisationBlock == true ) + else if ( Notarisations > 1 ) { // Any attempted notarization needs to be in its own block! // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } + Notarisations++; } } } From a37e1ae63363c64f1503e9a7c9c306666d3b432c Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 14 Feb 2019 23:02:38 +0500 Subject: [PATCH 2111/3904] vopretStripped eliminated in heir cc --- src/cc/heir.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 4fea0be1e..d90f87d07 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -327,16 +327,17 @@ uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& { uint8_t evalCodeTokens = 0; std::vector voutPubkeysDummy; - std::vector vopretExtra, vopretStripped; + std::vector vopretExtra /*, vopretStripped*/; if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { if (vopretExtra.size() > 1) { // restore the second opret: - if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size + /* unmarshalled in DecodeTokenOpRet: + if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; return (uint8_t)0; - } + }*/ } else { if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl; @@ -344,10 +345,10 @@ uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& } } else { - GetOpReturnData(scriptPubKey, vopretStripped); + GetOpReturnData(scriptPubKey, vopretExtra); } - return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); + return _DecodeHeirOpRet(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, fundingTxidInOpret, hasHeirSpendingBegun, noLogging); } // overload to decode opret in fundingtxid: From dc739bc9daac0bff64c829adbe3de87018676f00 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 14 Feb 2019 23:33:34 +0500 Subject: [PATCH 2112/3904] empty if{} removed --- src/cc/heir.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index d90f87d07..aca30208b 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -330,16 +330,16 @@ uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& std::vector vopretExtra /*, vopretStripped*/; if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { - if (vopretExtra.size() > 1) { - // restore the second opret: + /* if (vopretExtra.size() > 1) { + // restore the second opret: - /* unmarshalled in DecodeTokenOpRet: + /* unmarshalled in DecodeTokenOpRet: if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size - if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; - return (uint8_t)0; - }*/ - } - else { + if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl; + return (uint8_t)0; + } + } */ + if (vopretExtra.size() < 1) { if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl; return (uint8_t)0; } From 2933c4d2a9220576e0fc5766c50c006374282827 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 14 Feb 2019 22:08:20 +0000 Subject: [PATCH 2113/3904] modified: assetchains.json modified: assetchains.old --- src/assetchains.json | 9 ++++++++- src/assetchains.old | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 2775f5db3..c4e61d395 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -240,5 +240,12 @@ "217.182.129.38", "37.187.225.231" ] - } + }, + { + "ac_name": "ILN", + "ac_supply": "10000000000", + "ac_cc": "2", + "addnode": ["51.75.122.83"] + } + ] diff --git a/src/assetchains.old b/src/assetchains.old index 41cbbdae1..c1b2594fe 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -47,4 +47,5 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & +./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 & From 8702ec813060035217711e4d8b1bbb2409968ad8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 14 Feb 2019 22:34:38 +0000 Subject: [PATCH 2114/3904] new file: ac/ilien new file: fiat/ilien --- src/ac/ilien | 3 +++ src/fiat/ilien | 3 +++ 2 files changed, 6 insertions(+) create mode 100755 src/ac/ilien create mode 100755 src/fiat/ilien diff --git a/src/ac/ilien b/src/ac/ilien new file mode 100755 index 000000000..53e571661 --- /dev/null +++ b/src/ac/ilien @@ -0,0 +1,3 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 + diff --git a/src/fiat/ilien b/src/fiat/ilien new file mode 100755 index 000000000..53e571661 --- /dev/null +++ b/src/fiat/ilien @@ -0,0 +1,3 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 + From 791d8dc13b4b75800f1f7caf38892ec340e13f2e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 11:01:10 +0800 Subject: [PATCH 2115/3904] remove dynamic notary pay reward and revert to static amounts, cannot work! --- src/komodo.h | 36 ++++++++++----------------------- src/komodo_bitcoind.h | 46 ++++++++----------------------------------- src/komodo_notary.h | 5 +---- src/komodo_structs.h | 2 +- src/main.cpp | 30 +++++++--------------------- src/miner.cpp | 5 +++-- src/rpc/misc.cpp | 6 +++--- 7 files changed, 33 insertions(+), 97 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 34051f173..82341a369 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -267,11 +267,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; } - sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; - sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; - sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth); - printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d PPPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,sp->PPPNOTARIZED_HEIGHT); } else if ( func == 'U' ) // deprecated { @@ -701,22 +697,12 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - // If we are checking a reorged notarisation tx we need to return true. So the coinbase can be recreated, otherwise notaries are not paid, - // if a notarisation TX is reorged before the next notarization happens! - if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) + // Because of reorgs its not possible to use notarizations that are in order. If its validated pay the notaries! + if ( fJustCheck ) return(-2); if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { - if ( fJustCheck ) - return(-2); - // On the first notarization initilise previous previous to 0. - if ( sp->NUM_NPOINTS == 1 ) - sp->PPPNOTARIZED_HEIGHT = 0; - - sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; - sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; - sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; @@ -727,7 +713,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar } komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("[%s] ht.%d NUM_NPOINTS.%d NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,sp->NUM_NPOINTS,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); + printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { @@ -753,8 +739,8 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0); } } - } else if ( fJustCheck ) - return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one! + } //else if ( fJustCheck ) + // return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one! } else if ( opretlen != 149 && height > 600000 && matched != 0 ) printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } @@ -893,7 +879,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. // make sure for first 3 notarizations, that we check all tx in block! - if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 && check_pprevnotarizedht() ) + if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); @@ -971,12 +957,11 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); - if ( fJustCheck && (notaryid == -2 || notaryid == -3) ) + if ( fJustCheck && notaryid == -2 ) { - // We see a valid notarisation here, save its location. + // We see a valid notarisation here, save its location. notarisations.push_back(i); } - //fprintf(stderr, "notaryid.%i\n",notaryid); if ( 0 && i > 0 ) { for (k=0; kGetHeight()); if (fJustCheck) { - if (notarisations.size() == 0) + if ( notarisations.size() == 0 ) return(0); if ( notarisations.size() == 1 && notarisations[0] == 1 ) return(1); - else + if ( notarisations.size() > 1 ) return(-1); } else return(0); } - #endif diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ce6d03076..e1ef2c21d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,11 +1776,9 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); - uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) { - int8_t curEra = 0; + int8_t curEra = 0; int64_t ret = 0; // if we have an end block in the first era, find our current era if ( ASSETCHAINS_ENDSUBSIDY[0] > 1 ) { @@ -1798,39 +1796,11 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); } - // fetch notarised height, the previous, and the one before that. - int32_t notarizedht=0,prevMoMheight,prevnotarizedht=0,pprevnotarizedht=0,ppprevnotarizedht=0,n=0; uint256 notarizedhash,txid; - uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); - fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d ppprevnotarizedht.%d\n",notarizedht,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht); - - // We cannot pay out if 4 notarisation's have not yet happened! - // redundant now... should never happen. - if ( ppprevnotarizedht == 0 ) - { - fprintf(stderr, "need 4 notarizations to happen before notaries can be paid.\n"); - return(0); - } - if ( prevnotarizedht == pprevnotarizedht ) - return(0); // cant happen, sanity check. - - if ( notarizedht == nHeight ) - { - // we need to use the previous previous previous notarized heights, to make sure the payment is the same, if trying to use a reorged nota. - n = ppprevnotarizedht - pprevnotarizedht; - } - else - { - // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, - // are them selves actually notarised and cannot be reorged. - n = prevnotarizedht - pprevnotarizedht; - } - - // multiply the amount possible to be used for each block by the amount of blocks passed - // to get the total posible to be paid for this notarisation. - AmountToPay = ASSETCHAINS_NOTARY_PAY[curEra]*n; - fprintf(stderr, "era.%i paying total of %lu for %i blocks\n",curEra,AmountToPay,n); - ret = AmountToPay / notarycount; + // Because of reorgs we cannot use the notarized height value. + // We need to basically guess here and just pay some static amount. + // Has the unwanted effect of varying coin emission, but cannot be helped. + fprintf(stderr, "era.%i paying total of %lu\n",curEra, ASSETCHAINS_NOTARY_PAY[curEra]); + ret = ASSETCHAINS_NOTARY_PAY[curEra] / notarycount; return(ret); } @@ -1852,6 +1822,7 @@ int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *sc } else { + // This should no longer happen. Unless notaries are making actual invalid notarizations. fprintf(stderr, "<<<<< &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len) { // fetch notary pubkey array. - // Need a better/safer way for notaries era, should really be height based rather than timestamp? uint64_t total = 0, AmountToPay = 0; int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; @@ -1880,7 +1850,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); - // Calcualte the amount to pay. If 0, means not enough notarizations to calcuate amount. + // Calcualte the amount to pay according to the current era. AmountToPay = komodo_notarypayamount(height,NotarisationNotaries.size()); if ( AmountToPay == 0 ) return(0); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5c3372193..c4984cee2 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,16 +452,13 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { *hashp = sp->NOTARIZED_HASH; *txidp = sp->NOTARIZED_DESTTXID; - *prevNotarizedHt = sp->PNOTARIZED_HEIGHT; - *ppNotarizedHt = sp->PPNOTARIZED_HEIGHT; - *pppNotarizedHt = sp->PPPNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 793957756..6b7c316b6 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,PPPNOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index b31a1be80..ab95e5b34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3248,22 +3248,6 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); -bool check_pprevnotarizedht() -{ - static bool init; - if ( init ) - return(true); - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); - if ( ppprevnotarizedht > 0 ) - { - init = true; - return(true); - } - else - return(false); -} - bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { @@ -3299,7 +3283,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 && check_pprevnotarizedht() ) + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) { // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. @@ -3925,8 +3909,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4260,8 +4244,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5612,8 +5596,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/miner.cpp b/src/miner.cpp index 540aee622..539b039c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -392,7 +392,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if ( fNotarisation && check_pprevnotarizedht() ) + if ( fNotarisation ) { // check if the notarization found is actually valid. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) @@ -402,6 +402,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { + Notarisations++; int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); if ( notarizedheight != 0 ) { @@ -435,11 +436,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } else if ( Notarisations > 1 ) { + fprintf(stderr, "skipping notarizations.%d\n",Notarisations); // Any attempted notarization needs to be in its own block! // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } - Notarisations++; } } } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 9bc2c0785..b7f202cb4 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); From f577aa00330f4de75bd9899bbe041c26e469f554 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 11:12:17 +0800 Subject: [PATCH 2116/3904] fix validation --- src/komodo.h | 2 +- src/main.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 82341a369..93e0d9eb2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -1025,7 +1025,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) return(0); if ( notarisations.size() == 1 && notarisations[0] == 1 ) return(1); - if ( notarisations.size() > 1 ) + if ( notarisations.size() > 1 || (notarisations.size() == 1 && notarisations[0] != 1) ) return(-1); } else return(0); diff --git a/src/main.cpp b/src/main.cpp index ab95e5b34..66766e795 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3248,7 +3248,6 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); - bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3288,9 +3287,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); - // -1 means that the valid notarization isnt in position 1. + // -1 means that the valid notarization isnt in position 1 or there are too many notarizations in this block. if ( notarisationTx == -1 ) - return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + return state.DoS(100, error("ConnectBlock(): Notarization is not in TX position 1 or block contains more than 1 notarization! Invalid Block!"), REJECT_INVALID, "bad-notarization-position"); // 1 means this block contains a valid notarisation and its in position 1. // its no longer possible for any attempted notarization to be in a block with a valid one! From 98fe10d12c6cfa925ef60e5425980b3aed0752bf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 14:29:59 +0800 Subject: [PATCH 2117/3904] enable prints for network hack --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 66766e795..46d259568 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5488,11 +5488,11 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo { pfrom->nBlocksinARow = 0; pfrom->nBlocksinARow2 = 0; - //fprintf(stderr, "reset node.%i\n",(int32_t)pfrom->GetId()); + fprintf(stderr, "reset node.%i\n",(int32_t)pfrom->GetId()); } else { - //fprintf(stderr, "Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",(int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2); + fprintf(stderr, "Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",(int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2); return(false); } } From 28ee0fd7565a4ac9247be588e2af67af4c711b95 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Feb 2019 20:24:44 -1100 Subject: [PATCH 2118/3904] -fred --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 86a633212..e2e427545 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -39,7 +39,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); -std::string Rogue_pname = "fred"; +std::string Rogue_pname = ""; /* Roguelander - using highlander competition between rogue players @@ -403,7 +403,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); obj.push_back(Pair("chain",symbol)); - obj.push_back(Pair("name",pname)); + obj.push_back(Pair("pname",pname)); return(obj); } From b6e147e4d81b7aabbda58a0940ac1b7eb96ac243 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Feb 2019 20:42:03 -1100 Subject: [PATCH 2119/3904] pname --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e2e427545..70a4b842e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1109,7 +1109,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( (namestr= jstri(params,0)) != 0 ) { result.push_back(Pair("result","success")); - result.push_back(Pair("name",namestr)); + result.push_back(Pair("pname",namestr)); Rogue_pname = namestr; return(result); } From 871b765999694f5943f11bb359cf76fe41867332 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Fri, 15 Feb 2019 17:18:40 +0800 Subject: [PATCH 2120/3904] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c6bf320a2..5996eb870 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5093,7 +5093,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); //fprintf(stderr, "num utxos.%li\n", numUtxos); - if (numUtxos < 1 && numNotes == 0) { + if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From e6d764b081e3c18d954d3b1538b15a9ee405b789 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 17:20:48 +0800 Subject: [PATCH 2121/3904] fix miner getting stuck --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 539b039c3..aa19c3bd7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -406,13 +406,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); if ( notarizedheight != 0 ) { + //fprintf(stderr, "notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); if ( last_notarizedheight == 0 ) { // this is the first one we see, add it to the block as TX1 NotarisationNotaries = TMP_NotarisationNotaries; dPriority = 1e16; fNotarisationBlock = true; - last_notarizedheight = notarizedheight; fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); } else if ( notarizedheight > last_notarizedheight ) @@ -433,6 +433,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fNotarisationBlock = true; fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } + last_notarizedheight = notarizedheight; } else if ( Notarisations > 1 ) { @@ -441,6 +442,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } + //fprintf(stderr, "BOTTOM: notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); } } } From b6f1f8cf13b52469f3be607b3bbe7de47b693e47 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Fri, 15 Feb 2019 11:10:36 +0100 Subject: [PATCH 2122/3904] Fix for new DecodeTokenOpRet --- src/cc/channels.cpp | 6 +++--- src/cc/gateways.cpp | 20 ++++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index ca069ee57..fd20314bb 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -106,12 +106,12 @@ CScript EncodeChannelsOpRet(uint8_t funcid,uint256 tokenid,uint256 opentxid,CPub uint8_t DecodeChannelsOpRet(const CScript &scriptPubKey, uint256 &tokenid, uint256 &opentxid, CPubKey &srcpub,CPubKey &destpub,int32_t &numpayments,int64_t &payment,uint256 &hashchain) { - std::vector vopret; uint8_t *script,e,f,tokenevalcode; - std::vector pubkeys; std::vector vOpretExtra; + std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; + std::vector pubkeys; if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { - if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + vopret=vOpretExtra; } else GetOpReturnData(scriptPubKey, vopret); if ( vopret.size() > 2 ) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 41cd37e3a..5d803a80e 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -167,12 +167,11 @@ CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin, uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t wiftype) { - std::vector vopret; uint8_t *script,e,f,tokenevalcode; - std::vector vOpretExtra; std::vector pubkeys; + std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { - if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + vopret=vOpretExtra; } else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -230,12 +229,11 @@ CScript EncodeGatewaysClaimOpRet(uint8_t funcid,uint256 tokenid,uint256 bindtxid uint8_t DecodeGatewaysClaimOpRet(const CScript &scriptPubKey,uint256 &tokenid,uint256 &bindtxid,std::string &refcoin,uint256 &deposittxid,CPubKey &destpub,int64_t &amount) { - std::vector vopret; uint8_t *script,e,f,tokenevalcode; - std::vector pubkeys; std::vector vOpretExtra; + std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { - if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + vopret=vOpretExtra; } else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -260,12 +258,11 @@ CScript EncodeGatewaysWithdrawOpRet(uint8_t funcid,uint256 tokenid,uint256 bindt uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256& tokenid, uint256 &bindtxid, std::string &refcoin, CPubKey &withdrawpub, int64_t &amount) { - std::vector vopret; uint8_t *script,e,f,tokenevalcode; - std::vector pubkeys; std::vector vOpretExtra; + std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { - if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + vopret=vOpretExtra; } else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -339,12 +336,11 @@ uint8_t DecodeGatewaysMarkDoneOpRet(const CScript &scriptPubKey, uint256 &withdr uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey) { - std::vector vopret; uint8_t *script,e,f,tokenevalcode; - std::vector pubkeys; std::vector vOpretExtra; uint256 tokenid; + std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; uint256 tokenid; if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { - if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); + vopret=vOpretExtra; } else GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); From def8dd646268a81afd9a3cbf8db4dff4d2e488ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 15 Feb 2019 00:45:01 -1100 Subject: [PATCH 2123/3904] (int64_t) in Pair --- src/cc/makecclib | 1 + src/cc/makerogue | 1 + src/cc/rogue_rpc.cpp | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 0aecab072..ea44acdae 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1 +1,2 @@ +#!/bin/sh gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp diff --git a/src/cc/makerogue b/src/cc/makerogue index c4fc45dd7..490576bd1 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,3 +1,4 @@ +#!/bin/sh cd rogue; ./configure # only need this first time make; cd .. diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 70a4b842e..5daca5d1c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1028,7 +1028,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","success")); rogue_univalue(result,"pending",-1,-1); result.push_back(Pair("pending",a)); - result.push_back(Pair("numpending",a.size())); + result.push_back(Pair("numpending",(int64_t)a.size())); return(result); } @@ -1055,7 +1055,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } } result.push_back(Pair("playerdata",a)); - result.push_back(Pair("numplayerdata",a.size())); + result.push_back(Pair("numplayerdata",(int64_t)a.size())); return(result); } @@ -1094,7 +1094,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } result.push_back(Pair("pastgames",b)); result.push_back(Pair("games",a)); - result.push_back(Pair("numgames",a.size()+b.size())); + result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); return(result); } From c9b2389854e7872d2f90d77e40d887af60dd5dbe Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 15 Feb 2019 04:44:22 -1100 Subject: [PATCH 2124/3904] Gather curses dependencies --- src/cc/rogue/armor.c | 2 +- src/cc/rogue/chase.c | 4 +- src/cc/rogue/command.c | 5 +-- src/cc/rogue/daemon.c | 2 +- src/cc/rogue/daemons.c | 2 +- src/cc/rogue/extern.c | 2 +- src/cc/rogue/extern.h | 3 ++ src/cc/rogue/fight.c | 8 ++-- src/cc/rogue/init.c | 8 ++-- src/cc/rogue/io.c | 11 ++--- src/cc/rogue/list.c | 6 +-- src/cc/rogue/mach_dep.c | 3 +- src/cc/rogue/mdport.c | 2 +- src/cc/rogue/misc.c | 8 ++-- src/cc/rogue/monsters.c | 6 +-- src/cc/rogue/move.c | 4 +- src/cc/rogue/new_level.c | 4 +- src/cc/rogue/options.c | 8 ++-- src/cc/rogue/pack.c | 6 +-- src/cc/rogue/passages.c | 4 +- src/cc/rogue/potions.c | 4 +- src/cc/rogue/rings.c | 2 +- src/cc/rogue/rip.c | 14 +++--- src/cc/rogue/rogue.c | 40 +++++++++-------- src/cc/rogue/rogue.h | 91 +++++++++++++++++++++++++++++++++++++- src/cc/rogue/rooms.c | 4 +- src/cc/rogue/save.c | 14 +++--- src/cc/rogue/scrolls.c | 4 +- src/cc/rogue/state.c | 6 +-- src/cc/rogue/sticks.c | 6 +-- src/cc/rogue/things.c | 94 ++++++++++++++++++++-------------------- src/cc/rogue/weapons.c | 6 +-- src/cc/rogue/wizard.c | 8 ++-- 33 files changed, 242 insertions(+), 149 deletions(-) diff --git a/src/cc/rogue/armor.c b/src/cc/rogue/armor.c index 5244628b1..20c5704a8 100644 --- a/src/cc/rogue/armor.c +++ b/src/cc/rogue/armor.c @@ -9,7 +9,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/chase.c b/src/cc/rogue/chase.c index 73d53e1fd..059df470d 100644 --- a/src/cc/rogue/chase.c +++ b/src/cc/rogue/chase.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" #define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */ diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 63aed25be..1a32246bb 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -10,10 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index 8309dc642..1da06d499 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -11,7 +11,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" #define EMPTY 0 diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 436aa004d..42e685320 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -10,7 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/extern.c b/src/cc/rogue/extern.c index 39a48b23f..fdb77307c 100644 --- a/src/cc/rogue/extern.c +++ b/src/cc/rogue/extern.c @@ -10,7 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 486d85ff1..fc3454830 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -13,6 +13,9 @@ #ifndef H_EXTERN_ROGUE_H #define H_EXTERN_ROGUE_H +#include +#include + #ifdef HAVE_CONFIG_H #ifdef PDCURSES #undef HAVE_UNISTD_H diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 7f4aad587..43474616e 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" //#define EQSTR(a, b) (strcmp(a, b) == 0) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 1f63e1d51..1603474e2 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 30795f2ad..6791c26a4 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -4,10 +4,10 @@ * @(#)io.c 4.32 (Berkeley) 02/05/99 */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /* @@ -162,7 +162,8 @@ readchar(struct rogue_state *rs) //fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } - fprintf(stderr,"replay finished but readchar called\n"); + if ( rs->replaydone != 0 ) + fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); //if ( (rand() & 1) == 0 ) // return(ESCAPE); diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 6affc662c..622af60cd 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -10,9 +10,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" #ifdef MASTER diff --git a/src/cc/rogue/mach_dep.c b/src/cc/rogue/mach_dep.c index 34e502816..6d0e1c66f 100644 --- a/src/cc/rogue/mach_dep.c +++ b/src/cc/rogue/mach_dep.c @@ -46,7 +46,8 @@ #include #include #include -#include +//#include +#include "rogue.h" #include "extern.h" #define NOOP(x) (x += 0) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index acd257617..443ef1e60 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -44,7 +44,7 @@ #undef MOUSE_MOVED #endif -#include +//#include #include "extern.h" #if defined(HAVE_SYS_TYPES) diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 168886b6b..7db9d073a 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 4649de9a2..2f6d68362 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" -#include +//#include /* * List of monsters in rough order of vorpalness diff --git a/src/cc/rogue/move.c b/src/cc/rogue/move.c index 3bdf90d37..c70d668ca 100644 --- a/src/cc/rogue/move.c +++ b/src/cc/rogue/move.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index 9dc0d761f..b55d3e42c 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -11,8 +11,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" #define TREAS_ROOM 20 /* one chance in TREAS_ROOM for a treasure room */ diff --git a/src/cc/rogue/options.c b/src/cc/rogue/options.c index 6907da598..d74979365 100644 --- a/src/cc/rogue/options.c +++ b/src/cc/rogue/options.c @@ -12,10 +12,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" #define EQSTR(a, b, c) (strncmp(a, b, c) == 0) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index ee628b4f0..b6debc966 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -10,9 +10,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/passages.c b/src/cc/rogue/passages.c index 79b3706aa..5437f4972 100644 --- a/src/cc/rogue/passages.c +++ b/src/cc/rogue/passages.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index de09efb9b..00865b5dd 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" typedef struct diff --git a/src/cc/rogue/rings.c b/src/cc/rogue/rings.c index 56f7a0294..747da302a 100644 --- a/src/cc/rogue/rings.c +++ b/src/cc/rogue/rings.c @@ -10,7 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index a5b3e7208..be97fb867 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -11,14 +11,14 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" #include "score.h" diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 00cda9426..be17b25be 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -8,12 +8,11 @@ * @(#)main.c 4.22 (Berkeley) 02/05/99 */ -#include -#include +//#include +//#include #include -#include -#include -#include +//#include +//#include #include "rogue.h" #ifdef STANDALONE #include "../komodo/src/komodo_cJSON.h" @@ -88,6 +87,8 @@ void rogueiterate(struct rogue_state *rs) endwin(); my_exit(1); } + //fprintf(stderr,"LINES %d, COLS %d\n",LINES,COLS); + // Set up windows if ( hw == NULL ) hw = newwin(LINES, COLS, 0, 0); @@ -247,21 +248,24 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); - /*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); - sleep(2); - - starttime = (uint32_t)time(NULL); - for (i=0; i<100; i++) + if ( 0 ) { - memset(rs,0,sizeof(*rs)); - rs->seed = seed; - rs->keystrokes = keystrokes; - rs->numkeys = num; - rs->sleeptime = 0; - rogueiterate(rs); + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); + sleep(2); + + starttime = (uint32_t)time(NULL); + for (i=0; i<10000; i++) + { + memset(rs,0,sizeof(*rs)); + rs->seed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = 0; + rogueiterate(rs); + } + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); + sleep(3); } - fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); - sleep(1);*/ if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(rs,fp,0); diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index a407ae8a6..419d5aa1b 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -12,10 +12,92 @@ #ifndef H_ROGUE_H #define H_ROGUE_H +#include +#include +#include +#include +#include +#include +#include /* we need va_list */ +#include /* we want wchar_t */ +#include +#include -#include "extern.h" +#include +#include +#include +#include +#include -#undef lines +#ifndef DONTUSEGUI +#include +#else + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +typedef void *WINDOW; +WINDOW stdscr; + +#define standout() +#define standend() +#define refresh() +#define raw() +#define noecho() +#define flushinp() +#define initscr() +#define clear() +#define clrtoeol() + +#define addch(a) +#define werase(a) +#define wclear(a) +#define delwin(a) +#define addstr(a) +#define touchwin(a) +#define idlok(a,b) +#define clearok(a,b) +#define keypad(a,b) +#define leaveok(a,b) +#define waddch(a,b) +#define waddstr(a,b) +#define move(a,b) +#define mvwin(a,b,c) +#define wmove(a,b,c) +#define mvaddch(a,b,c) +#define mvaddstr(a,b,c) +#define wgetnstr(a,b,c) +#define getyx(a,b,c) +#define mvcur(a,b,c,d) +#define mvwaddch(a,b,c,d) +#define mvprintw(...) +#define printw(...) +#define wprintw(...) +#define mvwprintw(...) + + +#define A_CHARTEXT 0xff +#define inch() 0 +#define endwin() 1 +#define isendwin() 0 +#define baudrate() 9600 +#define killchar() 3 +#define erasechar() 8 +#define wclrtoeol(a) 0 +#define wrefresh(a) 0 +#define unctrl(a) "^x" +#define getmaxx(a) COLS +#define getmaxy(a) LINES +#define mvinch(a,b) '.' +#define mvwinch(a,b,c) 0 +#define newwin(a,b,c,d) 0 +#define subwin(a,b,c,d,e) 0 + +#endif #ifdef LINES #undef LINES @@ -27,6 +109,11 @@ #define LINES 24 #define COLS 80 +#include "extern.h" + + +#undef lines + #define NOOP(x) (x += 0) #define CCHAR(x) ( (char) (x & A_CHARTEXT) ) /* diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index 31991b08f..41041d627 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" typedef struct spot { /* position matrix for maze positions */ diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index adec30e2e..718c5074b 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -10,13 +10,13 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include #include "rogue.h" #include "score.h" diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index b6854ab07..5554a5701 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 3db54a319..e034039a8 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -29,9 +29,9 @@ SUCH DAMAGE. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" /************************************************************************/ diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index 39e098339..f048f9423 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -11,9 +11,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 4e572c60b..29c51c4ed 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -11,9 +11,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" /* @@ -498,55 +498,55 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) if (line_cnt >= LINES - 1 || fmt == NULL) { if (inv_type == INV_OVER && fmt == NULL && !newpage) - { - msg(rs,""); + { + msg(rs,""); if ( rs->sleeptime != 0 ) refresh(); - tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); - sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); - for (y = 0; y <= line_cnt; y++) - { - wmove(sw, y, 0); - for (x = 0; x <= maxlen; x++) - waddch(sw, mvwinch(hw, y, x)); - } - wmove(tw, line_cnt, 1); - waddstr(tw, prompt); - /* - * if there are lines below, use 'em - */ - if (LINES > NUMLINES) - { - if (NUMLINES + line_cnt > LINES) - mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); - else - mvwin(tw, NUMLINES, 0); - } - touchwin(tw); - wrefresh(tw); - wait_for(rs,' '); - if (md_hasclreol()) - { - werase(tw); - leaveok(tw, TRUE); - wrefresh(tw); - } - delwin(tw); - touchwin(stdscr); + tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); + sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); + for (y = 0; y <= line_cnt; y++) + { + wmove(sw, y, 0); + for (x = 0; x <= maxlen; x++) + waddch(sw, mvwinch(hw, y, x)); + } + wmove(tw, line_cnt, 1); + waddstr(tw, prompt); + /* + * if there are lines below, use 'em + */ + if (LINES > NUMLINES) + { + if (NUMLINES + line_cnt > LINES) + mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); + else + mvwin(tw, NUMLINES, 0); + } + touchwin(tw); + wrefresh(tw); + wait_for(rs,' '); + if (md_hasclreol()) + { + werase(tw); + leaveok(tw, TRUE); + wrefresh(tw); + } + delwin(tw); + touchwin(stdscr); } else { - wmove(hw, LINES - 1, 0); - waddstr(hw, prompt); - wrefresh(hw); - wait_for(rs,' '); - clearok(curscr, TRUE); - wclear(hw); - touchwin(stdscr); - } - newpage = TRUE; - line_cnt = 0; - maxlen = (int) strlen(prompt); + wmove(hw, LINES - 1, 0); + waddstr(hw, prompt); + wrefresh(hw); + wait_for(rs,' '); + clearok(curscr, TRUE); + wclear(hw); + touchwin(stdscr); + } + newpage = TRUE; + line_cnt = 0; + maxlen = (int) strlen(prompt); } if (fmt != NULL && !(line_cnt == 0 && *fmt == '\0')) { diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 6693f0814..e5a5eacf6 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -10,9 +10,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" #define NO_WEAPON -1 diff --git a/src/cc/rogue/wizard.c b/src/cc/rogue/wizard.c index e56928d33..ee16b2d9b 100644 --- a/src/cc/rogue/wizard.c +++ b/src/cc/rogue/wizard.c @@ -11,10 +11,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /* From 72a3a99eaacb877649e6a496b394a12335b80d26 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 15 Feb 2019 15:52:15 -0800 Subject: [PATCH 2125/3904] quick hack to make things build on mac --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8503ebb56..84445f5be 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -572,7 +572,7 @@ komodod_LDADD += \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) \ - libcc.so -lncurses + libcc.dylib -lncurses if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) From 88e7828253c341129c86047e4bcc32cd78c0f41a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 15 Feb 2019 17:15:12 -0800 Subject: [PATCH 2126/3904] Fix building of libcc on darwin --- src/Makefile.am | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 84445f5be..1881f0a90 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -571,8 +571,14 @@ komodod_LDADD += \ $(LIBBITCOIN_CRYPTO) \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ - $(LIBZCASH_LIBS) \ - libcc.dylib -lncurses + $(LIBZCASH_LIBS) + +if TARGET_DARWIN +komodod_LDADD += libcc.dylib -lncurses +else +komodod_LDADD += libcc.so -lncurses +endif + if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) From f6be5ec6480b35deef11c07c7fc1629580c67844 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 16 Feb 2019 16:06:35 +0800 Subject: [PATCH 2127/3904] LASTH to group1 --- src/miner.cpp | 1 - src/notaries_staked.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index aa19c3bd7..344ef6431 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,7 +155,6 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); -bool check_pprevnotarizedht(); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c2f902c82..c44d89df2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,7 +17,7 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "ORKL") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABSTH") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. From f3be53cbff1d35bdda82265915f6ce082db85878 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 00:20:39 -1100 Subject: [PATCH 2128/3904] +print --- src/cc/rogue/pack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index b6debc966..ebc4c32f4 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -178,7 +178,8 @@ pack_room(struct rogue_state *rs,bool from_floor, THING *obj) inpack = MAXPACK; return FALSE; } - + fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2); + if (from_floor) { detach(lvl_obj, obj); From f5d952300c5bb614d417c7de99e560ec3480bc29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 00:29:13 -1100 Subject: [PATCH 2129/3904] +/- print --- src/cc/rogue/pack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index ebc4c32f4..bfe176dfa 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -178,7 +178,7 @@ pack_room(struct rogue_state *rs,bool from_floor, THING *obj) inpack = MAXPACK; return FALSE; } - fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2); + //fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2); if (from_floor) { @@ -273,6 +273,8 @@ inventory(struct rogue_state *rs,THING *list, int type) } msg_esc = FALSE; } + //if ( n_objs != numpack ) + fprintf(stderr,"n_objs.%d vs numpack.%d\n",n_objs,numpack), sleep(2); if (n_objs == 0) { if (terse) From e64329265c916dfa41c52e8e877691bdeb5e4e46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 00:43:26 -1100 Subject: [PATCH 2130/3904] cursesd.h --- src/cc/rogue/cursesd.h | 79 ++++++++++++++++++++++++++++++++++++++++++ src/cc/rogue/rogue.h | 65 +--------------------------------- 2 files changed, 80 insertions(+), 64 deletions(-) create mode 100644 src/cc/rogue/cursesd.h diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h new file mode 100644 index 000000000..76e9b878e --- /dev/null +++ b/src/cc/rogue/cursesd.h @@ -0,0 +1,79 @@ +/* + * Score file structure + * + * @(#)score.h 4.6 (Berkeley) 02/05/99 + * + * Rogue: Exploring the Dungeons of Doom + * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ +#ifndef H_CURSESD_H +#define H_CURSESD_H + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +typedef void *WINDOW; +WINDOW stdscr; + +#define standout() +#define standend() +#define refresh() +#define raw() +#define noecho() +#define flushinp() +#define initscr() +#define clear() +#define clrtoeol() + +#define addch(a) +#define werase(a) +#define wclear(a) +#define delwin(a) +#define addstr(a) +#define touchwin(a) +#define idlok(a,b) +#define clearok(a,b) +#define keypad(a,b) +#define leaveok(a,b) +#define waddch(a,b) +#define waddstr(a,b) +#define move(a,b) +#define mvwin(a,b,c) +#define wmove(a,b,c) +#define mvaddch(a,b,c) +#define mvaddstr(a,b,c) +#define wgetnstr(a,b,c) +#define getyx(a,b,c) +#define mvcur(a,b,c,d) +#define mvwaddch(a,b,c,d) +#define mvprintw(...) +#define printw(...) +#define wprintw(...) +#define mvwprintw(...) + + +#define A_CHARTEXT 0xff +#define inch() 0 +#define endwin() 1 +#define isendwin() 0 +#define baudrate() 9600 +#define killchar() 3 +#define erasechar() 8 +#define wclrtoeol(a) 0 +#define wrefresh(a) 0 +#define unctrl(a) "^x" +#define getmaxx(a) COLS +#define getmaxy(a) LINES +#define mvinch(a,b) '.' +#define mvwinch(a,b,c) 0 +#define newwin(a,b,c,d) 0 +#define subwin(a,b,c,d,e) 0 + +#endif diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 419d5aa1b..b83b1a3f5 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -33,70 +33,7 @@ #include #else -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -typedef void *WINDOW; -WINDOW stdscr; - -#define standout() -#define standend() -#define refresh() -#define raw() -#define noecho() -#define flushinp() -#define initscr() -#define clear() -#define clrtoeol() - -#define addch(a) -#define werase(a) -#define wclear(a) -#define delwin(a) -#define addstr(a) -#define touchwin(a) -#define idlok(a,b) -#define clearok(a,b) -#define keypad(a,b) -#define leaveok(a,b) -#define waddch(a,b) -#define waddstr(a,b) -#define move(a,b) -#define mvwin(a,b,c) -#define wmove(a,b,c) -#define mvaddch(a,b,c) -#define mvaddstr(a,b,c) -#define wgetnstr(a,b,c) -#define getyx(a,b,c) -#define mvcur(a,b,c,d) -#define mvwaddch(a,b,c,d) -#define mvprintw(...) -#define printw(...) -#define wprintw(...) -#define mvwprintw(...) - - -#define A_CHARTEXT 0xff -#define inch() 0 -#define endwin() 1 -#define isendwin() 0 -#define baudrate() 9600 -#define killchar() 3 -#define erasechar() 8 -#define wclrtoeol(a) 0 -#define wrefresh(a) 0 -#define unctrl(a) "^x" -#define getmaxx(a) COLS -#define getmaxy(a) LINES -#define mvinch(a,b) '.' -#define mvwinch(a,b,c) 0 -#define newwin(a,b,c,d) 0 -#define subwin(a,b,c,d,e) 0 - +#include "cursesd.h" #endif #ifdef LINES From f341a6938ee2c4f84b633004f5f70826e5b34c81 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 00:44:29 -1100 Subject: [PATCH 2131/3904] Inpack --- src/cc/rogue/pack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index bfe176dfa..1984a87a8 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -273,8 +273,8 @@ inventory(struct rogue_state *rs,THING *list, int type) } msg_esc = FALSE; } - //if ( n_objs != numpack ) - fprintf(stderr,"n_objs.%d vs numpack.%d\n",n_objs,numpack), sleep(2); + //if ( n_objs != inpack ) + fprintf(stderr,"n_objs.%d vs inpack.%d\n",n_objs,inpack), sleep(2); if (n_objs == 0) { if (terse) From 49e84c350ebb7c27b91030436753d380a9ade706 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 01:29:42 -1100 Subject: [PATCH 2132/3904] Calculate unpack --- src/cc/rogue/Makefile.in | 2 +- src/cc/rogue/cursesd.c | 22 ++++++++++++++++++++++ src/cc/rogue/cursesd.h | 38 ++++++++++++++++++++++++-------------- src/cc/rogue/pack.c | 11 +++++++++++ src/cc/rogue/rogue.h | 1 + 5 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 src/cc/rogue/cursesd.c diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index c2f4e551a..e276584a9 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -101,7 +101,7 @@ HDRS = rogue.h extern.h score.h OBJS1 = vers.$(O) extern.$(O) armor.$(O) chase.$(O) command.$(O) \ daemon.$(O) daemons.$(O) fight.$(O) init.$(O) io.$(O) list.$(O) \ mach_dep.$(O) rogue.$(O) mdport.$(O) misc.$(O) monsters.$(O) \ - move.$(O) new_level.$(O) + move.$(O) new_level.$(O) cursesd.$(O) OBJS2 = options.$(O) pack.$(O) passages.$(O) potions.$(O) rings.$(O) \ rip.$(O) rooms.$(O) save.$(O) scrolls.$(O) state.$(O) sticks.$(O) \ things.$(O) weapons.$(O) wizard.$(O) xcrypt.$(O) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c new file mode 100644 index 000000000..71843d36d --- /dev/null +++ b/src/cc/rogue/cursesd.c @@ -0,0 +1,22 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include "cursesd.h" + +WINDOW *initscr() +{ + if ( stdscr == 0 ) + stdscr = (WINDOW)calloc(1,sizeof(*stdscr)); +} diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 76e9b878e..54c368220 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -1,17 +1,30 @@ -/* - * Score file structure - * - * @(#)score.h 4.6 (Berkeley) 02/05/99 - * - * Rogue: Exploring the Dungeons of Doom - * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman - * All rights reserved. - * - * See the file LICENSE.TXT for full copyright and licensing information. - */ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + #ifndef H_CURSESD_H #define H_CURSESD_H +#define LINES 24 +#define COLS 80 + +struct cursesd_info +{ + uint8_t screen[LINES][COLS]; +} *stdscr; +typedef struct cursesd_info WINDOW; + #ifndef TRUE #define TRUE 1 #endif @@ -19,8 +32,6 @@ #define FALSE 0 #endif -typedef void *WINDOW; -WINDOW stdscr; #define standout() #define standend() @@ -28,7 +39,6 @@ WINDOW stdscr; #define raw() #define noecho() #define flushinp() -#define initscr() #define clear() #define clrtoeol() diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 1984a87a8..1e308892e 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -165,6 +165,7 @@ out: bool pack_room(struct rogue_state *rs,bool from_floor, THING *obj) { + inpack = num_packitems(); if (++inpack > MAXPACK) { if (!terse) @@ -245,6 +246,16 @@ pack_char() * List what is in the pack. Return TRUE if there is something of * the given type. */ + +int32_t num_packitems() +{ + THING *list = pack; + int32_t type = 0,n = 0; + for (; list != NULL; list = next(list)) + n++; + return(n); +} + bool inventory(struct rogue_state *rs,THING *list, int type) { diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index b83b1a3f5..7d00bd8cf 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -816,6 +816,7 @@ THING *leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all); THING *new_item(void); THING *new_thing(struct rogue_state *rs); void end_line(struct rogue_state *rs); +int32_t num_packitems(); void runners(struct rogue_state *rs,int); void land(struct rogue_state *rs,int); From 2fc5f85f0f920aaeaa641bee9fb416fff1321f20 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 01:33:36 -1100 Subject: [PATCH 2133/3904] Fix --- src/cc/rogue/cursesd.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 54c368220..db6c184b9 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -19,6 +19,8 @@ #define LINES 24 #define COLS 80 +#include + struct cursesd_info { uint8_t screen[LINES][COLS]; From 9da6a5c5d0972ccbbc52654743237d9570fc4fae Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 01:34:23 -1100 Subject: [PATCH 2134/3904] Test --- src/cc/rogue/cursesd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 71843d36d..ff1e9a388 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -13,10 +13,10 @@ * * ******************************************************************************/ -#include "cursesd.h" +/*#include "cursesd.h" WINDOW *initscr() { if ( stdscr == 0 ) stdscr = (WINDOW)calloc(1,sizeof(*stdscr)); -} +}*/ From ffccabc6f288d1b8b43387e17df0646e6c851236 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 01:39:02 -1100 Subject: [PATCH 2135/3904] -print --- src/cc/rogue/cursesd.c | 7 ++++--- src/cc/rogue/pack.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index ff1e9a388..174ce89e7 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -13,10 +13,11 @@ * * ******************************************************************************/ -/*#include "cursesd.h" +#include "cursesd.h" WINDOW *initscr() { if ( stdscr == 0 ) - stdscr = (WINDOW)calloc(1,sizeof(*stdscr)); -}*/ + stdscr = (WINDOW *)calloc(1,sizeof(*stdscr)); + return(stdscr); +} diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 1e308892e..2f683441b 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -285,7 +285,7 @@ inventory(struct rogue_state *rs,THING *list, int type) msg_esc = FALSE; } //if ( n_objs != inpack ) - fprintf(stderr,"n_objs.%d vs inpack.%d\n",n_objs,inpack), sleep(2); + // fprintf(stderr,"n_objs.%d vs inpack.%d\n",n_objs,inpack), sleep(2); if (n_objs == 0) { if (terse) From 49593a055a48acde8f6ebf50b6e19971ebf89cae Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 01:41:22 -1100 Subject: [PATCH 2136/3904] -print --- src/cc/rogue/cursesd.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index db6c184b9..3df9a5a19 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -19,7 +19,22 @@ #define LINES 24 #define COLS 80 +#include #include +#include +#include +#include +#include +#include /* we need va_list */ +#include /* we want wchar_t */ +#include +#include + +#include +#include +#include +#include +#include struct cursesd_info { From eb2e0928c094ecba54298f15c96ffd1c92c6ba4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 02:07:04 -1100 Subject: [PATCH 2137/3904] Test --- src/cc/rogue/Makefile.in | 2 +- src/cc/rogue/cursesd.c | 85 ++++++++++++++++++++++++++++++++++++++++ src/cc/rogue/cursesd.h | 22 +++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index e276584a9..a6d410b23 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -101,7 +101,7 @@ HDRS = rogue.h extern.h score.h OBJS1 = vers.$(O) extern.$(O) armor.$(O) chase.$(O) command.$(O) \ daemon.$(O) daemons.$(O) fight.$(O) init.$(O) io.$(O) list.$(O) \ mach_dep.$(O) rogue.$(O) mdport.$(O) misc.$(O) monsters.$(O) \ - move.$(O) new_level.$(O) cursesd.$(O) + move.$(O) new_level.$(O) OBJS2 = options.$(O) pack.$(O) passages.$(O) potions.$(O) rings.$(O) \ rip.$(O) rooms.$(O) save.$(O) scrolls.$(O) state.$(O) sticks.$(O) \ things.$(O) weapons.$(O) wizard.$(O) xcrypt.$(O) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 174ce89e7..643ed87de 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -15,9 +15,94 @@ #include "cursesd.h" +static int32_t endwinflag; + WINDOW *initscr() { if ( stdscr == 0 ) stdscr = (WINDOW *)calloc(1,sizeof(*stdscr)); return(stdscr); } + +void endwin() +{ + if ( stdscr != 0 ) + free(stdscr), stdscr = 0; + endwinflag = 1; +} + +int isendwin(void) +{ + return(endwinflag); +} + +int wrefresh(WINDOW *win) +{ + return(0); +} + +int refresh(void) +{ + endwinflag = 0; + return(wrefresh(stdscr)); +} + +int wnoutrefresh(WINDOW *win) +{ + return(0); +} + +int doupdate(void) +{ + return(0); +} + +int redrawwin(WINDOW *win) +{ + return(wrefresh(win)); +} + +int wredrawln(WINDOW *win, int beg_line, int num_lines) +{ + return(wrefresh(win)); +} + +int werase(WINDOW *win) +{ + +} + +int erase(void) +{ + return(werase(stdscr)); +} + +int wclear(WINDOW *win) +{ + +} + +int clear(void) +{ + return(wclear(stdscr)); +} + +int wclrtobot(WINDOW *win) +{ + +} + +int clrtobot(void) +{ + return(wclrtobot(stdscr)); +} + +int wclrtoeol(WINDOW *win) +{ + +} + +int clrtoeol(void) +{ + return(wclrtoeol(stdscr)); +} diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 3df9a5a19..d01a9325d 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -49,6 +49,28 @@ typedef struct cursesd_info WINDOW; #define FALSE 0 #endif +WINDOW *initscr(void); +int endwin(void); +int isendwin(void); +//SCREEN *newterm(const char *type, FILE *outfd, FILE *infd); +//SCREEN *set_term(SCREEN *new); +//void delscreen(SCREEN* sp); + +int refresh(void); +int wrefresh(WINDOW *win); +//int wnoutrefresh(WINDOW *win); +//int doupdate(void); +int redrawwin(WINDOW *win); +int wredrawln(WINDOW *win, int beg_line, int num_lines); + +int erase(void); +int werase(WINDOW *win); +int clear(void); +int wclear(WINDOW *win); +int clrtobot(void); +int wclrtobot(WINDOW *win); +int clrtoeol(void); +int wclrtoeol(WINDOW *win); #define standout() #define standend() From 4c2dfcbc8e99720b979e5625c71512f654df9b41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 02:08:09 -1100 Subject: [PATCH 2138/3904] Test --- src/cc/rogue/cursesd.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index d01a9325d..5e3d375ca 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -36,19 +36,14 @@ #include #include +#ifdef notyet + struct cursesd_info { uint8_t screen[LINES][COLS]; } *stdscr; typedef struct cursesd_info WINDOW; -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - WINDOW *initscr(void); int endwin(void); int isendwin(void); @@ -72,6 +67,16 @@ int wclrtobot(WINDOW *win); int clrtoeol(void); int wclrtoeol(WINDOW *win); +#endif + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + + #define standout() #define standend() #define refresh() From a994a2c01504d44b7bcdf296ae87e71c58d83b7f Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 16 Feb 2019 21:39:01 +0500 Subject: [PATCH 2139/3904] corrected invalid non-canonical corrected burntx nExpiryHeight to prevent duplication of importtx (malleability) added importcoin validation for amount, ac_pubkey added sourcetx creation with amount in opret --- src/cc/import.cpp | 369 ++++++++++++++++++++++++++++++++++----- src/importcoin.cpp | 7 +- src/importcoin.h | 2 +- src/rpc/crosschain.cpp | 144 ++++++++++++--- src/rpc/server.cpp | 3 +- src/rpc/server.h | 2 +- src/wallet/rpcwallet.cpp | 52 ++++++ 7 files changed, 505 insertions(+), 74 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index ea69745b0..dbbf7832f 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -20,6 +20,10 @@ #include "primitives/transaction.h" #include "cc/CCinclude.h" +//#define LEV_INFO 0 +//#define LEV_DEBUG1 1 +//#define LOGSTREAM(category, level, logoperator) { std::ostringstream stream; logoperator; for(int i = 0; i < level; i ++) if( LogAcceptCategory( (std::string(category) + (level > 0 ? std::string("-")+std::to_string(level) : std::string("") )).c_str() ) ) LogPrintStr(stream.str()); } + /* * CC Eval method for import coin. * @@ -33,63 +37,299 @@ extern std::string ASSETCHAINS_SELFIMPORT; extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT; extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; -int32_t GetSelfimportProof(std::string source,CMutableTransaction &mtx,CScript &scriptPubKey,TxProof &proof,uint64_t burnAmount,std::vector rawtx,uint256 txid,std::vector rawproof) // find burnTx with hash from "other" daemon +// utilities from gateways.cpp +uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::vector &txids); +uint256 GatewaysReverseScan(uint256 &txid, int32_t height, uint256 reforacletxid, uint256 batontxid); +int32_t GatewaysCointxidExists(struct CCcontract_info *cp, uint256 cointxid); +uint8_t DecodeGatewaysBindOpRet(char *depositaddr, const CScript &scriptPubKey, std::string &coin, uint256 &tokenid, int64_t &totalsupply, uint256 &oracletxid, uint8_t &M, uint8_t &N, std::vector &pubkeys, uint8_t &taddr, uint8_t &prefix, uint8_t &prefix2); + +// ac_import=chain support: +// encode opret for gateways import +CScript EncodeGatewaysImportTxOpRet(uint32_t targetCCid, std::string coin, uint256 bindtxid, std::vector publishers, std::vectortxids, int32_t height, uint256 cointxid, int32_t claimvout, std::string rawburntx, std::vectorproof, CPubKey destpub, int64_t amount) { - MerkleBranch newBranch; CMutableTransaction tmpmtx; CTransaction tx,vintx; uint256 blockHash; char destaddr[64],pkaddr[64]; - tmpmtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),komodo_nextheight()); - if ( source == "BEAM" ) + CScript opret; + opret << OP_RETURN << E_MARSHAL(ss << targetCCid << coin << bindtxid << publishers << txids << height << cointxid << claimvout << rawburntx << proof << destpub << amount); + return(opret); +} + +bool ImportCoinGatewaysVerify(char *refdepositaddr, uint256 oracletxid, int32_t claimvout, std::string refcoin, uint256 burntxid, const std::string rawburntx, std::vectorproof, uint256 merkleroot) +{ + std::vector txids; + uint256 proofroot, hashBlock, foundtxid = zeroid; + CTransaction oracletx, burntx; + std::string name, description, format; + char destaddr[64], destpubaddr[64], claimaddr[64]; + int32_t i, numvouts; + int64_t nValue = 0; + + if (myGetTransaction(oracletxid, oracletx, hashBlock) == 0 || (numvouts = oracletx.vout.size()) <= 0) { - if ( ASSETCHAINS_BEAMPORT == 0 ) - return(-1); - // confirm via ASSETCHAINS_BEAMPORT that burnTx/hash is a valid BEAM burn - // return(0); + LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify can't find oracletxid=" << oracletxid.GetHex() << std::endl); + return false; } - else if ( source == "CODA" ) + if (DecodeOraclesCreateOpRet(oracletx.vout[numvouts - 1].scriptPubKey, name, description, format) != 'C' || name != refcoin) { - if ( ASSETCHAINS_CODAPORT == 0 ) - return(-1); - // confirm via ASSETCHAINS_CODAPORT that burnTx/hash is a valid CODA burn - // return(0); + LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify mismatched oracle name=" << name.c_str() << " != " << refcoin.c_str() << std::endl); + return false; } - else + proofroot = BitcoinGetProofMerkleRoot(proof, txids); + if (proofroot != merkleroot) { - if ( !E_UNMARSHAL(rawtx, ss >> tx) ) - return(-1); - scriptPubKey = tx.vout[0].scriptPubKey; - mtx = tx; - mtx.fOverwintered = tmpmtx.fOverwintered; - mtx.nExpiryHeight = tmpmtx.nExpiryHeight; - mtx.nVersionGroupId = tmpmtx.nVersionGroupId; - mtx.nVersion = tmpmtx.nVersion; - mtx.vout.clear(); - mtx.vout.resize(1); - mtx.vout[0].nValue = burnAmount; - mtx.vout[0].scriptPubKey = scriptPubKey; - if ( tx.GetHash() != txid ) - return(-1); - if ( source == "PUBKEY" ) + LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify mismatched proof merkleroot=" << proofroot.GetHex() << " and oracles merkleroot=" << merkleroot.GetHex() << std::endl); + return false; + } + + // check the burntxid is in the proof: + if (std::find(txids.begin(), txids.end(), burntxid) == txids.end()) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify invalid proof for this burntxid=" << burntxid.GetHex() << std::endl); + return false; + } + + /* + if (DecodeHexTx(burntx, rawburntx) != 0) + { + Getscriptaddress(claimaddr, burntx.vout[claimvout].scriptPubKey); + Getscriptaddress(destpubaddr, CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG); + if (strcmp(claimaddr, destpubaddr) == 0) { - // make sure vin0 is signed by ASSETCHAINS_OVERRIDE_PUBKEY33 - if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,blockHash) == 0 ) - return(-1); - if ( tx.vin[0].prevout.n < vintx.vout.size() && Getscriptaddress(destaddr,vintx.vout[tx.vin[0].prevout.n].scriptPubKey) != 0 ) + for (i = 0; i %s vs %s\n",tx.vin[0].prevout.n,destaddr,pkaddr); } } - else if ( source == ASSETCHAINS_SELFIMPORT ) + else fprintf(stderr, "claimaddr.(%s) != destpubaddr.(%s)\n", claimaddr, destpubaddr); + }*/ + + /* + if (foundtxid == burntxid) { + LOGSTREAM("importcoin", LEV_DEBUG1, stream << "verified proof for burntxid=" << burntxid.GetHex() << " in merkleroot merkleroot" << std::endl); + return(nValue); + } + else { + LOGSTREAM("importcoin", LEV_INFO, stream << "verified proof for burntxid=" << burntxid.GetHex() << " in merkleroot merkleroot" << std::endl); + + fprintf(stderr, "(%s) != (%s) or txid %s mismatch.%d or script mismatch\n", refdepositaddr, destaddr, uint256_str(str, foundtxid), foundtxid != burntxid); + */ + + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "verified proof for burntxid=" << burntxid.GetHex() << " in trusted merkleroot" << std::endl); + return true; +} + + +// make import tx with burntx and its proof of existence +std::string MakeGatewaysImportTx(uint64_t txfee, uint256 bindtxid, int32_t height, std::string refcoin, std::vectorproof, std::string rawburntx, int32_t ivout, uint256 burntxid) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction burntx, bindtx; + CPubKey mypk, gatewayspk; + uint256 oracletxid, merkleroot, mhash, hashBlock, tokenid, txid; + int64_t totalsupply; + int32_t i, m, n, numvouts; + uint8_t M, N, taddr, prefix, prefix2; + std::string coin; + struct CCcontract_info *cp, C; + std::vector pubkeys, publishers; + std::vectortxids; + char depositaddr[64], txidaddr[64]; + + cp = CCinit(&C, EVAL_GATEWAYS); + /*if (txfee == 0) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + gatewayspk = GetUnspendable(cp, 0); */ + + if (!E_UNMARSHAL(ParseHex(rawburntx), ss >> burntx)) + return std::string(""); + + CAmount amount = GetCoinImportValue(burntx); // equal to int64_t + + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeGatewaysImportTx height=" << height << " coin=" << refcoin << " amount=" << (double)amount / COIN << " pubkeys num=" << pubkeys.size() << std::endl); + + if (GetTransaction(bindtxid, bindtx, hashBlock, false) == 0 || (numvouts = bindtx.vout.size()) <= 0) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx cant find bindtxid=" << bindtxid.GetHex() << std::endl); + return(""); + } +/* if (DecodeGatewaysBindOpRet(depositaddr, bindtx.vout[numvouts - 1].scriptPubKey, coin, tokenid, totalsupply, oracletxid, M, N, pubkeys, taddr, prefix, prefix2) != 'B' || refcoin != coin) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx invalid coin - bindtxid=" << bindtxid.GetHex() << " coin=" << coin.c_str() << std::endl); + return(""); + } eliminate link err */ + n = (int32_t)pubkeys.size(); + merkleroot = zeroid; + for (i = m = 0; i < n; i++) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx using pubkeys[" << i << "]=" << HexStr(pubkeys[i]) << std::endl); + if ((mhash = GatewaysReverseScan(txid, height, oracletxid, OraclesBatontxid(oracletxid, pubkeys[i]))) != zeroid) { - // source is external coin is the assetchains symbol in the burnTx OP_RETURN - // burnAmount, rawtx and rawproof should be enough for gatewaysdeposit equivalent + if (merkleroot == zeroid) + merkleroot = mhash, m = 1; + else if (mhash == merkleroot) + m ++; + publishers.push_back(pubkeys[i]); + txids.push_back(txid); } } - return(-1); + + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeGatewaysImportTx burntxid=" << burntxid.GetHex() << " nodes m=" << m << " of n=" << n << std::endl); + if (merkleroot == zeroid || m < n / 2) // none or less than half oracle nodes sent merkleroot + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx couldnt find merkleroot for block height=" << height << "coin=" << coin.c_str() << " oracleid=" << oracletxid.GetHex() << " m=" << m << " vs n=" << n << std::endl ); + return(""); + } + if (GatewaysCointxidExists(cp, burntxid) != 0) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx burntxid=" << burntxid.GetHex() << " already exists" << std::endl); + return(""); + } + if (!ImportCoinGatewaysVerify(depositaddr, oracletxid, ivout, coin, burntxid, rawburntx, proof, merkleroot)) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx could not validate burntx, txid=" << burntxid.GetHex() << std::endl); + return(""); + } + + + std::vector leaftxids; + BitcoinGetProofMerkleRoot(proof, leaftxids); + MerkleBranch newBranch(0, leaftxids); + TxProof txProof = std::make_pair(burntxid, newBranch); + + std::vector vouts; + + + + return HexStr(E_MARSHAL(ss << MakeImportCoinTransaction(txProof, burntx, vouts))); + + /*if (AddNormalinputs(mtx, mypk, 3 * txfee, 4) > 0) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode, txfee, destpub)); + mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr, burntxid))) << OP_CHECKSIG)); + return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeGatewaysImportTxOpRet(0xFFFFFFFF, coin, bindtxid, publishers, txids, height, burntxid, ivout, rawburntx, proof, destpub, amount))); + } + LOGSTREAM("importcoin", LEV_INFO, stream << "MakeGatewaysImportTx coud not find normal imputs" << std::endl);*/ + return(""); +} + +// makes source tx for self import tx +std::string MakeSelfImportSourceTx(CTxDestination &dest, int64_t amount, CMutableTransaction &mtx) +{ + const int64_t txfee = 10000; + int64_t inputs, change; + CPubKey myPubKey = Mypubkey(); + struct CCcontract_info *cpDummy, C; + + cpDummy = CCinit(&C, EVAL_TOKENS); + + mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + + if( (inputs = AddNormalinputs(mtx, myPubKey, txfee, 4)) == 0 ) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeSelfImportSourceTx: cannot find normal imputs for txfee" << std::endl); + return std::string(""); + } + + CScript scriptPubKey = GetScriptForDestination(dest); + mtx.vout.push_back(CTxOut(txfee, scriptPubKey)); + change = inputs - txfee; + if( change != 0 ) + mtx.vout.push_back(CTxOut(change, CScript() << ParseHex(HexStr(myPubKey)) << OP_CHECKSIG)); + + //make opret with amount: + return FinalizeCCTx(0, cpDummy, mtx, myPubKey, txfee, CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_IMPORTCOIN << (uint8_t)'A' << amount)); +} + +// make sure vin0 is signed by ASSETCHAINS_OVERRIDE_PUBKEY33 +int32_t CheckVin0PubKey(const CTransaction &sourcetx) +{ + CTransaction vintx; + uint256 blockHash; + char destaddr[64], pkaddr[64]; + + if( !myGetTransaction(sourcetx.vin[0].prevout.hash, vintx, blockHash) ) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckVin0PubKey() could not load vintx" << sourcetx.vin[0].prevout.hash.GetHex() << std::endl); + return(-1); + } + if( sourcetx.vin[0].prevout.n < vintx.vout.size() && Getscriptaddress(destaddr, vintx.vout[sourcetx.vin[0].prevout.n].scriptPubKey) != 0 ) + { + pubkey2addr(pkaddr, ASSETCHAINS_OVERRIDE_PUBKEY33); + if (strcmp(pkaddr, destaddr) == 0) { + return(0); + } + LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckVin0PubKey() mismatched vin0[prevout.n=" << sourcetx.vin[0].prevout.n << "] -> destaddr=" << destaddr << " vs pkaddr=" << pkaddr << std::endl); + } + return -1; +} + +// ac_import=PUBKEY support: +// prepare a tx for creating import tx and quasi-burn tx +int32_t GetSelfimportProof(std::string source, CMutableTransaction &mtx, CScript &scriptPubKey, TxProof &proof, std::string rawsourcetx, int32_t &ivout, uint256 sourcetxid, uint64_t burnAmount) // find burnTx with hash from "other" daemon +{ + MerkleBranch newBranch; + CMutableTransaction tmpmtx; + CTransaction sourcetx; + + tmpmtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + + if (!E_UNMARSHAL(ParseHex(rawsourcetx), ss >> sourcetx)) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "GetSelfimportProof: could not unmarshal source tx" << std::endl); + return(-1); + } + + if (sourcetx.vout.size() == 0) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "GetSelfimportProof: vout size is 0" << std::endl); + return -1; + } + + if (ivout < 0) { // "ivout < 0" means "find" + // try to find vout + CPubKey myPubkey = Mypubkey(); + ivout = 0; + // skip change: + if (sourcetx.vout[ivout].scriptPubKey == (CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG)) + ivout++; + } + + if (ivout >= sourcetx.vout.size()) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "GetSelfimportProof: needed vout not found" << std::endl); + return -1; + } + + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "GetSelfimportProof: using vout[" << ivout << "] of the passed rawtx" << std::endl); + + scriptPubKey = sourcetx.vout[ivout].scriptPubKey; + + //mtx is template for import tx + mtx = sourcetx; + mtx.fOverwintered = tmpmtx.fOverwintered; + + //malleability fix for burn tx: + //mtx.nExpiryHeight = tmpmtx.nExpiryHeight; + mtx.nExpiryHeight = sourcetx.nExpiryHeight; + + mtx.nVersionGroupId = tmpmtx.nVersionGroupId; + mtx.nVersion = tmpmtx.nVersion; + mtx.vout.clear(); + mtx.vout.resize(1); + mtx.vout[0].nValue = burnAmount; + mtx.vout[0].scriptPubKey = scriptPubKey; + + // not sure we need this now as we create sourcetx ourselves: + if (sourcetx.GetHash() != sourcetxid) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "GetSelfimportProof: passed source txid incorrect" << std::endl); + return(-1); + } + + // check ac_pubkey: + if (CheckVin0PubKey(sourcetx) < 0) { + return -1; + } + proof = std::make_pair(sourcetxid, newBranch); + return 0; } // use proof from the above functions to validate the import @@ -116,9 +356,46 @@ int32_t CheckGATEWAYimport(TxProof proof,std::vector rawproof,CTransact int32_t CheckPUBKEYimport(TxProof proof,std::vector rawproof,CTransaction burnTx,std::vector payouts) { // if burnTx has ASSETCHAINS_PUBKEY vin, it is valid return(0); - fprintf(stderr,"proof txid.%s\n",proof.first.GetHex().c_str()); + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "proof txid=" << proof.first.GetHex() << std::endl); + + uint256 sourcetxid = proof.first, hashBlock; + CTransaction sourcetx; + + if (!myGetTransaction(sourcetxid, sourcetx, hashBlock)) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "could not load source txid=" << sourcetxid.GetHex() << std::endl); + return -1; + } + + if (sourcetx.vout.size() == 0) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "no vouts in source txid=" << sourcetxid.GetHex() << std::endl); + return -1; + } + + //ac_pubkey check: + if (CheckVin0PubKey(sourcetx) < 0) { + return -1; + } + + // get source tx opret: + std::vector vopret; + uint8_t evalCode, funcId; + int64_t amount; + + GetOpReturnData(sourcetx.vout.back().scriptPubKey, vopret); + if (vopret.size() == 0 || !E_UNMARSHAL(vopret, ss >> evalCode; ss >> funcId; ss >> amount) || evalCode != EVAL_IMPORTCOIN || funcId != 'A') { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "no or incorrect opret to validate in source txid=" << sourcetxid.GetHex() << std::endl); + return -1; + } + + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "importTx amount=" << payouts[0].nValue << " burnTx amount=" << burnTx.vout[0].nValue << " opret amount=" << amount << " source txid=" << sourcetxid.GetHex() << std::endl); + + // amount malleability check with the opret from the source tx: + if (payouts[0].nValue != amount) { // assume that burntx amount is checked in the common code in Eval::ImportCoin() + LOGSTREAM("importcoin", CCLOG_INFO, stream << "importTx amount != amount in the opret of source txid=" << sourcetxid.GetHex() << std::endl); + return -1; + } + return(0); - return(-1); } bool Eval::ImportCoin(const std::vector params,const CTransaction &importTx,unsigned int nIn) @@ -132,10 +409,10 @@ bool Eval::ImportCoin(const std::vector params,const CTransaction &impo return Invalid("invalid-params"); // Control all aspects of this transaction // It should not be at all malleable - if (MakeImportCoinTransaction(proof, burnTx, payouts).GetHash() != importTx.GetHash()) + if (MakeImportCoinTransaction(proof, burnTx, payouts, importTx.nExpiryHeight).GetHash() != importTx.GetHash()) return Invalid("non-canonical"); // burn params - if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCcid, payoutsHash,rawproof)) + if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCcid, payoutsHash, rawproof)) return Invalid("invalid-burn-tx"); // check burn amount { diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 39ff01d68..381a52fb8 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -26,14 +26,17 @@ int32_t komodo_nextheight(); -CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts) +CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts, uint32_t nExpiryHeightOverride) { std::vector payload = E_MARSHAL(ss << EVAL_IMPORTCOIN); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); mtx.vout = payouts; auto importData = E_MARSHAL(ss << proof; ss << burnTx); mtx.vout.insert(mtx.vout.begin(), CTxOut(0, CScript() << OP_RETURN << importData)); + + if (nExpiryHeightOverride != 0) + mtx.nExpiryHeight = nExpiryHeightOverride; //this is for construction of the tx used for validating importtx return CTransaction(mtx); } diff --git a/src/importcoin.h b/src/importcoin.h index 64019ac8f..947debcd8 100644 --- a/src/importcoin.h +++ b/src/importcoin.h @@ -26,7 +26,7 @@ CAmount GetCoinImportValue(const CTransaction &tx); CTransaction MakeImportCoinTransaction(const TxProof proof, - const CTransaction burnTx, const std::vector payouts); + const CTransaction burnTx, const std::vector payouts, uint32_t nExpiryHeightOverride = 0); CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts,std::vector rawproof); diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index a0a3b507f..1a6dc41ea 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -34,21 +34,27 @@ #include "script/sign.h" #include "script/standard.h" +#include "key_io.h" + #include #include #include - using namespace std; +extern std::string ASSETCHAINS_SELFIMPORT; +extern uint16_t ASSETCHAINS_CODAPORT, ASSETCHAINS_BEAMPORT; + int32_t komodo_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip); int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM *mdata,char *symbol,int32_t kmdheight,int32_t notarized_height); struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi); uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth); extern std::string ASSETCHAINS_SELFIMPORT; uint256 Parseuint256(char *hexstr); -int32_t GetSelfimportProof(std::string source,CMutableTransaction &mtx,CScript &scriptPubKey,TxProof &proof,uint64_t burnAmount,std::vector rawtx,uint256 txid,std::vector rawproof); +std::string MakeSelfImportSourceTx(CTxDestination &dest, int64_t amount, CMutableTransaction &mtx); +int32_t GetSelfimportProof(std::string source, CMutableTransaction &mtx, CScript &scriptPubKey, TxProof &proof, std::string rawsourcetx, int32_t &ivout, uint256 sourcetxid, uint64_t burnAmount); +std::string MakeGatewaysImportTx(uint64_t txfee, uint256 bindtxid, int32_t height, std::string refcoin, std::vectorproof, std::string rawburntx, int32_t ivout, uint256 burntxid); UniValue assetchainproof(const UniValue& params, bool fHelp) { @@ -256,6 +262,7 @@ UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp) TxProof proof = GetAssetchainProof(burnTx.GetHash(),burnTx); CTransaction importTx = MakeImportCoinTransaction(proof, burnTx, payouts); + return HexStr(E_MARSHAL(ss << importTx)); } @@ -281,31 +288,122 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp) UniValue selfimport(const UniValue& params, bool fHelp) { - CMutableTransaction mtx; - std::string source; TxProof proof; CTransaction burnTx,tx; CTxOut burnOut; uint64_t burnAmount; uint256 txid,blockHash; std::vector vouts; std::vector rawtx,rawproof; CScript scriptPubKey; + UniValue result(UniValue::VOBJ); + CMutableTransaction sourceMtx, templateMtx; + std::string destaddr; + std::string source; + std::string rawsourcetx; + CTransaction burnTx; + CTxOut burnOut; + uint64_t burnAmount; + uint256 sourcetxid, blockHash; + std::vector vouts; + std::vector rawproof, rawproofEmpty; + int32_t ivout = 0; + CScript scriptPubKey; + TxProof proof; + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) throw runtime_error("selfimport only works on -ac_import chains"); - if (fHelp || params.size() < 3 || params.size() > 5 ) - throw runtime_error("selfimport rawtx txid burnamount [rawproof source]\n\n" - "creates signed selfimport transaction"); - rawtx = ParseHex(params[0].get_str().c_str()); - txid = Parseuint256((char *)params[1].get_str().c_str()); // allow for txid != hash(rawtx) - burnAmount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; - source = ASSETCHAINS_SELFIMPORT; - if ( params.size() >= 4 ) + + if (fHelp || params.size() != 2) + throw runtime_error("selfimport destaddr amount\n" + //old: "selfimport rawsourcetx sourcetxid {nvout|\"find\"} amount \n" + //TODO: "or selfimport rawburntx burntxid {nvout|\"find\"} rawproof source bindtxid height} \n" + "\ncreates self import coin transaction"); + +/* OLD selfimport schema: + rawsourcetx = params[0].get_str(); + sourcetxid = Parseuint256((char *)params[1].get_str().c_str()); // allow for txid != hash(rawtx) + + int32_t ivout = -1; + if( params[2].get_str() != "find" ) { + if( !std::all_of(params[2].get_str().begin(), params[2].get_str().end(), ::isdigit) ) // check if not all chars are digit + throw std::runtime_error("incorrect nvout param"); + + ivout = atoi(params[2].get_str().c_str()); + } + + burnAmount = atof(params[3].get_str().c_str()) * COIN + 0.00000000499999; */ + + destaddr = params[0].get_str(); + burnAmount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; + + source = ASSETCHAINS_SELFIMPORT; //defaults to -ac_import=... param + /* TODO for gateways: + if ( params.size() >= 5 ) { - rawproof = ParseHex(params[3].get_str().c_str()); - if ( params.size() == 5 ) - source = params[4].get_str(); + rawproof = ParseHex(params[4].get_str().c_str()); + if ( params.size() == 6 ) + source = params[5].get_str(); + } */ + + + if (source == "BEAM") + { + if (ASSETCHAINS_BEAMPORT == 0) + return(-1); + // confirm via ASSETCHAINS_BEAMPORT that burnTx/hash is a valid BEAM burn + // return(0); + return -1; } - if ( GetSelfimportProof(source,mtx,scriptPubKey,proof,burnAmount,rawtx,txid,rawproof) < 0 ) - throw std::runtime_error("Failed validating selfimport"); - vouts = mtx.vout; - burnOut = MakeBurnOutput(burnAmount,0xffffffff,ASSETCHAINS_SELFIMPORT,vouts,rawproof); - mtx.vout.clear(); - mtx.vout.push_back(burnOut); - burnTx = mtx; - return HexStr(E_MARSHAL(ss << MakeImportCoinTransaction(proof,burnTx,vouts))); + else if (source == "CODA") + { + if (ASSETCHAINS_CODAPORT == 0) + return(-1); + // confirm via ASSETCHAINS_CODAPORT that burnTx/hash is a valid CODA burn + // return(0); + return -1; + } + else if (source == "PUBKEY") + { + + CTxDestination dest = DecodeDestination(destaddr.c_str()); + rawsourcetx = MakeSelfImportSourceTx(dest, burnAmount, sourceMtx); + sourcetxid = sourceMtx.GetHash(); + + // prepare self-import 'quasi-burn' tx and also create vout for import tx (in mtx.vout): + if (GetSelfimportProof(source, templateMtx, scriptPubKey, proof, rawsourcetx, ivout, sourcetxid, burnAmount) < 0) + throw std::runtime_error("Failed validating selfimport"); + + vouts = templateMtx.vout; + burnOut = MakeBurnOutput(burnAmount, 0xffffffff, ASSETCHAINS_SELFIMPORT, vouts, rawproofEmpty); + templateMtx.vout.clear(); + templateMtx.vout.push_back(burnOut); // burn tx has only opret with vouts and optional proof + + burnTx = templateMtx; // complete the creation of 'quasi-burn' tx + + std::string hextx = HexStr(E_MARSHAL(ss << MakeImportCoinTransaction(proof, burnTx, vouts))); + + CTxDestination address; + bool fValidAddress = ExtractDestination(scriptPubKey, address); + + result.push_back(Pair("sourceTxHex", rawsourcetx)); + result.push_back(Pair("importTxHex", hextx)); + result.push_back(Pair("UsedRawtxVout", ivout)); // notify user about the used vout of rawtx + result.push_back(Pair("DestinationAddress", EncodeDestination(address))); // notify user about the address where the funds will be sent + + return result; + } + else if (source == ASSETCHAINS_SELFIMPORT) + { + throw std::runtime_error("not implemented yet\n"); + + if (params.size() != 8) + throw runtime_error("use \'selfimport rawburntx burntxid nvout rawproof source bindtxid height\' to import from a coin chain\n"); + + uint256 bindtxid = Parseuint256((char *)params[6].get_str().c_str()); + int32_t height = atoi((char *)params[7].get_str().c_str()); + + + // source is external coin is the assetchains symbol in the burnTx OP_RETURN + // burnAmount, rawtx and rawproof should be enough for gatewaysdeposit equivalent + std::string hextx = MakeGatewaysImportTx(0, bindtxid, height, source, rawproof, rawsourcetx, ivout, sourcetxid); + + result.push_back(Pair("hex", hextx)); + result.push_back(Pair("UsedRawtxVout", ivout)); // notify user about the used vout of rawtx + } + return result; } UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 98b5deccc..19ac60525 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -541,7 +541,8 @@ static const CRPCCommand vRPCCommands[] = /* Not shown in help */ { "hidden", "setmocktime", &setmocktime, true }, { "hidden", "test_ac", &test_ac, true }, - { "hidden", "test_heirmarker", &test_heirmarker, true }, + { "hidden", "test_heirmarker", &test_heirmarker, true }, + { "hidden", "test_proof", &test_proof, true }, { "hidden", "test_burntx", &test_burntx, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 9cacce8ac..b41203df9 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -478,6 +478,6 @@ extern UniValue paxwithdraw(const UniValue& params, bool fHelp); extern UniValue test_ac(const UniValue& params, bool fHelp); extern UniValue test_heirmarker(const UniValue& params, bool fHelp); extern UniValue test_burntx(const UniValue& params, bool fHelp); - +extern UniValue test_proof(const UniValue& params, bool fHelp); #endif // BITCOIN_RPCSERVER_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5564c2000..f945b82fc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7883,8 +7883,11 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_HEIR); return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); + + } + UniValue test_burntx(const UniValue& params, bool fHelp) { // make fake token tx: @@ -7927,3 +7930,52 @@ UniValue test_burntx(const UniValue& params, bool fHelp) CCaddr2set(cp, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, EncodeTokenOpRet(tokenid, voutPubkeys, CScript()))); } + +UniValue test_proof(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + std::vectorproof; + + if (fHelp || (params.size() != 2)) + throw runtime_error("incorrect params\n"); + + + proof = ParseHex(params[0].get_str()); + uint256 cointxid = Parseuint256((char *)params[1].get_str().c_str()); + + std::vector txids; + + CMerkleBlock merkleBlock; + if (!E_UNMARSHAL(proof, ss >> merkleBlock)) { + result.push_back(Pair("error", "could not unmarshal proof")); + return result; + } + uint256 merkleRoot = merkleBlock.txn.ExtractMatches(txids); + + result.push_back(Pair("source_root", merkleRoot.GetHex())); + + for (int i = 0; i < txids.size(); i++) + std::cerr << "merkle block txid=" << txids[0].GetHex() << std::endl; + + + std::vector vMatches(txids.size()); + for (auto v : vMatches) v = true; + CPartialMerkleTree verifTree(txids, vMatches); + + result.push_back(Pair("verif_root", verifTree.ExtractMatches(txids).GetHex())); + + if (std::find(txids.begin(), txids.end(), cointxid) == txids.end()) { + fprintf(stderr, "invalid proof for this cointxid\n"); + } + + std::vector vMerkleTree; + bool f; + ::BuildMerkleTree(&f, txids, vMerkleTree); + + std::vector vMerkleBranch = ::GetMerkleBranch(0, txids.size(), vMerkleTree); + + uint256 ourResult = SafeCheckMerkleBranch(zeroid, vMerkleBranch, 0); + result.push_back(Pair("SafeCheckMerkleBranch", ourResult.GetHex())); + + return result; +} From 7b312f6ce680977b12690fa11be83cfe9fd3c02b Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 16 Feb 2019 21:59:21 +0500 Subject: [PATCH 2140/3904] added burn tx nExpiryHeight validation --- src/cc/import.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index dbbf7832f..1b49f5c94 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -371,6 +371,12 @@ int32_t CheckPUBKEYimport(TxProof proof,std::vector rawproof,CTransacti return -1; } + // might be malleable: + if (burnTx.nExpiryHeight != sourcetx.nExpiryHeight) { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "burntx nExpiryHeight incorrect for source txid=" << sourcetxid.GetHex() << std::endl); + return -1; + } + //ac_pubkey check: if (CheckVin0PubKey(sourcetx) < 0) { return -1; From 3c3531627f25c6a6d94fc6aef07dcbb6e4150b66 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 16 Feb 2019 22:15:55 +0500 Subject: [PATCH 2141/3904] comment added --- src/cc/import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 1b49f5c94..25bed49df 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -415,7 +415,7 @@ bool Eval::ImportCoin(const std::vector params,const CTransaction &impo return Invalid("invalid-params"); // Control all aspects of this transaction // It should not be at all malleable - if (MakeImportCoinTransaction(proof, burnTx, payouts, importTx.nExpiryHeight).GetHash() != importTx.GetHash()) + if (MakeImportCoinTransaction(proof, burnTx, payouts, importTx.nExpiryHeight).GetHash() != importTx.GetHash()) // ExistsImportTombstone prevents from duplication return Invalid("non-canonical"); // burn params if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCcid, payoutsHash, rawproof)) From ec0a203d88aa48031c2934d5eb3d12bb8bbf67fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 07:19:14 -1100 Subject: [PATCH 2142/3904] Extract roc --- src/cc/cclib.cpp | 3 +++ src/cc/rogue/rogue.c | 6 ++--- src/cc/rogue/rogue.h | 2 +- src/cc/rogue_rpc.cpp | 62 +++++++++++++++++++++++++++++++++++++++----- 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c13f55ce4..be6f3a3fe 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -89,6 +89,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -118,6 +119,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(rogue_bailout(txfee,cp,params)); else if ( strcmp(method,"highlander") == 0 ) return(rogue_highlander(txfee,cp,params)); + else if ( strcmp(method,"extract") == 0 ) + return(rogue_extract(txfee,cp,params)); else if ( strcmp(method,"playerinfo") == 0 ) return(rogue_playerinfo(txfee,cp,params)); else if ( strcmp(method,"players") == 0 ) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index be17b25be..0f53dfff2 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -232,14 +232,14 @@ void rogue_bailout(struct rogue_state *rs) fprintf(stderr,"error issuing (%s)\n",cmd); } -int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player) +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis) { struct rogue_state *rs; FILE *fp; int32_t i; rs = (struct rogue_state *)calloc(1,sizeof(*rs)); rs->seed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; - rs->sleeptime = 0*50000; + rs->sleeptime = sleepmillis * 1000; if ( player != 0 ) { rs->P = *player; @@ -320,7 +320,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } if ( num > 0 ) { - rogue_replay2(0,seed,keystrokes,num,0); + rogue_replay2(0,seed,keystrokes,num,0,0); mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 7d00bd8cf..fac84d8b0 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -392,7 +392,7 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter); int32_t flushkeystrokes(struct rogue_state *rs); int32_t rogue_restorepack(struct rogue_state *rs); void restore_player(struct rogue_state *rs); -int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); void rogue_bailout(struct rogue_state *rs); /* diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5daca5d1c..3597eab5a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -34,7 +34,7 @@ struct rogue_player int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; -int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player); +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); #define ROGUE_DECLARED_PACK void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); @@ -826,6 +826,54 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } +UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,regslot,numkeys,err; std::string symbol,pname,maxplayers,batonht,batonvout; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; + mypk = pubkey2pk(Mypubkey()); + roguepk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); + result.push_back(Pair("name","rogue")); + result.push_back(Pair("method",method)); + result.push_back(Pair("myrogueaddr",myrogueaddr)); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + { + if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 ) + { + UniValue obj; struct rogue_player P; + seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname,batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i highlander vout from creategame TCBOO @@ -869,15 +917,11 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("gametxid",gametxid.GetHex())); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { - if ( maxplayers == 1 ) - mult /= 2; if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 ) { UniValue obj; struct rogue_player P; - if ( pname.size() == 0 ) - pname = Rogue_pname; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname,batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -886,7 +930,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } if ( keystrokes != 0 ) { - num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P); + num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); if ( keystrokes != 0 ) free(keystrokes); } else num = 0; @@ -909,6 +953,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else { + if ( maxplayers == 1 ) + mult /= 2; cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); @@ -933,6 +979,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); CScript opret; + if ( pname.size() == 0 ) + pname = Rogue_pname; if ( newdata.size() == 0 ) { opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, nodata,pname); From 466fdb06a7f198a884cfd521a19722bfc016786f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 07:20:36 -1100 Subject: [PATCH 2143/3904] syntax --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3597eab5a..0041a68c4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -828,12 +828,12 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,regslot,numkeys,err; std::string symbol,pname,maxplayers,batonht,batonvout; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; + UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,gameheight,numplayers,regslot,numkeys,err; std::string symbol,pname,maxplayers,batonht,batonvout; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000]; mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); result.push_back(Pair("name","rogue")); - result.push_back(Pair("method",method)); + result.push_back(Pair("method","extract")); result.push_back(Pair("myrogueaddr",myrogueaddr)); if ( (params= cclib_reparse(&n,params)) != 0 ) { From c501ef7e684a30bb6e894757f9b52597614c2587 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 07:22:12 -1100 Subject: [PATCH 2144/3904] Fix --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0041a68c4..88e8a1749 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -828,7 +828,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,gameheight,numplayers,regslot,numkeys,err; std::string symbol,pname,maxplayers,batonht,batonvout; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000]; + UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,maxplayers,gameheight,numplayers,regslot,numkeys,err; std::string symbol,pname,maxplayers,batonht,batonvout; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000]; mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); @@ -847,7 +847,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname,batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -921,7 +921,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { UniValue obj; struct rogue_player P; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname,batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { From efbaeecaa39f4dca075edcf6236efdedeb738d7d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 07:23:08 -1100 Subject: [PATCH 2145/3904] ,batonht,batonvout --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 88e8a1749..b403acd1a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -828,7 +828,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,maxplayers,gameheight,numplayers,regslot,numkeys,err; std::string symbol,pname,maxplayers,batonht,batonvout; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000]; + UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000]; mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); From 3a93aa649c74b64efe411e6c4947ab8bea416044 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 07:39:28 -1100 Subject: [PATCH 2146/3904] Test --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b403acd1a..60e7fab35 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -832,6 +832,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); + result.push_back(Pair("status","success")); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); result.push_back(Pair("myrogueaddr",myrogueaddr)); @@ -841,6 +842,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); + fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 ) From 0871a2be6acec1b82bea5b057296bc988a23b106 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 07:41:24 -1100 Subject: [PATCH 2147/3904] Add to table --- src/cc/cclib.cpp | 1 + src/cc/rogue_rpc.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index be6f3a3fe..481dd81ce 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -64,6 +64,7 @@ CClib_methods[] = { (char *)"rogue", (char *)"players", (char *)"", 0, 0, 'D', EVAL_ROGUE }, { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, { (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE }, + { (char *)"rogue", (char *)"extract", (char *)"gametxid", 1, 1, 'X', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 60e7fab35..36e770823 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -836,6 +836,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); result.push_back(Pair("myrogueaddr",myrogueaddr)); + fprintf(stderr,"extract\n"); if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) From 0ddddd52f02fd25121a32f222b044430ae2703e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 08:16:18 -1100 Subject: [PATCH 2148/3904] +prints --- src/cc/rogue/rogue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 0f53dfff2..4b96026ef 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -294,11 +294,13 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) while ( 1 ) { roguefname(fname,seed,counter); + printf("check (%s)\n",fname); if ( (fp= fopen(fname,"rb")) == 0 ) break; if ( (fsize= get_filesize(fp)) <= 0 ) { fclose(fp); + printf("fsize.%ld\n",fsize); break; } if ( (keystrokes= (char *)realloc(keystrokes,num+fsize)) == 0 ) From a2da66be25e56359aee4d6a65edcd8950f0ce07a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 08:20:56 -1100 Subject: [PATCH 2149/3904] rogue.seed.0 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 36e770823..ebef1f19d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -859,7 +859,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } if ( keystrokes != 0 ) { - sprintf(fname,"%llu.0",(long long)seed); + sprintf(fname,"rogue.%llu.0",(long long)seed); if ( (fp= fopen(fname,"wb")) != 0 ) { if ( fwrite(keystrokes,1,numkeys,fp) != numkeys ) From 16e9d5e6b2086d4bcb09aec4738c2efed09c1bb4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 08:21:47 -1100 Subject: [PATCH 2150/3904] Slow down replay --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 4b96026ef..494e99b9c 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -322,7 +322,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } if ( num > 0 ) { - rogue_replay2(0,seed,keystrokes,num,0,0); + rogue_replay2(0,seed,keystrokes,num,0,50); mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); } From 878db4d87968f5d81307b24910a691ac353b3ff2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 08:33:56 -1100 Subject: [PATCH 2151/3904] Pub key arg to extract --- src/cc/cclib.cpp | 2 +- src/cc/rogue_rpc.cpp | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 481dd81ce..8a5cd2185 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -64,7 +64,7 @@ CClib_methods[] = { (char *)"rogue", (char *)"players", (char *)"", 0, 0, 'D', EVAL_ROGUE }, { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, { (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE }, - { (char *)"rogue", (char *)"extract", (char *)"gametxid", 1, 1, 'X', EVAL_ROGUE }, + { (char *)"rogue", (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, 'X', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ebef1f19d..69e77f5d8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -828,28 +828,35 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char myrogueaddr[64],fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000]; - mypk = pubkey2pk(Mypubkey()); + UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); result.push_back(Pair("status","success")); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); - result.push_back(Pair("myrogueaddr",myrogueaddr)); - fprintf(stderr,"extract\n"); if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); - fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); + if ( n == 2 ) + { + if ( (pubstr= jstr(jitem(params,1),0)) != 0 && strlen(pubstr) == 66 ) + { + decode_hex(pub33,33,pubstr); + pk = buf2pk(pub33); + } + fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); + } + GetCCaddress1of2(cp,myrogueaddr,roguepk,pk); + result.push_back(Pair("rogueaddr",rogueaddr)); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { - if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 ) + if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) { UniValue obj; struct rogue_player P; - seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr); + seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) From c7db40898ae5d4673bc60fff9c62be05e5870582 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 08:35:27 -1100 Subject: [PATCH 2152/3904] Fix --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 69e77f5d8..d9daf2187 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -828,7 +828,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey mypk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("status","success")); @@ -849,7 +849,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); } - GetCCaddress1of2(cp,myrogueaddr,roguepk,pk); + GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { From e9bddb1ed175a33c22d5fc8d8908cf50f74daf33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 08:53:22 -1100 Subject: [PATCH 2153/3904] Mark replay done on Q --- src/cc/rogue/command.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 1a32246bb..6cc6b0763 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -269,6 +269,7 @@ over: q_comm = FALSE; if ( rs->guiflag != 0 ) rogue_bailout(rs); + else rs->replaydone = (uint32_t)time(NULL); return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); From eba3ba86f637a4a932d028f0429381ddd08916ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 09:00:32 -1100 Subject: [PATCH 2154/3904] Alternate esc and y --- src/cc/rogue/io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 6791c26a4..fbcddf5fa 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -155,6 +155,7 @@ readchar(struct rogue_state *rs) char ch = -1; if ( rs != 0 && rs->guiflag == 0 ) { + static uint32_t counter; if ( rs->ind < rs->numkeys ) { //if ( rs->ind == rs->numkeys-1 ) @@ -162,13 +163,15 @@ readchar(struct rogue_state *rs) //fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } - if ( rs->replaydone != 0 ) + if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); //if ( (rand() & 1) == 0 ) // return(ESCAPE); //else - return('y'); + if ( counter < 3 || (counter & 1) == 0 ) + return('y'); + else return(ESCAPE); } if ( rs == 0 || rs->guiflag != 0 ) { From 139a7bdfec066e1c25cd6aedcd02dbbced2f1807 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 09:31:50 -1100 Subject: [PATCH 2155/3904] Extract player data --- src/cc/rogue/init.c | 4 ++++ src/cc/rogue/rogue.c | 4 +++- src/cc/rogue_rpc.cpp | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 1603474e2..dcbdb2f6d 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -49,7 +49,11 @@ void init_player(struct rogue_state *rs) // duplicate rng usage of normal case obj = new_item(); init_weapon(obj, MACE); + free(obj); + obj = new_item(); init_weapon(obj, BOW); + free(obj); + obj = new_item(); init_weapon(obj, ARROW); obj->o_count = rnd(15) + 25; free(obj); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 494e99b9c..43d230eec 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -104,7 +104,9 @@ void rogueiterate(struct rogue_state *rs) fuse(swander, 0, WANDERTIME, AFTER); start_daemon(stomach, 0, AFTER); if ( rs->restoring != 0 ) + { restore_player(rs); + } playit(rs); } @@ -244,7 +246,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu { rs->P = *player; rs->restoring = 1; - fprintf(stderr,"restore player packsize.%d\n",rs->P.packsize); + fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d9daf2187..143842007 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -873,6 +873,13 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"error writing %s\n",fname); fclose(fp); } + sprintf(fname,"rogue.%llu.player",(long long)seed); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + if ( fwrite(playerdata,1,(int32_t)playerdata.size(),fp) != playerdata.size() ) + fprintf(stderr,"error writing %s\n",fname); + fclose(fp); + } num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,50); if ( keystrokes != 0 ) free(keystrokes); From d0090c3c881a237fe9db63a4fd7456c8c0c53d7c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 09:33:09 -1100 Subject: [PATCH 2156/3904] Syntax --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 143842007..65b8be53e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -876,7 +876,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) sprintf(fname,"rogue.%llu.player",(long long)seed); if ( (fp= fopen(fname,"wb")) != 0 ) { - if ( fwrite(playerdata,1,(int32_t)playerdata.size(),fp) != playerdata.size() ) + if ( fwrite(&playerdata[0],1,(int32_t)playerdata.size(),fp) != playerdata.size() ) fprintf(stderr,"error writing %s\n",fname); fclose(fp); } From eeee29d3ae81e1bf8ee157480a4d16764b11c82b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 09:39:28 -1100 Subject: [PATCH 2157/3904] Make app use player data --- src/cc/rogue/rogue.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 43d230eec..f8b645d91 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -290,7 +290,7 @@ long get_filesize(FILE *fp) int32_t rogue_replay(uint64_t seed,int32_t sleeptime) { - FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; + FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0; if ( seed == 0 ) seed = 777; while ( 1 ) @@ -324,7 +324,17 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } if ( num > 0 ) { - rogue_replay2(0,seed,keystrokes,num,0,50); + sprintf(fname,"rogue.%llu.player",(long long)seed); + if ( (fp=fopen(fname,"rb")) != 0 ) + { + if ( fread(&P,1,sizeof(P),fp) > 0 ) + { + printf("max size player\n"); + player = &P; + } + fclose(fp); + } + rogue_replay2(0,seed,keystrokes,num,player,50); mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); } From ede1db736aa26d811fe889a11ecb80e5ed5009e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:01:15 -1100 Subject: [PATCH 2158/3904] +print --- src/cc/rogue_rpc.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 65b8be53e..854f5f6e1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -828,7 +828,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("status","success")); @@ -881,6 +881,18 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fclose(fp); } num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,50); + newdata.resize(num); + for (i=0; i no playerdata\n"); + newdata.resize(0); + } + else fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); if ( keystrokes != 0 ) free(keystrokes); } else num = 0; From 4f6cdb4b155b8c63c430a7c4275464a7bfb139f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:02:42 -1100 Subject: [PATCH 2159/3904] +print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 854f5f6e1..4d6167b3f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -892,7 +892,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - else fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); if ( keystrokes != 0 ) free(keystrokes); } else num = 0; From 8b6fe6bec71ff6f772d582949a7db23fb9dc2f08 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:19:22 -1100 Subject: [PATCH 2160/3904] -print --- src/cc/rogue/save.c | 15 +++++++++------ src/cc/rogue/state.c | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 718c5074b..7349c196a 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -165,21 +165,24 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) memset(histo,0,sizeof(histo)); for (i=0; iP)[i]); + //fprintf(stderr,"%02x",((uint8_t *)&rs->P)[i]); histo[((uint8_t *)&rs->P)[i]]++; rs->playerdata[i] = ((uint8_t *)&rs->P)[i]; } rs->playersize = n; - fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n); + //fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n); if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 ) { fwrite(&rs->P,1,n,fp); fclose(fp); } - for (i=nonz=0; i<0x100; i++) - if ( histo[i] != 0 ) - fprintf(stderr,"(%d %d) ",i,histo[i]), nonz++; - fprintf(stderr,"nonz.%d\n",nonz); + if ( 0 ) + { + for (i=nonz=0; i<0x100; i++) + if ( histo[i] != 0 ) + fprintf(stderr,"(%d %d) ",i,histo[i]), nonz++; + fprintf(stderr,"nonz.%d\n",nonz); + } fflush(savef); fclose(savef); if ( guiflag != 0 ) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index e034039a8..36191d72c 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1434,7 +1434,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) item = &rs->P.roguepack[rs->P.packsize]; if ( pstats.s_hpt <= 0 ) { - fprintf(stderr,"KILLED\n"); + //fprintf(stderr,"KILLED\n"); rs->P.gold = -1; rs->P.hitpoints = -1; rs->P.strength = -1; @@ -1452,9 +1452,9 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); + //fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } - fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); + //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) { packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); From 2f13dbdf4e30d5eb3b8949a4978022de4cc11ac5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:23:55 -1100 Subject: [PATCH 2161/3904] -print + delay --- src/cc/rogue/main.c | 2 +- src/cc/rogue/rogue.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index c3484eafe..12e6af368 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -252,7 +252,7 @@ int main(int argc, char **argv, char **envp) if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { seed = atol(argv[1]); - fprintf(stderr,"replay %llu\n",(long long)seed); + //fprintf(stderr,"replay %llu\n",(long long)seed); return(rogue_replay(seed,50000)); } else diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f8b645d91..7f885e861 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -246,7 +246,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu { rs->P = *player; rs->restoring = 1; - fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); + //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); @@ -296,7 +296,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) while ( 1 ) { roguefname(fname,seed,counter); - printf("check (%s)\n",fname); + //printf("check (%s)\n",fname); if ( (fp= fopen(fname,"rb")) == 0 ) break; if ( (fsize= get_filesize(fp)) <= 0 ) @@ -329,13 +329,14 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) { if ( fread(&P,1,sizeof(P),fp) > 0 ) { - printf("max size player\n"); + //printf("max size player\n"); player = &P; } fclose(fp); } rogue_replay2(0,seed,keystrokes,num,player,50); mvaddstr(LINES - 2, 0, (char *)"replay completed"); + sleep(4); endwin(); } if ( keystrokes != 0 ) From 593ec0e34092997f12d528d51f45882d057277c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:25:49 -1100 Subject: [PATCH 2162/3904] Pause --- src/cc/rogue/rogue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 7f885e861..340fe94a8 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -335,8 +335,9 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) fclose(fp); } rogue_replay2(0,seed,keystrokes,num,player,50); - mvaddstr(LINES - 2, 0, (char *)"replay completed"); sleep(4); + + //mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); } if ( keystrokes != 0 ) From 40a2bb28df79dc4378058740e7fb2e1042017941 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:26:05 -1100 Subject: [PATCH 2163/3904] 150 --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 340fe94a8..4e9d9438e 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -334,7 +334,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } fclose(fp); } - rogue_replay2(0,seed,keystrokes,num,player,50); + rogue_replay2(0,seed,keystrokes,num,player,150); sleep(4); //mvaddstr(LINES - 2, 0, (char *)"replay completed"); From bc71d62f820f415f55d1d9a802f218176b7a2aeb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:29:29 -1100 Subject: [PATCH 2164/3904] -score --- src/cc/rogue/rogue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 4e9d9438e..1e110ee12 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -646,8 +646,8 @@ quit(int sig) } else { - score(rs,purse, 1, 0); - fprintf(stderr,"done!\n"); + //score(rs,purse, 1, 0); + //fprintf(stderr,"done!\n"); } } else From 009b20d427f56e566744fe7fa617047e35f8e404 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:32:00 -1100 Subject: [PATCH 2165/3904] Test --- src/cc/rogue/rogue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 1e110ee12..e288bcf1a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -335,7 +335,6 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) fclose(fp); } rogue_replay2(0,seed,keystrokes,num,player,150); - sleep(4); //mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); @@ -589,7 +588,7 @@ playit(struct rogue_state *rs) { if ( rs->replaydone != 0 ) { - //fprintf(stderr,"replaydone\n"); sleep(3); + fprintf(stderr,"replaydone\n"); sleep(3); return; } if ( rs->sleeptime != 0 ) From 8c4226da9b970711352553cac62e03b2f38f8354 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 10:33:17 -1100 Subject: [PATCH 2166/3904] Sleeptime --- src/cc/rogue/rogue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index e288bcf1a..63e699c30 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -588,7 +588,8 @@ playit(struct rogue_state *rs) { if ( rs->replaydone != 0 ) { - fprintf(stderr,"replaydone\n"); sleep(3); + if ( rs->sleeptime != 0 ) + sleep(3); return; } if ( rs->sleeptime != 0 ) From e225c54012f306294773afe8ba0fac4dd8859da0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 16 Feb 2019 20:32:20 -1100 Subject: [PATCH 2167/3904] Use current strength --- src/cc/rogue/init.c | 2 +- src/cc/rogue/state.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index dcbdb2f6d..f296d6182 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -27,7 +27,7 @@ void restore_player(struct rogue_state *rs) int32_t i; THING *obj; //rs->P.gold = purse; max_hp = rs->P.hitpoints; - max_stats.s_str = rs->P.strength; + pstats.s_str = max_stats.s_str = rs->P.strength; pstats.s_lvl = rs->P.level; pstats.s_exp = rs->P.experience; for (i=0; iP.packsize; i++) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 36191d72c..e738a9d16 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1448,7 +1448,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) { rs->P.gold = purse; rs->P.hitpoints = max_hp; - rs->P.strength = max_stats.s_str; + rs->P.strength = pstats.s_str; //max_stats.s_str; rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; From e3ccd36f0b325587acaf5a5c9affa36fb9190f9b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:46:28 -1100 Subject: [PATCH 2168/3904] Initial cursesd --- src/cc/makerogue | 2 +- src/cc/rogue/cursesd.c | 363 +++++++++++++++++++++++++++++++++++++---- src/cc/rogue/cursesd.h | 161 +++++++++--------- src/cc/rogue/options.c | 6 +- src/cc/rogue/rip.c | 1 + src/cc/rogue/rogue.c | 2 + src/cc/rogue/rogue.h | 2 +- src/cc/rogue/rogue.scr | 0 src/cc/rogue/save.c | 4 +- src/cc/rogue/things.c | 63 +++---- 10 files changed, 465 insertions(+), 139 deletions(-) create mode 100644 src/cc/rogue/rogue.scr diff --git a/src/cc/makerogue b/src/cc/makerogue index 490576bd1..249e646f5 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -2,7 +2,7 @@ cd rogue; ./configure # only need this first time make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses +gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 643ed87de..54f55c4f5 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -17,13 +17,268 @@ static int32_t endwinflag; +WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) +{ + WINDOW *scr = 0; + if ( nlines == LINES && ncols == COLS && begin_y == 0 && begin_x == 0 ) + scr = (WINDOW *)calloc(1,sizeof(*stdscr)); + return(scr); +} + WINDOW *initscr() { if ( stdscr == 0 ) - stdscr = (WINDOW *)calloc(1,sizeof(*stdscr)); + stdscr = newwin(LINES,COLS,0,0); return(stdscr); } +int32_t delwin(WINDOW *win) +{ + free(win); + return(0); +} + +int32_t wmove(WINDOW *win, int32_t y, int32_t x) +{ + win->y = y; + win->x = x; + return(0); +} + +int32_t move(int32_t y, int32_t x) +{ + return(wmove(stdscr,y,x)); +} + +int werase(WINDOW *win) +{ + memset(win->screen,' ',sizeof(win->screen)); + return(0); +} + +int wclear(WINDOW *win) +{ + werase(win); + clearok(win,TRUE); + return(0); +} + +int wclrtoeol(WINDOW *win) +{ + if ( win->x < COLS-1 ) + memset(&win->screen[win->y][win->x],' ',COLS - win->x); + return(0); +} + +int wclrtobot(WINDOW *win) +{ + wclrtoeol(win); + if ( win->y < LINES-1 ) + memset(&win->screen[win->y+1][0],' ',COLS); + return(0); +} + +int erase(void) +{ + return(werase(stdscr)); +} + +int clear(void) +{ + return(wclear(stdscr)); +} + +int clrtobot(void) +{ + return(wclrtobot(stdscr)); +} + +int clrtoeol(void) +{ + return(wclrtoeol(stdscr)); +} + +int32_t waddch(WINDOW *win, chtype ch) +{ + int32_t t; + if ( ch == '\t' ) + { + for (i=0; i<8; i++) + { + if ( win->x >= COLS-1 ) + break; + win->x++; + if ( (win->x & 7) == 0 ) + break; + } + } + else if ( ch == '\n' ) + { + wclrtoeol(win); + win->x = 0; + win->y++; + if ( win->y >= LINES ) + win->y = 0; + } + else if ( ch == '\b' ) + { + if ( win->x > 0 ) + win->x--; + } + else + { + win->screen[win->y][win->x++] = ch; + if ( win->x >= COLS ) + { + win->x = 0; + win->y++; + if ( win->y >= LINES ) + win->y = 0; + } + } + reurn(0); +} + +int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch) +{ + win->y = y; + win->x = x; + return(waddch(win,ch)); +} + +int32_t addch(chtype ch) +{ + return(waddch(stdscr,ch)); +} + +int32_t mvaddch(int32_t y, int32_t x, chtype ch) +{ + return(mvwaddch(stdscr,y,x,ch)); +} + +int32_t waddstr(WINDOW *win, const char *str) +{ + int32_t i; + for (i=0; str[i]!=0; i++) + waddch(win,str[i]); + return(0); +} + +int32_t waddnstr(WINDOW *win, const char *str, int32_t n) +{ + int32_t i; + for (i=0; str[i]!=0 && iy = y; + win->x = x; + return(waddstr(win,str)); +} + +int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n) +{ + win->y = y; + win->x = x; + return(waddnstr(win,str)); +} + +int32_t addstr(const char *str) +{ + return(waddstr(stdscr,str)); +} + +int32_t addnstr(const char *str, int32_t n) +{ + return(waddnstr(stdscr,str,n)); +} + +int32_t mvaddstr(int32_t y, int32_t x, const char *str) +{ + stdscr->y = y; + stdscr->x = x; + return(waddstr(stdscr,str)); +} + +int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n) +{ + stdscr->y = y; + stdscr->x = x; + return(waddnstr(stdscr,str,n)); +} + +int32_t printw(char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + return(addstr(str)); +} + +int32_t wprintw(WINDOW *win,char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + return(waddstr(win,str)); +} + +int32_t mvprintw(int32_t y,int32_t x,char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + stdscr->y = y; + stdscr->x = x; + return(addstr(str)); +} + +int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + win->y = y; + win->x = x; + return(waddstr(win,str)); +} + +chtype winch(WINDOW *win) +{ + return(win->screen[win->y][win->x]); +} + +chtype inch(void) +{ + return(winch(stdscr)); +} + +chtype mvwinch(WINDOW *win, int32_t y, int32_t x) +{ + win->y = y; + win->x = x; + return(win->screen[win->y][win->x]); +} + +chtype mvinch(int32_t y, int32_t x) +{ + return(mvwinch(stdscr,y,x)); +} + +int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol) +{ + stdscr->y = newrow; + stdscr->x = newcol; + return(0); +} + void endwin() { if ( stdscr != 0 ) @@ -36,27 +291,12 @@ int isendwin(void) return(endwinflag); } -int wrefresh(WINDOW *win) -{ - return(0); -} - int refresh(void) { endwinflag = 0; return(wrefresh(stdscr)); } -int wnoutrefresh(WINDOW *win) -{ - return(0); -} - -int doupdate(void) -{ - return(0); -} - int redrawwin(WINDOW *win) { return(wrefresh(win)); @@ -67,42 +307,101 @@ int wredrawln(WINDOW *win, int beg_line, int num_lines) return(wrefresh(win)); } -int werase(WINDOW *win) +// functions with no data side effect +#ifdef they_are_macros +int wrefresh(WINDOW *win) { - + return(0); } -int erase(void) +int wnoutrefresh(WINDOW *win) { - return(werase(stdscr)); + return(0); } -int wclear(WINDOW *win) +int doupdate(void) { - + return(0); } -int clear(void) +int32_t touchwin(WINDOW *win) { - return(wclear(stdscr)); + return(0); } -int wclrtobot(WINDOW *win) +int standout(void) { - + return(0); } -int clrtobot(void) +int standend(void) { - return(wclrtobot(stdscr)); + return(0); } -int wclrtoeol(WINDOW *win) +int raw(void) { - + return(0); } -int clrtoeol(void) +int32_t keypad(WINDOW *win, bool bf) { - return(wclrtoeol(stdscr)); + return(0); } + +int noecho(void) +{ + return(0); +} + +int flushinp(void) +{ + return(0); +} + +int clearok(WINDOW *win, bool bf) +{ + return(0); +} + +int idlok(WINDOW *win, bool bf) +{ + return(0); +} + +int leaveok(WINDOW *win, bool bf) +{ + return(0); +} +#endif + +int32_t mvwin(WINDOW *win, int32_t y, int32_t x); // stub +{ + fprintf(stderr,"unexpected call to mvwin\n"); + return(0); +} + +WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x) +{ + fprintf(stderr,"unexpected and unsupported call to subwin\n"); + return(0); +} + +char erasechar(void) +{ + fprintf(stderr,"unexpected and unsupported call to erasechar\n"); + return(8); +} + +char killchar(void) +{ + fprintf(stderr,"unexpected and unsupported call to erasechar\n"); + return(3); +} + +int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n) // stub +{ + fprintf(stderr,"unexpected and unsupported call to mvgetnstr\n"); + return(0); +} + diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 5e3d375ca..6d5944b75 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -36,38 +36,107 @@ #include #include -#ifdef notyet - struct cursesd_info { uint8_t screen[LINES][COLS]; + int32_t x,y; } *stdscr; typedef struct cursesd_info WINDOW; +typedef char chtype; WINDOW *initscr(void); -int endwin(void); -int isendwin(void); +int32_t endwin(void); +int32_t isendwin(void); //SCREEN *newterm(const char *type, FILE *outfd, FILE *infd); //SCREEN *set_term(SCREEN *new); //void delscreen(SCREEN* sp); -int refresh(void); -int wrefresh(WINDOW *win); -//int wnoutrefresh(WINDOW *win); -//int doupdate(void); -int redrawwin(WINDOW *win); -int wredrawln(WINDOW *win, int beg_line, int num_lines); +int32_t refresh(void); +int32_t wrefresh(WINDOW *win); +//int32_t wnoutrefresh(WINDOW *win); +//int32_t doupdate(void); +int32_t redrawwin(WINDOW *win); +int32_t wredrawln(WINDOW *win, int32_t beg_line, int32_t num_lines); -int erase(void); -int werase(WINDOW *win); -int clear(void); -int wclear(WINDOW *win); -int clrtobot(void); -int wclrtobot(WINDOW *win); -int clrtoeol(void); -int wclrtoeol(WINDOW *win); +int32_t erase(void); +int32_t werase(WINDOW *win); +int32_t clear(void); +int32_t wclear(WINDOW *win); +int32_t clrtobot(void); +int32_t wclrtobot(WINDOW *win); +int32_t clrtoeol(void); +int32_t wclrtoeol(WINDOW *win); -#endif +int32_t standout(void); +int32_t standend(void); +int32_t raw(void); +int32_t noecho(void); +int32_t flushinp(void); +int32_t keypad(WINDOW *win, bool bf); + +int32_t clearok(WINDOW *win, bool bf); +int32_t idlok(WINDOW *win, bool bf); +int32_t leaveok(WINDOW *win, bool bf); + +WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x); // only LINES,COLS,0,0 +int32_t delwin(WINDOW *win); +int32_t touchwin(WINDOW *win); // stub +WINDOW *subwin(WINDOW *orig, int32_t nlines, int32_t ncols, int32_t begin_y, int32_t begin_x); // stub +int32_t mvwin(WINDOW *win, int32_t y, int32_t x); // stub +int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol); + +char erasechar(void); // stub +char killchar(void); // stub + +int32_t move(int32_t y, int32_t x); +int32_t wmove(WINDOW *win, int32_t y, int32_t x); + +chtype inch(void); +chtype winch(WINDOW *win); +chtype mvinch(int32_t y, int32_t x); +chtype mvwinch(WINDOW *win, int32_t y, int32_t x); + +int32_t addch(chtype ch); +int32_t waddch(WINDOW *win, chtype ch); +int32_t mvaddch(int32_t y, int32_t x, chtype ch); +int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch); + +int32_t addstr(const char *str); +int32_t addnstr(const char *str, int32_t n); +int32_t waddstr(WINDOW *win, const char *str); +int32_t waddnstr(WINDOW *win, const char *str, int32_t n); +int32_t mvaddstr(int32_t y, int32_t x, const char *str); +int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n); +int32_t mvwaddstr(WINDOW *win, int32_t y, int32_t x, const char *str); +int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n); + +int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n); // stub +int32_t printw(char *fmt,...); +int32_t wprintw(WINDOW *win,char *fmt,...); +int32_t mvprintw(int32_t y,int32_t x,char *fmt,...); +int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); + +#define A_CHARTEXT 0xff +#define baudrate() 9600 +#define unctrl(a) "^x" +#define getmaxx(a) COLS +#define getmaxy(a) LINES +#define getxy(win,y,x) y = win->y, x = win->x + +// functions with only visible effects +#define wrefresh(win) 0 +#define wnoutrefresh(win) 0 +#define doupdate() 0 +#define touchwin(win) 0 +#define standout() 0 +#define standend() 0 +#define raw() 0 +#define keypad(win,bf) 0 +#define noecho() 0 +#define flushinp() 0 +#define clearok(win,bf) 0 +#define idlok(win,bf) 0 +#define leaveok(win,bf) 0 #ifndef TRUE #define TRUE 1 @@ -77,57 +146,3 @@ int wclrtoeol(WINDOW *win); #endif -#define standout() -#define standend() -#define refresh() -#define raw() -#define noecho() -#define flushinp() -#define clear() -#define clrtoeol() - -#define addch(a) -#define werase(a) -#define wclear(a) -#define delwin(a) -#define addstr(a) -#define touchwin(a) -#define idlok(a,b) -#define clearok(a,b) -#define keypad(a,b) -#define leaveok(a,b) -#define waddch(a,b) -#define waddstr(a,b) -#define move(a,b) -#define mvwin(a,b,c) -#define wmove(a,b,c) -#define mvaddch(a,b,c) -#define mvaddstr(a,b,c) -#define wgetnstr(a,b,c) -#define getyx(a,b,c) -#define mvcur(a,b,c,d) -#define mvwaddch(a,b,c,d) -#define mvprintw(...) -#define printw(...) -#define wprintw(...) -#define mvwprintw(...) - - -#define A_CHARTEXT 0xff -#define inch() 0 -#define endwin() 1 -#define isendwin() 0 -#define baudrate() 9600 -#define killchar() 3 -#define erasechar() 8 -#define wclrtoeol(a) 0 -#define wrefresh(a) 0 -#define unctrl(a) "^x" -#define getmaxx(a) COLS -#define getmaxy(a) LINES -#define mvinch(a,b) '.' -#define mvwinch(a,b,c) 0 -#define newwin(a,b,c,d) 0 -#define subwin(a,b,c,d,e) 0 - -#endif diff --git a/src/cc/rogue/options.c b/src/cc/rogue/options.c index d74979365..258bd184f 100644 --- a/src/cc/rogue/options.c +++ b/src/cc/rogue/options.c @@ -266,7 +266,7 @@ get_str(struct rogue_state *rs,void *vopt, WINDOW *win) { if (c == -1) continue; - else if (c == erasechar()) /* process erase character */ + /*else if (c == erasechar()) // process erase character { if (sp > buf) { @@ -276,12 +276,12 @@ get_str(struct rogue_state *rs,void *vopt, WINDOW *win) } continue; } - else if (c == killchar()) /* process kill character */ + else if (c == killchar()) // process kill character { sp = buf; wmove(win, oy, ox); continue; - } + }*/ else if (sp == buf) { if (c == '-' && win != stdscr) diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index be97fb867..65be2e8fa 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -87,6 +87,7 @@ score(struct rogue_state *rs,int amount, int flags, char monst) delwin(curscr); if (hw != NULL) delwin(hw); + hw = NULL; } top_ten = (SCORE *) malloc(numscores * sizeof (SCORE)); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 63e699c30..eb605385d 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -91,7 +91,9 @@ void rogueiterate(struct rogue_state *rs) // Set up windows if ( hw == NULL ) + { hw = newwin(LINES, COLS, 0, 0); + } idlok(stdscr, TRUE); idlok(hw, TRUE); #ifdef MASTER diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index fac84d8b0..f8e5dd23b 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -29,7 +29,7 @@ #include #include -#ifndef DONTUSEGUI +#ifndef BUILD_ROGUE #include #else diff --git a/src/cc/rogue/rogue.scr b/src/cc/rogue/rogue.scr new file mode 100644 index 000000000..e69de29bb diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 7349c196a..15dda401e 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -227,7 +227,9 @@ restore(struct rogue_state *rs,char *file, char **envp) char buf[MAXSTR]; //auto STAT sbuf2; - + if ( rs->guiflag == 0 ) + return(0); + if (strcmp(file, "-r") == 0) file = file_name; diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 29c51c4ed..39c7b94b7 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -502,37 +502,44 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) msg(rs,""); if ( rs->sleeptime != 0 ) refresh(); - tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); - sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); - for (y = 0; y <= line_cnt; y++) + if ( rs->guiflag != 0 ) { - wmove(sw, y, 0); - for (x = 0; x <= maxlen; x++) - waddch(sw, mvwinch(hw, y, x)); - } - wmove(tw, line_cnt, 1); - waddstr(tw, prompt); - /* - * if there are lines below, use 'em - */ - if (LINES > NUMLINES) - { - if (NUMLINES + line_cnt > LINES) - mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); - else - mvwin(tw, NUMLINES, 0); - } - touchwin(tw); - wrefresh(tw); - wait_for(rs,' '); - if (md_hasclreol()) - { - werase(tw); - leaveok(tw, TRUE); + tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); + sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); + for (y = 0; y <= line_cnt; y++) + { + wmove(sw, y, 0); + for (x = 0; x <= maxlen; x++) + waddch(sw, mvwinch(hw, y, x)); + } + wmove(tw, line_cnt, 1); + waddstr(tw, prompt); + /* + * if there are lines below, use 'em + */ + if (LINES > NUMLINES) + { + if (NUMLINES + line_cnt > LINES) + mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); + else + mvwin(tw, NUMLINES, 0); + } + touchwin(tw); wrefresh(tw); + wait_for(rs,' '); + if (md_hasclreol()) + { + werase(tw); + leaveok(tw, TRUE); + wrefresh(tw); + } + delwin(tw); + touchwin(stdscr); + } + else + { + wait_for(rs,' '); } - delwin(tw); - touchwin(stdscr); } else { From a6b024b5595f0a9e1c65217fc25b3cc32bee5fac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:47:24 -1100 Subject: [PATCH 2169/3904] Delete rogue.scr --- src/cc/rogue/rogue.scr | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/cc/rogue/rogue.scr diff --git a/src/cc/rogue/rogue.scr b/src/cc/rogue/rogue.scr deleted file mode 100644 index e69de29bb..000000000 From 8d1a4eb532cc2ac86aa237be27af71e914a75ca6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:48:56 -1100 Subject: [PATCH 2170/3904] Terminate ifdef --- src/cc/rogue/cursesd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 6d5944b75..8a2062a36 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -145,4 +145,5 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define FALSE 0 #endif +#endif From a76f1fd959472a54c7534ceca9a48287f42a3b40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:51:28 -1100 Subject: [PATCH 2171/3904] Test --- src/cc/rogue/rogue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f8e5dd23b..8cf5f7d90 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -30,9 +30,10 @@ #include #ifndef BUILD_ROGUE +xxx #include #else - +yyy #include "cursesd.h" #endif From 360cb73281bddb712eeec96dbbe11dbd96d3bb23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:53:51 -1100 Subject: [PATCH 2172/3904] Mdport -= curses.h --- src/cc/rogue/mdport.c | 5 +++++ src/cc/rogue/rogue.h | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 443ef1e60..899f5d9db 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -81,7 +81,12 @@ #endif #endif +#ifndef BUILD_ROGUE #include /* AIX requires curses.h be included before term.h */ +#else +#include "cursesd.h" +#endif + #if defined(HAVE_TERM_H) #include diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 8cf5f7d90..e99c0d5ff 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -30,10 +30,8 @@ #include #ifndef BUILD_ROGUE -xxx #include #else -yyy #include "cursesd.h" #endif From 413b477db0f6baba40e942d991cbcac87ac3983b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:55:09 -1100 Subject: [PATCH 2173/3904] io.c --- src/cc/rogue/io.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index fbcddf5fa..a5762adda 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -8,6 +8,12 @@ //#include //#include //#include +#ifndef BUILD_ROGUE +#include +#else +#include "cursesd.h" +#endif + #include "rogue.h" /* From bc1fc144ae51f30579e19e765737e5d9db511627 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:58:04 -1100 Subject: [PATCH 2174/3904] Stdscr --- src/cc/rogue/cursesd.c | 1 + src/cc/rogue/cursesd.h | 3 ++- src/cc/rogue/io.c | 5 ----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 54f55c4f5..76760c3f9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -16,6 +16,7 @@ #include "cursesd.h" static int32_t endwinflag; +WINDOW *stdscr; WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) { diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 8a2062a36..0cbb2cc01 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -40,7 +40,8 @@ struct cursesd_info { uint8_t screen[LINES][COLS]; int32_t x,y; -} *stdscr; +}; +extern WINDOW *stdscr; typedef struct cursesd_info WINDOW; typedef char chtype; diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index a5762adda..c920ee411 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -8,11 +8,6 @@ //#include //#include //#include -#ifndef BUILD_ROGUE -#include -#else -#include "cursesd.h" -#endif #include "rogue.h" From da992ca886ca526d58536b91501581d89284e848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:15:30 -1100 Subject: [PATCH 2175/3904] Fixes --- src/cc/rogue/cursesd.c | 3 ++- src/cc/rogue/cursesd.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 76760c3f9..8462532b9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -23,6 +23,7 @@ WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) WINDOW *scr = 0; if ( nlines == LINES && ncols == COLS && begin_y == 0 && begin_x == 0 ) scr = (WINDOW *)calloc(1,sizeof(*stdscr)); + curscr = scr; return(scr); } @@ -400,7 +401,7 @@ char killchar(void) return(3); } -int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n) // stub +int32_t wgetnstr(WINDOW *win, char *str, int32_t n) // stub { fprintf(stderr,"unexpected and unsupported call to mvgetnstr\n"); return(0); diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 0cbb2cc01..57cb51237 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -41,7 +41,7 @@ struct cursesd_info uint8_t screen[LINES][COLS]; int32_t x,y; }; -extern WINDOW *stdscr; +extern WINDOW *stdscr,*curscr; typedef struct cursesd_info WINDOW; typedef char chtype; @@ -111,7 +111,7 @@ int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n); int32_t mvwaddstr(WINDOW *win, int32_t y, int32_t x, const char *str); int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n); -int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n); // stub +int32_t wgetnstr(WINDOW *win, char *str, int32_t n); // stub int32_t printw(char *fmt,...); int32_t wprintw(WINDOW *win,char *fmt,...); int32_t mvprintw(int32_t y,int32_t x,char *fmt,...); @@ -122,7 +122,7 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define unctrl(a) "^x" #define getmaxx(a) COLS #define getmaxy(a) LINES -#define getxy(win,y,x) y = win->y, x = win->x +#define getyx(win,y,x) y = win->y, x = win->x // functions with only visible effects #define wrefresh(win) 0 From 958365e987e02457d833e96b657c0e2406151d48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:42:06 -1100 Subject: [PATCH 2176/3904] _argfory --- src/cc/rogue/cursesd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 57cb51237..12ab8b2be 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -122,7 +122,7 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define unctrl(a) "^x" #define getmaxx(a) COLS #define getmaxy(a) LINES -#define getyx(win,y,x) y = win->y, x = win->x +#define getyx(win,_argfory,_argforx) _argfory = win->y, _argforx = win->x // functions with only visible effects #define wrefresh(win) 0 From 8824e836a700a03bdcc1265e1aa36cbd37e275f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:44:12 -1100 Subject: [PATCH 2177/3904] extern WINDOW *stdscr,*curscr; --- src/cc/rogue/rogue.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index e99c0d5ff..f3f5572b2 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -860,5 +860,8 @@ extern const char *wood[]; extern int cNWOOD; extern const char *metal[]; extern int cNMETAL; + +extern WINDOW *stdscr,*curscr; + #endif From 43edfb4ae23abe6ce59ce2377f7329e78eb83e17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:51:13 -1100 Subject: [PATCH 2178/3904] Stubs --- src/cc/rogue/cursesd.c | 6 ++++++ src/cc/rogue/cursesd.h | 6 +++++- src/cc/rogue/rogue.c | 2 ++ src/cc/rogue/rogue.h | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 8462532b9..c89a713ae 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -407,3 +407,9 @@ int32_t wgetnstr(WINDOW *win, char *str, int32_t n) // stub return(0); } +int32_t getch(void) +{ + fprintf(stderr,"unexpected and unsupported call to getch\n"); + return(0); +} + diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 12ab8b2be..53d928ad0 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -41,10 +41,12 @@ struct cursesd_info uint8_t screen[LINES][COLS]; int32_t x,y; }; -extern WINDOW *stdscr,*curscr; typedef struct cursesd_info WINDOW; +extern WINDOW *stdscr,*curscr; typedef char chtype; +int32_t getch(void); // stub + WINDOW *initscr(void); int32_t endwin(void); int32_t isendwin(void); @@ -138,6 +140,8 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define clearok(win,bf) 0 #define idlok(win,bf) 0 #define leaveok(win,bf) 0 +#define halfdelay(x) 0 +#define nocbreak() 0 #ifndef TRUE #define TRUE 1 diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index eb605385d..b709e8d3a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -544,9 +544,11 @@ tstp(int ignored) fflush(stdout); //wmove(curscr,oy,ox); #ifndef __APPLE__ +#ifndef BUILD_ROGUE curscr->_cury = oy; curscr->_curx = ox; #endif +#endif } /* diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f3f5572b2..a5ddf943f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -861,7 +861,7 @@ extern int cNWOOD; extern const char *metal[]; extern int cNMETAL; -extern WINDOW *stdscr,*curscr; +//extern WINDOW *stdscr,*curscr; #endif From db50762b5cd84439904e55d0f1d8515b84b24653 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:59:19 -1100 Subject: [PATCH 2179/3904] md_readchar --- src/cc/rogue/cursesd.c | 7 +++++++ src/cc/rogue/cursesd.h | 4 ++++ src/cc/rogue/mdport.c | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c89a713ae..c7a28fc62 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -17,6 +17,7 @@ static int32_t endwinflag; WINDOW *stdscr; +int32_t ESCDELAY; WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) { @@ -413,3 +414,9 @@ int32_t getch(void) return(0); } +int32_t md_readchar(void) +{ + fprintf(stderr,"unexpected and unsupported call to md_readchar\n"); + return(0); +} + diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 53d928ad0..4fa09e9d9 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -36,6 +36,8 @@ #include #include +#define ERR (-1) + struct cursesd_info { uint8_t screen[LINES][COLS]; @@ -43,9 +45,11 @@ struct cursesd_info }; typedef struct cursesd_info WINDOW; extern WINDOW *stdscr,*curscr; +extern int32_t ESCDELAY; typedef char chtype; int32_t getch(void); // stub +int32_t md_readchar(void); // stub WINDOW *initscr(void); int32_t endwin(void); diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 899f5d9db..841dffbb8 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -1081,6 +1081,7 @@ md_setsuspchar(int c) #define M_KEYPAD 2 #define M_TRAIL 3 +#ifndef BUILD_ROGUE int md_readchar() { @@ -1320,7 +1321,8 @@ md_readchar() return(ch & 0x7F); } - +#endif + #if defined(LOADAV) && defined(HAVE_NLIST_H) && defined(HAVE_NLIST) /* * loadav: From 0e79c0002e61f8597ffd0e047ea14b0864859c04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:03:09 -1100 Subject: [PATCH 2180/3904] Build cursesd.c --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8a5cd2185..77f6a21ac 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -496,6 +496,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #ifdef BUILD_ROGUE #include "rogue_rpc.cpp" +#include "rogue/cursesd.c" #include "rogue/vers.c" #include "rogue/extern.c" #include "rogue/armor.c" From 4a6e3550134ae0b1d04a86f4e2fdac2a9aa4b1f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:05:20 -1100 Subject: [PATCH 2181/3904] syntax --- src/cc/rogue/cursesd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c7a28fc62..d1975624c 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -103,7 +103,7 @@ int clrtoeol(void) int32_t waddch(WINDOW *win, chtype ch) { - int32_t t; + int32_t i; if ( ch == '\t' ) { for (i=0; i<8; i++) @@ -139,7 +139,7 @@ int32_t waddch(WINDOW *win, chtype ch) win->y = 0; } } - reurn(0); + return(0); } int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch) @@ -186,7 +186,7 @@ int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n { win->y = y; win->x = x; - return(waddnstr(win,str)); + return(waddnstr(win,str,n)); } int32_t addstr(const char *str) @@ -378,7 +378,7 @@ int leaveok(WINDOW *win, bool bf) } #endif -int32_t mvwin(WINDOW *win, int32_t y, int32_t x); // stub +int32_t mvwin(WINDOW *win, int32_t y, int32_t x) // stub { fprintf(stderr,"unexpected call to mvwin\n"); return(0); From 62e1966b14263fcb96ca95d36f4535bc70b514f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:05:58 -1100 Subject: [PATCH 2182/3904] Void --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index d1975624c..5bba65c95 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -282,7 +282,7 @@ int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol) return(0); } -void endwin() +void endwin(void) { if ( stdscr != 0 ) free(stdscr), stdscr = 0; From 3666f642e496ef9a2bc9d27e5514794bd19dcfc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:07:34 -1100 Subject: [PATCH 2183/3904] int32_t --- src/cc/rogue/cursesd.c | 51 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 5bba65c95..99274b86f 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -53,27 +53,27 @@ int32_t move(int32_t y, int32_t x) return(wmove(stdscr,y,x)); } -int werase(WINDOW *win) +int32_t werase(WINDOW *win) { memset(win->screen,' ',sizeof(win->screen)); return(0); } -int wclear(WINDOW *win) +int32_t wclear(WINDOW *win) { werase(win); clearok(win,TRUE); return(0); } -int wclrtoeol(WINDOW *win) +int32_t wclrtoeol(WINDOW *win) { if ( win->x < COLS-1 ) memset(&win->screen[win->y][win->x],' ',COLS - win->x); return(0); } -int wclrtobot(WINDOW *win) +int32_t wclrtobot(WINDOW *win) { wclrtoeol(win); if ( win->y < LINES-1 ) @@ -81,22 +81,22 @@ int wclrtobot(WINDOW *win) return(0); } -int erase(void) +int32_t erase(void) { return(werase(stdscr)); } -int clear(void) +int32_t clear(void) { return(wclear(stdscr)); } -int clrtobot(void) +int32_t clrtobot(void) { return(wclrtobot(stdscr)); } -int clrtoeol(void) +int32_t clrtoeol(void) { return(wclrtoeol(stdscr)); } @@ -282,47 +282,48 @@ int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol) return(0); } -void endwin(void) +int32_t endwin(void) { if ( stdscr != 0 ) free(stdscr), stdscr = 0; endwinflag = 1; + return(0); } -int isendwin(void) +int32_t isendwin(void) { return(endwinflag); } -int refresh(void) +int32_t refresh(void) { endwinflag = 0; return(wrefresh(stdscr)); } -int redrawwin(WINDOW *win) +int32_t redrawwin(WINDOW *win) { return(wrefresh(win)); } -int wredrawln(WINDOW *win, int beg_line, int num_lines) +int32_t wredrawln(WINDOW *win, int32_t beg_line, int32_t num_lines) { return(wrefresh(win)); } // functions with no data side effect #ifdef they_are_macros -int wrefresh(WINDOW *win) +int32_t wrefresh(WINDOW *win) { return(0); } -int wnoutrefresh(WINDOW *win) +int32_t wnoutrefresh(WINDOW *win) { return(0); } -int doupdate(void) +int32_t doupdate(void) { return(0); } @@ -332,17 +333,17 @@ int32_t touchwin(WINDOW *win) return(0); } -int standout(void) +int32_t standout(void) { return(0); } -int standend(void) +int32_t standend(void) { return(0); } -int raw(void) +int32_t raw(void) { return(0); } @@ -352,27 +353,27 @@ int32_t keypad(WINDOW *win, bool bf) return(0); } -int noecho(void) +int32_t noecho(void) { return(0); } -int flushinp(void) +int32_t flushinp(void) { return(0); } -int clearok(WINDOW *win, bool bf) +int32_t clearok(WINDOW *win, bool bf) { return(0); } -int idlok(WINDOW *win, bool bf) +int32_t idlok(WINDOW *win, bool bf) { return(0); } -int leaveok(WINDOW *win, bool bf) +int32_t leaveok(WINDOW *win, bool bf) { return(0); } @@ -384,7 +385,7 @@ int32_t mvwin(WINDOW *win, int32_t y, int32_t x) // stub return(0); } -WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x) +WINDOW *subwin(WINDOW *orig, int32_t nlines, int32_t ncols, int32_t begin_y, int32_t begin_x) { fprintf(stderr,"unexpected and unsupported call to subwin\n"); return(0); From d908ddc5a5bb97b63a62a8b6da45d3bebdf0ec58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:34:50 -1100 Subject: [PATCH 2184/3904] +print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4d6167b3f..ed69b6bc2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -459,7 +459,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint } if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used From acedc0026123f41a35bfd577f767f8d13e22ce03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:39:36 -1100 Subject: [PATCH 2185/3904] Dont save from daemon --- src/cc/rogue/save.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 15dda401e..b1cac8f8f 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -148,7 +148,9 @@ void save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) { char buf[80],fname[512]; int32_t i,n,nonz,histo[0x100]; FILE *fp; - memset(&rs->P,0,sizeof(rs->P)); + if ( rs->guiflag == 0 ) + return; + //memset(&rs->P,0,sizeof(rs->P)); mvcur(0, COLS - 1, LINES - 1, 0); putchar('\n'); endwin(); From dd68e9cdfeac3b0b7ddd838bd008b22d9b0bea8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:49:03 -1100 Subject: [PATCH 2186/3904] +print --- src/cc/rogue/cursesd.c | 1 + src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 99274b86f..e504a0ca4 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,6 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ed69b6bc2..44d42dff8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -459,7 +459,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint } if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used @@ -880,7 +880,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"error writing %s\n",fname); fclose(fp); } - num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,50); + num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i Date: Sun, 17 Feb 2019 02:53:02 -1100 Subject: [PATCH 2187/3904] Test --- src/cc/rogue/save.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index b1cac8f8f..af0ed37b6 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -148,19 +148,20 @@ void save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) { char buf[80],fname[512]; int32_t i,n,nonz,histo[0x100]; FILE *fp; - if ( rs->guiflag == 0 ) - return; - //memset(&rs->P,0,sizeof(rs->P)); - mvcur(0, COLS - 1, LINES - 1, 0); - putchar('\n'); - endwin(); - resetltchars(); - md_chmod(file_name, 0400); - if ( guiflag != 0 ) + if ( rs->guiflag != 0 ) { - encwrite(version, strlen(version)+1, savef); - sprintf(buf,"%d x %d\n", LINES, COLS); - encwrite(buf,80,savef); + //memset(&rs->P,0,sizeof(rs->P)); + mvcur(0, COLS - 1, LINES - 1, 0); + putchar('\n'); + endwin(); + resetltchars(); + md_chmod(file_name, 0400); + if ( guiflag != 0 ) + { + encwrite(version, strlen(version)+1, savef); + sprintf(buf,"%d x %d\n", LINES, COLS); + encwrite(buf,80,savef); + } } rs_save_file(rs,savef); n = sizeof(rs->P) - sizeof(rs->P.roguepack) + sizeof(rs->P.roguepack[0])*rs->P.packsize; From 35eb8d347a2404e15b1187de9a344553fc63df6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:57:06 -1100 Subject: [PATCH 2188/3904] Test speed --- src/cc/rogue/cursesd.c | 2 +- src/cc/rogue/rogue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index e504a0ca4..c9785c0d1 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b709e8d3a..ca2926c35 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -252,7 +252,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); - if ( 0 ) + if ( 1 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); sleep(2); From 4d1bfb8c862506993c14329f9fe5ff27b296d075 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 03:03:06 -1100 Subject: [PATCH 2189/3904] Test --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index ca2926c35..b709e8d3a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -252,7 +252,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); - if ( 1 ) + if ( 0 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); sleep(2); From bb03c1d872d6cb3a0174bb7bc8744d72b027938b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 17 Feb 2019 06:03:35 -0800 Subject: [PATCH 2190/3904] Update zeromq to 4.3.1 --- depends/packages/zeromq.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index b9a57cba7..0cb256e81 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -14,10 +14,10 @@ define $(package)_set_vars endef else package=zeromq -$(package)_version=4.2.1 -$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version) +$(package)_version=4.3.1 +$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/ $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=27d1e82a099228ee85a7ddb2260f40830212402c605a4a10b5e5498a7e0e9d03 +$(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb define $(package)_set_vars $(package)_config_opts=--without-documentation --disable-shared --disable-curve From d6309d063a8184e5d8f932f3615b1e7c9336b45d Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 17 Feb 2019 15:09:21 +0100 Subject: [PATCH 2191/3904] update zmq --- depends/packages/zeromq.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index b9a57cba7..ab3b95632 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -14,10 +14,10 @@ define $(package)_set_vars endef else package=zeromq -$(package)_version=4.2.1 +$(package)_version=4.3.1 $(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version) $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=27d1e82a099228ee85a7ddb2260f40830212402c605a4a10b5e5498a7e0e9d03 +$(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb define $(package)_set_vars $(package)_config_opts=--without-documentation --disable-shared --disable-curve From 5c6ca4c2915a2593aa86c0466881b857545d0c05 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 17 Feb 2019 15:15:17 +0100 Subject: [PATCH 2192/3904] update ZMQ --- depends/packages/zeromq.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index ab3b95632..57806f50e 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -1,9 +1,9 @@ ifeq ($(host_os),mingw32) -$(package)_version=4.2.2-1 +$(package)_version=4.3.1 $(package)_download_path=https://github.com/ca333/libzmq/archive $(package)_download_file=v$($(package)_version).tar.gz $(package)_file_name=libzmq-$($(package)_version).tar.gz -$(package)_sha256_hash=0e225b85ce11be23bf7eb7d3f25c6686728bf30d5c31f61c12d37bb646c69962 +$(package)_sha256_hash=cb8ebe5b60dadeb526745610d6237f05a98aba287114d8991dad1fa14f4be354 define $(package)_set_vars $(package)_build_env+= From 4f5ba23dfcf01bd3d272da05a004b60af3a8b40e Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 17 Feb 2019 16:05:19 +0100 Subject: [PATCH 2193/3904] set static ZMQ flag --- depends/packages/zeromq.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 57806f50e..b7b352f12 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -9,7 +9,7 @@ define $(package)_set_vars $(package)_build_env+= $(package)_config_opts=--enable-shared=false --enable-static --host=x86_64-w64-mingw32 $(package)_config_opts_mingw32=--enable-shared=false --enable-static --host=x86_64-w64-mingw32 - $(package)_cflags=-Wno-error -Wall -Wno-pedantic-ms-format -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lws2_32 -liphlpapi -lrpcrt4 + $(package)_cflags=-Wno-error -Wall -Wno-pedantic-ms-format -DZMQ_STATIC -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lws2_32 -liphlpapi -lrpcrt4 $(package)_conf_tool=./configure endef else @@ -31,7 +31,8 @@ define $(package)_preprocess_cmds cd $($(package)_build_subdir); ./autogen.sh endef define $(package)_config_cmds - $($(package)_conf_tool) $($(package)_config_opts) CFLAGS="-Wno-error -Wall -Wno-pedantic-ms-format -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lws2_32 -liphlpapi -lrpcrt4" + $($(package)_conf_tool) $($(package)_config_opts) + CFLAGS="-Wno-error -Wall -Wno-pedantic-ms-format -DZMQ_STATIC -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lzmq -lws2_32 -liphlpapi -lrpcrt4" endef else define $(package)_config_cmds From ec95ae2d65c11e821f8f41878d48ea249e9b02d4 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 17 Feb 2019 17:14:18 +0100 Subject: [PATCH 2194/3904] remove ZMQ from WIN --- depends/packages/packages.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 5bc8fcda6..624079b91 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -49,6 +49,6 @@ wallet_packages=bdb ifeq ($(host_os),linux) packages := boost openssl libevent zeromq $(zcash_packages) googletest #googlemock else - packages := boost openssl libevent zeromq $(zcash_packages) libcurl googletest #googlemock + packages := boost openssl libevent $(zcash_packages) libcurl googletest #googlemock endif From d16b2dd1bf68d50c69b497b8dda4b0a2fb1d0d05 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 05:56:17 -1100 Subject: [PATCH 2195/3904] Test --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c9785c0d1..e504a0ca4 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - //fprintf(stderr,"%s\n",str); + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From 9c8ebf3f6279614516e32cbb5ee65c8a92aa2721 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:04:59 -1100 Subject: [PATCH 2196/3904] Flush always --- src/cc/rogue/rogue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b709e8d3a..f28d0df29 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -336,7 +336,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } fclose(fp); } - rogue_replay2(0,seed,keystrokes,num,player,150); + rogue_replay2(0,seed,keystrokes,num,player,30); //mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); @@ -601,7 +601,7 @@ playit(struct rogue_state *rs) } else { - if ( rs->needflush != 0 && rs->num > 4096 ) + if ( rs->needflush != 0 )//&& rs->num > 4096 ) { if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; From e5865055252d9c5683e99de8d1bb81afd9f13052 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:18:52 -1100 Subject: [PATCH 2197/3904] +proint --- src/cc/rogue/state.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index e738a9d16..8b312ae5f 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1434,7 +1434,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) item = &rs->P.roguepack[rs->P.packsize]; if ( pstats.s_hpt <= 0 ) { - //fprintf(stderr,"KILLED\n"); + fprintf(stderr,"KILLED\n"); rs->P.gold = -1; rs->P.hitpoints = -1; rs->P.strength = -1; @@ -1452,9 +1452,9 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - //fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } - //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); + fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) { packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); @@ -2009,7 +2009,10 @@ int rs_save_file(struct rogue_state *rs,FILE *savef) { if (write_error) + { + fprintf(stderr,"write error\n"); return(WRITESTAT); + } rs_write_boolean(savef, after); /* 1 */ /* extern.c */ rs_write_boolean(savef, again); /* 2 */ From af9ff2e6204f6432fca42010fc564b4dc7b43c32 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 17 Feb 2019 18:20:57 +0100 Subject: [PATCH 2198/3904] update zeromq --- depends/packages/zeromq.mk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index b7b352f12..89fb6ef1c 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -8,8 +8,8 @@ $(package)_sha256_hash=cb8ebe5b60dadeb526745610d6237f05a98aba287114d8991dad1fa14 define $(package)_set_vars $(package)_build_env+= $(package)_config_opts=--enable-shared=false --enable-static --host=x86_64-w64-mingw32 - $(package)_config_opts_mingw32=--enable-shared=false --enable-static --host=x86_64-w64-mingw32 - $(package)_cflags=-Wno-error -Wall -Wno-pedantic-ms-format -DZMQ_STATIC -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lws2_32 -liphlpapi -lrpcrt4 + $(package)_config_opts_mingw32=--enable-shared=false --enable-static --prefix=$(host_prefix) --host=x86_64-w64-mingw32 -disable-curve + $(package)_cflags=-Wno-error -Wall -Wno-pedantic-ms-format -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lws2_32 -liphlpapi -lrpcrt4 $(package)_conf_tool=./configure endef else @@ -31,8 +31,7 @@ define $(package)_preprocess_cmds cd $($(package)_build_subdir); ./autogen.sh endef define $(package)_config_cmds - $($(package)_conf_tool) $($(package)_config_opts) - CFLAGS="-Wno-error -Wall -Wno-pedantic-ms-format -DZMQ_STATIC -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lzmq -lws2_32 -liphlpapi -lrpcrt4" + $($(package)_conf_tool) $($(package)_config_opts) CFLAGS="-Wno-error -Wall -Wno-pedantic-ms-format -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lws2_32 -liphlpapi -lrpcrt4" endef else define $(package)_config_cmds From 7d50f06c7613cf74f56d23768919c7f52b114922 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 17 Feb 2019 18:21:18 +0100 Subject: [PATCH 2199/3904] add ZMQ to WIN --- depends/packages/packages.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 624079b91..5bc8fcda6 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -49,6 +49,6 @@ wallet_packages=bdb ifeq ($(host_os),linux) packages := boost openssl libevent zeromq $(zcash_packages) googletest #googlemock else - packages := boost openssl libevent $(zcash_packages) libcurl googletest #googlemock + packages := boost openssl libevent zeromq $(zcash_packages) libcurl googletest #googlemock endif From 9cec68f8c49833a6143eabf2a9b58858847321f1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:25:24 -1100 Subject: [PATCH 2200/3904] +prints --- src/cc/rogue/rogue.c | 1 + src/cc/rogue/rogue.h | 4 ++-- src/cc/rogue/save.c | 8 +++++--- src/cc/rogue/state.c | 3 ++- src/cc/rogue_rpc.cpp | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f28d0df29..2fd50607a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -273,6 +273,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(rs,fp,0); + fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index a5ddf943f..20f32c6f2 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -358,7 +358,7 @@ typedef union _bits256 bits256; #endif -#ifndef ROGUE_DECLARED_PACK +/*#ifndef ROGUE_DECLARED_PACK struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; @@ -369,7 +369,7 @@ struct rogue_player int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; -#define ROGUE_DECLARED_PACK +#define ROGUE_DECLARED_PACK*/ #endif struct rogue_state diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index af0ed37b6..0496eaa73 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -150,7 +150,6 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) char buf[80],fname[512]; int32_t i,n,nonz,histo[0x100]; FILE *fp; if ( rs->guiflag != 0 ) { - //memset(&rs->P,0,sizeof(rs->P)); mvcur(0, COLS - 1, LINES - 1, 0); putchar('\n'); endwin(); @@ -163,7 +162,10 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) encwrite(buf,80,savef); } } - rs_save_file(rs,savef); + memset(&rs->P,0,sizeof(rs->P)); + rs_save_file(rs,savef); // sets rs->P + fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d %d\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel); + n = sizeof(rs->P) - sizeof(rs->P.roguepack) + sizeof(rs->P.roguepack[0])*rs->P.packsize; memset(histo,0,sizeof(histo)); for (i=0; iplayerdata[i] = ((uint8_t *)&rs->P)[i]; } rs->playersize = n; - //fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n); + fprintf(stderr," packsize.%d playersize.%d\n",rs->P.packsize,n); if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 ) { fwrite(&rs->P,1,n,fp); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 8b312ae5f..d1ceaaa2f 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1452,7 +1452,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) @@ -1460,6 +1460,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); rs->P.packsize++; } + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } } rs_write_marker(savef, RSID_OBJECT); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 44d42dff8..7b26ff572 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -23,6 +23,7 @@ #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 + #define MAXPACK 23 struct rogue_packitem { From 2ee3594c1b0da6c8596be7f7f37d5afd0e422ec4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:27:05 -1100 Subject: [PATCH 2201/3904] Test --- src/cc/rogue/rogue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 20f32c6f2..a5ddf943f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -358,7 +358,7 @@ typedef union _bits256 bits256; #endif -/*#ifndef ROGUE_DECLARED_PACK +#ifndef ROGUE_DECLARED_PACK struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; @@ -369,7 +369,7 @@ struct rogue_player int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; -#define ROGUE_DECLARED_PACK*/ +#define ROGUE_DECLARED_PACK #endif struct rogue_state From fa7ad1f44bbc418ac2644f589844fb1f329af368 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:32:17 -1100 Subject: [PATCH 2202/3904] Test --- src/cc/rogue/cursesd.c | 2 +- src/cc/rogue/save.c | 4 ++-- src/cc/rogue/state.c | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index e504a0ca4..c9785c0d1 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 0496eaa73..4df79e150 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -164,7 +164,7 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) } memset(&rs->P,0,sizeof(rs->P)); rs_save_file(rs,savef); // sets rs->P - fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d %d\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel); + //fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d %d\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel); n = sizeof(rs->P) - sizeof(rs->P.roguepack) + sizeof(rs->P.roguepack[0])*rs->P.packsize; memset(histo,0,sizeof(histo)); @@ -175,7 +175,7 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) rs->playerdata[i] = ((uint8_t *)&rs->P)[i]; } rs->playersize = n; - fprintf(stderr," packsize.%d playersize.%d\n",rs->P.packsize,n); + //fprintf(stderr," packsize.%d playersize.%d\n",rs->P.packsize,n); if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 ) { fwrite(&rs->P,1,n,fp); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index d1ceaaa2f..800622444 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1434,7 +1434,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) item = &rs->P.roguepack[rs->P.packsize]; if ( pstats.s_hpt <= 0 ) { - fprintf(stderr,"KILLED\n"); + //fprintf(stderr,"KILLED\n"); rs->P.gold = -1; rs->P.hitpoints = -1; rs->P.strength = -1; @@ -1452,15 +1452,14 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); + //fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } - fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); + //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) { packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); rs->P.packsize++; } - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } } rs_write_marker(savef, RSID_OBJECT); From 64d18650222bff6079d0f8e1ddd36224225d7a60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:34:57 -1100 Subject: [PATCH 2203/3904] rogue_player.h --- src/cc/rogue/rogue.h | 15 +-------------- src/cc/rogue/rogue_player.h | 35 +++++++++++++++++++++++++++++++++++ src/cc/rogue_rpc.cpp | 17 +---------------- 3 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 src/cc/rogue/rogue_player.h diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index a5ddf943f..905a5ed36 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -357,20 +357,7 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif - -#ifndef ROGUE_DECLARED_PACK -struct rogue_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; -struct rogue_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; - struct rogue_packitem roguepack[MAXPACK]; -}; -#define ROGUE_DECLARED_PACK -#endif +#include "rogue_player.h" // interface to rpc struct rogue_state { diff --git a/src/cc/rogue/rogue_player.h b/src/cc/rogue/rogue_player.h new file mode 100644 index 000000000..1319b3213 --- /dev/null +++ b/src/cc/rogue/rogue_player.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#ifndef ROGUE_DECLARED_PACK +#define ROGUE_DECLARED_PACK + + +#define MAXPACK 23 +struct rogue_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; +struct rogue_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; + struct rogue_packitem roguepack[MAXPACK]; +}; +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); +void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); + +#endif + diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7b26ff572..253f3ec89 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -23,22 +23,7 @@ #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 - -#define MAXPACK 23 -struct rogue_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; -struct rogue_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; - struct rogue_packitem roguepack[MAXPACK]; -}; -int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); -#define ROGUE_DECLARED_PACK -void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); - +#include "rogue/rogueplayer.h" std::string Rogue_pname = ""; From 0d022d48145c19964ea5889138934b824c2937f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:35:36 -1100 Subject: [PATCH 2204/3904] _ --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 253f3ec89..e297f6a27 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -23,7 +23,7 @@ #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 -#include "rogue/rogueplayer.h" +#include "rogue/rogue_player.h" std::string Rogue_pname = ""; From 82a43da6ec36fceefce05a21872cd64d447e5680 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 07:17:08 -1100 Subject: [PATCH 2205/3904] Print extracted string --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e297f6a27..032a99ea9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -720,7 +720,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) playertxid = juint256(jitem(params,1)); if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); - if ( tokenid != zeroid ) + if ( tokenid != zeroid ) // if it is tokentransfer this will be 0 vout = 1; } rogue_univalue(result,0,maxplayers,buyin); @@ -814,7 +814,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("status","success")); @@ -878,7 +878,8 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + sprintf(str,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + result.push_back(Pair("extracted",str)); if ( keystrokes != 0 ) free(keystrokes); } else num = 0; From 72e86ef16ef542b2e754aafd4011cf661d24166d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 07:23:10 -1100 Subject: [PATCH 2206/3904] Test --- src/cc/rogue_rpc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 032a99ea9..25b279f61 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -812,6 +812,8 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } +// change to subfunction without JSON to be used by other functions + UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; @@ -878,8 +880,9 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - sprintf(str,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); result.push_back(Pair("extracted",str)); + fprintf(stderr,"%s\n",str); if ( keystrokes != 0 ) free(keystrokes); } else num = 0; From b95214f57e411a114322b251b17822be4c81de61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 07:43:08 -1100 Subject: [PATCH 2207/3904] - -lncurses --- src/Makefile.am | 4 ++-- src/cc/rogue_rpc.cpp | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 1881f0a90..53331ee8f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -574,9 +574,9 @@ komodod_LDADD += \ $(LIBZCASH_LIBS) if TARGET_DARWIN -komodod_LDADD += libcc.dylib -lncurses +komodod_LDADD += libcc.dylib # -lncurses else -komodod_LDADD += libcc.so -lncurses +komodod_LDADD += libcc.so # -lncurses endif diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 25b279f61..3ad5766a9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -120,9 +120,9 @@ std::string Rogue_pname = ""; */ // todo: -// verify keystrokes tx is in mempool and confirmed -// chaining when mempool tx sometimes infinite loops? -// bailout stealing, is it possible? +// add some more conditions to multiplayer +// change rogue_extract to subfunction without JSON to be used by other functions +// how does it work with playertxid instead of pubkey //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -812,8 +812,6 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -// change to subfunction without JSON to be used by other functions - UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; From d41134cb97a1e00d0b81586eda74df5f8a0f7836 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 18 Feb 2019 00:03:48 +0500 Subject: [PATCH 2208/3904] token marker moved to vout tokeninfo validates vouts --- src/cc/CCtokens.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index e5b9eeb78..d5fffdf5b 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -907,10 +907,12 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st if( nonfungibleData.size() > 0 ) destEvalCode = nonfungibleData.begin()[0]; + // NOTE: we should prevent spending fake-tokens from this marker in IsTokenvout(): + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to token cc addr, burnable and validated, vout pos now changed to 0 (from 1) mtx.vout.push_back(MakeTokensCC1vout(destEvalCode, tokensupply, mypk)); //mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); // old marker (non-burnable because spending could not be validated) - // NOTE: we should prevent spending fake-tokens from this marker in IsTokenvout(): - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to token cc addr, burnable and validated, this vout must be=1 + //mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // ...moved to vout=0 for matching with rogue-game token + return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } @@ -1007,8 +1009,11 @@ UniValue TokenInfo(uint256 tokenid) std::vector origpubkey; std::vector vopretNonfungible; std::string name, description; + struct CCcontract_info *cpTokens, tokensCCinfo; - if (GetTransaction(tokenid, vintx, hashBlock, false) == 0) + cpTokens = CCinit(&tokensCCinfo, EVAL_TOKENS); + + if( !GetTransaction(tokenid, vintx, hashBlock, false) ) { fprintf(stderr, "TokenInfo() cant find tokenid\n"); result.push_back(Pair("result", "error")); @@ -1020,17 +1025,23 @@ UniValue TokenInfo(uint256 tokenid) LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); result.push_back(Pair("result", "error")); result.push_back(Pair("error", "tokenid isnt token creation txid")); + return result; } result.push_back(Pair("result", "success")); result.push_back(Pair("tokenid", tokenid.GetHex())); result.push_back(Pair("owner", HexStr(origpubkey))); result.push_back(Pair("name", name)); - result.push_back(Pair("supply", vintx.vout[0].nValue)); + + int64_t supply = 0, output; + for (int v = 0; v < vintx.vout.size() - 1; v++) + if ((output = IsTokensvout(false, true, cpTokens, NULL, vintx, v, tokenid)) > 0) + supply += output; + result.push_back(Pair("supply", supply)); result.push_back(Pair("description", description)); if( !vopretNonfungible.empty() ) result.push_back(Pair("data", HexStr(vopretNonfungible))); - return(result); + return result; } UniValue TokenList() From 2fc487d21339eeb8ba17a3022893bcffab06986e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 08:10:40 -1100 Subject: [PATCH 2209/3904] Fix undefined --- src/cc/rogue/cursesd.c | 2 +- src/cc/rogue/mdport.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c9785c0d1..02a80c470 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -16,7 +16,7 @@ #include "cursesd.h" static int32_t endwinflag; -WINDOW *stdscr; +WINDOW *stdscr,*curscr; int32_t ESCDELAY; WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 841dffbb8..d72c4097a 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -263,12 +263,12 @@ int md_hasclreol() { #if defined(clr_eol) -#ifdef NCURSES_VERSION +/*#ifdef NCURSES_VERSION if (cur_term == NULL) return(0); //if (cur_term->type.Strings == NULL) return(0); -#endif +#endif*/ return((clr_eol != NULL) && (*clr_eol != 0)); #elif defined(__PDCURSES__) return(TRUE); From 54c7943a38b43b37acd2f7fafa2a33a58a47d99c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 08:16:52 -1100 Subject: [PATCH 2210/3904] Return 0 --- src/cc/rogue/mdport.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index d72c4097a..9d6c7d2c6 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -262,19 +262,20 @@ md_onsignal_autosave() int md_hasclreol() { -#if defined(clr_eol) -/*#ifdef NCURSES_VERSION +/*#if defined(clr_eol) +#ifdef NCURSES_VERSION if (cur_term == NULL) return(0); //if (cur_term->type.Strings == NULL) return(0); -#endif*/ +#endif return((clr_eol != NULL) && (*clr_eol != 0)); #elif defined(__PDCURSES__) return(TRUE); #else return((CE != NULL) && (*CE != 0)); -#endif +#endif*/ + return(0); } void From f641b7c31d6603e597d8c3217d1b383ea3fb3edc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 08:56:48 -1100 Subject: [PATCH 2211/3904] Guard null name --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3ad5766a9..309602c2c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -389,7 +389,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); obj.push_back(Pair("chain",symbol)); - obj.push_back(Pair("pname",pname)); + obj.push_back(Pair("pname",pname.size() > 0 ? pname : "noname")); return(obj); } From 9fda3717842d971cbf444e2fa3114449da7c9869 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:00:14 -1100 Subject: [PATCH 2212/3904] Test --- src/cc/rogue_rpc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 309602c2c..c9d873656 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -388,8 +388,10 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); - obj.push_back(Pair("chain",symbol)); - obj.push_back(Pair("pname",pname.size() > 0 ? pname : "noname")); + if ( symbol.c_str() != 0 ) + obj.push_back(Pair("chain",symbol.c_str())); + if ( pname.c_str() != 0 ) + obj.push_back(Pair("pname",pname._cstr())); return(obj); } From 5fd1874cb363d14383c88d4ad3a4af2568857590 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:00:51 -1100 Subject: [PATCH 2213/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c9d873656..1db0d51f1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -391,7 +391,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint if ( symbol.c_str() != 0 ) obj.push_back(Pair("chain",symbol.c_str())); if ( pname.c_str() != 0 ) - obj.push_back(Pair("pname",pname._cstr())); + obj.push_back(Pair("pname",pname.c_str())); return(obj); } From 73fa543afa9495de92b250655def5c3613620134 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:04:16 -1100 Subject: [PATCH 2214/3904] Test --- src/cc/rogue_rpc.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1db0d51f1..41e40edb4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -357,7 +357,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname) { - int32_t i; struct rogue_player P; char packitemstr[512],*datastr; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); + int32_t i; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -379,8 +379,11 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint if ( tokenid != zeroid ) obj.push_back(Pair("tokenid",tokenid.GetHex())); else obj.push_back(Pair("tokenid",playertxid.GetHex())); - obj.push_back(Pair("data",datastr)); - free(datastr); + if ( datastr != 0 ) + { + obj.push_back(Pair("data",datastr)); + free(datastr); + } obj.push_back(Pair("pack",a)); obj.push_back(Pair("packsize",(int64_t)P.packsize)); obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); @@ -388,10 +391,8 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); - if ( symbol.c_str() != 0 ) - obj.push_back(Pair("chain",symbol.c_str())); - if ( pname.c_str() != 0 ) - obj.push_back(Pair("pname",pname.c_str())); + obj.push_back(Pair("chain",symbol)); + obj.push_back(Pair("pname",pname)); return(obj); } From 88fa8f223315f802c93cdf0025a09ad95d5204d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:09:52 -1100 Subject: [PATCH 2215/3904] Test --- src/cc/rogue_rpc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 41e40edb4..1e6d3111d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -798,8 +798,11 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { + result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) { + result.push_back(Pair("batontxid",batontxid.GetHex())); + result.push_back(Pair("playertxid",playertxid.GetHex())); if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); From 8a9687d2550cd1f46bb707fd2f23683a8a9ca0e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:12:08 -1100 Subject: [PATCH 2216/3904] Dont keystrokes tx more than once per 1024 --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 2fd50607a..01c8b1873 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -602,7 +602,7 @@ playit(struct rogue_state *rs) } else { - if ( rs->needflush != 0 )//&& rs->num > 4096 ) + if ( rs->needflush != 0 && rs->num > 1024 ) { if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; From 5391c8ca87f3c5ff564c58ef31ec210fbdb383e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:28:54 -1100 Subject: [PATCH 2217/3904] Keystrokesstr --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1e6d3111d..4fec21b5a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -123,6 +123,7 @@ std::string Rogue_pname = ""; // add some more conditions to multiplayer // change rogue_extract to subfunction without JSON to be used by other functions // how does it work with playertxid instead of pubkey +// keystrokes retry //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -792,13 +793,14 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + result.push_back(Pair("keystrokes",keystrokestr)); keystrokes = ParseHex(keystrokestr); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { - result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) { result.push_back(Pair("batontxid",batontxid.GetHex())); From 5325bf6507ff34928a83193b128e26e4a33223e5 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 00:05:24 +0100 Subject: [PATCH 2218/3904] add Makefile for rogue multiOS supported Makefile --- src/cc/Makefile_rogue | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/cc/Makefile_rogue diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue new file mode 100644 index 000000000..7fb3f799f --- /dev/null +++ b/src/cc/Makefile_rogue @@ -0,0 +1,37 @@ +SHELL = /bin/sh +CC = gcc +CC_DARWIN = g++-6 +CC_WIN = x86_64-w64-mingw32-gcc-posix +CFLAGS_DARWIN = -DBUILD_ROGUE -std=c++11 -arch x86_64 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib +CFLAGS = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared +CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared +DEBUGFLAGS = -O0 -D _DEBUG +RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program +$(info $(OS)) +OS := $(shell uname -s) +$(info $(OS)) +TARGET = librogue.so +TARGET_DARWIN = librogue.dylib +TARGET_WIN = librogue.dll +SOURCES = cclib.cpp +#HEADERS = $(shell echo ../cryptoconditions/include/*.h) -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ + +all: $(TARGET) + +$(TARGET): $(SOURCES) + $(info Building cclib to src/) +ifeq ($(OS),Darwin) + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) -c $(SOURCES) -lncurses + cp $(TARGET_DARWIN) ../libcc.dylib +else ifeq ($(OS),Linux) + $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) -lncurses + cp $(TARGET) ../libcc.so +#else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host +else + $(info WINDOWS) + $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) -lncurses + cp $(TARGET_WIN) ../libcc.dll +endif + +clean: + rm -rf $(TARGET) From 9eb16504de6a35e5a31792954cb266bf96d37912 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 00:08:03 +0100 Subject: [PATCH 2219/3904] update makerogue --- src/cc/makerogue | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 249e646f5..3b47638e9 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,8 +1,5 @@ #!/bin/sh cd rogue; -./configure # only need this first time +./configure make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so -cp librogue.so ../libcc.so - +make -f Makefile_rogue From c5b8640d9dde49a4b5b7706c545c1afb4eebb7ce Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 00:15:35 +0100 Subject: [PATCH 2220/3904] update OSX makefile --- zcutil/build-mac.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index a3619111f..df4efd05f 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -47,14 +47,7 @@ make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 WD=$PWD cd src/cc echo $PWD - -if make "$@"; then - echo CCLIB BUILD SUCCESSFUL -else - echo CCLIB BUILD FAILED - exit 1 -fi - +./makerogue cd $WD ./autogen.sh From cfa13caa4c1fe9cddc3c1b267d19e69da37257c1 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 00:16:20 +0100 Subject: [PATCH 2221/3904] update makerogue --- src/cc/makerogue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 3b47638e9..a38eab6a4 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -2,4 +2,10 @@ cd rogue; ./configure make; cd .. -make -f Makefile_rogue + +if make -f Makefile_rogue "$@"; then + echo ROGUE BUILD SUCCESSFUL +else + echo ROGUE BUILD FAILED + exit 1 +fi From 6de80465b5dea552ac478a9162db961774d7726d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:06:22 -1100 Subject: [PATCH 2222/3904] Extract game function --- src/cc/rogue_rpc.cpp | 116 ++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4fec21b5a..54aad1326 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -121,7 +121,6 @@ std::string Rogue_pname = ""; // todo: // add some more conditions to multiplayer -// change rogue_extract to subfunction without JSON to be used by other functions // how does it work with playertxid instead of pubkey // keystrokes retry @@ -820,12 +819,67 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } +char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,int64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +{ + CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; + roguepk = GetUnspendable(cp,0); + *numkeysp = 0; + seed = 0; + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + { + if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) + { + UniValue obj; + seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i no playerdata\n"); + newdata.resize(0); + } + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel,n,(int32_t)sizeof(endP)); + fprintf(stderr,"%s\n",str); + } else num = 0; + } + } + *numkeysp = numkeys; + return(keystrokes); +} + UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); - result.push_back(Pair("status","success")); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -845,57 +899,19 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + if ( (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) { - if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) - { - UniValue obj; struct rogue_player P; - seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); - memset(&P,0,sizeof(P)); - if ( playerdata.size() > 0 ) - { - for (i=0; i no playerdata\n"); - newdata.resize(0); - } - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); - result.push_back(Pair("extracted",str)); - fprintf(stderr,"%s\n",str); - if ( keystrokes != 0 ) - free(keystrokes); - } else num = 0; - } + result.push_back(Pair("status","success")); + flag = 1; + result.push_back(Pair("extracted",str)); + result.push_back(Pair("numkeys",(int64_t)numkeys)); + result.push_back(Pair("seed",(int64_t)seed)); + free(keystrokes); } } } + if ( flag == 0 ) + result.push_back(Pair("status","error")); return(result); } From e06149dc5617971911651a796de137de3423ad22 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:08:12 -1100 Subject: [PATCH 2223/3904] Syntax --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 54aad1326..b8a816158 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -866,7 +866,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel,n,(int32_t)sizeof(endP)); + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); } else num = 0; } @@ -877,7 +877,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; struct rogue_player P,endP; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); From 51e251ff220885c51c1a10536f9b56faf219bca3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:09:15 -1100 Subject: [PATCH 2224/3904] uint64_t seed --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b8a816158..087567df5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -819,7 +819,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,int64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; roguepk = GetUnspendable(cp,0); From 274bbfb0c8e8fa9e4e36ca139ac3b2f7164442e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:12:42 -1100 Subject: [PATCH 2225/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 087567df5..144692404 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -899,7 +899,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; From 99ea9f366ea5e7e90344376fa119148bc814163d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:14:29 -1100 Subject: [PATCH 2226/3904] Huh? --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 144692404..1a364dd53 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -877,12 +877,12 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; struct rogue_player P,endP; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; struct rogue_player P,endP; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { From 35110a993c489477b6a2ae148c08bb8f8b18d52c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:18:06 -1100 Subject: [PATCH 2227/3904] Test --- src/cc/rogue_rpc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1a364dd53..eb13d0a41 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -819,9 +819,9 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { - CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; + CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; @@ -877,11 +877,12 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; struct rogue_player P,endP; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); + fprintf(stderr,"inside rogue extract\n"); if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) @@ -899,7 +900,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; From 93f7c80bce2128f546a5320ac055b37c2c437e21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:20:03 -1100 Subject: [PATCH 2228/3904] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index eb13d0a41..5f7fb233f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -883,7 +883,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); fprintf(stderr,"inside rogue extract\n"); - if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) + /* if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { @@ -910,7 +910,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) free(keystrokes); } } - } + }*/ if ( flag == 0 ) result.push_back(Pair("status","error")); return(result); From 0ad53817bf541f2e3f2db081d4ac5bc75f035ec7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:22:29 -1100 Subject: [PATCH 2229/3904] Test --- src/cc/rogue_rpc.cpp | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5f7fb233f..9c6ab7152 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -876,6 +876,45 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat } UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; + std::vector > addressIndex; + //std::vector > unspentOutputs; + roguepk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,coinaddr,roguepk,mypk); + //SetCCunspents(unspentOutputs,coinaddr); + SetCCtxids(addressIndex,coinaddr); + rogue_univalue(result,"extract",-1,-1); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( vout == 0 ) + { + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) + { + if ( CCgettxout(txid,vout,1) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); + } + } + } + } + } + result.push_back(Pair("pastgames",b)); + result.push_back(Pair("games",a)); + result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); + return(result); +} + +UniValue realrogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); @@ -883,7 +922,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); fprintf(stderr,"inside rogue extract\n"); - /* if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) + if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { @@ -900,7 +939,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; @@ -910,7 +949,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) free(keystrokes); } } - }*/ + } if ( flag == 0 ) result.push_back(Pair("status","error")); return(result); From 7572af1ac9e250c8e89bee702ae7e2c5dcef1165 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:24:45 -1100 Subject: [PATCH 2230/3904] (UniValue::VOBJ) --- src/cc/rogue_rpc.cpp | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9c6ab7152..6101eead4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -877,51 +877,11 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; - std::vector > addressIndex; - //std::vector > unspentOutputs; - roguepk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - GetCCaddress1of2(cp,coinaddr,roguepk,mypk); - //SetCCunspents(unspentOutputs,coinaddr); - SetCCtxids(addressIndex,coinaddr); - rogue_univalue(result,"extract",-1,-1); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( vout == 0 ) - { - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) - { - if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) - { - if ( CCgettxout(txid,vout,1) < 0 ) - b.push_back(gametxid.GetHex()); - else a.push_back(gametxid.GetHex()); - } - } - } - } - } - result.push_back(Pair("pastgames",b)); - result.push_back(Pair("games",a)); - result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); - return(result); -} - -UniValue realrogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; + UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); - fprintf(stderr,"inside rogue extract\n"); if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) From ca219e38ad00ea27912b998aff294b698c6042b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:26:46 -1100 Subject: [PATCH 2231/3904] Test --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6101eead4..240d74752 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -899,6 +899,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); + return(result); if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); From 98947db212f7fd17b59a5651d87dbc7361fa31e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:28:34 -1100 Subject: [PATCH 2232/3904] Test --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 240d74752..8f39b3d5e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -899,14 +899,14 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - return(result); + str[0] = 0; if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; result.push_back(Pair("extracted",str)); - result.push_back(Pair("numkeys",(int64_t)numkeys)); - result.push_back(Pair("seed",(int64_t)seed)); + //result.push_back(Pair("numkeys",(int64_t)numkeys)); + //result.push_back(Pair("seed",(int64_t)seed)); free(keystrokes); } } From 0a849f55b90626ffd9c3f376c3b961f4966e9bf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:31:06 -1100 Subject: [PATCH 2233/3904] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8f39b3d5e..5fa964407 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -905,8 +905,8 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("status","success")); flag = 1; result.push_back(Pair("extracted",str)); - //result.push_back(Pair("numkeys",(int64_t)numkeys)); - //result.push_back(Pair("seed",(int64_t)seed)); + result.push_back(Pair("numkeys",(int64_t)numkeys)); + result.push_back(Pair("seed",(int64_t)seed)); free(keystrokes); } } From afc2c11591636aed86a9c3ab396b6f19a8a59592 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:39:10 -1100 Subject: [PATCH 2234/3904] Slseepmillis --- src/cc/cclib.cpp | 2 +- src/cc/rogue/main.c | 2 +- src/cc/rogue/rogue.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 77f6a21ac..f2f13837c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -76,7 +76,7 @@ CClib_methods[] = std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); #ifdef BUILD_ROGUE -int32_t rogue_replay(uint64_t seed,int32_t sleeptime); +int32_t rogue_replay(uint64_t seed,int32_t sleepmillis); bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 12e6af368..c0fa36752 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -253,7 +253,7 @@ int main(int argc, char **argv, char **envp) { seed = atol(argv[1]); //fprintf(stderr,"replay %llu\n",(long long)seed); - return(rogue_replay(seed,50000)); + return(rogue_replay(seed,10)); } else { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 01c8b1873..516100906 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -337,7 +337,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } fclose(fp); } - rogue_replay2(0,seed,keystrokes,num,player,30); + rogue_replay2(0,seed,keystrokes,num,player,sleeptime); //mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); From 02794ea8641936484dd4df859524ba6886939d4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:39:51 -1100 Subject: [PATCH 2235/3904] Replay --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5fa964407..318567383 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -907,6 +907,8 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("extracted",str)); result.push_back(Pair("numkeys",(int64_t)numkeys)); result.push_back(Pair("seed",(int64_t)seed)); + sprintf(str,"cc/rogue/rogue %llu",(long long)seed); + result.push_back(Pair("replay",str)); free(keystrokes); } } From 5793bef688561caa644d528e2830c88df4c149b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:46:37 -1100 Subject: [PATCH 2236/3904] playertxid --- src/cc/rogue_rpc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 318567383..93baaa44b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -819,9 +819,9 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { - CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; + CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; @@ -877,7 +877,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; + UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); @@ -900,10 +900,11 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); str[0] = 0; - if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; + result.push_back(Pair("playertxid",playertxid.GetHex())); result.push_back(Pair("extracted",str)); result.push_back(Pair("numkeys",(int64_t)numkeys)); result.push_back(Pair("seed",(int64_t)seed)); From 156e9057d088b127f10be4da2d99797840b017e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:52:01 -1100 Subject: [PATCH 2237/3904] Require registration within ROGUE_MAXKEYSTROKESGAP --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 93baaa44b..de91eef19 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -726,6 +726,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( tokenid != zeroid ) // if it is tokentransfer this will be 0 vout = 1; } + if ( komodo_nextheight() > gameheight + ROGUE_MAXKEYSTROKESGAP ) + return(cclib_error(result,"didnt register in time, ROGUE_MAXKEYSTROKESGAP")); rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) From 3549fd1c0fb49cc792dab85a847704b31fc48f31 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:53:53 -1100 Subject: [PATCH 2238/3904] Update pending valid filter --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index de91eef19..4a7ef705d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1113,7 +1113,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers continue; - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && gameheight > nextheight-777 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && nextheight <= gameheight+ROGUE_MAXKEYSTROKESGAP ) { rogue_playersalive(numplayers,txid,maxplayers); if ( numplayers < maxplayers ) From 533c2e564dd06eb2c1203bc8807c5bd8d23b9bba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:27:02 -1100 Subject: [PATCH 2239/3904] Exit from replay --- src/cc/rogue/rogue.c | 3 ++- src/cc/rogue_rpc.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 516100906..d015be4a9 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -339,8 +339,9 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } rogue_replay2(0,seed,keystrokes,num,player,sleeptime); - //mvaddstr(LINES - 2, 0, (char *)"replay completed"); + mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); + my_exit(0); } if ( keystrokes != 0 ) free(keystrokes); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4a7ef705d..17d58a960 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -833,7 +833,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -897,7 +897,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) decode_hex(pub33,33,pubstr); pk = buf2pk(pub33); } - fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); + //fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); @@ -1047,7 +1047,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } result.push_back(Pair("result","success")); } else fprintf(stderr,"illegal game err.%d\n",err); - } else fprintf(stderr,"n.%d\n",n); + } else fprintf(stderr,"parameters only n.%d\n",n); } return(result); } @@ -1217,6 +1217,43 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; CTransaction vintx; uint256 hashBlock; + if ( (numvouts= tx.vout.size()) > 1 ) + { + scriptPubKey = tx.vout[numvouts-1].scriptPubKey; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 ) + { + script = (uint8_t *)vopret.data(); + if ( script[0] == EVAL_ROGUE ) + { + switch ( script[1] ) + { + case 'G': // newgame + case 'R': // register + case 'K': // keystrokes + case 'H': // win + case 'Q': // bailout + return(true); + break; + default: + return eval->Invalid("illegal rogue funcid"); + break; + } + } + else if ( script[0] == EVAL_TOKENS ) + { + if ( script[1] == 'c' ) + { + + } + else + { + + } + } else return eval->Invalid("illegal evalcode"); + } else return eval->Invalid("opret too small"); + } else return eval->Invalid("not enough vouts"); return(true); } From 444a5de9bc9156dd9666bd5d303657e0f4005613 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:30:29 -1100 Subject: [PATCH 2240/3904] -print --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index d015be4a9..337592f86 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -743,7 +743,7 @@ my_exit(int st) { uint32_t counter; resetltchars(); - if ( globalR.guiflag != 0 ) + if ( globalR.guiflag != 0 || globalR.sleeptime != 0 ) exit(st); else if ( counter++ < 10 ) { From 9ecce2eb73035ce4bd640c5ffe2b78ff079998c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:43:20 -1100 Subject: [PATCH 2241/3904] Preserve both player strength and max strength --- src/cc/rogue/init.c | 7 ++++++- src/cc/rogue/rogue.c | 2 +- src/cc/rogue/state.c | 6 +++--- src/cc/rogue_rpc.cpp | 11 ++++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index f296d6182..6ff0a71c0 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -27,7 +27,12 @@ void restore_player(struct rogue_state *rs) int32_t i; THING *obj; //rs->P.gold = purse; max_hp = rs->P.hitpoints; - pstats.s_str = max_stats.s_str = rs->P.strength; + pstats.s_str = rs->P.strength & 0xffff; + max_stats.s_str = rs->P.strength >> 16; + if ( max_stats.s_str < 12 ) + max_stats.s_str = 12; + if ( pstats.s_str > max_stats.s_str ) + pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; pstats.s_exp = rs->P.experience; for (i=0; iP.packsize; i++) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 337592f86..72fe07558 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -273,7 +273,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(rs,fp,0); - fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); + fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); } diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 800622444..778540b68 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1437,7 +1437,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) //fprintf(stderr,"KILLED\n"); rs->P.gold = -1; rs->P.hitpoints = -1; - rs->P.strength = -1; + rs->P.strength = 0; rs->P.level = -1; rs->P.experience = -1; rs->P.dungeonlevel = -1; @@ -1448,11 +1448,11 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) { rs->P.gold = purse; rs->P.hitpoints = max_hp; - rs->P.strength = pstats.s_str; //max_stats.s_str; + rs->P.strength = (pstats.s_str & 0xffff) | (max_stats.s_str << 16); rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - //fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); + //fprintf(stderr,"%ld gold.%d hp.%d strength.%d/%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 17d58a960..b79d653d5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -387,7 +387,8 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("pack",a)); obj.push_back(Pair("packsize",(int64_t)P.packsize)); obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); - obj.push_back(Pair("strength",(int64_t)P.strength)); + obj.push_back(Pair("strength",(int64_t)(P.strength&0xffff))); + obj.push_back(Pair("maxstrength",(int64_t)(P.strength>>16))); obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); @@ -863,12 +864,12 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat newdata[i] = newplayer[i]; ((uint8_t *)&endP)[i] = newplayer[i]; } - if ( endP.gold <= 0 || endP.hitpoints <= 0 || endP.strength <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) + if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel); + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); } else num = 0; } @@ -993,7 +994,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - if ( P.gold <= 0 || P.hitpoints <= 0 || P.strength <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) + if ( P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) { fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); @@ -1005,7 +1006,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); cashout = (uint64_t)P.gold * mult; if ( funcid == 'H' && maxplayers > 1 ) { From 6224d87b12dd461382289b908ccc341ff40888ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:45:29 -1100 Subject: [PATCH 2242/3904] Validate bypass --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b79d653d5..62f653685 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1246,11 +1246,11 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( script[1] == 'c' ) { - + return(true); } else { - + return(true); } } else return eval->Invalid("illegal evalcode"); } else return eval->Invalid("opret too small"); From 31a369f9855b16d616ba69f7830791e09e96adf2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:49:08 -1100 Subject: [PATCH 2243/3904] +fprintf in cursesd --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 02a80c470..30cc54ec9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - //fprintf(stderr,"%s\n",str); + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From ab28897a624d29b96d13d0ba5e493e257555c0ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:57:34 -1100 Subject: [PATCH 2244/3904] Redo chg_str --- src/cc/rogue/misc.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 7db9d073a..8a4d1df94 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -349,17 +349,36 @@ void chg_str(int amt) { //auto jl777: strange compiler error - str_t comp; + uint32_t comp; if (amt == 0) return; - add_str(&pstats.s_str, amt); + //add_str(&pstats.s_str, amt); + pstats.s_str += amt; + if ( pstats.s_str < 3 ) + pstats.s_str = 3; + else if ( pstats.s_str > 31 ) + pstats.s_str = 31; comp = pstats.s_str; if (ISRING(LEFT, R_ADDSTR)) - add_str(&comp, -cur_ring[LEFT]->o_arm); + { + // add_str(&comp, -cur_ring[LEFT]->o_arm); + comp += -cur_ring[LEFT]->o_arm; + if ( comp < 3 ) + comp = 3; + else if ( comp > 31 ) + comp = 31; + } if (ISRING(RIGHT, R_ADDSTR)) - add_str(&comp, -cur_ring[RIGHT]->o_arm); - if (comp > max_stats.s_str) + { + //add_str(&comp, -cur_ring[RIGHT]->o_arm); + comp += -cur_ring[RIGHT]->o_arm; + if ( comp < 3 ) + comp = 3; + else if ( comp > 31 ) + comp = 31; + } + if ( comp > max_stats.s_str ) max_stats.s_str = comp; } From 67879fb99208d901882322d83ef6a9416d9a5602 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:03:55 -1100 Subject: [PATCH 2245/3904] +chars print --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index c920ee411..7cfa7e59f 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -161,7 +161,7 @@ readchar(struct rogue_state *rs) { //if ( rs->ind == rs->numkeys-1 ) // rs->replaydone = (uint32_t)time(NULL); - //fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); + fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } if ( rs->replaydone != 0 && counter++ < 3 ) From 10ad979ac9fe8cdf4862358f4ced79e84c9e51e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:08:13 -1100 Subject: [PATCH 2246/3904] Test --- src/cc/rogue/command.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 6cc6b0763..22723b6c6 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -259,7 +259,8 @@ over: again = TRUE; goto over; } - when 'q': quaff(rs); + case 'q': quaff(rs); + break; when 'Q': after = FALSE; q_comm = TRUE; From fbdd8a6166c356655a87b0ea8d4cb2c41c742504 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:10:48 -1100 Subject: [PATCH 2247/3904] Test --- src/cc/rogue/command.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 22723b6c6..5dbc97051 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -262,15 +262,18 @@ over: case 'q': quaff(rs); break; when 'Q': - after = FALSE; - q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); - q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); + if ( rs->sleeptime == 1 ) + { + after = FALSE; + q_comm = TRUE; + quit(0); + if ( rs->guiflag != 0 && rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + q_comm = FALSE; + if ( rs->guiflag != 0 ) + rogue_bailout(rs); + else rs->replaydone = (uint32_t)time(NULL); + } return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); From da2234e121cc9649b367dc0cd18ad9f1e80b3e9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:15:25 -1100 Subject: [PATCH 2248/3904] Test --- src/cc/rogue/command.c | 21 +++++++++------------ src/cc/rogue/rogue.c | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 5dbc97051..d13be4972 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -262,18 +262,15 @@ over: case 'q': quaff(rs); break; when 'Q': - if ( rs->sleeptime == 1 ) - { - after = FALSE; - q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); - q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); - } + after = FALSE; + q_comm = TRUE; + quit(0); + if ( rs->guiflag != 0 && rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + q_comm = FALSE; + if ( rs->guiflag != 0 ) + rogue_bailout(rs); + else rs->replaydone = (uint32_t)time(NULL); return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 72fe07558..67a99aa14 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -633,9 +633,9 @@ quit(int sig) */ if (!q_comm) mpos = 0; - getyx(curscr, oy, ox); - msg(rs,"really quit?"); } + getyx(curscr, oy, ox); + msg(rs,"really quit?"); if (readchar(rs) == 'y') { if ( rs->guiflag != 0 ) @@ -653,7 +653,7 @@ quit(int sig) else { //score(rs,purse, 1, 0); - //fprintf(stderr,"done!\n"); + fprintf(stderr,"done!\n"); } } else From 0d262ff7e2e0a68520b6d59668fa3f7a9ae5d848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:17:40 -1100 Subject: [PATCH 2249/3904] Test --- src/cc/rogue/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 7cfa7e59f..83e0c2ff6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -161,7 +161,12 @@ readchar(struct rogue_state *rs) { //if ( rs->ind == rs->numkeys-1 ) // rs->replaydone = (uint32_t)time(NULL); - fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); + if ( rs->keystrokes[rs->ind] == 'Q' ) + { + rs->ind++; + fprintf(stderr,"Q.(%c) ",rs->keystrokes[rs->ind]); + return('q'); + } return(rs->keystrokes[rs->ind++]); } if ( rs->replaydone != 0 && counter++ < 3 ) From ae05cc1f6816560481cabb33d2e38041a5ce8f8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:22:50 -1100 Subject: [PATCH 2250/3904] Quit handling --- src/cc/rogue/command.c | 17 ++++++++++------- src/cc/rogue/extern.h | 2 +- src/cc/rogue/io.c | 13 ------------- src/cc/rogue/rogue.c | 7 ++++--- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d13be4972..d55b93a5b 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -264,14 +264,17 @@ over: when 'Q': after = FALSE; q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); + if ( quit(0) > 0 ) + { + if ( rs->guiflag != 0 ) + { + if (rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + rogue_bailout(rs); + } else rs->replaydone = (uint32_t)time(NULL); + } q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); - return; + return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); when 'd': drop(rs); diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index fc3454830..ff45e0fee 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -141,7 +141,7 @@ void getltchars(void); void leave(int); void my_exit(int st); void playltchars(void); -void quit(int); +int32_t quit(int); void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 83e0c2ff6..576314a42 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -158,23 +158,10 @@ readchar(struct rogue_state *rs) { static uint32_t counter; if ( rs->ind < rs->numkeys ) - { - //if ( rs->ind == rs->numkeys-1 ) - // rs->replaydone = (uint32_t)time(NULL); - if ( rs->keystrokes[rs->ind] == 'Q' ) - { - rs->ind++; - fprintf(stderr,"Q.(%c) ",rs->keystrokes[rs->ind]); - return('q'); - } return(rs->keystrokes[rs->ind++]); - } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); - //if ( (rand() & 1) == 0 ) - // return(ESCAPE); - //else if ( counter < 3 || (counter & 1) == 0 ) return('y'); else return(ESCAPE); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 67a99aa14..bfb4e0277 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -618,8 +618,7 @@ playit(struct rogue_state *rs) * Have player make certain, then exit. */ -void -quit(int sig) +int32_t quit(int sig) { struct rogue_state *rs = &globalR; int oy, ox; @@ -653,8 +652,9 @@ quit(int sig) else { //score(rs,purse, 1, 0); - fprintf(stderr,"done!\n"); + //fprintf(stderr,"done!\n"); } + return(1); } else { @@ -667,6 +667,7 @@ quit(int sig) mpos = 0; count = 0; to_death = FALSE; + return(0); } } From f513e5d1f531de4760c41d09f9f0ece0069d00ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:26:03 -1100 Subject: [PATCH 2251/3904] Prints --- src/cc/rogue/io.c | 2 ++ src/cc/rogue/rogue.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 576314a42..6e070b2a8 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -158,7 +158,9 @@ readchar(struct rogue_state *rs) { static uint32_t counter; if ( rs->ind < rs->numkeys ) + { return(rs->keystrokes[rs->ind++]); + } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index bfb4e0277..dafcf3f01 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -621,7 +621,7 @@ playit(struct rogue_state *rs) int32_t quit(int sig) { struct rogue_state *rs = &globalR; - int oy, ox; + int oy, ox, c; //fprintf(stderr,"inside quit(%d)\n",sig); if ( rs->guiflag != 0 ) { @@ -635,7 +635,8 @@ int32_t quit(int sig) } getyx(curscr, oy, ox); msg(rs,"really quit?"); - if (readchar(rs) == 'y') + sleep(1); + if ( (c= readchar(rs)) == 'y') { if ( rs->guiflag != 0 ) { @@ -652,12 +653,13 @@ int32_t quit(int sig) else { //score(rs,purse, 1, 0); - //fprintf(stderr,"done!\n"); + fprintf(stderr,"done!\n"); } return(1); } else { + fprintf(stderr,"'Q' answer (%c)\n",c); move(0, 0); clrtoeol(); status(rs); From ef4844d5a3538f097c7b81a311c7409172f46107 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:29:58 -1100 Subject: [PATCH 2252/3904] _quit --- src/cc/rogue/command.c | 2 +- src/cc/rogue/extern.h | 3 ++- src/cc/rogue/io.c | 2 +- src/cc/rogue/rogue.c | 40 +++++++++++++++++++++++++--------------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d55b93a5b..54d7beb99 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -264,7 +264,7 @@ over: when 'Q': after = FALSE; q_comm = TRUE; - if ( quit(0) > 0 ) + if ( _quit() > 0 ) { if ( rs->guiflag != 0 ) { diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index ff45e0fee..7fba842f3 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -141,7 +141,8 @@ void getltchars(void); void leave(int); void my_exit(int st); void playltchars(void); -int32_t quit(int); +void quit(int); +int32_t _quit(); void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 6e070b2a8..79eadb571 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -174,7 +174,7 @@ readchar(struct rogue_state *rs) if (ch == 3) { - quit(0); + _quit(); return(27); } if ( rs != 0 && rs->guiflag != 0 ) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index dafcf3f01..02feef2ab 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -613,26 +613,13 @@ playit(struct rogue_state *rs) endit(0); } -/* - * quit: - * Have player make certain, then exit. - */ -int32_t quit(int sig) + +int32_t _quit() { struct rogue_state *rs = &globalR; int oy, ox, c; //fprintf(stderr,"inside quit(%d)\n",sig); - if ( rs->guiflag != 0 ) - { - NOOP(sig); - - /* - * Reset the signal in case we got here via an interrupt - */ - if (!q_comm) - mpos = 0; - } getyx(curscr, oy, ox); msg(rs,"really quit?"); sleep(1); @@ -673,6 +660,29 @@ int32_t quit(int sig) } } +/* + * quit: + * Have player make certain, then exit. + */ + +void quit(int sig) +{ + struct rogue_state *rs = &globalR; + int oy, ox, c; + //fprintf(stderr,"inside quit(%d)\n",sig); + if ( rs->guiflag != 0 ) + { + NOOP(sig); + + /* + * Reset the signal in case we got here via an interrupt + */ + if (!q_comm) + mpos = 0; + } + _quit(); +} + /* * leave: * Leave quickly, but curteously From 7be1c552280b7c4347306e064632bdebcf024dba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:33:13 -1100 Subject: [PATCH 2253/3904] tst --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 02feef2ab..bc576dabf 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -640,7 +640,7 @@ int32_t _quit() else { //score(rs,purse, 1, 0); - fprintf(stderr,"done!\n"); + fprintf(stderr,"done! (%c)\n",c); } return(1); } From 0a11653334e01b49116a47003f57088d99fd5eac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:38:44 -1100 Subject: [PATCH 2254/3904] test --- src/cc/rogue/io.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 79eadb571..525550e67 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -153,13 +153,22 @@ step_ok(int ch) char readchar(struct rogue_state *rs) { - char ch = -1; + char c,ch = -1; if ( rs != 0 && rs->guiflag == 0 ) { static uint32_t counter; if ( rs->ind < rs->numkeys ) { - return(rs->keystrokes[rs->ind++]); + c = rs->keystrokes[rs->ind++]; + while ( c == 'Q' && rs->ind < rs->numkeys ) + { + fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); + if ( rs->keystrokes[rs->ind] == 'y' ) + return(c); + rs->ind++; + c = rs->keystrokes[rs->ind++]; + } + return(c); } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); From 8ea12e7dde906edc9d0e4342929bc13c7eb70b92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:02:10 -1100 Subject: [PATCH 2255/3904] Test --- src/cc/rogue/rogue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index bc576dabf..6583725f4 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -250,6 +250,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->restoring = 1; //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); } + globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); if ( 0 ) @@ -760,7 +761,7 @@ my_exit(int st) exit(st); else if ( counter++ < 10 ) { - fprintf(stderr,"would have exit.(%d)\n",st); + fprintf(stderr,"would have exit.(%d) sleeptime.%d\n",st,globalR.sleeptime); globalR.replaydone = 1; } } From ef554cc4744b53eda75dafeea3698e94328eb042 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:03:55 -1100 Subject: [PATCH 2256/3904] -print and pause --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 525550e67..9842ba353 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -162,7 +162,7 @@ readchar(struct rogue_state *rs) c = rs->keystrokes[rs->ind++]; while ( c == 'Q' && rs->ind < rs->numkeys ) { - fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); + //fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); if ( rs->keystrokes[rs->ind] == 'y' ) return(c); rs->ind++; From 85d4e67ea779ef417ffa07567d4639d10e897884 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:16:03 -1100 Subject: [PATCH 2257/3904] -print --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 30cc54ec9..02a80c470 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From 61d7ede6b44b6a3bbf987163e74e4a74dece8f37 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 18 Feb 2019 18:23:47 +0800 Subject: [PATCH 2258/3904] enable miner only for notary pay, and fix magic values for non notary pay chains. --- src/komodo_utils.h | 8 ++------ src/miner.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6e4a09546..fed8cfcca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1778,11 +1778,6 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY[i] = 0; printf("ERA%u: ASSETCHAINS_DECAY cant be more than 100000000\n", i); } - if ( ASSETCHAINS_NOTARY_PAY[i] < 64 ) - { - ASSETCHAINS_NOTARY_PAY[i] = 64; - printf("ERA%u: ASSETCHAINS_NOTARY_PAY cant be less than 64. Set to 64.\n", i); - } } MAX_BLOCK_SIGOPS = 60000; @@ -1942,7 +1937,8 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); } if (ASSETCHAINS_LASTERA > 0) diff --git a/src/miner.cpp b/src/miner.cpp index 344ef6431..f35fb160c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -251,8 +251,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Now we have the block time, we can get the active notaries. int32_t staked_era = 0; int8_t numSN = 0; uint8_t staked_pubkeys[64][33] = {0}; - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) < 3 ) { + // Only use speical miner for LABS chains in the actual cluster that use notarypay! + // It wouldnt hurt to use it on other chains, but serves little purpose. staked_era = STAKED_era(pblock->nTime); numSN = numStakedNotaries(staked_pubkeys,staked_era); } @@ -393,7 +395,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( fNotarisation ) { - // check if the notarization found is actually valid. + // Special miner for notary pay chains. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation From 26f77ab47dc2a66b9529921794bebadf9951ac5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:29:45 -1100 Subject: [PATCH 2259/3904] -sleep --- src/cc/rogue/rogue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6583725f4..c2f1d9829 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -595,7 +595,7 @@ playit(struct rogue_state *rs) { if ( rs->replaydone != 0 ) { - if ( rs->sleeptime != 0 ) + if ( 0 && rs->sleeptime != 0 ) sleep(3); return; } @@ -623,7 +623,7 @@ int32_t _quit() //fprintf(stderr,"inside quit(%d)\n",sig); getyx(curscr, oy, ox); msg(rs,"really quit?"); - sleep(1); + //sleep(1); if ( (c= readchar(rs)) == 'y') { if ( rs->guiflag != 0 ) From 9ef4ca17230036e43607999f0f9d6f06ff3ee282 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:33:24 -1100 Subject: [PATCH 2260/3904] Validation prints --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 62f653685..d0ed66cbb 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1235,6 +1235,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'K': // keystrokes case 'H': // win case 'Q': // bailout + fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return(true); break; default: @@ -1244,6 +1245,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } else if ( script[0] == EVAL_TOKENS ) { + fprintf(stderr,"ht.%d tokens.(%c)\n",height,script[1]); if ( script[1] == 'c' ) { return(true); From 9a48b245d436297903ae8f44292f9332deee427b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:46:14 -1100 Subject: [PATCH 2261/3904] Remove minstrength check --- src/cc/rogue/init.c | 4 +--- src/cc/rogue_rpc.cpp | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 6ff0a71c0..62998889d 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -28,9 +28,7 @@ void restore_player(struct rogue_state *rs) //rs->P.gold = purse; max_hp = rs->P.hitpoints; pstats.s_str = rs->P.strength & 0xffff; - max_stats.s_str = rs->P.strength >> 16; - if ( max_stats.s_str < 12 ) - max_stats.s_str = 12; + max_stats.s_str = (rs->P.strength >> 16) & 0xffff; if ( pstats.s_str > max_stats.s_str ) pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d0ed66cbb..068847c93 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1226,9 +1226,18 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( vopret.size() > 2 ) { script = (uint8_t *)vopret.data(); + if ( script[0] == EVAL_TOKENS ) + { + if ( script[1] == 'c' ) + { + } + else if ( script[1] == 't' ) + { + } else return eval->Invalid("illegal tokens funcid"); + } if ( script[0] == EVAL_ROGUE ) { - switch ( script[1] ) + switch ( funcid ) { case 'G': // newgame case 'R': // register @@ -1242,18 +1251,6 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("illegal rogue funcid"); break; } - } - else if ( script[0] == EVAL_TOKENS ) - { - fprintf(stderr,"ht.%d tokens.(%c)\n",height,script[1]); - if ( script[1] == 'c' ) - { - return(true); - } - else - { - return(true); - } } else return eval->Invalid("illegal evalcode"); } else return eval->Invalid("opret too small"); } else return eval->Invalid("not enough vouts"); From eff9ec93e24fbf2be824a4ef68e194933854de72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:47:59 -1100 Subject: [PATCH 2262/3904] Backwards compatibility --- src/cc/rogue/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 62998889d..1a5faa9ce 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -28,7 +28,8 @@ void restore_player(struct rogue_state *rs) //rs->P.gold = purse; max_hp = rs->P.hitpoints; pstats.s_str = rs->P.strength & 0xffff; - max_stats.s_str = (rs->P.strength >> 16) & 0xffff; + if ( (max_stats.s_str= (rs->P.strength >> 16) & 0xffff) == 0 ) + max_stats.s_str = 16; if ( pstats.s_str > max_stats.s_str ) pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; From 2e1e7f8c7ba42670af2156759e38fc38fb0529aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:52:07 -1100 Subject: [PATCH 2263/3904] Fix num_pack --- src/cc/rogue/pack.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 2f683441b..37072bf93 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -252,7 +252,10 @@ int32_t num_packitems() THING *list = pack; int32_t type = 0,n = 0; for (; list != NULL; list = next(list)) - n++; + { + if (!list->o_packch) + n++; + } return(n); } From 76c397d4d1137a44b6f7b8026cfa9c898222c101 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:00:06 -1100 Subject: [PATCH 2264/3904] Rework validation --- src/cc/rogue/pack.c | 16 ++++++++-------- src/cc/rogue_rpc.cpp | 9 +++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 37072bf93..392159fb5 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -52,9 +52,9 @@ add_pack(struct rogue_state *rs,THING *obj, bool silent) if (pack == NULL) { - pack = obj; - obj->o_packch = pack_char(); - inpack++; + pack = obj; + obj->o_packch = pack_char(); + inpack++; } else { @@ -291,11 +291,11 @@ inventory(struct rogue_state *rs,THING *list, int type) // fprintf(stderr,"n_objs.%d vs inpack.%d\n",n_objs,inpack), sleep(2); if (n_objs == 0) { - if (terse) - msg(rs,type == 0 ? (char *)"empty handed" : (char *)"nothing appropriate"); - else - msg(rs,type == 0 ? (char *)"you are empty handed" : (char *)"you don't have anything appropriate"); - return FALSE; + if (terse) + msg(rs,type == 0 ? (char *)"empty handed" : (char *)"nothing appropriate"); + else + msg(rs,type == 0 ? (char *)"you are empty handed" : (char *)"you don't have anything appropriate"); + return FALSE; } end_line(rs); return TRUE; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 068847c93..c4a142ba1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1226,16 +1226,21 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( vopret.size() > 2 ) { script = (uint8_t *)vopret.data(); - if ( script[0] == EVAL_TOKENS ) + funcid = script[1]; + if ( (e= script[0]) == EVAL_TOKENS ) { if ( script[1] == 'c' ) { + e = EVAL_ROGUE; + funcid = 'Q'; } else if ( script[1] == 't' ) { + e = EVAL_ROGUE; + funcid = 'Q'; } else return eval->Invalid("illegal tokens funcid"); } - if ( script[0] == EVAL_ROGUE ) + if ( e == EVAL_ROGUE ) { switch ( funcid ) { From 27002ce1f2f10f12baef75e4fb30c898370c8d9b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:07:45 -1100 Subject: [PATCH 2265/3904] -print --- src/cc/assets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 28adf9be6..f42c4fda3 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -177,7 +177,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti // find single-eval token user cc addr: //GetCCaddress(cpTokens, signleEvalTokensCCaddr, pubkey2pk(origpubkey)); - fprintf(stderr,"AssetValidate (%c)\n",funcid); + //fprintf(stderr,"AssetValidate (%c)\n",funcid); if( funcid != 'o' && funcid != 'x' && eval->GetTxUnconfirmed(assetid, createTx, hashBlock) == 0 ) return eval->Invalid("cant find asset create txid"); From 553b54b61cb32f41a86281dd26fabe2ecce1363f Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 12:13:11 +0100 Subject: [PATCH 2266/3904] roguefy makefile 'roguefy' for komodo linux makefile --- zcutil/build.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index dc312c8e8..7b452a1fc 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -103,20 +103,12 @@ ld -v HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 - #BUILD CCLIB WD=$PWD cd src/cc echo $PWD - -if make "$@"; then - echo CCLIB BUILD SUCCESSFUL -else - echo CCLIB BUILD FAILED - exit 1 -fi - +./makerogue cd $WD ./autogen.sh From 2d98e3a0e58072fac0eb866dfbcf2c36d3c8bc2e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:39:21 -1100 Subject: [PATCH 2267/3904] Decode all ospreys --- src/cc/rogue_rpc.cpp | 69 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c4a142ba1..ac63dea42 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1218,7 +1218,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; CTransaction vintx; uint256 hashBlock; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -1229,30 +1229,67 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C funcid = script[1]; if ( (e= script[0]) == EVAL_TOKENS ) { - if ( script[1] == 'c' ) + if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) { - e = EVAL_ROGUE; - funcid = 'Q'; - } - else if ( script[1] == 't' ) - { - e = EVAL_ROGUE; - funcid = 'Q'; - } else return eval->Invalid("illegal tokens funcid"); + if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) + { + funcid = 'Q'; + fprintf(stderr,"ht.%d couldnt decode tokens opret\n",height); + } else e = EVAL_ROGUE, decoded = 1; + } else e = EVAL_ROGUE, decoded = 1; } if ( e == EVAL_ROGUE ) { + if ( decoded == 0 ) + { + switch ( funcid ) + { + case 'G': + if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' ) + return eval->Invalid("couldnt decode newgame opret"); + // validate newgame tx + return(true); + break; + case 'R': + if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) + return eval->Invalid("couldnt decode register opret"); + break; + case 'K': + if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) + return eval->Invalid("couldnt decode keystrokes opret"); + // validate keystrokes are from the correct pk. might need to add vin + return(true); + break; + case 'H': case 'Q': + if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) + return eval->Invalid("couldnt decode H/Q opret"); + break; + default: + return eval->Invalid("illegal rogue non-decoded funcid"); + break; + } + } switch ( funcid ) { - case 'G': // newgame - case 'R': // register - case 'K': // keystrokes - case 'H': // win - case 'Q': // bailout - fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); + case 'R': + // validate register: within 60 blocks, not duplicate, etc. + return(true); + break; + case 'H': // fall through + case 'Q': + // make sure any playerdata is reproduced via replay + if ( funcid == 'Q' ) + { + // validate bailout constraints + } + else // 'H' + { + // validate winner constraints + } return(true); break; default: + fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return eval->Invalid("illegal rogue funcid"); break; } From bec0d4935f6227df401270e3cd779f05657fd65b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:39:56 -1100 Subject: [PATCH 2268/3904] Playertxid --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ac63dea42..06d2b63b8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1218,7 +1218,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; From 0a59b078e15e4b4fb4a63caffc32531b6befb150 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:41:45 -1100 Subject: [PATCH 2269/3904] -proint --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c4a142ba1..451b3bedb 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1249,7 +1249,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'K': // keystrokes case 'H': // win case 'Q': // bailout - fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); + //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return(true); break; default: From 562e99fc96d91c8d796580ca3d688d34d8aa6884 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:51:21 -1100 Subject: [PATCH 2270/3904] Do total items --- src/cc/rogue/pack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 392159fb5..4858afcdd 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -250,12 +250,16 @@ pack_char() int32_t num_packitems() { THING *list = pack; - int32_t type = 0,n = 0; + int32_t type = 0,n = 0,total = 0; for (; list != NULL; list = next(list)) { - if (!list->o_packch) + if ( list->o_packch != 0 ) + { n++; + total += list->o_count; + } } + fprintf(stderr,"total.%d vs %d inventory letters\n",total,n); return(n); } From 437af05de66e9e0822c1472eef335425bcb49883 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:53:23 -1100 Subject: [PATCH 2271/3904] Test --- src/cc/rogue/pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 4858afcdd..8fc488389 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -259,7 +259,7 @@ int32_t num_packitems() total += list->o_count; } } - fprintf(stderr,"total.%d vs %d inventory letters\n",total,n); + fprintf(stderr,"total.%d vs %d inventory letters\n",total,n); sleep(1); return(n); } From 986488d139c1eda626c50837a3899e28582bfe3d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 18 Feb 2019 19:55:18 +0800 Subject: [PATCH 2272/3904] fix format --- src/notaries_staked.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c44d89df2..5311f8e51 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -12,23 +12,23 @@ extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { - static int8_t STAKED,doneinit; - if ( chain_name[0] == 0 ) - return(0); - if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) + static int8_t STAKED,doneinit; + if ( chain_name[0] == 0 ) + return(0); + if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) + return(STAKED); + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABSTH") == 0) ) + STAKED = 1; // These chains are allowed coin emissions. + else if ( (strncmp(chain_name, "LABS", 4) == 0) ) + STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. + else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + STAKED = 3; // These chains have no speical rules at all. + else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) + STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. + else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) + STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. + doneinit = 1; return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABSTH") == 0) ) - STAKED = 1; // These chains are allowed coin emissions. - else if ( (strncmp(chain_name, "LABS", 4) == 0) ) - STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. - else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; // These chains have no speical rules at all. - else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. - else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) - STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. - doneinit = 1; - return(STAKED); }; int32_t STAKED_era(int timestamp) From dae06859f1803ad54733671a512c993cc34a5417 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:57:16 -1100 Subject: [PATCH 2273/3904] -sleep --- src/cc/rogue/pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 8fc488389..39dc163b1 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -259,7 +259,7 @@ int32_t num_packitems() total += list->o_count; } } - fprintf(stderr,"total.%d vs %d inventory letters\n",total,n); sleep(1); + fprintf(stderr,"total.%d vs %d inventory letters\n",total,n); return(n); } From 040d3f8bfeebe26f46104c6000efe8352e03a39d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:04:14 -1100 Subject: [PATCH 2274/3904] Print --- src/cc/rogue/pack.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 39dc163b1..1589d4d34 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -259,14 +259,17 @@ int32_t num_packitems() total += list->o_count; } } - fprintf(stderr,"total.%d vs %d inventory letters\n",total,n); + + char inv_temp[MAXSTR],str[MAXSTR]; + sprintf(str,"total.%d vs %d inventory letters\n",total,n); + add_line(rs,inv_temp,str); return(n); } bool inventory(struct rogue_state *rs,THING *list, int type) { - static char inv_temp[MAXSTR]; + char inv_temp[MAXSTR]; n_objs = 0; for (; list != NULL; list = next(list)) From e4c1ce63964d04147e20bcb4e4643a852ee38bbe Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:04:51 -1100 Subject: [PATCH 2275/3904] struct rogue_state *rs --- src/cc/rogue/pack.c | 4 ++-- src/cc/rogue/rogue.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 1589d4d34..0c967a85b 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -165,7 +165,7 @@ out: bool pack_room(struct rogue_state *rs,bool from_floor, THING *obj) { - inpack = num_packitems(); + inpack = num_packitems(rs); if (++inpack > MAXPACK) { if (!terse) @@ -247,7 +247,7 @@ pack_char() * the given type. */ -int32_t num_packitems() +int32_t num_packitems(struct rogue_state *rs) { THING *list = pack; int32_t type = 0,n = 0,total = 0; diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 905a5ed36..515c1d44a 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -802,7 +802,7 @@ THING *leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all); THING *new_item(void); THING *new_thing(struct rogue_state *rs); void end_line(struct rogue_state *rs); -int32_t num_packitems(); +int32_t num_packitems(struct rogue_state *rs); void runners(struct rogue_state *rs,int); void land(struct rogue_state *rs,int); From 63bad40a584d5a8c6206219103960ddd68f21e53 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:07:59 -1100 Subject: [PATCH 2276/3904] Fat --- src/cc/rogue/pack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 0c967a85b..7e93dd759 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -260,9 +260,9 @@ int32_t num_packitems(struct rogue_state *rs) } } - char inv_temp[MAXSTR],str[MAXSTR]; + char str[MAXSTR]; sprintf(str,"total.%d vs %d inventory letters\n",total,n); - add_line(rs,inv_temp,str); + add_line(rs,"%s",str); return(n); } From f9b288af4768d7f4f75a44da02ab1067accbed0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:11:53 -1100 Subject: [PATCH 2277/3904] Total < strength*3 --- src/cc/rogue/pack.c | 74 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 7e93dd759..f8fc98175 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -157,37 +157,55 @@ out: } } +int32_t num_packitems(struct rogue_state *rs) +{ + THING *list = pack; + int32_t type = 0,n = 0,total = 0; + for (; list != NULL; list = next(list)) + { + if ( list->o_packch != 0 ) + { + n++; + total += list->o_count; + } + } + + char str[MAXSTR]; + sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); + add_line(rs,"%s",str); + if ( total > pstats.s_str*3 ) + return(MAXPACK); + return(n); +} + /* * pack_room: * See if there's room in the pack. If not, print out an * appropriate message */ -bool -pack_room(struct rogue_state *rs,bool from_floor, THING *obj) +bool pack_room(struct rogue_state *rs,bool from_floor, THING *obj) { inpack = num_packitems(rs); - if (++inpack > MAXPACK) + if ( ++inpack > MAXPACK ) { - if (!terse) - addmsg(rs,"there's "); - addmsg(rs,"no room"); - if (!terse) - addmsg(rs," in your pack"); - endmsg(rs); - if (from_floor) - move_msg(rs,obj); - inpack = MAXPACK; - return FALSE; + if (!terse) + addmsg(rs,"there's "); + addmsg(rs,"no room"); + if (!terse) + addmsg(rs," in your pack"); + endmsg(rs); + if (from_floor) + move_msg(rs,obj); + inpack = MAXPACK; + return FALSE; } //fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2); - - if (from_floor) + if ( from_floor != 0 ) { - detach(lvl_obj, obj); - mvaddch(hero.y, hero.x, floor_ch()); - chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR; + detach(lvl_obj, obj); + mvaddch(hero.y, hero.x, floor_ch()); + chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR; } - return TRUE; } @@ -247,24 +265,6 @@ pack_char() * the given type. */ -int32_t num_packitems(struct rogue_state *rs) -{ - THING *list = pack; - int32_t type = 0,n = 0,total = 0; - for (; list != NULL; list = next(list)) - { - if ( list->o_packch != 0 ) - { - n++; - total += list->o_count; - } - } - - char str[MAXSTR]; - sprintf(str,"total.%d vs %d inventory letters\n",total,n); - add_line(rs,"%s",str); - return(n); -} bool inventory(struct rogue_state *rs,THING *list, int type) From 575f5b4fd85d91560e6feb27a15934a6cbb51070 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:13:31 -1100 Subject: [PATCH 2278/3904] Disable --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 06d2b63b8..f4f45bf25 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1219,6 +1219,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + return(true); if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -1289,7 +1290,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(true); break; default: - fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); + //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return eval->Invalid("illegal rogue funcid"); break; } From 54319f4bb65ce2ff948b23d58247f15ca515b0d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:20:28 -1100 Subject: [PATCH 2279/3904] Test opret validation --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 068a959cc..e5381a802 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1219,7 +1219,6 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; - return(true); if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -1254,6 +1253,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'R': if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) return eval->Invalid("couldnt decode register opret"); + // validation is done below break; case 'K': if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) @@ -1264,6 +1264,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'H': case 'Q': if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) return eval->Invalid("couldnt decode H/Q opret"); + // validation is done below break; default: return eval->Invalid("illegal rogue non-decoded funcid"); From c19cc548ad998128ea19628bcc9294e2746f8103 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:22:53 -1100 Subject: [PATCH 2280/3904] Height exemption --- src/cc/rogue_rpc.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e5381a802..b1eb36e65 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1246,7 +1246,11 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { case 'G': if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' ) - return eval->Invalid("couldnt decode newgame opret"); + { + fprintf(stderr,"height.%d couldnt decode newgame opret\n",height); + if ( height > 20000 ) + return eval->Invalid("couldnt decode newgame opret"); + } // validate newgame tx return(true); break; From 53c35e3c89c1ea5358e75ebf9a6069b5fac6a424 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:26:56 -1100 Subject: [PATCH 2281/3904] Test --- src/cc/rogue_rpc.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b1eb36e65..6e6da24f2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1240,6 +1240,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } if ( e == EVAL_ROGUE ) { + fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); if ( decoded == 0 ) { switch ( funcid ) @@ -1261,7 +1262,11 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C break; case 'K': if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) - return eval->Invalid("couldnt decode keystrokes opret"); + { + fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height); + if ( height > 20000 ) + return eval->Invalid("couldnt decode keystrokes opret"); + } // validate keystrokes are from the correct pk. might need to add vin return(true); break; @@ -1286,7 +1291,6 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(true); break; default: - //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return eval->Invalid("illegal rogue funcid"); break; } From aa26fa0a69c7ba92ab3b2a0ade2c5adf8eac2300 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:30:05 -1100 Subject: [PATCH 2282/3904] Bypass all --- src/cc/rogue_rpc.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6e6da24f2..994cbe319 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1257,7 +1257,11 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C break; case 'R': if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) - return eval->Invalid("couldnt decode register opret"); + { + fprintf(stderr,"height.%d couldnt decode register opret\n",height); + if ( height > 20000 ) + return eval->Invalid("couldnt decode register opret"); + } // validation is done below break; case 'K': @@ -1272,7 +1276,11 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C break; case 'H': case 'Q': if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) - return eval->Invalid("couldnt decode H/Q opret"); + { + fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); + if ( height > 20000 ) + return eval->Invalid("couldnt decode H/Q opret"); + } // validation is done below break; default: From 535741426479fc5d01d35ef90b74ed6fba2b880c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 01:35:21 -1100 Subject: [PATCH 2283/3904] Test --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 994cbe319..ef24489ba 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1234,7 +1234,9 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) { funcid = 'Q'; - fprintf(stderr,"ht.%d couldnt decode tokens opret\n",height); + fprintf(stderr,"ht.%d couldnt decode tokens opret (%c)\n",height,script[1]); + if ( height < 20000 ) + e = EVAL_ROGUE; } else e = EVAL_ROGUE, decoded = 1; } else e = EVAL_ROGUE, decoded = 1; } From 49d8a2aa5d9b6306776650cfa3e9e3442d1716e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 03:20:43 -1100 Subject: [PATCH 2284/3904] Disable --- src/cc/rogue/pack.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index f8fc98175..f28ef891d 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -169,12 +169,14 @@ int32_t num_packitems(struct rogue_state *rs) total += list->o_count; } } - - char str[MAXSTR]; - sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); - add_line(rs,"%s",str); - if ( total > pstats.s_str*3 ) - return(MAXPACK); + if ( 0 ) // crashes playerinfo + { + char str[MAXSTR]; + sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); + add_line(rs,"%s",str); + if ( total > pstats.s_str*3 ) + return(MAXPACK); + } return(n); } From f5af7f465f635877aafcea1bc630016e4d86114f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 03:23:15 -1100 Subject: [PATCH 2285/3904] Fix player info crash --- src/cc/rogue/pack.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index f8fc98175..7fae5452a 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -169,10 +169,12 @@ int32_t num_packitems(struct rogue_state *rs) total += list->o_count; } } - - char str[MAXSTR]; - sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); - add_line(rs,"%s",str); + if ( 0 ) + { + char str[MAXSTR]; + sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); + add_line(rs,"%s",str); + } if ( total > pstats.s_str*3 ) return(MAXPACK); return(n); From a4f241718bdec6e7312a479037eba3ad40daa0f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 03:24:21 -1100 Subject: [PATCH 2286/3904] Test --- src/cc/rogue/pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index f28ef891d..d482a8a52 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -169,14 +169,14 @@ int32_t num_packitems(struct rogue_state *rs) total += list->o_count; } } - if ( 0 ) // crashes playerinfo + if ( rs->guiflag != 0 ) { char str[MAXSTR]; sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); add_line(rs,"%s",str); - if ( total > pstats.s_str*3 ) - return(MAXPACK); } + if ( total > pstats.s_str*3 ) + return(MAXPACK); return(n); } From 8b35141984d4a25ed761bdf23fb40a1772145b5e Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 15:29:59 +0100 Subject: [PATCH 2287/3904] roguefy WIN makefile --- zcutil/build-win.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zcutil/build-win.sh b/zcutil/build-win.sh index 5c12893fa..ef0c09549 100755 --- a/zcutil/build-win.sh +++ b/zcutil/build-win.sh @@ -11,6 +11,12 @@ cd "$(dirname "$(readlink -f "$0")")/.." cd depends/ && make HOST=$HOST V=1 NO_QT=1 cd ../ +WD=$PWD +cd src/cc +echo $PWD +./makerogue +cd $WD + ./autogen.sh CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure From cbe32599e4cb46c06a97f8dca6e6cdcd96492573 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 03:35:29 -1100 Subject: [PATCH 2288/3904] Conditional validate --- src/cc/rogue_rpc.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ef24489ba..31336d8fb 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1219,6 +1219,8 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 20000 ) + return(true); if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -1231,12 +1233,9 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) { - if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) + if ( (f= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) { - funcid = 'Q'; fprintf(stderr,"ht.%d couldnt decode tokens opret (%c)\n",height,script[1]); - if ( height < 20000 ) - e = EVAL_ROGUE; } else e = EVAL_ROGUE, decoded = 1; } else e = EVAL_ROGUE, decoded = 1; } @@ -1250,8 +1249,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'G': if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' ) { - fprintf(stderr,"height.%d couldnt decode newgame opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode newgame opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode newgame opret"); } // validate newgame tx @@ -1260,8 +1259,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'R': if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) { - fprintf(stderr,"height.%d couldnt decode register opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode register opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode register opret"); } // validation is done below @@ -1269,8 +1268,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'K': if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) { - fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode keystrokes opret"); } // validate keystrokes are from the correct pk. might need to add vin @@ -1279,8 +1278,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'H': case 'Q': if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) { - fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode H/Q opret"); } // validation is done below @@ -1292,11 +1291,18 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } switch ( funcid ) { - case 'G': // newgame case 'R': // register - case 'K': // keystrokes + return(true); case 'H': // win case 'Q': // bailout + if ( funcid == 'Q' ) + { + + } + else + { + + } //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return(true); break; From b4c9cbc661f35e298814b6b910c56583b421c966 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 03:59:54 -1100 Subject: [PATCH 2289/3904] Fix setpubkey crash --- src/wallet/rpcwallet.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f945b82fc..47f7d3004 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5306,15 +5306,20 @@ UniValue setpubkey(const UniValue& params, bool fHelp) LOCK(cs_main); #endif - char Raddress[18]; + char Raddress[64]; uint8_t pubkey33[33]; - if ( NOTARY_PUBKEY33[0] == 0 ) { - if (strlen(params[0].get_str().c_str()) == 66) { + if ( NOTARY_PUBKEY33[0] == 0 ) + { + if (strlen(params[0].get_str().c_str()) == 66) + { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { + if ( 0 && strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) // no idea what this addr is + { result.push_back(Pair("error", "pubkey entered is invalid.")); - } else { + } + else + { CBitcoinAddress address(Raddress); bool isValid = address.IsValid(); if (isValid) @@ -5331,10 +5336,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp) decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); USE_EXTERNAL_PUBKEY = 1; } - } else { - result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } - } else { + } else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); + } + else + { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon, pubkey in use is below.")); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); std::string address_ret; address_ret.assign(Raddress); From 25acb3c52ca4246b79ddb1b3187491a8ce5d24dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 04:01:14 -1100 Subject: [PATCH 2290/3904] Fix setpubkey crash --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f945b82fc..6d37033d6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5306,7 +5306,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) LOCK(cs_main); #endif - char Raddress[18]; + char Raddress[64]; uint8_t pubkey33[33]; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { From 50070c8c531bb802b58509c04b1b47882d324728 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 04:27:23 -1100 Subject: [PATCH 2291/3904] Verify player data --- src/cc/rogue_rpc.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 31336d8fb..08e3e27bc 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1216,6 +1216,20 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) +{ + char str[512],*keystrokes,rogueaddr[64]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 platertxid; CPubKey roguepk; + roguepk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,rogueaddr,roguepk,pk); + if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) + { + if ( newdata == playerdata ) + return(0); + else fprintf(stderr,"newdata[%d] != playerdata[%d]\n",(int32_t)newdata.size(),(int32_t)playerdata.size()); + } + return(-1); +} + bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; @@ -1295,15 +1309,22 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(true); case 'H': // win case 'Q': // bailout + // verify pk belongs to this tx + if ( playerdata.size() > 0 ) + { + if ( rogue_playerdata_validate(cp,playerdata,gametxid,pk) < 0 ) + { + fprintf(stderr,"ht.%d gametxid.%s player.%x invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)playerdata.size()); + } else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,playertxid.GetHex().c_str()); + } if ( funcid == 'Q' ) { - + // verify vin/vout } - else + else // 'H' { - + // verify vin/vout } - //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return(true); break; default: From f06745f9ee29533a70e19dcfac707360f0866ca3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 04:28:25 -1100 Subject: [PATCH 2292/3904] Formats --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 08e3e27bc..25d3c37ed 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1218,7 +1218,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { - char str[512],*keystrokes,rogueaddr[64]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 platertxid; CPubKey roguepk; + char str[512],*keystrokes,rogueaddr[64]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) @@ -1314,7 +1314,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( rogue_playerdata_validate(cp,playerdata,gametxid,pk) < 0 ) { - fprintf(stderr,"ht.%d gametxid.%s player.%x invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)playerdata.size()); + fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)playerdata.size()); } else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,playertxid.GetHex().c_str()); } if ( funcid == 'Q' ) From 1aae4fa9c53c6abc382182fcc96cb3e437fe49f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 04:34:06 -1100 Subject: [PATCH 2293/3904] Dont deadlock in GetTransaction --- src/cc/assets.cpp | 2 +- src/cc/rogue_rpc.cpp | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index f42c4fda3..921d33d69 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -305,7 +305,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("mismatched vout0 AssetsCCaddr for fillbuy"); } } - fprintf(stderr,"fillbuy validated\n"); + //fprintf(stderr,"fillbuy validated\n"); break; //case 'e': // selloffer // break; // disable swaps diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 25d3c37ed..aeb7d8228 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -265,7 +265,7 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, vout = i+1; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { - if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) { Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(myrogueaddr,destaddr) == 0 ) @@ -296,7 +296,7 @@ int32_t rogue_playersalive(int32_t &numplayers,uint256 gametxid,int32_t maxplaye uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) { CBlockIndex *pindex; int32_t ht,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; - if ( GetTransaction(gametxid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + if ( myGetTransaction(gametxid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); delay = ROGUE_REGISTRATION * (maxplayers > 1); @@ -329,7 +329,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { gameheight = komodo_blockheight(hashBlock); if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) >= txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) @@ -434,14 +434,14 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,std::string &symbol,std::string &pname,uint256 playertxid) { uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; - if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 && (numvouts= playertx.vout.size()) > 0 ) { if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { if ( tokenid != zeroid ) { playertxid = tokenid; - if ( GetTransaction(playertxid,playertx,hashBlock,false) == 0 || (numvouts= playertx.vout.size()) <= 0 ) + if ( myGetTransaction(playertxid,playertx,hashBlock) == 0 || (numvouts= playertx.vout.size()) <= 0 ) { fprintf(stderr,"couldnt get tokenid.%s\n",playertxid.GetHex().c_str()); return(-2); @@ -480,7 +480,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke { if ( myIsutxo_spent(spenttxid,gametxid,i+1) >= 0 ) { - if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) { numplayers++; Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); @@ -524,7 +524,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke txid = spenttxid; if ( spentvini != 0 ) return(-3); - if ( keystrokesp != 0 && GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() >= 2 ) + if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) { uint256 g,b; CPubKey p; std::vector k; if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) @@ -547,7 +547,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke batonvout = 0; // not vini // how to detect timeout, bailedout, highlander hashBlock = zeroid; - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 0 ) + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 0 ) { if ( hashBlock == zeroid ) batonht = komodo_nextheight(); @@ -577,7 +577,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { - if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-1)); @@ -585,7 +585,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet { if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) { - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 1 ) + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 ) { if ( rogue_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) obj.push_back(Pair("status","registered")); @@ -758,7 +758,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( playertxid != zeroid ) { voutPubkeysEmpty.push_back(burnpk); - if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 ) { if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, vopretExtra)) != 0) { // if token in the opret @@ -1174,7 +1174,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( vout == 0 ) { - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) { From bc1e1418ea44884427d17ebc86b3cc580f52f489 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 04:42:16 -1100 Subject: [PATCH 2294/3904] Set funcid --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index aeb7d8228..a932a8151 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1247,7 +1247,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) { - if ( (f= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) + if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) { fprintf(stderr,"ht.%d couldnt decode tokens opret (%c)\n",height,script[1]); } else e = EVAL_ROGUE, decoded = 1; From 7d97a0ef0317130b4e4182a40fe4f058d563d818 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 04:45:44 -1100 Subject: [PATCH 2295/3904] +prints --- src/cc/rogue_rpc.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a932a8151..ee67d04b6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -828,13 +828,15 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; + fprintf(stderr,"calling validgame\n"); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { + fprintf(stderr,"calling baton\n"); if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -872,8 +874,8 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); } else num = 0; - } - } + } else fprintf(stderr,"extractgame: couldnt find baton\n"); + } else fprintf(stderr,"extractgame: invalid game\n"); *numkeysp = numkeys; return(keystrokes); } @@ -1221,8 +1223,11 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); + fprintf(stderr,"call extractgame\n"); if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { + free(keystrokes); + fprintf(stderr,"extracted.(%s)\n",str); if ( newdata == playerdata ) return(0); else fprintf(stderr,"newdata[%d] != playerdata[%d]\n",(int32_t)newdata.size(),(int32_t)playerdata.size()); From 667d50cea019a269a37df03137df3ed0b6312533 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 04:59:33 -1100 Subject: [PATCH 2296/3904] Prints --- src/cc/rogue_rpc.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ee67d04b6..46446a883 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -478,6 +478,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke playertxid = zeroid; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -489,26 +490,26 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke matches++; regslot = i; matchtx = spenttx; - } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); - } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); - } //else fprintf(stderr,"%d+1 unspent\n",i); + } else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } else fprintf(stderr,"%d+1 unspent\n",i); } if ( matches == 1 ) { if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1) < 0 ) { @@ -541,8 +542,9 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); return(-5); } + fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -555,7 +557,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - //printf("keystrokes[%d]\n",numkeys); + printf("keystrokes[%d]\n",numkeys); return(0); } } From 7cced97fb91e24a8e7016d926ec04b5288e1e775 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 05:08:49 -1100 Subject: [PATCH 2297/3904] +print --- src/cc/rogue_rpc.cpp | 5 +++-- src/komodo_bitcoind.h | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 46446a883..b5e669237 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -557,9 +557,9 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("keystrokes[%d]\n",numkeys); + printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); - } + } else fprintf(stderr,"couldnt find baton\n"); } } else fprintf(stderr,"findbaton opret error\n"); } @@ -837,6 +837,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) { UniValue obj; + fprintf(stderr,"calling gamefields\n"); seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 68250e6cf..6cc7dc427 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1127,10 +1127,10 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 int32_t komodo_nextheight() { - CBlockIndex *pindex; int32_t ht,longest = komodo_longestchain(); - if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) >= longest ) + CBlockIndex *pindex; int32_t ht; + if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) > 0 ) return(ht+1); - else return(longest + 1); + else return(komodo_longestchain() + 1); } int32_t komodo_isrealtime(int32_t *kmdheightp) From 726a46027aa156ba1a216f9650f24e49f55af031 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 05:27:51 -1100 Subject: [PATCH 2298/3904] Init pack --- src/cc/rogue/init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 1a5faa9ce..30370f958 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -24,7 +24,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item); void restore_player(struct rogue_state *rs) { - int32_t i; THING *obj; + int32_t i,total = 0; THING *obj; //rs->P.gold = purse; max_hp = rs->P.hitpoints; pstats.s_str = rs->P.strength & 0xffff; @@ -34,10 +34,13 @@ void restore_player(struct rogue_state *rs) pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; pstats.s_exp = rs->P.experience; - for (i=0; iP.packsize; i++) + for (i=0; iP.packsize&&iP.roguepack[i]); + total += obj->o_count; + if ( total > pstats.s_str*3 ) + break; add_pack(rs,obj,TRUE); } } From a0e262832560685a38338834e3f28661c3813f82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 05:29:01 -1100 Subject: [PATCH 2299/3904] Init pack with strength limit --- src/cc/rogue/init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 1a5faa9ce..30370f958 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -24,7 +24,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item); void restore_player(struct rogue_state *rs) { - int32_t i; THING *obj; + int32_t i,total = 0; THING *obj; //rs->P.gold = purse; max_hp = rs->P.hitpoints; pstats.s_str = rs->P.strength & 0xffff; @@ -34,10 +34,13 @@ void restore_player(struct rogue_state *rs) pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; pstats.s_exp = rs->P.experience; - for (i=0; iP.packsize; i++) + for (i=0; iP.packsize&&iP.roguepack[i]); + total += obj->o_count; + if ( total > pstats.s_str*3 ) + break; add_pack(rs,obj,TRUE); } } From bda6c83b969400a9226288a3d33f008e31f8ec8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 05:39:28 -1100 Subject: [PATCH 2300/3904] +print --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 02a80c470..30cc54ec9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - //fprintf(stderr,"%s\n",str); + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From 4ba765895cb3a12e3e5dbc692616c12c7f0cb62a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 05:42:02 -1100 Subject: [PATCH 2301/3904] Fix dereference --- src/cc/rogue/rogue.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index c2f1d9829..2393b0ced 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -238,7 +238,7 @@ void rogue_bailout(struct rogue_state *rs) int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis) { - struct rogue_state *rs; FILE *fp; int32_t i; + struct rogue_state *rs; FILE *fp; int32_t i,n; rs = (struct rogue_state *)calloc(1,sizeof(*rs)); rs->seed = seed; rs->keystrokes = keystrokes; @@ -248,7 +248,9 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu { rs->P = *player; rs->restoring = 1; - //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); + fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); + if ( rs->P.packsize > MAXPACK ) + rs->P.packsize = MAXPACK; } globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); @@ -278,8 +280,9 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); } + n = rs->playsize; free(rs); - return(rs->playersize); + return(n); } #endif From c0bdecef07107470c479b7c3c8c9efbc67b18d0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 05:42:57 -1100 Subject: [PATCH 2302/3904] Er --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 2393b0ced..cbcc67afd 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -280,7 +280,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); } - n = rs->playsize; + n = rs->playersize; free(rs); return(n); } From 20402a3a01bb80098e5e600dfde91a90871ea99c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 05:53:41 -1100 Subject: [PATCH 2303/3904] New unctrl --- src/cc/rogue/cursesd.c | 7 +++++++ src/cc/rogue/cursesd.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 30cc54ec9..ab57e2107 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -422,3 +422,10 @@ int32_t md_readchar(void) return(0); } +char *unctrl(char c) +{ + static char ctrlstr[3]; + ctrlstr[0] = '^'; + ctrlstr[1] = 'a' + c; + return(ctrlstr); +} diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 4fa09e9d9..87304cfa6 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -123,9 +123,10 @@ int32_t wprintw(WINDOW *win,char *fmt,...); int32_t mvprintw(int32_t y,int32_t x,char *fmt,...); int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); +char *unctrl(char c); + #define A_CHARTEXT 0xff #define baudrate() 9600 -#define unctrl(a) "^x" #define getmaxx(a) COLS #define getmaxy(a) LINES #define getyx(win,_argfory,_argforx) _argfory = win->y, _argforx = win->x From 92e136108c905aa6f776f235f97849d20065a481 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:00:56 -1100 Subject: [PATCH 2304/3904] ^%% --- src/cc/rogue/cursesd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index ab57e2107..102e2bd7b 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -424,8 +424,7 @@ int32_t md_readchar(void) char *unctrl(char c) { - static char ctrlstr[3]; - ctrlstr[0] = '^'; - ctrlstr[1] = 'a' + c; + static char ctrlstr[5]; + sprintf(ctrlstr,"^%%%02x",c); return(ctrlstr); } From 12c97d71a744c7d458815fcdafd326b14dabedf1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:06:47 -1100 Subject: [PATCH 2305/3904] Dont loop on bad item select --- src/cc/rogue/pack.c | 106 +++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index d482a8a52..e4ceee689 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -410,59 +410,63 @@ get_item(struct rogue_state *rs,char *purpose, int type) { THING *obj; char ch; - + if (pack == NULL) - msg(rs,"you aren't carrying anything"); + msg(rs,"you aren't carrying anything"); else if (again) - if (last_pick) - return last_pick; - else - msg(rs,"you ran out"); - else - { - for (;;) - { - if (!terse) - addmsg(rs,"which object do you want to "); - addmsg(rs,purpose); - if (terse) - addmsg(rs," what"); - msg(rs,"? (* for list): "); - ch = readchar(rs); - mpos = 0; - /* - * Give the poor player a chance to abort the command - */ - if (ch == ESCAPE) - { - reset_last(); - after = FALSE; - msg(rs,""); - return NULL; - } - n_objs = 1; /* normal case: person types one char */ - if (ch == '*') - { - mpos = 0; - if (inventory(rs,pack, type) == 0) - { - after = FALSE; - return NULL; - } - continue; - } - for (obj = pack; obj != NULL; obj = next(obj)) - if (obj->o_packch == ch) - break; - if (obj == NULL) - { - msg(rs,"'%s' is not a valid item",unctrl(ch)); - continue; - } - else - return obj; - } - } + if (last_pick) + return last_pick; + else + msg(rs,"you ran out"); + else + { + for (;;) + { + if (!terse) + addmsg(rs,"which object do you want to "); + addmsg(rs,purpose); + if (terse) + addmsg(rs," what"); + msg(rs,"? (* for list): "); + ch = readchar(rs); + mpos = 0; + /* + * Give the poor player a chance to abort the command + */ + if (ch == ESCAPE) + { + reset_last(); + after = FALSE; + msg(rs,""); + return NULL; + } + n_objs = 1; /* normal case: person types one char */ + if (ch == '*') + { + mpos = 0; + if (inventory(rs,pack, type) == 0) + { + after = FALSE; + return NULL; + } + continue; + } + for (obj = pack; obj != NULL; obj = next(obj)) + if (obj->o_packch == ch) + break; + if (obj == NULL) + { + //msg(rs,"'%s' is not a valid item",unctrl(ch)); + //continue; + reset_last(); + after = FALSE; + msg(rs,"'%s' is not a valid item",unctrl(ch)); + return NULL; + } + else + return obj; + } + } return NULL; } From 5e543b34032b9d8e7a1833cf9ce9baf1e9e47001 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:12:46 -1100 Subject: [PATCH 2306/3904] <30000 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b5e669237..499f7fcda 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1241,7 +1241,7 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; - if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 20000 ) + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 30000 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) { From a9d9c7599dacc9fa962b33700cd84b47861a3537 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 18:14:32 +0100 Subject: [PATCH 2307/3904] Update Makefile_rogue --- src/cc/Makefile_rogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 7fb3f799f..543ab2895 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -4,7 +4,7 @@ CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -DBUILD_ROGUE -std=c++11 -arch x86_64 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared +CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/x86_64-w64-mingw32/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) From beb670166961a6d7f5f55e07d952333d27ba2a27 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:17:07 -1100 Subject: [PATCH 2308/3904] -print --- src/cc/rogue/cursesd.c | 2 +- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 102e2bd7b..202cc4acb 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 499f7fcda..b5e669237 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1241,7 +1241,7 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; - if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 30000 ) + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 20000 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) { From 82f46bd36fbbdb16e0bb2718bb132ff3b02e5057 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:22:01 -1100 Subject: [PATCH 2309/3904] -print --- src/cc/rogue_rpc.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b5e669237..694464c05 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -478,7 +478,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke playertxid = zeroid; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -490,26 +490,26 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke matches++; regslot = i; matchtx = spenttx; - } else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); - } else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); - } else fprintf(stderr,"%d+1 unspent\n",i); + } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"%d+1 unspent\n",i); } if ( matches == 1 ) { if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1) < 0 ) { @@ -542,9 +542,9 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); return(-5); } - fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); + //fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); } - fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -557,7 +557,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } @@ -830,16 +830,13 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; - fprintf(stderr,"calling validgame\n"); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) { - fprintf(stderr,"calling baton\n"); if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) { UniValue obj; - fprintf(stderr,"calling gamefields\n"); seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { From 4b966a1b3d3ca7f026b3255ed8ada2efb09a9ac6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:26:17 -1100 Subject: [PATCH 2310/3904] -print --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index cbcc67afd..21c229860 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -248,7 +248,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu { rs->P = *player; rs->restoring = 1; - fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); + //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); if ( rs->P.packsize > MAXPACK ) rs->P.packsize = MAXPACK; } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 694464c05..f4081330b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1223,14 +1223,14 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); - fprintf(stderr,"call extractgame\n"); + //fprintf(stderr,"call extractgame\n"); if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { free(keystrokes); - fprintf(stderr,"extracted.(%s)\n",str); + //fprintf(stderr,"extracted.(%s)\n",str); if ( newdata == playerdata ) return(0); - else fprintf(stderr,"newdata[%d] != playerdata[%d]\n",(int32_t)newdata.size(),(int32_t)playerdata.size()); + else fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys); } return(-1); } From 09e17f4c5fcbe21290b4d0a054a2d8f3146a2c85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:35:52 -1100 Subject: [PATCH 2311/3904] Playertxid --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f4081330b..6618d62a8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -502,7 +502,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; @@ -1220,7 +1220,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { - char str[512],*keystrokes,rogueaddr[64]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; + char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); //fprintf(stderr,"call extractgame\n"); @@ -1230,7 +1230,7 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector Date: Mon, 18 Feb 2019 06:42:03 -1100 Subject: [PATCH 2312/3904] +prints --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6618d62a8..3c7ce393e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -499,7 +499,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); @@ -560,7 +560,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); - } + } else fprintf(stderr,"error with playerdata\n"); } else fprintf(stderr,"findbaton opret error\n"); } else From 31a18239da2ab69cbb4ad37f8610e9161e5592e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:42:41 -1100 Subject: [PATCH 2313/3904] Ptr --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3c7ce393e..3da4b5977 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1230,7 +1230,7 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector Date: Mon, 18 Feb 2019 06:43:17 -1100 Subject: [PATCH 2314/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3da4b5977..a11319daa 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1230,7 +1230,7 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector Date: Mon, 18 Feb 2019 18:47:07 +0100 Subject: [PATCH 2315/3904] update win makefile --- zcutil/build-win.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zcutil/build-win.sh b/zcutil/build-win.sh index ef0c09549..8cf1751af 100755 --- a/zcutil/build-win.sh +++ b/zcutil/build-win.sh @@ -1,5 +1,5 @@ #!/bin/bash -HOST=x86_64-w64-mingw32 +export HOST=x86_64-w64-mingw32 CXX=x86_64-w64-mingw32-g++-posix CC=x86_64-w64-mingw32-gcc-posix PREFIX="$(pwd)/depends/$HOST" From 3b0f836867283e68528b7bebd7632ac760bd0554 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:51:31 -1100 Subject: [PATCH 2316/3904] Prints --- src/cc/rogue_rpc.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a11319daa..c3016c356 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -836,7 +836,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -1220,7 +1220,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { - char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; + char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; struct rogue_player P; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); //fprintf(stderr,"call extractgame\n"); @@ -1230,7 +1230,14 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector no playerdata\n"); + } + fprintf(stderr,"playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str()); } return(-1); } From 0d644e8be0518a2f54e732e6df27eb731f1dd2a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:52:11 -1100 Subject: [PATCH 2317/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c3016c356..5c149e19e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1220,7 +1220,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { - char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; struct rogue_player P; + char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; struct rogue_player P; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); //fprintf(stderr,"call extractgame\n"); From f70593d5fbe61a79eb16aff958da2f72c2610b57 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 06:52:44 -1100 Subject: [PATCH 2318/3904] Size --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5c149e19e..424799597 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1230,7 +1230,7 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector Date: Mon, 18 Feb 2019 07:02:58 -1100 Subject: [PATCH 2319/3904] Clear maxstre --- src/cc/rogue_rpc.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 424799597..1a60bc268 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1220,6 +1220,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { + static uint32_t good,bad; char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; struct rogue_player P; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); @@ -1229,7 +1230,18 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector no playerdata\n"); } fprintf(stderr,"playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str()); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str()); } return(-1); } From 9ff01f928fa9fcc3f6971b9b162011d6c5a1041e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 07:04:51 -1100 Subject: [PATCH 2320/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1a60bc268..3730d2aa2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1249,7 +1249,7 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector no playerdata\n"); } fprintf(stderr,"playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str()); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } return(-1); } From 68cd9e8792e742817c5c9ddcba8592e84dfb20ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 07:15:34 -1100 Subject: [PATCH 2321/3904] Test --- src/cc/rogue_rpc.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3730d2aa2..581603889 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1218,10 +1218,10 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) +int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; - char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; uint256 playertxid; CPubKey roguepk; struct rogue_player P; + char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; CPubKey roguepk; struct rogue_player P; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); //fprintf(stderr,"call extractgame\n"); @@ -1232,13 +1232,14 @@ int32_t rogue_playerdata_validate(struct CCcontract_info *cp,std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 20000 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) @@ -1336,10 +1337,10 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C // verify pk belongs to this tx if ( playerdata.size() > 0 ) { - if ( rogue_playerdata_validate(cp,playerdata,gametxid,pk) < 0 ) + if ( rogue_playerdata_validate(ptxid,cp,playerdata,gametxid,pk) < 0 ) { - fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)playerdata.size()); - } else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,playertxid.GetHex().c_str()); + fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + } else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,ptxid.GetHex().c_str()); } if ( funcid == 'Q' ) { From 3c9f9ce5542383ef69ac90dedd8c6937676d0f87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 07:24:05 -1100 Subject: [PATCH 2322/3904] -prints --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 21c229860..786718039 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -650,7 +650,7 @@ int32_t _quit() } else { - fprintf(stderr,"'Q' answer (%c)\n",c); + //fprintf(stderr,"'Q' answer (%c)\n",c); move(0, 0); clrtoeol(); status(rs); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 581603889..cf8e3feed 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -499,10 +499,10 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; @@ -836,7 +836,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -1339,8 +1339,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( rogue_playerdata_validate(ptxid,cp,playerdata,gametxid,pk) < 0 ) { - fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); - } else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,ptxid.GetHex().c_str()); + //fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + } //else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,ptxid.GetHex().c_str()); } if ( funcid == 'Q' ) { From 84dacb5ff8c0c8fdd6db19ae7da1cd54ab65b3b7 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 19:31:49 +0100 Subject: [PATCH 2323/3904] update Makefile_rogue --- src/cc/Makefile_rogue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 543ab2895..45efdc803 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -23,14 +23,15 @@ $(TARGET): $(SOURCES) ifeq ($(OS),Darwin) $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) -c $(SOURCES) -lncurses cp $(TARGET_DARWIN) ../libcc.dylib -else ifeq ($(OS),Linux) - $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) -lncurses - cp $(TARGET) ../libcc.so -#else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host -else +else ifeq ($(HOST),x86_64-w64-mingw32) $(info WINDOWS) $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) -lncurses - cp $(TARGET_WIN) ../libcc.dll + cp $(TARGET_WIN) ../libcc.dll +#else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host +else + $(info LINUX) + $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) -lncurses + cp $(TARGET) ../libcc.so endif clean: From 7e3a9acab7578eef88e3d507279ae94f8944d84f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 07:32:50 -1100 Subject: [PATCH 2324/3904] +gametxid --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cf8e3feed..45e67d286 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1232,14 +1232,14 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp if ( newdata == playerdata ) { good++; - fprintf(stderr,"good.%d bad.%d\n",good,bad); + fprintf(stderr,"%s good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); return(0); } newdata[10] = newdata[11] = playerdata[10] = playerdata[11] = 0; if ( newdata == playerdata ) { good++; - fprintf(stderr,"matched after clearing maxstrength good.%d bad.%d\n",good,bad); + fprintf(stderr,"%s matched after clearing maxstrength good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); return(0); } bad++; From 5bb65c9e8bb34c78bbf9df6dbd0850afd8fbd92a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 07:35:29 -1100 Subject: [PATCH 2325/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 45e67d286..9c4463930 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1258,7 +1258,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; - if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 20000 ) + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) { From 7b43e451d0b1a1003be23f031b58b8df0b60a54b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 07:39:50 -1100 Subject: [PATCH 2326/3904] -print --- src/cc/assets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 921d33d69..6e3fd5909 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -259,7 +259,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("invalid refund for cancelbuy"); preventCCvins = 3; preventCCvouts = 0; - fprintf(stderr,"cancelbuy validated to origaddr.(%s)\n",origNormalAddr); + //fprintf(stderr,"cancelbuy validated to origaddr.(%s)\n",origNormalAddr); break; case 'B': // fillbuy: From 6019a16cf161eddb3c4e6901dd9bfcfe3cb4bff7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 07:46:03 -1100 Subject: [PATCH 2327/3904] Test --- src/cc/rogue_rpc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9c4463930..d74bc9619 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1220,8 +1220,11 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { - static uint32_t good,bad; + static uint32_t good,bad; static uint256 prevgame; char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; CPubKey roguepk; struct rogue_player P; + if ( gametxid == prevgame ) + return(0); + prevgame = gametxid; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); //fprintf(stderr,"call extractgame\n"); @@ -1249,7 +1252,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp { fprintf(stderr,"zero value character was killed -> no playerdata\n"); } - fprintf(stderr,"playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } return(-1); From 8ac6e7458b2a3ffd982c2d3dd4151e63b9a17f9d Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 20:55:08 +0100 Subject: [PATCH 2328/3904] test --- src/cc/rogue/mdport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 9d6c7d2c6..f87650f38 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -33,7 +33,7 @@ #include #if defined(_WIN32) -#include +#include #include #include #include From 846e102e7b9b4774552ab05dabe4b319974b4772 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 22:13:28 +0100 Subject: [PATCH 2329/3904] fix --- src/cc/rogue/mdport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index f87650f38..d9c4e9c21 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -34,7 +34,7 @@ #if defined(_WIN32) #include -#include +#include #include #include #pragma warning( disable: 4201 ) From 10dfaedb062d1c7a8520d41a3ae9c5d72f8695d2 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 18 Feb 2019 23:23:26 +0100 Subject: [PATCH 2330/3904] fix --- src/cc/rogue/mdport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index d9c4e9c21..988e1c7b7 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -40,7 +40,7 @@ #pragma warning( disable: 4201 ) #include #pragma warning( default: 4201 ) -#include +#include #undef MOUSE_MOVED #endif From 640f3e0699cfd2d93c6ceb7a2c6977a0d7bb5bbe Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 00:15:41 +0100 Subject: [PATCH 2331/3904] resolve conflict --- src/cc/rogue_rpc.cpp | 121 +++++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 33 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ef24489ba..d74bc9619 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -265,7 +265,7 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, vout = i+1; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { - if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) { Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(myrogueaddr,destaddr) == 0 ) @@ -296,7 +296,7 @@ int32_t rogue_playersalive(int32_t &numplayers,uint256 gametxid,int32_t maxplaye uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) { CBlockIndex *pindex; int32_t ht,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; - if ( GetTransaction(gametxid,tx,hashBlock,false) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + if ( myGetTransaction(gametxid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { ht = pindex->GetHeight(); delay = ROGUE_REGISTRATION * (maxplayers > 1); @@ -329,7 +329,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { gameheight = komodo_blockheight(hashBlock); if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) >= txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) @@ -434,14 +434,14 @@ int32_t rogue_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firs int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,std::string &symbol,std::string &pname,uint256 playertxid) { uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; - if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 && (numvouts= playertx.vout.size()) > 0 ) + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 && (numvouts= playertx.vout.size()) > 0 ) { if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { if ( tokenid != zeroid ) { playertxid = tokenid; - if ( GetTransaction(playertxid,playertx,hashBlock,false) == 0 || (numvouts= playertx.vout.size()) <= 0 ) + if ( myGetTransaction(playertxid,playertx,hashBlock) == 0 || (numvouts= playertx.vout.size()) <= 0 ) { fprintf(stderr,"couldnt get tokenid.%s\n",playertxid.GetHex().c_str()); return(-2); @@ -478,9 +478,10 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke playertxid = zeroid; for (i=0; i= 0 ) { - if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) { numplayers++; Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); @@ -524,7 +525,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke txid = spenttxid; if ( spentvini != 0 ) return(-3); - if ( keystrokesp != 0 && GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() >= 2 ) + if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) { uint256 g,b; CPubKey p; std::vector k; if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) @@ -541,13 +542,14 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); return(-5); } + //fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); } //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander hashBlock = zeroid; - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 0 ) + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 0 ) { if ( hashBlock == zeroid ) batonht = komodo_nextheight(); @@ -555,10 +557,10 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - //printf("keystrokes[%d]\n",numkeys); + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); - } - } + } else fprintf(stderr,"couldnt find baton\n"); + } else fprintf(stderr,"error with playerdata\n"); } else fprintf(stderr,"findbaton opret error\n"); } else @@ -577,7 +579,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet destaddr[0] = 0; if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) { - if ( GetTransaction(spenttxid,spenttx,hashBlock,false) != 0 && spenttx.vout.size() > 0 ) + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); } obj.push_back(Pair("slot",(int64_t)vout-1)); @@ -585,7 +587,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet { if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 ) { - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && batontx.vout.size() > 1 ) + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 ) { if ( rogue_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) obj.push_back(Pair("status","registered")); @@ -758,7 +760,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( playertxid != zeroid ) { voutPubkeysEmpty.push_back(burnpk); - if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 ) { if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, vopretExtra)) != 0) { // if token in the opret @@ -834,7 +836,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -872,8 +874,8 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); } else num = 0; - } - } + } else fprintf(stderr,"extractgame: couldnt find baton\n"); + } else fprintf(stderr,"extractgame: invalid game\n"); *numkeysp = numkeys; return(keystrokes); } @@ -1174,7 +1176,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( vout == 0 ) { - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) { @@ -1216,9 +1218,51 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) +{ + static uint32_t good,bad; static uint256 prevgame; + char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; CPubKey roguepk; struct rogue_player P; + if ( gametxid == prevgame ) + return(0); + prevgame = gametxid; + roguepk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,rogueaddr,roguepk,pk); + //fprintf(stderr,"call extractgame\n"); + if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) + { + free(keystrokes); + //fprintf(stderr,"extracted.(%s)\n",str); + if ( newdata == playerdata ) + { + good++; + fprintf(stderr,"%s good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); + return(0); + } + newdata[10] = newdata[11] = playerdata[10] = playerdata[11] = 0; + if ( newdata == playerdata ) + { + good++; + fprintf(stderr,"%s matched after clearing maxstrength good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); + return(0); + } + bad++; + for (i=0; i no playerdata\n"); + } + fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + } + return(-1); +} + bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) + return(true); if ( (numvouts= tx.vout.size()) > 1 ) { scriptPubKey = tx.vout[numvouts-1].scriptPubKey; @@ -1233,10 +1277,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) { - funcid = 'Q'; fprintf(stderr,"ht.%d couldnt decode tokens opret (%c)\n",height,script[1]); - if ( height < 20000 ) - e = EVAL_ROGUE; } else e = EVAL_ROGUE, decoded = 1; } else e = EVAL_ROGUE, decoded = 1; } @@ -1250,8 +1291,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'G': if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' ) { - fprintf(stderr,"height.%d couldnt decode newgame opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode newgame opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode newgame opret"); } // validate newgame tx @@ -1260,8 +1301,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'R': if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) { - fprintf(stderr,"height.%d couldnt decode register opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode register opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode register opret"); } // validation is done below @@ -1269,8 +1310,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'K': if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) { - fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode keystrokes opret"); } // validate keystrokes are from the correct pk. might need to add vin @@ -1279,8 +1320,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'H': case 'Q': if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) { - fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); - if ( height > 20000 ) + //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); + //if ( height > 20000 ) return eval->Invalid("couldnt decode H/Q opret"); } // validation is done below @@ -1292,12 +1333,26 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } switch ( funcid ) { - case 'G': // newgame case 'R': // register - case 'K': // keystrokes + return(true); case 'H': // win case 'Q': // bailout - //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); + // verify pk belongs to this tx + if ( playerdata.size() > 0 ) + { + if ( rogue_playerdata_validate(ptxid,cp,playerdata,gametxid,pk) < 0 ) + { + //fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + } //else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,ptxid.GetHex().c_str()); + } + if ( funcid == 'Q' ) + { + // verify vin/vout + } + else // 'H' + { + // verify vin/vout + } return(true); break; default: From 7b8460cfaa7e3535918b9512be9aa66c8e03b5a5 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 01:33:03 +0100 Subject: [PATCH 2332/3904] update openssl --- depends/packages/openssl.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk index dec8ecef6..090090769 100644 --- a/depends/packages/openssl.mk +++ b/depends/packages/openssl.mk @@ -1,8 +1,8 @@ package=openssl -$(package)_version=1.1.0h +$(package)_version=1.1.1a $(package)_download_path=https://www.openssl.org/source $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=5835626cde9e99656585fc7aaa2302a73a7e1340bf8c14fd635a62c66802a517 +$(package)_sha256_hash=fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed3f9f41 define $(package)_set_vars $(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" From 7b6a6a729af6b646fd596899af9a7b010a070c03 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 01:38:02 +0100 Subject: [PATCH 2333/3904] update openssl --- depends/packages/openssl.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk index 090090769..e378088e6 100644 --- a/depends/packages/openssl.mk +++ b/depends/packages/openssl.mk @@ -92,7 +92,7 @@ $(package)_config_opts_i686_mingw32=mingw endef define $(package)_preprocess_cmds - sed -i.old "/define DATE/d" util/mkbuildinf.pl && \ + sed -i.old 's/built on: $date/built on: not available/' util/mkbuildinf.pl && \ sed -i.old "s|\"engines\", \"apps\", \"test\"|\"engines\"|" Configure endef From 599bb0b2e1de6822142a4c5d3dead7a7f9e594e4 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 01:52:16 +0100 Subject: [PATCH 2334/3904] update boost --- depends/packages/boost.mk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 8f3fd1b1c..7a0439ba7 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,9 +1,8 @@ - package=boost -$(package)_version=1_66_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.66.0/source +$(package)_version=1_69_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.69.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9 +$(package)_sha256_hash=8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 define $(package)_set_vars $(package)_config_opts_release=variant=release From a53eee78b5f4fdde9fad0ad49047695036cf8588 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 01:54:40 +0100 Subject: [PATCH 2335/3904] update rust --- depends/packages/rust.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/depends/packages/rust.mk b/depends/packages/rust.mk index a08ac2747..9cfb95054 100644 --- a/depends/packages/rust.mk +++ b/depends/packages/rust.mk @@ -1,13 +1,13 @@ package=rust -$(package)_version=1.28.0 +$(package)_version=1.32.0 $(package)_download_path=https://static.rust-lang.org/dist $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_linux=2a1390340db1d24a9498036884e6b2748e9b4b057fc5219694e298bdaa37b810 +$(package)_sha256_hash_linux=e024698320d76b74daf0e6e71be3681a1e7923122e3ebd03673fcac3ecc23810 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_darwin=5d7a70ed4701fe9410041c1eea025c95cad97e5b3d8acc46426f9ac4f9f02393 +$(package)_sha256_hash_darwin=f0dfba507192f9b5c330b5984ba71d57d434475f3d62bd44a39201e36fa76304 $(package)_file_name_mingw32=rust-$($(package)_version)-x86_64-pc-windows-gnu.tar.gz -$(package)_sha256_hash_mingw32=55c07426f791c51c8a2b6934b35784175c4abb4e03f123f3e847109c4dc1ad8b +$(package)_sha256_hash_mingw32=358e1435347c67dbf33aa9cad6fe501a833d6633ed5d5aa1863d5dffa0349be9 ifeq ($(build_os),darwin) $(package)_file_name=$($(package)_file_name_darwin) From c2665ae8bf7eaf4ed6792effaab934b28890a86d Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 02:15:13 +0100 Subject: [PATCH 2336/3904] update libsodium osx --- depends/packages/libsodium.mk | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 76f0d9a28..e63bff653 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -1,12 +1,3 @@ -ifeq ($(build_os),darwin) -package=libsodium -$(package)_version=1.0.11 -$(package)_download_path=https://supernetorg.bintray.com/misc -$(package)_file_name=libsodium-1.0.11.tar.gz -$(package)_sha256_hash=a14549db3c49f6ae2170cbbf4664bd48ace50681045e8dbea7c8d9fb96f9c765 -$(package)_dependencies= -$(package)_config_opts= -else package=libsodium $(package)_version=1.0.15 $(package)_download_path=https://download.libsodium.org/libsodium/releases/old @@ -14,7 +5,7 @@ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 $(package)_dependencies= $(package)_config_opts= -endif + define $(package)_preprocess_cmds cd $($(package)_build_subdir); ./autogen.sh From 8003443417cd7f8f35cb8de12c055aac67ce5099 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 19 Feb 2019 10:16:31 +0800 Subject: [PATCH 2337/3904] setpubkey fix --- src/komodo.h | 1 - src/wallet/rpcwallet.cpp | 66 +++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 93e0d9eb2..8f4217cc4 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -878,7 +878,6 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) break; } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. - // make sure for first 3 notarizations, that we check all tx in block! if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) break; txhash = block.vtx[i].GetHash(); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e7b76afc0..4f94ae8a3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5430,50 +5430,54 @@ UniValue setpubkey(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); - char Raddress[18]; + char Raddress[64]; uint8_t pubkey33[33]; - if ( NOTARY_PUBKEY33[0] == 0 ) { - if (strlen(params[0].get_str().c_str()) == 66) { + if ( NOTARY_PUBKEY33[0] == 0 ) + { + if (strlen(params[0].get_str().c_str()) == 66) + { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { - result.push_back(Pair("error", "pubkey entered is invalid.")); - } else { - CBitcoinAddress address(Raddress); - bool isValid = address.IsValid(); - if (isValid) + CBitcoinAddress address(Raddress); + bool isValid = address.IsValid(); + if (isValid) + { + CTxDestination dest = address.Get(); + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + if ( mine == ISMINE_NO ) + result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); + else { - CTxDestination dest = address.Get(); - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - if ( mine == ISMINE_NO ) { - result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); - } else { - result.push_back(Pair("ismine", "true")); - std::string notaryname; - if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { - result.push_back(Pair("IsNotary", notaryname)); - IS_KOMODO_NOTARY = 0; - } + result.push_back(Pair("ismine", "true")); + std::string notaryname; + if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) + { + result.push_back(Pair("IsNotary", notaryname)); + IS_KOMODO_NOTARY = 0; } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - USE_EXTERNAL_PUBKEY = 1; - NOTARY_ADDRESS = address.ToString(); - } else { - result.push_back(Pair("error", "pubkey entered is invalid.")); } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + USE_EXTERNAL_PUBKEY = 1; + NOTARY_ADDRESS = address.ToString(); } - } else { - result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); + else + result.push_back(Pair("error", "pubkey entered is invalid.")); } - } else { - if ( NOTARY_ADDRESS.empty() ) { + else + result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); + } + else + { + if ( NOTARY_ADDRESS.empty() ) + { pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); } result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { + if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) + { result.push_back(Pair("address", NOTARY_ADDRESS)); result.push_back(Pair("pubkey", NOTARY_PUBKEY)); } From a14c2a2af5ce107988fc0b2fd31a75413746493b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 19 Feb 2019 11:45:14 +0800 Subject: [PATCH 2338/3904] ? --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4f94ae8a3..1c7114c34 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5466,7 +5466,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) } else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } + } else { if ( NOTARY_ADDRESS.empty() ) From 70b684eeaacf986ee8438e60426cf65d15de82fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 19 Feb 2019 12:32:58 +0800 Subject: [PATCH 2339/3904] add more descriptive print for expired transactions in mempool. --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index de9ad9c9f..6bee5855c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1111,7 +1111,8 @@ bool ContextualCheckTransaction( if (IsExpiredTx(tx, nHeight)) { // Don't increase banscore if the transaction only just expired int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? (dosLevel > 10 ? dosLevel : 10) : 0; - return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired"); + + return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight), REJECT_INVALID, "tx-overwinter-expired"); } } From aa60acbf2764632b9e0a206364a959f503f0c729 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 21:15:47 -1100 Subject: [PATCH 2340/3904] ROGUE_MAXTOTAL = strength*2, ISMANY -> 1 --- src/cc/rogue/init.c | 11 +++++++++-- src/cc/rogue/pack.c | 6 +++--- src/cc/rogue/rogue.h | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 30370f958..ffc0b3707 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -22,6 +22,13 @@ */ void rogue_restoreobject(THING *o,struct rogue_packitem *item); +int32_t rogue_total(THING *o) +{ + if ( (o->o_flags & ISMANY) != 0 ) + return(1); + else return(o->o_count); +} + void restore_player(struct rogue_state *rs) { int32_t i,total = 0; THING *obj; @@ -38,8 +45,8 @@ void restore_player(struct rogue_state *rs) { obj = new_item(); rogue_restoreobject(obj,&rs->P.roguepack[i]); - total += obj->o_count; - if ( total > pstats.s_str*3 ) + total += rogue_total(obj); + if ( total > ROGUE_MAXTOTAL ) break; add_pack(rs,obj,TRUE); } diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index e4ceee689..776669b3b 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -166,16 +166,16 @@ int32_t num_packitems(struct rogue_state *rs) if ( list->o_packch != 0 ) { n++; - total += list->o_count; + total += rogue_total(list); } } if ( rs->guiflag != 0 ) { char str[MAXSTR]; - sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); + sprintf(str,"strength*2 %d vs total.%d vs %d inventory letters\n",ROGUE_MAXTOTAL,total,n); add_line(rs,"%s",str); } - if ( total > pstats.s_str*3 ) + if ( total > ROGUE_MAXTOTAL ) return(MAXPACK); return(n); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 515c1d44a..9339b630f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -381,6 +381,9 @@ void restore_player(struct rogue_state *rs); int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); void rogue_bailout(struct rogue_state *rs); +#define ROGUE_MAXTOTAL (pstats.s_str*2) +int32_t rogue_total(THING *o); + /* * Help list */ From f77c99d7817ea50bb83c6d1d3929434016a8fe3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 21:16:32 -1100 Subject: [PATCH 2341/3904] int32_t rogue_total(THING *o); --- src/cc/rogue/rogue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 9339b630f..f687b170c 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -382,7 +382,6 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu void rogue_bailout(struct rogue_state *rs); #define ROGUE_MAXTOTAL (pstats.s_str*2) -int32_t rogue_total(THING *o); /* * Help list @@ -806,6 +805,7 @@ THING *new_item(void); THING *new_thing(struct rogue_state *rs); void end_line(struct rogue_state *rs); int32_t num_packitems(struct rogue_state *rs); +int32_t rogue_total(THING *o); void runners(struct rogue_state *rs,int); void land(struct rogue_state *rs,int); From 2c6640cdd4c7774a25cce074be62ea3fd772563f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 22:21:26 -1100 Subject: [PATCH 2342/3904] Change multiplayer payout to 2x, if amulet then 10x --- src/cc/rogue/rogue_player.h | 2 +- src/cc/rogue/state.c | 1 + src/cc/rogue_rpc.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue_player.h b/src/cc/rogue/rogue_player.h index 1319b3213..e6b7a69e6 100644 --- a/src/cc/rogue/rogue_player.h +++ b/src/cc/rogue/rogue_player.h @@ -25,7 +25,7 @@ struct rogue_packitem }; struct rogue_player { - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; struct rogue_packitem roguepack[MAXPACK]; }; int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 778540b68..589f77422 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1452,6 +1452,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; + rs->P.amulet = amulet; //fprintf(stderr,"%ld gold.%d hp.%d strength.%d/%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d74bc9619..a7bbaa489 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -957,7 +957,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param else { funcid = 'H'; - mult = 1000000; + mult = 200000; } if ( (params= cclib_reparse(&n,params)) != 0 ) { @@ -1008,11 +1008,13 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); + if ( P.amulet != 0 ) + mult *= 5; cashout = (uint64_t)P.gold * mult; if ( funcid == 'H' && maxplayers > 1 ) { - if ( numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1 && (P.dungeonlevel > 1 || P.gold < 10000 || P.level < 20) ) + if ( (numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1) && P.amulet == 0 ) return(cclib_error(result,"highlander must be a winner or last one standing")); cashout += numplayers * buyin; } From 1c85c52f49c17e7520ff253aaeee70d37a9233d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:04:17 -1100 Subject: [PATCH 2343/3904] You can ignore ./makerogue: shell: not found --- src/cc/makerogue | 1 + src/cc/rogue_rpc.cpp | 50 ++++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 249e646f5..fb7a53cec 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,4 +1,5 @@ #!/bin/sh +echo "you can ignore ./makerogue: shell: not found" cd rogue; ./configure # only need this first time make; cd .. diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a7bbaa489..1ca1bce88 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -325,18 +325,20 @@ uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 return(seed); } -int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid) +int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0) { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { gameheight = komodo_blockheight(hashBlock); - if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) >= txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(playertxid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { - if ( numvouts > maxplayers+1 ) + if ( maxplayers < 1 || maxplayers > ROGUE_MAXPLAYERS || buyin < 0 ) + return(-6); + if ( numvouts > 2*maxplayers+1 ) { for (i=0; i 0 ) { gametxid = juint256(jitem(params,0)); - if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid)) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1)) == 0 ) { if ( n > 1 ) { @@ -803,7 +806,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,destaddr,roguepk,mypk); - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1) == 0 ) { if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) { @@ -811,7 +814,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("playertxid",playertxid.GetHex())); if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { - mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); + mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); // this validates user mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,roguepk,mypk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); @@ -830,7 +833,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) { if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) { @@ -965,7 +968,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,1)) == 0 ) { if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 ) { @@ -1078,7 +1081,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { txid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",txid.GetHex())); - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,0) == 0 ) { result.push_back(Pair("result","success")); result.push_back(Pair("gameheight",(int64_t)gameheight)); @@ -1118,7 +1121,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers continue; - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && nextheight <= gameheight+ROGUE_MAXKEYSTROKESGAP ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,1) == 0 && nextheight <= gameheight+ROGUE_MAXKEYSTROKESGAP ) { rogue_playersalive(numplayers,txid,maxplayers); if ( numplayers < maxplayers ) @@ -1182,7 +1185,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) { - if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) { if ( CCgettxout(txid,vout,1) < 0 ) b.push_back(gametxid.GetHex()); @@ -1262,7 +1265,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errs,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) @@ -1291,13 +1294,12 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'G': - if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { - //fprintf(stderr,"height.%d couldnt decode newgame opret\n",height); + fprintf(stderr,"height.%d rogue_isvalidgame error.%d\n",height,err); //if ( height > 20000 ) - return eval->Invalid("couldnt decode newgame opret"); + return eval->Invalid("invalid gametxid"); } - // validate newgame tx return(true); break; case 'R': @@ -1307,6 +1309,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C //if ( height > 20000 ) return eval->Invalid("couldnt decode register opret"); } + // baton is created // validation is done below break; case 'K': @@ -1316,7 +1319,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C //if ( height > 20000 ) return eval->Invalid("couldnt decode keystrokes opret"); } - // validate keystrokes are from the correct pk. might need to add vin + // spending the baton proves it is the user if the pk is the signer return(true); break; case 'H': case 'Q': @@ -1326,7 +1329,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C //if ( height > 20000 ) return eval->Invalid("couldnt decode H/Q opret"); } - // validation is done below + // spending the baton proves it is the user if the pk is the signer + // rest of validation is done below break; default: return eval->Invalid("illegal rogue non-decoded funcid"); @@ -1353,7 +1357,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } else // 'H' { - // verify vin/vout + // verify vin/vout and proper payouts } return(true); break; From fed6024ee745bf526d543ba70f9253239b09a6c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:05:43 -1100 Subject: [PATCH 2344/3904] err --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1ca1bce88..b5e44aad5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -332,7 +332,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { gameheight = komodo_blockheight(hashBlock); - if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(playertxid,0,1) == txfee) ) + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { @@ -1265,7 +1265,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errs,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) From 9377ec6542066c435b6660797d38ccd92393175d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:06:36 -1100 Subject: [PATCH 2345/3904] Ignore --- src/cc/makerogue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index fb7a53cec..d737f39fa 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,9 +1,8 @@ #!/bin/sh -echo "you can ignore ./makerogue: shell: not found" cd rogue; ./configure # only need this first time +echo "you can ignore ./makerogue: shell: not found" make; cd .. gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From 0ca1b888c395737651ddf73b4592d4021e3c7c30 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:10:55 -1100 Subject: [PATCH 2346/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b5e44aad5..510b67727 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1297,7 +1297,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { fprintf(stderr,"height.%d rogue_isvalidgame error.%d\n",height,err); - //if ( height > 20000 ) + if ( height > 30000 ) return eval->Invalid("invalid gametxid"); } return(true); From 60e6554848eacda156de40263806f6966ca315a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:16:24 -1100 Subject: [PATCH 2347/3904] Test --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 510b67727..d4ee66b57 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1294,12 +1294,14 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'G': + gametxid = tx.GetHash(); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { - fprintf(stderr,"height.%d rogue_isvalidgame error.%d\n",height,err); + fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); if ( height > 30000 ) return eval->Invalid("invalid gametxid"); } + fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': From 79e09db7e6a8a0b1c35fc5a3d75bd54f2ae9497d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:28:25 -1100 Subject: [PATCH 2348/3904] +print --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d4ee66b57..f7ac0162a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -814,7 +814,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("playertxid",playertxid.GetHex())); if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { - mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); // this validates user + mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); //this validates user if pk mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,roguepk,mypk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); @@ -1293,7 +1293,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { switch ( funcid ) { - case 'G': + case 'G': // seems just need to make sure no vout abuse is left to do gametxid = tx.GetHash(); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { @@ -1301,7 +1301,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( height > 30000 ) return eval->Invalid("invalid gametxid"); } - fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); + //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': @@ -1342,6 +1342,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'R': // register + // verify vout amounts are as they should be and no vins that shouldnt be return(true); case 'H': // win case 'Q': // bailout From 961a1eb0a2b1967cfdb74fe548f661fd3b5a7713 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:28:46 -1100 Subject: [PATCH 2349/3904] Enforce new game --- src/cc/rogue_rpc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f7ac0162a..ec1b669dc 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1298,8 +1298,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); - if ( height > 30000 ) - return eval->Invalid("invalid gametxid"); + return eval->Invalid("invalid gametxid"); } //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); From f3c28c684a58e4601e439be6200f8365aac0d6fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 00:07:07 -1100 Subject: [PATCH 2350/3904] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ec1b669dc..9cef26d83 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1288,7 +1288,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } if ( e == EVAL_ROGUE ) { - fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); + //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); if ( decoded == 0 ) { switch ( funcid ) From d0888260aa142faab3044a6ea0876a2ed5849a61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:24:08 -1100 Subject: [PATCH 2351/3904] +print validgame --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9cef26d83..d1c63f592 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1300,7 +1300,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); } - //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); + fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': From ef05677ec88427b56d6083c6711a0de05af00297 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:24:32 -1100 Subject: [PATCH 2352/3904] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d1c63f592..9cef26d83 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1300,7 +1300,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); } - fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); + //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': From ee5d656a2c1c7df3160281939ebebeab3fbeba8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:31:02 -1100 Subject: [PATCH 2353/3904] Rework game validation --- src/cc/rogue_rpc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9cef26d83..78541b63c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -329,9 +329,10 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; - if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( (txid == zeroid || myGetTransaction(txid,tx,hashBlock) != 0) && (numvouts= tx.vout.size()) > 1 ) { - gameheight = komodo_blockheight(hashBlock); + if ( txid != zeroid ) + gameheight = komodo_blockheight(hashBlock); if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) @@ -1295,7 +1296,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { case 'G': // seems just need to make sure no vout abuse is left to do gametxid = tx.GetHash(); - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) + gameheight = height; + if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zerotxid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); From 67eb2929d63534398efdea4007c7d6192b598634 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:31:56 -1100 Subject: [PATCH 2354/3904] Zeroed --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 78541b63c..9d493e5ae 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1297,7 +1297,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'G': // seems just need to make sure no vout abuse is left to do gametxid = tx.GetHash(); gameheight = height; - if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zerotxid,0)) != 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zeroid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); From 92c9825cdea8ad8be5a00b7f74412556840d69a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:41:28 -1100 Subject: [PATCH 2355/3904] Test --- src/cc/rogue_rpc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9d493e5ae..50492e2cf 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -333,6 +333,11 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa { if ( txid != zeroid ) gameheight = komodo_blockheight(hashBlock); + else + { + txid = tx.GetHash(); + fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); + } if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) From fbe6061dc6e76a292ae49e284a1354dc2de4f8b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:42:45 -1100 Subject: [PATCH 2356/3904] Test --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 50492e2cf..2496d6a5e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1300,9 +1300,10 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'G': // seems just need to make sure no vout abuse is left to do + gametx = tx; gametxid = tx.GetHash(); gameheight = height; - if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zeroid,0)) != 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,zeroid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); From 180114697aaf5f7ff6ee96ec51722e1150aeea42 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:44:36 -1100 Subject: [PATCH 2357/3904] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2496d6a5e..3d89e0568 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -336,7 +336,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa else { txid = tx.GetHash(); - fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); + //fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); } if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { From 2ca8d1eedaef49bccd8622bc8f61a6d6fa4c6dc9 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 14:15:09 +0100 Subject: [PATCH 2358/3904] resolve conflict PR for multi OS build will follow this PR --- src/cc/makerogue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index d737f39fa..a38eab6a4 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,8 +1,11 @@ #!/bin/sh cd rogue; -./configure # only need this first time -echo "you can ignore ./makerogue: shell: not found" +./configure make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -cp librogue.so ../libcc.so +if make -f Makefile_rogue "$@"; then + echo ROGUE BUILD SUCCESSFUL +else + echo ROGUE BUILD FAILED + exit 1 +fi From 7bf6996468e9e31689cee2c4171b463e7cd94a97 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 16:02:03 +0100 Subject: [PATCH 2359/3904] update libsodium --- depends/packages/libsodium.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index e63bff653..179ebe86c 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -6,6 +6,13 @@ $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe $(package)_dependencies= $(package)_config_opts= +ifeq ($(build_os),darwin) +define $(package)_set_vars + $(package)_build_env=MACOSX_DEPLOYMENT_TARGET="10.11" + $(package)_cc=clang + $(package)_cxx=clang++ +endef +endif define $(package)_preprocess_cmds cd $($(package)_build_subdir); ./autogen.sh From 4bf1256a68a0248dfdc9b54b8e31dbe759cf073b Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 16:57:47 +0100 Subject: [PATCH 2360/3904] add ifndef WIN --- src/cc/rogue/cursesd.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 87304cfa6..cb74941e5 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -48,7 +48,10 @@ extern WINDOW *stdscr,*curscr; extern int32_t ESCDELAY; typedef char chtype; +#ifndef __MINGW32__ int32_t getch(void); // stub +#endif + int32_t md_readchar(void); // stub WINDOW *initscr(void); From c127a8f0b5bfd89e76364e6432c8a70b5eb3a203 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 06:34:34 -1100 Subject: [PATCH 2361/3904] ENABLE_MODULE_MUSIG --- src/secp256k1/Makefile.am | 5 + src/secp256k1/src/ecmult.h | 55 + src/secp256k1/src/ecmult_impl.h | 1176 +++++++++++++++++ .../src/modules/musig/Makefile.am.include | 17 + src/secp256k1/src/modules/musig/example.c | 166 +++ src/secp256k1/src/modules/musig/main_impl.h | 631 +++++++++ src/secp256k1/src/modules/musig/tests_impl.h | 758 +++++++++++ .../modules/schnorrsig/Makefile.am.include | 9 + .../src/modules/schnorrsig/main_impl.h | 339 +++++ .../src/modules/schnorrsig/tests_impl.h | 727 ++++++++++ src/secp256k1/src/scalar.h | 235 ++++ src/secp256k1/src/scalar_4x64.h | 49 + src/secp256k1/src/scalar_4x64_impl.h | 1056 +++++++++++++++ src/secp256k1/src/scalar_8x32.h | 24 + src/secp256k1/src/scalar_8x32_impl.h | 838 ++++++++++++ src/secp256k1/src/scalar_impl.h | 340 +++++ src/secp256k1/src/scalar_low.h | 20 + src/secp256k1/src/scalar_low_impl.h | 126 ++ 18 files changed, 6571 insertions(+) create mode 100644 src/secp256k1/src/modules/musig/Makefile.am.include create mode 100644 src/secp256k1/src/modules/musig/example.c create mode 100644 src/secp256k1/src/modules/musig/main_impl.h create mode 100644 src/secp256k1/src/modules/musig/tests_impl.h create mode 100644 src/secp256k1/src/modules/schnorrsig/Makefile.am.include create mode 100644 src/secp256k1/src/modules/schnorrsig/main_impl.h create mode 100644 src/secp256k1/src/modules/schnorrsig/tests_impl.h diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index c071fbe27..ff5a2c50c 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -172,6 +172,11 @@ if ENABLE_MODULE_ECDH include src/modules/ecdh/Makefile.am.include endif +if ENABLE_MODULE_MUSIG +include src/modules/schnorrsig/Makefile.am.include +include src/modules/musig/Makefile.am.include +endif + if ENABLE_MODULE_RECOVERY include src/modules/recovery/Makefile.am.include endif diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 6d44aba60..7fe619b21 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -29,3 +31,56 @@ static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng); #endif /* SECP256K1_ECMULT_H */ + +#else +/********************************************************************** + * Copyright (c) 2013, 2014, 2017 Pieter Wuille, Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_ECMULT_H +#define SECP256K1_ECMULT_H + +#include "num.h" +#include "group.h" +#include "scalar.h" +#include "scratch.h" + +typedef struct { + /* For accelerating the computation of a*P + b*G: */ + secp256k1_ge_storage (*pre_g)[]; /* odd multiples of the generator */ +#ifdef USE_ENDOMORPHISM + secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */ +#endif +} secp256k1_ecmult_context; + +static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx); +static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb); +static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, + const secp256k1_ecmult_context *src, const secp256k1_callback *cb); +static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx); +static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx); + +/** Double multiply: R = na*A + ng*G */ +static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng); + +typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); + +/** + * Multi-multiply: R = inp_g_sc * G + sum_i ni * Ai. + * Chooses the right algorithm for a given number of points and scratch space + * size. Resets and overwrites the given scratch space. If the points do not + * fit in the scratch space the algorithm is repeatedly run with batches of + * points. If no scratch space is given then a simple algorithm is used that + * simply multiplies the points with the corresponding scalars and adds them up. + * Returns: 1 on success (including when inp_g_sc is NULL and n is 0) + * 0 if there is not enough scratch space for a single point or + * callback returns 0 + */ +static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); + +#endif /* SECP256K1_ECMULT_H */ + +#endif + diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 93d3794cb..6c9a1daf2 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1,3 +1,6 @@ +#ifndef ENABLE_MODULE_MUSIG + + /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -404,3 +407,1176 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej } #endif /* SECP256K1_ECMULT_IMPL_H */ + +#else + +/***************************************************************************** + * Copyright (c) 2013, 2014, 2017 Pieter Wuille, Andrew Poelstra, Jonas Nick * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php. * + *****************************************************************************/ + +#ifndef SECP256K1_ECMULT_IMPL_H +#define SECP256K1_ECMULT_IMPL_H + +#include +#include + +#include "group.h" +#include "scalar.h" +#include "ecmult.h" + +#if defined(EXHAUSTIVE_TEST_ORDER) +/* We need to lower these values for exhaustive tests because + * the tables cannot have infinities in them (this breaks the + * affine-isomorphism stuff which tracks z-ratios) */ +# if EXHAUSTIVE_TEST_ORDER > 128 +# define WINDOW_A 5 +# define WINDOW_G 8 +# elif EXHAUSTIVE_TEST_ORDER > 8 +# define WINDOW_A 4 +# define WINDOW_G 4 +# else +# define WINDOW_A 2 +# define WINDOW_G 2 +# endif +#else +/* optimal for 128-bit and 256-bit exponents. */ +#define WINDOW_A 5 +/** larger numbers may result in slightly better performance, at the cost of + exponentially larger precomputed tables. */ +#ifdef USE_ENDOMORPHISM +/** Two tables for window size 15: 1.375 MiB. */ +#define WINDOW_G 15 +#else +/** One table for window size 16: 1.375 MiB. */ +#define WINDOW_G 16 +#endif +#endif + +#ifdef USE_ENDOMORPHISM +#define WNAF_BITS 128 +#else +#define WNAF_BITS 256 +#endif +#define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) +#define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) + +/** The number of entries a table with precomputed multiples needs to have. */ +#define ECMULT_TABLE_SIZE(w) (1 << ((w)-2)) + +/* The number of objects allocated on the scratch space for ecmult_multi algorithms */ +#define PIPPENGER_SCRATCH_OBJECTS 6 +#define STRAUSS_SCRATCH_OBJECTS 6 + +#define PIPPENGER_MAX_BUCKET_WINDOW 12 + +/* Minimum number of points for which pippenger_wnaf is faster than strauss wnaf */ +#ifdef USE_ENDOMORPHISM +#define ECMULT_PIPPENGER_THRESHOLD 88 +#else +#define ECMULT_PIPPENGER_THRESHOLD 160 +#endif + +#ifdef USE_ENDOMORPHISM +#define ECMULT_MAX_POINTS_PER_BATCH 5000000 +#else +#define ECMULT_MAX_POINTS_PER_BATCH 10000000 +#endif + +/** Fill a table 'prej' with precomputed odd multiples of a. Prej will contain + * the values [1*a,3*a,...,(2*n-1)*a], so it space for n values. zr[0] will + * contain prej[0].z / a.z. The other zr[i] values = prej[i].z / prej[i-1].z. + * Prej's Z values are undefined, except for the last value. + */ +static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_gej *prej, secp256k1_fe *zr, const secp256k1_gej *a) { + secp256k1_gej d; + secp256k1_ge a_ge, d_ge; + int i; + + VERIFY_CHECK(!a->infinity); + + secp256k1_gej_double_var(&d, a, NULL); + + /* + * Perform the additions on an isomorphism where 'd' is affine: drop the z coordinate + * of 'd', and scale the 1P starting value's x/y coordinates without changing its z. + */ + d_ge.x = d.x; + d_ge.y = d.y; + d_ge.infinity = 0; + + secp256k1_ge_set_gej_zinv(&a_ge, a, &d.z); + prej[0].x = a_ge.x; + prej[0].y = a_ge.y; + prej[0].z = a->z; + prej[0].infinity = 0; + + zr[0] = d.z; + for (i = 1; i < n; i++) { + secp256k1_gej_add_ge_var(&prej[i], &prej[i-1], &d_ge, &zr[i]); + } + + /* + * Each point in 'prej' has a z coordinate too small by a factor of 'd.z'. Only + * the final point's z coordinate is actually used though, so just update that. + */ + secp256k1_fe_mul(&prej[n-1].z, &prej[n-1].z, &d.z); +} + +/** Fill a table 'pre' with precomputed odd multiples of a. + * + * There are two versions of this function: + * - secp256k1_ecmult_odd_multiples_table_globalz_windowa which brings its + * resulting point set to a single constant Z denominator, stores the X and Y + * coordinates as ge_storage points in pre, and stores the global Z in rz. + * It only operates on tables sized for WINDOW_A wnaf multiples. + * - secp256k1_ecmult_odd_multiples_table_storage_var, which converts its + * resulting point set to actually affine points, and stores those in pre. + * It operates on tables of any size, but uses heap-allocated temporaries. + * + * To compute a*P + b*G, we compute a table for P using the first function, + * and for G using the second (which requires an inverse, but it only needs to + * happen once). + */ +static void secp256k1_ecmult_odd_multiples_table_globalz_windowa(secp256k1_ge *pre, secp256k1_fe *globalz, const secp256k1_gej *a) { + secp256k1_gej prej[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_fe zr[ECMULT_TABLE_SIZE(WINDOW_A)]; + + /* Compute the odd multiples in Jacobian form. */ + secp256k1_ecmult_odd_multiples_table(ECMULT_TABLE_SIZE(WINDOW_A), prej, zr, a); + /* Bring them to the same Z denominator. */ + secp256k1_ge_globalz_set_table_gej(ECMULT_TABLE_SIZE(WINDOW_A), pre, globalz, prej, zr); +} + +static void secp256k1_ecmult_odd_multiples_table_storage_var(const int n, secp256k1_ge_storage *pre, const secp256k1_gej *a) { + secp256k1_gej d; + secp256k1_ge d_ge, p_ge; + secp256k1_gej pj; + secp256k1_fe zi; + secp256k1_fe zr; + secp256k1_fe dx_over_dz_squared; + int i; + + VERIFY_CHECK(!a->infinity); + + secp256k1_gej_double_var(&d, a, NULL); + + /* First, we perform all the additions in an isomorphic curve obtained by multiplying + * all `z` coordinates by 1/`d.z`. In these coordinates `d` is affine so we can use + * `secp256k1_gej_add_ge_var` to perform the additions. For each addition, we store + * the resulting y-coordinate and the z-ratio, since we only have enough memory to + * store two field elements. These are sufficient to efficiently undo the isomorphism + * and recompute all the `x`s. + */ + d_ge.x = d.x; + d_ge.y = d.y; + d_ge.infinity = 0; + + secp256k1_ge_set_gej_zinv(&p_ge, a, &d.z); + pj.x = p_ge.x; + pj.y = p_ge.y; + pj.z = a->z; + pj.infinity = 0; + + for (i = 0; i < (n - 1); i++) { + secp256k1_fe_normalize_var(&pj.y); + secp256k1_fe_to_storage(&pre[i].y, &pj.y); + secp256k1_gej_add_ge_var(&pj, &pj, &d_ge, &zr); + secp256k1_fe_normalize_var(&zr); + secp256k1_fe_to_storage(&pre[i].x, &zr); + } + + /* Invert d.z in the same batch, preserving pj.z so we can extract 1/d.z */ + secp256k1_fe_mul(&zi, &pj.z, &d.z); + secp256k1_fe_inv_var(&zi, &zi); + + /* Directly set `pre[n - 1]` to `pj`, saving the inverted z-coordinate so + * that we can combine it with the saved z-ratios to compute the other zs + * without any more inversions. */ + secp256k1_ge_set_gej_zinv(&p_ge, &pj, &zi); + secp256k1_ge_to_storage(&pre[n - 1], &p_ge); + + /* Compute the actual x-coordinate of D, which will be needed below. */ + secp256k1_fe_mul(&d.z, &zi, &pj.z); /* d.z = 1/d.z */ + secp256k1_fe_sqr(&dx_over_dz_squared, &d.z); + secp256k1_fe_mul(&dx_over_dz_squared, &dx_over_dz_squared, &d.x); + + /* Going into the second loop, we have set `pre[n-1]` to its final affine + * form, but still need to set `pre[i]` for `i` in 0 through `n-2`. We + * have `zi = (p.z * d.z)^-1`, where + * + * `p.z` is the z-coordinate of the point on the isomorphic curve + * which was ultimately assigned to `pre[n-1]`. + * `d.z` is the multiplier that must be applied to all z-coordinates + * to move from our isomorphic curve back to secp256k1; so the + * product `p.z * d.z` is the z-coordinate of the secp256k1 + * point assigned to `pre[n-1]`. + * + * All subsequent inverse-z-coordinates can be obtained by multiplying this + * factor by successive z-ratios, which is much more efficient than directly + * computing each one. + * + * Importantly, these inverse-zs will be coordinates of points on secp256k1, + * while our other stored values come from computations on the isomorphic + * curve. So in the below loop, we will take care not to actually use `zi` + * or any derived values until we're back on secp256k1. + */ + i = n - 1; + while (i > 0) { + secp256k1_fe zi2, zi3; + const secp256k1_fe *rzr; + i--; + + secp256k1_ge_from_storage(&p_ge, &pre[i]); + + /* For each remaining point, we extract the z-ratio from the stored + * x-coordinate, compute its z^-1 from that, and compute the full + * point from that. */ + rzr = &p_ge.x; + secp256k1_fe_mul(&zi, &zi, rzr); + secp256k1_fe_sqr(&zi2, &zi); + secp256k1_fe_mul(&zi3, &zi2, &zi); + /* To compute the actual x-coordinate, we use the stored z ratio and + * y-coordinate, which we obtained from `secp256k1_gej_add_ge_var` + * in the loop above, as well as the inverse of the square of its + * z-coordinate. We store the latter in the `zi2` variable, which is + * computed iteratively starting from the overall Z inverse then + * multiplying by each z-ratio in turn. + * + * Denoting the z-ratio as `rzr`, we observe that it is equal to `h` + * from the inside of the above `gej_add_ge_var` call. This satisfies + * + * rzr = d_x * z^2 - x * d_z^2 + * + * where (`d_x`, `d_z`) are Jacobian coordinates of `D` and `(x, z)` + * are Jacobian coordinates of our desired point -- except both are on + * the isomorphic curve that we were using when we called `gej_add_ge_var`. + * To get back to secp256k1, we must multiply both `z`s by `d_z`, or + * equivalently divide both `x`s by `d_z^2`. Our equation then becomes + * + * rzr = d_x * z^2 / d_z^2 - x + * + * (The left-hand-side, being a ratio of z-coordinates, is unaffected + * by the isomorphism.) + * + * Rearranging to solve for `x`, we have + * + * x = d_x * z^2 / d_z^2 - rzr + * + * But what we actually want is the affine coordinate `X = x/z^2`, + * which will satisfy + * + * X = d_x / d_z^2 - rzr / z^2 + * = dx_over_dz_squared - rzr * zi2 + */ + secp256k1_fe_mul(&p_ge.x, rzr, &zi2); + secp256k1_fe_negate(&p_ge.x, &p_ge.x, 1); + secp256k1_fe_add(&p_ge.x, &dx_over_dz_squared); + /* y is stored_y/z^3, as we expect */ + secp256k1_fe_mul(&p_ge.y, &p_ge.y, &zi3); + /* Store */ + secp256k1_ge_to_storage(&pre[i], &p_ge); + } +} + +/** The following two macro retrieves a particular odd multiple from a table + * of precomputed multiples. */ +#define ECMULT_TABLE_GET_GE(r,pre,n,w) do { \ +VERIFY_CHECK(((n) & 1) == 1); \ +VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ +VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ +if ((n) > 0) { \ +*(r) = (pre)[((n)-1)/2]; \ +} else { \ +secp256k1_ge_neg((r), &(pre)[(-(n)-1)/2]); \ +} \ +} while(0) + +#define ECMULT_TABLE_GET_GE_STORAGE(r,pre,n,w) do { \ +VERIFY_CHECK(((n) & 1) == 1); \ +VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ +VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ +if ((n) > 0) { \ +secp256k1_ge_from_storage((r), &(pre)[((n)-1)/2]); \ +} else { \ +secp256k1_ge_from_storage((r), &(pre)[(-(n)-1)/2]); \ +secp256k1_ge_neg((r), (r)); \ +} \ +} while(0) + +static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx) { + ctx->pre_g = NULL; +#ifdef USE_ENDOMORPHISM + ctx->pre_g_128 = NULL; +#endif +} + +static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb) { + secp256k1_gej gj; + + if (ctx->pre_g != NULL) { + return; + } + + /* get the generator */ + secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g); + + ctx->pre_g = (secp256k1_ge_storage (*)[])checked_malloc(cb, sizeof((*ctx->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G)); + + /* precompute the tables with odd multiples */ + secp256k1_ecmult_odd_multiples_table_storage_var(ECMULT_TABLE_SIZE(WINDOW_G), *ctx->pre_g, &gj); + +#ifdef USE_ENDOMORPHISM + { + secp256k1_gej g_128j; + int i; + + ctx->pre_g_128 = (secp256k1_ge_storage (*)[])checked_malloc(cb, sizeof((*ctx->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G)); + + /* calculate 2^128*generator */ + g_128j = gj; + for (i = 0; i < 128; i++) { + secp256k1_gej_double_var(&g_128j, &g_128j, NULL); + } + secp256k1_ecmult_odd_multiples_table_storage_var(ECMULT_TABLE_SIZE(WINDOW_G), *ctx->pre_g_128, &g_128j); + } +#endif +} + +static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, + const secp256k1_ecmult_context *src, const secp256k1_callback *cb) { + if (src->pre_g == NULL) { + dst->pre_g = NULL; + } else { + size_t size = sizeof((*dst->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G); + dst->pre_g = (secp256k1_ge_storage (*)[])checked_malloc(cb, size); + memcpy(dst->pre_g, src->pre_g, size); + } +#ifdef USE_ENDOMORPHISM + if (src->pre_g_128 == NULL) { + dst->pre_g_128 = NULL; + } else { + size_t size = sizeof((*dst->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G); + dst->pre_g_128 = (secp256k1_ge_storage (*)[])checked_malloc(cb, size); + memcpy(dst->pre_g_128, src->pre_g_128, size); + } +#endif +} + +static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx) { + return ctx->pre_g != NULL; +} + +static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx) { + free(ctx->pre_g); +#ifdef USE_ENDOMORPHISM + free(ctx->pre_g_128); +#endif + secp256k1_ecmult_context_init(ctx); +} + +/** Convert a number to WNAF notation. The number becomes represented by sum(2^i * wnaf[i], i=0..bits), + * with the following guarantees: + * - each wnaf[i] is either 0, or an odd integer between -(1<<(w-1) - 1) and (1<<(w-1) - 1) + * - two non-zero entries in wnaf are separated by at least w-1 zeroes. + * - the number of set values in wnaf is returned. This number is at most 256, and at most one more + * than the number of bits in the (absolute value) of the input. + */ +static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, int w) { + secp256k1_scalar s = *a; + int last_set_bit = -1; + int bit = 0; + int sign = 1; + int carry = 0; + + VERIFY_CHECK(wnaf != NULL); + VERIFY_CHECK(0 <= len && len <= 256); + VERIFY_CHECK(a != NULL); + VERIFY_CHECK(2 <= w && w <= 31); + + memset(wnaf, 0, len * sizeof(wnaf[0])); + + if (secp256k1_scalar_get_bits(&s, 255, 1)) { + secp256k1_scalar_negate(&s, &s); + sign = -1; + } + + while (bit < len) { + int now; + int word; + if (secp256k1_scalar_get_bits(&s, bit, 1) == (unsigned int)carry) { + bit++; + continue; + } + + now = w; + if (now > len - bit) { + now = len - bit; + } + + word = secp256k1_scalar_get_bits_var(&s, bit, now) + carry; + + carry = (word >> (w-1)) & 1; + word -= carry << w; + + wnaf[bit] = sign * word; + last_set_bit = bit; + + bit += now; + } +#ifdef VERIFY + CHECK(carry == 0); + while (bit < 256) { + CHECK(secp256k1_scalar_get_bits(&s, bit++, 1) == 0); + } +#endif + return last_set_bit + 1; +} + +struct secp256k1_strauss_point_state { +#ifdef USE_ENDOMORPHISM + secp256k1_scalar na_1, na_lam; + int wnaf_na_1[130]; + int wnaf_na_lam[130]; + int bits_na_1; + int bits_na_lam; +#else + int wnaf_na[256]; + int bits_na; +#endif + size_t input_pos; +}; + +struct secp256k1_strauss_state { + secp256k1_gej* prej; + secp256k1_fe* zr; + secp256k1_ge* pre_a; +#ifdef USE_ENDOMORPHISM + secp256k1_ge* pre_a_lam; +#endif + struct secp256k1_strauss_point_state* ps; +}; + +static void secp256k1_ecmult_strauss_wnaf(const secp256k1_ecmult_context *ctx, const struct secp256k1_strauss_state *state, secp256k1_gej *r, int num, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) { + secp256k1_ge tmpa; + secp256k1_fe Z; +#ifdef USE_ENDOMORPHISM + /* Splitted G factors. */ + secp256k1_scalar ng_1, ng_128; + int wnaf_ng_1[129]; + int bits_ng_1 = 0; + int wnaf_ng_128[129]; + int bits_ng_128 = 0; +#else + int wnaf_ng[256]; + int bits_ng = 0; +#endif + int i; + int bits = 0; + int np; + int no = 0; + + for (np = 0; np < num; ++np) { + if (secp256k1_scalar_is_zero(&na[np]) || secp256k1_gej_is_infinity(&a[np])) { + continue; + } + state->ps[no].input_pos = np; +#ifdef USE_ENDOMORPHISM + /* split na into na_1 and na_lam (where na = na_1 + na_lam*lambda, and na_1 and na_lam are ~128 bit) */ + secp256k1_scalar_split_lambda(&state->ps[no].na_1, &state->ps[no].na_lam, &na[np]); + + /* build wnaf representation for na_1 and na_lam. */ + state->ps[no].bits_na_1 = secp256k1_ecmult_wnaf(state->ps[no].wnaf_na_1, 130, &state->ps[no].na_1, WINDOW_A); + state->ps[no].bits_na_lam = secp256k1_ecmult_wnaf(state->ps[no].wnaf_na_lam, 130, &state->ps[no].na_lam, WINDOW_A); + VERIFY_CHECK(state->ps[no].bits_na_1 <= 130); + VERIFY_CHECK(state->ps[no].bits_na_lam <= 130); + if (state->ps[no].bits_na_1 > bits) { + bits = state->ps[no].bits_na_1; + } + if (state->ps[no].bits_na_lam > bits) { + bits = state->ps[no].bits_na_lam; + } +#else + /* build wnaf representation for na. */ + state->ps[no].bits_na = secp256k1_ecmult_wnaf(state->ps[no].wnaf_na, 256, &na[np], WINDOW_A); + if (state->ps[no].bits_na > bits) { + bits = state->ps[no].bits_na; + } +#endif + ++no; + } + + /* Calculate odd multiples of a. + * All multiples are brought to the same Z 'denominator', which is stored + * in Z. Due to secp256k1' isomorphism we can do all operations pretending + * that the Z coordinate was 1, use affine addition formulae, and correct + * the Z coordinate of the result once at the end. + * The exception is the precomputed G table points, which are actually + * affine. Compared to the base used for other points, they have a Z ratio + * of 1/Z, so we can use secp256k1_gej_add_zinv_var, which uses the same + * isomorphism to efficiently add with a known Z inverse. + */ + if (no > 0) { + /* Compute the odd multiples in Jacobian form. */ + secp256k1_ecmult_odd_multiples_table(ECMULT_TABLE_SIZE(WINDOW_A), state->prej, state->zr, &a[state->ps[0].input_pos]); + for (np = 1; np < no; ++np) { + secp256k1_gej tmp = a[state->ps[np].input_pos]; +#ifdef VERIFY + secp256k1_fe_normalize_var(&(state->prej[(np - 1) * ECMULT_TABLE_SIZE(WINDOW_A) + ECMULT_TABLE_SIZE(WINDOW_A) - 1].z)); +#endif + secp256k1_gej_rescale(&tmp, &(state->prej[(np - 1) * ECMULT_TABLE_SIZE(WINDOW_A) + ECMULT_TABLE_SIZE(WINDOW_A) - 1].z)); + secp256k1_ecmult_odd_multiples_table(ECMULT_TABLE_SIZE(WINDOW_A), state->prej + np * ECMULT_TABLE_SIZE(WINDOW_A), state->zr + np * ECMULT_TABLE_SIZE(WINDOW_A), &tmp); + secp256k1_fe_mul(state->zr + np * ECMULT_TABLE_SIZE(WINDOW_A), state->zr + np * ECMULT_TABLE_SIZE(WINDOW_A), &(a[state->ps[np].input_pos].z)); + } + /* Bring them to the same Z denominator. */ + secp256k1_ge_globalz_set_table_gej(ECMULT_TABLE_SIZE(WINDOW_A) * no, state->pre_a, &Z, state->prej, state->zr); + } else { + secp256k1_fe_set_int(&Z, 1); + } + +#ifdef USE_ENDOMORPHISM + for (np = 0; np < no; ++np) { + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_ge_mul_lambda(&state->pre_a_lam[np * ECMULT_TABLE_SIZE(WINDOW_A) + i], &state->pre_a[np * ECMULT_TABLE_SIZE(WINDOW_A) + i]); + } + } + + if (ng) { + /* split ng into ng_1 and ng_128 (where gn = gn_1 + gn_128*2^128, and gn_1 and gn_128 are ~128 bit) */ + secp256k1_scalar_split_128(&ng_1, &ng_128, ng); + + /* Build wnaf representation for ng_1 and ng_128 */ + bits_ng_1 = secp256k1_ecmult_wnaf(wnaf_ng_1, 129, &ng_1, WINDOW_G); + bits_ng_128 = secp256k1_ecmult_wnaf(wnaf_ng_128, 129, &ng_128, WINDOW_G); + if (bits_ng_1 > bits) { + bits = bits_ng_1; + } + if (bits_ng_128 > bits) { + bits = bits_ng_128; + } + } +#else + if (ng) { + bits_ng = secp256k1_ecmult_wnaf(wnaf_ng, 256, ng, WINDOW_G); + if (bits_ng > bits) { + bits = bits_ng; + } + } +#endif + + secp256k1_gej_set_infinity(r); + + for (i = bits - 1; i >= 0; i--) { + int n; + secp256k1_gej_double_var(r, r, NULL); +#ifdef USE_ENDOMORPHISM + for (np = 0; np < no; ++np) { + if (i < state->ps[np].bits_na_1 && (n = state->ps[np].wnaf_na_1[i])) { + ECMULT_TABLE_GET_GE(&tmpa, state->pre_a + np * ECMULT_TABLE_SIZE(WINDOW_A), n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + if (i < state->ps[np].bits_na_lam && (n = state->ps[np].wnaf_na_lam[i])) { + ECMULT_TABLE_GET_GE(&tmpa, state->pre_a_lam + np * ECMULT_TABLE_SIZE(WINDOW_A), n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + } + if (i < bits_ng_1 && (n = wnaf_ng_1[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } + if (i < bits_ng_128 && (n = wnaf_ng_128[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g_128, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } +#else + for (np = 0; np < no; ++np) { + if (i < state->ps[np].bits_na && (n = state->ps[np].wnaf_na[i])) { + ECMULT_TABLE_GET_GE(&tmpa, state->pre_a + np * ECMULT_TABLE_SIZE(WINDOW_A), n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + } + if (i < bits_ng && (n = wnaf_ng[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } +#endif + } + + if (!r->infinity) { + secp256k1_fe_mul(&r->z, &r->z, &Z); + } +} + +static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) { + secp256k1_gej prej[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_fe zr[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_ge pre_a[ECMULT_TABLE_SIZE(WINDOW_A)]; + struct secp256k1_strauss_point_state ps[1]; +#ifdef USE_ENDOMORPHISM + secp256k1_ge pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; +#endif + struct secp256k1_strauss_state state; + + state.prej = prej; + state.zr = zr; + state.pre_a = pre_a; +#ifdef USE_ENDOMORPHISM + state.pre_a_lam = pre_a_lam; +#endif + state.ps = ps; + secp256k1_ecmult_strauss_wnaf(ctx, &state, r, 1, a, na, ng); +} + +static size_t secp256k1_strauss_scratch_size(size_t n_points) { +#ifdef USE_ENDOMORPHISM + static const size_t point_size = (2 * sizeof(secp256k1_ge) + sizeof(secp256k1_gej) + sizeof(secp256k1_fe)) * ECMULT_TABLE_SIZE(WINDOW_A) + sizeof(struct secp256k1_strauss_point_state) + sizeof(secp256k1_gej) + sizeof(secp256k1_scalar); +#else + static const size_t point_size = (sizeof(secp256k1_ge) + sizeof(secp256k1_gej) + sizeof(secp256k1_fe)) * ECMULT_TABLE_SIZE(WINDOW_A) + sizeof(struct secp256k1_strauss_point_state) + sizeof(secp256k1_gej) + sizeof(secp256k1_scalar); +#endif + return n_points*point_size; +} + +static int secp256k1_ecmult_strauss_batch(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points, size_t cb_offset) { + secp256k1_gej* points; + secp256k1_scalar* scalars; + struct secp256k1_strauss_state state; + size_t i; + + secp256k1_gej_set_infinity(r); + if (inp_g_sc == NULL && n_points == 0) { + return 1; + } + + if (!secp256k1_scratch_allocate_frame(scratch, secp256k1_strauss_scratch_size(n_points), STRAUSS_SCRATCH_OBJECTS)) { + return 0; + } + points = (secp256k1_gej*)secp256k1_scratch_alloc(scratch, n_points * sizeof(secp256k1_gej)); + scalars = (secp256k1_scalar*)secp256k1_scratch_alloc(scratch, n_points * sizeof(secp256k1_scalar)); + state.prej = (secp256k1_gej*)secp256k1_scratch_alloc(scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_gej)); + state.zr = (secp256k1_fe*)secp256k1_scratch_alloc(scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_fe)); +#ifdef USE_ENDOMORPHISM + state.pre_a = (secp256k1_ge*)secp256k1_scratch_alloc(scratch, n_points * 2 * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_ge)); + state.pre_a_lam = state.pre_a + n_points * ECMULT_TABLE_SIZE(WINDOW_A); +#else + state.pre_a = (secp256k1_ge*)secp256k1_scratch_alloc(scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_ge)); +#endif + state.ps = (struct secp256k1_strauss_point_state*)secp256k1_scratch_alloc(scratch, n_points * sizeof(struct secp256k1_strauss_point_state)); + + for (i = 0; i < n_points; i++) { + secp256k1_ge point; + if (!cb(&scalars[i], &point, i+cb_offset, cbdata)) { + secp256k1_scratch_deallocate_frame(scratch); + return 0; + } + secp256k1_gej_set_ge(&points[i], &point); + } + secp256k1_ecmult_strauss_wnaf(ctx, &state, r, n_points, points, scalars, inp_g_sc); + secp256k1_scratch_deallocate_frame(scratch); + return 1; +} + +/* Wrapper for secp256k1_ecmult_multi_func interface */ +static int secp256k1_ecmult_strauss_batch_single(const secp256k1_ecmult_context *actx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { + return secp256k1_ecmult_strauss_batch(actx, scratch, r, inp_g_sc, cb, cbdata, n, 0); +} + +static size_t secp256k1_strauss_max_points(secp256k1_scratch *scratch) { + return secp256k1_scratch_max_allocation(scratch, STRAUSS_SCRATCH_OBJECTS) / secp256k1_strauss_scratch_size(1); +} + +/** Convert a number to WNAF notation. + * The number becomes represented by sum(2^{wi} * wnaf[i], i=0..WNAF_SIZE(w)+1) - return_val. + * It has the following guarantees: + * - each wnaf[i] is either 0 or an odd integer between -(1 << w) and (1 << w) + * - the number of words set is always WNAF_SIZE(w) + * - the returned skew is 0 or 1 + */ +static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { + int skew = 0; + int pos; + int max_pos; + int last_w; + const secp256k1_scalar *work = s; + + if (secp256k1_scalar_is_zero(s)) { + for (pos = 0; pos < WNAF_SIZE(w); pos++) { + wnaf[pos] = 0; + } + return 0; + } + + if (secp256k1_scalar_is_even(s)) { + skew = 1; + } + + wnaf[0] = secp256k1_scalar_get_bits_var(work, 0, w) + skew; + /* Compute last window size. Relevant when window size doesn't divide the + * number of bits in the scalar */ + last_w = WNAF_BITS - (WNAF_SIZE(w) - 1) * w; + + /* Store the position of the first nonzero word in max_pos to allow + * skipping leading zeros when calculating the wnaf. */ + for (pos = WNAF_SIZE(w) - 1; pos > 0; pos--) { + int val = secp256k1_scalar_get_bits_var(work, pos * w, pos == WNAF_SIZE(w)-1 ? last_w : w); + if(val != 0) { + break; + } + wnaf[pos] = 0; + } + max_pos = pos; + pos = 1; + + while (pos <= max_pos) { + int val = secp256k1_scalar_get_bits_var(work, pos * w, pos == WNAF_SIZE(w)-1 ? last_w : w); + if ((val & 1) == 0) { + wnaf[pos - 1] -= (1 << w); + wnaf[pos] = (val + 1); + } else { + wnaf[pos] = val; + } + /* Set a coefficient to zero if it is 1 or -1 and the proceeding digit + * is strictly negative or strictly positive respectively. Only change + * coefficients at previous positions because above code assumes that + * wnaf[pos - 1] is odd. + */ + if (pos >= 2 && ((wnaf[pos - 1] == 1 && wnaf[pos - 2] < 0) || (wnaf[pos - 1] == -1 && wnaf[pos - 2] > 0))) { + if (wnaf[pos - 1] == 1) { + wnaf[pos - 2] += 1 << w; + } else { + wnaf[pos - 2] -= 1 << w; + } + wnaf[pos - 1] = 0; + } + ++pos; + } + + return skew; +} + +struct secp256k1_pippenger_point_state { + int skew_na; + size_t input_pos; +}; + +struct secp256k1_pippenger_state { + int *wnaf_na; + struct secp256k1_pippenger_point_state* ps; +}; + +/* + * pippenger_wnaf computes the result of a multi-point multiplication as + * follows: The scalars are brought into wnaf with n_wnaf elements each. Then + * for every i < n_wnaf, first each point is added to a "bucket" corresponding + * to the point's wnaf[i]. Second, the buckets are added together such that + * r += 1*bucket[0] + 3*bucket[1] + 5*bucket[2] + ... + */ +static int secp256k1_ecmult_pippenger_wnaf(secp256k1_gej *buckets, int bucket_window, struct secp256k1_pippenger_state *state, secp256k1_gej *r, const secp256k1_scalar *sc, const secp256k1_ge *pt, size_t num) { + size_t n_wnaf = WNAF_SIZE(bucket_window+1); + size_t np; + size_t no = 0; + int i; + int j; + + for (np = 0; np < num; ++np) { + if (secp256k1_scalar_is_zero(&sc[np]) || secp256k1_ge_is_infinity(&pt[np])) { + continue; + } + state->ps[no].input_pos = np; + state->ps[no].skew_na = secp256k1_wnaf_fixed(&state->wnaf_na[no*n_wnaf], &sc[np], bucket_window+1); + no++; + } + secp256k1_gej_set_infinity(r); + + if (no == 0) { + return 1; + } + + for (i = n_wnaf - 1; i >= 0; i--) { + secp256k1_gej running_sum; + + for(j = 0; j < ECMULT_TABLE_SIZE(bucket_window+2); j++) { + secp256k1_gej_set_infinity(&buckets[j]); + } + + for (np = 0; np < no; ++np) { + int n = state->wnaf_na[np*n_wnaf + i]; + struct secp256k1_pippenger_point_state point_state = state->ps[np]; + secp256k1_ge tmp; + int idx; + + if (i == 0) { + /* correct for wnaf skew */ + int skew = point_state.skew_na; + if (skew) { + secp256k1_ge_neg(&tmp, &pt[point_state.input_pos]); + secp256k1_gej_add_ge_var(&buckets[0], &buckets[0], &tmp, NULL); + } + } + if (n > 0) { + idx = (n - 1)/2; + secp256k1_gej_add_ge_var(&buckets[idx], &buckets[idx], &pt[point_state.input_pos], NULL); + } else if (n < 0) { + idx = -(n + 1)/2; + secp256k1_ge_neg(&tmp, &pt[point_state.input_pos]); + secp256k1_gej_add_ge_var(&buckets[idx], &buckets[idx], &tmp, NULL); + } + } + + for(j = 0; j < bucket_window; j++) { + secp256k1_gej_double_var(r, r, NULL); + } + + secp256k1_gej_set_infinity(&running_sum); + /* Accumulate the sum: bucket[0] + 3*bucket[1] + 5*bucket[2] + 7*bucket[3] + ... + * = bucket[0] + bucket[1] + bucket[2] + bucket[3] + ... + * + 2 * (bucket[1] + 2*bucket[2] + 3*bucket[3] + ...) + * using an intermediate running sum: + * running_sum = bucket[0] + bucket[1] + bucket[2] + ... + * + * The doubling is done implicitly by deferring the final window doubling (of 'r'). + */ + for(j = ECMULT_TABLE_SIZE(bucket_window+2) - 1; j > 0; j--) { + secp256k1_gej_add_var(&running_sum, &running_sum, &buckets[j], NULL); + secp256k1_gej_add_var(r, r, &running_sum, NULL); + } + + secp256k1_gej_add_var(&running_sum, &running_sum, &buckets[0], NULL); + secp256k1_gej_double_var(r, r, NULL); + secp256k1_gej_add_var(r, r, &running_sum, NULL); + } + return 1; +} + +/** + * Returns optimal bucket_window (number of bits of a scalar represented by a + * set of buckets) for a given number of points. + */ +static int secp256k1_pippenger_bucket_window(size_t n) { +#ifdef USE_ENDOMORPHISM + if (n <= 1) { + return 1; + } else if (n <= 4) { + return 2; + } else if (n <= 20) { + return 3; + } else if (n <= 57) { + return 4; + } else if (n <= 136) { + return 5; + } else if (n <= 235) { + return 6; + } else if (n <= 1260) { + return 7; + } else if (n <= 4420) { + return 9; + } else if (n <= 7880) { + return 10; + } else if (n <= 16050) { + return 11; + } else { + return PIPPENGER_MAX_BUCKET_WINDOW; + } +#else + if (n <= 1) { + return 1; + } else if (n <= 11) { + return 2; + } else if (n <= 45) { + return 3; + } else if (n <= 100) { + return 4; + } else if (n <= 275) { + return 5; + } else if (n <= 625) { + return 6; + } else if (n <= 1850) { + return 7; + } else if (n <= 3400) { + return 8; + } else if (n <= 9630) { + return 9; + } else if (n <= 17900) { + return 10; + } else if (n <= 32800) { + return 11; + } else { + return PIPPENGER_MAX_BUCKET_WINDOW; + } +#endif +} + +/** + * Returns the maximum optimal number of points for a bucket_window. + */ +static size_t secp256k1_pippenger_bucket_window_inv(int bucket_window) { + switch(bucket_window) { +#ifdef USE_ENDOMORPHISM + case 1: return 1; + case 2: return 4; + case 3: return 20; + case 4: return 57; + case 5: return 136; + case 6: return 235; + case 7: return 1260; + case 8: return 1260; + case 9: return 4420; + case 10: return 7880; + case 11: return 16050; + case PIPPENGER_MAX_BUCKET_WINDOW: return SIZE_MAX; +#else + case 1: return 1; + case 2: return 11; + case 3: return 45; + case 4: return 100; + case 5: return 275; + case 6: return 625; + case 7: return 1850; + case 8: return 3400; + case 9: return 9630; + case 10: return 17900; + case 11: return 32800; + case PIPPENGER_MAX_BUCKET_WINDOW: return SIZE_MAX; +#endif + } + return 0; +} + + +#ifdef USE_ENDOMORPHISM +SECP256K1_INLINE static void secp256k1_ecmult_endo_split(secp256k1_scalar *s1, secp256k1_scalar *s2, secp256k1_ge *p1, secp256k1_ge *p2) { + secp256k1_scalar tmp = *s1; + secp256k1_scalar_split_lambda(s1, s2, &tmp); + secp256k1_ge_mul_lambda(p2, p1); + + if (secp256k1_scalar_is_high(s1)) { + secp256k1_scalar_negate(s1, s1); + secp256k1_ge_neg(p1, p1); + } + if (secp256k1_scalar_is_high(s2)) { + secp256k1_scalar_negate(s2, s2); + secp256k1_ge_neg(p2, p2); + } +} +#endif + +/** + * Returns the scratch size required for a given number of points (excluding + * base point G) without considering alignment. + */ +static size_t secp256k1_pippenger_scratch_size(size_t n_points, int bucket_window) { +#ifdef USE_ENDOMORPHISM + size_t entries = 2*n_points + 2; +#else + size_t entries = n_points + 1; +#endif + size_t entry_size = sizeof(secp256k1_ge) + sizeof(secp256k1_scalar) + sizeof(struct secp256k1_pippenger_point_state) + (WNAF_SIZE(bucket_window+1)+1)*sizeof(int); + return ((1<ps = (struct secp256k1_pippenger_point_state *) secp256k1_scratch_alloc(scratch, entries * sizeof(*state_space->ps)); + state_space->wnaf_na = (int *) secp256k1_scratch_alloc(scratch, entries*(WNAF_SIZE(bucket_window+1)) * sizeof(int)); + buckets = (secp256k1_gej *) secp256k1_scratch_alloc(scratch, (1<ps[i].skew_na = 0; + for(j = 0; j < WNAF_SIZE(bucket_window+1); j++) { + state_space->wnaf_na[i * WNAF_SIZE(bucket_window+1) + j] = 0; + } + } + for(i = 0; i < 1< max_alloc) { + break; + } + space_for_points = max_alloc - space_overhead; + + n_points = space_for_points/entry_size; + n_points = n_points > max_points ? max_points : n_points; + if (n_points > res) { + res = n_points; + } + if (n_points < max_points) { + /* A larger bucket_window may support even more points. But if we + * would choose that then the caller couldn't safely use any number + * smaller than what this function returns */ + break; + } + } + return res; +} + +/* Computes ecmult_multi by simply multiplying and adding each point. Does not + * require a scratch space */ +static int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { + size_t point_idx; + secp256k1_scalar szero; + secp256k1_gej tmpj; + + secp256k1_scalar_set_int(&szero, 0); + /* r = inp_g_sc*G */ + secp256k1_gej_set_infinity(r); + secp256k1_ecmult(ctx, r, &tmpj, &szero, inp_g_sc); + for (point_idx = 0; point_idx < n_points; point_idx++) { + secp256k1_ge point; + secp256k1_gej pointj; + secp256k1_scalar scalar; + if (!cb(&scalar, &point, point_idx, cbdata)) { + return 0; + } + /* r += scalar*point */ + secp256k1_gej_set_ge(&pointj, &point); + secp256k1_ecmult(ctx, &tmpj, &pointj, &scalar, NULL); + secp256k1_gej_add_var(r, r, &tmpj, NULL); + } + return 1; +} + +typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); +static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { + size_t i; + + int (*f)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t, size_t); + size_t max_points; + size_t n_batches; + size_t n_batch_points; + + secp256k1_gej_set_infinity(r); + if (inp_g_sc == NULL && n == 0) { + return 1; + } else if (n == 0) { + secp256k1_scalar szero; + secp256k1_scalar_set_int(&szero, 0); + secp256k1_ecmult(ctx, r, r, &szero, inp_g_sc); + return 1; + } + if (scratch == NULL) { + return secp256k1_ecmult_multi_var_simple(ctx, r, inp_g_sc, cb, cbdata, n); + } + + max_points = secp256k1_pippenger_max_points(scratch); + if (max_points == 0) { + return 0; + } else if (max_points > ECMULT_MAX_POINTS_PER_BATCH) { + max_points = ECMULT_MAX_POINTS_PER_BATCH; + } + n_batches = (n+max_points-1)/max_points; + n_batch_points = (n+n_batches-1)/n_batches; + + if (n_batch_points >= ECMULT_PIPPENGER_THRESHOLD) { + f = secp256k1_ecmult_pippenger_batch; + } else { + max_points = secp256k1_strauss_max_points(scratch); + if (max_points == 0) { + return 0; + } + n_batches = (n+max_points-1)/max_points; + n_batch_points = (n+n_batches-1)/n_batches; + f = secp256k1_ecmult_strauss_batch; + } + for(i = 0; i < n_batches; i++) { + size_t nbp = n < n_batch_points ? n : n_batch_points; + size_t offset = n_batch_points*i; + secp256k1_gej tmp; + if (!f(ctx, scratch, &tmp, i == 0 ? inp_g_sc : NULL, cb, cbdata, nbp, offset)) { + return 0; + } + secp256k1_gej_add_var(r, r, &tmp, NULL); + n -= nbp; + } + return 1; +} + +#endif /* SECP256K1_ECMULT_IMPL_H */ + +#endif + diff --git a/src/secp256k1/src/modules/musig/Makefile.am.include b/src/secp256k1/src/modules/musig/Makefile.am.include new file mode 100644 index 000000000..34583a23a --- /dev/null +++ b/src/secp256k1/src/modules/musig/Makefile.am.include @@ -0,0 +1,17 @@ +include_HEADERS += include/secp256k1_musig.h +noinst_HEADERS += src/modules/musig/main_impl.h +noinst_HEADERS += src/modules/musig/tests_impl.h + +noinst_PROGRAMS += example_musig +example_musig_SOURCES = src/modules/musig/example.c +example_musig_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include $(SECP_INCLUDES) +if !ENABLE_COVERAGE +example_musig_CPPFLAGS += -DVERIFY +endif +example_musig_LDADD = libsecp256k1.la $(SECP_LIBS) +example_musig_LDFLAGS = -static + +if USE_TESTS +TESTS += example_musig +endif + diff --git a/src/secp256k1/src/modules/musig/example.c b/src/secp256k1/src/modules/musig/example.c new file mode 100644 index 000000000..ceae18686 --- /dev/null +++ b/src/secp256k1/src/modules/musig/example.c @@ -0,0 +1,166 @@ +/********************************************************************** + * Copyright (c) 2018 Jonas Nick * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +/** + * This file demonstrates how to use the MuSig module to create a multisignature. + * Additionally, see the documentation in include/secp256k1_musig.h. + */ + +#include +#include +#include +#include +#include + + /* Number of public keys involved in creating the aggregate signature */ +#define N_SIGNERS 3 + /* Create a key pair and store it in seckey and pubkey */ +int create_key(const secp256k1_context* ctx, unsigned char* seckey, secp256k1_pubkey* pubkey) { + int ret; + FILE *frand = fopen("/dev/urandom", "r"); + if (frand == NULL) { + return 0; + } + do { + if(!fread(seckey, 32, 1, frand)) { + fclose(frand); + return 0; + } + /* The probability that this not a valid secret key is approximately 2^-128 */ + } while (!secp256k1_ec_seckey_verify(ctx, seckey)); + fclose(frand); + ret = secp256k1_ec_pubkey_create(ctx, pubkey, seckey); + return ret; +} + +/* Sign a message hash with the given key pairs and store the result in sig */ +int sign(const secp256k1_context* ctx, unsigned char seckeys[][32], const secp256k1_pubkey* pubkeys, const unsigned char* msg32, secp256k1_schnorrsig *sig) { + secp256k1_musig_session musig_session[N_SIGNERS]; + unsigned char nonce_commitment[N_SIGNERS][32]; + const unsigned char *nonce_commitment_ptr[N_SIGNERS]; + secp256k1_musig_session_signer_data signer_data[N_SIGNERS][N_SIGNERS]; + secp256k1_pubkey nonce[N_SIGNERS]; + int i, j; + secp256k1_musig_partial_signature partial_sig[N_SIGNERS]; + + for (i = 0; i < N_SIGNERS; i++) { + FILE *frand; + unsigned char session_id32[32]; + unsigned char pk_hash[32]; + secp256k1_pubkey combined_pk; + + /* Create combined pubkey and initialize signer data */ + if (!secp256k1_musig_pubkey_combine(ctx, NULL, &combined_pk, pk_hash, pubkeys, N_SIGNERS)) { + return 0; + } + /* Create random session ID. It is absolutely necessary that the session ID + * is unique for every call of secp256k1_musig_session_initialize. Otherwise + * it's trivial for an attacker to extract the secret key! */ + frand = fopen("/dev/urandom", "r"); + if(frand == NULL) { + return 0; + } + if (!fread(session_id32, 32, 1, frand)) { + fclose(frand); + return 0; + } + fclose(frand); + /* Initialize session */ + if (!secp256k1_musig_session_initialize(ctx, &musig_session[i], signer_data[i], nonce_commitment[i], session_id32, msg32, &combined_pk, pk_hash, N_SIGNERS, i, seckeys[i])) { + return 0; + } + nonce_commitment_ptr[i] = &nonce_commitment[i][0]; + } + /* Communication round 1: Exchange nonce commitments */ + for (i = 0; i < N_SIGNERS; i++) { + /* Set nonce commitments in the signer data and get the own public nonce */ + if (!secp256k1_musig_session_get_public_nonce(ctx, &musig_session[i], signer_data[i], &nonce[i], nonce_commitment_ptr, N_SIGNERS)) { + return 0; + } + } + /* Communication round 2: Exchange nonces */ + for (i = 0; i < N_SIGNERS; i++) { + for (j = 0; j < N_SIGNERS; j++) { + if (!secp256k1_musig_set_nonce(ctx, &signer_data[i][j], &nonce[j])) { + /* Signer j's nonce does not match the nonce commitment. In this case + * abort the protocol. If you make another attempt at finishing the + * protocol, create a new session (with a fresh session ID!). */ + return 0; + } + } + if (!secp256k1_musig_session_combine_nonces(ctx, &musig_session[i], signer_data[i], N_SIGNERS, NULL, NULL)) { + return 0; + } + } + for (i = 0; i < N_SIGNERS; i++) { + if (!secp256k1_musig_partial_sign(ctx, &musig_session[i], &partial_sig[i])) { + return 0; + } + } + /* Communication round 3: Exchange partial signatures */ + for (i = 0; i < N_SIGNERS; i++) { + for (j = 0; j < N_SIGNERS; j++) { + /* To check whether signing was successful, it suffices to either verify + * the the combined signature with the combined public key using + * secp256k1_schnorrsig_verify, or verify all partial signatures of all + * signers individually. Verifying the combined signature is cheaper but + * verifying the individual partial signatures has the advantage that it + * can be used to determine which of the partial signatures are invalid + * (if any), i.e., which of the partial signatures cause the combined + * signature to be invalid and thus the protocol run to fail. It's also + * fine to first verify the combined sig, and only verify the individual + * sigs if it does not work. + */ + if (!secp256k1_musig_partial_sig_verify(ctx, &musig_session[i], &signer_data[i][j], &partial_sig[j], &pubkeys[j])) { + return 0; + } + } + } + return secp256k1_musig_partial_sig_combine(ctx, &musig_session[0], sig, partial_sig, N_SIGNERS); +} + + int main(void) { + secp256k1_context* ctx; + int i; + unsigned char seckeys[N_SIGNERS][32]; + secp256k1_pubkey pubkeys[N_SIGNERS]; + secp256k1_pubkey combined_pk; + unsigned char msg[32] = "this_could_be_the_hash_of_a_msg!"; + secp256k1_schnorrsig sig; + + /* Create a context for signing and verification */ + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + printf("Creating key pairs......"); + for (i = 0; i < N_SIGNERS; i++) { + if (!create_key(ctx, seckeys[i], &pubkeys[i])) { + printf("FAILED\n"); + return 1; + } + } + printf("ok\n"); + printf("Combining public keys..."); + if (!secp256k1_musig_pubkey_combine(ctx, NULL, &combined_pk, NULL, pubkeys, N_SIGNERS)) { + printf("FAILED\n"); + return 1; + } + printf("ok\n"); + printf("Signing message........."); + if (!sign(ctx, seckeys, pubkeys, msg, &sig)) { + printf("FAILED\n"); + return 1; + } + printf("ok\n"); + printf("Verifying signature....."); + if (!secp256k1_schnorrsig_verify(ctx, &sig, msg, &combined_pk)) { + printf("FAILED\n"); + return 1; + } + printf("ok\n"); + secp256k1_context_destroy(ctx); + return 0; +} + + diff --git a/src/secp256k1/src/modules/musig/main_impl.h b/src/secp256k1/src/modules/musig/main_impl.h new file mode 100644 index 000000000..dece823d6 --- /dev/null +++ b/src/secp256k1/src/modules/musig/main_impl.h @@ -0,0 +1,631 @@ + +/********************************************************************** + * Copyright (c) 2018 Andrew Poelstra, Jonas Nick * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_MUSIG_MAIN_ +#define _SECP256K1_MODULE_MUSIG_MAIN_ + +#include "include/secp256k1.h" +#include "include/secp256k1_musig.h" +#include "hash.h" + +/* Computes ell = SHA256(pk[0], ..., pk[np-1]) */ +static int secp256k1_musig_compute_ell(const secp256k1_context *ctx, unsigned char *ell, const secp256k1_pubkey *pk, size_t np) { + secp256k1_sha256 sha; + size_t i; + + secp256k1_sha256_initialize(&sha); + for (i = 0; i < np; i++) { + unsigned char ser[33]; + size_t serlen = sizeof(ser); + if (!secp256k1_ec_pubkey_serialize(ctx, ser, &serlen, &pk[i], SECP256K1_EC_COMPRESSED)) { + return 0; + } + secp256k1_sha256_write(&sha, ser, serlen); + } + secp256k1_sha256_finalize(&sha, ell); + return 1; +} + +/* Initializes SHA256 with fixed midstate. This midstate was computed by applying + * SHA256 to SHA256("MuSig coefficient")||SHA256("MuSig coefficient"). */ +static void secp256k1_musig_sha256_init_tagged(secp256k1_sha256 *sha) { + secp256k1_sha256_initialize(sha); + + sha->s[0] = 0x0fd0690cul; + sha->s[1] = 0xfefeae97ul; + sha->s[2] = 0x996eac7ful; + sha->s[3] = 0x5c30d864ul; + sha->s[4] = 0x8c4a0573ul; + sha->s[5] = 0xaca1a22ful; + sha->s[6] = 0x6f43b801ul; + sha->s[7] = 0x85ce27cdul; + sha->bytes = 64; +} + +/* Compute r = SHA256(ell, idx). The four bytes of idx are serialized least significant byte first. */ +static void secp256k1_musig_coefficient(secp256k1_scalar *r, const unsigned char *ell, uint32_t idx) { + secp256k1_sha256 sha; + unsigned char buf[32]; + size_t i; + + secp256k1_musig_sha256_init_tagged(&sha); + secp256k1_sha256_write(&sha, ell, 32); + /* We're hashing the index of the signer instead of its public key as specified + * in the MuSig paper. This reduces the total amount of data that needs to be + * hashed. + * Additionally, it prevents creating identical musig_coefficients for identical + * public keys. A participant Bob could choose his public key to be the same as + * Alice's, then replay Alice's messages (nonce and partial signature) to create + * a valid partial signature. This is not a problem for MuSig per se, but could + * result in subtle issues with protocols building on threshold signatures. + * With the assumption that public keys are unique, hashing the index is + * equivalent to hashing the public key. Because the public key can be + * identified by the index given the ordered list of public keys (included in + * ell), the index is just a different encoding of the public key.*/ + for (i = 0; i < sizeof(uint32_t); i++) { + unsigned char c = idx; + secp256k1_sha256_write(&sha, &c, 1); + idx >>= 8; + } + secp256k1_sha256_finalize(&sha, buf); + secp256k1_scalar_set_b32(r, buf, NULL); +} + +typedef struct { + const secp256k1_context *ctx; + unsigned char ell[32]; + const secp256k1_pubkey *pks; +} secp256k1_musig_pubkey_combine_ecmult_data; + +/* Callback for batch EC multiplication to compute ell_0*P0 + ell_1*P1 + ... */ +static int secp256k1_musig_pubkey_combine_callback(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data) { + secp256k1_musig_pubkey_combine_ecmult_data *ctx = (secp256k1_musig_pubkey_combine_ecmult_data *) data; + secp256k1_musig_coefficient(sc, ctx->ell, idx); + return secp256k1_pubkey_load(ctx->ctx, pt, &ctx->pks[idx]); +} + + +static void secp256k1_musig_signers_init(secp256k1_musig_session_signer_data *signers, uint32_t n_signers) { + uint32_t i; + for (i = 0; i < n_signers; i++) { + memset(&signers[i], 0, sizeof(signers[i])); + signers[i].index = i; + signers[i].present = 0; + } +} + +int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp256k1_scratch_space *scratch, secp256k1_pubkey *combined_pk, unsigned char *pk_hash32, const secp256k1_pubkey *pubkeys, size_t n_pubkeys) { + secp256k1_musig_pubkey_combine_ecmult_data ecmult_data; + secp256k1_gej pkj; + secp256k1_ge pkp; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(combined_pk != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(pubkeys != NULL); + ARG_CHECK(n_pubkeys > 0); + + ecmult_data.ctx = ctx; + ecmult_data.pks = pubkeys; + if (!secp256k1_musig_compute_ell(ctx, ecmult_data.ell, pubkeys, n_pubkeys)) { + return 0; + } + if (!secp256k1_ecmult_multi_var(&ctx->ecmult_ctx, scratch, &pkj, NULL, secp256k1_musig_pubkey_combine_callback, (void *) &ecmult_data, n_pubkeys)) { + return 0; + } + secp256k1_ge_set_gej(&pkp, &pkj); + secp256k1_pubkey_save(combined_pk, &pkp); + + if (pk_hash32 != NULL) { + memcpy(pk_hash32, ecmult_data.ell, 32); + } + return 1; +} + +int secp256k1_musig_session_initialize(const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, unsigned char *nonce_commitment32, const unsigned char *session_id32, const unsigned char *msg32, const secp256k1_pubkey *combined_pk, const unsigned char *pk_hash32, size_t n_signers, size_t my_index, const unsigned char *seckey) { + unsigned char combined_ser[33]; + size_t combined_ser_size = sizeof(combined_ser); + int overflow; + secp256k1_scalar secret; + secp256k1_scalar mu; + secp256k1_sha256 sha; + secp256k1_gej rj; + secp256k1_ge rp; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(session != NULL); + ARG_CHECK(signers != NULL); + ARG_CHECK(nonce_commitment32 != NULL); + ARG_CHECK(session_id32 != NULL); + ARG_CHECK(combined_pk != NULL); + ARG_CHECK(pk_hash32 != NULL); + ARG_CHECK(seckey != NULL); + + memset(session, 0, sizeof(*session)); + + if (msg32 != NULL) { + memcpy(session->msg, msg32, 32); + session->msg_is_set = 1; + } else { + session->msg_is_set = 0; + } + memcpy(&session->combined_pk, combined_pk, sizeof(*combined_pk)); + memcpy(session->pk_hash, pk_hash32, 32); + session->nonce_is_set = 0; + session->has_secret_data = 1; + if (n_signers == 0 || my_index >= n_signers) { + return 0; + } + if (n_signers > UINT32_MAX) { + return 0; + } + session->n_signers = (uint32_t) n_signers; + secp256k1_musig_signers_init(signers, session->n_signers); + session->nonce_commitments_hash_is_set = 0; + + /* Compute secret key */ + secp256k1_scalar_set_b32(&secret, seckey, &overflow); + if (overflow) { + secp256k1_scalar_clear(&secret); + return 0; + } + secp256k1_musig_coefficient(&mu, pk_hash32, (uint32_t) my_index); + secp256k1_scalar_mul(&secret, &secret, &mu); + secp256k1_scalar_get_b32(session->seckey, &secret); + + /* Compute secret nonce */ + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, session_id32, 32); + if (session->msg_is_set) { + secp256k1_sha256_write(&sha, msg32, 32); + } + secp256k1_ec_pubkey_serialize(ctx, combined_ser, &combined_ser_size, combined_pk, SECP256K1_EC_COMPRESSED); + secp256k1_sha256_write(&sha, combined_ser, combined_ser_size); + secp256k1_sha256_write(&sha, seckey, 32); + secp256k1_sha256_finalize(&sha, session->secnonce); + secp256k1_scalar_set_b32(&secret, session->secnonce, &overflow); + if (overflow) { + secp256k1_scalar_clear(&secret); + return 0; + } + + /* Compute public nonce and commitment */ + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &rj, &secret); + secp256k1_ge_set_gej(&rp, &rj); + secp256k1_pubkey_save(&session->nonce, &rp); + + if (nonce_commitment32 != NULL) { + unsigned char commit[33]; + size_t commit_size = sizeof(commit); + secp256k1_sha256_initialize(&sha); + secp256k1_ec_pubkey_serialize(ctx, commit, &commit_size, &session->nonce, SECP256K1_EC_COMPRESSED); + secp256k1_sha256_write(&sha, commit, commit_size); + secp256k1_sha256_finalize(&sha, nonce_commitment32); + } + + secp256k1_scalar_clear(&secret); + return 1; +} + +int secp256k1_musig_session_get_public_nonce(const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, secp256k1_pubkey *nonce, const unsigned char *const *commitments, size_t n_commitments) { + secp256k1_sha256 sha; + unsigned char nonce_commitments_hash[32]; + size_t i; + (void) ctx; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(session != NULL); + ARG_CHECK(signers != NULL); + ARG_CHECK(nonce != NULL); + ARG_CHECK(commitments != NULL); + + if (!session->has_secret_data || n_commitments != session->n_signers) { + return 0; + } + for (i = 0; i < n_commitments; i++) { + ARG_CHECK(commitments[i] != NULL); + } + + secp256k1_sha256_initialize(&sha); + for (i = 0; i < n_commitments; i++) { + memcpy(signers[i].nonce_commitment, commitments[i], 32); + secp256k1_sha256_write(&sha, commitments[i], 32); + } + secp256k1_sha256_finalize(&sha, nonce_commitments_hash); + if (session->nonce_commitments_hash_is_set + && memcmp(session->nonce_commitments_hash, nonce_commitments_hash, 32) != 0) { + /* Abort if get_public_nonce has been called before with a different array of + * commitments. */ + return 0; + } + memcpy(session->nonce_commitments_hash, nonce_commitments_hash, 32); + session->nonce_commitments_hash_is_set = 1; + memcpy(nonce, &session->nonce, sizeof(*nonce)); + return 1; +} + +int secp256k1_musig_session_initialize_verifier(const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, const unsigned char *msg32, const secp256k1_pubkey *combined_pk, const unsigned char *pk_hash32, const unsigned char *const *commitments, size_t n_signers) { + size_t i; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(session != NULL); + ARG_CHECK(signers != NULL); + ARG_CHECK(combined_pk != NULL); + ARG_CHECK(pk_hash32 != NULL); + ARG_CHECK(commitments != NULL); + /* Check n_signers before checking commitments to allow testing the case where + * n_signers is big without allocating the space. */ + if (n_signers > UINT32_MAX) { + return 0; + } + for (i = 0; i < n_signers; i++) { + ARG_CHECK(commitments[i] != NULL); + } + (void) ctx; + + memset(session, 0, sizeof(*session)); + + memcpy(&session->combined_pk, combined_pk, sizeof(*combined_pk)); + if (n_signers == 0) { + return 0; + } + session->n_signers = (uint32_t) n_signers; + secp256k1_musig_signers_init(signers, session->n_signers); + + memcpy(session->pk_hash, pk_hash32, 32); + session->nonce_is_set = 0; + session->msg_is_set = 0; + if (msg32 != NULL) { + memcpy(session->msg, msg32, 32); + session->msg_is_set = 1; + } + session->has_secret_data = 0; + session->nonce_commitments_hash_is_set = 0; + + for (i = 0; i < n_signers; i++) { + memcpy(signers[i].nonce_commitment, commitments[i], 32); + } + return 1; +} + +int secp256k1_musig_set_nonce(const secp256k1_context* ctx, secp256k1_musig_session_signer_data *signer, const secp256k1_pubkey *nonce) { + unsigned char commit[33]; + size_t commit_size = sizeof(commit); + secp256k1_sha256 sha; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(signer != NULL); + ARG_CHECK(nonce != NULL); + + secp256k1_sha256_initialize(&sha); + secp256k1_ec_pubkey_serialize(ctx, commit, &commit_size, nonce, SECP256K1_EC_COMPRESSED); + secp256k1_sha256_write(&sha, commit, commit_size); + secp256k1_sha256_finalize(&sha, commit); + + if (memcmp(commit, signer->nonce_commitment, 32) != 0) { + return 0; + } + memcpy(&signer->nonce, nonce, sizeof(*nonce)); + signer->present = 1; + return 1; +} + +int secp256k1_musig_session_combine_nonces(const secp256k1_context* ctx, secp256k1_musig_session *session, const secp256k1_musig_session_signer_data *signers, size_t n_signers, int *nonce_is_negated, const secp256k1_pubkey *adaptor) { + secp256k1_gej combined_noncej; + secp256k1_ge combined_noncep; + secp256k1_ge noncep; + secp256k1_sha256 sha; + unsigned char nonce_commitments_hash[32]; + size_t i; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(session != NULL); + ARG_CHECK(signers != NULL); + + if (n_signers != session->n_signers) { + return 0; + } + secp256k1_sha256_initialize(&sha); + secp256k1_gej_set_infinity(&combined_noncej); + for (i = 0; i < n_signers; i++) { + if (!signers[i].present) { + return 0; + } + secp256k1_sha256_write(&sha, signers[i].nonce_commitment, 32); + secp256k1_pubkey_load(ctx, &noncep, &signers[i].nonce); + secp256k1_gej_add_ge_var(&combined_noncej, &combined_noncej, &noncep, NULL); + } + secp256k1_sha256_finalize(&sha, nonce_commitments_hash); + /* Either the session is a verifier session or or the nonce_commitments_hash has + * been set in `musig_session_get_public_nonce`. */ + VERIFY_CHECK(!session->has_secret_data || session->nonce_commitments_hash_is_set); + if (session->has_secret_data + && memcmp(session->nonce_commitments_hash, nonce_commitments_hash, 32) != 0) { + /* If the signers' commitments changed between get_public_nonce and now we + * have to abort because in that case they may have seen our nonce before + * creating their commitment. That can happen if the signer_data given to + * this function is different to the signer_data given to get_public_nonce. + * */ + return 0; + } + + /* Add public adaptor to nonce */ + if (adaptor != NULL) { + secp256k1_pubkey_load(ctx, &noncep, adaptor); + secp256k1_gej_add_ge_var(&combined_noncej, &combined_noncej, &noncep, NULL); + } + secp256k1_ge_set_gej(&combined_noncep, &combined_noncej); + if (secp256k1_fe_is_quad_var(&combined_noncep.y)) { + session->nonce_is_negated = 0; + } else { + session->nonce_is_negated = 1; + secp256k1_ge_neg(&combined_noncep, &combined_noncep); + } + if (nonce_is_negated != NULL) { + *nonce_is_negated = session->nonce_is_negated; + } + secp256k1_pubkey_save(&session->combined_nonce, &combined_noncep); + session->nonce_is_set = 1; + return 1; +} + +int secp256k1_musig_session_set_msg(const secp256k1_context* ctx, secp256k1_musig_session *session, const unsigned char *msg32) { + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(session != NULL); + ARG_CHECK(msg32 != NULL); + + if (session->msg_is_set) { + return 0; + } + memcpy(session->msg, msg32, 32); + session->msg_is_set = 1; + return 1; +} + +int secp256k1_musig_partial_signature_serialize(const secp256k1_context* ctx, unsigned char *out32, const secp256k1_musig_partial_signature* sig) { + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(out32 != NULL); + ARG_CHECK(sig != NULL); + memcpy(out32, sig->data, 32); + return 1; +} + +int secp256k1_musig_partial_signature_parse(const secp256k1_context* ctx, secp256k1_musig_partial_signature* sig, const unsigned char *in32) { + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(in32 != NULL); + memcpy(sig->data, in32, 32); + return 1; +} + +/* Compute msghash = SHA256(combined_nonce, combined_pk, msg) */ +static int secp256k1_musig_compute_messagehash(const secp256k1_context *ctx, unsigned char *msghash, const secp256k1_musig_session *session) { + unsigned char buf[33]; + size_t bufsize = 33; + secp256k1_ge rp; + secp256k1_sha256 sha; + + secp256k1_sha256_initialize(&sha); + if (!session->nonce_is_set) { + return 0; + } + secp256k1_pubkey_load(ctx, &rp, &session->combined_nonce); + secp256k1_fe_get_b32(buf, &rp.x); + secp256k1_sha256_write(&sha, buf, 32); + secp256k1_ec_pubkey_serialize(ctx, buf, &bufsize, &session->combined_pk, SECP256K1_EC_COMPRESSED); + VERIFY_CHECK(bufsize == 33); + secp256k1_sha256_write(&sha, buf, bufsize); + if (!session->msg_is_set) { + return 0; + } + secp256k1_sha256_write(&sha, session->msg, 32); + secp256k1_sha256_finalize(&sha, msghash); + return 1; +} + +int secp256k1_musig_partial_sign(const secp256k1_context* ctx, const secp256k1_musig_session *session, secp256k1_musig_partial_signature *partial_sig) { + unsigned char msghash[32]; + int overflow; + secp256k1_scalar sk; + secp256k1_scalar e, k; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(partial_sig != NULL); + ARG_CHECK(session != NULL); + + if (!session->nonce_is_set || !session->has_secret_data) { + return 0; + } + + /* build message hash */ + if (!secp256k1_musig_compute_messagehash(ctx, msghash, session)) { + return 0; + } + secp256k1_scalar_set_b32(&e, msghash, NULL); + + secp256k1_scalar_set_b32(&sk, session->seckey, &overflow); + if (overflow) { + secp256k1_scalar_clear(&sk); + return 0; + } + + secp256k1_scalar_set_b32(&k, session->secnonce, &overflow); + if (overflow || secp256k1_scalar_is_zero(&k)) { + secp256k1_scalar_clear(&sk); + secp256k1_scalar_clear(&k); + return 0; + } + if (session->nonce_is_negated) { + secp256k1_scalar_negate(&k, &k); + } + + /* Sign */ + secp256k1_scalar_mul(&e, &e, &sk); + secp256k1_scalar_add(&e, &e, &k); + secp256k1_scalar_get_b32(&partial_sig->data[0], &e); + secp256k1_scalar_clear(&sk); + secp256k1_scalar_clear(&k); + + return 1; +} + +int secp256k1_musig_partial_sig_combine(const secp256k1_context* ctx, const secp256k1_musig_session *session, secp256k1_schnorrsig *sig, const secp256k1_musig_partial_signature *partial_sigs, size_t n_sigs) { + size_t i; + secp256k1_scalar s; + secp256k1_ge noncep; + (void) ctx; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(partial_sigs != NULL); + ARG_CHECK(session != NULL); + + if (!session->nonce_is_set) { + return 0; + } + if (n_sigs != session->n_signers) { + return 0; + } + secp256k1_scalar_clear(&s); + for (i = 0; i < n_sigs; i++) { + int overflow; + secp256k1_scalar term; + + secp256k1_scalar_set_b32(&term, partial_sigs[i].data, &overflow); + if (overflow) { + return 0; + } + secp256k1_scalar_add(&s, &s, &term); + } + + secp256k1_pubkey_load(ctx, &noncep, &session->combined_nonce); + VERIFY_CHECK(secp256k1_fe_is_quad_var(&noncep.y)); + secp256k1_fe_normalize(&noncep.x); + secp256k1_fe_get_b32(&sig->data[0], &noncep.x); + secp256k1_scalar_get_b32(&sig->data[32], &s); + + return 1; +} + +int secp256k1_musig_partial_sig_verify(const secp256k1_context* ctx, const secp256k1_musig_session *session, const secp256k1_musig_session_signer_data *signer, const secp256k1_musig_partial_signature *partial_sig, const secp256k1_pubkey *pubkey) { + unsigned char msghash[32]; + secp256k1_scalar s; + secp256k1_scalar e; + secp256k1_scalar mu; + secp256k1_gej rj; + secp256k1_ge rp; + int overflow; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(session != NULL); + ARG_CHECK(signer != NULL); + ARG_CHECK(partial_sig != NULL); + ARG_CHECK(pubkey != NULL); + + if (!session->nonce_is_set || !signer->present) { + return 0; + } + secp256k1_scalar_set_b32(&s, partial_sig->data, &overflow); + if (overflow) { + return 0; + } + if (!secp256k1_musig_compute_messagehash(ctx, msghash, session)) { + return 0; + } + secp256k1_scalar_set_b32(&e, msghash, NULL); + + /* Multiplying the messagehash by the musig coefficient is equivalent + * to multiplying the signer's public key by the coefficient, except + * much easier to do. */ + secp256k1_musig_coefficient(&mu, session->pk_hash, signer->index); + secp256k1_scalar_mul(&e, &e, &mu); + + if (!secp256k1_pubkey_load(ctx, &rp, &signer->nonce)) { + return 0; + } + + if (!secp256k1_schnorrsig_real_verify(ctx, &rj, &s, &e, pubkey)) { + return 0; + } + if (!session->nonce_is_negated) { + secp256k1_ge_neg(&rp, &rp); + } + secp256k1_gej_add_ge_var(&rj, &rj, &rp, NULL); + + return secp256k1_gej_is_infinity(&rj); +} + +int secp256k1_musig_partial_sig_adapt(const secp256k1_context* ctx, secp256k1_musig_partial_signature *adaptor_sig, const secp256k1_musig_partial_signature *partial_sig, const unsigned char *sec_adaptor32, int nonce_is_negated) { + secp256k1_scalar s; + secp256k1_scalar t; + int overflow; + + (void) ctx; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(adaptor_sig != NULL); + ARG_CHECK(partial_sig != NULL); + ARG_CHECK(sec_adaptor32 != NULL); + + secp256k1_scalar_set_b32(&s, partial_sig->data, &overflow); + if (overflow) { + return 0; + } + secp256k1_scalar_set_b32(&t, sec_adaptor32, &overflow); + if (overflow) { + secp256k1_scalar_clear(&t); + return 0; + } + + if (nonce_is_negated) { + secp256k1_scalar_negate(&t, &t); + } + + secp256k1_scalar_add(&s, &s, &t); + secp256k1_scalar_get_b32(adaptor_sig->data, &s); + secp256k1_scalar_clear(&t); + return 1; +} + +int secp256k1_musig_extract_secret_adaptor(const secp256k1_context* ctx, unsigned char *sec_adaptor32, const secp256k1_schnorrsig *sig, const secp256k1_musig_partial_signature *partial_sigs, size_t n_partial_sigs, int nonce_is_negated) { + secp256k1_scalar t; + secp256k1_scalar s; + int overflow; + size_t i; + + (void) ctx; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sec_adaptor32 != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(partial_sigs != NULL); + + secp256k1_scalar_set_b32(&t, &sig->data[32], &overflow); + if (overflow) { + return 0; + } + secp256k1_scalar_negate(&t, &t); + + for (i = 0; i < n_partial_sigs; i++) { + secp256k1_scalar_set_b32(&s, partial_sigs[i].data, &overflow); + if (overflow) { + secp256k1_scalar_clear(&t); + return 0; + } + secp256k1_scalar_add(&t, &t, &s); + } + + if (!nonce_is_negated) { + secp256k1_scalar_negate(&t, &t); + } + secp256k1_scalar_get_b32(sec_adaptor32, &t); + secp256k1_scalar_clear(&t); + return 1; +} + +#endif + diff --git a/src/secp256k1/src/modules/musig/tests_impl.h b/src/secp256k1/src/modules/musig/tests_impl.h new file mode 100644 index 000000000..c58ae95af --- /dev/null +++ b/src/secp256k1/src/modules/musig/tests_impl.h @@ -0,0 +1,758 @@ +/********************************************************************** + * Copyright (c) 2018 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_MUSIG_TESTS_ +#define _SECP256K1_MODULE_MUSIG_TESTS_ + +#include "secp256k1_musig.h" + +void musig_api_tests(secp256k1_scratch_space *scratch) { + secp256k1_scratch_space *scratch_small; + secp256k1_musig_session session[2]; + secp256k1_musig_session verifier_session; + secp256k1_musig_session_signer_data signer0[2]; + secp256k1_musig_session_signer_data signer1[2]; + secp256k1_musig_session_signer_data verifier_signer_data[2]; + secp256k1_musig_partial_signature partial_sig[2]; + secp256k1_musig_partial_signature partial_sig_adapted[2]; + secp256k1_musig_partial_signature partial_sig_overflow; + secp256k1_schnorrsig final_sig; + secp256k1_schnorrsig final_sig_cmp; + + unsigned char buf[32]; + unsigned char sk[2][32]; + unsigned char ones[32]; + unsigned char session_id[2][32]; + unsigned char nonce_commitment[2][32]; + int nonce_is_negated; + const unsigned char *ncs[2]; + unsigned char msg[32]; + unsigned char msghash[32]; + secp256k1_pubkey combined_pk; + unsigned char pk_hash[32]; + secp256k1_pubkey pk[2]; + + unsigned char sec_adaptor[32]; + unsigned char sec_adaptor1[32]; + secp256k1_pubkey adaptor; + + /** setup **/ + secp256k1_context *none = secp256k1_context_create(SECP256K1_CONTEXT_NONE); + secp256k1_context *sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + secp256k1_context *vrfy = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); + int ecount; + + secp256k1_context_set_error_callback(none, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(vrfy, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(none, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount); + + memset(ones, 0xff, 32); + + secp256k1_rand256(session_id[0]); + secp256k1_rand256(session_id[1]); + secp256k1_rand256(sk[0]); + secp256k1_rand256(sk[1]); + secp256k1_rand256(msg); + secp256k1_rand256(sec_adaptor); + + CHECK(secp256k1_ec_pubkey_create(ctx, &pk[0], sk[0]) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk[1], sk[1]) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &adaptor, sec_adaptor) == 1); + + /** main test body **/ + + /* Key combination */ + ecount = 0; + CHECK(secp256k1_musig_pubkey_combine(none, scratch, &combined_pk, pk_hash, pk, 2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_pubkey_combine(sign, scratch, &combined_pk, pk_hash, pk, 2) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, pk_hash, pk, 2) == 1); + CHECK(ecount == 2); + /* pubkey_combine does not require a scratch space */ + CHECK(secp256k1_musig_pubkey_combine(vrfy, NULL, &combined_pk, pk_hash, pk, 2) == 1); + CHECK(ecount == 2); + /* If a scratch space is given it shouldn't be too small */ + scratch_small = secp256k1_scratch_space_create(ctx, 1); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch_small, &combined_pk, pk_hash, pk, 2) == 0); + secp256k1_scratch_space_destroy(scratch_small); + CHECK(ecount == 2); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, NULL, pk_hash, pk, 2) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, NULL, pk, 2) == 1); + CHECK(ecount == 3); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, pk_hash, NULL, 2) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, pk_hash, pk, 0) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, pk_hash, NULL, 0) == 0); + CHECK(ecount == 6); + + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, pk_hash, pk, 2) == 1); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, pk_hash, pk, 2) == 1); + CHECK(secp256k1_musig_pubkey_combine(vrfy, scratch, &combined_pk, pk_hash, pk, 2) == 1); + + /** Session creation **/ + ecount = 0; + CHECK(secp256k1_musig_session_initialize(none, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_session_initialize(vrfy, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_musig_session_initialize(sign, NULL, signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], NULL, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, NULL, session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], NULL, msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 0); + CHECK(ecount == 6); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], NULL, &combined_pk, pk_hash, 2, 0, sk[0]) == 1); + CHECK(ecount == 6); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, NULL, pk_hash, 2, 0, sk[0]) == 0); + CHECK(ecount == 7); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, NULL, 2, 0, sk[0]) == 0); + CHECK(ecount == 8); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 0, 0, sk[0]) == 0); + CHECK(ecount == 8); + /* If more than UINT32_MAX fits in a size_t, test that session_initialize + * rejects n_signers that high. */ + if (SIZE_MAX > UINT32_MAX) { + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, ((size_t) UINT32_MAX) + 2, 0, sk[0]) == 0); + } + CHECK(ecount == 8); + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, NULL) == 0); + CHECK(ecount == 9); + /* secret key overflows */ + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, ones) == 0); + CHECK(ecount == 9); + + + { + secp256k1_musig_session session_without_msg; + CHECK(secp256k1_musig_session_initialize(sign, &session_without_msg, signer0, nonce_commitment[0], session_id[0], NULL, &combined_pk, pk_hash, 2, 0, sk[0]) == 1); + CHECK(secp256k1_musig_session_set_msg(none, &session_without_msg, msg) == 1); + CHECK(secp256k1_musig_session_set_msg(none, &session_without_msg, msg) == 0); + } + CHECK(secp256k1_musig_session_initialize(sign, &session[0], signer0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 1); + CHECK(secp256k1_musig_session_initialize(sign, &session[1], signer1, nonce_commitment[1], session_id[1], msg, &combined_pk, pk_hash, 2, 1, sk[1]) == 1); + ncs[0] = nonce_commitment[0]; + ncs[1] = nonce_commitment[1]; + + ecount = 0; + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, msg, &combined_pk, pk_hash, ncs, 2) == 1); + CHECK(ecount == 0); + CHECK(secp256k1_musig_session_initialize_verifier(none, NULL, verifier_signer_data, msg, &combined_pk, pk_hash, ncs, 2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, NULL, &combined_pk, pk_hash, ncs, 2) == 1); + CHECK(ecount == 1); + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, msg, NULL, pk_hash, ncs, 2) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, msg, &combined_pk, NULL, ncs, 2) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, msg, &combined_pk, pk_hash, NULL, 2) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, msg, &combined_pk, pk_hash, ncs, 0) == 0); + CHECK(ecount == 4); + if (SIZE_MAX > UINT32_MAX) { + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, msg, &combined_pk, pk_hash, ncs, ((size_t) UINT32_MAX) + 2) == 0); + } + CHECK(ecount == 4); + CHECK(secp256k1_musig_session_initialize_verifier(none, &verifier_session, verifier_signer_data, msg, &combined_pk, pk_hash, ncs, 2) == 1); + + CHECK(secp256k1_musig_compute_messagehash(none, msghash, &verifier_session) == 0); + CHECK(secp256k1_musig_compute_messagehash(none, msghash, &session[0]) == 0); + + /** Signing step 0 -- exchange nonce commitments */ + ecount = 0; + { + secp256k1_pubkey nonce; + + /* Can obtain public nonce after commitments have been exchanged; still can't sign */ + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[0], signer0, &nonce, ncs, 2) == 1); + CHECK(secp256k1_musig_partial_sign(none, &session[0], &partial_sig[0]) == 0); + CHECK(ecount == 0); + } + + /** Signing step 1 -- exchange nonces */ + ecount = 0; + { + secp256k1_pubkey public_nonce[3]; + + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[0], signer0, &public_nonce[0], ncs, 2) == 1); + CHECK(ecount == 0); + CHECK(secp256k1_musig_session_get_public_nonce(none, NULL, signer0, &public_nonce[0], ncs, 2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[0], NULL, &public_nonce[0], ncs, 2) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[0], signer0, NULL, ncs, 2) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[0], signer0, &public_nonce[0], NULL, 2) == 0); + CHECK(ecount == 4); + /* Number of commitments and number of signers are different */ + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[0], signer0, &public_nonce[0], ncs, 1) == 0); + CHECK(ecount == 4); + + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[0], signer0, &public_nonce[0], ncs, 2) == 1); + CHECK(secp256k1_musig_session_get_public_nonce(none, &session[1], signer1, &public_nonce[1], ncs, 2) == 1); + + CHECK(secp256k1_musig_set_nonce(none, &signer0[0], &public_nonce[0]) == 1); + CHECK(secp256k1_musig_set_nonce(none, &signer0[1], &public_nonce[0]) == 0); + CHECK(secp256k1_musig_set_nonce(none, &signer0[1], &public_nonce[1]) == 1); + CHECK(secp256k1_musig_set_nonce(none, &signer0[1], &public_nonce[1]) == 1); + CHECK(ecount == 4); + + CHECK(secp256k1_musig_set_nonce(none, NULL, &public_nonce[0]) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_musig_set_nonce(none, &signer1[0], NULL) == 0); + CHECK(ecount == 6); + + CHECK(secp256k1_musig_set_nonce(none, &signer1[0], &public_nonce[0]) == 1); + CHECK(secp256k1_musig_set_nonce(none, &signer1[1], &public_nonce[1]) == 1); + CHECK(secp256k1_musig_set_nonce(none, &verifier_signer_data[0], &public_nonce[0]) == 1); + CHECK(secp256k1_musig_set_nonce(none, &verifier_signer_data[1], &public_nonce[1]) == 1); + + ecount = 0; + CHECK(secp256k1_musig_session_combine_nonces(none, &session[0], signer0, 2, &nonce_is_negated, &adaptor) == 1); + CHECK(secp256k1_musig_session_combine_nonces(none, NULL, signer0, 2, &nonce_is_negated, &adaptor) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_session_combine_nonces(none, &session[0], NULL, 2, &nonce_is_negated, &adaptor) == 0); + CHECK(ecount == 2); + /* Number of signers differs from number during intialization */ + CHECK(secp256k1_musig_session_combine_nonces(none, &session[0], signer0, 1, &nonce_is_negated, &adaptor) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_session_combine_nonces(none, &session[0], signer0, 2, NULL, &adaptor) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_musig_session_combine_nonces(none, &session[0], signer0, 2, &nonce_is_negated, NULL) == 1); + + CHECK(secp256k1_musig_session_combine_nonces(none, &session[0], signer0, 2, &nonce_is_negated, &adaptor) == 1); + CHECK(secp256k1_musig_session_combine_nonces(none, &session[1], signer0, 2, &nonce_is_negated, &adaptor) == 1); + CHECK(secp256k1_musig_session_combine_nonces(none, &verifier_session, verifier_signer_data, 2, &nonce_is_negated, &adaptor) == 1); + } + + /** Signing step 2 -- partial signatures */ + ecount = 0; + CHECK(secp256k1_musig_partial_sign(none, &session[0], &partial_sig[0]) == 1); + CHECK(ecount == 0); + CHECK(secp256k1_musig_partial_sign(none, NULL, &partial_sig[0]) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_partial_sign(none, &session[0], NULL) == 0); + CHECK(ecount == 2); + + CHECK(secp256k1_musig_partial_sign(none, &session[0], &partial_sig[0]) == 1); + CHECK(secp256k1_musig_partial_sign(none, &session[1], &partial_sig[1]) == 1); + /* observer can't sign */ + CHECK(secp256k1_musig_partial_sign(none, &verifier_session, &partial_sig[2]) == 0); + CHECK(ecount == 2); + + ecount = 0; + CHECK(secp256k1_musig_partial_signature_serialize(none, buf, &partial_sig[0]) == 1); + CHECK(secp256k1_musig_partial_signature_serialize(none, NULL, &partial_sig[0]) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_partial_signature_serialize(none, buf, NULL) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_partial_signature_parse(none, &partial_sig[0], buf) == 1); + CHECK(secp256k1_musig_partial_signature_parse(none, NULL, buf) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_musig_partial_signature_parse(none, &partial_sig[0], NULL) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_musig_partial_signature_parse(none, &partial_sig_overflow, ones) == 1); + + /** Partial signature verification */ + ecount = 0; + CHECK(secp256k1_musig_partial_sig_verify(none, &session[0], &signer0[0], &partial_sig[0], &pk[0]) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_partial_sig_verify(sign, &session[0], &signer0[0], &partial_sig[0], &pk[0]) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], &signer0[0], &partial_sig[0], &pk[0]) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], &signer0[0], &partial_sig[1], &pk[0]) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, NULL, &signer0[0], &partial_sig[0], &pk[0]) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], NULL, &partial_sig[0], &pk[0]) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], &signer0[0], NULL, &pk[0]) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], &signer0[0], &partial_sig_overflow, &pk[0]) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], &signer0[0], &partial_sig[0], NULL) == 0); + CHECK(ecount == 6); + + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], &signer0[0], &partial_sig[0], &pk[0]) == 1); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[1], &signer1[0], &partial_sig[0], &pk[0]) == 1); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[0], &signer0[1], &partial_sig[1], &pk[1]) == 1); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &session[1], &signer1[1], &partial_sig[1], &pk[1]) == 1); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &verifier_session, &verifier_signer_data[0], &partial_sig[0], &pk[0]) == 1); + CHECK(secp256k1_musig_partial_sig_verify(vrfy, &verifier_session, &verifier_signer_data[1], &partial_sig[1], &pk[1]) == 1); + CHECK(ecount == 6); + + /** Adaptor signature verification */ + memcpy(&partial_sig_adapted[1], &partial_sig[1], sizeof(partial_sig_adapted[1])); + ecount = 0; + CHECK(secp256k1_musig_partial_sig_adapt(none, &partial_sig_adapted[0], &partial_sig[0], sec_adaptor, nonce_is_negated) == 1); + CHECK(secp256k1_musig_partial_sig_adapt(none, NULL, &partial_sig[0], sec_adaptor, 0) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_partial_sig_adapt(none, &partial_sig_adapted[0], NULL, sec_adaptor, 0) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_partial_sig_adapt(none, &partial_sig_adapted[0], &partial_sig_overflow, sec_adaptor, nonce_is_negated) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_partial_sig_adapt(none, &partial_sig_adapted[0], &partial_sig[0], NULL, 0) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_musig_partial_sig_adapt(none, &partial_sig_adapted[0], &partial_sig[0], ones, nonce_is_negated) == 0); + CHECK(ecount == 3); + + /** Signing combining and verification */ + ecount = 0; + CHECK(secp256k1_musig_partial_sig_combine(none, &session[0], &final_sig, partial_sig_adapted, 2) == 1); + CHECK(secp256k1_musig_partial_sig_combine(none, &session[0], &final_sig_cmp, partial_sig_adapted, 2) == 1); + CHECK(memcmp(&final_sig, &final_sig_cmp, sizeof(final_sig)) == 0); + CHECK(secp256k1_musig_partial_sig_combine(none, &session[0], &final_sig_cmp, partial_sig_adapted, 2) == 1); + CHECK(memcmp(&final_sig, &final_sig_cmp, sizeof(final_sig)) == 0); + + CHECK(secp256k1_musig_partial_sig_combine(none, NULL, &final_sig, partial_sig_adapted, 2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_partial_sig_combine(none, &session[0], NULL, partial_sig_adapted, 2) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_musig_partial_sig_combine(none, &session[0], &final_sig, NULL, 2) == 0); + CHECK(ecount == 3); + { + secp256k1_musig_partial_signature partial_sig_tmp[2]; + partial_sig_tmp[0] = partial_sig_adapted[0]; + partial_sig_tmp[1] = partial_sig_overflow; + CHECK(secp256k1_musig_partial_sig_combine(none, &session[0], &final_sig, partial_sig_tmp, 2) == 0); + } + CHECK(ecount == 3); + /* Wrong number of partial sigs */ + CHECK(secp256k1_musig_partial_sig_combine(none, &session[0], &final_sig, partial_sig_adapted, 1) == 0); + CHECK(ecount == 3); + + CHECK(secp256k1_schnorrsig_verify(vrfy, &final_sig, msg, &combined_pk) == 1); + + /** Secret adaptor can be extracted from signature */ + ecount = 0; + CHECK(secp256k1_musig_extract_secret_adaptor(none, sec_adaptor1, &final_sig, partial_sig, 2, nonce_is_negated) == 1); + CHECK(memcmp(sec_adaptor, sec_adaptor1, 32) == 0); + CHECK(secp256k1_musig_extract_secret_adaptor(none, NULL, &final_sig, partial_sig, 2, 0) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_musig_extract_secret_adaptor(none, sec_adaptor1, NULL, partial_sig, 2, 0) == 0); + CHECK(ecount == 2); + { + secp256k1_schnorrsig final_sig_tmp = final_sig; + memcpy(&final_sig_tmp.data[32], ones, 32); + CHECK(secp256k1_musig_extract_secret_adaptor(none, sec_adaptor1, &final_sig_tmp, partial_sig, 2, nonce_is_negated) == 0); + } + CHECK(ecount == 2); + CHECK(secp256k1_musig_extract_secret_adaptor(none, sec_adaptor1, &final_sig, NULL, 2, 0) == 0); + CHECK(ecount == 3); + { + secp256k1_musig_partial_signature partial_sig_tmp[2]; + partial_sig_tmp[0] = partial_sig[0]; + partial_sig_tmp[1] = partial_sig_overflow; + CHECK(secp256k1_musig_extract_secret_adaptor(none, sec_adaptor1, &final_sig, partial_sig_tmp, 2, nonce_is_negated) == 0); + } + CHECK(ecount == 3); + CHECK(secp256k1_musig_extract_secret_adaptor(none, sec_adaptor1, &final_sig, partial_sig, 0, 0) == 1); + CHECK(secp256k1_musig_extract_secret_adaptor(none, sec_adaptor1, &final_sig, partial_sig, 2, 1) == 1); + + /** cleanup **/ + memset(&session, 0, sizeof(session)); + secp256k1_context_destroy(none); + secp256k1_context_destroy(sign); + secp256k1_context_destroy(vrfy); +} + +/* Initializes two sessions, one use the given parameters (session_id, + * nonce_commitments, etc.) except that `session_tmp` uses new signers with different + * public keys. The point of this test is to call `musig_session_get_public_nonce` + * with signers from `session_tmp` who have different public keys than the correct + * ones and return the resulting messagehash. This should not result in a different + * messagehash because the public keys of the signers are only used during session + * initialization. */ +int musig_state_machine_diff_signer_msghash_test(unsigned char *msghash, secp256k1_pubkey *pks, secp256k1_pubkey *combined_pk, unsigned char *pk_hash, const unsigned char * const *nonce_commitments, unsigned char *msg, secp256k1_pubkey *nonce_other, unsigned char *sk, unsigned char *session_id) { + secp256k1_musig_session session; + secp256k1_musig_session session_tmp; + unsigned char nonce_commitment[32]; + secp256k1_musig_session_signer_data signers[2]; + secp256k1_musig_session_signer_data signers_tmp[2]; + unsigned char sk_dummy[32]; + secp256k1_pubkey pks_tmp[2]; + secp256k1_pubkey combined_pk_tmp; + unsigned char pk_hash_tmp[32]; + secp256k1_pubkey nonce; + + /* Set up signers with different public keys */ + secp256k1_rand256(sk_dummy); + pks_tmp[0] = pks[0]; + CHECK(secp256k1_ec_pubkey_create(ctx, &pks_tmp[1], sk_dummy) == 1); + CHECK(secp256k1_musig_pubkey_combine(ctx, NULL, &combined_pk_tmp, pk_hash_tmp, pks_tmp, 2) == 1); + CHECK(secp256k1_musig_session_initialize(ctx, &session_tmp, signers_tmp, nonce_commitment, session_id, msg, &combined_pk_tmp, pk_hash_tmp, 2, 0, sk_dummy) == 1); + + CHECK(secp256k1_musig_session_initialize(ctx, &session, signers, nonce_commitment, session_id, msg, combined_pk, pk_hash, 2, 0, sk) == 1); + CHECK(memcmp(nonce_commitment, nonce_commitments[1], 32) == 0); + /* Call get_public_nonce with different signers than the signers the session was + * initialized with. */ + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session_tmp, signers, &nonce, nonce_commitments, 2) == 1); + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session, signers_tmp, &nonce, nonce_commitments, 2) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[0], nonce_other) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[1], &nonce) == 1); + CHECK(secp256k1_musig_session_combine_nonces(ctx, &session, signers, 2, NULL, NULL) == 1); + + return secp256k1_musig_compute_messagehash(ctx, msghash, &session); +} + +/* Creates a new session (with a different session id) and tries to use that session + * to combine nonces with given signers_other. This should fail, because the nonce + * commitments of signers_other do not match the nonce commitments the new session + * was initialized with. If do_test is 0, the correct signers are being used and + * therefore the function should return 1. */ +int musig_state_machine_diff_signers_combine_nonce_test(secp256k1_pubkey *combined_pk, unsigned char *pk_hash, unsigned char *nonce_commitment_other, secp256k1_pubkey *nonce_other, unsigned char *msg, unsigned char *sk, secp256k1_musig_session_signer_data *signers_other, int do_test) { + secp256k1_musig_session session; + secp256k1_musig_session_signer_data signers[2]; + secp256k1_musig_session_signer_data *signers_to_use; + unsigned char nonce_commitment[32]; + unsigned char session_id[32]; + secp256k1_pubkey nonce; + const unsigned char *ncs[2]; + + /* Initialize new signers */ + secp256k1_rand256(session_id); + CHECK(secp256k1_musig_session_initialize(ctx, &session, signers, nonce_commitment, session_id, msg, combined_pk, pk_hash, 2, 1, sk) == 1); + ncs[0] = nonce_commitment_other; + ncs[1] = nonce_commitment; + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session, signers, &nonce, ncs, 2) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[0], nonce_other) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[1], &nonce) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[1], &nonce) == 1); + secp256k1_musig_session_combine_nonces(ctx, &session, signers_other, 2, NULL, NULL); + if (do_test) { + signers_to_use = signers_other; + } else { + signers_to_use = signers; + } + return secp256k1_musig_session_combine_nonces(ctx, &session, signers_to_use, 2, NULL, NULL); +} + +/* Recreates a session with the given session_id, signers, pk, msg etc. parameters + * and tries to sign and verify the other signers partial signature. Both should fail + * if msg is NULL. */ +int musig_state_machine_missing_msg_test(secp256k1_pubkey *pks, secp256k1_pubkey *combined_pk, unsigned char *pk_hash, unsigned char *nonce_commitment_other, secp256k1_pubkey *nonce_other, secp256k1_musig_partial_signature *partial_sig_other, unsigned char *sk, unsigned char *session_id, unsigned char *msg) { + secp256k1_musig_session session; + secp256k1_musig_session_signer_data signers[2]; + unsigned char nonce_commitment[32]; + const unsigned char *ncs[2]; + secp256k1_pubkey nonce; + secp256k1_musig_partial_signature partial_sig; + int partial_sign, partial_verify; + + CHECK(secp256k1_musig_session_initialize(ctx, &session, signers, nonce_commitment, session_id, msg, combined_pk, pk_hash, 2, 0, sk) == 1); + ncs[0] = nonce_commitment_other; + ncs[1] = nonce_commitment; + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session, signers, &nonce, ncs, 2) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[0], nonce_other) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[1], &nonce) == 1); + + CHECK(secp256k1_musig_session_combine_nonces(ctx, &session, signers, 2, NULL, NULL) == 1); + partial_sign = secp256k1_musig_partial_sign(ctx, &session, &partial_sig); + partial_verify = secp256k1_musig_partial_sig_verify(ctx, &session, &signers[0], partial_sig_other, &pks[0]); + if (msg != NULL) { + /* Return 1 if both succeeded */ + return partial_sign && partial_verify; + } + /* Return 0 if both failed */ + return partial_sign || partial_verify; +} + +/* Recreates a session with the given session_id, signers, pk, msg etc. parameters + * and tries to verify and combine partial sigs. If do_combine is 0, the + * combine_nonces step is left out. In that case verify and combine should fail and + * this function should return 0. */ +int musig_state_machine_missing_combine_test(secp256k1_pubkey *pks, secp256k1_pubkey *combined_pk, unsigned char *pk_hash, unsigned char *nonce_commitment_other, secp256k1_pubkey *nonce_other, secp256k1_musig_partial_signature *partial_sig_other, unsigned char *msg, unsigned char *sk, unsigned char *session_id, secp256k1_musig_partial_signature *partial_sig, int do_combine) { + secp256k1_musig_session session; + secp256k1_musig_session_signer_data signers[2]; + unsigned char nonce_commitment[32]; + const unsigned char *ncs[2]; + secp256k1_pubkey nonce; + secp256k1_musig_partial_signature partial_sigs[2]; + secp256k1_schnorrsig sig; + int partial_verify, sig_combine; + + CHECK(secp256k1_musig_session_initialize(ctx, &session, signers, nonce_commitment, session_id, msg, combined_pk, pk_hash, 2, 0, sk) == 1); + ncs[0] = nonce_commitment_other; + ncs[1] = nonce_commitment; + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session, signers, &nonce, ncs, 2) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[0], nonce_other) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers[1], &nonce) == 1); + + partial_sigs[0] = *partial_sig_other; + partial_sigs[1] = *partial_sig; + if (do_combine != 0) { + CHECK(secp256k1_musig_session_combine_nonces(ctx, &session, signers, 2, NULL, NULL) == 1); + } + partial_verify = secp256k1_musig_partial_sig_verify(ctx, &session, signers, partial_sig_other, &pks[0]); + sig_combine = secp256k1_musig_partial_sig_combine(ctx, &session, &sig, partial_sigs, 2); + if (do_combine != 0) { + /* Return 1 if both succeeded */ + return partial_verify && sig_combine; + } + /* Return 0 if both failed */ + return partial_verify || sig_combine; +} + +void musig_state_machine_tests(secp256k1_scratch_space *scratch) { + size_t i; + secp256k1_musig_session session[2]; + secp256k1_musig_session_signer_data signers0[2]; + secp256k1_musig_session_signer_data signers1[2]; + unsigned char nonce_commitment[2][32]; + unsigned char session_id[2][32]; + unsigned char msg[32]; + unsigned char sk[2][32]; + secp256k1_pubkey pk[2]; + secp256k1_pubkey combined_pk; + unsigned char pk_hash[32]; + secp256k1_pubkey nonce[2]; + const unsigned char *ncs[2]; + secp256k1_musig_partial_signature partial_sig[2]; + unsigned char msghash1[32]; + unsigned char msghash2[32]; + + /* Run state machine with the same objects twice to test that it's allowed to + * reinitialize session and session_signer_data. */ + for (i = 0; i < 2; i++) { + /* Setup */ + secp256k1_rand256(session_id[0]); + secp256k1_rand256(session_id[1]); + secp256k1_rand256(sk[0]); + secp256k1_rand256(sk[1]); + secp256k1_rand256(msg); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk[0], sk[0]) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk[1], sk[1]) == 1); + CHECK(secp256k1_musig_pubkey_combine(ctx, scratch, &combined_pk, pk_hash, pk, 2) == 1); + CHECK(secp256k1_musig_session_initialize(ctx, &session[0], signers0, nonce_commitment[0], session_id[0], msg, &combined_pk, pk_hash, 2, 0, sk[0]) == 1); + CHECK(secp256k1_musig_session_initialize(ctx, &session[1], signers1, nonce_commitment[1], session_id[1], msg, &combined_pk, pk_hash, 2, 1, sk[1]) == 1); + + /* Set nonce commitments */ + ncs[0] = nonce_commitment[0]; + ncs[1] = nonce_commitment[1]; + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session[0], signers0, &nonce[0], ncs, 2) == 1); + /* Changing a nonce commitment is not okay */ + ncs[1] = (unsigned char*) "this isn't a nonce commitment..."; + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session[0], signers0, &nonce[0], ncs, 2) == 0); + /* Repeating with the same nonce commitments is okay */ + ncs[1] = nonce_commitment[1]; + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session[0], signers0, &nonce[0], ncs, 2) == 1); + + /* Get nonce for signer 1 */ + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &session[1], signers1, &nonce[1], ncs, 2) == 1); + + /* Set nonces */ + CHECK(secp256k1_musig_set_nonce(ctx, &signers0[0], &nonce[0]) == 1); + /* Can't set nonce that doesn't match nonce commitment */ + CHECK(secp256k1_musig_set_nonce(ctx, &signers0[1], &nonce[0]) == 0); + /* Set correct nonce */ + CHECK(secp256k1_musig_set_nonce(ctx, &signers0[1], &nonce[1]) == 1); + + /* Combine nonces */ + CHECK(secp256k1_musig_session_combine_nonces(ctx, &session[0], signers0, 2, NULL, NULL) == 1); + /* Not everyone is present from signer 1's view */ + CHECK(secp256k1_musig_session_combine_nonces(ctx, &session[1], signers1, 2, NULL, NULL) == 0); + /* Make everyone present */ + CHECK(secp256k1_musig_set_nonce(ctx, &signers1[0], &nonce[0]) == 1); + CHECK(secp256k1_musig_set_nonce(ctx, &signers1[1], &nonce[1]) == 1); + + /* Can't combine nonces from signers of a different session */ + CHECK(musig_state_machine_diff_signers_combine_nonce_test(&combined_pk, pk_hash, nonce_commitment[0], &nonce[0], msg, sk[1], signers1, 1) == 0); + CHECK(musig_state_machine_diff_signers_combine_nonce_test(&combined_pk, pk_hash, nonce_commitment[0], &nonce[0], msg, sk[1], signers1, 0) == 1); + + /* Partially sign */ + CHECK(secp256k1_musig_partial_sign(ctx, &session[0], &partial_sig[0]) == 1); + /* Can't verify or sign until nonce is combined */ + CHECK(secp256k1_musig_partial_sig_verify(ctx, &session[1], &signers1[0], &partial_sig[0], &pk[0]) == 0); + CHECK(secp256k1_musig_partial_sign(ctx, &session[1], &partial_sig[1]) == 0); + CHECK(secp256k1_musig_session_combine_nonces(ctx, &session[1], signers1, 2, NULL, NULL) == 1); + CHECK(secp256k1_musig_partial_sig_verify(ctx, &session[1], &signers1[0], &partial_sig[0], &pk[0]) == 1); + /* messagehash should be the same as a session whose get_public_nonce was called + * with different signers (i.e. they diff in public keys). This is because the + * public keys of the signers is set in stone when initializing the session. */ + CHECK(secp256k1_musig_compute_messagehash(ctx, msghash1, &session[1]) == 1); + CHECK(musig_state_machine_diff_signer_msghash_test(msghash2, pk, &combined_pk, pk_hash, ncs, msg, &nonce[0], sk[1], session_id[1]) == 1); + CHECK(memcmp(msghash1, msghash2, 32) == 0); + CHECK(secp256k1_musig_partial_sign(ctx, &session[1], &partial_sig[1]) == 1); + CHECK(secp256k1_musig_partial_sig_verify(ctx, &session[1], &signers1[1], &partial_sig[1], &pk[1]) == 1); + /* Wrong signature */ + CHECK(secp256k1_musig_partial_sig_verify(ctx, &session[1], &signers1[1], &partial_sig[0], &pk[1]) == 0); + /* Can't sign or verify until msg is set */ + CHECK(musig_state_machine_missing_msg_test(pk, &combined_pk, pk_hash, nonce_commitment[0], &nonce[0], &partial_sig[0], sk[1], session_id[1], NULL) == 0); + CHECK(musig_state_machine_missing_msg_test(pk, &combined_pk, pk_hash, nonce_commitment[0], &nonce[0], &partial_sig[0], sk[1], session_id[1], msg) == 1); + + /* Can't verify and combine partial sigs until nonces are combined */ + CHECK(musig_state_machine_missing_combine_test(pk, &combined_pk, pk_hash, nonce_commitment[0], &nonce[0], &partial_sig[0], msg, sk[1], session_id[1], &partial_sig[1], 0) == 0); + CHECK(musig_state_machine_missing_combine_test(pk, &combined_pk, pk_hash, nonce_commitment[0], &nonce[0], &partial_sig[0], msg, sk[1], session_id[1], &partial_sig[1], 1) == 1); + } +} + +void scriptless_atomic_swap(secp256k1_scratch_space *scratch) { + /* Throughout this test "a" and "b" refer to two hypothetical blockchains, + * while the indices 0 and 1 refer to the two signers. Here signer 0 is + * sending a-coins to signer 1, while signer 1 is sending b-coins to signer + * 0. Signer 0 produces the adaptor signatures. */ + secp256k1_schnorrsig final_sig_a; + secp256k1_schnorrsig final_sig_b; + secp256k1_musig_partial_signature partial_sig_a[2]; + secp256k1_musig_partial_signature partial_sig_b_adapted[2]; + secp256k1_musig_partial_signature partial_sig_b[2]; + unsigned char sec_adaptor[32]; + unsigned char sec_adaptor_extracted[32]; + secp256k1_pubkey pub_adaptor; + + unsigned char seckey_a[2][32]; + unsigned char seckey_b[2][32]; + secp256k1_pubkey pk_a[2]; + secp256k1_pubkey pk_b[2]; + unsigned char pk_hash_a[32]; + unsigned char pk_hash_b[32]; + secp256k1_pubkey combined_pk_a; + secp256k1_pubkey combined_pk_b; + secp256k1_musig_session musig_session_a[2]; + secp256k1_musig_session musig_session_b[2]; + unsigned char noncommit_a[2][32]; + unsigned char noncommit_b[2][32]; + const unsigned char *noncommit_a_ptr[2]; + const unsigned char *noncommit_b_ptr[2]; + secp256k1_pubkey pubnon_a[2]; + secp256k1_pubkey pubnon_b[2]; + int nonce_is_negated_a; + int nonce_is_negated_b; + secp256k1_musig_session_signer_data data_a[2]; + secp256k1_musig_session_signer_data data_b[2]; + + const unsigned char seed[32] = "still tired of choosing seeds..."; + const unsigned char msg32_a[32] = "this is the message blockchain a"; + const unsigned char msg32_b[32] = "this is the message blockchain b"; + + /* Step 1: key setup */ + secp256k1_rand256(seckey_a[0]); + secp256k1_rand256(seckey_a[1]); + secp256k1_rand256(seckey_b[0]); + secp256k1_rand256(seckey_b[1]); + secp256k1_rand256(sec_adaptor); + + CHECK(secp256k1_ec_pubkey_create(ctx, &pk_a[0], seckey_a[0])); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk_a[1], seckey_a[1])); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk_b[0], seckey_b[0])); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk_b[1], seckey_b[1])); + CHECK(secp256k1_ec_pubkey_create(ctx, &pub_adaptor, sec_adaptor)); + + CHECK(secp256k1_musig_pubkey_combine(ctx, scratch, &combined_pk_a, pk_hash_a, pk_a, 2)); + CHECK(secp256k1_musig_pubkey_combine(ctx, scratch, &combined_pk_b, pk_hash_b, pk_b, 2)); + + CHECK(secp256k1_musig_session_initialize(ctx, &musig_session_a[0], data_a, noncommit_a[0], seed, msg32_a, &combined_pk_a, pk_hash_a, 2, 0, seckey_a[0])); + CHECK(secp256k1_musig_session_initialize(ctx, &musig_session_a[1], data_a, noncommit_a[1], seed, msg32_a, &combined_pk_a, pk_hash_a, 2, 1, seckey_a[1])); + noncommit_a_ptr[0] = noncommit_a[0]; + noncommit_a_ptr[1] = noncommit_a[1]; + + CHECK(secp256k1_musig_session_initialize(ctx, &musig_session_b[0], data_b, noncommit_b[0], seed, msg32_b, &combined_pk_b, pk_hash_b, 2, 0, seckey_b[0])); + CHECK(secp256k1_musig_session_initialize(ctx, &musig_session_b[1], data_b, noncommit_b[1], seed, msg32_b, &combined_pk_b, pk_hash_b, 2, 1, seckey_b[1])); + noncommit_b_ptr[0] = noncommit_b[0]; + noncommit_b_ptr[1] = noncommit_b[1]; + + /* Step 2: Exchange nonces */ + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &musig_session_a[0], data_a, &pubnon_a[0], noncommit_a_ptr, 2)); + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &musig_session_a[1], data_a, &pubnon_a[1], noncommit_a_ptr, 2)); + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &musig_session_b[0], data_b, &pubnon_b[0], noncommit_b_ptr, 2)); + CHECK(secp256k1_musig_session_get_public_nonce(ctx, &musig_session_b[1], data_b, &pubnon_b[1], noncommit_b_ptr, 2)); + CHECK(secp256k1_musig_set_nonce(ctx, &data_a[0], &pubnon_a[0])); + CHECK(secp256k1_musig_set_nonce(ctx, &data_a[1], &pubnon_a[1])); + CHECK(secp256k1_musig_set_nonce(ctx, &data_b[0], &pubnon_b[0])); + CHECK(secp256k1_musig_set_nonce(ctx, &data_b[1], &pubnon_b[1])); + CHECK(secp256k1_musig_session_combine_nonces(ctx, &musig_session_a[0], data_a, 2, &nonce_is_negated_a, &pub_adaptor)); + CHECK(secp256k1_musig_session_combine_nonces(ctx, &musig_session_a[1], data_a, 2, NULL, &pub_adaptor)); + CHECK(secp256k1_musig_session_combine_nonces(ctx, &musig_session_b[0], data_b, 2, &nonce_is_negated_b, &pub_adaptor)); + CHECK(secp256k1_musig_session_combine_nonces(ctx, &musig_session_b[1], data_b, 2, NULL, &pub_adaptor)); + + /* Step 3: Signer 0 produces partial signatures for both chains. */ + CHECK(secp256k1_musig_partial_sign(ctx, &musig_session_a[0], &partial_sig_a[0])); + CHECK(secp256k1_musig_partial_sign(ctx, &musig_session_b[0], &partial_sig_b[0])); + + /* Step 4: Signer 1 receives partial signatures, verifies them and creates a + * partial signature to send B-coins to signer 0. */ + CHECK(secp256k1_musig_partial_sig_verify(ctx, &musig_session_a[1], data_a, &partial_sig_a[0], &pk_a[0]) == 1); + CHECK(secp256k1_musig_partial_sig_verify(ctx, &musig_session_b[1], data_b, &partial_sig_b[0], &pk_b[0]) == 1); + CHECK(secp256k1_musig_partial_sign(ctx, &musig_session_b[1], &partial_sig_b[1])); + + /* Step 5: Signer 0 adapts its own partial signature and combines it with the + * partial signature from signer 1. This results in a complete signature which + * is broadcasted by signer 0 to take B-coins. */ + CHECK(secp256k1_musig_partial_sig_adapt(ctx, &partial_sig_b_adapted[0], &partial_sig_b[0], sec_adaptor, nonce_is_negated_b)); + memcpy(&partial_sig_b_adapted[1], &partial_sig_b[1], sizeof(partial_sig_b_adapted[1])); + CHECK(secp256k1_musig_partial_sig_combine(ctx, &musig_session_b[0], &final_sig_b, partial_sig_b_adapted, 2) == 1); + CHECK(secp256k1_schnorrsig_verify(ctx, &final_sig_b, msg32_b, &combined_pk_b) == 1); + + /* Step 6: Signer 1 extracts adaptor from the published signature, applies it to + * other partial signature, and takes A-coins. */ + CHECK(secp256k1_musig_extract_secret_adaptor(ctx, sec_adaptor_extracted, &final_sig_b, partial_sig_b, 2, nonce_is_negated_b) == 1); + CHECK(memcmp(sec_adaptor_extracted, sec_adaptor, sizeof(sec_adaptor)) == 0); /* in real life we couldn't check this, of course */ + CHECK(secp256k1_musig_partial_sig_adapt(ctx, &partial_sig_a[0], &partial_sig_a[0], sec_adaptor_extracted, nonce_is_negated_a)); + CHECK(secp256k1_musig_partial_sign(ctx, &musig_session_a[1], &partial_sig_a[1])); + CHECK(secp256k1_musig_partial_sig_combine(ctx, &musig_session_a[1], &final_sig_a, partial_sig_a, 2) == 1); + CHECK(secp256k1_schnorrsig_verify(ctx, &final_sig_a, msg32_a, &combined_pk_a) == 1); +} + +/* Checks that hash initialized by secp256k1_musig_sha256_init_tagged has the + * expected state. */ +void sha256_tag_test(void) { + char tag[17] = "MuSig coefficient"; + secp256k1_sha256 sha; + secp256k1_sha256 sha_tagged; + unsigned char buf[32]; + unsigned char buf2[32]; + size_t i; + + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, (unsigned char *) tag, 17); + secp256k1_sha256_finalize(&sha, buf); + /* buf = SHA256("MuSig coefficient") */ + + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, buf, 32); + secp256k1_sha256_write(&sha, buf, 32); + /* Is buffer fully consumed? */ + CHECK((sha.bytes & 0x3F) == 0); + + /* Compare with tagged SHA */ + secp256k1_musig_sha256_init_tagged(&sha_tagged); + for (i = 0; i < 8; i++) { + CHECK(sha_tagged.s[i] == sha.s[i]); + } + secp256k1_sha256_write(&sha, buf, 32); + secp256k1_sha256_write(&sha_tagged, buf, 32); + secp256k1_sha256_finalize(&sha, buf); + secp256k1_sha256_finalize(&sha_tagged, buf2); + CHECK(memcmp(buf, buf2, 32) == 0); +} + +void run_musig_tests(void) { + int i; + secp256k1_scratch_space *scratch = secp256k1_scratch_space_create(ctx, 1024 * 1024); + + musig_api_tests(scratch); + musig_state_machine_tests(scratch); + for (i = 0; i < count; i++) { + /* Run multiple times to ensure that the nonce is negated in some tests */ + scriptless_atomic_swap(scratch); + } + sha256_tag_test(); + + secp256k1_scratch_space_destroy(scratch); +} + +#endif + diff --git a/src/secp256k1/src/modules/schnorrsig/Makefile.am.include b/src/secp256k1/src/modules/schnorrsig/Makefile.am.include new file mode 100644 index 000000000..0296c1299 --- /dev/null +++ b/src/secp256k1/src/modules/schnorrsig/Makefile.am.include @@ -0,0 +1,9 @@ +include_HEADERS += include/secp256k1_schnorrsig.h +noinst_HEADERS += src/modules/schnorrsig/main_impl.h +noinst_HEADERS += src/modules/schnorrsig/tests_impl.h +if USE_BENCHMARK +noinst_PROGRAMS += bench_schnorrsig +bench_schnorrsig_SOURCES = src/bench_schnorrsig.c +bench_schnorrsig_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB) +endif + diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h new file mode 100644 index 000000000..b366236d8 --- /dev/null +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -0,0 +1,339 @@ +/********************************************************************** + * Copyright (c) 2018 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_SCHNORRSIG_MAIN_ +#define _SECP256K1_MODULE_SCHNORRSIG_MAIN_ + +#include "include/secp256k1.h" +#include "include/secp256k1_schnorrsig.h" +#include "hash.h" + +int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { + (void) ctx; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(out64 != NULL); + ARG_CHECK(sig != NULL); + memcpy(out64, sig->data, 64); + return 1; +} + +int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64) { + (void) ctx; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(in64 != NULL); + memcpy(sig->data, in64, 64); + return 1; +} + +int secp256k1_schnorrsig_sign(const secp256k1_context* ctx, secp256k1_schnorrsig *sig, int *nonce_is_negated, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, void *ndata) { + secp256k1_scalar x; + secp256k1_scalar e; + secp256k1_scalar k; + secp256k1_gej pkj; + secp256k1_gej rj; + secp256k1_ge pk; + secp256k1_ge r; + secp256k1_sha256 sha; + int overflow; + unsigned char buf[33]; + size_t buflen = sizeof(buf); + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(sig != NULL); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(seckey != NULL); + + if (noncefp == NULL) { + noncefp = secp256k1_nonce_function_bipschnorr; + } + secp256k1_scalar_set_b32(&x, seckey, &overflow); + /* Fail if the secret key is invalid. */ + if (overflow || secp256k1_scalar_is_zero(&x)) { + memset(sig, 0, sizeof(*sig)); + return 0; + } + + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pkj, &x); + secp256k1_ge_set_gej(&pk, &pkj); + + if (!noncefp(buf, msg32, seckey, NULL, (void*)ndata, 0)) { + return 0; + } + secp256k1_scalar_set_b32(&k, buf, NULL); + if (secp256k1_scalar_is_zero(&k)) { + return 0; + } + + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &rj, &k); + secp256k1_ge_set_gej(&r, &rj); + + if (nonce_is_negated != NULL) { + *nonce_is_negated = 0; + } + if (!secp256k1_fe_is_quad_var(&r.y)) { + secp256k1_scalar_negate(&k, &k); + if (nonce_is_negated != NULL) { + *nonce_is_negated = 1; + } + } + secp256k1_fe_normalize(&r.x); + secp256k1_fe_get_b32(&sig->data[0], &r.x); + + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, &sig->data[0], 32); + secp256k1_eckey_pubkey_serialize(&pk, buf, &buflen, 1); + secp256k1_sha256_write(&sha, buf, buflen); + secp256k1_sha256_write(&sha, msg32, 32); + secp256k1_sha256_finalize(&sha, buf); + + secp256k1_scalar_set_b32(&e, buf, NULL); + secp256k1_scalar_mul(&e, &e, &x); + secp256k1_scalar_add(&e, &e, &k); + + secp256k1_scalar_get_b32(&sig->data[32], &e); + secp256k1_scalar_clear(&k); + secp256k1_scalar_clear(&x); + + return 1; +} + +/* Helper function for verification and batch verification. + * Computes R = sG - eP. */ +static int secp256k1_schnorrsig_real_verify(const secp256k1_context* ctx, secp256k1_gej *rj, const secp256k1_scalar *s, const secp256k1_scalar *e, const secp256k1_pubkey *pk) { + secp256k1_scalar nege; + secp256k1_ge pkp; + secp256k1_gej pkj; + + secp256k1_scalar_negate(&nege, e); + + if (!secp256k1_pubkey_load(ctx, &pkp, pk)) { + return 0; + } + secp256k1_gej_set_ge(&pkj, &pkp); + + /* rj = s*G + (-e)*pkj */ + secp256k1_ecmult(&ctx->ecmult_ctx, rj, &pkj, &nege, s); + return 1; +} + +int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk) { + secp256k1_scalar s; + secp256k1_scalar e; + secp256k1_gej rj; + secp256k1_fe rx; + secp256k1_sha256 sha; + unsigned char buf[33]; + size_t buflen = sizeof(buf); + int overflow; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(sig != NULL); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(pk != NULL); + + if (!secp256k1_fe_set_b32(&rx, &sig->data[0])) { + return 0; + } + + secp256k1_scalar_set_b32(&s, &sig->data[32], &overflow); + if (overflow) { + return 0; + } + + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, &sig->data[0], 32); + secp256k1_ec_pubkey_serialize(ctx, buf, &buflen, pk, SECP256K1_EC_COMPRESSED); + secp256k1_sha256_write(&sha, buf, buflen); + secp256k1_sha256_write(&sha, msg32, 32); + secp256k1_sha256_finalize(&sha, buf); + secp256k1_scalar_set_b32(&e, buf, NULL); + + if (!secp256k1_schnorrsig_real_verify(ctx, &rj, &s, &e, pk) + || !secp256k1_gej_has_quad_y_var(&rj) /* fails if rj is infinity */ + || !secp256k1_gej_eq_x_var(&rx, &rj)) { + return 0; + } + + return 1; +} + +/* Data that is used by the batch verification ecmult callback */ +typedef struct { + const secp256k1_context *ctx; + /* Seed for the random number generator */ + unsigned char chacha_seed[32]; + /* Caches randomizers generated by the PRNG which returns two randomizers per call. Caching + * avoids having to call the PRNG twice as often. The very first randomizer will be set to 1 and + * the PRNG is called at every odd indexed schnorrsig to fill the cache. */ + secp256k1_scalar randomizer_cache[2]; + /* Signature, message, public key tuples to verify */ + const secp256k1_schnorrsig *const *sig; + const unsigned char *const *msg32; + const secp256k1_pubkey *const *pk; + size_t n_sigs; +} secp256k1_schnorrsig_verify_ecmult_context; + +/* Callback function which is called by ecmult_multi in order to convert the ecmult_context + * consisting of signature, message and public key tuples into scalars and points. */ +static int secp256k1_schnorrsig_verify_batch_ecmult_callback(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data) { + secp256k1_schnorrsig_verify_ecmult_context *ecmult_context = (secp256k1_schnorrsig_verify_ecmult_context *) data; + + if (idx % 4 == 2) { + /* Every idx corresponds to a (scalar,point)-tuple. So this callback is called with 4 + * consecutive tuples before we need to call the RNG for new randomizers: + * (-randomizer_cache[0], R1) + * (-randomizer_cache[0]*e1, P1) + * (-randomizer_cache[1], R2) + * (-randomizer_cache[1]*e2, P2) */ + secp256k1_scalar_chacha20(&ecmult_context->randomizer_cache[0], &ecmult_context->randomizer_cache[1], ecmult_context->chacha_seed, idx / 4); + } + + /* R */ + if (idx % 2 == 0) { + secp256k1_fe rx; + *sc = ecmult_context->randomizer_cache[(idx / 2) % 2]; + if (!secp256k1_fe_set_b32(&rx, &ecmult_context->sig[idx / 2]->data[0])) { + return 0; + } + if (!secp256k1_ge_set_xquad(pt, &rx)) { + return 0; + } + /* eP */ + } else { + unsigned char buf[33]; + size_t buflen = sizeof(buf); + secp256k1_sha256 sha; + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, &ecmult_context->sig[idx / 2]->data[0], 32); + secp256k1_ec_pubkey_serialize(ecmult_context->ctx, buf, &buflen, ecmult_context->pk[idx / 2], SECP256K1_EC_COMPRESSED); + secp256k1_sha256_write(&sha, buf, buflen); + secp256k1_sha256_write(&sha, ecmult_context->msg32[idx / 2], 32); + secp256k1_sha256_finalize(&sha, buf); + + secp256k1_scalar_set_b32(sc, buf, NULL); + secp256k1_scalar_mul(sc, sc, &ecmult_context->randomizer_cache[(idx / 2) % 2]); + + if (!secp256k1_pubkey_load(ecmult_context->ctx, pt, ecmult_context->pk[idx / 2])) { + return 0; + } + } + return 1; +} + +/** Helper function for batch verification. Hashes signature verification data into the + * randomization seed and initializes ecmult_context. + * + * Returns 1 if the randomizer was successfully initialized. + * + * Args: ctx: a secp256k1 context object + * Out: ecmult_context: context for batch_ecmult_callback + * In/Out sha: an initialized sha256 object which hashes the schnorrsig input in order to get a + * seed for the randomizer PRNG + * In: sig: array of signatures, or NULL if there are no signatures + * msg32: array of messages, or NULL if there are no signatures + * pk: array of public keys, or NULL if there are no signatures + * n_sigs: number of signatures in above arrays (must be 0 if they are NULL) + */ +int secp256k1_schnorrsig_verify_batch_init_randomizer(const secp256k1_context *ctx, secp256k1_schnorrsig_verify_ecmult_context *ecmult_context, secp256k1_sha256 *sha, const secp256k1_schnorrsig *const *sig, const unsigned char *const *msg32, const secp256k1_pubkey *const *pk, size_t n_sigs) { + size_t i; + + if (n_sigs > 0) { + ARG_CHECK(sig != NULL); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(pk != NULL); + } + + for (i = 0; i < n_sigs; i++) { + unsigned char buf[33]; + size_t buflen = sizeof(buf); + secp256k1_sha256_write(sha, sig[i]->data, 64); + secp256k1_sha256_write(sha, msg32[i], 32); + secp256k1_ec_pubkey_serialize(ctx, buf, &buflen, pk[i], SECP256K1_EC_COMPRESSED); + secp256k1_sha256_write(sha, buf, 32); + } + ecmult_context->ctx = ctx; + ecmult_context->sig = sig; + ecmult_context->msg32 = msg32; + ecmult_context->pk = pk; + ecmult_context->n_sigs = n_sigs; + + return 1; +} + +/** Helper function for batch verification. Sums the s part of all signatures multiplied by their + * randomizer. + * + * Returns 1 if s is successfully summed. + * + * In/Out: s: the s part of the input sigs is added to this s argument + * In: chacha_seed: PRNG seed for computing randomizers + * sig: array of signatures, or NULL if there are no signatures + * n_sigs: number of signatures in above array (must be 0 if they are NULL) + */ +int secp256k1_schnorrsig_verify_batch_sum_s(secp256k1_scalar *s, unsigned char *chacha_seed, const secp256k1_schnorrsig *const *sig, size_t n_sigs) { + secp256k1_scalar randomizer_cache[2]; + size_t i; + + secp256k1_scalar_set_int(&randomizer_cache[0], 1); + for (i = 0; i < n_sigs; i++) { + int overflow; + secp256k1_scalar term; + if (i % 2 == 1) { + secp256k1_scalar_chacha20(&randomizer_cache[0], &randomizer_cache[1], chacha_seed, i / 2); + } + + secp256k1_scalar_set_b32(&term, &sig[i]->data[32], &overflow); + if (overflow) { + return 0; + } + secp256k1_scalar_mul(&term, &term, &randomizer_cache[i % 2]); + secp256k1_scalar_add(s, s, &term); + } + return 1; +} + +/* schnorrsig batch verification. + * Seeds a random number generator with the inputs and derives a random number ai for every + * signature i. Fails if y-coordinate of any R is not a quadratic residue or if + * 0 != -(s1 + a2*s2 + ... + au*su)G + R1 + a2*R2 + ... + au*Ru + e1*P1 + (a2*e2)P2 + ... + (au*eu)Pu. */ +int secp256k1_schnorrsig_verify_batch(const secp256k1_context *ctx, secp256k1_scratch *scratch, const secp256k1_schnorrsig *const *sig, const unsigned char *const *msg32, const secp256k1_pubkey *const *pk, size_t n_sigs) { + secp256k1_schnorrsig_verify_ecmult_context ecmult_context; + secp256k1_sha256 sha; + secp256k1_scalar s; + secp256k1_gej rj; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(scratch != NULL); + /* Check that n_sigs is less than half of the maximum size_t value. This is necessary because + * the number of points given to ecmult_multi is 2*n_sigs. */ + ARG_CHECK(n_sigs <= SIZE_MAX / 2); + /* Check that n_sigs is less than 2^31 to ensure the same behavior of this function on 32-bit + * and 64-bit platforms. */ + ARG_CHECK(n_sigs < (size_t)(1 << 31)); + + secp256k1_sha256_initialize(&sha); + if (!secp256k1_schnorrsig_verify_batch_init_randomizer(ctx, &ecmult_context, &sha, sig, msg32, pk, n_sigs)) { + return 0; + } + secp256k1_sha256_finalize(&sha, ecmult_context.chacha_seed); + secp256k1_scalar_set_int(&ecmult_context.randomizer_cache[0], 1); + + secp256k1_scalar_clear(&s); + if (!secp256k1_schnorrsig_verify_batch_sum_s(&s, ecmult_context.chacha_seed, sig, n_sigs)) { + return 0; + } + secp256k1_scalar_negate(&s, &s); + + return secp256k1_ecmult_multi_var(&ctx->ecmult_ctx, scratch, &rj, &s, secp256k1_schnorrsig_verify_batch_ecmult_callback, (void *) &ecmult_context, 2 * n_sigs) + && secp256k1_gej_is_infinity(&rj); +} + +#endif + diff --git a/src/secp256k1/src/modules/schnorrsig/tests_impl.h b/src/secp256k1/src/modules/schnorrsig/tests_impl.h new file mode 100644 index 000000000..de84992a9 --- /dev/null +++ b/src/secp256k1/src/modules/schnorrsig/tests_impl.h @@ -0,0 +1,727 @@ +/********************************************************************** + * Copyright (c) 2018 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_SCHNORRSIG_TESTS_ +#define _SECP256K1_MODULE_SCHNORRSIG_TESTS_ + +#include "secp256k1_schnorrsig.h" + +void test_schnorrsig_serialize(void) { + secp256k1_schnorrsig sig; + unsigned char in[64]; + unsigned char out[64]; + + memset(in, 0x12, 64); + CHECK(secp256k1_schnorrsig_parse(ctx, &sig, in)); + CHECK(secp256k1_schnorrsig_serialize(ctx, out, &sig)); + CHECK(memcmp(in, out, 64) == 0); +} + +void test_schnorrsig_api(secp256k1_scratch_space *scratch) { + unsigned char sk1[32]; + unsigned char sk2[32]; + unsigned char sk3[32]; + unsigned char msg[32]; + unsigned char sig64[64]; + secp256k1_pubkey pk[3]; + secp256k1_schnorrsig sig; + const secp256k1_schnorrsig *sigptr = &sig; + const unsigned char *msgptr = msg; + const secp256k1_pubkey *pkptr = &pk[0]; + int nonce_is_negated; + + /** setup **/ + secp256k1_context *none = secp256k1_context_create(SECP256K1_CONTEXT_NONE); + secp256k1_context *sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + secp256k1_context *vrfy = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); + secp256k1_context *both = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + int ecount; + + secp256k1_context_set_error_callback(none, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(vrfy, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(both, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(none, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(both, counting_illegal_callback_fn, &ecount); + + secp256k1_rand256(sk1); + secp256k1_rand256(sk2); + secp256k1_rand256(sk3); + secp256k1_rand256(msg); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk[0], sk1) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk[1], sk2) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pk[2], sk3) == 1); + + /** main test body **/ + ecount = 0; + CHECK(secp256k1_schnorrsig_sign(none, &sig, &nonce_is_negated, msg, sk1, NULL, NULL) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_schnorrsig_sign(vrfy, &sig, &nonce_is_negated, msg, sk1, NULL, NULL) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_sign(sign, &sig, &nonce_is_negated, msg, sk1, NULL, NULL) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_sign(sign, NULL, &nonce_is_negated, msg, sk1, NULL, NULL) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_schnorrsig_sign(sign, &sig, NULL, msg, sk1, NULL, NULL) == 1); + CHECK(ecount == 3); + CHECK(secp256k1_schnorrsig_sign(sign, &sig, &nonce_is_negated, NULL, sk1, NULL, NULL) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_schnorrsig_sign(sign, &sig, &nonce_is_negated, msg, NULL, NULL, NULL) == 0); + CHECK(ecount == 5); + + ecount = 0; + CHECK(secp256k1_schnorrsig_serialize(none, sig64, &sig) == 1); + CHECK(ecount == 0); + CHECK(secp256k1_schnorrsig_serialize(none, NULL, &sig) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_schnorrsig_serialize(none, sig64, NULL) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_parse(none, &sig, sig64) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_parse(none, NULL, sig64) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_schnorrsig_parse(none, &sig, NULL) == 0); + CHECK(ecount == 4); + + ecount = 0; + CHECK(secp256k1_schnorrsig_verify(none, &sig, msg, &pk[0]) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_schnorrsig_verify(sign, &sig, msg, &pk[0]) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_verify(vrfy, &sig, msg, &pk[0]) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_verify(vrfy, NULL, msg, &pk[0]) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_schnorrsig_verify(vrfy, &sig, NULL, &pk[0]) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_schnorrsig_verify(vrfy, &sig, msg, NULL) == 0); + CHECK(ecount == 5); + + ecount = 0; + CHECK(secp256k1_schnorrsig_verify_batch(none, scratch, &sigptr, &msgptr, &pkptr, 1) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_schnorrsig_verify_batch(sign, scratch, &sigptr, &msgptr, &pkptr, 1) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_verify_batch(vrfy, scratch, &sigptr, &msgptr, &pkptr, 1) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_verify_batch(vrfy, scratch, NULL, NULL, NULL, 0) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_schnorrsig_verify_batch(vrfy, scratch, NULL, &msgptr, &pkptr, 1) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_schnorrsig_verify_batch(vrfy, scratch, &sigptr, NULL, &pkptr, 1) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_schnorrsig_verify_batch(vrfy, scratch, &sigptr, &msgptr, NULL, 1) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_schnorrsig_verify_batch(vrfy, scratch, &sigptr, &msgptr, &pkptr, (size_t)1 << (sizeof(size_t)*8-1)) == 0); + CHECK(ecount == 6); + CHECK(secp256k1_schnorrsig_verify_batch(vrfy, scratch, &sigptr, &msgptr, &pkptr, 1 << 31) == 0); + CHECK(ecount == 7); + + secp256k1_context_destroy(none); + secp256k1_context_destroy(sign); + secp256k1_context_destroy(vrfy); + secp256k1_context_destroy(both); +} + +/* Helper function for schnorrsig_bip_vectors + * Signs the message and checks that it's the same as expected_sig. */ +void test_schnorrsig_bip_vectors_check_signing(const unsigned char *sk, const unsigned char *pk_serialized, const unsigned char *msg, const unsigned char *expected_sig, const int expected_nonce_is_negated) { + secp256k1_schnorrsig sig; + unsigned char serialized_sig[64]; + secp256k1_pubkey pk; + int nonce_is_negated; + + CHECK(secp256k1_schnorrsig_sign(ctx, &sig, &nonce_is_negated, msg, sk, NULL, NULL)); + CHECK(nonce_is_negated == expected_nonce_is_negated); + CHECK(secp256k1_schnorrsig_serialize(ctx, serialized_sig, &sig)); + CHECK(memcmp(serialized_sig, expected_sig, 64) == 0); + + CHECK(secp256k1_ec_pubkey_parse(ctx, &pk, pk_serialized, 33)); + CHECK(secp256k1_schnorrsig_verify(ctx, &sig, msg, &pk)); +} + +/* Helper function for schnorrsig_bip_vectors + * Checks that both verify and verify_batch return the same value as expected. */ +void test_schnorrsig_bip_vectors_check_verify(secp256k1_scratch_space *scratch, const unsigned char *pk_serialized, const unsigned char *msg32, const unsigned char *sig_serialized, int expected) { + const unsigned char *msg_arr[1]; + const secp256k1_schnorrsig *sig_arr[1]; + const secp256k1_pubkey *pk_arr[1]; + secp256k1_pubkey pk; + secp256k1_schnorrsig sig; + + CHECK(secp256k1_ec_pubkey_parse(ctx, &pk, pk_serialized, 33)); + CHECK(secp256k1_schnorrsig_parse(ctx, &sig, sig_serialized)); + + sig_arr[0] = &sig; + msg_arr[0] = msg32; + pk_arr[0] = &pk; + + CHECK(expected == secp256k1_schnorrsig_verify(ctx, &sig, msg32, &pk)); + CHECK(expected == secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 1)); +} + +/* Test vectors according to BIP-schnorr + * (https://github.com/sipa/bips/blob/7f6a73e53c8bbcf2d008ea0546f76433e22094a8/bip-schnorr/test-vectors.csv). + */ +void test_schnorrsig_bip_vectors(secp256k1_scratch_space *scratch) { + { + /* Test vector 1 */ + const unsigned char sk1[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 + }; + const unsigned char pk1[33] = { + 0x02, 0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, + 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0x0B, + 0x07, 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, + 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17, + 0x98 + }; + const unsigned char msg1[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + const unsigned char sig1[64] = { + 0x78, 0x7A, 0x84, 0x8E, 0x71, 0x04, 0x3D, 0x28, + 0x0C, 0x50, 0x47, 0x0E, 0x8E, 0x15, 0x32, 0xB2, + 0xDD, 0x5D, 0x20, 0xEE, 0x91, 0x2A, 0x45, 0xDB, + 0xDD, 0x2B, 0xD1, 0xDF, 0xBF, 0x18, 0x7E, 0xF6, + 0x70, 0x31, 0xA9, 0x88, 0x31, 0x85, 0x9D, 0xC3, + 0x4D, 0xFF, 0xEE, 0xDD, 0xA8, 0x68, 0x31, 0x84, + 0x2C, 0xCD, 0x00, 0x79, 0xE1, 0xF9, 0x2A, 0xF1, + 0x77, 0xF7, 0xF2, 0x2C, 0xC1, 0xDC, 0xED, 0x05 + }; + test_schnorrsig_bip_vectors_check_signing(sk1, pk1, msg1, sig1, 1); + test_schnorrsig_bip_vectors_check_verify(scratch, pk1, msg1, sig1, 1); + } + { + /* Test vector 2 */ + const unsigned char sk2[32] = { + 0xB7, 0xE1, 0x51, 0x62, 0x8A, 0xED, 0x2A, 0x6A, + 0xBF, 0x71, 0x58, 0x80, 0x9C, 0xF4, 0xF3, 0xC7, + 0x62, 0xE7, 0x16, 0x0F, 0x38, 0xB4, 0xDA, 0x56, + 0xA7, 0x84, 0xD9, 0x04, 0x51, 0x90, 0xCF, 0xEF + }; + const unsigned char pk2[33] = { + 0x02, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg2[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig2[64] = { + 0x2A, 0x29, 0x8D, 0xAC, 0xAE, 0x57, 0x39, 0x5A, + 0x15, 0xD0, 0x79, 0x5D, 0xDB, 0xFD, 0x1D, 0xCB, + 0x56, 0x4D, 0xA8, 0x2B, 0x0F, 0x26, 0x9B, 0xC7, + 0x0A, 0x74, 0xF8, 0x22, 0x04, 0x29, 0xBA, 0x1D, + 0x1E, 0x51, 0xA2, 0x2C, 0xCE, 0xC3, 0x55, 0x99, + 0xB8, 0xF2, 0x66, 0x91, 0x22, 0x81, 0xF8, 0x36, + 0x5F, 0xFC, 0x2D, 0x03, 0x5A, 0x23, 0x04, 0x34, + 0xA1, 0xA6, 0x4D, 0xC5, 0x9F, 0x70, 0x13, 0xFD + }; + test_schnorrsig_bip_vectors_check_signing(sk2, pk2, msg2, sig2, 0); + test_schnorrsig_bip_vectors_check_verify(scratch, pk2, msg2, sig2, 1); + } + { + /* Test vector 3 */ + const unsigned char sk3[32] = { + 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, + 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, + 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x14, 0xE5, 0xC7 + }; + const unsigned char pk3[33] = { + 0x03, 0xFA, 0xC2, 0x11, 0x4C, 0x2F, 0xBB, 0x09, + 0x15, 0x27, 0xEB, 0x7C, 0x64, 0xEC, 0xB1, 0x1F, + 0x80, 0x21, 0xCB, 0x45, 0xE8, 0xE7, 0x80, 0x9D, + 0x3C, 0x09, 0x38, 0xE4, 0xB8, 0xC0, 0xE5, 0xF8, + 0x4B + }; + const unsigned char msg3[32] = { + 0x5E, 0x2D, 0x58, 0xD8, 0xB3, 0xBC, 0xDF, 0x1A, + 0xBA, 0xDE, 0xC7, 0x82, 0x90, 0x54, 0xF9, 0x0D, + 0xDA, 0x98, 0x05, 0xAA, 0xB5, 0x6C, 0x77, 0x33, + 0x30, 0x24, 0xB9, 0xD0, 0xA5, 0x08, 0xB7, 0x5C + }; + const unsigned char sig3[64] = { + 0x00, 0xDA, 0x9B, 0x08, 0x17, 0x2A, 0x9B, 0x6F, + 0x04, 0x66, 0xA2, 0xDE, 0xFD, 0x81, 0x7F, 0x2D, + 0x7A, 0xB4, 0x37, 0xE0, 0xD2, 0x53, 0xCB, 0x53, + 0x95, 0xA9, 0x63, 0x86, 0x6B, 0x35, 0x74, 0xBE, + 0x00, 0x88, 0x03, 0x71, 0xD0, 0x17, 0x66, 0x93, + 0x5B, 0x92, 0xD2, 0xAB, 0x4C, 0xD5, 0xC8, 0xA2, + 0xA5, 0x83, 0x7E, 0xC5, 0x7F, 0xED, 0x76, 0x60, + 0x77, 0x3A, 0x05, 0xF0, 0xDE, 0x14, 0x23, 0x80 + }; + test_schnorrsig_bip_vectors_check_signing(sk3, pk3, msg3, sig3, 0); + test_schnorrsig_bip_vectors_check_verify(scratch, pk3, msg3, sig3, 1); + } + { + /* Test vector 4 */ + const unsigned char pk4[33] = { + 0x03, 0xDE, 0xFD, 0xEA, 0x4C, 0xDB, 0x67, 0x77, + 0x50, 0xA4, 0x20, 0xFE, 0xE8, 0x07, 0xEA, 0xCF, + 0x21, 0xEB, 0x98, 0x98, 0xAE, 0x79, 0xB9, 0x76, + 0x87, 0x66, 0xE4, 0xFA, 0xA0, 0x4A, 0x2D, 0x4A, + 0x34 + }; + const unsigned char msg4[32] = { + 0x4D, 0xF3, 0xC3, 0xF6, 0x8F, 0xCC, 0x83, 0xB2, + 0x7E, 0x9D, 0x42, 0xC9, 0x04, 0x31, 0xA7, 0x24, + 0x99, 0xF1, 0x78, 0x75, 0xC8, 0x1A, 0x59, 0x9B, + 0x56, 0x6C, 0x98, 0x89, 0xB9, 0x69, 0x67, 0x03 + }; + const unsigned char sig4[64] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3B, 0x78, 0xCE, 0x56, 0x3F, + 0x89, 0xA0, 0xED, 0x94, 0x14, 0xF5, 0xAA, 0x28, + 0xAD, 0x0D, 0x96, 0xD6, 0x79, 0x5F, 0x9C, 0x63, + 0x02, 0xA8, 0xDC, 0x32, 0xE6, 0x4E, 0x86, 0xA3, + 0x33, 0xF2, 0x0E, 0xF5, 0x6E, 0xAC, 0x9B, 0xA3, + 0x0B, 0x72, 0x46, 0xD6, 0xD2, 0x5E, 0x22, 0xAD, + 0xB8, 0xC6, 0xBE, 0x1A, 0xEB, 0x08, 0xD4, 0x9D + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk4, msg4, sig4, 1); + } + { + /* Test vector 5 */ + const unsigned char pk5[33] = { + 0x03, 0x1B, 0x84, 0xC5, 0x56, 0x7B, 0x12, 0x64, + 0x40, 0x99, 0x5D, 0x3E, 0xD5, 0xAA, 0xBA, 0x05, + 0x65, 0xD7, 0x1E, 0x18, 0x34, 0x60, 0x48, 0x19, + 0xFF, 0x9C, 0x17, 0xF5, 0xE9, 0xD5, 0xDD, 0x07, + 0x8F + }; + const unsigned char msg5[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + const unsigned char sig5[64] = { + 0x52, 0x81, 0x85, 0x79, 0xAC, 0xA5, 0x97, 0x67, + 0xE3, 0x29, 0x1D, 0x91, 0xB7, 0x6B, 0x63, 0x7B, + 0xEF, 0x06, 0x20, 0x83, 0x28, 0x49, 0x92, 0xF2, + 0xD9, 0x5F, 0x56, 0x4C, 0xA6, 0xCB, 0x4E, 0x35, + 0x30, 0xB1, 0xDA, 0x84, 0x9C, 0x8E, 0x83, 0x04, + 0xAD, 0xC0, 0xCF, 0xE8, 0x70, 0x66, 0x03, 0x34, + 0xB3, 0xCF, 0xC1, 0x8E, 0x82, 0x5E, 0xF1, 0xDB, + 0x34, 0xCF, 0xAE, 0x3D, 0xFC, 0x5D, 0x81, 0x87 + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk5, msg5, sig5, 1); + } + { + /* Test vector 6 */ + const unsigned char pk6[33] = { + 0x03, 0xFA, 0xC2, 0x11, 0x4C, 0x2F, 0xBB, 0x09, + 0x15, 0x27, 0xEB, 0x7C, 0x64, 0xEC, 0xB1, 0x1F, + 0x80, 0x21, 0xCB, 0x45, 0xE8, 0xE7, 0x80, 0x9D, + 0x3C, 0x09, 0x38, 0xE4, 0xB8, 0xC0, 0xE5, 0xF8, + 0x4B + }; + const unsigned char msg6[32] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + }; + const unsigned char sig6[64] = { + 0x57, 0x0D, 0xD4, 0xCA, 0x83, 0xD4, 0xE6, 0x31, + 0x7B, 0x8E, 0xE6, 0xBA, 0xE8, 0x34, 0x67, 0xA1, + 0xBF, 0x41, 0x9D, 0x07, 0x67, 0x12, 0x2D, 0xE4, + 0x09, 0x39, 0x44, 0x14, 0xB0, 0x50, 0x80, 0xDC, + 0xE9, 0xEE, 0x5F, 0x23, 0x7C, 0xBD, 0x10, 0x8E, + 0xAB, 0xAE, 0x1E, 0x37, 0x75, 0x9A, 0xE4, 0x7F, + 0x8E, 0x42, 0x03, 0xDA, 0x35, 0x32, 0xEB, 0x28, + 0xDB, 0x86, 0x0F, 0x33, 0xD6, 0x2D, 0x49, 0xBD + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk6, msg6, sig6, 1); + } + { + /* Test vector 7 */ + const unsigned char pk7[33] = { + 0x03, 0xEE, 0xFD, 0xEA, 0x4C, 0xDB, 0x67, 0x77, + 0x50, 0xA4, 0x20, 0xFE, 0xE8, 0x07, 0xEA, 0xCF, + 0x21, 0xEB, 0x98, 0x98, 0xAE, 0x79, 0xB9, 0x76, + 0x87, 0x66, 0xE4, 0xFA, 0xA0, 0x4A, 0x2D, 0x4A, + 0x34 + }; + secp256k1_pubkey pk7_parsed; + /* No need to check the signature of the test vector as parsing the pubkey already fails */ + CHECK(!secp256k1_ec_pubkey_parse(ctx, &pk7_parsed, pk7, 33)); + } + { + /* Test vector 8 */ + const unsigned char pk8[33] = { + 0x02, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg8[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig8[64] = { + 0x2A, 0x29, 0x8D, 0xAC, 0xAE, 0x57, 0x39, 0x5A, + 0x15, 0xD0, 0x79, 0x5D, 0xDB, 0xFD, 0x1D, 0xCB, + 0x56, 0x4D, 0xA8, 0x2B, 0x0F, 0x26, 0x9B, 0xC7, + 0x0A, 0x74, 0xF8, 0x22, 0x04, 0x29, 0xBA, 0x1D, + 0xFA, 0x16, 0xAE, 0xE0, 0x66, 0x09, 0x28, 0x0A, + 0x19, 0xB6, 0x7A, 0x24, 0xE1, 0x97, 0x7E, 0x46, + 0x97, 0x71, 0x2B, 0x5F, 0xD2, 0x94, 0x39, 0x14, + 0xEC, 0xD5, 0xF7, 0x30, 0x90, 0x1B, 0x4A, 0xB7 + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk8, msg8, sig8, 0); + } + { + /* Test vector 9 */ + const unsigned char pk9[33] = { + 0x03, 0xFA, 0xC2, 0x11, 0x4C, 0x2F, 0xBB, 0x09, + 0x15, 0x27, 0xEB, 0x7C, 0x64, 0xEC, 0xB1, 0x1F, + 0x80, 0x21, 0xCB, 0x45, 0xE8, 0xE7, 0x80, 0x9D, + 0x3C, 0x09, 0x38, 0xE4, 0xB8, 0xC0, 0xE5, 0xF8, + 0x4B + }; + const unsigned char msg9[32] = { + 0x5E, 0x2D, 0x58, 0xD8, 0xB3, 0xBC, 0xDF, 0x1A, + 0xBA, 0xDE, 0xC7, 0x82, 0x90, 0x54, 0xF9, 0x0D, + 0xDA, 0x98, 0x05, 0xAA, 0xB5, 0x6C, 0x77, 0x33, + 0x30, 0x24, 0xB9, 0xD0, 0xA5, 0x08, 0xB7, 0x5C + }; + const unsigned char sig9[64] = { + 0x00, 0xDA, 0x9B, 0x08, 0x17, 0x2A, 0x9B, 0x6F, + 0x04, 0x66, 0xA2, 0xDE, 0xFD, 0x81, 0x7F, 0x2D, + 0x7A, 0xB4, 0x37, 0xE0, 0xD2, 0x53, 0xCB, 0x53, + 0x95, 0xA9, 0x63, 0x86, 0x6B, 0x35, 0x74, 0xBE, + 0xD0, 0x92, 0xF9, 0xD8, 0x60, 0xF1, 0x77, 0x6A, + 0x1F, 0x74, 0x12, 0xAD, 0x8A, 0x1E, 0xB5, 0x0D, + 0xAC, 0xCC, 0x22, 0x2B, 0xC8, 0xC0, 0xE2, 0x6B, + 0x20, 0x56, 0xDF, 0x2F, 0x27, 0x3E, 0xFD, 0xEC + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk9, msg9, sig9, 0); + } + { + /* Test vector 10 */ + const unsigned char pk10[33] = { + 0x02, 0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, + 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0x0B, + 0x07, 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, + 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17, + 0x98 + }; + const unsigned char msg10[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + const unsigned char sig10[64] = { + 0x78, 0x7A, 0x84, 0x8E, 0x71, 0x04, 0x3D, 0x28, + 0x0C, 0x50, 0x47, 0x0E, 0x8E, 0x15, 0x32, 0xB2, + 0xDD, 0x5D, 0x20, 0xEE, 0x91, 0x2A, 0x45, 0xDB, + 0xDD, 0x2B, 0xD1, 0xDF, 0xBF, 0x18, 0x7E, 0xF6, + 0x8F, 0xCE, 0x56, 0x77, 0xCE, 0x7A, 0x62, 0x3C, + 0xB2, 0x00, 0x11, 0x22, 0x57, 0x97, 0xCE, 0x7A, + 0x8D, 0xE1, 0xDC, 0x6C, 0xCD, 0x4F, 0x75, 0x4A, + 0x47, 0xDA, 0x6C, 0x60, 0x0E, 0x59, 0x54, 0x3C + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk10, msg10, sig10, 0); + } + { + /* Test vector 11 */ + const unsigned char pk11[33] = { + 0x03, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg11[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig11[64] = { + 0x2A, 0x29, 0x8D, 0xAC, 0xAE, 0x57, 0x39, 0x5A, + 0x15, 0xD0, 0x79, 0x5D, 0xDB, 0xFD, 0x1D, 0xCB, + 0x56, 0x4D, 0xA8, 0x2B, 0x0F, 0x26, 0x9B, 0xC7, + 0x0A, 0x74, 0xF8, 0x22, 0x04, 0x29, 0xBA, 0x1D, + 0x1E, 0x51, 0xA2, 0x2C, 0xCE, 0xC3, 0x55, 0x99, + 0xB8, 0xF2, 0x66, 0x91, 0x22, 0x81, 0xF8, 0x36, + 0x5F, 0xFC, 0x2D, 0x03, 0x5A, 0x23, 0x04, 0x34, + 0xA1, 0xA6, 0x4D, 0xC5, 0x9F, 0x70, 0x13, 0xFD + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk11, msg11, sig11, 0); + } + { + /* Test vector 12 */ + const unsigned char pk12[33] = { + 0x02, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg12[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig12[64] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x9E, 0x9D, 0x01, 0xAF, 0x98, 0x8B, 0x5C, 0xED, + 0xCE, 0x47, 0x22, 0x1B, 0xFA, 0x9B, 0x22, 0x27, + 0x21, 0xF3, 0xFA, 0x40, 0x89, 0x15, 0x44, 0x4A, + 0x4B, 0x48, 0x90, 0x21, 0xDB, 0x55, 0x77, 0x5F + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk12, msg12, sig12, 0); + } + { + /* Test vector 13 */ + const unsigned char pk13[33] = { + 0x02, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg13[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig13[64] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0xD3, 0x7D, 0xDF, 0x02, 0x54, 0x35, 0x18, 0x36, + 0xD8, 0x4B, 0x1B, 0xD6, 0xA7, 0x95, 0xFD, 0x5D, + 0x52, 0x30, 0x48, 0xF2, 0x98, 0xC4, 0x21, 0x4D, + 0x18, 0x7F, 0xE4, 0x89, 0x29, 0x47, 0xF7, 0x28 + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk13, msg13, sig13, 0); + } + { + /* Test vector 14 */ + const unsigned char pk14[33] = { + 0x02, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg14[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x14, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig14[64] = { + 0x4A, 0x29, 0x8D, 0xAC, 0xAE, 0x57, 0x39, 0x5A, + 0x15, 0xD0, 0x79, 0x5D, 0xDB, 0xFD, 0x1D, 0xCB, + 0x56, 0x4D, 0xA8, 0x2B, 0x0F, 0x26, 0x9B, 0xC7, + 0x0A, 0x74, 0xF8, 0x22, 0x04, 0x29, 0xBA, 0x1D, + 0x1E, 0x51, 0xA2, 0x2C, 0xCE, 0xC3, 0x55, 0x99, + 0xB8, 0xF2, 0x66, 0x91, 0x22, 0x81, 0xF8, 0x36, + 0x5F, 0xFC, 0x2D, 0x03, 0x5A, 0x23, 0x04, 0x34, + 0xA1, 0xA6, 0x4D, 0xC5, 0x9F, 0x70, 0x13, 0xFD + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk14, msg14, sig14, 0); + } + { + /* Test vector 15 */ + const unsigned char pk15[33] = { + 0x02, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg15[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig15[64] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x2F, + 0x1E, 0x51, 0xA2, 0x2C, 0xCE, 0xC3, 0x55, 0x99, + 0xB8, 0xF2, 0x66, 0x91, 0x22, 0x81, 0xF8, 0x36, + 0x5F, 0xFC, 0x2D, 0x03, 0x5A, 0x23, 0x04, 0x34, + 0xA1, 0xA6, 0x4D, 0xC5, 0x9F, 0x70, 0x13, 0xFD + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk15, msg15, sig15, 0); + } + { + /* Test vector 16 */ + const unsigned char pk16[33] = { + 0x02, 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, + 0x5F, 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, + 0xBE, 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, + 0xD8, 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, + 0x59 + }; + const unsigned char msg16[32] = { + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, + 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, + 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89 + }; + const unsigned char sig16[64] = { + 0x2A, 0x29, 0x8D, 0xAC, 0xAE, 0x57, 0x39, 0x5A, + 0x15, 0xD0, 0x79, 0x5D, 0xDB, 0xFD, 0x1D, 0xCB, + 0x56, 0x4D, 0xA8, 0x2B, 0x0F, 0x26, 0x9B, 0xC7, + 0x0A, 0x74, 0xF8, 0x22, 0x04, 0x29, 0xBA, 0x1D, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, + 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, + 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41 + }; + test_schnorrsig_bip_vectors_check_verify(scratch, pk16, msg16, sig16, 0); + } +} + +/* Nonce function that returns constant 0 */ +static int nonce_function_failing(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + (void) msg32; + (void) key32; + (void) algo16; + (void) data; + (void) counter; + (void) nonce32; + return 0; +} + +/* Nonce function that sets nonce to 0 */ +static int nonce_function_0(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + (void) msg32; + (void) key32; + (void) algo16; + (void) data; + (void) counter; + + memset(nonce32, 0, 32); + return 1; +} + +void test_schnorrsig_sign(void) { + unsigned char sk[32]; + const unsigned char msg[32] = "this is a msg for a schnorrsig.."; + secp256k1_schnorrsig sig; + + memset(sk, 23, sizeof(sk)); + CHECK(secp256k1_schnorrsig_sign(ctx, &sig, NULL, msg, sk, NULL, NULL) == 1); + + /* Overflowing secret key */ + memset(sk, 0xFF, sizeof(sk)); + CHECK(secp256k1_schnorrsig_sign(ctx, &sig, NULL, msg, sk, NULL, NULL) == 0); + memset(sk, 23, sizeof(sk)); + + CHECK(secp256k1_schnorrsig_sign(ctx, &sig, NULL, msg, sk, nonce_function_failing, NULL) == 0); + CHECK(secp256k1_schnorrsig_sign(ctx, &sig, NULL, msg, sk, nonce_function_0, NULL) == 0); +} + +#define N_SIGS 200 +/* Creates N_SIGS valid signatures and verifies them with verify and verify_batch. Then flips some + * bits and checks that verification now fails. */ +void test_schnorrsig_sign_verify(secp256k1_scratch_space *scratch) { + const unsigned char sk[32] = "shhhhhhhh! this key is a secret."; + unsigned char msg[N_SIGS][32]; + secp256k1_schnorrsig sig[N_SIGS]; + size_t i; + const secp256k1_schnorrsig *sig_arr[N_SIGS]; + const unsigned char *msg_arr[N_SIGS]; + const secp256k1_pubkey *pk_arr[N_SIGS]; + secp256k1_pubkey pk; + + CHECK(secp256k1_ec_pubkey_create(ctx, &pk, sk)); + + CHECK(secp256k1_schnorrsig_verify_batch(ctx, scratch, NULL, NULL, NULL, 0)); + + for (i = 0; i < N_SIGS; i++) { + secp256k1_rand256(msg[i]); + CHECK(secp256k1_schnorrsig_sign(ctx, &sig[i], NULL, msg[i], sk, NULL, NULL)); + CHECK(secp256k1_schnorrsig_verify(ctx, &sig[i], msg[i], &pk)); + sig_arr[i] = &sig[i]; + msg_arr[i] = msg[i]; + pk_arr[i] = &pk; + } + + CHECK(secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 1)); + CHECK(secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 2)); + CHECK(secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 4)); + CHECK(secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, N_SIGS)); + + { + /* Flip a few bits in the signature and in the message and check that + * verify and verify_batch fail */ + size_t sig_idx = secp256k1_rand_int(4); + size_t byte_idx = secp256k1_rand_int(32); + unsigned char xorbyte = secp256k1_rand_int(254)+1; + sig[sig_idx].data[byte_idx] ^= xorbyte; + CHECK(!secp256k1_schnorrsig_verify(ctx, &sig[sig_idx], msg[sig_idx], &pk)); + CHECK(!secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 4)); + sig[sig_idx].data[byte_idx] ^= xorbyte; + + byte_idx = secp256k1_rand_int(32); + sig[sig_idx].data[32+byte_idx] ^= xorbyte; + CHECK(!secp256k1_schnorrsig_verify(ctx, &sig[sig_idx], msg[sig_idx], &pk)); + CHECK(!secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 4)); + sig[sig_idx].data[32+byte_idx] ^= xorbyte; + + byte_idx = secp256k1_rand_int(32); + msg[sig_idx][byte_idx] ^= xorbyte; + CHECK(!secp256k1_schnorrsig_verify(ctx, &sig[sig_idx], msg[sig_idx], &pk)); + CHECK(!secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 4)); + msg[sig_idx][byte_idx] ^= xorbyte; + + /* Check that above bitflips have been reversed correctly */ + CHECK(secp256k1_schnorrsig_verify(ctx, &sig[sig_idx], msg[sig_idx], &pk)); + CHECK(secp256k1_schnorrsig_verify_batch(ctx, scratch, sig_arr, msg_arr, pk_arr, 4)); + } +} +#undef N_SIGS + +void run_schnorrsig_tests(void) { + secp256k1_scratch_space *scratch = secp256k1_scratch_space_create(ctx, 1024 * 1024); + + test_schnorrsig_serialize(); + test_schnorrsig_api(scratch); + test_schnorrsig_bip_vectors(scratch); + test_schnorrsig_sign(); + test_schnorrsig_sign_verify(scratch); + + secp256k1_scratch_space_destroy(scratch); +} + +#endif + diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h index 59304cb66..3d972dc84 100644 --- a/src/secp256k1/src/scalar.h +++ b/src/secp256k1/src/scalar.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -104,3 +106,236 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); #endif /* SECP256K1_SCALAR_H */ + +#else + +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_H +#define SECP256K1_SCALAR_H + +#include "num.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(EXHAUSTIVE_TEST_ORDER) +#include "scalar_low.h" +#elif defined(USE_SCALAR_4X64) +#include "scalar_4x64.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32.h" +#else +#error "Please select scalar implementation" +#endif + +/** Clear a scalar to prevent the leak of sensitive data. */ +static void secp256k1_scalar_clear(secp256k1_scalar *r); + +/** Access bits from a scalar. All requested bits must belong to the same 32-bit limb. */ +static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Access bits from a scalar. Not constant time. */ +static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Set a scalar from a big endian byte array. */ +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow); + +/** Set a scalar to an unsigned integer. */ +static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v); + +/** Set a scalar to an unsigned 64-bit integer */ +static void secp256k1_scalar_set_u64(secp256k1_scalar *r, uint64_t v); + +/** Convert a scalar to a byte array. */ +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a); + +/** Add two scalars together (modulo the group order). Returns whether it overflowed. */ +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Conditionally add a power of two to a scalar. The result is not allowed to overflow. */ +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag); + +/** Multiply two scalars (modulo the group order). */ +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Shift a scalar right by some amount strictly between 0 and 16, returning + * the low bits that were shifted off */ +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n); + +/** Compute the square of a scalar (modulo the group order). */ +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order). */ +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order), without constant-time guarantee. */ +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the complement of a scalar (modulo the group order). */ +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Check whether a scalar equals zero. */ +static int secp256k1_scalar_is_zero(const secp256k1_scalar *a); + +/** Check whether a scalar equals one. */ +static int secp256k1_scalar_is_one(const secp256k1_scalar *a); + +/** Check whether a scalar, considered as an nonnegative integer, is even. */ +static int secp256k1_scalar_is_even(const secp256k1_scalar *a); + +/** Check whether a scalar is higher than the group order divided by 2. */ +static int secp256k1_scalar_is_high(const secp256k1_scalar *a); + +/** Conditionally negate a number, in constant time. + * Returns -1 if the number was negated, 1 otherwise */ +static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag); + +#ifndef USE_NUM_NONE +/** Convert a scalar to a number. */ +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a); + +/** Get the order of the group as a number. */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r); +#endif + +/** Compare two scalars. */ +static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b); + +#ifdef USE_ENDOMORPHISM +/** Find r1 and r2 such that r1+r2*2^128 = a. */ +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +/** Find r1 and r2 such that r1+r2*lambda = a, and r1 and r2 are maximum 128 bits long (see secp256k1_gej_mul_lambda). */ +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +#endif + +/** Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer. Shift must be at least 256. */ +static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); + +/** Generate two scalars from a 32-byte seed and an integer using the chacha20 stream cipher */ +static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); + +#endif /* SECP256K1_SCALAR_H */ +#endif + +#else + +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_H +#define SECP256K1_SCALAR_H + +#include "num.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(EXHAUSTIVE_TEST_ORDER) +#include "scalar_low.h" +#elif defined(USE_SCALAR_4X64) +#include "scalar_4x64.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32.h" +#else +#error "Please select scalar implementation" +#endif + +/** Clear a scalar to prevent the leak of sensitive data. */ +static void secp256k1_scalar_clear(secp256k1_scalar *r); + +/** Access bits from a scalar. All requested bits must belong to the same 32-bit limb. */ +static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Access bits from a scalar. Not constant time. */ +static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Set a scalar from a big endian byte array. */ +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow); + +/** Set a scalar to an unsigned integer. */ +static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v); + +/** Set a scalar to an unsigned 64-bit integer */ +static void secp256k1_scalar_set_u64(secp256k1_scalar *r, uint64_t v); + +/** Convert a scalar to a byte array. */ +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a); + +/** Add two scalars together (modulo the group order). Returns whether it overflowed. */ +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Conditionally add a power of two to a scalar. The result is not allowed to overflow. */ +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag); + +/** Multiply two scalars (modulo the group order). */ +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Shift a scalar right by some amount strictly between 0 and 16, returning + * the low bits that were shifted off */ +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n); + +/** Compute the square of a scalar (modulo the group order). */ +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order). */ +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order), without constant-time guarantee. */ +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the complement of a scalar (modulo the group order). */ +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Check whether a scalar equals zero. */ +static int secp256k1_scalar_is_zero(const secp256k1_scalar *a); + +/** Check whether a scalar equals one. */ +static int secp256k1_scalar_is_one(const secp256k1_scalar *a); + +/** Check whether a scalar, considered as an nonnegative integer, is even. */ +static int secp256k1_scalar_is_even(const secp256k1_scalar *a); + +/** Check whether a scalar is higher than the group order divided by 2. */ +static int secp256k1_scalar_is_high(const secp256k1_scalar *a); + +/** Conditionally negate a number, in constant time. + * Returns -1 if the number was negated, 1 otherwise */ +static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag); + +#ifndef USE_NUM_NONE +/** Convert a scalar to a number. */ +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a); + +/** Get the order of the group as a number. */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r); +#endif + +/** Compare two scalars. */ +static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b); + +#ifdef USE_ENDOMORPHISM +/** Find r1 and r2 such that r1+r2*2^128 = a. */ +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +/** Find r1 and r2 such that r1+r2*lambda = a, and r1 and r2 are maximum 128 bits long (see secp256k1_gej_mul_lambda). */ +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +#endif + +/** Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer. Shift must be at least 256. */ +static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); + +/** Generate two scalars from a 32-byte seed and an integer using the chacha20 stream cipher */ +static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); + +#endif /* SECP256K1_SCALAR_H */ +#endif + diff --git a/src/secp256k1/src/scalar_4x64.h b/src/secp256k1/src/scalar_4x64.h index 19c7495d1..326afd6b5 100644 --- a/src/secp256k1/src/scalar_4x64.h +++ b/src/secp256k1/src/scalar_4x64.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -17,3 +19,50 @@ typedef struct { #define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} #endif /* SECP256K1_SCALAR_REPR_H */ + +#else +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_REPR_H +#define SECP256K1_SCALAR_REPR_H + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef struct { + uint64_t d[4]; +} secp256k1_scalar; + +#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} + +#endif /* SECP256K1_SCALAR_REPR_H */ +#endif + + +#else +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_REPR_H +#define SECP256K1_SCALAR_REPR_H + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef struct { + uint64_t d[4]; +} secp256k1_scalar; + +#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} + +#endif /* SECP256K1_SCALAR_REPR_H */ +#endif + + diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index db1ebf94b..ee75ad51e 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -947,3 +949,1057 @@ SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, } #endif /* SECP256K1_SCALAR_REPR_IMPL_H */ + + +#else +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_REPR_IMPL_H +#define SECP256K1_SCALAR_REPR_IMPL_H + +#include "scalar.h" +#include + +/* Limbs of the secp256k1 order. */ +#define SECP256K1_N_0 ((uint64_t)0xBFD25E8CD0364141ULL) +#define SECP256K1_N_1 ((uint64_t)0xBAAEDCE6AF48A03BULL) +#define SECP256K1_N_2 ((uint64_t)0xFFFFFFFFFFFFFFFEULL) +#define SECP256K1_N_3 ((uint64_t)0xFFFFFFFFFFFFFFFFULL) + +/* Limbs of 2^256 minus the secp256k1 order. */ +#define SECP256K1_N_C_0 (~SECP256K1_N_0 + 1) +#define SECP256K1_N_C_1 (~SECP256K1_N_1) +#define SECP256K1_N_C_2 (1) + +/* Limbs of half the secp256k1 order. */ +#define SECP256K1_N_H_0 ((uint64_t)0xDFE92F46681B20A0ULL) +#define SECP256K1_N_H_1 ((uint64_t)0x5D576E7357A4501DULL) +#define SECP256K1_N_H_2 ((uint64_t)0xFFFFFFFFFFFFFFFFULL) +#define SECP256K1_N_H_3 ((uint64_t)0x7FFFFFFFFFFFFFFFULL) + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { + r->d[0] = 0; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { + r->d[0] = v; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_u64(secp256k1_scalar *r, uint64_t v) { + r->d[0] = v; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK((offset + count - 1) >> 6 == offset >> 6); + return (a->d[offset >> 6] >> (offset & 0x3F)) & ((((uint64_t)1) << count) - 1); +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK(count < 32); + VERIFY_CHECK(offset + count <= 256); + if ((offset + count - 1) >> 6 == offset >> 6) { + return secp256k1_scalar_get_bits(a, offset, count); + } else { + VERIFY_CHECK((offset >> 6) + 1 < 4); + return ((a->d[offset >> 6] >> (offset & 0x3F)) | (a->d[(offset >> 6) + 1] << (64 - (offset & 0x3F)))) & ((((uint64_t)1) << count) - 1); + } +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[3] < SECP256K1_N_3); /* No need for a > check. */ + no |= (a->d[2] < SECP256K1_N_2); + yes |= (a->d[2] > SECP256K1_N_2) & ~no; + no |= (a->d[1] < SECP256K1_N_1); + yes |= (a->d[1] > SECP256K1_N_1) & ~no; + yes |= (a->d[0] >= SECP256K1_N_0) & ~no; + return yes; +} + +SECP256K1_INLINE static int secp256k1_scalar_reduce(secp256k1_scalar *r, unsigned int overflow) { + uint128_t t; + VERIFY_CHECK(overflow <= 1); + t = (uint128_t)r->d[0] + overflow * SECP256K1_N_C_0; + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[1] + overflow * SECP256K1_N_C_1; + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[2] + overflow * SECP256K1_N_C_2; + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint64_t)r->d[3]; + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; + return overflow; +} + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + int overflow; + uint128_t t = (uint128_t)a->d[0] + b->d[0]; + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[1] + b->d[1]; + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[2] + b->d[2]; + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[3] + b->d[3]; + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + overflow = t + secp256k1_scalar_check_overflow(r); + VERIFY_CHECK(overflow == 0 || overflow == 1); + secp256k1_scalar_reduce(r, overflow); + return overflow; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + uint128_t t; + VERIFY_CHECK(bit < 256); + bit += ((uint32_t) flag - 1) & 0x100; /* forcing (bit >> 6) > 3 makes this a noop */ + t = (uint128_t)r->d[0] + (((uint64_t)((bit >> 6) == 0)) << (bit & 0x3F)); + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[1] + (((uint64_t)((bit >> 6) == 1)) << (bit & 0x3F)); + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[2] + (((uint64_t)((bit >> 6) == 2)) << (bit & 0x3F)); + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[3] + (((uint64_t)((bit >> 6) == 3)) << (bit & 0x3F)); + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; +#ifdef VERIFY + VERIFY_CHECK((t >> 64) == 0); + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + int over; + r->d[0] = (uint64_t)b32[31] | (uint64_t)b32[30] << 8 | (uint64_t)b32[29] << 16 | (uint64_t)b32[28] << 24 | (uint64_t)b32[27] << 32 | (uint64_t)b32[26] << 40 | (uint64_t)b32[25] << 48 | (uint64_t)b32[24] << 56; + r->d[1] = (uint64_t)b32[23] | (uint64_t)b32[22] << 8 | (uint64_t)b32[21] << 16 | (uint64_t)b32[20] << 24 | (uint64_t)b32[19] << 32 | (uint64_t)b32[18] << 40 | (uint64_t)b32[17] << 48 | (uint64_t)b32[16] << 56; + r->d[2] = (uint64_t)b32[15] | (uint64_t)b32[14] << 8 | (uint64_t)b32[13] << 16 | (uint64_t)b32[12] << 24 | (uint64_t)b32[11] << 32 | (uint64_t)b32[10] << 40 | (uint64_t)b32[9] << 48 | (uint64_t)b32[8] << 56; + r->d[3] = (uint64_t)b32[7] | (uint64_t)b32[6] << 8 | (uint64_t)b32[5] << 16 | (uint64_t)b32[4] << 24 | (uint64_t)b32[3] << 32 | (uint64_t)b32[2] << 40 | (uint64_t)b32[1] << 48 | (uint64_t)b32[0] << 56; + over = secp256k1_scalar_reduce(r, secp256k1_scalar_check_overflow(r)); + if (overflow) { + *overflow = over; + } +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + bin[0] = a->d[3] >> 56; bin[1] = a->d[3] >> 48; bin[2] = a->d[3] >> 40; bin[3] = a->d[3] >> 32; bin[4] = a->d[3] >> 24; bin[5] = a->d[3] >> 16; bin[6] = a->d[3] >> 8; bin[7] = a->d[3]; + bin[8] = a->d[2] >> 56; bin[9] = a->d[2] >> 48; bin[10] = a->d[2] >> 40; bin[11] = a->d[2] >> 32; bin[12] = a->d[2] >> 24; bin[13] = a->d[2] >> 16; bin[14] = a->d[2] >> 8; bin[15] = a->d[2]; + bin[16] = a->d[1] >> 56; bin[17] = a->d[1] >> 48; bin[18] = a->d[1] >> 40; bin[19] = a->d[1] >> 32; bin[20] = a->d[1] >> 24; bin[21] = a->d[1] >> 16; bin[22] = a->d[1] >> 8; bin[23] = a->d[1]; + bin[24] = a->d[0] >> 56; bin[25] = a->d[0] >> 48; bin[26] = a->d[0] >> 40; bin[27] = a->d[0] >> 32; bin[28] = a->d[0] >> 24; bin[29] = a->d[0] >> 16; bin[30] = a->d[0] >> 8; bin[31] = a->d[0]; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return (a->d[0] | a->d[1] | a->d[2] | a->d[3]) == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint64_t nonzero = 0xFFFFFFFFFFFFFFFFULL * (secp256k1_scalar_is_zero(a) == 0); + uint128_t t = (uint128_t)(~a->d[0]) + SECP256K1_N_0 + 1; + r->d[0] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[1]) + SECP256K1_N_1; + r->d[1] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[2]) + SECP256K1_N_2; + r->d[2] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[3]) + SECP256K1_N_3; + r->d[3] = t & nonzero; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return ((a->d[0] ^ 1) | a->d[1] | a->d[2] | a->d[3]) == 0; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[3] < SECP256K1_N_H_3); + yes |= (a->d[3] > SECP256K1_N_H_3) & ~no; + no |= (a->d[2] < SECP256K1_N_H_2) & ~yes; /* No need for a > check. */ + no |= (a->d[1] < SECP256K1_N_H_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_H_1) & ~no; + yes |= (a->d[0] > SECP256K1_N_H_0) & ~no; + return yes; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + /* If we are flag = 0, mask = 00...00 and this is a no-op; + * if we are flag = 1, mask = 11...11 and this is identical to secp256k1_scalar_negate */ + uint64_t mask = !flag - 1; + uint64_t nonzero = (secp256k1_scalar_is_zero(r) != 0) - 1; + uint128_t t = (uint128_t)(r->d[0] ^ mask) + ((SECP256K1_N_0 + 1) & mask); + r->d[0] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[1] ^ mask) + (SECP256K1_N_1 & mask); + r->d[1] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[2] ^ mask) + (SECP256K1_N_2 & mask); + r->d[2] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[3] ^ mask) + (SECP256K1_N_3 & mask); + r->d[3] = t & nonzero; + return 2 * (mask == 0) - 1; +} + +/* Inspired by the macros in OpenSSL's crypto/bn/asm/x86_64-gcc.c. */ + +/** Add a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd(a,b) { \ +uint64_t tl, th; \ +{ \ +uint128_t t = (uint128_t)a * b; \ +th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ +tl = t; \ +} \ +c0 += tl; /* overflow is handled on the next line */ \ +th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ +c1 += th; /* overflow is handled on the next line */ \ +c2 += (c1 < th) ? 1 : 0; /* never overflows by contract (verified in the next line) */ \ +VERIFY_CHECK((c1 >= th) || (c2 != 0)); \ +} + +/** Add a*b to the number defined by (c0,c1). c1 must never overflow. */ +#define muladd_fast(a,b) { \ +uint64_t tl, th; \ +{ \ +uint128_t t = (uint128_t)a * b; \ +th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ +tl = t; \ +} \ +c0 += tl; /* overflow is handled on the next line */ \ +th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ +c1 += th; /* never overflows by contract (verified in the next line) */ \ +VERIFY_CHECK(c1 >= th); \ +} + +/** Add 2*a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd2(a,b) { \ +uint64_t tl, th, th2, tl2; \ +{ \ +uint128_t t = (uint128_t)a * b; \ +th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ +tl = t; \ +} \ +th2 = th + th; /* at most 0xFFFFFFFFFFFFFFFE (in case th was 0x7FFFFFFFFFFFFFFF) */ \ +c2 += (th2 < th) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((th2 >= th) || (c2 != 0)); \ +tl2 = tl + tl; /* at most 0xFFFFFFFFFFFFFFFE (in case the lowest 63 bits of tl were 0x7FFFFFFFFFFFFFFF) */ \ +th2 += (tl2 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ +c0 += tl2; /* overflow is handled on the next line */ \ +th2 += (c0 < tl2) ? 1 : 0; /* second overflow is handled on the next line */ \ +c2 += (c0 < tl2) & (th2 == 0); /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((c0 >= tl2) || (th2 != 0) || (c2 != 0)); \ +c1 += th2; /* overflow is handled on the next line */ \ +c2 += (c1 < th2) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((c1 >= th2) || (c2 != 0)); \ +} + +/** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define sumadd(a) { \ +unsigned int over; \ +c0 += (a); /* overflow is handled on the next line */ \ +over = (c0 < (a)) ? 1 : 0; \ +c1 += over; /* overflow is handled on the next line */ \ +c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ +} + +/** Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero. */ +#define sumadd_fast(a) { \ +c0 += (a); /* overflow is handled on the next line */ \ +c1 += (c0 < (a)) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \ +VERIFY_CHECK(c2 == 0); \ +} + +/** Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits. */ +#define extract(n) { \ +(n) = c0; \ +c0 = c1; \ +c1 = c2; \ +c2 = 0; \ +} + +/** Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits. c2 is required to be zero. */ +#define extract_fast(n) { \ +(n) = c0; \ +c0 = c1; \ +c1 = 0; \ +VERIFY_CHECK(c2 == 0); \ +} + +static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint64_t *l) { +#ifdef USE_ASM_X86_64 + /* Reduce 512 bits into 385. */ + uint64_t m0, m1, m2, m3, m4, m5, m6; + uint64_t p0, p1, p2, p3, p4; + uint64_t c; + + __asm__ __volatile__( + /* Preload. */ + "movq 32(%%rsi), %%r11\n" + "movq 40(%%rsi), %%r12\n" + "movq 48(%%rsi), %%r13\n" + "movq 56(%%rsi), %%r14\n" + /* Initialize r8,r9,r10 */ + "movq 0(%%rsi), %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9) += n0 * c0 */ + "movq %8, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* extract m0 */ + "movq %%r8, %q0\n" + "xorq %%r8, %%r8\n" + /* (r9,r10) += l1 */ + "addq 8(%%rsi), %%r9\n" + "adcq $0, %%r10\n" + /* (r9,r10,r8) += n1 * c0 */ + "movq %8, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += n0 * c1 */ + "movq %9, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* extract m1 */ + "movq %%r9, %q1\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += l2 */ + "addq 16(%%rsi), %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n2 * c0 */ + "movq %8, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n1 * c1 */ + "movq %9, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n0 */ + "addq %%r11, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* extract m2 */ + "movq %%r10, %q2\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += l3 */ + "addq 24(%%rsi), %%r8\n" + "adcq $0, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n3 * c0 */ + "movq %8, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n2 * c1 */ + "movq %9, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n1 */ + "addq %%r12, %%r8\n" + "adcq $0, %%r9\n" + "adcq $0, %%r10\n" + /* extract m3 */ + "movq %%r8, %q3\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += n3 * c1 */ + "movq %9, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += n2 */ + "addq %%r13, %%r9\n" + "adcq $0, %%r10\n" + "adcq $0, %%r8\n" + /* extract m4 */ + "movq %%r9, %q4\n" + /* (r10,r8) += n3 */ + "addq %%r14, %%r10\n" + "adcq $0, %%r8\n" + /* extract m5 */ + "movq %%r10, %q5\n" + /* extract m6 */ + "movq %%r8, %q6\n" + : "=g"(m0), "=g"(m1), "=g"(m2), "=g"(m3), "=g"(m4), "=g"(m5), "=g"(m6) + : "S"(l), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc"); + + /* Reduce 385 bits into 258. */ + __asm__ __volatile__( + /* Preload */ + "movq %q9, %%r11\n" + "movq %q10, %%r12\n" + "movq %q11, %%r13\n" + /* Initialize (r8,r9,r10) */ + "movq %q5, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9) += m4 * c0 */ + "movq %12, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* extract p0 */ + "movq %%r8, %q0\n" + "xorq %%r8, %%r8\n" + /* (r9,r10) += m1 */ + "addq %q6, %%r9\n" + "adcq $0, %%r10\n" + /* (r9,r10,r8) += m5 * c0 */ + "movq %12, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += m4 * c1 */ + "movq %13, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* extract p1 */ + "movq %%r9, %q1\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += m2 */ + "addq %q7, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m6 * c0 */ + "movq %12, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m5 * c1 */ + "movq %13, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m4 */ + "addq %%r11, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* extract p2 */ + "movq %%r10, %q2\n" + /* (r8,r9) += m3 */ + "addq %q8, %%r8\n" + "adcq $0, %%r9\n" + /* (r8,r9) += m6 * c1 */ + "movq %13, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* (r8,r9) += m5 */ + "addq %%r12, %%r8\n" + "adcq $0, %%r9\n" + /* extract p3 */ + "movq %%r8, %q3\n" + /* (r9) += m6 */ + "addq %%r13, %%r9\n" + /* extract p4 */ + "movq %%r9, %q4\n" + : "=&g"(p0), "=&g"(p1), "=&g"(p2), "=g"(p3), "=g"(p4) + : "g"(m0), "g"(m1), "g"(m2), "g"(m3), "g"(m4), "g"(m5), "g"(m6), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "cc"); + + /* Reduce 258 bits into 256. */ + __asm__ __volatile__( + /* Preload */ + "movq %q5, %%r10\n" + /* (rax,rdx) = p4 * c0 */ + "movq %7, %%rax\n" + "mulq %%r10\n" + /* (rax,rdx) += p0 */ + "addq %q1, %%rax\n" + "adcq $0, %%rdx\n" + /* extract r0 */ + "movq %%rax, 0(%q6)\n" + /* Move to (r8,r9) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + /* (r8,r9) += p1 */ + "addq %q2, %%r8\n" + "adcq $0, %%r9\n" + /* (r8,r9) += p4 * c1 */ + "movq %8, %%rax\n" + "mulq %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* Extract r1 */ + "movq %%r8, 8(%q6)\n" + "xorq %%r8, %%r8\n" + /* (r9,r8) += p4 */ + "addq %%r10, %%r9\n" + "adcq $0, %%r8\n" + /* (r9,r8) += p2 */ + "addq %q3, %%r9\n" + "adcq $0, %%r8\n" + /* Extract r2 */ + "movq %%r9, 16(%q6)\n" + "xorq %%r9, %%r9\n" + /* (r8,r9) += p3 */ + "addq %q4, %%r8\n" + "adcq $0, %%r9\n" + /* Extract r3 */ + "movq %%r8, 24(%q6)\n" + /* Extract c */ + "movq %%r9, %q0\n" + : "=g"(c) + : "g"(p0), "g"(p1), "g"(p2), "g"(p3), "g"(p4), "D"(r), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "cc", "memory"); +#else + uint128_t c; + uint64_t c0, c1, c2; + uint64_t n0 = l[4], n1 = l[5], n2 = l[6], n3 = l[7]; + uint64_t m0, m1, m2, m3, m4, m5; + uint32_t m6; + uint64_t p0, p1, p2, p3; + uint32_t p4; + + /* Reduce 512 bits into 385. */ + /* m[0..6] = l[0..3] + n[0..3] * SECP256K1_N_C. */ + c0 = l[0]; c1 = 0; c2 = 0; + muladd_fast(n0, SECP256K1_N_C_0); + extract_fast(m0); + sumadd_fast(l[1]); + muladd(n1, SECP256K1_N_C_0); + muladd(n0, SECP256K1_N_C_1); + extract(m1); + sumadd(l[2]); + muladd(n2, SECP256K1_N_C_0); + muladd(n1, SECP256K1_N_C_1); + sumadd(n0); + extract(m2); + sumadd(l[3]); + muladd(n3, SECP256K1_N_C_0); + muladd(n2, SECP256K1_N_C_1); + sumadd(n1); + extract(m3); + muladd(n3, SECP256K1_N_C_1); + sumadd(n2); + extract(m4); + sumadd_fast(n3); + extract_fast(m5); + VERIFY_CHECK(c0 <= 1); + m6 = c0; + + /* Reduce 385 bits into 258. */ + /* p[0..4] = m[0..3] + m[4..6] * SECP256K1_N_C. */ + c0 = m0; c1 = 0; c2 = 0; + muladd_fast(m4, SECP256K1_N_C_0); + extract_fast(p0); + sumadd_fast(m1); + muladd(m5, SECP256K1_N_C_0); + muladd(m4, SECP256K1_N_C_1); + extract(p1); + sumadd(m2); + muladd(m6, SECP256K1_N_C_0); + muladd(m5, SECP256K1_N_C_1); + sumadd(m4); + extract(p2); + sumadd_fast(m3); + muladd_fast(m6, SECP256K1_N_C_1); + sumadd_fast(m5); + extract_fast(p3); + p4 = c0 + m6; + VERIFY_CHECK(p4 <= 2); + + /* Reduce 258 bits into 256. */ + /* r[0..3] = p[0..3] + p[4] * SECP256K1_N_C. */ + c = p0 + (uint128_t)SECP256K1_N_C_0 * p4; + r->d[0] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p1 + (uint128_t)SECP256K1_N_C_1 * p4; + r->d[1] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p2 + (uint128_t)p4; + r->d[2] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p3; + r->d[3] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; +#endif + + /* Final reduction of r. */ + secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r)); +} + +static void secp256k1_scalar_mul_512(uint64_t l[8], const secp256k1_scalar *a, const secp256k1_scalar *b) { +#ifdef USE_ASM_X86_64 + const uint64_t *pb = b->d; + __asm__ __volatile__( + /* Preload */ + "movq 0(%%rdi), %%r15\n" + "movq 8(%%rdi), %%rbx\n" + "movq 16(%%rdi), %%rcx\n" + "movq 0(%%rdx), %%r11\n" + "movq 8(%%rdx), %%r12\n" + "movq 16(%%rdx), %%r13\n" + "movq 24(%%rdx), %%r14\n" + /* (rax,rdx) = a0 * b0 */ + "movq %%r15, %%rax\n" + "mulq %%r11\n" + /* Extract l0 */ + "movq %%rax, 0(%%rsi)\n" + /* (r8,r9,r10) = (rdx) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += a0 * b1 */ + "movq %%r15, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a1 * b0 */ + "movq %%rbx, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l1 */ + "movq %%r8, 8(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += a0 * b2 */ + "movq %%r15, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a1 * b1 */ + "movq %%rbx, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a2 * b0 */ + "movq %%rcx, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l2 */ + "movq %%r9, 16(%%rsi)\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += a0 * b3 */ + "movq %%r15, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Preload a3 */ + "movq 24(%%rdi), %%r15\n" + /* (r10,r8,r9) += a1 * b2 */ + "movq %%rbx, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += a2 * b1 */ + "movq %%rcx, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += a3 * b0 */ + "movq %%r15, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Extract l3 */ + "movq %%r10, 24(%%rsi)\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += a1 * b3 */ + "movq %%rbx, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a2 * b2 */ + "movq %%rcx, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a3 * b1 */ + "movq %%r15, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l4 */ + "movq %%r8, 32(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += a2 * b3 */ + "movq %%rcx, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a3 * b2 */ + "movq %%r15, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l5 */ + "movq %%r9, 40(%%rsi)\n" + /* (r10,r8) += a3 * b3 */ + "movq %%r15, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + /* Extract l6 */ + "movq %%r10, 48(%%rsi)\n" + /* Extract l7 */ + "movq %%r8, 56(%%rsi)\n" + : "+d"(pb) + : "S"(l), "D"(a->d) + : "rax", "rbx", "rcx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "cc", "memory"); +#else + /* 160 bit accumulator. */ + uint64_t c0 = 0, c1 = 0; + uint32_t c2 = 0; + + /* l[0..7] = a[0..3] * b[0..3]. */ + muladd_fast(a->d[0], b->d[0]); + extract_fast(l[0]); + muladd(a->d[0], b->d[1]); + muladd(a->d[1], b->d[0]); + extract(l[1]); + muladd(a->d[0], b->d[2]); + muladd(a->d[1], b->d[1]); + muladd(a->d[2], b->d[0]); + extract(l[2]); + muladd(a->d[0], b->d[3]); + muladd(a->d[1], b->d[2]); + muladd(a->d[2], b->d[1]); + muladd(a->d[3], b->d[0]); + extract(l[3]); + muladd(a->d[1], b->d[3]); + muladd(a->d[2], b->d[2]); + muladd(a->d[3], b->d[1]); + extract(l[4]); + muladd(a->d[2], b->d[3]); + muladd(a->d[3], b->d[2]); + extract(l[5]); + muladd_fast(a->d[3], b->d[3]); + extract_fast(l[6]); + VERIFY_CHECK(c1 == 0); + l[7] = c0; +#endif +} + +static void secp256k1_scalar_sqr_512(uint64_t l[8], const secp256k1_scalar *a) { +#ifdef USE_ASM_X86_64 + __asm__ __volatile__( + /* Preload */ + "movq 0(%%rdi), %%r11\n" + "movq 8(%%rdi), %%r12\n" + "movq 16(%%rdi), %%r13\n" + "movq 24(%%rdi), %%r14\n" + /* (rax,rdx) = a0 * a0 */ + "movq %%r11, %%rax\n" + "mulq %%r11\n" + /* Extract l0 */ + "movq %%rax, 0(%%rsi)\n" + /* (r8,r9,r10) = (rdx,0) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += 2 * a0 * a1 */ + "movq %%r11, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l1 */ + "movq %%r8, 8(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += 2 * a0 * a2 */ + "movq %%r11, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a1 * a1 */ + "movq %%r12, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l2 */ + "movq %%r9, 16(%%rsi)\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += 2 * a0 * a3 */ + "movq %%r11, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += 2 * a1 * a2 */ + "movq %%r12, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Extract l3 */ + "movq %%r10, 24(%%rsi)\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += 2 * a1 * a3 */ + "movq %%r12, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a2 * a2 */ + "movq %%r13, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l4 */ + "movq %%r8, 32(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += 2 * a2 * a3 */ + "movq %%r13, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l5 */ + "movq %%r9, 40(%%rsi)\n" + /* (r10,r8) += a3 * a3 */ + "movq %%r14, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + /* Extract l6 */ + "movq %%r10, 48(%%rsi)\n" + /* Extract l7 */ + "movq %%r8, 56(%%rsi)\n" + : + : "S"(l), "D"(a->d) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc", "memory"); +#else + /* 160 bit accumulator. */ + uint64_t c0 = 0, c1 = 0; + uint32_t c2 = 0; + + /* l[0..7] = a[0..3] * b[0..3]. */ + muladd_fast(a->d[0], a->d[0]); + extract_fast(l[0]); + muladd2(a->d[0], a->d[1]); + extract(l[1]); + muladd2(a->d[0], a->d[2]); + muladd(a->d[1], a->d[1]); + extract(l[2]); + muladd2(a->d[0], a->d[3]); + muladd2(a->d[1], a->d[2]); + extract(l[3]); + muladd2(a->d[1], a->d[3]); + muladd(a->d[2], a->d[2]); + extract(l[4]); + muladd2(a->d[2], a->d[3]); + extract(l[5]); + muladd_fast(a->d[3], a->d[3]); + extract_fast(l[6]); + VERIFY_CHECK(c1 == 0); + l[7] = c0; +#endif +} + +#undef sumadd +#undef sumadd_fast +#undef muladd +#undef muladd_fast +#undef muladd2 +#undef extract +#undef extract_fast + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + uint64_t l[8]; + secp256k1_scalar_mul_512(l, a, b); + secp256k1_scalar_reduce_512(r, l); +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = r->d[0] & ((1 << n) - 1); + r->d[0] = (r->d[0] >> n) + (r->d[1] << (64 - n)); + r->d[1] = (r->d[1] >> n) + (r->d[2] << (64 - n)); + r->d[2] = (r->d[2] >> n) + (r->d[3] << (64 - n)); + r->d[3] = (r->d[3] >> n); + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint64_t l[8]; + secp256k1_scalar_sqr_512(l, a); + secp256k1_scalar_reduce_512(r, l); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + r1->d[0] = a->d[0]; + r1->d[1] = a->d[1]; + r1->d[2] = 0; + r1->d[3] = 0; + r2->d[0] = a->d[2]; + r2->d[1] = a->d[3]; + r2->d[2] = 0; + r2->d[3] = 0; +} +#endif + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return ((a->d[0] ^ b->d[0]) | (a->d[1] ^ b->d[1]) | (a->d[2] ^ b->d[2]) | (a->d[3] ^ b->d[3])) == 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift) { + uint64_t l[8]; + unsigned int shiftlimbs; + unsigned int shiftlow; + unsigned int shifthigh; + VERIFY_CHECK(shift >= 256); + secp256k1_scalar_mul_512(l, a, b); + shiftlimbs = shift >> 6; + shiftlow = shift & 0x3F; + shifthigh = 64 - shiftlow; + r->d[0] = shift < 512 ? (l[0 + shiftlimbs] >> shiftlow | (shift < 448 && shiftlow ? (l[1 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[1] = shift < 448 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[2] = shift < 384 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[3] = shift < 320 ? (l[3 + shiftlimbs] >> shiftlow) : 0; + secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 6] >> ((shift - 1) & 0x3f)) & 1); +} + +#define ROTL32(x,n) ((x) << (n) | (x) >> (32-(n))) +#define QUARTERROUND(a,b,c,d) \ +a += b; d = ROTL32(d ^ a, 16); \ +c += d; b = ROTL32(b ^ c, 12); \ +a += b; d = ROTL32(d ^ a, 8); \ +c += d; b = ROTL32(b ^ c, 7); + +#ifdef WORDS_BIGENDIAN +#define LE32(p) ((((p) & 0xFF) << 24) | (((p) & 0xFF00) << 8) | (((p) & 0xFF0000) >> 8) | (((p) & 0xFF000000) >> 24)) +#define BE32(p) (p) +#else +#define BE32(p) ((((p) & 0xFF) << 24) | (((p) & 0xFF00) << 8) | (((p) & 0xFF0000) >> 8) | (((p) & 0xFF000000) >> 24)) +#define LE32(p) (p) +#endif + +static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { + size_t n; + size_t over_count = 0; + uint32_t seed32[8]; + uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; + int over1, over2; + + memcpy((void *) seed32, (const void *) seed, 32); + do { + x0 = 0x61707865; + x1 = 0x3320646e; + x2 = 0x79622d32; + x3 = 0x6b206574; + x4 = LE32(seed32[0]); + x5 = LE32(seed32[1]); + x6 = LE32(seed32[2]); + x7 = LE32(seed32[3]); + x8 = LE32(seed32[4]); + x9 = LE32(seed32[5]); + x10 = LE32(seed32[6]); + x11 = LE32(seed32[7]); + x12 = idx; + x13 = idx >> 32; + x14 = 0; + x15 = over_count; + + n = 10; + while (n--) { + QUARTERROUND(x0, x4, x8,x12) + QUARTERROUND(x1, x5, x9,x13) + QUARTERROUND(x2, x6,x10,x14) + QUARTERROUND(x3, x7,x11,x15) + QUARTERROUND(x0, x5,x10,x15) + QUARTERROUND(x1, x6,x11,x12) + QUARTERROUND(x2, x7, x8,x13) + QUARTERROUND(x3, x4, x9,x14) + } + + x0 += 0x61707865; + x1 += 0x3320646e; + x2 += 0x79622d32; + x3 += 0x6b206574; + x4 += LE32(seed32[0]); + x5 += LE32(seed32[1]); + x6 += LE32(seed32[2]); + x7 += LE32(seed32[3]); + x8 += LE32(seed32[4]); + x9 += LE32(seed32[5]); + x10 += LE32(seed32[6]); + x11 += LE32(seed32[7]); + x12 += idx; + x13 += idx >> 32; + x14 += 0; + x15 += over_count; + + r1->d[3] = LE32((uint64_t) x0) << 32 | LE32(x1); + r1->d[2] = LE32((uint64_t) x2) << 32 | LE32(x3); + r1->d[1] = LE32((uint64_t) x4) << 32 | LE32(x5); + r1->d[0] = LE32((uint64_t) x6) << 32 | LE32(x7); + r2->d[3] = LE32((uint64_t) x8) << 32 | LE32(x9); + r2->d[2] = LE32((uint64_t) x10) << 32 | LE32(x11); + r2->d[1] = LE32((uint64_t) x12) << 32 | LE32(x13); + r2->d[0] = LE32((uint64_t) x14) << 32 | LE32(x15); + + over1 = secp256k1_scalar_check_overflow(r1); + over2 = secp256k1_scalar_check_overflow(r2); + over_count++; + } while (over1 | over2); +} + +#undef ROTL32 +#undef QUARTERROUND +#undef BE32 +#undef LE32 + +#endif /* SECP256K1_SCALAR_REPR_IMPL_H */ +#endif + diff --git a/src/secp256k1/src/scalar_8x32.h b/src/secp256k1/src/scalar_8x32.h index 2c9a348e2..68a2c0428 100644 --- a/src/secp256k1/src/scalar_8x32.h +++ b/src/secp256k1/src/scalar_8x32.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -17,3 +19,25 @@ typedef struct { #define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}} #endif /* SECP256K1_SCALAR_REPR_H */ + +#else +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_REPR_H +#define SECP256K1_SCALAR_REPR_H + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef struct { + uint32_t d[8]; +} secp256k1_scalar; + +#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}} + +#endif /* SECP256K1_SCALAR_REPR_H */ +#endif diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/src/secp256k1/src/scalar_8x32_impl.h index 4f9ed61fe..e1299cbaa 100644 --- a/src/secp256k1/src/scalar_8x32_impl.h +++ b/src/secp256k1/src/scalar_8x32_impl.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -719,3 +721,839 @@ SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, } #endif /* SECP256K1_SCALAR_REPR_IMPL_H */ + +#else +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_REPR_IMPL_H +#define SECP256K1_SCALAR_REPR_IMPL_H + +#include + +/* Limbs of the secp256k1 order. */ +#define SECP256K1_N_0 ((uint32_t)0xD0364141UL) +#define SECP256K1_N_1 ((uint32_t)0xBFD25E8CUL) +#define SECP256K1_N_2 ((uint32_t)0xAF48A03BUL) +#define SECP256K1_N_3 ((uint32_t)0xBAAEDCE6UL) +#define SECP256K1_N_4 ((uint32_t)0xFFFFFFFEUL) +#define SECP256K1_N_5 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_6 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_7 ((uint32_t)0xFFFFFFFFUL) + +/* Limbs of 2^256 minus the secp256k1 order. */ +#define SECP256K1_N_C_0 (~SECP256K1_N_0 + 1) +#define SECP256K1_N_C_1 (~SECP256K1_N_1) +#define SECP256K1_N_C_2 (~SECP256K1_N_2) +#define SECP256K1_N_C_3 (~SECP256K1_N_3) +#define SECP256K1_N_C_4 (1) + +/* Limbs of half the secp256k1 order. */ +#define SECP256K1_N_H_0 ((uint32_t)0x681B20A0UL) +#define SECP256K1_N_H_1 ((uint32_t)0xDFE92F46UL) +#define SECP256K1_N_H_2 ((uint32_t)0x57A4501DUL) +#define SECP256K1_N_H_3 ((uint32_t)0x5D576E73UL) +#define SECP256K1_N_H_4 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_5 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_6 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_7 ((uint32_t)0x7FFFFFFFUL) + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { + r->d[0] = 0; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; + r->d[4] = 0; + r->d[5] = 0; + r->d[6] = 0; + r->d[7] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { + r->d[0] = v; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; + r->d[4] = 0; + r->d[5] = 0; + r->d[6] = 0; + r->d[7] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_u64(secp256k1_scalar *r, uint64_t v) { + r->d[0] = v; + r->d[1] = v >> 32; + r->d[2] = 0; + r->d[3] = 0; + r->d[4] = 0; + r->d[5] = 0; + r->d[6] = 0; + r->d[7] = 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK((offset + count - 1) >> 5 == offset >> 5); + return (a->d[offset >> 5] >> (offset & 0x1F)) & ((1 << count) - 1); +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK(count < 32); + VERIFY_CHECK(offset + count <= 256); + if ((offset + count - 1) >> 5 == offset >> 5) { + return secp256k1_scalar_get_bits(a, offset, count); + } else { + VERIFY_CHECK((offset >> 5) + 1 < 8); + return ((a->d[offset >> 5] >> (offset & 0x1F)) | (a->d[(offset >> 5) + 1] << (32 - (offset & 0x1F)))) & ((((uint32_t)1) << count) - 1); + } +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[7] < SECP256K1_N_7); /* No need for a > check. */ + no |= (a->d[6] < SECP256K1_N_6); /* No need for a > check. */ + no |= (a->d[5] < SECP256K1_N_5); /* No need for a > check. */ + no |= (a->d[4] < SECP256K1_N_4); + yes |= (a->d[4] > SECP256K1_N_4) & ~no; + no |= (a->d[3] < SECP256K1_N_3) & ~yes; + yes |= (a->d[3] > SECP256K1_N_3) & ~no; + no |= (a->d[2] < SECP256K1_N_2) & ~yes; + yes |= (a->d[2] > SECP256K1_N_2) & ~no; + no |= (a->d[1] < SECP256K1_N_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_1) & ~no; + yes |= (a->d[0] >= SECP256K1_N_0) & ~no; + return yes; +} + +SECP256K1_INLINE static int secp256k1_scalar_reduce(secp256k1_scalar *r, uint32_t overflow) { + uint64_t t; + VERIFY_CHECK(overflow <= 1); + t = (uint64_t)r->d[0] + overflow * SECP256K1_N_C_0; + r->d[0] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[1] + overflow * SECP256K1_N_C_1; + r->d[1] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[2] + overflow * SECP256K1_N_C_2; + r->d[2] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[3] + overflow * SECP256K1_N_C_3; + r->d[3] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[4] + overflow * SECP256K1_N_C_4; + r->d[4] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[5]; + r->d[5] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[6]; + r->d[6] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[7]; + r->d[7] = t & 0xFFFFFFFFUL; + return overflow; +} + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + int overflow; + uint64_t t = (uint64_t)a->d[0] + b->d[0]; + r->d[0] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[1] + b->d[1]; + r->d[1] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[2] + b->d[2]; + r->d[2] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[3] + b->d[3]; + r->d[3] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[4] + b->d[4]; + r->d[4] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[5] + b->d[5]; + r->d[5] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[6] + b->d[6]; + r->d[6] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[7] + b->d[7]; + r->d[7] = t & 0xFFFFFFFFULL; t >>= 32; + overflow = t + secp256k1_scalar_check_overflow(r); + VERIFY_CHECK(overflow == 0 || overflow == 1); + secp256k1_scalar_reduce(r, overflow); + return overflow; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + uint64_t t; + VERIFY_CHECK(bit < 256); + bit += ((uint32_t) flag - 1) & 0x100; /* forcing (bit >> 5) > 7 makes this a noop */ + t = (uint64_t)r->d[0] + (((uint32_t)((bit >> 5) == 0)) << (bit & 0x1F)); + r->d[0] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[1] + (((uint32_t)((bit >> 5) == 1)) << (bit & 0x1F)); + r->d[1] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[2] + (((uint32_t)((bit >> 5) == 2)) << (bit & 0x1F)); + r->d[2] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[3] + (((uint32_t)((bit >> 5) == 3)) << (bit & 0x1F)); + r->d[3] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[4] + (((uint32_t)((bit >> 5) == 4)) << (bit & 0x1F)); + r->d[4] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[5] + (((uint32_t)((bit >> 5) == 5)) << (bit & 0x1F)); + r->d[5] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[6] + (((uint32_t)((bit >> 5) == 6)) << (bit & 0x1F)); + r->d[6] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[7] + (((uint32_t)((bit >> 5) == 7)) << (bit & 0x1F)); + r->d[7] = t & 0xFFFFFFFFULL; +#ifdef VERIFY + VERIFY_CHECK((t >> 32) == 0); + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + int over; + r->d[0] = (uint32_t)b32[31] | (uint32_t)b32[30] << 8 | (uint32_t)b32[29] << 16 | (uint32_t)b32[28] << 24; + r->d[1] = (uint32_t)b32[27] | (uint32_t)b32[26] << 8 | (uint32_t)b32[25] << 16 | (uint32_t)b32[24] << 24; + r->d[2] = (uint32_t)b32[23] | (uint32_t)b32[22] << 8 | (uint32_t)b32[21] << 16 | (uint32_t)b32[20] << 24; + r->d[3] = (uint32_t)b32[19] | (uint32_t)b32[18] << 8 | (uint32_t)b32[17] << 16 | (uint32_t)b32[16] << 24; + r->d[4] = (uint32_t)b32[15] | (uint32_t)b32[14] << 8 | (uint32_t)b32[13] << 16 | (uint32_t)b32[12] << 24; + r->d[5] = (uint32_t)b32[11] | (uint32_t)b32[10] << 8 | (uint32_t)b32[9] << 16 | (uint32_t)b32[8] << 24; + r->d[6] = (uint32_t)b32[7] | (uint32_t)b32[6] << 8 | (uint32_t)b32[5] << 16 | (uint32_t)b32[4] << 24; + r->d[7] = (uint32_t)b32[3] | (uint32_t)b32[2] << 8 | (uint32_t)b32[1] << 16 | (uint32_t)b32[0] << 24; + over = secp256k1_scalar_reduce(r, secp256k1_scalar_check_overflow(r)); + if (overflow) { + *overflow = over; + } +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + bin[0] = a->d[7] >> 24; bin[1] = a->d[7] >> 16; bin[2] = a->d[7] >> 8; bin[3] = a->d[7]; + bin[4] = a->d[6] >> 24; bin[5] = a->d[6] >> 16; bin[6] = a->d[6] >> 8; bin[7] = a->d[6]; + bin[8] = a->d[5] >> 24; bin[9] = a->d[5] >> 16; bin[10] = a->d[5] >> 8; bin[11] = a->d[5]; + bin[12] = a->d[4] >> 24; bin[13] = a->d[4] >> 16; bin[14] = a->d[4] >> 8; bin[15] = a->d[4]; + bin[16] = a->d[3] >> 24; bin[17] = a->d[3] >> 16; bin[18] = a->d[3] >> 8; bin[19] = a->d[3]; + bin[20] = a->d[2] >> 24; bin[21] = a->d[2] >> 16; bin[22] = a->d[2] >> 8; bin[23] = a->d[2]; + bin[24] = a->d[1] >> 24; bin[25] = a->d[1] >> 16; bin[26] = a->d[1] >> 8; bin[27] = a->d[1]; + bin[28] = a->d[0] >> 24; bin[29] = a->d[0] >> 16; bin[30] = a->d[0] >> 8; bin[31] = a->d[0]; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return (a->d[0] | a->d[1] | a->d[2] | a->d[3] | a->d[4] | a->d[5] | a->d[6] | a->d[7]) == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint32_t nonzero = 0xFFFFFFFFUL * (secp256k1_scalar_is_zero(a) == 0); + uint64_t t = (uint64_t)(~a->d[0]) + SECP256K1_N_0 + 1; + r->d[0] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[1]) + SECP256K1_N_1; + r->d[1] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[2]) + SECP256K1_N_2; + r->d[2] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[3]) + SECP256K1_N_3; + r->d[3] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[4]) + SECP256K1_N_4; + r->d[4] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[5]) + SECP256K1_N_5; + r->d[5] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[6]) + SECP256K1_N_6; + r->d[6] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[7]) + SECP256K1_N_7; + r->d[7] = t & nonzero; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return ((a->d[0] ^ 1) | a->d[1] | a->d[2] | a->d[3] | a->d[4] | a->d[5] | a->d[6] | a->d[7]) == 0; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[7] < SECP256K1_N_H_7); + yes |= (a->d[7] > SECP256K1_N_H_7) & ~no; + no |= (a->d[6] < SECP256K1_N_H_6) & ~yes; /* No need for a > check. */ + no |= (a->d[5] < SECP256K1_N_H_5) & ~yes; /* No need for a > check. */ + no |= (a->d[4] < SECP256K1_N_H_4) & ~yes; /* No need for a > check. */ + no |= (a->d[3] < SECP256K1_N_H_3) & ~yes; + yes |= (a->d[3] > SECP256K1_N_H_3) & ~no; + no |= (a->d[2] < SECP256K1_N_H_2) & ~yes; + yes |= (a->d[2] > SECP256K1_N_H_2) & ~no; + no |= (a->d[1] < SECP256K1_N_H_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_H_1) & ~no; + yes |= (a->d[0] > SECP256K1_N_H_0) & ~no; + return yes; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + /* If we are flag = 0, mask = 00...00 and this is a no-op; + * if we are flag = 1, mask = 11...11 and this is identical to secp256k1_scalar_negate */ + uint32_t mask = !flag - 1; + uint32_t nonzero = 0xFFFFFFFFUL * (secp256k1_scalar_is_zero(r) == 0); + uint64_t t = (uint64_t)(r->d[0] ^ mask) + ((SECP256K1_N_0 + 1) & mask); + r->d[0] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[1] ^ mask) + (SECP256K1_N_1 & mask); + r->d[1] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[2] ^ mask) + (SECP256K1_N_2 & mask); + r->d[2] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[3] ^ mask) + (SECP256K1_N_3 & mask); + r->d[3] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[4] ^ mask) + (SECP256K1_N_4 & mask); + r->d[4] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[5] ^ mask) + (SECP256K1_N_5 & mask); + r->d[5] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[6] ^ mask) + (SECP256K1_N_6 & mask); + r->d[6] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[7] ^ mask) + (SECP256K1_N_7 & mask); + r->d[7] = t & nonzero; + return 2 * (mask == 0) - 1; +} + + +/* Inspired by the macros in OpenSSL's crypto/bn/asm/x86_64-gcc.c. */ + +/** Add a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd(a,b) { \ +uint32_t tl, th; \ +{ \ +uint64_t t = (uint64_t)a * b; \ +th = t >> 32; /* at most 0xFFFFFFFE */ \ +tl = t; \ +} \ +c0 += tl; /* overflow is handled on the next line */ \ +th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ +c1 += th; /* overflow is handled on the next line */ \ +c2 += (c1 < th) ? 1 : 0; /* never overflows by contract (verified in the next line) */ \ +VERIFY_CHECK((c1 >= th) || (c2 != 0)); \ +} + +/** Add a*b to the number defined by (c0,c1). c1 must never overflow. */ +#define muladd_fast(a,b) { \ +uint32_t tl, th; \ +{ \ +uint64_t t = (uint64_t)a * b; \ +th = t >> 32; /* at most 0xFFFFFFFE */ \ +tl = t; \ +} \ +c0 += tl; /* overflow is handled on the next line */ \ +th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ +c1 += th; /* never overflows by contract (verified in the next line) */ \ +VERIFY_CHECK(c1 >= th); \ +} + +/** Add 2*a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd2(a,b) { \ +uint32_t tl, th, th2, tl2; \ +{ \ +uint64_t t = (uint64_t)a * b; \ +th = t >> 32; /* at most 0xFFFFFFFE */ \ +tl = t; \ +} \ +th2 = th + th; /* at most 0xFFFFFFFE (in case th was 0x7FFFFFFF) */ \ +c2 += (th2 < th) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((th2 >= th) || (c2 != 0)); \ +tl2 = tl + tl; /* at most 0xFFFFFFFE (in case the lowest 63 bits of tl were 0x7FFFFFFF) */ \ +th2 += (tl2 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ +c0 += tl2; /* overflow is handled on the next line */ \ +th2 += (c0 < tl2) ? 1 : 0; /* second overflow is handled on the next line */ \ +c2 += (c0 < tl2) & (th2 == 0); /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((c0 >= tl2) || (th2 != 0) || (c2 != 0)); \ +c1 += th2; /* overflow is handled on the next line */ \ +c2 += (c1 < th2) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((c1 >= th2) || (c2 != 0)); \ +} + +/** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define sumadd(a) { \ +unsigned int over; \ +c0 += (a); /* overflow is handled on the next line */ \ +over = (c0 < (a)) ? 1 : 0; \ +c1 += over; /* overflow is handled on the next line */ \ +c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ +} + +/** Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero. */ +#define sumadd_fast(a) { \ +c0 += (a); /* overflow is handled on the next line */ \ +c1 += (c0 < (a)) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ +VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \ +VERIFY_CHECK(c2 == 0); \ +} + +/** Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. */ +#define extract(n) { \ +(n) = c0; \ +c0 = c1; \ +c1 = c2; \ +c2 = 0; \ +} + +/** Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. c2 is required to be zero. */ +#define extract_fast(n) { \ +(n) = c0; \ +c0 = c1; \ +c1 = 0; \ +VERIFY_CHECK(c2 == 0); \ +} + +static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint32_t *l) { + uint64_t c; + uint32_t n0 = l[8], n1 = l[9], n2 = l[10], n3 = l[11], n4 = l[12], n5 = l[13], n6 = l[14], n7 = l[15]; + uint32_t m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12; + uint32_t p0, p1, p2, p3, p4, p5, p6, p7, p8; + + /* 96 bit accumulator. */ + uint32_t c0, c1, c2; + + /* Reduce 512 bits into 385. */ + /* m[0..12] = l[0..7] + n[0..7] * SECP256K1_N_C. */ + c0 = l[0]; c1 = 0; c2 = 0; + muladd_fast(n0, SECP256K1_N_C_0); + extract_fast(m0); + sumadd_fast(l[1]); + muladd(n1, SECP256K1_N_C_0); + muladd(n0, SECP256K1_N_C_1); + extract(m1); + sumadd(l[2]); + muladd(n2, SECP256K1_N_C_0); + muladd(n1, SECP256K1_N_C_1); + muladd(n0, SECP256K1_N_C_2); + extract(m2); + sumadd(l[3]); + muladd(n3, SECP256K1_N_C_0); + muladd(n2, SECP256K1_N_C_1); + muladd(n1, SECP256K1_N_C_2); + muladd(n0, SECP256K1_N_C_3); + extract(m3); + sumadd(l[4]); + muladd(n4, SECP256K1_N_C_0); + muladd(n3, SECP256K1_N_C_1); + muladd(n2, SECP256K1_N_C_2); + muladd(n1, SECP256K1_N_C_3); + sumadd(n0); + extract(m4); + sumadd(l[5]); + muladd(n5, SECP256K1_N_C_0); + muladd(n4, SECP256K1_N_C_1); + muladd(n3, SECP256K1_N_C_2); + muladd(n2, SECP256K1_N_C_3); + sumadd(n1); + extract(m5); + sumadd(l[6]); + muladd(n6, SECP256K1_N_C_0); + muladd(n5, SECP256K1_N_C_1); + muladd(n4, SECP256K1_N_C_2); + muladd(n3, SECP256K1_N_C_3); + sumadd(n2); + extract(m6); + sumadd(l[7]); + muladd(n7, SECP256K1_N_C_0); + muladd(n6, SECP256K1_N_C_1); + muladd(n5, SECP256K1_N_C_2); + muladd(n4, SECP256K1_N_C_3); + sumadd(n3); + extract(m7); + muladd(n7, SECP256K1_N_C_1); + muladd(n6, SECP256K1_N_C_2); + muladd(n5, SECP256K1_N_C_3); + sumadd(n4); + extract(m8); + muladd(n7, SECP256K1_N_C_2); + muladd(n6, SECP256K1_N_C_3); + sumadd(n5); + extract(m9); + muladd(n7, SECP256K1_N_C_3); + sumadd(n6); + extract(m10); + sumadd_fast(n7); + extract_fast(m11); + VERIFY_CHECK(c0 <= 1); + m12 = c0; + + /* Reduce 385 bits into 258. */ + /* p[0..8] = m[0..7] + m[8..12] * SECP256K1_N_C. */ + c0 = m0; c1 = 0; c2 = 0; + muladd_fast(m8, SECP256K1_N_C_0); + extract_fast(p0); + sumadd_fast(m1); + muladd(m9, SECP256K1_N_C_0); + muladd(m8, SECP256K1_N_C_1); + extract(p1); + sumadd(m2); + muladd(m10, SECP256K1_N_C_0); + muladd(m9, SECP256K1_N_C_1); + muladd(m8, SECP256K1_N_C_2); + extract(p2); + sumadd(m3); + muladd(m11, SECP256K1_N_C_0); + muladd(m10, SECP256K1_N_C_1); + muladd(m9, SECP256K1_N_C_2); + muladd(m8, SECP256K1_N_C_3); + extract(p3); + sumadd(m4); + muladd(m12, SECP256K1_N_C_0); + muladd(m11, SECP256K1_N_C_1); + muladd(m10, SECP256K1_N_C_2); + muladd(m9, SECP256K1_N_C_3); + sumadd(m8); + extract(p4); + sumadd(m5); + muladd(m12, SECP256K1_N_C_1); + muladd(m11, SECP256K1_N_C_2); + muladd(m10, SECP256K1_N_C_3); + sumadd(m9); + extract(p5); + sumadd(m6); + muladd(m12, SECP256K1_N_C_2); + muladd(m11, SECP256K1_N_C_3); + sumadd(m10); + extract(p6); + sumadd_fast(m7); + muladd_fast(m12, SECP256K1_N_C_3); + sumadd_fast(m11); + extract_fast(p7); + p8 = c0 + m12; + VERIFY_CHECK(p8 <= 2); + + /* Reduce 258 bits into 256. */ + /* r[0..7] = p[0..7] + p[8] * SECP256K1_N_C. */ + c = p0 + (uint64_t)SECP256K1_N_C_0 * p8; + r->d[0] = c & 0xFFFFFFFFUL; c >>= 32; + c += p1 + (uint64_t)SECP256K1_N_C_1 * p8; + r->d[1] = c & 0xFFFFFFFFUL; c >>= 32; + c += p2 + (uint64_t)SECP256K1_N_C_2 * p8; + r->d[2] = c & 0xFFFFFFFFUL; c >>= 32; + c += p3 + (uint64_t)SECP256K1_N_C_3 * p8; + r->d[3] = c & 0xFFFFFFFFUL; c >>= 32; + c += p4 + (uint64_t)p8; + r->d[4] = c & 0xFFFFFFFFUL; c >>= 32; + c += p5; + r->d[5] = c & 0xFFFFFFFFUL; c >>= 32; + c += p6; + r->d[6] = c & 0xFFFFFFFFUL; c >>= 32; + c += p7; + r->d[7] = c & 0xFFFFFFFFUL; c >>= 32; + + /* Final reduction of r. */ + secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r)); +} + +static void secp256k1_scalar_mul_512(uint32_t *l, const secp256k1_scalar *a, const secp256k1_scalar *b) { + /* 96 bit accumulator. */ + uint32_t c0 = 0, c1 = 0, c2 = 0; + + /* l[0..15] = a[0..7] * b[0..7]. */ + muladd_fast(a->d[0], b->d[0]); + extract_fast(l[0]); + muladd(a->d[0], b->d[1]); + muladd(a->d[1], b->d[0]); + extract(l[1]); + muladd(a->d[0], b->d[2]); + muladd(a->d[1], b->d[1]); + muladd(a->d[2], b->d[0]); + extract(l[2]); + muladd(a->d[0], b->d[3]); + muladd(a->d[1], b->d[2]); + muladd(a->d[2], b->d[1]); + muladd(a->d[3], b->d[0]); + extract(l[3]); + muladd(a->d[0], b->d[4]); + muladd(a->d[1], b->d[3]); + muladd(a->d[2], b->d[2]); + muladd(a->d[3], b->d[1]); + muladd(a->d[4], b->d[0]); + extract(l[4]); + muladd(a->d[0], b->d[5]); + muladd(a->d[1], b->d[4]); + muladd(a->d[2], b->d[3]); + muladd(a->d[3], b->d[2]); + muladd(a->d[4], b->d[1]); + muladd(a->d[5], b->d[0]); + extract(l[5]); + muladd(a->d[0], b->d[6]); + muladd(a->d[1], b->d[5]); + muladd(a->d[2], b->d[4]); + muladd(a->d[3], b->d[3]); + muladd(a->d[4], b->d[2]); + muladd(a->d[5], b->d[1]); + muladd(a->d[6], b->d[0]); + extract(l[6]); + muladd(a->d[0], b->d[7]); + muladd(a->d[1], b->d[6]); + muladd(a->d[2], b->d[5]); + muladd(a->d[3], b->d[4]); + muladd(a->d[4], b->d[3]); + muladd(a->d[5], b->d[2]); + muladd(a->d[6], b->d[1]); + muladd(a->d[7], b->d[0]); + extract(l[7]); + muladd(a->d[1], b->d[7]); + muladd(a->d[2], b->d[6]); + muladd(a->d[3], b->d[5]); + muladd(a->d[4], b->d[4]); + muladd(a->d[5], b->d[3]); + muladd(a->d[6], b->d[2]); + muladd(a->d[7], b->d[1]); + extract(l[8]); + muladd(a->d[2], b->d[7]); + muladd(a->d[3], b->d[6]); + muladd(a->d[4], b->d[5]); + muladd(a->d[5], b->d[4]); + muladd(a->d[6], b->d[3]); + muladd(a->d[7], b->d[2]); + extract(l[9]); + muladd(a->d[3], b->d[7]); + muladd(a->d[4], b->d[6]); + muladd(a->d[5], b->d[5]); + muladd(a->d[6], b->d[4]); + muladd(a->d[7], b->d[3]); + extract(l[10]); + muladd(a->d[4], b->d[7]); + muladd(a->d[5], b->d[6]); + muladd(a->d[6], b->d[5]); + muladd(a->d[7], b->d[4]); + extract(l[11]); + muladd(a->d[5], b->d[7]); + muladd(a->d[6], b->d[6]); + muladd(a->d[7], b->d[5]); + extract(l[12]); + muladd(a->d[6], b->d[7]); + muladd(a->d[7], b->d[6]); + extract(l[13]); + muladd_fast(a->d[7], b->d[7]); + extract_fast(l[14]); + VERIFY_CHECK(c1 == 0); + l[15] = c0; +} + +static void secp256k1_scalar_sqr_512(uint32_t *l, const secp256k1_scalar *a) { + /* 96 bit accumulator. */ + uint32_t c0 = 0, c1 = 0, c2 = 0; + + /* l[0..15] = a[0..7]^2. */ + muladd_fast(a->d[0], a->d[0]); + extract_fast(l[0]); + muladd2(a->d[0], a->d[1]); + extract(l[1]); + muladd2(a->d[0], a->d[2]); + muladd(a->d[1], a->d[1]); + extract(l[2]); + muladd2(a->d[0], a->d[3]); + muladd2(a->d[1], a->d[2]); + extract(l[3]); + muladd2(a->d[0], a->d[4]); + muladd2(a->d[1], a->d[3]); + muladd(a->d[2], a->d[2]); + extract(l[4]); + muladd2(a->d[0], a->d[5]); + muladd2(a->d[1], a->d[4]); + muladd2(a->d[2], a->d[3]); + extract(l[5]); + muladd2(a->d[0], a->d[6]); + muladd2(a->d[1], a->d[5]); + muladd2(a->d[2], a->d[4]); + muladd(a->d[3], a->d[3]); + extract(l[6]); + muladd2(a->d[0], a->d[7]); + muladd2(a->d[1], a->d[6]); + muladd2(a->d[2], a->d[5]); + muladd2(a->d[3], a->d[4]); + extract(l[7]); + muladd2(a->d[1], a->d[7]); + muladd2(a->d[2], a->d[6]); + muladd2(a->d[3], a->d[5]); + muladd(a->d[4], a->d[4]); + extract(l[8]); + muladd2(a->d[2], a->d[7]); + muladd2(a->d[3], a->d[6]); + muladd2(a->d[4], a->d[5]); + extract(l[9]); + muladd2(a->d[3], a->d[7]); + muladd2(a->d[4], a->d[6]); + muladd(a->d[5], a->d[5]); + extract(l[10]); + muladd2(a->d[4], a->d[7]); + muladd2(a->d[5], a->d[6]); + extract(l[11]); + muladd2(a->d[5], a->d[7]); + muladd(a->d[6], a->d[6]); + extract(l[12]); + muladd2(a->d[6], a->d[7]); + extract(l[13]); + muladd_fast(a->d[7], a->d[7]); + extract_fast(l[14]); + VERIFY_CHECK(c1 == 0); + l[15] = c0; +} + +#undef sumadd +#undef sumadd_fast +#undef muladd +#undef muladd_fast +#undef muladd2 +#undef extract +#undef extract_fast + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + uint32_t l[16]; + secp256k1_scalar_mul_512(l, a, b); + secp256k1_scalar_reduce_512(r, l); +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = r->d[0] & ((1 << n) - 1); + r->d[0] = (r->d[0] >> n) + (r->d[1] << (32 - n)); + r->d[1] = (r->d[1] >> n) + (r->d[2] << (32 - n)); + r->d[2] = (r->d[2] >> n) + (r->d[3] << (32 - n)); + r->d[3] = (r->d[3] >> n) + (r->d[4] << (32 - n)); + r->d[4] = (r->d[4] >> n) + (r->d[5] << (32 - n)); + r->d[5] = (r->d[5] >> n) + (r->d[6] << (32 - n)); + r->d[6] = (r->d[6] >> n) + (r->d[7] << (32 - n)); + r->d[7] = (r->d[7] >> n); + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint32_t l[16]; + secp256k1_scalar_sqr_512(l, a); + secp256k1_scalar_reduce_512(r, l); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + r1->d[0] = a->d[0]; + r1->d[1] = a->d[1]; + r1->d[2] = a->d[2]; + r1->d[3] = a->d[3]; + r1->d[4] = 0; + r1->d[5] = 0; + r1->d[6] = 0; + r1->d[7] = 0; + r2->d[0] = a->d[4]; + r2->d[1] = a->d[5]; + r2->d[2] = a->d[6]; + r2->d[3] = a->d[7]; + r2->d[4] = 0; + r2->d[5] = 0; + r2->d[6] = 0; + r2->d[7] = 0; +} +#endif + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return ((a->d[0] ^ b->d[0]) | (a->d[1] ^ b->d[1]) | (a->d[2] ^ b->d[2]) | (a->d[3] ^ b->d[3]) | (a->d[4] ^ b->d[4]) | (a->d[5] ^ b->d[5]) | (a->d[6] ^ b->d[6]) | (a->d[7] ^ b->d[7])) == 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift) { + uint32_t l[16]; + unsigned int shiftlimbs; + unsigned int shiftlow; + unsigned int shifthigh; + VERIFY_CHECK(shift >= 256); + secp256k1_scalar_mul_512(l, a, b); + shiftlimbs = shift >> 5; + shiftlow = shift & 0x1F; + shifthigh = 32 - shiftlow; + r->d[0] = shift < 512 ? (l[0 + shiftlimbs] >> shiftlow | (shift < 480 && shiftlow ? (l[1 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[1] = shift < 480 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 448 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[2] = shift < 448 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 416 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[3] = shift < 416 ? (l[3 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[4 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[4] = shift < 384 ? (l[4 + shiftlimbs] >> shiftlow | (shift < 352 && shiftlow ? (l[5 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[5] = shift < 352 ? (l[5 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[6 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[6] = shift < 320 ? (l[6 + shiftlimbs] >> shiftlow | (shift < 288 && shiftlow ? (l[7 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[7] = shift < 288 ? (l[7 + shiftlimbs] >> shiftlow) : 0; + secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 5] >> ((shift - 1) & 0x1f)) & 1); +} + +#define ROTL32(x,n) ((x) << (n) | (x) >> (32-(n))) +#define QUARTERROUND(a,b,c,d) \ +a += b; d = ROTL32(d ^ a, 16); \ +c += d; b = ROTL32(b ^ c, 12); \ +a += b; d = ROTL32(d ^ a, 8); \ +c += d; b = ROTL32(b ^ c, 7); + +#ifdef WORDS_BIGENDIAN +#define LE32(p) ((((p) & 0xFF) << 24) | (((p) & 0xFF00) << 8) | (((p) & 0xFF0000) >> 8) | (((p) & 0xFF000000) >> 24)) +#define BE32(p) (p) +#else +#define BE32(p) ((((p) & 0xFF) << 24) | (((p) & 0xFF00) << 8) | (((p) & 0xFF0000) >> 8) | (((p) & 0xFF000000) >> 24)) +#define LE32(p) (p) +#endif + +static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { + size_t n; + size_t over_count = 0; + uint32_t seed32[8]; + uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; + int over1, over2; + + memcpy((void *) seed32, (const void *) seed, 32); + do { + x0 = 0x61707865; + x1 = 0x3320646e; + x2 = 0x79622d32; + x3 = 0x6b206574; + x4 = LE32(seed32[0]); + x5 = LE32(seed32[1]); + x6 = LE32(seed32[2]); + x7 = LE32(seed32[3]); + x8 = LE32(seed32[4]); + x9 = LE32(seed32[5]); + x10 = LE32(seed32[6]); + x11 = LE32(seed32[7]); + x12 = idx; + x13 = idx >> 32; + x14 = 0; + x15 = over_count; + + n = 10; + while (n--) { + QUARTERROUND(x0, x4, x8,x12) + QUARTERROUND(x1, x5, x9,x13) + QUARTERROUND(x2, x6,x10,x14) + QUARTERROUND(x3, x7,x11,x15) + QUARTERROUND(x0, x5,x10,x15) + QUARTERROUND(x1, x6,x11,x12) + QUARTERROUND(x2, x7, x8,x13) + QUARTERROUND(x3, x4, x9,x14) + } + + x0 += 0x61707865; + x1 += 0x3320646e; + x2 += 0x79622d32; + x3 += 0x6b206574; + x4 += LE32(seed32[0]); + x5 += LE32(seed32[1]); + x6 += LE32(seed32[2]); + x7 += LE32(seed32[3]); + x8 += LE32(seed32[4]); + x9 += LE32(seed32[5]); + x10 += LE32(seed32[6]); + x11 += LE32(seed32[7]); + x12 += idx; + x13 += idx >> 32; + x14 += 0; + x15 += over_count; + + r1->d[7] = LE32(x0); + r1->d[6] = LE32(x1); + r1->d[5] = LE32(x2); + r1->d[4] = LE32(x3); + r1->d[3] = LE32(x4); + r1->d[2] = LE32(x5); + r1->d[1] = LE32(x6); + r1->d[0] = LE32(x7); + r2->d[7] = LE32(x8); + r2->d[6] = LE32(x9); + r2->d[5] = LE32(x10); + r2->d[4] = LE32(x11); + r2->d[3] = LE32(x12); + r2->d[2] = LE32(x13); + r2->d[1] = LE32(x14); + r2->d[0] = LE32(x15); + + over1 = secp256k1_scalar_check_overflow(r1); + over2 = secp256k1_scalar_check_overflow(r2); + over_count++; + } while (over1 | over2); +} + +#undef ROTL32 +#undef QUARTERROUND +#undef BE32 +#undef LE32 + +#endif /* SECP256K1_SCALAR_REPR_IMPL_H */ +#endif + diff --git a/src/secp256k1/src/scalar_impl.h b/src/secp256k1/src/scalar_impl.h index fa790570f..494168e53 100644 --- a/src/secp256k1/src/scalar_impl.h +++ b/src/secp256k1/src/scalar_impl.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * @@ -331,3 +333,341 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar #endif #endif /* SECP256K1_SCALAR_IMPL_H */ + + +#else +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_IMPL_H +#define SECP256K1_SCALAR_IMPL_H + +#include "group.h" +#include "scalar.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(EXHAUSTIVE_TEST_ORDER) +#include "scalar_low_impl.h" +#elif defined(USE_SCALAR_4X64) +#include "scalar_4x64_impl.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32_impl.h" +#else +#error "Please select scalar implementation" +#endif + +#ifndef USE_NUM_NONE +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a) { + unsigned char c[32]; + secp256k1_scalar_get_b32(c, a); + secp256k1_num_set_bin(r, c, 32); +} + +/** secp256k1 curve order, see secp256k1_ecdsa_const_order_as_fe in ecdsa_impl.h */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r) { +#if defined(EXHAUSTIVE_TEST_ORDER) + static const unsigned char order[32] = { + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,EXHAUSTIVE_TEST_ORDER + }; +#else + static const unsigned char order[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41 + }; +#endif + secp256k1_num_set_bin(r, order, 32); +} +#endif + +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *x) { +#if defined(EXHAUSTIVE_TEST_ORDER) + int i; + *r = 0; + for (i = 0; i < EXHAUSTIVE_TEST_ORDER; i++) + if ((i * *x) % EXHAUSTIVE_TEST_ORDER == 1) + *r = i; + /* If this VERIFY_CHECK triggers we were given a noninvertible scalar (and thus + * have a composite group order; fix it in exhaustive_tests.c). */ + VERIFY_CHECK(*r != 0); +} +#else +secp256k1_scalar *t; +int i; +/* First compute xN as x ^ (2^N - 1) for some values of N, + * and uM as x ^ M for some values of M. */ +secp256k1_scalar x2, x3, x6, x8, x14, x28, x56, x112, x126; +secp256k1_scalar u2, u5, u9, u11, u13; + +secp256k1_scalar_sqr(&u2, x); +secp256k1_scalar_mul(&x2, &u2, x); +secp256k1_scalar_mul(&u5, &u2, &x2); +secp256k1_scalar_mul(&x3, &u5, &u2); +secp256k1_scalar_mul(&u9, &x3, &u2); +secp256k1_scalar_mul(&u11, &u9, &u2); +secp256k1_scalar_mul(&u13, &u11, &u2); + +secp256k1_scalar_sqr(&x6, &u13); +secp256k1_scalar_sqr(&x6, &x6); +secp256k1_scalar_mul(&x6, &x6, &u11); + +secp256k1_scalar_sqr(&x8, &x6); +secp256k1_scalar_sqr(&x8, &x8); +secp256k1_scalar_mul(&x8, &x8, &x2); + +secp256k1_scalar_sqr(&x14, &x8); +for (i = 0; i < 5; i++) { + secp256k1_scalar_sqr(&x14, &x14); +} +secp256k1_scalar_mul(&x14, &x14, &x6); + +secp256k1_scalar_sqr(&x28, &x14); +for (i = 0; i < 13; i++) { + secp256k1_scalar_sqr(&x28, &x28); +} +secp256k1_scalar_mul(&x28, &x28, &x14); + +secp256k1_scalar_sqr(&x56, &x28); +for (i = 0; i < 27; i++) { + secp256k1_scalar_sqr(&x56, &x56); +} +secp256k1_scalar_mul(&x56, &x56, &x28); + +secp256k1_scalar_sqr(&x112, &x56); +for (i = 0; i < 55; i++) { + secp256k1_scalar_sqr(&x112, &x112); +} +secp256k1_scalar_mul(&x112, &x112, &x56); + +secp256k1_scalar_sqr(&x126, &x112); +for (i = 0; i < 13; i++) { + secp256k1_scalar_sqr(&x126, &x126); +} +secp256k1_scalar_mul(&x126, &x126, &x14); + +/* Then accumulate the final result (t starts at x126). */ +t = &x126; +for (i = 0; i < 3; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u11); /* 1011 */ +for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u11); /* 1011 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 5; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 3; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u9); /* 1001 */ +for (i = 0; i < 6; i++) { /* 000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 10; i++) { /* 0000000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 9; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x8); /* 11111111 */ +for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u9); /* 1001 */ +for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u11); /* 1011 */ +for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 5; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x2); /* 11 */ +for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 10; i++) { /* 000000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u9); /* 1001 */ +for (i = 0; i < 6; i++) { /* 00000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, x); /* 1 */ +for (i = 0; i < 8; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(r, t, &x6); /* 111111 */ +} + +SECP256K1_INLINE static int secp256k1_scalar_is_even(const secp256k1_scalar *a) { + return !(a->d[0] & 1); +} +#endif + +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *x) { +#if defined(USE_SCALAR_INV_BUILTIN) + secp256k1_scalar_inverse(r, x); +#elif defined(USE_SCALAR_INV_NUM) + unsigned char b[32]; + secp256k1_num n, m; + secp256k1_scalar t = *x; + secp256k1_scalar_get_b32(b, &t); + secp256k1_num_set_bin(&n, b, 32); + secp256k1_scalar_order_get_num(&m); + secp256k1_num_mod_inverse(&n, &n, &m); + secp256k1_num_get_bin(b, 32, &n); + secp256k1_scalar_set_b32(r, b, NULL); + /* Verify that the inverse was computed correctly, without GMP code. */ + secp256k1_scalar_mul(&t, &t, r); + CHECK(secp256k1_scalar_is_one(&t)); +#else +#error "Please select scalar inverse implementation" +#endif +} + +#ifdef USE_ENDOMORPHISM +#if defined(EXHAUSTIVE_TEST_ORDER) +/** + * Find k1 and k2 given k, such that k1 + k2 * lambda == k mod n; unlike in the + * full case we don't bother making k1 and k2 be small, we just want them to be + * nontrivial to get full test coverage for the exhaustive tests. We therefore + * (arbitrarily) set k2 = k + 5 and k1 = k - k2 * lambda. + */ +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + *r2 = (*a + 5) % EXHAUSTIVE_TEST_ORDER; + *r1 = (*a + (EXHAUSTIVE_TEST_ORDER - *r2) * EXHAUSTIVE_TEST_LAMBDA) % EXHAUSTIVE_TEST_ORDER; +} +#else +/** + * The Secp256k1 curve has an endomorphism, where lambda * (x, y) = (beta * x, y), where + * lambda is {0x53,0x63,0xad,0x4c,0xc0,0x5c,0x30,0xe0,0xa5,0x26,0x1c,0x02,0x88,0x12,0x64,0x5a, + * 0x12,0x2e,0x22,0xea,0x20,0x81,0x66,0x78,0xdf,0x02,0x96,0x7c,0x1b,0x23,0xbd,0x72} + * + * "Guide to Elliptic Curve Cryptography" (Hankerson, Menezes, Vanstone) gives an algorithm + * (algorithm 3.74) to find k1 and k2 given k, such that k1 + k2 * lambda == k mod n, and k1 + * and k2 have a small size. + * It relies on constants a1, b1, a2, b2. These constants for the value of lambda above are: + * + * - a1 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * - b1 = -{0xe4,0x43,0x7e,0xd6,0x01,0x0e,0x88,0x28,0x6f,0x54,0x7f,0xa9,0x0a,0xbf,0xe4,0xc3} + * - a2 = {0x01,0x14,0xca,0x50,0xf7,0xa8,0xe2,0xf3,0xf6,0x57,0xc1,0x10,0x8d,0x9d,0x44,0xcf,0xd8} + * - b2 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * + * The algorithm then computes c1 = round(b1 * k / n) and c2 = round(b2 * k / n), and gives + * k1 = k - (c1*a1 + c2*a2) and k2 = -(c1*b1 + c2*b2). Instead, we use modular arithmetic, and + * compute k1 as k - k2 * lambda, avoiding the need for constants a1 and a2. + * + * g1, g2 are precomputed constants used to replace division with a rounded multiplication + * when decomposing the scalar for an endomorphism-based point multiplication. + * + * The possibility of using precomputed estimates is mentioned in "Guide to Elliptic Curve + * Cryptography" (Hankerson, Menezes, Vanstone) in section 3.5. + * + * The derivation is described in the paper "Efficient Software Implementation of Public-Key + * Cryptography on Sensor Networks Using the MSP430X Microcontroller" (Gouvea, Oliveira, Lopez), + * Section 4.3 (here we use a somewhat higher-precision estimate): + * d = a1*b2 - b1*a2 + * g1 = round((2^272)*b2/d) + * g2 = round((2^272)*b1/d) + * + * (Note that 'd' is also equal to the curve order here because [a1,b1] and [a2,b2] are found + * as outputs of the Extended Euclidean Algorithm on inputs 'order' and 'lambda'). + * + * The function below splits a in r1 and r2, such that r1 + lambda * r2 == a (mod order). + */ + +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + secp256k1_scalar c1, c2; + static const secp256k1_scalar minus_lambda = SECP256K1_SCALAR_CONST( + 0xAC9C52B3UL, 0x3FA3CF1FUL, 0x5AD9E3FDUL, 0x77ED9BA4UL, + 0xA880B9FCUL, 0x8EC739C2UL, 0xE0CFC810UL, 0xB51283CFUL + ); + static const secp256k1_scalar minus_b1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xE4437ED6UL, 0x010E8828UL, 0x6F547FA9UL, 0x0ABFE4C3UL + ); + static const secp256k1_scalar minus_b2 = SECP256K1_SCALAR_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, + 0x8A280AC5UL, 0x0774346DUL, 0xD765CDA8UL, 0x3DB1562CUL + ); + static const secp256k1_scalar g1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00003086UL, + 0xD221A7D4UL, 0x6BCDE86CUL, 0x90E49284UL, 0xEB153DABUL + ); + static const secp256k1_scalar g2 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0000E443UL, + 0x7ED6010EUL, 0x88286F54UL, 0x7FA90ABFUL, 0xE4C42212UL + ); + VERIFY_CHECK(r1 != a); + VERIFY_CHECK(r2 != a); + /* these _var calls are constant time since the shift amount is constant */ + secp256k1_scalar_mul_shift_var(&c1, a, &g1, 272); + secp256k1_scalar_mul_shift_var(&c2, a, &g2, 272); + secp256k1_scalar_mul(&c1, &c1, &minus_b1); + secp256k1_scalar_mul(&c2, &c2, &minus_b2); + secp256k1_scalar_add(r2, &c1, &c2); + secp256k1_scalar_mul(r1, r2, &minus_lambda); + secp256k1_scalar_add(r1, r1, a); +} +#endif +#endif + +#endif /* SECP256K1_SCALAR_IMPL_H */ +#endif + diff --git a/src/secp256k1/src/scalar_low.h b/src/secp256k1/src/scalar_low.h index 5836febc5..2039aafc7 100644 --- a/src/secp256k1/src/scalar_low.h +++ b/src/secp256k1/src/scalar_low.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * @@ -13,3 +15,21 @@ typedef uint32_t secp256k1_scalar; #endif /* SECP256K1_SCALAR_REPR_H */ + +#else +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_REPR_H +#define SECP256K1_SCALAR_REPR_H + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef uint32_t secp256k1_scalar; + +#endif /* SECP256K1_SCALAR_REPR_H */ +#endif diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index c80e70c5a..99689a4fd 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -1,3 +1,5 @@ +#ifdef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * @@ -112,3 +114,127 @@ SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const } #endif /* SECP256K1_SCALAR_REPR_IMPL_H */ + +#else +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_REPR_IMPL_H +#define SECP256K1_SCALAR_REPR_IMPL_H + +#include "scalar.h" + +#include + +SECP256K1_INLINE static int secp256k1_scalar_is_even(const secp256k1_scalar *a) { + return !(*a & 1); +} + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { *r = 0; } +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { *r = v; } +SECP256K1_INLINE static void secp256k1_scalar_set_u64(secp256k1_scalar *r, uint64_t v) { *r = v % EXHAUSTIVE_TEST_ORDER; } + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + if (offset < 32) + return ((*a >> offset) & ((((uint32_t)1) << count) - 1)); + else + return 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + return secp256k1_scalar_get_bits(a, offset, count); +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { return *a >= EXHAUSTIVE_TEST_ORDER; } + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + *r = (*a + *b) % EXHAUSTIVE_TEST_ORDER; + return *r < *b; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + if (flag && bit < 32) + *r += (1 << bit); +#ifdef VERIFY + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + const int base = 0x100 % EXHAUSTIVE_TEST_ORDER; + int i; + *r = 0; + for (i = 0; i < 32; i++) { + *r = ((*r * base) + b32[i]) % EXHAUSTIVE_TEST_ORDER; + } + /* just deny overflow, it basically always happens */ + if (overflow) *overflow = 0; +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + memset(bin, 0, 32); + bin[28] = *a >> 24; bin[29] = *a >> 16; bin[30] = *a >> 8; bin[31] = *a; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return *a == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + if (*a == 0) { + *r = 0; + } else { + *r = EXHAUSTIVE_TEST_ORDER - *a; + } +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return *a == 1; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + return *a > EXHAUSTIVE_TEST_ORDER / 2; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + if (flag) secp256k1_scalar_negate(r, r); + return flag ? -1 : 1; +} + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + *r = (*a * *b) % EXHAUSTIVE_TEST_ORDER; +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = *r & ((1 << n) - 1); + *r >>= n; + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + *r = (*a * *a) % EXHAUSTIVE_TEST_ORDER; +} + +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + *r1 = *a; + *r2 = 0; +} + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return *a == *b; +} + +SECP256K1_INLINE static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { + *r1 = (seed[0] + n) % EXHAUSTIVE_TEST_ORDER; + *r2 = (seed[1] + n) % EXHAUSTIVE_TEST_ORDER; +} + +#endif /* SECP256K1_SCALAR_REPR_IMPL_H */ +#endif + From cf2a4fb66a2f714b78f9cfc69f28a08cdcd1f603 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 06:36:26 -1100 Subject: [PATCH 2362/3904] AM_CONDITIONAL --- src/secp256k1/configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/src/secp256k1/configure.ac b/src/secp256k1/configure.ac index e5fcbcb4e..4c46f321f 100644 --- a/src/secp256k1/configure.ac +++ b/src/secp256k1/configure.ac @@ -479,6 +479,7 @@ AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"]) AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"]) AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"]) AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"]) +AM_CONDITIONAL([ENABLE_MODULE_MUSIG], [test x"$enable_module_musig" = x"yes"]) AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"]) AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"]) AM_CONDITIONAL([USE_JNI], [test x"$use_jni" == x"yes"]) From a8b89a2d87884db14f7398a29c75164e792fcca8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 06:43:01 -1100 Subject: [PATCH 2363/3904] #include "scratch_impl.h" --- src/secp256k1/Makefile.am | 2 + src/secp256k1/src/scalar.h | 117 ------------------------------- src/secp256k1/src/scalar_4x64.h | 24 ------- src/secp256k1/src/scratch.h | 40 +++++++++++ src/secp256k1/src/scratch_impl.h | 87 +++++++++++++++++++++++ src/secp256k1/src/secp256k1.c | 1 + 6 files changed, 130 insertions(+), 141 deletions(-) create mode 100644 src/secp256k1/src/scratch.h create mode 100644 src/secp256k1/src/scratch_impl.h diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index ff5a2c50c..36d56a9ac 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -42,6 +42,8 @@ noinst_HEADERS += src/field_5x52_asm_impl.h noinst_HEADERS += src/java/org_bitcoin_NativeSecp256k1.h noinst_HEADERS += src/java/org_bitcoin_Secp256k1Context.h noinst_HEADERS += src/util.h +noinst_HEADERS += src/scratch.h +noinst_HEADERS += src/scratch_impl.h noinst_HEADERS += src/testrand.h noinst_HEADERS += src/testrand_impl.h noinst_HEADERS += src/hash.h diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h index 3d972dc84..aa1cc3286 100644 --- a/src/secp256k1/src/scalar.h +++ b/src/secp256k1/src/scalar.h @@ -222,120 +222,3 @@ static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2 #endif /* SECP256K1_SCALAR_H */ #endif - -#else - -/********************************************************************** - * Copyright (c) 2014 Pieter Wuille * - * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* - **********************************************************************/ - -#ifndef SECP256K1_SCALAR_H -#define SECP256K1_SCALAR_H - -#include "num.h" - -#if defined HAVE_CONFIG_H -#include "libsecp256k1-config.h" -#endif - -#if defined(EXHAUSTIVE_TEST_ORDER) -#include "scalar_low.h" -#elif defined(USE_SCALAR_4X64) -#include "scalar_4x64.h" -#elif defined(USE_SCALAR_8X32) -#include "scalar_8x32.h" -#else -#error "Please select scalar implementation" -#endif - -/** Clear a scalar to prevent the leak of sensitive data. */ -static void secp256k1_scalar_clear(secp256k1_scalar *r); - -/** Access bits from a scalar. All requested bits must belong to the same 32-bit limb. */ -static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count); - -/** Access bits from a scalar. Not constant time. */ -static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count); - -/** Set a scalar from a big endian byte array. */ -static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow); - -/** Set a scalar to an unsigned integer. */ -static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v); - -/** Set a scalar to an unsigned 64-bit integer */ -static void secp256k1_scalar_set_u64(secp256k1_scalar *r, uint64_t v); - -/** Convert a scalar to a byte array. */ -static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a); - -/** Add two scalars together (modulo the group order). Returns whether it overflowed. */ -static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); - -/** Conditionally add a power of two to a scalar. The result is not allowed to overflow. */ -static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag); - -/** Multiply two scalars (modulo the group order). */ -static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); - -/** Shift a scalar right by some amount strictly between 0 and 16, returning - * the low bits that were shifted off */ -static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n); - -/** Compute the square of a scalar (modulo the group order). */ -static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a); - -/** Compute the inverse of a scalar (modulo the group order). */ -static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a); - -/** Compute the inverse of a scalar (modulo the group order), without constant-time guarantee. */ -static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a); - -/** Compute the complement of a scalar (modulo the group order). */ -static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a); - -/** Check whether a scalar equals zero. */ -static int secp256k1_scalar_is_zero(const secp256k1_scalar *a); - -/** Check whether a scalar equals one. */ -static int secp256k1_scalar_is_one(const secp256k1_scalar *a); - -/** Check whether a scalar, considered as an nonnegative integer, is even. */ -static int secp256k1_scalar_is_even(const secp256k1_scalar *a); - -/** Check whether a scalar is higher than the group order divided by 2. */ -static int secp256k1_scalar_is_high(const secp256k1_scalar *a); - -/** Conditionally negate a number, in constant time. - * Returns -1 if the number was negated, 1 otherwise */ -static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag); - -#ifndef USE_NUM_NONE -/** Convert a scalar to a number. */ -static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a); - -/** Get the order of the group as a number. */ -static void secp256k1_scalar_order_get_num(secp256k1_num *r); -#endif - -/** Compare two scalars. */ -static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b); - -#ifdef USE_ENDOMORPHISM -/** Find r1 and r2 such that r1+r2*2^128 = a. */ -static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); -/** Find r1 and r2 such that r1+r2*lambda = a, and r1 and r2 are maximum 128 bits long (see secp256k1_gej_mul_lambda). */ -static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); -#endif - -/** Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer. Shift must be at least 256. */ -static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); - -/** Generate two scalars from a 32-byte seed and an integer using the chacha20 stream cipher */ -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); - -#endif /* SECP256K1_SCALAR_H */ -#endif - diff --git a/src/secp256k1/src/scalar_4x64.h b/src/secp256k1/src/scalar_4x64.h index 326afd6b5..1768966cf 100644 --- a/src/secp256k1/src/scalar_4x64.h +++ b/src/secp256k1/src/scalar_4x64.h @@ -42,27 +42,3 @@ typedef struct { #endif /* SECP256K1_SCALAR_REPR_H */ #endif - -#else -/********************************************************************** - * Copyright (c) 2014 Pieter Wuille * - * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* - **********************************************************************/ - -#ifndef SECP256K1_SCALAR_REPR_H -#define SECP256K1_SCALAR_REPR_H - -#include - -/** A scalar modulo the group order of the secp256k1 curve. */ -typedef struct { - uint64_t d[4]; -} secp256k1_scalar; - -#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} - -#endif /* SECP256K1_SCALAR_REPR_H */ -#endif - - diff --git a/src/secp256k1/src/scratch.h b/src/secp256k1/src/scratch.h new file mode 100644 index 000000000..04faa9f0a --- /dev/null +++ b/src/secp256k1/src/scratch.h @@ -0,0 +1,40 @@ +/********************************************************************** + * Copyright (c) 2017 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCRATCH_ +#define _SECP256K1_SCRATCH_ + +#define SECP256K1_SCRATCH_MAX_FRAMES 5 + +/* The typedef is used internally; the struct name is used in the public API + * (where it is exposed as a different typedef) */ +typedef struct secp256k1_scratch_space_struct { + void *data[SECP256K1_SCRATCH_MAX_FRAMES]; + size_t offset[SECP256K1_SCRATCH_MAX_FRAMES]; + size_t frame_size[SECP256K1_SCRATCH_MAX_FRAMES]; + size_t frame; + size_t max_size; + const secp256k1_callback* error_callback; +} secp256k1_scratch; + +static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t max_size); + +static void secp256k1_scratch_destroy(secp256k1_scratch* scratch); + +/** Attempts to allocate a new stack frame with `n` available bytes. Returns 1 on success, 0 on failure */ +static int secp256k1_scratch_allocate_frame(secp256k1_scratch* scratch, size_t n, size_t objects); + +/** Deallocates a stack frame */ +static void secp256k1_scratch_deallocate_frame(secp256k1_scratch* scratch); + +/** Returns the maximum allocation the scratch space will allow */ +static size_t secp256k1_scratch_max_allocation(const secp256k1_scratch* scratch, size_t n_objects); + +/** Returns a pointer into the most recently allocated frame, or NULL if there is insufficient available space */ +static void *secp256k1_scratch_alloc(secp256k1_scratch* scratch, size_t n); + +#endif + diff --git a/src/secp256k1/src/scratch_impl.h b/src/secp256k1/src/scratch_impl.h new file mode 100644 index 000000000..1ce3ff9b0 --- /dev/null +++ b/src/secp256k1/src/scratch_impl.h @@ -0,0 +1,87 @@ +/********************************************************************** + * Copyright (c) 2017 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCRATCH_IMPL_H_ +#define _SECP256K1_SCRATCH_IMPL_H_ + +#include "scratch.h" + +/* Using 16 bytes alignment because common architectures never have alignment + * requirements above 8 for any of the types we care about. In addition we + * leave some room because currently we don't care about a few bytes. + * TODO: Determine this at configure time. */ +#define ALIGNMENT 16 + +static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t max_size) { + secp256k1_scratch* ret = (secp256k1_scratch*)checked_malloc(error_callback, sizeof(*ret)); + if (ret != NULL) { + memset(ret, 0, sizeof(*ret)); + ret->max_size = max_size; + ret->error_callback = error_callback; + } + return ret; +} + +static void secp256k1_scratch_destroy(secp256k1_scratch* scratch) { + if (scratch != NULL) { + VERIFY_CHECK(scratch->frame == 0); + free(scratch); + } +} + +static size_t secp256k1_scratch_max_allocation(const secp256k1_scratch* scratch, size_t objects) { + size_t i = 0; + size_t allocated = 0; + for (i = 0; i < scratch->frame; i++) { + allocated += scratch->frame_size[i]; + } + if (scratch->max_size - allocated <= objects * ALIGNMENT) { + return 0; + } + return scratch->max_size - allocated - objects * ALIGNMENT; +} + +static int secp256k1_scratch_allocate_frame(secp256k1_scratch* scratch, size_t n, size_t objects) { + VERIFY_CHECK(scratch->frame < SECP256K1_SCRATCH_MAX_FRAMES); + + if (n <= secp256k1_scratch_max_allocation(scratch, objects)) { + n += objects * ALIGNMENT; + scratch->data[scratch->frame] = checked_malloc(scratch->error_callback, n); + if (scratch->data[scratch->frame] == NULL) { + return 0; + } + scratch->frame_size[scratch->frame] = n; + scratch->offset[scratch->frame] = 0; + scratch->frame++; + return 1; + } else { + return 0; + } +} + +static void secp256k1_scratch_deallocate_frame(secp256k1_scratch* scratch) { + VERIFY_CHECK(scratch->frame > 0); + scratch->frame -= 1; + free(scratch->data[scratch->frame]); +} + +static void *secp256k1_scratch_alloc(secp256k1_scratch* scratch, size_t size) { + void *ret; + size_t frame = scratch->frame - 1; + size = ((size + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT; + + if (scratch->frame == 0 || size + scratch->offset[frame] > scratch->frame_size[frame]) { + return NULL; + } + ret = (void *) ((unsigned char *) scratch->data[frame] + scratch->offset[frame]); + memset(ret, 0, size); + scratch->offset[frame] += size; + + return ret; +} + +#endif + diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index cecb1550b..b89a7c04a 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -17,6 +17,7 @@ #include "ecdsa_impl.h" #include "eckey_impl.h" #include "hash_impl.h" +#include "scratch_impl.h" #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ From f9482fe0fe5ec7a3f89d1b09f195a5b93ad8218f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 06:45:11 -1100 Subject: [PATCH 2364/3904] ENABLE_MODULE_MUSIG --- src/secp256k1/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 36d56a9ac..84359ddb9 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -148,7 +148,7 @@ endif if USE_ECMULT_STATIC_PRECOMPUTATION CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) -CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function +CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function -DENABLE_MODULE_MUSIG gen_context_OBJECTS = gen_context.o gen_context_BIN = gen_context$(BUILD_EXEEXT) From 20c08245a251ea332cd8ddb7bfcaf42fc93ff181 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 06:47:51 -1100 Subject: [PATCH 2365/3904] Test --- src/secp256k1/src/scalar_4x64_impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index ee75ad51e..192874529 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -2001,5 +2001,6 @@ static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2 #undef LE32 #endif /* SECP256K1_SCALAR_REPR_IMPL_H */ +xxx #endif From 03f15db75cc1c94bb7b5d8897419539b56fc0bb9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 06:59:00 -1100 Subject: [PATCH 2366/3904] -DENABLE_MODULE_MUSIG --- src/secp256k1/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 84359ddb9..d8c03e96b 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -1,5 +1,7 @@ ACLOCAL_AMFLAGS = -I build-aux/m4 +CFLAGS += -DENABLE_MODULE_MUSIG + lib_LTLIBRARIES = libsecp256k1.la if USE_JNI JNI_LIB = libsecp256k1_jni.la @@ -148,7 +150,7 @@ endif if USE_ECMULT_STATIC_PRECOMPUTATION CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) -CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function -DENABLE_MODULE_MUSIG +CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function gen_context_OBJECTS = gen_context.o gen_context_BIN = gen_context$(BUILD_EXEEXT) From 4a3fc65631cece063441797421e0a685acd66133 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:15:31 -1100 Subject: [PATCH 2367/3904] Test --- configure.ac | 2 +- src/secp256k1/Makefile.am | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9a1a75f53..b3863f368 100644 --- a/configure.ac +++ b/configure.ac @@ -960,7 +960,7 @@ PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR" unset PKG_CONFIG_LIBDIR PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP" -ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery" +ac_configure_args="${ac_configure_args} -DENABLE_MODULE_MUSIG --disable-shared --with-pic --with-bignum=no --enable-module-recovery" AC_CONFIG_SUBDIRS([src/secp256k1 src/snark src/univalue src/cryptoconditions]) AC_OUTPUT diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index d8c03e96b..36d56a9ac 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -1,7 +1,5 @@ ACLOCAL_AMFLAGS = -I build-aux/m4 -CFLAGS += -DENABLE_MODULE_MUSIG - lib_LTLIBRARIES = libsecp256k1.la if USE_JNI JNI_LIB = libsecp256k1_jni.la From fbbd542ab8d55ae0a85020410685b8270fb73cc1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:20:34 -1100 Subject: [PATCH 2368/3904] Test --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 53331ee8f..03a34a140 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,7 +67,7 @@ LIBBITCOIN_WALLET=libbitcoin_wallet.a endif $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g -DENABLE_MODULE_MUSIG" LIBSNARK_CXXFLAGS = $(AM_CXXFLAGS) $(PIC_FLAGS) -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1 -fstack-protector-all LIBSNARK_CONFIG_FLAGS = CURVE=ALT_BN128 NO_PROCPS=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT NO_COPY_DEPINST=1 NO_COMPILE_LIBGTEST=1 From e735d1e89cb567bacc01b387223abc7ce39e9a8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:26:23 -1100 Subject: [PATCH 2369/3904] Fixes --- configure.ac | 2 +- src/Makefile.am | 2 +- src/secp256k1/Makefile.am | 2 +- src/secp256k1/configure.ac | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index b3863f368..9a1a75f53 100644 --- a/configure.ac +++ b/configure.ac @@ -960,7 +960,7 @@ PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR" unset PKG_CONFIG_LIBDIR PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP" -ac_configure_args="${ac_configure_args} -DENABLE_MODULE_MUSIG --disable-shared --with-pic --with-bignum=no --enable-module-recovery" +ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery" AC_CONFIG_SUBDIRS([src/secp256k1 src/snark src/univalue src/cryptoconditions]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 03a34a140..53331ee8f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,7 +67,7 @@ LIBBITCOIN_WALLET=libbitcoin_wallet.a endif $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g -DENABLE_MODULE_MUSIG" + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " LIBSNARK_CXXFLAGS = $(AM_CXXFLAGS) $(PIC_FLAGS) -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1 -fstack-protector-all LIBSNARK_CONFIG_FLAGS = CURVE=ALT_BN128 NO_PROCPS=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT NO_COPY_DEPINST=1 NO_COMPILE_LIBGTEST=1 diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 36d56a9ac..5aa22dfd3 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -73,7 +73,7 @@ endif endif libsecp256k1_la_SOURCES = src/secp256k1.c -libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) +libsecp256k1_la_CPPFLAGS = -DENABLE_MODULE_MUSIG -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB) libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c diff --git a/src/secp256k1/configure.ac b/src/secp256k1/configure.ac index 4c46f321f..e5fcbcb4e 100644 --- a/src/secp256k1/configure.ac +++ b/src/secp256k1/configure.ac @@ -479,7 +479,6 @@ AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"]) AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"]) AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"]) AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"]) -AM_CONDITIONAL([ENABLE_MODULE_MUSIG], [test x"$enable_module_musig" = x"yes"]) AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"]) AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"]) AM_CONDITIONAL([USE_JNI], [test x"$use_jni" == x"yes"]) From f238a35805d13220e4c2727524b20dde08702576 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:29:14 -1100 Subject: [PATCH 2370/3904] Includes --- src/secp256k1/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 5aa22dfd3..676415834 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -174,10 +174,10 @@ if ENABLE_MODULE_ECDH include src/modules/ecdh/Makefile.am.include endif -if ENABLE_MODULE_MUSIG +#if ENABLE_MODULE_MUSIG include src/modules/schnorrsig/Makefile.am.include include src/modules/musig/Makefile.am.include -endif +#endif if ENABLE_MODULE_RECOVERY include src/modules/recovery/Makefile.am.include From 00e80034568ba83651160988df86798d6cc9a0fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:32:52 -1100 Subject: [PATCH 2371/3904] Ifndef! --- src/secp256k1/src/ecmult.h | 2 +- src/secp256k1/src/scalar.h | 2 +- src/secp256k1/src/scalar_4x64.h | 2 +- src/secp256k1/src/scalar_4x64_impl.h | 2 +- src/secp256k1/src/scalar_8x32.h | 2 +- src/secp256k1/src/scalar_8x32_impl.h | 2 +- src/secp256k1/src/scalar_impl.h | 2 +- src/secp256k1/src/scalar_low.h | 2 +- src/secp256k1/src/scalar_low_impl.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 7fe619b21..4f12090a7 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h index aa1cc3286..3213d302b 100644 --- a/src/secp256k1/src/scalar.h +++ b/src/secp256k1/src/scalar.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2014 Pieter Wuille * diff --git a/src/secp256k1/src/scalar_4x64.h b/src/secp256k1/src/scalar_4x64.h index 1768966cf..68096f2a9 100644 --- a/src/secp256k1/src/scalar_4x64.h +++ b/src/secp256k1/src/scalar_4x64.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2014 Pieter Wuille * diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index 192874529..a12c80626 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * diff --git a/src/secp256k1/src/scalar_8x32.h b/src/secp256k1/src/scalar_8x32.h index 68a2c0428..8a630ac40 100644 --- a/src/secp256k1/src/scalar_8x32.h +++ b/src/secp256k1/src/scalar_8x32.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2014 Pieter Wuille * diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/src/secp256k1/src/scalar_8x32_impl.h index e1299cbaa..ff7bf5ee4 100644 --- a/src/secp256k1/src/scalar_8x32_impl.h +++ b/src/secp256k1/src/scalar_8x32_impl.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2014 Pieter Wuille * diff --git a/src/secp256k1/src/scalar_impl.h b/src/secp256k1/src/scalar_impl.h index 494168e53..d69a94880 100644 --- a/src/secp256k1/src/scalar_impl.h +++ b/src/secp256k1/src/scalar_impl.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2014 Pieter Wuille * diff --git a/src/secp256k1/src/scalar_low.h b/src/secp256k1/src/scalar_low.h index 2039aafc7..16b167f9c 100644 --- a/src/secp256k1/src/scalar_low.h +++ b/src/secp256k1/src/scalar_low.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index 99689a4fd..c6c65ff5b 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * From 26ed5d691909e90e7473b1ce87118bf67b7546c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:38:31 -1100 Subject: [PATCH 2372/3904] const_imple --- src/secp256k1/src/ecmult_const_impl.h | 264 ++++++++++++++++++++++++++ 1 file changed, 264 insertions(+) diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index 7d7a172b7..d8697e0e9 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -1,3 +1,5 @@ +#ifndef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * @@ -238,3 +240,265 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons } #endif /* SECP256K1_ECMULT_CONST_IMPL_H */ + +#else +/********************************************************************** + * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_ECMULT_CONST_IMPL_H +#define SECP256K1_ECMULT_CONST_IMPL_H + +#include "scalar.h" +#include "group.h" +#include "ecmult_const.h" +#include "ecmult_impl.h" + +/* This is like `ECMULT_TABLE_GET_GE` but is constant time */ +#define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ +int m; \ +int abs_n = (n) * (((n) > 0) * 2 - 1); \ +int idx_n = abs_n / 2; \ +secp256k1_fe neg_y; \ +VERIFY_CHECK(((n) & 1) == 1); \ +VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ +VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ +VERIFY_SETUP(secp256k1_fe_clear(&(r)->x)); \ +VERIFY_SETUP(secp256k1_fe_clear(&(r)->y)); \ +for (m = 0; m < ECMULT_TABLE_SIZE(w); m++) { \ +/* This loop is used to avoid secret data in array indices. See +* the comment in ecmult_gen_impl.h for rationale. */ \ +secp256k1_fe_cmov(&(r)->x, &(pre)[m].x, m == idx_n); \ +secp256k1_fe_cmov(&(r)->y, &(pre)[m].y, m == idx_n); \ +} \ +(r)->infinity = 0; \ +secp256k1_fe_negate(&neg_y, &(r)->y, 1); \ +secp256k1_fe_cmov(&(r)->y, &neg_y, (n) != abs_n); \ +} while(0) + + +/** Convert a number to WNAF notation. + * The number becomes represented by sum(2^{wi} * wnaf[i], i=0..WNAF_SIZE(w)+1) - return_val. + * It has the following guarantees: + * - each wnaf[i] an odd integer between -(1 << w) and (1 << w) + * - each wnaf[i] is nonzero + * - the number of words set is always WNAF_SIZE(w) + 1 + * + * Adapted from `The Width-w NAF Method Provides Small Memory and Fast Elliptic Scalar + * Multiplications Secure against Side Channel Attacks`, Okeya and Tagaki. M. Joye (Ed.) + * CT-RSA 2003, LNCS 2612, pp. 328-443, 2003. Springer-Verlagy Berlin Heidelberg 2003 + * + * Numbers reference steps of `Algorithm SPA-resistant Width-w NAF with Odd Scalar` on pp. 335 + */ +static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w, int size) { + int global_sign; + int skew = 0; + int word = 0; + + /* 1 2 3 */ + int u_last; + int u; + + int flip; + int bit; + secp256k1_scalar neg_s; + int not_neg_one; + /* Note that we cannot handle even numbers by negating them to be odd, as is + * done in other implementations, since if our scalars were specified to have + * width < 256 for performance reasons, their negations would have width 256 + * and we'd lose any performance benefit. Instead, we use a technique from + * Section 4.2 of the Okeya/Tagaki paper, which is to add either 1 (for even) + * or 2 (for odd) to the number we are encoding, returning a skew value indicating + * this, and having the caller compensate after doing the multiplication. + * + * In fact, we _do_ want to negate numbers to minimize their bit-lengths (and in + * particular, to ensure that the outputs from the endomorphism-split fit into + * 128 bits). If we negate, the parity of our number flips, inverting which of + * {1, 2} we want to add to the scalar when ensuring that it's odd. Further + * complicating things, -1 interacts badly with `secp256k1_scalar_cadd_bit` and + * we need to special-case it in this logic. */ + flip = secp256k1_scalar_is_high(&s); + /* We add 1 to even numbers, 2 to odd ones, noting that negation flips parity */ + bit = flip ^ !secp256k1_scalar_is_even(&s); + /* We check for negative one, since adding 2 to it will cause an overflow */ + secp256k1_scalar_negate(&neg_s, &s); + not_neg_one = !secp256k1_scalar_is_one(&neg_s); + secp256k1_scalar_cadd_bit(&s, bit, not_neg_one); + /* If we had negative one, flip == 1, s.d[0] == 0, bit == 1, so caller expects + * that we added two to it and flipped it. In fact for -1 these operations are + * identical. We only flipped, but since skewing is required (in the sense that + * the skew must be 1 or 2, never zero) and flipping is not, we need to change + * our flags to claim that we only skewed. */ + global_sign = secp256k1_scalar_cond_negate(&s, flip); + global_sign *= not_neg_one * 2 - 1; + skew = 1 << bit; + + /* 4 */ + u_last = secp256k1_scalar_shr_int(&s, w); + while (word * w < size) { + int sign; + int even; + + /* 4.1 4.4 */ + u = secp256k1_scalar_shr_int(&s, w); + /* 4.2 */ + even = ((u & 1) == 0); + sign = 2 * (u_last > 0) - 1; + u += sign * even; + u_last -= sign * even * (1 << w); + + /* 4.3, adapted for global sign change */ + wnaf[word++] = u_last * global_sign; + + u_last = u; + } + wnaf[word] = u * global_sign; + + VERIFY_CHECK(secp256k1_scalar_is_zero(&s)); + VERIFY_CHECK(word == WNAF_SIZE_BITS(size, w)); + return skew; +} + +static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *scalar, int size) { + secp256k1_ge pre_a[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_ge tmpa; + secp256k1_fe Z; + + int skew_1; +#ifdef USE_ENDOMORPHISM + secp256k1_ge pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; + int wnaf_lam[1 + WNAF_SIZE(WINDOW_A - 1)]; + int skew_lam; + secp256k1_scalar q_1, q_lam; +#endif + int wnaf_1[1 + WNAF_SIZE(WINDOW_A - 1)]; + + int i; + secp256k1_scalar sc = *scalar; + + /* build wnaf representation for q. */ + int rsize = size; +#ifdef USE_ENDOMORPHISM + if (size > 128) { + rsize = 128; + /* split q into q_1 and q_lam (where q = q_1 + q_lam*lambda, and q_1 and q_lam are ~128 bit) */ + secp256k1_scalar_split_lambda(&q_1, &q_lam, &sc); + skew_1 = secp256k1_wnaf_const(wnaf_1, q_1, WINDOW_A - 1, 128); + skew_lam = secp256k1_wnaf_const(wnaf_lam, q_lam, WINDOW_A - 1, 128); + } else +#endif + { + skew_1 = secp256k1_wnaf_const(wnaf_1, sc, WINDOW_A - 1, size); +#ifdef USE_ENDOMORPHISM + skew_lam = 0; +#endif + } + + /* Calculate odd multiples of a. + * All multiples are brought to the same Z 'denominator', which is stored + * in Z. Due to secp256k1' isomorphism we can do all operations pretending + * that the Z coordinate was 1, use affine addition formulae, and correct + * the Z coordinate of the result once at the end. + */ + secp256k1_gej_set_ge(r, a); + secp256k1_ecmult_odd_multiples_table_globalz_windowa(pre_a, &Z, r); + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_fe_normalize_weak(&pre_a[i].y); + } +#ifdef USE_ENDOMORPHISM + if (size > 128) { + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_ge_mul_lambda(&pre_a_lam[i], &pre_a[i]); + } + } +#endif + + /* first loop iteration (separated out so we can directly set r, rather + * than having it start at infinity, get doubled several times, then have + * its new value added to it) */ + i = wnaf_1[WNAF_SIZE_BITS(rsize, WINDOW_A - 1)]; + VERIFY_CHECK(i != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, i, WINDOW_A); + secp256k1_gej_set_ge(r, &tmpa); +#ifdef USE_ENDOMORPHISM + if (size > 128) { + i = wnaf_lam[WNAF_SIZE_BITS(rsize, WINDOW_A - 1)]; + VERIFY_CHECK(i != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a_lam, i, WINDOW_A); + secp256k1_gej_add_ge(r, r, &tmpa); + } +#endif + /* remaining loop iterations */ + for (i = WNAF_SIZE_BITS(rsize, WINDOW_A - 1) - 1; i >= 0; i--) { + int n; + int j; + for (j = 0; j < WINDOW_A - 1; ++j) { + secp256k1_gej_double_nonzero(r, r, NULL); + } + + n = wnaf_1[i]; + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + VERIFY_CHECK(n != 0); + secp256k1_gej_add_ge(r, r, &tmpa); +#ifdef USE_ENDOMORPHISM + if (size > 128) { + n = wnaf_lam[i]; + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a_lam, n, WINDOW_A); + VERIFY_CHECK(n != 0); + secp256k1_gej_add_ge(r, r, &tmpa); + } +#endif + } + + secp256k1_fe_mul(&r->z, &r->z, &Z); + + { + /* Correct for wNAF skew */ + secp256k1_ge correction = *a; + secp256k1_ge_storage correction_1_stor; +#ifdef USE_ENDOMORPHISM + secp256k1_ge_storage correction_lam_stor; +#endif + secp256k1_ge_storage a2_stor; + secp256k1_gej tmpj; + secp256k1_gej_set_ge(&tmpj, &correction); + secp256k1_gej_double_var(&tmpj, &tmpj, NULL); + secp256k1_ge_set_gej(&correction, &tmpj); + secp256k1_ge_to_storage(&correction_1_stor, a); +#ifdef USE_ENDOMORPHISM + if (size > 128) { + secp256k1_ge_to_storage(&correction_lam_stor, a); + } +#endif + secp256k1_ge_to_storage(&a2_stor, &correction); + + /* For odd numbers this is 2a (so replace it), for even ones a (so no-op) */ + secp256k1_ge_storage_cmov(&correction_1_stor, &a2_stor, skew_1 == 2); +#ifdef USE_ENDOMORPHISM + if (size > 128) { + secp256k1_ge_storage_cmov(&correction_lam_stor, &a2_stor, skew_lam == 2); + } +#endif + + /* Apply the correction */ + secp256k1_ge_from_storage(&correction, &correction_1_stor); + secp256k1_ge_neg(&correction, &correction); + secp256k1_gej_add_ge(r, r, &correction); + +#ifdef USE_ENDOMORPHISM + if (size > 128) { + secp256k1_ge_from_storage(&correction, &correction_lam_stor); + secp256k1_ge_neg(&correction, &correction); + secp256k1_ge_mul_lambda(&correction, &correction); + secp256k1_gej_add_ge(r, r, &correction); + } +#endif + } +} + +#endif /* SECP256K1_ECMULT_CONST_IMPL_H */ + +#endif + From 0765b151fe12438759076262be9fdc5c3b45466d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:44:44 -1100 Subject: [PATCH 2373/3904] ,256 --- .../src/include/secp256k1/src/ecmult_const.h | 24 +++++++++++++++++++ src/secp256k1/src/modules/ecdh/main_impl.h | 2 +- src/secp256k1/src/tests.c | 18 +++++++------- src/secp256k1/src/tests_exhaustive.c | 2 +- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h index 72bf7d758..bdb9ae43a 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h @@ -1,3 +1,5 @@ +#ifndef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * @@ -13,3 +15,25 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q); #endif /* SECP256K1_ECMULT_CONST_H */ + +#else + +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_ECMULT_CONST_H +#define SECP256K1_ECMULT_CONST_H + +#include "scalar.h" +#include "group.h" + +/* Here `bits` should be set to the maximum bitlength of the _absolute value_ of `q`, plus + * one because we internally sometimes add 2 to the number during the WNAF conversion. */ +static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q, int bits); + + +#endif + diff --git a/src/secp256k1/src/modules/ecdh/main_impl.h b/src/secp256k1/src/modules/ecdh/main_impl.h index bd8739eeb..74332ba1d 100644 --- a/src/secp256k1/src/modules/ecdh/main_impl.h +++ b/src/secp256k1/src/modules/ecdh/main_impl.h @@ -30,7 +30,7 @@ int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *result, const se unsigned char y[1]; secp256k1_sha256 sha; - secp256k1_ecmult_const(&res, &pt, &s); + secp256k1_ecmult_const(&res, &pt, &s,256); secp256k1_ge_set_gej(&pt, &res); /* Compute a hash of the point in compressed form * Note we cannot use secp256k1_eckey_pubkey_serialize here since it does not diff --git a/src/secp256k1/src/tests.c b/src/secp256k1/src/tests.c index f307b99d5..345fb0bdf 100644 --- a/src/secp256k1/src/tests.c +++ b/src/secp256k1/src/tests.c @@ -2405,7 +2405,7 @@ void ecmult_const_random_mult(void) { 0xb84e4e1b, 0xfb77e21f, 0x96baae2a, 0x63dec956 ); secp256k1_gej b; - secp256k1_ecmult_const(&b, &a, &xn); + secp256k1_ecmult_const(&b, &a, &xn,256); CHECK(secp256k1_ge_is_valid_var(&a)); ge_equals_gej(&expected_b, &b); @@ -2421,12 +2421,12 @@ void ecmult_const_commutativity(void) { random_scalar_order_test(&a); random_scalar_order_test(&b); - secp256k1_ecmult_const(&res1, &secp256k1_ge_const_g, &a); - secp256k1_ecmult_const(&res2, &secp256k1_ge_const_g, &b); + secp256k1_ecmult_const(&res1, &secp256k1_ge_const_g, &a,256); + secp256k1_ecmult_const(&res2, &secp256k1_ge_const_g, &b,256); secp256k1_ge_set_gej(&mid1, &res1); secp256k1_ge_set_gej(&mid2, &res2); - secp256k1_ecmult_const(&res1, &mid1, &b); - secp256k1_ecmult_const(&res2, &mid2, &a); + secp256k1_ecmult_const(&res1, &mid1, &b,256); + secp256k1_ecmult_const(&res2, &mid2, &a,256); secp256k1_ge_set_gej(&mid1, &res1); secp256k1_ge_set_gej(&mid2, &res2); ge_equals_ge(&mid1, &mid2); @@ -2442,13 +2442,13 @@ void ecmult_const_mult_zero_one(void) { secp256k1_scalar_negate(&negone, &one); random_group_element_test(&point); - secp256k1_ecmult_const(&res1, &point, &zero); + secp256k1_ecmult_const(&res1, &point, &zero,256); secp256k1_ge_set_gej(&res2, &res1); CHECK(secp256k1_ge_is_infinity(&res2)); - secp256k1_ecmult_const(&res1, &point, &one); + secp256k1_ecmult_const(&res1, &point, &one,256); secp256k1_ge_set_gej(&res2, &res1); ge_equals_ge(&res2, &point); - secp256k1_ecmult_const(&res1, &point, &negone); + secp256k1_ecmult_const(&res1, &point, &negone,256); secp256k1_gej_neg(&res1, &res1); secp256k1_ge_set_gej(&res2, &res1); ge_equals_ge(&res2, &point); @@ -2474,7 +2474,7 @@ void ecmult_const_chain_multiply(void) { for (i = 0; i < 100; ++i) { secp256k1_ge tmp; secp256k1_ge_set_gej(&tmp, &point); - secp256k1_ecmult_const(&point, &tmp, &scalar); + secp256k1_ecmult_const(&point, &tmp, &scalar,256); } secp256k1_ge_set_gej(&res, &point); ge_equals_gej(&res, &expected_point); diff --git a/src/secp256k1/src/tests_exhaustive.c b/src/secp256k1/src/tests_exhaustive.c index b040bb073..1e58c3b5f 100644 --- a/src/secp256k1/src/tests_exhaustive.c +++ b/src/secp256k1/src/tests_exhaustive.c @@ -174,7 +174,7 @@ void test_exhaustive_ecmult(const secp256k1_context *ctx, const secp256k1_ge *gr ge_equals_gej(&group[(i * r_log + j) % order], &tmp); if (i > 0) { - secp256k1_ecmult_const(&tmp, &group[i], &ng); + secp256k1_ecmult_const(&tmp, &group[i], &ng,256); ge_equals_gej(&group[(i * j) % order], &tmp); } } From 1be8baf63beed94548f05f6fa59ac020244cc16e Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 19:44:50 +0100 Subject: [PATCH 2374/3904] add ifndef WIN --- src/cc/rogue/cursesd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 202cc4acb..6c295fc94 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -410,11 +410,13 @@ int32_t wgetnstr(WINDOW *win, char *str, int32_t n) // stub return(0); } +#ifndef __MINGW32__ int32_t getch(void) { fprintf(stderr,"unexpected and unsupported call to getch\n"); return(0); } +#endif int32_t md_readchar(void) { From 3fcb317a842cdec6c36dc392a7f28b57f9f89078 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:46:50 -1100 Subject: [PATCH 2375/3904] fix --- src/secp256k1/src/ecmult_const.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/secp256k1/src/ecmult_const.h b/src/secp256k1/src/ecmult_const.h index 72bf7d758..0d32fa389 100644 --- a/src/secp256k1/src/ecmult_const.h +++ b/src/secp256k1/src/ecmult_const.h @@ -1,3 +1,5 @@ +#ifndef ENABLE_MODULE_MUSIG + /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * @@ -13,3 +15,24 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q); #endif /* SECP256K1_ECMULT_CONST_H */ + +#else +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_ECMULT_CONST_H +#define SECP256K1_ECMULT_CONST_H + +#include "scalar.h" +#include "group.h" + +/* Here `bits` should be set to the maximum bitlength of the _absolute value_ of `q`, plus + * one because we internally sometimes add 2 to the number during the WNAF conversion. */ +static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q, int bits); + +#endif /* SECP256K1_ECMULT_CONST_H */ +#endif + From 093421dc4e3143809f9798969e556d262bbb2eac Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:49:06 -1100 Subject: [PATCH 2376/3904] Undo --- src/secp256k1/src/scalar_impl.h | 338 -------------------------------- 1 file changed, 338 deletions(-) diff --git a/src/secp256k1/src/scalar_impl.h b/src/secp256k1/src/scalar_impl.h index d69a94880..dec541aed 100644 --- a/src/secp256k1/src/scalar_impl.h +++ b/src/secp256k1/src/scalar_impl.h @@ -1,4 +1,3 @@ -#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2014 Pieter Wuille * @@ -334,340 +333,3 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar #endif /* SECP256K1_SCALAR_IMPL_H */ - -#else -/********************************************************************** - * Copyright (c) 2014 Pieter Wuille * - * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* - **********************************************************************/ - -#ifndef SECP256K1_SCALAR_IMPL_H -#define SECP256K1_SCALAR_IMPL_H - -#include "group.h" -#include "scalar.h" - -#if defined HAVE_CONFIG_H -#include "libsecp256k1-config.h" -#endif - -#if defined(EXHAUSTIVE_TEST_ORDER) -#include "scalar_low_impl.h" -#elif defined(USE_SCALAR_4X64) -#include "scalar_4x64_impl.h" -#elif defined(USE_SCALAR_8X32) -#include "scalar_8x32_impl.h" -#else -#error "Please select scalar implementation" -#endif - -#ifndef USE_NUM_NONE -static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a) { - unsigned char c[32]; - secp256k1_scalar_get_b32(c, a); - secp256k1_num_set_bin(r, c, 32); -} - -/** secp256k1 curve order, see secp256k1_ecdsa_const_order_as_fe in ecdsa_impl.h */ -static void secp256k1_scalar_order_get_num(secp256k1_num *r) { -#if defined(EXHAUSTIVE_TEST_ORDER) - static const unsigned char order[32] = { - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,EXHAUSTIVE_TEST_ORDER - }; -#else - static const unsigned char order[32] = { - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, - 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, - 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41 - }; -#endif - secp256k1_num_set_bin(r, order, 32); -} -#endif - -static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *x) { -#if defined(EXHAUSTIVE_TEST_ORDER) - int i; - *r = 0; - for (i = 0; i < EXHAUSTIVE_TEST_ORDER; i++) - if ((i * *x) % EXHAUSTIVE_TEST_ORDER == 1) - *r = i; - /* If this VERIFY_CHECK triggers we were given a noninvertible scalar (and thus - * have a composite group order; fix it in exhaustive_tests.c). */ - VERIFY_CHECK(*r != 0); -} -#else -secp256k1_scalar *t; -int i; -/* First compute xN as x ^ (2^N - 1) for some values of N, - * and uM as x ^ M for some values of M. */ -secp256k1_scalar x2, x3, x6, x8, x14, x28, x56, x112, x126; -secp256k1_scalar u2, u5, u9, u11, u13; - -secp256k1_scalar_sqr(&u2, x); -secp256k1_scalar_mul(&x2, &u2, x); -secp256k1_scalar_mul(&u5, &u2, &x2); -secp256k1_scalar_mul(&x3, &u5, &u2); -secp256k1_scalar_mul(&u9, &x3, &u2); -secp256k1_scalar_mul(&u11, &u9, &u2); -secp256k1_scalar_mul(&u13, &u11, &u2); - -secp256k1_scalar_sqr(&x6, &u13); -secp256k1_scalar_sqr(&x6, &x6); -secp256k1_scalar_mul(&x6, &x6, &u11); - -secp256k1_scalar_sqr(&x8, &x6); -secp256k1_scalar_sqr(&x8, &x8); -secp256k1_scalar_mul(&x8, &x8, &x2); - -secp256k1_scalar_sqr(&x14, &x8); -for (i = 0; i < 5; i++) { - secp256k1_scalar_sqr(&x14, &x14); -} -secp256k1_scalar_mul(&x14, &x14, &x6); - -secp256k1_scalar_sqr(&x28, &x14); -for (i = 0; i < 13; i++) { - secp256k1_scalar_sqr(&x28, &x28); -} -secp256k1_scalar_mul(&x28, &x28, &x14); - -secp256k1_scalar_sqr(&x56, &x28); -for (i = 0; i < 27; i++) { - secp256k1_scalar_sqr(&x56, &x56); -} -secp256k1_scalar_mul(&x56, &x56, &x28); - -secp256k1_scalar_sqr(&x112, &x56); -for (i = 0; i < 55; i++) { - secp256k1_scalar_sqr(&x112, &x112); -} -secp256k1_scalar_mul(&x112, &x112, &x56); - -secp256k1_scalar_sqr(&x126, &x112); -for (i = 0; i < 13; i++) { - secp256k1_scalar_sqr(&x126, &x126); -} -secp256k1_scalar_mul(&x126, &x126, &x14); - -/* Then accumulate the final result (t starts at x126). */ -t = &x126; -for (i = 0; i < 3; i++) { - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u5); /* 101 */ -for (i = 0; i < 4; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x3); /* 111 */ -for (i = 0; i < 4; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u5); /* 101 */ -for (i = 0; i < 5; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u11); /* 1011 */ -for (i = 0; i < 4; i++) { - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u11); /* 1011 */ -for (i = 0; i < 4; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x3); /* 111 */ -for (i = 0; i < 5; i++) { /* 00 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x3); /* 111 */ -for (i = 0; i < 6; i++) { /* 00 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u13); /* 1101 */ -for (i = 0; i < 4; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u5); /* 101 */ -for (i = 0; i < 3; i++) { - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x3); /* 111 */ -for (i = 0; i < 5; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u9); /* 1001 */ -for (i = 0; i < 6; i++) { /* 000 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u5); /* 101 */ -for (i = 0; i < 10; i++) { /* 0000000 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x3); /* 111 */ -for (i = 0; i < 4; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x3); /* 111 */ -for (i = 0; i < 9; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x8); /* 11111111 */ -for (i = 0; i < 5; i++) { /* 0 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u9); /* 1001 */ -for (i = 0; i < 6; i++) { /* 00 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u11); /* 1011 */ -for (i = 0; i < 4; i++) { - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u13); /* 1101 */ -for (i = 0; i < 5; i++) { - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &x2); /* 11 */ -for (i = 0; i < 6; i++) { /* 00 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u13); /* 1101 */ -for (i = 0; i < 10; i++) { /* 000000 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u13); /* 1101 */ -for (i = 0; i < 4; i++) { - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, &u9); /* 1001 */ -for (i = 0; i < 6; i++) { /* 00000 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(t, t, x); /* 1 */ -for (i = 0; i < 8; i++) { /* 00 */ - secp256k1_scalar_sqr(t, t); -} -secp256k1_scalar_mul(r, t, &x6); /* 111111 */ -} - -SECP256K1_INLINE static int secp256k1_scalar_is_even(const secp256k1_scalar *a) { - return !(a->d[0] & 1); -} -#endif - -static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *x) { -#if defined(USE_SCALAR_INV_BUILTIN) - secp256k1_scalar_inverse(r, x); -#elif defined(USE_SCALAR_INV_NUM) - unsigned char b[32]; - secp256k1_num n, m; - secp256k1_scalar t = *x; - secp256k1_scalar_get_b32(b, &t); - secp256k1_num_set_bin(&n, b, 32); - secp256k1_scalar_order_get_num(&m); - secp256k1_num_mod_inverse(&n, &n, &m); - secp256k1_num_get_bin(b, 32, &n); - secp256k1_scalar_set_b32(r, b, NULL); - /* Verify that the inverse was computed correctly, without GMP code. */ - secp256k1_scalar_mul(&t, &t, r); - CHECK(secp256k1_scalar_is_one(&t)); -#else -#error "Please select scalar inverse implementation" -#endif -} - -#ifdef USE_ENDOMORPHISM -#if defined(EXHAUSTIVE_TEST_ORDER) -/** - * Find k1 and k2 given k, such that k1 + k2 * lambda == k mod n; unlike in the - * full case we don't bother making k1 and k2 be small, we just want them to be - * nontrivial to get full test coverage for the exhaustive tests. We therefore - * (arbitrarily) set k2 = k + 5 and k1 = k - k2 * lambda. - */ -static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { - *r2 = (*a + 5) % EXHAUSTIVE_TEST_ORDER; - *r1 = (*a + (EXHAUSTIVE_TEST_ORDER - *r2) * EXHAUSTIVE_TEST_LAMBDA) % EXHAUSTIVE_TEST_ORDER; -} -#else -/** - * The Secp256k1 curve has an endomorphism, where lambda * (x, y) = (beta * x, y), where - * lambda is {0x53,0x63,0xad,0x4c,0xc0,0x5c,0x30,0xe0,0xa5,0x26,0x1c,0x02,0x88,0x12,0x64,0x5a, - * 0x12,0x2e,0x22,0xea,0x20,0x81,0x66,0x78,0xdf,0x02,0x96,0x7c,0x1b,0x23,0xbd,0x72} - * - * "Guide to Elliptic Curve Cryptography" (Hankerson, Menezes, Vanstone) gives an algorithm - * (algorithm 3.74) to find k1 and k2 given k, such that k1 + k2 * lambda == k mod n, and k1 - * and k2 have a small size. - * It relies on constants a1, b1, a2, b2. These constants for the value of lambda above are: - * - * - a1 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} - * - b1 = -{0xe4,0x43,0x7e,0xd6,0x01,0x0e,0x88,0x28,0x6f,0x54,0x7f,0xa9,0x0a,0xbf,0xe4,0xc3} - * - a2 = {0x01,0x14,0xca,0x50,0xf7,0xa8,0xe2,0xf3,0xf6,0x57,0xc1,0x10,0x8d,0x9d,0x44,0xcf,0xd8} - * - b2 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} - * - * The algorithm then computes c1 = round(b1 * k / n) and c2 = round(b2 * k / n), and gives - * k1 = k - (c1*a1 + c2*a2) and k2 = -(c1*b1 + c2*b2). Instead, we use modular arithmetic, and - * compute k1 as k - k2 * lambda, avoiding the need for constants a1 and a2. - * - * g1, g2 are precomputed constants used to replace division with a rounded multiplication - * when decomposing the scalar for an endomorphism-based point multiplication. - * - * The possibility of using precomputed estimates is mentioned in "Guide to Elliptic Curve - * Cryptography" (Hankerson, Menezes, Vanstone) in section 3.5. - * - * The derivation is described in the paper "Efficient Software Implementation of Public-Key - * Cryptography on Sensor Networks Using the MSP430X Microcontroller" (Gouvea, Oliveira, Lopez), - * Section 4.3 (here we use a somewhat higher-precision estimate): - * d = a1*b2 - b1*a2 - * g1 = round((2^272)*b2/d) - * g2 = round((2^272)*b1/d) - * - * (Note that 'd' is also equal to the curve order here because [a1,b1] and [a2,b2] are found - * as outputs of the Extended Euclidean Algorithm on inputs 'order' and 'lambda'). - * - * The function below splits a in r1 and r2, such that r1 + lambda * r2 == a (mod order). - */ - -static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { - secp256k1_scalar c1, c2; - static const secp256k1_scalar minus_lambda = SECP256K1_SCALAR_CONST( - 0xAC9C52B3UL, 0x3FA3CF1FUL, 0x5AD9E3FDUL, 0x77ED9BA4UL, - 0xA880B9FCUL, 0x8EC739C2UL, 0xE0CFC810UL, 0xB51283CFUL - ); - static const secp256k1_scalar minus_b1 = SECP256K1_SCALAR_CONST( - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0xE4437ED6UL, 0x010E8828UL, 0x6F547FA9UL, 0x0ABFE4C3UL - ); - static const secp256k1_scalar minus_b2 = SECP256K1_SCALAR_CONST( - 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, - 0x8A280AC5UL, 0x0774346DUL, 0xD765CDA8UL, 0x3DB1562CUL - ); - static const secp256k1_scalar g1 = SECP256K1_SCALAR_CONST( - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00003086UL, - 0xD221A7D4UL, 0x6BCDE86CUL, 0x90E49284UL, 0xEB153DABUL - ); - static const secp256k1_scalar g2 = SECP256K1_SCALAR_CONST( - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0000E443UL, - 0x7ED6010EUL, 0x88286F54UL, 0x7FA90ABFUL, 0xE4C42212UL - ); - VERIFY_CHECK(r1 != a); - VERIFY_CHECK(r2 != a); - /* these _var calls are constant time since the shift amount is constant */ - secp256k1_scalar_mul_shift_var(&c1, a, &g1, 272); - secp256k1_scalar_mul_shift_var(&c2, a, &g2, 272); - secp256k1_scalar_mul(&c1, &c1, &minus_b1); - secp256k1_scalar_mul(&c2, &c2, &minus_b2); - secp256k1_scalar_add(r2, &c1, &c2); - secp256k1_scalar_mul(r1, r2, &minus_lambda); - secp256k1_scalar_add(r1, r1, a); -} -#endif -#endif - -#endif /* SECP256K1_SCALAR_IMPL_H */ -#endif - From 56837e817483890243612313293ec76a809f2627 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:52:56 -1100 Subject: [PATCH 2377/3904] -xxx --- src/secp256k1/src/scalar_4x64_impl.h | 2 +- src/secp256k1/src/scalar_impl.h | 338 +++++++++++++++++++++++++++ 2 files changed, 339 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index a12c80626..b1b62ac1f 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -2001,6 +2001,6 @@ static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2 #undef LE32 #endif /* SECP256K1_SCALAR_REPR_IMPL_H */ -xxx + #endif diff --git a/src/secp256k1/src/scalar_impl.h b/src/secp256k1/src/scalar_impl.h index dec541aed..d69a94880 100644 --- a/src/secp256k1/src/scalar_impl.h +++ b/src/secp256k1/src/scalar_impl.h @@ -1,3 +1,4 @@ +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** * Copyright (c) 2014 Pieter Wuille * @@ -333,3 +334,340 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar #endif /* SECP256K1_SCALAR_IMPL_H */ + +#else +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_SCALAR_IMPL_H +#define SECP256K1_SCALAR_IMPL_H + +#include "group.h" +#include "scalar.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(EXHAUSTIVE_TEST_ORDER) +#include "scalar_low_impl.h" +#elif defined(USE_SCALAR_4X64) +#include "scalar_4x64_impl.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32_impl.h" +#else +#error "Please select scalar implementation" +#endif + +#ifndef USE_NUM_NONE +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a) { + unsigned char c[32]; + secp256k1_scalar_get_b32(c, a); + secp256k1_num_set_bin(r, c, 32); +} + +/** secp256k1 curve order, see secp256k1_ecdsa_const_order_as_fe in ecdsa_impl.h */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r) { +#if defined(EXHAUSTIVE_TEST_ORDER) + static const unsigned char order[32] = { + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,EXHAUSTIVE_TEST_ORDER + }; +#else + static const unsigned char order[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41 + }; +#endif + secp256k1_num_set_bin(r, order, 32); +} +#endif + +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *x) { +#if defined(EXHAUSTIVE_TEST_ORDER) + int i; + *r = 0; + for (i = 0; i < EXHAUSTIVE_TEST_ORDER; i++) + if ((i * *x) % EXHAUSTIVE_TEST_ORDER == 1) + *r = i; + /* If this VERIFY_CHECK triggers we were given a noninvertible scalar (and thus + * have a composite group order; fix it in exhaustive_tests.c). */ + VERIFY_CHECK(*r != 0); +} +#else +secp256k1_scalar *t; +int i; +/* First compute xN as x ^ (2^N - 1) for some values of N, + * and uM as x ^ M for some values of M. */ +secp256k1_scalar x2, x3, x6, x8, x14, x28, x56, x112, x126; +secp256k1_scalar u2, u5, u9, u11, u13; + +secp256k1_scalar_sqr(&u2, x); +secp256k1_scalar_mul(&x2, &u2, x); +secp256k1_scalar_mul(&u5, &u2, &x2); +secp256k1_scalar_mul(&x3, &u5, &u2); +secp256k1_scalar_mul(&u9, &x3, &u2); +secp256k1_scalar_mul(&u11, &u9, &u2); +secp256k1_scalar_mul(&u13, &u11, &u2); + +secp256k1_scalar_sqr(&x6, &u13); +secp256k1_scalar_sqr(&x6, &x6); +secp256k1_scalar_mul(&x6, &x6, &u11); + +secp256k1_scalar_sqr(&x8, &x6); +secp256k1_scalar_sqr(&x8, &x8); +secp256k1_scalar_mul(&x8, &x8, &x2); + +secp256k1_scalar_sqr(&x14, &x8); +for (i = 0; i < 5; i++) { + secp256k1_scalar_sqr(&x14, &x14); +} +secp256k1_scalar_mul(&x14, &x14, &x6); + +secp256k1_scalar_sqr(&x28, &x14); +for (i = 0; i < 13; i++) { + secp256k1_scalar_sqr(&x28, &x28); +} +secp256k1_scalar_mul(&x28, &x28, &x14); + +secp256k1_scalar_sqr(&x56, &x28); +for (i = 0; i < 27; i++) { + secp256k1_scalar_sqr(&x56, &x56); +} +secp256k1_scalar_mul(&x56, &x56, &x28); + +secp256k1_scalar_sqr(&x112, &x56); +for (i = 0; i < 55; i++) { + secp256k1_scalar_sqr(&x112, &x112); +} +secp256k1_scalar_mul(&x112, &x112, &x56); + +secp256k1_scalar_sqr(&x126, &x112); +for (i = 0; i < 13; i++) { + secp256k1_scalar_sqr(&x126, &x126); +} +secp256k1_scalar_mul(&x126, &x126, &x14); + +/* Then accumulate the final result (t starts at x126). */ +t = &x126; +for (i = 0; i < 3; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u11); /* 1011 */ +for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u11); /* 1011 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 5; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 3; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u9); /* 1001 */ +for (i = 0; i < 6; i++) { /* 000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u5); /* 101 */ +for (i = 0; i < 10; i++) { /* 0000000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x3); /* 111 */ +for (i = 0; i < 9; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x8); /* 11111111 */ +for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u9); /* 1001 */ +for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u11); /* 1011 */ +for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 5; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &x2); /* 11 */ +for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 10; i++) { /* 000000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u13); /* 1101 */ +for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, &u9); /* 1001 */ +for (i = 0; i < 6; i++) { /* 00000 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(t, t, x); /* 1 */ +for (i = 0; i < 8; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); +} +secp256k1_scalar_mul(r, t, &x6); /* 111111 */ +} + +SECP256K1_INLINE static int secp256k1_scalar_is_even(const secp256k1_scalar *a) { + return !(a->d[0] & 1); +} +#endif + +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *x) { +#if defined(USE_SCALAR_INV_BUILTIN) + secp256k1_scalar_inverse(r, x); +#elif defined(USE_SCALAR_INV_NUM) + unsigned char b[32]; + secp256k1_num n, m; + secp256k1_scalar t = *x; + secp256k1_scalar_get_b32(b, &t); + secp256k1_num_set_bin(&n, b, 32); + secp256k1_scalar_order_get_num(&m); + secp256k1_num_mod_inverse(&n, &n, &m); + secp256k1_num_get_bin(b, 32, &n); + secp256k1_scalar_set_b32(r, b, NULL); + /* Verify that the inverse was computed correctly, without GMP code. */ + secp256k1_scalar_mul(&t, &t, r); + CHECK(secp256k1_scalar_is_one(&t)); +#else +#error "Please select scalar inverse implementation" +#endif +} + +#ifdef USE_ENDOMORPHISM +#if defined(EXHAUSTIVE_TEST_ORDER) +/** + * Find k1 and k2 given k, such that k1 + k2 * lambda == k mod n; unlike in the + * full case we don't bother making k1 and k2 be small, we just want them to be + * nontrivial to get full test coverage for the exhaustive tests. We therefore + * (arbitrarily) set k2 = k + 5 and k1 = k - k2 * lambda. + */ +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + *r2 = (*a + 5) % EXHAUSTIVE_TEST_ORDER; + *r1 = (*a + (EXHAUSTIVE_TEST_ORDER - *r2) * EXHAUSTIVE_TEST_LAMBDA) % EXHAUSTIVE_TEST_ORDER; +} +#else +/** + * The Secp256k1 curve has an endomorphism, where lambda * (x, y) = (beta * x, y), where + * lambda is {0x53,0x63,0xad,0x4c,0xc0,0x5c,0x30,0xe0,0xa5,0x26,0x1c,0x02,0x88,0x12,0x64,0x5a, + * 0x12,0x2e,0x22,0xea,0x20,0x81,0x66,0x78,0xdf,0x02,0x96,0x7c,0x1b,0x23,0xbd,0x72} + * + * "Guide to Elliptic Curve Cryptography" (Hankerson, Menezes, Vanstone) gives an algorithm + * (algorithm 3.74) to find k1 and k2 given k, such that k1 + k2 * lambda == k mod n, and k1 + * and k2 have a small size. + * It relies on constants a1, b1, a2, b2. These constants for the value of lambda above are: + * + * - a1 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * - b1 = -{0xe4,0x43,0x7e,0xd6,0x01,0x0e,0x88,0x28,0x6f,0x54,0x7f,0xa9,0x0a,0xbf,0xe4,0xc3} + * - a2 = {0x01,0x14,0xca,0x50,0xf7,0xa8,0xe2,0xf3,0xf6,0x57,0xc1,0x10,0x8d,0x9d,0x44,0xcf,0xd8} + * - b2 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * + * The algorithm then computes c1 = round(b1 * k / n) and c2 = round(b2 * k / n), and gives + * k1 = k - (c1*a1 + c2*a2) and k2 = -(c1*b1 + c2*b2). Instead, we use modular arithmetic, and + * compute k1 as k - k2 * lambda, avoiding the need for constants a1 and a2. + * + * g1, g2 are precomputed constants used to replace division with a rounded multiplication + * when decomposing the scalar for an endomorphism-based point multiplication. + * + * The possibility of using precomputed estimates is mentioned in "Guide to Elliptic Curve + * Cryptography" (Hankerson, Menezes, Vanstone) in section 3.5. + * + * The derivation is described in the paper "Efficient Software Implementation of Public-Key + * Cryptography on Sensor Networks Using the MSP430X Microcontroller" (Gouvea, Oliveira, Lopez), + * Section 4.3 (here we use a somewhat higher-precision estimate): + * d = a1*b2 - b1*a2 + * g1 = round((2^272)*b2/d) + * g2 = round((2^272)*b1/d) + * + * (Note that 'd' is also equal to the curve order here because [a1,b1] and [a2,b2] are found + * as outputs of the Extended Euclidean Algorithm on inputs 'order' and 'lambda'). + * + * The function below splits a in r1 and r2, such that r1 + lambda * r2 == a (mod order). + */ + +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + secp256k1_scalar c1, c2; + static const secp256k1_scalar minus_lambda = SECP256K1_SCALAR_CONST( + 0xAC9C52B3UL, 0x3FA3CF1FUL, 0x5AD9E3FDUL, 0x77ED9BA4UL, + 0xA880B9FCUL, 0x8EC739C2UL, 0xE0CFC810UL, 0xB51283CFUL + ); + static const secp256k1_scalar minus_b1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xE4437ED6UL, 0x010E8828UL, 0x6F547FA9UL, 0x0ABFE4C3UL + ); + static const secp256k1_scalar minus_b2 = SECP256K1_SCALAR_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, + 0x8A280AC5UL, 0x0774346DUL, 0xD765CDA8UL, 0x3DB1562CUL + ); + static const secp256k1_scalar g1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00003086UL, + 0xD221A7D4UL, 0x6BCDE86CUL, 0x90E49284UL, 0xEB153DABUL + ); + static const secp256k1_scalar g2 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0000E443UL, + 0x7ED6010EUL, 0x88286F54UL, 0x7FA90ABFUL, 0xE4C42212UL + ); + VERIFY_CHECK(r1 != a); + VERIFY_CHECK(r2 != a); + /* these _var calls are constant time since the shift amount is constant */ + secp256k1_scalar_mul_shift_var(&c1, a, &g1, 272); + secp256k1_scalar_mul_shift_var(&c2, a, &g2, 272); + secp256k1_scalar_mul(&c1, &c1, &minus_b1); + secp256k1_scalar_mul(&c2, &c2, &minus_b2); + secp256k1_scalar_add(r2, &c1, &c2); + secp256k1_scalar_mul(r1, r2, &minus_lambda); + secp256k1_scalar_add(r1, r1, a); +} +#endif +#endif + +#endif /* SECP256K1_SCALAR_IMPL_H */ +#endif + From 4a4e2f0bdd0c20eb653305cf91d1eee68fa5e341 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 19:54:03 +0100 Subject: [PATCH 2378/3904] add mingw32 ncurses this is a test with mingw32 crossbuilt ncurses release from the original ncurses dev --- src/cc/Makefile_rogue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 45efdc803..ddaf392a3 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -9,6 +9,7 @@ DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) OS := $(shell uname -s) +DIR := ${CURDIR} $(info $(OS)) TARGET = librogue.so TARGET_DARWIN = librogue.dylib @@ -25,6 +26,9 @@ ifeq ($(OS),Darwin) cp $(TARGET_DARWIN) ../libcc.dylib else ifeq ($(HOST),x86_64-w64-mingw32) $(info WINDOWS) + wget -O ../../depends/x86_64-w64-mingw32/mingw64.zip https://invisible-island.net/datafiles/release/mingw32.zip + cd ../../depends/x86_64-w64-mingw32 && unzip mingw32.zip + cd $(DIR) $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) -lncurses cp $(TARGET_WIN) ../libcc.dll #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host From 380b4f61582ae61faaf8e3f15561703537f6d7ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 07:58:23 -1100 Subject: [PATCH 2379/3904] Sudoku est --- src/cc/sudoku.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 7571d22e4..2d1b4477c 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -3049,3 +3049,8 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return eval->Invalid("not enough vouts"); } +#include +#include +#include + + From 5448b0af3481609b8eaec481380b72fb9faca0b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 08:02:35 -1100 Subject: [PATCH 2380/3904] Create includes --- src/secp256k1/include/secp256k1_musig.h | 432 +++++++++++++++++++ src/secp256k1/include/secp256k1_schnorrsig.h | 119 +++++ 2 files changed, 551 insertions(+) create mode 100644 src/secp256k1/include/secp256k1_musig.h create mode 100644 src/secp256k1/include/secp256k1_schnorrsig.h diff --git a/src/secp256k1/include/secp256k1_musig.h b/src/secp256k1/include/secp256k1_musig.h new file mode 100644 index 000000000..5796f677f --- /dev/null +++ b/src/secp256k1/include/secp256k1_musig.h @@ -0,0 +1,432 @@ +#ifndef SECP256K1_MUSIG_H +#define SECP256K1_MUSIG_H + +#include + +/** This module implements a Schnorr-based multi-signature scheme called MuSig + * (https://eprint.iacr.org/2018/068.pdf). There's an example C source file in the + * module's directory (src/modules/musig/example.c) that demonstrates how it can be + * used. + */ + +/** Data structure containing data related to a signing session resulting in a single + * signature. + * + * This structure is not opaque, but it MUST NOT be copied or read or written to it + * directly. A signer who is online throughout the whole process and can keep this + * structure in memory can use the provided API functions for a safe standard + * workflow. + * + * A signer who goes offline and needs to import/export or save/load this structure + * **must** take measures prevent replay attacks wherein an old state is loaded and + * the signing protocol forked from that point. One straightforward way to accomplish + * this is to attach the output of a monotonic non-resettable counter (hardware + * support is needed for this). Increment the counter before each output and + * encrypt+sign the entire package. If a package is deserialized with an old counter + * state or bad signature it should be rejected. + * + * Observe that an independent counter is needed for each concurrent signing session + * such a device is involved in. To avoid fragility, it is therefore recommended that + * any offline signer be usable for only a single session at once. + * + * Given access to such a counter, its output should be used as (or mixed into) the + * session ID to ensure uniqueness. + * + * Fields: + * combined_pk: MuSig-computed combined public key + * n_signers: Number of signers + * pk_hash: The 32-byte hash of the original public keys + * combined_nonce: Summed combined public nonce (undefined if `nonce_is_set` is false) + * nonce_is_set: Whether the above nonce has been set + * nonce_is_negated: If `nonce_is_set`, whether the above nonce was negated after + * summing the participants' nonces. Needed to ensure the nonce's y + * coordinate has a quadratic-residue y coordinate + * msg: The 32-byte message (hash) to be signed + * msg_is_set: Whether the above message has been set + * has_secret_data: Whether this session object has a signers' secret data; if this + * is `false`, it may still be used for verification purposes. + * seckey: If `has_secret_data`, the signer's secret key + * secnonce: If `has_secret_data`, the signer's secret nonce + * nonce: If `has_secret_data`, the signer's public nonce + * nonce_commitments_hash: If `has_secret_data` and `nonce_commitments_hash_is_set`, + * the hash of all signers' commitments + * nonce_commitments_hash_is_set: If `has_secret_data`, whether the + * nonce_commitments_hash has been set + */ +typedef struct { + secp256k1_pubkey combined_pk; + uint32_t n_signers; + unsigned char pk_hash[32]; + secp256k1_pubkey combined_nonce; + int nonce_is_set; + int nonce_is_negated; + unsigned char msg[32]; + int msg_is_set; + int has_secret_data; + unsigned char seckey[32]; + unsigned char secnonce[32]; + secp256k1_pubkey nonce; + unsigned char nonce_commitments_hash[32]; + int nonce_commitments_hash_is_set; +} secp256k1_musig_session; + +/** Data structure containing data on all signers in a single session. + * + * The workflow for this structure is as follows: + * + * 1. This structure is initialized with `musig_session_initialize` or + * `musig_session_initialize_verifier`, which set the `index` field, and zero out + * all other fields. The public session is initialized with the signers' + * nonce_commitments. + * + * 2. In a non-public session the nonce_commitments are set with the function + * `musig_get_public_nonce`, which also returns the signer's public nonce. This + * ensures that the public nonce is not exposed until all commitments have been + * received. + * + * 3. Each individual data struct should be updated with `musig_set_nonce` once a + * nonce is available. This function takes a single signer data struct rather than + * an array because it may fail in the case that the provided nonce does not match + * the commitment. In this case, it is desirable to identify the exact party whose + * nonce was inconsistent. + * + * Fields: + * present: indicates whether the signer's nonce is set + * index: index of the signer in the MuSig key aggregation + * nonce: public nonce, must be a valid curvepoint if the signer is `present` + * nonce_commitment: commitment to the nonce, or all-bits zero if a commitment + * has not yet been set + */ +typedef struct { + int present; + uint32_t index; + secp256k1_pubkey nonce; + unsigned char nonce_commitment[32]; +} secp256k1_musig_session_signer_data; + +/** Opaque data structure that holds a MuSig partial signature. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is however + * guaranteed to be 32 bytes in size, and can be safely copied/moved. If you need + * to convert to a format suitable for storage, transmission, or comparison, use the + * `musig_partial_signature_serialize` and `musig_partial_signature_parse` + * functions. + */ +typedef struct { + unsigned char data[32]; +} secp256k1_musig_partial_signature; + +/** Computes a combined public key and the hash of the given public keys + * + * Returns: 1 if the public keys were successfully combined, 0 otherwise + * Args: ctx: pointer to a context object initialized for verification + * (cannot be NULL) + * scratch: scratch space used to compute the combined pubkey by + * multiexponentiation. If NULL, an inefficient algorithm is used. + * Out: combined_pk: the MuSig-combined public key (cannot be NULL) + * pk_hash32: if non-NULL, filled with the 32-byte hash of all input public + * keys in order to be used in `musig_session_initialize`. + * In: pubkeys: input array of public keys to combine. The order is important; + * a different order will result in a different combined public + * key (cannot be NULL) + * n_pubkeys: length of pubkeys array + */ +SECP256K1_API int secp256k1_musig_pubkey_combine( + const secp256k1_context* ctx, + secp256k1_scratch_space *scratch, + secp256k1_pubkey *combined_pk, + unsigned char *pk_hash32, + const secp256k1_pubkey *pubkeys, + size_t n_pubkeys +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5); + +/** Initializes a signing session for a signer + * + * Returns: 1: session is successfully initialized + * 0: session could not be initialized: secret key or secret nonce overflow + * Args: ctx: pointer to a context object, initialized for signing (cannot + * be NULL) + * Out: session: the session structure to initialize (cannot be NULL) + * signers: an array of signers' data to be initialized. Array length must + * equal to `n_signers` (cannot be NULL) + * nonce_commitment32: filled with a 32-byte commitment to the generated nonce + * (cannot be NULL) + * In: session_id32: a *unique* 32-byte ID to assign to this session (cannot be + * NULL). If a non-unique session_id32 was given then a partial + * signature will LEAK THE SECRET KEY. + * msg32: the 32-byte message to be signed. Shouldn't be NULL unless you + * require sharing public nonces before the message is known + * because it reduces nonce misuse resistance. If NULL, must be + * set with `musig_session_set_msg` before signing and verifying. + * combined_pk: the combined public key of all signers (cannot be NULL) + * pk_hash32: the 32-byte hash of the signers' individual keys (cannot be + * NULL) + * n_signers: length of signers array. Number of signers participating in + * the MuSig. Must be greater than 0 and at most 2^32 - 1. + * my_index: index of this signer in the signers array + * seckey: the signer's 32-byte secret key (cannot be NULL) + */ +SECP256K1_API int secp256k1_musig_session_initialize( + const secp256k1_context* ctx, + secp256k1_musig_session *session, + secp256k1_musig_session_signer_data *signers, + unsigned char *nonce_commitment32, + const unsigned char *session_id32, + const unsigned char *msg32, + const secp256k1_pubkey *combined_pk, + const unsigned char *pk_hash32, + size_t n_signers, + size_t my_index, + const unsigned char *seckey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(7) SECP256K1_ARG_NONNULL(8) SECP256K1_ARG_NONNULL(11); + +/** Gets the signer's public nonce given a list of all signers' data with commitments + * + * Returns: 1: public nonce is written in nonce + * 0: signer data is missing commitments or session isn't initialized + * for signing + * Args: ctx: pointer to a context object (cannot be NULL) + * session: the signing session to get the nonce from (cannot be NULL) + * signers: an array of signers' data initialized with + * `musig_session_initialize`. Array length must equal to + * `n_commitments` (cannot be NULL) + * Out: nonce: the nonce (cannot be NULL) + * In: commitments: array of 32-byte nonce commitments (cannot be NULL) + * n_commitments: the length of commitments and signers array. Must be the total + * number of signers participating in the MuSig. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_get_public_nonce( + const secp256k1_context* ctx, + secp256k1_musig_session *session, + secp256k1_musig_session_signer_data *signers, + secp256k1_pubkey *nonce, + const unsigned char *const *commitments, + size_t n_commitments +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5); + +/** Initializes a verifier session that can be used for verifying nonce commitments + * and partial signatures. It does not have secret key material and therefore can not + * be used to create signatures. + * + * Returns: 1 when session is successfully initialized, 0 otherwise + * Args: ctx: pointer to a context object (cannot be NULL) + * Out: session: the session structure to initialize (cannot be NULL) + * signers: an array of signers' data to be initialized. Array length must + * equal to `n_signers`(cannot be NULL) + * In: msg32: the 32-byte message to be signed If NULL, must be set with + * `musig_session_set_msg` before using the session for verifying + * partial signatures. + * combined_pk: the combined public key of all signers (cannot be NULL) + * pk_hash32: the 32-byte hash of the signers' individual keys (cannot be NULL) + * commitments: array of 32-byte nonce commitments. Array length must equal to + * `n_signers` (cannot be NULL) + * n_signers: length of signers and commitments array. Number of signers + * participating in the MuSig. Must be greater than 0 and at most + * 2^32 - 1. + */ +SECP256K1_API int secp256k1_musig_session_initialize_verifier( + const secp256k1_context* ctx, + secp256k1_musig_session *session, + secp256k1_musig_session_signer_data *signers, + const unsigned char *msg32, + const secp256k1_pubkey *combined_pk, + const unsigned char *pk_hash32, + const unsigned char *const *commitments, + size_t n_signers +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(6) SECP256K1_ARG_NONNULL(7); + +/** Checks a signer's public nonce against a commitment to said nonce, and update + * data structure if they match + * + * Returns: 1: commitment was valid, data structure updated + * 0: commitment was invalid, nothing happened + * Args: ctx: pointer to a context object (cannot be NULL) + * signer: pointer to the signer data to update (cannot be NULL). Must have + * been used with `musig_session_get_public_nonce` or initialized + * with `musig_session_initialize_verifier`. + * In: nonce: signer's alleged public nonce (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_set_nonce( + const secp256k1_context* ctx, + secp256k1_musig_session_signer_data *signer, + const secp256k1_pubkey *nonce +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Updates a session with the combined public nonce of all signers. The combined + * public nonce is the sum of every signer's public nonce. + * + * Returns: 1: nonces are successfully combined + * 0: a signer's nonce is missing + * Args: ctx: pointer to a context object (cannot be NULL) + * session: session to update with the combined public nonce (cannot be + * NULL) + * signers: an array of signers' data, which must have had public nonces + * set with `musig_set_nonce`. Array length must equal to `n_signers` + * (cannot be NULL) + * n_signers: the length of the signers array. Must be the total number of + * signers participating in the MuSig. + * Out: nonce_is_negated: a pointer to an integer that indicates if the combined + * public nonce had to be negated. + * adaptor: point to add to the combined public nonce. If NULL, nothing is + * added to the combined nonce. + */ +SECP256K1_API int secp256k1_musig_session_combine_nonces( + const secp256k1_context* ctx, + secp256k1_musig_session *session, + const secp256k1_musig_session_signer_data *signers, + size_t n_signers, + int *nonce_is_negated, + const secp256k1_pubkey *adaptor +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4); + +/** Sets the message of a session if previously unset + * + * Returns 1 if the message was not set yet and is now successfully set + * 0 otherwise + * Args: ctx: pointer to a context object (cannot be NULL) + * session: the session structure to update with the message (cannot be NULL) + * In: msg32: the 32-byte message to be signed (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_set_msg( + const secp256k1_context* ctx, + secp256k1_musig_session *session, + const unsigned char *msg32 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Serialize a MuSig partial signature or adaptor signature + * + * Returns: 1 when the signature could be serialized, 0 otherwise + * Args: ctx: a secp256k1 context object + * Out: out32: pointer to a 32-byte array to store the serialized signature + * In: sig: pointer to the signature + */ +SECP256K1_API int secp256k1_musig_partial_signature_serialize( + const secp256k1_context* ctx, + unsigned char *out32, + const secp256k1_musig_partial_signature* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Parse and verify a MuSig partial signature. + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: pointer to a signature object + * In: in32: pointer to the 32-byte signature to be parsed + * + * After the call, sig will always be initialized. If parsing failed or the + * encoded numbers are out of range, signature verification with it is + * guaranteed to fail for every message and public key. + */ +SECP256K1_API int secp256k1_musig_partial_signature_parse( + const secp256k1_context* ctx, + secp256k1_musig_partial_signature* sig, + const unsigned char *in32 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Produces a partial signature + * + * Returns: 1: partial signature constructed + * 0: session in incorrect or inconsistent state + * Args: ctx: pointer to a context object (cannot be NULL) + * session: active signing session for which the combined nonce has been + * computed (cannot be NULL) + * Out: partial_sig: partial signature (cannot be NULL) + */ +SECP256K1_API int secp256k1_musig_partial_sign( + const secp256k1_context* ctx, + const secp256k1_musig_session *session, + secp256k1_musig_partial_signature *partial_sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Checks that an individual partial signature verifies + * + * This function is essential when using protocols with adaptor signatures. + * However, it is not essential for regular MuSig's, in the sense that if any + * partial signatures does not verify, the full signature will also not verify, so the + * problem will be caught. But this function allows determining the specific party + * who produced an invalid signature, so that signing can be restarted without them. + * + * Returns: 1: partial signature verifies + * 0: invalid signature or bad data + * Args: ctx: pointer to a context object (cannot be NULL) + * session: active session for which the combined nonce has been computed + * (cannot be NULL) + * signer: data for the signer who produced this signature (cannot be NULL) + * In: partial_sig: signature to verify (cannot be NULL) + * pubkey: public key of the signer who produced the signature (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_verify( + const secp256k1_context* ctx, + const secp256k1_musig_session *session, + const secp256k1_musig_session_signer_data *signer, + const secp256k1_musig_partial_signature *partial_sig, + const secp256k1_pubkey *pubkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5); + +/** Combines partial signatures + * + * Returns: 1: all partial signatures have values in range. Does NOT mean the + * resulting signature verifies. + * 0: some partial signature had s/r out of range + * Args: ctx: pointer to a context object (cannot be NULL) + * session: initialized session for which the combined nonce has been + * computed (cannot be NULL) + * Out: sig: complete signature (cannot be NULL) + * In: partial_sigs: array of partial signatures to combine (cannot be NULL) + * n_sigs: number of signatures in the partial_sigs array + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_combine( + const secp256k1_context* ctx, + const secp256k1_musig_session *session, + secp256k1_schnorrsig *sig, + const secp256k1_musig_partial_signature *partial_sigs, + size_t n_sigs +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Converts a partial signature to an adaptor signature by adding a given secret + * adaptor. + * + * Returns: 1: signature and secret adaptor contained valid values + * 0: otherwise + * Args: ctx: pointer to a context object (cannot be NULL) + * Out: adaptor_sig: adaptor signature to produce (cannot be NULL) + * In: partial_sig: partial signature to tweak with secret adaptor (cannot be NULL) + * sec_adaptor32: 32-byte secret adaptor to add to the partial signature (cannot + * be NULL) + * nonce_is_negated: the `nonce_is_negated` output of `musig_session_combine_nonces` + */ +SECP256K1_API int secp256k1_musig_partial_sig_adapt( + const secp256k1_context* ctx, + secp256k1_musig_partial_signature *adaptor_sig, + const secp256k1_musig_partial_signature *partial_sig, + const unsigned char *sec_adaptor32, + int nonce_is_negated +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Extracts a secret adaptor from a MuSig, given all parties' partial + * signatures. This function will not fail unless given grossly invalid data; if it + * is merely given signatures that do not verify, the returned value will be + * nonsense. It is therefore important that all data be verified at earlier steps of + * any protocol that uses this function. + * + * Returns: 1: signatures contained valid data such that an adaptor could be extracted + * 0: otherwise + * Args: ctx: pointer to a context object (cannot be NULL) + * Out:sec_adaptor32: 32-byte secret adaptor (cannot be NULL) + * In: sig: complete 2-of-2 signature (cannot be NULL) + * partial_sigs: array of partial signatures (cannot be NULL) + * n_partial_sigs: number of elements in partial_sigs array + * nonce_is_negated: the `nonce_is_negated` output of `musig_session_combine_nonces` + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_extract_secret_adaptor( + const secp256k1_context* ctx, + unsigned char *sec_adaptor32, + const secp256k1_schnorrsig *sig, + const secp256k1_musig_partial_signature *partial_sigs, + size_t n_partial_sigs, + int nonce_is_negated +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +#endif + diff --git a/src/secp256k1/include/secp256k1_schnorrsig.h b/src/secp256k1/include/secp256k1_schnorrsig.h new file mode 100644 index 000000000..9dea16653 --- /dev/null +++ b/src/secp256k1/include/secp256k1_schnorrsig.h @@ -0,0 +1,119 @@ +#ifndef SECP256K1_SCHNORRSIG_H +#define SECP256K1_SCHNORRSIG_H + +/** This module implements a variant of Schnorr signatures compliant with + * BIP-schnorr + * (https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki). + */ + +/** Opaque data structure that holds a parsed Schnorr signature. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is + * however guaranteed to be 64 bytes in size, and can be safely copied/moved. + * If you need to convert to a format suitable for storage, transmission, or + * comparison, use the `secp256k1_schnorrsig_serialize` and + * `secp256k1_schnorrsig_parse` functions. + */ +typedef struct { + unsigned char data[64]; +} secp256k1_schnorrsig; + +/** Serialize a Schnorr signature. + * + * Returns: 1 + * Args: ctx: a secp256k1 context object + * Out: out64: pointer to a 64-byte array to store the serialized signature + * In: sig: pointer to the signature + * + * See secp256k1_schnorrsig_parse for details about the encoding. + */ +SECP256K1_API int secp256k1_schnorrsig_serialize( + const secp256k1_context* ctx, + unsigned char *out64, + const secp256k1_schnorrsig* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Parse a Schnorr signature. + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: pointer to a signature object + * In: in64: pointer to the 64-byte signature to be parsed + * + * The signature is serialized in the form R||s, where R is a 32-byte public + * key (x-coordinate only; the y-coordinate is considered to be the unique + * y-coordinate satisfying the curve equation that is a quadratic residue) + * and s is a 32-byte big-endian scalar. + * + * After the call, sig will always be initialized. If parsing failed or the + * encoded numbers are out of range, signature validation with it is + * guaranteed to fail for every message and public key. + */ +SECP256K1_API int secp256k1_schnorrsig_parse( + const secp256k1_context* ctx, + secp256k1_schnorrsig* sig, + const unsigned char *in64 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Create a Schnorr signature. + * + * Returns 1 on success, 0 on failure. + * Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) + * Out: sig: pointer to the returned signature (cannot be NULL) + * nonce_is_negated: a pointer to an integer indicates if signing algorithm negated the + * nonce (can be NULL) + * In: msg32: the 32-byte message hash being signed (cannot be NULL) + * seckey: pointer to a 32-byte secret key (cannot be NULL) + * noncefp: pointer to a nonce generation function. If NULL, secp256k1_nonce_function_bipschnorr is used + * ndata: pointer to arbitrary data used by the nonce generation function (can be NULL) + */ +SECP256K1_API int secp256k1_schnorrsig_sign( + const secp256k1_context* ctx, + secp256k1_schnorrsig *sig, + int *nonce_is_negated, + const unsigned char *msg32, + const unsigned char *seckey, + secp256k1_nonce_function noncefp, + void *ndata +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5); + +/** Verify a Schnorr signature. + * + * Returns: 1: correct signature + * 0: incorrect or unparseable signature + * Args: ctx: a secp256k1 context object, initialized for verification. + * In: sig: the signature being verified (cannot be NULL) + * msg32: the 32-byte message hash being verified (cannot be NULL) + * pubkey: pointer to a public key to verify with (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_verify( + const secp256k1_context* ctx, + const secp256k1_schnorrsig *sig, + const unsigned char *msg32, + const secp256k1_pubkey *pubkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Verifies a set of Schnorr signatures. + * + * Returns 1 if all succeeded, 0 otherwise. In particular, returns 1 if n_sigs is 0. + * + * Args: ctx: a secp256k1 context object, initialized for verification. + * scratch: scratch space used for the multiexponentiation + * In: sig: array of signatures, or NULL if there are no signatures + * msg32: array of messages, or NULL if there are no signatures + * pk: array of public keys, or NULL if there are no signatures + * n_sigs: number of signatures in above arrays. Must be smaller than + * 2^31 and smaller than half the maximum size_t value. Must be 0 + * if above arrays are NULL. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_verify_batch( + const secp256k1_context* ctx, + secp256k1_scratch_space *scratch, + const secp256k1_schnorrsig *const *sig, + const unsigned char *const *msg32, + const secp256k1_pubkey *const *pk, + size_t n_sigs +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2); +#endif + From 7d570282f5ffef0de82e56e9ed39682f8d196395 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 08:03:24 -1100 Subject: [PATCH 2381/3904] Makecclib --- src/cc/makecclib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index ea44acdae..832cf1e96 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,2 +1,2 @@ #!/bin/sh -gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +gcc -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp From 839e7791512d49d9ce0bfe8cbe84ae5c491aca20 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 08:06:31 -1100 Subject: [PATCH 2382/3904] Scratch --- src/secp256k1/include/secp256k1.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/secp256k1/include/secp256k1.h b/src/secp256k1/include/secp256k1.h index 3e9c098d1..7dcdd7d0b 100644 --- a/src/secp256k1/include/secp256k1.h +++ b/src/secp256k1/include/secp256k1.h @@ -42,6 +42,19 @@ extern "C" { */ typedef struct secp256k1_context_struct secp256k1_context; +/** Opaque data structure that holds rewriteable "scratch space" + * + * The purpose of this structure is to replace dynamic memory allocations, + * because we target architectures where this may not be available. It is + * essentially a resizable (within specified parameters) block of bytes, + * which is initially created either by memory allocation or TODO as a pointer + * into some fixed rewritable space. + * + * Unlike the context object, this cannot safely be shared between threads + * without additional synchronization logic. + */ +typedef struct secp256k1_scratch_space_struct secp256k1_scratch_space; + /** Opaque data structure that holds a parsed and valid public key. * * The exact representation of data inside is implementation defined and not From ae5ec5372580029458a6cb16601f447f7ecc890e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 08:12:19 -1100 Subject: [PATCH 2383/3904] 4 -> 3 --- src/secp256k1/include/secp256k1_musig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/include/secp256k1_musig.h b/src/secp256k1/include/secp256k1_musig.h index 5796f677f..7e974e36d 100644 --- a/src/secp256k1/include/secp256k1_musig.h +++ b/src/secp256k1/include/secp256k1_musig.h @@ -278,7 +278,7 @@ SECP256K1_API int secp256k1_musig_session_combine_nonces( size_t n_signers, int *nonce_is_negated, const secp256k1_pubkey *adaptor -) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4); +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); /** Sets the message of a session if previously unset * From a29516ed1e6ceef22cd6041a509e0c81fc076f77 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 20:26:24 +0100 Subject: [PATCH 2384/3904] winify rogue makefile --- src/cc/Makefile_rogue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index ddaf392a3..0122764c1 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -27,8 +27,8 @@ ifeq ($(OS),Darwin) else ifeq ($(HOST),x86_64-w64-mingw32) $(info WINDOWS) wget -O ../../depends/x86_64-w64-mingw32/mingw64.zip https://invisible-island.net/datafiles/release/mingw32.zip - cd ../../depends/x86_64-w64-mingw32 && unzip mingw32.zip - cd $(DIR) + cd ../../depends/x86_64-w64-mingw32 && unzip mingw32.zip + cd $(DIR) $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) -lncurses cp $(TARGET_WIN) ../libcc.dll #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host From 653da2b728bafb32d59fb24ad08f706acafec66e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 08:48:59 -1100 Subject: [PATCH 2385/3904] main.$(O) --- src/cc/rogue/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index a6d410b23..e6cfde467 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -130,7 +130,7 @@ MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c $(PROGRAM): $(HDRS) $(OBJS) - $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2) -lcurses; $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2) -lcurses; $(CC) $(CFLAGS) $(LDFLAGS) main.$(O) $(OBJS) $(LIBS) -o $@ clean: $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so From 34a3ff37050d47cd8e1d1e5f27baf79471b7a37a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 08:50:25 -1100 Subject: [PATCH 2386/3904] Revert --- src/cc/rogue/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index e6cfde467..a6d410b23 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -130,7 +130,7 @@ MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c $(PROGRAM): $(HDRS) $(OBJS) - $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2) -lcurses; $(CC) $(CFLAGS) $(LDFLAGS) main.$(O) $(OBJS) $(LIBS) -o $@ + $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2) -lcurses; $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ clean: $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so From 7649ce3e67c4d5429599b6e19d14057f307d47dd Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 20:56:28 +0100 Subject: [PATCH 2387/3904] fix arch --- src/cc/Makefile_rogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 0122764c1..4697cd8f7 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -26,7 +26,7 @@ ifeq ($(OS),Darwin) cp $(TARGET_DARWIN) ../libcc.dylib else ifeq ($(HOST),x86_64-w64-mingw32) $(info WINDOWS) - wget -O ../../depends/x86_64-w64-mingw32/mingw64.zip https://invisible-island.net/datafiles/release/mingw32.zip + wget -O ../../depends/x86_64-w64-mingw32/mingw32.zip https://invisible-island.net/datafiles/release/mingw32.zip cd ../../depends/x86_64-w64-mingw32 && unzip mingw32.zip cd $(DIR) $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) -lncurses From f2eb58fa7910448e6f3505f7d4a8043ca98562d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 08:58:17 -1100 Subject: [PATCH 2388/3904] Remove -lncurses --- src/Makefile.am | 4 ++-- src/cc/Makefile_rogue | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 53331ee8f..395ff0352 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -574,9 +574,9 @@ komodod_LDADD += \ $(LIBZCASH_LIBS) if TARGET_DARWIN -komodod_LDADD += libcc.dylib # -lncurses +komodod_LDADD += libcc.dylib else -komodod_LDADD += libcc.so # -lncurses +komodod_LDADD += libcc.so endif diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 45efdc803..a7c60f724 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -21,16 +21,16 @@ all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib to src/) ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) -c $(SOURCES) -lncurses + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) -c $(SOURCES) cp $(TARGET_DARWIN) ../libcc.dylib else ifeq ($(HOST),x86_64-w64-mingw32) $(info WINDOWS) - $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) -lncurses + $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) cp $(TARGET_WIN) ../libcc.dll #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host else $(info LINUX) - $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) -lncurses + $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) cp $(TARGET) ../libcc.so endif From 30cab829bdc6739254527ca315e7803a55cf224c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 09:00:53 -1100 Subject: [PATCH 2389/3904] -lcurses --- src/cc/rogue/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index a6d410b23..8e6f7ca24 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -130,7 +130,7 @@ MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c $(PROGRAM): $(HDRS) $(OBJS) - $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2) -lcurses; $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ clean: $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so From 5ff8a7c25caaaa3e56ac760af7cf3a62986e8985 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 09:02:36 -1100 Subject: [PATCH 2390/3904] Add cursesd.c --- src/cc/rogue/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index 8e6f7ca24..d40c25826 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -111,7 +111,7 @@ CFILES = vers.c extern.c armor.c chase.c command.c daemon.c \ main.c mdport.c misc.c monsters.c move.c new_level.c \ options.c pack.c passages.c potions.c rings.c rip.c \ rooms.c save.c scrolls.c state.c sticks.c things.c \ - weapons.c wizard.c xcrypt.c + weapons.c wizard.c xcrypt.c cursesd.c MISC_C = findpw.c scedit.c scmisc.c DOCSRC = rogue.me.in rogue.6.in rogue.doc.in rogue.html.in rogue.cat.in DOCS = $(PROGRAM).doc $(PROGRAM).html $(PROGRAM).cat $(PROGRAM).me \ @@ -130,7 +130,7 @@ MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c $(PROGRAM): $(HDRS) $(OBJS) - $(RM) rogue.so ; $(CC) -shared -o rogue.so $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + $(RM) rogue.so ; $(CC) -shared -o rogue.so cursesd.o $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ clean: $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so From 08bbf62d12366a5e8e0a882d5b3f8b4f19fd699d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 09:04:10 -1100 Subject: [PATCH 2391/3904] .0 -> .c --- src/cc/rogue/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index d40c25826..40044b082 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -130,7 +130,7 @@ MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c $(PROGRAM): $(HDRS) $(OBJS) - $(RM) rogue.so ; $(CC) -shared -o rogue.so cursesd.o $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + $(RM) rogue.so ; $(CC) -shared -o rogue.so cursesd.c $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ clean: $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so From e027678ec2eae6e1ecab6886057e9abab9835b9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 09:05:31 -1100 Subject: [PATCH 2392/3904] Make just rogue --- src/cc/rogue/Makefile.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index 40044b082..c53ece6ac 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -111,7 +111,7 @@ CFILES = vers.c extern.c armor.c chase.c command.c daemon.c \ main.c mdport.c misc.c monsters.c move.c new_level.c \ options.c pack.c passages.c potions.c rings.c rip.c \ rooms.c save.c scrolls.c state.c sticks.c things.c \ - weapons.c wizard.c xcrypt.c cursesd.c + weapons.c wizard.c xcrypt.c MISC_C = findpw.c scedit.c scmisc.c DOCSRC = rogue.me.in rogue.6.in rogue.doc.in rogue.html.in rogue.cat.in DOCS = $(PROGRAM).doc $(PROGRAM).html $(PROGRAM).cat $(PROGRAM).me \ @@ -128,9 +128,11 @@ MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c - + +#$(RM) rogue.so ; $(CC) -shared -o rogue.so cursesd.c $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + $(PROGRAM): $(HDRS) $(OBJS) - $(RM) rogue.so ; $(CC) -shared -o rogue.so cursesd.c $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ clean: $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so From 6b3ba45960bdae80b7dc700425b6b48de1bbec8f Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 21:26:58 +0100 Subject: [PATCH 2393/3904] include ncursesw --- src/cc/Makefile_rogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 4697cd8f7..330854bea 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -4,7 +4,7 @@ CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -DBUILD_ROGUE -std=c++11 -arch x86_64 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/x86_64-w64-mingw32/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared +CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/x86_64-w64-mingw32/include -I../../depends/x86_64-w64-mingw32/include/ncursesw -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) From ad7631f4cee2f57704a393e008478d76c8181290 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 22:23:10 +0100 Subject: [PATCH 2394/3904] test --- src/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 53331ee8f..eee289704 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -575,11 +575,13 @@ komodod_LDADD += \ if TARGET_DARWIN komodod_LDADD += libcc.dylib # -lncurses +endif +if TARGET_WINDOWS +komodod_LDADD += libcc.dll else komodod_LDADD += libcc.so # -lncurses endif - if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) endif From fb462bf7de0248b4c4ce6b17f7faba60891b8a14 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 22:53:56 +0100 Subject: [PATCH 2395/3904] update boost --- depends/packages/boost.mk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 8f3fd1b1c..7a0439ba7 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,9 +1,8 @@ - package=boost -$(package)_version=1_66_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.66.0/source +$(package)_version=1_69_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.69.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9 +$(package)_sha256_hash=8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 define $(package)_set_vars $(package)_config_opts_release=variant=release From 85071d5d9cf12142fca556246f7e571e1f0df719 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 22:54:44 +0100 Subject: [PATCH 2396/3904] update libsodium --- depends/packages/libsodium.mk | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 76f0d9a28..179ebe86c 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -1,12 +1,3 @@ -ifeq ($(build_os),darwin) -package=libsodium -$(package)_version=1.0.11 -$(package)_download_path=https://supernetorg.bintray.com/misc -$(package)_file_name=libsodium-1.0.11.tar.gz -$(package)_sha256_hash=a14549db3c49f6ae2170cbbf4664bd48ace50681045e8dbea7c8d9fb96f9c765 -$(package)_dependencies= -$(package)_config_opts= -else package=libsodium $(package)_version=1.0.15 $(package)_download_path=https://download.libsodium.org/libsodium/releases/old @@ -14,6 +5,13 @@ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 $(package)_dependencies= $(package)_config_opts= + +ifeq ($(build_os),darwin) +define $(package)_set_vars + $(package)_build_env=MACOSX_DEPLOYMENT_TARGET="10.11" + $(package)_cc=clang + $(package)_cxx=clang++ +endef endif define $(package)_preprocess_cmds From d257da66dce007e5405f2639b55a9559844b1b3a Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 22:55:14 +0100 Subject: [PATCH 2397/3904] update openssl --- depends/packages/openssl.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk index dec8ecef6..e378088e6 100644 --- a/depends/packages/openssl.mk +++ b/depends/packages/openssl.mk @@ -1,8 +1,8 @@ package=openssl -$(package)_version=1.1.0h +$(package)_version=1.1.1a $(package)_download_path=https://www.openssl.org/source $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=5835626cde9e99656585fc7aaa2302a73a7e1340bf8c14fd635a62c66802a517 +$(package)_sha256_hash=fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed3f9f41 define $(package)_set_vars $(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" @@ -92,7 +92,7 @@ $(package)_config_opts_i686_mingw32=mingw endef define $(package)_preprocess_cmds - sed -i.old "/define DATE/d" util/mkbuildinf.pl && \ + sed -i.old 's/built on: $date/built on: not available/' util/mkbuildinf.pl && \ sed -i.old "s|\"engines\", \"apps\", \"test\"|\"engines\"|" Configure endef From 9c3581f568b78714ee8605bb11aa1d1b53ce542f Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 22:55:49 +0100 Subject: [PATCH 2398/3904] update rust --- depends/packages/rust.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/depends/packages/rust.mk b/depends/packages/rust.mk index a08ac2747..9cfb95054 100644 --- a/depends/packages/rust.mk +++ b/depends/packages/rust.mk @@ -1,13 +1,13 @@ package=rust -$(package)_version=1.28.0 +$(package)_version=1.32.0 $(package)_download_path=https://static.rust-lang.org/dist $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_linux=2a1390340db1d24a9498036884e6b2748e9b4b057fc5219694e298bdaa37b810 +$(package)_sha256_hash_linux=e024698320d76b74daf0e6e71be3681a1e7923122e3ebd03673fcac3ecc23810 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_darwin=5d7a70ed4701fe9410041c1eea025c95cad97e5b3d8acc46426f9ac4f9f02393 +$(package)_sha256_hash_darwin=f0dfba507192f9b5c330b5984ba71d57d434475f3d62bd44a39201e36fa76304 $(package)_file_name_mingw32=rust-$($(package)_version)-x86_64-pc-windows-gnu.tar.gz -$(package)_sha256_hash_mingw32=55c07426f791c51c8a2b6934b35784175c4abb4e03f123f3e847109c4dc1ad8b +$(package)_sha256_hash_mingw32=358e1435347c67dbf33aa9cad6fe501a833d6633ed5d5aa1863d5dffa0349be9 ifeq ($(build_os),darwin) $(package)_file_name=$($(package)_file_name_darwin) From 4ad570e237003e559e64e459e64ebd42c3ffeeaa Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 23:16:22 +0100 Subject: [PATCH 2399/3904] remove ncurses remove -lncurses flag from Makefile_rogue --- src/cc/Makefile_rogue | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 330854bea..a7c60f724 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -4,12 +4,11 @@ CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -DBUILD_ROGUE -std=c++11 -arch x86_64 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/x86_64-w64-mingw32/include -I../../depends/x86_64-w64-mingw32/include/ncursesw -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared +CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/x86_64-w64-mingw32/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) OS := $(shell uname -s) -DIR := ${CURDIR} $(info $(OS)) TARGET = librogue.so TARGET_DARWIN = librogue.dylib @@ -22,19 +21,16 @@ all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib to src/) ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) -c $(SOURCES) -lncurses + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) -c $(SOURCES) cp $(TARGET_DARWIN) ../libcc.dylib else ifeq ($(HOST),x86_64-w64-mingw32) $(info WINDOWS) - wget -O ../../depends/x86_64-w64-mingw32/mingw32.zip https://invisible-island.net/datafiles/release/mingw32.zip - cd ../../depends/x86_64-w64-mingw32 && unzip mingw32.zip - cd $(DIR) - $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) -lncurses + $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) cp $(TARGET_WIN) ../libcc.dll #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host else $(info LINUX) - $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) -lncurses + $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) cp $(TARGET) ../libcc.so endif From edb2fad98eedc0c76a6ed6f7c56fb05a0aa45219 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 23:18:14 +0100 Subject: [PATCH 2400/3904] remove ncurses from automake makefile --- src/Makefile.am | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index eee289704..395ff0352 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -574,14 +574,12 @@ komodod_LDADD += \ $(LIBZCASH_LIBS) if TARGET_DARWIN -komodod_LDADD += libcc.dylib # -lncurses -endif -if TARGET_WINDOWS -komodod_LDADD += libcc.dll +komodod_LDADD += libcc.dylib else -komodod_LDADD += libcc.so # -lncurses +komodod_LDADD += libcc.so endif + if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) endif From bc902be9e57fa9a8ef7062553cdda20dc2fe08f4 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 23:21:47 +0100 Subject: [PATCH 2401/3904] add WIN --- src/Makefile.am | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 395ff0352..e9d41a510 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -572,13 +572,15 @@ komodod_LDADD += \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) - + if TARGET_DARWIN komodod_LDADD += libcc.dylib -else -komodod_LDADD += libcc.so endif - +if TARGET_WINDOWS +komodod_LDADD += libcc.dll +else +komodod_LDADD += libcc.so +endif if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) From 619c92a1ac2a08cd4dae195bb706f7d89abcce2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 16:57:07 -1100 Subject: [PATCH 2402/3904] Remove OS specific --- src/cc/rogue/rogue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 786718039..80a4e7da2 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -548,13 +548,13 @@ tstp(int ignored) getyx(curscr, y, x); mvcur(y, x, oy, ox); fflush(stdout); - //wmove(curscr,oy,ox); -#ifndef __APPLE__ + wmove(curscr,oy,ox); +/*#ifndef __APPLE__ #ifndef BUILD_ROGUE curscr->_cury = oy; curscr->_curx = ox; #endif -#endif +#endif*/x } /* From 61966f52f8b9c337c011d76db1e81f31ade20c7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 16:57:56 -1100 Subject: [PATCH 2403/3904] -x --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 80a4e7da2..92d3ad378 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -554,7 +554,7 @@ tstp(int ignored) curscr->_cury = oy; curscr->_curx = ox; #endif -#endif*/x +#endif*/ } /* From f1d392b72c168edf4c6216c29f8a5b4f9381b7b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 07:10:36 -1100 Subject: [PATCH 2404/3904] Initial musig CC commit --- src/cc/cclib.cpp | 81 ++++++++++--- src/cc/musig.cpp | 265 +++++++++++++++++++++++++++++++++++++++++++ src/cc/rogue_rpc.cpp | 5 +- src/cc/sudoku.cpp | 4 - 4 files changed, 332 insertions(+), 23 deletions(-) create mode 100755 src/cc/musig.cpp diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f2f13837c..ae3d88573 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -36,6 +36,7 @@ std::string MYCCLIBNAME = (char *)"rogue"; #else #define EVAL_SUDOKU 17 +#define EVAL_MUSIG 18 std::string MYCCLIBNAME = (char *)"sudoku"; #endif @@ -70,6 +71,16 @@ CClib_methods[] = { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"solution", (char *)"txid solution timestamps[81]", 83, 83, 'S', EVAL_SUDOKU }, + { (char *)"musig", (char *)"calcmsg", (char *)"sendtxid scriptPubKey", 2, 2, 'C', EVAL_MUSIG }, + { (char *)"musig", (char *)"combine", (char *)"pubkeys ...", 2, 256, 'P', EVAL_MUSIG }, + { (char *)"musig", (char *)"session", (char *)"msg pkhash", 2, 2, 'R', EVAL_MUSIG }, + { (char *)"musig", (char *)"commit", (char *)"pubkeys ...", 2, 256, 'H', EVAL_MUSIG }, + { (char *)"musig", (char *)"nonce", (char *)"pubkeys ...", 2, 256, 'N', EVAL_MUSIG }, + { (char *)"musig", (char *)"partialsign", (char *)"pubkeys ...", 2, 256, 'S', EVAL_MUSIG }, + { (char *)"musig", (char *)"sigcombine", (char *)"pubkeys ...", 2, 256, 'M', EVAL_MUSIG }, + { (char *)"musig", (char *)"verify", (char *)"msg sig pubkey", 3, 3, 'V', EVAL_MUSIG }, + { (char *)"musig", (char *)"send", (char *)"combined_pk amount", 2, 2, 'x', EVAL_MUSIG }, + { (char *)"musig", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_MUSIG }, #endif }; @@ -98,6 +109,18 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); + +bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); +UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #endif UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) @@ -158,6 +181,37 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(result); } } + else if ( cp->evalcode == EVAL_MUSIG ) + { + //printf("CClib_method params.%p\n",params); + if ( strcmp(method,"combine") == 0 ) + return(musig_combine(txfee,cp,params)); + else if ( strcmp(method,"calcmsg") == 0 ) + return(musig_calcmsg(txfee,cp,params)); + else if ( strcmp(method,"session") == 0 ) + return(musig_session(txfee,cp,params)); + else if ( strcmp(method,"commit") == 0 ) + return(musig_commit(txfee,cp,params)); + else if ( strcmp(method,"nonce") == 0 ) // returns combined nonce if ready + return(musig_nonce(txfee,cp,params)); + else if ( strcmp(method,"partialsign") == 0 ) + return(musig_partialsign(txfee,cp,params)); + else if ( strcmp(method,"sigcombine") == 0 ) + return(musig_sigcombine(txfee,cp,params)); + else if ( strcmp(method,"verify") == 0 ) + return(musig_verify(txfee,cp,params)); + else if ( strcmp(method,"send") == 0 ) + return(musig_send(txfee,cp,params)); + else if ( strcmp(method,"spend") == 0 ) + return(musig_spend(txfee,cp,params)); + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid musig method")); + result.push_back(Pair("method",method)); + return(result); + } + } #endif else { @@ -278,7 +332,11 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C #ifdef BUILD_ROGUE return(rogue_validate(cp,height,eval,tx)); #else - return(sudoku_validate(cp,height,eval,tx)); + if ( cp->evalcode == EVAL_SUDOKU ) + return(sudoku_validate(cp,height,eval,tx)); + else if ( cp->evalcode == EVAL_MUSIG ) + return(musig_validate(cp,height,eval,tx)); + else return eval->Invalid("invalid evalcode"); #endif } numvins = tx.vin.size(); @@ -385,21 +443,6 @@ std::string Faucet2Fund(struct CCcontract_info *cp,uint64_t txfee,int64_t funds) return(""); } -/*UniValue FaucetInfo() -{ - UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey faucetpk; struct CCcontract_info *cp,C; int64_t funding; - result.push_back(Pair("result","success")); - result.push_back(Pair("name","Faucet")); - cp = CCinit(&C,EVAL_FAUCET); - faucetpk = GetUnspendable(cp,0); - funding = AddFaucetInputs(cp,mtx,faucetpk,0,0); - sprintf(numstr,"%.8f",(double)funding/COIN); - result.push_back(Pair("funding",numstr)); - return(result); -}*/ - std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -481,7 +524,10 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will { newstr[j++] = '"'; i += 2; - } else newstr[j++] = jsonstr[i]; + } + else if ( jsonstr[i] == ''' ) + newstr[j++] = '"'; + else newstr[j++] = jsonstr[i]; } newstr[j] = 0; params = cJSON_Parse(newstr); @@ -533,5 +579,6 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #else #include "sudoku.cpp" +#include "musig.cpp" #endif diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp new file mode 100755 index 000000000..1a9d860cf --- /dev/null +++ b/src/cc/musig.cpp @@ -0,0 +1,265 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + + +#include +#include +#include + +#define MUSIG_PREVN 0 // for now, just use vout0 for the musig output + +uint256 musig_msghash(uint256 prevhash,int32_t prevn,CTxOut vout,secp256k1_pubkey combined_pk) +{ + std::vector data; uint256 hash; int32_t len = 0; + data << E_MARSHAL(ss << prevhash << prevn << vout << combined_pk); +fprintf(stderr,"data size %d\n",(int32_t)data.size()); + vcalc_sha256(0,(uint8_t *)&hash,data.ptr(),data.size()); + return(hash); +} + +uint256 musig_prevoutmsg(uint256 sendtxid,CScript scriptPubKey) +{ + CTransaction vintx; uint256 hashBlock; int32_t numvouts; CTxOut vout; secp256k1_pubkey combined_pk; + if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) + { + if ( musig_sendopretdecode(combined_pk,vintx.vouts[numvouts-1].scriptPubKey) == 'x' ) + { + vout.nValue = vintx.vout[MUSIG_PREVN].nValue - txfee; + vout.scriptPubKey = scriptPubKey; + return(musig_msghash(prevhash,MUSIG_PREVN,vout,combined_pk)); + } + } + return(zeroid); +} + +UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); uint256 sendtxid,msg; char *scriptstr; int32_t n; + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n == 2 ) + { + sendtxid = juint256(jitem(params,0)); + scriptstr = jstr(jitem(params,1),0); + if ( is_hexstr(scriptstr,0) != 0 ) + { + CScript scriptPubKey(ParseHex(scriptstr)); + msg = musig_prevoutmsg(sendtxid,scriptPubKey); + result.push_back("result","success"); + result.push_back("msg",msg.GetHex()); + return(result); + } else return(cclib_error(result,"script is not hex")); + } else return(cclib_error(result,"need exactly 2 parameters: sendtxid, scriptPubKey")); + } else return(cclib_error(result,"couldnt parse params")); +} + +UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back("result","success"); + return(result); +} + +UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back("result","success"); + return(result); +} + +UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back("result","success"); + return(result); +} + +UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back("result","success"); + return(result); +} + +UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back("result","success"); + return(result); +} + +UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back("result","success"); + return(result); +} + +UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back("result","success"); + return(result); +} + +// helpers for rpc calls that generate/validate onchain tx + +UniValue musig_rawtxresult(UniValue &result,std::string rawtx) +{ + CTransaction tx; + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + //if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + // RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + +CScript musig_sendopret(uint8_t funcid,secp256k1_pubkey combined_pk) +{ + CScript opret; uint8_t evalcode = EVAL_MUSIG; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << combined_pk); + return(opret); +} + +uint8_t musig_sendopretdecode(secp256k1_pubkey &combined_pk,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> combined_pk) != 0 && e == EVAL_MUSIG && f == 'x' ) + { + return(f); + } + return(0); +} + +CScript musig_spendopret(uint8_t funcid,secp256k1_pubkey combined_pk,secp256k1_schnorrsig musig) +{ + CScript opret; uint8_t evalcode = EVAL_MUSIG; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << combined_pk << musig); + return(opret); +} + +uint8_t musig_spendopretdecode(secp256k1_pubkey &combined_pk,secp256k1_schnorrsig &musig,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> combined_pk; ss >> musig) != 0 && e == EVAL_MUSIG && f == 'y' ) + { + return(f); + } + return(0); +} + +UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); int32_t n; char *hexstr; std::string rawtx; int64_t amount; CPubKey musigpk,mypk; + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + musigpk = GetUnspendable(cp,0); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n == 2 && (hexstr= jstr(jitem(params,0),0)) != 0 && is_hexstr(hexstr,0) == 66 ) + { + secp256k1_pubkey combined_pk(ParseHex(hexstr)); + amount = jdouble(jitem(params,1),0) * COIN + 0.0000000049; + if ( amount >= 3*txfee && AddNormalinputs(mtx,mypk,amount+2*txfee,64) >= amount+2*txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount+txfee,musigpk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_sendopret('x',combined_pk)); + return(musig_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt find funds or less than 0.0003")); + } else return(cclib_error(result,"must have 2 params: combined_pk, amount")); + } else return(cclib_error(result,"not enough parameters")); +} + +UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + static secp256k1_context *ctx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint256 msg,prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n == 3 ) + { + prevhash = juint256(jitem(params,0)); + scriptstr = jstr(jitem(params,1),0); + musigstr = jstr(jitem(params,2),0); + if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) != 0 ) + { + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + secp256k1_schnorrsig musig(ParseHex(musigstr)); + CScript scriptPubKey(ParseHex(scriptstr)); + if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) + { + vout.nValue = vintx.vout[0].nValue - txfee; + vout.scriptPubKey = scriptPubKey; + if ( musig_sendopretdecode(combined_pk,vintx.vouts[numvouts-1].scriptPubKey) == 'x' ) + { + msg = musig_prevoutmsg(prevhash,vout.scriptPubKey); + if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) + return(cclib_error(result,"musig didnt validate")); + mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); + mtx.vout.push_back(vout); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_spendopret('y',combined_pk,musig)); + return(musig_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt decode send opret")); + } else return(cclib_error(result,"couldnt find vin0")); + } else return(cclib_error(result,"script or musig is not hex")); + } else return(cclib_error(result,"need to have exactly 3 params prevhash, scriptPubKey, musig")); + } else return(cclib_error(result,"params parse error")); +} + +bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + static secp256k1_context *ctx; + secp256k1_pubkey combined_pk,checkpk; secp256k1_schnorrsig musig; uint256 msg,hashBlock; CTransaction vintx; int32_t numvouts; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( tx.vout.size() != 2 ) + return eval->Invalid("numvouts != 2"); + else if ( tx.vin.size() != 1 ) + return eval->Invalid("numvins != 1"); + else if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) + return eval->Invalid("illegal normal vin0"); + else if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) + { + if ( musig_sendopretdecode(combined_pk,vintx.vouts[numvouts-1].scriptPubKey) == 'x' ) + { + if ( musig_spendopretdecode(check_pk,musig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) + { + if ( combined_pk == check_pk ) + { + msg = musig_prevoutmsg(tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); + if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) + return eval->Invalid("failed schnorrsig_verify"); + else return(true); + } else return eval->Invalid("combined_pk didnt match send opret"); + } else return eval->Invalid("failed decode musig spendopret"); + } else return eval->Invalid("couldnt decode send opret"); + } else return eval->Invalid("couldnt find vin0 tx"); +} diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3d89e0568..8ca239c7b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1078,7 +1078,7 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; result.push_back(Pair("name","rogue")); result.push_back(Pair("method","gameinfo")); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -1095,7 +1095,8 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,myrogueaddr,roguepk,mypk); //fprintf(stderr,"myrogueaddr.%s\n",myrogueaddr); - rogue_gamefields(result,maxplayers,buyin,txid,myrogueaddr); + seed = rogue_gamefields(result,maxplayers,buyin,txid,myrogueaddr); + result.push_back(Pair("seed",(int64_t)seed)); for (i=0; iInvalid("not enough vouts"); } -#include -#include -#include - From 998a2cf173f5b199d95c2b7ba71e032dee411ce5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 07:17:05 -1100 Subject: [PATCH 2405/3904] CScript opret; uint8_t evalcode = EVAL_MUSIG; opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << combined_pk); --- src/cc/cclib.cpp | 2 +- src/cc/musig.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index ae3d88573..0d907d4ca 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -525,7 +525,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will newstr[j++] = '"'; i += 2; } - else if ( jsonstr[i] == ''' ) + else if ( jsonstr[i] == '\'' ) newstr[j++] = '"'; else newstr[j++] = jsonstr[i]; } diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 1a9d860cf..4696f7949 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -22,6 +22,7 @@ uint256 musig_msghash(uint256 prevhash,int32_t prevn,CTxOut vout,secp256k1_pubkey combined_pk) { + CScript data; std::vector data; uint256 hash; int32_t len = 0; data << E_MARSHAL(ss << prevhash << prevn << vout << combined_pk); fprintf(stderr,"data size %d\n",(int32_t)data.size()); From fdaf1fb297d1535d2016cbe15d171c3701e10b8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 07:21:15 -1100 Subject: [PATCH 2406/3904] syntax --- src/cc/musig.cpp | 232 +++++++++++++++++++++++------------------------ 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 4696f7949..12da40f1d 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -19,120 +19,7 @@ #include #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output - -uint256 musig_msghash(uint256 prevhash,int32_t prevn,CTxOut vout,secp256k1_pubkey combined_pk) -{ - CScript data; - std::vector data; uint256 hash; int32_t len = 0; - data << E_MARSHAL(ss << prevhash << prevn << vout << combined_pk); -fprintf(stderr,"data size %d\n",(int32_t)data.size()); - vcalc_sha256(0,(uint8_t *)&hash,data.ptr(),data.size()); - return(hash); -} - -uint256 musig_prevoutmsg(uint256 sendtxid,CScript scriptPubKey) -{ - CTransaction vintx; uint256 hashBlock; int32_t numvouts; CTxOut vout; secp256k1_pubkey combined_pk; - if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) - { - if ( musig_sendopretdecode(combined_pk,vintx.vouts[numvouts-1].scriptPubKey) == 'x' ) - { - vout.nValue = vintx.vout[MUSIG_PREVN].nValue - txfee; - vout.scriptPubKey = scriptPubKey; - return(musig_msghash(prevhash,MUSIG_PREVN,vout,combined_pk)); - } - } - return(zeroid); -} - -UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); uint256 sendtxid,msg; char *scriptstr; int32_t n; - if ( (params= cclib_reparse(&n,params)) != 0 ) - { - if ( n == 2 ) - { - sendtxid = juint256(jitem(params,0)); - scriptstr = jstr(jitem(params,1),0); - if ( is_hexstr(scriptstr,0) != 0 ) - { - CScript scriptPubKey(ParseHex(scriptstr)); - msg = musig_prevoutmsg(sendtxid,scriptPubKey); - result.push_back("result","success"); - result.push_back("msg",msg.GetHex()); - return(result); - } else return(cclib_error(result,"script is not hex")); - } else return(cclib_error(result,"need exactly 2 parameters: sendtxid, scriptPubKey")); - } else return(cclib_error(result,"couldnt parse params")); -} - -UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - result.push_back("result","success"); - return(result); -} - -UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - result.push_back("result","success"); - return(result); -} - -UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - result.push_back("result","success"); - return(result); -} - -UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - result.push_back("result","success"); - return(result); -} - -UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - result.push_back("result","success"); - return(result); -} - -UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - result.push_back("result","success"); - return(result); -} - -UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - result.push_back("result","success"); - return(result); -} - -// helpers for rpc calls that generate/validate onchain tx - -UniValue musig_rawtxresult(UniValue &result,std::string rawtx) -{ - CTransaction tx; - if ( rawtx.size() > 0 ) - { - result.push_back(Pair("hex",rawtx)); - if ( DecodeHexTx(tx,rawtx) != 0 ) - { - //if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) - // RelayTransaction(tx); - result.push_back(Pair("txid",tx.GetHash().ToString())); - result.push_back(Pair("result","success")); - } else result.push_back(Pair("error","decode hex")); - } else result.push_back(Pair("error","couldnt finalize CCtx")); - return(result); -} +#define MUSIG_TXFEE 10000 CScript musig_sendopret(uint8_t funcid,secp256k1_pubkey combined_pk) { @@ -170,12 +57,125 @@ uint8_t musig_spendopretdecode(secp256k1_pubkey &combined_pk,secp256k1_schnorrsi return(0); } +uint256 musig_msghash(uint256 prevhash,int32_t prevn,CTxOut vout,secp256k1_pubkey combined_pk) +{ + CScript data; uint256 hash; int32_t len = 0; + data << E_MARSHAL(ss << prevhash << prevn << vout << combined_pk); +fprintf(stderr,"data size %d\n",(int32_t)data.size()); + vcalc_sha256(0,(uint8_t *)&hash,data.data(),data.size()); + return(hash); +} + +uint256 musig_prevoutmsg(uint256 sendtxid,CScript scriptPubKey) +{ + CTransaction vintx; uint256 hashBlock; int32_t numvouts; CTxOut vout; secp256k1_pubkey combined_pk; + if ( myGetTransaction(sendtxid,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) + { + if ( musig_sendopretdecode(combined_pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + { + vout.nValue = vintx.vout[MUSIG_PREVN].nValue - MUSIG_TXFEE; + vout.scriptPubKey = scriptPubKey; + return(musig_msghash(sendtxid,MUSIG_PREVN,vout,combined_pk)); + } + } + return(zeroid); +} + +UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); uint256 sendtxid,msg; char *scriptstr; int32_t n; + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n == 2 ) + { + sendtxid = juint256(jitem(params,0)); + scriptstr = jstr(jitem(params,1),0); + if ( is_hexstr(scriptstr,0) != 0 ) + { + CScript scriptPubKey(ParseHex(scriptstr)); + msg = musig_prevoutmsg(sendtxid,scriptPubKey); + result.push_back(Pair("result","success")); + result.push_back(Pair("msg",msg.GetHex())); + return(result); + } else return(cclib_error(result,"script is not hex")); + } else return(cclib_error(result,"need exactly 2 parameters: sendtxid, scriptPubKey")); + } else return(cclib_error(result,"couldnt parse params")); +} + +UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + return(result); +} + +UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + return(result); +} + +// helpers for rpc calls that generate/validate onchain tx + +UniValue musig_rawtxresult(UniValue &result,std::string rawtx) +{ + CTransaction tx; + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + //if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + // RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); int32_t n; char *hexstr; std::string rawtx; int64_t amount; CPubKey musigpk,mypk; if ( txfee == 0 ) - txfee = 10000; + txfee = MUSIG_TXFEE; mypk = pubkey2pk(Mypubkey()); musigpk = GetUnspendable(cp,0); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -211,7 +211,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) != 0 ) { if ( txfee == 0 ) - txfee = 10000; + txfee = MUSIG_TXFEE; mypk = pubkey2pk(Mypubkey()); secp256k1_schnorrsig musig(ParseHex(musigstr)); CScript scriptPubKey(ParseHex(scriptstr)); From a2d6ae5e145cff32f35981f71229022785b272a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 07:28:27 -1100 Subject: [PATCH 2407/3904] Msg -> msg[32] --- src/cc/musig.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 12da40f1d..6d2a1f583 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -57,16 +57,15 @@ uint8_t musig_spendopretdecode(secp256k1_pubkey &combined_pk,secp256k1_schnorrsi return(0); } -uint256 musig_msghash(uint256 prevhash,int32_t prevn,CTxOut vout,secp256k1_pubkey combined_pk) +void musig_msghash(uint8_t *msg,uint256 prevhash,int32_t prevn,CTxOut vout,secp256k1_pubkey combined_pk) { CScript data; uint256 hash; int32_t len = 0; data << E_MARSHAL(ss << prevhash << prevn << vout << combined_pk); fprintf(stderr,"data size %d\n",(int32_t)data.size()); - vcalc_sha256(0,(uint8_t *)&hash,data.data(),data.size()); - return(hash); + vcalc_sha256(0,msg,data.data(),data.size()); } -uint256 musig_prevoutmsg(uint256 sendtxid,CScript scriptPubKey) +int32_t musig_prevoutmsg(uint8_t *msg,uint256 sendtxid,CScript scriptPubKey) { CTransaction vintx; uint256 hashBlock; int32_t numvouts; CTxOut vout; secp256k1_pubkey combined_pk; if ( myGetTransaction(sendtxid,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) @@ -75,7 +74,7 @@ uint256 musig_prevoutmsg(uint256 sendtxid,CScript scriptPubKey) { vout.nValue = vintx.vout[MUSIG_PREVN].nValue - MUSIG_TXFEE; vout.scriptPubKey = scriptPubKey; - return(musig_msghash(sendtxid,MUSIG_PREVN,vout,combined_pk)); + return(musig_msghash(msg,sendtxid,MUSIG_PREVN,vout,combined_pk)); } } return(zeroid); @@ -83,7 +82,7 @@ uint256 musig_prevoutmsg(uint256 sendtxid,CScript scriptPubKey) UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); uint256 sendtxid,msg; char *scriptstr; int32_t n; + UniValue result(UniValue::VOBJ); uint256 sendtxid; int32_t i; uint8_t msg[32]; char *scriptstr,str[65]; int32_t n; if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n == 2 ) @@ -93,9 +92,12 @@ UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( is_hexstr(scriptstr,0) != 0 ) { CScript scriptPubKey(ParseHex(scriptstr)); - msg = musig_prevoutmsg(sendtxid,scriptPubKey); + musig_prevoutmsg(msg,sendtxid,scriptPubKey); result.push_back(Pair("result","success")); - result.push_back(Pair("msg",msg.GetHex())); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",msg[i]); + str[64] = 0; + result.push_back(Pair("msg",str)); return(result); } else return(cclib_error(result,"script is not hex")); } else return(cclib_error(result,"need exactly 2 parameters: sendtxid, scriptPubKey")); @@ -198,7 +200,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint256 msg,prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -219,9 +221,9 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { vout.nValue = vintx.vout[0].nValue - txfee; vout.scriptPubKey = scriptPubKey; - if ( musig_sendopretdecode(combined_pk,vintx.vouts[numvouts-1].scriptPubKey) == 'x' ) + if ( musig_sendopretdecode(combined_pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { - msg = musig_prevoutmsg(prevhash,vout.scriptPubKey); + musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) return(cclib_error(result,"musig didnt validate")); mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); @@ -238,7 +240,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static secp256k1_context *ctx; - secp256k1_pubkey combined_pk,checkpk; secp256k1_schnorrsig musig; uint256 msg,hashBlock; CTransaction vintx; int32_t numvouts; + secp256k1_pubkey combined_pk,checkpk; secp256k1_schnorrsig musig; uint256 hashBlock; CTransaction vintx; int32_t numvouts; uint8_t msg[32]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( tx.vout.size() != 2 ) @@ -249,13 +251,13 @@ bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("illegal normal vin0"); else if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { - if ( musig_sendopretdecode(combined_pk,vintx.vouts[numvouts-1].scriptPubKey) == 'x' ) + if ( musig_sendopretdecode(combined_pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { - if ( musig_spendopretdecode(check_pk,musig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) + if ( musig_spendopretdecode(checkpk,musig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) { - if ( combined_pk == check_pk ) + if ( combined_pk == checkpk ) { - msg = musig_prevoutmsg(tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); + musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) return eval->Invalid("failed schnorrsig_verify"); else return(true); From 30edb30e4aca089bbe7fe59246ae1b0aeff35485 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 07:47:39 -1100 Subject: [PATCH 2408/3904] Serialize pk -> combined_pk --- src/cc/musig.cpp | 76 ++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 6d2a1f583..561851640 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -21,63 +21,65 @@ #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 -CScript musig_sendopret(uint8_t funcid,secp256k1_pubkey combined_pk) +CScript musig_sendopret(uint8_t funcid,CPubKey pk) { CScript opret; uint8_t evalcode = EVAL_MUSIG; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << combined_pk); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); return(opret); } -uint8_t musig_sendopretdecode(secp256k1_pubkey &combined_pk,CScript scriptPubKey) +uint8_t musig_sendopretdecode(CPubKey &pk,CScript scriptPubKey) { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> combined_pk) != 0 && e == EVAL_MUSIG && f == 'x' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_MUSIG && f == 'x' ) { return(f); } return(0); } -CScript musig_spendopret(uint8_t funcid,secp256k1_pubkey combined_pk,secp256k1_schnorrsig musig) +CScript musig_spendopret(uint8_t funcid,CPubKey pk,secp256k1_schnorrsig musig) { CScript opret; uint8_t evalcode = EVAL_MUSIG; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << combined_pk << musig); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk << musig); return(opret); } -uint8_t musig_spendopretdecode(secp256k1_pubkey &combined_pk,secp256k1_schnorrsig &musig,CScript scriptPubKey) +uint8_t musig_spendopretdecode(CPubKey &pk,secp256k1_schnorrsig &musig,CScript scriptPubKey) { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> combined_pk; ss >> musig) != 0 && e == EVAL_MUSIG && f == 'y' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> musig) != 0 && e == EVAL_MUSIG && f == 'y' ) { return(f); } return(0); } -void musig_msghash(uint8_t *msg,uint256 prevhash,int32_t prevn,CTxOut vout,secp256k1_pubkey combined_pk) +int32_t musig_msghash(uint8_t *msg,uint256 prevhash,int32_t prevn,CTxOut vout,CPubKey pk) { CScript data; uint256 hash; int32_t len = 0; - data << E_MARSHAL(ss << prevhash << prevn << vout << combined_pk); + data << E_MARSHAL(ss << prevhash << prevn << vout << pk); fprintf(stderr,"data size %d\n",(int32_t)data.size()); - vcalc_sha256(0,msg,data.data(),data.size()); + vcalc_sha256(0,msg,data.begin(),data.size()); + return(0); } int32_t musig_prevoutmsg(uint8_t *msg,uint256 sendtxid,CScript scriptPubKey) { - CTransaction vintx; uint256 hashBlock; int32_t numvouts; CTxOut vout; secp256k1_pubkey combined_pk; + CTransaction vintx; uint256 hashBlock; int32_t numvouts; CTxOut vout; CPubKey pk; + memset(msg,0,32); if ( myGetTransaction(sendtxid,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { - if ( musig_sendopretdecode(combined_pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + if ( musig_sendopretdecode(pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { vout.nValue = vintx.vout[MUSIG_PREVN].nValue - MUSIG_TXFEE; vout.scriptPubKey = scriptPubKey; - return(musig_msghash(msg,sendtxid,MUSIG_PREVN,vout,combined_pk)); + return(musig_msghash(msg,sendtxid,MUSIG_PREVN,vout,pk)); } } - return(zeroid); + return(-1); } UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) @@ -184,15 +186,15 @@ UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( n == 2 && (hexstr= jstr(jitem(params,0),0)) != 0 && is_hexstr(hexstr,0) == 66 ) { - secp256k1_pubkey combined_pk(ParseHex(hexstr)); + CPubKey pk(ParseHex(hexstr)); amount = jdouble(jitem(params,1),0) * COIN + 0.0000000049; if ( amount >= 3*txfee && AddNormalinputs(mtx,mypk,amount+2*txfee,64) >= amount+2*txfee ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount+txfee,musigpk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_sendopret('x',combined_pk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_sendopret('x',pk)); return(musig_rawtxresult(result,rawtx)); } else return(cclib_error(result,"couldnt find funds or less than 0.0003")); - } else return(cclib_error(result,"must have 2 params: combined_pk, amount")); + } else return(cclib_error(result,"must have 2 params: pk, amount")); } else return(cclib_error(result,"not enough parameters")); } @@ -200,7 +202,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -221,15 +223,18 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { vout.nValue = vintx.vout[0].nValue - txfee; vout.scriptPubKey = scriptPubKey; - if ( musig_sendopretdecode(combined_pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + if ( musig_sendopretdecode(pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { - musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); - if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) - return(cclib_error(result,"musig didnt validate")); - mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); - mtx.vout.push_back(vout); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_spendopret('y',combined_pk,musig)); - return(musig_rawtxresult(result,rawtx)); + if ( secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) + { + musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); + if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) + return(cclib_error(result,"musig didnt validate")); + mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); + mtx.vout.push_back(vout); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_spendopret('y',pk,musig)); + return(musig_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt parse pk")); } else return(cclib_error(result,"couldnt decode send opret")); } else return(cclib_error(result,"couldnt find vin0")); } else return(cclib_error(result,"script or musig is not hex")); @@ -240,7 +245,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static secp256k1_context *ctx; - secp256k1_pubkey combined_pk,checkpk; secp256k1_schnorrsig musig; uint256 hashBlock; CTransaction vintx; int32_t numvouts; uint8_t msg[32]; + secp256k1_pubkey combined_pk; CPubKey pk,checkpk; secp256k1_schnorrsig musig; uint256 hashBlock; CTransaction vintx; int32_t numvouts; uint8_t msg[32]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( tx.vout.size() != 2 ) @@ -251,16 +256,19 @@ bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("illegal normal vin0"); else if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { - if ( musig_sendopretdecode(combined_pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + if ( musig_sendopretdecode(pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { if ( musig_spendopretdecode(checkpk,musig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) { - if ( combined_pk == checkpk ) + if ( pk == checkpk ) { - musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); - if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) - return eval->Invalid("failed schnorrsig_verify"); - else return(true); + if ( secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) + { + musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); + if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) + return eval->Invalid("failed schnorrsig_verify"); + else return(true); + } else return eval->Invalid("couldnt parse pk"); } else return eval->Invalid("combined_pk didnt match send opret"); } else return eval->Invalid("failed decode musig spendopret"); } else return eval->Invalid("couldnt decode send opret"); From 8de3c71baa8ab11903439d50f8e0191a326ce112 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 07:56:45 -1100 Subject: [PATCH 2409/3904] musig64 --- src/cc/musig.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 561851640..64d7528b6 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -39,18 +39,18 @@ uint8_t musig_sendopretdecode(CPubKey &pk,CScript scriptPubKey) return(0); } -CScript musig_spendopret(uint8_t funcid,CPubKey pk,secp256k1_schnorrsig musig) +CScript musig_spendopret(uint8_t funcid,CPubKey pk,std::vector musig64) { CScript opret; uint8_t evalcode = EVAL_MUSIG; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk << musig); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk << musig64); return(opret); } -uint8_t musig_spendopretdecode(CPubKey &pk,secp256k1_schnorrsig &musig,CScript scriptPubKey) +uint8_t musig_spendopretdecode(CPubKey &pk,std::vector &musig64,CScript scriptPubKey) { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> musig) != 0 && e == EVAL_MUSIG && f == 'y' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> musig64) != 0 && e == EVAL_MUSIG && f == 'y' ) { return(f); } @@ -62,7 +62,7 @@ int32_t musig_msghash(uint8_t *msg,uint256 prevhash,int32_t prevn,CTxOut vout,CP CScript data; uint256 hash; int32_t len = 0; data << E_MARSHAL(ss << prevhash << prevn << vout << pk); fprintf(stderr,"data size %d\n",(int32_t)data.size()); - vcalc_sha256(0,msg,data.begin(),data.size()); + vcalc_sha256(0,msg,data.begin(),(int32_t)data.size()); return(0); } @@ -212,12 +212,12 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) prevhash = juint256(jitem(params,0)); scriptstr = jstr(jitem(params,1),0); musigstr = jstr(jitem(params,2),0); - if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) != 0 ) + if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) != 128 ) { if ( txfee == 0 ) txfee = MUSIG_TXFEE; mypk = pubkey2pk(Mypubkey()); - secp256k1_schnorrsig musig(ParseHex(musigstr)); + std::vector musig64(ParseHex(musigstr)); CScript scriptPubKey(ParseHex(scriptstr)); if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { @@ -225,16 +225,17 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) vout.scriptPubKey = scriptPubKey; if ( musig_sendopretdecode(pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { - if ( secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) + if ( secp256k1_schnorrsig_parse(ctx,&musig,&musig64[0]) > 0 && + secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) { musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) return(cclib_error(result,"musig didnt validate")); mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); mtx.vout.push_back(vout); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_spendopret('y',pk,musig)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_spendopret('y',pk,musig64)); return(musig_rawtxresult(result,rawtx)); - } else return(cclib_error(result,"couldnt parse pk")); + } else return(cclib_error(result,"couldnt parse pk or musig")); } else return(cclib_error(result,"couldnt decode send opret")); } else return(cclib_error(result,"couldnt find vin0")); } else return(cclib_error(result,"script or musig is not hex")); @@ -245,7 +246,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static secp256k1_context *ctx; - secp256k1_pubkey combined_pk; CPubKey pk,checkpk; secp256k1_schnorrsig musig; uint256 hashBlock; CTransaction vintx; int32_t numvouts; uint8_t msg[32]; + secp256k1_pubkey combined_pk; CPubKey pk,checkpk; secp256k1_schnorrsig musig; uint256 hashBlock; CTransaction vintx; int32_t numvouts; std::vector musig64; uint8_t msg[32]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( tx.vout.size() != 2 ) @@ -258,17 +259,18 @@ bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( musig_sendopretdecode(pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { - if ( musig_spendopretdecode(checkpk,musig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) + if ( musig_spendopretdecode(checkpk,musig64,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) { if ( pk == checkpk ) { - if ( secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) + if ( secp256k1_schnorrsig_parse(ctx,&musig,&musig64[0]) > 0 && + secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) { musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) return eval->Invalid("failed schnorrsig_verify"); else return(true); - } else return eval->Invalid("couldnt parse pk"); + } else return eval->Invalid("couldnt parse pk or musig"); } else return eval->Invalid("combined_pk didnt match send opret"); } else return eval->Invalid("failed decode musig spendopret"); } else return eval->Invalid("couldnt decode send opret"); From 6ed384ff471be6653e0084f7b8fcf0e524e6611e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:07:05 -1100 Subject: [PATCH 2410/3904] Fixes --- src/cc/musig.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 64d7528b6..c12866865 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -62,7 +62,8 @@ int32_t musig_msghash(uint8_t *msg,uint256 prevhash,int32_t prevn,CTxOut vout,CP CScript data; uint256 hash; int32_t len = 0; data << E_MARSHAL(ss << prevhash << prevn << vout << pk); fprintf(stderr,"data size %d\n",(int32_t)data.size()); - vcalc_sha256(0,msg,data.begin(),(int32_t)data.size()); + hash = Hash(data.begin(),data.end()); + memcpy(msg,&hash,sizeof(hash)); return(0); } @@ -202,7 +203,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; secp256k1_schnorrsig musig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( (params= cclib_reparse(&n,params)) != 0 ) From fb69ddb0c66c37f949b3e007720162344c7e4b8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:12:36 -1100 Subject: [PATCH 2411/3904] Add modules --- src/secp256k1/Makefile.am | 5 ----- src/secp256k1/src/secp256k1.c | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 676415834..089d3ee8e 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -174,11 +174,6 @@ if ENABLE_MODULE_ECDH include src/modules/ecdh/Makefile.am.include endif -#if ENABLE_MODULE_MUSIG -include src/modules/schnorrsig/Makefile.am.include -include src/modules/musig/Makefile.am.include -#endif - if ENABLE_MODULE_RECOVERY include src/modules/recovery/Makefile.am.include endif diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index b89a7c04a..2cf57856b 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -580,6 +580,12 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif +#ifdef ENABLE_MODULE_MUSIG +#include "modules/schnorrsig/main_impl.h" +#include "modules/musig/main_impl.h" +#endif + + #ifdef ENABLE_MODULE_RECOVERY # include "modules/recovery/main_impl.h" #endif From 88d08c07fa1ebce2f59216f2719014e198a41d2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:17:34 -1100 Subject: [PATCH 2412/3904] secp256k1_nonce_function_bipschnorr --- src/secp256k1/src/secp256k1.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 2cf57856b..fbff4b3aa 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -340,6 +340,27 @@ static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *m return 1; } +/* This nonce function is described in BIP-schnorr + * (https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki) */ +static int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + secp256k1_sha256 sha; + (void) data; + (void) counter; + VERIFY_CHECK(counter == 0); + + /* Hash x||msg as per the spec */ + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, key32, 32); + secp256k1_sha256_write(&sha, msg32, 32); + /* Hash in algorithm, which is not in the spec, but may be critical to + * users depending on it to avoid nonce reuse across algorithms. */ + if (algo16 != NULL) { + secp256k1_sha256_write(&sha, algo16, 16); + } + secp256k1_sha256_finalize(&sha, nonce32); + return 1; +} + const secp256k1_nonce_function secp256k1_nonce_function_rfc6979 = nonce_function_rfc6979; const secp256k1_nonce_function secp256k1_nonce_function_default = nonce_function_rfc6979; From 6adebc5e7bf3a82cfbaf8b0b35e06df8a4cbaf6b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:19:37 -1100 Subject: [PATCH 2413/3904] Test --- src/secp256k1/src/modules/schnorrsig/main_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index b366236d8..6ccec1523 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -10,7 +10,7 @@ #include "include/secp256k1.h" #include "include/secp256k1_schnorrsig.h" #include "hash.h" - +hello int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { (void) ctx; VERIFY_CHECK(ctx != NULL); From 0a433f453bd4098de592b12219f545655aa04c06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:20:59 -1100 Subject: [PATCH 2414/3904] ENABLE_MODULE_MUSIG --- src/secp256k1/src/modules/schnorrsig/main_impl.h | 2 +- src/secp256k1/src/secp256k1.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index 6ccec1523..b366236d8 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -10,7 +10,7 @@ #include "include/secp256k1.h" #include "include/secp256k1_schnorrsig.h" #include "hash.h" -hello + int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { (void) ctx; VERIFY_CHECK(ctx != NULL); diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index fbff4b3aa..1f04af395 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -4,6 +4,7 @@ * file COPYING or http://www.opensource.org/licenses/mit-license.php.* **********************************************************************/ +#define ENABLE_MODULE_MUSIG #include "include/secp256k1.h" #include "util.h" From 965abd3d526caa3f87188cb62836b29a9f798115 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:23:06 -1100 Subject: [PATCH 2415/3904] Force include --- src/secp256k1/src/secp256k1.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 1f04af395..4c24c1084 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -4,7 +4,6 @@ * file COPYING or http://www.opensource.org/licenses/mit-license.php.* **********************************************************************/ -#define ENABLE_MODULE_MUSIG #include "include/secp256k1.h" #include "util.h" @@ -602,10 +601,10 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif -#ifdef ENABLE_MODULE_MUSIG +//#ifdef ENABLE_MODULE_MUSIG #include "modules/schnorrsig/main_impl.h" #include "modules/musig/main_impl.h" -#endif +//#endif #ifdef ENABLE_MODULE_RECOVERY From 5944b3e64fce54a06a5dbbe971fac12c617645cd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:25:10 -1100 Subject: [PATCH 2416/3904] Test --- src/secp256k1/src/secp256k1.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 4c24c1084..1c7b75bc5 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -601,10 +601,8 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif -//#ifdef ENABLE_MODULE_MUSIG #include "modules/schnorrsig/main_impl.h" #include "modules/musig/main_impl.h" -//#endif #ifdef ENABLE_MODULE_RECOVERY From 8de28666e0e18373444888d390be2ded4ea2795e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:34:19 -1100 Subject: [PATCH 2417/3904] $(LIBSECP256K1) --- src/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 395ff0352..22668c91f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -574,9 +574,9 @@ komodod_LDADD += \ $(LIBZCASH_LIBS) if TARGET_DARWIN -komodod_LDADD += libcc.dylib +komodod_LDADD += libcc.dylib $(LIBSECP256K1) else -komodod_LDADD += libcc.so +komodod_LDADD += libcc.so $(LIBSECP256K1) endif From 9ca5858eebdca923517dd5e786c6d63034dd2bcf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:41:10 -1100 Subject: [PATCH 2418/3904] Include secp --- src/cc/cclib.cpp | 1 + src/cc/makecclib | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 0d907d4ca..f02d63dbd 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -579,6 +579,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #else #include "sudoku.cpp" +#include "../secp256k1/src/secp256k1.c" #include "musig.cpp" #endif diff --git a/src/cc/makecclib b/src/cc/makecclib index 832cf1e96..871569325 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,2 +1,2 @@ #!/bin/sh -gcc -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +gcc -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp ../secp256k1/libsecp256k1.la From 38e67bca763fed2b6d2b618d5089019ac1b145fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:45:05 -1100 Subject: [PATCH 2419/3904] ../include --- src/cc/makecclib | 2 +- src/secp256k1/src/secp256k1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 871569325..f4d2bd01b 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,2 +1,2 @@ #!/bin/sh -gcc -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp ../secp256k1/libsecp256k1.la +gcc -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 1c7b75bc5..657893d0d 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -4,7 +4,7 @@ * file COPYING or http://www.opensource.org/licenses/mit-license.php.* **********************************************************************/ -#include "include/secp256k1.h" +#include "../include/secp256k1.h" #include "util.h" #include "num_impl.h" From b82b61d772c9b321ff662b49a888d8464051a8fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:50:03 -1100 Subject: [PATCH 2420/3904] -DSECP256K1_BUILD --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f02d63dbd..3cfb1a185 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -579,6 +579,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #else #include "sudoku.cpp" +#define SECP256K1_BUILD #include "../secp256k1/src/secp256k1.c" #include "musig.cpp" #endif From 8ce89adfe711d8972d72c48b4cd8442cd65ca349 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:55:49 -1100 Subject: [PATCH 2421/3904] Basic-config --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 3cfb1a185..88fa9b554 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -579,7 +579,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #else #include "sudoku.cpp" -#define SECP256K1_BUILD +#include "../secp256k1/src/basic-config.h" #include "../secp256k1/src/secp256k1.c" #include "musig.cpp" #endif From d745071b2abc938668eaea61517a00fcb35c332a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 08:59:00 -1100 Subject: [PATCH 2422/3904] USE_BASIC_CONFIG --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 88fa9b554..1fc8c45a7 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -579,6 +579,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #else #include "sudoku.cpp" +#define USE_BASIC_CONFIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/src/secp256k1.c" #include "musig.cpp" From 5d7ffa476033156a598430775e57e6992e839e66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:01:29 -1100 Subject: [PATCH 2423/3904] ../../.. --- src/secp256k1/src/modules/musig/main_impl.h | 4 ++-- src/secp256k1/src/modules/schnorrsig/main_impl.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/secp256k1/src/modules/musig/main_impl.h b/src/secp256k1/src/modules/musig/main_impl.h index dece823d6..8bd2f1831 100644 --- a/src/secp256k1/src/modules/musig/main_impl.h +++ b/src/secp256k1/src/modules/musig/main_impl.h @@ -8,8 +8,8 @@ #ifndef _SECP256K1_MODULE_MUSIG_MAIN_ #define _SECP256K1_MODULE_MUSIG_MAIN_ -#include "include/secp256k1.h" -#include "include/secp256k1_musig.h" +#include "../../../include/secp256k1.h" +#include "../../../include/secp256k1_musig.h" #include "hash.h" /* Computes ell = SHA256(pk[0], ..., pk[np-1]) */ diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index b366236d8..f2b418159 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -7,8 +7,8 @@ #ifndef _SECP256K1_MODULE_SCHNORRSIG_MAIN_ #define _SECP256K1_MODULE_SCHNORRSIG_MAIN_ -#include "include/secp256k1.h" -#include "include/secp256k1_schnorrsig.h" +#include "../../../include/secp256k1.h" +#include "../../../include/secp256k1_schnorrsig.h" #include "hash.h" int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { From 96c6f295339ddb1f9f5f92b55e41fa4b33ec4ea4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:06:09 -1100 Subject: [PATCH 2424/3904] Define funds --- src/secp256k1/src/modules/schnorrsig/main_impl.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index f2b418159..9a08e81d8 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -11,6 +11,9 @@ #include "../../../include/secp256k1_schnorrsig.h" #include "hash.h" +static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); + int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { (void) ctx; VERIFY_CHECK(ctx != NULL); From 23a530ae4ebb7dc2f23c06aeecce591a9fc2c117 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:09:43 -1100 Subject: [PATCH 2425/3904] static int secp256k1_musig_pubkey_combine_callback(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data) --- src/secp256k1/src/modules/schnorrsig/main_impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index 9a08e81d8..00f241020 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -13,6 +13,7 @@ static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { (void) ctx; From c1264e8ddb42fae26bb3c128ae204391416706e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:12:08 -1100 Subject: [PATCH 2426/3904] Reorder --- src/secp256k1/src/modules/schnorrsig/main_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index 00f241020..2eb939f55 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -11,9 +11,9 @@ #include "../../../include/secp256k1_schnorrsig.h" #include "hash.h" +typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); -typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { (void) ctx; From dfb71e518242d8ea2bef87a9cb2647e5915c1542 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:14:59 -1100 Subject: [PATCH 2427/3904] e tes --- src/cc/cclib.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 1fc8c45a7..33b76ff91 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -579,9 +579,9 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #else #include "sudoku.cpp" -#define USE_BASIC_CONFIG -#include "../secp256k1/src/basic-config.h" -#include "../secp256k1/src/secp256k1.c" +//#define USE_BASIC_CONFIG +//#include "../secp256k1/src/basic-config.h" +//#include "../secp256k1/src/secp256k1.c" #include "musig.cpp" #endif From e4494dc1207d38a16a26166c760c417b8bab1197 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:16:35 -1100 Subject: [PATCH 2428/3904] Test --- src/cc/musig.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index c12866865..34561d820 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -14,9 +14,9 @@ ******************************************************************************/ -#include -#include -#include +#include "../secp256k1/include/secp256k1.h" +#include "../secp256k1/include/secp256k1_schnorrsig.h" +#include "../secp256k1/include/secp256k1_musig.h" #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 From 60122c9eeca2a91331eae3ed8dd50c8369552fbe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:23:32 -1100 Subject: [PATCH 2429/3904] (const uint8_t *) --- src/cc/musig.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 34561d820..800102e13 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -226,11 +226,11 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) vout.scriptPubKey = scriptPubKey; if ( musig_sendopretdecode(pk,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { - if ( secp256k1_schnorrsig_parse(ctx,&musig,&musig64[0]) > 0 && + if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) { musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); - if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) + if ( !secp256k1_schnorrsig_verify((const secp256k1_context *)ctx,&musig,(const uint8_t *)msg,(const secp256k1_pubkey *)&combined_pk) ) return(cclib_error(result,"musig didnt validate")); mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); mtx.vout.push_back(vout); @@ -264,11 +264,11 @@ bool musig_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( pk == checkpk ) { - if ( secp256k1_schnorrsig_parse(ctx,&musig,&musig64[0]) > 0 && + if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) { musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); - if ( !secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) ) + if ( !secp256k1_schnorrsig_verify((const secp256k1_context *)ctx,&musig,(const uint8_t *)msg,(const secp256k1_pubkey *)&combined_pk) ) return eval->Invalid("failed schnorrsig_verify"); else return(true); } else return eval->Invalid("couldnt parse pk or musig"); From 6cdecbe7f78ddf29eeab4368f150dbeb7a302e7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:30:27 -1100 Subject: [PATCH 2430/3904] Pull in schnorr --- src/komodo_gateway.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 02ab67407..35952bebf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -16,6 +16,17 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse #include "komodo_defs.h" +#include "secp256k1/include/secp256k1.h" +#include "secp256k1/include/secp256k1_schnorrsig.h" +#include "secp256k1/include/secp256k1_musig.h" + +void dummy_linker_tricker() +{ + secp256k1_context *ctx = 0; std::vector musig64; CPubKey pk; secp256k1_schnorrsig musig; secp256k1_pubkey combined_pk; + if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) + return(1); +} + int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx); int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) From bb07e87c4a993b12b0fc43c91b0bf677f15e185b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:31:44 -1100 Subject: [PATCH 2431/3904] Int32 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 35952bebf..5dd9907c9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -20,7 +20,7 @@ #include "secp256k1/include/secp256k1_schnorrsig.h" #include "secp256k1/include/secp256k1_musig.h" -void dummy_linker_tricker() +int32_t dummy_linker_tricker() { secp256k1_context *ctx = 0; std::vector musig64; CPubKey pk; secp256k1_schnorrsig musig; secp256k1_pubkey combined_pk; if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) From befefc81c9e22b9f1a191ee3d5012dcf26113254 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:34:07 -1100 Subject: [PATCH 2432/3904] Test --- src/komodo_gateway.h | 4 ++-- src/secp256k1/src/modules/schnorrsig/main_impl.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5dd9907c9..68e648b14 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -16,7 +16,7 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse #include "komodo_defs.h" -#include "secp256k1/include/secp256k1.h" +/*#include "secp256k1/include/secp256k1.h" #include "secp256k1/include/secp256k1_schnorrsig.h" #include "secp256k1/include/secp256k1_musig.h" @@ -25,7 +25,7 @@ int32_t dummy_linker_tricker() secp256k1_context *ctx = 0; std::vector musig64; CPubKey pk; secp256k1_schnorrsig musig; secp256k1_pubkey combined_pk; if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) return(1); -} +}*/ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx); diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index 2eb939f55..925c49d2a 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -25,6 +25,7 @@ int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char * } int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64) { + parse is here (void) ctx; VERIFY_CHECK(ctx != NULL); ARG_CHECK(sig != NULL); From 0fe4fdd07cbac8b174db05227f398315be1690ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:43:00 -1100 Subject: [PATCH 2433/3904] Disable for now --- src/cc/cclib.cpp | 2 +- src/secp256k1/src/modules/schnorrsig/main_impl.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 33b76ff91..75dd13fa2 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -582,6 +582,6 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will //#define USE_BASIC_CONFIG //#include "../secp256k1/src/basic-config.h" //#include "../secp256k1/src/secp256k1.c" -#include "musig.cpp" +//#include "musig.cpp" #endif diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index 925c49d2a..2eb939f55 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -25,7 +25,6 @@ int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char * } int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64) { - parse is here (void) ctx; VERIFY_CHECK(ctx != NULL); ARG_CHECK(sig != NULL); From 33c9f37abe0da91e990047e3204c0f989cb713af Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:45:12 -1100 Subject: [PATCH 2434/3904] Enable --- src/cc/cclib.cpp | 2 +- src/secp256k1/src/modules/schnorrsig/main_impl.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 75dd13fa2..33b76ff91 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -582,6 +582,6 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will //#define USE_BASIC_CONFIG //#include "../secp256k1/src/basic-config.h" //#include "../secp256k1/src/secp256k1.c" -//#include "musig.cpp" +#include "musig.cpp" #endif diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index 2eb939f55..a99897d2c 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -11,9 +11,9 @@ #include "../../../include/secp256k1_schnorrsig.h" #include "hash.h" -typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); -static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +//typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); +//static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +//static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { (void) ctx; From 3c802c4a0219207903151d7ca483665a749d37a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 09:53:09 -1100 Subject: [PATCH 2435/3904] -// --- src/secp256k1/src/modules/schnorrsig/main_impl.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index a99897d2c..f2b418159 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -11,10 +11,6 @@ #include "../../../include/secp256k1_schnorrsig.h" #include "hash.h" -//typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); -//static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); -//static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); - int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig) { (void) ctx; VERIFY_CHECK(ctx != NULL); From ea3e9ee36a7fb89f48aecc824ce18050de53848c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 10:01:21 -1100 Subject: [PATCH 2436/3904] Parse --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 68e648b14..5dd9907c9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -16,7 +16,7 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse #include "komodo_defs.h" -/*#include "secp256k1/include/secp256k1.h" +#include "secp256k1/include/secp256k1.h" #include "secp256k1/include/secp256k1_schnorrsig.h" #include "secp256k1/include/secp256k1_musig.h" @@ -25,7 +25,7 @@ int32_t dummy_linker_tricker() secp256k1_context *ctx = 0; std::vector musig64; CPubKey pk; secp256k1_schnorrsig musig; secp256k1_pubkey combined_pk; if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) return(1); -}*/ +} int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx); From 5280af8c12010d7cc7929651fc7d92337d4a2368 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 10:13:16 -1100 Subject: [PATCH 2437/3904] Revert --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5dd9907c9..68e648b14 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -16,7 +16,7 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse #include "komodo_defs.h" -#include "secp256k1/include/secp256k1.h" +/*#include "secp256k1/include/secp256k1.h" #include "secp256k1/include/secp256k1_schnorrsig.h" #include "secp256k1/include/secp256k1_musig.h" @@ -25,7 +25,7 @@ int32_t dummy_linker_tricker() secp256k1_context *ctx = 0; std::vector musig64; CPubKey pk; secp256k1_schnorrsig musig; secp256k1_pubkey combined_pk; if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) return(1); -} +}*/ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx); From 0594b52df25a3b8096ac18e99ed02f283c8d320a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 20:33:13 -1100 Subject: [PATCH 2438/3904] Big buffer --- .gitignore | 10 ++++++++++ src/cc/rogue/init.c | 1 + src/cc/rogue/io.c | 12 ++++++++++++ src/cc/rogue/rip.c | 2 +- src/cc/rogue/rogue.c | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ebaa71f4d..2f97780ab 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,13 @@ src/cc/rogue/rogue src/cc/rogue/rogue.so src/cc/rogue/test.zip + +src/rogue.530623577502174316.0 + +src/rogue.530623577502174316.pack + +src/rogue.530623577502174316.player + +src/checkfile + +src/log diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index ffc0b3707..b11cfa80c 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -34,6 +34,7 @@ void restore_player(struct rogue_state *rs) int32_t i,total = 0; THING *obj; //rs->P.gold = purse; max_hp = rs->P.hitpoints; + //pstats.s_hpt = max_hp; pstats.s_str = rs->P.strength & 0xffff; if ( (max_stats.s_str= (rs->P.strength >> 16) & 0xffff) == 0 ) max_stats.s_str = 16; diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 9842ba353..994f112e2 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,6 +160,18 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; + if ( 0 ) + { + static FILE *fp; static int32_t counter; + if ( fp == 0 ) + fp = fopen("log","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%d: (%c) hp.%d\n",counter,c,pstats.s_hpt); + fflush(fp); + counter++; + } + } while ( c == 'Q' && rs->ind < rs->numkeys ) { //fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index 65be2e8fa..1866f0b48 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -238,7 +238,7 @@ death(struct rogue_state *rs,char monst) //struct tm *localtime(const time_t *); if ( rs->guiflag == 0 ) { - fprintf(stderr,"death during replay\n"); + fprintf(stderr,"death during replay by (%c)\n",monst); //sleep(3); rs->replaydone = (uint32_t)time(NULL); return; } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 92d3ad378..2f4545585 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -607,7 +607,7 @@ playit(struct rogue_state *rs) } else { - if ( rs->needflush != 0 && rs->num > 1024 ) + if ( rs->needflush != 0 && rs->num > 8000 ) { if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; From 23caa3477367a08556128a329ffd1ba602591fef Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 21:33:25 -1100 Subject: [PATCH 2439/3904] Allow zombies --- .gitignore | 2 + src/cc/rogue/main.c | 514 +++++++++++++++++++++++++++++++++++++++++++ src/cc/rogue/rogue.c | 71 +----- src/cc/rogue/rogue.h | 4 +- src/cc/rogue/state.c | 2 +- src/cc/rogue_rpc.cpp | 2 +- 6 files changed, 526 insertions(+), 69 deletions(-) diff --git a/.gitignore b/.gitignore index 2f97780ab..0d0846e31 100644 --- a/.gitignore +++ b/.gitignore @@ -142,3 +142,5 @@ src/rogue.530623577502174316.player src/checkfile src/log + +src/foo.zip diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index c0fa36752..1131e3429 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -20,10 +20,17 @@ #include #include #include +#include +#include + +char USERPASS[8192]; +char Gametxidstr[67]; #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) #define dstr(x) ((double)(x) / SATOSHIDEN) +#define KOMODO_ASSETCHAIN_MAXLEN 65 +#define ASSETCHAINS_SYMBOL "ROGUE" #ifndef _BITS256 #define _BITS256 @@ -31,6 +38,15 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif +double OS_milliseconds() +{ + struct timeval tv; double millis; + gettimeofday(&tv,NULL); + millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.); + //printf("tv_sec.%ld usec.%d %f\n",tv.tv_sec,tv.tv_usec,millis); + return(millis); +} + int32_t _unhex(char c) { if ( c >= '0' && c <= '9' ) @@ -167,6 +183,23 @@ char *clonestr(char *str) strcpy(clone,str); return(clone); } + +char *parse_conf_line(char *line,char *field) +{ + line += strlen(field); + for (; *line!='='&&*line!=0; line++) + break; + if ( *line == 0 ) + return(0); + if ( *line == '=' ) + line++; + while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' ) + line[strlen(line)-1] = 0; + //printf("LINE.(%s)\n",line); + _stripwhite(line,0); + return(clonestr(line)); +} + int32_t safecopy(char *dest,char *src,long len) { int32_t i = -1; @@ -246,6 +279,487 @@ uint8_t *OS_fileptr(long *allocsizep,char *fname) return((uint8_t *)retptr); } +struct MemoryStruct { char *memory; size_t size; }; +struct return_string { char *ptr; size_t len; }; + +// return data from the server +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_SSL (1<<0) +#define CURL_GLOBAL_WIN32 (1<<1) + + +/************************************************************************ + * + * Initialize the string handler so that it is thread safe + * + ************************************************************************/ + +void init_string(struct return_string *s) +{ + s->len = 0; + s->ptr = (char *)calloc(1,s->len+1); + if ( s->ptr == NULL ) + { + fprintf(stderr,"init_string malloc() failed\n"); + exit(-1); + } + s->ptr[0] = '\0'; +} + +/************************************************************************ + * + * Use the "writer" to accumulate text until done + * + ************************************************************************/ + +size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *s) +{ + size_t new_len = s->len + size*nmemb; + s->ptr = (char *)realloc(s->ptr,new_len+1); + if ( s->ptr == NULL ) + { + fprintf(stderr, "accumulate realloc() failed\n"); + exit(-1); + } + memcpy(s->ptr+s->len,ptr,size*nmemb); + s->ptr[new_len] = '\0'; + s->len = new_len; + return(size * nmemb); +} + +/************************************************************************ + * + * return the current system time in milliseconds + * + ************************************************************************/ + +#define EXTRACT_BITCOIND_RESULT // if defined, ensures error is null and returns the "result" field +#ifdef EXTRACT_BITCOIND_RESULT + +/************************************************************************ + * + * perform post processing of the results + * + ************************************************************************/ + +char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params) +{ + long i,j,len; char *retstr = 0; cJSON *json,*result,*error; + //printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); + if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 ) + { + if ( strcmp(command,"signrawtransaction") != 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); + return(rpcstr); + } + json = cJSON_Parse(rpcstr); + if ( json == 0 ) + { + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s) params.(%s)\n",debugstr,command,rpcstr,params); + free(rpcstr); + return(0); + } + result = cJSON_GetObjectItem(json,"result"); + error = cJSON_GetObjectItem(json,"error"); + if ( error != 0 && result != 0 ) + { + if ( (error->type&0xff) == cJSON_NULL && (result->type&0xff) != cJSON_NULL ) + { + retstr = cJSON_Print(result); + len = strlen(retstr); + if ( retstr[0] == '"' && retstr[len-1] == '"' ) + { + for (i=1,j=0; itype&0xff) != cJSON_NULL || (result->type&0xff) != cJSON_NULL ) + { + if ( strcmp(command,"signrawtransaction") != 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr); + } + free(rpcstr); + } else retstr = rpcstr; + free_json(json); + //fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: postprocess returns.(%s)\n",retstr); + return(retstr); +} +#endif + +/************************************************************************ + * + * perform the query + * + ************************************************************************/ + +char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params) +{ + static int didinit,count,count2; static double elapsedsum,elapsedsum2; + struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle; + char *bracket0,*bracket1,*databuf = 0; long len; int32_t specialcase,numretries; double starttime; + if ( didinit == 0 ) + { + didinit = 1; + curl_global_init(CURL_GLOBAL_ALL); //init the curl session + } + numretries = 0; + if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 ) + specialcase = 1; + else specialcase = 0; + if ( url[0] == 0 ) + strcpy(url,"http://127.0.0.1:7876/nxt"); + if ( specialcase != 0 && 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params); +try_again: + if ( retstrp != 0 ) + *retstrp = 0; + starttime = OS_milliseconds(); + curl_handle = curl_easy_init(); + init_string(&s); + headers = curl_slist_append(0,"Expect:"); + + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl_handle,CURLOPT_URL, url); + curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function + curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback + curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash + curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback + if ( strncmp(url,"https",5) == 0 ) + { + curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,0); + curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYHOST,0); + } + if ( userpass != 0 ) + curl_easy_setopt(curl_handle,CURLOPT_USERPWD, userpass); + databuf = 0; + if ( params != 0 ) + { + if ( command != 0 && specialcase == 0 ) + { + len = strlen(params); + if ( len > 0 && params[0] == '[' && params[len-1] == ']' ) { + bracket0 = bracket1 = (char *)""; + } + else + { + bracket0 = (char *)"["; + bracket1 = (char *)"]"; + } + + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); + sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); + //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); + // + } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); + curl_easy_setopt(curl_handle,CURLOPT_POST,1L); + if ( databuf != 0 ) + curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,databuf); + else curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,params); + } + //laststart = milliseconds(); + res = curl_easy_perform(curl_handle); + curl_slist_free_all(headers); + curl_easy_cleanup(curl_handle); + if ( databuf != 0 ) // clean up temporary buffer + { + free(databuf); + databuf = 0; + } + if ( res != CURLE_OK ) + { + numretries++; + if ( specialcase != 0 ) + { + printf("<<<<<<<<<<< bitcoind_RPC.(%s): BTCD.%s timeout params.(%s) s.ptr.(%s) err.%d\n",url,command,params,s.ptr,res); + free(s.ptr); + return(0); + } + else if ( numretries >= 1 ) + { + //printf("Maximum number of retries exceeded!\n"); + free(s.ptr); + return(0); + } + if ( (rand() % 1000) == 0 ) + printf( "curl_easy_perform() failed: %s %s.(%s %s), retries: %d\n",curl_easy_strerror(res),debugstr,url,command,numretries); + free(s.ptr); + sleep((1< (%s)\n",params,s.ptr); + count2++; + elapsedsum2 += (OS_milliseconds() - starttime); + if ( (count2 % 10000) == 0) + printf("%d: ave %9.6f | elapsed %.3f millis | NXT calls.(%s) cmd.(%s)\n",count2,elapsedsum2/count2,(double)(OS_milliseconds() - starttime),url,command); + return(s.ptr); + } + } + printf("bitcoind_RPC: impossible case\n"); + free(s.ptr); + return(0); +} + +static size_t WriteMemoryCallback(void *ptr,size_t size,size_t nmemb,void *data) +{ + size_t realsize = (size * nmemb); + struct MemoryStruct *mem = (struct MemoryStruct *)data; + mem->memory = (char *)((ptr != 0) ? realloc(mem->memory,mem->size + realsize + 1) : malloc(mem->size + realsize + 1)); + if ( mem->memory != 0 ) + { + if ( ptr != 0 ) + memcpy(&(mem->memory[mem->size]),ptr,realsize); + mem->size += realsize; + mem->memory[mem->size] = 0; + } + //printf("got %d bytes\n",(int32_t)(size*nmemb)); + return(realsize); +} + +char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *hdr0,char *hdr1,char *hdr2,char *hdr3) +{ + struct MemoryStruct chunk; CURL *cHandle; long code; struct curl_slist *headers = 0; + if ( (cHandle= *cHandlep) == NULL ) + *cHandlep = cHandle = curl_easy_init(); + else curl_easy_reset(cHandle); + //#ifdef DEBUG + //curl_easy_setopt(cHandle,CURLOPT_VERBOSE, 1); + //#endif + curl_easy_setopt(cHandle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + curl_easy_setopt(cHandle,CURLOPT_SSL_VERIFYPEER,0); + //curl_easy_setopt(cHandle,CURLOPT_SSLVERSION,1); + curl_easy_setopt(cHandle,CURLOPT_URL,url); + curl_easy_setopt(cHandle,CURLOPT_CONNECTTIMEOUT,10); + if ( userpass != 0 && userpass[0] != 0 ) + curl_easy_setopt(cHandle,CURLOPT_USERPWD,userpass); + if ( postfields != 0 && postfields[0] != 0 ) + { + curl_easy_setopt(cHandle,CURLOPT_POST,1); + curl_easy_setopt(cHandle,CURLOPT_POSTFIELDS,postfields); + } + if ( hdr0 != NULL && hdr0[0] != 0 ) + { + //printf("HDR0.(%s) HDR1.(%s) HDR2.(%s) HDR3.(%s)\n",hdr0!=0?hdr0:"",hdr1!=0?hdr1:"",hdr2!=0?hdr2:"",hdr3!=0?hdr3:""); + headers = curl_slist_append(headers,hdr0); + if ( hdr1 != 0 && hdr1[0] != 0 ) + headers = curl_slist_append(headers,hdr1); + if ( hdr2 != 0 && hdr2[0] != 0 ) + headers = curl_slist_append(headers,hdr2); + if ( hdr3 != 0 && hdr3[0] != 0 ) + headers = curl_slist_append(headers,hdr3); + } //headers = curl_slist_append(0,"Expect:"); + if ( headers != 0 ) + curl_easy_setopt(cHandle,CURLOPT_HTTPHEADER,headers); + //res = curl_easy_perform(cHandle); + memset(&chunk,0,sizeof(chunk)); + curl_easy_setopt(cHandle,CURLOPT_WRITEFUNCTION,WriteMemoryCallback); + curl_easy_setopt(cHandle,CURLOPT_WRITEDATA,(void *)&chunk); + curl_easy_perform(cHandle); + curl_easy_getinfo(cHandle,CURLINFO_RESPONSE_CODE,&code); + if ( headers != 0 ) + curl_slist_free_all(headers); + if ( code != 200 ) + printf("(%s) server responded with code %ld (%s)\n",url,code,chunk.memory); + return(chunk.memory); +} + +#ifdef autoextract +uint16_t _komodo_userpass(char *username,char *password,FILE *fp) +{ + char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0; + rpcuser = rpcpassword = 0; + username[0] = password[0] = 0; + while ( fgets(line,sizeof(line),fp) != 0 ) + { + if ( line[0] == '#' ) + continue; + //printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword")); + if ( (str= strstr(line,(char *)"rpcuser")) != 0 ) + rpcuser = parse_conf_line(str,(char *)"rpcuser"); + else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) + rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); + else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) + { + port = atoi(parse_conf_line(str,(char *)"rpcport")); + //fprintf(stderr,"rpcport.%u in file\n",port); + } + } + if ( rpcuser != 0 && rpcpassword != 0 ) + { + strcpy(username,rpcuser); + strcpy(password,rpcpassword); + } + //printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port); + if ( rpcuser != 0 ) + free(rpcuser); + if ( rpcpassword != 0 ) + free(rpcpassword); + return(port); +} + +void komodo_statefname(char *fname,char *symbol,char *str) +{ + int32_t n,len; + sprintf(fname,"%s",getDataDir()); + if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 ) + { + len = (int32_t)strlen(fname); + if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 ) + fname[len - n] = 0; + else + { + printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]); + return; + } + } + else + { +#ifdef _WIN32 + strcat(fname,"\\"); +#else + strcat(fname,"/"); +#endif + } + if ( symbol != 0 && symbol[0] != 0 && strcmp("KMD",symbol) != 0 ) + { + strcat(fname,symbol); + //printf("statefname.(%s) -> (%s)\n",symbol,fname); +#ifdef _WIN32 + strcat(fname,"\\"); +#else + strcat(fname,"/"); +#endif + } + strcat(fname,str); + //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname); +} + +uint16_t komodo_userpass(char *userpass,char *symbol) +{ + FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[KOMODO_ASSETCHAIN_MAXLEN]; + userpass[0] = 0; + if ( strcmp("KMD",symbol) == 0 ) + { +#ifdef __APPLE__ + sprintf(confname,"Komodo.conf"); +#else + sprintf(confname,"komodo.conf"); +#endif + } + else sprintf(confname,"%s.conf",symbol); + komodo_statefname(fname,symbol,confname); + if ( (fp= fopen(fname,"rb")) != 0 ) + { + port = _komodo_userpass(username,password,fp); + sprintf(userpass,"%s:%s",username,password); + if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 ) + strcpy(USERPASS,userpass); + fclose(fp); + } + return(port); +} +#endif + +#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) + +char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) +{ + //static void *cHandle; + char url[512],*retstr=0,*retstr2=0,postdata[8192]; + if ( params == 0 || params[0] == 0 ) + params = (char *)"[]"; + if ( strlen(params) < sizeof(postdata)-128 ) + { + sprintf(url,(char *)"http://127.0.0.1:%u",port); + sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); + //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); + retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); + //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); + } + return(retstr2); +} + +#include "rogue.h" + +void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) +{ + char cmd[16384],hexstr[16384]; int32_t i; + if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) + { + for (i=0; i> keystrokes.log",Gametxidstr,hexstr); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + } +} + +int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) +{ + char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + if ( rs->guiflag == 0 ) + return(-1); + if ( gametxidstr == 0 || *gametxidstr == 0 ) + return(retval); + sprintf(fname,"%s.gameinfo",gametxidstr); + sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + else + { + filestr = (char *)OS_fileptr(&allocsize,fname); + if ( (retjson= cJSON_Parse(filestr)) != 0 ) + { + if ( (array= jarray(&n,retjson,"players")) != 0 ) + { + for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); + fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0)); + rs->restoring = 1; + } + } + } + } + } + free_json(retjson); + } + free(filestr); + } + return(retval); +} + int main(int argc, char **argv, char **envp) { uint64_t seed; FILE *fp = 0; diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 2f4545585..7e5a53fe5 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -26,7 +26,6 @@ */ struct rogue_state globalR; void garbage_collect(); -char Gametxidstr[67]; void purge_obj_guess(struct obj_info *array,int32_t n) { @@ -152,71 +151,11 @@ int32_t flushkeystrokes(struct rogue_state *rs) } #else -uint8_t *OS_fileptr(long *allocsizep,char *fname); -#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) - -int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) -{ - char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; - if ( gametxidstr == 0 || *gametxidstr == 0 ) - return(retval); - sprintf(fname,"%s.gameinfo",gametxidstr); - sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); - else - { - filestr = (char *)OS_fileptr(&allocsize,fname); - if ( (retjson= cJSON_Parse(filestr)) != 0 ) - { - if ( (array= jarray(&n,retjson,"players")) != 0 ) - { - for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); - fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0)); - rs->restoring = 1; - } - } - } - } - } - free_json(retjson); - } - free(filestr); - } - return(retval); -} - -void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) -{ - char cmd[16384],hexstr[16384]; int32_t i; - if ( Gametxidstr[0] != 0 ) - { - for (i=0; i> keystrokes.log",Gametxidstr,hexstr); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); - } -} - int32_t flushkeystrokes(struct rogue_state *rs) { if ( rs->num > 0 ) { - rogue_progress(rs->seed,rs->buffered,rs->num); + rogue_progress(rs,rs->seed,rs->buffered,rs->num); memset(rs->buffered,0,sizeof(rs->buffered)); rs->counter++; rs->num = 0; @@ -230,10 +169,10 @@ void rogue_bailout(struct rogue_state *rs) flushkeystrokes(rs); //sleep(5); return; - fprintf(stderr,"bailing out\n"); + /*fprintf(stderr,"bailing out\n"); sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr); if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); + fprintf(stderr,"error issuing (%s)\n",cmd);*/ } int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis) @@ -356,6 +295,8 @@ int rogue(int argc, char **argv, char **envp) { char *env; int lowtime; struct rogue_state *rs = &globalR; memset(rs,0,sizeof(*rs)); + rs->guiflag = 1; + rs->sleeptime = 1; // non-zero to allow refresh() if ( argc == 3 && strlen(argv[2]) == 64 ) { rs->seed = atol(argv[1]); @@ -366,8 +307,6 @@ int rogue(int argc, char **argv, char **envp) return(-1); } } else rs->seed = 777; - rs->guiflag = 1; - rs->sleeptime = 1; // non-zero to allow refresh() md_init(); #ifdef MASTER diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f687b170c..802dd5f64 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -370,7 +370,7 @@ struct rogue_state uint8_t playerdata[10000]; }; extern struct rogue_state globalR; - +extern char Gametxidstr[67]; int rogue(int argc, char **argv, char **envp); void rogueiterate(struct rogue_state *rs); @@ -380,6 +380,8 @@ int32_t rogue_restorepack(struct rogue_state *rs); void restore_player(struct rogue_state *rs); int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); void rogue_bailout(struct rogue_state *rs); +void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num); +int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr); #define ROGUE_MAXTOTAL (pstats.s_str*2) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 589f77422..7a0e2e4c6 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1432,7 +1432,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) if ( o->_o._o_packch != 0 ) { item = &rs->P.roguepack[rs->P.packsize]; - if ( pstats.s_hpt <= 0 ) + if ( 0 && pstats.s_hpt <= 0 ) { //fprintf(stderr,"KILLED\n"); rs->P.gold = -1; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8ca239c7b..2d34d27c8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1005,7 +1005,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - if ( P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) + if ( 0 && (P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0) ) { fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); From a08a6f3be4a9dce2379a8a1b0057e4ed05a8fa21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 21:35:14 -1100 Subject: [PATCH 2440/3904] -lcurl --- src/cc/rogue/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/Makefile.in b/src/cc/rogue/Makefile.in index c53ece6ac..2669a2025 100644 --- a/src/cc/rogue/Makefile.in +++ b/src/cc/rogue/Makefile.in @@ -28,8 +28,8 @@ CC = @CC@ #CFLAGS=-O2 CFLAGS= @CFLAGS@ -fPIC -#LIBS=-lcurses -LIBS = @LIBS@ +LIBS=-lcurses -lcurl +#LIBS = @LIBS@ #RM=rm -f RM = rm -f From 0514250ce31de0ebe26e23e09c39b2af036baa6e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:07:25 -1100 Subject: [PATCH 2441/3904] Attempt curl. Will be broken until debugged --- .gitignore | 8 ++ src/cc/rogue/config.h | 270 ------------------------------------------ src/cc/rogue/main.c | 77 ++++++++---- 3 files changed, 65 insertions(+), 290 deletions(-) delete mode 100644 src/cc/rogue/config.h diff --git a/.gitignore b/.gitignore index 0d0846e31..030c9dc5a 100644 --- a/.gitignore +++ b/.gitignore @@ -144,3 +144,11 @@ src/checkfile src/log src/foo.zip + +src/cc/rogue/config.h + +src/cc/rogue/config.h + +src/ROGUE.conf + +src/rogue.scr diff --git a/src/cc/rogue/config.h b/src/cc/rogue/config.h deleted file mode 100644 index 558ae3ba1..000000000 --- a/src/cc/rogue/config.h +++ /dev/null @@ -1,270 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if scorefile is top scores, not top players */ -#define ALLSCORES 1 - -/* Define if checktime feature should be enabled */ -/* #undef CHECKTIME */ - -/* Define to group owner of setgid executable */ -/* #undef GROUPOWNER */ - -/* Define to 1 if you have the `alarm' function. */ -#define HAVE_ALARM 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ARPA_INET_H 1 - -/* Define to 1 if libcurses is requested */ -#define HAVE_CURSES_H 1 - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -/* #undef HAVE_DOPRNT */ - -/* Define to 1 if you have the `erasechar' function. */ -#define HAVE_ERASECHAR 1 - -/* Define if ncurses has ESCDELAY variable */ -#define HAVE_ESCDELAY 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `fork' function. */ -#define HAVE_FORK 1 - -/* Define to 1 if you have the `getgid' function. */ -#define HAVE_GETGID 1 - -/* Define to 1 if you have the `getloadavg' function. */ -#define HAVE_GETLOADAVG 1 - -/* Define to 1 if you have the `getpass' function. */ -#define HAVE_GETPASS 1 - -/* Define to 1 if you have the `getpwuid' function. */ -#define HAVE_GETPWUID 1 - -/* Define to 1 if you have the `getuid' function. */ -#define HAVE_GETUID 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `killchar' function. */ -#define HAVE_KILLCHAR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the `loadav' function. */ -/* #undef HAVE_LOADAV */ - -/* Define to 1 if `lstat' has the bug that it succeeds when given the - zero-length file name argument. */ -/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if libncurses is requested */ -/* #undef HAVE_NCURSES_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NCURSES_TERM_H */ - -/* Define to 1 if you have the `nlist' function. */ -/* #undef HAVE_NLIST */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NLIST_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_PROCESS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_PWD_H 1 - -/* Define to 1 if you have the `setenv' function. */ -#define HAVE_SETENV 1 - -/* Define to 1 if you have the `setgid' function. */ -#define HAVE_SETGID 1 - -/* Define to 1 if you have the `setregid' function. */ -#define HAVE_SETREGID 1 - -/* Define to 1 if you have the `setresgid' function. */ -/* #undef HAVE_SETRESGID */ - -/* Define to 1 if you have the `setresuid' function. */ -/* #undef HAVE_SETRESUID */ - -/* Define to 1 if you have the `setreuid' function. */ -#define HAVE_SETREUID 1 - -/* Define to 1 if you have the `setuid' function. */ -#define HAVE_SETUID 1 - -/* Define to 1 if you have the `spawnl' function. */ -/* #undef HAVE_SPAWNL */ - -/* Define to 1 if `stat' has the bug that it succeeds when given the - zero-length file name argument. */ -/* #undef HAVE_STAT_EMPTY_STRING_BUG */ - -/* Define to 1 if stdbool.h conforms to C99. */ -#define HAVE_STDBOOL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UTSNAME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TERM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UTMP_H 1 - -/* Define to 1 if you have the `vfork' function. */ -#define HAVE_VFORK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VFORK_H */ - -/* Define to 1 if you have the `vprintf' function. */ -#define HAVE_VPRINTF 1 - -/* Define to 1 if `fork' works. */ -#define HAVE_WORKING_FORK 1 - -/* Define to 1 if `vfork' works. */ -#define HAVE_WORKING_VFORK 1 - -/* Define to 1 if the system has the type `_Bool'. */ -#define HAVE__BOOL 1 - -/* Define to 1 if you have the `_spawnl' function. */ -/* #undef HAVE__SPAWNL */ - -/* define if we should use program's load average function instead of system - */ -/* #undef LOADAV */ - -/* Define to file to use for scoreboard lockfile */ -#define LOCKFILE "rogue.lck" - -/* Define to 1 if `lstat' dereferences a symlink specified with a trailing - slash. */ -/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */ - -/* Define to include wizard mode */ -/* #undef MASTER */ - -/* Define if maxusers feature should be enabled */ -/* #undef MAXLOAD */ - -/* Define if maxusers feature should be enabled */ -/* #undef MAXUSERS */ - -/* kernel file to pass to nlist() when reading load average (unlikely to work) - */ -/* #undef NAMELIST */ - -/* word for the number of scores to store in scoreboard */ -#define NUMNAME "Ten" - -/* number of scores to store in scoreboard */ -#define NUMSCORES 10 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "yendor@rogueforge.net" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "Rogue" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "Rogue 5.4.4" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "rogue" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "5.4.4" - -/* Define crypt(3) wizard mode password */ -/* #undef PASSWD */ - -/* Define as the return type of signal handlers (`int' or `void'). */ -#define RETSIGTYPE void - -/* Define to file to use for scoreboard */ -#define SCOREFILE "rogue.scr" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if your declares `struct tm'. */ -/* #undef TM_IN_SYS_TIME */ - -/* define if we should use program's user counting function instead of - system's */ -/* #undef UCOUNT */ - -/* utmp like file to pass to ucount() when counting online users (unlikely to - work) */ -/* #undef UTMP */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define as `fork' if `vfork' does not work. */ -/* #undef vfork */ diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 1131e3429..01ae794eb 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -23,14 +23,14 @@ #include #include -char USERPASS[8192]; +char USERPASS[8192]; uint16_t ROGUE_PORT; char Gametxidstr[67]; #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) #define dstr(x) ((double)(x) / SATOSHIDEN) #define KOMODO_ASSETCHAIN_MAXLEN 65 -#define ASSETCHAINS_SYMBOL "ROGUE" +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; #ifndef _BITS256 #define _BITS256 @@ -583,7 +583,6 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char * return(chunk.memory); } -#ifdef autoextract uint16_t _komodo_userpass(char *username,char *password,FILE *fp) { char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0; @@ -617,7 +616,7 @@ uint16_t _komodo_userpass(char *username,char *password,FILE *fp) return(port); } -void komodo_statefname(char *fname,char *symbol,char *str) +/*void komodo_statefname(char *fname,char *symbol,char *str) { int32_t n,len; sprintf(fname,"%s",getDataDir()); @@ -652,7 +651,7 @@ void komodo_statefname(char *fname,char *symbol,char *str) } strcat(fname,str); //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname); -} +}*/ uint16_t komodo_userpass(char *userpass,char *symbol) { @@ -667,8 +666,8 @@ uint16_t komodo_userpass(char *userpass,char *symbol) #endif } else sprintf(confname,"%s.conf",symbol); - komodo_statefname(fname,symbol,confname); - if ( (fp= fopen(fname,"rb")) != 0 ) + //komodo_statefname(fname,symbol,confname); + if ( (fp= fopen(confname,"rb")) != 0 ) { port = _komodo_userpass(username,password,fp); sprintf(userpass,"%s:%s",username,password); @@ -678,7 +677,6 @@ uint16_t komodo_userpass(char *userpass,char *symbol) } return(port); } -#endif #define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) @@ -703,32 +701,53 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384]; int32_t i; + char cmd[16384],hexstr[16384],params[32768]; int32_t i; if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { for (i=0; i> keystrokes.log",Gametxidstr,hexstr); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); + if ( 0 ) + { + sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + } + else + { + sprintf(params,"[\"keystrokes\",17,[\"%s\",\"%s\"]]",Gametxidstr,hexstr); + if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) + { + fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); + free(retstr); + } + } } } int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { - char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + char cmd[32768]; int32_t i,n,retval=-1; char *filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; if ( rs->guiflag == 0 ) return(-1); if ( gametxidstr == 0 || *gametxidstr == 0 ) return(retval); - sprintf(fname,"%s.gameinfo",gametxidstr); - sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); + if ( 0 ) + { + sprintf(fname,"%s.gameinfo",gametxidstr); + sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + else filestr = (char *)OS_fileptr(&allocsize,fname); + } else { - filestr = (char *)OS_fileptr(&allocsize,fname); + sprintf(params,"[\"gameinfo\",17,[\"%s\"]]",gametxidstr); + filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); + } + if ( filestr != 0 ) + { + fprintf(stderr,"gameinfo.(%s)\n",filestr); if ( (retjson= cJSON_Parse(filestr)) != 0 ) { if ( (array= jarray(&n,retjson,"players")) != 0 ) @@ -762,7 +781,20 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) int main(int argc, char **argv, char **envp) { - uint64_t seed; FILE *fp = 0; + uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; + for (i=j=0; argv[0][i]!=0&&j Date: Wed, 20 Feb 2019 22:09:20 -1100 Subject: [PATCH 2442/3904] syntax --- .gitignore | 2 ++ src/cc/rogue/main.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 030c9dc5a..2ab07ee0f 100644 --- a/.gitignore +++ b/.gitignore @@ -152,3 +152,5 @@ src/cc/rogue/config.h src/ROGUE.conf src/rogue.scr + +src/cc/rogue/confdefs.h diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 01ae794eb..84e7ae91f 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -701,7 +701,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768]; int32_t i; + char cmd[16384],hexstr[16384],params[32768],*retstr; int32_t i; if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { for (i=0; iguiflag == 0 ) return(-1); if ( gametxidstr == 0 || *gametxidstr == 0 ) From 513a9cc3fc5b6a8b9144cc697da31973a44ed59c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:20:36 -1100 Subject: [PATCH 2443/3904] +prints --- src/cc/cclib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 33b76ff91..578ce84d8 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -253,7 +253,7 @@ UniValue CClib_info(struct CCcontract_info *cp) UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; - //printf("CClib params.%p\n",params); + printf("CClib params.%p (%s)\n",params,params!=0?jprint(params,0):""); for (i=0; ievalcode == CClib_methods[i].evalcode && strcmp(method,CClib_methods[i].method) == 0 ) @@ -531,7 +531,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will } newstr[j] = 0; params = cJSON_Parse(newstr); - if ( 0 && params != 0 ) + if ( 1 && params != 0 ) printf("new.(%s) -> %s\n",newstr,jprint(params,0)); free(newstr); *nump = cJSON_GetArraySize(params); From b60b2118c54d2031df82f95d046b3e399728f1e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:28:44 -1100 Subject: [PATCH 2444/3904] Stubs --- src/cc/rogue/main.c | 2 +- src/cc/rogue/rogue.c | 13 +++++++++++++ src/cc/rogue/rogue.h | 1 - 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 84e7ae91f..f0e7df58a 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -24,7 +24,7 @@ #include char USERPASS[8192]; uint16_t ROGUE_PORT; -char Gametxidstr[67]; +extern char Gametxidstr[67]; #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 7e5a53fe5..b4cb6244f 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -25,6 +25,7 @@ * The main program, of course */ struct rogue_state globalR; +char Gametxidstr[67]; void garbage_collect(); void purge_obj_guess(struct obj_info *array,int32_t n) @@ -151,6 +152,18 @@ int32_t flushkeystrokes(struct rogue_state *rs) } #else +#ifdef BUILD_ROGUE +// stubs for inside daemon +void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) +{ +} + +int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) +{ + return(-1); +} +#endif + int32_t flushkeystrokes(struct rogue_state *rs) { if ( rs->num > 0 ) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 802dd5f64..b64af8f1a 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -370,7 +370,6 @@ struct rogue_state uint8_t playerdata[10000]; }; extern struct rogue_state globalR; -extern char Gametxidstr[67]; int rogue(int argc, char **argv, char **envp); void rogueiterate(struct rogue_state *rs); From 3db424cdf87bd91c3855292bc77f887bb90d3254 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:30:21 -1100 Subject: [PATCH 2445/3904] Test --- src/cc/rogue/rogue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b4cb6244f..6d0af34b2 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -154,6 +154,7 @@ int32_t flushkeystrokes(struct rogue_state *rs) #ifdef BUILD_ROGUE // stubs for inside daemon +xxx void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) { } From 8d39e0119b11d8084bbb724e9dd277dfc34a9a29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:32:17 -1100 Subject: [PATCH 2446/3904] Fix --- src/cc/rogue/rogue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6d0af34b2..0a6d83cff 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -154,7 +154,8 @@ int32_t flushkeystrokes(struct rogue_state *rs) #ifdef BUILD_ROGUE // stubs for inside daemon -xxx +char Gametxidstr[67]; + void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) { } From d835211676faa3bcbdd26690ed38f0a6a7e57b21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:32:57 -1100 Subject: [PATCH 2447/3904] -Gameidstr --- src/cc/rogue/rogue.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 0a6d83cff..e8de063de 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -154,7 +154,6 @@ int32_t flushkeystrokes(struct rogue_state *rs) #ifdef BUILD_ROGUE // stubs for inside daemon -char Gametxidstr[67]; void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) { From f6d2b31ab65be445a56fe70fdd5ad7e9344512ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:39:20 -1100 Subject: [PATCH 2448/3904] tst --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f0e7df58a..5056ff14d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -742,7 +742,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } else { - sprintf(params,"[\"gameinfo\",17,[\"%s\"]]",gametxidstr); + sprintf(params,"[\"gameinfo\",\"17\",\"[\'%s\']\"]",gametxidstr); filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); } if ( filestr != 0 ) From c5dce15a91ea65c7629b3e85c9e8666d1b6dc49b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:40:23 -1100 Subject: [PATCH 2449/3904] %22 --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 5056ff14d..8ec480a0a 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -742,7 +742,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } else { - sprintf(params,"[\"gameinfo\",\"17\",\"[\'%s\']\"]",gametxidstr); + sprintf(params,"[\"gameinfo\",\"17\",\"[%22%s%22]\"]",gametxidstr); filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); } if ( filestr != 0 ) From acd6f878168806bc48ac761e14215066efbd2665 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:41:08 -1100 Subject: [PATCH 2450/3904] %22 --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 8ec480a0a..c338cf397 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -715,7 +715,7 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ } else { - sprintf(params,"[\"keystrokes\",17,[\"%s\",\"%s\"]]",Gametxidstr,hexstr); + sprintf(params,"[\"keystrokes\",\"17\",\"[%22%s%22,%22%s%22]\"]",Gametxidstr,hexstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); From f394bf75acb1022d8ea37550cd23b1f87f427714 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:42:05 -1100 Subject: [PATCH 2451/3904] %% --- src/cc/rogue/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index c338cf397..8f674ba40 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -715,7 +715,7 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ } else { - sprintf(params,"[\"keystrokes\",\"17\",\"[%22%s%22,%22%s%22]\"]",Gametxidstr,hexstr); + sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); @@ -742,7 +742,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } else { - sprintf(params,"[\"gameinfo\",\"17\",\"[%22%s%22]\"]",gametxidstr); + sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); } if ( filestr != 0 ) From f98831dafdc41acf0ea694296a148dac2a3f1b9a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:43:28 -1100 Subject: [PATCH 2452/3904] Test --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 8f674ba40..a7c1d1d3f 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -690,7 +690,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) { sprintf(url,(char *)"http://127.0.0.1:%u",port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); - //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); + printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); } From 652d9880a7ffce3a756995a05dc0a45439fb8757 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:43:56 -1100 Subject: [PATCH 2453/3904] USERPASS --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index a7c1d1d3f..969314166 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -690,7 +690,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) { sprintf(url,(char *)"http://127.0.0.1:%u",port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); - printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); + printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); } From 957178495bbeee8f426621ee1733903a25c2c04f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:46:12 -1100 Subject: [PATCH 2454/3904] Test --- src/cc/rogue/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 969314166..49a09a5cf 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -450,7 +450,7 @@ try_again: databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); - //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); + printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); // } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); curl_easy_setopt(curl_handle,CURLOPT_POST,1L); @@ -690,7 +690,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) { sprintf(url,(char *)"http://127.0.0.1:%u",port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); - printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS); + //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); } From 3881f9cea47df07f7ad7ce02f06cdd88e0b28e95 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:50:57 -1100 Subject: [PATCH 2455/3904] Prints --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 47f7d3004..99d9b87f1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5416,6 +5416,7 @@ UniValue cclib(const UniValue& params, bool fHelp) } if ( params.size() == 3 ) { + fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),params[2].get_str().c_str()); jsonparams = cJSON_Parse(params[2].get_str().c_str()); } } From a65a83bdb8d4619bc45c14883d77d9ffddd81eee Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:55:40 -1100 Subject: [PATCH 2456/3904] Test --- src/cc/rogue/main.c | 6 +++--- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 49a09a5cf..fab4875b1 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -450,7 +450,7 @@ try_again: databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); - printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); + //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); // } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); curl_easy_setopt(curl_handle,CURLOPT_POST,1L); @@ -715,7 +715,7 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ } else { - sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); + sprintf(params,"[\"keystrokes\",\"17\",\\\"[%%22%s%%22,%%22%s%%22]\\\"]",Gametxidstr,hexstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); @@ -742,7 +742,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } else { - sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); + sprintf(params,"[\"gameinfo\",\"17\",\\\"[%%22%s%%22]\\\"]",gametxidstr); filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); } if ( filestr != 0 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 99d9b87f1..decb6fb96 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5416,7 +5416,7 @@ UniValue cclib(const UniValue& params, bool fHelp) } if ( params.size() == 3 ) { - fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),params[2].get_str().c_str()); + //fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),params[2].get_str().c_str()); jsonparams = cJSON_Parse(params[2].get_str().c_str()); } } From c2def52cb232f7faf28829aa4624e1a36d9c4929 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 22:56:53 -1100 Subject: [PATCH 2457/3904] Test --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index fab4875b1..6ac9efe3b 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -715,7 +715,7 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ } else { - sprintf(params,"[\"keystrokes\",\"17\",\\\"[%%22%s%%22,%%22%s%%22]\\\"]",Gametxidstr,hexstr); + sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); From 2496f79e41c478c780b6142cb1036490361c9949 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:05:58 -1100 Subject: [PATCH 2458/3904] Jsonstr --- src/cc/CCinclude.h | 2 +- src/cc/cclib.cpp | 76 +++++++++++++++++++++------------------- src/wallet/rpcwallet.cpp | 6 ++-- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index eb9297a36..ca51506e8 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -139,7 +139,7 @@ int32_t komodo_nextheight(); int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 txid,int32_t vout); void CCclearvars(struct CCcontract_info *cp); -UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params); +UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr); UniValue CClib_info(struct CCcontract_info *cp); CBlockIndex *komodo_blockindex(uint256 hash); CBlockIndex *komodo_chainactive(int32_t height); diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 578ce84d8..88db00732 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -123,9 +123,43 @@ UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #endif -UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) +cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be freed by caller { - UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; + cJSON *params; char *jsonstr,*newstr; int32_t i,j; + *nump = 0; + if ( jsonstr != 0 ) + { + if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) + { + jsonstr[strlen(jsonstr)-1] = 0; + jsonstr++; + } + newstr = (char *)malloc(strlen(jsonstr)+1); + for (i=j=0; jsonstr[i]!=0; i++) + { + if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) + { + newstr[j++] = '"'; + i += 2; + } + else if ( jsonstr[i] == '\'' ) + newstr[j++] = '"'; + else newstr[j++] = jsonstr[i]; + } + newstr[j] = 0; + params = cJSON_Parse(newstr); + if ( 1 && params != 0 ) + printf("new.(%s) -> %s\n",newstr,jprint(params,0)); + free(newstr); + *nump = cJSON_GetArraySize(params); + //free(origparams); + } else params = 0; + return(params); +} + +UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) +{ + UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; int32_t m; cJSON *params = cclib_reparse(&m,jsonstr); #ifdef BUILD_ROGUE if ( cp->evalcode == EVAL_ROGUE ) { @@ -250,10 +284,10 @@ UniValue CClib_info(struct CCcontract_info *cp) return(result); } -UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) +UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr) { UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; - printf("CClib params.%p (%s)\n",params,params!=0?jprint(params,0):""); + printf("CClib params.(%s)\n",jsonstr!=0?jsonstr:""); for (i=0; ievalcode == CClib_methods[i].evalcode && strcmp(method,CClib_methods[i].method) == 0 ) @@ -265,7 +299,7 @@ UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params) rawtx = CClib_rawtxgen(cp,CClib_methods[i].funcid,params); result.push_back(Pair("rawtx",rawtx)); return(result); - } else return(CClib_method(cp,method,params)); + } else return(CClib_method(cp,method,jsonstr)); } } result.push_back(Pair("result","error")); @@ -507,38 +541,6 @@ uint256 juint256(cJSON *obj) return(revuint256(tmp)); } -cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will be freed by caller -{ - cJSON *params; char *jsonstr,*newstr; int32_t i,j; - if ( (jsonstr= jprint(origparams,0)) != 0 ) - { - if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) - { - jsonstr[strlen(jsonstr)-1] = 0; - jsonstr++; - } - newstr = (char *)malloc(strlen(jsonstr)+1); - for (i=j=0; jsonstr[i]!=0; i++) - { - if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) - { - newstr[j++] = '"'; - i += 2; - } - else if ( jsonstr[i] == '\'' ) - newstr[j++] = '"'; - else newstr[j++] = jsonstr[i]; - } - newstr[j] = 0; - params = cJSON_Parse(newstr); - if ( 1 && params != 0 ) - printf("new.(%s) -> %s\n",newstr,jprint(params,0)); - free(newstr); - *nump = cJSON_GetArraySize(params); - //free(origparams); - } else params = 0; - return(params); -} #ifdef BUILD_ROGUE #include "rogue_rpc.cpp" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index decb6fb96..3965416c4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5396,7 +5396,7 @@ UniValue cclibinfo(const UniValue& params, bool fHelp) UniValue cclib(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *method; cJSON *jsonparams=0; uint8_t evalcode = EVAL_FIRSTUSER; + struct CCcontract_info *cp,C; char *method,*jsonstr=0; uint8_t evalcode = EVAL_FIRSTUSER; if ( fHelp || params.size() > 3 ) throw runtime_error("cclib method [evalcode] [JSON params]\n"); if ( ASSETCHAINS_CCLIB.size() == 0 ) @@ -5417,11 +5417,11 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( params.size() == 3 ) { //fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),params[2].get_str().c_str()); - jsonparams = cJSON_Parse(params[2].get_str().c_str()); + jsonparams = params[2].get_str().c_str(); } } cp = CCinit(&C,evalcode); - return(CClib(cp,method,jsonparams)); + return(CClib(cp,method,jsonstr)); } UniValue oraclesaddress(const UniValue& params, bool fHelp) From d9a52ff53cd8099f5dac9a768a68df26eb1f83c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:08:13 -1100 Subject: [PATCH 2459/3904] if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) --- src/cc/musig.cpp | 6 +++--- src/cc/rogue_rpc.cpp | 16 ++++++++-------- src/cc/sudoku.cpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 800102e13..04f3fe35d 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -86,7 +86,7 @@ int32_t musig_prevoutmsg(uint8_t *msg,uint256 sendtxid,CScript scriptPubKey) UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); uint256 sendtxid; int32_t i; uint8_t msg[32]; char *scriptstr,str[65]; int32_t n; - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n == 2 ) { @@ -183,7 +183,7 @@ UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) txfee = MUSIG_TXFEE; mypk = pubkey2pk(Mypubkey()); musigpk = GetUnspendable(cp,0); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n == 2 && (hexstr= jstr(jitem(params,0),0)) != 0 && is_hexstr(hexstr,0) == 66 ) { @@ -206,7 +206,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; secp256k1_schnorrsig musig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n == 3 ) { diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2d34d27c8..60d9a5cfd 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -657,7 +657,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1; if ( txfee == 0 ) txfee = 10000; - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 0 ) { @@ -693,7 +693,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; std::string symbol,pname; result.push_back(Pair("result","success")); rogue_univalue(result,"playerinfo",-1,-1); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 0 ) { @@ -723,7 +723,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); rogue_univalue(result,"register",-1,-1); playertxid = tokenid = zeroid; - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 0 ) { @@ -803,7 +803,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); - if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); @@ -896,7 +896,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 0 ) { @@ -968,7 +968,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param funcid = 'H'; mult = 200000; } - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 0 ) { @@ -1081,7 +1081,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; result.push_back(Pair("name","rogue")); result.push_back(Pair("method","gameinfo")); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 0 ) { @@ -1212,7 +1212,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t n; char *namestr = 0; rogue_univalue(result,"setname",-1,-1); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 0 ) { diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index d48a1bc2c..a8e7c651b 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2817,7 +2817,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params good = 0; if ( params != 0 ) { - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) { if ( n > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 ) { From 2dff5b98f025b4dda5b391d93e447956211c4934 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:10:26 -1100 Subject: [PATCH 2460/3904] Jsonstr --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3965416c4..36172a612 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5417,7 +5417,7 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( params.size() == 3 ) { //fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),params[2].get_str().c_str()); - jsonparams = params[2].get_str().c_str(); + jsonstr = params[2].get_str().c_str(); } } cp = CCinit(&C,evalcode); From 695278546955eeab749f3f3b2b5a8f7a0f8eff5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:12:58 -1100 Subject: [PATCH 2461/3904] params --- src/cc/musig.cpp | 6 +++--- src/cc/rogue_rpc.cpp | 16 ++++++++-------- src/cc/sudoku.cpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 04f3fe35d..5d56635aa 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -86,7 +86,7 @@ int32_t musig_prevoutmsg(uint8_t *msg,uint256 sendtxid,CScript scriptPubKey) UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); uint256 sendtxid; int32_t i; uint8_t msg[32]; char *scriptstr,str[65]; int32_t n; - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n == 2 ) { @@ -183,7 +183,7 @@ UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) txfee = MUSIG_TXFEE; mypk = pubkey2pk(Mypubkey()); musigpk = GetUnspendable(cp,0); - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n == 2 && (hexstr= jstr(jitem(params,0),0)) != 0 && is_hexstr(hexstr,0) == 66 ) { @@ -206,7 +206,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; secp256k1_schnorrsig musig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n == 3 ) { diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 60d9a5cfd..57ce1e14b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -657,7 +657,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1; if ( txfee == 0 ) txfee = 10000; - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) { @@ -693,7 +693,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; std::string symbol,pname; result.push_back(Pair("result","success")); rogue_univalue(result,"playerinfo",-1,-1); - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) { @@ -723,7 +723,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); rogue_univalue(result,"register",-1,-1); playertxid = tokenid = zeroid; - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) { @@ -803,7 +803,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( txfee == 0 ) txfee = 10000; rogue_univalue(result,"keystrokes",-1,-1); - if ( params != 0 && (n= cJSON_GetArraySize()) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); @@ -896,7 +896,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) { @@ -968,7 +968,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param funcid = 'H'; mult = 200000; } - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) { @@ -1081,7 +1081,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; result.push_back(Pair("name","rogue")); result.push_back(Pair("method","gameinfo")); - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) { @@ -1212,7 +1212,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t n; char *namestr = 0; rogue_univalue(result,"setname",-1,-1); - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) { diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a8e7c651b..49bcf79d9 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2817,7 +2817,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params good = 0; if ( params != 0 ) { - if ( params != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 ) { From 0dd112c6d85de51692730161a31ff06646e29ea5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:16:37 -1100 Subject: [PATCH 2462/3904] Syntax --- src/cc/cclib.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 88db00732..f17f04273 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -125,7 +125,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be freed by caller { - cJSON *params; char *jsonstr,*newstr; int32_t i,j; + cJSON *params; char *newstr; int32_t i,j; *nump = 0; if ( jsonstr != 0 ) { @@ -286,7 +286,7 @@ UniValue CClib_info(struct CCcontract_info *cp) UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr) { - UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; + UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; cJSON *params; printf("CClib params.(%s)\n",jsonstr!=0?jsonstr:""); for (i=0; i Date: Wed, 20 Feb 2019 23:17:40 -1100 Subject: [PATCH 2463/3904] Char * --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 36172a612..ab8992c0d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5417,7 +5417,7 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( params.size() == 3 ) { //fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),params[2].get_str().c_str()); - jsonstr = params[2].get_str().c_str(); + jsonstr = (char *)params[2].get_str().c_str(); } } cp = CCinit(&C,evalcode); From d58bfc8a7fbda8a03f009f2242dd5df7e3c9a106 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:20:37 -1100 Subject: [PATCH 2464/3904] Prints --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f17f04273..3f4a5d6a8 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -160,6 +160,7 @@ cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) { UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; int32_t m; cJSON *params = cclib_reparse(&m,jsonstr); + fprintf(stderr,"method.(%s) -> (%s)\n",jsonstr!=0?jsonstr:"",params!=0?jprint(params,0):""); #ifdef BUILD_ROGUE if ( cp->evalcode == EVAL_ROGUE ) { From e392999374bfb4cded273a333aeac44c52739a99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:24:27 -1100 Subject: [PATCH 2465/3904] Jsonstr --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ab8992c0d..de4b22b7e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5416,8 +5416,8 @@ UniValue cclib(const UniValue& params, bool fHelp) } if ( params.size() == 3 ) { - //fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),params[2].get_str().c_str()); jsonstr = (char *)params[2].get_str().c_str(); + fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),jsonstr); } } cp = CCinit(&C,evalcode); From 0cc4ef9d9008f73e3f0ff855a80bb048372de4d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:26:36 -1100 Subject: [PATCH 2466/3904] Test --- src/cc/rogue/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 6ac9efe3b..49a09a5cf 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -450,7 +450,7 @@ try_again: databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); - //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); + printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); // } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); curl_easy_setopt(curl_handle,CURLOPT_POST,1L); @@ -742,7 +742,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } else { - sprintf(params,"[\"gameinfo\",\"17\",\\\"[%%22%s%%22]\\\"]",gametxidstr); + sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); } if ( filestr != 0 ) From 13ba8a70ca9a86f8964d1c0b478b984b4921cadd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:28:57 -1100 Subject: [PATCH 2467/3904] -prints --- src/cc/cclib.cpp | 4 ++-- src/cc/rogue/main.c | 2 +- src/wallet/rpcwallet.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 3f4a5d6a8..a595f5559 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -160,7 +160,7 @@ cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) { UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; int32_t m; cJSON *params = cclib_reparse(&m,jsonstr); - fprintf(stderr,"method.(%s) -> (%s)\n",jsonstr!=0?jsonstr:"",params!=0?jprint(params,0):""); + //fprintf(stderr,"method.(%s) -> (%s)\n",jsonstr!=0?jsonstr:"",params!=0?jprint(params,0):""); #ifdef BUILD_ROGUE if ( cp->evalcode == EVAL_ROGUE ) { @@ -288,7 +288,7 @@ UniValue CClib_info(struct CCcontract_info *cp) UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr) { UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; cJSON *params; - printf("CClib params.(%s)\n",jsonstr!=0?jsonstr:""); + //printf("CClib params.(%s)\n",jsonstr!=0?jsonstr:""); for (i=0; ievalcode == CClib_methods[i].evalcode && strcmp(method,CClib_methods[i].method) == 0 ) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 49a09a5cf..af357feb8 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -450,7 +450,7 @@ try_again: databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); - printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); + //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); // } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); curl_easy_setopt(curl_handle,CURLOPT_POST,1L); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index de4b22b7e..0ed2f866c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5417,7 +5417,7 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( params.size() == 3 ) { jsonstr = (char *)params[2].get_str().c_str(); - fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),jsonstr); + //fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),jsonstr); } } cp = CCinit(&C,evalcode); From 89e375e95dbccb5877f55a94c298134e6f5f8fe6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:32:23 -1100 Subject: [PATCH 2468/3904] Resultjson --- src/cc/cclib.cpp | 2 +- src/cc/rogue/main.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index a595f5559..625872483 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -148,7 +148,7 @@ cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be } newstr[j] = 0; params = cJSON_Parse(newstr); - if ( 1 && params != 0 ) + if ( 0 && params != 0 ) printf("new.(%s) -> %s\n",newstr,jprint(params,0)); free(newstr); *nump = cJSON_GetArraySize(params); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index af357feb8..32967614c 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -727,7 +727,7 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { - char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item; + char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson; if ( rs->guiflag == 0 ) return(-1); if ( gametxidstr == 0 || *gametxidstr == 0 ) @@ -747,10 +747,10 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } if ( filestr != 0 ) { - fprintf(stderr,"gameinfo.(%s)\n",filestr); - if ( (retjson= cJSON_Parse(filestr)) != 0 ) + if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jitem(retjson,"result")) != 0 ) { - if ( (array= jarray(&n,retjson,"players")) != 0 ) + fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); + if ( (array= jarray(&n,resultjson,"players")) != 0 ) { for (i=0; i Date: Wed, 20 Feb 2019 23:32:59 -1100 Subject: [PATCH 2469/3904] jobj --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 32967614c..7971a9b3d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -747,7 +747,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } if ( filestr != 0 ) { - if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jitem(retjson,"result")) != 0 ) + if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,"result")) != 0 ) { fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); if ( (array= jarray(&n,resultjson,"players")) != 0 ) From 2fdc745c0b75bf03ede1bb02be566eaff6b5b026 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Feb 2019 23:35:42 -1100 Subject: [PATCH 2470/3904] -print --- src/cc/rogue/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 7971a9b3d..ca05226d3 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -718,7 +718,7 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { - fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); + //fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); free(retstr); } } @@ -749,7 +749,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) { if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,"result")) != 0 ) { - fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); + //fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); if ( (array= jarray(&n,resultjson,"players")) != 0 ) { for (i=0; i Date: Thu, 21 Feb 2019 00:19:53 -1100 Subject: [PATCH 2471/3904] ../secp256k1/src/ --- src/cc/cclib.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 625872483..df60833d2 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,9 +584,12 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" -//#define USE_BASIC_CONFIG -//#include "../secp256k1/src/basic-config.h" +#define USE_BASIC_CONFIG +#include "../secp256k1/src/basic-config.h" //#include "../secp256k1/src/secp256k1.c" +#include "../secp256k1/src/modules/schnorrsig/main_impl.h" +#include "../secp256k1/src/modules/musig/main_impl.h" + #include "musig.cpp" #endif From 9d8ec78d880dce011f65bc67d680656a9d0a9322 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:21:49 -1100 Subject: [PATCH 2472/3904] ../secp256k1/src/ --- src/cc/cclib.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index df60833d2..2ccfcce46 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -586,6 +586,21 @@ uint256 juint256(cJSON *obj) #include "sudoku.cpp" #define USE_BASIC_CONFIG #include "../secp256k1/src/basic-config.h" +#include "../secp256k1/include/secp256k1.h" + +#include "../secp256k1/src/util.h" +#include "../secp256k1/src/num_impl.h" +#include "../secp256k1/src/field_impl.h" +#include "../secp256k1/src/scalar_impl.h" +#include "../secp256k1/src/group_impl.h" +#include "../secp256k1/src/ecmult_impl.h" +#include "../secp256k1/src/ecmult_const_impl.h" +#include "../secp256k1/src/ecmult_gen_impl.h" +#include "../secp256k1/src/ecdsa_impl.h" +#include "../secp256k1/src/eckey_impl.h" +#include "../secp256k1/src/hash_impl.h" +#include "../secp256k1/src/scratch_impl.h" + //#include "../secp256k1/src/secp256k1.c" #include "../secp256k1/src/modules/schnorrsig/main_impl.h" #include "../secp256k1/src/modules/musig/main_impl.h" From df9f4a10928e80e91fc83c01dc5c49767490398e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:22:54 -1100 Subject: [PATCH 2473/3904] ARG_CHECK --- src/cc/cclib.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 2ccfcce46..b6a79b32e 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -601,6 +601,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/hash_impl.h" #include "../secp256k1/src/scratch_impl.h" +#define ARG_CHECK(cond) do { \ +if (EXPECT(!(cond), 0)) { \ +secp256k1_callback_call(&ctx->illegal_callback, #cond); \ +return 0; \ +} \ +} while(0) + //#include "../secp256k1/src/secp256k1.c" #include "../secp256k1/src/modules/schnorrsig/main_impl.h" #include "../secp256k1/src/modules/musig/main_impl.h" From b9c1f3bc3d1e46f524abc207d9a5166bebd107a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:33:15 -1100 Subject: [PATCH 2474/3904] Ctx --- src/cc/cclib.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b6a79b32e..496005016 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -601,6 +601,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/hash_impl.h" #include "../secp256k1/src/scratch_impl.h" +struct secp256k1_context_struct { + secp256k1_ecmult_context ecmult_ctx; + secp256k1_ecmult_gen_context ecmult_gen_ctx; + secp256k1_callback illegal_callback; + secp256k1_callback error_callback; +}; + #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ secp256k1_callback_call(&ctx->illegal_callback, #cond); \ From 6d3246be8115432643197f91b6ae3000a2a08c0b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:39:15 -1100 Subject: [PATCH 2475/3904] Declare --- src/cc/cclib.cpp | 5 +++++ src/secp256k1/src/ecmult.h | 2 +- src/secp256k1/src/scalar.h | 2 +- src/secp256k1/src/scalar_4x64_impl.h | 2 +- src/secp256k1/src/scalar_8x32_impl.h | 2 +- src/secp256k1/src/scalar_low_impl.h | 2 +- src/secp256k1/src/secp256k1.c | 4 ++-- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 496005016..da8829de6 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -608,6 +608,11 @@ struct secp256k1_context_struct { secp256k1_callback error_callback; }; +int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); +int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); + #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ secp256k1_callback_call(&ctx->illegal_callback, #cond); \ diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 4f12090a7..fbcf6a445 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -78,7 +78,7 @@ typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge * 0 if there is not enough scratch space for a single point or * callback returns 0 */ -static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #endif /* SECP256K1_ECMULT_H */ diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h index 3213d302b..d83ccc22a 100644 --- a/src/secp256k1/src/scalar.h +++ b/src/secp256k1/src/scalar.h @@ -218,7 +218,7 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); /** Generate two scalars from a 32-byte seed and an integer using the chacha20 stream cipher */ -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); #endif /* SECP256K1_SCALAR_H */ #endif diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index b1b62ac1f..04f1da85d 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -1925,7 +1925,7 @@ c += d; b = ROTL32(b ^ c, 7); #define LE32(p) (p) #endif -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { size_t n; size_t over_count = 0; uint32_t seed32[8]; diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/src/secp256k1/src/scalar_8x32_impl.h index ff7bf5ee4..f1429b162 100644 --- a/src/secp256k1/src/scalar_8x32_impl.h +++ b/src/secp256k1/src/scalar_8x32_impl.h @@ -1471,7 +1471,7 @@ c += d; b = ROTL32(b ^ c, 7); #define LE32(p) (p) #endif -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { size_t n; size_t over_count = 0; uint32_t seed32[8]; diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index c6c65ff5b..cc83eb8c7 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -230,7 +230,7 @@ SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const return *a == *b; } -SECP256K1_INLINE static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { +SECP256K1_INLINE void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { *r1 = (seed[0] + n) % EXHAUSTIVE_TEST_ORDER; *r2 = (seed[1] + n) % EXHAUSTIVE_TEST_ORDER; } diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 657893d0d..1acb028d2 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. @@ -342,7 +342,7 @@ static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *m /* This nonce function is described in BIP-schnorr * (https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki) */ -static int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { +int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { secp256k1_sha256 sha; (void) data; (void) counter; From 8ceea089ae28523f1cf1347adcf9c54893ca8aa4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:41:42 -1100 Subject: [PATCH 2476/3904] typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); --- src/cc/cclib.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index da8829de6..9f66e7022 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -608,6 +608,8 @@ struct secp256k1_context_struct { secp256k1_callback error_callback; }; +typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); + int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); From b81052aff00e17a4e659da9a4e8fd68812215fc1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:44:37 -1100 Subject: [PATCH 2477/3904] void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) --- src/cc/cclib.cpp | 2 +- src/secp256k1/src/ecmult_impl.h | 4 ++-- src/secp256k1/src/secp256k1.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 9f66e7022..1d7bedd82 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -609,7 +609,7 @@ struct secp256k1_context_struct { }; typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); - +void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 6c9a1daf2..6f2242d7c 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1497,7 +1497,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { /* Computes ecmult_multi by simply multiplying and adding each point. Does not * require a scratch space */ -static int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { + int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { size_t point_idx; secp256k1_scalar szero; secp256k1_gej tmpj; @@ -1522,7 +1522,7 @@ static int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); -static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { +int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; int (*f)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t, size_t); diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 1acb028d2..2b219b589 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -134,7 +134,7 @@ int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const return 1; } -static void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) { +void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) { if (sizeof(secp256k1_ge_storage) == 64) { secp256k1_ge_storage s; secp256k1_ge_to_storage(&s, ge); From 82bacc85ff2d319c7fb8213e5e69796f5079f3c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:47:38 -1100 Subject: [PATCH 2478/3904] "C" --- src/cc/cclib.cpp | 2 +- src/secp256k1/src/secp256k1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 1d7bedd82..c63d03a38 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -611,7 +611,7 @@ struct secp256k1_context_struct { typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); -int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); +"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 2b219b589..8be12059d 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. From da61c3f152361c5ba0b7f8a3684b59cc1be01c0d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:48:14 -1100 Subject: [PATCH 2479/3904] Extern "C" --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c63d03a38..7fb06259a 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -611,7 +611,7 @@ struct secp256k1_context_struct { typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); -"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); +extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); From bb264c86e12bc41f3688ae2a9b7f5fbda76ff42c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:49:07 -1100 Subject: [PATCH 2480/3904] "C" --- src/secp256k1/src/secp256k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 8be12059d..f39d373e3 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. From 85dfd9107105a311ce7a84cb28b7328fac6f5d19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:49:44 -1100 Subject: [PATCH 2481/3904] -"C" --- src/secp256k1/src/secp256k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index f39d373e3..2b219b589 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. From 0e67be94c996dc2cdcfa6bbdd9374b59528aab1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:51:20 -1100 Subject: [PATCH 2482/3904] Extern "C" --- src/cc/cclib.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 7fb06259a..e6b405955 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -609,11 +609,11 @@ struct secp256k1_context_struct { }; typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); -void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); -int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); +extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); +extern "C" int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); -void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); -int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +extern "C" void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ From 991766db5f089befe038ff7b061d88c1c82af691 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:01:31 -1100 Subject: [PATCH 2483/3904] -ENABLE_MODULE_MUSIG --- src/secp256k1/Makefile.am | 2 +- src/secp256k1/src/secp256k1.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 089d3ee8e..7603cc626 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -73,7 +73,7 @@ endif endif libsecp256k1_la_SOURCES = src/secp256k1.c -libsecp256k1_la_CPPFLAGS = -DENABLE_MODULE_MUSIG -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) +libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB) libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 2b219b589..4643ab903 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -601,8 +601,8 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif -#include "modules/schnorrsig/main_impl.h" -#include "modules/musig/main_impl.h" +//#include "modules/schnorrsig/main_impl.h" +//#include "modules/musig/main_impl.h" #ifdef ENABLE_MODULE_RECOVERY From db9f81504bca3e1f50f76e06fe0c9e3909c3e5cb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:02:56 -1100 Subject: [PATCH 2484/3904] Revert --- src/secp256k1/src/secp256k1.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 4643ab903..065ce72d4 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -17,7 +17,6 @@ #include "ecdsa_impl.h" #include "eckey_impl.h" #include "hash_impl.h" -#include "scratch_impl.h" #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ @@ -601,9 +600,6 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif -//#include "modules/schnorrsig/main_impl.h" -//#include "modules/musig/main_impl.h" - #ifdef ENABLE_MODULE_RECOVERY # include "modules/recovery/main_impl.h" From 340c8ba1ca2e30a7b182f282ff005264d020b3f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:04:53 -1100 Subject: [PATCH 2485/3904] -SCALAR_INLINE --- src/secp256k1/src/scalar_low_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index cc83eb8c7..956cccd04 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -230,7 +230,7 @@ SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const return *a == *b; } -SECP256K1_INLINE void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { *r1 = (seed[0] + n) % EXHAUSTIVE_TEST_ORDER; *r2 = (seed[1] + n) % EXHAUSTIVE_TEST_ORDER; } From 1d47bd1cc7167d03c59b18b68453e69d8e03670b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:08:23 -1100 Subject: [PATCH 2486/3904] Pippenger --- src/secp256k1/src/ecmult_impl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 6f2242d7c..88a9cfae2 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1154,6 +1154,8 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { return skew; } +#endif /* SECP256K1_ECMULT_IMPL_H */ + struct secp256k1_pippenger_point_state { int skew_na; size_t input_pos; @@ -1497,7 +1499,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { /* Computes ecmult_multi by simply multiplying and adding each point. Does not * require a scratch space */ - int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { +int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { size_t point_idx; secp256k1_scalar szero; secp256k1_gej tmpj; @@ -1522,6 +1524,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); + int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; @@ -1576,7 +1579,5 @@ int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_sc return 1; } -#endif /* SECP256K1_ECMULT_IMPL_H */ - #endif From 0caedf0c8c60ea9536cc15c39bc4967bfec2c463 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:09:43 -1100 Subject: [PATCH 2487/3904] Move endif --- src/secp256k1/src/ecmult_impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 88a9cfae2..48d8af8f4 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1155,6 +1155,8 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { } #endif /* SECP256K1_ECMULT_IMPL_H */ +#endif + struct secp256k1_pippenger_point_state { int skew_na; @@ -1579,5 +1581,4 @@ int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_sc return 1; } -#endif From 22e3b0b00ddebfdd56e97d378904a181829fb858 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:12:00 -1100 Subject: [PATCH 2488/3904] scratch.h --- src/secp256k1/src/ecmult_impl.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 48d8af8f4..c0d21f4ba 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1157,6 +1157,20 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { #endif /* SECP256K1_ECMULT_IMPL_H */ #endif +#include "../scratch.h" + +/* The number of objects allocated on the scratch space for ecmult_multi algorithms */ +#define PIPPENGER_SCRATCH_OBJECTS 6 +#define STRAUSS_SCRATCH_OBJECTS 6 + +#define PIPPENGER_MAX_BUCKET_WINDOW 12 + +/* Minimum number of points for which pippenger_wnaf is faster than strauss wnaf */ +#ifdef USE_ENDOMORPHISM +#define ECMULT_PIPPENGER_THRESHOLD 88 +#else +#define ECMULT_PIPPENGER_THRESHOLD 160 +#endif struct secp256k1_pippenger_point_state { int skew_na; From 061dde468e52ca35a5307c37b19942871dadd89c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:14:59 -1100 Subject: [PATCH 2489/3904] -.. --- src/secp256k1/src/ecmult_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index c0d21f4ba..2a0fac4e7 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1157,7 +1157,7 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { #endif /* SECP256K1_ECMULT_IMPL_H */ #endif -#include "../scratch.h" +#include "scratch.h" /* The number of objects allocated on the scratch space for ecmult_multi algorithms */ #define PIPPENGER_SCRATCH_OBJECTS 6 From 536cb5f86d68b8cc9d368986f20ad6c0731fda81 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 21 Feb 2019 20:17:08 +0800 Subject: [PATCH 2490/3904] geterablockheights RPC --- src/main.cpp | 5 +++-- src/rpc/misc.cpp | 30 ++++++++++++++++++++++++++++-- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6bee5855c..6ad0e613d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1111,8 +1111,9 @@ bool ContextualCheckTransaction( if (IsExpiredTx(tx, nHeight)) { // Don't increase banscore if the transaction only just expired int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? (dosLevel > 10 ? dosLevel : 10) : 0; - - return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight), REJECT_INVALID, "tx-overwinter-expired"); + string strHex = EncodeHexTx(tx); + //fprintf(stderr, "transaction exipred.%s\n",strHex.c_str()); + return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i\n txhex.%s",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight,strHex), REJECT_INVALID, "tx-overwinter-expired"); } } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 564d76c9c..a6b0e7923 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -86,10 +86,10 @@ extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[],ASSETCHAINS_NOTARY_PAY[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; -int32_t getera(int now) +int32_t getera(int timestamp) { for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { - if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + if ( timestamp <= STAKED_NOTARIES_TIMESTAMP[i] ) { return(i); } } @@ -163,6 +163,32 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) return ret; } +UniValue geterablockheights(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getnotarysendmany\n" + "Returns a JSON object with the first block in each era.\n" + ); + + CBlockIndex *pindex; int8_t lastera,era = 0; UniValue ret(UniValue::VOBJ); + + for (size_t i = 1; i < chainActive.LastTip()->GetHeight(); i++) + { + pindex = chainActive[i]; + era = getera(pindex->nTime)+1; + if ( era > lastera ) + { + char str[16]; + sprintf(str, "%d", era); + ret.push_back(Pair(str,i)); + lastera = era; + } + } + + return(ret); +} + UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 89baeddf5..46eb95a25 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -293,6 +293,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "help", &help, true }, { "control", "getiguanajson", &getiguanajson, true }, { "control", "getnotarysendmany", &getnotarysendmany, true }, + { "control", "geterablockheights", &geterablockheights, true }, { "control", "stop", &stop, true }, /* P2P networking */ diff --git a/src/rpc/server.h b/src/rpc/server.h index 6aedeb254..abd0ea6a8 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -381,6 +381,7 @@ extern UniValue decodeccopret(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); extern UniValue getiguanajson(const UniValue& params, bool fHelp); extern UniValue getnotarysendmany(const UniValue& params, bool fHelp); +extern UniValue geterablockheights(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); From f04c2097fb47546e6bdd3ccb10fae9d650f757b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:21:14 -1100 Subject: [PATCH 2491/3904] Test --- src/secp256k1/src/ecmult_impl.h | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 2a0fac4e7..bc596608e 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1,4 +1,4 @@ -#ifndef ENABLE_MODULE_MUSIG +#ifdef always_do_ENABLE_MODULE_MUSIG /********************************************************************** @@ -1154,24 +1154,6 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { return skew; } -#endif /* SECP256K1_ECMULT_IMPL_H */ -#endif - -#include "scratch.h" - -/* The number of objects allocated on the scratch space for ecmult_multi algorithms */ -#define PIPPENGER_SCRATCH_OBJECTS 6 -#define STRAUSS_SCRATCH_OBJECTS 6 - -#define PIPPENGER_MAX_BUCKET_WINDOW 12 - -/* Minimum number of points for which pippenger_wnaf is faster than strauss wnaf */ -#ifdef USE_ENDOMORPHISM -#define ECMULT_PIPPENGER_THRESHOLD 88 -#else -#define ECMULT_PIPPENGER_THRESHOLD 160 -#endif - struct secp256k1_pippenger_point_state { int skew_na; size_t input_pos; @@ -1515,7 +1497,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { /* Computes ecmult_multi by simply multiplying and adding each point. Does not * require a scratch space */ -int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { + int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { size_t point_idx; secp256k1_scalar szero; secp256k1_gej tmpj; @@ -1540,7 +1522,6 @@ int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp2 } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); - int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; @@ -1595,4 +1576,7 @@ int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_sc return 1; } +#endif /* SECP256K1_ECMULT_IMPL_H */ + +#endif From 75ffdd2e91b5779152c8a6eee1672ca9c29f62a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:25:39 -1100 Subject: [PATCH 2492/3904] -DENABLE_MODULE_MUSIG --- src/secp256k1/Makefile.am | 2 +- src/secp256k1/src/ecmult.h | 1 - src/secp256k1/src/ecmult_impl.h | 2 +- src/secp256k1/src/secp256k1.c | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 7603cc626..c5fa00fc5 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -73,7 +73,7 @@ endif endif libsecp256k1_la_SOURCES = src/secp256k1.c -libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) +libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -DENABLE_MODULE_MUSIG -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB) libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index fbcf6a445..88475791b 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -45,7 +45,6 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej #include "num.h" #include "group.h" #include "scalar.h" -#include "scratch.h" typedef struct { /* For accelerating the computation of a*P + b*G: */ diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index bc596608e..116a9f154 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1,4 +1,4 @@ -#ifdef always_do_ENABLE_MODULE_MUSIG +#ifdef ENABLE_MODULE_MUSIG /********************************************************************** diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 065ce72d4..4225607ff 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -17,6 +17,7 @@ #include "ecdsa_impl.h" #include "eckey_impl.h" #include "hash_impl.h" +#include "scratch_impl.h" #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ From 5ee30cdd96d7fe085401b4b2bf7cc41c650f85e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:30:47 -1100 Subject: [PATCH 2493/3904] scratch.h --- src/secp256k1/src/ecmult.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 88475791b..fbcf6a445 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -45,6 +45,7 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej #include "num.h" #include "group.h" #include "scalar.h" +#include "scratch.h" typedef struct { /* For accelerating the computation of a*P + b*G: */ From 57ef97ca58085e6d5204860e8a3763020da71219 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:38:49 -1100 Subject: [PATCH 2494/3904] #include "util.h" --- src/secp256k1/src/secp256k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 4225607ff..2f482803a 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -6,13 +6,13 @@ #include "../include/secp256k1.h" -#include "util.h" #include "num_impl.h" #include "field_impl.h" #include "scalar_impl.h" #include "group_impl.h" #include "ecmult_impl.h" #include "ecmult_const_impl.h" +#include "util.h" #include "ecmult_gen_impl.h" #include "ecdsa_impl.h" #include "eckey_impl.h" From 0a460a527382e5d59813d389bbc034df2ed7c07e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:41:57 -1100 Subject: [PATCH 2495/3904] Header order --- src/secp256k1/src/secp256k1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 2f482803a..e6af45df7 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -6,13 +6,13 @@ #include "../include/secp256k1.h" +#include "ecmult_impl.h" +#include "ecmult_const_impl.h" +#include "util.h" #include "num_impl.h" #include "field_impl.h" #include "scalar_impl.h" #include "group_impl.h" -#include "ecmult_impl.h" -#include "ecmult_const_impl.h" -#include "util.h" #include "ecmult_gen_impl.h" #include "ecdsa_impl.h" #include "eckey_impl.h" From d7e8e8d4b35c7dce5af8a60a5506515fdfe8e835 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:44:15 -1100 Subject: [PATCH 2496/3904] Fx --- src/cc/cclib.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e6b405955..e570be7d1 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,13 +588,14 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" + +#include "../secp256k1/src/ecmult_impl.h" +#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" #include "../secp256k1/src/group_impl.h" -#include "../secp256k1/src/ecmult_impl.h" -#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" From 99bf645bf19752c76f813a4164b3dbdcd8d01f73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:50:25 -1100 Subject: [PATCH 2497/3904] Revert --- src/cc/cclib.cpp | 5 ++--- src/secp256k1/src/secp256k1.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e570be7d1..e6b405955 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,14 +588,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" - -#include "../secp256k1/src/ecmult_impl.h" -#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" #include "../secp256k1/src/group_impl.h" +#include "../secp256k1/src/ecmult_impl.h" +#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index e6af45df7..4225607ff 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -6,13 +6,13 @@ #include "../include/secp256k1.h" -#include "ecmult_impl.h" -#include "ecmult_const_impl.h" #include "util.h" #include "num_impl.h" #include "field_impl.h" #include "scalar_impl.h" #include "group_impl.h" +#include "ecmult_impl.h" +#include "ecmult_const_impl.h" #include "ecmult_gen_impl.h" #include "ecdsa_impl.h" #include "eckey_impl.h" From ba4917acf45ec4943a2dcec065596446a6f581af Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:55:28 -1100 Subject: [PATCH 2498/3904] WNAF_SIZE --- src/secp256k1/src/ecmult_const_impl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index d8697e0e9..410c4a6b6 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -14,12 +14,20 @@ #include "ecmult_const.h" #include "ecmult_impl.h" +#ifdef USE_ENDOMORPHISM +#define WNAF_BITS 128 +#else +#define WNAF_BITS 256 +#endif +#define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) +#define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) + #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else #define WNAF_BITS 256 #endif -#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) +//#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ From 4fab71d374a4c64bfe1214b3e9c688e6e4f95748 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:59:32 -1100 Subject: [PATCH 2499/3904] Define WNAF BITS --- src/secp256k1/src/ecmult_const_impl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index 410c4a6b6..d2eaa2368 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -14,6 +14,7 @@ #include "ecmult_const.h" #include "ecmult_impl.h" + #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else @@ -22,12 +23,13 @@ #define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) #define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) +/* #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else #define WNAF_BITS 256 #endif -//#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) +#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w))*/ /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ From 15fb6f16954f9c9a6b77330ac0ae641b4aa98343 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:03:12 -1100 Subject: [PATCH 2500/3904] ... --- src/secp256k1/src/ecmult_const_impl.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index d2eaa2368..28636290d 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -15,21 +15,12 @@ #include "ecmult_impl.h" -#ifdef USE_ENDOMORPHISM -#define WNAF_BITS 128 -#else -#define WNAF_BITS 256 -#endif -#define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) -#define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) - -/* #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else #define WNAF_BITS 256 #endif -#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w))*/ +#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ @@ -266,6 +257,14 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons #include "ecmult_const.h" #include "ecmult_impl.h" +#ifdef USE_ENDOMORPHISM +#define WNAF_BITS 128 +#else +#define WNAF_BITS 256 +#endif +#define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) +#define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) + /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ int m; \ From 1b9cfb04a9a4dab9d8405ee90617e7c498bfd68a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:08:02 -1100 Subject: [PATCH 2501/3904] Scratch --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e6b405955..4019bf422 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -600,6 +600,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/eckey_impl.h" #include "../secp256k1/src/hash_impl.h" #include "../secp256k1/src/scratch_impl.h" +#include "../secp256k1/src/scratch.h" struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; From 1b099fca7157e64ccd27bccbb359626d78f749bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:09:33 -1100 Subject: [PATCH 2502/3904] Reorder --- src/cc/cclib.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 4019bf422..9a2f9c3ab 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -593,14 +593,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" #include "../secp256k1/src/group_impl.h" +#include "../secp256k1/src/scratch_impl.h" #include "../secp256k1/src/ecmult_impl.h" #include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" #include "../secp256k1/src/hash_impl.h" -#include "../secp256k1/src/scratch_impl.h" -#include "../secp256k1/src/scratch.h" struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; From 8c96abe167f9d9166a5eade2b16652dfdf1b4978 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:11:39 -1100 Subject: [PATCH 2503/3904] Enable --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 9a2f9c3ab..b02456b33 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -585,6 +585,7 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" #define USE_BASIC_CONFIG +#define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" From a244fe9cdc8abaaa2e510ecc8146ceb11229c890 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:14:20 -1100 Subject: [PATCH 2504/3904] removes --- src/cc/cclib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b02456b33..4fc753b8c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -589,7 +589,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/src/util.h" +/*#include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" @@ -600,7 +600,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" -#include "../secp256k1/src/hash_impl.h" +#include "../secp256k1/src/hash_impl.h"*/ struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; From c95287714595b64b419d4af5c8e2ad31f9b9ee0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:16:57 -1100 Subject: [PATCH 2505/3904] Revert --- src/cc/cclib.cpp | 6 ++---- src/secp256k1/src/secp256k1.c | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 4fc753b8c..3c0baf856 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -600,14 +600,14 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" -#include "../secp256k1/src/hash_impl.h"*/ +#include "../secp256k1/src/hash_impl.h" struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; secp256k1_ecmult_gen_context ecmult_gen_ctx; secp256k1_callback illegal_callback; secp256k1_callback error_callback; -}; +};*/ typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); @@ -624,8 +624,6 @@ return 0; \ } while(0) //#include "../secp256k1/src/secp256k1.c" -#include "../secp256k1/src/modules/schnorrsig/main_impl.h" -#include "../secp256k1/src/modules/musig/main_impl.h" #include "musig.cpp" #endif diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 4225607ff..7861a5f79 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -601,6 +601,8 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif +#include "../secp256k1/src/modules/schnorrsig/main_impl.h" +#include "../secp256k1/src/modules/musig/main_impl.h" #ifdef ENABLE_MODULE_RECOVERY # include "modules/recovery/main_impl.h" From ecdd65b56690b0471b783c53ccf18ed1f9cf7980 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:20:11 -1100 Subject: [PATCH 2506/3904] xx --- src/cc/cclib.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 3c0baf856..f7df312e7 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,12 +584,12 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" -#define USE_BASIC_CONFIG +/*#define USE_BASIC_CONFIG #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" -/*#include "../secp256k1/src/util.h" +#include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" @@ -607,7 +607,7 @@ struct secp256k1_context_struct { secp256k1_ecmult_gen_context ecmult_gen_ctx; secp256k1_callback illegal_callback; secp256k1_callback error_callback; -};*/ +}; typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); @@ -621,7 +621,7 @@ if (EXPECT(!(cond), 0)) { \ secp256k1_callback_call(&ctx->illegal_callback, #cond); \ return 0; \ } \ -} while(0) +} while(0)*/ //#include "../secp256k1/src/secp256k1.c" From 4c934237feb82112ee9a0bd0d721e8034d15ef1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:25:31 -1100 Subject: [PATCH 2507/3904] Almost --- src/cc/cclib.cpp | 4 +++- src/cc/musig.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f7df312e7..a83107234 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -614,7 +614,6 @@ extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge extern "C" int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); extern "C" void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); -extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ @@ -624,6 +623,9 @@ return 0; \ } while(0)*/ //#include "../secp256k1/src/secp256k1.c" +extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); +extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); #include "musig.cpp" #endif diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 5d56635aa..520234da1 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -15,9 +15,11 @@ #include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/include/secp256k1_schnorrsig.h" +//#include "../secp256k1/include/secp256k1_schnorrsig.h" #include "../secp256k1/include/secp256k1_musig.h" +typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; + #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 From d17ef9b3e264e7bac9cccc4d27de3b19ae7fc40d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:28:36 -1100 Subject: [PATCH 2508/3904] ees --- src/cc/cclib.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index a83107234..484be6191 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,10 +584,11 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" +#include "../secp256k1/include/secp256k1.h" +#include "../secp256k1/src/ecmult.h" /*#define USE_BASIC_CONFIG #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" -#include "../secp256k1/include/secp256k1.h" #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" @@ -602,12 +603,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/eckey_impl.h" #include "../secp256k1/src/hash_impl.h" -struct secp256k1_context_struct { - secp256k1_ecmult_context ecmult_ctx; - secp256k1_ecmult_gen_context ecmult_gen_ctx; - secp256k1_callback illegal_callback; - secp256k1_callback error_callback; -}; + typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); @@ -623,6 +619,12 @@ return 0; \ } while(0)*/ //#include "../secp256k1/src/secp256k1.c" +struct secp256k1_context_struct { + secp256k1_ecmult_context ecmult_ctx; + secp256k1_ecmult_gen_context ecmult_gen_ctx; + secp256k1_callback illegal_callback; + secp256k1_callback error_callback; +}; extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); From 7833fc5f4b1af8d19a49edb8dfd396da3ff2c995 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:29:47 -1100 Subject: [PATCH 2509/3904] Sss --- src/cc/cclib.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 484be6191..35a6362ec 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,12 +584,12 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" -#include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/src/ecmult.h" -/*#define USE_BASIC_CONFIG +#define USE_BASIC_CONFIG #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" +#include "../secp256k1/include/secp256k1.h" +/* #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" From 0f1ceab602d3c3cf48127072a5d39727e1f5b5aa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 21 Feb 2019 21:30:39 +0800 Subject: [PATCH 2510/3904] minsigs = 6. --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index c30c8f17e..4151e52b6 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int32_t iguanaPort = 9997; static const int8_t BTCminsigs = 13; -static const int8_t overrideMinSigs = 0; +static const int8_t overrideMinSigs = 6; static const char *iguanaSeeds[8][1] = { {"80.240.17.222"}, From 7573d3f815cca5c5d08e9e8a56c9a9b3f41c6c93 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:31:15 -1100 Subject: [PATCH 2511/3904] Tes --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 35a6362ec..5681a380f 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,6 +588,7 @@ uint256 juint256(cJSON *obj) #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" +#include "../secp256k1/include/ecmult.h" /* #include "../secp256k1/src/util.h" From aec159bdc0bcbceb80f2ccb4d4e3bc479854cb2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:31:47 -1100 Subject: [PATCH 2512/3904] Src --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 5681a380f..8a96a81bf 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,7 +588,7 @@ uint256 juint256(cJSON *obj) #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/include/ecmult.h" +#include "../secp256k1/src/ecmult.h" /* #include "../secp256k1/src/util.h" From 3106e5f0a83784a4dff7128920acfc2f44eba786 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:33:11 -1100 Subject: [PATCH 2513/3904] typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; --- src/cc/cclib.cpp | 3 +++ src/cc/musig.cpp | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8a96a81bf..76d1dfa39 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -589,6 +589,9 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" #include "../secp256k1/src/ecmult.h" +#include "../secp256k1/src/ecmult_gen.h" + +typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; /* #include "../secp256k1/src/util.h" diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 520234da1..318cb7664 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -18,7 +18,6 @@ //#include "../secp256k1/include/secp256k1_schnorrsig.h" #include "../secp256k1/include/secp256k1_musig.h" -typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 From 51ae3da5ec6a575c8d7b003f62e72af65a03949a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:38:45 -1100 Subject: [PATCH 2514/3904] #ifdef __cplusplus --- src/secp256k1/src/ecmult.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index fbcf6a445..3ed2e435a 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -78,6 +78,10 @@ typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge * 0 if there is not enough scratch space for a single point or * callback returns 0 */ + +#ifdef __cplusplus +extern "C" +#endif int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #endif /* SECP256K1_ECMULT_H */ From 4da533ffc5cb53f0ea28010601e09ec8effc46c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:42:25 -1100 Subject: [PATCH 2515/3904] Test --- src/cc/cclib.cpp | 1 + src/secp256k1/src/ecmult_impl.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 76d1dfa39..5d321bdae 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -629,6 +629,7 @@ struct secp256k1_context_struct { secp256k1_callback illegal_callback; secp256k1_callback error_callback; }; + extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 116a9f154..6fd705ef4 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1522,6 +1522,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); + int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; From b09b0261aca1812eef070b5046aad2b4cbefebf7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:45:02 -1100 Subject: [PATCH 2516/3904] Test --- src/secp256k1/src/ecmult_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 6fd705ef4..bea64ebcd 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1525,7 +1525,7 @@ typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; - + xxx int (*f)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t, size_t); size_t max_points; size_t n_batches; From c44e7ae038a9b462b83f69dbb2f31d9fe1b5e97d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:48:05 -1100 Subject: [PATCH 2517/3904] Fix --- src/secp256k1/src/ecmult_impl.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index bea64ebcd..b761304cf 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** @@ -1525,7 +1525,6 @@ typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; - xxx int (*f)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t, size_t); size_t max_points; size_t n_batches; From ccd1b516294fedc391e29b763aa640e72f58fdb0 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 15:36:02 +0100 Subject: [PATCH 2518/3904] resolve conflict --- src/Makefile.am | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index e9d41a510..22668c91f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -572,16 +572,14 @@ komodod_LDADD += \ $(LIBVERUS_CRYPTO) \ $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) - + if TARGET_DARWIN -komodod_LDADD += libcc.dylib -endif -if TARGET_WINDOWS -komodod_LDADD += libcc.dll +komodod_LDADD += libcc.dylib $(LIBSECP256K1) else -komodod_LDADD += libcc.so +komodod_LDADD += libcc.so $(LIBSECP256K1) endif + if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) endif From a659c209e489adf22ec8cad02e016d3dd3c75731 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 21 Feb 2019 22:38:40 +0800 Subject: [PATCH 2519/3904] it builds --- src/cc/rogue/main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index ca05226d3..93391d153 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -30,7 +30,7 @@ extern char Gametxidstr[67]; #define SATOSHIDEN ((uint64_t)100000000L) #define dstr(x) ((double)(x) / SATOSHIDEN) #define KOMODO_ASSETCHAIN_MAXLEN 65 -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],IPADDRESS[100]; #ifndef _BITS256 #define _BITS256 @@ -583,7 +583,7 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char * return(chunk.memory); } -uint16_t _komodo_userpass(char *username,char *password,FILE *fp) +uint16_t _komodo_userpass(char *username, char *password, char *ipaddress, FILE *fp) { char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0; rpcuser = rpcpassword = 0; @@ -602,6 +602,10 @@ uint16_t _komodo_userpass(char *username,char *password,FILE *fp) port = atoi(parse_conf_line(str,(char *)"rpcport")); //fprintf(stderr,"rpcport.%u in file\n",port); } + else if ( (str= strstr(line,(char *)"ipaddress")) != 0 ) + { + ipaddress = parse_conf_line(str,(char *)"ipaddress"); + } } if ( rpcuser != 0 && rpcpassword != 0 ) { @@ -653,7 +657,7 @@ uint16_t _komodo_userpass(char *username,char *password,FILE *fp) //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname); }*/ -uint16_t komodo_userpass(char *userpass,char *symbol) +uint16_t komodo_userpass(char *userpass,char *symbol,char *ipaddress) { FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[KOMODO_ASSETCHAIN_MAXLEN]; userpass[0] = 0; @@ -669,7 +673,7 @@ uint16_t komodo_userpass(char *userpass,char *symbol) //komodo_statefname(fname,symbol,confname); if ( (fp= fopen(confname,"rb")) != 0 ) { - port = _komodo_userpass(username,password,fp); + port = _komodo_userpass(username,password,ipaddress,fp); sprintf(userpass,"%s:%s",username,password); if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 ) strcpy(USERPASS,userpass); @@ -688,7 +692,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) params = (char *)"[]"; if ( strlen(params) < sizeof(postdata)-128 ) { - sprintf(url,(char *)"http://127.0.0.1:%u",port); + sprintf(url,(char *)"http://%s:%u",IPADDRESS,port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); @@ -793,7 +797,7 @@ int main(int argc, char **argv, char **envp) ASSETCHAINS_SYMBOL[j++] = toupper(c); } ASSETCHAINS_SYMBOL[j++] = 0; - ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL); + ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL,IPADDRESS); printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s)\n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { @@ -813,5 +817,3 @@ int main(int argc, char **argv, char **envp) return(rogue(argc,argv,envp)); } } - - From f6d693768f1f733dbdb18c02a1b904c23cfcb5f5 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 15:40:26 +0100 Subject: [PATCH 2520/3904] winify Makefile --- src/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 22668c91f..fa2c17b5d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -575,11 +575,13 @@ komodod_LDADD += \ if TARGET_DARWIN komodod_LDADD += libcc.dylib $(LIBSECP256K1) +endif +if TARGET_WINDOWS +komodod_LDADD += libcc.dll $(LIBSECP256K1) else komodod_LDADD += libcc.so $(LIBSECP256K1) endif - if ENABLE_PROTON komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) endif From 0816deb0b0f328e0ded5ee722b088d359c97956a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 04:04:18 -1100 Subject: [PATCH 2521/3904] Musig combine rpc --- src/cc/musig.cpp | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 318cb7664..865ec311c 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -110,9 +110,40 @@ UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - result.push_back(Pair("result","success")); - return(result); + static secp256k1_context *ctx; secp256k1_scratch_space scratch; + size_t clen = CPubKey::PUBLIC_KEY_SIZE; + UniValue result(UniValue::VOBJ); int32_t i,n; uint8_t pkhash[32]; char *hexstr,str[67]; secp256k1_pubkey combined_pk,spk; std::vector pubkeys; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + for (i=0; i 0 ) + pubkeys.push_back(spk); + else return(cclib_error(result,"error parsing pk")); + } else return(cclib_error(result,"all pubkeys must be 33 bytes hexdata")); + } + if ( secp256k1_musig_pubkey_combine(ctx,&scratch,&combined_pk,pkhash,&pubkeys[0],n) > 0 ) + { + if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&combined_pk,SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) + { + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",pkhash[i]); + str[64] = 0; + result.push_back(Pair("pkhash",str)); + + for (i=0; i<33; i++) + sprintf(&str[i<<1],"%02x",((uint8_t *)pk.begin())[i]); + str[66] = 0; + result.push_back(Pair("combined_pk",str)); + result.push_back(Pair("result","success")); + } else return(cclib_error(result,"error serializeing combined_pk")); + } else return(cclib_error(result,"error combining pukbeys")); + } else return(cclib_error(result,"need pubkeys params")); } UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) From a96f0c861eae0bc5df1d327d8ddbc73a10abe5e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 04:06:22 -1100 Subject: [PATCH 2522/3904] Declare pk --- src/cc/musig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 865ec311c..057307fae 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -112,7 +112,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; secp256k1_scratch_space scratch; size_t clen = CPubKey::PUBLIC_KEY_SIZE; - UniValue result(UniValue::VOBJ); int32_t i,n; uint8_t pkhash[32]; char *hexstr,str[67]; secp256k1_pubkey combined_pk,spk; std::vector pubkeys; + UniValue result(UniValue::VOBJ); CPubKey pk; int32_t i,n; uint8_t pkhash[32]; char *hexstr,str[67]; secp256k1_pubkey combined_pk,spk; std::vector pubkeys; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) From 556a45f37b87d7fe7f9ce2445a7044964dee4f81 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 04:08:41 -1100 Subject: [PATCH 2523/3904] Extern C --- src/cc/cclib.cpp | 19 ------------------- src/cc/musig.cpp | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 5d321bdae..bfd57e61d 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,14 +584,6 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" -#define USE_BASIC_CONFIG -#define ENABLE_MODULE_MUSIG -#include "../secp256k1/src/basic-config.h" -#include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/src/ecmult.h" -#include "../secp256k1/src/ecmult_gen.h" - -typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; /* #include "../secp256k1/src/util.h" @@ -623,17 +615,6 @@ return 0; \ } while(0)*/ //#include "../secp256k1/src/secp256k1.c" -struct secp256k1_context_struct { - secp256k1_ecmult_context ecmult_ctx; - secp256k1_ecmult_gen_context ecmult_gen_ctx; - secp256k1_callback illegal_callback; - secp256k1_callback error_callback; -}; - -extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); -extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); -extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); - #include "musig.cpp" #endif diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 057307fae..23c14bb8e 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -13,8 +13,28 @@ * * ******************************************************************************/ - +#define USE_BASIC_CONFIG +#define ENABLE_MODULE_MUSIG +#include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" +#include "../secp256k1/src/ecmult.h" +#include "../secp256k1/src/ecmult_gen.h" + +typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; +struct secp256k1_context_struct { + secp256k1_ecmult_context ecmult_ctx; + secp256k1_ecmult_gen_context ecmult_gen_ctx; + secp256k1_callback illegal_callback; + secp256k1_callback error_callback; +}; + +extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); +extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); +extern "C" int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp256k1_scratch_space *scratch, secp256k1_pubkey *combined_pk, unsigned char *pk_hash32, const secp256k1_pubkey *pubkeys, size_t n_pubkeys); + + +//#include "../secp256k1/include/secp256k1.h" //#include "../secp256k1/include/secp256k1_schnorrsig.h" #include "../secp256k1/include/secp256k1_musig.h" From c96ca4eab9a842e001edeedb2ad6e97a687d693c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 04:12:42 -1100 Subject: [PATCH 2524/3904] Test --- src/cc/musig.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 23c14bb8e..ee4c3400e 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -135,6 +135,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); CPubKey pk; int32_t i,n; uint8_t pkhash[32]; char *hexstr,str[67]; secp256k1_pubkey combined_pk,spk; std::vector pubkeys; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + fprintf(stderr,"args.(%s)\n",jprint(params,0)); if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { for (i=0; i Date: Thu, 21 Feb 2019 04:17:20 -1100 Subject: [PATCH 2525/3904] Test --- src/cc/musig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index ee4c3400e..0b8600de4 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -135,9 +135,9 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); CPubKey pk; int32_t i,n; uint8_t pkhash[32]; char *hexstr,str[67]; secp256k1_pubkey combined_pk,spk; std::vector pubkeys; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - fprintf(stderr,"args.(%s)\n",jprint(params,0)); if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { + fprintf(stderr,"n.%d args.(%s)\n",jprint(params,0)); for (i=0; i Date: Thu, 21 Feb 2019 04:18:37 -1100 Subject: [PATCH 2526/3904] N, --- src/cc/musig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 0b8600de4..0c2ce2d15 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -137,7 +137,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { - fprintf(stderr,"n.%d args.(%s)\n",jprint(params,0)); + fprintf(stderr,"n.%d args.(%s)\n",n,jprint(params,0)); for (i=0; i Date: Thu, 21 Feb 2019 04:20:26 -1100 Subject: [PATCH 2527/3904] -scratch --- src/cc/musig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 0c2ce2d15..0e7f374db 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -130,7 +130,7 @@ UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - static secp256k1_context *ctx; secp256k1_scratch_space scratch; + static secp256k1_context *ctx; size_t clen = CPubKey::PUBLIC_KEY_SIZE; UniValue result(UniValue::VOBJ); CPubKey pk; int32_t i,n; uint8_t pkhash[32]; char *hexstr,str[67]; secp256k1_pubkey combined_pk,spk; std::vector pubkeys; if ( ctx == 0 ) @@ -148,7 +148,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) else return(cclib_error(result,"error parsing pk")); } else return(cclib_error(result,"all pubkeys must be 33 bytes hexdata")); } - if ( secp256k1_musig_pubkey_combine(ctx,&scratch,&combined_pk,pkhash,&pubkeys[0],n) > 0 ) + if ( secp256k1_musig_pubkey_combine(ctx,NULL,&combined_pk,pkhash,&pubkeys[0],n) > 0 ) { if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&combined_pk,SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) { From d32c12e0bbfb75f620b80ff84e8affbd033694f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 04:24:21 -1100 Subject: [PATCH 2528/3904] Return! --- src/cc/musig.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 0e7f374db..1a664f4b4 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -162,6 +162,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) str[66] = 0; result.push_back(Pair("combined_pk",str)); result.push_back(Pair("result","success")); + return(result); } else return(cclib_error(result,"error serializeing combined_pk")); } else return(cclib_error(result,"error combining pukbeys")); } else return(cclib_error(result,"need pubkeys params")); From c6b2a865e65c8bb54a54baafe1d2e3cb3fa064c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 04:33:06 -1100 Subject: [PATCH 2529/3904] Music usage example --- src/cc/musig.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 1a664f4b4..17c4d1368 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -13,6 +13,52 @@ * * ******************************************************************************/ +/* first make a combined pk: +./c cclib combine 18 \"[%2202aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22,%22039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22]\" +{ + "pkhash": "5be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba", + "combined_pk": "032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b", + "result": "success" +} +*/ + +/* second, send 0.777 coins to the combined_pk + ./c cclib send 18 \"[%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,0.777]\" + { + "hex": "0400008085202f8901bf7afcbbab7a5e1ba20c8010325e199305afa7d15b4bc86a589a512201d39924000000004847304402203e0cff8aaa831dd990afd979bbc0a648316f77407cb5e02780d18e0670f5172a0220283d5c52d0406b10c508cc2b19dd6dbe2420e7c5cf431a1d41072d0eec28edb901ffffffff03b0c2a10400000000302ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cca91e223700000000232102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac0000000000000000266a24127821032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b00000000900000000000000000000000000000", + "txid": "cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be", + "result": "success" + } + + { + "value": 0.77710000, + "valueZat": 77710000, + "n": 0, + "scriptPubKey": { + "asm": "a22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401 OP_CHECKCRYPTOCONDITION", + "hex": "2ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cc", + "reqSigs": 1, + "type": "cryptocondition", + "addresses": [ + "RKWS7jxyjPX9iaJttk8iMKf1AumanKypez" + ] + } + change script: 2102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac + + sendtxid: cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be + + broadcast sendtxid and wait for it to be confirmed. then get the msg we need to sign: + + ./c cclib calcmsg 18 \"[%22cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22]\" + + { + "result": "success", + "msg": "63b799913d4c9487f321b32d6ae8614f653f38e0b50d4df4bc1d36339ea18485" + } + +*/ + + #define USE_BASIC_CONFIG #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" @@ -82,7 +128,6 @@ int32_t musig_msghash(uint8_t *msg,uint256 prevhash,int32_t prevn,CTxOut vout,CP { CScript data; uint256 hash; int32_t len = 0; data << E_MARSHAL(ss << prevhash << prevn << vout << pk); -fprintf(stderr,"data size %d\n",(int32_t)data.size()); hash = Hash(data.begin(),data.end()); memcpy(msg,&hash,sizeof(hash)); return(0); @@ -137,7 +182,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { - fprintf(stderr,"n.%d args.(%s)\n",n,jprint(params,0)); + //fprintf(stderr,"n.%d args.(%s)\n",n,jprint(params,0)); for (i=0; i Date: Thu, 21 Feb 2019 16:35:00 +0100 Subject: [PATCH 2530/3904] add WIN makefile target: rogue.exe --- src/cc/rogue/Makefile_win | 222 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 src/cc/rogue/Makefile_win diff --git a/src/cc/rogue/Makefile_win b/src/cc/rogue/Makefile_win new file mode 100644 index 000000000..dbc900e48 --- /dev/null +++ b/src/cc/rogue/Makefile_win @@ -0,0 +1,222 @@ +############################################################################### +# +# Makefile for rogue +# +# Rogue: Exploring the Dungeons of Doom +# Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman +# All rights reserved. +# +# See the file LICENSE.TXT for full copyright and licensing information. +# +############################################################################### + +############################################################################### +# Site configuration occurs beneath this comment +# Typically ./configure (autoconf tools) configures this section +# This section could be manually configured if autoconf/configure fails +############################################################################### + +DISTNAME=rogue5.4.4 +PACKAGE_TARNAME = rogue-5.4.4 +PROGRAM=rogue + +O=o + +#CC=gcc +CC = x86_64-w64-mingw32-gcc + +#CFLAGS=-O2 +CFLAGS= -g -O2 -I./ncurses/include + +#LIBS=-lcurses +LIBS = -L./ncurses/lib -lncursesw + +#RM=rm -f +RM = rm -f + +#GROFF=groff +GROFF = groff + +#NROFF=nroff +NROFF = nroff + +#TBL=tbl +TBL = tbl + +#COLCRT=colcrt +COLCRT = colcrt + +#SED=sed +SED = sed + +#SCOREFILE=rogue54.scr +SCOREFILE = rogue.scr + +#LOCKFILE=rogue54.lck +LOCKFILE = rogue.lck + +#GROUPOWNER=games +GROUPOWNER = + +#CPPFLAGS=-DHAVE_CONFIG_H +CPPFLAGS =-DHAVE_CONFIG_H + +#DISTFILE = $(PROGRAM) +DISTFILE = $(DISTNAME)-x86_64-w64-mingw32 + +INSTALL=./install-sh + +#INSTGROUP=-g games +INSTGROUP= +#INSTOWNER=-u root +INSTOWNER= + +CHGRP=chgrp + +MKDIR=mkdir + +TOUCH=touch + +RMDIR=rmdir + +CHMOD=chmod + +DESTDIR= + +prefix=/usr/local +exec_prefix=${prefix} +datarootdir=${prefix}/share +datadir=${datarootdir} +bindir=${exec_prefix}/bin +mandir=${datarootdir}/man +docdir=${datarootdir}/doc/${PACKAGE_TARNAME} +man6dir = $(mandir)/man6 + +############################################################################### +# Site configuration occurs above this comment +# It should not be necessary to change anything below this comment +############################################################################### + +HDRS = rogue.h extern.h score.h +OBJS1 = vers.$(O) extern.$(O) armor.$(O) chase.$(O) command.$(O) \ + daemon.$(O) daemons.$(O) fight.$(O) init.$(O) io.$(O) list.$(O) \ + mach_dep.$(O) rogue.$(O) mdport.$(O) misc.$(O) monsters.$(O) \ + move.$(O) new_level.$(O) +OBJS2 = options.$(O) pack.$(O) passages.$(O) potions.$(O) rings.$(O) \ + rip.$(O) rooms.$(O) save.$(O) scrolls.$(O) state.$(O) sticks.$(O) \ + things.$(O) weapons.$(O) wizard.$(O) xcrypt.$(O) +OBJS = main.$(O) $(OBJS1) $(OBJS2) +CFILES = vers.c extern.c armor.c chase.c command.c daemon.c \ + daemons.c fight.c init.c io.c list.c mach_dep.c \ + main.c mdport.c misc.c monsters.c move.c new_level.c \ + options.c pack.c passages.c potions.c rings.c rip.c \ + rooms.c save.c scrolls.c state.c sticks.c things.c \ + weapons.c wizard.c xcrypt.c +MISC_C = findpw.c scedit.c scmisc.c +DOCSRC = rogue.me.in rogue.6.in rogue.doc.in rogue.html.in rogue.cat.in +DOCS = $(PROGRAM).doc $(PROGRAM).html $(PROGRAM).cat $(PROGRAM).me \ + $(PROGRAM).6 +AFILES = configure Makefile.in configure.ac config.h.in config.sub config.guess \ + install-sh rogue.6.in rogue.me.in rogue.html.in rogue.doc.in rogue.cat.in +MISC = Makefile.std LICENSE.TXT rogue54.sln rogue54.vcproj rogue.spec \ + rogue.png rogue.desktop + +.SUFFIXES: .obj + +.c.obj: + $(CC) $(CFLAGS) $(CPPFLAGS) /c $*.c + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c + +#$(RM) rogue.so ; $(CC) -shared -o rogue.so cursesd.c $(OBJS1) $(OBJS2); $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + +$(PROGRAM): $(HDRS) $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@.exe + +clean: + $(RM) $(OBJS1); $(RM) main.$(O) ; $(RM) rogue.so + $(RM) $(OBJS2) + $(RM) core a.exe a.out a.exe.stackdump $(PROGRAM) $(PROGRAM).exe + $(RM) $(PROGRAM).tar $(PROGRAM).tar.gz $(PROGRAM).zip + $(RM) $(DISTNAME)/* + -rmdir $(DISTNAME) + +maintainer-clean: + $(RM) config.h + $(RM) Makefile + $(RM) config.status + $(RM) -r autom4te.cache + $(RM) config.log + $(RM) $(PROGRAM).scr $(PROGRAM).lck + +stddocs: + sed -e 's/rogue/rogue/' -e 's/rogue.scr/rogue.scr/' rogue.6.in > rogue.6 + sed -e 's/rogue/rogue/' -e 's/rogue.scr/rogue.scr/' rogue.me.in > rogue.me + sed -e 's/rogue/rogue/' -e 's/rogue.scr/rogue.scr/' rogue.html.in > rogue,html + sed -e 's/rogue/rogue/' -e 's/rogue.scr/rogue.scr/' rogue.doc.in > rogue.doc + sed -e 's/rogue/rogue/' -e 's/rogue.scr/rogue.scr/' rogue.cat.in > rogue.cat + +dist.src: + $(MAKE) $(MAKEFILE) clean + mkdir $(DISTNAME) + cp $(CFILES) $(HDRS) $(MISC) $(AFILES) $(DISTNAME) + tar cf $(DISTNAME)-src.tar $(DISTNAME) + gzip -f $(DISTNAME)-src.tar + rm -fr $(DISTNAME) + +findpw: findpw.c xcrypt.o mdport.o xcrypt.o + $(CC) -s -o findpw findpw.c xcrypt.o mdport.o -lcurses + +scedit: scedit.o scmisc.o vers.o mdport.o xcrypt.o + $(CC) -s -o scedit vers.o scedit.o scmisc.o mdport.o xcrypt.o -lcurses + +scmisc.o scedit.o: + $(CC) -O -c $(SF) $*.c + +$(PROGRAM).doc: rogue.me + if test "x$(GROFF)" != "x" -a "x$(SED)" != "x" ; then \ + $(GROFF) -P-c -t -me -Tascii rogue.me | $(SED) -e 's/.\x08//g' > $(PROGRAM).doc ;\ + elif test "x$(NROFF)" != "x" -a "x$(TBL)" != "x" -a "x$(COLCRT)" != "x" ; then \ + tbl rogue.me | $(NROFF) -me | colcrt - > $(PROGRAM).doc ;\ + fi + +$(PROGRAM).cat: rogue.6 + if test "x$(GROFF)" != "x" -a "x$(SED)" != "x" ; then \ + $(GROFF) -Tascii -man rogue.6 | $(SED) -e 's/.\x08//g' > $(PROGRAM).cat ;\ + elif test "x$(NROFF)" != "x" -a "x$(TBL)" != "x" -a "x$(COLCRT)" != "x" ; then \ + $(NROFF) -man rogue.6 | $(COLCRT) - > $(PROGRAM).cat ;\ + fi + +dist: clean $(PROGRAM) + tar cf $(DISTFILE).tar $(PROGRAM) LICENSE.TXT $(DOCS) + gzip -f $(DISTFILE).tar + +install: $(PROGRAM) + -$(TOUCH) test + -if test ! -f $(DESTDIR)$(SCOREFILE) ; then $(INSTALL) -m 0664 test $(DESTDIR)$(SCOREFILE) ; fi + -$(INSTALL) -m 0755 $(PROGRAM) $(DESTDIR)$(bindir)/$(PROGRAM) + -if test "x$(GROUPOWNER)" != "x" ; then \ + $(CHGRP) $(GROUPOWNER) $(DESTDIR)$(SCOREFILE) ; \ + $(CHGRP) $(GROUPOWNER) $(DESTDIR)$(bindir)/$(PROGRAM) ; \ + $(CHMOD) 02755 $(DESTDIR)$(bindir)/$(PROGRAM) ; \ + $(CHMOD) 0464 $(DESTDIR)$(SCOREFILE) ; \ + fi + -if test -d $(man6dir) ; then $(INSTALL) -m 0644 rogue.6 $(DESTDIR)$(man6dir)/$(PROGRAM).6 ; fi + -if test ! -d $(man6dir) ; then $(INSTALL) -m 0644 rogue.6 $(DESTDIR)$(mandir)/$(PROGRAM).6 ; fi + -$(INSTALL) -m 0644 rogue.doc $(DESTDIR)$(docdir)/$(PROGRAM).doc + -$(INSTALL) -m 0644 rogue.html $(DESTDIR)$(docdir)/$(PROGRAM).html + -$(INSTALL) -m 0644 rogue.cat $(DESTDIR)$(docdir)/$(PROGRAM).cat + -$(INSTALL) -m 0644 LICENSE.TXT $(DESTDIR)$(docdir)/LICENSE.TXT + -$(INSTALL) -m 0644 rogue.me $(DESTDIR)$(docdir)/$(PROGRAM).me + -if test ! -f $(DESTDIR)$(LOCKFILE) ; then $(INSTALL) -m 0666 test $(DESTDIR)$(LOCKFILE) ; $(RM) $(DESTDIR)$(LOCKFILE) ; fi + -$(RM) test + +uninstall: + -$(RM) $(DESTDIR)$(bindir)/$(PROGRAM) + -$(RM) $(DESTDIR)$(man6dir)/$(PROGRAM).6 + -$(RM) $(DESTDIR)$(docdir)$(PROGRAM)/$(PROGRAM).doc + -$(RM) $(DESTDIR)$(LOCKFILE) + -$(RMDIR) $(DESTDIR)$(docdir)$(PROGRAM) + +reinstall: uninstall install From e8a72377f732410718b5e4b912270a9725e2a943 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 16:36:12 +0100 Subject: [PATCH 2531/3904] WINify makerogue modify rogue game build --- src/cc/makerogue | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index a38eab6a4..3068fa38e 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,7 +1,26 @@ #!/bin/sh cd rogue; -./configure -make; cd .. + +if [ "$HOST" = "x86_64-w64-mingw32" ]; then + echo building rogue.exe... + if make -f Makefile_win "$@"; then + echo rogue.exe build SUCCESSFUL + cd .. + else + echo rogue.exe build FAILED + exit 1 + fi +else + echo building rogue... + ./configure + if make "$@"; then + echo rogue build SUCCESSFUL + cd .. + else + echo rogue build FAILED + exit 1 + fi +fi if make -f Makefile_rogue "$@"; then echo ROGUE BUILD SUCCESSFUL From cfcde22a1e0a0ce80e4c0e365ba53282e79bb920 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 17:48:52 +0100 Subject: [PATCH 2532/3904] add ncurses for rogue.exe --- src/cc/makerogue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/makerogue b/src/cc/makerogue index 3068fa38e..ff175c586 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -3,6 +3,10 @@ cd rogue; if [ "$HOST" = "x86_64-w64-mingw32" ]; then echo building rogue.exe... + mkdir ncurses && cd ncurses + wget https://invisible-island.net/datafiles/release/mingw32.zip + unzip mingw32.zip && delete mingw32.zip + cd .. if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL cd .. From 7453b21b6da2b0f7ecc5bac28832cfb3ccda88c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 06:01:19 -1100 Subject: [PATCH 2533/3904] Comments --- src/cc/musig.cpp | 151 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 17c4d1368..ec7f5e788 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -217,6 +217,37 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); result.push_back(Pair("result","success")); + /** Initializes a signing session for a signer + * + * Returns: 1: session is successfully initialized + * 0: session could not be initialized: secret key or secret nonce overflow + * Args: ctx: pointer to a context object, initialized for signing (cannot + * be NULL) + * Out: session: the session structure to initialize (cannot be NULL) + * signers: an array of signers' data to be initialized. Array length must + * equal to `n_signers` (cannot be NULL) + * nonce_commitment32: filled with a 32-byte commitment to the generated nonce + * (cannot be NULL) + * In: session_id32: a *unique* 32-byte ID to assign to this session (cannot be + * NULL). If a non-unique session_id32 was given then a partial + * signature will LEAK THE SECRET KEY. + * msg32: the 32-byte message to be signed. Shouldn't be NULL unless you + * require sharing public nonces before the message is known + * because it reduces nonce misuse resistance. If NULL, must be + * set with `musig_session_set_msg` before signing and verifying. + * combined_pk: the combined public key of all signers (cannot be NULL) + * pk_hash32: the 32-byte hash of the signers' individual keys (cannot be + * NULL) + * n_signers: length of signers array. Number of signers participating in + * the MuSig. Must be greater than 0 and at most 2^32 - 1. + * my_index: index of this signer in the signers array + * seckey: the signer's 32-byte secret key (cannot be NULL) + */ + //if (!secp256k1_musig_session_initialize(ctx, &musig_session[i], signer_data[i], nonce_commitment[i], session_id32, msg32, &combined_pk, pk_hash, N_SIGNERS, i, seckeys[i])) + //return 0; + // randombytes_buf(buf, num); + + //nonce_commitment_ptr[i] = &nonce_commitment[i][0]; return(result); } @@ -224,6 +255,25 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); result.push_back(Pair("result","success")); + /** Gets the signer's public nonce given a list of all signers' data with commitments + * + * Returns: 1: public nonce is written in nonce + * 0: signer data is missing commitments or session isn't initialized + * for signing + * Args: ctx: pointer to a context object (cannot be NULL) + * session: the signing session to get the nonce from (cannot be NULL) + * signers: an array of signers' data initialized with + * `musig_session_initialize`. Array length must equal to + * `n_commitments` (cannot be NULL) + * Out: nonce: the nonce (cannot be NULL) + * In: commitments: array of 32-byte nonce commitments (cannot be NULL) + * n_commitments: the length of commitments and signers array. Must be the total + * number of signers participating in the MuSig. + */ + // Set nonce commitments in the signer data and get the own public nonce + //if (!secp256k1_musig_session_get_public_nonce(ctx, &musig_session[i], signer_data[i], &nonce[i], nonce_commitment_ptr, N_SIGNERS)) + // return 0; + return(result); } @@ -231,13 +281,69 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); result.push_back(Pair("result","success")); - return(result); + /** Checks a signer's public nonce against a commitment to said nonce, and update + * data structure if they match + * + * Returns: 1: commitment was valid, data structure updated + * 0: commitment was invalid, nothing happened + * Args: ctx: pointer to a context object (cannot be NULL) + * signer: pointer to the signer data to update (cannot be NULL). Must have + * been used with `musig_session_get_public_nonce` or initialized + * with `musig_session_initialize_verifier`. + * In: nonce: signer's alleged public nonce (cannot be NULL) + */ + //if (!secp256k1_musig_set_nonce(ctx, &signer_data[i][j], &nonce[j])) { + + + /** Updates a session with the combined public nonce of all signers. The combined + * public nonce is the sum of every signer's public nonce. + * + * Returns: 1: nonces are successfully combined + * 0: a signer's nonce is missing + * Args: ctx: pointer to a context object (cannot be NULL) + * session: session to update with the combined public nonce (cannot be + * NULL) + * signers: an array of signers' data, which must have had public nonces + * set with `musig_set_nonce`. Array length must equal to `n_signers` + * (cannot be NULL) + * n_signers: the length of the signers array. Must be the total number of + * signers participating in the MuSig. + * Out: nonce_is_negated: a pointer to an integer that indicates if the combined + * public nonce had to be negated. + * adaptor: point to add to the combined public nonce. If NULL, nothing is + * added to the combined nonce. + */ + // after all nonces: if (!secp256k1_musig_session_combine_nonces(ctx, &musig_session[i], signer_data[i], N_SIGNERS, NULL, NULL)) { + return(result); } UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); result.push_back(Pair("result","success")); + /** Produces a partial signature + * + * Returns: 1: partial signature constructed + * 0: session in incorrect or inconsistent state + * Args: ctx: pointer to a context object (cannot be NULL) + * session: active signing session for which the combined nonce has been + * computed (cannot be NULL) + * Out: partial_sig: partial signature (cannot be NULL) + */ + //if (!secp256k1_musig_partial_sign(ctx, &musig_session[i], &partial_sig[i])) { + /** Parse and verify a MuSig partial signature. + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: pointer to a signature object + * In: in32: pointer to the 32-byte signature to be parsed + * + * After the call, sig will always be initialized. If parsing failed or the + * encoded numbers are out of range, signature verification with it is + * guaranteed to fail for every message and public key. + */ + //SECP256K1_API int secp256k1_musig_partial_signature_parse( + return(result); } @@ -245,13 +351,54 @@ UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { UniValue result(UniValue::VOBJ); result.push_back(Pair("result","success")); - return(result); + /** Checks that an individual partial signature verifies + * + * This function is essential when using protocols with adaptor signatures. + * However, it is not essential for regular MuSig's, in the sense that if any + * partial signatures does not verify, the full signature will also not verify, so the + * problem will be caught. But this function allows determining the specific party + * who produced an invalid signature, so that signing can be restarted without them. + * + * Returns: 1: partial signature verifies + * 0: invalid signature or bad data + * Args: ctx: pointer to a context object (cannot be NULL) + * session: active session for which the combined nonce has been computed + * (cannot be NULL) + * signer: data for the signer who produced this signature (cannot be NULL) + * In: partial_sig: signature to verify (cannot be NULL) + * pubkey: public key of the signer who produced the signature (cannot be NULL) + */ + //if (!secp256k1_musig_partial_sig_verify(ctx, &musig_session[i], &signer_data[i][j], &partial_sig[j], &pubkeys[j])) { + return 0; + /** Combines partial signatures + * + * Returns: 1: all partial signatures have values in range. Does NOT mean the + * resulting signature verifies. + * 0: some partial signature had s/r out of range + * Args: ctx: pointer to a context object (cannot be NULL) + * session: initialized session for which the combined nonce has been + * computed (cannot be NULL) + * Out: sig: complete signature (cannot be NULL) + * In: partial_sigs: array of partial signatures to combine (cannot be NULL) + * n_sigs: number of signatures in the partial_sigs array + */ + // after all partials: return secp256k1_musig_partial_sig_combine(ctx, &musig_session[0], sig, partial_sig, N_SIGNERS return(result); } UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); result.push_back(Pair("result","success")); + /** Verify a Schnorr signature. + * + * Returns: 1: correct signature + * 0: incorrect or unparseable signature + * Args: ctx: a secp256k1 context object, initialized for verification. + * In: sig: the signature being verified (cannot be NULL) + * msg32: the 32-byte message hash being verified (cannot be NULL) + * pubkey: pointer to a public key to verify with (cannot be NULL) + */ + // if (!secp256k1_schnorrsig_verify(ctx, &sig, msg, &combined_pk)) { return(result); } From a709fe0fef57f03a74e6506b56ff450f31c6f5db Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 06:44:01 -1100 Subject: [PATCH 2534/3904] Remove exe permission on source files --- src/cc/dapps/cJSON.c | 0 src/cc/musig.cpp | 0 src/komodo_cJSON.c | 0 src/komodo_cJSON.h | 0 src/komodo_jumblr.h | 0 src/uthash.h | 0 src/utlist.h | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/cc/dapps/cJSON.c mode change 100755 => 100644 src/cc/musig.cpp mode change 100755 => 100644 src/komodo_cJSON.c mode change 100755 => 100644 src/komodo_cJSON.h mode change 100755 => 100644 src/komodo_jumblr.h mode change 100755 => 100644 src/uthash.h mode change 100755 => 100644 src/utlist.h diff --git a/src/cc/dapps/cJSON.c b/src/cc/dapps/cJSON.c old mode 100755 new mode 100644 diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp old mode 100755 new mode 100644 diff --git a/src/komodo_cJSON.c b/src/komodo_cJSON.c old mode 100755 new mode 100644 diff --git a/src/komodo_cJSON.h b/src/komodo_cJSON.h old mode 100755 new mode 100644 diff --git a/src/komodo_jumblr.h b/src/komodo_jumblr.h old mode 100755 new mode 100644 diff --git a/src/uthash.h b/src/uthash.h old mode 100755 new mode 100644 diff --git a/src/utlist.h b/src/utlist.h old mode 100755 new mode 100644 From 7cef15077601820d30f2b14788daa3f1aad75b9d Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 18:48:22 +0100 Subject: [PATCH 2535/3904] add win deps --- src/cc/rogue/Makefile_win | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile_win b/src/cc/rogue/Makefile_win index dbc900e48..96b6e61be 100644 --- a/src/cc/rogue/Makefile_win +++ b/src/cc/rogue/Makefile_win @@ -26,7 +26,7 @@ O=o CC = x86_64-w64-mingw32-gcc #CFLAGS=-O2 -CFLAGS= -g -O2 -I./ncurses/include +CFLAGS= -g -O2 -I./ncurses/include --I../../../depends/x86_64-w64-mingw32/include #LIBS=-lcurses LIBS = -L./ncurses/lib -lncursesw From 118461e55427865e34bdbb8a873b489ca9809aab Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 18:51:12 +0100 Subject: [PATCH 2536/3904] fix typo --- src/cc/makerogue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index ff175c586..c67892b90 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -5,7 +5,7 @@ if [ "$HOST" = "x86_64-w64-mingw32" ]; then echo building rogue.exe... mkdir ncurses && cd ncurses wget https://invisible-island.net/datafiles/release/mingw32.zip - unzip mingw32.zip && delete mingw32.zip + unzip mingw32.zip && rm mingw32.zip cd .. if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL From bf44755dadc8ba400c86018d3aed161b778cb8cf Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 18:56:25 +0100 Subject: [PATCH 2537/3904] pwd --- src/cc/makerogue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index c67892b90..9135753c1 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -6,7 +6,6 @@ if [ "$HOST" = "x86_64-w64-mingw32" ]; then mkdir ncurses && cd ncurses wget https://invisible-island.net/datafiles/release/mingw32.zip unzip mingw32.zip && rm mingw32.zip - cd .. if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL cd .. From 8998c66874885248c2ac53aa044fdee3c413bcfb Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 18:58:09 +0100 Subject: [PATCH 2538/3904] revert --- src/cc/makerogue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/makerogue b/src/cc/makerogue index 9135753c1..c67892b90 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -6,6 +6,7 @@ if [ "$HOST" = "x86_64-w64-mingw32" ]; then mkdir ncurses && cd ncurses wget https://invisible-island.net/datafiles/release/mingw32.zip unzip mingw32.zip && rm mingw32.zip + cd .. if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL cd .. From 55b7035f9b0736f06607768e13e2cd5b94a8da06 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 19:04:45 +0100 Subject: [PATCH 2539/3904] add include --- src/cc/rogue/Makefile_win | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile_win b/src/cc/rogue/Makefile_win index 96b6e61be..17941732c 100644 --- a/src/cc/rogue/Makefile_win +++ b/src/cc/rogue/Makefile_win @@ -26,7 +26,7 @@ O=o CC = x86_64-w64-mingw32-gcc #CFLAGS=-O2 -CFLAGS= -g -O2 -I./ncurses/include --I../../../depends/x86_64-w64-mingw32/include +CFLAGS= -g -O2 -I./ncurses/include -I../../../depends/x86_64-w64-mingw32/include #LIBS=-lcurses LIBS = -L./ncurses/lib -lncursesw From 762e3582d1d1109e97c3cb81ac8fb9501236033e Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 19:09:07 +0100 Subject: [PATCH 2540/3904] pwd --- src/cc/makerogue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index c67892b90..9135753c1 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -6,7 +6,6 @@ if [ "$HOST" = "x86_64-w64-mingw32" ]; then mkdir ncurses && cd ncurses wget https://invisible-island.net/datafiles/release/mingw32.zip unzip mingw32.zip && rm mingw32.zip - cd .. if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL cd .. From b635717ec1219c8d3542962cfc01dc43432815b1 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 19:40:52 +0100 Subject: [PATCH 2541/3904] add ncursesw --- src/cc/rogue/Makefile_win | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile_win b/src/cc/rogue/Makefile_win index 17941732c..9c440349e 100644 --- a/src/cc/rogue/Makefile_win +++ b/src/cc/rogue/Makefile_win @@ -26,7 +26,7 @@ O=o CC = x86_64-w64-mingw32-gcc #CFLAGS=-O2 -CFLAGS= -g -O2 -I./ncurses/include -I../../../depends/x86_64-w64-mingw32/include +CFLAGS= -g -O2 -I./ncurses/include -I./ncurses/include/ncursesw -I../../../depends/x86_64-w64-mingw32/include #LIBS=-lcurses LIBS = -L./ncurses/lib -lncursesw From 47b99da2a3d4a7dfa6bd9ccce67446a6183dcabb Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 20:41:57 +0100 Subject: [PATCH 2542/3904] add debug --- src/cc/makerogue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/makerogue b/src/cc/makerogue index 9135753c1..b690e60e7 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -4,8 +4,11 @@ cd rogue; if [ "$HOST" = "x86_64-w64-mingw32" ]; then echo building rogue.exe... mkdir ncurses && cd ncurses + echo $PWD wget https://invisible-island.net/datafiles/release/mingw32.zip unzip mingw32.zip && rm mingw32.zip + echo lib archive cleaned + echo $PWD if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL cd .. From fddc7d4369b242cb3b481f0a09d6247513a7913a Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 21:28:57 +0100 Subject: [PATCH 2543/3904] change dir --- src/cc/makerogue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/makerogue b/src/cc/makerogue index b690e60e7..063de081e 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -8,6 +8,7 @@ if [ "$HOST" = "x86_64-w64-mingw32" ]; then wget https://invisible-island.net/datafiles/release/mingw32.zip unzip mingw32.zip && rm mingw32.zip echo lib archive cleaned + cd .. echo $PWD if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL From adb32b5a5138baa53adb30e7d324cb3d28405fdd Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 22:36:25 +0100 Subject: [PATCH 2544/3904] add WIN ifdef --- src/cc/rogue/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index ca05226d3..bcd35da73 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -41,7 +41,11 @@ typedef union _bits256 bits256; double OS_milliseconds() { struct timeval tv; double millis; + #ifdef __MINGW32__ + mingw_gettimeofday(&tv,NULL); + #else gettimeofday(&tv,NULL); + #endif millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.); //printf("tv_sec.%ld usec.%d %f\n",tv.tv_sec,tv.tv_usec,millis); return(millis); From 064179cf1894a31b018cf1461074e6895e3b0677 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 21 Feb 2019 23:09:25 +0100 Subject: [PATCH 2545/3904] config WIN --- src/cc/makerogue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/makerogue b/src/cc/makerogue index 063de081e..51caef6e2 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -3,6 +3,7 @@ cd rogue; if [ "$HOST" = "x86_64-w64-mingw32" ]; then echo building rogue.exe... + ./configure --host=x86_64-w64-mingw32 mkdir ncurses && cd ncurses echo $PWD wget https://invisible-island.net/datafiles/release/mingw32.zip From 6ca1613add51ece97efb7c9bb33ab878bd76cc2a Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 22 Feb 2019 00:31:49 +0100 Subject: [PATCH 2546/3904] add ifdef WIN mdport --- src/cc/rogue/mdport.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 988e1c7b7..fd53be72c 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -705,7 +705,9 @@ md_erasechar() #elif defined(VERASE) return(_tty.c_cc[VERASE]); /* process erase character */ #else + #ifndef __MINGW32__ return(_tty.sg_erase); /* process erase character */ + #endif #endif } @@ -717,7 +719,9 @@ md_killchar() #elif defined(VKILL) return(_tty.c_cc[VKILL]); #else + #ifndef __MINGW32__ return(_tty.sg_kill); + #endif #endif } From ff9f59279bc6bf3a4e178b99eebda54050208014 Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 22 Feb 2019 01:21:04 +0100 Subject: [PATCH 2547/3904] cache deps --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3ace05cb9..a9fb7a01b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,9 +32,9 @@ build:ubuntu: variables: DOCKER_DRIVER: overlay2 cache: - key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" + key: ${CI_COMMIT_REF_SLUG} paths: - - depends/built + - depends/ script: - zcutil/build.sh -j$(nproc) - mkdir ${PACKAGE_DIR_LINUX} From c7b070e91ca79f220e25cfae3d65e057fae519b4 Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 22 Feb 2019 01:48:44 +0100 Subject: [PATCH 2548/3904] add curl --- src/cc/rogue/Makefile_win | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/Makefile_win b/src/cc/rogue/Makefile_win index 9c440349e..6e558960c 100644 --- a/src/cc/rogue/Makefile_win +++ b/src/cc/rogue/Makefile_win @@ -29,7 +29,7 @@ CC = x86_64-w64-mingw32-gcc CFLAGS= -g -O2 -I./ncurses/include -I./ncurses/include/ncursesw -I../../../depends/x86_64-w64-mingw32/include #LIBS=-lcurses -LIBS = -L./ncurses/lib -lncursesw +LIBS = -L./ncurses/lib -lncursesw -lcurl #RM=rm -f RM = rm -f From ba34a8050009e4d1bef4df01b9ec685d7db5cca1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 19:58:07 -1100 Subject: [PATCH 2549/3904] +print --- src/cc/faucet.cpp | 2 +- src/cc/musig.cpp | 297 +++++++++++++++++++++++++++++++--------------- 2 files changed, 204 insertions(+), 95 deletions(-) diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index b44337461..3f1ac4982 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -124,9 +124,9 @@ bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //int height = it->first.blockHeight; if ( CCduration(numblocks,it->first.txhash) > 0 && numblocks > 3 ) { - //fprintf(stderr,"would return error %s numblocks.%d ago\n",uint256_str(str,it->first.txhash),numblocks); return eval->Invalid("faucet is only for brand new addresses"); } + fprintf(stderr,"txid %s numblocks.%d ago\n",uint256_str(str,it->first.txhash),numblocks); } retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index ec7f5e788..263ed2fff 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -88,6 +88,54 @@ extern "C" int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 +struct musig_info +{ + secp256k1_musig_session musig_session; + secp256k1_pubkey combined_pk; + uint8_t *nonce_commitments; // 32*N_SIGNERS + secp256k1_musig_session_signer_data *signer_data; //[N_SIGNERS]; + secp256k1_pubkey *nonce; //[N_SIGNERS]; + secp256k1_musig_partial_signature *partial_sig; //[N_SIGNERS]; + int32_t myind,num; + uint8_t msg[32],pkhash[32],combpk[33]; +} *MUSIG; + +struct musig_info *musig_infocreate(int32_t myind,int32_t num) +{ + struct musig_info *mp = (struct musig_info *)calloc(1,sizeof(*mp)); + mp->myind = myind, mp->num = num; + mp->nonce_commitments = (uint8_t *)calloc(num,32); + mp->signer_data = (uint8_t *)calloc(num,sizeof(*np->signer_data)); + mp->nonce = (uint8_t *)calloc(num,sizeof(*np->nonce)); + mp->partial_sig = (uint8_t *)calloc(num,sizeof(*np->partial_sig)); + return(mp); +} + +void musig_infofree(struct musig_info *mp) +{ + if ( mp->partial_sig != 0 ) + { + random_buf(mp->partial_sig,num*sizeof(*np->partial_sig)) + free(mp->partial_sig); + } + if ( mp->nonce != 0 ) + { + random_buf(mp->nonce,num*sizeof(*np->nonce)) + free(mp->nonce); + } + if ( mp->signer_data != 0 ) + { + random_buf(mp->signer_data,num*sizeof(*np->signer_data)) + free(mp->signer_data); + } + if ( mp->nonce_commitments != 0 ) + { + random_buf(mp->nonce_commitments,num*32) + free(mp->nonce_commitments); + } + free(mp); +} + CScript musig_sendopret(uint8_t funcid,CPubKey pk) { CScript opret; uint8_t evalcode = EVAL_MUSIG; @@ -215,111 +263,158 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - result.push_back(Pair("result","success")); - /** Initializes a signing session for a signer - * - * Returns: 1: session is successfully initialized - * 0: session could not be initialized: secret key or secret nonce overflow - * Args: ctx: pointer to a context object, initialized for signing (cannot - * be NULL) - * Out: session: the session structure to initialize (cannot be NULL) - * signers: an array of signers' data to be initialized. Array length must - * equal to `n_signers` (cannot be NULL) - * nonce_commitment32: filled with a 32-byte commitment to the generated nonce - * (cannot be NULL) - * In: session_id32: a *unique* 32-byte ID to assign to this session (cannot be - * NULL). If a non-unique session_id32 was given then a partial - * signature will LEAK THE SECRET KEY. - * msg32: the 32-byte message to be signed. Shouldn't be NULL unless you - * require sharing public nonces before the message is known - * because it reduces nonce misuse resistance. If NULL, must be - * set with `musig_session_set_msg` before signing and verifying. - * combined_pk: the combined public key of all signers (cannot be NULL) - * pk_hash32: the 32-byte hash of the signers' individual keys (cannot be - * NULL) - * n_signers: length of signers array. Number of signers participating in - * the MuSig. Must be greater than 0 and at most 2^32 - 1. - * my_index: index of this signer in the signers array - * seckey: the signer's 32-byte secret key (cannot be NULL) - */ - //if (!secp256k1_musig_session_initialize(ctx, &musig_session[i], signer_data[i], nonce_commitment[i], session_id32, msg32, &combined_pk, pk_hash, N_SIGNERS, i, seckeys[i])) - //return 0; - // randombytes_buf(buf, num); - - //nonce_commitment_ptr[i] = &nonce_commitment[i][0]; - return(result); + static secp256k1_context *ctx; + UniValue result(UniValue::VOBJ); int32_t i,n,myind,num; char *pkstr,*pkhashstr,*msgstr; uint8_t session[32],msg[32],pkhash[32],privkey[32],pub33[33]; CPubKey pk; char str[67]; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 5 ) + { + // set the 5 args: myind, num, pub33, pkhash32, msg32 + if ( MUSIG != 0 ) + musig_infofree(MUSIG), MUSIG = 0; + MUSIG = musig_infocreate(myind,num); + pk = buf2pk(pub33); + if ( secp256k1_ec_pubkey_parse(ctx,&MUSIG->combined_pk,pk.begin(),33) > 0 ) + { + memcpy(MUSIG->pkhash,pkhash,sizeof(pkhash)); + memcpy(MUSIG->msg,msg,sizeof(msg)); + random_buf(session,32); + Myprivkey(privkey); + /** Initializes a signing session for a signer + * + * Returns: 1: session is successfully initialized + * 0: session could not be initialized: secret key or secret nonce overflow + * Args: ctx: pointer to a context object, initialized for signing (cannot + * be NULL) + * Out: session: the session structure to initialize (cannot be NULL) + * signers: an array of signers' data to be initialized. Array length must + * equal to `n_signers` (cannot be NULL) + * nonce_commitment32: filled with a 32-byte commitment to the generated nonce + * (cannot be NULL) + * In: session_id32: a *unique* 32-byte ID to assign to this session (cannot be + * NULL). If a non-unique session_id32 was given then a partial + * signature will LEAK THE SECRET KEY. + * msg32: the 32-byte message to be signed. Shouldn't be NULL unless you + * require sharing public nonces before the message is known + * because it reduces nonce misuse resistance. If NULL, must be + * set with `musig_session_set_msg` before signing and verifying. + * combined_pk: the combined public key of all signers (cannot be NULL) + * pk_hash32: the 32-byte hash of the signers' individual keys (cannot be + * NULL) + * n_signers: length of signers array. Number of signers participating in + * the MuSig. Must be greater than 0 and at most 2^32 - 1. + * my_index: index of this signer in the signers array + * seckey: the signer's 32-byte secret key (cannot be NULL) + */ + if ( secp256k1_musig_session_initialize(ctx,&MUSIG->musig_session,MUSIG->signer_data, &MUSIG->nonce_commitment[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) + { + result.push_back(Pair("myind",(int64_t)myind)); + result.push_back(Pair("numsigners",(int64_t)num)); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitment[MUSIG->myind*32 + i]); + str[64] = 0; + result.push_back(Pair("commitment",str)); + result.push_back(Pair("result","success")); + return(result) + } else return(cclib_error(result,"couldnt initialize session")); + } else return(cclib_error(result,"couldnt parse combined pubkey")); + } else return(cclib_error(result,"wrong number of params, need 5: myindex, numsigners, combined_pk, pkhash, msg32")); } UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - result.push_back(Pair("result","success")); - /** Gets the signer's public nonce given a list of all signers' data with commitments - * - * Returns: 1: public nonce is written in nonce - * 0: signer data is missing commitments or session isn't initialized - * for signing - * Args: ctx: pointer to a context object (cannot be NULL) - * session: the signing session to get the nonce from (cannot be NULL) - * signers: an array of signers' data initialized with - * `musig_session_initialize`. Array length must equal to - * `n_commitments` (cannot be NULL) - * Out: nonce: the nonce (cannot be NULL) - * In: commitments: array of 32-byte nonce commitments (cannot be NULL) - * n_commitments: the length of commitments and signers array. Must be the total - * number of signers participating in the MuSig. - */ - // Set nonce commitments in the signer data and get the own public nonce - //if (!secp256k1_musig_session_get_public_nonce(ctx, &musig_session[i], signer_data[i], &nonce[i], nonce_commitment_ptr, N_SIGNERS)) - // return 0; - - return(result); + static secp256k1_context *ctx; + UniValue result(UniValue::VOBJ); int32_t n; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + { + // pkhash, ind, commitment + // if all commitments, emit nonce, else just update MUSIG-> + + /** Gets the signer's public nonce given a list of all signers' data with commitments + * + * Returns: 1: public nonce is written in nonce + * 0: signer data is missing commitments or session isn't initialized + * for signing + * Args: ctx: pointer to a context object (cannot be NULL) + * session: the signing session to get the nonce from (cannot be NULL) + * signers: an array of signers' data initialized with + * `musig_session_initialize`. Array length must equal to + * `n_commitments` (cannot be NULL) + * Out: nonce: the nonce (cannot be NULL) + * In: commitments: array of 32-byte nonce commitments (cannot be NULL) + * n_commitments: the length of commitments and signers array. Must be the total + * number of signers participating in the MuSig. + */ + // Set nonce commitments in the signer data and get the own public nonce + //if (secp256k1_musig_session_get_public_nonce(ctx, &musig_session[i], signer_data[i], &nonce[i], nonce_commitment_ptr, N_SIGNERS) > 0 ) + { + // publish nonce + result.push_back(Pair("result","success")); + } + // return 0; + } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, commitment")); } UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - result.push_back(Pair("result","success")); - /** Checks a signer's public nonce against a commitment to said nonce, and update - * data structure if they match - * - * Returns: 1: commitment was valid, data structure updated - * 0: commitment was invalid, nothing happened - * Args: ctx: pointer to a context object (cannot be NULL) - * signer: pointer to the signer data to update (cannot be NULL). Must have - * been used with `musig_session_get_public_nonce` or initialized - * with `musig_session_initialize_verifier`. - * In: nonce: signer's alleged public nonce (cannot be NULL) - */ - //if (!secp256k1_musig_set_nonce(ctx, &signer_data[i][j], &nonce[j])) { - - - /** Updates a session with the combined public nonce of all signers. The combined - * public nonce is the sum of every signer's public nonce. - * - * Returns: 1: nonces are successfully combined - * 0: a signer's nonce is missing - * Args: ctx: pointer to a context object (cannot be NULL) - * session: session to update with the combined public nonce (cannot be - * NULL) - * signers: an array of signers' data, which must have had public nonces - * set with `musig_set_nonce`. Array length must equal to `n_signers` - * (cannot be NULL) - * n_signers: the length of the signers array. Must be the total number of - * signers participating in the MuSig. - * Out: nonce_is_negated: a pointer to an integer that indicates if the combined - * public nonce had to be negated. - * adaptor: point to add to the combined public nonce. If NULL, nothing is - * added to the combined nonce. - */ - // after all nonces: if (!secp256k1_musig_session_combine_nonces(ctx, &musig_session[i], signer_data[i], N_SIGNERS, NULL, NULL)) { + static secp256k1_context *ctx; + UniValue result(UniValue::VOBJ); int32_t n; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + // pkhash, ind, nonce + // if all nonces, combine nonce, else just update MUSIG-> + result.push_back(Pair("result","success")); + /** Checks a signer's public nonce against a commitment to said nonce, and update + * data structure if they match + * + * Returns: 1: commitment was valid, data structure updated + * 0: commitment was invalid, nothing happened + * Args: ctx: pointer to a context object (cannot be NULL) + * signer: pointer to the signer data to update (cannot be NULL). Must have + * been used with `musig_session_get_public_nonce` or initialized + * with `musig_session_initialize_verifier`. + * In: nonce: signer's alleged public nonce (cannot be NULL) + */ + //if (!secp256k1_musig_set_nonce(ctx, &signer_data[i][j], &nonce[j])) { + + + /** Updates a session with the combined public nonce of all signers. The combined + * public nonce is the sum of every signer's public nonce. + * + * Returns: 1: nonces are successfully combined + * 0: a signer's nonce is missing + * Args: ctx: pointer to a context object (cannot be NULL) + * session: session to update with the combined public nonce (cannot be + * NULL) + * signers: an array of signers' data, which must have had public nonces + * set with `musig_set_nonce`. Array length must equal to `n_signers` + * (cannot be NULL) + * n_signers: the length of the signers array. Must be the total number of + * signers participating in the MuSig. + * Out: nonce_is_negated: a pointer to an integer that indicates if the combined + * public nonce had to be negated. + * adaptor: point to add to the combined public nonce. If NULL, nothing is + * added to the combined nonce. + */ + // after all nonces: if (!secp256k1_musig_session_combine_nonces(ctx, &musig_session[i], signer_data[i], N_SIGNERS, NULL, NULL)) { return(result); + } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, nonce")); } UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); + static secp256k1_context *ctx; + UniValue result(UniValue::VOBJ); int32_t n; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + // similar to commit/nonce + } result.push_back(Pair("result","success")); /** Produces a partial signature * @@ -349,7 +444,14 @@ UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *para UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); + static secp256k1_context *ctx; + UniValue result(UniValue::VOBJ); int32_t n; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + // finally! + } result.push_back(Pair("result","success")); /** Checks that an individual partial signature verifies * @@ -387,7 +489,14 @@ UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); + static secp256k1_context *ctx; + UniValue result(UniValue::VOBJ); int32_t n; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + // can code this out of order + } result.push_back(Pair("result","success")); /** Verify a Schnorr signature. * From cb1a6291c6e45addf50146971703be58badeff52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 19:59:46 -1100 Subject: [PATCH 2550/3904] Mp --- src/cc/musig.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 263ed2fff..b54bf26d1 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -105,9 +105,9 @@ struct musig_info *musig_infocreate(int32_t myind,int32_t num) struct musig_info *mp = (struct musig_info *)calloc(1,sizeof(*mp)); mp->myind = myind, mp->num = num; mp->nonce_commitments = (uint8_t *)calloc(num,32); - mp->signer_data = (uint8_t *)calloc(num,sizeof(*np->signer_data)); - mp->nonce = (uint8_t *)calloc(num,sizeof(*np->nonce)); - mp->partial_sig = (uint8_t *)calloc(num,sizeof(*np->partial_sig)); + mp->signer_data = (uint8_t *)calloc(num,sizeof(*mp->signer_data)); + mp->nonce = (uint8_t *)calloc(num,sizeof(*mp->nonce)); + mp->partial_sig = (uint8_t *)calloc(num,sizeof(*mp->partial_sig)); return(mp); } @@ -115,22 +115,22 @@ void musig_infofree(struct musig_info *mp) { if ( mp->partial_sig != 0 ) { - random_buf(mp->partial_sig,num*sizeof(*np->partial_sig)) + random_buf(mp->partial_sig,mp->num*sizeof(*np->partial_sig)) free(mp->partial_sig); } if ( mp->nonce != 0 ) { - random_buf(mp->nonce,num*sizeof(*np->nonce)) + random_buf(mp->nonce,mp->num*sizeof(*mp->nonce)) free(mp->nonce); } if ( mp->signer_data != 0 ) { - random_buf(mp->signer_data,num*sizeof(*np->signer_data)) + random_buf(mp->signer_data,mp->num*sizeof(*mp->signer_data)) free(mp->signer_data); } if ( mp->nonce_commitments != 0 ) { - random_buf(mp->nonce_commitments,num*32) + random_buf(mp->nonce_commitments,mp->num*32) free(mp->nonce_commitments); } free(mp); From da11af7c0ff54a3071e0e3f50723d2d6610e4364 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:01:06 -1100 Subject: [PATCH 2551/3904] Test --- src/cc/musig.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index b54bf26d1..44ddf6ef3 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -87,6 +87,7 @@ extern "C" int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 +#define random_buf(a,b) struct musig_info { @@ -105,9 +106,9 @@ struct musig_info *musig_infocreate(int32_t myind,int32_t num) struct musig_info *mp = (struct musig_info *)calloc(1,sizeof(*mp)); mp->myind = myind, mp->num = num; mp->nonce_commitments = (uint8_t *)calloc(num,32); - mp->signer_data = (uint8_t *)calloc(num,sizeof(*mp->signer_data)); - mp->nonce = (uint8_t *)calloc(num,sizeof(*mp->nonce)); - mp->partial_sig = (uint8_t *)calloc(num,sizeof(*mp->partial_sig)); + mp->signer_data = (secp256k1_musig_session_signer_data *)calloc(num,sizeof(*mp->signer_data)); + mp->nonce = (secp256k1_pubkey *)calloc(num,sizeof(*mp->nonce)); + mp->partial_sig = (secp256k1_musig_partial_signature *)calloc(num,sizeof(*mp->partial_sig)); return(mp); } @@ -115,7 +116,7 @@ void musig_infofree(struct musig_info *mp) { if ( mp->partial_sig != 0 ) { - random_buf(mp->partial_sig,mp->num*sizeof(*np->partial_sig)) + random_buf(mp->partial_sig,mp->num*sizeof(*mp->partial_sig)) free(mp->partial_sig); } if ( mp->nonce != 0 ) From e1c434466734a26921d98c6e0db1cb12df3a2f08 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:02:05 -1100 Subject: [PATCH 2552/3904] syntax --- src/cc/musig.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 44ddf6ef3..aa821f644 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -307,16 +307,16 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * my_index: index of this signer in the signers array * seckey: the signer's 32-byte secret key (cannot be NULL) */ - if ( secp256k1_musig_session_initialize(ctx,&MUSIG->musig_session,MUSIG->signer_data, &MUSIG->nonce_commitment[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) + if ( secp256k1_musig_session_initialize(ctx,&MUSIG->musig_session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) { result.push_back(Pair("myind",(int64_t)myind)); result.push_back(Pair("numsigners",(int64_t)num)); for (i=0; i<32; i++) - sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitment[MUSIG->myind*32 + i]); + sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitments[MUSIG->myind*32 + i]); str[64] = 0; result.push_back(Pair("commitment",str)); result.push_back(Pair("result","success")); - return(result) + return(result); } else return(cclib_error(result,"couldnt initialize session")); } else return(cclib_error(result,"couldnt parse combined pubkey")); } else return(cclib_error(result,"wrong number of params, need 5: myindex, numsigners, combined_pk, pkhash, msg32")); From 40c26873ba97286ed860c8e4c742b68cc28f237c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:03:14 -1100 Subject: [PATCH 2553/3904] extern "C" --- src/cc/musig.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index aa821f644..68787e67b 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -78,6 +78,7 @@ extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, s extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); extern "C" int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp256k1_scratch_space *scratch, secp256k1_pubkey *combined_pk, unsigned char *pk_hash32, const secp256k1_pubkey *pubkeys, size_t n_pubkeys); +extern "C" int secp256k1_musig_session_initialize(const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, unsigned char *nonce_commitment32, const unsigned char *session_id32, const unsigned char *msg32, const secp256k1_pubkey *combined_pk, const unsigned char *pk_hash32, size_t n_signers, size_t my_index, const unsigned char *seckey); //#include "../secp256k1/include/secp256k1.h" From 146d452410880c1657f479c22f33d51402b667aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:03:56 -1100 Subject: [PATCH 2554/3904] Reorder --- src/cc/musig.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 68787e67b..8fdba80a2 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -74,18 +74,18 @@ struct secp256k1_context_struct { secp256k1_callback error_callback; }; -extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); -extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); -extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); -extern "C" int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp256k1_scratch_space *scratch, secp256k1_pubkey *combined_pk, unsigned char *pk_hash32, const secp256k1_pubkey *pubkeys, size_t n_pubkeys); -extern "C" int secp256k1_musig_session_initialize(const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, unsigned char *nonce_commitment32, const unsigned char *session_id32, const unsigned char *msg32, const secp256k1_pubkey *combined_pk, const unsigned char *pk_hash32, size_t n_signers, size_t my_index, const unsigned char *seckey); - //#include "../secp256k1/include/secp256k1.h" //#include "../secp256k1/include/secp256k1_schnorrsig.h" #include "../secp256k1/include/secp256k1_musig.h" +extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); +extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); +extern "C" int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp256k1_scratch_space *scratch, secp256k1_pubkey *combined_pk, unsigned char *pk_hash32, const secp256k1_pubkey *pubkeys, size_t n_pubkeys); +extern "C" int secp256k1_musig_session_initialize(const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, unsigned char *nonce_commitment32, const unsigned char *session_id32, const unsigned char *msg32, const secp256k1_pubkey *combined_pk, const unsigned char *pk_hash32, size_t n_signers, size_t my_index, const unsigned char *seckey); + #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 #define random_buf(a,b) From c76bd865230436337d54231fcaa6ca86957cb0b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:06:25 -1100 Subject: [PATCH 2555/3904] #ifdef __cplusplus --- src/secp256k1/include/secp256k1_musig.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/include/secp256k1_musig.h b/src/secp256k1/include/secp256k1_musig.h index 7e974e36d..d58550cf8 100644 --- a/src/secp256k1/include/secp256k1_musig.h +++ b/src/secp256k1/include/secp256k1_musig.h @@ -167,7 +167,12 @@ SECP256K1_API int secp256k1_musig_pubkey_combine( * my_index: index of this signer in the signers array * seckey: the signer's 32-byte secret key (cannot be NULL) */ -SECP256K1_API int secp256k1_musig_session_initialize( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_session_initialize( const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, From db9149577974a6cda3a60ae4196c9b2d7a3eeec5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:07:50 -1100 Subject: [PATCH 2556/3904] Again --- src/secp256k1/include/secp256k1_musig.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/include/secp256k1_musig.h b/src/secp256k1/include/secp256k1_musig.h index d58550cf8..a0106e691 100644 --- a/src/secp256k1/include/secp256k1_musig.h +++ b/src/secp256k1/include/secp256k1_musig.h @@ -132,7 +132,12 @@ typedef struct { * key (cannot be NULL) * n_pubkeys: length of pubkeys array */ -SECP256K1_API int secp256k1_musig_pubkey_combine( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_pubkey_combine( const secp256k1_context* ctx, secp256k1_scratch_space *scratch, secp256k1_pubkey *combined_pk, From f20d2860dec77fcdca16d874787a037058855cf5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:11:38 -1100 Subject: [PATCH 2557/3904] -print --- src/cc/faucet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index 3f1ac4982..b794d9b1c 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -126,7 +126,7 @@ bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx { return eval->Invalid("faucet is only for brand new addresses"); } - fprintf(stderr,"txid %s numblocks.%d ago\n",uint256_str(str,it->first.txhash),numblocks); + //fprintf(stderr,"txid %s numblocks.%d ago\n",uint256_str(str,it->first.txhash),numblocks); } retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) From f448c53ac872751e8a2f3d5bd6ed562b61e28443 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:13:18 -1100 Subject: [PATCH 2558/3904] (uint8_t *) --- src/cc/musig.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 8fdba80a2..80da59927 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -88,7 +88,6 @@ extern "C" int secp256k1_musig_session_initialize(const secp256k1_context* ctx, #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 -#define random_buf(a,b) struct musig_info { @@ -117,22 +116,22 @@ void musig_infofree(struct musig_info *mp) { if ( mp->partial_sig != 0 ) { - random_buf(mp->partial_sig,mp->num*sizeof(*mp->partial_sig)) + GetRandBytes((uint8_t *)mp->partial_sig,mp->num*sizeof(*mp->partial_sig)) free(mp->partial_sig); } if ( mp->nonce != 0 ) { - random_buf(mp->nonce,mp->num*sizeof(*mp->nonce)) + GetRandBytes((uint8_t *)mp->nonce,mp->num*sizeof(*mp->nonce)) free(mp->nonce); } if ( mp->signer_data != 0 ) { - random_buf(mp->signer_data,mp->num*sizeof(*mp->signer_data)) + GetRandBytes((uint8_t *)mp->signer_data,mp->num*sizeof(*mp->signer_data)) free(mp->signer_data); } if ( mp->nonce_commitments != 0 ) { - random_buf(mp->nonce_commitments,mp->num*32) + GetRandBytes((uint8_t *)mp->nonce_commitments,mp->num*32) free(mp->nonce_commitments); } free(mp); @@ -280,7 +279,7 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { memcpy(MUSIG->pkhash,pkhash,sizeof(pkhash)); memcpy(MUSIG->msg,msg,sizeof(msg)); - random_buf(session,32); + GetRandBytes(session,32); Myprivkey(privkey); /** Initializes a signing session for a signer * From 41d1eef0191a48413140f73c5d8abb30602cfceb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:14:14 -1100 Subject: [PATCH 2559/3904] ; --- src/cc/musig.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 80da59927..633c95feb 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -116,24 +116,25 @@ void musig_infofree(struct musig_info *mp) { if ( mp->partial_sig != 0 ) { - GetRandBytes((uint8_t *)mp->partial_sig,mp->num*sizeof(*mp->partial_sig)) + GetRandBytes((uint8_t *)mp->partial_sig,mp->num*sizeof(*mp->partial_sig)); free(mp->partial_sig); } if ( mp->nonce != 0 ) { - GetRandBytes((uint8_t *)mp->nonce,mp->num*sizeof(*mp->nonce)) + GetRandBytes((uint8_t *)mp->nonce,mp->num*sizeof(*mp->nonce)); free(mp->nonce); } if ( mp->signer_data != 0 ) { - GetRandBytes((uint8_t *)mp->signer_data,mp->num*sizeof(*mp->signer_data)) + GetRandBytes((uint8_t *)mp->signer_data,mp->num*sizeof(*mp->signer_data)); free(mp->signer_data); } if ( mp->nonce_commitments != 0 ) { - GetRandBytes((uint8_t *)mp->nonce_commitments,mp->num*32) + GetRandBytes((uint8_t *)mp->nonce_commitments,mp->num*32); free(mp->nonce_commitments); } + GetRandBytes((uint8_t *)mp,sizeof(*mp)); free(mp); } From dc3767b68f5369114164235da1297ebb07525356 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:15:40 -1100 Subject: [PATCH 2560/3904] Session --- src/cc/musig.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 633c95feb..9f529a341 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -281,6 +281,10 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) memcpy(MUSIG->pkhash,pkhash,sizeof(pkhash)); memcpy(MUSIG->msg,msg,sizeof(msg)); GetRandBytes(session,32); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",session[i]); + str[64] = 0; + fprintf(stderr,"session %s\n",str); Myprivkey(privkey); /** Initializes a signing session for a signer * From 3bc10962e5af83cbca4eaf7f8edf5046ce21b5d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 20:17:28 -1100 Subject: [PATCH 2561/3904] Move --- src/cc/musig.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 9f529a341..fc83fe382 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -276,15 +276,15 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) musig_infofree(MUSIG), MUSIG = 0; MUSIG = musig_infocreate(myind,num); pk = buf2pk(pub33); + GetRandBytes(session,32); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",session[i]); + str[64] = 0; + fprintf(stderr,"session %s\n",str); if ( secp256k1_ec_pubkey_parse(ctx,&MUSIG->combined_pk,pk.begin(),33) > 0 ) { memcpy(MUSIG->pkhash,pkhash,sizeof(pkhash)); memcpy(MUSIG->msg,msg,sizeof(msg)); - GetRandBytes(session,32); - for (i=0; i<32; i++) - sprintf(&str[i<<1],"%02x",session[i]); - str[64] = 0; - fprintf(stderr,"session %s\n",str); Myprivkey(privkey); /** Initializes a signing session for a signer * From d84a9afe6f071c0801f1350c9acbf7a128f96c55 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 22:03:15 -1100 Subject: [PATCH 2562/3904] Add parsing for session --- src/cc/musig.cpp | 64 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index fc83fe382..ccb554e0f 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -223,6 +223,27 @@ UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } else return(cclib_error(result,"couldnt parse params")); } +int32_t musig_parsepubkey(secp256k1_context *ctx,secp256k1_pubkey &spk,cJSON *item) +{ + char *hexstr; + if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == 66 ) + { + CPubKey pk(ParseHex(hexstr)); + if ( secp256k1_ec_pubkey_parse(ctx,&spk,pk.begin(),33) > 0 ) + return(1); + } else return(-1); +} + +int32_t musig_parsehash32(uint8_t *hash32,cJSON *item) +{ + char *hexstr; + if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == 64 ) + { + decode_hex(hash32,32,hexstr); + return(0); + } else return(-1); +} + UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; @@ -235,13 +256,9 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //fprintf(stderr,"n.%d args.(%s)\n",n,jprint(params,0)); for (i=0; i 0 ) - pubkeys.push_back(spk); - else return(cclib_error(result,"error parsing pk")); - } else return(cclib_error(result,"all pubkeys must be 33 bytes hexdata")); + if ( musig_parsepubkey(ctx,spk,jitem(params,i)) < 0 ) + return(cclib_error(result,"error parsing pk")); + pubkeys.push_back(spk); } if ( secp256k1_musig_pubkey_combine(ctx,NULL,&combined_pk,pkhash,&pubkeys[0],n) > 0 ) { @@ -271,21 +288,26 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 5 ) { - // set the 5 args: myind, num, pub33, pkhash32, msg32 + myind = juint(jitem(params,0),0); + num = juint(jitem(params,1),0); + if ( myind < 0 || myind >= num || num <= 0 ) + return(cclib_error(result,"illegal myindex and numsigners")); if ( MUSIG != 0 ) musig_infofree(MUSIG), MUSIG = 0; MUSIG = musig_infocreate(myind,num); - pk = buf2pk(pub33); - GetRandBytes(session,32); - for (i=0; i<32; i++) - sprintf(&str[i<<1],"%02x",session[i]); - str[64] = 0; - fprintf(stderr,"session %s\n",str); - if ( secp256k1_ec_pubkey_parse(ctx,&MUSIG->combined_pk,pk.begin(),33) > 0 ) + if ( musig_parsepubkey(ctx,MUSIG->combined_pk,jitem(params,2)) < 0 ) + return(cclib_error(result,"error parsing combined_pubkey")); { - memcpy(MUSIG->pkhash,pkhash,sizeof(pkhash)); - memcpy(MUSIG->msg,msg,sizeof(msg)); + if ( musig_parsehash32(MUSIG->pkhash,jitem(params,3)) < 0 ) + return(cclib_error(result,"error parsing pkhash")); + if ( musig_parsehash32(MUSIG->msg,jitem(params,4)) < 0 ) + return(cclib_error(result,"error parsing msg")); Myprivkey(privkey); + GetRandBytes(session,32); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",session[i]); + str[64] = 0; + fprintf(stderr,"session %s\n",str); /** Initializes a signing session for a signer * * Returns: 1: session is successfully initialized @@ -314,6 +336,7 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) */ if ( secp256k1_musig_session_initialize(ctx,&MUSIG->musig_session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) { + memset(session,0,sizeof(session)); result.push_back(Pair("myind",(int64_t)myind)); result.push_back(Pair("numsigners",(int64_t)num)); for (i=0; i<32; i++) @@ -322,7 +345,12 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("commitment",str)); result.push_back(Pair("result","success")); return(result); - } else return(cclib_error(result,"couldnt initialize session")); + } + else + { + memset(session,0,sizeof(session)); + return(cclib_error(result,"couldnt initialize session")); + } } else return(cclib_error(result,"couldnt parse combined pubkey")); } else return(cclib_error(result,"wrong number of params, need 5: myindex, numsigners, combined_pk, pkhash, msg32")); } From 101a4153799c06ce3efc6705286c36184c3c383b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 22:05:27 -1100 Subject: [PATCH 2563/3904] Fix --- src/cc/musig.cpp | 52 +++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index ccb554e0f..7b9510b2a 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -297,17 +297,12 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) MUSIG = musig_infocreate(myind,num); if ( musig_parsepubkey(ctx,MUSIG->combined_pk,jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing combined_pubkey")); - { - if ( musig_parsehash32(MUSIG->pkhash,jitem(params,3)) < 0 ) - return(cclib_error(result,"error parsing pkhash")); - if ( musig_parsehash32(MUSIG->msg,jitem(params,4)) < 0 ) - return(cclib_error(result,"error parsing msg")); - Myprivkey(privkey); - GetRandBytes(session,32); - for (i=0; i<32; i++) - sprintf(&str[i<<1],"%02x",session[i]); - str[64] = 0; - fprintf(stderr,"session %s\n",str); + else if ( musig_parsehash32(MUSIG->pkhash,jitem(params,3)) < 0 ) + return(cclib_error(result,"error parsing pkhash")); + else if ( musig_parsehash32(MUSIG->msg,jitem(params,4)) < 0 ) + return(cclib_error(result,"error parsing msg")); + Myprivkey(privkey); + GetRandBytes(session,32); /** Initializes a signing session for a signer * * Returns: 1: session is successfully initialized @@ -334,24 +329,23 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * my_index: index of this signer in the signers array * seckey: the signer's 32-byte secret key (cannot be NULL) */ - if ( secp256k1_musig_session_initialize(ctx,&MUSIG->musig_session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) - { - memset(session,0,sizeof(session)); - result.push_back(Pair("myind",(int64_t)myind)); - result.push_back(Pair("numsigners",(int64_t)num)); - for (i=0; i<32; i++) - sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitments[MUSIG->myind*32 + i]); - str[64] = 0; - result.push_back(Pair("commitment",str)); - result.push_back(Pair("result","success")); - return(result); - } - else - { - memset(session,0,sizeof(session)); - return(cclib_error(result,"couldnt initialize session")); - } - } else return(cclib_error(result,"couldnt parse combined pubkey")); + if ( secp256k1_musig_session_initialize(ctx,&MUSIG->musig_session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) + { + memset(session,0,sizeof(session)); + result.push_back(Pair("myind",(int64_t)myind)); + result.push_back(Pair("numsigners",(int64_t)num)); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitments[MUSIG->myind*32 + i]); + str[64] = 0; + result.push_back(Pair("commitment",str)); + result.push_back(Pair("result","success")); + return(result); + } + else + { + memset(session,0,sizeof(session)); + return(cclib_error(result,"couldnt initialize session")); + } } else return(cclib_error(result,"wrong number of params, need 5: myindex, numsigners, combined_pk, pkhash, msg32")); } From eb09e81eaedefc639bb3ea61729066e3b33224b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 23:29:46 -1100 Subject: [PATCH 2564/3904] Musig commitment, nonce and partial sig roc --- src/cc/cclib.cpp | 20 +- src/cc/musig.cpp | 231 +++++++++++-------- src/secp256k1/include/secp256k1_musig.h | 84 ++++++- src/secp256k1/include/secp256k1_schnorrsig.h | 14 +- 4 files changed, 226 insertions(+), 123 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index bfd57e61d..ec74877b6 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -72,12 +72,11 @@ CClib_methods[] = { (char *)"sudoku", (char *)"pending", (char *)"", 0, 0, 'U', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"solution", (char *)"txid solution timestamps[81]", 83, 83, 'S', EVAL_SUDOKU }, { (char *)"musig", (char *)"calcmsg", (char *)"sendtxid scriptPubKey", 2, 2, 'C', EVAL_MUSIG }, - { (char *)"musig", (char *)"combine", (char *)"pubkeys ...", 2, 256, 'P', EVAL_MUSIG }, - { (char *)"musig", (char *)"session", (char *)"msg pkhash", 2, 2, 'R', EVAL_MUSIG }, - { (char *)"musig", (char *)"commit", (char *)"pubkeys ...", 2, 256, 'H', EVAL_MUSIG }, - { (char *)"musig", (char *)"nonce", (char *)"pubkeys ...", 2, 256, 'N', EVAL_MUSIG }, - { (char *)"musig", (char *)"partialsign", (char *)"pubkeys ...", 2, 256, 'S', EVAL_MUSIG }, - { (char *)"musig", (char *)"sigcombine", (char *)"pubkeys ...", 2, 256, 'M', EVAL_MUSIG }, + { (char *)"musig", (char *)"combine", (char *)"pubkeys ...", 2, 999999999, 'P', EVAL_MUSIG }, + { (char *)"musig", (char *)"session", (char *)"myindex,numsigners,combined_pk,pkhash,msg32", 5, 5, 'R', EVAL_MUSIG }, + { (char *)"musig", (char *)"commit", (char *)"pkhash,ind,commitment", 3, 3, 'H', EVAL_MUSIG }, + { (char *)"musig", (char *)"nonce", (char *)"pkhash,ind,nonce", 3, 3, 'N', EVAL_MUSIG }, + { (char *)"musig", (char *)"partialsig", (char *)"pkhash,ind,partialsig", 3, 3, 'S', EVAL_MUSIG }, { (char *)"musig", (char *)"verify", (char *)"msg sig pubkey", 3, 3, 'V', EVAL_MUSIG }, { (char *)"musig", (char *)"send", (char *)"combined_pk amount", 2, 2, 'x', EVAL_MUSIG }, { (char *)"musig", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_MUSIG }, @@ -116,8 +115,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -229,10 +227,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(musig_commit(txfee,cp,params)); else if ( strcmp(method,"nonce") == 0 ) // returns combined nonce if ready return(musig_nonce(txfee,cp,params)); - else if ( strcmp(method,"partialsign") == 0 ) - return(musig_partialsign(txfee,cp,params)); - else if ( strcmp(method,"sigcombine") == 0 ) - return(musig_sigcombine(txfee,cp,params)); + else if ( strcmp(method,"partialsig") == 0 ) + return(musig_partialsig(txfee,cp,params)); else if ( strcmp(method,"verify") == 0 ) return(musig_verify(txfee,cp,params)); else if ( strcmp(method,"send") == 0 ) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 7b9510b2a..f6a7bf7b7 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -20,6 +20,7 @@ "combined_pk": "032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b", "result": "success" } + the combined_pk and pkhash will be needed for various other rpc calls */ /* second, send 0.777 coins to the combined_pk @@ -55,6 +56,33 @@ "result": "success", "msg": "63b799913d4c9487f321b32d6ae8614f653f38e0b50d4df4bc1d36339ea18485" } +the "msg" is what needs to be signed to create a valid spend + + now on each signing node, a session needs to be created: + 5 args: ind, numsigners, combined_pk, pkhash, message to be signed + + on node with pubkey: 02aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848 + ./c cclib session 18 \"[0,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%2263b799913d4c9487f321b32d6ae8614f653f38e0b50d4df4bc1d36339ea18485%22]\" + { + "myind": 0, + "numsigners": 2, + "commitment": "053a97ba56b1b8adf174a0a28dc16b1bb4e91a33ca0b52a579ce9ba4af299973", + "result": "success" + } + + on node with pubkey: 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 + ./c cclib session 18 \"[1,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%2263b799913d4c9487f321b32d6ae8614f653f38e0b50d4df4bc1d36339ea18485%22]\" + { + "myind": 1, + "numsigners": 2, + "commitment": "8c8dc6717aaa1994d4a51d1094c0c5cbfaf033c11642dbeeab32a32de4cfbc86", + "result": "success" + } + + now we need to get the commitment from each node to the other one. the session already put the commitment for each node into the global struct. Keep in mind there is a single global struct with session unique to each cclib session call. that means no restarting any deamon in the middle of the process on any of the nodes and only call cclib session a single time. this is an artificial restriction just to simplify the initial implementation of musig + + ./c cclib commitment 18 \"[1,%228c8dc6717aaa1994d4a51d1094c0c5cbfaf033c11642dbeeab32a32de4cfbc86%22]\" + ./c cclib commitment 18 \"[0,%22053a97ba56b1b8adf174a0a28dc16b1bb4e91a33ca0b52a579ce9ba4af299973%22]\" */ @@ -91,9 +119,9 @@ extern "C" int secp256k1_musig_session_initialize(const secp256k1_context* ctx, struct musig_info { - secp256k1_musig_session musig_session; + secp256k1_musig_session session; secp256k1_pubkey combined_pk; - uint8_t *nonce_commitments; // 32*N_SIGNERS + uint8_t *nonce_commitments,**commitment_ptrs; // 32*N_SIGNERS secp256k1_musig_session_signer_data *signer_data; //[N_SIGNERS]; secp256k1_pubkey *nonce; //[N_SIGNERS]; secp256k1_musig_partial_signature *partial_sig; //[N_SIGNERS]; @@ -103,9 +131,12 @@ struct musig_info struct musig_info *musig_infocreate(int32_t myind,int32_t num) { - struct musig_info *mp = (struct musig_info *)calloc(1,sizeof(*mp)); + int32_t i; struct musig_info *mp = (struct musig_info *)calloc(1,sizeof(*mp)); mp->myind = myind, mp->num = num; mp->nonce_commitments = (uint8_t *)calloc(num,32); + mp->commitment_ptrs = (uint8_t **)calloc(num,sizeof(*mp->commitment_ptrs)); + for (i=0; icommitment_ptrs[i] = &mp->nonce_commitments[i*32]; mp->signer_data = (secp256k1_musig_session_signer_data *)calloc(num,sizeof(*mp->signer_data)); mp->nonce = (secp256k1_pubkey *)calloc(num,sizeof(*mp->nonce)); mp->partial_sig = (secp256k1_musig_partial_signature *)calloc(num,sizeof(*mp->partial_sig)); @@ -134,6 +165,11 @@ void musig_infofree(struct musig_info *mp) GetRandBytes((uint8_t *)mp->nonce_commitments,mp->num*32); free(mp->nonce_commitments); } + if ( mp->commitment_ptrs != 0 ) + { + GetRandBytes((uint8_t *)mp->commitment_ptrs,mp->num*sizeof(*mp->commitment_ptrs)); + free(mp->commitment_ptrs); + } GetRandBytes((uint8_t *)mp,sizeof(*mp)); free(mp); } @@ -329,7 +365,7 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * my_index: index of this signer in the signers array * seckey: the signer's 32-byte secret key (cannot be NULL) */ - if ( secp256k1_musig_session_initialize(ctx,&MUSIG->musig_session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) + if ( secp256k1_musig_session_initialize(ctx,&MUSIG->session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) { memset(session,0,sizeof(session)); result.push_back(Pair("myind",(int64_t)myind)); @@ -352,14 +388,19 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t n; + UniValue result(UniValue::VOBJ); int32_t n,ind; uint8_t pkhash[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - // pkhash, ind, commitment - // if all commitments, emit nonce, else just update MUSIG-> - + if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) + return(cclib_error(result,"error parsing pkhash")); + else if ( memcmp(MUSING->pkhash,pkhash,32) != 0 ) + return(cclib_error(result,"pkhash doesnt match session pkhash")); + else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + return(cclib_error(result,"illegal ind for session")); + else if ( musig_parsehash32(&MUSIG->commitment[ind*32],jitem(params,2)) < 0 ) + return(cclib_error(result,"error parsing commitment")); /** Gets the signer's public nonce given a list of all signers' data with commitments * * Returns: 1: public nonce is written in nonce @@ -375,27 +416,44 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * n_commitments: the length of commitments and signers array. Must be the total * number of signers participating in the MuSig. */ - // Set nonce commitments in the signer data and get the own public nonce - //if (secp256k1_musig_session_get_public_nonce(ctx, &musig_session[i], signer_data[i], &nonce[i], nonce_commitment_ptr, N_SIGNERS) > 0 ) + result.push_back(Pair("added_index",ind)); + if ( secp256k1_musig_session_get_public_nonce(ctx,&MUSIG->session,MUSIG->signer_data,&MUSIG->nonces[MUSIG->myind],MUSIG->nonce_commitments,MUSIG->num) > 0 ) { - // publish nonce + if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG->nonces[MUSIG->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) + { + for (i=0; i<33; i++) + sprintf(&str[i<<1],"%02x",((uint8_t *)pk.begin())[i]); + str[66] = 0; + result.push_back(Pair("nonce",str)); + result.push_back(Pair("result","success")); + } else return(cclib_error(result,"error serializing nonce (pubkey)")); + } + else + { + result.push_back(Pair("status","not enough commitments")); result.push_back(Pair("result","success")); } - // return 0; + return(result); } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, commitment")); } UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t n; + UniValue result(UniValue::VOBJ); int32_t i,n,ind; uint8_t pkhash[32],psig[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - // pkhash, ind, nonce - // if all nonces, combine nonce, else just update MUSIG-> - result.push_back(Pair("result","success")); + if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) + return(cclib_error(result,"error parsing pkhash")); + else if ( memcmp(MUSING->pkhash,pkhash,32) != 0 ) + return(cclib_error(result,"pkhash doesnt match session pkhash")); + else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + return(cclib_error(result,"illegal ind for session")); + else if ( musig_parsepubkey(ctx,&MUSIG->nonces[ind],jitem(params,2)) < 0 ) + return(cclib_error(result,"error parsing nonce")); + result.push_back(Pair("added_index",ind)); /** Checks a signer's public nonce against a commitment to said nonce, and update * data structure if they match * @@ -407,9 +465,11 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * with `musig_session_initialize_verifier`. * In: nonce: signer's alleged public nonce (cannot be NULL) */ - //if (!secp256k1_musig_set_nonce(ctx, &signer_data[i][j], &nonce[j])) { - - + for (i=0; inum; i++) + { + if ( secp256k1_musig_set_nonce(ctx,&MUSIG->signer_data[i],&MUSIG->nonces[i]) == 0 ) + return(cclib_error(result,"error setting nonce")); + } /** Updates a session with the combined public nonce of all signers. The combined * public nonce is the sum of every signer's public nonce. * @@ -428,91 +488,68 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * adaptor: point to add to the combined public nonce. If NULL, nothing is * added to the combined nonce. */ - // after all nonces: if (!secp256k1_musig_session_combine_nonces(ctx, &musig_session[i], signer_data[i], N_SIGNERS, NULL, NULL)) { - return(result); + if ( secp256k1_musig_session_combine_nonces(ctx,&MUSIG->session,MUSIG->signer_data,MUSIG->num,NULL,NULL) > 0 ) + { + if ( secp256k1_musig_partial_sign(ctx,&MUSIG->session,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + { + if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + { + result.push_back(Pair("myind",ind)); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",psig[i]); + str[64] = 0; + result.push_back(Pair("partialsig",str)); + result.push_back(Pair("result","success")); + return(result); + } else return(cclib_error(result,"error serializing partial sig")); + } else return(cclib_error(result,"error making partial sig")); + } else return(cclib_error(result,"error combining nonces")); } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, nonce")); } -UniValue musig_partialsign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t n; + UniValue result(UniValue::VOBJ); int32_t ind,n; uint8_t pkhash[32],psig[32],out64[64]; char str[129]; secp256k1_schnorrsig sig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - // similar to commit/nonce - } - result.push_back(Pair("result","success")); - /** Produces a partial signature - * - * Returns: 1: partial signature constructed - * 0: session in incorrect or inconsistent state - * Args: ctx: pointer to a context object (cannot be NULL) - * session: active signing session for which the combined nonce has been - * computed (cannot be NULL) - * Out: partial_sig: partial signature (cannot be NULL) - */ - //if (!secp256k1_musig_partial_sign(ctx, &musig_session[i], &partial_sig[i])) { - /** Parse and verify a MuSig partial signature. - * - * Returns: 1 when the signature could be parsed, 0 otherwise. - * Args: ctx: a secp256k1 context object - * Out: sig: pointer to a signature object - * In: in32: pointer to the 32-byte signature to be parsed - * - * After the call, sig will always be initialized. If parsing failed or the - * encoded numbers are out of range, signature verification with it is - * guaranteed to fail for every message and public key. - */ - //SECP256K1_API int secp256k1_musig_partial_signature_parse( - - return(result); -} - -UniValue musig_sigcombine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t n; - if ( ctx == 0 ) - ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - // finally! - } - result.push_back(Pair("result","success")); - /** Checks that an individual partial signature verifies - * - * This function is essential when using protocols with adaptor signatures. - * However, it is not essential for regular MuSig's, in the sense that if any - * partial signatures does not verify, the full signature will also not verify, so the - * problem will be caught. But this function allows determining the specific party - * who produced an invalid signature, so that signing can be restarted without them. - * - * Returns: 1: partial signature verifies - * 0: invalid signature or bad data - * Args: ctx: pointer to a context object (cannot be NULL) - * session: active session for which the combined nonce has been computed - * (cannot be NULL) - * signer: data for the signer who produced this signature (cannot be NULL) - * In: partial_sig: signature to verify (cannot be NULL) - * pubkey: public key of the signer who produced the signature (cannot be NULL) - */ - //if (!secp256k1_musig_partial_sig_verify(ctx, &musig_session[i], &signer_data[i][j], &partial_sig[j], &pubkeys[j])) { - return 0; - /** Combines partial signatures - * - * Returns: 1: all partial signatures have values in range. Does NOT mean the - * resulting signature verifies. - * 0: some partial signature had s/r out of range - * Args: ctx: pointer to a context object (cannot be NULL) - * session: initialized session for which the combined nonce has been - * computed (cannot be NULL) - * Out: sig: complete signature (cannot be NULL) - * In: partial_sigs: array of partial signatures to combine (cannot be NULL) - * n_sigs: number of signatures in the partial_sigs array - */ - // after all partials: return secp256k1_musig_partial_sig_combine(ctx, &musig_session[0], sig, partial_sig, N_SIGNERS return(result); + if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) + return(cclib_error(result,"error parsing pkhash")); + else if ( memcmp(MUSING->pkhash,pkhash,32) != 0 ) + return(cclib_error(result,"pkhash doesnt match session pkhash")); + else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + return(cclib_error(result,"illegal ind for session")); + else if ( musig_parsepartial(ctx,&MUSIG->partial_sig[ind],jitem(params,2)) < 0 ) + return(cclib_error(result,"error parsing partialsig")); + result.push_back(Pair("added_index",ind)); + if (secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) + { + if ( secp256k1_schnorrsig_serialize(ctx,out64,&sig) > 0 ) + { + result.push_back(Pair("result","success")); + for (i=0; i<64; i++) + sprintf(&str[i<<1],"%02x",out64[i]); + str[128] = 0; + result.push_back(Pair("combinedsig",str)); + } else return(cclib_error(result,"error serializing combinedsig")); + } + else + { + if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + { + result.push_back(Pair("myind",ind)); + for (i=0; i<32; i++) + sprintf(&str[i<<1],"%02x",psig[i]); + str[64] = 0; + result.push_back(Pair("partialsig",str)); + result.push_back(Pair("result","success")); + result.push_back(Pair("status","need more partialsigs")); + } else return(cclib_error(result,"error generating my partialsig")); + } + return(result); + } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, partialsig")); } UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) diff --git a/src/secp256k1/include/secp256k1_musig.h b/src/secp256k1/include/secp256k1_musig.h index a0106e691..84106822a 100644 --- a/src/secp256k1/include/secp256k1_musig.h +++ b/src/secp256k1/include/secp256k1_musig.h @@ -206,7 +206,12 @@ SECP256K1_API * n_commitments: the length of commitments and signers array. Must be the total * number of signers participating in the MuSig. */ -SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_get_public_nonce( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_get_public_nonce( const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, @@ -235,7 +240,12 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_get_publi * participating in the MuSig. Must be greater than 0 and at most * 2^32 - 1. */ -SECP256K1_API int secp256k1_musig_session_initialize_verifier( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_session_initialize_verifier( const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, @@ -257,7 +267,12 @@ SECP256K1_API int secp256k1_musig_session_initialize_verifier( * with `musig_session_initialize_verifier`. * In: nonce: signer's alleged public nonce (cannot be NULL) */ -SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_set_nonce( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_set_nonce( const secp256k1_context* ctx, secp256k1_musig_session_signer_data *signer, const secp256k1_pubkey *nonce @@ -281,7 +296,12 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_set_nonce( * adaptor: point to add to the combined public nonce. If NULL, nothing is * added to the combined nonce. */ -SECP256K1_API int secp256k1_musig_session_combine_nonces( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_session_combine_nonces( const secp256k1_context* ctx, secp256k1_musig_session *session, const secp256k1_musig_session_signer_data *signers, @@ -298,7 +318,12 @@ SECP256K1_API int secp256k1_musig_session_combine_nonces( * session: the session structure to update with the message (cannot be NULL) * In: msg32: the 32-byte message to be signed (cannot be NULL) */ -SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_set_msg( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_set_msg( const secp256k1_context* ctx, secp256k1_musig_session *session, const unsigned char *msg32 @@ -311,7 +336,12 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_session_set_msg( * Out: out32: pointer to a 32-byte array to store the serialized signature * In: sig: pointer to the signature */ -SECP256K1_API int secp256k1_musig_partial_signature_serialize( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_partial_signature_serialize( const secp256k1_context* ctx, unsigned char *out32, const secp256k1_musig_partial_signature* sig @@ -328,7 +358,12 @@ SECP256K1_API int secp256k1_musig_partial_signature_serialize( * encoded numbers are out of range, signature verification with it is * guaranteed to fail for every message and public key. */ -SECP256K1_API int secp256k1_musig_partial_signature_parse( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_partial_signature_parse( const secp256k1_context* ctx, secp256k1_musig_partial_signature* sig, const unsigned char *in32 @@ -343,7 +378,12 @@ SECP256K1_API int secp256k1_musig_partial_signature_parse( * computed (cannot be NULL) * Out: partial_sig: partial signature (cannot be NULL) */ -SECP256K1_API int secp256k1_musig_partial_sign( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_partial_sign( const secp256k1_context* ctx, const secp256k1_musig_session *session, secp256k1_musig_partial_signature *partial_sig @@ -366,7 +406,12 @@ SECP256K1_API int secp256k1_musig_partial_sign( * In: partial_sig: signature to verify (cannot be NULL) * pubkey: public key of the signer who produced the signature (cannot be NULL) */ -SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_verify( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_verify( const secp256k1_context* ctx, const secp256k1_musig_session *session, const secp256k1_musig_session_signer_data *signer, @@ -386,7 +431,12 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_verif * In: partial_sigs: array of partial signatures to combine (cannot be NULL) * n_sigs: number of signatures in the partial_sigs array */ -SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_combine( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_combine( const secp256k1_context* ctx, const secp256k1_musig_session *session, secp256k1_schnorrsig *sig, @@ -406,7 +456,12 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_partial_sig_combi * be NULL) * nonce_is_negated: the `nonce_is_negated` output of `musig_session_combine_nonces` */ -SECP256K1_API int secp256k1_musig_partial_sig_adapt( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + int secp256k1_musig_partial_sig_adapt( const secp256k1_context* ctx, secp256k1_musig_partial_signature *adaptor_sig, const secp256k1_musig_partial_signature *partial_sig, @@ -429,7 +484,12 @@ SECP256K1_API int secp256k1_musig_partial_sig_adapt( * n_partial_sigs: number of elements in partial_sigs array * nonce_is_negated: the `nonce_is_negated` output of `musig_session_combine_nonces` */ -SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_extract_secret_adaptor( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif + SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_extract_secret_adaptor( const secp256k1_context* ctx, unsigned char *sec_adaptor32, const secp256k1_schnorrsig *sig, diff --git a/src/secp256k1/include/secp256k1_schnorrsig.h b/src/secp256k1/include/secp256k1_schnorrsig.h index 9dea16653..e4d02f34f 100644 --- a/src/secp256k1/include/secp256k1_schnorrsig.h +++ b/src/secp256k1/include/secp256k1_schnorrsig.h @@ -28,7 +28,12 @@ typedef struct { * * See secp256k1_schnorrsig_parse for details about the encoding. */ -SECP256K1_API int secp256k1_schnorrsig_serialize( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif +int secp256k1_schnorrsig_serialize( const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig @@ -50,7 +55,12 @@ SECP256K1_API int secp256k1_schnorrsig_serialize( * encoded numbers are out of range, signature validation with it is * guaranteed to fail for every message and public key. */ -SECP256K1_API int secp256k1_schnorrsig_parse( +#ifdef __cplusplus +extern "C" +#else +SECP256K1_API +#endif +int secp256k1_schnorrsig_parse( const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64 From 141790634d27cc0461329d2261859c54ec3bebfa Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 23:33:13 -1100 Subject: [PATCH 2565/3904] Syntax --- src/cc/musig.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index f6a7bf7b7..8696809da 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -123,7 +123,7 @@ struct musig_info secp256k1_pubkey combined_pk; uint8_t *nonce_commitments,**commitment_ptrs; // 32*N_SIGNERS secp256k1_musig_session_signer_data *signer_data; //[N_SIGNERS]; - secp256k1_pubkey *nonce; //[N_SIGNERS]; + secp256k1_pubkey *nonces; //[N_SIGNERS]; secp256k1_musig_partial_signature *partial_sig; //[N_SIGNERS]; int32_t myind,num; uint8_t msg[32],pkhash[32],combpk[33]; @@ -138,7 +138,7 @@ struct musig_info *musig_infocreate(int32_t myind,int32_t num) for (i=0; icommitment_ptrs[i] = &mp->nonce_commitments[i*32]; mp->signer_data = (secp256k1_musig_session_signer_data *)calloc(num,sizeof(*mp->signer_data)); - mp->nonce = (secp256k1_pubkey *)calloc(num,sizeof(*mp->nonce)); + mp->nonces = (secp256k1_pubkey *)calloc(num,sizeof(*mp->nonces)); mp->partial_sig = (secp256k1_musig_partial_signature *)calloc(num,sizeof(*mp->partial_sig)); return(mp); } @@ -150,10 +150,10 @@ void musig_infofree(struct musig_info *mp) GetRandBytes((uint8_t *)mp->partial_sig,mp->num*sizeof(*mp->partial_sig)); free(mp->partial_sig); } - if ( mp->nonce != 0 ) + if ( mp->nonces != 0 ) { - GetRandBytes((uint8_t *)mp->nonce,mp->num*sizeof(*mp->nonce)); - free(mp->nonce); + GetRandBytes((uint8_t *)mp->nonces,mp->num*sizeof(*mp->nonces)); + free(mp->nonces); } if ( mp->signer_data != 0 ) { @@ -388,14 +388,14 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t n,ind; uint8_t pkhash[32]; CPubKey pk; char str[67]; + UniValue result(UniValue::VOBJ); int32_t i,n,ind; uint8_t pkhash[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSING->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); @@ -424,6 +424,7 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i<33; i++) sprintf(&str[i<<1],"%02x",((uint8_t *)pk.begin())[i]); str[66] = 0; + result.push_back(Pair("myind",MUSIG->myind)); result.push_back(Pair("nonce",str)); result.push_back(Pair("result","success")); } else return(cclib_error(result,"error serializing nonce (pubkey)")); @@ -447,7 +448,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSING->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); @@ -498,6 +499,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i<32; i++) sprintf(&str[i<<1],"%02x",psig[i]); str[64] = 0; + result.push_back(Pair("myind",MUSIG->myind)); result.push_back(Pair("partialsig",str)); result.push_back(Pair("result","success")); return(result); @@ -510,14 +512,14 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t ind,n; uint8_t pkhash[32],psig[32],out64[64]; char str[129]; secp256k1_schnorrsig sig; + UniValue result(UniValue::VOBJ); int32_t i,ind,n; uint8_t pkhash[32],psig[32],out64[64]; char str[129]; secp256k1_schnorrsig sig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSING->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); From 3d99ab8a66a0de574abfd066ff6980390734f860 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 23:39:37 -1100 Subject: [PATCH 2566/3904] Fix --- src/cc/musig.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 8696809da..2d4002059 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -388,6 +388,7 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; + size_t clen = CPubKey::PUBLIC_KEY_SIZE; UniValue result(UniValue::VOBJ); int32_t i,n,ind; uint8_t pkhash[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); @@ -399,7 +400,7 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash32(&MUSIG->commitment[ind*32],jitem(params,2)) < 0 ) + else if ( musig_parsehash32(&MUSIG->nonce_commitments[ind*32],jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing commitment")); /** Gets the signer's public nonce given a list of all signers' data with commitments * @@ -417,7 +418,7 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * number of signers participating in the MuSig. */ result.push_back(Pair("added_index",ind)); - if ( secp256k1_musig_session_get_public_nonce(ctx,&MUSIG->session,MUSIG->signer_data,&MUSIG->nonces[MUSIG->myind],MUSIG->nonce_commitments,MUSIG->num) > 0 ) + if ( secp256k1_musig_session_get_public_nonce(ctx,&MUSIG->session,MUSIG->signer_data,&MUSIG->nonces[MUSIG->myind],MUSIG->commitment_ptrs,MUSIG->num) > 0 ) { if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG->nonces[MUSIG->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) { @@ -452,7 +453,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsepubkey(ctx,&MUSIG->nonces[ind],jitem(params,2)) < 0 ) + else if ( musig_parsepubkey(ctx,MUSIG->nonces[ind],jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing nonce")); result.push_back(Pair("added_index",ind)); /** Checks a signer's public nonce against a commitment to said nonce, and update @@ -523,7 +524,9 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsepartial(ctx,&MUSIG->partial_sig[ind],jitem(params,2)) < 0 ) + else if ( musig_parsehash32(ctx,psig,jitem(params,2)) < 0 ) + return(cclib_error(result,"error parsing psig")); + else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); result.push_back(Pair("added_index",ind)); if (secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) From b17065ce1762782a13ab6205c06bd20df5a644ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 23:41:10 -1100 Subject: [PATCH 2567/3904] extern "C" --- src/cc/musig.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 2d4002059..03eb01e3e 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -113,6 +113,7 @@ extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const s extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); extern "C" int secp256k1_musig_pubkey_combine(const secp256k1_context* ctx, secp256k1_scratch_space *scratch, secp256k1_pubkey *combined_pk, unsigned char *pk_hash32, const secp256k1_pubkey *pubkeys, size_t n_pubkeys); extern "C" int secp256k1_musig_session_initialize(const secp256k1_context* ctx, secp256k1_musig_session *session, secp256k1_musig_session_signer_data *signers, unsigned char *nonce_commitment32, const unsigned char *session_id32, const unsigned char *msg32, const secp256k1_pubkey *combined_pk, const unsigned char *pk_hash32, size_t n_signers, size_t my_index, const unsigned char *seckey); +extern "C" int secp256k1_schnorrsig_serialize(const secp256k1_context* ctx, unsigned char *out64, const secp256k1_schnorrsig* sig); #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 @@ -524,12 +525,12 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash32(ctx,psig,jitem(params,2)) < 0 ) + else if ( musig_parsehash32(psig,jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing psig")); else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); result.push_back(Pair("added_index",ind)); - if (secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) + if ( secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) { if ( secp256k1_schnorrsig_serialize(ctx,out64,&sig) > 0 ) { From c07c6724b2d05dac81104b69a53f8fc23c49b845 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 23:52:20 -1100 Subject: [PATCH 2568/3904] Rpc examples to make a combined signature "combinedsig": "bc0062cd3233433e098fbf4f3c333946779c3dccfaefc423243e3f90edfdf9a6dbfabf4 2d26f3c668fe6e10f1ed367a46dfddbafaee82b3eb79722ae49f45320" --- src/cc/musig.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 03eb01e3e..4f08dd4cf 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -66,7 +66,7 @@ the "msg" is what needs to be signed to create a valid spend { "myind": 0, "numsigners": 2, - "commitment": "053a97ba56b1b8adf174a0a28dc16b1bb4e91a33ca0b52a579ce9ba4af299973", + "commitment": "89af8f6db69fc3d4b95480a914dceba9933039e9823151a82677c3ca4e961fcc", "result": "success" } @@ -75,15 +75,73 @@ the "msg" is what needs to be signed to create a valid spend { "myind": 1, "numsigners": 2, - "commitment": "8c8dc6717aaa1994d4a51d1094c0c5cbfaf033c11642dbeeab32a32de4cfbc86", + "commitment": "a43da5ef8322abb43b9fddadef7b6479baf7853e860f915e01521e3060e5342b", "result": "success" } now we need to get the commitment from each node to the other one. the session already put the commitment for each node into the global struct. Keep in mind there is a single global struct with session unique to each cclib session call. that means no restarting any deamon in the middle of the process on any of the nodes and only call cclib session a single time. this is an artificial restriction just to simplify the initial implementation of musig - ./c cclib commitment 18 \"[1,%228c8dc6717aaa1994d4a51d1094c0c5cbfaf033c11642dbeeab32a32de4cfbc86%22]\" - ./c cclib commitment 18 \"[0,%22053a97ba56b1b8adf174a0a28dc16b1bb4e91a33ca0b52a579ce9ba4af299973%22]\" + ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%22a43da5ef8322abb43b9fddadef7b6479baf7853e860f915e01521e3060e5342b%22]\" + { + "added_index": 1, + "myind": 0, + "nonce": "03bf28874f5e5dccf55170406d58ded84ac6ca713011d718c6048400d700cb879a", + "result": "success" + } + + ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%2289af8f6db69fc3d4b95480a914dceba9933039e9823151a82677c3ca4e961fcc%22]\" + { + "added_index": 0, + "myind": 1, + "nonce": "039ae1f542e8f0f6d03d734dc2295651973e1b7fa99508e2f36dad5d21f09889f6", + "result": "success" + } + + Now exchange the revealed nonces to each node: + + ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%22039ae1f542e8f0f6d03d734dc2295651973e1b7fa99508e2f36dad5d21f09889f6%22]\" + { + "added_index": 1, + "myind": 0, + "partialsig": "5da4c1ec828cd1563bc6554aa74c90c29fcd38b2aea26f7fa92e0d007aa9463f", + "result": "success" + } + + ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%2203bf28874f5e5dccf55170406d58ded84ac6ca713011d718c6048400d700cb879a%22]\" + { + "added_index": 0, + "myind": 1, + "partialsig": "7e55fd564fe26b1054208bc47786d6e1ce30a2fd0045bbbf0e6915adcf4b0ce1", + "result": "success" + } + + Almost there! final step is to exchange the partial sigs between signers + ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%227e55fd564fe26b1054208bc47786d6e1ce30a2fd0045bbbf0e6915adcf4b0ce1%22]\" + { + "added_index": 1, + "result": "success", + "combinedsig": "bc0062cd3233433e098fbf4f3c333946779c3dccfaefc423243e3f90edfdf9a6dbfabf42d26f3c668fe6e10f1ed367a46dfddbafaee82b3eb79722ae49f45320" + } + + ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%225da4c1ec828cd1563bc6554aa74c90c29fcd38b2aea26f7fa92e0d007aa9463f%22]\" + + { + "added_index": 0, + "result": "success", + "combinedsig": "bc0062cd3233433e098fbf4f3c333946779c3dccfaefc423243e3f90edfdf9a6dbfabf42d26f3c668fe6e10f1ed367a46dfddbafaee82b3eb79722ae49f45320" + } + + Notice both nodes generated the same combined signature! + + Now for a sanity test, we can use the verify call to make sure this sig will work with the msg needed for the spend: + + xxxx + + + and finally the spend: + + */ @@ -497,7 +555,6 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) { - result.push_back(Pair("myind",ind)); for (i=0; i<32; i++) sprintf(&str[i<<1],"%02x",psig[i]); str[64] = 0; From 925eaa285162afaeed9396aced6413ed38c61a62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 23:57:30 -1100 Subject: [PATCH 2569/3904] Test --- src/cc/musig.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 4f08dd4cf..6b2e7abca 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -139,9 +139,9 @@ the "msg" is what needs to be signed to create a valid spend xxxx - and finally the spend: - + and finally the spend: sendtxid, scriptPubKey, musig +./c cclib spend 18 \"[%22cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22,%22bc0062cd3233433e098fbf4f3c333946779c3dccfaefc423243e3f90edfdf9a6dbfabf42d26f3c668fe6e10f1ed367a46dfddbafaee82b3eb79722ae49f45320%22]\" */ @@ -696,6 +696,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) prevhash = juint256(jitem(params,0)); scriptstr = jstr(jitem(params,1),0); musigstr = jstr(jitem(params,2),0); + printf("script.(%s) musig.(%s) %d\n",scriptstr,musigstr,(int32_t)strlen(musigstr)); if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) != 128 ) { if ( txfee == 0 ) @@ -723,7 +724,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } else return(cclib_error(result,"couldnt decode send opret")); } else return(cclib_error(result,"couldnt find vin0")); } else return(cclib_error(result,"script or musig is not hex")); - } else return(cclib_error(result,"need to have exactly 3 params prevhash, scriptPubKey, musig")); + } else return(cclib_error(result,"need to have exactly 3 params sendtxid, scriptPubKey, musig")); } else return(cclib_error(result,"params parse error")); } From 748ab667e2d36b71c29d943b855d7dbbc07abd86 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 23:59:42 -1100 Subject: [PATCH 2570/3904] Test --- src/cc/musig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 6b2e7abca..172958fba 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -696,7 +696,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) prevhash = juint256(jitem(params,0)); scriptstr = jstr(jitem(params,1),0); musigstr = jstr(jitem(params,2),0); - printf("script.(%s) musig.(%s) %d\n",scriptstr,musigstr,(int32_t)strlen(musigstr)); + printf("script.(%s) %d musig.(%s) %d\n",scriptstr,is_hexstr(scriptstr,0),musigstr,is_hexstr(musigstr,0)); if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) != 128 ) { if ( txfee == 0 ) From 3bea6f84e4c353df73316e8079e516a903461516 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:00:55 -1100 Subject: [PATCH 2571/3904] Fix --- src/cc/musig.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 172958fba..a690e4d01 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -696,8 +696,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) prevhash = juint256(jitem(params,0)); scriptstr = jstr(jitem(params,1),0); musigstr = jstr(jitem(params,2),0); - printf("script.(%s) %d musig.(%s) %d\n",scriptstr,is_hexstr(scriptstr,0),musigstr,is_hexstr(musigstr,0)); - if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) != 128 ) + if ( is_hexstr(scriptstr,0) != 0 && is_hexstr(musigstr,0) == 128 ) { if ( txfee == 0 ) txfee = MUSIG_TXFEE; From 33811cce5f78616998d2b7fe1a75714d028fae23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:16:26 -1100 Subject: [PATCH 2572/3904] +print --- src/cc/musig.cpp | 64 ++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index a690e4d01..be4ff278e 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -26,8 +26,8 @@ /* second, send 0.777 coins to the combined_pk ./c cclib send 18 \"[%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,0.777]\" { - "hex": "0400008085202f8901bf7afcbbab7a5e1ba20c8010325e199305afa7d15b4bc86a589a512201d39924000000004847304402203e0cff8aaa831dd990afd979bbc0a648316f77407cb5e02780d18e0670f5172a0220283d5c52d0406b10c508cc2b19dd6dbe2420e7c5cf431a1d41072d0eec28edb901ffffffff03b0c2a10400000000302ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cca91e223700000000232102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac0000000000000000266a24127821032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b00000000900000000000000000000000000000", - "txid": "cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be", + "hex": "0400008085202f8908018bbc4a0acf0f896680b84cc1000ec5530042fa3cf7471ab5c11cde56f6d0e60000000048473044022041a900fa57e54f939b797d09f0cee81ab9a79d978cd473ef3fc9f09c7678ad6b02206386bd15ee7ee8224a984fdd1d2a094738d082aec06028a5846d7bc61ddf16ca01ffffffff0b969f0e1ea787f0cc4e81d128353bd1cb670ab89bd1db4b47fbb7e872cd39fb00000000494830450221008c5de4b196e57b0dd94aa415950adf274e3e6859b82cf218729af84c1f15e76c022024aeab7eda63e6a652ef488bf26a8dc4ef8d2d4aa5746726085bfe5f169a5db701ffffffff0b36b70b43457fab377f28fb22da5a3e9d8186a37daae18cf0f710a221ab26250000000048473044022004ec20ae7490e7adabf9a3f78e4a58df84a3245485bfdd40f421cafe61d19c340220456d2b6f3c6e88632027c02606a0af1c21208d05f2de0826fbf4dfe7391ec83901ffffffff0aaff3cfe4ca22b97b6179a6f7cfac91945e5440e9438b89d1ec09500167176a0000000048473044022074dcad30c8ab9ed79a3ac69169611fc9e5f4b76a561b183461d968249316997f022063b25decaa285f494d277b9c8c2bcf6445b7929a304542e89c0645828d30a1a901ffffffff090e1bb92e9bf404a0d6455701b21af3dbf6765e61a1dc28b7c0f608ec4f12da000000004847304402202f9182c532c66138a6bdfcbb85a06cf1bf1532f2bf8f63170ef20843e4a81d0202207612a4353eb9606e84621c444ec7db1b683ff29c56127bda2d5e9c0eb13dbbc001ffffffff08a57005c7a40a923b1a510820b07f7318d760fe2a233b077d918cce357ad3af00000000484730440220643d60c68634fb2e0f6656389fc70c9f84c7086fc6e35b0fa26297e844f6c5fc02201d79669e073efe738d47de0130fdcba875e284e18fd478c0e6834d46632d8b8101ffffffff068cfd0ea6c0f5d401c67ec38f92425a9e59b0d5ade55bb2971ea955675a17bd00000000484730440220747139724248da4bcc1e5e3828e0ea811756e1fad0ebc40aeb006fd8079d46e402200d8f1c229c79494b5617e4373a3e083966dcd74571323f9d334be901d53871fa01ffffffff0200382fb6984b6128bb75115346242809c6555274e0cacef822825a2b4d231700000000484730440220454fcac398f6913fb4d8ed330f110f9cf62eec6c8cdb67d5df1effd2cf8222d5022017f6323630669777573e342e870c88727a917cc06c33611ebbd9d1fccc1dcd3701ffffffff03b0c2a10400000000302ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cc40ca220000000000232102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac0000000000000000266a24127821032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b00000000460100000000000000000000000000", + "txid": "2c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68", "result": "success" } @@ -46,92 +46,94 @@ } change script: 2102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac - sendtxid: cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be + sendtxid: 2c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68 broadcast sendtxid and wait for it to be confirmed. then get the msg we need to sign: - ./c cclib calcmsg 18 \"[%22cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22]\" + ./c cclib calcmsg 18 \"[%222c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22]\" { "result": "success", - "msg": "63b799913d4c9487f321b32d6ae8614f653f38e0b50d4df4bc1d36339ea18485" + "msg": "caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0" } + the "msg" is what needs to be signed to create a valid spend now on each signing node, a session needs to be created: 5 args: ind, numsigners, combined_pk, pkhash, message to be signed on node with pubkey: 02aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848 - ./c cclib session 18 \"[0,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%2263b799913d4c9487f321b32d6ae8614f653f38e0b50d4df4bc1d36339ea18485%22]\" + ./c cclib session 18 \"[0,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%22caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0%22]\" { "myind": 0, "numsigners": 2, - "commitment": "89af8f6db69fc3d4b95480a914dceba9933039e9823151a82677c3ca4e961fcc", + "commitment": "e82228c10d0e100477630349150dea744d3b2790dcd347511a1a98199840cda4", "result": "success" } on node with pubkey: 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 - ./c cclib session 18 \"[1,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%2263b799913d4c9487f321b32d6ae8614f653f38e0b50d4df4bc1d36339ea18485%22]\" + ./c cclib session 18 \"[1,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%22caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0%22]\" { "myind": 1, "numsigners": 2, - "commitment": "a43da5ef8322abb43b9fddadef7b6479baf7853e860f915e01521e3060e5342b", + "commitment": "6e426e850ddc45e7742cfb6321781c00ee69a995ab12fa1f9ded7fe43658babf", "result": "success" } now we need to get the commitment from each node to the other one. the session already put the commitment for each node into the global struct. Keep in mind there is a single global struct with session unique to each cclib session call. that means no restarting any deamon in the middle of the process on any of the nodes and only call cclib session a single time. this is an artificial restriction just to simplify the initial implementation of musig - ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%22a43da5ef8322abb43b9fddadef7b6479baf7853e860f915e01521e3060e5342b%22]\" + ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%226e426e850ddc45e7742cfb6321781c00ee69a995ab12fa1f9ded7fe43658babf%22]\" { "added_index": 1, "myind": 0, - "nonce": "03bf28874f5e5dccf55170406d58ded84ac6ca713011d718c6048400d700cb879a", + "nonce": "0261671b0a6de416938cf035c98f8af37c6ca88bbbd1bcce693d709d4919b010e1", "result": "success" } - ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%2289af8f6db69fc3d4b95480a914dceba9933039e9823151a82677c3ca4e961fcc%22]\" + ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%22e82228c10d0e100477630349150dea744d3b2790dcd347511a1a98199840cda4%22]\" { "added_index": 0, "myind": 1, - "nonce": "039ae1f542e8f0f6d03d734dc2295651973e1b7fa99508e2f36dad5d21f09889f6", + "nonce": "02570f62a625ceb19a754a053152b162810c3e403df63f3d443e85bdacc74bfdfe", "result": "success" } Now exchange the revealed nonces to each node: - ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%22039ae1f542e8f0f6d03d734dc2295651973e1b7fa99508e2f36dad5d21f09889f6%22]\" + ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%2202570f62a625ceb19a754a053152b162810c3e403df63f3d443e85bdacc74bfdfe%22]\" { "added_index": 1, "myind": 0, - "partialsig": "5da4c1ec828cd1563bc6554aa74c90c29fcd38b2aea26f7fa92e0d007aa9463f", + "partialsig": "3f21885e6d2d020e1473435ccd148a61cdcb1d1105867fed45913185dc0acf59", "result": "success" } - ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%2203bf28874f5e5dccf55170406d58ded84ac6ca713011d718c6048400d700cb879a%22]\" + ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%220261671b0a6de416938cf035c98f8af37c6ca88bbbd1bcce693d709d4919b010e1%22]\" { "added_index": 0, + "myind": 0, "myind": 1, - "partialsig": "7e55fd564fe26b1054208bc47786d6e1ce30a2fd0045bbbf0e6915adcf4b0ce1", + "partialsig": "af7f28455fb2e988d81068cd9d800879cd334036a8300118dc307b777a38c1ed", "result": "success" } Almost there! final step is to exchange the partial sigs between signers - ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%227e55fd564fe26b1054208bc47786d6e1ce30a2fd0045bbbf0e6915adcf4b0ce1%22]\" + ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%22af7f28455fb2e988d81068cd9d800879cd334036a8300118dc307b777a38c1ed%22]\" { "added_index": 1, "result": "success", - "combinedsig": "bc0062cd3233433e098fbf4f3c333946779c3dccfaefc423243e3f90edfdf9a6dbfabf42d26f3c668fe6e10f1ed367a46dfddbafaee82b3eb79722ae49f45320" + "combinedsig": "5e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146" } + - ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%225da4c1ec828cd1563bc6554aa74c90c29fcd38b2aea26f7fa92e0d007aa9463f%22]\" + ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%223f21885e6d2d020e1473435ccd148a61cdcb1d1105867fed45913185dc0acf59%22]\" { "added_index": 0, "result": "success", - "combinedsig": "bc0062cd3233433e098fbf4f3c333946779c3dccfaefc423243e3f90edfdf9a6dbfabf42d26f3c668fe6e10f1ed367a46dfddbafaee82b3eb79722ae49f45320" + "combinedsig": "5e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146" } - Notice both nodes generated the same combined signature! Now for a sanity test, we can use the verify call to make sure this sig will work with the msg needed for the spend: @@ -141,7 +143,7 @@ the "msg" is what needs to be signed to create a valid spend and finally the spend: sendtxid, scriptPubKey, musig -./c cclib spend 18 \"[%22cb5309ed249da95e2b5696eb763a8736e2fff1d14922ada737b931494ca3d2be%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22,%22bc0062cd3233433e098fbf4f3c333946779c3dccfaefc423243e3f90edfdf9a6dbfabf42d26f3c668fe6e10f1ed367a46dfddbafaee82b3eb79722ae49f45320%22]\" +./c cclib spend 18 \"[%222c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22,%225e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146%22]\" */ @@ -686,7 +688,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; secp256k1_schnorrsig musig; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t i,n,numvouts; char str[129]; CTxOut vout; secp256k1_schnorrsig musig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) @@ -713,6 +715,20 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) { musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); + { + for (i=0; i<32; i++) + sprintf(&str[i*2],"%02x",msg[i]); + str[64] = 0; + result.push_back(Pair("msg",str)); + for (i=0; i<33; i++) + sprintf(&str[i*2],"%02x",((uint8_t *)pk.begin)[i]); + str[66] = 0; + result.push_back(Pair("combined_pk",str)); + for (i=0; i<64; i++) + sprintf(&str[i*2],"%02x",musig64[i]); + str[128] = 0; + result.push_back(Pair("combinedsig",str)); + } if ( !secp256k1_schnorrsig_verify((const secp256k1_context *)ctx,&musig,(const uint8_t *)msg,(const secp256k1_pubkey *)&combined_pk) ) return(cclib_error(result,"musig didnt validate")); mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); From 8b8339b5b941963c6ea6331cf57af5c5edc2facc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:17:05 -1100 Subject: [PATCH 2573/3904] () --- src/cc/musig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index be4ff278e..88bf62449 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -721,7 +721,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) str[64] = 0; result.push_back(Pair("msg",str)); for (i=0; i<33; i++) - sprintf(&str[i*2],"%02x",((uint8_t *)pk.begin)[i]); + sprintf(&str[i*2],"%02x",((uint8_t *)pk.begin())[i]); str[66] = 0; result.push_back(Pair("combined_pk",str)); for (i=0; i<64; i++) From 6eaac8547a3ddb506e70896e3251daf07524395c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:23:02 -1100 Subject: [PATCH 2574/3904] Skip test --- src/cc/musig.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 88bf62449..63d7e5291 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -730,7 +730,9 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("combinedsig",str)); } if ( !secp256k1_schnorrsig_verify((const secp256k1_context *)ctx,&musig,(const uint8_t *)msg,(const secp256k1_pubkey *)&combined_pk) ) - return(cclib_error(result,"musig didnt validate")); + { + //return(cclib_error(result,"musig didnt validate")); + } mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); mtx.vout.push_back(vout); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,musig_spendopret('y',pk,musig64)); From baef592f94e608d939f4bf627d1ae34e785f1187 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:26:39 -1100 Subject: [PATCH 2575/3904] Fix script parsing --- src/cc/musig.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 63d7e5291..28795d95c 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -704,7 +704,9 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) txfee = MUSIG_TXFEE; mypk = pubkey2pk(Mypubkey()); std::vector musig64(ParseHex(musigstr)); - CScript scriptPubKey(ParseHex(scriptstr)); + CScript scriptPubKey; + scriptPubKey.resize(strlen(scriptstr)/2); + decode_hex((uint8_t *)scriptPubKey.data(),strlen(scriptstr)/2,scriptstr); if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { vout.nValue = vintx.vout[0].nValue - txfee; From 3de50a250b2d1ad2321d67c2336dfe061fb6d2da Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:29:48 -1100 Subject: [PATCH 2576/3904] Test --- src/cc/musig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 28795d95c..fdb24f7a0 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -706,7 +706,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector musig64(ParseHex(musigstr)); CScript scriptPubKey; scriptPubKey.resize(strlen(scriptstr)/2); - decode_hex((uint8_t *)scriptPubKey.data(),strlen(scriptstr)/2,scriptstr); + decode_hex(&scriptPubKey[0],strlen(scriptstr)/2,scriptstr); if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { vout.nValue = vintx.vout[0].nValue - txfee; From a687d695af02abc60505583027971cfc2373c446 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:41:51 -1100 Subject: [PATCH 2577/3904] Verify roc --- src/cc/musig.cpp | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index fdb24f7a0..9eaec4404 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -620,25 +620,35 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t n; + UniValue result(UniValue::VOBJ); int32_t i,n; uint8_t msg[32],musig64[64]; secp256k1_pubkey combined_pk; secp256k1_schnorrsig musig; char str[129]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) != 3 ) { - // can code this out of order - } - result.push_back(Pair("result","success")); - /** Verify a Schnorr signature. - * - * Returns: 1: correct signature - * 0: incorrect or unparseable signature - * Args: ctx: a secp256k1 context object, initialized for verification. - * In: sig: the signature being verified (cannot be NULL) - * msg32: the 32-byte message hash being verified (cannot be NULL) - * pubkey: pointer to a public key to verify with (cannot be NULL) - */ - // if (!secp256k1_schnorrsig_verify(ctx, &sig, msg, &combined_pk)) { - return(result); + if ( musig_parsehash32(msg,jitem(params,0)) < 0 ) + return(cclib_error(result,"error parsing pkhash")); + else if ( musig_parsepubkey(ctx,combined_pk,jitem(params,1)) < 0 ) + return(cclib_error(result,"error parsing combined_pk")); + else if ( musig_parsehash64(musig64,jitem(params,2)) < 0 ) + return(cclib_error(result,"error parsing musig64")); + for (i=0; i<32; i++) + sprintf(&str[i*2],"%02x",msg[i]); + str[64] = 0; + result.push_back(Pair("msg",str)); + result.push_back(Pair("combined_pk",jstr(jitem(params,1),0))); + for (i=0; i<64; i++) + sprintf(&str[i*2],"%02x",musig64[i]); + str[128] = 0; + result.push_back(Pair("combinedsig",str)); + if ( secp256k1_schnorrsig_parse(ctx,&musig,&musig64[0]) > 0 ) + { + if ( secp256k1_schnorrsig_verify(ctx,&musig,msg,&combined_pk) > 0 ) + { + result.push_back(Pair("result","success")); + return(result); + } else return(cclib_error(result,"musig didnt verify")); + } else return(cclib_error(result,"couldnt parse musig64")); + } else return(cclib_error(result,"wrong number of params, need 3: msg, combined_pk, combinedsig")); } // helpers for rpc calls that generate/validate onchain tx @@ -733,7 +743,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } if ( !secp256k1_schnorrsig_verify((const secp256k1_context *)ctx,&musig,(const uint8_t *)msg,(const secp256k1_pubkey *)&combined_pk) ) { - //return(cclib_error(result,"musig didnt validate")); + return(cclib_error(result,"musig didnt validate")); } mtx.vin.push_back(CTxIn(prevhash,MUSIG_PREVN)); mtx.vout.push_back(vout); From 317fa937b3ca5010daa59cfdb58725c7bc2b7d45 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:43:44 -1100 Subject: [PATCH 2578/3904] parsehash --- src/cc/musig.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 9eaec4404..c5cf5fc4e 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -331,12 +331,12 @@ int32_t musig_parsepubkey(secp256k1_context *ctx,secp256k1_pubkey &spk,cJSON *it } else return(-1); } -int32_t musig_parsehash32(uint8_t *hash32,cJSON *item) +int32_t musig_parsehash(uint8_t *hash32,cJSON *item,int32_t len) { char *hexstr; - if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == 64 ) + if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == len*2 ) { - decode_hex(hash32,32,hexstr); + decode_hex(hash32,len,hexstr); return(0); } else return(-1); } @@ -394,9 +394,9 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) MUSIG = musig_infocreate(myind,num); if ( musig_parsepubkey(ctx,MUSIG->combined_pk,jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing combined_pubkey")); - else if ( musig_parsehash32(MUSIG->pkhash,jitem(params,3)) < 0 ) + else if ( musig_parsehash(MUSIG->pkhash,jitem(params,3),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( musig_parsehash32(MUSIG->msg,jitem(params,4)) < 0 ) + else if ( musig_parsehash(MUSIG->msg,jitem(params,4),32) < 0 ) return(cclib_error(result,"error parsing msg")); Myprivkey(privkey); GetRandBytes(session,32); @@ -455,13 +455,13 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) + if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash32(&MUSIG->nonce_commitments[ind*32],jitem(params,2)) < 0 ) + else if ( musig_parsehash(&MUSIG->nonce_commitments[ind*32],jitem(params,2),32) < 0 ) return(cclib_error(result,"error parsing commitment")); /** Gets the signer's public nonce given a list of all signers' data with commitments * @@ -508,7 +508,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) + if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); @@ -578,13 +578,13 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - if ( musig_parsehash32(pkhash,jitem(params,0)) < 0 ) + if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash32(psig,jitem(params,2)) < 0 ) + else if ( musig_parsehash(psig,jitem(params,2),32) < 0 ) return(cclib_error(result,"error parsing psig")); else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); @@ -625,11 +625,11 @@ UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) != 3 ) { - if ( musig_parsehash32(msg,jitem(params,0)) < 0 ) + if ( musig_parsehash(msg,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); else if ( musig_parsepubkey(ctx,combined_pk,jitem(params,1)) < 0 ) return(cclib_error(result,"error parsing combined_pk")); - else if ( musig_parsehash64(musig64,jitem(params,2)) < 0 ) + else if ( musig_parsehash(musig64,jitem(params,2),64) < 0 ) return(cclib_error(result,"error parsing musig64")); for (i=0; i<32; i++) sprintf(&str[i*2],"%02x",msg[i]); From 6704dd969965d0b938ad2dceab6714a90daca687 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:52:37 -1100 Subject: [PATCH 2579/3904] Fix --- src/cc/musig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index c5cf5fc4e..8e37a2add 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -138,7 +138,7 @@ the "msg" is what needs to be signed to create a valid spend Now for a sanity test, we can use the verify call to make sure this sig will work with the msg needed for the spend: - xxxx + ./c cclib verify 18 \"[%22caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0%22,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146%22]\" and finally the spend: sendtxid, scriptPubKey, musig @@ -623,7 +623,7 @@ UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); int32_t i,n; uint8_t msg[32],musig64[64]; secp256k1_pubkey combined_pk; secp256k1_schnorrsig musig; char str[129]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) != 3 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { if ( musig_parsehash(msg,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); From 3caa4fb350c74d5af61b02770a523272ddc8324d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:59:15 -1100 Subject: [PATCH 2580/3904] Test check.c --- src/cc/cclib.cpp | 32 +---------------------- src/secp256k1/src/modules/musig/example.c | 6 ++--- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index ec74877b6..b070ded78 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -580,37 +580,7 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" - -/* -#include "../secp256k1/src/util.h" -#include "../secp256k1/src/num_impl.h" -#include "../secp256k1/src/field_impl.h" -#include "../secp256k1/src/scalar_impl.h" -#include "../secp256k1/src/group_impl.h" -#include "../secp256k1/src/scratch_impl.h" -#include "../secp256k1/src/ecmult_impl.h" -#include "../secp256k1/src/ecmult_const_impl.h" -#include "../secp256k1/src/ecmult_gen_impl.h" -#include "../secp256k1/src/ecdsa_impl.h" -#include "../secp256k1/src/eckey_impl.h" -#include "../secp256k1/src/hash_impl.h" - - - -typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); -extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); -extern "C" int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); -extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); -extern "C" void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); - -#define ARG_CHECK(cond) do { \ -if (EXPECT(!(cond), 0)) { \ -secp256k1_callback_call(&ctx->illegal_callback, #cond); \ -return 0; \ -} \ -} while(0)*/ - -//#include "../secp256k1/src/secp256k1.c" #include "musig.cpp" +#include "../secp256k1/modules/musig/check.c" #endif diff --git a/src/secp256k1/src/modules/musig/example.c b/src/secp256k1/src/modules/musig/example.c index ceae18686..94c9fdef2 100644 --- a/src/secp256k1/src/modules/musig/example.c +++ b/src/secp256k1/src/modules/musig/example.c @@ -9,11 +9,11 @@ * Additionally, see the documentation in include/secp256k1_musig.h. */ -#include +/*#include #include #include #include -#include +#include */ /* Number of public keys involved in creating the aggregate signature */ #define N_SIGNERS 3 @@ -122,7 +122,7 @@ int sign(const secp256k1_context* ctx, unsigned char seckeys[][32], const secp25 return secp256k1_musig_partial_sig_combine(ctx, &musig_session[0], sig, partial_sig, N_SIGNERS); } - int main(void) { + int testmain(void) { secp256k1_context* ctx; int i; unsigned char seckeys[N_SIGNERS][32]; From fe60cfbf6eb486ac08a5b3906854ab1c82d1d1c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 00:59:44 -1100 Subject: [PATCH 2581/3904] Src --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b070ded78..9cd947efc 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -581,6 +581,6 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" #include "musig.cpp" -#include "../secp256k1/modules/musig/check.c" +#include "../secp256k1/src/modules/musig/check.c" #endif From 1a34721c44c35815f90b739c30eb4d28ef3e6783 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 01:01:00 -1100 Subject: [PATCH 2582/3904] example.c --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 9cd947efc..c770917ea 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -581,6 +581,6 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" #include "musig.cpp" -#include "../secp256k1/src/modules/musig/check.c" +#include "../secp256k1/src/modules/musig/example.c" #endif From 93acda143f271f0e08b07393f958dc194bb352ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 01:03:17 -1100 Subject: [PATCH 2583/3904] fprintf(stderr, --- src/cc/musig.cpp | 2 ++ src/secp256k1/src/modules/musig/example.c | 26 +++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 8e37a2add..446f9333d 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -617,10 +617,12 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, partialsig")); } +int testmain(void); UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; UniValue result(UniValue::VOBJ); int32_t i,n; uint8_t msg[32],musig64[64]; secp256k1_pubkey combined_pk; secp256k1_schnorrsig musig; char str[129]; + testmain(); if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) diff --git a/src/secp256k1/src/modules/musig/example.c b/src/secp256k1/src/modules/musig/example.c index 94c9fdef2..70d183e7d 100644 --- a/src/secp256k1/src/modules/musig/example.c +++ b/src/secp256k1/src/modules/musig/example.c @@ -128,37 +128,37 @@ int sign(const secp256k1_context* ctx, unsigned char seckeys[][32], const secp25 unsigned char seckeys[N_SIGNERS][32]; secp256k1_pubkey pubkeys[N_SIGNERS]; secp256k1_pubkey combined_pk; - unsigned char msg[32] = "this_could_be_the_hash_of_a_msg!"; + unsigned char msg[32] = "this_could_be_the_hash_of_a_msg"; secp256k1_schnorrsig sig; /* Create a context for signing and verification */ ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - printf("Creating key pairs......"); + fprintf(stderr,"Creating key pairs......"); for (i = 0; i < N_SIGNERS; i++) { if (!create_key(ctx, seckeys[i], &pubkeys[i])) { - printf("FAILED\n"); + fprintf(stderr,"FAILED\n"); return 1; } } - printf("ok\n"); - printf("Combining public keys..."); + fprintf(stderr,"ok\n"); + fprintf(stderr,"Combining public keys..."); if (!secp256k1_musig_pubkey_combine(ctx, NULL, &combined_pk, NULL, pubkeys, N_SIGNERS)) { - printf("FAILED\n"); + fprintf(stderr,"FAILED\n"); return 1; } - printf("ok\n"); - printf("Signing message........."); + fprintf(stderr,"ok\n"); + fprintf(stderr,"Signing message........."); if (!sign(ctx, seckeys, pubkeys, msg, &sig)) { - printf("FAILED\n"); + fprintf(stderr,"FAILED\n"); return 1; } - printf("ok\n"); - printf("Verifying signature....."); + fprintf(stderr,"ok\n"); + fprintf(stderr,"Verifying signature....."); if (!secp256k1_schnorrsig_verify(ctx, &sig, msg, &combined_pk)) { - printf("FAILED\n"); + fprintf(stderr,"FAILED\n"); return 1; } - printf("ok\n"); + fprintf(stderr,"ok\n"); secp256k1_context_destroy(ctx); return 0; } From a0b7227e007bcfa96ad6e99c54a85875652eed63 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 09:29:09 -1100 Subject: [PATCH 2584/3904] Dont create rogue files on validation --- src/cc/rogue_rpc.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 57ce1e14b..213e382a1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -833,7 +833,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; roguepk = GetUnspendable(cp,0); @@ -854,19 +854,22 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat } if ( keystrokes != 0 ) { - sprintf(fname,"rogue.%llu.0",(long long)seed); - if ( (fp= fopen(fname,"wb")) != 0 ) + if ( makefiles != 0 ) { - if ( fwrite(keystrokes,1,numkeys,fp) != numkeys ) - fprintf(stderr,"error writing %s\n",fname); - fclose(fp); - } - sprintf(fname,"rogue.%llu.player",(long long)seed); - if ( (fp= fopen(fname,"wb")) != 0 ) - { - if ( fwrite(&playerdata[0],1,(int32_t)playerdata.size(),fp) != playerdata.size() ) - fprintf(stderr,"error writing %s\n",fname); - fclose(fp); + sprintf(fname,"rogue.%llu.0",(long long)seed); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + if ( fwrite(keystrokes,1,numkeys,fp) != numkeys ) + fprintf(stderr,"error writing %s\n",fname); + fclose(fp); + } + sprintf(fname,"rogue.%llu.player",(long long)seed); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + if ( fwrite(&playerdata[0],1,(int32_t)playerdata.size(),fp) != playerdata.size() ) + fprintf(stderr,"error writing %s\n",fname); + fclose(fp); + } } num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); @@ -914,7 +917,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); str[0] = 0; - if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) + if ( (keystrokes= rogue_extractgame(1,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; @@ -1240,7 +1243,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); //fprintf(stderr,"call extractgame\n"); - if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) + if ( (keystrokes= rogue_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { free(keystrokes); //fprintf(stderr,"extracted.(%s)\n",str); From fa3b624d512d7476ea3a3927a810c1f426b98b14 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Feb 2019 15:12:00 +0800 Subject: [PATCH 2585/3904] fix musig and working example added --- src/cc/musig.cpp | 236 ++++++++++++++++++++++++++++------------------- 1 file changed, 139 insertions(+), 97 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 446f9333d..bd3d74a95 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -14,47 +14,67 @@ ******************************************************************************/ /* first make a combined pk: -./c cclib combine 18 \"[%2202aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22,%22039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22]\" -{ - "pkhash": "5be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba", - "combined_pk": "032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b", - "result": "success" -} - the combined_pk and pkhash will be needed for various other rpc calls -*/ -/* second, send 0.777 coins to the combined_pk - ./c cclib send 18 \"[%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,0.777]\" +./komodo-cli -ac_name=MUSIG cclib combine 18 '["02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28","0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4"]' +{ + "pkhash": "5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b", + "combined_pk": "03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b", + "result": "success" +} + + the combined_pk and pkhash will be needed for various other rpc calls + + second, send 1 coin to the combined_pk + ./komodo-cli -ac_name=MUSIG cclib send 18 '["03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b",1]' { - "hex": "0400008085202f8908018bbc4a0acf0f896680b84cc1000ec5530042fa3cf7471ab5c11cde56f6d0e60000000048473044022041a900fa57e54f939b797d09f0cee81ab9a79d978cd473ef3fc9f09c7678ad6b02206386bd15ee7ee8224a984fdd1d2a094738d082aec06028a5846d7bc61ddf16ca01ffffffff0b969f0e1ea787f0cc4e81d128353bd1cb670ab89bd1db4b47fbb7e872cd39fb00000000494830450221008c5de4b196e57b0dd94aa415950adf274e3e6859b82cf218729af84c1f15e76c022024aeab7eda63e6a652ef488bf26a8dc4ef8d2d4aa5746726085bfe5f169a5db701ffffffff0b36b70b43457fab377f28fb22da5a3e9d8186a37daae18cf0f710a221ab26250000000048473044022004ec20ae7490e7adabf9a3f78e4a58df84a3245485bfdd40f421cafe61d19c340220456d2b6f3c6e88632027c02606a0af1c21208d05f2de0826fbf4dfe7391ec83901ffffffff0aaff3cfe4ca22b97b6179a6f7cfac91945e5440e9438b89d1ec09500167176a0000000048473044022074dcad30c8ab9ed79a3ac69169611fc9e5f4b76a561b183461d968249316997f022063b25decaa285f494d277b9c8c2bcf6445b7929a304542e89c0645828d30a1a901ffffffff090e1bb92e9bf404a0d6455701b21af3dbf6765e61a1dc28b7c0f608ec4f12da000000004847304402202f9182c532c66138a6bdfcbb85a06cf1bf1532f2bf8f63170ef20843e4a81d0202207612a4353eb9606e84621c444ec7db1b683ff29c56127bda2d5e9c0eb13dbbc001ffffffff08a57005c7a40a923b1a510820b07f7318d760fe2a233b077d918cce357ad3af00000000484730440220643d60c68634fb2e0f6656389fc70c9f84c7086fc6e35b0fa26297e844f6c5fc02201d79669e073efe738d47de0130fdcba875e284e18fd478c0e6834d46632d8b8101ffffffff068cfd0ea6c0f5d401c67ec38f92425a9e59b0d5ade55bb2971ea955675a17bd00000000484730440220747139724248da4bcc1e5e3828e0ea811756e1fad0ebc40aeb006fd8079d46e402200d8f1c229c79494b5617e4373a3e083966dcd74571323f9d334be901d53871fa01ffffffff0200382fb6984b6128bb75115346242809c6555274e0cacef822825a2b4d231700000000484730440220454fcac398f6913fb4d8ed330f110f9cf62eec6c8cdb67d5df1effd2cf8222d5022017f6323630669777573e342e870c88727a917cc06c33611ebbd9d1fccc1dcd3701ffffffff03b0c2a10400000000302ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cc40ca220000000000232102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac0000000000000000266a24127821032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b00000000460100000000000000000000000000", - "txid": "2c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68", - "result": "success" + "hex": "0400008085202f8901a980664dffc810725a79ffb89ac48be4c7b6bade9b789732fcf871acf8e81a2e010000006a47304402207e52763661ecd2c34a65d6623950be11794825db71576dc11894c606ddc317800220028fef46dc20630d0fdf22647b5d4ff0f1c47cf75f48702d0a91d5589eff99d001210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ffffffff031008f60500000000302ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cce09aa4350000000023210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac0000000000000000266a2412782103f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b00000000920500000000000000000000000000", + "txid": "5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c", + "result": "success" } - { - "value": 0.77710000, - "valueZat": 77710000, - "n": 0, - "scriptPubKey": { - "asm": "a22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401 OP_CHECKCRYPTOCONDITION", - "hex": "2ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cc", - "reqSigs": 1, - "type": "cryptocondition", - "addresses": [ - "RKWS7jxyjPX9iaJttk8iMKf1AumanKypez" - ] - } - change script: 2102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac + sendrawtransaction of the above hex. - sendtxid: 2c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68 + ./komodo-cli -ac_name=MUSIG getrawtransaction 5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c 1 + "vout": [ + { + "value": 1.00010000, + "valueSat": 100010000, + "n": 0, + "scriptPubKey": { + "asm": "a22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401 OP_CHECKCRYPTOCONDITION", + "hex": "2ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cc", + "reqSigs": 1, + "type": "cryptocondition", + "addresses": [ + "RKWS7jxyjPX9iaJttk8iMKf1AumanKypez" + ] + } + }, + { + "value": 8.99980000, + "valueSat": 899980000, + "n": 1, + "scriptPubKey": { + "asm": "0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4 OP_CHECKSIG", + "hex": "210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac", + "reqSigs": 1, + "type": "pubkey", + "addresses": [ + "RVQjvGdRbYLJ49bfH4SAFseipvwE3UdoDw" + ] + } - broadcast sendtxid and wait for it to be confirmed. then get the msg we need to sign: + script: 210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac - ./c cclib calcmsg 18 \"[%222c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22]\" + sendtxid: 5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c + + get the msg we need to sign: + + ./komodo-cli -ac_name=MUSIG cclib calcmsg 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac"]' { - "result": "success", - "msg": "caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0" + "msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75", + "result": "success" } the "msg" is what needs to be signed to create a valid spend @@ -62,88 +82,101 @@ the "msg" is what needs to be signed to create a valid spend now on each signing node, a session needs to be created: 5 args: ind, numsigners, combined_pk, pkhash, message to be signed - on node with pubkey: 02aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848 - ./c cclib session 18 \"[0,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%22caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0%22]\" + on node with pubkey: 02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28 + ./komodo-cli -ac_name=MUSIG cclib session 18 '[0,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","c1b34139744f3b54b652dc741ebd0f9d5b53ad28795cc6614dd8ad3aaabf15ae","f5d91999b23b85630a4cbd0baea3736529411b052cf5f1f4345c5d181af12825"]' { - "myind": 0, - "numsigners": 2, - "commitment": "e82228c10d0e100477630349150dea744d3b2790dcd347511a1a98199840cda4", - "result": "success" + "myind": 0, + "numsigners": 2, + "commitment": "bbea1f2562eca01b9a1393c5dc188bdd44551aebf684f4459930f59dde01f7ae", + "result": "success" } - - on node with pubkey: 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 - ./c cclib session 18 \"[1,2,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,%22caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0%22]\" - { - "myind": 1, - "numsigners": 2, - "commitment": "6e426e850ddc45e7742cfb6321781c00ee69a995ab12fa1f9ded7fe43658babf", - "result": "success" - } - - now we need to get the commitment from each node to the other one. the session already put the commitment for each node into the global struct. Keep in mind there is a single global struct with session unique to each cclib session call. that means no restarting any deamon in the middle of the process on any of the nodes and only call cclib session a single time. this is an artificial restriction just to simplify the initial implementation of musig - - ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%226e426e850ddc45e7742cfb6321781c00ee69a995ab12fa1f9ded7fe43658babf%22]\" - { - "added_index": 1, - "myind": 0, - "nonce": "0261671b0a6de416938cf035c98f8af37c6ca88bbbd1bcce693d709d4919b010e1", - "result": "success" - } - - ./c cclib commit 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%22e82228c10d0e100477630349150dea744d3b2790dcd347511a1a98199840cda4%22]\" - { - "added_index": 0, - "myind": 1, - "nonce": "02570f62a625ceb19a754a053152b162810c3e403df63f3d443e85bdacc74bfdfe", - "result": "success" - } - - Now exchange the revealed nonces to each node: - - ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%2202570f62a625ceb19a754a053152b162810c3e403df63f3d443e85bdacc74bfdfe%22]\" + on node with pubkey: 0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4 + ./komodo-cli -ac_name=MUSIG cclib session 18 '[1,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]' { - "added_index": 1, - "myind": 0, - "partialsig": "3f21885e6d2d020e1473435ccd148a61cdcb1d1105867fed45913185dc0acf59", - "result": "success" + "myind": 1, + "numsigners": 2, + "commitment": "c2291acb747a75b1a40014d8eb0cc90a1360f74d413f65f78e20a7de45eda851", + "result": "success" + } + + now we need to get the commitment from each node to the other one. the session already put the commitment for each node into the global struct. Keep in mind there is a single global struct with session unique to each cclib session call. that means no restarting any deamon in the middle of the process on any of the nodes and only call cclib session a single time. this is an artificial restriction just to simplify the initial implementation of musig + ./komodo-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","c2291acb747a75b1a40014d8eb0cc90a1360f74d413f65f78e20a7de45eda851"]' + { + "added_index": 1, + "myind": 0, + "nonce": "02fec7a9310c959a0a97b86bc3f8c30d392d1fb51793915898c568f73f1f70476b", + "result": "success" } - ./c cclib nonce 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%220261671b0a6de416938cf035c98f8af37c6ca88bbbd1bcce693d709d4919b010e1%22]\" + ./komodo-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"d242cff13fa8c9b83248e4219fda459ada146b885f2171481f1b0f66c66d94ad"]' { - "added_index": 0, - "myind": 0, - "myind": 1, - "partialsig": "af7f28455fb2e988d81068cd9d800879cd334036a8300118dc307b777a38c1ed", - "result": "success" + "added_index": 0, + "myind": 1, + "nonce": "039365deaaaea089d509ba4c9f846de2baf4aa04cf6b26fa2c1cd818553e47f80c", + "result": "success" } + + Now exchange the revealed nonces to each node: + ./komodo-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","039365deaaaea089d509ba4c9f846de2baf4aa04cf6b26fa2c1cd818553e47f80c"]' +{ + "added_index": 1, + "myind": 0, + "partialsig": "1d65c09cd9bffe4f0604227e66cd7cd221480bbb08262fe885563a9df7cf8f5b", + "result": "success" +} + +./komodo-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"02fec7a9310c959a0a97b86bc3f8c30d392d1fb51793915898c568f73f1f70476b"]' +{ + "added_index": 0, + "myind": 1, + "partialsig": "4a3795e6801b355102c617390cf5a462061e082e35dc2ed8f8b1fab54cc0769e", + "result": "success" +} Almost there! final step is to exchange the partial sigs between signers - ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,1,%22af7f28455fb2e988d81068cd9d800879cd334036a8300118dc307b777a38c1ed%22]\" + ./komodo-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","4a3795e6801b355102c617390cf5a462061e082e35dc2ed8f8b1fab54cc0769e"]' { - "added_index": 1, - "result": "success", - "combinedsig": "5e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146" + "added_index": 1, + "result": "success", + "combinedsig": "a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9" } - - ./c cclib partialsig 18 \"[%225be117f3c5ce87e7dc6882c24b8231e0652ee82054bf7b9f94aef1f45e055cba%22,0,%223f21885e6d2d020e1473435ccd148a61cdcb1d1105867fed45913185dc0acf59%22]\" - + ./komodo-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"1d65c09cd9bffe4f0604227e66cd7cd221480bbb08262fe885563a9df7cf8f5b"]' { - "added_index": 0, - "result": "success", - "combinedsig": "5e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146" + "added_index": 0, + "result": "success", + "combinedsig": "a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9" } + Notice both nodes generated the same combined signature! Now for a sanity test, we can use the verify call to make sure this sig will work with the msg needed for the spend: - ./c cclib verify 18 \"[%22caa64ba398ddfe5c33d8c70a61e556caa0e69b19d93110c5a458a1b37ad44cb0%22,%22032ddac56613cd0667b589bd7f32b665e2d2ce0247e337a5a0bca6c72e3d9d057b%22,%225e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146%22]\" - + ./komodo-cli -ac_name=MUSIG cclib verify 18 '["f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75","03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]' + { + "msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75", + "combined_pk": "03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b", + "combinedsig": "a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9", + "result": "success" + } and finally the spend: sendtxid, scriptPubKey, musig -./c cclib spend 18 \"[%222c4159bb19212dcaa412ae37de7d72398f063194053e04a65b0facf767ebcc68%22,%222102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac%22,%225e64dc5dda93b2d3f25fe44b2aaca69b8f15d21f70e2bc1c2c53e17262d941bbeea0b0a3ccdfeb96ec83ac2a6a9492db9afe5d47adb6810621c1acfd56439146%22]\" + ./komodo-cli -ac_name=MUSIG cclib spend 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]' +{ + "scriptpubkey": "210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac", + "msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75", + "combined_pk": "03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b", + "combinedsig": "a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9", + "hex": "0400008085202f89014c821930f9eb360daaf1a1e12d5a82998b63884e8db4130421ee53a13740e75c000000007b4c79a276a072a26ba067a5658021032d29d6545a2aafad795d9cf50912ecade549137 +163934dfb2895ebc0e211ce8a81409671a60db89b3bc58966f3acc80194479b1a43d868e95a11ebc5609646d18710341a8ff92a7817571980307f5d660cc00a2735ac6333e0a7191243f1263f1959a100af03800112 +a10001ffffffff0200e1f5050000000023210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac0000000000000000686a4c6512792103f016c348437c7422eed92d865aa9789614f +75327cada463eefc566126b54785b40a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f900000000a805 +00000000000000000000000000", + "txid": "910635bf69a047fc90567a83ff12e47b753f470658b6d0855ec96e07e7349a8a", + "result": "success" +} */ @@ -298,7 +331,7 @@ int32_t musig_prevoutmsg(uint8_t *msg,uint256 sendtxid,CScript scriptPubKey) UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); uint256 sendtxid; int32_t i; uint8_t msg[32]; char *scriptstr,str[65]; int32_t n; + UniValue result(UniValue::VOBJ); uint256 sendtxid; int32_t i,zeros=0; uint8_t msg[32]; char *scriptstr,str[65]; int32_t n; if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n == 2 ) @@ -307,14 +340,23 @@ UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) scriptstr = jstr(jitem(params,1),0); if ( is_hexstr(scriptstr,0) != 0 ) { - CScript scriptPubKey(ParseHex(scriptstr)); + CScript scriptPubKey; + scriptPubKey.resize(strlen(scriptstr)/2); + decode_hex(&scriptPubKey[0],strlen(scriptstr)/2,scriptstr); musig_prevoutmsg(msg,sendtxid,scriptPubKey); - result.push_back(Pair("result","success")); for (i=0; i<32; i++) + { sprintf(&str[i<<1],"%02x",msg[i]); + if ( msg[i] == 0 ) + zeros++; + } str[64] = 0; - result.push_back(Pair("msg",str)); - return(result); + if ( zeros != 32 ) + { + result.push_back(Pair("msg",str)); + result.push_back(Pair("result","success")); + return(result); + } else return(cclib_error(result,"null result, make sure params are sendtxid, scriptPubKey")); } else return(cclib_error(result,"script is not hex")); } else return(cclib_error(result,"need exactly 2 parameters: sendtxid, scriptPubKey")); } else return(cclib_error(result,"couldnt parse params")); From ebc07912fdb319358e162ec5be149f8e03bd5c0f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Feb 2019 15:18:18 +0800 Subject: [PATCH 2586/3904] fix rogue ipaddress thing for Alright. Needs to be tested! --- depends/packages/boost.mk | 6 +-- src/cc/rogue/main.c | 2 + src/musigtest.py | 91 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100755 src/musigtest.py diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 7a0439ba7..3c180b0ce 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,8 +1,8 @@ package=boost -$(package)_version=1_69_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.69.0/source +$(package)_version=1_66_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.66.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 +$(package)_sha256_hash=5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9 define $(package)_set_vars $(package)_config_opts_release=variant=release diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 3461445ee..6fc3d36c8 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -802,6 +802,8 @@ int main(int argc, char **argv, char **envp) } ASSETCHAINS_SYMBOL[j++] = 0; ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL,IPADDRESS); + if ( IPADDRESS[0] == 0 ) + strcopy("127.0.0.1",IPADDRESS); printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s)\n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { diff --git a/src/musigtest.py b/src/musigtest.py new file mode 100755 index 000000000..f5f25d250 --- /dev/null +++ b/src/musigtest.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 +import platform +import os +import re +import json +import random +import base58 +import binascii +import hashlib +import sys +from slickrpc import Proxy + +# fucntion to define rpc_connection +def def_credentials(chain): + rpcport = ''; + operating_system = platform.system() + if operating_system == 'Darwin': + ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' + elif operating_system == 'Linux': + ac_dir = os.environ['HOME'] + '/.komodo' + elif operating_system == 'Windows': + ac_dir = '%s/komodo/' % os.environ['APPDATA'] + if chain == 'KMD': + coin_config_file = str(ac_dir + '/komodo.conf') + else: + coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') + with open(coin_config_file, 'r') as f: + for line in f: + l = line.rstrip() + if re.search('rpcuser', l): + rpcuser = l.replace('rpcuser=', '') + elif re.search('rpcpassword', l): + rpcpassword = l.replace('rpcpassword=', '') + elif re.search('rpcport', l): + rpcport = l.replace('rpcport=', '') + if len(rpcport) == 0: + if chain == 'KMD': + rpcport = 7771 + else: + print("rpcport not in conf file, exiting") + print("check " + coin_config_file) + exit(1) + return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport)))) + + +# generate address, validate address, dump private key +def genvaldump(rpc_connection): + # get new address + address = rpc_connection.getnewaddress() + # validate address + validateaddress_result = rpc_connection.validateaddress(address) + pubkey = validateaddress_result['pubkey'] + address = validateaddress_result['address'] + # dump private key for the address + privkey = rpc_connection.dumpprivkey(address) + # function output + output = [pubkey, privkey, address] + return(output) + +CHAIN = 'MUSIG' #sys.argv[1] + +rpc = def_credentials(CHAIN) + +pubkeys = [] +address_info = [] +ret = input('Do you want to generate new pubkeys? ').lower() + +if ret.startswith('y'): + numpks = int(input('Enter number of pubkeys to combine: ')) + if os.path.isfile("list.json"): + print('Already have list.json, move it if you would like to generate a new set.') + sys.exit(0) + while len(address_info) < numpks: + addressinfo = genvaldump(rpc) + address_info.append(addressinfo) + f = open("list.json", "w+") + f.write(json.dumps(address_info)) +else: + if os.path.isfile("list.json"): + with open('list.json') as list: + address_info = json.load(list) + else: + sys.exit('No list.json you need to create new pubkeys!') + +for addressinfo in address_info: + pubkeys.append(addressinfo[0]) + +ret = rpc.setpubkey(pubkeys[0]) +combinedpk = rpc.cclib("combine", "18", str(pubkeys))['combined_pk'] + +print('Your combined pubkey is: ' + combinedpk) From fb82fc82aaae27fc885a0ad156747bbfbde0b78a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Feb 2019 15:23:08 +0800 Subject: [PATCH 2587/3904] fix --- src/cc/rogue/main.c | 2 +- src/musigtest.py | 91 --------------------------------------------- 2 files changed, 1 insertion(+), 92 deletions(-) delete mode 100755 src/musigtest.py diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 6fc3d36c8..4dfc0a70a 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -803,7 +803,7 @@ int main(int argc, char **argv, char **envp) ASSETCHAINS_SYMBOL[j++] = 0; ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL,IPADDRESS); if ( IPADDRESS[0] == 0 ) - strcopy("127.0.0.1",IPADDRESS); + strcpy("127.0.0.1",IPADDRESS); printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s)\n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { diff --git a/src/musigtest.py b/src/musigtest.py deleted file mode 100755 index f5f25d250..000000000 --- a/src/musigtest.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python3 -import platform -import os -import re -import json -import random -import base58 -import binascii -import hashlib -import sys -from slickrpc import Proxy - -# fucntion to define rpc_connection -def def_credentials(chain): - rpcport = ''; - operating_system = platform.system() - if operating_system == 'Darwin': - ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' - elif operating_system == 'Linux': - ac_dir = os.environ['HOME'] + '/.komodo' - elif operating_system == 'Windows': - ac_dir = '%s/komodo/' % os.environ['APPDATA'] - if chain == 'KMD': - coin_config_file = str(ac_dir + '/komodo.conf') - else: - coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') - with open(coin_config_file, 'r') as f: - for line in f: - l = line.rstrip() - if re.search('rpcuser', l): - rpcuser = l.replace('rpcuser=', '') - elif re.search('rpcpassword', l): - rpcpassword = l.replace('rpcpassword=', '') - elif re.search('rpcport', l): - rpcport = l.replace('rpcport=', '') - if len(rpcport) == 0: - if chain == 'KMD': - rpcport = 7771 - else: - print("rpcport not in conf file, exiting") - print("check " + coin_config_file) - exit(1) - return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport)))) - - -# generate address, validate address, dump private key -def genvaldump(rpc_connection): - # get new address - address = rpc_connection.getnewaddress() - # validate address - validateaddress_result = rpc_connection.validateaddress(address) - pubkey = validateaddress_result['pubkey'] - address = validateaddress_result['address'] - # dump private key for the address - privkey = rpc_connection.dumpprivkey(address) - # function output - output = [pubkey, privkey, address] - return(output) - -CHAIN = 'MUSIG' #sys.argv[1] - -rpc = def_credentials(CHAIN) - -pubkeys = [] -address_info = [] -ret = input('Do you want to generate new pubkeys? ').lower() - -if ret.startswith('y'): - numpks = int(input('Enter number of pubkeys to combine: ')) - if os.path.isfile("list.json"): - print('Already have list.json, move it if you would like to generate a new set.') - sys.exit(0) - while len(address_info) < numpks: - addressinfo = genvaldump(rpc) - address_info.append(addressinfo) - f = open("list.json", "w+") - f.write(json.dumps(address_info)) -else: - if os.path.isfile("list.json"): - with open('list.json') as list: - address_info = json.load(list) - else: - sys.exit('No list.json you need to create new pubkeys!') - -for addressinfo in address_info: - pubkeys.append(addressinfo[0]) - -ret = rpc.setpubkey(pubkeys[0]) -combinedpk = rpc.cclib("combine", "18", str(pubkeys))['combined_pk'] - -print('Your combined pubkey is: ' + combinedpk) From 9ed121b9477012c42e16acb4ec4cebf38b39cb6d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Feb 2019 15:24:23 +0800 Subject: [PATCH 2588/3904] undo --- depends/packages/boost.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 3c180b0ce..7a0439ba7 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,8 +1,8 @@ package=boost -$(package)_version=1_66_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.66.0/source +$(package)_version=1_69_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.69.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9 +$(package)_sha256_hash=8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 define $(package)_set_vars $(package)_config_opts_release=variant=release From aa6b693feecac75cf90c4dd3657499f13818d220 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Feb 2019 15:26:18 +0800 Subject: [PATCH 2589/3904] fix strcpy --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 4dfc0a70a..165f01dfd 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -803,7 +803,7 @@ int main(int argc, char **argv, char **envp) ASSETCHAINS_SYMBOL[j++] = 0; ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL,IPADDRESS); if ( IPADDRESS[0] == 0 ) - strcpy("127.0.0.1",IPADDRESS); + strcpy(IPADDRESS,"127.0.0.1"); printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s)\n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { From 9df722e1b6a5f82254bcf7281e3a4f365f200023 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 21:04:55 -1100 Subject: [PATCH 2590/3904] Dilithium lib --- src/cc/cclib.cpp | 3 +- src/cc/dilithium.c | 2837 ++++++++++++++++++++++++++++++++++++++++++++ src/cc/dilithium.h | 474 ++++++++ src/cc/makecclib | 2 +- src/cc/musig.cpp | 4 +- 5 files changed, 3316 insertions(+), 4 deletions(-) create mode 100644 src/cc/dilithium.c create mode 100644 src/cc/dilithium.h diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c770917ea..84f229069 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -581,6 +581,7 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" #include "musig.cpp" -#include "../secp256k1/src/modules/musig/example.c" +#inclide "dilithium.c" +//#include "../secp256k1/src/modules/musig/example.c" #endif diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c new file mode 100644 index 000000000..b6624353e --- /dev/null +++ b/src/cc/dilithium.c @@ -0,0 +1,2837 @@ +/* Based on the public domain implementation in + * crypto_hash/keccakc512/simple/ from http://bench.cr.yp.to/supercop.html + * by Ronny Van Keer + * and the public domain "TweetFips202" implementation + * from https://twitter.com/tweetfips202 + * by Gilles Van Assche, Daniel J. Bernstein, and Peter Schwabe */ + +#include +#include "dilithium.h" + + +#define NROUNDS 24 +#define ROL(a, offset) ((a << offset) ^ (a >> (64-offset))) + +/************************************************* +* Name: load64 +* +* Description: Load 8 bytes into uint64_t in little-endian order +* +* Arguments: - const uint8_t *x: pointer to input byte array +* +* Returns the loaded 64-bit unsigned integer +**************************************************/ +static uint64_t load64(const uint8_t *x) { + uint32_t i; + uint64_t r = 0; + + for (i = 0; i < 8; ++i) + r |= (uint64_t)x[i] << 8*i; + + return r; +} + +/************************************************* +* Name: store64 +* +* Description: Store a 64-bit integer to array of 8 bytes in little-endian order +* +* Arguments: - uint8_t *x: pointer to the output byte array (allocated) +* - uint64_t u: input 64-bit unsigned integer +**************************************************/ +static void store64(uint8_t *x, uint64_t u) { + uint32_t i; + + for(i = 0; i < 8; ++i) + x[i] = u >> 8*i; +} + +/* Keccak round constants */ +static const uint64_t KeccakF_RoundConstants[NROUNDS] = { + (uint64_t)0x0000000000000001ULL, + (uint64_t)0x0000000000008082ULL, + (uint64_t)0x800000000000808aULL, + (uint64_t)0x8000000080008000ULL, + (uint64_t)0x000000000000808bULL, + (uint64_t)0x0000000080000001ULL, + (uint64_t)0x8000000080008081ULL, + (uint64_t)0x8000000000008009ULL, + (uint64_t)0x000000000000008aULL, + (uint64_t)0x0000000000000088ULL, + (uint64_t)0x0000000080008009ULL, + (uint64_t)0x000000008000000aULL, + (uint64_t)0x000000008000808bULL, + (uint64_t)0x800000000000008bULL, + (uint64_t)0x8000000000008089ULL, + (uint64_t)0x8000000000008003ULL, + (uint64_t)0x8000000000008002ULL, + (uint64_t)0x8000000000000080ULL, + (uint64_t)0x000000000000800aULL, + (uint64_t)0x800000008000000aULL, + (uint64_t)0x8000000080008081ULL, + (uint64_t)0x8000000000008080ULL, + (uint64_t)0x0000000080000001ULL, + (uint64_t)0x8000000080008008ULL +}; + +/************************************************* +* Name: KeccakF1600_StatePermute +* +* Description: The Keccak F1600 Permutation +* +* Arguments: - uint64_t *state: pointer to input/output Keccak state +**************************************************/ +static void KeccakF1600_StatePermute(uint64_t *state) +{ + int round; + + uint64_t Aba, Abe, Abi, Abo, Abu; + uint64_t Aga, Age, Agi, Ago, Agu; + uint64_t Aka, Ake, Aki, Ako, Aku; + uint64_t Ama, Ame, Ami, Amo, Amu; + uint64_t Asa, Ase, Asi, Aso, Asu; + uint64_t BCa, BCe, BCi, BCo, BCu; + uint64_t Da, De, Di, Do, Du; + uint64_t Eba, Ebe, Ebi, Ebo, Ebu; + uint64_t Ega, Ege, Egi, Ego, Egu; + uint64_t Eka, Eke, Eki, Eko, Eku; + uint64_t Ema, Eme, Emi, Emo, Emu; + uint64_t Esa, Ese, Esi, Eso, Esu; + + //copyFromState(A, state) + Aba = state[ 0]; + Abe = state[ 1]; + Abi = state[ 2]; + Abo = state[ 3]; + Abu = state[ 4]; + Aga = state[ 5]; + Age = state[ 6]; + Agi = state[ 7]; + Ago = state[ 8]; + Agu = state[ 9]; + Aka = state[10]; + Ake = state[11]; + Aki = state[12]; + Ako = state[13]; + Aku = state[14]; + Ama = state[15]; + Ame = state[16]; + Ami = state[17]; + Amo = state[18]; + Amu = state[19]; + Asa = state[20]; + Ase = state[21]; + Asi = state[22]; + Aso = state[23]; + Asu = state[24]; + + for( round = 0; round < NROUNDS; round += 2 ) + { + // prepareTheta + BCa = Aba^Aga^Aka^Ama^Asa; + BCe = Abe^Age^Ake^Ame^Ase; + BCi = Abi^Agi^Aki^Ami^Asi; + BCo = Abo^Ago^Ako^Amo^Aso; + BCu = Abu^Agu^Aku^Amu^Asu; + + //thetaRhoPiChiIotaPrepareTheta(round , A, E) + Da = BCu^ROL(BCe, 1); + De = BCa^ROL(BCi, 1); + Di = BCe^ROL(BCo, 1); + Do = BCi^ROL(BCu, 1); + Du = BCo^ROL(BCa, 1); + + Aba ^= Da; + BCa = Aba; + Age ^= De; + BCe = ROL(Age, 44); + Aki ^= Di; + BCi = ROL(Aki, 43); + Amo ^= Do; + BCo = ROL(Amo, 21); + Asu ^= Du; + BCu = ROL(Asu, 14); + Eba = BCa ^((~BCe)& BCi ); + Eba ^= (uint64_t)KeccakF_RoundConstants[round]; + Ebe = BCe ^((~BCi)& BCo ); + Ebi = BCi ^((~BCo)& BCu ); + Ebo = BCo ^((~BCu)& BCa ); + Ebu = BCu ^((~BCa)& BCe ); + + Abo ^= Do; + BCa = ROL(Abo, 28); + Agu ^= Du; + BCe = ROL(Agu, 20); + Aka ^= Da; + BCi = ROL(Aka, 3); + Ame ^= De; + BCo = ROL(Ame, 45); + Asi ^= Di; + BCu = ROL(Asi, 61); + Ega = BCa ^((~BCe)& BCi ); + Ege = BCe ^((~BCi)& BCo ); + Egi = BCi ^((~BCo)& BCu ); + Ego = BCo ^((~BCu)& BCa ); + Egu = BCu ^((~BCa)& BCe ); + + Abe ^= De; + BCa = ROL(Abe, 1); + Agi ^= Di; + BCe = ROL(Agi, 6); + Ako ^= Do; + BCi = ROL(Ako, 25); + Amu ^= Du; + BCo = ROL(Amu, 8); + Asa ^= Da; + BCu = ROL(Asa, 18); + Eka = BCa ^((~BCe)& BCi ); + Eke = BCe ^((~BCi)& BCo ); + Eki = BCi ^((~BCo)& BCu ); + Eko = BCo ^((~BCu)& BCa ); + Eku = BCu ^((~BCa)& BCe ); + + Abu ^= Du; + BCa = ROL(Abu, 27); + Aga ^= Da; + BCe = ROL(Aga, 36); + Ake ^= De; + BCi = ROL(Ake, 10); + Ami ^= Di; + BCo = ROL(Ami, 15); + Aso ^= Do; + BCu = ROL(Aso, 56); + Ema = BCa ^((~BCe)& BCi ); + Eme = BCe ^((~BCi)& BCo ); + Emi = BCi ^((~BCo)& BCu ); + Emo = BCo ^((~BCu)& BCa ); + Emu = BCu ^((~BCa)& BCe ); + + Abi ^= Di; + BCa = ROL(Abi, 62); + Ago ^= Do; + BCe = ROL(Ago, 55); + Aku ^= Du; + BCi = ROL(Aku, 39); + Ama ^= Da; + BCo = ROL(Ama, 41); + Ase ^= De; + BCu = ROL(Ase, 2); + Esa = BCa ^((~BCe)& BCi ); + Ese = BCe ^((~BCi)& BCo ); + Esi = BCi ^((~BCo)& BCu ); + Eso = BCo ^((~BCu)& BCa ); + Esu = BCu ^((~BCa)& BCe ); + + // prepareTheta + BCa = Eba^Ega^Eka^Ema^Esa; + BCe = Ebe^Ege^Eke^Eme^Ese; + BCi = Ebi^Egi^Eki^Emi^Esi; + BCo = Ebo^Ego^Eko^Emo^Eso; + BCu = Ebu^Egu^Eku^Emu^Esu; + + //thetaRhoPiChiIotaPrepareTheta(round+1, E, A) + Da = BCu^ROL(BCe, 1); + De = BCa^ROL(BCi, 1); + Di = BCe^ROL(BCo, 1); + Do = BCi^ROL(BCu, 1); + Du = BCo^ROL(BCa, 1); + + Eba ^= Da; + BCa = Eba; + Ege ^= De; + BCe = ROL(Ege, 44); + Eki ^= Di; + BCi = ROL(Eki, 43); + Emo ^= Do; + BCo = ROL(Emo, 21); + Esu ^= Du; + BCu = ROL(Esu, 14); + Aba = BCa ^((~BCe)& BCi ); + Aba ^= (uint64_t)KeccakF_RoundConstants[round+1]; + Abe = BCe ^((~BCi)& BCo ); + Abi = BCi ^((~BCo)& BCu ); + Abo = BCo ^((~BCu)& BCa ); + Abu = BCu ^((~BCa)& BCe ); + + Ebo ^= Do; + BCa = ROL(Ebo, 28); + Egu ^= Du; + BCe = ROL(Egu, 20); + Eka ^= Da; + BCi = ROL(Eka, 3); + Eme ^= De; + BCo = ROL(Eme, 45); + Esi ^= Di; + BCu = ROL(Esi, 61); + Aga = BCa ^((~BCe)& BCi ); + Age = BCe ^((~BCi)& BCo ); + Agi = BCi ^((~BCo)& BCu ); + Ago = BCo ^((~BCu)& BCa ); + Agu = BCu ^((~BCa)& BCe ); + + Ebe ^= De; + BCa = ROL(Ebe, 1); + Egi ^= Di; + BCe = ROL(Egi, 6); + Eko ^= Do; + BCi = ROL(Eko, 25); + Emu ^= Du; + BCo = ROL(Emu, 8); + Esa ^= Da; + BCu = ROL(Esa, 18); + Aka = BCa ^((~BCe)& BCi ); + Ake = BCe ^((~BCi)& BCo ); + Aki = BCi ^((~BCo)& BCu ); + Ako = BCo ^((~BCu)& BCa ); + Aku = BCu ^((~BCa)& BCe ); + + Ebu ^= Du; + BCa = ROL(Ebu, 27); + Ega ^= Da; + BCe = ROL(Ega, 36); + Eke ^= De; + BCi = ROL(Eke, 10); + Emi ^= Di; + BCo = ROL(Emi, 15); + Eso ^= Do; + BCu = ROL(Eso, 56); + Ama = BCa ^((~BCe)& BCi ); + Ame = BCe ^((~BCi)& BCo ); + Ami = BCi ^((~BCo)& BCu ); + Amo = BCo ^((~BCu)& BCa ); + Amu = BCu ^((~BCa)& BCe ); + + Ebi ^= Di; + BCa = ROL(Ebi, 62); + Ego ^= Do; + BCe = ROL(Ego, 55); + Eku ^= Du; + BCi = ROL(Eku, 39); + Ema ^= Da; + BCo = ROL(Ema, 41); + Ese ^= De; + BCu = ROL(Ese, 2); + Asa = BCa ^((~BCe)& BCi ); + Ase = BCe ^((~BCi)& BCo ); + Asi = BCi ^((~BCo)& BCu ); + Aso = BCo ^((~BCu)& BCa ); + Asu = BCu ^((~BCa)& BCe ); + } + + //copyToState(state, A) + state[ 0] = Aba; + state[ 1] = Abe; + state[ 2] = Abi; + state[ 3] = Abo; + state[ 4] = Abu; + state[ 5] = Aga; + state[ 6] = Age; + state[ 7] = Agi; + state[ 8] = Ago; + state[ 9] = Agu; + state[10] = Aka; + state[11] = Ake; + state[12] = Aki; + state[13] = Ako; + state[14] = Aku; + state[15] = Ama; + state[16] = Ame; + state[17] = Ami; + state[18] = Amo; + state[19] = Amu; + state[20] = Asa; + state[21] = Ase; + state[22] = Asi; + state[23] = Aso; + state[24] = Asu; +} + +/************************************************* +* Name: keccak_absorb +* +* Description: Absorb step of Keccak; +* non-incremental, starts by zeroeing the state. +* +* Arguments: - uint64_t *s: pointer to (uninitialized) output Keccak state +* - unsigned int r: rate in bytes (e.g., 168 for SHAKE128) +* - const uint8_t *m: pointer to input to be absorbed into s +* - int32_t mlen: length of input in bytes +* - uint8_t p: domain-separation byte for different +* Keccak-derived functions +**************************************************/ +static void keccak_absorb(uint64_t *s, + uint32_t r, + const uint8_t *m, + int32_t mlen, + uint8_t p) +{ + uint32_t i; + uint8_t t[200]; + DBENCH_START(); + + /* Zero state */ + for(i = 0; i < 25; ++i) + s[i] = 0; + + while(mlen >= r) { + for(i = 0; i < r/8; ++i) + s[i] ^= load64(m + 8*i); + + KeccakF1600_StatePermute(s); + mlen -= r; + m += r; + } + + for(i = 0; i < r; ++i) + t[i] = 0; + for(i = 0; i < mlen; ++i) + t[i] = m[i]; + t[i] = p; + t[r-1] |= 128; + for(i = 0; i < r/8; ++i) + s[i] ^= load64(t + 8*i); + + DBENCH_STOP(*tshake); +} + +/************************************************* +* Name: keccak_squeezeblocks +* +* Description: Squeeze step of Keccak. Squeezes full blocks of r bytes each. +* Modifies the state. Can be called multiple times to keep +* squeezing, i.e., is incremental. +* +* Arguments: - uint8_t *h: pointer to output blocks +* - int32_t int nblocks: number of blocks to be +* squeezed (written to h) +* - uint64_t *s: pointer to input/output Keccak state +* - uint32_t r: rate in bytes (e.g., 168 for SHAKE128) +**************************************************/ +static void keccak_squeezeblocks(uint8_t *h, + int32_t nblocks, + uint64_t *s, + uint32_t r) +{ + uint32_t i; + DBENCH_START(); + + while(nblocks > 0) { + KeccakF1600_StatePermute(s); + for(i=0; i < (r >> 3); i++) { + store64(h + 8*i, s[i]); + } + h += r; + --nblocks; + } + + DBENCH_STOP(*tshake); +} + +/************************************************* +* Name: shake128_absorb +* +* Description: Absorb step of the SHAKE128 XOF. +* non-incremental, starts by zeroeing the state. +* +* Arguments: - uint64_t *s: pointer to (uninitialized) output Keccak state +* - const uint8_t *input: pointer to input to be absorbed +* into s +* - int32_t inlen: length of input in bytes +**************************************************/ +void shake128_absorb(uint64_t *s, + const uint8_t *input, + int32_t inlen) +{ + keccak_absorb(s, SHAKE128_RATE, input, inlen, 0x1F); +} + +/************************************************* +* Name: shake128_squeezeblocks +* +* Description: Squeeze step of SHAKE128 XOF. Squeezes full blocks of +* SHAKE128_RATE bytes each. Modifies the state. Can be called +* multiple times to keep squeezing, i.e., is incremental. +* +* Arguments: - uint8_t *output: pointer to output blocks +* - int32_t nblocks: number of blocks to be squeezed +* (written to output) +* - uint64_t *s: pointer to input/output Keccak state +**************************************************/ +void shake128_squeezeblocks(uint8_t *output, + int32_t nblocks, + uint64_t *s) +{ + keccak_squeezeblocks(output, nblocks, s, SHAKE128_RATE); +} + +/************************************************* +* Name: shake256_absorb +* +* Description: Absorb step of the SHAKE256 XOF. +* non-incremental, starts by zeroeing the state. +* +* Arguments: - uint64_t *s: pointer to (uninitialized) output Keccak state +* - const uint8_t *input: pointer to input to be absorbed +* into s +* - int32_t inlen: length of input in bytes +**************************************************/ +void shake256_absorb(uint64_t *s, + const uint8_t *input, + int32_t inlen) +{ + keccak_absorb(s, SHAKE256_RATE, input, inlen, 0x1F); +} + +/************************************************* +* Name: shake256_squeezeblocks +* +* Description: Squeeze step of SHAKE256 XOF. Squeezes full blocks of +* SHAKE256_RATE bytes each. Modifies the state. Can be called +* multiple times to keep squeezing, i.e., is incremental. +* +* Arguments: - uint8_t *output: pointer to output blocks +* - int32_t nblocks: number of blocks to be squeezed +* (written to output) +* - uint64_t *s: pointer to input/output Keccak state +**************************************************/ +void shake256_squeezeblocks(uint8_t *output, + int32_t nblocks, + uint64_t *s) +{ + keccak_squeezeblocks(output, nblocks, s, SHAKE256_RATE); +} + +/************************************************* +* Name: shake128 +* +* Description: SHAKE128 XOF with non-incremental API +* +* Arguments: - uint8_t *output: pointer to output +* - int32_t outlen: requested output length in bytes +* - const uint8_t *input: pointer to input +* - int32_t inlen: length of input in bytes +**************************************************/ +void shake128(uint8_t *output, + int32_t outlen, + const uint8_t *input, + int32_t inlen) +{ + uint32_t i,nblocks = outlen/SHAKE128_RATE; + uint8_t t[SHAKE128_RATE]; + uint64_t s[25]; + + shake128_absorb(s, input, inlen); + shake128_squeezeblocks(output, nblocks, s); + + output += nblocks*SHAKE128_RATE; + outlen -= nblocks*SHAKE128_RATE; + + if(outlen) { + shake128_squeezeblocks(t, 1, s); + for(i = 0; i < outlen; ++i) + output[i] = t[i]; + } +} + +/************************************************* +* Name: shake256 +* +* Description: SHAKE256 XOF with non-incremental API +* +* Arguments: - uint8_t *output: pointer to output +* - int32_t outlen: requested output length in bytes +* - const uint8_t *input: pointer to input +* - int32_t inlen: length of input in bytes +**************************************************/ +void shake256(uint8_t *output, + int32_t outlen, + const uint8_t *input, + int32_t inlen) +{ + uint32_t i,nblocks = outlen/SHAKE256_RATE; + uint8_t t[SHAKE256_RATE]; + uint64_t s[25]; + + shake256_absorb(s, input, inlen); + shake256_squeezeblocks(output, nblocks, s); + + output += nblocks*SHAKE256_RATE; + outlen -= nblocks*SHAKE256_RATE; + + if(outlen) { + shake256_squeezeblocks(t, 1, s); + for(i = 0; i < outlen; ++i) + output[i] = t[i]; + } +} +//#include "params.h" +//#include "reduce.h" +//#include "ntt.h" +//#include "poly.h" + +/* Roots of unity in order needed by forward ntt */ +static const uint32_t zetas[N] = {0, 25847, 5771523, 7861508, 237124, 7602457, 7504169, 466468, 1826347, 2353451, 8021166, 6288512, 3119733, 5495562, 3111497, 2680103, 2725464, 1024112, 7300517, 3585928, 7830929, 7260833, 2619752, 6271868, 6262231, 4520680, 6980856, 5102745, 1757237, 8360995, 4010497, 280005, 2706023, 95776, 3077325, 3530437, 6718724, 4788269, 5842901, 3915439, 4519302, 5336701, 3574422, 5512770, 3539968, 8079950, 2348700, 7841118, 6681150, 6736599, 3505694, 4558682, 3507263, 6239768, 6779997, 3699596, 811944, 531354, 954230, 3881043, 3900724, 5823537, 2071892, 5582638, 4450022, 6851714, 4702672, 5339162, 6927966, 3475950, 2176455, 6795196, 7122806, 1939314, 4296819, 7380215, 5190273, 5223087, 4747489, 126922, 3412210, 7396998, 2147896, 2715295, 5412772, 4686924, 7969390, 5903370, 7709315, 7151892, 8357436, 7072248, 7998430, 1349076, 1852771, 6949987, 5037034, 264944, 508951, 3097992, 44288, 7280319, 904516, 3958618, 4656075, 8371839, 1653064, 5130689, 2389356, 8169440, 759969, 7063561, 189548, 4827145, 3159746, 6529015, 5971092, 8202977, 1315589, 1341330, 1285669, 6795489, 7567685, 6940675, 5361315, 4499357, 4751448, 3839961, 2091667, 3407706, 2316500, 3817976, 5037939, 2244091, 5933984, 4817955, 266997, 2434439, 7144689, 3513181, 4860065, 4621053, 7183191, 5187039, 900702, 1859098, 909542, 819034, 495491, 6767243, 8337157, 7857917, 7725090, 5257975, 2031748, 3207046, 4823422, 7855319, 7611795, 4784579, 342297, 286988, 5942594, 4108315, 3437287, 5038140, 1735879, 203044, 2842341, 2691481, 5790267, 1265009, 4055324, 1247620, 2486353, 1595974, 4613401, 1250494, 2635921, 4832145, 5386378, 1869119, 1903435, 7329447, 7047359, 1237275, 5062207, 6950192, 7929317, 1312455, 3306115, 6417775, 7100756, 1917081, 5834105, 7005614, 1500165, 777191, 2235880, 3406031, 7838005, 5548557, 6709241, 6533464, 5796124, 4656147, 594136, 4603424, 6366809, 2432395, 2454455, 8215696, 1957272, 3369112, 185531, 7173032, 5196991, 162844, 1616392, 3014001, 810149, 1652634, 4686184, 6581310, 5341501, 3523897, 3866901, 269760, 2213111, 7404533, 1717735, 472078, 7953734, 1723600, 6577327, 1910376, 6712985, 7276084, 8119771, 4546524, 5441381, 6144432, 7959518, 6094090, 183443, 7403526, 1612842, 4834730, 7826001, 3919660, 8332111, 7018208, 3937738, 1400424, 7534263, 1976782}; + +/* Roots of unity in order needed by inverse ntt */ +static const uint32_t zetas_inv[N] = {6403635, 846154, 6979993, 4442679, 1362209, 48306, 4460757, 554416, 3545687, 6767575, 976891, 8196974, 2286327, 420899, 2235985, 2939036, 3833893, 260646, 1104333, 1667432, 6470041, 1803090, 6656817, 426683, 7908339, 6662682, 975884, 6167306, 8110657, 4513516, 4856520, 3038916, 1799107, 3694233, 6727783, 7570268, 5366416, 6764025, 8217573, 3183426, 1207385, 8194886, 5011305, 6423145, 164721, 5925962, 5948022, 2013608, 3776993, 7786281, 3724270, 2584293, 1846953, 1671176, 2831860, 542412, 4974386, 6144537, 7603226, 6880252, 1374803, 2546312, 6463336, 1279661, 1962642, 5074302, 7067962, 451100, 1430225, 3318210, 7143142, 1333058, 1050970, 6476982, 6511298, 2994039, 3548272, 5744496, 7129923, 3767016, 6784443, 5894064, 7132797, 4325093, 7115408, 2590150, 5688936, 5538076, 8177373, 6644538, 3342277, 4943130, 4272102, 2437823, 8093429, 8038120, 3595838, 768622, 525098, 3556995, 5173371, 6348669, 3122442, 655327, 522500, 43260, 1613174, 7884926, 7561383, 7470875, 6521319, 7479715, 3193378, 1197226, 3759364, 3520352, 4867236, 1235728, 5945978, 8113420, 3562462, 2446433, 6136326, 3342478, 4562441, 6063917, 4972711, 6288750, 4540456, 3628969, 3881060, 3019102, 1439742, 812732, 1584928, 7094748, 7039087, 7064828, 177440, 2409325, 1851402, 5220671, 3553272, 8190869, 1316856, 7620448, 210977, 5991061, 3249728, 6727353, 8578, 3724342, 4421799, 7475901, 1100098, 8336129, 5282425, 7871466, 8115473, 3343383, 1430430, 6527646, 7031341, 381987, 1308169, 22981, 1228525, 671102, 2477047, 411027, 3693493, 2967645, 5665122, 6232521, 983419, 4968207, 8253495, 3632928, 3157330, 3190144, 1000202, 4083598, 6441103, 1257611, 1585221, 6203962, 4904467, 1452451, 3041255, 3677745, 1528703, 3930395, 2797779, 6308525, 2556880, 4479693, 4499374, 7426187, 7849063, 7568473, 4680821, 1600420, 2140649, 4873154, 3821735, 4874723, 1643818, 1699267, 539299, 6031717, 300467, 4840449, 2867647, 4805995, 3043716, 3861115, 4464978, 2537516, 3592148, 1661693, 4849980, 5303092, 8284641, 5674394, 8100412, 4369920, 19422, 6623180, 3277672, 1399561, 3859737, 2118186, 2108549, 5760665, 1119584, 549488, 4794489, 1079900, 7356305, 5654953, 5700314, 5268920, 2884855, 5260684, 2091905, 359251, 6026966, 6554070, 7913949, 876248, 777960, 8143293, 518909, 2608894, 8354570}; + +/************************************************* +* Name: ntt +* +* Description: Forward NTT, in-place. No modular reduction is performed after +* additions or subtractions. Hence output coefficients can be up +* to 16*Q larger than the coefficients of the input polynomial. +* Output vector is in bitreversed order. +* +* Arguments: - uint32_t p[N]: input/output coefficient array +**************************************************/ +void ntt(uint32_t p[N]) { + uint32_t len, start, j, k; + uint32_t zeta, t; + + k = 1; + for(len = 128; len > 0; len >>= 1) { + for(start = 0; start < N; start = j + len) { + zeta = zetas[k++]; + for(j = start; j < start + len; ++j) { + t = montgomery_reduce((uint64_t)zeta * p[j + len]); + p[j + len] = p[j] + 2*Q - t; + p[j] = p[j] + t; + } + } + } +} + +/************************************************* +* Name: invntt_frominvmont +* +* Description: Inverse NTT and multiplication by Montgomery factor 2^32. +* In-place. No modular reductions after additions or +* subtractions. Input coefficient need to be smaller than 2*Q. +* Output coefficient are smaller than 2*Q. +* +* Arguments: - uint32_t p[N]: input/output coefficient array +**************************************************/ +void invntt_frominvmont(uint32_t p[N]) { + uint32_t start, len, j, k; + uint32_t t, zeta; + const uint32_t f = (((uint64_t)MONT*MONT % Q) * (Q-1) % Q) * ((Q-1) >> 8) % Q; + + k = 0; + for(len = 1; len < N; len <<= 1) { + for(start = 0; start < N; start = j + len) { + zeta = zetas_inv[k++]; + for(j = start; j < start + len; ++j) { + t = p[j]; + p[j] = t + p[j + len]; + p[j + len] = t + 256*Q - p[j + len]; + p[j + len] = montgomery_reduce((uint64_t)zeta * p[j + len]); + } + } + } + + for(j = 0; j < N; ++j) { + p[j] = montgomery_reduce((uint64_t)f * p[j]); + } +} +//#include "params.h" +//#include "poly.h" +//#include "polyvec.h" +//#include "packing.h" + +/************************************************* +* Name: pack_pk +* +* Description: Bit-pack public key pk = (rho, t1). +* +* Arguments: - uint8_t pk[]: output byte array +* - const uint8_t rho[]: byte array containing rho +* - const polyveck *t1: pointer to vector t1 +**************************************************/ +void pack_pk(uint8_t pk[CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], + const polyveck *t1) +{ + uint32_t i; + + for(i = 0; i < SEEDBYTES; ++i) + pk[i] = rho[i]; + pk += SEEDBYTES; + + for(i = 0; i < K; ++i) + polyt1_pack(pk + i*POLT1_SIZE_PACKED, t1->vec+i); +} + +/************************************************* +* Name: unpack_pk +* +* Description: Unpack public key pk = (rho, t1). +* +* Arguments: - const uint8_t rho[]: output byte array for rho +* - const polyveck *t1: pointer to output vector t1 +* - uint8_t pk[]: byte array containing bit-packed pk +**************************************************/ +void unpack_pk(uint8_t rho[SEEDBYTES], + polyveck *t1, + const uint8_t pk[CRYPTO_PUBLICKEYBYTES]) +{ + uint32_t i; + + for(i = 0; i < SEEDBYTES; ++i) + rho[i] = pk[i]; + pk += SEEDBYTES; + + for(i = 0; i < K; ++i) + polyt1_unpack(t1->vec+i, pk + i*POLT1_SIZE_PACKED); +} + +/************************************************* +* Name: pack_sk +* +* Description: Bit-pack secret key sk = (rho, key, tr, s1, s2, t0). +* +* Arguments: - uint8_t sk[]: output byte array +* - const uint8_t rho[]: byte array containing rho +* - const uint8_t key[]: byte array containing key +* - const uint8_t tr[]: byte array containing tr +* - const polyvecl *s1: pointer to vector s1 +* - const polyveck *s2: pointer to vector s2 +* - const polyveck *t0: pointer to vector t0 +**************************************************/ +void pack_sk(uint8_t sk[CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], + const polyvecl *s1, + const polyveck *s2, + const polyveck *t0) +{ + uint32_t i; + + for(i = 0; i < SEEDBYTES; ++i) + sk[i] = rho[i]; + sk += SEEDBYTES; + + for(i = 0; i < SEEDBYTES; ++i) + sk[i] = key[i]; + sk += SEEDBYTES; + + for(i = 0; i < CRHBYTES; ++i) + sk[i] = tr[i]; + sk += CRHBYTES; + + for(i = 0; i < L; ++i) + polyeta_pack(sk + i*POLETA_SIZE_PACKED, s1->vec+i); + sk += L*POLETA_SIZE_PACKED; + + for(i = 0; i < K; ++i) + polyeta_pack(sk + i*POLETA_SIZE_PACKED, s2->vec+i); + sk += K*POLETA_SIZE_PACKED; + + for(i = 0; i < K; ++i) + polyt0_pack(sk + i*POLT0_SIZE_PACKED, t0->vec+i); +} + +/************************************************* +* Name: unpack_sk +* +* Description: Unpack secret key sk = (rho, key, tr, s1, s2, t0). +* +* Arguments: - const uint8_t rho[]: output byte array for rho +* - const uint8_t key[]: output byte array for key +* - const uint8_t tr[]: output byte array for tr +* - const polyvecl *s1: pointer to output vector s1 +* - const polyveck *s2: pointer to output vector s2 +* - const polyveck *r0: pointer to output vector t0 +* - uint8_t sk[]: byte array containing bit-packed sk +**************************************************/ +void unpack_sk(uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], + polyvecl *s1, + polyveck *s2, + polyveck *t0, + const uint8_t sk[CRYPTO_SECRETKEYBYTES]) +{ + uint32_t i; + + for(i = 0; i < SEEDBYTES; ++i) + rho[i] = sk[i]; + sk += SEEDBYTES; + + for(i = 0; i < SEEDBYTES; ++i) + key[i] = sk[i]; + sk += SEEDBYTES; + + for(i = 0; i < CRHBYTES; ++i) + tr[i] = sk[i]; + sk += CRHBYTES; + + for(i=0; i < L; ++i) + polyeta_unpack(s1->vec+i, sk + i*POLETA_SIZE_PACKED); + sk += L*POLETA_SIZE_PACKED; + + for(i=0; i < K; ++i) + polyeta_unpack(s2->vec+i, sk + i*POLETA_SIZE_PACKED); + sk += K*POLETA_SIZE_PACKED; + + for(i=0; i < K; ++i) + polyt0_unpack(t0->vec+i, sk + i*POLT0_SIZE_PACKED); +} + +/************************************************* +* Name: pack_sig +* +* Description: Bit-pack signature sig = (z, h, c). +* +* Arguments: - uint8_t sig[]: output byte array +* - const polyvecl *z: pointer to vector z +* - const polyveck *h: pointer to hint vector h +* - const poly *c: pointer to challenge polynomial +**************************************************/ +void pack_sig(uint8_t sig[CRYPTO_BYTES], + const polyvecl *z, + const polyveck *h, + const poly *c) +{ + uint32_t i, j, k; + uint64_t signs, mask; + + for(i = 0; i < L; ++i) + polyz_pack(sig + i*POLZ_SIZE_PACKED, z->vec+i); + sig += L*POLZ_SIZE_PACKED; + + /* Encode h */ + k = 0; + for(i = 0; i < K; ++i) { + for(j = 0; j < N; ++j) + if(h->vec[i].coeffs[j] != 0) + sig[k++] = j; + + sig[OMEGA + i] = k; + } + while(k < OMEGA) sig[k++] = 0; + sig += OMEGA + K; + + /* Encode c */ + signs = 0; + mask = 1; + for(i = 0; i < N/8; ++i) { + sig[i] = 0; + for(j = 0; j < 8; ++j) { + if(c->coeffs[8*i+j] != 0) { + sig[i] |= (1U << j); + if(c->coeffs[8*i+j] == (Q - 1)) signs |= mask; + mask <<= 1; + } + } + } + sig += N/8; + for(i = 0; i < 8; ++i) + sig[i] = signs >> 8*i; +} + +/************************************************* +* Name: unpack_sig +* +* Description: Unpack signature sig = (z, h, c). +* +* Arguments: - polyvecl *z: pointer to output vector z +* - polyveck *h: pointer to output hint vector h +* - poly *c: pointer to output challenge polynomial +* - const uint8_t sig[]: byte array containing +* bit-packed signature +* +* Returns 1 in case of malformed signature; otherwise 0. +**************************************************/ +int unpack_sig(polyvecl *z, + polyveck *h, + poly *c, + const uint8_t sig[CRYPTO_BYTES]) +{ + uint32_t i, j, k; + uint64_t signs, mask; + + for(i = 0; i < L; ++i) + polyz_unpack(z->vec+i, sig + i*POLZ_SIZE_PACKED); + sig += L*POLZ_SIZE_PACKED; + + /* Decode h */ + k = 0; + for(i = 0; i < K; ++i) { + for(j = 0; j < N; ++j) + h->vec[i].coeffs[j] = 0; + + if(sig[OMEGA + i] < k || sig[OMEGA + i] > OMEGA) + return 1; + + for(j = k; j < sig[OMEGA + i]; ++j) { + /* Coefficients are ordered for strong unforgeability */ + if(j > k && sig[j] <= sig[j-1]) return 1; + h->vec[i].coeffs[sig[j]] = 1; + } + + k = sig[OMEGA + i]; + } + + /* Extra indices are zero for strong unforgeability */ + for(j = k; j < OMEGA; ++j) + if(sig[j]) + return 1; + + sig += OMEGA + K; + + /* Decode c */ + for(i = 0; i < N; ++i) + c->coeffs[i] = 0; + + signs = 0; + for(i = 0; i < 8; ++i) + signs |= (uint64_t)sig[N/8+i] << 8*i; + + /* Extra sign bits are zero for strong unforgeability */ + if(signs >> 60) + return 1; + + mask = 1; + for(i = 0; i < N/8; ++i) { + for(j = 0; j < 8; ++j) { + if((sig[i] >> j) & 0x01) { + c->coeffs[8*i+j] = (signs & mask) ? Q - 1 : 1; + mask <<= 1; + } + } + } + + return 0; +} +//#include +//#include "test/cpucycles.h" +//#include "fips202.h" +//#include "params.h" +//#include "reduce.h" +//#include "rounding.h" +//#include "ntt.h" +//#include "poly.h" + +#ifdef DBENCH +extern const uint64_t timing_overhead; +extern uint64_t *tred, *tadd, *tmul, *tround, *tsample, *tpack; +#endif + +/************************************************* +* Name: poly_reduce +* +* Description: Reduce all coefficients of input polynomial to representative +* in [0,2*Q[. +* +* Arguments: - poly *a: pointer to input/output polynomial +**************************************************/ +void poly_reduce(poly *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a->coeffs[i] = reduce32(a->coeffs[i]); + + DBENCH_STOP(*tred); +} + +/************************************************* +* Name: poly_csubq +* +* Description: For all coefficients of input polynomial subtract Q if +* coefficient is bigger than Q. +* +* Arguments: - poly *a: pointer to input/output polynomial +**************************************************/ +void poly_csubq(poly *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a->coeffs[i] = csubq(a->coeffs[i]); + + DBENCH_STOP(*tred); +} + +/************************************************* +* Name: poly_freeze +* +* Description: Reduce all coefficients of the polynomial to standard +* representatives. +* +* Arguments: - poly *a: pointer to input/output polynomial +**************************************************/ +void poly_freeze(poly *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a->coeffs[i] = freeze(a->coeffs[i]); + + DBENCH_STOP(*tred); +} + +/************************************************* +* Name: poly_add +* +* Description: Add polynomials. No modular reduction is performed. +* +* Arguments: - poly *c: pointer to output polynomial +* - const poly *a: pointer to first summand +* - const poly *b: pointer to second summand +**************************************************/ +void poly_add(poly *c, const poly *a, const poly *b) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + c->coeffs[i] = a->coeffs[i] + b->coeffs[i]; + + DBENCH_STOP(*tadd); +} + +/************************************************* +* Name: poly_sub +* +* Description: Subtract polynomials. Assumes coefficients of second input +* polynomial to be less than 2*Q. No modular reduction is +* performed. +* +* Arguments: - poly *c: pointer to output polynomial +* - const poly *a: pointer to first input polynomial +* - const poly *b: pointer to second input polynomial to be +* subtraced from first input polynomial +**************************************************/ +void poly_sub(poly *c, const poly *a, const poly *b) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + c->coeffs[i] = a->coeffs[i] + 2*Q - b->coeffs[i]; + + DBENCH_STOP(*tadd); +} + +/************************************************* +* Name: poly_neg +* +* Description: Negate polynomial. Assumes input coefficients to be standard +* representatives. +* +* Arguments: - poly *a: pointer to input/output polynomial +**************************************************/ +void poly_neg(poly *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a->coeffs[i] = Q - a->coeffs[i]; + + DBENCH_STOP(*tadd); +} + +/************************************************* +* Name: poly_shiftl +* +* Description: Multiply polynomial by 2^k without modular reduction. Assumes +* input coefficients to be less than 2^{32-k}. +* +* Arguments: - poly *a: pointer to input/output polynomial +* - uint32_t k: exponent +**************************************************/ +void poly_shiftl(poly *a, uint32_t k) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a->coeffs[i] <<= k; + + DBENCH_STOP(*tmul); +} + +/************************************************* +* Name: poly_ntt +* +* Description: Forward NTT. Output coefficients can be up to 16*Q larger than +* input coefficients. +* +* Arguments: - poly *a: pointer to input/output polynomial +**************************************************/ +void poly_ntt(poly *a) { + DBENCH_START(); + + ntt(a->coeffs); + + DBENCH_STOP(*tmul); +} + +/************************************************* +* Name: poly_invntt_montgomery +* +* Description: Inverse NTT and multiplication with 2^{32}. Input coefficients +* need to be less than 2*Q. Output coefficients are less than 2*Q. +* +* Arguments: - poly *a: pointer to input/output polynomial +**************************************************/ +void poly_invntt_montgomery(poly *a) { + DBENCH_START(); + + invntt_frominvmont(a->coeffs); + + DBENCH_STOP(*tmul); +} + +/************************************************* +* Name: poly_pointwise_invmontgomery +* +* Description: Pointwise multiplication of polynomials in NTT domain +* representation and multiplication of resulting polynomial +* with 2^{-32}. Output coefficients are less than 2*Q if input +* coefficient are less than 22*Q. +* +* Arguments: - poly *c: pointer to output polynomial +* - const poly *a: pointer to first input polynomial +* - const poly *b: pointer to second input polynomial +**************************************************/ +void poly_pointwise_invmontgomery(poly *c, const poly *a, const poly *b) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + c->coeffs[i] = montgomery_reduce((uint64_t)a->coeffs[i] * b->coeffs[i]); + + DBENCH_STOP(*tmul); +} + +/************************************************* +* Name: poly_power2round +* +* Description: For all coefficients c of the input polynomial, +* compute c0, c1 such that c mod Q = c1*2^D + c0 +* with -2^{D-1} < c0 <= 2^{D-1}. Assumes coefficients to be +* standard representatives. +* +* Arguments: - poly *a1: pointer to output polynomial with coefficients c1 +* - poly *a0: pointer to output polynomial with coefficients Q + a0 +* - const poly *v: pointer to input polynomial +**************************************************/ +void poly_power2round(poly *a1, poly *a0, const poly *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a1->coeffs[i] = power2round(a->coeffs[i], a0->coeffs+i); + + DBENCH_STOP(*tround); +} + +/************************************************* +* Name: poly_decompose +* +* Description: For all coefficients c of the input polynomial, +* compute high and low bits c0, c1 such c mod Q = c1*ALPHA + c0 +* with -ALPHA/2 < c0 <= ALPHA/2 except c1 = (Q-1)/ALPHA where we +* set c1 = 0 and -ALPHA/2 <= c0 = c mod Q - Q < 0. +* Assumes coefficients to be standard representatives. +* +* Arguments: - poly *a1: pointer to output polynomial with coefficients c1 +* - poly *a0: pointer to output polynomial with coefficients Q + a0 +* - const poly *c: pointer to input polynomial +**************************************************/ +void poly_decompose(poly *a1, poly *a0, const poly *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a1->coeffs[i] = decompose(a->coeffs[i], a0->coeffs+i); + + DBENCH_STOP(*tround); +} + +/************************************************* +* Name: poly_make_hint +* +* Description: Compute hint polynomial. The coefficients of which indicate +* whether the high bits of the corresponding coefficients +* of the first input polynomial and of the sum of the input +* polynomials differ. +* +* Arguments: - poly *h: pointer to output hint polynomial +* - const poly *a: pointer to first input polynomial +* - const poly *b: pointer to second input polynomial +* +* Returns number of 1 bits. +**************************************************/ +uint32_t poly_make_hint(poly *h, const poly *a, const poly *b) { + uint32_t i, s = 0; + DBENCH_START(); + + for(i = 0; i < N; ++i) { + h->coeffs[i] = make_hint(a->coeffs[i], b->coeffs[i]); + s += h->coeffs[i]; + } + + DBENCH_STOP(*tround); + return s; +} + +/************************************************* +* Name: poly_use_hint +* +* Description: Use hint polynomial to correct the high bits of a polynomial. +* +* Arguments: - poly *a: pointer to output polynomial with corrected high bits +* - const poly *b: pointer to input polynomial +* - const poly *h: pointer to input hint polynomial +**************************************************/ +void poly_use_hint(poly *a, const poly *b, const poly *h) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N; ++i) + a->coeffs[i] = use_hint(b->coeffs[i], h->coeffs[i]); + + DBENCH_STOP(*tround); +} + +/************************************************* +* Name: poly_chknorm +* +* Description: Check infinity norm of polynomial against given bound. +* Assumes input coefficients to be standard representatives. +* +* Arguments: - const poly *a: pointer to polynomial +* - uint32_t B: norm bound +* +* Returns 0 if norm is strictly smaller than B and 1 otherwise. +**************************************************/ +int poly_chknorm(const poly *a, uint32_t B) { + uint32_t i; + int32_t t; + DBENCH_START(); + + /* It is ok to leak which coefficient violates the bound since + the probability for each coefficient is independent of secret + data but we must not leak the sign of the centralized representative. */ + for(i = 0; i < N; ++i) { + /* Absolute value of centralized representative */ + t = (Q-1)/2 - a->coeffs[i]; + t ^= (t >> 31); + t = (Q-1)/2 - t; + + if((uint32_t)t >= B) { + DBENCH_STOP(*tsample); + return 1; + } + } + + DBENCH_STOP(*tsample); + return 0; +} + +/************************************************* +* Name: poly_uniform +* +* Description: Sample uniformly random polynomial using stream of random bytes. +* Assumes that enough random bytes are given (e.g. +* 5*SHAKE128_RATE bytes). +* +* Arguments: - poly *a: pointer to output polynomial +* - const uint8_t *buf: array of random bytes +**************************************************/ +void poly_uniform(poly *a, const uint8_t *buf) { + uint32_t ctr, pos; + uint32_t t; + DBENCH_START(); + + ctr = pos = 0; + while(ctr < N) { + t = buf[pos++]; + t |= (uint32_t)buf[pos++] << 8; + t |= (uint32_t)buf[pos++] << 16; + t &= 0x7FFFFF; + + if(t < Q) + a->coeffs[ctr++] = t; + } + + DBENCH_STOP(*tsample); +} + +/************************************************* +* Name: rej_eta +* +* Description: Sample uniformly random coefficients in [-ETA, ETA] by +* performing rejection sampling using array of random bytes. +* +* Arguments: - uint32_t *a: pointer to output array (allocated) +* - uint32_t len: number of coefficients to be sampled +* - const uint8_t *buf: array of random bytes +* - uint32_t buflen: length of array of random bytes +* +* Returns number of sampled coefficients. Can be smaller than len if not enough +* random bytes were given. +**************************************************/ +static uint32_t rej_eta(uint32_t *a, + uint32_t len, + const uint8_t *buf, + uint32_t buflen) +{ +#if ETA > 7 +#error "rej_eta() assumes ETA <= 7" +#endif + uint32_t ctr, pos; + uint8_t t0, t1; + DBENCH_START(); + + ctr = pos = 0; + while(ctr < len && pos < buflen) { +#if ETA <= 3 + t0 = buf[pos] & 0x07; + t1 = buf[pos++] >> 5; +#else + t0 = buf[pos] & 0x0F; + t1 = buf[pos++] >> 4; +#endif + + if(t0 <= 2*ETA) + a[ctr++] = Q + ETA - t0; + if(t1 <= 2*ETA && ctr < len) + a[ctr++] = Q + ETA - t1; + } + + DBENCH_STOP(*tsample); + return ctr; +} + +/************************************************* +* Name: poly_uniform_eta +* +* Description: Sample polynomial with uniformly random coefficients +* in [-ETA,ETA] by performing rejection sampling using the +* output stream from SHAKE256(seed|nonce). +* +* Arguments: - poly *a: pointer to output polynomial +* - const uint8_t seed[]: byte array with seed of length +* SEEDBYTES +* - uint8_t nonce: nonce byte +**************************************************/ +void poly_uniform_eta(poly *a, + const uint8_t seed[SEEDBYTES], + uint8_t nonce) +{ + uint32_t i, ctr; + uint8_t inbuf[SEEDBYTES + 1]; + /* Probability that we need more than 2 blocks: < 2^{-84} + Probability that we need more than 3 blocks: < 2^{-352} */ + uint8_t outbuf[2*SHAKE256_RATE]; + uint64_t state[25]; + + for(i= 0; i < SEEDBYTES; ++i) + inbuf[i] = seed[i]; + inbuf[SEEDBYTES] = nonce; + + shake256_absorb(state, inbuf, SEEDBYTES + 1); + shake256_squeezeblocks(outbuf, 2, state); + + ctr = rej_eta(a->coeffs, N, outbuf, 2*SHAKE256_RATE); + if(ctr < N) { + shake256_squeezeblocks(outbuf, 1, state); + rej_eta(a->coeffs + ctr, N - ctr, outbuf, SHAKE256_RATE); + } +} + +/************************************************* +* Name: rej_gamma1m1 +* +* Description: Sample uniformly random coefficients +* in [-(GAMMA1 - 1), GAMMA1 - 1] by performing rejection sampling +* using array of random bytes. +* +* Arguments: - uint32_t *a: pointer to output array (allocated) +* - uint32_t len: number of coefficients to be sampled +* - const uint8_t *buf: array of random bytes +* - uint32_t buflen: length of array of random bytes +* +* Returns number of sampled coefficients. Can be smaller than len if not enough +* random bytes were given. +**************************************************/ +static uint32_t rej_gamma1m1(uint32_t *a, + uint32_t len, + const uint8_t *buf, + uint32_t buflen) +{ +#if GAMMA1 > (1 << 19) +#error "rej_gamma1m1() assumes GAMMA1 - 1 fits in 19 bits" +#endif + uint32_t ctr, pos; + uint32_t t0, t1; + DBENCH_START(); + + ctr = pos = 0; + while(ctr < len && pos + 5 <= buflen) { + t0 = buf[pos]; + t0 |= (uint32_t)buf[pos + 1] << 8; + t0 |= (uint32_t)buf[pos + 2] << 16; + t0 &= 0xFFFFF; + + t1 = buf[pos + 2] >> 4; + t1 |= (uint32_t)buf[pos + 3] << 4; + t1 |= (uint32_t)buf[pos + 4] << 12; + + pos += 5; + + if(t0 <= 2*GAMMA1 - 2) + a[ctr++] = Q + GAMMA1 - 1 - t0; + if(t1 <= 2*GAMMA1 - 2 && ctr < len) + a[ctr++] = Q + GAMMA1 - 1 - t1; + } + + DBENCH_STOP(*tsample); + return ctr; +} + +/************************************************* +* Name: poly_uniform_gamma1m1 +* +* Description: Sample polynomial with uniformly random coefficients +* in [-(GAMMA1 - 1), GAMMA1 - 1] by performing rejection +* sampling on output stream of SHAKE256(seed|nonce). +* +* Arguments: - poly *a: pointer to output polynomial +* - const uint8_t seed[]: byte array with seed of length +* SEEDBYTES + CRHBYTES +* - uint16_t nonce: 16-bit nonce +**************************************************/ +void poly_uniform_gamma1m1(poly *a, + const uint8_t seed[SEEDBYTES + CRHBYTES], + uint16_t nonce) +{ + uint32_t i, ctr; + uint8_t inbuf[SEEDBYTES + CRHBYTES + 2]; + /* Probability that we need more than 5 blocks: < 2^{-81} + Probability that we need more than 6 blocks: < 2^{-467} */ + uint8_t outbuf[5*SHAKE256_RATE]; + uint64_t state[25]; + + for(i = 0; i < SEEDBYTES + CRHBYTES; ++i) + inbuf[i] = seed[i]; + inbuf[SEEDBYTES + CRHBYTES] = nonce & 0xFF; + inbuf[SEEDBYTES + CRHBYTES + 1] = nonce >> 8; + + shake256_absorb(state, inbuf, SEEDBYTES + CRHBYTES + 2); + shake256_squeezeblocks(outbuf, 5, state); + + ctr = rej_gamma1m1(a->coeffs, N, outbuf, 5*SHAKE256_RATE); + if(ctr < N) { + /* There are no bytes left in outbuf + since 5*SHAKE256_RATE is divisible by 5 */ + shake256_squeezeblocks(outbuf, 1, state); + rej_gamma1m1(a->coeffs + ctr, N - ctr, outbuf, SHAKE256_RATE); + } +} + +/************************************************* +* Name: polyeta_pack +* +* Description: Bit-pack polynomial with coefficients in [-ETA,ETA]. +* Input coefficients are assumed to lie in [Q-ETA,Q+ETA]. +* +* Arguments: - uint8_t *r: pointer to output byte array with at least +* POLETA_SIZE_PACKED bytes +* - const poly *a: pointer to input polynomial +**************************************************/ +void polyeta_pack(uint8_t *r, const poly *a) { +#if ETA > 7 +#error "polyeta_pack() assumes ETA <= 7" +#endif + uint32_t i; + uint8_t t[8]; + DBENCH_START(); + +#if ETA <= 3 + for(i = 0; i < N/8; ++i) { + t[0] = Q + ETA - a->coeffs[8*i+0]; + t[1] = Q + ETA - a->coeffs[8*i+1]; + t[2] = Q + ETA - a->coeffs[8*i+2]; + t[3] = Q + ETA - a->coeffs[8*i+3]; + t[4] = Q + ETA - a->coeffs[8*i+4]; + t[5] = Q + ETA - a->coeffs[8*i+5]; + t[6] = Q + ETA - a->coeffs[8*i+6]; + t[7] = Q + ETA - a->coeffs[8*i+7]; + + r[3*i+0] = t[0]; + r[3*i+0] |= t[1] << 3; + r[3*i+0] |= t[2] << 6; + r[3*i+1] = t[2] >> 2; + r[3*i+1] |= t[3] << 1; + r[3*i+1] |= t[4] << 4; + r[3*i+1] |= t[5] << 7; + r[3*i+2] = t[5] >> 1; + r[3*i+2] |= t[6] << 2; + r[3*i+2] |= t[7] << 5; + } +#else + for(i = 0; i < N/2; ++i) { + t[0] = Q + ETA - a->coeffs[2*i+0]; + t[1] = Q + ETA - a->coeffs[2*i+1]; + r[i] = t[0] | (t[1] << 4); + } +#endif + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyeta_unpack +* +* Description: Unpack polynomial with coefficients in [-ETA,ETA]. +* Output coefficients lie in [Q-ETA,Q+ETA]. +* +* Arguments: - poly *r: pointer to output polynomial +* - const uint8_t *a: byte array with bit-packed polynomial +**************************************************/ +void polyeta_unpack(poly *r, const uint8_t *a) { + uint32_t i; + DBENCH_START(); + +#if ETA <= 3 + for(i = 0; i < N/8; ++i) { + r->coeffs[8*i+0] = a[3*i+0] & 0x07; + r->coeffs[8*i+1] = (a[3*i+0] >> 3) & 0x07; + r->coeffs[8*i+2] = (a[3*i+0] >> 6) | ((a[3*i+1] & 0x01) << 2); + r->coeffs[8*i+3] = (a[3*i+1] >> 1) & 0x07; + r->coeffs[8*i+4] = (a[3*i+1] >> 4) & 0x07; + r->coeffs[8*i+5] = (a[3*i+1] >> 7) | ((a[3*i+2] & 0x03) << 1); + r->coeffs[8*i+6] = (a[3*i+2] >> 2) & 0x07; + r->coeffs[8*i+7] = (a[3*i+2] >> 5); + + r->coeffs[8*i+0] = Q + ETA - r->coeffs[8*i+0]; + r->coeffs[8*i+1] = Q + ETA - r->coeffs[8*i+1]; + r->coeffs[8*i+2] = Q + ETA - r->coeffs[8*i+2]; + r->coeffs[8*i+3] = Q + ETA - r->coeffs[8*i+3]; + r->coeffs[8*i+4] = Q + ETA - r->coeffs[8*i+4]; + r->coeffs[8*i+5] = Q + ETA - r->coeffs[8*i+5]; + r->coeffs[8*i+6] = Q + ETA - r->coeffs[8*i+6]; + r->coeffs[8*i+7] = Q + ETA - r->coeffs[8*i+7]; + } +#else + for(i = 0; i < N/2; ++i) { + r->coeffs[2*i+0] = a[i] & 0x0F; + r->coeffs[2*i+1] = a[i] >> 4; + r->coeffs[2*i+0] = Q + ETA - r->coeffs[2*i+0]; + r->coeffs[2*i+1] = Q + ETA - r->coeffs[2*i+1]; + } +#endif + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyt1_pack +* +* Description: Bit-pack polynomial t1 with coefficients fitting in 9 bits. +* Input coefficients are assumed to be standard representatives. +* +* Arguments: - uint8_t *r: pointer to output byte array with at least +* POLT1_SIZE_PACKED bytes +* - const poly *a: pointer to input polynomial +**************************************************/ +void polyt1_pack(uint8_t *r, const poly *a) { +#if D != 14 +#error "polyt1_pack() assumes D == 14" +#endif + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N/8; ++i) { + r[9*i+0] = a->coeffs[8*i+0] & 0xFF; + r[9*i+1] = (a->coeffs[8*i+0] >> 8) | ((a->coeffs[8*i+1] & 0x7F) << 1); + r[9*i+2] = (a->coeffs[8*i+1] >> 7) | ((a->coeffs[8*i+2] & 0x3F) << 2); + r[9*i+3] = (a->coeffs[8*i+2] >> 6) | ((a->coeffs[8*i+3] & 0x1F) << 3); + r[9*i+4] = (a->coeffs[8*i+3] >> 5) | ((a->coeffs[8*i+4] & 0x0F) << 4); + r[9*i+5] = (a->coeffs[8*i+4] >> 4) | ((a->coeffs[8*i+5] & 0x07) << 5); + r[9*i+6] = (a->coeffs[8*i+5] >> 3) | ((a->coeffs[8*i+6] & 0x03) << 6); + r[9*i+7] = (a->coeffs[8*i+6] >> 2) | ((a->coeffs[8*i+7] & 0x01) << 7); + r[9*i+8] = a->coeffs[8*i+7] >> 1; + } + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyt1_unpack +* +* Description: Unpack polynomial t1 with 9-bit coefficients. +* Output coefficients are standard representatives. +* +* Arguments: - poly *r: pointer to output polynomial +* - const uint8_t *a: byte array with bit-packed polynomial +**************************************************/ +void polyt1_unpack(poly *r, const uint8_t *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N/8; ++i) { + r->coeffs[8*i+0] = a[9*i+0] | ((uint32_t)(a[9*i+1] & 0x01) << 8); + r->coeffs[8*i+1] = (a[9*i+1] >> 1) | ((uint32_t)(a[9*i+2] & 0x03) << 7); + r->coeffs[8*i+2] = (a[9*i+2] >> 2) | ((uint32_t)(a[9*i+3] & 0x07) << 6); + r->coeffs[8*i+3] = (a[9*i+3] >> 3) | ((uint32_t)(a[9*i+4] & 0x0F) << 5); + r->coeffs[8*i+4] = (a[9*i+4] >> 4) | ((uint32_t)(a[9*i+5] & 0x1F) << 4); + r->coeffs[8*i+5] = (a[9*i+5] >> 5) | ((uint32_t)(a[9*i+6] & 0x3F) << 3); + r->coeffs[8*i+6] = (a[9*i+6] >> 6) | ((uint32_t)(a[9*i+7] & 0x7F) << 2); + r->coeffs[8*i+7] = (a[9*i+7] >> 7) | ((uint32_t)(a[9*i+8] & 0xFF) << 1); + } + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyt0_pack +* +* Description: Bit-pack polynomial t0 with coefficients in ]-2^{D-1}, 2^{D-1}]. +* Input coefficients are assumed to lie in ]Q-2^{D-1}, Q+2^{D-1}]. +* +* Arguments: - uint8_t *r: pointer to output byte array with at least +* POLT0_SIZE_PACKED bytes +* - const poly *a: pointer to input polynomial +**************************************************/ +void polyt0_pack(uint8_t *r, const poly *a) { + uint32_t i; + uint32_t t[4]; + DBENCH_START(); + + for(i = 0; i < N/4; ++i) { + t[0] = Q + (1 << (D-1)) - a->coeffs[4*i+0]; + t[1] = Q + (1 << (D-1)) - a->coeffs[4*i+1]; + t[2] = Q + (1 << (D-1)) - a->coeffs[4*i+2]; + t[3] = Q + (1 << (D-1)) - a->coeffs[4*i+3]; + + r[7*i+0] = t[0]; + r[7*i+1] = t[0] >> 8; + r[7*i+1] |= t[1] << 6; + r[7*i+2] = t[1] >> 2; + r[7*i+3] = t[1] >> 10; + r[7*i+3] |= t[2] << 4; + r[7*i+4] = t[2] >> 4; + r[7*i+5] = t[2] >> 12; + r[7*i+5] |= t[3] << 2; + r[7*i+6] = t[3] >> 6; + } + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyt0_unpack +* +* Description: Unpack polynomial t0 with coefficients in ]-2^{D-1}, 2^{D-1}]. +* Output coefficients lie in ]Q-2^{D-1},Q+2^{D-1}]. +* +* Arguments: - poly *r: pointer to output polynomial +* - const uint8_t *a: byte array with bit-packed polynomial +**************************************************/ +void polyt0_unpack(poly *r, const uint8_t *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N/4; ++i) { + r->coeffs[4*i+0] = a[7*i+0]; + r->coeffs[4*i+0] |= (uint32_t)(a[7*i+1] & 0x3F) << 8; + + r->coeffs[4*i+1] = a[7*i+1] >> 6; + r->coeffs[4*i+1] |= (uint32_t)a[7*i+2] << 2; + r->coeffs[4*i+1] |= (uint32_t)(a[7*i+3] & 0x0F) << 10; + + r->coeffs[4*i+2] = a[7*i+3] >> 4; + r->coeffs[4*i+2] |= (uint32_t)a[7*i+4] << 4; + r->coeffs[4*i+2] |= (uint32_t)(a[7*i+5] & 0x03) << 12; + + r->coeffs[4*i+3] = a[7*i+5] >> 2; + r->coeffs[4*i+3] |= (uint32_t)a[7*i+6] << 6; + + r->coeffs[4*i+0] = Q + (1 << (D-1)) - r->coeffs[4*i+0]; + r->coeffs[4*i+1] = Q + (1 << (D-1)) - r->coeffs[4*i+1]; + r->coeffs[4*i+2] = Q + (1 << (D-1)) - r->coeffs[4*i+2]; + r->coeffs[4*i+3] = Q + (1 << (D-1)) - r->coeffs[4*i+3]; + } + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyz_pack +* +* Description: Bit-pack polynomial z with coefficients +* in [-(GAMMA1 - 1), GAMMA1 - 1]. +* Input coefficients are assumed to be standard representatives. +* +* Arguments: - uint8_t *r: pointer to output byte array with at least +* POLZ_SIZE_PACKED bytes +* - const poly *a: pointer to input polynomial +**************************************************/ +void polyz_pack(uint8_t *r, const poly *a) { +#if GAMMA1 > (1 << 19) +#error "polyz_pack() assumes GAMMA1 <= 2^{19}" +#endif + uint32_t i; + uint32_t t[2]; + DBENCH_START(); + + for(i = 0; i < N/2; ++i) { + /* Map to {0,...,2*GAMMA1 - 2} */ + t[0] = GAMMA1 - 1 - a->coeffs[2*i+0]; + t[0] += ((int32_t)t[0] >> 31) & Q; + t[1] = GAMMA1 - 1 - a->coeffs[2*i+1]; + t[1] += ((int32_t)t[1] >> 31) & Q; + + r[5*i+0] = t[0]; + r[5*i+1] = t[0] >> 8; + r[5*i+2] = t[0] >> 16; + r[5*i+2] |= t[1] << 4; + r[5*i+3] = t[1] >> 4; + r[5*i+4] = t[1] >> 12; + } + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyz_unpack +* +* Description: Unpack polynomial z with coefficients +* in [-(GAMMA1 - 1), GAMMA1 - 1]. +* Output coefficients are standard representatives. +* +* Arguments: - poly *r: pointer to output polynomial +* - const uint8_t *a: byte array with bit-packed polynomial +**************************************************/ +void polyz_unpack(poly *r, const uint8_t *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N/2; ++i) { + r->coeffs[2*i+0] = a[5*i+0]; + r->coeffs[2*i+0] |= (uint32_t)a[5*i+1] << 8; + r->coeffs[2*i+0] |= (uint32_t)(a[5*i+2] & 0x0F) << 16; + + r->coeffs[2*i+1] = a[5*i+2] >> 4; + r->coeffs[2*i+1] |= (uint32_t)a[5*i+3] << 4; + r->coeffs[2*i+1] |= (uint32_t)a[5*i+4] << 12; + + r->coeffs[2*i+0] = GAMMA1 - 1 - r->coeffs[2*i+0]; + r->coeffs[2*i+0] += ((int32_t)r->coeffs[2*i+0] >> 31) & Q; + r->coeffs[2*i+1] = GAMMA1 - 1 - r->coeffs[2*i+1]; + r->coeffs[2*i+1] += ((int32_t)r->coeffs[2*i+1] >> 31) & Q; + } + + DBENCH_STOP(*tpack); +} + +/************************************************* +* Name: polyw1_pack +* +* Description: Bit-pack polynomial w1 with coefficients in [0, 15]. +* Input coefficients are assumed to be standard representatives. +* +* Arguments: - uint8_t *r: pointer to output byte array with at least +* POLW1_SIZE_PACKED bytes +* - const poly *a: pointer to input polynomial +**************************************************/ +void polyw1_pack(uint8_t *r, const poly *a) { + uint32_t i; + DBENCH_START(); + + for(i = 0; i < N/2; ++i) + r[i] = a->coeffs[2*i+0] | (a->coeffs[2*i+1] << 4); + + DBENCH_STOP(*tpack); +} +//#include +//#include "params.h" +//#include "poly.h" +//#include "polyvec.h" + +/**************************************************************/ +/************ Vectors of polynomials of length L **************/ +/**************************************************************/ + +/************************************************* +* Name: polyvecl_freeze +* +* Description: Reduce coefficients of polynomials in vector of length L +* to standard representatives. +* +* Arguments: - polyvecl *v: pointer to input/output vector +**************************************************/ +void polyvecl_freeze(polyvecl *v) { + uint32_t i; + + for(i = 0; i < L; ++i) + poly_freeze(v->vec+i); +} + +/************************************************* +* Name: polyvecl_add +* +* Description: Add vectors of polynomials of length L. +* No modular reduction is performed. +* +* Arguments: - polyvecl *w: pointer to output vector +* - const polyvecl *u: pointer to first summand +* - const polyvecl *v: pointer to second summand +**************************************************/ +void polyvecl_add(polyvecl *w, const polyvecl *u, const polyvecl *v) { + uint32_t i; + + for(i = 0; i < L; ++i) + poly_add(w->vec+i, u->vec+i, v->vec+i); +} + +/************************************************* +* Name: polyvecl_ntt +* +* Description: Forward NTT of all polynomials in vector of length L. Output +* coefficients can be up to 16*Q larger than input coefficients. +* +* Arguments: - polyvecl *v: pointer to input/output vector +**************************************************/ +void polyvecl_ntt(polyvecl *v) { + uint32_t i; + + for(i = 0; i < L; ++i) + poly_ntt(v->vec+i); +} + +/************************************************* +* Name: polyvecl_pointwise_acc_invmontgomery +* +* Description: Pointwise multiply vectors of polynomials of length L, multiply +* resulting vector by 2^{-32} and add (accumulate) polynomials +* in it. Input/output vectors are in NTT domain representation. +* Input coefficients are assumed to be less than 22*Q. Output +* coeffcient are less than 2*L*Q. +* +* Arguments: - poly *w: output polynomial +* - const polyvecl *u: pointer to first input vector +* - const polyvecl *v: pointer to second input vector +**************************************************/ +void polyvecl_pointwise_acc_invmontgomery(poly *w, + const polyvecl *u, + const polyvecl *v) +{ + uint32_t i; + poly t; + + poly_pointwise_invmontgomery(w, u->vec+0, v->vec+0); + + for(i = 1; i < L; ++i) { + poly_pointwise_invmontgomery(&t, u->vec+i, v->vec+i); + poly_add(w, w, &t); + } +} + +/************************************************* +* Name: polyvecl_chknorm +* +* Description: Check infinity norm of polynomials in vector of length L. +* Assumes input coefficients to be standard representatives. +* +* Arguments: - const polyvecl *v: pointer to vector +* - uint32_t B: norm bound +* +* Returns 0 if norm of all polynomials is strictly smaller than B and 1 +* otherwise. +**************************************************/ +int polyvecl_chknorm(const polyvecl *v, uint32_t bound) { + uint32_t i; + int ret = 0; + + for(i = 0; i < L; ++i) + ret |= poly_chknorm(v->vec+i, bound); + + return ret; +} + +/**************************************************************/ +/************ Vectors of polynomials of length K **************/ +/**************************************************************/ + + +/************************************************* +* Name: polyveck_reduce +* +* Description: Reduce coefficients of polynomials in vector of length K +* to representatives in [0,2*Q[. +* +* Arguments: - polyveck *v: pointer to input/output vector +**************************************************/ +void polyveck_reduce(polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_reduce(v->vec+i); +} + +/************************************************* +* Name: polyveck_csubq +* +* Description: For all coefficients of polynomials in vector of length K +* subtract Q if coefficient is bigger than Q. +* +* Arguments: - polyveck *v: pointer to input/output vector +**************************************************/ +void polyveck_csubq(polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_csubq(v->vec+i); +} + +/************************************************* +* Name: polyveck_freeze +* +* Description: Reduce coefficients of polynomials in vector of length K +* to standard representatives. +* +* Arguments: - polyveck *v: pointer to input/output vector +**************************************************/ +void polyveck_freeze(polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_freeze(v->vec+i); +} + +/************************************************* +* Name: polyveck_add +* +* Description: Add vectors of polynomials of length K. +* No modular reduction is performed. +* +* Arguments: - polyveck *w: pointer to output vector +* - const polyveck *u: pointer to first summand +* - const polyveck *v: pointer to second summand +**************************************************/ +void polyveck_add(polyveck *w, const polyveck *u, const polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_add(w->vec+i, u->vec+i, v->vec+i); +} + +/************************************************* +* Name: polyveck_sub +* +* Description: Subtract vectors of polynomials of length K. +* Assumes coefficients of polynomials in second input vector +* to be less than 2*Q. No modular reduction is performed. +* +* Arguments: - polyveck *w: pointer to output vector +* - const polyveck *u: pointer to first input vector +* - const polyveck *v: pointer to second input vector to be +* subtracted from first input vector +**************************************************/ +void polyveck_sub(polyveck *w, const polyveck *u, const polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_sub(w->vec+i, u->vec+i, v->vec+i); +} + +/************************************************* +* Name: polyveck_shiftl +* +* Description: Multiply vector of polynomials of Length K by 2^k without modular +* reduction. Assumes input coefficients to be less than 2^{32-k}. +* +* Arguments: - polyveck *v: pointer to input/output vector +* - uint32_t k: exponent +**************************************************/ +void polyveck_shiftl(polyveck *v, uint32_t k) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_shiftl(v->vec+i, k); +} + +/************************************************* +* Name: polyveck_ntt +* +* Description: Forward NTT of all polynomials in vector of length K. Output +* coefficients can be up to 16*Q larger than input coefficients. +* +* Arguments: - polyveck *v: pointer to input/output vector +**************************************************/ +void polyveck_ntt(polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_ntt(v->vec+i); +} + +/************************************************* +* Name: polyveck_invntt_montgomery +* +* Description: Inverse NTT and multiplication by 2^{32} of polynomials +* in vector of length K. Input coefficients need to be less +* than 2*Q. +* +* Arguments: - polyveck *v: pointer to input/output vector +**************************************************/ +void polyveck_invntt_montgomery(polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_invntt_montgomery(v->vec+i); +} + +/************************************************* +* Name: polyveck_chknorm +* +* Description: Check infinity norm of polynomials in vector of length K. +* Assumes input coefficients to be standard representatives. +* +* Arguments: - const polyveck *v: pointer to vector +* - uint32_t B: norm bound +* +* Returns 0 if norm of all polynomials are strictly smaller than B and 1 +* otherwise. +**************************************************/ +int polyveck_chknorm(const polyveck *v, uint32_t bound) { + uint32_t i; + int ret = 0; + + for(i = 0; i < K; ++i) + ret |= poly_chknorm(v->vec+i, bound); + + return ret; +} + +/************************************************* +* Name: polyveck_power2round +* +* Description: For all coefficients a of polynomials in vector of length K, +* compute a0, a1 such that a mod Q = a1*2^D + a0 +* with -2^{D-1} < a0 <= 2^{D-1}. Assumes coefficients to be +* standard representatives. +* +* Arguments: - polyveck *v1: pointer to output vector of polynomials with +* coefficients a1 +* - polyveck *v0: pointer to output vector of polynomials with +* coefficients Q + a0 +* - const polyveck *v: pointer to input vector +**************************************************/ +void polyveck_power2round(polyveck *v1, polyveck *v0, const polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_power2round(v1->vec+i, v0->vec+i, v->vec+i); +} + +/************************************************* +* Name: polyveck_decompose +* +* Description: For all coefficients a of polynomials in vector of length K, +* compute high and low bits a0, a1 such a mod Q = a1*ALPHA + a0 +* with -ALPHA/2 < a0 <= ALPHA/2 except a1 = (Q-1)/ALPHA where we +* set a1 = 0 and -ALPHA/2 <= a0 = a mod Q - Q < 0. +* Assumes coefficients to be standard representatives. +* +* Arguments: - polyveck *v1: pointer to output vector of polynomials with +* coefficients a1 +* - polyveck *v0: pointer to output vector of polynomials with +* coefficients Q + a0 +* - const polyveck *v: pointer to input vector +**************************************************/ +void polyveck_decompose(polyveck *v1, polyveck *v0, const polyveck *v) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_decompose(v1->vec+i, v0->vec+i, v->vec+i); +} + +/************************************************* +* Name: polyveck_make_hint +* +* Description: Compute hint vector. +* +* Arguments: - polyveck *h: pointer to output vector +* - const polyveck *u: pointer to first input vector +* - const polyveck *u: pointer to second input vector +* +* Returns number of 1 bits. +**************************************************/ +uint32_t polyveck_make_hint(polyveck *h, + const polyveck *u, + const polyveck *v) +{ + uint32_t i, s = 0; + + for(i = 0; i < K; ++i) + s += poly_make_hint(h->vec+i, u->vec+i, v->vec+i); + + return s; +} + +/************************************************* +* Name: polyveck_use_hint +* +* Description: Use hint vector to correct the high bits of input vector. +* +* Arguments: - polyveck *w: pointer to output vector of polynomials with +* corrected high bits +* - const polyveck *u: pointer to input vector +* - const polyveck *h: pointer to input hint vector +**************************************************/ +void polyveck_use_hint(polyveck *w, const polyveck *u, const polyveck *h) { + uint32_t i; + + for(i = 0; i < K; ++i) + poly_use_hint(w->vec+i, u->vec+i, h->vec+i); +} +//#include +//#include "params.h" +//#include "reduce.h" + +/************************************************* +* Name: montgomery_reduce +* +* Description: For finite field element a with 0 <= a <= Q*2^32, +* compute r \equiv a*2^{-32} (mod Q) such that 0 <= r < 2*Q. +* +* Arguments: - uint64_t: finite field element a +* +* Returns r. +**************************************************/ +uint32_t montgomery_reduce(uint64_t a) { + uint64_t t; + + t = a * QINV; + t &= (1ULL << 32) - 1; + t *= Q; + t = a + t; + t >>= 32; + return t; +} + +/************************************************* +* Name: reduce32 +* +* Description: For finite field element a, compute r \equiv a (mod Q) +* such that 0 <= r < 2*Q. +* +* Arguments: - uint32_t: finite field element a +* +* Returns r. +**************************************************/ +uint32_t reduce32(uint32_t a) { + uint32_t t; + + t = a & 0x7FFFFF; + a >>= 23; + t += (a << 13) - a; + return t; +} + +/************************************************* +* Name: csubq +* +* Description: Subtract Q if input coefficient is bigger than Q. +* +* Arguments: - uint32_t: finite field element a +* +* Returns r. +**************************************************/ +uint32_t csubq(uint32_t a) { + a -= Q; + a += ((int32_t)a >> 31) & Q; + return a; +} + +/************************************************* +* Name: freeze +* +* Description: For finite field element a, compute standard +* representative r = a mod Q. +* +* Arguments: - uint32_t: finite field element a +* +* Returns r. +**************************************************/ +uint32_t freeze(uint32_t a) { + a = reduce32(a); + a = csubq(a); + return a; +} +//#include +//#include "params.h" + +/************************************************* +* Name: power2round +* +* Description: For finite field element a, compute a0, a1 such that +* a mod Q = a1*2^D + a0 with -2^{D-1} < a0 <= 2^{D-1}. +* Assumes a to be standard representative. +* +* Arguments: - uint32_t a: input element +* - uint32_t *a0: pointer to output element Q + a0 +* +* Returns a1. +**************************************************/ +uint32_t power2round(uint32_t a, uint32_t *a0) { + int32_t t; + + /* Centralized remainder mod 2^D */ + t = a & ((1 << D) - 1); + t -= (1 << (D-1)) + 1; + t += (t >> 31) & (1 << D); + t -= (1 << (D-1)) - 1; + *a0 = Q + t; + a = (a - t) >> D; + return a; +} + +/************************************************* +* Name: decompose +* +* Description: For finite field element a, compute high and low bits a0, a1 such +* that a mod Q = a1*ALPHA + a0 with -ALPHA/2 < a0 <= ALPHA/2 except +* if a1 = (Q-1)/ALPHA where we set a1 = 0 and +* -ALPHA/2 <= a0 = a mod Q - Q < 0. Assumes a to be standard +* representative. +* +* Arguments: - uint32_t a: input element +* - uint32_t *a0: pointer to output element Q + a0 +* +* Returns a1. +**************************************************/ +uint32_t decompose(uint32_t a, uint32_t *a0) { +#if ALPHA != (Q-1)/16 +#error "decompose assumes ALPHA == (Q-1)/16" +#endif + int32_t t, u; + + /* Centralized remainder mod ALPHA */ + t = a & 0x7FFFF; + t += (a >> 19) << 9; + t -= ALPHA/2 + 1; + t += (t >> 31) & ALPHA; + t -= ALPHA/2 - 1; + a -= t; + + /* Divide by ALPHA (possible to avoid) */ + u = a - 1; + u >>= 31; + a = (a >> 19) + 1; + a -= u & 1; + + /* Border case */ + *a0 = Q + t - (a >> 4); + a &= 0xF; + return a; +} + +/************************************************* +* Name: make_hint +* +* Description: Compute hint bit indicating whether or not high bits of two +* finite field elements differ. Assumes input elements to be +* standard representatives. +* +* Arguments: - uint32_t a: first input element +* - uint32_t b: second input element +* +* Returns 1 if high bits of a and b differ and 0 otherwise. +**************************************************/ +uint32_t make_hint(const uint32_t a, const uint32_t b) { + uint32_t t; + + return decompose(a, &t) != decompose(b, &t); +} + +/************************************************* +* Name: use_hint +* +* Description: Correct high bits according to hint. +* +* Arguments: - uint32_t a: input element +* - uint32_t hint: hint bit +* +* Returns corrected high bits. +**************************************************/ +uint32_t use_hint(const uint32_t a, const uint32_t hint) { + uint32_t a0, a1; + + a1 = decompose(a, &a0); + if(hint == 0) + return a1; + else if(a0 > Q) + return (a1 + 1) & 0xF; + else + return (a1 - 1) & 0xF; + + /* If decompose does not divide out ALPHA: + if(hint == 0) + return a1; + else if(a0 > Q) + return (a1 + ALPHA) % (Q - 1); + else + return (a1 - ALPHA) % (Q - 1); + */ +} +//#include +//#include "params.h" +//#include "sign.h" +//#include "randombytes.h" +//#include "fips202.h" +//#include "poly.h" +//#include "polyvec.h" +//#include "packing.h" +#ifdef STANDALONE +#ifdef _WIN32 +#include +void randombytes(unsigned char *x,long xlen) +{ + HCRYPTPROV prov = 0; + CryptAcquireContextW(&prov, NULL, NULL,PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT); + CryptGenRandom(prov, xlen, x); + CryptReleaseContext(prov, 0); +} +#else +#include +#include +#include +void randombytes(unsigned char *x,long xlen) +{ + static int fd = -1; + int32_t i; + if (fd == -1) { + for (;;) { + fd = open("/dev/urandom",O_RDONLY); + if (fd != -1) break; + sleep(1); + } + } + while (xlen > 0) { + if (xlen < 1048576) i = (int32_t)xlen; else i = 1048576; + i = (int32_t)read(fd,x,i); + if (i < 1) { + sleep(1); + continue; + } + if ( 0 ) + { + int32_t j; + for (j=0; j %p\n",x); + } + x += i; + xlen -= i; + } +} +#endif +#endif + +/************************************************* +* Name: expand_mat +* +* Description: Implementation of ExpandA. Generates matrix A with uniformly +* random coefficients a_{i,j} by performing rejection +* sampling on the output stream of SHAKE128(rho|i|j). +* +* Arguments: - polyvecl mat[K]: output matrix +* - const uint8_t rho[]: byte array containing seed rho +**************************************************/ +void expand_mat(polyvecl mat[K], const uint8_t rho[SEEDBYTES]) { + uint32_t i, j; + uint8_t inbuf[SEEDBYTES + 1]; + /* Don't change this to smaller values, + * sampling later assumes sufficient SHAKE output! + * Probability that we need more than 5 blocks: < 2^{-132}. + * Probability that we need more than 6 blocks: < 2^{-546}. */ + uint8_t outbuf[5*SHAKE128_RATE]; + + for(i = 0; i < SEEDBYTES; ++i) + inbuf[i] = rho[i]; + + for(i = 0; i < K; ++i) { + for(j = 0; j < L; ++j) { + inbuf[SEEDBYTES] = i + (j << 4); + shake128(outbuf, sizeof(outbuf), inbuf, SEEDBYTES + 1); + poly_uniform(mat[i].vec+j, outbuf); + } + } +} + +/************************************************* +* Name: challenge +* +* Description: Implementation of H. Samples polynomial with 60 nonzero +* coefficients in {-1,1} using the output stream of +* SHAKE256(mu|w1). +* +* Arguments: - poly *c: pointer to output polynomial +* - const uint8_t mu[]: byte array containing mu +* - const polyveck *w1: pointer to vector w1 +**************************************************/ +void challenge(poly *c, + const uint8_t mu[CRHBYTES], + const polyveck *w1) +{ + uint32_t i, b, pos; + uint8_t inbuf[CRHBYTES + K*POLW1_SIZE_PACKED]; + uint8_t outbuf[SHAKE256_RATE]; + uint64_t state[25], signs, mask; + + for(i = 0; i < CRHBYTES; ++i) + inbuf[i] = mu[i]; + for(i = 0; i < K; ++i) + polyw1_pack(inbuf + CRHBYTES + i*POLW1_SIZE_PACKED, w1->vec+i); + + shake256_absorb(state, inbuf, sizeof(inbuf)); + shake256_squeezeblocks(outbuf, 1, state); + + signs = 0; + for(i = 0; i < 8; ++i) + signs |= (uint64_t)outbuf[i] << 8*i; + + pos = 8; + mask = 1; + + for(i = 0; i < N; ++i) + c->coeffs[i] = 0; + + for(i = 196; i < 256; ++i) { + do { + if(pos >= SHAKE256_RATE) { + shake256_squeezeblocks(outbuf, 1, state); + pos = 0; + } + + b = outbuf[pos++]; + } while(b > i); + + c->coeffs[i] = c->coeffs[b]; + c->coeffs[b] = (signs & mask) ? Q - 1 : 1; + mask <<= 1; + } +} + +/************************************************* +* Name: dilithium_keypair +* +* Description: Generates public and private key. +* +* Arguments: - uint8_t *pk: pointer to output public key (allocated +* array of CRYPTO_PUBLICKEYBYTES bytes) +* - uint8_t *sk: pointer to output private key (allocated +* array of CRYPTO_SECRETKEYBYTES bytes) +* +* Returns 0 (success) +**************************************************/ +int dilithium_keypair(uint8_t *pk, uint8_t *sk) { + uint32_t i; + uint8_t seedbuf[3*SEEDBYTES]; + uint8_t tr[CRHBYTES]; + uint8_t *rho, *rhoprime, *key; + uint16_t nonce = 0; + polyvecl mat[K]; + polyvecl s1, s1hat; + polyveck s2, t, t1, t0; + + /* Expand 32 bytes of randomness into rho, rhoprime and key */ + randombytes(seedbuf, SEEDBYTES); + shake256(seedbuf, 3*SEEDBYTES, seedbuf, SEEDBYTES); + rho = seedbuf; + rhoprime = rho + SEEDBYTES; + key = rho + 2*SEEDBYTES; + + /* Expand matrix */ + expand_mat(mat, rho); + + /* Sample short vectors s1 and s2 */ + for(i = 0; i < L; ++i) + poly_uniform_eta(s1.vec+i, rhoprime, nonce++); + for(i = 0; i < K; ++i) + poly_uniform_eta(s2.vec+i, rhoprime, nonce++); + + /* Matrix-vector multiplication */ + s1hat = s1; + polyvecl_ntt(&s1hat); + for(i = 0; i < K; ++i) { + polyvecl_pointwise_acc_invmontgomery(t.vec+i, mat+i, &s1hat); + poly_reduce(t.vec+i); + poly_invntt_montgomery(t.vec+i); + } + + /* Add noise vector s2 */ + polyveck_add(&t, &t, &s2); + + /* Extract t1 and write public key */ + polyveck_freeze(&t); + polyveck_power2round(&t1, &t0, &t); + pack_pk(pk, rho, &t1); + + /* Compute CRH(rho, t1) and write secret key */ + shake256(tr, CRHBYTES, pk, CRYPTO_PUBLICKEYBYTES); + pack_sk(sk, rho, key, tr, &s1, &s2, &t0); + + return 0; +} + +/************************************************* +* Name: dilithium_sign +* +* Description: Compute signed message. +* +* Arguments: - uint8_t *sm: pointer to output signed message (allocated +* array with CRYPTO_BYTES + mlen bytes), +* can be equal to m +* - int32_t *smlen: pointer to output length of signed +* message +* - const uint8_t *m: pointer to message to be signed +* - int32_t mlen: length of message +* - const uint8_t *sk: pointer to bit-packed secret key +* +* Returns 0 (success) +**************************************************/ +int dilithium_sign(uint8_t *sm, + int32_t *smlen, + const uint8_t *m, + int32_t mlen, + const uint8_t *sk) +{ + int32_t i, j; + uint32_t n; + uint8_t seedbuf[2*SEEDBYTES + CRHBYTES]; // TODO: nonce in seedbuf (2x) + uint8_t tr[CRHBYTES]; + uint8_t *rho, *key, *mu; + uint16_t nonce = 0; + poly c, chat; + polyvecl mat[K], s1, y, yhat, z; + polyveck s2, t0, w, w1; + polyveck h, wcs2, wcs20, ct0, tmp; + + rho = seedbuf; + key = seedbuf + SEEDBYTES; + mu = seedbuf + 2*SEEDBYTES; + unpack_sk(rho, key, tr, &s1, &s2, &t0, sk); + + /* Copy tr and message into the sm buffer, + * backwards since m and sm can be equal in SUPERCOP API */ + for(i = 1; i <= mlen; ++i) + sm[CRYPTO_BYTES + mlen - i] = m[mlen - i]; + for(i = 0; i < CRHBYTES; ++i) + sm[CRYPTO_BYTES - CRHBYTES + i] = tr[i]; + + /* Compute CRH(tr, msg) */ + shake256(mu, CRHBYTES, sm + CRYPTO_BYTES - CRHBYTES, CRHBYTES + mlen); + + /* Expand matrix and transform vectors */ + expand_mat(mat, rho); + polyvecl_ntt(&s1); + polyveck_ntt(&s2); + polyveck_ntt(&t0); + + rej: + /* Sample intermediate vector y */ + for(i = 0; i < L; ++i) + poly_uniform_gamma1m1(y.vec+i, key, nonce++); + + /* Matrix-vector multiplication */ + yhat = y; + polyvecl_ntt(&yhat); + for(i = 0; i < K; ++i) { + polyvecl_pointwise_acc_invmontgomery(w.vec+i, mat+i, &yhat); + poly_reduce(w.vec+i); + poly_invntt_montgomery(w.vec+i); + } + + /* Decompose w and call the random oracle */ + polyveck_csubq(&w); + polyveck_decompose(&w1, &tmp, &w); + challenge(&c, mu, &w1); + + /* Compute z, reject if it reveals secret */ + chat = c; + poly_ntt(&chat); + for(i = 0; i < L; ++i) { + poly_pointwise_invmontgomery(z.vec+i, &chat, s1.vec+i); + poly_invntt_montgomery(z.vec+i); + } + polyvecl_add(&z, &z, &y); + polyvecl_freeze(&z); + if(polyvecl_chknorm(&z, GAMMA1 - BETA)) + goto rej; + + /* Compute w - cs2, reject if w1 can not be computed from it */ + for(i = 0; i < K; ++i) { + poly_pointwise_invmontgomery(wcs2.vec+i, &chat, s2.vec+i); + poly_invntt_montgomery(wcs2.vec+i); + } + polyveck_sub(&wcs2, &w, &wcs2); + polyveck_freeze(&wcs2); + polyveck_decompose(&tmp, &wcs20, &wcs2); + polyveck_csubq(&wcs20); + if(polyveck_chknorm(&wcs20, GAMMA2 - BETA)) + goto rej; + + for(i = 0; i < K; ++i) + for(j = 0; j < N; ++j) + if(tmp.vec[i].coeffs[j] != w1.vec[i].coeffs[j]) + goto rej; + + /* Compute hints for w1 */ + for(i = 0; i < K; ++i) { + poly_pointwise_invmontgomery(ct0.vec+i, &chat, t0.vec+i); + poly_invntt_montgomery(ct0.vec+i); + } + + polyveck_csubq(&ct0); + if(polyveck_chknorm(&ct0, GAMMA2)) + goto rej; + + polyveck_add(&tmp, &wcs2, &ct0); + polyveck_csubq(&tmp); + n = polyveck_make_hint(&h, &wcs2, &tmp); + if(n > OMEGA) + goto rej; + + /* Write signature */ + pack_sig(sm, &z, &h, &c); + + *smlen = mlen + CRYPTO_BYTES; + return 0; +} + +/************************************************* +* Name: dilithium_verify +* +* Description: Verify signed message. +* +* Arguments: - uint8_t *m: pointer to output message (allocated +* array with smlen bytes), can be equal to sm +* - int32_t *mlen: pointer to output length of message +* - const uint8_t *sm: pointer to signed message +* - int32_t smlen: length of signed message +* - const uint8_t *pk: pointer to bit-packed public key +* +* Returns 0 if signed message could be verified correctly and -1 otherwise +**************************************************/ +int dilithium_verify(uint8_t *m, + int32_t *mlen, + const uint8_t *sm, + int32_t smlen, + const uint8_t *pk) +{ + int32_t i; + uint8_t rho[SEEDBYTES]; + uint8_t mu[CRHBYTES]; + poly c, chat, cp; + polyvecl mat[K], z; + polyveck t1, w1, h, tmp1, tmp2; + + if(smlen < CRYPTO_BYTES) + goto badsig; + + *mlen = smlen - CRYPTO_BYTES; + + unpack_pk(rho, &t1, pk); + if(unpack_sig(&z, &h, &c, sm)) + goto badsig; + if(polyvecl_chknorm(&z, GAMMA1 - BETA)) + goto badsig; + + /* Compute CRH(CRH(rho, t1), msg) using m as "playground" buffer */ + if(sm != m) + for(i = 0; i < *mlen; ++i) + m[CRYPTO_BYTES + i] = sm[CRYPTO_BYTES + i]; + + shake256(m + CRYPTO_BYTES - CRHBYTES, CRHBYTES, pk, CRYPTO_PUBLICKEYBYTES); + shake256(mu, CRHBYTES, m + CRYPTO_BYTES - CRHBYTES, CRHBYTES + *mlen); + + /* Matrix-vector multiplication; compute Az - c2^dt1 */ + expand_mat(mat, rho); + polyvecl_ntt(&z); + for(i = 0; i < K ; ++i) + polyvecl_pointwise_acc_invmontgomery(tmp1.vec+i, mat+i, &z); + + chat = c; + poly_ntt(&chat); + polyveck_shiftl(&t1, D); + polyveck_ntt(&t1); + for(i = 0; i < K; ++i) + poly_pointwise_invmontgomery(tmp2.vec+i, &chat, t1.vec+i); + + polyveck_sub(&tmp1, &tmp1, &tmp2); + polyveck_reduce(&tmp1); + polyveck_invntt_montgomery(&tmp1); + + /* Reconstruct w1 */ + polyveck_csubq(&tmp1); + polyveck_use_hint(&w1, &tmp1, &h); + + /* Call random oracle and verify challenge */ + challenge(&cp, mu, &w1); + for(i = 0; i < N; ++i) + if(c.coeffs[i] != cp.coeffs[i]) + { + /* Signature verification failed */ + badsig: + *mlen = (int32_t) -1; + for(i = 0; i < smlen; ++i) + m[i] = 0; + + return -1; + } + + /* All good, copy msg, return 0 */ + for(i = 0; i < *mlen; ++i) + m[i] = sm[CRYPTO_BYTES + i]; + return 0; +} + +#ifdef STANDALONE +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#define MLEN 59 +#define NTESTS 10000 + +int64_t timing_overhead; +#ifdef DBENCH +int64_t *tred, *tadd, *tmul, *tround, *tsample, *tpack, *tshake; +#endif + +static int cmp_llu(const void *a, const void*b) +{ + if(*(int64_t *)a < *(int64_t *)b) return -1; + if(*(int64_t *)a > *(int64_t *)b) return 1; + return 0; +} + +static int64_t median(int64_t *l, size_t llen) +{ + qsort(l,llen,sizeof(uint64_t),cmp_llu); + + if(llen%2) return l[llen/2]; + else return (l[llen/2-1]+l[llen/2])/2; +} + +static int64_t average(int64_t *t, size_t tlen) +{ + uint64_t acc=0; + size_t i; + for(i=0;i + +#ifndef CPUCYCLES_H +#define CPUCYCLES_H + +#ifdef DBENCH +#define DBENCH_START() uint64_t time = cpucycles_start() +#define DBENCH_STOP(t) t += cpucycles_stop() - time - timing_overhead +#else +#define DBENCH_START() +#define DBENCH_STOP(t) +#endif + +#ifdef USE_RDPMC /* Needs echo 2 > /sys/devices/cpu/rdpmc */ +#ifdef SERIALIZE_RDC + +static inline uint64_t cpucycles_start(void) { + const uint32_t ecx = (1U << 30) + 1; + uint64_t result; + + asm volatile("cpuid; movl %1,%%ecx; rdpmc; shlq $32,%%rdx; orq %%rdx,%%rax" + : "=&a" (result) : "r" (ecx) : "rbx", "rcx", "rdx"); + + return result; +} + +static inline uint64_t cpucycles_stop(void) { + const uint32_t ecx = (1U << 30) + 1; + uint64_t result, dummy; + + asm volatile("rdpmc; shlq $32,%%rdx; orq %%rdx,%%rax; movq %%rax,%0; cpuid" + : "=&r" (result), "=c" (dummy) : "c" (ecx) : "rax", "rbx", "rdx"); + + return result; +} + +#else + +static inline uint64_t cpucycles_start(void) { + const uint32_t ecx = (1U << 30) + 1; + uint64_t result; + + asm volatile("rdpmc; shlq $32,%%rdx; orq %%rdx,%%rax" + : "=a" (result) : "c" (ecx) : "rdx"); + + return result; +} + +static inline uint64_t cpucycles_stop(void) { + const uint32_t ecx = (1U << 30) + 1; + uint64_t result; + + asm volatile("rdpmc; shlq $32,%%rdx; orq %%rdx,%%rax" + : "=a" (result) : "c" (ecx) : "rdx"); + + return result; +} + +#endif +#else +#ifdef SERIALIZE_RDC + +static inline uint64_t cpucycles_start(void) { + uint64_t result; + + asm volatile("cpuid; rdtsc; shlq $32,%%rdx; orq %%rdx,%%rax" + : "=a" (result) : : "%rbx", "%rcx", "%rdx"); + + return result; +} + +static inline uint64_t cpucycles_stop(void) { + uint64_t result; + + asm volatile("rdtscp; shlq $32,%%rdx; orq %%rdx,%%rax; mov %%rax,%0; cpuid" + : "=r" (result) : : "%rax", "%rbx", "%rcx", "%rdx"); + + return result; +} + +#else + +static inline uint64_t cpucycles_start(void) { + uint64_t result; + + asm volatile("rdtsc; shlq $32,%%rdx; orq %%rdx,%%rax" + : "=a" (result) : : "%rdx"); + + return result; +} + +static inline uint64_t cpucycles_stop(void) { + uint64_t result; + + asm volatile("rdtsc; shlq $32,%%rdx; orq %%rdx,%%rax" + : "=a" (result) : : "%rdx"); + + return result; +} + +#endif +#endif + +int64_t cpucycles_overhead(void); + +#endif + +#ifndef FIPS202_H +#define FIPS202_H + + +#define SHAKE128_RATE 168 +#define SHAKE256_RATE 136 + +void shake128_absorb(uint64_t *s, + const uint8_t *input, + int32_t inlen); + +void shake128_squeezeblocks(uint8_t *output, + int32_t nblocks, + uint64_t *s); + +void shake256_absorb(uint64_t *s, + const uint8_t *input, + int32_t inlen); + +void shake256_squeezeblocks(uint8_t *output, + int32_t nblocks, + uint64_t *s); + +void shake128(uint8_t *output, + int32_t outlen, + const uint8_t *input, + int32_t inlen); + +void shake256(uint8_t *output, + int32_t outlen, + const uint8_t *input, + int32_t inlen); + +#endif + +#ifndef PARAMS_H +#define PARAMS_H + +#ifndef MODE +#define MODE 2 +#endif + +#define SEEDBYTES 32U +#define CRHBYTES 48U +#define N 256U +#define Q 8380417U +#define QBITS 23U +#define ROOT_OF_UNITY 1753U +#define D 14U +#define GAMMA1 ((Q - 1U)/16U) +#define GAMMA2 (GAMMA1/2U) +#define ALPHA (2U*GAMMA2) + +#if MODE == 0 +#define K 3U +#define L 2U +#define ETA 7U +#define SETABITS 4U +#define BETA 375U +#define OMEGA 64U + +#elif MODE == 1 +#define K 4U +#define L 3U +#define ETA 6U +#define SETABITS 4U +#define BETA 325U +#define OMEGA 80U + +#elif MODE == 2 +#define K 5U +#define L 4U +#define ETA 5U +#define SETABITS 4U +#define BETA 275U +#define OMEGA 96U + +#elif MODE == 3 +#define K 6U +#define L 5U +#define ETA 3U +#define SETABITS 3U +#define BETA 175U +#define OMEGA 120U + +#endif + +#define POL_SIZE_PACKED ((N*QBITS)/8) +#define POLT1_SIZE_PACKED ((N*(QBITS - D))/8) +#define POLT0_SIZE_PACKED ((N*D)/8) +#define POLETA_SIZE_PACKED ((N*SETABITS)/8) +#define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) +#define POLW1_SIZE_PACKED ((N*4)/8) +#define POLVECK_SIZE_PACKED (K*POL_SIZE_PACKED) +#define POLVECL_SIZE_PACKED (L*POL_SIZE_PACKED) + +#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) +#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) +#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) + +#endif +#ifndef POLY_H +#define POLY_H + +//#include +//#include "params.h" +//#include "fips202.h" + +typedef struct { + uint32_t coeffs[N]; +} poly __attribute__((aligned(32))); + +void poly_reduce(poly *a); +void poly_csubq(poly *a); +void poly_freeze(poly *a); + +void poly_add(poly *c, const poly *a, const poly *b); +void poly_sub(poly *c, const poly *a, const poly *b); +void poly_neg(poly *a); +void poly_shiftl(poly *a, uint32_t k); + +void poly_ntt(poly *a); +void poly_invntt_montgomery(poly *a); +void poly_pointwise_invmontgomery(poly *c, const poly *a, const poly *b); + +void poly_power2round(poly *a1, poly *a0, const poly *a); +void poly_decompose(poly *a1, poly *a0, const poly *a); +uint32_t poly_make_hint(poly *h, const poly *a, const poly *b); +void poly_use_hint(poly *a, const poly *b, const poly *h); + +int poly_chknorm(const poly *a, uint32_t B); +void poly_uniform(poly *a, const uint8_t *buf); +void poly_uniform_eta(poly *a, + const uint8_t seed[SEEDBYTES], + uint8_t nonce); +void poly_uniform_gamma1m1(poly *a, + const uint8_t seed[SEEDBYTES + CRHBYTES], + uint16_t nonce); + +void polyeta_pack(uint8_t *r, const poly *a); +void polyeta_unpack(poly *r, const uint8_t *a); + +void polyt1_pack(uint8_t *r, const poly *a); +void polyt1_unpack(poly *r, const uint8_t *a); + +void polyt0_pack(uint8_t *r, const poly *a); +void polyt0_unpack(poly *r, const uint8_t *a); + +void polyz_pack(uint8_t *r, const poly *a); +void polyz_unpack(poly *r, const uint8_t *a); + +void polyw1_pack(uint8_t *r, const poly *a); +#endif +#ifndef POLYVEC_H +#define POLYVEC_H + +//#include +//#include "params.h" +//#include "poly.h" + +/* Vectors of polynomials of length L */ +typedef struct { + poly vec[L]; +} polyvecl; + +void polyvecl_freeze(polyvecl *v); + +void polyvecl_add(polyvecl *w, const polyvecl *u, const polyvecl *v); + +void polyvecl_ntt(polyvecl *v); +void polyvecl_pointwise_acc_invmontgomery(poly *w, + const polyvecl *u, + const polyvecl *v); + +int polyvecl_chknorm(const polyvecl *v, uint32_t B); + + + +/* Vectors of polynomials of length K */ +typedef struct { + poly vec[K]; +} polyveck; + +void polyveck_reduce(polyveck *v); +void polyveck_csubq(polyveck *v); +void polyveck_freeze(polyveck *v); + +void polyveck_add(polyveck *w, const polyveck *u, const polyveck *v); +void polyveck_sub(polyveck *w, const polyveck *u, const polyveck *v); +void polyveck_shiftl(polyveck *v, uint32_t k); + +void polyveck_ntt(polyveck *v); +void polyveck_invntt_montgomery(polyveck *v); + +int polyveck_chknorm(const polyveck *v, uint32_t B); + +void polyveck_power2round(polyveck *v1, polyveck *v0, const polyveck *v); +void polyveck_decompose(polyveck *v1, polyveck *v0, const polyveck *v); +uint32_t polyveck_make_hint(polyveck *h, + const polyveck *u, + const polyveck *v); +void polyveck_use_hint(polyveck *w, const polyveck *v, const polyveck *h); + +#endif + +#ifndef NTT_H +#define NTT_H + +//#include +//#include "params.h" + +void ntt(uint32_t p[N]); +void invntt_frominvmont(uint32_t p[N]); + +#endif +#ifndef PACKING_H +#define PACKING_H + +//#include "params.h" +//#include "polyvec.h" + +void pack_pk(uint8_t pk[CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], const polyveck *t1); +void pack_sk(uint8_t sk[CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], + const polyvecl *s1, + const polyveck *s2, + const polyveck *t0); +void pack_sig(uint8_t sig[CRYPTO_BYTES], + const polyvecl *z, const polyveck *h, const poly *c); + +void unpack_pk(uint8_t rho[SEEDBYTES], polyveck *t1, + const uint8_t pk[CRYPTO_PUBLICKEYBYTES]); +void unpack_sk(uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], + polyvecl *s1, + polyveck *s2, + polyveck *t0, + const uint8_t sk[CRYPTO_SECRETKEYBYTES]); +int unpack_sig(polyvecl *z, polyveck *h, poly *c, + const uint8_t sig[CRYPTO_BYTES]); + +#endif +#ifndef REDUCE_H +#define REDUCE_H + +//#include + +#define MONT 4193792U // 2^32 % Q +#define QINV 4236238847U // -q^(-1) mod 2^32 + +/* a <= Q*2^32 => r < 2*Q */ +uint32_t montgomery_reduce(uint64_t a); + +/* r < 2*Q */ +uint32_t reduce32(uint32_t a); + +/* a < 2*Q => r < Q */ +uint32_t csubq(uint32_t a); + +/* r < Q */ +uint32_t freeze(uint32_t a); + +#endif +#ifndef ROUNDING_H +#define ROUNDING_H + +//#include + +uint32_t power2round(const uint32_t a, uint32_t *a0); +uint32_t decompose(uint32_t a, uint32_t *a0); +uint32_t make_hint(const uint32_t a, const uint32_t b); +uint32_t use_hint(const uint32_t a, const uint32_t hint); + +#endif +#ifndef SIGN_H +#define SIGN_H + +//#include "params.h" +//#include "poly.h" +//#include "polyvec.h" + +void expand_mat(polyvecl mat[K], const uint8_t rho[SEEDBYTES]); +void challenge(poly *c, const uint8_t mu[CRHBYTES], + const polyveck *w1); + +int crypto_sign_keypair(uint8_t *pk, uint8_t *sk); + +int crypto_sign(uint8_t *sm, int32_t *smlen, + const uint8_t *msg, int32_t len, + const uint8_t *sk); + +int crypto_sign_open(uint8_t *m, int32_t *mlen, + const uint8_t *sm, int32_t smlen, + const uint8_t *pk); + +#endif + +#ifndef API_H +#define API_H + +#ifndef MODE +#define MODE 2 +#endif + +#if MODE == 0 +#if CRYPTO_PUBLICKEYBYTES -896U +CRYPTO_PUBLICKEYBYTES size error +#endif +#if CRYPTO_SECRETKEYBYTES -2096U +CRYPTO_SECRETKEYBYTES size error +#endif +#if CRYPTO_BYTES -1387U +CRYPTO_BYTES size error +#endif + +#elif MODE == 1 +#if CRYPTO_PUBLICKEYBYTES -1184U +CRYPTO_PUBLICKEYBYTES size error +#endif +#if CRYPTO_SECRETKEYBYTES -2800U +CRYPTO_SECRETKEYBYTES size error +#endif +#if CRYPTO_BYTES -2044U +CRYPTO_BYTES size error +#endif + +#elif MODE == 2 +#if CRYPTO_PUBLICKEYBYTES -1472U +CRYPTO_PUBLICKEYBYTES size error +#endif +#if CRYPTO_SECRETKEYBYTES -3504U +CRYPTO_SECRETKEYBYTES size error +#endif +#if CRYPTO_BYTES -2701U +CRYPTO_BYTES size error +#endif + +#elif MODE == 3 +#if CRYPTO_PUBLICKEYBYTES -1760U +CRYPTO_PUBLICKEYBYTES size error +#endif +#if CRYPTO_SECRETKEYBYTES -3856U +CRYPTO_SECRETKEYBYTES size error +#endif +#if CRYPTO_BYTES -3366U +CRYPTO_BYTES size error +#endif + +#endif + +#define CRYPTO_ALGNAME "Dilithium" + +int crypto_sign_keypair(uint8_t *pk, uint8_t *sk); + +int crypto_sign(uint8_t *sm, int32_t *smlen, + const uint8_t *msg, int32_t len, + const uint8_t *sk); + +int crypto_sign_open(uint8_t *m, int32_t *mlen, + const uint8_t *sm, int32_t smlen, + const uint8_t *pk); + +#endif diff --git a/src/cc/makecclib b/src/cc/makecclib index f4d2bd01b..adac757c3 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,2 +1,2 @@ #!/bin/sh -gcc -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index bd3d74a95..6dbab482a 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -659,12 +659,12 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, partialsig")); } -int testmain(void); +//int testmain(void); UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; UniValue result(UniValue::VOBJ); int32_t i,n; uint8_t msg[32],musig64[64]; secp256k1_pubkey combined_pk; secp256k1_schnorrsig musig; char str[129]; - testmain(); + //testmain(); if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) From ad439274bd21d003280c35468f937ef152ceac35 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 21:07:37 -1100 Subject: [PATCH 2591/3904] include --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 84f229069..c7372907e 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -581,7 +581,7 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" #include "musig.cpp" -#inclide "dilithium.c" +#include "dilithium.c" //#include "../secp256k1/src/modules/musig/example.c" #endif From fc0b7b15c8f46618794734d27449f031acc8f34c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 21:16:25 -1100 Subject: [PATCH 2592/3904] Revert to boost 1.66 --- depends/packages/boost.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 7a0439ba7..3c180b0ce 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,8 +1,8 @@ package=boost -$(package)_version=1_69_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.69.0/source +$(package)_version=1_66_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.66.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 +$(package)_sha256_hash=5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9 define $(package)_set_vars $(package)_config_opts_release=variant=release From 33f126914ed4152f7832c660299980af972b847c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 21:45:03 -1100 Subject: [PATCH 2593/3904] Dilithium key pair --- src/cc/cclib.cpp | 33 +++++++++++++++++++++++++++++++++ src/cc/dilithium.c | 39 +++++++++++++++++++++++++++++++++++++++ src/cc/dilithium.h | 9 +++++---- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c7372907e..46a5f4736 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -37,6 +37,7 @@ std::string MYCCLIBNAME = (char *)"rogue"; #define EVAL_SUDOKU 17 #define EVAL_MUSIG 18 +#define EVAL_DILITHIUM 19 std::string MYCCLIBNAME = (char *)"sudoku"; #endif @@ -80,6 +81,11 @@ CClib_methods[] = { (char *)"musig", (char *)"verify", (char *)"msg sig pubkey", 3, 3, 'V', EVAL_MUSIG }, { (char *)"musig", (char *)"send", (char *)"combined_pk amount", 2, 2, 'x', EVAL_MUSIG }, { (char *)"musig", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_MUSIG }, + { (char *)"dilithium", (char *)"keypair", (char *)"", 0, 0, 'K', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"sign", (char *)"msg privkey", 2, 2, 'S', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"verify", (char *)"msg sig pubtxid", 3, 3, 'V', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"send", (char *)"pubtxid amount", 2, 2, 'x', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_DILITHIUM }, #endif }; @@ -119,6 +125,13 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); + +UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); + #endif cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be freed by caller @@ -243,6 +256,26 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(result); } } + else if ( cp->evalcode == EVAL_DILITHIUM ) + { + if ( strcmp(method,"send") == 0 ) + return(dilithium_send(txfee,cp,params)); + else if ( strcmp(method,"spend") == 0 ) + return(dilithium_spend(txfee,cp,params)); + else if ( strcmp(method,"keypair") == 0 ) + return(dilithium_keypair(txfee,cp,params)); + else if ( strcmp(method,"sign") == 0 ) + return(dilithium_sign(txfee,cp,params)); + else if ( strcmp(method,"verify") == 0 ) + return(dilithium_verify(txfee,cp,params)); + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid dilithium method")); + result.push_back(Pair("method",method)); + return(result); + } + } #endif else { diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index b6624353e..902a3ca49 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2835,3 +2835,42 @@ int32_t main(void) } #endif +UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); uint8_t pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i; + dilithium_keypair(pk,sk); + for (i=0; i +/* #ifndef CPUCYCLES_H #define CPUCYCLES_H @@ -11,7 +12,7 @@ #define DBENCH_STOP(t) #endif -#ifdef USE_RDPMC /* Needs echo 2 > /sys/devices/cpu/rdpmc */ +#ifdef USE_RDPMC // Needs echo 2 > /sys/devices/cpu/rdpmc #ifdef SERIALIZE_RDC static inline uint64_t cpucycles_start(void) { @@ -103,7 +104,7 @@ static inline uint64_t cpucycles_stop(void) { int64_t cpucycles_overhead(void); -#endif +#endif*/ #ifndef FIPS202_H #define FIPS202_H @@ -144,7 +145,7 @@ void shake256(uint8_t *output, #define PARAMS_H #ifndef MODE -#define MODE 2 +#define MODE 3 #endif #define SEEDBYTES 32U @@ -410,7 +411,7 @@ int crypto_sign_open(uint8_t *m, int32_t *mlen, #define API_H #ifndef MODE -#define MODE 2 +#define MODE 3 #endif #if MODE == 0 From 3846555d1914b38bb95455e3e2143bc1b427252f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 21:46:51 -1100 Subject: [PATCH 2594/3904] Dbench start/stop --- src/cc/dilithium.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 902a3ca49..6a7f90d83 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -6,6 +6,10 @@ * by Gilles Van Assche, Daniel J. Bernstein, and Peter Schwabe */ #include + +#define DBENCH_START() +#define DBENCH_STOP() + #include "dilithium.h" From 54e28a8ebf715800b4d3436a1adf445f07760070 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Feb 2019 21:48:26 -1100 Subject: [PATCH 2595/3904] Arg --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 6a7f90d83..cfe3b253f 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -8,7 +8,7 @@ #include #define DBENCH_START() -#define DBENCH_STOP() +#define DBENCH_STOP(arg) #include "dilithium.h" From 99f94425ebc6d1b1eedaaf50cb871092f97fc09e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 03:18:52 -1100 Subject: [PATCH 2596/3904] +prints --- src/cc/dilithium.c | 22 ++++++++++++---------- src/cc/rogue_rpc.cpp | 9 ++++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index cfe3b253f..9103a6037 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2426,7 +2426,7 @@ void challenge(poly *c, } /************************************************* -* Name: dilithium_keypair +* Name: _dilithium_keypair * * Description: Generates public and private key. * @@ -2437,7 +2437,7 @@ void challenge(poly *c, * * Returns 0 (success) **************************************************/ -int dilithium_keypair(uint8_t *pk, uint8_t *sk) { +int _dilithium_keypair(uint8_t *pk, uint8_t *sk) { uint32_t i; uint8_t seedbuf[3*SEEDBYTES]; uint8_t tr[CRHBYTES]; @@ -2488,7 +2488,7 @@ int dilithium_keypair(uint8_t *pk, uint8_t *sk) { } /************************************************* -* Name: dilithium_sign +* Name: _dilithium_sign * * Description: Compute signed message. * @@ -2503,7 +2503,7 @@ int dilithium_keypair(uint8_t *pk, uint8_t *sk) { * * Returns 0 (success) **************************************************/ -int dilithium_sign(uint8_t *sm, +int _dilithium_sign(uint8_t *sm, int32_t *smlen, const uint8_t *m, int32_t mlen, @@ -2613,7 +2613,7 @@ int dilithium_sign(uint8_t *sm, } /************************************************* -* Name: dilithium_verify +* Name: _dilithium_verify * * Description: Verify signed message. * @@ -2626,7 +2626,7 @@ int dilithium_sign(uint8_t *sm, * * Returns 0 if signed message could be verified correctly and -1 otherwise **************************************************/ -int dilithium_verify(uint8_t *m, +int _dilithium_verify(uint8_t *m, int32_t *mlen, const uint8_t *sm, int32_t smlen, @@ -2785,7 +2785,7 @@ int32_t main(void) tkeygen[i] = cpucycles_start(); #endif - dilithium_keypair(pk, sk); // 1.3 + _dilithium_keypair(pk, sk); // 1.3 #ifdef DBENCH tkeygen[i] = cpucycles_stop() - tkeygen[i] - timing_overhead; // tred = tadd = tmul = tround = tsample = tpack = tshake = &dummy; @@ -2793,13 +2793,13 @@ int32_t main(void) #endif randombytes(m, MLEN); // 1.27 - dilithium_sign(sm, &smlen, m, MLEN, sk); // 7.2 + _dilithium_sign(sm, &smlen, m, MLEN, sk); // 7.2 #ifdef DBENCH tsign[i] = cpucycles_stop() - tsign[i] - timing_overhead; tverify[i] = cpucycles_start(); #endif - ret = dilithium_verify(m2, &mlen, sm, smlen, pk); + ret = _dilithium_verify(m2, &mlen, sm, smlen, pk); #ifdef DBENCH tverify[i] = cpucycles_stop() - tverify[i] - timing_overhead; #endif @@ -2842,7 +2842,7 @@ int32_t main(void) UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); uint8_t pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i; - dilithium_keypair(pk,sk); + _dilithium_keypair(pk,sk); for (i=0; i>16,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); + *numkeysp = numkeys; + return(keystrokes); } else num = 0; } else fprintf(stderr,"extractgame: couldnt find baton\n"); } else fprintf(stderr,"extractgame: invalid game\n"); - *numkeysp = numkeys; - return(keystrokes); + return(0); } UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) From 504fed539e7b2d8759ebf72d13a4e1469affa649 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 03:30:44 -1100 Subject: [PATCH 2597/3904] +prints --- src/cc/rogue_rpc.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index edac1d813..fd068aca4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -890,8 +890,15 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto *numkeysp = numkeys; return(keystrokes); } else num = 0; - } else fprintf(stderr,"extractgame: couldnt find baton\n"); + } + else + { + fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p\n",keystrokes); + if ( keystrokes != 0 ) + free(keystrokes), keystrokes = 0; + } } else fprintf(stderr,"extractgame: invalid game\n"); + fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); return(0); } @@ -1248,6 +1255,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp //fprintf(stderr,"call extractgame\n"); if ( (keystrokes= rogue_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { + fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); //fprintf(stderr,"extracted.(%s)\n",str); if ( newdata == playerdata ) @@ -1273,6 +1281,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } + fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); return(-1); } From 348d6df6a520382ef91be6e94d93e7dd60579865 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 03:40:13 -1100 Subject: [PATCH 2598/3904] -print --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index fd068aca4..5aa5b3a8d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -898,7 +898,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto free(keystrokes), keystrokes = 0; } } else fprintf(stderr,"extractgame: invalid game\n"); - fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); + //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); return(0); } @@ -1255,7 +1255,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp //fprintf(stderr,"call extractgame\n"); if ( (keystrokes= rogue_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { - fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); + //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); //fprintf(stderr,"extracted.(%s)\n",str); if ( newdata == playerdata ) @@ -1281,7 +1281,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } - fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); + //fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); return(-1); } From 09b5de739be060ae95474754497e4749adc65cfe Mon Sep 17 00:00:00 2001 From: CHMEX <33424502+CHMEX@users.noreply.github.com> Date: Sat, 23 Feb 2019 16:11:56 +0100 Subject: [PATCH 2599/3904] OUR OUR is notarized but missing. --- src/assetchains.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 1b23bc616..91baf9829 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -224,5 +224,21 @@ "addnode": [ "37.187.225.231" ] - } + }, + { + "ac_name": "OUR", + "ac_reward": "1478310502", + "ac_halving": "525600", + "ac_cc": "42", + "ac_supply": "100000000", + "ac_perc": "77700", + "ac_staked": "93", + "ac_pubkey": "02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c", + "ac_public": "1", + "addnode": [ + "51.255.195.65", + "217.182.129.38", + "95.216.150.177" + ] +} ] From 1b5d9b5032f41422113868eca35d182c07529f7e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Feb 2019 23:24:17 +0800 Subject: [PATCH 2600/3904] show --- src/cc/musig.cpp | 106 +++++++++++++--------- src/musigtest.py | 189 +++++++++++++++++++++++++++++++++++++++ src/wallet/rpcwallet.cpp | 8 +- 3 files changed, 255 insertions(+), 48 deletions(-) create mode 100755 src/musigtest.py diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index bd3d74a95..cdf53be09 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -89,7 +89,7 @@ the "msg" is what needs to be signed to create a valid spend "numsigners": 2, "commitment": "bbea1f2562eca01b9a1393c5dc188bdd44551aebf684f4459930f59dde01f7ae", "result": "success" - } +} on node with pubkey: 0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4 ./komodo-cli -ac_name=MUSIG cclib session 18 '[1,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]' @@ -221,7 +221,9 @@ struct musig_info secp256k1_musig_partial_signature *partial_sig; //[N_SIGNERS]; int32_t myind,num; uint8_t msg[32],pkhash[32],combpk[33]; -} *MUSIG; +}; + +std::vector MUSIG; struct musig_info *musig_infocreate(int32_t myind,int32_t num) { @@ -431,14 +433,15 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) num = juint(jitem(params,1),0); if ( myind < 0 || myind >= num || num <= 0 ) return(cclib_error(result,"illegal myindex and numsigners")); - if ( MUSIG != 0 ) - musig_infofree(MUSIG), MUSIG = 0; - MUSIG = musig_infocreate(myind,num); - if ( musig_parsepubkey(ctx,MUSIG->combined_pk,jitem(params,2)) < 0 ) + //if ( MUSIG[myind] != 0 ) + // musig_infofree(MUSIG[myind]), MUSIG[myind] = 0; + struct musig_info *temp_musig = musig_infocreate(myind,num); + MUSIG.push_back(temp_musig); + if ( musig_parsepubkey(ctx,MUSIG[myind]->combined_pk,jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing combined_pubkey")); - else if ( musig_parsehash(MUSIG->pkhash,jitem(params,3),32) < 0 ) + else if ( musig_parsehash(MUSIG[myind]->pkhash,jitem(params,3),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( musig_parsehash(MUSIG->msg,jitem(params,4),32) < 0 ) + else if ( musig_parsehash(MUSIG[myind]->msg,jitem(params,4),32) < 0 ) return(cclib_error(result,"error parsing msg")); Myprivkey(privkey); GetRandBytes(session,32); @@ -468,13 +471,13 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * my_index: index of this signer in the signers array * seckey: the signer's 32-byte secret key (cannot be NULL) */ - if ( secp256k1_musig_session_initialize(ctx,&MUSIG->session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) + if ( secp256k1_musig_session_initialize(ctx,&MUSIG[myind]->session,MUSIG[myind]->signer_data, &MUSIG[myind]->nonce_commitments[MUSIG[myind]->myind * 32],session,MUSIG[myind]->msg,&MUSIG[myind]->combined_pk,MUSIG[myind]->pkhash,MUSIG[myind]->num,MUSIG[myind]->myind,privkey) > 0 ) { memset(session,0,sizeof(session)); result.push_back(Pair("myind",(int64_t)myind)); result.push_back(Pair("numsigners",(int64_t)num)); for (i=0; i<32; i++) - sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitments[MUSIG->myind*32 + i]); + sprintf(&str[i<<1],"%02x",MUSIG[myind]->nonce_commitments[MUSIG[myind]->myind*32 + i]); str[64] = 0; result.push_back(Pair("commitment",str)); result.push_back(Pair("result","success")); @@ -492,18 +495,20 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; size_t clen = CPubKey::PUBLIC_KEY_SIZE; - UniValue result(UniValue::VOBJ); int32_t i,n,ind; uint8_t pkhash[32]; CPubKey pk; char str[67]; + UniValue result(UniValue::VOBJ); int32_t i,n,ind,myind; uint8_t pkhash[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 4 ) { - if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) + if ( (myind= juint(jitem(params,0),0)) < 0 ) + return(cclib_error(result,"myind is wrong")); + if ( musig_parsehash(pkhash,jitem(params,1),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG[myind]->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); - else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + else if ( (ind= juint(jitem(params,2),0)) < 0 || ind >= MUSIG[myind]->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash(&MUSIG->nonce_commitments[ind*32],jitem(params,2),32) < 0 ) + else if ( musig_parsehash(&MUSIG[myind]->nonce_commitments[ind*32],jitem(params,3),32) < 0 ) return(cclib_error(result,"error parsing commitment")); /** Gets the signer's public nonce given a list of all signers' data with commitments * @@ -521,14 +526,15 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * number of signers participating in the MuSig. */ result.push_back(Pair("added_index",ind)); - if ( secp256k1_musig_session_get_public_nonce(ctx,&MUSIG->session,MUSIG->signer_data,&MUSIG->nonces[MUSIG->myind],MUSIG->commitment_ptrs,MUSIG->num) > 0 ) + fprintf(stderr, "COMMIT: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); + if ( secp256k1_musig_session_get_public_nonce(ctx,&MUSIG[myind]->session,MUSIG[myind]->signer_data,&MUSIG[myind]->nonces[MUSIG[myind]->myind],MUSIG[myind]->commitment_ptrs,MUSIG[myind]->num) > 0 ) { - if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG->nonces[MUSIG->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) + if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG[myind]->nonces[MUSIG[myind]->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) { for (i=0; i<33; i++) sprintf(&str[i<<1],"%02x",((uint8_t *)pk.begin())[i]); str[66] = 0; - result.push_back(Pair("myind",MUSIG->myind)); + result.push_back(Pair("myind",MUSIG[myind]->myind)); result.push_back(Pair("nonce",str)); result.push_back(Pair("result","success")); } else return(cclib_error(result,"error serializing nonce (pubkey)")); @@ -539,26 +545,29 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","success")); } return(result); - } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, commitment")); + } else return(cclib_error(result,"wrong number of params, need 4: myind, pkhash, ind, commitment")); } UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t i,n,ind; uint8_t pkhash[32],psig[32]; CPubKey pk; char str[67]; + UniValue result(UniValue::VOBJ); int32_t i,n,ind,myind; uint8_t pkhash[32],psig[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 4 ) { - if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) + if ( (myind= juint(jitem(params,0),0)) < 0 ) + return(cclib_error(result,"myind is wrong")); + if ( musig_parsehash(pkhash,jitem(params,1),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG[myind]->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); - else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + else if ( (ind= juint(jitem(params,2),0)) < 0 || ind >= MUSIG[myind]->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsepubkey(ctx,MUSIG->nonces[ind],jitem(params,2)) < 0 ) + else if ( musig_parsepubkey(ctx,MUSIG[myind]->nonces[ind],jitem(params,3)) < 0 ) return(cclib_error(result,"error parsing nonce")); result.push_back(Pair("added_index",ind)); + fprintf(stderr, "NONCE: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); /** Checks a signer's public nonce against a commitment to said nonce, and update * data structure if they match * @@ -569,10 +578,16 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * been used with `musig_session_get_public_nonce` or initialized * with `musig_session_initialize_verifier`. * In: nonce: signer's alleged public nonce (cannot be NULL) - */ - for (i=0; inum; i++) + * + if ( ind != MUSIG[myind]->num-1 ) { - if ( secp256k1_musig_set_nonce(ctx,&MUSIG->signer_data[i],&MUSIG->nonces[i]) == 0 ) + fprintf(stderr, "ind.%i MUSIG[myind]->num.%i\n", ind, MUSIG[myind]->num); + return(cclib_error(result,"need rest of nonce's to continue")); + }*/ + for (i=0; inum; i++) + { + fprintf(stderr, "setting nonce for index.%i\n",i); + if ( secp256k1_musig_set_nonce(ctx,&MUSIG[myind]->signer_data[i],&MUSIG[myind]->nonces[i]) == 0 ) return(cclib_error(result,"error setting nonce")); } /** Updates a session with the combined public nonce of all signers. The combined @@ -593,45 +608,48 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * adaptor: point to add to the combined public nonce. If NULL, nothing is * added to the combined nonce. */ - if ( secp256k1_musig_session_combine_nonces(ctx,&MUSIG->session,MUSIG->signer_data,MUSIG->num,NULL,NULL) > 0 ) + if ( secp256k1_musig_session_combine_nonces(ctx,&MUSIG[myind]->session,MUSIG[myind]->signer_data,MUSIG[myind]->num,NULL,NULL) > 0 ) { - if ( secp256k1_musig_partial_sign(ctx,&MUSIG->session,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + if ( secp256k1_musig_partial_sign(ctx,&MUSIG[myind]->session,&MUSIG[myind]->partial_sig[MUSIG[myind]->myind]) > 0 ) { - if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG[myind]->partial_sig[MUSIG[myind]->myind]) > 0 ) { for (i=0; i<32; i++) sprintf(&str[i<<1],"%02x",psig[i]); str[64] = 0; - result.push_back(Pair("myind",MUSIG->myind)); + result.push_back(Pair("myind",MUSIG[myind]->myind)); result.push_back(Pair("partialsig",str)); result.push_back(Pair("result","success")); return(result); } else return(cclib_error(result,"error serializing partial sig")); } else return(cclib_error(result,"error making partial sig")); } else return(cclib_error(result,"error combining nonces")); - } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, nonce")); + } else return(cclib_error(result,"wrong number of params, need 4: myind, pkhash, ind, nonce")); } UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t i,ind,n; uint8_t pkhash[32],psig[32],out64[64]; char str[129]; secp256k1_schnorrsig sig; + UniValue result(UniValue::VOBJ); int32_t i,ind,myind,n; uint8_t pkhash[32],psig[32],out64[64]; char str[129]; secp256k1_schnorrsig sig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 4 ) { - if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) + if ( (myind= juint(jitem(params,0),0)) < 0 ) + return(cclib_error(result,"myind is wrong")); + if ( musig_parsehash(pkhash,jitem(params,1),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG[myind]->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); - else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + else if ( (ind= juint(jitem(params,2),0)) < 0 || ind >= MUSIG[myind]->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash(psig,jitem(params,2),32) < 0 ) + else if ( musig_parsehash(psig,jitem(params,3),32) < 0 ) return(cclib_error(result,"error parsing psig")); - else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG->partial_sig[ind],psig) == 0 ) + else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG[myind]->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); result.push_back(Pair("added_index",ind)); - if ( secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) + fprintf(stderr, "PARTIALSIG: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); + if ( secp256k1_musig_partial_sig_combine(ctx,&MUSIG[myind]->session,&sig,MUSIG[myind]->partial_sig,MUSIG[myind]->num) > 0 ) { if ( secp256k1_schnorrsig_serialize(ctx,out64,&sig) > 0 ) { @@ -644,7 +662,7 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else { - if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG[myind]->partial_sig[MUSIG[myind]->myind]) > 0 ) { result.push_back(Pair("myind",ind)); for (i=0; i<32; i++) @@ -656,7 +674,7 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"error generating my partialsig")); } return(result); - } else return(cclib_error(result,"wrong number of params, need 3: pkhash, ind, partialsig")); + } else return(cclib_error(result,"wrong number of params, need 4: myind, pkhash, ind, partialsig")); } int testmain(void); diff --git a/src/musigtest.py b/src/musigtest.py new file mode 100755 index 000000000..26f09d588 --- /dev/null +++ b/src/musigtest.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 +import platform +import os +import re +import json +import random +import base58 +import binascii +import hashlib +import sys +import time +from slickrpc import Proxy + +# fucntion to define rpc_connection +def def_credentials(chain): + rpcport = ''; + operating_system = platform.system() + if operating_system == 'Darwin': + ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' + elif operating_system == 'Linux': + ac_dir = os.environ['HOME'] + '/.komodo' + elif operating_system == 'Windows': + ac_dir = '%s/komodo/' % os.environ['APPDATA'] + if chain == 'KMD': + coin_config_file = str(ac_dir + '/komodo.conf') + else: + coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') + with open(coin_config_file, 'r') as f: + for line in f: + l = line.rstrip() + if re.search('rpcuser', l): + rpcuser = l.replace('rpcuser=', '') + elif re.search('rpcpassword', l): + rpcpassword = l.replace('rpcpassword=', '') + elif re.search('rpcport', l): + rpcport = l.replace('rpcport=', '') + if len(rpcport) == 0: + if chain == 'KMD': + rpcport = 7771 + else: + print("rpcport not in conf file, exiting") + print("check " + coin_config_file) + exit(1) + return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport)))) + + +# generate address, validate address, dump private key +def genvaldump(rpc_connection): + # get new address + address = rpc_connection.getnewaddress() + # validate address + validateaddress_result = rpc_connection.validateaddress(address) + pubkey = validateaddress_result['pubkey'] + address = validateaddress_result['address'] + # dump private key for the address + privkey = rpc_connection.dumpprivkey(address) + # function output + output = [pubkey, privkey, address] + return(output) + +CHAIN = 'MUSIG' #sys.argv[1] + +rpc = def_credentials(CHAIN) + +pubkeys = [] +address_info = [] +ret = input('Do you want to generate new pubkeys? ').lower() + +if ret.startswith('y'): + numpks = int(input('Enter number of pubkeys to combine: ')) + if os.path.isfile("list.json"): + print('Already have list.json, move it if you would like to generate a new set.') + sys.exit(0) + while len(address_info) < numpks: + addressinfo = genvaldump(rpc) + address_info.append(addressinfo) + f = open("list.json", "w+") + f.write(json.dumps(address_info)) +else: + if os.path.isfile("list.json"): + with open('list.json') as list: + address_info = json.load(list) + else: + sys.exit('No list.json you need to create new pubkeys!') + +for addressinfo in address_info: + pubkeys.append(addressinfo[0]) + +ret = rpc.setpubkey(pubkeys[0]) +ret = rpc.cclib("combine", "18", str(pubkeys)) +pkhash = str(ret['pkhash']) +combinedpk = str(ret['combined_pk']) +print('Your combined pubkey is: ' + combinedpk) +print('Your pkhash is: ' + pkhash) +amount = int(input('Enter amount to send: ')) +tmp = str([combinedpk, amount]) +hex = rpc.cclib("send", "18", tmp)['hex'] +senttxid = rpc.sendrawtransaction(hex) +print('Your senttxid is: ' + senttxid) + +print("Waiting for tx to be confirmed") +while True: + confirmed = int(rpc.gettransaction(senttxid)["confirmations"]) + if not confirmed: + time.sleep(10) + else: + print('SentTX confirmed') + break + +scriptPubKey = rpc.getrawtransaction(senttxid,1)['vout'][1]['scriptPubKey']['hex'] +print('Your scriptPubKey is: ' + scriptPubKey) +tmp = str([senttxid, scriptPubKey]) +msg = rpc.cclib("calcmsg", "18", tmp)['msg'] +print('Your msg is: ' + msg) + +i = 0; +commitments = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + tmp = str([i, len(pubkeys), combinedpk, pkhash, msg]) + commitments.append(rpc.cclib("session", "18", tmp)['commitment']) + i = i + 1 + +print(commitments) + +i = 0 +nonces = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + n = 0 + for commitment in commitments: + if n == i: + n = n + 1 + continue; + tmp = str([i, pkhash, n, commitment]) + ret = rpc.cclib("commit", "18", tmp) + if len(ret) == 4: + nonces.append(ret['nonce']) + n = n + 1 + i = i + 1 + +print(nonces) + +i = 0 +partialsigs = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + n = 0 + for nonce in nonces: + #if n == i: + # n = n + 1 + # continue; + tmp = str([i, pkhash, n, nonce]) + ret = rpc.cclib("nonce", "18", tmp) + print(ret) + if len(ret) == 4: + partialsigs.append(ret['partialsig']) + n = n + 1 + i = i + 1 + +print(partialsigs) + +i = 0 +combinedsigs = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + n = 0 + for partialsig in partialsigs: + if n == i: + n = n + 1 + continue; + tmp = str([i, pkhash, n, partialsig]) + ret = rpc.cclib("partialsig", "18", tmp) + if len(ret) == 4: + combinedsigs.append(ret['combinedsig']) + n = n + 1 + i = i + 1 + +print(combinedsigs) + +tmp = str([msg, combinedpk, combinedsigs[0]]) +ret = rpc.cclib("verify", "18", tmp) + +print(ret) + +tmp = str([sendtxid, scriptPubKey, combinedsigs[0]]) +ret = rpc.cclib("spend", "18", tmp) + +print(ret) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0ed2f866c..8cffd78f7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5308,8 +5308,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[64]; uint8_t pubkey33[33]; - if ( NOTARY_PUBKEY33[0] == 0 ) - { + //if ( NOTARY_PUBKEY33[0] == 0 ) + //{ if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -5337,14 +5337,14 @@ UniValue setpubkey(const UniValue& params, bool fHelp) USE_EXTERNAL_PUBKEY = 1; } } else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } + /*} else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon, pubkey in use is below.")); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); std::string address_ret; address_ret.assign(Raddress); result.push_back(Pair("address",address_ret)); - } + }*/ result.push_back(Pair("pubkey", NOTARY_PUBKEY)); return result; } From 69a890fe53bfa7d2025b8cebb6d3e5feed164c09 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 04:56:59 -1100 Subject: [PATCH 2601/3904] Seed based dilithium key generation --- src/cc/cclib.cpp | 2 +- src/cc/dilithium.c | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 46a5f4736..4f539b7f9 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -81,7 +81,7 @@ CClib_methods[] = { (char *)"musig", (char *)"verify", (char *)"msg sig pubkey", 3, 3, 'V', EVAL_MUSIG }, { (char *)"musig", (char *)"send", (char *)"combined_pk amount", 2, 2, 'x', EVAL_MUSIG }, { (char *)"musig", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_MUSIG }, - { (char *)"dilithium", (char *)"keypair", (char *)"", 0, 0, 'K', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"keypair", (char *)"[hexseed]", 0, 1, 'K', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"sign", (char *)"msg privkey", 2, 2, 'S', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"verify", (char *)"msg sig pubtxid", 3, 3, 'V', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"send", (char *)"pubtxid amount", 2, 2, 'x', EVAL_DILITHIUM }, diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 9103a6037..10718d1c3 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2437,7 +2437,8 @@ void challenge(poly *c, * * Returns 0 (success) **************************************************/ -int _dilithium_keypair(uint8_t *pk, uint8_t *sk) { +int _dilithium_keypair(uint8_t *pk, uint8_t *sk,uint8_t *privkey) +{ uint32_t i; uint8_t seedbuf[3*SEEDBYTES]; uint8_t tr[CRHBYTES]; @@ -2448,7 +2449,8 @@ int _dilithium_keypair(uint8_t *pk, uint8_t *sk) { polyveck s2, t, t1, t0; /* Expand 32 bytes of randomness into rho, rhoprime and key */ - randombytes(seedbuf, SEEDBYTES); + //randombytes(seedbuf, SEEDBYTES); + memcpy(seedbuf,privkey,SEEDBYTES); shake256(seedbuf, 3*SEEDBYTES, seedbuf, SEEDBYTES); rho = seedbuf; rhoprime = rho + SEEDBYTES; @@ -2841,8 +2843,16 @@ int32_t main(void) UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); uint8_t pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i; - _dilithium_keypair(pk,sk); + UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; + //randombytes(seed,SEEDBYTES); + Myprivkey(seed); + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + { + if ( musig_parsehash(seed,jitem(params,0),32) < 0 ) + return(cclib_error(result,"error parsing seed")); + else externalflag = 1; + } + _dilithium_keypair(pk,sk,seed); for (i=0; i Date: Sat, 23 Feb 2019 05:06:29 -1100 Subject: [PATCH 2602/3904] Pkaddr and skaddr --- src/cc/dilithium.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 10718d1c3..87d55c35d 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2843,7 +2843,7 @@ int32_t main(void) UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; + UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr,str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; //randombytes(seed,SEEDBYTES); Myprivkey(seed); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) @@ -2865,6 +2865,12 @@ UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *para sprintf(&str[i<<1],"%02x",seed[i]); str[i<<1] = 0; result.push_back(Pair("seed",str)); + calc_rmd160_sha256(rmd160,pk,CRYPTO_PUBLICKEYBYTES); + bitcoin_address(coinaddr,38,rmd160,20); + result.push_back(Pair("pkaddr",coinaddr)); + calc_rmd160_sha256(rmd160,sk,CRYPTO_SECRETKEYBYTES); + bitcoin_address(coinaddr,188,rmd160,20); + result.push_back(Pair("skaddr",coinaddr)); if ( externalflag == 0 ) result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); result.push_back(Pair("result","success")); From 6cdadf77f0f9035e8c7b7020930974d4e8a57ddd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 05:07:51 -1100 Subject: [PATCH 2603/3904] define --- src/cc/dilithium.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 87d55c35d..730e76faa 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2841,6 +2841,9 @@ int32_t main(void) } #endif +void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); +char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); + UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr,str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; From d689598506cb4b9770bfe1081316a077d3b5d0eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 05:09:30 -1100 Subject: [PATCH 2604/3904] [64] --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 730e76faa..65c17c8fb 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2846,7 +2846,7 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160, UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr,str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; + UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; //randombytes(seed,SEEDBYTES); Myprivkey(seed); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) From 03920374e4a6ea93530affad1631456ae43271b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 05:12:08 -1100 Subject: [PATCH 2605/3904] Try to map base58 address to P... and S.. --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 65c17c8fb..cfc482290 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2869,10 +2869,10 @@ UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *para str[i<<1] = 0; result.push_back(Pair("seed",str)); calc_rmd160_sha256(rmd160,pk,CRYPTO_PUBLICKEYBYTES); - bitcoin_address(coinaddr,38,rmd160,20); + bitcoin_address(coinaddr,55,rmd160,20); result.push_back(Pair("pkaddr",coinaddr)); calc_rmd160_sha256(rmd160,sk,CRYPTO_SECRETKEYBYTES); - bitcoin_address(coinaddr,188,rmd160,20); + bitcoin_address(coinaddr,63,rmd160,20); result.push_back(Pair("skaddr",coinaddr)); if ( externalflag == 0 ) result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); From b6990f5f5ef7fc5a40251583873c9cda76620bb4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 24 Feb 2019 01:05:18 +0800 Subject: [PATCH 2606/3904] working single node multi sign --- src/cc/musig.cpp | 24 +++++++++++++++++------- src/musigtest.py | 38 ++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index cdf53be09..d50ee92d8 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -525,8 +525,13 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * n_commitments: the length of commitments and signers array. Must be the total * number of signers participating in the MuSig. */ + if ( ind != MUSIG[myind]->num-1 ) + { + //fprintf(stderr, "ind.%i MUSIG[myind]->num.%i\n", ind, MUSIG[myind]->num); + return(cclib_error(result,"need rest of nonce's to continue")); + } result.push_back(Pair("added_index",ind)); - fprintf(stderr, "COMMIT: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); + //fprintf(stderr, "COMMIT: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); if ( secp256k1_musig_session_get_public_nonce(ctx,&MUSIG[myind]->session,MUSIG[myind]->signer_data,&MUSIG[myind]->nonces[MUSIG[myind]->myind],MUSIG[myind]->commitment_ptrs,MUSIG[myind]->num) > 0 ) { if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG[myind]->nonces[MUSIG[myind]->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) @@ -567,7 +572,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) else if ( musig_parsepubkey(ctx,MUSIG[myind]->nonces[ind],jitem(params,3)) < 0 ) return(cclib_error(result,"error parsing nonce")); result.push_back(Pair("added_index",ind)); - fprintf(stderr, "NONCE: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); + //fprintf(stderr, "NONCE: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); /** Checks a signer's public nonce against a commitment to said nonce, and update * data structure if they match * @@ -578,15 +583,15 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * been used with `musig_session_get_public_nonce` or initialized * with `musig_session_initialize_verifier`. * In: nonce: signer's alleged public nonce (cannot be NULL) - * + */ if ( ind != MUSIG[myind]->num-1 ) { - fprintf(stderr, "ind.%i MUSIG[myind]->num.%i\n", ind, MUSIG[myind]->num); + //fprintf(stderr, "ind.%i MUSIG[myind]->num.%i\n", ind, MUSIG[myind]->num); return(cclib_error(result,"need rest of nonce's to continue")); - }*/ + } for (i=0; inum; i++) { - fprintf(stderr, "setting nonce for index.%i\n",i); + //fprintf(stderr, "setting nonce for index.%i\n",i); if ( secp256k1_musig_set_nonce(ctx,&MUSIG[myind]->signer_data[i],&MUSIG[myind]->nonces[i]) == 0 ) return(cclib_error(result,"error setting nonce")); } @@ -648,7 +653,12 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG[myind]->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); result.push_back(Pair("added_index",ind)); - fprintf(stderr, "PARTIALSIG: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); + //fprintf(stderr, "PARTIALSIG: number of MUSIG structs.%li using struct.%i addedindex.%i\n",MUSIG.size(),myind,ind); + if ( ind != MUSIG[myind]->num-1 ) + { + //fprintf(stderr, "ind.%i MUSIG[myind]->num.%i\n", ind, MUSIG[myind]->num); + return(cclib_error(result,"need rest of nonce's to continue")); + } if ( secp256k1_musig_partial_sig_combine(ctx,&MUSIG[myind]->session,&sig,MUSIG[myind]->partial_sig,MUSIG[myind]->num) > 0 ) { if ( secp256k1_schnorrsig_serialize(ctx,out64,&sig) > 0 ) diff --git a/src/musigtest.py b/src/musigtest.py index 26f09d588..9a28bb2d4 100755 --- a/src/musigtest.py +++ b/src/musigtest.py @@ -121,7 +121,7 @@ for pubkey in pubkeys: commitments.append(rpc.cclib("session", "18", tmp)['commitment']) i = i + 1 -print(commitments) +#print(commitments) i = 0 nonces = [] @@ -129,17 +129,16 @@ for pubkey in pubkeys: ret = rpc.setpubkey(pubkey) n = 0 for commitment in commitments: - if n == i: - n = n + 1 - continue; tmp = str([i, pkhash, n, commitment]) ret = rpc.cclib("commit", "18", tmp) - if len(ret) == 4: + try: nonces.append(ret['nonce']) + except: + x = 1 n = n + 1 i = i + 1 -print(nonces) +#print(nonces) i = 0 partialsigs = [] @@ -147,18 +146,17 @@ for pubkey in pubkeys: ret = rpc.setpubkey(pubkey) n = 0 for nonce in nonces: - #if n == i: - # n = n + 1 - # continue; tmp = str([i, pkhash, n, nonce]) ret = rpc.cclib("nonce", "18", tmp) print(ret) - if len(ret) == 4: + try: partialsigs.append(ret['partialsig']) + except: + x = 1 n = n + 1 i = i + 1 -print(partialsigs) +#print(partialsigs) i = 0 combinedsigs = [] @@ -166,24 +164,28 @@ for pubkey in pubkeys: ret = rpc.setpubkey(pubkey) n = 0 for partialsig in partialsigs: - if n == i: - n = n + 1 - continue; tmp = str([i, pkhash, n, partialsig]) ret = rpc.cclib("partialsig", "18", tmp) - if len(ret) == 4: + print(ret) + try: combinedsigs.append(ret['combinedsig']) + except: + x = 1 n = n + 1 i = i + 1 -print(combinedsigs) +#print(combinedsigs) tmp = str([msg, combinedpk, combinedsigs[0]]) ret = rpc.cclib("verify", "18", tmp) -print(ret) +#print(ret) -tmp = str([sendtxid, scriptPubKey, combinedsigs[0]]) +tmp = str([senttxid, scriptPubKey, combinedsigs[0]]) ret = rpc.cclib("spend", "18", tmp) print(ret) + +ret = rpc.sendrawtransaction(ret['hex']) + +print(ret) From d25a12fb8403d1041d9f0f9d9436de2ad9585095 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 24 Feb 2019 00:30:29 +0100 Subject: [PATCH 2607/3904] fix build --- src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index fa2c17b5d..c32551c2c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -578,7 +578,8 @@ komodod_LDADD += libcc.dylib $(LIBSECP256K1) endif if TARGET_WINDOWS komodod_LDADD += libcc.dll $(LIBSECP256K1) -else +endif +if TARGET_LINUX komodod_LDADD += libcc.so $(LIBSECP256K1) endif From 6722c9bc2063b72e2884493a3227741b8ce5418e Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 24 Feb 2019 00:52:39 +0100 Subject: [PATCH 2608/3904] add linux target --- src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index c32551c2c..f06de8910 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,7 +36,8 @@ LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl endif if TARGET_DARWIN LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl -else +endif +if TARGET_LINUX LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl endif From 2968a6b6339d72618549759d444fd707a1dca673 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sun, 24 Feb 2019 00:57:05 +0100 Subject: [PATCH 2609/3904] add linux target --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 9a1a75f53..12256c0cc 100644 --- a/configure.ac +++ b/configure.ac @@ -884,6 +884,7 @@ fi AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin]) AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin]) +AM_CONDITIONAL([TARGET_LINUX], [test x$TARGET_OS = xlinux]) AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows]) AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes]) AM_CONDITIONAL([ENABLE_MINING],[test x$enable_mining = xyes]) From 41c82bee96a9fc6f30f82e0e9d604d80d98d09c3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 24 Feb 2019 11:53:17 +0800 Subject: [PATCH 2610/3904] stop print flood --- src/musigtest.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/musigtest.py b/src/musigtest.py index 9a28bb2d4..0880f1494 100755 --- a/src/musigtest.py +++ b/src/musigtest.py @@ -148,7 +148,6 @@ for pubkey in pubkeys: for nonce in nonces: tmp = str([i, pkhash, n, nonce]) ret = rpc.cclib("nonce", "18", tmp) - print(ret) try: partialsigs.append(ret['partialsig']) except: @@ -166,7 +165,6 @@ for pubkey in pubkeys: for partialsig in partialsigs: tmp = str([i, pkhash, n, partialsig]) ret = rpc.cclib("partialsig", "18", tmp) - print(ret) try: combinedsigs.append(ret['combinedsig']) except: From 74070330f5b68c0e164af1b3e186ce118e7ed3c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 20:31:30 -1100 Subject: [PATCH 2611/3904] Lose 20% gold if killed, remove single player reduction of gold conversion --- src/cc/dilithium.c | 3 +++ src/cc/rogue_rpc.cpp | 29 ++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index cfc482290..996d4f2b1 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2877,6 +2877,7 @@ UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *para if ( externalflag == 0 ) result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); result.push_back(Pair("result","success")); + // make a tx that has pubkey in opreturn return(result); } @@ -2897,11 +2898,13 @@ UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); + // copy musig method return(result); } UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); + // copy musig method return(result); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5aa5b3a8d..8cfb4379f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -882,8 +882,9 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { - fprintf(stderr,"zero value character was killed -> no playerdata\n"); - newdata.resize(0); + //fprintf(stderr,"zero value character was killed -> no playerdata\n"); + //newdata.resize(0); + P.gold = (P.gold * 8) / 10; } sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); @@ -1018,22 +1019,23 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - if ( 0 && (P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0) ) + if ( (P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0) ) { - fprintf(stderr,"zero value character was killed -> no playerdata\n"); - newdata.resize(0); + //fprintf(stderr,"zero value character was killed -> no playerdata\n"); + //newdata.resize(0); + P.gold = (P.gold * 8) / 10; } - else + //else { - if ( maxplayers == 1 ) - mult /= 2; + //if ( maxplayers == 1 ) + // mult /= 2; cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( P.amulet != 0 ) mult *= 5; cashout = (uint64_t)P.gold * mult; + fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( funcid == 'H' && maxplayers > 1 ) { if ( (numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1) && P.amulet == 0 ) @@ -1271,13 +1273,18 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp fprintf(stderr,"%s matched after clearing maxstrength good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); return(0); } - bad++; for (i=0; i no playerdata\n"); + fprintf(stderr,"zero value character was killed -> no playerdata, good.%d bad.%d\n",good,bad); + if ( newdata.size() == 0 ) + { + good++; + return(0); + } } + bad++; fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } From 4220a1cc929d39b00674849fb1d6e4c928c2fb37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:07:14 -1100 Subject: [PATCH 2612/3904] Dilithium register, sign, verify rpc calls --- src/cc/cclib.cpp | 28 ++++++- src/cc/dilithium.c | 197 ++++++++++++++++++++++++++++++++++++++------- src/cc/musig.cpp | 47 +++-------- 3 files changed, 206 insertions(+), 66 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 4f539b7f9..20cc8ee32 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -82,8 +82,9 @@ CClib_methods[] = { (char *)"musig", (char *)"send", (char *)"combined_pk amount", 2, 2, 'x', EVAL_MUSIG }, { (char *)"musig", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_MUSIG }, { (char *)"dilithium", (char *)"keypair", (char *)"[hexseed]", 0, 1, 'K', EVAL_DILITHIUM }, - { (char *)"dilithium", (char *)"sign", (char *)"msg privkey", 2, 2, 'S', EVAL_DILITHIUM }, - { (char *)"dilithium", (char *)"verify", (char *)"msg sig pubtxid", 3, 3, 'V', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"register", (char *)"handle, [hexseed]", 1, 2, 'R', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"sign", (char *)"msg [hexseed]", 1, 2, 'S', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"verify", (char *)"pubtxid msg sig", 3, 3, 'V', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"send", (char *)"pubtxid amount", 2, 2, 'x', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_DILITHIUM }, #endif @@ -126,6 +127,7 @@ UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -264,6 +266,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(dilithium_spend(txfee,cp,params)); else if ( strcmp(method,"keypair") == 0 ) return(dilithium_keypair(txfee,cp,params)); + else if ( strcmp(method,"register") == 0 ) + return(dilithium_register(txfee,cp,params)); else if ( strcmp(method,"sign") == 0 ) return(dilithium_sign(txfee,cp,params)); else if ( strcmp(method,"verify") == 0 ) @@ -573,6 +577,26 @@ uint256 juint256(cJSON *obj) return(revuint256(tmp)); } +int32_t cclib_parsepubkey(secp256k1_context *ctx,secp256k1_pubkey &spk,cJSON *item) +{ + char *hexstr; + if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == 66 ) + { + CPubKey pk(ParseHex(hexstr)); + if ( secp256k1_ec_pubkey_parse(ctx,&spk,pk.begin(),33) > 0 ) + return(1); + } else return(-1); +} + +int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) +{ + char *hexstr; + if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == len*2 ) + { + decode_hex(hash32,len,hexstr); + return(0); + } else return(-1); +} #ifdef BUILD_ROGUE #include "rogue_rpc.cpp" diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 996d4f2b1..5881d0840 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2841,58 +2841,195 @@ int32_t main(void) } #endif +#define DILITHIUM_TXFEE 10000 + void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); +CScript dilithium_registeropret(std::string handle,CPubKey pk,std::vector bigpub) +{ + CScript opret; uint8_t evalcode = EVAL_DILITHIUM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'R' << handle << pk << bigpub); + return(opret); +} + +uint8_t dilithium_registeropretdecode(std::string &handle,CPubKey &pk,std::vector &bigpub,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> handle; ss >> pk; ss >> bigpub) != 0 && e == EVAL_DILITHIUM && f == 'R' ) + { + return(f); + } + return(0); +} + +UniValue dilithium_rawtxresult(UniValue &result,std::string rawtx) +{ + CTransaction tx; + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + //if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + // RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + +char *dilithium_addr(char *coinaddr,uint8_t *buf,int32_t len) +{ + uint8_t rmd160[20],addrtype; + if ( len == CRYPTO_PUBLICKEYBYTES ) + addrtype = 55; + else if ( len == CRYPTO_SECRETKEYBYTES ) + addrtype = 63; + else + { + strcpy(coinaddr,"unexpected len.%d",len); + return(coinaddr); + } + calc_rmd160_sha256(rmd160,buf,len); + bitcoin_address(coinaddr,addrtype,rmd160,20); + return(coinaddr); +} + +char *dilithium_hexstr(char *str,uint8_t *buf,int32_t len) +{ + int32_t i; + for (i=0; i bigpub; + if ( myGetTransaction(pubtxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( dilithium_registeropretdecode(handle,pk33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' && bigpub.size() == CRYPTO_PUBLICKEYBYTES ) + { + memcpy(pk,&bigpub[0],CRYPTO_PUBLICKEYBYTES); + return(0); + } else return(-2); + } + return(-1); +} + UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; - //randombytes(seed,SEEDBYTES); + UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i,n,externalflag=0; Myprivkey(seed); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { - if ( musig_parsehash(seed,jitem(params,0),32) < 0 ) - return(cclib_error(result,"error parsing seed")); - else externalflag = 1; + if ( cclib_parsehash(seed,jitem(params,0),32) < 0 ) + { + randombytes(seed,SEEDBYTES); + result.push_back(Pair("status","using random high entropy seed")); + } + externalflag = 1; } _dilithium_keypair(pk,sk,seed); - for (i=0; i bigpub; int32_t i,n,warningflag = 0; + if ( txfee == 0 ) + txfee = DILITHIUM_TXFEE; + mypk = pubkey2pk(Mypubkey()); + dilithiumpk = GetUnspendable(cp,0); + if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 1 || n == 2) ) + { + std::string handle(jstr(jitem(params,0),0)); + result.push_back(Pair("handle",handle)); + if ( n == 2 || cclib_parsehash(seed,jitem(params,1),32) < 0 ) + { + Myprivkey(seed); + result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); + } + _dilithium_keypair(pk,sk,seed); + result.push_back(Pair("seed",dilithium_hexstr(str,seed,SEEDBYTES))); + result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); + result.push_back(Pair("skaddr",dilithium_addr(coinaddr,sk,CRYPTO_SECRETKEYBYTES))); + for (i=0; i= 3*txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,dilithiumpk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_registeropret('R',handle,mypk,bigpub)); + return(musig_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt find enough funds")); + } else return(cclib_error(result,"not enough parameters")); +} + UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - //_dilithium_sign(sm, &smlen, m, MLEN, sk); // 7.2 - - return(result); + UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],msg[32],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1],sm[32+CRYPTO_BYTES]; int32_t n,smlen; + if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 1 || n == 2) ) + { + if ( cclib_parsehash(msg,jitem(params,0),32) < 0 ) + return(cclib_error(result,"couldnt parse message to sign")); + else if ( n == 2 || cclib_parsehash(seed,jitem(params,1),32) < 0 ) + { + Myprivkey(seed); + result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); + } + _dilithium_keypair(pk,sk,seed); + result.push_back(Pair("msg32",dilithium_hexstr(str,msg,32))); + result.push_back(Pair("seed",dilithium_hexstr(str,seed,SEEDBYTES))); + result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); + result.push_back(Pair("skaddr",dilithium_addr(coinaddr,sk,CRYPTO_SECRETKEYBYTES))); + _dilithium_sign(sm,&smlen,msg,32,sk); + if ( smlen == 32+CRYPTO_BYTES ) + { + result.push_back(Pair("signature",dilithium_hexstr(str,sm,smlen))); + calc_rmd160_sha256(rmd160,sm,smlen); + result.push_back(Pair("sighash",dilithium_hexstr(str,rmd160,20))); + } else return(cclib_error(result,"unexpected signed message len")); + } else return(cclib_error(result,"not enough parameters")); } UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - return(result); + UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1],sm[32+CRYPTO_BYTES]; int32_t mlen,n; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + { + pubtxid = juint256(jitem(params,0)); + if ( dilithium_bigpubget(handle,pk33,pk,pubtxid) < 0 ) + return(cclib_error(result,"couldnt parse message to sign")); + else if ( cclib_parsehash(msg,jitem(params,1),32) < 0 ) + return(cclib_error(result,"couldnt parse message to sign")); + else if ( cclib_parsehash(sm,jitem(params,2),32+CRYPTO_BYTES) < 0 ) + return(cclib_error(result,"couldnt parse sig")); + else if ( _dilithium_verify(msg2,&mlen,sm,smlen,pk) < 0 ) + return(cclib_error(result,"dilithium verify error")); + else if ( mlen != 32 ) + return(cclib_error(result,"message len mismatch")); + else if ( memcmp(msg2,msg,32) != 0 ) + return(cclib_error(result,"message content mismatch")); + result.push_back(Pair("msg32",dilithium_hexstr(str,msg,32))); + result.push_back(Pair("handle",handle)); + result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); + result.push_back(Pair("result","success")); + return(result); + } else return(cclib_error(result,"not enough parameters")); } UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 6dbab482a..f4ba51d47 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -362,27 +362,6 @@ UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } else return(cclib_error(result,"couldnt parse params")); } -int32_t musig_parsepubkey(secp256k1_context *ctx,secp256k1_pubkey &spk,cJSON *item) -{ - char *hexstr; - if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == 66 ) - { - CPubKey pk(ParseHex(hexstr)); - if ( secp256k1_ec_pubkey_parse(ctx,&spk,pk.begin(),33) > 0 ) - return(1); - } else return(-1); -} - -int32_t musig_parsehash(uint8_t *hash32,cJSON *item,int32_t len) -{ - char *hexstr; - if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == len*2 ) - { - decode_hex(hash32,len,hexstr); - return(0); - } else return(-1); -} - UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; @@ -395,7 +374,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //fprintf(stderr,"n.%d args.(%s)\n",n,jprint(params,0)); for (i=0; icombined_pk,jitem(params,2)) < 0 ) + if ( cclib_parsepubkey(ctx,MUSIG->combined_pk,jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing combined_pubkey")); - else if ( musig_parsehash(MUSIG->pkhash,jitem(params,3),32) < 0 ) + else if ( cclib_parsehash(MUSIG->pkhash,jitem(params,3),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( musig_parsehash(MUSIG->msg,jitem(params,4),32) < 0 ) + else if ( cclib_parsehash(MUSIG->msg,jitem(params,4),32) < 0 ) return(cclib_error(result,"error parsing msg")); Myprivkey(privkey); GetRandBytes(session,32); @@ -497,13 +476,13 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) + if ( cclib_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash(&MUSIG->nonce_commitments[ind*32],jitem(params,2),32) < 0 ) + else if ( cclib_parsehash(&MUSIG->nonce_commitments[ind*32],jitem(params,2),32) < 0 ) return(cclib_error(result,"error parsing commitment")); /** Gets the signer's public nonce given a list of all signers' data with commitments * @@ -550,13 +529,13 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) + if ( cclib_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsepubkey(ctx,MUSIG->nonces[ind],jitem(params,2)) < 0 ) + else if ( cclib_parsepubkey(ctx,MUSIG->nonces[ind],jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing nonce")); result.push_back(Pair("added_index",ind)); /** Checks a signer's public nonce against a commitment to said nonce, and update @@ -620,13 +599,13 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - if ( musig_parsehash(pkhash,jitem(params,0),32) < 0 ) + if ( cclib_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsehash(psig,jitem(params,2),32) < 0 ) + else if ( cclib_parsehash(psig,jitem(params,2),32) < 0 ) return(cclib_error(result,"error parsing psig")); else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); @@ -669,11 +648,11 @@ UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { - if ( musig_parsehash(msg,jitem(params,0),32) < 0 ) + if ( cclib_parsehash(msg,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( musig_parsepubkey(ctx,combined_pk,jitem(params,1)) < 0 ) + else if ( cclib_parsepubkey(ctx,combined_pk,jitem(params,1)) < 0 ) return(cclib_error(result,"error parsing combined_pk")); - else if ( musig_parsehash(musig64,jitem(params,2),64) < 0 ) + else if ( cclib_parsehash(musig64,jitem(params,2),64) < 0 ) return(cclib_error(result,"error parsing musig64")); for (i=0; i<32; i++) sprintf(&str[i*2],"%02x",msg[i]); From 4551484dc3da7d4fcc47e52fdc904da31ed4ff6b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:09:23 -1100 Subject: [PATCH 2613/3904] Revert musig_parsepubkey --- src/cc/cclib.cpp | 11 ----------- src/cc/musig.cpp | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 20cc8ee32..8382ba8a0 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -577,17 +577,6 @@ uint256 juint256(cJSON *obj) return(revuint256(tmp)); } -int32_t cclib_parsepubkey(secp256k1_context *ctx,secp256k1_pubkey &spk,cJSON *item) -{ - char *hexstr; - if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == 66 ) - { - CPubKey pk(ParseHex(hexstr)); - if ( secp256k1_ec_pubkey_parse(ctx,&spk,pk.begin(),33) > 0 ) - return(1); - } else return(-1); -} - int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) { char *hexstr; diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index f4ba51d47..d93792463 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -304,6 +304,17 @@ uint8_t musig_spendopretdecode(CPubKey &pk,std::vector &musig64,CScript return(0); } +int32_t musig_parsepubkey(secp256k1_context *ctx,secp256k1_pubkey &spk,cJSON *item) +{ + char *hexstr; + if ( (hexstr= jstr(item,0)) != 0 && is_hexstr(hexstr,0) == 66 ) + { + CPubKey pk(ParseHex(hexstr)); + if ( secp256k1_ec_pubkey_parse(ctx,&spk,pk.begin(),33) > 0 ) + return(1); + } else return(-1); +} + int32_t musig_msghash(uint8_t *msg,uint256 prevhash,int32_t prevn,CTxOut vout,CPubKey pk) { CScript data; uint256 hash; int32_t len = 0; @@ -374,7 +385,7 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //fprintf(stderr,"n.%d args.(%s)\n",n,jprint(params,0)); for (i=0; icombined_pk,jitem(params,2)) < 0 ) + if ( musig_parsepubkey(ctx,MUSIG->combined_pk,jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing combined_pubkey")); else if ( cclib_parsehash(MUSIG->pkhash,jitem(params,3),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); @@ -535,7 +546,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(cclib_error(result,"pkhash doesnt match session pkhash")); else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) return(cclib_error(result,"illegal ind for session")); - else if ( cclib_parsepubkey(ctx,MUSIG->nonces[ind],jitem(params,2)) < 0 ) + else if ( musig_parsepubkey(ctx,MUSIG->nonces[ind],jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing nonce")); result.push_back(Pair("added_index",ind)); /** Checks a signer's public nonce against a commitment to said nonce, and update @@ -650,7 +661,7 @@ UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( cclib_parsehash(msg,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( cclib_parsepubkey(ctx,combined_pk,jitem(params,1)) < 0 ) + else if ( musig_parsepubkey(ctx,combined_pk,jitem(params,1)) < 0 ) return(cclib_error(result,"error parsing combined_pk")); else if ( cclib_parsehash(musig64,jitem(params,2),64) < 0 ) return(cclib_error(result,"error parsing musig64")); From 89d221c232400573fe5231d292b4fa8cf3c1d28d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:10:45 -1100 Subject: [PATCH 2614/3904] Syntax --- src/cc/dilithium.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 5881d0840..46b05cc50 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2890,7 +2890,7 @@ char *dilithium_addr(char *coinaddr,uint8_t *buf,int32_t len) addrtype = 63; else { - strcpy(coinaddr,"unexpected len.%d",len); + sprintf(coinaddr,"unexpected len.%d",len); return(coinaddr); } calc_rmd160_sha256(rmd160,buf,len); @@ -2968,12 +2968,12 @@ UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *par result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); result.push_back(Pair("skaddr",dilithium_addr(coinaddr,sk,CRYPTO_SECRETKEYBYTES))); for (i=0; i= 3*txfee ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,dilithiumpk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_registeropret('R',handle,mypk,bigpub)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_registeropret(handle,mypk,bigpub)); return(musig_rawtxresult(result,rawtx)); } else return(cclib_error(result,"couldnt find enough funds")); } else return(cclib_error(result,"not enough parameters")); From 2eec7b0bfb696b06988427609a621e5e1f720b53 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:12:20 -1100 Subject: [PATCH 2615/3904] Syntax --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 46b05cc50..c7ab0d4cb 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2981,7 +2981,7 @@ UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *par UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],msg[32],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1],sm[32+CRYPTO_BYTES]; int32_t n,smlen; + UniValue result(UniValue::VOBJ); uint8_t seed[SEEDBYTES],msg[32],rmd160[20],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES],sm[32+CRYPTO_BYTES]; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t n,smlen; if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 1 || n == 2) ) { if ( cclib_parsehash(msg,jitem(params,0),32) < 0 ) @@ -3008,7 +3008,7 @@ UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1],sm[32+CRYPTO_BYTES]; int32_t mlen,n; + UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1],sm[32+CRYPTO_BYTES]; int32_t mlen,n; std::string handle; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { pubtxid = juint256(jitem(params,0)); From cdd14fd61a312a61d7b3d8dcdf252bd27c717e1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:13:13 -1100 Subject: [PATCH 2616/3904] uint8 --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index c7ab0d4cb..e4a7e24ac 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3008,7 +3008,7 @@ UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1],sm[32+CRYPTO_BYTES]; int32_t mlen,n; std::string handle; + UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES],sm[32+CRYPTO_BYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t mlen,n; std::string handle; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { pubtxid = juint256(jitem(params,0)); From 4acaa5e7fb546c3ae5d0201c1f3a8ff881025e5f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:14:10 -1100 Subject: [PATCH 2617/3904] Smell --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index e4a7e24ac..59f53e829 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3008,7 +3008,7 @@ UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES],sm[32+CRYPTO_BYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t mlen,n; std::string handle; + UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES],sm[32+CRYPTO_BYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t smlen=32+CRYPTO_BYTES,mlen,n; std::string handle; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { pubtxid = juint256(jitem(params,0)); @@ -3016,7 +3016,7 @@ UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(cclib_error(result,"couldnt parse message to sign")); else if ( cclib_parsehash(msg,jitem(params,1),32) < 0 ) return(cclib_error(result,"couldnt parse message to sign")); - else if ( cclib_parsehash(sm,jitem(params,2),32+CRYPTO_BYTES) < 0 ) + else if ( cclib_parsehash(sm,jitem(params,2),smlen) < 0 ) return(cclib_error(result,"couldnt parse sig")); else if ( _dilithium_verify(msg2,&mlen,sm,smlen,pk) < 0 ) return(cclib_error(result,"dilithium verify error")); From 27564336b7c94232b7c1819db73404c25f826b37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:25:28 -1100 Subject: [PATCH 2618/3904] Off by one --- src/cc/dilithium.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 59f53e829..d8fcef08c 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2841,6 +2841,28 @@ int32_t main(void) } #endif +////////////////////////////////////////////////////// +/* First register a pubkey,ie. bind handle, pub33 and bigpub together and then can be referred by pubtxid in other calls + + cclib register 19 \"[%22jl777%22]\" + { + "handle": "jl777", + "warning": "test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!", + "pkaddr": "PNoTcVH8G5TBTQigyVZTsaMMNYYRvywUNu", + "skaddr": "SejsccjwGrZKaziD1kpfgQhXA32xvzP75i", + "hex": "0400008085202f89010184fa95fce1a13d441e6c87631f7d0ca5f22ad8b28ae4321e02177b125b5f2400000000494830450221009fb8ff0ea4e810f34e54f0a872952f364e6eb697bb4ab34ea571fd213299b685022017c0b09fc71ec2d2abf49e435a72d32ecc874d14aac39be7b9753704fad7d06c01ffffffff041027000000000000302ea22c8020979f9b424db4e028cdba433622c6cd17b9193763e68b4572cd7f3727dcd335978....00000000000", + "txid": "9d856b2be6e54c8f04ae3f86aef722b0535180b3e9eb926c53740e481a1715f9", + "result": "success" + } + + sendrawtransaction from above -> pubtxid 9d856b2be6e54c8f04ae3f86aef722b0535180b3e9eb926c53740e481a1715f9 + + now test signing some random 32 byte message + + cclib sign 19 \"[%22aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22]\" + + */ + #define DILITHIUM_TXFEE 10000 void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); @@ -2931,13 +2953,13 @@ UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *para { randombytes(seed,SEEDBYTES); result.push_back(Pair("status","using random high entropy seed")); + result.push_back(Pair("seed",dilithium_hexstr(str,seed,SEEDBYTES))); } externalflag = 1; } _dilithium_keypair(pk,sk,seed); result.push_back(Pair("pubkey",dilithium_hexstr(str,pk,CRYPTO_PUBLICKEYBYTES))); result.push_back(Pair("privkey",dilithium_hexstr(str,sk,CRYPTO_SECRETKEYBYTES))); - result.push_back(Pair("seed",dilithium_hexstr(str,seed,SEEDBYTES))); result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); result.push_back(Pair("skaddr",dilithium_addr(coinaddr,sk,CRYPTO_SECRETKEYBYTES))); if ( externalflag == 0 ) @@ -2958,13 +2980,12 @@ UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *par { std::string handle(jstr(jitem(params,0),0)); result.push_back(Pair("handle",handle)); - if ( n == 2 || cclib_parsehash(seed,jitem(params,1),32) < 0 ) + if ( n == 1 || cclib_parsehash(seed,jitem(params,1),32) < 0 ) { Myprivkey(seed); result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); } _dilithium_keypair(pk,sk,seed); - result.push_back(Pair("seed",dilithium_hexstr(str,seed,SEEDBYTES))); result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); result.push_back(Pair("skaddr",dilithium_addr(coinaddr,sk,CRYPTO_SECRETKEYBYTES))); for (i=0; i Date: Sat, 23 Feb 2019 22:26:39 -1100 Subject: [PATCH 2619/3904] Return result --- src/cc/dilithium.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index d8fcef08c..35902f266 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3022,6 +3022,7 @@ UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("signature",dilithium_hexstr(str,sm,smlen))); calc_rmd160_sha256(rmd160,sm,smlen); result.push_back(Pair("sighash",dilithium_hexstr(str,rmd160,20))); + return(result); } else return(cclib_error(result,"unexpected signed message len")); } else return(cclib_error(result,"not enough parameters")); } From a0ece6b680f0bdb5a9742d4d7552ba1454e9fd08 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:31:29 -1100 Subject: [PATCH 2620/3904] Add sighash for easy compare --- src/cc/dilithium.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 35902f266..a60c63527 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2860,7 +2860,18 @@ int32_t main(void) now test signing some random 32 byte message cclib sign 19 \"[%22aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22]\" + { + "warning": "test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!", + "msg32": "aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848", + "pkaddr": "PNoTcVH8G5TBTQigyVZTsaMMNYYRvywUNu", + "skaddr": "SejsccjwGrZKaziD1kpfgQhXA32xvzP75i", + "signature": "be067f4bd81b9b0b772e0e2872cc086f6c2ff4c558a465afe80ab71c2c7b39a25ad8300629337c022d8c477cf7728cd11a3f6135bccfdbd68de5cd4517e70a70ec3b836041dc9c2f1abed65f2519e43a31ca6ad4991ce98460a14ee70d28c47f5a1d967c25b1ac93afea7e2b11...836b0f0efbcb26ee679f4f4848", + "sighash": "cfed6d7f059b87635bde6cb31accd736bf99ff3d" + } + it is a very big signature, but that seems to be dilithium sig size. let us verify it: + + cclib verify 19 \"[%229d856b2be6e54c8f04ae3f86aef722b0535180b3e9eb926c53740e481a1715f9%22,%22aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22,%22be067f4bd81b9b0b772e0e2872cc086f6c2ff4c558a465afe80ab71c2c7b39a25ad8300629337c022d8c477cf7728cd11a3f6135bccfdbd68de5cd4517e70a70ec3b836041dc9c2f1abed65f2519e43a31ca6ad4991ce98460a14ee70d28c47f5a1d967c25b1ac93afea7e2b11aa2fb715ac08bd3eac739425c67974ecd682f711a0b175b30278febfe55586650ed8b0098de745944450a6836b6ab23e0c5ebdd7503188428c3159f1671ca27d9d529d344d246e116b2001dbba085afe1bfcdd12d88ae2efbcead268b10cec4f76531aba594887dd239b59c4c676b348a56a1cc2e0032590c74513cfba7f03f8b6d7a14bb6f6a16ae743317ecd8551b3362dc892bcae550032682d130772f65b2e96a5ad4ce2b8e9a41a48c2a52c80f349c99dc110807e7c662f7ef960f628001ca9a9f249b53b23c4680e3a6acec89e3c26d0265b617353654f55a752f9ea3689570c068a414793c3575fae66f6fa425ce282a574981228a52e2ede14fbde3ac66a8e061a538bee737d17fbb48afc39cd914518ef2a182ce1feb66b1a8bf9934b6fef491f2bd3598e3421399fe11754bc61e149e8846f74d44d96c7dc47f06d04d6c09dc2b2c9d78e76a713722eec637f8e3fb5cd5adfd8ba2ce05dacdf2f9522e89bff2ee745d49873755a0079835e982c6c55fd9a96597505d79090da8df4feb422422b1d6427fde4242aafcb6ed581d8e4ffd722daf56fd45b017a2a2fa2f4e30a3a457686bdd184505461fc6749e4a20b7faa2a1d9a295a445ea564b84c1b820d9cf5c06142353671f989565a3767bd6ddabfc3bf1368acdae8870580f21baa2093cea4447688e35719bd78c785821f944ecc9a093f9a65bf2584f1a0c68f70f11f2485e02f288c2c8b6692883983607960aa16065d22082121f6fd6588f07cd3fb57bba624fbb9c7077cb1400fe4edf48156b7622fab70cce1cbd17bde2f4c24b9a86d485727df413e06a6c31cab27284a69fd46e00fc6e80872ed5291b598c74964488ffdb19d0dc94fce37db3f5230d947cb4d83ae55e0357aab1ec86b63fe606f86a77aa78fc4fe986be450b74f1ffbb5ba9eeaea11c7c7ffa6d87a9d49767ce761614bd6cc5df3767ed6396b84354a9634bb3e35606e961fc023504473bf3b7e13244f19d1dee101af1854f80899f95409bb402a5267ad21ddba80e2dd0dd513d0fc88067ac4078e69c12bd19807c03a916d2a42cdbe7b4cdac4bc2314fe3369723d16c30bf277db823c1457f5ff64f3117b82b991ee8b65b7e6b8f7814a15b4ca8cebe88d12236cf1b7dd06b75cab506d78c2072fddf2002be366f43ca68866f87fe9a56808ab7f82aa925091e1f0fba371642039316939446b769973a9c93efe3104699ad3eceac89eb1c2507b65b43d21388f93ff28b194110d7114b97a10cb212515127ede0287d455791e1c6d554b0d8a4e75f2701bc3430786cc69081dbd96a73a308fc6a60fc773fdc7df49b1865c3e989f2a528872fd4c1715dadb11c801c1492ce07bde59e25a801bb542e2caef35f99ca4cb0a3f1d2c2c6e3895c94001a0b2cc648057c2e44c780655f93d56a2cd62a9d55eb8de45e9ec75bfa3d121223aba700062ba3f54162fb9ba136aca6aeb119bca9a0d6bf18e89f54d9ff09c6a2036f767098fbbaf20e10db25e43386ecda201c05e794805269f1a77e50657052d16ae1e154d706a7fa81c419b9d262766e8edb8fd6343f509bed44098ef741f10a6206474c3490354695762a5a4532dd0279abc38ef75a44899a5d8d0e77af638aedd07071f37a3c5f82bbbd05a7b4c0e23d2fc3a5bbc40a52f588c8592f02fb30be56ae0990b24a80690c0b5c9df29549f7dec89f62920a37d05c62c27a62ee01fea164bf28937cdc7d3f2937a5756ada91c2615ce7ed20f0ed07cf486b76d0a63d193363567746eff0ff90ace3dbdfb770d55161c84ccdebca1a600337e7ffed0fdfbc041ed44e0014cced03d1af55ae9fa14d87d60dfe96ac7cde67a1d8ea2150c00ba5fb9a0ec0eff5bd9f734da71edbe7e2f71b6465984c411de8a3cc77a337b2ffdee6ab6d904a79316c15d15176401bc7e72fabb1e9571c7e7188ba09a295400437e4b96549d9827fba6d3493bc6f58f95e240b0a0159054014e5e3103e3af4eef77d3896290c7bf930edbe77615d56aa0a93034c92830c1382c0c06726d2ec7d6c2ed45d3a9fb9646892402812f1df9a003705d3f549d84f9ed3b5fe3c40fcb0bcb28a0d32f2fa27fcdb82509a0725d7314a3eb99a701169fae9e3dcdc2cc20d73aa8b2c5feb645556a8b946581e4e9e82f6a19a21f5babd35d49810dc88923c4908eca3690b774f367a41c3a37b54af9847d73a7eed1ee45edaaed0f316d551c08e3e642cebc97ce71a811664ee9296e7fedffb90011cc353302acd931bc0d152d7e6332a8f0d71059987c3b90f3f57178dec3f30c58ded0bc80eb65b0c9b8d16ec73ebe17e31259181b2376405db17e279419f1c685ad71b6cc91c81a120de2db2c532e67bc3a58d22b549fae61f32398d03cb1f5e245cfec65c40c9dfd0b8a93812f67840c653c5304402a1ff6189fd24f8ce3482e5cf92b3581445009c3b586bb421459ce9457868787c78b787bd45df7e55c3165a92194d38b913a6ef6f31af4c2afcfd0158eb8eb2820f7d41e3efca9367528a0b6fe6ec3fd01082bc60a9fe2a13ab3705b3b0c07173d4d762c8de4b6598d30b97e32339aeb706de47170e1033603267c6ce8caa2977990cbda75984de4e5ede6e36ff889b53b2cbbebc37f9e56e78c62ff856bcb27aba8892ace8fcaae09b31d7f5f850596014e868003d632c9dc12e7c83f6de676d9ae4328862326572e2e0353d5547f7f73fdf5b0227b6d108ae28e3dc622d5ac3dcf98bd1461917d78468ac2912329027c1085611dce7a6b7b3fa8451a5c3c6b448b1b9ad9dd84308991e4688595bcb289ec4b99f63db0c18969bd4b5cdc14d85007d683f936ab3207b59e3971f86f8fb388e72bdc7c9fb3b466061223e85138ee6a5657e8862ca51819c9d92b339ac6900e9f60a71d4a1eb09707cedc32bb477c91a8b5792e850606e1de57122d017a2025423d40b48e0bbe711ec03381630b9003ff55e10ac6f0031dfc54ed54ccd3309abd17ee026958fdf23bb74d53b84d8e2ef150fb2216265454c5f6446e221ab1c95c086571cad14251f618c9c58a9dfb83f9a8c58c9c5c026b9bc8f90860acde16557c064f95b178a9776e463b2d7d658e4acfa1ea30c429c0b813a5872b02d7b0bafcc095e979f737834933fbbf1220c05a0b0346f5932c669c534e22ab5ab42c39fd0e062abff05a2d34060e6f539c7ae9244903d981095fac6cff5d20ac9d298de27cb1ea7079d6dcc47504f988e3bdd1c48ca23f9ec305950459446c51b879a62e75cbc3570d2dbf93594f299111e27b60e5193d6e766a40130ee5d33a43eb43aba5c5701de878fdeaa16c998607e7fbf6c8827cb1f914db9d73c6ae48a0cb416218cc50b335f171e4df050561dfb1669939ccf2c498ff1d8f53a7d7c77195348502c4ffd5c18362f4eb4c3077e504853ff1e84c6166e1f889781bf5dcccf0daf8ac0881ee7202650abdff8d6cda2f8bf3b6a96d23f5ffa0104ee72dd1e8ae7cd08258d36b50cb40048756216845815a3e01efd33d5fae86a0680920422325893296dcb2af0d6df21c7193e387092b61408aac63df4a79c3b1e54869ba3c43ae2a54446e64053c061dd8bb3e132be46d9a83b6675791f49aa9617345801e97be7f4f7159ba1d7da623c7868ad281ddbb0f75fec7fe56ff0a44a8ac3b51a1f784b2b039d6434f92d3254fd83b4221ca18883637a0eb12217ebc8e149681c21e0edbd11289cfa7f78d536d8858a60056b8c28916e1d34ce1a6d344034b2e72162a5fc92b137354c2b791e7ad6ee4679f71181188ba69c9ded078421885a6cc18bc58c383d190c11d236e53eaa39a99d157e4dd74bc4aa2ce1354511128d6b407007dbcaeb9c3b712ed2b334de23c66735f534a9dddb7ab2d06c6a4669d2bd38c8c812b287b39b3591ac77e617834ea7c4c38b1133f2cafdf51f9afca7f44e9b527d3e0e840b05ec8bf57fcceb8a28546a3593ff1b94ee6a8d7d28b8e6007d0ea7da80552e4382b3ff3b6152175083717f42c5c902131b0a27e23bbcf4ba03140a6dc3bcccbc8ca93ba6161fe3c36a1835e9e02695bac571a07f6b2267998213aa0c4c7b93c2ed3a58e12cab5a51edf462a30df14e7e32727b4da1f7f29e9ea30f65ab090b22e9ae00ae9419bf26a44482d536812e2b4c2e1fd2af622d827b04b67eac1052d2ccee68207b3b6ca3d96bc4de4039a3a3e50c58a17786edb08caad6091dab0e7beffd0acb748d5c5ef6a171d8d113c7c310f18712a53607dbf01653157090cdd19c5845c1b7e11a4a61c2229cbb1e6927c74f187964c646b007051841b1b83e670611c1e9eb0b2406ee432122613a4c7e9f60c2cf8db2d6032225604c1d5468b1e90bb57651c2223363743516164a4aab0b4bac2d70d1a254f687384889daee2fc2d32365d78878b8c9aabbbbcc8d7f4fb191d23283f4d5359767e8c99a1b8c8cddfe5040c1e2339606e788ca9cad6f2fc0712236a70c9cdd6fb0000000000000000000000000000000000000000000000000000000000000000000000101c2c3e4c55b80404422409560084401072601824140801b8244ae84401008080081022408cdea5834e5fd1220daff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22]\" */ #define DILITHIUM_TXFEE 10000 @@ -3029,7 +3040,7 @@ UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES],sm[32+CRYPTO_BYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t smlen=32+CRYPTO_BYTES,mlen,n; std::string handle; + UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t rmd160[20],msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES],sm[32+CRYPTO_BYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t smlen=32+CRYPTO_BYTES,mlen,n; std::string handle; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { pubtxid = juint256(jitem(params,0)); @@ -3048,6 +3059,8 @@ UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("msg32",dilithium_hexstr(str,msg,32))); result.push_back(Pair("handle",handle)); result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); + calc_rmd160_sha256(rmd160,sm,smlen); + result.push_back(Pair("sighash",dilithium_hexstr(str,rmd160,20))); result.push_back(Pair("result","success")); return(result); } else return(cclib_error(result,"not enough parameters")); From 16953993cce2f6ce0ffd23b8e38880457ceacec9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 22:33:48 -1100 Subject: [PATCH 2621/3904] Reorder --- src/cc/dilithium.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index a60c63527..a41e1ea59 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3050,19 +3050,22 @@ UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *param return(cclib_error(result,"couldnt parse message to sign")); else if ( cclib_parsehash(sm,jitem(params,2),smlen) < 0 ) return(cclib_error(result,"couldnt parse sig")); - else if ( _dilithium_verify(msg2,&mlen,sm,smlen,pk) < 0 ) - return(cclib_error(result,"dilithium verify error")); - else if ( mlen != 32 ) - return(cclib_error(result,"message len mismatch")); - else if ( memcmp(msg2,msg,32) != 0 ) - return(cclib_error(result,"message content mismatch")); - result.push_back(Pair("msg32",dilithium_hexstr(str,msg,32))); - result.push_back(Pair("handle",handle)); - result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); - calc_rmd160_sha256(rmd160,sm,smlen); - result.push_back(Pair("sighash",dilithium_hexstr(str,rmd160,20))); - result.push_back(Pair("result","success")); - return(result); + else + { + calc_rmd160_sha256(rmd160,sm,smlen); + result.push_back(Pair("sighash",dilithium_hexstr(str,rmd160,20))); + if ( _dilithium_verify(msg2,&mlen,sm,smlen,pk) < 0 ) + return(cclib_error(result,"dilithium verify error")); + else if ( mlen != 32 ) + return(cclib_error(result,"message len mismatch")); + else if ( memcmp(msg2,msg,32) != 0 ) + return(cclib_error(result,"message content mismatch")); + result.push_back(Pair("msg32",dilithium_hexstr(str,msg,32))); + result.push_back(Pair("handle",handle)); + result.push_back(Pair("pkaddr",dilithium_addr(coinaddr,pk,CRYPTO_PUBLICKEYBYTES))); + result.push_back(Pair("result","success")); + return(result); + } } else return(cclib_error(result,"not enough parameters")); } From 16771b99f2eb4c719ff4cf5bbcfc4843942df73a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 23:07:50 -1100 Subject: [PATCH 2622/3904] Dilithium send --- src/cc/cclib.cpp | 2 +- src/cc/dilithium.c | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8382ba8a0..c64ac025b 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -85,7 +85,7 @@ CClib_methods[] = { (char *)"dilithium", (char *)"register", (char *)"handle, [hexseed]", 1, 2, 'R', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"sign", (char *)"msg [hexseed]", 1, 2, 'S', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"verify", (char *)"pubtxid msg sig", 3, 3, 'V', EVAL_DILITHIUM }, - { (char *)"dilithium", (char *)"send", (char *)"pubtxid amount", 2, 2, 'x', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"send", (char *)"handle pubtxid amount", 3, 3, 'x', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_DILITHIUM }, #endif }; diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index a41e1ea59..8406b0c00 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2872,6 +2872,18 @@ int32_t main(void) it is a very big signature, but that seems to be dilithium sig size. let us verify it: cclib verify 19 \"[%229d856b2be6e54c8f04ae3f86aef722b0535180b3e9eb926c53740e481a1715f9%22,%22aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22,%22be067f4bd81b9b0b772e0e2872cc086f6c2ff4c558a465afe80ab71c2c7b39a25ad8300629337c022d8c477cf7728cd11a3f6135bccfdbd68de5cd4517e70a70ec3b836041dc9c2f1abed65f2519e43a31ca6ad4991ce98460a14ee70d28c47f5a1d967c25b1ac93afea7e2b11aa2fb715ac08bd3eac739425c67974ecd682f711a0b175b30278febfe55586650ed8b0098de745944450a6836b6ab23e0c5ebdd7503188428c3159f1671ca27d9d529d344d246e116b2001dbba085afe1bfcdd12d88ae2efbcead268b10cec4f76531aba594887dd239b59c4c676b348a56a1cc2e0032590c74513cfba7f03f8b6d7a14bb6f6a16ae743317ecd8551b3362dc892bcae550032682d130772f65b2e96a5ad4ce2b8e9a41a48c2a52c80f349c99dc110807e7c662f7ef960f628001ca9a9f249b53b23c4680e3a6acec89e3c26d0265b617353654f55a752f9ea3689570c068a414793c3575fae66f6fa425ce282a574981228a52e2ede14fbde3ac66a8e061a538bee737d17fbb48afc39cd914518ef2a182ce1feb66b1a8bf9934b6fef491f2bd3598e3421399fe11754bc61e149e8846f74d44d96c7dc47f06d04d6c09dc2b2c9d78e76a713722eec637f8e3fb5cd5adfd8ba2ce05dacdf2f9522e89bff2ee745d49873755a0079835e982c6c55fd9a96597505d79090da8df4feb422422b1d6427fde4242aafcb6ed581d8e4ffd722daf56fd45b017a2a2fa2f4e30a3a457686bdd184505461fc6749e4a20b7faa2a1d9a295a445ea564b84c1b820d9cf5c06142353671f989565a3767bd6ddabfc3bf1368acdae8870580f21baa2093cea4447688e35719bd78c785821f944ecc9a093f9a65bf2584f1a0c68f70f11f2485e02f288c2c8b6692883983607960aa16065d22082121f6fd6588f07cd3fb57bba624fbb9c7077cb1400fe4edf48156b7622fab70cce1cbd17bde2f4c24b9a86d485727df413e06a6c31cab27284a69fd46e00fc6e80872ed5291b598c74964488ffdb19d0dc94fce37db3f5230d947cb4d83ae55e0357aab1ec86b63fe606f86a77aa78fc4fe986be450b74f1ffbb5ba9eeaea11c7c7ffa6d87a9d49767ce761614bd6cc5df3767ed6396b84354a9634bb3e35606e961fc023504473bf3b7e13244f19d1dee101af1854f80899f95409bb402a5267ad21ddba80e2dd0dd513d0fc88067ac4078e69c12bd19807c03a916d2a42cdbe7b4cdac4bc2314fe3369723d16c30bf277db823c1457f5ff64f3117b82b991ee8b65b7e6b8f7814a15b4ca8cebe88d12236cf1b7dd06b75cab506d78c2072fddf2002be366f43ca68866f87fe9a56808ab7f82aa925091e1f0fba371642039316939446b769973a9c93efe3104699ad3eceac89eb1c2507b65b43d21388f93ff28b194110d7114b97a10cb212515127ede0287d455791e1c6d554b0d8a4e75f2701bc3430786cc69081dbd96a73a308fc6a60fc773fdc7df49b1865c3e989f2a528872fd4c1715dadb11c801c1492ce07bde59e25a801bb542e2caef35f99ca4cb0a3f1d2c2c6e3895c94001a0b2cc648057c2e44c780655f93d56a2cd62a9d55eb8de45e9ec75bfa3d121223aba700062ba3f54162fb9ba136aca6aeb119bca9a0d6bf18e89f54d9ff09c6a2036f767098fbbaf20e10db25e43386ecda201c05e794805269f1a77e50657052d16ae1e154d706a7fa81c419b9d262766e8edb8fd6343f509bed44098ef741f10a6206474c3490354695762a5a4532dd0279abc38ef75a44899a5d8d0e77af638aedd07071f37a3c5f82bbbd05a7b4c0e23d2fc3a5bbc40a52f588c8592f02fb30be56ae0990b24a80690c0b5c9df29549f7dec89f62920a37d05c62c27a62ee01fea164bf28937cdc7d3f2937a5756ada91c2615ce7ed20f0ed07cf486b76d0a63d193363567746eff0ff90ace3dbdfb770d55161c84ccdebca1a600337e7ffed0fdfbc041ed44e0014cced03d1af55ae9fa14d87d60dfe96ac7cde67a1d8ea2150c00ba5fb9a0ec0eff5bd9f734da71edbe7e2f71b6465984c411de8a3cc77a337b2ffdee6ab6d904a79316c15d15176401bc7e72fabb1e9571c7e7188ba09a295400437e4b96549d9827fba6d3493bc6f58f95e240b0a0159054014e5e3103e3af4eef77d3896290c7bf930edbe77615d56aa0a93034c92830c1382c0c06726d2ec7d6c2ed45d3a9fb9646892402812f1df9a003705d3f549d84f9ed3b5fe3c40fcb0bcb28a0d32f2fa27fcdb82509a0725d7314a3eb99a701169fae9e3dcdc2cc20d73aa8b2c5feb645556a8b946581e4e9e82f6a19a21f5babd35d49810dc88923c4908eca3690b774f367a41c3a37b54af9847d73a7eed1ee45edaaed0f316d551c08e3e642cebc97ce71a811664ee9296e7fedffb90011cc353302acd931bc0d152d7e6332a8f0d71059987c3b90f3f57178dec3f30c58ded0bc80eb65b0c9b8d16ec73ebe17e31259181b2376405db17e279419f1c685ad71b6cc91c81a120de2db2c532e67bc3a58d22b549fae61f32398d03cb1f5e245cfec65c40c9dfd0b8a93812f67840c653c5304402a1ff6189fd24f8ce3482e5cf92b3581445009c3b586bb421459ce9457868787c78b787bd45df7e55c3165a92194d38b913a6ef6f31af4c2afcfd0158eb8eb2820f7d41e3efca9367528a0b6fe6ec3fd01082bc60a9fe2a13ab3705b3b0c07173d4d762c8de4b6598d30b97e32339aeb706de47170e1033603267c6ce8caa2977990cbda75984de4e5ede6e36ff889b53b2cbbebc37f9e56e78c62ff856bcb27aba8892ace8fcaae09b31d7f5f850596014e868003d632c9dc12e7c83f6de676d9ae4328862326572e2e0353d5547f7f73fdf5b0227b6d108ae28e3dc622d5ac3dcf98bd1461917d78468ac2912329027c1085611dce7a6b7b3fa8451a5c3c6b448b1b9ad9dd84308991e4688595bcb289ec4b99f63db0c18969bd4b5cdc14d85007d683f936ab3207b59e3971f86f8fb388e72bdc7c9fb3b466061223e85138ee6a5657e8862ca51819c9d92b339ac6900e9f60a71d4a1eb09707cedc32bb477c91a8b5792e850606e1de57122d017a2025423d40b48e0bbe711ec03381630b9003ff55e10ac6f0031dfc54ed54ccd3309abd17ee026958fdf23bb74d53b84d8e2ef150fb2216265454c5f6446e221ab1c95c086571cad14251f618c9c58a9dfb83f9a8c58c9c5c026b9bc8f90860acde16557c064f95b178a9776e463b2d7d658e4acfa1ea30c429c0b813a5872b02d7b0bafcc095e979f737834933fbbf1220c05a0b0346f5932c669c534e22ab5ab42c39fd0e062abff05a2d34060e6f539c7ae9244903d981095fac6cff5d20ac9d298de27cb1ea7079d6dcc47504f988e3bdd1c48ca23f9ec305950459446c51b879a62e75cbc3570d2dbf93594f299111e27b60e5193d6e766a40130ee5d33a43eb43aba5c5701de878fdeaa16c998607e7fbf6c8827cb1f914db9d73c6ae48a0cb416218cc50b335f171e4df050561dfb1669939ccf2c498ff1d8f53a7d7c77195348502c4ffd5c18362f4eb4c3077e504853ff1e84c6166e1f889781bf5dcccf0daf8ac0881ee7202650abdff8d6cda2f8bf3b6a96d23f5ffa0104ee72dd1e8ae7cd08258d36b50cb40048756216845815a3e01efd33d5fae86a0680920422325893296dcb2af0d6df21c7193e387092b61408aac63df4a79c3b1e54869ba3c43ae2a54446e64053c061dd8bb3e132be46d9a83b6675791f49aa9617345801e97be7f4f7159ba1d7da623c7868ad281ddbb0f75fec7fe56ff0a44a8ac3b51a1f784b2b039d6434f92d3254fd83b4221ca18883637a0eb12217ebc8e149681c21e0edbd11289cfa7f78d536d8858a60056b8c28916e1d34ce1a6d344034b2e72162a5fc92b137354c2b791e7ad6ee4679f71181188ba69c9ded078421885a6cc18bc58c383d190c11d236e53eaa39a99d157e4dd74bc4aa2ce1354511128d6b407007dbcaeb9c3b712ed2b334de23c66735f534a9dddb7ab2d06c6a4669d2bd38c8c812b287b39b3591ac77e617834ea7c4c38b1133f2cafdf51f9afca7f44e9b527d3e0e840b05ec8bf57fcceb8a28546a3593ff1b94ee6a8d7d28b8e6007d0ea7da80552e4382b3ff3b6152175083717f42c5c902131b0a27e23bbcf4ba03140a6dc3bcccbc8ca93ba6161fe3c36a1835e9e02695bac571a07f6b2267998213aa0c4c7b93c2ed3a58e12cab5a51edf462a30df14e7e32727b4da1f7f29e9ea30f65ab090b22e9ae00ae9419bf26a44482d536812e2b4c2e1fd2af622d827b04b67eac1052d2ccee68207b3b6ca3d96bc4de4039a3a3e50c58a17786edb08caad6091dab0e7beffd0acb748d5c5ef6a171d8d113c7c310f18712a53607dbf01653157090cdd19c5845c1b7e11a4a61c2229cbb1e6927c74f187964c646b007051841b1b83e670611c1e9eb0b2406ee432122613a4c7e9f60c2cf8db2d6032225604c1d5468b1e90bb57651c2223363743516164a4aab0b4bac2d70d1a254f687384889daee2fc2d32365d78878b8c9aabbbbcc8d7f4fb191d23283f4d5359767e8c99a1b8c8cddfe5040c1e2339606e788ca9cad6f2fc0712236a70c9cdd6fb0000000000000000000000000000000000000000000000000000000000000000000000101c2c3e4c55b80404422409560084401072601824140801b8244ae84401008080081022408cdea5834e5fd1220daff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848%22]\" + { + "sighash": "cfed6d7f059b87635bde6cb31accd736bf99ff3d", + "msg32": "aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848", + "handle": "jl777", + "pkaddr": "PNoTcVH8G5TBTQigyVZTsaMMNYYRvywUNu", + "result": "success" + } + + the basics are working, now it is time to send and spend + + cclib send 19 \"[%22jl777%22,%229d856b2be6e54c8f04ae3f86aef722b0535180b3e9eb926c53740e481a1715f9%22,7.77]\" + */ #define DILITHIUM_TXFEE 10000 @@ -3071,9 +3083,30 @@ UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - // copy musig method - return(result); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx,checkhandle; CPubKey destpub33,mypk,dilithiumpk; int32_t i,n; int64_t amount; uint256 destpubtxid; uint8_t pk[CRYPTO_PUBLICKEYBYTES]; + if ( txfee == 0 ) + txfee = DILITHIUM_TXFEE; + mypk = pubkey2pk(Mypubkey()); + dilithiumpk = GetUnspendable(cp,0); + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + { + amount = jdouble(jitem(params,2),0)*COIN + 0.0000000049; + std::string handle(jstr(jitem(params,0),0)); + result.push_back(Pair("handle",handle)); + destpubtxid = juint256(jitem(params,1)); + if ( dilithium_bigpubget(checkhandle,destpub33,pk,pubtxid) < 0 ) + return(cclib_error(result,"couldnt parse message to sign")); + else if ( handle == checkhandle ) + { + if ( AddNormalinputs(mtx,mypk,amount+txfee,64) >= amount+txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,destpub33)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_sendopret(destpubtxid)); + return(musig_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt find enough funds")); + } else return(cclib_error(result,"handle mismatch")); + } else return(cclib_error(result,"not enough parameters")); } UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) From 60c8bda1305697f429364c0b74309222968b10e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 23:09:13 -1100 Subject: [PATCH 2623/3904] Opret --- src/cc/dilithium.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 8406b0c00..47c447f88 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2909,6 +2909,24 @@ uint8_t dilithium_registeropretdecode(std::string &handle,CPubKey &pk,std::vecto return(0); } +CScript dilithium_sendopret(uint256 destpubtxid) +{ + CScript opret; uint8_t evalcode = EVAL_DILITHIUM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'x' << destpubtxid); + return(opret); +} + +uint8_t dilithium_sendopretdecode(uint256 &destpubtxid,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> handle; ss >> destpubtxid) != 0 && e == EVAL_DILITHIUM && f == 'x' ) + { + return(f); + } + return(0); +} + UniValue dilithium_rawtxresult(UniValue &result,std::string rawtx) { CTransaction tx; From f86cdd74f9dad20ba2a3a6ead53e8c02507cadcb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 23:10:10 -1100 Subject: [PATCH 2624/3904] Destpubtxid --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 47c447f88..5db52bd00 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3113,7 +3113,7 @@ UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::string handle(jstr(jitem(params,0),0)); result.push_back(Pair("handle",handle)); destpubtxid = juint256(jitem(params,1)); - if ( dilithium_bigpubget(checkhandle,destpub33,pk,pubtxid) < 0 ) + if ( dilithium_bigpubget(checkhandle,destpub33,pk,destpubtxid) < 0 ) return(cclib_error(result,"couldnt parse message to sign")); else if ( handle == checkhandle ) { From 461ed55d093d71448179fa18f42d99704bebac92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 23:10:59 -1100 Subject: [PATCH 2625/3904] Fix --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 5db52bd00..3e485f893 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2920,7 +2920,7 @@ uint8_t dilithium_sendopretdecode(uint256 &destpubtxid,CScript scriptPubKey) { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> handle; ss >> destpubtxid) != 0 && e == EVAL_DILITHIUM && f == 'x' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> destpubtxid) != 0 && e == EVAL_DILITHIUM && f == 'x' ) { return(f); } From 7d623078f3e3146e111590609b613c70ec55de82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 23:44:43 -1100 Subject: [PATCH 2626/3904] Docs --- src/cc/dilithium.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 3e485f893..ed0956c62 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2842,7 +2842,18 @@ int32_t main(void) #endif ////////////////////////////////////////////////////// -/* First register a pubkey,ie. bind handle, pub33 and bigpub together and then can be referred by pubtxid in other calls + +/* + dilithium has very big pubkeys and privkeys, so some practical things are done to make them more manageable. luckily the big privkey can be generated from a normal 256bit seed in about 100 microseconds. Of course, if you use a normal privkey that is also having its pubkey known, it defeats the purpose of using quantum secure protocol. however it is convenient for testing. just make sure to use externally generated seeds that never get used for secp256k1 if you want to keep it quantum secure. + + there are some useful "addresses" starting with 'P' and 'S' that are the base58 encoded dilithium pubkey and privkey. this is just so you can make sure the right one was used in an operation as the ~3kb of hex is very hard to compare visually. + + Now comes the cool part. Instead of having to specify these giant pubkeys in each spend and maybe even send, we send to a pubtxid instead. the pubtxid is the txid of a registration tx where a handle, secp256k1 pubkey and the dilithium pubkey are bound together. So by referring to the txid, you refer to all three. Again, for convenience it is possible to use the same secp256k1 pubkey that is derived from the 256bit seed that the dilithium pubkey is generated, but that offers no additonal quantum protection. To gain the quantum protection, use an externally provided seed to generate the dilithium pubkey. there should be no algorithmic linkage between the pubtxid secp256k1 pubkey and the dilithium pubkey. They are linked simply by being in the same register transaction. + + Once you have registered the pubkey(s), then you can do a send to it. Both pubkeys are used so that to spend you need to have a proper CC signature and a dilithium signature. The spend will necessarily need to have the almost 4kb signature in the opreturn, but at least the big pubkey is only referenced via the pubtxid + + + First register a pubkey,ie. bind handle, pub33 and bigpub together and then can be referred by pubtxid in other calls cclib register 19 \"[%22jl777%22]\" { @@ -2883,6 +2894,15 @@ int32_t main(void) the basics are working, now it is time to send and spend cclib send 19 \"[%22jl777%22,%229d856b2be6e54c8f04ae3f86aef722b0535180b3e9eb926c53740e481a1715f9%22,7.77]\" + { + "handle": "jl777", + "hex": "0400008085202f8901ff470ca3fb4f935a32dd312db801dcabce0e8b49c7774bb4f1d39a45b3a68bab0100000049483045022100d1c29d5f870dd18aa865e12632fa0cc8df9a8a770a23360e9c443d39cb141c5f0220304c7c77a6d711888d4bcb836530b6509eabe158496029b0bf57b5716f24beb101ffffffff034014502e00000000302ea22c8020b09ee47b12b5b9a2edcf0e7c4fb2a517b879eb88ac98b16185dfef476506b1dd8103120c008203000401cc3cd0ff7646070000232102aff51dad774a1c612dc82e63f85f07b992b665836b0f0efbcb26ee679f4f4848ac0000000000000000246a221378f915171a480e74536c92ebe9b3805153b022f7ae863fae048f4ce5e62b6b859d00000000120c00000000000000000000000000", + "txid": "4aac73ebe82c12665d1d005a0ae1a1493cb1e2c714680ef9d016f48a7c77b4a2", + "result": "success" + } + dont forget to broadcast it: 4aac73ebe82c12665d1d005a0ae1a1493cb1e2c714680ef9d016f48a7c77b4a2 + notice how small the tx is! 289 bytes as it is sent to the destpubtxid, which in turn contains the handle, pub33 and bigpub. the handle is used for error check, pub33 is used to make the destination CC address, so the normal CC signing needs to be passed in addition to the spend restrictions for dilithium. + */ From 4136857e21370a9c44a9afb0f3a963bc95bfb27b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 23:50:15 -1100 Subject: [PATCH 2627/3904] Guard against combining before having num music --- src/cc/musig.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index d93792463..33695aeaa 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -219,7 +219,7 @@ struct musig_info secp256k1_musig_session_signer_data *signer_data; //[N_SIGNERS]; secp256k1_pubkey *nonces; //[N_SIGNERS]; secp256k1_musig_partial_signature *partial_sig; //[N_SIGNERS]; - int32_t myind,num; + int32_t myind,num,numcommits,numnonces,numpartials; uint8_t msg[32],pkhash[32],combpk[33]; } *MUSIG; @@ -511,7 +511,8 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * number of signers participating in the MuSig. */ result.push_back(Pair("added_index",ind)); - if ( secp256k1_musig_session_get_public_nonce(ctx,&MUSIG->session,MUSIG->signer_data,&MUSIG->nonces[MUSIG->myind],MUSIG->commitment_ptrs,MUSIG->num) > 0 ) + MUSIG->numcommits++; + if ( MUSIG->numcommits >= MUSIG->num && secp256k1_musig_session_get_public_nonce(ctx,&MUSIG->session,MUSIG->signer_data,&MUSIG->nonces[MUSIG->myind],MUSIG->commitment_ptrs,MUSIG->num) > 0 ) { if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG->nonces[MUSIG->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) { @@ -583,7 +584,8 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * adaptor: point to add to the combined public nonce. If NULL, nothing is * added to the combined nonce. */ - if ( secp256k1_musig_session_combine_nonces(ctx,&MUSIG->session,MUSIG->signer_data,MUSIG->num,NULL,NULL) > 0 ) + MUSIG->numnonces++; + if ( MUSIG->numnonces >= MUSIG->num && secp256k1_musig_session_combine_nonces(ctx,&MUSIG->session,MUSIG->signer_data,MUSIG->num,NULL,NULL) > 0 ) { if ( secp256k1_musig_partial_sign(ctx,&MUSIG->session,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) { @@ -621,7 +623,8 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); result.push_back(Pair("added_index",ind)); - if ( secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) + MUSIG->numpartials++; + if ( MUSIG->numpartials >= MUSIG->num && secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) { if ( secp256k1_schnorrsig_serialize(ctx,out64,&sig) > 0 ) { From 8bfc74cef033bf4ed8d796a85e827a9acca0239f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 23 Feb 2019 23:52:24 -1100 Subject: [PATCH 2628/3904] Set numb to 1 --- src/cc/musig.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 33695aeaa..5986f8716 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -466,6 +466,7 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i<32; i++) sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitments[MUSIG->myind*32 + i]); str[64] = 0; + MUSIG->numcommits = 1; result.push_back(Pair("commitment",str)); result.push_back(Pair("result","success")); return(result); @@ -519,6 +520,7 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i<33; i++) sprintf(&str[i<<1],"%02x",((uint8_t *)pk.begin())[i]); str[66] = 0; + MUSIG->numnonces = 1; result.push_back(Pair("myind",MUSIG->myind)); result.push_back(Pair("nonce",str)); result.push_back(Pair("result","success")); @@ -597,6 +599,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("myind",MUSIG->myind)); result.push_back(Pair("partialsig",str)); result.push_back(Pair("result","success")); + MUSIG->numpartials = 1; return(result); } else return(cclib_error(result,"error serializing partial sig")); } else return(cclib_error(result,"error making partial sig")); From 9dcb99c828800311803140e37298d3f0204ced7e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:08:21 -1100 Subject: [PATCH 2629/3904] Dilithium spend --- src/cc/cclib.cpp | 4 +-- src/cc/dilithium.c | 74 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c64ac025b..b7b2db059 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -80,13 +80,13 @@ CClib_methods[] = { (char *)"musig", (char *)"partialsig", (char *)"pkhash,ind,partialsig", 3, 3, 'S', EVAL_MUSIG }, { (char *)"musig", (char *)"verify", (char *)"msg sig pubkey", 3, 3, 'V', EVAL_MUSIG }, { (char *)"musig", (char *)"send", (char *)"combined_pk amount", 2, 2, 'x', EVAL_MUSIG }, - { (char *)"musig", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_MUSIG }, + { (char *)"musig", (char *)"spend", (char *)"sendtxid sig scriptPubKey", 3, 3, 'y', EVAL_MUSIG }, { (char *)"dilithium", (char *)"keypair", (char *)"[hexseed]", 0, 1, 'K', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"register", (char *)"handle, [hexseed]", 1, 2, 'R', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"sign", (char *)"msg [hexseed]", 1, 2, 'S', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"verify", (char *)"pubtxid msg sig", 3, 3, 'V', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"send", (char *)"handle pubtxid amount", 3, 3, 'x', EVAL_DILITHIUM }, - { (char *)"dilithium", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"spend", (char *)"sendtxid scriptPubKey [hexseed]", 2, 3, 'y', EVAL_DILITHIUM }, #endif }; diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index ed0956c62..30fd2a3bd 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2947,6 +2947,24 @@ uint8_t dilithium_sendopretdecode(uint256 &destpubtxid,CScript scriptPubKey) return(0); } +CScript dilithium_spendopret(uint256 destpubtxid,std::vector sig) +{ + CScript opret; uint8_t evalcode = EVAL_DILITHIUM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'y' << destpubtxid << sig); + return(opret); +} + +uint8_t dilithium_spendopretdecode(uint256 &destpubtxid,std::vector &sig,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> destpubtxid; ss > sig) != 0 && e == EVAL_DILITHIUM && f == 'y' ) + { + return(f); + } + return(0); +} + UniValue dilithium_rawtxresult(UniValue &result,std::string rawtx) { CTransaction tx; @@ -3147,9 +3165,59 @@ UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } else return(cclib_error(result,"not enough parameters")); } +/* + ultimately what is needed is to be able to scan all utxos to the CC address and be able to spend many vins in the same tx. to do this the opreturn would need to be able to have txid of special with the sigs. However, it is complicated by the need to create a specific message to sign that is the desired outputs and all the inputs. Also, to properly be able to do change and keep everything in dilithium outputs, there needs to be a second destpub. + + so the proposed opreturn for spend would be: + + destpubtxid0, destpubtxid1 (zeroid if only 1), vector of sigs/sigtxid where if it is len 32 it is a txid that just has the sig in the opreturn. + + however, for now, to keep things simple we will only support spending a specific txid to normal output to avoid needing a combined opreturn and other complications. + */ + UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); - // copy musig method - return(result); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,destpub33; char *scriptstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock,destpubtxid; int32_t i,smlen,n,numvouts; char str[129]; CTxOut vout; std::string handle; uint8_t pk[CRYPTO_PUBLICKEYBYTES],pk2[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; std::vector sig; + if ( txfee == 0 ) + txfee = DILITHIUM_TXFEE; + mypk = pubkey2pk(Mypubkey()); + if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) + { + prevhash = juint256(jitem(params,0)); + scriptstr = jstr(jitem(params,1),0); + if ( n == 2 || cclib_parsehash(seed,jitem(params,2),32) < 0 ) + { + Myprivkey(seed); + result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); + } + _dilithium_keypair(pk,sk,seed); + if ( is_hexstr(scriptstr,0) != 0 ) + { + CScript scriptPubKey; + scriptPubKey.resize(strlen(scriptstr)/2); + decode_hex(&scriptPubKey[0],strlen(scriptstr)/2,scriptstr); + if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) + { + vout.nValue = vintx.vout[0].nValue - txfee; + vout.scriptPubKey = scriptPubKey; + musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); + sig.resize(32+CRYPTO_SIZE); + if ( dilithium_bigpubget(handle,destpub33,pk2,destpubtxid) < 0 ) + return(cclib_error(result,"couldnt parse message to sign")); + else if ( memcmp(pk,pk2,sizeof(pk)) != 0 ) + return(cclib_error(result,"dilithium bigpub mismatch")); + else if ( destpub33 != mypk ) + return(cclib_error(result,"destpub33 is not for this -pubkey")); + else if ( _dilithium_sign(&sig[0],&smlen,msg,32,sk) < 0 ) + return(cclib_error(result,"dilithium signing error")); + else if ( smlen != 32+CRYPTO_SIZE ) + return(cclib_error(result,"siglen error")); + mtx.vin.push_back(CTxIn(prevhash,0)); + mtx.vout.push_back(vout); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_spendopret('y',destpubtxid,sig)); + return(dilithium_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt find vin0")); + } else return(cclib_error(result,"script or bad destpubtxid is not hex")); + } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } From 1d4243bb951802fe5eed257161dcbbbdf307a10e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:11:30 -1100 Subject: [PATCH 2630/3904] > -> >> --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 30fd2a3bd..cc41d2360 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2958,7 +2958,7 @@ uint8_t dilithium_spendopretdecode(uint256 &destpubtxid,std::vector &si { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> destpubtxid; ss > sig) != 0 && e == EVAL_DILITHIUM && f == 'y' ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> destpubtxid; ss >> sig) != 0 && e == EVAL_DILITHIUM && f == 'y' ) { return(f); } From 852e7ce0162e18c31cbd500df5c7ed97c9e0e444 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:13:30 -1100 Subject: [PATCH 2631/3904] Syntax --- src/cc/dilithium.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index cc41d2360..197d62786 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3178,7 +3178,7 @@ UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,destpub33; char *scriptstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock,destpubtxid; int32_t i,smlen,n,numvouts; char str[129]; CTxOut vout; std::string handle; uint8_t pk[CRYPTO_PUBLICKEYBYTES],pk2[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; std::vector sig; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,destpub33; CTransaction vintx; uint256 prevhash,hashBlock,destpubtxid; int32_t i,smlen,n,numvouts; char str[129],*scriptstr; CTxOut vout; std::string handle; uint8_t pk[CRYPTO_PUBLICKEYBYTES],pk2[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES],msg[32],seed[32]; std::vector sig; if ( txfee == 0 ) txfee = DILITHIUM_TXFEE; mypk = pubkey2pk(Mypubkey()); @@ -3211,11 +3211,11 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(cclib_error(result,"destpub33 is not for this -pubkey")); else if ( _dilithium_sign(&sig[0],&smlen,msg,32,sk) < 0 ) return(cclib_error(result,"dilithium signing error")); - else if ( smlen != 32+CRYPTO_SIZE ) + else if ( smlen != 32+CRYPTO_BYTES ) return(cclib_error(result,"siglen error")); mtx.vin.push_back(CTxIn(prevhash,0)); mtx.vout.push_back(vout); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_spendopret('y',destpubtxid,sig)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_spendopret(destpubtxid,sig)); return(dilithium_rawtxresult(result,rawtx)); } else return(cclib_error(result,"couldnt find vin0")); } else return(cclib_error(result,"script or bad destpubtxid is not hex")); From 32a3cc94bbd6799754f083e0c2eb4fa86bb3f024 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:18:43 -1100 Subject: [PATCH 2632/3904] Prev --- src/cc/dilithium.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 197d62786..8a59ecba3 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2903,6 +2903,7 @@ int32_t main(void) dont forget to broadcast it: 4aac73ebe82c12665d1d005a0ae1a1493cb1e2c714680ef9d016f48a7c77b4a2 notice how small the tx is! 289 bytes as it is sent to the destpubtxid, which in turn contains the handle, pub33 and bigpub. the handle is used for error check, pub33 is used to make the destination CC address, so the normal CC signing needs to be passed in addition to the spend restrictions for dilithium. + cclib spend 19 \"[%224aac73ebe82c12665d1d005a0ae1a1493cb1e2c714680ef9d016f48a7c77b4a2%22,%22210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac%22]\" */ @@ -3182,6 +3183,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( txfee == 0 ) txfee = DILITHIUM_TXFEE; mypk = pubkey2pk(Mypubkey()); + fprintf(stderr,"inside\n"); if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) { prevhash = juint256(jitem(params,0)); @@ -3192,13 +3194,16 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); } _dilithium_keypair(pk,sk,seed); + fprintf(stderr,"after keypair\n"); if ( is_hexstr(scriptstr,0) != 0 ) { + fprintf(stderr,"have script\n"); CScript scriptPubKey; scriptPubKey.resize(strlen(scriptstr)/2); decode_hex(&scriptPubKey[0],strlen(scriptstr)/2,scriptstr); if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { + fprintf(stderr,"got tx\n"); vout.nValue = vintx.vout[0].nValue - txfee; vout.scriptPubKey = scriptPubKey; musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); @@ -3213,6 +3218,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(cclib_error(result,"dilithium signing error")); else if ( smlen != 32+CRYPTO_BYTES ) return(cclib_error(result,"siglen error")); + fprintf(stderr,"prepare tx\n"); mtx.vin.push_back(CTxIn(prevhash,0)); mtx.vout.push_back(vout); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_spendopret(destpubtxid,sig)); From 93770abb7e0fd41b1e75e936305a91db112cbf2f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:20:15 -1100 Subject: [PATCH 2633/3904] CRYPTO_BYTES --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 8a59ecba3..d1a700e0b 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3207,7 +3207,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params vout.nValue = vintx.vout[0].nValue - txfee; vout.scriptPubKey = scriptPubKey; musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); - sig.resize(32+CRYPTO_SIZE); + sig.resize(32+CRYPTO_BYTES); if ( dilithium_bigpubget(handle,destpub33,pk2,destpubtxid) < 0 ) return(cclib_error(result,"couldnt parse message to sign")); else if ( memcmp(pk,pk2,sizeof(pk)) != 0 ) From 6deb58ad51184bfb28e48b6be1b1440d201ecb94 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:24:31 -1100 Subject: [PATCH 2634/3904] Fix --- src/cc/dilithium.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index d1a700e0b..58a3fd514 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3183,7 +3183,6 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( txfee == 0 ) txfee = DILITHIUM_TXFEE; mypk = pubkey2pk(Mypubkey()); - fprintf(stderr,"inside\n"); if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) { prevhash = juint256(jitem(params,0)); @@ -3194,35 +3193,34 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); } _dilithium_keypair(pk,sk,seed); - fprintf(stderr,"after keypair\n"); if ( is_hexstr(scriptstr,0) != 0 ) { - fprintf(stderr,"have script\n"); CScript scriptPubKey; scriptPubKey.resize(strlen(scriptstr)/2); decode_hex(&scriptPubKey[0],strlen(scriptstr)/2,scriptstr); if ( myGetTransaction(prevhash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { - fprintf(stderr,"got tx\n"); vout.nValue = vintx.vout[0].nValue - txfee; vout.scriptPubKey = scriptPubKey; musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); sig.resize(32+CRYPTO_BYTES); - if ( dilithium_bigpubget(handle,destpub33,pk2,destpubtxid) < 0 ) - return(cclib_error(result,"couldnt parse message to sign")); - else if ( memcmp(pk,pk2,sizeof(pk)) != 0 ) - return(cclib_error(result,"dilithium bigpub mismatch")); - else if ( destpub33 != mypk ) - return(cclib_error(result,"destpub33 is not for this -pubkey")); - else if ( _dilithium_sign(&sig[0],&smlen,msg,32,sk) < 0 ) - return(cclib_error(result,"dilithium signing error")); - else if ( smlen != 32+CRYPTO_BYTES ) - return(cclib_error(result,"siglen error")); - fprintf(stderr,"prepare tx\n"); - mtx.vin.push_back(CTxIn(prevhash,0)); - mtx.vout.push_back(vout); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_spendopret(destpubtxid,sig)); - return(dilithium_rawtxresult(result,rawtx)); + if ( dilithium_sendopretdecode(destpubtxid,tx.vout[numvouts-1].scriptPubKey) == 'x' ) + { + if ( dilithium_bigpubget(handle,destpub33,pk2,destpubtxid) < 0 ) + return(cclib_error(result,"couldnt parse message to sign")); + else if ( memcmp(pk,pk2,sizeof(pk)) != 0 ) + return(cclib_error(result,"dilithium bigpub mismatch")); + else if ( destpub33 != mypk ) + return(cclib_error(result,"destpub33 is not for this -pubkey")); + else if ( _dilithium_sign(&sig[0],&smlen,msg,32,sk) < 0 ) + return(cclib_error(result,"dilithium signing error")); + else if ( smlen != 32+CRYPTO_BYTES ) + return(cclib_error(result,"siglen error")); + mtx.vin.push_back(CTxIn(prevhash,0)); + mtx.vout.push_back(vout); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_spendopret(destpubtxid,sig)); + return(dilithium_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt decode send opret")); } else return(cclib_error(result,"couldnt find vin0")); } else return(cclib_error(result,"script or bad destpubtxid is not hex")); } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); From c16c21f664a3ef3f448046f3b8680b70da9324b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:25:08 -1100 Subject: [PATCH 2635/3904] Vent --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 58a3fd514..94e2efc66 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3204,7 +3204,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params vout.scriptPubKey = scriptPubKey; musig_prevoutmsg(msg,prevhash,vout.scriptPubKey); sig.resize(32+CRYPTO_BYTES); - if ( dilithium_sendopretdecode(destpubtxid,tx.vout[numvouts-1].scriptPubKey) == 'x' ) + if ( dilithium_sendopretdecode(destpubtxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { if ( dilithium_bigpubget(handle,destpub33,pk2,destpubtxid) < 0 ) return(cclib_error(result,"couldnt parse message to sign")); From 57c1d1cc8c7303cf6bd81ca20b8e9358136e5fe0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:43:30 -1100 Subject: [PATCH 2636/3904] Dilithium validate --- src/cc/cclib.cpp | 3 +++ src/cc/dilithium.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b7b2db059..286008660 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -127,6 +127,7 @@ UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -406,6 +407,8 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(sudoku_validate(cp,height,eval,tx)); else if ( cp->evalcode == EVAL_MUSIG ) return(musig_validate(cp,height,eval,tx)); + else if ( cp->evalcode == DILITHIUM_MUSIG ) + return(dilithium_validate(cp,height,eval,tx)); else return eval->Invalid("invalid evalcode"); #endif } diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 94e2efc66..dc636d7e8 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3207,7 +3207,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( dilithium_sendopretdecode(destpubtxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { if ( dilithium_bigpubget(handle,destpub33,pk2,destpubtxid) < 0 ) - return(cclib_error(result,"couldnt parse message to sign")); + return(cclib_error(result,"couldnt get bigpub")); else if ( memcmp(pk,pk2,sizeof(pk)) != 0 ) return(cclib_error(result,"dilithium bigpub mismatch")); else if ( destpub33 != mypk ) @@ -3225,3 +3225,35 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else return(cclib_error(result,"script or bad destpubtxid is not hex")); } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } + +bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES]; + if ( tx.vout.size() != 2 ) + return eval->Invalid("numvouts != 2"); + else if ( tx.vin.size() != 1 ) + return eval->Invalid("numvins != 1"); + else if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) + return eval->Invalid("illegal normal vin0"); + else if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) + { + if ( dilithium_sendopretdecode(destpubtxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + { + if ( dilithium_spendopretdecode(checktxid,sig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) + { + if ( destpubtxid == checktxid ) + { + musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); + if ( dilithium_bigpubget(handle,destpub33,pk,destpubtxid) < 0 ) + return eval->Invalid(result,"couldnt get bigpub"); + else if ( _dilithium_verify(msg2,&mlen,&sig[0],(int32_t)sig.size(),pk) < 0 ) + return eval->Invalid("failed dilithium verify"); + else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) + return eval->Invalid("failed dilithium msg verify"); + else return eval->Invalid("this is actually success!"); + } else return eval->Invalid("destpubtxid didnt match send opret"); + } else return eval->Invalid("failed decode dilithium spendopret"); + } else return eval->Invalid("couldnt decode send opret"); + } else return eval->Invalid("couldnt find vin0 tx"); +} + From 0ee7d2fed4c0988e49cc79bbcc182cc7a3078213 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:45:00 -1100 Subject: [PATCH 2637/3904] Fix --- src/cc/cclib.cpp | 2 +- src/cc/dilithium.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 286008660..f7749d99f 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -407,7 +407,7 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(sudoku_validate(cp,height,eval,tx)); else if ( cp->evalcode == EVAL_MUSIG ) return(musig_validate(cp,height,eval,tx)); - else if ( cp->evalcode == DILITHIUM_MUSIG ) + else if ( cp->evalcode == EVAL_DILITHIUM ) return(dilithium_validate(cp,height,eval,tx)); else return eval->Invalid("invalid evalcode"); #endif diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index dc636d7e8..cf52a98c2 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3245,7 +3245,7 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con { musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); if ( dilithium_bigpubget(handle,destpub33,pk,destpubtxid) < 0 ) - return eval->Invalid(result,"couldnt get bigpub"); + return eval->Invalid("couldnt get bigpub"); else if ( _dilithium_verify(msg2,&mlen,&sig[0],(int32_t)sig.size(),pk) < 0 ) return eval->Invalid("failed dilithium verify"); else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) From 7f601cbfc7b284aceea87bc87d8721cab85c640a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:50:16 -1100 Subject: [PATCH 2638/3904] +print --- src/cc/dilithium.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index cf52a98c2..bb6b06e91 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3237,13 +3237,18 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con return eval->Invalid("illegal normal vin0"); else if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { + fprintf(stderr,"inside\n"); if ( dilithium_sendopretdecode(destpubtxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { + fprintf(stderr,"about to spendopret\n"); if ( dilithium_spendopretdecode(checktxid,sig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) { - if ( destpubtxid == checktxid ) + fprintf(stderr,"checktxid.%s vs %s\n",destpubtxid.GetHex().c_str(),checktxid.GetHex().c_str()); + if ( destpubtxid == checktxid && sig.size() == CRYPTO_BYTES+32 ) { + fprintf(stderr,"call prevoutmsg\n"); musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); + fprintf(stderr,"call dilithium_bigpubget\n"); if ( dilithium_bigpubget(handle,destpub33,pk,destpubtxid) < 0 ) return eval->Invalid("couldnt get bigpub"); else if ( _dilithium_verify(msg2,&mlen,&sig[0],(int32_t)sig.size(),pk) < 0 ) @@ -3251,7 +3256,7 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) return eval->Invalid("failed dilithium msg verify"); else return eval->Invalid("this is actually success!"); - } else return eval->Invalid("destpubtxid didnt match send opret"); + } else return eval->Invalid("destpubtxid or sig size didnt match send opret"); } else return eval->Invalid("failed decode dilithium spendopret"); } else return eval->Invalid("couldnt decode send opret"); } else return eval->Invalid("couldnt find vin0 tx"); From 97db451dc1e635801dcacf277af8d94538590247 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:55:31 -1100 Subject: [PATCH 2639/3904] Bigger msg2 --- src/cc/dilithium.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index bb6b06e91..5e6b926fa 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3109,7 +3109,7 @@ UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t rmd160[20],msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES],sm[32+CRYPTO_BYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t smlen=32+CRYPTO_BYTES,mlen,n; std::string handle; + UniValue result(UniValue::VOBJ); CPubKey pk33; uint8_t rmd160[20],msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],sm[32+CRYPTO_BYTES]; uint256 pubtxid; char coinaddr[64],str[(32+CRYPTO_BYTES)*2+1]; int32_t smlen=32+CRYPTO_BYTES,mlen,n; std::string handle; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) { pubtxid = juint256(jitem(params,0)); @@ -3228,7 +3228,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig; uint8_t msg[32],msg2[32],pk[CRYPTO_PUBLICKEYBYTES]; + CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES]; if ( tx.vout.size() != 2 ) return eval->Invalid("numvouts != 2"); else if ( tx.vin.size() != 1 ) @@ -3244,18 +3244,22 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con if ( dilithium_spendopretdecode(checktxid,sig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) { fprintf(stderr,"checktxid.%s vs %s\n",destpubtxid.GetHex().c_str(),checktxid.GetHex().c_str()); - if ( destpubtxid == checktxid && sig.size() == CRYPTO_BYTES+32 ) + if ( destpubtxid == checktxid && sig.size() == smlen ) { fprintf(stderr,"call prevoutmsg\n"); musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); fprintf(stderr,"call dilithium_bigpubget\n"); if ( dilithium_bigpubget(handle,destpub33,pk,destpubtxid) < 0 ) return eval->Invalid("couldnt get bigpub"); - else if ( _dilithium_verify(msg2,&mlen,&sig[0],(int32_t)sig.size(),pk) < 0 ) - return eval->Invalid("failed dilithium verify"); - else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) - return eval->Invalid("failed dilithium msg verify"); - else return eval->Invalid("this is actually success!"); + else + { + fprintf(stderr,"call _dilithium_verify\n"); + if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 ) + return eval->Invalid("failed dilithium verify"); + else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) + return eval->Invalid("failed dilithium msg verify"); + else return eval->Invalid("this is actually success!"); + } } else return eval->Invalid("destpubtxid or sig size didnt match send opret"); } else return eval->Invalid("failed decode dilithium spendopret"); } else return eval->Invalid("couldnt decode send opret"); From 38a94fefae6a9a7f448a056dbcc47a1993c370e8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 06:58:12 -1100 Subject: [PATCH 2640/3904] Test bad sig --- src/cc/dilithium.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 5e6b926fa..8c56b0bc7 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3237,23 +3237,18 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con return eval->Invalid("illegal normal vin0"); else if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { - fprintf(stderr,"inside\n"); if ( dilithium_sendopretdecode(destpubtxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { - fprintf(stderr,"about to spendopret\n"); if ( dilithium_spendopretdecode(checktxid,sig,tx.vout[tx.vout.size()-1].scriptPubKey) == 'y' ) { - fprintf(stderr,"checktxid.%s vs %s\n",destpubtxid.GetHex().c_str(),checktxid.GetHex().c_str()); if ( destpubtxid == checktxid && sig.size() == smlen ) { - fprintf(stderr,"call prevoutmsg\n"); musig_prevoutmsg(msg,tx.vin[0].prevout.hash,tx.vout[0].scriptPubKey); - fprintf(stderr,"call dilithium_bigpubget\n"); if ( dilithium_bigpubget(handle,destpub33,pk,destpubtxid) < 0 ) return eval->Invalid("couldnt get bigpub"); else { - fprintf(stderr,"call _dilithium_verify\n"); + sig[777] ^= 0xaa; if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 ) return eval->Invalid("failed dilithium verify"); else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) From ddae255171e120b7fdb00bfef1a744a98352c6a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 07:00:21 -1100 Subject: [PATCH 2641/3904] Dlithium validation active, hardforking change --- src/cc/dilithium.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 8c56b0bc7..ab8ca9ae5 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2905,6 +2905,9 @@ int32_t main(void) cclib spend 19 \"[%224aac73ebe82c12665d1d005a0ae1a1493cb1e2c714680ef9d016f48a7c77b4a2%22,%22210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac%22]\" + this generates a really big hex, broadcast it and if all went well it will get confirmed. + a dilithium spend! + */ #define DILITHIUM_TXFEE 10000 @@ -3248,12 +3251,11 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con return eval->Invalid("couldnt get bigpub"); else { - sig[777] ^= 0xaa; if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 ) return eval->Invalid("failed dilithium verify"); else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) return eval->Invalid("failed dilithium msg verify"); - else return eval->Invalid("this is actually success!"); + else return(true); } } else return eval->Invalid("destpubtxid or sig size didnt match send opret"); } else return eval->Invalid("failed decode dilithium spendopret"); From 98d8d03e2f8928e74cc8b3700c041806a3cf39ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 07:27:30 -1100 Subject: [PATCH 2642/3904] Gold * gold payout algo change --- src/cc/rogue_rpc.cpp | 106 ++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8cfb4379f..16c09fbe9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -947,6 +947,56 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) +{ + static uint32_t good,bad; static uint256 prevgame; + char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; CPubKey roguepk; struct rogue_player P; + if ( gametxid == prevgame ) + return(0); + prevgame = gametxid; + roguepk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,rogueaddr,roguepk,pk); + //fprintf(stderr,"call extractgame\n"); + if ( (keystrokes= rogue_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) + { + //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); + free(keystrokes); + //fprintf(stderr,"extracted.(%s)\n",str); + if ( newdata == playerdata ) + { + good++; + fprintf(stderr,"%s good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); + return(0); + } + newdata[10] = newdata[11] = playerdata[10] = playerdata[11] = 0; + if ( newdata == playerdata ) + { + good++; + fprintf(stderr,"%s matched after clearing maxstrength good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); + return(0); + } + for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); + } + bad++; + fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + } + //fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); + return(-1); +} + UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,char *method) { //vin0 -> highlander vout from creategame TCBOO @@ -975,12 +1025,12 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( strcmp(method,"bailout") == 0 ) { funcid = 'Q'; - mult = 100000; + mult = 100; //100000; } else { funcid = 'H'; - mult = 200000; + mult = 200; //200000; } if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { @@ -1005,7 +1055,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); if ( keystrokes != 0 ) - free(keystrokes); + free(keystrokes), keystrokes = 0; } else num = 0; mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); mtx.vin.push_back(CTxIn(gametxid,1+maxplayers+regslot,CScript())); @@ -1034,7 +1084,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); if ( P.amulet != 0 ) mult *= 5; - cashout = (uint64_t)P.gold * mult; + cashout = (uint64_t)P.gold * P.gold * mult; fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( funcid == 'H' && maxplayers > 1 ) { @@ -1051,7 +1101,6 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } } mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); - Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); CScript opret; @@ -1245,53 +1294,6 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) -{ - static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; CPubKey roguepk; struct rogue_player P; - if ( gametxid == prevgame ) - return(0); - prevgame = gametxid; - roguepk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,rogueaddr,roguepk,pk); - //fprintf(stderr,"call extractgame\n"); - if ( (keystrokes= rogue_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) - { - //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); - free(keystrokes); - //fprintf(stderr,"extracted.(%s)\n",str); - if ( newdata == playerdata ) - { - good++; - fprintf(stderr,"%s good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); - return(0); - } - newdata[10] = newdata[11] = playerdata[10] = playerdata[11] = 0; - if ( newdata == playerdata ) - { - good++; - fprintf(stderr,"%s matched after clearing maxstrength good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); - return(0); - } - for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); - if ( newdata.size() == 0 ) - { - good++; - return(0); - } - } - bad++; - fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); - } - //fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); - return(-1); -} - bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; From 4dcef6624bc8f2c1da09a9e8e78bca8357872028 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 08:17:20 -1100 Subject: [PATCH 2643/3904] Delay after keystrokes --- src/cc/rogue/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 165f01dfd..4dba36f2b 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -726,9 +726,10 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { - //fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); + fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); free(retstr); } + sleep(1); } } } From b88129c21cfeb98a32131056daafdcfc462652b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 08:19:09 -1100 Subject: [PATCH 2644/3904] Force keystrokes --- src/cc/rogue/rogue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index e8de063de..52d41435c 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -567,6 +567,8 @@ playit(struct rogue_state *rs) } } } + if ( rs->guiflag != 0 ) + flushkeystrokes(rs); endit(0); } From 46055e824fbf3d9b1e132863026faef9eb30236e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 08:29:21 -1100 Subject: [PATCH 2645/3904] Log keystrokes to keystrokes.log --- src/cc/rogue/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 4dba36f2b..5de27317e 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -723,10 +723,17 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ } else { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("keystrokes.log","a"); sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { - fprintf(stderr,"KEYSTROKES.(%s)\n",retstr); + if ( fp != 0 ) + { + fprintf(fp,"%s\n",retstr); + fflush(fp); + } free(retstr); } sleep(1); From df66ea2b9da0a3bcafc4517077736607cf255f8e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 08:37:33 -1100 Subject: [PATCH 2646/3904] Kill the zombies --- src/cc/rogue/state.c | 2 +- src/cc/rogue_rpc.cpp | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 7a0e2e4c6..b0176a042 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1432,7 +1432,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) if ( o->_o._o_packch != 0 ) { item = &rs->P.roguepack[rs->P.packsize]; - if ( 0 && pstats.s_hpt <= 0 ) + if ( 1 && pstats.s_hpt <= 0 ) { //fprintf(stderr,"KILLED\n"); rs->P.gold = -1; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 16c09fbe9..4790932d1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -883,13 +883,22 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { //fprintf(stderr,"zero value character was killed -> no playerdata\n"); - //newdata.resize(0); - P.gold = (P.gold * 8) / 10; + newdata.resize(0); + //P.gold = (P.gold * 8) / 10; + if ( keystrokes != 0 ) + { + free(keystrokes); + keystrokes = 0; + *numkeysp = 0; + } + } + else + { + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); + fprintf(stderr,"%s\n",str); + *numkeysp = numkeys; + return(keystrokes); } - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); - fprintf(stderr,"%s\n",str); - *numkeysp = numkeys; - return(keystrokes); } else num = 0; } else @@ -979,9 +988,9 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp ((uint8_t *)&P)[i] = playerdata[i]; if ( P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) { - P.gold = (P.gold * 8) / 10; - for (i=0; i no playerdata\n"); - //newdata.resize(0); - P.gold = (P.gold * 8) / 10; + newdata.resize(0); + //P.gold = (P.gold * 8) / 10; } - //else + else { //if ( maxplayers == 1 ) // mult /= 2; From b0735e2f327ce7ca08224e274b86a3a177a9d2d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 09:11:38 -1100 Subject: [PATCH 2647/3904] Gold payout = (gold * gold * level * 10) satoshi --- src/cc/rogue_rpc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4790932d1..1a4f7c1cd 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1020,7 +1020,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) @@ -1034,12 +1034,12 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( strcmp(method,"bailout") == 0 ) { funcid = 'Q'; - mult = 100; //100000; + mult = 10; //100000; } else { funcid = 'H'; - mult = 200; //200000; + mult = 20; //200000; } if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { @@ -1093,7 +1093,10 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); if ( P.amulet != 0 ) mult *= 5; - cashout = (uint64_t)P.gold * P.gold * mult; + dungeonlevel = P.dungeonlevel; + if ( P.amulet != 0 && dungeonlevel < 21 ) + dungeonlevel = 21; + cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel; fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( funcid == 'H' && maxplayers > 1 ) { From 8c5ba39d22f91af50e0bf93d1e7cd2f1dce5828f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Feb 2019 13:18:14 +0800 Subject: [PATCH 2648/3904] fix ipaddress --- src/cc/rogue/main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 5de27317e..02690a482 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -587,9 +587,9 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char * return(chunk.memory); } -uint16_t _komodo_userpass(char *username, char *password, char *ipaddress, FILE *fp) +uint16_t _komodo_userpass(char *username, char *password, FILE *fp) { - char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0; + char *rpcuser,*rpcpassword,*str,*ipaddress,line[8192]; uint16_t port = 0; rpcuser = rpcpassword = 0; username[0] = password[0] = 0; while ( fgets(line,sizeof(line),fp) != 0 ) @@ -609,6 +609,7 @@ uint16_t _komodo_userpass(char *username, char *password, char *ipaddress, FILE else if ( (str= strstr(line,(char *)"ipaddress")) != 0 ) { ipaddress = parse_conf_line(str,(char *)"ipaddress"); + strcpy(IPADDRESS,ipaddress); } } if ( rpcuser != 0 && rpcpassword != 0 ) @@ -616,7 +617,7 @@ uint16_t _komodo_userpass(char *username, char *password, char *ipaddress, FILE strcpy(username,rpcuser); strcpy(password,rpcpassword); } - //printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port); + //printf("rpcuser.(%s) rpcpassword.(%s) %u ipaddress.%s\n",rpcuser,rpcpassword,port,ipaddress); if ( rpcuser != 0 ) free(rpcuser); if ( rpcpassword != 0 ) @@ -661,7 +662,7 @@ uint16_t _komodo_userpass(char *username, char *password, char *ipaddress, FILE //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname); }*/ -uint16_t komodo_userpass(char *userpass,char *symbol,char *ipaddress) +uint16_t komodo_userpass(char *userpass,char *symbol) { FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[KOMODO_ASSETCHAIN_MAXLEN]; userpass[0] = 0; @@ -677,7 +678,7 @@ uint16_t komodo_userpass(char *userpass,char *symbol,char *ipaddress) //komodo_statefname(fname,symbol,confname); if ( (fp= fopen(confname,"rb")) != 0 ) { - port = _komodo_userpass(username,password,ipaddress,fp); + port = _komodo_userpass(username,password,fp); sprintf(userpass,"%s:%s",username,password); if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 ) strcpy(USERPASS,userpass); @@ -809,10 +810,10 @@ int main(int argc, char **argv, char **envp) ASSETCHAINS_SYMBOL[j++] = toupper(c); } ASSETCHAINS_SYMBOL[j++] = 0; - ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL,IPADDRESS); + ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL); if ( IPADDRESS[0] == 0 ) strcpy(IPADDRESS,"127.0.0.1"); - printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s)\n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS); sleep(1); + printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s) IPADDRESS.%s \n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS,IPADDRESS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { seed = atol(argv[1]); From 6f5d9655c903ae265eb0f0cb72da4cf9af4b0b9d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Feb 2019 13:20:48 +0800 Subject: [PATCH 2649/3904] fix --- src/musigtest.py | 189 --------------------------------------- src/wallet/rpcwallet.cpp | 8 +- 2 files changed, 4 insertions(+), 193 deletions(-) delete mode 100755 src/musigtest.py diff --git a/src/musigtest.py b/src/musigtest.py deleted file mode 100755 index 0880f1494..000000000 --- a/src/musigtest.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env python3 -import platform -import os -import re -import json -import random -import base58 -import binascii -import hashlib -import sys -import time -from slickrpc import Proxy - -# fucntion to define rpc_connection -def def_credentials(chain): - rpcport = ''; - operating_system = platform.system() - if operating_system == 'Darwin': - ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' - elif operating_system == 'Linux': - ac_dir = os.environ['HOME'] + '/.komodo' - elif operating_system == 'Windows': - ac_dir = '%s/komodo/' % os.environ['APPDATA'] - if chain == 'KMD': - coin_config_file = str(ac_dir + '/komodo.conf') - else: - coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') - with open(coin_config_file, 'r') as f: - for line in f: - l = line.rstrip() - if re.search('rpcuser', l): - rpcuser = l.replace('rpcuser=', '') - elif re.search('rpcpassword', l): - rpcpassword = l.replace('rpcpassword=', '') - elif re.search('rpcport', l): - rpcport = l.replace('rpcport=', '') - if len(rpcport) == 0: - if chain == 'KMD': - rpcport = 7771 - else: - print("rpcport not in conf file, exiting") - print("check " + coin_config_file) - exit(1) - return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport)))) - - -# generate address, validate address, dump private key -def genvaldump(rpc_connection): - # get new address - address = rpc_connection.getnewaddress() - # validate address - validateaddress_result = rpc_connection.validateaddress(address) - pubkey = validateaddress_result['pubkey'] - address = validateaddress_result['address'] - # dump private key for the address - privkey = rpc_connection.dumpprivkey(address) - # function output - output = [pubkey, privkey, address] - return(output) - -CHAIN = 'MUSIG' #sys.argv[1] - -rpc = def_credentials(CHAIN) - -pubkeys = [] -address_info = [] -ret = input('Do you want to generate new pubkeys? ').lower() - -if ret.startswith('y'): - numpks = int(input('Enter number of pubkeys to combine: ')) - if os.path.isfile("list.json"): - print('Already have list.json, move it if you would like to generate a new set.') - sys.exit(0) - while len(address_info) < numpks: - addressinfo = genvaldump(rpc) - address_info.append(addressinfo) - f = open("list.json", "w+") - f.write(json.dumps(address_info)) -else: - if os.path.isfile("list.json"): - with open('list.json') as list: - address_info = json.load(list) - else: - sys.exit('No list.json you need to create new pubkeys!') - -for addressinfo in address_info: - pubkeys.append(addressinfo[0]) - -ret = rpc.setpubkey(pubkeys[0]) -ret = rpc.cclib("combine", "18", str(pubkeys)) -pkhash = str(ret['pkhash']) -combinedpk = str(ret['combined_pk']) -print('Your combined pubkey is: ' + combinedpk) -print('Your pkhash is: ' + pkhash) -amount = int(input('Enter amount to send: ')) -tmp = str([combinedpk, amount]) -hex = rpc.cclib("send", "18", tmp)['hex'] -senttxid = rpc.sendrawtransaction(hex) -print('Your senttxid is: ' + senttxid) - -print("Waiting for tx to be confirmed") -while True: - confirmed = int(rpc.gettransaction(senttxid)["confirmations"]) - if not confirmed: - time.sleep(10) - else: - print('SentTX confirmed') - break - -scriptPubKey = rpc.getrawtransaction(senttxid,1)['vout'][1]['scriptPubKey']['hex'] -print('Your scriptPubKey is: ' + scriptPubKey) -tmp = str([senttxid, scriptPubKey]) -msg = rpc.cclib("calcmsg", "18", tmp)['msg'] -print('Your msg is: ' + msg) - -i = 0; -commitments = [] -for pubkey in pubkeys: - ret = rpc.setpubkey(pubkey) - tmp = str([i, len(pubkeys), combinedpk, pkhash, msg]) - commitments.append(rpc.cclib("session", "18", tmp)['commitment']) - i = i + 1 - -#print(commitments) - -i = 0 -nonces = [] -for pubkey in pubkeys: - ret = rpc.setpubkey(pubkey) - n = 0 - for commitment in commitments: - tmp = str([i, pkhash, n, commitment]) - ret = rpc.cclib("commit", "18", tmp) - try: - nonces.append(ret['nonce']) - except: - x = 1 - n = n + 1 - i = i + 1 - -#print(nonces) - -i = 0 -partialsigs = [] -for pubkey in pubkeys: - ret = rpc.setpubkey(pubkey) - n = 0 - for nonce in nonces: - tmp = str([i, pkhash, n, nonce]) - ret = rpc.cclib("nonce", "18", tmp) - try: - partialsigs.append(ret['partialsig']) - except: - x = 1 - n = n + 1 - i = i + 1 - -#print(partialsigs) - -i = 0 -combinedsigs = [] -for pubkey in pubkeys: - ret = rpc.setpubkey(pubkey) - n = 0 - for partialsig in partialsigs: - tmp = str([i, pkhash, n, partialsig]) - ret = rpc.cclib("partialsig", "18", tmp) - try: - combinedsigs.append(ret['combinedsig']) - except: - x = 1 - n = n + 1 - i = i + 1 - -#print(combinedsigs) - -tmp = str([msg, combinedpk, combinedsigs[0]]) -ret = rpc.cclib("verify", "18", tmp) - -#print(ret) - -tmp = str([senttxid, scriptPubKey, combinedsigs[0]]) -ret = rpc.cclib("spend", "18", tmp) - -print(ret) - -ret = rpc.sendrawtransaction(ret['hex']) - -print(ret) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8cffd78f7..0ed2f866c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5308,8 +5308,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[64]; uint8_t pubkey33[33]; - //if ( NOTARY_PUBKEY33[0] == 0 ) - //{ + if ( NOTARY_PUBKEY33[0] == 0 ) + { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -5337,14 +5337,14 @@ UniValue setpubkey(const UniValue& params, bool fHelp) USE_EXTERNAL_PUBKEY = 1; } } else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - /*} + } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon, pubkey in use is below.")); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); std::string address_ret; address_ret.assign(Raddress); result.push_back(Pair("address",address_ret)); - }*/ + } result.push_back(Pair("pubkey", NOTARY_PUBKEY)); return result; } From c5930804ab2789402fa7c0a0d73460a1aa32488b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 18:24:33 -1100 Subject: [PATCH 2650/3904] Flush keystrokes every 1000 --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 52d41435c..53f6da353 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -560,7 +560,7 @@ playit(struct rogue_state *rs) } else { - if ( rs->needflush != 0 && rs->num > 8000 ) + if ( rs->needflush != 0 && rs->num > 1000 ) { if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; From 54ee605f7f5be48886c14e9bfbc56564096238f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 18:27:26 -1100 Subject: [PATCH 2651/3904] Save params in keystrokes.log --- src/cc/rogue/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 5de27317e..ec347dd12 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -731,6 +731,7 @@ void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_ { if ( fp != 0 ) { + fprintf(fp,"%s\n",params); fprintf(fp,"%s\n",retstr); fflush(fp); } From ab4a58ac9c36445d78e990cb7b9369dcf14138b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Feb 2019 13:43:49 +0800 Subject: [PATCH 2652/3904] fix getera --- src/rpc/misc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a6b0e7923..43733826d 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -93,6 +93,7 @@ int32_t getera(int timestamp) return(i); } } + return(0) } UniValue getiguanajson(const UniValue& params, bool fHelp) From a5d480a40e5ea6fca146407bceb525a0e139185e Mon Sep 17 00:00:00 2001 From: igorvoltaic Date: Mon, 25 Feb 2019 09:50:10 +0300 Subject: [PATCH 2653/3904] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a8582891..6cf69af16 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,12 @@ cd komodo ``` #### OSX -Ensure you have [brew](https://brew.sh) and the command line tools installed (comes automatically with XCode) and run: +Ensure you have [brew](https://brew.sh) and Command Line Tools installed. ```shell +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +# installs brew +xcode-select --install +# opens a pop-up window to install CLT without downloading large Xcode package brew update && brew install gcc@6 git clone https://github.com/komodoplatform/komodo --branch master --single-branch cd komodo From d8c4f6ec94f6252f3a5633ac2e4a807f7bfcb66a Mon Sep 17 00:00:00 2001 From: igorvoltaic Date: Mon, 25 Feb 2019 09:54:07 +0300 Subject: [PATCH 2654/3904] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6cf69af16..0f112982d 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Ensure you have [brew](https://brew.sh) and Command Line Tools installed. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # installs brew xcode-select --install -# opens a pop-up window to install CLT without downloading large Xcode package +# opens a pop-up window to install CLT without installing the entire Xcode package brew update && brew install gcc@6 git clone https://github.com/komodoplatform/komodo --branch master --single-branch cd komodo From 9ac98901880a29499aa290be22b1bc2b6d21be4b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Feb 2019 16:08:45 +0800 Subject: [PATCH 2655/3904] fix --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 43733826d..ef1c8bf5c 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -93,7 +93,7 @@ int32_t getera(int timestamp) return(i); } } - return(0) + return(0); } UniValue getiguanajson(const UniValue& params, bool fHelp) From e8a36b89826e934a20f95a229b3ab103a67414af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Feb 2019 17:12:25 +0800 Subject: [PATCH 2656/3904] Update to enable using a single node with musigtest.py script. Fix crash in nonce step. --- src/cc/musig.cpp | 126 +++++++++++++++--------- src/musigtest.py | 200 +++++++++++++++++++++++++++++++++++++++ src/wallet/rpcwallet.cpp | 2 +- 3 files changed, 282 insertions(+), 46 deletions(-) create mode 100755 src/musigtest.py diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 5986f8716..35293088c 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -33,7 +33,6 @@ } sendrawtransaction of the above hex. - ./komodo-cli -ac_name=MUSIG getrawtransaction 5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c 1 "vout": [ { @@ -83,7 +82,7 @@ the "msg" is what needs to be signed to create a valid spend 5 args: ind, numsigners, combined_pk, pkhash, message to be signed on node with pubkey: 02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28 - ./komodo-cli -ac_name=MUSIG cclib session 18 '[0,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","c1b34139744f3b54b652dc741ebd0f9d5b53ad28795cc6614dd8ad3aaabf15ae","f5d91999b23b85630a4cbd0baea3736529411b052cf5f1f4345c5d181af12825"]' + ./komodo-cli -ac_name=MUSIG cclib session 18 '[0,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]' { "myind": 0, "numsigners": 2, @@ -221,7 +220,9 @@ struct musig_info secp256k1_musig_partial_signature *partial_sig; //[N_SIGNERS]; int32_t myind,num,numcommits,numnonces,numpartials; uint8_t msg[32],pkhash[32],combpk[33]; -} *MUSIG; +}; + +std::vector MUSIG; struct musig_info *musig_infocreate(int32_t myind,int32_t num) { @@ -412,23 +413,33 @@ UniValue musig_combine(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t i,n,myind,num; char *pkstr,*pkhashstr,*msgstr; uint8_t session[32],msg[32],pkhash[32],privkey[32],pub33[33]; CPubKey pk; char str[67]; + UniValue result(UniValue::VOBJ); int32_t i,n,myind,num,musiglocation; char *pkstr,*pkhashstr,*msgstr; uint8_t session[32],msg[32],pkhash[32],privkey[32],pub33[33]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 5 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) >= 5 ) { myind = juint(jitem(params,0),0); num = juint(jitem(params,1),0); if ( myind < 0 || myind >= num || num <= 0 ) return(cclib_error(result,"illegal myindex and numsigners")); - if ( MUSIG != 0 ) - musig_infofree(MUSIG), MUSIG = 0; - MUSIG = musig_infocreate(myind,num); - if ( musig_parsepubkey(ctx,MUSIG->combined_pk,jitem(params,2)) < 0 ) + if ( n > 5 ) + musiglocation = juint(jitem(params,5),0); + else if ( n == 5 ) + musiglocation = 0; + //printf("number of params.%i musiglocation.%i\n",n,musiglocation); + if ( MUSIG.size() > musiglocation ) + { + for (int i = 0; i < MUSIG.size()-1; i++) + musig_infofree(MUSIG[i]); + MUSIG.clear(); + } + struct musig_info *temp_musig = musig_infocreate(myind,num); + MUSIG.push_back(temp_musig); + if ( musig_parsepubkey(ctx,MUSIG[musiglocation]->combined_pk,jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing combined_pubkey")); - else if ( cclib_parsehash(MUSIG->pkhash,jitem(params,3),32) < 0 ) + else if ( cclib_parsehash(MUSIG[musiglocation]->pkhash,jitem(params,3),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( cclib_parsehash(MUSIG->msg,jitem(params,4),32) < 0 ) + else if ( cclib_parsehash(MUSIG[musiglocation]->msg,jitem(params,4),32) < 0 ) return(cclib_error(result,"error parsing msg")); Myprivkey(privkey); GetRandBytes(session,32); @@ -458,15 +469,17 @@ UniValue musig_session(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * my_index: index of this signer in the signers array * seckey: the signer's 32-byte secret key (cannot be NULL) */ - if ( secp256k1_musig_session_initialize(ctx,&MUSIG->session,MUSIG->signer_data, &MUSIG->nonce_commitments[MUSIG->myind * 32],session,MUSIG->msg,&MUSIG->combined_pk,MUSIG->pkhash,MUSIG->num,MUSIG->myind,privkey) > 0 ) + //fprintf(stderr, "SESSION: struct_size.%li using struct %i\n",MUSIG.size(), musiglocation); + if ( secp256k1_musig_session_initialize(ctx,&MUSIG[musiglocation]->session,MUSIG[musiglocation]->signer_data, &MUSIG[musiglocation]->nonce_commitments[MUSIG[musiglocation]->myind * 32],session,MUSIG[musiglocation]->msg,&MUSIG[musiglocation]->combined_pk,MUSIG[musiglocation]->pkhash,MUSIG[musiglocation]->num,MUSIG[musiglocation]->myind,privkey) > 0 ) { memset(session,0,sizeof(session)); result.push_back(Pair("myind",(int64_t)myind)); result.push_back(Pair("numsigners",(int64_t)num)); for (i=0; i<32; i++) - sprintf(&str[i<<1],"%02x",MUSIG->nonce_commitments[MUSIG->myind*32 + i]); + sprintf(&str[i<<1],"%02x",MUSIG[musiglocation]->nonce_commitments[MUSIG[musiglocation]->myind*32 + i]); str[64] = 0; - MUSIG->numcommits = 1; + if ( n == 5 ) + MUSIG[musiglocation]->numcommits = 1; result.push_back(Pair("commitment",str)); result.push_back(Pair("result","success")); return(result); @@ -483,18 +496,22 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; size_t clen = CPubKey::PUBLIC_KEY_SIZE; - UniValue result(UniValue::VOBJ); int32_t i,n,ind; uint8_t pkhash[32]; CPubKey pk; char str[67]; + UniValue result(UniValue::VOBJ); int32_t i,n,ind,myind; uint8_t pkhash[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) >= 3 ) { + if ( n > 3 ) + myind = juint(jitem(params,3),0); + else if ( n == 3 ) + myind = 0; if ( cclib_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG[myind]->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); - else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG[myind]->num ) return(cclib_error(result,"illegal ind for session")); - else if ( cclib_parsehash(&MUSIG->nonce_commitments[ind*32],jitem(params,2),32) < 0 ) + else if ( cclib_parsehash(&MUSIG[myind]->nonce_commitments[ind*32],jitem(params,2),32) < 0 ) return(cclib_error(result,"error parsing commitment")); /** Gets the signer's public nonce given a list of all signers' data with commitments * @@ -512,16 +529,18 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * number of signers participating in the MuSig. */ result.push_back(Pair("added_index",ind)); - MUSIG->numcommits++; - if ( MUSIG->numcommits >= MUSIG->num && secp256k1_musig_session_get_public_nonce(ctx,&MUSIG->session,MUSIG->signer_data,&MUSIG->nonces[MUSIG->myind],MUSIG->commitment_ptrs,MUSIG->num) > 0 ) + //fprintf(stderr, "COMMIT: struct_size.%li using_struct.%i added_index.%i\n",MUSIG.size(), myind, ind); + MUSIG[myind]->numcommits++; + if ( MUSIG[myind]->numcommits >= MUSIG[myind]->num && secp256k1_musig_session_get_public_nonce(ctx,&MUSIG[myind]->session,MUSIG[myind]->signer_data,&MUSIG[myind]->nonces[MUSIG[myind]->myind],MUSIG[myind]->commitment_ptrs,MUSIG[myind]->num) > 0 ) { - if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG->nonces[MUSIG->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) + if ( secp256k1_ec_pubkey_serialize(ctx,(uint8_t *)pk.begin(),&clen,&MUSIG[myind]->nonces[MUSIG[myind]->myind],SECP256K1_EC_COMPRESSED) > 0 && clen == 33 ) { for (i=0; i<33; i++) sprintf(&str[i<<1],"%02x",((uint8_t *)pk.begin())[i]); str[66] = 0; - MUSIG->numnonces = 1; - result.push_back(Pair("myind",MUSIG->myind)); + if ( n == 5 ) + MUSIG[myind]->numnonces = 1; + result.push_back(Pair("myind",MUSIG[myind]->myind)); result.push_back(Pair("nonce",str)); result.push_back(Pair("result","success")); } else return(cclib_error(result,"error serializing nonce (pubkey)")); @@ -538,18 +557,22 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t i,n,ind; uint8_t pkhash[32],psig[32]; CPubKey pk; char str[67]; + UniValue result(UniValue::VOBJ); int32_t i,n,ind,myind; uint8_t pkhash[32],psig[32]; CPubKey pk; char str[67]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) >= 3 ) { + if ( n > 3 ) + myind = juint(jitem(params,3),0); + else if ( n == 3 ) + myind = 0; if ( cclib_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG[myind]->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); - else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG[myind]->num ) return(cclib_error(result,"illegal ind for session")); - else if ( musig_parsepubkey(ctx,MUSIG->nonces[ind],jitem(params,2)) < 0 ) + else if ( musig_parsepubkey(ctx,MUSIG[myind]->nonces[ind],jitem(params,2)) < 0 ) return(cclib_error(result,"error parsing nonce")); result.push_back(Pair("added_index",ind)); /** Checks a signer's public nonce against a commitment to said nonce, and update @@ -563,9 +586,17 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * with `musig_session_initialize_verifier`. * In: nonce: signer's alleged public nonce (cannot be NULL) */ - for (i=0; inum; i++) + MUSIG[myind]->numnonces++; + //fprintf(stderr, "NONCE: struct_size.%li using_struct.%i added_index.%i numnounces.%i num.%i\n",MUSIG.size(), myind, ind, MUSIG[myind]->numnonces, MUSIG[myind]->num); + if ( MUSIG[myind]->numnonces < MUSIG[myind]->num ) { - if ( secp256k1_musig_set_nonce(ctx,&MUSIG->signer_data[i],&MUSIG->nonces[i]) == 0 ) + result.push_back(Pair("status","not enough nonces")); + result.push_back(Pair("result","success")); + return(result); + } + for (i=0; inum; i++) + { + if ( secp256k1_musig_set_nonce(ctx,&MUSIG[myind]->signer_data[i],&MUSIG[myind]->nonces[i]) == 0 ) return(cclib_error(result,"error setting nonce")); } /** Updates a session with the combined public nonce of all signers. The combined @@ -586,20 +617,20 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) * adaptor: point to add to the combined public nonce. If NULL, nothing is * added to the combined nonce. */ - MUSIG->numnonces++; - if ( MUSIG->numnonces >= MUSIG->num && secp256k1_musig_session_combine_nonces(ctx,&MUSIG->session,MUSIG->signer_data,MUSIG->num,NULL,NULL) > 0 ) + if ( secp256k1_musig_session_combine_nonces(ctx,&MUSIG[myind]->session,MUSIG[myind]->signer_data,MUSIG[myind]->num,NULL,NULL) > 0 ) { - if ( secp256k1_musig_partial_sign(ctx,&MUSIG->session,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + if ( secp256k1_musig_partial_sign(ctx,&MUSIG[myind]->session,&MUSIG[myind]->partial_sig[MUSIG[myind]->myind]) > 0 ) { - if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG[myind]->partial_sig[MUSIG[myind]->myind]) > 0 ) { for (i=0; i<32; i++) sprintf(&str[i<<1],"%02x",psig[i]); str[64] = 0; - result.push_back(Pair("myind",MUSIG->myind)); + result.push_back(Pair("myind",MUSIG[myind]->myind)); result.push_back(Pair("partialsig",str)); result.push_back(Pair("result","success")); - MUSIG->numpartials = 1; + if ( n == 5 ) + MUSIG[myind]->numpartials = 1; return(result); } else return(cclib_error(result,"error serializing partial sig")); } else return(cclib_error(result,"error making partial sig")); @@ -610,24 +641,29 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static secp256k1_context *ctx; - UniValue result(UniValue::VOBJ); int32_t i,ind,n; uint8_t pkhash[32],psig[32],out64[64]; char str[129]; secp256k1_schnorrsig sig; + UniValue result(UniValue::VOBJ); int32_t i,ind,n,myind; uint8_t pkhash[32],psig[32],out64[64]; char str[129]; secp256k1_schnorrsig sig; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 3 ) + if ( params != 0 && (n= cJSON_GetArraySize(params)) >= 3 ) { + if ( n > 3 ) + myind = juint(jitem(params,3),0); + else if ( n == 3 ) + myind = 0; if ( cclib_parsehash(pkhash,jitem(params,0),32) < 0 ) return(cclib_error(result,"error parsing pkhash")); - else if ( memcmp(MUSIG->pkhash,pkhash,32) != 0 ) + else if ( memcmp(MUSIG[myind]->pkhash,pkhash,32) != 0 ) return(cclib_error(result,"pkhash doesnt match session pkhash")); - else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG->num ) + else if ( (ind= juint(jitem(params,1),0)) < 0 || ind >= MUSIG[myind]->num ) return(cclib_error(result,"illegal ind for session")); else if ( cclib_parsehash(psig,jitem(params,2),32) < 0 ) return(cclib_error(result,"error parsing psig")); - else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG->partial_sig[ind],psig) == 0 ) + else if ( secp256k1_musig_partial_signature_parse(ctx,&MUSIG[myind]->partial_sig[ind],psig) == 0 ) return(cclib_error(result,"error parsing partialsig")); result.push_back(Pair("added_index",ind)); - MUSIG->numpartials++; - if ( MUSIG->numpartials >= MUSIG->num && secp256k1_musig_partial_sig_combine(ctx,&MUSIG->session,&sig,MUSIG->partial_sig,MUSIG->num) > 0 ) + //fprintf(stderr, "SIG: struct_size.%li using_struct.%i added_index.%i\n",MUSIG.size(), myind, ind); + MUSIG[myind]->numpartials++; + if ( MUSIG[myind]->numpartials >= MUSIG[myind]->num && secp256k1_musig_partial_sig_combine(ctx,&MUSIG[myind]->session,&sig,MUSIG[myind]->partial_sig,MUSIG[myind]->num) > 0 ) { if ( secp256k1_schnorrsig_serialize(ctx,out64,&sig) > 0 ) { @@ -640,7 +676,7 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else { - if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG->partial_sig[MUSIG->myind]) > 0 ) + if ( secp256k1_musig_partial_signature_serialize(ctx,psig,&MUSIG[myind]->partial_sig[MUSIG[myind]->myind]) > 0 ) { result.push_back(Pair("myind",ind)); for (i=0; i<32; i++) diff --git a/src/musigtest.py b/src/musigtest.py new file mode 100755 index 000000000..a452b7e97 --- /dev/null +++ b/src/musigtest.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python3 +import platform +import os +import re +import json +import random +import base58 +import binascii +import hashlib +import sys +import time +from slickrpc import Proxy + +# fucntion to define rpc_connection +def def_credentials(chain): + rpcport = ''; + operating_system = platform.system() + if operating_system == 'Darwin': + ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' + elif operating_system == 'Linux': + ac_dir = os.environ['HOME'] + '/.komodo' + elif operating_system == 'Windows': + ac_dir = '%s/komodo/' % os.environ['APPDATA'] + if chain == 'KMD': + coin_config_file = str(ac_dir + '/komodo.conf') + else: + coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') + with open(coin_config_file, 'r') as f: + for line in f: + l = line.rstrip() + if re.search('rpcuser', l): + rpcuser = l.replace('rpcuser=', '') + elif re.search('rpcpassword', l): + rpcpassword = l.replace('rpcpassword=', '') + elif re.search('rpcport', l): + rpcport = l.replace('rpcport=', '') + if len(rpcport) == 0: + if chain == 'KMD': + rpcport = 7771 + else: + print("rpcport not in conf file, exiting") + print("check " + coin_config_file) + exit(1) + return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport)))) + + +# generate address, validate address, dump private key +def genvaldump(rpc_connection): + # get new address + address = rpc_connection.getnewaddress() + # validate address + validateaddress_result = rpc_connection.validateaddress(address) + pubkey = validateaddress_result['pubkey'] + address = validateaddress_result['address'] + # dump private key for the address + privkey = rpc_connection.dumpprivkey(address) + # function output + output = [pubkey, privkey, address] + return(output) + +CHAIN = 'MUSIG' #sys.argv[1] + +rpc = def_credentials(CHAIN) + +pubkeys = [] +address_info = [] +ret = input('Do you want to generate new pubkeys? ').lower() + +if ret.startswith('y'): + numpks = int(input('Enter number of pubkeys to combine: ')) + if os.path.isfile("list.json"): + print('Already have list.json, move it if you would like to generate a new set.') + sys.exit(0) + while len(address_info) < numpks: + addressinfo = genvaldump(rpc) + address_info.append(addressinfo) + f = open("list.json", "w+") + f.write(json.dumps(address_info)) +else: + if os.path.isfile("list.json"): + with open('list.json') as list: + address_info = json.load(list) + else: + sys.exit('No list.json you need to create new pubkeys!') + +for addressinfo in address_info: + pubkeys.append(addressinfo[0]) + +ret = rpc.setpubkey(pubkeys[0]) +ret = rpc.cclib("combine", "18", str(pubkeys)) +pkhash = str(ret['pkhash']) +combinedpk = str(ret['combined_pk']) +print('Your combined pubkey is: ' + combinedpk) +print('Your pkhash is: ' + pkhash) +amount = float(input('Enter amount to send: ')) +if amount == 0: + sys.exit('Cannot send 0 coins. Exiting.') +tmp = str([combinedpk, amount]) +hex = rpc.cclib("send", "18", tmp)['hex'] +senttxid = rpc.sendrawtransaction(hex) +print('Your senttxid is: ' + senttxid) + +print("Waiting for tx to be confirmed") +while True: + confirmed = int(rpc.gettransaction(senttxid)["confirmations"]) + if not confirmed: + time.sleep(10) + else: + print('SentTX confirmed') + break + +scriptPubKey = rpc.getrawtransaction(senttxid,1)['vout'][1]['scriptPubKey']['hex'] +print('Your scriptPubKey is: ' + scriptPubKey) +tmp = str([senttxid, scriptPubKey]) +msg = rpc.cclib("calcmsg", "18", tmp)['msg'] +print('Your msg is: ' + msg) + +i = 0; +commitments = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + tmp = str([i, len(pubkeys), combinedpk, pkhash, msg, i]) + commitments.append(rpc.cclib("session", "18", tmp)['commitment']) + i = i + 1 + +print("Created commitments sucessfully... Sending to all signers.") + +i = 0 +nonces = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + n = 0 + for commitment in commitments: + tmp = str([pkhash, n, commitment, i]) + ret = rpc.cclib("commit", "18", tmp) + try: + nonces.append(ret['nonce']) + except: + x = 1 + n = n + 1 + i = i + 1 + +print("Created nounce's sucessfully... Sending to all signers.") + +i = 0 +partialsigs = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + n = 0 + for nonce in nonces: + tmp = str([pkhash, n, nonce, i]) + ret = rpc.cclib("nonce", "18", tmp) + try: + partialsigs.append(ret['partialsig']) + except: + x = 1 + n = n + 1 + i = i + 1 + +print("Created partial sigs sucessfully... Sending to all signers.") + +i = 0 +combinedsigs = [] +for pubkey in pubkeys: + ret = rpc.setpubkey(pubkey) + n = 0 + for partialsig in partialsigs: + tmp = str([pkhash, n, partialsig, i]) + ret = rpc.cclib("partialsig", "18", tmp) + try: + combinedsigs.append(ret['combinedsig']) + except: + x = 1 + n = n + 1 + i = i + 1 + +print("Created combined sigs sucessfully... Verifying.") + +tmp = str([msg, combinedpk, combinedsigs[0]]) +ret = rpc.cclib("verify", "18", tmp) + +if ret['result'] != "success": + print(ret) + sys.exit('Could not verify signature.') + +print('Verified... Attempting to send.') + +tmp = str([senttxid, scriptPubKey, combinedsigs[0]]) +ret = rpc.cclib("spend", "18", tmp) + +if ret['result'] != "success": + print(ret) + sys.exit('Could not create spend transaction.') + +try: + ret = rpc.sendrawtransaction(ret['hex']) +except: + sys.exit('Could not send transaction.') + +print('Spent txid: ' + ret) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0ed2f866c..0e0ab9906 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5308,7 +5308,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[64]; uint8_t pubkey33[33]; - if ( NOTARY_PUBKEY33[0] == 0 ) + if ( NOTARY_PUBKEY33[0] == 0 || (strcmp(ASSETCHAINS_SYMBOL, "MUSIG") == 0) ) { if (strlen(params[0].get_str().c_str()) == 66) { From 4d4a74d917c80d4dc2fa46bdf40348049ef3ec8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 22:44:40 -1100 Subject: [PATCH 2657/3904] Cashout prints --- src/cc/dilithium.c | 1 + src/cc/rogue_rpc.cpp | 65 ++++++++++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index ab8ca9ae5..c0ff8f274 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3232,6 +3232,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES]; + // if all dilithium tx -> do multispend/send, else: if ( tx.vout.size() != 2 ) return eval->Invalid("numvouts != 2"); else if ( tx.vin.size() != 1 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1a4f7c1cd..3d9b02115 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -894,7 +894,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } else { - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); *numkeysp = numkeys; return(keystrokes); @@ -956,13 +956,11 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) +int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,numkeys; std::vector newdata; uint64_t seed; CPubKey roguepk; struct rogue_player P; - if ( gametxid == prevgame ) - return(0); - prevgame = gametxid; + char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed,mult = 10; CPubKey roguepk; struct rogue_player P; + *cashoutp = 0; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); //fprintf(stderr,"call extractgame\n"); @@ -971,21 +969,35 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); //fprintf(stderr,"extracted.(%s)\n",str); + for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); + } + *cashoutp = 0; return(0); } - fprintf(stderr,"zero value character was killed -> no playerdata, good.%d bad.%d\n",good,bad); } - bad++; - fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + if ( gametxid != prevgame ) + { + prevgame = gametxid; + bad++; + fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + } } //fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); return(-1); @@ -1308,7 +1329,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) @@ -1393,10 +1414,14 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C // verify pk belongs to this tx if ( playerdata.size() > 0 ) { - if ( rogue_playerdata_validate(ptxid,cp,playerdata,gametxid,pk) < 0 ) + if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) { //fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); - } //else fprintf(stderr,"ht.%d playertxid.%s validated\n",height,ptxid.GetHex().c_str()); + } + if ( funcid == 'H' ) + cashout *= 2; + if ( tx.vout.size() > 2 ) + fprintf(stderr,"ht.%d playertxid.%s cashout %.8f vs vout2 %.8f\n",height,ptxid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); } if ( funcid == 'Q' ) { From 4a09d29d0ddb199b94ddb3a35352343085409487 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 22:57:10 -1100 Subject: [PATCH 2658/3904] +print --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3d9b02115..f2b6b7986 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -518,7 +518,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1) < 0 ) { @@ -532,6 +532,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-2); } txid = spenttxid; + fprintf(stderr,"next txid.%s/v%d\n",txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) return(-3); if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) From c8d3d0c13b79ed62e56aeb51c2b377b3cc1b6f03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 22:59:31 -1100 Subject: [PATCH 2659/3904] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f2b6b7986..23204e225 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -505,7 +505,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } if ( matches == 1 ) { - if ( myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) + if ( 1 || myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) { numvouts = matchtx.vout.size(); //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); @@ -576,7 +576,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke else { fprintf(stderr,"already played\n"); - return(-5); + return(-6); } } return(-1); From 957343c1f4fbf420f3ff534c34b3cd2604fb9239 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 23:01:02 -1100 Subject: [PATCH 2660/3904] Fix can't find baton error --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 23204e225..305b6cd8f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -518,7 +518,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1) < 0 ) { @@ -532,7 +532,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-2); } txid = spenttxid; - fprintf(stderr,"next txid.%s/v%d\n",txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"next txid.%s/v%d\n",txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) return(-3); if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) From 8fa093fad2fce1a3470f9374418493864c30620b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 23:06:30 -1100 Subject: [PATCH 2661/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 305b6cd8f..4ce8a4748 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1417,7 +1417,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) { - //fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); } if ( funcid == 'H' ) cashout *= 2; From 9340287d340f9625e25f807d89858792161523d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 23:08:08 -1100 Subject: [PATCH 2662/3904] txid --- src/cc/rogue_rpc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4ce8a4748..d6a325fa1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1330,11 +1330,12 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) { + txid = tx.GetHash(); scriptPubKey = tx.vout[numvouts-1].scriptPubKey; GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() > 2 ) @@ -1422,7 +1423,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( funcid == 'H' ) cashout *= 2; if ( tx.vout.size() > 2 ) - fprintf(stderr,"ht.%d playertxid.%s cashout %.8f vs vout2 %.8f\n",height,ptxid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + fprintf(stderr,"ht.%d txid.%s cashout %.8f vs vout2 %.8f\n",height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); } if ( funcid == 'Q' ) { From 9a9204085bbce2aa2441c0ed55e358ef7772c59d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Feb 2019 23:18:35 -1100 Subject: [PATCH 2663/3904] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d6a325fa1..c8e37d161 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1422,7 +1422,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } if ( funcid == 'H' ) cashout *= 2; - if ( tx.vout.size() > 2 ) + if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout fprintf(stderr,"ht.%d txid.%s cashout %.8f vs vout2 %.8f\n",height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); } if ( funcid == 'Q' ) From 208aff399794b5eecc5f4c4ac79d7b9536d8391e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 01:58:46 -1100 Subject: [PATCH 2664/3904] Skip revalidating playertxid for asset tx --- src/cc/rogue_rpc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c8e37d161..d98a77711 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1406,6 +1406,16 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C break; } } + else // this is asset transaction, which means playerdata txid already confirmed + { + switch ( funcid ) + { + case 'H': // win + case 'Q': // bailout + return(true); + break; + } + } switch ( funcid ) { case 'R': // register From b711cfaee314f503d5897f14c1cf882eea5b450d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 02:18:53 -1100 Subject: [PATCH 2665/3904] Test --- src/cc/dilithium.c | 5 ++++- src/cc/rogue_rpc.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index c0ff8f274..9a9c4de71 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3231,8 +3231,11 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES]; + CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,numvins,mlen,smlen=CRYPTO_BYTES+32; std::vector sig; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES]; // if all dilithium tx -> do multispend/send, else: + numvouts = tx.vout.size(); + numvins = tx.vin.size(); + if ( tx.vout.size() != 2 ) return eval->Invalid("numvouts != 2"); else if ( tx.vin.size() != 1 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d98a77711..9accfe7f7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1330,7 +1330,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) @@ -1344,6 +1344,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C funcid = script[1]; if ( (e= script[0]) == EVAL_TOKENS ) { + tokentx = 1; if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) { if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) @@ -1408,13 +1409,14 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } else // this is asset transaction, which means playerdata txid already confirmed { - switch ( funcid ) + fprintf(stderr,"ht.%d tokentx.%d funcid.(%c)\n",height,tokentx,funcid); + /*switch ( funcid ) { case 'H': // win case 'Q': // bailout return(true); break; - } + }*/ } switch ( funcid ) { From 6e51ad8984a21a9e6e34b6bd96012f47978a2b4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 02:24:59 -1100 Subject: [PATCH 2666/3904] -print --- src/cc/rogue_rpc.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9accfe7f7..88b669799 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1407,17 +1407,6 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C break; } } - else // this is asset transaction, which means playerdata txid already confirmed - { - fprintf(stderr,"ht.%d tokentx.%d funcid.(%c)\n",height,tokentx,funcid); - /*switch ( funcid ) - { - case 'H': // win - case 'Q': // bailout - return(true); - break; - }*/ - } switch ( funcid ) { case 'R': // register From 3ac0038a15b63d913863981a068dfe4bd6097a03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 02:41:02 -1100 Subject: [PATCH 2667/3904] Rescue cancelled warriors --- src/cc/rogue_rpc.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 88b669799..aee151530 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -472,12 +472,25 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_t vout,uint256 origplayergame) { - int64_t txfee = 10000; + int64_t txfee = 10000; CTransaction tx; uint256 hashBlock; if ( CCgettxout(playertxid,vout,1) == 1 ) // not sure if this is enough validation { mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); return(0); - } else return(-1); + } + else + { + vout = 0; + if ( myGetTransaction(playertxid,tx,hashBlock) != 0 && tx.vout[vout].nValue == 1 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) + { + if ( CCgettxout(playertxid,vout,1) == 1 ) // not sure if this is enough validation + { + mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); + return(0); + } + } + return(-1); + } } int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) From d17312f526417ffe7fe9a928496be4d71e006d47 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 04:50:40 -1100 Subject: [PATCH 2668/3904] Qvalidate --- src/cc/dilithium.c | 106 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 4 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 9a9c4de71..1b3ed1d86 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2915,6 +2915,30 @@ int32_t main(void) void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); +int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector voutpubtxids) +{ + CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector vintxids; std::vector nValues; std::vector vinprevns; std::vector scriptPubKeys; + numvins = tx.vin.size(); + numvouts = tx.vout.size(); + if ( tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) + { + for (i=0; i bigpub) { CScript opret; uint8_t evalcode = EVAL_DILITHIUM; @@ -2969,6 +2993,24 @@ uint8_t dilithium_spendopretdecode(uint256 &destpubtxid,std::vector &si return(0); } +CScript dilithium_Qsendopret(uint256 destpubtxid,std::vectorsig,std::vector voutpubtxids) +{ + CScript opret; uint8_t evalcode = EVAL_DILITHIUM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'Q' << destpubtxid << sig << voutpubtxids); + return(opret); +} + +uint8_t dilithium_Qsendopretdecode(uint256 &destpubtxid,std::vector&sig,std::vector &voutpubtxids,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> destpubtxid; ss >> sig; ss >> voutpubtxids) != 0 && e == EVAL_DILITHIUM && f == 'Q' ) + { + return(f); + } + return(0); +} + UniValue dilithium_rawtxresult(UniValue &result,std::string rawtx) { CTransaction tx; @@ -3229,14 +3271,70 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } +bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + int32_t i,numvins,numvouts,mlen,smlen=CRYPTO_BYTES+32; CPubKey destpub33; std::string handle; uint256 tmptxid,hashBlock,destpubtxid,signerpubtxid; CTransaction vintx; std::vector tmpsig,sig,vopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; std::vector voutpubtxids; + numvins = tx.vin.size(); + signerpubtxid = zeriod; + for (i=0; i 1 ) + { + GetOpReturnData(vintx.vout[numvouts-1].scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( script[1] == 'Q' ) + { + if ( dilithium_Qsendopretdecode(tmptxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) != 'Q' ) + return eval->Invalid("couldnt decode destpubtxid from Qsend"); + else if ( vntx.vin[i].prevout.n > voutpubtxids.size() ) + return eval->Invalid("no destpubtxid for prevout.n"); + destpubtxid = voutpubtxids[vintx.vin[i].prevout.n]; + } + else + { + if ( dilithium_sendopretdecode(destpubtxid,vintx.vout[numvouts-1].scriptPubKey) != 'x' ) + return eval->Invalid("couldnt decode destpubtxid from send"); + } + if ( signerpubtxid == zeroid ) + signerpubtxid = destpubtxid; + else if ( destpubtxid != signerpubtxid ) + return eval->Invalid("destpubtxid of vini doesnt match first one"); + } + } + } + if ( signerpubtxid != zeroid ) + { + numvouts = tx.vout.size(); + if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen ) + { + if ( dilithium_Qmsghash(msg,tx,voutpubtxids) < 0 ) + return eval->Invalid("couldnt get Qmsghash"); + else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 ) + return eval->Invalid("couldnt get bigpub"); + else + { + if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 ) + return eval->Invalid("failed dilithium verify"); + else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) + return eval->Invalid("failed dilithium msg verify"); + else return eval->Invalid("this is actually a success"); + } + } else return eval->Invalid("failed decode Qsend"); + } else return eval->Invalid("unexpected zero signerpubtxid"); +} + bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,numvins,mlen,smlen=CRYPTO_BYTES+32; std::vector sig; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES]; + CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig,vpopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; // if all dilithium tx -> do multispend/send, else: numvouts = tx.vout.size(); - numvins = tx.vin.size(); - - if ( tx.vout.size() != 2 ) + GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); + script = (uint8_t *)vopret.data(); + if ( script[1] == 'Q' ) + return(dilithium_Qvalidate(cp,height,eval,tx)); + else if ( tx.vout.size() != 2 ) return eval->Invalid("numvouts != 2"); else if ( tx.vin.size() != 1 ) return eval->Invalid("numvins != 1"); From 3e5cd48c382daa653d0c8c8f7580d5a267ca83a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 04:52:10 -1100 Subject: [PATCH 2669/3904] Syntax --- src/cc/dilithium.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 1b3ed1d86..0a3ec40ea 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2929,8 +2929,8 @@ int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector vou } for (i=0; iInvalid("couldnt decode destpubtxid from Qsend"); - else if ( vntx.vin[i].prevout.n > voutpubtxids.size() ) + else if ( vintx.vin[i].prevout.n > voutpubtxids.size() ) return eval->Invalid("no destpubtxid for prevout.n"); destpubtxid = voutpubtxids[vintx.vin[i].prevout.n]; } @@ -3327,7 +3327,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig,vpopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; + CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig,vopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; // if all dilithium tx -> do multispend/send, else: numvouts = tx.vout.size(); GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); From 483ac5bbea0862f9128777cccc3328c73a2be5e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 04:56:10 -1100 Subject: [PATCH 2670/3904] Change to CTxout --- src/cc/dilithium.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 0a3ec40ea..ed23dd813 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2917,7 +2917,7 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160, int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector voutpubtxids) { - CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector vintxids; std::vector nValues; std::vector vinprevns; std::vector scriptPubKeys; + CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; numvins = tx.vin.size(); numvouts = tx.vout.size(); if ( tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) @@ -2928,11 +2928,9 @@ int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector vou vinprevns.push_back(tx.vin[i].prevout.n); } for (i=0; i tmpsig,sig,vopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; std::vector voutpubtxids; numvins = tx.vin.size(); - signerpubtxid = zeriod; + signerpubtxid = zeroid; for (i=0; i Date: Mon, 25 Feb 2019 06:43:39 -1100 Subject: [PATCH 2671/3904] Qsend rpc --- src/cc/cclib.cpp | 6 ++- src/cc/dilithium.c | 115 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 110 insertions(+), 11 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f7749d99f..121a16475 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -87,6 +87,7 @@ CClib_methods[] = { (char *)"dilithium", (char *)"verify", (char *)"pubtxid msg sig", 3, 3, 'V', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"send", (char *)"handle pubtxid amount", 3, 3, 'x', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"spend", (char *)"sendtxid scriptPubKey [hexseed]", 2, 3, 'y', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"Qsend", (char *)"mypubtxid hexseed/'mypriv' destpubtxid,amount, ...", 4, 66, 'Q', EVAL_DILITHIUM }, #endif }; @@ -134,6 +135,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #endif @@ -261,7 +263,9 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) } else if ( cp->evalcode == EVAL_DILITHIUM ) { - if ( strcmp(method,"send") == 0 ) + if ( strcmp(method,"Qsend") == 0 ) + return(dilithium_Qsend(txfee,cp,params)); + else if ( strcmp(method,"send") == 0 ) return(dilithium_send(txfee,cp,params)); else if ( strcmp(method,"spend") == 0 ) return(dilithium_spend(txfee,cp,params)); diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index ed23dd813..b04390323 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3209,16 +3209,6 @@ UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } else return(cclib_error(result,"not enough parameters")); } -/* - ultimately what is needed is to be able to scan all utxos to the CC address and be able to spend many vins in the same tx. to do this the opreturn would need to be able to have txid of special with the sigs. However, it is complicated by the need to create a specific message to sign that is the desired outputs and all the inputs. Also, to properly be able to do change and keep everything in dilithium outputs, there needs to be a second destpub. - - so the proposed opreturn for spend would be: - - destpubtxid0, destpubtxid1 (zeroid if only 1), vector of sigs/sigtxid where if it is len 32 it is a txid that just has the sig in the opreturn. - - however, for now, to keep things simple we will only support spending a specific txid to normal output to avoid needing a combined opreturn and other complications. - */ - UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -3269,6 +3259,111 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } +int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr) +{ + char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 tmptxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; + std::vector > unspentOutputs; + GetCCaddress(cp,coinaddr,pk); + SetCCunspents(unspentOutputs,coinaddr); + threshold = total/(maxinputs+1); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); + if ( it->second.satoshis < threshold || it->second.satoshis == DILITHIUM_TXFEE ) + continue; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts= vintx.vout.size()) > 1 ) + { + if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + { + if ( dilithium_Qsendopretdecode(tmptxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(tmptxid,tmpsig,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + { + if ( total != 0 && maxinputs != 0 ) + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + nValue = it->second.satoshis; + totalinputs += nValue; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) + break; + } + } //else fprintf(stderr,"nValue %.8f too small or already spent in mempool\n",(double)nValue/COIN); + } else fprintf(stderr,"couldnt get tx\n"); + } + return(totalinputs); +} + +UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,destpub33; CTransaction tx,vintx; uint256 prevhash,mypubtxid,hashBlock,destpubtxid; int64_t amount,inputsum,outputsum,change; int32_t i,smlen,n,numvouts; char str[129],myCCaddr[64],*scriptstr; CTxOut vout; std::string handle; uint8_t pk[CRYPTO_PUBLICKEYBYTES],pk2[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES],msg[32],seed[32]; std::vector sig; std::vector voutpubtxids; + if ( txfee == 0 ) + txfee = DILITHIUM_TXFEE; + mypk = pubkey2pk(Mypubkey()); + GetCCaddress(cp,myCCaddr,mypk); + if ( params != 0 && (n= cJSON_GetArraySize(params)) >= 4 && (n & 1) == 0 ) + { + mypubtxid = juint256(jitem(params,0)); + if ( cclib_parsehash(seed,jitem(params,1),32) < 0 ) + { + Myprivkey(seed); + result.push_back(Pair("warning","test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!!")); + } + _dilithium_keypair(pk,sk,seed); + outputsum = 0; + for (i=2; ievalcode,amount,destpub33)); + voutpubtxids.push_back(prevhash); // binds destpub22 CC addr with dilithium bigpub + } else return(cclib_error(result,"couldnt find bigpub at txid")); + } + else + { + CScript scriptPubKey; + scriptPubKey.resize(strlen(scriptstr)/2); + decode_hex(&scriptPubKey[0],strlen(scriptstr)/2,scriptstr); + vout.nValue = amount; + vout.scriptPubKey = scriptPubKey; + mtx.vout.push_back(vout); + voutpubtxids.push_back(zeroid); + } + outputsum += amount; + } + if ( (inputsum= dilithium_inputs(cp,mtx,mypk,outputsum+txfee,64,myCCaddr)) >= outputsum+txfee ) + { + change = (inputsum - outputsum - txfee) + if ( change >= txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,mypk)); + voutpubtxids.push_back(mypubtxid); + } + tx = mtx; + dilithium_Qmsghash(msg,tx,voutpubtxids); + sig.resize(32+CRYPTO_BYTES); + if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 ) + return(cclib_error(result,"couldnt get bigpub")); + else if ( memcmp(pk,pk2,sizeof(pk)) != 0 ) + return(cclib_error(result,"dilithium bigpub mismatch")); + else if ( destpub33 != mypk ) + return(cclib_error(result,"destpub33 is not for this -pubkey")); + else if ( _dilithium_sign(&sig[0],&smlen,msg,32,sk) < 0 ) + return(cclib_error(result,"dilithium signing error")); + else if ( smlen != 32+CRYPTO_BYTES ) + return(cclib_error(result,"siglen error")); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_Qsendopret(destpubtxid,sig,voutpubtxids)); + return(dilithium_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt find vin0")); + } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); +} + bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { int32_t i,numvins,numvouts,mlen,smlen=CRYPTO_BYTES+32; CPubKey destpub33; std::string handle; uint256 tmptxid,hashBlock,destpubtxid,signerpubtxid; CTransaction vintx; std::vector tmpsig,sig,vopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; std::vector voutpubtxids; From 6751dc52fce22e037a25b3e2b2536e20339b33d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 06:46:08 -1100 Subject: [PATCH 2672/3904] -DILITHIUM_TXFEE --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index b04390323..432b4b264 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3277,7 +3277,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( dilithium_Qsendopretdecode(tmptxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(tmptxid,tmpsig,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + if ( dilithium_Qsendopretdecode(tmptxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(tmptxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From a762316ef1b4a7886cfa944394a18fe23f40eacc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 06:46:28 -1100 Subject: [PATCH 2673/3904] ; --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 432b4b264..a0aadd209 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3339,7 +3339,7 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } if ( (inputsum= dilithium_inputs(cp,mtx,mypk,outputsum+txfee,64,myCCaddr)) >= outputsum+txfee ) { - change = (inputsum - outputsum - txfee) + change = (inputsum - outputsum - txfee); if ( change >= txfee ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,mypk)); From 4dff19ad47eaff67ce33ef3c3d0fe04968bdcd54 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 06:55:54 -1100 Subject: [PATCH 2674/3904] Fix --- src/cc/dilithium.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index a0aadd209..b7106a95d 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2908,6 +2908,14 @@ int32_t main(void) this generates a really big hex, broadcast it and if all went well it will get confirmed. a dilithium spend! + to generate a seed that wont be directly derivable from an secp256k1 keypair, do: + cclib keypair 19 \"[%22rand%22]\" + + to do a Qsend (multiple dilithium inputs and outputs) + + cclib Qsend 19 \"[%22mypubtxid%22,%22%22,%22%22,0.777]\" + there can be up to 64 outputs, where each one can be a different destpubtxid or scriptPubKey. The only restriction is that scriptPubKey hex cant be 32 bytes. + */ #define DILITHIUM_TXFEE 10000 @@ -3315,7 +3323,6 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { amount = jdouble(jitem(params,i+1),0)*COIN + 0.0000000049; scriptstr = jstr(jitem(params,i),0); - return(cclib_error(result,"illegal dest scriptPubKey")); if ( is_hexstr(scriptstr,0) == 64 ) { prevhash = juint256(jitem(params,i)); From 0b83ec2d379914cb6adff05cb47a307d1a0167fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 06:59:15 -1100 Subject: [PATCH 2675/3904] +filed --- src/cc/dilithium.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index b7106a95d..71cb505e7 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3330,7 +3330,12 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,destpub33)); voutpubtxids.push_back(prevhash); // binds destpub22 CC addr with dilithium bigpub - } else return(cclib_error(result,"couldnt find bigpub at txid")); + } + else + { + result.push_back(Pair("destpubtxid",prevhash.GetHex().c_str())); + return(cclib_error(result,"couldnt find bigpub at destpubtxid")); + } } else { From 3a117c9d928fad05b7e021bb75b78f286be7ce96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:05:27 -1100 Subject: [PATCH 2676/3904] +print --- src/cc/dilithium.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 71cb505e7..6277e95e0 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3062,15 +3062,18 @@ char *dilithium_hexstr(char *str,uint8_t *buf,int32_t len) int32_t dilithium_bigpubget(std::string &handle,CPubKey &pk33,uint8_t *pk,uint256 pubtxid) { - CTransaction tx; uint256 hashBlock; int32_t numvouts; std::vector bigpub; + CTransaction tx; uint8_t funcid; uint256 hashBlock; int32_t numvouts=0; std::vector bigpub; if ( myGetTransaction(pubtxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { - if ( dilithium_registeropretdecode(handle,pk33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' && bigpub.size() == CRYPTO_PUBLICKEYBYTES ) + if ( (funcid= dilithium_registeropretdecode(handle,pk33,bigpub,tx.vout[numvouts-1].scriptPubKey)) == 'R' && bigpub.size() == CRYPTO_PUBLICKEYBYTES ) { memcpy(pk,&bigpub[0],CRYPTO_PUBLICKEYBYTES); return(0); - } else return(-2); + } + fprintf(stderr,"%s funcid.(%c) size.%d vs %d\n",handle,funcid,(int32_t)bigpub.size(),CRYPTO_PUBLICKEYBYTES); + return(-2); } + fprintf(stderr,"numvouts.%d\n",numvouts); return(-1); } From e658b24151a468b67ae640466dade8516d4adb5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:06:07 -1100 Subject: [PATCH 2677/3904] .cstr --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 6277e95e0..8eadc72cd 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3070,7 +3070,7 @@ int32_t dilithium_bigpubget(std::string &handle,CPubKey &pk33,uint8_t *pk,uint25 memcpy(pk,&bigpub[0],CRYPTO_PUBLICKEYBYTES); return(0); } - fprintf(stderr,"%s funcid.(%c) size.%d vs %d\n",handle,funcid,(int32_t)bigpub.size(),CRYPTO_PUBLICKEYBYTES); + fprintf(stderr,"%s funcid.(%c) size.%d vs %d\n",handle.c_str(),funcid,(int32_t)bigpub.size(),CRYPTO_PUBLICKEYBYTES); return(-2); } fprintf(stderr,"numvouts.%d\n",numvouts); From fe7f9ef1bf132a069d0c0ac940e54c9dbabb9c51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:08:23 -1100 Subject: [PATCH 2678/3904] Test --- src/cc/dilithium.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 8eadc72cd..c0661b64a 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3329,6 +3329,7 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( is_hexstr(scriptstr,0) == 64 ) { prevhash = juint256(jitem(params,i)); + fprintf(stderr,"call bigpub\n"); if ( dilithium_bigpubget(handle,destpub33,pk2,prevhash) < 0 ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,destpub33)); From 51aa55d3be98e1957f9a993adbfedd932b649581 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:10:59 -1100 Subject: [PATCH 2679/3904] +print --- src/cc/dilithium.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index c0661b64a..e81425674 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3063,17 +3063,22 @@ char *dilithium_hexstr(char *str,uint8_t *buf,int32_t len) int32_t dilithium_bigpubget(std::string &handle,CPubKey &pk33,uint8_t *pk,uint256 pubtxid) { CTransaction tx; uint8_t funcid; uint256 hashBlock; int32_t numvouts=0; std::vector bigpub; - if ( myGetTransaction(pubtxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + fprintf(stderr,"inside bigpubget\n"); + if ( myGetTransaction(pubtxid,tx,hashBlock) != 0 ) { - if ( (funcid= dilithium_registeropretdecode(handle,pk33,bigpub,tx.vout[numvouts-1].scriptPubKey)) == 'R' && bigpub.size() == CRYPTO_PUBLICKEYBYTES ) + fprintf(stderr,"got tx\n"); + if ( (numvouts= tx.vout.size()) > 1 ) { - memcpy(pk,&bigpub[0],CRYPTO_PUBLICKEYBYTES); - return(0); + if ( (funcid= dilithium_registeropretdecode(handle,pk33,bigpub,tx.vout[numvouts-1].scriptPubKey)) == 'R' && bigpub.size() == CRYPTO_PUBLICKEYBYTES ) + { + memcpy(pk,&bigpub[0],CRYPTO_PUBLICKEYBYTES); + return(0); + } + fprintf(stderr,"%s funcid.(%c) size.%d vs %d\n",handle.c_str(),funcid,(int32_t)bigpub.size(),CRYPTO_PUBLICKEYBYTES); + return(-2); } - fprintf(stderr,"%s funcid.(%c) size.%d vs %d\n",handle.c_str(),funcid,(int32_t)bigpub.size(),CRYPTO_PUBLICKEYBYTES); - return(-2); - } - fprintf(stderr,"numvouts.%d\n",numvouts); + fprintf(stderr,"numvouts.%d\n",numvouts); + } else fprintf(stderr,"no tx\n"); return(-1); } From 1a7a8158d224ea8aaffe25a4a460d9320a7ed661 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:13:43 -1100 Subject: [PATCH 2680/3904] -print --- src/cc/dilithium.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index e81425674..18c3d8266 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3063,22 +3063,17 @@ char *dilithium_hexstr(char *str,uint8_t *buf,int32_t len) int32_t dilithium_bigpubget(std::string &handle,CPubKey &pk33,uint8_t *pk,uint256 pubtxid) { CTransaction tx; uint8_t funcid; uint256 hashBlock; int32_t numvouts=0; std::vector bigpub; - fprintf(stderr,"inside bigpubget\n"); if ( myGetTransaction(pubtxid,tx,hashBlock) != 0 ) { - fprintf(stderr,"got tx\n"); if ( (numvouts= tx.vout.size()) > 1 ) { if ( (funcid= dilithium_registeropretdecode(handle,pk33,bigpub,tx.vout[numvouts-1].scriptPubKey)) == 'R' && bigpub.size() == CRYPTO_PUBLICKEYBYTES ) { memcpy(pk,&bigpub[0],CRYPTO_PUBLICKEYBYTES); return(0); - } - fprintf(stderr,"%s funcid.(%c) size.%d vs %d\n",handle.c_str(),funcid,(int32_t)bigpub.size(),CRYPTO_PUBLICKEYBYTES); - return(-2); + } else return(-2); } - fprintf(stderr,"numvouts.%d\n",numvouts); - } else fprintf(stderr,"no tx\n"); + } return(-1); } @@ -3334,17 +3329,16 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( is_hexstr(scriptstr,0) == 64 ) { prevhash = juint256(jitem(params,i)); - fprintf(stderr,"call bigpub\n"); if ( dilithium_bigpubget(handle,destpub33,pk2,prevhash) < 0 ) - { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,destpub33)); - voutpubtxids.push_back(prevhash); // binds destpub22 CC addr with dilithium bigpub - } - else { result.push_back(Pair("destpubtxid",prevhash.GetHex().c_str())); return(cclib_error(result,"couldnt find bigpub at destpubtxid")); } + else + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,destpub33)); + voutpubtxids.push_back(prevhash); // binds destpub22 CC addr with dilithium bigpub + } } else { From 9754d8c501aa07acf49374c7fd65790ed607ca9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:15:48 -1100 Subject: [PATCH 2681/3904] Test --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 18c3d8266..15bf3e2a0 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3073,7 +3073,7 @@ int32_t dilithium_bigpubget(std::string &handle,CPubKey &pk33,uint8_t *pk,uint25 return(0); } else return(-2); } - } + } return(-1); } @@ -3375,7 +3375,7 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(cclib_error(result,"siglen error")); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_Qsendopret(destpubtxid,sig,voutpubtxids)); return(dilithium_rawtxresult(result,rawtx)); - } else return(cclib_error(result,"couldnt find vin0")); + } else return(cclib_error(result,"Q couldnt find enough Q or x inputs")); } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } From 2c52e2737a0c31e2c1feb485965bc3d83db53eb0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:19:38 -1100 Subject: [PATCH 2682/3904] Fix --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 15bf3e2a0..3917b61fe 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3373,7 +3373,7 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params return(cclib_error(result,"dilithium signing error")); else if ( smlen != 32+CRYPTO_BYTES ) return(cclib_error(result,"siglen error")); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_Qsendopret(destpubtxid,sig,voutpubtxids)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_Qsendopret(mypubtxid,sig,voutpubtxids)); return(dilithium_rawtxresult(result,rawtx)); } else return(cclib_error(result,"Q couldnt find enough Q or x inputs")); } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); From 7be98a290ec8523cc31940bd27731a1e627c2e67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:31:19 -1100 Subject: [PATCH 2683/3904] +comments --- src/cc/dilithium.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 3917b61fe..8b258bf49 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2916,6 +2916,12 @@ int32_t main(void) cclib Qsend 19 \"[%22mypubtxid%22,%22%22,%22%22,0.777]\" there can be up to 64 outputs, where each one can be a different destpubtxid or scriptPubKey. The only restriction is that scriptPubKey hex cant be 32 bytes. + Qsend is able to spend many Qvins as long as they are for the same dilithium bigpub + secp pub33. And the outputs can be to many different Qvouts or normal vouts. This allows to keep funds totally within the dilithium system and also to transfer back to normal taddrs. Qsend currently only sends from Qfunds, though it could also use funds from normal inputs. + + Currently, to get funds from normal inputs to a dilithium, the send rpc can be used as above. So that provides a way to push funds into dilithium. The spend rpc becomes redundant with Qsend. + + To properly test this, we need to make sure that transactions Qsend can use send outputs, and Qsend outputs and a combination. Of course, it needs to be validated that funds are not lost, Qsends work properly, etc. + */ #define DILITHIUM_TXFEE 10000 From 621ec418fb41fc8083d43534eb52333055ad5156 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 07:37:17 -1100 Subject: [PATCH 2684/3904] Return true --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 8b258bf49..1f893d268 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3433,7 +3433,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co return eval->Invalid("failed dilithium verify"); else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) return eval->Invalid("failed dilithium msg verify"); - else return eval->Invalid("this is actually a success"); + else return true; } } else return eval->Invalid("failed decode Qsend"); } else return eval->Invalid("unexpected zero signerpubtxid"); From 5c00bf5580e16a0a581e4649eec9fb208def2822 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 08:11:05 -1100 Subject: [PATCH 2685/3904] Print gametxid in playertxid --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index aee151530..4d98855d4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -364,7 +364,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } -UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname) +UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { int32_t i; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); @@ -385,6 +385,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint a.push_back(packitemstr); } obj.push_back(Pair("playertxid",playertxid.GetHex())); + obj.push_back(Pair("gametxid",gametxid.GetHex())); if ( tokenid != zeroid ) obj.push_back(Pair("tokenid",tokenid.GetHex())); else obj.push_back(Pair("tokenid",playertxid.GetHex())); @@ -625,7 +626,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); obj.push_back(Pair("batonht",(int64_t)batonht)); if ( playerdata.size() > 0 ) - obj.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid,symbol,pname))); + obj.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid,symbol,pname,gametxid))); } else fprintf(stderr,"findbaton err.%d\n",retval); } @@ -714,7 +715,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param playertxid = juint256(jitem(params,0)); if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) return(cclib_error(result,"invalid playerdata")); - result.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid,symbol,pname))); + result.push_back(Pair("player",rogue_playerobj(playerdata,playertxid,tokenid,symbol,pname,origplayergame))); } else return(cclib_error(result,"no playertxid")); return(result); } else return(cclib_error(result,"couldnt reparse params")); From 0d2bfae2bf13225d2ba9a0e1922d588005936554 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Tue, 26 Feb 2019 04:51:32 +0300 Subject: [PATCH 2686/3904] ILN --- src/ac/iln | 2 ++ src/assetchains.json | 9 ++++++++- src/assetchains.old | 2 +- src/fiat/iln | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 src/ac/iln create mode 100755 src/fiat/iln diff --git a/src/ac/iln b/src/ac/iln new file mode 100755 index 000000000..f453c338e --- /dev/null +++ b/src/ac/iln @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index 2775f5db3..c4e61d395 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -240,5 +240,12 @@ "217.182.129.38", "37.187.225.231" ] - } + }, + { + "ac_name": "ILN", + "ac_supply": "10000000000", + "ac_cc": "2", + "addnode": ["51.75.122.83"] + } + ] diff --git a/src/assetchains.old b/src/assetchains.old index 41cbbdae1..bb493da9f 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -47,4 +47,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & - +./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addnode=51.75.122.83 & diff --git a/src/fiat/iln b/src/fiat/iln new file mode 100755 index 000000000..f453c338e --- /dev/null +++ b/src/fiat/iln @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 From f76ceced5be31c1483e77a5be26166426a3e9c47 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 11:14:19 +0800 Subject: [PATCH 2687/3904] make notarypay work with KMD notaries --- src/komodo_bitcoind.h | 33 ++++++++++++++++----------------- src/miner.cpp | 28 ++++++++++++---------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index eafcf16f7..a7dd2027c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -25,6 +25,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); +int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); bool EnsureWalletIsAvailable(bool avoidException); extern bool fRequestShutdown; @@ -1825,8 +1826,6 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) return(ret); } -int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); - int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len) { // Check the notarisation is valid, and extract notarised height. @@ -1855,13 +1854,12 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar { // fetch notary pubkey array. uint64_t total = 0, AmountToPay = 0; - int32_t staked_era; int8_t numSN; - uint8_t staked_pubkeys[64][33]; - staked_era = STAKED_era(timestamp); + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + numSN = komodo_notaries(notarypubkeys, height, timestamp); + // No point going further, no notaries can be paid. - if ( staked_era == 0 ) + if ( notarypubkeys[0][0] == 0 ) return(0); - numSN = numStakedNotaries(staked_pubkeys,staked_era); // Check the notarisation is valid. int32_t notarizedheight = komodo_getnotarizedheight(timestamp, height, script, len); @@ -1886,7 +1884,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar ptr[0] = 33; for (int8_t i=0; i<33; i++) { - ptr[i+1] = staked_pubkeys[NotarisationNotaries[n]][i]; + ptr[i+1] = notarypubkeys[NotarisationNotaries[n]][i]; //fprintf(stderr,"%02x",ptr[i+1]); } ptr[34] = OP_CHECKSIG; @@ -1901,13 +1899,12 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { std::vector NotarisationNotaries; uint32_t timestamp = pblock->nTime; - int32_t staked_era; int8_t numSN; - uint8_t staked_pubkeys[64][33]; - staked_era = STAKED_era(timestamp); + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + numSN = komodo_notaries(notarypubkeys, height, timestamp); + // No point going further, no notaries can be paid. - if ( staked_era == 0 ) + if ( notarypubkeys[0][0] == 0 ) return(0); - numSN = numStakedNotaries(staked_pubkeys,staked_era); uint8_t *script; int32_t scriptlen; // Loop over the notarisation and extract the position of the participating notaries in the array of pukeys for this era. @@ -1920,7 +1917,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); - if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 ) NotarisationNotaries.push_back(i); } } @@ -1979,7 +1976,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) // Check the pubkeys match the pubkeys in the notarisation. script = (uint8_t *)&txout.scriptPubKey[0]; scriptlen = (int32_t)txout.scriptPubKey.size(); - if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[NotarisationNotaries[n-1]],33) == 0 ) { // check the value is correct if ( pblock->vtx[0].vout[n].nValue == AmountToPay ) @@ -2196,9 +2193,11 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } // Check min sigs. - if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + numSN = komodo_notaries(notarypubkeys, height, pblock->nTime) + if ( pblock->vtx[1].vin.size() < numSN/5) ) { - fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,(num_notaries_STAKED[STAKED_era(pblock->nTime)]/5),pblock->vtx[1].vin.size()); + fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,numSN/5),pblock->vtx[1].vin.size()); return(-1); } } diff --git a/src/miner.cpp b/src/miner.cpp index f35fb160c..0f87a0643 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -152,9 +152,9 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); -int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -248,15 +248,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } pblock->nTime = GetAdjustedTime(); - // Now we have the block time, we can get the active notaries. - int32_t staked_era = 0; int8_t numSN = 0; - uint8_t staked_pubkeys[64][33] = {0}; - if ( is_STAKED(ASSETCHAINS_SYMBOL) < 3 ) + // Now we have the block time + height, we can get the active notaries. + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { - // Only use speical miner for LABS chains in the actual cluster that use notarypay! - // It wouldnt hurt to use it on other chains, but serves little purpose. - staked_era = STAKED_era(pblock->nTime); - numSN = numStakedNotaries(staked_pubkeys,staked_era); + // Only use speical miner for notary pay chains. + numSN = komodo_notaries(notarypubkeys, nHeight, pblock->nTime) } CCoinsViewCache view(pcoinsTip); @@ -268,7 +265,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", true); + bool fPrintPriority = GetBoolArg("-printpriority", false); // This vector will be sorted into a priority queue: vector vecPriority; @@ -302,17 +299,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CAmount nTotalIn = 0; bool fMissingInputs = false; bool fNotarisation = false; - std::vector TMP_NotarisationNotaries = {0}; + std::vector TMP_NotarisationNotaries; if (tx.IsCoinImport()) { CAmount nValueIn = GetCoinImportValue(tx); // burn amount nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { - //int numNotaryVins = 0; TMP_NotarisationNotaries.clear(); bool fToCryptoAddress = false; - if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) + if ( numSN != 0 && notarypubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; BOOST_FOREACH(const CTxIn& txin, tx.vin) @@ -361,7 +357,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); - if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 ) { // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. TMP_NotarisationNotaries.push_back(i); @@ -395,7 +391,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( fNotarisation ) { - // Special miner for notary pay chains. + // Special miner for notary pay chains. Can only enter this if numSN is set higher up. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation @@ -458,7 +454,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else + else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } From e3495bf3e9dbd2d226fc4667bffd05e6163d323d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:17:53 +0800 Subject: [PATCH 2688/3904] remove pointless things --- src/Makefile.am | 21 +++++++-------- src/assetchains.json | 61 ++++++++++++++++++------------------------- src/bitcoin-cli.cpp | 1 - src/cc/dice.cpp | 8 +++--- src/cc/utils.h | 1 - src/coins.h | 8 +++--- src/komodo_bitcoind.h | 8 +++--- src/komodo_utils.h | 12 ++++----- src/main.cpp | 45 ++++++++++++------------------- src/miner.cpp | 2 +- 10 files changed, 70 insertions(+), 97 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c0a2a2e03..a10868135 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,9 +123,8 @@ TESTS = bin_PROGRAMS += komodod #endif -# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli + bin_PROGRAMS += komodo-cli komodo-tx endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility @@ -205,7 +204,7 @@ BITCOIN_CORE_H = \ mruset.h \ net.h \ netbase.h \ - notaries_staked.h \ + notaries_staked.h \ noui.h \ paymentdisclosure.h \ paymentdisclosuredb.h \ @@ -313,7 +312,7 @@ libbitcoin_server_a_SOURCES = \ chain.cpp \ checkpoints.cpp \ crosschain.cpp \ - crosschain_authority.cpp \ + crosschain_authority.cpp \ crypto/haraka.h \ crypto/haraka_portable.h \ crypto/verus_hash.h \ @@ -328,7 +327,7 @@ libbitcoin_server_a_SOURCES = \ metrics.h \ miner.cpp \ net.cpp \ - notaries_staked.cpp \ + notaries_staked.cpp \ noui.cpp \ notarisationdb.cpp \ paymentdisclosure.cpp \ @@ -620,8 +619,8 @@ komodo_cli_LDADD = \ $(EVENT_LIBS) \ $(LIBZCASH) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) if ENABLE_WALLET @@ -629,8 +628,8 @@ wallet_utility_LDADD = \ libbitcoin_wallet.a \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBSECP256K1) \ $(LIBBITCOIN_UTIL) \ $(BOOST_LIBS) \ @@ -639,7 +638,7 @@ wallet_utility_LDADD = \ $(LIBZCASH) \ $(LIBSNARK) \ $(LIBZCASH_LIBS)\ - $(LIBCRYPTOCONDITIONS) + $(LIBCRYPTOCONDITIONS) endif # zcash-tx binary # @@ -679,7 +678,7 @@ libzcash_a_SOURCES = \ zcash/Note.cpp \ zcash/prf.cpp \ zcash/util.cpp \ - zcash/zip32.cpp \ + zcash/zip32.cpp \ zcash/circuit/commitment.tcc \ zcash/circuit/gadget.tcc \ zcash/circuit/merkle.tcc \ diff --git a/src/assetchains.json b/src/assetchains.json index bd07f1fb1..91baf9829 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -136,51 +136,42 @@ "ac_reward": "100000000" }, { - "ac_name": "CFEKED", - "ac_supply": "1000", + "ac_name": "SEC", + "ac_supply": "1000000000", + "ac_cc": "333" + }, + { + "ac_name": "CCL", + "ac_supply": "200000000", "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", "addnode": [ - "195.201.137.5", - "195.201.20.230" + "142.93.136.89", + "195.201.22.89" ] }, { - "ac_name": "CFEKING", - "ac_supply": "1000", - "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", + "ac_name": "PIRATE", + "ac_supply": "0", + "ac_reward": "25600000000", + "ac_halving": "77777", + "ac_private": "1", "addnode": [ - "195.201.137.5", - "195.201.20.230" + "136.243.102.225" ] }, { - "ac_name": "CFEKLF", - "ac_supply": "1000", - "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", + "ac_name": "MGNX", + "ac_supply": "12465003", + "ac_staked": "90", + "ac_reward": "2000000000", + "ac_halving": "525960", + "ac_cc": "2", + "ac_end": "2629800", "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "CFEKMLT", - "ac_supply": "1000", - "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", - "addnode": [ - "195.201.137.5", - "195.201.20.230" + "142.93.27.180" ] }, { diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 31d3b9e3e..544972586 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -25,7 +25,6 @@ #include "util.h" #include "utilstrencodings.h" - #include #include diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index afd1ff5ac..ab723790f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1213,9 +1213,6 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } else { return(0); } - fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); - entropytxs = n; - return(totalinputs); } bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) @@ -1419,7 +1416,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; if ( bet < 0 ) { - CCerror = "bet must be positive"; + CCerror = "Diceinit error in bet, is your transaction confirmed?"; return(""); } if ( odds < 2 || odds > 9999 ) @@ -1756,7 +1753,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,num,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error in status"; + CCerror = "Diceinit error in status, is your transaction confirmed?"; + fprintf(stderr,"%s\n", CCerror.c_str() ); return(0.); } win = loss = 0; diff --git a/src/cc/utils.h b/src/cc/utils.h index fcbea7f5b..39bce0e95 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -20,7 +20,6 @@ #include "version.h" - /* * Serialisation boilerplate */ diff --git a/src/coins.h b/src/coins.h index 6cd5d9933..e0ea7d822 100644 --- a/src/coins.h +++ b/src/coins.h @@ -41,7 +41,7 @@ #include "zcash/IncrementalMerkleTree.hpp" //#include "veruslaunch.h" -/** +/** * Pruned version of CTransaction: only retains metadata and unspent transaction outputs * * Serialized format: @@ -443,7 +443,7 @@ public: class CCoinsViewCache; -/** +/** * A reference to a mutable cache entry. Encapsulating it allows us to run * cleanup code after the modification is finished, and keeping track of * concurrent modifications. @@ -503,7 +503,7 @@ protected: /** * Make mutable so that we can "fill the cache" even from Get-methods - * declared as "const". + * declared as "const". */ mutable uint256 hashBlock; mutable CCoinsMap cacheCoins; @@ -579,7 +579,7 @@ public: //! Calculate the size of the cache (in bytes) size_t DynamicMemoryUsage() const; - /** + /** * Amount of bitcoins coming in to a transaction * Note that lightweight clients may not know anything besides the hash of previous transactions, * so may not be able to calculate this. diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a7dd2027c..f23fde7c1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1536,7 +1536,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_uint256 bnTarget,arith_uint256 bhash) { CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; arith_uint256 POWTarget; - if ( ASSETCHAINS_STAKED == 100 && height <= 100 ) + if ( ASSETCHAINS_STAKED == 100 && height <= 10 ) return(1); BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; @@ -2194,10 +2194,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } // Check min sigs. int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; - numSN = komodo_notaries(notarypubkeys, height, pblock->nTime) - if ( pblock->vtx[1].vin.size() < numSN/5) ) + numSN = komodo_notaries(notarypubkeys, height, pblock->nTime); + if ( pblock->vtx[1].vin.size() < numSN/5 ) { - fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,numSN/5),pblock->vtx[1].vin.size()); + fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,numSN/5,pblock->vtx[1].vin.size()); return(-1); } } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 8d6395ac2..2fbb782ce 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1690,7 +1690,7 @@ void komodo_args(char *argv0) IS_KOMODO_NOTARY = 1; KOMODO_MININGTHREADS = 1; mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - IS_STAKED_NOTARY = -1; + IS_STAKED_NOTARY = -1; fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); break; } @@ -1723,7 +1723,7 @@ void komodo_args(char *argv0) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); } - if ( name.c_str()[0] != 0 ) + if ( name.c_str()[0] != 0 ) { std::string selectedAlgo = GetArg("-ac_algo", std::string(ASSETCHAINS_ALGORITHMS[0])); @@ -1897,10 +1897,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else - { - printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); - } + else + { + printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); + } /*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) { //ASSETCHAINS_OVERRIDE_PUBKEY.clear(); diff --git a/src/main.cpp b/src/main.cpp index 6ad0e613d..ab3a97549 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,6 @@ ******************************************************************************/ #include "main.h" -#include "notaries_staked.h" #include "sodium.h" #include "addrman.h" @@ -1267,35 +1266,23 @@ extern uint8_t NUM_NOTARIES; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - { - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) - { - for (int32_t i=0; i<=NUM_NOTARIES; i++) - if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) - return(1); - } - } - else - { - static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; - int32_t i; - if ( didinit == 0 ) - { - uint8_t pubkey33[33]; - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) - { - if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) - decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - didinit = 1; - } - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) - if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) - return(1); + static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; + int32_t i; + if ( didinit == 0 ) + { + uint8_t pubkey33[33]; + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + { + if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) + decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } + didinit = 1; } + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) + return(1); return(0); } diff --git a/src/miner.cpp b/src/miner.cpp index 0f87a0643..09ce3fd1a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -253,7 +253,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { // Only use speical miner for notary pay chains. - numSN = komodo_notaries(notarypubkeys, nHeight, pblock->nTime) + numSN = komodo_notaries(notarypubkeys, nHeight, pblock->nTime); } CCoinsViewCache view(pcoinsTip); From 5d8d2753f44d37bb1e077c75218577b2506aef49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:20:46 +0800 Subject: [PATCH 2689/3904] fix --- src/Makefile.am | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a10868135..a1d7c8dd3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,8 +123,9 @@ TESTS = bin_PROGRAMS += komodod #endif +# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli komodo-tx + bin_PROGRAMS += komodo-cli endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility @@ -619,8 +620,8 @@ komodo_cli_LDADD = \ $(EVENT_LIBS) \ $(LIBZCASH) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) if ENABLE_WALLET @@ -628,8 +629,8 @@ wallet_utility_LDADD = \ libbitcoin_wallet.a \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBSECP256K1) \ $(LIBBITCOIN_UTIL) \ $(BOOST_LIBS) \ @@ -638,7 +639,7 @@ wallet_utility_LDADD = \ $(LIBZCASH) \ $(LIBSNARK) \ $(LIBZCASH_LIBS)\ - $(LIBCRYPTOCONDITIONS) + $(LIBCRYPTOCONDITIONS) endif # zcash-tx binary # @@ -678,7 +679,7 @@ libzcash_a_SOURCES = \ zcash/Note.cpp \ zcash/prf.cpp \ zcash/util.cpp \ - zcash/zip32.cpp \ + zcash/zip32.cpp \ zcash/circuit/commitment.tcc \ zcash/circuit/gadget.tcc \ zcash/circuit/merkle.tcc \ From d63ed05d703c804654871ae5e5b349487530709d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:21:39 +0800 Subject: [PATCH 2690/3904] fix tx --- src/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a1d7c8dd3..d168a328f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,9 +123,8 @@ TESTS = bin_PROGRAMS += komodod #endif -# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli + bin_PROGRAMS += komodo-cli komodo-tx endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility From c95f1253e337db6adb60dcb8fd1666a935b54eeb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:22:58 +0800 Subject: [PATCH 2691/3904] fix dice --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index ab723790f..8c17ac184 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1416,7 +1416,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; if ( bet < 0 ) { - CCerror = "Diceinit error in bet, is your transaction confirmed?"; + CCerror = "bet must be positive"; return(""); } if ( odds < 2 || odds > 9999 ) @@ -1426,7 +1426,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "error in Diceinit"; + CCerror = "Diceinit error in bet, is your transaction confirmed?"; return(""); } if ( bet < minbet || bet > maxbet || odds > maxodds ) From dc30e99e635dab63992be5a3a7a27396483eb282 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:23:31 +0800 Subject: [PATCH 2692/3904] space --- src/cc/dice.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 8c17ac184..1bb44af18 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1425,7 +1425,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error in bet, is your transaction confirmed?"; return(""); } From 096d25df978f1693905c45d5865b403aacf6fce5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:49:17 +0800 Subject: [PATCH 2693/3904] Disable all experminetal/LABS features that are not required. --- src/komodo.h | 3 ++- src/main.cpp | 8 ++++++-- src/rpc/server.cpp | 2 +- src/rpc/server.h | 2 +- src/version.h | 2 +- src/wallet/rpcwallet.cpp | 7 +++++-- src/wallet/wallet.cpp | 3 ++- src/wallet/walletdb.cpp | 18 ------------------ 8 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 8f4217cc4..24a3eb723 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,7 +825,8 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) return(0); } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) + // Wallet Filter. Disabled here. Cant be activated by notaries or pools with some changes. + if ( 0 & is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); if ( !fJustCheck && staked_era != lastStakedEra ) diff --git a/src/main.cpp b/src/main.cpp index ab3a97549..7658bd4ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5330,7 +5330,9 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } int nHeight = pindex->GetHeight(); - int32_t usetmp = 1; + // Temp File fix. LABS has been using this for ages with no bad effects. + // Disabled here. Set use tmp to whatever you need to use this for. + int32_t usetmp = 0; if ( IsInitialBlockDownload() ) usetmp = 0; @@ -5468,7 +5470,9 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo komodo_currentheight_set(chainActive.LastTip()->GetHeight()); checked = CheckBlock(&futureblock,height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0); bool fRequested = MarkBlockAsReceived(hash); - if ( pfrom && !fRequested && vNodes.size() > 1 ) + // Test thing on LABS to test viability of rejecting a node pushing a chain. + // Supposed to stop malicious forks being pushed. Untested. Disabled incase of problems it may cause. + if ( 0 & pfrom && !fRequested && vNodes.size() > 1 ) { pfrom->nBlocksinARow += 1; if ( pfrom->nBlocksinARow >= 10 ) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 46eb95a25..e8a7d648e 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -561,7 +561,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, +// { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index abd0ea6a8..fcd30d32f 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -353,7 +353,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); +//extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/version.h b/src/version.h index 4056f105d..aab89eea4 100644 --- a/src/version.h +++ b/src/version.h @@ -24,7 +24,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170008; +static const int PROTOCOL_VERSION = 170007; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4ae0b2274..110bbd134 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1030,7 +1030,10 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } -UniValue cleanwallettransactions(const UniValue& params, bool fHelp) + +// for cleaning wallets, many main net notaries are using this to gain a MASSIVE advantage. +// Disabled here. but they can enable it a bit easier now, then using their own forks. +/*UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -1131,7 +1134,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) ret.push_back(Pair("remaining_transactons", (int)remaining)); ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); return (ret); -} +} */ UniValue getbalance(const UniValue& params, bool fHelp) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 02467b5d6..d3c1c0f5b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1768,7 +1768,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { - if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + // wallet filter for notary nodes. Disabled! Can be reenabled or customised for any specific use, pools could also use this to prevent wallet dwy attack. + if ( 0 & !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index a1527dcb8..972b2cdf4 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -950,24 +950,6 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) catch (...) { result = DB_CORRUPT; } - - if (!deadTxns.empty()) - { - int32_t reAdded = 0; - BOOST_FOREACH (uint256& hash, deadTxns) { - if (!EraseTx(hash)) - fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); - uint256 blockhash; CTransaction tx; - if (GetTransaction(hash,tx,blockhash,true)) - { - CWalletTx wtx(pwallet,tx); - pwallet->AddToWallet(wtx, true, NULL); - reAdded++; - } - } - fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",deadTxns.size(),reAdded); - deadTxns.clear(); - } if (!deadTxns.empty()) { From fa0a8e37953c64744f6b4ad5beeaa23241a06147 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 13:19:45 +0800 Subject: [PATCH 2694/3904] fix build --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 7658bd4ec..01513149c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5472,7 +5472,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool fRequested = MarkBlockAsReceived(hash); // Test thing on LABS to test viability of rejecting a node pushing a chain. // Supposed to stop malicious forks being pushed. Untested. Disabled incase of problems it may cause. - if ( 0 & pfrom && !fRequested && vNodes.size() > 1 ) + if ( 0 && pfrom && !fRequested && vNodes.size() > 1 ) { pfrom->nBlocksinARow += 1; if ( pfrom->nBlocksinARow >= 10 ) From 142744f22d18cddaa9378968e501706a7f3be40a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 17:35:07 +0800 Subject: [PATCH 2695/3904] verushashv1_1, fix walletdb.h, proto version, cleanwallettransactions add --- src/chainparams.cpp | 2 +- src/init.cpp | 4 ++-- src/komodo_bitcoind.h | 6 +++--- src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/metrics.cpp | 2 +- src/miner.cpp | 4 ++-- src/rpc/server.cpp | 2 +- src/rpc/server.h | 2 +- src/version.h | 2 +- src/wallet-utility.cpp | 2 +- src/wallet/db.h | 2 +- src/wallet/rpcwallet.cpp | 6 ++---- 13 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5fa0007d4..6bfcc0e5c 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -297,7 +297,7 @@ void *chainparams_commandline(void *ptr) mainParams.consensus.nPowAveragingWindow = 45; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); } - else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing diff --git a/src/init.cpp b/src/init.cpp index ea8286cd0..6049fb09f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1178,7 +1178,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // set the hash algorithm to use for this chain // Again likely better solution here, than using long IF ELSE. - extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; + extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1; CVerusHash::init(); CVerusHashV2::init(); if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) @@ -1186,7 +1186,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // initialize VerusHash CBlockHeader::SetVerusHash(); } - else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1) { // initialize VerusHashV2 CBlockHeader::SetVerusHashV2(); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f23fde7c1..dbea7ba12 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1348,7 +1348,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( m+n < 100 ) { // We do actual PoS % at the start. Requires coin distribution in first 10 blocks! - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) percPoS = (percPoS*100) / (m+n); else // This seems to be inverse. The actual PoS % is backwards in the first 100 blocks. @@ -1453,7 +1453,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( blocktime+iter+segid*2 < txtime+minage ) continue; diff = (iter + blocktime - txtime - minage); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) { /*if ( PoSperc < ASSETCHAINS_STAKED ) { @@ -1481,7 +1481,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) { if ( PoSperc < ASSETCHAINS_STAKED ) { diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 4d89fe416..2c3647b30 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -51,7 +51,7 @@ extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; -extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; +extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9c2f1df62..859fada99 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -76,7 +76,7 @@ uint8_t ASSETCHAINS_CCDISABLES[256]; uint32_t ASSETCHAINS_NUMALGOS = 3; uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH; uint32_t ASSETCHAINS_VERUSHASH = 1; -uint32_t ASSETCHAINS_VERUSHASHV2 = 2; +uint32_t ASSETCHAINS_VERUSHASHV1_1 = 2; const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash", "verushash11"}; uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff,0xfffffff}; uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; diff --git a/src/metrics.cpp b/src/metrics.cpp index e794ad220..1fa8ebfb5 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -136,7 +136,7 @@ int64_t GetUptime() double GetLocalSolPS() { - if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1) { return miningTimer.rate(nHashCount); } diff --git a/src/miner.cpp b/src/miner.cpp index 09ce3fd1a..165adb592 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1436,7 +1436,7 @@ void static BitcoinMiner_noeq() CVerusHashV2Writer ss2 = CVerusHashV2Writer(SER_GETHASH, PROTOCOL_VERSION); ss2 << *((CBlockHeader *)pblock); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) extraPtr = ss2.xI64p(); CVerusHashV2 &vh2 = ss2.GetState(); vh2.ClearExtra(); @@ -1459,7 +1459,7 @@ void static BitcoinMiner_noeq() *extraPtr = i; if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) vh.ExtraHash((unsigned char *)&hashResult); - else if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + else if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) vh2.ExtraHash((unsigned char *)&hashResult); if ( UintToArith256(hashResult) <= hashTarget ) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index e8a7d648e..46eb95a25 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -561,7 +561,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, -// { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, + { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index fcd30d32f..abd0ea6a8 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -353,7 +353,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -//extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); +extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/version.h b/src/version.h index aab89eea4..64150b740 100644 --- a/src/version.h +++ b/src/version.h @@ -33,7 +33,7 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170007; +static const int MIN_PEER_PROTO_VERSION = 170002; static const int STAKEDMIN_PEER_PROTO_VERSION = 170007; //! nTime field added to CAddress, starting with this version; diff --git a/src/wallet-utility.cpp b/src/wallet-utility.cpp index f4041dfbe..655a3cab4 100644 --- a/src/wallet-utility.cpp +++ b/src/wallet-utility.cpp @@ -18,7 +18,7 @@ uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint32_t ASSETCHAINS_EQUIHASH = 0; uint32_t ASSETCHAINS_VERUSHASH = 1; -uint32_t ASSETCHAINS_VERUSHASHV2 = 2; +uint32_t ASSETCHAINS_VERUSHASHV1_1 = 2; uint32_t ASSETCHAINS_ALGO = 0; int32_t ASSETCHAINS_LWMAPOS = 0; int32_t VERUS_BLOCK_POSUNITS = 1000; diff --git a/src/wallet/db.h b/src/wallet/db.h index f7854fe2f..19b9b6079 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -33,7 +33,7 @@ #include -#include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" +#include extern unsigned int nWalletDBUpdated; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 110bbd134..f49246995 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1031,9 +1031,7 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef } -// for cleaning wallets, many main net notaries are using this to gain a MASSIVE advantage. -// Disabled here. but they can enable it a bit easier now, then using their own forks. -/*UniValue cleanwallettransactions(const UniValue& params, bool fHelp) +UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -1134,7 +1132,7 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef ret.push_back(Pair("remaining_transactons", (int)remaining)); ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); return (ret); -} */ +} UniValue getbalance(const UniValue& params, bool fHelp) { From fa0f53295c8127ec107f8ff5febb3a88e315e8cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Feb 2019 23:51:56 -1100 Subject: [PATCH 2696/3904] +print --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4d98855d4..a7cefcc45 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -448,6 +448,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint { if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { + fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); if ( tokenid != zeroid ) { playertxid = tokenid; @@ -462,6 +463,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { + fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); // if registertxid has vin from pk, it can be used return(0); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); From 67dc3a0d2a8c2f845868ec45eef5c82fdcb2b47d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Feb 2019 00:02:43 -1100 Subject: [PATCH 2697/3904] Test batontxid --- src/cc/rogue_rpc.cpp | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a7cefcc45..cf7aa7979 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -366,7 +366,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { - int32_t i; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); + int32_t i,vout,spentvini,n=0; uint256 txid,spenttxid,hashblock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -384,8 +384,38 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint rogue_packitemstr(packitemstr,&P.roguepack[i]); a.push_back(packitemstr); } - obj.push_back(Pair("playertxid",playertxid.GetHex())); + txid = playertxid; + vout = 0; + while ( CCgettxout(txid,vout,1) < 0 ) + { + spenttxid = zeroid; + spentvini = -1; + if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + break; + } + txid = spenttxid; + vout = 0; + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + for (i=0; i 1000 ) + break; + } obj.push_back(Pair("gametxid",gametxid.GetHex())); + if ( txid != playertxid ) + obj.push_back(Pair("batontxid",txid.GetHex())); + obj.push_back(Pair("playertxid",playertxid.GetHex())); if ( tokenid != zeroid ) obj.push_back(Pair("tokenid",tokenid.GetHex())); else obj.push_back(Pair("tokenid",playertxid.GetHex())); @@ -448,7 +478,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint { if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) { - fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); + origplayergame = gametxid; if ( tokenid != zeroid ) { playertxid = tokenid; @@ -463,7 +493,6 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { - fprintf(stderr,"gametxid.%s\n",gametxid.GetHex().c_str()); // if registertxid has vin from pk, it can be used return(0); } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); From d5dd62e4ee80eb3c3cbd6063a2415c38ab144e0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Feb 2019 00:03:26 -1100 Subject: [PATCH 2698/3904] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cf7aa7979..a288e6175 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -366,7 +366,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { - int32_t i,vout,spentvini,n=0; uint256 txid,spenttxid,hashblock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; + int32_t i,vout,spentvini,n=0; uint256 txid,spenttxid,hashBlock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { From 7bff2f9229ee1db01881cf3316738233e4598b29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Feb 2019 00:03:59 -1100 Subject: [PATCH 2699/3904] Syntax --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a288e6175..52a4a8ce6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -366,7 +366,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { - int32_t i,vout,spentvini,n=0; uint256 txid,spenttxid,hashBlock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; + int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { From 075ec9cb1bafad85e007e3a63efafde56b84e5f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Feb 2019 00:06:02 -1100 Subject: [PATCH 2700/3904] start with vout.1 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 52a4a8ce6..31545dbf8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -385,7 +385,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint a.push_back(packitemstr); } txid = playertxid; - vout = 0; + vout = 1; while ( CCgettxout(txid,vout,1) < 0 ) { spenttxid = zeroid; From e619b775276f94f29bd47d7c6904a7289da252bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 19:06:41 +0800 Subject: [PATCH 2701/3904] fix miner for ac_notarypay. --- src/miner.cpp | 49 ++++++++----------------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 165adb592..4b5191d06 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -153,7 +153,6 @@ int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); -int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) @@ -233,8 +232,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetAdjustedTime(); - - int32_t last_notarizedheight = 0; if (proposedTime == nMedianTimePast) { @@ -391,7 +388,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( fNotarisation ) { - // Special miner for notary pay chains. Can only enter this if numSN is set higher up. + // Special miner for notary pay chains. Can only enter this if numSN/notarypubkeys is set higher up. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation @@ -400,46 +397,17 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( script[0] == OP_RETURN ) { Notarisations++; - int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); - if ( notarizedheight != 0 ) + if ( Notarisations > 1 ) { - //fprintf(stderr, "notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); - if ( last_notarizedheight == 0 ) - { - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); - } - else if ( notarizedheight > last_notarizedheight ) - continue; // leave this notarisation for the next block, it will be valid! - else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else if ( notarizedheight < last_notarizedheight ) - { - // we need to remove the last seen notarzation from block - const CTransaction& Tx = *(vecPriority.front().get<2>()); - TxPriorityCompare comparer(0); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - // add this one as its valid before the other one. - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); - } - last_notarizedheight = notarizedheight; - } - else if ( Notarisations > 1 ) - { - fprintf(stderr, "skipping notarizations.%d\n",Notarisations); + fprintf(stderr, "skipping notarization.%d\n",Notarisations); // Any attempted notarization needs to be in its own block! - // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } - //fprintf(stderr, "BOTTOM: notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); } } } @@ -447,7 +415,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { dPriority -= 10; // make sure notarisation is tx[1] in block. - // Need to check this? Tried sapling tx and it was not set to max priotity, maybe missing something. } if (porphan) { From 9ce70a4711fed4631e8686a68917c9302e117d14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Feb 2019 00:07:52 -1100 Subject: [PATCH 2702/3904] Fix --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 31545dbf8..2f263e8aa 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -390,9 +390,9 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint { spenttxid = zeroid; spentvini = -1; - if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) + if ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) >= 0 ) txid = spenttxid; - else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) { fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); break; From 8425000e5904f7440797eb7d7bf82daeb22b8afd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Feb 2019 00:09:14 -1100 Subject: [PATCH 2703/3904] Add gametxid and batontxid to player info --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2f263e8aa..fa4abae24 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -408,7 +408,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint break; } } - fprintf(stderr,"trace spend to %s/v%d\n",txid.GetHex().c_str(),vout); + //fprintf(stderr,"trace spend to %s/v%d\n",txid.GetHex().c_str(),vout); if ( n++ > 1000 ) break; } From ba7adb6aa0688be487da29aed0345c36d63bfc64 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Feb 2019 00:41:44 -1100 Subject: [PATCH 2704/3904] -print --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 53f6da353..7cd1874e5 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -599,7 +599,7 @@ int32_t _quit() else { //score(rs,purse, 1, 0); - fprintf(stderr,"done! (%c)\n",c); + //fprintf(stderr,"done! (%c)\n",c); } return(1); } From 7309367c04d46b270ce11339343d5229082142bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 19:55:14 +0800 Subject: [PATCH 2705/3904] fix & to &&! --- src/komodo.h | 2 +- src/wallet/wallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 24a3eb723..601d242f6 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -826,7 +826,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); // Wallet Filter. Disabled here. Cant be activated by notaries or pools with some changes. - if ( 0 & is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) + if ( 0 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); if ( !fJustCheck && staked_era != lastStakedEra ) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d3c1c0f5b..82642df00 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1769,7 +1769,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { // wallet filter for notary nodes. Disabled! Can be reenabled or customised for any specific use, pools could also use this to prevent wallet dwy attack. - if ( 0 & !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + if ( 0 && !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) From b3d61f98f452e5d1c9eeccff7f1443d6acdfab99 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 20:33:53 +0800 Subject: [PATCH 2706/3904] fix sync of labs chains. It cant enter here anyway. --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 601d242f6..a78b6848c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -826,7 +826,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); // Wallet Filter. Disabled here. Cant be activated by notaries or pools with some changes. - if ( 0 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); if ( !fJustCheck && staked_era != lastStakedEra ) From e6aede49ae8a708cb19c39a65064bd2e49fb2781 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 27 Feb 2019 13:11:11 +0800 Subject: [PATCH 2707/3904] fix extremely rare bug! --- src/komodo.h | 7 +++---- src/miner.cpp | 15 ++++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a78b6848c..bd3550e38 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -630,6 +630,9 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( matched != 0 ) validated = komodo_validate_chain(srchash,*notarizedheightp); else validated = 1; + // Any notarization that is matched and has a decodable op_return is enough to pay notaries. Otherwise bugs! + if ( fJustCheck && matched != 0 ) + return(-2); if ( notarized != 0 && validated != 0 ) { //sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -697,10 +700,6 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - // Because of reorgs its not possible to use notarizations that are in order. If its validated pay the notaries! - if ( fJustCheck ) - return(-2); - if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; diff --git a/src/miner.cpp b/src/miner.cpp index 4b5191d06..a567e2e20 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,6 +154,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); +int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -403,11 +404,15 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Any attempted notarization needs to be in its own block! continue; } - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) + { + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + } } } } From 7f536a40818b0c51cd63aaa1cfca5500abc5554c Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Wed, 27 Feb 2019 12:22:13 +0100 Subject: [PATCH 2708/3904] Fix gatewaysbind --- src/cc/gateways.cpp | 2 +- src/wallet/rpcwallet.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 5d803a80e..da94822a7 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -956,7 +956,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t prefix2 = p2; wiftype = p3; taddr = p4; - LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d for %s\n",prefix,prefix2,wiftype,coin.c_str()); + LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d, taddr %d for %s\n",prefix,prefix2,wiftype,taddr,coin.c_str()); } if ( N == 0 || N > 15 || M > N ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f49246995..a19eebb20 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6349,7 +6349,7 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); uint256 tokenid,oracletxid; int32_t i; int64_t totalsupply; std::vector pubkeys; uint8_t M,N,p1,p2,p3,p4=0; std::string hex,coin; std::vector pubkey; - if ( fHelp || params.size() < 9 ) + if ( fHelp || params.size() < 10 ) throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s) pubtype p2shtype wiftype [taddr]\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); @@ -6363,10 +6363,10 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp) N = atoi((char *)params[5].get_str().c_str()); if ( M > N || N == 0 || N > 15 || totalsupply < COIN/100 || tokenid == zeroid ) throw runtime_error("illegal M or N > 15 or tokensupply or invalid tokenid\n"); + if ( params.size() < 6+N+3 ) + throw runtime_error("not enough parameters for N pubkeys\n"); for (i=0; i 0 ) From 5e17fafef0d6ff4cd3500461eda0cb47fd9d9c30 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 00:24:44 -1100 Subject: [PATCH 2709/3904] +/- print --- src/cc/rogue/rogue.c | 4 +++- src/cc/rogue_rpc.cpp | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 7cd1874e5..10fff1dd7 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -169,6 +169,8 @@ int32_t flushkeystrokes(struct rogue_state *rs) { if ( rs->num > 0 ) { + // need to get existing keystrokes including mempool + // create keystrokes that are not saved rogue_progress(rs,rs->seed,rs->buffered,rs->num); memset(rs->buffered,0,sizeof(rs->buffered)); rs->counter++; @@ -229,7 +231,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(rs,fp,0); - fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); + //fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index fa4abae24..d4c1776e8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -941,7 +941,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto else { sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); *numkeysp = numkeys; return(keystrokes); } @@ -1221,7 +1221,7 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myrogueaddr[64],str[64]; CPubKey mypk,roguepk; result.push_back(Pair("name","rogue")); result.push_back(Pair("method","gameinfo")); if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) @@ -1248,6 +1248,11 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr); a.push_back(obj); } + else + { + fprintf(str,"vout %d+1 is unspent",i); + result.push_back(Pair("unspent",str)); + } } result.push_back(Pair("players",a)); } else return(cclib_error(result,"couldnt find valid game")); @@ -1469,7 +1474,15 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( funcid == 'H' ) cashout *= 2; if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout - fprintf(stderr,"ht.%d txid.%s cashout %.8f vs vout2 %.8f\n",height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + { + static char laststr[512]; + fprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } + } } if ( funcid == 'Q' ) { From f20724fcef51849562925743fd6235be9da8bfdf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 00:25:48 -1100 Subject: [PATCH 2710/3904] S --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d4c1776e8..619feef69 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1250,7 +1250,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } else { - fprintf(str,"vout %d+1 is unspent",i); + sprintf(str,"vout %d+1 is unspent",i); result.push_back(Pair("unspent",str)); } } @@ -1476,7 +1476,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout { static char laststr[512]; - fprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); From 26b114c0c661315a1839279255336e7f65dfbab8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 00:26:32 -1100 Subject: [PATCH 2711/3904] Cashstr --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 619feef69..481224d90 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1475,7 +1475,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C cashout *= 2; if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout { - static char laststr[512]; + static char laststr[512]; char cashstr[512]; sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { From 36ffbed7d1df8df196aaf77e494c27296c30c0b6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 00:32:04 -1100 Subject: [PATCH 2712/3904] +print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 481224d90..d238abc2f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -577,7 +577,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-2); } txid = spenttxid; - //fprintf(stderr,"next txid.%s/v%d\n",txid.GetHex().c_str(),spentvini); +fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) return(-3); if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) From 0942e9e47c69d6b40e403921b54697c1091ac93e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 00:41:55 -1100 Subject: [PATCH 2713/3904] terminate baton search when non-zero spentvini --- src/cc/rogue_rpc.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d238abc2f..8bd8d4bf2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -528,8 +528,8 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) { int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; - numkeys = numplayers = 0; - playertxid = zeroid; + batonvalue = numkeys = numplayers = batonht = 0; + playertxid = batontxid = zeroid; for (i=0; i= 2 ) { uint256 g,b; CPubKey p; std::vector k; From 0e567288cde35925be33dafcba17ad4f6d21797e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 01:34:42 -1100 Subject: [PATCH 2714/3904] +print --- src/cc/rogue_rpc.cpp | 228 ++++++++++++++++++++++++------------------- 1 file changed, 130 insertions(+), 98 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8bd8d4bf2..158b2a7c6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -277,25 +277,9 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } -int32_t rogue_playersalive(int32_t &numplayers,uint256 gametxid,int32_t maxplayers) -{ - int32_t i,alive = 0; uint64_t txfee = 10000; - numplayers = 0; - for (i=0; iGetHeight(); @@ -317,9 +301,10 @@ uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 obj.push_back(Pair("run",cmd)); } } + obj.push_back(Pair("alive",rogue_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); + obj.push_back(Pair("openslots",openslots)); + obj.push_back(Pair("numplayers",numplayers)); } - obj.push_back(Pair("alive",rogue_playersalive(numplayers,gametxid,maxplayers))); - obj.push_back(Pair("numplayers",numplayers)); obj.push_back(Pair("maxplayers",maxplayers)); obj.push_back(Pair("buyin",ValueFromAmount(buyin))); return(seed); @@ -550,85 +535,129 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } if ( matches == 1 ) { - if ( 1 || myIsutxo_spent(spenttxid,gametxid,maxplayers+i+1) < 0 ) + numvouts = matchtx.vout.size(); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); - if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + if ( tokenid != zeroid ) + active = tokenid; + else active = playertxid; + if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); - if ( tokenid != zeroid ) - active = tokenid; - else active = playertxid; - if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) + txid = matchtx.GetHash(); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + n = 0; + while ( CCgettxout(txid,0,1) < 0 ) { - txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); - n = 0; - while ( CCgettxout(txid,0,1) < 0 ) - { - spenttxid = zeroid; - spentvini = -1; - if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) - txid = spenttxid; - else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) - { - fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); - return(-2); - } + spenttxid = zeroid; + spentvini = -1; + if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) txid = spenttxid; -//fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); - if ( spentvini != 0 ) // game is over? - { - return(0); - } - if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) - { - uint256 g,b; CPubKey p; std::vector k; - if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) - { - keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); - for (i=0; i= ROGUE_MAXITERATIONS ) - { - fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); - return(-5); - } - //fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); - } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); - batontxid = txid; - batonvout = 0; // not vini - // how to detect timeout, bailedout, highlander - hashBlock = zeroid; - if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 0 ) + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + return(-2); + } + txid = spenttxid; + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + if ( spentvini != 0 ) // game is over? { - if ( hashBlock == zeroid ) - batonht = komodo_nextheight(); - else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) - return(-4); - else batonht = pindex->GetHeight(); - batonvalue = batontx.vout[0].nValue; - //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); - } else fprintf(stderr,"couldnt find baton\n"); - } else fprintf(stderr,"error with playerdata\n"); - } else fprintf(stderr,"findbaton opret error\n"); - } - else - { - fprintf(stderr,"already played\n"); - return(-6); - } + } + if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) + { + uint256 g,b; CPubKey p; std::vector k; + if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) + { + keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); + for (i=0; i= ROGUE_MAXITERATIONS ) + { + fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); + return(-5); + } + //fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); + } + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + batontxid = txid; + batonvout = 0; // not vini + // how to detect timeout, bailedout, highlander + hashBlock = zeroid; + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 0 ) + { + if ( hashBlock == zeroid ) + batonht = komodo_nextheight(); + else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) + return(-4); + else batonht = pindex->GetHeight(); + batonvalue = batontx.vout[0].nValue; + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + return(0); + } else fprintf(stderr,"couldnt find baton\n"); + } else fprintf(stderr,"error with playerdata\n"); + } else fprintf(stderr,"findbaton opret error\n"); } return(-1); } +int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametxid,int32_t maxplayers,int32_t gameht,CTransaction gametx) +{ + int32_t i,n,vout,spentvini,registration_open = 0,alive = 0; CTransaction tx; uint256 txid,spenttxid,hashBlock; CBlockIndex *pindex; uint64_t txfee = 10000; + numplayers = openslots = 0; + if ( komodo_nextheight() <= gameheight+ROGUE_MAXKEYSTROKESGAP ) + registration_open = 1; + for (i=0; i= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + break; + } + txid = spenttxid; + vout = 0; + fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + if ( spentvini != 0 ) + break; + if ( n++ > 1000 ) + break; + } + if ( txid != zeroid ) + { + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + if ( pindex->GetHeight() <= gameheight+ROGUE_MAXKEYSTROKESGAP ) + alive++; + } + } + } + } + else if ( registration_open != 0 ) + openslots++; + } + return(alive); +} + void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *myrogueaddr) { // identify if bailout or quit or timed out @@ -883,7 +912,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { - CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; + CPubKey roguepk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; @@ -891,7 +920,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto playertxid = zeroid; if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) { - if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) + if ( (retval= rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname)) == 0 ) { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); @@ -951,7 +980,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } else { - fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p\n",keystrokes); + fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); if ( keystrokes != 0 ) free(keystrokes), keystrokes = 0; } @@ -1155,8 +1184,6 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else { - //if ( maxplayers == 1 ) - // mult /= 2; cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); @@ -1169,8 +1196,13 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( funcid == 'H' && maxplayers > 1 ) { - if ( (numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1) && P.amulet == 0 ) - return(cclib_error(result,"highlander must be a winner or last one standing")); + if ( P.amulet == 0 ) + { + if ( numplayers != maxplayers ) + return(cclib_error(result,"numplayers != maxplayers")); + else if ( rogue_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) + return(cclib_error(result,"highlander must be a winner or last one standing")); + } cashout += numplayers * buyin; } if ( cashout >= txfee ) @@ -1265,7 +1297,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t maxplayers,numplayers,gameheight,nextheight,vout,numvouts; CPubKey roguepk; char coinaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t openslots,maxplayers,numplayers,gameheight,nextheight,vout,numvouts; CPubKey roguepk; char coinaddr[64]; std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,roguepk); @@ -1280,8 +1312,8 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) continue; if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,1) == 0 && nextheight <= gameheight+ROGUE_MAXKEYSTROKESGAP ) { - rogue_playersalive(numplayers,txid,maxplayers); - if ( numplayers < maxplayers ) + rogue_playersalive(openslots,numplayers,txid,maxplayers,gameheight,tx); + if ( openslots > 0 ) a.push_back(txid.GetHex()); } } From 9b6c331f8105d7ec17f7c9450bdbe1357a201fae Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 01:40:44 -1100 Subject: [PATCH 2715/3904] Synth --- src/cc/rogue_rpc.cpp | 70 ++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 158b2a7c6..b418926dc 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -277,39 +277,6 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } -uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) -{ - CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; - if ( myGetTransaction(gametxid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) - { - ht = pindex->GetHeight(); - delay = ROGUE_REGISTRATION * (maxplayers > 1); - obj.push_back(Pair("height",ht)); - obj.push_back(Pair("start",ht+delay)); - if ( komodo_nextheight() > ht+delay ) - { - if ( (pindex= komodo_chainactive(ht+delay)) != 0 ) - { - hashBlock = pindex->GetBlockHash(); - obj.push_back(Pair("starthash",hashBlock.ToString())); - memcpy(&seed,&hashBlock,sizeof(seed)); - seed &= (1LL << 62) - 1; - obj.push_back(Pair("seed",(int64_t)seed)); - if ( rogue_iamregistered(maxplayers,gametxid,tx,myrogueaddr) > 0 ) - sprintf(cmd,"cc/rogue/rogue %llu %s",(long long)seed,gametxid.ToString().c_str()); - else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str()); - obj.push_back(Pair("run",cmd)); - } - } - obj.push_back(Pair("alive",rogue_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); - obj.push_back(Pair("openslots",openslots)); - obj.push_back(Pair("numplayers",numplayers)); - } - obj.push_back(Pair("maxplayers",maxplayers)); - obj.push_back(Pair("buyin",ValueFromAmount(buyin))); - return(seed); -} - int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0) { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; @@ -610,7 +577,7 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx { int32_t i,n,vout,spentvini,registration_open = 0,alive = 0; CTransaction tx; uint256 txid,spenttxid,hashBlock; CBlockIndex *pindex; uint64_t txfee = 10000; numplayers = openslots = 0; - if ( komodo_nextheight() <= gameheight+ROGUE_MAXKEYSTROKESGAP ) + if ( komodo_nextheight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) registration_open = 1; for (i=0; iGetHeight() <= gameheight+ROGUE_MAXKEYSTROKESGAP ) + if ( pindex->GetHeight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) alive++; } } @@ -658,6 +625,39 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx return(alive); } +uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *myrogueaddr) +{ + CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; + if ( myGetTransaction(gametxid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + ht = pindex->GetHeight(); + delay = ROGUE_REGISTRATION * (maxplayers > 1); + obj.push_back(Pair("height",ht)); + obj.push_back(Pair("start",ht+delay)); + if ( komodo_nextheight() > ht+delay ) + { + if ( (pindex= komodo_chainactive(ht+delay)) != 0 ) + { + hashBlock = pindex->GetBlockHash(); + obj.push_back(Pair("starthash",hashBlock.ToString())); + memcpy(&seed,&hashBlock,sizeof(seed)); + seed &= (1LL << 62) - 1; + obj.push_back(Pair("seed",(int64_t)seed)); + if ( rogue_iamregistered(maxplayers,gametxid,tx,myrogueaddr) > 0 ) + sprintf(cmd,"cc/rogue/rogue %llu %s",(long long)seed,gametxid.ToString().c_str()); + else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str()); + obj.push_back(Pair("run",cmd)); + } + } + obj.push_back(Pair("alive",rogue_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); + obj.push_back(Pair("openslots",openslots)); + obj.push_back(Pair("numplayers",numplayers)); + } + obj.push_back(Pair("maxplayers",maxplayers)); + obj.push_back(Pair("buyin",ValueFromAmount(buyin))); + return(seed); +} + void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *myrogueaddr) { // identify if bailout or quit or timed out From bfdd14c4fdc1c67c45fc99e1c560dcbadc09398c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 01:45:31 -1100 Subject: [PATCH 2716/3904] +prints --- src/cc/rogue_rpc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b418926dc..f4bc769f5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -503,17 +503,17 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( matches == 1 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1) < 0 ) { @@ -527,7 +527,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-2); } txid = spenttxid; - //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); @@ -564,7 +564,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); From 4e9aa2136d513419947bf2cad6626c445b27cd59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 01:55:59 -1100 Subject: [PATCH 2717/3904] add rogueaddr to extract --- src/cc/rogue_rpc.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f4bc769f5..52a514870 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -996,6 +996,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); + rogueaddr[0] = 0; if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) @@ -1004,14 +1005,20 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("gametxid",gametxid.GetHex())); if ( n == 2 ) { - if ( (pubstr= jstr(jitem(params,1),0)) != 0 && strlen(pubstr) == 66 ) + if ( (pubstr= jstr(jitem(params,1),0)) != 0 ) { - decode_hex(pub33,33,pubstr); - pk = buf2pk(pub33); + if (strlen(pubstr) == 66 ) + { + decode_hex(pub33,33,pubstr); + pk = buf2pk(pub33); + } + else if ( strlen(pub33) < 36 ) + strcpy(rogueaddr,pubstr); } //fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); } - GetCCaddress1of2(cp,rogueaddr,roguepk,pk); + if ( rogueaddr[0] == 0 ) + GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); str[0] = 0; if ( (keystrokes= rogue_extractgame(1,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) From 885acadeb53181f28b5af983bcb2111b1a44d904 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 01:56:53 -1100 Subject: [PATCH 2718/3904] pubstr --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 52a514870..75eb1ab6b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1012,7 +1012,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) decode_hex(pub33,33,pubstr); pk = buf2pk(pub33); } - else if ( strlen(pub33) < 36 ) + else if ( strlen(pubstr) < 36 ) strcpy(rogueaddr,pubstr); } //fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); From e4d71c9ada40fdcb137ce05b67c16f9ac3960f2e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 02:01:06 -1100 Subject: [PATCH 2719/3904] -print --- src/cc/rogue_rpc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 75eb1ab6b..5553c9c2a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -503,17 +503,17 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( matches == 1 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1) < 0 ) { @@ -527,7 +527,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-2); } txid = spenttxid; - fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); @@ -564,7 +564,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); From 47ec1a61e396613e83abd3897bbe013463ee9177 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 02:13:59 -1100 Subject: [PATCH 2720/3904] Keystrokes --- src/cc/rogue_rpc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5553c9c2a..c05b02a91 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -971,7 +971,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } else { - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); + sprintf(str,"$$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); //fprintf(stderr,"%s\n",str); *numkeysp = numkeys; return(keystrokes); @@ -991,7 +991,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; + UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*hexstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); @@ -1025,9 +1025,15 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("status","success")); flag = 1; + hexstr = malloc(numkeys*2 + 1) + for (i=0; i Date: Wed, 27 Feb 2019 02:15:06 -1100 Subject: [PATCH 2721/3904] Char * --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c05b02a91..4d0011d06 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1025,7 +1025,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("status","success")); flag = 1; - hexstr = malloc(numkeys*2 + 1) + hexstr = (char *)malloc(numkeys*2 + 1); for (i=0; i Date: Wed, 27 Feb 2019 03:05:41 -1100 Subject: [PATCH 2722/3904] Test --- src/cc/rogue/main.c | 68 ++++++++++++++++++++++++++++++++++++++++++-- src/cc/rogue/rogue.c | 21 +++++++------- src/cc/rogue/rogue.h | 10 ++++--- src/cc/rogue_rpc.cpp | 8 +++--- 4 files changed, 86 insertions(+), 21 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 2daa1d0c7..d814bcbd3 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -708,11 +708,48 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) #include "rogue.h" -void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) +int32_t rogue_confirmed(uint256 txid) { - char cmd[16384],hexstr[16384],params[32768],*retstr; int32_t i; + char params[512],*retstr; cJSON *retjson; int32_t numconfs = -1; + sprintf(params,"[\"%s\"]",txid.GetHex().c_str()); + if ( (retstr= komodo_issuemethod(USERPASS,"getrawtransaction",params,ROGUE_PORT)) != 0 ) + { + fprintf(stderr,"params.(%s) -> %s\n",params,retstr); + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + numconfs = juint(retjson,"confirmations"); + free_json(retjson); + } + free(retstr); + } + fprintf(stderr,"numconfs %d\n",numconfs); + return(numconfs); +} + +void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) +{ + char cmd[16384],hexstr[16384],params[32768],*retstr; int32_t i; uint256 txid; + memset(&txid,0,sizeof(txid)); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { + if ( rs->keytxid != zeroid ) + { + if ( rogue_confirmed(rs->keytxid) < 2 ) + { + if ( waitflag == 0 ) + return(0); + else + { + while ( rogue_confirmed(rs->keytxid) < 2 ) + { + fprintf(stderr,"pre-rebroadcast\n"); + RelayTransaction(rs->keystrokestx); + sleep(10); + } + } + } + rs->keytxid = zeroid; + } for (i=0; ikeystrokestx = tx; + rs->keytxid = txid; + fprintf(stderr,"set keystrokestx <- %s\n",txid.GetHex().c_str()); + } + } + } + free_json(retjson); + } free(retstr); } - sleep(1); + if ( waitflag != 0 && rs->keytxid != zeroid ) + { + while ( rogue_confirmed(rs->keytxid) < 2 ) + { + fprintf(stderr,"post-rebroadcast\n"); + RelayTransaction(rs->keystrokestx); + sleep(3); + } + } } } } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 10fff1dd7..2b8a0ffc0 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -119,7 +119,7 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter) } #ifdef test -int32_t flushkeystrokes(struct rogue_state *rs) +int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) { char fname[1024]; FILE *fp; int32_t i,retflag = -1; roguefname(fname,rs->seed,rs->counter); @@ -155,7 +155,7 @@ int32_t flushkeystrokes(struct rogue_state *rs) #ifdef BUILD_ROGUE // stubs for inside daemon -void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num) +void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { } @@ -165,16 +165,17 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) } #endif -int32_t flushkeystrokes(struct rogue_state *rs) +int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) { if ( rs->num > 0 ) { // need to get existing keystrokes including mempool // create keystrokes that are not saved - rogue_progress(rs,rs->seed,rs->buffered,rs->num); + //rs->keytxid = rogue_progress(rs,waitflag,rs->seed,&rs->buffered[rs->lastnum],rs->num - rs->lastnum); + //rs->lastnum = rs->num; + rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num); memset(rs->buffered,0,sizeof(rs->buffered)); rs->counter++; - rs->num = 0; } return(0); } @@ -182,7 +183,7 @@ int32_t flushkeystrokes(struct rogue_state *rs) void rogue_bailout(struct rogue_state *rs) { char cmd[512]; - flushkeystrokes(rs); + flushkeystrokes(rs,1); //sleep(5); return; /*fprintf(stderr,"bailing out\n"); @@ -562,15 +563,15 @@ playit(struct rogue_state *rs) } else { - if ( rs->needflush != 0 && rs->num > 1000 ) + if ( rs->needflush != 0 ) { - if ( flushkeystrokes(rs) == 0 ) + if ( flushkeystrokes(rs,0) == 0 ) rs->needflush = 0; } } } if ( rs->guiflag != 0 ) - flushkeystrokes(rs); + flushkeystrokes(rs,1); endit(0); } @@ -595,7 +596,7 @@ int32_t _quit() if ( rs->sleeptime != 0 ) refresh(); score(rs,purse, 1, 0); - flushkeystrokes(rs); + flushkeystrokes(rs,1); my_exit(0); } else diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index b64af8f1a..e5ea51771 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -361,12 +361,14 @@ typedef union _bits256 bits256; struct rogue_state { + uint256 keytxid; + CTransaction keystrokestx; uint64_t seed; char *keystrokes; uint32_t needflush,replaydone; - int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring; + int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; struct rogue_player P; - char buffered[8192]; + char buffered[65536*16]; uint8_t playerdata[10000]; }; extern struct rogue_state globalR; @@ -374,12 +376,12 @@ extern struct rogue_state globalR; int rogue(int argc, char **argv, char **envp); void rogueiterate(struct rogue_state *rs); int32_t roguefname(char *fname,uint64_t seed,int32_t counter); -int32_t flushkeystrokes(struct rogue_state *rs); +int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag); int32_t rogue_restorepack(struct rogue_state *rs); void restore_player(struct rogue_state *rs); int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); void rogue_bailout(struct rogue_state *rs); -void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num); +void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num); int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr); #define ROGUE_MAXTOTAL (pstats.s_str*2) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4d0011d06..08d1b72e7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -361,7 +361,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint } } //fprintf(stderr,"trace spend to %s/v%d\n",txid.GetHex().c_str(),vout); - if ( n++ > 1000 ) + if ( n++ > ROGUE_MAXITERATIONS ) break; } obj.push_back(Pair("gametxid",gametxid.GetHex())); @@ -588,7 +588,7 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx { txid = gametxid; vout = 1+i; - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",gametxid.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",gametxid.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,vout,1) < 0 ) { @@ -603,10 +603,10 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx } txid = spenttxid; vout = 0; - fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) break; - if ( n++ > 1000 ) + if ( n++ > ROGUE_MAXITERATIONS ) break; } if ( txid != zeroid ) From 16341e10bc92a01c232dd3edb8335e607d0cb136 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 03:15:49 -1100 Subject: [PATCH 2723/3904] Test --- src/cc/rogue/main.c | 46 ++++++++++++++++++++------------------------ src/cc/rogue/rogue.h | 4 +--- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index d814bcbd3..80d572a72 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -708,22 +708,25 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) #include "rogue.h" -int32_t rogue_confirmed(uint256 txid) +int32_t rogue_sendrawtransaction(char *rawtx) { char params[512],*retstr; cJSON *retjson; int32_t numconfs = -1; - sprintf(params,"[\"%s\"]",txid.GetHex().c_str()); - if ( (retstr= komodo_issuemethod(USERPASS,"getrawtransaction",params,ROGUE_PORT)) != 0 ) + sprintf(params,"[\"%s\"]",rawtx); + if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { fprintf(stderr,"params.(%s) -> %s\n",params,retstr); + if ( is_hexstr(retstr,64) == 64 ) + { + free(retstr); + return(0); + } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - numconfs = juint(retjson,"confirmations"); free_json(retjson); } free(retstr); } - fprintf(stderr,"numconfs %d\n",numconfs); - return(numconfs); + return(-1); } void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) @@ -732,23 +735,22 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * memset(&txid,0,sizeof(txid)); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { - if ( rs->keytxid != zeroid ) + if ( rs->keystrokeshex != 0 ) { - if ( rogue_confirmed(rs->keytxid) < 2 ) + if ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { if ( waitflag == 0 ) - return(0); + return; else { - while ( rogue_confirmed(rs->keytxid) < 2 ) + while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { fprintf(stderr,"pre-rebroadcast\n"); - RelayTransaction(rs->keystrokestx); sleep(10); } } } - rs->keytxid = zeroid; + free(rs->keystrokeshex), rs->keystrokeshex = 0; } for (i=0; ikeystrokestx = tx; - rs->keytxid = txid; - fprintf(stderr,"set keystrokestx <- %s\n",txid.GetHex().c_str()); - } - } + if ( rs->keystrokeshex != 0 ) + free(rs->keystrokeshex); + rs->keystrokeshex = (char *)malloc(strlen(hexstr)+1); + strcpy(rs->keystrokeshex,hexstr); + fprintf(stderr,"set keystrokestx <- %s\n",txid.GetHex().c_str()); } free_json(retjson); } free(retstr); } - if ( waitflag != 0 && rs->keytxid != zeroid ) + if ( waitflag != 0 && rs->keystrokeshex != 0 ) { - while ( rogue_confirmed(rs->keytxid) < 2 ) + while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { fprintf(stderr,"post-rebroadcast\n"); - RelayTransaction(rs->keystrokestx); sleep(3); } } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index e5ea51771..e5422c3c2 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -361,10 +361,8 @@ typedef union _bits256 bits256; struct rogue_state { - uint256 keytxid; - CTransaction keystrokestx; uint64_t seed; - char *keystrokes; + char *keystrokes,*keystrokeshex; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; struct rogue_player P; From 18f44b1077f39975840ec571b8cec6dfdbf0aa09 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 03:17:29 -1100 Subject: [PATCH 2724/3904] rs->keystrokeshex --- src/cc/rogue/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 80d572a72..1a915cc6c 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -731,7 +731,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr; int32_t i; uint256 txid; + char cmd[16384],hexstr[16384],params[32768],*retstr; int32_t i; cJSON *retjson; memset(&txid,0,sizeof(txid)); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { @@ -783,7 +783,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(rs->keystrokeshex); rs->keystrokeshex = (char *)malloc(strlen(hexstr)+1); strcpy(rs->keystrokeshex,hexstr); - fprintf(stderr,"set keystrokestx <- %s\n",txid.GetHex().c_str()); + fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } free_json(retjson); } From 62684be1a1a1762f4726dd232e0c7d45a109d7e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 03:18:52 -1100 Subject: [PATCH 2725/3904] Rawtx --- src/cc/rogue/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 1a915cc6c..9612d3bce 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -731,8 +731,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr; int32_t i; cJSON *retjson; - memset(&txid,0,sizeof(txid)); + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson; if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { if ( rs->keystrokeshex != 0 ) @@ -777,12 +776,12 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (hexstr= jstr(retjson,"hex")) != 0 ) + if ( (rawtx= jstr(retjson,"hex")) != 0 ) { if ( rs->keystrokeshex != 0 ) free(rs->keystrokeshex); - rs->keystrokeshex = (char *)malloc(strlen(hexstr)+1); - strcpy(rs->keystrokeshex,hexstr); + rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); + strcpy(rs->keystrokeshex,rawtx); fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } free_json(retjson); From c712f2815323157eb67e640230950151c3e3748e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 03:29:33 -1100 Subject: [PATCH 2726/3904] +print --- src/cc/rogue/main.c | 2 ++ src/cc/rogue/rogue.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 9612d3bce..2ebd171c9 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -712,6 +712,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) { char params[512],*retstr; cJSON *retjson; int32_t numconfs = -1; sprintf(params,"[\"%s\"]",rawtx); + fprintf(stderr,"sendrawtransaction\n"); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { fprintf(stderr,"params.(%s) -> %s\n",params,retstr); @@ -732,6 +733,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson; + fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { if ( rs->keystrokeshex != 0 ) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 2b8a0ffc0..14650a0c7 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -318,6 +318,7 @@ int rogue(int argc, char **argv, char **envp) { rs->seed = atol(argv[1]); strcpy(Gametxidstr,argv[2]); + fprintf(stderr,"setplayerdata\n"); if ( rogue_setplayerdata(rs,Gametxidstr) < 0 ) { fprintf(stderr,"invalid gametxid, or already started\n"); @@ -413,7 +414,7 @@ int rogue(int argc, char **argv, char **envp) #endif printf("Hello %s, just a moment while I dig the dungeon... seed.%llu", whoami,(long long)rs->seed); fflush(stdout); - + fprintf(stderr,"rogueiterate\n"); rogueiterate(rs); return(0); } From 4b030a62a9b0c6cea9594b928c91f552dafd9af7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 03:34:07 -1100 Subject: [PATCH 2727/3904] Reduce size of buffer --- src/cc/rogue/rogue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index e5422c3c2..d453a871f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -366,7 +366,7 @@ struct rogue_state uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; struct rogue_player P; - char buffered[65536*16]; + char buffered[10000]; uint8_t playerdata[10000]; }; extern struct rogue_state globalR; From f09c30068068bd40a28052dd5381776219ca9639 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 03:51:31 -1100 Subject: [PATCH 2728/3904] -print --- src/cc/rogue/main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 2ebd171c9..4bcc5c533 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -712,10 +712,9 @@ int32_t rogue_sendrawtransaction(char *rawtx) { char params[512],*retstr; cJSON *retjson; int32_t numconfs = -1; sprintf(params,"[\"%s\"]",rawtx); - fprintf(stderr,"sendrawtransaction\n"); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { - fprintf(stderr,"params.(%s) -> %s\n",params,retstr); + //fprintf(stderr,"params.(%s) -> %s\n",params,retstr); if ( is_hexstr(retstr,64) == 64 ) { free(retstr); @@ -733,7 +732,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson; - fprintf(stderr,"rogue_progress num.%d\n",num); + //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { if ( rs->keystrokeshex != 0 ) @@ -746,7 +745,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * { while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { - fprintf(stderr,"pre-rebroadcast\n"); + //fprintf(stderr,"pre-rebroadcast\n"); sleep(10); } } @@ -784,7 +783,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(rs->keystrokeshex); rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); strcpy(rs->keystrokeshex,rawtx); - fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); + //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } free_json(retjson); } @@ -794,7 +793,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * { while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { - fprintf(stderr,"post-rebroadcast\n"); + //fprintf(stderr,"post-rebroadcast\n"); sleep(3); } } From 263f5fcfe97d4de6dc8bf5fdb363c21e493ad1e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 04:04:10 -1100 Subject: [PATCH 2729/3904] -print --- src/cc/rogue/rip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index 1866f0b48..123b1aaa8 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -238,7 +238,7 @@ death(struct rogue_state *rs,char monst) //struct tm *localtime(const time_t *); if ( rs->guiflag == 0 ) { - fprintf(stderr,"death during replay by (%c)\n",monst); //sleep(3); + //fprintf(stderr,"death during replay by (%c)\n",monst); //sleep(3); rs->replaydone = (uint32_t)time(NULL); return; } From 53e66f1170614c94ebb2c4b81bcdff757c382fcd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 04:31:00 -1100 Subject: [PATCH 2730/3904] Merge branch 'dev' into FSM # Conflicts: # depends/packages/zeromq.mk # src/assetchains.json --- README.md | 6 ++- depends/packages/boost.mk | 6 +-- depends/packages/zeromq.mk | 8 ++-- doc/release-notes/release-notes-0.3.0.md | 58 ++++++++++++++++++++++++ src/ac/iln | 2 + src/ac/our | 2 + src/assetchains.json | 12 +++-- src/assetchains.old | 2 + src/cc/assets.cpp | 7 +++ src/fiat/iln | 2 + src/fiat/our | 2 + 11 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 doc/release-notes/release-notes-0.3.0.md create mode 100755 src/ac/iln create mode 100755 src/ac/our create mode 100755 src/fiat/iln create mode 100755 src/fiat/our diff --git a/README.md b/README.md index 9a8582891..0f112982d 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,12 @@ cd komodo ``` #### OSX -Ensure you have [brew](https://brew.sh) and the command line tools installed (comes automatically with XCode) and run: +Ensure you have [brew](https://brew.sh) and Command Line Tools installed. ```shell +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +# installs brew +xcode-select --install +# opens a pop-up window to install CLT without installing the entire Xcode package brew update && brew install gcc@6 git clone https://github.com/komodoplatform/komodo --branch master --single-branch cd komodo diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 3c180b0ce..7a0439ba7 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,8 +1,8 @@ package=boost -$(package)_version=1_66_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.66.0/source +$(package)_version=1_69_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.69.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9 +$(package)_sha256_hash=8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 define $(package)_set_vars $(package)_config_opts_release=variant=release diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 0cb256e81..89fb6ef1c 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -1,21 +1,21 @@ ifeq ($(host_os),mingw32) -$(package)_version=4.2.2-1 +$(package)_version=4.3.1 $(package)_download_path=https://github.com/ca333/libzmq/archive $(package)_download_file=v$($(package)_version).tar.gz $(package)_file_name=libzmq-$($(package)_version).tar.gz -$(package)_sha256_hash=0e225b85ce11be23bf7eb7d3f25c6686728bf30d5c31f61c12d37bb646c69962 +$(package)_sha256_hash=cb8ebe5b60dadeb526745610d6237f05a98aba287114d8991dad1fa14f4be354 define $(package)_set_vars $(package)_build_env+= $(package)_config_opts=--enable-shared=false --enable-static --host=x86_64-w64-mingw32 - $(package)_config_opts_mingw32=--enable-shared=false --enable-static --host=x86_64-w64-mingw32 + $(package)_config_opts_mingw32=--enable-shared=false --enable-static --prefix=$(host_prefix) --host=x86_64-w64-mingw32 -disable-curve $(package)_cflags=-Wno-error -Wall -Wno-pedantic-ms-format -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -lws2_32 -liphlpapi -lrpcrt4 $(package)_conf_tool=./configure endef else package=zeromq $(package)_version=4.3.1 -$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/ +$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version) $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb diff --git a/doc/release-notes/release-notes-0.3.0.md b/doc/release-notes/release-notes-0.3.0.md new file mode 100644 index 000000000..84ffc8efb --- /dev/null +++ b/doc/release-notes/release-notes-0.3.0.md @@ -0,0 +1,58 @@ + +Komodo specific changelog: + +- add CC functionality and bugfixes +- set sapling activation +- change z-addr prefix byte +- blocksize increased from 2MB to 4 MB +- transaction size increased from 100KB to 200KB + +Sapling related changelog: + +- Decoupled Spend Authority +- Improved Performance for Shielded Transactions (using sapling instead of sprout) +- transaction format changed + +Alex Morcos (1): Output line to debug.log when IsInitialBlockDownload latches to false + +Ariel Gabizon (1): Extend Joinsplit tests to Groth + +Charlie OKeefe (1): Remove extra slash from lockfile path + +Cory Fields (1): crypter: shuffle Makefile so that crypto can be used by the wallet + +Daira Hopwood (1): Support testnet rollback. + +Daniel Cousens (2): move rpc* to rpc/ rpc: update inline comments to refer to new file paths + +Dimitris Apostolou (1): Fix typos + +Duke Leto (3): Fix absurd fee bug reported in #3281, with tests Update comment as per @arielgabizon Improve error message + +Eirik Ogilvie-Wigley (24): Add more options when asserting in RPC tests Add change indicator for notes Fix test broken by change indicator Rename note data to include sprout Remove redundant curly braces Consolidate for loops Add out point for sapling note data Add sapling note data and map Decrement sapling note witnesses Clear sapling witness cache Extract method for copying previous witnesses Extract methods for incrementing witnesses Extract method for incrementing witness heights Pass sapling merkle tree when incrementing witnesses Increment sapling note witnesses Rename sprout specific methods Remove extra indentation Add getter and setter for sapling note data and update tests Add parameter for version in GetValidReceive Rename Merkle Trees to include sprout or sapling Rename Witnesses to include sprout or sapling Rename test objects to include sprout or sapling Only include the change field if we have a spending key Fix assertion and comment + +Gregory Maxwell (2): IBD check uses minimumchain work instead of checkpoints. IsInitialBlockDownload no longer uses header-only timestamps. + +Jack Grigg (41): Add some more checkpoints, up to the 1.1.0 release Add Sapling support to z_validateaddress Update payment-api.md with type field of z_validateaddress Alter SaplingNote::nullifier() to take a SaplingFullViewingKey Expose note position in IncrementalMerkleWitness TransactionBuilder with support for creating Sapling-only transactions TransactionBuilder: Check that all anchors in a transaction are identical Formatting test: Move ECC_Start() call into src/gtest/main.cpp TransactionBuilder: Add support for transparent inputs and outputs TransactionBuilder: Add change output to transaction TransactionBuilder: Make fee configurable Rename xsk to expsk Implement CKeyStore::GetSaplingPaymentAddresses() Raise the 90-character limit on Bech32 encodings Add Sapling support to z_getnewaddress and z_listaddresses Fix block hash for checkpoint at height 270000 Formatting test: Deduplicate logic in wallet_addresses RPC test test: Another assert in wallet_zkeys_tests.store_and_load_sapling_zkeys test: Fix permissions of wallet_addresses test: Update rpc_wallet_z_importexport to account for Sapling changes Rename DecryptSpendingKey -> DecryptSproutSpendingKey Rename CryptedSpendingKeyMap -> CryptedSproutSpendingKeyMap Add Sapling decryption check to CCryptoKeyStore::Unlock() Check for unencrypted Sapling keys in CCryptoKeyStore::SetCrypted() Remove outdated comment Add CWallet::AddCryptedSaplingSpendingKey() hook Pass SaplingPaymentAddress to store through the CKeyStore Rename SpendingKeyMap -> SproutSpendingKeyMap Rename SerializedSize -> SerializedSproutSize Rename ViewingKey -> SproutViewingKey Formatting nits Rename *SpendingKey -> *SproutSpendingKey chainparams: Add BIP 44 coin type (as registered in SLIP 44) Upgrade Rust to 1.28.0 stable Adjust Makefile so that common can be used by the wallet Move RewindBlockIndex log message inside rewindLength check test: gtest for Sapling encoding and decoding test: Use regtest in key_tests/zs_address_test Disable Sapling features on mainnet + +Jay Graber (13): Add Sapling Add/Have/Get to keystore Add SaplingIncomingViewingKeys map, SaplingFullViewingKey methods Add StoreAndRetrieveSaplingSpendingKey test Change default_address to return SaplingPaymentAddr and not boost::optional Add crypted keystore sapling add key Discard sk if ivk == 0 Add Sapling support to z_exportkey Add Sapling support to z_importkey Add Sapling to rpc_wallet_z_importexport test Refactor into visitors and throw errors for invalid key or address. Take expiryheight as param to createrawtransaction Add Sapling have/get sk crypter overrides Add Sapling keys to CCryptoKeyStore::EncryptKeys + +Jonas Schnelli (2): [RPC, Wallet] Move RPC dispatch table registration to wallet/ code Fix test_bitcoin circular dependency issue + +Kaz Wesley (1): IsInitialBlockDownload: usually avoid locking + +Larry Ruane (4): Disable libsnark debug logging in Boost tests add extra help how to enable experimental features Add call to sync_all() after (z_sendmany, wait) don't ban peers when loading pre-overwinter blocks + +Pejvan (2): Update README.md Update README.md + +Richard Littauer (1): docs(LICENSE): update license year to 2018 + +Sean Bowe (21): Update librustzcash Implementation of Sapling in-band secret distribution. Swap types in OutputDescription to use new NoteEncryption interfaces. Prevent nonce reuse in Sapling note encryption API. Add get_esk() function to Sapling note encryption. Minor edits Decryption and tests of note/outgoing encryption. Update librustzcash and sapling-crypto. Fix bug in return value. Ensure sum of valueBalance and all vpub_new's does not exceed MAX_MONEY inside of CheckTransactionWithoutProofVerification. Move extern params to beginning of test_checktransaction. Relocate ECC_Start() to avoid test failures. Don't call ECC_Start/ECC_Stop outside the test harness. Make changes to gtest ECC behavior suggested by @str4d. Check the hash of the (Sapling+) zk-SNARK parameters during initialization. Switch to use the official Sapling parameters. make-release.py: Versioning changes for 2.0.0-rc1. make-release.py: Updated manpages for 2.0.0-rc1. make-release.py: Updated release notes and changelog for 2.0.0-rc1. Always write the empty root down as the best root, since we may roll back. Sapling mainnet activation height + +Simon Liu (11): Add encryption of SaplingNotePlaintext and SaplingOutgoingPlaintext classes. Update and fix per review comments, the test for absurd fee. Minor update to address nits in review. Implement Sapling note decryption using full viewing key. Rename AttemptSaplingEncDecryptionUsingFullViewingKey and use function overloading. Only check for a valid Sapling anchor after Sapling activation. Clean up for rebase: rename mapNoteData to mapSproutNoteData. Clean up help messages for RPC createrawtransaction. Add tests for expiryheight parameter of RPC createrawtransaction. make-release.py: Versioning changes for 2.0.0. make-release.py: Updated manpages for 2.0.0. + +Wladimir J. van der Laan (2): Make max tip age an option instead of chainparam rpc: Register calls where they are defined + +kozyilmaz (1): Add -Wl,-pie linker option for macOS and use it instead of -pie + +mdr0id (1): Fix minor references to auto-senescence in code diff --git a/src/ac/iln b/src/ac/iln new file mode 100755 index 000000000..f453c338e --- /dev/null +++ b/src/ac/iln @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/our b/src/ac/our new file mode 100755 index 000000000..66c774476 --- /dev/null +++ b/src/ac/our @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index 91baf9829..9e7307a31 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -238,7 +238,13 @@ "addnode": [ "51.255.195.65", "217.182.129.38", - "95.216.150.177" - ] -} + "37.187.225.231" + ] + }, + { + "ac_name": "ILN", + "ac_supply": "10000000000", + "ac_cc": "2", + "addnode": ["51.75.122.83"] + } ] diff --git a/src/assetchains.old b/src/assetchains.old index 136f7c709..bb493da9f 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -46,3 +46,5 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=DION -ac_supply=3900000000 -ac_reward=22260000000 -ac_staked=100 -ac_cc=1 -ac_end=4300000000 -addnode=51.75.124.34 & ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & +./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & +./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addnode=51.75.122.83 & diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 6e3fd5909..6e57e816b 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -146,6 +146,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti numvouts = tx.vout.size(); outputsDummy = inputs = 0; preventCCvins = preventCCvouts = -1; + + // add specific chains exceptions for old token support: + if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) + return true; + + if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) + return true; // add specific chains exceptions for old token support: if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) diff --git a/src/fiat/iln b/src/fiat/iln new file mode 100755 index 000000000..f453c338e --- /dev/null +++ b/src/fiat/iln @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/our b/src/fiat/our new file mode 100755 index 000000000..66c774476 --- /dev/null +++ b/src/fiat/our @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6 From b00411083fe6ba16cd828493e5414ac46a09e37b Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Wed, 27 Feb 2019 16:31:41 +0100 Subject: [PATCH 2731/3904] GatewaysCC small fixes --- src/cc/gateways.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index da94822a7..fd18a69b9 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -1815,7 +1815,7 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key) priv=EncodeCustomSecret(key,wiftype); result.push_back(Pair("result","success")); - result.push_back(Pair("address",priv.c_str())); + result.push_back(Pair("privkey",priv.c_str())); return(result); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a19eebb20..d17752223 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6310,7 +6310,7 @@ UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp) uint256 bindtxid; if ( fHelp || params.size() != 2) - throw runtime_error("gatewaysexternaladdress bindtxid address\n"); + throw runtime_error("gatewaysdumpprivkey bindtxid address\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); LOCK2(cs_main, pwalletMain->cs_wallet); From a232b0cd760e7b49a32ab53070e1372d59b9b58a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 04:32:43 -1100 Subject: [PATCH 2732/3904] Revert to boost 1.69 --- depends/packages/boost.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 7a0439ba7..800c424c5 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,8 +1,9 @@ package=boost -$(package)_version=1_69_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.69.0/source + +$(package)_version=1_66_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.66.0/source +$(package)_sha256_hash=5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9 $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 define $(package)_set_vars $(package)_config_opts_release=variant=release From 616c8c33f56cb9c90c1891171f7e6bdf06f80419 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 07:59:32 -1100 Subject: [PATCH 2733/3904] Reset rs->num! --- src/cc/rogue/rogue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 14650a0c7..6cc51e04b 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -175,6 +175,7 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) //rs->lastnum = rs->num; rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num); memset(rs->buffered,0,sizeof(rs->buffered)); + rs->num = 0; rs->counter++; } return(0); From de6828ec7ccd942d3b618c56d762a941eb7cd025 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 00:07:08 +0500 Subject: [PATCH 2734/3904] tokens blob support --- src/Makefile.am | 2 + src/cc/CCassets.h | 2 +- src/cc/CCassetsCore.cpp | 21 ++- src/cc/CCassetstx.cpp | 14 +- src/cc/CCinclude.h | 44 +++-- src/cc/CCtokens.cpp | 345 +++++++++++++-------------------------- src/cc/CCtokens.h | 2 +- src/cc/CCtokensOpRet.cpp | 265 ++++++++++++++++++++++++++++++ src/cc/CCtx.cpp | 3 +- src/cc/CCutilbits.cpp | 105 ++++++++++++ src/cc/CCutils.cpp | 83 ---------- src/cc/assets.cpp | 7 - src/cc/channels.cpp | 9 +- src/cc/gateways.cpp | 31 ++-- src/cc/heir.cpp | 30 ++-- src/cc/heir_validate.h | 16 +- src/cc/prices.cpp | 2 +- src/cc/rogue_rpc.cpp | 22 ++- src/rpc/misc.cpp | 5 +- 19 files changed, 608 insertions(+), 400 deletions(-) create mode 100644 src/cc/CCtokensOpRet.cpp create mode 100644 src/cc/CCutilbits.cpp diff --git a/src/Makefile.am b/src/Makefile.am index d168a328f..ce7fd1731 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -490,6 +490,8 @@ libbitcoin_common_a_SOURCES = \ script/sign.cpp \ script/standard.cpp \ transaction_builder.cpp \ + cc/CCtokensOpRet.cpp \ + cc/CCutilbits.cpp \ $(BITCOIN_CORE_H) \ $(LIBZCASH_H) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index af9ec5bd1..7b31c094d 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -29,7 +29,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCassetsCore -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); +vscript_t EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 63c94d920..d4cc8646e 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -239,30 +239,30 @@ CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,st } */ -CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey) +vscript_t EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey) { - CScript opret; + vscript_t vopret; uint8_t evalcode = EVAL_ASSETS; switch ( assetFuncId ) { //case 't': this cannot be here case 'x': case 'o': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << assetFuncId); + vopret = /*<< OP_RETURN <<*/ E_MARSHAL(ss << evalcode << assetFuncId); break; case 's': case 'b': case 'S': case 'B': - opret << OP_RETURN << E_MARSHAL(ss << evalcode << assetFuncId << price << origpubkey); + vopret = /*<< OP_RETURN <<*/ E_MARSHAL(ss << evalcode << assetFuncId << price << origpubkey); break; case 'E': case 'e': assetid2 = revuint256(assetid2); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << assetFuncId << assetid2 << price << origpubkey); + vopret = /*<< OP_RETURN <<*/ E_MARSHAL(ss << evalcode << assetFuncId << assetid2 << price << origpubkey); break; default: fprintf(stderr,"EncodeAssetOpRet: illegal funcid.%02x\n", assetFuncId); - opret << OP_RETURN; + //opret << OP_RETURN; break; } - return(opret); + return(vopret); } /* it is for compatibility, do not use this for new contracts (use DecodeTokenCreateOpRet) @@ -281,10 +281,11 @@ bool DecodeAssetCreateOpRet(const CScript &scriptPubKey, std::vector &o uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey) { - std::vector vopretAssets; //, vopretAssetsStripped; + vscript_t vopretAssets; //, vopretAssetsStripped; uint8_t *script, funcId = 0, assetsFuncId = 0, dummyEvalCode, dummyAssetFuncId; uint256 dummyTokenid; std::vector voutPubkeysDummy; + std::vector> oprets; tokenid = zeroid; assetid2 = zeroid; @@ -293,7 +294,9 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo assetsFuncId = 0; // First - decode token opret: - funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, vopretAssets); + funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, oprets); + GetOpretBlob(oprets, OPRETID_GATEWAYSDATA, vopretAssets); + LOGSTREAM((char *)"ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl); if (funcId == 0 || vopretAssets.size() < 2) { diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 14be084b4..dfe04fcb2 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -353,9 +353,9 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, txfee, mypk)); std::vector voutTokenPubkeys; // should be empty - no token vouts - return(FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, + return FinalizeCCTx(0, cpAssets, mtx, mypk, txfee, EncodeTokenOpRet(assetid, voutTokenPubkeys, // TODO: actually this tx is not 'tokens', maybe it is better not to have token opret here but only asset opret. - EncodeAssetOpRet('b', zeroid, pricetotal, Mypubkey())))); // But still such token opret should not make problems because no token eval in these vouts + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('b', zeroid, pricetotal, Mypubkey())))); // But still such token opret should not make problems because no token eval in these vouts } CCerror = strprintf("no coins found to make buy offer"); return(""); @@ -419,7 +419,7 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p return FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeTokenOpRet(assetid, voutTokenPubkeys, - EncodeAssetOpRet('s', zeroid, pricetotal, Mypubkey()))); + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('s', zeroid, pricetotal, Mypubkey())))); } else { fprintf(stderr, "need some tokens to place ask\n"); @@ -540,7 +540,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeTokenOpRet(assetid, voutTokenPubkeys, - EncodeAssetOpRet('o', zeroid, 0, Mypubkey())))); + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('o', zeroid, 0, Mypubkey()))))); } } return(""); @@ -608,7 +608,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeTokenOpRet(assetid, voutTokenPubkeys, - EncodeAssetOpRet('x', zeroid, 0, Mypubkey())))); + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('x', zeroid, 0, Mypubkey()))))); } } return(""); @@ -695,7 +695,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f return(FinalizeCCTx(mask, cpTokens, mtx, mypk, txfee, EncodeTokenOpRet(assetid, voutTokenPubkeys, - EncodeAssetOpRet('B', zeroid, remaining_required, origpubkey)))); + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('B', zeroid, remaining_required, origpubkey))))); } else return("dont have any assets to fill bid"); } } @@ -820,7 +820,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a return(FinalizeCCTx(mask, cpAssets, mtx, mypk, txfee, EncodeTokenOpRet(assetid, voutTokenPubkeys, - EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid2, remaining_nValue, origpubkey)))); + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet(assetid2 != zeroid ? 'E' : 'S', assetid2, remaining_nValue, origpubkey))))); } else { CCerror = strprintf("filltx not enough utxos"); fprintf(stderr,"%s\n", CCerror.c_str()); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index ca51506e8..53233f89c 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -67,12 +67,26 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../komodo_cJSON.h" -// opret data block ids: - enum { - OPRETID_NONFUNGIBLEDATA = 0x11 - // TODO: OPRETID_ASSETSDATA = 0x12 +// token opret additional data block ids: + enum opretid : uint8_t { + OPRETID_NONFUNGIBLEDATA = 0x11, OPRETID_FIRST = OPRETID_NONFUNGIBLEDATA, // first id + OPRETID_ASSETSDATA = 0x12, + OPRETID_GATEWAYSDATA = 0x13, + OPRETID_CHANNELSDATA = 0x14, + OPRETID_HEIRDATA = 0x15, + OPRETID_ROGUEGAMEDATA = 0x16, + + OPRETID_BURNDATA = 0x70, + OPRETID_IMPORTDATA = 0x71, OPRETID_LAST = OPRETID_IMPORTDATA // last id }; + // find opret blob by opretid + inline bool GetOpretBlob(const std::vector>> &oprets, uint8_t id, std::vector &vopret) { + vopret.clear(); + for(auto p : oprets) if (p.first == id) { vopret = p.second; return true; } + return false; + } + struct CC_utxo { uint256 txid; @@ -129,6 +143,8 @@ struct oracleprice_info int32_t height; }; +typedef std::vector vscript_t; + #ifdef ENABLE_WALLET extern CWallet* pwalletMain; #endif @@ -172,18 +188,22 @@ uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); //int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); -int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs, std::vector &vopretNonfungible); +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs, vscript_t &vopretNonfungible); int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); -CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector vopretNonfungible); -CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload); //old version -CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload); +CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, vscript_t vopretNonfungible); +CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector> oprets); +CScript EncodeTokenImportOpRet(std::vector origpubkey, std::string name, std::string description, uint256 srctokenid, std::vector> oprets); +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::pair opretWithId); +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector> oprets); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); -uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector &vopretNonfungible); -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra); -void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible); +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector> &oprets); +uint8_t DecodeTokenImportOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, uint256 &srctokenid, std::vector> &oprets); +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector> &oprets); +void GetNonfungibleData(uint256 tokenid, vscript_t &vopretNonfungible); +bool ExtractTokensCCVinPubkeys(const CTransaction &tx, std::vector &vinPubkeys); uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t *data,int32_t offset,int32_t datalen); @@ -227,7 +247,7 @@ uint256 revuint256(uint256 txid); bool pubkey2addr(char *destaddr,uint8_t *pubkey33); char *uint256_str(char *dest,uint256 txid); char *pubkey33_str(char *dest,uint8_t *pubkey33); -uint256 Parseuint256(char *hexstr); +uint256 Parseuint256(const char *hexstr); CPubKey pubkey2pk(std::vector pubkey); int64_t CCfullsupply(uint256 tokenid); int64_t CCtoken_balance(char *destaddr,uint256 tokenid); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index d5fffdf5b..a91591729 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -34,197 +34,13 @@ Yes, this is quite confusing... - In ValudateTokenRemainder the naming convention is nValue is the coin/token with the offer on the books and "units" is what it is being paid in. The high level check is to make sure we didnt lose any coins or tokens, the harder to validate is the actual price paid as the "orderbook" is in terms of the combined nValue for the combined totalunits. + In ValidateTokenRemainder the naming convention is nValue is the coin/token with the offer on the books and "units" is what it is being paid in. The high level check is to make sure we didnt lose any coins or tokens, the harder to validate is the actual price paid as the "orderbook" is in terms of the combined nValue for the combined totalunits. We assume that the effective unit cost in the orderbook is valid and that that amount was paid and also that any remainder will be close enough in effective unit cost to not matter. At the edge cases, this will probably be not true and maybe some orders wont be practically fillable when reduced to fractional state. However, the original pubkey that created the offer can always reclaim it. ------------------------------ */ -// NOTE: this inital tx won't be used by other contract -// for tokens to be used there should be at least one 't' tx with other contract's custom opret -CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector vopretNonfungible ) -{ - CScript opret; - uint8_t evalcode = EVAL_TOKENS; - funcid = 'c'; // override the param - - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description; \ - if (!vopretNonfungible.empty()) { \ - ss << (uint8_t)OPRETID_NONFUNGIBLEDATA; \ - ss << vopretNonfungible; \ - }); - return(opret); -} - - -CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, CScript payload) -{ - CScript opret; - uint8_t tokenFuncId = 't'; - uint8_t evalCodeInOpret = EVAL_TOKENS; - - tokenid = revuint256(tokenid); - - uint8_t ccType = 0; - if (voutPubkeys.size() >= 0 && voutPubkeys.size() <= 2) - ccType = voutPubkeys.size(); - else { - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); - } - - std::vector vpayload; - GetOpReturnData(payload, vpayload); - - opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \ - if (ccType >= 1) ss << voutPubkeys[0]; \ - if (ccType == 2) ss << voutPubkeys[1]; \ - if (vpayload.size() > 0) ss << vpayload); - - // bad opret cases (retries to attach payload without re-serialization): - - // "error 64: scriptpubkey": - // if (payload.size() > 0) - // opret += payload; - - // error 64: scriptpubkey: - // CScript opretPayloadNoOpcode(vpayload); - // return opret + opretPayloadNoOpcode; - - // error sig_aborted: - // opret.resize(opret.size() + vpayload.size()); - // CScript::iterator it = opret.begin() + opret.size(); - // for (int i = 0; i < vpayload.size(); i++, it++) - // *it = vpayload[i]; - - return opret; -} - -// overload for compatibility -CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload) -{ - return EncodeTokenOpRet(tokenid, voutPubkeys, payload); -} - -// overload for fungible: -uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description) { - std::vector vopretNonfungibleDummy; - return DecodeTokenCreateOpRet(scriptPubKey, origpubkey, name, description, vopretNonfungibleDummy); -} - -uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description, std::vector &vopretNonfungible) -{ - std::vector vopret; uint8_t dummyEvalcode, funcid, *script, fieldId = 0; - - GetOpReturnData(scriptPubKey, vopret); - script = (uint8_t *)vopret.data(); - - if ( script != 0 && vopret.size() > 2 && script[0] == EVAL_TOKENS && script[1] == 'c' ) - { - if (E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description; \ - // we suppose in 'c' opret it might be only non-fungible payload and not any assets/heir/etc payloads - if (!ss.eof()) { \ - ss >> fieldId; \ - if( fieldId == OPRETID_NONFUNGIBLEDATA ) \ - ss >> vopretNonfungible; \ - })) - return(funcid); - } - return (uint8_t)0; -} - -// overload for compatibility allows only usual fungible tokens: -// warning: it makes vopret marshalling to CScript because this is what caller would expect -/*uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) { - std::vector vopret1, vopret2; - uint8_t funcId = DecodeTokenOpRet(scriptPubKey, evalCode, tokenid, voutPubkeys, vopret1, vopret2); - - CScript opretExtra; - vopretExtra.clear(); - - // make marshalling for compatibility - // callers of this func expect length of full array at the beginning (and they will make 'vopretStripped' from vopretExtra) - if (vopret2.empty()) - opretExtra << OP_RETURN << E_MARSHAL(ss << vopret1); // if first opret (or no oprets) - else - opretExtra << OP_RETURN << E_MARSHAL(ss << vopret2); // if both oprets present, return assets/heir/gateways/... opret (dump non-fungible opret) - - GetOpReturnData(opretExtra, vopretExtra); - return funcId; -} */ - -// decodes token opret: -// for 't' returns all data from opret, vopretExtra contains other contract's data (currently only assets'). -// for 'c' returns only funcid. NOTE: nonfungible data is not returned -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopretExtra) -{ - std::vector vopret, extra, dummyPubkey, vnonfungibleDummy; - uint8_t funcId=0, *script, dummyEvalCode, dummyFuncId, ccType, fieldId = 0; - std::string dummyName; std::string dummyDescription; - CPubKey voutPubkey1, voutPubkey2; - - GetOpReturnData(scriptPubKey, vopret); - script = (uint8_t *)vopret.data(); - tokenid = zeroid; - vopretExtra.clear(); - - if (script != NULL && vopret.size() > 2) - { - // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! - bool isEof = true; - - evalCodeTokens = script[0]; - if (evalCodeTokens != EVAL_TOKENS) - return (uint8_t)0; - - funcId = script[1]; - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId?funcId:' ') << std::endl); - - switch( funcId ) - { - case 'c': - return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription, vnonfungibleDummy); - //break; - case 't': - //not used yet: case 'l': - // NOTE: 'E_UNMARSHAL result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' - if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; \ - if (ccType >= 1) ss >> voutPubkey1; \ - if (ccType == 2) ss >> voutPubkey2; \ - isEof = ss.eof(); \ - if (!isEof) ss >> vopretExtra; \ - // if something else remains -> bad format - isEof = ss.eof()) || !isEof) - { - - if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); - return (uint8_t)0; - } - - // add verification pubkeys: - voutPubkeys.clear(); - if (voutPubkey1.IsValid()) - voutPubkeys.push_back(voutPubkey1); - if (voutPubkey2.IsValid()) - voutPubkeys.push_back(voutPubkey2); - - tokenid = revuint256(tokenid); - return(funcId); - } - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format, isEof=" << isEof << " ccType=" << ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); - return (uint8_t)0; - - default: - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl); - return (uint8_t)0; - } - } - else { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() empty opret, could not parse" << std::endl); - } - return (uint8_t)0; -} // tx validation bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn) @@ -233,7 +49,8 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & CTxDestination address; CTransaction vinTx, createTx; uint256 hashBlock, tokenid, tokenid2; int32_t i, starti, numvins, numvouts, preventCCvins, preventCCvouts; int64_t remaining_price, nValue, tokenoshis, outputs, inputs, tmpprice, totalunits, ignore; - std::vector vopretExtra, tmporigpubkey, ignorepubkey; + std::vector> oprets; + vscript_t /*vopretExtra,*/ tmporigpubkey, ignorepubkey; uint8_t funcid, evalCodeInOpret; char destaddr[64], origaddr[64], CCaddr[64]; std::vector voutTokenPubkeys, vinTokenPubkeys; @@ -250,7 +67,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & if (numvouts < 1) return eval->Invalid("no vouts"); - if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, oprets)) == 0) return eval->Invalid("TokenValidate: invalid opreturn payload"); LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << std::hex << (int)cp->evalcode << std::endl); @@ -272,11 +89,11 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & } // validate spending from token cc addr: allowed only for burned non-fungible tokens: - if (ExtractTokensVinPubkeys(tx, vinTokenPubkeys) && std::find(vinTokenPubkeys.begin(), vinTokenPubkeys.end(), GetUnspendable(cp, NULL)) != vinTokenPubkeys.end()) { + if (ExtractTokensCCVinPubkeys(tx, vinTokenPubkeys) && std::find(vinTokenPubkeys.begin(), vinTokenPubkeys.end(), GetUnspendable(cp, NULL)) != vinTokenPubkeys.end()) { // validate spending from token unspendable cc addr: int64_t burnedAmount = HasBurnedTokensvouts(cp, eval, tx, tokenid); if (burnedAmount > 0) { - std::vector vopretNonfungible; + vscript_t vopretNonfungible; GetNonfungibleData(tokenid, vopretNonfungible); if( vopretNonfungible.empty() ) return eval->Invalid("spending cc marker not supported for fungible tokens"); @@ -331,13 +148,14 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction & // helper funcs: // extract cc token vins' pubkeys: -bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys) { +bool ExtractTokensCCVinPubkeys(const CTransaction &tx, std::vector &vinPubkeys) { bool found = false; CPubKey pubkey; struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); + vinPubkeys.clear(); for (int32_t i = 0; i < tx.vin.size(); i++) { @@ -384,7 +202,7 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { uint8_t funcid; uint8_t dummyEvalCode; std::vector voutPubkeysDummy; - std::vector vopretExtraDummy; + std::vector> opretsDummy; // this is just for log messages indentation fur debugging recursive calls: std::string indentStr = std::string().append(tokenValIndentSize, '.'); @@ -392,7 +210,7 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { if (tx.vout.size() == 0) return (uint8_t)0; - if ((funcid = DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenidOpret, voutPubkeysDummy, vopretExtraDummy)) == 0) + if ((funcid = DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenidOpret, voutPubkeysDummy, opretsDummy)) == 0) { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "ValidateTokenOpret() DecodeTokenOpret could not parse opret for txid=" << tx.GetHash().GetHex() << std::endl); return (uint8_t)0; @@ -400,13 +218,23 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { else if (funcid == 'c') { if (tokenid != zeroid && tokenid == tx.GetHash()) { - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); return funcid; } else { LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my tokenbase txid=" << tx.GetHash().GetHex() << std::endl); } } + else if (funcid == 'i') + { + if (tokenid != zeroid && tokenid == tx.GetHash()) { + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() this is import 'i' tx, txid=" << tx.GetHash().GetHex() << " returning true" << std::endl); + return funcid; + } + else { + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << indentStr << "ValidateTokenOpret() not my import txid=" << tx.GetHash().GetHex() << std::endl); + } + } else if (funcid == 't') { //std::cerr << indentStr << "ValidateTokenOpret() tokenid=" << tokenid.GetHex() << " tokenIdOpret=" << tokenidOpret.GetHex() << " txid=" << tx.GetHash().GetHex() << std::endl; @@ -425,17 +253,31 @@ uint8_t ValidateTokenOpret(CTransaction tx, uint256 tokenid) { } // remove token->unspendablePk (it is only for marker usage) -std::vector FilterOutTokensUnspendablePk(std::vector sourcePubkeys) { +void FilterOutTokensUnspendablePk(const std::vector &sourcePubkeys, std::vector &destPubkeys) { struct CCcontract_info *cpTokens, tokensC; cpTokens = CCinit(&tokensC, EVAL_TOKENS); CPubKey tokensUnspendablePk = GetUnspendable(cpTokens, NULL); - std::vector destPubkeys; + destPubkeys.clear(); for (auto pk : sourcePubkeys) if (pk != tokensUnspendablePk) destPubkeys.push_back(pk); - return destPubkeys; +} + +void FilterOutBurnOpret(const std::vector> &oprets, vscript_t vopret) { + + vopret.clear(); + + if (oprets.size() > 2) + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "FilterOutBurnOpret() oprets.size > 2 currently not supported" << oprets.size() << std::endl); + + for (auto o : oprets) { + if (o.first != EVAL_IMPORTCOIN) { // skip burn opret + vopret = o.second; // return first contract opret (more than 1 is not supported yet) + break; + } + } } // Checks if the vout is a really Tokens CC vout @@ -488,7 +330,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true uint8_t dummyEvalCode; uint256 tokenIdOpret; std::vector voutPubkeys, voutPubkeysInOpret; - std::vector vopretExtra, vopretNonfungible; + vscript_t vopretExtra, vopretNonfungible; + std::vector> oprets; uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim uint8_t evalCode2 = 0; // will be checked if zero or not @@ -496,12 +339,16 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true // test vouts for possible token use-cases: std::vector> testVouts; - DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeysInOpret, vopretExtra); + DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeysInOpret, oprets); + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() oprets.size()=" << oprets.size() << std::endl); + + // get assets/channels/gateways token data: + FilterOutBurnOpret(oprets, vopretExtra); // NOTE: only 1 additional evalcode in token opret is currently supported LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl); + // get non-fungible data GetNonfungibleData(reftokenid, vopretNonfungible); - - voutPubkeys = FilterOutTokensUnspendablePk(voutPubkeysInOpret); // cannot send tokens to token unspendable cc addr (only marker is allowed there) + FilterOutTokensUnspendablePk(voutPubkeysInOpret, voutPubkeys); // cannot send tokens to token unspendable cc addr (only marker is allowed there) // NOTE: evalcode order in vouts is important: // non-fungible-eval -> EVAL_TOKENS -> assets-eval @@ -512,7 +359,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true evalCode2 = vopretExtra.begin()[0]; if (evalCode == EVAL_TOKENS && evalCode2 != 0) { - evalCode = evalCode2; + evalCode = evalCode2; // for using MakeTokensCC1vout(evalcode,...) instead of MakeCC1vout(EVAL_TOKENS, evalcode...) evalCode2 = 0; } @@ -562,8 +409,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true // maybe it is single-eval or dual/three-eval token change? std::vector vinPubkeys, vinPubkeysUnfiltered; - ExtractTokensVinPubkeys(tx, vinPubkeysUnfiltered); - vinPubkeys = FilterOutTokensUnspendablePk(vinPubkeysUnfiltered); // cannot send tokens to token unspendable cc addr (only marker is allowed there) + ExtractTokensCCVinPubkeys(tx, vinPubkeysUnfiltered); + FilterOutTokensUnspendablePk(vinPubkeysUnfiltered, vinPubkeys); // cannot send tokens to token unspendable cc addr (only marker is allowed there) for(std::vector::iterator it = vinPubkeys.begin(); it != vinPubkeys.end(); it++) { testVouts.push_back(std::make_pair(MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, *it), std::string("single-eval cc1 self vin pk"))); @@ -577,11 +424,11 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true } else { CPubKey origPubkey; - std::vector vorigPubkey; + vscript_t vorigPubkey; std::string dummyName, dummyDescription; - std::vector vopret1; + std::vector> oprets; - if (DecodeTokenCreateOpRet(tx.vout.back().scriptPubKey, vorigPubkey, dummyName, dummyDescription, vopret1) == 0) { + if (DecodeTokenCreateOpRet(tx.vout.back().scriptPubKey, vorigPubkey, dummyName, dummyDescription, oprets) == 0) { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << indentStr << "IsTokensvout() could not decode create opret" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl); return 0; } @@ -689,7 +536,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu // get non-fungible data from 'tokenbase' tx (the data might be empty) -void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible) +void GetNonfungibleData(uint256 tokenid, vscript_t &vopretNonfungible) { CTransaction tokenbasetx; uint256 hashBlock; @@ -704,22 +551,24 @@ void GetNonfungibleData(uint256 tokenid, std::vector &vopretNonfungible if (tokenbasetx.vout.size() > 0) { std::vector origpubkey; std::string name, description; - std::vector vopretExtra; - if (DecodeTokenCreateOpRet(tokenbasetx.vout.back().scriptPubKey, origpubkey, name, description, vopretExtra) == 'c') - vopretNonfungible = vopretExtra; + std::vector> oprets; + + if (DecodeTokenCreateOpRet(tokenbasetx.vout.back().scriptPubKey, origpubkey, name, description, oprets) == 'c') { + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); + } } } // overload, adds inputs from token cc addr int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) { - std::vector vopretNonfungibleDummy; + vscript_t vopretNonfungibleDummy; return AddTokenCCInputs(cp, mtx, pk, tokenid, total, maxinputs, vopretNonfungibleDummy); } // adds inputs from token cc addr and returns non-fungible opret payload if present // also sets evalcode in cp, if needed -int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs, std::vector &vopretNonfungible) +int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs, vscript_t &vopretNonfungible) { char tokenaddr[64], destaddr[64]; int64_t threshold, nValue, price, totalinputs = 0; @@ -771,7 +620,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C { //for non-fungible tokens check payload: if (!vopretNonfungible.empty()) { - std::vector vopret; + vscript_t vopret; // check if it is non-fungible token: GetNonfungibleData(tokenid, vopret); @@ -807,7 +656,8 @@ int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTran uint8_t dummyEvalCode; uint256 tokenIdOpret; std::vector voutPubkeys, voutPubkeysDummy; - std::vector vopretExtra, vopretNonfungible; + std::vector> oprets; + vscript_t vopretExtra, vopretNonfungible; uint8_t evalCode = EVAL_TOKENS; // if both payloads are empty maybe it is a transfer to non-payload-one-eval-token vout like GatewaysClaim uint8_t evalCode2 = 0; // will be checked if zero or not @@ -823,11 +673,14 @@ int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTran } - if (DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeysDummy, vopretExtra) == 0) { + if (DecodeTokenOpRet(tx.vout.back().scriptPubKey, dummyEvalCode, tokenIdOpret, voutPubkeysDummy, oprets) == 0) { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "HasBurnedTokensvouts() cannot parse opret DecodeTokenOpRet returned 0, txid=" << tx.GetHash().GetHex() << std::endl); return 0; } + // get assets/channels/gateways token data: + FilterOutBurnOpret(oprets, vopretExtra); // NOTE: only 1 additional evalcode in token opret is currently supported + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "HasBurnedTokensvouts() vopretExtra=" << HexStr(vopretExtra) << std::endl); GetNonfungibleData(reftokenid, vopretNonfungible); @@ -874,18 +727,40 @@ int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTran return burnedAmount; } -std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, std::string description, std::vector nonfungibleData) +CPubKey GetTokenOriginatorPubKey(CScript scriptPubKey) { + + uint8_t funcId, evalCode; + uint256 tokenid; + std::vector voutTokenPubkeys; + std::vector> oprets; + + if ((funcId = DecodeTokenOpRet(scriptPubKey, evalCode, tokenid, voutTokenPubkeys, oprets)) != 0) { + CTransaction tokenbasetx; + uint256 hashBlock; + + if (myGetTransaction(tokenid, tokenbasetx, hashBlock) && tokenbasetx.vout.size() > 0) { + vscript_t vorigpubkey; + std::string name, desc; + if (DecodeTokenCreateOpRet(tokenbasetx.vout.back().scriptPubKey, vorigpubkey, name, desc) != 0) + return pubkey2pk(vorigpubkey); + } + } + return CPubKey(); //return invalid pubkey +} + + +std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, std::string description, vscript_t nonfungibleData) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; struct CCcontract_info *cp, C; - if (tokensupply < 0) - { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "CreateToken() negative tokensupply=" << tokensupply << std::endl); + if (tokensupply < 0) { + CCerror = "negative tokensupply"; + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "CreateToken() =" << CCerror << "=" << tokensupply << std::endl); return std::string(""); } if (!nonfungibleData.empty() && tokensupply != 1) { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "CreateToken() for non-fungible tokens tokensupply should be equal to 1" << std::endl); CCerror = "for non-fungible tokens tokensupply should be equal to 1"; + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "CreateToken() " << CCerror << std::endl); return std::string(""); } @@ -893,8 +768,8 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st cp = CCinit(&C, EVAL_TOKENS); if (name.size() > 32 || description.size() > 4096) // this is also checked on rpc level { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "name of=" << name.size() << " or description of=" << description.size() << " is too big" << std::endl); - CCerror = "name should be < 32, description should be < 4096"; + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "name len=" << name.size() << " or description len=" << description.size() << " is too big" << std::endl); + CCerror = "name should be <= 32, description should be <= 4096"; return(""); } if (txfee == 0) @@ -916,21 +791,22 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "cant find normal inputs" << std::endl); CCerror = "cant find normal inputs"; + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "CreateToken() " << CCerror << std::endl); return std::string(""); } // transfer tokens to another pubkey // param additionalEvalCode allows transfer of dual-eval non-fungible tokens -std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector destpubkey, int64_t total) +std::string TokenTransfer(int64_t txfee, uint256 tokenid, vscript_t destpubkey, int64_t total) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk; uint64_t mask; int64_t CCchange = 0, inputs = 0; struct CCcontract_info *cp, C; - std::vector vopretNonfungible; + vscript_t vopretNonfungible, vopretEmpty; if (total < 0) { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "negative total=" << total << std::endl); + CCerror = strprintf("negative total"); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << CCerror << "=" << total << std::endl); return(""); } @@ -946,8 +822,8 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d if ((inputs = AddTokenCCInputs(cp, mtx, mypk, tokenid, total, 60, vopretNonfungible)) > 0) // NOTE: AddTokenCCInputs might set cp->additionalEvalCode which is used in FinalizeCCtx! { if (inputs < total) { //added dimxy - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenTransfer(): insufficient token funds" << std::endl); CCerror = strprintf("insufficient token inputs"); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenTransfer() " << CCerror << std::endl); return std::string(""); } @@ -964,17 +840,17 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, std::vector d std::vector voutTokenPubkeys; voutTokenPubkeys.push_back(pubkey2pk(destpubkey)); // dest pubkey for validating vout - return(FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutTokenPubkeys, CScript()))); + return FinalizeCCTx(mask, cp, mtx, mypk, txfee, EncodeTokenOpRet(tokenid, voutTokenPubkeys, std::make_pair((uint8_t)0, vopretEmpty))); } else { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "not enough CC token inputs for amount=" << total << std::endl); CCerror = strprintf("no token inputs"); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenTransfer() " << CCerror << total << std::endl); } //} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size()); } else { - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "not enough normal inputs for txfee" << std::endl); - CCerror = strprintf("insufficient normal inputs"); + CCerror = strprintf("insufficient normal inputs for tx fee"); + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenTransfer() " << CCerror << std::endl); } return(""); } @@ -1007,7 +883,8 @@ UniValue TokenInfo(uint256 tokenid) uint256 hashBlock; CTransaction vintx; std::vector origpubkey; - std::vector vopretNonfungible; + std::vector> oprets; + vscript_t vopretNonfungible; std::string name, description; struct CCcontract_info *cpTokens, tokensCCinfo; @@ -1020,7 +897,7 @@ UniValue TokenInfo(uint256 tokenid) result.push_back(Pair("error", "cant find tokenid")); return(result); } - if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description, vopretNonfungible) == 0) + if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description, oprets) != 'c') { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); result.push_back(Pair("result", "error")); @@ -1038,6 +915,8 @@ UniValue TokenInfo(uint256 tokenid) supply += output; result.push_back(Pair("supply", supply)); result.push_back(Pair("description", description)); + + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); if( !vopretNonfungible.empty() ) result.push_back(Pair("data", HexStr(vopretNonfungible))); diff --git a/src/cc/CCtokens.h b/src/cc/CCtokens.h index 791107648..f63c563a9 100644 --- a/src/cc/CCtokens.h +++ b/src/cc/CCtokens.h @@ -30,8 +30,8 @@ bool TokensValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); std::string CreateToken(int64_t txfee, int64_t assetsupply, std::string name, std::string description, std::vector nonfungibleData); std::string TokenTransfer(int64_t txfee, uint256 assetid, std::vector destpubkey, int64_t total); -bool ExtractTokensVinPubkeys(CTransaction tx, std::vector &vinPubkeys); int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, uint256 reftokenid); +CPubKey GetTokenOriginatorPubKey(CScript scriptPubKey); int64_t GetTokenBalance(CPubKey pk, uint256 tokenid); UniValue TokenInfo(uint256 tokenid); diff --git a/src/cc/CCtokensOpRet.cpp b/src/cc/CCtokensOpRet.cpp new file mode 100644 index 000000000..31ece4d78 --- /dev/null +++ b/src/cc/CCtokensOpRet.cpp @@ -0,0 +1,265 @@ +// encode decode tokens opret +// (moved to a separate file to enable linking lib common.so with importcoin.cpp) + +#include "CCtokens.h" + +// NOTE: this inital tx won't be used by other contract +// for tokens to be used there should be at least one 't' tx with other contract's custom opret +CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, vscript_t vopretNonfungible) +{ + /* CScript opret; + uint8_t evalcode = EVAL_TOKENS; + funcid = 'c'; // override the param + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description; \ + if (!vopretNonfungible.empty()) { + ss << (uint8_t)OPRETID_NONFUNGIBLEDATA; + ss << vopretNonfungible; + }); */ + + std::vector> oprets; + + oprets.push_back(std::make_pair(OPRETID_NONFUNGIBLEDATA, vopretNonfungible)); + return EncodeTokenCreateOpRet(funcid, origpubkey, name, description, oprets); +} + +CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector> oprets) +{ + CScript opret; + uint8_t evalcode = EVAL_TOKENS; + funcid = 'c'; // override the param + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description; + for (auto o : oprets) { + if (o.first != 0) { + ss << (uint8_t)o.first; + ss << o.second; + } + }); + return(opret); +} + +// opret 'i' for imported tokens +CScript EncodeTokenImportOpRet(std::vector origpubkey, std::string name, std::string description, uint256 srctokenid, std::vector> oprets) +{ + CScript opret; + uint8_t evalcode = EVAL_TOKENS; + uint8_t funcid = 'i'; + + srctokenid = revuint256(srctokenid); // do not forget this + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << origpubkey << name << description << srctokenid; + for (auto o : oprets) { + if (o.first != 0) { + ss << (uint8_t)o.first; + ss << o.second; + } + }); + return(opret); +} + + + +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::pair opretWithId) +{ + std::vector> oprets; + oprets.push_back(opretWithId); + return EncodeTokenOpRet(tokenid, voutPubkeys, oprets); +} + +CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector> oprets) +{ + CScript opret; + uint8_t tokenFuncId = 't'; + uint8_t evalCodeInOpret = EVAL_TOKENS; + + tokenid = revuint256(tokenid); + + uint8_t ccType = 0; + if (voutPubkeys.size() >= 0 && voutPubkeys.size() <= 2) + ccType = voutPubkeys.size(); + else { + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "EncodeTokenOpRet voutPubkeys.size()=" << voutPubkeys.size() << " not supported" << std::endl); + } + + //vopret_t vpayload; + //GetOpReturnData(payload, vpayload); + + opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; + if (ccType >= 1) ss << voutPubkeys[0]; + if (ccType == 2) ss << voutPubkeys[1]; + for (auto o : oprets) { + if (o.first != 0) { + ss << (uint8_t)o.first; + ss << o.second; + } + }); + + // bad opret cases (tries to attach payload without re-serialization): + + // error "64: scriptpubkey": + // if (payload.size() > 0) + // opret += payload; + + // error "64: scriptpubkey": + // CScript opretPayloadNoOpcode(vpayload); + // return opret + opretPayloadNoOpcode; + + // error "sig_aborted": + // opret.resize(opret.size() + vpayload.size()); + // CScript::iterator it = opret.begin() + opret.size(); + // for (int i = 0; i < vpayload.size(); i++, it++) + // *it = vpayload[i]; + + return opret; +} + +// overload for compatibility +//CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector voutPubkeys, CScript payload) +//{ +// return EncodeTokenOpRet(tokenid, voutPubkeys, payload); +//} + +// overload for fungible tokens (no additional data in opret): +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description) { + //vopret_t vopretNonfungibleDummy; + std::vector> opretsDummy; + return DecodeTokenCreateOpRet(scriptPubKey, origpubkey, name, description, opretsDummy); +} + +uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector> &oprets) +{ + vscript_t vopret, vblob; + uint8_t dummyEvalcode, funcid, opretId = 0; + + GetOpReturnData(scriptPubKey, vopret); + oprets.clear(); + + if (vopret.size() > 2 && vopret.begin()[0] == EVAL_TOKENS && vopret.begin()[1] == 'c') + { + if (E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description; + while (!ss.eof()) { + ss >> opretId; + if (!ss.eof()) { + ss >> vblob; + oprets.push_back(std::make_pair(opretId, vblob)); + } + })) + { + return(funcid); + } + } + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenCreateOpRet() incorrect token create opret" << std::endl); + return (uint8_t)0; +} + +// for imported tokens +uint8_t DecodeTokenImportOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, uint256 &srctokenid, std::vector> &oprets) +{ + vscript_t vopret, vblob; + uint8_t dummyEvalcode, funcid, opretId = 0; + + GetOpReturnData(scriptPubKey, vopret); + oprets.clear(); + + if (vopret.size() > 2 && vopret.begin()[0] == EVAL_TOKENS && vopret.begin()[1] == 'i') + { + if (E_UNMARSHAL(vopret, ss >> dummyEvalcode; ss >> funcid; ss >> origpubkey; ss >> name; ss >> description; ss >> srctokenid; + while (!ss.eof()) { + ss >> opretId; + if (!ss.eof()) { + ss >> vblob; + oprets.push_back(std::make_pair(opretId, vblob)); + } + })) + { + srctokenid = revuint256(srctokenid); // do not forget this + return(funcid); + } + } + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenImportOpRet() incorrect token import opret" << std::endl); + return (uint8_t)0; +} + +// decodes token opret: +// for 't' returns all data from opret, vopretExtra contains other contract's data (currently only assets'). +// for 'c' and 'i' returns only funcid. NOTE: nonfungible data is not returned +uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector> &oprets) +{ + vscript_t vopret, vblob, dummyPubkey, vnonfungibleDummy; + uint8_t funcId = 0, *script, dummyEvalCode, dummyFuncId, ccType, opretId = 0; + std::string dummyName; std::string dummyDescription; + uint256 dummySrcTokenId; + CPubKey voutPubkey1, voutPubkey2; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + tokenid = zeroid; + oprets.clear(); + + if (script != NULL && vopret.size() > 2) + { + // NOTE: if parse error occures, parse might not be able to set error. It is safer to treat that it was eof if it is not set! + // bool isEof = true; + + evalCodeTokens = script[0]; + if (evalCodeTokens != EVAL_TOKENS) { + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect evalcode in tokens opret" << std::endl); + return (uint8_t)0; + } + + funcId = script[1]; + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "DecodeTokenOpRet decoded funcId=" << (char)(funcId ? funcId : ' ') << std::endl); + + switch (funcId) + { + case 'c': + return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription, oprets); + case 'i': + return DecodeTokenImportOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription, dummySrcTokenId, oprets); + //break; + case 't': + //not used yet: case 'l': + // NOTE: 'E_UNMARSHAL result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' + if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; + if (ccType >= 1) ss >> voutPubkey1; + if (ccType == 2) ss >> voutPubkey2; + while (!ss.eof()) { + ss >> opretId; + if (!ss.eof()) { + ss >> vblob; + oprets.push_back(std::make_pair(opretId, vblob)); + } + })) + { + if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); + return (uint8_t)0; + } + + // add verification pubkeys: + voutPubkeys.clear(); + if (voutPubkey1.IsValid()) + voutPubkeys.push_back(voutPubkey1); + if (voutPubkey2.IsValid()) + voutPubkeys.push_back(voutPubkey2); + + tokenid = revuint256(tokenid); + return(funcId); + } + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format," << " ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); + return (uint8_t)0; + + default: + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() illegal funcid=" << (int)funcId << std::endl); + return (uint8_t)0; + } + } + else { + LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() empty opret, could not parse" << std::endl); + } + return (uint8_t)0; +} + + + diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 0f7e103f9..52346ed2d 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -420,7 +420,8 @@ int64_t CCtoken_balance(char *coinaddr,uint256 reftokenid) { char str[65]; std::vector voutTokenPubkeys; - if ( reftokenid==txid || (DecodeTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCode, tokenid, voutTokenPubkeys, vopretExtra) != 0 && reftokenid == tokenid)) + std::vector> oprets; + if ( reftokenid==txid || (DecodeTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCode, tokenid, voutTokenPubkeys, oprets) != 0 && reftokenid == tokenid)) { sum += it->second.satoshis; } diff --git a/src/cc/CCutilbits.cpp b/src/cc/CCutilbits.cpp new file mode 100644 index 000000000..d50fb971c --- /dev/null +++ b/src/cc/CCutilbits.cpp @@ -0,0 +1,105 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +/* + CCutilbits.cpp has very low level functions that are universally useful for all contracts and have low dependency from other sources + */ + +#include "CCinclude.h" +#include "komodo_structs.h" + +int32_t unstringbits(char *buf,uint64_t bits) +{ + int32_t i; + for (i=0; i<8; i++,bits>>=8) + if ( (buf[i]= (char)(bits & 0xff)) == 0 ) + break; + buf[i] = 0; + return(i); +} + +uint64_t stringbits(char *str) +{ + uint64_t bits = 0; + if ( str == 0 ) + return(0); + int32_t i,n = (int32_t)strlen(str); + if ( n > 8 ) + n = 8; + for (i=n-1; i>=0; i--) + bits = (bits << 8) | (str[i] & 0xff); + //printf("(%s) -> %llx %llu\n",str,(long long)bits,(long long)bits); + return(bits); +} + +uint256 revuint256(uint256 txid) +{ + uint256 revtxid; int32_t i; + for (i=31; i>=0; i--) + ((uint8_t *)&revtxid)[31-i] = ((uint8_t *)&txid)[i]; + return(revtxid); +} + +char *uint256_str(char *dest,uint256 txid) +{ + int32_t i,j=0; + for (i=31; i>=0; i--) + sprintf(&dest[j++ * 2],"%02x",((uint8_t *)&txid)[i]); + dest[64] = 0; + return(dest); +} + +char *pubkey33_str(char *dest,uint8_t *pubkey33) +{ + int32_t i; + if ( pubkey33 != 0 ) + { + for (i=0; i<33; i++) + sprintf(&dest[i * 2],"%02x",pubkey33[i]); + } else dest[0] = 0; + return(dest); +} + +uint256 Parseuint256(const char *hexstr) +{ + uint256 txid; int32_t i; std::vector txidbytes(ParseHex(hexstr)); + memset(&txid,0,sizeof(txid)); + if ( strlen(hexstr) == 64 ) + { + for (i=31; i>=0; i--) + ((uint8_t *)&txid)[31-i] = ((uint8_t *)txidbytes.data())[i]; + } + return(txid); +} + +CPubKey buf2pk(uint8_t *buf33) +{ + CPubKey pk; int32_t i; uint8_t *dest; + dest = (uint8_t *)pk.begin(); + for (i=0; i<33; i++) + dest[i] = buf33[i]; + return(pk); +} + +CPubKey pubkey2pk(std::vector pubkey) +{ + CPubKey pk; int32_t i,n; uint8_t *dest,*pubkey33; + n = pubkey.size(); + dest = (uint8_t *)pk.begin(); + pubkey33 = (uint8_t *)pubkey.data(); + for (i=0; i>=8) - if ( (buf[i]= (char)(bits & 0xff)) == 0 ) - break; - buf[i] = 0; - return(i); -} - -uint64_t stringbits(char *str) -{ - uint64_t bits = 0; - if ( str == 0 ) - return(0); - int32_t i,n = (int32_t)strlen(str); - if ( n > 8 ) - n = 8; - for (i=n-1; i>=0; i--) - bits = (bits << 8) | (str[i] & 0xff); - //printf("(%s) -> %llx %llu\n",str,(long long)bits,(long long)bits); - return(bits); -} - -uint256 revuint256(uint256 txid) -{ - uint256 revtxid; int32_t i; - for (i=31; i>=0; i--) - ((uint8_t *)&revtxid)[31-i] = ((uint8_t *)&txid)[i]; - return(revtxid); -} - -char *uint256_str(char *dest,uint256 txid) -{ - int32_t i,j=0; - for (i=31; i>=0; i--) - sprintf(&dest[j++ * 2],"%02x",((uint8_t *)&txid)[i]); - dest[64] = 0; - return(dest); -} - -char *pubkey33_str(char *dest,uint8_t *pubkey33) -{ - int32_t i; - if ( pubkey33 != 0 ) - { - for (i=0; i<33; i++) - sprintf(&dest[i * 2],"%02x",pubkey33[i]); - } else dest[0] = 0; - return(dest); -} - -uint256 Parseuint256(char *hexstr) -{ - uint256 txid; int32_t i; std::vector txidbytes(ParseHex(hexstr)); - memset(&txid,0,sizeof(txid)); - if ( strlen(hexstr) == 64 ) - { - for (i=31; i>=0; i--) - ((uint8_t *)&txid)[31-i] = ((uint8_t *)txidbytes.data())[i]; - } - return(txid); -} - -CPubKey buf2pk(uint8_t *buf33) -{ - CPubKey pk; int32_t i; uint8_t *dest; - dest = (uint8_t *)pk.begin(); - for (i=0; i<33; i++) - dest[i] = buf33[i]; - return(pk); -} - -CPubKey pubkey2pk(std::vector pubkey) -{ - CPubKey pk; int32_t i,n; uint8_t *dest,*pubkey33; - n = pubkey.size(); - dest = (uint8_t *)pk.begin(); - pubkey33 = (uint8_t *)pubkey.data(); - for (i=0; i pks; pks.push_back(srcpub); pks.push_back(destpub); - return(EncodeTokenOpRet(tokenid,pks,opret)); + return(EncodeTokenOpRet(tokenid,pks, std::make_pair(OPRETID_CHANNELSDATA, vopret))); } + opret << OP_RETURN << vopret; return(opret); } uint8_t DecodeChannelsOpRet(const CScript &scriptPubKey, uint256 &tokenid, uint256 &opentxid, CPubKey &srcpub,CPubKey &destpub,int32_t &numpayments,int64_t &payment,uint256 &hashchain) { + std::vector> oprets; std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; - if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,oprets)!=0 && GetOpretBlob(oprets, OPRETID_CHANNELSDATA, vOpretExtra) && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { vopret=vOpretExtra; } diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index fd18a69b9..35d7e0cd1 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -157,19 +157,21 @@ CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin, { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; std::vector pubkeys; + vscript_t vopret; cp = CCinit(&C,EVAL_GATEWAYS); gatewayspk = GetUnspendable(cp,0); pubkeys.push_back(gatewayspk); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << totalsupply << oracletxid << M << N << gatewaypubkeys << taddr << prefix << prefix2 << wiftype); - return(EncodeTokenOpRet(tokenid,pubkeys,opret)); + vopret = E_MARSHAL(ss << evalcode << funcid << coin << totalsupply << oracletxid << M << N << gatewaypubkeys << taddr << prefix << prefix2 << wiftype); + return(EncodeTokenOpRet(tokenid,pubkeys, std::make_pair(OPRETID_GATEWAYSDATA, vopret))); } uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t wiftype) { + std::vector> oprets; std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; - if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,oprets)!=0 && GetOpretBlob(oprets, OPRETID_GATEWAYSDATA, vOpretExtra) && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { vopret=vOpretExtra; } @@ -221,17 +223,19 @@ CScript EncodeGatewaysClaimOpRet(uint8_t funcid,uint256 tokenid,uint256 bindtxid { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; std::vector pubkeys; + vscript_t vopret; pubkeys.push_back(destpub); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << bindtxid << refcoin << deposittxid << destpub << amount); - return(EncodeTokenOpRet(tokenid,pubkeys,opret)); + vopret = /*<< OP_RETURN <<*/ E_MARSHAL(ss << evalcode << funcid << bindtxid << refcoin << deposittxid << destpub << amount); + return(EncodeTokenOpRet(tokenid,pubkeys, make_pair(OPRETID_GATEWAYSDATA, vopret))); } uint8_t DecodeGatewaysClaimOpRet(const CScript &scriptPubKey,uint256 &tokenid,uint256 &bindtxid,std::string &refcoin,uint256 &deposittxid,CPubKey &destpub,int64_t &amount) { + std::vector> oprets; std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; - if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys, oprets)!=0 && GetOpretBlob(oprets, OPRETID_GATEWAYSDATA, vOpretExtra) && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { vopret=vOpretExtra; } @@ -248,19 +252,21 @@ CScript EncodeGatewaysWithdrawOpRet(uint8_t funcid,uint256 tokenid,uint256 bindt { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; struct CCcontract_info *cp,C; CPubKey gatewayspk; std::vector pubkeys; + vscript_t vopret; cp = CCinit(&C,EVAL_GATEWAYS); gatewayspk = GetUnspendable(cp,0); pubkeys.push_back(gatewayspk); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << bindtxid << refcoin << withdrawpub << amount); - return(EncodeTokenOpRet(tokenid,pubkeys,opret)); + vopret = /*opret << OP_RETURN << */ E_MARSHAL(ss << evalcode << funcid << bindtxid << refcoin << withdrawpub << amount); + return(EncodeTokenOpRet(tokenid,pubkeys, std::make_pair(OPRETID_GATEWAYSDATA, vopret))); } uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256& tokenid, uint256 &bindtxid, std::string &refcoin, CPubKey &withdrawpub, int64_t &amount) { + std::vector> oprets; std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; - if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys, oprets)!=0 && GetOpretBlob(oprets, OPRETID_GATEWAYSDATA, vOpretExtra) && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { vopret=vOpretExtra; } @@ -336,9 +342,10 @@ uint8_t DecodeGatewaysMarkDoneOpRet(const CScript &scriptPubKey, uint256 &withdr uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey) { + std::vector> oprets; std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; uint256 tokenid; - if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys, oprets)!=0 && GetOpretBlob(oprets, OPRETID_GATEWAYSDATA, vOpretExtra) && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) { vopret=vOpretExtra; } @@ -956,7 +963,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t prefix2 = p2; wiftype = p3; taddr = p4; - LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d, taddr %d for %s\n",prefix,prefix2,wiftype,taddr,coin.c_str()); + LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d for %s\n",prefix,prefix2,wiftype,coin.c_str()); } if ( N == 0 || N > 15 || M > N ) { @@ -1815,7 +1822,7 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key) priv=EncodeCustomSecret(key,wiftype); result.push_back(Pair("result","success")); - result.push_back(Pair("privkey",priv.c_str())); + result.push_back(Pair("address",priv.c_str())); return(result); } diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index aca30208b..9cb0f03bd 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -255,25 +255,25 @@ template int64_t IsHeirFundingVout(struct CCcontract_info* cp, co } // makes coin initial tx opret -CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo) +vscript_t EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo) { uint8_t evalcode = EVAL_HEIR; - return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName << memo); + return /*CScript() << OP_RETURN <<*/ E_MARSHAL(ss << evalcode << funcid << ownerPubkey << heirPubkey << inactivityTimeSec << heirName << memo); } // makes coin additional tx opret -CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpendingBegun) +vscript_t EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t hasHeirSpendingBegun) { uint8_t evalcode = EVAL_HEIR; fundingtxid = revuint256(fundingtxid); - return CScript() << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); + return /*CScript() << OP_RETURN <<*/ E_MARSHAL(ss << evalcode << funcid << fundingtxid << hasHeirSpendingBegun); } // decode opret vout for Heir contract -uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) +uint8_t _DecodeHeirOpRet(vscript_t vopret, CPubKey& ownerPubkey, CPubKey& heirPubkey, int64_t& inactivityTime, std::string& heirName, std::string& memo, uint256& fundingTxidInOpret, uint8_t &hasHeirSpendingBegun, bool noLogging) { uint8_t evalCodeInOpret = 0; uint8_t heirFuncId = 0; @@ -287,13 +287,13 @@ uint8_t _DecodeHeirOpRet(std::vector vopret, CPubKey& ownerPubkey, CPub uint8_t heirFuncId = 0; hasHeirSpendingBegun = 0; - bool result = E_UNMARSHAL(vopret, { ss >> evalCodeInOpret; ss >> heirFuncId; \ - if (heirFuncId == 'F') { \ - ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; ss >> memo; \ - } \ - else { \ - ss >> fundingTxidInOpret >> hasHeirSpendingBegun; \ - } \ + bool result = E_UNMARSHAL(vopret, { ss >> evalCodeInOpret; ss >> heirFuncId; + if (heirFuncId == 'F') { + ss >> ownerPubkey; ss >> heirPubkey; ss >> inactivityTime; ss >> heirName; ss >> memo; + } + else { + ss >> fundingTxidInOpret >> hasHeirSpendingBegun; + } }); if (!result) { @@ -327,9 +327,11 @@ uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey& { uint8_t evalCodeTokens = 0; std::vector voutPubkeysDummy; - std::vector vopretExtra /*, vopretStripped*/; + std::vector> oprets; + vscript_t vopretExtra /*, vopretStripped*/; - if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) { + + if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, oprets) != 0 && GetOpretBlob(oprets, OPRETID_HEIRDATA, vopretExtra)) { /* if (vopretExtra.size() > 1) { // restore the second opret: diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 890e2b710..a27dc3340 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -7,8 +7,8 @@ #define IS_CHARINSTR(c, str) (std::string(str).find((char)(c)) != std::string::npos) // makes coin initial tx opret -CScript EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo); -CScript EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan); +vscript_t EncodeHeirCreateOpRet(uint8_t funcid, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo); +vscript_t EncodeHeirOpRet(uint8_t funcid, uint256 fundingtxid, uint8_t isHeirSpendingBegan); uint256 FindLatestFundingTx(uint256 fundingtxid, uint256 &tokenid, CScript& opRetScript, uint8_t &isHeirSpendingBegan); //uint8_t DecodeHeirOpRet(CScript scriptPubKey, uint256& fundingtxid, uint8_t &isHeirSpendingBegan, bool noLogging = false); @@ -29,13 +29,13 @@ public: } static CScript makeCreateOpRet(uint256 dummyid, std::vector dummyPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo) { - return EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo); + return CScript() << OP_RETURN << EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo); } static CScript makeAddOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan); + return CScript() << OP_RETURN << EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan); } static CScript makeClaimOpRet(uint256 dummyid, std::vector dummyPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { - return EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan); + return CScript() << OP_RETURN << EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan); } static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { return MakeCC1of2vout(EVAL_HEIR, amount, ownerPubkey, heirPubkey); @@ -71,15 +71,15 @@ public: static CScript makeCreateOpRet(uint256 tokenid, std::vector voutTokenPubkeys, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string heirName, std::string memo) { return EncodeTokenOpRet(tokenid, voutTokenPubkeys, - EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo)); + std::make_pair(OPRETID_HEIRDATA, EncodeHeirCreateOpRet((uint8_t)'F', ownerPubkey, heirPubkey, inactivityTimeSec, heirName, memo))); } static CScript makeAddOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { return EncodeTokenOpRet(tokenid, voutTokenPubkeys, - EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan)); + std::make_pair(OPRETID_HEIRDATA, EncodeHeirOpRet((uint8_t)'A', fundingtxid, isHeirSpendingBegan))); } static CScript makeClaimOpRet(uint256 tokenid, std::vector voutTokenPubkeys, uint256 fundingtxid, uint8_t isHeirSpendingBegan) { return EncodeTokenOpRet(tokenid, voutTokenPubkeys, - EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan)); + std::make_pair(OPRETID_HEIRDATA, EncodeHeirOpRet((uint8_t)'C', fundingtxid, isHeirSpendingBegan))); } static CTxOut make1of2Vout(int64_t amount, CPubKey ownerPubkey, CPubKey heirPubkey) { diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 07f20f833..c53207562 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -334,7 +334,7 @@ std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingt std::vector voutTokenPubkeysEmpty; //TODO: add token vout pubkeys return(FinalizeCCTx(0,cp,mtx,mypk,txfee, EncodeTokenOpRet(bettoken, voutTokenPubkeysEmpty, - EncodeAssetOpRet('t',/*bettoken,*/zeroid, 0, Mypubkey())))); + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('t',/*bettoken,*/zeroid, 0, Mypubkey()))))); } else { diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index aee151530..3ad39194b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -169,16 +169,18 @@ CScript rogue_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CP uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol, std::string &pname,CScript scriptPubKey) { std::string name, description; std::vector vorigPubkey; + std::vector> oprets, opretsDummy; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; uint8_t e, f,*script; std::vector voutPubkeys; tokenid = zeroid; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,vopretNonfungible)) == 'c' ) + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description, oprets)) == 'c' ) { + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretDummy); vopret = vopretNonfungible; } - else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) + else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, opretsDummy)) != 0 ) { //fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx @@ -206,17 +208,20 @@ uint8_t rogue_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey uint8_t rogue_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &playertxid,CScript scriptPubKey) { std::string name, description; std::vector vorigPubkey; + std::vector> oprets; std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; uint8_t e, f,*script; std::vector voutPubkeys; tokenid = zeroid; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,vopretNonfungible)) == 'c' ) + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,oprets)) == 'c' ) { + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); vopret = vopretNonfungible; } - else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, vopretDummy)) != 0 ) + else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, oprets)) != 0 ) { + GetOpretBlob(oprets, OPRETID_ROGUEGAMEDATA, vopretDummy); // blob from non-creation tx opret vopret = vopretDummy; } if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_ROGUE && f == 'R' ) @@ -778,20 +783,23 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr); mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); - std::vector vopretExtra; uint8_t e, funcid; uint256 tid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; + uint8_t e, funcid; uint256 tid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { voutPubkeysEmpty.push_back(burnpk); if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 ) { - if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, vopretExtra)) != 0) + std::vector> oprets; + if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, oprets)) != 0) { // if token in the opret didtx = 1; if ( funcid == 'c' ) tid = tokenid == zeroid ? playertxid : tokenid; + vscript_t vopretRegister; + GetOpReturnData(opretRegister, vopretRegister); rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, - EncodeTokenOpRet(tid, voutPubkeysEmpty /*=never spent*/, opretRegister)); + EncodeTokenOpRet(tid, voutPubkeysEmpty /*=never spent*/, std::make_pair(OPRETID_ROGUEGAMEDATA, vopretRegister))); } } } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index ef1c8bf5c..5e5ed9ce3 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1479,8 +1479,11 @@ UniValue decodeccopret(const UniValue& params, bool fHelp) } std::vector hex(ParseHex(params[0].get_str())); CScript scripthex(hex.begin(),hex.end()); - if (DecodeTokenOpRet(scripthex,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) + std::vector> oprets; + if (DecodeTokenOpRet(scripthex,tokenevalcode,tokenid,pubkeys, oprets)!=0 && tokenevalcode==EVAL_TOKENS && oprets.size()>0) { + // seems we need a loop here + vOpretExtra = oprets[0].second; UniValue obj(UniValue::VOBJ); GetOpReturnData(scripthex,vopret); script = (uint8_t *)vopret.data(); From 9cba4bbf7970050cdef10f67d40fc513f8ff10cf Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 00:25:56 +0500 Subject: [PATCH 2735/3904] merged changes from Fix gatewaysbind #1289 and GatewaysCC small fixes (#1290) --- src/cc/gateways.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 35d7e0cd1..c0ee794ef 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -963,7 +963,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t prefix2 = p2; wiftype = p3; taddr = p4; - LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d for %s\n",prefix,prefix2,wiftype,coin.c_str()); + LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d, taddr %d for %s\n",prefix,prefix2,wiftype,taddr,coin.c_str()); } if ( N == 0 || N > 15 || M > N ) { @@ -1822,7 +1822,7 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key) priv=EncodeCustomSecret(key,wiftype); result.push_back(Pair("result","success")); - result.push_back(Pair("address",priv.c_str())); + result.push_back(Pair("privkey",priv.c_str())); return(result); } From b5a02a6b5f30d26f3005215cbf787d517d9d7ef3 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 00:58:47 +0500 Subject: [PATCH 2736/3904] corr call to EncodeTokenOpRet in test func --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d17752223..510dff7be 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -8070,7 +8070,7 @@ UniValue test_burntx(const UniValue& params, bool fHelp) CPubKey unspPk = GetUnspendable(cp, tokenpriv); GetCCaddress(cp, unspendableTokenAddr, unspPk); CCaddr2set(cp, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); - return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, EncodeTokenOpRet(tokenid, voutPubkeys, CScript()))); + return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, EncodeTokenOpRet(tokenid, voutPubkeys, std::make_pair(0, vscript_t())))); } UniValue test_proof(const UniValue& params, bool fHelp) From 5cd9437aada4711caa5be9fd44bf9f962c21a299 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 18:09:18 -1100 Subject: [PATCH 2737/3904] Fix OS X build issue in rpc/misc.cpp --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index ef1c8bf5c..a8b6d6dc5 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -182,7 +182,7 @@ UniValue geterablockheights(const UniValue& params, bool fHelp) { char str[16]; sprintf(str, "%d", era); - ret.push_back(Pair(str,i)); + ret.push_back(Pair(str,(int64_t)i)); lastera = era; } } From bd78364587f59410fea7d2ef89ad1be0457413ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Feb 2019 18:18:41 -1100 Subject: [PATCH 2738/3904] rogue.sendlog --- src/cc/rogue/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 4bcc5c533..56377071f 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -720,6 +720,16 @@ int32_t rogue_sendrawtransaction(char *rawtx) free(retstr); return(0); } + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("rogue.sendlog","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%s\n",retstr); + fflush(fp); + } + } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { free_json(retjson); @@ -789,13 +799,14 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(retstr); } - if ( waitflag != 0 && rs->keystrokeshex != 0 ) + if ( 0 && waitflag != 0 && rs->keystrokeshex != 0 ) { while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { //fprintf(stderr,"post-rebroadcast\n"); sleep(3); } + free(rs->keystrokeshex), rs->keystrokeshex = 0; } } } From 2a32401ef8447b574c45d0c9d1c4718b15d4c4d7 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 13:54:56 +0500 Subject: [PATCH 2739/3904] corr FilterOutNonCCOprets checking cc opret data --- src/cc/CCinclude.h | 9 ++++++--- src/cc/CCtokens.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 53233f89c..5b1a29421 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -69,15 +69,18 @@ one other technical note is that komodod has the insight-explorer extensions bui // token opret additional data block ids: enum opretid : uint8_t { - OPRETID_NONFUNGIBLEDATA = 0x11, OPRETID_FIRST = OPRETID_NONFUNGIBLEDATA, // first id + // cc contracts data: + OPRETID_NONFUNGIBLEDATA = 0x11, OPRETID_ASSETSDATA = 0x12, OPRETID_GATEWAYSDATA = 0x13, OPRETID_CHANNELSDATA = 0x14, OPRETID_HEIRDATA = 0x15, OPRETID_ROGUEGAMEDATA = 0x16, - OPRETID_BURNDATA = 0x70, - OPRETID_IMPORTDATA = 0x71, OPRETID_LAST = OPRETID_IMPORTDATA // last id + // non cc contract data: + OPRETID_FIRSTNONCCDATA = 0x80, + OPRETID_BURNDATA = 0x80, + OPRETID_IMPORTDATA = 0x81 }; // find opret blob by opretid diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index a91591729..f62021130 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -265,16 +265,16 @@ void FilterOutTokensUnspendablePk(const std::vector &sourcePubkeys, std } -void FilterOutBurnOpret(const std::vector> &oprets, vscript_t vopret) { +void FilterOutNonCCOprets(const std::vector> &oprets, vscript_t vopret) { vopret.clear(); if (oprets.size() > 2) - LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "FilterOutBurnOpret() oprets.size > 2 currently not supported" << oprets.size() << std::endl); + LOGSTREAM("cctokens", CCLOG_INFO, stream << "FilterOutNonCCOprets() warning!! oprets.size > 2 currently not supported" << oprets.size() << std::endl); for (auto o : oprets) { - if (o.first != EVAL_IMPORTCOIN) { // skip burn opret - vopret = o.second; // return first contract opret (more than 1 is not supported yet) + if (o.first < OPRETID_FIRSTNONCCDATA) { // skip burn, import, etc opret data + vopret = o.second; // return first contract opret (more than 1 is not supported yet) break; } } @@ -343,7 +343,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys /*<--not used, always true LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() oprets.size()=" << oprets.size() << std::endl); // get assets/channels/gateways token data: - FilterOutBurnOpret(oprets, vopretExtra); // NOTE: only 1 additional evalcode in token opret is currently supported + FilterOutNonCCOprets(oprets, vopretExtra); // NOTE: only 1 additional evalcode in token opret is currently supported LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl); // get non-fungible data @@ -679,7 +679,7 @@ int64_t HasBurnedTokensvouts(struct CCcontract_info *cp, Eval* eval, const CTran } // get assets/channels/gateways token data: - FilterOutBurnOpret(oprets, vopretExtra); // NOTE: only 1 additional evalcode in token opret is currently supported + FilterOutNonCCOprets(oprets, vopretExtra); // NOTE: only 1 additional evalcode in token opret is currently supported LOGSTREAM((char *)"cctokens", CCLOG_DEBUG2, stream << "HasBurnedTokensvouts() vopretExtra=" << HexStr(vopretExtra) << std::endl); From faff472bc1565783708020688ed9b534b91d0424 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 14:54:29 +0500 Subject: [PATCH 2740/3904] corr EncodeTokenCreateOpRet check non fungible empty --- src/cc/CCtokensOpRet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtokensOpRet.cpp b/src/cc/CCtokensOpRet.cpp index 31ece4d78..edbc59db4 100644 --- a/src/cc/CCtokensOpRet.cpp +++ b/src/cc/CCtokensOpRet.cpp @@ -19,7 +19,8 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::vector> oprets; - oprets.push_back(std::make_pair(OPRETID_NONFUNGIBLEDATA, vopretNonfungible)); + if(!vopretNonfungible.empty()) + oprets.push_back(std::make_pair(OPRETID_NONFUNGIBLEDATA, vopretNonfungible)); return EncodeTokenCreateOpRet(funcid, origpubkey, name, description, oprets); } From f9776e877fb3a7a3946d96a10f431b5a17c9b7d8 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 15:19:27 +0500 Subject: [PATCH 2741/3904] corr FilterOutNonCCOprets ref param --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index f62021130..8aa5e88f7 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -265,7 +265,7 @@ void FilterOutTokensUnspendablePk(const std::vector &sourcePubkeys, std } -void FilterOutNonCCOprets(const std::vector> &oprets, vscript_t vopret) { +void FilterOutNonCCOprets(const std::vector> &oprets, vscript_t &vopret) { vopret.clear(); From b436bb429126c42496ea507dac6bbb65e32f2637 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 15:54:52 +0500 Subject: [PATCH 2742/3904] corr opretid for assets --- src/cc/CCassetsCore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index d4cc8646e..06d843b40 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -295,7 +295,7 @@ uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCo // First - decode token opret: funcId = DecodeTokenOpRet(scriptPubKey, dummyEvalCode, tokenid, voutPubkeysDummy, oprets); - GetOpretBlob(oprets, OPRETID_GATEWAYSDATA, vopretAssets); + GetOpretBlob(oprets, OPRETID_ASSETSDATA, vopretAssets); LOGSTREAM((char *)"ccassets", CCLOG_DEBUG2, stream << "DecodeAssetTokenOpRet() from DecodeTokenOpRet returned funcId=" << (int)funcId << std::endl); From 2d9fc69a0be9a6dd7972e0ced5c05b31621438f7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 28 Feb 2019 20:24:29 +0800 Subject: [PATCH 2743/3904] fix is_STAKED --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 5311f8e51..a3278ac12 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,6 +17,7 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); + else STAKED = 0; if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABSTH") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) From a3b3459642e68ef214b29704e31cc83ffae93f43 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 20:04:05 +0500 Subject: [PATCH 2744/3904] corr getting non-funglible data in rogue_highlanderopretdecode --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3ad39194b..fae9d53f0 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -177,7 +177,7 @@ uint8_t rogue_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t script = (uint8_t *)vopret.data(); if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description, oprets)) == 'c' ) { - GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretDummy); + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); vopret = vopretNonfungible; } else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, opretsDummy)) != 0 ) From f459487cd891f2b2626f504131e68f094b9eeb0d Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 20:59:19 +0500 Subject: [PATCH 2745/3904] added decoding of old rogue data in token opret --- src/cc/CCtokensOpRet.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/cc/CCtokensOpRet.cpp b/src/cc/CCtokensOpRet.cpp index edbc59db4..7514f4bb6 100644 --- a/src/cc/CCtokensOpRet.cpp +++ b/src/cc/CCtokensOpRet.cpp @@ -193,6 +193,9 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui uint256 dummySrcTokenId; CPubKey voutPubkey1, voutPubkey2; + vscript_t vroguedata; + bool foundRogue = false; + GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); tokenid = zeroid; @@ -222,16 +225,28 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui case 't': //not used yet: case 'l': // NOTE: 'E_UNMARSHAL result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' - if (E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; - if (ccType >= 1) ss >> voutPubkey1; - if (ccType == 2) ss >> voutPubkey2; - while (!ss.eof()) { - ss >> opretId; - if (!ss.eof()) { - ss >> vblob; - oprets.push_back(std::make_pair(opretId, vblob)); - } - })) + + // compatibility with rogue data: + // try to unmarshal rogue data: + + foundRogue = E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; + if (ccType >= 1) ss >> voutPubkey1; + if (ccType == 2) ss >> voutPubkey2; + if (!ss.eof()) { + ss >> vroguedata; + }) && vroguedata.size() > 2 && vroguedata.begin()[0] == 0x11 /*EVAL_ROGUE*/ && vroguedata.begin()[1] == 'R'; + + if(foundRogue || // fix for compatibility with old rogue data (no opretid) + E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; + if (ccType >= 1) ss >> voutPubkey1; + if (ccType == 2) ss >> voutPubkey2; + while (!ss.eof()) { + ss >> opretId; + if (!ss.eof()) { + ss >> vblob; + oprets.push_back(std::make_pair(opretId, vblob)); + } + })) { if (!(ccType >= 0 && ccType <= 2)) { //incorrect ccType LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() incorrect ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); @@ -246,6 +261,11 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui voutPubkeys.push_back(voutPubkey2); tokenid = revuint256(tokenid); + + if (foundRogue) { + oprets.push_back(std::make_pair(OPRETID_ROGUEGAMEDATA, vroguedata)); + } + return(funcId); } LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "DecodeTokenOpRet() bad opret format," << " ccType=" << (int)ccType << " tokenid=" << revuint256(tokenid).GetHex() << std::endl); From e385253b47e87d15b114a4e8bbce4629e19fd59c Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 21:01:46 +0500 Subject: [PATCH 2746/3904] logging added --- src/cc/CCtokensOpRet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCtokensOpRet.cpp b/src/cc/CCtokensOpRet.cpp index 7514f4bb6..049319527 100644 --- a/src/cc/CCtokensOpRet.cpp +++ b/src/cc/CCtokensOpRet.cpp @@ -263,6 +263,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui tokenid = revuint256(tokenid); if (foundRogue) { + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet() found old-style rogue data" << " for tokenid=" << revuint256(tokenid).GetHex() << std::endl); oprets.push_back(std::make_pair(OPRETID_ROGUEGAMEDATA, vroguedata)); } From 2056d59c7ea30d9c9e9cef1d85b9483006bf881c Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Thu, 28 Feb 2019 19:05:44 +0100 Subject: [PATCH 2747/3904] Fix token vout number for Gateways --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 52346ed2d..fd432359e 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -399,7 +399,7 @@ int64_t CCfullsupply(uint256 tokenid) { if (DecodeTokenCreateOpRet(tx.vout[numvouts-1].scriptPubKey,origpubkey,name,description)) { - return(tx.vout[0].nValue); + return(tx.vout[1].nValue); } } return(0); From be8befeed59c55ea5742ec1f4205f448fe98a512 Mon Sep 17 00:00:00 2001 From: dimxy Date: Thu, 28 Feb 2019 23:37:47 +0500 Subject: [PATCH 2748/3904] detect old style opret: assets support, more funcids support --- src/cc/CCtokensOpRet.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtokensOpRet.cpp b/src/cc/CCtokensOpRet.cpp index 049319527..23422f660 100644 --- a/src/cc/CCtokensOpRet.cpp +++ b/src/cc/CCtokensOpRet.cpp @@ -3,6 +3,10 @@ #include "CCtokens.h" +#ifndef IS_CHARINSTR +#define IS_CHARINSTR(c, str) (std::string(str).find((char)(c)) != std::string::npos) +#endif + // NOTE: this inital tx won't be used by other contract // for tokens to be used there should be at least one 't' tx with other contract's custom opret CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, vscript_t vopretNonfungible) @@ -226,15 +230,17 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui //not used yet: case 'l': // NOTE: 'E_UNMARSHAL result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' - // compatibility with rogue data: - // try to unmarshal rogue data: + // compatibility with rogue or assets data: + // try to unmarshal rogue or assets data: foundRogue = E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; if (ccType >= 1) ss >> voutPubkey1; if (ccType == 2) ss >> voutPubkey2; if (!ss.eof()) { ss >> vroguedata; - }) && vroguedata.size() > 2 && vroguedata.begin()[0] == 0x11 /*EVAL_ROGUE*/ && vroguedata.begin()[1] == 'R'; + }) && vroguedata.size() > 2 && + (vroguedata.begin()[0] == 0x11 /*EVAL_ROGUE*/ && IS_CHARINSTR(vroguedata.begin()[1], "RHQKG") || + vroguedata.begin()[0] == EVAL_ASSETS && IS_CHARINSTR(vroguedata.begin()[1], "sbSBxo")) ; if(foundRogue || // fix for compatibility with old rogue data (no opretid) E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; From 792dab26b6068fbd33395fc078010b112af0c9dc Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 1 Mar 2019 00:10:50 +0500 Subject: [PATCH 2749/3904] corr opretid for old-style assets --- src/cc/CCtokensOpRet.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/cc/CCtokensOpRet.cpp b/src/cc/CCtokensOpRet.cpp index 23422f660..9271b01a9 100644 --- a/src/cc/CCtokensOpRet.cpp +++ b/src/cc/CCtokensOpRet.cpp @@ -197,8 +197,8 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui uint256 dummySrcTokenId; CPubKey voutPubkey1, voutPubkey2; - vscript_t vroguedata; - bool foundRogue = false; + vscript_t voldstyledata; + bool foundOldstyle = false; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); @@ -227,22 +227,19 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui return DecodeTokenImportOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription, dummySrcTokenId, oprets); //break; case 't': - //not used yet: case 'l': - // NOTE: 'E_UNMARSHAL result==false' means 'parse error' OR 'not eof state'. Consequently, 'result==false' but 'isEof==true' means just 'parse error' - - // compatibility with rogue or assets data: - // try to unmarshal rogue or assets data: - - foundRogue = E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; + + // compatibility with old-style rogue or assets data (with no opretid): + // try to unmarshal old-style rogue or assets data: + foundOldstyle = E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; if (ccType >= 1) ss >> voutPubkey1; if (ccType == 2) ss >> voutPubkey2; if (!ss.eof()) { - ss >> vroguedata; - }) && vroguedata.size() > 2 && - (vroguedata.begin()[0] == 0x11 /*EVAL_ROGUE*/ && IS_CHARINSTR(vroguedata.begin()[1], "RHQKG") || - vroguedata.begin()[0] == EVAL_ASSETS && IS_CHARINSTR(vroguedata.begin()[1], "sbSBxo")) ; + ss >> voldstyledata; + }) && voldstyledata.size() > 2 && + (voldstyledata.begin()[0] == 0x11 /*EVAL_ROGUE*/ && IS_CHARINSTR(voldstyledata.begin()[1], "RHQKG") || + voldstyledata.begin()[0] == EVAL_ASSETS && IS_CHARINSTR(voldstyledata.begin()[1], "sbSBxo")) ; - if(foundRogue || // fix for compatibility with old rogue data (no opretid) + if (foundOldstyle || // fix for compatibility with old style data (no opretid) E_UNMARSHAL(vopret, ss >> dummyEvalCode; ss >> dummyFuncId; ss >> tokenid; ss >> ccType; if (ccType >= 1) ss >> voutPubkey1; if (ccType == 2) ss >> voutPubkey2; @@ -268,9 +265,15 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui tokenid = revuint256(tokenid); - if (foundRogue) { - LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet() found old-style rogue data" << " for tokenid=" << revuint256(tokenid).GetHex() << std::endl); - oprets.push_back(std::make_pair(OPRETID_ROGUEGAMEDATA, vroguedata)); + if (foundOldstyle) { //patch for old-style opret data with no opretid + LOGSTREAM((char *)"cctokens", CCLOG_DEBUG1, stream << "DecodeTokenOpRet() found old-style rogue/asset data, evalcode=" << (int)voldstyledata.begin()[0] << " funcid=" << (char)voldstyledata.begin()[1] << " for tokenid=" << revuint256(tokenid).GetHex() << std::endl); + uint8_t opretIdRestored; + if (voldstyledata.begin()[0] == 0x11 /*EVAL_ROGUE*/) + opretIdRestored = OPRETID_ROGUEGAMEDATA; + else // EVAL_ASSETS + opretIdRestored = OPRETID_ASSETSDATA; + + oprets.push_back(std::make_pair(opretIdRestored, voldstyledata)); } return(funcId); From 6b6f4ee29fde3c6c85944326a5a5ff5732edea23 Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 1 Mar 2019 00:25:31 +0500 Subject: [PATCH 2750/3904] corr condition to '>=2' in detect old-style data (for 'o' asset cancels) --- src/cc/CCtokensOpRet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokensOpRet.cpp b/src/cc/CCtokensOpRet.cpp index 9271b01a9..4c6dc4b6d 100644 --- a/src/cc/CCtokensOpRet.cpp +++ b/src/cc/CCtokensOpRet.cpp @@ -235,7 +235,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui if (ccType == 2) ss >> voutPubkey2; if (!ss.eof()) { ss >> voldstyledata; - }) && voldstyledata.size() > 2 && + }) && voldstyledata.size() >= 2 && (voldstyledata.begin()[0] == 0x11 /*EVAL_ROGUE*/ && IS_CHARINSTR(voldstyledata.begin()[1], "RHQKG") || voldstyledata.begin()[0] == EVAL_ASSETS && IS_CHARINSTR(voldstyledata.begin()[1], "sbSBxo")) ; From 094a153beab57529c15fa9d6d544d59ce6dfaa46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Feb 2019 18:29:57 -1100 Subject: [PATCH 2751/3904] Remove while loop waiting for send --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 56377071f..7b68aa49e 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -751,7 +751,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * { if ( waitflag == 0 ) return; - else + else if ( 0 ) { while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { From 1adc843ab233344f1c4453de708e4377d19867b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Feb 2019 19:12:57 -1100 Subject: [PATCH 2752/3904] +print --- src/cc/rogue_rpc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 13724ed7b..f0ef921ad 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -489,7 +489,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke playertxid = batontxid = zeroid; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -508,17 +508,17 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( matches == 1 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1) < 0 ) { @@ -532,7 +532,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-2); } txid = spenttxid; - //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); From 0cea17dea9baa3bde36a3780460023623d27a0bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Feb 2019 19:32:56 -1100 Subject: [PATCH 2753/3904] +print --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 01513149c..aa5b0df75 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2083,14 +2083,14 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo memset(&hashBlock,0,sizeof(hashBlock)); // need a GetTransaction without lock so the validation code for assets can run without deadlock { - //fprintf(stderr,"check mempool\n"); + fprintf(stderr,"check mempool %s\n",hash.GetHex().c_str()); if (mempool.lookup(hash, txOut)) { //fprintf(stderr,"found in mempool\n"); return true; } } - //fprintf(stderr,"check disk\n"); + fprintf(stderr,"check disk %s\n",hash.GetHex().c_str()); if (fTxIndex) { CDiskTxPos postx; From 2e0420792098fd9e14ba80e616317fd89e99e53b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Feb 2019 19:45:45 -1100 Subject: [PATCH 2754/3904] +print --- src/cc/rogue_rpc.cpp | 3 +++ src/main.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f0ef921ad..e77600d39 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -540,13 +540,16 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) { uint256 g,b; CPubKey p; std::vector k; + fprintf(stderr,"decode keys\n"); if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) { + fprintf(stderr,"decoded keys %d\n",(int32_t)k.size()); keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); for (i=0; i= ROGUE_MAXITERATIONS ) diff --git a/src/main.cpp b/src/main.cpp index aa5b0df75..df3c87ca4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2112,11 +2112,11 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo hashBlock = header.GetHash(); if (txOut.GetHash() != hash) return error("%s: txid mismatch", __func__); - //fprintf(stderr,"found on disk\n"); + fprintf(stderr,"found on disk %s\n",hash.GetHex().c_str()); return true; } } - //fprintf(stderr,"not found\n"); + fprintf(stderr,"not found on disk %s\n",hash.GetHex().c_str()); return false; } From e06dcabe9e1f3157438f3d87474c8fd07f43028e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Feb 2019 19:56:19 -1100 Subject: [PATCH 2755/3904] +/- prints --- src/cc/rogue_rpc.cpp | 3 ++- src/main.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e77600d39..6a7a81e20 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -539,6 +539,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) { + fprintf(stderr,"declares\n"); uint256 g,b; CPubKey p; std::vector k; fprintf(stderr,"decode keys\n"); if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) @@ -552,12 +553,12 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke fprintf(stderr,"updated keystrokes.%p[%d]\n",keystrokes,numkeys); } } + fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); if ( ++n >= ROGUE_MAXITERATIONS ) { fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); return(-5); } - //fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); } //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; diff --git a/src/main.cpp b/src/main.cpp index df3c87ca4..01e19628c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2083,14 +2083,14 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo memset(&hashBlock,0,sizeof(hashBlock)); // need a GetTransaction without lock so the validation code for assets can run without deadlock { - fprintf(stderr,"check mempool %s\n",hash.GetHex().c_str()); + //fprintf(stderr,"check mempool %s\n",hash.GetHex().c_str()); if (mempool.lookup(hash, txOut)) { //fprintf(stderr,"found in mempool\n"); return true; } } - fprintf(stderr,"check disk %s\n",hash.GetHex().c_str()); + //fprintf(stderr,"check disk %s\n",hash.GetHex().c_str()); if (fTxIndex) { CDiskTxPos postx; @@ -2112,11 +2112,11 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo hashBlock = header.GetHash(); if (txOut.GetHash() != hash) return error("%s: txid mismatch", __func__); - fprintf(stderr,"found on disk %s\n",hash.GetHex().c_str()); + //fprintf(stderr,"found on disk %s\n",hash.GetHex().c_str()); return true; } } - fprintf(stderr,"not found on disk %s\n",hash.GetHex().c_str()); + //fprintf(stderr,"not found on disk %s\n",hash.GetHex().c_str()); return false; } From 973124163e36164737f2a4ba34759dd99577478c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Feb 2019 20:14:38 -1100 Subject: [PATCH 2756/3904] Lockflag --- src/cc/CCinclude.h | 2 +- src/cc/CCtx.cpp | 25 ++++++++++++++++++------- src/cc/marmara.cpp | 2 +- src/cc/rogue_rpc.cpp | 35 ++++++++++++++++++++--------------- src/cc/sudoku.cpp | 2 +- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 5b1a29421..91e9467dd 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -170,7 +170,7 @@ static int32_t ignorevin; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); int32_t is_hexstr(char *str,int32_t n); bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false); -int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag); +int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockflag); bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout); bool mytxid_inmempool(uint256 txid); int32_t myIsutxo_spent(uint256 &spenttxid,uint256 txid,int32_t vout); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index fd432359e..dd9812c99 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -347,17 +347,28 @@ int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout) return(0); } -int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag) +int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockflag) { CCoins coins; if ( mempoolflag != 0 ) { - LOCK(mempool.cs); - CCoinsViewMemPool view(pcoinsTip, mempool); - if (!view.GetCoins(txid, coins)) - return(-1); - if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) - return(-1); + if ( lockflag != 0 ) + { + LOCK(mempool.cs); + CCoinsViewMemPool view(pcoinsTip, mempool); + if (!view.GetCoins(txid, coins)) + return(-1); + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) + return(-1); + } + else + { + CCoinsViewMemPool view(pcoinsTip, mempool); + if (!view.GetCoins(txid, coins)) + return(-1); + if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) + return(-1); + } } else { diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f43f3a559..3c35632c8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -167,7 +167,7 @@ int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid, creditloop.push_back(txid); //fprintf(stderr,"%d: %s\n",n,txid.GetHex().c_str()); n++; - if ( (value= CCgettxout(spenttxid,vout,1)) == 10000 ) + if ( (value= CCgettxout(spenttxid,vout,1,1)) == 10000 ) { batontxid = spenttxid; //fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6a7a81e20..f9c9cb331 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -295,7 +295,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa txid = tx.GetHash(); //fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); } - if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1,0) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { @@ -343,7 +343,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint } txid = playertxid; vout = 1; - while ( CCgettxout(txid,vout,1) < 0 ) + while ( CCgettxout(txid,vout,1,0) < 0 ) { spenttxid = zeroid; spentvini = -1; @@ -462,7 +462,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_t vout,uint256 origplayergame) { int64_t txfee = 10000; CTransaction tx; uint256 hashBlock; - if ( CCgettxout(playertxid,vout,1) == 1 ) // not sure if this is enough validation + if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation { mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); return(0); @@ -472,7 +472,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_ vout = 0; if ( myGetTransaction(playertxid,tx,hashBlock) != 0 && tx.vout[vout].nValue == 1 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if ( CCgettxout(playertxid,vout,1) == 1 ) // not sure if this is enough validation + if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation { mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); return(0); @@ -520,16 +520,21 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke txid = matchtx.GetHash(); fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; - while ( CCgettxout(txid,0,1) < 0 ) + while ( CCgettxout(txid,0,1,0) < 0 ) { spenttxid = zeroid; spentvini = -1; + fprintf(stderr,"check myIsutxo_spent\n"); if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) txid = spenttxid; - else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + else { - fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); - return(-2); + fprintf(stderr,"check myIsutxo_spentinmempool\n"); + if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + return(-2); + } } txid = spenttxid; fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); @@ -590,16 +595,16 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx registration_open = 1; for (i=0; i 1 ) { @@ -710,7 +715,7 @@ int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTrans for (j=0; j 1 ) { From 50acda66405b99f299c4532513a6903f7f0a7545 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Feb 2019 20:28:06 -1100 Subject: [PATCH 2757/3904] +prot --- src/cc/CCtx.cpp | 5 +++-- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index dd9812c99..65aad8e3a 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -350,6 +350,7 @@ int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout) int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockflag) { CCoins coins; + fprintf(stderr,"CCgettxoud %s/v%d\n",txid.GetHex().c_str(),vout); if ( mempoolflag != 0 ) { if ( lockflag != 0 ) @@ -358,7 +359,7 @@ int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockfla CCoinsViewMemPool view(pcoinsTip, mempool); if (!view.GetCoins(txid, coins)) return(-1); - if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) + else if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) return(-1); } else @@ -366,7 +367,7 @@ int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockfla CCoinsViewMemPool view(pcoinsTip, mempool); if (!view.GetCoins(txid, coins)) return(-1); - if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) + else if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 ) return(-1); } } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f9c9cb331..cc96dfff5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -565,7 +565,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-5); } } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -578,7 +578,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); From 1f8591b0e94b81692465ef0bf8bb320231535cd6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 01:47:09 -1100 Subject: [PATCH 2758/3904] Fixes --- src/cc/dilithium.c | 8 ++++---- src/cc/rogue_rpc.cpp | 9 +++++++-- src/komodo_globals.h | 18 ++++++++++++++++-- src/komodo_utils.h | 7 ++++++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 1f893d268..b01a3bf1d 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3276,9 +3276,9 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } -int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr) +int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 pubtxid,int64_t total,int32_t maxinputs,char *cmpaddr) { - char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 tmptxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; + char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 checktxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); @@ -3294,7 +3294,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( dilithium_Qsendopretdecode(tmptxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(tmptxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && desttxid == checktxid ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -3358,7 +3358,7 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } outputsum += amount; } - if ( (inputsum= dilithium_inputs(cp,mtx,mypk,outputsum+txfee,64,myCCaddr)) >= outputsum+txfee ) + if ( (inputsum= dilithium_inputs(cp,mtx,mypk,mypubtxid,outputsum+txfee,64,myCCaddr)) >= outputsum+txfee ) { change = (inputsum - outputsum - txfee); if ( change >= txfee ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cc96dfff5..508bf6040 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -593,16 +593,19 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx numplayers = openslots = 0; if ( komodo_nextheight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) registration_open = 1; + fprintf(stderr,"players alive\n"); for (i=0; i ROGUE_MAXITERATIONS ) break; } + fprintf(stderr,"out of while\n"); if ( txid != zeroid ) { + fprintf(stderr,"get height of %s\n",txid.GetHex().c_str()); if ( myGetTransaction(txid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { if ( pindex->GetHeight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 859fada99..b94281b02 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -129,7 +129,7 @@ int32_t komodo_baseid(char *origbase) #ifndef SATOSHIDEN #define SATOSHIDEN ((uint64_t)100000000L) #endif -int64_t komodo_current_supply(uint32_t nHeight) +uint64_t komodo_current_supply(uint32_t nHeight) { uint64_t cur_money; int32_t baseid; @@ -264,5 +264,19 @@ int64_t komodo_current_supply(uint32_t nHeight) } } } - return((int64_t)(cur_money + (cur_money * ASSETCHAINS_COMMISSION))); +#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) +#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) + + if ( KOMODO_BIT63SET(cur_money) != 0 ) + return(KOMODO_MAXNVALUE); + if ( ASSETCHAINS_COMMISSION != 0 ) + { + uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)); + if ( KOMODO_BIT63SET(newval) != 0 ) + return(KOMODO_MAXNVALUE); + else if ( newval < curval ) // check for underflow + return(KOMODO_MAXNVALUE); + return(newvalue) + } + return(cur_money); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2fbb782ce..65114c16b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,7 +1562,7 @@ char *argv0names[] = (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH" }; -int64_t komodo_max_money() +uint64_t komodo_max_money() { return komodo_current_supply(10000000); } @@ -1787,6 +1787,11 @@ void komodo_args(char *argv0) ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); + if ( ASSETCHAINS_SUPPLY > (uint64_t)90*1000*1000000 ) + { + fprintf(stderr,"-ac_supply must be less than 90 billion\n"); + exit(0); + } ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); From 3f64e818b7b8a8164ed59ec359e92df96757343b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 01:52:06 -1100 Subject: [PATCH 2759/3904] cur_money --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b94281b02..2c668ae7b 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -274,7 +274,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)); if ( KOMODO_BIT63SET(newval) != 0 ) return(KOMODO_MAXNVALUE); - else if ( newval < curval ) // check for underflow + else if ( newval < cur_money ) // check for underflow return(KOMODO_MAXNVALUE); return(newvalue) } From c02c249c22a0d910c14034d40630bdd4ecbd5f5d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 01:53:32 -1100 Subject: [PATCH 2760/3904] newval --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 2c668ae7b..35a4032ce 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -276,7 +276,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) return(KOMODO_MAXNVALUE); else if ( newval < cur_money ) // check for underflow return(KOMODO_MAXNVALUE); - return(newvalue) + return(newval) } return(cur_money); } From cc42fe2a866a8c783f94a8f73f9b5c6bee76bc8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 01:54:13 -1100 Subject: [PATCH 2761/3904] ; --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 35a4032ce..13de7c310 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -276,7 +276,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) return(KOMODO_MAXNVALUE); else if ( newval < cur_money ) // check for underflow return(KOMODO_MAXNVALUE); - return(newval) + return(newval); } return(cur_money); } From 1dcc19e22f6506a4c2c879ce70e6fc34c7e0eeee Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 02:09:06 -1100 Subject: [PATCH 2762/3904] Finally --- src/cc/rogue_rpc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 508bf6040..863934e75 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -630,11 +630,17 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx if ( txid != zeroid ) { fprintf(stderr,"get height of %s\n",txid.GetHex().c_str()); - if ( myGetTransaction(txid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 ) { - if ( pindex->GetHeight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) - alive++; + fprintf(stderr,"got tx %s\n",txid.GetHex().c_str()); + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + fprintf(stderr,"got pindex %s\n",hashBlock.GetHex().c_str()); + if ( pindex->GetHeight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) + alive++; + } } + fprintf(stderr,"got height of %s\n",txid.GetHex().c_str()); } } } From 0b23f6273761c7341ff538ccee7dd251677f547b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 02:23:22 -1100 Subject: [PATCH 2763/3904] +print --- src/cc/rogue_rpc.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 863934e75..f0453b66d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -508,28 +508,26 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( matches == 1 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1,0) < 0 ) { spenttxid = zeroid; spentvini = -1; - fprintf(stderr,"check myIsutxo_spent\n"); if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) txid = spenttxid; else { - fprintf(stderr,"check myIsutxo_spentinmempool\n"); if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) { fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); @@ -537,35 +535,32 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } } txid = spenttxid; - fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); } if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) { - fprintf(stderr,"declares\n"); uint256 g,b; CPubKey p; std::vector k; - fprintf(stderr,"decode keys\n"); if ( rogue_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) { - fprintf(stderr,"decoded keys %d\n",(int32_t)k.size()); keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); for (i=0; i= ROGUE_MAXITERATIONS ) { fprintf(stderr,"rogue_findbaton n.%d, seems something is wrong\n",n); return(-5); } } - fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -578,7 +573,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); @@ -596,7 +591,7 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx fprintf(stderr,"players alive\n"); for (i=0; i 0 ) { @@ -978,6 +974,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto fclose(fp); } } + fprintf(stderr,"replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i Date: Fri, 1 Mar 2019 02:40:17 -1100 Subject: [PATCH 2764/3904] Break out of infinite loops! --- src/cc/rogue/monsters.c | 2 +- src/cc/rogue/new_level.c | 14 +++++++------- src/cc/rogue/pack.c | 2 ++ src/cc/rogue/rings.c | 34 ++++++++++++++++++---------------- src/cc/rogue/rogue.h | 8 ++++---- src/cc/rogue/rooms.c | 24 ++++++++++++++---------- src/cc/rogue/sticks.c | 2 +- src/cc/rogue/weapons.c | 2 ++ src/cc/rogue/wizard.c | 30 ++++++++++++++++-------------- src/cc/rogue_rpc.cpp | 16 +++++----------- 10 files changed, 70 insertions(+), 64 deletions(-) diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 2f6d68362..7e1186e8d 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -124,7 +124,7 @@ wanderer(struct rogue_state *rs) tp = new_item(); do { - find_floor((struct room *) NULL, &cp, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); } while (roomin(rs,&cp) == proom); new_monster(rs,tp, randmonster(TRUE), &cp); if (on(player, SEEMONST)) diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index b55d3e42c..c2ec5219d 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -74,7 +74,7 @@ new_level(struct rogue_state *rs) */ do { - find_floor((struct room *) NULL, &stairs, FALSE, FALSE); + find_floor(rs,(struct room *) NULL, &stairs, FALSE, FALSE); } while (chat(stairs.y, stairs.x) != FLOOR); sp = &flat(stairs.y, stairs.x); *sp &= ~F_REAL; @@ -84,14 +84,14 @@ new_level(struct rogue_state *rs) /* * Place the staircase down. */ - find_floor((struct room *) NULL, &stairs, FALSE, FALSE); + find_floor(rs,(struct room *) NULL, &stairs, FALSE, FALSE); chat(stairs.y, stairs.x) = STAIRS; seenstairs = FALSE; for (tp = mlist; tp != NULL; tp = next(tp)) tp->t_room = roomin(rs,&tp->t_pos); - find_floor((struct room *) NULL, &hero, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &hero, FALSE, TRUE); enter_room(rs,&hero); mvaddch(hero.y, hero.x, PLAYER); if (on(player, SEEMONST)) @@ -153,7 +153,7 @@ put_things(struct rogue_state *rs) /* * Put it somewhere */ - find_floor((struct room *) NULL, &obj->o_pos, FALSE, FALSE); + find_floor(rs,(struct room *) NULL, &obj->o_pos, FALSE, FALSE); chat(obj->o_pos.y, obj->o_pos.x) = (char) obj->o_type; } /* @@ -173,7 +173,7 @@ put_things(struct rogue_state *rs) /* * Put it somewhere */ - find_floor((struct room *) NULL, &obj->o_pos, FALSE, FALSE); + find_floor(rs,(struct room *) NULL, &obj->o_pos, FALSE, FALSE); chat(obj->o_pos.y, obj->o_pos.x) = AMULET; } } @@ -201,7 +201,7 @@ treas_room(struct rogue_state *rs) num_monst = nm = rnd(spots) + MINTREAS; while (nm--) { - find_floor(rp, &mp, 2 * MAXTRIES, FALSE); + find_floor(rs,rp, &mp, 2 * MAXTRIES, FALSE); //fprintf(stderr,"treas_room\n"); tp = new_thing(rs); tp->o_pos = mp; @@ -222,7 +222,7 @@ treas_room(struct rogue_state *rs) while (nm--) { spots = 0; - if (find_floor(rp, &mp, MAXTRIES, TRUE)) + if (find_floor(rs,rp, &mp, MAXTRIES, TRUE)) { tp = new_item(); new_monster(rs,tp, randmonster(FALSE), &mp); diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 776669b3b..362c65412 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -422,6 +422,8 @@ get_item(struct rogue_state *rs,char *purpose, int type) { for (;;) { + if ( rs->replaydone != 0 ) + return(NULL); if (!terse) addmsg(rs,"which object do you want to "); addmsg(rs,purpose); diff --git a/src/cc/rogue/rings.c b/src/cc/rogue/rings.c index 747da302a..af6cc881b 100644 --- a/src/cc/rogue/rings.c +++ b/src/cc/rogue/rings.c @@ -130,24 +130,26 @@ int gethand(struct rogue_state *rs) { int c; - + for (;;) { - if (terse) - msg(rs,"left or right ring? "); - else - msg(rs,"left hand or right hand? "); - if ((c = readchar(rs)) == ESCAPE) - return -1; - mpos = 0; - if (c == 'l' || c == 'L') - return LEFT; - else if (c == 'r' || c == 'R') - return RIGHT; - if (terse) - msg(rs,"L or R"); - else - msg(rs,"please type L or R"); + if ( rs->replaydone != 0 ) + return(-1); + if (terse) + msg(rs,"left or right ring? "); + else + msg(rs,"left hand or right hand? "); + if ((c = readchar(rs)) == ESCAPE) + return -1; + mpos = 0; + if (c == 'l' || c == 'L') + return LEFT; + else if (c == 'r' || c == 'R') + return RIGHT; + if (terse) + msg(rs,"L or R"); + else + msg(rs,"please type L or R"); } } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index d453a871f..8c1101fc6 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -612,7 +612,7 @@ void current(struct rogue_state *rs,THING *cur, char *how, char *where); void d_level(struct rogue_state *rs); void death(struct rogue_state *rs,char monst); char death_monst(void); -void dig(int y, int x); +void dig(struct rogue_state *rs,int y, int x); void discard(THING *item); void discovered(struct rogue_state *rs); int dist(int y1, int x1, int y2, int x2); @@ -620,7 +620,7 @@ int dist_cp(coord *c1, coord *c2); int do_chase(struct rogue_state *rs,THING *th); void do_daemons(struct rogue_state *rs,int flag); void do_fuses(struct rogue_state *rs,int flag); -void do_maze(struct room *rp); +void do_maze(struct rogue_state *rs,struct room *rp); void do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta); void do_move(struct rogue_state *rs,int dy, int dx); void do_passages(struct rogue_state *rs); @@ -632,7 +632,7 @@ void doadd(struct rogue_state *rs,char *fmt, va_list args); void door(struct room *rm, coord *cp); void door_open(struct rogue_state *rs,struct room *rp); void drain(struct rogue_state *rs); -void draw_room(struct room *rp); +void draw_room(struct rogue_state *rs,struct room *rp); void drop(struct rogue_state *rs); void eat(struct rogue_state *rs); size_t encread(char *start, size_t size, FILE *inf); @@ -761,7 +761,7 @@ bool chase(THING *tp, coord *ee); bool diag_ok(coord *sp, coord *ep); bool dropcheck(struct rogue_state *rs,THING *obj); bool fallpos(coord *pos, coord *newpos); -bool find_floor(struct room *rp, coord *cp, int limit, bool monst); +bool find_floor(struct rogue_state *rs,struct room *rp, coord *cp, int limit, bool monst); bool is_magic(THING *obj); bool is_symlink(char *sp); bool levit_check(struct rogue_state *rs); diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index 41041d627..67ca701d9 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -112,7 +112,7 @@ do_rooms(struct rogue_state *rs) rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x); rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y); } until (rp->r_pos.y != 0); - draw_room(rp); + draw_room(rs,rp); /* * Put the gold in */ @@ -122,7 +122,7 @@ do_rooms(struct rogue_state *rs) gold = new_item(); gold->o_goldval = rp->r_goldval = GOLDCALC; - find_floor(rp, &rp->r_gold, FALSE, FALSE); + find_floor(rs,rp, &rp->r_gold, FALSE, FALSE); gold->o_pos = rp->r_gold; chat(rp->r_gold.y, rp->r_gold.x) = GOLD; gold->o_flags = ISMANY; @@ -136,7 +136,7 @@ do_rooms(struct rogue_state *rs) if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25)) { tp = new_item(); - find_floor(rp, &mp, FALSE, TRUE); + find_floor(rs,rp, &mp, FALSE, TRUE); new_monster(rs,tp, randmonster(FALSE), &mp); give_pack(rs,tp); } @@ -150,12 +150,12 @@ do_rooms(struct rogue_state *rs) */ void -draw_room(struct room *rp) +draw_room(struct rogue_state *rs,struct room *rp) { int y, x; if (rp->r_flags & ISMAZE) - do_maze(rp); + do_maze(rs,rp); else { vert(rp, rp->r_pos.x); /* Draw left side */ @@ -211,7 +211,7 @@ static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1]; void -do_maze(struct room *rp) +do_maze(struct rogue_state *rs,struct room *rp) { SPOT *sp; int starty, startx; @@ -232,7 +232,7 @@ do_maze(struct room *rp) pos.y = starty + Starty; pos.x = startx + Startx; putpass(&pos); - dig(starty, startx); + dig(rs,starty, startx); } /* @@ -241,7 +241,7 @@ do_maze(struct room *rp) */ void -dig(int y, int x) +dig(struct rogue_state *rs,int y, int x) { coord *cp; int cnt, newy, newx, nexty = 0, nextx = 0; @@ -252,6 +252,8 @@ dig(int y, int x) for (;;) { + if ( rs->replaydone != 0 ) + return; cnt = 0; for (cp = del; cp <= &del[3]; cp++) { @@ -291,7 +293,7 @@ dig(int y, int x) pos.y = nexty + Starty; pos.x = nextx + Startx; putpass(&pos); - dig(nexty, nextx); + dig(rs,nexty, nextx); } } @@ -332,7 +334,7 @@ rnd_pos(struct room *rp, coord *cp) * pick a new room each time around the loop. */ bool -find_floor(struct room *rp, coord *cp, int limit, bool monst) +find_floor(struct rogue_state *rs,struct room *rp, coord *cp, int limit, bool monst) { PLACE *pp; int cnt; @@ -346,6 +348,8 @@ find_floor(struct room *rp, coord *cp, int limit, bool monst) cnt = limit; for (;;) { + if ( rs->replaydone != 0 ) + return(FALSE); if (limit && cnt-- == 0) return FALSE; if (pickroom) diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index f048f9423..cd559daef 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -158,7 +158,7 @@ do_zap(struct rogue_state *rs) { do { - find_floor(NULL, &new_pos, FALSE, TRUE); + find_floor(rs,NULL, &new_pos, FALSE, TRUE); } while (ce(new_pos, hero)); } else diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index e5a5eacf6..e313bf9d3 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -81,6 +81,8 @@ do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta) obj->o_pos = hero; for (;;) { + if ( rs->replaydone != 0 ) + return; /* * Erase the old one */ diff --git a/src/cc/rogue/wizard.c b/src/cc/rogue/wizard.c index ee16b2d9b..35ce9fb54 100644 --- a/src/cc/rogue/wizard.c +++ b/src/cc/rogue/wizard.c @@ -35,19 +35,21 @@ whatis(struct rogue_state *rs,bool insist, int type) for (;;) { - obj = get_item(rs,"identify", type); - if (insist) - { - if (n_objs == 0) - return; - else if (obj == NULL) - msg(rs,"you must identify something"); - else if (type && obj->o_type != type && - !(type == R_OR_S && (obj->o_type == RING || obj->o_type == STICK)) ) - msg(rs,"you must identify a %s", type_name(type)); - else - break; - } + if ( rs->replaydone != 0 ) + return; + obj = get_item(rs,"identify", type); + if (insist) + { + if (n_objs == 0) + return; + else if (obj == NULL) + msg(rs,"you must identify something"); + else if (type && obj->o_type != type && + !(type == R_OR_S && (obj->o_type == RING || obj->o_type == STICK)) ) + msg(rs,"you must identify a %s", type_name(type)); + else + break; + } else break; } @@ -202,7 +204,7 @@ teleport(struct rogue_state *rs) static coord c; mvaddch(hero.y, hero.x, floor_at()); - find_floor((struct room *) NULL, &c, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &c, FALSE, TRUE); if (roomin(rs,&c) != proom) { leave_room(rs,&hero); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f0453b66d..107e50e4d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -588,19 +588,18 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx numplayers = openslots = 0; if ( komodo_nextheight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) registration_open = 1; - fprintf(stderr,"players alive\n"); for (i=0; i ROGUE_MAXITERATIONS ) break; } - fprintf(stderr,"out of while\n"); if ( txid != zeroid ) { - fprintf(stderr,"get height of %s\n",txid.GetHex().c_str()); if ( myGetTransaction(txid,tx,hashBlock) != 0 ) { - fprintf(stderr,"got tx %s\n",txid.GetHex().c_str()); if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) { - fprintf(stderr,"got pindex %s\n",hashBlock.GetHex().c_str()); if ( pindex->GetHeight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) alive++; } } - fprintf(stderr,"got height of %s\n",txid.GetHex().c_str()); } } } else if ( registration_open != 0 ) openslots++; } - fprintf(stderr,"numalive.%d openslots.%d\n",alive,openslots); + //fprintf(stderr,"numalive.%d openslots.%d\n",alive,openslots); return(alive); } From 7a761304c516d4f517d3f344015073c795fb33b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 02:47:51 -1100 Subject: [PATCH 2765/3904] -print --- src/cc/CCtx.cpp | 2 +- src/cc/rogue_rpc.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 65aad8e3a..2b0893eb4 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -350,7 +350,7 @@ int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout) int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockflag) { CCoins coins; - fprintf(stderr,"CCgettxoud %s/v%d\n",txid.GetHex().c_str(),vout); + //fprintf(stderr,"CCgettxoud %s/v%d\n",txid.GetHex().c_str(),vout); if ( mempoolflag != 0 ) { if ( lockflag != 0 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 107e50e4d..2457f4f4b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -489,7 +489,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke playertxid = batontxid = zeroid; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -942,7 +942,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -968,7 +968,6 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto fclose(fp); } } - fprintf(stderr,"replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i Date: Fri, 1 Mar 2019 02:52:21 -1100 Subject: [PATCH 2766/3904] -print --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2457f4f4b..00fe4c842 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -936,6 +936,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto seed = 0; num = numkeys = 0; playertxid = zeroid; + str[0] = 0; if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) { if ( (retval= rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname)) == 0 ) @@ -977,7 +978,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { - //fprintf(stderr,"zero value character was killed -> no playerdata\n"); + fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); //P.gold = (P.gold * 8) / 10; if ( keystrokes != 0 ) @@ -985,6 +986,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto free(keystrokes); keystrokes = 0; *numkeysp = 0; + return(keystrokes); } } else From 448ecdbdd1f82d12b8f60ba096d648ab8227fb1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 08:51:11 -1100 Subject: [PATCH 2767/3904] +print --- src/komodo_bitcoind.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dbea7ba12..2387048cd 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2012,10 +2012,10 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - //int32_t i; - //for (i=0; ivtx[0].vout[1].nValue/COIN); + int32_t i; + for (i=0; ivtx[0].vout[1].nValue/COIN); if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) @@ -2031,7 +2031,13 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) matched = 25; if ( matched == 0 ) { - fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d] checktoshis.%llu\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2,(long long)checktoshis); + if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) + { + int32_t i; + for (i=0; i Date: Fri, 1 Mar 2019 08:57:28 -1100 Subject: [PATCH 2768/3904] -print --- src/komodo_bitcoind.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2387048cd..b846ba9d1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2012,10 +2012,13 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - int32_t i; - for (i=0; ivtx[0].vout[1].nValue/COIN); + if ( 0 ) + { + int32_t i; + for (i=0; ivtx[0].vout[1].nValue/COIN); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) @@ -2031,7 +2034,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) matched = 25; if ( matched == 0 ) { - if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) + if ( 0 && ASSETCHAINS_SCRIPTPUB.size() > 1 ) { int32_t i; for (i=0; i Date: Fri, 1 Mar 2019 19:31:48 -1100 Subject: [PATCH 2769/3904] Destpubtxid --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index b01a3bf1d..4841eb981 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3276,7 +3276,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } -int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 pubtxid,int64_t total,int32_t maxinputs,char *cmpaddr) +int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 destpubtxid,int64_t total,int32_t maxinputs,char *cmpaddr) { char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 checktxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; std::vector > unspentOutputs; @@ -3294,7 +3294,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && desttxid == checktxid ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && destpubtxid == checktxid ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From 92510adcf1b0d5a9effe37a1556b4b4dd22a479f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 20:51:03 -1100 Subject: [PATCH 2770/3904] Local files --- src/cc/rogue/rogue.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6cc51e04b..d0827ddbe 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -118,22 +118,21 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter) return(0); } -#ifdef test -int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) +int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) { char fname[1024]; FILE *fp; int32_t i,retflag = -1; + rs->counter++; roguefname(fname,rs->seed,rs->counter); if ( (fp= fopen(fname,"wb")) != 0 ) { if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num ) { - rs->counter++; rs->num = 0; retflag = 0; fclose(fp); if ( (fp= fopen("savefile","wb")) != 0 ) { - save_file(rs,fp,0); + //save_file(rs,fp,0); if ( 0 && (fp= fopen("savefile","rb")) != 0 ) { for (i=0; i<0x150; i++) @@ -150,7 +149,7 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) } else fprintf(stderr,"error creating (%s)\n",fname); return(retflag); } -#else +#endif #ifdef BUILD_ROGUE // stubs for inside daemon @@ -174,9 +173,10 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) //rs->keytxid = rogue_progress(rs,waitflag,rs->seed,&rs->buffered[rs->lastnum],rs->num - rs->lastnum); //rs->lastnum = rs->num; rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num); + flushkeystrokes_local(rs,waitflag); memset(rs->buffered,0,sizeof(rs->buffered)); - rs->num = 0; - rs->counter++; + //rs->num = 0; + //rs->counter++; } return(0); } From 3d8d0a3e21ef9fa87f9981f832402cb176559401 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 20:52:46 -1100 Subject: [PATCH 2771/3904] Endif --- src/cc/rogue/rogue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index d0827ddbe..d2eeb826d 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -120,6 +120,7 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter) int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) { +#ifndef BUILD_ROGUE char fname[1024]; FILE *fp; int32_t i,retflag = -1; rs->counter++; roguefname(fname,rs->seed,rs->counter); @@ -148,8 +149,10 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) } else fprintf(stderr,"error writing (%s)\n",fname); } else fprintf(stderr,"error creating (%s)\n",fname); return(retflag); -} +#else + return(0); #endif +} #ifdef BUILD_ROGUE // stubs for inside daemon From 42f52b2ffa5a9e867cc39973bf97df5b1a52e08f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 20:53:24 -1100 Subject: [PATCH 2772/3904] -endif --- src/cc/rogue/rogue.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index d2eeb826d..90045f083 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -244,7 +244,6 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu free(rs); return(n); } -#endif long get_filesize(FILE *fp) { From 07b3f1ab548152199ee82b79ff3be81f306a31b6 Mon Sep 17 00:00:00 2001 From: "Anton \"TonyL\" Lysakov" Date: Sat, 2 Mar 2019 15:40:35 +0700 Subject: [PATCH 2773/3904] ensuring that rogue update --- src/cc/makerogue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/makerogue b/src/cc/makerogue index 51caef6e2..f1f1452c0 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,5 +1,6 @@ #!/bin/sh cd rogue; +make clean; if [ "$HOST" = "x86_64-w64-mingw32" ]; then echo building rogue.exe... From 1db23db8b7392ead72cc00ce23a32085e0a4394d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 22:26:25 -1100 Subject: [PATCH 2774/3904] Enforce player data at height 50000 --- src/cc/rogue_rpc.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 00fe4c842..eee5bc9e9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1447,9 +1447,14 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; - if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) - return(true); + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,enabled = 0,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 ) + { + if (height < 21274 ) + return(true); + else if ( height > 50000 ) + enabled = 1; + } else enabled = 1; if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); @@ -1549,6 +1554,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C strcpy(laststr,cashstr); fprintf(stderr,"%s\n",cashstr); } + if ( enabled != 0 && tx.vout[2].nValue != cashout ) + return eval->Invalid("mismatched cashout amount"); } } if ( funcid == 'Q' ) From 72c2649727d90db9c0dba491a7ec4500cd1ca921 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 22:43:16 -1100 Subject: [PATCH 2775/3904] Enforce 63 bit nValue limits --- src/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 01e19628c..c88f1520a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1808,7 +1808,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; double dPriority = view.GetPriority(tx, chainActive.Height()); - + if ( KOMODO_BIT63SET(nValueOut) != 0 ) + return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); + // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; @@ -3371,6 +3373,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTimeStart = GetTimeMicros(); CAmount nFees = 0; int nInputs = 0; + uint64_t voutsum = 0,prevsum=0,valueout; int64_t interest,sum = 0; unsigned int nSigOps = 0; CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); @@ -3490,9 +3493,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin txdata.emplace_back(tx); + valueout = tx.GetValueOut(); + if ( KOMODO_BIT63SET(valueout) != 0 ) + return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); + prevsum = voutsum; + voutsum += valueout; + if ( KOMODO_BIT63SET(voutsum) != 0 ) + return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); + else if ( voutsum < prevsum ) + return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big"); if (!tx.IsCoinBase()) { - nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - tx.GetValueOut(); + nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - valueout; sum += interest; std::vector vChecks; From c3fcff8b3b9c31c03f11803a17d626cba1b33b67 Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Sat, 2 Mar 2019 10:57:05 +0100 Subject: [PATCH 2776/3904] add libboost-dev to README as dependency --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f112982d..d0bc3cf52 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Komodo is based on Zcash and has been extended by our innovative consensus algor ```shell #The following packages are needed: -sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl +sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl libboost-dev ``` ### Build Komodo From a5475a30dea8ae59b8b91465b2a9e130ccfdad58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 23:18:52 -1100 Subject: [PATCH 2777/3904] Change amulet level to 26 --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index eee5bc9e9..93eb22dc8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1084,8 +1084,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C if ( P.amulet != 0 ) mult *= 5; dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 21 ) - dungeonlevel = 21; + if ( P.amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; *cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel; if ( newdata == playerdata ) { From f9913c7a5a1501fdd0aa359178d399967b5e1b06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 23:33:41 -1100 Subject: [PATCH 2778/3904] Set max_money --- src/komodo_globals.h | 3 ++- src/komodo_utils.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 13de7c310..bfac8cb93 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -266,7 +266,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) } #define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) #define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) - + cur_money *= COIN; if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) @@ -278,5 +278,6 @@ uint64_t komodo_current_supply(uint32_t nHeight) return(KOMODO_MAXNVALUE); return(newval); } + fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); return(cur_money); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 65114c16b..56af296a6 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2049,9 +2049,9 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; - if ( MAX_MONEY <= 0 || MAX_MONEY > 10000100000LL*SATOSHIDEN ) - MAX_MONEY = 10000100000LL*SATOSHIDEN; - //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); + if ( MAX_MONEY <= 0 || MAX_MONEY > (uint64_t)90*1000*1000*1000*SATOSHIDEN ) + MAX_MONEY = (uint64_t)90*1000*1000*1000*SATOSHIDEN; + fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); uint16_t tmpport = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); if ( GetArg("-port",0) != 0 ) From 5a39e093312551e9c4c46f22b35e98d15cd18f2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 23:38:27 -1100 Subject: [PATCH 2779/3904] ASSETCHAINS_SUPPLY --- src/komodo_utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 56af296a6..e7d71e686 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1792,6 +1792,8 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_supply must be less than 90 billion\n"); exit(0); } + fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY); + ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); From fe8f69b08c44ed35bc57c22e08d3ec339639d084 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 23:42:00 -1100 Subject: [PATCH 2780/3904] unmult --- src/komodo_globals.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index bfac8cb93..7370e8c70 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -142,7 +142,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL; if ( ASSETCHAINS_LASTERA == 0 && ASSETCHAINS_REWARD[0] == 0 ) { - cur_money += (nHeight * 10000) / SATOSHIDEN; + cur_money += (nHeight * 10000);// / SATOSHIDEN; } else { @@ -266,7 +266,6 @@ uint64_t komodo_current_supply(uint32_t nHeight) } #define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) #define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) - cur_money *= COIN; if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) From 0cf62abcbd5769c5c18696903ea6239ea50d616e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 23:47:17 -1100 Subject: [PATCH 2781/3904] MAX_MONEY capped at 63 bits - 1 --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e7d71e686..3b7d06401 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2051,8 +2051,8 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; - if ( MAX_MONEY <= 0 || MAX_MONEY > (uint64_t)90*1000*1000*1000*SATOSHIDEN ) - MAX_MONEY = (uint64_t)90*1000*1000*1000*SATOSHIDEN; + if ( KOMODO_BIT63SET(MAX_MONEY) != 0 ) + MAX_MONEY = KOMODO_MAXNVALUE; fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); uint16_t tmpport = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); From a8ef36c29cfe8454c2e9d2d13de931c6dff14233 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Mar 2019 23:53:02 -1100 Subject: [PATCH 2782/3904] Test version --- src/cc/rogue/rogue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 8c1101fc6..b59ee710f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -60,7 +60,7 @@ #define MAXOBJ 9 #define MAXPACK 23 #define MAXTRAPS 10 -#define AMULETLEVEL 26 +#define AMULETLEVEL 3 //26 #define NUMTHINGS 7 /* number of types of things */ #define MAXPASS 13 /* upper limit on number of passages */ #define NUMLINES 24 From 5fde22c3d897fc71fae6b2b0e8876cd73493e9e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 00:33:39 -1100 Subject: [PATCH 2783/3904] Amulet -> level 26 --- src/cc/rogue/rogue.h | 2 +- src/utilstrencodings.cpp | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index b59ee710f..8c1101fc6 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -60,7 +60,7 @@ #define MAXOBJ 9 #define MAXPACK 23 #define MAXTRAPS 10 -#define AMULETLEVEL 3 //26 +#define AMULETLEVEL 26 #define NUMTHINGS 7 /* number of types of things */ #define MAXPASS 13 /* upper limit on number of passages */ #define NUMLINES 24 diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index ece2ec73e..f1cba3f43 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -419,10 +419,26 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) int mantissa_tzeros = 0; bool mantissa_sign = false; bool exponent_sign = false; - int ptr = 0; + int i,n,ptr = 0; char *str = val.c_str(); int end = val.size(); int point_ofs = 0; - + n = val.size(); + if ( n == 11 && (val[0] < '9' || val[1] < '3') ) + { + uint64_t val64 = 0; + for (i=0; i '9' ) + break; + val64 = (val64 * 10) + (val[i] - '0') + } + if ( i == n ) // 90000000000 + { + *amount_out = val64 * COIN; + fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)val64/COIN); + return(true); + } + } if (ptr < end && val[ptr] == '-') { mantissa_sign = true; ++ptr; From a99263b97e6061250d0edab74709466d234e9478 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 00:35:59 -1100 Subject: [PATCH 2784/3904] Syntax --- src/utilstrencodings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index f1cba3f43..e08993993 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -419,7 +419,7 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) int mantissa_tzeros = 0; bool mantissa_sign = false; bool exponent_sign = false; - int i,n,ptr = 0; char *str = val.c_str(); + int i,n,ptr = 0; char *str = (char *)val.c_str(); int end = val.size(); int point_ofs = 0; n = val.size(); @@ -430,7 +430,7 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) { if ( val[i] < '0' || val[i] > '9' ) break; - val64 = (val64 * 10) + (val[i] - '0') + val64 = (val64 * 10) + (val[i] - '0'); } if ( i == n ) // 90000000000 { From 59c289c8a2db0aaec825297a701c0528bf25ab06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 00:36:33 -1100 Subject: [PATCH 2785/3904] 100000000 --- src/utilstrencodings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index e08993993..861a07b03 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -434,7 +434,7 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) } if ( i == n ) // 90000000000 { - *amount_out = val64 * COIN; + *amount_out = val64 * 100000000; fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)val64/COIN); return(true); } From ef691d5a4c1601eed87aa2e237d8c428ba6ba13b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 00:37:14 -1100 Subject: [PATCH 2786/3904] 100000000 --- src/utilstrencodings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index 861a07b03..10902054f 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -435,7 +435,7 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) if ( i == n ) // 90000000000 { *amount_out = val64 * 100000000; - fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)val64/COIN); + fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)val64/100000000); return(true); } } From 9615ec75746118c5846c68f3ee9ec72a94d783bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 00:46:51 -1100 Subject: [PATCH 2787/3904] Test --- src/utilstrencodings.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index 10902054f..df788b2ab 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -435,7 +435,7 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) if ( i == n ) // 90000000000 { *amount_out = val64 * 100000000; - fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)val64/100000000); + fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)*amount_out/100000000); return(true); } } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 46cc71958..5200677fd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -421,7 +421,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Check amount if (nValue <= 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount"); - +fprintf(stderr,"nValue %.8f vs curBalance %.8f\n",(double)nValue/COIN,(double)curBalance/COIN); if (nValue > curBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); From 62cea0f4e863f3861054a8e35bcccdd8bdf766bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 01:18:01 -1100 Subject: [PATCH 2788/3904] +print --- src/main.cpp | 2 +- src/utilstrencodings.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c88f1520a..2aad3b9bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2870,7 +2870,7 @@ namespace { hasher << hashBlock; hasher << blockundo; if (hashChecksum != hasher.GetHash()) - return error("%s: Checksum mismatch", __func__); + return error("%s: Checksum mismatch %s vs %s", __func__,hashChecksum.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); return true; } diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index df788b2ab..d4bba72ee 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -435,7 +435,7 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) if ( i == n ) // 90000000000 { *amount_out = val64 * 100000000; - fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)*amount_out/100000000); + //fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)*amount_out/100000000); return(true); } } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5200677fd..6cf8eeed8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -421,7 +421,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Check amount if (nValue <= 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount"); -fprintf(stderr,"nValue %.8f vs curBalance %.8f\n",(double)nValue/COIN,(double)curBalance/COIN); +//fprintf(stderr,"nValue %.8f vs curBalance %.8f\n",(double)nValue/COIN,(double)curBalance/COIN); if (nValue > curBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); From 93ba595a83137d0cf75fa452abb626100a7acbe2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 01:51:51 -1100 Subject: [PATCH 2789/3904] +print --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2aad3b9bb..e02ec515b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2845,7 +2845,7 @@ namespace { hasher << hashBlock; hasher << blockundo; fileout << hasher.GetHash(); - +fprintf(stderr,"hashBlock.%s hasher.%s\n",hashBlock.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); return true; } @@ -2870,7 +2870,7 @@ namespace { hasher << hashBlock; hasher << blockundo; if (hashChecksum != hasher.GetHash()) - return error("%s: Checksum mismatch %s vs %s", __func__,hashChecksum.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); + return error("%s: %s Checksum mismatch %s vs %s", __func__,hashBlock.GetHex().c_str(),hashChecksum.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); return true; } @@ -3634,6 +3634,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; // Write undo information to disk + fprintf(stderr,"isNull %d vs isvalid %d nStatus %x\n",pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus); if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS)) { if (pindex->GetUndoPos().IsNull()) { @@ -3644,7 +3645,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"ConnectBlock: unexpected null pprev\n"); if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart())) return AbortNode(state, "Failed to write undo data"); - // update nUndoPos in block index pindex->nUndoPos = pos.nPos; pindex->nStatus |= BLOCK_HAVE_UNDO; From 4a8df61a7be185823547495e092ff34fa54129aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 01:54:50 -1100 Subject: [PATCH 2790/3904] +print --- src/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e02ec515b..1d7a6f8b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3634,10 +3634,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; // Write undo information to disk - fprintf(stderr,"isNull %d vs isvalid %d nStatus %x\n",pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus); + fprintf(stderr,"nFile.%d isNull %d vs isvalid %d nStatus %x\n",(int32_t)pindex->nFile,pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus); if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS)) { - if (pindex->GetUndoPos().IsNull()) { + if (pindex->GetUndoPos().IsNull()) + { CDiskBlockPos pos; if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40)) return error("ConnectBlock(): FindUndoPos failed"); @@ -3649,7 +3650,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin pindex->nUndoPos = pos.nPos; pindex->nStatus |= BLOCK_HAVE_UNDO; } - + // Now that all consensus rules have been validated, set nCachedBranchId. // Move this if BLOCK_VALID_CONSENSUS is ever altered. static_assert(BLOCK_VALID_CONSENSUS == BLOCK_VALID_SCRIPTS, @@ -3660,7 +3661,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } else if (pindex->pprev) { pindex->nCachedBranchId = pindex->pprev->nCachedBranchId; } - + pindex->RaiseValidity(BLOCK_VALID_SCRIPTS); setDirtyBlockIndex.insert(pindex); } From 00b0b26fd41cdf553082d8156b7863bdaf22e684 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 02:25:57 -1100 Subject: [PATCH 2791/3904] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1d7a6f8b1..e0b2ec8bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3634,7 +3634,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; // Write undo information to disk - fprintf(stderr,"nFile.%d isNull %d vs isvalid %d nStatus %x\n",(int32_t)pindex->nFile,pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus); + //fprintf(stderr,"nFile.%d isNull %d vs isvalid %d nStatus %x\n",(int32_t)pindex->nFile,pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus); if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS)) { if (pindex->GetUndoPos().IsNull()) From 1d0d663b920ca6899017afcf23eb1beb80e26a00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 02:33:02 -1100 Subject: [PATCH 2792/3904] Test --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index e0b2ec8bc..b97f04f63 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3499,7 +3499,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin prevsum = voutsum; voutsum += valueout; if ( KOMODO_BIT63SET(voutsum) != 0 ) + { + fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN); return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); + } else if ( voutsum < prevsum ) return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big"); if (!tx.IsCoinBase()) From 0c03bfd48e491a591d62b48f6e8d2cd891ec8f8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 02:40:49 -1100 Subject: [PATCH 2793/3904] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b97f04f63..1b88aecf7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2845,7 +2845,7 @@ namespace { hasher << hashBlock; hasher << blockundo; fileout << hasher.GetHash(); -fprintf(stderr,"hashBlock.%s hasher.%s\n",hashBlock.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); +//fprintf(stderr,"hashBlock.%s hasher.%s\n",hashBlock.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); return true; } From 16efbff11a7cae11be9466a506c121fc09db1356 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 02:55:51 -1100 Subject: [PATCH 2794/3904] Billion at a time --- src/komodo_globals.h | 2 ++ src/komodo_utils.h | 13 +++++++++++-- src/main.cpp | 6 +++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 7370e8c70..551a61704 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -266,6 +266,8 @@ uint64_t komodo_current_supply(uint32_t nHeight) } #define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) #define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) +#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000) + if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 3b7d06401..4086af94c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1639,9 +1639,18 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } } } - if ( nHeight == 1 ) + uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); + if ( ASSETCHAINS_SUPPLY > 1000000000 ) + { + if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 ) + { + subsidy = (uint64_t)1000000000 * COIN; + if ( nHeight == 1 ) + subsidy += magicExtra; + } + } + else if ( nHeight == 1 ) { - uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); if ( ASSETCHAINS_LASTERA == 0 ) subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; else diff --git a/src/main.cpp b/src/main.cpp index 1b88aecf7..603ad054c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1808,7 +1808,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; double dPriority = view.GetPriority(tx, chainActive.Height()); - if ( KOMODO_BIT63SET(nValueOut) != 0 ) + if ( KOMODO_VALUETOOBIG(nValueOut) != 0 ) return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); // Keep track of transactions that spend a coinbase, which we re-scan @@ -3494,11 +3494,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin txdata.emplace_back(tx); valueout = tx.GetValueOut(); - if ( KOMODO_BIT63SET(valueout) != 0 ) + if ( KOMODO_VALUETOOBIG(valueout) != 0 ) return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); prevsum = voutsum; voutsum += valueout; - if ( KOMODO_BIT63SET(voutsum) != 0 ) + if ( KOMODO_VALUETOOBIG(voutsum) != 0 ) { fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN); return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); From 36a8bd762f7fad8a42648a90ecfb5bfdbd8e7682 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:09:51 -1100 Subject: [PATCH 2795/3904] +print --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index a567e2e20..1e7d29ff1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -621,7 +621,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - + fprintf(stderr,"mine ht.%d with %.8f\n",(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); From 685b22266364e916a9a1be318e4ddad73711287f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:11:32 -1100 Subject: [PATCH 2796/3904] nHeight --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1e7d29ff1..556efb090 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -621,7 +621,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - fprintf(stderr,"mine ht.%d with %.8f\n",(double)txNew.vout[0].nValue/COIN); + fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); From 422b604ca59d6451b9aa8e61c5db07fc0b550a0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:16:51 -1100 Subject: [PATCH 2797/3904] Test --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 603ad054c..370e1e98b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3495,7 +3495,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin valueout = tx.GetValueOut(); if ( KOMODO_VALUETOOBIG(valueout) != 0 ) + { + fprintf(stderr,"valueout %.8f too big\n",(double)valueout/COIN); return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); + } prevsum = voutsum; voutsum += valueout; if ( KOMODO_VALUETOOBIG(voutsum) != 0 ) From de704db25fbbda344280b181be1ca09adb54c111 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:19:41 -1100 Subject: [PATCH 2798/3904] Too big --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 551a61704..a752d0b8b 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -266,7 +266,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) } #define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) #define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) -#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000) +#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN) if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); From e8afffb17b28bfb26878efa105b8d898e26e5ab0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:27:25 -1100 Subject: [PATCH 2799/3904] Prevent miner from mining too big a block in txvalue --- src/miner.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 556efb090..eb7c2d185 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -173,7 +173,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } else pk = _pk; - uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); + uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarisationBlock = false; std::vector NotarisationNotaries; //fprintf(stderr,"create new block\n"); @@ -221,6 +221,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint256 cbHash; + voutsum = GetBlockSubsidy(nHeight,consensusParams) + nFees; CBlockIndex* pindexPrev = 0; { ENTER_CRITICAL_SECTION(cs_main); @@ -270,7 +271,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 vecPriority.reserve(mempool.mapTx.size() + 1); // now add transactions from the mem pool - int32_t Notarisations = 0; + int32_t Notarisations = 0; uint64_t txvalue; for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) { @@ -285,7 +286,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); continue; } - + txvalue = tx.GetValueOut(); + if ( KOMODO_VALUETOOBIG(txvalue) != 0 ) + continue; + if ( KOMODO_VALUETOOBIG(txvalue + voutsum) != 0 ) + continue; + voutsum += txvalue; if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) { //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); @@ -621,7 +627,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); + //fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); From 1f4863694b87c1187943f1c58c3df356fc5469e8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:32:18 -1100 Subject: [PATCH 2800/3904] Move things --- src/komodo_defs.h | 4 ++++ src/komodo_globals.h | 6 +----- src/miner.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 2c3647b30..e1b941197 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -34,6 +34,10 @@ #define GETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] & (1 << ((bitoffset) & 7))) #define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7))) +#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) +#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) +#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN) + extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a752d0b8b..44c12bdf4 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -263,11 +263,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) } } } - } -#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) -#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) -#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN) - + } if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index eb7c2d185..2069e5a8c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -221,7 +221,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint256 cbHash; - voutsum = GetBlockSubsidy(nHeight,consensusParams) + nFees; CBlockIndex* pindexPrev = 0; { ENTER_CRITICAL_SECTION(cs_main); @@ -234,7 +233,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetAdjustedTime(); - + voutsum = GetBlockSubsidy(nHeight,consensusParams) + 10000*COIN; // approx fees + if (proposedTime == nMedianTimePast) { // too fast or stuck, this addresses the too fast issue, while moving From 4a77a2d625b4d9ba1e6270eab2017379caf28f31 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:35:56 -1100 Subject: [PATCH 2801/3904] Prevent too big tx to enter mempool --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 370e1e98b..08869080e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1808,7 +1808,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; double dPriority = view.GetPriority(tx, chainActive.Height()); - if ( KOMODO_VALUETOOBIG(nValueOut) != 0 ) + if ( KOMODO_VALUETOOBIG(nValueOut - 777777*COIN) != 0 ) // some room for blockreward and txfees return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); // Keep track of transactions that spend a coinbase, which we re-scan From 0ca3cae55691f96654c4f12cc5c0d923f544d1e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 03:43:08 -1100 Subject: [PATCH 2802/3904] Fix ac_subsidy calls --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4086af94c..e8608c8bd 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1644,9 +1644,9 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 ) { - subsidy = (uint64_t)1000000000 * COIN; + subsidy += (uint64_t)1000000000 * COIN; if ( nHeight == 1 ) - subsidy += magicExtra; + subsidy += (ASSETCHAINS_SUPPLY % 1000000000)*COIN + magicExtra; } } else if ( nHeight == 1 ) From f442acaeb6a6971ea5af00a72368dfc26538a3a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 04:15:55 -1100 Subject: [PATCH 2803/3904] > 10 billion exemption --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e8608c8bd..34d1d8d4d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1640,7 +1640,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } } uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); - if ( ASSETCHAINS_SUPPLY > 1000000000 ) + if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion? { if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 ) { From 92f2fe7cf05c561e1bc3858c753b3fad07d87a51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 04:20:03 -1100 Subject: [PATCH 2804/3904] Prevent > 10 billion for -ac_script/-ac_perc --- src/komodo_utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 34d1d8d4d..2c4a2d040 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1896,6 +1896,11 @@ void komodo_args(char *argv0) } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { + if ( ASSETCHAINS_SUPPLY > 10000000000 ) + { + printf("ac_pubkey or ac_script wont work with ac_supply over 10 billion\n"); + exit(0); + } if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n"); From c6322f54ec85bdef50bde970872cc1adbe82a45f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 05:18:27 -1100 Subject: [PATCH 2805/3904] Test slowflag --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b846ba9d1..53472ae63 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2125,7 +2125,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); else { - bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); + if ( slowflag != 0 ) + bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash > bnTarget ) { for (i=31; i>=16; i--) From 845ce0b543a1c4f5cb851216eeebef6146aa5452 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 05:30:10 -1100 Subject: [PATCH 2806/3904] Height 100 exception --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 53472ae63..70a1a7c02 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2125,9 +2125,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); else { - if ( slowflag != 0 ) - bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); - if ( bhash > bnTarget ) + bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); + if ( bhash > bnTarget && height > 100 ) { for (i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&bhash)[i]); @@ -2136,7 +2135,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED); return(-1); - } else + } + else { failed = 0; CBlockIndex *pindex; From 37086fe0a7a831360c3869862d5492426bb4d75e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 05:44:38 -1100 Subject: [PATCH 2807/3904] Fix mempool acceptance bug --- src/cc/dilithium.c | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 4841eb981..eb2b78ecc 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2944,7 +2944,7 @@ int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector vou for (i=0; i 777777*COIN && KOMODO_VALUETOOBIG(nValueOut - 777777*COIN) != 0 ) // some room for blockreward and txfees return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); // Keep track of transactions that spend a coinbase, which we re-scan From 76bb0a23608502b341b0a3d795486a541e5d1cb0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:41:09 -1100 Subject: [PATCH 2808/3904] +print --- src/komodo_globals.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 44c12bdf4..0abe48ace 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -264,6 +264,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) } } } + fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) From 1d692f4df361c88bce7527fd22dc643f128dc6c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:45:06 -1100 Subject: [PATCH 2809/3904] Fix maxmoney estimate for acPErc --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0abe48ace..0eaa430a3 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -269,7 +269,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) { - uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)); + uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)/COIN); if ( KOMODO_BIT63SET(newval) != 0 ) return(KOMODO_MAXNVALUE); else if ( newval < cur_money ) // check for underflow From ef8df0fd1bab6d0c61f9470acce3b62c4c9cba99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:49:37 -1100 Subject: [PATCH 2810/3904] +print --- src/komodo_globals.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0eaa430a3..096b31a37 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -169,7 +169,9 @@ uint64_t komodo_current_supply(uint32_t nHeight) if (!period) { // no halving, straight multiply + fprintf(stderr,"cur_money %.8f += %.8f * %d\n",(double)cur_money/COIN,(double)reward/COIN,nHeight); cur_money += reward * (nHeight - 1); + fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); } // if exactly SATOSHIDEN, linear decay to zero or to next era, same as: // (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks @@ -264,12 +266,11 @@ uint64_t komodo_current_supply(uint32_t nHeight) } } } - fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) { - uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)/COIN); + uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION)); if ( KOMODO_BIT63SET(newval) != 0 ) return(KOMODO_MAXNVALUE); else if ( newval < cur_money ) // check for underflow From 022cfeee63839ca1dded623ff626ed1316373f2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:54:50 -1100 Subject: [PATCH 2811/3904] +print --- src/komodo_globals.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 096b31a37..72f0ebbb7 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -134,9 +134,9 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint64_t cur_money; int32_t baseid; - if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 ) - cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; - else + //if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 ) + // cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; + //else { // figure out max_money by adding up supply to a maximum of 10,000,000 blocks cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL; @@ -155,6 +155,8 @@ uint64_t komodo_current_supply(uint32_t nHeight) // add rewards from this era, up to nHeight int64_t reward = ASSETCHAINS_REWARD[j]; + + fprintf(stderr,"last.%d reward %llu period %llu\n",ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); if ( reward > 0 ) { uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; From 25109df8ec4ce187e38a06c67f2927bcfd1c75d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:57:19 -1100 Subject: [PATCH 2812/3904] Test --- src/komodo_globals.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 72f0ebbb7..13ec6eb80 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -156,7 +156,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) // add rewards from this era, up to nHeight int64_t reward = ASSETCHAINS_REWARD[j]; - fprintf(stderr,"last.%d reward %llu period %llu\n",ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); + fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); if ( reward > 0 ) { uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; @@ -168,10 +168,10 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint32_t modulo = (curEnd - lastEnd) % period; uint64_t decay = ASSETCHAINS_DECAY[j]; + fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); if (!period) { // no halving, straight multiply - fprintf(stderr,"cur_money %.8f += %.8f * %d\n",(double)cur_money/COIN,(double)reward/COIN,nHeight); cur_money += reward * (nHeight - 1); fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); } From 9b9f61566d9198c9ebc25eb2ab916a84f8cecab1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 08:00:58 -1100 Subject: [PATCH 2813/3904] Fix maxmoney calc for period 0 chains --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 13ec6eb80..0cc5ab6f8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -169,7 +169,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint64_t decay = ASSETCHAINS_DECAY[j]; fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); - if (!period) + if ( ASSETCHAINS_HALVING[j] == 0 ) { // no halving, straight multiply cur_money += reward * (nHeight - 1); From 729edc4e80bb7095dfc72300f565c3c5f196eb34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 08:03:10 -1100 Subject: [PATCH 2814/3904] -print --- src/komodo_globals.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0cc5ab6f8..69ad6b840 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -156,7 +156,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) // add rewards from this era, up to nHeight int64_t reward = ASSETCHAINS_REWARD[j]; - fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); + //fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); if ( reward > 0 ) { uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; @@ -168,12 +168,12 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint32_t modulo = (curEnd - lastEnd) % period; uint64_t decay = ASSETCHAINS_DECAY[j]; - fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); + //fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); if ( ASSETCHAINS_HALVING[j] == 0 ) { // no halving, straight multiply cur_money += reward * (nHeight - 1); - fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); + //fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); } // if exactly SATOSHIDEN, linear decay to zero or to next era, same as: // (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks @@ -279,6 +279,6 @@ uint64_t komodo_current_supply(uint32_t nHeight) return(KOMODO_MAXNVALUE); return(newval); } - fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); + //fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); return(cur_money); } From 164b718ccd44755437b9f3b1f527838e00817692 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 09:19:05 -1100 Subject: [PATCH 2815/3904] Truncate next file --- src/cc/rogue/rogue.c | 2 +- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 90045f083..8406684c7 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -141,7 +141,7 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) fprintf(stderr," first part rnd.%d\n",rnd(1000)); fclose(fp); } - roguefname(fname,rs->seed,rs->counter); + roguefname(fname,rs->seed,rs->counter+1); if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file fclose(fp); //fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 93eb22dc8..c5370309d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1315,7 +1315,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr); a.push_back(obj); } - else + else if ( 0 ) { sprintf(str,"vout %d+1 is unspent",i); result.push_back(Pair("unspent",str)); From e3de4fd2ef5465b8b48fe4ab136639e037347093 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 20:06:11 -1100 Subject: [PATCH 2816/3904] +print --- src/cc/dilithium.c | 19 ++++++++++++++++++- src/cc/rogue/rogue.c | 8 ++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index eb2b78ecc..f646b53c4 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2940,11 +2940,17 @@ int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector vou { vintxids.push_back(tx.vin[i].prevout.hash); vinprevns.push_back(tx.vin[i].prevout.n); + fprintf(stderr,"%s/v%d ",tx.vin[i].prevout.hash.GetHex().c_str(),tx.vin[i].prevout.n); } for (i=0; iInvalid("failed dilithium verify"); else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) + { + for (i=0; i<32; i++) + fprintf(stderr,"%02x",msg[i]); + fprintf(stderr," vs "); + for (i=0; iInvalid("failed dilithium msg verify"); + } else return true; } } else return eval->Invalid("failed decode Qsend"); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 8406684c7..ca0c92343 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -131,21 +131,21 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) rs->num = 0; retflag = 0; fclose(fp); - if ( (fp= fopen("savefile","wb")) != 0 ) + /*if ( (fp= fopen("savefile","wb")) != 0 ) { - //save_file(rs,fp,0); + save_file(rs,fp,0); if ( 0 && (fp= fopen("savefile","rb")) != 0 ) { for (i=0; i<0x150; i++) fprintf(stderr,"%02x",fgetc(fp)); fprintf(stderr," first part rnd.%d\n",rnd(1000)); fclose(fp); - } + }*/ roguefname(fname,rs->seed,rs->counter+1); if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file fclose(fp); //fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag); - } + //} } else fprintf(stderr,"error writing (%s)\n",fname); } else fprintf(stderr,"error creating (%s)\n",fname); return(retflag); From b544ed791ca0aeb51a122e79becb6337f37b12da Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 20:16:46 -1100 Subject: [PATCH 2817/3904] Typo --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index f646b53c4..9dcc69b40 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3446,8 +3446,8 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co fprintf(stderr,"%02x",msg[i]); fprintf(stderr," vs "); for (i=0; iInvalid("failed dilithium msg verify"); } else return true; From 1a87dd883c53a057fbe39a3306cb67e162222a47 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 20:21:49 -1100 Subject: [PATCH 2818/3904] Recalc Qmsg --- src/cc/dilithium.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 9dcc69b40..da4576582 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2929,32 +2929,28 @@ int32_t main(void) void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); -int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector voutpubtxids) +int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector voutpubtxids) { CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; numvins = tx.vin.size(); - numvouts = tx.vout.size(); - if ( tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) + for (i=0; i bigpub) @@ -3373,7 +3369,7 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params voutpubtxids.push_back(mypubtxid); } tx = mtx; - dilithium_Qmsghash(msg,tx,voutpubtxids); + dilithium_Qmsghash(msg,tx,(int32_t)voutpubtxids.size(),voutpubtxids); for (i=0; i<32; i++) fprintf(stderr,"%02x",msg[i]); fprintf(stderr," msg\n"); @@ -3432,7 +3428,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co numvouts = tx.vout.size(); if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen ) { - if ( dilithium_Qmsghash(msg,tx,voutpubtxids) < 0 ) + if ( dilithium_Qmsghash(msg,tx,numvouts-1,voutpubtxids) < 0 ) return eval->Invalid("couldnt get Qmsghash"); else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 ) return eval->Invalid("couldnt get bigpub"); From e54f9c4850a648212eb9dd45e2ec23a0a6e59883 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 20:25:59 -1100 Subject: [PATCH 2819/3904] Nnumvouts --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index da4576582..0b7ccd667 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2931,7 +2931,7 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160, int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector voutpubtxids) { - CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; + CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; numvins = tx.vin.size(); for (i=0; i Date: Sat, 2 Mar 2019 20:28:02 -1100 Subject: [PATCH 2820/3904] -print --- src/cc/dilithium.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 0b7ccd667..e36ea807e 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2937,17 +2937,17 @@ int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::ve { vintxids.push_back(tx.vin[i].prevout.hash); vinprevns.push_back(tx.vin[i].prevout.n); - fprintf(stderr,"%s/v%d ",tx.vin[i].prevout.hash.GetHex().c_str(),tx.vin[i].prevout.n); + //fprintf(stderr,"%s/v%d ",tx.vin[i].prevout.hash.GetHex().c_str(),tx.vin[i].prevout.n); } for (i=0; i Date: Sat, 2 Mar 2019 21:39:07 -1100 Subject: [PATCH 2821/3904] +msg --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index f2d733a62..83762eaf7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4276,6 +4276,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" + _("Please help, human!"); LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); + fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); StartShutdown(); return false; From 78f4a6c6271259c4574b75d237804d2aa5b0dab7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 21:40:46 -1100 Subject: [PATCH 2822/3904] c_str() --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 83762eaf7..8e836ffa0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4276,7 +4276,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" + _("Please help, human!"); LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); - fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); + fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10); uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); StartShutdown(); return false; From 548c2819750936bf4b4c29806e3f8e60577b66bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 22:34:28 -1100 Subject: [PATCH 2823/3904] Extract zombies for comparison --- src/cc/rogue/main.c | 6 + src/cc/rogue/passages.c | 416 ++++++++++++++++++++-------------------- src/cc/rogue/rings.c | 128 ++++++------- src/cc/rogue/rogue.c | 18 +- src/cc/rogue_rpc.cpp | 8 +- 5 files changed, 296 insertions(+), 280 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 7b68aa49e..eeb085192 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -235,6 +235,7 @@ int32_t safecopy(char *dest,char *src,long len) #endif int32_t rogue_replay(uint64_t seed,int32_t sleeptime); +char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter); int rogue(int argc, char **argv, char **envp); void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) @@ -762,6 +763,11 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(rs->keystrokeshex), rs->keystrokeshex = 0; } + if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) + { + free(pastkeys); + } + for (i=0; iisconn[j] = FALSE; - r1->ingraph = FALSE; + for (j = 0; j < MAXROOMS; j++) + r1->isconn[j] = FALSE; + r1->ingraph = FALSE; } - + /* * starting with one room, connect it to a random adjacent room and * then pick a new room to start with. @@ -61,65 +61,65 @@ do_passages(struct rogue_state *rs) r1->ingraph = TRUE; do { - /* - * find a room to connect with - */ - j = 0; - for (i = 0; i < MAXROOMS; i++) - if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0) - r2 = &rdes[i]; - /* - * if no adjacent rooms are outside the graph, pick a new room - * to look from - */ - if (j == 0) - { - do - r1 = &rdes[rnd(MAXROOMS)]; - until (r1->ingraph); - } - /* - * otherwise, connect new room to the graph, and draw a tunnel - * to it - */ - else - { - r2->ingraph = TRUE; - i = (int)(r1 - rdes); - j = (int)(r2 - rdes); - conn(rs,i, j); - r1->isconn[j] = TRUE; - r2->isconn[i] = TRUE; - roomcount++; - } + /* + * find a room to connect with + */ + j = 0; + for (i = 0; i < MAXROOMS; i++) + if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0) + r2 = &rdes[i]; + /* + * if no adjacent rooms are outside the graph, pick a new room + * to look from + */ + if (j == 0) + { + do + r1 = &rdes[rnd(MAXROOMS)]; + until (r1->ingraph); + } + /* + * otherwise, connect new room to the graph, and draw a tunnel + * to it + */ + else + { + r2->ingraph = TRUE; + i = (int)(r1 - rdes); + j = (int)(r2 - rdes); + conn(rs,i, j); + r1->isconn[j] = TRUE; + r2->isconn[i] = TRUE; + roomcount++; + } } while (roomcount < MAXROOMS); - + /* * attempt to add passages to the graph a random number of times so * that there isn't always just one unique passage through it. */ for (roomcount = rnd(5); roomcount > 0; roomcount--) { - r1 = &rdes[rnd(MAXROOMS)]; /* a random room to look from */ - /* - * find an adjacent room not already connected - */ - j = 0; - for (i = 0; i < MAXROOMS; i++) - if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0) - r2 = &rdes[i]; - /* - * if there is one, connect it and look for the next added - * passage - */ - if (j != 0) - { - i = (int)(r1 - rdes); - j = (int)(r2 - rdes); - conn(rs,i, j); - r1->isconn[j] = TRUE; - r2->isconn[i] = TRUE; - } + r1 = &rdes[rnd(MAXROOMS)]; /* a random room to look from */ + /* + * find an adjacent room not already connected + */ + j = 0; + for (i = 0; i < MAXROOMS; i++) + if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0) + r2 = &rdes[i]; + /* + * if there is one, connect it and look for the next added + * passage + */ + if (j != 0) + { + i = (int)(r1 - rdes); + j = (int)(r2 - rdes); + conn(rs,i, j); + r1->isconn[j] = TRUE; + r2->isconn[i] = TRUE; + } } passnum(); } @@ -138,22 +138,22 @@ conn(struct rogue_state *rs,int r1, int r2) int rm; char direc; static coord del, curr, turn_delta, spos, epos; - + if (r1 < r2) { - rm = r1; - if (r1 + 1 == r2) - direc = 'r'; - else - direc = 'd'; + rm = r1; + if (r1 + 1 == r2) + direc = 'r'; + else + direc = 'd'; } else { - rm = r2; - if (r2 + 1 == r1) - direc = 'r'; - else - direc = 'd'; + rm = r2; + if (r2 + 1 == r1) + direc = 'r'; + else + direc = 'd'; } rpf = &rooms[rm]; /* @@ -162,75 +162,75 @@ conn(struct rogue_state *rs,int r1, int r2) */ if (direc == 'd') { - rmt = rm + 3; /* room # of dest */ - rpt = &rooms[rmt]; /* room pointer of dest */ - del.x = 0; /* direction of move */ - del.y = 1; - spos.x = rpf->r_pos.x; /* start of move */ - spos.y = rpf->r_pos.y; - epos.x = rpt->r_pos.x; /* end of move */ - epos.y = rpt->r_pos.y; - if (!(rpf->r_flags & ISGONE)) /* if not gone pick door pos */ - do - { - spos.x = rpf->r_pos.x + rnd(rpf->r_max.x - 2) + 1; - spos.y = rpf->r_pos.y + rpf->r_max.y - 1; - } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); - if (!(rpt->r_flags & ISGONE)) - do - { - epos.x = rpt->r_pos.x + rnd(rpt->r_max.x - 2) + 1; - } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); - distance = abs(spos.y - epos.y) - 1; /* distance to move */ - turn_delta.y = 0; /* direction to turn */ - turn_delta.x = (spos.x < epos.x ? 1 : -1); - turn_distance = abs(spos.x - epos.x); /* how far to turn */ + rmt = rm + 3; /* room # of dest */ + rpt = &rooms[rmt]; /* room pointer of dest */ + del.x = 0; /* direction of move */ + del.y = 1; + spos.x = rpf->r_pos.x; /* start of move */ + spos.y = rpf->r_pos.y; + epos.x = rpt->r_pos.x; /* end of move */ + epos.y = rpt->r_pos.y; + if (!(rpf->r_flags & ISGONE)) /* if not gone pick door pos */ + do + { + spos.x = rpf->r_pos.x + rnd(rpf->r_max.x - 2) + 1; + spos.y = rpf->r_pos.y + rpf->r_max.y - 1; + } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); + if (!(rpt->r_flags & ISGONE)) + do + { + epos.x = rpt->r_pos.x + rnd(rpt->r_max.x - 2) + 1; + } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); + distance = abs(spos.y - epos.y) - 1; /* distance to move */ + turn_delta.y = 0; /* direction to turn */ + turn_delta.x = (spos.x < epos.x ? 1 : -1); + turn_distance = abs(spos.x - epos.x); /* how far to turn */ } else if (direc == 'r') /* setup for moving right */ { - rmt = rm + 1; - rpt = &rooms[rmt]; - del.x = 1; - del.y = 0; - spos.x = rpf->r_pos.x; - spos.y = rpf->r_pos.y; - epos.x = rpt->r_pos.x; - epos.y = rpt->r_pos.y; - if (!(rpf->r_flags & ISGONE)) - do - { - spos.x = rpf->r_pos.x + rpf->r_max.x - 1; - spos.y = rpf->r_pos.y + rnd(rpf->r_max.y - 2) + 1; - } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); - if (!(rpt->r_flags & ISGONE)) - do - { - epos.y = rpt->r_pos.y + rnd(rpt->r_max.y - 2) + 1; - } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); - distance = abs(spos.x - epos.x) - 1; - turn_delta.y = (spos.y < epos.y ? 1 : -1); - turn_delta.x = 0; - turn_distance = abs(spos.y - epos.y); + rmt = rm + 1; + rpt = &rooms[rmt]; + del.x = 1; + del.y = 0; + spos.x = rpf->r_pos.x; + spos.y = rpf->r_pos.y; + epos.x = rpt->r_pos.x; + epos.y = rpt->r_pos.y; + if (!(rpf->r_flags & ISGONE)) + do + { + spos.x = rpf->r_pos.x + rpf->r_max.x - 1; + spos.y = rpf->r_pos.y + rnd(rpf->r_max.y - 2) + 1; + } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); + if (!(rpt->r_flags & ISGONE)) + do + { + epos.y = rpt->r_pos.y + rnd(rpt->r_max.y - 2) + 1; + } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); + distance = abs(spos.x - epos.x) - 1; + turn_delta.y = (spos.y < epos.y ? 1 : -1); + turn_delta.x = 0; + turn_distance = abs(spos.y - epos.y); } #ifdef MASTER else - debug("error in connection tables"); + debug("error in connection tables"); #endif - + turn_spot = rnd(distance - 1) + 1; /* where turn starts */ - + /* * Draw in the doors on either side of the passage or just put #'s * if the rooms are gone. */ if (!(rpf->r_flags & ISGONE)) - door(rpf, &spos); + door(rpf, &spos); else - putpass(&spos); + putpass(&spos); if (!(rpt->r_flags & ISGONE)) - door(rpt, &epos); + door(rpt, &epos); else - putpass(&epos); + putpass(&epos); /* * Get ready to move... */ @@ -238,31 +238,31 @@ conn(struct rogue_state *rs,int r1, int r2) curr.y = spos.y; while (distance > 0) { - /* - * Move to new position - */ - curr.x += del.x; - curr.y += del.y; - /* - * Check if we are at the turn place, if so do the turn - */ - if (distance == turn_spot) - while (turn_distance--) - { - putpass(&curr); - curr.x += turn_delta.x; - curr.y += turn_delta.y; - } - /* - * Continue digging along - */ - putpass(&curr); - distance--; + /* + * Move to new position + */ + curr.x += del.x; + curr.y += del.y; + /* + * Check if we are at the turn place, if so do the turn + */ + if (distance == turn_spot) + while (turn_distance--) + { + putpass(&curr); + curr.x += turn_delta.x; + curr.y += turn_delta.y; + } + /* + * Continue digging along + */ + putpass(&curr); + distance--; } curr.x += del.x; curr.y += del.y; if (!ce(curr, epos)) - msg(rs,"warning, connectivity problem on this level"); + msg(rs,"warning, connectivity problem on this level"); } /* @@ -274,13 +274,13 @@ void putpass(coord *cp) { PLACE *pp; - + pp = INDEX(cp->y, cp->x); pp->p_flags |= F_PASS; if (rnd(10) + 1 < level && rnd(40) == 0) - pp->p_flags &= ~F_REAL; + pp->p_flags &= ~F_REAL; else - pp->p_ch = PASSAGE; + pp->p_ch = PASSAGE; } /* @@ -293,23 +293,23 @@ void door(struct room *rm, coord *cp) { PLACE *pp; - + rm->r_exit[rm->r_nexits++] = *cp; - + if (rm->r_flags & ISMAZE) - return; - + return; + pp = INDEX(cp->y, cp->x); if (rnd(10) + 1 < level && rnd(5) == 0) { - if (cp->y == rm->r_pos.y || cp->y == rm->r_pos.y + rm->r_max.y - 1) - pp->p_ch = '-'; - else - pp->p_ch = '|'; - pp->p_flags &= ~F_REAL; + if (cp->y == rm->r_pos.y || cp->y == rm->r_pos.y + rm->r_max.y - 1) + pp->p_ch = '-'; + else + pp->p_ch = '|'; + pp->p_flags &= ~F_REAL; } else - pp->p_ch = DOOR; + pp->p_ch = DOOR; } #ifdef MASTER @@ -324,31 +324,31 @@ add_pass() PLACE *pp; int y, x; char ch; - + for (y = 1; y < NUMLINES - 1; y++) - for (x = 0; x < NUMCOLS; x++) - { - pp = INDEX(y, x); - if ((pp->p_flags & F_PASS) || pp->p_ch == DOOR || - (!(pp->p_flags&F_REAL) && (pp->p_ch == '|' || pp->p_ch == '-'))) - { - ch = pp->p_ch; - if (pp->p_flags & F_PASS) - ch = PASSAGE; - pp->p_flags |= F_SEEN; - move(y, x); - if (pp->p_monst != NULL) - pp->p_monst->t_oldch = pp->p_ch; - else if (pp->p_flags & F_REAL) - addch(ch); - else - { - standout(); - addch((pp->p_flags & F_PASS) ? PASSAGE : DOOR); - standend(); - } - } - } + for (x = 0; x < NUMCOLS; x++) + { + pp = INDEX(y, x); + if ((pp->p_flags & F_PASS) || pp->p_ch == DOOR || + (!(pp->p_flags&F_REAL) && (pp->p_ch == '|' || pp->p_ch == '-'))) + { + ch = pp->p_ch; + if (pp->p_flags & F_PASS) + ch = PASSAGE; + pp->p_flags |= F_SEEN; + move(y, x); + if (pp->p_monst != NULL) + pp->p_monst->t_oldch = pp->p_ch; + else if (pp->p_flags & F_REAL) + addch(ch); + else + { + standout(); + addch((pp->p_flags & F_PASS) ? PASSAGE : DOOR); + standend(); + } + } + } } #endif @@ -365,17 +365,17 @@ passnum() { struct room *rp; int i; - + pnum = 0; newpnum = FALSE; for (rp = passages; rp < &passages[MAXPASS]; rp++) - rp->r_nexits = 0; + rp->r_nexits = 0; for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) - for (i = 0; i < rp->r_nexits; i++) - { - newpnum ^= 1;//newpnum++; - numpass(rp->r_exit[i].y, rp->r_exit[i].x); - } + for (i = 0; i < rp->r_nexits; i++) + { + newpnum ^= 1;//newpnum++; + numpass(rp->r_exit[i].y, rp->r_exit[i].x); + } } /* @@ -389,30 +389,30 @@ numpass(int y, int x) char *fp; struct room *rp; char ch; - + if (x >= NUMCOLS || x < 0 || y >= NUMLINES || y <= 0) - return; + return; fp = &flat(y, x); if (*fp & F_PNUM) - return; + return; if (newpnum) { - pnum++; - newpnum = FALSE; + pnum++; + newpnum = FALSE; } /* * check to see if it is a door or secret door, i.e., a new exit, * or a numerable type of place */ if ((ch = chat(y, x)) == DOOR || - (!(*fp & F_REAL) && (ch == '|' || ch == '-'))) + (!(*fp & F_REAL) && (ch == '|' || ch == '-'))) { - rp = &passages[pnum]; - rp->r_exit[rp->r_nexits].y = y; - rp->r_exit[rp->r_nexits++].x = x; + rp = &passages[pnum]; + rp->r_exit[rp->r_nexits].y = y; + rp->r_exit[rp->r_nexits++].x = x; } else if (!(*fp & F_PASS)) - return; + return; *fp |= pnum; /* * recurse on the surrounding places diff --git a/src/cc/rogue/rings.c b/src/cc/rogue/rings.c index af6cc881b..f9ce50795 100644 --- a/src/cc/rogue/rings.c +++ b/src/cc/rogue/rings.c @@ -23,65 +23,65 @@ ring_on(struct rogue_state *rs) { THING *obj; int ring; - + obj = get_item(rs,"put on", RING); /* * Make certain that it is somethings that we want to wear */ if (obj == NULL) - return; + return; if (obj->o_type != RING) { - if (!terse) - msg(rs,"it would be difficult to wrap that around a finger"); - else - msg(rs,"not a ring"); - return; + if (!terse) + msg(rs,"it would be difficult to wrap that around a finger"); + else + msg(rs,"not a ring"); + return; } - + /* * find out which hand to put it on */ if (is_current(rs,obj)) - return; - + return; + if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) { - if ((ring = gethand(rs)) < 0) - return; + if ((ring = gethand(rs)) < 0) + return; } else if (cur_ring[LEFT] == NULL) - ring = LEFT; + ring = LEFT; else if (cur_ring[RIGHT] == NULL) - ring = RIGHT; + ring = RIGHT; else { - if (!terse) - msg(rs,"you already have a ring on each hand"); - else - msg(rs,"wearing two"); - return; + if (!terse) + msg(rs,"you already have a ring on each hand"); + else + msg(rs,"wearing two"); + return; } cur_ring[ring] = obj; - + /* * Calculate the effect it has on the poor guy. */ switch (obj->o_which) { - case R_ADDSTR: - chg_str(obj->o_arm); - break; - case R_SEEINVIS: - invis_on(); - break; - case R_AGGR: - aggravate(rs); - break; + case R_ADDSTR: + chg_str(obj->o_arm); + break; + case R_SEEINVIS: + invis_on(); + break; + case R_AGGR: + aggravate(rs); + break; } - + if (!terse) - addmsg(rs,"you are now wearing "); + addmsg(rs,"you are now wearing "); msg(rs,"%s (%c)", inv_name(obj, TRUE), obj->o_packch); } @@ -95,31 +95,31 @@ ring_off(struct rogue_state *rs) { int ring; THING *obj; - + if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) { - if (terse) - msg(rs,"no rings"); - else - msg(rs,"you aren't wearing any rings"); - return; + if (terse) + msg(rs,"no rings"); + else + msg(rs,"you aren't wearing any rings"); + return; } else if (cur_ring[LEFT] == NULL) - ring = RIGHT; + ring = RIGHT; else if (cur_ring[RIGHT] == NULL) - ring = LEFT; + ring = LEFT; else - if ((ring = gethand(rs)) < 0) - return; + if ((ring = gethand(rs)) < 0) + return; mpos = 0; obj = cur_ring[ring]; if (obj == NULL) { - msg(rs,"not wearing such a ring"); - return; + msg(rs,"not wearing such a ring"); + return; } if (dropcheck(rs,obj)) - msg(rs,"was wearing %s(%c)", inv_name(obj, TRUE), obj->o_packch); + msg(rs,"was wearing %s(%c)", inv_name(obj, TRUE), obj->o_packch); } /* @@ -163,21 +163,21 @@ ring_eat(int hand) THING *ring; int eat; static int uses[] = { - 1, /* R_PROTECT */ 1, /* R_ADDSTR */ - 1, /* R_SUSTSTR */ -3, /* R_SEARCH */ - -5, /* R_SEEINVIS */ 0, /* R_NOP */ - 0, /* R_AGGR */ -3, /* R_ADDHIT */ - -3, /* R_ADDDAM */ 2, /* R_REGEN */ - -2, /* R_DIGEST */ 0, /* R_TELEPORT */ - 1, /* R_STEALTH */ 1 /* R_SUSTARM */ + 1, /* R_PROTECT */ 1, /* R_ADDSTR */ + 1, /* R_SUSTSTR */ -3, /* R_SEARCH */ + -5, /* R_SEEINVIS */ 0, /* R_NOP */ + 0, /* R_AGGR */ -3, /* R_ADDHIT */ + -3, /* R_ADDDAM */ 2, /* R_REGEN */ + -2, /* R_DIGEST */ 0, /* R_TELEPORT */ + 1, /* R_STEALTH */ 1 /* R_SUSTARM */ }; - + if ((ring = cur_ring[hand]) == NULL) - return 0; + return 0; if ((eat = uses[ring->o_which]) < 0) - eat = (rnd(-eat) == 0); + eat = (rnd(-eat) == 0); if (ring->o_which == R_DIGEST) - eat = -eat; + eat = -eat; return eat; } @@ -189,18 +189,18 @@ char * ring_num(THING *obj) { static char buf[10]; - + if (!(obj->o_flags & ISKNOW)) - return ""; + return ""; switch (obj->o_which) { - case R_PROTECT: - case R_ADDSTR: - case R_ADDDAM: - case R_ADDHIT: - sprintf(buf, " [%s]", num(obj->o_arm, 0, RING)); - otherwise: - return ""; + case R_PROTECT: + case R_ADDSTR: + case R_ADDDAM: + case R_ADDHIT: + sprintf(buf, " [%s]", num(obj->o_arm, 0, RING)); + otherwise: + return ""; } return buf; } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index ca0c92343..57890207b 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -254,11 +254,10 @@ long get_filesize(FILE *fp) return(fsize); } -int32_t rogue_replay(uint64_t seed,int32_t sleeptime) +char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) { - FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0; - if ( seed == 0 ) - seed = 777; + char fname[1024],*keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; + *numkeysp = 0; while ( 1 ) { roguefname(fname,seed,counter); @@ -288,6 +287,16 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) counter++; fprintf(stderr,"loaded %ld from (%s) total %ld\n",fsize,fname,num); } + *numkeysp = num; + return(keystrokes); +} + +int32_t rogue_replay(uint64_t seed,int32_t sleeptime) +{ + FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0; + if ( seed == 0 ) + seed = 777; + keystrokes = rogue_keystrokesload(&num,seed,counter); if ( num > 0 ) { sprintf(fname,"rogue.%llu.player",(long long)seed); @@ -301,7 +310,6 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) fclose(fp); } rogue_replay2(0,seed,keystrokes,num,player,sleeptime); - mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); my_exit(0); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c5370309d..dce56f6a1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -978,16 +978,18 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { - fprintf(stderr,"zero value character was killed -> no playerdata\n"); + sprintf(str,"zero value character was killed -> no playerdata\n"); newdata.resize(0); - //P.gold = (P.gold * 8) / 10; + *numkeysp = numkeys; + return(keystrokes); + /* P.gold = (P.gold * 8) / 10; if ( keystrokes != 0 ) { free(keystrokes); keystrokes = 0; *numkeysp = 0; return(keystrokes); - } + }*/ } else { From 59725a3c3e47ee54cb068735360ae5b063dda2f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 22:36:38 -1100 Subject: [PATCH 2824/3904] Syntax --- src/cc/rogue/main.c | 2 +- src/cc/rogue/rogue.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index eeb085192..4e6221aa1 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -742,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson; + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys; int32_t i,numpastkeys; cJSON *retjson; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 57890207b..478e3d2ed 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -274,18 +274,19 @@ char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) { fprintf(stderr,"error reallocating keystrokes\n"); fclose(fp); - return(-1); + return(0); } if ( fread(&keystrokes[num],1,fsize,fp) != fsize ) { fprintf(stderr,"error reading keystrokes from (%s)\n",fname); fclose(fp); - return(-1); + free(keystrokes); + return(0); } fclose(fp); num += fsize; counter++; - fprintf(stderr,"loaded %ld from (%s) total %ld\n",fsize,fname,num); + fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); } *numkeysp = num; return(keystrokes); @@ -293,7 +294,7 @@ char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) int32_t rogue_replay(uint64_t seed,int32_t sleeptime) { - FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0; + FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0; if ( seed == 0 ) seed = 777; keystrokes = rogue_keystrokesload(&num,seed,counter); From 11800949cf914e5158d1ad49f04c3cd5cb1ed61b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 23:57:21 -1100 Subject: [PATCH 2825/3904] Token fill shouldn't be invalid --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index dce56f6a1..e7e809807 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1544,10 +1544,12 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) { fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + if ( enabled != 0 ) + return eval->Invalid("mismatched playerdata"); } if ( funcid == 'H' ) cashout *= 2; - if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout + if ( tokentx == 0 ) { static char laststr[512]; char cashstr[512]; sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); From e12cf5ad4fa5e88ea7f6793761284aeef3883e32 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 23:58:43 -1100 Subject: [PATCH 2826/3904] Cache prints --- src/cc/rogue_rpc.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e7e809807..af1cd9a43 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1541,9 +1541,15 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C // verify pk belongs to this tx if ( playerdata.size() > 0 ) { + static char laststr[512]; char cashstr[512]; if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) { - fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + sprintf(cashstr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } if ( enabled != 0 ) return eval->Invalid("mismatched playerdata"); } @@ -1551,7 +1557,6 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C cashout *= 2; if ( tokentx == 0 ) { - static char laststr[512]; char cashstr[512]; sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { From 66644afe27762540fa96d72f38fabb9e64b94f70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 00:07:42 -1100 Subject: [PATCH 2827/3904] Pritns --- src/cc/rogue_rpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index af1cd9a43..3318e4dc9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1544,7 +1544,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C static char laststr[512]; char cashstr[512]; if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) { - sprintf(cashstr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + sprintf(cashstr,"tokentx.%d decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); @@ -1555,15 +1555,15 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } if ( funcid == 'H' ) cashout *= 2; - if ( tokentx == 0 ) + //if ( tokentx == 0 ) { - sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + sprintf(cashstr,"tokentx.%d decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); fprintf(stderr,"%s\n",cashstr); } - if ( enabled != 0 && tx.vout[2].nValue != cashout ) + if ( tokentx == 0 && enabled != 0 && tx.vout[2].nValue != cashout ) return eval->Invalid("mismatched cashout amount"); } } From 71fbf19c478ca7afc43a7d6fac501eae7201d6f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 00:11:34 -1100 Subject: [PATCH 2828/3904] Test --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3318e4dc9..b690a583e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1468,7 +1468,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C funcid = script[1]; if ( (e= script[0]) == EVAL_TOKENS ) { - tokentx = 1; + tokentx = funcid; if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) { if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) @@ -1544,7 +1544,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C static char laststr[512]; char cashstr[512]; if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) { - sprintf(cashstr,"tokentx.%d decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); @@ -1557,7 +1557,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C cashout *= 2; //if ( tokentx == 0 ) { - sprintf(cashstr,"tokentx.%d decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); From 96d66260fc478925600fc5e1bed3725326d288fa Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Sun, 3 Mar 2019 13:37:32 +0100 Subject: [PATCH 2829/3904] remove libboost-dev dep --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0bc3cf52..0f112982d 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Komodo is based on Zcash and has been extended by our innovative consensus algor ```shell #The following packages are needed: -sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl libboost-dev +sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl ``` ### Build Komodo From 12b23c595d004423db1217ca87da7c4df10312f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 05:08:09 -1100 Subject: [PATCH 2830/3904] Remove voutsum overflow check, rely on monotonicity --- src/cc/rogue_rpc.cpp | 2 +- src/main.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b690a583e..164f50729 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1480,7 +1480,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( e == EVAL_ROGUE ) { //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); - if ( decoded == 0 ) + //if ( decoded == 0 ) { switch ( funcid ) { diff --git a/src/main.cpp b/src/main.cpp index 8e836ffa0..8ea3a499b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3373,8 +3373,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTimeStart = GetTimeMicros(); CAmount nFees = 0; int nInputs = 0; - uint64_t voutsum = 0,prevsum=0,valueout; - int64_t interest,sum = 0; + uint64_t valueout; + int64_t voutsum = 0,prevsum=0,interest,sum = 0; unsigned int nSigOps = 0; CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); std::vector > vPos; @@ -3501,12 +3501,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } prevsum = voutsum; voutsum += valueout; - if ( KOMODO_VALUETOOBIG(voutsum) != 0 ) + /*if ( KOMODO_VALUETOOBIG(voutsum) != 0 ) { fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN); return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); } - else if ( voutsum < prevsum ) + else*/ + if ( voutsum < prevsum ) return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big"); if (!tx.IsCoinBase()) { From e64f0f7bc6cd5d0fbb559a46b835035b20516963 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 05:30:49 -1100 Subject: [PATCH 2831/3904] 10 billion and 1 --- src/komodo_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index e1b941197..f17e14ebf 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -36,7 +36,7 @@ #define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) #define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) -#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN) +#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000001*COIN) extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); From 70ac45748f04b54831b6fe564ed91c6c863febc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 05:54:36 -1100 Subject: [PATCH 2832/3904] Skip revalidating player data on 't' --- src/cc/rogue_rpc.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 164f50729..f9a4ba79d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1480,7 +1480,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( e == EVAL_ROGUE ) { //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); - //if ( decoded == 0 ) + if ( decoded == 0 ) { switch ( funcid ) { @@ -1523,6 +1523,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C //if ( height > 20000 ) return eval->Invalid("couldnt decode H/Q opret"); } + fprintf(stderr,"height.%d decoded H/Q opret\n",height); // spending the baton proves it is the user if the pk is the signer // rest of validation is done below break; @@ -1538,8 +1539,14 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(true); case 'H': // win case 'Q': // bailout + if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) + { + //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); + //if ( height > 20000 ) + return eval->Invalid("couldnt decode H/Q opret"); + } // verify pk belongs to this tx - if ( playerdata.size() > 0 ) + if ( tokentx != 'c' && playerdata.size() > 0 ) { static char laststr[512]; char cashstr[512]; if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) @@ -1555,17 +1562,14 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } if ( funcid == 'H' ) cashout *= 2; - //if ( tokentx == 0 ) + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + if ( strcmp(laststr,cashstr) != 0 ) { - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); - if ( strcmp(laststr,cashstr) != 0 ) - { - strcpy(laststr,cashstr); - fprintf(stderr,"%s\n",cashstr); - } - if ( tokentx == 0 && enabled != 0 && tx.vout[2].nValue != cashout ) - return eval->Invalid("mismatched cashout amount"); + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); } + if ( enabled != 0 && tx.vout[2].nValue != cashout ) + return eval->Invalid("mismatched cashout amount"); } if ( funcid == 'Q' ) { From bbc9c187fb68abeb15abbff2d55c65b26739ffde Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 06:02:51 -1100 Subject: [PATCH 2833/3904] Check 'c' for valid player data --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f9a4ba79d..ce00ef043 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1517,7 +1517,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(true); break; case 'H': case 'Q': - if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) + /*if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) { //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); //if ( height > 20000 ) @@ -1525,7 +1525,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } fprintf(stderr,"height.%d decoded H/Q opret\n",height); // spending the baton proves it is the user if the pk is the signer - // rest of validation is done below + // rest of validation is done below*/ break; default: return eval->Invalid("illegal rogue non-decoded funcid"); @@ -1546,7 +1546,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("couldnt decode H/Q opret"); } // verify pk belongs to this tx - if ( tokentx != 'c' && playerdata.size() > 0 ) + if ( tokentx == 'c' && playerdata.size() > 0 ) { static char laststr[512]; char cashstr[512]; if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) From c816d2d558ec344e784d479857907eb64f7078ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 06:03:23 -1100 Subject: [PATCH 2834/3904] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ce00ef043..bfcdf1f92 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1562,7 +1562,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } if ( funcid == 'H' ) cashout *= 2; - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); From f005240c4fcaad778e66d122a7fded11b95a78ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 07:19:56 -1100 Subject: [PATCH 2835/3904] Remove voutsum check --- src/cc/rogue_rpc.cpp | 18 +++--------------- src/main.cpp | 6 +++--- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index bfcdf1f92..4e604cc84 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1499,9 +1499,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'R': if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) { - //fprintf(stderr,"height.%d couldnt decode register opret\n",height); - //if ( height > 20000 ) - return eval->Invalid("couldnt decode register opret"); + return eval->Invalid("couldnt decode register opret"); } // baton is created // validation is done below @@ -1509,23 +1507,13 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'K': if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) { - //fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height); - //if ( height > 20000 ) - return eval->Invalid("couldnt decode keystrokes opret"); + return eval->Invalid("couldnt decode keystrokes opret"); } // spending the baton proves it is the user if the pk is the signer return(true); break; case 'H': case 'Q': - /*if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) - { - //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); - //if ( height > 20000 ) - return eval->Invalid("couldnt decode H/Q opret"); - } - fprintf(stderr,"height.%d decoded H/Q opret\n",height); - // spending the baton proves it is the user if the pk is the signer - // rest of validation is done below*/ + // done in the next switch statement as there are some H/Q tx with playerdata which would skip this section break; default: return eval->Invalid("illegal rogue non-decoded funcid"); diff --git a/src/main.cpp b/src/main.cpp index 8ea3a499b..ce0760cf5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3506,9 +3506,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN); return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); } - else*/ - if ( voutsum < prevsum ) - return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big"); + else + if ( voutsum < prevsum ) // PRLPAY overflows this and it isnt a conclusive test anyway + return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");*/ if (!tx.IsCoinBase()) { nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - valueout; From e3b9f3cb215343895cbcbc2c2fbd96519c2f25d1 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Sun, 3 Mar 2019 20:16:32 +0100 Subject: [PATCH 2836/3904] Fix channelslist RPC. --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6cf8eeed8..6bd1802f0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5955,7 +5955,7 @@ UniValue channelslist(const UniValue& params, bool fHelp) { if ( fHelp || params.size() > 0 ) throw runtime_error("channelsinfo\n"); - if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) + if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); From a4ed36e3c4871a81161cda273f875fbb2bfa5de6 Mon Sep 17 00:00:00 2001 From: ca333 Date: Mon, 4 Mar 2019 00:18:45 +0100 Subject: [PATCH 2837/3904] windowsify rogue build (#1310) * update rogue makefile * update roguelib libs * update rogue makefile * update rogue libs * add ncurses * add rogue WIN artifacts --- .gitlab-ci.yml | 5 +++++ src/cc/Makefile_rogue | 2 +- src/cc/makerogue | 6 ++---- src/cc/rogue/Makefile_win | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9fb7a01b..fab986211 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,6 +71,10 @@ build:windows: - cp src/komodod.exe src/komodo-cli.exe src/komodo-tx.exe + src/cc/rogue/rogue.exe + zcutil/fetch-params.bat + src/cc/rogue/x86_64-w64-mingw32/libcurl-4.dll + src/cc/rogue/x86_64-w64-mingw32/libncursesw6.dll ${PACKAGE_DIR_WINDOWS} - zip -r ${PACKAGE_DIR_WINDOWS}.zip ${PACKAGE_DIR_WINDOWS} - md5sum ${AGAMA_ARTIFACTS_WINDOWS} > ${AGAMA_ARTIFACTS_WINDOWS_CHECKSUM} @@ -91,6 +95,7 @@ build:macos: key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" paths: - depends/built + allow_failure: true script: - zcutil/build-mac.sh -j$(sysctl -n hw.physicalcpu) - ./makeRelease.sh ${PACKAGE_DIR_MACOS} diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index a7c60f724..baf8767aa 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -4,7 +4,7 @@ CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -DBUILD_ROGUE -std=c++11 -arch x86_64 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/x86_64-w64-mingw32/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared +CFLAGS_WIN = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I./rogue/x86_64-w64-mingw32/include -I./rogue/x86_64-w64-mingw32/include/ncursesw -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) diff --git a/src/cc/makerogue b/src/cc/makerogue index f1f1452c0..ff16cbb16 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -5,12 +5,10 @@ make clean; if [ "$HOST" = "x86_64-w64-mingw32" ]; then echo building rogue.exe... ./configure --host=x86_64-w64-mingw32 - mkdir ncurses && cd ncurses echo $PWD - wget https://invisible-island.net/datafiles/release/mingw32.zip - unzip mingw32.zip && rm mingw32.zip + wget https://github.com/KomodoPlatform/rogue/releases/download/0.3.3b-01/x86_64-w64-mingw32.tar.gz + tar xvfz x86_64-w64-mingw32.tar.gz && rm x86_64-w64-mingw32.tar.gz echo lib archive cleaned - cd .. echo $PWD if make -f Makefile_win "$@"; then echo rogue.exe build SUCCESSFUL diff --git a/src/cc/rogue/Makefile_win b/src/cc/rogue/Makefile_win index 6e558960c..e5a36d9b4 100644 --- a/src/cc/rogue/Makefile_win +++ b/src/cc/rogue/Makefile_win @@ -26,10 +26,10 @@ O=o CC = x86_64-w64-mingw32-gcc #CFLAGS=-O2 -CFLAGS= -g -O2 -I./ncurses/include -I./ncurses/include/ncursesw -I../../../depends/x86_64-w64-mingw32/include +CFLAGS= -g -O2 -I./x86_64-w64-mingw32/include -I./x86_64-w64-mingw32/include/ncursesw #LIBS=-lcurses -LIBS = -L./ncurses/lib -lncursesw -lcurl +LIBS = -L./x86_64-w64-mingw32/lib -lncursesw -lcurl #RM=rm -f RM = rm -f From c99801952b06ee192aff6b87ae6577438c8c36ce Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 3 Mar 2019 18:27:50 -0500 Subject: [PATCH 2838/3904] Teach RPC interface about dpow-enabled minconfs (#1231) * Make minconfs dpow-aware in z_listunspent + z_listreceivedbyaddress * Add dpow-related test files to test suite * Add dpow simulation to regtest every 7 blocks * Fix compiler errors * Fix link error * Fix stdout spam when running regtests * Dpowminconfs for listreceivedbyaddress * dpowconfs tests * Start adding specific tests for dpowminconfs in listreceivedbyaddress * Get dpowminconfs tests for listreceivedbyaddress working * Add dpowminconfs to getreceivedbyaddress + listunspent * Add test for listtransactions + getreceivedbyaddress support * Reliably passing dpowminconf tests. We only check for notarized-ness now, not exact confirmation numbers, to avoid race conditions * Poll for the expected notarization info before running further tests; add support for getbalance * Migrate tx_height() to a place where asyncrpcoperation_sendmany.cpp can use it * fix * Teach GetFilteredNotes about dpowconfs Many RPCs rely on this internal function, which now correctly uses dpowconfs to filter by the minconf/maxconf parameters. * Fix sendmany when using non-default minconf * inline seems to make things happy * cleanup * Add some code to test z_sendmany, which points out https://github.com/jl777/komodo/issues/1247 * try this * Use already calculated value of dpowconfs instead of calculating it again --- qa/pull-tester/rpc-tests.sh | 2 + qa/rpc-tests/dpowconfs.py | 151 +++++++++++++++++ qa/rpc-tests/test_framework/util.py | 10 +- src/komodo.h | 9 + src/komodo_bitcoind.h | 19 +++ src/komodo_defs.h | 1 + src/komodo_notary.h | 1 - src/komodo_utils.h | 3 +- src/wallet/asyncrpcoperation_sendmany.cpp | 14 +- src/wallet/rpcwallet.cpp | 190 ++++++++++++---------- src/wallet/wallet.cpp | 21 ++- src/wallet/wallet.h | 1 + 12 files changed, 324 insertions(+), 98 deletions(-) create mode 100755 qa/rpc-tests/dpowconfs.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 226c16b11..c4775fa85 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -11,6 +11,8 @@ export BITCOIND=${REAL_BITCOIND} #Run the tests testScripts=( + 'dpow.py' + 'dpowconfs.py' 'ac_private.py' 'verushash.py' 'paymentdisclosure.py' diff --git a/qa/rpc-tests/dpowconfs.py b/qa/rpc-tests/dpowconfs.py new file mode 100755 index 000000000..9c449923e --- /dev/null +++ b/qa/rpc-tests/dpowconfs.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 The Hush developers +# Copyright (c) 2019 The SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * +import time + +class DPoWConfsTest(BitcoinTestFramework): + def debug_info(self): + rpc = self.nodes[0] + print "-- DEBUG --" + getinfo = rpc.getinfo() + getwalletinfo = rpc.getwalletinfo() + listreceivedbyaddress = rpc.listreceivedbyaddress() + print "notarized=", getinfo['notarized'], " blocks=", getinfo['blocks'] + #print "getinfo=", getinfo + print "balance=", getwalletinfo['balance'] + #print "getwalletinfo=", getwalletinfo + print "listreceivedbyaddress=", listreceivedbyaddress + print "-- DEBUG --" + + def setup_chain(self): + self.num_nodes = 1 + print("Initializing DPoWconfs test directory "+self.options.tmpdir) + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self): + print("Setting up network...") + self.nodes = [] + self.is_network_split = False + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.nodes = start_nodes( self.num_nodes, self.options.tmpdir, + extra_args=[[ + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + #'-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ]] + ) + self.sync_all() + + def run_test(self): + rpc = self.nodes[0] + # 98 is notarized, next will be 105. Must mine at least 101 + # blocks for 100 block maturity rule + blockhashes = rpc.generate(101) + # block 98, this is 0 indexed + notarizedhash = blockhashes[97] + self.debug_info() + + taddr = rpc.getnewaddress() + txid = rpc.sendtoaddress(taddr, 5.55) + # blocks 102,103 + rpc.generate(2) + self.debug_info() + + info = rpc.getinfo() + print "notarizedhash=", notarizedhash, "\n" + print "info[notarizedhash]", info['notarizedhash'], "\n" + assert_equal( info['notarizedhash'], notarizedhash) + + result = rpc.listunspent() + + # this xtn has 2 raw confs, but not in a notarized block, + # so dpowconfs holds it at 1 + for res in result: + if (res['address'] == taddr and res['generated'] == 'false'): + assert_equal( result[0]['confirmations'], 1 ) + assert_equal( result[0]['rawconfirmations'], 2 ) + + # we will now have 3 rawconfs but confirmations=1 because not notarized + # block 104 + rpc.generate(1) + self.debug_info() + minconf = 2 + result = rpc.listreceivedbyaddress(minconf) + print "listreceivedbyaddress(2)=", result, "\n" + + # nothing is notarized, so we should see no results for minconf=2 + assert len(result) == 0 + + print "getreceivedaddress" + received = rpc.getreceivedbyaddress(taddr, minconf) + assert_equal( received, 0.00000000) + + #received = rpc.getreceivedbyaddress(taddr) + #assert_equal( received, "5.55000000") + taddr = rpc.getnewaddress() + zaddr = rpc.z_getnewaddress() + # should get insufficient funds error + recipients = [ { "amount" : Decimal('4.20'), "address" : zaddr } ] + txid = rpc.z_sendmany( taddr, recipients, minconf) + + # generate a notarized block, block 105 and block 106 + # only generating the notarized block seems to have + # race conditions about whether the block is notarized + txids = rpc.generate(2) + self.debug_info() + + getinfo = rpc.getinfo() + # try to allow notarization data to update + print "Sleeping" + while (getinfo['blocks'] != 106) or (getinfo['notarized'] != 105): + printf(".") + time.sleep(1) + getinfo = rpc.getinfo() + + # make sure this block was notarized as we expect + #assert_equal(getinfo['blocks'], getinfo['notarized']) + #assert_equal(getinfo['notarizedhash'], txids[0]) + + result = rpc.listreceivedbyaddress(minconf) + print "listreceivedbyaddress(2)=", result + + assert_equal( len(result), 1, 'got one xtn with minconf=2' ) + + # verify we see the correct dpowconfs + rawconfs + assert_greater_than( result[0]['confirmations'], 1) + assert_greater_than( result[0]['rawconfirmations'], 1) + + print "listtransactions" + xtns = rpc.listtransactions() + # verify this rpc agrees with listreceivedbyaddress + assert_greater_than(xtns[0]['confirmations'], 1) + assert_greater_than(xtns[0]['rawconfirmations'], 1) + + print "getreceivedaddress" + received = rpc.getreceivedbyaddress(taddr, minconf) + assert_equal( "%.8f" % received, "5.55000000") + + received = rpc.getreceivedbyaddress(taddr) + assert_equal( "%.8f" % received, "5.55000000") + +if __name__ == '__main__': + DPoWConfsTest().main() diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index e9130171b..6bcf4cd18 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -1,9 +1,7 @@ # Copyright (c) 2014 The Bitcoin Core developers -# Copyright (c) 2018 The SuperNET developers +# Copyright (c) 2018-2019 The SuperNET developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. - - # # Helpful routines for regression testing # @@ -415,10 +413,16 @@ def assert_true(condition, message = ""): def assert_false(condition, message = ""): assert_true(not condition, message) +# assert thing2 > thing1 def assert_greater_than(thing1, thing2): if thing1 <= thing2: raise AssertionError("%s <= %s"%(str(thing1),str(thing2))) +# assert thing2 >= thing1 +def assert_greater_than_or_equal(thing1, thing2): + if thing1 < thing2: + raise AssertionError("%s < %s"%(str(thing1),str(thing2))) + def assert_raises(exc, fun, *args, **kwds): try: fun(*args, **kwds) diff --git a/src/komodo.h b/src/komodo.h index bd3550e38..791adba33 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -27,6 +27,8 @@ #define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) +extern int32_t NOTARIZED_HEIGHT; +uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; #include #include @@ -930,6 +932,13 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) } notarized = 1; } + // simulate DPoW in regtest mode for dpowconfs tests/etc + if ( Params().NetworkIDString() == "regtest" && ( height%7 == 0) ) { + notarized = 1; + sp->NOTARIZED_HEIGHT = height; + sp->NOTARIZED_HASH = block.GetHash(); + sp->NOTARIZED_DESTTXID = txhash; + } if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("(tx.%d: ",i); for (j=0; jptr[0] = '\0'; } +int tx_height( const uint256 &hash ){ + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(hash, tx, hashBlock, true)) { + fprintf(stderr,"tx hash %s does not exist!\n", hash.ToString().c_str() ); + } + + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + return nHeight; +} + + /************************************************************************ * * Use the "writer" to accumulate text until done diff --git a/src/komodo_defs.h b/src/komodo_defs.h index f17e14ebf..cbf84b7f0 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -78,6 +78,7 @@ extern int32_t VERUS_MIN_STAKEAGE; extern std::string DONATION_PUBKEY; extern uint8_t ASSETCHAINS_PRIVATE; extern int32_t USE_EXTERNAL_PUBKEY; +int tx_height( const uint256 &hash ); extern char NOTARYADDRS[64][36]; extern uint8_t NUM_NOTARIES; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c4984cee2..5cdbf237d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -15,7 +15,6 @@ #include "komodo_defs.h" - #include "komodo_cJSON.h" #include "notaries_staked.h" diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2c4a2d040..079ce1eea 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1366,7 +1366,8 @@ void komodo_statefname(char *fname,char *symbol,char *str) fname[len - n] = 0; else { - printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]); + if ( strcmp(symbol,"REGTEST") != 0 ) + printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]); return; } } diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index d4c5077cc..0ea17a5f8 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -54,6 +54,8 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[65]; +int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +int tx_height( const uint256 &hash ); extern UniValue signrawtransaction(const UniValue& params, bool fHelp); extern UniValue sendrawtransaction(const UniValue& params, bool fHelp); @@ -1049,8 +1051,16 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { continue; } - if (out.nDepth < mindepth_) { - continue; + if( mindepth_ > 1 ) { + int nHeight = tx_height(out.tx->GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, out.nDepth); + if (dpowconfs < mindepth_) { + continue; + } + } else { + if (out.nDepth < mindepth_) { + continue; + } } const CScript &scriptPubKey = out.tx->vout[out.i].scriptPubKey; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6bd1802f0..2397be883 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -84,6 +84,8 @@ UniValue z_getoperationstatus_IMPL(const UniValue&, bool); #define PLAN_NAME_MAX 8 #define VALID_PLAN_NAME(x) (strlen(x) <= PLAN_NAME_MAX) +int tx_height( const uint256 &hash ); + std::string HelpRequiringPassphrase() { return pwalletMain && pwalletMain->IsCrypted() @@ -933,9 +935,20 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) continue; BOOST_FOREACH(const CTxOut& txout, wtx.vout) - if (txout.scriptPubKey == scriptPubKey) - if (wtx.GetDepthInMainChain() >= nMinDepth) - nAmount += txout.nValue; // komodo_interest? + if (txout.scriptPubKey == scriptPubKey) { + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs >= nMinDepth) { + nAmount += txout.nValue; // komodo_interest? + } + } else { + if (nDepth >= nMinDepth) { + nAmount += txout.nValue; // komodo_interest? + } + } + } } return ValueFromAmount(nAmount); @@ -1013,8 +1026,18 @@ CAmount GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi CAmount nReceived, nSent, nFee; wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee, filter); - if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) - nBalance += nReceived; + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (nReceived != 0 && dpowconfs >= nMinDepth) { + nBalance += nReceived; + } + } else { + if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) { + nBalance += nReceived; + } + } nBalance -= nSent + nFee; } @@ -1186,10 +1209,20 @@ UniValue getbalance(const UniValue& params, bool fHelp) list listReceived; list listSent; wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); - if (wtx.GetDepthInMainChain() >= nMinDepth) - { - BOOST_FOREACH(const COutputEntry& r, listReceived) - nBalance += r.amount; + + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs >= nMinDepth) { + BOOST_FOREACH(const COutputEntry& r, listReceived) + nBalance += r.amount; + } + } else { + if (nDepth >= nMinDepth) { + BOOST_FOREACH(const COutputEntry& r, listReceived) + nBalance += r.amount; + } } BOOST_FOREACH(const COutputEntry& s, listSent) nBalance -= s.amount; @@ -1460,8 +1493,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) EnsureWalletIsUnlocked(); // Check funds - CAmount nBalance = pwalletMain->GetBalance(); - //CAmount nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE); + CAmount nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE); if (totalAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); @@ -1572,9 +1604,16 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) if (wtx.IsCoinBase() || !CheckFinalTx(wtx)) continue; - int nDepth = wtx.GetDepthInMainChain(); - if (nDepth < nMinDepth) - continue; + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs < nMinDepth) + continue; + } else { + if (nDepth < nMinDepth) + continue; + } BOOST_FOREACH(const CTxOut& txout, wtx.vout) { @@ -2851,8 +2890,16 @@ UniValue listunspent(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); BOOST_FOREACH(const COutput& out, vecOutputs) { - if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) - continue; + int nDepth = out.tx->GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(out.tx->GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs < nMinDepth || dpowconfs > nMaxDepth) + continue; + } else { + if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) + continue; + } CTxDestination address; const CScript& scriptPubKey = out.tx->vout[out.i].scriptPubKey; @@ -3068,28 +3115,17 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; + + int nHeight = tx_height(entry.jsop.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("jsindex", (int)entry.jsop.js )); obj.push_back(Pair("jsoutindex", (int)entry.jsop.n)); - - if (!GetTransaction(entry.jsop.hash, tx, hashBlock, true)) { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() ); - } - - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); bool hasSproutSpendingKey = pwalletMain->HaveSproutSpendingKey(boost::get(entry.address)); obj.push_back(Pair("spendable", hasSproutSpendingKey)); @@ -3105,25 +3141,17 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) for (auto & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); + + int nHeight = tx_height(entry.op.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; + obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("outindex", (int)entry.op.n)); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; - if (!GetTransaction(entry.op.hash, tx, hashBlock, true)) { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"tx hash %s does not exist!\n", entry.op.hash.ToString().c_str() ); - } - - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); libzcash::SaplingIncomingViewingKey ivk; libzcash::SaplingFullViewingKey fvk; @@ -3144,7 +3172,6 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) return results; } - UniValue fundrawtransaction(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -3795,8 +3822,17 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); BOOST_FOREACH(const COutput& out, vecOutputs) { - if (out.nDepth < minDepth) { - continue; + int nDepth = out.tx->GetDepthInMainChain(); + if( minDepth > 1 ) { + int nHeight = tx_height(out.tx->GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs < minDepth) { + continue; + } + } else { + if (out.nDepth < minDepth) { + continue; + } } if (ignoreUnspendable && !out.fSpendable) { @@ -3901,21 +3937,11 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) if (boost::get(&zaddr) != nullptr) { for (CSproutNotePlaintextEntry & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; - - if (GetTransaction(entry.jsop.hash, tx, hashBlock, true)) { - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - } else { - fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() ); - } + int nHeight = tx_height(entry.jsop.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value())))); @@ -3924,7 +3950,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) obj.push_back(Pair("jsindex", entry.jsop.js)); obj.push_back(Pair("jsoutindex", entry.jsop.n)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSproutChange(nullifierSet, entry.address, entry.jsop))); } @@ -3933,27 +3959,19 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) } else if (boost::get(&zaddr) != nullptr) { for (SaplingNoteEntry & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; - if (GetTransaction(entry.op.hash, tx, hashBlock, true)) { - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - } else { - fprintf(stderr,"tx hash %s does not exist!\n", entry.op.hash.ToString().c_str() ); - } + int nHeight = tx_height(entry.op.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; + obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.note.value())))); obj.push_back(Pair("memo", HexStr(entry.memo))); obj.push_back(Pair("outindex", (int)entry.op.n)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSaplingChange(nullifierSet, entry.address, entry.op))); } @@ -8024,8 +8042,6 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_HEIR); return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); - - } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 82642df00..9cf2a86cb 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -60,6 +60,9 @@ bool fPayAtLeastCustomFee = true; #include "komodo_defs.h" CBlockIndex *komodo_chainactive(int32_t height); +extern std::string DONATION_PUBKEY; +int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +int tx_height( const uint256 &hash ); /** * Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) @@ -4966,11 +4969,21 @@ void CWallet::GetFilteredNotes( CWalletTx wtx = p.second; // Filter the transactions before checking for notes - if (!CheckFinalTx(wtx) || - wtx.GetBlocksToMaturity() > 0 || - wtx.GetDepthInMainChain() < minDepth || - wtx.GetDepthInMainChain() > maxDepth) { + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0) continue; + + if (minDepth > 1) { + int nHeight = tx_height(wtx.GetHash()); + int nDepth = wtx.GetDepthInMainChain(); + int dpowconfs = komodo_dpowconfs(nHeight,nDepth); + if ( dpowconfs < minDepth || dpowconfs > maxDepth) { + continue; + } + } else { + if ( wtx.GetDepthInMainChain() < minDepth || + wtx.GetDepthInMainChain() > maxDepth) { + continue; + } } for (auto & pair : wtx.mapSproutNoteData) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 663e60367..10aa83ce6 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -60,6 +60,7 @@ extern bool bSpendZeroConfChange; extern bool fSendFreeTransactions; extern bool fPayAtLeastCustomFee; + //! -paytxfee default static const CAmount DEFAULT_TRANSACTION_FEE = 0; //! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB From a3b4e026dae1ca7660a1799250ececb43ff125b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 21:21:55 -1100 Subject: [PATCH 2839/3904] Cleanup .pack file --- src/cc/rogue/main.c | 2 ++ src/cc/rogue_rpc.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 4e6221aa1..5e79e399e 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -763,6 +763,8 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(rs->keystrokeshex), rs->keystrokeshex = 0; } + // extract and get keystrokes field and compare it to pastkeys + // if not matching... panic? if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { free(pastkeys); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4e604cc84..c92a52725 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1071,7 +1071,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed,mult = 10; CPubKey roguepk; struct rogue_player P; + char str[512],*keystrokes,rogueaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed,mult = 10; CPubKey roguepk; struct rogue_player P; *cashoutp = 0; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); @@ -1080,6 +1080,9 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C { //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); + sprintf(fname,"rogue.%llu.pack",(long long)seed); + boost::filesystem::remove(fname); + //fprintf(stderr,"extracted.(%s)\n",str); for (i=0; i Date: Sun, 3 Mar 2019 21:22:39 -1100 Subject: [PATCH 2840/3904] Remove --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c92a52725..7bd7a160a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1081,7 +1081,7 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); sprintf(fname,"rogue.%llu.pack",(long long)seed); - boost::filesystem::remove(fname); + remove(fname); //fprintf(stderr,"extracted.(%s)\n",str); for (i=0; i Date: Sun, 3 Mar 2019 21:40:04 -1100 Subject: [PATCH 2841/3904] Remove .pack --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7bd7a160a..f765a17b9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1138,7 +1138,9 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } } - //fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); + sprintf(fname,"rogue.%llu.pack",(long long)seed); + remove(fname); + //fprintf(stderr,"no keys rogue_extractgame %s\n",gametxid.GetHex().c_str()); return(-1); } From 58cd84959181a66668cb4dcaf9684ac88fa5f785 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 21:42:12 -1100 Subject: [PATCH 2842/3904] Jl777 (#1311) * Remove voutsum check * Teach RPC interface about dpow-enabled minconfs (#1231) * Make minconfs dpow-aware in z_listunspent + z_listreceivedbyaddress * Add dpow-related test files to test suite * Add dpow simulation to regtest every 7 blocks * Fix compiler errors * Fix link error * Fix stdout spam when running regtests * Dpowminconfs for listreceivedbyaddress * dpowconfs tests * Start adding specific tests for dpowminconfs in listreceivedbyaddress * Get dpowminconfs tests for listreceivedbyaddress working * Add dpowminconfs to getreceivedbyaddress + listunspent * Add test for listtransactions + getreceivedbyaddress support * Reliably passing dpowminconf tests. We only check for notarized-ness now, not exact confirmation numbers, to avoid race conditions * Poll for the expected notarization info before running further tests; add support for getbalance * Migrate tx_height() to a place where asyncrpcoperation_sendmany.cpp can use it * fix * Teach GetFilteredNotes about dpowconfs Many RPCs rely on this internal function, which now correctly uses dpowconfs to filter by the minconf/maxconf parameters. * Fix sendmany when using non-default minconf * inline seems to make things happy * cleanup * Add some code to test z_sendmany, which points out https://github.com/jl777/komodo/issues/1247 * try this * Use already calculated value of dpowconfs instead of calculating it again * Cleanup .pack file * Remove * Remove .pack --- qa/pull-tester/rpc-tests.sh | 2 + qa/rpc-tests/dpowconfs.py | 151 +++++++++++++++++ qa/rpc-tests/test_framework/util.py | 10 +- src/cc/rogue/main.c | 2 + src/cc/rogue_rpc.cpp | 27 ++- src/komodo.h | 9 + src/komodo_bitcoind.h | 19 +++ src/komodo_defs.h | 1 + src/komodo_notary.h | 1 - src/komodo_utils.h | 3 +- src/main.cpp | 6 +- src/wallet/asyncrpcoperation_sendmany.cpp | 14 +- src/wallet/rpcwallet.cpp | 190 ++++++++++++---------- src/wallet/wallet.cpp | 21 ++- src/wallet/wallet.h | 1 + 15 files changed, 339 insertions(+), 118 deletions(-) create mode 100755 qa/rpc-tests/dpowconfs.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 226c16b11..c4775fa85 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -11,6 +11,8 @@ export BITCOIND=${REAL_BITCOIND} #Run the tests testScripts=( + 'dpow.py' + 'dpowconfs.py' 'ac_private.py' 'verushash.py' 'paymentdisclosure.py' diff --git a/qa/rpc-tests/dpowconfs.py b/qa/rpc-tests/dpowconfs.py new file mode 100755 index 000000000..9c449923e --- /dev/null +++ b/qa/rpc-tests/dpowconfs.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 The Hush developers +# Copyright (c) 2019 The SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * +import time + +class DPoWConfsTest(BitcoinTestFramework): + def debug_info(self): + rpc = self.nodes[0] + print "-- DEBUG --" + getinfo = rpc.getinfo() + getwalletinfo = rpc.getwalletinfo() + listreceivedbyaddress = rpc.listreceivedbyaddress() + print "notarized=", getinfo['notarized'], " blocks=", getinfo['blocks'] + #print "getinfo=", getinfo + print "balance=", getwalletinfo['balance'] + #print "getwalletinfo=", getwalletinfo + print "listreceivedbyaddress=", listreceivedbyaddress + print "-- DEBUG --" + + def setup_chain(self): + self.num_nodes = 1 + print("Initializing DPoWconfs test directory "+self.options.tmpdir) + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self): + print("Setting up network...") + self.nodes = [] + self.is_network_split = False + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.nodes = start_nodes( self.num_nodes, self.options.tmpdir, + extra_args=[[ + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + #'-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ]] + ) + self.sync_all() + + def run_test(self): + rpc = self.nodes[0] + # 98 is notarized, next will be 105. Must mine at least 101 + # blocks for 100 block maturity rule + blockhashes = rpc.generate(101) + # block 98, this is 0 indexed + notarizedhash = blockhashes[97] + self.debug_info() + + taddr = rpc.getnewaddress() + txid = rpc.sendtoaddress(taddr, 5.55) + # blocks 102,103 + rpc.generate(2) + self.debug_info() + + info = rpc.getinfo() + print "notarizedhash=", notarizedhash, "\n" + print "info[notarizedhash]", info['notarizedhash'], "\n" + assert_equal( info['notarizedhash'], notarizedhash) + + result = rpc.listunspent() + + # this xtn has 2 raw confs, but not in a notarized block, + # so dpowconfs holds it at 1 + for res in result: + if (res['address'] == taddr and res['generated'] == 'false'): + assert_equal( result[0]['confirmations'], 1 ) + assert_equal( result[0]['rawconfirmations'], 2 ) + + # we will now have 3 rawconfs but confirmations=1 because not notarized + # block 104 + rpc.generate(1) + self.debug_info() + minconf = 2 + result = rpc.listreceivedbyaddress(minconf) + print "listreceivedbyaddress(2)=", result, "\n" + + # nothing is notarized, so we should see no results for minconf=2 + assert len(result) == 0 + + print "getreceivedaddress" + received = rpc.getreceivedbyaddress(taddr, minconf) + assert_equal( received, 0.00000000) + + #received = rpc.getreceivedbyaddress(taddr) + #assert_equal( received, "5.55000000") + taddr = rpc.getnewaddress() + zaddr = rpc.z_getnewaddress() + # should get insufficient funds error + recipients = [ { "amount" : Decimal('4.20'), "address" : zaddr } ] + txid = rpc.z_sendmany( taddr, recipients, minconf) + + # generate a notarized block, block 105 and block 106 + # only generating the notarized block seems to have + # race conditions about whether the block is notarized + txids = rpc.generate(2) + self.debug_info() + + getinfo = rpc.getinfo() + # try to allow notarization data to update + print "Sleeping" + while (getinfo['blocks'] != 106) or (getinfo['notarized'] != 105): + printf(".") + time.sleep(1) + getinfo = rpc.getinfo() + + # make sure this block was notarized as we expect + #assert_equal(getinfo['blocks'], getinfo['notarized']) + #assert_equal(getinfo['notarizedhash'], txids[0]) + + result = rpc.listreceivedbyaddress(minconf) + print "listreceivedbyaddress(2)=", result + + assert_equal( len(result), 1, 'got one xtn with minconf=2' ) + + # verify we see the correct dpowconfs + rawconfs + assert_greater_than( result[0]['confirmations'], 1) + assert_greater_than( result[0]['rawconfirmations'], 1) + + print "listtransactions" + xtns = rpc.listtransactions() + # verify this rpc agrees with listreceivedbyaddress + assert_greater_than(xtns[0]['confirmations'], 1) + assert_greater_than(xtns[0]['rawconfirmations'], 1) + + print "getreceivedaddress" + received = rpc.getreceivedbyaddress(taddr, minconf) + assert_equal( "%.8f" % received, "5.55000000") + + received = rpc.getreceivedbyaddress(taddr) + assert_equal( "%.8f" % received, "5.55000000") + +if __name__ == '__main__': + DPoWConfsTest().main() diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index e9130171b..6bcf4cd18 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -1,9 +1,7 @@ # Copyright (c) 2014 The Bitcoin Core developers -# Copyright (c) 2018 The SuperNET developers +# Copyright (c) 2018-2019 The SuperNET developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. - - # # Helpful routines for regression testing # @@ -415,10 +413,16 @@ def assert_true(condition, message = ""): def assert_false(condition, message = ""): assert_true(not condition, message) +# assert thing2 > thing1 def assert_greater_than(thing1, thing2): if thing1 <= thing2: raise AssertionError("%s <= %s"%(str(thing1),str(thing2))) +# assert thing2 >= thing1 +def assert_greater_than_or_equal(thing1, thing2): + if thing1 < thing2: + raise AssertionError("%s < %s"%(str(thing1),str(thing2))) + def assert_raises(exc, fun, *args, **kwds): try: fun(*args, **kwds) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 4e6221aa1..5e79e399e 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -763,6 +763,8 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(rs->keystrokeshex), rs->keystrokeshex = 0; } + // extract and get keystrokes field and compare it to pastkeys + // if not matching... panic? if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { free(pastkeys); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index bfcdf1f92..f765a17b9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1071,7 +1071,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,rogueaddr[64],str2[67]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed,mult = 10; CPubKey roguepk; struct rogue_player P; + char str[512],*keystrokes,rogueaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed,mult = 10; CPubKey roguepk; struct rogue_player P; *cashoutp = 0; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); @@ -1080,6 +1080,9 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C { //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); + sprintf(fname,"rogue.%llu.pack",(long long)seed); + remove(fname); + //fprintf(stderr,"extracted.(%s)\n",str); for (i=0; i 20000 ) - return eval->Invalid("couldnt decode register opret"); + return eval->Invalid("couldnt decode register opret"); } // baton is created // validation is done below @@ -1509,23 +1512,13 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'K': if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) { - //fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height); - //if ( height > 20000 ) - return eval->Invalid("couldnt decode keystrokes opret"); + return eval->Invalid("couldnt decode keystrokes opret"); } // spending the baton proves it is the user if the pk is the signer return(true); break; case 'H': case 'Q': - /*if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) - { - //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); - //if ( height > 20000 ) - return eval->Invalid("couldnt decode H/Q opret"); - } - fprintf(stderr,"height.%d decoded H/Q opret\n",height); - // spending the baton proves it is the user if the pk is the signer - // rest of validation is done below*/ + // done in the next switch statement as there are some H/Q tx with playerdata which would skip this section break; default: return eval->Invalid("illegal rogue non-decoded funcid"); diff --git a/src/komodo.h b/src/komodo.h index bd3550e38..791adba33 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -27,6 +27,8 @@ #define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) +extern int32_t NOTARIZED_HEIGHT; +uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; #include #include @@ -930,6 +932,13 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) } notarized = 1; } + // simulate DPoW in regtest mode for dpowconfs tests/etc + if ( Params().NetworkIDString() == "regtest" && ( height%7 == 0) ) { + notarized = 1; + sp->NOTARIZED_HEIGHT = height; + sp->NOTARIZED_HASH = block.GetHash(); + sp->NOTARIZED_DESTTXID = txhash; + } if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("(tx.%d: ",i); for (j=0; jptr[0] = '\0'; } +int tx_height( const uint256 &hash ){ + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(hash, tx, hashBlock, true)) { + fprintf(stderr,"tx hash %s does not exist!\n", hash.ToString().c_str() ); + } + + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + return nHeight; +} + + /************************************************************************ * * Use the "writer" to accumulate text until done diff --git a/src/komodo_defs.h b/src/komodo_defs.h index f17e14ebf..cbf84b7f0 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -78,6 +78,7 @@ extern int32_t VERUS_MIN_STAKEAGE; extern std::string DONATION_PUBKEY; extern uint8_t ASSETCHAINS_PRIVATE; extern int32_t USE_EXTERNAL_PUBKEY; +int tx_height( const uint256 &hash ); extern char NOTARYADDRS[64][36]; extern uint8_t NUM_NOTARIES; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c4984cee2..5cdbf237d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -15,7 +15,6 @@ #include "komodo_defs.h" - #include "komodo_cJSON.h" #include "notaries_staked.h" diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2c4a2d040..079ce1eea 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1366,7 +1366,8 @@ void komodo_statefname(char *fname,char *symbol,char *str) fname[len - n] = 0; else { - printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]); + if ( strcmp(symbol,"REGTEST") != 0 ) + printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]); return; } } diff --git a/src/main.cpp b/src/main.cpp index 8ea3a499b..ce0760cf5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3506,9 +3506,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN); return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); } - else*/ - if ( voutsum < prevsum ) - return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big"); + else + if ( voutsum < prevsum ) // PRLPAY overflows this and it isnt a conclusive test anyway + return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");*/ if (!tx.IsCoinBase()) { nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - valueout; diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index d4c5077cc..0ea17a5f8 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -54,6 +54,8 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[65]; +int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +int tx_height( const uint256 &hash ); extern UniValue signrawtransaction(const UniValue& params, bool fHelp); extern UniValue sendrawtransaction(const UniValue& params, bool fHelp); @@ -1049,8 +1051,16 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { continue; } - if (out.nDepth < mindepth_) { - continue; + if( mindepth_ > 1 ) { + int nHeight = tx_height(out.tx->GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, out.nDepth); + if (dpowconfs < mindepth_) { + continue; + } + } else { + if (out.nDepth < mindepth_) { + continue; + } } const CScript &scriptPubKey = out.tx->vout[out.i].scriptPubKey; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6bd1802f0..2397be883 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -84,6 +84,8 @@ UniValue z_getoperationstatus_IMPL(const UniValue&, bool); #define PLAN_NAME_MAX 8 #define VALID_PLAN_NAME(x) (strlen(x) <= PLAN_NAME_MAX) +int tx_height( const uint256 &hash ); + std::string HelpRequiringPassphrase() { return pwalletMain && pwalletMain->IsCrypted() @@ -933,9 +935,20 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) continue; BOOST_FOREACH(const CTxOut& txout, wtx.vout) - if (txout.scriptPubKey == scriptPubKey) - if (wtx.GetDepthInMainChain() >= nMinDepth) - nAmount += txout.nValue; // komodo_interest? + if (txout.scriptPubKey == scriptPubKey) { + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs >= nMinDepth) { + nAmount += txout.nValue; // komodo_interest? + } + } else { + if (nDepth >= nMinDepth) { + nAmount += txout.nValue; // komodo_interest? + } + } + } } return ValueFromAmount(nAmount); @@ -1013,8 +1026,18 @@ CAmount GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi CAmount nReceived, nSent, nFee; wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee, filter); - if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) - nBalance += nReceived; + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (nReceived != 0 && dpowconfs >= nMinDepth) { + nBalance += nReceived; + } + } else { + if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) { + nBalance += nReceived; + } + } nBalance -= nSent + nFee; } @@ -1186,10 +1209,20 @@ UniValue getbalance(const UniValue& params, bool fHelp) list listReceived; list listSent; wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); - if (wtx.GetDepthInMainChain() >= nMinDepth) - { - BOOST_FOREACH(const COutputEntry& r, listReceived) - nBalance += r.amount; + + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs >= nMinDepth) { + BOOST_FOREACH(const COutputEntry& r, listReceived) + nBalance += r.amount; + } + } else { + if (nDepth >= nMinDepth) { + BOOST_FOREACH(const COutputEntry& r, listReceived) + nBalance += r.amount; + } } BOOST_FOREACH(const COutputEntry& s, listSent) nBalance -= s.amount; @@ -1460,8 +1493,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) EnsureWalletIsUnlocked(); // Check funds - CAmount nBalance = pwalletMain->GetBalance(); - //CAmount nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE); + CAmount nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE); if (totalAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); @@ -1572,9 +1604,16 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) if (wtx.IsCoinBase() || !CheckFinalTx(wtx)) continue; - int nDepth = wtx.GetDepthInMainChain(); - if (nDepth < nMinDepth) - continue; + int nDepth = wtx.GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(wtx.GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs < nMinDepth) + continue; + } else { + if (nDepth < nMinDepth) + continue; + } BOOST_FOREACH(const CTxOut& txout, wtx.vout) { @@ -2851,8 +2890,16 @@ UniValue listunspent(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); BOOST_FOREACH(const COutput& out, vecOutputs) { - if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) - continue; + int nDepth = out.tx->GetDepthInMainChain(); + if( nMinDepth > 1 ) { + int nHeight = tx_height(out.tx->GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs < nMinDepth || dpowconfs > nMaxDepth) + continue; + } else { + if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) + continue; + } CTxDestination address; const CScript& scriptPubKey = out.tx->vout[out.i].scriptPubKey; @@ -3068,28 +3115,17 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; + + int nHeight = tx_height(entry.jsop.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("jsindex", (int)entry.jsop.js )); obj.push_back(Pair("jsoutindex", (int)entry.jsop.n)); - - if (!GetTransaction(entry.jsop.hash, tx, hashBlock, true)) { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() ); - } - - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); bool hasSproutSpendingKey = pwalletMain->HaveSproutSpendingKey(boost::get(entry.address)); obj.push_back(Pair("spendable", hasSproutSpendingKey)); @@ -3105,25 +3141,17 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) for (auto & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); + + int nHeight = tx_height(entry.op.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; + obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("outindex", (int)entry.op.n)); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; - if (!GetTransaction(entry.op.hash, tx, hashBlock, true)) { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"tx hash %s does not exist!\n", entry.op.hash.ToString().c_str() ); - } - - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - // TODO: should we throw JSONRPCError ? - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); libzcash::SaplingIncomingViewingKey ivk; libzcash::SaplingFullViewingKey fvk; @@ -3144,7 +3172,6 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) return results; } - UniValue fundrawtransaction(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -3795,8 +3822,17 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); BOOST_FOREACH(const COutput& out, vecOutputs) { - if (out.nDepth < minDepth) { - continue; + int nDepth = out.tx->GetDepthInMainChain(); + if( minDepth > 1 ) { + int nHeight = tx_height(out.tx->GetHash()); + int dpowconfs = komodo_dpowconfs(nHeight, nDepth); + if (dpowconfs < minDepth) { + continue; + } + } else { + if (out.nDepth < minDepth) { + continue; + } } if (ignoreUnspendable && !out.fSpendable) { @@ -3901,21 +3937,11 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) if (boost::get(&zaddr) != nullptr) { for (CSproutNotePlaintextEntry & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; - - if (GetTransaction(entry.jsop.hash, tx, hashBlock, true)) { - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - } else { - fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() ); - } + int nHeight = tx_height(entry.jsop.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value())))); @@ -3924,7 +3950,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) obj.push_back(Pair("jsindex", entry.jsop.js)); obj.push_back(Pair("jsoutindex", entry.jsop.n)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSproutChange(nullifierSet, entry.address, entry.jsop))); } @@ -3933,27 +3959,19 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) } else if (boost::get(&zaddr) != nullptr) { for (SaplingNoteEntry & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = 0; - CTransaction tx; - uint256 hashBlock; - if (GetTransaction(entry.op.hash, tx, hashBlock, true)) { - BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); - if (it != mapBlockIndex.end()) { - nHeight = it->second->GetHeight(); - //fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); - } else { - fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); - } - } else { - fprintf(stderr,"tx hash %s does not exist!\n", entry.op.hash.ToString().c_str() ); - } + int nHeight = tx_height(entry.op.hash); + int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); + // Only return notarized results when minconf>1 + if (nMinDepth > 1 && dpowconfs == 1) + continue; + obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.note.value())))); obj.push_back(Pair("memo", HexStr(entry.memo))); obj.push_back(Pair("outindex", (int)entry.op.n)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); - obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("confirmations", dpowconfs)); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSaplingChange(nullifierSet, entry.address, entry.op))); } @@ -8024,8 +8042,6 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) cp = CCinit(&C, EVAL_HEIR); return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); - - } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 82642df00..9cf2a86cb 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -60,6 +60,9 @@ bool fPayAtLeastCustomFee = true; #include "komodo_defs.h" CBlockIndex *komodo_chainactive(int32_t height); +extern std::string DONATION_PUBKEY; +int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +int tx_height( const uint256 &hash ); /** * Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) @@ -4966,11 +4969,21 @@ void CWallet::GetFilteredNotes( CWalletTx wtx = p.second; // Filter the transactions before checking for notes - if (!CheckFinalTx(wtx) || - wtx.GetBlocksToMaturity() > 0 || - wtx.GetDepthInMainChain() < minDepth || - wtx.GetDepthInMainChain() > maxDepth) { + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0) continue; + + if (minDepth > 1) { + int nHeight = tx_height(wtx.GetHash()); + int nDepth = wtx.GetDepthInMainChain(); + int dpowconfs = komodo_dpowconfs(nHeight,nDepth); + if ( dpowconfs < minDepth || dpowconfs > maxDepth) { + continue; + } + } else { + if ( wtx.GetDepthInMainChain() < minDepth || + wtx.GetDepthInMainChain() > maxDepth) { + continue; + } } for (auto & pair : wtx.mapSproutNoteData) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 663e60367..10aa83ce6 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -60,6 +60,7 @@ extern bool bSpendZeroConfChange; extern bool fSendFreeTransactions; extern bool fPayAtLeastCustomFee; + //! -paytxfee default static const CAmount DEFAULT_TRANSACTION_FEE = 0; //! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB From 1d048ad5fc26441774fab6f27e51d46d9dbd249e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 21:56:17 -1100 Subject: [PATCH 2843/3904] Disable passkeys --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 5e79e399e..6b466e9a0 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -765,7 +765,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } // extract and get keystrokes field and compare it to pastkeys // if not matching... panic? - if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) + if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { free(pastkeys); } From 2188a603186e35670493cba8b97688523b0f6878 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 23:58:08 -1100 Subject: [PATCH 2844/3904] Rvalidate --- src/cc/CCinclude.h | 1 + src/cc/cclib.cpp | 25 ++++++++++ src/cc/dilithium.c | 119 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 136 insertions(+), 9 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 91e9467dd..f5877c711 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -201,6 +201,7 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, CScript EncodeTokenImportOpRet(std::vector origpubkey, std::string name, std::string description, uint256 srctokenid, std::vector> oprets); CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::pair opretWithId); CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector> oprets); +int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector> &oprets); uint8_t DecodeTokenImportOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, uint256 &srctokenid, std::vector> &oprets); diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 121a16475..695ccd16b 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -504,6 +504,31 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } +int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk) +{ + char coinaddr[64]; int64_t txfee = 10000; uint256 txid,hashBlock; CTransaction vintx; int32_t vout; + std::vector > unspentOutputs; + GetCCaddress(cp,coinaddr,pk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); + if ( it->second.satoshis < txfee ) + continue; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + { + if ( (nValue= IsCClibvout(cp,vintx,vout,coinaddr)) != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + { + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + return(it->second.satoshis); + } //else fprintf(stderr,"nValue %.8f too small or already spent in mempool\n",(double)nValue/COIN); + } else fprintf(stderr,"couldnt get tx\n"); + } + return(0); +} + std::string Faucet2Fund(struct CCcontract_info *cp,uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index e36ea807e..4136b0bca 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2929,6 +2929,29 @@ int32_t main(void) void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); +struct dilithium_handle +{ + UT_hash_handle hh; + uint256 destpubtxid; + char handle[32]; +} *Dilithium_handles; + +struct dilithium_handle *dilithium_handlenew(std::string handle) +{ + struct dilithium_handle *hashstr = 0; + if ( handle.size() < sizeof(Dilithium_handles[0].handle)-1 ) + { + HASH_FIND(hh,Dilithium_handles,handle,(int32_t)handle.size(),hashstr); + if ( hashstr == 0 ) + { + hashstr = calloc(1,sizeof(*hashstr)); + strncpy(hashstr->handle,handle.c_str(),sizeof(hashstr->handle)); + HASH_ADD_KEYPTR(hh,Dilithium_handles,hashstr->handle,(int32_t)handle.size(),hashstr); + } + } + return(hashstr); +} + int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector voutpubtxids) { CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; @@ -3110,12 +3133,20 @@ UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *para return(result); } +CPubKey Faucet_pubkeyget() +{ + struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_FAUCET); + return(GetUnspendable(cp,0)); +} + UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,dilithiumpk; uint8_t seed[SEEDBYTES],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[CRYPTO_SECRETKEYBYTES*2+1]; std::vector bigpub; int32_t i,n,warningflag = 0; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey faucetpk,mypk,dilithiumpk; uint8_t seed[SEEDBYTES],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[CRYPTO_SECRETKEYBYTES*2+1]; int64_t CCchange,inputs; std::vector bigpub; int32_t i,n,warningflag = 0; if ( txfee == 0 ) txfee = DILITHIUM_TXFEE; + faucetpk = Faucet_pubkeyget(); mypk = pubkey2pk(Mypubkey()); dilithiumpk = GetUnspendable(cp,0); if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 1 || n == 2) ) @@ -3132,14 +3163,23 @@ UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *par result.push_back(Pair("skaddr",dilithium_addr(coinaddr,sk,CRYPTO_SECRETKEYBYTES))); for (i=0; i= 3*txfee ) + if ( (inputs= AddCClibtxfee(cp,mtx,dilithiumpk)) > 0 ) { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,dilithiumpk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_registeropret(handle,mypk,bigpub)); - return(musig_rawtxresult(result,rawtx)); - } else return(cclib_error(result,"couldnt find enough funds")); - } else return(cclib_error(result,"not enough parameters")); + if ( inputs > txfee ) + CCchange = (inputs - txfee); + else CCchange = 0; + if ( AddNormalinputs(mtx,mypk,COIN+3*txfee,64) >= 3*txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,2*txfee,dilithiumpk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET,COIN,faucetpk)); + if ( CCchange != 0 ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,dilithiumpk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_registeropret(handle,mypk,bigpub)); + return(musig_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt find enough funds")); + } else return(cclib_error(result,"not enough parameters")); + } else return(cclib_error(result,"not dilithiumpk funds")); } UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) @@ -3452,6 +3492,65 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co } else return eval->Invalid("unexpected zero signerpubtxid"); } +bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + static int32_t didinit; + std::vector > txids; + uint256 txid,hashBlock; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CTransaction txi; CPubKey pub33,dilithiumpk; CTxOut vout,vout0; char CCaddr[64]; + dilithiumpk = GetUnspendable(cp,0); + if ( didinit == 0 ) + { + GetCCaddress(cp,CCaddr,dilithiumpk); + SetCCtxids(txids,CCaddr); + for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + { + txid = it->first.txhash; + if ( myGetTransaction(txid,txi,hashBlock) != 0 && (numvouts= txi.vout.size()) > 1 ) + { + if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( (hashstr= dilithium_handlenew(handle)) != 0 ) + { + if ( hashstr->destpubtxid != txid ) + { + if ( hashstr->destpubtxid != zeroid ) + fprintf(stderr,"overwriting %s %s with %s\n",handle.c_str(),hashstr->destpubtxid.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"%s <- %s\n",handle.c_str(),txid.GetHex().c_str()); + hashstr->destpubtxid = txid; + } + } + } + } + } + didinit = 1; + } + if ( (numvouts= tx.vout.size()) <= 1 ) + return eval->Invalid("not enough vouts for registration tx"); + else if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + // relies on all current block tx to be put into mempool + txid = tx.GetHash(); + vout0 = MakeCC1vout(cp->evalcode,2*DILITHIUM_TXFEE,dilithiumpk); + vout = MakeCC1vout(EVAL_FAUCET,COIN,Faucet_pubkeyget()); + if ( tx.vout[0] != vout0 ) + return eval->Invalid("mismatched vout0 for register"); + else if ( tx.vout[1].nValue != DILITHIUM_TXFEE ) + return eval->Invalid("vout1 for register not txfee"); + else if ( tx.vout[2] != vout ) + return eval->Invalid("register not sending to faucet"); + else if ( (hashstr= dilithium_handlenew(handle)) == 0 ) + return eval->Invalid("error creating dilithium handle"); + else if ( hashstr->destpubtxid == zeroid ) + { + hashstr->destpubtxid = txid; + return(true); + } + else if ( hashstr->destpubtxid == txid ) + return(true); + else return eval->Invalid("duplicate dilithium handle rejected"); + } else return eval->Invalid("couldnt decode register opret"); +} + bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig,vopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; @@ -3459,7 +3558,9 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con numvouts = tx.vout.size(); GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( script[1] == 'Q' ) + if ( script[1] == 'R' ) + return(dilithium_Rvalidate(cp,height,eval,tx)); + else if ( script[1] == 'Q' ) return(dilithium_Qvalidate(cp,height,eval,tx)); else if ( tx.vout.size() != 2 ) return eval->Invalid("numvouts != 2"); From d6534d9069a286563e5549f96d9cd3e31149d328 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Mar 2019 23:59:55 -1100 Subject: [PATCH 2845/3904] Syntax --- src/cc/cclib.cpp | 2 +- src/cc/dilithium.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 695ccd16b..3a6fba108 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -506,7 +506,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk) { - char coinaddr[64]; int64_t txfee = 10000; uint256 txid,hashBlock; CTransaction vintx; int32_t vout; + char coinaddr[64]; int64_t nValue,txfee = 10000; uint256 txid,hashBlock; CTransaction vintx; int32_t vout; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 4136b0bca..8cfc85028 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2941,10 +2941,10 @@ struct dilithium_handle *dilithium_handlenew(std::string handle) struct dilithium_handle *hashstr = 0; if ( handle.size() < sizeof(Dilithium_handles[0].handle)-1 ) { - HASH_FIND(hh,Dilithium_handles,handle,(int32_t)handle.size(),hashstr); + HASH_FIND(hh,Dilithium_handles,handle.c_str(),(int32_t)handle.size(),hashstr); if ( hashstr == 0 ) { - hashstr = calloc(1,sizeof(*hashstr)); + hashstr = (struct dilithium_handle *)calloc(1,sizeof(*hashstr)); strncpy(hashstr->handle,handle.c_str(),sizeof(hashstr->handle)); HASH_ADD_KEYPTR(hh,Dilithium_handles,hashstr->handle,(int32_t)handle.size(),hashstr); } From e8982c5f17af04b4a621628ba09e8d68184867ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 00:12:44 -1100 Subject: [PATCH 2846/3904] Allow overwrite by same pub33 --- src/cc/dilithium.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 8cfc85028..9bf337c2a 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3492,6 +3492,17 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co } else return eval->Invalid("unexpected zero signerpubtxid"); } +int32_t dilithium_registrationpub33(CPubKey &pub33,uint256 txid) +{ + std::string handle; std::vector bigpub; + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + return(0); + } + return(-1); +} + bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static int32_t didinit; @@ -3545,8 +3556,16 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co hashstr->destpubtxid = txid; return(true); } - else if ( hashstr->destpubtxid == txid ) - return(true); + else + { + if ( hashstr->destpubtxid == txid ) + return(true); + else if ( dilithium_registrationpub33(oldpub33,hashstr->destpubtxid) == 0 ) + { + if ( oldpub33 == pub33 ) + return(true); + } else return eval->Invalid("duplicate dilithium handle rejected"); + } else return eval->Invalid("duplicate dilithium handle rejected"); } else return eval->Invalid("couldnt decode register opret"); } From d28fa50d9ba37dc30fcfe027431bf9cc78c52a1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 00:13:30 -1100 Subject: [PATCH 2847/3904] Tx --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 9bf337c2a..7fab10faf 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3494,7 +3494,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co int32_t dilithium_registrationpub33(CPubKey &pub33,uint256 txid) { - std::string handle; std::vector bigpub; + std::string handle; std::vector bigpub; CTransaction tx; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) From 905868c6c145109171ac26a6bb3b19f07b19f2f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 00:14:15 -1100 Subject: [PATCH 2848/3904] Declare variables --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 7fab10faf..51f4c9510 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3494,7 +3494,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co int32_t dilithium_registrationpub33(CPubKey &pub33,uint256 txid) { - std::string handle; std::vector bigpub; CTransaction tx; + std::string handle; std::vector bigpub; CTransaction tx; uint256 hashBlock; int32_t numvouts; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) @@ -3507,7 +3507,7 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co { static int32_t didinit; std::vector > txids; - uint256 txid,hashBlock; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CTransaction txi; CPubKey pub33,dilithiumpk; CTxOut vout,vout0; char CCaddr[64]; + uint256 txid,hashBlock; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CTransaction txi; CPubKey oldpub33,pub33,dilithiumpk; CTxOut vout,vout0; char CCaddr[64]; dilithiumpk = GetUnspendable(cp,0); if ( didinit == 0 ) { From 94b32af9645369c9f96f86b82466e207fb48e9db Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 00:15:04 -1100 Subject: [PATCH 2849/3904] Allow replacement handle --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 51f4c9510..d7b59f54c 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3564,9 +3564,9 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co { if ( oldpub33 == pub33 ) return(true); - } else return eval->Invalid("duplicate dilithium handle rejected"); + } + return eval->Invalid("duplicate dilithium handle rejected"); } - else return eval->Invalid("duplicate dilithium handle rejected"); } else return eval->Invalid("couldnt decode register opret"); } From f53e6c02b3f18eacd2150c63da2995218c3342a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 00:18:28 -1100 Subject: [PATCH 2850/3904] Grandfather existing handles --- src/cc/dilithium.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index d7b59f54c..4a181e7c5 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3508,6 +3508,8 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co static int32_t didinit; std::vector > txids; uint256 txid,hashBlock; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CTransaction txi; CPubKey oldpub33,pub33,dilithiumpk; CTxOut vout,vout0; char CCaddr[64]; + if ( height < 14500 ) + return(true); dilithiumpk = GetUnspendable(cp,0); if ( didinit == 0 ) { From c5032f46df0e7c6a8d8a1200c4b7ab7245f6e31e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 00:59:44 -1100 Subject: [PATCH 2851/3904] Test --- src/cc/dilithium.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 4a181e7c5..a82113ebc 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3527,8 +3527,8 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co if ( hashstr->destpubtxid != txid ) { if ( hashstr->destpubtxid != zeroid ) - fprintf(stderr,"overwriting %s %s with %s\n",handle.c_str(),hashstr->destpubtxid.GetHex().c_str(),txid.GetHex().c_str()); - fprintf(stderr,"%s <- %s\n",handle.c_str(),txid.GetHex().c_str()); + fprintf(stderr,"ht.%d overwriting %s %s with %s\n",height,handle.c_str(),hashstr->destpubtxid.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"ht.%d %s <- %s\n",height,handle.c_str(),txid.GetHex().c_str()); hashstr->destpubtxid = txid; } } @@ -3565,7 +3565,11 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co else if ( dilithium_registrationpub33(oldpub33,hashstr->destpubtxid) == 0 ) { if ( oldpub33 == pub33 ) + { + hashstr->destpubtxid = txid; + fprintf(stderr,"ht.%d %s <- %s\n",height,handle.c_str(),txid.GetHex().c_str()); return(true); + } } return eval->Invalid("duplicate dilithium handle rejected"); } From 08318626f353c2b0985ef87975de0348ff3ec21d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 01:17:04 -1100 Subject: [PATCH 2852/3904] Handleinfo --- src/cc/cclib.cpp | 4 ++++ src/cc/dilithium.c | 51 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 3a6fba108..651723e44 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -83,6 +83,7 @@ CClib_methods[] = { (char *)"musig", (char *)"spend", (char *)"sendtxid sig scriptPubKey", 3, 3, 'y', EVAL_MUSIG }, { (char *)"dilithium", (char *)"keypair", (char *)"[hexseed]", 0, 1, 'K', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"register", (char *)"handle, [hexseed]", 1, 2, 'R', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"handleinfo", (char *)"handle", 1, 1, 'I', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"sign", (char *)"msg [hexseed]", 1, 2, 'S', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"verify", (char *)"pubtxid msg sig", 3, 3, 'V', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"send", (char *)"handle pubtxid amount", 3, 3, 'x', EVAL_DILITHIUM }, @@ -130,6 +131,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -273,6 +275,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(dilithium_keypair(txfee,cp,params)); else if ( strcmp(method,"register") == 0 ) return(dilithium_register(txfee,cp,params)); + else if ( strcmp(method,"handleinfo") == 0 ) + return(dilithium_handleinfo(txfee,cp,params)); else if ( strcmp(method,"sign") == 0 ) return(dilithium_sign(txfee,cp,params)); else if ( strcmp(method,"verify") == 0 ) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index a82113ebc..5f79e2e50 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2936,22 +2936,30 @@ struct dilithium_handle char handle[32]; } *Dilithium_handles; -struct dilithium_handle *dilithium_handlenew(std::string handle) +struct dilithium_handle *dilithium_handlenew(char *handle) { - struct dilithium_handle *hashstr = 0; - if ( handle.size() < sizeof(Dilithium_handles[0].handle)-1 ) + struct dilithium_handle *hashstr = 0; int32_t len = (int32_t)strlen(handle); + if ( len < sizeof(Dilithium_handles[0].handle)-1 ) { - HASH_FIND(hh,Dilithium_handles,handle.c_str(),(int32_t)handle.size(),hashstr); + HASH_FIND(hh,Dilithium_handles,handle,len,hashstr); if ( hashstr == 0 ) { hashstr = (struct dilithium_handle *)calloc(1,sizeof(*hashstr)); - strncpy(hashstr->handle,handle.c_str(),sizeof(hashstr->handle)); - HASH_ADD_KEYPTR(hh,Dilithium_handles,hashstr->handle,(int32_t)handle.size(),hashstr); + strncpy(hashstr->handle,handle,sizeof(hashstr->handle)); + HASH_ADD_KEYPTR(hh,Dilithium_handles,hashstr->handle,len,hashstr); } } return(hashstr); } +struct dilithium_handle *dilithium_handlefind(char *handle) +{ + struct dilithium_handle *hashstr = 0; int32_t len = (int32_t)strlen(handle); + if ( len < sizeof(Dilithium_handles[0].handle)-1 ) + HASH_FIND(hh,Dilithium_handles,handle,len,hashstr); + return(hashstr); +} + int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector voutpubtxids) { CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; @@ -3503,6 +3511,33 @@ int32_t dilithium_registrationpub33(CPubKey &pub33,uint256 txid) return(-1); } +UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); CPubKey pub33; int32_t i,n; char *handlestr,str[67]; struct dilithium_handle *hashstr; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + { + if ( (handlestr= jstr(jitem(params,0),0)) != 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("handle",handlestr)); + if ( (hashstr= dilithium_handlefind(handlestr)) != 0 ) + { + result.push_back(Pair("destpubtxid",hashstr->destpubtxid.GetHex().c_str())); + if ( dilithium_registrationpub33(pub33,hashstr->destpubtxid) == 0 ) + { + for (i=0; i<33; i++) + sprintf(&str[i<<1],"%02x",((uint8_t *)pub33.data())[i]); + str[i<<1] = 0; + } + result.push_back(Pair("pubkey",str)); + } else result.push_back(Pair("status","available")); + return(result); + } + } + result.push_back(Pair("result","error")); + return(result); +} + bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static int32_t didinit; @@ -3522,7 +3557,7 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co { if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) { - if ( (hashstr= dilithium_handlenew(handle)) != 0 ) + if ( (hashstr= dilithium_handlenew(handle.c_str())) != 0 ) { if ( hashstr->destpubtxid != txid ) { @@ -3551,7 +3586,7 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co return eval->Invalid("vout1 for register not txfee"); else if ( tx.vout[2] != vout ) return eval->Invalid("register not sending to faucet"); - else if ( (hashstr= dilithium_handlenew(handle)) == 0 ) + else if ( (hashstr= dilithium_handlenew(handle.c_str())) == 0 ) return eval->Invalid("error creating dilithium handle"); else if ( hashstr->destpubtxid == zeroid ) { From be402b768464dcd9792de625eb2d00d7da46b0e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 01:18:19 -1100 Subject: [PATCH 2853/3904] Char * --- src/cc/dilithium.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 5f79e2e50..80502687d 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3526,7 +3526,7 @@ UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *p if ( dilithium_registrationpub33(pub33,hashstr->destpubtxid) == 0 ) { for (i=0; i<33; i++) - sprintf(&str[i<<1],"%02x",((uint8_t *)pub33.data())[i]); + sprintf(&str[i<<1],"%02x",((uint8_t *)pub33.ptr())[i]); str[i<<1] = 0; } result.push_back(Pair("pubkey",str)); @@ -3557,7 +3557,7 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co { if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) { - if ( (hashstr= dilithium_handlenew(handle.c_str())) != 0 ) + if ( (hashstr= dilithium_handlenew((char *)handle.c_str())) != 0 ) { if ( hashstr->destpubtxid != txid ) { @@ -3586,7 +3586,7 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co return eval->Invalid("vout1 for register not txfee"); else if ( tx.vout[2] != vout ) return eval->Invalid("register not sending to faucet"); - else if ( (hashstr= dilithium_handlenew(handle.c_str())) == 0 ) + else if ( (hashstr= dilithium_handlenew((char *)handle.c_str())) == 0 ) return eval->Invalid("error creating dilithium handle"); else if ( hashstr->destpubtxid == zeroid ) { From 3e22ce7bc77848e1d5d9b650ab4621d76c6f60d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 01:19:08 -1100 Subject: [PATCH 2854/3904] Begin --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 80502687d..a35de9a2c 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3526,7 +3526,7 @@ UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *p if ( dilithium_registrationpub33(pub33,hashstr->destpubtxid) == 0 ) { for (i=0; i<33; i++) - sprintf(&str[i<<1],"%02x",((uint8_t *)pub33.ptr())[i]); + sprintf(&str[i<<1],"%02x",((uint8_t *)pub33.begin())[i]); str[i<<1] = 0; } result.push_back(Pair("pubkey",str)); From 6773dfcbb29c50dc17a426e408dcf7f27e7bf6ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 02:19:21 -1100 Subject: [PATCH 2855/3904] Add mutex --- src/cc/dilithium.c | 85 +++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 32 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index a35de9a2c..6ca4a64eb 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2936,11 +2936,14 @@ struct dilithium_handle char handle[32]; } *Dilithium_handles; +pthread_mutex_t DILITHIUM_MUTEX; + struct dilithium_handle *dilithium_handlenew(char *handle) { struct dilithium_handle *hashstr = 0; int32_t len = (int32_t)strlen(handle); if ( len < sizeof(Dilithium_handles[0].handle)-1 ) { + pthread_mutex_lock(&DILITHIUM_MUTEX); HASH_FIND(hh,Dilithium_handles,handle,len,hashstr); if ( hashstr == 0 ) { @@ -2948,6 +2951,7 @@ struct dilithium_handle *dilithium_handlenew(char *handle) strncpy(hashstr->handle,handle,sizeof(hashstr->handle)); HASH_ADD_KEYPTR(hh,Dilithium_handles,hashstr->handle,len,hashstr); } + pthread_mutex_unlock(&DILITHIUM_MUTEX); } return(hashstr); } @@ -2956,7 +2960,11 @@ struct dilithium_handle *dilithium_handlefind(char *handle) { struct dilithium_handle *hashstr = 0; int32_t len = (int32_t)strlen(handle); if ( len < sizeof(Dilithium_handles[0].handle)-1 ) + { + pthread_mutex_lock(&DILITHIUM_MUTEX); HASH_FIND(hh,Dilithium_handles,handle,len,hashstr); + pthread_mutex_unlock(&DILITHIUM_MUTEX); + } return(hashstr); } @@ -3500,22 +3508,60 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co } else return eval->Invalid("unexpected zero signerpubtxid"); } -int32_t dilithium_registrationpub33(CPubKey &pub33,uint256 txid) +int32_t dilithium_registrationpub33(char *pkaddr,CPubKey &pub33,uint256 txid) { std::string handle; std::vector bigpub; CTransaction tx; uint256 hashBlock; int32_t numvouts; + pkaddr[0] = 0; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + dilithium_addr(pkaddr,&bigpub[0],CRYPTO_PUBLICKEYBYTES); return(0); + } } return(-1); } +void dilithium_handleinit(struct CCcontract_info *cp) +{ + static int32_t didinit; + std::vector > txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector bigpub; std::string handle; + if ( didinit != 0 ) + return; + pthread_mutex_init(&DILITHIUM_MUTEX,NULL); + dilithiumpk = GetUnspendable(cp,0); + GetCCaddress(cp,CCaddr,dilithiumpk); + SetCCtxids(txids,CCaddr); + for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + { + txid = it->first.txhash; + if ( myGetTransaction(txid,txi,hashBlock) != 0 && (numvouts= txi.vout.size()) > 1 ) + { + if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( (hashstr= dilithium_handlenew((char *)handle.c_str())) != 0 ) + { + if ( hashstr->destpubtxid != txid ) + { + if ( hashstr->destpubtxid != zeroid ) + fprintf(stderr,"overwriting %s %s with %s\n",handle.c_str(),hashstr->destpubtxid.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"%s <- %s\n",handle.c_str(),txid.GetHex().c_str()); + hashstr->destpubtxid = txid; + } + } + } + } + } + didinit = 1; +} + UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pub33; int32_t i,n; char *handlestr,str[67]; struct dilithium_handle *hashstr; + UniValue result(UniValue::VOBJ); CPubKey pub33; int32_t i,n; char *handlestr,pkaddr[64],str[67]; struct dilithium_handle *hashstr; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { + dilithium_handleinit(cp); if ( (handlestr= jstr(jitem(params,0),0)) != 0 ) { result.push_back(Pair("result","success")); @@ -3523,11 +3569,12 @@ UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *p if ( (hashstr= dilithium_handlefind(handlestr)) != 0 ) { result.push_back(Pair("destpubtxid",hashstr->destpubtxid.GetHex().c_str())); - if ( dilithium_registrationpub33(pub33,hashstr->destpubtxid) == 0 ) + if ( dilithium_registrationpub33(pkaddr,pub33,hashstr->destpubtxid) == 0 ) { for (i=0; i<33; i++) sprintf(&str[i<<1],"%02x",((uint8_t *)pub33.begin())[i]); str[i<<1] = 0; + result.push_back(Pair("pkaddr",pkaddr)); } result.push_back(Pair("pubkey",str)); } else result.push_back(Pair("status","available")); @@ -3541,37 +3588,11 @@ UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *p bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static int32_t didinit; - std::vector > txids; - uint256 txid,hashBlock; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CTransaction txi; CPubKey oldpub33,pub33,dilithiumpk; CTxOut vout,vout0; char CCaddr[64]; + uint256 txid; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CPubKey oldpub33,pub33,dilithiumpk; CTxOut vout,vout0; char CCaddr[64],pkaddr[64]; if ( height < 14500 ) return(true); + dilithium_handleinit(cp); dilithiumpk = GetUnspendable(cp,0); - if ( didinit == 0 ) - { - GetCCaddress(cp,CCaddr,dilithiumpk); - SetCCtxids(txids,CCaddr); - for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) - { - txid = it->first.txhash; - if ( myGetTransaction(txid,txi,hashBlock) != 0 && (numvouts= txi.vout.size()) > 1 ) - { - if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) - { - if ( (hashstr= dilithium_handlenew((char *)handle.c_str())) != 0 ) - { - if ( hashstr->destpubtxid != txid ) - { - if ( hashstr->destpubtxid != zeroid ) - fprintf(stderr,"ht.%d overwriting %s %s with %s\n",height,handle.c_str(),hashstr->destpubtxid.GetHex().c_str(),txid.GetHex().c_str()); - fprintf(stderr,"ht.%d %s <- %s\n",height,handle.c_str(),txid.GetHex().c_str()); - hashstr->destpubtxid = txid; - } - } - } - } - } - didinit = 1; - } if ( (numvouts= tx.vout.size()) <= 1 ) return eval->Invalid("not enough vouts for registration tx"); else if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) @@ -3597,7 +3618,7 @@ bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co { if ( hashstr->destpubtxid == txid ) return(true); - else if ( dilithium_registrationpub33(oldpub33,hashstr->destpubtxid) == 0 ) + else if ( dilithium_registrationpub33(pkaddr,oldpub33,hashstr->destpubtxid) == 0 ) { if ( oldpub33 == pub33 ) { From 3af9fd9af46b9c9bcc85ce1c054f9e50b845accc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 02:20:17 -1100 Subject: [PATCH 2856/3904] CCaddr --- src/cc/dilithium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 6ca4a64eb..b92102f22 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3526,7 +3526,7 @@ int32_t dilithium_registrationpub33(char *pkaddr,CPubKey &pub33,uint256 txid) void dilithium_handleinit(struct CCcontract_info *cp) { static int32_t didinit; - std::vector > txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector bigpub; std::string handle; + std::vector > txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector bigpub; std::string handle; char CCaddr[64]; if ( didinit != 0 ) return; pthread_mutex_init(&DILITHIUM_MUTEX,NULL); @@ -3588,7 +3588,7 @@ UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *p bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { static int32_t didinit; - uint256 txid; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CPubKey oldpub33,pub33,dilithiumpk; CTxOut vout,vout0; char CCaddr[64],pkaddr[64]; + uint256 txid; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CPubKey oldpub33,pub33,dilithiumpk; CTxOut vout,vout0; char pkaddr[64]; if ( height < 14500 ) return(true); dilithium_handleinit(cp); From 8e89c783d4ce66cf419ddd8f3eefef50ab2c4a28 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Mar 2019 03:22:51 -1100 Subject: [PATCH 2857/3904] Casts for windows --- src/wallet/wallet.cpp | 4 ++-- src/wallet/walletdb.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9cf2a86cb..1208a77f2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1825,12 +1825,12 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "Received transaction to address other than notary address, ignored! \n"); return false; } - fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); + fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,(int32_t)numvoutIsOurs); // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; if ( avgVoutSize < MIN_RECV_SATS ) { // average vout size is less than set minimum, default is 1 coin, we will ignore it - fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); + fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, (long)avgVoutSize); return false; } } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 972b2cdf4..83a79821f 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -965,7 +965,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) reAdded++; } } - fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",deadTxns.size(),reAdded); + fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",(long)deadTxns.size(),reAdded); deadTxns.clear(); } From dbb33e694984e1284d6fae65d47cba233a2ffc51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:16:30 -1100 Subject: [PATCH 2858/3904] +debugs --- src/cc/rogue/list.c | 96 ++++++++++++++++++++++++-------------------- src/cc/rogue/main.c | 21 +++++++++- src/cc/rogue/rogue.c | 2 +- src/cc/rogue/rogue.h | 1 + src/cc/rogue/state.c | 6 +++ 5 files changed, 81 insertions(+), 45 deletions(-) diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 622af60cd..59abef98c 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -19,6 +19,58 @@ int total = 0; /* total dynamic memory bytes */ #endif +/* + * discard: + * Free up an item + */ + +int32_t itemcounter; +THING *thingptrs[100000]; +int32_t numptrs; + +int32_t thing_find(THING *ptr) +{ + for (i=0; i_t._t_type,thingptrs[i]->o_type,thingptrs[i]->o_type); + free(thingptrs[i]); + } + memset(thingptrs,0,sizeof(thingptrs)); + numptrs = 0; +} + /* * detach: * takes an item out of whatever linked list it might be in @@ -77,49 +129,7 @@ _free_list(THING **ptr) } } -/* - * discard: - * Free up an item - */ -int32_t itemcounter; -THING *thingptrs[100000]; -int32_t numptrs; - -void -discard(THING *item) -{ -#ifdef MASTER - total--; -#endif - if ( 0 ) - { - int32_t i; - for (i=0; i_t._t_type,thingptrs[i]->o_type,thingptrs[i]->o_type); - free(thingptrs[i]); - } - memset(thingptrs,0,sizeof(thingptrs)); - numptrs = 0; -} /* * new_item @@ -139,7 +149,7 @@ new_item(void) #else item = (THING *)calloc(1, sizeof *item); #endif - if ( 0 ) + if ( 1 ) { thingptrs[numptrs++] = item; if ( (++itemcounter % 100) == 0 ) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 6b466e9a0..d58e45e47 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -742,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys; int32_t i,numpastkeys; cJSON *retjson; + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { @@ -767,6 +767,25 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * // if not matching... panic? if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { + sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); + if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (keys= jstr(retjson,"keystrokes")) != 0 ) + { + len = strlen(keys) / 2; + pastcmp = (char *)malloc(len + 1) + decode_hex(pastcmp,len,keys); + if ( len != numpastkeys || memcmp(pastcmp,pastkeys,len) != 0 ) + { + fprintf(stderr,"pastcmp[%d] != pastkeys[%d]?\n",len,numpastkeys); + } + free(pastcmp); + } + free_json(retjson); + } + } free(pastkeys); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 478e3d2ed..5e5a66e06 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -286,7 +286,7 @@ char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) fclose(fp); num += fsize; counter++; - fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); + //fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); } *numkeysp = num; return(keystrokes); diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 8c1101fc6..ba57adbe6 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -824,6 +824,7 @@ void doctor(struct rogue_state *rs,int); void playit(struct rogue_state *rs); struct room *roomin(struct rogue_state *rs,coord *cp); +int32_t thing_find(THING *ptr); #define MAXDAEMONS 20 diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index b0176a042..b649e32ee 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1429,6 +1429,11 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) struct rogue_packitem *item; if (write_error) return(WRITESTAT); + if ( thing_find(o) < 0 ) + { + fprintf(stderr,"cant find thing.%p in list\n",o); + return(0); + } if ( o->_o._o_packch != 0 ) { item = &rs->P.roguepack[rs->P.packsize]; @@ -1478,6 +1483,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs_write_int(savef, o->_o._o_flags); rs_write_int(savef, o->_o._o_group); rs_write_string(savef, o->_o._o_label); + fprintf(stderr,"label.%p\n",o->_o._o_label); return(WRITESTAT); } From ead3aefd44cbdbb48f941bfb2d2534fd9262a844 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:19:12 -1100 Subject: [PATCH 2859/3904] Syntax --- src/cc/rogue/list.c | 1 + src/cc/rogue/main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 59abef98c..2700d9948 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -30,6 +30,7 @@ int32_t numptrs; int32_t thing_find(THING *ptr) { + int32_t i; for (i=0; i Date: Wed, 6 Mar 2019 00:19:49 -1100 Subject: [PATCH 2860/3904] Item --- src/cc/rogue/list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 2700d9948..40f141861 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -28,7 +28,7 @@ int32_t itemcounter; THING *thingptrs[100000]; int32_t numptrs; -int32_t thing_find(THING *ptr) +int32_t thing_find(THING *item) { int32_t i; for (i=0; i Date: Wed, 6 Mar 2019 00:22:33 -1100 Subject: [PATCH 2861/3904] Skeet --- src/cc/rogue/state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index b649e32ee..54188cec0 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1431,7 +1431,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) return(WRITESTAT); if ( thing_find(o) < 0 ) { - fprintf(stderr,"cant find thing.%p in list\n",o); + fprintf(stderr,"cant find thing.%p in list\n",o); sleep(3); return(0); } if ( o->_o._o_packch != 0 ) From b92ff12efea38d6de9af76a79b30079079a60320 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:26:51 -1100 Subject: [PATCH 2862/3904] +print --- src/cc/rogue/state.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 54188cec0..f0ce015cd 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1431,7 +1431,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) return(WRITESTAT); if ( thing_find(o) < 0 ) { - fprintf(stderr,"cant find thing.%p in list\n",o); sleep(3); + fprintf(stderr,"cant find thing.%p (%s) in list\n",o,inv_name(o,FALSE)); sleep(3); return(0); } if ( o->_o._o_packch != 0 ) @@ -1483,7 +1483,6 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs_write_int(savef, o->_o._o_flags); rs_write_int(savef, o->_o._o_group); rs_write_string(savef, o->_o._o_label); - fprintf(stderr,"label.%p\n",o->_o._o_label); return(WRITESTAT); } From 8a7fc182f026dd252eb58511a8f03d0676b3c256 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 6 Mar 2019 16:36:12 +0500 Subject: [PATCH 2863/3904] Fixed tokenfillbid failure (#1312) * commented preventcc call * preventcc call restored preventccvouts ++ added for 'B' --- src/cc/assets.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 6e57e816b..9ae4cc1eb 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -297,6 +297,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); else if ( inputs != tx.vout[2].nValue + tx.vout[4].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); + preventCCvouts ++; } else if( ConstrainVout(tx.vout[2], 1, origTokensCCaddr, inputs) == 0 ) // tokens to originator cc addr (tokens+nonfungible evals) return eval->Invalid("vout2 doesnt match inputs fillbuy"); @@ -468,7 +469,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti } // what does this do? - bool bPrevent = PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts); + bool bPrevent = PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts); // seems we do not need this call as we already checked vouts well //std::cerr << "AssetsValidate() PreventCC returned=" << bPrevent << std::endl; return (bPrevent); } From 5c46f7488eb7cb89dea5044968e0360d6ed66789 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:36:43 -1100 Subject: [PATCH 2864/3904] Error check things --- src/cc/rogue/list.c | 16 +++++++++++++--- src/cc/rogue/pack.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 40f141861..68d889d8b 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -24,17 +24,24 @@ int total = 0; /* total dynamic memory bytes */ * Free up an item */ +#define ENABLE_DEBUG +#define MAX_DEBUGPTRS 100000 + int32_t itemcounter; -THING *thingptrs[100000]; +THING *thingptrs[MAX_DEBUGPTRS]; int32_t numptrs; int32_t thing_find(THING *item) { +#ifdef ENABLE_DEBUG int32_t i; for (i=0; il_next = NULL; item->l_prev = NULL; return item; diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 362c65412..8ad899c7b 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -466,7 +466,14 @@ get_item(struct rogue_state *rs,char *purpose, int type) return NULL; } else + { + if ( thing_find(obj) < 0 ) + { + fprintf(stderr,"cant find thing.%p in list\n",obj); sleep(3); + return(NULL); + } return obj; + } } } return NULL; From 26078cf4abd3ce46603bb952c82e778ff8cd2a8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:41:27 -1100 Subject: [PATCH 2865/3904] +prints --- src/cc/rogue/pack.c | 2 +- src/cc/rogue/state.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 8ad899c7b..a43a7dcb5 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -467,7 +467,7 @@ get_item(struct rogue_state *rs,char *purpose, int type) } else { - if ( thing_find(obj) < 0 ) + if ( 0 && thing_find(obj) < 0 ) { fprintf(stderr,"cant find thing.%p in list\n",obj); sleep(3); return(NULL); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index f0ce015cd..25bb2e461 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1734,6 +1734,7 @@ rs_write_thing(struct rogue_state *rs,FILE *savef, THING *t) rs_write_short(savef, t->_t._t_flags); rs_write_stats(savef, &t->_t._t_stats); rs_write_room_reference(savef, t->_t._t_room); + fprintf(stderr,"pack\n"); rs_write_object_list(rs,savef, t->_t._t_pack); //fprintf(stderr,"%ld\n",ftell(savef)); @@ -2100,6 +2101,7 @@ rs_save_file(struct rogue_state *rs,FILE *savef) rs_write_coord(savef, oldpos); rs_write_coord(savef, stairs); rs_write_thing(rs,savef, &player); + fprintf(stderr,"references\n"); rs_write_object_reference(savef, player.t_pack, cur_armor); rs_write_object_reference(savef, player.t_pack, cur_ring[0]); rs_write_object_reference(savef, player.t_pack, cur_ring[1]); @@ -2107,7 +2109,9 @@ rs_save_file(struct rogue_state *rs,FILE *savef) rs_write_object_reference(savef, player.t_pack, l_last_pick); rs_write_object_reference(savef, player.t_pack, last_pick); + fprintf(stderr,"lvl_obj\n"); rs_write_object_list(rs,savef, lvl_obj); + fprintf(stderr,"mlist\n"); rs_write_thing_list(rs,savef, mlist); rs_write_places(savef,places,MAXLINES*MAXCOLS); From 0ee026a04727e8cb03bfa1c1c764de9282803bfd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:47:15 -1100 Subject: [PATCH 2866/3904] -sleep --- src/cc/rogue/pack.c | 5 +++++ src/cc/rogue/state.c | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index a43a7dcb5..7de1fd7a5 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -280,6 +280,11 @@ inventory(struct rogue_state *rs,THING *list, int type) list->o_type != FOOD && list->o_type != AMULET) && !(type == R_OR_S && (list->o_type == RING || list->o_type == STICK))) continue; + if ( thing_find(list) < 0 ) + { + fprintf(stderr,"cant find thing.(%c) in pack\n",list->o_packch); + sleep(3); + } n_objs++; #ifdef MASTER if (!list->o_packch) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 25bb2e461..9963bbc9e 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1431,7 +1431,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) return(WRITESTAT); if ( thing_find(o) < 0 ) { - fprintf(stderr,"cant find thing.%p (%s) in list\n",o,inv_name(o,FALSE)); sleep(3); + fprintf(stderr,"cant find thing.%p (%s) in list\n",o,inv_name(o,FALSE)); //sleep(3); return(0); } if ( o->_o._o_packch != 0 ) @@ -1734,7 +1734,6 @@ rs_write_thing(struct rogue_state *rs,FILE *savef, THING *t) rs_write_short(savef, t->_t._t_flags); rs_write_stats(savef, &t->_t._t_stats); rs_write_room_reference(savef, t->_t._t_room); - fprintf(stderr,"pack\n"); rs_write_object_list(rs,savef, t->_t._t_pack); //fprintf(stderr,"%ld\n",ftell(savef)); @@ -2101,7 +2100,6 @@ rs_save_file(struct rogue_state *rs,FILE *savef) rs_write_coord(savef, oldpos); rs_write_coord(savef, stairs); rs_write_thing(rs,savef, &player); - fprintf(stderr,"references\n"); rs_write_object_reference(savef, player.t_pack, cur_armor); rs_write_object_reference(savef, player.t_pack, cur_ring[0]); rs_write_object_reference(savef, player.t_pack, cur_ring[1]); @@ -2109,9 +2107,7 @@ rs_save_file(struct rogue_state *rs,FILE *savef) rs_write_object_reference(savef, player.t_pack, l_last_pick); rs_write_object_reference(savef, player.t_pack, last_pick); - fprintf(stderr,"lvl_obj\n"); rs_write_object_list(rs,savef, lvl_obj); - fprintf(stderr,"mlist\n"); rs_write_thing_list(rs,savef, mlist); rs_write_places(savef,places,MAXLINES*MAXCOLS); From df13632747546607e46b6656032a1ff51d69491c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:51:52 -1100 Subject: [PATCH 2867/3904] Brute force inventory check --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 54d7beb99..3bbb5fc53 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -25,7 +25,7 @@ command(struct rogue_state *rs) char *fp; THING *mp; static char countch, direction, newcount = FALSE; - +inventory(rs,pack, 0); if (on(player, ISHASTE)) ntimes++; /* From 8bb36334e4b39c687438a693694f0b2ece493603 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:53:04 -1100 Subject: [PATCH 2868/3904] Revert --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 3bbb5fc53..5e3b56f02 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -25,7 +25,7 @@ command(struct rogue_state *rs) char *fp; THING *mp; static char countch, direction, newcount = FALSE; -inventory(rs,pack, 0); + if (on(player, ISHASTE)) ntimes++; /* From 8ce1f9dea1ec543663d5d511fe5907a0116783e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 01:10:45 -1100 Subject: [PATCH 2869/3904] num_packitems --- src/cc/rogue/command.c | 2 +- src/cc/rogue/pack.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 5e3b56f02..affa08782 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -25,7 +25,7 @@ command(struct rogue_state *rs) char *fp; THING *mp; static char countch, direction, newcount = FALSE; - +num_packitems(rs); if (on(player, ISHASTE)) ntimes++; /* diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 7de1fd7a5..e3b20a45d 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -163,6 +163,11 @@ int32_t num_packitems(struct rogue_state *rs) int32_t type = 0,n = 0,total = 0; for (; list != NULL; list = next(list)) { + if ( thing_find(list) < 0 ) + { + fprintf(stderr,"num_packitems cant find %p\n",list); + sleep(3); + } if ( list->o_packch != 0 ) { n++; From d3e077180d6982437c7616e9637938e8259dd801 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 01:18:07 -1100 Subject: [PATCH 2870/3904] Log file --- src/cc/rogue/command.c | 1 - src/cc/rogue/fight.c | 44 +++++++++++++++++++++++------------------- src/cc/rogue/io.c | 4 ++-- src/cc/rogue/pack.c | 33 ++++++++++++++++--------------- 4 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index affa08782..84281c5a7 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -25,7 +25,6 @@ command(struct rogue_state *rs) char *fp; THING *mp; static char countch, direction, newcount = FALSE; -num_packitems(rs); if (on(player, ISHASTE)) ntimes++; /* diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 43474616e..95d7105b2 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -290,27 +290,31 @@ attack(struct rogue_state *rs,THING *mp) } when 'N': { - register THING *obj, *steal; - register int nobj; + register THING *obj, *steal; + register int nobj; + + /* + * Nymph's steal a magic item, look through the pack + * and pick out one we like. + */ + steal = NULL; + for (nobj = 0, obj = pack; obj != NULL; obj = next(obj)) + if (obj != cur_armor && obj != cur_weapon + && obj != cur_ring[LEFT] && obj != cur_ring[RIGHT] + && is_magic(obj) && rnd(++nobj) == 0) + steal = obj; + if (steal != NULL) + { + remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); + mp=NULL; + fprintf(stderr,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); - /* - * Nymph's steal a magic item, look through the pack - * and pick out one we like. - */ - steal = NULL; - for (nobj = 0, obj = pack; obj != NULL; obj = next(obj)) - if (obj != cur_armor && obj != cur_weapon - && obj != cur_ring[LEFT] && obj != cur_ring[RIGHT] - && is_magic(obj) && rnd(++nobj) == 0) - steal = obj; - if (steal != NULL) - { - remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); - mp=NULL; - leave_pack(rs,steal, FALSE, FALSE); - msg(rs,"she stole %s!", inv_name(steal, TRUE)); - discard(steal); - } + leave_pack(rs,steal, FALSE, FALSE); + msg(rs,"she stole %s!", inv_name(steal, TRUE)); + fprintf(stderr,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); + discard(steal); + fprintf(stderr,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); + } } otherwise: break; diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 994f112e2..dbbdb2cc1 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,14 +160,14 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 0 ) + if ( 1 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) fp = fopen("log","wb"); if ( fp != 0 ) { - fprintf(fp,"%d: (%c) hp.%d\n",counter,c,pstats.s_hpt); + fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); fflush(fp); counter++; } diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index e3b20a45d..d49f6aa02 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -167,6 +167,7 @@ int32_t num_packitems(struct rogue_state *rs) { fprintf(stderr,"num_packitems cant find %p\n",list); sleep(3); + return(-1); } if ( list->o_packch != 0 ) { @@ -224,29 +225,29 @@ THING * leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all) { THING *nobj; - + inpack--; nobj = obj; if (obj->o_count > 1 && !all) { - last_pick = obj; - obj->o_count--; - if (obj->o_group) - inpack++; - if (newobj) - { - nobj = new_item(); - *nobj = *obj; - next(nobj) = NULL; - prev(nobj) = NULL; - nobj->o_count = 1; - } + last_pick = obj; + obj->o_count--; + if (obj->o_group) + inpack++; + if (newobj) + { + nobj = new_item(); + *nobj = *obj; + next(nobj) = NULL; + prev(nobj) = NULL; + nobj->o_count = 1; + } } else { - last_pick = NULL; - pack_used[obj->o_packch - 'a'] = FALSE; - detach(pack, obj); + last_pick = NULL; + pack_used[obj->o_packch - 'a'] = FALSE; + detach(pack, obj); } return nobj; } From 435535f3a6c378496c059617ce1a8f61cea6ca15 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 01:21:07 -1100 Subject: [PATCH 2871/3904] Test --- src/cc/rogue/fight.c | 6 +++--- src/cc/rogue/io.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 95d7105b2..371431cd0 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -307,13 +307,13 @@ attack(struct rogue_state *rs,THING *mp) { remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); mp=NULL; - fprintf(stderr,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); + fprintf(stderr,"hp.%d num.%d\n",pstats.s_hpt,num_packitems(rs)); leave_pack(rs,steal, FALSE, FALSE); msg(rs,"she stole %s!", inv_name(steal, TRUE)); - fprintf(stderr,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); + fprintf(stderr," hp.%d num.%d\n",pstats.s_hpt,num_packitems(rs)); discard(steal); - fprintf(stderr,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); + fprintf(stderr," hp.%d num.%d\n",pstats.s_hpt,num_packitems(rs)); } } otherwise: diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index dbbdb2cc1..32f19bdb2 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -167,7 +167,7 @@ readchar(struct rogue_state *rs) fp = fopen("log","wb"); if ( fp != 0 ) { - fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs);); + fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs)); fflush(fp); counter++; } From 5c5fc9ca4868a6b63d4fc651d9471942a07bb35a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 01:23:46 -1100 Subject: [PATCH 2872/3904] ABC --- src/cc/rogue/fight.c | 6 +++--- src/cc/rogue/pack.c | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 371431cd0..ba140205e 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -307,13 +307,13 @@ attack(struct rogue_state *rs,THING *mp) { remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); mp=NULL; - fprintf(stderr,"hp.%d num.%d\n",pstats.s_hpt,num_packitems(rs)); + fprintf(stderr,"hp.%d num.%d A\n",pstats.s_hpt,num_packitems(rs)); sleep(3); leave_pack(rs,steal, FALSE, FALSE); msg(rs,"she stole %s!", inv_name(steal, TRUE)); - fprintf(stderr," hp.%d num.%d\n",pstats.s_hpt,num_packitems(rs)); + fprintf(stderr," hp.%d num.%d B\n",pstats.s_hpt,num_packitems(rs)); sleep(3); discard(steal); - fprintf(stderr," hp.%d num.%d\n",pstats.s_hpt,num_packitems(rs)); + fprintf(stderr," hp.%d num.%d C\n",pstats.s_hpt,num_packitems(rs)); sleep(3); } } otherwise: diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index d49f6aa02..e7aa8874a 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -166,8 +166,6 @@ int32_t num_packitems(struct rogue_state *rs) if ( thing_find(list) < 0 ) { fprintf(stderr,"num_packitems cant find %p\n",list); - sleep(3); - return(-1); } if ( list->o_packch != 0 ) { From 4626a8dae9d15519ee95ce80488755fb5f2afc33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 01:27:56 -1100 Subject: [PATCH 2873/3904] Test --- src/cc/rogue/fight.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index ba140205e..4c9b61da6 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -307,13 +307,14 @@ attack(struct rogue_state *rs,THING *mp) { remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); mp=NULL; - fprintf(stderr,"hp.%d num.%d A\n",pstats.s_hpt,num_packitems(rs)); sleep(3); - +if ( thing_find(steal) < 0 ) +{ + fprintf(stderr,"steal %p not foun\n",steal); + sleep(3); +} leave_pack(rs,steal, FALSE, FALSE); msg(rs,"she stole %s!", inv_name(steal, TRUE)); - fprintf(stderr," hp.%d num.%d B\n",pstats.s_hpt,num_packitems(rs)); sleep(3); discard(steal); - fprintf(stderr," hp.%d num.%d C\n",pstats.s_hpt,num_packitems(rs)); sleep(3); } } otherwise: From c4e7d1f436f570b93ffd3fb5a260d8eab8897db6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 6 Mar 2019 08:10:01 -0500 Subject: [PATCH 2874/3904] Add help docs for all -ac_* params of komodod (#1313) --- src/init.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 6049fb09f..2a612634e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -562,6 +562,36 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-metricsui", _("Set to 1 for a persistent metrics screen, 0 for sequential metrics output (default: 1 if running in a console, 0 otherwise)")); strUsage += HelpMessageOpt("-metricsrefreshtime", strprintf(_("Number of seconds between metrics refreshes (default: %u if running in a console, %u otherwise)"), 1, 600)); } + strUsage += HelpMessageGroup(_("Komodo Asset Chain options:")); + strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash")); + strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60")); + strUsage += HelpMessageOpt("-ac_cc", _("Cryptoconditions, default 0")); + strUsage += HelpMessageOpt("-ac_beam", _("BEAM integration")); + strUsage += HelpMessageOpt("-ac_coda", _("CODA integration")); + strUsage += HelpMessageOpt("-ac_cclib", _("Cryptoconditions dynamicly loadable library")); + strUsage += HelpMessageOpt("-ac_ccenable", _("Cryptoconditions to enable")); + strUsage += HelpMessageOpt("-ac_ccactivate", _("Block height to enable Cryptoconditions")); + strUsage += HelpMessageOpt("-ac_decay", _("Percentage of block reward decrease at each halving")); + strUsage += HelpMessageOpt("-ac_end", _("Block height at which block rewards will end")); + strUsage += HelpMessageOpt("-ac_eras", _("Block reward eras")); + strUsage += HelpMessageOpt("-ac_founders", _("Number of blocks between founders reward payouts")); + strUsage += HelpMessageOpt("-ac_halving", _("Number of blocks between each block reward halving")); + strUsage += HelpMessageOpt("-ac_name", _("Name of asset chain")); + strUsage += HelpMessageOpt("-ac_notarypay", _("Pay notaries, default 0")); + strUsage += HelpMessageOpt("-ac_perc", _("Percentage of block rewards paid to the founder")); + strUsage += HelpMessageOpt("-ac_private", _("Shielded transactions only (except coinbase + notaries), default is 0")); + strUsage += HelpMessageOpt("-ac_pubkey", _("Public key for receiving payments on the network")); + strUsage += HelpMessageOpt("-ac_public", _("Transparent transactions only, default 0")); + strUsage += HelpMessageOpt("-ac_reward", _("Block reward in satoshis, default is 0")); + strUsage += HelpMessageOpt("-ac_sapling", _("Sapling activation block height")); + strUsage += HelpMessageOpt("-ac_script", _("P2SH/multisig address to receive founders rewards")); + strUsage += HelpMessageOpt("-ac_staked", _("Percentage of blocks that are Proof-Of-Stake, default 0")); + strUsage += HelpMessageOpt("-ac_supply", _("Starting supply, default is 0")); + strUsage += HelpMessageOpt("-ac_timelockfrom", _("Timelocked coinbase start height")); + strUsage += HelpMessageOpt("-ac_timelockgte", _("Timelocked coinbase minimum amount to be locked")); + strUsage += HelpMessageOpt("-ac_timelockto", _("Timelocked coinbase stop height")); + strUsage += HelpMessageOpt("-ac_txpow", _("Enforce transaction-rate limit, default 0")); + strUsage += HelpMessageOpt("-ac_veruspos", _("Use Verus Proof-Of-Stake (-ac_veruspos=50) default 0")); return strUsage; } From 23ca797f73945b7c85d940762c34f6979e00d248 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 02:13:05 -1100 Subject: [PATCH 2875/3904] Remove myAddress from roc --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2397be883..289b97dfb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5393,8 +5393,8 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector Date: Wed, 6 Mar 2019 20:30:20 +0700 Subject: [PATCH 2876/3904] Fixed CCs RPC tests (#1314) * updated diceaddress rpc keys, added prints for diceaddress key / value # removed Dicemarker # fixed DiceCCaddress spelling to DiceCCAddress # NOTE myaddress/myAddress is duplicated # added DiceCCTokensAddress DiceNormalAddress # removed CCaddress * Updated keys for faucetaddress * Update cryptoconditions_oracles.py Updated address keys. * update test-rpc keys * fixed rewards test * fixed channels tests * fixed tokenCC tests --- qa/rpc-tests/cryptoconditions_channels.py | 3 ++- qa/rpc-tests/cryptoconditions_dice.py | 20 ++++++++++++-------- qa/rpc-tests/cryptoconditions_faucet.py | 14 +++++++++----- qa/rpc-tests/cryptoconditions_heir.py | 6 +++--- qa/rpc-tests/cryptoconditions_oracles.py | 4 ++-- qa/rpc-tests/cryptoconditions_rewards.py | 6 ++++-- qa/rpc-tests/cryptoconditions_token.py | 22 +++++++++++----------- 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 722cce66e..71f62f49d 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -31,7 +31,8 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): result = rpc.channelsaddress(self.pubkey) assert_success(result) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'ChannelsCCaddress', 'Channelsmarker', 'myaddress', 'CCaddress']: + for x in ['ChannelsCC1of2TokensAddress', 'myCCAddress(Channels)', 'ChannelsCC1of2Address', 'myAddress', \ + 'myCCaddress', 'ChannelsNormalAddress', 'PubkeyCCaddress(Channels)', 'ChannelsCCAddress']: assert_equal(result[x][0], 'R') # getting empty channels list diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 51fd18908..7b960cb67 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -24,15 +24,19 @@ class CryptoconditionsDiceTest(CryptoconditionsTestFramework): result = rpc1.getbalance() assert_greater_than(result, 100000) - dice = rpc.diceaddress() - assert_equal(dice['result'], 'success') - for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress']: - assert_equal(dice[x][0], 'R') + result = rpc.diceaddress() + for x in result.keys(): + print(x+": "+str(result[x])) + assert_equal(result['result'], 'success') + for x in ['myCCaddress', 'DiceCCAddress', 'myaddress']: + assert_equal(result[x][0], 'R') - dice = rpc.diceaddress(self.pubkey) - assert_equal(dice['result'], 'success') - for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress', 'CCaddress']: - assert_equal(dice[x][0], 'R') + result = rpc.diceaddress(self.pubkey) + for x in result.keys(): + print(x+": "+str(result[x])) + assert_equal(result['result'], 'success') + for x in ['myCCaddress', 'DiceCCAddress', 'myaddress', 'DiceCCTokensAddress', 'DiceNormalAddress']: + assert_equal(result[x][0], 'R') # no dice created yet result = rpc.dicelist() diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index a3cbdeb15..c02522cc5 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -24,16 +24,20 @@ class CryptoconditionsFaucetTest(CryptoconditionsTestFramework): assert_greater_than(result['balance'], 0.0) balance = result['balance'] - faucet = rpc.faucetaddress() - assert_equal(faucet['result'], 'success') + result = rpc.faucetaddress() + assert_equal(result['result'], 'success') + for x in result.keys(): + print(x+": "+str(result[x])) # verify all keys look like valid AC addrs, could be better - for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress']: - assert_equal(faucet[x][0], 'R') + for x in ['myCCaddress', 'FaucetCCTokensAddress', 'FaucetNormalAddress', 'myaddress']: + assert_equal(result[x][0], 'R') result = rpc.faucetaddress(self.pubkey) assert_success(result) + for x in result.keys(): + print(x+": "+str(result[x])) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress', 'CCaddress']: + for x in ['myCCaddress', 'FaucetCCTokensAddress', 'FaucetNormalAddress', 'myaddress']: assert_equal(result[x][0], 'R') # no funds in the faucet yet diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index b79ae7bba..a2443f0b3 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -20,16 +20,16 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] - result = rpc.heiraddress() + result = rpc.heiraddress('') assert_success(result) # verify all keys look like valid AC addrs, could be better - for x in ['myCCaddress', 'HeirCCaddress', 'Heirmarker', 'myaddress']: + for x in ['HeirNormalAddress', 'HeirCCTokensAddress', 'myaddress', 'myCCaddress', 'HeirCCAddress']: assert_equal(result[x][0], 'R') result = rpc.heiraddress(self.pubkey) assert_success(result) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'HeirCCaddress', 'Heirmarker', 'myaddress', 'CCaddress']: + for x in ['HeirNormalAddress', 'myCCaddress', 'myaddress', 'HeirCC1of2Address', 'HeirCCAddress', 'HeirCC1of2TokensAddress']: assert_equal(result[x][0], 'R') # getting empty heir list diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 048b577d1..008ab6256 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -22,12 +22,12 @@ class CryptoconditionsOraclesTest(CryptoconditionsTestFramework): result = rpc.oraclesaddress() assert_success(result) - for x in ['OraclesCCaddress', 'Oraclesmarker', 'myCCaddress', 'myaddress']: + for x in ['myCCaddress', 'OraclesCCAddress', 'OraclesNormalAddress', 'myaddress', 'OraclesCCTokensAddress']: assert_equal(result[x][0], 'R') result = rpc.oraclesaddress(self.pubkey) assert_success(result) - for x in ['OraclesCCaddress', 'Oraclesmarker', 'myCCaddress', 'myaddress']: + for x in ['myCCaddress', 'OraclesCCAddress', 'OraclesNormalAddress', 'myaddress', 'OraclesCCTokensAddress']: assert_equal(result[x][0], 'R') # there are no oracles created yet diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 7bda54eaf..d70e40740 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -15,13 +15,15 @@ from cryptoconditions import assert_success, assert_error, generate_random_strin class CryptoconditionsRewardsTest(CryptoconditionsTestFramework): def run_rewards_tests(self): + rpc = self.nodes[0] + result = rpc.rewardsaddress() - for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress']: + for x in ['myCCaddress', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.rewardsaddress(self.pubkey) - for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress', 'CCaddress']: + for x in ['myCCaddress', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: assert_equal(result[x][0], 'R') # no rewards yet diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 97ed86f8d..faf2cbc8d 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -21,22 +21,22 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): result = rpc.tokenaddress() assert_success(result) - for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress']: + for x in ['TokensCCAddress', 'myCCaddress', 'myCCAddress(Tokens)', 'myaddress', 'TokensNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.tokenaddress(self.pubkey) assert_success(result) - for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress', 'CCaddress']: + for x in ['TokensCCAddress', 'myCCaddress', 'myCCAddress(Tokens)', 'myaddress', 'TokensNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.assetsaddress() assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress']: + for x in ['AssetsCCAddress', 'myCCaddress', 'myCCAddress(Assets)', 'myaddress', 'AssetsNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.assetsaddress(self.pubkey) assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress', 'CCaddress']: + for x in ['AssetsCCAddress', 'myCCaddress', 'myCCAddress(Assets)', 'myaddress', 'AssetsNormalAddress']: assert_equal(result[x][0], 'R') # there are no tokens created yet @@ -61,7 +61,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): assert_equal(result[0], tokenid) # there are no token orders yet - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # getting token balance for non existing tokenid @@ -117,7 +117,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): tokenask = rpc.tokenask("100", tokenid, "7.77") tokenaskhex = tokenask['hex'] tokenaskid = self.send_and_mine(tokenask['hex'], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) order = result[0] assert order, "found order" @@ -136,7 +136,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): assert txid, "found txid" # should be no token orders - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # checking ask cancellation @@ -157,7 +157,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): # from valid node cancel = rpc.tokencancelask(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) @@ -184,7 +184,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): tokenbid = rpc.tokenbid("100", tokenid, "10") tokenbidhex = tokenbid['hex'] tokenbidid = self.send_and_mine(tokenbid['hex'], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) order = result[0] assert order, "found order" @@ -203,7 +203,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): assert txid, "found txid" # should be no token orders - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # checking bid cancellation @@ -220,7 +220,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): # from valid node cancel = rpc.tokencancelbid(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # invalid token transfer amount (have to add status to CC code!) From 6a7e9592de85896374ad92b7d02ee90217b36db7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 02:41:39 -1100 Subject: [PATCH 2877/3904] +print --- src/cc/rogue/fight.c | 5 ----- src/cc/rogue/pack.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 4c9b61da6..e65e96d76 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -307,11 +307,6 @@ attack(struct rogue_state *rs,THING *mp) { remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); mp=NULL; -if ( thing_find(steal) < 0 ) -{ - fprintf(stderr,"steal %p not foun\n",steal); - sleep(3); -} leave_pack(rs,steal, FALSE, FALSE); msg(rs,"she stole %s!", inv_name(steal, TRUE)); discard(steal); diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index e7aa8874a..d7622a5e7 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -226,6 +226,11 @@ leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all) inpack--; nobj = obj; + if ( thing_find(obj) < 0 ) + { + fprintf(stderr,"leave_pack unknown obj %p\n",obj); + sleep(3); + } if (obj->o_count > 1 && !all) { last_pick = obj; From 891bfb4b9d4c582e94f6c2cc8fa33028a72afe85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 02:51:03 -1100 Subject: [PATCH 2878/3904] Test --- src/cc/rogue/pack.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index d7622a5e7..c49b87140 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -166,6 +166,7 @@ int32_t num_packitems(struct rogue_state *rs) if ( thing_find(list) < 0 ) { fprintf(stderr,"num_packitems cant find %p\n",list); + return(-1); } if ( list->o_packch != 0 ) { @@ -226,11 +227,6 @@ leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all) inpack--; nobj = obj; - if ( thing_find(obj) < 0 ) - { - fprintf(stderr,"leave_pack unknown obj %p\n",obj); - sleep(3); - } if (obj->o_count > 1 && !all) { last_pick = obj; @@ -289,11 +285,11 @@ inventory(struct rogue_state *rs,THING *list, int type) list->o_type != FOOD && list->o_type != AMULET) && !(type == R_OR_S && (list->o_type == RING || list->o_type == STICK))) continue; - if ( thing_find(list) < 0 ) + /*if ( thing_find(list) < 0 ) { fprintf(stderr,"cant find thing.(%c) in pack\n",list->o_packch); sleep(3); - } + }*/ n_objs++; #ifdef MASTER if (!list->o_packch) From ab4fde8764b2748b1ecf4e4e2a2a4d03de7dd5e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:03:46 -1100 Subject: [PATCH 2879/3904] Test --- src/cc/rogue/fight.c | 26 ++++++++++++-------------- src/cc/rogue/list.c | 35 +++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index e65e96d76..ae2db635d 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -290,8 +290,7 @@ attack(struct rogue_state *rs,THING *mp) } when 'N': { - register THING *obj, *steal; - register int nobj; + THING *obj, *steal; int nobj; /* * Nymph's steal a magic item, look through the pack @@ -594,26 +593,25 @@ void remove_mon(struct rogue_state *rs,coord *mp, THING *tp, bool waskill) { register THING *obj, *nexti; - for (obj = tp->t_pack; obj != NULL; obj = nexti) { - nexti = next(obj); - obj->o_pos = tp->t_pos; - detach(tp->t_pack, obj); - if (waskill) - fall(rs,obj, FALSE); - else - discard(obj); + nexti = next(obj); + obj->o_pos = tp->t_pos; + detach(tp->t_pack, obj); + if (waskill) + fall(rs,obj, FALSE); + else + discard(obj); } moat(mp->y, mp->x) = NULL; mvaddch(mp->y, mp->x, tp->t_oldch); detach(mlist, tp); if (on(*tp, ISTARGET)) { - kamikaze = FALSE; - to_death = FALSE; - if (fight_flush) - flush_type(); + kamikaze = FALSE; + to_death = FALSE; + if (fight_flush) + flush_type(); } discard(tp); } diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 68d889d8b..60eac8b16 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -61,6 +61,16 @@ discard(THING *item) break; } } + THING *list = pack; + for (; list != NULL; list = next(list)) + { + if ( list == item ) + { + fprintf(stderr,"pack item discarded? (%s)\n",inv_name(list,FALSE)); + sleep(3); + break; + } + } #endif itemcounter--; free((char *) item); @@ -89,11 +99,11 @@ void _detach(THING **list, THING *item) { if (*list == item) - *list = next(item); + *list = next(item); if (prev(item) != NULL) - item->l_prev->l_next = next(item); + item->l_prev->l_next = next(item); if (next(item) != NULL) - item->l_next->l_prev = prev(item); + item->l_next->l_prev = prev(item); item->l_next = NULL; item->l_prev = NULL; } @@ -108,14 +118,14 @@ _attach(THING **list, THING *item) { if (*list != NULL) { - item->l_next = *list; - (*list)->l_prev = item; - item->l_prev = NULL; + item->l_next = *list; + (*list)->l_prev = item; + item->l_prev = NULL; } else { - item->l_next = NULL; - item->l_prev = NULL; + item->l_next = NULL; + item->l_prev = NULL; } *list = item; } @@ -129,17 +139,14 @@ void _free_list(THING **ptr) { THING *item; - while (*ptr != NULL) { - item = *ptr; - *ptr = next(item); - discard(item); + item = *ptr; + *ptr = next(item); + discard(item); } } - - /* * new_item * Get a new item with a specified size From 90b730090474e0308d46aa365b169c823a48a9a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:09:47 -1100 Subject: [PATCH 2880/3904] Leave pack all --- src/cc/rogue/fight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index ae2db635d..6d81a53fe 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -306,7 +306,7 @@ attack(struct rogue_state *rs,THING *mp) { remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); mp=NULL; - leave_pack(rs,steal, FALSE, FALSE); + leave_pack(rs,steal, FALSE, TRUE);//FALSE); msg(rs,"she stole %s!", inv_name(steal, TRUE)); discard(steal); } From 53b12740a38ddaed0b77526d4dbb63ade876159b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:14:43 -1100 Subject: [PATCH 2881/3904] Dont discard unless last o_count --- src/cc/rogue/fight.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 6d81a53fe..0e512d4b7 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -306,7 +306,7 @@ attack(struct rogue_state *rs,THING *mp) { remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); mp=NULL; - leave_pack(rs,steal, FALSE, TRUE);//FALSE); + leave_pack(rs,steal, FALSE, FALSE); msg(rs,"she stole %s!", inv_name(steal, TRUE)); discard(steal); } @@ -600,7 +600,7 @@ remove_mon(struct rogue_state *rs,coord *mp, THING *tp, bool waskill) detach(tp->t_pack, obj); if (waskill) fall(rs,obj, FALSE); - else + else if ( obj->o_count <= 0 ) discard(obj); } moat(mp->y, mp->x) = NULL; From 25e1e4c703a75662e0abd0a393eb1834d6f033e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:17:32 -1100 Subject: [PATCH 2882/3904] Prevent pack corruption --- src/cc/rogue/fight.c | 6 +++--- src/cc/rogue/potions.c | 2 +- src/cc/rogue/scrolls.c | 2 +- src/cc/rogue/weapons.c | 38 +++++++++++++++++++------------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 0e512d4b7..9cb4bf61e 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -308,7 +308,8 @@ attack(struct rogue_state *rs,THING *mp) mp=NULL; leave_pack(rs,steal, FALSE, FALSE); msg(rs,"she stole %s!", inv_name(steal, TRUE)); - discard(steal); + if ( steal->o_count <= 0 ) + discard(steal); } } otherwise: @@ -600,8 +601,7 @@ remove_mon(struct rogue_state *rs,coord *mp, THING *tp, bool waskill) detach(tp->t_pack, obj); if (waskill) fall(rs,obj, FALSE); - else if ( obj->o_count <= 0 ) - discard(obj); + else discard(obj); } moat(mp->y, mp->x) = NULL; mvaddch(mp->y, mp->x, tp->t_oldch); diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 00865b5dd..b10f83bd4 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -220,7 +220,7 @@ quaff(struct rogue_state *rs) call_it(rs,&pot_info[obj->o_which]); if (discardit) - discard(obj); + discard(obj); return; } diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index 5554a5701..8ed6d2648 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -313,7 +313,7 @@ def: call_it(rs,&scr_info[obj->o_which]); if (discardit) - discard(obj); + discard(obj); } /* diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index e313bf9d3..0a8b6016c 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -129,28 +129,28 @@ fall(struct rogue_state *rs,THING *obj, bool pr) if (fallpos(&obj->o_pos, &fpos)) { - pp = INDEX(fpos.y, fpos.x); - pp->p_ch = (char) obj->o_type; - obj->o_pos = fpos; - if (cansee(rs,fpos.y, fpos.x)) - { - if (pp->p_monst != NULL) - pp->p_monst->t_oldch = (char) obj->o_type; - else - mvaddch(fpos.y, fpos.x, obj->o_type); - } - attach(lvl_obj, obj); - return; + pp = INDEX(fpos.y, fpos.x); + pp->p_ch = (char) obj->o_type; + obj->o_pos = fpos; + if (cansee(rs,fpos.y, fpos.x)) + { + if (pp->p_monst != NULL) + pp->p_monst->t_oldch = (char) obj->o_type; + else + mvaddch(fpos.y, fpos.x, obj->o_type); + } + attach(lvl_obj, obj); + return; } if (pr) { - if (has_hit) - { - endmsg(rs); - has_hit = FALSE; - } - msg(rs,"the %s vanishes as it hits the ground", - weap_info[obj->o_which].oi_name); + if (has_hit) + { + endmsg(rs); + has_hit = FALSE; + } + msg(rs,"the %s vanishes as it hits the ground", + weap_info[obj->o_which].oi_name); } discard(obj); } From e670687db59468245b500ff817dd5dde1c1e78ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:20:41 -1100 Subject: [PATCH 2883/3904] -ddebugs --- src/cc/rogue/io.c | 2 +- src/cc/rogue/list.c | 2 +- src/cc/rogue/pack.c | 10 ---------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 32f19bdb2..4c289ad7d 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,7 +160,7 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 1 ) + if ( 0 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 60eac8b16..a021c6a8f 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -24,7 +24,7 @@ int total = 0; /* total dynamic memory bytes */ * Free up an item */ -#define ENABLE_DEBUG +//#define ENABLE_DEBUG #define MAX_DEBUGPTRS 100000 int32_t itemcounter; diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index c49b87140..1f2f3faaa 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -285,11 +285,6 @@ inventory(struct rogue_state *rs,THING *list, int type) list->o_type != FOOD && list->o_type != AMULET) && !(type == R_OR_S && (list->o_type == RING || list->o_type == STICK))) continue; - /*if ( thing_find(list) < 0 ) - { - fprintf(stderr,"cant find thing.(%c) in pack\n",list->o_packch); - sleep(3); - }*/ n_objs++; #ifdef MASTER if (!list->o_packch) @@ -477,11 +472,6 @@ get_item(struct rogue_state *rs,char *purpose, int type) } else { - if ( 0 && thing_find(obj) < 0 ) - { - fprintf(stderr,"cant find thing.%p in list\n",obj); sleep(3); - return(NULL); - } return obj; } } From fb89be82f12f567409a0652df530d9bc577729f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:36:36 -1100 Subject: [PATCH 2884/3904] Merge branch 'FSM' into jl777 # Conflicts: # src/cc/rogue/main.c --- qa/rpc-tests/cryptoconditions_channels.py | 3 ++- qa/rpc-tests/cryptoconditions_dice.py | 20 ++++++++++++-------- qa/rpc-tests/cryptoconditions_faucet.py | 14 +++++++++----- qa/rpc-tests/cryptoconditions_heir.py | 6 +++--- qa/rpc-tests/cryptoconditions_oracles.py | 4 ++-- qa/rpc-tests/cryptoconditions_rewards.py | 6 ++++-- qa/rpc-tests/cryptoconditions_token.py | 22 +++++++++++----------- src/cc/assets.cpp | 3 ++- 8 files changed, 45 insertions(+), 33 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 722cce66e..71f62f49d 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -31,7 +31,8 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): result = rpc.channelsaddress(self.pubkey) assert_success(result) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'ChannelsCCaddress', 'Channelsmarker', 'myaddress', 'CCaddress']: + for x in ['ChannelsCC1of2TokensAddress', 'myCCAddress(Channels)', 'ChannelsCC1of2Address', 'myAddress', \ + 'myCCaddress', 'ChannelsNormalAddress', 'PubkeyCCaddress(Channels)', 'ChannelsCCAddress']: assert_equal(result[x][0], 'R') # getting empty channels list diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 51fd18908..7b960cb67 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -24,15 +24,19 @@ class CryptoconditionsDiceTest(CryptoconditionsTestFramework): result = rpc1.getbalance() assert_greater_than(result, 100000) - dice = rpc.diceaddress() - assert_equal(dice['result'], 'success') - for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress']: - assert_equal(dice[x][0], 'R') + result = rpc.diceaddress() + for x in result.keys(): + print(x+": "+str(result[x])) + assert_equal(result['result'], 'success') + for x in ['myCCaddress', 'DiceCCAddress', 'myaddress']: + assert_equal(result[x][0], 'R') - dice = rpc.diceaddress(self.pubkey) - assert_equal(dice['result'], 'success') - for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress', 'CCaddress']: - assert_equal(dice[x][0], 'R') + result = rpc.diceaddress(self.pubkey) + for x in result.keys(): + print(x+": "+str(result[x])) + assert_equal(result['result'], 'success') + for x in ['myCCaddress', 'DiceCCAddress', 'myaddress', 'DiceCCTokensAddress', 'DiceNormalAddress']: + assert_equal(result[x][0], 'R') # no dice created yet result = rpc.dicelist() diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index a3cbdeb15..c02522cc5 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -24,16 +24,20 @@ class CryptoconditionsFaucetTest(CryptoconditionsTestFramework): assert_greater_than(result['balance'], 0.0) balance = result['balance'] - faucet = rpc.faucetaddress() - assert_equal(faucet['result'], 'success') + result = rpc.faucetaddress() + assert_equal(result['result'], 'success') + for x in result.keys(): + print(x+": "+str(result[x])) # verify all keys look like valid AC addrs, could be better - for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress']: - assert_equal(faucet[x][0], 'R') + for x in ['myCCaddress', 'FaucetCCTokensAddress', 'FaucetNormalAddress', 'myaddress']: + assert_equal(result[x][0], 'R') result = rpc.faucetaddress(self.pubkey) assert_success(result) + for x in result.keys(): + print(x+": "+str(result[x])) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress', 'CCaddress']: + for x in ['myCCaddress', 'FaucetCCTokensAddress', 'FaucetNormalAddress', 'myaddress']: assert_equal(result[x][0], 'R') # no funds in the faucet yet diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index b79ae7bba..a2443f0b3 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -20,16 +20,16 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] - result = rpc.heiraddress() + result = rpc.heiraddress('') assert_success(result) # verify all keys look like valid AC addrs, could be better - for x in ['myCCaddress', 'HeirCCaddress', 'Heirmarker', 'myaddress']: + for x in ['HeirNormalAddress', 'HeirCCTokensAddress', 'myaddress', 'myCCaddress', 'HeirCCAddress']: assert_equal(result[x][0], 'R') result = rpc.heiraddress(self.pubkey) assert_success(result) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'HeirCCaddress', 'Heirmarker', 'myaddress', 'CCaddress']: + for x in ['HeirNormalAddress', 'myCCaddress', 'myaddress', 'HeirCC1of2Address', 'HeirCCAddress', 'HeirCC1of2TokensAddress']: assert_equal(result[x][0], 'R') # getting empty heir list diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 048b577d1..008ab6256 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -22,12 +22,12 @@ class CryptoconditionsOraclesTest(CryptoconditionsTestFramework): result = rpc.oraclesaddress() assert_success(result) - for x in ['OraclesCCaddress', 'Oraclesmarker', 'myCCaddress', 'myaddress']: + for x in ['myCCaddress', 'OraclesCCAddress', 'OraclesNormalAddress', 'myaddress', 'OraclesCCTokensAddress']: assert_equal(result[x][0], 'R') result = rpc.oraclesaddress(self.pubkey) assert_success(result) - for x in ['OraclesCCaddress', 'Oraclesmarker', 'myCCaddress', 'myaddress']: + for x in ['myCCaddress', 'OraclesCCAddress', 'OraclesNormalAddress', 'myaddress', 'OraclesCCTokensAddress']: assert_equal(result[x][0], 'R') # there are no oracles created yet diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 7bda54eaf..d70e40740 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -15,13 +15,15 @@ from cryptoconditions import assert_success, assert_error, generate_random_strin class CryptoconditionsRewardsTest(CryptoconditionsTestFramework): def run_rewards_tests(self): + rpc = self.nodes[0] + result = rpc.rewardsaddress() - for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress']: + for x in ['myCCaddress', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.rewardsaddress(self.pubkey) - for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress', 'CCaddress']: + for x in ['myCCaddress', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: assert_equal(result[x][0], 'R') # no rewards yet diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 97ed86f8d..faf2cbc8d 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -21,22 +21,22 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): result = rpc.tokenaddress() assert_success(result) - for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress']: + for x in ['TokensCCAddress', 'myCCaddress', 'myCCAddress(Tokens)', 'myaddress', 'TokensNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.tokenaddress(self.pubkey) assert_success(result) - for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress', 'CCaddress']: + for x in ['TokensCCAddress', 'myCCaddress', 'myCCAddress(Tokens)', 'myaddress', 'TokensNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.assetsaddress() assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress']: + for x in ['AssetsCCAddress', 'myCCaddress', 'myCCAddress(Assets)', 'myaddress', 'AssetsNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.assetsaddress(self.pubkey) assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress', 'CCaddress']: + for x in ['AssetsCCAddress', 'myCCaddress', 'myCCAddress(Assets)', 'myaddress', 'AssetsNormalAddress']: assert_equal(result[x][0], 'R') # there are no tokens created yet @@ -61,7 +61,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): assert_equal(result[0], tokenid) # there are no token orders yet - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # getting token balance for non existing tokenid @@ -117,7 +117,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): tokenask = rpc.tokenask("100", tokenid, "7.77") tokenaskhex = tokenask['hex'] tokenaskid = self.send_and_mine(tokenask['hex'], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) order = result[0] assert order, "found order" @@ -136,7 +136,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): assert txid, "found txid" # should be no token orders - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # checking ask cancellation @@ -157,7 +157,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): # from valid node cancel = rpc.tokencancelask(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) @@ -184,7 +184,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): tokenbid = rpc.tokenbid("100", tokenid, "10") tokenbidhex = tokenbid['hex'] tokenbidid = self.send_and_mine(tokenbid['hex'], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) order = result[0] assert order, "found order" @@ -203,7 +203,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): assert txid, "found txid" # should be no token orders - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # checking bid cancellation @@ -220,7 +220,7 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): # from valid node cancel = rpc.tokencancelbid(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # invalid token transfer amount (have to add status to CC code!) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 6e57e816b..9ae4cc1eb 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -297,6 +297,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); else if ( inputs != tx.vout[2].nValue + tx.vout[4].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); + preventCCvouts ++; } else if( ConstrainVout(tx.vout[2], 1, origTokensCCaddr, inputs) == 0 ) // tokens to originator cc addr (tokens+nonfungible evals) return eval->Invalid("vout2 doesnt match inputs fillbuy"); @@ -468,7 +469,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti } // what does this do? - bool bPrevent = PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts); + bool bPrevent = PreventCC(eval, tx, preventCCvins, numvins, preventCCvouts, numvouts); // seems we do not need this call as we already checked vouts well //std::cerr << "AssetsValidate() PreventCC returned=" << bPrevent << std::endl; return (bPrevent); } From 100eac16540646e98fb02cd36a935ee57da6741e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:38:14 -1100 Subject: [PATCH 2885/3904] Jl777 (#1315) * Remove voutsum check * Teach RPC interface about dpow-enabled minconfs (#1231) * Make minconfs dpow-aware in z_listunspent + z_listreceivedbyaddress * Add dpow-related test files to test suite * Add dpow simulation to regtest every 7 blocks * Fix compiler errors * Fix link error * Fix stdout spam when running regtests * Dpowminconfs for listreceivedbyaddress * dpowconfs tests * Start adding specific tests for dpowminconfs in listreceivedbyaddress * Get dpowminconfs tests for listreceivedbyaddress working * Add dpowminconfs to getreceivedbyaddress + listunspent * Add test for listtransactions + getreceivedbyaddress support * Reliably passing dpowminconf tests. We only check for notarized-ness now, not exact confirmation numbers, to avoid race conditions * Poll for the expected notarization info before running further tests; add support for getbalance * Migrate tx_height() to a place where asyncrpcoperation_sendmany.cpp can use it * fix * Teach GetFilteredNotes about dpowconfs Many RPCs rely on this internal function, which now correctly uses dpowconfs to filter by the minconf/maxconf parameters. * Fix sendmany when using non-default minconf * inline seems to make things happy * cleanup * Add some code to test z_sendmany, which points out https://github.com/jl777/komodo/issues/1247 * try this * Use already calculated value of dpowconfs instead of calculating it again * Cleanup .pack file * Remove * Remove .pack * Disable passkeys * Rvalidate * Syntax * Allow overwrite by same pub33 * Tx * Declare variables * Allow replacement handle * Grandfather existing handles * Test * Handleinfo * Char * * Begin * Add mutex * CCaddr * Casts for windows * +debugs * Syntax * Item * Skeet * +print * Error check things * +prints * -sleep * Brute force inventory check * Revert * num_packitems * Log file * Test * ABC * Test * Add help docs for all -ac_* params of komodod (#1313) * Remove myAddress from roc * +print * Test * Test * Leave pack all * Dont discard unless last o_count * Prevent pack corruption * -ddebugs * Merge branch 'FSM' into jl777 # Conflicts: # src/cc/rogue/main.c --- src/cc/CCinclude.h | 1 + src/cc/cclib.cpp | 29 ++++++ src/cc/dilithium.c | 200 +++++++++++++++++++++++++++++++++++++-- src/cc/rogue/command.c | 1 - src/cc/rogue/fight.c | 64 ++++++------- src/cc/rogue/io.c | 2 +- src/cc/rogue/list.c | 150 +++++++++++++++++------------ src/cc/rogue/main.c | 23 ++++- src/cc/rogue/pack.c | 39 ++++---- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rogue.c | 2 +- src/cc/rogue/rogue.h | 1 + src/cc/rogue/scrolls.c | 2 +- src/cc/rogue/state.c | 5 + src/cc/rogue/weapons.c | 38 ++++---- src/init.cpp | 30 ++++++ src/wallet/rpcwallet.cpp | 4 +- src/wallet/wallet.cpp | 4 +- src/wallet/walletdb.cpp | 2 +- 19 files changed, 449 insertions(+), 150 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 91e9467dd..f5877c711 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -201,6 +201,7 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, CScript EncodeTokenImportOpRet(std::vector origpubkey, std::string name, std::string description, uint256 srctokenid, std::vector> oprets); CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::pair opretWithId); CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector> oprets); +int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description); uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector> &oprets); uint8_t DecodeTokenImportOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, uint256 &srctokenid, std::vector> &oprets); diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 121a16475..651723e44 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -83,6 +83,7 @@ CClib_methods[] = { (char *)"musig", (char *)"spend", (char *)"sendtxid sig scriptPubKey", 3, 3, 'y', EVAL_MUSIG }, { (char *)"dilithium", (char *)"keypair", (char *)"[hexseed]", 0, 1, 'K', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"register", (char *)"handle, [hexseed]", 1, 2, 'R', EVAL_DILITHIUM }, + { (char *)"dilithium", (char *)"handleinfo", (char *)"handle", 1, 1, 'I', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"sign", (char *)"msg [hexseed]", 1, 2, 'S', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"verify", (char *)"pubtxid msg sig", 3, 3, 'V', EVAL_DILITHIUM }, { (char *)"dilithium", (char *)"send", (char *)"handle pubtxid amount", 3, 3, 'x', EVAL_DILITHIUM }, @@ -130,6 +131,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -273,6 +275,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(dilithium_keypair(txfee,cp,params)); else if ( strcmp(method,"register") == 0 ) return(dilithium_register(txfee,cp,params)); + else if ( strcmp(method,"handleinfo") == 0 ) + return(dilithium_handleinfo(txfee,cp,params)); else if ( strcmp(method,"sign") == 0 ) return(dilithium_sign(txfee,cp,params)); else if ( strcmp(method,"verify") == 0 ) @@ -504,6 +508,31 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } +int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk) +{ + char coinaddr[64]; int64_t nValue,txfee = 10000; uint256 txid,hashBlock; CTransaction vintx; int32_t vout; + std::vector > unspentOutputs; + GetCCaddress(cp,coinaddr,pk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); + if ( it->second.satoshis < txfee ) + continue; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + { + if ( (nValue= IsCClibvout(cp,vintx,vout,coinaddr)) != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + { + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + return(it->second.satoshis); + } //else fprintf(stderr,"nValue %.8f too small or already spent in mempool\n",(double)nValue/COIN); + } else fprintf(stderr,"couldnt get tx\n"); + } + return(0); +} + std::string Faucet2Fund(struct CCcontract_info *cp,uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index e36ea807e..b92102f22 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2929,6 +2929,45 @@ int32_t main(void) void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); +struct dilithium_handle +{ + UT_hash_handle hh; + uint256 destpubtxid; + char handle[32]; +} *Dilithium_handles; + +pthread_mutex_t DILITHIUM_MUTEX; + +struct dilithium_handle *dilithium_handlenew(char *handle) +{ + struct dilithium_handle *hashstr = 0; int32_t len = (int32_t)strlen(handle); + if ( len < sizeof(Dilithium_handles[0].handle)-1 ) + { + pthread_mutex_lock(&DILITHIUM_MUTEX); + HASH_FIND(hh,Dilithium_handles,handle,len,hashstr); + if ( hashstr == 0 ) + { + hashstr = (struct dilithium_handle *)calloc(1,sizeof(*hashstr)); + strncpy(hashstr->handle,handle,sizeof(hashstr->handle)); + HASH_ADD_KEYPTR(hh,Dilithium_handles,hashstr->handle,len,hashstr); + } + pthread_mutex_unlock(&DILITHIUM_MUTEX); + } + return(hashstr); +} + +struct dilithium_handle *dilithium_handlefind(char *handle) +{ + struct dilithium_handle *hashstr = 0; int32_t len = (int32_t)strlen(handle); + if ( len < sizeof(Dilithium_handles[0].handle)-1 ) + { + pthread_mutex_lock(&DILITHIUM_MUTEX); + HASH_FIND(hh,Dilithium_handles,handle,len,hashstr); + pthread_mutex_unlock(&DILITHIUM_MUTEX); + } + return(hashstr); +} + int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector voutpubtxids) { CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; @@ -3110,12 +3149,20 @@ UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *para return(result); } +CPubKey Faucet_pubkeyget() +{ + struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_FAUCET); + return(GetUnspendable(cp,0)); +} + UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,dilithiumpk; uint8_t seed[SEEDBYTES],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[CRYPTO_SECRETKEYBYTES*2+1]; std::vector bigpub; int32_t i,n,warningflag = 0; + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey faucetpk,mypk,dilithiumpk; uint8_t seed[SEEDBYTES],pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char coinaddr[64],str[CRYPTO_SECRETKEYBYTES*2+1]; int64_t CCchange,inputs; std::vector bigpub; int32_t i,n,warningflag = 0; if ( txfee == 0 ) txfee = DILITHIUM_TXFEE; + faucetpk = Faucet_pubkeyget(); mypk = pubkey2pk(Mypubkey()); dilithiumpk = GetUnspendable(cp,0); if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 1 || n == 2) ) @@ -3132,14 +3179,23 @@ UniValue dilithium_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *par result.push_back(Pair("skaddr",dilithium_addr(coinaddr,sk,CRYPTO_SECRETKEYBYTES))); for (i=0; i= 3*txfee ) + if ( (inputs= AddCClibtxfee(cp,mtx,dilithiumpk)) > 0 ) { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,dilithiumpk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_registeropret(handle,mypk,bigpub)); - return(musig_rawtxresult(result,rawtx)); - } else return(cclib_error(result,"couldnt find enough funds")); - } else return(cclib_error(result,"not enough parameters")); + if ( inputs > txfee ) + CCchange = (inputs - txfee); + else CCchange = 0; + if ( AddNormalinputs(mtx,mypk,COIN+3*txfee,64) >= 3*txfee ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,2*txfee,dilithiumpk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET,COIN,faucetpk)); + if ( CCchange != 0 ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,dilithiumpk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,dilithium_registeropret(handle,mypk,bigpub)); + return(musig_rawtxresult(result,rawtx)); + } else return(cclib_error(result,"couldnt find enough funds")); + } else return(cclib_error(result,"not enough parameters")); + } else return(cclib_error(result,"not dilithiumpk funds")); } UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) @@ -3452,6 +3508,130 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co } else return eval->Invalid("unexpected zero signerpubtxid"); } +int32_t dilithium_registrationpub33(char *pkaddr,CPubKey &pub33,uint256 txid) +{ + std::string handle; std::vector bigpub; CTransaction tx; uint256 hashBlock; int32_t numvouts; + pkaddr[0] = 0; + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + dilithium_addr(pkaddr,&bigpub[0],CRYPTO_PUBLICKEYBYTES); + return(0); + } + } + return(-1); +} + +void dilithium_handleinit(struct CCcontract_info *cp) +{ + static int32_t didinit; + std::vector > txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector bigpub; std::string handle; char CCaddr[64]; + if ( didinit != 0 ) + return; + pthread_mutex_init(&DILITHIUM_MUTEX,NULL); + dilithiumpk = GetUnspendable(cp,0); + GetCCaddress(cp,CCaddr,dilithiumpk); + SetCCtxids(txids,CCaddr); + for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + { + txid = it->first.txhash; + if ( myGetTransaction(txid,txi,hashBlock) != 0 && (numvouts= txi.vout.size()) > 1 ) + { + if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( (hashstr= dilithium_handlenew((char *)handle.c_str())) != 0 ) + { + if ( hashstr->destpubtxid != txid ) + { + if ( hashstr->destpubtxid != zeroid ) + fprintf(stderr,"overwriting %s %s with %s\n",handle.c_str(),hashstr->destpubtxid.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"%s <- %s\n",handle.c_str(),txid.GetHex().c_str()); + hashstr->destpubtxid = txid; + } + } + } + } + } + didinit = 1; +} + +UniValue dilithium_handleinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); CPubKey pub33; int32_t i,n; char *handlestr,pkaddr[64],str[67]; struct dilithium_handle *hashstr; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + { + dilithium_handleinit(cp); + if ( (handlestr= jstr(jitem(params,0),0)) != 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("handle",handlestr)); + if ( (hashstr= dilithium_handlefind(handlestr)) != 0 ) + { + result.push_back(Pair("destpubtxid",hashstr->destpubtxid.GetHex().c_str())); + if ( dilithium_registrationpub33(pkaddr,pub33,hashstr->destpubtxid) == 0 ) + { + for (i=0; i<33; i++) + sprintf(&str[i<<1],"%02x",((uint8_t *)pub33.begin())[i]); + str[i<<1] = 0; + result.push_back(Pair("pkaddr",pkaddr)); + } + result.push_back(Pair("pubkey",str)); + } else result.push_back(Pair("status","available")); + return(result); + } + } + result.push_back(Pair("result","error")); + return(result); +} + +bool dilithium_Rvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + static int32_t didinit; + uint256 txid; int32_t numvouts; struct dilithium_handle *hashstr; std::string handle; std::vector bigpub; CPubKey oldpub33,pub33,dilithiumpk; CTxOut vout,vout0; char pkaddr[64]; + if ( height < 14500 ) + return(true); + dilithium_handleinit(cp); + dilithiumpk = GetUnspendable(cp,0); + if ( (numvouts= tx.vout.size()) <= 1 ) + return eval->Invalid("not enough vouts for registration tx"); + else if ( dilithium_registeropretdecode(handle,pub33,bigpub,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + // relies on all current block tx to be put into mempool + txid = tx.GetHash(); + vout0 = MakeCC1vout(cp->evalcode,2*DILITHIUM_TXFEE,dilithiumpk); + vout = MakeCC1vout(EVAL_FAUCET,COIN,Faucet_pubkeyget()); + if ( tx.vout[0] != vout0 ) + return eval->Invalid("mismatched vout0 for register"); + else if ( tx.vout[1].nValue != DILITHIUM_TXFEE ) + return eval->Invalid("vout1 for register not txfee"); + else if ( tx.vout[2] != vout ) + return eval->Invalid("register not sending to faucet"); + else if ( (hashstr= dilithium_handlenew((char *)handle.c_str())) == 0 ) + return eval->Invalid("error creating dilithium handle"); + else if ( hashstr->destpubtxid == zeroid ) + { + hashstr->destpubtxid = txid; + return(true); + } + else + { + if ( hashstr->destpubtxid == txid ) + return(true); + else if ( dilithium_registrationpub33(pkaddr,oldpub33,hashstr->destpubtxid) == 0 ) + { + if ( oldpub33 == pub33 ) + { + hashstr->destpubtxid = txid; + fprintf(stderr,"ht.%d %s <- %s\n",height,handle.c_str(),txid.GetHex().c_str()); + return(true); + } + } + return eval->Invalid("duplicate dilithium handle rejected"); + } + } else return eval->Invalid("couldnt decode register opret"); +} + bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { CPubKey destpub33; std::string handle; uint256 hashBlock,destpubtxid,checktxid; CTransaction vintx; int32_t numvouts,mlen,smlen=CRYPTO_BYTES+32; std::vector sig,vopret; uint8_t msg[32],msg2[CRYPTO_BYTES+32],pk[CRYPTO_PUBLICKEYBYTES],*script; @@ -3459,7 +3639,9 @@ bool dilithium_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,con numvouts = tx.vout.size(); GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); script = (uint8_t *)vopret.data(); - if ( script[1] == 'Q' ) + if ( script[1] == 'R' ) + return(dilithium_Rvalidate(cp,height,eval,tx)); + else if ( script[1] == 'Q' ) return(dilithium_Qvalidate(cp,height,eval,tx)); else if ( tx.vout.size() != 2 ) return eval->Invalid("numvouts != 2"); diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 54d7beb99..84281c5a7 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -25,7 +25,6 @@ command(struct rogue_state *rs) char *fp; THING *mp; static char countch, direction, newcount = FALSE; - if (on(player, ISHASTE)) ntimes++; /* diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 43474616e..9cb4bf61e 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -290,27 +290,27 @@ attack(struct rogue_state *rs,THING *mp) } when 'N': { - register THING *obj, *steal; - register int nobj; - - /* - * Nymph's steal a magic item, look through the pack - * and pick out one we like. - */ - steal = NULL; - for (nobj = 0, obj = pack; obj != NULL; obj = next(obj)) - if (obj != cur_armor && obj != cur_weapon - && obj != cur_ring[LEFT] && obj != cur_ring[RIGHT] - && is_magic(obj) && rnd(++nobj) == 0) - steal = obj; - if (steal != NULL) - { - remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); - mp=NULL; - leave_pack(rs,steal, FALSE, FALSE); - msg(rs,"she stole %s!", inv_name(steal, TRUE)); - discard(steal); - } + THING *obj, *steal; int nobj; + + /* + * Nymph's steal a magic item, look through the pack + * and pick out one we like. + */ + steal = NULL; + for (nobj = 0, obj = pack; obj != NULL; obj = next(obj)) + if (obj != cur_armor && obj != cur_weapon + && obj != cur_ring[LEFT] && obj != cur_ring[RIGHT] + && is_magic(obj) && rnd(++nobj) == 0) + steal = obj; + if (steal != NULL) + { + remove_mon(rs,&mp->t_pos, moat(mp->t_pos.y, mp->t_pos.x), FALSE); + mp=NULL; + leave_pack(rs,steal, FALSE, FALSE); + msg(rs,"she stole %s!", inv_name(steal, TRUE)); + if ( steal->o_count <= 0 ) + discard(steal); + } } otherwise: break; @@ -594,26 +594,24 @@ void remove_mon(struct rogue_state *rs,coord *mp, THING *tp, bool waskill) { register THING *obj, *nexti; - for (obj = tp->t_pack; obj != NULL; obj = nexti) { - nexti = next(obj); - obj->o_pos = tp->t_pos; - detach(tp->t_pack, obj); - if (waskill) - fall(rs,obj, FALSE); - else - discard(obj); + nexti = next(obj); + obj->o_pos = tp->t_pos; + detach(tp->t_pack, obj); + if (waskill) + fall(rs,obj, FALSE); + else discard(obj); } moat(mp->y, mp->x) = NULL; mvaddch(mp->y, mp->x, tp->t_oldch); detach(mlist, tp); if (on(*tp, ISTARGET)) { - kamikaze = FALSE; - to_death = FALSE; - if (fight_flush) - flush_type(); + kamikaze = FALSE; + to_death = FALSE; + if (fight_flush) + flush_type(); } discard(tp); } diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 994f112e2..4c289ad7d 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -167,7 +167,7 @@ readchar(struct rogue_state *rs) fp = fopen("log","wb"); if ( fp != 0 ) { - fprintf(fp,"%d: (%c) hp.%d\n",counter,c,pstats.s_hpt); + fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs)); fflush(fp); counter++; } diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 622af60cd..a021c6a8f 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -19,80 +19,38 @@ int total = 0; /* total dynamic memory bytes */ #endif -/* - * detach: - * takes an item out of whatever linked list it might be in - */ - -void -_detach(THING **list, THING *item) -{ - if (*list == item) - *list = next(item); - if (prev(item) != NULL) - item->l_prev->l_next = next(item); - if (next(item) != NULL) - item->l_next->l_prev = prev(item); - item->l_next = NULL; - item->l_prev = NULL; -} - -/* - * _attach: - * add an item to the head of a list - */ - -void -_attach(THING **list, THING *item) -{ - if (*list != NULL) - { - item->l_next = *list; - (*list)->l_prev = item; - item->l_prev = NULL; - } - else - { - item->l_next = NULL; - item->l_prev = NULL; - } - *list = item; -} - -/* - * _free_list: - * Throw the whole blamed thing away - */ - -void -_free_list(THING **ptr) -{ - THING *item; - - while (*ptr != NULL) - { - item = *ptr; - *ptr = next(item); - discard(item); - } -} - /* * discard: * Free up an item */ +//#define ENABLE_DEBUG +#define MAX_DEBUGPTRS 100000 + int32_t itemcounter; -THING *thingptrs[100000]; +THING *thingptrs[MAX_DEBUGPTRS]; int32_t numptrs; +int32_t thing_find(THING *item) +{ +#ifdef ENABLE_DEBUG + int32_t i; + for (i=0; il_prev->l_next = next(item); + if (next(item) != NULL) + item->l_next->l_prev = prev(item); + item->l_next = NULL; + item->l_prev = NULL; +} + +/* + * _attach: + * add an item to the head of a list + */ + +void +_attach(THING **list, THING *item) +{ + if (*list != NULL) + { + item->l_next = *list; + (*list)->l_prev = item; + item->l_prev = NULL; + } + else + { + item->l_next = NULL; + item->l_prev = NULL; + } + *list = item; +} + +/* + * _free_list: + * Throw the whole blamed thing away + */ + +void +_free_list(THING **ptr) +{ + THING *item; + while (*ptr != NULL) + { + item = *ptr; + *ptr = next(item); + discard(item); + } +} + /* * new_item * Get a new item with a specified size @@ -139,12 +165,14 @@ new_item(void) #else item = (THING *)calloc(1, sizeof *item); #endif - if ( 0 ) +#ifdef ENABLE_DEBUG + if ( numptrs < MAX_DEBUGPTRS ) { thingptrs[numptrs++] = item; if ( (++itemcounter % 100) == 0 ) fprintf(stderr,"itemcounter.%d\n",itemcounter); } +#endif item->l_next = NULL; item->l_prev = NULL; return item; diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 5e79e399e..e743a9672 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -742,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys; int32_t i,numpastkeys; cJSON *retjson; + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { @@ -765,8 +765,27 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } // extract and get keystrokes field and compare it to pastkeys // if not matching... panic? - if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) + if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { + sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); + if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (keys= jstr(retjson,"keystrokes")) != 0 ) + { + len = strlen(keys) / 2; + pastcmp = (char *)malloc(len + 1); + decode_hex(pastcmp,len,keys); + if ( len != numpastkeys || memcmp(pastcmp,pastkeys,len) != 0 ) + { + fprintf(stderr,"pastcmp[%d] != pastkeys[%d]?\n",len,numpastkeys); + } + free(pastcmp); + } + free_json(retjson); + } + } free(pastkeys); } diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 362c65412..1f2f3faaa 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -163,6 +163,11 @@ int32_t num_packitems(struct rogue_state *rs) int32_t type = 0,n = 0,total = 0; for (; list != NULL; list = next(list)) { + if ( thing_find(list) < 0 ) + { + fprintf(stderr,"num_packitems cant find %p\n",list); + return(-1); + } if ( list->o_packch != 0 ) { n++; @@ -219,29 +224,29 @@ THING * leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all) { THING *nobj; - + inpack--; nobj = obj; if (obj->o_count > 1 && !all) { - last_pick = obj; - obj->o_count--; - if (obj->o_group) - inpack++; - if (newobj) - { - nobj = new_item(); - *nobj = *obj; - next(nobj) = NULL; - prev(nobj) = NULL; - nobj->o_count = 1; - } + last_pick = obj; + obj->o_count--; + if (obj->o_group) + inpack++; + if (newobj) + { + nobj = new_item(); + *nobj = *obj; + next(nobj) = NULL; + prev(nobj) = NULL; + nobj->o_count = 1; + } } else { - last_pick = NULL; - pack_used[obj->o_packch - 'a'] = FALSE; - detach(pack, obj); + last_pick = NULL; + pack_used[obj->o_packch - 'a'] = FALSE; + detach(pack, obj); } return nobj; } @@ -466,7 +471,9 @@ get_item(struct rogue_state *rs,char *purpose, int type) return NULL; } else + { return obj; + } } } return NULL; diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 00865b5dd..b10f83bd4 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -220,7 +220,7 @@ quaff(struct rogue_state *rs) call_it(rs,&pot_info[obj->o_which]); if (discardit) - discard(obj); + discard(obj); return; } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 478e3d2ed..5e5a66e06 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -286,7 +286,7 @@ char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) fclose(fp); num += fsize; counter++; - fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); + //fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); } *numkeysp = num; return(keystrokes); diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 8c1101fc6..ba57adbe6 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -824,6 +824,7 @@ void doctor(struct rogue_state *rs,int); void playit(struct rogue_state *rs); struct room *roomin(struct rogue_state *rs,coord *cp); +int32_t thing_find(THING *ptr); #define MAXDAEMONS 20 diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index 5554a5701..8ed6d2648 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -313,7 +313,7 @@ def: call_it(rs,&scr_info[obj->o_which]); if (discardit) - discard(obj); + discard(obj); } /* diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index b0176a042..9963bbc9e 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1429,6 +1429,11 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) struct rogue_packitem *item; if (write_error) return(WRITESTAT); + if ( thing_find(o) < 0 ) + { + fprintf(stderr,"cant find thing.%p (%s) in list\n",o,inv_name(o,FALSE)); //sleep(3); + return(0); + } if ( o->_o._o_packch != 0 ) { item = &rs->P.roguepack[rs->P.packsize]; diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index e313bf9d3..0a8b6016c 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -129,28 +129,28 @@ fall(struct rogue_state *rs,THING *obj, bool pr) if (fallpos(&obj->o_pos, &fpos)) { - pp = INDEX(fpos.y, fpos.x); - pp->p_ch = (char) obj->o_type; - obj->o_pos = fpos; - if (cansee(rs,fpos.y, fpos.x)) - { - if (pp->p_monst != NULL) - pp->p_monst->t_oldch = (char) obj->o_type; - else - mvaddch(fpos.y, fpos.x, obj->o_type); - } - attach(lvl_obj, obj); - return; + pp = INDEX(fpos.y, fpos.x); + pp->p_ch = (char) obj->o_type; + obj->o_pos = fpos; + if (cansee(rs,fpos.y, fpos.x)) + { + if (pp->p_monst != NULL) + pp->p_monst->t_oldch = (char) obj->o_type; + else + mvaddch(fpos.y, fpos.x, obj->o_type); + } + attach(lvl_obj, obj); + return; } if (pr) { - if (has_hit) - { - endmsg(rs); - has_hit = FALSE; - } - msg(rs,"the %s vanishes as it hits the ground", - weap_info[obj->o_which].oi_name); + if (has_hit) + { + endmsg(rs); + has_hit = FALSE; + } + msg(rs,"the %s vanishes as it hits the ground", + weap_info[obj->o_which].oi_name); } discard(obj); } diff --git a/src/init.cpp b/src/init.cpp index 6049fb09f..2a612634e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -562,6 +562,36 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-metricsui", _("Set to 1 for a persistent metrics screen, 0 for sequential metrics output (default: 1 if running in a console, 0 otherwise)")); strUsage += HelpMessageOpt("-metricsrefreshtime", strprintf(_("Number of seconds between metrics refreshes (default: %u if running in a console, %u otherwise)"), 1, 600)); } + strUsage += HelpMessageGroup(_("Komodo Asset Chain options:")); + strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash")); + strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60")); + strUsage += HelpMessageOpt("-ac_cc", _("Cryptoconditions, default 0")); + strUsage += HelpMessageOpt("-ac_beam", _("BEAM integration")); + strUsage += HelpMessageOpt("-ac_coda", _("CODA integration")); + strUsage += HelpMessageOpt("-ac_cclib", _("Cryptoconditions dynamicly loadable library")); + strUsage += HelpMessageOpt("-ac_ccenable", _("Cryptoconditions to enable")); + strUsage += HelpMessageOpt("-ac_ccactivate", _("Block height to enable Cryptoconditions")); + strUsage += HelpMessageOpt("-ac_decay", _("Percentage of block reward decrease at each halving")); + strUsage += HelpMessageOpt("-ac_end", _("Block height at which block rewards will end")); + strUsage += HelpMessageOpt("-ac_eras", _("Block reward eras")); + strUsage += HelpMessageOpt("-ac_founders", _("Number of blocks between founders reward payouts")); + strUsage += HelpMessageOpt("-ac_halving", _("Number of blocks between each block reward halving")); + strUsage += HelpMessageOpt("-ac_name", _("Name of asset chain")); + strUsage += HelpMessageOpt("-ac_notarypay", _("Pay notaries, default 0")); + strUsage += HelpMessageOpt("-ac_perc", _("Percentage of block rewards paid to the founder")); + strUsage += HelpMessageOpt("-ac_private", _("Shielded transactions only (except coinbase + notaries), default is 0")); + strUsage += HelpMessageOpt("-ac_pubkey", _("Public key for receiving payments on the network")); + strUsage += HelpMessageOpt("-ac_public", _("Transparent transactions only, default 0")); + strUsage += HelpMessageOpt("-ac_reward", _("Block reward in satoshis, default is 0")); + strUsage += HelpMessageOpt("-ac_sapling", _("Sapling activation block height")); + strUsage += HelpMessageOpt("-ac_script", _("P2SH/multisig address to receive founders rewards")); + strUsage += HelpMessageOpt("-ac_staked", _("Percentage of blocks that are Proof-Of-Stake, default 0")); + strUsage += HelpMessageOpt("-ac_supply", _("Starting supply, default is 0")); + strUsage += HelpMessageOpt("-ac_timelockfrom", _("Timelocked coinbase start height")); + strUsage += HelpMessageOpt("-ac_timelockgte", _("Timelocked coinbase minimum amount to be locked")); + strUsage += HelpMessageOpt("-ac_timelockto", _("Timelocked coinbase stop height")); + strUsage += HelpMessageOpt("-ac_txpow", _("Enforce transaction-rate limit, default 0")); + strUsage += HelpMessageOpt("-ac_veruspos", _("Use Verus Proof-Of-Stake (-ac_veruspos=50) default 0")); return strUsage; } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2397be883..289b97dfb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5393,8 +5393,8 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector Date: Wed, 6 Mar 2019 04:00:29 -1100 Subject: [PATCH 2886/3904] Enable keystrokes test --- src/cc/rogue/main.c | 13 +++++++++---- src/cc/rogue/rogue.c | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index e743a9672..ae5875d0e 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -765,7 +765,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } // extract and get keystrokes field and compare it to pastkeys // if not matching... panic? - if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) + if ( 1 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) @@ -777,15 +777,20 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * len = strlen(keys) / 2; pastcmp = (char *)malloc(len + 1); decode_hex(pastcmp,len,keys); + fprintf(stderr,"keystrokes.(%s) vs pastkeys\n",keys); + for (i=0; i Date: Wed, 6 Mar 2019 04:13:57 -1100 Subject: [PATCH 2887/3904] +debug --- src/cc/rogue/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index ae5875d0e..0dffa882b 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -763,8 +763,6 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(rs->keystrokeshex), rs->keystrokeshex = 0; } - // extract and get keystrokes field and compare it to pastkeys - // if not matching... panic? if ( 1 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); @@ -789,10 +787,11 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } else fprintf(stderr,"no keystrokes in (%s)\n",retstr); free_json(retjson); } else fprintf(stderr,"error parsing.(%s)\n",retstr); + fprintf(stderr,"extracted.(%s)\n",retstr); free(retstr); } else fprintf(stderr,"error extracting game\n"); free(pastkeys); - } + } else fprintf(stderr,"no pastkeys\n"); for (i=0; i Date: Wed, 6 Mar 2019 16:15:31 +0100 Subject: [PATCH 2888/3904] Updated macOS (OSX) install instructions (#1316) --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0f112982d..6c0002ba4 100644 --- a/README.md +++ b/README.md @@ -71,20 +71,32 @@ cd komodo #This can take some time. ``` + #### OSX Ensure you have [brew](https://brew.sh) and Command Line Tools installed. ```shell +# Install brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -# installs brew +# Install Xcode, opens a pop-up window to install CLT without installing the entire Xcode package xcode-select --install -# opens a pop-up window to install CLT without installing the entire Xcode package -brew update && brew install gcc@6 +# Update brew and install dependencies +brew update +brew upgrade +brew tap discoteq/discoteq; brew install flock +brew install autoconf autogen automake +brew install gcc@6 +brew install binutils +brew install protobuf +brew install coreutils +brew install wget +# Clone the Komodo repo git clone https://github.com/komodoplatform/komodo --branch master --single-branch +# Change master branch to other branch you wish to compile cd komodo ./zcutil/fetch-params.sh # -j8 = using 8 threads for the compilation - replace 8 with number of threads you want to use ./zcutil/build-mac.sh -j8 -#This can take some time. +# This can take some time. ``` #### Windows From 2bc42f00e02d5c565f0ca74c67629d8b103d23bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 04:22:11 -1100 Subject: [PATCH 2889/3904] Fix rogue results processing --- src/cc/rogue/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 0dffa882b..87f0a0c31 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -770,7 +770,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (keys= jstr(retjson,"keystrokes")) != 0 ) + if ( (resobj= jobj(retjson,"result")) != 0 && (keys= jstr(resobj,"keystrokes")) != 0 ) { len = strlen(keys) / 2; pastcmp = (char *)malloc(len + 1); @@ -791,7 +791,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(retstr); } else fprintf(stderr,"error extracting game\n"); free(pastkeys); - } else fprintf(stderr,"no pastkeys\n"); + } // else fprintf(stderr,"no pastkeys\n"); for (i=0; ikeystrokeshex != 0 ) free(rs->keystrokeshex); rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); strcpy(rs->keystrokeshex,rawtx); - //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); +fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } free_json(retjson); } From 40d4907f8cbdf62024b20ca542933fa2057cf2c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 04:22:47 -1100 Subject: [PATCH 2890/3904] Resobj --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 87f0a0c31..1db9bb62c 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -742,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson; + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { From e8d71bc8f16d39424d997d63cc0fd58bf28be9a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 04:35:14 -1100 Subject: [PATCH 2891/3904] Enable keystrokes sending --- src/cc/rogue/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 1db9bb62c..6b1008363 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -716,11 +716,6 @@ int32_t rogue_sendrawtransaction(char *rawtx) if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { //fprintf(stderr,"params.(%s) -> %s\n",params,retstr); - if ( is_hexstr(retstr,64) == 64 ) - { - free(retstr); - return(0); - } { static FILE *fp; if ( fp == 0 ) @@ -731,6 +726,11 @@ int32_t rogue_sendrawtransaction(char *rawtx) fflush(fp); } } + if ( is_hexstr(retstr,64) == 64 ) + { + free(retstr); + return(0); + } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { free_json(retjson); @@ -763,7 +763,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(rs->keystrokeshex), rs->keystrokeshex = 0; } - if ( 1 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) + if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) @@ -824,7 +824,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(rs->keystrokeshex); rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); strcpy(rs->keystrokeshex,rawtx); -fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); +//fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } free_json(retjson); } From 3c5d1a7fea87e2deda2a32ce09e99a6d40f08c7d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 04:55:14 -1100 Subject: [PATCH 2892/3904] Test --- src/cc/rogue/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 6b1008363..f38ee1976 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -711,10 +711,12 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t rogue_sendrawtransaction(char *rawtx) { - char params[512],*retstr; cJSON *retjson; int32_t numconfs = -1; + char *params,*retstr; cJSON *retjson; int32_t numconfs = -1; + params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { + free(params); //fprintf(stderr,"params.(%s) -> %s\n",params,retstr); { static FILE *fp; @@ -737,6 +739,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) } free(retstr); } + free(params); return(-1); } From c5b6ed9894407f9f2d0f153732ee8405f4eb8d7d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 05:04:04 -1100 Subject: [PATCH 2893/3904] Print --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f38ee1976..f3d1b41d7 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -717,7 +717,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { free(params); - //fprintf(stderr,"params.(%s) -> %s\n",params,retstr); + fprintf(stderr,"sendrawtransaction.(%s)\n",retstr); { static FILE *fp; if ( fp == 0 ) From 415bc355f351f34dcd49f443593f23006a635281 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 05:16:21 -1100 Subject: [PATCH 2894/3904] Sendrawtransaction result --- src/cc/rogue/main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f3d1b41d7..e5bf9383f 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -711,13 +711,12 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t rogue_sendrawtransaction(char *rawtx) { - char *params,*retstr; cJSON *retjson; int32_t numconfs = -1; + char *params,*retstr,*hexstr; cJSON *retjson; int32_t numconfs = -1; params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { free(params); - fprintf(stderr,"sendrawtransaction.(%s)\n",retstr); { static FILE *fp; if ( fp == 0 ) @@ -728,13 +727,16 @@ int32_t rogue_sendrawtransaction(char *rawtx) fflush(fp); } } - if ( is_hexstr(retstr,64) == 64 ) - { - free(retstr); - return(0); - } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { + if ( (resobj= jobj(retjson,"result")) != 0 ) + { + if ( (hexstr= jstr(resobj,0)) != 0 && is_hexstr(hexstr,64) == 64 ) + { + free(retstr); + return(0); + } + } free_json(retjson); } free(retstr); From 1bf8f353866daab692b5ccf1aaa63b61aa65c724 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 05:17:21 -1100 Subject: [PATCH 2895/3904] Resobj --- src/cc/rogue/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index e5bf9383f..89c4eaae7 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -711,7 +711,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t rogue_sendrawtransaction(char *rawtx) { - char *params,*retstr,*hexstr; cJSON *retjson; int32_t numconfs = -1; + char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t numconfs = -1; params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) From 6e26b4505dbe6efd634db19a60a0410f2dbf3911 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 05:34:58 -1100 Subject: [PATCH 2896/3904] Fix crash --- src/cc/rogue/main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 89c4eaae7..ea58767ba 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -711,12 +711,11 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t rogue_sendrawtransaction(char *rawtx) { - char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t numconfs = -1; + char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { - free(params); { static FILE *fp; if ( fp == 0 ) @@ -732,17 +731,14 @@ int32_t rogue_sendrawtransaction(char *rawtx) if ( (resobj= jobj(retjson,"result")) != 0 ) { if ( (hexstr= jstr(resobj,0)) != 0 && is_hexstr(hexstr,64) == 64 ) - { - free(retstr); - return(0); - } + retval = 0; } free_json(retjson); } free(retstr); } free(params); - return(-1); + return(retval); } void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) From 07b9fe389f2c1bfbe383170dc7a3f3774fdbb6ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 06:00:54 -1100 Subject: [PATCH 2897/3904] Jl777 (#1317) * Remove voutsum check * Teach RPC interface about dpow-enabled minconfs (#1231) * Make minconfs dpow-aware in z_listunspent + z_listreceivedbyaddress * Add dpow-related test files to test suite * Add dpow simulation to regtest every 7 blocks * Fix compiler errors * Fix link error * Fix stdout spam when running regtests * Dpowminconfs for listreceivedbyaddress * dpowconfs tests * Start adding specific tests for dpowminconfs in listreceivedbyaddress * Get dpowminconfs tests for listreceivedbyaddress working * Add dpowminconfs to getreceivedbyaddress + listunspent * Add test for listtransactions + getreceivedbyaddress support * Reliably passing dpowminconf tests. We only check for notarized-ness now, not exact confirmation numbers, to avoid race conditions * Poll for the expected notarization info before running further tests; add support for getbalance * Migrate tx_height() to a place where asyncrpcoperation_sendmany.cpp can use it * fix * Teach GetFilteredNotes about dpowconfs Many RPCs rely on this internal function, which now correctly uses dpowconfs to filter by the minconf/maxconf parameters. * Fix sendmany when using non-default minconf * inline seems to make things happy * cleanup * Add some code to test z_sendmany, which points out https://github.com/jl777/komodo/issues/1247 * try this * Use already calculated value of dpowconfs instead of calculating it again * Cleanup .pack file * Remove * Remove .pack * Disable passkeys * Rvalidate * Syntax * Allow overwrite by same pub33 * Tx * Declare variables * Allow replacement handle * Grandfather existing handles * Test * Handleinfo * Char * * Begin * Add mutex * CCaddr * Casts for windows * +debugs * Syntax * Item * Skeet * +print * Error check things * +prints * -sleep * Brute force inventory check * Revert * num_packitems * Log file * Test * ABC * Test * Add help docs for all -ac_* params of komodod (#1313) * Remove myAddress from roc * +print * Test * Test * Leave pack all * Dont discard unless last o_count * Prevent pack corruption * -ddebugs * Merge branch 'FSM' into jl777 # Conflicts: # src/cc/rogue/main.c * Enable keystrokes test * +debug * Fix rogue results processing * Resobj * Enable keystrokes sending * Test * Print * Sendrawtransaction result * Resobj * Fix crash --- src/cc/rogue/main.c | 41 +++++++++++++++++++++++------------------ src/cc/rogue/rogue.c | 2 +- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index e743a9672..ea58767ba 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -711,16 +711,11 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t rogue_sendrawtransaction(char *rawtx) { - char params[512],*retstr; cJSON *retjson; int32_t numconfs = -1; + char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; + params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { - //fprintf(stderr,"params.(%s) -> %s\n",params,retstr); - if ( is_hexstr(retstr,64) == 64 ) - { - free(retstr); - return(0); - } { static FILE *fp; if ( fp == 0 ) @@ -733,16 +728,22 @@ int32_t rogue_sendrawtransaction(char *rawtx) } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { + if ( (resobj= jobj(retjson,"result")) != 0 ) + { + if ( (hexstr= jstr(resobj,0)) != 0 && is_hexstr(hexstr,64) == 64 ) + retval = 0; + } free_json(retjson); } free(retstr); } - return(-1); + free(params); + return(retval); } void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson; + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { @@ -763,8 +764,6 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(rs->keystrokeshex), rs->keystrokeshex = 0; } - // extract and get keystrokes field and compare it to pastkeys - // if not matching... panic? if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); @@ -772,22 +771,28 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (keys= jstr(retjson,"keystrokes")) != 0 ) + if ( (resobj= jobj(retjson,"result")) != 0 && (keys= jstr(resobj,"keystrokes")) != 0 ) { len = strlen(keys) / 2; pastcmp = (char *)malloc(len + 1); decode_hex(pastcmp,len,keys); + fprintf(stderr,"keystrokes.(%s) vs pastkeys\n",keys); + for (i=0; ikeystrokeshex != 0 ) free(rs->keystrokeshex); rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); strcpy(rs->keystrokeshex,rawtx); - //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); +//fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } free_json(retjson); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 5e5a66e06..352e950ec 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -267,7 +267,7 @@ char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) if ( (fsize= get_filesize(fp)) <= 0 ) { fclose(fp); - printf("fsize.%ld\n",fsize); + //printf("fsize.%ld\n",fsize); break; } if ( (keystrokes= (char *)realloc(keystrokes,num+fsize)) == 0 ) From b7326ab6cd5fb3a26cfd0d8d7170f8eecd452d74 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 07:10:16 -1100 Subject: [PATCH 2898/3904] Dont long sends --- src/cc/rogue/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index ea58767ba..df7c6481a 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -716,6 +716,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) sprintf(params,"[\"%s\"]",rawtx); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { + if ( 0 ) { static FILE *fp; if ( fp == 0 ) From 00f1b19d62d657148cc21afc73ceb8388c6afdfc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 21:19:53 -1100 Subject: [PATCH 2899/3904] Fix Qsend spend of Qsend --- src/cc/dilithium.c | 4 ++-- src/cc/rogue/main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index b92102f22..d4b75bf38 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3463,9 +3463,9 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co { if ( dilithium_Qsendopretdecode(tmptxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) != 'Q' ) return eval->Invalid("couldnt decode destpubtxid from Qsend"); - else if ( vintx.vin[i].prevout.n > voutpubtxids.size() ) + else if ( tx.vin[i].prevout.n > voutpubtxids.size() ) return eval->Invalid("no destpubtxid for prevout.n"); - destpubtxid = voutpubtxids[vintx.vin[i].prevout.n]; + destpubtxid = voutpubtxids[tx.vin[i].prevout.n]; } else { diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index df7c6481a..c2155a085 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -716,7 +716,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) sprintf(params,"[\"%s\"]",rawtx); if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { - if ( 0 ) + if ( 0 ) // causes 4th level crash { static FILE *fp; if ( fp == 0 ) From 2885e77258bf31fce829f3557c1ded6d092fbabe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 23:06:59 -1100 Subject: [PATCH 2900/3904] Test --- src/cc/tetris.cpp | 2393 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2393 insertions(+) create mode 100644 src/cc/tetris.cpp diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp new file mode 100644 index 000000000..2b1c7736c --- /dev/null +++ b/src/cc/tetris.cpp @@ -0,0 +1,2393 @@ + +/***************************************************************************/ +/** https://github.com/brenns10/tetris + @file main.c + @author Stephen Brennan + @date Created Wednesday, 10 June 2015 + @brief Main program for tetris. + @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised + BSD License. See LICENSE.txt for details. + *******************************************************************************/ + + +#ifndef TETRIS_H +#define TETRIS_H + +#include // for FILE +#include // for bool +#include +#include +#include +#include +#include + +#include +#include + +//#include +//#include + + +/* + Convert a tetromino type to its corresponding cell. + */ +#define TYPE_TO_CELL(x) ((x)+1) + +/* + Strings for how you would print a tetris board. + */ +#define TC_EMPTY_STR " " +#define TC_BLOCK_STR "\u2588" + +/* + Questions about a tetris cell. + */ +#define TC_IS_EMPTY(x) ((x) == TC_EMPTY) +#define TC_IS_FILLED(x) (!TC_IS_EMPTY(x)) + +/* + How many cells in a tetromino? + */ +#define TETRIS 4 +/* + How many tetrominos? + */ +#define NUM_TETROMINOS 7 +/* + How many orientations of a tetromino? + */ +#define NUM_ORIENTATIONS 4 + +/* + Level constants. + */ +#define MAX_LEVEL 19 +#define LINES_PER_LEVEL 10 + +/* + A "cell" is a 1x1 block within a tetris board. + */ +typedef enum { + TC_EMPTY, TC_CELLI, TC_CELLJ, TC_CELLL, TC_CELLO, TC_CELLS, TC_CELLT, TC_CELLZ +} tetris_cell; + +/* + A "type" is a type/shape of a tetromino. Not including orientation. + */ +typedef enum { + TET_I, TET_J, TET_L, TET_O, TET_S, TET_T, TET_Z +} tetris_type; + +/* + A row,column pair. Negative numbers allowed, because we need them for + offsets. + */ +typedef struct { + int row; + int col; +} tetris_location; + +/* + A "block" is a struct that contains information about a tetromino. + Specifically, what type it is, what orientation it has, and where it is. + */ +typedef struct { + int typ; + int ori; + tetris_location loc; +} tetris_block; + +/* + All possible moves to give as input to the game. + */ +typedef enum { + TM_LEFT, TM_RIGHT, TM_CLOCK, TM_COUNTER, TM_DROP, TM_HOLD, TM_NONE +} tetris_move; + +/* + A game object! + */ +typedef struct { + /* + Game board stuff: + */ + int rows; + int cols; + char *board; + /* + Scoring information: + */ + int points; + int level; + /* + Falling block is the one currently going down. Next block is the one that + will be falling after this one. Stored is the block that you can swap out. + */ + tetris_block falling; + tetris_block next; + tetris_block stored; + /* + Number of game ticks until the block will move down. + */ + int ticks_till_gravity; + /* + Number of lines until you advance to the next level. + */ + int lines_remaining; +} tetris_game; + +/* + This array stores all necessary information about the cells that are filled by + each tetromino. The first index is the type of the tetromino (i.e. shape, + e.g. I, J, Z, etc.). The next index is the orientation (0-3). The final + array contains 4 tetris_location objects, each mapping to an offset from a + point on the upper left that is the tetromino "origin". + */ +extern tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; + +/* + This array tells you how many ticks per gravity by level. Decreases as level + increases, to add difficulty. + */ +extern int GRAVITY_LEVEL[MAX_LEVEL+1]; + +// Data structure manipulation. +void tg_init(tetris_game *obj, int rows, int cols); +tetris_game *tg_create(int rows, int cols); +void tg_destroy(tetris_game *obj); +void tg_delete(tetris_game *obj); +tetris_game *tg_load(FILE *f); +void tg_save(tetris_game *obj, FILE *f); + +// Public methods not related to memory: +char tg_get(tetris_game *obj, int row, int col); +bool tg_check(tetris_game *obj, int row, int col); +bool tg_tick(tetris_game *obj, tetris_move move); +void tg_print(tetris_game *obj, FILE *f); + +#endif // TETRIS_H + + +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) + +/******************************************************************************* + Array Definitions + *******************************************************************************/ + +tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS] = { + // I + {{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, + {{0, 2}, {1, 2}, {2, 2}, {3, 2}}, + {{3, 0}, {3, 1}, {3, 2}, {3, 3}}, + {{0, 1}, {1, 1}, {2, 1}, {3, 1}}}, + // J + {{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, + {{0, 1}, {1, 1}, {2, 0}, {2, 1}}}, + // L + {{{0, 2}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, + {{0, 0}, {0, 1}, {1, 1}, {2, 1}}}, + // O + {{{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}}, + // S + {{{0, 1}, {0, 2}, {1, 0}, {1, 1}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 2}}, + {{1, 1}, {1, 2}, {2, 0}, {2, 1}}, + {{0, 0}, {1, 0}, {1, 1}, {2, 1}}}, + // T + {{{0, 1}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 1}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 1}}}, + // Z + {{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, + {{0, 2}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {2, 1}, {2, 2}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 0}}}, +}; + +int GRAVITY_LEVEL[MAX_LEVEL+1] = { + // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + //10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 30, 28, 26, 24, 22, 20, 16, 12, 8, 4 +}; + +/******************************************************************************* + Helper Functions for Blocks + *******************************************************************************/ + +void sleep_milli(int milliseconds) +{ + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = milliseconds * 1000 * 1000; + nanosleep(&ts, NULL); +} + +/* + Return the block at the given row and column. + */ +char tg_get(tetris_game *obj, int row, int column) +{ + return obj->board[obj->cols * row + column]; +} + +/* + Set the block at the given row and column. + */ +static void tg_set(tetris_game *obj, int row, int column, char value) +{ + obj->board[obj->cols * row + column] = value; +} + +/* + Check whether a row and column are in bounds. + */ +bool tg_check(tetris_game *obj, int row, int col) +{ + return 0 <= row && row < obj->rows && 0 <= col && col < obj->cols; +} + +/* + Place a block onto the board. + */ +static void tg_put(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, + TYPE_TO_CELL(block.typ)); + } +} + +/* + Clear a block out of the board. + */ +static void tg_remove(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, TC_EMPTY); + } +} + +/* + Check if a block can be placed on the board. + */ +static bool tg_fits(tetris_game *obj, tetris_block block) +{ + int i, r, c; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + r = block.loc.row + cell.row; + c = block.loc.col + cell.col; + if (!tg_check(obj, r, c) || TC_IS_FILLED(tg_get(obj, r, c))) { + return false; + } + } + return true; +} + +/* + Return a random tetromino type. + */ +static int random_tetromino(void) { + return rand() % NUM_TETROMINOS; +} + +/* + Create a new falling block and populate the next falling block with a random + one. + */ +static void tg_new_falling(tetris_game *obj) +{ + // Put in a new falling tetromino. + obj->falling = obj->next; + obj->next.typ = random_tetromino(); + obj->next.ori = 0; + obj->next.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; +} + +/******************************************************************************* + Game Turn Helpers + *******************************************************************************/ + +/* + Tick gravity, and move the block down if gravity should act. + */ +static void tg_do_gravity_tick(tetris_game *obj) +{ + obj->ticks_till_gravity--; + if (obj->ticks_till_gravity <= 0) { + tg_remove(obj, obj->falling); + obj->falling.loc.row++; + if (tg_fits(obj, obj->falling)) { + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + } else { + obj->falling.loc.row--; + tg_put(obj, obj->falling); + + tg_new_falling(obj); + } + tg_put(obj, obj->falling); + } +} + +/* + Move the falling tetris block left (-1) or right (+1). + */ +static void tg_move(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + obj->falling.loc.col += direction; + if (!tg_fits(obj, obj->falling)) { + obj->falling.loc.col -= direction; + } + tg_put(obj, obj->falling); +} + +/* + Send the falling tetris block to the bottom. + */ +static void tg_down(tetris_game *obj) +{ + tg_remove(obj, obj->falling); + while (tg_fits(obj, obj->falling)) { + obj->falling.loc.row++; + } + obj->falling.loc.row--; + tg_put(obj, obj->falling); + tg_new_falling(obj); +} + +/* + Rotate the falling block in either direction (+/-1). + */ +static void tg_rotate(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + + while (true) { + obj->falling.ori = (obj->falling.ori + direction) % NUM_ORIENTATIONS; + + // If the new orientation fits, we're done. + if (tg_fits(obj, obj->falling)) + break; + + // Otherwise, try moving left to make it fit. + obj->falling.loc.col--; + if (tg_fits(obj, obj->falling)) + break; + + // Finally, try moving right to make it fit. + obj->falling.loc.col += 2; + if (tg_fits(obj, obj->falling)) + break; + + // Put it back in its original location and try the next orientation. + obj->falling.loc.col--; + // Worst case, we come back to the original orientation and it fits, so this + // loop will terminate. + } + + tg_put(obj, obj->falling); +} + +/* + Swap the falling block with the block in the hold buffer. + */ +static void tg_hold(tetris_game *obj) +{ + tg_remove(obj, obj->falling); + if (obj->stored.typ == -1) { + obj->stored = obj->falling; + tg_new_falling(obj); + } else { + int typ = obj->falling.typ, ori = obj->falling.ori; + obj->falling.typ = obj->stored.typ; + obj->falling.ori = obj->stored.ori; + obj->stored.typ = typ; + obj->stored.ori = ori; + while (!tg_fits(obj, obj->falling)) { + obj->falling.loc.row--; + } + } + tg_put(obj, obj->falling); +} + +/* + Perform the action specified by the move. + */ +static void tg_handle_move(tetris_game *obj, tetris_move move) +{ + switch (move) { + case TM_LEFT: + tg_move(obj, -1); + break; + case TM_RIGHT: + tg_move(obj, 1); + break; + case TM_DROP: + tg_down(obj); + break; + case TM_CLOCK: + tg_rotate(obj, 1); + break; + case TM_COUNTER: + tg_rotate(obj, -1); + break; + case TM_HOLD: + tg_hold(obj); + break; + default: + // pass + break; + } +} + +/* + Return true if line i is full. + */ +static bool tg_line_full(tetris_game *obj, int i) +{ + int j; + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) + return false; + } + return true; +} + +/* + Shift every row above r down one. + */ +static void tg_shift_lines(tetris_game *obj, int r) +{ + int i, j; + for (i = r-1; i >= 0; i--) { + for (j = 0; j < obj->cols; j++) { + tg_set(obj, i+1, j, tg_get(obj, i, j)); + tg_set(obj, i, j, TC_EMPTY); + } + } +} + +/* + Find rows that are filled, remove them, shift, and return the number of + cleared rows. + */ +static int tg_check_lines(tetris_game *obj) +{ + int i, nlines = 0; + tg_remove(obj, obj->falling); // don't want to mess up falling block + + for (i = obj->rows-1; i >= 0; i--) { + if (tg_line_full(obj, i)) { + tg_shift_lines(obj, i); + i++; // do this line over again since they're shifted + nlines++; + } + } + + tg_put(obj, obj->falling); // replace + return nlines; +} + +/* + Adjust the score for the game, given how many lines were just cleared. + */ +static void tg_adjust_score(tetris_game *obj, int lines_cleared) +{ + static int line_multiplier[] = {0, 40, 100, 300, 1200}; + obj->points += line_multiplier[lines_cleared] * (obj->level + 1); + if (lines_cleared >= obj->lines_remaining) { + obj->level = MIN(MAX_LEVEL, obj->level + 1); + lines_cleared -= obj->lines_remaining; + obj->lines_remaining = LINES_PER_LEVEL - lines_cleared; + } else { + obj->lines_remaining -= lines_cleared; + } +} + +/* + Return true if the game is over. + */ +static bool tg_game_over(tetris_game *obj) +{ + int i, j; + bool over = false; + tg_remove(obj, obj->falling); + for (i = 0; i < 2; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + over = true; + } + } + } + tg_put(obj, obj->falling); + return over; +} + +/******************************************************************************* + Main Public Functions + *******************************************************************************/ + +/* + Do a single game tick: process gravity, user input, and score. Return true if + the game is still running, false if it is over. + */ +bool tg_tick(tetris_game *obj, tetris_move move) +{ + int lines_cleared; + // Handle gravity. + tg_do_gravity_tick(obj); + + // Handle input. + tg_handle_move(obj, move); + + // Check for cleared lines + lines_cleared = tg_check_lines(obj); + + tg_adjust_score(obj, lines_cleared); + + // Return whether the game will continue (NOT whether it's over) + return !tg_game_over(obj); +} + +void tg_init(tetris_game *obj, int rows, int cols) +{ + // Initialization logic + obj->rows = rows; + obj->cols = cols; + obj->board = malloc(rows * cols); + memset(obj->board, TC_EMPTY, rows * cols); + obj->points = 0; + obj->level = 0; + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + obj->lines_remaining = LINES_PER_LEVEL; + srand(time(NULL)); + tg_new_falling(obj); + tg_new_falling(obj); + obj->stored.typ = -1; + obj->stored.ori = 0; + obj->stored.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; + printf("%d", obj->falling.loc.col); +} + +tetris_game *tg_create(int rows, int cols) +{ + tetris_game *obj = malloc(sizeof(tetris_game)); + tg_init(obj, rows, cols); + return obj; +} + +void tg_destroy(tetris_game *obj) +{ + // Cleanup logic + free(obj->board); +} + +void tg_delete(tetris_game *obj) { + tg_destroy(obj); + free(obj); +} + +/* + Load a game from a file. + */ +tetris_game *tg_load(FILE *f) +{ + tetris_game *obj = malloc(sizeof(tetris_game)); + fread(obj, sizeof(tetris_game), 1, f); + obj->board = malloc(obj->rows * obj->cols); + fread(obj->board, sizeof(char), obj->rows * obj->cols, f); + return obj; +} + +/* + Save a game to a file. + */ +void tg_save(tetris_game *obj, FILE *f) +{ + fwrite(obj, sizeof(tetris_game), 1, f); + fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f); +} + +/* + Print a game board to a file. Really just for early debugging. + */ +void tg_print(tetris_game *obj, FILE *f) { + int i, j; + for (i = 0; i < obj->rows; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) { + fputs(TC_EMPTY_STR, f); + } else { + fputs(TC_BLOCK_STR, f); + } + } + fputc('\n', f); + } +} + +/* + 2 columns per cell makes the game much nicer. + */ +#define COLS_PER_CELL 2 +/* + Macro to print a cell of a specific type to a window. + */ +#define ADD_BLOCK(w,x) waddch((w),' '|A_REVERSE|COLOR_PAIR(x)); \ +waddch((w),' '|A_REVERSE|COLOR_PAIR(x)) +#define ADD_EMPTY(w) waddch((w), ' '); waddch((w), ' ') + +/* + Print the tetris board onto the ncurses window. + */ +void display_board(WINDOW *w, tetris_game *obj) +{ + int i, j; + box(w, 0, 0); + for (i = 0; i < obj->rows; i++) { + wmove(w, 1 + i, 1); + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + ADD_BLOCK(w,tg_get(obj, i, j)); + } else { + ADD_EMPTY(w); + } + } + } + wnoutrefresh(w); +} + +/* + Display a tetris piece in a dedicated window. + */ +void display_piece(WINDOW *w, tetris_block block) +{ + int b; + tetris_location c; + wclear(w); + box(w, 0, 0); + if (block.typ == -1) { + wnoutrefresh(w); + return; + } + for (b = 0; b < TETRIS; b++) { + c = TETROMINOS[block.typ][block.ori][b]; + wmove(w, c.row + 1, c.col * COLS_PER_CELL + 1); + ADD_BLOCK(w, TYPE_TO_CELL(block.typ)); + } + wnoutrefresh(w); +} + +/* + Display score information in a dedicated window. + */ +void display_score(WINDOW *w, tetris_game *tg) +{ + wclear(w); + box(w, 0, 0); + wprintw(w, "Score\n%d\n", tg->points); + wprintw(w, "Level\n%d\n", tg->level); + wprintw(w, "Lines\n%d\n", tg->lines_remaining); + wnoutrefresh(w); +} + +/* + Boss mode! Make it look like you're doing work. + */ +void boss_mode(void) +{ + clear(); + //Mix_PauseMusic(); + printw("user@workstation-312:~/Documents/presentation $ ls -l\n" + "total 528\n" + "drwxr-xr-x 2 user users 4096 Jun 9 17:05 .\n" + "drwxr-xr-x 4 user users 4096 Jun 10 09:52 ..\n" + "-rw-r--r-- 1 user users 88583 Jun 9 14:13 figure1.png\n" + "-rw-r--r-- 1 user users 65357 Jun 9 15:40 figure2.png\n" + "-rw-r--r-- 1 user users 4469 Jun 9 16:17 presentation.aux\n" + "-rw-r--r-- 1 user users 42858 Jun 9 16:17 presentation.log\n" + "-rw-r--r-- 1 user users 2516 Jun 9 16:17 presentation.nav\n" + "-rw-r--r-- 1 user users 183 Jun 9 16:17 presentation.out\n" + "-rw-r--r-- 1 user users 349607 Jun 9 16:17 presentation.pdf\n" + "-rw-r--r-- 1 user users 0 Jun 9 16:17 presentation.snm\n" + "-rw-r--r-- 1 user users 9284 Jun 9 17:05 presentation.tex\n" + "-rw-r--r-- 1 user users 229 Jun 9 16:17 presentation.toc\n" + "\n" + "user@workstation-312:~/Documents/presentation $ "); + echo(); + timeout(-1); + while (getch() != KEY_F(1)); + timeout(0); + noecho(); + clear(); + //Mix_ResumeMusic(); +} + +/* + Save and exit the game. + */ +void save(tetris_game *game, WINDOW *w) +{ + FILE *f; + + wclear(w); + box(w, 0, 0); // return the border + wmove(w, 1, 1); + wprintw(w, "Save and exit? [Y/n] "); + wrefresh(w); + timeout(-1); + if (getch() == 'n') { + timeout(0); + return; + } + f = fopen("tetris.save", "w"); + tg_save(game, f); + fclose(f); + tg_delete(game); + endwin(); + printf("Game saved to \"tetris.save\".\n"); + printf("Resume by passing the filename as an argument to this program.\n"); + exit(EXIT_SUCCESS); +} + +/* + Do the NCURSES initialization steps for color blocks. + */ +void init_colors(void) +{ + start_color(); + //init_color(COLOR_ORANGE, 1000, 647, 0); + init_pair(TC_CELLI, COLOR_CYAN, COLOR_BLACK); + init_pair(TC_CELLJ, COLOR_BLUE, COLOR_BLACK); + init_pair(TC_CELLL, COLOR_WHITE, COLOR_BLACK); + init_pair(TC_CELLO, COLOR_YELLOW, COLOR_BLACK); + init_pair(TC_CELLS, COLOR_GREEN, COLOR_BLACK); + init_pair(TC_CELLT, COLOR_MAGENTA, COLOR_BLACK); + init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); +} + +/* + Main tetris game! + */ +#ifdef STANDALONE + +int main(int argc, char **argv) +{ + tetris_game *tg; + tetris_move move = TM_NONE; + bool running = true; + WINDOW *board, *next, *hold, *score; + //Mix_Music *music; + + // Load file if given a filename. + if (argc >= 2) { + FILE *f = fopen(argv[1], "r"); + if (f == NULL) { + perror("tetris"); + exit(EXIT_FAILURE); + } + tg = tg_load(f); + fclose(f); + } else { + // Otherwise create new game. + tg = tg_create(22, 10); + } + + /* Initialize music. + if (SDL_Init(SDL_INIT_AUDIO) < 0) { + fprintf(stderr, "unable to initialize SDL\n"); + exit(EXIT_FAILURE); + } + if (Mix_Init(MIX_INIT_MP3) != MIX_INIT_MP3) { + fprintf(stderr, "unable to initialize SDL_mixer\n"); + exit(EXIT_FAILURE); + } + if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) != 0) { + fprintf(stderr, "unable to initialize audio\n"); + exit(EXIT_FAILURE); + } + Mix_AllocateChannels(1); // only need background music + music = Mix_LoadMUS("tetris.mp3"); + if (music) { + Mix_PlayMusic(music, -1); + }*/ + + // NCURSES initialization: + initscr(); // initialize curses + cbreak(); // pass key presses to program, but not signals + noecho(); // don't echo key presses to screen + keypad(stdscr, TRUE); // allow arrow keys + timeout(0); // no blocking on getch() + curs_set(0); // set the cursor to invisible + init_colors(); // setup tetris colors + + // Create windows for each section of the interface. + board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); + next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); + hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); + score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); + + // Game loop + while (running) { + running = tg_tick(tg, move); + display_board(board, tg); + display_piece(next, tg->next); + display_piece(hold, tg->stored); + display_score(score, tg); + doupdate(); + sleep_milli(10); + + switch (getch()) { + case KEY_LEFT: + move = TM_LEFT; + break; + case KEY_RIGHT: + move = TM_RIGHT; + break; + case KEY_UP: + move = TM_CLOCK; + break; + case KEY_DOWN: + move = TM_DROP; + break; + case 'q': + running = false; + move = TM_NONE; + break; + case 'p': + wclear(board); + box(board, 0, 0); + wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); + wprintw(board, "PAUSED"); + wrefresh(board); + timeout(-1); + getch(); + timeout(0); + move = TM_NONE; + break; + case 'b': + boss_mode(); + move = TM_NONE; + break; + case 's': + save(tg, board); + move = TM_NONE; + break; + case ' ': + move = TM_HOLD; + break; + default: + move = TM_NONE; + } + } + + // Deinitialize NCurses + wclear(stdscr); + endwin(); + + /* Deinitialize Sound + Mix_HaltMusic(); + Mix_FreeMusic(music); + Mix_CloseAudio(); + Mix_Quit();*/ + + // Output ending message. + printf("Game over!\n"); + printf("You finished with %d points on level %d.\n", tg->points, tg->level); + + // Deinitialize Tetris + tg_delete(tg); + return 0; +} +#endif + +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include "cJSON.h" +#include "CCinclude.h" + +#define TETRIS_REGISTRATION 5 +#define TETRIS_REGISTRATIONSIZE (100 * 10000) +#define TETRIS_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching +#define TETRIS_MAXKEYSTROKESGAP 60 +#define TETRIS_MAXITERATIONS 777 + + +std::string Tetris_pname = ""; + +CScript tetris_newgameopret(int64_t buyin,int32_t maxplayers) +{ + CScript opret; uint8_t evalcode = EVAL_TETRIS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << buyin << maxplayers); + return(opret); +} + +CScript tetris_registeropret(uint256 gametxid,uint256 playertxid) +{ + CScript opret; uint8_t evalcode = EVAL_TETRIS; + //fprintf(stderr,"opret.(%s %s).R\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'R' << gametxid << playertxid); + return(opret); +} + +CScript tetris_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std::vectorkeystrokes) +{ + CScript opret; uint8_t evalcode = EVAL_TETRIS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << batontxid << pk << keystrokes); + return(opret); +} + +CScript tetris_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata,std::string pname) +{ + CScript opret; uint8_t evalcode = EVAL_TETRIS; std::string symbol(ASSETCHAINS_SYMBOL); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << symbol << pname << regslot << pk << playerdata ); + return(opret); +} + +uint8_t tetris_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol, std::string &pname,CScript scriptPubKey) +{ + std::string name, description; std::vector vorigPubkey; + std::vector> oprets, opretsDummy; + std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; + uint8_t e, f,*script; std::vector voutPubkeys; + tokenid = zeroid; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description, oprets)) == 'c' ) + { + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); + vopret = vopretNonfungible; + } + else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, opretsDummy)) != 0 ) + { + //fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); + GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx + vopret = vopretNonfungible; + } + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> symbol; ss >> pname; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_TETRIS && (f == 'H' || f == 'Q') ) + { + return(f); + } + fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); + return(0); +} + +uint8_t tetris_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey &pk,std::vector &keystrokes,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> batontxid; ss >> pk; ss >> keystrokes) != 0 && e == EVAL_TETRIS && f == 'K' ) + { + return(f); + } + return(0); +} + +uint8_t tetris_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &playertxid,CScript scriptPubKey) +{ + std::string name, description; std::vector vorigPubkey; + std::vector> oprets; + std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; + uint8_t e, f,*script; std::vector voutPubkeys; + tokenid = zeroid; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,oprets)) == 'c' ) + { + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); + vopret = vopretNonfungible; + } + else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, oprets)) != 0 ) + { + GetOpretBlob(oprets, OPRETID_TETRISGAMEDATA, vopretDummy); // blob from non-creation tx opret + vopret = vopretDummy; + } + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_TETRIS && f == 'R' ) + { + return(f); + } + //fprintf(stderr,"e.%d f.%c game.%s playertxid.%s\n",e,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + return(0); +} + +uint8_t tetris_newgameopreturndecode(int64_t &buyin,int32_t &maxplayers,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin; ss >> maxplayers) != 0 && e == EVAL_TETRIS && f == 'G' ) + { + return(f); + } + return(0); +} + +void tetris_univalue(UniValue &result,const char *method,int64_t maxplayers,int64_t buyin) +{ + if ( method != 0 ) + { + result.push_back(Pair("name","tetris")); + result.push_back(Pair("method",method)); + } + if ( maxplayers > 0 ) + result.push_back(Pair("maxplayers",maxplayers)); + if ( buyin >= 0 ) + { + result.push_back(Pair("buyin",ValueFromAmount(buyin))); + if ( buyin == 0 ) + result.push_back(Pair("type","newbie")); + else result.push_back(Pair("type","buyin")); + } +} + +int32_t tetris_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx,char *mytetrisaddr) +{ + int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; char destaddr[64]; + for (i=0; i= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + { + Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); + if ( strcmp(mytetrisaddr,destaddr) == 0 ) + return(1); + //else fprintf(stderr,"myaddr.%s vs %s\n",mytetrisaddr,destaddr); + } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"vout %d is unspent\n",vout); + } + return(0); +} + +int32_t tetris_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0) +{ + uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey tetrispk; uint64_t txfee = 10000; + buyin = maxplayers = 0; + if ( (txid == zeroid || myGetTransaction(txid,tx,hashBlock) != 0) && (numvouts= tx.vout.size()) > 1 ) + { + if ( txid != zeroid ) + gameheight = komodo_blockheight(hashBlock); + else + { + txid = tx.GetHash(); + //fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); + } + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1,0) == txfee) ) + { + if ( tetris_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + if ( maxplayers < 1 || maxplayers > TETRIS_MAXPLAYERS || buyin < 0 ) + return(-6); + if ( numvouts > 2*maxplayers+1 ) + { + for (i=0; i playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) +{ + int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct tetris_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + datastr = (char *)malloc(playerdata.size()*2+1); + for (i=0; i= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + break; + } + txid = spenttxid; + vout = 0; + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + for (i=0; i TETRIS_MAXITERATIONS ) + break; + } + obj.push_back(Pair("gametxid",gametxid.GetHex())); + if ( txid != playertxid ) + obj.push_back(Pair("batontxid",txid.GetHex())); + obj.push_back(Pair("playertxid",playertxid.GetHex())); + if ( tokenid != zeroid ) + obj.push_back(Pair("tokenid",tokenid.GetHex())); + else obj.push_back(Pair("tokenid",playertxid.GetHex())); + if ( datastr != 0 ) + { + obj.push_back(Pair("data",datastr)); + free(datastr); + } + obj.push_back(Pair("pack",a)); + obj.push_back(Pair("packsize",(int64_t)P.packsize)); + obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); + obj.push_back(Pair("strength",(int64_t)(P.strength&0xffff))); + obj.push_back(Pair("maxstrength",(int64_t)(P.strength>>16))); + obj.push_back(Pair("level",(int64_t)P.level)); + obj.push_back(Pair("experience",(int64_t)P.experience)); + obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); + obj.push_back(Pair("chain",symbol)); + obj.push_back(Pair("pname",pname)); + return(obj); +} + +int32_t tetris_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and tetris_playerdataspend makes sure it can only be used once +{ + uint256 spenttxid,txid = firsttxid; int32_t spentvini,n,vout = firstvout; + registertxid = zeroid; + if ( vout < 0 ) + return(-1); + n = 0; + while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) + { + txid = spenttxid; + vout = spentvini; + if ( registertxid == zeroid ) + registertxid = txid; + if ( ++n >= TETRIS_MAXITERATIONS ) + { + fprintf(stderr,"tetris_iterateplayer n.%d, seems something is wrong\n",n); + return(-2); + } + } + if ( txid == lasttxid ) + return(0); + else + { + fprintf(stderr,"firsttxid.%s/v%d -> %s != last.%s\n",firsttxid.ToString().c_str(),firstvout,txid.ToString().c_str(),lasttxid.ToString().c_str()); + return(-1); + } +} + +/* + playertxid is whoever owns the nonfungible satoshi and it might have been bought and sold many times. + highlander is the game winning tx with the player data and is the only place where the unique player data exists + origplayergame is the gametxid that ends up being won by the highlander and they are linked directly as the highlander tx spends gametxid.vout0 + */ + +int32_t tetris_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,std::string &symbol,std::string &pname,uint256 playertxid) +{ + uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 && (numvouts= playertx.vout.size()) > 0 ) + { + if ( (f= tetris_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + { + origplayergame = gametxid; + if ( tokenid != zeroid ) + { + playertxid = tokenid; + if ( myGetTransaction(playertxid,playertx,hashBlock) == 0 || (numvouts= playertx.vout.size()) <= 0 ) + { + fprintf(stderr,"couldnt get tokenid.%s\n",playertxid.GetHex().c_str()); + return(-2); + } + } + if ( tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) + { + //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),tetris_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && tetris_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) + { + // if registertxid has vin from pk, it can be used + return(0); + } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); + } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); + } //else fprintf(stderr,"invalid player funcid.%c\n",f); + } else fprintf(stderr,"couldnt get playertxid.%s\n",playertxid.GetHex().c_str()); + return(-1); +} + +int32_t tetris_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_t vout,uint256 origplayergame) +{ + int64_t txfee = 10000; CTransaction tx; uint256 hashBlock; + if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation + { + mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); + return(0); + } + else + { + vout = 0; + if ( myGetTransaction(playertxid,tx,hashBlock) != 0 && tx.vout[vout].nValue == 1 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) + { + if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation + { + mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); + return(0); + } + } + return(-1); + } +} + +int32_t tetris_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) +{ + int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + batonvalue = numkeys = numplayers = batonht = 0; + playertxid = batontxid = zeroid; + for (i=0; i= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + { + numplayers++; + Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); + if ( strcmp(destaddr,ccaddr) == 0 ) + { + matches++; + regslot = i; + matchtx = spenttx; + } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"%d+1 unspent\n",i); + } + if ( matches == 1 ) + { + numvouts = matchtx.vout.size(); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + if ( tetris_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) + { + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + if ( tokenid != zeroid ) + active = tokenid; + else active = playertxid; + if ( active == zeroid || tetris_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) + { + txid = matchtx.GetHash(); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + n = 0; + while ( CCgettxout(txid,0,1,0) < 0 ) + { + spenttxid = zeroid; + spentvini = -1; + if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) + txid = spenttxid; + else + { + if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + return(-2); + } + } + txid = spenttxid; + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + if ( spentvini != 0 ) // game is over? + { + return(0); + } + if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) + { + uint256 g,b; CPubKey p; std::vector k; + if ( tetris_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) + { + keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); + for (i=0; i= TETRIS_MAXITERATIONS ) + { + fprintf(stderr,"tetris_findbaton n.%d, seems something is wrong\n",n); + return(-5); + } + } + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + batontxid = txid; + batonvout = 0; // not vini + // how to detect timeout, bailedout, highlander + hashBlock = zeroid; + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 0 ) + { + if ( hashBlock == zeroid ) + batonht = komodo_nextheight(); + else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) + return(-4); + else batonht = pindex->GetHeight(); + batonvalue = batontx.vout[0].nValue; + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + return(0); + } else fprintf(stderr,"couldnt find baton\n"); + } else fprintf(stderr,"error with playerdata\n"); + } else fprintf(stderr,"findbaton opret error\n"); + } + return(-1); +} + +int32_t tetris_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametxid,int32_t maxplayers,int32_t gameht,CTransaction gametx) +{ + int32_t i,n,vout,spentvini,registration_open = 0,alive = 0; CTransaction tx; uint256 txid,spenttxid,hashBlock; CBlockIndex *pindex; uint64_t txfee = 10000; + numplayers = openslots = 0; + if ( komodo_nextheight() <= gameht+TETRIS_MAXKEYSTROKESGAP ) + registration_open = 1; + for (i=0; i= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + break; + } + txid = spenttxid; + vout = 0; + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + if ( spentvini != 0 ) + break; + if ( n++ > TETRIS_MAXITERATIONS ) + break; + } + if ( txid != zeroid ) + { + if ( myGetTransaction(txid,tx,hashBlock) != 0 ) + { + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + if ( pindex->GetHeight() <= gameht+TETRIS_MAXKEYSTROKESGAP ) + alive++; + } + } + } + } + } + else if ( registration_open != 0 ) + openslots++; + } + //fprintf(stderr,"numalive.%d openslots.%d\n",alive,openslots); + return(alive); +} + +uint64_t tetris_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mytetrisaddr) +{ + CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; + if ( myGetTransaction(gametxid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + ht = pindex->GetHeight(); + delay = TETRIS_REGISTRATION * (maxplayers > 1); + obj.push_back(Pair("height",ht)); + obj.push_back(Pair("start",ht+delay)); + if ( komodo_nextheight() > ht+delay ) + { + if ( (pindex= komodo_chainactive(ht+delay)) != 0 ) + { + hashBlock = pindex->GetBlockHash(); + obj.push_back(Pair("starthash",hashBlock.ToString())); + memcpy(&seed,&hashBlock,sizeof(seed)); + seed &= (1LL << 62) - 1; + obj.push_back(Pair("seed",(int64_t)seed)); + if ( tetris_iamregistered(maxplayers,gametxid,tx,mytetrisaddr) > 0 ) + sprintf(cmd,"cc/tetris %llu %s",(long long)seed,gametxid.ToString().c_str()); + else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_TETRIS,gametxid.ToString().c_str()); + obj.push_back(Pair("run",cmd)); + } + } + obj.push_back(Pair("alive",tetris_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); + obj.push_back(Pair("openslots",openslots)); + obj.push_back(Pair("numplayers",numplayers)); + } + obj.push_back(Pair("maxplayers",maxplayers)); + obj.push_back(Pair("buyin",ValueFromAmount(buyin))); + return(seed); +} + +void tetris_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *mytetrisaddr) +{ + // identify if bailout or quit or timed out + uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; std::string symbol,pname; + destaddr[0] = 0; + if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); + } + obj.push_back(Pair("slot",(int64_t)vout-1)); + if ( (retval= tetris_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers,symbol,pname)) == 0 ) + { + if ( CCgettxout(gametxid,maxplayers+vout,1,0) == 10000 ) + { + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 ) + { + if ( tetris_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) + obj.push_back(Pair("status","registered")); + else obj.push_back(Pair("status","alive")); + } else obj.push_back(Pair("status","error")); + } else obj.push_back(Pair("status","finished")); + obj.push_back(Pair("baton",batontxid.ToString())); + obj.push_back(Pair("tokenid",tokenid.ToString())); + obj.push_back(Pair("batonaddr",destaddr)); + obj.push_back(Pair("ismine",strcmp(mytetrisaddr,destaddr)==0)); + obj.push_back(Pair("batonvout",(int64_t)batonvout)); + obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); + obj.push_back(Pair("batonht",(int64_t)batonht)); + if ( playerdata.size() > 0 ) + obj.push_back(Pair("player",tetris_playerobj(playerdata,playertxid,tokenid,symbol,pname,gametxid))); + } else fprintf(stderr,"findbaton err.%d\n",retval); +} + +int64_t tetris_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTransaction gametx,int32_t maxplayers) +{ + int32_t vout,j,r; int64_t nValue; + if ( gametx.vout.size() > maxplayers+1 ) + { + r = rand() % maxplayers; + for (j=0; j 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + +UniValue tetris_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey tetrispk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1; + if ( txfee == 0 ) + txfee = 10000; + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + maxplayers = juint(jitem(params,0),0); + if ( n > 1 ) + buyin = jdouble(jitem(params,1),0) * COIN + 0.0000000049; + } + } + if ( maxplayers < 1 || maxplayers > TETRIS_MAXPLAYERS ) + return(cclib_error(result,"illegal maxplayers")); + mypk = pubkey2pk(Mypubkey()); + tetrispk = GetUnspendable(cp,0); + tetris_univalue(result,"newgame",maxplayers,buyin); + required = (3*txfee + maxplayers*(TETRIS_REGISTRATIONSIZE+txfee)); + if ( (inputsum= AddCClibInputs(cp,mtx,tetrispk,required,16,cp->unspendableCCaddr)) >= required ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,tetrispk)); // for highlander TCBOO creation + for (i=0; ievalcode,TETRIS_REGISTRATIONSIZE,tetrispk,tetrispk)); + for (i=0; ievalcode,txfee,tetrispk,tetrispk)); + if ( (change= inputsum - required) >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,tetrispk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tetris_newgameopret(buyin,maxplayers)); + return(tetris_rawtxresult(result,rawtx,1)); + } + else return(cclib_error(result,"illegal maxplayers")); + return(result); +} + +UniValue tetris_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; std::string symbol,pname; + result.push_back(Pair("result","success")); + tetris_univalue(result,"playerinfo",-1,-1); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + playertxid = juint256(jitem(params,0)); + if ( tetris_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) + return(cclib_error(result,"invalid playerdata")); + result.push_back(Pair("player",tetris_playerobj(playerdata,playertxid,tokenid,symbol,pname,origplayergame))); + } else return(cclib_error(result,"no playertxid")); + return(result); + } else return(cclib_error(result,"couldnt reparse params")); +} + +UniValue tetris_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + // vin0 -> TETRIS_REGISTRATIONSIZE 1of2 registration baton from creategame + // vin1 -> optional nonfungible character vout @ + // vin2 -> original creation TCBOO playerdata used + // vin3+ -> buyin + // vout0 -> keystrokes/completion baton + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=1; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,tetrispk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx,symbol,pname; bits256 t; + + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY)); + tetrispk = GetUnspendable(cp,0); + tetris_univalue(result,"register",-1,-1); + playertxid = tokenid = zeroid; + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + if ( (err= tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1)) == 0 ) + { + if ( n > 1 ) + { + playertxid = juint256(jitem(params,1)); + if ( tetris_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) + return(cclib_error(result,"couldnt extract valid playerdata")); + if ( tokenid != zeroid ) // if it is tokentransfer this will be 0 + vout = 1; + } + if ( komodo_nextheight() > gameheight + TETRIS_MAXKEYSTROKESGAP ) + return(cclib_error(result,"didnt register in time, TETRIS_MAXKEYSTROKESGAP")); + tetris_univalue(result,0,maxplayers,buyin); + GetCCaddress1of2(cp,coinaddr,tetrispk,mypk); + if ( tetris_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) + return(cclib_error(result,"already registered")); + if ( (inputsum= tetris_registrationbaton(mtx,gametxid,tx,maxplayers)) != TETRIS_REGISTRATIONSIZE ) + return(cclib_error(result,"couldnt find available registration baton")); + else if ( playertxid != zeroid && tetris_playerdataspend(mtx,playertxid,vout,origplayergame) < 0 ) + return(cclib_error(result,"couldnt find playerdata to spend")); + else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) + return(cclib_error(result,"couldnt find enough normal funds for buyin")); + if ( tokenid != zeroid ) + { + mtx.vin.push_back(CTxIn(tokenid,0)); // spending cc marker as token is burned + char unspendableTokenAddr[64]; uint8_t tokenpriv[32]; struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + CPubKey unspPk = GetUnspendable(cpTokens, tokenpriv); + GetCCaddress(cpTokens, unspendableTokenAddr, unspPk); + CCaddr2set(cp, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); + } + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,tetrispk,mypk)); + GetCCaddress1of2(cp,destaddr,tetrispk,tetrispk); + CCaddr1of2set(cp,tetrispk,tetrispk,cp->CCpriv,destaddr); + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); + + uint8_t e, funcid; uint256 tid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; + CScript opretRegister = tetris_registeropret(gametxid, playertxid); + if ( playertxid != zeroid ) + { + voutPubkeysEmpty.push_back(burnpk); + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 ) + { + std::vector> oprets; + if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, oprets)) != 0) + { // if token in the opret + didtx = 1; + if ( funcid == 'c' ) + tid = tokenid == zeroid ? playertxid : tokenid; + vscript_t vopretRegister; + GetOpReturnData(opretRegister, vopretRegister); + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, + EncodeTokenOpRet(tid, voutPubkeysEmpty /*=never spent*/, std::make_pair(OPRETID_TETRISGAMEDATA, vopretRegister))); + } + } + } + if ( didtx == 0 ) + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister); + + return(tetris_rawtxresult(result,rawtx,1)); + } else return(cclib_error(result,"invalid gametxid")); + } else return(cclib_error(result,"no gametxid")); + } else return(cclib_error(result,"couldnt reparse params")); +} + +UniValue tetris_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + // vin0 -> baton from registration or previous keystrokes + // vout0 -> new baton + // opret -> user input chars + // being killed should auto broadcast (possible to be suppressed?) + // respawn to be prevented by including timestamps + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); + UniValue result(UniValue::VOBJ); CPubKey tetrispk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; + if ( txfee == 0 ) + txfee = 10000; + tetris_univalue(result,"keystrokes",-1,-1); + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + result.push_back(Pair("keystrokes",keystrokestr)); + keystrokes = ParseHex(keystrokestr); + mypk = pubkey2pk(Mypubkey()); + tetrispk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,destaddr,tetrispk,mypk); + if ( tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1) == 0 ) + { + if ( tetris_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) + { + result.push_back(Pair("batontxid",batontxid.GetHex())); + result.push_back(Pair("playertxid",playertxid.GetHex())); + if ( maxplayers == 1 || nextheight <= batonht+TETRIS_MAXKEYSTROKESGAP ) + { + mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); //this validates user if pk + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,tetrispk,mypk)); + Myprivkey(mypriv); + CCaddr1of2set(cp,tetrispk,mypk,mypriv,destaddr); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tetris_keystrokesopret(gametxid,batontxid,mypk,keystrokes)); + //fprintf(stderr,"KEYSTROKES.(%s)\n",rawtx.c_str()); + return(tetris_rawtxresult(result,rawtx,1)); + } else return(cclib_error(result,"keystrokes tx was too late")); + } else return(cclib_error(result,"couldnt find batontxid")); + } else return(cclib_error(result,"invalid gametxid")); + } else return(cclib_error(result,"couldnt reparse params")); +} + +char *tetris_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *tetrisaddr) +{ + CPubKey tetrispk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct tetris_player P,endP; + tetrispk = GetUnspendable(cp,0); + *numkeysp = 0; + seed = 0; + num = numkeys = 0; + playertxid = zeroid; + str[0] = 0; + if ( (err= tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) + { + if ( (retval= tetris_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,tetrisaddr,numplayers,symbol,pname)) == 0 ) + { + UniValue obj; + seed = tetris_gamefields(obj,maxplayers,buyin,gametxid,tetrisaddr); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Tetris_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i no playerdata\n"); + newdata.resize(0); + *numkeysp = numkeys; + return(keystrokes); + /* P.gold = (P.gold * 8) / 10; + if ( keystrokes != 0 ) + { + free(keystrokes); + keystrokes = 0; + *numkeysp = 0; + return(keystrokes); + }*/ + } + else + { + sprintf(str,"$$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); + //fprintf(stderr,"%s\n",str); + *numkeysp = numkeys; + return(keystrokes); + } + } else num = 0; + } + else + { + fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); + if ( keystrokes != 0 ) + free(keystrokes), keystrokes = 0; + } + } else fprintf(stderr,"extractgame: invalid game\n"); + //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); + return(0); +} + +UniValue tetris_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); CPubKey pk,tetrispk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],tetrisaddr[64],*pubstr,*hexstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; + pk = pubkey2pk(Mypubkey()); + tetrispk = GetUnspendable(cp,0); + result.push_back(Pair("name","tetris")); + result.push_back(Pair("method","extract")); + tetrisaddr[0] = 0; + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + if ( n == 2 ) + { + if ( (pubstr= jstr(jitem(params,1),0)) != 0 ) + { + if (strlen(pubstr) == 66 ) + { + decode_hex(pub33,33,pubstr); + pk = buf2pk(pub33); + } + else if ( strlen(pubstr) < 36 ) + strcpy(tetrisaddr,pubstr); + } + //fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); + } + if ( tetrisaddr[0] == 0 ) + GetCCaddress1of2(cp,tetrisaddr,tetrispk,pk); + result.push_back(Pair("tetrisaddr",tetrisaddr)); + str[0] = 0; + if ( (keystrokes= tetris_extractgame(1,str,&numkeys,newdata,seed,playertxid,cp,gametxid,tetrisaddr)) != 0 ) + { + result.push_back(Pair("status","success")); + flag = 1; + hexstr = (char *)malloc(numkeys*2 + 1); + for (i=0; i playerdata,uint256 gametxid,CPubKey pk) +{ + static uint32_t good,bad; static uint256 prevgame; + char str[512],*keystrokes,tetrisaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed,mult = 10; CPubKey tetrispk; struct tetris_player P; + *cashoutp = 0; + tetrispk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,tetrisaddr,tetrispk,pk); + //fprintf(stderr,"call extractgame\n"); + if ( (keystrokes= tetris_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,tetrisaddr)) != 0 ) + { + //fprintf(stderr,"numkeys.%d tetris_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); + free(keystrokes); + sprintf(fname,"tetris.%llu.pack",(long long)seed); + remove(fname); + + //fprintf(stderr,"extracted.(%s)\n",str); + for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); + } + *cashoutp = 0; + return(0); + } + } + if ( gametxid != prevgame ) + { + prevgame = gametxid; + bad++; + fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,tetrisaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + } + } + sprintf(fname,"tetris.%llu.pack",(long long)seed); + remove(fname); + //fprintf(stderr,"no keys tetris_extractgame %s\n",gametxid.GetHex().c_str()); + return(-1); +} + +UniValue tetris_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,char *method) +{ + //vin0 -> highlander vout from creategame TCBOO + //vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 60 blocks since last keystrokes, it is forfeit + //vins2+ -> rest of unspent registration utxo so all newgame vouts are spent + //vout0 -> nonfungible character with pack @ + //vout1 -> 1% ingame gold and all the buyins + + // detect if last to bailout + // vin0 -> kestrokes baton of completed game with Q + // vout0 -> playerdata marker + // vout0 -> 1% ingame gold + // get any playerdata, get all keystrokes, replay game and compare final state + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char mytetrisaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,tetrispk; uint8_t player[10000],mypriv[32],funcid; + struct CCcontract_info *cpTokens, tokensC; + + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + tetrispk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,mytetrisaddr,tetrispk,mypk); + result.push_back(Pair("name","tetris")); + result.push_back(Pair("method",method)); + result.push_back(Pair("mytetrisaddr",mytetrisaddr)); + if ( strcmp(method,"bailout") == 0 ) + { + funcid = 'Q'; + mult = 10; //100000; + } + else + { + funcid = 'H'; + mult = 20; //200000; + } + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + if ( (err= tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,1)) == 0 ) + { + if ( tetris_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,mytetrisaddr,numplayers,symbol,pname) == 0 ) + { + UniValue obj; struct tetris_player P; + seed = tetris_gamefields(obj,maxplayers,buyin,gametxid,mytetrisaddr); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Tetris_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i 0 ) + { + newdata.resize(num); + for (i=0; i no playerdata\n"); + newdata.resize(0); + //P.gold = (P.gold * 8) / 10; + } + else + { + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); + if ( P.amulet != 0 ) + mult *= 5; + dungeonlevel = P.dungeonlevel; + if ( P.amulet != 0 && dungeonlevel < 21 ) + dungeonlevel = 21; + cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel; + fprintf(stderr,"\nextracted $$$gold.%d -> %.8f TETRIS hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); + if ( funcid == 'H' && maxplayers > 1 ) + { + if ( P.amulet == 0 ) + { + if ( numplayers != maxplayers ) + return(cclib_error(result,"numplayers != maxplayers")); + else if ( tetris_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) + return(cclib_error(result,"highlander must be a winner or last one standing")); + } + cashout += numplayers * buyin; + } + if ( cashout >= txfee ) + { + if ( (inputsum= AddCClibInputs(cp,mtx,tetrispk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) + CCchange = (inputsum - cashout); + mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + } + } + } + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),tetrispk)); + Myprivkey(mypriv); + CCaddr1of2set(cp,tetrispk,mypk,mypriv,mytetrisaddr); + CScript opret; + if ( pname.size() == 0 ) + pname = Tetris_pname; + if ( newdata.size() == 0 ) + { + opret = tetris_highlanderopret(funcid, gametxid, regslot, mypk, nodata,pname); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); + //fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx.c_str()); + } + else + { + opret = tetris_highlanderopret(funcid, gametxid, regslot, mypk, newdata,pname); + char seedstr[32]; + sprintf(seedstr,"%llu",(long long)seed); + std::vector vopretNonfungible; + GetOpReturnData(opret, vopretNonfungible); + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string(seedstr), gametxid.GetHex(), vopretNonfungible)); + } + return(tetris_rawtxresult(result,rawtx,1)); + } + result.push_back(Pair("result","success")); + } else fprintf(stderr,"illegal game err.%d\n",err); + } else fprintf(stderr,"parameters only n.%d\n",n); + } + return(result); +} + +UniValue tetris_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + return(tetris_finishgame(txfee,cp,params,"bailout")); +} + +UniValue tetris_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + return(tetris_finishgame(txfee,cp,params,"highlander")); +} + +UniValue tetris_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char mytetrisaddr[64],str[64]; CPubKey mypk,tetrispk; + result.push_back(Pair("name","tetris")); + result.push_back(Pair("method","gameinfo")); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + txid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",txid.GetHex())); + if ( tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,0) == 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("gameheight",(int64_t)gameheight)); + mypk = pubkey2pk(Mypubkey()); + tetrispk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,mytetrisaddr,tetrispk,mypk); + //fprintf(stderr,"mytetrisaddr.%s\n",mytetrisaddr); + seed = tetris_gamefields(result,maxplayers,buyin,txid,mytetrisaddr); + result.push_back(Pair("seed",(int64_t)seed)); + for (i=0; i > unspentOutputs; + tetrispk = GetUnspendable(cp,0); + GetCCaddress(cp,coinaddr,tetrispk); + SetCCunspents(unspentOutputs,coinaddr); + nextheight = komodo_nextheight(); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers + continue; + if ( tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,1) == 0 && nextheight <= gameheight+TETRIS_MAXKEYSTROKESGAP ) + { + tetris_playersalive(openslots,numplayers,txid,maxplayers,gameheight,tx); + if ( openslots > 0 ) + a.push_back(txid.GetHex()); + } + } + result.push_back(Pair("result","success")); + tetris_univalue(result,"pending",-1,-1); + result.push_back(Pair("pending",a)); + result.push_back(Pair("numpending",(int64_t)a.size())); + return(result); +} + +UniValue tetris_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey tetrispk,mypk,pk; std::string symbol,pname; char coinaddr[64]; + std::vector > unspentOutputs; + tetrispk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetTokensCCaddress(cp,coinaddr,mypk); + SetCCunspents(unspentOutputs,coinaddr); + tetris_univalue(result,"players",-1,-1); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( it->second.satoshis != 1 || vout > 1 ) + continue; + if ( tetris_playerdata(cp,gametxid,tokenid,pk,playerdata,symbol,pname,txid) == 0 )//&& pk == mypk ) + { + a.push_back(txid.GetHex()); + //a.push_back(Pair("playerdata",tetris_playerobj(playerdata))); + } + } + result.push_back(Pair("playerdata",a)); + result.push_back(Pair("numplayerdata",(int64_t)a.size())); + return(result); +} + +UniValue tetris_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey tetrispk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; + std::vector > addressIndex; + //std::vector > unspentOutputs; + tetrispk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,coinaddr,tetrispk,mypk); + //SetCCunspents(unspentOutputs,coinaddr); + SetCCtxids(addressIndex,coinaddr); + tetris_univalue(result,"games",-1,-1); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( vout == 0 ) + { + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( tetris_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) + { + if ( CCgettxout(txid,vout,1,0) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); + } + } + } + } + } + result.push_back(Pair("pastgames",b)); + result.push_back(Pair("games",a)); + result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); + return(result); +} + +UniValue tetris_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); int32_t n; char *namestr = 0; + tetris_univalue(result,"setname",-1,-1); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + if ( (namestr= jstri(params,0)) != 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("pname",namestr)); + tetris_pname = namestr; + return(result); + } + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt get name")); + return(result); +} + +bool tetris_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,enabled = 0,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 ) + { + if (height < 21274 ) + return(true); + else if ( height > 50000 ) + enabled = 1; + } else enabled = 1; + if ( (numvouts= tx.vout.size()) > 1 ) + { + txid = tx.GetHash(); + scriptPubKey = tx.vout[numvouts-1].scriptPubKey; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 ) + { + script = (uint8_t *)vopret.data(); + funcid = script[1]; + if ( (e= script[0]) == EVAL_TOKENS ) + { + tokentx = funcid; + if ( (funcid= tetris_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) + { + if ( (funcid= tetris_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) + { + fprintf(stderr,"ht.%d couldnt decode tokens opret (%c)\n",height,script[1]); + } else e = EVAL_TETRIS, decoded = 1; + } else e = EVAL_TETRIS, decoded = 1; + } + if ( e == EVAL_TETRIS ) + { + //fprintf(stderr,"ht.%d tetris.(%c)\n",height,script[1]); + if ( decoded == 0 ) + { + switch ( funcid ) + { + case 'G': // seems just need to make sure no vout abuse is left to do + gametx = tx; + gametxid = tx.GetHash(); + gameheight = height; + if ( (err= tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,zeroid,0)) != 0 ) + { + fprintf(stderr,"height.%d %s tetris_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); + return eval->Invalid("invalid gametxid"); + } + //fprintf(stderr,"height.%d %s tetris_isvalidgame\n",height,gametxid.GetHex().c_str()); + return(true); + break; + case 'R': + if ( (funcid= tetris_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) + { + return eval->Invalid("couldnt decode register opret"); + } + // baton is created + // validation is done below + break; + case 'K': + if ( (funcid= tetris_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) + { + return eval->Invalid("couldnt decode keystrokes opret"); + } + // spending the baton proves it is the user if the pk is the signer + return(true); + break; + case 'H': case 'Q': + // done in the next switch statement as there are some H/Q tx with playerdata which would skip this section + break; + default: + return eval->Invalid("illegal tetris non-decoded funcid"); + break; + } + } + switch ( funcid ) + { + case 'R': // register + // verify vout amounts are as they should be and no vins that shouldnt be + return(true); + case 'H': // win + case 'Q': // bailout + if ( (f= tetris_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) + { + //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); + //if ( height > 20000 ) + return eval->Invalid("couldnt decode H/Q opret"); + } + // verify pk belongs to this tx + if ( tokentx == 'c' && playerdata.size() > 0 ) + { + static char laststr[512]; char cashstr[512]; + if ( tetris_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) + { + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } + if ( enabled != 0 ) + return eval->Invalid("mismatched playerdata"); + } + if ( funcid == 'H' ) + cashout *= 2; + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } + if ( enabled != 0 && tx.vout[2].nValue != cashout ) + return eval->Invalid("mismatched cashout amount"); + } + if ( funcid == 'Q' ) + { + // verify vin/vout + } + else // 'H' + { + // verify vin/vout and proper payouts + } + return(true); + break; + default: + return eval->Invalid("illegal tetris funcid"); + break; + } + } else return eval->Invalid("illegal evalcode"); + } else return eval->Invalid("opret too small"); + } else return eval->Invalid("not enough vouts"); + return(true); +} + From 5678fc596efa74b2f434402a039c9750b90ee66b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 23:08:52 -1100 Subject: [PATCH 2901/3904] Separate path --- src/cc/tetris.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 2b1c7736c..3e579d3e6 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -915,7 +915,7 @@ int main(int argc, char **argv) tg_delete(tg); return 0; } -#endif +#else /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -2390,4 +2390,5 @@ bool tetris_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const } else return eval->Invalid("not enough vouts"); return(true); } +#endif From 92ffb6d276a5ae9f15814510dfea29200a1e9a0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 23:13:20 -1100 Subject: [PATCH 2902/3904] Syntax --- src/cc/tetris.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 3e579d3e6..994ffc62a 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -588,7 +588,7 @@ void tg_init(tetris_game *obj, int rows, int cols) tetris_game *tg_create(int rows, int cols) { - tetris_game *obj = malloc(sizeof(tetris_game)); + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); tg_init(obj, rows, cols); return obj; } @@ -609,10 +609,11 @@ void tg_delete(tetris_game *obj) { */ tetris_game *tg_load(FILE *f) { - tetris_game *obj = malloc(sizeof(tetris_game)); + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); fread(obj, sizeof(tetris_game), 1, f); - obj->board = malloc(obj->rows * obj->cols); - fread(obj->board, sizeof(char), obj->rows * obj->cols, f); + obj->board = (char *)malloc(obj->rows * obj->cols); + if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + fprintf(stderr,"fread error\n"); return obj; } @@ -621,8 +622,10 @@ tetris_game *tg_load(FILE *f) */ void tg_save(tetris_game *obj, FILE *f) { - fwrite(obj, sizeof(tetris_game), 1, f); - fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f); + if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) + fprintf(stderr,"error writing tetrisgame\n"); + else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + fprintf(stderr,"error writing board\n"); } /* From 9d4fb2c5cf31f18826df8cdda6c4f5641335fc3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 23:17:20 -1100 Subject: [PATCH 2903/3904] Fix --- src/cc/tetris.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 994ffc62a..5dc3cacd9 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -570,7 +570,7 @@ void tg_init(tetris_game *obj, int rows, int cols) // Initialization logic obj->rows = rows; obj->cols = cols; - obj->board = malloc(rows * cols); + obj->board = (char *)malloc(rows * cols); memset(obj->board, TC_EMPTY, rows * cols); obj->points = 0; obj->level = 0; From 38674d0147e4d43f6d2d8d6850452fe11f8f7611 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 23:18:53 -1100 Subject: [PATCH 2904/3904] Free obj --- src/cc/tetris.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 5dc3cacd9..254c9b135 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -610,10 +610,23 @@ void tg_delete(tetris_game *obj) { tetris_game *tg_load(FILE *f) { tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); - fread(obj, sizeof(tetris_game), 1, f); - obj->board = (char *)malloc(obj->rows * obj->cols); - if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) - fprintf(stderr,"fread error\n"); + if (fread(obj, sizeof(tetris_game), 1, f) != 1 ) + { + fprintf(stderr,"read game error\n"); + free(obj); + obj = 0; + } + else + { + obj->board = (char *)malloc(obj->rows * obj->cols); + if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + { + fprintf(stderr,"fread error\n"); + free(obj->board); + free(obj); + obj = 0; + } + } return obj; } From 44d1fac8574ff9e4b63081d602ddc5323dd72e31 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Mar 2019 03:10:10 -1100 Subject: [PATCH 2905/3904] Maketetris --- src/cc/maketetris | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 src/cc/maketetris diff --git a/src/cc/maketetris b/src/cc/maketetris new file mode 100755 index 000000000..9c2a005a0 --- /dev/null +++ b/src/cc/maketetris @@ -0,0 +1,2 @@ +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE tetris.cpp -lncurses -o tetris + From 61beeb9e1fa542db8a0025ee0e42e140981d3537 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Fri, 8 Mar 2019 02:16:54 +0300 Subject: [PATCH 2906/3904] MNZ so long and thanks for fish --- src/assetchains.json | 4 ---- src/assetchains.old | 1 - 2 files changed, 5 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 27bf3bd56..67a2d5132 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -64,10 +64,6 @@ "ac_name": "MESH", "ac_supply": "1000007" }, - { - "ac_name": "MNZ", - "ac_supply": "257142858" - }, { "ac_name": "AXO", "ac_supply": "200000000" diff --git a/src/assetchains.old b/src/assetchains.old index bb493da9f..88d176df5 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -20,7 +20,6 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000007 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=MNZ -ac_supply=257142858 -addnode=51.15.138.138 $1 & ./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=ETOMIC -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BTCH -ac_supply=20998641 -addnode=78.47.196.146 & From 3c4eea4456f8be5b36b9802e3fdf4d6cff4732dd Mon Sep 17 00:00:00 2001 From: ca333 Date: Fri, 8 Mar 2019 03:25:10 +0100 Subject: [PATCH 2907/3904] update gitlab conf --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fab986211..a7354b240 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -73,8 +73,8 @@ build:windows: src/komodo-tx.exe src/cc/rogue/rogue.exe zcutil/fetch-params.bat - src/cc/rogue/x86_64-w64-mingw32/libcurl-4.dll - src/cc/rogue/x86_64-w64-mingw32/libncursesw6.dll + src/cc/rogue/x86_64-w64-mingw32/bin/libcurl-4.dll + src/cc/rogue/x86_64-w64-mingw32/bin/libncursesw6.dll ${PACKAGE_DIR_WINDOWS} - zip -r ${PACKAGE_DIR_WINDOWS}.zip ${PACKAGE_DIR_WINDOWS} - md5sum ${AGAMA_ARTIFACTS_WINDOWS} > ${AGAMA_ARTIFACTS_WINDOWS_CHECKSUM} From 0ed77a852c33ab9056ef0625665fa8b34d5b5f27 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Mar 2019 21:46:19 -1100 Subject: [PATCH 2908/3904] Slow down clock --- src/cc/tetris.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 254c9b135..40278d493 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -867,7 +867,7 @@ int main(int argc, char **argv) display_piece(hold, tg->stored); display_score(score, tg); doupdate(); - sleep_milli(10); + sleep_milli(50); switch (getch()) { case KEY_LEFT: From 5e44e6d33ec4ef262f360ce9bcd883640e2ab5f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Mar 2019 21:47:51 -1100 Subject: [PATCH 2909/3904] Faster and slower --- src/cc/tetris.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 40278d493..41e8c1a78 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -858,7 +858,7 @@ int main(int argc, char **argv) next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); - + int32_t counter = 0; // Game loop while (running) { running = tg_tick(tg, move); @@ -866,8 +866,9 @@ int main(int argc, char **argv) display_piece(next, tg->next); display_piece(hold, tg->stored); display_score(score, tg); - doupdate(); - sleep_milli(50); + if ( (counter++ & 1) == 0 ) + doupdate(); + sleep_milli(25); switch (getch()) { case KEY_LEFT: From 6ef61a1aa9de6902245f8a030e6fc5d09c15de3c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Mar 2019 21:50:30 -1100 Subject: [PATCH 2910/3904] A0/50 --- src/cc/tetris.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 41e8c1a78..d6ae473fe 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -866,9 +866,9 @@ int main(int argc, char **argv) display_piece(next, tg->next); display_piece(hold, tg->stored); display_score(score, tg); - if ( (counter++ & 1) == 0 ) + if ( (counter++ % 5) == 0 ) doupdate(); - sleep_milli(25); + sleep_milli(10); switch (getch()) { case KEY_LEFT: From 21c8a023e70703c4d31be9ca0279f28a43c3f4de Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Mar 2019 22:54:02 -1100 Subject: [PATCH 2911/3904] Fix dilithium inputs scan to compare for the voutpubtxids[vout] --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index d4b75bf38..7ab6b4c37 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3352,7 +3352,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && destpubtxid == checktxid ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && checktxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From 5c66b810d3cbad6ad7b1cd7da30695490cfdef3b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 9 Mar 2019 07:50:53 -0800 Subject: [PATCH 2912/3904] Prevent use of uninitialized ignoredAddresses --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index b798599b7..f00f2adf8 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -441,7 +441,7 @@ uint32_t komodo_segid32(char *coinaddr); UniValue CBlockTreeDB::Snapshot(int top) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; - int64_t utxos = 0; int64_t ignoredAddresses; + int64_t utxos = 0; int64_t ignoredAddresses = 0; boost::scoped_ptr iter(NewIterator()); std::map addressAmounts; std::vector > vaddr; From 6398d6f0547436681e01f46e44a97c1430240a04 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 9 Mar 2019 14:52:49 -0800 Subject: [PATCH 2913/3904] Filter out amount=0 UTXOs from getsnapshot results --- src/txdb.cpp | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index f00f2adf8..0588d52de 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -491,27 +491,31 @@ UniValue CBlockTreeDB::Snapshot(int top) getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); - std::map ::iterator ignored = ignoredMap.find(address); - if (ignored != ignoredMap.end()) { - fprintf(stderr,"ignoring %s\n", address.c_str()); - ignoredAddresses++; - continue; - } + if (nValue > 0) { + std::map ::iterator ignored = ignoredMap.find(address); + if (ignored != ignoredMap.end()) { + fprintf(stderr,"ignoring %s\n", address.c_str()); + ignoredAddresses++; + continue; + } - std::map ::iterator pos = addressAmounts.find(address); - if (pos == addressAmounts.end()) { - // insert new address + utxo amount - //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); - addressAmounts[address] = nValue; - totalAddresses++; + std::map ::iterator pos = addressAmounts.find(address); + if (pos == addressAmounts.end()) { + // insert new address + utxo amount + //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); + addressAmounts[address] = nValue; + totalAddresses++; + } else { + // update unspent tally for this address + //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); + addressAmounts[address] += nValue; + } + //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); + // total += nValue; + utxos++; } else { - // update unspent tally for this address - //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); - addressAmounts[address] += nValue; + fprintf(stderr,"ignoring amount=0 UTXO for %s\n", address.c_str()); } - //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); - // total += nValue; - utxos++; } catch (const std::exception& e) { fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what()); break; From 3c0a67db4ad5ec709e45143d146334258d9afc6f Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Sun, 10 Mar 2019 03:53:16 +0300 Subject: [PATCH 2914/3904] AXO -ac_ccenable=130000 --- src/assetchains.json | 3 ++- src/assetchains.old | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 67a2d5132..65cbba763 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -66,7 +66,8 @@ }, { "ac_name": "AXO", - "ac_supply": "200000000" + "ac_supply": "200000000", + "ac_ccenable": "130000" }, { "ac_name": "ETOMIC", diff --git a/src/assetchains.old b/src/assetchains.old index 88d176df5..6c7374aa3 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -20,7 +20,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000007 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -addnode=78.47.196.146 & +./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -addnode=78.47.196.146 -ac_ccenable=130000 & ./komodod -pubkey=$pubkey -ac_name=ETOMIC -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BTCH -ac_supply=20998641 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & From de840514db6dc350f2ef8f1e9ab7dbd05985600c Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Sun, 10 Mar 2019 17:23:16 +0100 Subject: [PATCH 2915/3904] Fix logs and wiftype in DecodeGatewaysBind. (#1325) --- src/cc/gateways.cpp | 228 ++++++++++++++++++++++---------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index c0ee794ef..f0c8735e2 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -166,7 +166,7 @@ CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin, return(EncodeTokenOpRet(tokenid,pubkeys, std::make_pair(OPRETID_GATEWAYSDATA, vopret))); } -uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t wiftype) +uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype) { std::vector> oprets; std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector pubkeys; @@ -185,7 +185,7 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui if ( N > 1 ) { strcpy(depositaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys))).ToString().c_str()); - LogPrint("gatewayscc-1","f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr); + LOGSTREAM("gatewayscc", CCLOG_DEBUG1, stream << "f." << f << " M." << M << " of N." << N << " size." << (int32_t)gatewaypubkeys.size() << " -> " << depositaddr << std::endl); } else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG); } else @@ -194,7 +194,7 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui else GetCustomscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG,taddr,prefix,prefix2); } return(f); - } else LogPrint("gatewayscc-1","error decoding bind opret\n"); + } else LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "error decoding bind opret" << std::endl); return(0); } @@ -381,15 +381,15 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti numvouts = tx.vout.size(); for (i=0; iismyvin)(tx.vin[i].scriptSig) != 0 ) { - //LogPrint("gatewayscc","vini.%d check mempool\n",i); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "vini." << i << " check mempool" << std::endl); if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) return eval->Invalid("cant find vinTx"); else { - //LogPrint("gatewayscc","vini.%d check hash and vout\n",i); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "vini." << i << " check hash and vout" << std::endl); if ( hashBlock == zerohash ) return eval->Invalid("cant Gateways from mempool"); if ( (assetoshis= IsGatewaysvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) @@ -399,13 +399,13 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti } for (i=0; iInvalid("mismatched inputs != outputs + txfee"); } else return(true); @@ -425,7 +425,7 @@ static int32_t myIs_coinaddr_inmempoolvout(char *coinaddr) Getscriptaddress(destaddr,tx.vout[i].scriptPubKey); if ( strcmp(destaddr,coinaddr) == 0 ) { - LogPrint("gatewayscc-1","found (%s) vout in mempool\n",coinaddr); + LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "found (" << coinaddr << ") vout in mempool" << std::endl); return(1); } } @@ -438,36 +438,35 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u { CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int32_t len,len2,numvouts; int64_t val,merkleht; CPubKey pk; std::vectordata; txid = zeroid; - char str[65]; - LogPrint("gatewayscc-2","start reverse scan %s\n",uint256_str(str,batontxid)); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "start reverse scan " << batontxid.GetHex() << std::endl); while ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) { - LogPrint("gatewayscc-2","check %s\n",uint256_str(str,batontxid)); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "check " << batontxid.GetHex() << std::endl); if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid ) { - LogPrint("gatewayscc-2","decoded %s\n",uint256_str(str,batontxid)); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "decoded " << batontxid.GetHex() << std::endl); if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) { len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()); len2 = oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()); - char str2[65]; LogPrint("gatewayscc","found merkleht.%d len.%d len2.%d %s %s\n",(int32_t)merkleht,len,len2,uint256_str(str,hash),uint256_str(str2,mhash)); + LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "found merkleht." << (int32_t)merkleht << " len." << len << " len2." << len2 << " " << hash.GetHex() << " " << mhash.GetHex() << std::endl); if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid ) { txid = batontxid; - LogPrint("gatewayscc-2","set txid\n"); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "set txid" << std::endl); return(mhash); } else { - LogPrint("gatewayscc-2","missing hash\n"); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "missing hash" << std::endl); return(zeroid); } - } else LogPrint("gatewayscc-2","height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); + } else LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "height." << (int32_t)merkleht << " vs search ht." << (int32_t)height << std::endl); batontxid = bhash; - LogPrint("gatewayscc-2","new hash %s\n",uint256_str(str,batontxid)); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "new hash " << batontxid.GetHex() << std::endl); } else break; } - LogPrint("gatewayscc-2","end of loop\n"); + LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "end of loop\n"); return(zeroid); } @@ -500,27 +499,27 @@ uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::ve int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 cointxid,const std::string deposithex,std::vectorproof,uint256 merkleroot,CPubKey destpub,uint8_t taddr,uint8_t prefix,uint8_t prefix2) { std::vector txids; uint256 proofroot,hashBlock,txid = zeroid; CTransaction tx; std::string name,description,format; - char destaddr[64],destpubaddr[64],claimaddr[64],str[65],str2[65]; int32_t i,numvouts; int64_t nValue = 0; + char destaddr[64],destpubaddr[64],claimaddr[64]; int32_t i,numvouts; int64_t nValue = 0; if ( myGetTransaction(oracletxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - LogPrint("gatewayscc","GatewaysVerify cant find oracletxid %s\n",uint256_str(str,oracletxid)); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify cant find oracletxid " << oracletxid.GetHex() << std::endl); return(0); } if ( DecodeOraclesCreateOpRet(tx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' || name != refcoin ) { - LogPrint("gatewayscc","GatewaysVerify mismatched oracle name %s != %s\n",name.c_str(),refcoin.c_str()); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify mismatched oracle name " << name << " != " << refcoin << std::endl); return(0); } proofroot = BitcoinGetProofMerkleRoot(proof,txids); if ( proofroot != merkleroot ) { - LogPrint("gatewayscc","GatewaysVerify mismatched merkleroot %s != %s\n",uint256_str(str,proofroot),uint256_str(str2,merkleroot)); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify mismatched merkleroot " << proofroot.GetHex() << " != " << merkleroot.GetHex() << std::endl); return(0); } if (std::find(txids.begin(), txids.end(), cointxid) == txids.end()) { - LogPrint("gatewayscc", "GatewaysVerify invalid proof for this cointxid\n"); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify invalid proof for this cointxid" << std::endl); return 0; } if ( DecodeHexTx(tx,deposithex) != 0 ) @@ -541,10 +540,10 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout } if ( txid == cointxid ) { - LogPrint("gatewayscc-1","verified proof for cointxid in merkleroot\n"); + LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "verified proof for cointxid in merkleroot" << std::endl); return(nValue); - } else LogPrint("gatewayscc","(%s) != (%s) or txid %s mismatch.%d or script mismatch\n",refdepositaddr,destaddr,uint256_str(str,txid),txid != cointxid); - } else LogPrint("gatewayscc","claimaddr.(%s) != destpubaddr.(%s)\n",claimaddr,destpubaddr); + } else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "(" << refdepositaddr << ") != (" << destaddr << ") or txid " << txid.GetHex() << " mismatch." << (txid!=cointxid) << " or script mismatch" << std::endl); + } else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "claimaddr." << claimaddr << " != destpubaddr." << destpubaddr << std::endl); } return(0); } @@ -578,7 +577,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 { if ( tokenid == reftokenid ) { - LogPrint("gatewayscc","trying to bind an existing tokenid\n"); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "trying to bind an existing tokenid" << std::endl); return(1); } } @@ -876,7 +875,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & } retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) - LogPrint("gatewayscc","Gateways tx validated\n"); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "Gateways tx validated" << std::endl); else fprintf(stderr,"Gateways tx invalid\n"); return(retval); // } @@ -900,7 +899,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP GetTokensCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); threshold = total/(maxinputs+1); - LogPrint("gatewayscc-1","check %s for gateway inputs\n",coinaddr); + LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "check " << coinaddr << " for gateway inputs" << std::endl); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -935,9 +934,9 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP } return(totalinputs); } - else LogPrint("gatewayscc","invalid GatewaysBind\n"); + else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "invalid GatewaysBind" << std::endl); } - else LogPrint("gatewayscc","can't find GatewaysBind txid\n"); + else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "can't find GatewaysBind txid" << std::endl); return(0); } @@ -963,18 +962,18 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t prefix2 = p2; wiftype = p3; taddr = p4; - LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d, taddr %d for %s\n",prefix,prefix2,wiftype,taddr,coin.c_str()); + LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "set prefix " << prefix << ", prefix2 " << prefix2 << ", wiftype " << wiftype << ", taddr " << taddr << " for " << coin << std::endl); } if ( N == 0 || N > 15 || M > N ) { CCerror = strprintf("illegal M.%d or N.%d",M,N); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( pubkeys.size() != N ) { CCerror = strprintf("M.%d N.%d but pubkeys[%d]",M,N,(int32_t)pubkeys.size()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } for (i=0; iunspendableCCaddr,(double)totalsupply/COIN,(double)fullsupply/COIN); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( CCtoken_balance(myTokenCCaddr,tokenid) != totalsupply ) { CCerror = strprintf("token balance on %s %.8f != %.8f",myTokenCCaddr,(double)CCtoken_balance(myTokenCCaddr,tokenid)/COIN,(double)totalsupply/COIN); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) { CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' ) { CCerror = strprintf("mismatched oracle name %s != %s",name.c_str(),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( (fstr=(char *)format.c_str()) == 0 || strncmp(fstr,"Ihh",3) != 0 ) { CCerror = strprintf("illegal format (%s) != (%s)",fstr,(char *)"Ihh"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( GatewaysBindExists(cp,gatewayspk,tokenid) != 0 ) { CCerror = strprintf("Gateway bind.%s (%s) already exists",coin.c_str(),uint256_str(str,tokenid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) @@ -1044,7 +1043,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t } } CCerror = strprintf("cant find enough inputs"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1059,30 +1058,31 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - LogPrint("gatewayscc-1","GatewaysDeposit ht.%d %s %.8f numpks.%d\n",height,refcoin.c_str(),(double)amount/COIN,(int32_t)pubkeys.size()); + LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "GatewaysDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl); if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) { CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (komodo_txnotarizedconfirmed(bindtxid)==false) { CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } n = (int32_t)pubkeys.size(); merkleroot = zeroid; for (i=m=0; i 0 ) @@ -1119,7 +1119,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysDepositOpRet('D',bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,destpub,amount))); } CCerror = strprintf("cant find enough inputs"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1139,49 +1139,49 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || coin != refcoin ) { CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (komodo_txnotarizedconfirmed(bindtxid)==false) { CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( GetTransaction(deposittxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find deposittxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmptxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D' || coin != refcoin) { CCerror = strprintf("invalid coin - deposittxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (komodo_txnotarizedconfirmed(deposittxid)==false) { CCerror = strprintf("gatewaysdeposit tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (tmpdestpub!=destpub) { CCerror = strprintf("different destination pubkey from desdeposit tx"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( (depositamount=GatewaysDepositval(tx,mypk)) != amount ) { CCerror = strprintf("invalid Gateways deposittxid %s %.8f != %.8f",uint256_str(str,deposittxid),(double)depositamount/COIN,(double)amount/COIN); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) @@ -1196,7 +1196,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui } } CCerror = strprintf("cant find enough inputs or mismatched total"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1218,19 +1218,19 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || coin != refcoin ) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (komodo_txnotarizedconfirmed(bindtxid)==false) { CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); @@ -1248,7 +1248,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) { CCerror = strprintf("unable to create withdraw, another withdraw pending"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1257,7 +1257,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) { CCerror = strprintf("unable to create withdraw, another withdraw pending"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } @@ -1275,12 +1275,12 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin else { CCerror = strprintf("not enough balance of tokens for withdraw"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } CCerror = strprintf("cant find enough normal inputs"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1301,7 +1301,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (funcid=='W') @@ -1310,26 +1310,26 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } @@ -1338,39 +1338,39 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) { CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) { CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } @@ -1381,7 +1381,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysPartialOpRet('P',withdrawtxid,refcoin,K+1,mypk,hex))); } CCerror = strprintf("error adding funds for partialsign"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1401,7 +1401,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (funcid=='W') @@ -1410,26 +1410,26 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,lasttxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } @@ -1438,38 +1438,38 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) { CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) { CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,withdrawtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } @@ -1480,7 +1480,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,K+1,hex))); } CCerror = strprintf("error adding funds for completesigning"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1498,44 +1498,44 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) { CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex)!='S' || refcoin!=coin) { CCerror = strprintf("cannot decode completesigning tx opret %s",uint256_str(str,completetxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (komodo_txnotarizedconfirmed(completetxid)==false) { CCerror = strprintf("gatewayscompletesigning tx not yet confirmed/notarized"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) { CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) { CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin!=coin || tokenid!=tmptokenid) { CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (AddNormalinputs(mtx,mypk,txfee,3)!=0) @@ -1545,7 +1545,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',withdrawtxid,refcoin,completetxid))); } CCerror = strprintf("error adding funds for markdone"); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1565,13 +1565,13 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } SetCCunspents(unspentOutputs,coinaddr); @@ -1620,13 +1620,13 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } n = msigpubkeys.size(); @@ -1708,13 +1708,13 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin) { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } n = msigpubkeys.size(); @@ -1786,13 +1786,13 @@ UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey) if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } GetCustomscriptaddress(addr,CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG,taddr,prefix,prefix2); @@ -1810,13 +1810,13 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key) if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -1839,13 +1839,13 @@ UniValue GatewaysInfo(uint256 bindtxid) if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') { CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LogPrint("gatewayscc","%s\n", CCerror.c_str() ); + LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) From b1a3104786769ce2fef8f74b448b0e1bc7b90cb1 Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 10 Mar 2019 21:20:20 +0100 Subject: [PATCH 2916/3904] ac_ccactivate (#1326) * ac_ccactivate * Update assetchains.json --- src/assetchains.json | 2 +- src/assetchains.old | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 65cbba763..dfc352a2f 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -67,7 +67,7 @@ { "ac_name": "AXO", "ac_supply": "200000000", - "ac_ccenable": "130000" + "ac_ccactivate": "130000" }, { "ac_name": "ETOMIC", diff --git a/src/assetchains.old b/src/assetchains.old index 6c7374aa3..58f8e754a 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -20,7 +20,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000007 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -addnode=78.47.196.146 -ac_ccenable=130000 & +./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -ac_ccactivate=130000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=ETOMIC -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BTCH -ac_supply=20998641 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & From 1cfb5374de1ff4a21bab9da6ed552c8fb2c717cf Mon Sep 17 00:00:00 2001 From: Decker Date: Mon, 11 Mar 2019 05:51:02 +0300 Subject: [PATCH 2917/3904] + msvc 2015 deps headers --- .../deps/install/include/acs_defs.h | 265 +++ .../deps/install/include/curses.h | 1846 +++++++++++++++++ .../deps/install/include/curspriv.h | 134 ++ .../deps/install/include/getopt.h | 93 + .../deps/install/include/panel.h | 56 + .../deps/install/include/term.h | 48 + .../deps/install/include/unistd.h | 56 + 7 files changed, 2498 insertions(+) create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h new file mode 100644 index 000000000..c8c02a737 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h @@ -0,0 +1,265 @@ +/* Many of the following #defines are completely unused for the +nonce. For each character, its code point in code page 437, +Unicode, and page 8859-1 are given. The first is used for +non-wide builds in Win32 console, DOS, SDL, and OS/2. +Unicode is used for all wide builds, and for the non-wide +build of WinGUI. Code page 8859-1 is used for non-wide X11. + + All of these characters exist in CP437 and Unicode. Some +don't exist in 8859-1, in which case the last column is 'TBD'. +Only 32 are used in ncurses. So caution is advised. */ + +#ifdef USE_ISO8859_CHARSET + #define CHOOSE( A, B, C) (C) + #define TBD '!' +#else + #define CHOOSE( A, B, C) (USE_UNICODE_ACS_CHARS ? B : A) +#endif + +/* Codes found from https://en.wikipedia.org/wiki/Code_page_437 */ + +#define SMILE CHOOSE( 0x01, 0x263a, 'O') +#define REV_SMILE CHOOSE( 0x02, 0x263b, 'O') +#define HEART CHOOSE( 0x03, 0x2665, 'H') +#define DIAMOND CHOOSE( 0x04, 0x2666, 0x01) +#define CLUB CHOOSE( 0x05, 0x2663, 'C') +#define SPADE CHOOSE( 0x06, 0x2660, 'S') +#define MEDIUM_BULLET CHOOSE( 0x07, 0x2022, 0xb7) +#define REV_BULLET CHOOSE( 0x08, 0x2508, 0xb7) +#define WHITE_BULLET CHOOSE( 0x09, 0x25cb, 7) +#define REV_WHITE_BULLET CHOOSE( 0x0a, 0x25D9, 7) +#define MALE_SYM CHOOSE( 0x0b, 0x2642, 'm') +#define FEMALE_SYM CHOOSE( 0x0c, 0x2640, 'f') +#define QTR_NOTE CHOOSE( 0x0d, 0x266a, 0xbc) +#define EIGHTH_NOTE CHOOSE( 0x0e, 0x266b, 0xbd) +#define SPLAT CHOOSE( 0x0f, 0xa4 , 0xa4) +#define RIGHT_TRIANGLE CHOOSE( 0x10, 0x25b6, '>') +#define LEFT_TRIANGLE CHOOSE( 0x11, 0x25c0, '<') +#define UP_DOWN_ARROW CHOOSE( 0x12, 0x2195, 0x19) +#define DBL_BANG CHOOSE( 0x13, 0x203c, '!') +#define PILCROW CHOOSE( 0x14, 0xb6 , 0xb6) +#define SECTION_SIGN CHOOSE( 0x15, 0xa7 , 0xa7) +#define LOW_QTR_BLOCK CHOOSE( 0x16, 0x25b2, '_') +#define UP_DOWN_ARROW_UNDERSCORED CHOOSE( 0x17, 0x21ab, 0x19) +#define UP_ARROW CHOOSE( 0x18, 0x2191, '^') +#define DOWN_ARROW CHOOSE( 0x19, 0x2193, 'v') +#define RIGHT_ARROW CHOOSE( 0x1a, 0x2192, '>') +#define LEFT_ARROW CHOOSE( 0x1b, 0x2190, '<') +#define RIGHT_ANGLE CHOOSE( 0x1c, 0x221f, 0xe) +#define LEFT_RIGHT_ARROW CHOOSE( 0x1d, 0x2194, '-') +#define UP_TRIANGLE CHOOSE( 0x1e, 0x25b2, '^') +#define DOWN_TRIANGLE CHOOSE( 0x1f, 0x25bc, 'v') + +#define UPPERCASE_C_CEDILLA CHOOSE( 0x80, 0xc7 , 0xc7) +#define LOWERCASE_U_UMLAUT CHOOSE( 0x81, 0xfc , 0xfc) +#define LOWERCASE_E_ACUTE CHOOSE( 0x82, 0xe9 , 0xe9) +#define LOWERCASE_A_CIRCUMFLEX CHOOSE( 0x83, 0xe2 , 0xe2) +#define LOWERCASE_A_UMLAUT CHOOSE( 0x84, 0xe4 , 0xe4) +#define LOWERCASE_A_GRAVE CHOOSE( 0x85, 0xe0 , 0xea) +#define LOWERCASE_A_RING CHOOSE( 0x86, 0xe5 , 0xe5) +#define LOWERCASE_C_CEDILLA CHOOSE( 0x87, 0xe7 , 0xe7) +#define LOWERCASE_E_CIRCUMFLEX CHOOSE( 0x88, 0xea , 0xea) +#define LOWERCASE_E_UMLAUT CHOOSE( 0x89, 0xeb , 0xeb) +#define LOWERCASE_E_GRAVE CHOOSE( 0x8a, 0xe8 , 0xe8) +#define LOWERCASE_I_UMLAUT CHOOSE( 0x8b, 0xef , 0xef) +#define LOWERCASE_I_CIRCUMFLEX CHOOSE( 0x8c, 0xee , 0xee) +#define LOWERCASE_I_GRAVE CHOOSE( 0x8d, 0xec , 0xce) +#define UPPERCASE_A_UMLAUT CHOOSE( 0x8e, 0xc4 , 0xc4) +#define UPPERCASE_A_RING CHOOSE( 0x8f, 0xc5 , 0xc5) + +#define UPPERCASE_E_ACUTE CHOOSE( 0x90, 0xc9 , 0xc9) +#define LOWERCASE_AE_LIGATURE CHOOSE( 0x91, 0xe6 , 0xe6) +#define UPPERCASE_AE_LIGATURE CHOOSE( 0x92, 0xc6 , 0xc6) +#define LOWERCASE_O_CIRCUMFLEX CHOOSE( 0x93, 0xf4 , 0xf4) +#define LOWERCASE_O_UMLAUT CHOOSE( 0x94, 0xf6 , 0xf6) +#define LOWERCASE_O_GRAVE CHOOSE( 0x95, 0xf2 , 0xf2) +#define LOWERCASE_U_CIRCUMFLEX CHOOSE( 0x96, 0xfb , 0xfb) +#define LOWERCASE_U_GRAVE CHOOSE( 0x97, 0xf9 , 0xf9) +#define LOWERCASE_Y_UMLAUT CHOOSE( 0x98, 0xff , 0xff) +#define UPPERCASE_O_UMLAUT CHOOSE( 0x99, 0xd6 , 0xd6) +#define UPPERCASE_U_UMLAUT CHOOSE( 0x9a, 0xdc , 0xdc) +#define CENT_SIGN CHOOSE( 0x9b, 0xa2 , 0xa2) +#define STERLING_SIGN CHOOSE( 0x9c, 0xa3 , 30) +#define YEN_SIGN CHOOSE( 0x9d, 0xa5 , 0xa5) +#define PESETA_SIGN CHOOSE( 0x9e, 0x20a7, TBD) +#define F_WITH_HOOK CHOOSE( 0x9f, 0x0192, TBD) + +#define LOWERCASE_A_ACUTE CHOOSE( 0xa0, 0xe1 , 0xe1) +#define LOWERCASE_I_ACUTE CHOOSE( 0xa1, 0xed , 0xed) +#define LOWERCASE_O_ACUTE CHOOSE( 0xa2, 0xf3 , 0xf3) +#define LOWERCASE_U_ACUTE CHOOSE( 0xa3, 0xfa , 0xfa) +#define LOWERCASE_N_TILDE CHOOSE( 0xa4, 0xf1 , 0xf1) +#define UPPERCASE_N_TILDE CHOOSE( 0xa5, 0xd1 , 0xd1) +#define A_ORDINAL CHOOSE( 0xa6, 0xaa , 0xaa) +#define O_ORDINAL CHOOSE( 0xa7, 0xba , 0xba) +#define INVERTED_QUESTION_MARK CHOOSE( 0xa8, 0xbf , 0xbf) +#define REVERSED_NOT_SIGN CHOOSE( 0xa9, 0x2310, TBD) +#define NOT_SIGN CHOOSE( 0xaa, 0xac , 0xac) +#define VULGAR_HALF CHOOSE( 0xab, 0xbd , 0xbd) +#define VULGAR_QUARTER CHOOSE( 0xac, 0xbc , 0xbc) +#define INVERTED_EXCLAMATION_MARK CHOOSE( 0xad, 0xa1 , 0xa1) +#define LEFT_ANGLE_QUOTE_MARK CHOOSE( 0xae, 0xab , 0xab) +#define RIGHT_ANGLE_QUOTE_MARK CHOOSE( 0xaf, 0xbb , 0xbb) + +#define LIGHT_SHADE CHOOSE( 0xb0, 0x2591, '#' ) +#define MEDIUM_SHADE CHOOSE( 0xb1, 0x2592, 2) +#define DARK_SHADE CHOOSE( 0xb2, 0x2593, TBD) +#define BOX_VLINE CHOOSE( 0xb3, 0x2502, 25) +#define BOX_RTEE CHOOSE( 0xb4, 0x2524, 22) +#define BOX_SD_RTEE CHOOSE( 0xb5, 0x2561, 22) +#define BOX_DS_RTEE CHOOSE( 0xb6, 0x2562, 22) +#define BOX_DS_URCORNER CHOOSE( 0xb7, 0x2556, 12) +#define BOX_SD_URCORNER CHOOSE( 0xb8, 0x2555, 12) +#define BOX_D_RTEE CHOOSE( 0xb9, 0x2563, 22) +#define BOX_D_VLINE CHOOSE( 0xba, 0x2551, 25) +#define BOX_D_URCORNER CHOOSE( 0xbb, 0x2557, 12) +#define BOX_D_LRCORNER CHOOSE( 0xbc, 0x255D, 11) +#define BOX_DS_LRCORNER CHOOSE( 0xbd, 0x255c, 11) +#define BOX_SD_LRCORNER CHOOSE( 0xbe, 0x255b, 11) +#define BOX_URCORNER CHOOSE( 0xbf, 0x2510, 12) + +#define BOX_LLCORNER CHOOSE( 0xc0, 0x2514, 14) +#define BOX_BTEE CHOOSE( 0xc1, 0x2534, 23) +#define BOX_TTEE CHOOSE( 0xc2, 0x252c, 24) +#define BOX_LTEE CHOOSE( 0xc3, 0x251c, 21) +#define BOX_HLINE CHOOSE( 0xc4, 0x2500, 18) +#define BOX_PLUS CHOOSE( 0xc5, 0x253c, 15) +#define BOX_SD_LTEE CHOOSE( 0xc6, 0x255e, 21) +#define BOX_DS_LTEE CHOOSE( 0xc7, 0x255f, 21) +#define BOX_D_LLCORNER CHOOSE( 0xc8, 0x255A, 14) +#define BOX_D_ULCORNER CHOOSE( 0xc9, 0x2554, 13) +#define BOX_D_BTEE CHOOSE( 0xca, 0x2569, 23) +#define BOX_D_TTEE CHOOSE( 0xcb, 0x2566, 24) +#define BOX_D_LTEE CHOOSE( 0xcc, 0x2560, 21) +#define BOX_D_HLINE CHOOSE( 0xcd, 0x2550, 18) +#define BOX_D_PLUS CHOOSE( 0xce, 0x256C, 15) +#define BOX_SD_BTEE CHOOSE( 0xcf, 0x2567, 23) + +#define BOX_DS_BTEE CHOOSE( 0xd0, 0x2568, 23) +#define BOX_SD_TTEE CHOOSE( 0xd1, 0x2564, 24) +#define BOX_DS_TTEE CHOOSE( 0xd2, 0x2565, 24) +#define BOX_DS_LLCORNER CHOOSE( 0xd3, 0x2559, 14) +#define BOX_SD_LLCORNER CHOOSE( 0xd4, 0x2558, 14) +#define BOX_SD_ULCORNER CHOOSE( 0xd5, 0x2552, 13) +#define BOX_DS_ULCORNER CHOOSE( 0xd6, 0x2553, 13) +#define BOX_DS_PLUS CHOOSE( 0xd7, 0x256b, 15) +#define BOX_SD_PLUS CHOOSE( 0xd8, 0x256a, 15) +#define BOX_LRCORNER CHOOSE( 0xd9, 0x2518, 11) +#define BOX_ULCORNER CHOOSE( 0xda, 0x250c, 13) +#define FULL_BLOCK CHOOSE( 0xdb, 0x2588, 0) +#define LOWER_HALF_BLOCK CHOOSE( 0xdc, 0x2584, TBD) +#define LEFT_HALF_BLOCK CHOOSE( 0xdd, 0x258c, TBD) +#define RIGHT_HALF_BLOCK CHOOSE( 0xde, 0x2590, TBD) +#define UPPER_HALF_BLOCK CHOOSE( 0xdf, 0x2580, TBD) + +#define ALPHA CHOOSE( 0xe0, 0x03b1, TBD) +#define BETA CHOOSE( 0xe1, 0x00df, TBD) +#define GAMMA CHOOSE( 0xe2, 0x0393, TBD) +#define PI CHOOSE( 0xe3, 0x03c0, 28) +#define UPPERCASE_SIGMA CHOOSE( 0xe4, 0x03a3, TBD) +#define LOWERCASE_SIGMA CHOOSE( 0xe5, 0x03c3, TBD) +#define MU CHOOSE( 0xe6, 0x00b5, 0xb5) +#define TAU CHOOSE( 0xe7, 0x03c4, TBD) +#define UPPERCASE_PHI CHOOSE( 0xe8, 0x03a6, TBD) +#define THETA CHOOSE( 0xe9, 0x0398, TBD) +#define OMEGA CHOOSE( 0xea, 0x03a9, TBD) +#define DELTA CHOOSE( 0xeb, 0x03b4, TBD) +#define INFINITY_SIGN CHOOSE( 0xec, 0x221e, TBD) +#define LOWERCASE_PHI CHOOSE( 0xed, 0x03c6, TBD) +#define EPSILON CHOOSE( 0xee, 0x03b5, TBD) +#define INTERSECTION CHOOSE( 0xef, 0x2229, TBD) + +#define TRIPLE_BAR CHOOSE( 0xf0, 0x2261, TBD) +#define PLUS_OR_MINUS CHOOSE( 0xf1, 0x00b1, 8) +#define GREATER_THAN_OR_EQUAL_TO CHOOSE( 0xf2, 0x2265, 27) +#define LESSER_THAN_OR_EQUAL_TO CHOOSE( 0xf3, 0x2264, 26) +#define UPPER_HALF_INTEGRAL_SIGN CHOOSE( 0xf4, 0x2320, TBD) +#define LOWER_HALF_INTEGRAL_SIGN CHOOSE( 0xf5, 0x2321, TBD) +#define DIVISION_SIGN CHOOSE( 0xf6, 0x00f7, 0xf7) +#define APPROXIMATELY_EQUALS_SIGN CHOOSE( 0xf7, 0x2248, TBD) +#define DEGREE_SIGN CHOOSE( 0xf8, 0x00b0, 0xb0) +#define LARGE_BULLET CHOOSE( 0xf9, 0x2219, 7) +#define SMALL_BULLET CHOOSE( 0xfa, 0x00b7, 0xb7) +#define SQUARE_ROOT CHOOSE( 0xfb, 0x221a, TBD) +#define SUPERSCRIPT_N CHOOSE( 0xfc, 0x207f, TBD) +#define SUPERSCRIPT_2 CHOOSE( 0xfd, 0x00b2, 0xb2) +#define CENTERED_SQUARE CHOOSE( 0xfe, 0x25a0, TBD) +#define NON_BREAKING_SPACE CHOOSE( 0xff, 0x00a0, TBD) + + + + /* It says at http://unicode.org/charts/PDF/U2300.pdf */ + /* that '...the scan line numbers here refer to old, */ + /* low-resolution technology for terminals, with only */ + /* nine scan lines per fixed-size character glyph. */ + /* Even-numbered scan lines are unified with box */ + /* drawing graphics." */ + /* The utility of these is questionable; they'd */ + /* work Just Fine in wingdi (_if_ the appropriate */ + /* glyphs are available), but not elsewhere. */ +#define HORIZ_SCAN_LINE_1 CHOOSE( 0x2d, 0x23ba, 16) +#define HORIZ_SCAN_LINE_3 CHOOSE( 0x2d, 0x23bb, 17) +#define HORIZ_SCAN_LINE_7 CHOOSE( 0x2d, 0x23bc, 19) +#define HORIZ_SCAN_LINE_9 CHOOSE( '_', 0x23bd, 20) + + /* Code page 437 lacks a 'for real' not-equals, so for that, */ + /* we use the double-horizontal single-vertical box drawing : */ +#define NOT_EQUALS_SIGN CHOOSE( 0xd8, 0x2260, 29) + +# define A(x) ((chtype)x | A_ALTCHARSET) + +chtype acs_map[128] = +{ + A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), + A(9), A(10), + CLUB, HEART, SPADE, SMILE, REV_SMILE, /* 11 12 13 14 15 */ + MEDIUM_BULLET, WHITE_BULLET, PILCROW, SECTION_SIGN, /* 16 17 18 19 */ + A_ORDINAL, O_ORDINAL, LOWERCASE_PHI, /* 20 21 22 */ + INVERTED_EXCLAMATION_MARK, INVERTED_QUESTION_MARK, /* 23 24 */ + REVERSED_NOT_SIGN, NOT_SIGN, /* 25 26 */ + UPPER_HALF_INTEGRAL_SIGN, LOWER_HALF_INTEGRAL_SIGN, /* 27 28 */ + SUPERSCRIPT_N, CENTERED_SQUARE, F_WITH_HOOK, /* 29 30 31 */ + + RIGHT_ARROW, LEFT_ARROW, UP_ARROW, DOWN_ARROW, /* 32 !"# */ + + PI, NOT_EQUALS_SIGN, VULGAR_HALF, VULGAR_QUARTER, /* $%&' */ + '(', + LEFT_ANGLE_QUOTE_MARK, RIGHT_ANGLE_QUOTE_MARK, /* )* */ + DARK_SHADE, SUPERSCRIPT_2, INFINITY_SIGN, /* +,- */ + ALPHA, BETA, GAMMA, UPPERCASE_SIGMA, LOWERCASE_SIGMA, /* ./012 */ + '3', + MU, TAU, UPPERCASE_PHI, THETA, OMEGA, DELTA, EPSILON, /* 456789: */ + + BOX_SD_LRCORNER, BOX_SD_URCORNER, BOX_SD_ULCORNER, /* ;<= */ + BOX_SD_LLCORNER, BOX_SD_PLUS, /* >? */ + BOX_SD_LTEE, BOX_SD_RTEE, BOX_SD_BTEE, BOX_SD_TTEE, /* @ABC */ + + BOX_D_LRCORNER, BOX_D_URCORNER, BOX_D_ULCORNER, /* DEF */ + BOX_D_LLCORNER, BOX_D_PLUS, /* GH */ + BOX_D_LTEE, BOX_D_RTEE, BOX_D_BTEE, BOX_D_TTEE, /* IJKL */ + + BOX_DS_LRCORNER, BOX_DS_URCORNER, BOX_DS_ULCORNER, /* MNO */ + BOX_DS_LLCORNER, BOX_DS_PLUS, /* PQ */ + BOX_DS_LTEE, BOX_DS_RTEE, BOX_DS_BTEE, BOX_DS_TTEE, /* RSTU */ + + BOX_LRCORNER, BOX_URCORNER, BOX_ULCORNER, /* VWX */ + BOX_LLCORNER, BOX_PLUS, /* YZ */ + BOX_LTEE, BOX_RTEE, BOX_BTEE, BOX_TTEE, /* [\]^ */ + + BOX_HLINE, BOX_VLINE, BOX_D_HLINE, BOX_D_VLINE, /* _`ab */ + + DIVISION_SIGN, APPROXIMATELY_EQUALS_SIGN, /* cd */ + INTERSECTION, TRIPLE_BAR, /* ef */ + SMALL_BULLET, LARGE_BULLET, SQUARE_ROOT, /* ghi */ + DIAMOND, MEDIUM_SHADE, /* jk */ + HORIZ_SCAN_LINE_1, HORIZ_SCAN_LINE_3, /* lm */ + HORIZ_SCAN_LINE_7, HORIZ_SCAN_LINE_9, /* no */ + UPPER_HALF_BLOCK, LOWER_HALF_BLOCK, /* pq */ + LEFT_HALF_BLOCK, RIGHT_HALF_BLOCK, FULL_BLOCK, /* rst */ + LESSER_THAN_OR_EQUAL_TO, GREATER_THAN_OR_EQUAL_TO, /* uv */ + DEGREE_SIGN, PLUS_OR_MINUS, LIGHT_SHADE, SPLAT, /* wxyz */ + CENT_SIGN, YEN_SIGN, PESETA_SIGN, STERLING_SIGN, /* {|}~ */ + A(127) +}; + +# undef A diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h new file mode 100644 index 000000000..9ee3f08a6 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h @@ -0,0 +1,1846 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES__ +#define __PDCURSES__ 1 + +/*man-start************************************************************** + +PDCurses definitions list: (Only define those needed) + + XCURSES True if compiling for X11. + PDC_RGB True if you want to use RGB color definitions + (Red = 1, Green = 2, Blue = 4) instead of BGR. + PDC_WIDE True if building wide-character support. + PDC_DLL_BUILD True if building a Windows DLL. + PDC_NCMOUSE Use the ncurses mouse API instead + of PDCurses' traditional mouse API. + +PDCurses portable platform definitions list: + + PDC_BUILD Defines API build version. + PDCURSES Enables access to PDCurses-only routines. + XOPEN Always true. + SYSVcurses True if you are compiling for SYSV portability. + BSDcurses True if you are compiling for BSD portability. + +**man-end****************************************************************/ + +#define PDCURSES 1 /* PDCurses-only routines */ +#define XOPEN 1 /* X/Open Curses routines */ +#define SYSVcurses 1 /* System V Curses routines */ +#define BSDcurses 1 /* BSD Curses routines */ +#if defined( CHTYPE_32) + #define CHTYPE_LONG 1 /* chtypes will be 32 bits */ +#elif !defined( CHTYPE_16) + #define CHTYPE_LONG 2 /* chtypes will be (default) 64 bits */ +#endif + +/*----------------------------------------------------------------------*/ + +#ifdef NO_STDINT_H + #define uint64_t unsigned long long + #define uint32_t unsigned long + #define uint16_t unsigned short +#else + #include +#endif +#include +#include +#include /* Required by X/Open usage below */ + +#ifdef PDC_WIDE +# include +#endif + +#if defined(__STDC_VERSION__) && __STDC_VERSION >= 199901L && \ + !defined(__bool_true_false_are_defined) +# include +#endif + +#ifdef __cplusplus +extern "C" +{ +# define bool _bool +#endif + +/*---------------------------------------------------------------------- + * + * Constants and Types + * + */ + +#undef FALSE +#undef TRUE + +#ifdef __bool_true_false_are_defined + +# define FALSE false +# define TRUE true + +#else + +typedef unsigned char bool; + +# define FALSE 0 +# define TRUE 1 + +#endif + +#undef ERR +#define ERR (-1) + +#undef OK +#define OK 0 + +#ifdef CHTYPE_LONG + #if(CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes */ + typedef uint64_t chtype; + #else /* "Standard" CHTYPE_LONG case, 32-bit: */ + typedef uint32_t chtype; + # endif +#else +typedef uint16_t chtype; /* 8-bit attr + 8-bit char */ +#endif + +#ifdef PDC_WIDE +typedef chtype cchar_t; +#endif + +typedef chtype attr_t; + +/* Version constants, available as of version 4.0 : */ +/* Don't forget to update 'version.mif' if MAJOR/MINOR changes! */ + +#define PDC_VER_MAJOR 4 +#define PDC_VER_MINOR 0 +#define PDC_VER_CHANGE 4 +#define PDC_VER_YEAR 2019 +#define PDC_VER_MONTH 1 +#define PDC_VER_DAY 20 + +#define PDC_BUILD (PDC_VER_MAJOR*1000 + PDC_VER_MINOR *100 + PDC_VER_CHANGE) + +/* When using PDCurses as a DLL (Windows) or shared library (BSD or *nix), +it's possible to switch the DLL or shared library. One may therefore want +to inquire of the DLL/shared library the port, version numbers, and +chtype_size used, and make sure they're what one was expecting. The +'PDC_version' structure lets you do just that. */ + +enum PDC_port +{ + PDC_PORT_X11 = 0, + PDC_PORT_WIN32 = 1, + PDC_PORT_WINGUI = 2, + PDC_PORT_DOS = 3, + PDC_PORT_OS2 = 4, + PDC_PORT_SDL1 = 5, + PDC_PORT_SDL2 = 6, + PDC_PORT_VT = 7 +}; + +/* Detailed PDC version information */ +#define PDC_HAS_VERSION_INFO 1 +typedef struct +{ + const enum PDC_port port; + const int ver_major; + const int ver_minor; + const int ver_change; + const size_t chtype_size; + const bool is_wide; + const bool is_forced_utf8; +} PDC_version_info; + +/*---------------------------------------------------------------------- + * + * Mouse Interface -- SYSVR4, with extensions + * + */ + +/* Most flavors of PDCurses support three buttons. WinGUI supports */ +/* these plus two "extended" buttons. But we'll set this macro to */ +/* six, allowing future versions to support up to nine total buttons. */ +/* (The button states are broken up into two arrays to allow for the */ +/* possibility of backward compatibility to DLLs compiled with only */ +/* three mouse buttons.) */ + +#define PDC_MAX_MOUSE_BUTTONS 9 +#define PDC_N_EXTENDED_MOUSE_BUTTONS 6 + +typedef struct +{ + int x; /* absolute column, 0 based, measured in characters */ + int y; /* absolute row, 0 based, measured in characters */ + short button[3]; /* state of three "normal" buttons */ + int changes; /* flags indicating what has changed with the mouse */ + short xbutton[PDC_N_EXTENDED_MOUSE_BUTTONS]; /* state of ext buttons */ +} MOUSE_STATUS; + +#define BUTTON_RELEASED 0x0000 +#define BUTTON_PRESSED 0x0001 +#define BUTTON_CLICKED 0x0002 +#define BUTTON_DOUBLE_CLICKED 0x0003 +#define BUTTON_TRIPLE_CLICKED 0x0004 +#define BUTTON_MOVED 0x0005 /* PDCurses */ +#define WHEEL_SCROLLED 0x0006 /* PDCurses */ +#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */ + +#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */ +#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */ +#define PDC_BUTTON_ALT 0x0020 /* PDCurses */ +#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */ + +#define MOUSE_X_POS (Mouse_status.x) +#define MOUSE_Y_POS (Mouse_status.y) + +/* + * Bits associated with the .changes field: + * 3 2 1 0 + * 210987654321098765432109876543210 + * 1 <- button 1 has changed 0 + * 10 <- button 2 has changed 1 + * 100 <- button 3 has changed 2 + * 1000 <- mouse has moved 3 + * 10000 <- mouse position report 4 + * 100000 <- mouse wheel up 5 + * 1000000 <- mouse wheel down 6 + * 10000000 <- mouse wheel left 7 + * 100000000 <- mouse wheel right 8 + * 1000000000 <- button 4 has changed 9 + * (NOTE: buttons 6 to 10000000000 <- button 5 has changed 10 + * 9 aren't implemented 100000000000 <- button 6 has changed 11 + * in any flavor of 1000000000000 <- button 7 has changed 12 + * PDCurses yet!) 10000000000000 <- button 8 has changed 13 + * 100000000000000 <- button 9 has changed 14 + */ + +#define PDC_MOUSE_MOVED 0x0008 +#define PDC_MOUSE_POSITION 0x0010 +#define PDC_MOUSE_WHEEL_UP 0x0020 +#define PDC_MOUSE_WHEEL_DOWN 0x0040 +#define PDC_MOUSE_WHEEL_LEFT 0x0080 +#define PDC_MOUSE_WHEEL_RIGHT 0x0100 + +#define A_BUTTON_CHANGED (Mouse_status.changes & 7) +#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED) +#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION) +#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - ((x)<4 ? 1 : -5)))) +#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1]) +#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP) +#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN) +#define MOUSE_WHEEL_LEFT (Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT) +#define MOUSE_WHEEL_RIGHT (Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT) + +/* mouse bit-masks */ + +#define BUTTON1_RELEASED 0x00000001L +#define BUTTON1_PRESSED 0x00000002L +#define BUTTON1_CLICKED 0x00000004L +#define BUTTON1_DOUBLE_CLICKED 0x00000008L +#define BUTTON1_TRIPLE_CLICKED 0x00000010L +#define BUTTON1_MOVED 0x00000010L /* PDCurses */ + +#define BUTTON2_RELEASED 0x00000020L +#define BUTTON2_PRESSED 0x00000040L +#define BUTTON2_CLICKED 0x00000080L +#define BUTTON2_DOUBLE_CLICKED 0x00000100L +#define BUTTON2_TRIPLE_CLICKED 0x00000200L +#define BUTTON2_MOVED 0x00000200L /* PDCurses */ + +#define BUTTON3_RELEASED 0x00000400L +#define BUTTON3_PRESSED 0x00000800L +#define BUTTON3_CLICKED 0x00001000L +#define BUTTON3_DOUBLE_CLICKED 0x00002000L +#define BUTTON3_TRIPLE_CLICKED 0x00004000L +#define BUTTON3_MOVED 0x00004000L /* PDCurses */ + +/* For the ncurses-compatible functions only, BUTTON4_PRESSED and + BUTTON5_PRESSED are returned for mouse scroll wheel up and down; + otherwise PDCurses doesn't support buttons 4 and 5... except + as described above for WinGUI, and perhaps to be extended to + other PDCurses flavors */ + +#define BUTTON4_RELEASED 0x00008000L +#define BUTTON4_PRESSED 0x00010000L +#define BUTTON4_CLICKED 0x00020000L +#define BUTTON4_DOUBLE_CLICKED 0x00040000L +#define BUTTON4_TRIPLE_CLICKED 0x00080000L + +#define BUTTON5_RELEASED 0x00100000L +#define BUTTON5_PRESSED 0x00200000L +#define BUTTON5_CLICKED 0x00400000L +#define BUTTON5_DOUBLE_CLICKED 0x00800000L +#define BUTTON5_TRIPLE_CLICKED 0x01000000L + +#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */ +#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */ +#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */ +#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */ + +#define ALL_MOUSE_EVENTS 0x1fffffffL +#define REPORT_MOUSE_POSITION 0x20000000L + +/* ncurses mouse interface */ + +typedef unsigned long mmask_t; + +typedef struct +{ + short id; /* unused, always 0 */ + int x, y, z; /* x, y same as MOUSE_STATUS; z unused */ + mmask_t bstate; /* equivalent to changes + button[], but + in the same format as used for mousemask() */ +} MEVENT; + +#if defined(PDC_NCMOUSE) && !defined(NCURSES_MOUSE_VERSION) +# define NCURSES_MOUSE_VERSION 2 +#endif + +#ifdef NCURSES_MOUSE_VERSION +# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT +# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL +# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL +# define BUTTON_ALT BUTTON_MODIFIER_ALT +#else +# define BUTTON_SHIFT PDC_BUTTON_SHIFT +# define BUTTON_CONTROL PDC_BUTTON_CONTROL +# define BUTTON_ALT PDC_BUTTON_ALT +#endif + +/*---------------------------------------------------------------------- + * + * Window and Screen Structures + * + */ + +typedef struct _win /* definition of a window */ +{ + int _cury; /* current pseudo-cursor */ + int _curx; + int _maxy; /* max window coordinates */ + int _maxx; + int _begy; /* origin on screen */ + int _begx; + int _flags; /* window properties */ + chtype _attrs; /* standard attributes and colors */ + chtype _bkgd; /* background, normally blank */ + bool _clear; /* causes clear at next refresh */ + bool _leaveit; /* leaves cursor where it is */ + bool _scroll; /* allows window scrolling */ + bool _nodelay; /* input character wait flag */ + bool _immed; /* immediate update flag */ + bool _sync; /* synchronise window ancestors */ + bool _use_keypad; /* flags keypad key mode active */ + chtype **_y; /* pointer to line pointer array */ + int *_firstch; /* first changed character in line */ + int *_lastch; /* last changed character in line */ + int _tmarg; /* top of scrolling region */ + int _bmarg; /* bottom of scrolling region */ + int _delayms; /* milliseconds of delay for getch() */ + int _parx, _pary; /* coords relative to parent (0,0) */ + struct _win *_parent; /* subwin's pointer to parent win */ +} WINDOW; + +/* Avoid using the SCREEN struct directly -- use the corresponding + functions if possible. This struct may eventually be made private. */ + +typedef struct +{ + bool alive; /* if initscr() called, and not endwin() */ + bool autocr; /* if cr -> lf */ + bool cbreak; /* if terminal unbuffered */ + bool echo; /* if terminal echo */ + bool raw_inp; /* raw input mode (v. cooked input) */ + bool raw_out; /* raw output mode (7 v. 8 bits) */ + bool audible; /* FALSE if the bell is visual */ + bool mono; /* TRUE if current screen is mono */ + bool resized; /* TRUE if TERM has been resized */ + bool orig_attr; /* TRUE if we have the original colors */ + short orig_fore; /* original screen foreground color */ + short orig_back; /* original screen foreground color */ + int cursrow; /* position of physical cursor */ + int curscol; /* position of physical cursor */ + int visibility; /* visibility of cursor */ + int orig_cursor; /* original cursor size */ + int lines; /* new value for LINES */ + int cols; /* new value for COLS */ + unsigned long _trap_mbe; /* trap these mouse button events */ + unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ + int mouse_wait; /* time to wait (in ms) for a + button release after a press, in + order to count it as a click */ + int slklines; /* lines in use by slk_init() */ + WINDOW *slk_winptr; /* window for slk */ + int linesrippedoff; /* lines ripped off via ripoffline() */ + int linesrippedoffontop; /* lines ripped off on + top via ripoffline() */ + int delaytenths; /* 1/10ths second to wait block + getch() for */ + bool _preserve; /* TRUE if screen background + to be preserved */ + int _restore; /* specifies if screen background + to be restored, and how */ + bool save_key_modifiers; /* TRUE if each key modifiers saved + with each key press */ + bool return_key_modifiers; /* TRUE if modifier keys are + returned as "real" keys */ + bool key_code; /* TRUE if last key is a special key; + used internally by get_wch() */ +#ifdef XCURSES + int XcurscrSize; /* size of Xcurscr shared memory block */ + bool sb_on; + int sb_viewport_y; + int sb_viewport_x; + int sb_total_y; + int sb_total_x; + int sb_cur_y; + int sb_cur_x; + int exit_key; +#endif + short line_color; /* color of line attributes - default -1 */ +} SCREEN; + +/*---------------------------------------------------------------------- + * + * External Variables + * + */ + +#ifdef PDC_DLL_BUILD +# ifdef CURSES_LIBRARY +# define PDCEX __declspec(dllexport) extern +# else +# define PDCEX __declspec(dllimport) +# endif +#else +# define PDCEX extern +#endif + +PDCEX int LINES; /* terminal height */ +PDCEX int COLS; /* terminal width */ +PDCEX WINDOW *stdscr; /* the default screen window */ +PDCEX WINDOW *curscr; /* the current screen image */ +PDCEX SCREEN *SP; /* curses variables */ +PDCEX MOUSE_STATUS Mouse_status; +PDCEX int COLORS; +PDCEX int COLOR_PAIRS; +PDCEX int TABSIZE; +PDCEX chtype acs_map[]; /* alternate character set map */ +PDCEX char ttytype[]; /* terminal name/description */ +PDCEX PDC_version_info PDC_version; + +/*man-start************************************************************** + +Text Attributes +=============== + +Originally, PDCurses used a short (16 bits) for its chtype. To include +color, a number of things had to be sacrificed from the strict Unix and +System V support. The main problem was fitting all character attributes +and color into an unsigned char (all 8 bits!). + +Today, PDCurses by default uses a long (32 bits) for its chtype, as in +System V. The short chtype is still available, by undefining CHTYPE_LONG +and rebuilding the library. + +The following is the structure of a win->_attrs chtype: + +short form: + + +-----------------------------------------------+ + |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| + +-----------------------------------------------+ + color number | attrs | character eg 'a' + +The available non-color attributes are bold, reverse and blink. Others +have no effect. The high order char is an index into an array of +physical colors (defined in color.c) -- 32 foreground/background color +pairs (5 bits) plus 3 bits for other attributes. + +long form: + + +--------------------------------------------------------------------+ + |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0| + +--------------------------------------------------------------------+ + color number | modifiers | character eg 'a' + +The available non-color attributes are bold, underline, invisible, +right-line, left-line, protect, reverse and blink. 256 color pairs (8 +bits), 8 bits for other attributes, and 16 bits for character data. + + Note that there is now a "super-long" 64-bit form, available by +defining CHTYPE_LONG to be 2: + +------------------------------------------------------------------------------- +|63|62|61|60|59|..|34|33|32|31|30|29|28|..|22|21|20|19|18|17|16|..| 3| 2| 1| 0| +------------------------------------------------------------------------------- + color number | modifiers | character eg 'a' + + + We take five more bits for the character (thus allowing Unicode values +past 64K; UTF-16 can go up to 0x10ffff, requiring 21 bits total), and +four more bits for attributes. Three are currently used as A_OVERLINE, A_DIM, +and A_STRIKEOUT; one more is reserved for future use. 31 bits are then used +for color. These are usually just treated as the usual palette +indices, and range from 0 to 255. However, if bit 63 is +set, the remaining 30 bits are interpreted as foreground RGB (first +fifteen bits, five bits for each of the three channels) and background RGB +(same scheme using the remaining 15 bits.) + +**man-end****************************************************************/ + +/*** Video attribute macros ***/ + +#define A_NORMAL (chtype)0 + +#ifdef CHTYPE_LONG + +# if(CHTYPE_LONG >= 2) /* 64-bit chtypes */ + # define PDC_CHARTEXT_BITS 21 + # define A_CHARTEXT (chtype)( ((chtype)0x1 << PDC_CHARTEXT_BITS) - 1) + # define A_ALTCHARSET ((chtype)0x001 << PDC_CHARTEXT_BITS) + # define A_RIGHTLINE ((chtype)0x002 << PDC_CHARTEXT_BITS) + # define A_LEFTLINE ((chtype)0x004 << PDC_CHARTEXT_BITS) + # define A_INVIS ((chtype)0x008 << PDC_CHARTEXT_BITS) + # define A_UNDERLINE ((chtype)0x010 << PDC_CHARTEXT_BITS) + # define A_REVERSE ((chtype)0x020 << PDC_CHARTEXT_BITS) + # define A_BLINK ((chtype)0x040 << PDC_CHARTEXT_BITS) + # define A_BOLD ((chtype)0x080 << PDC_CHARTEXT_BITS) + # define A_OVERLINE ((chtype)0x100 << PDC_CHARTEXT_BITS) + # define A_STRIKEOUT ((chtype)0x200 << PDC_CHARTEXT_BITS) + # define A_DIM ((chtype)0x400 << PDC_CHARTEXT_BITS) +#if 0 + /* May come up with a use for this bit */ + /* someday; reserved for the future: */ + # define A_FUTURE_2 ((chtype)0x800 << PDC_CHARTEXT_BITS) +#endif + # define PDC_COLOR_SHIFT (PDC_CHARTEXT_BITS + 12) + # define A_COLOR ((chtype)0x7fffffff << PDC_COLOR_SHIFT) + # define A_RGB_COLOR ((chtype)0x40000000 << PDC_COLOR_SHIFT) + # define A_ATTRIBUTES (((chtype)0xfff << PDC_CHARTEXT_BITS) | A_COLOR) + # define A_RGB( rfore, gfore, bfore, rback, gback, bback) \ + (( (((chtype)(bfore) << 25) \ + | ((chtype)(gfore) << 20) \ + | ((chtype)(rfore) << 15) \ + | ((chtype)(bback) << 10) \ + | ((chtype)(gback) << 5) \ + | ((chtype)(rback) )) << PDC_COLOR_SHIFT) | A_RGB_COLOR) +# else /* plain ol' 32-bit chtypes */ + # define A_ALTCHARSET (chtype)0x00010000 + # define A_RIGHTLINE (chtype)0x00020000 + # define A_LEFTLINE (chtype)0x00040000 + # define A_INVIS (chtype)0x00080000 + # define A_UNDERLINE (chtype)0x00100000 + # define A_REVERSE (chtype)0x00200000 + # define A_BLINK (chtype)0x00400000 + # define A_BOLD (chtype)0x00800000 + # define A_COLOR (chtype)0xff000000 + # define A_RGB_COLOR A_NORMAL +#ifdef PDC_WIDE + # define A_CHARTEXT (chtype)0x0000ffff + # define A_ATTRIBUTES (chtype)0xffff0000 + # define A_DIM A_NORMAL + # define A_OVERLINE A_NORMAL + # define A_STRIKEOUT A_NORMAL +#else /* with 8-bit chars, we have bits for these attribs : */ + # define A_CHARTEXT (chtype)0x000000ff + # define A_ATTRIBUTES (chtype)0xffffe000 + # define A_DIM (chtype)0x00008000 + # define A_OVERLINE (chtype)0x00004000 + # define A_STRIKEOUT (chtype)0x00002000 +#endif + # define PDC_COLOR_SHIFT 24 +#endif + + +# define A_ITALIC A_INVIS +# define A_PROTECT (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE) + +#else /* 16-bit chtypes */ +# define A_BOLD (chtype)0x0100 /* X/Open */ +# define A_REVERSE (chtype)0x0200 /* X/Open */ +# define A_BLINK (chtype)0x0400 /* X/Open */ + +# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */ +# define A_CHARTEXT (chtype)0x00ff /* X/Open */ +# define A_COLOR (chtype)0xf800 /* System V */ + +# define A_ALTCHARSET A_NORMAL /* X/Open */ +# define A_PROTECT A_NORMAL /* X/Open */ +# define A_UNDERLINE A_NORMAL /* X/Open */ +# define A_OVERLINE A_NORMAL /* X/Open */ +# define A_STRIKEOUT A_NORMAL /* X/Open */ + +# define A_LEFTLINE A_NORMAL +# define A_RIGHTLINE A_NORMAL +# define A_ITALIC A_NORMAL +# define A_INVIS A_NORMAL +# define A_RGB_COLOR A_NORMAL +# define A_DIM A_NORMAL + +# define PDC_COLOR_SHIFT 11 +#endif + +#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */ + +#define CHR_MSK A_CHARTEXT /* Obsolete */ +#define ATR_MSK A_ATTRIBUTES /* Obsolete */ +#define ATR_NRM A_NORMAL /* Obsolete */ + +/* For use with attr_t -- X/Open says, "these shall be distinct", so + this is a non-conforming implementation. */ + +#define WA_NORMAL A_NORMAL + +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_BLINK A_BLINK +#define WA_BOLD A_BOLD +#define WA_DIM A_DIM +#define WA_INVIS A_INVIS +#define WA_LEFT A_LEFTLINE +#define WA_PROTECT A_PROTECT +#define WA_REVERSE A_REVERSE +#define WA_RIGHT A_RIGHTLINE +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE + +#define WA_HORIZONTAL A_NORMAL +#define WA_LOW A_NORMAL +#define WA_TOP A_NORMAL +#define WA_VERTICAL A_NORMAL + +#define WA_ATTRIBUTES A_ATTRIBUTES + +/*** Alternate character set macros ***/ + +/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET + 'n' = 16-bit chtype; it gets the fallback set because no bit is + available for A_ALTCHARSET */ + +#ifdef CHTYPE_LONG +# define PDC_ACS(w, n) ((chtype)w | A_ALTCHARSET) +#else +# define PDC_ACS(w, n) ((chtype)n) +#endif + +/* VT100-compatible symbols -- box chars */ + +#define ACS_LRCORNER PDC_ACS('V', '+') +#define ACS_URCORNER PDC_ACS('W', '+') +#define ACS_ULCORNER PDC_ACS('X', '+') +#define ACS_LLCORNER PDC_ACS('Y', '+') +#define ACS_PLUS PDC_ACS('Z', '+') +#define ACS_LTEE PDC_ACS('[', '+') +#define ACS_RTEE PDC_ACS('\\', '+') +#define ACS_BTEE PDC_ACS(']', '+') +#define ACS_TTEE PDC_ACS('^', '+') +#define ACS_HLINE PDC_ACS('_', '-') +#define ACS_VLINE PDC_ACS('`', '|') + +/* PDCurses-only ACS chars. Don't use if ncurses compatibility matters. +Some won't work in non-wide X11 builds (see 'acs_defs.h' for details). */ + +#define ACS_CENT PDC_ACS('{', 'c') +#define ACS_YEN PDC_ACS('|', 'y') +#define ACS_PESETA PDC_ACS('}', 'p') +#define ACS_HALF PDC_ACS('&', '/') +#define ACS_QUARTER PDC_ACS('\'', '/') +#define ACS_LEFT_ANG_QU PDC_ACS(')', '<') +#define ACS_RIGHT_ANG_QU PDC_ACS('*', '>') +#define ACS_D_HLINE PDC_ACS('a', '-') +#define ACS_D_VLINE PDC_ACS('b', '|') +#define ACS_CLUB PDC_ACS( 11, 'C') +#define ACS_HEART PDC_ACS( 12, 'H') +#define ACS_SPADE PDC_ACS( 13, 'S') +#define ACS_SMILE PDC_ACS( 14, 'O') +#define ACS_REV_SMILE PDC_ACS( 15, 'O') +#define ACS_MED_BULLET PDC_ACS( 16, '.') +#define ACS_WHITE_BULLET PDC_ACS( 17, 'O') +#define ACS_PILCROW PDC_ACS( 18, 'O') +#define ACS_SECTION PDC_ACS( 19, 'O') + +#define ACS_SUP2 PDC_ACS(',', '2') +#define ACS_ALPHA PDC_ACS('.', 'a') +#define ACS_BETA PDC_ACS('/', 'b') +#define ACS_GAMMA PDC_ACS('0', 'y') +#define ACS_UP_SIGMA PDC_ACS('1', 'S') +#define ACS_LO_SIGMA PDC_ACS('2', 's') +#define ACS_MU PDC_ACS('4', 'u') +#define ACS_TAU PDC_ACS('5', 't') +#define ACS_UP_PHI PDC_ACS('6', 'F') +#define ACS_THETA PDC_ACS('7', 't') +#define ACS_OMEGA PDC_ACS('8', 'w') +#define ACS_DELTA PDC_ACS('9', 'd') +#define ACS_INFINITY PDC_ACS('-', 'i') +#define ACS_LO_PHI PDC_ACS( 22, 'f') +#define ACS_EPSILON PDC_ACS(':', 'e') +#define ACS_INTERSECT PDC_ACS('e', 'u') +#define ACS_TRIPLE_BAR PDC_ACS('f', '=') +#define ACS_DIVISION PDC_ACS('c', '/') +#define ACS_APPROX_EQ PDC_ACS('d', '~') +#define ACS_SM_BULLET PDC_ACS('g', '.') +#define ACS_SQUARE_ROOT PDC_ACS('i', '!') +#define ACS_UBLOCK PDC_ACS('p', '^') +#define ACS_BBLOCK PDC_ACS('q', '_') +#define ACS_LBLOCK PDC_ACS('r', '<') +#define ACS_RBLOCK PDC_ACS('s', '>') + +#define ACS_A_ORDINAL PDC_ACS(20, 'a') +#define ACS_O_ORDINAL PDC_ACS(21, 'o') +#define ACS_INV_QUERY PDC_ACS(24, '?') +#define ACS_REV_NOT PDC_ACS(25, '!') +#define ACS_NOT PDC_ACS(26, '!') +#define ACS_INV_BANG PDC_ACS(23, '!') +#define ACS_UP_INTEGRAL PDC_ACS(27, '|') +#define ACS_LO_INTEGRAL PDC_ACS(28, '|') +#define ACS_SUP_N PDC_ACS(29, 'n') +#define ACS_CENTER_SQU PDC_ACS(30, 'x') +#define ACS_F_WITH_HOOK PDC_ACS(31, 'f') + +#define ACS_SD_LRCORNER PDC_ACS(';', '+') +#define ACS_SD_URCORNER PDC_ACS('<', '+') +#define ACS_SD_ULCORNER PDC_ACS('=', '+') +#define ACS_SD_LLCORNER PDC_ACS('>', '+') +#define ACS_SD_PLUS PDC_ACS('?', '+') +#define ACS_SD_LTEE PDC_ACS('@', '+') +#define ACS_SD_RTEE PDC_ACS('A', '+') +#define ACS_SD_BTEE PDC_ACS('B', '+') +#define ACS_SD_TTEE PDC_ACS('C', '+') + +#define ACS_D_LRCORNER PDC_ACS('D', '+') +#define ACS_D_URCORNER PDC_ACS('E', '+') +#define ACS_D_ULCORNER PDC_ACS('F', '+') +#define ACS_D_LLCORNER PDC_ACS('G', '+') +#define ACS_D_PLUS PDC_ACS('H', '+') +#define ACS_D_LTEE PDC_ACS('I', '+') +#define ACS_D_RTEE PDC_ACS('J', '+') +#define ACS_D_BTEE PDC_ACS('K', '+') +#define ACS_D_TTEE PDC_ACS('L', '+') + +#define ACS_DS_LRCORNER PDC_ACS('M', '+') +#define ACS_DS_URCORNER PDC_ACS('N', '+') +#define ACS_DS_ULCORNER PDC_ACS('O', '+') +#define ACS_DS_LLCORNER PDC_ACS('P', '+') +#define ACS_DS_PLUS PDC_ACS('Q', '+') +#define ACS_DS_LTEE PDC_ACS('R', '+') +#define ACS_DS_RTEE PDC_ACS('S', '+') +#define ACS_DS_BTEE PDC_ACS('T', '+') +#define ACS_DS_TTEE PDC_ACS('U', '+') + +/* VT100-compatible symbols -- other */ + +#define ACS_S1 PDC_ACS('l', '-') +#define ACS_S9 PDC_ACS('o', '_') +#define ACS_DIAMOND PDC_ACS('j', '+') +#define ACS_CKBOARD PDC_ACS('k', ':') +#define ACS_DEGREE PDC_ACS('w', '\'') +#define ACS_PLMINUS PDC_ACS('x', '#') +#define ACS_BULLET PDC_ACS('h', 'o') + +/* Teletype 5410v1 symbols -- these are defined in SysV curses, but + are not well-supported by most terminals. Stick to VT100 characters + for optimum portability. */ + +#define ACS_LARROW PDC_ACS('!', '<') +#define ACS_RARROW PDC_ACS(' ', '>') +#define ACS_DARROW PDC_ACS('#', 'v') +#define ACS_UARROW PDC_ACS('"', '^') +#define ACS_BOARD PDC_ACS('+', '#') +#define ACS_LTBOARD PDC_ACS('y', '#') +#define ACS_LANTERN PDC_ACS('z', '*') +#define ACS_BLOCK PDC_ACS('t', '#') + +/* That goes double for these -- undocumented SysV symbols. Don't use + them. */ + +#define ACS_S3 PDC_ACS('m', '-') +#define ACS_S7 PDC_ACS('n', '-') +#define ACS_LEQUAL PDC_ACS('u', '<') +#define ACS_GEQUAL PDC_ACS('v', '>') +#define ACS_PI PDC_ACS('$', 'n') +#define ACS_NEQUAL PDC_ACS('%', '+') +#define ACS_STERLING PDC_ACS('~', 'L') + +/* Box char aliases */ + +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +/* cchar_t aliases */ + +#ifdef PDC_WIDE +# define WACS_LRCORNER (&(acs_map['V'])) +# define WACS_URCORNER (&(acs_map['W'])) +# define WACS_ULCORNER (&(acs_map['X'])) +# define WACS_LLCORNER (&(acs_map['Y'])) +# define WACS_PLUS (&(acs_map['Z'])) +# define WACS_LTEE (&(acs_map['['])) +# define WACS_RTEE (&(acs_map['\\'])) +# define WACS_BTEE (&(acs_map[']'])) +# define WACS_TTEE (&(acs_map['^'])) +# define WACS_HLINE (&(acs_map['_'])) +# define WACS_VLINE (&(acs_map['`'])) + +# define WACS_CENT (&(acs_map['{'])) +# define WACS_YEN (&(acs_map['|'])) +# define WACS_PESETA (&(acs_map['}'])) +# define WACS_HALF (&(acs_map['&'])) +# define WACS_QUARTER (&(acs_map['\''])) +# define WACS_LEFT_ANG_QU (&(acs_map[')'])) +# define WACS_RIGHT_ANG_QU (&(acs_map['*'])) +# define WACS_D_HLINE (&(acs_map['a'])) +# define WACS_D_VLINE (&(acs_map['b'])) +# define WACS_CLUB (&(acs_map[ 11])) +# define WACS_HEART (&(acs_map[ 12])) +# define WACS_SPADE (&(acs_map[ 13])) +# define WACS_SMILE (&(acs_map[ 14])) +# define WACS_REV_SMILE (&(acs_map[ 15])) +# define WACS_MED_BULLET (&(acs_map[ 16])) +# define WACS_WHITE_BULLET (&(acs_map[ 17])) +# define WACS_PILCROW (&(acs_map[ 18])) +# define WACS_SECTION (&(acs_map[ 19])) + +# define WACS_SUP2 (&(acs_map[','])) +# define WACS_ALPHA (&(acs_map['.'])) +# define WACS_BETA (&(acs_map['/'])) +# define WACS_GAMMA (&(acs_map['0'])) +# define WACS_UP_SIGMA (&(acs_map['1'])) +# define WACS_LO_SIGMA (&(acs_map['2'])) +# define WACS_MU (&(acs_map['4'])) +# define WACS_TAU (&(acs_map['5'])) +# define WACS_UP_PHI (&(acs_map['6'])) +# define WACS_THETA (&(acs_map['7'])) +# define WACS_OMEGA (&(acs_map['8'])) +# define WACS_DELTA (&(acs_map['9'])) +# define WACS_INFINITY (&(acs_map['-'])) +# define WACS_LO_PHI (&(acs_map[ 22])) +# define WACS_EPSILON (&(acs_map[':'])) +# define WACS_INTERSECT (&(acs_map['e'])) +# define WACS_TRIPLE_BAR (&(acs_map['f'])) +# define WACS_DIVISION (&(acs_map['c'])) +# define WACS_APPROX_EQ (&(acs_map['d'])) +# define WACS_SM_BULLET (&(acs_map['g'])) +# define WACS_SQUARE_ROOT (&(acs_map['i'])) +# define WACS_UBLOCK (&(acs_map['p'])) +# define WACS_BBLOCK (&(acs_map['q'])) +# define WACS_LBLOCK (&(acs_map['r'])) +# define WACS_RBLOCK (&(acs_map['s'])) + +# define WACS_A_ORDINAL (&(acs_map[20])) +# define WACS_O_ORDINAL (&(acs_map[21])) +# define WACS_INV_QUERY (&(acs_map[24])) +# define WACS_REV_NOT (&(acs_map[25])) +# define WACS_NOT (&(acs_map[26])) +# define WACS_INV_BANG (&(acs_map[23])) +# define WACS_UP_INTEGRAL (&(acs_map[27])) +# define WACS_LO_INTEGRAL (&(acs_map[28])) +# define WACS_SUP_N (&(acs_map[29])) +# define WACS_CENTER_SQU (&(acs_map[30])) +# define WACS_F_WITH_HOOK (&(acs_map[31])) + +# define WACS_SD_LRCORNER (&(acs_map[';'])) +# define WACS_SD_URCORNER (&(acs_map['<'])) +# define WACS_SD_ULCORNER (&(acs_map['='])) +# define WACS_SD_LLCORNER (&(acs_map['>'])) +# define WACS_SD_PLUS (&(acs_map['?'])) +# define WACS_SD_LTEE (&(acs_map['@'])) +# define WACS_SD_RTEE (&(acs_map['A'])) +# define WACS_SD_BTEE (&(acs_map['B'])) +# define WACS_SD_TTEE (&(acs_map['C'])) + +# define WACS_D_LRCORNER (&(acs_map['D'])) +# define WACS_D_URCORNER (&(acs_map['E'])) +# define WACS_D_ULCORNER (&(acs_map['F'])) +# define WACS_D_LLCORNER (&(acs_map['G'])) +# define WACS_D_PLUS (&(acs_map['H'])) +# define WACS_D_LTEE (&(acs_map['I'])) +# define WACS_D_RTEE (&(acs_map['J'])) +# define WACS_D_BTEE (&(acs_map['K'])) +# define WACS_D_TTEE (&(acs_map['L'])) + +# define WACS_DS_LRCORNER (&(acs_map['M'])) +# define WACS_DS_URCORNER (&(acs_map['N'])) +# define WACS_DS_ULCORNER (&(acs_map['O'])) +# define WACS_DS_LLCORNER (&(acs_map['P'])) +# define WACS_DS_PLUS (&(acs_map['Q'])) +# define WACS_DS_LTEE (&(acs_map['R'])) +# define WACS_DS_RTEE (&(acs_map['S'])) +# define WACS_DS_BTEE (&(acs_map['T'])) +# define WACS_DS_TTEE (&(acs_map['U'])) + +# define WACS_S1 (&(acs_map['l'])) +# define WACS_S9 (&(acs_map['o'])) +# define WACS_DIAMOND (&(acs_map['j'])) +# define WACS_CKBOARD (&(acs_map['k'])) +# define WACS_DEGREE (&(acs_map['w'])) +# define WACS_PLMINUS (&(acs_map['x'])) +# define WACS_BULLET (&(acs_map['h'])) + + +# define WACS_LARROW (&(acs_map['!'])) +# define WACS_RARROW (&(acs_map[' '])) +# define WACS_DARROW (&(acs_map['#'])) +# define WACS_UARROW (&(acs_map['"'])) +# define WACS_BOARD (&(acs_map['+'])) +# define WACS_LTBOARD (&(acs_map['y'])) +# define WACS_LANTERN (&(acs_map['z'])) +# define WACS_BLOCK (&(acs_map['t'])) + +# define WACS_S3 (&(acs_map['m'])) +# define WACS_S7 (&(acs_map['n'])) +# define WACS_LEQUAL (&(acs_map['u'])) +# define WACS_GEQUAL (&(acs_map['v'])) +# define WACS_PI (&(acs_map['$'])) +# define WACS_NEQUAL (&(acs_map['%'])) +# define WACS_STERLING (&(acs_map['~'])) + +# define WACS_BSSB WACS_ULCORNER +# define WACS_SSBB WACS_LLCORNER +# define WACS_BBSS WACS_URCORNER +# define WACS_SBBS WACS_LRCORNER +# define WACS_SBSS WACS_RTEE +# define WACS_SSSB WACS_LTEE +# define WACS_SSBS WACS_BTEE +# define WACS_BSSS WACS_TTEE +# define WACS_BSBS WACS_HLINE +# define WACS_SBSB WACS_VLINE +# define WACS_SSSS WACS_PLUS +#endif + +/*** Color macros ***/ + +#define COLOR_BLACK 0 + +#ifdef PDC_RGB /* RGB */ +# define COLOR_RED 1 +# define COLOR_GREEN 2 +# define COLOR_BLUE 4 +#else /* BGR */ +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_RED 4 +#endif + +#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) +#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) +#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) + +#define COLOR_WHITE 7 + +/*---------------------------------------------------------------------- + * + * Function and Keypad Key Definitions + * Many are just for compatibility + * + */ + +#ifdef PDC_WIDE + #define KEY_OFFSET 0xec00 +#else + #define KEY_OFFSET 0x100 +#endif + +#define KEY_CODE_YES (KEY_OFFSET + 0x00) /* If get_wch() gives a key code */ + +#define KEY_BREAK (KEY_OFFSET + 0x01) /* Not on PC KBD */ +#define KEY_DOWN (KEY_OFFSET + 0x02) /* Down arrow key */ +#define KEY_UP (KEY_OFFSET + 0x03) /* Up arrow key */ +#define KEY_LEFT (KEY_OFFSET + 0x04) /* Left arrow key */ +#define KEY_RIGHT (KEY_OFFSET + 0x05) /* Right arrow key */ +#define KEY_HOME (KEY_OFFSET + 0x06) /* home key */ +#define KEY_BACKSPACE (KEY_OFFSET + 0x07) /* not on pc */ +#define KEY_F0 (KEY_OFFSET + 0x08) /* function keys; 64 reserved */ + +#define KEY_DL (KEY_OFFSET + 0x48) /* delete line */ +#define KEY_IL (KEY_OFFSET + 0x49) /* insert line */ +#define KEY_DC (KEY_OFFSET + 0x4a) /* delete character */ +#define KEY_IC (KEY_OFFSET + 0x4b) /* insert char or enter ins mode */ +#define KEY_EIC (KEY_OFFSET + 0x4c) /* exit insert char mode */ +#define KEY_CLEAR (KEY_OFFSET + 0x4d) /* clear screen */ +#define KEY_EOS (KEY_OFFSET + 0x4e) /* clear to end of screen */ +#define KEY_EOL (KEY_OFFSET + 0x4f) /* clear to end of line */ +#define KEY_SF (KEY_OFFSET + 0x50) /* scroll 1 line forward */ +#define KEY_SR (KEY_OFFSET + 0x51) /* scroll 1 line back (reverse) */ +#define KEY_NPAGE (KEY_OFFSET + 0x52) /* next page */ +#define KEY_PPAGE (KEY_OFFSET + 0x53) /* previous page */ +#define KEY_STAB (KEY_OFFSET + 0x54) /* set tab */ +#define KEY_CTAB (KEY_OFFSET + 0x55) /* clear tab */ +#define KEY_CATAB (KEY_OFFSET + 0x56) /* clear all tabs */ +#define KEY_ENTER (KEY_OFFSET + 0x57) /* enter or send (unreliable) */ +#define KEY_SRESET (KEY_OFFSET + 0x58) /* soft/reset (partial/unreliable) */ +#define KEY_RESET (KEY_OFFSET + 0x59) /* reset/hard reset (unreliable) */ +#define KEY_PRINT (KEY_OFFSET + 0x5a) /* print/copy */ +#define KEY_LL (KEY_OFFSET + 0x5b) /* home down/bottom (lower left) */ +#define KEY_ABORT (KEY_OFFSET + 0x5c) /* abort/terminate key (any) */ +#define KEY_SHELP (KEY_OFFSET + 0x5d) /* short help */ +#define KEY_LHELP (KEY_OFFSET + 0x5e) /* long help */ +#define KEY_BTAB (KEY_OFFSET + 0x5f) /* Back tab key */ +#define KEY_BEG (KEY_OFFSET + 0x60) /* beg(inning) key */ +#define KEY_CANCEL (KEY_OFFSET + 0x61) /* cancel key */ +#define KEY_CLOSE (KEY_OFFSET + 0x62) /* close key */ +#define KEY_COMMAND (KEY_OFFSET + 0x63) /* cmd (command) key */ +#define KEY_COPY (KEY_OFFSET + 0x64) /* copy key */ +#define KEY_CREATE (KEY_OFFSET + 0x65) /* create key */ +#define KEY_END (KEY_OFFSET + 0x66) /* end key */ +#define KEY_EXIT (KEY_OFFSET + 0x67) /* exit key */ +#define KEY_FIND (KEY_OFFSET + 0x68) /* find key */ +#define KEY_HELP (KEY_OFFSET + 0x69) /* help key */ +#define KEY_MARK (KEY_OFFSET + 0x6a) /* mark key */ +#define KEY_MESSAGE (KEY_OFFSET + 0x6b) /* message key */ +#define KEY_MOVE (KEY_OFFSET + 0x6c) /* move key */ +#define KEY_NEXT (KEY_OFFSET + 0x6d) /* next object key */ +#define KEY_OPEN (KEY_OFFSET + 0x6e) /* open key */ +#define KEY_OPTIONS (KEY_OFFSET + 0x6f) /* options key */ +#define KEY_PREVIOUS (KEY_OFFSET + 0x70) /* previous object key */ +#define KEY_REDO (KEY_OFFSET + 0x71) /* redo key */ +#define KEY_REFERENCE (KEY_OFFSET + 0x72) /* ref(erence) key */ +#define KEY_REFRESH (KEY_OFFSET + 0x73) /* refresh key */ +#define KEY_REPLACE (KEY_OFFSET + 0x74) /* replace key */ +#define KEY_RESTART (KEY_OFFSET + 0x75) /* restart key */ +#define KEY_RESUME (KEY_OFFSET + 0x76) /* resume key */ +#define KEY_SAVE (KEY_OFFSET + 0x77) /* save key */ +#define KEY_SBEG (KEY_OFFSET + 0x78) /* shifted beginning key */ +#define KEY_SCANCEL (KEY_OFFSET + 0x79) /* shifted cancel key */ +#define KEY_SCOMMAND (KEY_OFFSET + 0x7a) /* shifted command key */ +#define KEY_SCOPY (KEY_OFFSET + 0x7b) /* shifted copy key */ +#define KEY_SCREATE (KEY_OFFSET + 0x7c) /* shifted create key */ +#define KEY_SDC (KEY_OFFSET + 0x7d) /* shifted delete char key */ +#define KEY_SDL (KEY_OFFSET + 0x7e) /* shifted delete line key */ +#define KEY_SELECT (KEY_OFFSET + 0x7f) /* select key */ +#define KEY_SEND (KEY_OFFSET + 0x80) /* shifted end key */ +#define KEY_SEOL (KEY_OFFSET + 0x81) /* shifted clear line key */ +#define KEY_SEXIT (KEY_OFFSET + 0x82) /* shifted exit key */ +#define KEY_SFIND (KEY_OFFSET + 0x83) /* shifted find key */ +#define KEY_SHOME (KEY_OFFSET + 0x84) /* shifted home key */ +#define KEY_SIC (KEY_OFFSET + 0x85) /* shifted input key */ + +#define KEY_SLEFT (KEY_OFFSET + 0x87) /* shifted left arrow key */ +#define KEY_SMESSAGE (KEY_OFFSET + 0x88) /* shifted message key */ +#define KEY_SMOVE (KEY_OFFSET + 0x89) /* shifted move key */ +#define KEY_SNEXT (KEY_OFFSET + 0x8a) /* shifted next key */ +#define KEY_SOPTIONS (KEY_OFFSET + 0x8b) /* shifted options key */ +#define KEY_SPREVIOUS (KEY_OFFSET + 0x8c) /* shifted prev key */ +#define KEY_SPRINT (KEY_OFFSET + 0x8d) /* shifted print key */ +#define KEY_SREDO (KEY_OFFSET + 0x8e) /* shifted redo key */ +#define KEY_SREPLACE (KEY_OFFSET + 0x8f) /* shifted replace key */ +#define KEY_SRIGHT (KEY_OFFSET + 0x90) /* shifted right arrow */ +#define KEY_SRSUME (KEY_OFFSET + 0x91) /* shifted resume key */ +#define KEY_SSAVE (KEY_OFFSET + 0x92) /* shifted save key */ +#define KEY_SSUSPEND (KEY_OFFSET + 0x93) /* shifted suspend key */ +#define KEY_SUNDO (KEY_OFFSET + 0x94) /* shifted undo key */ +#define KEY_SUSPEND (KEY_OFFSET + 0x95) /* suspend key */ +#define KEY_UNDO (KEY_OFFSET + 0x96) /* undo key */ + +/* PDCurses-specific key definitions -- PC only */ + +#define ALT_0 (KEY_OFFSET + 0x97) +#define ALT_1 (KEY_OFFSET + 0x98) +#define ALT_2 (KEY_OFFSET + 0x99) +#define ALT_3 (KEY_OFFSET + 0x9a) +#define ALT_4 (KEY_OFFSET + 0x9b) +#define ALT_5 (KEY_OFFSET + 0x9c) +#define ALT_6 (KEY_OFFSET + 0x9d) +#define ALT_7 (KEY_OFFSET + 0x9e) +#define ALT_8 (KEY_OFFSET + 0x9f) +#define ALT_9 (KEY_OFFSET + 0xa0) +#define ALT_A (KEY_OFFSET + 0xa1) +#define ALT_B (KEY_OFFSET + 0xa2) +#define ALT_C (KEY_OFFSET + 0xa3) +#define ALT_D (KEY_OFFSET + 0xa4) +#define ALT_E (KEY_OFFSET + 0xa5) +#define ALT_F (KEY_OFFSET + 0xa6) +#define ALT_G (KEY_OFFSET + 0xa7) +#define ALT_H (KEY_OFFSET + 0xa8) +#define ALT_I (KEY_OFFSET + 0xa9) +#define ALT_J (KEY_OFFSET + 0xaa) +#define ALT_K (KEY_OFFSET + 0xab) +#define ALT_L (KEY_OFFSET + 0xac) +#define ALT_M (KEY_OFFSET + 0xad) +#define ALT_N (KEY_OFFSET + 0xae) +#define ALT_O (KEY_OFFSET + 0xaf) +#define ALT_P (KEY_OFFSET + 0xb0) +#define ALT_Q (KEY_OFFSET + 0xb1) +#define ALT_R (KEY_OFFSET + 0xb2) +#define ALT_S (KEY_OFFSET + 0xb3) +#define ALT_T (KEY_OFFSET + 0xb4) +#define ALT_U (KEY_OFFSET + 0xb5) +#define ALT_V (KEY_OFFSET + 0xb6) +#define ALT_W (KEY_OFFSET + 0xb7) +#define ALT_X (KEY_OFFSET + 0xb8) +#define ALT_Y (KEY_OFFSET + 0xb9) +#define ALT_Z (KEY_OFFSET + 0xba) + +#define CTL_LEFT (KEY_OFFSET + 0xbb) /* Control-Left-Arrow */ +#define CTL_RIGHT (KEY_OFFSET + 0xbc) +#define CTL_PGUP (KEY_OFFSET + 0xbd) +#define CTL_PGDN (KEY_OFFSET + 0xbe) +#define CTL_HOME (KEY_OFFSET + 0xbf) +#define CTL_END (KEY_OFFSET + 0xc0) + +#define KEY_A1 (KEY_OFFSET + 0xc1) /* upper left on Virtual keypad */ +#define KEY_A2 (KEY_OFFSET + 0xc2) /* upper middle on Virt. keypad */ +#define KEY_A3 (KEY_OFFSET + 0xc3) /* upper right on Vir. keypad */ +#define KEY_B1 (KEY_OFFSET + 0xc4) /* middle left on Virt. keypad */ +#define KEY_B2 (KEY_OFFSET + 0xc5) /* center on Virt. keypad */ +#define KEY_B3 (KEY_OFFSET + 0xc6) /* middle right on Vir. keypad */ +#define KEY_C1 (KEY_OFFSET + 0xc7) /* lower left on Virt. keypad */ +#define KEY_C2 (KEY_OFFSET + 0xc8) /* lower middle on Virt. keypad */ +#define KEY_C3 (KEY_OFFSET + 0xc9) /* lower right on Vir. keypad */ + +#define PADSLASH (KEY_OFFSET + 0xca) /* slash on keypad */ +#define PADENTER (KEY_OFFSET + 0xcb) /* enter on keypad */ +#define CTL_PADENTER (KEY_OFFSET + 0xcc) /* ctl-enter on keypad */ +#define ALT_PADENTER (KEY_OFFSET + 0xcd) /* alt-enter on keypad */ +#define PADSTOP (KEY_OFFSET + 0xce) /* stop on keypad */ +#define PADSTAR (KEY_OFFSET + 0xcf) /* star on keypad */ +#define PADMINUS (KEY_OFFSET + 0xd0) /* minus on keypad */ +#define PADPLUS (KEY_OFFSET + 0xd1) /* plus on keypad */ +#define CTL_PADSTOP (KEY_OFFSET + 0xd2) /* ctl-stop on keypad */ +#define CTL_PADCENTER (KEY_OFFSET + 0xd3) /* ctl-enter on keypad */ +#define CTL_PADPLUS (KEY_OFFSET + 0xd4) /* ctl-plus on keypad */ +#define CTL_PADMINUS (KEY_OFFSET + 0xd5) /* ctl-minus on keypad */ +#define CTL_PADSLASH (KEY_OFFSET + 0xd6) /* ctl-slash on keypad */ +#define CTL_PADSTAR (KEY_OFFSET + 0xd7) /* ctl-star on keypad */ +#define ALT_PADPLUS (KEY_OFFSET + 0xd8) /* alt-plus on keypad */ +#define ALT_PADMINUS (KEY_OFFSET + 0xd9) /* alt-minus on keypad */ +#define ALT_PADSLASH (KEY_OFFSET + 0xda) /* alt-slash on keypad */ +#define ALT_PADSTAR (KEY_OFFSET + 0xdb) /* alt-star on keypad */ +#define ALT_PADSTOP (KEY_OFFSET + 0xdc) /* alt-stop on keypad */ +#define CTL_INS (KEY_OFFSET + 0xdd) /* ctl-insert */ +#define ALT_DEL (KEY_OFFSET + 0xde) /* alt-delete */ +#define ALT_INS (KEY_OFFSET + 0xdf) /* alt-insert */ +#define CTL_UP (KEY_OFFSET + 0xe0) /* ctl-up arrow */ +#define CTL_DOWN (KEY_OFFSET + 0xe1) /* ctl-down arrow */ +#define CTL_TAB (KEY_OFFSET + 0xe2) /* ctl-tab */ +#define ALT_TAB (KEY_OFFSET + 0xe3) +#define ALT_MINUS (KEY_OFFSET + 0xe4) +#define ALT_EQUAL (KEY_OFFSET + 0xe5) +#define ALT_HOME (KEY_OFFSET + 0xe6) +#define ALT_PGUP (KEY_OFFSET + 0xe7) +#define ALT_PGDN (KEY_OFFSET + 0xe8) +#define ALT_END (KEY_OFFSET + 0xe9) +#define ALT_UP (KEY_OFFSET + 0xea) /* alt-up arrow */ +#define ALT_DOWN (KEY_OFFSET + 0xeb) /* alt-down arrow */ +#define ALT_RIGHT (KEY_OFFSET + 0xec) /* alt-right arrow */ +#define ALT_LEFT (KEY_OFFSET + 0xed) /* alt-left arrow */ +#define ALT_ENTER (KEY_OFFSET + 0xee) /* alt-enter */ +#define ALT_ESC (KEY_OFFSET + 0xef) /* alt-escape */ +#define ALT_BQUOTE (KEY_OFFSET + 0xf0) /* alt-back quote */ +#define ALT_LBRACKET (KEY_OFFSET + 0xf1) /* alt-left bracket */ +#define ALT_RBRACKET (KEY_OFFSET + 0xf2) /* alt-right bracket */ +#define ALT_SEMICOLON (KEY_OFFSET + 0xf3) /* alt-semi-colon */ +#define ALT_FQUOTE (KEY_OFFSET + 0xf4) /* alt-forward quote */ +#define ALT_COMMA (KEY_OFFSET + 0xf5) /* alt-comma */ +#define ALT_STOP (KEY_OFFSET + 0xf6) /* alt-stop */ +#define ALT_FSLASH (KEY_OFFSET + 0xf7) /* alt-forward slash */ +#define ALT_BKSP (KEY_OFFSET + 0xf8) /* alt-backspace */ +#define CTL_BKSP (KEY_OFFSET + 0xf9) /* ctl-backspace */ +#define PAD0 (KEY_OFFSET + 0xfa) /* keypad 0 */ + +#define CTL_PAD0 (KEY_OFFSET + 0xfb) /* ctl-keypad 0 */ +#define CTL_PAD1 (KEY_OFFSET + 0xfc) +#define CTL_PAD2 (KEY_OFFSET + 0xfd) +#define CTL_PAD3 (KEY_OFFSET + 0xfe) +#define CTL_PAD4 (KEY_OFFSET + 0xff) +#define CTL_PAD5 (KEY_OFFSET + 0x100) +#define CTL_PAD6 (KEY_OFFSET + 0x101) +#define CTL_PAD7 (KEY_OFFSET + 0x102) +#define CTL_PAD8 (KEY_OFFSET + 0x103) +#define CTL_PAD9 (KEY_OFFSET + 0x104) + +#define ALT_PAD0 (KEY_OFFSET + 0x105) /* alt-keypad 0 */ +#define ALT_PAD1 (KEY_OFFSET + 0x106) +#define ALT_PAD2 (KEY_OFFSET + 0x107) +#define ALT_PAD3 (KEY_OFFSET + 0x108) +#define ALT_PAD4 (KEY_OFFSET + 0x109) +#define ALT_PAD5 (KEY_OFFSET + 0x10a) +#define ALT_PAD6 (KEY_OFFSET + 0x10b) +#define ALT_PAD7 (KEY_OFFSET + 0x10c) +#define ALT_PAD8 (KEY_OFFSET + 0x10d) +#define ALT_PAD9 (KEY_OFFSET + 0x10e) + +#define CTL_DEL (KEY_OFFSET + 0x10f) /* clt-delete */ +#define ALT_BSLASH (KEY_OFFSET + 0x110) /* alt-back slash */ +#define CTL_ENTER (KEY_OFFSET + 0x111) /* ctl-enter */ + +#define SHF_PADENTER (KEY_OFFSET + 0x112) /* shift-enter on keypad */ +#define SHF_PADSLASH (KEY_OFFSET + 0x113) /* shift-slash on keypad */ +#define SHF_PADSTAR (KEY_OFFSET + 0x114) /* shift-star on keypad */ +#define SHF_PADPLUS (KEY_OFFSET + 0x115) /* shift-plus on keypad */ +#define SHF_PADMINUS (KEY_OFFSET + 0x116) /* shift-minus on keypad */ +#define SHF_UP (KEY_OFFSET + 0x117) /* shift-up on keypad */ +#define SHF_DOWN (KEY_OFFSET + 0x118) /* shift-down on keypad */ +#define SHF_IC (KEY_OFFSET + 0x119) /* shift-insert on keypad */ +#define SHF_DC (KEY_OFFSET + 0x11a) /* shift-delete on keypad */ + +#define KEY_MOUSE (KEY_OFFSET + 0x11b) /* "mouse" key */ +#define KEY_SHIFT_L (KEY_OFFSET + 0x11c) /* Left-shift */ +#define KEY_SHIFT_R (KEY_OFFSET + 0x11d) /* Right-shift */ +#define KEY_CONTROL_L (KEY_OFFSET + 0x11e) /* Left-control */ +#define KEY_CONTROL_R (KEY_OFFSET + 0x11f) /* Right-control */ +#define KEY_ALT_L (KEY_OFFSET + 0x120) /* Left-alt */ +#define KEY_ALT_R (KEY_OFFSET + 0x121) /* Right-alt */ +#define KEY_RESIZE (KEY_OFFSET + 0x122) /* Window resize */ +#define KEY_SUP (KEY_OFFSET + 0x123) /* Shifted up arrow */ +#define KEY_SDOWN (KEY_OFFSET + 0x124) /* Shifted down arrow */ + + /* The following were added 2011 Sep 14, and are */ + /* not returned by most flavors of PDCurses: */ + +#define CTL_SEMICOLON (KEY_OFFSET + 0x125) +#define CTL_EQUAL (KEY_OFFSET + 0x126) +#define CTL_COMMA (KEY_OFFSET + 0x127) +#define CTL_MINUS (KEY_OFFSET + 0x128) +#define CTL_STOP (KEY_OFFSET + 0x129) +#define CTL_FSLASH (KEY_OFFSET + 0x12a) +#define CTL_BQUOTE (KEY_OFFSET + 0x12b) + +#define KEY_APPS (KEY_OFFSET + 0x12c) +#define KEY_SAPPS (KEY_OFFSET + 0x12d) +#define CTL_APPS (KEY_OFFSET + 0x12e) +#define ALT_APPS (KEY_OFFSET + 0x12f) + +#define KEY_PAUSE (KEY_OFFSET + 0x130) +#define KEY_SPAUSE (KEY_OFFSET + 0x131) +#define CTL_PAUSE (KEY_OFFSET + 0x132) + +#define KEY_PRINTSCREEN (KEY_OFFSET + 0x133) +#define ALT_PRINTSCREEN (KEY_OFFSET + 0x134) +#define KEY_SCROLLLOCK (KEY_OFFSET + 0x135) +#define ALT_SCROLLLOCK (KEY_OFFSET + 0x136) + +#define CTL_0 (KEY_OFFSET + 0x137) +#define CTL_1 (KEY_OFFSET + 0x138) +#define CTL_2 (KEY_OFFSET + 0x139) +#define CTL_3 (KEY_OFFSET + 0x13a) +#define CTL_4 (KEY_OFFSET + 0x13b) +#define CTL_5 (KEY_OFFSET + 0x13c) +#define CTL_6 (KEY_OFFSET + 0x13d) +#define CTL_7 (KEY_OFFSET + 0x13e) +#define CTL_8 (KEY_OFFSET + 0x13f) +#define CTL_9 (KEY_OFFSET + 0x140) + +#define KEY_BROWSER_BACK (KEY_OFFSET + 0x141) +#define KEY_SBROWSER_BACK (KEY_OFFSET + 0x142) +#define KEY_CBROWSER_BACK (KEY_OFFSET + 0x143) +#define KEY_ABROWSER_BACK (KEY_OFFSET + 0x144) +#define KEY_BROWSER_FWD (KEY_OFFSET + 0x145) +#define KEY_SBROWSER_FWD (KEY_OFFSET + 0x146) +#define KEY_CBROWSER_FWD (KEY_OFFSET + 0x147) +#define KEY_ABROWSER_FWD (KEY_OFFSET + 0x148) +#define KEY_BROWSER_REF (KEY_OFFSET + 0x149) +#define KEY_SBROWSER_REF (KEY_OFFSET + 0x14A) +#define KEY_CBROWSER_REF (KEY_OFFSET + 0x14B) +#define KEY_ABROWSER_REF (KEY_OFFSET + 0x14C) +#define KEY_BROWSER_STOP (KEY_OFFSET + 0x14D) +#define KEY_SBROWSER_STOP (KEY_OFFSET + 0x14E) +#define KEY_CBROWSER_STOP (KEY_OFFSET + 0x14F) +#define KEY_ABROWSER_STOP (KEY_OFFSET + 0x150) +#define KEY_SEARCH (KEY_OFFSET + 0x151) +#define KEY_SSEARCH (KEY_OFFSET + 0x152) +#define KEY_CSEARCH (KEY_OFFSET + 0x153) +#define KEY_ASEARCH (KEY_OFFSET + 0x154) +#define KEY_FAVORITES (KEY_OFFSET + 0x155) +#define KEY_SFAVORITES (KEY_OFFSET + 0x156) +#define KEY_CFAVORITES (KEY_OFFSET + 0x157) +#define KEY_AFAVORITES (KEY_OFFSET + 0x158) +#define KEY_BROWSER_HOME (KEY_OFFSET + 0x159) +#define KEY_SBROWSER_HOME (KEY_OFFSET + 0x15A) +#define KEY_CBROWSER_HOME (KEY_OFFSET + 0x15B) +#define KEY_ABROWSER_HOME (KEY_OFFSET + 0x15C) +#define KEY_VOLUME_MUTE (KEY_OFFSET + 0x15D) +#define KEY_SVOLUME_MUTE (KEY_OFFSET + 0x15E) +#define KEY_CVOLUME_MUTE (KEY_OFFSET + 0x15F) +#define KEY_AVOLUME_MUTE (KEY_OFFSET + 0x160) +#define KEY_VOLUME_DOWN (KEY_OFFSET + 0x161) +#define KEY_SVOLUME_DOWN (KEY_OFFSET + 0x162) +#define KEY_CVOLUME_DOWN (KEY_OFFSET + 0x163) +#define KEY_AVOLUME_DOWN (KEY_OFFSET + 0x164) +#define KEY_VOLUME_UP (KEY_OFFSET + 0x165) +#define KEY_SVOLUME_UP (KEY_OFFSET + 0x166) +#define KEY_CVOLUME_UP (KEY_OFFSET + 0x167) +#define KEY_AVOLUME_UP (KEY_OFFSET + 0x168) +#define KEY_NEXT_TRACK (KEY_OFFSET + 0x169) +#define KEY_SNEXT_TRACK (KEY_OFFSET + 0x16A) +#define KEY_CNEXT_TRACK (KEY_OFFSET + 0x16B) +#define KEY_ANEXT_TRACK (KEY_OFFSET + 0x16C) +#define KEY_PREV_TRACK (KEY_OFFSET + 0x16D) +#define KEY_SPREV_TRACK (KEY_OFFSET + 0x16E) +#define KEY_CPREV_TRACK (KEY_OFFSET + 0x16F) +#define KEY_APREV_TRACK (KEY_OFFSET + 0x170) +#define KEY_MEDIA_STOP (KEY_OFFSET + 0x171) +#define KEY_SMEDIA_STOP (KEY_OFFSET + 0x172) +#define KEY_CMEDIA_STOP (KEY_OFFSET + 0x173) +#define KEY_AMEDIA_STOP (KEY_OFFSET + 0x174) +#define KEY_PLAY_PAUSE (KEY_OFFSET + 0x175) +#define KEY_SPLAY_PAUSE (KEY_OFFSET + 0x176) +#define KEY_CPLAY_PAUSE (KEY_OFFSET + 0x177) +#define KEY_APLAY_PAUSE (KEY_OFFSET + 0x178) +#define KEY_LAUNCH_MAIL (KEY_OFFSET + 0x179) +#define KEY_SLAUNCH_MAIL (KEY_OFFSET + 0x17A) +#define KEY_CLAUNCH_MAIL (KEY_OFFSET + 0x17B) +#define KEY_ALAUNCH_MAIL (KEY_OFFSET + 0x17C) +#define KEY_MEDIA_SELECT (KEY_OFFSET + 0x17D) +#define KEY_SMEDIA_SELECT (KEY_OFFSET + 0x17E) +#define KEY_CMEDIA_SELECT (KEY_OFFSET + 0x17F) +#define KEY_AMEDIA_SELECT (KEY_OFFSET + 0x180) +#define KEY_LAUNCH_APP1 (KEY_OFFSET + 0x181) +#define KEY_SLAUNCH_APP1 (KEY_OFFSET + 0x182) +#define KEY_CLAUNCH_APP1 (KEY_OFFSET + 0x183) +#define KEY_ALAUNCH_APP1 (KEY_OFFSET + 0x184) +#define KEY_LAUNCH_APP2 (KEY_OFFSET + 0x185) +#define KEY_SLAUNCH_APP2 (KEY_OFFSET + 0x186) +#define KEY_CLAUNCH_APP2 (KEY_OFFSET + 0x187) +#define KEY_ALAUNCH_APP2 (KEY_OFFSET + 0x188) + +#define KEY_MIN KEY_BREAK /* Minimum curses key value */ +#define KEY_MAX KEY_ALAUNCH_APP2 /* Maximum curses key */ + +#define KEY_F(n) (KEY_F0 + (n)) + +/*---------------------------------------------------------------------- + * + * PDCurses Function Declarations + * + */ + +/* Standard */ + +PDCEX int addch(const chtype); +PDCEX int addchnstr(const chtype *, int); +PDCEX int addchstr(const chtype *); +PDCEX int addnstr(const char *, int); +PDCEX int addstr(const char *); +PDCEX int attroff(chtype); +PDCEX int attron(chtype); +PDCEX int attrset(chtype); +PDCEX int attr_get(attr_t *, short *, void *); +PDCEX int attr_off(attr_t, void *); +PDCEX int attr_on(attr_t, void *); +PDCEX int attr_set(attr_t, short, void *); +PDCEX int baudrate(void); +PDCEX int beep(void); +PDCEX int bkgd(chtype); +PDCEX void bkgdset(chtype); +PDCEX int border(chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int box(WINDOW *, chtype, chtype); +PDCEX bool can_change_color(void); +PDCEX int cbreak(void); +PDCEX int chgat(int, attr_t, short, const void *); +PDCEX int clearok(WINDOW *, bool); +PDCEX int clear(void); +PDCEX int clrtobot(void); +PDCEX int clrtoeol(void); +PDCEX int color_content(short, short *, short *, short *); +PDCEX int color_set(short, void *); +PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int, + int, int, int, int); +PDCEX int curs_set(int); +PDCEX int def_prog_mode(void); +PDCEX int def_shell_mode(void); +PDCEX int delay_output(int); +PDCEX int delch(void); +PDCEX int deleteln(void); +PDCEX void delscreen(SCREEN *); +PDCEX int delwin(WINDOW *); +PDCEX WINDOW *derwin(WINDOW *, int, int, int, int); +PDCEX int doupdate(void); +PDCEX WINDOW *dupwin(WINDOW *); +PDCEX int echochar(const chtype); +PDCEX int echo(void); +PDCEX int endwin(void); +PDCEX char erasechar(void); +PDCEX int erase(void); +PDCEX void filter(void); +PDCEX int flash(void); +PDCEX int flushinp(void); +PDCEX chtype getbkgd(WINDOW *); +PDCEX int getnstr(char *, int); +PDCEX int getstr(char *); +PDCEX WINDOW *getwin(FILE *); +PDCEX int halfdelay(int); +PDCEX bool has_colors(void); +PDCEX bool has_ic(void); +PDCEX bool has_il(void); +PDCEX int hline(chtype, int); +PDCEX void idcok(WINDOW *, bool); +PDCEX int idlok(WINDOW *, bool); +PDCEX void immedok(WINDOW *, bool); +PDCEX int inchnstr(chtype *, int); +PDCEX int inchstr(chtype *); +PDCEX chtype inch(void); +PDCEX int init_color(short, short, short, short); +PDCEX int init_pair(short, short, short); +PDCEX WINDOW *initscr(void); +PDCEX int innstr(char *, int); +PDCEX int insch(chtype); +PDCEX int insdelln(int); +PDCEX int insertln(void); +PDCEX int insnstr(const char *, int); +PDCEX int insstr(const char *); +PDCEX int instr(char *); +PDCEX int intrflush(WINDOW *, bool); +PDCEX bool isendwin(void); +PDCEX bool is_linetouched(WINDOW *, int); +PDCEX bool is_wintouched(WINDOW *); +PDCEX char *keyname(int); +PDCEX int keypad(WINDOW *, bool); +PDCEX char killchar(void); +PDCEX int leaveok(WINDOW *, bool); +PDCEX char *longname(void); +PDCEX int meta(WINDOW *, bool); +PDCEX int move(int, int); +PDCEX int mvaddch(int, int, const chtype); +PDCEX int mvaddchnstr(int, int, const chtype *, int); +PDCEX int mvaddchstr(int, int, const chtype *); +PDCEX int mvaddnstr(int, int, const char *, int); +PDCEX int mvaddstr(int, int, const char *); +PDCEX int mvchgat(int, int, int, attr_t, short, const void *); +PDCEX int mvcur(int, int, int, int); +PDCEX int mvdelch(int, int); +PDCEX int mvderwin(WINDOW *, int, int); +PDCEX int mvgetch(int, int); +PDCEX int mvgetnstr(int, int, char *, int); +PDCEX int mvgetstr(int, int, char *); +PDCEX int mvhline(int, int, chtype, int); +PDCEX chtype mvinch(int, int); +PDCEX int mvinchnstr(int, int, chtype *, int); +PDCEX int mvinchstr(int, int, chtype *); +PDCEX int mvinnstr(int, int, char *, int); +PDCEX int mvinsch(int, int, chtype); +PDCEX int mvinsnstr(int, int, const char *, int); +PDCEX int mvinsstr(int, int, const char *); +PDCEX int mvinstr(int, int, char *); +PDCEX int mvprintw(int, int, const char *, ...); +PDCEX int mvscanw(int, int, const char *, ...); +PDCEX int mvvline(int, int, chtype, int); +PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); +PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *); +PDCEX int mvwaddch(WINDOW *, int, int, const chtype); +PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwaddstr(WINDOW *, int, int, const char *); +PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); +PDCEX int mvwdelch(WINDOW *, int, int); +PDCEX int mvwgetch(WINDOW *, int, int); +PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwgetstr(WINDOW *, int, int, char *); +PDCEX int mvwhline(WINDOW *, int, int, chtype, int); +PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int); +PDCEX int mvwinchstr(WINDOW *, int, int, chtype *); +PDCEX chtype mvwinch(WINDOW *, int, int); +PDCEX int mvwinnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwinsch(WINDOW *, int, int, chtype); +PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwinsstr(WINDOW *, int, int, const char *); +PDCEX int mvwinstr(WINDOW *, int, int, char *); +PDCEX int mvwin(WINDOW *, int, int); +PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwvline(WINDOW *, int, int, chtype, int); +PDCEX int napms(int); +PDCEX WINDOW *newpad(int, int); +PDCEX SCREEN *newterm(const char *, FILE *, FILE *); +PDCEX WINDOW *newwin(int, int, int, int); +PDCEX int nl(void); +PDCEX int nocbreak(void); +PDCEX int nodelay(WINDOW *, bool); +PDCEX int noecho(void); +PDCEX int nonl(void); +PDCEX void noqiflush(void); +PDCEX int noraw(void); +PDCEX int notimeout(WINDOW *, bool); +PDCEX int overlay(const WINDOW *, WINDOW *); +PDCEX int overwrite(const WINDOW *, WINDOW *); +PDCEX int pair_content(short, short *, short *); +PDCEX int pechochar(WINDOW *, chtype); +PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int prefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int printw(const char *, ...); +PDCEX int putwin(WINDOW *, FILE *); +PDCEX void qiflush(void); +PDCEX int raw(void); +PDCEX int redrawwin(WINDOW *); +PDCEX int refresh(void); +PDCEX int reset_prog_mode(void); +PDCEX int reset_shell_mode(void); +PDCEX int resetty(void); +PDCEX int ripoffline(int, int (*)(WINDOW *, int)); +PDCEX int savetty(void); +PDCEX int scanw(const char *, ...); +PDCEX int scr_dump(const char *); +PDCEX int scr_init(const char *); +PDCEX int scr_restore(const char *); +PDCEX int scr_set(const char *); +PDCEX int scrl(int); +PDCEX int scroll(WINDOW *); +PDCEX int scrollok(WINDOW *, bool); +PDCEX SCREEN *set_term(SCREEN *); +PDCEX int setscrreg(int, int); +PDCEX int slk_attroff(const chtype); +PDCEX int slk_attr_off(const attr_t, void *); +PDCEX int slk_attron(const chtype); +PDCEX int slk_attr_on(const attr_t, void *); +PDCEX int slk_attrset(const chtype); +PDCEX int slk_attr_set(const attr_t, short, void *); +PDCEX int slk_clear(void); +PDCEX int slk_color(short); +PDCEX int slk_init(int); +PDCEX char *slk_label(int); +PDCEX int slk_noutrefresh(void); +PDCEX int slk_refresh(void); +PDCEX int slk_restore(void); +PDCEX int slk_set(int, const char *, int); +PDCEX int slk_touch(void); +PDCEX int standend(void); +PDCEX int standout(void); +PDCEX int start_color(void); +PDCEX WINDOW *subpad(WINDOW *, int, int, int, int); +PDCEX WINDOW *subwin(WINDOW *, int, int, int, int); +PDCEX int syncok(WINDOW *, bool); +PDCEX chtype termattrs(void); +PDCEX attr_t term_attrs(void); +PDCEX char *termname(void); +PDCEX void timeout(int); +PDCEX int touchline(WINDOW *, int, int); +PDCEX int touchwin(WINDOW *); +PDCEX int typeahead(int); +PDCEX int untouchwin(WINDOW *); +PDCEX void use_env(bool); +PDCEX int vidattr(chtype); +PDCEX int vid_attr(attr_t, short, void *); +PDCEX int vidputs(chtype, int (*)(int)); +PDCEX int vid_puts(attr_t, short, void *, int (*)(int)); +PDCEX int vline(chtype, int); +PDCEX int vw_printw(WINDOW *, const char *, va_list); +PDCEX int vwprintw(WINDOW *, const char *, va_list); +PDCEX int vw_scanw(WINDOW *, const char *, va_list); +PDCEX int vwscanw(WINDOW *, const char *, va_list); +PDCEX int waddchnstr(WINDOW *, const chtype *, int); +PDCEX int waddchstr(WINDOW *, const chtype *); +PDCEX int waddch(WINDOW *, const chtype); +PDCEX int waddnstr(WINDOW *, const char *, int); +PDCEX int waddstr(WINDOW *, const char *); +PDCEX int wattroff(WINDOW *, chtype); +PDCEX int wattron(WINDOW *, chtype); +PDCEX int wattrset(WINDOW *, chtype); +PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *); +PDCEX int wattr_off(WINDOW *, attr_t, void *); +PDCEX int wattr_on(WINDOW *, attr_t, void *); +PDCEX int wattr_set(WINDOW *, attr_t, short, void *); +PDCEX void wbkgdset(WINDOW *, chtype); +PDCEX int wbkgd(WINDOW *, chtype); +PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *); +PDCEX int wclear(WINDOW *); +PDCEX int wclrtobot(WINDOW *); +PDCEX int wclrtoeol(WINDOW *); +PDCEX int wcolor_set(WINDOW *, short, void *); +PDCEX void wcursyncup(WINDOW *); +PDCEX int wdelch(WINDOW *); +PDCEX int wdeleteln(WINDOW *); +PDCEX int wechochar(WINDOW *, const chtype); +PDCEX int werase(WINDOW *); +PDCEX int wgetch(WINDOW *); +PDCEX int wgetnstr(WINDOW *, char *, int); +PDCEX int wgetstr(WINDOW *, char *); +PDCEX int whline(WINDOW *, chtype, int); +PDCEX int winchnstr(WINDOW *, chtype *, int); +PDCEX int winchstr(WINDOW *, chtype *); +PDCEX chtype winch(WINDOW *); +PDCEX int winnstr(WINDOW *, char *, int); +PDCEX int winsch(WINDOW *, chtype); +PDCEX int winsdelln(WINDOW *, int); +PDCEX int winsertln(WINDOW *); +PDCEX int winsnstr(WINDOW *, const char *, int); +PDCEX int winsstr(WINDOW *, const char *); +PDCEX int winstr(WINDOW *, char *); +PDCEX int wmove(WINDOW *, int, int); +PDCEX int wnoutrefresh(WINDOW *); +PDCEX int wprintw(WINDOW *, const char *, ...); +PDCEX int wredrawln(WINDOW *, int, int); +PDCEX int wrefresh(WINDOW *); +PDCEX int wscanw(WINDOW *, const char *, ...); +PDCEX int wscrl(WINDOW *, int); +PDCEX int wsetscrreg(WINDOW *, int, int); +PDCEX int wstandend(WINDOW *); +PDCEX int wstandout(WINDOW *); +PDCEX void wsyncdown(WINDOW *); +PDCEX void wsyncup(WINDOW *); +PDCEX void wtimeout(WINDOW *, int); +PDCEX int wtouchln(WINDOW *, int, int, int); +PDCEX int wvline(WINDOW *, chtype, int); + +/* Wide-character functions */ + +#ifdef PDC_WIDE +PDCEX int addnwstr(const wchar_t *, int); +PDCEX int addwstr(const wchar_t *); +PDCEX int add_wch(const cchar_t *); +PDCEX int add_wchnstr(const cchar_t *, int); +PDCEX int add_wchstr(const cchar_t *); +PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *); +PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *); +PDCEX int echo_wchar(const cchar_t *); +PDCEX int erasewchar(wchar_t *); +PDCEX int getbkgrnd(cchar_t *); +PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); +PDCEX int getn_wstr(wint_t *, int); +PDCEX int get_wch(wint_t *); +PDCEX int get_wstr(wint_t *); +PDCEX int hline_set(const cchar_t *, int); +PDCEX int innwstr(wchar_t *, int); +PDCEX int ins_nwstr(const wchar_t *, int); +PDCEX int ins_wch(const cchar_t *); +PDCEX int ins_wstr(const wchar_t *); +PDCEX int inwstr(wchar_t *); +PDCEX int in_wch(cchar_t *); +PDCEX int in_wchnstr(cchar_t *, int); +PDCEX int in_wchstr(cchar_t *); +PDCEX char *key_name(wchar_t); +PDCEX int killwchar(wchar_t *); +PDCEX int mvaddnwstr(int, int, const wchar_t *, int); +PDCEX int mvaddwstr(int, int, const wchar_t *); +PDCEX int mvadd_wch(int, int, const cchar_t *); +PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int); +PDCEX int mvadd_wchstr(int, int, const cchar_t *); +PDCEX int mvgetn_wstr(int, int, wint_t *, int); +PDCEX int mvget_wch(int, int, wint_t *); +PDCEX int mvget_wstr(int, int, wint_t *); +PDCEX int mvhline_set(int, int, const cchar_t *, int); +PDCEX int mvinnwstr(int, int, wchar_t *, int); +PDCEX int mvins_nwstr(int, int, const wchar_t *, int); +PDCEX int mvins_wch(int, int, const cchar_t *); +PDCEX int mvins_wstr(int, int, const wchar_t *); +PDCEX int mvinwstr(int, int, wchar_t *); +PDCEX int mvin_wch(int, int, cchar_t *); +PDCEX int mvin_wchnstr(int, int, cchar_t *, int); +PDCEX int mvin_wchstr(int, int, cchar_t *); +PDCEX int mvvline_set(int, int, const cchar_t *, int); +PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int); +PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *); +PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *); +PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); +PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *); +PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); +PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *); +PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *); +PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int pecho_wchar(WINDOW *, const cchar_t*); +PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t, + short, const void*); +PDCEX int slk_wset(int, const wchar_t *, int); +PDCEX int unget_wch(const wchar_t); +PDCEX int vline_set(const cchar_t *, int); +PDCEX int waddnwstr(WINDOW *, const wchar_t *, int); +PDCEX int waddwstr(WINDOW *, const wchar_t *); +PDCEX int wadd_wch(WINDOW *, const cchar_t *); +PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int); +PDCEX int wadd_wchstr(WINDOW *, const cchar_t *); +PDCEX int wbkgrnd(WINDOW *, const cchar_t *); +PDCEX void wbkgrndset(WINDOW *, const cchar_t *); +PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *); +PDCEX int wecho_wchar(WINDOW *, const cchar_t *); +PDCEX int wgetbkgrnd(WINDOW *, cchar_t *); +PDCEX int wgetn_wstr(WINDOW *, wint_t *, int); +PDCEX int wget_wch(WINDOW *, wint_t *); +PDCEX int wget_wstr(WINDOW *, wint_t *); +PDCEX int whline_set(WINDOW *, const cchar_t *, int); +PDCEX int winnwstr(WINDOW *, wchar_t *, int); +PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int); +PDCEX int wins_wch(WINDOW *, const cchar_t *); +PDCEX int wins_wstr(WINDOW *, const wchar_t *); +PDCEX int winwstr(WINDOW *, wchar_t *); +PDCEX int win_wch(WINDOW *, cchar_t *); +PDCEX int win_wchnstr(WINDOW *, cchar_t *, int); +PDCEX int win_wchstr(WINDOW *, cchar_t *); +PDCEX wchar_t *wunctrl(cchar_t *); +PDCEX int wvline_set(WINDOW *, const cchar_t *, int); +#endif + +/* Quasi-standard */ + +PDCEX chtype getattrs(WINDOW *); +PDCEX int getbegx(WINDOW *); +PDCEX int getbegy(WINDOW *); +PDCEX int getmaxx(WINDOW *); +PDCEX int getmaxy(WINDOW *); +PDCEX int getparx(WINDOW *); +PDCEX int getpary(WINDOW *); +PDCEX int getcurx(WINDOW *); +PDCEX int getcury(WINDOW *); +PDCEX void traceoff(void); +PDCEX void traceon(void); +PDCEX char *unctrl(chtype); + +PDCEX int crmode(void); +PDCEX int nocrmode(void); +PDCEX int draino(int); +PDCEX int resetterm(void); +PDCEX int fixterm(void); +PDCEX int saveterm(void); +PDCEX void setsyx(int, int); + +PDCEX int mouse_set(unsigned long); +PDCEX int mouse_on(unsigned long); +PDCEX int mouse_off(unsigned long); +PDCEX int request_mouse_pos(void); +PDCEX int map_button(unsigned long); +PDCEX void wmouse_position(WINDOW *, int *, int *); +PDCEX unsigned long getmouse(void); +PDCEX unsigned long getbmap(void); + +/* ncurses */ + +PDCEX int assume_default_colors(int, int); +PDCEX const char *curses_version(void); +PDCEX bool has_key(int); +PDCEX int use_default_colors(void); +PDCEX int wresize(WINDOW *, int, int); + +PDCEX int mouseinterval(int); +PDCEX mmask_t mousemask(mmask_t, mmask_t *); +PDCEX bool mouse_trafo(int *, int *, bool); +PDCEX int nc_getmouse(MEVENT *); +PDCEX int ungetmouse(MEVENT *); +PDCEX bool wenclose(const WINDOW *, int, int); +PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool); + +/* PDCurses */ + +PDCEX int addrawch(chtype); +PDCEX int insrawch(chtype); +PDCEX bool is_termresized(void); +PDCEX int mvaddrawch(int, int, chtype); +PDCEX int mvdeleteln(int, int); +PDCEX int mvinsertln(int, int); +PDCEX int mvinsrawch(int, int, chtype); +PDCEX int mvwaddrawch(WINDOW *, int, int, chtype); +PDCEX int mvwdeleteln(WINDOW *, int, int); +PDCEX int mvwinsertln(WINDOW *, int, int); +PDCEX int mvwinsrawch(WINDOW *, int, int, chtype); +PDCEX int raw_output(bool); +PDCEX int resize_term(int, int); +PDCEX WINDOW *resize_window(WINDOW *, int, int); +PDCEX int waddrawch(WINDOW *, chtype); +PDCEX int winsrawch(WINDOW *, chtype); +PDCEX char wordchar(void); + +#ifdef PDC_WIDE +PDCEX wchar_t *slk_wlabel(int); +#endif + +PDCEX void PDC_debug(const char *, ...); +PDCEX int PDC_ungetch(int); +PDCEX int PDC_set_blink(bool); +PDCEX int PDC_set_line_color(short); +PDCEX void PDC_set_title(const char *); + +PDCEX int PDC_clearclipboard(void); +PDCEX int PDC_freeclipboard(char *); +PDCEX int PDC_getclipboard(char **, long *); +PDCEX int PDC_setclipboard(const char *, long); + +PDCEX unsigned long PDC_get_input_fd(void); +PDCEX unsigned long PDC_get_key_modifiers(void); +PDCEX int PDC_return_key_modifiers(bool); +PDCEX int PDC_save_key_modifiers(bool); +PDCEX void PDC_set_resize_limits( const int new_min_lines, + const int new_max_lines, + const int new_min_cols, + const int new_max_cols); + +#define FUNCTION_KEY_SHUT_DOWN 0 +#define FUNCTION_KEY_PASTE 1 +#define FUNCTION_KEY_ENLARGE_FONT 2 +#define FUNCTION_KEY_SHRINK_FONT 3 +#define FUNCTION_KEY_CHOOSE_FONT 4 +#define FUNCTION_KEY_ABORT 5 +#define PDC_MAX_FUNCTION_KEYS 6 + +PDCEX int PDC_set_function_key( const unsigned function, + const int new_key); + +PDCEX WINDOW *Xinitscr(int, char **); +#ifdef XCURSES +PDCEX void XCursesExit(void); +PDCEX int sb_init(void); +PDCEX int sb_set_horz(int, int, int); +PDCEX int sb_set_vert(int, int, int); +PDCEX int sb_get_horz(int *, int *, int *); +PDCEX int sb_get_vert(int *, int *, int *); +PDCEX int sb_refresh(void); + #endif + +/*** Functions defined as macros ***/ + +/* getch() and ungetch() conflict with some DOS libraries */ + +#define getch() wgetch(stdscr) +#define ungetch(ch) PDC_ungetch(ch) + +#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) +#define PAIR_NUMBER(n) ((((n) & A_COLOR) >> PDC_COLOR_SHIFT) & 0xff) + +/* These will _only_ work as macros */ + +#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w)) +#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) +#define getparyx(w, y, x) (y = getpary(w), x = getparx(w)) +#define getyx(w, y, x) (y = getcury(w), x = getcurx(w)) + +#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \ + else getyx(curscr,(y),(x)); } + +#ifdef NCURSES_MOUSE_VERSION +# define getmouse(x) nc_getmouse(x) +#endif + +/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ + +#define PDC_CLIP_SUCCESS 0 +#define PDC_CLIP_ACCESS_ERROR 1 +#define PDC_CLIP_EMPTY 2 +#define PDC_CLIP_MEMORY_ERROR 3 + +/* PDCurses key modifier masks */ + +#define PDC_KEY_MODIFIER_SHIFT 1 +#define PDC_KEY_MODIFIER_CONTROL 2 +#define PDC_KEY_MODIFIER_ALT 4 +#define PDC_KEY_MODIFIER_NUMLOCK 8 +#define PDC_KEY_MODIFIER_REPEAT 16 + +#ifdef __cplusplus +# undef bool +} +#endif + +#endif /* __PDCURSES__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h new file mode 100644 index 000000000..b5edcc173 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h @@ -0,0 +1,134 @@ +/* Public Domain Curses */ + +/* Private definitions and declarations for use within PDCurses. + These should generally not be referenced by applications. */ + +#ifndef __CURSES_INTERNALS__ +#define __CURSES_INTERNALS__ 1 + +#define CURSES_LIBRARY +#include + +#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \ + defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__WATCOMC__) || defined(__PACIFIC__) +# ifndef HAVE_VSSCANF +# define HAVE_VSSCANF /* have vsscanf() */ +# endif +#endif + +#if defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__LCC__) || defined(__WATCOMC__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF /* have vsnprintf() */ +# endif +#endif + +#if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ +#endif + +/*----------------------------------------------------------------------*/ + +typedef struct /* structure for ripped off lines */ +{ + int line; + int (*init)(WINDOW *, int); +} RIPPEDOFFLINE; + +/* Window properties */ + +#define _SUBWIN 0x01 /* window is a subwindow */ +#define _PAD 0x10 /* X/Open Pad. */ +#define _SUBPAD 0x20 /* X/Open subpad. */ + +/* Miscellaneous */ + +#define _NO_CHANGE -1 /* flags line edge unchanged */ + +#define _ECHAR 0x08 /* Erase char (^H) */ +#define _DWCHAR 0x17 /* Delete Word char (^W) */ +#define _DLCHAR 0x15 /* Delete Line char (^U) */ + +extern WINDOW *pdc_lastscr; +extern FILE *pdc_dbfp; /* tracing file pointer (NULL = off) */ +extern bool pdc_color_started; +extern unsigned long pdc_key_modifiers; +extern MOUSE_STATUS pdc_mouse_status; + +/*----------------------------------------------------------------------*/ + +/* Platform implementation functions */ + +void PDC_beep(void); +bool PDC_can_change_color(void); +int PDC_color_content(short, short *, short *, short *); +bool PDC_check_key(void); +int PDC_curs_set(int); +void PDC_flushinp(void); +int PDC_get_columns(void); +int PDC_get_cursor_mode(void); +int PDC_get_key(void); +int PDC_get_rows(void); +void PDC_gotoyx(int, int); +int PDC_init_color(short, short, short, short); +void PDC_init_pair(short, short, short); +int PDC_modifiers_set(void); +int PDC_mouse_set(void); +void PDC_napms(int); +int PDC_pair_content(short, short *, short *); +void PDC_reset_prog_mode(void); +void PDC_reset_shell_mode(void); +int PDC_resize_screen(int, int); +void PDC_restore_screen_mode(int); +void PDC_save_screen_mode(int); +void PDC_scr_close(void); +void PDC_scr_free(void); +int PDC_scr_open(int, char **); +void PDC_set_keyboard_binary(bool); +void PDC_transform_line(int, int, int, const chtype *); +const char *PDC_sysname(void); + +/* Internal cross-module functions */ + +void PDC_init_atrtab(void); +WINDOW *PDC_makelines(WINDOW *); +WINDOW *PDC_makenew(int, int, int, int); +int PDC_mouse_in_slk(int, int); +void PDC_slk_free(void); +void PDC_slk_initialize(void); +void PDC_sync(WINDOW *); + +#ifdef PDC_WIDE +int PDC_mbtowc(wchar_t *, const char *, size_t); +size_t PDC_mbstowcs(wchar_t *, const char *, size_t); +size_t PDC_wcstombs(char *, const wchar_t *, size_t); +#endif + +#ifdef PDCDEBUG +# define PDC_LOG(x) if (pdc_dbfp) PDC_debug x +#else +# define PDC_LOG(x) +#endif + +/* Internal macros for attributes */ + +#ifdef CHTYPE_LONG +# define PDC_COLOR_PAIRS 256 +#else +# define PDC_COLOR_PAIRS 32 +#endif + +#ifndef max +# define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +# define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define DIVROUND(num, divisor) (((num) + ((divisor) >> 1)) / (divisor)) + +#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if + not set by mouseinterval() */ + +#endif /* __CURSES_INTERNALS__*/ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h new file mode 100644 index 000000000..4de6e853e --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h @@ -0,0 +1,93 @@ +/* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */ +/* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */ +/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _GETOPT_H_ +#define _GETOPT_H_ + +#if 0 +#include +#endif + +/* + * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option { + /* name of long option */ + const char *name; + /* + * one of no_argument, required_argument, and optional_argument: + * whether option takes an argument + */ + int has_arg; + /* if not NULL, set *flag to val when option found */ + int *flag; + /* if flag not NULL, value to set *flag to; else return value */ + int val; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +int getopt_long(int, char * const *, const char *, + const struct option *, int *); +int getopt_long_only(int, char * const *, const char *, + const struct option *, int *); +#ifndef _GETOPT_DEFINED +#define _GETOPT_DEFINED +int getopt(int, char * const *, const char *); +int getsubopt(char **, char * const *, char **); + +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +extern int optreset; +extern char *suboptarg; /* getsubopt(3) external variable */ +#endif /* _GETOPT_DEFINED */ + +#ifdef __cplusplus +} +#endif +#endif /* !_GETOPT_H_ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h new file mode 100644 index 000000000..7f1fb1f17 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h @@ -0,0 +1,56 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * Panels for PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES_PANEL_H__ +#define __PDCURSES_PANEL_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct panelobs +{ + struct panelobs *above; + struct panel *pan; +} PANELOBS; + +typedef struct panel +{ + WINDOW *win; + int wstarty; + int wendy; + int wstartx; + int wendx; + struct panel *below; + struct panel *above; + const void *user; + struct panelobs *obscure; +} PANEL; + +PDCEX int bottom_panel(PANEL *pan); +PDCEX int del_panel(PANEL *pan); +PDCEX int hide_panel(PANEL *pan); +PDCEX int move_panel(PANEL *pan, int starty, int startx); +PDCEX PANEL *new_panel(WINDOW *win); +PDCEX PANEL *panel_above(const PANEL *pan); +PDCEX PANEL *panel_below(const PANEL *pan); +PDCEX int panel_hidden(const PANEL *pan); +PDCEX const void *panel_userptr(const PANEL *pan); +PDCEX WINDOW *panel_window(const PANEL *pan); +PDCEX int replace_panel(PANEL *pan, WINDOW *win); +PDCEX int set_panel_userptr(PANEL *pan, const void *uptr); +PDCEX int show_panel(PANEL *pan); +PDCEX int top_panel(PANEL *pan); +PDCEX void update_panels(void); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_PANEL_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h new file mode 100644 index 000000000..0ba0b7a7f --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h @@ -0,0 +1,48 @@ +/* Public Domain Curses */ + +/* PDCurses doesn't operate with terminfo, but we need these functions for + compatibility, to allow some things (notably, interface libraries for + other languages) to be compiled. Anyone who tries to actually _use_ + them will be disappointed, since they only return ERR. */ + +#ifndef __PDCURSES_TERM_H__ +#define __PDCURSES_TERM_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct +{ + const char *_termname; +} TERMINAL; + +/* PDCEX is defined in curses.h */ +PDCEX TERMINAL *cur_term; + +int del_curterm(TERMINAL *); +int putp(const char *); +int restartterm(const char *, int, int *); +TERMINAL *set_curterm(TERMINAL *); +int setterm(const char *); +int setupterm(const char *, int, int *); +int tgetent(char *, const char *); +int tgetflag(const char *); +int tgetnum(const char *); +char *tgetstr(const char *, char **); +char *tgoto(const char *, int, int); +int tigetflag(const char *); +int tigetnum(const char *); +char *tigetstr(const char *); +char *tparm(const char *, long, long, long, long, long, + long, long, long, long); +int tputs(const char *, int, int (*)(int)); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_TERM_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h new file mode 100644 index 000000000..5d2440309 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h @@ -0,0 +1,56 @@ +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +/* This is intended as a drop-in replacement for unistd.h on Windows. + * Please add functionality as neeeded. + * https://stackoverflow.com/a/826027/1202830 + */ + +#include +#include +#include /* getopt at: https://gist.github.com/ashelly/7776712 */ +#include /* for getpid() and the exec..() family */ +#include /* for _getcwd() and _chdir() */ + +#define srandom srand +#define random rand + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +//#define X_OK 1 /* execute permission - unsupported in windows*/ +#define F_OK 0 /* Test for existence. */ + +#define access _access +#define dup2 _dup2 +#define execve _execve +#define ftruncate _chsize +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define chdir _chdir +#define isatty _isatty +#define lseek _lseek +/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ + +#ifdef _WIN64 +#define ssize_t __int64 +#else +#define ssize_t long +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +/* should be in some equivalent to */ +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#endif /* unistd.h */ \ No newline at end of file From e914f0936f26277a0e78f688f54a38eaff690e5f Mon Sep 17 00:00:00 2001 From: Decker Date: Mon, 11 Mar 2019 05:52:21 +0300 Subject: [PATCH 2918/3904] + msvc deps build script this script builds only deps, to build rogue binary, open *.sln file in MSVC 2015 and build x64 Release version. --- src/cc/rogue/rogue_build_msvc.cmd | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/cc/rogue/rogue_build_msvc.cmd diff --git a/src/cc/rogue/rogue_build_msvc.cmd b/src/cc/rogue/rogue_build_msvc.cmd new file mode 100644 index 000000000..e49ab7228 --- /dev/null +++ b/src/cc/rogue/rogue_build_msvc.cmd @@ -0,0 +1,64 @@ +@echo off +echo Rogue Build Script by Decker (c) 2019 + +@REM Check for Visual Studio +call set "VSPATH=" +if defined VS140COMNTOOLS ( if not defined VSPATH ( + call set "VSPATH=%%VS140COMNTOOLS%%" +) ) + +@REM check if we already have the tools in the environment +if exist "%VCINSTALLDIR%" ( + goto compile +) + +if not defined VSPATH ( + echo You need Microsoft Visual Studio 15 installed + pause + exit +) + +@REM set up the environment +if exist "%VSPATH%..\..\vc\vcvarsall.bat" ( + call "%%VSPATH%%..\..\vc\vcvarsall.bat" amd64 + goto compile +) + +echo Unable to set up the environment +pause +exit + +:compile + +mkdir x86_64-w64-msvc\deps +mkdir x86_64-w64-msvc\deps\install + +pushd x86_64-w64-msvc\deps + +:compile_pdcurses +rem git clone https://github.com/wmcbrine/PDCurses PDCurses.org +git clone https://github.com/Bill-Gray/PDCurses + +set PREFIX_DIR=%CD%\install + +pushd PDCurses +mkdir build64 & pushd build64 +rem cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Debug -DPDCDEBUG=ON .. +cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Release .. +popd +rem cmake --build build64 --config Debug --target install +cmake --build build64 --config Release --target install +popd + +:compile_curl + +git clone https://github.com/curl/curl +pushd curl + +mkdir build64 & pushd build64 +cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_USE_WINSSL:BOOL=ON .. +rem cmake --build . --config Release --target libcurl +cmake --build . --config Release --target install +popd +popd + From 9205b5404ccbef6c0da8331fcbe1590993b88b88 Mon Sep 17 00:00:00 2001 From: Decker Date: Mon, 11 Mar 2019 05:57:04 +0300 Subject: [PATCH 2919/3904] + msvc solution (*.sln) update --- src/cc/rogue/rogue54.sln | 14 +- src/cc/rogue/rogue54.vcxproj | 257 +++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+), 3 deletions(-) create mode 100644 src/cc/rogue/rogue54.vcxproj diff --git a/src/cc/rogue/rogue54.sln b/src/cc/rogue/rogue54.sln index da1c58f07..751959465 100644 --- a/src/cc/rogue/rogue54.sln +++ b/src/cc/rogue/rogue54.sln @@ -1,17 +1,25 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcxproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.ActiveCfg = Debug|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.Build.0 = Debug|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.ActiveCfg = Debug|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.Build.0 = Debug|x64 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.ActiveCfg = Release|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.Build.0 = Release|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.ActiveCfg = Release|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/cc/rogue/rogue54.vcxproj b/src/cc/rogue/rogue54.vcxproj new file mode 100644 index 000000000..344598dd8 --- /dev/null +++ b/src/cc/rogue/rogue54.vcxproj @@ -0,0 +1,257 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6} + Win32Proj + 8.1 + + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + false + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + Debug\ + Debug\ + true + + + true + + + Release\ + Release\ + false + + + false + + + + Disabled + Default + ../pdcurses;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;MASTER;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + EnableFastChecks + MultiThreaded + true + true + false + true + + + Level4 + EditAndContinue + CompileAsC + + + Ws2_32.lib;pdcurses.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + ..\pdcurses;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + MachineX86 + + + + + Disabled + Default + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + + EnableFastChecks + MultiThreaded + true + true + false + true + + + + + Level4 + ProgramDatabase + CompileAsC + + + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + NotUsing + Level3 + ProgramDatabase + $(ProjectDir)\x86_64-w64-msvc\include\ncursesw;$(ProjectDir)\x86_64-w64-msvc\include;%(AdditionalIncludeDirectories) + + + $(OutDir)rogue54.exe + true + Windows + true + true + MachineX86 + %(AdditionalLibraryDirectories) + %(AdditionalDependencies) + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;_WINDOWS;NDEBUG;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + ProgramDatabase + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + stdafx.h + CompileAsC + + + + + $(OutDir)rogue54.exe + true + Console + true + true + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + %(IgnoreSpecificDefaultLibraries) + false + %(ForceSymbolReferences) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 56905677d5c20e83bd8d10ed5491bec271ea2d7a Mon Sep 17 00:00:00 2001 From: Decker Date: Mon, 11 Mar 2019 05:58:10 +0300 Subject: [PATCH 2920/3904] + msvc build fix --- .gitignore | 1 + src/cc/rogue/extern.h | 9 ++++++++- src/cc/rogue/main.c | 45 ++++++++++++++++++++++++++++++++++++++++++- src/cc/rogue/rogue.c | 27 ++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2ab07ee0f..9f05e147c 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,4 @@ src/ROGUE.conf src/rogue.scr src/cc/rogue/confdefs.h +src/cc/rogue/x64 diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 7fba842f3..c62646b67 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -107,6 +107,12 @@ #include #include +#ifdef _WIN32 +#ifdef _MSC_VER +#include +#endif +#endif + #undef SIGTSTP #define MAXSTR 1024 /* maximum length of strings */ @@ -142,7 +148,8 @@ void leave(int); void my_exit(int st); void playltchars(void); void quit(int); -int32_t _quit(); +int32_t _quit(); + void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index c2155a085..da46898f8 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -38,6 +38,31 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif +#ifdef _WIN32 +#ifdef _MSC_VER +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = ((uint64_t)file_time.dwLowDateTime); + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); + return 0; +} +#endif // _MSC_VER +#endif + + + double OS_milliseconds() { struct timeval tv; double millis; @@ -392,6 +417,12 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char * } #endif +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + /************************************************************************ * * perform the query @@ -919,7 +950,19 @@ int main(int argc, char **argv, char **envp) printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s) IPADDRESS.%s \n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS,IPADDRESS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { - seed = atol(argv[1]); + + #ifdef _WIN32 + #ifdef _MSC_VER + seed = _strtoui64(argv[1], NULL, 10); + fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%I64u)", argv[1], seed); + #else + fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%llu)", argv[1], (long long)seed); + seed = atol(argv[1]); // windows, but not MSVC + #endif // _MSC_VER + #else + seed = atol(argv[1]); // non-windows + #endif // _WIN32 + //fprintf(stderr,"replay %llu\n",(long long)seed); return(rogue_replay(seed,10)); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 352e950ec..36616b340 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -13,6 +13,7 @@ #include //#include //#include + #include "rogue.h" #ifdef STANDALONE #include "../komodo/src/komodo_cJSON.h" @@ -196,6 +197,12 @@ void rogue_bailout(struct rogue_state *rs) fprintf(stderr,"error issuing (%s)\n",cmd);*/ } +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis) { struct rogue_state *rs; FILE *fp; int32_t i,n; @@ -215,6 +222,14 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); + + /* + // keypress after replay + printf("[Press return to continue]"); + fflush(stdout); + if (fgets(prbuf, 10, stdin) != 0); + */ + if ( 0 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); @@ -526,6 +541,18 @@ tstp(int ignored) #endif*/ } + +#ifdef _WIN32 +#ifdef _MSC_VER +void usleep(int32_t micros) +{ + if (micros < 1000) + Sleep(1); + else Sleep(micros / 1000); +} +#endif +#endif + /* * playit: * The main loop of the program. Loop until the game is over, From 42e975b4dfa7da992fd3dfece41955fe7dfa97de Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 11 Mar 2019 06:32:02 +0300 Subject: [PATCH 2921/3904] fix libcurl deps install (msvc) --- src/cc/rogue/rogue_build_msvc.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue_build_msvc.cmd b/src/cc/rogue/rogue_build_msvc.cmd index e49ab7228..77e7cd852 100644 --- a/src/cc/rogue/rogue_build_msvc.cmd +++ b/src/cc/rogue/rogue_build_msvc.cmd @@ -57,7 +57,7 @@ pushd curl mkdir build64 & pushd build64 cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_USE_WINSSL:BOOL=ON .. -rem cmake --build . --config Release --target libcurl +cmake --build . --config Release --target libcurl cmake --build . --config Release --target install popd popd From bc0073b27dc826fae3bf5cc3896fa2bd86b34e4c Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 11 Mar 2019 08:33:40 +0200 Subject: [PATCH 2922/3904] rogue msvc build (#1327) * + msvc 2015 deps headers * + msvc deps build script this script builds only deps, to build rogue binary, open *.sln file in MSVC 2015 and build x64 Release version. * + msvc solution (*.sln) update * + msvc build fix * fix libcurl deps install (msvc) --- .gitignore | 1 + src/cc/rogue/extern.h | 9 +- src/cc/rogue/main.c | 45 +- src/cc/rogue/rogue.c | 27 + src/cc/rogue/rogue54.sln | 14 +- src/cc/rogue/rogue54.vcxproj | 257 +++ src/cc/rogue/rogue_build_msvc.cmd | 64 + .../deps/install/include/acs_defs.h | 265 +++ .../deps/install/include/curses.h | 1846 +++++++++++++++++ .../deps/install/include/curspriv.h | 134 ++ .../deps/install/include/getopt.h | 93 + .../deps/install/include/panel.h | 56 + .../deps/install/include/term.h | 48 + .../deps/install/include/unistd.h | 56 + 14 files changed, 2910 insertions(+), 5 deletions(-) create mode 100644 src/cc/rogue/rogue54.vcxproj create mode 100644 src/cc/rogue/rogue_build_msvc.cmd create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h diff --git a/.gitignore b/.gitignore index 2ab07ee0f..9f05e147c 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,4 @@ src/ROGUE.conf src/rogue.scr src/cc/rogue/confdefs.h +src/cc/rogue/x64 diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 7fba842f3..c62646b67 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -107,6 +107,12 @@ #include #include +#ifdef _WIN32 +#ifdef _MSC_VER +#include +#endif +#endif + #undef SIGTSTP #define MAXSTR 1024 /* maximum length of strings */ @@ -142,7 +148,8 @@ void leave(int); void my_exit(int st); void playltchars(void); void quit(int); -int32_t _quit(); +int32_t _quit(); + void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index c2155a085..da46898f8 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -38,6 +38,31 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif +#ifdef _WIN32 +#ifdef _MSC_VER +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = ((uint64_t)file_time.dwLowDateTime); + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); + return 0; +} +#endif // _MSC_VER +#endif + + + double OS_milliseconds() { struct timeval tv; double millis; @@ -392,6 +417,12 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char * } #endif +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + /************************************************************************ * * perform the query @@ -919,7 +950,19 @@ int main(int argc, char **argv, char **envp) printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s) IPADDRESS.%s \n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS,IPADDRESS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { - seed = atol(argv[1]); + + #ifdef _WIN32 + #ifdef _MSC_VER + seed = _strtoui64(argv[1], NULL, 10); + fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%I64u)", argv[1], seed); + #else + fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%llu)", argv[1], (long long)seed); + seed = atol(argv[1]); // windows, but not MSVC + #endif // _MSC_VER + #else + seed = atol(argv[1]); // non-windows + #endif // _WIN32 + //fprintf(stderr,"replay %llu\n",(long long)seed); return(rogue_replay(seed,10)); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 352e950ec..36616b340 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -13,6 +13,7 @@ #include //#include //#include + #include "rogue.h" #ifdef STANDALONE #include "../komodo/src/komodo_cJSON.h" @@ -196,6 +197,12 @@ void rogue_bailout(struct rogue_state *rs) fprintf(stderr,"error issuing (%s)\n",cmd);*/ } +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis) { struct rogue_state *rs; FILE *fp; int32_t i,n; @@ -215,6 +222,14 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); + + /* + // keypress after replay + printf("[Press return to continue]"); + fflush(stdout); + if (fgets(prbuf, 10, stdin) != 0); + */ + if ( 0 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); @@ -526,6 +541,18 @@ tstp(int ignored) #endif*/ } + +#ifdef _WIN32 +#ifdef _MSC_VER +void usleep(int32_t micros) +{ + if (micros < 1000) + Sleep(1); + else Sleep(micros / 1000); +} +#endif +#endif + /* * playit: * The main loop of the program. Loop until the game is over, diff --git a/src/cc/rogue/rogue54.sln b/src/cc/rogue/rogue54.sln index da1c58f07..751959465 100644 --- a/src/cc/rogue/rogue54.sln +++ b/src/cc/rogue/rogue54.sln @@ -1,17 +1,25 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcxproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.ActiveCfg = Debug|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.Build.0 = Debug|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.ActiveCfg = Debug|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.Build.0 = Debug|x64 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.ActiveCfg = Release|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.Build.0 = Release|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.ActiveCfg = Release|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/cc/rogue/rogue54.vcxproj b/src/cc/rogue/rogue54.vcxproj new file mode 100644 index 000000000..344598dd8 --- /dev/null +++ b/src/cc/rogue/rogue54.vcxproj @@ -0,0 +1,257 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6} + Win32Proj + 8.1 + + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + false + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + Debug\ + Debug\ + true + + + true + + + Release\ + Release\ + false + + + false + + + + Disabled + Default + ../pdcurses;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;MASTER;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + EnableFastChecks + MultiThreaded + true + true + false + true + + + Level4 + EditAndContinue + CompileAsC + + + Ws2_32.lib;pdcurses.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + ..\pdcurses;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + MachineX86 + + + + + Disabled + Default + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + + EnableFastChecks + MultiThreaded + true + true + false + true + + + + + Level4 + ProgramDatabase + CompileAsC + + + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + NotUsing + Level3 + ProgramDatabase + $(ProjectDir)\x86_64-w64-msvc\include\ncursesw;$(ProjectDir)\x86_64-w64-msvc\include;%(AdditionalIncludeDirectories) + + + $(OutDir)rogue54.exe + true + Windows + true + true + MachineX86 + %(AdditionalLibraryDirectories) + %(AdditionalDependencies) + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;_WINDOWS;NDEBUG;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + ProgramDatabase + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + stdafx.h + CompileAsC + + + + + $(OutDir)rogue54.exe + true + Console + true + true + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + %(IgnoreSpecificDefaultLibraries) + false + %(ForceSymbolReferences) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/cc/rogue/rogue_build_msvc.cmd b/src/cc/rogue/rogue_build_msvc.cmd new file mode 100644 index 000000000..77e7cd852 --- /dev/null +++ b/src/cc/rogue/rogue_build_msvc.cmd @@ -0,0 +1,64 @@ +@echo off +echo Rogue Build Script by Decker (c) 2019 + +@REM Check for Visual Studio +call set "VSPATH=" +if defined VS140COMNTOOLS ( if not defined VSPATH ( + call set "VSPATH=%%VS140COMNTOOLS%%" +) ) + +@REM check if we already have the tools in the environment +if exist "%VCINSTALLDIR%" ( + goto compile +) + +if not defined VSPATH ( + echo You need Microsoft Visual Studio 15 installed + pause + exit +) + +@REM set up the environment +if exist "%VSPATH%..\..\vc\vcvarsall.bat" ( + call "%%VSPATH%%..\..\vc\vcvarsall.bat" amd64 + goto compile +) + +echo Unable to set up the environment +pause +exit + +:compile + +mkdir x86_64-w64-msvc\deps +mkdir x86_64-w64-msvc\deps\install + +pushd x86_64-w64-msvc\deps + +:compile_pdcurses +rem git clone https://github.com/wmcbrine/PDCurses PDCurses.org +git clone https://github.com/Bill-Gray/PDCurses + +set PREFIX_DIR=%CD%\install + +pushd PDCurses +mkdir build64 & pushd build64 +rem cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Debug -DPDCDEBUG=ON .. +cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Release .. +popd +rem cmake --build build64 --config Debug --target install +cmake --build build64 --config Release --target install +popd + +:compile_curl + +git clone https://github.com/curl/curl +pushd curl + +mkdir build64 & pushd build64 +cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_USE_WINSSL:BOOL=ON .. +cmake --build . --config Release --target libcurl +cmake --build . --config Release --target install +popd +popd + diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h new file mode 100644 index 000000000..c8c02a737 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h @@ -0,0 +1,265 @@ +/* Many of the following #defines are completely unused for the +nonce. For each character, its code point in code page 437, +Unicode, and page 8859-1 are given. The first is used for +non-wide builds in Win32 console, DOS, SDL, and OS/2. +Unicode is used for all wide builds, and for the non-wide +build of WinGUI. Code page 8859-1 is used for non-wide X11. + + All of these characters exist in CP437 and Unicode. Some +don't exist in 8859-1, in which case the last column is 'TBD'. +Only 32 are used in ncurses. So caution is advised. */ + +#ifdef USE_ISO8859_CHARSET + #define CHOOSE( A, B, C) (C) + #define TBD '!' +#else + #define CHOOSE( A, B, C) (USE_UNICODE_ACS_CHARS ? B : A) +#endif + +/* Codes found from https://en.wikipedia.org/wiki/Code_page_437 */ + +#define SMILE CHOOSE( 0x01, 0x263a, 'O') +#define REV_SMILE CHOOSE( 0x02, 0x263b, 'O') +#define HEART CHOOSE( 0x03, 0x2665, 'H') +#define DIAMOND CHOOSE( 0x04, 0x2666, 0x01) +#define CLUB CHOOSE( 0x05, 0x2663, 'C') +#define SPADE CHOOSE( 0x06, 0x2660, 'S') +#define MEDIUM_BULLET CHOOSE( 0x07, 0x2022, 0xb7) +#define REV_BULLET CHOOSE( 0x08, 0x2508, 0xb7) +#define WHITE_BULLET CHOOSE( 0x09, 0x25cb, 7) +#define REV_WHITE_BULLET CHOOSE( 0x0a, 0x25D9, 7) +#define MALE_SYM CHOOSE( 0x0b, 0x2642, 'm') +#define FEMALE_SYM CHOOSE( 0x0c, 0x2640, 'f') +#define QTR_NOTE CHOOSE( 0x0d, 0x266a, 0xbc) +#define EIGHTH_NOTE CHOOSE( 0x0e, 0x266b, 0xbd) +#define SPLAT CHOOSE( 0x0f, 0xa4 , 0xa4) +#define RIGHT_TRIANGLE CHOOSE( 0x10, 0x25b6, '>') +#define LEFT_TRIANGLE CHOOSE( 0x11, 0x25c0, '<') +#define UP_DOWN_ARROW CHOOSE( 0x12, 0x2195, 0x19) +#define DBL_BANG CHOOSE( 0x13, 0x203c, '!') +#define PILCROW CHOOSE( 0x14, 0xb6 , 0xb6) +#define SECTION_SIGN CHOOSE( 0x15, 0xa7 , 0xa7) +#define LOW_QTR_BLOCK CHOOSE( 0x16, 0x25b2, '_') +#define UP_DOWN_ARROW_UNDERSCORED CHOOSE( 0x17, 0x21ab, 0x19) +#define UP_ARROW CHOOSE( 0x18, 0x2191, '^') +#define DOWN_ARROW CHOOSE( 0x19, 0x2193, 'v') +#define RIGHT_ARROW CHOOSE( 0x1a, 0x2192, '>') +#define LEFT_ARROW CHOOSE( 0x1b, 0x2190, '<') +#define RIGHT_ANGLE CHOOSE( 0x1c, 0x221f, 0xe) +#define LEFT_RIGHT_ARROW CHOOSE( 0x1d, 0x2194, '-') +#define UP_TRIANGLE CHOOSE( 0x1e, 0x25b2, '^') +#define DOWN_TRIANGLE CHOOSE( 0x1f, 0x25bc, 'v') + +#define UPPERCASE_C_CEDILLA CHOOSE( 0x80, 0xc7 , 0xc7) +#define LOWERCASE_U_UMLAUT CHOOSE( 0x81, 0xfc , 0xfc) +#define LOWERCASE_E_ACUTE CHOOSE( 0x82, 0xe9 , 0xe9) +#define LOWERCASE_A_CIRCUMFLEX CHOOSE( 0x83, 0xe2 , 0xe2) +#define LOWERCASE_A_UMLAUT CHOOSE( 0x84, 0xe4 , 0xe4) +#define LOWERCASE_A_GRAVE CHOOSE( 0x85, 0xe0 , 0xea) +#define LOWERCASE_A_RING CHOOSE( 0x86, 0xe5 , 0xe5) +#define LOWERCASE_C_CEDILLA CHOOSE( 0x87, 0xe7 , 0xe7) +#define LOWERCASE_E_CIRCUMFLEX CHOOSE( 0x88, 0xea , 0xea) +#define LOWERCASE_E_UMLAUT CHOOSE( 0x89, 0xeb , 0xeb) +#define LOWERCASE_E_GRAVE CHOOSE( 0x8a, 0xe8 , 0xe8) +#define LOWERCASE_I_UMLAUT CHOOSE( 0x8b, 0xef , 0xef) +#define LOWERCASE_I_CIRCUMFLEX CHOOSE( 0x8c, 0xee , 0xee) +#define LOWERCASE_I_GRAVE CHOOSE( 0x8d, 0xec , 0xce) +#define UPPERCASE_A_UMLAUT CHOOSE( 0x8e, 0xc4 , 0xc4) +#define UPPERCASE_A_RING CHOOSE( 0x8f, 0xc5 , 0xc5) + +#define UPPERCASE_E_ACUTE CHOOSE( 0x90, 0xc9 , 0xc9) +#define LOWERCASE_AE_LIGATURE CHOOSE( 0x91, 0xe6 , 0xe6) +#define UPPERCASE_AE_LIGATURE CHOOSE( 0x92, 0xc6 , 0xc6) +#define LOWERCASE_O_CIRCUMFLEX CHOOSE( 0x93, 0xf4 , 0xf4) +#define LOWERCASE_O_UMLAUT CHOOSE( 0x94, 0xf6 , 0xf6) +#define LOWERCASE_O_GRAVE CHOOSE( 0x95, 0xf2 , 0xf2) +#define LOWERCASE_U_CIRCUMFLEX CHOOSE( 0x96, 0xfb , 0xfb) +#define LOWERCASE_U_GRAVE CHOOSE( 0x97, 0xf9 , 0xf9) +#define LOWERCASE_Y_UMLAUT CHOOSE( 0x98, 0xff , 0xff) +#define UPPERCASE_O_UMLAUT CHOOSE( 0x99, 0xd6 , 0xd6) +#define UPPERCASE_U_UMLAUT CHOOSE( 0x9a, 0xdc , 0xdc) +#define CENT_SIGN CHOOSE( 0x9b, 0xa2 , 0xa2) +#define STERLING_SIGN CHOOSE( 0x9c, 0xa3 , 30) +#define YEN_SIGN CHOOSE( 0x9d, 0xa5 , 0xa5) +#define PESETA_SIGN CHOOSE( 0x9e, 0x20a7, TBD) +#define F_WITH_HOOK CHOOSE( 0x9f, 0x0192, TBD) + +#define LOWERCASE_A_ACUTE CHOOSE( 0xa0, 0xe1 , 0xe1) +#define LOWERCASE_I_ACUTE CHOOSE( 0xa1, 0xed , 0xed) +#define LOWERCASE_O_ACUTE CHOOSE( 0xa2, 0xf3 , 0xf3) +#define LOWERCASE_U_ACUTE CHOOSE( 0xa3, 0xfa , 0xfa) +#define LOWERCASE_N_TILDE CHOOSE( 0xa4, 0xf1 , 0xf1) +#define UPPERCASE_N_TILDE CHOOSE( 0xa5, 0xd1 , 0xd1) +#define A_ORDINAL CHOOSE( 0xa6, 0xaa , 0xaa) +#define O_ORDINAL CHOOSE( 0xa7, 0xba , 0xba) +#define INVERTED_QUESTION_MARK CHOOSE( 0xa8, 0xbf , 0xbf) +#define REVERSED_NOT_SIGN CHOOSE( 0xa9, 0x2310, TBD) +#define NOT_SIGN CHOOSE( 0xaa, 0xac , 0xac) +#define VULGAR_HALF CHOOSE( 0xab, 0xbd , 0xbd) +#define VULGAR_QUARTER CHOOSE( 0xac, 0xbc , 0xbc) +#define INVERTED_EXCLAMATION_MARK CHOOSE( 0xad, 0xa1 , 0xa1) +#define LEFT_ANGLE_QUOTE_MARK CHOOSE( 0xae, 0xab , 0xab) +#define RIGHT_ANGLE_QUOTE_MARK CHOOSE( 0xaf, 0xbb , 0xbb) + +#define LIGHT_SHADE CHOOSE( 0xb0, 0x2591, '#' ) +#define MEDIUM_SHADE CHOOSE( 0xb1, 0x2592, 2) +#define DARK_SHADE CHOOSE( 0xb2, 0x2593, TBD) +#define BOX_VLINE CHOOSE( 0xb3, 0x2502, 25) +#define BOX_RTEE CHOOSE( 0xb4, 0x2524, 22) +#define BOX_SD_RTEE CHOOSE( 0xb5, 0x2561, 22) +#define BOX_DS_RTEE CHOOSE( 0xb6, 0x2562, 22) +#define BOX_DS_URCORNER CHOOSE( 0xb7, 0x2556, 12) +#define BOX_SD_URCORNER CHOOSE( 0xb8, 0x2555, 12) +#define BOX_D_RTEE CHOOSE( 0xb9, 0x2563, 22) +#define BOX_D_VLINE CHOOSE( 0xba, 0x2551, 25) +#define BOX_D_URCORNER CHOOSE( 0xbb, 0x2557, 12) +#define BOX_D_LRCORNER CHOOSE( 0xbc, 0x255D, 11) +#define BOX_DS_LRCORNER CHOOSE( 0xbd, 0x255c, 11) +#define BOX_SD_LRCORNER CHOOSE( 0xbe, 0x255b, 11) +#define BOX_URCORNER CHOOSE( 0xbf, 0x2510, 12) + +#define BOX_LLCORNER CHOOSE( 0xc0, 0x2514, 14) +#define BOX_BTEE CHOOSE( 0xc1, 0x2534, 23) +#define BOX_TTEE CHOOSE( 0xc2, 0x252c, 24) +#define BOX_LTEE CHOOSE( 0xc3, 0x251c, 21) +#define BOX_HLINE CHOOSE( 0xc4, 0x2500, 18) +#define BOX_PLUS CHOOSE( 0xc5, 0x253c, 15) +#define BOX_SD_LTEE CHOOSE( 0xc6, 0x255e, 21) +#define BOX_DS_LTEE CHOOSE( 0xc7, 0x255f, 21) +#define BOX_D_LLCORNER CHOOSE( 0xc8, 0x255A, 14) +#define BOX_D_ULCORNER CHOOSE( 0xc9, 0x2554, 13) +#define BOX_D_BTEE CHOOSE( 0xca, 0x2569, 23) +#define BOX_D_TTEE CHOOSE( 0xcb, 0x2566, 24) +#define BOX_D_LTEE CHOOSE( 0xcc, 0x2560, 21) +#define BOX_D_HLINE CHOOSE( 0xcd, 0x2550, 18) +#define BOX_D_PLUS CHOOSE( 0xce, 0x256C, 15) +#define BOX_SD_BTEE CHOOSE( 0xcf, 0x2567, 23) + +#define BOX_DS_BTEE CHOOSE( 0xd0, 0x2568, 23) +#define BOX_SD_TTEE CHOOSE( 0xd1, 0x2564, 24) +#define BOX_DS_TTEE CHOOSE( 0xd2, 0x2565, 24) +#define BOX_DS_LLCORNER CHOOSE( 0xd3, 0x2559, 14) +#define BOX_SD_LLCORNER CHOOSE( 0xd4, 0x2558, 14) +#define BOX_SD_ULCORNER CHOOSE( 0xd5, 0x2552, 13) +#define BOX_DS_ULCORNER CHOOSE( 0xd6, 0x2553, 13) +#define BOX_DS_PLUS CHOOSE( 0xd7, 0x256b, 15) +#define BOX_SD_PLUS CHOOSE( 0xd8, 0x256a, 15) +#define BOX_LRCORNER CHOOSE( 0xd9, 0x2518, 11) +#define BOX_ULCORNER CHOOSE( 0xda, 0x250c, 13) +#define FULL_BLOCK CHOOSE( 0xdb, 0x2588, 0) +#define LOWER_HALF_BLOCK CHOOSE( 0xdc, 0x2584, TBD) +#define LEFT_HALF_BLOCK CHOOSE( 0xdd, 0x258c, TBD) +#define RIGHT_HALF_BLOCK CHOOSE( 0xde, 0x2590, TBD) +#define UPPER_HALF_BLOCK CHOOSE( 0xdf, 0x2580, TBD) + +#define ALPHA CHOOSE( 0xe0, 0x03b1, TBD) +#define BETA CHOOSE( 0xe1, 0x00df, TBD) +#define GAMMA CHOOSE( 0xe2, 0x0393, TBD) +#define PI CHOOSE( 0xe3, 0x03c0, 28) +#define UPPERCASE_SIGMA CHOOSE( 0xe4, 0x03a3, TBD) +#define LOWERCASE_SIGMA CHOOSE( 0xe5, 0x03c3, TBD) +#define MU CHOOSE( 0xe6, 0x00b5, 0xb5) +#define TAU CHOOSE( 0xe7, 0x03c4, TBD) +#define UPPERCASE_PHI CHOOSE( 0xe8, 0x03a6, TBD) +#define THETA CHOOSE( 0xe9, 0x0398, TBD) +#define OMEGA CHOOSE( 0xea, 0x03a9, TBD) +#define DELTA CHOOSE( 0xeb, 0x03b4, TBD) +#define INFINITY_SIGN CHOOSE( 0xec, 0x221e, TBD) +#define LOWERCASE_PHI CHOOSE( 0xed, 0x03c6, TBD) +#define EPSILON CHOOSE( 0xee, 0x03b5, TBD) +#define INTERSECTION CHOOSE( 0xef, 0x2229, TBD) + +#define TRIPLE_BAR CHOOSE( 0xf0, 0x2261, TBD) +#define PLUS_OR_MINUS CHOOSE( 0xf1, 0x00b1, 8) +#define GREATER_THAN_OR_EQUAL_TO CHOOSE( 0xf2, 0x2265, 27) +#define LESSER_THAN_OR_EQUAL_TO CHOOSE( 0xf3, 0x2264, 26) +#define UPPER_HALF_INTEGRAL_SIGN CHOOSE( 0xf4, 0x2320, TBD) +#define LOWER_HALF_INTEGRAL_SIGN CHOOSE( 0xf5, 0x2321, TBD) +#define DIVISION_SIGN CHOOSE( 0xf6, 0x00f7, 0xf7) +#define APPROXIMATELY_EQUALS_SIGN CHOOSE( 0xf7, 0x2248, TBD) +#define DEGREE_SIGN CHOOSE( 0xf8, 0x00b0, 0xb0) +#define LARGE_BULLET CHOOSE( 0xf9, 0x2219, 7) +#define SMALL_BULLET CHOOSE( 0xfa, 0x00b7, 0xb7) +#define SQUARE_ROOT CHOOSE( 0xfb, 0x221a, TBD) +#define SUPERSCRIPT_N CHOOSE( 0xfc, 0x207f, TBD) +#define SUPERSCRIPT_2 CHOOSE( 0xfd, 0x00b2, 0xb2) +#define CENTERED_SQUARE CHOOSE( 0xfe, 0x25a0, TBD) +#define NON_BREAKING_SPACE CHOOSE( 0xff, 0x00a0, TBD) + + + + /* It says at http://unicode.org/charts/PDF/U2300.pdf */ + /* that '...the scan line numbers here refer to old, */ + /* low-resolution technology for terminals, with only */ + /* nine scan lines per fixed-size character glyph. */ + /* Even-numbered scan lines are unified with box */ + /* drawing graphics." */ + /* The utility of these is questionable; they'd */ + /* work Just Fine in wingdi (_if_ the appropriate */ + /* glyphs are available), but not elsewhere. */ +#define HORIZ_SCAN_LINE_1 CHOOSE( 0x2d, 0x23ba, 16) +#define HORIZ_SCAN_LINE_3 CHOOSE( 0x2d, 0x23bb, 17) +#define HORIZ_SCAN_LINE_7 CHOOSE( 0x2d, 0x23bc, 19) +#define HORIZ_SCAN_LINE_9 CHOOSE( '_', 0x23bd, 20) + + /* Code page 437 lacks a 'for real' not-equals, so for that, */ + /* we use the double-horizontal single-vertical box drawing : */ +#define NOT_EQUALS_SIGN CHOOSE( 0xd8, 0x2260, 29) + +# define A(x) ((chtype)x | A_ALTCHARSET) + +chtype acs_map[128] = +{ + A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), + A(9), A(10), + CLUB, HEART, SPADE, SMILE, REV_SMILE, /* 11 12 13 14 15 */ + MEDIUM_BULLET, WHITE_BULLET, PILCROW, SECTION_SIGN, /* 16 17 18 19 */ + A_ORDINAL, O_ORDINAL, LOWERCASE_PHI, /* 20 21 22 */ + INVERTED_EXCLAMATION_MARK, INVERTED_QUESTION_MARK, /* 23 24 */ + REVERSED_NOT_SIGN, NOT_SIGN, /* 25 26 */ + UPPER_HALF_INTEGRAL_SIGN, LOWER_HALF_INTEGRAL_SIGN, /* 27 28 */ + SUPERSCRIPT_N, CENTERED_SQUARE, F_WITH_HOOK, /* 29 30 31 */ + + RIGHT_ARROW, LEFT_ARROW, UP_ARROW, DOWN_ARROW, /* 32 !"# */ + + PI, NOT_EQUALS_SIGN, VULGAR_HALF, VULGAR_QUARTER, /* $%&' */ + '(', + LEFT_ANGLE_QUOTE_MARK, RIGHT_ANGLE_QUOTE_MARK, /* )* */ + DARK_SHADE, SUPERSCRIPT_2, INFINITY_SIGN, /* +,- */ + ALPHA, BETA, GAMMA, UPPERCASE_SIGMA, LOWERCASE_SIGMA, /* ./012 */ + '3', + MU, TAU, UPPERCASE_PHI, THETA, OMEGA, DELTA, EPSILON, /* 456789: */ + + BOX_SD_LRCORNER, BOX_SD_URCORNER, BOX_SD_ULCORNER, /* ;<= */ + BOX_SD_LLCORNER, BOX_SD_PLUS, /* >? */ + BOX_SD_LTEE, BOX_SD_RTEE, BOX_SD_BTEE, BOX_SD_TTEE, /* @ABC */ + + BOX_D_LRCORNER, BOX_D_URCORNER, BOX_D_ULCORNER, /* DEF */ + BOX_D_LLCORNER, BOX_D_PLUS, /* GH */ + BOX_D_LTEE, BOX_D_RTEE, BOX_D_BTEE, BOX_D_TTEE, /* IJKL */ + + BOX_DS_LRCORNER, BOX_DS_URCORNER, BOX_DS_ULCORNER, /* MNO */ + BOX_DS_LLCORNER, BOX_DS_PLUS, /* PQ */ + BOX_DS_LTEE, BOX_DS_RTEE, BOX_DS_BTEE, BOX_DS_TTEE, /* RSTU */ + + BOX_LRCORNER, BOX_URCORNER, BOX_ULCORNER, /* VWX */ + BOX_LLCORNER, BOX_PLUS, /* YZ */ + BOX_LTEE, BOX_RTEE, BOX_BTEE, BOX_TTEE, /* [\]^ */ + + BOX_HLINE, BOX_VLINE, BOX_D_HLINE, BOX_D_VLINE, /* _`ab */ + + DIVISION_SIGN, APPROXIMATELY_EQUALS_SIGN, /* cd */ + INTERSECTION, TRIPLE_BAR, /* ef */ + SMALL_BULLET, LARGE_BULLET, SQUARE_ROOT, /* ghi */ + DIAMOND, MEDIUM_SHADE, /* jk */ + HORIZ_SCAN_LINE_1, HORIZ_SCAN_LINE_3, /* lm */ + HORIZ_SCAN_LINE_7, HORIZ_SCAN_LINE_9, /* no */ + UPPER_HALF_BLOCK, LOWER_HALF_BLOCK, /* pq */ + LEFT_HALF_BLOCK, RIGHT_HALF_BLOCK, FULL_BLOCK, /* rst */ + LESSER_THAN_OR_EQUAL_TO, GREATER_THAN_OR_EQUAL_TO, /* uv */ + DEGREE_SIGN, PLUS_OR_MINUS, LIGHT_SHADE, SPLAT, /* wxyz */ + CENT_SIGN, YEN_SIGN, PESETA_SIGN, STERLING_SIGN, /* {|}~ */ + A(127) +}; + +# undef A diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h new file mode 100644 index 000000000..9ee3f08a6 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h @@ -0,0 +1,1846 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES__ +#define __PDCURSES__ 1 + +/*man-start************************************************************** + +PDCurses definitions list: (Only define those needed) + + XCURSES True if compiling for X11. + PDC_RGB True if you want to use RGB color definitions + (Red = 1, Green = 2, Blue = 4) instead of BGR. + PDC_WIDE True if building wide-character support. + PDC_DLL_BUILD True if building a Windows DLL. + PDC_NCMOUSE Use the ncurses mouse API instead + of PDCurses' traditional mouse API. + +PDCurses portable platform definitions list: + + PDC_BUILD Defines API build version. + PDCURSES Enables access to PDCurses-only routines. + XOPEN Always true. + SYSVcurses True if you are compiling for SYSV portability. + BSDcurses True if you are compiling for BSD portability. + +**man-end****************************************************************/ + +#define PDCURSES 1 /* PDCurses-only routines */ +#define XOPEN 1 /* X/Open Curses routines */ +#define SYSVcurses 1 /* System V Curses routines */ +#define BSDcurses 1 /* BSD Curses routines */ +#if defined( CHTYPE_32) + #define CHTYPE_LONG 1 /* chtypes will be 32 bits */ +#elif !defined( CHTYPE_16) + #define CHTYPE_LONG 2 /* chtypes will be (default) 64 bits */ +#endif + +/*----------------------------------------------------------------------*/ + +#ifdef NO_STDINT_H + #define uint64_t unsigned long long + #define uint32_t unsigned long + #define uint16_t unsigned short +#else + #include +#endif +#include +#include +#include /* Required by X/Open usage below */ + +#ifdef PDC_WIDE +# include +#endif + +#if defined(__STDC_VERSION__) && __STDC_VERSION >= 199901L && \ + !defined(__bool_true_false_are_defined) +# include +#endif + +#ifdef __cplusplus +extern "C" +{ +# define bool _bool +#endif + +/*---------------------------------------------------------------------- + * + * Constants and Types + * + */ + +#undef FALSE +#undef TRUE + +#ifdef __bool_true_false_are_defined + +# define FALSE false +# define TRUE true + +#else + +typedef unsigned char bool; + +# define FALSE 0 +# define TRUE 1 + +#endif + +#undef ERR +#define ERR (-1) + +#undef OK +#define OK 0 + +#ifdef CHTYPE_LONG + #if(CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes */ + typedef uint64_t chtype; + #else /* "Standard" CHTYPE_LONG case, 32-bit: */ + typedef uint32_t chtype; + # endif +#else +typedef uint16_t chtype; /* 8-bit attr + 8-bit char */ +#endif + +#ifdef PDC_WIDE +typedef chtype cchar_t; +#endif + +typedef chtype attr_t; + +/* Version constants, available as of version 4.0 : */ +/* Don't forget to update 'version.mif' if MAJOR/MINOR changes! */ + +#define PDC_VER_MAJOR 4 +#define PDC_VER_MINOR 0 +#define PDC_VER_CHANGE 4 +#define PDC_VER_YEAR 2019 +#define PDC_VER_MONTH 1 +#define PDC_VER_DAY 20 + +#define PDC_BUILD (PDC_VER_MAJOR*1000 + PDC_VER_MINOR *100 + PDC_VER_CHANGE) + +/* When using PDCurses as a DLL (Windows) or shared library (BSD or *nix), +it's possible to switch the DLL or shared library. One may therefore want +to inquire of the DLL/shared library the port, version numbers, and +chtype_size used, and make sure they're what one was expecting. The +'PDC_version' structure lets you do just that. */ + +enum PDC_port +{ + PDC_PORT_X11 = 0, + PDC_PORT_WIN32 = 1, + PDC_PORT_WINGUI = 2, + PDC_PORT_DOS = 3, + PDC_PORT_OS2 = 4, + PDC_PORT_SDL1 = 5, + PDC_PORT_SDL2 = 6, + PDC_PORT_VT = 7 +}; + +/* Detailed PDC version information */ +#define PDC_HAS_VERSION_INFO 1 +typedef struct +{ + const enum PDC_port port; + const int ver_major; + const int ver_minor; + const int ver_change; + const size_t chtype_size; + const bool is_wide; + const bool is_forced_utf8; +} PDC_version_info; + +/*---------------------------------------------------------------------- + * + * Mouse Interface -- SYSVR4, with extensions + * + */ + +/* Most flavors of PDCurses support three buttons. WinGUI supports */ +/* these plus two "extended" buttons. But we'll set this macro to */ +/* six, allowing future versions to support up to nine total buttons. */ +/* (The button states are broken up into two arrays to allow for the */ +/* possibility of backward compatibility to DLLs compiled with only */ +/* three mouse buttons.) */ + +#define PDC_MAX_MOUSE_BUTTONS 9 +#define PDC_N_EXTENDED_MOUSE_BUTTONS 6 + +typedef struct +{ + int x; /* absolute column, 0 based, measured in characters */ + int y; /* absolute row, 0 based, measured in characters */ + short button[3]; /* state of three "normal" buttons */ + int changes; /* flags indicating what has changed with the mouse */ + short xbutton[PDC_N_EXTENDED_MOUSE_BUTTONS]; /* state of ext buttons */ +} MOUSE_STATUS; + +#define BUTTON_RELEASED 0x0000 +#define BUTTON_PRESSED 0x0001 +#define BUTTON_CLICKED 0x0002 +#define BUTTON_DOUBLE_CLICKED 0x0003 +#define BUTTON_TRIPLE_CLICKED 0x0004 +#define BUTTON_MOVED 0x0005 /* PDCurses */ +#define WHEEL_SCROLLED 0x0006 /* PDCurses */ +#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */ + +#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */ +#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */ +#define PDC_BUTTON_ALT 0x0020 /* PDCurses */ +#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */ + +#define MOUSE_X_POS (Mouse_status.x) +#define MOUSE_Y_POS (Mouse_status.y) + +/* + * Bits associated with the .changes field: + * 3 2 1 0 + * 210987654321098765432109876543210 + * 1 <- button 1 has changed 0 + * 10 <- button 2 has changed 1 + * 100 <- button 3 has changed 2 + * 1000 <- mouse has moved 3 + * 10000 <- mouse position report 4 + * 100000 <- mouse wheel up 5 + * 1000000 <- mouse wheel down 6 + * 10000000 <- mouse wheel left 7 + * 100000000 <- mouse wheel right 8 + * 1000000000 <- button 4 has changed 9 + * (NOTE: buttons 6 to 10000000000 <- button 5 has changed 10 + * 9 aren't implemented 100000000000 <- button 6 has changed 11 + * in any flavor of 1000000000000 <- button 7 has changed 12 + * PDCurses yet!) 10000000000000 <- button 8 has changed 13 + * 100000000000000 <- button 9 has changed 14 + */ + +#define PDC_MOUSE_MOVED 0x0008 +#define PDC_MOUSE_POSITION 0x0010 +#define PDC_MOUSE_WHEEL_UP 0x0020 +#define PDC_MOUSE_WHEEL_DOWN 0x0040 +#define PDC_MOUSE_WHEEL_LEFT 0x0080 +#define PDC_MOUSE_WHEEL_RIGHT 0x0100 + +#define A_BUTTON_CHANGED (Mouse_status.changes & 7) +#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED) +#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION) +#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - ((x)<4 ? 1 : -5)))) +#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1]) +#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP) +#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN) +#define MOUSE_WHEEL_LEFT (Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT) +#define MOUSE_WHEEL_RIGHT (Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT) + +/* mouse bit-masks */ + +#define BUTTON1_RELEASED 0x00000001L +#define BUTTON1_PRESSED 0x00000002L +#define BUTTON1_CLICKED 0x00000004L +#define BUTTON1_DOUBLE_CLICKED 0x00000008L +#define BUTTON1_TRIPLE_CLICKED 0x00000010L +#define BUTTON1_MOVED 0x00000010L /* PDCurses */ + +#define BUTTON2_RELEASED 0x00000020L +#define BUTTON2_PRESSED 0x00000040L +#define BUTTON2_CLICKED 0x00000080L +#define BUTTON2_DOUBLE_CLICKED 0x00000100L +#define BUTTON2_TRIPLE_CLICKED 0x00000200L +#define BUTTON2_MOVED 0x00000200L /* PDCurses */ + +#define BUTTON3_RELEASED 0x00000400L +#define BUTTON3_PRESSED 0x00000800L +#define BUTTON3_CLICKED 0x00001000L +#define BUTTON3_DOUBLE_CLICKED 0x00002000L +#define BUTTON3_TRIPLE_CLICKED 0x00004000L +#define BUTTON3_MOVED 0x00004000L /* PDCurses */ + +/* For the ncurses-compatible functions only, BUTTON4_PRESSED and + BUTTON5_PRESSED are returned for mouse scroll wheel up and down; + otherwise PDCurses doesn't support buttons 4 and 5... except + as described above for WinGUI, and perhaps to be extended to + other PDCurses flavors */ + +#define BUTTON4_RELEASED 0x00008000L +#define BUTTON4_PRESSED 0x00010000L +#define BUTTON4_CLICKED 0x00020000L +#define BUTTON4_DOUBLE_CLICKED 0x00040000L +#define BUTTON4_TRIPLE_CLICKED 0x00080000L + +#define BUTTON5_RELEASED 0x00100000L +#define BUTTON5_PRESSED 0x00200000L +#define BUTTON5_CLICKED 0x00400000L +#define BUTTON5_DOUBLE_CLICKED 0x00800000L +#define BUTTON5_TRIPLE_CLICKED 0x01000000L + +#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */ +#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */ +#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */ +#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */ + +#define ALL_MOUSE_EVENTS 0x1fffffffL +#define REPORT_MOUSE_POSITION 0x20000000L + +/* ncurses mouse interface */ + +typedef unsigned long mmask_t; + +typedef struct +{ + short id; /* unused, always 0 */ + int x, y, z; /* x, y same as MOUSE_STATUS; z unused */ + mmask_t bstate; /* equivalent to changes + button[], but + in the same format as used for mousemask() */ +} MEVENT; + +#if defined(PDC_NCMOUSE) && !defined(NCURSES_MOUSE_VERSION) +# define NCURSES_MOUSE_VERSION 2 +#endif + +#ifdef NCURSES_MOUSE_VERSION +# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT +# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL +# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL +# define BUTTON_ALT BUTTON_MODIFIER_ALT +#else +# define BUTTON_SHIFT PDC_BUTTON_SHIFT +# define BUTTON_CONTROL PDC_BUTTON_CONTROL +# define BUTTON_ALT PDC_BUTTON_ALT +#endif + +/*---------------------------------------------------------------------- + * + * Window and Screen Structures + * + */ + +typedef struct _win /* definition of a window */ +{ + int _cury; /* current pseudo-cursor */ + int _curx; + int _maxy; /* max window coordinates */ + int _maxx; + int _begy; /* origin on screen */ + int _begx; + int _flags; /* window properties */ + chtype _attrs; /* standard attributes and colors */ + chtype _bkgd; /* background, normally blank */ + bool _clear; /* causes clear at next refresh */ + bool _leaveit; /* leaves cursor where it is */ + bool _scroll; /* allows window scrolling */ + bool _nodelay; /* input character wait flag */ + bool _immed; /* immediate update flag */ + bool _sync; /* synchronise window ancestors */ + bool _use_keypad; /* flags keypad key mode active */ + chtype **_y; /* pointer to line pointer array */ + int *_firstch; /* first changed character in line */ + int *_lastch; /* last changed character in line */ + int _tmarg; /* top of scrolling region */ + int _bmarg; /* bottom of scrolling region */ + int _delayms; /* milliseconds of delay for getch() */ + int _parx, _pary; /* coords relative to parent (0,0) */ + struct _win *_parent; /* subwin's pointer to parent win */ +} WINDOW; + +/* Avoid using the SCREEN struct directly -- use the corresponding + functions if possible. This struct may eventually be made private. */ + +typedef struct +{ + bool alive; /* if initscr() called, and not endwin() */ + bool autocr; /* if cr -> lf */ + bool cbreak; /* if terminal unbuffered */ + bool echo; /* if terminal echo */ + bool raw_inp; /* raw input mode (v. cooked input) */ + bool raw_out; /* raw output mode (7 v. 8 bits) */ + bool audible; /* FALSE if the bell is visual */ + bool mono; /* TRUE if current screen is mono */ + bool resized; /* TRUE if TERM has been resized */ + bool orig_attr; /* TRUE if we have the original colors */ + short orig_fore; /* original screen foreground color */ + short orig_back; /* original screen foreground color */ + int cursrow; /* position of physical cursor */ + int curscol; /* position of physical cursor */ + int visibility; /* visibility of cursor */ + int orig_cursor; /* original cursor size */ + int lines; /* new value for LINES */ + int cols; /* new value for COLS */ + unsigned long _trap_mbe; /* trap these mouse button events */ + unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ + int mouse_wait; /* time to wait (in ms) for a + button release after a press, in + order to count it as a click */ + int slklines; /* lines in use by slk_init() */ + WINDOW *slk_winptr; /* window for slk */ + int linesrippedoff; /* lines ripped off via ripoffline() */ + int linesrippedoffontop; /* lines ripped off on + top via ripoffline() */ + int delaytenths; /* 1/10ths second to wait block + getch() for */ + bool _preserve; /* TRUE if screen background + to be preserved */ + int _restore; /* specifies if screen background + to be restored, and how */ + bool save_key_modifiers; /* TRUE if each key modifiers saved + with each key press */ + bool return_key_modifiers; /* TRUE if modifier keys are + returned as "real" keys */ + bool key_code; /* TRUE if last key is a special key; + used internally by get_wch() */ +#ifdef XCURSES + int XcurscrSize; /* size of Xcurscr shared memory block */ + bool sb_on; + int sb_viewport_y; + int sb_viewport_x; + int sb_total_y; + int sb_total_x; + int sb_cur_y; + int sb_cur_x; + int exit_key; +#endif + short line_color; /* color of line attributes - default -1 */ +} SCREEN; + +/*---------------------------------------------------------------------- + * + * External Variables + * + */ + +#ifdef PDC_DLL_BUILD +# ifdef CURSES_LIBRARY +# define PDCEX __declspec(dllexport) extern +# else +# define PDCEX __declspec(dllimport) +# endif +#else +# define PDCEX extern +#endif + +PDCEX int LINES; /* terminal height */ +PDCEX int COLS; /* terminal width */ +PDCEX WINDOW *stdscr; /* the default screen window */ +PDCEX WINDOW *curscr; /* the current screen image */ +PDCEX SCREEN *SP; /* curses variables */ +PDCEX MOUSE_STATUS Mouse_status; +PDCEX int COLORS; +PDCEX int COLOR_PAIRS; +PDCEX int TABSIZE; +PDCEX chtype acs_map[]; /* alternate character set map */ +PDCEX char ttytype[]; /* terminal name/description */ +PDCEX PDC_version_info PDC_version; + +/*man-start************************************************************** + +Text Attributes +=============== + +Originally, PDCurses used a short (16 bits) for its chtype. To include +color, a number of things had to be sacrificed from the strict Unix and +System V support. The main problem was fitting all character attributes +and color into an unsigned char (all 8 bits!). + +Today, PDCurses by default uses a long (32 bits) for its chtype, as in +System V. The short chtype is still available, by undefining CHTYPE_LONG +and rebuilding the library. + +The following is the structure of a win->_attrs chtype: + +short form: + + +-----------------------------------------------+ + |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| + +-----------------------------------------------+ + color number | attrs | character eg 'a' + +The available non-color attributes are bold, reverse and blink. Others +have no effect. The high order char is an index into an array of +physical colors (defined in color.c) -- 32 foreground/background color +pairs (5 bits) plus 3 bits for other attributes. + +long form: + + +--------------------------------------------------------------------+ + |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0| + +--------------------------------------------------------------------+ + color number | modifiers | character eg 'a' + +The available non-color attributes are bold, underline, invisible, +right-line, left-line, protect, reverse and blink. 256 color pairs (8 +bits), 8 bits for other attributes, and 16 bits for character data. + + Note that there is now a "super-long" 64-bit form, available by +defining CHTYPE_LONG to be 2: + +------------------------------------------------------------------------------- +|63|62|61|60|59|..|34|33|32|31|30|29|28|..|22|21|20|19|18|17|16|..| 3| 2| 1| 0| +------------------------------------------------------------------------------- + color number | modifiers | character eg 'a' + + + We take five more bits for the character (thus allowing Unicode values +past 64K; UTF-16 can go up to 0x10ffff, requiring 21 bits total), and +four more bits for attributes. Three are currently used as A_OVERLINE, A_DIM, +and A_STRIKEOUT; one more is reserved for future use. 31 bits are then used +for color. These are usually just treated as the usual palette +indices, and range from 0 to 255. However, if bit 63 is +set, the remaining 30 bits are interpreted as foreground RGB (first +fifteen bits, five bits for each of the three channels) and background RGB +(same scheme using the remaining 15 bits.) + +**man-end****************************************************************/ + +/*** Video attribute macros ***/ + +#define A_NORMAL (chtype)0 + +#ifdef CHTYPE_LONG + +# if(CHTYPE_LONG >= 2) /* 64-bit chtypes */ + # define PDC_CHARTEXT_BITS 21 + # define A_CHARTEXT (chtype)( ((chtype)0x1 << PDC_CHARTEXT_BITS) - 1) + # define A_ALTCHARSET ((chtype)0x001 << PDC_CHARTEXT_BITS) + # define A_RIGHTLINE ((chtype)0x002 << PDC_CHARTEXT_BITS) + # define A_LEFTLINE ((chtype)0x004 << PDC_CHARTEXT_BITS) + # define A_INVIS ((chtype)0x008 << PDC_CHARTEXT_BITS) + # define A_UNDERLINE ((chtype)0x010 << PDC_CHARTEXT_BITS) + # define A_REVERSE ((chtype)0x020 << PDC_CHARTEXT_BITS) + # define A_BLINK ((chtype)0x040 << PDC_CHARTEXT_BITS) + # define A_BOLD ((chtype)0x080 << PDC_CHARTEXT_BITS) + # define A_OVERLINE ((chtype)0x100 << PDC_CHARTEXT_BITS) + # define A_STRIKEOUT ((chtype)0x200 << PDC_CHARTEXT_BITS) + # define A_DIM ((chtype)0x400 << PDC_CHARTEXT_BITS) +#if 0 + /* May come up with a use for this bit */ + /* someday; reserved for the future: */ + # define A_FUTURE_2 ((chtype)0x800 << PDC_CHARTEXT_BITS) +#endif + # define PDC_COLOR_SHIFT (PDC_CHARTEXT_BITS + 12) + # define A_COLOR ((chtype)0x7fffffff << PDC_COLOR_SHIFT) + # define A_RGB_COLOR ((chtype)0x40000000 << PDC_COLOR_SHIFT) + # define A_ATTRIBUTES (((chtype)0xfff << PDC_CHARTEXT_BITS) | A_COLOR) + # define A_RGB( rfore, gfore, bfore, rback, gback, bback) \ + (( (((chtype)(bfore) << 25) \ + | ((chtype)(gfore) << 20) \ + | ((chtype)(rfore) << 15) \ + | ((chtype)(bback) << 10) \ + | ((chtype)(gback) << 5) \ + | ((chtype)(rback) )) << PDC_COLOR_SHIFT) | A_RGB_COLOR) +# else /* plain ol' 32-bit chtypes */ + # define A_ALTCHARSET (chtype)0x00010000 + # define A_RIGHTLINE (chtype)0x00020000 + # define A_LEFTLINE (chtype)0x00040000 + # define A_INVIS (chtype)0x00080000 + # define A_UNDERLINE (chtype)0x00100000 + # define A_REVERSE (chtype)0x00200000 + # define A_BLINK (chtype)0x00400000 + # define A_BOLD (chtype)0x00800000 + # define A_COLOR (chtype)0xff000000 + # define A_RGB_COLOR A_NORMAL +#ifdef PDC_WIDE + # define A_CHARTEXT (chtype)0x0000ffff + # define A_ATTRIBUTES (chtype)0xffff0000 + # define A_DIM A_NORMAL + # define A_OVERLINE A_NORMAL + # define A_STRIKEOUT A_NORMAL +#else /* with 8-bit chars, we have bits for these attribs : */ + # define A_CHARTEXT (chtype)0x000000ff + # define A_ATTRIBUTES (chtype)0xffffe000 + # define A_DIM (chtype)0x00008000 + # define A_OVERLINE (chtype)0x00004000 + # define A_STRIKEOUT (chtype)0x00002000 +#endif + # define PDC_COLOR_SHIFT 24 +#endif + + +# define A_ITALIC A_INVIS +# define A_PROTECT (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE) + +#else /* 16-bit chtypes */ +# define A_BOLD (chtype)0x0100 /* X/Open */ +# define A_REVERSE (chtype)0x0200 /* X/Open */ +# define A_BLINK (chtype)0x0400 /* X/Open */ + +# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */ +# define A_CHARTEXT (chtype)0x00ff /* X/Open */ +# define A_COLOR (chtype)0xf800 /* System V */ + +# define A_ALTCHARSET A_NORMAL /* X/Open */ +# define A_PROTECT A_NORMAL /* X/Open */ +# define A_UNDERLINE A_NORMAL /* X/Open */ +# define A_OVERLINE A_NORMAL /* X/Open */ +# define A_STRIKEOUT A_NORMAL /* X/Open */ + +# define A_LEFTLINE A_NORMAL +# define A_RIGHTLINE A_NORMAL +# define A_ITALIC A_NORMAL +# define A_INVIS A_NORMAL +# define A_RGB_COLOR A_NORMAL +# define A_DIM A_NORMAL + +# define PDC_COLOR_SHIFT 11 +#endif + +#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */ + +#define CHR_MSK A_CHARTEXT /* Obsolete */ +#define ATR_MSK A_ATTRIBUTES /* Obsolete */ +#define ATR_NRM A_NORMAL /* Obsolete */ + +/* For use with attr_t -- X/Open says, "these shall be distinct", so + this is a non-conforming implementation. */ + +#define WA_NORMAL A_NORMAL + +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_BLINK A_BLINK +#define WA_BOLD A_BOLD +#define WA_DIM A_DIM +#define WA_INVIS A_INVIS +#define WA_LEFT A_LEFTLINE +#define WA_PROTECT A_PROTECT +#define WA_REVERSE A_REVERSE +#define WA_RIGHT A_RIGHTLINE +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE + +#define WA_HORIZONTAL A_NORMAL +#define WA_LOW A_NORMAL +#define WA_TOP A_NORMAL +#define WA_VERTICAL A_NORMAL + +#define WA_ATTRIBUTES A_ATTRIBUTES + +/*** Alternate character set macros ***/ + +/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET + 'n' = 16-bit chtype; it gets the fallback set because no bit is + available for A_ALTCHARSET */ + +#ifdef CHTYPE_LONG +# define PDC_ACS(w, n) ((chtype)w | A_ALTCHARSET) +#else +# define PDC_ACS(w, n) ((chtype)n) +#endif + +/* VT100-compatible symbols -- box chars */ + +#define ACS_LRCORNER PDC_ACS('V', '+') +#define ACS_URCORNER PDC_ACS('W', '+') +#define ACS_ULCORNER PDC_ACS('X', '+') +#define ACS_LLCORNER PDC_ACS('Y', '+') +#define ACS_PLUS PDC_ACS('Z', '+') +#define ACS_LTEE PDC_ACS('[', '+') +#define ACS_RTEE PDC_ACS('\\', '+') +#define ACS_BTEE PDC_ACS(']', '+') +#define ACS_TTEE PDC_ACS('^', '+') +#define ACS_HLINE PDC_ACS('_', '-') +#define ACS_VLINE PDC_ACS('`', '|') + +/* PDCurses-only ACS chars. Don't use if ncurses compatibility matters. +Some won't work in non-wide X11 builds (see 'acs_defs.h' for details). */ + +#define ACS_CENT PDC_ACS('{', 'c') +#define ACS_YEN PDC_ACS('|', 'y') +#define ACS_PESETA PDC_ACS('}', 'p') +#define ACS_HALF PDC_ACS('&', '/') +#define ACS_QUARTER PDC_ACS('\'', '/') +#define ACS_LEFT_ANG_QU PDC_ACS(')', '<') +#define ACS_RIGHT_ANG_QU PDC_ACS('*', '>') +#define ACS_D_HLINE PDC_ACS('a', '-') +#define ACS_D_VLINE PDC_ACS('b', '|') +#define ACS_CLUB PDC_ACS( 11, 'C') +#define ACS_HEART PDC_ACS( 12, 'H') +#define ACS_SPADE PDC_ACS( 13, 'S') +#define ACS_SMILE PDC_ACS( 14, 'O') +#define ACS_REV_SMILE PDC_ACS( 15, 'O') +#define ACS_MED_BULLET PDC_ACS( 16, '.') +#define ACS_WHITE_BULLET PDC_ACS( 17, 'O') +#define ACS_PILCROW PDC_ACS( 18, 'O') +#define ACS_SECTION PDC_ACS( 19, 'O') + +#define ACS_SUP2 PDC_ACS(',', '2') +#define ACS_ALPHA PDC_ACS('.', 'a') +#define ACS_BETA PDC_ACS('/', 'b') +#define ACS_GAMMA PDC_ACS('0', 'y') +#define ACS_UP_SIGMA PDC_ACS('1', 'S') +#define ACS_LO_SIGMA PDC_ACS('2', 's') +#define ACS_MU PDC_ACS('4', 'u') +#define ACS_TAU PDC_ACS('5', 't') +#define ACS_UP_PHI PDC_ACS('6', 'F') +#define ACS_THETA PDC_ACS('7', 't') +#define ACS_OMEGA PDC_ACS('8', 'w') +#define ACS_DELTA PDC_ACS('9', 'd') +#define ACS_INFINITY PDC_ACS('-', 'i') +#define ACS_LO_PHI PDC_ACS( 22, 'f') +#define ACS_EPSILON PDC_ACS(':', 'e') +#define ACS_INTERSECT PDC_ACS('e', 'u') +#define ACS_TRIPLE_BAR PDC_ACS('f', '=') +#define ACS_DIVISION PDC_ACS('c', '/') +#define ACS_APPROX_EQ PDC_ACS('d', '~') +#define ACS_SM_BULLET PDC_ACS('g', '.') +#define ACS_SQUARE_ROOT PDC_ACS('i', '!') +#define ACS_UBLOCK PDC_ACS('p', '^') +#define ACS_BBLOCK PDC_ACS('q', '_') +#define ACS_LBLOCK PDC_ACS('r', '<') +#define ACS_RBLOCK PDC_ACS('s', '>') + +#define ACS_A_ORDINAL PDC_ACS(20, 'a') +#define ACS_O_ORDINAL PDC_ACS(21, 'o') +#define ACS_INV_QUERY PDC_ACS(24, '?') +#define ACS_REV_NOT PDC_ACS(25, '!') +#define ACS_NOT PDC_ACS(26, '!') +#define ACS_INV_BANG PDC_ACS(23, '!') +#define ACS_UP_INTEGRAL PDC_ACS(27, '|') +#define ACS_LO_INTEGRAL PDC_ACS(28, '|') +#define ACS_SUP_N PDC_ACS(29, 'n') +#define ACS_CENTER_SQU PDC_ACS(30, 'x') +#define ACS_F_WITH_HOOK PDC_ACS(31, 'f') + +#define ACS_SD_LRCORNER PDC_ACS(';', '+') +#define ACS_SD_URCORNER PDC_ACS('<', '+') +#define ACS_SD_ULCORNER PDC_ACS('=', '+') +#define ACS_SD_LLCORNER PDC_ACS('>', '+') +#define ACS_SD_PLUS PDC_ACS('?', '+') +#define ACS_SD_LTEE PDC_ACS('@', '+') +#define ACS_SD_RTEE PDC_ACS('A', '+') +#define ACS_SD_BTEE PDC_ACS('B', '+') +#define ACS_SD_TTEE PDC_ACS('C', '+') + +#define ACS_D_LRCORNER PDC_ACS('D', '+') +#define ACS_D_URCORNER PDC_ACS('E', '+') +#define ACS_D_ULCORNER PDC_ACS('F', '+') +#define ACS_D_LLCORNER PDC_ACS('G', '+') +#define ACS_D_PLUS PDC_ACS('H', '+') +#define ACS_D_LTEE PDC_ACS('I', '+') +#define ACS_D_RTEE PDC_ACS('J', '+') +#define ACS_D_BTEE PDC_ACS('K', '+') +#define ACS_D_TTEE PDC_ACS('L', '+') + +#define ACS_DS_LRCORNER PDC_ACS('M', '+') +#define ACS_DS_URCORNER PDC_ACS('N', '+') +#define ACS_DS_ULCORNER PDC_ACS('O', '+') +#define ACS_DS_LLCORNER PDC_ACS('P', '+') +#define ACS_DS_PLUS PDC_ACS('Q', '+') +#define ACS_DS_LTEE PDC_ACS('R', '+') +#define ACS_DS_RTEE PDC_ACS('S', '+') +#define ACS_DS_BTEE PDC_ACS('T', '+') +#define ACS_DS_TTEE PDC_ACS('U', '+') + +/* VT100-compatible symbols -- other */ + +#define ACS_S1 PDC_ACS('l', '-') +#define ACS_S9 PDC_ACS('o', '_') +#define ACS_DIAMOND PDC_ACS('j', '+') +#define ACS_CKBOARD PDC_ACS('k', ':') +#define ACS_DEGREE PDC_ACS('w', '\'') +#define ACS_PLMINUS PDC_ACS('x', '#') +#define ACS_BULLET PDC_ACS('h', 'o') + +/* Teletype 5410v1 symbols -- these are defined in SysV curses, but + are not well-supported by most terminals. Stick to VT100 characters + for optimum portability. */ + +#define ACS_LARROW PDC_ACS('!', '<') +#define ACS_RARROW PDC_ACS(' ', '>') +#define ACS_DARROW PDC_ACS('#', 'v') +#define ACS_UARROW PDC_ACS('"', '^') +#define ACS_BOARD PDC_ACS('+', '#') +#define ACS_LTBOARD PDC_ACS('y', '#') +#define ACS_LANTERN PDC_ACS('z', '*') +#define ACS_BLOCK PDC_ACS('t', '#') + +/* That goes double for these -- undocumented SysV symbols. Don't use + them. */ + +#define ACS_S3 PDC_ACS('m', '-') +#define ACS_S7 PDC_ACS('n', '-') +#define ACS_LEQUAL PDC_ACS('u', '<') +#define ACS_GEQUAL PDC_ACS('v', '>') +#define ACS_PI PDC_ACS('$', 'n') +#define ACS_NEQUAL PDC_ACS('%', '+') +#define ACS_STERLING PDC_ACS('~', 'L') + +/* Box char aliases */ + +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +/* cchar_t aliases */ + +#ifdef PDC_WIDE +# define WACS_LRCORNER (&(acs_map['V'])) +# define WACS_URCORNER (&(acs_map['W'])) +# define WACS_ULCORNER (&(acs_map['X'])) +# define WACS_LLCORNER (&(acs_map['Y'])) +# define WACS_PLUS (&(acs_map['Z'])) +# define WACS_LTEE (&(acs_map['['])) +# define WACS_RTEE (&(acs_map['\\'])) +# define WACS_BTEE (&(acs_map[']'])) +# define WACS_TTEE (&(acs_map['^'])) +# define WACS_HLINE (&(acs_map['_'])) +# define WACS_VLINE (&(acs_map['`'])) + +# define WACS_CENT (&(acs_map['{'])) +# define WACS_YEN (&(acs_map['|'])) +# define WACS_PESETA (&(acs_map['}'])) +# define WACS_HALF (&(acs_map['&'])) +# define WACS_QUARTER (&(acs_map['\''])) +# define WACS_LEFT_ANG_QU (&(acs_map[')'])) +# define WACS_RIGHT_ANG_QU (&(acs_map['*'])) +# define WACS_D_HLINE (&(acs_map['a'])) +# define WACS_D_VLINE (&(acs_map['b'])) +# define WACS_CLUB (&(acs_map[ 11])) +# define WACS_HEART (&(acs_map[ 12])) +# define WACS_SPADE (&(acs_map[ 13])) +# define WACS_SMILE (&(acs_map[ 14])) +# define WACS_REV_SMILE (&(acs_map[ 15])) +# define WACS_MED_BULLET (&(acs_map[ 16])) +# define WACS_WHITE_BULLET (&(acs_map[ 17])) +# define WACS_PILCROW (&(acs_map[ 18])) +# define WACS_SECTION (&(acs_map[ 19])) + +# define WACS_SUP2 (&(acs_map[','])) +# define WACS_ALPHA (&(acs_map['.'])) +# define WACS_BETA (&(acs_map['/'])) +# define WACS_GAMMA (&(acs_map['0'])) +# define WACS_UP_SIGMA (&(acs_map['1'])) +# define WACS_LO_SIGMA (&(acs_map['2'])) +# define WACS_MU (&(acs_map['4'])) +# define WACS_TAU (&(acs_map['5'])) +# define WACS_UP_PHI (&(acs_map['6'])) +# define WACS_THETA (&(acs_map['7'])) +# define WACS_OMEGA (&(acs_map['8'])) +# define WACS_DELTA (&(acs_map['9'])) +# define WACS_INFINITY (&(acs_map['-'])) +# define WACS_LO_PHI (&(acs_map[ 22])) +# define WACS_EPSILON (&(acs_map[':'])) +# define WACS_INTERSECT (&(acs_map['e'])) +# define WACS_TRIPLE_BAR (&(acs_map['f'])) +# define WACS_DIVISION (&(acs_map['c'])) +# define WACS_APPROX_EQ (&(acs_map['d'])) +# define WACS_SM_BULLET (&(acs_map['g'])) +# define WACS_SQUARE_ROOT (&(acs_map['i'])) +# define WACS_UBLOCK (&(acs_map['p'])) +# define WACS_BBLOCK (&(acs_map['q'])) +# define WACS_LBLOCK (&(acs_map['r'])) +# define WACS_RBLOCK (&(acs_map['s'])) + +# define WACS_A_ORDINAL (&(acs_map[20])) +# define WACS_O_ORDINAL (&(acs_map[21])) +# define WACS_INV_QUERY (&(acs_map[24])) +# define WACS_REV_NOT (&(acs_map[25])) +# define WACS_NOT (&(acs_map[26])) +# define WACS_INV_BANG (&(acs_map[23])) +# define WACS_UP_INTEGRAL (&(acs_map[27])) +# define WACS_LO_INTEGRAL (&(acs_map[28])) +# define WACS_SUP_N (&(acs_map[29])) +# define WACS_CENTER_SQU (&(acs_map[30])) +# define WACS_F_WITH_HOOK (&(acs_map[31])) + +# define WACS_SD_LRCORNER (&(acs_map[';'])) +# define WACS_SD_URCORNER (&(acs_map['<'])) +# define WACS_SD_ULCORNER (&(acs_map['='])) +# define WACS_SD_LLCORNER (&(acs_map['>'])) +# define WACS_SD_PLUS (&(acs_map['?'])) +# define WACS_SD_LTEE (&(acs_map['@'])) +# define WACS_SD_RTEE (&(acs_map['A'])) +# define WACS_SD_BTEE (&(acs_map['B'])) +# define WACS_SD_TTEE (&(acs_map['C'])) + +# define WACS_D_LRCORNER (&(acs_map['D'])) +# define WACS_D_URCORNER (&(acs_map['E'])) +# define WACS_D_ULCORNER (&(acs_map['F'])) +# define WACS_D_LLCORNER (&(acs_map['G'])) +# define WACS_D_PLUS (&(acs_map['H'])) +# define WACS_D_LTEE (&(acs_map['I'])) +# define WACS_D_RTEE (&(acs_map['J'])) +# define WACS_D_BTEE (&(acs_map['K'])) +# define WACS_D_TTEE (&(acs_map['L'])) + +# define WACS_DS_LRCORNER (&(acs_map['M'])) +# define WACS_DS_URCORNER (&(acs_map['N'])) +# define WACS_DS_ULCORNER (&(acs_map['O'])) +# define WACS_DS_LLCORNER (&(acs_map['P'])) +# define WACS_DS_PLUS (&(acs_map['Q'])) +# define WACS_DS_LTEE (&(acs_map['R'])) +# define WACS_DS_RTEE (&(acs_map['S'])) +# define WACS_DS_BTEE (&(acs_map['T'])) +# define WACS_DS_TTEE (&(acs_map['U'])) + +# define WACS_S1 (&(acs_map['l'])) +# define WACS_S9 (&(acs_map['o'])) +# define WACS_DIAMOND (&(acs_map['j'])) +# define WACS_CKBOARD (&(acs_map['k'])) +# define WACS_DEGREE (&(acs_map['w'])) +# define WACS_PLMINUS (&(acs_map['x'])) +# define WACS_BULLET (&(acs_map['h'])) + + +# define WACS_LARROW (&(acs_map['!'])) +# define WACS_RARROW (&(acs_map[' '])) +# define WACS_DARROW (&(acs_map['#'])) +# define WACS_UARROW (&(acs_map['"'])) +# define WACS_BOARD (&(acs_map['+'])) +# define WACS_LTBOARD (&(acs_map['y'])) +# define WACS_LANTERN (&(acs_map['z'])) +# define WACS_BLOCK (&(acs_map['t'])) + +# define WACS_S3 (&(acs_map['m'])) +# define WACS_S7 (&(acs_map['n'])) +# define WACS_LEQUAL (&(acs_map['u'])) +# define WACS_GEQUAL (&(acs_map['v'])) +# define WACS_PI (&(acs_map['$'])) +# define WACS_NEQUAL (&(acs_map['%'])) +# define WACS_STERLING (&(acs_map['~'])) + +# define WACS_BSSB WACS_ULCORNER +# define WACS_SSBB WACS_LLCORNER +# define WACS_BBSS WACS_URCORNER +# define WACS_SBBS WACS_LRCORNER +# define WACS_SBSS WACS_RTEE +# define WACS_SSSB WACS_LTEE +# define WACS_SSBS WACS_BTEE +# define WACS_BSSS WACS_TTEE +# define WACS_BSBS WACS_HLINE +# define WACS_SBSB WACS_VLINE +# define WACS_SSSS WACS_PLUS +#endif + +/*** Color macros ***/ + +#define COLOR_BLACK 0 + +#ifdef PDC_RGB /* RGB */ +# define COLOR_RED 1 +# define COLOR_GREEN 2 +# define COLOR_BLUE 4 +#else /* BGR */ +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_RED 4 +#endif + +#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) +#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) +#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) + +#define COLOR_WHITE 7 + +/*---------------------------------------------------------------------- + * + * Function and Keypad Key Definitions + * Many are just for compatibility + * + */ + +#ifdef PDC_WIDE + #define KEY_OFFSET 0xec00 +#else + #define KEY_OFFSET 0x100 +#endif + +#define KEY_CODE_YES (KEY_OFFSET + 0x00) /* If get_wch() gives a key code */ + +#define KEY_BREAK (KEY_OFFSET + 0x01) /* Not on PC KBD */ +#define KEY_DOWN (KEY_OFFSET + 0x02) /* Down arrow key */ +#define KEY_UP (KEY_OFFSET + 0x03) /* Up arrow key */ +#define KEY_LEFT (KEY_OFFSET + 0x04) /* Left arrow key */ +#define KEY_RIGHT (KEY_OFFSET + 0x05) /* Right arrow key */ +#define KEY_HOME (KEY_OFFSET + 0x06) /* home key */ +#define KEY_BACKSPACE (KEY_OFFSET + 0x07) /* not on pc */ +#define KEY_F0 (KEY_OFFSET + 0x08) /* function keys; 64 reserved */ + +#define KEY_DL (KEY_OFFSET + 0x48) /* delete line */ +#define KEY_IL (KEY_OFFSET + 0x49) /* insert line */ +#define KEY_DC (KEY_OFFSET + 0x4a) /* delete character */ +#define KEY_IC (KEY_OFFSET + 0x4b) /* insert char or enter ins mode */ +#define KEY_EIC (KEY_OFFSET + 0x4c) /* exit insert char mode */ +#define KEY_CLEAR (KEY_OFFSET + 0x4d) /* clear screen */ +#define KEY_EOS (KEY_OFFSET + 0x4e) /* clear to end of screen */ +#define KEY_EOL (KEY_OFFSET + 0x4f) /* clear to end of line */ +#define KEY_SF (KEY_OFFSET + 0x50) /* scroll 1 line forward */ +#define KEY_SR (KEY_OFFSET + 0x51) /* scroll 1 line back (reverse) */ +#define KEY_NPAGE (KEY_OFFSET + 0x52) /* next page */ +#define KEY_PPAGE (KEY_OFFSET + 0x53) /* previous page */ +#define KEY_STAB (KEY_OFFSET + 0x54) /* set tab */ +#define KEY_CTAB (KEY_OFFSET + 0x55) /* clear tab */ +#define KEY_CATAB (KEY_OFFSET + 0x56) /* clear all tabs */ +#define KEY_ENTER (KEY_OFFSET + 0x57) /* enter or send (unreliable) */ +#define KEY_SRESET (KEY_OFFSET + 0x58) /* soft/reset (partial/unreliable) */ +#define KEY_RESET (KEY_OFFSET + 0x59) /* reset/hard reset (unreliable) */ +#define KEY_PRINT (KEY_OFFSET + 0x5a) /* print/copy */ +#define KEY_LL (KEY_OFFSET + 0x5b) /* home down/bottom (lower left) */ +#define KEY_ABORT (KEY_OFFSET + 0x5c) /* abort/terminate key (any) */ +#define KEY_SHELP (KEY_OFFSET + 0x5d) /* short help */ +#define KEY_LHELP (KEY_OFFSET + 0x5e) /* long help */ +#define KEY_BTAB (KEY_OFFSET + 0x5f) /* Back tab key */ +#define KEY_BEG (KEY_OFFSET + 0x60) /* beg(inning) key */ +#define KEY_CANCEL (KEY_OFFSET + 0x61) /* cancel key */ +#define KEY_CLOSE (KEY_OFFSET + 0x62) /* close key */ +#define KEY_COMMAND (KEY_OFFSET + 0x63) /* cmd (command) key */ +#define KEY_COPY (KEY_OFFSET + 0x64) /* copy key */ +#define KEY_CREATE (KEY_OFFSET + 0x65) /* create key */ +#define KEY_END (KEY_OFFSET + 0x66) /* end key */ +#define KEY_EXIT (KEY_OFFSET + 0x67) /* exit key */ +#define KEY_FIND (KEY_OFFSET + 0x68) /* find key */ +#define KEY_HELP (KEY_OFFSET + 0x69) /* help key */ +#define KEY_MARK (KEY_OFFSET + 0x6a) /* mark key */ +#define KEY_MESSAGE (KEY_OFFSET + 0x6b) /* message key */ +#define KEY_MOVE (KEY_OFFSET + 0x6c) /* move key */ +#define KEY_NEXT (KEY_OFFSET + 0x6d) /* next object key */ +#define KEY_OPEN (KEY_OFFSET + 0x6e) /* open key */ +#define KEY_OPTIONS (KEY_OFFSET + 0x6f) /* options key */ +#define KEY_PREVIOUS (KEY_OFFSET + 0x70) /* previous object key */ +#define KEY_REDO (KEY_OFFSET + 0x71) /* redo key */ +#define KEY_REFERENCE (KEY_OFFSET + 0x72) /* ref(erence) key */ +#define KEY_REFRESH (KEY_OFFSET + 0x73) /* refresh key */ +#define KEY_REPLACE (KEY_OFFSET + 0x74) /* replace key */ +#define KEY_RESTART (KEY_OFFSET + 0x75) /* restart key */ +#define KEY_RESUME (KEY_OFFSET + 0x76) /* resume key */ +#define KEY_SAVE (KEY_OFFSET + 0x77) /* save key */ +#define KEY_SBEG (KEY_OFFSET + 0x78) /* shifted beginning key */ +#define KEY_SCANCEL (KEY_OFFSET + 0x79) /* shifted cancel key */ +#define KEY_SCOMMAND (KEY_OFFSET + 0x7a) /* shifted command key */ +#define KEY_SCOPY (KEY_OFFSET + 0x7b) /* shifted copy key */ +#define KEY_SCREATE (KEY_OFFSET + 0x7c) /* shifted create key */ +#define KEY_SDC (KEY_OFFSET + 0x7d) /* shifted delete char key */ +#define KEY_SDL (KEY_OFFSET + 0x7e) /* shifted delete line key */ +#define KEY_SELECT (KEY_OFFSET + 0x7f) /* select key */ +#define KEY_SEND (KEY_OFFSET + 0x80) /* shifted end key */ +#define KEY_SEOL (KEY_OFFSET + 0x81) /* shifted clear line key */ +#define KEY_SEXIT (KEY_OFFSET + 0x82) /* shifted exit key */ +#define KEY_SFIND (KEY_OFFSET + 0x83) /* shifted find key */ +#define KEY_SHOME (KEY_OFFSET + 0x84) /* shifted home key */ +#define KEY_SIC (KEY_OFFSET + 0x85) /* shifted input key */ + +#define KEY_SLEFT (KEY_OFFSET + 0x87) /* shifted left arrow key */ +#define KEY_SMESSAGE (KEY_OFFSET + 0x88) /* shifted message key */ +#define KEY_SMOVE (KEY_OFFSET + 0x89) /* shifted move key */ +#define KEY_SNEXT (KEY_OFFSET + 0x8a) /* shifted next key */ +#define KEY_SOPTIONS (KEY_OFFSET + 0x8b) /* shifted options key */ +#define KEY_SPREVIOUS (KEY_OFFSET + 0x8c) /* shifted prev key */ +#define KEY_SPRINT (KEY_OFFSET + 0x8d) /* shifted print key */ +#define KEY_SREDO (KEY_OFFSET + 0x8e) /* shifted redo key */ +#define KEY_SREPLACE (KEY_OFFSET + 0x8f) /* shifted replace key */ +#define KEY_SRIGHT (KEY_OFFSET + 0x90) /* shifted right arrow */ +#define KEY_SRSUME (KEY_OFFSET + 0x91) /* shifted resume key */ +#define KEY_SSAVE (KEY_OFFSET + 0x92) /* shifted save key */ +#define KEY_SSUSPEND (KEY_OFFSET + 0x93) /* shifted suspend key */ +#define KEY_SUNDO (KEY_OFFSET + 0x94) /* shifted undo key */ +#define KEY_SUSPEND (KEY_OFFSET + 0x95) /* suspend key */ +#define KEY_UNDO (KEY_OFFSET + 0x96) /* undo key */ + +/* PDCurses-specific key definitions -- PC only */ + +#define ALT_0 (KEY_OFFSET + 0x97) +#define ALT_1 (KEY_OFFSET + 0x98) +#define ALT_2 (KEY_OFFSET + 0x99) +#define ALT_3 (KEY_OFFSET + 0x9a) +#define ALT_4 (KEY_OFFSET + 0x9b) +#define ALT_5 (KEY_OFFSET + 0x9c) +#define ALT_6 (KEY_OFFSET + 0x9d) +#define ALT_7 (KEY_OFFSET + 0x9e) +#define ALT_8 (KEY_OFFSET + 0x9f) +#define ALT_9 (KEY_OFFSET + 0xa0) +#define ALT_A (KEY_OFFSET + 0xa1) +#define ALT_B (KEY_OFFSET + 0xa2) +#define ALT_C (KEY_OFFSET + 0xa3) +#define ALT_D (KEY_OFFSET + 0xa4) +#define ALT_E (KEY_OFFSET + 0xa5) +#define ALT_F (KEY_OFFSET + 0xa6) +#define ALT_G (KEY_OFFSET + 0xa7) +#define ALT_H (KEY_OFFSET + 0xa8) +#define ALT_I (KEY_OFFSET + 0xa9) +#define ALT_J (KEY_OFFSET + 0xaa) +#define ALT_K (KEY_OFFSET + 0xab) +#define ALT_L (KEY_OFFSET + 0xac) +#define ALT_M (KEY_OFFSET + 0xad) +#define ALT_N (KEY_OFFSET + 0xae) +#define ALT_O (KEY_OFFSET + 0xaf) +#define ALT_P (KEY_OFFSET + 0xb0) +#define ALT_Q (KEY_OFFSET + 0xb1) +#define ALT_R (KEY_OFFSET + 0xb2) +#define ALT_S (KEY_OFFSET + 0xb3) +#define ALT_T (KEY_OFFSET + 0xb4) +#define ALT_U (KEY_OFFSET + 0xb5) +#define ALT_V (KEY_OFFSET + 0xb6) +#define ALT_W (KEY_OFFSET + 0xb7) +#define ALT_X (KEY_OFFSET + 0xb8) +#define ALT_Y (KEY_OFFSET + 0xb9) +#define ALT_Z (KEY_OFFSET + 0xba) + +#define CTL_LEFT (KEY_OFFSET + 0xbb) /* Control-Left-Arrow */ +#define CTL_RIGHT (KEY_OFFSET + 0xbc) +#define CTL_PGUP (KEY_OFFSET + 0xbd) +#define CTL_PGDN (KEY_OFFSET + 0xbe) +#define CTL_HOME (KEY_OFFSET + 0xbf) +#define CTL_END (KEY_OFFSET + 0xc0) + +#define KEY_A1 (KEY_OFFSET + 0xc1) /* upper left on Virtual keypad */ +#define KEY_A2 (KEY_OFFSET + 0xc2) /* upper middle on Virt. keypad */ +#define KEY_A3 (KEY_OFFSET + 0xc3) /* upper right on Vir. keypad */ +#define KEY_B1 (KEY_OFFSET + 0xc4) /* middle left on Virt. keypad */ +#define KEY_B2 (KEY_OFFSET + 0xc5) /* center on Virt. keypad */ +#define KEY_B3 (KEY_OFFSET + 0xc6) /* middle right on Vir. keypad */ +#define KEY_C1 (KEY_OFFSET + 0xc7) /* lower left on Virt. keypad */ +#define KEY_C2 (KEY_OFFSET + 0xc8) /* lower middle on Virt. keypad */ +#define KEY_C3 (KEY_OFFSET + 0xc9) /* lower right on Vir. keypad */ + +#define PADSLASH (KEY_OFFSET + 0xca) /* slash on keypad */ +#define PADENTER (KEY_OFFSET + 0xcb) /* enter on keypad */ +#define CTL_PADENTER (KEY_OFFSET + 0xcc) /* ctl-enter on keypad */ +#define ALT_PADENTER (KEY_OFFSET + 0xcd) /* alt-enter on keypad */ +#define PADSTOP (KEY_OFFSET + 0xce) /* stop on keypad */ +#define PADSTAR (KEY_OFFSET + 0xcf) /* star on keypad */ +#define PADMINUS (KEY_OFFSET + 0xd0) /* minus on keypad */ +#define PADPLUS (KEY_OFFSET + 0xd1) /* plus on keypad */ +#define CTL_PADSTOP (KEY_OFFSET + 0xd2) /* ctl-stop on keypad */ +#define CTL_PADCENTER (KEY_OFFSET + 0xd3) /* ctl-enter on keypad */ +#define CTL_PADPLUS (KEY_OFFSET + 0xd4) /* ctl-plus on keypad */ +#define CTL_PADMINUS (KEY_OFFSET + 0xd5) /* ctl-minus on keypad */ +#define CTL_PADSLASH (KEY_OFFSET + 0xd6) /* ctl-slash on keypad */ +#define CTL_PADSTAR (KEY_OFFSET + 0xd7) /* ctl-star on keypad */ +#define ALT_PADPLUS (KEY_OFFSET + 0xd8) /* alt-plus on keypad */ +#define ALT_PADMINUS (KEY_OFFSET + 0xd9) /* alt-minus on keypad */ +#define ALT_PADSLASH (KEY_OFFSET + 0xda) /* alt-slash on keypad */ +#define ALT_PADSTAR (KEY_OFFSET + 0xdb) /* alt-star on keypad */ +#define ALT_PADSTOP (KEY_OFFSET + 0xdc) /* alt-stop on keypad */ +#define CTL_INS (KEY_OFFSET + 0xdd) /* ctl-insert */ +#define ALT_DEL (KEY_OFFSET + 0xde) /* alt-delete */ +#define ALT_INS (KEY_OFFSET + 0xdf) /* alt-insert */ +#define CTL_UP (KEY_OFFSET + 0xe0) /* ctl-up arrow */ +#define CTL_DOWN (KEY_OFFSET + 0xe1) /* ctl-down arrow */ +#define CTL_TAB (KEY_OFFSET + 0xe2) /* ctl-tab */ +#define ALT_TAB (KEY_OFFSET + 0xe3) +#define ALT_MINUS (KEY_OFFSET + 0xe4) +#define ALT_EQUAL (KEY_OFFSET + 0xe5) +#define ALT_HOME (KEY_OFFSET + 0xe6) +#define ALT_PGUP (KEY_OFFSET + 0xe7) +#define ALT_PGDN (KEY_OFFSET + 0xe8) +#define ALT_END (KEY_OFFSET + 0xe9) +#define ALT_UP (KEY_OFFSET + 0xea) /* alt-up arrow */ +#define ALT_DOWN (KEY_OFFSET + 0xeb) /* alt-down arrow */ +#define ALT_RIGHT (KEY_OFFSET + 0xec) /* alt-right arrow */ +#define ALT_LEFT (KEY_OFFSET + 0xed) /* alt-left arrow */ +#define ALT_ENTER (KEY_OFFSET + 0xee) /* alt-enter */ +#define ALT_ESC (KEY_OFFSET + 0xef) /* alt-escape */ +#define ALT_BQUOTE (KEY_OFFSET + 0xf0) /* alt-back quote */ +#define ALT_LBRACKET (KEY_OFFSET + 0xf1) /* alt-left bracket */ +#define ALT_RBRACKET (KEY_OFFSET + 0xf2) /* alt-right bracket */ +#define ALT_SEMICOLON (KEY_OFFSET + 0xf3) /* alt-semi-colon */ +#define ALT_FQUOTE (KEY_OFFSET + 0xf4) /* alt-forward quote */ +#define ALT_COMMA (KEY_OFFSET + 0xf5) /* alt-comma */ +#define ALT_STOP (KEY_OFFSET + 0xf6) /* alt-stop */ +#define ALT_FSLASH (KEY_OFFSET + 0xf7) /* alt-forward slash */ +#define ALT_BKSP (KEY_OFFSET + 0xf8) /* alt-backspace */ +#define CTL_BKSP (KEY_OFFSET + 0xf9) /* ctl-backspace */ +#define PAD0 (KEY_OFFSET + 0xfa) /* keypad 0 */ + +#define CTL_PAD0 (KEY_OFFSET + 0xfb) /* ctl-keypad 0 */ +#define CTL_PAD1 (KEY_OFFSET + 0xfc) +#define CTL_PAD2 (KEY_OFFSET + 0xfd) +#define CTL_PAD3 (KEY_OFFSET + 0xfe) +#define CTL_PAD4 (KEY_OFFSET + 0xff) +#define CTL_PAD5 (KEY_OFFSET + 0x100) +#define CTL_PAD6 (KEY_OFFSET + 0x101) +#define CTL_PAD7 (KEY_OFFSET + 0x102) +#define CTL_PAD8 (KEY_OFFSET + 0x103) +#define CTL_PAD9 (KEY_OFFSET + 0x104) + +#define ALT_PAD0 (KEY_OFFSET + 0x105) /* alt-keypad 0 */ +#define ALT_PAD1 (KEY_OFFSET + 0x106) +#define ALT_PAD2 (KEY_OFFSET + 0x107) +#define ALT_PAD3 (KEY_OFFSET + 0x108) +#define ALT_PAD4 (KEY_OFFSET + 0x109) +#define ALT_PAD5 (KEY_OFFSET + 0x10a) +#define ALT_PAD6 (KEY_OFFSET + 0x10b) +#define ALT_PAD7 (KEY_OFFSET + 0x10c) +#define ALT_PAD8 (KEY_OFFSET + 0x10d) +#define ALT_PAD9 (KEY_OFFSET + 0x10e) + +#define CTL_DEL (KEY_OFFSET + 0x10f) /* clt-delete */ +#define ALT_BSLASH (KEY_OFFSET + 0x110) /* alt-back slash */ +#define CTL_ENTER (KEY_OFFSET + 0x111) /* ctl-enter */ + +#define SHF_PADENTER (KEY_OFFSET + 0x112) /* shift-enter on keypad */ +#define SHF_PADSLASH (KEY_OFFSET + 0x113) /* shift-slash on keypad */ +#define SHF_PADSTAR (KEY_OFFSET + 0x114) /* shift-star on keypad */ +#define SHF_PADPLUS (KEY_OFFSET + 0x115) /* shift-plus on keypad */ +#define SHF_PADMINUS (KEY_OFFSET + 0x116) /* shift-minus on keypad */ +#define SHF_UP (KEY_OFFSET + 0x117) /* shift-up on keypad */ +#define SHF_DOWN (KEY_OFFSET + 0x118) /* shift-down on keypad */ +#define SHF_IC (KEY_OFFSET + 0x119) /* shift-insert on keypad */ +#define SHF_DC (KEY_OFFSET + 0x11a) /* shift-delete on keypad */ + +#define KEY_MOUSE (KEY_OFFSET + 0x11b) /* "mouse" key */ +#define KEY_SHIFT_L (KEY_OFFSET + 0x11c) /* Left-shift */ +#define KEY_SHIFT_R (KEY_OFFSET + 0x11d) /* Right-shift */ +#define KEY_CONTROL_L (KEY_OFFSET + 0x11e) /* Left-control */ +#define KEY_CONTROL_R (KEY_OFFSET + 0x11f) /* Right-control */ +#define KEY_ALT_L (KEY_OFFSET + 0x120) /* Left-alt */ +#define KEY_ALT_R (KEY_OFFSET + 0x121) /* Right-alt */ +#define KEY_RESIZE (KEY_OFFSET + 0x122) /* Window resize */ +#define KEY_SUP (KEY_OFFSET + 0x123) /* Shifted up arrow */ +#define KEY_SDOWN (KEY_OFFSET + 0x124) /* Shifted down arrow */ + + /* The following were added 2011 Sep 14, and are */ + /* not returned by most flavors of PDCurses: */ + +#define CTL_SEMICOLON (KEY_OFFSET + 0x125) +#define CTL_EQUAL (KEY_OFFSET + 0x126) +#define CTL_COMMA (KEY_OFFSET + 0x127) +#define CTL_MINUS (KEY_OFFSET + 0x128) +#define CTL_STOP (KEY_OFFSET + 0x129) +#define CTL_FSLASH (KEY_OFFSET + 0x12a) +#define CTL_BQUOTE (KEY_OFFSET + 0x12b) + +#define KEY_APPS (KEY_OFFSET + 0x12c) +#define KEY_SAPPS (KEY_OFFSET + 0x12d) +#define CTL_APPS (KEY_OFFSET + 0x12e) +#define ALT_APPS (KEY_OFFSET + 0x12f) + +#define KEY_PAUSE (KEY_OFFSET + 0x130) +#define KEY_SPAUSE (KEY_OFFSET + 0x131) +#define CTL_PAUSE (KEY_OFFSET + 0x132) + +#define KEY_PRINTSCREEN (KEY_OFFSET + 0x133) +#define ALT_PRINTSCREEN (KEY_OFFSET + 0x134) +#define KEY_SCROLLLOCK (KEY_OFFSET + 0x135) +#define ALT_SCROLLLOCK (KEY_OFFSET + 0x136) + +#define CTL_0 (KEY_OFFSET + 0x137) +#define CTL_1 (KEY_OFFSET + 0x138) +#define CTL_2 (KEY_OFFSET + 0x139) +#define CTL_3 (KEY_OFFSET + 0x13a) +#define CTL_4 (KEY_OFFSET + 0x13b) +#define CTL_5 (KEY_OFFSET + 0x13c) +#define CTL_6 (KEY_OFFSET + 0x13d) +#define CTL_7 (KEY_OFFSET + 0x13e) +#define CTL_8 (KEY_OFFSET + 0x13f) +#define CTL_9 (KEY_OFFSET + 0x140) + +#define KEY_BROWSER_BACK (KEY_OFFSET + 0x141) +#define KEY_SBROWSER_BACK (KEY_OFFSET + 0x142) +#define KEY_CBROWSER_BACK (KEY_OFFSET + 0x143) +#define KEY_ABROWSER_BACK (KEY_OFFSET + 0x144) +#define KEY_BROWSER_FWD (KEY_OFFSET + 0x145) +#define KEY_SBROWSER_FWD (KEY_OFFSET + 0x146) +#define KEY_CBROWSER_FWD (KEY_OFFSET + 0x147) +#define KEY_ABROWSER_FWD (KEY_OFFSET + 0x148) +#define KEY_BROWSER_REF (KEY_OFFSET + 0x149) +#define KEY_SBROWSER_REF (KEY_OFFSET + 0x14A) +#define KEY_CBROWSER_REF (KEY_OFFSET + 0x14B) +#define KEY_ABROWSER_REF (KEY_OFFSET + 0x14C) +#define KEY_BROWSER_STOP (KEY_OFFSET + 0x14D) +#define KEY_SBROWSER_STOP (KEY_OFFSET + 0x14E) +#define KEY_CBROWSER_STOP (KEY_OFFSET + 0x14F) +#define KEY_ABROWSER_STOP (KEY_OFFSET + 0x150) +#define KEY_SEARCH (KEY_OFFSET + 0x151) +#define KEY_SSEARCH (KEY_OFFSET + 0x152) +#define KEY_CSEARCH (KEY_OFFSET + 0x153) +#define KEY_ASEARCH (KEY_OFFSET + 0x154) +#define KEY_FAVORITES (KEY_OFFSET + 0x155) +#define KEY_SFAVORITES (KEY_OFFSET + 0x156) +#define KEY_CFAVORITES (KEY_OFFSET + 0x157) +#define KEY_AFAVORITES (KEY_OFFSET + 0x158) +#define KEY_BROWSER_HOME (KEY_OFFSET + 0x159) +#define KEY_SBROWSER_HOME (KEY_OFFSET + 0x15A) +#define KEY_CBROWSER_HOME (KEY_OFFSET + 0x15B) +#define KEY_ABROWSER_HOME (KEY_OFFSET + 0x15C) +#define KEY_VOLUME_MUTE (KEY_OFFSET + 0x15D) +#define KEY_SVOLUME_MUTE (KEY_OFFSET + 0x15E) +#define KEY_CVOLUME_MUTE (KEY_OFFSET + 0x15F) +#define KEY_AVOLUME_MUTE (KEY_OFFSET + 0x160) +#define KEY_VOLUME_DOWN (KEY_OFFSET + 0x161) +#define KEY_SVOLUME_DOWN (KEY_OFFSET + 0x162) +#define KEY_CVOLUME_DOWN (KEY_OFFSET + 0x163) +#define KEY_AVOLUME_DOWN (KEY_OFFSET + 0x164) +#define KEY_VOLUME_UP (KEY_OFFSET + 0x165) +#define KEY_SVOLUME_UP (KEY_OFFSET + 0x166) +#define KEY_CVOLUME_UP (KEY_OFFSET + 0x167) +#define KEY_AVOLUME_UP (KEY_OFFSET + 0x168) +#define KEY_NEXT_TRACK (KEY_OFFSET + 0x169) +#define KEY_SNEXT_TRACK (KEY_OFFSET + 0x16A) +#define KEY_CNEXT_TRACK (KEY_OFFSET + 0x16B) +#define KEY_ANEXT_TRACK (KEY_OFFSET + 0x16C) +#define KEY_PREV_TRACK (KEY_OFFSET + 0x16D) +#define KEY_SPREV_TRACK (KEY_OFFSET + 0x16E) +#define KEY_CPREV_TRACK (KEY_OFFSET + 0x16F) +#define KEY_APREV_TRACK (KEY_OFFSET + 0x170) +#define KEY_MEDIA_STOP (KEY_OFFSET + 0x171) +#define KEY_SMEDIA_STOP (KEY_OFFSET + 0x172) +#define KEY_CMEDIA_STOP (KEY_OFFSET + 0x173) +#define KEY_AMEDIA_STOP (KEY_OFFSET + 0x174) +#define KEY_PLAY_PAUSE (KEY_OFFSET + 0x175) +#define KEY_SPLAY_PAUSE (KEY_OFFSET + 0x176) +#define KEY_CPLAY_PAUSE (KEY_OFFSET + 0x177) +#define KEY_APLAY_PAUSE (KEY_OFFSET + 0x178) +#define KEY_LAUNCH_MAIL (KEY_OFFSET + 0x179) +#define KEY_SLAUNCH_MAIL (KEY_OFFSET + 0x17A) +#define KEY_CLAUNCH_MAIL (KEY_OFFSET + 0x17B) +#define KEY_ALAUNCH_MAIL (KEY_OFFSET + 0x17C) +#define KEY_MEDIA_SELECT (KEY_OFFSET + 0x17D) +#define KEY_SMEDIA_SELECT (KEY_OFFSET + 0x17E) +#define KEY_CMEDIA_SELECT (KEY_OFFSET + 0x17F) +#define KEY_AMEDIA_SELECT (KEY_OFFSET + 0x180) +#define KEY_LAUNCH_APP1 (KEY_OFFSET + 0x181) +#define KEY_SLAUNCH_APP1 (KEY_OFFSET + 0x182) +#define KEY_CLAUNCH_APP1 (KEY_OFFSET + 0x183) +#define KEY_ALAUNCH_APP1 (KEY_OFFSET + 0x184) +#define KEY_LAUNCH_APP2 (KEY_OFFSET + 0x185) +#define KEY_SLAUNCH_APP2 (KEY_OFFSET + 0x186) +#define KEY_CLAUNCH_APP2 (KEY_OFFSET + 0x187) +#define KEY_ALAUNCH_APP2 (KEY_OFFSET + 0x188) + +#define KEY_MIN KEY_BREAK /* Minimum curses key value */ +#define KEY_MAX KEY_ALAUNCH_APP2 /* Maximum curses key */ + +#define KEY_F(n) (KEY_F0 + (n)) + +/*---------------------------------------------------------------------- + * + * PDCurses Function Declarations + * + */ + +/* Standard */ + +PDCEX int addch(const chtype); +PDCEX int addchnstr(const chtype *, int); +PDCEX int addchstr(const chtype *); +PDCEX int addnstr(const char *, int); +PDCEX int addstr(const char *); +PDCEX int attroff(chtype); +PDCEX int attron(chtype); +PDCEX int attrset(chtype); +PDCEX int attr_get(attr_t *, short *, void *); +PDCEX int attr_off(attr_t, void *); +PDCEX int attr_on(attr_t, void *); +PDCEX int attr_set(attr_t, short, void *); +PDCEX int baudrate(void); +PDCEX int beep(void); +PDCEX int bkgd(chtype); +PDCEX void bkgdset(chtype); +PDCEX int border(chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int box(WINDOW *, chtype, chtype); +PDCEX bool can_change_color(void); +PDCEX int cbreak(void); +PDCEX int chgat(int, attr_t, short, const void *); +PDCEX int clearok(WINDOW *, bool); +PDCEX int clear(void); +PDCEX int clrtobot(void); +PDCEX int clrtoeol(void); +PDCEX int color_content(short, short *, short *, short *); +PDCEX int color_set(short, void *); +PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int, + int, int, int, int); +PDCEX int curs_set(int); +PDCEX int def_prog_mode(void); +PDCEX int def_shell_mode(void); +PDCEX int delay_output(int); +PDCEX int delch(void); +PDCEX int deleteln(void); +PDCEX void delscreen(SCREEN *); +PDCEX int delwin(WINDOW *); +PDCEX WINDOW *derwin(WINDOW *, int, int, int, int); +PDCEX int doupdate(void); +PDCEX WINDOW *dupwin(WINDOW *); +PDCEX int echochar(const chtype); +PDCEX int echo(void); +PDCEX int endwin(void); +PDCEX char erasechar(void); +PDCEX int erase(void); +PDCEX void filter(void); +PDCEX int flash(void); +PDCEX int flushinp(void); +PDCEX chtype getbkgd(WINDOW *); +PDCEX int getnstr(char *, int); +PDCEX int getstr(char *); +PDCEX WINDOW *getwin(FILE *); +PDCEX int halfdelay(int); +PDCEX bool has_colors(void); +PDCEX bool has_ic(void); +PDCEX bool has_il(void); +PDCEX int hline(chtype, int); +PDCEX void idcok(WINDOW *, bool); +PDCEX int idlok(WINDOW *, bool); +PDCEX void immedok(WINDOW *, bool); +PDCEX int inchnstr(chtype *, int); +PDCEX int inchstr(chtype *); +PDCEX chtype inch(void); +PDCEX int init_color(short, short, short, short); +PDCEX int init_pair(short, short, short); +PDCEX WINDOW *initscr(void); +PDCEX int innstr(char *, int); +PDCEX int insch(chtype); +PDCEX int insdelln(int); +PDCEX int insertln(void); +PDCEX int insnstr(const char *, int); +PDCEX int insstr(const char *); +PDCEX int instr(char *); +PDCEX int intrflush(WINDOW *, bool); +PDCEX bool isendwin(void); +PDCEX bool is_linetouched(WINDOW *, int); +PDCEX bool is_wintouched(WINDOW *); +PDCEX char *keyname(int); +PDCEX int keypad(WINDOW *, bool); +PDCEX char killchar(void); +PDCEX int leaveok(WINDOW *, bool); +PDCEX char *longname(void); +PDCEX int meta(WINDOW *, bool); +PDCEX int move(int, int); +PDCEX int mvaddch(int, int, const chtype); +PDCEX int mvaddchnstr(int, int, const chtype *, int); +PDCEX int mvaddchstr(int, int, const chtype *); +PDCEX int mvaddnstr(int, int, const char *, int); +PDCEX int mvaddstr(int, int, const char *); +PDCEX int mvchgat(int, int, int, attr_t, short, const void *); +PDCEX int mvcur(int, int, int, int); +PDCEX int mvdelch(int, int); +PDCEX int mvderwin(WINDOW *, int, int); +PDCEX int mvgetch(int, int); +PDCEX int mvgetnstr(int, int, char *, int); +PDCEX int mvgetstr(int, int, char *); +PDCEX int mvhline(int, int, chtype, int); +PDCEX chtype mvinch(int, int); +PDCEX int mvinchnstr(int, int, chtype *, int); +PDCEX int mvinchstr(int, int, chtype *); +PDCEX int mvinnstr(int, int, char *, int); +PDCEX int mvinsch(int, int, chtype); +PDCEX int mvinsnstr(int, int, const char *, int); +PDCEX int mvinsstr(int, int, const char *); +PDCEX int mvinstr(int, int, char *); +PDCEX int mvprintw(int, int, const char *, ...); +PDCEX int mvscanw(int, int, const char *, ...); +PDCEX int mvvline(int, int, chtype, int); +PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); +PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *); +PDCEX int mvwaddch(WINDOW *, int, int, const chtype); +PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwaddstr(WINDOW *, int, int, const char *); +PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); +PDCEX int mvwdelch(WINDOW *, int, int); +PDCEX int mvwgetch(WINDOW *, int, int); +PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwgetstr(WINDOW *, int, int, char *); +PDCEX int mvwhline(WINDOW *, int, int, chtype, int); +PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int); +PDCEX int mvwinchstr(WINDOW *, int, int, chtype *); +PDCEX chtype mvwinch(WINDOW *, int, int); +PDCEX int mvwinnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwinsch(WINDOW *, int, int, chtype); +PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwinsstr(WINDOW *, int, int, const char *); +PDCEX int mvwinstr(WINDOW *, int, int, char *); +PDCEX int mvwin(WINDOW *, int, int); +PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwvline(WINDOW *, int, int, chtype, int); +PDCEX int napms(int); +PDCEX WINDOW *newpad(int, int); +PDCEX SCREEN *newterm(const char *, FILE *, FILE *); +PDCEX WINDOW *newwin(int, int, int, int); +PDCEX int nl(void); +PDCEX int nocbreak(void); +PDCEX int nodelay(WINDOW *, bool); +PDCEX int noecho(void); +PDCEX int nonl(void); +PDCEX void noqiflush(void); +PDCEX int noraw(void); +PDCEX int notimeout(WINDOW *, bool); +PDCEX int overlay(const WINDOW *, WINDOW *); +PDCEX int overwrite(const WINDOW *, WINDOW *); +PDCEX int pair_content(short, short *, short *); +PDCEX int pechochar(WINDOW *, chtype); +PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int prefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int printw(const char *, ...); +PDCEX int putwin(WINDOW *, FILE *); +PDCEX void qiflush(void); +PDCEX int raw(void); +PDCEX int redrawwin(WINDOW *); +PDCEX int refresh(void); +PDCEX int reset_prog_mode(void); +PDCEX int reset_shell_mode(void); +PDCEX int resetty(void); +PDCEX int ripoffline(int, int (*)(WINDOW *, int)); +PDCEX int savetty(void); +PDCEX int scanw(const char *, ...); +PDCEX int scr_dump(const char *); +PDCEX int scr_init(const char *); +PDCEX int scr_restore(const char *); +PDCEX int scr_set(const char *); +PDCEX int scrl(int); +PDCEX int scroll(WINDOW *); +PDCEX int scrollok(WINDOW *, bool); +PDCEX SCREEN *set_term(SCREEN *); +PDCEX int setscrreg(int, int); +PDCEX int slk_attroff(const chtype); +PDCEX int slk_attr_off(const attr_t, void *); +PDCEX int slk_attron(const chtype); +PDCEX int slk_attr_on(const attr_t, void *); +PDCEX int slk_attrset(const chtype); +PDCEX int slk_attr_set(const attr_t, short, void *); +PDCEX int slk_clear(void); +PDCEX int slk_color(short); +PDCEX int slk_init(int); +PDCEX char *slk_label(int); +PDCEX int slk_noutrefresh(void); +PDCEX int slk_refresh(void); +PDCEX int slk_restore(void); +PDCEX int slk_set(int, const char *, int); +PDCEX int slk_touch(void); +PDCEX int standend(void); +PDCEX int standout(void); +PDCEX int start_color(void); +PDCEX WINDOW *subpad(WINDOW *, int, int, int, int); +PDCEX WINDOW *subwin(WINDOW *, int, int, int, int); +PDCEX int syncok(WINDOW *, bool); +PDCEX chtype termattrs(void); +PDCEX attr_t term_attrs(void); +PDCEX char *termname(void); +PDCEX void timeout(int); +PDCEX int touchline(WINDOW *, int, int); +PDCEX int touchwin(WINDOW *); +PDCEX int typeahead(int); +PDCEX int untouchwin(WINDOW *); +PDCEX void use_env(bool); +PDCEX int vidattr(chtype); +PDCEX int vid_attr(attr_t, short, void *); +PDCEX int vidputs(chtype, int (*)(int)); +PDCEX int vid_puts(attr_t, short, void *, int (*)(int)); +PDCEX int vline(chtype, int); +PDCEX int vw_printw(WINDOW *, const char *, va_list); +PDCEX int vwprintw(WINDOW *, const char *, va_list); +PDCEX int vw_scanw(WINDOW *, const char *, va_list); +PDCEX int vwscanw(WINDOW *, const char *, va_list); +PDCEX int waddchnstr(WINDOW *, const chtype *, int); +PDCEX int waddchstr(WINDOW *, const chtype *); +PDCEX int waddch(WINDOW *, const chtype); +PDCEX int waddnstr(WINDOW *, const char *, int); +PDCEX int waddstr(WINDOW *, const char *); +PDCEX int wattroff(WINDOW *, chtype); +PDCEX int wattron(WINDOW *, chtype); +PDCEX int wattrset(WINDOW *, chtype); +PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *); +PDCEX int wattr_off(WINDOW *, attr_t, void *); +PDCEX int wattr_on(WINDOW *, attr_t, void *); +PDCEX int wattr_set(WINDOW *, attr_t, short, void *); +PDCEX void wbkgdset(WINDOW *, chtype); +PDCEX int wbkgd(WINDOW *, chtype); +PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *); +PDCEX int wclear(WINDOW *); +PDCEX int wclrtobot(WINDOW *); +PDCEX int wclrtoeol(WINDOW *); +PDCEX int wcolor_set(WINDOW *, short, void *); +PDCEX void wcursyncup(WINDOW *); +PDCEX int wdelch(WINDOW *); +PDCEX int wdeleteln(WINDOW *); +PDCEX int wechochar(WINDOW *, const chtype); +PDCEX int werase(WINDOW *); +PDCEX int wgetch(WINDOW *); +PDCEX int wgetnstr(WINDOW *, char *, int); +PDCEX int wgetstr(WINDOW *, char *); +PDCEX int whline(WINDOW *, chtype, int); +PDCEX int winchnstr(WINDOW *, chtype *, int); +PDCEX int winchstr(WINDOW *, chtype *); +PDCEX chtype winch(WINDOW *); +PDCEX int winnstr(WINDOW *, char *, int); +PDCEX int winsch(WINDOW *, chtype); +PDCEX int winsdelln(WINDOW *, int); +PDCEX int winsertln(WINDOW *); +PDCEX int winsnstr(WINDOW *, const char *, int); +PDCEX int winsstr(WINDOW *, const char *); +PDCEX int winstr(WINDOW *, char *); +PDCEX int wmove(WINDOW *, int, int); +PDCEX int wnoutrefresh(WINDOW *); +PDCEX int wprintw(WINDOW *, const char *, ...); +PDCEX int wredrawln(WINDOW *, int, int); +PDCEX int wrefresh(WINDOW *); +PDCEX int wscanw(WINDOW *, const char *, ...); +PDCEX int wscrl(WINDOW *, int); +PDCEX int wsetscrreg(WINDOW *, int, int); +PDCEX int wstandend(WINDOW *); +PDCEX int wstandout(WINDOW *); +PDCEX void wsyncdown(WINDOW *); +PDCEX void wsyncup(WINDOW *); +PDCEX void wtimeout(WINDOW *, int); +PDCEX int wtouchln(WINDOW *, int, int, int); +PDCEX int wvline(WINDOW *, chtype, int); + +/* Wide-character functions */ + +#ifdef PDC_WIDE +PDCEX int addnwstr(const wchar_t *, int); +PDCEX int addwstr(const wchar_t *); +PDCEX int add_wch(const cchar_t *); +PDCEX int add_wchnstr(const cchar_t *, int); +PDCEX int add_wchstr(const cchar_t *); +PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *); +PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *); +PDCEX int echo_wchar(const cchar_t *); +PDCEX int erasewchar(wchar_t *); +PDCEX int getbkgrnd(cchar_t *); +PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); +PDCEX int getn_wstr(wint_t *, int); +PDCEX int get_wch(wint_t *); +PDCEX int get_wstr(wint_t *); +PDCEX int hline_set(const cchar_t *, int); +PDCEX int innwstr(wchar_t *, int); +PDCEX int ins_nwstr(const wchar_t *, int); +PDCEX int ins_wch(const cchar_t *); +PDCEX int ins_wstr(const wchar_t *); +PDCEX int inwstr(wchar_t *); +PDCEX int in_wch(cchar_t *); +PDCEX int in_wchnstr(cchar_t *, int); +PDCEX int in_wchstr(cchar_t *); +PDCEX char *key_name(wchar_t); +PDCEX int killwchar(wchar_t *); +PDCEX int mvaddnwstr(int, int, const wchar_t *, int); +PDCEX int mvaddwstr(int, int, const wchar_t *); +PDCEX int mvadd_wch(int, int, const cchar_t *); +PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int); +PDCEX int mvadd_wchstr(int, int, const cchar_t *); +PDCEX int mvgetn_wstr(int, int, wint_t *, int); +PDCEX int mvget_wch(int, int, wint_t *); +PDCEX int mvget_wstr(int, int, wint_t *); +PDCEX int mvhline_set(int, int, const cchar_t *, int); +PDCEX int mvinnwstr(int, int, wchar_t *, int); +PDCEX int mvins_nwstr(int, int, const wchar_t *, int); +PDCEX int mvins_wch(int, int, const cchar_t *); +PDCEX int mvins_wstr(int, int, const wchar_t *); +PDCEX int mvinwstr(int, int, wchar_t *); +PDCEX int mvin_wch(int, int, cchar_t *); +PDCEX int mvin_wchnstr(int, int, cchar_t *, int); +PDCEX int mvin_wchstr(int, int, cchar_t *); +PDCEX int mvvline_set(int, int, const cchar_t *, int); +PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int); +PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *); +PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *); +PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); +PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *); +PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); +PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *); +PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *); +PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int pecho_wchar(WINDOW *, const cchar_t*); +PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t, + short, const void*); +PDCEX int slk_wset(int, const wchar_t *, int); +PDCEX int unget_wch(const wchar_t); +PDCEX int vline_set(const cchar_t *, int); +PDCEX int waddnwstr(WINDOW *, const wchar_t *, int); +PDCEX int waddwstr(WINDOW *, const wchar_t *); +PDCEX int wadd_wch(WINDOW *, const cchar_t *); +PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int); +PDCEX int wadd_wchstr(WINDOW *, const cchar_t *); +PDCEX int wbkgrnd(WINDOW *, const cchar_t *); +PDCEX void wbkgrndset(WINDOW *, const cchar_t *); +PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *); +PDCEX int wecho_wchar(WINDOW *, const cchar_t *); +PDCEX int wgetbkgrnd(WINDOW *, cchar_t *); +PDCEX int wgetn_wstr(WINDOW *, wint_t *, int); +PDCEX int wget_wch(WINDOW *, wint_t *); +PDCEX int wget_wstr(WINDOW *, wint_t *); +PDCEX int whline_set(WINDOW *, const cchar_t *, int); +PDCEX int winnwstr(WINDOW *, wchar_t *, int); +PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int); +PDCEX int wins_wch(WINDOW *, const cchar_t *); +PDCEX int wins_wstr(WINDOW *, const wchar_t *); +PDCEX int winwstr(WINDOW *, wchar_t *); +PDCEX int win_wch(WINDOW *, cchar_t *); +PDCEX int win_wchnstr(WINDOW *, cchar_t *, int); +PDCEX int win_wchstr(WINDOW *, cchar_t *); +PDCEX wchar_t *wunctrl(cchar_t *); +PDCEX int wvline_set(WINDOW *, const cchar_t *, int); +#endif + +/* Quasi-standard */ + +PDCEX chtype getattrs(WINDOW *); +PDCEX int getbegx(WINDOW *); +PDCEX int getbegy(WINDOW *); +PDCEX int getmaxx(WINDOW *); +PDCEX int getmaxy(WINDOW *); +PDCEX int getparx(WINDOW *); +PDCEX int getpary(WINDOW *); +PDCEX int getcurx(WINDOW *); +PDCEX int getcury(WINDOW *); +PDCEX void traceoff(void); +PDCEX void traceon(void); +PDCEX char *unctrl(chtype); + +PDCEX int crmode(void); +PDCEX int nocrmode(void); +PDCEX int draino(int); +PDCEX int resetterm(void); +PDCEX int fixterm(void); +PDCEX int saveterm(void); +PDCEX void setsyx(int, int); + +PDCEX int mouse_set(unsigned long); +PDCEX int mouse_on(unsigned long); +PDCEX int mouse_off(unsigned long); +PDCEX int request_mouse_pos(void); +PDCEX int map_button(unsigned long); +PDCEX void wmouse_position(WINDOW *, int *, int *); +PDCEX unsigned long getmouse(void); +PDCEX unsigned long getbmap(void); + +/* ncurses */ + +PDCEX int assume_default_colors(int, int); +PDCEX const char *curses_version(void); +PDCEX bool has_key(int); +PDCEX int use_default_colors(void); +PDCEX int wresize(WINDOW *, int, int); + +PDCEX int mouseinterval(int); +PDCEX mmask_t mousemask(mmask_t, mmask_t *); +PDCEX bool mouse_trafo(int *, int *, bool); +PDCEX int nc_getmouse(MEVENT *); +PDCEX int ungetmouse(MEVENT *); +PDCEX bool wenclose(const WINDOW *, int, int); +PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool); + +/* PDCurses */ + +PDCEX int addrawch(chtype); +PDCEX int insrawch(chtype); +PDCEX bool is_termresized(void); +PDCEX int mvaddrawch(int, int, chtype); +PDCEX int mvdeleteln(int, int); +PDCEX int mvinsertln(int, int); +PDCEX int mvinsrawch(int, int, chtype); +PDCEX int mvwaddrawch(WINDOW *, int, int, chtype); +PDCEX int mvwdeleteln(WINDOW *, int, int); +PDCEX int mvwinsertln(WINDOW *, int, int); +PDCEX int mvwinsrawch(WINDOW *, int, int, chtype); +PDCEX int raw_output(bool); +PDCEX int resize_term(int, int); +PDCEX WINDOW *resize_window(WINDOW *, int, int); +PDCEX int waddrawch(WINDOW *, chtype); +PDCEX int winsrawch(WINDOW *, chtype); +PDCEX char wordchar(void); + +#ifdef PDC_WIDE +PDCEX wchar_t *slk_wlabel(int); +#endif + +PDCEX void PDC_debug(const char *, ...); +PDCEX int PDC_ungetch(int); +PDCEX int PDC_set_blink(bool); +PDCEX int PDC_set_line_color(short); +PDCEX void PDC_set_title(const char *); + +PDCEX int PDC_clearclipboard(void); +PDCEX int PDC_freeclipboard(char *); +PDCEX int PDC_getclipboard(char **, long *); +PDCEX int PDC_setclipboard(const char *, long); + +PDCEX unsigned long PDC_get_input_fd(void); +PDCEX unsigned long PDC_get_key_modifiers(void); +PDCEX int PDC_return_key_modifiers(bool); +PDCEX int PDC_save_key_modifiers(bool); +PDCEX void PDC_set_resize_limits( const int new_min_lines, + const int new_max_lines, + const int new_min_cols, + const int new_max_cols); + +#define FUNCTION_KEY_SHUT_DOWN 0 +#define FUNCTION_KEY_PASTE 1 +#define FUNCTION_KEY_ENLARGE_FONT 2 +#define FUNCTION_KEY_SHRINK_FONT 3 +#define FUNCTION_KEY_CHOOSE_FONT 4 +#define FUNCTION_KEY_ABORT 5 +#define PDC_MAX_FUNCTION_KEYS 6 + +PDCEX int PDC_set_function_key( const unsigned function, + const int new_key); + +PDCEX WINDOW *Xinitscr(int, char **); +#ifdef XCURSES +PDCEX void XCursesExit(void); +PDCEX int sb_init(void); +PDCEX int sb_set_horz(int, int, int); +PDCEX int sb_set_vert(int, int, int); +PDCEX int sb_get_horz(int *, int *, int *); +PDCEX int sb_get_vert(int *, int *, int *); +PDCEX int sb_refresh(void); + #endif + +/*** Functions defined as macros ***/ + +/* getch() and ungetch() conflict with some DOS libraries */ + +#define getch() wgetch(stdscr) +#define ungetch(ch) PDC_ungetch(ch) + +#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) +#define PAIR_NUMBER(n) ((((n) & A_COLOR) >> PDC_COLOR_SHIFT) & 0xff) + +/* These will _only_ work as macros */ + +#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w)) +#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) +#define getparyx(w, y, x) (y = getpary(w), x = getparx(w)) +#define getyx(w, y, x) (y = getcury(w), x = getcurx(w)) + +#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \ + else getyx(curscr,(y),(x)); } + +#ifdef NCURSES_MOUSE_VERSION +# define getmouse(x) nc_getmouse(x) +#endif + +/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ + +#define PDC_CLIP_SUCCESS 0 +#define PDC_CLIP_ACCESS_ERROR 1 +#define PDC_CLIP_EMPTY 2 +#define PDC_CLIP_MEMORY_ERROR 3 + +/* PDCurses key modifier masks */ + +#define PDC_KEY_MODIFIER_SHIFT 1 +#define PDC_KEY_MODIFIER_CONTROL 2 +#define PDC_KEY_MODIFIER_ALT 4 +#define PDC_KEY_MODIFIER_NUMLOCK 8 +#define PDC_KEY_MODIFIER_REPEAT 16 + +#ifdef __cplusplus +# undef bool +} +#endif + +#endif /* __PDCURSES__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h new file mode 100644 index 000000000..b5edcc173 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h @@ -0,0 +1,134 @@ +/* Public Domain Curses */ + +/* Private definitions and declarations for use within PDCurses. + These should generally not be referenced by applications. */ + +#ifndef __CURSES_INTERNALS__ +#define __CURSES_INTERNALS__ 1 + +#define CURSES_LIBRARY +#include + +#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \ + defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__WATCOMC__) || defined(__PACIFIC__) +# ifndef HAVE_VSSCANF +# define HAVE_VSSCANF /* have vsscanf() */ +# endif +#endif + +#if defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__LCC__) || defined(__WATCOMC__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF /* have vsnprintf() */ +# endif +#endif + +#if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ +#endif + +/*----------------------------------------------------------------------*/ + +typedef struct /* structure for ripped off lines */ +{ + int line; + int (*init)(WINDOW *, int); +} RIPPEDOFFLINE; + +/* Window properties */ + +#define _SUBWIN 0x01 /* window is a subwindow */ +#define _PAD 0x10 /* X/Open Pad. */ +#define _SUBPAD 0x20 /* X/Open subpad. */ + +/* Miscellaneous */ + +#define _NO_CHANGE -1 /* flags line edge unchanged */ + +#define _ECHAR 0x08 /* Erase char (^H) */ +#define _DWCHAR 0x17 /* Delete Word char (^W) */ +#define _DLCHAR 0x15 /* Delete Line char (^U) */ + +extern WINDOW *pdc_lastscr; +extern FILE *pdc_dbfp; /* tracing file pointer (NULL = off) */ +extern bool pdc_color_started; +extern unsigned long pdc_key_modifiers; +extern MOUSE_STATUS pdc_mouse_status; + +/*----------------------------------------------------------------------*/ + +/* Platform implementation functions */ + +void PDC_beep(void); +bool PDC_can_change_color(void); +int PDC_color_content(short, short *, short *, short *); +bool PDC_check_key(void); +int PDC_curs_set(int); +void PDC_flushinp(void); +int PDC_get_columns(void); +int PDC_get_cursor_mode(void); +int PDC_get_key(void); +int PDC_get_rows(void); +void PDC_gotoyx(int, int); +int PDC_init_color(short, short, short, short); +void PDC_init_pair(short, short, short); +int PDC_modifiers_set(void); +int PDC_mouse_set(void); +void PDC_napms(int); +int PDC_pair_content(short, short *, short *); +void PDC_reset_prog_mode(void); +void PDC_reset_shell_mode(void); +int PDC_resize_screen(int, int); +void PDC_restore_screen_mode(int); +void PDC_save_screen_mode(int); +void PDC_scr_close(void); +void PDC_scr_free(void); +int PDC_scr_open(int, char **); +void PDC_set_keyboard_binary(bool); +void PDC_transform_line(int, int, int, const chtype *); +const char *PDC_sysname(void); + +/* Internal cross-module functions */ + +void PDC_init_atrtab(void); +WINDOW *PDC_makelines(WINDOW *); +WINDOW *PDC_makenew(int, int, int, int); +int PDC_mouse_in_slk(int, int); +void PDC_slk_free(void); +void PDC_slk_initialize(void); +void PDC_sync(WINDOW *); + +#ifdef PDC_WIDE +int PDC_mbtowc(wchar_t *, const char *, size_t); +size_t PDC_mbstowcs(wchar_t *, const char *, size_t); +size_t PDC_wcstombs(char *, const wchar_t *, size_t); +#endif + +#ifdef PDCDEBUG +# define PDC_LOG(x) if (pdc_dbfp) PDC_debug x +#else +# define PDC_LOG(x) +#endif + +/* Internal macros for attributes */ + +#ifdef CHTYPE_LONG +# define PDC_COLOR_PAIRS 256 +#else +# define PDC_COLOR_PAIRS 32 +#endif + +#ifndef max +# define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +# define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define DIVROUND(num, divisor) (((num) + ((divisor) >> 1)) / (divisor)) + +#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if + not set by mouseinterval() */ + +#endif /* __CURSES_INTERNALS__*/ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h new file mode 100644 index 000000000..4de6e853e --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h @@ -0,0 +1,93 @@ +/* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */ +/* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */ +/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _GETOPT_H_ +#define _GETOPT_H_ + +#if 0 +#include +#endif + +/* + * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option { + /* name of long option */ + const char *name; + /* + * one of no_argument, required_argument, and optional_argument: + * whether option takes an argument + */ + int has_arg; + /* if not NULL, set *flag to val when option found */ + int *flag; + /* if flag not NULL, value to set *flag to; else return value */ + int val; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +int getopt_long(int, char * const *, const char *, + const struct option *, int *); +int getopt_long_only(int, char * const *, const char *, + const struct option *, int *); +#ifndef _GETOPT_DEFINED +#define _GETOPT_DEFINED +int getopt(int, char * const *, const char *); +int getsubopt(char **, char * const *, char **); + +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +extern int optreset; +extern char *suboptarg; /* getsubopt(3) external variable */ +#endif /* _GETOPT_DEFINED */ + +#ifdef __cplusplus +} +#endif +#endif /* !_GETOPT_H_ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h new file mode 100644 index 000000000..7f1fb1f17 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h @@ -0,0 +1,56 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * Panels for PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES_PANEL_H__ +#define __PDCURSES_PANEL_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct panelobs +{ + struct panelobs *above; + struct panel *pan; +} PANELOBS; + +typedef struct panel +{ + WINDOW *win; + int wstarty; + int wendy; + int wstartx; + int wendx; + struct panel *below; + struct panel *above; + const void *user; + struct panelobs *obscure; +} PANEL; + +PDCEX int bottom_panel(PANEL *pan); +PDCEX int del_panel(PANEL *pan); +PDCEX int hide_panel(PANEL *pan); +PDCEX int move_panel(PANEL *pan, int starty, int startx); +PDCEX PANEL *new_panel(WINDOW *win); +PDCEX PANEL *panel_above(const PANEL *pan); +PDCEX PANEL *panel_below(const PANEL *pan); +PDCEX int panel_hidden(const PANEL *pan); +PDCEX const void *panel_userptr(const PANEL *pan); +PDCEX WINDOW *panel_window(const PANEL *pan); +PDCEX int replace_panel(PANEL *pan, WINDOW *win); +PDCEX int set_panel_userptr(PANEL *pan, const void *uptr); +PDCEX int show_panel(PANEL *pan); +PDCEX int top_panel(PANEL *pan); +PDCEX void update_panels(void); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_PANEL_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h new file mode 100644 index 000000000..0ba0b7a7f --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h @@ -0,0 +1,48 @@ +/* Public Domain Curses */ + +/* PDCurses doesn't operate with terminfo, but we need these functions for + compatibility, to allow some things (notably, interface libraries for + other languages) to be compiled. Anyone who tries to actually _use_ + them will be disappointed, since they only return ERR. */ + +#ifndef __PDCURSES_TERM_H__ +#define __PDCURSES_TERM_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct +{ + const char *_termname; +} TERMINAL; + +/* PDCEX is defined in curses.h */ +PDCEX TERMINAL *cur_term; + +int del_curterm(TERMINAL *); +int putp(const char *); +int restartterm(const char *, int, int *); +TERMINAL *set_curterm(TERMINAL *); +int setterm(const char *); +int setupterm(const char *, int, int *); +int tgetent(char *, const char *); +int tgetflag(const char *); +int tgetnum(const char *); +char *tgetstr(const char *, char **); +char *tgoto(const char *, int, int); +int tigetflag(const char *); +int tigetnum(const char *); +char *tigetstr(const char *); +char *tparm(const char *, long, long, long, long, long, + long, long, long, long); +int tputs(const char *, int, int (*)(int)); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_TERM_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h new file mode 100644 index 000000000..5d2440309 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h @@ -0,0 +1,56 @@ +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +/* This is intended as a drop-in replacement for unistd.h on Windows. + * Please add functionality as neeeded. + * https://stackoverflow.com/a/826027/1202830 + */ + +#include +#include +#include /* getopt at: https://gist.github.com/ashelly/7776712 */ +#include /* for getpid() and the exec..() family */ +#include /* for _getcwd() and _chdir() */ + +#define srandom srand +#define random rand + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +//#define X_OK 1 /* execute permission - unsupported in windows*/ +#define F_OK 0 /* Test for existence. */ + +#define access _access +#define dup2 _dup2 +#define execve _execve +#define ftruncate _chsize +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define chdir _chdir +#define isatty _isatty +#define lseek _lseek +/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ + +#ifdef _WIN64 +#define ssize_t __int64 +#else +#define ssize_t long +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +/* should be in some equivalent to */ +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#endif /* unistd.h */ \ No newline at end of file From 8ff5220943fb1def080bc8003495d251b66af5ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Mar 2019 20:13:48 -1100 Subject: [PATCH 2923/3904] Fix wrong dilithium compare --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 7ab6b4c37..0854236ec 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3352,7 +3352,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && checktxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && destpubtxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From 02961a91e48edb9b45d5254a291d2fe821c87667 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 11 Mar 2019 09:46:22 -0400 Subject: [PATCH 2924/3904] Port getchaintxstats from BTC master (#1328) This will allow explorers to present interesting analytics about transaction volume in various time frames. --- src/rpc/blockchain.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++ src/rpc/client.cpp | 1 + 2 files changed, 83 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5be94dc94..6dac120e4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1655,6 +1655,87 @@ UniValue getmempoolinfo(const UniValue& params, bool fHelp) return mempoolInfoToJSON(); } +inline CBlockIndex* LookupBlockIndex(const uint256& hash) +{ + AssertLockHeld(cs_main); + BlockMap::const_iterator it = mapBlockIndex.find(hash); + return it == mapBlockIndex.end() ? nullptr : it->second; +} + +UniValue getchaintxstats(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "getchaintxstats\n" + "\nCompute statistics about the total number and rate of transactions in the chain.\n" + "\nArguments:\n" + "1. nblocks (numeric, optional) Number of blocks in averaging window.\n" + "2. blockhash (string, optional) The hash of the block which ends the window.\n" + "\nResult:\n" + "{\n" + " \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n" + " \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n" + " \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n" + " \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n" + " \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n" + " \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n" + " \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getchaintxstats", "") + + HelpExampleRpc("getchaintxstats", "2016") + ); + + const CBlockIndex* pindex; + int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month + + if (params[1].isNull()) { + LOCK(cs_main); + pindex = chainActive.Tip(); + } else { + uint256 hash(ParseHashV(params[1], "blockhash")); + LOCK(cs_main); + pindex = LookupBlockIndex(hash); + if (!pindex) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + } + if (!chainActive.Contains(pindex)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block is not in main chain"); + } + } + + assert(pindex != nullptr); + + if (params[0].isNull()) { + blockcount = std::max(0, std::min(blockcount, pindex->GetHeight() - 1)); + } else { + blockcount = params[0].get_int(); + + if (blockcount < 0 || (blockcount > 0 && blockcount >= pindex->GetHeight())) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block count: should be between 0 and the block's height - 1"); + } + } + + const CBlockIndex* pindexPast = pindex->GetAncestor(pindex->GetHeight() - blockcount); + int nTimeDiff = pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast(); + int nTxDiff = pindex->nChainTx - pindexPast->nChainTx; + + UniValue ret(UniValue::VOBJ); + ret.pushKV("time", (int64_t)pindex->nTime); + ret.pushKV("txcount", (int64_t)pindex->nChainTx); + ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex()); + ret.pushKV("window_block_count", blockcount); + if (blockcount > 0) { + ret.pushKV("window_tx_count", nTxDiff); + ret.pushKV("window_interval", nTimeDiff); + if (nTimeDiff > 0) { + ret.pushKV("txrate", ((double)nTxDiff) / nTimeDiff); + } + } + + return ret; +} + UniValue invalidateblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -1742,6 +1823,7 @@ static const CRPCCommand commands[] = { "blockchain", "getblockhash", &getblockhash, true }, { "blockchain", "getblockheader", &getblockheader, true }, { "blockchain", "getchaintips", &getchaintips, true }, + { "blockchain", "getchaintxstats", &getchaintxstats, true }, { "blockchain", "getdifficulty", &getdifficulty, true }, { "blockchain", "getmempoolinfo", &getmempoolinfo, true }, { "blockchain", "getrawmempool", &getrawmempool, true }, diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 3cbde9f10..19910b25c 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -89,6 +89,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listunspent", 2 }, { "getblock", 1 }, { "getblockheader", 1 }, + { "getchaintxstats", 0 }, { "getlastsegidstakes", 0 }, { "gettransaction", 1 }, { "getrawtransaction", 1 }, From bd8e9da7863e60a115c219970c11153b94d147fa Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Tue, 12 Mar 2019 13:18:16 +0100 Subject: [PATCH 2925/3904] Fix memory leak in FinalizeCCTx (#1329) --- src/cc/CCtx.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 2b0893eb4..3e93b3462 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -290,6 +290,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cc_free(othercond3); if ( othercond4 != 0 ) cc_free(othercond4); + if ( othercond1of2 != 0 ) + cc_free(othercond1of2); + if ( othercond1of2tokens != 0 ) + cc_free(othercond1of2tokens); + if ( mytokenscond != 0 ) + cc_free(mytokenscond); + if ( mysingletokenscond != 0 ) + cc_free(mysingletokenscond); + if ( othertokenscond != 0 ) + cc_free(othertokenscond); std::string strHex = EncodeHexTx(mtx); if ( strHex.size() > 0 ) return(strHex); From 445d68395e6ae0a54af7bf33c47361c9ca5ba027 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Tue, 12 Mar 2019 19:25:13 +0300 Subject: [PATCH 2926/3904] [msvc] fix seed str -> uint64 conversion --- src/cc/rogue/rogue.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 36616b340..7a8e38c15 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -343,7 +343,15 @@ int rogue(int argc, char **argv, char **envp) rs->sleeptime = 1; // non-zero to allow refresh() if ( argc == 3 && strlen(argv[2]) == 64 ) { - rs->seed = atol(argv[1]); + #ifdef _WIN32 + #ifdef _MSC_VER + rs->seed = _strtoui64(argv[1], NULL, 10); + #else + rs->seed = atol(argv[1]); // windows, but not MSVC + #endif // _MSC_VER + #else + rs->seed = atol(argv[1]); // non-windows + #endif // _WIN32 strcpy(Gametxidstr,argv[2]); fprintf(stderr,"setplayerdata\n"); if ( rogue_setplayerdata(rs,Gametxidstr) < 0 ) From 6c907d78c129c003a4bf3222520d2834a072624c Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Tue, 12 Mar 2019 19:26:03 +0300 Subject: [PATCH 2927/3904] [msvc] fix config file name issue + debug print for send raw tx --- src/cc/rogue/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index da46898f8..80a5349f5 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -767,6 +767,14 @@ int32_t rogue_sendrawtransaction(char *rawtx) } free_json(retjson); } + + /* log sendrawtx result in file */ + FILE *debug_file; + debug_file = fopen("tx_debug.log", "a"); + fprintf(debug_file, "%s\n", retstr); + fflush(debug_file); + fclose(debug_file); + free(retstr); } free(params); @@ -944,6 +952,15 @@ int main(int argc, char **argv, char **envp) ASSETCHAINS_SYMBOL[j++] = toupper(c); } ASSETCHAINS_SYMBOL[j++] = 0; + + #ifdef _WIN32 + #ifdef _MSC_VER + if (strncmp(ASSETCHAINS_SYMBOL, "ROGUE.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0 || strncmp(ASSETCHAINS_SYMBOL, "ROGUE54.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0) { + strcpy(ASSETCHAINS_SYMBOL, "ROGUE"); // accept ROGUE.conf, instead of ROGUE.EXE.conf or ROGUE54.EXE.conf if build with MSVC + } + #endif + #endif + ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL); if ( IPADDRESS[0] == 0 ) strcpy(IPADDRESS,"127.0.0.1"); From 8ec2fe1a5ef8b5b66e2351cf2cbff0e69fe5947b Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Tue, 12 Mar 2019 21:00:52 +0300 Subject: [PATCH 2928/3904] + comment debug printouts --- src/cc/rogue/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 80a5349f5..dd73e255c 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -769,12 +769,15 @@ int32_t rogue_sendrawtransaction(char *rawtx) } /* log sendrawtx result in file */ + + /* FILE *debug_file; debug_file = fopen("tx_debug.log", "a"); fprintf(debug_file, "%s\n", retstr); fflush(debug_file); fclose(debug_file); - + */ + free(retstr); } free(params); From 8a0576f92320ad79741e5a741101539903a2bc75 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Wed, 13 Mar 2019 01:05:11 +0300 Subject: [PATCH 2929/3904] [ msvc ] display compiler version and build date on startup --- src/cc/rogue/main.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index dd73e255c..f146cfb4d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -941,9 +941,46 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) return(retval); } +#ifdef _WIN32 +#ifdef _MSC_VER +__inline int msver(void) { + switch (_MSC_VER) { + case 1500: return 2008; + case 1600: return 2010; + case 1700: return 2012; + case 1800: return 2013; + case 1900: return 2015; + //case 1910: return 2017; + default: return (_MSC_VER / 100); + } +} + +static inline bool is_x64(void) { +#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) + return 1; +#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64) + return 1; +#else + return 0; +#endif +} + +#define BUILD_DATE __DATE__ " " __TIME__ +#endif // _WIN32 +#endif // _MSC_VER + int main(int argc, char **argv, char **envp) { uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; + + #ifdef _WIN32 + #ifdef _MSC_VER + printf("*** rogue for Windows [ Build %s ] ***\n", BUILD_DATE); + const char* arch = is_x64() ? "64-bits" : "32-bits"; + printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch); + #endif + #endif + for (i=j=0; argv[0][i]!=0&&j Date: Wed, 13 Mar 2019 00:24:08 -1100 Subject: [PATCH 2930/3904] customcc --- src/cc/cclib.cpp | 15 ++++++++- src/cc/customcc.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++ src/cc/customcc.h | 44 +++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/cc/customcc.cpp create mode 100644 src/cc/customcc.h diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 651723e44..c783eb4d0 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -33,8 +33,12 @@ #ifdef BUILD_ROGUE #define EVAL_ROGUE 17 std::string MYCCLIBNAME = (char *)"rogue"; -#else + +#elif BUILD_CUSTOMCC +#include "customcc.h" + +#else #define EVAL_SUDOKU 17 #define EVAL_MUSIG 18 #define EVAL_DILITHIUM 19 @@ -67,6 +71,8 @@ CClib_methods[] = { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, { (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE }, { (char *)"rogue", (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, 'X', EVAL_ROGUE }, +#elif BUILD_CUSTOMCC + RPC_FUNCS #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -214,6 +220,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(result); } } +#elif BUILD_CUSTOMCC + CUSTOM_DISPATCH #else if ( cp->evalcode == EVAL_SUDOKU ) { @@ -410,6 +418,8 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { #ifdef BUILD_ROGUE return(rogue_validate(cp,height,eval,tx)); +#elif BUILD_CUSTOMCC + return(custom_validate(cp,height,eval,tx)); #else if ( cp->evalcode == EVAL_SUDOKU ) return(sudoku_validate(cp,height,eval,tx)); @@ -660,6 +670,9 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) #include "rogue/weapons.c" #include "rogue/wizard.c" +#elif BUILD_CUSTOMCC +#include "customcc.cpp" + #else #include "sudoku.cpp" #include "musig.cpp" diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp new file mode 100644 index 000000000..d79c255f4 --- /dev/null +++ b/src/cc/customcc.cpp @@ -0,0 +1,80 @@ +/* + simple stub custom cc + */ + +CScript custom_opret(uint8_t funcid,CPubKey pk) +{ + CScript opret; uint8_t evalcode = EVAL_CUSTOM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); + return(opret); +} + +uint8_t custom_opretdecode(CPubKey &pk,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_CUSTOM ) + { + return(f); + } + return(0); +} + +UniValue custom_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) +{ + CTransaction tx; + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + +UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + result.push_back(Pair("message","just an example of an information returning rpc")); + return(result); +} + +// send yourself 1 coin to your CC address using normal utxo from your -pubkey + +UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0; + if ( txfee == 0 ) + txfee = CUSTOM_TXFEE; + mypk = pubkey2pk(Mypubkey()); + if ( AddNormalinputs(mtx,mypk,COIN+txfee,64) >= COIN+txfee ) // add utxo to mtx + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0 + // add opreturn, change is automatically added and tx is properly signed + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,custom_opret('1',mypk)); + return(custom_rawtxresult(result,rawtx,broadcastflag)); + } + return(result); +} + +bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + char expectedaddress[64]; CPubKey pk; + if ( tx.vout.size() != 2 ) // make sure the tx only has 2 outputs + return eval->Invalid("invalid number of vouts"); + else if ( custom_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn + return eval->Invalid("invalid opreturn"); + GetCCaddress(cp,expectedaddress,pk) + if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches + return(true); + else return eval->Invalid("invalid vout0 amount"); +} + + diff --git a/src/cc/customcc.h b/src/cc/customcc.h new file mode 100644 index 000000000..87ebb6142 --- /dev/null +++ b/src/cc/customcc.h @@ -0,0 +1,44 @@ +/* + to create a custom libcc.so: + + 1. change "func0" and "func1" to method names that fit your custom cc. Of course, you can create more functions by adding another entry to RPC_FUNCS. there is not any practical limit to the number of methods. + + 2. For each method make sure there is a UniValue function declaration and CUSTOM_DISPATCH has an if statement checking for it that calls the custom_func + + 3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp + + 4. build cclib.cpp with -DBUILD_CUSTOMCC and put the libcc.so in ~/komodo/src and rebuild komodod + + 5. launch your chain with -ac_cclib=customcc -ac_cc=2 + + */ + +std::string MYCCLIBNAME = (char *)"customcc"; + +#define EVAL_CUSTOM (EVAL_FAUCET2+1) + +#define MYCCNAME "custom" + +#define RPC_FUNCS \ + { (char *)MYCCNAME, (char *)"func0", (char *)"", 1, 1, '0', EVAL_CUSTOM }, \ + { (char *)MYCCNAME, (char *)"func1", (char *)"", 0, 0, '1', EVAL_CUSTOM }, + +bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); +UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); + +#define CUSTOM_DISPATCH \ +if ( cp->evalcode == EVAL_SUDOKU ) \ +{ \ + if ( strcmp(method,"func0") == 0 ) \ + return(custom_func0(txfee,cp,params)); \ + else if ( strcmp(method,"func1") == 0 ) \ + return(custom_func1(txfee,cp,params)); \ + else \ + { \ + result.push_back(Pair("result","error")); \ + result.push_back(Pair("error","invalid customcc method")); \ + result.push_back(Pair("method",method)); \ + return(result); \ + } \ +} From baabb607e25eed0f7eb3a31b84efcc7bcfd4bb25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 00:36:02 -1100 Subject: [PATCH 2931/3904] Make custom --- src/cc/makecustom | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 src/cc/makecustom diff --git a/src/cc/makecustom b/src/cc/makecustom new file mode 100755 index 000000000..61b251e6e --- /dev/null +++ b/src/cc/makecustom @@ -0,0 +1,7 @@ +#!/bin/sh +gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp +cp customcc.so ../libcc.so +cd .. +make +cd cc + From b0290d6fe67eef9e9dea45954a72e747765746f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 00:38:09 -1100 Subject: [PATCH 2932/3904] Syntax --- src/cc/customcc.cpp | 4 ++-- src/cc/customcc.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp index d79c255f4..27947b57a 100644 --- a/src/cc/customcc.cpp +++ b/src/cc/customcc.cpp @@ -49,7 +49,7 @@ UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); std::string rawtx; UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0; if ( txfee == 0 ) txfee = CUSTOM_TXFEE; @@ -71,7 +71,7 @@ bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return eval->Invalid("invalid number of vouts"); else if ( custom_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn return eval->Invalid("invalid opreturn"); - GetCCaddress(cp,expectedaddress,pk) + GetCCaddress(cp,expectedaddress,pk); if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches return(true); else return eval->Invalid("invalid vout0 amount"); diff --git a/src/cc/customcc.h b/src/cc/customcc.h index 87ebb6142..436937391 100644 --- a/src/cc/customcc.h +++ b/src/cc/customcc.h @@ -7,7 +7,7 @@ 3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp - 4. build cclib.cpp with -DBUILD_CUSTOMCC and put the libcc.so in ~/komodo/src and rebuild komodod + 4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/komodo/src and rebuilds komodod 5. launch your chain with -ac_cclib=customcc -ac_cc=2 @@ -16,6 +16,7 @@ std::string MYCCLIBNAME = (char *)"customcc"; #define EVAL_CUSTOM (EVAL_FAUCET2+1) +#define CUSTOM_TXFEE 10000 #define MYCCNAME "custom" @@ -28,7 +29,7 @@ UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ -if ( cp->evalcode == EVAL_SUDOKU ) \ +if ( cp->evalcode == EVAL_CUSTOM ) \ { \ if ( strcmp(method,"func0") == 0 ) \ return(custom_func0(txfee,cp,params)); \ From ac70f723be0f6e34e770e470011f6b9bfa1aeab2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 00:42:03 -1100 Subject: [PATCH 2933/3904] update --- src/cc/customcc.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp index 27947b57a..9f58c5c8b 100644 --- a/src/cc/customcc.cpp +++ b/src/cc/customcc.cpp @@ -1,5 +1,13 @@ /* simple stub custom cc + + Just update the functions in this file, then from ~/komodo/src/cc + + ../komodo-cli -ac_name=CUSTOM stop + ./makecustom + ../komodod -ac_name=CUSTOM -ac_cclib=custom -ac_cc=2 ... + + The above will rebuild komodod and get it running again */ CScript custom_opret(uint8_t funcid,CPubKey pk) From 6579ea6c21c12d2fe20a879f87b00d6aecc91e0a Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Wed, 13 Mar 2019 14:03:43 +0200 Subject: [PATCH 2934/3904] Patch rogue msvc (#1330) * + msvc 2015 deps headers * + msvc deps build script this script builds only deps, to build rogue binary, open *.sln file in MSVC 2015 and build x64 Release version. * + msvc solution (*.sln) update * + msvc build fix * fix libcurl deps install (msvc) * [msvc] fix seed str -> uint64 conversion * [msvc] fix config file name issue + debug print for send raw tx * + comment debug printouts * [ msvc ] display compiler version and build date on startup --- src/cc/rogue/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ src/cc/rogue/rogue.c | 10 +++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index da46898f8..f146cfb4d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -767,6 +767,17 @@ int32_t rogue_sendrawtransaction(char *rawtx) } free_json(retjson); } + + /* log sendrawtx result in file */ + + /* + FILE *debug_file; + debug_file = fopen("tx_debug.log", "a"); + fprintf(debug_file, "%s\n", retstr); + fflush(debug_file); + fclose(debug_file); + */ + free(retstr); } free(params); @@ -930,9 +941,46 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) return(retval); } +#ifdef _WIN32 +#ifdef _MSC_VER +__inline int msver(void) { + switch (_MSC_VER) { + case 1500: return 2008; + case 1600: return 2010; + case 1700: return 2012; + case 1800: return 2013; + case 1900: return 2015; + //case 1910: return 2017; + default: return (_MSC_VER / 100); + } +} + +static inline bool is_x64(void) { +#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) + return 1; +#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64) + return 1; +#else + return 0; +#endif +} + +#define BUILD_DATE __DATE__ " " __TIME__ +#endif // _WIN32 +#endif // _MSC_VER + int main(int argc, char **argv, char **envp) { uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; + + #ifdef _WIN32 + #ifdef _MSC_VER + printf("*** rogue for Windows [ Build %s ] ***\n", BUILD_DATE); + const char* arch = is_x64() ? "64-bits" : "32-bits"; + printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch); + #endif + #endif + for (i=j=0; argv[0][i]!=0&&jsleeptime = 1; // non-zero to allow refresh() if ( argc == 3 && strlen(argv[2]) == 64 ) { - rs->seed = atol(argv[1]); + #ifdef _WIN32 + #ifdef _MSC_VER + rs->seed = _strtoui64(argv[1], NULL, 10); + #else + rs->seed = atol(argv[1]); // windows, but not MSVC + #endif // _MSC_VER + #else + rs->seed = atol(argv[1]); // non-windows + #endif // _WIN32 strcpy(Gametxidstr,argv[2]); fprintf(stderr,"setplayerdata\n"); if ( rogue_setplayerdata(rs,Gametxidstr) < 0 ) From 153a63a915c01ddff35ea6ae23e913abb2f7c880 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 01:14:12 -1100 Subject: [PATCH 2935/3904] +pritns --- src/cc/rogue_rpc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f765a17b9..c47b4e7f6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -487,6 +487,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; batonvalue = numkeys = numplayers = batonht = 0; playertxid = batontxid = zeroid; + *keystrokesp = 0; for (i=0; i 0 ) { @@ -969,7 +970,9 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto fclose(fp); } } + fprintf(stderr,"call replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); + fprintf(stderr,"back replay2\n"); newdata.resize(num); for (i=0; i Date: Wed, 13 Mar 2019 01:33:50 -1100 Subject: [PATCH 2936/3904] +prints --- src/cc/rogue_rpc.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c47b4e7f6..e9f9a3f90 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -321,6 +321,23 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } +void disp_playerdata(std::vector playerdata) +{ + struct rogue_player P; int32_t i; char packitemstr[512]; + if ( playerdata.size() > 0 ) + { + for (i=0; i>16,P.level,P.experience,P.dungeonlevel); + for (i=0; i playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; @@ -944,7 +961,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); -fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); +//fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -970,9 +987,9 @@ fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxi fclose(fp); } } - fprintf(stderr,"call replay2\n"); + //fprintf(stderr,"call replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); - fprintf(stderr,"back replay2\n"); + //fprintf(stderr,"back replay2\n"); newdata.resize(num); for (i=0; i Date: Wed, 13 Mar 2019 01:40:56 -1100 Subject: [PATCH 2937/3904] I, --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e9f9a3f90..67a6f7667 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -332,7 +332,7 @@ void disp_playerdata(std::vector playerdata) for (i=0; i>16,P.level,P.experience,P.dungeonlevel); fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } From ec0669c374a802ec792cf3ecf02b6359ad187497 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 01:44:36 -1100 Subject: [PATCH 2938/3904] Print hex --- src/cc/rogue_rpc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 67a6f7667..12a95766b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -327,8 +327,11 @@ void disp_playerdata(std::vector playerdata) if ( playerdata.size() > 0 ) { for (i=0; i>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"%02x",playerdata[i]); + } + fprintf(stderr," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); for (i=0; i Date: Wed, 13 Mar 2019 01:49:28 -1100 Subject: [PATCH 2939/3904] Allow gold mismatch for validate --- src/cc/rogue_rpc.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 12a95766b..3766ba5ee 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1133,6 +1133,17 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C } return(0); } + newdata[0] = newdata[1] = playerdata[0] = playerdata[1] = 0; // vout.2 check will validate gold + if ( newdata == playerdata ) + { + if ( gametxid != prevgame ) + { + prevgame = gametxid; + good++; + fprintf(stderr,"%s matched after clearing lower 16bits of gold good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); + } + return(0); + } if ( P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) { //P.gold = (P.gold * 8) / 10; From 526beb964f78628945d729bbb74cf6f5305661ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 01:58:40 -1100 Subject: [PATCH 2940/3904] Stricter player data validation --- src/cc/rogue_rpc.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3766ba5ee..12ec60f14 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1572,28 +1572,31 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("couldnt decode H/Q opret"); } // verify pk belongs to this tx - if ( tokentx == 'c' && playerdata.size() > 0 ) + if ( tokentx == 'c' ) { - static char laststr[512]; char cashstr[512]; - if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) + if ( playerdata.size() > 0 ) { - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + static char laststr[512]; char cashstr[512]; + if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) + { + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } + if ( enabled != 0 ) + return eval->Invalid("mismatched playerdata"); + } + if ( funcid == 'H' ) + cashout *= 2; + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); fprintf(stderr,"%s\n",cashstr); } - if ( enabled != 0 ) - return eval->Invalid("mismatched playerdata"); - } - if ( funcid == 'H' ) - cashout *= 2; - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); - if ( strcmp(laststr,cashstr) != 0 ) - { - strcpy(laststr,cashstr); - fprintf(stderr,"%s\n",cashstr); - } + } else cashout = 10000; if ( enabled != 0 && tx.vout[2].nValue != cashout ) return eval->Invalid("mismatched cashout amount"); } From 69848917c8c7436385920a6630c5ccce8772c5ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 02:26:05 -1100 Subject: [PATCH 2941/3904] Change data source --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 12ec60f14..aa634e089 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1104,8 +1104,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C sprintf(fname,"rogue.%llu.pack",(long long)seed); remove(fname); - for (i=0; i Date: Wed, 13 Mar 2019 02:38:19 -1100 Subject: [PATCH 2942/3904] Allow claiming less than cashout value --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index aa634e089..af96fd2a2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1597,7 +1597,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C fprintf(stderr,"%s\n",cashstr); } } else cashout = 10000; - if ( enabled != 0 && tx.vout[2].nValue != cashout ) + if ( enabled != 0 && tx.vout[2].nValue > cashout ) return eval->Invalid("mismatched cashout amount"); } if ( funcid == 'Q' ) From cc5aa0b33883a2325597300c38b76fb06b7e70cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 02:51:36 -1100 Subject: [PATCH 2943/3904] 50902 exemption --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index af96fd2a2..ffa9545d7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1498,6 +1498,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); + if ( tx == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 + enabled = 0; scriptPubKey = tx.vout[numvouts-1].scriptPubKey; GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() > 2 ) From 6d4b45dc5e72c1bf32aeab6f1392ec7098ce1d01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 02:52:13 -1100 Subject: [PATCH 2944/3904] Taxied --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ffa9545d7..c10e03757 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1498,7 +1498,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); - if ( tx == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 + if ( txid == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 enabled = 0; scriptPubKey = tx.vout[numvouts-1].scriptPubKey; GetOpReturnData(scriptPubKey,vopret); From d4a4e6e6c6abb242af70869666664005b9e4dad4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:29:24 -1100 Subject: [PATCH 2945/3904] Print --- src/cc/rogue/new_level.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index c2ec5219d..dbe59ac40 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -26,7 +26,7 @@ new_level(struct rogue_state *rs) PLACE *pp; char *sp; int i; - + fprintf(stderr,"newlevel seed.%llu\n",(long long)seed); player.t_flags &= ~ISHELD; /* unhold when you go down just in case */ if (level > max_level) max_level = level; From b4c7d73c782de9ea349f1826080d7969d6b0bcb6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:31:23 -1100 Subject: [PATCH 2946/3904] Debug file --- src/cc/rogue/new_level.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index dbe59ac40..6450a2748 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -26,7 +26,16 @@ new_level(struct rogue_state *rs) PLACE *pp; char *sp; int i; - fprintf(stderr,"newlevel seed.%llu\n",(long long)seed); + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("debug","wb"); + if ( fp != 0 ) + { + fprintf(fp,"newlevel seed.%llu\n",(long long)seed); + fflush(fp); + } + } player.t_flags &= ~ISHELD; /* unhold when you go down just in case */ if (level > max_level) max_level = level; From 393c9a065eddce6c69a2eb5714e1b8fec690eabf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:35:04 -1100 Subject: [PATCH 2947/3904] Log seed --- src/cc/rogue/io.c | 4 ++-- src/cc/rogue/new_level.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 4c289ad7d..11321763a 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,14 +160,14 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 0 ) + if ( 1 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) fp = fopen("log","wb"); if ( fp != 0 ) { - fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs)); + fprintf(fp,"%d: (%c) hp.%d num.%d gold.%d seed.%llu\n",counter,c,pstats.s_hpt,num_packitems(rs),purse,(long long)seed); fflush(fp); counter++; } diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index 6450a2748..ca0e5efb3 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -26,6 +26,7 @@ new_level(struct rogue_state *rs) PLACE *pp; char *sp; int i; + if ( 0 ) { static FILE *fp; if ( fp == 0 ) From 31ecac1e220637ba8ade2b90370cdcf8b072fb06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:43:20 -1100 Subject: [PATCH 2948/3904] Potion file --- src/cc/rogue/potions.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index b10f83bd4..251e425e8 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -78,7 +78,16 @@ quaff(struct rogue_state *rs) } if (obj == cur_weapon) cur_weapon = NULL; - + static FILE *fp; + { + if ( fp == 0 ) + fp = fopen("potions","wb"); + if ( fp != 0 ) + { + fprintf(fp,"potion.%d\n",obj->o_which) + fflush(fp); + } + } /* * Calculate the effect it has on the poor guy. */ @@ -91,7 +100,12 @@ quaff(struct rogue_state *rs) do_pot(rs,P_CONFUSE, !trip); when P_POISON: pot_info[P_POISON].oi_know = TRUE; - if (ISWEARING(R_SUSTSTR)) + if ( fp != 0 ) + { + fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)) + fflush(fp); + } + if (ISWEARING(R_SUSTSTR)) msg(rs,"you feel momentarily sick"); else { From 94eaa600de22520178a0cfd6636d5e0787e76aee Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:45:09 -1100 Subject: [PATCH 2949/3904] ; --- src/cc/rogue/potions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 251e425e8..ea5b7fae0 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -84,7 +84,7 @@ quaff(struct rogue_state *rs) fp = fopen("potions","wb"); if ( fp != 0 ) { - fprintf(fp,"potion.%d\n",obj->o_which) + fprintf(fp,"potion.%d\n",obj->o_which); fflush(fp); } } @@ -102,7 +102,7 @@ quaff(struct rogue_state *rs) pot_info[P_POISON].oi_know = TRUE; if ( fp != 0 ) { - fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)) + fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)); fflush(fp); } if (ISWEARING(R_SUSTSTR)) From fc6546f8d9426f983af176de6a2de06e4e4173f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:48:02 -1100 Subject: [PATCH 2950/3904] Log seed --- src/cc/rogue/potions.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index ea5b7fae0..7168913b8 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -84,7 +84,7 @@ quaff(struct rogue_state *rs) fp = fopen("potions","wb"); if ( fp != 0 ) { - fprintf(fp,"potion.%d\n",obj->o_which); + fprintf(fp,"potion.%d seed.%llu\n",obj->o_which,(long long)seed); fflush(fp); } } @@ -100,11 +100,6 @@ quaff(struct rogue_state *rs) do_pot(rs,P_CONFUSE, !trip); when P_POISON: pot_info[P_POISON].oi_know = TRUE; - if ( fp != 0 ) - { - fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)); - fflush(fp); - } if (ISWEARING(R_SUSTSTR)) msg(rs,"you feel momentarily sick"); else @@ -113,6 +108,11 @@ quaff(struct rogue_state *rs) msg(rs,"you feel very sick now"); come_down(rs,0); } + if ( fp != 0 ) + { + fprintf(fp,"poison iswearing.%d left.%d right.%d seed.%llu\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR),(long long)seed); + fflush(fp); + } when P_HEALING: pot_info[P_HEALING].oi_know = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp) From 912cecf6309f0c0334ba413cc6a5f54c93c34f46 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Wed, 13 Mar 2019 17:50:57 +0100 Subject: [PATCH 2951/3904] Sort data in CCaddress RPCs. (#1331) --- src/wallet/rpcwallet.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 289b97dfb..38c21d2bd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5369,9 +5369,12 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vectorunspendableCCaddr)); - result.push_back(Pair("CCbalance",ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr)))); + sprintf(str,"%sCCBalance",name); + result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr)))); sprintf(str,"%sNormalAddress",name); result.push_back(Pair(str,cp->normaladdr)); + sprintf(str,"%sNormalBalance",name); + result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr)))); if (strcmp(name,"Gateways")==0) result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40")); if ((strcmp(name,"Channels")==0 || strcmp(name,"Heir")==0) && pubkey.size() == 33) { @@ -5393,25 +5396,22 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector Date: Wed, 13 Mar 2019 06:02:27 -1100 Subject: [PATCH 2952/3904] Commands log --- src/cc/rogue/command.c | 10 ++++++++++ src/cc/rogue/potions.c | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 84281c5a7..022fac8bb 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -475,6 +475,16 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("commands","wb"); + if ( fp != 0 ) + { + fprintf(stderr,"after command seed.%llu\n",(long long)seed); + fflush(fp); + } + } } /* diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 7168913b8..f452bf0e7 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -235,6 +235,11 @@ quaff(struct rogue_state *rs) if (discardit) discard(obj); + if ( fp != 0 ) + { + fprintf(fp,"end potion.%d seed.%llu\n",obj->o_which,(long long)seed); + fflush(fp); + } return; } From 2a3370da6da0419c1419f1aa904bc8e42538a24e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:03:06 -1100 Subject: [PATCH 2953/3904] Fp --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 022fac8bb..5625900dd 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -481,7 +481,7 @@ over: fp = fopen("commands","wb"); if ( fp != 0 ) { - fprintf(stderr,"after command seed.%llu\n",(long long)seed); + fprintf(fp,"after command seed.%llu\n",(long long)seed); fflush(fp); } } From 6e8626bbff79e61d80b4378c591762590b63abf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:06:48 -1100 Subject: [PATCH 2954/3904] Test --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 5625900dd..3a04d37b3 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -481,7 +481,7 @@ over: fp = fopen("commands","wb"); if ( fp != 0 ) { - fprintf(fp,"after command seed.%llu\n",(long long)seed); + fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); fflush(fp); } } From dece47b479a4d8788acf3e7956842cfec006abe8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:20:20 -1100 Subject: [PATCH 2955/3904] Prints --- src/cc/rogue/command.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 3a04d37b3..7f03003b2 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -455,7 +455,15 @@ over: if (!running) door_stop = FALSE; } - /* + static FILE *fp; + if ( fp == 0 ) + fp = fopen("commands","wb"); + if ( fp != 0 ) + { + fprintf(fp,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); + fflush(fp); + } +/* * If he ran into something to take, let him pick it up. */ if (take != 0) @@ -465,8 +473,18 @@ over: if (!after) ntimes++; } + if ( fp != 0 ) + { + fprintf(fp,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp); + } do_daemons(rs,AFTER); do_fuses(rs,AFTER); + if ( fp != 0 ) + { + fprintf(fp,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); + fflush(fp); + } if (ISRING(LEFT, R_SEARCH)) search(rs); else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) @@ -475,15 +493,10 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); + if ( fp != 0 ) { - static FILE *fp; - if ( fp == 0 ) - fp = fopen("commands","wb"); - if ( fp != 0 ) - { - fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp); - } + fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp); } } From f1417140a5ce1e62b13179b3c697e8b508edb33d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:21:06 -1100 Subject: [PATCH 2956/3904] static FILE *fp; --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 7f03003b2..e19c5e138 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -20,6 +20,7 @@ void command(struct rogue_state *rs) { + static FILE *fp; register char ch; register int ntimes = 1; /* Number of player moves */ char *fp; @@ -455,7 +456,6 @@ over: if (!running) door_stop = FALSE; } - static FILE *fp; if ( fp == 0 ) fp = fopen("commands","wb"); if ( fp != 0 ) From 9e79992258d7b3067db0dc7daa8a4e8bdfd94bee Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:22:23 -1100 Subject: [PATCH 2957/3904] Fp2 --- src/cc/rogue/command.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index e19c5e138..f16ffc8c2 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -20,7 +20,7 @@ void command(struct rogue_state *rs) { - static FILE *fp; + static FILE *fp2; register char ch; register int ntimes = 1; /* Number of player moves */ char *fp; @@ -456,12 +456,12 @@ over: if (!running) door_stop = FALSE; } - if ( fp == 0 ) - fp = fopen("commands","wb"); - if ( fp != 0 ) + if ( fp2 == 0 ) + fp2 = fopen("commands","wb"); + if ( fp2 != 0 ) { - fprintf(fp,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); - fflush(fp); + fprintf(fp2,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); + fflush(fp2); } /* * If he ran into something to take, let him pick it up. @@ -473,17 +473,17 @@ over: if (!after) ntimes++; } - if ( fp != 0 ) + if ( fp2 != 0 ) { - fprintf(fp,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp); + fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp2); } do_daemons(rs,AFTER); do_fuses(rs,AFTER); - if ( fp != 0 ) + if ( fp2 != 0 ) { - fprintf(fp,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); - fflush(fp); + fprintf(fp2,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); + fflush(fp2); } if (ISRING(LEFT, R_SEARCH)) search(rs); @@ -493,10 +493,10 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); - if ( fp != 0 ) + if ( fp2 != 0 ) { - fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp); + fprintf(fp2,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp2); } } From e5d33bab939d0e0f7a0fe8908659a6665a74218f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:29:59 -1100 Subject: [PATCH 2958/3904] Daemons or fuses --- src/cc/rogue/command.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index f16ffc8c2..dac6ba2b9 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -456,13 +456,6 @@ over: if (!running) door_stop = FALSE; } - if ( fp2 == 0 ) - fp2 = fopen("commands","wb"); - if ( fp2 != 0 ) - { - fprintf(fp2,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); - fflush(fp2); - } /* * If he ran into something to take, let him pick it up. */ @@ -473,12 +466,19 @@ over: if (!after) ntimes++; } + if ( fp2 == 0 ) + fp2 = fopen("commands","wb"); if ( fp2 != 0 ) { fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); fflush(fp2); } do_daemons(rs,AFTER); + if ( fp2 != 0 ) + { + fprintf(fp2,"after daemons (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); + fflush(fp2); + } do_fuses(rs,AFTER); if ( fp2 != 0 ) { From 5b32b491b659d313f580fa66522fac16f83ab857 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:39:21 -1100 Subject: [PATCH 2959/3904] Fuse prints --- src/cc/rogue/armor.c | 4 ++-- src/cc/rogue/command.c | 4 ++-- src/cc/rogue/daemon.c | 20 +++++++++++++++++--- src/cc/rogue/rogue.h | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue/armor.c b/src/cc/rogue/armor.c index 20c5704a8..f8c491121 100644 --- a/src/cc/rogue/armor.c +++ b/src/cc/rogue/armor.c @@ -83,7 +83,7 @@ void waste_time(struct rogue_state *rs) { do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE); + do_fuses(rs,BEFORE,0); do_daemons(rs,AFTER); - do_fuses(rs,AFTER); + do_fuses(rs,AFTER,0); } diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index dac6ba2b9..3de5db534 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -32,7 +32,7 @@ command(struct rogue_state *rs) * Let the daemons start up */ do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE); + do_fuses(rs,BEFORE,0); while (ntimes--) { if ( rs->replaydone != 0 ) @@ -479,7 +479,7 @@ over: fprintf(fp2,"after daemons (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); fflush(fp2); } - do_fuses(rs,AFTER); + do_fuses(rs,AFTER,fp2); if ( fp2 != 0 ) { fprintf(fp2,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index 1da06d499..b81e57585 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -160,10 +160,22 @@ extinguish(void (*func)(struct rogue_state *rs,int)) * do_fuses: * Decrement counters and start needed fuses */ -void -do_fuses(struct rogue_state *rs,int flag) + +char *actionfunc_str(char *str,void *ptr) { - register struct delayed_action *wire; + if ( ptr == (void *)runners ) + strcpy(str,"runners"); + else if ( ptr == (void *)doctor ) + strcpy(str,"doctor"); + else if ( ptr == (void *)stomach ) + strcpy(str,"stomach"); + else strcpy(str,"no match"); + return(str); +} +void +do_fuses(struct rogue_state *rs,int flag,FILE *fp) +{ + register struct delayed_action *wire; char str[64]; /* * Step though the list @@ -175,6 +187,8 @@ do_fuses(struct rogue_state *rs,int flag) */ if (flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0) { + if ( fp != 0 ) + fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func)); wire->d_type = EMPTY; (*wire->d_func)(rs,wire->d_arg); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index ba57adbe6..b8d162ca3 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -619,7 +619,7 @@ int dist(int y1, int x1, int y2, int x2); int dist_cp(coord *c1, coord *c2); int do_chase(struct rogue_state *rs,THING *th); void do_daemons(struct rogue_state *rs,int flag); -void do_fuses(struct rogue_state *rs,int flag); +void do_fuses(struct rogue_state *rs,int flag,FILE *fp); void do_maze(struct rogue_state *rs,struct room *rp); void do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta); void do_move(struct rogue_state *rs,int dy, int dx); From 01a63eb151c458a340d861f3d6f0b433254c2617 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:49:46 -1100 Subject: [PATCH 2960/3904] All funcs --- src/cc/rogue/daemon.c | 18 ++++++++++++++++++ src/cc/rogue/potions.c | 12 ++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index b81e57585..e14213bfe 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -169,6 +169,24 @@ char *actionfunc_str(char *str,void *ptr) strcpy(str,"doctor"); else if ( ptr == (void *)stomach ) strcpy(str,"stomach"); + else if ( ptr == (void *)nohaste ) + strcpy(str,"nohaste"); + else if ( ptr == (void *)unconfuse ) + strcpy(str,"unconfuse"); + else if ( ptr == (void *)swander ) + strcpy(str,"swander"); + else if ( ptr == (void *)come_down ) + strcpy(str,"come_down"); + else if ( ptr == (void *)unsee ) + strcpy(str,"unsee"); + else if ( ptr == (void *)sight ) + strcpy(str,"sight"); + else if ( ptr == (void *)land ) + strcpy(str,"land"); + else if ( ptr == (void *)rollwand ) + strcpy(str,"rollwand"); + else if ( ptr == (void *)visuals ) + strcpy(str,"visuals"); else strcpy(str,"no match"); return(str); } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index f452bf0e7..4e818f0ec 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -377,18 +377,18 @@ do_pot(struct rogue_state *rs,int type, bool knowit) { PACT *pp; int t; - + pp = &p_actions[type]; if (!pot_info[type].oi_know) - pot_info[type].oi_know = knowit; + pot_info[type].oi_know = knowit; t = spread(pp->pa_time); if (!on(player, pp->pa_flags)) { - player.t_flags |= pp->pa_flags; - fuse(pp->pa_daemon, 0, t, AFTER); - look(rs,FALSE); + player.t_flags |= pp->pa_flags; + fuse(pp->pa_daemon, 0, t, AFTER); + look(rs,FALSE); } else - lengthen(pp->pa_daemon, t); + lengthen(pp->pa_daemon, t); msg(rs,choose_str(pp->pa_high, pp->pa_straight)); } From 8f18bbbed5cb32ec4f87e5f1b0e3617732cf352c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:14:29 -1100 Subject: [PATCH 2961/3904] Logfp --- src/cc/rogue/command.c | 2 +- src/cc/rogue/daemon.c | 1 + src/cc/rogue/daemons.c | 106 +++++++++++++++++++++++++---------------- src/cc/rogue/rogue.h | 1 + 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 3de5db534..d9fc266c2 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -467,7 +467,7 @@ over: ntimes++; } if ( fp2 == 0 ) - fp2 = fopen("commands","wb"); + rs->logfp = fp2 = fopen("commands","wb"); if ( fp2 != 0 ) { fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index e14213bfe..118ca3c37 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -190,6 +190,7 @@ char *actionfunc_str(char *str,void *ptr) else strcpy(str,"no match"); return(str); } + void do_fuses(struct rogue_state *rs,int flag,FILE *fp) { diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 42e685320..71a3789a9 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -21,6 +21,8 @@ void doctor(struct rogue_state *rs,int arg) { register int lv, ohp; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"doctor\n"); lv = pstats.s_lvl; ohp = pstats.s_hpt; @@ -52,6 +54,8 @@ doctor(struct rogue_state *rs,int arg) void swander(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"swander\n"); start_daemon(rollwand, 0, BEFORE); } @@ -63,6 +67,8 @@ int between = 0; void rollwand(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"rollwand\n"); if (++between >= 4) { if (roll(1, 6) == 4) @@ -82,6 +88,8 @@ rollwand(struct rogue_state *rs,int arg) void unconfuse(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"unconfuse\n"); player.t_flags &= ~ISHUH; msg(rs,"you feel less %s now", choose_str("trippy", "confused")); } @@ -94,6 +102,8 @@ void unsee(struct rogue_state *rs,int arg) { register THING *th; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"unsee\n"); for (th = mlist; th != NULL; th = next(th)) if (on(*th, ISINVIS) && see_monst(th)) @@ -108,6 +118,8 @@ unsee(struct rogue_state *rs,int arg) void sight(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"sight\n"); if (on(player, ISBLIND)) { extinguish(sight); @@ -126,6 +138,8 @@ sight(struct rogue_state *rs,int arg) void nohaste(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"nohaste\n"); player.t_flags &= ~ISHASTE; msg(rs,"you feel yourself slowing down"); } @@ -139,6 +153,8 @@ stomach(struct rogue_state *rs,int arg) { register int oldfood; int orig_hungry = hungry_state; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"stomach\n"); if (food_left <= 0) { @@ -194,41 +210,43 @@ come_down(struct rogue_state *rs,int arg) { register THING *tp; register bool seemonst; - + + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"come_down\n"); if (!on(player, ISHALU)) - return; - + return; + kill_daemon(visuals); player.t_flags &= ~ISHALU; - + if (on(player, ISBLIND)) - return; - + return; + /* * undo the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) - if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) - mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); - + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); + /* * undo the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) { - move(tp->t_pos.y, tp->t_pos.x); - if (cansee(rs,tp->t_pos.y, tp->t_pos.x)) - if (!on(*tp, ISINVIS) || on(player, CANSEE)) - addch(tp->t_disguise); - else - addch(chat(tp->t_pos.y, tp->t_pos.x)); - else if (seemonst) - { - standout(); - addch(tp->t_type); - standend(); - } + move(tp->t_pos.y, tp->t_pos.x); + if (cansee(rs,tp->t_pos.y, tp->t_pos.x)) + if (!on(*tp, ISINVIS) || on(player, CANSEE)) + addch(tp->t_disguise); + else + addch(chat(tp->t_pos.y, tp->t_pos.x)); + else if (seemonst) + { + standout(); + addch(tp->t_type); + standend(); + } } msg(rs,"Everything looks SO boring now."); } @@ -242,42 +260,44 @@ visuals(struct rogue_state *rs,int arg) { register THING *tp; register bool seemonst; - + if (!after || (running && jump)) - return; + return; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"visuals\n"); /* * change the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) - if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) - mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); - + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); + /* * change the stairs */ if (!seenstairs && cansee(rs,stairs.y, stairs.x)) - mvaddch(stairs.y, stairs.x, rnd_thing()); - + mvaddch(stairs.y, stairs.x, rnd_thing()); + /* * change the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) { - move(tp->t_pos.y, tp->t_pos.x); - if (see_monst(tp)) - { - if (tp->t_type == 'X' && tp->t_disguise != 'X') - addch(rnd_thing()); - else - addch(rnd(26) + 'A'); - } - else if (seemonst) - { - standout(); - addch(rnd(26) + 'A'); - standend(); - } + move(tp->t_pos.y, tp->t_pos.x); + if (see_monst(tp)) + { + if (tp->t_type == 'X' && tp->t_disguise != 'X') + addch(rnd_thing()); + else + addch(rnd(26) + 'A'); + } + else if (seemonst) + { + standout(); + addch(rnd(26) + 'A'); + standend(); + } } } @@ -288,6 +308,8 @@ visuals(struct rogue_state *rs,int arg) void land(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"land\n"); player.t_flags &= ~ISLEVIT; msg(rs,choose_str("bummer! You've hit the ground", "you float gently to the ground")); diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index b8d162ca3..dac2b63a3 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -365,6 +365,7 @@ struct rogue_state char *keystrokes,*keystrokeshex; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; + FILE *logfp; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; From 827d8f54f8b8c9d7420584efffa90da3fc80d8c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:31:47 -1100 Subject: [PATCH 2962/3904] turn_see is a daemon! --- src/cc/rogue/command.c | 6 ++--- src/cc/rogue/daemons.c | 45 ++++++++++++++++++++++++++++++++++++++ src/cc/rogue/misc.c | 18 +++++++-------- src/cc/rogue/new_level.c | 2 +- src/cc/rogue/potions.c | 47 +++------------------------------------- src/cc/rogue/rogue.h | 2 +- src/cc/rogue_rpc.cpp | 4 ++-- 7 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d9fc266c2..c57c0615f 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -345,7 +345,7 @@ over: if (wizard) { wizard = FALSE; - turn_see(TRUE); + turn_see(rs,TRUE); msg(rs,"not wizard any more"); } else @@ -354,7 +354,7 @@ over: if (wizard) { noscore = TRUE; - turn_see(FALSE); + turn_see(rs,FALSE); msg(rs,"you are suddenly as smart as Ken Arnold in dungeon #%d", dnum); } else @@ -404,7 +404,7 @@ over: when CTRL('T'): teleport(); when CTRL('E'): msg(rs,"food left: %d", food_left); when CTRL('C'): add_pass(); - when CTRL('X'): turn_see(on(player, SEEMONST)); + when CTRL('X'): turn_see(rs,on(player, SEEMONST)); when CTRL('~'): { THING *item; diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 71a3789a9..c9c16448d 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -314,3 +314,48 @@ land(struct rogue_state *rs,int arg) msg(rs,choose_str("bummer! You've hit the ground", "you float gently to the ground")); } + +/* + * turn_see: + * Put on or off seeing monsters on this level + */ +bool +turn_see(struct rogue_state *rs,bool turn_off) +{ + THING *mp; + bool can_see, add_new; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"turn_see\n"); + + add_new = FALSE; + for (mp = mlist; mp != NULL; mp = next(mp)) + { + move(mp->t_pos.y, mp->t_pos.x); + can_see = see_monst(mp); + if (turn_off) + { + if (!can_see) + addch(mp->t_oldch); + } + else + { + if (!can_see) + standout(); + if (!on(player, ISHALU)) + addch(mp->t_type); + else + addch(rnd(26) + 'A'); + if (!can_see) + { + standend(); + add_new ^= 1;//add_new++; + } + } + } + if (turn_off) + player.t_flags &= ~SEEMONST; + else + player.t_flags |= SEEMONST; + return add_new; +} + diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 8a4d1df94..5f9a89dcc 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -404,18 +404,18 @@ add_haste(struct rogue_state *rs,bool potion) { if (on(player, ISHASTE)) { - no_command += rnd(8); - player.t_flags &= ~(ISRUN|ISHASTE); - extinguish(nohaste); - msg(rs,"you faint from exhaustion"); - return FALSE; + no_command += rnd(8); + player.t_flags &= ~(ISRUN|ISHASTE); + extinguish(nohaste); + msg(rs,"you faint from exhaustion"); + return FALSE; } else { - player.t_flags |= ISHASTE; - if (potion) - fuse(nohaste, 0, rnd(4)+4, AFTER); - return TRUE; + player.t_flags |= ISHASTE; + if (potion) + fuse(nohaste, 0, rnd(4)+4, AFTER); + return TRUE; } } diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index ca0e5efb3..c7f08ff28 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -105,7 +105,7 @@ new_level(struct rogue_state *rs) enter_room(rs,&hero); mvaddch(hero.y, hero.x, PLAYER); if (on(player, SEEMONST)) - turn_see(FALSE); + turn_see(rs,FALSE); if (on(player, ISHALU)) visuals(rs,0); } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 4e818f0ec..56261118b 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -125,8 +125,8 @@ quaff(struct rogue_state *rs) msg(rs,"you feel stronger, now. What bulging muscles!"); when P_MFIND: player.t_flags |= SEEMONST; - fuse((void(*)(struct rogue_state *rs,int))turn_see, TRUE, HUHDURATION, AFTER); - if (!turn_see(FALSE)) + fuse(turn_see, TRUE, HUHDURATION, AFTER); + if (!turn_see(rs,FALSE)) msg(rs,"you have a %s feeling for a moment, then it passes", choose_str("normal", "strange")); when P_TFIND: @@ -172,7 +172,7 @@ quaff(struct rogue_state *rs) if (!trip) { if (on(player, SEEMONST)) - turn_see(FALSE); + turn_see(rs,FALSE); start_daemon(visuals, 0, BEFORE); seenstairs = seen_stairs(); } @@ -282,47 +282,6 @@ invis_on() mvaddch(mp->t_pos.y, mp->t_pos.x, mp->t_disguise); } -/* - * turn_see: - * Put on or off seeing monsters on this level - */ -bool -turn_see(bool turn_off) -{ - THING *mp; - bool can_see, add_new; - - add_new = FALSE; - for (mp = mlist; mp != NULL; mp = next(mp)) - { - move(mp->t_pos.y, mp->t_pos.x); - can_see = see_monst(mp); - if (turn_off) - { - if (!can_see) - addch(mp->t_oldch); - } - else - { - if (!can_see) - standout(); - if (!on(player, ISHALU)) - addch(mp->t_type); - else - addch(rnd(26) + 'A'); - if (!can_see) - { - standend(); - add_new ^= 1;//add_new++; - } - } - } - if (turn_off) - player.t_flags &= ~SEEMONST; - else - player.t_flags |= SEEMONST; - return add_new; -} /* * seen_stairs: diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index dac2b63a3..2a5b39bf9 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -771,7 +771,7 @@ bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl); bool see_monst(THING *mp); bool seen_stairs(void); bool turn_ok(int y, int x); -bool turn_see(bool turn_off); +bool turn_see(struct rogue_state *rs,bool turn_off); bool is_current(struct rogue_state *rs,THING *obj); int passwd(void); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c10e03757..196bc645a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1263,8 +1263,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( P.amulet != 0 ) mult *= 5; dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 21 ) - dungeonlevel = 21; + if ( P.amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel; fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( funcid == 'H' && maxplayers > 1 ) From 680c622eec80cc570d66f6e276c5256b15b5509a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:33:10 -1100 Subject: [PATCH 2963/3904] 'void (*)(struct rogue_state *, int) --- src/cc/rogue/potions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 56261118b..27e78303f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -125,7 +125,7 @@ quaff(struct rogue_state *rs) msg(rs,"you feel stronger, now. What bulging muscles!"); when P_MFIND: player.t_flags |= SEEMONST; - fuse(turn_see, TRUE, HUHDURATION, AFTER); + fuse((void(*)(struct rogue_state *rs,int))turn_see, TRUE, HUHDURATION, AFTER); if (!turn_see(rs,FALSE)) msg(rs,"you have a %s feeling for a moment, then it passes", choose_str("normal", "strange")); From 7a04cea145fa51cc7dfe10400ba13eaa141c1333 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:37:40 -1100 Subject: [PATCH 2964/3904] -prints --- src/cc/rogue/command.c | 25 +------------------------ src/cc/rogue/daemon.c | 2 ++ src/cc/rogue/io.c | 2 +- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index c57c0615f..830fa2356 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -20,7 +20,6 @@ void command(struct rogue_state *rs) { - static FILE *fp2; register char ch; register int ntimes = 1; /* Number of player moves */ char *fp; @@ -466,25 +465,8 @@ over: if (!after) ntimes++; } - if ( fp2 == 0 ) - rs->logfp = fp2 = fopen("commands","wb"); - if ( fp2 != 0 ) - { - fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp2); - } do_daemons(rs,AFTER); - if ( fp2 != 0 ) - { - fprintf(fp2,"after daemons (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); - fflush(fp2); - } - do_fuses(rs,AFTER,fp2); - if ( fp2 != 0 ) - { - fprintf(fp2,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); - fflush(fp2); - } + do_fuses(rs,AFTER,0); if (ISRING(LEFT, R_SEARCH)) search(rs); else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) @@ -493,11 +475,6 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); - if ( fp2 != 0 ) - { - fprintf(fp2,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp2); - } } /* diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index 118ca3c37..c98b10f88 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -187,6 +187,8 @@ char *actionfunc_str(char *str,void *ptr) strcpy(str,"rollwand"); else if ( ptr == (void *)visuals ) strcpy(str,"visuals"); + else if ( ptr == (void *)turn_see ) + strcpy(str,"turn_see"); else strcpy(str,"no match"); return(str); } diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 11321763a..ad22407f6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,7 +160,7 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 1 ) + if ( 0 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) From 41d89521a1b2181178dc49233543613b5646ee99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:43:10 -1100 Subject: [PATCH 2965/3904] -file fp --- src/cc/rogue/armor.c | 4 ++-- src/cc/rogue/command.c | 4 ++-- src/cc/rogue/daemon.c | 10 +++++----- src/cc/rogue/rogue.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue/armor.c b/src/cc/rogue/armor.c index f8c491121..20c5704a8 100644 --- a/src/cc/rogue/armor.c +++ b/src/cc/rogue/armor.c @@ -83,7 +83,7 @@ void waste_time(struct rogue_state *rs) { do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE,0); + do_fuses(rs,BEFORE); do_daemons(rs,AFTER); - do_fuses(rs,AFTER,0); + do_fuses(rs,AFTER); } diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 830fa2356..568f4b8f8 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -31,7 +31,7 @@ command(struct rogue_state *rs) * Let the daemons start up */ do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE,0); + do_fuses(rs,BEFORE); while (ntimes--) { if ( rs->replaydone != 0 ) @@ -466,7 +466,7 @@ over: ntimes++; } do_daemons(rs,AFTER); - do_fuses(rs,AFTER,0); + do_fuses(rs,AFTER); if (ISRING(LEFT, R_SEARCH)) search(rs); else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index c98b10f88..81bdd0a73 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -161,7 +161,7 @@ extinguish(void (*func)(struct rogue_state *rs,int)) * Decrement counters and start needed fuses */ -char *actionfunc_str(char *str,void *ptr) +/*char *actionfunc_str(char *str,void *ptr) { if ( ptr == (void *)runners ) strcpy(str,"runners"); @@ -191,10 +191,10 @@ char *actionfunc_str(char *str,void *ptr) strcpy(str,"turn_see"); else strcpy(str,"no match"); return(str); -} +}*/ void -do_fuses(struct rogue_state *rs,int flag,FILE *fp) +do_fuses(struct rogue_state *rs,int flag) { register struct delayed_action *wire; char str[64]; @@ -208,8 +208,8 @@ do_fuses(struct rogue_state *rs,int flag,FILE *fp) */ if (flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0) { - if ( fp != 0 ) - fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func)); + //if ( fp != 0 ) + // fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func)); wire->d_type = EMPTY; (*wire->d_func)(rs,wire->d_arg); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 2a5b39bf9..5540da2da 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -620,7 +620,7 @@ int dist(int y1, int x1, int y2, int x2); int dist_cp(coord *c1, coord *c2); int do_chase(struct rogue_state *rs,THING *th); void do_daemons(struct rogue_state *rs,int flag); -void do_fuses(struct rogue_state *rs,int flag,FILE *fp); +void do_fuses(struct rogue_state *rs,int flag); void do_maze(struct rogue_state *rs,struct room *rp); void do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta); void do_move(struct rogue_state *rs,int dy, int dx); From 00955f71b0009831de12fddf9b56f949bfd04115 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:46:34 -1100 Subject: [PATCH 2966/3904] -potions file --- src/cc/rogue/potions.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 27e78303f..2425b051f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -78,16 +78,6 @@ quaff(struct rogue_state *rs) } if (obj == cur_weapon) cur_weapon = NULL; - static FILE *fp; - { - if ( fp == 0 ) - fp = fopen("potions","wb"); - if ( fp != 0 ) - { - fprintf(fp,"potion.%d seed.%llu\n",obj->o_which,(long long)seed); - fflush(fp); - } - } /* * Calculate the effect it has on the poor guy. */ @@ -108,11 +98,6 @@ quaff(struct rogue_state *rs) msg(rs,"you feel very sick now"); come_down(rs,0); } - if ( fp != 0 ) - { - fprintf(fp,"poison iswearing.%d left.%d right.%d seed.%llu\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR),(long long)seed); - fflush(fp); - } when P_HEALING: pot_info[P_HEALING].oi_know = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp) @@ -235,11 +220,6 @@ quaff(struct rogue_state *rs) if (discardit) discard(obj); - if ( fp != 0 ) - { - fprintf(fp,"end potion.%d seed.%llu\n",obj->o_which,(long long)seed); - fflush(fp); - } return; } From 784e1cb1277198a960b4f779f07465a7ea7814df Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:52:57 -1100 Subject: [PATCH 2967/3904] Test --- src/cc/rogue/io.c | 2 +- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index ad22407f6..11321763a 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,7 +160,7 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 0 ) + if ( 1 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 196bc645a..7fc88b878 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -992,13 +992,13 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } //fprintf(stderr,"call replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); - //fprintf(stderr,"back replay2\n"); newdata.resize(num); for (i=0; i no playerdata\n"); From 2f4fd73ed42430a16cd30672ea4cecdf1d7141ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 08:01:36 -1100 Subject: [PATCH 2968/3904] -log --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 11321763a..ad22407f6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,7 +160,7 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 1 ) + if ( 0 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) From ffd9731880022c1cb2c3c0e8c7c4685a3c5b836b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 09:02:28 -1100 Subject: [PATCH 2969/3904] -print replay2 gold --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7fc88b878..c65e0e70c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -998,7 +998,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto newdata[i] = newplayer[i]; ((uint8_t *)&endP)[i] = newplayer[i]; } - fprintf(stderr,"back replay2 gold.%d\n",endP.gold); + //fprintf(stderr,"back replay2 gold.%d\n",endP.gold); if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { sprintf(str,"zero value character was killed -> no playerdata\n"); From 34fc048c0c04b9ddf55893d4486f3669c4a7b650 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 09:28:07 -1100 Subject: [PATCH 2970/3904] Test --- src/cc/rogue_rpc.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c65e0e70c..4dc449596 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -510,7 +510,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke *keystrokesp = 0; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -529,17 +529,17 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( matches == 1 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1,0) < 0 ) { @@ -556,7 +556,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } } txid = spenttxid; - //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); @@ -581,7 +581,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-5); } } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -594,7 +594,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); From 5ac1415bf98f0bcf9f29ef223fb4a85457a0633e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 09:32:37 -1100 Subject: [PATCH 2971/3904] D'oh! --- src/cc/rogue_rpc.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4dc449596..5dc970bc8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -507,10 +507,11 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; batonvalue = numkeys = numplayers = batonht = 0; playertxid = batontxid = zeroid; - *keystrokesp = 0; + if ( keystrokesp != 0 ) + *keystrokesp = 0; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -529,17 +530,17 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); if ( matches == 1 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1,0) < 0 ) { @@ -556,7 +557,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); } } txid = spenttxid; - fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); @@ -581,7 +582,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); return(-5); } } - fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -594,7 +595,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); From b97f4e091ec7fdc60fd88cb3c93c86dfe87c1bf1 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Thu, 14 Mar 2019 16:47:09 +0800 Subject: [PATCH 2972/3904] fix 100% PoS chain (#1332) --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c530db4fb..ae9a9360b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1527,7 +1527,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); isPoS = 0; } - else + else if ( ASSETCHAINS_STAKED != 100 ) { bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) From 0fe3a71428d0fb6b8508839f9df0fb621849c4a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 22:54:11 -1100 Subject: [PATCH 2973/3904] Merge branch 'beta' into dev # Conflicts: # src/assetchains.old --- .gitignore | 16 ++++++++++++++++ src/ac/ilien | 3 +++ src/assetchains.old | 3 ++- src/fiat/ilien | 3 +++ src/komodo_bitcoind.h | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100755 src/ac/ilien create mode 100755 src/fiat/ilien diff --git a/.gitignore b/.gitignore index cd2641c22..4204d39ec 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,19 @@ src/komodo-tx.exe src/cryptoconditions/compile + +src/checkfile + +src/foo.zip + +src/log + +src/rogue.530623577502174316.0 + +src/rogue.530623577502174316.pack + +src/rogue.530623577502174316.player + +src/ROGUE.conf + +src/rogue.scr diff --git a/src/ac/ilien b/src/ac/ilien new file mode 100755 index 000000000..53e571661 --- /dev/null +++ b/src/ac/ilien @@ -0,0 +1,3 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 + diff --git a/src/assetchains.old b/src/assetchains.old index 58f8e754a..cc85f1cd1 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -46,4 +46,5 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 & ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & -./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addnode=51.75.122.83 & +./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 & + diff --git a/src/fiat/ilien b/src/fiat/ilien new file mode 100755 index 000000000..53e571661 --- /dev/null +++ b/src/fiat/ilien @@ -0,0 +1,3 @@ +#!/bin/bash +./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 + diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c530db4fb..ae9a9360b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1527,7 +1527,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); isPoS = 0; } - else + else if ( ASSETCHAINS_STAKED != 100 ) { bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) From 05977b8af6de99402eef31f2145d49ce388a1969 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 22:58:20 -1100 Subject: [PATCH 2974/3904] Jl777 (#1333) * Slow down clock * Faster and slower * A0/50 * Fix dilithium inputs scan to compare for the voutpubtxids[vout] * Prevent use of uninitialized ignoredAddresses * Filter out amount=0 UTXOs from getsnapshot results * rogue msvc build (#1327) * + msvc 2015 deps headers * + msvc deps build script this script builds only deps, to build rogue binary, open *.sln file in MSVC 2015 and build x64 Release version. * + msvc solution (*.sln) update * + msvc build fix * fix libcurl deps install (msvc) * Fix wrong dilithium compare * Port getchaintxstats from BTC master (#1328) This will allow explorers to present interesting analytics about transaction volume in various time frames. * customcc * Make custom * Syntax * update * Patch rogue msvc (#1330) * + msvc 2015 deps headers * + msvc deps build script this script builds only deps, to build rogue binary, open *.sln file in MSVC 2015 and build x64 Release version. * + msvc solution (*.sln) update * + msvc build fix * fix libcurl deps install (msvc) * [msvc] fix seed str -> uint64 conversion * [msvc] fix config file name issue + debug print for send raw tx * + comment debug printouts * [ msvc ] display compiler version and build date on startup * +pritns * +prints * I, * Print hex * Allow gold mismatch for validate * Stricter player data validation * Change data source * Allow claiming less than cashout value * 50902 exemption * Taxied * Print * Debug file * Log seed * Potion file * ; * Log seed * Commands log * Fp * Test * Prints * static FILE *fp; * Fp2 * Daemons or fuses * Fuse prints * All funcs * Logfp * turn_see is a daemon! * 'void (*)(struct rogue_state *, int) * -prints * -file fp * -potions file * Test * -log * -print replay2 gold * Test * D'oh! --- .gitignore | 1 + src/cc/cclib.cpp | 15 +- src/cc/customcc.cpp | 88 + src/cc/customcc.h | 45 + src/cc/dilithium.c | 2 +- src/cc/makecustom | 7 + src/cc/rogue/command.c | 8 +- src/cc/rogue/daemon.c | 37 +- src/cc/rogue/daemons.c | 151 +- src/cc/rogue/extern.h | 9 +- src/cc/rogue/io.c | 2 +- src/cc/rogue/main.c | 102 +- src/cc/rogue/misc.c | 18 +- src/cc/rogue/new_level.c | 14 +- src/cc/rogue/potions.c | 60 +- src/cc/rogue/rogue.c | 37 +- src/cc/rogue/rogue.h | 3 +- src/cc/rogue/rogue54.sln | 14 +- src/cc/rogue/rogue54.vcxproj | 257 +++ src/cc/rogue/rogue_build_msvc.cmd | 64 + .../deps/install/include/acs_defs.h | 265 +++ .../deps/install/include/curses.h | 1846 +++++++++++++++++ .../deps/install/include/curspriv.h | 134 ++ .../deps/install/include/getopt.h | 93 + .../deps/install/include/panel.h | 56 + .../deps/install/include/term.h | 48 + .../deps/install/include/unistd.h | 56 + src/cc/rogue_rpc.cpp | 87 +- src/cc/tetris.cpp | 5 +- src/rpc/blockchain.cpp | 82 + src/rpc/client.cpp | 1 + src/txdb.cpp | 42 +- 32 files changed, 3485 insertions(+), 164 deletions(-) create mode 100644 src/cc/customcc.cpp create mode 100644 src/cc/customcc.h create mode 100755 src/cc/makecustom create mode 100644 src/cc/rogue/rogue54.vcxproj create mode 100644 src/cc/rogue/rogue_build_msvc.cmd create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h diff --git a/.gitignore b/.gitignore index d05db4c67..6cebf87fe 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,4 @@ src/ROGUE.conf src/rogue.scr src/cc/rogue/confdefs.h +src/cc/rogue/x64 diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 651723e44..c783eb4d0 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -33,8 +33,12 @@ #ifdef BUILD_ROGUE #define EVAL_ROGUE 17 std::string MYCCLIBNAME = (char *)"rogue"; -#else + +#elif BUILD_CUSTOMCC +#include "customcc.h" + +#else #define EVAL_SUDOKU 17 #define EVAL_MUSIG 18 #define EVAL_DILITHIUM 19 @@ -67,6 +71,8 @@ CClib_methods[] = { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, { (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE }, { (char *)"rogue", (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, 'X', EVAL_ROGUE }, +#elif BUILD_CUSTOMCC + RPC_FUNCS #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -214,6 +220,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(result); } } +#elif BUILD_CUSTOMCC + CUSTOM_DISPATCH #else if ( cp->evalcode == EVAL_SUDOKU ) { @@ -410,6 +418,8 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { #ifdef BUILD_ROGUE return(rogue_validate(cp,height,eval,tx)); +#elif BUILD_CUSTOMCC + return(custom_validate(cp,height,eval,tx)); #else if ( cp->evalcode == EVAL_SUDOKU ) return(sudoku_validate(cp,height,eval,tx)); @@ -660,6 +670,9 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) #include "rogue/weapons.c" #include "rogue/wizard.c" +#elif BUILD_CUSTOMCC +#include "customcc.cpp" + #else #include "sudoku.cpp" #include "musig.cpp" diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp new file mode 100644 index 000000000..9f58c5c8b --- /dev/null +++ b/src/cc/customcc.cpp @@ -0,0 +1,88 @@ +/* + simple stub custom cc + + Just update the functions in this file, then from ~/komodo/src/cc + + ../komodo-cli -ac_name=CUSTOM stop + ./makecustom + ../komodod -ac_name=CUSTOM -ac_cclib=custom -ac_cc=2 ... + + The above will rebuild komodod and get it running again + */ + +CScript custom_opret(uint8_t funcid,CPubKey pk) +{ + CScript opret; uint8_t evalcode = EVAL_CUSTOM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); + return(opret); +} + +uint8_t custom_opretdecode(CPubKey &pk,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_CUSTOM ) + { + return(f); + } + return(0); +} + +UniValue custom_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) +{ + CTransaction tx; + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + +UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + result.push_back(Pair("message","just an example of an information returning rpc")); + return(result); +} + +// send yourself 1 coin to your CC address using normal utxo from your -pubkey + +UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); std::string rawtx; + UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0; + if ( txfee == 0 ) + txfee = CUSTOM_TXFEE; + mypk = pubkey2pk(Mypubkey()); + if ( AddNormalinputs(mtx,mypk,COIN+txfee,64) >= COIN+txfee ) // add utxo to mtx + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0 + // add opreturn, change is automatically added and tx is properly signed + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,custom_opret('1',mypk)); + return(custom_rawtxresult(result,rawtx,broadcastflag)); + } + return(result); +} + +bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + char expectedaddress[64]; CPubKey pk; + if ( tx.vout.size() != 2 ) // make sure the tx only has 2 outputs + return eval->Invalid("invalid number of vouts"); + else if ( custom_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn + return eval->Invalid("invalid opreturn"); + GetCCaddress(cp,expectedaddress,pk); + if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches + return(true); + else return eval->Invalid("invalid vout0 amount"); +} + + diff --git a/src/cc/customcc.h b/src/cc/customcc.h new file mode 100644 index 000000000..436937391 --- /dev/null +++ b/src/cc/customcc.h @@ -0,0 +1,45 @@ +/* + to create a custom libcc.so: + + 1. change "func0" and "func1" to method names that fit your custom cc. Of course, you can create more functions by adding another entry to RPC_FUNCS. there is not any practical limit to the number of methods. + + 2. For each method make sure there is a UniValue function declaration and CUSTOM_DISPATCH has an if statement checking for it that calls the custom_func + + 3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp + + 4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/komodo/src and rebuilds komodod + + 5. launch your chain with -ac_cclib=customcc -ac_cc=2 + + */ + +std::string MYCCLIBNAME = (char *)"customcc"; + +#define EVAL_CUSTOM (EVAL_FAUCET2+1) +#define CUSTOM_TXFEE 10000 + +#define MYCCNAME "custom" + +#define RPC_FUNCS \ + { (char *)MYCCNAME, (char *)"func0", (char *)"", 1, 1, '0', EVAL_CUSTOM }, \ + { (char *)MYCCNAME, (char *)"func1", (char *)"", 0, 0, '1', EVAL_CUSTOM }, + +bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); +UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); + +#define CUSTOM_DISPATCH \ +if ( cp->evalcode == EVAL_CUSTOM ) \ +{ \ + if ( strcmp(method,"func0") == 0 ) \ + return(custom_func0(txfee,cp,params)); \ + else if ( strcmp(method,"func1") == 0 ) \ + return(custom_func1(txfee,cp,params)); \ + else \ + { \ + result.push_back(Pair("result","error")); \ + result.push_back(Pair("error","invalid customcc method")); \ + result.push_back(Pair("method",method)); \ + return(result); \ + } \ +} diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index d4b75bf38..0854236ec 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3352,7 +3352,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && destpubtxid == checktxid ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && destpubtxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/makecustom b/src/cc/makecustom new file mode 100755 index 000000000..61b251e6e --- /dev/null +++ b/src/cc/makecustom @@ -0,0 +1,7 @@ +#!/bin/sh +gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp +cp customcc.so ../libcc.so +cd .. +make +cd cc + diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 84281c5a7..568f4b8f8 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -344,7 +344,7 @@ over: if (wizard) { wizard = FALSE; - turn_see(TRUE); + turn_see(rs,TRUE); msg(rs,"not wizard any more"); } else @@ -353,7 +353,7 @@ over: if (wizard) { noscore = TRUE; - turn_see(FALSE); + turn_see(rs,FALSE); msg(rs,"you are suddenly as smart as Ken Arnold in dungeon #%d", dnum); } else @@ -403,7 +403,7 @@ over: when CTRL('T'): teleport(); when CTRL('E'): msg(rs,"food left: %d", food_left); when CTRL('C'): add_pass(); - when CTRL('X'): turn_see(on(player, SEEMONST)); + when CTRL('X'): turn_see(rs,on(player, SEEMONST)); when CTRL('~'): { THING *item; @@ -455,7 +455,7 @@ over: if (!running) door_stop = FALSE; } - /* +/* * If he ran into something to take, let him pick it up. */ if (take != 0) diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index 1da06d499..81bdd0a73 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -160,10 +160,43 @@ extinguish(void (*func)(struct rogue_state *rs,int)) * do_fuses: * Decrement counters and start needed fuses */ + +/*char *actionfunc_str(char *str,void *ptr) +{ + if ( ptr == (void *)runners ) + strcpy(str,"runners"); + else if ( ptr == (void *)doctor ) + strcpy(str,"doctor"); + else if ( ptr == (void *)stomach ) + strcpy(str,"stomach"); + else if ( ptr == (void *)nohaste ) + strcpy(str,"nohaste"); + else if ( ptr == (void *)unconfuse ) + strcpy(str,"unconfuse"); + else if ( ptr == (void *)swander ) + strcpy(str,"swander"); + else if ( ptr == (void *)come_down ) + strcpy(str,"come_down"); + else if ( ptr == (void *)unsee ) + strcpy(str,"unsee"); + else if ( ptr == (void *)sight ) + strcpy(str,"sight"); + else if ( ptr == (void *)land ) + strcpy(str,"land"); + else if ( ptr == (void *)rollwand ) + strcpy(str,"rollwand"); + else if ( ptr == (void *)visuals ) + strcpy(str,"visuals"); + else if ( ptr == (void *)turn_see ) + strcpy(str,"turn_see"); + else strcpy(str,"no match"); + return(str); +}*/ + void do_fuses(struct rogue_state *rs,int flag) { - register struct delayed_action *wire; + register struct delayed_action *wire; char str[64]; /* * Step though the list @@ -175,6 +208,8 @@ do_fuses(struct rogue_state *rs,int flag) */ if (flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0) { + //if ( fp != 0 ) + // fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func)); wire->d_type = EMPTY; (*wire->d_func)(rs,wire->d_arg); } diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 42e685320..c9c16448d 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -21,6 +21,8 @@ void doctor(struct rogue_state *rs,int arg) { register int lv, ohp; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"doctor\n"); lv = pstats.s_lvl; ohp = pstats.s_hpt; @@ -52,6 +54,8 @@ doctor(struct rogue_state *rs,int arg) void swander(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"swander\n"); start_daemon(rollwand, 0, BEFORE); } @@ -63,6 +67,8 @@ int between = 0; void rollwand(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"rollwand\n"); if (++between >= 4) { if (roll(1, 6) == 4) @@ -82,6 +88,8 @@ rollwand(struct rogue_state *rs,int arg) void unconfuse(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"unconfuse\n"); player.t_flags &= ~ISHUH; msg(rs,"you feel less %s now", choose_str("trippy", "confused")); } @@ -94,6 +102,8 @@ void unsee(struct rogue_state *rs,int arg) { register THING *th; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"unsee\n"); for (th = mlist; th != NULL; th = next(th)) if (on(*th, ISINVIS) && see_monst(th)) @@ -108,6 +118,8 @@ unsee(struct rogue_state *rs,int arg) void sight(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"sight\n"); if (on(player, ISBLIND)) { extinguish(sight); @@ -126,6 +138,8 @@ sight(struct rogue_state *rs,int arg) void nohaste(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"nohaste\n"); player.t_flags &= ~ISHASTE; msg(rs,"you feel yourself slowing down"); } @@ -139,6 +153,8 @@ stomach(struct rogue_state *rs,int arg) { register int oldfood; int orig_hungry = hungry_state; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"stomach\n"); if (food_left <= 0) { @@ -194,41 +210,43 @@ come_down(struct rogue_state *rs,int arg) { register THING *tp; register bool seemonst; - + + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"come_down\n"); if (!on(player, ISHALU)) - return; - + return; + kill_daemon(visuals); player.t_flags &= ~ISHALU; - + if (on(player, ISBLIND)) - return; - + return; + /* * undo the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) - if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) - mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); - + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); + /* * undo the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) { - move(tp->t_pos.y, tp->t_pos.x); - if (cansee(rs,tp->t_pos.y, tp->t_pos.x)) - if (!on(*tp, ISINVIS) || on(player, CANSEE)) - addch(tp->t_disguise); - else - addch(chat(tp->t_pos.y, tp->t_pos.x)); - else if (seemonst) - { - standout(); - addch(tp->t_type); - standend(); - } + move(tp->t_pos.y, tp->t_pos.x); + if (cansee(rs,tp->t_pos.y, tp->t_pos.x)) + if (!on(*tp, ISINVIS) || on(player, CANSEE)) + addch(tp->t_disguise); + else + addch(chat(tp->t_pos.y, tp->t_pos.x)); + else if (seemonst) + { + standout(); + addch(tp->t_type); + standend(); + } } msg(rs,"Everything looks SO boring now."); } @@ -242,42 +260,44 @@ visuals(struct rogue_state *rs,int arg) { register THING *tp; register bool seemonst; - + if (!after || (running && jump)) - return; + return; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"visuals\n"); /* * change the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) - if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) - mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); - + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); + /* * change the stairs */ if (!seenstairs && cansee(rs,stairs.y, stairs.x)) - mvaddch(stairs.y, stairs.x, rnd_thing()); - + mvaddch(stairs.y, stairs.x, rnd_thing()); + /* * change the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) { - move(tp->t_pos.y, tp->t_pos.x); - if (see_monst(tp)) - { - if (tp->t_type == 'X' && tp->t_disguise != 'X') - addch(rnd_thing()); - else - addch(rnd(26) + 'A'); - } - else if (seemonst) - { - standout(); - addch(rnd(26) + 'A'); - standend(); - } + move(tp->t_pos.y, tp->t_pos.x); + if (see_monst(tp)) + { + if (tp->t_type == 'X' && tp->t_disguise != 'X') + addch(rnd_thing()); + else + addch(rnd(26) + 'A'); + } + else if (seemonst) + { + standout(); + addch(rnd(26) + 'A'); + standend(); + } } } @@ -288,7 +308,54 @@ visuals(struct rogue_state *rs,int arg) void land(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"land\n"); player.t_flags &= ~ISLEVIT; msg(rs,choose_str("bummer! You've hit the ground", "you float gently to the ground")); } + +/* + * turn_see: + * Put on or off seeing monsters on this level + */ +bool +turn_see(struct rogue_state *rs,bool turn_off) +{ + THING *mp; + bool can_see, add_new; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"turn_see\n"); + + add_new = FALSE; + for (mp = mlist; mp != NULL; mp = next(mp)) + { + move(mp->t_pos.y, mp->t_pos.x); + can_see = see_monst(mp); + if (turn_off) + { + if (!can_see) + addch(mp->t_oldch); + } + else + { + if (!can_see) + standout(); + if (!on(player, ISHALU)) + addch(mp->t_type); + else + addch(rnd(26) + 'A'); + if (!can_see) + { + standend(); + add_new ^= 1;//add_new++; + } + } + } + if (turn_off) + player.t_flags &= ~SEEMONST; + else + player.t_flags |= SEEMONST; + return add_new; +} + diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 7fba842f3..c62646b67 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -107,6 +107,12 @@ #include #include +#ifdef _WIN32 +#ifdef _MSC_VER +#include +#endif +#endif + #undef SIGTSTP #define MAXSTR 1024 /* maximum length of strings */ @@ -142,7 +148,8 @@ void leave(int); void my_exit(int st); void playltchars(void); void quit(int); -int32_t _quit(); +int32_t _quit(); + void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 4c289ad7d..ad22407f6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -167,7 +167,7 @@ readchar(struct rogue_state *rs) fp = fopen("log","wb"); if ( fp != 0 ) { - fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs)); + fprintf(fp,"%d: (%c) hp.%d num.%d gold.%d seed.%llu\n",counter,c,pstats.s_hpt,num_packitems(rs),purse,(long long)seed); fflush(fp); counter++; } diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index c2155a085..f146cfb4d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -38,6 +38,31 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif +#ifdef _WIN32 +#ifdef _MSC_VER +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = ((uint64_t)file_time.dwLowDateTime); + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); + return 0; +} +#endif // _MSC_VER +#endif + + + double OS_milliseconds() { struct timeval tv; double millis; @@ -392,6 +417,12 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char * } #endif +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + /************************************************************************ * * perform the query @@ -736,6 +767,17 @@ int32_t rogue_sendrawtransaction(char *rawtx) } free_json(retjson); } + + /* log sendrawtx result in file */ + + /* + FILE *debug_file; + debug_file = fopen("tx_debug.log", "a"); + fprintf(debug_file, "%s\n", retstr); + fflush(debug_file); + fclose(debug_file); + */ + free(retstr); } free(params); @@ -899,9 +941,46 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) return(retval); } +#ifdef _WIN32 +#ifdef _MSC_VER +__inline int msver(void) { + switch (_MSC_VER) { + case 1500: return 2008; + case 1600: return 2010; + case 1700: return 2012; + case 1800: return 2013; + case 1900: return 2015; + //case 1910: return 2017; + default: return (_MSC_VER / 100); + } +} + +static inline bool is_x64(void) { +#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) + return 1; +#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64) + return 1; +#else + return 0; +#endif +} + +#define BUILD_DATE __DATE__ " " __TIME__ +#endif // _WIN32 +#endif // _MSC_VER + int main(int argc, char **argv, char **envp) { uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; + + #ifdef _WIN32 + #ifdef _MSC_VER + printf("*** rogue for Windows [ Build %s ] ***\n", BUILD_DATE); + const char* arch = is_x64() ? "64-bits" : "32-bits"; + printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch); + #endif + #endif + for (i=j=0; argv[0][i]!=0&&j max_level) max_level = level; @@ -95,7 +105,7 @@ new_level(struct rogue_state *rs) enter_room(rs,&hero); mvaddch(hero.y, hero.x, PLAYER); if (on(player, SEEMONST)) - turn_see(FALSE); + turn_see(rs,FALSE); if (on(player, ISHALU)) visuals(rs,0); } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index b10f83bd4..2425b051f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -78,7 +78,6 @@ quaff(struct rogue_state *rs) } if (obj == cur_weapon) cur_weapon = NULL; - /* * Calculate the effect it has on the poor guy. */ @@ -91,7 +90,7 @@ quaff(struct rogue_state *rs) do_pot(rs,P_CONFUSE, !trip); when P_POISON: pot_info[P_POISON].oi_know = TRUE; - if (ISWEARING(R_SUSTSTR)) + if (ISWEARING(R_SUSTSTR)) msg(rs,"you feel momentarily sick"); else { @@ -112,7 +111,7 @@ quaff(struct rogue_state *rs) when P_MFIND: player.t_flags |= SEEMONST; fuse((void(*)(struct rogue_state *rs,int))turn_see, TRUE, HUHDURATION, AFTER); - if (!turn_see(FALSE)) + if (!turn_see(rs,FALSE)) msg(rs,"you have a %s feeling for a moment, then it passes", choose_str("normal", "strange")); when P_TFIND: @@ -158,7 +157,7 @@ quaff(struct rogue_state *rs) if (!trip) { if (on(player, SEEMONST)) - turn_see(FALSE); + turn_see(rs,FALSE); start_daemon(visuals, 0, BEFORE); seenstairs = seen_stairs(); } @@ -263,47 +262,6 @@ invis_on() mvaddch(mp->t_pos.y, mp->t_pos.x, mp->t_disguise); } -/* - * turn_see: - * Put on or off seeing monsters on this level - */ -bool -turn_see(bool turn_off) -{ - THING *mp; - bool can_see, add_new; - - add_new = FALSE; - for (mp = mlist; mp != NULL; mp = next(mp)) - { - move(mp->t_pos.y, mp->t_pos.x); - can_see = see_monst(mp); - if (turn_off) - { - if (!can_see) - addch(mp->t_oldch); - } - else - { - if (!can_see) - standout(); - if (!on(player, ISHALU)) - addch(mp->t_type); - else - addch(rnd(26) + 'A'); - if (!can_see) - { - standend(); - add_new ^= 1;//add_new++; - } - } - } - if (turn_off) - player.t_flags &= ~SEEMONST; - else - player.t_flags |= SEEMONST; - return add_new; -} /* * seen_stairs: @@ -358,18 +316,18 @@ do_pot(struct rogue_state *rs,int type, bool knowit) { PACT *pp; int t; - + pp = &p_actions[type]; if (!pot_info[type].oi_know) - pot_info[type].oi_know = knowit; + pot_info[type].oi_know = knowit; t = spread(pp->pa_time); if (!on(player, pp->pa_flags)) { - player.t_flags |= pp->pa_flags; - fuse(pp->pa_daemon, 0, t, AFTER); - look(rs,FALSE); + player.t_flags |= pp->pa_flags; + fuse(pp->pa_daemon, 0, t, AFTER); + look(rs,FALSE); } else - lengthen(pp->pa_daemon, t); + lengthen(pp->pa_daemon, t); msg(rs,choose_str(pp->pa_high, pp->pa_straight)); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 352e950ec..7a8e38c15 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -13,6 +13,7 @@ #include //#include //#include + #include "rogue.h" #ifdef STANDALONE #include "../komodo/src/komodo_cJSON.h" @@ -196,6 +197,12 @@ void rogue_bailout(struct rogue_state *rs) fprintf(stderr,"error issuing (%s)\n",cmd);*/ } +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis) { struct rogue_state *rs; FILE *fp; int32_t i,n; @@ -215,6 +222,14 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); + + /* + // keypress after replay + printf("[Press return to continue]"); + fflush(stdout); + if (fgets(prbuf, 10, stdin) != 0); + */ + if ( 0 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); @@ -328,7 +343,15 @@ int rogue(int argc, char **argv, char **envp) rs->sleeptime = 1; // non-zero to allow refresh() if ( argc == 3 && strlen(argv[2]) == 64 ) { - rs->seed = atol(argv[1]); + #ifdef _WIN32 + #ifdef _MSC_VER + rs->seed = _strtoui64(argv[1], NULL, 10); + #else + rs->seed = atol(argv[1]); // windows, but not MSVC + #endif // _MSC_VER + #else + rs->seed = atol(argv[1]); // non-windows + #endif // _WIN32 strcpy(Gametxidstr,argv[2]); fprintf(stderr,"setplayerdata\n"); if ( rogue_setplayerdata(rs,Gametxidstr) < 0 ) @@ -526,6 +549,18 @@ tstp(int ignored) #endif*/ } + +#ifdef _WIN32 +#ifdef _MSC_VER +void usleep(int32_t micros) +{ + if (micros < 1000) + Sleep(1); + else Sleep(micros / 1000); +} +#endif +#endif + /* * playit: * The main loop of the program. Loop until the game is over, diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index ba57adbe6..5540da2da 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -365,6 +365,7 @@ struct rogue_state char *keystrokes,*keystrokeshex; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; + FILE *logfp; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; @@ -770,7 +771,7 @@ bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl); bool see_monst(THING *mp); bool seen_stairs(void); bool turn_ok(int y, int x); -bool turn_see(bool turn_off); +bool turn_see(struct rogue_state *rs,bool turn_off); bool is_current(struct rogue_state *rs,THING *obj); int passwd(void); diff --git a/src/cc/rogue/rogue54.sln b/src/cc/rogue/rogue54.sln index da1c58f07..751959465 100644 --- a/src/cc/rogue/rogue54.sln +++ b/src/cc/rogue/rogue54.sln @@ -1,17 +1,25 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcxproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.ActiveCfg = Debug|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.Build.0 = Debug|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.ActiveCfg = Debug|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.Build.0 = Debug|x64 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.ActiveCfg = Release|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.Build.0 = Release|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.ActiveCfg = Release|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/cc/rogue/rogue54.vcxproj b/src/cc/rogue/rogue54.vcxproj new file mode 100644 index 000000000..344598dd8 --- /dev/null +++ b/src/cc/rogue/rogue54.vcxproj @@ -0,0 +1,257 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6} + Win32Proj + 8.1 + + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + false + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + Debug\ + Debug\ + true + + + true + + + Release\ + Release\ + false + + + false + + + + Disabled + Default + ../pdcurses;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;MASTER;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + EnableFastChecks + MultiThreaded + true + true + false + true + + + Level4 + EditAndContinue + CompileAsC + + + Ws2_32.lib;pdcurses.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + ..\pdcurses;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + MachineX86 + + + + + Disabled + Default + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + + EnableFastChecks + MultiThreaded + true + true + false + true + + + + + Level4 + ProgramDatabase + CompileAsC + + + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + NotUsing + Level3 + ProgramDatabase + $(ProjectDir)\x86_64-w64-msvc\include\ncursesw;$(ProjectDir)\x86_64-w64-msvc\include;%(AdditionalIncludeDirectories) + + + $(OutDir)rogue54.exe + true + Windows + true + true + MachineX86 + %(AdditionalLibraryDirectories) + %(AdditionalDependencies) + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;_WINDOWS;NDEBUG;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + ProgramDatabase + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + stdafx.h + CompileAsC + + + + + $(OutDir)rogue54.exe + true + Console + true + true + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + %(IgnoreSpecificDefaultLibraries) + false + %(ForceSymbolReferences) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/cc/rogue/rogue_build_msvc.cmd b/src/cc/rogue/rogue_build_msvc.cmd new file mode 100644 index 000000000..77e7cd852 --- /dev/null +++ b/src/cc/rogue/rogue_build_msvc.cmd @@ -0,0 +1,64 @@ +@echo off +echo Rogue Build Script by Decker (c) 2019 + +@REM Check for Visual Studio +call set "VSPATH=" +if defined VS140COMNTOOLS ( if not defined VSPATH ( + call set "VSPATH=%%VS140COMNTOOLS%%" +) ) + +@REM check if we already have the tools in the environment +if exist "%VCINSTALLDIR%" ( + goto compile +) + +if not defined VSPATH ( + echo You need Microsoft Visual Studio 15 installed + pause + exit +) + +@REM set up the environment +if exist "%VSPATH%..\..\vc\vcvarsall.bat" ( + call "%%VSPATH%%..\..\vc\vcvarsall.bat" amd64 + goto compile +) + +echo Unable to set up the environment +pause +exit + +:compile + +mkdir x86_64-w64-msvc\deps +mkdir x86_64-w64-msvc\deps\install + +pushd x86_64-w64-msvc\deps + +:compile_pdcurses +rem git clone https://github.com/wmcbrine/PDCurses PDCurses.org +git clone https://github.com/Bill-Gray/PDCurses + +set PREFIX_DIR=%CD%\install + +pushd PDCurses +mkdir build64 & pushd build64 +rem cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Debug -DPDCDEBUG=ON .. +cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Release .. +popd +rem cmake --build build64 --config Debug --target install +cmake --build build64 --config Release --target install +popd + +:compile_curl + +git clone https://github.com/curl/curl +pushd curl + +mkdir build64 & pushd build64 +cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_USE_WINSSL:BOOL=ON .. +cmake --build . --config Release --target libcurl +cmake --build . --config Release --target install +popd +popd + diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h new file mode 100644 index 000000000..c8c02a737 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h @@ -0,0 +1,265 @@ +/* Many of the following #defines are completely unused for the +nonce. For each character, its code point in code page 437, +Unicode, and page 8859-1 are given. The first is used for +non-wide builds in Win32 console, DOS, SDL, and OS/2. +Unicode is used for all wide builds, and for the non-wide +build of WinGUI. Code page 8859-1 is used for non-wide X11. + + All of these characters exist in CP437 and Unicode. Some +don't exist in 8859-1, in which case the last column is 'TBD'. +Only 32 are used in ncurses. So caution is advised. */ + +#ifdef USE_ISO8859_CHARSET + #define CHOOSE( A, B, C) (C) + #define TBD '!' +#else + #define CHOOSE( A, B, C) (USE_UNICODE_ACS_CHARS ? B : A) +#endif + +/* Codes found from https://en.wikipedia.org/wiki/Code_page_437 */ + +#define SMILE CHOOSE( 0x01, 0x263a, 'O') +#define REV_SMILE CHOOSE( 0x02, 0x263b, 'O') +#define HEART CHOOSE( 0x03, 0x2665, 'H') +#define DIAMOND CHOOSE( 0x04, 0x2666, 0x01) +#define CLUB CHOOSE( 0x05, 0x2663, 'C') +#define SPADE CHOOSE( 0x06, 0x2660, 'S') +#define MEDIUM_BULLET CHOOSE( 0x07, 0x2022, 0xb7) +#define REV_BULLET CHOOSE( 0x08, 0x2508, 0xb7) +#define WHITE_BULLET CHOOSE( 0x09, 0x25cb, 7) +#define REV_WHITE_BULLET CHOOSE( 0x0a, 0x25D9, 7) +#define MALE_SYM CHOOSE( 0x0b, 0x2642, 'm') +#define FEMALE_SYM CHOOSE( 0x0c, 0x2640, 'f') +#define QTR_NOTE CHOOSE( 0x0d, 0x266a, 0xbc) +#define EIGHTH_NOTE CHOOSE( 0x0e, 0x266b, 0xbd) +#define SPLAT CHOOSE( 0x0f, 0xa4 , 0xa4) +#define RIGHT_TRIANGLE CHOOSE( 0x10, 0x25b6, '>') +#define LEFT_TRIANGLE CHOOSE( 0x11, 0x25c0, '<') +#define UP_DOWN_ARROW CHOOSE( 0x12, 0x2195, 0x19) +#define DBL_BANG CHOOSE( 0x13, 0x203c, '!') +#define PILCROW CHOOSE( 0x14, 0xb6 , 0xb6) +#define SECTION_SIGN CHOOSE( 0x15, 0xa7 , 0xa7) +#define LOW_QTR_BLOCK CHOOSE( 0x16, 0x25b2, '_') +#define UP_DOWN_ARROW_UNDERSCORED CHOOSE( 0x17, 0x21ab, 0x19) +#define UP_ARROW CHOOSE( 0x18, 0x2191, '^') +#define DOWN_ARROW CHOOSE( 0x19, 0x2193, 'v') +#define RIGHT_ARROW CHOOSE( 0x1a, 0x2192, '>') +#define LEFT_ARROW CHOOSE( 0x1b, 0x2190, '<') +#define RIGHT_ANGLE CHOOSE( 0x1c, 0x221f, 0xe) +#define LEFT_RIGHT_ARROW CHOOSE( 0x1d, 0x2194, '-') +#define UP_TRIANGLE CHOOSE( 0x1e, 0x25b2, '^') +#define DOWN_TRIANGLE CHOOSE( 0x1f, 0x25bc, 'v') + +#define UPPERCASE_C_CEDILLA CHOOSE( 0x80, 0xc7 , 0xc7) +#define LOWERCASE_U_UMLAUT CHOOSE( 0x81, 0xfc , 0xfc) +#define LOWERCASE_E_ACUTE CHOOSE( 0x82, 0xe9 , 0xe9) +#define LOWERCASE_A_CIRCUMFLEX CHOOSE( 0x83, 0xe2 , 0xe2) +#define LOWERCASE_A_UMLAUT CHOOSE( 0x84, 0xe4 , 0xe4) +#define LOWERCASE_A_GRAVE CHOOSE( 0x85, 0xe0 , 0xea) +#define LOWERCASE_A_RING CHOOSE( 0x86, 0xe5 , 0xe5) +#define LOWERCASE_C_CEDILLA CHOOSE( 0x87, 0xe7 , 0xe7) +#define LOWERCASE_E_CIRCUMFLEX CHOOSE( 0x88, 0xea , 0xea) +#define LOWERCASE_E_UMLAUT CHOOSE( 0x89, 0xeb , 0xeb) +#define LOWERCASE_E_GRAVE CHOOSE( 0x8a, 0xe8 , 0xe8) +#define LOWERCASE_I_UMLAUT CHOOSE( 0x8b, 0xef , 0xef) +#define LOWERCASE_I_CIRCUMFLEX CHOOSE( 0x8c, 0xee , 0xee) +#define LOWERCASE_I_GRAVE CHOOSE( 0x8d, 0xec , 0xce) +#define UPPERCASE_A_UMLAUT CHOOSE( 0x8e, 0xc4 , 0xc4) +#define UPPERCASE_A_RING CHOOSE( 0x8f, 0xc5 , 0xc5) + +#define UPPERCASE_E_ACUTE CHOOSE( 0x90, 0xc9 , 0xc9) +#define LOWERCASE_AE_LIGATURE CHOOSE( 0x91, 0xe6 , 0xe6) +#define UPPERCASE_AE_LIGATURE CHOOSE( 0x92, 0xc6 , 0xc6) +#define LOWERCASE_O_CIRCUMFLEX CHOOSE( 0x93, 0xf4 , 0xf4) +#define LOWERCASE_O_UMLAUT CHOOSE( 0x94, 0xf6 , 0xf6) +#define LOWERCASE_O_GRAVE CHOOSE( 0x95, 0xf2 , 0xf2) +#define LOWERCASE_U_CIRCUMFLEX CHOOSE( 0x96, 0xfb , 0xfb) +#define LOWERCASE_U_GRAVE CHOOSE( 0x97, 0xf9 , 0xf9) +#define LOWERCASE_Y_UMLAUT CHOOSE( 0x98, 0xff , 0xff) +#define UPPERCASE_O_UMLAUT CHOOSE( 0x99, 0xd6 , 0xd6) +#define UPPERCASE_U_UMLAUT CHOOSE( 0x9a, 0xdc , 0xdc) +#define CENT_SIGN CHOOSE( 0x9b, 0xa2 , 0xa2) +#define STERLING_SIGN CHOOSE( 0x9c, 0xa3 , 30) +#define YEN_SIGN CHOOSE( 0x9d, 0xa5 , 0xa5) +#define PESETA_SIGN CHOOSE( 0x9e, 0x20a7, TBD) +#define F_WITH_HOOK CHOOSE( 0x9f, 0x0192, TBD) + +#define LOWERCASE_A_ACUTE CHOOSE( 0xa0, 0xe1 , 0xe1) +#define LOWERCASE_I_ACUTE CHOOSE( 0xa1, 0xed , 0xed) +#define LOWERCASE_O_ACUTE CHOOSE( 0xa2, 0xf3 , 0xf3) +#define LOWERCASE_U_ACUTE CHOOSE( 0xa3, 0xfa , 0xfa) +#define LOWERCASE_N_TILDE CHOOSE( 0xa4, 0xf1 , 0xf1) +#define UPPERCASE_N_TILDE CHOOSE( 0xa5, 0xd1 , 0xd1) +#define A_ORDINAL CHOOSE( 0xa6, 0xaa , 0xaa) +#define O_ORDINAL CHOOSE( 0xa7, 0xba , 0xba) +#define INVERTED_QUESTION_MARK CHOOSE( 0xa8, 0xbf , 0xbf) +#define REVERSED_NOT_SIGN CHOOSE( 0xa9, 0x2310, TBD) +#define NOT_SIGN CHOOSE( 0xaa, 0xac , 0xac) +#define VULGAR_HALF CHOOSE( 0xab, 0xbd , 0xbd) +#define VULGAR_QUARTER CHOOSE( 0xac, 0xbc , 0xbc) +#define INVERTED_EXCLAMATION_MARK CHOOSE( 0xad, 0xa1 , 0xa1) +#define LEFT_ANGLE_QUOTE_MARK CHOOSE( 0xae, 0xab , 0xab) +#define RIGHT_ANGLE_QUOTE_MARK CHOOSE( 0xaf, 0xbb , 0xbb) + +#define LIGHT_SHADE CHOOSE( 0xb0, 0x2591, '#' ) +#define MEDIUM_SHADE CHOOSE( 0xb1, 0x2592, 2) +#define DARK_SHADE CHOOSE( 0xb2, 0x2593, TBD) +#define BOX_VLINE CHOOSE( 0xb3, 0x2502, 25) +#define BOX_RTEE CHOOSE( 0xb4, 0x2524, 22) +#define BOX_SD_RTEE CHOOSE( 0xb5, 0x2561, 22) +#define BOX_DS_RTEE CHOOSE( 0xb6, 0x2562, 22) +#define BOX_DS_URCORNER CHOOSE( 0xb7, 0x2556, 12) +#define BOX_SD_URCORNER CHOOSE( 0xb8, 0x2555, 12) +#define BOX_D_RTEE CHOOSE( 0xb9, 0x2563, 22) +#define BOX_D_VLINE CHOOSE( 0xba, 0x2551, 25) +#define BOX_D_URCORNER CHOOSE( 0xbb, 0x2557, 12) +#define BOX_D_LRCORNER CHOOSE( 0xbc, 0x255D, 11) +#define BOX_DS_LRCORNER CHOOSE( 0xbd, 0x255c, 11) +#define BOX_SD_LRCORNER CHOOSE( 0xbe, 0x255b, 11) +#define BOX_URCORNER CHOOSE( 0xbf, 0x2510, 12) + +#define BOX_LLCORNER CHOOSE( 0xc0, 0x2514, 14) +#define BOX_BTEE CHOOSE( 0xc1, 0x2534, 23) +#define BOX_TTEE CHOOSE( 0xc2, 0x252c, 24) +#define BOX_LTEE CHOOSE( 0xc3, 0x251c, 21) +#define BOX_HLINE CHOOSE( 0xc4, 0x2500, 18) +#define BOX_PLUS CHOOSE( 0xc5, 0x253c, 15) +#define BOX_SD_LTEE CHOOSE( 0xc6, 0x255e, 21) +#define BOX_DS_LTEE CHOOSE( 0xc7, 0x255f, 21) +#define BOX_D_LLCORNER CHOOSE( 0xc8, 0x255A, 14) +#define BOX_D_ULCORNER CHOOSE( 0xc9, 0x2554, 13) +#define BOX_D_BTEE CHOOSE( 0xca, 0x2569, 23) +#define BOX_D_TTEE CHOOSE( 0xcb, 0x2566, 24) +#define BOX_D_LTEE CHOOSE( 0xcc, 0x2560, 21) +#define BOX_D_HLINE CHOOSE( 0xcd, 0x2550, 18) +#define BOX_D_PLUS CHOOSE( 0xce, 0x256C, 15) +#define BOX_SD_BTEE CHOOSE( 0xcf, 0x2567, 23) + +#define BOX_DS_BTEE CHOOSE( 0xd0, 0x2568, 23) +#define BOX_SD_TTEE CHOOSE( 0xd1, 0x2564, 24) +#define BOX_DS_TTEE CHOOSE( 0xd2, 0x2565, 24) +#define BOX_DS_LLCORNER CHOOSE( 0xd3, 0x2559, 14) +#define BOX_SD_LLCORNER CHOOSE( 0xd4, 0x2558, 14) +#define BOX_SD_ULCORNER CHOOSE( 0xd5, 0x2552, 13) +#define BOX_DS_ULCORNER CHOOSE( 0xd6, 0x2553, 13) +#define BOX_DS_PLUS CHOOSE( 0xd7, 0x256b, 15) +#define BOX_SD_PLUS CHOOSE( 0xd8, 0x256a, 15) +#define BOX_LRCORNER CHOOSE( 0xd9, 0x2518, 11) +#define BOX_ULCORNER CHOOSE( 0xda, 0x250c, 13) +#define FULL_BLOCK CHOOSE( 0xdb, 0x2588, 0) +#define LOWER_HALF_BLOCK CHOOSE( 0xdc, 0x2584, TBD) +#define LEFT_HALF_BLOCK CHOOSE( 0xdd, 0x258c, TBD) +#define RIGHT_HALF_BLOCK CHOOSE( 0xde, 0x2590, TBD) +#define UPPER_HALF_BLOCK CHOOSE( 0xdf, 0x2580, TBD) + +#define ALPHA CHOOSE( 0xe0, 0x03b1, TBD) +#define BETA CHOOSE( 0xe1, 0x00df, TBD) +#define GAMMA CHOOSE( 0xe2, 0x0393, TBD) +#define PI CHOOSE( 0xe3, 0x03c0, 28) +#define UPPERCASE_SIGMA CHOOSE( 0xe4, 0x03a3, TBD) +#define LOWERCASE_SIGMA CHOOSE( 0xe5, 0x03c3, TBD) +#define MU CHOOSE( 0xe6, 0x00b5, 0xb5) +#define TAU CHOOSE( 0xe7, 0x03c4, TBD) +#define UPPERCASE_PHI CHOOSE( 0xe8, 0x03a6, TBD) +#define THETA CHOOSE( 0xe9, 0x0398, TBD) +#define OMEGA CHOOSE( 0xea, 0x03a9, TBD) +#define DELTA CHOOSE( 0xeb, 0x03b4, TBD) +#define INFINITY_SIGN CHOOSE( 0xec, 0x221e, TBD) +#define LOWERCASE_PHI CHOOSE( 0xed, 0x03c6, TBD) +#define EPSILON CHOOSE( 0xee, 0x03b5, TBD) +#define INTERSECTION CHOOSE( 0xef, 0x2229, TBD) + +#define TRIPLE_BAR CHOOSE( 0xf0, 0x2261, TBD) +#define PLUS_OR_MINUS CHOOSE( 0xf1, 0x00b1, 8) +#define GREATER_THAN_OR_EQUAL_TO CHOOSE( 0xf2, 0x2265, 27) +#define LESSER_THAN_OR_EQUAL_TO CHOOSE( 0xf3, 0x2264, 26) +#define UPPER_HALF_INTEGRAL_SIGN CHOOSE( 0xf4, 0x2320, TBD) +#define LOWER_HALF_INTEGRAL_SIGN CHOOSE( 0xf5, 0x2321, TBD) +#define DIVISION_SIGN CHOOSE( 0xf6, 0x00f7, 0xf7) +#define APPROXIMATELY_EQUALS_SIGN CHOOSE( 0xf7, 0x2248, TBD) +#define DEGREE_SIGN CHOOSE( 0xf8, 0x00b0, 0xb0) +#define LARGE_BULLET CHOOSE( 0xf9, 0x2219, 7) +#define SMALL_BULLET CHOOSE( 0xfa, 0x00b7, 0xb7) +#define SQUARE_ROOT CHOOSE( 0xfb, 0x221a, TBD) +#define SUPERSCRIPT_N CHOOSE( 0xfc, 0x207f, TBD) +#define SUPERSCRIPT_2 CHOOSE( 0xfd, 0x00b2, 0xb2) +#define CENTERED_SQUARE CHOOSE( 0xfe, 0x25a0, TBD) +#define NON_BREAKING_SPACE CHOOSE( 0xff, 0x00a0, TBD) + + + + /* It says at http://unicode.org/charts/PDF/U2300.pdf */ + /* that '...the scan line numbers here refer to old, */ + /* low-resolution technology for terminals, with only */ + /* nine scan lines per fixed-size character glyph. */ + /* Even-numbered scan lines are unified with box */ + /* drawing graphics." */ + /* The utility of these is questionable; they'd */ + /* work Just Fine in wingdi (_if_ the appropriate */ + /* glyphs are available), but not elsewhere. */ +#define HORIZ_SCAN_LINE_1 CHOOSE( 0x2d, 0x23ba, 16) +#define HORIZ_SCAN_LINE_3 CHOOSE( 0x2d, 0x23bb, 17) +#define HORIZ_SCAN_LINE_7 CHOOSE( 0x2d, 0x23bc, 19) +#define HORIZ_SCAN_LINE_9 CHOOSE( '_', 0x23bd, 20) + + /* Code page 437 lacks a 'for real' not-equals, so for that, */ + /* we use the double-horizontal single-vertical box drawing : */ +#define NOT_EQUALS_SIGN CHOOSE( 0xd8, 0x2260, 29) + +# define A(x) ((chtype)x | A_ALTCHARSET) + +chtype acs_map[128] = +{ + A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), + A(9), A(10), + CLUB, HEART, SPADE, SMILE, REV_SMILE, /* 11 12 13 14 15 */ + MEDIUM_BULLET, WHITE_BULLET, PILCROW, SECTION_SIGN, /* 16 17 18 19 */ + A_ORDINAL, O_ORDINAL, LOWERCASE_PHI, /* 20 21 22 */ + INVERTED_EXCLAMATION_MARK, INVERTED_QUESTION_MARK, /* 23 24 */ + REVERSED_NOT_SIGN, NOT_SIGN, /* 25 26 */ + UPPER_HALF_INTEGRAL_SIGN, LOWER_HALF_INTEGRAL_SIGN, /* 27 28 */ + SUPERSCRIPT_N, CENTERED_SQUARE, F_WITH_HOOK, /* 29 30 31 */ + + RIGHT_ARROW, LEFT_ARROW, UP_ARROW, DOWN_ARROW, /* 32 !"# */ + + PI, NOT_EQUALS_SIGN, VULGAR_HALF, VULGAR_QUARTER, /* $%&' */ + '(', + LEFT_ANGLE_QUOTE_MARK, RIGHT_ANGLE_QUOTE_MARK, /* )* */ + DARK_SHADE, SUPERSCRIPT_2, INFINITY_SIGN, /* +,- */ + ALPHA, BETA, GAMMA, UPPERCASE_SIGMA, LOWERCASE_SIGMA, /* ./012 */ + '3', + MU, TAU, UPPERCASE_PHI, THETA, OMEGA, DELTA, EPSILON, /* 456789: */ + + BOX_SD_LRCORNER, BOX_SD_URCORNER, BOX_SD_ULCORNER, /* ;<= */ + BOX_SD_LLCORNER, BOX_SD_PLUS, /* >? */ + BOX_SD_LTEE, BOX_SD_RTEE, BOX_SD_BTEE, BOX_SD_TTEE, /* @ABC */ + + BOX_D_LRCORNER, BOX_D_URCORNER, BOX_D_ULCORNER, /* DEF */ + BOX_D_LLCORNER, BOX_D_PLUS, /* GH */ + BOX_D_LTEE, BOX_D_RTEE, BOX_D_BTEE, BOX_D_TTEE, /* IJKL */ + + BOX_DS_LRCORNER, BOX_DS_URCORNER, BOX_DS_ULCORNER, /* MNO */ + BOX_DS_LLCORNER, BOX_DS_PLUS, /* PQ */ + BOX_DS_LTEE, BOX_DS_RTEE, BOX_DS_BTEE, BOX_DS_TTEE, /* RSTU */ + + BOX_LRCORNER, BOX_URCORNER, BOX_ULCORNER, /* VWX */ + BOX_LLCORNER, BOX_PLUS, /* YZ */ + BOX_LTEE, BOX_RTEE, BOX_BTEE, BOX_TTEE, /* [\]^ */ + + BOX_HLINE, BOX_VLINE, BOX_D_HLINE, BOX_D_VLINE, /* _`ab */ + + DIVISION_SIGN, APPROXIMATELY_EQUALS_SIGN, /* cd */ + INTERSECTION, TRIPLE_BAR, /* ef */ + SMALL_BULLET, LARGE_BULLET, SQUARE_ROOT, /* ghi */ + DIAMOND, MEDIUM_SHADE, /* jk */ + HORIZ_SCAN_LINE_1, HORIZ_SCAN_LINE_3, /* lm */ + HORIZ_SCAN_LINE_7, HORIZ_SCAN_LINE_9, /* no */ + UPPER_HALF_BLOCK, LOWER_HALF_BLOCK, /* pq */ + LEFT_HALF_BLOCK, RIGHT_HALF_BLOCK, FULL_BLOCK, /* rst */ + LESSER_THAN_OR_EQUAL_TO, GREATER_THAN_OR_EQUAL_TO, /* uv */ + DEGREE_SIGN, PLUS_OR_MINUS, LIGHT_SHADE, SPLAT, /* wxyz */ + CENT_SIGN, YEN_SIGN, PESETA_SIGN, STERLING_SIGN, /* {|}~ */ + A(127) +}; + +# undef A diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h new file mode 100644 index 000000000..9ee3f08a6 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h @@ -0,0 +1,1846 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES__ +#define __PDCURSES__ 1 + +/*man-start************************************************************** + +PDCurses definitions list: (Only define those needed) + + XCURSES True if compiling for X11. + PDC_RGB True if you want to use RGB color definitions + (Red = 1, Green = 2, Blue = 4) instead of BGR. + PDC_WIDE True if building wide-character support. + PDC_DLL_BUILD True if building a Windows DLL. + PDC_NCMOUSE Use the ncurses mouse API instead + of PDCurses' traditional mouse API. + +PDCurses portable platform definitions list: + + PDC_BUILD Defines API build version. + PDCURSES Enables access to PDCurses-only routines. + XOPEN Always true. + SYSVcurses True if you are compiling for SYSV portability. + BSDcurses True if you are compiling for BSD portability. + +**man-end****************************************************************/ + +#define PDCURSES 1 /* PDCurses-only routines */ +#define XOPEN 1 /* X/Open Curses routines */ +#define SYSVcurses 1 /* System V Curses routines */ +#define BSDcurses 1 /* BSD Curses routines */ +#if defined( CHTYPE_32) + #define CHTYPE_LONG 1 /* chtypes will be 32 bits */ +#elif !defined( CHTYPE_16) + #define CHTYPE_LONG 2 /* chtypes will be (default) 64 bits */ +#endif + +/*----------------------------------------------------------------------*/ + +#ifdef NO_STDINT_H + #define uint64_t unsigned long long + #define uint32_t unsigned long + #define uint16_t unsigned short +#else + #include +#endif +#include +#include +#include /* Required by X/Open usage below */ + +#ifdef PDC_WIDE +# include +#endif + +#if defined(__STDC_VERSION__) && __STDC_VERSION >= 199901L && \ + !defined(__bool_true_false_are_defined) +# include +#endif + +#ifdef __cplusplus +extern "C" +{ +# define bool _bool +#endif + +/*---------------------------------------------------------------------- + * + * Constants and Types + * + */ + +#undef FALSE +#undef TRUE + +#ifdef __bool_true_false_are_defined + +# define FALSE false +# define TRUE true + +#else + +typedef unsigned char bool; + +# define FALSE 0 +# define TRUE 1 + +#endif + +#undef ERR +#define ERR (-1) + +#undef OK +#define OK 0 + +#ifdef CHTYPE_LONG + #if(CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes */ + typedef uint64_t chtype; + #else /* "Standard" CHTYPE_LONG case, 32-bit: */ + typedef uint32_t chtype; + # endif +#else +typedef uint16_t chtype; /* 8-bit attr + 8-bit char */ +#endif + +#ifdef PDC_WIDE +typedef chtype cchar_t; +#endif + +typedef chtype attr_t; + +/* Version constants, available as of version 4.0 : */ +/* Don't forget to update 'version.mif' if MAJOR/MINOR changes! */ + +#define PDC_VER_MAJOR 4 +#define PDC_VER_MINOR 0 +#define PDC_VER_CHANGE 4 +#define PDC_VER_YEAR 2019 +#define PDC_VER_MONTH 1 +#define PDC_VER_DAY 20 + +#define PDC_BUILD (PDC_VER_MAJOR*1000 + PDC_VER_MINOR *100 + PDC_VER_CHANGE) + +/* When using PDCurses as a DLL (Windows) or shared library (BSD or *nix), +it's possible to switch the DLL or shared library. One may therefore want +to inquire of the DLL/shared library the port, version numbers, and +chtype_size used, and make sure they're what one was expecting. The +'PDC_version' structure lets you do just that. */ + +enum PDC_port +{ + PDC_PORT_X11 = 0, + PDC_PORT_WIN32 = 1, + PDC_PORT_WINGUI = 2, + PDC_PORT_DOS = 3, + PDC_PORT_OS2 = 4, + PDC_PORT_SDL1 = 5, + PDC_PORT_SDL2 = 6, + PDC_PORT_VT = 7 +}; + +/* Detailed PDC version information */ +#define PDC_HAS_VERSION_INFO 1 +typedef struct +{ + const enum PDC_port port; + const int ver_major; + const int ver_minor; + const int ver_change; + const size_t chtype_size; + const bool is_wide; + const bool is_forced_utf8; +} PDC_version_info; + +/*---------------------------------------------------------------------- + * + * Mouse Interface -- SYSVR4, with extensions + * + */ + +/* Most flavors of PDCurses support three buttons. WinGUI supports */ +/* these plus two "extended" buttons. But we'll set this macro to */ +/* six, allowing future versions to support up to nine total buttons. */ +/* (The button states are broken up into two arrays to allow for the */ +/* possibility of backward compatibility to DLLs compiled with only */ +/* three mouse buttons.) */ + +#define PDC_MAX_MOUSE_BUTTONS 9 +#define PDC_N_EXTENDED_MOUSE_BUTTONS 6 + +typedef struct +{ + int x; /* absolute column, 0 based, measured in characters */ + int y; /* absolute row, 0 based, measured in characters */ + short button[3]; /* state of three "normal" buttons */ + int changes; /* flags indicating what has changed with the mouse */ + short xbutton[PDC_N_EXTENDED_MOUSE_BUTTONS]; /* state of ext buttons */ +} MOUSE_STATUS; + +#define BUTTON_RELEASED 0x0000 +#define BUTTON_PRESSED 0x0001 +#define BUTTON_CLICKED 0x0002 +#define BUTTON_DOUBLE_CLICKED 0x0003 +#define BUTTON_TRIPLE_CLICKED 0x0004 +#define BUTTON_MOVED 0x0005 /* PDCurses */ +#define WHEEL_SCROLLED 0x0006 /* PDCurses */ +#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */ + +#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */ +#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */ +#define PDC_BUTTON_ALT 0x0020 /* PDCurses */ +#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */ + +#define MOUSE_X_POS (Mouse_status.x) +#define MOUSE_Y_POS (Mouse_status.y) + +/* + * Bits associated with the .changes field: + * 3 2 1 0 + * 210987654321098765432109876543210 + * 1 <- button 1 has changed 0 + * 10 <- button 2 has changed 1 + * 100 <- button 3 has changed 2 + * 1000 <- mouse has moved 3 + * 10000 <- mouse position report 4 + * 100000 <- mouse wheel up 5 + * 1000000 <- mouse wheel down 6 + * 10000000 <- mouse wheel left 7 + * 100000000 <- mouse wheel right 8 + * 1000000000 <- button 4 has changed 9 + * (NOTE: buttons 6 to 10000000000 <- button 5 has changed 10 + * 9 aren't implemented 100000000000 <- button 6 has changed 11 + * in any flavor of 1000000000000 <- button 7 has changed 12 + * PDCurses yet!) 10000000000000 <- button 8 has changed 13 + * 100000000000000 <- button 9 has changed 14 + */ + +#define PDC_MOUSE_MOVED 0x0008 +#define PDC_MOUSE_POSITION 0x0010 +#define PDC_MOUSE_WHEEL_UP 0x0020 +#define PDC_MOUSE_WHEEL_DOWN 0x0040 +#define PDC_MOUSE_WHEEL_LEFT 0x0080 +#define PDC_MOUSE_WHEEL_RIGHT 0x0100 + +#define A_BUTTON_CHANGED (Mouse_status.changes & 7) +#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED) +#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION) +#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - ((x)<4 ? 1 : -5)))) +#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1]) +#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP) +#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN) +#define MOUSE_WHEEL_LEFT (Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT) +#define MOUSE_WHEEL_RIGHT (Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT) + +/* mouse bit-masks */ + +#define BUTTON1_RELEASED 0x00000001L +#define BUTTON1_PRESSED 0x00000002L +#define BUTTON1_CLICKED 0x00000004L +#define BUTTON1_DOUBLE_CLICKED 0x00000008L +#define BUTTON1_TRIPLE_CLICKED 0x00000010L +#define BUTTON1_MOVED 0x00000010L /* PDCurses */ + +#define BUTTON2_RELEASED 0x00000020L +#define BUTTON2_PRESSED 0x00000040L +#define BUTTON2_CLICKED 0x00000080L +#define BUTTON2_DOUBLE_CLICKED 0x00000100L +#define BUTTON2_TRIPLE_CLICKED 0x00000200L +#define BUTTON2_MOVED 0x00000200L /* PDCurses */ + +#define BUTTON3_RELEASED 0x00000400L +#define BUTTON3_PRESSED 0x00000800L +#define BUTTON3_CLICKED 0x00001000L +#define BUTTON3_DOUBLE_CLICKED 0x00002000L +#define BUTTON3_TRIPLE_CLICKED 0x00004000L +#define BUTTON3_MOVED 0x00004000L /* PDCurses */ + +/* For the ncurses-compatible functions only, BUTTON4_PRESSED and + BUTTON5_PRESSED are returned for mouse scroll wheel up and down; + otherwise PDCurses doesn't support buttons 4 and 5... except + as described above for WinGUI, and perhaps to be extended to + other PDCurses flavors */ + +#define BUTTON4_RELEASED 0x00008000L +#define BUTTON4_PRESSED 0x00010000L +#define BUTTON4_CLICKED 0x00020000L +#define BUTTON4_DOUBLE_CLICKED 0x00040000L +#define BUTTON4_TRIPLE_CLICKED 0x00080000L + +#define BUTTON5_RELEASED 0x00100000L +#define BUTTON5_PRESSED 0x00200000L +#define BUTTON5_CLICKED 0x00400000L +#define BUTTON5_DOUBLE_CLICKED 0x00800000L +#define BUTTON5_TRIPLE_CLICKED 0x01000000L + +#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */ +#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */ +#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */ +#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */ + +#define ALL_MOUSE_EVENTS 0x1fffffffL +#define REPORT_MOUSE_POSITION 0x20000000L + +/* ncurses mouse interface */ + +typedef unsigned long mmask_t; + +typedef struct +{ + short id; /* unused, always 0 */ + int x, y, z; /* x, y same as MOUSE_STATUS; z unused */ + mmask_t bstate; /* equivalent to changes + button[], but + in the same format as used for mousemask() */ +} MEVENT; + +#if defined(PDC_NCMOUSE) && !defined(NCURSES_MOUSE_VERSION) +# define NCURSES_MOUSE_VERSION 2 +#endif + +#ifdef NCURSES_MOUSE_VERSION +# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT +# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL +# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL +# define BUTTON_ALT BUTTON_MODIFIER_ALT +#else +# define BUTTON_SHIFT PDC_BUTTON_SHIFT +# define BUTTON_CONTROL PDC_BUTTON_CONTROL +# define BUTTON_ALT PDC_BUTTON_ALT +#endif + +/*---------------------------------------------------------------------- + * + * Window and Screen Structures + * + */ + +typedef struct _win /* definition of a window */ +{ + int _cury; /* current pseudo-cursor */ + int _curx; + int _maxy; /* max window coordinates */ + int _maxx; + int _begy; /* origin on screen */ + int _begx; + int _flags; /* window properties */ + chtype _attrs; /* standard attributes and colors */ + chtype _bkgd; /* background, normally blank */ + bool _clear; /* causes clear at next refresh */ + bool _leaveit; /* leaves cursor where it is */ + bool _scroll; /* allows window scrolling */ + bool _nodelay; /* input character wait flag */ + bool _immed; /* immediate update flag */ + bool _sync; /* synchronise window ancestors */ + bool _use_keypad; /* flags keypad key mode active */ + chtype **_y; /* pointer to line pointer array */ + int *_firstch; /* first changed character in line */ + int *_lastch; /* last changed character in line */ + int _tmarg; /* top of scrolling region */ + int _bmarg; /* bottom of scrolling region */ + int _delayms; /* milliseconds of delay for getch() */ + int _parx, _pary; /* coords relative to parent (0,0) */ + struct _win *_parent; /* subwin's pointer to parent win */ +} WINDOW; + +/* Avoid using the SCREEN struct directly -- use the corresponding + functions if possible. This struct may eventually be made private. */ + +typedef struct +{ + bool alive; /* if initscr() called, and not endwin() */ + bool autocr; /* if cr -> lf */ + bool cbreak; /* if terminal unbuffered */ + bool echo; /* if terminal echo */ + bool raw_inp; /* raw input mode (v. cooked input) */ + bool raw_out; /* raw output mode (7 v. 8 bits) */ + bool audible; /* FALSE if the bell is visual */ + bool mono; /* TRUE if current screen is mono */ + bool resized; /* TRUE if TERM has been resized */ + bool orig_attr; /* TRUE if we have the original colors */ + short orig_fore; /* original screen foreground color */ + short orig_back; /* original screen foreground color */ + int cursrow; /* position of physical cursor */ + int curscol; /* position of physical cursor */ + int visibility; /* visibility of cursor */ + int orig_cursor; /* original cursor size */ + int lines; /* new value for LINES */ + int cols; /* new value for COLS */ + unsigned long _trap_mbe; /* trap these mouse button events */ + unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ + int mouse_wait; /* time to wait (in ms) for a + button release after a press, in + order to count it as a click */ + int slklines; /* lines in use by slk_init() */ + WINDOW *slk_winptr; /* window for slk */ + int linesrippedoff; /* lines ripped off via ripoffline() */ + int linesrippedoffontop; /* lines ripped off on + top via ripoffline() */ + int delaytenths; /* 1/10ths second to wait block + getch() for */ + bool _preserve; /* TRUE if screen background + to be preserved */ + int _restore; /* specifies if screen background + to be restored, and how */ + bool save_key_modifiers; /* TRUE if each key modifiers saved + with each key press */ + bool return_key_modifiers; /* TRUE if modifier keys are + returned as "real" keys */ + bool key_code; /* TRUE if last key is a special key; + used internally by get_wch() */ +#ifdef XCURSES + int XcurscrSize; /* size of Xcurscr shared memory block */ + bool sb_on; + int sb_viewport_y; + int sb_viewport_x; + int sb_total_y; + int sb_total_x; + int sb_cur_y; + int sb_cur_x; + int exit_key; +#endif + short line_color; /* color of line attributes - default -1 */ +} SCREEN; + +/*---------------------------------------------------------------------- + * + * External Variables + * + */ + +#ifdef PDC_DLL_BUILD +# ifdef CURSES_LIBRARY +# define PDCEX __declspec(dllexport) extern +# else +# define PDCEX __declspec(dllimport) +# endif +#else +# define PDCEX extern +#endif + +PDCEX int LINES; /* terminal height */ +PDCEX int COLS; /* terminal width */ +PDCEX WINDOW *stdscr; /* the default screen window */ +PDCEX WINDOW *curscr; /* the current screen image */ +PDCEX SCREEN *SP; /* curses variables */ +PDCEX MOUSE_STATUS Mouse_status; +PDCEX int COLORS; +PDCEX int COLOR_PAIRS; +PDCEX int TABSIZE; +PDCEX chtype acs_map[]; /* alternate character set map */ +PDCEX char ttytype[]; /* terminal name/description */ +PDCEX PDC_version_info PDC_version; + +/*man-start************************************************************** + +Text Attributes +=============== + +Originally, PDCurses used a short (16 bits) for its chtype. To include +color, a number of things had to be sacrificed from the strict Unix and +System V support. The main problem was fitting all character attributes +and color into an unsigned char (all 8 bits!). + +Today, PDCurses by default uses a long (32 bits) for its chtype, as in +System V. The short chtype is still available, by undefining CHTYPE_LONG +and rebuilding the library. + +The following is the structure of a win->_attrs chtype: + +short form: + + +-----------------------------------------------+ + |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| + +-----------------------------------------------+ + color number | attrs | character eg 'a' + +The available non-color attributes are bold, reverse and blink. Others +have no effect. The high order char is an index into an array of +physical colors (defined in color.c) -- 32 foreground/background color +pairs (5 bits) plus 3 bits for other attributes. + +long form: + + +--------------------------------------------------------------------+ + |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0| + +--------------------------------------------------------------------+ + color number | modifiers | character eg 'a' + +The available non-color attributes are bold, underline, invisible, +right-line, left-line, protect, reverse and blink. 256 color pairs (8 +bits), 8 bits for other attributes, and 16 bits for character data. + + Note that there is now a "super-long" 64-bit form, available by +defining CHTYPE_LONG to be 2: + +------------------------------------------------------------------------------- +|63|62|61|60|59|..|34|33|32|31|30|29|28|..|22|21|20|19|18|17|16|..| 3| 2| 1| 0| +------------------------------------------------------------------------------- + color number | modifiers | character eg 'a' + + + We take five more bits for the character (thus allowing Unicode values +past 64K; UTF-16 can go up to 0x10ffff, requiring 21 bits total), and +four more bits for attributes. Three are currently used as A_OVERLINE, A_DIM, +and A_STRIKEOUT; one more is reserved for future use. 31 bits are then used +for color. These are usually just treated as the usual palette +indices, and range from 0 to 255. However, if bit 63 is +set, the remaining 30 bits are interpreted as foreground RGB (first +fifteen bits, five bits for each of the three channels) and background RGB +(same scheme using the remaining 15 bits.) + +**man-end****************************************************************/ + +/*** Video attribute macros ***/ + +#define A_NORMAL (chtype)0 + +#ifdef CHTYPE_LONG + +# if(CHTYPE_LONG >= 2) /* 64-bit chtypes */ + # define PDC_CHARTEXT_BITS 21 + # define A_CHARTEXT (chtype)( ((chtype)0x1 << PDC_CHARTEXT_BITS) - 1) + # define A_ALTCHARSET ((chtype)0x001 << PDC_CHARTEXT_BITS) + # define A_RIGHTLINE ((chtype)0x002 << PDC_CHARTEXT_BITS) + # define A_LEFTLINE ((chtype)0x004 << PDC_CHARTEXT_BITS) + # define A_INVIS ((chtype)0x008 << PDC_CHARTEXT_BITS) + # define A_UNDERLINE ((chtype)0x010 << PDC_CHARTEXT_BITS) + # define A_REVERSE ((chtype)0x020 << PDC_CHARTEXT_BITS) + # define A_BLINK ((chtype)0x040 << PDC_CHARTEXT_BITS) + # define A_BOLD ((chtype)0x080 << PDC_CHARTEXT_BITS) + # define A_OVERLINE ((chtype)0x100 << PDC_CHARTEXT_BITS) + # define A_STRIKEOUT ((chtype)0x200 << PDC_CHARTEXT_BITS) + # define A_DIM ((chtype)0x400 << PDC_CHARTEXT_BITS) +#if 0 + /* May come up with a use for this bit */ + /* someday; reserved for the future: */ + # define A_FUTURE_2 ((chtype)0x800 << PDC_CHARTEXT_BITS) +#endif + # define PDC_COLOR_SHIFT (PDC_CHARTEXT_BITS + 12) + # define A_COLOR ((chtype)0x7fffffff << PDC_COLOR_SHIFT) + # define A_RGB_COLOR ((chtype)0x40000000 << PDC_COLOR_SHIFT) + # define A_ATTRIBUTES (((chtype)0xfff << PDC_CHARTEXT_BITS) | A_COLOR) + # define A_RGB( rfore, gfore, bfore, rback, gback, bback) \ + (( (((chtype)(bfore) << 25) \ + | ((chtype)(gfore) << 20) \ + | ((chtype)(rfore) << 15) \ + | ((chtype)(bback) << 10) \ + | ((chtype)(gback) << 5) \ + | ((chtype)(rback) )) << PDC_COLOR_SHIFT) | A_RGB_COLOR) +# else /* plain ol' 32-bit chtypes */ + # define A_ALTCHARSET (chtype)0x00010000 + # define A_RIGHTLINE (chtype)0x00020000 + # define A_LEFTLINE (chtype)0x00040000 + # define A_INVIS (chtype)0x00080000 + # define A_UNDERLINE (chtype)0x00100000 + # define A_REVERSE (chtype)0x00200000 + # define A_BLINK (chtype)0x00400000 + # define A_BOLD (chtype)0x00800000 + # define A_COLOR (chtype)0xff000000 + # define A_RGB_COLOR A_NORMAL +#ifdef PDC_WIDE + # define A_CHARTEXT (chtype)0x0000ffff + # define A_ATTRIBUTES (chtype)0xffff0000 + # define A_DIM A_NORMAL + # define A_OVERLINE A_NORMAL + # define A_STRIKEOUT A_NORMAL +#else /* with 8-bit chars, we have bits for these attribs : */ + # define A_CHARTEXT (chtype)0x000000ff + # define A_ATTRIBUTES (chtype)0xffffe000 + # define A_DIM (chtype)0x00008000 + # define A_OVERLINE (chtype)0x00004000 + # define A_STRIKEOUT (chtype)0x00002000 +#endif + # define PDC_COLOR_SHIFT 24 +#endif + + +# define A_ITALIC A_INVIS +# define A_PROTECT (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE) + +#else /* 16-bit chtypes */ +# define A_BOLD (chtype)0x0100 /* X/Open */ +# define A_REVERSE (chtype)0x0200 /* X/Open */ +# define A_BLINK (chtype)0x0400 /* X/Open */ + +# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */ +# define A_CHARTEXT (chtype)0x00ff /* X/Open */ +# define A_COLOR (chtype)0xf800 /* System V */ + +# define A_ALTCHARSET A_NORMAL /* X/Open */ +# define A_PROTECT A_NORMAL /* X/Open */ +# define A_UNDERLINE A_NORMAL /* X/Open */ +# define A_OVERLINE A_NORMAL /* X/Open */ +# define A_STRIKEOUT A_NORMAL /* X/Open */ + +# define A_LEFTLINE A_NORMAL +# define A_RIGHTLINE A_NORMAL +# define A_ITALIC A_NORMAL +# define A_INVIS A_NORMAL +# define A_RGB_COLOR A_NORMAL +# define A_DIM A_NORMAL + +# define PDC_COLOR_SHIFT 11 +#endif + +#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */ + +#define CHR_MSK A_CHARTEXT /* Obsolete */ +#define ATR_MSK A_ATTRIBUTES /* Obsolete */ +#define ATR_NRM A_NORMAL /* Obsolete */ + +/* For use with attr_t -- X/Open says, "these shall be distinct", so + this is a non-conforming implementation. */ + +#define WA_NORMAL A_NORMAL + +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_BLINK A_BLINK +#define WA_BOLD A_BOLD +#define WA_DIM A_DIM +#define WA_INVIS A_INVIS +#define WA_LEFT A_LEFTLINE +#define WA_PROTECT A_PROTECT +#define WA_REVERSE A_REVERSE +#define WA_RIGHT A_RIGHTLINE +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE + +#define WA_HORIZONTAL A_NORMAL +#define WA_LOW A_NORMAL +#define WA_TOP A_NORMAL +#define WA_VERTICAL A_NORMAL + +#define WA_ATTRIBUTES A_ATTRIBUTES + +/*** Alternate character set macros ***/ + +/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET + 'n' = 16-bit chtype; it gets the fallback set because no bit is + available for A_ALTCHARSET */ + +#ifdef CHTYPE_LONG +# define PDC_ACS(w, n) ((chtype)w | A_ALTCHARSET) +#else +# define PDC_ACS(w, n) ((chtype)n) +#endif + +/* VT100-compatible symbols -- box chars */ + +#define ACS_LRCORNER PDC_ACS('V', '+') +#define ACS_URCORNER PDC_ACS('W', '+') +#define ACS_ULCORNER PDC_ACS('X', '+') +#define ACS_LLCORNER PDC_ACS('Y', '+') +#define ACS_PLUS PDC_ACS('Z', '+') +#define ACS_LTEE PDC_ACS('[', '+') +#define ACS_RTEE PDC_ACS('\\', '+') +#define ACS_BTEE PDC_ACS(']', '+') +#define ACS_TTEE PDC_ACS('^', '+') +#define ACS_HLINE PDC_ACS('_', '-') +#define ACS_VLINE PDC_ACS('`', '|') + +/* PDCurses-only ACS chars. Don't use if ncurses compatibility matters. +Some won't work in non-wide X11 builds (see 'acs_defs.h' for details). */ + +#define ACS_CENT PDC_ACS('{', 'c') +#define ACS_YEN PDC_ACS('|', 'y') +#define ACS_PESETA PDC_ACS('}', 'p') +#define ACS_HALF PDC_ACS('&', '/') +#define ACS_QUARTER PDC_ACS('\'', '/') +#define ACS_LEFT_ANG_QU PDC_ACS(')', '<') +#define ACS_RIGHT_ANG_QU PDC_ACS('*', '>') +#define ACS_D_HLINE PDC_ACS('a', '-') +#define ACS_D_VLINE PDC_ACS('b', '|') +#define ACS_CLUB PDC_ACS( 11, 'C') +#define ACS_HEART PDC_ACS( 12, 'H') +#define ACS_SPADE PDC_ACS( 13, 'S') +#define ACS_SMILE PDC_ACS( 14, 'O') +#define ACS_REV_SMILE PDC_ACS( 15, 'O') +#define ACS_MED_BULLET PDC_ACS( 16, '.') +#define ACS_WHITE_BULLET PDC_ACS( 17, 'O') +#define ACS_PILCROW PDC_ACS( 18, 'O') +#define ACS_SECTION PDC_ACS( 19, 'O') + +#define ACS_SUP2 PDC_ACS(',', '2') +#define ACS_ALPHA PDC_ACS('.', 'a') +#define ACS_BETA PDC_ACS('/', 'b') +#define ACS_GAMMA PDC_ACS('0', 'y') +#define ACS_UP_SIGMA PDC_ACS('1', 'S') +#define ACS_LO_SIGMA PDC_ACS('2', 's') +#define ACS_MU PDC_ACS('4', 'u') +#define ACS_TAU PDC_ACS('5', 't') +#define ACS_UP_PHI PDC_ACS('6', 'F') +#define ACS_THETA PDC_ACS('7', 't') +#define ACS_OMEGA PDC_ACS('8', 'w') +#define ACS_DELTA PDC_ACS('9', 'd') +#define ACS_INFINITY PDC_ACS('-', 'i') +#define ACS_LO_PHI PDC_ACS( 22, 'f') +#define ACS_EPSILON PDC_ACS(':', 'e') +#define ACS_INTERSECT PDC_ACS('e', 'u') +#define ACS_TRIPLE_BAR PDC_ACS('f', '=') +#define ACS_DIVISION PDC_ACS('c', '/') +#define ACS_APPROX_EQ PDC_ACS('d', '~') +#define ACS_SM_BULLET PDC_ACS('g', '.') +#define ACS_SQUARE_ROOT PDC_ACS('i', '!') +#define ACS_UBLOCK PDC_ACS('p', '^') +#define ACS_BBLOCK PDC_ACS('q', '_') +#define ACS_LBLOCK PDC_ACS('r', '<') +#define ACS_RBLOCK PDC_ACS('s', '>') + +#define ACS_A_ORDINAL PDC_ACS(20, 'a') +#define ACS_O_ORDINAL PDC_ACS(21, 'o') +#define ACS_INV_QUERY PDC_ACS(24, '?') +#define ACS_REV_NOT PDC_ACS(25, '!') +#define ACS_NOT PDC_ACS(26, '!') +#define ACS_INV_BANG PDC_ACS(23, '!') +#define ACS_UP_INTEGRAL PDC_ACS(27, '|') +#define ACS_LO_INTEGRAL PDC_ACS(28, '|') +#define ACS_SUP_N PDC_ACS(29, 'n') +#define ACS_CENTER_SQU PDC_ACS(30, 'x') +#define ACS_F_WITH_HOOK PDC_ACS(31, 'f') + +#define ACS_SD_LRCORNER PDC_ACS(';', '+') +#define ACS_SD_URCORNER PDC_ACS('<', '+') +#define ACS_SD_ULCORNER PDC_ACS('=', '+') +#define ACS_SD_LLCORNER PDC_ACS('>', '+') +#define ACS_SD_PLUS PDC_ACS('?', '+') +#define ACS_SD_LTEE PDC_ACS('@', '+') +#define ACS_SD_RTEE PDC_ACS('A', '+') +#define ACS_SD_BTEE PDC_ACS('B', '+') +#define ACS_SD_TTEE PDC_ACS('C', '+') + +#define ACS_D_LRCORNER PDC_ACS('D', '+') +#define ACS_D_URCORNER PDC_ACS('E', '+') +#define ACS_D_ULCORNER PDC_ACS('F', '+') +#define ACS_D_LLCORNER PDC_ACS('G', '+') +#define ACS_D_PLUS PDC_ACS('H', '+') +#define ACS_D_LTEE PDC_ACS('I', '+') +#define ACS_D_RTEE PDC_ACS('J', '+') +#define ACS_D_BTEE PDC_ACS('K', '+') +#define ACS_D_TTEE PDC_ACS('L', '+') + +#define ACS_DS_LRCORNER PDC_ACS('M', '+') +#define ACS_DS_URCORNER PDC_ACS('N', '+') +#define ACS_DS_ULCORNER PDC_ACS('O', '+') +#define ACS_DS_LLCORNER PDC_ACS('P', '+') +#define ACS_DS_PLUS PDC_ACS('Q', '+') +#define ACS_DS_LTEE PDC_ACS('R', '+') +#define ACS_DS_RTEE PDC_ACS('S', '+') +#define ACS_DS_BTEE PDC_ACS('T', '+') +#define ACS_DS_TTEE PDC_ACS('U', '+') + +/* VT100-compatible symbols -- other */ + +#define ACS_S1 PDC_ACS('l', '-') +#define ACS_S9 PDC_ACS('o', '_') +#define ACS_DIAMOND PDC_ACS('j', '+') +#define ACS_CKBOARD PDC_ACS('k', ':') +#define ACS_DEGREE PDC_ACS('w', '\'') +#define ACS_PLMINUS PDC_ACS('x', '#') +#define ACS_BULLET PDC_ACS('h', 'o') + +/* Teletype 5410v1 symbols -- these are defined in SysV curses, but + are not well-supported by most terminals. Stick to VT100 characters + for optimum portability. */ + +#define ACS_LARROW PDC_ACS('!', '<') +#define ACS_RARROW PDC_ACS(' ', '>') +#define ACS_DARROW PDC_ACS('#', 'v') +#define ACS_UARROW PDC_ACS('"', '^') +#define ACS_BOARD PDC_ACS('+', '#') +#define ACS_LTBOARD PDC_ACS('y', '#') +#define ACS_LANTERN PDC_ACS('z', '*') +#define ACS_BLOCK PDC_ACS('t', '#') + +/* That goes double for these -- undocumented SysV symbols. Don't use + them. */ + +#define ACS_S3 PDC_ACS('m', '-') +#define ACS_S7 PDC_ACS('n', '-') +#define ACS_LEQUAL PDC_ACS('u', '<') +#define ACS_GEQUAL PDC_ACS('v', '>') +#define ACS_PI PDC_ACS('$', 'n') +#define ACS_NEQUAL PDC_ACS('%', '+') +#define ACS_STERLING PDC_ACS('~', 'L') + +/* Box char aliases */ + +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +/* cchar_t aliases */ + +#ifdef PDC_WIDE +# define WACS_LRCORNER (&(acs_map['V'])) +# define WACS_URCORNER (&(acs_map['W'])) +# define WACS_ULCORNER (&(acs_map['X'])) +# define WACS_LLCORNER (&(acs_map['Y'])) +# define WACS_PLUS (&(acs_map['Z'])) +# define WACS_LTEE (&(acs_map['['])) +# define WACS_RTEE (&(acs_map['\\'])) +# define WACS_BTEE (&(acs_map[']'])) +# define WACS_TTEE (&(acs_map['^'])) +# define WACS_HLINE (&(acs_map['_'])) +# define WACS_VLINE (&(acs_map['`'])) + +# define WACS_CENT (&(acs_map['{'])) +# define WACS_YEN (&(acs_map['|'])) +# define WACS_PESETA (&(acs_map['}'])) +# define WACS_HALF (&(acs_map['&'])) +# define WACS_QUARTER (&(acs_map['\''])) +# define WACS_LEFT_ANG_QU (&(acs_map[')'])) +# define WACS_RIGHT_ANG_QU (&(acs_map['*'])) +# define WACS_D_HLINE (&(acs_map['a'])) +# define WACS_D_VLINE (&(acs_map['b'])) +# define WACS_CLUB (&(acs_map[ 11])) +# define WACS_HEART (&(acs_map[ 12])) +# define WACS_SPADE (&(acs_map[ 13])) +# define WACS_SMILE (&(acs_map[ 14])) +# define WACS_REV_SMILE (&(acs_map[ 15])) +# define WACS_MED_BULLET (&(acs_map[ 16])) +# define WACS_WHITE_BULLET (&(acs_map[ 17])) +# define WACS_PILCROW (&(acs_map[ 18])) +# define WACS_SECTION (&(acs_map[ 19])) + +# define WACS_SUP2 (&(acs_map[','])) +# define WACS_ALPHA (&(acs_map['.'])) +# define WACS_BETA (&(acs_map['/'])) +# define WACS_GAMMA (&(acs_map['0'])) +# define WACS_UP_SIGMA (&(acs_map['1'])) +# define WACS_LO_SIGMA (&(acs_map['2'])) +# define WACS_MU (&(acs_map['4'])) +# define WACS_TAU (&(acs_map['5'])) +# define WACS_UP_PHI (&(acs_map['6'])) +# define WACS_THETA (&(acs_map['7'])) +# define WACS_OMEGA (&(acs_map['8'])) +# define WACS_DELTA (&(acs_map['9'])) +# define WACS_INFINITY (&(acs_map['-'])) +# define WACS_LO_PHI (&(acs_map[ 22])) +# define WACS_EPSILON (&(acs_map[':'])) +# define WACS_INTERSECT (&(acs_map['e'])) +# define WACS_TRIPLE_BAR (&(acs_map['f'])) +# define WACS_DIVISION (&(acs_map['c'])) +# define WACS_APPROX_EQ (&(acs_map['d'])) +# define WACS_SM_BULLET (&(acs_map['g'])) +# define WACS_SQUARE_ROOT (&(acs_map['i'])) +# define WACS_UBLOCK (&(acs_map['p'])) +# define WACS_BBLOCK (&(acs_map['q'])) +# define WACS_LBLOCK (&(acs_map['r'])) +# define WACS_RBLOCK (&(acs_map['s'])) + +# define WACS_A_ORDINAL (&(acs_map[20])) +# define WACS_O_ORDINAL (&(acs_map[21])) +# define WACS_INV_QUERY (&(acs_map[24])) +# define WACS_REV_NOT (&(acs_map[25])) +# define WACS_NOT (&(acs_map[26])) +# define WACS_INV_BANG (&(acs_map[23])) +# define WACS_UP_INTEGRAL (&(acs_map[27])) +# define WACS_LO_INTEGRAL (&(acs_map[28])) +# define WACS_SUP_N (&(acs_map[29])) +# define WACS_CENTER_SQU (&(acs_map[30])) +# define WACS_F_WITH_HOOK (&(acs_map[31])) + +# define WACS_SD_LRCORNER (&(acs_map[';'])) +# define WACS_SD_URCORNER (&(acs_map['<'])) +# define WACS_SD_ULCORNER (&(acs_map['='])) +# define WACS_SD_LLCORNER (&(acs_map['>'])) +# define WACS_SD_PLUS (&(acs_map['?'])) +# define WACS_SD_LTEE (&(acs_map['@'])) +# define WACS_SD_RTEE (&(acs_map['A'])) +# define WACS_SD_BTEE (&(acs_map['B'])) +# define WACS_SD_TTEE (&(acs_map['C'])) + +# define WACS_D_LRCORNER (&(acs_map['D'])) +# define WACS_D_URCORNER (&(acs_map['E'])) +# define WACS_D_ULCORNER (&(acs_map['F'])) +# define WACS_D_LLCORNER (&(acs_map['G'])) +# define WACS_D_PLUS (&(acs_map['H'])) +# define WACS_D_LTEE (&(acs_map['I'])) +# define WACS_D_RTEE (&(acs_map['J'])) +# define WACS_D_BTEE (&(acs_map['K'])) +# define WACS_D_TTEE (&(acs_map['L'])) + +# define WACS_DS_LRCORNER (&(acs_map['M'])) +# define WACS_DS_URCORNER (&(acs_map['N'])) +# define WACS_DS_ULCORNER (&(acs_map['O'])) +# define WACS_DS_LLCORNER (&(acs_map['P'])) +# define WACS_DS_PLUS (&(acs_map['Q'])) +# define WACS_DS_LTEE (&(acs_map['R'])) +# define WACS_DS_RTEE (&(acs_map['S'])) +# define WACS_DS_BTEE (&(acs_map['T'])) +# define WACS_DS_TTEE (&(acs_map['U'])) + +# define WACS_S1 (&(acs_map['l'])) +# define WACS_S9 (&(acs_map['o'])) +# define WACS_DIAMOND (&(acs_map['j'])) +# define WACS_CKBOARD (&(acs_map['k'])) +# define WACS_DEGREE (&(acs_map['w'])) +# define WACS_PLMINUS (&(acs_map['x'])) +# define WACS_BULLET (&(acs_map['h'])) + + +# define WACS_LARROW (&(acs_map['!'])) +# define WACS_RARROW (&(acs_map[' '])) +# define WACS_DARROW (&(acs_map['#'])) +# define WACS_UARROW (&(acs_map['"'])) +# define WACS_BOARD (&(acs_map['+'])) +# define WACS_LTBOARD (&(acs_map['y'])) +# define WACS_LANTERN (&(acs_map['z'])) +# define WACS_BLOCK (&(acs_map['t'])) + +# define WACS_S3 (&(acs_map['m'])) +# define WACS_S7 (&(acs_map['n'])) +# define WACS_LEQUAL (&(acs_map['u'])) +# define WACS_GEQUAL (&(acs_map['v'])) +# define WACS_PI (&(acs_map['$'])) +# define WACS_NEQUAL (&(acs_map['%'])) +# define WACS_STERLING (&(acs_map['~'])) + +# define WACS_BSSB WACS_ULCORNER +# define WACS_SSBB WACS_LLCORNER +# define WACS_BBSS WACS_URCORNER +# define WACS_SBBS WACS_LRCORNER +# define WACS_SBSS WACS_RTEE +# define WACS_SSSB WACS_LTEE +# define WACS_SSBS WACS_BTEE +# define WACS_BSSS WACS_TTEE +# define WACS_BSBS WACS_HLINE +# define WACS_SBSB WACS_VLINE +# define WACS_SSSS WACS_PLUS +#endif + +/*** Color macros ***/ + +#define COLOR_BLACK 0 + +#ifdef PDC_RGB /* RGB */ +# define COLOR_RED 1 +# define COLOR_GREEN 2 +# define COLOR_BLUE 4 +#else /* BGR */ +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_RED 4 +#endif + +#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) +#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) +#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) + +#define COLOR_WHITE 7 + +/*---------------------------------------------------------------------- + * + * Function and Keypad Key Definitions + * Many are just for compatibility + * + */ + +#ifdef PDC_WIDE + #define KEY_OFFSET 0xec00 +#else + #define KEY_OFFSET 0x100 +#endif + +#define KEY_CODE_YES (KEY_OFFSET + 0x00) /* If get_wch() gives a key code */ + +#define KEY_BREAK (KEY_OFFSET + 0x01) /* Not on PC KBD */ +#define KEY_DOWN (KEY_OFFSET + 0x02) /* Down arrow key */ +#define KEY_UP (KEY_OFFSET + 0x03) /* Up arrow key */ +#define KEY_LEFT (KEY_OFFSET + 0x04) /* Left arrow key */ +#define KEY_RIGHT (KEY_OFFSET + 0x05) /* Right arrow key */ +#define KEY_HOME (KEY_OFFSET + 0x06) /* home key */ +#define KEY_BACKSPACE (KEY_OFFSET + 0x07) /* not on pc */ +#define KEY_F0 (KEY_OFFSET + 0x08) /* function keys; 64 reserved */ + +#define KEY_DL (KEY_OFFSET + 0x48) /* delete line */ +#define KEY_IL (KEY_OFFSET + 0x49) /* insert line */ +#define KEY_DC (KEY_OFFSET + 0x4a) /* delete character */ +#define KEY_IC (KEY_OFFSET + 0x4b) /* insert char or enter ins mode */ +#define KEY_EIC (KEY_OFFSET + 0x4c) /* exit insert char mode */ +#define KEY_CLEAR (KEY_OFFSET + 0x4d) /* clear screen */ +#define KEY_EOS (KEY_OFFSET + 0x4e) /* clear to end of screen */ +#define KEY_EOL (KEY_OFFSET + 0x4f) /* clear to end of line */ +#define KEY_SF (KEY_OFFSET + 0x50) /* scroll 1 line forward */ +#define KEY_SR (KEY_OFFSET + 0x51) /* scroll 1 line back (reverse) */ +#define KEY_NPAGE (KEY_OFFSET + 0x52) /* next page */ +#define KEY_PPAGE (KEY_OFFSET + 0x53) /* previous page */ +#define KEY_STAB (KEY_OFFSET + 0x54) /* set tab */ +#define KEY_CTAB (KEY_OFFSET + 0x55) /* clear tab */ +#define KEY_CATAB (KEY_OFFSET + 0x56) /* clear all tabs */ +#define KEY_ENTER (KEY_OFFSET + 0x57) /* enter or send (unreliable) */ +#define KEY_SRESET (KEY_OFFSET + 0x58) /* soft/reset (partial/unreliable) */ +#define KEY_RESET (KEY_OFFSET + 0x59) /* reset/hard reset (unreliable) */ +#define KEY_PRINT (KEY_OFFSET + 0x5a) /* print/copy */ +#define KEY_LL (KEY_OFFSET + 0x5b) /* home down/bottom (lower left) */ +#define KEY_ABORT (KEY_OFFSET + 0x5c) /* abort/terminate key (any) */ +#define KEY_SHELP (KEY_OFFSET + 0x5d) /* short help */ +#define KEY_LHELP (KEY_OFFSET + 0x5e) /* long help */ +#define KEY_BTAB (KEY_OFFSET + 0x5f) /* Back tab key */ +#define KEY_BEG (KEY_OFFSET + 0x60) /* beg(inning) key */ +#define KEY_CANCEL (KEY_OFFSET + 0x61) /* cancel key */ +#define KEY_CLOSE (KEY_OFFSET + 0x62) /* close key */ +#define KEY_COMMAND (KEY_OFFSET + 0x63) /* cmd (command) key */ +#define KEY_COPY (KEY_OFFSET + 0x64) /* copy key */ +#define KEY_CREATE (KEY_OFFSET + 0x65) /* create key */ +#define KEY_END (KEY_OFFSET + 0x66) /* end key */ +#define KEY_EXIT (KEY_OFFSET + 0x67) /* exit key */ +#define KEY_FIND (KEY_OFFSET + 0x68) /* find key */ +#define KEY_HELP (KEY_OFFSET + 0x69) /* help key */ +#define KEY_MARK (KEY_OFFSET + 0x6a) /* mark key */ +#define KEY_MESSAGE (KEY_OFFSET + 0x6b) /* message key */ +#define KEY_MOVE (KEY_OFFSET + 0x6c) /* move key */ +#define KEY_NEXT (KEY_OFFSET + 0x6d) /* next object key */ +#define KEY_OPEN (KEY_OFFSET + 0x6e) /* open key */ +#define KEY_OPTIONS (KEY_OFFSET + 0x6f) /* options key */ +#define KEY_PREVIOUS (KEY_OFFSET + 0x70) /* previous object key */ +#define KEY_REDO (KEY_OFFSET + 0x71) /* redo key */ +#define KEY_REFERENCE (KEY_OFFSET + 0x72) /* ref(erence) key */ +#define KEY_REFRESH (KEY_OFFSET + 0x73) /* refresh key */ +#define KEY_REPLACE (KEY_OFFSET + 0x74) /* replace key */ +#define KEY_RESTART (KEY_OFFSET + 0x75) /* restart key */ +#define KEY_RESUME (KEY_OFFSET + 0x76) /* resume key */ +#define KEY_SAVE (KEY_OFFSET + 0x77) /* save key */ +#define KEY_SBEG (KEY_OFFSET + 0x78) /* shifted beginning key */ +#define KEY_SCANCEL (KEY_OFFSET + 0x79) /* shifted cancel key */ +#define KEY_SCOMMAND (KEY_OFFSET + 0x7a) /* shifted command key */ +#define KEY_SCOPY (KEY_OFFSET + 0x7b) /* shifted copy key */ +#define KEY_SCREATE (KEY_OFFSET + 0x7c) /* shifted create key */ +#define KEY_SDC (KEY_OFFSET + 0x7d) /* shifted delete char key */ +#define KEY_SDL (KEY_OFFSET + 0x7e) /* shifted delete line key */ +#define KEY_SELECT (KEY_OFFSET + 0x7f) /* select key */ +#define KEY_SEND (KEY_OFFSET + 0x80) /* shifted end key */ +#define KEY_SEOL (KEY_OFFSET + 0x81) /* shifted clear line key */ +#define KEY_SEXIT (KEY_OFFSET + 0x82) /* shifted exit key */ +#define KEY_SFIND (KEY_OFFSET + 0x83) /* shifted find key */ +#define KEY_SHOME (KEY_OFFSET + 0x84) /* shifted home key */ +#define KEY_SIC (KEY_OFFSET + 0x85) /* shifted input key */ + +#define KEY_SLEFT (KEY_OFFSET + 0x87) /* shifted left arrow key */ +#define KEY_SMESSAGE (KEY_OFFSET + 0x88) /* shifted message key */ +#define KEY_SMOVE (KEY_OFFSET + 0x89) /* shifted move key */ +#define KEY_SNEXT (KEY_OFFSET + 0x8a) /* shifted next key */ +#define KEY_SOPTIONS (KEY_OFFSET + 0x8b) /* shifted options key */ +#define KEY_SPREVIOUS (KEY_OFFSET + 0x8c) /* shifted prev key */ +#define KEY_SPRINT (KEY_OFFSET + 0x8d) /* shifted print key */ +#define KEY_SREDO (KEY_OFFSET + 0x8e) /* shifted redo key */ +#define KEY_SREPLACE (KEY_OFFSET + 0x8f) /* shifted replace key */ +#define KEY_SRIGHT (KEY_OFFSET + 0x90) /* shifted right arrow */ +#define KEY_SRSUME (KEY_OFFSET + 0x91) /* shifted resume key */ +#define KEY_SSAVE (KEY_OFFSET + 0x92) /* shifted save key */ +#define KEY_SSUSPEND (KEY_OFFSET + 0x93) /* shifted suspend key */ +#define KEY_SUNDO (KEY_OFFSET + 0x94) /* shifted undo key */ +#define KEY_SUSPEND (KEY_OFFSET + 0x95) /* suspend key */ +#define KEY_UNDO (KEY_OFFSET + 0x96) /* undo key */ + +/* PDCurses-specific key definitions -- PC only */ + +#define ALT_0 (KEY_OFFSET + 0x97) +#define ALT_1 (KEY_OFFSET + 0x98) +#define ALT_2 (KEY_OFFSET + 0x99) +#define ALT_3 (KEY_OFFSET + 0x9a) +#define ALT_4 (KEY_OFFSET + 0x9b) +#define ALT_5 (KEY_OFFSET + 0x9c) +#define ALT_6 (KEY_OFFSET + 0x9d) +#define ALT_7 (KEY_OFFSET + 0x9e) +#define ALT_8 (KEY_OFFSET + 0x9f) +#define ALT_9 (KEY_OFFSET + 0xa0) +#define ALT_A (KEY_OFFSET + 0xa1) +#define ALT_B (KEY_OFFSET + 0xa2) +#define ALT_C (KEY_OFFSET + 0xa3) +#define ALT_D (KEY_OFFSET + 0xa4) +#define ALT_E (KEY_OFFSET + 0xa5) +#define ALT_F (KEY_OFFSET + 0xa6) +#define ALT_G (KEY_OFFSET + 0xa7) +#define ALT_H (KEY_OFFSET + 0xa8) +#define ALT_I (KEY_OFFSET + 0xa9) +#define ALT_J (KEY_OFFSET + 0xaa) +#define ALT_K (KEY_OFFSET + 0xab) +#define ALT_L (KEY_OFFSET + 0xac) +#define ALT_M (KEY_OFFSET + 0xad) +#define ALT_N (KEY_OFFSET + 0xae) +#define ALT_O (KEY_OFFSET + 0xaf) +#define ALT_P (KEY_OFFSET + 0xb0) +#define ALT_Q (KEY_OFFSET + 0xb1) +#define ALT_R (KEY_OFFSET + 0xb2) +#define ALT_S (KEY_OFFSET + 0xb3) +#define ALT_T (KEY_OFFSET + 0xb4) +#define ALT_U (KEY_OFFSET + 0xb5) +#define ALT_V (KEY_OFFSET + 0xb6) +#define ALT_W (KEY_OFFSET + 0xb7) +#define ALT_X (KEY_OFFSET + 0xb8) +#define ALT_Y (KEY_OFFSET + 0xb9) +#define ALT_Z (KEY_OFFSET + 0xba) + +#define CTL_LEFT (KEY_OFFSET + 0xbb) /* Control-Left-Arrow */ +#define CTL_RIGHT (KEY_OFFSET + 0xbc) +#define CTL_PGUP (KEY_OFFSET + 0xbd) +#define CTL_PGDN (KEY_OFFSET + 0xbe) +#define CTL_HOME (KEY_OFFSET + 0xbf) +#define CTL_END (KEY_OFFSET + 0xc0) + +#define KEY_A1 (KEY_OFFSET + 0xc1) /* upper left on Virtual keypad */ +#define KEY_A2 (KEY_OFFSET + 0xc2) /* upper middle on Virt. keypad */ +#define KEY_A3 (KEY_OFFSET + 0xc3) /* upper right on Vir. keypad */ +#define KEY_B1 (KEY_OFFSET + 0xc4) /* middle left on Virt. keypad */ +#define KEY_B2 (KEY_OFFSET + 0xc5) /* center on Virt. keypad */ +#define KEY_B3 (KEY_OFFSET + 0xc6) /* middle right on Vir. keypad */ +#define KEY_C1 (KEY_OFFSET + 0xc7) /* lower left on Virt. keypad */ +#define KEY_C2 (KEY_OFFSET + 0xc8) /* lower middle on Virt. keypad */ +#define KEY_C3 (KEY_OFFSET + 0xc9) /* lower right on Vir. keypad */ + +#define PADSLASH (KEY_OFFSET + 0xca) /* slash on keypad */ +#define PADENTER (KEY_OFFSET + 0xcb) /* enter on keypad */ +#define CTL_PADENTER (KEY_OFFSET + 0xcc) /* ctl-enter on keypad */ +#define ALT_PADENTER (KEY_OFFSET + 0xcd) /* alt-enter on keypad */ +#define PADSTOP (KEY_OFFSET + 0xce) /* stop on keypad */ +#define PADSTAR (KEY_OFFSET + 0xcf) /* star on keypad */ +#define PADMINUS (KEY_OFFSET + 0xd0) /* minus on keypad */ +#define PADPLUS (KEY_OFFSET + 0xd1) /* plus on keypad */ +#define CTL_PADSTOP (KEY_OFFSET + 0xd2) /* ctl-stop on keypad */ +#define CTL_PADCENTER (KEY_OFFSET + 0xd3) /* ctl-enter on keypad */ +#define CTL_PADPLUS (KEY_OFFSET + 0xd4) /* ctl-plus on keypad */ +#define CTL_PADMINUS (KEY_OFFSET + 0xd5) /* ctl-minus on keypad */ +#define CTL_PADSLASH (KEY_OFFSET + 0xd6) /* ctl-slash on keypad */ +#define CTL_PADSTAR (KEY_OFFSET + 0xd7) /* ctl-star on keypad */ +#define ALT_PADPLUS (KEY_OFFSET + 0xd8) /* alt-plus on keypad */ +#define ALT_PADMINUS (KEY_OFFSET + 0xd9) /* alt-minus on keypad */ +#define ALT_PADSLASH (KEY_OFFSET + 0xda) /* alt-slash on keypad */ +#define ALT_PADSTAR (KEY_OFFSET + 0xdb) /* alt-star on keypad */ +#define ALT_PADSTOP (KEY_OFFSET + 0xdc) /* alt-stop on keypad */ +#define CTL_INS (KEY_OFFSET + 0xdd) /* ctl-insert */ +#define ALT_DEL (KEY_OFFSET + 0xde) /* alt-delete */ +#define ALT_INS (KEY_OFFSET + 0xdf) /* alt-insert */ +#define CTL_UP (KEY_OFFSET + 0xe0) /* ctl-up arrow */ +#define CTL_DOWN (KEY_OFFSET + 0xe1) /* ctl-down arrow */ +#define CTL_TAB (KEY_OFFSET + 0xe2) /* ctl-tab */ +#define ALT_TAB (KEY_OFFSET + 0xe3) +#define ALT_MINUS (KEY_OFFSET + 0xe4) +#define ALT_EQUAL (KEY_OFFSET + 0xe5) +#define ALT_HOME (KEY_OFFSET + 0xe6) +#define ALT_PGUP (KEY_OFFSET + 0xe7) +#define ALT_PGDN (KEY_OFFSET + 0xe8) +#define ALT_END (KEY_OFFSET + 0xe9) +#define ALT_UP (KEY_OFFSET + 0xea) /* alt-up arrow */ +#define ALT_DOWN (KEY_OFFSET + 0xeb) /* alt-down arrow */ +#define ALT_RIGHT (KEY_OFFSET + 0xec) /* alt-right arrow */ +#define ALT_LEFT (KEY_OFFSET + 0xed) /* alt-left arrow */ +#define ALT_ENTER (KEY_OFFSET + 0xee) /* alt-enter */ +#define ALT_ESC (KEY_OFFSET + 0xef) /* alt-escape */ +#define ALT_BQUOTE (KEY_OFFSET + 0xf0) /* alt-back quote */ +#define ALT_LBRACKET (KEY_OFFSET + 0xf1) /* alt-left bracket */ +#define ALT_RBRACKET (KEY_OFFSET + 0xf2) /* alt-right bracket */ +#define ALT_SEMICOLON (KEY_OFFSET + 0xf3) /* alt-semi-colon */ +#define ALT_FQUOTE (KEY_OFFSET + 0xf4) /* alt-forward quote */ +#define ALT_COMMA (KEY_OFFSET + 0xf5) /* alt-comma */ +#define ALT_STOP (KEY_OFFSET + 0xf6) /* alt-stop */ +#define ALT_FSLASH (KEY_OFFSET + 0xf7) /* alt-forward slash */ +#define ALT_BKSP (KEY_OFFSET + 0xf8) /* alt-backspace */ +#define CTL_BKSP (KEY_OFFSET + 0xf9) /* ctl-backspace */ +#define PAD0 (KEY_OFFSET + 0xfa) /* keypad 0 */ + +#define CTL_PAD0 (KEY_OFFSET + 0xfb) /* ctl-keypad 0 */ +#define CTL_PAD1 (KEY_OFFSET + 0xfc) +#define CTL_PAD2 (KEY_OFFSET + 0xfd) +#define CTL_PAD3 (KEY_OFFSET + 0xfe) +#define CTL_PAD4 (KEY_OFFSET + 0xff) +#define CTL_PAD5 (KEY_OFFSET + 0x100) +#define CTL_PAD6 (KEY_OFFSET + 0x101) +#define CTL_PAD7 (KEY_OFFSET + 0x102) +#define CTL_PAD8 (KEY_OFFSET + 0x103) +#define CTL_PAD9 (KEY_OFFSET + 0x104) + +#define ALT_PAD0 (KEY_OFFSET + 0x105) /* alt-keypad 0 */ +#define ALT_PAD1 (KEY_OFFSET + 0x106) +#define ALT_PAD2 (KEY_OFFSET + 0x107) +#define ALT_PAD3 (KEY_OFFSET + 0x108) +#define ALT_PAD4 (KEY_OFFSET + 0x109) +#define ALT_PAD5 (KEY_OFFSET + 0x10a) +#define ALT_PAD6 (KEY_OFFSET + 0x10b) +#define ALT_PAD7 (KEY_OFFSET + 0x10c) +#define ALT_PAD8 (KEY_OFFSET + 0x10d) +#define ALT_PAD9 (KEY_OFFSET + 0x10e) + +#define CTL_DEL (KEY_OFFSET + 0x10f) /* clt-delete */ +#define ALT_BSLASH (KEY_OFFSET + 0x110) /* alt-back slash */ +#define CTL_ENTER (KEY_OFFSET + 0x111) /* ctl-enter */ + +#define SHF_PADENTER (KEY_OFFSET + 0x112) /* shift-enter on keypad */ +#define SHF_PADSLASH (KEY_OFFSET + 0x113) /* shift-slash on keypad */ +#define SHF_PADSTAR (KEY_OFFSET + 0x114) /* shift-star on keypad */ +#define SHF_PADPLUS (KEY_OFFSET + 0x115) /* shift-plus on keypad */ +#define SHF_PADMINUS (KEY_OFFSET + 0x116) /* shift-minus on keypad */ +#define SHF_UP (KEY_OFFSET + 0x117) /* shift-up on keypad */ +#define SHF_DOWN (KEY_OFFSET + 0x118) /* shift-down on keypad */ +#define SHF_IC (KEY_OFFSET + 0x119) /* shift-insert on keypad */ +#define SHF_DC (KEY_OFFSET + 0x11a) /* shift-delete on keypad */ + +#define KEY_MOUSE (KEY_OFFSET + 0x11b) /* "mouse" key */ +#define KEY_SHIFT_L (KEY_OFFSET + 0x11c) /* Left-shift */ +#define KEY_SHIFT_R (KEY_OFFSET + 0x11d) /* Right-shift */ +#define KEY_CONTROL_L (KEY_OFFSET + 0x11e) /* Left-control */ +#define KEY_CONTROL_R (KEY_OFFSET + 0x11f) /* Right-control */ +#define KEY_ALT_L (KEY_OFFSET + 0x120) /* Left-alt */ +#define KEY_ALT_R (KEY_OFFSET + 0x121) /* Right-alt */ +#define KEY_RESIZE (KEY_OFFSET + 0x122) /* Window resize */ +#define KEY_SUP (KEY_OFFSET + 0x123) /* Shifted up arrow */ +#define KEY_SDOWN (KEY_OFFSET + 0x124) /* Shifted down arrow */ + + /* The following were added 2011 Sep 14, and are */ + /* not returned by most flavors of PDCurses: */ + +#define CTL_SEMICOLON (KEY_OFFSET + 0x125) +#define CTL_EQUAL (KEY_OFFSET + 0x126) +#define CTL_COMMA (KEY_OFFSET + 0x127) +#define CTL_MINUS (KEY_OFFSET + 0x128) +#define CTL_STOP (KEY_OFFSET + 0x129) +#define CTL_FSLASH (KEY_OFFSET + 0x12a) +#define CTL_BQUOTE (KEY_OFFSET + 0x12b) + +#define KEY_APPS (KEY_OFFSET + 0x12c) +#define KEY_SAPPS (KEY_OFFSET + 0x12d) +#define CTL_APPS (KEY_OFFSET + 0x12e) +#define ALT_APPS (KEY_OFFSET + 0x12f) + +#define KEY_PAUSE (KEY_OFFSET + 0x130) +#define KEY_SPAUSE (KEY_OFFSET + 0x131) +#define CTL_PAUSE (KEY_OFFSET + 0x132) + +#define KEY_PRINTSCREEN (KEY_OFFSET + 0x133) +#define ALT_PRINTSCREEN (KEY_OFFSET + 0x134) +#define KEY_SCROLLLOCK (KEY_OFFSET + 0x135) +#define ALT_SCROLLLOCK (KEY_OFFSET + 0x136) + +#define CTL_0 (KEY_OFFSET + 0x137) +#define CTL_1 (KEY_OFFSET + 0x138) +#define CTL_2 (KEY_OFFSET + 0x139) +#define CTL_3 (KEY_OFFSET + 0x13a) +#define CTL_4 (KEY_OFFSET + 0x13b) +#define CTL_5 (KEY_OFFSET + 0x13c) +#define CTL_6 (KEY_OFFSET + 0x13d) +#define CTL_7 (KEY_OFFSET + 0x13e) +#define CTL_8 (KEY_OFFSET + 0x13f) +#define CTL_9 (KEY_OFFSET + 0x140) + +#define KEY_BROWSER_BACK (KEY_OFFSET + 0x141) +#define KEY_SBROWSER_BACK (KEY_OFFSET + 0x142) +#define KEY_CBROWSER_BACK (KEY_OFFSET + 0x143) +#define KEY_ABROWSER_BACK (KEY_OFFSET + 0x144) +#define KEY_BROWSER_FWD (KEY_OFFSET + 0x145) +#define KEY_SBROWSER_FWD (KEY_OFFSET + 0x146) +#define KEY_CBROWSER_FWD (KEY_OFFSET + 0x147) +#define KEY_ABROWSER_FWD (KEY_OFFSET + 0x148) +#define KEY_BROWSER_REF (KEY_OFFSET + 0x149) +#define KEY_SBROWSER_REF (KEY_OFFSET + 0x14A) +#define KEY_CBROWSER_REF (KEY_OFFSET + 0x14B) +#define KEY_ABROWSER_REF (KEY_OFFSET + 0x14C) +#define KEY_BROWSER_STOP (KEY_OFFSET + 0x14D) +#define KEY_SBROWSER_STOP (KEY_OFFSET + 0x14E) +#define KEY_CBROWSER_STOP (KEY_OFFSET + 0x14F) +#define KEY_ABROWSER_STOP (KEY_OFFSET + 0x150) +#define KEY_SEARCH (KEY_OFFSET + 0x151) +#define KEY_SSEARCH (KEY_OFFSET + 0x152) +#define KEY_CSEARCH (KEY_OFFSET + 0x153) +#define KEY_ASEARCH (KEY_OFFSET + 0x154) +#define KEY_FAVORITES (KEY_OFFSET + 0x155) +#define KEY_SFAVORITES (KEY_OFFSET + 0x156) +#define KEY_CFAVORITES (KEY_OFFSET + 0x157) +#define KEY_AFAVORITES (KEY_OFFSET + 0x158) +#define KEY_BROWSER_HOME (KEY_OFFSET + 0x159) +#define KEY_SBROWSER_HOME (KEY_OFFSET + 0x15A) +#define KEY_CBROWSER_HOME (KEY_OFFSET + 0x15B) +#define KEY_ABROWSER_HOME (KEY_OFFSET + 0x15C) +#define KEY_VOLUME_MUTE (KEY_OFFSET + 0x15D) +#define KEY_SVOLUME_MUTE (KEY_OFFSET + 0x15E) +#define KEY_CVOLUME_MUTE (KEY_OFFSET + 0x15F) +#define KEY_AVOLUME_MUTE (KEY_OFFSET + 0x160) +#define KEY_VOLUME_DOWN (KEY_OFFSET + 0x161) +#define KEY_SVOLUME_DOWN (KEY_OFFSET + 0x162) +#define KEY_CVOLUME_DOWN (KEY_OFFSET + 0x163) +#define KEY_AVOLUME_DOWN (KEY_OFFSET + 0x164) +#define KEY_VOLUME_UP (KEY_OFFSET + 0x165) +#define KEY_SVOLUME_UP (KEY_OFFSET + 0x166) +#define KEY_CVOLUME_UP (KEY_OFFSET + 0x167) +#define KEY_AVOLUME_UP (KEY_OFFSET + 0x168) +#define KEY_NEXT_TRACK (KEY_OFFSET + 0x169) +#define KEY_SNEXT_TRACK (KEY_OFFSET + 0x16A) +#define KEY_CNEXT_TRACK (KEY_OFFSET + 0x16B) +#define KEY_ANEXT_TRACK (KEY_OFFSET + 0x16C) +#define KEY_PREV_TRACK (KEY_OFFSET + 0x16D) +#define KEY_SPREV_TRACK (KEY_OFFSET + 0x16E) +#define KEY_CPREV_TRACK (KEY_OFFSET + 0x16F) +#define KEY_APREV_TRACK (KEY_OFFSET + 0x170) +#define KEY_MEDIA_STOP (KEY_OFFSET + 0x171) +#define KEY_SMEDIA_STOP (KEY_OFFSET + 0x172) +#define KEY_CMEDIA_STOP (KEY_OFFSET + 0x173) +#define KEY_AMEDIA_STOP (KEY_OFFSET + 0x174) +#define KEY_PLAY_PAUSE (KEY_OFFSET + 0x175) +#define KEY_SPLAY_PAUSE (KEY_OFFSET + 0x176) +#define KEY_CPLAY_PAUSE (KEY_OFFSET + 0x177) +#define KEY_APLAY_PAUSE (KEY_OFFSET + 0x178) +#define KEY_LAUNCH_MAIL (KEY_OFFSET + 0x179) +#define KEY_SLAUNCH_MAIL (KEY_OFFSET + 0x17A) +#define KEY_CLAUNCH_MAIL (KEY_OFFSET + 0x17B) +#define KEY_ALAUNCH_MAIL (KEY_OFFSET + 0x17C) +#define KEY_MEDIA_SELECT (KEY_OFFSET + 0x17D) +#define KEY_SMEDIA_SELECT (KEY_OFFSET + 0x17E) +#define KEY_CMEDIA_SELECT (KEY_OFFSET + 0x17F) +#define KEY_AMEDIA_SELECT (KEY_OFFSET + 0x180) +#define KEY_LAUNCH_APP1 (KEY_OFFSET + 0x181) +#define KEY_SLAUNCH_APP1 (KEY_OFFSET + 0x182) +#define KEY_CLAUNCH_APP1 (KEY_OFFSET + 0x183) +#define KEY_ALAUNCH_APP1 (KEY_OFFSET + 0x184) +#define KEY_LAUNCH_APP2 (KEY_OFFSET + 0x185) +#define KEY_SLAUNCH_APP2 (KEY_OFFSET + 0x186) +#define KEY_CLAUNCH_APP2 (KEY_OFFSET + 0x187) +#define KEY_ALAUNCH_APP2 (KEY_OFFSET + 0x188) + +#define KEY_MIN KEY_BREAK /* Minimum curses key value */ +#define KEY_MAX KEY_ALAUNCH_APP2 /* Maximum curses key */ + +#define KEY_F(n) (KEY_F0 + (n)) + +/*---------------------------------------------------------------------- + * + * PDCurses Function Declarations + * + */ + +/* Standard */ + +PDCEX int addch(const chtype); +PDCEX int addchnstr(const chtype *, int); +PDCEX int addchstr(const chtype *); +PDCEX int addnstr(const char *, int); +PDCEX int addstr(const char *); +PDCEX int attroff(chtype); +PDCEX int attron(chtype); +PDCEX int attrset(chtype); +PDCEX int attr_get(attr_t *, short *, void *); +PDCEX int attr_off(attr_t, void *); +PDCEX int attr_on(attr_t, void *); +PDCEX int attr_set(attr_t, short, void *); +PDCEX int baudrate(void); +PDCEX int beep(void); +PDCEX int bkgd(chtype); +PDCEX void bkgdset(chtype); +PDCEX int border(chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int box(WINDOW *, chtype, chtype); +PDCEX bool can_change_color(void); +PDCEX int cbreak(void); +PDCEX int chgat(int, attr_t, short, const void *); +PDCEX int clearok(WINDOW *, bool); +PDCEX int clear(void); +PDCEX int clrtobot(void); +PDCEX int clrtoeol(void); +PDCEX int color_content(short, short *, short *, short *); +PDCEX int color_set(short, void *); +PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int, + int, int, int, int); +PDCEX int curs_set(int); +PDCEX int def_prog_mode(void); +PDCEX int def_shell_mode(void); +PDCEX int delay_output(int); +PDCEX int delch(void); +PDCEX int deleteln(void); +PDCEX void delscreen(SCREEN *); +PDCEX int delwin(WINDOW *); +PDCEX WINDOW *derwin(WINDOW *, int, int, int, int); +PDCEX int doupdate(void); +PDCEX WINDOW *dupwin(WINDOW *); +PDCEX int echochar(const chtype); +PDCEX int echo(void); +PDCEX int endwin(void); +PDCEX char erasechar(void); +PDCEX int erase(void); +PDCEX void filter(void); +PDCEX int flash(void); +PDCEX int flushinp(void); +PDCEX chtype getbkgd(WINDOW *); +PDCEX int getnstr(char *, int); +PDCEX int getstr(char *); +PDCEX WINDOW *getwin(FILE *); +PDCEX int halfdelay(int); +PDCEX bool has_colors(void); +PDCEX bool has_ic(void); +PDCEX bool has_il(void); +PDCEX int hline(chtype, int); +PDCEX void idcok(WINDOW *, bool); +PDCEX int idlok(WINDOW *, bool); +PDCEX void immedok(WINDOW *, bool); +PDCEX int inchnstr(chtype *, int); +PDCEX int inchstr(chtype *); +PDCEX chtype inch(void); +PDCEX int init_color(short, short, short, short); +PDCEX int init_pair(short, short, short); +PDCEX WINDOW *initscr(void); +PDCEX int innstr(char *, int); +PDCEX int insch(chtype); +PDCEX int insdelln(int); +PDCEX int insertln(void); +PDCEX int insnstr(const char *, int); +PDCEX int insstr(const char *); +PDCEX int instr(char *); +PDCEX int intrflush(WINDOW *, bool); +PDCEX bool isendwin(void); +PDCEX bool is_linetouched(WINDOW *, int); +PDCEX bool is_wintouched(WINDOW *); +PDCEX char *keyname(int); +PDCEX int keypad(WINDOW *, bool); +PDCEX char killchar(void); +PDCEX int leaveok(WINDOW *, bool); +PDCEX char *longname(void); +PDCEX int meta(WINDOW *, bool); +PDCEX int move(int, int); +PDCEX int mvaddch(int, int, const chtype); +PDCEX int mvaddchnstr(int, int, const chtype *, int); +PDCEX int mvaddchstr(int, int, const chtype *); +PDCEX int mvaddnstr(int, int, const char *, int); +PDCEX int mvaddstr(int, int, const char *); +PDCEX int mvchgat(int, int, int, attr_t, short, const void *); +PDCEX int mvcur(int, int, int, int); +PDCEX int mvdelch(int, int); +PDCEX int mvderwin(WINDOW *, int, int); +PDCEX int mvgetch(int, int); +PDCEX int mvgetnstr(int, int, char *, int); +PDCEX int mvgetstr(int, int, char *); +PDCEX int mvhline(int, int, chtype, int); +PDCEX chtype mvinch(int, int); +PDCEX int mvinchnstr(int, int, chtype *, int); +PDCEX int mvinchstr(int, int, chtype *); +PDCEX int mvinnstr(int, int, char *, int); +PDCEX int mvinsch(int, int, chtype); +PDCEX int mvinsnstr(int, int, const char *, int); +PDCEX int mvinsstr(int, int, const char *); +PDCEX int mvinstr(int, int, char *); +PDCEX int mvprintw(int, int, const char *, ...); +PDCEX int mvscanw(int, int, const char *, ...); +PDCEX int mvvline(int, int, chtype, int); +PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); +PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *); +PDCEX int mvwaddch(WINDOW *, int, int, const chtype); +PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwaddstr(WINDOW *, int, int, const char *); +PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); +PDCEX int mvwdelch(WINDOW *, int, int); +PDCEX int mvwgetch(WINDOW *, int, int); +PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwgetstr(WINDOW *, int, int, char *); +PDCEX int mvwhline(WINDOW *, int, int, chtype, int); +PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int); +PDCEX int mvwinchstr(WINDOW *, int, int, chtype *); +PDCEX chtype mvwinch(WINDOW *, int, int); +PDCEX int mvwinnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwinsch(WINDOW *, int, int, chtype); +PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwinsstr(WINDOW *, int, int, const char *); +PDCEX int mvwinstr(WINDOW *, int, int, char *); +PDCEX int mvwin(WINDOW *, int, int); +PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwvline(WINDOW *, int, int, chtype, int); +PDCEX int napms(int); +PDCEX WINDOW *newpad(int, int); +PDCEX SCREEN *newterm(const char *, FILE *, FILE *); +PDCEX WINDOW *newwin(int, int, int, int); +PDCEX int nl(void); +PDCEX int nocbreak(void); +PDCEX int nodelay(WINDOW *, bool); +PDCEX int noecho(void); +PDCEX int nonl(void); +PDCEX void noqiflush(void); +PDCEX int noraw(void); +PDCEX int notimeout(WINDOW *, bool); +PDCEX int overlay(const WINDOW *, WINDOW *); +PDCEX int overwrite(const WINDOW *, WINDOW *); +PDCEX int pair_content(short, short *, short *); +PDCEX int pechochar(WINDOW *, chtype); +PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int prefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int printw(const char *, ...); +PDCEX int putwin(WINDOW *, FILE *); +PDCEX void qiflush(void); +PDCEX int raw(void); +PDCEX int redrawwin(WINDOW *); +PDCEX int refresh(void); +PDCEX int reset_prog_mode(void); +PDCEX int reset_shell_mode(void); +PDCEX int resetty(void); +PDCEX int ripoffline(int, int (*)(WINDOW *, int)); +PDCEX int savetty(void); +PDCEX int scanw(const char *, ...); +PDCEX int scr_dump(const char *); +PDCEX int scr_init(const char *); +PDCEX int scr_restore(const char *); +PDCEX int scr_set(const char *); +PDCEX int scrl(int); +PDCEX int scroll(WINDOW *); +PDCEX int scrollok(WINDOW *, bool); +PDCEX SCREEN *set_term(SCREEN *); +PDCEX int setscrreg(int, int); +PDCEX int slk_attroff(const chtype); +PDCEX int slk_attr_off(const attr_t, void *); +PDCEX int slk_attron(const chtype); +PDCEX int slk_attr_on(const attr_t, void *); +PDCEX int slk_attrset(const chtype); +PDCEX int slk_attr_set(const attr_t, short, void *); +PDCEX int slk_clear(void); +PDCEX int slk_color(short); +PDCEX int slk_init(int); +PDCEX char *slk_label(int); +PDCEX int slk_noutrefresh(void); +PDCEX int slk_refresh(void); +PDCEX int slk_restore(void); +PDCEX int slk_set(int, const char *, int); +PDCEX int slk_touch(void); +PDCEX int standend(void); +PDCEX int standout(void); +PDCEX int start_color(void); +PDCEX WINDOW *subpad(WINDOW *, int, int, int, int); +PDCEX WINDOW *subwin(WINDOW *, int, int, int, int); +PDCEX int syncok(WINDOW *, bool); +PDCEX chtype termattrs(void); +PDCEX attr_t term_attrs(void); +PDCEX char *termname(void); +PDCEX void timeout(int); +PDCEX int touchline(WINDOW *, int, int); +PDCEX int touchwin(WINDOW *); +PDCEX int typeahead(int); +PDCEX int untouchwin(WINDOW *); +PDCEX void use_env(bool); +PDCEX int vidattr(chtype); +PDCEX int vid_attr(attr_t, short, void *); +PDCEX int vidputs(chtype, int (*)(int)); +PDCEX int vid_puts(attr_t, short, void *, int (*)(int)); +PDCEX int vline(chtype, int); +PDCEX int vw_printw(WINDOW *, const char *, va_list); +PDCEX int vwprintw(WINDOW *, const char *, va_list); +PDCEX int vw_scanw(WINDOW *, const char *, va_list); +PDCEX int vwscanw(WINDOW *, const char *, va_list); +PDCEX int waddchnstr(WINDOW *, const chtype *, int); +PDCEX int waddchstr(WINDOW *, const chtype *); +PDCEX int waddch(WINDOW *, const chtype); +PDCEX int waddnstr(WINDOW *, const char *, int); +PDCEX int waddstr(WINDOW *, const char *); +PDCEX int wattroff(WINDOW *, chtype); +PDCEX int wattron(WINDOW *, chtype); +PDCEX int wattrset(WINDOW *, chtype); +PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *); +PDCEX int wattr_off(WINDOW *, attr_t, void *); +PDCEX int wattr_on(WINDOW *, attr_t, void *); +PDCEX int wattr_set(WINDOW *, attr_t, short, void *); +PDCEX void wbkgdset(WINDOW *, chtype); +PDCEX int wbkgd(WINDOW *, chtype); +PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *); +PDCEX int wclear(WINDOW *); +PDCEX int wclrtobot(WINDOW *); +PDCEX int wclrtoeol(WINDOW *); +PDCEX int wcolor_set(WINDOW *, short, void *); +PDCEX void wcursyncup(WINDOW *); +PDCEX int wdelch(WINDOW *); +PDCEX int wdeleteln(WINDOW *); +PDCEX int wechochar(WINDOW *, const chtype); +PDCEX int werase(WINDOW *); +PDCEX int wgetch(WINDOW *); +PDCEX int wgetnstr(WINDOW *, char *, int); +PDCEX int wgetstr(WINDOW *, char *); +PDCEX int whline(WINDOW *, chtype, int); +PDCEX int winchnstr(WINDOW *, chtype *, int); +PDCEX int winchstr(WINDOW *, chtype *); +PDCEX chtype winch(WINDOW *); +PDCEX int winnstr(WINDOW *, char *, int); +PDCEX int winsch(WINDOW *, chtype); +PDCEX int winsdelln(WINDOW *, int); +PDCEX int winsertln(WINDOW *); +PDCEX int winsnstr(WINDOW *, const char *, int); +PDCEX int winsstr(WINDOW *, const char *); +PDCEX int winstr(WINDOW *, char *); +PDCEX int wmove(WINDOW *, int, int); +PDCEX int wnoutrefresh(WINDOW *); +PDCEX int wprintw(WINDOW *, const char *, ...); +PDCEX int wredrawln(WINDOW *, int, int); +PDCEX int wrefresh(WINDOW *); +PDCEX int wscanw(WINDOW *, const char *, ...); +PDCEX int wscrl(WINDOW *, int); +PDCEX int wsetscrreg(WINDOW *, int, int); +PDCEX int wstandend(WINDOW *); +PDCEX int wstandout(WINDOW *); +PDCEX void wsyncdown(WINDOW *); +PDCEX void wsyncup(WINDOW *); +PDCEX void wtimeout(WINDOW *, int); +PDCEX int wtouchln(WINDOW *, int, int, int); +PDCEX int wvline(WINDOW *, chtype, int); + +/* Wide-character functions */ + +#ifdef PDC_WIDE +PDCEX int addnwstr(const wchar_t *, int); +PDCEX int addwstr(const wchar_t *); +PDCEX int add_wch(const cchar_t *); +PDCEX int add_wchnstr(const cchar_t *, int); +PDCEX int add_wchstr(const cchar_t *); +PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *); +PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *); +PDCEX int echo_wchar(const cchar_t *); +PDCEX int erasewchar(wchar_t *); +PDCEX int getbkgrnd(cchar_t *); +PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); +PDCEX int getn_wstr(wint_t *, int); +PDCEX int get_wch(wint_t *); +PDCEX int get_wstr(wint_t *); +PDCEX int hline_set(const cchar_t *, int); +PDCEX int innwstr(wchar_t *, int); +PDCEX int ins_nwstr(const wchar_t *, int); +PDCEX int ins_wch(const cchar_t *); +PDCEX int ins_wstr(const wchar_t *); +PDCEX int inwstr(wchar_t *); +PDCEX int in_wch(cchar_t *); +PDCEX int in_wchnstr(cchar_t *, int); +PDCEX int in_wchstr(cchar_t *); +PDCEX char *key_name(wchar_t); +PDCEX int killwchar(wchar_t *); +PDCEX int mvaddnwstr(int, int, const wchar_t *, int); +PDCEX int mvaddwstr(int, int, const wchar_t *); +PDCEX int mvadd_wch(int, int, const cchar_t *); +PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int); +PDCEX int mvadd_wchstr(int, int, const cchar_t *); +PDCEX int mvgetn_wstr(int, int, wint_t *, int); +PDCEX int mvget_wch(int, int, wint_t *); +PDCEX int mvget_wstr(int, int, wint_t *); +PDCEX int mvhline_set(int, int, const cchar_t *, int); +PDCEX int mvinnwstr(int, int, wchar_t *, int); +PDCEX int mvins_nwstr(int, int, const wchar_t *, int); +PDCEX int mvins_wch(int, int, const cchar_t *); +PDCEX int mvins_wstr(int, int, const wchar_t *); +PDCEX int mvinwstr(int, int, wchar_t *); +PDCEX int mvin_wch(int, int, cchar_t *); +PDCEX int mvin_wchnstr(int, int, cchar_t *, int); +PDCEX int mvin_wchstr(int, int, cchar_t *); +PDCEX int mvvline_set(int, int, const cchar_t *, int); +PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int); +PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *); +PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *); +PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); +PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *); +PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); +PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *); +PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *); +PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int pecho_wchar(WINDOW *, const cchar_t*); +PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t, + short, const void*); +PDCEX int slk_wset(int, const wchar_t *, int); +PDCEX int unget_wch(const wchar_t); +PDCEX int vline_set(const cchar_t *, int); +PDCEX int waddnwstr(WINDOW *, const wchar_t *, int); +PDCEX int waddwstr(WINDOW *, const wchar_t *); +PDCEX int wadd_wch(WINDOW *, const cchar_t *); +PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int); +PDCEX int wadd_wchstr(WINDOW *, const cchar_t *); +PDCEX int wbkgrnd(WINDOW *, const cchar_t *); +PDCEX void wbkgrndset(WINDOW *, const cchar_t *); +PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *); +PDCEX int wecho_wchar(WINDOW *, const cchar_t *); +PDCEX int wgetbkgrnd(WINDOW *, cchar_t *); +PDCEX int wgetn_wstr(WINDOW *, wint_t *, int); +PDCEX int wget_wch(WINDOW *, wint_t *); +PDCEX int wget_wstr(WINDOW *, wint_t *); +PDCEX int whline_set(WINDOW *, const cchar_t *, int); +PDCEX int winnwstr(WINDOW *, wchar_t *, int); +PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int); +PDCEX int wins_wch(WINDOW *, const cchar_t *); +PDCEX int wins_wstr(WINDOW *, const wchar_t *); +PDCEX int winwstr(WINDOW *, wchar_t *); +PDCEX int win_wch(WINDOW *, cchar_t *); +PDCEX int win_wchnstr(WINDOW *, cchar_t *, int); +PDCEX int win_wchstr(WINDOW *, cchar_t *); +PDCEX wchar_t *wunctrl(cchar_t *); +PDCEX int wvline_set(WINDOW *, const cchar_t *, int); +#endif + +/* Quasi-standard */ + +PDCEX chtype getattrs(WINDOW *); +PDCEX int getbegx(WINDOW *); +PDCEX int getbegy(WINDOW *); +PDCEX int getmaxx(WINDOW *); +PDCEX int getmaxy(WINDOW *); +PDCEX int getparx(WINDOW *); +PDCEX int getpary(WINDOW *); +PDCEX int getcurx(WINDOW *); +PDCEX int getcury(WINDOW *); +PDCEX void traceoff(void); +PDCEX void traceon(void); +PDCEX char *unctrl(chtype); + +PDCEX int crmode(void); +PDCEX int nocrmode(void); +PDCEX int draino(int); +PDCEX int resetterm(void); +PDCEX int fixterm(void); +PDCEX int saveterm(void); +PDCEX void setsyx(int, int); + +PDCEX int mouse_set(unsigned long); +PDCEX int mouse_on(unsigned long); +PDCEX int mouse_off(unsigned long); +PDCEX int request_mouse_pos(void); +PDCEX int map_button(unsigned long); +PDCEX void wmouse_position(WINDOW *, int *, int *); +PDCEX unsigned long getmouse(void); +PDCEX unsigned long getbmap(void); + +/* ncurses */ + +PDCEX int assume_default_colors(int, int); +PDCEX const char *curses_version(void); +PDCEX bool has_key(int); +PDCEX int use_default_colors(void); +PDCEX int wresize(WINDOW *, int, int); + +PDCEX int mouseinterval(int); +PDCEX mmask_t mousemask(mmask_t, mmask_t *); +PDCEX bool mouse_trafo(int *, int *, bool); +PDCEX int nc_getmouse(MEVENT *); +PDCEX int ungetmouse(MEVENT *); +PDCEX bool wenclose(const WINDOW *, int, int); +PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool); + +/* PDCurses */ + +PDCEX int addrawch(chtype); +PDCEX int insrawch(chtype); +PDCEX bool is_termresized(void); +PDCEX int mvaddrawch(int, int, chtype); +PDCEX int mvdeleteln(int, int); +PDCEX int mvinsertln(int, int); +PDCEX int mvinsrawch(int, int, chtype); +PDCEX int mvwaddrawch(WINDOW *, int, int, chtype); +PDCEX int mvwdeleteln(WINDOW *, int, int); +PDCEX int mvwinsertln(WINDOW *, int, int); +PDCEX int mvwinsrawch(WINDOW *, int, int, chtype); +PDCEX int raw_output(bool); +PDCEX int resize_term(int, int); +PDCEX WINDOW *resize_window(WINDOW *, int, int); +PDCEX int waddrawch(WINDOW *, chtype); +PDCEX int winsrawch(WINDOW *, chtype); +PDCEX char wordchar(void); + +#ifdef PDC_WIDE +PDCEX wchar_t *slk_wlabel(int); +#endif + +PDCEX void PDC_debug(const char *, ...); +PDCEX int PDC_ungetch(int); +PDCEX int PDC_set_blink(bool); +PDCEX int PDC_set_line_color(short); +PDCEX void PDC_set_title(const char *); + +PDCEX int PDC_clearclipboard(void); +PDCEX int PDC_freeclipboard(char *); +PDCEX int PDC_getclipboard(char **, long *); +PDCEX int PDC_setclipboard(const char *, long); + +PDCEX unsigned long PDC_get_input_fd(void); +PDCEX unsigned long PDC_get_key_modifiers(void); +PDCEX int PDC_return_key_modifiers(bool); +PDCEX int PDC_save_key_modifiers(bool); +PDCEX void PDC_set_resize_limits( const int new_min_lines, + const int new_max_lines, + const int new_min_cols, + const int new_max_cols); + +#define FUNCTION_KEY_SHUT_DOWN 0 +#define FUNCTION_KEY_PASTE 1 +#define FUNCTION_KEY_ENLARGE_FONT 2 +#define FUNCTION_KEY_SHRINK_FONT 3 +#define FUNCTION_KEY_CHOOSE_FONT 4 +#define FUNCTION_KEY_ABORT 5 +#define PDC_MAX_FUNCTION_KEYS 6 + +PDCEX int PDC_set_function_key( const unsigned function, + const int new_key); + +PDCEX WINDOW *Xinitscr(int, char **); +#ifdef XCURSES +PDCEX void XCursesExit(void); +PDCEX int sb_init(void); +PDCEX int sb_set_horz(int, int, int); +PDCEX int sb_set_vert(int, int, int); +PDCEX int sb_get_horz(int *, int *, int *); +PDCEX int sb_get_vert(int *, int *, int *); +PDCEX int sb_refresh(void); + #endif + +/*** Functions defined as macros ***/ + +/* getch() and ungetch() conflict with some DOS libraries */ + +#define getch() wgetch(stdscr) +#define ungetch(ch) PDC_ungetch(ch) + +#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) +#define PAIR_NUMBER(n) ((((n) & A_COLOR) >> PDC_COLOR_SHIFT) & 0xff) + +/* These will _only_ work as macros */ + +#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w)) +#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) +#define getparyx(w, y, x) (y = getpary(w), x = getparx(w)) +#define getyx(w, y, x) (y = getcury(w), x = getcurx(w)) + +#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \ + else getyx(curscr,(y),(x)); } + +#ifdef NCURSES_MOUSE_VERSION +# define getmouse(x) nc_getmouse(x) +#endif + +/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ + +#define PDC_CLIP_SUCCESS 0 +#define PDC_CLIP_ACCESS_ERROR 1 +#define PDC_CLIP_EMPTY 2 +#define PDC_CLIP_MEMORY_ERROR 3 + +/* PDCurses key modifier masks */ + +#define PDC_KEY_MODIFIER_SHIFT 1 +#define PDC_KEY_MODIFIER_CONTROL 2 +#define PDC_KEY_MODIFIER_ALT 4 +#define PDC_KEY_MODIFIER_NUMLOCK 8 +#define PDC_KEY_MODIFIER_REPEAT 16 + +#ifdef __cplusplus +# undef bool +} +#endif + +#endif /* __PDCURSES__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h new file mode 100644 index 000000000..b5edcc173 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h @@ -0,0 +1,134 @@ +/* Public Domain Curses */ + +/* Private definitions and declarations for use within PDCurses. + These should generally not be referenced by applications. */ + +#ifndef __CURSES_INTERNALS__ +#define __CURSES_INTERNALS__ 1 + +#define CURSES_LIBRARY +#include + +#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \ + defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__WATCOMC__) || defined(__PACIFIC__) +# ifndef HAVE_VSSCANF +# define HAVE_VSSCANF /* have vsscanf() */ +# endif +#endif + +#if defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__LCC__) || defined(__WATCOMC__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF /* have vsnprintf() */ +# endif +#endif + +#if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ +#endif + +/*----------------------------------------------------------------------*/ + +typedef struct /* structure for ripped off lines */ +{ + int line; + int (*init)(WINDOW *, int); +} RIPPEDOFFLINE; + +/* Window properties */ + +#define _SUBWIN 0x01 /* window is a subwindow */ +#define _PAD 0x10 /* X/Open Pad. */ +#define _SUBPAD 0x20 /* X/Open subpad. */ + +/* Miscellaneous */ + +#define _NO_CHANGE -1 /* flags line edge unchanged */ + +#define _ECHAR 0x08 /* Erase char (^H) */ +#define _DWCHAR 0x17 /* Delete Word char (^W) */ +#define _DLCHAR 0x15 /* Delete Line char (^U) */ + +extern WINDOW *pdc_lastscr; +extern FILE *pdc_dbfp; /* tracing file pointer (NULL = off) */ +extern bool pdc_color_started; +extern unsigned long pdc_key_modifiers; +extern MOUSE_STATUS pdc_mouse_status; + +/*----------------------------------------------------------------------*/ + +/* Platform implementation functions */ + +void PDC_beep(void); +bool PDC_can_change_color(void); +int PDC_color_content(short, short *, short *, short *); +bool PDC_check_key(void); +int PDC_curs_set(int); +void PDC_flushinp(void); +int PDC_get_columns(void); +int PDC_get_cursor_mode(void); +int PDC_get_key(void); +int PDC_get_rows(void); +void PDC_gotoyx(int, int); +int PDC_init_color(short, short, short, short); +void PDC_init_pair(short, short, short); +int PDC_modifiers_set(void); +int PDC_mouse_set(void); +void PDC_napms(int); +int PDC_pair_content(short, short *, short *); +void PDC_reset_prog_mode(void); +void PDC_reset_shell_mode(void); +int PDC_resize_screen(int, int); +void PDC_restore_screen_mode(int); +void PDC_save_screen_mode(int); +void PDC_scr_close(void); +void PDC_scr_free(void); +int PDC_scr_open(int, char **); +void PDC_set_keyboard_binary(bool); +void PDC_transform_line(int, int, int, const chtype *); +const char *PDC_sysname(void); + +/* Internal cross-module functions */ + +void PDC_init_atrtab(void); +WINDOW *PDC_makelines(WINDOW *); +WINDOW *PDC_makenew(int, int, int, int); +int PDC_mouse_in_slk(int, int); +void PDC_slk_free(void); +void PDC_slk_initialize(void); +void PDC_sync(WINDOW *); + +#ifdef PDC_WIDE +int PDC_mbtowc(wchar_t *, const char *, size_t); +size_t PDC_mbstowcs(wchar_t *, const char *, size_t); +size_t PDC_wcstombs(char *, const wchar_t *, size_t); +#endif + +#ifdef PDCDEBUG +# define PDC_LOG(x) if (pdc_dbfp) PDC_debug x +#else +# define PDC_LOG(x) +#endif + +/* Internal macros for attributes */ + +#ifdef CHTYPE_LONG +# define PDC_COLOR_PAIRS 256 +#else +# define PDC_COLOR_PAIRS 32 +#endif + +#ifndef max +# define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +# define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define DIVROUND(num, divisor) (((num) + ((divisor) >> 1)) / (divisor)) + +#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if + not set by mouseinterval() */ + +#endif /* __CURSES_INTERNALS__*/ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h new file mode 100644 index 000000000..4de6e853e --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h @@ -0,0 +1,93 @@ +/* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */ +/* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */ +/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _GETOPT_H_ +#define _GETOPT_H_ + +#if 0 +#include +#endif + +/* + * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option { + /* name of long option */ + const char *name; + /* + * one of no_argument, required_argument, and optional_argument: + * whether option takes an argument + */ + int has_arg; + /* if not NULL, set *flag to val when option found */ + int *flag; + /* if flag not NULL, value to set *flag to; else return value */ + int val; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +int getopt_long(int, char * const *, const char *, + const struct option *, int *); +int getopt_long_only(int, char * const *, const char *, + const struct option *, int *); +#ifndef _GETOPT_DEFINED +#define _GETOPT_DEFINED +int getopt(int, char * const *, const char *); +int getsubopt(char **, char * const *, char **); + +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +extern int optreset; +extern char *suboptarg; /* getsubopt(3) external variable */ +#endif /* _GETOPT_DEFINED */ + +#ifdef __cplusplus +} +#endif +#endif /* !_GETOPT_H_ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h new file mode 100644 index 000000000..7f1fb1f17 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h @@ -0,0 +1,56 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * Panels for PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES_PANEL_H__ +#define __PDCURSES_PANEL_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct panelobs +{ + struct panelobs *above; + struct panel *pan; +} PANELOBS; + +typedef struct panel +{ + WINDOW *win; + int wstarty; + int wendy; + int wstartx; + int wendx; + struct panel *below; + struct panel *above; + const void *user; + struct panelobs *obscure; +} PANEL; + +PDCEX int bottom_panel(PANEL *pan); +PDCEX int del_panel(PANEL *pan); +PDCEX int hide_panel(PANEL *pan); +PDCEX int move_panel(PANEL *pan, int starty, int startx); +PDCEX PANEL *new_panel(WINDOW *win); +PDCEX PANEL *panel_above(const PANEL *pan); +PDCEX PANEL *panel_below(const PANEL *pan); +PDCEX int panel_hidden(const PANEL *pan); +PDCEX const void *panel_userptr(const PANEL *pan); +PDCEX WINDOW *panel_window(const PANEL *pan); +PDCEX int replace_panel(PANEL *pan, WINDOW *win); +PDCEX int set_panel_userptr(PANEL *pan, const void *uptr); +PDCEX int show_panel(PANEL *pan); +PDCEX int top_panel(PANEL *pan); +PDCEX void update_panels(void); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_PANEL_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h new file mode 100644 index 000000000..0ba0b7a7f --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h @@ -0,0 +1,48 @@ +/* Public Domain Curses */ + +/* PDCurses doesn't operate with terminfo, but we need these functions for + compatibility, to allow some things (notably, interface libraries for + other languages) to be compiled. Anyone who tries to actually _use_ + them will be disappointed, since they only return ERR. */ + +#ifndef __PDCURSES_TERM_H__ +#define __PDCURSES_TERM_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct +{ + const char *_termname; +} TERMINAL; + +/* PDCEX is defined in curses.h */ +PDCEX TERMINAL *cur_term; + +int del_curterm(TERMINAL *); +int putp(const char *); +int restartterm(const char *, int, int *); +TERMINAL *set_curterm(TERMINAL *); +int setterm(const char *); +int setupterm(const char *, int, int *); +int tgetent(char *, const char *); +int tgetflag(const char *); +int tgetnum(const char *); +char *tgetstr(const char *, char **); +char *tgoto(const char *, int, int); +int tigetflag(const char *); +int tigetnum(const char *); +char *tigetstr(const char *); +char *tparm(const char *, long, long, long, long, long, + long, long, long, long); +int tputs(const char *, int, int (*)(int)); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_TERM_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h new file mode 100644 index 000000000..5d2440309 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h @@ -0,0 +1,56 @@ +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +/* This is intended as a drop-in replacement for unistd.h on Windows. + * Please add functionality as neeeded. + * https://stackoverflow.com/a/826027/1202830 + */ + +#include +#include +#include /* getopt at: https://gist.github.com/ashelly/7776712 */ +#include /* for getpid() and the exec..() family */ +#include /* for _getcwd() and _chdir() */ + +#define srandom srand +#define random rand + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +//#define X_OK 1 /* execute permission - unsupported in windows*/ +#define F_OK 0 /* Test for existence. */ + +#define access _access +#define dup2 _dup2 +#define execve _execve +#define ftruncate _chsize +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define chdir _chdir +#define isatty _isatty +#define lseek _lseek +/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ + +#ifdef _WIN64 +#define ssize_t __int64 +#else +#define ssize_t long +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +/* should be in some equivalent to */ +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#endif /* unistd.h */ \ No newline at end of file diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f765a17b9..5dc970bc8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -321,6 +321,26 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } +void disp_playerdata(std::vector playerdata) +{ + struct rogue_player P; int32_t i; char packitemstr[512]; + if ( playerdata.size() > 0 ) + { + for (i=0; i>16,P.level,P.experience,P.dungeonlevel); + for (i=0; i playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; @@ -487,6 +507,8 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; batonvalue = numkeys = numplayers = batonht = 0; playertxid = batontxid = zeroid; + if ( keystrokesp != 0 ) + *keystrokesp = 0; for (i=0; i 0 ) { @@ -969,6 +991,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto fclose(fp); } } + //fprintf(stderr,"call replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i no playerdata\n"); @@ -1075,17 +1099,14 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C *cashoutp = 0; roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,rogueaddr,roguepk,pk); - //fprintf(stderr,"call extractgame\n"); if ( (keystrokes= rogue_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { - //fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); sprintf(fname,"rogue.%llu.pack",(long long)seed); remove(fname); - //fprintf(stderr,"extracted.(%s)\n",str); - for (i=0; i>16,P.level,P.experience,P.dungeonlevel); fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } @@ -1230,8 +1264,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( P.amulet != 0 ) mult *= 5; dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 21 ) - dungeonlevel = 21; + if ( P.amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel; fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( funcid == 'H' && maxplayers > 1 ) @@ -1465,6 +1499,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); + if ( txid == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 + enabled = 0; scriptPubKey = tx.vout[numvouts-1].scriptPubKey; GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() > 2 ) @@ -1539,29 +1575,32 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("couldnt decode H/Q opret"); } // verify pk belongs to this tx - if ( tokentx == 'c' && playerdata.size() > 0 ) + if ( tokentx == 'c' ) { - static char laststr[512]; char cashstr[512]; - if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) + if ( playerdata.size() > 0 ) { - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + static char laststr[512]; char cashstr[512]; + if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) + { + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } + if ( enabled != 0 ) + return eval->Invalid("mismatched playerdata"); + } + if ( funcid == 'H' ) + cashout *= 2; + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); fprintf(stderr,"%s\n",cashstr); } - if ( enabled != 0 ) - return eval->Invalid("mismatched playerdata"); - } - if ( funcid == 'H' ) - cashout *= 2; - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); - if ( strcmp(laststr,cashstr) != 0 ) - { - strcpy(laststr,cashstr); - fprintf(stderr,"%s\n",cashstr); - } - if ( enabled != 0 && tx.vout[2].nValue != cashout ) + } else cashout = 10000; + if ( enabled != 0 && tx.vout[2].nValue > cashout ) return eval->Invalid("mismatched cashout amount"); } if ( funcid == 'Q' ) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 254c9b135..d6ae473fe 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -858,7 +858,7 @@ int main(int argc, char **argv) next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); - + int32_t counter = 0; // Game loop while (running) { running = tg_tick(tg, move); @@ -866,7 +866,8 @@ int main(int argc, char **argv) display_piece(next, tg->next); display_piece(hold, tg->stored); display_score(score, tg); - doupdate(); + if ( (counter++ % 5) == 0 ) + doupdate(); sleep_milli(10); switch (getch()) { diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5be94dc94..6dac120e4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1655,6 +1655,87 @@ UniValue getmempoolinfo(const UniValue& params, bool fHelp) return mempoolInfoToJSON(); } +inline CBlockIndex* LookupBlockIndex(const uint256& hash) +{ + AssertLockHeld(cs_main); + BlockMap::const_iterator it = mapBlockIndex.find(hash); + return it == mapBlockIndex.end() ? nullptr : it->second; +} + +UniValue getchaintxstats(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "getchaintxstats\n" + "\nCompute statistics about the total number and rate of transactions in the chain.\n" + "\nArguments:\n" + "1. nblocks (numeric, optional) Number of blocks in averaging window.\n" + "2. blockhash (string, optional) The hash of the block which ends the window.\n" + "\nResult:\n" + "{\n" + " \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n" + " \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n" + " \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n" + " \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n" + " \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n" + " \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n" + " \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getchaintxstats", "") + + HelpExampleRpc("getchaintxstats", "2016") + ); + + const CBlockIndex* pindex; + int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month + + if (params[1].isNull()) { + LOCK(cs_main); + pindex = chainActive.Tip(); + } else { + uint256 hash(ParseHashV(params[1], "blockhash")); + LOCK(cs_main); + pindex = LookupBlockIndex(hash); + if (!pindex) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + } + if (!chainActive.Contains(pindex)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block is not in main chain"); + } + } + + assert(pindex != nullptr); + + if (params[0].isNull()) { + blockcount = std::max(0, std::min(blockcount, pindex->GetHeight() - 1)); + } else { + blockcount = params[0].get_int(); + + if (blockcount < 0 || (blockcount > 0 && blockcount >= pindex->GetHeight())) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block count: should be between 0 and the block's height - 1"); + } + } + + const CBlockIndex* pindexPast = pindex->GetAncestor(pindex->GetHeight() - blockcount); + int nTimeDiff = pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast(); + int nTxDiff = pindex->nChainTx - pindexPast->nChainTx; + + UniValue ret(UniValue::VOBJ); + ret.pushKV("time", (int64_t)pindex->nTime); + ret.pushKV("txcount", (int64_t)pindex->nChainTx); + ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex()); + ret.pushKV("window_block_count", blockcount); + if (blockcount > 0) { + ret.pushKV("window_tx_count", nTxDiff); + ret.pushKV("window_interval", nTimeDiff); + if (nTimeDiff > 0) { + ret.pushKV("txrate", ((double)nTxDiff) / nTimeDiff); + } + } + + return ret; +} + UniValue invalidateblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -1742,6 +1823,7 @@ static const CRPCCommand commands[] = { "blockchain", "getblockhash", &getblockhash, true }, { "blockchain", "getblockheader", &getblockheader, true }, { "blockchain", "getchaintips", &getchaintips, true }, + { "blockchain", "getchaintxstats", &getchaintxstats, true }, { "blockchain", "getdifficulty", &getdifficulty, true }, { "blockchain", "getmempoolinfo", &getmempoolinfo, true }, { "blockchain", "getrawmempool", &getrawmempool, true }, diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 3cbde9f10..19910b25c 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -89,6 +89,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listunspent", 2 }, { "getblock", 1 }, { "getblockheader", 1 }, + { "getchaintxstats", 0 }, { "getlastsegidstakes", 0 }, { "gettransaction", 1 }, { "getrawtransaction", 1 }, diff --git a/src/txdb.cpp b/src/txdb.cpp index b798599b7..0588d52de 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -441,7 +441,7 @@ uint32_t komodo_segid32(char *coinaddr); UniValue CBlockTreeDB::Snapshot(int top) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; - int64_t utxos = 0; int64_t ignoredAddresses; + int64_t utxos = 0; int64_t ignoredAddresses = 0; boost::scoped_ptr iter(NewIterator()); std::map addressAmounts; std::vector > vaddr; @@ -491,27 +491,31 @@ UniValue CBlockTreeDB::Snapshot(int top) getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); - std::map ::iterator ignored = ignoredMap.find(address); - if (ignored != ignoredMap.end()) { - fprintf(stderr,"ignoring %s\n", address.c_str()); - ignoredAddresses++; - continue; - } + if (nValue > 0) { + std::map ::iterator ignored = ignoredMap.find(address); + if (ignored != ignoredMap.end()) { + fprintf(stderr,"ignoring %s\n", address.c_str()); + ignoredAddresses++; + continue; + } - std::map ::iterator pos = addressAmounts.find(address); - if (pos == addressAmounts.end()) { - // insert new address + utxo amount - //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); - addressAmounts[address] = nValue; - totalAddresses++; + std::map ::iterator pos = addressAmounts.find(address); + if (pos == addressAmounts.end()) { + // insert new address + utxo amount + //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); + addressAmounts[address] = nValue; + totalAddresses++; + } else { + // update unspent tally for this address + //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); + addressAmounts[address] += nValue; + } + //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); + // total += nValue; + utxos++; } else { - // update unspent tally for this address - //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); - addressAmounts[address] += nValue; + fprintf(stderr,"ignoring amount=0 UTXO for %s\n", address.c_str()); } - //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); - // total += nValue; - utxos++; } catch (const std::exception& e) { fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what()); break; From fc2ae0cbe858e5802c2c422429733993be5d990f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Mar 2019 21:16:19 -1100 Subject: [PATCH 2975/3904] Fix < txfee cashout --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5dc970bc8..cfe108d36 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1279,6 +1279,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } cashout += numplayers * buyin; } + if ( cashout < txfee ) + cashout = txfee; if ( cashout >= txfee ) { if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) From 8f90135f348172c2ff1679a238d7c42446b519ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Mar 2019 21:25:45 -1100 Subject: [PATCH 2976/3904] Set cashout to 0 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cfe108d36..60707c89d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1192,7 +1192,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) From b07507de2e413cccb21e059f9ea14a5d52bbf0e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Mar 2019 21:35:46 -1100 Subject: [PATCH 2977/3904] Dont roundup --- src/cc/rogue_rpc.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 60707c89d..507f60c3f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1279,14 +1279,12 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } cashout += numplayers * buyin; } - if ( cashout < txfee ) - cashout = txfee; - if ( cashout >= txfee ) + if ( cashout > 0 ) { if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) CCchange = (inputsum - cashout); - mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } + mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } } mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); From c9d83ebdb781fedb6169aed98458bfb4350abfbe Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 15 Mar 2019 03:11:05 -1100 Subject: [PATCH 2978/3904] Dont issue change if not big enough --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 507f60c3f..d08ba61c2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1287,7 +1287,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } } - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); + if ( CCchange + (batonvalue-3*txfee) >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); CScript opret; From 89604d821dcbbeebdc39e6180f0fce799b468f1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 15 Mar 2019 03:13:27 -1100 Subject: [PATCH 2979/3904] Calc change properly --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d08ba61c2..2d1a45d33 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1281,7 +1281,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } if ( cashout > 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > cashout ) CCchange = (inputsum - cashout); } mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); From 2a3d132b554e02ba1d3fc3b6413fb05ac18e5c28 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 15 Mar 2019 14:28:39 -0400 Subject: [PATCH 2980/3904] Show foundersreward in getblocktemplate if ac_founders enabled (#1334) --- src/rpc/mining.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 975154cdf..2efe8d694 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -49,6 +49,7 @@ using namespace std; #include "komodo_defs.h" +extern int32_t ASSETCHAINS_FOUNDERS; arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); @@ -785,10 +786,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) if (tx.IsCoinBase() && coinbasetxn == true ) { // Show founders' reward if it is required - //if (pblock->vtx[0].vout.size() > 1) { + if (ASSETCHAINS_FOUNDERS && pblock->vtx[0].vout.size() > 1) { // Correct this if GetBlockTemplate changes the order - // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); - //} + entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); + } CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->GetHeight()+1, Params().GetConsensus()); entry.push_back(Pair("coinbasevalue", nReward)); entry.push_back(Pair("required", true)); From d8d7463ea05274a28a00dc193cfc39c19296ba60 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Mon, 18 Mar 2019 15:22:20 +0800 Subject: [PATCH 2981/3904] Fix sendmany bug for Alright (#1336) * fix sendmany bug, when sending to multiple address diffrent amounts would always use the first seen value. * Possible fix for multi node musig. Needs to be tested. Was getting stuck at nonce stage, as reported by gcharang. --- src/cc/musig.cpp | 4 ++-- src/wallet/rpcwallet.cpp | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 35293088c..bc113bc5c 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -538,7 +538,7 @@ UniValue musig_commit(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i<33; i++) sprintf(&str[i<<1],"%02x",((uint8_t *)pk.begin())[i]); str[66] = 0; - if ( n == 5 ) + if ( n == 3 ) MUSIG[myind]->numnonces = 1; result.push_back(Pair("myind",MUSIG[myind]->myind)); result.push_back(Pair("nonce",str)); @@ -629,7 +629,7 @@ UniValue musig_nonce(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("myind",MUSIG[myind]->myind)); result.push_back(Pair("partialsig",str)); result.push_back(Pair("result","success")); - if ( n == 5 ) + if ( n == 3 ) MUSIG[myind]->numpartials = 1; return(result); } else return(cclib_error(result,"error serializing partial sig")); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 38c21d2bd..471364b91 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1457,24 +1457,19 @@ UniValue sendmany(const UniValue& params, bool fHelp) if (params.size() > 4) subtractFeeFromAmount = params[4].get_array(); - std::set destinations; std::vector vecSend; CAmount totalAmount = 0; std::vector keys = sendTo.getKeys(); + int32_t i = 0; for (const std::string& name_ : keys) { CTxDestination dest = DecodeDestination(name_); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Zcash address: ") + name_); } - /*if (destinations.count(dest)) { - throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_); - }*/ - destinations.insert(dest); - CScript scriptPubKey = GetScriptForDestination(dest); - CAmount nAmount = AmountFromValue(sendTo[name_]); + CAmount nAmount = AmountFromValue(sendTo[i]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); totalAmount += nAmount; @@ -1488,6 +1483,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount}; vecSend.push_back(recipient); + i++; } EnsureWalletIsUnlocked(); From e49b9075803f408b58ac24cc7aeb728dbd315d5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Mar 2019 08:37:25 -1100 Subject: [PATCH 2982/3904] Error print --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2d1a45d33..495fa8774 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1281,8 +1281,9 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } if ( cashout > 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > cashout ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr)) > cashout ) CCchange = (inputsum - cashout); + else fprintf(stderr,"couldnt find enough utxos\n"); } mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } From f58655b1cd2e3c5b8e61138a23d268aa285b6d8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Mar 2019 08:40:47 -1100 Subject: [PATCH 2983/3904] Thresholding --- src/cc/cclib.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c783eb4d0..25cd691c5 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -492,7 +492,9 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); + if ( maxinputs != 0 ) + threshold = total/maxinputs; + else threshold = total; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 0322f2d98cbd0dc2ddabd5cd83dc2a4e8f2c2df8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Mar 2019 01:35:15 -1100 Subject: [PATCH 2984/3904] Morph static variables --- src/cc/rogue/command.c | 18 ++++++++-------- src/cc/rogue/init.c | 2 +- src/cc/rogue/monsters.c | 24 ++++++++++----------- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rogue.h | 1 + src/cc/rogue/rooms.c | 37 +++++++++++++-------------------- src/cc/rogue/scrolls.c | 27 +++++++++--------------- src/cc/rogue/sticks.c | 46 ++++++++++++++++++----------------------- src/cc/rogue/things.c | 17 +++++++-------- src/cc/rogue/weapons.c | 10 ++++----- 10 files changed, 80 insertions(+), 104 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 568f4b8f8..37bcedc74 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -24,7 +24,7 @@ command(struct rogue_state *rs) register int ntimes = 1; /* Number of player moves */ char *fp; THING *mp; - static char countch, direction, newcount = FALSE; + //static char countch, direction, newcount = FALSE; if (on(player, ISHASTE)) ntimes++; /* @@ -74,7 +74,7 @@ command(struct rogue_state *rs) if (running || to_death) ch = runch; else if (count) - ch = countch; + ch = rs->countch; else { ch = readchar(rs); @@ -98,11 +98,11 @@ command(struct rogue_state *rs) /* * check for prefixes */ - newcount = FALSE; + rs->newcount = FALSE; if (isdigit(ch)) { count = 0; - newcount = TRUE; + rs->newcount = TRUE; while (isdigit(ch)) { count = count * 10 + (ch - '0'); @@ -110,7 +110,7 @@ command(struct rogue_state *rs) count = 255; ch = readchar(rs); } - countch = ch; + rs->countch = ch; /* * turn off count for commands which don't make sense * to repeat @@ -205,12 +205,12 @@ over: door_stop = TRUE; firstmove = TRUE; } - if (count && !newcount) - ch = direction; + if (count && !rs->newcount) + ch = rs->direction; else { ch += ('A' - CTRL('A')); - direction = ch; + rs->direction = ch; } goto over; } @@ -372,7 +372,7 @@ over: else { ch = dir_ch; - countch = dir_ch; + rs->countch = dir_ch; goto over; } when ')': current(rs,cur_weapon, "wielding", NULL); diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index b11cfa80c..635e95843 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -369,7 +369,7 @@ init_materials() { register int i, j; register const char *str; - static bool metused[NMETAL]; + bool metused[NMETAL]; memset(metused,0,sizeof(metused)); for (i = 0; i < NWOOD; i++) used[i] = FALSE; diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 7e1186e8d..7d6d9a32e 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -18,12 +18,12 @@ /* * List of monsters in rough order of vorpalness */ -static char lvl_mons[] = { +static const char lvl_mons[] = { 'K', 'E', 'B', 'S', 'H', 'I', 'R', 'O', 'Z', 'L', 'C', 'Q', 'A', 'N', 'Y', 'F', 'T', 'W', 'P', 'X', 'U', 'M', 'V', 'G', 'J', 'D' }; -static char wand_mons[] = { +static const char wand_mons[] = { 'K', 'E', 'B', 'S', 'H', 0, 'R', 'O', 'Z', 0, 'C', 'Q', 'A', 0, 'Y', 0, 'T', 'W', 'P', 0, 'U', 'M', 'V', 'G', 'J', 0 }; @@ -119,27 +119,27 @@ void wanderer(struct rogue_state *rs) { THING *tp; - static coord cp; - + coord cp; + memset(&cp,0,sizeof(cp)); tp = new_item(); do { - find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); } while (roomin(rs,&cp) == proom); new_monster(rs,tp, randmonster(TRUE), &cp); if (on(player, SEEMONST)) { - standout(); - if (!on(player, ISHALU)) - addch(tp->t_type); - else - addch(rnd(26) + 'A'); - standend(); + standout(); + if (!on(player, ISHALU)) + addch(tp->t_type); + else + addch(rnd(26) + 'A'); + standend(); } runto(rs,&tp->t_pos); #ifdef MASTER if (wizard) - msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); + msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); #endif } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 2425b051f..e503056d6 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -22,7 +22,7 @@ typedef struct char *pa_high, *pa_straight; } PACT; -static PACT p_actions[] = +static const PACT p_actions[] = { { ISHUH, unconfuse, HUHDURATION, /* P_CONFUSE */ "what a tripy feeling!", diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 5540da2da..f8117cb91 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -366,6 +366,7 @@ struct rogue_state uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; FILE *logfp; + char countch, direction, newcount; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index 67ca701d9..f5454d501 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -30,14 +30,10 @@ typedef struct spot { /* position matrix for maze positions */ void do_rooms(struct rogue_state *rs) { - int i; - struct room *rp; - THING *tp; - int left_out; - static coord top; - coord bsze; /* maximum room size */ - coord mp; - + int i,left_out; struct room *rp; THING *tp; + //static coord top; + coord mp,bsze,top; /* maximum room size */ + memset(&top,0,sizeof(top)); bsze.x = NUMCOLS / 3; bsze.y = NUMLINES / 3; /* @@ -206,23 +202,18 @@ horiz(struct room *rp, int starty) */ static int Maxy, Maxx, Starty, Startx; - static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1]; - -void -do_maze(struct rogue_state *rs,struct room *rp) +void do_maze(struct rogue_state *rs,struct room *rp) { - SPOT *sp; - int starty, startx; - static coord pos; - + SPOT *sp; int starty, startx; + coord pos; + memset(&pos,0,sizeof(pos)); for (sp = &maze[0][0]; sp <= &maze[NUMLINES / 3][NUMCOLS / 3]; sp++) { - sp->used = FALSE; - sp->nexits = 0; + sp->used = FALSE; + sp->nexits = 0; } - Maxy = rp->r_max.y; Maxx = rp->r_max.x; Starty = rp->r_pos.y; @@ -245,11 +236,11 @@ dig(struct rogue_state *rs,int y, int x) { coord *cp; int cnt, newy, newx, nexty = 0, nextx = 0; - static coord pos; - static coord del[4] = { - {2, 0}, {-2, 0}, {0, 2}, {0, -2} + coord pos; + static const coord del[4] = { + {2, 0}, {-2, 0}, {0, 2}, {0, -2} }; - + memset(&pos,0,sizeof(pos)); for (;;) { if ( rs->replaydone != 0 ) diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index 8ed6d2648..49c427f67 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -22,26 +22,19 @@ void read_scroll(struct rogue_state *rs) { - THING *obj; - PLACE *pp; - int y, x; - char ch; - int i; - bool discardit = FALSE; - struct room *cur_room; - THING *orig_obj; - static coord mp; - + THING *obj,*orig_obj; PLACE *pp; int i, y, x; char ch; + bool discardit = FALSE; struct room *cur_room; coord mp; + memset(&mp,0,sizeof(mp)); obj = get_item(rs,"read", SCROLL); if (obj == NULL) - return; + return; if (obj->o_type != SCROLL) { - if (!terse) - msg(rs,"there is nothing on it to read"); - else - msg(rs,"nothing to read"); - return; + if (!terse) + msg(rs,"there is nothing on it to read"); + else + msg(rs,"nothing to read"); + return; } /* * Calculate the effect it has on the poor guy. @@ -149,7 +142,7 @@ read_scroll(struct rogue_state *rs) case S_ID_ARMOR: case S_ID_R_OR_S: { - static char id_type[S_ID_R_OR_S + 1] = + static const char id_type[S_ID_R_OR_S + 1] = { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; /* * Identify, let him figure something out diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index cd559daef..7ab33f03c 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -245,35 +245,29 @@ do_zap(struct rogue_state *rs) * Do drain hit points from player shtick */ -void -drain(struct rogue_state *rs) +void drain(struct rogue_state *rs) { - THING *mp; - struct room *corp; - THING **dp; - int cnt; - bool inpass; - static THING *drainee[40]; - + THING *mp,**dp; struct room *corp; int cnt; bool inpass; THING *drainee[40]; + memset(drainee,0,sizeof(drainee)); /* * First cnt how many things we need to spread the hit points among */ cnt = 0; if (chat(hero.y, hero.x) == DOOR) - corp = &passages[flat(hero.y, hero.x) & F_PNUM]; + corp = &passages[flat(hero.y, hero.x) & F_PNUM]; else - corp = NULL; + corp = NULL; inpass = (bool)(proom->r_flags & ISGONE); dp = drainee; for (mp = mlist; mp != NULL; mp = next(mp)) - if (mp->t_room == proom || mp->t_room == corp || - (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && - &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) - *dp++ = mp; + if (mp->t_room == proom || mp->t_room == corp || + (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && + &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) + *dp++ = mp; if ((cnt = (int)(dp - drainee)) == 0) { - msg(rs,"you have a tingling feeling"); - return; + msg(rs,"you have a tingling feeling"); + return; } *dp = NULL; pstats.s_hpt /= 2; @@ -283,11 +277,11 @@ drain(struct rogue_state *rs) */ for (dp = drainee; *dp; dp++) { - mp = *dp; - if ((mp->t_stats.s_hpt -= cnt) <= 0) - killed(rs,mp, see_monst(mp)); - else - runto(rs,&mp->t_pos); + mp = *dp; + if ((mp->t_stats.s_hpt -= cnt) <= 0) + killed(rs,mp, see_monst(mp)); + else + runto(rs,&mp->t_pos); } } @@ -421,12 +415,12 @@ char * charge_str(THING *obj) { static char buf[20]; - + if (!(obj->o_flags & ISKNOW)) - buf[0] = '\0'; + buf[0] = '\0'; else if (terse) - sprintf(buf, " [%d]", obj->o_charges); + sprintf(buf, " [%d]", obj->o_charges); else - sprintf(buf, " [%d charges]", obj->o_charges); + sprintf(buf, " [%d charges]", obj->o_charges); return buf; } diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 39c7b94b7..e1ce2a2a8 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -334,12 +334,9 @@ pick_one(struct rogue_state *rs,struct obj_info *info, int nitems) * list what the player has discovered in this game of a certain type */ static int line_cnt = 0; - static bool newpage = FALSE; - static char *lastfmt, *lastarg; - void discovered(struct rogue_state *rs) { @@ -480,16 +477,16 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) if (line_cnt == 0) { - wclear(hw); - if (inv_type == INV_SLOW) - mpos = 0; + wclear(hw); + if (inv_type == INV_SLOW) + mpos = 0; } if (inv_type == INV_SLOW) { - if (*fmt != '\0') - if (msg(rs,fmt, arg) == ESCAPE) - return ESCAPE; - line_cnt++; + if (*fmt != '\0') + if (msg(rs,fmt, arg) == ESCAPE) + return ESCAPE; + line_cnt++; } else { diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 0a8b6016c..592b405f7 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -19,7 +19,7 @@ int group = 2; -static struct init_weaps { +static const struct init_weaps { char *iw_dam; /* Damage when wielded */ char *iw_hrl; /* Damage when thrown */ char iw_launch; /* Launching weapon */ @@ -125,8 +125,8 @@ void fall(struct rogue_state *rs,THING *obj, bool pr) { PLACE *pp; - static coord fpos; - + coord fpos; + memset(&fpos,0,sizeof(fpos)); if (fallpos(&obj->o_pos, &fpos)) { pp = INDEX(fpos.y, fpos.x); @@ -197,8 +197,8 @@ init_weapon(THING *weap, int which) int hit_monster(struct rogue_state *rs,int y, int x, THING *obj) { - static coord mp; - + coord mp; + memset(&mp,0,sizeof(mp)); mp.y = y; mp.x = x; return fight(rs,&mp, obj, TRUE); From 02613880a18dc4f638f31731dc5a6c0d569d6220 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Mar 2019 01:38:15 -1100 Subject: [PATCH 2985/3904] Const --- src/cc/rogue/monsters.c | 2 +- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rooms.c | 28 ++++++++++++++-------------- src/cc/rogue/weapons.c | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 7d6d9a32e..465e57c2a 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -39,7 +39,7 @@ randmonster(bool wander) int d; char *mons; - mons = (wander ? wand_mons : lvl_mons); + mons = (char *)(wander ? wand_mons : lvl_mons); do { d = level + (rnd(10) - 6); diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index e503056d6..ce58e5acc 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -317,7 +317,7 @@ do_pot(struct rogue_state *rs,int type, bool knowit) PACT *pp; int t; - pp = &p_actions[type]; + pp = (PACT *)&p_actions[type]; if (!pot_info[type].oi_know) pot_info[type].oi_know = knowit; t = spread(pp->pa_time); diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index f5454d501..eea847d9d 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -246,20 +246,20 @@ dig(struct rogue_state *rs,int y, int x) if ( rs->replaydone != 0 ) return; cnt = 0; - for (cp = del; cp <= &del[3]; cp++) - { - newy = y + cp->y; - newx = x + cp->x; - if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) - continue; - if (flat(newy + Starty, newx + Startx) & F_PASS) - continue; - if (rnd(++cnt) == 0) - { - nexty = newy; - nextx = newx; - } - } + for (cp = (coord *)del; cp <= (coord *)&del[3]; cp++) + { + newy = y + cp->y; + newx = x + cp->x; + if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) + continue; + if (flat(newy + Starty, newx + Startx) & F_PASS) + continue; + if (rnd(++cnt) == 0) + { + nexty = newy; + nextx = newx; + } + } if (cnt == 0) return; accnt_maze(y, x, nexty, nextx); diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 592b405f7..a8a9556af 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -163,7 +163,7 @@ fall(struct rogue_state *rs,THING *obj, bool pr) void init_weapon(THING *weap, int which) { - struct init_weaps *iwp; + const struct init_weaps *iwp; weap->o_type = WEAPON; weap->o_which = which; iwp = &init_dam[which]; From f8c3d42f9b47b66f4744ca8cb85844df7b977ef7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Mar 2019 06:29:53 -1100 Subject: [PATCH 2986/3904] Revert "Const" This reverts commit 02613880a18dc4f638f31731dc5a6c0d569d6220. --- src/cc/rogue/monsters.c | 2 +- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rooms.c | 28 ++++++++++++++-------------- src/cc/rogue/weapons.c | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 465e57c2a..7d6d9a32e 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -39,7 +39,7 @@ randmonster(bool wander) int d; char *mons; - mons = (char *)(wander ? wand_mons : lvl_mons); + mons = (wander ? wand_mons : lvl_mons); do { d = level + (rnd(10) - 6); diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index ce58e5acc..e503056d6 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -317,7 +317,7 @@ do_pot(struct rogue_state *rs,int type, bool knowit) PACT *pp; int t; - pp = (PACT *)&p_actions[type]; + pp = &p_actions[type]; if (!pot_info[type].oi_know) pot_info[type].oi_know = knowit; t = spread(pp->pa_time); diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index eea847d9d..f5454d501 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -246,20 +246,20 @@ dig(struct rogue_state *rs,int y, int x) if ( rs->replaydone != 0 ) return; cnt = 0; - for (cp = (coord *)del; cp <= (coord *)&del[3]; cp++) - { - newy = y + cp->y; - newx = x + cp->x; - if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) - continue; - if (flat(newy + Starty, newx + Startx) & F_PASS) - continue; - if (rnd(++cnt) == 0) - { - nexty = newy; - nextx = newx; - } - } + for (cp = del; cp <= &del[3]; cp++) + { + newy = y + cp->y; + newx = x + cp->x; + if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) + continue; + if (flat(newy + Starty, newx + Startx) & F_PASS) + continue; + if (rnd(++cnt) == 0) + { + nexty = newy; + nextx = newx; + } + } if (cnt == 0) return; accnt_maze(y, x, nexty, nextx); diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index a8a9556af..592b405f7 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -163,7 +163,7 @@ fall(struct rogue_state *rs,THING *obj, bool pr) void init_weapon(THING *weap, int which) { - const struct init_weaps *iwp; + struct init_weaps *iwp; weap->o_type = WEAPON; weap->o_which = which; iwp = &init_dam[which]; From 94adc1406656df97e5fab4734ba477405e8c7589 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Mar 2019 06:30:28 -1100 Subject: [PATCH 2987/3904] Revert "Morph static variables" This reverts commit 0322f2d98cbd0dc2ddabd5cd83dc2a4e8f2c2df8. --- src/cc/rogue/command.c | 18 ++++++++-------- src/cc/rogue/init.c | 2 +- src/cc/rogue/monsters.c | 24 ++++++++++----------- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rogue.h | 1 - src/cc/rogue/rooms.c | 37 ++++++++++++++++++++------------- src/cc/rogue/scrolls.c | 27 +++++++++++++++--------- src/cc/rogue/sticks.c | 46 +++++++++++++++++++++++------------------ src/cc/rogue/things.c | 17 ++++++++------- src/cc/rogue/weapons.c | 10 ++++----- 10 files changed, 104 insertions(+), 80 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 37bcedc74..568f4b8f8 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -24,7 +24,7 @@ command(struct rogue_state *rs) register int ntimes = 1; /* Number of player moves */ char *fp; THING *mp; - //static char countch, direction, newcount = FALSE; + static char countch, direction, newcount = FALSE; if (on(player, ISHASTE)) ntimes++; /* @@ -74,7 +74,7 @@ command(struct rogue_state *rs) if (running || to_death) ch = runch; else if (count) - ch = rs->countch; + ch = countch; else { ch = readchar(rs); @@ -98,11 +98,11 @@ command(struct rogue_state *rs) /* * check for prefixes */ - rs->newcount = FALSE; + newcount = FALSE; if (isdigit(ch)) { count = 0; - rs->newcount = TRUE; + newcount = TRUE; while (isdigit(ch)) { count = count * 10 + (ch - '0'); @@ -110,7 +110,7 @@ command(struct rogue_state *rs) count = 255; ch = readchar(rs); } - rs->countch = ch; + countch = ch; /* * turn off count for commands which don't make sense * to repeat @@ -205,12 +205,12 @@ over: door_stop = TRUE; firstmove = TRUE; } - if (count && !rs->newcount) - ch = rs->direction; + if (count && !newcount) + ch = direction; else { ch += ('A' - CTRL('A')); - rs->direction = ch; + direction = ch; } goto over; } @@ -372,7 +372,7 @@ over: else { ch = dir_ch; - rs->countch = dir_ch; + countch = dir_ch; goto over; } when ')': current(rs,cur_weapon, "wielding", NULL); diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 635e95843..b11cfa80c 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -369,7 +369,7 @@ init_materials() { register int i, j; register const char *str; - bool metused[NMETAL]; + static bool metused[NMETAL]; memset(metused,0,sizeof(metused)); for (i = 0; i < NWOOD; i++) used[i] = FALSE; diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 7d6d9a32e..7e1186e8d 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -18,12 +18,12 @@ /* * List of monsters in rough order of vorpalness */ -static const char lvl_mons[] = { +static char lvl_mons[] = { 'K', 'E', 'B', 'S', 'H', 'I', 'R', 'O', 'Z', 'L', 'C', 'Q', 'A', 'N', 'Y', 'F', 'T', 'W', 'P', 'X', 'U', 'M', 'V', 'G', 'J', 'D' }; -static const char wand_mons[] = { +static char wand_mons[] = { 'K', 'E', 'B', 'S', 'H', 0, 'R', 'O', 'Z', 0, 'C', 'Q', 'A', 0, 'Y', 0, 'T', 'W', 'P', 0, 'U', 'M', 'V', 'G', 'J', 0 }; @@ -119,27 +119,27 @@ void wanderer(struct rogue_state *rs) { THING *tp; - coord cp; - memset(&cp,0,sizeof(cp)); + static coord cp; + tp = new_item(); do { - find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); } while (roomin(rs,&cp) == proom); new_monster(rs,tp, randmonster(TRUE), &cp); if (on(player, SEEMONST)) { - standout(); - if (!on(player, ISHALU)) - addch(tp->t_type); - else - addch(rnd(26) + 'A'); - standend(); + standout(); + if (!on(player, ISHALU)) + addch(tp->t_type); + else + addch(rnd(26) + 'A'); + standend(); } runto(rs,&tp->t_pos); #ifdef MASTER if (wizard) - msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); + msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); #endif } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index e503056d6..2425b051f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -22,7 +22,7 @@ typedef struct char *pa_high, *pa_straight; } PACT; -static const PACT p_actions[] = +static PACT p_actions[] = { { ISHUH, unconfuse, HUHDURATION, /* P_CONFUSE */ "what a tripy feeling!", diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f8117cb91..5540da2da 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -366,7 +366,6 @@ struct rogue_state uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; FILE *logfp; - char countch, direction, newcount; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index f5454d501..67ca701d9 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -30,10 +30,14 @@ typedef struct spot { /* position matrix for maze positions */ void do_rooms(struct rogue_state *rs) { - int i,left_out; struct room *rp; THING *tp; - //static coord top; - coord mp,bsze,top; /* maximum room size */ - memset(&top,0,sizeof(top)); + int i; + struct room *rp; + THING *tp; + int left_out; + static coord top; + coord bsze; /* maximum room size */ + coord mp; + bsze.x = NUMCOLS / 3; bsze.y = NUMLINES / 3; /* @@ -202,18 +206,23 @@ horiz(struct room *rp, int starty) */ static int Maxy, Maxx, Starty, Startx; + static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1]; -void do_maze(struct rogue_state *rs,struct room *rp) + +void +do_maze(struct rogue_state *rs,struct room *rp) { - SPOT *sp; int starty, startx; - coord pos; - memset(&pos,0,sizeof(pos)); + SPOT *sp; + int starty, startx; + static coord pos; + for (sp = &maze[0][0]; sp <= &maze[NUMLINES / 3][NUMCOLS / 3]; sp++) { - sp->used = FALSE; - sp->nexits = 0; + sp->used = FALSE; + sp->nexits = 0; } + Maxy = rp->r_max.y; Maxx = rp->r_max.x; Starty = rp->r_pos.y; @@ -236,11 +245,11 @@ dig(struct rogue_state *rs,int y, int x) { coord *cp; int cnt, newy, newx, nexty = 0, nextx = 0; - coord pos; - static const coord del[4] = { - {2, 0}, {-2, 0}, {0, 2}, {0, -2} + static coord pos; + static coord del[4] = { + {2, 0}, {-2, 0}, {0, 2}, {0, -2} }; - memset(&pos,0,sizeof(pos)); + for (;;) { if ( rs->replaydone != 0 ) diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index 49c427f67..8ed6d2648 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -22,19 +22,26 @@ void read_scroll(struct rogue_state *rs) { - THING *obj,*orig_obj; PLACE *pp; int i, y, x; char ch; - bool discardit = FALSE; struct room *cur_room; coord mp; - memset(&mp,0,sizeof(mp)); + THING *obj; + PLACE *pp; + int y, x; + char ch; + int i; + bool discardit = FALSE; + struct room *cur_room; + THING *orig_obj; + static coord mp; + obj = get_item(rs,"read", SCROLL); if (obj == NULL) - return; + return; if (obj->o_type != SCROLL) { - if (!terse) - msg(rs,"there is nothing on it to read"); - else - msg(rs,"nothing to read"); - return; + if (!terse) + msg(rs,"there is nothing on it to read"); + else + msg(rs,"nothing to read"); + return; } /* * Calculate the effect it has on the poor guy. @@ -142,7 +149,7 @@ read_scroll(struct rogue_state *rs) case S_ID_ARMOR: case S_ID_R_OR_S: { - static const char id_type[S_ID_R_OR_S + 1] = + static char id_type[S_ID_R_OR_S + 1] = { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; /* * Identify, let him figure something out diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index 7ab33f03c..cd559daef 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -245,29 +245,35 @@ do_zap(struct rogue_state *rs) * Do drain hit points from player shtick */ -void drain(struct rogue_state *rs) +void +drain(struct rogue_state *rs) { - THING *mp,**dp; struct room *corp; int cnt; bool inpass; THING *drainee[40]; - memset(drainee,0,sizeof(drainee)); + THING *mp; + struct room *corp; + THING **dp; + int cnt; + bool inpass; + static THING *drainee[40]; + /* * First cnt how many things we need to spread the hit points among */ cnt = 0; if (chat(hero.y, hero.x) == DOOR) - corp = &passages[flat(hero.y, hero.x) & F_PNUM]; + corp = &passages[flat(hero.y, hero.x) & F_PNUM]; else - corp = NULL; + corp = NULL; inpass = (bool)(proom->r_flags & ISGONE); dp = drainee; for (mp = mlist; mp != NULL; mp = next(mp)) - if (mp->t_room == proom || mp->t_room == corp || - (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && - &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) - *dp++ = mp; + if (mp->t_room == proom || mp->t_room == corp || + (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && + &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) + *dp++ = mp; if ((cnt = (int)(dp - drainee)) == 0) { - msg(rs,"you have a tingling feeling"); - return; + msg(rs,"you have a tingling feeling"); + return; } *dp = NULL; pstats.s_hpt /= 2; @@ -277,11 +283,11 @@ void drain(struct rogue_state *rs) */ for (dp = drainee; *dp; dp++) { - mp = *dp; - if ((mp->t_stats.s_hpt -= cnt) <= 0) - killed(rs,mp, see_monst(mp)); - else - runto(rs,&mp->t_pos); + mp = *dp; + if ((mp->t_stats.s_hpt -= cnt) <= 0) + killed(rs,mp, see_monst(mp)); + else + runto(rs,&mp->t_pos); } } @@ -415,12 +421,12 @@ char * charge_str(THING *obj) { static char buf[20]; - + if (!(obj->o_flags & ISKNOW)) - buf[0] = '\0'; + buf[0] = '\0'; else if (terse) - sprintf(buf, " [%d]", obj->o_charges); + sprintf(buf, " [%d]", obj->o_charges); else - sprintf(buf, " [%d charges]", obj->o_charges); + sprintf(buf, " [%d charges]", obj->o_charges); return buf; } diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index e1ce2a2a8..39c7b94b7 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -334,9 +334,12 @@ pick_one(struct rogue_state *rs,struct obj_info *info, int nitems) * list what the player has discovered in this game of a certain type */ static int line_cnt = 0; + static bool newpage = FALSE; + static char *lastfmt, *lastarg; + void discovered(struct rogue_state *rs) { @@ -477,16 +480,16 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) if (line_cnt == 0) { - wclear(hw); - if (inv_type == INV_SLOW) - mpos = 0; + wclear(hw); + if (inv_type == INV_SLOW) + mpos = 0; } if (inv_type == INV_SLOW) { - if (*fmt != '\0') - if (msg(rs,fmt, arg) == ESCAPE) - return ESCAPE; - line_cnt++; + if (*fmt != '\0') + if (msg(rs,fmt, arg) == ESCAPE) + return ESCAPE; + line_cnt++; } else { diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 592b405f7..0a8b6016c 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -19,7 +19,7 @@ int group = 2; -static const struct init_weaps { +static struct init_weaps { char *iw_dam; /* Damage when wielded */ char *iw_hrl; /* Damage when thrown */ char iw_launch; /* Launching weapon */ @@ -125,8 +125,8 @@ void fall(struct rogue_state *rs,THING *obj, bool pr) { PLACE *pp; - coord fpos; - memset(&fpos,0,sizeof(fpos)); + static coord fpos; + if (fallpos(&obj->o_pos, &fpos)) { pp = INDEX(fpos.y, fpos.x); @@ -197,8 +197,8 @@ init_weapon(THING *weap, int which) int hit_monster(struct rogue_state *rs,int y, int x, THING *obj) { - coord mp; - memset(&mp,0,sizeof(mp)); + static coord mp; + mp.y = y; mp.x = x; return fight(rs,&mp, obj, TRUE); From d61784c949f7f11d65110f862764ad4b4487771e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 20 Mar 2019 13:03:41 -0700 Subject: [PATCH 2988/3904] Custom asset chain client names (#1338) * Allow setting client name via cli * Add util.h for GetArg --- src/clientversion.cpp | 3 ++- src/init.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 4f004aac2..663e2e937 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -20,6 +20,7 @@ #include "clientversion.h" #include "tinyformat.h" +#include "util.h" #include @@ -34,7 +35,7 @@ * for both bitcoind and bitcoin-core, to make it harder for attackers to * target servers or GUI users specifically. */ -const std::string CLIENT_NAME("MagicBean"); +const std::string CLIENT_NAME = GetArg("-ac_clientname", "MagicBean"); /** * Client version number diff --git a/src/init.cpp b/src/init.cpp index 2a612634e..d2546347d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -571,6 +571,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-ac_cclib", _("Cryptoconditions dynamicly loadable library")); strUsage += HelpMessageOpt("-ac_ccenable", _("Cryptoconditions to enable")); strUsage += HelpMessageOpt("-ac_ccactivate", _("Block height to enable Cryptoconditions")); + strUsage += HelpMessageOpt("-ac_clientname", _("Full node client name, default 'MagicBean'")); strUsage += HelpMessageOpt("-ac_decay", _("Percentage of block reward decrease at each halving")); strUsage += HelpMessageOpt("-ac_end", _("Block height at which block rewards will end")); strUsage += HelpMessageOpt("-ac_eras", _("Block reward eras")); From 2dd54beb1dcdd7e32ba09b197725295673129e91 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Thu, 21 Mar 2019 03:11:17 +0300 Subject: [PATCH 2989/3904] RICK & MORTY --- src/ac/morty | 2 ++ src/ac/rick | 2 ++ src/assetchains.json | 15 +++++++++++++++ src/assetchains.old | 3 ++- src/fiat/morty | 2 ++ src/fiat/rick | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 src/ac/morty create mode 100755 src/ac/rick create mode 100755 src/fiat/morty create mode 100755 src/fiat/rick diff --git a/src/ac/morty b/src/ac/morty new file mode 100755 index 000000000..4579324b7 --- /dev/null +++ b/src/ac/morty @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6 diff --git a/src/ac/rick b/src/ac/rick new file mode 100755 index 000000000..b68bd56ab --- /dev/null +++ b/src/ac/rick @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index dfc352a2f..a37e13208 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -243,6 +243,21 @@ "ac_supply": "10000000000", "ac_cc": "2", "addnode": ["51.75.122.83"] + }, + { + "ac_name": "RICK", + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] + }, + { + "ac_name": "MORTY", + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] } + ] diff --git a/src/assetchains.old b/src/assetchains.old index cc85f1cd1..d200d26bd 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -47,4 +47,5 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 & - +./komodod -pubkey=$pubkey -ac_name=RICK -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 & +./komodod -pubkey=$pubkey -ac_name=MORTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 & diff --git a/src/fiat/morty b/src/fiat/morty new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/fiat/morty @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/rick b/src/fiat/rick new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/fiat/rick @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 From 42200a471667dadd6ab32f31f37767fe5a6de426 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 21 Mar 2019 00:00:40 -0700 Subject: [PATCH 2990/3904] Fix z_listunspent RPC docs, which require different quoting that CLI function arguments (#1339) --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 38c21d2bd..445f145fd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3031,7 +3031,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) "\nExamples\n" + HelpExampleCli("z_listunspent", "") + HelpExampleCli("z_listunspent", "6 9999999 false \"[\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\",\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\"]\"") - + HelpExampleRpc("z_listunspent", "6 9999999 false \"[\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\",\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\"]\"") + + HelpExampleRpc("z_listunspent", "6,9999999,false,[\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\",\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\"]") ); RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)(UniValue::VNUM)(UniValue::VBOOL)(UniValue::VARR)); From 314b66513926a864514eb16cf5d4d01121c5f2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mihail=20=C2=ABKolo=C2=BB=20Fedorov?= Date: Thu, 21 Mar 2019 10:01:53 +0300 Subject: [PATCH 2991/3904] RICK & MORTY (#1341) --- src/ac/morty | 2 ++ src/ac/rick | 2 ++ src/assetchains.json | 15 +++++++++++++++ src/assetchains.old | 3 ++- src/fiat/morty | 2 ++ src/fiat/rick | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 src/ac/morty create mode 100755 src/ac/rick create mode 100755 src/fiat/morty create mode 100755 src/fiat/rick diff --git a/src/ac/morty b/src/ac/morty new file mode 100755 index 000000000..4579324b7 --- /dev/null +++ b/src/ac/morty @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6 diff --git a/src/ac/rick b/src/ac/rick new file mode 100755 index 000000000..b68bd56ab --- /dev/null +++ b/src/ac/rick @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index dfc352a2f..a37e13208 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -243,6 +243,21 @@ "ac_supply": "10000000000", "ac_cc": "2", "addnode": ["51.75.122.83"] + }, + { + "ac_name": "RICK", + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] + }, + { + "ac_name": "MORTY", + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] } + ] diff --git a/src/assetchains.old b/src/assetchains.old index cc85f1cd1..d200d26bd 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -47,4 +47,5 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 & - +./komodod -pubkey=$pubkey -ac_name=RICK -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 & +./komodod -pubkey=$pubkey -ac_name=MORTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 & diff --git a/src/fiat/morty b/src/fiat/morty new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/fiat/morty @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/rick b/src/fiat/rick new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/fiat/rick @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 From dc9bb80448fe15d7448dfd4dfef52ca9befa0029 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Thu, 21 Mar 2019 15:31:27 +0300 Subject: [PATCH 2992/3904] fix --- src/fiat/morty | 2 +- src/fiat/rick | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fiat/morty b/src/fiat/morty index 99cfa9a09..4579324b7 100755 --- a/src/fiat/morty +++ b/src/fiat/morty @@ -1,2 +1,2 @@ #!/bin/bash -./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 +./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/rick b/src/fiat/rick index 99cfa9a09..b68bd56ab 100755 --- a/src/fiat/rick +++ b/src/fiat/rick @@ -1,2 +1,2 @@ #!/bin/bash -./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 +./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6 From 5caf0cb306a00980cf11994d458aa6cbdd67677b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mihail=20=C2=ABKolo=C2=BB=20Fedorov?= Date: Thu, 21 Mar 2019 15:36:40 +0300 Subject: [PATCH 2993/3904] fix rick & morty (#1342) * RICK & MORTY * fix --- src/fiat/morty | 2 +- src/fiat/rick | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fiat/morty b/src/fiat/morty index 99cfa9a09..4579324b7 100755 --- a/src/fiat/morty +++ b/src/fiat/morty @@ -1,2 +1,2 @@ #!/bin/bash -./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 +./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/rick b/src/fiat/rick index 99cfa9a09..b68bd56ab 100755 --- a/src/fiat/rick +++ b/src/fiat/rick @@ -1,2 +1,2 @@ #!/bin/bash -./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 +./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6 From ac5ec551261f6fa385d8a40bdee71d664d2e1154 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:14:59 -1100 Subject: [PATCH 2994/3904] Initial Payments CC without validation --- src/cc/CCPayments.h | 9 +- src/cc/CCtokens.cpp | 3 +- src/cc/CCtx.cpp | 20 +- src/cc/cclib.cpp | 2 + src/cc/dice.cpp | 4 +- src/cc/dilithium.c | 6 +- src/cc/faucet.cpp | 6 +- src/cc/gateways.cpp | 6 +- src/cc/marmara.cpp | 6 +- src/cc/payments.cpp | 599 +++++++++++++++++++++++++++++++-------- src/cc/rewards.cpp | 6 +- src/rpc/server.cpp | 6 + src/rpc/server.h | 7 + src/wallet/rpcwallet.cpp | 78 +++++ 14 files changed, 620 insertions(+), 138 deletions(-) diff --git a/src/cc/CCPayments.h b/src/cc/CCPayments.h index 187d9c9ad..247a0f2ec 100644 --- a/src/cc/CCPayments.h +++ b/src/cc/CCPayments.h @@ -19,9 +19,16 @@ #include "CCinclude.h" +#define PAYMENTS_TXFEE 10000 + bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom -UniValue PaymentsInfo(); +UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr); +UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr); +UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr); +UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr); +UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr); +UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr); #endif diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 8aa5e88f7..8eff2c749 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -586,8 +586,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); } - threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: maxinputs really could not be over 64? what if i want to calc total balance for all available uxtos? - // maybe it is better to add all uxtos if maxinputs == 0 + threshold = total / (maxinputs != 0 ? maxinputs : MAX_CCVINS); for (std::vector >::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 3e93b3462..13e097a8d 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -509,16 +509,18 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs) { - int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=CC_MAXVINS; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; + int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; #ifdef ENABLE_WALLET assert(pwalletMain != NULL); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos)); - threshold = total/(maxinputs+1); - if ( maxinputs > maxutxos ) - maxutxos = maxinputs; + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; sum = 0; BOOST_FOREACH(const COutput& out, vecOutputs) { @@ -602,12 +604,14 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs) { - int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=CC_MAXVINS; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; + int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos)); - threshold = total/(maxinputs+1); - if ( maxinputs > maxutxos ) - maxutxos = maxinputs; + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; sum = 0; Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG); SetCCunspents(unspentOutputs,coinaddr); diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 25cd691c5..1330c6b3e 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -492,6 +492,8 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; if ( maxinputs != 0 ) threshold = total/maxinputs; else threshold = total; diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4f2b421aa..ca1ad7b53 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1052,9 +1052,11 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) threshold = total / maxinputs; - else threshold = total / 64; + else threshold = total; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 0854236ec..7ba522f0f 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3340,7 +3340,11 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index b794d9b1c..81a2c2933 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -146,7 +146,11 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index f0c8735e2..18fc43004 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -898,7 +898,11 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP { GetTokensCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "check " << coinaddr << " for gateway inputs" << std::endl); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 3c35632c8..60afbc7fd 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -388,7 +388,11 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,i,n = 0; uint8_t funcid; CPubKey pk; std::vector vals; std::vector > unspentOutputs; SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index c4f476cfb..2a99c9d31 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -15,14 +15,81 @@ #include "CCPayments.h" -/* - Payments CC is a catchall CC, supported invoices, zpayments, automated funds allocation, including token based revshare +/* + 0) create <- update_allowed flag, locked_blocks, minrelease, list of scriptPubKeys, allocations + 1) lock amount to global CC address + 2) release amount -> vout[i] will be scriptPubKeys[i] and (amount * allocations[i]) / sumallocations[] (only using vins that have been locked for locked_blocks+). will make a tx with less than amount if it can find enough vins for minrelease amount + + 3) update (vins from all scriptPubkeys) new update_allowed flag, locked_blocks, minrelease, list of scriptPubKeys, allocations (only if update_allowed) + + 4) info txid -> display parameters, funds + 5) list -> all txids */ // start of consensus code +CScript EncodePaymentsTxidOpRet(int32_t allocation,std::vector scriptPubKey,std::vector opret) +{ + CScript opret; uint8_t evalcode = EVAL_PAYMENTS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'T' << allocation << scriptPubKey << opret); + return(opret); +} + +uint8_t DecodePaymentsTxidOpRet(CScript scriptPubKey,int32_t &allocation,std::vector &scriptPubKey,std::vector &opret) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> allocation; ss >> scriptPubKey; ss >> opret) != 0 ) + { + if ( e == EVAL_PAYMENTS && f == 'T' ) + return(f); + } + return(0); +} + +CScript EncodePaymentsFundOpRet(uint256 checktxid) +{ + CScript opret; uint8_t evalcode = EVAL_PAYMENTS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'F' << checktxid); + return(opret); +} + +uint8_t DecodePaymentsFundOpRet(CScript scriptPubKey,uint256 &checktxid) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> checktxid) != 0 ) + { + if ( e == EVAL_PAYMENTS && f == 'F' ) + return(f); + } + return(0); +} + +CScript EncodePaymentsOpRet(int32_t updateflag,int32_t lockedblocks,int32_t minrelease,int32_t totalallocations,std::vector txidoprets) +{ + CScript opret; uint8_t evalcode = EVAL_PAYMENTS; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << updateflag << lockedblocks << minrelease << totalallocations << txidoprets); + return(opret); +} + +uint8_t DecodePaymentsOpRet(CScript scriptPubKey,int32_t &updateflag,int32_t &lockedblocks,int32_t &minrelease,int32_t &totalallocations,std::vector &txidoprets) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> updateflag; ss >> lockedblocks; ss >> minrelease; ss >> totalallocations; ss >> txidoprets) != 0 ) + { + if ( e == EVAL_PAYMENTS && f == 'C' ) + return(f); + } + return(0); +} + int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; @@ -74,144 +141,434 @@ bool PaymentsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { - int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - return eval->Invalid("no validation yet"); - std::vector > txids; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - preventCCvins = preventCCvouts = -1; - if ( numvouts < 1 ) - return eval->Invalid("no vouts"); - else - { - for (i=0; iInvalid("illegal normal vini"); - } - } - //fprintf(stderr,"check amounts\n"); - if ( PaymentsExactAmounts(cp,eval,tx,1,10000) == false ) - { - fprintf(stderr,"Paymentsget invalid amount\n"); - return false; - } - else - { - txid = tx.GetHash(); - memcpy(hash,&txid,sizeof(hash)); - retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); - if ( retval != 0 ) - fprintf(stderr,"Paymentsget validated\n"); - else fprintf(stderr,"Paymentsget invalid\n"); - return(retval); - } - } + return(true); } // end of consensus code // helper functions for rpc calls in rpcwallet.cpp -int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs) +int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey txidpk,int64_t total,int32_t maxinputs,uint256 createtxid) { - // add threshold check - char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; + char coinaddr[64]; int64_t nValue,threshold,price,totalinputs = 0; uint256 txid,checktxid,hashBlock; std::vector origpubkey; CTransaction vintx,tx; int32_t iter,vout,n = 0; std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; + for (iter=0; iter<2; iter++) { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - // no need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( iter == 0 ) + GetCCaddress(cp,coinaddr,Paymentspk); + else GetCCaddress1of2(cp,coinaddr,Paymentspk,txidpk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - if ( (nValue= IsPaymentsvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( total != 0 && maxinputs != 0 ) - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - nValue = it->second.satoshis; - totalinputs += nValue; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) - break; + if ( iter == 0 ) + { + std::vector scriptPubKey,opret; + if ( myGetTransaction(txid,tx,hashBlock) == 0 || tx.vout.size() < 2 || DecodePaymentsFundOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,checktxid) != 'F' || checktxid != createtxid ) + continue; + } + if ( (nValue= IsPaymentsvout(cp,vintx,vout)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + { + if ( total != 0 && maxinputs != 0 ) + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + nValue = it->second.satoshis; + totalinputs += nValue; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) + break; + } } } } return(totalinputs); } -std::string PaymentsGet(uint64_t txfee,int64_t nValue) +UniValue payments_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) { - CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Paymentspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; - cp = CCinit(&C,EVAL_PAYMENTS); - if ( txfee == 0 ) - txfee = 10000; - Paymentspk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddPaymentsInputs(cp,mtx,Paymentspk,nValue+txfee,60)) > 0 ) + CTransaction tx; + if ( rawtx.size() > 0 ) { - if ( inputs > nValue ) - CCchange = (inputs - nValue - txfee); - if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,CCchange,Paymentspk)); - mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - fprintf(stderr,"start at %u\n",(uint32_t)time(NULL)); - j = rand() & 0xfffffff; - for (i=0; i<1000000; i++,j++) + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) { - tmpmtx = mtx; - rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_PAYMENTS << (uint8_t)'G' << j)); - if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 ) - { - len >>= 1; - decode_hex(buf,len,(char *)rawhex.c_str()); - hash = bits256_doublesha256(0,buf,len); - if ( (hash.bytes[0] & 0xff) == 0 && (hash.bytes[31] & 0xff) == 0 ) - { - fprintf(stderr,"found valid txid after %d iterations %u\n",i,(uint32_t)time(NULL)); - return(rawhex); - } - //fprintf(stderr,"%02x%02x ",hash.bytes[0],hash.bytes[31]); - } - } - fprintf(stderr,"couldnt generate valid txid %u\n",(uint32_t)time(NULL)); - return(""); - } else fprintf(stderr,"cant find Payments inputs\n"); - return(""); -} - -std::string PaymentsFund(uint64_t txfee,int64_t funds) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Paymentspk; CScript opret; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_PAYMENTS); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - Paymentspk = GetUnspendable(cp,0); - if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) - { - mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,funds,Paymentspk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); - } - return(""); -} - -UniValue PaymentsInfo() -{ - UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey Paymentspk; struct CCcontract_info *cp,C; int64_t funding; - result.push_back(Pair("result","success")); - result.push_back(Pair("name","Payments")); - cp = CCinit(&C,EVAL_PAYMENTS); - Paymentspk = GetUnspendable(cp,0); - funding = AddPaymentsInputs(cp,mtx,Paymentspk,0,0); - sprintf(numstr,"%.8f",(double)funding/COIN); - result.push_back(Pair("funding",numstr)); + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize payments CCtx")); return(result); } +cJSON *payments_reparse(int32_t *nump,char *jsonstr) +{ + cJSON *params; char *newstr; int32_t i,j; + *nump = 0; + if ( jsonstr != 0 ) + { + if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) + { + jsonstr[strlen(jsonstr)-1] = 0; + jsonstr++; + } + newstr = (char *)malloc(strlen(jsonstr)+1); + for (i=j=0; jsonstr[i]!=0; i++) + { + if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) + { + newstr[j++] = '"'; + i += 2; + } + else if ( jsonstr[i] == '\'' ) + newstr[j++] = '"'; + else newstr[j++] = jsonstr[i]; + } + newstr[j] = 0; + params = cJSON_Parse(newstr); + if ( 0 && params != 0 ) + printf("new.(%s) -> %s\n",newstr,jprint(params,0)); + free(newstr); + *nump = cJSON_GetArraySize(params); + } else params = 0; + return(params); +} + +uint256 payments_juint256(cJSON *obj) +{ + uint256 tmp; bits256 t = jbits256(obj,0); + memcpy(&tmp,&t,sizeof(tmp)); + return(revuint256(tmp)); +} + +int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t len) +{ + char *hexstr; int32_t val; + if ( (hexstr= jstr(item,0)) != 0 && ((val= is_hexstr(hexstr,0)) == len*2 || (val > 0 && len == 0)) ) + { + val >>= 1; + hexdata.resize(val); + decode_hex(hexdata,val,hexstr); + return(0); + } else return(-1); +} + +UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) +{ + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; + cJSON *params = payments_reparse(&n,jsonstr); + mypk = pubkey2pk(Mypubkey()); + Paymentspk = GetUnspendable(cp,0); + if ( params != 0 && n == 2 ) + { + createtxid = payments_juint256(jitem(params,0)); + amount = jdouble(jitem(params,1),0) * SATOSHIDEN + 0.0000000049; + if ( myGetTransaction(createtxid,tx,hashBlock) != 0 ) + { + if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) + { + for (i=0; i scriptPubKey,opret; + vout.nValue = 0; + if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) + { + vout.nValue = allocation; + vout.scriptPubKey.resize(scriptPubKey.size()); + memcpy(&vout.scriptPubKey[0],&scriptPubKey[0],scriptPubKey.size()); + checkallocations += allocation; + if ( opret.size() > 0 ) + { + scriptPubKey.resize(opret.size); + memcpy(&onlyopret[0],&opret[0],opret.size); + numoprets++; + } + } else break; + mtx.vout.push_back(vout); + } + if ( i != txidoprets.size() ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid txidoprets[i]")); + result.push_back(Pair("txi",(int64_t)i)); + return(result); + } + else if ( checkallocations != totalallocations ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","totalallocations mismatch")); + result.push_back(Pair("checkallocations",(int64_t)checkallocations)); + result.push_back(Pair("totalallocations",(int64_t)totalallocations)); + return(result); + } + else if ( numoprets > 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","too many oprets")); + result.push_back(Pair("numoprets",(int64_t)numoprets)); + return(result); + } + for (i=0; i= amount ) + { + if ( (CCchange= (inputsum - amount)) > TRANSACTIONS_TXFEE ) + mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,CCchange,Paymentspk,txidpk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); + return(payments_rawtxresult(result,rawtx,0)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt find enough locked funds")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt decode paymentscreate txid opret")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt find paymentscreate txid")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","parameters error")); + } + return(result); +} + +UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); + CPubKey Paymentspk,mypk,txidpk; uint256 txid,hashBlock; int64_t amount; CScript opret; CTransaction tx; char txidaddr[64]; std::string rawtx; int32_t n,useopret = 0,updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; + cJSON *params = payments_reparse(&n,jsonstr); + mypk = pubkey2pk(Mypubkey()); + Paymentspk = GetUnspendable(cp,0); + if ( params != 0 && n > 1 && n <= 3 ) + { + txid = payments_juint256(jitem(params,0)); + amount = jdouble(jitem(params,1),0) * SATOSHIDEN + 0.0000000049; + if ( n == 3 ) + useopret = jint(jitem(params,2),0) != 0; + if ( myGetTransaction(txid,tx,hashBlock) == 0 || tx.vout.size() == 1 || DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) == 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid createtxid")); + } + else if ( AddNormalinputs(mtx,mypk,amount+PAYMENTS_TXFEE,60) > 0 ) + { + if ( useopret == 0 ) + { + txidpk = CCtxidaddr(txidaddr,txid); + mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,funds,Paymentspk,txidpk)); + } + else + { + mtx.vout.push_back(MakeCCvout(EVAL_PAYMENTS,funds,Paymentspk)); + opret = EncodePaymentsFundOpRet(txid); + } + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); + return(payments_rawtxresult(result,rawtx,0)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt find enough funds")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","parameters error")); + } + return(result); +} + +UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); CPubKey mypk; std::string rawtx; + std::vector scriptPubKey,opret; int32_t allocation,n,retval0,retval1=0; + cJSON *params = payments_reparse(&n,jsonstr); + mypk = pubkey2pk(Mypubkey()); + if ( params != 0 && n > 1 && n <= 3 ) + { + allocation = juint(jitem(params,0),0); + retval0 = payments_parsehexdata(scriptPubKey,jitem(params,1)); + if ( m == 3 ) + retval1 = payments_parsehexdata(opret,jitem(params,2)); + if ( allocation > 0 && retval == 0 && retval1 == 0 && AddNormalinputs(mtx,mypk,PAYMENTS_TXFEE,10) > 0 ) + { + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsTxidOpRet(allocation,scriptPubKey,opret)); + return(payments_rawtxresult(result,rawtx,0)); + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid params or cant find txfee")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","parameters error")); + } + return(result); +} + +UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations=0; + cJSON *params = payments_reparse(&n,jsonstr); + if ( params != 0 && n >= 4 ) + { + updateflag = juint(jitem(params,0),0); + lockedblocks = juint(jitem(params,1),0); + minrelease = juint(jitem(params,2),0); + for (i=0; i scriptPubKey,opret; int32_t allocation; + if ( myGetTransaction(txidoprets[i],tx,hashBlock) != 0 && tx.vout.size() > 1 && DecodePaymentsTxidOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) + { + totalallocations += allocation; + if ( opret.size() > 0 ) + numoprets++; + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid txidopret")); + result.push_back(Pair("txid",txidoprets[i].GetHex())); + result.push_back(Pair("txi",(int64_t)i)); + return(result); + } + } + if ( numoprets > 1 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","too many opreturns")); + result.push_back(Pair("numoprets",(int64_t)numoprets)); + return(result); + } + mypk = pubkey2pk(Mypubkey()); + Paymentspk = GetUnspendable(cp,0); + if ( AddNormalinputs(mtx,mypk,2*PAYMENTS_TXFEE,60) > 0 ) + { + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,PAYMENTS_TXFEE,Paymentspk,Paymentspk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsOpRet(updateflag,lockedblocks,minrelease,totalallocations,txidoprets)); + return(payments_rawtxresult(result,rawtx,0)); + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough normal funds")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","parameters error")); + } + return(result); +} + +UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) +{ + UniValue result(UniValue::VOBJ),a(UniValue:VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,n,flag=0,allocation,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64]; + cJSON *params = payments_reparse(&n,jsonstr); + if ( params != 0 && n == 1 ) + { + Paymentspk = GetUnspendable(cp,0); + txid = payments_juint256(jitem(params,0)); + if ( myGetTransaction(txid,tx,hashBlock) != 0 ) + { + if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) + { + result.push_back(Pair("updateable",updateflag!=0?"yes":"no")); + result.push_back(Pair("lockedblocks",(int64_t)lockedblocks)); + result.push_back(Pair("totalallocations",(int64_t)totalallocations)); + result.push_back(Pair("minrelease",(int64_t)minrelease)); + for (i=0; i scriptPubKey,opret; + obj.push_back(Pair("txidopret",txidoprets[i])); + if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) + { + obj.push_back(Pair("scriptPubKey",scriptPubKey)); + if ( opret.size() != 0 ) + { + obj.push_back(Pair("opreturn",opret)); + numoprets++; + } + } + } + flag++; + if ( numoprets > 1 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","too many opreturns")); + result.push_back(Pair("numoprets",(int64_t)numoprets)); + } + else + { + txidpk = CCtxidaddr(txidaddr,txid); + GetCCaddress1of2(cp,fundsaddr,Paymentspk,txidpk); + funds = CCaddress_balance(fundsaddr); + result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); + GetCCaddress(cp,fundsopretaddr,Paymentspk); + fundsopret = CCaddress_balance(fundsopretaddr); + result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret))); + result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret))); + result.push_back(Pair("result","success")); + } + } + } + if ( flag == 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt find valid payments create txid")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","parameters error")); + } + return(result); +} + +UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) +{ + std::vector > addressIndex; uint256 txid,hashBlock; + UniValue result(UniValue::VOBJ),a(UniValue:VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; + result.push_back(Pair("result","success")); + Paymentspk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk); + SetCCtxids(addressIndex,markeraddr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + txid = it->first.txhash; + if ( it->first.index == 0 && myGetTransaction(txid,tx,hashBlock) != 0 ) + { + if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) == 'C' ) + { + a.push_back(uint256_str(str,txid)); + } + } + } + result.push_back(Pair("createtxids",a)); + return(result); +} diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index c201869b0..1351bbaeb 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -333,7 +333,11 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcont std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); + if ( maxinputs > CC_MAXVINS ) + maxinputs = CC_MAXVINS; + if ( maxinputs > 0 ) + threshold = total/maxinputs; + else threshold = total; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 46eb95a25..a44304ff0 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -466,6 +466,12 @@ static const CRPCCommand vRPCCommands[] = // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, + { "payments", "paymentstxidopret", &payments_txidopret, true }, + { "payments", "paymentscreate", &payments_create, true }, + { "payments", "paymentslist", &payments_list, true }, + { "payments", "paymentsinfo", &payments_info, true }, + { "payments", "paymentsfund", &payments_fund, true }, + { "payments", "paymentsrelease", &payments_release, true }, { "CClib", "cclibaddress", &cclibaddress, true }, { "CClib", "cclibinfo", &cclibinfo, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index abd0ea6a8..4eee49da3 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -288,6 +288,13 @@ extern UniValue marmara_creditloop(const UniValue& params, bool fHelp); extern UniValue marmara_settlement(const UniValue& params, bool fHelp); extern UniValue marmara_lock(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); +extern UniValue payments_release(const UniValue& params, bool fHelp); +extern UniValue payments_fund(const UniValue& params, bool fHelp); +extern UniValue payments_txidopret(const UniValue& params, bool fHelp); +extern UniValue payments_create(const UniValue& params, bool fHelp); +extern UniValue payments_info(const UniValue& params, bool fHelp); +extern UniValue payments_list(const UniValue& params, bool fHelp); + extern UniValue cclibaddress(const UniValue& params, bool fHelp); extern UniValue cclibinfo(const UniValue& params, bool fHelp); extern UniValue cclib(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 445f145fd..c64e22103 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5577,6 +5577,84 @@ UniValue cclib(const UniValue& params, bool fHelp) return(CClib(cp,method,jsonstr)); } +UniValue payments_release(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp,C; char *jsonstr=0; + if ( fHelp || params.size() != 2 ) + throw runtime_error("paymentsrelease createtxid amount\n"); + if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + cp = CCinit(&C,EVAL_PAYMENTS); + return(PaymentsRelease(cp,jsonstr)); +} + +UniValue payments_fund(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp,C; char *jsonstr=0; + if ( fHelp || params.size() < 2 || params.size() > 3 ) + throw runtime_error("paymentsfund createtxid amount [useopret]\n"); + if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + cp = CCinit(&C,EVAL_PAYMENTS); + return(PaymentsFund(cp,jsonstr)); +} + +UniValue payments_txidopret(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp,C; char *jsonstr=0; + if ( fHelp || params.size() < 2 ) + throw runtime_error("paymentstxidopret scriptPubKey opretformat\n"); + if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + cp = CCinit(&C,EVAL_PAYMENTS); + return(PaymentsTxidopret(cp,jsonstr)); +} + +UniValue payments_create(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp,C; char *jsonstr=0; + if ( fHelp || params.size() < 5 ) + throw runtime_error("paymentscreate updateallowed lockedblocks minamount paytxid0,...,paytxidN\n"); + if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + cp = CCinit(&C,EVAL_PAYMENTS); + return(PaymentsCreate(cp,jsonstr)); +} + +UniValue payments_info(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp,C; char *jsonstr=0; + if ( fHelp || params.size() != 1 ) + throw runtime_error("paymentsinfo createtxid\n"); + if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + cp = CCinit(&C,EVAL_PAYMENTS); + return(PaymentsInfo(cp,jsonstr)); +} + +UniValue payments_list(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp,C; char *jsonstr=0; + if ( fHelp || params.size() != 0 ) + throw runtime_error("paymentslist\n"); + if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); + cp = CCinit(&C,EVAL_PAYMENTS); + return(PaymentsList(cp,jsonstr)); +} + UniValue oraclesaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; From 3fec69791ac2af8a7ce622f453479e76e3cca063 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:17:15 -1100 Subject: [PATCH 2995/3904] utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 13e097a8d..a404b78e4 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -515,7 +515,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos)); + utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -606,7 +606,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; - utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos)); + utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) From 20c2d22056b4ee4a11484bf4e77308dbed40cbca Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:18:48 -1100 Subject: [PATCH 2996/3904] Maxinputs --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index a404b78e4..cb3f8b1a6 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -555,7 +555,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 up->vout = vout; sum += up->nValue; //fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos); - if ( n >= maxutxos || sum >= total ) + if ( n >= maxinputs || sum >= total ) break; } } @@ -648,7 +648,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput up->vout = vout; sum += up->nValue; //fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos); - if ( n >= maxutxos || sum >= total ) + if ( n >= maxinputs || sum >= total ) break; } } From 37100ff2c59624874b4581051ed79499282a73c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:21:52 -1100 Subject: [PATCH 2997/3904] CC_MAXVINS --- src/cc/CCtokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 8eff2c749..a81a69b1f 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -586,7 +586,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); } - threshold = total / (maxinputs != 0 ? maxinputs : MAX_CCVINS); + threshold = total / (maxinputs != 0 ? maxinputs : CC_MAXVINS); for (std::vector >::const_iterator it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) { From 5ea0cc3c4dbfe88baae82ba40d02c63e768c91a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:26:26 -1100 Subject: [PATCH 2998/3904] Syntax --- src/cc/payments.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 2a99c9d31..378db54ae 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -30,19 +30,19 @@ // start of consensus code -CScript EncodePaymentsTxidOpRet(int32_t allocation,std::vector scriptPubKey,std::vector opret) +CScript EncodePaymentsTxidOpRet(int32_t allocation,std::vector scriptPubKey,std::vector destopret) { CScript opret; uint8_t evalcode = EVAL_PAYMENTS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'T' << allocation << scriptPubKey << opret); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'T' << allocation << scriptPubKey << destopret); return(opret); } -uint8_t DecodePaymentsTxidOpRet(CScript scriptPubKey,int32_t &allocation,std::vector &scriptPubKey,std::vector &opret) +uint8_t DecodePaymentsTxidOpRet(CScript scriptPubKey,int32_t &allocation,std::vector &destscriptPubKey,std::vector &destopret) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> allocation; ss >> scriptPubKey; ss >> opret) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> allocation; ss >> destscriptPubKey; ss >> destopret) != 0 ) { if ( e == EVAL_PAYMENTS && f == 'T' ) return(f); @@ -149,13 +149,14 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey txidpk,int64_t total,int32_t maxinputs,uint256 createtxid) { - char coinaddr[64]; int64_t nValue,threshold,price,totalinputs = 0; uint256 txid,checktxid,hashBlock; std::vector origpubkey; CTransaction vintx,tx; int32_t iter,vout,n = 0; + char coinaddr[64]; CPubKey Paymentspk; int64_t nValue,threshold,price,totalinputs = 0; uint256 txid,checktxid,hashBlock; std::vector origpubkey; CTransaction vintx,tx; int32_t iter,vout,n = 0; std::vector > unspentOutputs; if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) threshold = total/maxinputs; else threshold = total; + Paymentspk = GetUnspendable(cp,0); for (iter=0; iter<2; iter++) { if ( iter == 0 ) @@ -254,7 +255,7 @@ int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t { val >>= 1; hexdata.resize(val); - decode_hex(hexdata,val,hexstr); + decode_hex(&hexdata[0],val,hexstr); return(0); } else return(-1); } @@ -262,7 +263,7 @@ int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; - CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; std::vector txidoprets; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); From 3e7e013503bb2c4dee8ab061d4d00375d0aeeb32 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:34:20 -1100 Subject: [PATCH 2999/3904] Syntax --- src/cc/payments.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 378db54ae..1715df3c9 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -263,7 +263,7 @@ int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; - CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; std::vector txidoprets; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; std::vector txidoprets; std::string rawtx; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); @@ -287,8 +287,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) checkallocations += allocation; if ( opret.size() > 0 ) { - scriptPubKey.resize(opret.size); - memcpy(&onlyopret[0],&opret[0],opret.size); + scriptPubKey.resize(opret.size()); + memcpy(&onlyopret[0],&opret[0],opret.size()); numoprets++; } } else break; @@ -324,7 +324,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) txidpk = CCtxidaddr(txidaddr,createtxid); if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount,60,createtxid)) >= amount ) { - if ( (CCchange= (inputsum - amount)) > TRANSACTIONS_TXFEE ) + if ( (CCchange= (inputsum - amount)) > PAYMENTS_TXFEE ) mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,CCchange,Paymentspk,txidpk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); return(payments_rawtxresult(result,rawtx,0)); @@ -378,11 +378,11 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) if ( useopret == 0 ) { txidpk = CCtxidaddr(txidaddr,txid); - mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,funds,Paymentspk,txidpk)); + mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,amount,Paymentspk,txidpk)); } else { - mtx.vout.push_back(MakeCCvout(EVAL_PAYMENTS,funds,Paymentspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,amount,Paymentspk)); opret = EncodePaymentsFundOpRet(txid); } rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); @@ -411,10 +411,10 @@ UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) if ( params != 0 && n > 1 && n <= 3 ) { allocation = juint(jitem(params,0),0); - retval0 = payments_parsehexdata(scriptPubKey,jitem(params,1)); - if ( m == 3 ) - retval1 = payments_parsehexdata(opret,jitem(params,2)); - if ( allocation > 0 && retval == 0 && retval1 == 0 && AddNormalinputs(mtx,mypk,PAYMENTS_TXFEE,10) > 0 ) + retval0 = payments_parsehexdata(scriptPubKey,jitem(params,1),0); + if ( n == 3 ) + retval1 = payments_parsehexdata(opret,jitem(params,2),0); + if ( allocation > 0 && retval0 == 0 && retval1 == 0 && AddNormalinputs(mtx,mypk,PAYMENTS_TXFEE,10) > 0 ) { rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsTxidOpRet(allocation,scriptPubKey,opret)); return(payments_rawtxresult(result,rawtx,0)); @@ -433,7 +433,7 @@ UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations=0; + UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk,mypk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations=0; std::string rawtx; cJSON *params = payments_reparse(&n,jsonstr); if ( params != 0 && n >= 4 ) { @@ -488,13 +488,13 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) { - UniValue result(UniValue::VOBJ),a(UniValue:VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,n,flag=0,allocation,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64]; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,n,flag=0,allocation,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64]; uint256 createtxid,hashBlock; cJSON *params = payments_reparse(&n,jsonstr); if ( params != 0 && n == 1 ) { Paymentspk = GetUnspendable(cp,0); - txid = payments_juint256(jitem(params,0)); - if ( myGetTransaction(txid,tx,hashBlock) != 0 ) + createtxid = payments_juint256(jitem(params,0)); + if ( myGetTransaction(createtxid,tx,hashBlock) != 0 ) { if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) { @@ -554,7 +554,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) { std::vector > addressIndex; uint256 txid,hashBlock; - UniValue result(UniValue::VOBJ),a(UniValue:VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; result.push_back(Pair("result","success")); Paymentspk = GetUnspendable(cp,0); GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk); From d2fce5741fa0f9f66101485db45e375328374090 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:37:53 -1100 Subject: [PATCH 3000/3904] .GetHex() --- src/cc/payments.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 1715df3c9..d50116459 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -505,13 +505,13 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) for (i=0; i scriptPubKey,opret; - obj.push_back(Pair("txidopret",txidoprets[i])); + obj.push_back(Pair("txidopret",txidoprets[i].GetHex())); if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { - obj.push_back(Pair("scriptPubKey",scriptPubKey)); + obj.push_back(Pair("scriptPubKey",scriptPubKey.GetHex())); if ( opret.size() != 0 ) { - obj.push_back(Pair("opreturn",opret)); + obj.push_back(Pair("opreturn",opret.GetHex())); numoprets++; } } @@ -525,7 +525,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) } else { - txidpk = CCtxidaddr(txidaddr,txid); + txidpk = CCtxidaddr(txidaddr,createtxid); GetCCaddress1of2(cp,fundsaddr,Paymentspk,txidpk); funds = CCaddress_balance(fundsaddr); result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); From 12c16f0dd7c866d6efd0968b7b096e0c26d8a214 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:38:52 -1100 Subject: [PATCH 3001/3904] ToString --- src/cc/payments.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index d50116459..91fc9245b 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -508,10 +508,10 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) obj.push_back(Pair("txidopret",txidoprets[i].GetHex())); if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { - obj.push_back(Pair("scriptPubKey",scriptPubKey.GetHex())); + obj.push_back(Pair("scriptPubKey",scriptPubKey.ToString())); if ( opret.size() != 0 ) { - obj.push_back(Pair("opreturn",opret.GetHex())); + obj.push_back(Pair("opreturn",opret.ToString())); numoprets++; } } From 2bc975404effaa782a219f4c8138e8030976e100 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 03:41:53 -1100 Subject: [PATCH 3002/3904] Ouster --- src/cc/payments.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 91fc9245b..629e8351e 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -488,7 +488,7 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,n,flag=0,allocation,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64]; uint256 createtxid,hashBlock; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,j,n,flag=0,allocation,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64],*outstr; uint256 createtxid,hashBlock; cJSON *params = payments_reparse(&n,jsonstr); if ( params != 0 && n == 1 ) { @@ -508,12 +508,20 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) obj.push_back(Pair("txidopret",txidoprets[i].GetHex())); if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { - obj.push_back(Pair("scriptPubKey",scriptPubKey.ToString())); + outstr = (char *)malloc(scriptPubKey.size() + opret.size() + 1); + for (j=0; j Date: Thu, 21 Mar 2019 03:46:05 -1100 Subject: [PATCH 3003/3904] CCPayments.h --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c64e22103..83793fdad 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5327,6 +5327,7 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits #include "../cc/CCPrices.h" #include "../cc/CCHeir.h" #include "../cc/CCMarmara.h" +#include "../cc/CCPayments.h" int32_t ensure_CCrequirements(uint8_t evalcode) { From 384ec464ed0cf91982222e9fec0af865f4a3fa20 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 04:13:21 -1100 Subject: [PATCH 3004/3904] -updateflag --- src/cc/payments.cpp | 38 ++++++++++++++++++-------------------- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 629e8351e..42a8bb1d9 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -70,19 +70,19 @@ uint8_t DecodePaymentsFundOpRet(CScript scriptPubKey,uint256 &checktxid) return(0); } -CScript EncodePaymentsOpRet(int32_t updateflag,int32_t lockedblocks,int32_t minrelease,int32_t totalallocations,std::vector txidoprets) +CScript EncodePaymentsOpRet(int32_t lockedblocks,int32_t minrelease,int32_t totalallocations,std::vector txidoprets) { CScript opret; uint8_t evalcode = EVAL_PAYMENTS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << updateflag << lockedblocks << minrelease << totalallocations << txidoprets); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << lockedblocks << minrelease << totalallocations << txidoprets); return(opret); } -uint8_t DecodePaymentsOpRet(CScript scriptPubKey,int32_t &updateflag,int32_t &lockedblocks,int32_t &minrelease,int32_t &totalallocations,std::vector &txidoprets) +uint8_t DecodePaymentsOpRet(CScript scriptPubKey,int32_t &lockedblocks,int32_t &minrelease,int32_t &totalallocations,std::vector &txidoprets) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> updateflag; ss >> lockedblocks; ss >> minrelease; ss >> totalallocations; ss >> txidoprets) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> lockedblocks; ss >> minrelease; ss >> totalallocations; ss >> txidoprets) != 0 ) { if ( e == EVAL_PAYMENTS && f == 'C' ) return(f); @@ -263,7 +263,7 @@ int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; - CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; std::vector txidoprets; std::string rawtx; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; std::vector txidoprets; std::string rawtx; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); @@ -273,7 +273,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) amount = jdouble(jitem(params,1),0) * SATOSHIDEN + 0.0000000049; if ( myGetTransaction(createtxid,tx,hashBlock) != 0 ) { - if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) + if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) { for (i=0; i txidoprets; + CPubKey Paymentspk,mypk,txidpk; uint256 txid,hashBlock; int64_t amount; CScript opret; CTransaction tx; char txidaddr[64]; std::string rawtx; int32_t n,useopret = 0,lockedblocks,minrelease,totalallocations; std::vector txidoprets; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); @@ -368,7 +368,7 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) amount = jdouble(jitem(params,1),0) * SATOSHIDEN + 0.0000000049; if ( n == 3 ) useopret = jint(jitem(params,2),0) != 0; - if ( myGetTransaction(txid,tx,hashBlock) == 0 || tx.vout.size() == 1 || DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) == 0 ) + if ( myGetTransaction(txid,tx,hashBlock) == 0 || tx.vout.size() == 1 || DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) == 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","invalid createtxid")); @@ -433,15 +433,14 @@ UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk,mypk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations=0; std::string rawtx; + UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk,mypk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations=0; std::string rawtx; cJSON *params = payments_reparse(&n,jsonstr); if ( params != 0 && n >= 4 ) { - updateflag = juint(jitem(params,0),0); - lockedblocks = juint(jitem(params,1),0); - minrelease = juint(jitem(params,2),0); - for (i=0; i scriptPubKey,opret; int32_t allocation; @@ -472,7 +471,7 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) if ( AddNormalinputs(mtx,mypk,2*PAYMENTS_TXFEE,60) > 0 ) { mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,PAYMENTS_TXFEE,Paymentspk,Paymentspk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsOpRet(updateflag,lockedblocks,minrelease,totalallocations,txidoprets)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsOpRet(lockedblocks,minrelease,totalallocations,txidoprets)); return(payments_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","error")); @@ -488,7 +487,7 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,j,n,flag=0,allocation,numoprets=0,updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64],*outstr; uint256 createtxid,hashBlock; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,j,n,flag=0,allocation,numoprets=0,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64],*outstr; uint256 createtxid,hashBlock; cJSON *params = payments_reparse(&n,jsonstr); if ( params != 0 && n == 1 ) { @@ -496,9 +495,8 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) createtxid = payments_juint256(jitem(params,0)); if ( myGetTransaction(createtxid,tx,hashBlock) != 0 ) { - if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) + if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) { - result.push_back(Pair("updateable",updateflag!=0?"yes":"no")); result.push_back(Pair("lockedblocks",(int64_t)lockedblocks)); result.push_back(Pair("totalallocations",(int64_t)totalallocations)); result.push_back(Pair("minrelease",(int64_t)minrelease)); @@ -562,7 +560,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) { std::vector > addressIndex; uint256 txid,hashBlock; - UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t updateflag,lockedblocks,minrelease,totalallocations; std::vector txidoprets; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease,totalallocations; std::vector txidoprets; result.push_back(Pair("result","success")); Paymentspk = GetUnspendable(cp,0); GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk); @@ -572,7 +570,7 @@ UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) txid = it->first.txhash; if ( it->first.index == 0 && myGetTransaction(txid,tx,hashBlock) != 0 ) { - if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,updateflag,lockedblocks,minrelease,totalallocations,txidoprets) == 'C' ) + if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) == 'C' ) { a.push_back(uint256_str(str,txid)); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 83793fdad..1668a6cb6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5620,8 +5620,8 @@ UniValue payments_txidopret(const UniValue& params, bool fHelp) UniValue payments_create(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; char *jsonstr=0; - if ( fHelp || params.size() < 5 ) - throw runtime_error("paymentscreate updateallowed lockedblocks minamount paytxid0,...,paytxidN\n"); + if ( fHelp || params.size() < 4 ) + throw runtime_error("paymentscreate lockedblocks minamount paytxid0,...,paytxidN\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; From b7dd9a3685ae5105dbad5950dc8756a4936ed5a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 04:56:23 -1100 Subject: [PATCH 3005/3904] All payments rpc to have one string arg --- src/cc/payments.cpp | 16 +++++++++++----- src/wallet/rpcwallet.cpp | 18 +++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 42a8bb1d9..a945d6a28 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -16,16 +16,22 @@ #include "CCPayments.h" /* - 0) create <- update_allowed flag, locked_blocks, minrelease, list of scriptPubKeys, allocations + 0) txidopret <- allocation, scriptPubKey, opret + 1) create <- locked_blocks, minrelease, list of txidopret - 1) lock amount to global CC address + 2) lock amount opretflag to global CC address with opret or txidaddr without - 2) release amount -> vout[i] will be scriptPubKeys[i] and (amount * allocations[i]) / sumallocations[] (only using vins that have been locked for locked_blocks+). will make a tx with less than amount if it can find enough vins for minrelease amount - - 3) update (vins from all scriptPubkeys) new update_allowed flag, locked_blocks, minrelease, list of scriptPubKeys, allocations (only if update_allowed) + 3) release amount -> vout[i] will be scriptPubKeys[i] and (amount * allocations[i]) / sumallocations[] (only using vins that have been locked for locked_blocks+). will make a tx with less than amount if it can find enough vins for minrelease amount 4) info txid -> display parameters, funds 5) list -> all txids + + First step is to create txids with the info needed in their opreturns. this info is the weight, scriptPubKey and opret if needed. To do that txidopret is used: + + ./c is a script that invokes komodo-cli with the correct -ac_name + + ./komodo-cli -ac_name=PAY paymentstxidopret \"[9,%222102d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388dac%22]\" + ./c paymentstxidopret \"[1,%2221039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775ac%22]\" */ // start of consensus code diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1668a6cb6..2bde855eb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5581,8 +5581,8 @@ UniValue cclib(const UniValue& params, bool fHelp) UniValue payments_release(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; char *jsonstr=0; - if ( fHelp || params.size() != 2 ) - throw runtime_error("paymentsrelease createtxid amount\n"); + if ( fHelp || params.size() != 1 ) + throw runtime_error("paymentsrelease \"[%22createtxid%22,amount]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -5594,8 +5594,8 @@ UniValue payments_release(const UniValue& params, bool fHelp) UniValue payments_fund(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; char *jsonstr=0; - if ( fHelp || params.size() < 2 || params.size() > 3 ) - throw runtime_error("paymentsfund createtxid amount [useopret]\n"); + if ( fHelp || params.size() != 1 ) + throw runtime_error("paymentsfund \"[%22createtxid%22,amount(,useopret)]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -5607,8 +5607,8 @@ UniValue payments_fund(const UniValue& params, bool fHelp) UniValue payments_txidopret(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; char *jsonstr=0; - if ( fHelp || params.size() < 2 ) - throw runtime_error("paymentstxidopret scriptPubKey opretformat\n"); + if ( fHelp || params.size() != 1 ) + throw runtime_error("paymentstxidopret \"[allocation,%22scriptPubKey%22(,%22destopret%22)]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -5620,8 +5620,8 @@ UniValue payments_txidopret(const UniValue& params, bool fHelp) UniValue payments_create(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; char *jsonstr=0; - if ( fHelp || params.size() < 4 ) - throw runtime_error("paymentscreate lockedblocks minamount paytxid0,...,paytxidN\n"); + if ( fHelp || params.size() != 1 ) + throw runtime_error("paymentscreate \"[lockedblocks,minamount,%22paytxid0%22,...,%22paytxidN%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; @@ -5634,7 +5634,7 @@ UniValue payments_info(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; char *jsonstr=0; if ( fHelp || params.size() != 1 ) - throw runtime_error("paymentsinfo createtxid\n"); + throw runtime_error("paymentsinfo \"[%22createtxid%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; From 51f0cd7bdbe2ab0207f4c7a7cdbe003250c35854 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 05:05:04 -1100 Subject: [PATCH 3006/3904] +prints --- src/cc/payments.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index a945d6a28..456bab847 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -30,7 +30,7 @@ ./c is a script that invokes komodo-cli with the correct -ac_name - ./komodo-cli -ac_name=PAY paymentstxidopret \"[9,%222102d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388dac%22]\" + ./c paymentstxidopret \"[9,%222102d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388dac%22]\" ./c paymentstxidopret \"[1,%2221039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775ac%22]\" */ @@ -305,6 +305,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("result","error")); result.push_back(Pair("error","invalid txidoprets[i]")); result.push_back(Pair("txi",(int64_t)i)); + if ( params != 0 ) + free_json(params); return(result); } else if ( checkallocations != totalallocations ) @@ -313,6 +315,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("error","totalallocations mismatch")); result.push_back(Pair("checkallocations",(int64_t)checkallocations)); result.push_back(Pair("totalallocations",(int64_t)totalallocations)); + if ( params != 0 ) + free_json(params); return(result); } else if ( numoprets > 0 ) @@ -320,6 +324,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("result","error")); result.push_back(Pair("error","too many oprets")); result.push_back(Pair("numoprets",(int64_t)numoprets)); + if ( params != 0 ) + free_json(params); return(result); } for (i=0; i PAYMENTS_TXFEE ) mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,CCchange,Paymentspk,txidpk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); + if ( params != 0 ) + free_json(params); return(payments_rawtxresult(result,rawtx,0)); } else @@ -358,6 +366,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("result","error")); result.push_back(Pair("error","parameters error")); } + if ( params != 0 ) + free_json(params); return(result); } @@ -392,6 +402,8 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) opret = EncodePaymentsFundOpRet(txid); } rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); + if ( params != 0 ) + free_json(params); return(payments_rawtxresult(result,rawtx,0)); } else @@ -405,6 +417,8 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("result","error")); result.push_back(Pair("error","parameters error")); } + if ( params != 0 ) + free_json(params); return(result); } @@ -423,6 +437,8 @@ UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) if ( allocation > 0 && retval0 == 0 && retval1 == 0 && AddNormalinputs(mtx,mypk,PAYMENTS_TXFEE,10) > 0 ) { rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsTxidOpRet(allocation,scriptPubKey,opret)); + if ( params != 0 ) + free_json(params); return(payments_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","error")); @@ -432,7 +448,11 @@ UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) { result.push_back(Pair("result","error")); result.push_back(Pair("error","parameters error")); + result.push_back(Pair("n",(int64_t)n)); + fprintf(stderr,"(%s) %p\n",jsonstr,params); } + if ( params != 0 ) + free_json(params); return(result); } @@ -462,6 +482,8 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("error","invalid txidopret")); result.push_back(Pair("txid",txidoprets[i].GetHex())); result.push_back(Pair("txi",(int64_t)i)); + if ( params != 0 ) + free_json(params); return(result); } } @@ -470,6 +492,8 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("result","error")); result.push_back(Pair("error","too many opreturns")); result.push_back(Pair("numoprets",(int64_t)numoprets)); + if ( params != 0 ) + free_json(params); return(result); } mypk = pubkey2pk(Mypubkey()); @@ -478,6 +502,8 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) { mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,PAYMENTS_TXFEE,Paymentspk,Paymentspk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsOpRet(lockedblocks,minrelease,totalallocations,txidoprets)); + if ( params != 0 ) + free_json(params); return(payments_rawtxresult(result,rawtx,0)); } result.push_back(Pair("result","error")); @@ -488,6 +514,8 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("result","error")); result.push_back(Pair("error","parameters error")); } + if ( params != 0 ) + free_json(params); return(result); } @@ -560,6 +588,8 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("result","error")); result.push_back(Pair("error","parameters error")); } + if ( params != 0 ) + free_json(params); return(result); } From 2f752ee6c9b306eeaafbc3caae5f4fa4c9a0c3cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 05:12:21 -1100 Subject: [PATCH 3007/3904] (char *)params[0].get_str().c_str() --- src/wallet/rpcwallet.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2bde855eb..062ef6148 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5580,7 +5580,7 @@ UniValue cclib(const UniValue& params, bool fHelp) UniValue payments_release(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *jsonstr=0; + struct CCcontract_info *cp,C; if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsrelease \"[%22createtxid%22,amount]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) @@ -5588,12 +5588,12 @@ UniValue payments_release(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsRelease(cp,jsonstr)); + return(PaymentsRelease(cp,(char *)params[0].get_str().c_str())); } UniValue payments_fund(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *jsonstr=0; + struct CCcontract_info *cp,C; if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsfund \"[%22createtxid%22,amount(,useopret)]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) @@ -5601,12 +5601,12 @@ UniValue payments_fund(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsFund(cp,jsonstr)); + return(PaymentsFund(cp,(char *)params[0].get_str().c_str())); } UniValue payments_txidopret(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *jsonstr=0; + struct CCcontract_info *cp,C; if ( fHelp || params.size() != 1 ) throw runtime_error("paymentstxidopret \"[allocation,%22scriptPubKey%22(,%22destopret%22)]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) @@ -5614,12 +5614,12 @@ UniValue payments_txidopret(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsTxidopret(cp,jsonstr)); + return(PaymentsTxidopret(cp,(char *)params[0].get_str().c_str())); } UniValue payments_create(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *jsonstr=0; + struct CCcontract_info *cp,C; if ( fHelp || params.size() != 1 ) throw runtime_error("paymentscreate \"[lockedblocks,minamount,%22paytxid0%22,...,%22paytxidN%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) @@ -5627,12 +5627,12 @@ UniValue payments_create(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsCreate(cp,jsonstr)); + return(PaymentsCreate(cp,(char *)params[0].get_str().c_str())); } UniValue payments_info(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *jsonstr=0; + struct CCcontract_info *cp,C; if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsinfo \"[%22createtxid%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) @@ -5640,12 +5640,12 @@ UniValue payments_info(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsInfo(cp,jsonstr)); + return(PaymentsInfo(cp,(char *)params[0].get_str().c_str())); } UniValue payments_list(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; char *jsonstr=0; + struct CCcontract_info *cp,C; if ( fHelp || params.size() != 0 ) throw runtime_error("paymentslist\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) @@ -5653,7 +5653,7 @@ UniValue payments_list(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsList(cp,jsonstr)); + return(PaymentsList(cp,"")); } UniValue oraclesaddress(const UniValue& params, bool fHelp) From 90e3ffbcf0b9541fb5f53a90291ede94b1a13fda Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 05:55:38 -1100 Subject: [PATCH 3008/3904] Check lockedblocks --- src/cc/payments.cpp | 110 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 11 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 456bab847..531aa2a33 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -19,9 +19,9 @@ 0) txidopret <- allocation, scriptPubKey, opret 1) create <- locked_blocks, minrelease, list of txidopret - 2) lock amount opretflag to global CC address with opret or txidaddr without + 2) fund createtxid amount opretflag to global CC address with opret or txidaddr without - 3) release amount -> vout[i] will be scriptPubKeys[i] and (amount * allocations[i]) / sumallocations[] (only using vins that have been locked for locked_blocks+). will make a tx with less than amount if it can find enough vins for minrelease amount + 3) release amount -> vout[i] will be scriptPubKeys[i] and (amount * allocations[i]) / sumallocations[] (only using vins that have been locked for locked_blocks+). 4) info txid -> display parameters, funds 5) list -> all txids @@ -30,8 +30,43 @@ ./c is a script that invokes komodo-cli with the correct -ac_name - ./c paymentstxidopret \"[9,%222102d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388dac%22]\" - ./c paymentstxidopret \"[1,%2221039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775ac%22]\" + ./c paymentstxidopret \"[9,%222102d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388dac%22]\" -> rawhex with txid 95d9fc8d8a3ef63693c7427e59ff5e177ef63b7345d5f6d6497ac262699a8def + + ./c paymentstxidopret \"[1,%2221039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775ac%22]\" -> rawhex txid 00469695a08b975ceaf7258896abbf1455eb0f383e8a98fc650deace4cbf02a1 + + now we have 2 txid with the required info in the opreturn. one of them has a 9 and the other a 1 for a 90%/10% split. + + ./c paymentscreate \"[0,0,%2295d9fc8d8a3ef63693c7427e59ff5e177ef63b7345d5f6d6497ac262699a8def%22,%2200469695a08b975ceaf7258896abbf1455eb0f383e8a98fc650deace4cbf02a1%22]\" -> created txid 318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a that will be the createtxid that the other rpc calls will use. + + lets see if this appears in the list + + ./c paymentslist -> + { + "result": "success", + "createtxids": [ + "318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a" + ] + } + + It appeared! now lets get more info on it: + ./c paymentsinfo \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22]\" + { + "lockedblocks": 0, + "totalallocations": 10, + "minrelease": 0, + "RWRM36sC8jSctyFZtsu7CyDcHYPdZX7nPZ": 0.00000000, + "REpyKi7avsVduqZ3eimncK4uKqSArLTGGK": 0.00000000, + "totalfunds": 0.00000000, + "result": "success" + } + + There are 2 possible places the funds for this createtxid can be, the first is the special address that is derived from combining the globalCC address with the txidaddr. txidaddr is a non-spendable markeraddress created by converting the txid into a 33 byte pubkey by prefixing 0x02 to the txid. It is a 1of2 address, so it doesnt matter that nobody knows the privkey for this txidaddr. the second address is the global CC address and only utxo to that address with an opreturn containing the createtxid are funds valid for this payments CC createtxid + + next let us add some funds to it. the funds can be to either of the two addresses, controlled by useopret (defaults to 0) + + ./c paymentsfund \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1,0]\" + + */ // start of consensus code @@ -153,9 +188,9 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // helper functions for rpc calls in rpcwallet.cpp -int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey txidpk,int64_t total,int32_t maxinputs,uint256 createtxid) +int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey txidpk,int64_t total,int32_t maxinputs,uint256 createtxid,int32_t latestheight) { - char coinaddr[64]; CPubKey Paymentspk; int64_t nValue,threshold,price,totalinputs = 0; uint256 txid,checktxid,hashBlock; std::vector origpubkey; CTransaction vintx,tx; int32_t iter,vout,n = 0; + char coinaddr[64]; CPubKey Paymentspk; int64_t nValue,threshold,price,totalinputs = 0; uint256 txid,checktxid,hashBlock; std::vector origpubkey; CTransaction vintx,tx; int32_t iter,vout,ht,n = 0; std::vector > unspentOutputs; if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; @@ -175,6 +210,13 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP vout = (int32_t)it->first.index; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { + if ( latestheight != 0 ) + { + if ( (ht= komodo_blockheight(hashBlock)) == 0 ) + continue; + else if ( ht > latestheight ) + continue; + } if ( iter == 0 ) { std::vector scriptPubKey,opret; @@ -268,7 +310,8 @@ int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { - CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; + int32_t latestheight,nextheight = komodo_nextheight(); + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; std::vector txidoprets; std::string rawtx; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); @@ -281,6 +324,21 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) { + if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","negative parameter")); + return(result); + } + latestheight = (nextheight - lockedblocks - 1); + if ( amount < minrelease ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","amount too smal")); + result.push_back(Pair("amount",ValueFromAmount(amount))); + result.push_back(Pair("minrelease",ValueFromAmount(minrelease))); + return(result); + } for (i=0; i scriptPubKey,opret; @@ -334,9 +392,9 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i].nValue /= totalallocations; } txidpk = CCtxidaddr(txidaddr,createtxid); - if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount,60,createtxid)) >= amount ) + if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount ) { - if ( (CCchange= (inputsum - amount)) > PAYMENTS_TXFEE ) + if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,CCchange,Paymentspk,txidpk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) @@ -391,6 +449,14 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) } else if ( AddNormalinputs(mtx,mypk,amount+PAYMENTS_TXFEE,60) > 0 ) { + if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","negative parameter")); + if ( params != 0 ) + free_json(params); + return(result); + } if ( useopret == 0 ) { txidpk = CCtxidaddr(txidaddr,txid); @@ -439,7 +505,7 @@ UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsTxidOpRet(allocation,scriptPubKey,opret)); if ( params != 0 ) free_json(params); - return(payments_rawtxresult(result,rawtx,0)); + return(payments_rawtxresult(result,rawtx,1)); } result.push_back(Pair("result","error")); result.push_back(Pair("error","invalid params or cant find txfee")); @@ -465,6 +531,14 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) { lockedblocks = juint(jitem(params,0),0); minrelease = juint(jitem(params,1),0); + if ( lockedblocks < 0 || minrelease < 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","negative parameter")); + if ( params != 0 ) + free_json(params); + return(result); + } for (i=0; i 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) { + if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","negative parameter")); + if ( params != 0 ) + free_json(params); + return(result); + } result.push_back(Pair("lockedblocks",(int64_t)lockedblocks)); result.push_back(Pair("totalallocations",(int64_t)totalallocations)); result.push_back(Pair("minrelease",(int64_t)minrelease)); @@ -597,7 +679,6 @@ UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) { std::vector > addressIndex; uint256 txid,hashBlock; UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease,totalallocations; std::vector txidoprets; - result.push_back(Pair("result","success")); Paymentspk = GetUnspendable(cp,0); GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk); SetCCtxids(addressIndex,markeraddr); @@ -608,10 +689,17 @@ UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) { if ( tx.vout.size() > 0 && DecodePaymentsOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) == 'C' ) { + if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","negative parameter")); + return(result); + } a.push_back(uint256_str(str,txid)); } } } + result.push_back(Pair("result","success")); result.push_back(Pair("createtxids",a)); return(result); } From 7f14b077b7260e695ee9d0b759b428d16d956a03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:06:18 -1100 Subject: [PATCH 3009/3904] +print --- src/cc/payments.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 531aa2a33..21efc0623 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -64,9 +64,13 @@ next let us add some funds to it. the funds can be to either of the two addresses, controlled by useopret (defaults to 0) - ./c paymentsfund \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1,0]\" + ./c paymentsfund \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1,0]\" -> txid 28f69b925bb7a21d2a3ba2327e85eb2031b014e976e43f5c2c6fb8a76767b221, which indeed sent funds to RWRM36sC8jSctyFZtsu7CyDcHYPdZX7nPZ without an opreturn and it appears on the payments info. + + ./c paymentsfund \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1,1]\" -> txid cc93330b5c951b724b246b3b138d00519c33f2a600a7c938bc9e51aff6e20e32, which indeed sent funds to REpyKi7avsVduqZ3eimncK4uKqSArLTGGK with an opreturn and it appears on the payments info. +./c paymentsrelease \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1.5]\" -> + */ // start of consensus code @@ -208,20 +212,30 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP { txid = it->first.txhash; vout = (int32_t)it->first.index; + fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr) if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { if ( latestheight != 0 ) { if ( (ht= komodo_blockheight(hashBlock)) == 0 ) + { + fprintf(stderr,"null ht\n"); continue; + } else if ( ht > latestheight ) + { + fprintf(stderr,"ht.%d > lastheight.%d\n",ht,lastheight); continue; + } } if ( iter == 0 ) { std::vector scriptPubKey,opret; if ( myGetTransaction(txid,tx,hashBlock) == 0 || tx.vout.size() < 2 || DecodePaymentsFundOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,checktxid) != 'F' || checktxid != createtxid ) + { + fprintf(stderr,"bad opret %s vs %s\n",checktxid.GetHex().c_str(),createtxid.GetHex().c_str()); continue; + } } if ( (nValue= IsPaymentsvout(cp,vintx,vout)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { @@ -232,7 +246,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; - } + } else fprintf(stderr,"nValue %.8f vs threshold %.8f\n",(double)nValue/COIN,(double)threshold/COIN); } } } From 33e35e4dd3eb2bc99aa443605fb32d520a1bc254 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:08:55 -1100 Subject: [PATCH 3010/3904] ; --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 21efc0623..e4c567cf7 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -212,7 +212,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP { txid = it->first.txhash; vout = (int32_t)it->first.index; - fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr) + fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { if ( latestheight != 0 ) From d6c1609dad3d0721fc15435e4dd7f13446ef2650 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:09:55 -1100 Subject: [PATCH 3011/3904] latestheight --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index e4c567cf7..789918354 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -224,7 +224,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP } else if ( ht > latestheight ) { - fprintf(stderr,"ht.%d > lastheight.%d\n",ht,lastheight); + fprintf(stderr,"ht.%d > lastheight.%d\n",ht,latestheight); continue; } } From 9894fad3526b11daf81b5bc0280a8f5aa2f87dfc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:12:47 -1100 Subject: [PATCH 3012/3904] IsPaymentsvout fix --- src/cc/payments.cpp | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 789918354..805e2e031 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -135,55 +135,17 @@ uint8_t DecodePaymentsOpRet(CScript scriptPubKey,int32_t &lockedblocks,int32_t & return(0); } -int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v,char *cmpaddr) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) { - if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) + if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && (cmpaddr[0] == 0 || strcmp(destaddr,cmpaddr) == 0) ) return(tx.vout[v].nValue); } return(0); } -bool PaymentsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) -{ - static uint256 zerohash; - CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - for (i=0; iismyvin)(tx.vin[i].scriptSig) != 0 ) - { - //fprintf(stderr,"vini.%d check mempool\n",i); - if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) - return eval->Invalid("cant find vinTx"); - else - { - //fprintf(stderr,"vini.%d check hash and vout\n",i); - if ( hashBlock == zerohash ) - return eval->Invalid("cant Payments from mempool"); - if ( (assetoshis= IsPaymentsvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) - inputs += assetoshis; - } - } - } - for (i=0; iInvalid("mismatched inputs != outputs + txfee"); - } - else return(true); -} - bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { return(true); @@ -237,7 +199,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP continue; } } - if ( (nValue= IsPaymentsvout(cp,vintx,vout)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + if ( (nValue= IsPaymentsvout(cp,vintx,vout,coinaddr)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From ee5fe1118204ec8b08a65897fa70ce321ed514ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:19:47 -1100 Subject: [PATCH 3013/3904] GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); --- src/cc/payments.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 805e2e031..24946993d 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -288,7 +288,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { int32_t latestheight,nextheight = komodo_nextheight(); CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; - CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64]; std::vector txidoprets; std::string rawtx; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; std::string rawtx; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); @@ -372,6 +372,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,CCchange,Paymentspk,txidpk)); + GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); + CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); From e25929eb0d763fe2feba5820b21ed9b5f52d8085 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:22:29 -1100 Subject: [PATCH 3014/3904] -print --- src/cc/payments.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 24946993d..f3be6fd62 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -174,8 +174,8 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP { txid = it->first.txhash; vout = (int32_t)it->first.index; - fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + //fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); + if ( vout == 0 && GetTransaction(txid,vintx,hashBlock,false) != 0 ) { if ( latestheight != 0 ) { @@ -208,7 +208,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; - } else fprintf(stderr,"nValue %.8f vs threshold %.8f\n",(double)nValue/COIN,(double)threshold/COIN); + } //else fprintf(stderr,"nValue %.8f vs threshold %.8f\n",(double)nValue/COIN,(double)threshold/COIN); } } } @@ -448,7 +448,7 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); if ( params != 0 ) free_json(params); - return(payments_rawtxresult(result,rawtx,0)); + return(payments_rawtxresult(result,rawtx,1)); } else { @@ -556,7 +556,7 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsOpRet(lockedblocks,minrelease,totalallocations,txidoprets)); if ( params != 0 ) free_json(params); - return(payments_rawtxresult(result,rawtx,0)); + return(payments_rawtxresult(result,rawtx,1)); } result.push_back(Pair("result","error")); result.push_back(Pair("error","not enough normal funds")); From 423e04e0a4ae51e43cb265c1dcbb95f30c014fd2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:23:00 -1100 Subject: [PATCH 3015/3904] +comment --- src/cc/payments.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index f3be6fd62..a3c8bee95 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -69,7 +69,9 @@ ./c paymentsfund \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1,1]\" -> txid cc93330b5c951b724b246b3b138d00519c33f2a600a7c938bc9e51aff6e20e32, which indeed sent funds to REpyKi7avsVduqZ3eimncK4uKqSArLTGGK with an opreturn and it appears on the payments info. -./c paymentsrelease \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1.5]\" -> +./c paymentsrelease \"[%22318d827cc6d8f25f40517e7fb0982e3f707b4aa749d322483fc336686a87b28a%22,1.5]\" -> a8d5dbbb8ee94c05e75c4f3c5221091f59dcb86e0e9c4e1e3d2cf69e6fce6b81 + + it used both fund utxos */ From 403ee2bb1554a4936f17f03c72fe1b1531237c1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:25:43 -1100 Subject: [PATCH 3016/3904] Numoprets > 1 --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index a3c8bee95..2a73194fb 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -355,7 +355,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) free_json(params); return(result); } - else if ( numoprets > 0 ) + else if ( numoprets > 1 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","too many oprets")); From 089f13299c2c6a3a6fcb5327542ec6f3c5c2aa87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 06:36:19 -1100 Subject: [PATCH 3017/3904] Validation comments --- src/cc/payments.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 2a73194fb..8fa87bd3d 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -150,6 +150,10 @@ int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { + // one of two addresses + // change must go to 1of2 txidaddr + // only 'F' or 1of2 txidaddr can be spent + // all vouts must match exactly return(true); } // end of consensus code From 9cead95733a8812c54a63a4ca2d77913aa59df61 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Thu, 21 Mar 2019 22:51:40 +0300 Subject: [PATCH 3018/3904] [fix] player lose focus, when call [i] inventory with MAXPACK (23) items --- src/cc/rogue/things.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 39c7b94b7..e0cf48454 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -527,6 +527,7 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) touchwin(tw); wrefresh(tw); wait_for(rs,' '); + if (md_hasclreol()) { werase(tw); @@ -543,16 +544,31 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) } else { + char *promptex = "--Wait 5 sec.--"; wmove(hw, LINES - 1, 0); - waddstr(hw, prompt); + waddstr(hw, newpage ? promptex : prompt); wrefresh(hw); - wait_for(rs,' '); + + if (newpage) { + + #ifdef _WIN32 + #ifdef _MSC_VER + #define sleep(x) Sleep(1000*(x)) + #endif + #endif + sleep(5); + + } else + wait_for(rs, ' '); + clearok(curscr, TRUE); wclear(hw); + touchwin(stdscr); } newpage = TRUE; line_cnt = 0; + maxlen = (int) strlen(prompt); } if (fmt != NULL && !(line_cnt == 0 && *fmt == '\0')) From 350c8a72aab49bbe0b3bc64427c5eee5b7975c43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 20:01:40 -1100 Subject: [PATCH 3019/3904] Shift payments vouts to put change in vout0 --- src/cc/payments.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 8fa87bd3d..a9e55fd50 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -321,6 +321,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("minrelease",ValueFromAmount(minrelease))); return(result); } + txidpk = CCtxidaddr(txidaddr,createtxid); + mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,0,Paymentspk,txidpk)); for (i=0; i scriptPubKey,opret; @@ -370,14 +372,13 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) } for (i=0; i= amount ) { if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) - mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,CCchange,Paymentspk,txidpk)); + mtx.vout[0].nValue = CCchange; GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); From fbc2feefa9fb44fcd7adeb0c9d8dc532d21b4bbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 20:41:06 -1100 Subject: [PATCH 3020/3904] Test --- src/cc/payments.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index a9e55fd50..08b1bca09 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -313,12 +313,12 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) return(result); } latestheight = (nextheight - lockedblocks - 1); - if ( amount < minrelease ) + if ( amount < minrelease*COIN ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","amount too smal")); result.push_back(Pair("amount",ValueFromAmount(amount))); - result.push_back(Pair("minrelease",ValueFromAmount(minrelease))); + result.push_back(Pair("minrelease",ValueFromAmount(minrelease*COIN))); return(result); } txidpk = CCtxidaddr(txidaddr,createtxid); @@ -375,6 +375,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i+1].nValue *= amount; mtx.vout[i+1].nValue /= totalallocations; } + fprintf(stderr,"addinputs %.8f\n",(double)amount/COIN); if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount ) { if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) From a1810eb2d39e285fb1c9108eb20b52e9dc007253 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 20:46:03 -1100 Subject: [PATCH 3021/3904] Test --- src/cc/payments.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 08b1bca09..744e82c5a 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -240,7 +240,7 @@ UniValue payments_rawtxresult(UniValue &result,std::string rawtx,int32_t broadca cJSON *payments_reparse(int32_t *nump,char *jsonstr) { - cJSON *params; char *newstr; int32_t i,j; + cJSON *params=0; char *newstr; int32_t i,j; *nump = 0; if ( jsonstr != 0 ) { @@ -263,11 +263,11 @@ cJSON *payments_reparse(int32_t *nump,char *jsonstr) } newstr[j] = 0; params = cJSON_Parse(newstr); - if ( 0 && params != 0 ) + if ( 1 && params != 0 ) printf("new.(%s) -> %s\n",newstr,jprint(params,0)); free(newstr); *nump = cJSON_GetArraySize(params); - } else params = 0; + } return(params); } @@ -295,6 +295,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) int32_t latestheight,nextheight = komodo_nextheight(); CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; std::string rawtx; + fprintf(stderr,"jsonstr.(%s)\n",jsonstr); cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); From c00a8f968d0f274f0bdc87aedaf69e42ae4380de Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 20:55:33 -1100 Subject: [PATCH 3022/3904] Add txidpk marker out --- src/cc/payments.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 744e82c5a..079a64329 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -381,6 +381,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; + mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); From 31c363cdad793d74592254fc371800901201c0d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:01:07 -1100 Subject: [PATCH 3023/3904] +prints --- src/cc/payments.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 079a64329..4c8958e28 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -180,7 +180,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP { txid = it->first.txhash; vout = (int32_t)it->first.index; - //fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); + fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); if ( vout == 0 && GetTransaction(txid,vintx,hashBlock,false) != 0 ) { if ( latestheight != 0 ) @@ -212,6 +212,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP nValue = it->second.satoshis; totalinputs += nValue; n++; + fprintf(stderr,"iter.%d %s/v%d %s %.8f\n",iter,txid.GetHex().c_str(),vout,coinaddr,(double)nValue/COIN); if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; } //else fprintf(stderr,"nValue %.8f vs threshold %.8f\n",(double)nValue/COIN,(double)threshold/COIN); @@ -263,7 +264,7 @@ cJSON *payments_reparse(int32_t *nump,char *jsonstr) } newstr[j] = 0; params = cJSON_Parse(newstr); - if ( 1 && params != 0 ) + if ( 0 && params != 0 ) printf("new.(%s) -> %s\n",newstr,jprint(params,0)); free(newstr); *nump = cJSON_GetArraySize(params); @@ -295,7 +296,6 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) int32_t latestheight,nextheight = komodo_nextheight(); CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; std::string rawtx; - fprintf(stderr,"jsonstr.(%s)\n",jsonstr); cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); From f0d03de3a738be57cd1c493f67719fd75c606713 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:04:25 -1100 Subject: [PATCH 3024/3904] +prints --- src/cc/payments.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 4c8958e28..2b3dcb7e2 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -381,9 +381,12 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; + fprintf(stderr,"CCchange %.8f\n",(double)CCchange/COIN); mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); + fprintf(stderr,"destaddr.(%s)\n",destaddr); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); + fprintf(stderr,"set 1of2\n"); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); From 6e0d22cf2c1a8e4d5819d3c639472fbf514ff33d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:05:00 -1100 Subject: [PATCH 3025/3904] +print --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 2b3dcb7e2..d1f7e273e 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -386,7 +386,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); fprintf(stderr,"destaddr.(%s)\n",destaddr); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); - fprintf(stderr,"set 1of2\n"); + fprintf(stderr,"set 1of2 opretsize.%d\n",(int32_t)onlyopret.size()); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); From 1df9808b0cf2cd5788b637a3d77086d986f8b332 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:09:22 -1100 Subject: [PATCH 3026/3904] +print --- src/cc/CCtx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index cb3f8b1a6..33be469c3 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -75,7 +75,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran othercond = MakeCCcond1(cp->evalcode, unspendablepk); GetCCaddress1of2(cp,CC1of2CCaddr,unspendablepk,unspendablepk); - //printf("evalcode.%d (%s)\n",cp->evalcode,unspendable); + fprintf(stderr,"evalcode.%d (%s)\n",cp->evalcode,unspendable); // tokens support: // to spend from dual/three-eval mypk vout @@ -96,6 +96,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. for (i=0; i Date: Thu, 21 Mar 2019 21:11:12 -1100 Subject: [PATCH 3027/3904] -% --- src/cc/CCtx.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 33be469c3..734397227 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -96,7 +96,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. for (i=0; i Date: Thu, 21 Mar 2019 21:17:06 -1100 Subject: [PATCH 3028/3904] +print --- src/cc/CCtx.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 734397227..e99a5b6ee 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -75,7 +75,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran othercond = MakeCCcond1(cp->evalcode, unspendablepk); GetCCaddress1of2(cp,CC1of2CCaddr,unspendablepk,unspendablepk); - fprintf(stderr,"evalcode.%d (%s)\n",cp->evalcode,unspendable); + //fprintf(stderr,"evalcode.%d (%s)\n",cp->evalcode,unspendable); // tokens support: // to spend from dual/three-eval mypk vout @@ -96,7 +96,6 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. for (i=0; i (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); + fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { @@ -183,7 +180,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); + fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, unspendabletokensaddr) == 0) { @@ -212,7 +209,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); + fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = cp->coins1of2priv;//myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -280,7 +277,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } } } else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str()); - } + fprintf(stderr,"done i.%d of %d\n",i,n); + } if ( mycond != 0 ) cc_free(mycond); if ( condCC2 != 0 ) From 857b9f650c2f4acfa36cf50e026515f3bf081d16 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:20:56 -1100 Subject: [PATCH 3029/3904] +print --- src/cc/CCtx.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index e99a5b6ee..d26b14f6b 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -48,7 +48,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran int32_t i,flag,utxovout,n,err = 0; char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], unspendabletokensaddr[64],CC1of2CCaddr[64]; uint8_t *privkey, myprivkey[32], unspendablepriv[32], /*tokensunspendablepriv[32],*/ *msg32 = 0; - CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; + CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond=0, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CPubKey unspendablepk /*, tokensunspendablepk*/; struct CCcontract_info *cpTokens, tokensC; globalpk = GetUnspendable(cp,0); @@ -156,7 +156,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); + //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { @@ -180,7 +180,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = unspendablepriv; cond = othercond; - fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); + //fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, unspendabletokensaddr) == 0) { @@ -209,7 +209,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); + //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = cp->coins1of2priv;//myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -279,6 +279,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str()); fprintf(stderr,"done i.%d of %d\n",i,n); } + fprintf(stderr,"free A\n"); if ( mycond != 0 ) cc_free(mycond); if ( condCC2 != 0 ) @@ -291,6 +292,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cc_free(othercond3); if ( othercond4 != 0 ) cc_free(othercond4); + fprintf(stderr,"free B\n"); if ( othercond1of2 != 0 ) cc_free(othercond1of2); if ( othercond1of2tokens != 0 ) @@ -301,6 +303,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cc_free(mysingletokenscond); if ( othertokenscond != 0 ) cc_free(othertokenscond); + fprintf(stderr,"free C\n"); std::string strHex = EncodeHexTx(mtx); if ( strHex.size() > 0 ) return(strHex); From 4657f4db229acb9e58fee4eb936338852a9c2762 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:21:57 -1100 Subject: [PATCH 3030/3904] -print --- src/cc/payments.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index d1f7e273e..eadc3b847 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -376,17 +376,13 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i+1].nValue *= amount; mtx.vout[i+1].nValue /= totalallocations; } - fprintf(stderr,"addinputs %.8f\n",(double)amount/COIN); if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount ) { if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; - fprintf(stderr,"CCchange %.8f\n",(double)CCchange/COIN); mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); - fprintf(stderr,"destaddr.(%s)\n",destaddr); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); - fprintf(stderr,"set 1of2 opretsize.%d\n",(int32_t)onlyopret.size()); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); From 5560b8574b1bfcf8f8ac99219b06405940d76736 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:25:51 -1100 Subject: [PATCH 3031/3904] Test --- src/cc/CCtx.cpp | 5 +---- src/cc/payments.cpp | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index d26b14f6b..3df8026ac 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -277,9 +277,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } } } else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str()); - fprintf(stderr,"done i.%d of %d\n",i,n); } - fprintf(stderr,"free A\n"); if ( mycond != 0 ) cc_free(mycond); if ( condCC2 != 0 ) @@ -292,7 +290,6 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cc_free(othercond3); if ( othercond4 != 0 ) cc_free(othercond4); - fprintf(stderr,"free B\n"); if ( othercond1of2 != 0 ) cc_free(othercond1of2); if ( othercond1of2tokens != 0 ) @@ -303,8 +300,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran cc_free(mysingletokenscond); if ( othertokenscond != 0 ) cc_free(othertokenscond); - fprintf(stderr,"free C\n"); std::string strHex = EncodeHexTx(mtx); + fprintf(stderr,"hex.(%s)\n",strHex.c_str()); if ( strHex.size() > 0 ) return(strHex); else return("0"); diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index eadc3b847..1e7b6626b 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -180,7 +180,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP { txid = it->first.txhash; vout = (int32_t)it->first.index; - fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); + //fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); if ( vout == 0 && GetTransaction(txid,vintx,hashBlock,false) != 0 ) { if ( latestheight != 0 ) @@ -212,7 +212,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP nValue = it->second.satoshis; totalinputs += nValue; n++; - fprintf(stderr,"iter.%d %s/v%d %s %.8f\n",iter,txid.GetHex().c_str(),vout,coinaddr,(double)nValue/COIN); + //fprintf(stderr,"iter.%d %s/v%d %s %.8f\n",iter,txid.GetHex().c_str(),vout,coinaddr,(double)nValue/COIN); if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; } //else fprintf(stderr,"nValue %.8f vs threshold %.8f\n",(double)nValue/COIN,(double)threshold/COIN); From 5af957ff1393580b801fdede8942a835111fa51e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:37:19 -1100 Subject: [PATCH 3032/3904] Test --- src/cc/CCtx.cpp | 1 - src/cc/payments.cpp | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 3df8026ac..ed06c1a4d 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -301,7 +301,6 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran if ( othertokenscond != 0 ) cc_free(othertokenscond); std::string strHex = EncodeHexTx(mtx); - fprintf(stderr,"hex.(%s)\n",strHex.c_str()); if ( strHex.size() > 0 ) return(strHex); else return("0"); diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 1e7b6626b..b2ad47d32 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -230,6 +230,7 @@ UniValue payments_rawtxresult(UniValue &result,std::string rawtx,int32_t broadca result.push_back(Pair("hex",rawtx)); if ( DecodeHexTx(tx,rawtx) != 0 ) { + fprintf(stderr,"decoded\n"); if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) RelayTransaction(tx); result.push_back(Pair("txid",tx.GetHash().ToString())); @@ -295,7 +296,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { int32_t latestheight,nextheight = komodo_nextheight(); CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; - CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; std::string rawtx; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,m,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); @@ -324,7 +325,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) } txidpk = CCtxidaddr(txidaddr,createtxid); mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,0,Paymentspk,txidpk)); - for (i=0; i scriptPubKey,opret; vout.nValue = 0; @@ -343,7 +345,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) } else break; mtx.vout.push_back(vout); } - if ( i != txidoprets.size() ) + if ( i != m ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","invalid txidoprets[i]")); @@ -371,13 +373,14 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) free_json(params); return(result); } - for (i=0; i= amount ) { + std::string rawtx; if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); @@ -386,6 +389,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); + fprintf(stderr,"got rawtx.(%s)\n",rawtx.c_str()); return(payments_rawtxresult(result,rawtx,0)); } else From 62b92bad4edef9d8181232c7cb47da8fd8036b9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 21:45:40 -1100 Subject: [PATCH 3033/3904] Move variable --- src/cc/payments.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index b2ad47d32..d1e11dae5 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -230,7 +230,6 @@ UniValue payments_rawtxresult(UniValue &result,std::string rawtx,int32_t broadca result.push_back(Pair("hex",rawtx)); if ( DecodeHexTx(tx,rawtx) != 0 ) { - fprintf(stderr,"decoded\n"); if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) RelayTransaction(tx); result.push_back(Pair("txid",tx.GetHash().ToString())); @@ -389,7 +388,6 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); - fprintf(stderr,"got rawtx.(%s)\n",rawtx.c_str()); return(payments_rawtxresult(result,rawtx,0)); } else From b897d56363f0cd41ec580ab53f5cc52433217521 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 22 Mar 2019 16:54:01 +0800 Subject: [PATCH 3034/3904] . --- src/cc/CCPayments.h | 2 +- src/cc/payments.cpp | 23 +++++++++++++++++++++-- src/wallet/rpcwallet.cpp | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/cc/CCPayments.h b/src/cc/CCPayments.h index 247a0f2ec..56d36f74e 100644 --- a/src/cc/CCPayments.h +++ b/src/cc/CCPayments.h @@ -29,6 +29,6 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr); UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr); UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr); UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr); -UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr); +UniValue PaymentsList(struct CCcontract_info *cp); #endif diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index d1e11dae5..8148be180 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -152,8 +152,23 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & { // one of two addresses // change must go to 1of2 txidaddr + // change is/must be in vout[0] // only 'F' or 1of2 txidaddr can be spent // all vouts must match exactly + BOOST_FOREACH(const CTxIn& vin, tx) + { + uint256 blockhash; CTransaction txin; + if ( myGetTransaction(vin.prevout.hash,txin,blockhash) ) + { + fprintf(stderr, "vin txid.%s\n", txin.GetHex().c_str()); + } + } + + BOOST_FOREACH(const CTxOut& vout, tx) + { + fprintf(stderr, "vout txid.%s\n", vout.hash.GetHex().c_str()); + } + return(true); } // end of consensus code @@ -377,6 +392,10 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i+1].nValue *= amount; mtx.vout[i+1].nValue /= totalallocations; } +<<<<<<< Updated upstream +======= + //fprintf(stderr,"addinputs %.8f\n",(double)amount/COIN); +>>>>>>> Stashed changes if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount ) { std::string rawtx; @@ -388,7 +407,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); - return(payments_rawtxresult(result,rawtx,0)); + return(payments_rawtxresult(result,rawtx,1)); } else { @@ -664,7 +683,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) return(result); } -UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) +UniValue PaymentsList(struct CCcontract_info *cp) { std::vector > addressIndex; uint256 txid,hashBlock; UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease,totalallocations; std::vector txidoprets; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 062ef6148..80ad2afe0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5653,7 +5653,7 @@ UniValue payments_list(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsList(cp,"")); + return(PaymentsList(cp)); } UniValue oraclesaddress(const UniValue& params, bool fHelp) From 5ec3125c455274cbba8a9557b4069e36546b0dc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 22:06:23 -1100 Subject: [PATCH 3035/3904] Gamescc stub --- src/cc/cclib.cpp | 12 ++++++++ src/cc/gamescc.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++ src/cc/gamescc.h | 31 +++++++++++++++++++ src/cc/makegames | 7 +++++ 4 files changed, 127 insertions(+) create mode 100644 src/cc/gamescc.cpp create mode 100644 src/cc/gamescc.h create mode 100755 src/cc/makegames diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 1330c6b3e..c8e714ba2 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -38,6 +38,9 @@ std::string MYCCLIBNAME = (char *)"rogue"; #elif BUILD_CUSTOMCC #include "customcc.h" +#elif BUILD_GAMESCC +#include "gamescc.h" + #else #define EVAL_SUDOKU 17 #define EVAL_MUSIG 18 @@ -73,6 +76,8 @@ CClib_methods[] = { (char *)"rogue", (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, 'X', EVAL_ROGUE }, #elif BUILD_CUSTOMCC RPC_FUNCS +#elif BUILD_GAMESCC + RPC_FUNCS #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -222,6 +227,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) } #elif BUILD_CUSTOMCC CUSTOM_DISPATCH +#elif BUILD_GAMESCC + CUSTOM_DISPATCH #else if ( cp->evalcode == EVAL_SUDOKU ) { @@ -420,6 +427,8 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(rogue_validate(cp,height,eval,tx)); #elif BUILD_CUSTOMCC return(custom_validate(cp,height,eval,tx)); +#elif BUILD_GAMESCC + return(games_validate(cp,height,eval,tx)); #else if ( cp->evalcode == EVAL_SUDOKU ) return(sudoku_validate(cp,height,eval,tx)); @@ -677,6 +686,9 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) #elif BUILD_CUSTOMCC #include "customcc.cpp" +#elif BUILD_GAMESCC +#include "gamescc.cpp" + #else #include "sudoku.cpp" #include "musig.cpp" diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp new file mode 100644 index 000000000..f5f9dfba6 --- /dev/null +++ b/src/cc/gamescc.cpp @@ -0,0 +1,77 @@ + +CScript games_opret(uint8_t funcid,CPubKey pk) +{ + CScript opret; uint8_t evalcode = EVAL_CUSTOM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); + return(opret); +} + +uint8_t games_opretdecode(CPubKey &pk,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_CUSTOM ) + { + return(f); + } + return(0); +} + +UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) +{ + CTransaction tx; + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + +UniValue games_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + result.push_back(Pair("message","just an example of an information returning rpc")); + return(result); +} + +// send yourself 1 coin to your CC address using normal utxo from your -pubkey + +UniValue games_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); std::string rawtx; + UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0; + if ( txfee == 0 ) + txfee = GAMES_TXFEE; + mypk = pubkey2pk(Mypubkey()); + if ( AddNormalinputs(mtx,mypk,COIN+txfee,64) >= COIN+txfee ) // add utxo to mtx + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0 + // add opreturn, change is automatically added and tx is properly signed + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,games_opret('1',mypk)); + return(games_rawtxresult(result,rawtx,broadcastflag)); + } + return(result); +} + +bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + char expectedaddress[64]; CPubKey pk; + if ( tx.vout.size() != 2 ) // make sure the tx only has 2 outputs + return eval->Invalid("invalid number of vouts"); + else if ( games_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn + return eval->Invalid("invalid opreturn"); + GetCCaddress(cp,expectedaddress,pk); + if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches + return(true); + else return eval->Invalid("invalid vout0 amount"); +} + + diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h new file mode 100644 index 000000000..6b0bdc771 --- /dev/null +++ b/src/cc/gamescc.h @@ -0,0 +1,31 @@ + +std::string MYCCLIBNAME = (char *)"gamescc"; + +#define EVAL_GAMES (EVAL_FAUCET2+1) +#define GAMES_TXFEE 10000 + +#define MYCCNAME "games" + +#define RPC_FUNCS \ + { (char *)MYCCNAME, (char *)"func0", (char *)"", 1, 1, '0', EVAL_CUSTOM }, \ + { (char *)MYCCNAME, (char *)"func1", (char *)"", 0, 0, '1', EVAL_CUSTOM }, + +bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); +UniValue games_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); + +#define CUSTOM_DISPATCH \ +if ( cp->evalcode == EVAL_GAMES ) \ +{ \ + if ( strcmp(method,"func0") == 0 ) \ + return(games_func0(txfee,cp,params)); \ + else if ( strcmp(method,"func1") == 0 ) \ + return(games_func1(txfee,cp,params)); \ + else \ + { \ + result.push_back(Pair("result","error")); \ + result.push_back(Pair("error","invalid gamescc method")); \ + result.push_back(Pair("method",method)); \ + return(result); \ + } \ +} diff --git a/src/cc/makegames b/src/cc/makegames new file mode 100755 index 000000000..b4b8cb803 --- /dev/null +++ b/src/cc/makegames @@ -0,0 +1,7 @@ +#!/bin/sh +gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp +cp gamescc.so ../libcc.so +cd .. +make +cd cc + From fa381dd73648dce713610c1a4d3f72f421bd15ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 22:07:53 -1100 Subject: [PATCH 3036/3904] EVAL_GAMES --- src/cc/gamescc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 6b0bdc771..5eceb2d35 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -7,8 +7,8 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define MYCCNAME "games" #define RPC_FUNCS \ - { (char *)MYCCNAME, (char *)"func0", (char *)"", 1, 1, '0', EVAL_CUSTOM }, \ - { (char *)MYCCNAME, (char *)"func1", (char *)"", 0, 0, '1', EVAL_CUSTOM }, + { (char *)MYCCNAME, (char *)"func0", (char *)"", 1, 1, '0', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"func1", (char *)"", 0, 0, '1', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue games_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); From 717e72871cd3980a4a9f6283680f985e365e203f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 22:09:00 -1100 Subject: [PATCH 3037/3904] Test --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index f5f9dfba6..cd2022231 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1,7 +1,7 @@ CScript games_opret(uint8_t funcid,CPubKey pk) { - CScript opret; uint8_t evalcode = EVAL_CUSTOM; + CScript opret; uint8_t evalcode = EVAL_GAMES; opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); return(opret); } @@ -10,7 +10,7 @@ uint8_t games_opretdecode(CPubKey &pk,CScript scriptPubKey) { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_CUSTOM ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_GAMES ) { return(f); } From 550f698a5693219c67fd60859ca99f29d1493632 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 22 Mar 2019 17:15:19 +0800 Subject: [PATCH 3038/3904] fix --- src/cc/payments.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 8148be180..8b1156004 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -155,18 +155,18 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // change is/must be in vout[0] // only 'F' or 1of2 txidaddr can be spent // all vouts must match exactly - BOOST_FOREACH(const CTxIn& vin, tx) + BOOST_FOREACH(const CTxIn& vin, tx.vin) { uint256 blockhash; CTransaction txin; if ( myGetTransaction(vin.prevout.hash,txin,blockhash) ) { - fprintf(stderr, "vin txid.%s\n", txin.GetHex().c_str()); + fprintf(stderr, "vin txid.%s\n", txin.GetHash().GetHex().c_str()); } } - BOOST_FOREACH(const CTxOut& vout, tx) + BOOST_FOREACH(const CTxOut& vout, tx.vout) { - fprintf(stderr, "vout txid.%s\n", vout.hash.GetHex().c_str()); + fprintf(stderr, "vout txid.%s\n", vout.GetHash().GetHex().c_str()); } return(true); @@ -392,10 +392,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i+1].nValue *= amount; mtx.vout[i+1].nValue /= totalallocations; } -<<<<<<< Updated upstream -======= //fprintf(stderr,"addinputs %.8f\n",(double)amount/COIN); ->>>>>>> Stashed changes if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount ) { std::string rawtx; From 9ef377508f91241118295ceac9209067db7db405 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 22:20:41 -1100 Subject: [PATCH 3039/3904] Add PAYMENTS_TXFEE --- src/cc/payments.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index d1e11dae5..0d36d3b9e 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -377,12 +377,12 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i+1].nValue *= amount; mtx.vout[i+1].nValue /= totalallocations; } - if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount ) + if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+2*PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount ) { std::string rawtx; if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; - mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(PAYMENTS_TXFEE,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); From a0a3e141ba8ad699a9f48670ab29b6d749f76cb1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 22 Mar 2019 17:25:21 +0800 Subject: [PATCH 3040/3904] fix --- src/cc/payments.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 8b1156004..d63f23515 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -397,8 +397,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { std::string rawtx; if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) - mtx.vout[0].nValue = CCchange; - mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); + mtx.vout[0].nValue = CCchange-PAYMENTS_TXFEE; + mtx.vout.push_back(CTxOut(PAYMENTS_TXFEE,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); From 1272346fecd0a80f833db43f90fd2568a9c4e421 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 22:48:03 -1100 Subject: [PATCH 3041/3904] Add obj to a[] --- src/cc/payments.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 0d36d3b9e..e864a7ccf 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -626,6 +626,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) } free(outstr); } + a.push_back(obj); } flag++; if ( numoprets > 1 ) @@ -642,6 +643,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); GetCCaddress(cp,fundsopretaddr,Paymentspk); fundsopret = CCaddress_balance(fundsopretaddr); + result.push_back(Pair("txidoprets",a)); result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret))); result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret))); result.push_back(Pair("result","success")); From b68178d5411a9eff4fc08efd1fa40966927a6ee7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 22:51:28 -1100 Subject: [PATCH 3042/3904] result.push_back --- src/cc/payments.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index e864a7ccf..a57fe0c84 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -626,7 +626,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) } free(outstr); } - a.push_back(obj); + result.push_back(obj); } flag++; if ( numoprets > 1 ) @@ -643,7 +643,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); GetCCaddress(cp,fundsopretaddr,Paymentspk); fundsopret = CCaddress_balance(fundsopretaddr); - result.push_back(Pair("txidoprets",a)); + //result.push_back(Pair("txidoprets",a)); result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret))); result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret))); result.push_back(Pair("result","success")); From 678ada7d651954288b8072db48acbb25477e3ebe Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 22:56:36 -1100 Subject: [PATCH 3043/3904] Test --- src/cc/payments.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index a57fe0c84..eb92e4eb7 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -609,23 +609,26 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) { UniValue obj(UniValue::VOBJ); std::vector scriptPubKey,opret; obj.push_back(Pair("txidopret",txidoprets[i].GetHex())); + fprintf(stderr,"i%d of %d\n",i,(int32_t)txidoprets.size()); if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { outstr = (char *)malloc(scriptPubKey.size() + opret.size() + 1); for (j=0; j Date: Thu, 21 Mar 2019 22:59:09 -1100 Subject: [PATCH 3044/3904] Test --- src/cc/payments.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index eb92e4eb7..f302f494c 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -612,24 +612,24 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) fprintf(stderr,"i%d of %d\n",i,(int32_t)txidoprets.size()); if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { - outstr = (char *)malloc(scriptPubKey.size() + opret.size() + 1); + outstr = (char *)malloc(2*(scriptPubKey.size() + opret.size()) + 1); for (j=0; j 1 ) @@ -646,7 +646,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); GetCCaddress(cp,fundsopretaddr,Paymentspk); fundsopret = CCaddress_balance(fundsopretaddr); - //result.push_back(Pair("txidoprets",a)); + result.push_back(Pair("txidoprets",a)); result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret))); result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret))); result.push_back(Pair("result","success")); From a543449878fb599b39c7309c6273da02081698f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:01:10 -1100 Subject: [PATCH 3045/3904] Reorder son --- src/cc/payments.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index f302f494c..371d16e91 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -608,22 +608,21 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) for (i=0; i scriptPubKey,opret; - obj.push_back(Pair("txidopret",txidoprets[i].GetHex())); - fprintf(stderr,"i%d of %d\n",i,(int32_t)txidoprets.size()); + obj.push_back(Pair("txid",txidoprets[i].GetHex())); if ( myGetTransaction(txidoprets[i],txO,hashBlock) != 0 && txO.vout.size() > 1 && DecodePaymentsTxidOpRet(txO.vout[txO.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { outstr = (char *)malloc(2*(scriptPubKey.size() + opret.size()) + 1); for (j=0; j 1 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","too many opreturns")); - result.push_back(Pair("numoprets",(int64_t)numoprets)); } else { + result.push_back(Pair("txidoprets",a)); txidpk = CCtxidaddr(txidaddr,createtxid); GetCCaddress1of2(cp,fundsaddr,Paymentspk,txidpk); funds = CCaddress_balance(fundsaddr); result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); GetCCaddress(cp,fundsopretaddr,Paymentspk); fundsopret = CCaddress_balance(fundsopretaddr); - result.push_back(Pair("txidoprets",a)); result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret))); result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret))); result.push_back(Pair("result","success")); From 3a612c39012825741544a782a1c0b3b58ac73f77 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:05:15 -1100 Subject: [PATCH 3046/3904] +print --- src/cc/payments.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 371d16e91..c36eed447 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -344,6 +344,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) } else break; mtx.vout.push_back(vout); } + result.push_back(Pair("numoprets",(int64_t)numoprets)); if ( i != m ) { result.push_back(Pair("result","error")); From 60ed1e25e33c42537a06f05c971ed3d0da43b1e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:07:00 -1100 Subject: [PATCH 3047/3904] Onlyopret --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index c36eed447..c4f869e34 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -368,7 +368,6 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { result.push_back(Pair("result","error")); result.push_back(Pair("error","too many oprets")); - result.push_back(Pair("numoprets",(int64_t)numoprets)); if ( params != 0 ) free_json(params); return(result); @@ -386,6 +385,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout.push_back(CTxOut(PAYMENTS_TXFEE,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); + fprintf(stderr,"onlyopret.[%d]\n",(int32_t)onlyopret.size()); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); From 7650a93d25e02bb0d15ecbcc0e6faf83f62c3926 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:08:50 -1100 Subject: [PATCH 3048/3904] Fix onlyopret --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index c4f869e34..501d48b5a 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -337,7 +337,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) checkallocations += allocation; if ( opret.size() > 0 ) { - scriptPubKey.resize(opret.size()); + onlyopret.resize(opret.size()); memcpy(&onlyopret[0],&opret[0],opret.size()); numoprets++; } From ec58cc8ca7186283a88d6a80e4bf857b47a55c4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:11:12 -1100 Subject: [PATCH 3049/3904] -print --- src/cc/payments.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 501d48b5a..a2447404b 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -385,7 +385,6 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout.push_back(CTxOut(PAYMENTS_TXFEE,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr); - fprintf(stderr,"onlyopret.[%d]\n",(int32_t)onlyopret.size()); rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); From 1971ee717dd3af885f7b3ccc0e458b91271eafca Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:18:43 -1100 Subject: [PATCH 3050/3904] Minimum payout of PAYMENT_TXFEE --- src/cc/payments.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index a2447404b..16b182800 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -295,7 +295,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { int32_t latestheight,nextheight = komodo_nextheight(); CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; - CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,m,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,m,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t newamount,inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); @@ -372,15 +372,21 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) free_json(params); return(result); } + newamount = amount; for (i=0; i= amount ) + if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,newamount+2*PAYMENTS_TXFEE,60,createtxid,latestheight)) >= newamount+2*PAYMENTS_TXFEE ) { std::string rawtx; - if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE ) + if ( (CCchange= (inputsum - newamount)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; mtx.vout.push_back(CTxOut(PAYMENTS_TXFEE,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); @@ -388,6 +394,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret); if ( params != 0 ) free_json(params); + result.push_back(Pair("amount",ValueFromAmount(amount))); + result.push_back(Pair("newamount",ValueFromAmount(newamount))); return(payments_rawtxresult(result,rawtx,0)); } else From 7965bf808cd997d87251ff74a401f7d64ddb3d36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:37:26 -1100 Subject: [PATCH 3051/3904] Fix Change --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 16b182800..83565fcd2 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -386,7 +386,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,newamount+2*PAYMENTS_TXFEE,60,createtxid,latestheight)) >= newamount+2*PAYMENTS_TXFEE ) { std::string rawtx; - if ( (CCchange= (inputsum - newamount)) >= PAYMENTS_TXFEE ) + if ( (CCchange= (inputsum - newamount - PAYMENTS_TXFEE)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; mtx.vout.push_back(CTxOut(PAYMENTS_TXFEE,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); From e66ec82ea22079abf55560f9c8fb1100c684e529 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Mar 2019 23:52:50 -1100 Subject: [PATCH 3052/3904] 2*txfee --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 83565fcd2..7971b9cbe 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -386,7 +386,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,newamount+2*PAYMENTS_TXFEE,60,createtxid,latestheight)) >= newamount+2*PAYMENTS_TXFEE ) { std::string rawtx; - if ( (CCchange= (inputsum - newamount - PAYMENTS_TXFEE)) >= PAYMENTS_TXFEE ) + if ( (CCchange= (inputsum - newamount - 2*PAYMENTS_TXFEE)) >= PAYMENTS_TXFEE ) mtx.vout[0].nValue = CCchange; mtx.vout.push_back(CTxOut(PAYMENTS_TXFEE,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG)); GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk); From b0009ecca2e0d94d5ba139b4d023d60532ebb762 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 00:48:24 -1100 Subject: [PATCH 3053/3904] Update --- src/cc/CCtx.cpp | 1 - src/cc/gamescc.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- src/cc/gamescc.h | 8 ++++---- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index ed06c1a4d..2713dd9ed 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -601,7 +601,6 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 return(0); } - int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs) { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index cd2022231..edc4904fb 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -34,9 +34,49 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf return(result); } -UniValue games_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint16_t seeds[4]; uint64_t seed; bits256 hash; + if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) + { + hash = jbits256(jitem(params,0),0); + seed = jdouble(jitem(params,1),0); + if ( n == 3 ) + { + playerid = juint(jitem(params,2),0); + if ( playerid >= 0x100 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","playerid too big")); + return(result); + } + } + if ( seed == 0 ) + { + playerid++; + if ( playerid == 0x100 ) + { + for (i=0; i<8; i++) + hash.uints[i] ^= 0xffffffff; + playerid--; + } + for (i=0; i<8; i++) + { + if ( ((1 << i) & playerid) != 0 ) + seed ^= hash.uints[i]; + } + } + else + { + for (i=0; i<4; i++) + { + seeds[i] = (seed >> (i*16)); + seeds[i] = (seeds[i]*11109 + 13849); + } + seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; + } + result.push_back(Pair("seed",seed)); + } result.push_back(Pair("result","success")); result.push_back(Pair("message","just an example of an information returning rpc")); return(result); diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 5eceb2d35..ebdb92a93 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -7,18 +7,18 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define MYCCNAME "games" #define RPC_FUNCS \ - { (char *)MYCCNAME, (char *)"func0", (char *)"", 1, 1, '0', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"rng", (char *)"hash,seed,playerid", 2, 3, '0', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"func1", (char *)"", 0, 0, '1', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); -UniValue games_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ { \ - if ( strcmp(method,"func0") == 0 ) \ - return(games_func0(txfee,cp,params)); \ + if ( strcmp(method,"rng") == 0 ) \ + return(games_rng(txfee,cp,params)); \ else if ( strcmp(method,"func1") == 0 ) \ return(games_func1(txfee,cp,params)); \ else \ From 966f2410317a7b96cd0fa518bf904ee9a259641d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:06:54 -1100 Subject: [PATCH 3054/3904] Test --- src/cc/gamescc.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index edc4904fb..b600a8c3a 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -76,9 +76,13 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; } result.push_back(Pair("seed",seed)); + result.push_back(Pair("result","success")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough params")); } - result.push_back(Pair("result","success")); - result.push_back(Pair("message","just an example of an information returning rpc")); return(result); } From b6cdf0725e35cf5ea347540022acffc6d3a869b6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:12:31 -1100 Subject: [PATCH 3055/3904] Test --- src/cc/gamescc.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b600a8c3a..d083e2292 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -36,7 +36,7 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint16_t seeds[4]; uint64_t seed; bits256 hash; + UniValue result(UniValue::VOBJ); int32_t i,invertflag=0,n,playerid=0; uint16_t seeds[4]; uint64_t seed; bits256 hash; if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) { hash = jbits256(jitem(params,0),0); @@ -56,15 +56,9 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) playerid++; if ( playerid == 0x100 ) { - for (i=0; i<8; i++) - hash.uints[i] ^= 0xffffffff; + invertflag = 1; playerid--; } - for (i=0; i<8; i++) - { - if ( ((1 << i) & playerid) != 0 ) - seed ^= hash.uints[i]; - } } else { @@ -74,6 +68,8 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) seeds[i] = (seeds[i]*11109 + 13849); } seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; + if ( invertflag != 0 ) + seed ^= -1; } result.push_back(Pair("seed",seed)); result.push_back(Pair("result","success")); From c5bcb12119f6fc8d2a58a8fb04731578d47620f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:14:47 -1100 Subject: [PATCH 3056/3904] seeds --- src/cc/gamescc.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index d083e2292..25088d7fc 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -59,6 +59,9 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) invertflag = 1; playerid--; } + for (i=0; i<8; i++) + if ( ((1 << i) & playerid) != 0 ) + seed ^= hash.uints[i]; } else { @@ -71,6 +74,7 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( invertflag != 0 ) seed ^= -1; } + result.push_back(Pair("playerid",(int64_t)(playerid - 1 + invertflag))); result.push_back(Pair("seed",seed)); result.push_back(Pair("result","success")); } From 6f6a9d28b20e188024e2a9d3a01353c055fc3d54 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:18:03 -1100 Subject: [PATCH 3057/3904] Initseed --- src/cc/gamescc.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 25088d7fc..a079df2cf 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -36,7 +36,7 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t i,invertflag=0,n,playerid=0; uint16_t seeds[4]; uint64_t seed; bits256 hash; + UniValue result(UniValue::VOBJ); int32_t i,invertflag=0,n,playerid=0; uint16_t seeds[4]; uint64_t seed,initseed; bits256 hash; if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) { hash = jbits256(jitem(params,0),0); @@ -60,21 +60,22 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) playerid--; } for (i=0; i<8; i++) + { if ( ((1 << i) & playerid) != 0 ) seed ^= hash.uints[i]; - } - else - { - for (i=0; i<4; i++) - { - seeds[i] = (seed >> (i*16)); - seeds[i] = (seeds[i]*11109 + 13849); + if ( invertflag != 0 ) + seed ^= (uint64_t)-1; } - seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; - if ( invertflag != 0 ) - seed ^= -1; } + initseed = seed; + for (i=0; i<4; i++) + { + seeds[i] = (seed >> (i*16)); + seeds[i] = (seeds[i]*11109 + 13849); + } + seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; result.push_back(Pair("playerid",(int64_t)(playerid - 1 + invertflag))); + result.push_back(Pair("initseed",initseed)); result.push_back(Pair("seed",seed)); result.push_back(Pair("result","success")); } From b03e6652ac640c7e135f7f99cd0d2e102732e0c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:22:31 -1100 Subject: [PATCH 3058/3904] Rngnext --- src/cc/gamescc.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index a079df2cf..6efe19da6 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -34,9 +34,21 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf return(result); } +uint64_t games_rngnext(uint64_t initseed) +{ + uint16_t seeds[4]; int32_t i; + for (i=0; i<4; i++) + { + seeds[i] = (seed >> (i*16)); + seeds[i] = (seeds[i]*11109 + 13849); + } + seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; + return(seed); +} + UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t i,invertflag=0,n,playerid=0; uint16_t seeds[4]; uint64_t seed,initseed; bits256 hash; + UniValue result(UniValue::VOBJ); int32_t i,invertflag=0,n,playerid=0; uint64_t seed,initseed; bits256 hash; if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) { hash = jbits256(jitem(params,0),0); @@ -44,7 +56,7 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( n == 3 ) { playerid = juint(jitem(params,2),0); - if ( playerid >= 0x100 ) + if ( playerid >= 0xff ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","playerid too big")); @@ -54,26 +66,14 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( seed == 0 ) { playerid++; - if ( playerid == 0x100 ) - { - invertflag = 1; - playerid--; - } for (i=0; i<8; i++) { if ( ((1 << i) & playerid) != 0 ) seed ^= hash.uints[i]; - if ( invertflag != 0 ) - seed ^= (uint64_t)-1; } } initseed = seed; - for (i=0; i<4; i++) - { - seeds[i] = (seed >> (i*16)); - seeds[i] = (seeds[i]*11109 + 13849); - } - seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; + seed = games_rngnext(initseed); result.push_back(Pair("playerid",(int64_t)(playerid - 1 + invertflag))); result.push_back(Pair("initseed",initseed)); result.push_back(Pair("seed",seed)); From 52e039e2e0d7b18ba059be738a356a5db16d9cd3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:24:49 -1100 Subject: [PATCH 3059/3904] More dynamic range --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 6efe19da6..335a72446 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -69,7 +69,7 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i<8; i++) { if ( ((1 << i) & playerid) != 0 ) - seed ^= hash.uints[i]; + seed ^= (uint64_t)hash.uints[i] << ((i&1)*32); } } initseed = seed; From 9089441e247e93ebcdf795e1f7e20e604b96847d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:27:23 -1100 Subject: [PATCH 3060/3904] Test --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 335a72446..b858338de 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -48,7 +48,7 @@ uint64_t games_rngnext(uint64_t initseed) UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t i,invertflag=0,n,playerid=0; uint64_t seed,initseed; bits256 hash; + UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint64_t seed,initseed; bits256 hash; if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) { hash = jbits256(jitem(params,0),0); @@ -74,7 +74,7 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } initseed = seed; seed = games_rngnext(initseed); - result.push_back(Pair("playerid",(int64_t)(playerid - 1 + invertflag))); + result.push_back(Pair("playerid",(int64_t)(playerid - 1))); result.push_back(Pair("initseed",initseed)); result.push_back(Pair("seed",seed)); result.push_back(Pair("result","success")); From 96604c9906c777c68fece883ea5241c13da1d0a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:28:10 -1100 Subject: [PATCH 3061/3904] Syntax --- src/cc/gamescc.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b858338de..42e1086a6 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -39,11 +39,10 @@ uint64_t games_rngnext(uint64_t initseed) uint16_t seeds[4]; int32_t i; for (i=0; i<4; i++) { - seeds[i] = (seed >> (i*16)); + seeds[i] = (initseed >> (i*16)); seeds[i] = (seeds[i]*11109 + 13849); } - seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]; - return(seed); + return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) From 2845aa8a4e601cbc28014613a14599d39e756126 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:33:30 -1100 Subject: [PATCH 3062/3904] Split --- src/cc/gamescc.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 42e1086a6..bc871535b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -37,11 +37,14 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf uint64_t games_rngnext(uint64_t initseed) { uint16_t seeds[4]; int32_t i; - for (i=0; i<4; i++) - { - seeds[i] = (initseed >> (i*16)); - seeds[i] = (seeds[i]*11109 + 13849); - } + seeds[0] = initseed; + seeds[1] = (initseed >> 16); + seeds[2] = (initseed >> 32); + seeds[3] = (initseed >> 48); + seeds[0] = (seeds[0]*11109 + 13849); + seeds[1] = ((seeds[0] ^ seeds[1])*11109 + 13849); + seeds[2] = ((seeds[0] ^ seeds[1] ^ seeds[2])*11109 + 13849); + seeds[3] = ((seeds[0] ^ seeds[1] ^ seeds[2] ^ seeds[3])*11109 + 13849); return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } From 6bc65b36d5d67a70dee690298f918b3ca98a73ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:42:54 -1100 Subject: [PATCH 3063/3904] #define GAMES_RNGMULT 11109 #define GAMES_RNGOFFSET 13849 #define GAMES_MAXRNGS 10000 --- src/cc/gamescc.cpp | 12 +++++++----- src/cc/gamescc.h | 4 ++++ src/cc/payments.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index bc871535b..ab1b802e0 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -41,10 +41,10 @@ uint64_t games_rngnext(uint64_t initseed) seeds[1] = (initseed >> 16); seeds[2] = (initseed >> 32); seeds[3] = (initseed >> 48); - seeds[0] = (seeds[0]*11109 + 13849); - seeds[1] = ((seeds[0] ^ seeds[1])*11109 + 13849); - seeds[2] = ((seeds[0] ^ seeds[1] ^ seeds[2])*11109 + 13849); - seeds[3] = ((seeds[0] ^ seeds[1] ^ seeds[2] ^ seeds[3])*11109 + 13849); + seeds[0] = (seeds[0]*GAMES_RNGMULT + GAMES_RNGOFFSET); + seeds[1] = ((seeds[0] ^ seeds[1])*GAMES_RNGMULT + GAMES_RNGOFFSET); + seeds[2] = ((seeds[0] ^ seeds[1] ^ seeds[2])*GAMES_RNGMULT + GAMES_RNGOFFSET); + seeds[3] = ((seeds[0] ^ seeds[1] ^ seeds[2] ^ seeds[3])*GAMES_RNGMULT + GAMES_RNGOFFSET); return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } @@ -79,6 +79,9 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("playerid",(int64_t)(playerid - 1))); result.push_back(Pair("initseed",initseed)); result.push_back(Pair("seed",seed)); + for (i=0; i= COIN+txfee ) // add utxo to mtx { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0 - // add opreturn, change is automatically added and tx is properly signed rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,games_opret('1',mypk)); return(games_rawtxresult(result,rawtx,broadcastflag)); } diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index ebdb92a93..aebda854f 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -4,6 +4,10 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define EVAL_GAMES (EVAL_FAUCET2+1) #define GAMES_TXFEE 10000 +#define GAMES_RNGMULT 11109 +#define GAMES_RNGOFFSET 13849 +#define GAMES_MAXRNGS 10000 + #define MYCCNAME "games" #define RPC_FUNCS \ diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 7971b9cbe..3dfcdcba9 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -383,7 +383,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i+1].nValue = PAYMENTS_TXFEE; } } - if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,newamount+2*PAYMENTS_TXFEE,60,createtxid,latestheight)) >= newamount+2*PAYMENTS_TXFEE ) + if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,newamount+2*PAYMENTS_TXFEE,MAX_CCVINS/2,createtxid,latestheight)) >= newamount+2*PAYMENTS_TXFEE ) { std::string rawtx; if ( (CCchange= (inputsum - newamount - 2*PAYMENTS_TXFEE)) >= PAYMENTS_TXFEE ) From 407eab0c8423540d870e6afa28f7b9e35dd54b06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:45:33 -1100 Subject: [PATCH 3064/3904] CC_MAXVINS --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 3dfcdcba9..97b56ff59 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -383,7 +383,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) mtx.vout[i+1].nValue = PAYMENTS_TXFEE; } } - if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,newamount+2*PAYMENTS_TXFEE,MAX_CCVINS/2,createtxid,latestheight)) >= newamount+2*PAYMENTS_TXFEE ) + if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,newamount+2*PAYMENTS_TXFEE,CC_MAXVINS/2,createtxid,latestheight)) >= newamount+2*PAYMENTS_TXFEE ) { std::string rawtx; if ( (CCchange= (inputsum - newamount - 2*PAYMENTS_TXFEE)) >= PAYMENTS_TXFEE ) From e74277a9346716c0f736d0f10bbb101874daca98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:47:23 -1100 Subject: [PATCH 3065/3904] Maxrngs --- src/cc/gamescc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ab1b802e0..02ead4d8f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -82,6 +82,7 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i Date: Fri, 22 Mar 2019 01:53:15 -1100 Subject: [PATCH 3066/3904] rngnext --- src/cc/gamescc.cpp | 31 +++++++++++++++++++++++++------ src/cc/gamescc.h | 10 +++++----- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 02ead4d8f..a9801d03e 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -34,7 +34,7 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf return(result); } -uint64_t games_rngnext(uint64_t initseed) +uint64_t _games_rngnext(uint64_t initseed) { uint16_t seeds[4]; int32_t i; seeds[0] = initseed; @@ -48,6 +48,25 @@ uint64_t games_rngnext(uint64_t initseed) return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } +UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); int32_t n; uint64_t seed; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + { + seed = jdouble(jitem(params,0),0); + result.push_back(Pair("seed",seed)); + seed = games_rngnext(seed); + result.push_back(Pair("rng",seed)); + result.push_back(Pair("result","success")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough params")); + } + return(result); +} + UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint64_t seed,initseed; bits256 hash; @@ -75,13 +94,13 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } } initseed = seed; - seed = games_rngnext(initseed); + seed = _games_rngnext(initseed); result.push_back(Pair("playerid",(int64_t)(playerid - 1))); - result.push_back(Pair("initseed",initseed)); - result.push_back(Pair("seed",seed)); + result.push_back(Pair("seed",initseed)); + result.push_back(Pair("rng",seed)); for (i=0; i", 0, 0, '1', EVAL_GAMES }, + { (char *)MYCCNAME, (char *)"rng", (char *)"hash,seed,playerid", 2, 3, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue games_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ { \ if ( strcmp(method,"rng") == 0 ) \ return(games_rng(txfee,cp,params)); \ - else if ( strcmp(method,"func1") == 0 ) \ - return(games_func1(txfee,cp,params)); \ + else if ( strcmp(method,"rngnext") == 0 ) \ + return(games_rngnext(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From 1747b7ebeae9fe541131d43b49c1e7d00dfb28c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:58:40 -1100 Subject: [PATCH 3067/3904] _ --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index a9801d03e..b05010e82 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -55,7 +55,7 @@ UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { seed = jdouble(jitem(params,0),0); result.push_back(Pair("seed",seed)); - seed = games_rngnext(seed); + seed = _games_rngnext(seed); result.push_back(Pair("rng",seed)); result.push_back(Pair("result","success")); } From c9765fec2a66f2fddef31615e6dff94f84e06d70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 02:05:19 -1100 Subject: [PATCH 3068/3904] Fixes --- src/cc/gamescc.cpp | 20 ++++++++------------ src/cc/gamescc.h | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b05010e82..c381ead1c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -69,14 +69,13 @@ UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint64_t seed,initseed; bits256 hash; - if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) + UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint64_t seed=0,initseed; bits256 hash; + if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 1 || n == 2) ) { hash = jbits256(jitem(params,0),0); - seed = jdouble(jitem(params,1),0); - if ( n == 3 ) + if ( n == 2 ) { - playerid = juint(jitem(params,2),0); + playerid = juint(jitem(params,1),0); if ( playerid >= 0xff ) { result.push_back(Pair("result","error")); @@ -84,14 +83,11 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } } - if ( seed == 0 ) + playerid++; + for (i=0; i<8; i++) { - playerid++; - for (i=0; i<8; i++) - { - if ( ((1 << i) & playerid) != 0 ) - seed ^= (uint64_t)hash.uints[i] << ((i&1)*32); - } + if ( ((1 << i) & playerid) != 0 ) + seed ^= (uint64_t)hash.uints[i] << ((i&1)*32); } initseed = seed; seed = _games_rngnext(initseed); diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index adb318522..a8e472622 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -11,7 +11,7 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define MYCCNAME "games" #define RPC_FUNCS \ - { (char *)MYCCNAME, (char *)"rng", (char *)"hash,seed,playerid", 2, 3, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); From fa6f9fcbbf4505e8dacd970b69e2a73b25da3bde Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 02:12:31 -1100 Subject: [PATCH 3069/3904] Rng basics documented --- src/cc/gamescc.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index c381ead1c..d9ea74871 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1,4 +1,32 @@ +/* +./c cclib rng 17 \"[%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,250]\" +{ + "playerid": 250, + "seed": 1398876319979341887, + "rng": 14565767519458298868, + "lastrng": 15075236803740723044, + "maxrngs": 10000, + "result": "success" +} + + ./c cclib rngnext 17 \"[14565767519458298868]\" + { + "seed": 14565767519458297856, + "rng": 4253087318999719449, + "result": "success" + } + + The idea is for a game to start with a near future blockhash, so the lobby gets players signed up until just prior to the designated height. then that blockhash can be used to create a stream of rngs. + + the same initial rng can be used for all players, if the identical starting condition is required. up to 255 different initial rng can be derived from a single blockhash. (Actually any number is possible, for simplicity rng rpc limits to 255). + + you will notice maxrngs and lastrng, the lastrng is the rng value that will happen after maxrng iterations of calling rngnext with the current rng. This allows making time based multiplayer games where all the nodes can validate all the other nodes rng, even without realtime synchronization of all user input events. + + Every time period, all players would set their rng value to the lastrng value. The only thing to be careful of is it not exceed the maxrng calls to rngnext in a single time period. otherwise the same set of rng numbers will be repeated. +*/ + + CScript games_opret(uint8_t funcid,CPubKey pk) { CScript opret; uint8_t evalcode = EVAL_GAMES; From 112df09f652ca26d1874776efec3c12c8196b63c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 04:25:09 -1100 Subject: [PATCH 3070/3904] Events --- src/cc/CCinclude.h | 2 ++ src/cc/gamescc.cpp | 58 +++++++++++++++++++++++++++++----------------- src/cc/gamescc.h | 18 +++++++++++++- src/main.cpp | 18 ++++++++++++-- src/miner.cpp | 17 ++++++++++++++ 5 files changed, 89 insertions(+), 24 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index f5877c711..13d7236d4 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -195,6 +195,8 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid); bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); +void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector payload); +int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t len); CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, vscript_t vopretNonfungible); CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector> oprets); diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index d9ea74871..68de4bb8a 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -136,35 +136,51 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -// send yourself 1 coin to your CC address using normal utxo from your -pubkey - -UniValue games_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); std::string rawtx; - UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0; - if ( txfee == 0 ) - txfee = GAMES_TXFEE; - mypk = pubkey2pk(Mypubkey()); - if ( AddNormalinputs(mtx,mypk,COIN+txfee,64) >= COIN+txfee ) // add utxo to mtx + UniValue result(UniValue::VOBJ); std::vector payload; int32_t n; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0 - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,games_opret('1',mypk)); - return(games_rawtxresult(result,rawtx,broadcastflag)); + if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) + { + komodo_sendmessage(4,8,"events",payload); + result.push_back(Pair("result","success")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parsehexdata")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough params")); } return(result); } +UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + +UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + +UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + return(result); +} + bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - char expectedaddress[64]; CPubKey pk; - if ( tx.vout.size() != 2 ) // make sure the tx only has 2 outputs - return eval->Invalid("invalid number of vouts"); - else if ( games_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn - return eval->Invalid("invalid opreturn"); - GetCCaddress(cp,expectedaddress,pk); - if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches - return(true); - else return eval->Invalid("invalid vout0 amount"); + return(true); } diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index a8e472622..02f589056 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -12,11 +12,19 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define RPC_FUNCS \ { (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, + { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"create", (char *)"game,minplayers,maxplayers,buyin,numblocks", 5, 5, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"info", (char *)"txid", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"events", (char *)"hex", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"register", (char *)"txid", 1, 1, ' ', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ @@ -25,6 +33,14 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_rng(txfee,cp,params)); \ else if ( strcmp(method,"rngnext") == 0 ) \ return(games_rngnext(txfee,cp,params)); \ + else if ( strcmp(method,"create") == 0 ) \ + return(games_create(txfee,cp,params)); \ + else if ( strcmp(method,"info") == 0 ) \ + return(games_info(txfee,cp,params)); \ + else if ( strcmp(method,"register") == 0 ) \ + return(games_register(txfee,cp,params)); \ + else if ( strcmp(method,"events") == 0 ) \ + return(games_events(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ diff --git a/src/main.cpp b/src/main.cpp index ce0760cf5..996fe2e3c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7035,8 +7035,22 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 1); return false; } - - + else if ( strCommand == "events" ) + { + int32_t i; + if ( ASSETCHAINS_CCLIB != MYCCLIBNAME || ASSETCHAINS_CCLIB != "gamescc" ) + { + Misbehaving(pfrom->GetId(), 1); + return false; + } + CNodeState *state = State(pfrom->GetId()); + if (state == NULL) + return; + for (i=0; iname ); + return(true); + } else if (strCommand == "verack") { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); diff --git a/src/miner.cpp b/src/miner.cpp index 2069e5a8c..eaba96ee1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -931,6 +931,23 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); } +void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector payload) +{ + int32_t numsent = 0; + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if ( pnode->hSocket == INVALID_SOCKET ) + continue; + if ( numsent < minpeers || (rand() % 10) == 0 ) + { + pnode->PushMessage(message,payload); + if ( numsent++ > maxpeers ) + break; + } + } +} + void komodo_broadcast(CBlock *pblock,int32_t limit) { if (IsInitialBlockDownload()) From 3a141d3ccc00f17a26cf683f1fa4efbd6f2cb637 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 04:30:02 -1100 Subject: [PATCH 3071/3904] Test --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 996fe2e3c..4aaa4e4ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7038,17 +7038,17 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if ( strCommand == "events" ) { int32_t i; - if ( ASSETCHAINS_CCLIB != MYCCLIBNAME || ASSETCHAINS_CCLIB != "gamescc" ) + if ( ASSETCHAINS_CCLIB != "gamescc" ) { Misbehaving(pfrom->GetId(), 1); return false; } - CNodeState *state = State(pfrom->GetId()); - if (state == NULL) - return; for (i=0; iname ); + CNodeState *state = State(pfrom->GetId()); + if ( state != NULL ) + fprintf(stderr," got event[%d] from %s: %s\n", (int32_t)vRecv.size(),__func__, state->name ); + else fprintf(stderr,"got event[%d]\n",(int32_t)vRecv.size()); return(true); } else if (strCommand == "verack") From 9c1f05c72a938f593b4f35157a3143770cdbe918 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 04:56:05 -1100 Subject: [PATCH 3072/3904] -print --- src/main.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4aaa4e4ea..5ed1a35fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7045,10 +7045,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } for (i=0; iGetId()); - if ( state != NULL ) - fprintf(stderr," got event[%d] from %s: %s\n", (int32_t)vRecv.size(),__func__, state->name ); - else fprintf(stderr,"got event[%d]\n",(int32_t)vRecv.size()); + fprintf(stderr," got event[%d]\n",(int32_t)vRecv.size()); return(true); } else if (strCommand == "verack") From 5e08aa28b9574efdbdfefe1714cb5116819d77dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 05:26:55 -1100 Subject: [PATCH 3073/3904] Fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 062ef6148..f20a63664 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5653,7 +5653,7 @@ UniValue payments_list(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); - return(PaymentsList(cp,"")); + return(PaymentsList(cp,(char *)"")); } UniValue oraclesaddress(const UniValue& params, bool fHelp) From 08f197fff3ab9d415b70b4a26d1b92689d31872d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 08:14:34 -1100 Subject: [PATCH 3074/3904] payload --- src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5ed1a35fe..5027e5fa6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7043,9 +7043,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 1); return false; } - for (i=0; i payload; + vRecv >> payload; + for (i=0; i Date: Fri, 22 Mar 2019 08:51:37 -1100 Subject: [PATCH 3075/3904] komodo_netevent --- src/cc/cclib.cpp | 4 ++++ src/cc/gamescc.cpp | 8 ++++++++ src/komodo_defs.h | 1 + src/main.cpp | 4 +--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c8e714ba2..65c706862 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -48,6 +48,10 @@ std::string MYCCLIBNAME = (char *)"rogue"; std::string MYCCLIBNAME = (char *)"sudoku"; #endif +#ifndef BUILD_GAMESCC +void komodo_netevent(std::vector payload) {} +#endif + char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } struct CClib_rpcinfo diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 68de4bb8a..29df990b5 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -178,6 +178,14 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +void komodo_netevent(std::vector payload) +{ + int32_t i; + for (i=0; i payload); #endif diff --git a/src/main.cpp b/src/main.cpp index 5027e5fa6..e520ad83f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7045,9 +7045,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } std::vector payload; vRecv >> payload; - for (i=0; i Date: Sat, 23 Mar 2019 14:32:43 +0800 Subject: [PATCH 3076/3904] initial validation commit ONLY validates non OP_RETURN --- src/cc/CCPayments.h | 2 +- src/cc/payments.cpp | 162 +++++++++++++++++++++++++++++++++++++++----- src/main.cpp | 2 +- 3 files changed, 147 insertions(+), 19 deletions(-) diff --git a/src/cc/CCPayments.h b/src/cc/CCPayments.h index 56d36f74e..247a0f2ec 100644 --- a/src/cc/CCPayments.h +++ b/src/cc/CCPayments.h @@ -29,6 +29,6 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr); UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr); UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr); UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr); -UniValue PaymentsList(struct CCcontract_info *cp); +UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr); #endif diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 6bd575835..93272fad7 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -148,27 +148,155 @@ int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } +void pub2createtxid(char *str) +{ + int i,n; + char *rev; + n = (int32_t)strlen(str); + rev = (char *)malloc(n + 1); + for (i=0; i txidoprets; + int32_t i; bool fHasOpret = false; + CPubKey txidpk,Paymentspk; + int64_t change; + + //the nValue 0 vout at the end of the tx (last one if no opret) + //it is a pay to pubkey vout + //the "pubkey" is just 0x02 + if ( tx.vout.size() < 2 ) + return(false); + if ( tx.vout.back().scriptPubKey[0] == OP_RETURN ) + { + scriptpubkey = HexStr(tx.vout[tx.vout.size()-2].scriptPubKey.begin()+2, tx.vout[tx.vout.size()-2].scriptPubKey.end()-1); + fHasOpret = true; + } else scriptpubkey = HexStr(tx.vout[tx.vout.size()-1].scriptPubKey.begin()+2,tx.vout[tx.vout.size()-1].scriptPubKey.end()-1); + strcpy(temp, scriptpubkey.c_str()); + pub2createtxid(temp); + createtxid = Parseuint256(temp); + //printf("createtxid.%s\n",createtxid.ToString().c_str()); + + // use the createtxid to fetch the tx and all of the plans info. + if ( myGetTransaction(createtxid,tmptx,blockhash) != 0 ) + { + if ( tmptx.vout.size() > 0 && DecodePaymentsOpRet(tmptx.vout[tmptx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) + { + if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 ) + return(false); + Paymentspk = GetUnspendable(cp,0); + //fprintf(stderr, "lockedblocks.%i minrelease.%i totalallocations.%i txidopret1.%s txidopret2.%s\n",lockedblocks, minrelease, totalallocations, txidoprets[0].ToString().c_str(), txidoprets[1].ToString().c_str() ); + + // Get all the script pubkeys and allocations + std::vector allocations; + std::vector scriptPubKeys; + int32_t checkallocations = 0; + i = 0; + BOOST_FOREACH(const uint256& txidopret, txidoprets) + { + CTransaction tx0; std::vector scriptPubKey,opret; int32_t allocation; + if ( myGetTransaction(txidopret,tx0,blockhash) != 0 && tx0.vout.size() > 1 && DecodePaymentsTxidOpRet(tx0.vout[tx0.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) + { + scriptPubKeys.push_back(CScript(scriptPubKey.begin(), scriptPubKey.end())); + allocations.push_back(allocation); + //fprintf(stderr, "i.%i scriptpubkey.%s allocation.%i\n",i,scriptPubKeys[i].ToString().c_str(),allocation); + checkallocations += allocation; + } + i++; + } + + // sanity check to make sure we got all the required info + if ( allocations.size() == 0 || scriptPubKeys.size() == 0 || allocations.size() != scriptPubKeys.size() ) + return(false); + + //fprintf(stderr, "totalallocations.%i checkallocations.%i\n",totalallocations, checkallocations); + if ( totalallocations != checkallocations ) + return(false); + + txidpk = CCtxidaddr(txidaddr,createtxid); + GetCCaddress1of2(cp,coinaddr,Paymentspk,txidpk); + //fprintf(stderr, "coinaddr.%s\n", coinaddr); + + // make sure change is in vout 0 and is paying to the contract address. + if ( (change= IsPaymentsvout(cp,tx,0,coinaddr)) == 0 ) + return(false); + + // Check vouts go to the right place and pay the right amounts. + int64_t amount = 0, checkamount; int32_t n = 0; + checkamount = tx.GetValueOut() - change - PAYMENTS_TXFEE; + for (i = 1; i < (fHasOpret ? tx.vout.size()-2 : tx.vout.size()-1); i++) { + std::string destscriptPubKey = HexStr(scriptPubKeys[n].begin(),scriptPubKeys[n].end()); + std::string voutscriptPubKey = HexStr(tx.vout[i].scriptPubKey.begin(),tx.vout[i].scriptPubKey.end()); + if ( destscriptPubKey != voutscriptPubKey ) + { + fprintf(stderr, "pays wrong destination destscriptPubKey.%s voutscriptPubKey.%s\n", destscriptPubKey.c_str(), voutscriptPubKey.c_str()); + return(false); + } + int64_t test = allocations[n]; + test *= checkamount; + test /= totalallocations; + if ( test != tx.vout[i].nValue ) + { + fprintf(stderr, "vout.%i test.%li vs nVlaue.%li\n",i, test, tx.vout[i].nValue); + return(false); + } + amount += tx.vout[i].nValue; + n++; + } + if ( checkamount != amount ) + return(false); + + if ( amount < minrelease*COIN ) + { + fprintf(stderr, "does not meet minrelease amount.%li minrelease.%li\n",amount, (int64_t)minrelease*COIN ); + return(false); + } + + i = 0; + BOOST_FOREACH(const CTxIn& vin, tx.vin) + { + CTransaction txin; + if ( myGetTransaction(vin.prevout.hash,txin,blockhash) ) + { + // check the vin comes from the CC address's + if ( IsPaymentsvout(cp,txin,i,coinaddr) != 0 ) + { + fprintf(stderr, "vin.%i is not a payments CC vout\n", i); + return(false); + } + // check the chain depth vs locked blcoks requirement. + CBlockIndex* pblockindex = mapBlockIndex[blockhash]; + if ( pblockindex->GetHeight() > chainActive.LastTip()->GetHeight()-lockedblocks ) + { + fprintf(stderr, "vin.%i is not elegible to be spent yet height.%i vs elegible_ht.%i\n", i, pblockindex->GetHeight(), chainActive.LastTip()->GetHeight()-lockedblocks); + return(false); + } + //fprintf(stderr, "vin txid.%s\n", txin.GetHash().GetHex().c_str()); + } + i++; + } + } + } + // one of two addresses? only seems to ever use the 1! // change must go to 1of2 txidaddr // change is/must be in vout[0] // only 'F' or 1of2 txidaddr can be spent // all vouts must match exactly - BOOST_FOREACH(const CTxIn& vin, tx.vin) - { - uint256 blockhash; CTransaction txin; - if ( myGetTransaction(vin.prevout.hash,txin,blockhash) ) - { - fprintf(stderr, "vin txid.%s\n", txin.GetHash().GetHex().c_str()); - } - } - - BOOST_FOREACH(const CTxOut& vout, tx.vout) - { - fprintf(stderr, "vout txid.%s\n", vout.GetHash().GetHex().c_str()); - } - return(true); } // end of consensus code @@ -411,7 +539,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) free_json(params); result.push_back(Pair("amount",ValueFromAmount(amount))); result.push_back(Pair("newamount",ValueFromAmount(newamount))); - return(payments_rawtxresult(result,rawtx,0)); + return(payments_rawtxresult(result,rawtx,1)); } else { @@ -691,7 +819,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) return(result); } -UniValue PaymentsList(struct CCcontract_info *cp) +UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) { std::vector > addressIndex; uint256 txid,hashBlock; UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease,totalallocations; std::vector txidoprets; diff --git a/src/main.cpp b/src/main.cpp index e520ad83f..9930e733c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7045,7 +7045,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } std::vector payload; vRecv >> payload; - komodo_netevent(payload); + //komodo_netevent(payload); return(true); } else if (strCommand == "verack") From 7fbcfc27e3e4ee4fe383c24d531713865aa50fe9 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sat, 23 Mar 2019 15:29:23 +0800 Subject: [PATCH 3077/3904] Update cryptoconditions.py update keys, remove failing tokens tests (no tokenid) --- qa/rpc-tests/cryptoconditions.py | 49 ++++++++++++-------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py index ee119b75a..d5456e801 100755 --- a/qa/rpc-tests/cryptoconditions.py +++ b/qa/rpc-tests/cryptoconditions.py @@ -3,7 +3,6 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. - from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ @@ -25,7 +24,6 @@ def generate_random_string(length): random_string = ''.join(choice(ascii_uppercase) for i in range(length)) return random_string - class CryptoConditionsTest (BitcoinTestFramework): def setup_chain(self): @@ -105,13 +103,13 @@ class CryptoConditionsTest (BitcoinTestFramework): faucet = rpc.faucetaddress() assert_equal(faucet['result'], 'success') # verify all keys look like valid AC addrs, could be better - for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress']: + for x in ['myCCAddress(Faucet)', 'FaucetCCAddress', 'FaucetCCTokensAddress', 'myaddress', 'FaucetNormalAddress']: assert_equal(faucet[x][0], 'R') - + result = rpc.faucetaddress(self.pubkey) assert_success(result) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress', 'CCaddress']: + for x in ['myCCAddress(Faucet)', 'FaucetCCAddress', 'FaucetCCTokensAddress', 'myaddress', 'FaucetNormalAddress']: assert_equal(result[x][0], 'R') # no funds in the faucet yet @@ -179,12 +177,12 @@ class CryptoConditionsTest (BitcoinTestFramework): dice = rpc.diceaddress() assert_equal(dice['result'], 'success') - for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress']: + for x in ['myCCAddress(Dice)', 'DiceCCAddress', 'DiceCCTokensAddress', 'myaddress', 'DiceNormalAddress']: assert_equal(dice[x][0], 'R') dice = rpc.diceaddress(self.pubkey) assert_equal(dice['result'], 'success') - for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress', 'CCaddress']: + for x in ['myCCAddress(Dice)', 'DiceCCAddress', 'DiceCCTokensAddress', 'myaddress', 'DiceNormalAddress']: assert_equal(dice[x][0], 'R') # no dice created yet @@ -333,12 +331,12 @@ class CryptoConditionsTest (BitcoinTestFramework): rpc = self.nodes[0] result = rpc.tokenaddress() assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress']: + for x in ['myCCAddress(Tokens)', 'TokensNormalAddress', 'TokensNormalAddress', 'myaddress','TokensCCAddress']: assert_equal(result[x][0], 'R') result = rpc.tokenaddress(self.pubkey) assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress', 'CCaddress']: + for x in ['myCCAddress(Tokens)', 'TokensNormalAddress', 'TokensNormalAddress', 'myaddress','TokensCCAddress']: assert_equal(result[x][0], 'R') # there are no tokens created yet result = rpc.tokenlist() @@ -361,17 +359,6 @@ class CryptoConditionsTest (BitcoinTestFramework): result = rpc.tokenlist() assert_equal(result[0], tokenid) - # there are no token orders yet - result = rpc.tokenorders() - assert_equal(result, []) - - # getting token balance for pubkey - result = rpc.tokenbalance(self.pubkey) - assert_success(result) - assert_equal(result['balance'], 0) - assert_equal(result['CCaddress'], 'RCRsm3VBXz8kKTsYaXKpy7pSEzrtNNQGJC') - assert_equal(result['tokenid'], self.pubkey) - # get token balance for token with pubkey result = rpc.tokenbalance(tokenid, self.pubkey) assert_success(result) @@ -421,7 +408,7 @@ class CryptoConditionsTest (BitcoinTestFramework): tokenask = rpc.tokenask("100", tokenid, "7.77") tokenaskhex = tokenask['hex'] tokenaskid = self.send_and_mine(tokenask['hex'], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) order = result[0] assert order, "found order" @@ -440,7 +427,7 @@ class CryptoConditionsTest (BitcoinTestFramework): assert txid, "found txid" # should be no token orders - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # checking ask cancellation @@ -448,7 +435,7 @@ class CryptoConditionsTest (BitcoinTestFramework): testorderid = self.send_and_mine(testorder['hex'], rpc) cancel = rpc.tokencancelask(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # invalid numtokens bid @@ -474,7 +461,7 @@ class CryptoConditionsTest (BitcoinTestFramework): tokenbid = rpc.tokenbid("100", tokenid, "10") tokenbidhex = tokenbid['hex'] tokenbidid = self.send_and_mine(tokenbid['hex'], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) order = result[0] assert order, "found order" @@ -493,7 +480,7 @@ class CryptoConditionsTest (BitcoinTestFramework): assert txid, "found txid" # should be no token orders - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # checking bid cancellation @@ -501,7 +488,7 @@ class CryptoConditionsTest (BitcoinTestFramework): testorderid = self.send_and_mine(testorder['hex'], rpc) cancel = rpc.tokencancelbid(tokenid, testorderid) self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders() + result = rpc.tokenorders(tokenid) assert_equal(result, []) # invalid token transfer amount (have to add status to CC code!) @@ -522,11 +509,11 @@ class CryptoConditionsTest (BitcoinTestFramework): def run_rewards_tests(self): rpc = self.nodes[0] result = rpc.rewardsaddress() - for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress']: + for x in ['myCCAddress(Rewards)', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: assert_equal(result[x][0], 'R') result = rpc.rewardsaddress(self.pubkey) - for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress', 'CCaddress']: + for x in ['myCCAddress(Rewards)', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: assert_equal(result[x][0], 'R') # no rewards yet @@ -637,12 +624,13 @@ class CryptoConditionsTest (BitcoinTestFramework): result = rpc.oraclesaddress() assert_success(result) - for x in ['OraclesCCaddress', 'Oraclesmarker', 'myCCaddress', 'myaddress']: + + for x in ['OraclesCCAddress', 'OraclesNormalAddress', 'myCCAddress(Oracles)','OraclesCCTokensAddress', 'myaddress']: assert_equal(result[x][0], 'R') result = rpc.oraclesaddress(self.pubkey) assert_success(result) - for x in ['OraclesCCaddress', 'Oraclesmarker', 'myCCaddress', 'myaddress']: + for x in ['OraclesCCAddress', 'OraclesNormalAddress', 'myCCAddress(Oracles)','OraclesCCTokensAddress', 'myaddress']: assert_equal(result[x][0], 'R') # there are no oracles created yet @@ -674,7 +662,6 @@ class CryptoConditionsTest (BitcoinTestFramework): # assert_success(result) # globals()["oracle_{}".format(f)] = self.send_and_mine(result['hex'], rpc) - def run_test (self): print("Mining blocks...") rpc = self.nodes[0] From 1f19c7c98710347b98300eaecafdd7ee3ec82029 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Mar 2019 15:39:33 +0800 Subject: [PATCH 3078/3904] push fixes to sync PAY --- src/cc/payments.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 93272fad7..aece40b67 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -181,7 +181,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & //it is a pay to pubkey vout //the "pubkey" is just 0x02 if ( tx.vout.size() < 2 ) - return(false); + return(eval->Invalid("not enough vouts")); if ( tx.vout.back().scriptPubKey[0] == OP_RETURN ) { scriptpubkey = HexStr(tx.vout[tx.vout.size()-2].scriptPubKey.begin()+2, tx.vout[tx.vout.size()-2].scriptPubKey.end()-1); @@ -198,7 +198,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( tmptx.vout.size() > 0 && DecodePaymentsOpRet(tmptx.vout[tmptx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) { if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 ) - return(false); + return(eval->Invalid("negative values")); Paymentspk = GetUnspendable(cp,0); //fprintf(stderr, "lockedblocks.%i minrelease.%i totalallocations.%i txidopret1.%s txidopret2.%s\n",lockedblocks, minrelease, totalallocations, txidoprets[0].ToString().c_str(), txidoprets[1].ToString().c_str() ); @@ -222,11 +222,11 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // sanity check to make sure we got all the required info if ( allocations.size() == 0 || scriptPubKeys.size() == 0 || allocations.size() != scriptPubKeys.size() ) - return(false); + return(eval->Invalid("missing data cannot validate")); //fprintf(stderr, "totalallocations.%i checkallocations.%i\n",totalallocations, checkallocations); if ( totalallocations != checkallocations ) - return(false); + return(eval->Invalid("allocation missmatch")); txidpk = CCtxidaddr(txidaddr,createtxid); GetCCaddress1of2(cp,coinaddr,Paymentspk,txidpk); @@ -234,7 +234,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // make sure change is in vout 0 and is paying to the contract address. if ( (change= IsPaymentsvout(cp,tx,0,coinaddr)) == 0 ) - return(false); + return(eval->Invalid("change is in wrong vout or is wrong tx type")); // Check vouts go to the right place and pay the right amounts. int64_t amount = 0, checkamount; int32_t n = 0; @@ -245,7 +245,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( destscriptPubKey != voutscriptPubKey ) { fprintf(stderr, "pays wrong destination destscriptPubKey.%s voutscriptPubKey.%s\n", destscriptPubKey.c_str(), voutscriptPubKey.c_str()); - return(false); + return(eval->Invalid("pays wrong address")); } int64_t test = allocations[n]; test *= checkamount; @@ -253,18 +253,19 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( test != tx.vout[i].nValue ) { fprintf(stderr, "vout.%i test.%li vs nVlaue.%li\n",i, test, tx.vout[i].nValue); - return(false); + //return(eval->Invalid("amounts do not match")); } amount += tx.vout[i].nValue; n++; } + // This is a backup check to make sure there are no extra vouts paying something else! if ( checkamount != amount ) - return(false); + return(eval->Invalid("amounts do not match")); if ( amount < minrelease*COIN ) { fprintf(stderr, "does not meet minrelease amount.%li minrelease.%li\n",amount, (int64_t)minrelease*COIN ); - return(false); + //return(eval->Invalid("amount is too small")); } i = 0; @@ -274,24 +275,26 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( myGetTransaction(vin.prevout.hash,txin,blockhash) ) { // check the vin comes from the CC address's - if ( IsPaymentsvout(cp,txin,i,coinaddr) != 0 ) + char destaddr[64]; + Getscriptaddress(destaddr,txin.vout[vin.prevout.n].scriptPubKey); + if ( strcmp(destaddr,coinaddr) != 0 ) { - fprintf(stderr, "vin.%i is not a payments CC vout\n", i); - return(false); + fprintf(stderr, "vin.%i is not a payments CC vout: txid.%s vout.%i\n", i, txin.GetHash().ToString().c_str(), vin.prevout.n); + return(eval->Invalid("vin is not paymentsCC type")); } // check the chain depth vs locked blcoks requirement. CBlockIndex* pblockindex = mapBlockIndex[blockhash]; if ( pblockindex->GetHeight() > chainActive.LastTip()->GetHeight()-lockedblocks ) { fprintf(stderr, "vin.%i is not elegible to be spent yet height.%i vs elegible_ht.%i\n", i, pblockindex->GetHeight(), chainActive.LastTip()->GetHeight()-lockedblocks); - return(false); + return(eval->Invalid("vin not elegible")); } //fprintf(stderr, "vin txid.%s\n", txin.GetHash().GetHex().c_str()); } i++; } - } - } + } else return(eval->Invalid("create transaction cannot decode")); + } else fprintf(stderr, "cannot get contract txn\n");//return(eval->Invalid("Could not get contract transaction")); // one of two addresses? only seems to ever use the 1! // change must go to 1of2 txidaddr // change is/must be in vout[0] From 0844c8290e15ac3f89848562bf1c93e114c8e146 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 23 Mar 2019 15:50:02 +0800 Subject: [PATCH 3079/3904] missed return --- src/cc/payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index aece40b67..7e2db0381 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -290,7 +290,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return(eval->Invalid("vin not elegible")); } //fprintf(stderr, "vin txid.%s\n", txin.GetHash().GetHex().c_str()); - } + } else return(eval->Invalid("cant get vin transaction")); i++; } } else return(eval->Invalid("create transaction cannot decode")); From afa0b894008073dc3f908f8fb2c79e3facb5fb20 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 01:58:45 -1100 Subject: [PATCH 3080/3904] Reduce keystrokes three --- src/cc/gamescc.cpp | 48 ++++++++++++++++++++++---------------------- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 29df990b5..89efcc6d2 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -136,30 +136,6 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); std::vector payload; int32_t n; - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) - { - if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) - { - komodo_sendmessage(4,8,"events",payload); - result.push_back(Pair("result","success")); - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt parsehexdata")); - } - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","not enough params")); - } - return(result); -} - UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); @@ -178,6 +154,30 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); std::vector payload; int32_t n; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + { + if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) + { + komodo_sendmessage(4,8,"events",payload); + result.push_back(Pair("result","success")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parsehexdata")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough params")); + } + return(result); +} + void komodo_netevent(std::vector payload) { int32_t i; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 495fa8774..0d6d9b3d4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -918,7 +918,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) - txfee = 10000; + txfee = 1000; // smaller than normal on purpose rogue_univalue(result,"keystrokes",-1,-1); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { From 00a8e9f59c2579c18f716ca1f21724b412c7b10d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 07:18:54 -1100 Subject: [PATCH 3081/3904] Force 1000 sats for keystrokes --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0d6d9b3d4..caf37b566 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -917,7 +917,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; - if ( txfee == 0 ) + // if ( txfee == 0 ) txfee = 1000; // smaller than normal on purpose rogue_univalue(result,"keystrokes",-1,-1); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) From d0aa3c7e13479468e3d692462b7780bc7086bfdc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 08:03:13 -1100 Subject: [PATCH 3082/3904] Skip keystrokes processing unless > 5 min from last one --- src/cc/rogue/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f146cfb4d..f0c0d2a5c 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -786,10 +786,13 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { + static uint32_t lasttime; char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { + if ( waitflag == 0 && time(NULL) < lasttime+300 ) + return; if ( rs->keystrokeshex != 0 ) { if ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) @@ -884,6 +887,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(rs->keystrokeshex), rs->keystrokeshex = 0; } } + lasttime = (uint32_t)time(NULL); } } From 219c6c4239f209fa0f1a559d7a9e568611adf66d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 19:56:21 -1100 Subject: [PATCH 3083/3904] Revert delay in keystrokes --- src/cc/rogue/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f0c0d2a5c..f146cfb4d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -786,13 +786,10 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - static uint32_t lasttime; char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { - if ( waitflag == 0 && time(NULL) < lasttime+300 ) - return; if ( rs->keystrokeshex != 0 ) { if ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) @@ -887,7 +884,6 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(rs->keystrokeshex), rs->keystrokeshex = 0; } } - lasttime = (uint32_t)time(NULL); } } From 867962c1e200a5bdcf3f963d4198e8e8955d2cb6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Mar 2019 14:57:56 +0800 Subject: [PATCH 3084/3904] add vin check for op_ret type funding. --- src/cc/payments.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 7e2db0381..1828e5ca2 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -239,7 +239,8 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // Check vouts go to the right place and pay the right amounts. int64_t amount = 0, checkamount; int32_t n = 0; checkamount = tx.GetValueOut() - change - PAYMENTS_TXFEE; - for (i = 1; i < (fHasOpret ? tx.vout.size()-2 : tx.vout.size()-1); i++) { + for (i = 1; i < (fHasOpret ? tx.vout.size()-2 : tx.vout.size()-1); i++) + { std::string destscriptPubKey = HexStr(scriptPubKeys[n].begin(),scriptPubKeys[n].end()); std::string voutscriptPubKey = HexStr(tx.vout[i].scriptPubKey.begin(),tx.vout[i].scriptPubKey.end()); if ( destscriptPubKey != voutscriptPubKey ) @@ -279,9 +280,13 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & Getscriptaddress(destaddr,txin.vout[vin.prevout.n].scriptPubKey); if ( strcmp(destaddr,coinaddr) != 0 ) { - fprintf(stderr, "vin.%i is not a payments CC vout: txid.%s vout.%i\n", i, txin.GetHash().ToString().c_str(), vin.prevout.n); - return(eval->Invalid("vin is not paymentsCC type")); - } + std::vector scriptPubKey,opret; CTransaction tx0; uint256 checktxid; + if ( txin.vout.size() < 2 || DecodePaymentsFundOpRet(txin.vout[txin.vout.size()-1].scriptPubKey,checktxid) != 'F' || checktxid != createtxid ) + { + fprintf(stderr, "vin.%i is not a payments CC vout: txid.%s\n", i, txin.GetHash().ToString().c_str()); + return(eval->Invalid("vin is not paymentsCC type")); + } else fprintf(stderr, "vin.%i opret type txid.%s\n", i, txin.GetHash().ToString().c_str()); + } // check the chain depth vs locked blcoks requirement. CBlockIndex* pblockindex = mapBlockIndex[blockhash]; if ( pblockindex->GetHeight() > chainActive.LastTip()->GetHeight()-lockedblocks ) From 82b078033164860fb727e1cb8693d8580540e791 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Mar 2019 17:47:55 +0800 Subject: [PATCH 3085/3904] clean up code --- src/cc/payments.cpp | 51 ++++++++++++++++++--------------------------- src/main.cpp | 2 +- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 1828e5ca2..8dec016b1 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -166,20 +166,14 @@ void pub2createtxid(char *str) bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { - char temp[128], coinaddr[64], txidaddr[64]; - std::string scriptpubkey; - uint256 createtxid; - uint256 blockhash; - CTransaction tmptx; - int32_t lockedblocks,minrelease,totalallocations; - std::vector txidoprets; - int32_t i; bool fHasOpret = false; - CPubKey txidpk,Paymentspk; - int64_t change; - - //the nValue 0 vout at the end of the tx (last one if no opret) - //it is a pay to pubkey vout - //the "pubkey" is just 0x02 + // one of two addresses + // change must go to 1of2 txidaddr + // change is/must be in vout[0] + // only 'F' or 1of2 txidaddr can be spent + // all vouts must match exactly + char temp[128], coinaddr[64], txidaddr[64]; std::string scriptpubkey; uint256 createtxid, blockhash; CTransaction tmptx; + int32_t i,lockedblocks,minrelease,totalallocations; int64_t change; std::vector txidoprets; bool fHasOpret = false; CPubKey txidpk,Paymentspk; + // user marker vout to get the createtxid if ( tx.vout.size() < 2 ) return(eval->Invalid("not enough vouts")); if ( tx.vout.back().scriptPubKey[0] == OP_RETURN ) @@ -203,9 +197,9 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & //fprintf(stderr, "lockedblocks.%i minrelease.%i totalallocations.%i txidopret1.%s txidopret2.%s\n",lockedblocks, minrelease, totalallocations, txidoprets[0].ToString().c_str(), txidoprets[1].ToString().c_str() ); // Get all the script pubkeys and allocations - std::vector allocations; + std::vector allocations; std::vector scriptPubKeys; - int32_t checkallocations = 0; + int64_t checkallocations = 0; i = 0; BOOST_FOREACH(const uint256& txidopret, txidoprets) { @@ -224,7 +218,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( allocations.size() == 0 || scriptPubKeys.size() == 0 || allocations.size() != scriptPubKeys.size() ) return(eval->Invalid("missing data cannot validate")); - //fprintf(stderr, "totalallocations.%i checkallocations.%i\n",totalallocations, checkallocations); + //fprintf(stderr, "totalallocations.%li checkallocations.%li\n",totalallocations, checkallocations); if ( totalallocations != checkallocations ) return(eval->Invalid("allocation missmatch")); @@ -254,7 +248,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( test != tx.vout[i].nValue ) { fprintf(stderr, "vout.%i test.%li vs nVlaue.%li\n",i, test, tx.vout[i].nValue); - //return(eval->Invalid("amounts do not match")); + return(eval->Invalid("amounts do not match")); } amount += tx.vout[i].nValue; n++; @@ -266,10 +260,11 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( amount < minrelease*COIN ) { fprintf(stderr, "does not meet minrelease amount.%li minrelease.%li\n",amount, (int64_t)minrelease*COIN ); - //return(eval->Invalid("amount is too small")); + return(eval->Invalid("amount is too small")); } - i = 0; + i = 0; + int32_t ht = chainActive.LastTip()->GetHeight(); BOOST_FOREACH(const CTxIn& vin, tx.vin) { CTransaction txin; @@ -280,31 +275,25 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & Getscriptaddress(destaddr,txin.vout[vin.prevout.n].scriptPubKey); if ( strcmp(destaddr,coinaddr) != 0 ) { - std::vector scriptPubKey,opret; CTransaction tx0; uint256 checktxid; + std::vector scriptPubKey,opret; uint256 checktxid; if ( txin.vout.size() < 2 || DecodePaymentsFundOpRet(txin.vout[txin.vout.size()-1].scriptPubKey,checktxid) != 'F' || checktxid != createtxid ) { fprintf(stderr, "vin.%i is not a payments CC vout: txid.%s\n", i, txin.GetHash().ToString().c_str()); return(eval->Invalid("vin is not paymentsCC type")); - } else fprintf(stderr, "vin.%i opret type txid.%s\n", i, txin.GetHash().ToString().c_str()); + } //else fprintf(stderr, "vin.%i opret type txid.%s\n", i, txin.GetHash().ToString().c_str()); } // check the chain depth vs locked blcoks requirement. CBlockIndex* pblockindex = mapBlockIndex[blockhash]; - if ( pblockindex->GetHeight() > chainActive.LastTip()->GetHeight()-lockedblocks ) + if ( pblockindex->GetHeight() > ht-lockedblocks ) { - fprintf(stderr, "vin.%i is not elegible to be spent yet height.%i vs elegible_ht.%i\n", i, pblockindex->GetHeight(), chainActive.LastTip()->GetHeight()-lockedblocks); + fprintf(stderr, "vin.%i is not elegible to be spent yet height.%i vs elegible_ht.%i\n", i, pblockindex->GetHeight(), ht-lockedblocks); return(eval->Invalid("vin not elegible")); } - //fprintf(stderr, "vin txid.%s\n", txin.GetHash().GetHex().c_str()); } else return(eval->Invalid("cant get vin transaction")); i++; } } else return(eval->Invalid("create transaction cannot decode")); - } else fprintf(stderr, "cannot get contract txn\n");//return(eval->Invalid("Could not get contract transaction")); - // one of two addresses? only seems to ever use the 1! - // change must go to 1of2 txidaddr - // change is/must be in vout[0] - // only 'F' or 1of2 txidaddr can be spent - // all vouts must match exactly + } else return(eval->Invalid("Could not get contract transaction")); return(true); } // end of consensus code diff --git a/src/main.cpp b/src/main.cpp index 9930e733c..e520ad83f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7045,7 +7045,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } std::vector payload; vRecv >> payload; - //komodo_netevent(payload); + komodo_netevent(payload); return(true); } else if (strCommand == "verack") From 5a1c07c477ecbc2fe54a2ee64e3a1f0895a80e34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 23:31:14 -1100 Subject: [PATCH 3086/3904] +print --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 079ce1eea..c1f488c5c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2079,7 +2079,7 @@ void komodo_args(char *argv0) while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) { - fprintf(stderr,"waiting for datadir\n"); + fprintf(stderr,"waiting for datadir (%s)\n",dirname); #ifndef _WIN32 sleep(3); #else From 3c9b45bf0a38b82da505701692f3b24f3fe4d62c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Mar 2019 18:32:19 +0800 Subject: [PATCH 3087/3904] change allocations to int64 --- src/cc/payments.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 8dec016b1..0190bf198 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -77,14 +77,14 @@ // start of consensus code -CScript EncodePaymentsTxidOpRet(int32_t allocation,std::vector scriptPubKey,std::vector destopret) +CScript EncodePaymentsTxidOpRet(int64_t allocation,std::vector scriptPubKey,std::vector destopret) { CScript opret; uint8_t evalcode = EVAL_PAYMENTS; opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'T' << allocation << scriptPubKey << destopret); return(opret); } -uint8_t DecodePaymentsTxidOpRet(CScript scriptPubKey,int32_t &allocation,std::vector &destscriptPubKey,std::vector &destopret) +uint8_t DecodePaymentsTxidOpRet(CScript scriptPubKey,int64_t &allocation,std::vector &destscriptPubKey,std::vector &destopret) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); @@ -117,14 +117,14 @@ uint8_t DecodePaymentsFundOpRet(CScript scriptPubKey,uint256 &checktxid) return(0); } -CScript EncodePaymentsOpRet(int32_t lockedblocks,int32_t minrelease,int32_t totalallocations,std::vector txidoprets) +CScript EncodePaymentsOpRet(int32_t lockedblocks,int32_t minrelease,int64_t totalallocations,std::vector txidoprets) { CScript opret; uint8_t evalcode = EVAL_PAYMENTS; opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'C' << lockedblocks << minrelease << totalallocations << txidoprets); return(opret); } -uint8_t DecodePaymentsOpRet(CScript scriptPubKey,int32_t &lockedblocks,int32_t &minrelease,int32_t &totalallocations,std::vector &txidoprets) +uint8_t DecodePaymentsOpRet(CScript scriptPubKey,int32_t &lockedblocks,int32_t &minrelease,int64_t &totalallocations,std::vector &txidoprets) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); @@ -172,7 +172,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // only 'F' or 1of2 txidaddr can be spent // all vouts must match exactly char temp[128], coinaddr[64], txidaddr[64]; std::string scriptpubkey; uint256 createtxid, blockhash; CTransaction tmptx; - int32_t i,lockedblocks,minrelease,totalallocations; int64_t change; std::vector txidoprets; bool fHasOpret = false; CPubKey txidpk,Paymentspk; + int32_t i,lockedblocks,minrelease; int64_t change,totalallocations; std::vector txidoprets; bool fHasOpret = false; CPubKey txidpk,Paymentspk; // user marker vout to get the createtxid if ( tx.vout.size() < 2 ) return(eval->Invalid("not enough vouts")); @@ -203,12 +203,12 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & i = 0; BOOST_FOREACH(const uint256& txidopret, txidoprets) { - CTransaction tx0; std::vector scriptPubKey,opret; int32_t allocation; + CTransaction tx0; std::vector scriptPubKey,opret; int64_t allocation; if ( myGetTransaction(txidopret,tx0,blockhash) != 0 && tx0.vout.size() > 1 && DecodePaymentsTxidOpRet(tx0.vout[tx0.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { scriptPubKeys.push_back(CScript(scriptPubKey.begin(), scriptPubKey.end())); allocations.push_back(allocation); - //fprintf(stderr, "i.%i scriptpubkey.%s allocation.%i\n",i,scriptPubKeys[i].ToString().c_str(),allocation); + //fprintf(stderr, "i.%i scriptpubkey.%s allocation.%li\n",i,scriptPubKeys[i].ToString().c_str(),allocation); checkallocations += allocation; } i++; @@ -435,7 +435,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) { int32_t latestheight,nextheight = komodo_nextheight(); CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock; - CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,m,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t newamount,inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; + CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,m,numoprets=0,lockedblocks,minrelease; int64_t newamount,inputsum,amount,CCchange=0,totalallocations,checkallocations=0,allocation; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector txidoprets; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); From 55a5f398aaac8319453122dbe2b63e10607afaf6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 00:38:27 -1100 Subject: [PATCH 3088/3904] Sign event payload --- src/cc/gamescc.cpp | 69 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 89efcc6d2..7628db500 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -45,6 +45,16 @@ uint8_t games_opretdecode(CPubKey &pk,CScript scriptPubKey) return(0); } +uint8_t games_eventdecode(CPubKey &pk,std::vector &sig,std::vector &payload,std::vector message) +{ + uint8_t e,f; + if ( message.size() > 2 && E_UNMARSHAL(message,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) + { + return(f); + } + return(0); +} + UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) { CTransaction tx; @@ -154,15 +164,49 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +int32_t games_eventsign(std::vector &sig,std::vector payload,CPubKey pk) +{ + bool signSuccess; SignatureData sigdata; uint256 hash; uint8_t *ptr; auto consensusBranchId = 0; + const CKeyStore& keystore = *pwalletMain; + txNew.vin.resize(1); + txNew.vout.resize(1); + txNew.vin[0].prevout.hash = payload.GetHash(); + txNew.vin[0].prevout.n = 0; + txNew.vout[0].scriptPubKey = CScript() << payload << OP_DROP << ParseHex(HexString(pk)) << OP_CHECKSIG; + txNew.vout[0].nValue = (int32_t)payload.size(); + txNew.nLockTime = 0; + CTransaction txNewConst(txNew); + signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), txNew.vout[0].scriptPubKey, sigdata, consensusBranchId); + if ( signSuccess > 0 ) + { + UpdateTransaction(txNew,0,sigdata); + ptr = (uint8_t *)&sigdata.scriptSig[0]; + siglen = sigdata.scriptSig.size(); + sig.resize(siglen); + for (i=0; i payload; int32_t n; + UniValue result(UniValue::VOBJ); std::vector sig,payload; int32_t n; CPubKey mypk; uint256 hash; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) { - komodo_sendmessage(4,8,"events",payload); - result.push_back(Pair("result","success")); + mypk = pubkey2pk(Mypubkey()); + if ( games_eventsign(sig,payload,mypk) == 0 ) + { + komodo_sendmessage(4,8,"events",E_MARSHAL(ss << EVAL_GAMES << 'E' << mypk << sig << payload)); + result.push_back(Pair("result","success")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","signing ereror")); + } } else { @@ -178,12 +222,21 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -void komodo_netevent(std::vector payload) +void komodo_netevent(std::vector message) { - int32_t i; - for (i=0; i sig,payload; char str[67]; + if ( games_eventdecode(pk,sig,payload,message) == 'E' ) + { + for (i=0; i Date: Mon, 25 Mar 2019 00:45:04 -1100 Subject: [PATCH 3089/3904] Syntax --- src/cc/gamescc.cpp | 8 ++++---- src/cc/gamescc.h | 1 + src/cc/payments.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 7628db500..1a7ce0257 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -166,17 +166,17 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t games_eventsign(std::vector &sig,std::vector payload,CPubKey pk) { - bool signSuccess; SignatureData sigdata; uint256 hash; uint8_t *ptr; auto consensusBranchId = 0; + bool signSuccess; SignatureData sigdata; int32_t i,siglen; uint256 hash; uint8_t *ptr; auto consensusBranchId = 0; CMutableTransaction txNew; const CKeyStore& keystore = *pwalletMain; txNew.vin.resize(1); txNew.vout.resize(1); txNew.vin[0].prevout.hash = payload.GetHash(); txNew.vin[0].prevout.n = 0; - txNew.vout[0].scriptPubKey = CScript() << payload << OP_DROP << ParseHex(HexString(pk)) << OP_CHECKSIG; - txNew.vout[0].nValue = (int32_t)payload.size(); + txNew.vout[0].scriptPubKey = CScript() << payload << OP_DROP << ParseHex(HexStr(pk)) << OP_CHECKSIG; + txNew.vout[0].nValue = payload.size(); txNew.nLockTime = 0; CTransaction txNewConst(txNew); - signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), txNew.vout[0].scriptPubKey, sigdata, consensusBranchId); + signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, payload.size(), SIGHASH_ALL), txNew.vout[0].scriptPubKey, sigdata, consensusBranchId); if ( signSuccess > 0 ) { UpdateTransaction(txNew,0,sigdata); diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 02f589056..6e88b9e32 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -1,3 +1,4 @@ +#include "CCinclud.h" std::string MYCCLIBNAME = (char *)"gamescc"; diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 0190bf198..75c1431f0 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -569,7 +569,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); - CPubKey Paymentspk,mypk,txidpk; uint256 txid,hashBlock; int64_t amount; CScript opret; CTransaction tx; char txidaddr[64]; std::string rawtx; int32_t n,useopret = 0,lockedblocks,minrelease,totalallocations; std::vector txidoprets; + CPubKey Paymentspk,mypk,txidpk; uint256 txid,hashBlock; int64_t amount,totalallocations; CScript opret; CTransaction tx; char txidaddr[64]; std::string rawtx; int32_t n,useopret = 0,lockedblocks,minrelease; std::vector txidoprets; cJSON *params = payments_reparse(&n,jsonstr); mypk = pubkey2pk(Mypubkey()); Paymentspk = GetUnspendable(cp,0); @@ -662,7 +662,7 @@ UniValue PaymentsTxidopret(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk,mypk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations=0; std::string rawtx; + UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk,mypk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,lockedblocks,minrelease; std::string rawtx; int64_t totalallocations = 0; cJSON *params = payments_reparse(&n,jsonstr); if ( params != 0 && n >= 4 ) { From 5a6c3fa7e71c922407ff77d7e35fbcd01915a3bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 00:45:37 -1100 Subject: [PATCH 3090/3904] E --- src/cc/gamescc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 6e88b9e32..143ecc50a 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -1,4 +1,4 @@ -#include "CCinclud.h" +#include "CCinclude.h" std::string MYCCLIBNAME = (char *)"gamescc"; From aa1c34fbf488d065593c2703ea065ff6c07d79fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 00:49:17 -1100 Subject: [PATCH 3091/3904] Syntax --- src/cc/gamescc.cpp | 2 +- src/cc/gamescc.h | 1 + src/cc/payments.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 1a7ce0257..7aa7c46da 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -229,7 +229,7 @@ void komodo_netevent(std::vector message) { for (i=0; i scriptPubKey,opret; int32_t allocation; + std::vector scriptPubKey,opret; int64_t allocation; if ( myGetTransaction(txidoprets[i],tx,hashBlock) != 0 && tx.vout.size() > 1 && DecodePaymentsTxidOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) { totalallocations += allocation; @@ -732,7 +732,7 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,j,n,flag=0,allocation,numoprets=0,lockedblocks,minrelease,totalallocations; std::vector txidoprets; int64_t funds,fundsopret; char fundsaddr[64],fundsopretaddr[64],txidaddr[64],*outstr; uint256 createtxid,hashBlock; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,j,n,flag=0,numoprets=0,lockedblocks,minrelease; std::vector txidoprets; int64_t funds,fundsopret,totalallocations=0,allocation; char fundsaddr[64],fundsopretaddr[64],txidaddr[64],*outstr; uint256 createtxid,hashBlock; cJSON *params = payments_reparse(&n,jsonstr); if ( params != 0 && n == 1 ) { From 2f26df49238a89979a9de18d3cd8f7e8261ff67d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 00:52:36 -1100 Subject: [PATCH 3092/3904] Test --- src/cc/gamescc.cpp | 3 ++- src/cc/gamescc.h | 5 +++++ src/cc/payments.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 7aa7c46da..c56df410b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1,3 +1,4 @@ +#include "gamescc.h" /* ./c cclib rng 17 \"[%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,250]\" @@ -229,7 +230,7 @@ void komodo_netevent(std::vector message) { for (i=0; ievalcode == EVAL_GAMES ) \ return(result); \ } \ } + +#endif diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 3ee592205..184c92d33 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -819,7 +819,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) { std::vector > addressIndex; uint256 txid,hashBlock; - UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease,totalallocations; std::vector txidoprets; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease; std::vector txidoprets; int64_t totalallocations; Paymentspk = GetUnspendable(cp,0); GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk); SetCCtxids(addressIndex,markeraddr); From 807ae7314a72e2b864d62839aa35d7f4a31f9409 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 00:54:40 -1100 Subject: [PATCH 3093/3904] Test --- src/cc/gamescc.cpp | 2 +- src/cc/gamescc.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index c56df410b..2163d46c5 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -230,7 +230,7 @@ void komodo_netevent(std::vector message) { for (i=0; i Date: Mon, 25 Mar 2019 12:56:01 +0100 Subject: [PATCH 3094/3904] update rpc-cc scripts for address keys --- qa/rpc-tests/cryptoconditions.py | 690 ---------------------- qa/rpc-tests/cryptoconditions_channels.py | 11 +- qa/rpc-tests/cryptoconditions_dice.py | 13 +- qa/rpc-tests/cryptoconditions_faucet.py | 12 +- qa/rpc-tests/cryptoconditions_gateways.py | 6 +- qa/rpc-tests/cryptoconditions_heir.py | 12 +- qa/rpc-tests/cryptoconditions_oracles.py | 12 +- qa/rpc-tests/cryptoconditions_rewards.py | 12 +- qa/rpc-tests/cryptoconditions_token.py | 20 +- 9 files changed, 63 insertions(+), 725 deletions(-) delete mode 100755 qa/rpc-tests/cryptoconditions.py diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py deleted file mode 100755 index d5456e801..000000000 --- a/qa/rpc-tests/cryptoconditions.py +++ /dev/null @@ -1,690 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2018 SuperNET developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.authproxy import JSONRPCException -from test_framework.util import assert_equal, assert_greater_than, \ - initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ - stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises - -import time -from decimal import Decimal -from random import choice -from string import ascii_uppercase - -def assert_success(result): - assert_equal(result['result'], 'success') - -def assert_error(result): - assert_equal(result['result'], 'error') - -def generate_random_string(length): - random_string = ''.join(choice(ascii_uppercase) for i in range(length)) - return random_string - -class CryptoConditionsTest (BitcoinTestFramework): - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid - - def run_faucet_tests(self): - rpc = self.rpc - rpc1 = self.rpc1 - - # basic sanity tests - result = rpc.getwalletinfo() - assert_greater_than(result['txcount'], 100) - assert_greater_than(result['balance'], 0.0) - balance = result['balance'] - - faucet = rpc.faucetaddress() - assert_equal(faucet['result'], 'success') - # verify all keys look like valid AC addrs, could be better - for x in ['myCCAddress(Faucet)', 'FaucetCCAddress', 'FaucetCCTokensAddress', 'myaddress', 'FaucetNormalAddress']: - assert_equal(faucet[x][0], 'R') - - result = rpc.faucetaddress(self.pubkey) - assert_success(result) - # test that additional CCaddress key is returned - for x in ['myCCAddress(Faucet)', 'FaucetCCAddress', 'FaucetCCTokensAddress', 'myaddress', 'FaucetNormalAddress']: - assert_equal(result[x][0], 'R') - - # no funds in the faucet yet - result = rpc.faucetget() - assert_error(result) - - result = rpc.faucetinfo() - assert_success(result) - - result = rpc.faucetfund("0") - assert_error(result) - - result = rpc.faucetfund("-1") - assert_error(result) - - # we need at least 1 + txfee to get - result = rpc.faucetfund("2") - assert_success(result) - assert result['hex'], "hex key found" - - # broadcast the xtn - result = rpc.sendrawtransaction(result['hex']) - txid = result[0] - assert txid, "found txid" - - # we need the tx above to be confirmed in the next block - rpc.generate(1) - self.sync_all() - - result = rpc.getwalletinfo() - # minus one block reward - balance2 = result['balance'] - 100000 - # make sure our balance is less now - assert_greater_than(balance, balance2) - - result = rpc.faucetinfo() - assert_success(result) - assert_greater_than( result['funding'], 0 ) - - # claiming faucet on second node - faucetgethex = rpc1.faucetget() - assert_success(faucetgethex) - assert faucetgethex['hex'], "hex key found" - - balance1 = rpc1.getwalletinfo()['balance'] - - # try to broadcast the faucetget transaction - result = self.send_and_mine(faucetgethex['hex'], rpc1) - assert txid, "transaction broadcasted" - - balance2 = rpc1.getwalletinfo()['balance'] - assert_greater_than(balance2, balance1) - - self.sync_all() - - def run_dice_tests(self): - rpc = self.nodes[0] - rpc1 = self.nodes[1] - self.sync_all() - - # have to generate few blocks on second node to be able to place bets - rpc1.generate(10) - result = rpc1.getbalance() - assert_greater_than(result, 100000) - - dice = rpc.diceaddress() - assert_equal(dice['result'], 'success') - for x in ['myCCAddress(Dice)', 'DiceCCAddress', 'DiceCCTokensAddress', 'myaddress', 'DiceNormalAddress']: - assert_equal(dice[x][0], 'R') - - dice = rpc.diceaddress(self.pubkey) - assert_equal(dice['result'], 'success') - for x in ['myCCAddress(Dice)', 'DiceCCAddress', 'DiceCCTokensAddress', 'myaddress', 'DiceNormalAddress']: - assert_equal(dice[x][0], 'R') - - # no dice created yet - result = rpc.dicelist() - assert_equal(result, []) - - # creating dice plan with too long name (>8 chars) - result = rpc.dicefund("THISISTOOLONG", "10000", "10", "10000", "10", "5") - assert_error(result) - - # creating dice plan with < 100 funding - result = rpc.dicefund("LUCKY","10","1","10000","10","5") - assert_error(result) - - # creating dice plan with 0 blocks timeout - result = rpc.dicefund("LUCKY","10","1","10000","10","0") - assert_error(result) - - # creating dice plan - dicefundtx = rpc.dicefund("LUCKY","1000","1","800","10","5") - diceid = self.send_and_mine(dicefundtx['hex'], rpc) - - # checking if it in plans list now - result = rpc.dicelist() - assert_equal(result[0], diceid) - - # set dice name for futher usage - dicename = "LUCKY" - - # adding zero funds to plan - result = rpc.diceaddfunds(dicename,diceid,"0") - assert_error(result) - - # adding negative funds to plan - result = rpc.diceaddfunds(dicename,diceid,"-1") - assert_error(result) - - # adding funds to plan - addfundstx = rpc.diceaddfunds(dicename,diceid,"1100") - result = self.send_and_mine(addfundstx['hex'], rpc) - - # checking if funds added to plan - result = rpc.diceinfo(diceid) - assert_equal(result["funding"], "2100.00000000") - - # not valid dice info checking - result = rpc.diceinfo("invalid") - assert_error(result) - - # placing 0 amount bet - result = rpc1.dicebet(dicename,diceid,"0","2") - assert_error(result) - - # placing negative amount bet - result = rpc1.dicebet(dicename,diceid,"-1","2") - assert_error(result) - - # placing bet more than maxbet - result = rpc1.dicebet(dicename,diceid,"900","2") - assert_error(result) - - # placing bet with amount more than funding - result = rpc1.dicebet(dicename,diceid,"3000","2") - assert_error(result) - - # placing bet with potential won more than funding - result = rpc1.dicebet(dicename,diceid,"750","9") - assert_error(result) - - # placing 0 odds bet - result = rpc1.dicebet(dicename,diceid,"1","0") - assert_error(result) - - # placing negative odds bet - result = rpc1.dicebet(dicename,diceid,"1","-1") - assert_error(result) - - # placing bet with odds more than allowed - result = rpc1.dicebet(dicename,diceid,"1","11") - assert_error(result) - - # placing bet with not correct dice name - result = rpc1.dicebet("nope",diceid,"100","2") - assert_error(result) - - # placing bet with not correct dice id - result = rpc1.dicebet(dicename,self.pubkey,"100","2") - assert_error(result) - - # have to make some entropy for the next test - entropytx = 0 - fundingsum = 1 - while entropytx < 110: - fundingsuminput = str(fundingsum) - fundinghex = rpc.diceaddfunds(dicename,diceid,fundingsuminput) - result = self.send_and_mine(fundinghex['hex'], rpc) - entropytx = entropytx + 1 - fundingsum = fundingsum + 1 - - rpc.generate(2) - self.sync_all() - - # valid bet placing - placebet = rpc1.dicebet(dicename,diceid,"100","2") - betid = self.send_and_mine(placebet["hex"], rpc1) - assert result, "bet placed" - - # check bet status - result = rpc1.dicestatus(dicename,diceid,betid) - assert_success(result) - - # note initial dice funding state at this point. - # TODO: track player balance somehow (hard to do because of mining and fees) - diceinfo = rpc.diceinfo(diceid) - funding = float(diceinfo['funding']) - - # # placing same amount bets with amount 1 and odds 1:3, checking if balance changed correct - # losscounter = 0 - # wincounter = 0 - # betcounter = 0 - # - # while (betcounter < 10): - # placebet = rpc1.dicebet(dicename,diceid,"1","2") - # betid = self.send_and_mine(placebet["hex"], rpc1) - # time.sleep(3) - # self.sync_all() - # finish = rpc.dicefinish(dicename,diceid,betid) - # self.send_and_mine(finish["hex"], rpc1) - # self.sync_all() - # time.sleep(3) - # betresult = rpc1.dicestatus(dicename,diceid,betid) - # betcounter = betcounter + 1 - # if betresult["status"] == "loss": - # losscounter = losscounter + 1 - # elif betresult["status"] == "win": - # wincounter = wincounter + 1 - # else: - # pass - # - # # funding balance should increase if player loss, decrease if player won - # fundbalanceguess = funding + losscounter - wincounter * 2 - # fundinfoactual = rpc.diceinfo(diceid) - # assert_equal(round(fundbalanceguess),round(float(fundinfoactual['funding']))) - - def run_token_tests(self): - rpc = self.nodes[0] - result = rpc.tokenaddress() - assert_success(result) - for x in ['myCCAddress(Tokens)', 'TokensNormalAddress', 'TokensNormalAddress', 'myaddress','TokensCCAddress']: - assert_equal(result[x][0], 'R') - - result = rpc.tokenaddress(self.pubkey) - assert_success(result) - for x in ['myCCAddress(Tokens)', 'TokensNormalAddress', 'TokensNormalAddress', 'myaddress','TokensCCAddress']: - assert_equal(result[x][0], 'R') - # there are no tokens created yet - result = rpc.tokenlist() - assert_equal(result, []) - - # trying to create token with negaive supply - result = rpc.tokencreate("NUKE", "-1987420", "no bueno supply") - assert_error(result) - - # creating token with name more than 32 chars - result = rpc.tokencreate("NUKE123456789012345678901234567890", "1987420", "name too long") - assert_error(result) - - # creating valid token - result = rpc.tokencreate("DUKE", "1987.420", "Duke's custom token") - assert_success(result) - - tokenid = self.send_and_mine(result['hex'], rpc) - - result = rpc.tokenlist() - assert_equal(result[0], tokenid) - - # get token balance for token with pubkey - result = rpc.tokenbalance(tokenid, self.pubkey) - assert_success(result) - assert_equal(result['balance'], 198742000000) - assert_equal(result['tokenid'], tokenid) - - # get token balance for token without pubkey - result = rpc.tokenbalance(tokenid) - assert_success(result) - assert_equal(result['balance'], 198742000000) - assert_equal(result['tokenid'], tokenid) - - # this is not a valid assetid - result = rpc.tokeninfo(self.pubkey) - assert_error(result) - - # check tokeninfo for valid token - result = rpc.tokeninfo(tokenid) - assert_success(result) - assert_equal(result['tokenid'], tokenid) - assert_equal(result['owner'], self.pubkey) - assert_equal(result['name'], "DUKE") - assert_equal(result['supply'], 198742000000) - assert_equal(result['description'], "Duke's custom token") - - # invalid numtokens ask - result = rpc.tokenask("-1", tokenid, "1") - assert_error(result) - - # invalid numtokens ask - result = rpc.tokenask("0", tokenid, "1") - assert_error(result) - - # invalid price ask - result = rpc.tokenask("1", tokenid, "-1") - assert_error(result) - - # invalid price ask - result = rpc.tokenask("1", tokenid, "0") - assert_error(result) - - # invalid tokenid ask - result = rpc.tokenask("100", "deadbeef", "1") - assert_error(result) - - # valid ask - tokenask = rpc.tokenask("100", tokenid, "7.77") - tokenaskhex = tokenask['hex'] - tokenaskid = self.send_and_mine(tokenask['hex'], rpc) - result = rpc.tokenorders(tokenid) - order = result[0] - assert order, "found order" - - # invalid ask fillunits - result = rpc.tokenfillask(tokenid, tokenaskid, "0") - assert_error(result) - - # invalid ask fillunits - result = rpc.tokenfillask(tokenid, tokenaskid, "-777") - assert_error(result) - - # valid ask fillunits - fillask = rpc.tokenfillask(tokenid, tokenaskid, "777") - result = self.send_and_mine(fillask['hex'], rpc) - txid = result[0] - assert txid, "found txid" - - # should be no token orders - result = rpc.tokenorders(tokenid) - assert_equal(result, []) - - # checking ask cancellation - testorder = rpc.tokenask("100", tokenid, "7.77") - testorderid = self.send_and_mine(testorder['hex'], rpc) - cancel = rpc.tokencancelask(tokenid, testorderid) - self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders(tokenid) - assert_equal(result, []) - - # invalid numtokens bid - result = rpc.tokenbid("-1", tokenid, "1") - assert_error(result) - - # invalid numtokens bid - result = rpc.tokenbid("0", tokenid, "1") - assert_error(result) - - # invalid price bid - result = rpc.tokenbid("1", tokenid, "-1") - assert_error(result) - - # invalid price bid - result = rpc.tokenbid("1", tokenid, "0") - assert_error(result) - - # invalid tokenid bid - result = rpc.tokenbid("100", "deadbeef", "1") - assert_error(result) - - tokenbid = rpc.tokenbid("100", tokenid, "10") - tokenbidhex = tokenbid['hex'] - tokenbidid = self.send_and_mine(tokenbid['hex'], rpc) - result = rpc.tokenorders(tokenid) - order = result[0] - assert order, "found order" - - # invalid bid fillunits - result = rpc.tokenfillbid(tokenid, tokenbidid, "0") - assert_error(result) - - # invalid bid fillunits - result = rpc.tokenfillbid(tokenid, tokenbidid, "-777") - assert_error(result) - - # valid bid fillunits - fillbid = rpc.tokenfillbid(tokenid, tokenbidid, "1000") - result = self.send_and_mine(fillbid['hex'], rpc) - txid = result[0] - assert txid, "found txid" - - # should be no token orders - result = rpc.tokenorders(tokenid) - assert_equal(result, []) - - # checking bid cancellation - testorder = rpc.tokenbid("100", tokenid, "7.77") - testorderid = self.send_and_mine(testorder['hex'], rpc) - cancel = rpc.tokencancelbid(tokenid, testorderid) - self.send_and_mine(cancel["hex"], rpc) - result = rpc.tokenorders(tokenid) - assert_equal(result, []) - - # invalid token transfer amount (have to add status to CC code!) - randompubkey = "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" - result = rpc.tokentransfer(tokenid,randompubkey,"0") - assert_error(result) - - # invalid token transfer amount (have to add status to CC code!) - result = rpc.tokentransfer(tokenid,randompubkey,"-1") - assert_error(result) - - # valid token transfer - sendtokens = rpc.tokentransfer(tokenid,randompubkey,"1") - self.send_and_mine(sendtokens["hex"], rpc) - result = rpc.tokenbalance(tokenid,randompubkey) - assert_equal(result["balance"], 1) - - def run_rewards_tests(self): - rpc = self.nodes[0] - result = rpc.rewardsaddress() - for x in ['myCCAddress(Rewards)', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: - assert_equal(result[x][0], 'R') - - result = rpc.rewardsaddress(self.pubkey) - for x in ['myCCAddress(Rewards)', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: - assert_equal(result[x][0], 'R') - - # no rewards yet - result = rpc.rewardslist() - assert_equal(result, []) - - # looking up non-existent reward should return error - result = rpc.rewardsinfo("none") - assert_error(result) - - # creating rewards plan with name > 8 chars, should return error - result = rpc.rewardscreatefunding("STUFFSTUFF", "7777", "25", "0", "10", "10") - assert_error(result) - - # creating rewards plan with 0 funding - result = rpc.rewardscreatefunding("STUFF", "0", "25", "0", "10", "10") - assert_error(result) - - # creating rewards plan with 0 maxdays - result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "0") - assert_error(result) - - # creating rewards plan with > 25% APR - result = rpc.rewardscreatefunding("STUFF", "7777", "30", "0", "10", "10") - assert_error(result) - - # creating valid rewards plan - result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "10") - assert result['hex'], 'got raw xtn' - fundingtxid = rpc.sendrawtransaction(result['hex']) - assert fundingtxid, 'got txid' - - # confirm the above xtn - rpc.generate(1) - result = rpc.rewardsinfo(fundingtxid) - assert_success(result) - assert_equal(result['name'], 'STUFF') - assert_equal(result['APR'], "25.00000000") - assert_equal(result['minseconds'], 0) - assert_equal(result['maxseconds'], 864000) - assert_equal(result['funding'], "7777.00000000") - assert_equal(result['mindeposit'], "10.00000000") - assert_equal(result['fundingtxid'], fundingtxid) - - # checking if new plan in rewardslist - result = rpc.rewardslist() - assert_equal(result[0], fundingtxid) - - # creating reward plan with already existing name, should return error - result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "10") - assert_error(result) - - # add funding amount must be positive - result = rpc.rewardsaddfunding("STUFF", fundingtxid, "-1") - assert_error(result) - - # add funding amount must be positive - result = rpc.rewardsaddfunding("STUFF", fundingtxid, "0") - assert_error(result) - - # adding valid funding - result = rpc.rewardsaddfunding("STUFF", fundingtxid, "555") - addfundingtxid = self.send_and_mine(result['hex'], rpc) - assert addfundingtxid, 'got funding txid' - - # checking if funding added to rewardsplan - result = rpc.rewardsinfo(fundingtxid) - assert_equal(result['funding'], "8332.00000000") - - # trying to lock funds, locking funds amount must be positive - result = rpc.rewardslock("STUFF", fundingtxid, "-5") - assert_error(result) - - # trying to lock funds, locking funds amount must be positive - result = rpc.rewardslock("STUFF", fundingtxid, "0") - assert_error(result) - - # trying to lock less than the min amount is an error - result = rpc.rewardslock("STUFF", fundingtxid, "7") - assert_error(result) - - # locking funds in rewards plan - result = rpc.rewardslock("STUFF", fundingtxid, "10") - assert_success(result) - locktxid = result['hex'] - assert locktxid, "got lock txid" - - # locktxid has not been broadcast yet - result = rpc.rewardsunlock("STUFF", fundingtxid, locktxid) - assert_error(result) - - # broadcast xtn - txid = rpc.sendrawtransaction(locktxid) - assert txid, 'got txid from sendrawtransaction' - - # confirm the xtn above - rpc.generate(1) - - # will not unlock since reward amount is less than tx fee - result = rpc.rewardsunlock("STUFF", fundingtxid, locktxid) - assert_error(result) - - def run_oracles_tests(self): - rpc = self.nodes[0] - rpc1 = self.nodes[1] - - result = rpc1.oraclesaddress() - - result = rpc.oraclesaddress() - assert_success(result) - - for x in ['OraclesCCAddress', 'OraclesNormalAddress', 'myCCAddress(Oracles)','OraclesCCTokensAddress', 'myaddress']: - assert_equal(result[x][0], 'R') - - result = rpc.oraclesaddress(self.pubkey) - assert_success(result) - for x in ['OraclesCCAddress', 'OraclesNormalAddress', 'myCCAddress(Oracles)','OraclesCCTokensAddress', 'myaddress']: - assert_equal(result[x][0], 'R') - - # there are no oracles created yet - result = rpc.oracleslist() - assert_equal(result, []) - - # looking up non-existent oracle should return error. - result = rpc.oraclesinfo("none") - assert_error(result) - - # attempt to create oracle with not valid data type should return error - result = rpc.oraclescreate("Test", "Test", "Test") - assert_error(result) - - # attempt to create oracle with description > 32 symbols should return error - too_long_name = generate_random_string(33) - result = rpc.oraclescreate(too_long_name, "Test", "s") - - - # attempt to create oracle with description > 4096 symbols should return error - too_long_description = generate_random_string(4100) - result = rpc.oraclescreate("Test", too_long_description, "s") - assert_error(result) - # # valid creating oracles of different types - # # using such naming to re-use it for data publishing / reading (e.g. oracle_s for s type) - # valid_formats = ["s", "S", "d", "D", "c", "C", "t", "T", "i", "I", "l", "L", "h", "Ihh"] - # for f in valid_formats: - # result = rpc.oraclescreate("Test", "Test", f) - # assert_success(result) - # globals()["oracle_{}".format(f)] = self.send_and_mine(result['hex'], rpc) - - def run_test (self): - print("Mining blocks...") - rpc = self.nodes[0] - rpc1 = self.nodes[1] - # utxos from block 1 become mature in block 101 - rpc.generate(101) - self.sync_all() - rpc.getinfo() - rpc1.getinfo() - # this corresponds to -pubkey above - print("Importing privkeys") - rpc.importprivkey(self.privkey) - rpc1.importprivkey(self.privkey1) - self.run_faucet_tests() - self.sync_all() - self.run_rewards_tests() - self.sync_all() - self.run_dice_tests() - self.sync_all() - self.run_token_tests() - self.sync_all() - self.run_oracles_tests() - - -if __name__ == '__main__': - CryptoConditionsTest ().main() diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 71f62f49d..2248efeab 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -27,13 +27,14 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): rpc1 = self.nodes[1] # checking channelsaddress call - + result = rpc.channelsaddress(self.pubkey) assert_success(result) # test that additional CCaddress key is returned - for x in ['ChannelsCC1of2TokensAddress', 'myCCAddress(Channels)', 'ChannelsCC1of2Address', 'myAddress', \ - 'myCCaddress', 'ChannelsNormalAddress', 'PubkeyCCaddress(Channels)', 'ChannelsCCAddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') # getting empty channels list result = rpc.channelslist() @@ -80,7 +81,7 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): # now in channelinfo payment information should appear result = rpc.channelsinfo(channel_txid) assert_equal(result["Transactions"][1]["Payment"], payment_tx_id) - + time.sleep(90) # number of payments should be equal 1 (one denomination used) result = rpc.channelsinfo(channel_txid)["Transactions"][1]["Number of payments"] assert_equal(result, 1) diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 7b960cb67..e93260178 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -28,15 +28,20 @@ class CryptoconditionsDiceTest(CryptoconditionsTestFramework): for x in result.keys(): print(x+": "+str(result[x])) assert_equal(result['result'], 'success') - for x in ['myCCaddress', 'DiceCCAddress', 'myaddress']: - assert_equal(result[x][0], 'R') + + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.diceaddress(self.pubkey) for x in result.keys(): print(x+": "+str(result[x])) assert_equal(result['result'], 'success') - for x in ['myCCaddress', 'DiceCCAddress', 'myaddress', 'DiceCCTokensAddress', 'DiceNormalAddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') # no dice created yet result = rpc.dicelist() diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index c02522cc5..47e81b5ed 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -29,16 +29,20 @@ class CryptoconditionsFaucetTest(CryptoconditionsTestFramework): for x in result.keys(): print(x+": "+str(result[x])) # verify all keys look like valid AC addrs, could be better - for x in ['myCCaddress', 'FaucetCCTokensAddress', 'FaucetNormalAddress', 'myaddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.faucetaddress(self.pubkey) assert_success(result) for x in result.keys(): print(x+": "+str(result[x])) # test that additional CCaddress key is returned - for x in ['myCCaddress', 'FaucetCCTokensAddress', 'FaucetNormalAddress', 'myaddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') # no funds in the faucet yet result = rpc.faucetget() diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index a7f0cad2b..b12ea9f7e 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -20,8 +20,10 @@ class CryptoconditionsGatewaysTest(CryptoconditionsTestFramework): result = rpc.gatewaysaddress() assert_success(result) - for x in ['GatewaysCCaddress', 'myCCaddress', 'Gatewaysmarker', 'myaddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') assert_equal("03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40", result["GatewaysPubkey"]) diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index a2443f0b3..12ca8b3da 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -22,15 +22,19 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework): result = rpc.heiraddress('') assert_success(result) + # verify all keys look like valid AC addrs, could be better - for x in ['HeirNormalAddress', 'HeirCCTokensAddress', 'myaddress', 'myCCaddress', 'HeirCCAddress']: - assert_equal(result[x][0], 'R') + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.heiraddress(self.pubkey) assert_success(result) + # test that additional CCaddress key is returned - for x in ['HeirNormalAddress', 'myCCaddress', 'myaddress', 'HeirCC1of2Address', 'HeirCCAddress', 'HeirCC1of2TokensAddress']: - assert_equal(result[x][0], 'R') + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') # getting empty heir list result = rpc.heirlist() diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 008ab6256..953df5ca9 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -22,13 +22,17 @@ class CryptoconditionsOraclesTest(CryptoconditionsTestFramework): result = rpc.oraclesaddress() assert_success(result) - for x in ['myCCaddress', 'OraclesCCAddress', 'OraclesNormalAddress', 'myaddress', 'OraclesCCTokensAddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.oraclesaddress(self.pubkey) assert_success(result) - for x in ['myCCaddress', 'OraclesCCAddress', 'OraclesNormalAddress', 'myaddress', 'OraclesCCTokensAddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') # there are no oracles created yet result = rpc.oracleslist() diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index d70e40740..8fd5d4c9f 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -19,12 +19,16 @@ class CryptoconditionsRewardsTest(CryptoconditionsTestFramework): rpc = self.nodes[0] result = rpc.rewardsaddress() - for x in ['myCCaddress', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.rewardsaddress(self.pubkey) - for x in ['myCCaddress', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: - assert_equal(result[x][0], 'R') + + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') # no rewards yet result = rpc.rewardslist() diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index faf2cbc8d..263d85dde 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -21,23 +21,27 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): result = rpc.tokenaddress() assert_success(result) - for x in ['TokensCCAddress', 'myCCaddress', 'myCCAddress(Tokens)', 'myaddress', 'TokensNormalAddress']: - assert_equal(result[x][0], 'R') + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.tokenaddress(self.pubkey) assert_success(result) - for x in ['TokensCCAddress', 'myCCaddress', 'myCCAddress(Tokens)', 'myaddress', 'TokensNormalAddress']: - assert_equal(result[x][0], 'R') + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.assetsaddress() assert_success(result) - for x in ['AssetsCCAddress', 'myCCaddress', 'myCCAddress(Assets)', 'myaddress', 'AssetsNormalAddress']: - assert_equal(result[x][0], 'R') + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') result = rpc.assetsaddress(self.pubkey) assert_success(result) - for x in ['AssetsCCAddress', 'myCCaddress', 'myCCAddress(Assets)', 'myaddress', 'AssetsNormalAddress']: - assert_equal(result[x][0], 'R') + for x in result.keys(): + if x.find('ddress') > 0: + assert_equal(result[x][0], 'R') # there are no tokens created yet result = rpc.tokenlist() From d31eea878a798b8ac8486b18df4b4620a0316e74 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:00:30 -1100 Subject: [PATCH 3095/3904] Sha256 --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2163d46c5..790652ba1 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -171,7 +171,7 @@ int32_t games_eventsign(std::vector &sig,std::vector payload,C const CKeyStore& keystore = *pwalletMain; txNew.vin.resize(1); txNew.vout.resize(1); - txNew.vin[0].prevout.hash = payload.GetHash(); + vcalc_sha256(0,(uint8_t *)&txNew.vin[0].prevout.hash,&payload[0],(int32_t)payload.size()); txNew.vin[0].prevout.n = 0; txNew.vout[0].scriptPubKey = CScript() << payload << OP_DROP << ParseHex(HexStr(pk)) << OP_CHECKSIG; txNew.vout[0].nValue = payload.size(); @@ -230,7 +230,7 @@ void komodo_netevent(std::vector message) { for (i=0; i Date: Mon, 25 Mar 2019 20:00:54 +0800 Subject: [PATCH 3096/3904] Update cryptoconditions_channels.py --- qa/rpc-tests/cryptoconditions_channels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 2248efeab..7f82f2f3c 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -81,7 +81,7 @@ class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): # now in channelinfo payment information should appear result = rpc.channelsinfo(channel_txid) assert_equal(result["Transactions"][1]["Payment"], payment_tx_id) - time.sleep(90) + # number of payments should be equal 1 (one denomination used) result = rpc.channelsinfo(channel_txid)["Transactions"][1]["Number of payments"] assert_equal(result, 1) From 5aa85d7dad0f4bac5bf9fa533898044a59d4e9e9 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Mon, 25 Mar 2019 20:01:40 +0800 Subject: [PATCH 3097/3904] Update cryptoconditions_rewards.py --- qa/rpc-tests/cryptoconditions_rewards.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 8fd5d4c9f..57d3032b8 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -19,13 +19,11 @@ class CryptoconditionsRewardsTest(CryptoconditionsTestFramework): rpc = self.nodes[0] result = rpc.rewardsaddress() - for x in result.keys(): if x.find('ddress') > 0: assert_equal(result[x][0], 'R') result = rpc.rewardsaddress(self.pubkey) - for x in result.keys(): if x.find('ddress') > 0: assert_equal(result[x][0], 'R') From 1b5605f3f70bedbbab2aaf038226194e66008418 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Mon, 25 Mar 2019 20:02:31 +0800 Subject: [PATCH 3098/3904] Update cryptoconditions_dice.py --- qa/rpc-tests/cryptoconditions_dice.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index e93260178..7b9d3fbae 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -25,11 +25,8 @@ class CryptoconditionsDiceTest(CryptoconditionsTestFramework): assert_greater_than(result, 100000) result = rpc.diceaddress() - for x in result.keys(): - print(x+": "+str(result[x])) assert_equal(result['result'], 'success') - for x in result.keys(): if x.find('ddress') > 0: assert_equal(result[x][0], 'R') From 3a4fa333f7cec948e25fe4348fa621d2aa4913c0 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Mon, 25 Mar 2019 20:03:07 +0800 Subject: [PATCH 3099/3904] Update cryptoconditions_faucet.py --- qa/rpc-tests/cryptoconditions_faucet.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index 47e81b5ed..27c5fce4e 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -26,10 +26,8 @@ class CryptoconditionsFaucetTest(CryptoconditionsTestFramework): result = rpc.faucetaddress() assert_equal(result['result'], 'success') - for x in result.keys(): - print(x+": "+str(result[x])) + # verify all keys look like valid AC addrs, could be better - for x in result.keys(): if x.find('ddress') > 0: assert_equal(result[x][0], 'R') From 7077fcf08e73bf607aedd10650ba790478a87043 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:17:23 -1100 Subject: [PATCH 3100/3904] Test --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 790652ba1..101e17d18 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -173,7 +173,7 @@ int32_t games_eventsign(std::vector &sig,std::vector payload,C txNew.vout.resize(1); vcalc_sha256(0,(uint8_t *)&txNew.vin[0].prevout.hash,&payload[0],(int32_t)payload.size()); txNew.vin[0].prevout.n = 0; - txNew.vout[0].scriptPubKey = CScript() << payload << OP_DROP << ParseHex(HexStr(pk)) << OP_CHECKSIG; + txNew.vout[0].scriptPubKey = CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG; txNew.vout[0].nValue = payload.size(); txNew.nLockTime = 0; CTransaction txNewConst(txNew); From 581df62b25bd04dfcbe03bad35d25c1dded79336 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:19:00 -1100 Subject: [PATCH 3101/3904] Json fields --- src/cc/gamescc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 101e17d18..02df2eb42 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -192,7 +192,7 @@ int32_t games_eventsign(std::vector &sig,std::vector payload,C UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector sig,payload; int32_t n; CPubKey mypk; uint256 hash; + UniValue result(UniValue::VOBJ); std::vector sig,payload; int32_t n; CPubKey mypk; char str[67]; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) @@ -202,6 +202,8 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { komodo_sendmessage(4,8,"events",E_MARSHAL(ss << EVAL_GAMES << 'E' << mypk << sig << payload)); result.push_back(Pair("result","success")); + result.push_back(Pair("pubkey33",pubkey33_str(str,mypk))); + result.push_back(Pair("sig",sig.HexStr())); } else { From 26b7510dba44a548b88d86f5385d56f0d8af14c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:25:40 -1100 Subject: [PATCH 3102/3904] Low level signing --- src/cc/gamescc.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 02df2eb42..b828ea41f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -167,26 +167,20 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t games_eventsign(std::vector &sig,std::vector payload,CPubKey pk) { - bool signSuccess; SignatureData sigdata; int32_t i,siglen; uint256 hash; uint8_t *ptr; auto consensusBranchId = 0; CMutableTransaction txNew; - const CKeyStore& keystore = *pwalletMain; - txNew.vin.resize(1); - txNew.vout.resize(1); - vcalc_sha256(0,(uint8_t *)&txNew.vin[0].prevout.hash,&payload[0],(int32_t)payload.size()); - txNew.vin[0].prevout.n = 0; - txNew.vout[0].scriptPubKey = CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG; - txNew.vout[0].nValue = payload.size(); - txNew.nLockTime = 0; - CTransaction txNewConst(txNew); - signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, payload.size(), SIGHASH_ALL), txNew.vout[0].scriptPubKey, sigdata, consensusBranchId); - if ( signSuccess > 0 ) + static void *ctx; + size_t siglen = 74; secp256k1_ecdsa_signature signature; uint8_t privkey[32]; + if ( ctx == 0 ) + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + if ( ctx != 0 ) { - UpdateTransaction(txNew,0,sigdata); - ptr = (uint8_t *)&sigdata.scriptSig[0]; - siglen = sigdata.scriptSig.size(); - sig.resize(siglen); - for (i=0; i 0 ) + { + sig.resize(siglen); + if ( secp256k1_ecdsa_signature_serialize_der(ctx,&sig[0],&siglen,&signature) > 0 ) + return(0); + else return(-3); + } else return(-2); } else return(-1); } From 778320952eb04ac51597e8c55ac9d1476cadfe41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:28:20 -1100 Subject: [PATCH 3103/3904] Include --- src/cc/gamescc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 124dac876..4743bd0b7 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -5,6 +5,7 @@ extern CWallet* pwalletMain; #include "CCinclude.h" +#include "secp256k1.h" std::string MYCCLIBNAME = (char *)"gamescc"; From 404ef7d173634f2950b8f505570245067bbdb68b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:29:22 -1100 Subject: [PATCH 3104/3904] secp256k1_context* --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b828ea41f..e6ee0c692 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -167,7 +167,7 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t games_eventsign(std::vector &sig,std::vector payload,CPubKey pk) { - static void *ctx; + static secp256k1_context *ctx; size_t siglen = 74; secp256k1_ecdsa_signature signature; uint8_t privkey[32]; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); From 15b10ece314d88a0f526f2633159a8c1a82672c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:29:45 -1100 Subject: [PATCH 3105/3904] Syntax --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index e6ee0c692..e0006684f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -196,7 +196,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { komodo_sendmessage(4,8,"events",E_MARSHAL(ss << EVAL_GAMES << 'E' << mypk << sig << payload)); result.push_back(Pair("result","success")); - result.push_back(Pair("pubkey33",pubkey33_str(str,mypk))); + result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); result.push_back(Pair("sig",sig.HexStr())); } else From a590bcb1361a878b2e52e725b949043aa5327b0b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:31:26 -1100 Subject: [PATCH 3106/3904] -field --- src/cc/gamescc.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index e0006684f..559910642 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -197,7 +197,6 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) komodo_sendmessage(4,8,"events",E_MARSHAL(ss << EVAL_GAMES << 'E' << mypk << sig << payload)); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); - result.push_back(Pair("sig",sig.HexStr())); } else { From e920af85dcd018336f68dcb5316dd9abf3b2f35e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:32:21 -1100 Subject: [PATCH 3107/3904] Calc hash --- src/cc/gamescc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 559910642..61efb799b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -168,12 +168,13 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t games_eventsign(std::vector &sig,std::vector payload,CPubKey pk) { static secp256k1_context *ctx; - size_t siglen = 74; secp256k1_ecdsa_signature signature; uint8_t privkey[32]; + size_t siglen = 74; secp256k1_ecdsa_signature signature; uint8_t privkey[32]; uint256 hash; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); if ( ctx != 0 ) { Myprivkey(privkey); + vcalc_sha256(0,(uint8_t *)&hash,&payload[0],(int32_t)payload.size()); if ( secp256k1_ecdsa_sign(ctx,&signature,(uint8_t *)&hash,privkey,NULL,NULL) > 0 ) { sig.resize(siglen); From 7338d62f37b21dd4862047dab7c570659d5a1d59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:43:41 -1100 Subject: [PATCH 3108/3904] Test --- src/cc/gamescc.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 61efb799b..bc2123439 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -46,16 +46,6 @@ uint8_t games_opretdecode(CPubKey &pk,CScript scriptPubKey) return(0); } -uint8_t games_eventdecode(CPubKey &pk,std::vector &sig,std::vector &payload,std::vector message) -{ - uint8_t e,f; - if ( message.size() > 2 && E_UNMARSHAL(message,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) - { - return(f); - } - return(0); -} - UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) { CTransaction tx; @@ -219,6 +209,17 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +uint8_t games_eventdecode(CPubKey &pk,std::vector &sig,std::vector &payload,std::vector message) +{ + uint8_t e,f; + if ( message.size() > 2 && E_UNMARSHAL(message,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) + { + return(f); + } + fprintf(stderr,"e.%d f.%d pk.%d sig.%d payload.%d\n",e,f,(int32_t)pk.size(),(int32_t)sig.size(),(int32_t)payload.size()); + return(0); +} + void komodo_netevent(std::vector message) { int32_t i; CPubKey pk; std::vector sig,payload; char str[67]; @@ -230,9 +231,9 @@ void komodo_netevent(std::vector message) } else { - for (i=0; i Date: Mon, 25 Mar 2019 01:49:59 -1100 Subject: [PATCH 3109/3904] Test --- src/cc/gamescc.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index bc2123439..5016350f4 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -46,6 +46,25 @@ uint8_t games_opretdecode(CPubKey &pk,CScript scriptPubKey) return(0); } +CScript games_eventopret(CPubKey pk,std::vector sig,std::vector payload) +{ + CScript opret; uint8_t evalcode = EVAL_GAMES; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'E' << pk << sig << payload); + return(opret); +} + +uint8_t games_eventdecode(CPubKey &pk,std::vector &sig,std::vector &payload,std::vector message) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(message,vopret); + if ( message.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) + { + return(f); + } + fprintf(stderr,"e.%d f.%d pk.%d sig.%d payload.%d\n",e,f,(int32_t)pk.size(),(int32_t)sig.size(),(int32_t)payload.size()); + return(0); +} + UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) { CTransaction tx; @@ -177,7 +196,7 @@ int32_t games_eventsign(std::vector &sig,std::vector payload,C UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector sig,payload; int32_t n; CPubKey mypk; char str[67]; + UniValue result(UniValue::VOBJ); std::vector sig,payload; int32_t n; CPubKey mypk; char str[67]; CScript msg; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) @@ -185,7 +204,8 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); if ( games_eventsign(sig,payload,mypk) == 0 ) { - komodo_sendmessage(4,8,"events",E_MARSHAL(ss << EVAL_GAMES << 'E' << mypk << sig << payload)); + msg = games_eventopret(pk,sig,payload); + komodo_sendmessage(4,8,"events",&msg[0],(int32_t)msg.size()); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); } @@ -209,17 +229,6 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -uint8_t games_eventdecode(CPubKey &pk,std::vector &sig,std::vector &payload,std::vector message) -{ - uint8_t e,f; - if ( message.size() > 2 && E_UNMARSHAL(message,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) - { - return(f); - } - fprintf(stderr,"e.%d f.%d pk.%d sig.%d payload.%d\n",e,f,(int32_t)pk.size(),(int32_t)sig.size(),(int32_t)payload.size()); - return(0); -} - void komodo_netevent(std::vector message) { int32_t i; CPubKey pk; std::vector sig,payload; char str[67]; From fe20bf47b007165df74cf1d1db7b10ee08ab61f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:52:16 -1100 Subject: [PATCH 3110/3904] Test --- src/cc/gamescc.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 5016350f4..0d1bc4f0e 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -53,10 +53,9 @@ CScript games_eventopret(CPubKey pk,std::vector sig,std::vector &sig,std::vector &payload,std::vector message) +uint8_t games_eventdecode(CPubKey &pk,std::vector &sig,std::vector &payload,std::vector vopret) { - std::vector vopret; uint8_t e,f; - GetOpReturnData(message,vopret); + uint8_t e,f; if ( message.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) { return(f); @@ -196,7 +195,7 @@ int32_t games_eventsign(std::vector &sig,std::vector payload,C UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector sig,payload; int32_t n; CPubKey mypk; char str[67]; CScript msg; + UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) @@ -204,8 +203,8 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); if ( games_eventsign(sig,payload,mypk) == 0 ) { - msg = games_eventopret(pk,sig,payload); - komodo_sendmessage(4,8,"events",&msg[0],(int32_t)msg.size()); + GetOpReturnData(games_eventopret(pk,sig,payload),vopret); + komodo_sendmessage(4,8,"events",&vopret[0],(int32_t)vopret.size()); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); } From 29ac5d0a2d3d3edac115e78123fdae26133bfb01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:54:15 -1100 Subject: [PATCH 3111/3904] Syntax --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 0d1bc4f0e..9f8d110c1 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -56,7 +56,7 @@ CScript games_eventopret(CPubKey pk,std::vector sig,std::vector &sig,std::vector &payload,std::vector vopret) { uint8_t e,f; - if ( message.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) { return(f); } @@ -203,7 +203,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); if ( games_eventsign(sig,payload,mypk) == 0 ) { - GetOpReturnData(games_eventopret(pk,sig,payload),vopret); + GetOpReturnData(games_eventopret(mypk,sig,payload),vopret); komodo_sendmessage(4,8,"events",&vopret[0],(int32_t)vopret.size()); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); From d17ad823bc50a68427ee03ca861c422cd7b6eb11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:55:32 -1100 Subject: [PATCH 3112/3904] & --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 9f8d110c1..6efa745f2 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -204,7 +204,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( games_eventsign(sig,payload,mypk) == 0 ) { GetOpReturnData(games_eventopret(mypk,sig,payload),vopret); - komodo_sendmessage(4,8,"events",&vopret[0],(int32_t)vopret.size()); + komodo_sendmessage(4,8,"events",(uint8_t *)&vopret[0],(int32_t)vopret.size()); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); } From c29ad5f680445952cc849f23305d718785501cfd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 01:56:43 -1100 Subject: [PATCH 3113/3904] Std::Vector --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 6efa745f2..1cbd6674f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -204,7 +204,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( games_eventsign(sig,payload,mypk) == 0 ) { GetOpReturnData(games_eventopret(mypk,sig,payload),vopret); - komodo_sendmessage(4,8,"events",(uint8_t *)&vopret[0],(int32_t)vopret.size()); + komodo_sendmessage(4,8,"events",vopret); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); } From 52eef070eccf1c95b038f9c0538f4f6be6abb969 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:07:55 -1100 Subject: [PATCH 3114/3904] Add timestamp --- src/cc/gamescc.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 1cbd6674f..0b75c64ab 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -53,11 +53,18 @@ CScript games_eventopret(CPubKey pk,std::vector sig,std::vector &sig,std::vector &payload,std::vector vopret) +uint8_t games_eventdecode(uint32_t ×tamp,CPubKey &pk,std::vector &sig,std::vector &payload,std::vector vopret) { - uint8_t e,f; - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) + uint8_t e,f; int32_t len; + timestamp = 0; + if ( vopret.size() > 6 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) { + len = (int32_t)payload.size(); + timestamp = payload[--len]; + timestamp = (timestamp << 8) | payload[--len]; + timestamp = (timestamp << 8) | payload[--len]; + timestamp = (timestamp << 8) | payload[--len]; + payload.resize(len); return(f); } fprintf(stderr,"e.%d f.%d pk.%d sig.%d payload.%d\n",e,f,(int32_t)pk.size(),(int32_t)sig.size(),(int32_t)payload.size()); @@ -176,13 +183,20 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t games_eventsign(std::vector &sig,std::vector payload,CPubKey pk) { static secp256k1_context *ctx; - size_t siglen = 74; secp256k1_ecdsa_signature signature; uint8_t privkey[32]; uint256 hash; + size_t siglen = 74; secp256k1_ecdsa_signature signature; int32_t len; uint8_t privkey[32]; uint256 hash; uint32_t timestamp; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); if ( ctx != 0 ) { Myprivkey(privkey); - vcalc_sha256(0,(uint8_t *)&hash,&payload[0],(int32_t)payload.size()); + len = payload.size(); + payload.resize(len + 4); + timestamp = (uin32_t)time(NULL); + payload[len++] = timestamp, timestamp >> 8; + payload[len++] = timestamp, timestamp >> 8; + payload[len++] = timestamp, timestamp >> 8; + payload[len++] = timestamp, timestamp >> 8; + vcalc_sha256(0,(uint8_t *)&hash,&payload[0],len); if ( secp256k1_ecdsa_sign(ctx,&signature,(uint8_t *)&hash,privkey,NULL,NULL) > 0 ) { sig.resize(siglen); @@ -230,12 +244,13 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) void komodo_netevent(std::vector message) { - int32_t i; CPubKey pk; std::vector sig,payload; char str[67]; - if ( games_eventdecode(pk,sig,payload,message) == 'E' ) + int32_t i; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; + if ( games_eventdecode(timestamp,pk,sig,payload,message) == 'E' ) { + now = (uint32_t)time(NULL); for (i=0; i Date: Mon, 25 Mar 2019 02:08:47 -1100 Subject: [PATCH 3115/3904] Fix --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 0b75c64ab..3d3052025 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -191,11 +191,11 @@ int32_t games_eventsign(std::vector &sig,std::vector payload,C Myprivkey(privkey); len = payload.size(); payload.resize(len + 4); - timestamp = (uin32_t)time(NULL); - payload[len++] = timestamp, timestamp >> 8; + timestamp = (uint32_t)time(NULL); payload[len++] = timestamp, timestamp >> 8; payload[len++] = timestamp, timestamp >> 8; payload[len++] = timestamp, timestamp >> 8; + payload[len++] = timestamp; vcalc_sha256(0,(uint8_t *)&hash,&payload[0],len); if ( secp256k1_ecdsa_sign(ctx,&signature,(uint8_t *)&hash,privkey,NULL,NULL) > 0 ) { From 093b14a1584f70820a791e95d2abef8e239b2740 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:14:36 -1100 Subject: [PATCH 3116/3904] Test --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 3d3052025..2a1bb1e4f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -180,7 +180,7 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -int32_t games_eventsign(std::vector &sig,std::vector payload,CPubKey pk) +int32_t games_eventsign(std::vector &sig,std::vector &payload,CPubKey pk) { static secp256k1_context *ctx; size_t siglen = 74; secp256k1_ecdsa_signature signature; int32_t len; uint8_t privkey[32]; uint256 hash; uint32_t timestamp; From 951a8e10cdf6b1420e7cca9bab63e6deb330fa13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:17:39 -1100 Subject: [PATCH 3117/3904] Test --- src/cc/gamescc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2a1bb1e4f..363f583a5 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -60,10 +60,10 @@ uint8_t games_eventdecode(uint32_t ×tamp,CPubKey &pk,std::vector & if ( vopret.size() > 6 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) { len = (int32_t)payload.size(); - timestamp = payload[--len]; - timestamp = (timestamp << 8) | payload[--len]; - timestamp = (timestamp << 8) | payload[--len]; - timestamp = (timestamp << 8) | payload[--len]; + timestamp = (uint32_t)payload[--len] << 24; + timestamp |= (uint32_t)payload[--len] << 16; + timestamp |= (uin32_t)payload[--len] << 8; + timestamp |= (uint32_t)payload[--len]; payload.resize(len); return(f); } From d8274fe83240c032f10ac3bd0fce926290974df3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:18:18 -1100 Subject: [PATCH 3118/3904] test --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 363f583a5..1067bc82a 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -62,7 +62,7 @@ uint8_t games_eventdecode(uint32_t ×tamp,CPubKey &pk,std::vector & len = (int32_t)payload.size(); timestamp = (uint32_t)payload[--len] << 24; timestamp |= (uint32_t)payload[--len] << 16; - timestamp |= (uin32_t)payload[--len] << 8; + timestamp |= (uint32_t)payload[--len] << 8; timestamp |= (uint32_t)payload[--len]; payload.resize(len); return(f); From 6ac2a8090d6939cbd9b39248d29c2a3be8cc5508 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:24:45 -1100 Subject: [PATCH 3119/3904] fprintf(stderr,"timestamp %08x\n",timestamp); --- src/cc/gamescc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 1067bc82a..6ef563bed 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -64,6 +64,7 @@ uint8_t games_eventdecode(uint32_t ×tamp,CPubKey &pk,std::vector & timestamp |= (uint32_t)payload[--len] << 16; timestamp |= (uint32_t)payload[--len] << 8; timestamp |= (uint32_t)payload[--len]; + fprintf(stderr,"timestamp %08x\n",timestamp); payload.resize(len); return(f); } @@ -192,6 +193,7 @@ int32_t games_eventsign(std::vector &sig,std::vector &payload, len = payload.size(); payload.resize(len + 4); timestamp = (uint32_t)time(NULL); + fprintf(stderr,"timestamp %08x\n",timestamp); payload[len++] = timestamp, timestamp >> 8; payload[len++] = timestamp, timestamp >> 8; payload[len++] = timestamp, timestamp >> 8; From 5beffe66371d983c7526a41ec3b20e4c6457422d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:31:24 -1100 Subject: [PATCH 3120/3904] Test --- src/cc/gamescc.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 6ef563bed..7c4a1fc80 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -46,26 +46,20 @@ uint8_t games_opretdecode(CPubKey &pk,CScript scriptPubKey) return(0); } -CScript games_eventopret(CPubKey pk,std::vector sig,std::vector payload) +CScript games_eventopret(uint32_t timestamp,CPubKey pk,std::vector sig,std::vector payload) { CScript opret; uint8_t evalcode = EVAL_GAMES; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'E' << pk << sig << payload); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'E' << timestamp << pk << sig << payload); return(opret); } uint8_t games_eventdecode(uint32_t ×tamp,CPubKey &pk,std::vector &sig,std::vector &payload,std::vector vopret) { - uint8_t e,f; int32_t len; + uint8_t e,f; timestamp = 0; - if ( vopret.size() > 6 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) + if ( vopret.size() > 6 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> timestamp; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) { - len = (int32_t)payload.size(); - timestamp = (uint32_t)payload[--len] << 24; - timestamp |= (uint32_t)payload[--len] << 16; - timestamp |= (uint32_t)payload[--len] << 8; - timestamp |= (uint32_t)payload[--len]; fprintf(stderr,"timestamp %08x\n",timestamp); - payload.resize(len); return(f); } fprintf(stderr,"e.%d f.%d pk.%d sig.%d payload.%d\n",e,f,(int32_t)pk.size(),(int32_t)sig.size(),(int32_t)payload.size()); @@ -181,10 +175,10 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -int32_t games_eventsign(std::vector &sig,std::vector &payload,CPubKey pk) +int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vector payload,CPubKey pk) { static secp256k1_context *ctx; - size_t siglen = 74; secp256k1_ecdsa_signature signature; int32_t len; uint8_t privkey[32]; uint256 hash; uint32_t timestamp; + size_t siglen = 74; secp256k1_ecdsa_signature signature; int32_t len; uint8_t privkey[32]; uint256 hash; uint32_t t; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); if ( ctx != 0 ) @@ -192,12 +186,12 @@ int32_t games_eventsign(std::vector &sig,std::vector &payload, Myprivkey(privkey); len = payload.size(); payload.resize(len + 4); - timestamp = (uint32_t)time(NULL); + t = timestamp = (uint32_t)time(NULL); fprintf(stderr,"timestamp %08x\n",timestamp); - payload[len++] = timestamp, timestamp >> 8; - payload[len++] = timestamp, timestamp >> 8; - payload[len++] = timestamp, timestamp >> 8; - payload[len++] = timestamp; + payload[len++] = t, t >> 8; + payload[len++] = t, t >> 8; + payload[len++] = t, t >> 8; + payload[len++] = t; vcalc_sha256(0,(uint8_t *)&hash,&payload[0],len); if ( secp256k1_ecdsa_sign(ctx,&signature,(uint8_t *)&hash,privkey,NULL,NULL) > 0 ) { @@ -211,15 +205,15 @@ int32_t games_eventsign(std::vector &sig,std::vector &payload, UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; + UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; uint32_t timestamp; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) { mypk = pubkey2pk(Mypubkey()); - if ( games_eventsign(sig,payload,mypk) == 0 ) + if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) { - GetOpReturnData(games_eventopret(mypk,sig,payload),vopret); + GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); komodo_sendmessage(4,8,"events",vopret); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); From e18ea7d1d4b46205aa6b70e2f2dea7559e46811b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:46:50 -1100 Subject: [PATCH 3121/3904] Test --- src/cc/gamescc.cpp | 51 +++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 7c4a1fc80..b24deca7f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -59,10 +59,9 @@ uint8_t games_eventdecode(uint32_t ×tamp,CPubKey &pk,std::vector & timestamp = 0; if ( vopret.size() > 6 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> timestamp; ss >> pk; ss >> sig; ss >> payload) != 0 && e == EVAL_GAMES ) { - fprintf(stderr,"timestamp %08x\n",timestamp); return(f); } - fprintf(stderr,"e.%d f.%d pk.%d sig.%d payload.%d\n",e,f,(int32_t)pk.size(),(int32_t)sig.size(),(int32_t)payload.size()); + fprintf(stderr,"ERROR e.%d f.%d pk.%d sig.%d payload.%d\n",e,f,(int32_t)pk.size(),(int32_t)sig.size(),(int32_t)payload.size()); return(0); } @@ -178,7 +177,7 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vector payload,CPubKey pk) { static secp256k1_context *ctx; - size_t siglen = 74; secp256k1_ecdsa_signature signature; int32_t len; uint8_t privkey[32]; uint256 hash; uint32_t t; + size_t siglen = 74; secp256k1_pubkey pubkey; secp256k1_ecdsa_signature signature; int32_t len,verifyflag = 1; uint8_t privkey[32]; uint256 hash; uint32_t t; if ( ctx == 0 ) ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); if ( ctx != 0 ) @@ -186,26 +185,45 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto Myprivkey(privkey); len = payload.size(); payload.resize(len + 4); - t = timestamp = (uint32_t)time(NULL); - fprintf(stderr,"timestamp %08x\n",timestamp); + if ( timestamp == 0 ) + { + timestamp = (uint32_t)time(NULL); + verifyflag = 0; + } + t = timestamp; payload[len++] = t, t >> 8; payload[len++] = t, t >> 8; payload[len++] = t, t >> 8; payload[len++] = t; vcalc_sha256(0,(uint8_t *)&hash,&payload[0],len); - if ( secp256k1_ecdsa_sign(ctx,&signature,(uint8_t *)&hash,privkey,NULL,NULL) > 0 ) + if ( verifyflag == 0 ) { - sig.resize(siglen); - if ( secp256k1_ecdsa_signature_serialize_der(ctx,&sig[0],&siglen,&signature) > 0 ) - return(0); - else return(-3); - } else return(-2); + if ( secp256k1_ecdsa_sign(ctx,&signature,(uint8_t *)&hash,privkey,NULL,NULL) > 0 ) + { + sig.resize(siglen); + if ( secp256k1_ecdsa_signature_serialize_der(ctx,&sig[0],&siglen,&signature) > 0 ) + return(0); + else return(-3); + } else return(-2); + } + else + { + if ( secp256k1_ec_pubkey_parse(ctx,&pubkey,pk.begin(),33) > 0 ) + { + if ( secp256k1_ecdsa_signature_parse_der(ctx,&signature,&sig[0],sig.size()) > 0 ) + { + if ( secp256k1_ecdsa_verify(ctx,&signature,(uint8_t *)&hash,&pubkey) > 0 ) + return(0); + else return(-4); + } else return(-3); + } else return(-2); + } } else return(-1); } UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; uint32_t timestamp; + UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; uint32_t timestamp = 0; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) @@ -240,13 +258,18 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) void komodo_netevent(std::vector message) { - int32_t i; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; + int32_t i,retval; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; if ( games_eventdecode(timestamp,pk,sig,payload,message) == 'E' ) { now = (uint32_t)time(NULL); + lag = now - timestamp; + if ( lag < -3 || lag > 3 ) + fprintf(stderr,"LAG ERROR "); + if ( (retval= games_eventsign(timestamp,sig,payload,pk)) != 0 ) + fprintf(stderr,"SIG ERROR.%d ",retval); for (i=0; i Date: Mon, 25 Mar 2019 02:47:21 -1100 Subject: [PATCH 3122/3904] Test --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b24deca7f..198933a77 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -258,7 +258,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) void komodo_netevent(std::vector message) { - int32_t i,retval; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; + int32_t i,retval,lag; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; if ( games_eventdecode(timestamp,pk,sig,payload,message) == 'E' ) { now = (uint32_t)time(NULL); From 05aba9047a0593ec98896c87464acae72c1b0312 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:50:03 -1100 Subject: [PATCH 3123/3904] sig.resize --- src/cc/gamescc.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 198933a77..02ee3708f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -202,7 +202,11 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto { sig.resize(siglen); if ( secp256k1_ecdsa_signature_serialize_der(ctx,&sig[0],&siglen,&signature) > 0 ) + { + if ( siglen != sig.size() ) + sig.resize(siglen); return(0); + } else return(-3); } else return(-2); } From 933e911bcca7ea1a2c5978b11f1a72dbcd200eac Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 02:52:25 -1100 Subject: [PATCH 3124/3904] SECP256K1_CONTEXT_VERIFY --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 02ee3708f..1e8b99079 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -179,7 +179,7 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto static secp256k1_context *ctx; size_t siglen = 74; secp256k1_pubkey pubkey; secp256k1_ecdsa_signature signature; int32_t len,verifyflag = 1; uint8_t privkey[32]; uint256 hash; uint32_t t; if ( ctx == 0 ) - ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); if ( ctx != 0 ) { Myprivkey(privkey); From d4ebd390faa180e63cd8249ac42ba53afb863f7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 03:03:53 -1100 Subject: [PATCH 3125/3904] relay --- src/cc/gamescc.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 1e8b99079..ca780b8cf 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -225,6 +225,11 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto } else return(-1); } +int32_t games_payload(CPubKey pk,uint32_t timestamp,std::vector payload) +{ + return(0); +} + UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; uint32_t timestamp = 0; @@ -236,6 +241,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) { GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); + games_payload(mypk,timestamp,payload); komodo_sendmessage(4,8,"events",vopret); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); @@ -262,15 +268,26 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) void komodo_netevent(std::vector message) { - int32_t i,retval,lag; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; + int32_t i,retval,lag,lagerr=0; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; if ( games_eventdecode(timestamp,pk,sig,payload,message) == 'E' ) { now = (uint32_t)time(NULL); lag = now - timestamp; if ( lag < -3 || lag > 3 ) + { fprintf(stderr,"LAG ERROR "); + lagerr = lag; + } if ( (retval= games_eventsign(timestamp,sig,payload,pk)) != 0 ) fprintf(stderr,"SIG ERROR.%d ",retval); + else if ( lagerr == 0 ) + { + if ( games_payload(pk,timestamp,payload) == 0 ) // first time this is seen + { + if ( (rand() % 10) == 0 ) + komodo_sendmessage(2,2,"events",message); + } + } for (i=0; i Date: Mon, 25 Mar 2019 03:04:52 -1100 Subject: [PATCH 3126/3904] +print --- src/cc/gamescc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ca780b8cf..fe2cfdcae 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -285,7 +285,10 @@ void komodo_netevent(std::vector message) if ( games_payload(pk,timestamp,payload) == 0 ) // first time this is seen { if ( (rand() % 10) == 0 ) + { + fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); komodo_sendmessage(2,2,"events",message); + } } } for (i=0; i Date: Mon, 25 Mar 2019 03:24:01 -1100 Subject: [PATCH 3127/3904] Add gametxid and eventid --- src/cc/gamescc.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index fe2cfdcae..f1bb3bf81 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -27,6 +27,8 @@ Every time period, all players would set their rng value to the lastrng value. The only thing to be careful of is it not exceed the maxrng calls to rngnext in a single time period. otherwise the same set of rng numbers will be repeated. */ +uint256 Gametxid; +uint32_t numevents; CScript games_opret(uint8_t funcid,CPubKey pk) { @@ -232,11 +234,26 @@ int32_t games_payload(CPubKey pk,uint32_t timestamp,std::vector payload UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; uint32_t timestamp = 0; + static uint256 lastgametxid; + UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t len,i,n; uint32_t x; CPubKey mypk; char str[67]; uint32_t timestamp = 0; if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) { + if ( Gametxid != lastgametxid ) + { + lastgametxid = Gametxid; + numevents = 0; + } + len = payload.size(); + payload.resize(len + 4 + 32); + for (i=0; i<32; i++) + payload[len++] = ((uint8_t *)&Gametxid)[i]; + x = numevents++; + payload[len++] = x, x >> 8; + payload[len++] = x, x >> 8; + payload[len++] = x, x >> 8; + payload[len++] = x; mypk = pubkey2pk(Mypubkey()); if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) { From 2136c632de3d4589fa2234c2422adb4991625b48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 03:28:04 -1100 Subject: [PATCH 3128/3904] >>= --- src/cc/gamescc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index f1bb3bf81..a5573753b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -193,9 +193,9 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto verifyflag = 0; } t = timestamp; - payload[len++] = t, t >> 8; - payload[len++] = t, t >> 8; - payload[len++] = t, t >> 8; + payload[len++] = t, t >>= 8; + payload[len++] = t, t >>= 8; + payload[len++] = t, t >>= 8; payload[len++] = t; vcalc_sha256(0,(uint8_t *)&hash,&payload[0],len); if ( verifyflag == 0 ) @@ -250,9 +250,9 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i<32; i++) payload[len++] = ((uint8_t *)&Gametxid)[i]; x = numevents++; - payload[len++] = x, x >> 8; - payload[len++] = x, x >> 8; - payload[len++] = x, x >> 8; + payload[len++] = x, x >>= 8; + payload[len++] = x, x >>= 8; + payload[len++] = x, x >>= 8; payload[len++] = x; mypk = pubkey2pk(Mypubkey()); if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) From 0b46d5e610efd9cc52d9e1f9640ec8380f902f4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 03:36:56 -1100 Subject: [PATCH 3129/3904] Extract gametxid and eventide --- src/cc/gamescc.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index a5573753b..b77c2aef4 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -229,7 +229,21 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto int32_t games_payload(CPubKey pk,uint32_t timestamp,std::vector payload) { - return(0); + uint8_t gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; + if ( (len= payload.size()) > 36 ) + { + len -= 36; + for (i=0; i<32; i++) + ((uint8_t *)&gametxid)[i] = payload[len+i]; + eventid = (uint32_t)payload[len+32]; + eventid |= (uint32_t)payload[len+33] << 8; + eventid |= (uint32_t)payload[len+34] << 16; + eventid |= (uint32_t)payload[len+35] << 24; + for (i=0; i Date: Mon, 25 Mar 2019 03:38:34 -1100 Subject: [PATCH 3130/3904] Uint256 --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b77c2aef4..ae3f0cd6f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -229,7 +229,7 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto int32_t games_payload(CPubKey pk,uint32_t timestamp,std::vector payload) { - uint8_t gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; + uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; if ( (len= payload.size()) > 36 ) { len -= 36; From c833422a79c2bd63c1edd990ea343b1c674fc962 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 03:48:00 -1100 Subject: [PATCH 3131/3904] Gametxid and eventid as params --- src/cc/gamescc.cpp | 27 ++++++++++++++++++++------- src/cc/gamescc.h | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ae3f0cd6f..95caa0f9e 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -248,22 +248,32 @@ int32_t games_payload(CPubKey pk,uint32_t timestamp,std::vector payload UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - static uint256 lastgametxid; - UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t len,i,n; uint32_t x; CPubKey mypk; char str[67]; uint32_t timestamp = 0; - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + static uint256 lastgametxid; static uint32_t numevents; + UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t len,i,n; uint32_t x; CPubKey mypk; char str[67]; uint32_t eventid,timestamp = 0; uint256 gametxid; + if ( params != 0 && (n= cJSON_GetArraySize(params)) >= 1 && n <= 3 ) { if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) { - if ( Gametxid != lastgametxid ) + if ( n >= 2 ) + gametxid = juint256(jitem(params,1),0); + else gametxid = zeroid; + if ( gametxid != lastgametxid ) { - lastgametxid = Gametxid; - numevents = 0; + lastgametxid = gametxid; + numevents = 1; + eventid = 0; } + if ( n == 3 ) + { + eventid = juint(jitem(params,2),0); + if ( numevents <= eventid ) + numevents = eventid+1; + } else eventid = numevents++; len = payload.size(); payload.resize(len + 4 + 32); for (i=0; i<32; i++) payload[len++] = ((uint8_t *)&Gametxid)[i]; - x = numevents++; + x = eventid; payload[len++] = x, x >>= 8; payload[len++] = x, x >>= 8; payload[len++] = x, x >>= 8; @@ -274,6 +284,9 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); games_payload(mypk,timestamp,payload); komodo_sendmessage(4,8,"events",vopret); + result.push_back(Pair("gametxid",gametxid.GetHex())); + result.push_back(Pair("eventid",(int64_t)eventid)); + result.push_back(Pair("timestamp",(int64_t)timestamp)); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); } diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 4743bd0b7..c1fc63b48 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -23,7 +23,7 @@ std::string MYCCLIBNAME = (char *)"gamescc"; { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"create", (char *)"game,minplayers,maxplayers,buyin,numblocks", 5, 5, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"info", (char *)"txid", 1, 1, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"events", (char *)"hex", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"events", (char *)"eventshex [gametxid [eventid]]", 1, 3, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"register", (char *)"txid", 1, 1, ' ', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); From a1f1b47d79f07c078023fc4876f9d578abacf7b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 03:48:19 -1100 Subject: [PATCH 3132/3904] -globals --- src/cc/gamescc.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 95caa0f9e..9419986e1 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -27,9 +27,6 @@ Every time period, all players would set their rng value to the lastrng value. The only thing to be careful of is it not exceed the maxrng calls to rngnext in a single time period. otherwise the same set of rng numbers will be repeated. */ -uint256 Gametxid; -uint32_t numevents; - CScript games_opret(uint8_t funcid,CPubKey pk) { CScript opret; uint8_t evalcode = EVAL_GAMES; From 200d451d2c5c4e99f2fc317c2d637586f623bea1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 03:49:14 -1100 Subject: [PATCH 3133/3904] Syntax --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 9419986e1..c0c031d71 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -252,7 +252,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) { if ( n >= 2 ) - gametxid = juint256(jitem(params,1),0); + gametxid = juint256(jitem(params,1)); else gametxid = zeroid; if ( gametxid != lastgametxid ) { @@ -269,7 +269,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) len = payload.size(); payload.resize(len + 4 + 32); for (i=0; i<32; i++) - payload[len++] = ((uint8_t *)&Gametxid)[i]; + payload[len++] = ((uint8_t *)&gametxid)[i]; x = eventid; payload[len++] = x, x >>= 8; payload[len++] = x, x >>= 8; From a1f240e680c47e9bdca80921e3b316f1524be5d6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:30:44 -1100 Subject: [PATCH 3134/3904] Lots of gamescc --- src/cc/gamescc.cpp | 1337 +++++++++++++++++++++++++++++++++++++++++- src/cc/gamescc.h | 47 +- src/cc/rogue_rpc.cpp | 3 + 3 files changed, 1358 insertions(+), 29 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index c0c031d71..2330d130c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -25,26 +25,120 @@ you will notice maxrngs and lastrng, the lastrng is the rng value that will happen after maxrng iterations of calling rngnext with the current rng. This allows making time based multiplayer games where all the nodes can validate all the other nodes rng, even without realtime synchronization of all user input events. Every time period, all players would set their rng value to the lastrng value. The only thing to be careful of is it not exceed the maxrng calls to rngnext in a single time period. otherwise the same set of rng numbers will be repeated. + + events rpc is called after each user event and broadcasts to the network the tuple (gametxid, pk, eventid, payload). This allows the network to verify realtime user events from a specific pk/gametxid and also to make sure no user events were changed. In the event the events were changed, then the guilty pk will be blacklisted. If no realtime events, then the guilty pk would be penalized. + + ./c cclib events 17 \"[%226c%22,%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,0]\" + ./c cclib events 17 \"[%226d%22,%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,1]\" */ -CScript games_opret(uint8_t funcid,CPubKey pk) + +CScript games_newgameopret(int64_t buyin,int32_t maxplayers) { CScript opret; uint8_t evalcode = EVAL_GAMES; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << buyin << maxplayers); return(opret); } -uint8_t games_opretdecode(CPubKey &pk,CScript scriptPubKey) +uint8_t games_newgameopreturndecode(int64_t &buyin,int32_t &maxplayers,CScript scriptPubKey) { std::vector vopret; uint8_t e,f; GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_GAMES ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin; ss >> maxplayers) != 0 && e == EVAL_GAMES && f == 'G' ) { return(f); } return(0); } +CScript games_registeropret(uint256 gametxid,uint256 playertxid) +{ + CScript opret; uint8_t evalcode = EVAL_GAMES; + //fprintf(stderr,"opret.(%s %s).R\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'R' << gametxid << playertxid); + return(opret); +} + +CScript games_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std::vectorkeystrokes) +{ + CScript opret; uint8_t evalcode = EVAL_GAMES; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << batontxid << pk << keystrokes); + return(opret); +} + +uint8_t games_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey &pk,std::vector &keystrokes,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> batontxid; ss >> pk; ss >> keystrokes) != 0 && e == EVAL_GAMES && f == 'K' ) + { + return(f); + } + return(0); +} + +uint8_t games_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &playertxid,CScript scriptPubKey) +{ + std::string name, description; std::vector vorigPubkey; + std::vector> oprets; + std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; + uint8_t e, f,*script; std::vector voutPubkeys; + tokenid = zeroid; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,oprets)) == 'c' ) + { + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); + vopret = vopretNonfungible; + } + else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, oprets)) != 0 ) + { + GetOpretBlob(oprets, OPRETID_ROGUEGAMEDATA, vopretDummy); // blob from non-creation tx opret + vopret = vopretDummy; + } + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_GAMES && f == 'R' ) + { + return(f); + } + //fprintf(stderr,"e.%d f.%c game.%s playertxid.%s\n",e,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + return(0); +} + +CScript games_finishopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata,std::string pname) +{ + CScript opret; uint8_t evalcode = EVAL_GAMES; std::string symbol(ASSETCHAINS_SYMBOL); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << symbol << pname << regslot << pk << playerdata ); + return(opret); +} + +uint8_t games_finishopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol, std::string &pname,CScript scriptPubKey) +{ + std::string name, description; std::vector vorigPubkey; + std::vector> oprets, opretsDummy; + std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; + uint8_t e, f,*script; std::vector voutPubkeys; + tokenid = zeroid; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description, oprets)) == 'c' ) + { + GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); + vopret = vopretNonfungible; + } + else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, opretsDummy)) != 0 ) + { + //fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); + GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx + vopret = vopretNonfungible; + } + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> symbol; ss >> pname; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_GAMES && (f == 'H' || f == 'Q') ) + { + return(f); + } + fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); + return(0); +} + CScript games_eventopret(uint32_t timestamp,CPubKey pk,std::vector sig,std::vector payload) { CScript opret; uint8_t evalcode = EVAL_GAMES; @@ -155,24 +249,6 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vector payload,CPubKey pk) { static secp256k1_context *ctx; @@ -224,7 +300,7 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto } else return(-1); } -int32_t games_payload(CPubKey pk,uint32_t timestamp,std::vector payload) +int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) { uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; if ( (len= payload.size()) > 36 ) @@ -279,7 +355,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) { GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); - games_payload(mypk,timestamp,payload); + games_payloadrecv(mypk,timestamp,payload); komodo_sendmessage(4,8,"events",vopret); result.push_back(Pair("gametxid",gametxid.GetHex())); result.push_back(Pair("eventid",(int64_t)eventid)); @@ -323,7 +399,7 @@ void komodo_netevent(std::vector message) fprintf(stderr,"SIG ERROR.%d ",retval); else if ( lagerr == 0 ) { - if ( games_payload(pk,timestamp,payload) == 0 ) // first time this is seen + if ( games_payloadrecv(pk,timestamp,payload) == 0 ) // first time this is seen { if ( (rand() % 10) == 0 ) { @@ -344,6 +420,1217 @@ void komodo_netevent(std::vector message) } } +void games_univalue(UniValue &result,const char *method,int64_t maxplayers,int64_t buyin) +{ + if ( method != 0 ) + { + result.push_back(Pair("name","games")); + result.push_back(Pair("method",method)); + } + if ( maxplayers > 0 ) + result.push_back(Pair("maxplayers",maxplayers)); + if ( buyin >= 0 ) + { + result.push_back(Pair("buyin",ValueFromAmount(buyin))); + if ( buyin == 0 ) + result.push_back(Pair("type","newbie")); + else result.push_back(Pair("type","buyin")); + } +} + +int32_t games_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0) +{ + uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey gamespk; uint64_t txfee = 10000; + buyin = maxplayers = 0; + if ( (txid == zeroid || myGetTransaction(txid,tx,hashBlock) != 0) && (numvouts= tx.vout.size()) > 1 ) + { + if ( txid != zeroid ) + gameheight = komodo_blockheight(hashBlock); + else + { + txid = tx.GetHash(); + //fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); + } + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1,0) == txfee) ) + { + if ( games_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) + { + if ( maxplayers < 1 || maxplayers > GAMES_MAXPLAYERS || buyin < 0 ) + return(-6); + if ( numvouts > 2*maxplayers+1 ) + { + for (i=0; i= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + break; + } + txid = spenttxid; + vout = 0; + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + if ( spentvini != 0 ) + break; + if ( n++ > GAMES_MAXITERATIONS ) + break; + } + if ( txid != zeroid ) + { + if ( myGetTransaction(txid,tx,hashBlock) != 0 ) + { + if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + if ( pindex->GetHeight() <= gameht+GAMES_MAXKEYSTROKESGAP ) + alive++; + } + } + } + } + } + else if ( registration_open != 0 ) + openslots++; + } + //fprintf(stderr,"numalive.%d openslots.%d\n",alive,openslots); + return(alive); +} + +void disp_gamesplayerdata(std::vector playerdata) +{ + struct games_player P; int32_t i; char packitemstr[512]; + if ( playerdata.size() > 0 ) + { + for (i=0; i>16,P.level,P.experience,P.dungeonlevel); + for (i=0; i playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) +{ + int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct games_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + datastr = (char *)malloc(playerdata.size()*2+1); + for (i=0; i= 0 ) + txid = spenttxid; + else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + break; + } + txid = spenttxid; + vout = 0; + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + for (i=0; i GAMES_MAXITERATIONS ) + break; + } + obj.push_back(Pair("gametxid",gametxid.GetHex())); + if ( txid != playertxid ) + obj.push_back(Pair("batontxid",txid.GetHex())); + obj.push_back(Pair("playertxid",playertxid.GetHex())); + if ( tokenid != zeroid ) + obj.push_back(Pair("tokenid",tokenid.GetHex())); + else obj.push_back(Pair("tokenid",playertxid.GetHex())); + if ( datastr != 0 ) + { + obj.push_back(Pair("data",datastr)); + free(datastr); + } + obj.push_back(Pair("pack",a)); + obj.push_back(Pair("packsize",(int64_t)P.packsize)); + obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); + obj.push_back(Pair("strength",(int64_t)(P.strength&0xffff))); + obj.push_back(Pair("maxstrength",(int64_t)(P.strength>>16))); + obj.push_back(Pair("level",(int64_t)P.level)); + obj.push_back(Pair("experience",(int64_t)P.experience)); + obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); + obj.push_back(Pair("chain",symbol)); + obj.push_back(Pair("pname",pname)); + return(obj); +} + +int32_t games_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and rogue_playerdataspend makes sure it can only be used once +{ + uint256 spenttxid,txid = firsttxid; int32_t spentvini,n,vout = firstvout; + registertxid = zeroid; + if ( vout < 0 ) + return(-1); + n = 0; + while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) + { + txid = spenttxid; + vout = spentvini; + if ( registertxid == zeroid ) + registertxid = txid; + if ( ++n >= GAMES_MAXITERATIONS ) + { + fprintf(stderr,"games_iterateplayer n.%d, seems something is wrong\n",n); + return(-2); + } + } + if ( txid == lasttxid ) + return(0); + else + { + fprintf(stderr,"firsttxid.%s/v%d -> %s != last.%s\n",firsttxid.ToString().c_str(),firstvout,txid.ToString().c_str(),lasttxid.ToString().c_str()); + return(-1); + } +} + +int32_t games_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,std::string &symbol,std::string &pname,uint256 playertxid) +{ + uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 && (numvouts= playertx.vout.size()) > 0 ) + { + if ( (f= games_finishopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) + { + origplayergame = gametxid; + if ( tokenid != zeroid ) + { + playertxid = tokenid; + if ( myGetTransaction(playertxid,playertx,hashBlock) == 0 || (numvouts= playertx.vout.size()) <= 0 ) + { + fprintf(stderr,"couldnt get tokenid.%s\n",playertxid.GetHex().c_str()); + return(-2); + } + } + if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) + { + //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),games_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && games_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) + { + // if registertxid has vin from pk, it can be used + return(0); + } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); + } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); + } //else fprintf(stderr,"invalid player funcid.%c\n",f); + } else fprintf(stderr,"couldnt get playertxid.%s\n",playertxid.GetHex().c_str()); + return(-1); +} + +int32_t games_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx,char *mygamesaddr) +{ + int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; char destaddr[64]; + for (i=0; i= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + { + Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); + if ( strcmp(mygamesaddr,destaddr) == 0 ) + return(1); + //else fprintf(stderr,"myaddr.%s vs %s\n",myrogueaddr,destaddr); + } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"vout %d is unspent\n",vout); + } + return(0); +} + +uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr) +{ + CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; + if ( myGetTransaction(gametxid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) + { + ht = pindex->GetHeight(); + delay = GAMES_REGISTRATION * (maxplayers > 1); + obj.push_back(Pair("height",ht)); + obj.push_back(Pair("start",ht+delay)); + if ( komodo_nextheight() > ht+delay ) + { + if ( (pindex= komodo_chainactive(ht+delay)) != 0 ) + { + hashBlock = pindex->GetBlockHash(); + obj.push_back(Pair("starthash",hashBlock.ToString())); + memcpy(&seed,&hashBlock,sizeof(seed)); + seed &= (1LL << 62) - 1; + obj.push_back(Pair("seed",(int64_t)seed)); + if ( games_iamregistered(maxplayers,gametxid,tx,mygamesaddr) > 0 ) + sprintf(cmd,"cc/%s %llu %s",GAMENAME,(long long)seed,gametxid.ToString().c_str()); + else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_GAMES,gametxid.ToString().c_str()); + obj.push_back(Pair("run",cmd)); + } + } + obj.push_back(Pair("alive",games_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); + obj.push_back(Pair("openslots",openslots)); + obj.push_back(Pair("numplayers",numplayers)); + } + obj.push_back(Pair("maxplayers",maxplayers)); + obj.push_back(Pair("buyin",ValueFromAmount(buyin))); + return(seed); +} + +UniValue games_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; std::string symbol,pname; + result.push_back(Pair("result","success")); + games_univalue(result,"playerinfo",-1,-1); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + playertxid = juint256(jitem(params,0)); + if ( games_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) + return(cclib_error(result,"invalid playerdata")); + result.push_back(Pair("player",games_playerobj(playerdata,playertxid,tokenid,symbol,pname,origplayergame))); + } else return(cclib_error(result,"no playertxid")); + return(result); + } else return(cclib_error(result,"couldnt reparse params")); +} + +int32_t games_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_t vout,uint256 origplayergame) +{ + int64_t txfee = 10000; CTransaction tx; uint256 hashBlock; + if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation + { + mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); + return(0); + } + else + { + vout = 0; + if ( myGetTransaction(playertxid,tx,hashBlock) != 0 && tx.vout[vout].nValue == 1 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) + { + if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation + { + mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); + return(0); + } + } + return(-1); + } +} + +int64_t games_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTransaction gametx,int32_t maxplayers) +{ + int32_t vout,j,r; int64_t nValue; + if ( gametx.vout.size() > maxplayers+1 ) + { + r = rand() % maxplayers; + for (j=0; j &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) +{ + int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + batonvalue = numkeys = numplayers = batonht = 0; + playertxid = batontxid = zeroid; + if ( keystrokesp != 0 ) + *keystrokesp = 0; + for (i=0; i= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + { + numplayers++; + Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); + if ( strcmp(destaddr,ccaddr) == 0 ) + { + matches++; + regslot = i; + matchtx = spenttx; + } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); + } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"%d+1 unspent\n",i); + } + if ( matches == 1 ) + { + numvouts = matchtx.vout.size(); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + if ( games_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) + { + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + if ( tokenid != zeroid ) + active = tokenid; + else active = playertxid; + if ( active == zeroid || games_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) + { + txid = matchtx.GetHash(); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + n = 0; + while ( CCgettxout(txid,0,1,0) < 0 ) + { + spenttxid = zeroid; + spentvini = -1; + if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) + txid = spenttxid; + else + { + if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) + { + fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); + return(-2); + } + } + txid = spenttxid; + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + if ( spentvini != 0 ) // game is over? + { + return(0); + } + if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) + { + uint256 g,b; CPubKey p; std::vector k; + if ( games_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) + { + keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); + for (i=0; i= GAMES_MAXITERATIONS ) + { + fprintf(stderr,"games_findbaton n.%d, seems something is wrong\n",n); + return(-5); + } + } + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + batontxid = txid; + batonvout = 0; // not vini + // how to detect timeout, bailedout, highlander + hashBlock = zeroid; + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 0 ) + { + if ( hashBlock == zeroid ) + batonht = komodo_nextheight(); + else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) + return(-4); + else batonht = pindex->GetHeight(); + batonvalue = batontx.vout[0].nValue; + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + return(0); + } else fprintf(stderr,"couldnt find baton\n"); + } else fprintf(stderr,"error with playerdata\n"); + } else fprintf(stderr,"findbaton opret error\n"); + } + return(-1); +} + +UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey gamespk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1; + if ( txfee == 0 ) + txfee = 10000; + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + maxplayers = juint(jitem(params,0),0); + if ( n > 1 ) + buyin = jdouble(jitem(params,1),0) * COIN + 0.0000000049; + } + } + if ( maxplayers < 1 || maxplayers > GAMES_MAXPLAYERS ) + return(cclib_error(result,"illegal maxplayers")); + mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + games_univalue(result,"newgame",maxplayers,buyin); + required = (3*txfee + maxplayers*(GAMES_REGISTRATIONSIZE+txfee)); + if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,required,16,cp->unspendableCCaddr)) >= required ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gamespk)); + for (i=0; ievalcode,GAMES_REGISTRATIONSIZE,gamespk,gamespk)); + for (i=0; ievalcode,txfee,gamespk,gamespk)); + if ( (change= inputsum - required) >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,gamespk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,games_newgameopret(buyin,maxplayers)); + return(games_rawtxresult(result,rawtx,1)); + } + else return(cclib_error(result,"illegal maxplayers")); + return(result); +} + +UniValue games_list(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey gamespk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; + std::vector > addressIndex; + gamespk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,coinaddr,gamespk,mypk); + SetCCtxids(addressIndex,coinaddr); + games_univalue(result,"games",-1,-1); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( vout == 0 ) + { + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( games_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) + { + if ( CCgettxout(txid,vout,1,0) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); + } + } + } + } + } + result.push_back(Pair("pastgames",b)); + result.push_back(Pair("games",a)); + result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); + return(result); +} + +UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t openslots,maxplayers,numplayers,gameheight,nextheight,vout,numvouts; CPubKey gamespk; char coinaddr[64]; + std::vector > unspentOutputs; + gamespk = GetUnspendable(cp,0); + GetCCaddress(cp,coinaddr,gamespk); + SetCCunspents(unspentOutputs,coinaddr); + nextheight = komodo_nextheight(); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers + continue; + if ( games_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,1) == 0 && nextheight <= gameheight+GAMES_MAXKEYSTROKESGAP ) + { + games_playersalive(openslots,numplayers,txid,maxplayers,gameheight,tx); + if ( openslots > 0 ) + a.push_back(txid.GetHex()); + } + } + result.push_back(Pair("result","success")); + games_univalue(result,"pending",-1,-1); + result.push_back(Pair("pending",a)); + result.push_back(Pair("numpending",(int64_t)a.size())); + return(result); +} + +UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myaddr[64],str[64]; CPubKey mypk,gamespk; + result.push_back(Pair("name","games")); + result.push_back(Pair("method","info")); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + txid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",txid.GetHex())); + if ( games_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,0) == 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("gameheight",(int64_t)gameheight)); + mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,myaddr,gamespk,mypk); + seed = games_gamefields(result,maxplayers,buyin,txid,myaddr); + result.push_back(Pair("seed",(int64_t)seed)); + for (i=0; i GAMES_REGISTRATIONSIZE 1of2 registration baton from creategame + // vin1 -> optional nonfungible character vout @ + // vin2 -> original creation TCBOO playerdata used + // vin3+ -> buyin + // vout0 -> keystrokes/completion baton + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=1; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,gamespk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx,symbol,pname; bits256 t; + + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY)); + gamespk = GetUnspendable(cp,0); + games_univalue(result,"register",-1,-1); + playertxid = tokenid = zeroid; + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + if ( (err= games_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1)) == 0 ) + { + if ( n > 1 ) + { + playertxid = juint256(jitem(params,1)); + if ( games_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) + return(cclib_error(result,"couldnt extract valid playerdata")); + if ( tokenid != zeroid ) // if it is tokentransfer this will be 0 + vout = 1; + } + if ( komodo_nextheight() > gameheight + GAMES_MAXKEYSTROKESGAP ) + return(cclib_error(result,"didnt register in time, GAMES_MAXKEYSTROKESGAP")); + games_univalue(result,0,maxplayers,buyin); + GetCCaddress1of2(cp,coinaddr,gamespk,mypk); + if ( games_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) + return(cclib_error(result,"already registered")); + if ( (inputsum= games_registrationbaton(mtx,gametxid,tx,maxplayers)) != GAMES_REGISTRATIONSIZE ) + return(cclib_error(result,"couldnt find available registration baton")); + else if ( playertxid != zeroid && games_playerdataspend(mtx,playertxid,vout,origplayergame) < 0 ) + return(cclib_error(result,"couldnt find playerdata to spend")); + else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) + return(cclib_error(result,"couldnt find enough normal funds for buyin")); + if ( tokenid != zeroid ) + { + mtx.vin.push_back(CTxIn(tokenid,0)); // spending cc marker as token is burned + char unspendableTokenAddr[64]; uint8_t tokenpriv[32]; struct CCcontract_info *cpTokens, tokensC; + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + CPubKey unspPk = GetUnspendable(cpTokens, tokenpriv); + GetCCaddress(cpTokens, unspendableTokenAddr, unspPk); + CCaddr2set(cp, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); + } + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,gamespk,mypk)); + GetCCaddress1of2(cp,destaddr,gamespk,gamespk); + CCaddr1of2set(cp,gamespk,gamespk,cp->CCpriv,destaddr); + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); + + uint8_t e, funcid; uint256 tid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; + CScript opretRegister = games_registeropret(gametxid, playertxid); + if ( playertxid != zeroid ) + { + voutPubkeysEmpty.push_back(burnpk); + if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 ) + { + std::vector> oprets; + if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, oprets)) != 0) + { // if token in the opret + didtx = 1; + if ( funcid == 'c' ) + tid = tokenid == zeroid ? playertxid : tokenid; + vscript_t vopretRegister; + GetOpReturnData(opretRegister, vopretRegister); + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, + EncodeTokenOpRet(tid, voutPubkeysEmpty /*=never spent*/, std::make_pair(OPRETID_ROGUEGAMEDATA, vopretRegister))); + } + } + } + if ( didtx == 0 ) + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister); + + return(games_rawtxresult(result,rawtx,1)); + } else return(cclib_error(result,"invalid gametxid")); + } else return(cclib_error(result,"no gametxid")); + } else return(cclib_error(result,"couldnt reparse params")); +} + +UniValue games_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + // vin0 -> baton from registration or previous keystrokes + // vout0 -> new baton + // opret -> user input chars + // being killed should auto broadcast (possible to be suppressed?) + // respawn to be prevented by including timestamps + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); + UniValue result(UniValue::VOBJ); CPubKey gamespk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; + // if ( txfee == 0 ) + txfee = 1000; // smaller than normal on purpose + games_univalue(result,"keystrokes",-1,-1); + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + result.push_back(Pair("keystrokes",keystrokestr)); + keystrokes = ParseHex(keystrokestr); + mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,destaddr,gamespk,mypk); + if ( games_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1) == 0 ) + { + if ( games_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) + { + result.push_back(Pair("batontxid",batontxid.GetHex())); + result.push_back(Pair("playertxid",playertxid.GetHex())); + if ( maxplayers == 1 || nextheight <= batonht+GAMES_MAXKEYSTROKESGAP ) + { + mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); //this validates user if pk + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,gamespk,mypk)); + Myprivkey(mypriv); + CCaddr1of2set(cp,gamespk,mypk,mypriv,destaddr); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,games_keystrokesopret(gametxid,batontxid,mypk,keystrokes)); + //fprintf(stderr,"KEYSTROKES.(%s)\n",rawtx.c_str()); + return(games_rawtxresult(result,rawtx,1)); + } else return(cclib_error(result,"keystrokes tx was too late")); + } else return(cclib_error(result,"couldnt find batontxid")); + } else return(cclib_error(result,"invalid gametxid")); + } else return(cclib_error(result,"couldnt reparse params")); +} + +char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) +{ + CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; + gamespk = GetUnspendable(cp,0); + *numkeysp = 0; + seed = 0; + num = numkeys = 0; + playertxid = zeroid; + str[0] = 0; + if ( (err= games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) + { + if ( (retval= games_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gamesaddr,numplayers,symbol,pname)) == 0 ) + { + UniValue obj; + seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i no playerdata\n"); + newdata.resize(0); + *numkeysp = numkeys; + return(keystrokes); + /* P.gold = (P.gold * 8) / 10; + if ( keystrokes != 0 ) + { + free(keystrokes); + keystrokes = 0; + *numkeysp = 0; + return(keystrokes); + }*/ + } + else + { + sprintf(str,"$$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); + //fprintf(stderr,"%s\n",str); + *numkeysp = numkeys; + return(keystrokes); + } + } else num = 0; + } + else + { + fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); + if ( keystrokes != 0 ) + free(keystrokes), keystrokes = 0; + } + } else fprintf(stderr,"extractgame: invalid game\n"); + //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); + return(0); +} + +UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); CPubKey pk,gamespk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],gamesaddr[64],*pubstr,*hexstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; + pk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + result.push_back(Pair("name","games")); + result.push_back(Pair("method","extract")); + gamesaddr[0] = 0; + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + if ( n == 2 ) + { + if ( (pubstr= jstr(jitem(params,1),0)) != 0 ) + { + if (strlen(pubstr) == 66 ) + { + decode_hex(pub33,33,pubstr); + pk = buf2pk(pub33); + } + else if ( strlen(pubstr) < 36 ) + strcpy(gamesaddr,pubstr); + } + //fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); + } + if ( gamesaddr[0] == 0 ) + GetCCaddress1of2(cp,gamesaddr,gamespk,pk); + result.push_back(Pair("gamesaddr",gamesaddr)); + str[0] = 0; + if ( (keystrokes= games_extractgame(1,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) + { + result.push_back(Pair("status","success")); + flag = 1; + hexstr = (char *)malloc(numkeys*2 + 1); + for (i=0; iamulet != 0 ) + mult *= 5; + dungeonlevel = P->dungeonlevel; + if ( P->amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; + cashout = (uint64_t)P->gold * P->gold * mult * dungeonlevel; + return(cashout); +} + +int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) +{ + static uint32_t good,bad; static uint256 prevgame; + char str[512],*keystrokes,gamesaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; + *cashoutp = 0; + gamespk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,gamesaddr,gamespk,pk); + if ( (keystrokes= games_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) + { + free(keystrokes); + sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); + remove(fname); + + for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); + } + *cashoutp = 0; + return(0); + } + } + if ( gametxid != prevgame ) + { + prevgame = gametxid; + bad++; + disp_gamesplayerdata(newdata); + disp_gamesplayerdata(playerdata); + fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,gamesaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + } + } + sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); + remove(fname); + //fprintf(stderr,"no keys games_extractgame %s\n",gametxid.GetHex().c_str()); + return(-1); +} + +UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + //vin0 -> highlander vout from creategame TCBOO + //vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 60 blocks since last keystrokes, it is forfeit + //vins2+ -> rest of unspent registration utxo so all newgame vouts are spent + //vout0 -> nonfungible character with pack @ + //vout1 -> 1% ingame gold and all the buyins + + // detect if last to bailout + // vin0 -> kestrokes baton of completed game with Q + // vout0 -> playerdata marker + // vout0 -> 1% ingame gold + // get any playerdata, get all keystrokes, replay game and compare final state + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); char *method = "bailout"; + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; + struct CCcontract_info *cpTokens, tokensC; + + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,mygamesaddr,gamespk,mypk); + result.push_back(Pair("name","games")); + result.push_back(Pair("method",method)); + result.push_back(Pair("mygamesaddr",mygamesaddr)); + if ( strcmp(method,"bailout") == 0 ) + { + funcid = 'Q'; + //mult = 10; //100000; + } + else + { + funcid = 'H'; + //mult = 20; //200000; + } + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + if ( (err= games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,1)) == 0 ) + { + if ( games_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,mygamesaddr,numplayers,symbol,pname) == 0 ) + { + UniValue obj; struct games_player P; + seed = games_gamefields(obj,maxplayers,buyin,gametxid,mygamesaddr); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i 0 ) + { + newdata.resize(num); + for (i=0; i no playerdata\n"); + newdata.resize(0); + //P.gold = (P.gold * 8) / 10; + } + else + { + cpTokens = CCinit(&tokensC, EVAL_TOKENS); + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); + cashout = games_cashout(&P); + fprintf(stderr,"\nextracted $$$gold.%d -> %.8f GAME hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); + if ( funcid == 'H' && maxplayers > 1 ) + { + if ( P.amulet == 0 ) + { + if ( numplayers != maxplayers ) + return(cclib_error(result,"numplayers != maxplayers")); + else if ( games_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) + return(cclib_error(result,"highlander must be a winner or last one standing")); + } + cashout += numplayers * buyin; + } + if ( cashout > 0 ) + { + if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,cashout,60,cp->unspendableCCaddr)) > cashout ) + CCchange = (inputsum - cashout); + else fprintf(stderr,"couldnt find enough utxos\n"); + } + mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + } + } + if ( CCchange + (batonvalue-3*txfee) >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),gamespk)); + Myprivkey(mypriv); + CCaddr1of2set(cp,gamespk,mypk,mypriv,mygamesaddr); + CScript opret; + if ( pname.size() == 0 ) + pname = Games_pname; + if ( newdata.size() == 0 ) + { + opret = games_finishopret(funcid, gametxid, regslot, mypk, nodata,pname); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); + //fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx.c_str()); + } + else + { + opret = games_finishopret(funcid, gametxid, regslot, mypk, newdata,pname); + char seedstr[32]; + sprintf(seedstr,"%llu",(long long)seed); + std::vector vopretNonfungible; + GetOpReturnData(opret, vopretNonfungible); + rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string(seedstr), gametxid.GetHex(), vopretNonfungible)); + } + return(games_rawtxresult(result,rawtx,1)); + } + result.push_back(Pair("result","success")); + } else fprintf(stderr,"illegal game err.%d\n",err); + } else fprintf(stderr,"parameters only n.%d\n",n); + } + return(result); +} + +UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey gamespk,mypk,pk; std::string symbol,pname; char coinaddr[64]; + std::vector > unspentOutputs; + gamespk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetTokensCCaddress(cp,coinaddr,mypk); + SetCCunspents(unspentOutputs,coinaddr); + games_univalue(result,"players",-1,-1); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( it->second.satoshis != 1 || vout > 1 ) + continue; + if ( games_playerdata(cp,gametxid,tokenid,pk,playerdata,symbol,pname,txid) == 0 )//&& pk == mypk ) + { + a.push_back(txid.GetHex()); + //a.push_back(Pair("playerdata",games_playerobj(playerdata))); + } + } + result.push_back(Pair("playerdata",a)); + result.push_back(Pair("numplayerdata",(int64_t)a.size())); + return(result); +} + +UniValue games_list(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey gamespk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; + std::vector > addressIndex; + gamespk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,coinaddr,gamespk,mypk); + SetCCtxids(addressIndex,coinaddr); + games_univalue(result,"games",-1,-1); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( vout == 0 ) + { + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( games_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) + { + if ( CCgettxout(txid,vout,1,0) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); + } + } + } + } + } + result.push_back(Pair("pastgames",b)); + result.push_back(Pair("games",a)); + result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); + return(result); +} + +UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); int32_t n; char *namestr = 0; + games_univalue(result,"setname",-1,-1); + if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) + { + if ( n > 0 ) + { + if ( (namestr= jstri(params,0)) != 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("pname",namestr)); + Games_pname = namestr; + return(result); + } + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt get name")); + return(result); +} + bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true); diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index c1fc63b48..2d3f56a48 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -11,28 +11,50 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define EVAL_GAMES (EVAL_FAUCET2+1) #define GAMES_TXFEE 10000 +#define GAMES_MAXITERATIONS 777 +#define GAMES_MAXKEYSTROKESGAP 60 +#define GAMES_MAYPLAYERS 64 +#define GAMES_REGISTRATIONSIZE (100 * 10000) #define GAMES_RNGMULT 11109 #define GAMES_RNGOFFSET 13849 #define GAMES_MAXRNGS 10000 #define MYCCNAME "games" +#define GAMENAME "sudoku" #define RPC_FUNCS \ { (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"create", (char *)"game,minplayers,maxplayers,buyin,numblocks", 5, 5, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"info", (char *)"txid", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"players", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"list", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"pending", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"setname", (char *)"pname", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"create", (char *)"maxplayers,buyin", 2, 2, 'C', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"playerinfo", (char *)"playertxid", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"info", (char *)"gametxid", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"keystrokes", (char *)"txid,hexstr", 2, 2, 'K', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"finish", (char *)"gametxid", 1, 1, 'Q', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"events", (char *)"eventshex [gametxid [eventid]]", 1, 3, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"register", (char *)"txid", 1, 1, ' ', EVAL_GAMES }, + { (char *)MYCCNAME, (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_GAMES }, + bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_list(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ @@ -58,4 +80,21 @@ if ( cp->evalcode == EVAL_GAMES ) \ } \ } +#define MAXPACK 23 +struct games_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; + +struct games_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; + struct games_packitem roguepack[MAXPACK]; +}; + +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); +void games_packitemstr(char *packitemstr,struct games_packitem *item); + + #endif diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index caf37b566..6f507e51e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1594,7 +1594,10 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("mismatched playerdata"); } if ( funcid == 'H' ) + { cashout *= 2; + cashout += numplayers * buyin; + } sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { From ff5abe4b6c3e5569216becbb71851f3ff8c1d207 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:32:53 -1100 Subject: [PATCH 3135/3904] Gamespack --- src/cc/gamescc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 2d3f56a48..51432105c 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -13,7 +13,7 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define GAMES_TXFEE 10000 #define GAMES_MAXITERATIONS 777 #define GAMES_MAXKEYSTROKESGAP 60 -#define GAMES_MAYPLAYERS 64 +#define GAMES_MAXPLAYERS 64 #define GAMES_REGISTRATIONSIZE (100 * 10000) #define GAMES_RNGMULT 11109 @@ -90,7 +90,7 @@ struct games_packitem struct games_player { int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; - struct games_packitem roguepack[MAXPACK]; + struct games_packitem gamespack[MAXPACK]; }; int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); From aad5cac5cca142e9d5b734ff06b6333b08eeae6c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:33:42 -1100 Subject: [PATCH 3136/3904] Test --- src/cc/gamescc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 51432105c..e060016ff 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -15,6 +15,7 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define GAMES_MAXKEYSTROKESGAP 60 #define GAMES_MAXPLAYERS 64 #define GAMES_REGISTRATIONSIZE (100 * 10000) +#define GAMES_REGISTRATION 5 #define GAMES_RNGMULT 11109 #define GAMES_RNGOFFSET 13849 From 2a01bdd2d15807328e518243eb149de9b5681347 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:34:47 -1100 Subject: [PATCH 3137/3904] Games --- src/cc/gamescc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index e060016ff..8a6a3b656 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -22,6 +22,8 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define GAMES_MAXRNGS 10000 #define MYCCNAME "games" + +std::string Games_pname; #define GAMENAME "sudoku" #define RPC_FUNCS \ @@ -94,7 +96,7 @@ struct games_player struct games_packitem gamespack[MAXPACK]; }; -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); void games_packitemstr(char *packitemstr,struct games_packitem *item); From a9684309b85bd81e749751ee6e05c68941e0b902 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:39:05 -1100 Subject: [PATCH 3138/3904] Fixes --- src/cc/gamescc.cpp | 76 ++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2330d130c..3dd9244aa 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -700,13 +700,47 @@ int32_t games_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); if ( strcmp(mygamesaddr,destaddr) == 0 ) return(1); - //else fprintf(stderr,"myaddr.%s vs %s\n",myrogueaddr,destaddr); + //else fprintf(stderr,"myaddr.%s vs %s\n",mygamesaddr,destaddr); } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); } //else fprintf(stderr,"vout %d is unspent\n",vout); } return(0); } +void games_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *mygamesaddr) +{ + // identify if bailout or quit or timed out + uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; std::string symbol,pname; + destaddr[0] = 0; + if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); + } + obj.push_back(Pair("slot",(int64_t)vout-1)); + if ( (retval= games_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers,symbol,pname)) == 0 ) + { + if ( CCgettxout(gametxid,maxplayers+vout,1,0) == 10000 ) + { + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 ) + { + if ( games_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) + obj.push_back(Pair("status","registered")); + else obj.push_back(Pair("status","alive")); + } else obj.push_back(Pair("status","error")); + } else obj.push_back(Pair("status","finished")); + obj.push_back(Pair("baton",batontxid.ToString())); + obj.push_back(Pair("tokenid",tokenid.ToString())); + obj.push_back(Pair("batonaddr",destaddr)); + obj.push_back(Pair("ismine",strcmp(mygamesaddr,destaddr)==0)); + obj.push_back(Pair("batonvout",(int64_t)batonvout)); + obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); + obj.push_back(Pair("batonht",(int64_t)batonht)); + if ( playerdata.size() > 0 ) + obj.push_back(Pair("player",games_playerobj(playerdata,playertxid,tokenid,symbol,pname,gametxid))); + } else fprintf(stderr,"findbaton err.%d\n",retval); +} + uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr) { CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; @@ -939,42 +973,6 @@ UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue games_list(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey gamespk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; - std::vector > addressIndex; - gamespk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - GetCCaddress1of2(cp,coinaddr,gamespk,mypk); - SetCCtxids(addressIndex,coinaddr); - games_univalue(result,"games",-1,-1); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( vout == 0 ) - { - if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - if ( games_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) - { - if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) - { - if ( CCgettxout(txid,vout,1,0) < 0 ) - b.push_back(gametxid.GetHex()); - else a.push_back(gametxid.GetHex()); - } - } - } - } - } - result.push_back(Pair("pastgames",b)); - result.push_back(Pair("games",a)); - result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); - return(result); -} - UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 txid,hashBlock; CTransaction tx; int32_t openslots,maxplayers,numplayers,gameheight,nextheight,vout,numvouts; CPubKey gamespk; char coinaddr[64]; @@ -1029,7 +1027,7 @@ UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( CCgettxout(txid,i+1,1,0) < 0 ) { UniValue obj(UniValue::VOBJ); - games_playerinfo(cp,obj,txid,tx,i+1,maxplayers,myaddr); + games_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myaddr); a.push_back(obj); } else if ( 0 ) @@ -1423,7 +1421,7 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> playerdata marker // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); char *method = "bailout"; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); char *method = (char *)"bailout"; UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; From e6371013aaff8463649f2dbdee227dc81559587c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:41:47 -1100 Subject: [PATCH 3139/3904] Reorder --- src/cc/gamescc.cpp | 68 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 3dd9244aa..aca989fd3 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -707,40 +707,6 @@ int32_t games_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } -void games_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *mygamesaddr) -{ - // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; std::string symbol,pname; - destaddr[0] = 0; - if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) - { - if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) - Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); - } - obj.push_back(Pair("slot",(int64_t)vout-1)); - if ( (retval= games_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers,symbol,pname)) == 0 ) - { - if ( CCgettxout(gametxid,maxplayers+vout,1,0) == 10000 ) - { - if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 ) - { - if ( games_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) - obj.push_back(Pair("status","registered")); - else obj.push_back(Pair("status","alive")); - } else obj.push_back(Pair("status","error")); - } else obj.push_back(Pair("status","finished")); - obj.push_back(Pair("baton",batontxid.ToString())); - obj.push_back(Pair("tokenid",tokenid.ToString())); - obj.push_back(Pair("batonaddr",destaddr)); - obj.push_back(Pair("ismine",strcmp(mygamesaddr,destaddr)==0)); - obj.push_back(Pair("batonvout",(int64_t)batonvout)); - obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); - obj.push_back(Pair("batonht",(int64_t)batonht)); - if ( playerdata.size() > 0 ) - obj.push_back(Pair("player",games_playerobj(playerdata,playertxid,tokenid,symbol,pname,gametxid))); - } else fprintf(stderr,"findbaton err.%d\n",retval); -} - uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr) { CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; @@ -936,6 +902,40 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-1); } +void games_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *mygamesaddr) +{ + // identify if bailout or quit or timed out + uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; std::string symbol,pname; + destaddr[0] = 0; + if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); + } + obj.push_back(Pair("slot",(int64_t)vout-1)); + if ( (retval= games_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers,symbol,pname)) == 0 ) + { + if ( CCgettxout(gametxid,maxplayers+vout,1,0) == 10000 ) + { + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 ) + { + if ( games_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) + obj.push_back(Pair("status","registered")); + else obj.push_back(Pair("status","alive")); + } else obj.push_back(Pair("status","error")); + } else obj.push_back(Pair("status","finished")); + obj.push_back(Pair("baton",batontxid.ToString())); + obj.push_back(Pair("tokenid",tokenid.ToString())); + obj.push_back(Pair("batonaddr",destaddr)); + obj.push_back(Pair("ismine",strcmp(mygamesaddr,destaddr)==0)); + obj.push_back(Pair("batonvout",(int64_t)batonvout)); + obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); + obj.push_back(Pair("batonht",(int64_t)batonht)); + if ( playerdata.size() > 0 ) + obj.push_back(Pair("player",games_playerobj(playerdata,playertxid,tokenid,symbol,pname,gametxid))); + } else fprintf(stderr,"findbaton err.%d\n",retval); +} + UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); From e97460a58dee3e50f3eaf1ee1b78f2feb7dbc61d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:43:18 -1100 Subject: [PATCH 3140/3904] Stub functions --- src/cc/gamescc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index aca989fd3..b68c9f55c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1634,4 +1634,14 @@ bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return(true); } +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) +{ + return(-1); +} + +void games_packitemstr(char *packitemstr,struct games_packitem *item) +{ + sprintf(packitemstr,"not yet"); +} + From c1be8157e76b8c3f7d225d9afdde494b2c5565f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 06:51:16 -1100 Subject: [PATCH 3141/3904] Dont advance keystrokes unless keystrokes tx worked --- src/cc/rogue/main.c | 15 ++++++++++----- src/cc/rogue/rogue.c | 16 ++++++---------- src/cc/rogue/rogue.h | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f146cfb4d..616ade086 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -784,9 +784,9 @@ int32_t rogue_sendrawtransaction(char *rawtx) return(retval); } -void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) +int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj; + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { @@ -795,7 +795,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * if ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) { if ( waitflag == 0 ) - return; + return(0); else if ( 0 ) { while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) @@ -866,8 +866,12 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * { if ( rs->keystrokeshex != 0 ) free(rs->keystrokeshex); - rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); - strcpy(rs->keystrokeshex,rawtx); + if ( (errstr= jstr(resobj,"error")) == 0 ) + { + rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); + strcpy(rs->keystrokeshex,rawtx); + retflag = 1; + } else fprintf(stderr,"error sending keystrokes tx\n"), sleep(1); //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } free_json(retjson); @@ -885,6 +889,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } } } + return(retflag); } int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 7a8e38c15..c687fd019 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -158,7 +158,7 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) #ifdef BUILD_ROGUE // stubs for inside daemon -void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) +int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { } @@ -172,15 +172,11 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) { if ( rs->num > 0 ) { - // need to get existing keystrokes including mempool - // create keystrokes that are not saved - //rs->keytxid = rogue_progress(rs,waitflag,rs->seed,&rs->buffered[rs->lastnum],rs->num - rs->lastnum); - //rs->lastnum = rs->num; - rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num); - flushkeystrokes_local(rs,waitflag); - memset(rs->buffered,0,sizeof(rs->buffered)); - //rs->num = 0; - //rs->counter++; + if ( rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num) > 0 ) + { + flushkeystrokes_local(rs,waitflag); + memset(rs->buffered,0,sizeof(rs->buffered)); + } } return(0); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 5540da2da..65ddf1e51 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -380,7 +380,7 @@ int32_t rogue_restorepack(struct rogue_state *rs); void restore_player(struct rogue_state *rs); int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); void rogue_bailout(struct rogue_state *rs); -void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num); +int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num); int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr); #define ROGUE_MAXTOTAL (pstats.s_str*2) From 259b9a983851e44f7d9fc7f8cbc0eb6d8a77ea49 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:35:23 -1100 Subject: [PATCH 3142/3904] Errata --- src/cc/gamescc.cpp | 896 ++++++++++++++++++++++++++++++++++++++++++++ src/cc/rogue/main.c | 2 +- 2 files changed, 897 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b68c9f55c..88df9586d 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1,3 +1,18 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + #include "gamescc.h" /* @@ -1645,3 +1660,884 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) } +/***************************************************************************/ +/** https://github.com/brenns10/tetris + @file main.c + @author Stephen Brennan + @date Created Wednesday, 10 June 2015 + @brief Main program for tetris. + @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised + BSD License. See LICENSE.txt for details. + *******************************************************************************/ + + +#ifndef TETRIS_H +#define TETRIS_H + +#include // for FILE +#include // for bool +#include +#include +#include +#include +#include +#include + +#ifdef BUILD_GAMES +#include "cursesd.h" +#include "rogue/cursesd.c" +#else +#include +#endif + + +/* + Convert a tetromino type to its corresponding cell. + */ +#define TYPE_TO_CELL(x) ((x)+1) + +/* + Strings for how you would print a tetris board. + */ +#define TC_EMPTY_STR " " +#define TC_BLOCK_STR "\u2588" + +/* + Questions about a tetris cell. + */ +#define TC_IS_EMPTY(x) ((x) == TC_EMPTY) +#define TC_IS_FILLED(x) (!TC_IS_EMPTY(x)) + +/* + How many cells in a tetromino? + */ +#define TETRIS 4 +/* + How many tetrominos? + */ +#define NUM_TETROMINOS 7 +/* + How many orientations of a tetromino? + */ +#define NUM_ORIENTATIONS 4 + +/* + Level constants. + */ +#define MAX_LEVEL 19 +#define LINES_PER_LEVEL 10 + +/* + A "cell" is a 1x1 block within a tetris board. + */ +typedef enum { + TC_EMPTY, TC_CELLI, TC_CELLJ, TC_CELLL, TC_CELLO, TC_CELLS, TC_CELLT, TC_CELLZ +} tetris_cell; + +/* + A "type" is a type/shape of a tetromino. Not including orientation. + */ +typedef enum { + TET_I, TET_J, TET_L, TET_O, TET_S, TET_T, TET_Z +} tetris_type; + +/* + A row,column pair. Negative numbers allowed, because we need them for + offsets. + */ +typedef struct { + int row; + int col; +} tetris_location; + +/* + A "block" is a struct that contains information about a tetromino. + Specifically, what type it is, what orientation it has, and where it is. + */ +typedef struct { + int typ; + int ori; + tetris_location loc; +} tetris_block; + +/* + All possible moves to give as input to the game. + */ +typedef enum { + TM_LEFT, TM_RIGHT, TM_CLOCK, TM_COUNTER, TM_DROP, TM_HOLD, TM_NONE +} tetris_move; + +/* + A game object! + */ +typedef struct { + /* + Game board stuff: + */ + int rows; + int cols; + char *board; + /* + Scoring information: + */ + int points; + int level; + /* + Falling block is the one currently going down. Next block is the one that + will be falling after this one. Stored is the block that you can swap out. + */ + tetris_block falling; + tetris_block next; + tetris_block stored; + /* + Number of game ticks until the block will move down. + */ + int ticks_till_gravity; + /* + Number of lines until you advance to the next level. + */ + int lines_remaining; +} tetris_game; + +/* + This array stores all necessary information about the cells that are filled by + each tetromino. The first index is the type of the tetromino (i.e. shape, + e.g. I, J, Z, etc.). The next index is the orientation (0-3). The final + array contains 4 tetris_location objects, each mapping to an offset from a + point on the upper left that is the tetromino "origin". + */ +extern tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; + +/* + This array tells you how many ticks per gravity by level. Decreases as level + increases, to add difficulty. + */ +extern int GRAVITY_LEVEL[MAX_LEVEL+1]; + +// Data structure manipulation. +void tg_init(tetris_game *obj, int rows, int cols); +tetris_game *tg_create(int rows, int cols); +void tg_destroy(tetris_game *obj); +void tg_delete(tetris_game *obj); +tetris_game *tg_load(FILE *f); +void tg_save(tetris_game *obj, FILE *f); + +// Public methods not related to memory: +char tg_get(tetris_game *obj, int row, int col); +bool tg_check(tetris_game *obj, int row, int col); +bool tg_tick(tetris_game *obj, tetris_move move); +void tg_print(tetris_game *obj, FILE *f); + +#endif // TETRIS_H + + +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) + +/******************************************************************************* + Array Definitions + *******************************************************************************/ + +tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS] = { + // I + {{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, + {{0, 2}, {1, 2}, {2, 2}, {3, 2}}, + {{3, 0}, {3, 1}, {3, 2}, {3, 3}}, + {{0, 1}, {1, 1}, {2, 1}, {3, 1}}}, + // J + {{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, + {{0, 1}, {1, 1}, {2, 0}, {2, 1}}}, + // L + {{{0, 2}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, + {{0, 0}, {0, 1}, {1, 1}, {2, 1}}}, + // O + {{{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}}, + // S + {{{0, 1}, {0, 2}, {1, 0}, {1, 1}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 2}}, + {{1, 1}, {1, 2}, {2, 0}, {2, 1}}, + {{0, 0}, {1, 0}, {1, 1}, {2, 1}}}, + // T + {{{0, 1}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 1}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 1}}}, + // Z + {{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, + {{0, 2}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {2, 1}, {2, 2}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 0}}}, +}; + +int GRAVITY_LEVEL[MAX_LEVEL+1] = { + // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + //10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 30, 28, 26, 24, 22, 20, 16, 12, 8, 4 +}; + +/******************************************************************************* + Helper Functions for Blocks + *******************************************************************************/ + +void sleep_milli(int milliseconds) +{ + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = milliseconds * 1000 * 1000; + nanosleep(&ts, NULL); +} + +/* + Return the block at the given row and column. + */ +char tg_get(tetris_game *obj, int row, int column) +{ + return obj->board[obj->cols * row + column]; +} + +/* + Set the block at the given row and column. + */ +static void tg_set(tetris_game *obj, int row, int column, char value) +{ + obj->board[obj->cols * row + column] = value; +} + +/* + Check whether a row and column are in bounds. + */ +bool tg_check(tetris_game *obj, int row, int col) +{ + return 0 <= row && row < obj->rows && 0 <= col && col < obj->cols; +} + +/* + Place a block onto the board. + */ +static void tg_put(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, + TYPE_TO_CELL(block.typ)); + } +} + +/* + Clear a block out of the board. + */ +static void tg_remove(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, TC_EMPTY); + } +} + +/* + Check if a block can be placed on the board. + */ +static bool tg_fits(tetris_game *obj, tetris_block block) +{ + int i, r, c; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + r = block.loc.row + cell.row; + c = block.loc.col + cell.col; + if (!tg_check(obj, r, c) || TC_IS_FILLED(tg_get(obj, r, c))) { + return false; + } + } + return true; +} + +/* + Return a random tetromino type. + */ +static int random_tetromino(void) +{ + return rand() % NUM_TETROMINOS; +} + +/* + Create a new falling block and populate the next falling block with a random + one. + */ +static void tg_new_falling(tetris_game *obj) +{ + // Put in a new falling tetromino. + obj->falling = obj->next; + obj->next.typ = random_tetromino(); + obj->next.ori = 0; + obj->next.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; +} + +/******************************************************************************* + Game Turn Helpers + *******************************************************************************/ + +/* + Tick gravity, and move the block down if gravity should act. + */ +static void tg_do_gravity_tick(tetris_game *obj) +{ + obj->ticks_till_gravity--; + if (obj->ticks_till_gravity <= 0) { + tg_remove(obj, obj->falling); + obj->falling.loc.row++; + if (tg_fits(obj, obj->falling)) { + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + } else { + obj->falling.loc.row--; + tg_put(obj, obj->falling); + + tg_new_falling(obj); + } + tg_put(obj, obj->falling); + } +} + +/* + Move the falling tetris block left (-1) or right (+1). + */ +static void tg_move(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + obj->falling.loc.col += direction; + if (!tg_fits(obj, obj->falling)) { + obj->falling.loc.col -= direction; + } + tg_put(obj, obj->falling); +} + +/* + Send the falling tetris block to the bottom. + */ +static void tg_down(tetris_game *obj) +{ + tg_remove(obj, obj->falling); + while (tg_fits(obj, obj->falling)) { + obj->falling.loc.row++; + } + obj->falling.loc.row--; + tg_put(obj, obj->falling); + tg_new_falling(obj); +} + +/* + Rotate the falling block in either direction (+/-1). + */ +static void tg_rotate(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + + while (true) { + obj->falling.ori = (obj->falling.ori + direction) % NUM_ORIENTATIONS; + + // If the new orientation fits, we're done. + if (tg_fits(obj, obj->falling)) + break; + + // Otherwise, try moving left to make it fit. + obj->falling.loc.col--; + if (tg_fits(obj, obj->falling)) + break; + + // Finally, try moving right to make it fit. + obj->falling.loc.col += 2; + if (tg_fits(obj, obj->falling)) + break; + + // Put it back in its original location and try the next orientation. + obj->falling.loc.col--; + // Worst case, we come back to the original orientation and it fits, so this + // loop will terminate. + } + + tg_put(obj, obj->falling); +} + +/* + Swap the falling block with the block in the hold buffer. + */ +static void tg_hold(tetris_game *obj) +{ + tg_remove(obj, obj->falling); + if (obj->stored.typ == -1) { + obj->stored = obj->falling; + tg_new_falling(obj); + } else { + int typ = obj->falling.typ, ori = obj->falling.ori; + obj->falling.typ = obj->stored.typ; + obj->falling.ori = obj->stored.ori; + obj->stored.typ = typ; + obj->stored.ori = ori; + while (!tg_fits(obj, obj->falling)) { + obj->falling.loc.row--; + } + } + tg_put(obj, obj->falling); +} + +/* + Perform the action specified by the move. + */ +static void tg_handle_move(tetris_game *obj, tetris_move move) +{ + switch (move) { + case TM_LEFT: + tg_move(obj, -1); + break; + case TM_RIGHT: + tg_move(obj, 1); + break; + case TM_DROP: + tg_down(obj); + break; + case TM_CLOCK: + tg_rotate(obj, 1); + break; + case TM_COUNTER: + tg_rotate(obj, -1); + break; + case TM_HOLD: + tg_hold(obj); + break; + default: + // pass + break; + } +} + +/* + Return true if line i is full. + */ +static bool tg_line_full(tetris_game *obj, int i) +{ + int j; + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) + return false; + } + return true; +} + +/* + Shift every row above r down one. + */ +static void tg_shift_lines(tetris_game *obj, int r) +{ + int i, j; + for (i = r-1; i >= 0; i--) { + for (j = 0; j < obj->cols; j++) { + tg_set(obj, i+1, j, tg_get(obj, i, j)); + tg_set(obj, i, j, TC_EMPTY); + } + } +} + +/* + Find rows that are filled, remove them, shift, and return the number of + cleared rows. + */ +static int tg_check_lines(tetris_game *obj) +{ + int i, nlines = 0; + tg_remove(obj, obj->falling); // don't want to mess up falling block + + for (i = obj->rows-1; i >= 0; i--) { + if (tg_line_full(obj, i)) { + tg_shift_lines(obj, i); + i++; // do this line over again since they're shifted + nlines++; + } + } + + tg_put(obj, obj->falling); // replace + return nlines; +} + +/* + Adjust the score for the game, given how many lines were just cleared. + */ +static void tg_adjust_score(tetris_game *obj, int lines_cleared) +{ + static int line_multiplier[] = {0, 40, 100, 300, 1200}; + obj->points += line_multiplier[lines_cleared] * (obj->level + 1); + if (lines_cleared >= obj->lines_remaining) { + obj->level = MIN(MAX_LEVEL, obj->level + 1); + lines_cleared -= obj->lines_remaining; + obj->lines_remaining = LINES_PER_LEVEL - lines_cleared; + } else { + obj->lines_remaining -= lines_cleared; + } +} + +/* + Return true if the game is over. + */ +static bool tg_game_over(tetris_game *obj) +{ + int i, j; + bool over = false; + tg_remove(obj, obj->falling); + for (i = 0; i < 2; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + over = true; + } + } + } + tg_put(obj, obj->falling); + return over; +} + +/******************************************************************************* + Main Public Functions + *******************************************************************************/ + +/* + Do a single game tick: process gravity, user input, and score. Return true if + the game is still running, false if it is over. + */ +bool tg_tick(tetris_game *obj, tetris_move move) +{ + int lines_cleared; + // Handle gravity. + tg_do_gravity_tick(obj); + + // Handle input. + tg_handle_move(obj, move); + + // Check for cleared lines + lines_cleared = tg_check_lines(obj); + + tg_adjust_score(obj, lines_cleared); + + // Return whether the game will continue (NOT whether it's over) + return !tg_game_over(obj); +} + +void tg_init(tetris_game *obj, int rows, int cols) +{ + // Initialization logic + obj->rows = rows; + obj->cols = cols; + obj->board = (char *)malloc(rows * cols); + memset(obj->board, TC_EMPTY, rows * cols); + obj->points = 0; + obj->level = 0; + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + obj->lines_remaining = LINES_PER_LEVEL; + srand(time(NULL)); + tg_new_falling(obj); + tg_new_falling(obj); + obj->stored.typ = -1; + obj->stored.ori = 0; + obj->stored.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; + printf("%d", obj->falling.loc.col); +} + +tetris_game *tg_create(int rows, int cols) +{ + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); + tg_init(obj, rows, cols); + return obj; +} + +void tg_destroy(tetris_game *obj) +{ + // Cleanup logic + free(obj->board); +} + +void tg_delete(tetris_game *obj) { + tg_destroy(obj); + free(obj); +} + +/* + Load a game from a file. + */ +tetris_game *tg_load(FILE *f) +{ + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); + if (fread(obj, sizeof(tetris_game), 1, f) != 1 ) + { + fprintf(stderr,"read game error\n"); + free(obj); + obj = 0; + } + else + { + obj->board = (char *)malloc(obj->rows * obj->cols); + if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + { + fprintf(stderr,"fread error\n"); + free(obj->board); + free(obj); + obj = 0; + } + } + return obj; +} + +/* + Save a game to a file. + */ +void tg_save(tetris_game *obj, FILE *f) +{ + if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) + fprintf(stderr,"error writing tetrisgame\n"); + else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + fprintf(stderr,"error writing board\n"); +} + +/* + Print a game board to a file. Really just for early debugging. + */ +void tg_print(tetris_game *obj, FILE *f) { + int i, j; + for (i = 0; i < obj->rows; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) { + fputs(TC_EMPTY_STR, f); + } else { + fputs(TC_BLOCK_STR, f); + } + } + fputc('\n', f); + } +} + +/* + 2 columns per cell makes the game much nicer. + */ +#define COLS_PER_CELL 2 +/* + Macro to print a cell of a specific type to a window. + */ +#define ADD_BLOCK(w,x) waddch((w),' '|A_REVERSE|COLOR_PAIR(x)); \ +waddch((w),' '|A_REVERSE|COLOR_PAIR(x)) +#define ADD_EMPTY(w) waddch((w), ' '); waddch((w), ' ') + +/* + Print the tetris board onto the ncurses window. + */ +void display_board(WINDOW *w, tetris_game *obj) +{ + int i, j; + box(w, 0, 0); + for (i = 0; i < obj->rows; i++) { + wmove(w, 1 + i, 1); + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + ADD_BLOCK(w,tg_get(obj, i, j)); + } else { + ADD_EMPTY(w); + } + } + } + wnoutrefresh(w); +} + +/* + Display a tetris piece in a dedicated window. + */ +void display_piece(WINDOW *w, tetris_block block) +{ + int b; + tetris_location c; + wclear(w); + box(w, 0, 0); + if (block.typ == -1) { + wnoutrefresh(w); + return; + } + for (b = 0; b < TETRIS; b++) { + c = TETROMINOS[block.typ][block.ori][b]; + wmove(w, c.row + 1, c.col * COLS_PER_CELL + 1); + ADD_BLOCK(w, TYPE_TO_CELL(block.typ)); + } + wnoutrefresh(w); +} + +/* + Display score information in a dedicated window. + */ +void display_score(WINDOW *w, tetris_game *tg) +{ + wclear(w); + box(w, 0, 0); + wprintw(w, "Score\n%d\n", tg->points); + wprintw(w, "Level\n%d\n", tg->level); + wprintw(w, "Lines\n%d\n", tg->lines_remaining); + wnoutrefresh(w); +} + +/* + Save and exit the game. + */ +void save(tetris_game *game, WINDOW *w) +{ + FILE *f; + + wclear(w); + box(w, 0, 0); // return the border + wmove(w, 1, 1); + wprintw(w, "Save and exit? [Y/n] "); + wrefresh(w); + timeout(-1); + if (getch() == 'n') { + timeout(0); + return; + } + f = fopen("tetris.save", "w"); + tg_save(game, f); + fclose(f); + tg_delete(game); + endwin(); + printf("Game saved to \"tetris.save\".\n"); + printf("Resume by passing the filename as an argument to this program.\n"); + exit(EXIT_SUCCESS); +} + +/* + Do the NCURSES initialization steps for color blocks. + */ +void init_colors(void) +{ + start_color(); + //init_color(COLOR_ORANGE, 1000, 647, 0); + init_pair(TC_CELLI, COLOR_CYAN, COLOR_BLACK); + init_pair(TC_CELLJ, COLOR_BLUE, COLOR_BLACK); + init_pair(TC_CELLL, COLOR_WHITE, COLOR_BLACK); + init_pair(TC_CELLO, COLOR_YELLOW, COLOR_BLACK); + init_pair(TC_CELLS, COLOR_GREEN, COLOR_BLACK); + init_pair(TC_CELLT, COLOR_MAGENTA, COLOR_BLACK); + init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); +} + +/* + Main tetris game! + */ +#ifndef STANDALONE + +int main(int argc, char **argv) +{ + tetris_game *tg; + tetris_move move = TM_NONE; + bool running = true; + WINDOW *board, *next, *hold, *score; + //Mix_Music *music; + + // Load file if given a filename. + if (argc >= 2) { + FILE *f = fopen(argv[1], "r"); + if (f == NULL) { + perror("tetris"); + exit(EXIT_FAILURE); + } + tg = tg_load(f); + fclose(f); + } else { + // Otherwise create new game. + tg = tg_create(22, 10); + } + // NCURSES initialization: + initscr(); // initialize curses + cbreak(); // pass key presses to program, but not signals + noecho(); // don't echo key presses to screen + keypad(stdscr, TRUE); // allow arrow keys + timeout(0); // no blocking on getch() + curs_set(0); // set the cursor to invisible + init_colors(); // setup tetris colors + + // Create windows for each section of the interface. + board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); + next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); + hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); + score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); + int32_t counter = 0; + // Game loop + while (running) { + running = tg_tick(tg, move); + display_board(board, tg); + display_piece(next, tg->next); + display_piece(hold, tg->stored); + display_score(score, tg); + if ( (counter++ % 5) == 0 ) + doupdate(); + sleep_milli(10); + + switch (getch()) { + case KEY_LEFT: + move = TM_LEFT; + break; + case KEY_RIGHT: + move = TM_RIGHT; + break; + case KEY_UP: + move = TM_CLOCK; + break; + case KEY_DOWN: + move = TM_DROP; + break; + case 'q': + running = false; + move = TM_NONE; + break; + case 'p': + wclear(board); + box(board, 0, 0); + wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); + wprintw(board, "PAUSED"); + wrefresh(board); + timeout(-1); + getch(); + timeout(0); + move = TM_NONE; + break; + case 's': + save(tg, board); + move = TM_NONE; + break; + case ' ': + move = TM_HOLD; + break; + default: + move = TM_NONE; + } + } + + // Deinitialize NCurses + wclear(stdscr); + endwin(); + + /* Deinitialize Sound + Mix_HaltMusic(); + Mix_FreeMusic(music); + Mix_CloseAudio(); + Mix_Quit();*/ + + // Output ending message. + printf("Game over!\n"); + printf("You finished with %d points on level %d.\n", tg->points, tg->level); + + // Deinitialize Tetris + tg_delete(tg); + return 0; +} + diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 616ade086..093b73d70 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -786,7 +786,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; + char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { From a266b5e613f05f686c056a56e6047fd950dee090 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:36:23 -1100 Subject: [PATCH 3143/3904] Test --- src/cc/gamescc.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 88df9586d..4b5dca4f5 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2525,13 +2525,6 @@ int main(int argc, char **argv) // Deinitialize NCurses wclear(stdscr); endwin(); - - /* Deinitialize Sound - Mix_HaltMusic(); - Mix_FreeMusic(music); - Mix_CloseAudio(); - Mix_Quit();*/ - // Output ending message. printf("Game over!\n"); printf("You finished with %d points on level %d.\n", tg->points, tg->level); @@ -2540,4 +2533,5 @@ int main(int argc, char **argv) tg_delete(tg); return 0; } +#endif From 59b34d0a1c68fd2cdb13fb9bbe2da4dab074f934 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:39:13 -1100 Subject: [PATCH 3144/3904] #include "rogue/cursesd.c" --- src/cc/cclib.cpp | 1 + src/cc/gamescc.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 65c706862..95748def4 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -692,6 +692,7 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) #elif BUILD_GAMESCC #include "gamescc.cpp" +#include "rogue/cursesd.c" #else #include "sudoku.cpp" diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 4b5dca4f5..3415c3eb7 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1685,7 +1685,6 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #ifdef BUILD_GAMES #include "cursesd.h" -#include "rogue/cursesd.c" #else #include #endif @@ -2433,7 +2432,7 @@ void init_colors(void) /* Main tetris game! */ -#ifndef STANDALONE +#ifdef STANDALONE int main(int argc, char **argv) { From 284a57b31f774f2800661354e81c12a2310a5ace Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:46:19 -1100 Subject: [PATCH 3145/3904] BUILD_GAMESCC --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 3415c3eb7..0d2564042 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1683,7 +1683,7 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include -#ifdef BUILD_GAMES +#ifdef BUILD_GAMESCC #include "cursesd.h" #else #include From f800ced0e20af6e559b6b24f5096960a4d2249b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:46:59 -1100 Subject: [PATCH 3146/3904] Rogue/cursesd --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 0d2564042..81942ebe4 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1684,7 +1684,7 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #ifdef BUILD_GAMESCC -#include "cursesd.h" +#include "rogue/cursesd.h" #else #include #endif From 7a1a5f15299816629b7c22124e68b56e2c14f29f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:51:45 -1100 Subject: [PATCH 3147/3904] Endif --- src/cc/gamescc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 81942ebe4..c6206b2ee 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1659,6 +1659,7 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) sprintf(packitemstr,"not yet"); } +#ifdef includgame /***************************************************************************/ /** https://github.com/brenns10/tetris @@ -2533,4 +2534,5 @@ int main(int argc, char **argv) return 0; } #endif +#endif From 347ba53d84c64133f5a3c695f7cb3f4515759090 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:52:57 -1100 Subject: [PATCH 3148/3904] // --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6f507e51e..fbb1a3d93 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1596,7 +1596,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( funcid == 'H' ) { cashout *= 2; - cashout += numplayers * buyin; + //cashout += numplayers * buyin; } sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) From 9c555e6168c8442e5994fdc69551e4865bf5cb46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 07:59:17 -1100 Subject: [PATCH 3149/3904] Colors --- src/cc/gamescc.cpp | 3 --- src/cc/rogue/cursesd.h | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index c6206b2ee..694846350 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1659,8 +1659,6 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) sprintf(packitemstr,"not yet"); } -#ifdef includgame - /***************************************************************************/ /** https://github.com/brenns10/tetris @file main.c @@ -2534,5 +2532,4 @@ int main(int argc, char **argv) return 0; } #endif -#endif diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index cb74941e5..fbac07855 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -16,6 +16,24 @@ #ifndef H_CURSESD_H #define H_CURSESD_H +#define COLOR_BLACK 0 + +#ifdef PDC_RGB /* RGB */ +# define COLOR_RED 1 +# define COLOR_GREEN 2 +# define COLOR_BLUE 4 +#else /* BGR */ +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_RED 4 +#endif + +#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) +#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) +#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) + +#define COLOR_WHITE 7 + #define LINES 24 #define COLS 80 From 02facf2da73eda9e77633fead9c7e0c4228f1177 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 08:04:50 -1100 Subject: [PATCH 3150/3904] Test --- src/cc/gamescc.cpp | 12 ++++++------ src/cc/rogue/cursesd.h | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 694846350..175cc3dc2 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2379,9 +2379,9 @@ void display_score(WINDOW *w, tetris_game *tg) { wclear(w); box(w, 0, 0); - wprintw(w, "Score\n%d\n", tg->points); - wprintw(w, "Level\n%d\n", tg->level); - wprintw(w, "Lines\n%d\n", tg->lines_remaining); + wprintw(w, (char *)"Score\n%d\n", tg->points); + wprintw(w, (char *)"Level\n%d\n", tg->level); + wprintw(w, (char *)"Lines\n%d\n", tg->lines_remaining); wnoutrefresh(w); } @@ -2395,7 +2395,7 @@ void save(tetris_game *game, WINDOW *w) wclear(w); box(w, 0, 0); // return the border wmove(w, 1, 1); - wprintw(w, "Save and exit? [Y/n] "); + wprintw(w, (char *)"Save and exit? [Y/n] "); wrefresh(w); timeout(-1); if (getch() == 'n') { @@ -2407,8 +2407,8 @@ void save(tetris_game *game, WINDOW *w) fclose(f); tg_delete(game); endwin(); - printf("Game saved to \"tetris.save\".\n"); - printf("Resume by passing the filename as an argument to this program.\n"); + fprintf(stderr,"Game saved to \"tetris.save\".\n"); + fprintf(stderr,"Resume by passing the filename as an argument to this program.\n"); exit(EXIT_SUCCESS); } diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index fbac07855..0ae992427 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -168,6 +168,12 @@ char *unctrl(char c); #define leaveok(win,bf) 0 #define halfdelay(x) 0 #define nocbreak() 0 +#define init_color(a,b,c) 0 +#define start_color() 0 +#define box(a,b,c) 0 +#define A_REVERSE 0 +#define COLOR_PAIR(a) 0 +#define timeout(x) 0 #ifndef TRUE #define TRUE 1 From a06129b526ff501c30bfed43625a325938e2107c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 08:07:18 -1100 Subject: [PATCH 3151/3904] init_pair --- src/cc/rogue/cursesd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 0ae992427..cdad704ed 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -168,7 +168,7 @@ char *unctrl(char c); #define leaveok(win,bf) 0 #define halfdelay(x) 0 #define nocbreak() 0 -#define init_color(a,b,c) 0 +#define init_pair(a,b,c) 0 #define start_color() 0 #define box(a,b,c) 0 #define A_REVERSE 0 From b91cd4346bca52fcd668c3748f535785b8a3ba25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 08:50:49 -1100 Subject: [PATCH 3152/3904] Standalone --- src/cc/gamescc.cpp | 995 ++++++++++++++++++++++++++++++++++++++++- src/cc/rogue/cursesd.h | 3 + 2 files changed, 996 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 175cc3dc2..59adfae1d 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1659,6 +1659,997 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) sprintf(packitemstr,"not yet"); } +#ifdef STANDALONE + +#include +#include +#include +#include +#include +#include +#include +#include + +char USERPASS[8192]; uint16_t GAMES_PORT; +extern char Gametxidstr[67]; + +#define SMALLVAL 0.000000000000001 +#define SATOSHIDEN ((uint64_t)100000000L) +#define dstr(x) ((double)(x) / SATOSHIDEN) +#define KOMODO_ASSETCHAIN_MAXLEN 65 +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],IPADDRESS[100]; + +#ifndef _BITS256 +#define _BITS256 +union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; +typedef union _bits256 bits256; +#endif + +#ifdef _WIN32 +#ifdef _MSC_VER +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = ((uint64_t)file_time.dwLowDateTime); + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); + return 0; +} +#endif // _MSC_VER +#endif + + + +double OS_milliseconds() +{ + struct timeval tv; double millis; +#ifdef __MINGW32__ + mingw_gettimeofday(&tv,NULL); +#else + gettimeofday(&tv,NULL); +#endif + millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.); + //printf("tv_sec.%ld usec.%d %f\n",tv.tv_sec,tv.tv_usec,millis); + return(millis); +} + +int32_t _unhex(char c) +{ + if ( c >= '0' && c <= '9' ) + return(c - '0'); + else if ( c >= 'a' && c <= 'f' ) + return(c - 'a' + 10); + else if ( c >= 'A' && c <= 'F' ) + return(c - 'A' + 10); + return(-1); +} + +int32_t is_hexstr(char *str,int32_t n) +{ + int32_t i; + if ( str == 0 || str[0] == 0 ) + return(0); + for (i=0; str[i]!=0; i++) + { + if ( n > 0 && i >= n ) + break; + if ( _unhex(str[i]) < 0 ) + break; + } + if ( n == 0 ) + return(i); + return(i == n); +} + +int32_t unhex(char c) +{ + int32_t hex; + if ( (hex= _unhex(c)) < 0 ) + { + //printf("unhex: illegal hexchar.(%c)\n",c); + } + return(hex); +} + +unsigned char _decode_hex(char *hex) { return((unhex(hex[0])<<4) | unhex(hex[1])); } + +int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) +{ + int32_t adjust,i = 0; + //printf("decode.(%s)\n",hex); + if ( is_hexstr(hex,n) <= 0 ) + { + memset(bytes,0,n); + return(n); + } + if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) + hex[--n] = 0; + if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) ) + { + if ( n > 0 ) + { + bytes[0] = unhex(hex[0]); + printf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex)); + } + bytes++; + hex++; + adjust = 1; + } else adjust = 0; + if ( n > 0 ) + { + for (i=0; i>4) & 0xf); + hexbytes[i*2 + 1] = hexbyte(message[i] & 0xf); + //printf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]); + } + hexbytes[len*2] = 0; + //printf("len.%ld\n",len*2+1); + return((int32_t)len*2+1); +} + +char *bits256_str(char hexstr[65],bits256 x) +{ + init_hexbytes_noT(hexstr,x.bytes,sizeof(x)); + return(hexstr); +} + +long _stripwhite(char *buf,int accept) +{ + int32_t i,j,c; + if ( buf == 0 || buf[0] == 0 ) + return(0); + for (i=j=0; buf[i]!=0; i++) + { + buf[j] = c = buf[i]; + if ( c == accept || (c != ' ' && c != '\n' && c != '\r' && c != '\t' && c != '\b') ) + j++; + } + buf[j] = 0; + return(j); +} + +char *clonestr(char *str) +{ + char *clone; + if ( str == 0 || str[0] == 0 ) + { + printf("warning cloning nullstr.%p\n",str); +#ifdef __APPLE__ + while ( 1 ) sleep(1); +#endif + str = (char *)""; + } + clone = (char *)malloc(strlen(str)+16); + strcpy(clone,str); + return(clone); +} + +char *parse_conf_line(char *line,char *field) +{ + line += strlen(field); + for (; *line!='='&&*line!=0; line++) + break; + if ( *line == 0 ) + return(0); + if ( *line == '=' ) + line++; + while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' ) + line[strlen(line)-1] = 0; + //printf("LINE.(%s)\n",line); + _stripwhite(line,0); + return(clonestr(line)); +} + +int32_t safecopy(char *dest,char *src,long len) +{ + int32_t i = -1; + if ( src != 0 && dest != 0 && src != dest ) + { + if ( dest != 0 ) + memset(dest,0,len); + for (i=0; i buflen ) + { + *allocsizep = filesize; + *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); + } + rewind(fp); + if ( buf == 0 ) + printf("Null buf ???\n"); + else + { + if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) + printf("error reading filesize.%ld\n",(long)filesize); + buf[filesize] = 0; + } + fclose(fp); + *lenp = filesize; + //printf("loaded.(%s)\n",buf); + } //else printf("OS_loadfile couldnt load.(%s)\n",fname); + return(buf); +} + +uint8_t *OS_fileptr(long *allocsizep,char *fname) +{ + long filesize = 0; uint8_t *buf = 0; void *retptr; + *allocsizep = 0; + retptr = OS_loadfile(fname,&buf,&filesize,allocsizep); + return((uint8_t *)retptr); +} + +struct MemoryStruct { char *memory; size_t size; }; +struct return_string { char *ptr; size_t len; }; + +// return data from the server +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_SSL (1<<0) +#define CURL_GLOBAL_WIN32 (1<<1) + + +/************************************************************************ + * + * Initialize the string handler so that it is thread safe + * + ************************************************************************/ + +void init_string(struct return_string *s) +{ + s->len = 0; + s->ptr = (char *)calloc(1,s->len+1); + if ( s->ptr == NULL ) + { + fprintf(stderr,"init_string malloc() failed\n"); + exit(-1); + } + s->ptr[0] = '\0'; +} + +/************************************************************************ + * + * Use the "writer" to accumulate text until done + * + ************************************************************************/ + +size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *s) +{ + size_t new_len = s->len + size*nmemb; + s->ptr = (char *)realloc(s->ptr,new_len+1); + if ( s->ptr == NULL ) + { + fprintf(stderr, "accumulate realloc() failed\n"); + exit(-1); + } + memcpy(s->ptr+s->len,ptr,size*nmemb); + s->ptr[new_len] = '\0'; + s->len = new_len; + return(size * nmemb); +} + +/************************************************************************ + * + * return the current system time in milliseconds + * + ************************************************************************/ + +#define EXTRACT_BITCOIND_RESULT // if defined, ensures error is null and returns the "result" field +#ifdef EXTRACT_BITCOIND_RESULT + +/************************************************************************ + * + * perform post processing of the results + * + ************************************************************************/ + +char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params) +{ + long i,j,len; char *retstr = 0; cJSON *json,*result,*error; + //printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); + if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 ) + { + if ( strcmp(command,"signrawtransaction") != 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); + return(rpcstr); + } + json = cJSON_Parse(rpcstr); + if ( json == 0 ) + { + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s) params.(%s)\n",debugstr,command,rpcstr,params); + free(rpcstr); + return(0); + } + result = cJSON_GetObjectItem(json,"result"); + error = cJSON_GetObjectItem(json,"error"); + if ( error != 0 && result != 0 ) + { + if ( (error->type&0xff) == cJSON_NULL && (result->type&0xff) != cJSON_NULL ) + { + retstr = cJSON_Print(result); + len = strlen(retstr); + if ( retstr[0] == '"' && retstr[len-1] == '"' ) + { + for (i=1,j=0; itype&0xff) != cJSON_NULL || (result->type&0xff) != cJSON_NULL ) + { + if ( strcmp(command,"signrawtransaction") != 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr); + } + free(rpcstr); + } else retstr = rpcstr; + free_json(json); + //fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: postprocess returns.(%s)\n",retstr); + return(retstr); +} +#endif + +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + +/************************************************************************ + * + * perform the query + * + ************************************************************************/ + +char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params) +{ + static int didinit,count,count2; static double elapsedsum,elapsedsum2; + struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle; + char *bracket0,*bracket1,*databuf = 0; long len; int32_t specialcase,numretries; double starttime; + if ( didinit == 0 ) + { + didinit = 1; + curl_global_init(CURL_GLOBAL_ALL); //init the curl session + } + numretries = 0; + if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 ) + specialcase = 1; + else specialcase = 0; + if ( url[0] == 0 ) + strcpy(url,"http://127.0.0.1:7876/nxt"); + if ( specialcase != 0 && 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params); +try_again: + if ( retstrp != 0 ) + *retstrp = 0; + starttime = OS_milliseconds(); + curl_handle = curl_easy_init(); + init_string(&s); + headers = curl_slist_append(0,"Expect:"); + + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl_handle,CURLOPT_URL, url); + curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function + curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback + curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash + curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback + if ( strncmp(url,"https",5) == 0 ) + { + curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,0); + curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYHOST,0); + } + if ( userpass != 0 ) + curl_easy_setopt(curl_handle,CURLOPT_USERPWD, userpass); + databuf = 0; + if ( params != 0 ) + { + if ( command != 0 && specialcase == 0 ) + { + len = strlen(params); + if ( len > 0 && params[0] == '[' && params[len-1] == ']' ) { + bracket0 = bracket1 = (char *)""; + } + else + { + bracket0 = (char *)"["; + bracket1 = (char *)"]"; + } + + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); + sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); + //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); + // + } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); + curl_easy_setopt(curl_handle,CURLOPT_POST,1L); + if ( databuf != 0 ) + curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,databuf); + else curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,params); + } + //laststart = milliseconds(); + res = curl_easy_perform(curl_handle); + curl_slist_free_all(headers); + curl_easy_cleanup(curl_handle); + if ( databuf != 0 ) // clean up temporary buffer + { + free(databuf); + databuf = 0; + } + if ( res != CURLE_OK ) + { + numretries++; + if ( specialcase != 0 ) + { + printf("<<<<<<<<<<< bitcoind_RPC.(%s): BTCD.%s timeout params.(%s) s.ptr.(%s) err.%d\n",url,command,params,s.ptr,res); + free(s.ptr); + return(0); + } + else if ( numretries >= 1 ) + { + //printf("Maximum number of retries exceeded!\n"); + free(s.ptr); + return(0); + } + if ( (rand() % 1000) == 0 ) + printf( "curl_easy_perform() failed: %s %s.(%s %s), retries: %d\n",curl_easy_strerror(res),debugstr,url,command,numretries); + free(s.ptr); + sleep((1< (%s)\n",params,s.ptr); + count2++; + elapsedsum2 += (OS_milliseconds() - starttime); + if ( (count2 % 10000) == 0) + printf("%d: ave %9.6f | elapsed %.3f millis | NXT calls.(%s) cmd.(%s)\n",count2,elapsedsum2/count2,(double)(OS_milliseconds() - starttime),url,command); + return(s.ptr); + } + } + printf("bitcoind_RPC: impossible case\n"); + free(s.ptr); + return(0); +} + +static size_t WriteMemoryCallback(void *ptr,size_t size,size_t nmemb,void *data) +{ + size_t realsize = (size * nmemb); + struct MemoryStruct *mem = (struct MemoryStruct *)data; + mem->memory = (char *)((ptr != 0) ? realloc(mem->memory,mem->size + realsize + 1) : malloc(mem->size + realsize + 1)); + if ( mem->memory != 0 ) + { + if ( ptr != 0 ) + memcpy(&(mem->memory[mem->size]),ptr,realsize); + mem->size += realsize; + mem->memory[mem->size] = 0; + } + //printf("got %d bytes\n",(int32_t)(size*nmemb)); + return(realsize); +} + +char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *hdr0,char *hdr1,char *hdr2,char *hdr3) +{ + struct MemoryStruct chunk; CURL *cHandle; long code; struct curl_slist *headers = 0; + if ( (cHandle= *cHandlep) == NULL ) + *cHandlep = cHandle = curl_easy_init(); + else curl_easy_reset(cHandle); + //#ifdef DEBUG + //curl_easy_setopt(cHandle,CURLOPT_VERBOSE, 1); + //#endif + curl_easy_setopt(cHandle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + curl_easy_setopt(cHandle,CURLOPT_SSL_VERIFYPEER,0); + //curl_easy_setopt(cHandle,CURLOPT_SSLVERSION,1); + curl_easy_setopt(cHandle,CURLOPT_URL,url); + curl_easy_setopt(cHandle,CURLOPT_CONNECTTIMEOUT,10); + if ( userpass != 0 && userpass[0] != 0 ) + curl_easy_setopt(cHandle,CURLOPT_USERPWD,userpass); + if ( postfields != 0 && postfields[0] != 0 ) + { + curl_easy_setopt(cHandle,CURLOPT_POST,1); + curl_easy_setopt(cHandle,CURLOPT_POSTFIELDS,postfields); + } + if ( hdr0 != NULL && hdr0[0] != 0 ) + { + //printf("HDR0.(%s) HDR1.(%s) HDR2.(%s) HDR3.(%s)\n",hdr0!=0?hdr0:"",hdr1!=0?hdr1:"",hdr2!=0?hdr2:"",hdr3!=0?hdr3:""); + headers = curl_slist_append(headers,hdr0); + if ( hdr1 != 0 && hdr1[0] != 0 ) + headers = curl_slist_append(headers,hdr1); + if ( hdr2 != 0 && hdr2[0] != 0 ) + headers = curl_slist_append(headers,hdr2); + if ( hdr3 != 0 && hdr3[0] != 0 ) + headers = curl_slist_append(headers,hdr3); + } //headers = curl_slist_append(0,"Expect:"); + if ( headers != 0 ) + curl_easy_setopt(cHandle,CURLOPT_HTTPHEADER,headers); + //res = curl_easy_perform(cHandle); + memset(&chunk,0,sizeof(chunk)); + curl_easy_setopt(cHandle,CURLOPT_WRITEFUNCTION,WriteMemoryCallback); + curl_easy_setopt(cHandle,CURLOPT_WRITEDATA,(void *)&chunk); + curl_easy_perform(cHandle); + curl_easy_getinfo(cHandle,CURLINFO_RESPONSE_CODE,&code); + if ( headers != 0 ) + curl_slist_free_all(headers); + if ( code != 200 ) + printf("(%s) server responded with code %ld (%s)\n",url,code,chunk.memory); + return(chunk.memory); +} + +uint16_t _komodo_userpass(char *username, char *password, FILE *fp) +{ + char *rpcuser,*rpcpassword,*str,*ipaddress,line[8192]; uint16_t port = 0; + rpcuser = rpcpassword = 0; + username[0] = password[0] = 0; + while ( fgets(line,sizeof(line),fp) != 0 ) + { + if ( line[0] == '#' ) + continue; + //printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword")); + if ( (str= strstr(line,(char *)"rpcuser")) != 0 ) + rpcuser = parse_conf_line(str,(char *)"rpcuser"); + else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) + rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); + else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) + { + port = atoi(parse_conf_line(str,(char *)"rpcport")); + //fprintf(stderr,"rpcport.%u in file\n",port); + } + else if ( (str= strstr(line,(char *)"ipaddress")) != 0 ) + { + ipaddress = parse_conf_line(str,(char *)"ipaddress"); + strcpy(IPADDRESS,ipaddress); + } + } + if ( rpcuser != 0 && rpcpassword != 0 ) + { + strcpy(username,rpcuser); + strcpy(password,rpcpassword); + } + //printf("rpcuser.(%s) rpcpassword.(%s) %u ipaddress.%s\n",rpcuser,rpcpassword,port,ipaddress); + if ( rpcuser != 0 ) + free(rpcuser); + if ( rpcpassword != 0 ) + free(rpcpassword); + return(port); +} + +uint16_t komodo_userpass(char *userpass,char *symbol) +{ + FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[KOMODO_ASSETCHAIN_MAXLEN]; + userpass[0] = 0; + if ( strcmp("KMD",symbol) == 0 ) + { +#ifdef __APPLE__ + sprintf(confname,"Komodo.conf"); +#else + sprintf(confname,"komodo.conf"); +#endif + } + else sprintf(confname,"%s.conf",symbol); + //komodo_statefname(fname,symbol,confname); + if ( (fp= fopen(confname,"rb")) != 0 ) + { + port = _komodo_userpass(username,password,fp); + sprintf(userpass,"%s:%s",username,password); + if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 ) + strcpy(USERPASS,userpass); + fclose(fp); + } + return(port); +} + +#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) + +char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) +{ + //static void *cHandle; + char url[512],*retstr=0,*retstr2=0,postdata[8192]; + if ( params == 0 || params[0] == 0 ) + params = (char *)"[]"; + if ( strlen(params) < sizeof(postdata)-128 ) + { + sprintf(url,(char *)"http://%s:%u",IPADDRESS,port); + sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); + //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS); + retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); + //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); + } + return(retstr2); +} + +int32_t games_sendrawtransaction(char *rawtx) +{ + char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; + params = (char *)malloc(strlen(rawtx) + 16); + sprintf(params,"[\"%s\"]",rawtx); + if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,GAMES_PORT)) != 0 ) + { + if ( 0 ) // causes 4th level crash + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("games.sendlog","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%s\n",retstr); + fflush(fp); + } + } + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,"result")) != 0 ) + { + if ( (hexstr= jstr(resobj,0)) != 0 && is_hexstr(hexstr,64) == 64 ) + retval = 0; + } + free_json(retjson); + } + + /* log sendrawtx result in file */ + + /* + FILE *debug_file; + debug_file = fopen("tx_debug.log", "a"); + fprintf(debug_file, "%s\n", retstr); + fflush(debug_file); + fclose(debug_file); + */ + + free(retstr); + } + free(params); + return(retval); +} + +int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) +{ + char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; + if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) + { + if ( rs->keystrokeshex != 0 ) + { + if ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) + { + if ( waitflag == 0 ) + return(0); + else if ( 0 ) + { + while ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) + { + //fprintf(stderr,"pre-rebroadcast\n"); + sleep(10); + } + } + } + free(rs->keystrokeshex), rs->keystrokeshex = 0; + } + if ( 0 && (pastkeys= games_keystrokesload(&numpastkeys,seed,1)) != 0 ) + { + sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); + if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,"result")) != 0 && (keys= jstr(resobj,"keystrokes")) != 0 ) + { + len = strlen(keys) / 2; + pastcmp = (char *)malloc(len + 1); + decode_hex(pastcmp,len,keys); + fprintf(stderr,"keystrokes.(%s) vs pastkeys\n",keys); + for (i=0; i> keystrokes.log",ASSETCHAINS_SYMBOL,Gametxidstr,hexstr); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + } + else + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("keystrokes.log","a"); + sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); + if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT)) != 0 ) + { + if ( fp != 0 ) + { + fprintf(fp,"%s\n",params); + fprintf(fp,"%s\n",retstr); + fflush(fp); + } + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,"result")) != 0 && (rawtx= jstr(resobj,"hex")) != 0 ) + { + if ( rs->keystrokeshex != 0 ) + free(rs->keystrokeshex); + if ( (errstr= jstr(resobj,"error")) == 0 ) + { + rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); + strcpy(rs->keystrokeshex,rawtx); + retflag = 1; + } else fprintf(stderr,"error sending keystrokes tx\n"), sleep(1); + //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); + } + free_json(retjson); + } + free(retstr); + } + if ( 0 && waitflag != 0 && rs->keystrokeshex != 0 ) + { + while ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) + { + //fprintf(stderr,"post-rebroadcast\n"); + sleep(3); + } + free(rs->keystrokeshex), rs->keystrokeshex = 0; + } + } + } + return(retflag); +} + +int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) +{ + char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson; + if ( rs->guiflag == 0 ) + return(-1); + if ( gametxidstr == 0 || *gametxidstr == 0 ) + return(retval); + if ( 0 ) + { + sprintf(fname,"%s.gameinfo",gametxidstr); + sprintf(cmd,"./komodo-cli -ac_name=%s cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",ASSETCHAINS_SYMBOL,gametxidstr,fname); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + else filestr = (char *)OS_fileptr(&allocsize,fname); + } + else + { + sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); + filestr = komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT); + } + if ( filestr != 0 ) + { + if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,"result")) != 0 ) + { + //fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); + if ( (array= jarray(&n,resultjson,"players")) != 0 ) + { + for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); + fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0)); + rs->restoring = 1; + } + } + } + } + } + free_json(retjson); + } + free(filestr); + } + return(retval); +} + +#ifdef _WIN32 +#ifdef _MSC_VER +__inline int msver(void) { + switch (_MSC_VER) { + case 1500: return 2008; + case 1600: return 2010; + case 1700: return 2012; + case 1800: return 2013; + case 1900: return 2015; + //case 1910: return 2017; + default: return (_MSC_VER / 100); + } +} + +static inline bool is_x64(void) { +#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) + return 1; +#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64) + return 1; +#else + return 0; +#endif +} + +#define BUILD_DATE __DATE__ " " __TIME__ +#endif // _WIN32 +#endif // _MSC_VER + +int main(int argc, char **argv) +{ + uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; + +#ifdef _WIN32 +#ifdef _MSC_VER + printf("*** games for Windows [ Build %s ] ***\n", BUILD_DATE); + const char* arch = is_x64() ? "64-bits" : "32-bits"; + printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch); +#endif +#endif + + for (i=j=0; argv[0][i]!=0&&j= 2) { @@ -2531,5 +3521,6 @@ int main(int argc, char **argv) tg_delete(tg); return 0; } + #endif diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index cdad704ed..e3eec5d41 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -168,12 +168,15 @@ char *unctrl(char c); #define leaveok(win,bf) 0 #define halfdelay(x) 0 #define nocbreak() 0 + +// for tetris #define init_pair(a,b,c) 0 #define start_color() 0 #define box(a,b,c) 0 #define A_REVERSE 0 #define COLOR_PAIR(a) 0 #define timeout(x) 0 +// end for tetris #ifndef TRUE #define TRUE 1 From 1d57bee66d4697a550e1df72d80e03e20478201b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 08:54:27 -1100 Subject: [PATCH 3153/3904] Maketetris --- src/cc/gamescc.cpp | 4 +++- src/cc/maketetris | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 59adfae1d..454af601d 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -15,6 +15,8 @@ #include "gamescc.h" +#ifndef STANDALONE + /* ./c cclib rng 17 \"[%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,250]\" { @@ -1658,8 +1660,8 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) { sprintf(packitemstr,"not yet"); } +#else -#ifdef STANDALONE #include #include diff --git a/src/cc/maketetris b/src/cc/maketetris index 9c2a005a0..b83bef611 100755 --- a/src/cc/maketetris +++ b/src/cc/maketetris @@ -1,2 +1,2 @@ -gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE tetris.cpp -lncurses -o tetris +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE gamescc.cpp -lncurses -o tetris From 3a7ca41dab30e01631befa8ca0ff02482ca5de4f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:13:13 -1100 Subject: [PATCH 3154/3904] Realtime events --- src/cc/gamescc.cpp | 56 +++++++++++++++++++++++++++++----------------- src/cc/gamescc.h | 12 ++++++++++ 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 454af601d..33d6722cd 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -336,12 +336,34 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay } else return(-1); } +int32_t games_event(uint32_t timestamp,uint256 gametxid,int32_t eventid,std::vector payload) +{ + std::vector sig,vopret; CPubKey mypk; uint32_t x; int32_t i,len = payload.size(); + payload.resize(len + 4 + 32); + for (i=0; i<32; i++) + payload[len++] = ((uint8_t *)&gametxid)[i]; + x = eventid; + payload[len++] = x, x >>= 8; + payload[len++] = x, x >>= 8; + payload[len++] = x, x >>= 8; + payload[len++] = x; + mypk = pubkey2pk(Mypubkey()); + if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) + { + GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); + games_payloadrecv(mypk,timestamp,payload); + komodo_sendmessage(4,8,"events",vopret); + return(0); + } else return(-1); +} + UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { static uint256 lastgametxid; static uint32_t numevents; - UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t len,i,n; uint32_t x; CPubKey mypk; char str[67]; uint32_t eventid,timestamp = 0; uint256 gametxid; + UniValue result(UniValue::VOBJ); std::vector payload; int32_t len,i,n; uint32_t x; CPubKey mypk; char str[67]; uint32_t eventid,timestamp = 0; uint256 gametxid; if ( params != 0 && (n= cJSON_GetArraySize(params)) >= 1 && n <= 3 ) { + mypk = pubkey2pk(Mypubkey()); if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) { if ( n >= 2 ) @@ -359,21 +381,8 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( numevents <= eventid ) numevents = eventid+1; } else eventid = numevents++; - len = payload.size(); - payload.resize(len + 4 + 32); - for (i=0; i<32; i++) - payload[len++] = ((uint8_t *)&gametxid)[i]; - x = eventid; - payload[len++] = x, x >>= 8; - payload[len++] = x, x >>= 8; - payload[len++] = x, x >>= 8; - payload[len++] = x; - mypk = pubkey2pk(Mypubkey()); - if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) + if ( games_event(timestamp,gametxid,eventid,payload) == 0 ) { - GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); - games_payloadrecv(mypk,timestamp,payload); - komodo_sendmessage(4,8,"events",vopret); result.push_back(Pair("gametxid",gametxid.GetHex())); result.push_back(Pair("eventid",(int64_t)eventid)); result.push_back(Pair("timestamp",(int64_t)timestamp)); @@ -2587,7 +2596,7 @@ static inline bool is_x64(void) { int main(int argc, char **argv) { uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; - + strcpy(ASSETCHAINS_SYMBOL,"GTEST"); #ifdef _WIN32 #ifdef _MSC_VER printf("*** games for Windows [ Build %s ] ***\n", BUILD_DATE); @@ -2610,8 +2619,8 @@ int main(int argc, char **argv) #ifdef _WIN32 #ifdef _MSC_VER - if (strncmp(ASSETCHAINS_SYMBOL, "TETRIS.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0 || strncmp(ASSETCHAINS_SYMBOL, "TETRIS54.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0) { - strcpy(ASSETCHAINS_SYMBOL, "TETRIS"); // accept TETRIS.conf, instead of TETRIS.EXE.conf or TETRIS54.EXE.conf if build with MSVC + if (strncmp(ASSETCHAINS_SYMBOL, "GTEST.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0 || strncmp(ASSETCHAINS_SYMBOL, "GTEST54.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0) { + strcpy(ASSETCHAINS_SYMBOL, "GTEST"); // accept TETRIS.conf, instead of TETRIS.EXE.conf or TETRIS54.EXE.conf if build with MSVC } #endif #endif @@ -3432,7 +3441,7 @@ int tetris(int argc, char **argv) tetris_move move = TM_NONE; bool running = true; WINDOW *board, *next, *hold, *score; - + int32_t c; uint256 gametxid; std::vector payload; uint32_t eventid = 0; // Load file if given a filename. if (argc >= 2) { FILE *f = fopen(argv[1], "r"); @@ -3462,6 +3471,7 @@ int tetris(int argc, char **argv) score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); int32_t counter = 0; // Game loop + payload.resize(1); while (running) { running = tg_tick(tg, move); display_board(board, tg); @@ -3471,8 +3481,12 @@ int tetris(int argc, char **argv) if ( (counter++ % 5) == 0 ) doupdate(); sleep_milli(10); - - switch (getch()) { + c = getch(); + payload[0] = c; + games_event(0,gametxid,eventid,payload); + eventid++; + switch ( c ) + { case KEY_LEFT: move = TM_LEFT; break; diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 8a6a3b656..9a48a14a4 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -96,6 +96,18 @@ struct games_player struct games_packitem gamespack[MAXPACK]; }; +struct games_state +{ + uint64_t seed; + char *keystrokes,*keystrokeshex; + uint32_t needflush,replaydone; + int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; + FILE *logfp; + struct games_player P; + char buffered[10000]; + uint8_t playerdata[10000]; +}; + int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); void games_packitemstr(char *packitemstr,struct games_packitem *item); From dfd756b938f96f3153d39099010bfd674fcd9a4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:23:42 -1100 Subject: [PATCH 3155/3904] issue_games_events --- src/cc/gamescc.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 33d6722cd..c73b0e46f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2360,6 +2360,32 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } +int32_t issue_games_events(uint256 gametxid,uint32_t eventid,char c) +{ + char params[512],*retstr; cJSON *retjson,*retobj; int32_t retval = -1; + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,gametxid.GetHex().c_str(),eventid); + if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,"result")) != 0 ) + { + retval = 0; + if ( fp == 0 ) + fp = fopen("events.log","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } + } + free_json(retjson); + } + free(retstr); + } + return(retval); +} + int32_t games_sendrawtransaction(char *rawtx) { char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; @@ -3483,7 +3509,7 @@ int tetris(int argc, char **argv) sleep_milli(10); c = getch(); payload[0] = c; - games_event(0,gametxid,eventid,payload); + issue_games_events(0,gametxid,eventid,payload); eventid++; switch ( c ) { From 3ee77bc360950fe63170783c3d59403b108692f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:26:42 -1100 Subject: [PATCH 3156/3904] Test --- src/cc/gamescc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index c73b0e46f..6ea6981c1 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2362,7 +2362,10 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t issue_games_events(uint256 gametxid,uint32_t eventid,char c) { + static FILE *fp; char params[512],*retstr; cJSON *retjson,*retobj; int32_t retval = -1; + if ( fp == 0 ) + fp = fopen("events.log","wb"); sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,gametxid.GetHex().c_str(),eventid); if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT)) != 0 ) { @@ -2371,8 +2374,6 @@ int32_t issue_games_events(uint256 gametxid,uint32_t eventid,char c) if ( (resobj= jobj(retjson,"result")) != 0 ) { retval = 0; - if ( fp == 0 ) - fp = fopen("events.log","wb"); if ( fp != 0 ) { fprintf(fp,"%s\n",jprint(resobj,0)); @@ -2380,9 +2381,9 @@ int32_t issue_games_events(uint256 gametxid,uint32_t eventid,char c) } } free_json(retjson); - } + } else fprintf(fp,"error parsing %s\n",jprint(retstr)); free(retstr); - } + } else fprintf(fp,"error issuing method %s\n",params); return(retval); } From 11b4733cb7e2c06e86764022cc730d76da1c4192 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:38:26 -1100 Subject: [PATCH 3157/3904] (char *) --- src/cc/gamescc.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 6ea6981c1..826012f43 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2363,15 +2363,15 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t issue_games_events(uint256 gametxid,uint32_t eventid,char c) { static FILE *fp; - char params[512],*retstr; cJSON *retjson,*retobj; int32_t retval = -1; + char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; if ( fp == 0 ) fp = fopen("events.log","wb"); sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,gametxid.GetHex().c_str(),eventid); - if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT)) != 0 ) + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (resobj= jobj(retjson,"result")) != 0 ) + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) { retval = 0; if ( fp != 0 ) @@ -2381,7 +2381,7 @@ int32_t issue_games_events(uint256 gametxid,uint32_t eventid,char c) } } free_json(retjson); - } else fprintf(fp,"error parsing %s\n",jprint(retstr)); + } else fprintf(fp,"error parsing %s\n",retstr); free(retstr); } else fprintf(fp,"error issuing method %s\n",params); return(retval); @@ -2392,7 +2392,7 @@ int32_t games_sendrawtransaction(char *rawtx) char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); - if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,GAMES_PORT)) != 0 ) + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"sendrawtransaction",params,GAMES_PORT)) != 0 ) { if ( 0 ) // causes 4th level crash { @@ -2407,7 +2407,7 @@ int32_t games_sendrawtransaction(char *rawtx) } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (resobj= jobj(retjson,"result")) != 0 ) + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) { if ( (hexstr= jstr(resobj,0)) != 0 && is_hexstr(hexstr,64) == 64 ) retval = 0; @@ -2460,7 +2460,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,cha { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (resobj= jobj(retjson,"result")) != 0 && (keys= jstr(resobj,"keystrokes")) != 0 ) + if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (keys= jstr(resobj,(char *)"keystrokes")) != 0 ) { len = strlen(keys) / 2; pastcmp = (char *)malloc(len + 1); @@ -2508,11 +2508,11 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,cha } if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (resobj= jobj(retjson,"result")) != 0 && (rawtx= jstr(resobj,"hex")) != 0 ) + if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (rawtx= jstr(resobj,(char *)"hex")) != 0 ) { if ( rs->keystrokeshex != 0 ) free(rs->keystrokeshex); - if ( (errstr= jstr(resobj,"error")) == 0 ) + if ( (errstr= jstr(resobj,(char *)"error")) == 0 ) { rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); strcpy(rs->keystrokeshex,rawtx); @@ -2556,26 +2556,26 @@ int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) else { sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); - filestr = komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT); + filestr = komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT); } if ( filestr != 0 ) { - if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,"result")) != 0 ) + if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,(char *)"result")) != 0 ) { //fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); - if ( (array= jarray(&n,resultjson,"players")) != 0 ) + if ( (array= jarray(&n,resultjson,(char *)"players")) != 0 ) { for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0)); From 5f2317bd8e368933c94665ebff2dac682a6ff8eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:42:42 -1100 Subject: [PATCH 3158/3904] fixes --- src/cc/gamescc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 826012f43..5217d5fa1 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1684,6 +1684,9 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; +#define MAX_STR 1024 +char whoami[MAXSTR]; + #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) #define dstr(x) ((double)(x) / SATOSHIDEN) @@ -2433,7 +2436,7 @@ int32_t games_sendrawtransaction(char *rawtx) int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; + char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; uint8_t *pastcmp; if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { if ( rs->keystrokeshex != 0 ) @@ -2456,7 +2459,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,cha if ( 0 && (pastkeys= games_keystrokesload(&numpastkeys,seed,1)) != 0 ) { sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); - if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT)) != 0 ) + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { @@ -2498,7 +2501,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,cha if ( fp == 0 ) fp = fopen("keystrokes.log","a"); sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); - if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,GAMES_PORT)) != 0 ) + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( fp != 0 ) { @@ -3510,7 +3513,7 @@ int tetris(int argc, char **argv) sleep_milli(10); c = getch(); payload[0] = c; - issue_games_events(0,gametxid,eventid,payload); + issue_games_events(gametxid,eventid,payload); eventid++; switch ( c ) { From 89f6370c5e66aea81ec14fb7e55c64e0e02c9af0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:44:58 -1100 Subject: [PATCH 3159/3904] Test --- src/cc/gamescc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 5217d5fa1..2f68fdfd8 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -13,10 +13,11 @@ * * ******************************************************************************/ -#include "gamescc.h" #ifndef STANDALONE +#include "gamescc.h" + /* ./c cclib rng 17 \"[%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,250]\" { @@ -1684,7 +1685,7 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; -#define MAX_STR 1024 +#define MAXSTR 1024 char whoami[MAXSTR]; #define SMALLVAL 0.000000000000001 @@ -2466,7 +2467,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,cha if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (keys= jstr(resobj,(char *)"keystrokes")) != 0 ) { len = strlen(keys) / 2; - pastcmp = (char *)malloc(len + 1); + pastcmp = (uint8_t *)malloc(len + 1); decode_hex(pastcmp,len,keys); fprintf(stderr,"keystrokes.(%s) vs pastkeys\n",keys); for (i=0; i Date: Mon, 25 Mar 2019 09:47:58 -1100 Subject: [PATCH 3160/3904] #include "../core_io.h" #include "../script/sign.h" #include "../wallet/wallet.h" #include --- src/cc/gamescc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2f68fdfd8..de08b8992 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1681,6 +1681,9 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include #include +#include "../core_io.h" +#include "../wallet/wallet.h" +#include char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; From 43b96f15b9ed811c94433b246dde54e0f2526d66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:52:12 -1100 Subject: [PATCH 3161/3904] Ifdef --- src/cc/gamescc.cpp | 3 ++- src/cc/gamescc.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index de08b8992..0721e88fe 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -13,10 +13,11 @@ * * ******************************************************************************/ +#include "gamescc.h" + #ifndef STANDALONE -#include "gamescc.h" /* ./c cclib rng 17 \"[%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,250]\" diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 9a48a14a4..b6b53e82e 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -1,6 +1,8 @@ #ifndef H_GAMESCC_H #define H_GAMESCC_H +#ifndef STANDALONE + #define ENABLE_WALLET extern CWallet* pwalletMain; @@ -82,6 +84,7 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(result); \ } \ } +#endif #define MAXPACK 23 struct games_packitem From d4d7d1adfdb6ab8cfab9f2e6a8129ff6fd9893f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:53:19 -1100 Subject: [PATCH 3162/3904] Stdio --- src/cc/gamescc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index b6b53e82e..034fee044 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -1,6 +1,9 @@ #ifndef H_GAMESCC_H #define H_GAMESCC_H +#include +#include + #ifndef STANDALONE #define ENABLE_WALLET From e774c89ab5c37ec3329dcc359cb6d1bc2a8cfd6f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:55:11 -1100 Subject: [PATCH 3163/3904] -stdlib --- src/cc/gamescc.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 0721e88fe..57ff21131 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1676,7 +1676,6 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include -#include #include #include #include From e7031c29640864a0e8d109bb3a3c1593c09b25d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:58:21 -1100 Subject: [PATCH 3164/3904] Test --- src/cc/gamescc.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 57ff21131..ffb92bc0d 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1679,12 +1679,15 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include #include -#include -#include #include "../core_io.h" #include "../wallet/wallet.h" #include +#define inline +#include +#include +#undef inline + char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; @@ -3475,7 +3478,7 @@ int tetris(int argc, char **argv) tetris_move move = TM_NONE; bool running = true; WINDOW *board, *next, *hold, *score; - int32_t c; uint256 gametxid; std::vector payload; uint32_t eventid = 0; + int32_t c; uint256 gametxid; uint32_t eventid = 0; // Load file if given a filename. if (argc >= 2) { FILE *f = fopen(argv[1], "r"); @@ -3516,8 +3519,7 @@ int tetris(int argc, char **argv) doupdate(); sleep_milli(10); c = getch(); - payload[0] = c; - issue_games_events(gametxid,eventid,payload); + issue_games_events(gametxid,eventid,c); eventid++; switch ( c ) { From 23cd6f2cbef1aab8af7b2606358085dddfbecb4f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 09:58:56 -1100 Subject: [PATCH 3165/3904] Mv --- src/cc/gamescc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ffb92bc0d..cc78ee5fe 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1679,13 +1679,13 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include #include -#include "../core_io.h" -#include "../wallet/wallet.h" -#include #define inline #include #include +#include "../core_io.h" +#include "../wallet/wallet.h" +#include #undef inline char USERPASS[8192]; uint16_t GAMES_PORT; From 901bc3fc952d0a3311a275fcabda8413372c5814 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:00:52 -1100 Subject: [PATCH 3166/3904] Test --- src/cc/gamescc.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index cc78ee5fe..9ec9f3cb0 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1679,14 +1679,8 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include #include - -#define inline #include #include -#include "../core_io.h" -#include "../wallet/wallet.h" -#include -#undef inline char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; From 6bce1c76135f585f3b9bf8e9b6443d411a960e61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:03:02 -1100 Subject: [PATCH 3167/3904] Test --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 9ec9f3cb0..229e7d066 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2364,7 +2364,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } -int32_t issue_games_events(uint256 gametxid,uint32_t eventid,char c) +int32_t issue_games_events(bits256 gametxid,uint32_t eventid,char c) { static FILE *fp; char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; @@ -3472,7 +3472,7 @@ int tetris(int argc, char **argv) tetris_move move = TM_NONE; bool running = true; WINDOW *board, *next, *hold, *score; - int32_t c; uint256 gametxid; uint32_t eventid = 0; + int32_t c; bits256 gametxid; uint32_t eventid = 0; // Load file if given a filename. if (argc >= 2) { FILE *f = fopen(argv[1], "r"); From 28f2d009b96e387c49f90e81c5ba98213e655c21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:06:05 -1100 Subject: [PATCH 3168/3904] Void *malloc --- src/cc/gamescc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 229e7d066..1c5818568 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1682,6 +1682,8 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include +void *malloc(size_t size); + char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; @@ -2367,10 +2369,10 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t issue_games_events(bits256 gametxid,uint32_t eventid,char c) { static FILE *fp; - char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; + char params[512],*retstr,str[65]; cJSON *retjson,*resobj; int32_t retval = -1; if ( fp == 0 ) fp = fopen("events.log","wb"); - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,gametxid.GetHex().c_str(),eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,bits256_str(str,gametxid),eventid); if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) @@ -3502,7 +3504,6 @@ int tetris(int argc, char **argv) score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); int32_t counter = 0; // Game loop - payload.resize(1); while (running) { running = tg_tick(tg, move); display_board(board, tg); From a19b854238731b7373f73ad728b7c620031774e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:09:35 -1100 Subject: [PATCH 3169/3904] -def --- src/cc/gamescc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 1c5818568..81bd3f48b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1682,8 +1682,6 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include #include -void *malloc(size_t size); - char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; From 09589bd0e04aa334290418317447a73715531829 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:11:31 -1100 Subject: [PATCH 3170/3904] Test --- src/cc/gamescc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 81bd3f48b..34d0740c4 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1861,7 +1861,7 @@ long _stripwhite(char *buf,int accept) char *clonestr(char *str) { - char *clone; + char *clone; int32_t len; if ( str == 0 || str[0] == 0 ) { printf("warning cloning nullstr.%p\n",str); @@ -1870,7 +1870,8 @@ char *clonestr(char *str) #endif str = (char *)""; } - clone = (char *)malloc(strlen(str)+16); + len = strlen(str); + clone = (char *)malloc(len+16); strcpy(clone,str); return(clone); } From ce31112c570f45661be5a1586baf434844aad59b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:12:09 -1100 Subject: [PATCH 3171/3904] Calloc --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 34d0740c4..4d461ee08 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1871,7 +1871,7 @@ char *clonestr(char *str) str = (char *)""; } len = strlen(str); - clone = (char *)malloc(len+16); + clone = (char *)calloc(1,len+16); strcpy(clone,str); return(clone); } From f83da7830241f3c22878b8a279be2fa1971f6ea9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:14:14 -1100 Subject: [PATCH 3172/3904] char *clonestr(char *str) --- src/cc/gamescc.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 4d461ee08..cd87e9995 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1684,6 +1684,7 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) char USERPASS[8192]; uint16_t GAMES_PORT; extern char Gametxidstr[67]; +char *clonestr(char *str); #define MAXSTR 1024 char whoami[MAXSTR]; @@ -1859,23 +1860,6 @@ long _stripwhite(char *buf,int accept) return(j); } -char *clonestr(char *str) -{ - char *clone; int32_t len; - if ( str == 0 || str[0] == 0 ) - { - printf("warning cloning nullstr.%p\n",str); -#ifdef __APPLE__ - while ( 1 ) sleep(1); -#endif - str = (char *)""; - } - len = strlen(str); - clone = (char *)calloc(1,len+16); - strcpy(clone,str); - return(clone); -} - char *parse_conf_line(char *line,char *field) { line += strlen(field); @@ -2722,6 +2706,22 @@ int main(int argc, char **argv) #include #endif +char *clonestr(char *str) +{ + char *clone; int32_t len; + if ( str == 0 || str[0] == 0 ) + { + printf("warning cloning nullstr.%p\n",str); +#ifdef __APPLE__ + while ( 1 ) sleep(1); +#endif + str = (char *)""; + } + len = strlen(str); + clone = (char *)calloc(1,len+16); + strcpy(clone,str); + return(clone); +} /* Convert a tetromino type to its corresponding cell. From 8665d036e6abc1718c145ee02a7508b06193d0ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:15:27 -1100 Subject: [PATCH 3173/3904] char *clonestr(char *str) --- src/cc/gamescc.cpp | 2 +- src/cc/maketetris | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index cd87e9995..fa36e8537 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1683,7 +1683,7 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) #include char USERPASS[8192]; uint16_t GAMES_PORT; -extern char Gametxidstr[67]; +char Gametxidstr[67]; char *clonestr(char *str); #define MAXSTR 1024 diff --git a/src/cc/maketetris b/src/cc/maketetris index b83bef611..9f0af354e 100755 --- a/src/cc/maketetris +++ b/src/cc/maketetris @@ -1,2 +1,2 @@ -gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE gamescc.cpp -lncurses -o tetris +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE gamescc.cpp -lncurses -lcurl -o tetris From be9c3500ac7c7d8170c908580f8bf97c12f2faff Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:17:38 -1100 Subject: [PATCH 3174/3904] Games replay --- src/cc/gamescc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index fa36e8537..9fb135dfe 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -3568,5 +3568,10 @@ int tetris(int argc, char **argv) return 0; } +int32_t games_replay(uint64_t seed,int32_t sleeptime) +{ + return(-1); +} + #endif From 361c928fc835fa1bfca5124ca28f946f40092fc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:20:53 -1100 Subject: [PATCH 3175/3904] Move clonestr --- src/cc/gamescc.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 9fb135dfe..ca9419d83 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2706,23 +2706,6 @@ int main(int argc, char **argv) #include #endif -char *clonestr(char *str) -{ - char *clone; int32_t len; - if ( str == 0 || str[0] == 0 ) - { - printf("warning cloning nullstr.%p\n",str); -#ifdef __APPLE__ - while ( 1 ) sleep(1); -#endif - str = (char *)""; - } - len = strlen(str); - clone = (char *)calloc(1,len+16); - strcpy(clone,str); - return(clone); -} - /* Convert a tetromino type to its corresponding cell. */ @@ -3466,6 +3449,22 @@ void init_colors(void) Main tetris game! */ #ifdef STANDALONE +char *clonestr(char *str) +{ + char *clone; int32_t len; + if ( str == 0 || str[0] == 0 ) + { + printf("warning cloning nullstr.%p\n",str); +#ifdef __APPLE__ + while ( 1 ) sleep(1); +#endif + str = (char *)""; + } + len = strlen(str); + clone = (char *)calloc(1,len+16); + strcpy(clone,str); + return(clone); +} int tetris(int argc, char **argv) { From 63ebb9d604ed36af16de650e183a14ba03e35ad0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:25:44 -1100 Subject: [PATCH 3176/3904] strcpy(ASSETCHAINS_SYMBOL,"GTEST"); --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ca9419d83..85f01ba43 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -2612,7 +2612,6 @@ static inline bool is_x64(void) { int main(int argc, char **argv) { uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; - strcpy(ASSETCHAINS_SYMBOL,"GTEST"); #ifdef _WIN32 #ifdef _MSC_VER printf("*** games for Windows [ Build %s ] ***\n", BUILD_DATE); @@ -2640,7 +2639,8 @@ int main(int argc, char **argv) } #endif #endif - + strcpy(ASSETCHAINS_SYMBOL,"GTEST"); + GAMES_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL); if ( IPADDRESS[0] == 0 ) strcpy(IPADDRESS,"127.0.0.1"); From ab954658167edf41a0233fd0ac0cc3cadde87ddd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:45:04 -1100 Subject: [PATCH 3177/3904] Test --- src/cc/gamescc.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 85f01ba43..c80c4e161 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -387,6 +387,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("gametxid",gametxid.GetHex())); result.push_back(Pair("eventid",(int64_t)eventid)); + result.push_back(Pair("payload",jstr(jitem(params,0),0))); result.push_back(Pair("timestamp",(int64_t)timestamp)); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); @@ -436,9 +437,9 @@ void komodo_netevent(std::vector message) } } } - for (i=0; i= 2) { FILE *f = fopen(argv[1], "r"); From 2a4a05055748694b8b49d1d44d72610bc6233ed2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 10:49:02 -1100 Subject: [PATCH 3178/3904] Test --- src/cc/gamescc.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index c80c4e161..7f7b15c89 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -51,6 +51,24 @@ ./c cclib events 17 \"[%226d%22,%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,1]\" */ +int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) +{ + uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; + if ( (len= payload.size()) > 36 ) + { + len -= 36; + for (i=0; i<32; i++) + ((uint8_t *)&gametxid)[i] = payload[len+i]; + eventid = (uint32_t)payload[len+32]; + eventid |= (uint32_t)payload[len+33] << 8; + eventid |= (uint32_t)payload[len+34] << 16; + eventid |= (uint32_t)payload[len+35] << 24; + for (i=0; i &sig,std::vecto } else return(-1); } -int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) -{ - uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; - if ( (len= payload.size()) > 36 ) - { - len -= 36; - for (i=0; i<32; i++) - ((uint8_t *)&gametxid)[i] = payload[len+i]; - eventid = (uint32_t)payload[len+32]; - eventid |= (uint32_t)payload[len+33] << 8; - eventid |= (uint32_t)payload[len+34] << 16; - eventid |= (uint32_t)payload[len+35] << 24; - for (i=0; i payload) { std::vector sig,vopret; CPubKey mypk; uint32_t x; int32_t i,len = payload.size(); @@ -3514,7 +3513,8 @@ int tetris(int argc, char **argv) doupdate(); sleep_milli(10); c = getch(); - issue_games_events(gametxid,eventid,c); + if ( c >= 0 ) + issue_games_events(gametxid,eventid,c); eventid++; switch ( c ) { From 9277db7e1e0beef080feb6f753e79724c36899d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 11:11:24 -1100 Subject: [PATCH 3179/3904] Skip count --- src/cc/gamescc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 7f7b15c89..b355584db 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -3472,7 +3472,7 @@ int tetris(int argc, char **argv) tetris_move move = TM_NONE; bool running = true; WINDOW *board, *next, *hold, *score; - int32_t c; bits256 gametxid; uint32_t eventid = 0; + int32_t c,skipcount=0; bits256 gametxid; uint32_t eventid = 0; memset(&gametxid,0,sizeof(gametxid)); // Load file if given a filename. if (argc >= 2) { @@ -3514,7 +3514,12 @@ int tetris(int argc, char **argv) sleep_milli(10); c = getch(); if ( c >= 0 ) + { + if ( skipcount > 0 ) + issue_games_events(gametxid,eventid-skipcount,skipcount | 0x4000); issue_games_events(gametxid,eventid,c); + skipcount = 0; + } else skipcount++; eventid++; switch ( c ) { From 81006ce271fc91f09abe725c580ea8d1acc030f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 11:50:08 -1100 Subject: [PATCH 3180/3904] Match rogue roc --- src/cc/gamescc.cpp | 6 +++--- src/cc/gamescc.h | 37 ++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b355584db..758d2fc78 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -964,7 +964,7 @@ void games_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet } else fprintf(stderr,"findbaton err.%d\n",retval); } -UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey gamespk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1; @@ -1030,7 +1030,7 @@ UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myaddr[64],str[64]; CPubKey mypk,gamespk; result.push_back(Pair("name","games")); @@ -1599,7 +1599,7 @@ UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue games_list(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey gamespk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; std::vector > addressIndex; diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 034fee044..19e5f8d26 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -35,29 +35,28 @@ std::string Games_pname; { (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"players", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"list", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"games", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"pending", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"setname", (char *)"pname", 1, 1, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"create", (char *)"maxplayers,buyin", 2, 2, 'C', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"newgame", (char *)"maxplayers,buyin", 2, 2, 'C', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"playerinfo", (char *)"playertxid", 1, 1, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"info", (char *)"gametxid", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"gameinfo", (char *)"gametxid", 1, 1, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"keystrokes", (char *)"txid,hexstr", 2, 2, 'K', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"finish", (char *)"gametxid", 1, 1, 'Q', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"events", (char *)"eventshex [gametxid [eventid]]", 1, 3, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_GAMES }, - bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue games_list(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); @@ -71,14 +70,30 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_rng(txfee,cp,params)); \ else if ( strcmp(method,"rngnext") == 0 ) \ return(games_rngnext(txfee,cp,params)); \ - else if ( strcmp(method,"create") == 0 ) \ - return(games_create(txfee,cp,params)); \ - else if ( strcmp(method,"info") == 0 ) \ - return(games_info(txfee,cp,params)); \ + else if ( strcmp(method,"newgame") == 0 ) \ + return(games_newgame(txfee,cp,params)); \ + else if ( strcmp(method,"gameinfo") == 0 ) \ + return(games_gameinfo(txfee,cp,params)); \ else if ( strcmp(method,"register") == 0 ) \ return(games_register(txfee,cp,params)); \ else if ( strcmp(method,"events") == 0 ) \ return(games_events(txfee,cp,params)); \ + else if ( strcmp(method,"players") == 0 ) \ + return(games_players(txfee,cp,params)); \ + else if ( strcmp(method,"games") == 0 ) \ + return(games_games(txfee,cp,params)); \ + else if ( strcmp(method,"pending") == 0 ) \ + return(games_pending(txfee,cp,params)); \ + else if ( strcmp(method,"setname") == 0 ) \ + return(games_setname(txfee,cp,params)); \ + else if ( strcmp(method,"playerinfo") == 0 ) \ + return(games_playerinfo(txfee,cp,params)); \ + else if ( strcmp(method,"keystrokes") == 0 ) \ + return(games_keystrokes(txfee,cp,params)); \ + else if ( strcmp(method,"extract") == 0 ) \ + return(games_extract(txfee,cp,params)); \ + else if ( strcmp(method,"finish") == 0 ) \ + return(games_finish(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From c7ac37f03a713fbbbf61cff73eda72be8127174a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Mar 2019 14:23:35 +0800 Subject: [PATCH 3181/3904] add check for transaction fee --- src/cc/rewards.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 1351bbaeb..65e32ee27 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -197,6 +197,9 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t uint256 txid,fundingtxid,hashBlock,vinfundingtxid; uint64_t vinsbits,sbits,APR,minseconds,maxseconds,mindeposit,amount,reward,txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; uint8_t funcid; CScript scriptPubKey; CTransaction fundingTx,vinTx; numvins = tx.vin.size(); numvouts = tx.vout.size(); + int64_t interest; uint64_t valuein; + CCoinsViewCache &view = *pcoinsTip; + valuein = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime); preventCCvins = preventCCvouts = -1; if ( numvouts < 1 ) return eval->Invalid("no vouts"); @@ -255,6 +258,11 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t if ( (*cp->ismyvin)(tx.vin[i].scriptSig) == 0 ) return eval->Invalid("unexpected normal vin for unlock"); } + if ( valuein-tx.GetValueOut() > txfee ) + { + fprintf(stderr, "valueout.%li vs valuein.%li txfee.%li\n", tx.GetValueOut(), valuein, txfee); + return eval->Invalid("alright is stealing your money"); + } if ( numvouts == 2 && numvins == 1 ) { if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -707,4 +715,3 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2 fprintf(stderr,"amount %.8f -> reward %.8f\n",(double)amount/COIN,(double)reward/COIN); return(""); } - From d08fedb7a43ac4740f8d29d7e93a2df181e17b6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 22:12:33 -1100 Subject: [PATCH 3182/3904] if ( komodo_nextheight() > 77777 && cashout > ROGUE_MAXCASHOUT ) --- src/cc/gamescc.cpp | 5 +++-- src/cc/rogue_rpc.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 758d2fc78..38e28a416 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -3513,11 +3513,12 @@ int tetris(int argc, char **argv) doupdate(); sleep_milli(10); c = getch(); - if ( c >= 0 ) + if ( c != -1 || skipcount == 0x3fff ) { if ( skipcount > 0 ) issue_games_events(gametxid,eventid-skipcount,skipcount | 0x4000); - issue_games_events(gametxid,eventid,c); + if ( c != -1 ) + issue_games_events(gametxid,eventid,c); skipcount = 0; } else skipcount++; eventid++; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index fbb1a3d93..ee5f3d566 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -22,6 +22,7 @@ #define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 +#define ROGUE_MAXCASHOUT (777 * COIN) #include "rogue/rogue_player.h" @@ -1112,6 +1113,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C dungeonlevel = P.dungeonlevel; if ( P.amulet != 0 && dungeonlevel < 26 ) dungeonlevel = 26; + if ( dungeonlevel > 42 ) + dungeonlevel = 42; *cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel; if ( newdata == playerdata ) { @@ -1281,6 +1284,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } if ( cashout > 0 ) { + if ( komodo_nextheight() > 77777 && cashout > ROGUE_MAXCASHOUT ) + cashout = ROGUE_MAXCASHOUT; if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr)) > cashout ) CCchange = (inputsum - cashout); else fprintf(stderr,"couldnt find enough utxos\n"); @@ -1598,6 +1603,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C cashout *= 2; //cashout += numplayers * buyin; } + if ( height > 777777 && cashout > ROGUE_MAXCASHOUT ) + cashout = ROGUE_MAXCASHOUT; sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { From fa0a35aa5a2dac695e4452587f5c9b18e5943be0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:11:36 -1100 Subject: [PATCH 3183/3904] Split out Tetris --- src/cc/dapps/dappstd.c | 1020 +++++++++++++++++ src/cc/gamescc.cpp | 2048 +--------------------------------- src/cc/gamescc.h | 32 +- src/cc/tetris.c | 758 +++++++++++++ src/cc/tetris.cpp | 2376 +--------------------------------------- src/cc/tetris.h | 197 ++++ 6 files changed, 2046 insertions(+), 4385 deletions(-) create mode 100644 src/cc/dapps/dappstd.c create mode 100644 src/cc/tetris.c create mode 100644 src/cc/tetris.h diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c new file mode 100644 index 000000000..ec8045b2f --- /dev/null +++ b/src/cc/dapps/dappstd.c @@ -0,0 +1,1020 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +// requires CHAINNAME and GAMEMAIN() to be #defined + +#include +#include +#include +#include +#include +#include +#include + +char USERPASS[8192]; uint16_t GAMES_PORT; +char Gametxidstr[67]; +char *clonestr(char *str); + +#define MAXSTR 1024 +char whoami[MAXSTR]; + +#define SMALLVAL 0.000000000000001 +#define SATOSHIDEN ((uint64_t)100000000L) +#define dstr(x) ((double)(x) / SATOSHIDEN) +#define KOMODO_ASSETCHAIN_MAXLEN 65 +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],IPADDRESS[100]; + +#ifndef _BITS256 +#define _BITS256 +union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; +typedef union _bits256 bits256; +#endif + +#ifdef _WIN32 +#ifdef _MSC_VER +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = ((uint64_t)file_time.dwLowDateTime); + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); + return 0; +} +#endif // _MSC_VER +#endif + +double OS_milliseconds() +{ + struct timeval tv; double millis; +#ifdef __MINGW32__ + mingw_gettimeofday(&tv,NULL); +#else + gettimeofday(&tv,NULL); +#endif + millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.); + //printf("tv_sec.%ld usec.%d %f\n",tv.tv_sec,tv.tv_usec,millis); + return(millis); +} + +int32_t _unhex(char c) +{ + if ( c >= '0' && c <= '9' ) + return(c - '0'); + else if ( c >= 'a' && c <= 'f' ) + return(c - 'a' + 10); + else if ( c >= 'A' && c <= 'F' ) + return(c - 'A' + 10); + return(-1); +} + +int32_t is_hexstr(char *str,int32_t n) +{ + int32_t i; + if ( str == 0 || str[0] == 0 ) + return(0); + for (i=0; str[i]!=0; i++) + { + if ( n > 0 && i >= n ) + break; + if ( _unhex(str[i]) < 0 ) + break; + } + if ( n == 0 ) + return(i); + return(i == n); +} + +int32_t unhex(char c) +{ + int32_t hex; + if ( (hex= _unhex(c)) < 0 ) + { + //printf("unhex: illegal hexchar.(%c)\n",c); + } + return(hex); +} + +unsigned char _decode_hex(char *hex) { return((unhex(hex[0])<<4) | unhex(hex[1])); } + +int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) +{ + int32_t adjust,i = 0; + //printf("decode.(%s)\n",hex); + if ( is_hexstr(hex,n) <= 0 ) + { + memset(bytes,0,n); + return(n); + } + if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) + hex[--n] = 0; + if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) ) + { + if ( n > 0 ) + { + bytes[0] = unhex(hex[0]); + printf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex)); + } + bytes++; + hex++; + adjust = 1; + } else adjust = 0; + if ( n > 0 ) + { + for (i=0; i>4) & 0xf); + hexbytes[i*2 + 1] = hexbyte(message[i] & 0xf); + //printf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]); + } + hexbytes[len*2] = 0; + //printf("len.%ld\n",len*2+1); + return((int32_t)len*2+1); +} + +char *bits256_str(char hexstr[65],bits256 x) +{ + init_hexbytes_noT(hexstr,x.bytes,sizeof(x)); + return(hexstr); +} + +long _stripwhite(char *buf,int accept) +{ + int32_t i,j,c; + if ( buf == 0 || buf[0] == 0 ) + return(0); + for (i=j=0; buf[i]!=0; i++) + { + buf[j] = c = buf[i]; + if ( c == accept || (c != ' ' && c != '\n' && c != '\r' && c != '\t' && c != '\b') ) + j++; + } + buf[j] = 0; + return(j); +} + +char *parse_conf_line(char *line,char *field) +{ + line += strlen(field); + for (; *line!='='&&*line!=0; line++) + break; + if ( *line == 0 ) + return(0); + if ( *line == '=' ) + line++; + while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' ) + line[strlen(line)-1] = 0; + //printf("LINE.(%s)\n",line); + _stripwhite(line,0); + return(clonestr(line)); +} + +int32_t safecopy(char *dest,char *src,long len) +{ + int32_t i = -1; + if ( src != 0 && dest != 0 && src != dest ) + { + if ( dest != 0 ) + memset(dest,0,len); + for (i=0; i buflen ) + { + *allocsizep = filesize; + *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); + } + rewind(fp); + if ( buf == 0 ) + printf("Null buf ???\n"); + else + { + if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) + printf("error reading filesize.%ld\n",(long)filesize); + buf[filesize] = 0; + } + fclose(fp); + *lenp = filesize; + //printf("loaded.(%s)\n",buf); + } //else printf("OS_loadfile couldnt load.(%s)\n",fname); + return(buf); +} + +uint8_t *OS_fileptr(long *allocsizep,char *fname) +{ + long filesize = 0; uint8_t *buf = 0; void *retptr; + *allocsizep = 0; + retptr = OS_loadfile(fname,&buf,&filesize,allocsizep); + return((uint8_t *)retptr); +} + +struct MemoryStruct { char *memory; size_t size; }; +struct return_string { char *ptr; size_t len; }; + +// return data from the server +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_SSL (1<<0) +#define CURL_GLOBAL_WIN32 (1<<1) + + +/************************************************************************ + * + * Initialize the string handler so that it is thread safe + * + ************************************************************************/ + +void init_string(struct return_string *s) +{ + s->len = 0; + s->ptr = (char *)calloc(1,s->len+1); + if ( s->ptr == NULL ) + { + fprintf(stderr,"init_string malloc() failed\n"); + exit(-1); + } + s->ptr[0] = '\0'; +} + +/************************************************************************ + * + * Use the "writer" to accumulate text until done + * + ************************************************************************/ + +size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *s) +{ + size_t new_len = s->len + size*nmemb; + s->ptr = (char *)realloc(s->ptr,new_len+1); + if ( s->ptr == NULL ) + { + fprintf(stderr, "accumulate realloc() failed\n"); + exit(-1); + } + memcpy(s->ptr+s->len,ptr,size*nmemb); + s->ptr[new_len] = '\0'; + s->len = new_len; + return(size * nmemb); +} + +/************************************************************************ + * + * return the current system time in milliseconds + * + ************************************************************************/ + +#define EXTRACT_BITCOIND_RESULT // if defined, ensures error is null and returns the "result" field +#ifdef EXTRACT_BITCOIND_RESULT + +/************************************************************************ + * + * perform post processing of the results + * + ************************************************************************/ + +char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params) +{ + long i,j,len; char *retstr = 0; cJSON *json,*result,*error; + //printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); + if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 ) + { + if ( strcmp(command,"signrawtransaction") != 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); + return(rpcstr); + } + json = cJSON_Parse(rpcstr); + if ( json == 0 ) + { + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s) params.(%s)\n",debugstr,command,rpcstr,params); + free(rpcstr); + return(0); + } + result = cJSON_GetObjectItem(json,"result"); + error = cJSON_GetObjectItem(json,"error"); + if ( error != 0 && result != 0 ) + { + if ( (error->type&0xff) == cJSON_NULL && (result->type&0xff) != cJSON_NULL ) + { + retstr = cJSON_Print(result); + len = strlen(retstr); + if ( retstr[0] == '"' && retstr[len-1] == '"' ) + { + for (i=1,j=0; itype&0xff) != cJSON_NULL || (result->type&0xff) != cJSON_NULL ) + { + if ( strcmp(command,"signrawtransaction") != 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr); + } + free(rpcstr); + } else retstr = rpcstr; + free_json(json); + //fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: postprocess returns.(%s)\n",retstr); + return(retstr); +} +#endif + +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + +/************************************************************************ + * + * perform the query + * + ************************************************************************/ + +char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params) +{ + static int didinit,count,count2; static double elapsedsum,elapsedsum2; + struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle; + char *bracket0,*bracket1,*databuf = 0; long len; int32_t specialcase,numretries; double starttime; + if ( didinit == 0 ) + { + didinit = 1; + curl_global_init(CURL_GLOBAL_ALL); //init the curl session + } + numretries = 0; + if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 ) + specialcase = 1; + else specialcase = 0; + if ( url[0] == 0 ) + strcpy(url,"http://127.0.0.1:7876/nxt"); + if ( specialcase != 0 && 0 ) + printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params); +try_again: + if ( retstrp != 0 ) + *retstrp = 0; + starttime = OS_milliseconds(); + curl_handle = curl_easy_init(); + init_string(&s); + headers = curl_slist_append(0,"Expect:"); + + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl_handle,CURLOPT_URL, url); + curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function + curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback + curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash + curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback + if ( strncmp(url,"https",5) == 0 ) + { + curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,0); + curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYHOST,0); + } + if ( userpass != 0 ) + curl_easy_setopt(curl_handle,CURLOPT_USERPWD, userpass); + databuf = 0; + if ( params != 0 ) + { + if ( command != 0 && specialcase == 0 ) + { + len = strlen(params); + if ( len > 0 && params[0] == '[' && params[len-1] == ']' ) { + bracket0 = bracket1 = (char *)""; + } + else + { + bracket0 = (char *)"["; + bracket1 = (char *)"]"; + } + + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); + sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); + //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); + // + } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); + curl_easy_setopt(curl_handle,CURLOPT_POST,1L); + if ( databuf != 0 ) + curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,databuf); + else curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,params); + } + //laststart = milliseconds(); + res = curl_easy_perform(curl_handle); + curl_slist_free_all(headers); + curl_easy_cleanup(curl_handle); + if ( databuf != 0 ) // clean up temporary buffer + { + free(databuf); + databuf = 0; + } + if ( res != CURLE_OK ) + { + numretries++; + if ( specialcase != 0 ) + { + printf("<<<<<<<<<<< bitcoind_RPC.(%s): BTCD.%s timeout params.(%s) s.ptr.(%s) err.%d\n",url,command,params,s.ptr,res); + free(s.ptr); + return(0); + } + else if ( numretries >= 1 ) + { + //printf("Maximum number of retries exceeded!\n"); + free(s.ptr); + return(0); + } + if ( (rand() % 1000) == 0 ) + printf( "curl_easy_perform() failed: %s %s.(%s %s), retries: %d\n",curl_easy_strerror(res),debugstr,url,command,numretries); + free(s.ptr); + sleep((1< (%s)\n",params,s.ptr); + count2++; + elapsedsum2 += (OS_milliseconds() - starttime); + if ( (count2 % 10000) == 0) + printf("%d: ave %9.6f | elapsed %.3f millis | NXT calls.(%s) cmd.(%s)\n",count2,elapsedsum2/count2,(double)(OS_milliseconds() - starttime),url,command); + return(s.ptr); + } + } + printf("bitcoind_RPC: impossible case\n"); + free(s.ptr); + return(0); +} + +static size_t WriteMemoryCallback(void *ptr,size_t size,size_t nmemb,void *data) +{ + size_t realsize = (size * nmemb); + struct MemoryStruct *mem = (struct MemoryStruct *)data; + mem->memory = (char *)((ptr != 0) ? realloc(mem->memory,mem->size + realsize + 1) : malloc(mem->size + realsize + 1)); + if ( mem->memory != 0 ) + { + if ( ptr != 0 ) + memcpy(&(mem->memory[mem->size]),ptr,realsize); + mem->size += realsize; + mem->memory[mem->size] = 0; + } + //printf("got %d bytes\n",(int32_t)(size*nmemb)); + return(realsize); +} + +char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *hdr0,char *hdr1,char *hdr2,char *hdr3) +{ + struct MemoryStruct chunk; CURL *cHandle; long code; struct curl_slist *headers = 0; + if ( (cHandle= *cHandlep) == NULL ) + *cHandlep = cHandle = curl_easy_init(); + else curl_easy_reset(cHandle); + //#ifdef DEBUG + //curl_easy_setopt(cHandle,CURLOPT_VERBOSE, 1); + //#endif + curl_easy_setopt(cHandle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + curl_easy_setopt(cHandle,CURLOPT_SSL_VERIFYPEER,0); + //curl_easy_setopt(cHandle,CURLOPT_SSLVERSION,1); + curl_easy_setopt(cHandle,CURLOPT_URL,url); + curl_easy_setopt(cHandle,CURLOPT_CONNECTTIMEOUT,10); + if ( userpass != 0 && userpass[0] != 0 ) + curl_easy_setopt(cHandle,CURLOPT_USERPWD,userpass); + if ( postfields != 0 && postfields[0] != 0 ) + { + curl_easy_setopt(cHandle,CURLOPT_POST,1); + curl_easy_setopt(cHandle,CURLOPT_POSTFIELDS,postfields); + } + if ( hdr0 != NULL && hdr0[0] != 0 ) + { + //printf("HDR0.(%s) HDR1.(%s) HDR2.(%s) HDR3.(%s)\n",hdr0!=0?hdr0:"",hdr1!=0?hdr1:"",hdr2!=0?hdr2:"",hdr3!=0?hdr3:""); + headers = curl_slist_append(headers,hdr0); + if ( hdr1 != 0 && hdr1[0] != 0 ) + headers = curl_slist_append(headers,hdr1); + if ( hdr2 != 0 && hdr2[0] != 0 ) + headers = curl_slist_append(headers,hdr2); + if ( hdr3 != 0 && hdr3[0] != 0 ) + headers = curl_slist_append(headers,hdr3); + } //headers = curl_slist_append(0,"Expect:"); + if ( headers != 0 ) + curl_easy_setopt(cHandle,CURLOPT_HTTPHEADER,headers); + //res = curl_easy_perform(cHandle); + memset(&chunk,0,sizeof(chunk)); + curl_easy_setopt(cHandle,CURLOPT_WRITEFUNCTION,WriteMemoryCallback); + curl_easy_setopt(cHandle,CURLOPT_WRITEDATA,(void *)&chunk); + curl_easy_perform(cHandle); + curl_easy_getinfo(cHandle,CURLINFO_RESPONSE_CODE,&code); + if ( headers != 0 ) + curl_slist_free_all(headers); + if ( code != 200 ) + printf("(%s) server responded with code %ld (%s)\n",url,code,chunk.memory); + return(chunk.memory); +} + +uint16_t _komodo_userpass(char *username, char *password, FILE *fp) +{ + char *rpcuser,*rpcpassword,*str,*ipaddress,line[8192]; uint16_t port = 0; + rpcuser = rpcpassword = 0; + username[0] = password[0] = 0; + while ( fgets(line,sizeof(line),fp) != 0 ) + { + if ( line[0] == '#' ) + continue; + //printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword")); + if ( (str= strstr(line,(char *)"rpcuser")) != 0 ) + rpcuser = parse_conf_line(str,(char *)"rpcuser"); + else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) + rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); + else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) + { + port = atoi(parse_conf_line(str,(char *)"rpcport")); + //fprintf(stderr,"rpcport.%u in file\n",port); + } + else if ( (str= strstr(line,(char *)"ipaddress")) != 0 ) + { + ipaddress = parse_conf_line(str,(char *)"ipaddress"); + strcpy(IPADDRESS,ipaddress); + } + } + if ( rpcuser != 0 && rpcpassword != 0 ) + { + strcpy(username,rpcuser); + strcpy(password,rpcpassword); + } + //printf("rpcuser.(%s) rpcpassword.(%s) %u ipaddress.%s\n",rpcuser,rpcpassword,port,ipaddress); + if ( rpcuser != 0 ) + free(rpcuser); + if ( rpcpassword != 0 ) + free(rpcpassword); + return(port); +} + +uint16_t komodo_userpass(char *userpass,char *symbol) +{ + FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[KOMODO_ASSETCHAIN_MAXLEN]; + userpass[0] = 0; + if ( strcmp("KMD",symbol) == 0 ) + { +#ifdef __APPLE__ + sprintf(confname,"Komodo.conf"); +#else + sprintf(confname,"komodo.conf"); +#endif + } + else sprintf(confname,"%s.conf",symbol); + //komodo_statefname(fname,symbol,confname); + if ( (fp= fopen(confname,"rb")) != 0 ) + { + port = _komodo_userpass(username,password,fp); + sprintf(userpass,"%s:%s",username,password); + if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 ) + strcpy(USERPASS,userpass); + fclose(fp); + } + return(port); +} + +#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) + +char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) +{ + //static void *cHandle; + char url[512],*retstr=0,*retstr2=0,postdata[8192]; + if ( params == 0 || params[0] == 0 ) + params = (char *)"[]"; + if ( strlen(params) < sizeof(postdata)-128 ) + { + sprintf(url,(char *)"http://%s:%u",IPADDRESS,port); + sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); + //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS); + retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); + //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); + } + return(retstr2); +} + +int32_t issue_games_events(bits256 gametxid,uint32_t eventid,int32_t c) +{ + static FILE *fp; + char params[512],*retstr,str[65]; cJSON *retjson,*resobj; int32_t retval = -1; + if ( fp == 0 ) + fp = fopen("events.log","wb"); + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c,bits256_str(str,gametxid),eventid); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + retval = 0; + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } + } + free_json(retjson); + } else fprintf(fp,"error parsing %s\n",retstr); + free(retstr); + } else fprintf(fp,"error issuing method %s\n",params); + return(retval); +} + +int32_t games_sendrawtransaction(char *rawtx) +{ + char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; + params = (char *)malloc(strlen(rawtx) + 16); + sprintf(params,"[\"%s\"]",rawtx); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"sendrawtransaction",params,GAMES_PORT)) != 0 ) + { + if ( 0 ) // causes 4th level crash + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("games.sendlog","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%s\n",retstr); + fflush(fp); + } + } + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + if ( (hexstr= jstr(resobj,0)) != 0 && is_hexstr(hexstr,64) == 64 ) + retval = 0; + } + free_json(retjson); + } + + /* log sendrawtx result in file */ + + /* + FILE *debug_file; + debug_file = fopen("tx_debug.log", "a"); + fprintf(debug_file, "%s\n", retstr); + fflush(debug_file); + fclose(debug_file); + */ + + free(retstr); + } + free(params); + return(retval); +} + +int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) +{ + char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; uint8_t *pastcmp; + if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) + { + if ( rs->keystrokeshex != 0 ) + { + if ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) + { + if ( waitflag == 0 ) + return(0); + else if ( 0 ) + { + while ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) + { + //fprintf(stderr,"pre-rebroadcast\n"); + sleep(10); + } + } + } + free(rs->keystrokeshex), rs->keystrokeshex = 0; + } + if ( 0 && (pastkeys= games_keystrokesload(&numpastkeys,seed,1)) != 0 ) + { + sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (keys= jstr(resobj,(char *)"keystrokes")) != 0 ) + { + len = strlen(keys) / 2; + pastcmp = (uint8_t *)malloc(len + 1); + decode_hex(pastcmp,len,keys); + fprintf(stderr,"keystrokes.(%s) vs pastkeys\n",keys); + for (i=0; i> keystrokes.log",ASSETCHAINS_SYMBOL,Gametxidstr,hexstr); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + } + else + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("keystrokes.log","a"); + sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( fp != 0 ) + { + fprintf(fp,"%s\n",params); + fprintf(fp,"%s\n",retstr); + fflush(fp); + } + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (rawtx= jstr(resobj,(char *)"hex")) != 0 ) + { + if ( rs->keystrokeshex != 0 ) + free(rs->keystrokeshex); + if ( (errstr= jstr(resobj,(char *)"error")) == 0 ) + { + rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); + strcpy(rs->keystrokeshex,rawtx); + retflag = 1; + } else fprintf(stderr,"error sending keystrokes tx\n"), sleep(1); + //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); + } + free_json(retjson); + } + free(retstr); + } + if ( 0 && waitflag != 0 && rs->keystrokeshex != 0 ) + { + while ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) + { + //fprintf(stderr,"post-rebroadcast\n"); + sleep(3); + } + free(rs->keystrokeshex), rs->keystrokeshex = 0; + } + } + } + return(retflag); +} + +int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) +{ + char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson; + if ( rs->guiflag == 0 ) + return(-1); + if ( gametxidstr == 0 || *gametxidstr == 0 ) + return(retval); + if ( 0 ) + { + sprintf(fname,"%s.gameinfo",gametxidstr); + sprintf(cmd,"./komodo-cli -ac_name=%s cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",ASSETCHAINS_SYMBOL,gametxidstr,fname); + if ( system(cmd) != 0 ) + fprintf(stderr,"error issuing (%s)\n",cmd); + else filestr = (char *)OS_fileptr(&allocsize,fname); + } + else + { + sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); + filestr = komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT); + } + if ( filestr != 0 ) + { + if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,(char *)"result")) != 0 ) + { + //fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); + if ( (array= jarray(&n,resultjson,(char *)"players")) != 0 ) + { + for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); + fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0)); + rs->restoring = 1; + } + } + } + } + } + free_json(retjson); + } + free(filestr); + } + return(retval); +} + +#ifdef _WIN32 +#ifdef _MSC_VER +__inline int msver(void) { + switch (_MSC_VER) { + case 1500: return 2008; + case 1600: return 2010; + case 1700: return 2012; + case 1800: return 2013; + case 1900: return 2015; + //case 1910: return 2017; + default: return (_MSC_VER / 100); + } +} + +static inline bool is_x64(void) { +#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) + return 1; +#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64) + return 1; +#else + return 0; +#endif +} + +#define BUILD_DATE __DATE__ " " __TIME__ +#endif // _WIN32 +#endif // _MSC_VER + +int main(int argc, char **argv) +{ + uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; +#ifdef _WIN32 +#ifdef _MSC_VER + printf("*** games for Windows [ Build %s ] ***\n", BUILD_DATE); + const char* arch = is_x64() ? "64-bits" : "32-bits"; + printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch); +#endif +#endif + + for (i=j=0; argv[0][i]!=0&&j payload) -{ - uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; - if ( (len= payload.size()) > 36 ) - { - len -= 36; - for (i=0; i<32; i++) - ((uint8_t *)&gametxid)[i] = payload[len+i]; - eventid = (uint32_t)payload[len+32]; - eventid |= (uint32_t)payload[len+33] << 8; - eventid |= (uint32_t)payload[len+34] << 16; - eventid |= (uint32_t)payload[len+35] << 24; - for (i=0; i payload); +int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk); +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); +void games_packitemstr(char *packitemstr,struct games_packitem *item); +int64_t games_cashout(struct games_player *P); + CScript games_newgameopret(int64_t buyin,int32_t maxplayers) { @@ -1343,99 +1335,6 @@ UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -int64_t games_cashout(struct games_player *P) -{ - int32_t dungeonlevel; int64_t mult=10,cashout = 0; - if ( P->amulet != 0 ) - mult *= 5; - dungeonlevel = P->dungeonlevel; - if ( P->amulet != 0 && dungeonlevel < 26 ) - dungeonlevel = 26; - cashout = (uint64_t)P->gold * P->gold * mult * dungeonlevel; - return(cashout); -} - -int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) -{ - static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,gamesaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; - *cashoutp = 0; - gamespk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,gamesaddr,gamespk,pk); - if ( (keystrokes= games_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) - { - free(keystrokes); - sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); - remove(fname); - - for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); - } - *cashoutp = 0; - return(0); - } - } - if ( gametxid != prevgame ) - { - prevgame = gametxid; - bad++; - disp_gamesplayerdata(newdata); - disp_gamesplayerdata(playerdata); - fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,gamesaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); - } - } - sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); - remove(fname); - //fprintf(stderr,"no keys games_extractgame %s\n",gametxid.GetHex().c_str()); - return(-1); -} - UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { //vin0 -> highlander vout from creategame TCBOO @@ -1657,1928 +1556,11 @@ UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) -{ - return(true); -} +#include "tetris.cpp" -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) -{ - return(-1); -} +#else // STANDALONE -void games_packitemstr(char *packitemstr,struct games_packitem *item) -{ - sprintf(packitemstr,"not yet"); -} -#else - - -#include -#include -#include -#include -#include -#include -#include - -char USERPASS[8192]; uint16_t GAMES_PORT; -char Gametxidstr[67]; -char *clonestr(char *str); - -#define MAXSTR 1024 -char whoami[MAXSTR]; - -#define SMALLVAL 0.000000000000001 -#define SATOSHIDEN ((uint64_t)100000000L) -#define dstr(x) ((double)(x) / SATOSHIDEN) -#define KOMODO_ASSETCHAIN_MAXLEN 65 -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],IPADDRESS[100]; - -#ifndef _BITS256 -#define _BITS256 -union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; -typedef union _bits256 bits256; -#endif - -#ifdef _WIN32 -#ifdef _MSC_VER -int gettimeofday(struct timeval * tp, struct timezone * tzp) -{ - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); - - SYSTEMTIME system_time; - FILETIME file_time; - uint64_t time; - - GetSystemTime(&system_time); - SystemTimeToFileTime(&system_time, &file_time); - time = ((uint64_t)file_time.dwLowDateTime); - time += ((uint64_t)file_time.dwHighDateTime) << 32; - - tp->tv_sec = (long)((time - EPOCH) / 10000000L); - tp->tv_usec = (long)(system_time.wMilliseconds * 1000); - return 0; -} -#endif // _MSC_VER -#endif - - - -double OS_milliseconds() -{ - struct timeval tv; double millis; -#ifdef __MINGW32__ - mingw_gettimeofday(&tv,NULL); -#else - gettimeofday(&tv,NULL); -#endif - millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.); - //printf("tv_sec.%ld usec.%d %f\n",tv.tv_sec,tv.tv_usec,millis); - return(millis); -} - -int32_t _unhex(char c) -{ - if ( c >= '0' && c <= '9' ) - return(c - '0'); - else if ( c >= 'a' && c <= 'f' ) - return(c - 'a' + 10); - else if ( c >= 'A' && c <= 'F' ) - return(c - 'A' + 10); - return(-1); -} - -int32_t is_hexstr(char *str,int32_t n) -{ - int32_t i; - if ( str == 0 || str[0] == 0 ) - return(0); - for (i=0; str[i]!=0; i++) - { - if ( n > 0 && i >= n ) - break; - if ( _unhex(str[i]) < 0 ) - break; - } - if ( n == 0 ) - return(i); - return(i == n); -} - -int32_t unhex(char c) -{ - int32_t hex; - if ( (hex= _unhex(c)) < 0 ) - { - //printf("unhex: illegal hexchar.(%c)\n",c); - } - return(hex); -} - -unsigned char _decode_hex(char *hex) { return((unhex(hex[0])<<4) | unhex(hex[1])); } - -int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) -{ - int32_t adjust,i = 0; - //printf("decode.(%s)\n",hex); - if ( is_hexstr(hex,n) <= 0 ) - { - memset(bytes,0,n); - return(n); - } - if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) - hex[--n] = 0; - if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) ) - { - if ( n > 0 ) - { - bytes[0] = unhex(hex[0]); - printf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex)); - } - bytes++; - hex++; - adjust = 1; - } else adjust = 0; - if ( n > 0 ) - { - for (i=0; i>4) & 0xf); - hexbytes[i*2 + 1] = hexbyte(message[i] & 0xf); - //printf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]); - } - hexbytes[len*2] = 0; - //printf("len.%ld\n",len*2+1); - return((int32_t)len*2+1); -} - -char *bits256_str(char hexstr[65],bits256 x) -{ - init_hexbytes_noT(hexstr,x.bytes,sizeof(x)); - return(hexstr); -} - -long _stripwhite(char *buf,int accept) -{ - int32_t i,j,c; - if ( buf == 0 || buf[0] == 0 ) - return(0); - for (i=j=0; buf[i]!=0; i++) - { - buf[j] = c = buf[i]; - if ( c == accept || (c != ' ' && c != '\n' && c != '\r' && c != '\t' && c != '\b') ) - j++; - } - buf[j] = 0; - return(j); -} - -char *parse_conf_line(char *line,char *field) -{ - line += strlen(field); - for (; *line!='='&&*line!=0; line++) - break; - if ( *line == 0 ) - return(0); - if ( *line == '=' ) - line++; - while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' ) - line[strlen(line)-1] = 0; - //printf("LINE.(%s)\n",line); - _stripwhite(line,0); - return(clonestr(line)); -} - -int32_t safecopy(char *dest,char *src,long len) -{ - int32_t i = -1; - if ( src != 0 && dest != 0 && src != dest ) - { - if ( dest != 0 ) - memset(dest,0,len); - for (i=0; i buflen ) - { - *allocsizep = filesize; - *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); - } - rewind(fp); - if ( buf == 0 ) - printf("Null buf ???\n"); - else - { - if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) - printf("error reading filesize.%ld\n",(long)filesize); - buf[filesize] = 0; - } - fclose(fp); - *lenp = filesize; - //printf("loaded.(%s)\n",buf); - } //else printf("OS_loadfile couldnt load.(%s)\n",fname); - return(buf); -} - -uint8_t *OS_fileptr(long *allocsizep,char *fname) -{ - long filesize = 0; uint8_t *buf = 0; void *retptr; - *allocsizep = 0; - retptr = OS_loadfile(fname,&buf,&filesize,allocsizep); - return((uint8_t *)retptr); -} - -struct MemoryStruct { char *memory; size_t size; }; -struct return_string { char *ptr; size_t len; }; - -// return data from the server -#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) -#define CURL_GLOBAL_SSL (1<<0) -#define CURL_GLOBAL_WIN32 (1<<1) - - -/************************************************************************ - * - * Initialize the string handler so that it is thread safe - * - ************************************************************************/ - -void init_string(struct return_string *s) -{ - s->len = 0; - s->ptr = (char *)calloc(1,s->len+1); - if ( s->ptr == NULL ) - { - fprintf(stderr,"init_string malloc() failed\n"); - exit(-1); - } - s->ptr[0] = '\0'; -} - -/************************************************************************ - * - * Use the "writer" to accumulate text until done - * - ************************************************************************/ - -size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *s) -{ - size_t new_len = s->len + size*nmemb; - s->ptr = (char *)realloc(s->ptr,new_len+1); - if ( s->ptr == NULL ) - { - fprintf(stderr, "accumulate realloc() failed\n"); - exit(-1); - } - memcpy(s->ptr+s->len,ptr,size*nmemb); - s->ptr[new_len] = '\0'; - s->len = new_len; - return(size * nmemb); -} - -/************************************************************************ - * - * return the current system time in milliseconds - * - ************************************************************************/ - -#define EXTRACT_BITCOIND_RESULT // if defined, ensures error is null and returns the "result" field -#ifdef EXTRACT_BITCOIND_RESULT - -/************************************************************************ - * - * perform post processing of the results - * - ************************************************************************/ - -char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params) -{ - long i,j,len; char *retstr = 0; cJSON *json,*result,*error; - //printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); - if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 ) - { - if ( strcmp(command,"signrawtransaction") != 0 ) - printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); - return(rpcstr); - } - json = cJSON_Parse(rpcstr); - if ( json == 0 ) - { - printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s) params.(%s)\n",debugstr,command,rpcstr,params); - free(rpcstr); - return(0); - } - result = cJSON_GetObjectItem(json,"result"); - error = cJSON_GetObjectItem(json,"error"); - if ( error != 0 && result != 0 ) - { - if ( (error->type&0xff) == cJSON_NULL && (result->type&0xff) != cJSON_NULL ) - { - retstr = cJSON_Print(result); - len = strlen(retstr); - if ( retstr[0] == '"' && retstr[len-1] == '"' ) - { - for (i=1,j=0; itype&0xff) != cJSON_NULL || (result->type&0xff) != cJSON_NULL ) - { - if ( strcmp(command,"signrawtransaction") != 0 ) - printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr); - } - free(rpcstr); - } else retstr = rpcstr; - free_json(json); - //fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: postprocess returns.(%s)\n",retstr); - return(retstr); -} -#endif - -#ifdef _WIN32 -#ifdef _MSC_VER -#define sleep(x) Sleep(1000*(x)) -#endif -#endif - -/************************************************************************ - * - * perform the query - * - ************************************************************************/ - -char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params) -{ - static int didinit,count,count2; static double elapsedsum,elapsedsum2; - struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle; - char *bracket0,*bracket1,*databuf = 0; long len; int32_t specialcase,numretries; double starttime; - if ( didinit == 0 ) - { - didinit = 1; - curl_global_init(CURL_GLOBAL_ALL); //init the curl session - } - numretries = 0; - if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 ) - specialcase = 1; - else specialcase = 0; - if ( url[0] == 0 ) - strcpy(url,"http://127.0.0.1:7876/nxt"); - if ( specialcase != 0 && 0 ) - printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params); -try_again: - if ( retstrp != 0 ) - *retstrp = 0; - starttime = OS_milliseconds(); - curl_handle = curl_easy_init(); - init_string(&s); - headers = curl_slist_append(0,"Expect:"); - - curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); - curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); - curl_easy_setopt(curl_handle,CURLOPT_URL, url); - curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function - curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback - curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash - curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback - if ( strncmp(url,"https",5) == 0 ) - { - curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,0); - curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYHOST,0); - } - if ( userpass != 0 ) - curl_easy_setopt(curl_handle,CURLOPT_USERPWD, userpass); - databuf = 0; - if ( params != 0 ) - { - if ( command != 0 && specialcase == 0 ) - { - len = strlen(params); - if ( len > 0 && params[0] == '[' && params[len-1] == ']' ) { - bracket0 = bracket1 = (char *)""; - } - else - { - bracket0 = (char *)"["; - bracket1 = (char *)"]"; - } - - databuf = (char *)malloc(256 + strlen(command) + strlen(params)); - sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); - //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); - // - } //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params); - curl_easy_setopt(curl_handle,CURLOPT_POST,1L); - if ( databuf != 0 ) - curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,databuf); - else curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,params); - } - //laststart = milliseconds(); - res = curl_easy_perform(curl_handle); - curl_slist_free_all(headers); - curl_easy_cleanup(curl_handle); - if ( databuf != 0 ) // clean up temporary buffer - { - free(databuf); - databuf = 0; - } - if ( res != CURLE_OK ) - { - numretries++; - if ( specialcase != 0 ) - { - printf("<<<<<<<<<<< bitcoind_RPC.(%s): BTCD.%s timeout params.(%s) s.ptr.(%s) err.%d\n",url,command,params,s.ptr,res); - free(s.ptr); - return(0); - } - else if ( numretries >= 1 ) - { - //printf("Maximum number of retries exceeded!\n"); - free(s.ptr); - return(0); - } - if ( (rand() % 1000) == 0 ) - printf( "curl_easy_perform() failed: %s %s.(%s %s), retries: %d\n",curl_easy_strerror(res),debugstr,url,command,numretries); - free(s.ptr); - sleep((1< (%s)\n",params,s.ptr); - count2++; - elapsedsum2 += (OS_milliseconds() - starttime); - if ( (count2 % 10000) == 0) - printf("%d: ave %9.6f | elapsed %.3f millis | NXT calls.(%s) cmd.(%s)\n",count2,elapsedsum2/count2,(double)(OS_milliseconds() - starttime),url,command); - return(s.ptr); - } - } - printf("bitcoind_RPC: impossible case\n"); - free(s.ptr); - return(0); -} - -static size_t WriteMemoryCallback(void *ptr,size_t size,size_t nmemb,void *data) -{ - size_t realsize = (size * nmemb); - struct MemoryStruct *mem = (struct MemoryStruct *)data; - mem->memory = (char *)((ptr != 0) ? realloc(mem->memory,mem->size + realsize + 1) : malloc(mem->size + realsize + 1)); - if ( mem->memory != 0 ) - { - if ( ptr != 0 ) - memcpy(&(mem->memory[mem->size]),ptr,realsize); - mem->size += realsize; - mem->memory[mem->size] = 0; - } - //printf("got %d bytes\n",(int32_t)(size*nmemb)); - return(realsize); -} - -char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *hdr0,char *hdr1,char *hdr2,char *hdr3) -{ - struct MemoryStruct chunk; CURL *cHandle; long code; struct curl_slist *headers = 0; - if ( (cHandle= *cHandlep) == NULL ) - *cHandlep = cHandle = curl_easy_init(); - else curl_easy_reset(cHandle); - //#ifdef DEBUG - //curl_easy_setopt(cHandle,CURLOPT_VERBOSE, 1); - //#endif - curl_easy_setopt(cHandle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); - curl_easy_setopt(cHandle,CURLOPT_SSL_VERIFYPEER,0); - //curl_easy_setopt(cHandle,CURLOPT_SSLVERSION,1); - curl_easy_setopt(cHandle,CURLOPT_URL,url); - curl_easy_setopt(cHandle,CURLOPT_CONNECTTIMEOUT,10); - if ( userpass != 0 && userpass[0] != 0 ) - curl_easy_setopt(cHandle,CURLOPT_USERPWD,userpass); - if ( postfields != 0 && postfields[0] != 0 ) - { - curl_easy_setopt(cHandle,CURLOPT_POST,1); - curl_easy_setopt(cHandle,CURLOPT_POSTFIELDS,postfields); - } - if ( hdr0 != NULL && hdr0[0] != 0 ) - { - //printf("HDR0.(%s) HDR1.(%s) HDR2.(%s) HDR3.(%s)\n",hdr0!=0?hdr0:"",hdr1!=0?hdr1:"",hdr2!=0?hdr2:"",hdr3!=0?hdr3:""); - headers = curl_slist_append(headers,hdr0); - if ( hdr1 != 0 && hdr1[0] != 0 ) - headers = curl_slist_append(headers,hdr1); - if ( hdr2 != 0 && hdr2[0] != 0 ) - headers = curl_slist_append(headers,hdr2); - if ( hdr3 != 0 && hdr3[0] != 0 ) - headers = curl_slist_append(headers,hdr3); - } //headers = curl_slist_append(0,"Expect:"); - if ( headers != 0 ) - curl_easy_setopt(cHandle,CURLOPT_HTTPHEADER,headers); - //res = curl_easy_perform(cHandle); - memset(&chunk,0,sizeof(chunk)); - curl_easy_setopt(cHandle,CURLOPT_WRITEFUNCTION,WriteMemoryCallback); - curl_easy_setopt(cHandle,CURLOPT_WRITEDATA,(void *)&chunk); - curl_easy_perform(cHandle); - curl_easy_getinfo(cHandle,CURLINFO_RESPONSE_CODE,&code); - if ( headers != 0 ) - curl_slist_free_all(headers); - if ( code != 200 ) - printf("(%s) server responded with code %ld (%s)\n",url,code,chunk.memory); - return(chunk.memory); -} - -uint16_t _komodo_userpass(char *username, char *password, FILE *fp) -{ - char *rpcuser,*rpcpassword,*str,*ipaddress,line[8192]; uint16_t port = 0; - rpcuser = rpcpassword = 0; - username[0] = password[0] = 0; - while ( fgets(line,sizeof(line),fp) != 0 ) - { - if ( line[0] == '#' ) - continue; - //printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword")); - if ( (str= strstr(line,(char *)"rpcuser")) != 0 ) - rpcuser = parse_conf_line(str,(char *)"rpcuser"); - else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) - rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); - else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) - { - port = atoi(parse_conf_line(str,(char *)"rpcport")); - //fprintf(stderr,"rpcport.%u in file\n",port); - } - else if ( (str= strstr(line,(char *)"ipaddress")) != 0 ) - { - ipaddress = parse_conf_line(str,(char *)"ipaddress"); - strcpy(IPADDRESS,ipaddress); - } - } - if ( rpcuser != 0 && rpcpassword != 0 ) - { - strcpy(username,rpcuser); - strcpy(password,rpcpassword); - } - //printf("rpcuser.(%s) rpcpassword.(%s) %u ipaddress.%s\n",rpcuser,rpcpassword,port,ipaddress); - if ( rpcuser != 0 ) - free(rpcuser); - if ( rpcpassword != 0 ) - free(rpcpassword); - return(port); -} - -uint16_t komodo_userpass(char *userpass,char *symbol) -{ - FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[KOMODO_ASSETCHAIN_MAXLEN]; - userpass[0] = 0; - if ( strcmp("KMD",symbol) == 0 ) - { -#ifdef __APPLE__ - sprintf(confname,"Komodo.conf"); -#else - sprintf(confname,"komodo.conf"); -#endif - } - else sprintf(confname,"%s.conf",symbol); - //komodo_statefname(fname,symbol,confname); - if ( (fp= fopen(confname,"rb")) != 0 ) - { - port = _komodo_userpass(username,password,fp); - sprintf(userpass,"%s:%s",username,password); - if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 ) - strcpy(USERPASS,userpass); - fclose(fp); - } - return(port); -} - -#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) - -char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) -{ - //static void *cHandle; - char url[512],*retstr=0,*retstr2=0,postdata[8192]; - if ( params == 0 || params[0] == 0 ) - params = (char *)"[]"; - if ( strlen(params) < sizeof(postdata)-128 ) - { - sprintf(url,(char *)"http://%s:%u",IPADDRESS,port); - sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); - //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS); - retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); - //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); - } - return(retstr2); -} - -int32_t issue_games_events(bits256 gametxid,uint32_t eventid,int32_t c) -{ - static FILE *fp; - char params[512],*retstr,str[65]; cJSON *retjson,*resobj; int32_t retval = -1; - if ( fp == 0 ) - fp = fopen("events.log","wb"); - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c,bits256_str(str,gametxid),eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) - { - retval = 0; - if ( fp != 0 ) - { - fprintf(fp,"%s\n",jprint(resobj,0)); - fflush(fp); - } - } - free_json(retjson); - } else fprintf(fp,"error parsing %s\n",retstr); - free(retstr); - } else fprintf(fp,"error issuing method %s\n",params); - return(retval); -} - -int32_t games_sendrawtransaction(char *rawtx) -{ - char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; - params = (char *)malloc(strlen(rawtx) + 16); - sprintf(params,"[\"%s\"]",rawtx); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"sendrawtransaction",params,GAMES_PORT)) != 0 ) - { - if ( 0 ) // causes 4th level crash - { - static FILE *fp; - if ( fp == 0 ) - fp = fopen("games.sendlog","wb"); - if ( fp != 0 ) - { - fprintf(fp,"%s\n",retstr); - fflush(fp); - } - } - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) - { - if ( (hexstr= jstr(resobj,0)) != 0 && is_hexstr(hexstr,64) == 64 ) - retval = 0; - } - free_json(retjson); - } - - /* log sendrawtx result in file */ - - /* - FILE *debug_file; - debug_file = fopen("tx_debug.log", "a"); - fprintf(debug_file, "%s\n", retstr); - fflush(debug_file); - fclose(debug_file); - */ - - free(retstr); - } - free(params); - return(retval); -} - -int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) -{ - char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; uint8_t *pastcmp; - if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) - { - if ( rs->keystrokeshex != 0 ) - { - if ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) - { - if ( waitflag == 0 ) - return(0); - else if ( 0 ) - { - while ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) - { - //fprintf(stderr,"pre-rebroadcast\n"); - sleep(10); - } - } - } - free(rs->keystrokeshex), rs->keystrokeshex = 0; - } - if ( 0 && (pastkeys= games_keystrokesload(&numpastkeys,seed,1)) != 0 ) - { - sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (keys= jstr(resobj,(char *)"keystrokes")) != 0 ) - { - len = strlen(keys) / 2; - pastcmp = (uint8_t *)malloc(len + 1); - decode_hex(pastcmp,len,keys); - fprintf(stderr,"keystrokes.(%s) vs pastkeys\n",keys); - for (i=0; i> keystrokes.log",ASSETCHAINS_SYMBOL,Gametxidstr,hexstr); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); - } - else - { - static FILE *fp; - if ( fp == 0 ) - fp = fopen("keystrokes.log","a"); - sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( fp != 0 ) - { - fprintf(fp,"%s\n",params); - fprintf(fp,"%s\n",retstr); - fflush(fp); - } - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (rawtx= jstr(resobj,(char *)"hex")) != 0 ) - { - if ( rs->keystrokeshex != 0 ) - free(rs->keystrokeshex); - if ( (errstr= jstr(resobj,(char *)"error")) == 0 ) - { - rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); - strcpy(rs->keystrokeshex,rawtx); - retflag = 1; - } else fprintf(stderr,"error sending keystrokes tx\n"), sleep(1); - //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); - } - free_json(retjson); - } - free(retstr); - } - if ( 0 && waitflag != 0 && rs->keystrokeshex != 0 ) - { - while ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) - { - //fprintf(stderr,"post-rebroadcast\n"); - sleep(3); - } - free(rs->keystrokeshex), rs->keystrokeshex = 0; - } - } - } - return(retflag); -} - -int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) -{ - char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson; - if ( rs->guiflag == 0 ) - return(-1); - if ( gametxidstr == 0 || *gametxidstr == 0 ) - return(retval); - if ( 0 ) - { - sprintf(fname,"%s.gameinfo",gametxidstr); - sprintf(cmd,"./komodo-cli -ac_name=%s cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",ASSETCHAINS_SYMBOL,gametxidstr,fname); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); - else filestr = (char *)OS_fileptr(&allocsize,fname); - } - else - { - sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); - filestr = komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT); - } - if ( filestr != 0 ) - { - if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,(char *)"result")) != 0 ) - { - //fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0)); - if ( (array= jarray(&n,resultjson,(char *)"players")) != 0 ) - { - for (i=0; iP,(int32_t)strlen(datastr)/2,datastr); - fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0)); - rs->restoring = 1; - } - } - } - } - } - free_json(retjson); - } - free(filestr); - } - return(retval); -} - -#ifdef _WIN32 -#ifdef _MSC_VER -__inline int msver(void) { - switch (_MSC_VER) { - case 1500: return 2008; - case 1600: return 2010; - case 1700: return 2012; - case 1800: return 2013; - case 1900: return 2015; - //case 1910: return 2017; - default: return (_MSC_VER / 100); - } -} - -static inline bool is_x64(void) { -#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) - return 1; -#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64) - return 1; -#else - return 0; -#endif -} - -#define BUILD_DATE __DATE__ " " __TIME__ -#endif // _WIN32 -#endif // _MSC_VER - -int main(int argc, char **argv) -{ - uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; -#ifdef _WIN32 -#ifdef _MSC_VER - printf("*** games for Windows [ Build %s ] ***\n", BUILD_DATE); - const char* arch = is_x64() ? "64-bits" : "32-bits"; - printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch); -#endif -#endif - - for (i=j=0; argv[0][i]!=0&&j // for FILE -#include // for bool -#include -#include -#include -#include -#include -#include - -#ifdef BUILD_GAMESCC -#include "rogue/cursesd.h" -#else -#include -#endif - -/* - Convert a tetromino type to its corresponding cell. - */ -#define TYPE_TO_CELL(x) ((x)+1) - -/* - Strings for how you would print a tetris board. - */ -#define TC_EMPTY_STR " " -#define TC_BLOCK_STR "\u2588" - -/* - Questions about a tetris cell. - */ -#define TC_IS_EMPTY(x) ((x) == TC_EMPTY) -#define TC_IS_FILLED(x) (!TC_IS_EMPTY(x)) - -/* - How many cells in a tetromino? - */ -#define TETRIS 4 -/* - How many tetrominos? - */ -#define NUM_TETROMINOS 7 -/* - How many orientations of a tetromino? - */ -#define NUM_ORIENTATIONS 4 - -/* - Level constants. - */ -#define MAX_LEVEL 19 -#define LINES_PER_LEVEL 10 - -/* - A "cell" is a 1x1 block within a tetris board. - */ -typedef enum { - TC_EMPTY, TC_CELLI, TC_CELLJ, TC_CELLL, TC_CELLO, TC_CELLS, TC_CELLT, TC_CELLZ -} tetris_cell; - -/* - A "type" is a type/shape of a tetromino. Not including orientation. - */ -typedef enum { - TET_I, TET_J, TET_L, TET_O, TET_S, TET_T, TET_Z -} tetris_type; - -/* - A row,column pair. Negative numbers allowed, because we need them for - offsets. - */ -typedef struct { - int row; - int col; -} tetris_location; - -/* - A "block" is a struct that contains information about a tetromino. - Specifically, what type it is, what orientation it has, and where it is. - */ -typedef struct { - int typ; - int ori; - tetris_location loc; -} tetris_block; - -/* - All possible moves to give as input to the game. - */ -typedef enum { - TM_LEFT, TM_RIGHT, TM_CLOCK, TM_COUNTER, TM_DROP, TM_HOLD, TM_NONE -} tetris_move; - -/* - A game object! - */ -typedef struct { - /* - Game board stuff: - */ - int rows; - int cols; - char *board; - /* - Scoring information: - */ - int points; - int level; - /* - Falling block is the one currently going down. Next block is the one that - will be falling after this one. Stored is the block that you can swap out. - */ - tetris_block falling; - tetris_block next; - tetris_block stored; - /* - Number of game ticks until the block will move down. - */ - int ticks_till_gravity; - /* - Number of lines until you advance to the next level. - */ - int lines_remaining; -} tetris_game; - -/* - This array stores all necessary information about the cells that are filled by - each tetromino. The first index is the type of the tetromino (i.e. shape, - e.g. I, J, Z, etc.). The next index is the orientation (0-3). The final - array contains 4 tetris_location objects, each mapping to an offset from a - point on the upper left that is the tetromino "origin". - */ -extern tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; - -/* - This array tells you how many ticks per gravity by level. Decreases as level - increases, to add difficulty. - */ -extern int GRAVITY_LEVEL[MAX_LEVEL+1]; - -// Data structure manipulation. -void tg_init(tetris_game *obj, int rows, int cols); -tetris_game *tg_create(int rows, int cols); -void tg_destroy(tetris_game *obj); -void tg_delete(tetris_game *obj); -tetris_game *tg_load(FILE *f); -void tg_save(tetris_game *obj, FILE *f); - -// Public methods not related to memory: -char tg_get(tetris_game *obj, int row, int col); -bool tg_check(tetris_game *obj, int row, int col); -bool tg_tick(tetris_game *obj, tetris_move move); -void tg_print(tetris_game *obj, FILE *f); - -#endif // TETRIS_H - - -#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) - -/******************************************************************************* - Array Definitions - *******************************************************************************/ - -tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS] = { - // I - {{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, - {{0, 2}, {1, 2}, {2, 2}, {3, 2}}, - {{3, 0}, {3, 1}, {3, 2}, {3, 3}}, - {{0, 1}, {1, 1}, {2, 1}, {3, 1}}}, - // J - {{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {2, 1}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, - {{0, 1}, {1, 1}, {2, 0}, {2, 1}}}, - // L - {{{0, 2}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, - {{0, 0}, {0, 1}, {1, 1}, {2, 1}}}, - // O - {{{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}}, - // S - {{{0, 1}, {0, 2}, {1, 0}, {1, 1}}, - {{0, 1}, {1, 1}, {1, 2}, {2, 2}}, - {{1, 1}, {1, 2}, {2, 0}, {2, 1}}, - {{0, 0}, {1, 0}, {1, 1}, {2, 1}}}, - // T - {{{0, 1}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {1, 1}, {1, 2}, {2, 1}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 1}}, - {{0, 1}, {1, 0}, {1, 1}, {2, 1}}}, - // Z - {{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, - {{0, 2}, {1, 1}, {1, 2}, {2, 1}}, - {{1, 0}, {1, 1}, {2, 1}, {2, 2}}, - {{0, 1}, {1, 0}, {1, 1}, {2, 0}}}, -}; - -int GRAVITY_LEVEL[MAX_LEVEL+1] = { - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, - //10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 30, 28, 26, 24, 22, 20, 16, 12, 8, 4 -}; - -/******************************************************************************* - Helper Functions for Blocks - *******************************************************************************/ - -void sleep_milli(int milliseconds) -{ - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = milliseconds * 1000 * 1000; - nanosleep(&ts, NULL); -} - -/* - Return the block at the given row and column. - */ -char tg_get(tetris_game *obj, int row, int column) -{ - return obj->board[obj->cols * row + column]; -} - -/* - Set the block at the given row and column. - */ -static void tg_set(tetris_game *obj, int row, int column, char value) -{ - obj->board[obj->cols * row + column] = value; -} - -/* - Check whether a row and column are in bounds. - */ -bool tg_check(tetris_game *obj, int row, int col) -{ - return 0 <= row && row < obj->rows && 0 <= col && col < obj->cols; -} - -/* - Place a block onto the board. - */ -static void tg_put(tetris_game *obj, tetris_block block) -{ - int i; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, - TYPE_TO_CELL(block.typ)); - } -} - -/* - Clear a block out of the board. - */ -static void tg_remove(tetris_game *obj, tetris_block block) -{ - int i; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, TC_EMPTY); - } -} - -/* - Check if a block can be placed on the board. - */ -static bool tg_fits(tetris_game *obj, tetris_block block) -{ - int i, r, c; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - r = block.loc.row + cell.row; - c = block.loc.col + cell.col; - if (!tg_check(obj, r, c) || TC_IS_FILLED(tg_get(obj, r, c))) { - return false; - } - } - return true; -} - -/* - Return a random tetromino type. - */ -static int random_tetromino(void) -{ - return rand() % NUM_TETROMINOS; -} - -/* - Create a new falling block and populate the next falling block with a random - one. - */ -static void tg_new_falling(tetris_game *obj) -{ - // Put in a new falling tetromino. - obj->falling = obj->next; - obj->next.typ = random_tetromino(); - obj->next.ori = 0; - obj->next.loc.row = 0; - obj->next.loc.col = obj->cols/2 - 2; -} - -/******************************************************************************* - Game Turn Helpers - *******************************************************************************/ - -/* - Tick gravity, and move the block down if gravity should act. - */ -static void tg_do_gravity_tick(tetris_game *obj) -{ - obj->ticks_till_gravity--; - if (obj->ticks_till_gravity <= 0) { - tg_remove(obj, obj->falling); - obj->falling.loc.row++; - if (tg_fits(obj, obj->falling)) { - obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; - } else { - obj->falling.loc.row--; - tg_put(obj, obj->falling); - - tg_new_falling(obj); - } - tg_put(obj, obj->falling); - } -} - -/* - Move the falling tetris block left (-1) or right (+1). - */ -static void tg_move(tetris_game *obj, int direction) -{ - tg_remove(obj, obj->falling); - obj->falling.loc.col += direction; - if (!tg_fits(obj, obj->falling)) { - obj->falling.loc.col -= direction; - } - tg_put(obj, obj->falling); -} - -/* - Send the falling tetris block to the bottom. - */ -static void tg_down(tetris_game *obj) -{ - tg_remove(obj, obj->falling); - while (tg_fits(obj, obj->falling)) { - obj->falling.loc.row++; - } - obj->falling.loc.row--; - tg_put(obj, obj->falling); - tg_new_falling(obj); -} - -/* - Rotate the falling block in either direction (+/-1). - */ -static void tg_rotate(tetris_game *obj, int direction) -{ - tg_remove(obj, obj->falling); - - while (true) { - obj->falling.ori = (obj->falling.ori + direction) % NUM_ORIENTATIONS; - - // If the new orientation fits, we're done. - if (tg_fits(obj, obj->falling)) - break; - - // Otherwise, try moving left to make it fit. - obj->falling.loc.col--; - if (tg_fits(obj, obj->falling)) - break; - - // Finally, try moving right to make it fit. - obj->falling.loc.col += 2; - if (tg_fits(obj, obj->falling)) - break; - - // Put it back in its original location and try the next orientation. - obj->falling.loc.col--; - // Worst case, we come back to the original orientation and it fits, so this - // loop will terminate. - } - - tg_put(obj, obj->falling); -} - -/* - Swap the falling block with the block in the hold buffer. - */ -static void tg_hold(tetris_game *obj) -{ - tg_remove(obj, obj->falling); - if (obj->stored.typ == -1) { - obj->stored = obj->falling; - tg_new_falling(obj); - } else { - int typ = obj->falling.typ, ori = obj->falling.ori; - obj->falling.typ = obj->stored.typ; - obj->falling.ori = obj->stored.ori; - obj->stored.typ = typ; - obj->stored.ori = ori; - while (!tg_fits(obj, obj->falling)) { - obj->falling.loc.row--; - } - } - tg_put(obj, obj->falling); -} - -/* - Perform the action specified by the move. - */ -static void tg_handle_move(tetris_game *obj, tetris_move move) -{ - switch (move) { - case TM_LEFT: - tg_move(obj, -1); - break; - case TM_RIGHT: - tg_move(obj, 1); - break; - case TM_DROP: - tg_down(obj); - break; - case TM_CLOCK: - tg_rotate(obj, 1); - break; - case TM_COUNTER: - tg_rotate(obj, -1); - break; - case TM_HOLD: - tg_hold(obj); - break; - default: - // pass - break; - } -} - -/* - Return true if line i is full. - */ -static bool tg_line_full(tetris_game *obj, int i) -{ - int j; - for (j = 0; j < obj->cols; j++) { - if (TC_IS_EMPTY(tg_get(obj, i, j))) - return false; - } - return true; -} - -/* - Shift every row above r down one. - */ -static void tg_shift_lines(tetris_game *obj, int r) -{ - int i, j; - for (i = r-1; i >= 0; i--) { - for (j = 0; j < obj->cols; j++) { - tg_set(obj, i+1, j, tg_get(obj, i, j)); - tg_set(obj, i, j, TC_EMPTY); - } - } -} - -/* - Find rows that are filled, remove them, shift, and return the number of - cleared rows. - */ -static int tg_check_lines(tetris_game *obj) -{ - int i, nlines = 0; - tg_remove(obj, obj->falling); // don't want to mess up falling block - - for (i = obj->rows-1; i >= 0; i--) { - if (tg_line_full(obj, i)) { - tg_shift_lines(obj, i); - i++; // do this line over again since they're shifted - nlines++; - } - } - - tg_put(obj, obj->falling); // replace - return nlines; -} - -/* - Adjust the score for the game, given how many lines were just cleared. - */ -static void tg_adjust_score(tetris_game *obj, int lines_cleared) -{ - static int line_multiplier[] = {0, 40, 100, 300, 1200}; - obj->points += line_multiplier[lines_cleared] * (obj->level + 1); - if (lines_cleared >= obj->lines_remaining) { - obj->level = MIN(MAX_LEVEL, obj->level + 1); - lines_cleared -= obj->lines_remaining; - obj->lines_remaining = LINES_PER_LEVEL - lines_cleared; - } else { - obj->lines_remaining -= lines_cleared; - } -} - -/* - Return true if the game is over. - */ -static bool tg_game_over(tetris_game *obj) -{ - int i, j; - bool over = false; - tg_remove(obj, obj->falling); - for (i = 0; i < 2; i++) { - for (j = 0; j < obj->cols; j++) { - if (TC_IS_FILLED(tg_get(obj, i, j))) { - over = true; - } - } - } - tg_put(obj, obj->falling); - return over; -} - -/******************************************************************************* - Main Public Functions - *******************************************************************************/ - -/* - Do a single game tick: process gravity, user input, and score. Return true if - the game is still running, false if it is over. - */ -bool tg_tick(tetris_game *obj, tetris_move move) -{ - int lines_cleared; - // Handle gravity. - tg_do_gravity_tick(obj); - - // Handle input. - tg_handle_move(obj, move); - - // Check for cleared lines - lines_cleared = tg_check_lines(obj); - - tg_adjust_score(obj, lines_cleared); - - // Return whether the game will continue (NOT whether it's over) - return !tg_game_over(obj); -} - -void tg_init(tetris_game *obj, int rows, int cols) -{ - // Initialization logic - obj->rows = rows; - obj->cols = cols; - obj->board = (char *)malloc(rows * cols); - memset(obj->board, TC_EMPTY, rows * cols); - obj->points = 0; - obj->level = 0; - obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; - obj->lines_remaining = LINES_PER_LEVEL; - srand(time(NULL)); - tg_new_falling(obj); - tg_new_falling(obj); - obj->stored.typ = -1; - obj->stored.ori = 0; - obj->stored.loc.row = 0; - obj->next.loc.col = obj->cols/2 - 2; - printf("%d", obj->falling.loc.col); -} - -tetris_game *tg_create(int rows, int cols) -{ - tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); - tg_init(obj, rows, cols); - return obj; -} - -void tg_destroy(tetris_game *obj) -{ - // Cleanup logic - free(obj->board); -} - -void tg_delete(tetris_game *obj) { - tg_destroy(obj); - free(obj); -} - -/* - Load a game from a file. - */ -tetris_game *tg_load(FILE *f) -{ - tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); - if (fread(obj, sizeof(tetris_game), 1, f) != 1 ) - { - fprintf(stderr,"read game error\n"); - free(obj); - obj = 0; - } - else - { - obj->board = (char *)malloc(obj->rows * obj->cols); - if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) - { - fprintf(stderr,"fread error\n"); - free(obj->board); - free(obj); - obj = 0; - } - } - return obj; -} - -/* - Save a game to a file. - */ -void tg_save(tetris_game *obj, FILE *f) -{ - if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) - fprintf(stderr,"error writing tetrisgame\n"); - else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) - fprintf(stderr,"error writing board\n"); -} - -/* - Print a game board to a file. Really just for early debugging. - */ -void tg_print(tetris_game *obj, FILE *f) { - int i, j; - for (i = 0; i < obj->rows; i++) { - for (j = 0; j < obj->cols; j++) { - if (TC_IS_EMPTY(tg_get(obj, i, j))) { - fputs(TC_EMPTY_STR, f); - } else { - fputs(TC_BLOCK_STR, f); - } - } - fputc('\n', f); - } -} - -/* - 2 columns per cell makes the game much nicer. - */ -#define COLS_PER_CELL 2 -/* - Macro to print a cell of a specific type to a window. - */ -#define ADD_BLOCK(w,x) waddch((w),' '|A_REVERSE|COLOR_PAIR(x)); \ -waddch((w),' '|A_REVERSE|COLOR_PAIR(x)) -#define ADD_EMPTY(w) waddch((w), ' '); waddch((w), ' ') - -/* - Print the tetris board onto the ncurses window. - */ -void display_board(WINDOW *w, tetris_game *obj) -{ - int i, j; - box(w, 0, 0); - for (i = 0; i < obj->rows; i++) { - wmove(w, 1 + i, 1); - for (j = 0; j < obj->cols; j++) { - if (TC_IS_FILLED(tg_get(obj, i, j))) { - ADD_BLOCK(w,tg_get(obj, i, j)); - } else { - ADD_EMPTY(w); - } - } - } - wnoutrefresh(w); -} - -/* - Display a tetris piece in a dedicated window. - */ -void display_piece(WINDOW *w, tetris_block block) -{ - int b; - tetris_location c; - wclear(w); - box(w, 0, 0); - if (block.typ == -1) { - wnoutrefresh(w); - return; - } - for (b = 0; b < TETRIS; b++) { - c = TETROMINOS[block.typ][block.ori][b]; - wmove(w, c.row + 1, c.col * COLS_PER_CELL + 1); - ADD_BLOCK(w, TYPE_TO_CELL(block.typ)); - } - wnoutrefresh(w); -} - -/* - Display score information in a dedicated window. - */ -void display_score(WINDOW *w, tetris_game *tg) -{ - wclear(w); - box(w, 0, 0); - wprintw(w, (char *)"Score\n%d\n", tg->points); - wprintw(w, (char *)"Level\n%d\n", tg->level); - wprintw(w, (char *)"Lines\n%d\n", tg->lines_remaining); - wnoutrefresh(w); -} - -/* - Save and exit the game. - */ -void save(tetris_game *game, WINDOW *w) -{ - FILE *f; - - wclear(w); - box(w, 0, 0); // return the border - wmove(w, 1, 1); - wprintw(w, (char *)"Save and exit? [Y/n] "); - wrefresh(w); - timeout(-1); - if (getch() == 'n') { - timeout(0); - return; - } - f = fopen("tetris.save", "w"); - tg_save(game, f); - fclose(f); - tg_delete(game); - endwin(); - fprintf(stderr,"Game saved to \"tetris.save\".\n"); - fprintf(stderr,"Resume by passing the filename as an argument to this program.\n"); - exit(EXIT_SUCCESS); -} - -/* - Do the NCURSES initialization steps for color blocks. - */ -void init_colors(void) -{ - start_color(); - //init_color(COLOR_ORANGE, 1000, 647, 0); - init_pair(TC_CELLI, COLOR_CYAN, COLOR_BLACK); - init_pair(TC_CELLJ, COLOR_BLUE, COLOR_BLACK); - init_pair(TC_CELLL, COLOR_WHITE, COLOR_BLACK); - init_pair(TC_CELLO, COLOR_YELLOW, COLOR_BLACK); - init_pair(TC_CELLS, COLOR_GREEN, COLOR_BLACK); - init_pair(TC_CELLT, COLOR_MAGENTA, COLOR_BLACK); - init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); -} - -/* - Main tetris game! - */ -#ifdef STANDALONE -char *clonestr(char *str) -{ - char *clone; int32_t len; - if ( str == 0 || str[0] == 0 ) - { - printf("warning cloning nullstr.%p\n",str); -#ifdef __APPLE__ - while ( 1 ) sleep(1); -#endif - str = (char *)""; - } - len = strlen(str); - clone = (char *)calloc(1,len+16); - strcpy(clone,str); - return(clone); -} - -int tetris(int argc, char **argv) -{ - tetris_game *tg; - tetris_move move = TM_NONE; - bool running = true; - WINDOW *board, *next, *hold, *score; - int32_t c,skipcount=0; bits256 gametxid; uint32_t eventid = 0; - memset(&gametxid,0,sizeof(gametxid)); - // Load file if given a filename. - if (argc >= 2) { - FILE *f = fopen(argv[1], "r"); - if (f == NULL) { - perror("tetris"); - exit(EXIT_FAILURE); - } - tg = tg_load(f); - fclose(f); - } else { - // Otherwise create new game. - tg = tg_create(22, 10); - } - // NCURSES initialization: - initscr(); // initialize curses - cbreak(); // pass key presses to program, but not signals - noecho(); // don't echo key presses to screen - keypad(stdscr, TRUE); // allow arrow keys - timeout(0); // no blocking on getch() - curs_set(0); // set the cursor to invisible - init_colors(); // setup tetris colors - - // Create windows for each section of the interface. - board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); - next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); - hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); - score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); - int32_t counter = 0; - // Game loop - while (running) { - running = tg_tick(tg, move); - display_board(board, tg); - display_piece(next, tg->next); - display_piece(hold, tg->stored); - display_score(score, tg); - if ( (counter++ % 5) == 0 ) - doupdate(); - sleep_milli(10); - c = getch(); - if ( c != -1 || skipcount == 0x3fff ) - { - if ( skipcount > 0 ) - issue_games_events(gametxid,eventid-skipcount,skipcount | 0x4000); - if ( c != -1 ) - issue_games_events(gametxid,eventid,c); - skipcount = 0; - } else skipcount++; - eventid++; - switch ( c ) - { - case KEY_LEFT: - move = TM_LEFT; - break; - case KEY_RIGHT: - move = TM_RIGHT; - break; - case KEY_UP: - move = TM_CLOCK; - break; - case KEY_DOWN: - move = TM_DROP; - break; - case 'q': - running = false; - move = TM_NONE; - break; - case 'p': - wclear(board); - box(board, 0, 0); - wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); - wprintw(board, "PAUSED"); - wrefresh(board); - timeout(-1); - getch(); - timeout(0); - move = TM_NONE; - break; - case 's': - save(tg, board); - move = TM_NONE; - break; - case ' ': - move = TM_HOLD; - break; - default: - move = TM_NONE; - } - } - - // Deinitialize NCurses - wclear(stdscr); - endwin(); - // Output ending message. - printf("Game over!\n"); - printf("You finished with %d points on level %d.\n", tg->points, tg->level); - - // Deinitialize Tetris - tg_delete(tg); - return 0; -} - -int32_t games_replay(uint64_t seed,int32_t sleeptime) -{ - return(-1); -} +#include "tetris.c" #endif diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 19e5f8d26..07a1f8e65 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -20,7 +20,7 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define GAMES_MAXKEYSTROKESGAP 60 #define GAMES_MAXPLAYERS 64 #define GAMES_REGISTRATIONSIZE (100 * 10000) -#define GAMES_REGISTRATION 5 +#define GAMES_REGISTRATION 1 #define GAMES_RNGMULT 11109 #define GAMES_RNGOFFSET 13849 @@ -29,7 +29,6 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define MYCCNAME "games" std::string Games_pname; -#define GAMENAME "sudoku" #define RPC_FUNCS \ { (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \ @@ -104,33 +103,4 @@ if ( cp->evalcode == EVAL_GAMES ) \ } #endif -#define MAXPACK 23 -struct games_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; - -struct games_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; - struct games_packitem gamespack[MAXPACK]; -}; - -struct games_state -{ - uint64_t seed; - char *keystrokes,*keystrokeshex; - uint32_t needflush,replaydone; - int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; - FILE *logfp; - struct games_player P; - char buffered[10000]; - uint8_t playerdata[10000]; -}; - -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); -void games_packitemstr(char *packitemstr,struct games_packitem *item); - - #endif diff --git a/src/cc/tetris.c b/src/cc/tetris.c new file mode 100644 index 000000000..4ffd27575 --- /dev/null +++ b/src/cc/tetris.c @@ -0,0 +1,758 @@ + +#include "tetris.h" +#include "dapps/dappstd.c" + + +/***************************************************************************/ +/** https://github.com/brenns10/tetris + @file main.c + @author Stephen Brennan + @date Created Wednesday, 10 June 2015 + @brief Main program for tetris. + @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised + BSD License. See LICENSE.txt for details. + *******************************************************************************/ + + +#include // for FILE +#include // for bool +#include +#include +#include +#include +#include +#include + +#ifdef BUILD_GAMESCC +#include "rogue/cursesd.h" +#else +#include +#endif + + +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) + +/******************************************************************************* + Array Definitions + *******************************************************************************/ + +const tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS] = +{ + // I + {{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, + {{0, 2}, {1, 2}, {2, 2}, {3, 2}}, + {{3, 0}, {3, 1}, {3, 2}, {3, 3}}, + {{0, 1}, {1, 1}, {2, 1}, {3, 1}}}, + // J + {{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, + {{0, 1}, {1, 1}, {2, 0}, {2, 1}}}, + // L + {{{0, 2}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, + {{0, 0}, {0, 1}, {1, 1}, {2, 1}}}, + // O + {{{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}}, + // S + {{{0, 1}, {0, 2}, {1, 0}, {1, 1}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 2}}, + {{1, 1}, {1, 2}, {2, 0}, {2, 1}}, + {{0, 0}, {1, 0}, {1, 1}, {2, 1}}}, + // T + {{{0, 1}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 1}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 1}}}, + // Z + {{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, + {{0, 2}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {2, 1}, {2, 2}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 0}}}, +}; + +const int GRAVITY_LEVEL[MAX_LEVEL+1] = { + // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + //10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 30, 28, 26, 24, 22, 20, 16, 12, 8, 4 +}; + +/******************************************************************************* + Helper Functions for Blocks + *******************************************************************************/ + +void sleep_milli(int milliseconds) +{ + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = milliseconds * 1000 * 1000; + nanosleep(&ts, NULL); +} + +/* + Return the block at the given row and column. + */ +char tg_get(tetris_game *obj, int row, int column) +{ + return obj->board[obj->cols * row + column]; +} + +/* + Set the block at the given row and column. + */ +static void tg_set(tetris_game *obj, int row, int column, char value) +{ + obj->board[obj->cols * row + column] = value; +} + +/* + Check whether a row and column are in bounds. + */ +bool tg_check(tetris_game *obj, int row, int col) +{ + return 0 <= row && row < obj->rows && 0 <= col && col < obj->cols; +} + +/* + Place a block onto the board. + */ +static void tg_put(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, + TYPE_TO_CELL(block.typ)); + } +} + +/* + Clear a block out of the board. + */ +static void tg_remove(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, TC_EMPTY); + } +} + +/* + Check if a block can be placed on the board. + */ +static bool tg_fits(tetris_game *obj, tetris_block block) +{ + int i, r, c; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + r = block.loc.row + cell.row; + c = block.loc.col + cell.col; + if (!tg_check(obj, r, c) || TC_IS_FILLED(tg_get(obj, r, c))) { + return false; + } + } + return true; +} + +/* + Create a new falling block and populate the next falling block with a random + one. + */ +static void tg_new_falling(tetris_game *obj) +{ + // Put in a new falling tetromino. + obj->falling = obj->next; + obj->next.typ = random_tetromino(); + obj->next.ori = 0; + obj->next.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; +} + +/******************************************************************************* + Game Turn Helpers + *******************************************************************************/ + +/* + Tick gravity, and move the block down if gravity should act. + */ +static void tg_do_gravity_tick(tetris_game *obj) +{ + obj->ticks_till_gravity--; + if (obj->ticks_till_gravity <= 0) { + tg_remove(obj, obj->falling); + obj->falling.loc.row++; + if (tg_fits(obj, obj->falling)) { + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + } else { + obj->falling.loc.row--; + tg_put(obj, obj->falling); + + tg_new_falling(obj); + } + tg_put(obj, obj->falling); + } +} + +/* + Move the falling tetris block left (-1) or right (+1). + */ +static void tg_move(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + obj->falling.loc.col += direction; + if (!tg_fits(obj, obj->falling)) { + obj->falling.loc.col -= direction; + } + tg_put(obj, obj->falling); +} + +/* + Send the falling tetris block to the bottom. + */ +static void tg_down(tetris_game *obj) +{ + tg_remove(obj, obj->falling); + while (tg_fits(obj, obj->falling)) { + obj->falling.loc.row++; + } + obj->falling.loc.row--; + tg_put(obj, obj->falling); + tg_new_falling(obj); +} + +/* + Rotate the falling block in either direction (+/-1). + */ +static void tg_rotate(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + + while (true) { + obj->falling.ori = (obj->falling.ori + direction) % NUM_ORIENTATIONS; + + // If the new orientation fits, we're done. + if (tg_fits(obj, obj->falling)) + break; + + // Otherwise, try moving left to make it fit. + obj->falling.loc.col--; + if (tg_fits(obj, obj->falling)) + break; + + // Finally, try moving right to make it fit. + obj->falling.loc.col += 2; + if (tg_fits(obj, obj->falling)) + break; + + // Put it back in its original location and try the next orientation. + obj->falling.loc.col--; + // Worst case, we come back to the original orientation and it fits, so this + // loop will terminate. + } + + tg_put(obj, obj->falling); +} + +/* + Swap the falling block with the block in the hold buffer. + */ +static void tg_hold(tetris_game *obj) +{ + tg_remove(obj, obj->falling); + if (obj->stored.typ == -1) { + obj->stored = obj->falling; + tg_new_falling(obj); + } else { + int typ = obj->falling.typ, ori = obj->falling.ori; + obj->falling.typ = obj->stored.typ; + obj->falling.ori = obj->stored.ori; + obj->stored.typ = typ; + obj->stored.ori = ori; + while (!tg_fits(obj, obj->falling)) { + obj->falling.loc.row--; + } + } + tg_put(obj, obj->falling); +} + +/* + Perform the action specified by the move. + */ +static void tg_handle_move(tetris_game *obj, tetris_move move) +{ + switch (move) { + case TM_LEFT: + tg_move(obj, -1); + break; + case TM_RIGHT: + tg_move(obj, 1); + break; + case TM_DROP: + tg_down(obj); + break; + case TM_CLOCK: + tg_rotate(obj, 1); + break; + case TM_COUNTER: + tg_rotate(obj, -1); + break; + case TM_HOLD: + tg_hold(obj); + break; + default: + // pass + break; + } +} + +/* + Return true if line i is full. + */ +static bool tg_line_full(tetris_game *obj, int i) +{ + int j; + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) + return false; + } + return true; +} + +/* + Shift every row above r down one. + */ +static void tg_shift_lines(tetris_game *obj, int r) +{ + int i, j; + for (i = r-1; i >= 0; i--) { + for (j = 0; j < obj->cols; j++) { + tg_set(obj, i+1, j, tg_get(obj, i, j)); + tg_set(obj, i, j, TC_EMPTY); + } + } +} + +/* + Find rows that are filled, remove them, shift, and return the number of + cleared rows. + */ +static int tg_check_lines(tetris_game *obj) +{ + int i, nlines = 0; + tg_remove(obj, obj->falling); // don't want to mess up falling block + + for (i = obj->rows-1; i >= 0; i--) { + if (tg_line_full(obj, i)) { + tg_shift_lines(obj, i); + i++; // do this line over again since they're shifted + nlines++; + } + } + + tg_put(obj, obj->falling); // replace + return nlines; +} + +/* + Adjust the score for the game, given how many lines were just cleared. + */ +static void tg_adjust_score(tetris_game *obj, int lines_cleared) +{ + static int line_multiplier[] = {0, 40, 100, 300, 1200}; + obj->points += line_multiplier[lines_cleared] * (obj->level + 1); + if (lines_cleared >= obj->lines_remaining) { + obj->level = MIN(MAX_LEVEL, obj->level + 1); + lines_cleared -= obj->lines_remaining; + obj->lines_remaining = LINES_PER_LEVEL - lines_cleared; + } else { + obj->lines_remaining -= lines_cleared; + } +} + +/* + Return true if the game is over. + */ +static bool tg_game_over(tetris_game *obj) +{ + int i, j; + bool over = false; + tg_remove(obj, obj->falling); + for (i = 0; i < 2; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + over = true; + } + } + } + tg_put(obj, obj->falling); + return over; +} + +/******************************************************************************* + Main Public Functions + *******************************************************************************/ + +/* + Do a single game tick: process gravity, user input, and score. Return true if + the game is still running, false if it is over. + */ +bool tg_tick(tetris_game *obj, tetris_move move) +{ + int lines_cleared; + // Handle gravity. + tg_do_gravity_tick(obj); + + // Handle input. + tg_handle_move(obj, move); + + // Check for cleared lines + lines_cleared = tg_check_lines(obj); + + tg_adjust_score(obj, lines_cleared); + + // Return whether the game will continue (NOT whether it's over) + return !tg_game_over(obj); +} + +void tg_init(tetris_game *obj, int rows, int cols) +{ + // Initialization logic + obj->rows = rows; + obj->cols = cols; + obj->board = (char *)malloc(rows * cols); + memset(obj->board, TC_EMPTY, rows * cols); + obj->points = 0; + obj->level = 0; + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + obj->lines_remaining = LINES_PER_LEVEL; + //srand(time(NULL)); + tg_new_falling(obj); + tg_new_falling(obj); + obj->stored.typ = -1; + obj->stored.ori = 0; + obj->stored.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; + printf("%d", obj->falling.loc.col); +} + +tetris_game *tg_create(int rows, int cols) +{ + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); + tg_init(obj, rows, cols); + return obj; +} + +void tg_destroy(tetris_game *obj) +{ + // Cleanup logic + free(obj->board); +} + +void tg_delete(tetris_game *obj) { + tg_destroy(obj); + free(obj); +} + +/* + Load a game from a file. + */ +tetris_game *tg_load(FILE *f) +{ + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); + if (fread(obj, sizeof(tetris_game), 1, f) != 1 ) + { + fprintf(stderr,"read game error\n"); + free(obj); + obj = 0; + } + else + { + obj->board = (char *)malloc(obj->rows * obj->cols); + if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + { + fprintf(stderr,"fread error\n"); + free(obj->board); + free(obj); + obj = 0; + } + } + return obj; +} + +/* + Save a game to a file. + */ +void tg_save(tetris_game *obj, FILE *f) +{ + if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) + fprintf(stderr,"error writing tetrisgame\n"); + else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + fprintf(stderr,"error writing board\n"); +} + +/* + Print a game board to a file. Really just for early debugging. + */ +void tg_print(tetris_game *obj, FILE *f) { + int i, j; + for (i = 0; i < obj->rows; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) { + fputs(TC_EMPTY_STR, f); + } else { + fputs(TC_BLOCK_STR, f); + } + } + fputc('\n', f); + } +} + +/* + 2 columns per cell makes the game much nicer. + */ +#define COLS_PER_CELL 2 +/* + Macro to print a cell of a specific type to a window. + */ +#define ADD_BLOCK(w,x) waddch((w),' '|A_REVERSE|COLOR_PAIR(x)); \ +waddch((w),' '|A_REVERSE|COLOR_PAIR(x)) +#define ADD_EMPTY(w) waddch((w), ' '); waddch((w), ' ') + +/* + Print the tetris board onto the ncurses window. + */ +void display_board(WINDOW *w, tetris_game *obj) +{ + int i, j; + box(w, 0, 0); + for (i = 0; i < obj->rows; i++) { + wmove(w, 1 + i, 1); + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + ADD_BLOCK(w,tg_get(obj, i, j)); + } else { + ADD_EMPTY(w); + } + } + } + wnoutrefresh(w); +} + +/* + Display a tetris piece in a dedicated window. + */ +void display_piece(WINDOW *w, tetris_block block) +{ + int b; + tetris_location c; + wclear(w); + box(w, 0, 0); + if (block.typ == -1) { + wnoutrefresh(w); + return; + } + for (b = 0; b < TETRIS; b++) { + c = TETROMINOS[block.typ][block.ori][b]; + wmove(w, c.row + 1, c.col * COLS_PER_CELL + 1); + ADD_BLOCK(w, TYPE_TO_CELL(block.typ)); + } + wnoutrefresh(w); +} + +/* + Display score information in a dedicated window. + */ +void display_score(WINDOW *w, tetris_game *tg) +{ + wclear(w); + box(w, 0, 0); + wprintw(w, (char *)"Score\n%d\n", tg->points); + wprintw(w, (char *)"Level\n%d\n", tg->level); + wprintw(w, (char *)"Lines\n%d\n", tg->lines_remaining); + wnoutrefresh(w); +} + +/* + Save and exit the game. + */ +void save(tetris_game *game, WINDOW *w) +{ + FILE *f; + + wclear(w); + box(w, 0, 0); // return the border + wmove(w, 1, 1); + wprintw(w, (char *)"Save and exit? [Y/n] "); + wrefresh(w); + timeout(-1); + if (getch() == 'n') { + timeout(0); + return; + } + f = fopen("tetris.save", "w"); + tg_save(game, f); + fclose(f); + tg_delete(game); + endwin(); + fprintf(stderr,"Game saved to \"tetris.save\".\n"); + fprintf(stderr,"Resume by passing the filename as an argument to this program.\n"); + exit(EXIT_SUCCESS); +} + +/* + Do the NCURSES initialization steps for color blocks. + */ +void init_colors(void) +{ + start_color(); + //init_color(COLOR_ORANGE, 1000, 647, 0); + init_pair(TC_CELLI, COLOR_CYAN, COLOR_BLACK); + init_pair(TC_CELLJ, COLOR_BLUE, COLOR_BLACK); + init_pair(TC_CELLL, COLOR_WHITE, COLOR_BLACK); + init_pair(TC_CELLO, COLOR_YELLOW, COLOR_BLACK); + init_pair(TC_CELLS, COLOR_GREEN, COLOR_BLACK); + init_pair(TC_CELLT, COLOR_MAGENTA, COLOR_BLACK); + init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); +} + +/* + Main tetris game! + */ +#ifdef STANDALONE +char *clonestr(char *str) +{ + char *clone; int32_t len; + if ( str == 0 || str[0] == 0 ) + { + printf("warning cloning nullstr.%p\n",str); +#ifdef __APPLE__ + while ( 1 ) sleep(1); +#endif + str = (char *)""; + } + len = strlen(str); + clone = (char *)calloc(1,len+16); + strcpy(clone,str); + return(clone); +} + +int tetris(int argc, char **argv) +{ + tetris_game *tg; + tetris_move move = TM_NONE; + bool running = true; + WINDOW *board, *next, *hold, *score; + int32_t c,skipcount=0; bits256 gametxid; uint32_t eventid = 0; + memset(&gametxid,0,sizeof(gametxid)); + // Load file if given a filename. + if (argc >= 2) { + FILE *f = fopen(argv[1], "r"); + if (f == NULL) { + perror("tetris"); + exit(EXIT_FAILURE); + } + tg = tg_load(f); + fclose(f); + } else { + // Otherwise create new game. + tg = tg_create(22, 10); + } + // NCURSES initialization: + initscr(); // initialize curses + cbreak(); // pass key presses to program, but not signals + noecho(); // don't echo key presses to screen + keypad(stdscr, TRUE); // allow arrow keys + timeout(0); // no blocking on getch() + curs_set(0); // set the cursor to invisible + init_colors(); // setup tetris colors + + // Create windows for each section of the interface. + board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); + next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); + hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); + score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); + int32_t counter = 0; + // Game loop + while (running) { + running = tg_tick(tg, move); + display_board(board, tg); + display_piece(next, tg->next); + display_piece(hold, tg->stored); + display_score(score, tg); + if ( (counter++ % 5) == 0 ) + doupdate(); + sleep_milli(10); + c = getch(); + if ( c != -1 || skipcount == 0x3fff ) + { + if ( skipcount > 0 ) + issue_games_events(gametxid,eventid-skipcount,skipcount | 0x4000); + if ( c != -1 ) + issue_games_events(gametxid,eventid,c); + skipcount = 0; + } else skipcount++; + eventid++; + switch ( c ) + { + case KEY_LEFT: + move = TM_LEFT; + break; + case KEY_RIGHT: + move = TM_RIGHT; + break; + case KEY_UP: + move = TM_CLOCK; + break; + case KEY_DOWN: + move = TM_DROP; + break; + case 'q': + running = false; + move = TM_NONE; + break; + case 'p': + wclear(board); + box(board, 0, 0); + wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); + wprintw(board, "PAUSED"); + wrefresh(board); + timeout(-1); + getch(); + timeout(0); + move = TM_NONE; + break; + case 's': + save(tg, board); + move = TM_NONE; + break; + case ' ': + move = TM_HOLD; + break; + default: + move = TM_NONE; + } + } + + // Deinitialize NCurses + wclear(stdscr); + endwin(); + // Output ending message. + printf("Game over!\n"); + printf("You finished with %d points on level %d.\n", tg->points, tg->level); + + // Deinitialize Tetris + tg_delete(tg); + return 0; +} + +int32_t games_replay(uint64_t seed,int32_t sleeptime) +{ + return(-1); +} diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index d6ae473fe..fd833d7b7 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -1,939 +1,4 @@ -/***************************************************************************/ -/** https://github.com/brenns10/tetris - @file main.c - @author Stephen Brennan - @date Created Wednesday, 10 June 2015 - @brief Main program for tetris. - @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised - BSD License. See LICENSE.txt for details. - *******************************************************************************/ - - -#ifndef TETRIS_H -#define TETRIS_H - -#include // for FILE -#include // for bool -#include -#include -#include -#include -#include - -#include -#include - -//#include -//#include - - -/* - Convert a tetromino type to its corresponding cell. - */ -#define TYPE_TO_CELL(x) ((x)+1) - -/* - Strings for how you would print a tetris board. - */ -#define TC_EMPTY_STR " " -#define TC_BLOCK_STR "\u2588" - -/* - Questions about a tetris cell. - */ -#define TC_IS_EMPTY(x) ((x) == TC_EMPTY) -#define TC_IS_FILLED(x) (!TC_IS_EMPTY(x)) - -/* - How many cells in a tetromino? - */ -#define TETRIS 4 -/* - How many tetrominos? - */ -#define NUM_TETROMINOS 7 -/* - How many orientations of a tetromino? - */ -#define NUM_ORIENTATIONS 4 - -/* - Level constants. - */ -#define MAX_LEVEL 19 -#define LINES_PER_LEVEL 10 - -/* - A "cell" is a 1x1 block within a tetris board. - */ -typedef enum { - TC_EMPTY, TC_CELLI, TC_CELLJ, TC_CELLL, TC_CELLO, TC_CELLS, TC_CELLT, TC_CELLZ -} tetris_cell; - -/* - A "type" is a type/shape of a tetromino. Not including orientation. - */ -typedef enum { - TET_I, TET_J, TET_L, TET_O, TET_S, TET_T, TET_Z -} tetris_type; - -/* - A row,column pair. Negative numbers allowed, because we need them for - offsets. - */ -typedef struct { - int row; - int col; -} tetris_location; - -/* - A "block" is a struct that contains information about a tetromino. - Specifically, what type it is, what orientation it has, and where it is. - */ -typedef struct { - int typ; - int ori; - tetris_location loc; -} tetris_block; - -/* - All possible moves to give as input to the game. - */ -typedef enum { - TM_LEFT, TM_RIGHT, TM_CLOCK, TM_COUNTER, TM_DROP, TM_HOLD, TM_NONE -} tetris_move; - -/* - A game object! - */ -typedef struct { - /* - Game board stuff: - */ - int rows; - int cols; - char *board; - /* - Scoring information: - */ - int points; - int level; - /* - Falling block is the one currently going down. Next block is the one that - will be falling after this one. Stored is the block that you can swap out. - */ - tetris_block falling; - tetris_block next; - tetris_block stored; - /* - Number of game ticks until the block will move down. - */ - int ticks_till_gravity; - /* - Number of lines until you advance to the next level. - */ - int lines_remaining; -} tetris_game; - -/* - This array stores all necessary information about the cells that are filled by - each tetromino. The first index is the type of the tetromino (i.e. shape, - e.g. I, J, Z, etc.). The next index is the orientation (0-3). The final - array contains 4 tetris_location objects, each mapping to an offset from a - point on the upper left that is the tetromino "origin". - */ -extern tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; - -/* - This array tells you how many ticks per gravity by level. Decreases as level - increases, to add difficulty. - */ -extern int GRAVITY_LEVEL[MAX_LEVEL+1]; - -// Data structure manipulation. -void tg_init(tetris_game *obj, int rows, int cols); -tetris_game *tg_create(int rows, int cols); -void tg_destroy(tetris_game *obj); -void tg_delete(tetris_game *obj); -tetris_game *tg_load(FILE *f); -void tg_save(tetris_game *obj, FILE *f); - -// Public methods not related to memory: -char tg_get(tetris_game *obj, int row, int col); -bool tg_check(tetris_game *obj, int row, int col); -bool tg_tick(tetris_game *obj, tetris_move move); -void tg_print(tetris_game *obj, FILE *f); - -#endif // TETRIS_H - - -#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) - -/******************************************************************************* - Array Definitions - *******************************************************************************/ - -tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS] = { - // I - {{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, - {{0, 2}, {1, 2}, {2, 2}, {3, 2}}, - {{3, 0}, {3, 1}, {3, 2}, {3, 3}}, - {{0, 1}, {1, 1}, {2, 1}, {3, 1}}}, - // J - {{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {2, 1}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, - {{0, 1}, {1, 1}, {2, 0}, {2, 1}}}, - // L - {{{0, 2}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, - {{0, 0}, {0, 1}, {1, 1}, {2, 1}}}, - // O - {{{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}}, - // S - {{{0, 1}, {0, 2}, {1, 0}, {1, 1}}, - {{0, 1}, {1, 1}, {1, 2}, {2, 2}}, - {{1, 1}, {1, 2}, {2, 0}, {2, 1}}, - {{0, 0}, {1, 0}, {1, 1}, {2, 1}}}, - // T - {{{0, 1}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {1, 1}, {1, 2}, {2, 1}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 1}}, - {{0, 1}, {1, 0}, {1, 1}, {2, 1}}}, - // Z - {{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, - {{0, 2}, {1, 1}, {1, 2}, {2, 1}}, - {{1, 0}, {1, 1}, {2, 1}, {2, 2}}, - {{0, 1}, {1, 0}, {1, 1}, {2, 0}}}, -}; - -int GRAVITY_LEVEL[MAX_LEVEL+1] = { - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, - //10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 30, 28, 26, 24, 22, 20, 16, 12, 8, 4 -}; - -/******************************************************************************* - Helper Functions for Blocks - *******************************************************************************/ - -void sleep_milli(int milliseconds) -{ - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = milliseconds * 1000 * 1000; - nanosleep(&ts, NULL); -} - -/* - Return the block at the given row and column. - */ -char tg_get(tetris_game *obj, int row, int column) -{ - return obj->board[obj->cols * row + column]; -} - -/* - Set the block at the given row and column. - */ -static void tg_set(tetris_game *obj, int row, int column, char value) -{ - obj->board[obj->cols * row + column] = value; -} - -/* - Check whether a row and column are in bounds. - */ -bool tg_check(tetris_game *obj, int row, int col) -{ - return 0 <= row && row < obj->rows && 0 <= col && col < obj->cols; -} - -/* - Place a block onto the board. - */ -static void tg_put(tetris_game *obj, tetris_block block) -{ - int i; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, - TYPE_TO_CELL(block.typ)); - } -} - -/* - Clear a block out of the board. - */ -static void tg_remove(tetris_game *obj, tetris_block block) -{ - int i; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, TC_EMPTY); - } -} - -/* - Check if a block can be placed on the board. - */ -static bool tg_fits(tetris_game *obj, tetris_block block) -{ - int i, r, c; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - r = block.loc.row + cell.row; - c = block.loc.col + cell.col; - if (!tg_check(obj, r, c) || TC_IS_FILLED(tg_get(obj, r, c))) { - return false; - } - } - return true; -} - -/* - Return a random tetromino type. - */ -static int random_tetromino(void) { - return rand() % NUM_TETROMINOS; -} - -/* - Create a new falling block and populate the next falling block with a random - one. - */ -static void tg_new_falling(tetris_game *obj) -{ - // Put in a new falling tetromino. - obj->falling = obj->next; - obj->next.typ = random_tetromino(); - obj->next.ori = 0; - obj->next.loc.row = 0; - obj->next.loc.col = obj->cols/2 - 2; -} - -/******************************************************************************* - Game Turn Helpers - *******************************************************************************/ - -/* - Tick gravity, and move the block down if gravity should act. - */ -static void tg_do_gravity_tick(tetris_game *obj) -{ - obj->ticks_till_gravity--; - if (obj->ticks_till_gravity <= 0) { - tg_remove(obj, obj->falling); - obj->falling.loc.row++; - if (tg_fits(obj, obj->falling)) { - obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; - } else { - obj->falling.loc.row--; - tg_put(obj, obj->falling); - - tg_new_falling(obj); - } - tg_put(obj, obj->falling); - } -} - -/* - Move the falling tetris block left (-1) or right (+1). - */ -static void tg_move(tetris_game *obj, int direction) -{ - tg_remove(obj, obj->falling); - obj->falling.loc.col += direction; - if (!tg_fits(obj, obj->falling)) { - obj->falling.loc.col -= direction; - } - tg_put(obj, obj->falling); -} - -/* - Send the falling tetris block to the bottom. - */ -static void tg_down(tetris_game *obj) -{ - tg_remove(obj, obj->falling); - while (tg_fits(obj, obj->falling)) { - obj->falling.loc.row++; - } - obj->falling.loc.row--; - tg_put(obj, obj->falling); - tg_new_falling(obj); -} - -/* - Rotate the falling block in either direction (+/-1). - */ -static void tg_rotate(tetris_game *obj, int direction) -{ - tg_remove(obj, obj->falling); - - while (true) { - obj->falling.ori = (obj->falling.ori + direction) % NUM_ORIENTATIONS; - - // If the new orientation fits, we're done. - if (tg_fits(obj, obj->falling)) - break; - - // Otherwise, try moving left to make it fit. - obj->falling.loc.col--; - if (tg_fits(obj, obj->falling)) - break; - - // Finally, try moving right to make it fit. - obj->falling.loc.col += 2; - if (tg_fits(obj, obj->falling)) - break; - - // Put it back in its original location and try the next orientation. - obj->falling.loc.col--; - // Worst case, we come back to the original orientation and it fits, so this - // loop will terminate. - } - - tg_put(obj, obj->falling); -} - -/* - Swap the falling block with the block in the hold buffer. - */ -static void tg_hold(tetris_game *obj) -{ - tg_remove(obj, obj->falling); - if (obj->stored.typ == -1) { - obj->stored = obj->falling; - tg_new_falling(obj); - } else { - int typ = obj->falling.typ, ori = obj->falling.ori; - obj->falling.typ = obj->stored.typ; - obj->falling.ori = obj->stored.ori; - obj->stored.typ = typ; - obj->stored.ori = ori; - while (!tg_fits(obj, obj->falling)) { - obj->falling.loc.row--; - } - } - tg_put(obj, obj->falling); -} - -/* - Perform the action specified by the move. - */ -static void tg_handle_move(tetris_game *obj, tetris_move move) -{ - switch (move) { - case TM_LEFT: - tg_move(obj, -1); - break; - case TM_RIGHT: - tg_move(obj, 1); - break; - case TM_DROP: - tg_down(obj); - break; - case TM_CLOCK: - tg_rotate(obj, 1); - break; - case TM_COUNTER: - tg_rotate(obj, -1); - break; - case TM_HOLD: - tg_hold(obj); - break; - default: - // pass - break; - } -} - -/* - Return true if line i is full. - */ -static bool tg_line_full(tetris_game *obj, int i) -{ - int j; - for (j = 0; j < obj->cols; j++) { - if (TC_IS_EMPTY(tg_get(obj, i, j))) - return false; - } - return true; -} - -/* - Shift every row above r down one. - */ -static void tg_shift_lines(tetris_game *obj, int r) -{ - int i, j; - for (i = r-1; i >= 0; i--) { - for (j = 0; j < obj->cols; j++) { - tg_set(obj, i+1, j, tg_get(obj, i, j)); - tg_set(obj, i, j, TC_EMPTY); - } - } -} - -/* - Find rows that are filled, remove them, shift, and return the number of - cleared rows. - */ -static int tg_check_lines(tetris_game *obj) -{ - int i, nlines = 0; - tg_remove(obj, obj->falling); // don't want to mess up falling block - - for (i = obj->rows-1; i >= 0; i--) { - if (tg_line_full(obj, i)) { - tg_shift_lines(obj, i); - i++; // do this line over again since they're shifted - nlines++; - } - } - - tg_put(obj, obj->falling); // replace - return nlines; -} - -/* - Adjust the score for the game, given how many lines were just cleared. - */ -static void tg_adjust_score(tetris_game *obj, int lines_cleared) -{ - static int line_multiplier[] = {0, 40, 100, 300, 1200}; - obj->points += line_multiplier[lines_cleared] * (obj->level + 1); - if (lines_cleared >= obj->lines_remaining) { - obj->level = MIN(MAX_LEVEL, obj->level + 1); - lines_cleared -= obj->lines_remaining; - obj->lines_remaining = LINES_PER_LEVEL - lines_cleared; - } else { - obj->lines_remaining -= lines_cleared; - } -} - -/* - Return true if the game is over. - */ -static bool tg_game_over(tetris_game *obj) -{ - int i, j; - bool over = false; - tg_remove(obj, obj->falling); - for (i = 0; i < 2; i++) { - for (j = 0; j < obj->cols; j++) { - if (TC_IS_FILLED(tg_get(obj, i, j))) { - over = true; - } - } - } - tg_put(obj, obj->falling); - return over; -} - -/******************************************************************************* - Main Public Functions - *******************************************************************************/ - -/* - Do a single game tick: process gravity, user input, and score. Return true if - the game is still running, false if it is over. - */ -bool tg_tick(tetris_game *obj, tetris_move move) -{ - int lines_cleared; - // Handle gravity. - tg_do_gravity_tick(obj); - - // Handle input. - tg_handle_move(obj, move); - - // Check for cleared lines - lines_cleared = tg_check_lines(obj); - - tg_adjust_score(obj, lines_cleared); - - // Return whether the game will continue (NOT whether it's over) - return !tg_game_over(obj); -} - -void tg_init(tetris_game *obj, int rows, int cols) -{ - // Initialization logic - obj->rows = rows; - obj->cols = cols; - obj->board = (char *)malloc(rows * cols); - memset(obj->board, TC_EMPTY, rows * cols); - obj->points = 0; - obj->level = 0; - obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; - obj->lines_remaining = LINES_PER_LEVEL; - srand(time(NULL)); - tg_new_falling(obj); - tg_new_falling(obj); - obj->stored.typ = -1; - obj->stored.ori = 0; - obj->stored.loc.row = 0; - obj->next.loc.col = obj->cols/2 - 2; - printf("%d", obj->falling.loc.col); -} - -tetris_game *tg_create(int rows, int cols) -{ - tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); - tg_init(obj, rows, cols); - return obj; -} - -void tg_destroy(tetris_game *obj) -{ - // Cleanup logic - free(obj->board); -} - -void tg_delete(tetris_game *obj) { - tg_destroy(obj); - free(obj); -} - -/* - Load a game from a file. - */ -tetris_game *tg_load(FILE *f) -{ - tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); - if (fread(obj, sizeof(tetris_game), 1, f) != 1 ) - { - fprintf(stderr,"read game error\n"); - free(obj); - obj = 0; - } - else - { - obj->board = (char *)malloc(obj->rows * obj->cols); - if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) - { - fprintf(stderr,"fread error\n"); - free(obj->board); - free(obj); - obj = 0; - } - } - return obj; -} - -/* - Save a game to a file. - */ -void tg_save(tetris_game *obj, FILE *f) -{ - if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) - fprintf(stderr,"error writing tetrisgame\n"); - else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) - fprintf(stderr,"error writing board\n"); -} - -/* - Print a game board to a file. Really just for early debugging. - */ -void tg_print(tetris_game *obj, FILE *f) { - int i, j; - for (i = 0; i < obj->rows; i++) { - for (j = 0; j < obj->cols; j++) { - if (TC_IS_EMPTY(tg_get(obj, i, j))) { - fputs(TC_EMPTY_STR, f); - } else { - fputs(TC_BLOCK_STR, f); - } - } - fputc('\n', f); - } -} - -/* - 2 columns per cell makes the game much nicer. - */ -#define COLS_PER_CELL 2 -/* - Macro to print a cell of a specific type to a window. - */ -#define ADD_BLOCK(w,x) waddch((w),' '|A_REVERSE|COLOR_PAIR(x)); \ -waddch((w),' '|A_REVERSE|COLOR_PAIR(x)) -#define ADD_EMPTY(w) waddch((w), ' '); waddch((w), ' ') - -/* - Print the tetris board onto the ncurses window. - */ -void display_board(WINDOW *w, tetris_game *obj) -{ - int i, j; - box(w, 0, 0); - for (i = 0; i < obj->rows; i++) { - wmove(w, 1 + i, 1); - for (j = 0; j < obj->cols; j++) { - if (TC_IS_FILLED(tg_get(obj, i, j))) { - ADD_BLOCK(w,tg_get(obj, i, j)); - } else { - ADD_EMPTY(w); - } - } - } - wnoutrefresh(w); -} - -/* - Display a tetris piece in a dedicated window. - */ -void display_piece(WINDOW *w, tetris_block block) -{ - int b; - tetris_location c; - wclear(w); - box(w, 0, 0); - if (block.typ == -1) { - wnoutrefresh(w); - return; - } - for (b = 0; b < TETRIS; b++) { - c = TETROMINOS[block.typ][block.ori][b]; - wmove(w, c.row + 1, c.col * COLS_PER_CELL + 1); - ADD_BLOCK(w, TYPE_TO_CELL(block.typ)); - } - wnoutrefresh(w); -} - -/* - Display score information in a dedicated window. - */ -void display_score(WINDOW *w, tetris_game *tg) -{ - wclear(w); - box(w, 0, 0); - wprintw(w, "Score\n%d\n", tg->points); - wprintw(w, "Level\n%d\n", tg->level); - wprintw(w, "Lines\n%d\n", tg->lines_remaining); - wnoutrefresh(w); -} - -/* - Boss mode! Make it look like you're doing work. - */ -void boss_mode(void) -{ - clear(); - //Mix_PauseMusic(); - printw("user@workstation-312:~/Documents/presentation $ ls -l\n" - "total 528\n" - "drwxr-xr-x 2 user users 4096 Jun 9 17:05 .\n" - "drwxr-xr-x 4 user users 4096 Jun 10 09:52 ..\n" - "-rw-r--r-- 1 user users 88583 Jun 9 14:13 figure1.png\n" - "-rw-r--r-- 1 user users 65357 Jun 9 15:40 figure2.png\n" - "-rw-r--r-- 1 user users 4469 Jun 9 16:17 presentation.aux\n" - "-rw-r--r-- 1 user users 42858 Jun 9 16:17 presentation.log\n" - "-rw-r--r-- 1 user users 2516 Jun 9 16:17 presentation.nav\n" - "-rw-r--r-- 1 user users 183 Jun 9 16:17 presentation.out\n" - "-rw-r--r-- 1 user users 349607 Jun 9 16:17 presentation.pdf\n" - "-rw-r--r-- 1 user users 0 Jun 9 16:17 presentation.snm\n" - "-rw-r--r-- 1 user users 9284 Jun 9 17:05 presentation.tex\n" - "-rw-r--r-- 1 user users 229 Jun 9 16:17 presentation.toc\n" - "\n" - "user@workstation-312:~/Documents/presentation $ "); - echo(); - timeout(-1); - while (getch() != KEY_F(1)); - timeout(0); - noecho(); - clear(); - //Mix_ResumeMusic(); -} - -/* - Save and exit the game. - */ -void save(tetris_game *game, WINDOW *w) -{ - FILE *f; - - wclear(w); - box(w, 0, 0); // return the border - wmove(w, 1, 1); - wprintw(w, "Save and exit? [Y/n] "); - wrefresh(w); - timeout(-1); - if (getch() == 'n') { - timeout(0); - return; - } - f = fopen("tetris.save", "w"); - tg_save(game, f); - fclose(f); - tg_delete(game); - endwin(); - printf("Game saved to \"tetris.save\".\n"); - printf("Resume by passing the filename as an argument to this program.\n"); - exit(EXIT_SUCCESS); -} - -/* - Do the NCURSES initialization steps for color blocks. - */ -void init_colors(void) -{ - start_color(); - //init_color(COLOR_ORANGE, 1000, 647, 0); - init_pair(TC_CELLI, COLOR_CYAN, COLOR_BLACK); - init_pair(TC_CELLJ, COLOR_BLUE, COLOR_BLACK); - init_pair(TC_CELLL, COLOR_WHITE, COLOR_BLACK); - init_pair(TC_CELLO, COLOR_YELLOW, COLOR_BLACK); - init_pair(TC_CELLS, COLOR_GREEN, COLOR_BLACK); - init_pair(TC_CELLT, COLOR_MAGENTA, COLOR_BLACK); - init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); -} - -/* - Main tetris game! - */ -#ifdef STANDALONE - -int main(int argc, char **argv) -{ - tetris_game *tg; - tetris_move move = TM_NONE; - bool running = true; - WINDOW *board, *next, *hold, *score; - //Mix_Music *music; - - // Load file if given a filename. - if (argc >= 2) { - FILE *f = fopen(argv[1], "r"); - if (f == NULL) { - perror("tetris"); - exit(EXIT_FAILURE); - } - tg = tg_load(f); - fclose(f); - } else { - // Otherwise create new game. - tg = tg_create(22, 10); - } - - /* Initialize music. - if (SDL_Init(SDL_INIT_AUDIO) < 0) { - fprintf(stderr, "unable to initialize SDL\n"); - exit(EXIT_FAILURE); - } - if (Mix_Init(MIX_INIT_MP3) != MIX_INIT_MP3) { - fprintf(stderr, "unable to initialize SDL_mixer\n"); - exit(EXIT_FAILURE); - } - if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) != 0) { - fprintf(stderr, "unable to initialize audio\n"); - exit(EXIT_FAILURE); - } - Mix_AllocateChannels(1); // only need background music - music = Mix_LoadMUS("tetris.mp3"); - if (music) { - Mix_PlayMusic(music, -1); - }*/ - - // NCURSES initialization: - initscr(); // initialize curses - cbreak(); // pass key presses to program, but not signals - noecho(); // don't echo key presses to screen - keypad(stdscr, TRUE); // allow arrow keys - timeout(0); // no blocking on getch() - curs_set(0); // set the cursor to invisible - init_colors(); // setup tetris colors - - // Create windows for each section of the interface. - board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); - next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); - hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); - score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); - int32_t counter = 0; - // Game loop - while (running) { - running = tg_tick(tg, move); - display_board(board, tg); - display_piece(next, tg->next); - display_piece(hold, tg->stored); - display_score(score, tg); - if ( (counter++ % 5) == 0 ) - doupdate(); - sleep_milli(10); - - switch (getch()) { - case KEY_LEFT: - move = TM_LEFT; - break; - case KEY_RIGHT: - move = TM_RIGHT; - break; - case KEY_UP: - move = TM_CLOCK; - break; - case KEY_DOWN: - move = TM_DROP; - break; - case 'q': - running = false; - move = TM_NONE; - break; - case 'p': - wclear(board); - box(board, 0, 0); - wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); - wprintw(board, "PAUSED"); - wrefresh(board); - timeout(-1); - getch(); - timeout(0); - move = TM_NONE; - break; - case 'b': - boss_mode(); - move = TM_NONE; - break; - case 's': - save(tg, board); - move = TM_NONE; - break; - case ' ': - move = TM_HOLD; - break; - default: - move = TM_NONE; - } - } - - // Deinitialize NCurses - wclear(stdscr); - endwin(); - - /* Deinitialize Sound - Mix_HaltMusic(); - Mix_FreeMusic(music); - Mix_CloseAudio(); - Mix_Quit();*/ - - // Output ending message. - printf("Game over!\n"); - printf("You finished with %d points on level %d.\n", tg->points, tg->level); - - // Deinitialize Tetris - tg_delete(tg); - return 0; -} -#else - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -949,973 +14,55 @@ int main(int argc, char **argv) * * ******************************************************************************/ -#include "cJSON.h" -#include "CCinclude.h" +// game specific code for daemon -#define TETRIS_REGISTRATION 5 -#define TETRIS_REGISTRATIONSIZE (100 * 10000) -#define TETRIS_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching -#define TETRIS_MAXKEYSTROKESGAP 60 -#define TETRIS_MAXITERATIONS 777 - - -std::string Tetris_pname = ""; - -CScript tetris_newgameopret(int64_t buyin,int32_t maxplayers) +int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) { - CScript opret; uint8_t evalcode = EVAL_TETRIS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'G' << buyin << maxplayers); - return(opret); -} - -CScript tetris_registeropret(uint256 gametxid,uint256 playertxid) -{ - CScript opret; uint8_t evalcode = EVAL_TETRIS; - //fprintf(stderr,"opret.(%s %s).R\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'R' << gametxid << playertxid); - return(opret); -} - -CScript tetris_keystrokesopret(uint256 gametxid,uint256 batontxid,CPubKey pk,std::vectorkeystrokes) -{ - CScript opret; uint8_t evalcode = EVAL_TETRIS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << 'K' << gametxid << batontxid << pk << keystrokes); - return(opret); -} - -CScript tetris_highlanderopret(uint8_t funcid,uint256 gametxid,int32_t regslot,CPubKey pk,std::vectorplayerdata,std::string pname) -{ - CScript opret; uint8_t evalcode = EVAL_TETRIS; std::string symbol(ASSETCHAINS_SYMBOL); - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << gametxid << symbol << pname << regslot << pk << playerdata ); - return(opret); -} - -uint8_t tetris_highlanderopretdecode(uint256 &gametxid, uint256 &tokenid, int32_t ®slot, CPubKey &pk, std::vector &playerdata, std::string &symbol, std::string &pname,CScript scriptPubKey) -{ - std::string name, description; std::vector vorigPubkey; - std::vector> oprets, opretsDummy; - std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; - uint8_t e, f,*script; std::vector voutPubkeys; - tokenid = zeroid; - GetOpReturnData(scriptPubKey, vopret); - script = (uint8_t *)vopret.data(); - if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description, oprets)) == 'c' ) + uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; + if ( (len= payload.size()) > 36 ) { - GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); - vopret = vopretNonfungible; - } - else if ( script[1] != 'H' && script[1] != 'Q' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, opretsDummy)) != 0 ) - { - //fprintf(stderr,"decode opret %c tokenid.%s\n",script[1],tokenid.GetHex().c_str()); - GetNonfungibleData(tokenid, vopretNonfungible); //load nonfungible data from the 'tokenbase' tx - vopret = vopretNonfungible; - } - if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> gametxid; ss >> symbol; ss >> pname; ss >> regslot; ss >> pk; ss >> playerdata) != 0 && e == EVAL_TETRIS && (f == 'H' || f == 'Q') ) - { - return(f); - } - fprintf(stderr,"SKIP obsolete: e.%d f.%c game.%s regslot.%d psize.%d\n",e,f,gametxid.GetHex().c_str(),regslot,(int32_t)playerdata.size()); - return(0); -} - -uint8_t tetris_keystrokesopretdecode(uint256 &gametxid,uint256 &batontxid,CPubKey &pk,std::vector &keystrokes,CScript scriptPubKey) -{ - std::vector vopret; uint8_t e,f; - GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> batontxid; ss >> pk; ss >> keystrokes) != 0 && e == EVAL_TETRIS && f == 'K' ) - { - return(f); - } - return(0); -} - -uint8_t tetris_registeropretdecode(uint256 &gametxid,uint256 &tokenid,uint256 &playertxid,CScript scriptPubKey) -{ - std::string name, description; std::vector vorigPubkey; - std::vector> oprets; - std::vector vopretNonfungible, vopret, vopretDummy,origpubkey; - uint8_t e, f,*script; std::vector voutPubkeys; - tokenid = zeroid; - GetOpReturnData(scriptPubKey, vopret); - script = (uint8_t *)vopret.data(); - if ( script[1] == 'c' && (f= DecodeTokenCreateOpRet(scriptPubKey,origpubkey,name,description,oprets)) == 'c' ) - { - GetOpretBlob(oprets, OPRETID_NONFUNGIBLEDATA, vopretNonfungible); - vopret = vopretNonfungible; - } - else if ( script[1] != 'R' && (f= DecodeTokenOpRet(scriptPubKey, e, tokenid, voutPubkeys, oprets)) != 0 ) - { - GetOpretBlob(oprets, OPRETID_TETRISGAMEDATA, vopretDummy); // blob from non-creation tx opret - vopret = vopretDummy; - } - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> gametxid; ss >> playertxid) != 0 && e == EVAL_TETRIS && f == 'R' ) - { - return(f); - } - //fprintf(stderr,"e.%d f.%c game.%s playertxid.%s\n",e,f,gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); - return(0); -} - -uint8_t tetris_newgameopreturndecode(int64_t &buyin,int32_t &maxplayers,CScript scriptPubKey) -{ - std::vector vopret; uint8_t e,f; - GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> buyin; ss >> maxplayers) != 0 && e == EVAL_TETRIS && f == 'G' ) - { - return(f); - } - return(0); -} - -void tetris_univalue(UniValue &result,const char *method,int64_t maxplayers,int64_t buyin) -{ - if ( method != 0 ) - { - result.push_back(Pair("name","tetris")); - result.push_back(Pair("method",method)); - } - if ( maxplayers > 0 ) - result.push_back(Pair("maxplayers",maxplayers)); - if ( buyin >= 0 ) - { - result.push_back(Pair("buyin",ValueFromAmount(buyin))); - if ( buyin == 0 ) - result.push_back(Pair("type","newbie")); - else result.push_back(Pair("type","buyin")); - } -} - -int32_t tetris_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx,char *mytetrisaddr) -{ - int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; char destaddr[64]; - for (i=0; i= 0 ) - { - if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) - { - Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); - if ( strcmp(mytetrisaddr,destaddr) == 0 ) - return(1); - //else fprintf(stderr,"myaddr.%s vs %s\n",mytetrisaddr,destaddr); - } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); - } //else fprintf(stderr,"vout %d is unspent\n",vout); - } - return(0); -} - -int32_t tetris_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0) -{ - uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey tetrispk; uint64_t txfee = 10000; - buyin = maxplayers = 0; - if ( (txid == zeroid || myGetTransaction(txid,tx,hashBlock) != 0) && (numvouts= tx.vout.size()) > 1 ) - { - if ( txid != zeroid ) - gameheight = komodo_blockheight(hashBlock); - else - { - txid = tx.GetHash(); - //fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); - } - if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1,0) == txfee) ) - { - if ( tetris_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) - { - if ( maxplayers < 1 || maxplayers > TETRIS_MAXPLAYERS || buyin < 0 ) - return(-6); - if ( numvouts > 2*maxplayers+1 ) - { - for (i=0; i playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) +int64_t games_cashout(struct games_player *P) { - int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct tetris_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; - memset(&P,0,sizeof(P)); - if ( playerdata.size() > 0 ) - { - datastr = (char *)malloc(playerdata.size()*2+1); - for (i=0; i= 0 ) - txid = spenttxid; - else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) - { - fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); - break; - } - txid = spenttxid; - vout = 0; - if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - for (i=0; i TETRIS_MAXITERATIONS ) - break; - } - obj.push_back(Pair("gametxid",gametxid.GetHex())); - if ( txid != playertxid ) - obj.push_back(Pair("batontxid",txid.GetHex())); - obj.push_back(Pair("playertxid",playertxid.GetHex())); - if ( tokenid != zeroid ) - obj.push_back(Pair("tokenid",tokenid.GetHex())); - else obj.push_back(Pair("tokenid",playertxid.GetHex())); - if ( datastr != 0 ) - { - obj.push_back(Pair("data",datastr)); - free(datastr); - } - obj.push_back(Pair("pack",a)); - obj.push_back(Pair("packsize",(int64_t)P.packsize)); - obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); - obj.push_back(Pair("strength",(int64_t)(P.strength&0xffff))); - obj.push_back(Pair("maxstrength",(int64_t)(P.strength>>16))); - obj.push_back(Pair("level",(int64_t)P.level)); - obj.push_back(Pair("experience",(int64_t)P.experience)); - obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); - obj.push_back(Pair("chain",symbol)); - obj.push_back(Pair("pname",pname)); - return(obj); + int32_t dungeonlevel; int64_t mult=10,cashout = 0; + if ( P->amulet != 0 ) + mult *= 5; + dungeonlevel = P->dungeonlevel; + if ( P->amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; + cashout = (uint64_t)P->gold * P->gold * mult * dungeonlevel; + return(cashout); } -int32_t tetris_iterateplayer(uint256 ®istertxid,uint256 firsttxid,int32_t firstvout,uint256 lasttxid) // retrace playertxid vins to reach highlander <- this verifies player is valid and tetris_playerdataspend makes sure it can only be used once -{ - uint256 spenttxid,txid = firsttxid; int32_t spentvini,n,vout = firstvout; - registertxid = zeroid; - if ( vout < 0 ) - return(-1); - n = 0; - while ( (spentvini= myIsutxo_spent(spenttxid,txid,vout)) == 0 ) - { - txid = spenttxid; - vout = spentvini; - if ( registertxid == zeroid ) - registertxid = txid; - if ( ++n >= TETRIS_MAXITERATIONS ) - { - fprintf(stderr,"tetris_iterateplayer n.%d, seems something is wrong\n",n); - return(-2); - } - } - if ( txid == lasttxid ) - return(0); - else - { - fprintf(stderr,"firsttxid.%s/v%d -> %s != last.%s\n",firsttxid.ToString().c_str(),firstvout,txid.ToString().c_str(),lasttxid.ToString().c_str()); - return(-1); - } -} - -/* - playertxid is whoever owns the nonfungible satoshi and it might have been bought and sold many times. - highlander is the game winning tx with the player data and is the only place where the unique player data exists - origplayergame is the gametxid that ends up being won by the highlander and they are linked directly as the highlander tx spends gametxid.vout0 - */ - -int32_t tetris_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint256 &tokenid,CPubKey &pk,std::vector &playerdata,std::string &symbol,std::string &pname,uint256 playertxid) -{ - uint256 origplayertxid,hashBlock,gametxid,registertxid; CTransaction gametx,playertx,highlandertx; std::vector vopret; uint8_t *script,e,f; int32_t i,regslot,gameheight,numvouts,maxplayers; int64_t buyin; - if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 && (numvouts= playertx.vout.size()) > 0 ) - { - if ( (f= tetris_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' ) - { - origplayergame = gametxid; - if ( tokenid != zeroid ) - { - playertxid = tokenid; - if ( myGetTransaction(playertxid,playertx,hashBlock) == 0 || (numvouts= playertx.vout.size()) <= 0 ) - { - fprintf(stderr,"couldnt get tokenid.%s\n",playertxid.GetHex().c_str()); - return(-2); - } - } - if ( tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) - { - //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),tetris_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); - if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && tetris_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) - { - // if registertxid has vin from pk, it can be used - return(0); - } else fprintf(stderr,"hash mismatch or illegal gametxid\n"); - } else fprintf(stderr,"invalid game %s\n",gametxid.GetHex().c_str()); - } //else fprintf(stderr,"invalid player funcid.%c\n",f); - } else fprintf(stderr,"couldnt get playertxid.%s\n",playertxid.GetHex().c_str()); - return(-1); -} - -int32_t tetris_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_t vout,uint256 origplayergame) -{ - int64_t txfee = 10000; CTransaction tx; uint256 hashBlock; - if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation - { - mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); - return(0); - } - else - { - vout = 0; - if ( myGetTransaction(playertxid,tx,hashBlock) != 0 && tx.vout[vout].nValue == 1 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) - { - if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation - { - mtx.vin.push_back(CTxIn(playertxid,vout,CScript())); - return(0); - } - } - return(-1); - } -} - -int32_t tetris_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) -{ - int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; - batonvalue = numkeys = numplayers = batonht = 0; - playertxid = batontxid = zeroid; - for (i=0; i= 0 ) - { - if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) - { - numplayers++; - Getscriptaddress(ccaddr,spenttx.vout[0].scriptPubKey); - if ( strcmp(destaddr,ccaddr) == 0 ) - { - matches++; - regslot = i; - matchtx = spenttx; - } //else fprintf(stderr,"%d+1 doesnt match %s vs %s\n",i,ccaddr,destaddr); - } //else fprintf(stderr,"%d+1 couldnt find spenttx.%s\n",i,spenttxid.GetHex().c_str()); - } //else fprintf(stderr,"%d+1 unspent\n",i); - } - if ( matches == 1 ) - { - numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); - if ( tetris_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) - { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); - if ( tokenid != zeroid ) - active = tokenid; - else active = playertxid; - if ( active == zeroid || tetris_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) - { - txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); - n = 0; - while ( CCgettxout(txid,0,1,0) < 0 ) - { - spenttxid = zeroid; - spentvini = -1; - if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 ) - txid = spenttxid; - else - { - if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid ) - { - fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); - return(-2); - } - } - txid = spenttxid; - //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); - if ( spentvini != 0 ) // game is over? - { - return(0); - } - if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) - { - uint256 g,b; CPubKey p; std::vector k; - if ( tetris_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) - { - keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); - for (i=0; i= TETRIS_MAXITERATIONS ) - { - fprintf(stderr,"tetris_findbaton n.%d, seems something is wrong\n",n); - return(-5); - } - } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); - batontxid = txid; - batonvout = 0; // not vini - // how to detect timeout, bailedout, highlander - hashBlock = zeroid; - if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 0 ) - { - if ( hashBlock == zeroid ) - batonht = komodo_nextheight(); - else if ( (pindex= komodo_blockindex(hashBlock)) == 0 ) - return(-4); - else batonht = pindex->GetHeight(); - batonvalue = batontx.vout[0].nValue; - //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); - return(0); - } else fprintf(stderr,"couldnt find baton\n"); - } else fprintf(stderr,"error with playerdata\n"); - } else fprintf(stderr,"findbaton opret error\n"); - } - return(-1); -} - -int32_t tetris_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametxid,int32_t maxplayers,int32_t gameht,CTransaction gametx) -{ - int32_t i,n,vout,spentvini,registration_open = 0,alive = 0; CTransaction tx; uint256 txid,spenttxid,hashBlock; CBlockIndex *pindex; uint64_t txfee = 10000; - numplayers = openslots = 0; - if ( komodo_nextheight() <= gameht+TETRIS_MAXKEYSTROKESGAP ) - registration_open = 1; - for (i=0; i= 0 ) - txid = spenttxid; - else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,vout) == 0 || spenttxid == zeroid ) - { - fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str()); - break; - } - txid = spenttxid; - vout = 0; - //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); - if ( spentvini != 0 ) - break; - if ( n++ > TETRIS_MAXITERATIONS ) - break; - } - if ( txid != zeroid ) - { - if ( myGetTransaction(txid,tx,hashBlock) != 0 ) - { - if ( (pindex= komodo_blockindex(hashBlock)) != 0 ) - { - if ( pindex->GetHeight() <= gameht+TETRIS_MAXKEYSTROKESGAP ) - alive++; - } - } - } - } - } - else if ( registration_open != 0 ) - openslots++; - } - //fprintf(stderr,"numalive.%d openslots.%d\n",alive,openslots); - return(alive); -} - -uint64_t tetris_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mytetrisaddr) -{ - CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; - if ( myGetTransaction(gametxid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) - { - ht = pindex->GetHeight(); - delay = TETRIS_REGISTRATION * (maxplayers > 1); - obj.push_back(Pair("height",ht)); - obj.push_back(Pair("start",ht+delay)); - if ( komodo_nextheight() > ht+delay ) - { - if ( (pindex= komodo_chainactive(ht+delay)) != 0 ) - { - hashBlock = pindex->GetBlockHash(); - obj.push_back(Pair("starthash",hashBlock.ToString())); - memcpy(&seed,&hashBlock,sizeof(seed)); - seed &= (1LL << 62) - 1; - obj.push_back(Pair("seed",(int64_t)seed)); - if ( tetris_iamregistered(maxplayers,gametxid,tx,mytetrisaddr) > 0 ) - sprintf(cmd,"cc/tetris %llu %s",(long long)seed,gametxid.ToString().c_str()); - else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",ASSETCHAINS_SYMBOL,EVAL_TETRIS,gametxid.ToString().c_str()); - obj.push_back(Pair("run",cmd)); - } - } - obj.push_back(Pair("alive",tetris_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); - obj.push_back(Pair("openslots",openslots)); - obj.push_back(Pair("numplayers",numplayers)); - } - obj.push_back(Pair("maxplayers",maxplayers)); - obj.push_back(Pair("buyin",ValueFromAmount(buyin))); - return(seed); -} - -void tetris_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gametxid,CTransaction gametx,int32_t vout,int32_t maxplayers,char *mytetrisaddr) -{ - // identify if bailout or quit or timed out - uint256 batontxid,spenttxid,gtxid,ptxid,tokenid,hashBlock,playertxid; CTransaction spenttx,batontx; int32_t numplayers,regslot,numkeys,batonvout,batonht,retval; int64_t batonvalue; std::vector playerdata; char destaddr[64]; std::string symbol,pname; - destaddr[0] = 0; - if ( myIsutxo_spent(spenttxid,gametxid,vout) >= 0 ) - { - if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) - Getscriptaddress(destaddr,spenttx.vout[0].scriptPubKey); - } - obj.push_back(Pair("slot",(int64_t)vout-1)); - if ( (retval= tetris_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers,symbol,pname)) == 0 ) - { - if ( CCgettxout(gametxid,maxplayers+vout,1,0) == 10000 ) - { - if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 ) - { - if ( tetris_registeropretdecode(gtxid,tokenid,ptxid,batontx.vout[batontx.vout.size()-1].scriptPubKey) == 'R' && ptxid == playertxid && gtxid == gametxid ) - obj.push_back(Pair("status","registered")); - else obj.push_back(Pair("status","alive")); - } else obj.push_back(Pair("status","error")); - } else obj.push_back(Pair("status","finished")); - obj.push_back(Pair("baton",batontxid.ToString())); - obj.push_back(Pair("tokenid",tokenid.ToString())); - obj.push_back(Pair("batonaddr",destaddr)); - obj.push_back(Pair("ismine",strcmp(mytetrisaddr,destaddr)==0)); - obj.push_back(Pair("batonvout",(int64_t)batonvout)); - obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); - obj.push_back(Pair("batonht",(int64_t)batonht)); - if ( playerdata.size() > 0 ) - obj.push_back(Pair("player",tetris_playerobj(playerdata,playertxid,tokenid,symbol,pname,gametxid))); - } else fprintf(stderr,"findbaton err.%d\n",retval); -} - -int64_t tetris_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTransaction gametx,int32_t maxplayers) -{ - int32_t vout,j,r; int64_t nValue; - if ( gametx.vout.size() > maxplayers+1 ) - { - r = rand() % maxplayers; - for (j=0; j 0 ) - { - result.push_back(Pair("hex",rawtx)); - if ( DecodeHexTx(tx,rawtx) != 0 ) - { - if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) - RelayTransaction(tx); - result.push_back(Pair("txid",tx.GetHash().ToString())); - result.push_back(Pair("result","success")); - } else result.push_back(Pair("error","decode hex")); - } else result.push_back(Pair("error","couldnt finalize CCtx")); - return(result); -} - -UniValue tetris_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey tetrispk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1; - if ( txfee == 0 ) - txfee = 10000; - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - if ( n > 0 ) - { - maxplayers = juint(jitem(params,0),0); - if ( n > 1 ) - buyin = jdouble(jitem(params,1),0) * COIN + 0.0000000049; - } - } - if ( maxplayers < 1 || maxplayers > TETRIS_MAXPLAYERS ) - return(cclib_error(result,"illegal maxplayers")); - mypk = pubkey2pk(Mypubkey()); - tetrispk = GetUnspendable(cp,0); - tetris_univalue(result,"newgame",maxplayers,buyin); - required = (3*txfee + maxplayers*(TETRIS_REGISTRATIONSIZE+txfee)); - if ( (inputsum= AddCClibInputs(cp,mtx,tetrispk,required,16,cp->unspendableCCaddr)) >= required ) - { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,tetrispk)); // for highlander TCBOO creation - for (i=0; ievalcode,TETRIS_REGISTRATIONSIZE,tetrispk,tetrispk)); - for (i=0; ievalcode,txfee,tetrispk,tetrispk)); - if ( (change= inputsum - required) >= txfee ) - mtx.vout.push_back(MakeCC1vout(cp->evalcode,change,tetrispk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tetris_newgameopret(buyin,maxplayers)); - return(tetris_rawtxresult(result,rawtx,1)); - } - else return(cclib_error(result,"illegal maxplayers")); - return(result); -} - -UniValue tetris_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); std::vector playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; std::string symbol,pname; - result.push_back(Pair("result","success")); - tetris_univalue(result,"playerinfo",-1,-1); - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - if ( n > 0 ) - { - playertxid = juint256(jitem(params,0)); - if ( tetris_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) - return(cclib_error(result,"invalid playerdata")); - result.push_back(Pair("player",tetris_playerobj(playerdata,playertxid,tokenid,symbol,pname,origplayergame))); - } else return(cclib_error(result,"no playertxid")); - return(result); - } else return(cclib_error(result,"couldnt reparse params")); -} - -UniValue tetris_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - // vin0 -> TETRIS_REGISTRATIONSIZE 1of2 registration baton from creategame - // vin1 -> optional nonfungible character vout @ - // vin2 -> original creation TCBOO playerdata used - // vin3+ -> buyin - // vout0 -> keystrokes/completion baton - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); char destaddr[64],coinaddr[64]; uint256 tokenid,gametxid,origplayergame,playertxid,hashBlock; int32_t err,maxplayers,gameheight,n,numvouts,vout=1; int64_t inputsum,buyin,CCchange=0; CPubKey pk,mypk,tetrispk,burnpk; CTransaction tx,playertx; std::vector playerdata; std::string rawtx,symbol,pname; bits256 t; - - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY)); - tetrispk = GetUnspendable(cp,0); - tetris_univalue(result,"register",-1,-1); - playertxid = tokenid = zeroid; - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - if ( n > 0 ) - { - gametxid = juint256(jitem(params,0)); - if ( (err= tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1)) == 0 ) - { - if ( n > 1 ) - { - playertxid = juint256(jitem(params,1)); - if ( tetris_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) - return(cclib_error(result,"couldnt extract valid playerdata")); - if ( tokenid != zeroid ) // if it is tokentransfer this will be 0 - vout = 1; - } - if ( komodo_nextheight() > gameheight + TETRIS_MAXKEYSTROKESGAP ) - return(cclib_error(result,"didnt register in time, TETRIS_MAXKEYSTROKESGAP")); - tetris_univalue(result,0,maxplayers,buyin); - GetCCaddress1of2(cp,coinaddr,tetrispk,mypk); - if ( tetris_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) - return(cclib_error(result,"already registered")); - if ( (inputsum= tetris_registrationbaton(mtx,gametxid,tx,maxplayers)) != TETRIS_REGISTRATIONSIZE ) - return(cclib_error(result,"couldnt find available registration baton")); - else if ( playertxid != zeroid && tetris_playerdataspend(mtx,playertxid,vout,origplayergame) < 0 ) - return(cclib_error(result,"couldnt find playerdata to spend")); - else if ( buyin > 0 && AddNormalinputs(mtx,mypk,buyin,64) < buyin ) - return(cclib_error(result,"couldnt find enough normal funds for buyin")); - if ( tokenid != zeroid ) - { - mtx.vin.push_back(CTxIn(tokenid,0)); // spending cc marker as token is burned - char unspendableTokenAddr[64]; uint8_t tokenpriv[32]; struct CCcontract_info *cpTokens, tokensC; - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - CPubKey unspPk = GetUnspendable(cpTokens, tokenpriv); - GetCCaddress(cpTokens, unspendableTokenAddr, unspPk); - CCaddr2set(cp, EVAL_TOKENS, unspPk, tokenpriv, unspendableTokenAddr); - } - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,buyin + inputsum - txfee,tetrispk,mypk)); - GetCCaddress1of2(cp,destaddr,tetrispk,tetrispk); - CCaddr1of2set(cp,tetrispk,tetrispk,cp->CCpriv,destaddr); - mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, burnpk)); - - uint8_t e, funcid; uint256 tid; std::vector voutPubkeys, voutPubkeysEmpty; int32_t didtx = 0; - CScript opretRegister = tetris_registeropret(gametxid, playertxid); - if ( playertxid != zeroid ) - { - voutPubkeysEmpty.push_back(burnpk); - if ( myGetTransaction(playertxid,playertx,hashBlock) != 0 ) - { - std::vector> oprets; - if ( (funcid= DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tid, voutPubkeys, oprets)) != 0) - { // if token in the opret - didtx = 1; - if ( funcid == 'c' ) - tid = tokenid == zeroid ? playertxid : tokenid; - vscript_t vopretRegister; - GetOpReturnData(opretRegister, vopretRegister); - rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, - EncodeTokenOpRet(tid, voutPubkeysEmpty /*=never spent*/, std::make_pair(OPRETID_TETRISGAMEDATA, vopretRegister))); - } - } - } - if ( didtx == 0 ) - rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister); - - return(tetris_rawtxresult(result,rawtx,1)); - } else return(cclib_error(result,"invalid gametxid")); - } else return(cclib_error(result,"no gametxid")); - } else return(cclib_error(result,"couldnt reparse params")); -} - -UniValue tetris_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - // vin0 -> baton from registration or previous keystrokes - // vout0 -> new baton - // opret -> user input chars - // being killed should auto broadcast (possible to be suppressed?) - // respawn to be prevented by including timestamps - int32_t nextheight = komodo_nextheight(); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); - UniValue result(UniValue::VOBJ); CPubKey tetrispk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; - if ( txfee == 0 ) - txfee = 10000; - tetris_univalue(result,"keystrokes",-1,-1); - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) - { - gametxid = juint256(jitem(params,0)); - result.push_back(Pair("gametxid",gametxid.GetHex())); - result.push_back(Pair("keystrokes",keystrokestr)); - keystrokes = ParseHex(keystrokestr); - mypk = pubkey2pk(Mypubkey()); - tetrispk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,destaddr,tetrispk,mypk); - if ( tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1) == 0 ) - { - if ( tetris_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) - { - result.push_back(Pair("batontxid",batontxid.GetHex())); - result.push_back(Pair("playertxid",playertxid.GetHex())); - if ( maxplayers == 1 || nextheight <= batonht+TETRIS_MAXKEYSTROKESGAP ) - { - mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); //this validates user if pk - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,tetrispk,mypk)); - Myprivkey(mypriv); - CCaddr1of2set(cp,tetrispk,mypk,mypriv,destaddr); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tetris_keystrokesopret(gametxid,batontxid,mypk,keystrokes)); - //fprintf(stderr,"KEYSTROKES.(%s)\n",rawtx.c_str()); - return(tetris_rawtxresult(result,rawtx,1)); - } else return(cclib_error(result,"keystrokes tx was too late")); - } else return(cclib_error(result,"couldnt find batontxid")); - } else return(cclib_error(result,"invalid gametxid")); - } else return(cclib_error(result,"couldnt reparse params")); -} - -char *tetris_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *tetrisaddr) -{ - CPubKey tetrispk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct tetris_player P,endP; - tetrispk = GetUnspendable(cp,0); - *numkeysp = 0; - seed = 0; - num = numkeys = 0; - playertxid = zeroid; - str[0] = 0; - if ( (err= tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) - { - if ( (retval= tetris_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,tetrisaddr,numplayers,symbol,pname)) == 0 ) - { - UniValue obj; - seed = tetris_gamefields(obj,maxplayers,buyin,gametxid,tetrisaddr); - //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Tetris_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); - memset(&P,0,sizeof(P)); - if ( playerdata.size() > 0 ) - { - for (i=0; i no playerdata\n"); - newdata.resize(0); - *numkeysp = numkeys; - return(keystrokes); - /* P.gold = (P.gold * 8) / 10; - if ( keystrokes != 0 ) - { - free(keystrokes); - keystrokes = 0; - *numkeysp = 0; - return(keystrokes); - }*/ - } - else - { - sprintf(str,"$$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); - //fprintf(stderr,"%s\n",str); - *numkeysp = numkeys; - return(keystrokes); - } - } else num = 0; - } - else - { - fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); - if ( keystrokes != 0 ) - free(keystrokes), keystrokes = 0; - } - } else fprintf(stderr,"extractgame: invalid game\n"); - //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); - return(0); -} - -UniValue tetris_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); CPubKey pk,tetrispk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],tetrisaddr[64],*pubstr,*hexstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; - pk = pubkey2pk(Mypubkey()); - tetrispk = GetUnspendable(cp,0); - result.push_back(Pair("name","tetris")); - result.push_back(Pair("method","extract")); - tetrisaddr[0] = 0; - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - if ( n > 0 ) - { - gametxid = juint256(jitem(params,0)); - result.push_back(Pair("gametxid",gametxid.GetHex())); - if ( n == 2 ) - { - if ( (pubstr= jstr(jitem(params,1),0)) != 0 ) - { - if (strlen(pubstr) == 66 ) - { - decode_hex(pub33,33,pubstr); - pk = buf2pk(pub33); - } - else if ( strlen(pubstr) < 36 ) - strcpy(tetrisaddr,pubstr); - } - //fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); - } - if ( tetrisaddr[0] == 0 ) - GetCCaddress1of2(cp,tetrisaddr,tetrispk,pk); - result.push_back(Pair("tetrisaddr",tetrisaddr)); - str[0] = 0; - if ( (keystrokes= tetris_extractgame(1,str,&numkeys,newdata,seed,playertxid,cp,gametxid,tetrisaddr)) != 0 ) - { - result.push_back(Pair("status","success")); - flag = 1; - hexstr = (char *)malloc(numkeys*2 + 1); - for (i=0; i playerdata,uint256 gametxid,CPubKey pk) +int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,tetrisaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed,mult = 10; CPubKey tetrispk; struct tetris_player P; + char str[512],*keystrokes,gamesaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; *cashoutp = 0; - tetrispk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,tetrisaddr,tetrispk,pk); - //fprintf(stderr,"call extractgame\n"); - if ( (keystrokes= tetris_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,tetrisaddr)) != 0 ) + gamespk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,gamesaddr,gamespk,pk); + if ( (keystrokes= games_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) { - //fprintf(stderr,"numkeys.%d tetris_extractgame %s\n",numkeys,gametxid.GetHex().c_str()); free(keystrokes); - sprintf(fname,"tetris.%llu.pack",(long long)seed); + sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); remove(fname); - - //fprintf(stderr,"extracted.(%s)\n",str); - for (i=0; i>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,tetrisaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,gamesaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } } - sprintf(fname,"tetris.%llu.pack",(long long)seed); + sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); remove(fname); - //fprintf(stderr,"no keys tetris_extractgame %s\n",gametxid.GetHex().c_str()); + //fprintf(stderr,"no keys games_extractgame %s\n",gametxid.GetHex().c_str()); return(-1); } -UniValue tetris_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,char *method) +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) // replay in daemon { - //vin0 -> highlander vout from creategame TCBOO - //vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 60 blocks since last keystrokes, it is forfeit - //vins2+ -> rest of unspent registration utxo so all newgame vouts are spent - //vout0 -> nonfungible character with pack @ - //vout1 -> 1% ingame gold and all the buyins - - // detect if last to bailout - // vin0 -> kestrokes baton of completed game with Q - // vout0 -> playerdata marker - // vout0 -> 1% ingame gold - // get any playerdata, get all keystrokes, replay game and compare final state - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char mytetrisaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,tetrispk; uint8_t player[10000],mypriv[32],funcid; - struct CCcontract_info *cpTokens, tokensC; - - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - tetrispk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,mytetrisaddr,tetrispk,mypk); - result.push_back(Pair("name","tetris")); - result.push_back(Pair("method",method)); - result.push_back(Pair("mytetrisaddr",mytetrisaddr)); - if ( strcmp(method,"bailout") == 0 ) - { - funcid = 'Q'; - mult = 10; //100000; - } - else - { - funcid = 'H'; - mult = 20; //200000; - } - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - if ( n > 0 ) - { - gametxid = juint256(jitem(params,0)); - result.push_back(Pair("gametxid",gametxid.GetHex())); - if ( (err= tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,1)) == 0 ) - { - if ( tetris_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,mytetrisaddr,numplayers,symbol,pname) == 0 ) - { - UniValue obj; struct tetris_player P; - seed = tetris_gamefields(obj,maxplayers,buyin,gametxid,mytetrisaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Tetris_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); - memset(&P,0,sizeof(P)); - if ( playerdata.size() > 0 ) - { - for (i=0; i 0 ) - { - newdata.resize(num); - for (i=0; i no playerdata\n"); - newdata.resize(0); - //P.gold = (P.gold * 8) / 10; - } - else - { - cpTokens = CCinit(&tokensC, EVAL_TOKENS); - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated - mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); - if ( P.amulet != 0 ) - mult *= 5; - dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 21 ) - dungeonlevel = 21; - cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel; - fprintf(stderr,"\nextracted $$$gold.%d -> %.8f TETRIS hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); - if ( funcid == 'H' && maxplayers > 1 ) - { - if ( P.amulet == 0 ) - { - if ( numplayers != maxplayers ) - return(cclib_error(result,"numplayers != maxplayers")); - else if ( tetris_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) - return(cclib_error(result,"highlander must be a winner or last one standing")); - } - cashout += numplayers * buyin; - } - if ( cashout >= txfee ) - { - if ( (inputsum= AddCClibInputs(cp,mtx,tetrispk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) - CCchange = (inputsum - cashout); - mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - } - } - } - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),tetrispk)); - Myprivkey(mypriv); - CCaddr1of2set(cp,tetrispk,mypk,mypriv,mytetrisaddr); - CScript opret; - if ( pname.size() == 0 ) - pname = Tetris_pname; - if ( newdata.size() == 0 ) - { - opret = tetris_highlanderopret(funcid, gametxid, regslot, mypk, nodata,pname); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,opret); - //fprintf(stderr,"nodata finalizetx.(%s)\n",rawtx.c_str()); - } - else - { - opret = tetris_highlanderopret(funcid, gametxid, regslot, mypk, newdata,pname); - char seedstr[32]; - sprintf(seedstr,"%llu",(long long)seed); - std::vector vopretNonfungible; - GetOpReturnData(opret, vopretNonfungible); - rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), std::string(seedstr), gametxid.GetHex(), vopretNonfungible)); - } - return(tetris_rawtxresult(result,rawtx,1)); - } - result.push_back(Pair("result","success")); - } else fprintf(stderr,"illegal game err.%d\n",err); - } else fprintf(stderr,"parameters only n.%d\n",n); - } - return(result); + return(-1); } -UniValue tetris_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +void games_packitemstr(char *packitemstr,struct games_packitem *item) { - return(tetris_finishgame(txfee,cp,params,"bailout")); + sprintf(packitemstr,"not yet"); } -UniValue tetris_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - return(tetris_finishgame(txfee,cp,params,"highlander")); -} - -UniValue tetris_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char mytetrisaddr[64],str[64]; CPubKey mypk,tetrispk; - result.push_back(Pair("name","tetris")); - result.push_back(Pair("method","gameinfo")); - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - if ( n > 0 ) - { - txid = juint256(jitem(params,0)); - result.push_back(Pair("gametxid",txid.GetHex())); - if ( tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,0) == 0 ) - { - result.push_back(Pair("result","success")); - result.push_back(Pair("gameheight",(int64_t)gameheight)); - mypk = pubkey2pk(Mypubkey()); - tetrispk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,mytetrisaddr,tetrispk,mypk); - //fprintf(stderr,"mytetrisaddr.%s\n",mytetrisaddr); - seed = tetris_gamefields(result,maxplayers,buyin,txid,mytetrisaddr); - result.push_back(Pair("seed",(int64_t)seed)); - for (i=0; i > unspentOutputs; - tetrispk = GetUnspendable(cp,0); - GetCCaddress(cp,coinaddr,tetrispk); - SetCCunspents(unspentOutputs,coinaddr); - nextheight = komodo_nextheight(); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers - continue; - if ( tetris_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,1) == 0 && nextheight <= gameheight+TETRIS_MAXKEYSTROKESGAP ) - { - tetris_playersalive(openslots,numplayers,txid,maxplayers,gameheight,tx); - if ( openslots > 0 ) - a.push_back(txid.GetHex()); - } - } - result.push_back(Pair("result","success")); - tetris_univalue(result,"pending",-1,-1); - result.push_back(Pair("pending",a)); - result.push_back(Pair("numpending",(int64_t)a.size())); - return(result); -} - -UniValue tetris_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey tetrispk,mypk,pk; std::string symbol,pname; char coinaddr[64]; - std::vector > unspentOutputs; - tetrispk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - GetTokensCCaddress(cp,coinaddr,mypk); - SetCCunspents(unspentOutputs,coinaddr); - tetris_univalue(result,"players",-1,-1); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( it->second.satoshis != 1 || vout > 1 ) - continue; - if ( tetris_playerdata(cp,gametxid,tokenid,pk,playerdata,symbol,pname,txid) == 0 )//&& pk == mypk ) - { - a.push_back(txid.GetHex()); - //a.push_back(Pair("playerdata",tetris_playerobj(playerdata))); - } - } - result.push_back(Pair("playerdata",a)); - result.push_back(Pair("numplayerdata",(int64_t)a.size())); - return(result); -} - -UniValue tetris_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey tetrispk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; - std::vector > addressIndex; - //std::vector > unspentOutputs; - tetrispk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - GetCCaddress1of2(cp,coinaddr,tetrispk,mypk); - //SetCCunspents(unspentOutputs,coinaddr); - SetCCtxids(addressIndex,coinaddr); - tetris_univalue(result,"games",-1,-1); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( vout == 0 ) - { - if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - if ( tetris_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) - { - if ( tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) - { - if ( CCgettxout(txid,vout,1,0) < 0 ) - b.push_back(gametxid.GetHex()); - else a.push_back(gametxid.GetHex()); - } - } - } - } - } - result.push_back(Pair("pastgames",b)); - result.push_back(Pair("games",a)); - result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); - return(result); -} - -UniValue tetris_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); int32_t n; char *namestr = 0; - tetris_univalue(result,"setname",-1,-1); - if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) - { - if ( n > 0 ) - { - if ( (namestr= jstri(params,0)) != 0 ) - { - result.push_back(Pair("result","success")); - result.push_back(Pair("pname",namestr)); - tetris_pname = namestr; - return(result); - } - } - } - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt get name")); - return(result); -} - -bool tetris_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) -{ - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,enabled = 0,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; - if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 ) - { - if (height < 21274 ) - return(true); - else if ( height > 50000 ) - enabled = 1; - } else enabled = 1; - if ( (numvouts= tx.vout.size()) > 1 ) - { - txid = tx.GetHash(); - scriptPubKey = tx.vout[numvouts-1].scriptPubKey; - GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 ) - { - script = (uint8_t *)vopret.data(); - funcid = script[1]; - if ( (e= script[0]) == EVAL_TOKENS ) - { - tokentx = funcid; - if ( (funcid= tetris_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) - { - if ( (funcid= tetris_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) - { - fprintf(stderr,"ht.%d couldnt decode tokens opret (%c)\n",height,script[1]); - } else e = EVAL_TETRIS, decoded = 1; - } else e = EVAL_TETRIS, decoded = 1; - } - if ( e == EVAL_TETRIS ) - { - //fprintf(stderr,"ht.%d tetris.(%c)\n",height,script[1]); - if ( decoded == 0 ) - { - switch ( funcid ) - { - case 'G': // seems just need to make sure no vout abuse is left to do - gametx = tx; - gametxid = tx.GetHash(); - gameheight = height; - if ( (err= tetris_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,zeroid,0)) != 0 ) - { - fprintf(stderr,"height.%d %s tetris_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); - return eval->Invalid("invalid gametxid"); - } - //fprintf(stderr,"height.%d %s tetris_isvalidgame\n",height,gametxid.GetHex().c_str()); - return(true); - break; - case 'R': - if ( (funcid= tetris_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' ) - { - return eval->Invalid("couldnt decode register opret"); - } - // baton is created - // validation is done below - break; - case 'K': - if ( (funcid= tetris_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' ) - { - return eval->Invalid("couldnt decode keystrokes opret"); - } - // spending the baton proves it is the user if the pk is the signer - return(true); - break; - case 'H': case 'Q': - // done in the next switch statement as there are some H/Q tx with playerdata which would skip this section - break; - default: - return eval->Invalid("illegal tetris non-decoded funcid"); - break; - } - } - switch ( funcid ) - { - case 'R': // register - // verify vout amounts are as they should be and no vins that shouldnt be - return(true); - case 'H': // win - case 'Q': // bailout - if ( (f= tetris_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) - { - //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); - //if ( height > 20000 ) - return eval->Invalid("couldnt decode H/Q opret"); - } - // verify pk belongs to this tx - if ( tokentx == 'c' && playerdata.size() > 0 ) - { - static char laststr[512]; char cashstr[512]; - if ( tetris_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) - { - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); - if ( strcmp(laststr,cashstr) != 0 ) - { - strcpy(laststr,cashstr); - fprintf(stderr,"%s\n",cashstr); - } - if ( enabled != 0 ) - return eval->Invalid("mismatched playerdata"); - } - if ( funcid == 'H' ) - cashout *= 2; - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); - if ( strcmp(laststr,cashstr) != 0 ) - { - strcpy(laststr,cashstr); - fprintf(stderr,"%s\n",cashstr); - } - if ( enabled != 0 && tx.vout[2].nValue != cashout ) - return eval->Invalid("mismatched cashout amount"); - } - if ( funcid == 'Q' ) - { - // verify vin/vout - } - else // 'H' - { - // verify vin/vout and proper payouts - } - return(true); - break; - default: - return eval->Invalid("illegal tetris funcid"); - break; - } - } else return eval->Invalid("illegal evalcode"); - } else return eval->Invalid("opret too small"); - } else return eval->Invalid("not enough vouts"); return(true); } -#endif diff --git a/src/cc/tetris.h b/src/cc/tetris.h new file mode 100644 index 000000000..f032bf2da --- /dev/null +++ b/src/cc/tetris.h @@ -0,0 +1,197 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#ifndef H_TETRIS_H +#define H_TETRIS_H + +#define GAMENAME "tetris" +#define GAMEMAIN tetris +#define CHAINNAME "GTEST" + +#define MAXPACK 23 +struct games_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; + +struct games_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; + struct games_packitem gamespack[MAXPACK]; +}; + +struct games_state +{ + uint64_t seed; + char *keystrokes,*keystrokeshex; + uint32_t needflush,replaydone; + int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; + FILE *logfp; + struct games_player P; + char buffered[10000]; + uint8_t playerdata[10000]; +}; + + +/***************************************************************************/ +/** https://github.com/brenns10/tetris + @file main.c + @author Stephen Brennan + @date Created Wednesday, 10 June 2015 + @brief Main program for tetris. + @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised + BSD License. See LICENSE.txt for details. + *******************************************************************************/ + +/* + Convert a tetromino type to its corresponding cell. + */ +#define TYPE_TO_CELL(x) ((x)+1) + +/* + Strings for how you would print a tetris board. + */ +#define TC_EMPTY_STR " " +#define TC_BLOCK_STR "\u2588" + +/* + Questions about a tetris cell. + */ +#define TC_IS_EMPTY(x) ((x) == TC_EMPTY) +#define TC_IS_FILLED(x) (!TC_IS_EMPTY(x)) + +/* + How many cells in a tetromino? + */ +#define TETRIS 4 +/* + How many tetrominos? + */ +#define NUM_TETROMINOS 7 +/* + How many orientations of a tetromino? + */ +#define NUM_ORIENTATIONS 4 + +/* + Level constants. + */ +#define MAX_LEVEL 19 +#define LINES_PER_LEVEL 10 + +/* + A "cell" is a 1x1 block within a tetris board. + */ +typedef enum { + TC_EMPTY, TC_CELLI, TC_CELLJ, TC_CELLL, TC_CELLO, TC_CELLS, TC_CELLT, TC_CELLZ +} tetris_cell; + +/* + A "type" is a type/shape of a tetromino. Not including orientation. + */ +typedef enum { + TET_I, TET_J, TET_L, TET_O, TET_S, TET_T, TET_Z +} tetris_type; + +/* + A row,column pair. Negative numbers allowed, because we need them for + offsets. + */ +typedef struct { + int row; + int col; +} tetris_location; + +/* + A "block" is a struct that contains information about a tetromino. + Specifically, what type it is, what orientation it has, and where it is. + */ +typedef struct { + int typ; + int ori; + tetris_location loc; +} tetris_block; + +/* + All possible moves to give as input to the game. + */ +typedef enum { + TM_LEFT, TM_RIGHT, TM_CLOCK, TM_COUNTER, TM_DROP, TM_HOLD, TM_NONE +} tetris_move; + +/* + A game object! + */ +typedef struct { + /* + Game board stuff: + */ + int rows; + int cols; + char *board; + /* + Scoring information: + */ + int points; + int level; + /* + Falling block is the one currently going down. Next block is the one that + will be falling after this one. Stored is the block that you can swap out. + */ + tetris_block falling; + tetris_block next; + tetris_block stored; + /* + Number of game ticks until the block will move down. + */ + int ticks_till_gravity; + /* + Number of lines until you advance to the next level. + */ + int lines_remaining; +} tetris_game; + +/* + This array stores all necessary information about the cells that are filled by + each tetromino. The first index is the type of the tetromino (i.e. shape, + e.g. I, J, Z, etc.). The next index is the orientation (0-3). The final + array contains 4 tetris_location objects, each mapping to an offset from a + point on the upper left that is the tetromino "origin". + */ +extern tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; + +/* + This array tells you how many ticks per gravity by level. Decreases as level + increases, to add difficulty. + */ +extern int GRAVITY_LEVEL[MAX_LEVEL+1]; + +// Data structure manipulation. +void tg_init(tetris_game *obj, int rows, int cols); +tetris_game *tg_create(int rows, int cols); +void tg_destroy(tetris_game *obj); +void tg_delete(tetris_game *obj); +tetris_game *tg_load(FILE *f); +void tg_save(tetris_game *obj, FILE *f); + +// Public methods not related to memory: +char tg_get(tetris_game *obj, int row, int col); +bool tg_check(tetris_game *obj, int row, int col); +bool tg_tick(tetris_game *obj, tetris_move move); +void tg_print(tetris_game *obj, FILE *f); + +#endif + From c5b7efd7f8c25acf310619f15d9b203f7bde8a50 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:26:24 -1100 Subject: [PATCH 3184/3904] Optimize --- src/cc/gamescc.cpp | 114 ++++----------------------------------------- src/cc/tetris.c | 11 ++++- src/cc/tetris.cpp | 85 +++++++++++++++++++++++++++++++++ src/cc/tetris.h | 88 +++++++++++++++++----------------- 4 files changed, 148 insertions(+), 150 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 11ceb3345..869205acc 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -14,15 +14,18 @@ ******************************************************************************/ #include "gamescc.h" - -#include "tetris.h" - -static int random_tetromino(void) -{ - return rand() % NUM_TETROMINOS; -} +#include "tetris.c" // replace with game code #ifndef STANDALONE +int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload); +int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk); +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); +void games_packitemstr(char *packitemstr,struct games_packitem *item); +int64_t games_cashout(struct games_player *P); +char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr); + +#include "tetris.cpp" // replace with game specific functions + /* ./c cclib rng 17 \"[%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,250]\" { @@ -55,12 +58,6 @@ static int random_tetromino(void) ./c cclib events 17 \"[%226d%22,%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,1]\" */ -int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload); -int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk); -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); -void games_packitemstr(char *packitemstr,struct games_packitem *item); -int64_t games_cashout(struct games_player *P); - CScript games_newgameopret(int64_t buyin,int32_t maxplayers) { @@ -1193,91 +1190,6 @@ UniValue games_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) -{ - CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; - gamespk = GetUnspendable(cp,0); - *numkeysp = 0; - seed = 0; - num = numkeys = 0; - playertxid = zeroid; - str[0] = 0; - if ( (err= games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) - { - if ( (retval= games_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gamesaddr,numplayers,symbol,pname)) == 0 ) - { - UniValue obj; - seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); - //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); - memset(&P,0,sizeof(P)); - if ( playerdata.size() > 0 ) - { - for (i=0; i no playerdata\n"); - newdata.resize(0); - *numkeysp = numkeys; - return(keystrokes); - /* P.gold = (P.gold * 8) / 10; - if ( keystrokes != 0 ) - { - free(keystrokes); - keystrokes = 0; - *numkeysp = 0; - return(keystrokes); - }*/ - } - else - { - sprintf(str,"$$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); - //fprintf(stderr,"%s\n",str); - *numkeysp = numkeys; - return(keystrokes); - } - } else num = 0; - } - else - { - fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); - if ( keystrokes != 0 ) - free(keystrokes), keystrokes = 0; - } - } else fprintf(stderr,"extractgame: invalid game\n"); - //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); - return(0); -} - UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); CPubKey pk,gamespk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],gamesaddr[64],*pubstr,*hexstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; @@ -1556,11 +1468,5 @@ UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -#include "tetris.cpp" - -#else // STANDALONE - -#include "tetris.c" - #endif diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 4ffd27575..94ceda83b 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -1,7 +1,10 @@ #include "tetris.h" -#include "dapps/dappstd.c" +static int random_tetromino(void) +{ + return rand() % NUM_TETROMINOS; +} /***************************************************************************/ /** https://github.com/brenns10/tetris @@ -622,10 +625,12 @@ void init_colors(void) init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); } +#else /* Main tetris game! */ -#ifdef STANDALONE +#include "dapps/dappstd.c" + char *clonestr(char *str) { char *clone; int32_t len; @@ -756,3 +761,5 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) { return(-1); } +#endif + diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index fd833d7b7..4d0be1e96 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -128,6 +128,91 @@ int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C return(-1); } +char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) +{ + CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; + gamespk = GetUnspendable(cp,0); + *numkeysp = 0; + seed = 0; + num = numkeys = 0; + playertxid = zeroid; + str[0] = 0; + if ( (err= games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) + { + if ( (retval= games_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gamesaddr,numplayers,symbol,pname)) == 0 ) + { + UniValue obj; + seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i no playerdata\n"); + newdata.resize(0); + *numkeysp = numkeys; + return(keystrokes); + /* P.gold = (P.gold * 8) / 10; + if ( keystrokes != 0 ) + { + free(keystrokes); + keystrokes = 0; + *numkeysp = 0; + return(keystrokes); + }*/ + } + else + { + sprintf(str,"$$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); + //fprintf(stderr,"%s\n",str); + *numkeysp = numkeys; + return(keystrokes); + } + } else num = 0; + } + else + { + fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); + if ( keystrokes != 0 ) + free(keystrokes), keystrokes = 0; + } + } else fprintf(stderr,"extractgame: invalid game\n"); + //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); + return(0); +} + int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) // replay in daemon { return(-1); diff --git a/src/cc/tetris.h b/src/cc/tetris.h index f032bf2da..b239a1644 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -1,51 +1,7 @@ -/****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ #ifndef H_TETRIS_H #define H_TETRIS_H -#define GAMENAME "tetris" -#define GAMEMAIN tetris -#define CHAINNAME "GTEST" - -#define MAXPACK 23 -struct games_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; - -struct games_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; - struct games_packitem gamespack[MAXPACK]; -}; - -struct games_state -{ - uint64_t seed; - char *keystrokes,*keystrokeshex; - uint32_t needflush,replaydone; - int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; - FILE *logfp; - struct games_player P; - char buffered[10000]; - uint8_t playerdata[10000]; -}; - - /***************************************************************************/ /** https://github.com/brenns10/tetris @file main.c @@ -193,5 +149,49 @@ bool tg_check(tetris_game *obj, int row, int col); bool tg_tick(tetris_game *obj, tetris_move move); void tg_print(tetris_game *obj, FILE *f); +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ +#define GAMENAME "tetris" +#define GAMEMAIN tetris +#define CHAINNAME "GTEST" + +#define MAXPACK 23 +struct games_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; + +struct games_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; + struct games_packitem gamespack[MAXPACK]; +}; + +struct games_state +{ + uint64_t seed; + char *keystrokes,*keystrokeshex; + uint32_t needflush,replaydone; + int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; + FILE *logfp; + struct games_player P; + char buffered[10000]; + uint8_t playerdata[10000]; +}; + + #endif From f9c20dab7876d7f08ccd0411fcbcf7311dee27f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:27:25 -1100 Subject: [PATCH 3185/3904] Def standalone --- src/cc/tetris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 94ceda83b..7c6ff768e 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -625,7 +625,7 @@ void init_colors(void) init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); } -#else +#ifdef STANDALONE /* Main tetris game! */ From a3d531714ec633ee3f685e493c12958500aee6ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:28:28 -1100 Subject: [PATCH 3186/3904] Extern const --- src/cc/tetris.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.h b/src/cc/tetris.h index b239a1644..e2639cba1 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -127,13 +127,13 @@ typedef struct { array contains 4 tetris_location objects, each mapping to an offset from a point on the upper left that is the tetromino "origin". */ -extern tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; +extern const tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; /* This array tells you how many ticks per gravity by level. Decreases as level increases, to add difficulty. */ -extern int GRAVITY_LEVEL[MAX_LEVEL+1]; +extern const int GRAVITY_LEVEL[MAX_LEVEL+1]; // Data structure manipulation. void tg_init(tetris_game *obj, int rows, int cols); From 8c71d44ba66aabfde1cdad6055d94185d3ae14dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:31:43 -1100 Subject: [PATCH 3187/3904] Reorder --- src/cc/gamescc.cpp | 26 -------------------------- src/cc/tetris.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 869205acc..f62a8699c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -17,12 +17,6 @@ #include "tetris.c" // replace with game code #ifndef STANDALONE -int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload); -int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk); -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); -void games_packitemstr(char *packitemstr,struct games_packitem *item); -int64_t games_cashout(struct games_player *P); -char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr); #include "tetris.cpp" // replace with game specific functions @@ -551,26 +545,6 @@ int32_t games_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx return(alive); } -void disp_gamesplayerdata(std::vector playerdata) -{ - struct games_player P; int32_t i; char packitemstr[512]; - if ( playerdata.size() > 0 ) - { - for (i=0; i>16,P.level,P.experience,P.dungeonlevel); - for (i=0; i playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct games_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 4d0be1e96..cb9c47cc8 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -14,6 +14,10 @@ * * ******************************************************************************/ +int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname); +int32_t games_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0); +uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr); + // game specific code for daemon int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) @@ -47,6 +51,26 @@ int64_t games_cashout(struct games_player *P) return(cashout); } +void disp_gamesplayerdata(std::vector playerdata) +{ + struct games_player P; int32_t i; char packitemstr[512]; + if ( playerdata.size() > 0 ) + { + for (i=0; i>16,P.level,P.experience,P.dungeonlevel); + for (i=0; i playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; static uint256 prevgame; From 43bdea08406e8d7e0b759c555c2d77085464583e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:33:49 -1100 Subject: [PATCH 3188/3904] Reorder --- src/cc/tetris.cpp | 174 +++++++++++++++++++++++----------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index cb9c47cc8..f9e4e167a 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -20,6 +20,16 @@ uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 // game specific code for daemon +void games_packitemstr(char *packitemstr,struct games_packitem *item) +{ + sprintf(packitemstr,"not yet"); +} + +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) // replay in daemon +{ + return(-1); +} + int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) { uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; @@ -71,87 +81,6 @@ void disp_gamesplayerdata(std::vector playerdata) } } -int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) -{ - static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,gamesaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; - *cashoutp = 0; - gamespk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,gamesaddr,gamespk,pk); - if ( (keystrokes= games_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) - { - free(keystrokes); - sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); - remove(fname); - - for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); - } - *cashoutp = 0; - return(0); - } - } - if ( gametxid != prevgame ) - { - prevgame = gametxid; - bad++; - disp_gamesplayerdata(newdata); - disp_gamesplayerdata(playerdata); - fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,gamesaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); - } - } - sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); - remove(fname); - //fprintf(stderr,"no keys games_extractgame %s\n",gametxid.GetHex().c_str()); - return(-1); -} - char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) { CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; @@ -237,16 +166,87 @@ char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto return(0); } -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) // replay in daemon +int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { + static uint32_t good,bad; static uint256 prevgame; + char str[512],*keystrokes,gamesaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; + *cashoutp = 0; + gamespk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,gamesaddr,gamespk,pk); + if ( (keystrokes= games_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) + { + free(keystrokes); + sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); + remove(fname); + + for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); + } + *cashoutp = 0; + return(0); + } + } + if ( gametxid != prevgame ) + { + prevgame = gametxid; + bad++; + disp_gamesplayerdata(newdata); + disp_gamesplayerdata(playerdata); + fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,gamesaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); + } + } + sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); + remove(fname); + //fprintf(stderr,"no keys games_extractgame %s\n",gametxid.GetHex().c_str()); return(-1); } -void games_packitemstr(char *packitemstr,struct games_packitem *item) -{ - sprintf(packitemstr,"not yet"); -} - bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true); From c166507c62a7afb2b21d69243a968a28fe51907d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:36:06 -1100 Subject: [PATCH 3189/3904] rand() --- src/cc/tetris.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 7c6ff768e..d3e9911a1 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -1,6 +1,12 @@ #include "tetris.h" +/* + In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events + */ + +int rand(); + static int random_tetromino(void) { return rand() % NUM_TETROMINOS; From d5e26e7bc590a061aabe1ae336bd66e7fae20ab4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:44:10 -1100 Subject: [PATCH 3190/3904] Declare rs --- src/cc/tetris.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index d3e9911a1..874a6437d 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -2,7 +2,7 @@ #include "tetris.h" /* - In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events + In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. */ int rand(); @@ -654,14 +654,40 @@ char *clonestr(char *str) return(clone); } +struct games_state globalR; + int tetris(int argc, char **argv) { tetris_game *tg; tetris_move move = TM_NONE; bool running = true; WINDOW *board, *next, *hold, *score; + struct games_state *rs = &globalR; int32_t c,skipcount=0; bits256 gametxid; uint32_t eventid = 0; memset(&gametxid,0,sizeof(gametxid)); + memset(rs,0,sizeof(*rs)); + rs->guiflag = 1; + rs->sleeptime = 1; // non-zero to allow refresh() + if ( argc == 3 && strlen(argv[2]) == 64 ) + { +#ifdef _WIN32 +#ifdef _MSC_VER + rs->seed = _strtoui64(argv[1], NULL, 10); +#else + rs->seed = atol(argv[1]); // windows, but not MSVC +#endif // _MSC_VER +#else + rs->seed = atol(argv[1]); // non-windows +#endif // _WIN32 + strcpy(Gametxidstr,argv[2]); + fprintf(stderr,"setplayerdata\n"); + if ( games_setplayerdata(rs,Gametxidstr) < 0 ) + { + fprintf(stderr,"invalid gametxid, or already started\n"); + return(-1); + } + } else rs->seed = 777; + // Load file if given a filename. if (argc >= 2) { FILE *f = fopen(argv[1], "r"); From 226179dcd386417dded5910f9c28154d5f905868 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:45:17 -1100 Subject: [PATCH 3191/3904] Skip rand() --- src/cc/tetris.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 874a6437d..adcf098f5 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -5,11 +5,10 @@ In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. */ -int rand(); - static int random_tetromino(void) { - return rand() % NUM_TETROMINOS; + return(0); + //return rand() % NUM_TETROMINOS; } /***************************************************************************/ From b4dd00266d9c2496f0e039a3e2d708e61bb3d540 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 00:55:53 -1100 Subject: [PATCH 3192/3904] Active rngnext --- src/cc/tetris.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index adcf098f5..db88c0659 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -3,12 +3,14 @@ /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. + + also, the standalone game needs to support argv of seed gametxid, along with replay args */ -static int random_tetromino(void) +static int random_tetromino(struct games_state *rs) { - return(0); - //return rand() % NUM_TETROMINOS; + rs->seed = _games_rngnext(rs->seed); + return(rs->seed % NUM_TETROMINOS); } /***************************************************************************/ @@ -173,11 +175,11 @@ static bool tg_fits(tetris_game *obj, tetris_block block) Create a new falling block and populate the next falling block with a random one. */ -static void tg_new_falling(tetris_game *obj) +static void tg_new_falling(struct games_state *rs,tetris_game *obj) { // Put in a new falling tetromino. obj->falling = obj->next; - obj->next.typ = random_tetromino(); + obj->next.typ = random_tetromino(rs); obj->next.ori = 0; obj->next.loc.row = 0; obj->next.loc.col = obj->cols/2 - 2; @@ -190,7 +192,7 @@ static void tg_new_falling(tetris_game *obj) /* Tick gravity, and move the block down if gravity should act. */ -static void tg_do_gravity_tick(tetris_game *obj) +static void tg_do_gravity_tick(struct games_state *rs,tetris_game *obj) { obj->ticks_till_gravity--; if (obj->ticks_till_gravity <= 0) { @@ -202,7 +204,7 @@ static void tg_do_gravity_tick(tetris_game *obj) obj->falling.loc.row--; tg_put(obj, obj->falling); - tg_new_falling(obj); + tg_new_falling(rs,obj); } tg_put(obj, obj->falling); } @@ -411,11 +413,11 @@ static bool tg_game_over(tetris_game *obj) Do a single game tick: process gravity, user input, and score. Return true if the game is still running, false if it is over. */ -bool tg_tick(tetris_game *obj, tetris_move move) +bool tg_tick(struct games_state *rs,tetris_game *obj, tetris_move move) { int lines_cleared; // Handle gravity. - tg_do_gravity_tick(obj); + tg_do_gravity_tick(rs,obj); // Handle input. tg_handle_move(obj, move); @@ -687,7 +689,7 @@ int tetris(int argc, char **argv) } } else rs->seed = 777; - // Load file if given a filename. + /* Load file if given a filename. if (argc >= 2) { FILE *f = fopen(argv[1], "r"); if (f == NULL) { @@ -699,7 +701,9 @@ int tetris(int argc, char **argv) } else { // Otherwise create new game. tg = tg_create(22, 10); - } + }*/ + tg = tg_create(22, 10); + // NCURSES initialization: initscr(); // initialize curses cbreak(); // pass key presses to program, but not signals @@ -717,7 +721,7 @@ int tetris(int argc, char **argv) int32_t counter = 0; // Game loop while (running) { - running = tg_tick(tg, move); + running = tg_tick(rs,tg, move); display_board(board, tg); display_piece(next, tg->next); display_piece(hold, tg->stored); From 46dba9071ba32f439570e7bd8bc390b0103e677c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 01:49:11 -1100 Subject: [PATCH 3193/3904] Add keystrokes replay --- src/cc/dapps/dappstd.c | 318 ++++++++++++++++++++++++++++------------- src/cc/tetris.c | 65 +++++++-- 2 files changed, 274 insertions(+), 109 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index ec8045b2f..033633665 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -688,33 +688,6 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } -int32_t issue_games_events(bits256 gametxid,uint32_t eventid,int32_t c) -{ - static FILE *fp; - char params[512],*retstr,str[65]; cJSON *retjson,*resobj; int32_t retval = -1; - if ( fp == 0 ) - fp = fopen("events.log","wb"); - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c,bits256_str(str,gametxid),eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) - { - retval = 0; - if ( fp != 0 ) - { - fprintf(fp,"%s\n",jprint(resobj,0)); - fflush(fp); - } - } - free_json(retjson); - } else fprintf(fp,"error parsing %s\n",retstr); - free(retstr); - } else fprintf(fp,"error issuing method %s\n",params); - return(retval); -} - int32_t games_sendrawtransaction(char *rawtx) { char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; @@ -781,91 +754,240 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,cha } free(rs->keystrokeshex), rs->keystrokeshex = 0; } - if ( 0 && (pastkeys= games_keystrokesload(&numpastkeys,seed,1)) != 0 ) - { - sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (keys= jstr(resobj,(char *)"keystrokes")) != 0 ) - { - len = strlen(keys) / 2; - pastcmp = (uint8_t *)malloc(len + 1); - decode_hex(pastcmp,len,keys); - fprintf(stderr,"keystrokes.(%s) vs pastkeys\n",keys); - for (i=0; i> keystrokes.log",ASSETCHAINS_SYMBOL,Gametxidstr,hexstr); - if ( system(cmd) != 0 ) - fprintf(stderr,"error issuing (%s)\n",cmd); - } - else - { - static FILE *fp; - if ( fp == 0 ) - fp = fopen("keystrokes.log","a"); - sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + if ( fp != 0 ) { - if ( fp != 0 ) + fprintf(fp,"%s\n",params); + fprintf(fp,"%s\n",retstr); + fflush(fp); + } + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (rawtx= jstr(resobj,(char *)"hex")) != 0 ) { - fprintf(fp,"%s\n",params); - fprintf(fp,"%s\n",retstr); - fflush(fp); - } - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 && (rawtx= jstr(resobj,(char *)"hex")) != 0 ) + if ( rs->keystrokeshex != 0 ) + free(rs->keystrokeshex); + if ( (errstr= jstr(resobj,(char *)"error")) == 0 ) { - if ( rs->keystrokeshex != 0 ) - free(rs->keystrokeshex); - if ( (errstr= jstr(resobj,(char *)"error")) == 0 ) - { - rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); - strcpy(rs->keystrokeshex,rawtx); - retflag = 1; - } else fprintf(stderr,"error sending keystrokes tx\n"), sleep(1); - //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); - } - free_json(retjson); + rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1); + strcpy(rs->keystrokeshex,rawtx); + retflag = 1; + } else fprintf(stderr,"error sending keystrokes tx\n"), sleep(1); + //fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex); } - free(retstr); - } - if ( 0 && waitflag != 0 && rs->keystrokeshex != 0 ) - { - while ( games_sendrawtransaction(rs->keystrokeshex) == 0 ) - { - //fprintf(stderr,"post-rebroadcast\n"); - sleep(3); - } - free(rs->keystrokeshex), rs->keystrokeshex = 0; + free_json(retjson); } + free(retstr); } } return(retflag); } +int32_t gamesfname(char *fname,uint64_t seed,int32_t counter) +{ + sprintf(fname,"%s.%llu.%d",GAMENAME,(long long)seed,counter); + return(0); +} + +int32_t flushkeystrokes_local(struct games_state *rs,int32_t waitflag) +{ +#ifdef STANDALONE + char fname[1024]; FILE *fp; int32_t i,retflag = -1; + rs->counter++; + gamesfname(fname,rs->seed,rs->counter); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num ) + { + rs->num = 0; + retflag = 0; + fclose(fp); + gamesfname(fname,rs->seed,rs->counter+1); + if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file + fclose(fp); + //fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag); + //} + } else fprintf(stderr,"error writing (%s)\n",fname); + } else fprintf(stderr,"error creating (%s)\n",fname); + return(retflag); +#else + return(0); +#endif +} + +#ifndef STANDALONE +// stubs for inside daemon + +int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) +{ + return(0); +} + +int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) +{ + return(-1); +} +#endif + +int32_t flushkeystrokes(struct games_state *rs,int32_t waitflag) +{ + if ( rs->num > 0 ) + { + if ( games_progress(rs,waitflag,rs->seed,rs->buffered,rs->num) > 0 ) + { + flushkeystrokes_local(rs,waitflag); + memset(rs->buffered,0,sizeof(rs->buffered)); + } + } + return(0); +} + +void games_bailout(struct games_state *rs) +{ + flushkeystrokes(rs,1); +} + +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + +int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) +{ + struct games_state *rs; FILE *fp; int32_t i,n; + rs = (struct games_state *)calloc(1,sizeof(*rs)); + rs->seed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = sleepmillis * 1000; + if ( player != 0 ) + { + rs->P = *player; + rs->restoring = 1; + //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); + if ( rs->P.packsize > MAXPACK ) + rs->P.packsize = MAXPACK; + } + globalR = *rs; + uint32_t starttime = (uint32_t)time(NULL); + gamesiterate(rs); + if ( 0 ) + { + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); + sleep(2); + starttime = (uint32_t)time(NULL); + for (i=0; i<10000; i++) + { + memset(rs,0,sizeof(*rs)); + rs->seed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = 0; + gamesiterate(rs); + } + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); + sleep(3); + } + // extract playerdata + + /*if ( (fp= fopen("checkfile","wb")) != 0 ) + { + //save_file(rs,fp,0); + //fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); + if ( newdata != 0 && rs->playersize > 0 ) + memcpy(newdata,rs->playerdata,rs->playersize); + }*/ + if ( newdata != 0 && rs->playersize > 0 ) + memcpy(newdata,rs->playerdata,rs->playersize); + n = rs->playersize; + free(rs); + return(n); +} + +long get_filesize(FILE *fp) +{ + long fsize,fpos = ftell(fp); + fseek(fp,0,SEEK_END); + fsize = ftell(fp); + fseek(fp,fpos,SEEK_SET); + return(fsize); +} + +char *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) +{ + char fname[1024],*keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; + *numkeysp = 0; + while ( 1 ) + { + gamesfname(fname,seed,counter); + //printf("check (%s)\n",fname); + if ( (fp= fopen(fname,"rb")) == 0 ) + break; + if ( (fsize= get_filesize(fp)) <= 0 ) + { + fclose(fp); + //printf("fsize.%ld\n",fsize); + break; + } + if ( (keystrokes= (char *)realloc(keystrokes,num+fsize)) == 0 ) + { + fprintf(stderr,"error reallocating keystrokes\n"); + fclose(fp); + return(0); + } + if ( fread(&keystrokes[num],1,fsize,fp) != fsize ) + { + fprintf(stderr,"error reading keystrokes from (%s)\n",fname); + fclose(fp); + free(keystrokes); + return(0); + } + fclose(fp); + num += fsize; + counter++; + //fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); + } + *numkeysp = num; + return(keystrokes); +} + +int32_t games_replay(uint64_t seed,int32_t sleeptime) +{ + FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct games_state *rs; struct games_player P,*player = 0; + if ( seed == 0 ) + seed = 777; + keystrokes = games_keystrokesload(&num,seed,counter); + if ( num > 0 ) + { + sprintf(fname,"%s.%llu.player",GAMENAME,(long long)seed); + if ( (fp=fopen(fname,"rb")) != 0 ) + { + if ( fread(&P,1,sizeof(P),fp) > 0 ) + { + //printf("max size player\n"); + player = &P; + } + fclose(fp); + } + games_replay2(0,seed,keystrokes,num,player,sleeptime); + mvaddstr(LINES - 2, 0, (char *)"replay completed"); + endwin(); + my_exit(0); + } + if ( keystrokes != 0 ) + free(keystrokes); + return(num); +} + int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) { char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson; diff --git a/src/cc/tetris.c b/src/cc/tetris.c index db88c0659..5e873e5c4 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -638,6 +638,34 @@ void init_colors(void) */ #include "dapps/dappstd.c" +int32_t issue_games_events(struct games_state *rs,bits256 gametxid,uint32_t eventid,char c) +{ + static FILE *fp; + char params[512],*retstr,str[65]; cJSON *retjson,*resobj; int32_t retval = -1; + if ( fp == 0 ) + fp = fopen("events.log","wb"); + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,bits256_str(str,gametxid),eventid); + rs->buffered[rs->num++] = c; + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + retval = 0; + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } + } + free_json(retjson); + } else fprintf(fp,"error parsing %s\n",retstr); + free(retstr); + } else fprintf(fp,"error issuing method %s\n",params); + return(retval); +} + char *clonestr(char *str) { char *clone; int32_t len; @@ -730,34 +758,49 @@ int tetris(int argc, char **argv) doupdate(); sleep_milli(10); c = getch(); - if ( c != -1 || skipcount == 0x3fff ) + switch ( c ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } + if ( c < 0 || skipcount == 0x7f ) { if ( skipcount > 0 ) - issue_games_events(gametxid,eventid-skipcount,skipcount | 0x4000); + issue_games_events(rs,gametxid,eventid-skipcount,skipcount | 0x80); if ( c != -1 ) - issue_games_events(gametxid,eventid,c); + issue_games_events(rs,gametxid,eventid,c); skipcount = 0; } else skipcount++; eventid++; switch ( c ) { - case KEY_LEFT: + case 'h': move = TM_LEFT; break; - case KEY_RIGHT: + case 'l': move = TM_RIGHT; break; - case KEY_UP: + case 'k': move = TM_CLOCK; break; - case KEY_DOWN: + case 'j': move = TM_DROP; break; case 'q': running = false; move = TM_NONE; break; - case 'p': + /*case 'p': wclear(board); box(board, 0, 0); wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); @@ -771,7 +814,7 @@ int tetris(int argc, char **argv) case 's': save(tg, board); move = TM_NONE; - break; + break;*/ case ' ': move = TM_HOLD; break; @@ -792,9 +835,9 @@ int tetris(int argc, char **argv) return 0; } -int32_t games_replay(uint64_t seed,int32_t sleeptime) +void gamesiterate(struct games_state *rs) { - return(-1); + } #endif From c9a3844f54799b77c862c38f9faf06c3a0a08a1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 01:52:18 -1100 Subject: [PATCH 3194/3904] Test --- src/cc/tetris.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.h b/src/cc/tetris.h index e2639cba1..40a9c97cb 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -137,7 +137,7 @@ extern const int GRAVITY_LEVEL[MAX_LEVEL+1]; // Data structure manipulation. void tg_init(tetris_game *obj, int rows, int cols); -tetris_game *tg_create(int rows, int cols); +tetris_game *tg_create(struct games_state *rs,int rows, int cols); void tg_destroy(tetris_game *obj); void tg_delete(tetris_game *obj); tetris_game *tg_load(FILE *f); @@ -146,7 +146,7 @@ void tg_save(tetris_game *obj, FILE *f); // Public methods not related to memory: char tg_get(tetris_game *obj, int row, int col); bool tg_check(tetris_game *obj, int row, int col); -bool tg_tick(tetris_game *obj, tetris_move move); +bool tg_tick(struct games_state *rs,tetris_game *obj, tetris_move move); void tg_print(tetris_game *obj, FILE *f); /****************************************************************************** @@ -192,6 +192,7 @@ struct games_state uint8_t playerdata[10000]; }; +uint64_t _games_rngnext(uint64_t initseed); #endif From a49081204962ba5076cdf59ec509d2182b6c4911 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 01:54:09 -1100 Subject: [PATCH 3195/3904] struct games_state *rs, --- src/cc/tetris.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 5e873e5c4..4dbb71f89 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -226,7 +226,7 @@ static void tg_move(tetris_game *obj, int direction) /* Send the falling tetris block to the bottom. */ -static void tg_down(tetris_game *obj) +static void tg_down(struct games_state *rs,tetris_game *obj) { tg_remove(obj, obj->falling); while (tg_fits(obj, obj->falling)) { @@ -234,7 +234,7 @@ static void tg_down(tetris_game *obj) } obj->falling.loc.row--; tg_put(obj, obj->falling); - tg_new_falling(obj); + tg_new_falling(rs,obj); } /* @@ -273,12 +273,12 @@ static void tg_rotate(tetris_game *obj, int direction) /* Swap the falling block with the block in the hold buffer. */ -static void tg_hold(tetris_game *obj) +static void tg_hold(struct games_state *rs,tetris_game *obj) { tg_remove(obj, obj->falling); if (obj->stored.typ == -1) { obj->stored = obj->falling; - tg_new_falling(obj); + tg_new_falling(rs,obj); } else { int typ = obj->falling.typ, ori = obj->falling.ori; obj->falling.typ = obj->stored.typ; @@ -431,7 +431,7 @@ bool tg_tick(struct games_state *rs,tetris_game *obj, tetris_move move) return !tg_game_over(obj); } -void tg_init(tetris_game *obj, int rows, int cols) +void tg_init(struct games_state *rs,tetris_game *obj, int rows, int cols) { // Initialization logic obj->rows = rows; @@ -443,8 +443,8 @@ void tg_init(tetris_game *obj, int rows, int cols) obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; obj->lines_remaining = LINES_PER_LEVEL; //srand(time(NULL)); - tg_new_falling(obj); - tg_new_falling(obj); + tg_new_falling(rs,obj); + tg_new_falling(ts,obj); obj->stored.typ = -1; obj->stored.ori = 0; obj->stored.loc.row = 0; @@ -452,10 +452,10 @@ void tg_init(tetris_game *obj, int rows, int cols) printf("%d", obj->falling.loc.col); } -tetris_game *tg_create(int rows, int cols) +tetris_game *tg_create(struct games_state *rs,int rows, int cols) { tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); - tg_init(obj, rows, cols); + tg_init(rs,obj, rows, cols); return obj; } From 30df5445c762767263c3312560624476bac74c02 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 01:57:07 -1100 Subject: [PATCH 3196/3904] struct games_state *rs, --- src/cc/tetris.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 4dbb71f89..1b039dc6f 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -295,7 +295,7 @@ static void tg_hold(struct games_state *rs,tetris_game *obj) /* Perform the action specified by the move. */ -static void tg_handle_move(tetris_game *obj, tetris_move move) +static void tg_handle_move(struct games_state *rs,tetris_game *obj, tetris_move move) { switch (move) { case TM_LEFT: @@ -305,7 +305,7 @@ static void tg_handle_move(tetris_game *obj, tetris_move move) tg_move(obj, 1); break; case TM_DROP: - tg_down(obj); + tg_down(rs,obj); break; case TM_CLOCK: tg_rotate(obj, 1); @@ -314,7 +314,7 @@ static void tg_handle_move(tetris_game *obj, tetris_move move) tg_rotate(obj, -1); break; case TM_HOLD: - tg_hold(obj); + tg_hold(rs,obj); break; default: // pass @@ -420,7 +420,7 @@ bool tg_tick(struct games_state *rs,tetris_game *obj, tetris_move move) tg_do_gravity_tick(rs,obj); // Handle input. - tg_handle_move(obj, move); + tg_handle_move(rs,obj, move); // Check for cleared lines lines_cleared = tg_check_lines(obj); @@ -444,7 +444,7 @@ void tg_init(struct games_state *rs,tetris_game *obj, int rows, int cols) obj->lines_remaining = LINES_PER_LEVEL; //srand(time(NULL)); tg_new_falling(rs,obj); - tg_new_falling(ts,obj); + tg_new_falling(rs,obj); obj->stored.typ = -1; obj->stored.ori = 0; obj->stored.loc.row = 0; @@ -728,9 +728,9 @@ int tetris(int argc, char **argv) fclose(f); } else { // Otherwise create new game. - tg = tg_create(22, 10); + tg = tg_create(rs,22, 10); }*/ - tg = tg_create(22, 10); + tg = tg_create(rs,22, 10); // NCURSES initialization: initscr(); // initialize curses From 8e6f5a6a2dd9e45b90c7d4d7d603f0901a157941 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Mar 2019 20:59:31 +0800 Subject: [PATCH 3197/3904] initial commit for backup release tx needs testing, i think it half works. --- src/cc/CCinclude.h | 1 + src/cc/CCutils.cpp | 14 +++++++++++++- src/cc/payments.cpp | 6 ++++-- src/cc/rewards.cpp | 21 +++++++-------------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 13d7236d4..839fd2c95 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -247,6 +247,7 @@ void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, c int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode); bool IsCCInput(CScript const& scriptSig); +bool CheckTxFee(const CTransaction &tx, uint64_t txfee, uint32_t height, uint64_t blocktime); int32_t unstringbits(char *buf,uint64_t bits); uint64_t stringbits(char *str); uint256 revuint256(uint256 txid); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index a3bf0a68b..887550a0c 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -168,6 +168,18 @@ bool IsCCInput(CScript const& scriptSig) return true; } +bool CheckTxFee(const CTransaction &tx, uint64_t txfee, uint32_t height, uint64_t blocktime) +{ + int64_t interest; uint64_t valuein; + CCoinsViewCache &view = *pcoinsTip; + valuein = view.GetValueIn(height,&interest,tx,blocktime); + if ( valuein-tx.GetValueOut() > txfee ) + { + //fprintf(stderr, "txfee.%li vs txfee.%li\n", valuein-tx.GetValueOut(), txfee); + return false; + } + return true; +} // set additional 'unspendable' addr void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) @@ -668,4 +680,4 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector paramsNull,co return(false); //eval->Invalid("error in CClib_validate"); } return eval->Invalid("cclib CC must have evalcode between 16 and 127"); -} \ No newline at end of file +} diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 184c92d33..e0c4c8ada 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -192,7 +192,9 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & if ( tmptx.vout.size() > 0 && DecodePaymentsOpRet(tmptx.vout[tmptx.vout.size()-1].scriptPubKey,lockedblocks,minrelease,totalallocations,txidoprets) != 0 ) { if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 ) - return(eval->Invalid("negative values")); + return(eval->Invalid("negative values")); + if ( !CheckTxFee(tx, PAYMENTS_TXFEE, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) ) + return eval->Invalid("txfee is too high"); Paymentspk = GetUnspendable(cp,0); //fprintf(stderr, "lockedblocks.%i minrelease.%i totalallocations.%i txidopret1.%s txidopret2.%s\n",lockedblocks, minrelease, totalallocations, txidoprets[0].ToString().c_str(), txidoprets[1].ToString().c_str() ); @@ -281,7 +283,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & fprintf(stderr, "vin.%i is not a payments CC vout: txid.%s\n", i, txin.GetHash().ToString().c_str()); return(eval->Invalid("vin is not paymentsCC type")); } //else fprintf(stderr, "vin.%i opret type txid.%s\n", i, txin.GetHash().ToString().c_str()); - } + } // check the chain depth vs locked blcoks requirement. CBlockIndex* pblockindex = mapBlockIndex[blockhash]; if ( pblockindex->GetHeight() > ht-lockedblocks ) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 65e32ee27..db64127e7 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -197,9 +197,6 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t uint256 txid,fundingtxid,hashBlock,vinfundingtxid; uint64_t vinsbits,sbits,APR,minseconds,maxseconds,mindeposit,amount,reward,txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; uint8_t funcid; CScript scriptPubKey; CTransaction fundingTx,vinTx; numvins = tx.vin.size(); numvouts = tx.vout.size(); - int64_t interest; uint64_t valuein; - CCoinsViewCache &view = *pcoinsTip; - valuein = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime); preventCCvins = preventCCvouts = -1; if ( numvouts < 1 ) return eval->Invalid("no vouts"); @@ -258,20 +255,17 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t if ( (*cp->ismyvin)(tx.vin[i].scriptSig) == 0 ) return eval->Invalid("unexpected normal vin for unlock"); } - if ( valuein-tx.GetValueOut() > txfee ) + if ( !CheckTxFee(tx, txfee, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) ) + return eval->Invalid("txfee is too high"); + if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 && tx.vout[1].nValue == 10000 ) { - fprintf(stderr, "valueout.%li vs valuein.%li txfee.%li\n", tx.GetValueOut(), valuein, txfee); - return eval->Invalid("alright is stealing your money"); - } - if ( numvouts == 2 && numvins == 1 ) - { - if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 ) - return eval->Invalid("unlock recover tx vout.0 is not normal output"); + if ( tx.vout[1].scriptPubKey != tx.vout[0].scriptPubKey ) + return eval->Invalid("unlock recover tx vout.1 mismatched scriptPubKey"); else if ( tx.vout[0].scriptPubKey != vinTx.vout[1].scriptPubKey ) return eval->Invalid("unlock recover tx vout.0 mismatched scriptPubKey"); else if ( tx.vout[0].nValue > vinTx.vout[0].nValue ) return eval->Invalid("unlock recover tx vout.0 mismatched amounts"); - else if ( tx.vout[1].nValue > 0 ) + else if ( tx.vout[2].nValue > 0 ) return eval->Invalid("unlock recover tx vout.1 nonz amount"); else return(true); } @@ -689,8 +683,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2 } else { - firstmtx.vout.push_back(CTxOut(amount-txfee,scriptPubKey)); - //CCerror = "cant find enough rewards inputs"; + firstmtx.vout.push_back(CTxOut(amount-txfee*2,scriptPubKey)); fprintf(stderr,"not enough rewards funds to payout %.8f, recover mode tx\n",(double)(reward+txfee)/COIN); return(FinalizeCCTx(-1LL,cp,firstmtx,mypk,txfee,EncodeRewardsOpRet('U',sbits,fundingtxid))); } From 3a6db6cc718d9550b414dca6190775755f8cf6a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 01:59:56 -1100 Subject: [PATCH 3198/3904] Gamesiterate --- src/cc/dapps/dappstd.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 033633665..5c8fb0204 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -23,6 +23,9 @@ #include #include +extern struct games_state globalR; +void gamesiterate(struct games_state *rs); + char USERPASS[8192]; uint16_t GAMES_PORT; char Gametxidstr[67]; char *clonestr(char *str); @@ -960,6 +963,19 @@ char *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) return(keystrokes); } +void games_exit() +{ + uint32_t counter; + resetltchars(); + if ( globalR.guiflag != 0 || globalR.sleeptime != 0 ) + exit(st); + else if ( counter++ < 10 ) + { + fprintf(stderr,"would have exit.(%d) sleeptime.%d\n",st,globalR.sleeptime); + globalR.replaydone = 1; + } +} + int32_t games_replay(uint64_t seed,int32_t sleeptime) { FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct games_state *rs; struct games_player P,*player = 0; @@ -981,7 +997,7 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) games_replay2(0,seed,keystrokes,num,player,sleeptime); mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); - my_exit(0); + games_exit(); } if ( keystrokes != 0 ) free(keystrokes); From 7604ee369749937957eb18958542dee377691973 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:01:32 -1100 Subject: [PATCH 3199/3904] Exit --- src/cc/dapps/dappstd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 5c8fb0204..5f8821890 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -966,9 +966,9 @@ char *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) void games_exit() { uint32_t counter; - resetltchars(); + //resetltchars(); if ( globalR.guiflag != 0 || globalR.sleeptime != 0 ) - exit(st); + exit(0); else if ( counter++ < 10 ) { fprintf(stderr,"would have exit.(%d) sleeptime.%d\n",st,globalR.sleeptime); From 62fc48877e96a4877de5d8ae12752221cdf4af30 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:05:19 -1100 Subject: [PATCH 3200/3904] -print --- src/cc/dapps/dappstd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 5f8821890..b93e7b41d 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -971,7 +971,7 @@ void games_exit() exit(0); else if ( counter++ < 10 ) { - fprintf(stderr,"would have exit.(%d) sleeptime.%d\n",st,globalR.sleeptime); + fprintf(stderr,"would have exit sleeptime.%d\n",globalR.sleeptime); globalR.replaydone = 1; } } From 7b8adf33e196a8a3e3ba5d957796a980a13922cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:06:33 -1100 Subject: [PATCH 3201/3904] Gamesrngnext --- src/cc/gamescc.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index f62a8699c..367c8d96e 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -16,6 +16,21 @@ #include "gamescc.h" #include "tetris.c" // replace with game code + +uint64_t _games_rngnext(uint64_t initseed) +{ + uint16_t seeds[4]; int32_t i; + seeds[0] = initseed; + seeds[1] = (initseed >> 16); + seeds[2] = (initseed >> 32); + seeds[3] = (initseed >> 48); + seeds[0] = (seeds[0]*GAMES_RNGMULT + GAMES_RNGOFFSET); + seeds[1] = ((seeds[0] ^ seeds[1])*GAMES_RNGMULT + GAMES_RNGOFFSET); + seeds[2] = ((seeds[0] ^ seeds[1] ^ seeds[2])*GAMES_RNGMULT + GAMES_RNGOFFSET); + seeds[3] = ((seeds[0] ^ seeds[1] ^ seeds[2] ^ seeds[3])*GAMES_RNGMULT + GAMES_RNGOFFSET); + return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); +} + #ifndef STANDALONE #include "tetris.cpp" // replace with game specific functions @@ -195,20 +210,6 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf return(result); } -uint64_t _games_rngnext(uint64_t initseed) -{ - uint16_t seeds[4]; int32_t i; - seeds[0] = initseed; - seeds[1] = (initseed >> 16); - seeds[2] = (initseed >> 32); - seeds[3] = (initseed >> 48); - seeds[0] = (seeds[0]*GAMES_RNGMULT + GAMES_RNGOFFSET); - seeds[1] = ((seeds[0] ^ seeds[1])*GAMES_RNGMULT + GAMES_RNGOFFSET); - seeds[2] = ((seeds[0] ^ seeds[1] ^ seeds[2])*GAMES_RNGMULT + GAMES_RNGOFFSET); - seeds[3] = ((seeds[0] ^ seeds[1] ^ seeds[2] ^ seeds[3])*GAMES_RNGMULT + GAMES_RNGOFFSET); - return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); -} - UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); int32_t n; uint64_t seed; From fd3ded58bc46422389e95033d69f22779fa99ec9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:07:13 -1100 Subject: [PATCH 3202/3904] #define GAMES_RNGMULT 11109 #define GAMES_RNGOFFSET 13849 #define GAMES_MAXRNGS 10000 --- src/cc/gamescc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 07a1f8e65..6ec5dc9c4 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -3,6 +3,9 @@ #include #include +#define GAMES_RNGMULT 11109 +#define GAMES_RNGOFFSET 13849 +#define GAMES_MAXRNGS 10000 #ifndef STANDALONE @@ -22,9 +25,6 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define GAMES_REGISTRATIONSIZE (100 * 10000) #define GAMES_REGISTRATION 1 -#define GAMES_RNGMULT 11109 -#define GAMES_RNGOFFSET 13849 -#define GAMES_MAXRNGS 10000 #define MYCCNAME "games" From 4e9f443e4a20fa1cf635541c6f0b6886802c36fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Mar 2019 21:09:24 +0800 Subject: [PATCH 3203/3904] fix minrelease recover transaction --- src/cc/rewards.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index db64127e7..2438b4035 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -257,9 +257,12 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t } if ( !CheckTxFee(tx, txfee, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) ) return eval->Invalid("txfee is too high"); + reward = RewardsCalc(amount,tx.vin[0].prevout.hash,APR,minseconds,maxseconds,mindeposit); if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 && tx.vout[1].nValue == 10000 ) { - if ( tx.vout[1].scriptPubKey != tx.vout[0].scriptPubKey ) + if ( reward == 0 ) + return eval->Invalid("unlock recover no rewards"); + else if ( tx.vout[1].scriptPubKey != tx.vout[0].scriptPubKey ) return eval->Invalid("unlock recover tx vout.1 mismatched scriptPubKey"); else if ( tx.vout[0].scriptPubKey != vinTx.vout[1].scriptPubKey ) return eval->Invalid("unlock recover tx vout.0 mismatched scriptPubKey"); From 5330c2349980178a6236e6d32308ef4b4982573c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:23:50 -1100 Subject: [PATCH 3204/3904] Gamesiterate --- src/cc/tetris.c | 186 ++++++++++++++++++++++++------------------------ 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 1b039dc6f..1cc7962f5 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -638,13 +638,13 @@ void init_colors(void) */ #include "dapps/dappstd.c" -int32_t issue_games_events(struct games_state *rs,bits256 gametxid,uint32_t eventid,char c) +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,char c) { static FILE *fp; - char params[512],*retstr,str[65]; cJSON *retjson,*resobj; int32_t retval = -1; + char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; if ( fp == 0 ) fp = fopen("events.log","wb"); - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,bits256_str(str,gametxid),eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,gametxidstr,eventid); rs->buffered[rs->num++] = c; if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { @@ -685,15 +685,98 @@ char *clonestr(char *str) struct games_state globalR; +void gamesiterate(struct games_state *rs,tetris_game *tg) +{ + uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; + int32_t c,skipcount=0; uint32_t eventid = 0; + WINDOW *board, *next, *hold, *score; + // Create windows for each section of the interface. + board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); + next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); + hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); + score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); + while (running) + { + running = tg_tick(rs,tg, move); + display_board(board, tg); + display_piece(next, tg->next); + display_piece(hold, tg->stored); + display_score(score, tg); + if ( (counter++ % 5) == 0 ) + doupdate(); + sleep_milli(10); + c = getch(); + switch ( c ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } + if ( c < 0 || skipcount == 0x7f ) + { + if ( skipcount > 0 ) + issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x80); + if ( c != -1 ) + issue_games_events(rs,Gametxidstr,eventid,c); + skipcount = 0; + } else skipcount++; + eventid++; + switch ( c ) + { + case 'h': + move = TM_LEFT; + break; + case 'l': + move = TM_RIGHT; + break; + case 'k': + move = TM_CLOCK; + break; + case 'j': + move = TM_DROP; + break; + case 'q': + running = false; + move = TM_NONE; + break; + /*case 'p': + wclear(board); + box(board, 0, 0); + wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); + wprintw(board, "PAUSED"); + wrefresh(board); + timeout(-1); + getch(); + timeout(0); + move = TM_NONE; + break; + case 's': + save(tg, board); + move = TM_NONE; + break;*/ + case ' ': + move = TM_HOLD; + break; + default: + move = TM_NONE; + } + } +} + int tetris(int argc, char **argv) { tetris_game *tg; - tetris_move move = TM_NONE; - bool running = true; - WINDOW *board, *next, *hold, *score; struct games_state *rs = &globalR; - int32_t c,skipcount=0; bits256 gametxid; uint32_t eventid = 0; - memset(&gametxid,0,sizeof(gametxid)); + int32_t c,skipcount=0; uint32_t eventid = 0; memset(rs,0,sizeof(*rs)); rs->guiflag = 1; rs->sleeptime = 1; // non-zero to allow refresh() @@ -741,88 +824,9 @@ int tetris(int argc, char **argv) curs_set(0); // set the cursor to invisible init_colors(); // setup tetris colors - // Create windows for each section of the interface. - board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); - next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); - hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); - score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); - int32_t counter = 0; // Game loop - while (running) { - running = tg_tick(rs,tg, move); - display_board(board, tg); - display_piece(next, tg->next); - display_piece(hold, tg->stored); - display_score(score, tg); - if ( (counter++ % 5) == 0 ) - doupdate(); - sleep_milli(10); - c = getch(); - switch ( c ) - { - case KEY_LEFT: - c = 'h'; - break; - case KEY_RIGHT: - c = 'l'; - break; - case KEY_UP: - c = 'k'; - break; - case KEY_DOWN: - c = 'j'; - break; - } - if ( c < 0 || skipcount == 0x7f ) - { - if ( skipcount > 0 ) - issue_games_events(rs,gametxid,eventid-skipcount,skipcount | 0x80); - if ( c != -1 ) - issue_games_events(rs,gametxid,eventid,c); - skipcount = 0; - } else skipcount++; - eventid++; - switch ( c ) - { - case 'h': - move = TM_LEFT; - break; - case 'l': - move = TM_RIGHT; - break; - case 'k': - move = TM_CLOCK; - break; - case 'j': - move = TM_DROP; - break; - case 'q': - running = false; - move = TM_NONE; - break; - /*case 'p': - wclear(board); - box(board, 0, 0); - wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); - wprintw(board, "PAUSED"); - wrefresh(board); - timeout(-1); - getch(); - timeout(0); - move = TM_NONE; - break; - case 's': - save(tg, board); - move = TM_NONE; - break;*/ - case ' ': - move = TM_HOLD; - break; - default: - move = TM_NONE; - } - } - + gamesiterate(rs,tg); + games_bailout(rs); // Deinitialize NCurses wclear(stdscr); endwin(); @@ -835,9 +839,5 @@ int tetris(int argc, char **argv) return 0; } -void gamesiterate(struct games_state *rs) -{ - -} #endif From b0d0adb729531b32267a673e9a0f1a6dbd42eb04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:28:32 -1100 Subject: [PATCH 3205/3904] Gamesiterate --- src/cc/tetris.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 1cc7962f5..98e6a2fab 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -685,12 +685,13 @@ char *clonestr(char *str) struct games_state globalR; -void gamesiterate(struct games_state *rs,tetris_game *tg) +void gamesiterate(struct games_state *rs) { uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; - int32_t c,skipcount=0; uint32_t eventid = 0; + int32_t c,skipcount=0; uint32_t eventid = 0; tetris_game *tg; WINDOW *board, *next, *hold, *score; // Create windows for each section of the interface. + tg = tg_create(rs,22, 10); board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); @@ -774,7 +775,6 @@ void gamesiterate(struct games_state *rs,tetris_game *tg) int tetris(int argc, char **argv) { - tetris_game *tg; struct games_state *rs = &globalR; int32_t c,skipcount=0; uint32_t eventid = 0; memset(rs,0,sizeof(*rs)); @@ -813,7 +813,6 @@ int tetris(int argc, char **argv) // Otherwise create new game. tg = tg_create(rs,22, 10); }*/ - tg = tg_create(rs,22, 10); // NCURSES initialization: initscr(); // initialize curses @@ -825,7 +824,7 @@ int tetris(int argc, char **argv) init_colors(); // setup tetris colors // Game loop - gamesiterate(rs,tg); + gamesiterate(rs); games_bailout(rs); // Deinitialize NCurses wclear(stdscr); From a02e96bc3b1b1c62b6b1ec7006b7a2ae2f3ec0e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:41:16 -1100 Subject: [PATCH 3206/3904] Free obj --- src/cc/dapps/dappstd.c | 15 ++++++++++----- src/cc/tetris.c | 21 +++++++++++---------- src/cc/tetris.h | 2 +- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index b93e7b41d..1ab3e6427 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -24,7 +24,7 @@ #include extern struct games_state globalR; -void gamesiterate(struct games_state *rs); +void *gamesiterate(struct games_state *rs); char USERPASS[8192]; uint16_t GAMES_PORT; char Gametxidstr[67]; @@ -866,7 +866,7 @@ void games_bailout(struct games_state *rs) int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) { - struct games_state *rs; FILE *fp; int32_t i,n; + struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; rs = (struct games_state *)calloc(1,sizeof(*rs)); rs->seed = seed; rs->keystrokes = keystrokes; @@ -882,7 +882,7 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu } globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); - gamesiterate(rs); + ptr = gamesiterate(rs); if ( 0 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); @@ -909,8 +909,13 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); }*/ - if ( newdata != 0 && rs->playersize > 0 ) - memcpy(newdata,rs->playerdata,rs->playersize); + if ( ptr != 0 ) + { + // extract data from ptr + if ( newdata != 0 && rs->playersize > 0 ) + memcpy(newdata,rs->playerdata,rs->playersize); + free(ptr); + } n = rs->playersize; free(rs); return(n); diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 98e6a2fab..0f81971c4 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -436,7 +436,7 @@ void tg_init(struct games_state *rs,tetris_game *obj, int rows, int cols) // Initialization logic obj->rows = rows; obj->cols = cols; - obj->board = (char *)malloc(rows * cols); + //obj->board = (char *)malloc(rows * cols); memset(obj->board, TC_EMPTY, rows * cols); obj->points = 0; obj->level = 0; @@ -454,19 +454,19 @@ void tg_init(struct games_state *rs,tetris_game *obj, int rows, int cols) tetris_game *tg_create(struct games_state *rs,int rows, int cols) { - tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game) + rows*cols); tg_init(rs,obj, rows, cols); return obj; } -void tg_destroy(tetris_game *obj) +/*void tg_destroy(tetris_game *obj) { // Cleanup logic free(obj->board); -} +}*/ void tg_delete(tetris_game *obj) { - tg_destroy(obj); + //tg_destroy(obj); free(obj); } @@ -591,7 +591,7 @@ void display_score(WINDOW *w, tetris_game *tg) /* Save and exit the game. - */ + void save(tetris_game *game, WINDOW *w) { FILE *f; @@ -614,7 +614,7 @@ void save(tetris_game *game, WINDOW *w) fprintf(stderr,"Game saved to \"tetris.save\".\n"); fprintf(stderr,"Resume by passing the filename as an argument to this program.\n"); exit(EXIT_SUCCESS); -} +}*/ /* Do the NCURSES initialization steps for color blocks. @@ -685,7 +685,7 @@ char *clonestr(char *str) struct games_state globalR; -void gamesiterate(struct games_state *rs) +void *gamesiterate(struct games_state *rs) { uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; int32_t c,skipcount=0; uint32_t eventid = 0; tetris_game *tg; @@ -771,12 +771,13 @@ void gamesiterate(struct games_state *rs) move = TM_NONE; } } + return(tg); } int tetris(int argc, char **argv) { struct games_state *rs = &globalR; - int32_t c,skipcount=0; uint32_t eventid = 0; + int32_t c,skipcount=0; uint32_t eventid = 0; tetris_game *tg = 0; memset(rs,0,sizeof(*rs)); rs->guiflag = 1; rs->sleeptime = 1; // non-zero to allow refresh() @@ -824,7 +825,7 @@ int tetris(int argc, char **argv) init_colors(); // setup tetris colors // Game loop - gamesiterate(rs); + tg = gamesiterate(rs); games_bailout(rs); // Deinitialize NCurses wclear(stdscr); diff --git a/src/cc/tetris.h b/src/cc/tetris.h index 40a9c97cb..9fce377d7 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -97,7 +97,6 @@ typedef struct { */ int rows; int cols; - char *board; /* Scoring information: */ @@ -118,6 +117,7 @@ typedef struct { Number of lines until you advance to the next level. */ int lines_remaining; + char board[]; } tetris_game; /* From 44776662d087dd12d3e2d40a4f73adb0ff126ea3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:45:09 -1100 Subject: [PATCH 3207/3904] -load --- src/cc/tetris.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 0f81971c4..23d58e45c 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -472,7 +472,7 @@ void tg_delete(tetris_game *obj) { /* Load a game from a file. - */ + tetris_game *tg_load(FILE *f) { tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); @@ -494,18 +494,18 @@ tetris_game *tg_load(FILE *f) } } return obj; -} +}*/ /* Save a game to a file. - */ + void tg_save(tetris_game *obj, FILE *f) { if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) fprintf(stderr,"error writing tetrisgame\n"); else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) fprintf(stderr,"error writing board\n"); -} +}*/ /* Print a game board to a file. Really just for early debugging. From 6712caf91e3ae2cf1f013e689e419dc72cacdfa8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 02:46:10 -1100 Subject: [PATCH 3208/3904] Ptr --- src/cc/tetris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 23d58e45c..305bf0c3b 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -825,7 +825,7 @@ int tetris(int argc, char **argv) init_colors(); // setup tetris colors // Game loop - tg = gamesiterate(rs); + tg = (tetris_game *)gamesiterate(rs); games_bailout(rs); // Deinitialize NCurses wclear(stdscr); From 6ba7bf538c81c86345fb41d70dfbed977b84aa69 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Mar 2019 22:13:14 +0800 Subject: [PATCH 3209/3904] small fix --- src/cc/rewards.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 2438b4035..73f723453 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -258,10 +258,12 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t if ( !CheckTxFee(tx, txfee, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) ) return eval->Invalid("txfee is too high"); reward = RewardsCalc(amount,tx.vin[0].prevout.hash,APR,minseconds,maxseconds,mindeposit); - if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 && tx.vout[1].nValue == 10000 ) + if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) { if ( reward == 0 ) return eval->Invalid("unlock recover no rewards"); + else if ( tx.vout[1].nValue != 10000 ) + return eval->Invalid("wrong marker vour value"); else if ( tx.vout[1].scriptPubKey != tx.vout[0].scriptPubKey ) return eval->Invalid("unlock recover tx vout.1 mismatched scriptPubKey"); else if ( tx.vout[0].scriptPubKey != vinTx.vout[1].scriptPubKey ) From b7c8205870d3ada608abbf1d29acb67c43c0eb39 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:14:26 -1100 Subject: [PATCH 3210/3904] Origseed --- src/cc/dapps/dappstd.c | 65 ++++++++++++++++++++++++++++++--- src/cc/tetris.c | 82 +++++++++++++++++++++++++----------------- src/cc/tetris.h | 2 +- 3 files changed, 111 insertions(+), 38 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 1ab3e6427..f98a3af63 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -805,7 +805,7 @@ int32_t flushkeystrokes_local(struct games_state *rs,int32_t waitflag) #ifdef STANDALONE char fname[1024]; FILE *fp; int32_t i,retflag = -1; rs->counter++; - gamesfname(fname,rs->seed,rs->counter); + gamesfname(fname,rs->origseed,rs->counter); if ( (fp= fopen(fname,"wb")) != 0 ) { if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num ) @@ -813,7 +813,7 @@ int32_t flushkeystrokes_local(struct games_state *rs,int32_t waitflag) rs->num = 0; retflag = 0; fclose(fp); - gamesfname(fname,rs->seed,rs->counter+1); + gamesfname(fname,rs->origseed,rs->counter+1); if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file fclose(fp); //fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag); @@ -844,7 +844,7 @@ int32_t flushkeystrokes(struct games_state *rs,int32_t waitflag) { if ( rs->num > 0 ) { - if ( games_progress(rs,waitflag,rs->seed,rs->buffered,rs->num) > 0 ) + if ( games_progress(rs,waitflag,rs->origseed,rs->buffered,rs->num) > 0 ) { flushkeystrokes_local(rs,waitflag); memset(rs->buffered,0,sizeof(rs->buffered)); @@ -868,7 +868,7 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu { struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; rs = (struct games_state *)calloc(1,sizeof(*rs)); - rs->seed = seed; + rs->seed = rs->origseed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; rs->sleeptime = sleepmillis * 1000; @@ -891,7 +891,7 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu for (i=0; i<10000; i++) { memset(rs,0,sizeof(*rs)); - rs->seed = seed; + rs->seed = rs->origseed = seed; rs->keystrokes = keystrokes; rs->numkeys = num; rs->sleeptime = 0; @@ -1009,6 +1009,61 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) return(num); } +char games_readchar(struct rogue_state *rs) +{ + char c,ch = -1; + if ( rs != 0 && rs->guiflag == 0 ) + { + static uint32_t counter; + if ( rs->ind < rs->numkeys ) + { + c = rs->keystrokes[rs->ind++]; + if ( 0 ) + { + static FILE *fp; static int32_t counter; + if ( fp == 0 ) + fp = fopen("log","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); + fflush(fp); + counter++; + } + } + return(c); + } + if ( rs->replaydone != 0 && counter++ < 3 ) + fprintf(stderr,"replay finished but readchar called\n"); + rs->replaydone = (uint32_t)time(NULL); + if ( counter < 3 || (counter & 1) == 0 ) + return('y'); + else return(ESCAPE); + } + if ( rs == 0 || rs->guiflag != 0 ) + { + ch = (char) getch(); + if (ch == 3) + { + _quit(); + return(27); + } + if ( rs != 0 && rs->guiflag != 0 ) + { + if ( rs->num < sizeof(rs->buffered) ) + { + rs->buffered[rs->num++] = ch; + if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) + { + rs->needflush = (uint32_t)time(NULL); + //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); + //sleep(3); + } + } else fprintf(stderr,"buffer filled without flushed\n"); + } + } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); + return(ch); +} + int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) { char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson; diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 305bf0c3b..3047e0e55 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -696,40 +696,57 @@ void *gamesiterate(struct games_state *rs) next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); - while (running) + while ( running != 0 ) { - running = tg_tick(rs,tg, move); - display_board(board, tg); - display_piece(next, tg->next); - display_piece(hold, tg->stored); - display_score(score, tg); - if ( (counter++ % 5) == 0 ) - doupdate(); - sleep_milli(10); - c = getch(); - switch ( c ) + running = tg_tick(rs,tg,move); + if ( rs->guiflag != 0 ) { - case KEY_LEFT: - c = 'h'; - break; - case KEY_RIGHT: - c = 'l'; - break; - case KEY_UP: - c = 'k'; - break; - case KEY_DOWN: - c = 'j'; - break; + display_board(board,tg); + display_piece(next,tg->next); + display_piece(hold,tg->stored); + display_score(score,tg); + if ( (counter++ % 5) == 0 ) + doupdate(); + sleep_milli(10); + c = games_readchar(rs); + switch ( c ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } + if ( c < 0 || skipcount == 0x7f ) + { + if ( skipcount > 0 ) + issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x80); + if ( c != -1 ) + issue_games_events(rs,Gametxidstr,eventid,c); + skipcount = 0; + } else skipcount++; } - if ( c < 0 || skipcount == 0x7f ) + else { + if ( skipcount == 0 ) + { + c = games_readchar(rs); + if ( (c & 0x80) != 0 ) + { + skipcount = (c & 0x7f); + c = 'S'; + } + } if ( skipcount > 0 ) - issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x80); - if ( c != -1 ) - issue_games_events(rs,Gametxidstr,eventid,c); - skipcount = 0; - } else skipcount++; + skipcount--; + } eventid++; switch ( c ) { @@ -785,13 +802,14 @@ int tetris(int argc, char **argv) { #ifdef _WIN32 #ifdef _MSC_VER - rs->seed = _strtoui64(argv[1], NULL, 10); + rs->origseed = _strtoui64(argv[1], NULL, 10); #else - rs->seed = atol(argv[1]); // windows, but not MSVC + rs->origseed = atol(argv[1]); // windows, but not MSVC #endif // _MSC_VER #else - rs->seed = atol(argv[1]); // non-windows + rs->origseed = atol(argv[1]); // non-windows #endif // _WIN32 + rs->seed = rs->origseed; strcpy(Gametxidstr,argv[2]); fprintf(stderr,"setplayerdata\n"); if ( games_setplayerdata(rs,Gametxidstr) < 0 ) diff --git a/src/cc/tetris.h b/src/cc/tetris.h index 9fce377d7..317dad62b 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -182,7 +182,7 @@ struct games_player struct games_state { - uint64_t seed; + uint64_t seed,origseed; char *keystrokes,*keystrokeshex; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; From 81263613bb334f39325a4c46bcae4b3cd8eceded Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:15:11 -1100 Subject: [PATCH 3211/3904] Games --- src/cc/dapps/dappstd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index f98a3af63..714bcaf82 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -1009,7 +1009,7 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) return(num); } -char games_readchar(struct rogue_state *rs) +char games_readchar(struct games_state *rs) { char c,ch = -1; if ( rs != 0 && rs->guiflag == 0 ) From d223563eff2e4595e0fa11102d4b7c429b76ffa6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:16:36 -1100 Subject: [PATCH 3212/3904] Test --- src/cc/dapps/dappstd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 714bcaf82..0f3d8cc24 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -1035,16 +1035,14 @@ char games_readchar(struct games_state *rs) if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); - if ( counter < 3 || (counter & 1) == 0 ) - return('y'); - else return(ESCAPE); + return(0); } if ( rs == 0 || rs->guiflag != 0 ) { ch = (char) getch(); if (ch == 3) { - _quit(); + //_quit(); return(27); } if ( rs != 0 && rs->guiflag != 0 ) From a4103580310f3648eecf57747a5b6ed1b371066d Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Tue, 26 Mar 2019 15:36:10 +0100 Subject: [PATCH 3213/3904] Correct GatewaysCC validation to check spending from global address. (#19) - Add additional vin/vout check - Check that marker spending from global CC address is only for a marker value - Set fixed marker values instead of depending on txfee --- src/cc/gateways.cpp | 163 +++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 78 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index f0c8735e2..4993e1078 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -152,6 +152,7 @@ #define KMD_P2SHTYPE 85 #define KMD_WIFTYPE 188 #define KMD_TADDR 0 +#define CC_MARKER_VALUE 10000 CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector gatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype) { @@ -185,7 +186,7 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui if ( N > 1 ) { strcpy(depositaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys))).ToString().c_str()); - LOGSTREAM("gatewayscc", CCLOG_DEBUG1, stream << "f." << f << " M." << M << " of N." << N << " size." << (int32_t)gatewaypubkeys.size() << " -> " << depositaddr << std::endl); + LOGSTREAM("gatewayscc", CCLOG_DEBUG1, stream << "f." << f << " M." << (int)M << " of N." << (int)N << " size." << (int32_t)gatewaypubkeys.size() << " -> " << depositaddr << std::endl); } else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG); } else @@ -600,7 +601,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],K,M,N,taddr,prefix,prefix2,wiftype; - char str[65],destaddr[64],depositaddr[65],validationError[512]; + char str[65],destaddr[65],depositaddr[65],gatewaystokensaddr[65],validationError[512]; std::vector txids; std::vector pubkeys,publishers,tmppublishers; std::vector proof; int64_t fullsupply,totalsupply,amount,tmpamount; uint256 hashblock,txid,bindtxid,deposittxid,withdrawtxid,completetxid,tokenid,tmptokenid,oracletxid,bindtokenid,cointxid,tmptxid,merkleroot,mhash; CTransaction bindtx,tmptx; std::string refcoin,tmprefcoin,hex,name,description,format; CPubKey pubkey,tmppubkey,gatewayspk; @@ -619,7 +620,8 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & // } // else // { - gatewayspk = GetUnspendable(cp,0); + gatewayspk = GetUnspendable(cp,0); + GetTokensCCaddress(cp, gatewaystokensaddr, gatewayspk); if ( (funcid = DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)) != 0) { switch ( funcid ) @@ -628,14 +630,14 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & //vin.0: normal input //vin.1: CC input of tokens //vout.0: CC vout of gateways tokens to gateways tokens CC address - //vout.1: CC vout txfee marker + //vout.1: CC vout marker //vout.n-1: opreturn - 'B' tokenid coin totalsupply oracletxid M N pubkeys taddr prefix prefix2 wiftype return eval->Invalid("unexpected GatewaysValidate for gatewaysbind!"); break; case 'D': //vin.0: normal input - //vout.0: CC vout txfee marker to destination pubkey - //vout.1: normal output txfee marker to txidaddr + //vout.0: CC vout marker to destination pubkey + //vout.1: normal output marker to txidaddr //vout.n-1: opreturn - 'D' bindtxid coin publishers txids height cointxid claimvout deposithex proof destpub amount return eval->Invalid("unexpected GatewaysValidate for gatewaysdeposit!"); break; @@ -647,19 +649,19 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & //vout.1: CC vout change of gateways tokens to gateways tokens CC address (if any) //vout.n-1: opreturn - 'C' tokenid bindtxid coin deposittxid destpub amount if ((numvouts=tx.vout.size()) < 1 || DecodeGatewaysClaimOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,refcoin,deposittxid,pubkey,amount)!='C') - return eval->Invalid("invalid gatewaysClaim OP_RETURN data!"); - else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for gatewaysClaim!"); - else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for gatewaysClaim!"); - else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) - return eval->Invalid("vin.2 is CC for gatewaysClaim!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewaysClaim!"); + return eval->Invalid("invalid gatewaysclaim OP_RETURN data!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,tmprefcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysbind!"); + else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysbind!"); + else if ( ConstrainVout(tmptx.vout[0],1,gatewaystokensaddr,totalsupply)==0) + return eval->Invalid("invalid tokens to gateways vout for gatewaysbind!"); + else if ( ConstrainVout(tmptx.vout[1],1,cp->unspendableCCaddr,CC_MARKER_VALUE)==0) + return eval->Invalid("invalid marker vout for gatewaysbind!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); else if (tmptokenid!=tokenid) @@ -697,6 +699,12 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("invalid gatewaysdeposittxid!"); else if ((numvouts=tmptx.vout.size()) < 1 || DecodeGatewaysDepositOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptxid,tmprefcoin,tmppublishers,txids,height,cointxid,claimvout,hex,proof,tmppubkey,tmpamount) != 'D') return eval->Invalid("invalid gatewaysdeposit OP_RETURN data!"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysdeposit!"); + else if ( GetCCaddress(cp,destaddr,tmppubkey)==0 || ConstrainVout(tmptx.vout[0],1,destaddr,CC_MARKER_VALUE)==0) + return eval->Invalid("invalid CC marker vout for gatewaysdeposit!"); + else if ( CCtxidaddr(destaddr,cointxid)==CPubKey() || ConstrainVout(tmptx.vout[1],0,destaddr,CC_MARKER_VALUE)==0) + return eval->Invalid("invalid normal marker vout for gatewaysdeposit!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in deposit tx"); else if (bindtxid!=tmptxid) @@ -705,6 +713,18 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("deposit amount greater then bind total supply"); else if (komodo_txnotarizedconfirmed(deposittxid) == false) return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(tx.vin[2].prevout.hash,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysdeposittxid!"); + else if (IsCCInput(tx.vin[0].scriptSig) != 0) + return eval->Invalid("vin.0 is normal for gatewaysclaim!"); + else if (IsCCInput(tx.vin[1].scriptSig) == 0) + return eval->Invalid("vin.1 is CC for gatewaysclaim!"); + else if ((*cp->ismyvin)(tx.vin[2].scriptSig) == 0 || myGetTransaction(tx.vin[2].prevout.hash,tmptx,hashblock)==0 || tmptx.vout[tx.vin[2].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.2 is CC marker for gatewaysclaim or invalid marker amount!"); + else if (_GetCCaddress(destaddr,EVAL_TOKENS,pubkey)==0 || ConstrainVout(tx.vout[0],1,destaddr,amount)==0) + return eval->Invalid("invalid vout tokens to destpub for gatewaysclaim!"); + else if (numvouts>2 && (myGetTransaction(tx.vin[1].prevout.hash,tmptx,hashblock)==0 || ConstrainVout(tx.vout[1],1,gatewaystokensaddr,tmptx.vout[tx.vin[1].prevout.n].nValue-amount)==0)) + return eval->Invalid("invalid CC change vout for gatewaysclaim!"); else if (amount!=tmpamount) return eval->Invalid("claimed amount different then deposit amount"); else if (tx.vout[0].nValue!=amount) @@ -739,7 +759,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & case 'W': //vin.0: normal input //vin.1: CC input of tokens - //vout.0: CC vout txfee marker to gateways CC address + //vout.0: CC vout marker to gateways CC address //vout.1: CC vout of gateways tokens back to gateways tokens CC address //vout.2: CC vout change of tokens back to owners pubkey (if any) //vout.n-1: opreturn - 'W' tokenid bindtxid refcoin withdrawpub amount @@ -748,16 +768,10 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & case 'P': //vin.0: normal input //vin.1: CC input of marker from previous tx (withdraw or partialsing) - //vout.0: CC vout txfee marker to gateways CC address + //vout.0: CC vout marker to gateways CC address //vout.n-1: opreturn - 'P' withdrawtxid refcoin number_of_signs mypk hex if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,K,pubkey,hex)!='P') - return eval->Invalid("invalid gatewaysPartialSign OP_RETURN data!"); - else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for gatewaysPartialSign!"); - else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for gatewaysPartialSign!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewaysPartialSign!"); + return eval->Invalid("invalid gatewaysPartialSign OP_RETURN data!"); else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid withdraw txid!"); else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,tmprefcoin,pubkey,amount)!='W') @@ -768,10 +782,10 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); - else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewaysWithdraw!"); - else if ( tmptx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.1 is CC for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE)==0) + return eval->Invalid("invalid marker vout for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[1],1,gatewaystokensaddr,amount)==0) + return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); else if (tmptx.vout[1].nValue!=amount) return eval->Invalid("amount in opret not matching tx tokens amount!"); else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) @@ -785,23 +799,23 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & else if (tmptokenid!=tokenid) return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); else if (komodo_txnotarizedconfirmed(bindtxid) == false) - return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (IsCCInput(tx.vin[0].scriptSig) != 0) + return eval->Invalid("vin.0 is normal for gatewayspartialsign!"); + else if ((*cp->ismyvin)(tx.vin[1].scriptSig) == 0 || myGetTransaction(tx.vin[1].prevout.hash,tmptx,hashblock)==0 || tmptx.vout[tx.vin[1].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.1 is CC marker for gatewayspartialsign or invalid marker amount!"); + else if (ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE) == 0 ) + return eval->Invalid("vout.0 invalid marker for gatewayspartialsign!"); else if (K>M) return eval->Invalid("invalid number of signs!"); break; case 'S': //vin.0: normal input //vin.1: CC input of marker from previous tx (withdraw or partialsing) - //vout.0: CC vout txfee marker to gateways CC address + //vout.0: CC vout marker to gateways CC address //vout.n-1: opreturn - 'S' withdrawtxid refcoin hex if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,K,hex)!='S') return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); - else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); - else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for gatewayscompletesigning!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewayscompletesigning!"); else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid withdraw txid!"); else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,tmprefcoin,pubkey,amount)!='W') @@ -812,10 +826,10 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); - else if ( tmptx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.0 is CC for gatewaysWithdraw!"); - else if ( tmptx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.1 is CC for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE)==0) + return eval->Invalid("invalid marker vout for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[1],1,gatewaystokensaddr,amount)==0) + return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); else if (tmptx.vout[1].nValue!=amount) return eval->Invalid("amount in opret not matching tx tokens amount!"); else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) @@ -829,21 +843,22 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & else if (tmptokenid!=tokenid) return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); else if (komodo_txnotarizedconfirmed(bindtxid) == false) - return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (IsCCInput(tx.vin[0].scriptSig) != 0) + return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); + else if ((*cp->ismyvin)(tx.vin[1].scriptSig) == 0 || myGetTransaction(tx.vin[1].prevout.hash,tmptx,hashblock)==0 || tmptx.vout[tx.vin[1].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.1 is CC marker for gatewayscompletesigning or invalid marker amount!"); + else if (ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE) == 0 ) + return eval->Invalid("vout.0 invalid marker for gatewayscompletesigning!"); else if (KInvalid("invalid number of signs!"); break; case 'M': - //vin.0: CC input of gatewayscompletesigning tx marker to gateways CC address + //vin.0: normal input + //vin.1: CC input of gatewayscompletesigning tx marker to gateways CC address //vout.0: opreturn - 'M' withdrawtxid refcoin completetxid if ((numvouts=tx.vout.size()) > 0 && DecodeGatewaysMarkDoneOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,completetxid)!='M') - return eval->Invalid("invalid gatewaysmarkdone OP_RETURN data!"); - else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for gatewaysmarkdone!"); - else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for gatewaysmarkdone!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 ) - return eval->Invalid("vout.0 is normal for gatewaysmarkdone!"); + return eval->Invalid("invalid gatewaysmarkdone OP_RETURN data!"); else if (myGetTransaction(completetxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewayscompletesigning txid!"); else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S') @@ -867,7 +882,11 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & else if (tmptokenid!=tokenid) return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); else if (komodo_txnotarizedconfirmed(bindtxid) == false) - return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysmarkdone!"); + else if ((*cp->ismyvin)(tx.vin[1].scriptSig) == 0 || myGetTransaction(tx.vin[1].prevout.hash,tmptx,hashblock)==0 || tmptx.vout[tx.vin[1].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.1 is CC marker for gatewaysmarkdone or invalid marker amount!"); else if (KInvalid("invalid number of signs!"); break; @@ -907,29 +926,17 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { funcid=DecodeGatewaysOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey); - if (vout==0 && funcid=='B' && bindtxid==txid && total != 0 && maxinputs != 0) + if ((vout==0 && funcid=='B' && bindtxid==txid && total != 0 && maxinputs != 0) || + (vout==1 && funcid=='W' && DecodeGatewaysWithdrawOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,tmptokenid,tmpbindtxid,tmprefcoin,withdrawpub,amount) == 'W' && + tmpbindtxid==bindtxid && tmprefcoin==refcoin && tmptokenid==tokenid && total != 0 && maxinputs != 0) || + (vout==1 && funcid=='C' && DecodeGatewaysClaimOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,tmptokenid,tmpbindtxid,tmprefcoin,deposittxid,destpub,amount) == 'C' && + tmpbindtxid==bindtxid && tmprefcoin==refcoin && tmptokenid==tokenid && total != 0 && maxinputs != 0)) { mtx.vin.push_back(CTxIn(txid,vout,CScript())); totalinputs += it->second.satoshis; n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; - } - else if (vout==1 && funcid=='W' && DecodeGatewaysWithdrawOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,tmptokenid,tmpbindtxid,tmprefcoin,withdrawpub,amount) == 'W' && - tmpbindtxid==bindtxid && tmprefcoin==refcoin && tmptokenid==tokenid && total != 0 && maxinputs != 0) - { - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - totalinputs += it->second.satoshis; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; - } - else if (vout==1 && funcid=='C' && DecodeGatewaysClaimOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,tmptokenid,tmpbindtxid,tmprefcoin,deposittxid,destpub,amount) == 'C' && - tmpbindtxid==bindtxid && tmprefcoin==refcoin && tmptokenid==tokenid && total != 0 && maxinputs != 0) - { - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - totalinputs += it->second.satoshis; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs)) break; - } + } } } return(totalinputs); @@ -1033,12 +1040,12 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) + if ( AddNormalinputs(mtx,mypk,txfee+CC_MARKER_VALUE,3) > 0 ) { if (AddTokenCCInputs(cpTokens, mtx, mypk, tokenid, totalsupply, 64)>0) { mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,totalsupply,gatewayspk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gatewayspk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CC_MARKER_VALUE,gatewayspk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysBindOpRet('B',tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype))); } } @@ -1112,10 +1119,10 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( AddNormalinputs(mtx,mypk,3*txfee,4) > 0 ) + if ( AddNormalinputs(mtx,mypk,txfee+2*CC_MARKER_VALUE,4) > 0 ) { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,destpub)); - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,cointxid))) << OP_CHECKSIG)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CC_MARKER_VALUE,destpub)); + mtx.vout.push_back(CTxOut(CC_MARKER_VALUE,CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr,cointxid))) << OP_CHECKSIG)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysDepositOpRet('D',bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,destpub,amount))); } CCerror = strprintf("cant find enough inputs"); @@ -1262,12 +1269,12 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin } } } - if( AddNormalinputs(mtx, mypk, 3*txfee, 4) > 0 ) + if( AddNormalinputs(mtx, mypk, txfee+CC_MARKER_VALUE, 4) > 0 ) { if ((inputs = AddTokenCCInputs(cpTokens, mtx, mypk, tokenid, amount, 60)) > 0) { if ( inputs > amount ) CCchange = (inputs - amount); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CC_MARKER_VALUE,gatewayspk)); mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,amount,gatewayspk)); if ( CCchange != 0 ) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); return(FinalizeCCTx(0, cpTokens, mtx, mypk, txfee,EncodeGatewaysWithdrawOpRet('W',tokenid,bindtxid,refcoin,withdrawpub,amount))); @@ -1377,7 +1384,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc if (AddNormalinputs(mtx,mypk,txfee,3)!=0) { mtx.vin.push_back(CTxIn(tx.GetHash(),0,CScript())); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CC_MARKER_VALUE,gatewayspk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysPartialOpRet('P',withdrawtxid,refcoin,K+1,mypk,hex))); } CCerror = strprintf("error adding funds for partialsign"); @@ -1476,7 +1483,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string if (AddNormalinputs(mtx,mypk,txfee,3)!=0) { mtx.vin.push_back(CTxIn(lasttxid,0,CScript())); - mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,txfee,gatewayspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CC_MARKER_VALUE,gatewayspk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,K+1,hex))); } CCerror = strprintf("error adding funds for completesigning"); @@ -1541,7 +1548,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref if (AddNormalinputs(mtx,mypk,txfee,3)!=0) { mtx.vin.push_back(CTxIn(completetxid,0,CScript())); - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(CC_MARKER_VALUE,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',withdrawtxid,refcoin,completetxid))); } CCerror = strprintf("error adding funds for markdone"); From 80085d9d390de918412418dff05e64121b55b8aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:38:25 -1100 Subject: [PATCH 3214/3904] Fund --- src/cc/gamescc.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/cc/gamescc.h | 2 ++ src/cc/tetris.c | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 367c8d96e..a361b43ba 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1443,5 +1443,42 @@ UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; CPubKey gamespk,mypk; std::vector opret; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + { + amount = jdouble(jitem(params,1),0) * COIN + 0.0000000049; + gamespk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + if ( amount > GAMES_TXFEE ) + { + if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) + { + mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,amount,gamespk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,opret); + return(games_rawtxresult(result,rawtx,1)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough funds")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","amount too small")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parse")); + } + return(result); +} + #endif diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 6ec5dc9c4..a61b07564 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -33,6 +33,7 @@ std::string Games_pname; #define RPC_FUNCS \ { (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"fund", (char *)"amount", 1, 1, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"players", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"games", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"pending", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \ @@ -49,6 +50,7 @@ std::string Games_pname; bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 3047e0e55..fe042d28c 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -811,7 +811,7 @@ int tetris(int argc, char **argv) #endif // _WIN32 rs->seed = rs->origseed; strcpy(Gametxidstr,argv[2]); - fprintf(stderr,"setplayerdata\n"); + fprintf(stderr,"setplayerdata %s\n",Gametxidstr); if ( games_setplayerdata(rs,Gametxidstr) < 0 ) { fprintf(stderr,"invalid gametxid, or already started\n"); From 84023b1540678bd5bb3be354295ff6b2e58177b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:40:55 -1100 Subject: [PATCH 3215/3904] Script --- src/cc/gamescc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index a361b43ba..41e571c15 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1446,8 +1446,8 @@ UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; CPubKey gamespk,mypk; std::vector opret; - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; CPubKey gamespk,mypk; CScript opret; + if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { amount = jdouble(jitem(params,1),0) * COIN + 0.0000000049; gamespk = GetUnspendable(cp,0); From e954ca48c7df58953263d5affaf1bd805686a795 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:42:56 -1100 Subject: [PATCH 3216/3904] Enable fund --- src/cc/gamescc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index a61b07564..e3bd15ea7 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -95,6 +95,8 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_extract(txfee,cp,params)); \ else if ( strcmp(method,"finish") == 0 ) \ return(games_finish(txfee,cp,params)); \ + else if ( strcmp(method,"fund") == 0 ) \ + return(games_fund(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From 62731f9972a0a88c9b7702bbb7d4ca6bb833c6ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:44:39 -1100 Subject: [PATCH 3217/3904] params0 --- src/cc/gamescc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 41e571c15..9be6426ea 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1449,7 +1449,7 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; CPubKey gamespk,mypk; CScript opret; if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { - amount = jdouble(jitem(params,1),0) * COIN + 0.0000000049; + amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; gamespk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); if ( amount > GAMES_TXFEE ) From fc3753d23b96782459aab4663a8543f6713b6a66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:50:45 -1100 Subject: [PATCH 3218/3904] +print --- src/cc/gamescc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 9be6426ea..5ac8fc5c7 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1457,6 +1457,11 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) { mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,amount,gamespk)); + { + char destaddr[64]; + GetScriptaddress(destaddr,mtx.vout[0].scriptPubKey); + fprintf(stderr,"destaddr.(%s) %d\n",destaddr,cp->evalcode); + } rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,opret); return(games_rawtxresult(result,rawtx,1)); } From 00e6b83927e172ca8204778e800c4059d0bc9e8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:51:19 -1100 Subject: [PATCH 3219/3904] Fix --- src/cc/gamescc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 5ac8fc5c7..2f48a2c3c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1456,7 +1456,8 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) { - mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,amount,gamespk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); + if ( 0 ) { char destaddr[64]; GetScriptaddress(destaddr,mtx.vout[0].scriptPubKey); From f3c31104f7b62483bd1bfbe76e107a870128df34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 03:51:35 -1100 Subject: [PATCH 3220/3904] Test --- src/cc/gamescc.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2f48a2c3c..2f5c031c5 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1457,12 +1457,6 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); - if ( 0 ) - { - char destaddr[64]; - GetScriptaddress(destaddr,mtx.vout[0].scriptPubKey); - fprintf(stderr,"destaddr.(%s) %d\n",destaddr,cp->evalcode); - } rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,opret); return(games_rawtxresult(result,rawtx,1)); } From 4b5da75d7da26636917cc757d3f01932505e96f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 04:10:41 -1100 Subject: [PATCH 3221/3904] Fix gameloop --- src/cc/tetris.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index fe042d28c..d09116881 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -724,11 +724,11 @@ void *gamesiterate(struct games_state *rs) c = 'j'; break; } - if ( c < 0 || skipcount == 0x7f ) + if ( c >= 0 || skipcount == 0x7f ) { if ( skipcount > 0 ) issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x80); - if ( c != -1 ) + if ( c >= 0 ) issue_games_events(rs,Gametxidstr,eventid,c); skipcount = 0; } else skipcount++; From b4043bc6bb0c58cb6ee7d0cc33cdc1f2d5ac6bed Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 04:17:43 -1100 Subject: [PATCH 3222/3904] Scrub vals --- src/cc/dapps/dappstd.c | 15 +++++++++++++++ src/cc/tetris.c | 20 +++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 0f3d8cc24..267335b05 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -1040,6 +1040,21 @@ char games_readchar(struct games_state *rs) if ( rs == 0 || rs->guiflag != 0 ) { ch = (char) getch(); + switch ( ch ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } if (ch == 3) { //_quit(); diff --git a/src/cc/tetris.c b/src/cc/tetris.c index d09116881..5ddb10ca4 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -299,9 +299,11 @@ static void tg_handle_move(struct games_state *rs,tetris_game *obj, tetris_move { switch (move) { case TM_LEFT: + fprintf(stderr,"LEFT "); tg_move(obj, -1); break; case TM_RIGHT: + fprintf(stderr,"RIGHT "); tg_move(obj, 1); break; case TM_DROP: @@ -644,8 +646,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; if ( fp == 0 ) fp = fopen("events.log","wb"); - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c,gametxidstr,eventid); - rs->buffered[rs->num++] = c; + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) @@ -709,21 +710,6 @@ void *gamesiterate(struct games_state *rs) doupdate(); sleep_milli(10); c = games_readchar(rs); - switch ( c ) - { - case KEY_LEFT: - c = 'h'; - break; - case KEY_RIGHT: - c = 'l'; - break; - case KEY_UP: - c = 'k'; - break; - case KEY_DOWN: - c = 'j'; - break; - } if ( c >= 0 || skipcount == 0x7f ) { if ( skipcount > 0 ) From 510689b9541daa870f0b136502ef663af755ab31 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 04:18:59 -1100 Subject: [PATCH 3223/3904] Necroses --- src/cc/dapps/dappstd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 267335b05..80b651b45 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -22,6 +22,7 @@ #include #include #include +#include extern struct games_state globalR; void *gamesiterate(struct games_state *rs); From aeba5e4b071ce0a470bd007f084a417d1572a607 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 04:20:20 -1100 Subject: [PATCH 3224/3904] Fetch --- src/cc/dapps/dappstd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 80b651b45..a5ef379db 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -22,7 +22,6 @@ #include #include #include -#include extern struct games_state globalR; void *gamesiterate(struct games_state *rs); @@ -1012,7 +1011,7 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) char games_readchar(struct games_state *rs) { - char c,ch = -1; + char ch = -1; int32_t c; if ( rs != 0 && rs->guiflag == 0 ) { static uint32_t counter; @@ -1040,8 +1039,8 @@ char games_readchar(struct games_state *rs) } if ( rs == 0 || rs->guiflag != 0 ) { - ch = (char) getch(); - switch ( ch ) + c = getch(); + switch ( c ) { case KEY_LEFT: c = 'h'; @@ -1056,6 +1055,7 @@ char games_readchar(struct games_state *rs) c = 'j'; break; } + ch = c; if (ch == 3) { //_quit(); @@ -1065,7 +1065,7 @@ char games_readchar(struct games_state *rs) { if ( rs->num < sizeof(rs->buffered) ) { - rs->buffered[rs->num++] = ch; + rs->buffered[rs->num++] = c; if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) { rs->needflush = (uint32_t)time(NULL); @@ -1075,7 +1075,7 @@ char games_readchar(struct games_state *rs) } else fprintf(stderr,"buffer filled without flushed\n"); } } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); - return(ch); + return(c); } int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) From e96b3bf96ae29acd188baa7f336313c8e48c9d9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 04:34:08 -1100 Subject: [PATCH 3225/3904] Gamesevent --- src/cc/dapps/dappstd.c | 43 +++++++++++++++++++++++++----------------- src/cc/tetris.c | 18 +++++++++--------- src/cc/tetris.cpp | 6 +++--- src/cc/tetris.h | 8 +++++--- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index a5ef379db..05f4fe332 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -249,7 +249,7 @@ int32_t safecopy(char *dest,char *src,long len) //#endif int32_t games_replay(uint64_t seed,int32_t sleeptime); -char *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter); +gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter); int GAMEMAIN(int argc, char **argv); @@ -735,9 +735,9 @@ int32_t games_sendrawtransaction(char *rawtx) return(retval); } -int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) +int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,gamesevent *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj; uint8_t *pastcmp; + char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx; int32_t i,len,retflag = -1; cJSON *retjson,*resobj; if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { if ( rs->keystrokeshex != 0 ) @@ -757,9 +757,18 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,cha } free(rs->keystrokeshex), rs->keystrokeshex = 0; } + memset(hexstr,0,sizeof(hexstr)); for (i=0; iorigseed,rs->counter); if ( (fp= fopen(fname,"wb")) != 0 ) { - if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num ) + if ( fwrite(rs->buffered,sizeof(*rs->buffered),rs->num,fp) == rs->num ) { rs->num = 0; retflag = 0; @@ -864,7 +873,7 @@ void games_bailout(struct games_state *rs) #endif #endif -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) +int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) { struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; rs = (struct games_state *)calloc(1,sizeof(*rs)); @@ -930,9 +939,9 @@ long get_filesize(FILE *fp) return(fsize); } -char *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) +gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) { - char fname[1024],*keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; + char fname[1024]; gamesevent *keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; *numkeysp = 0; while ( 1 ) { @@ -946,7 +955,7 @@ char *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) //printf("fsize.%ld\n",fsize); break; } - if ( (keystrokes= (char *)realloc(keystrokes,num+fsize)) == 0 ) + if ( (keystrokes= (char *)realloc(keystrokes,sizeof(*keystrokes)*(num+fsize))) == 0 ) { fprintf(stderr,"error reallocating keystrokes\n"); fclose(fp); @@ -983,7 +992,7 @@ void games_exit() int32_t games_replay(uint64_t seed,int32_t sleeptime) { - FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct games_state *rs; struct games_player P,*player = 0; + FILE *fp; char fname[1024]; gamesevent *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct games_state *rs; struct games_player P,*player = 0; if ( seed == 0 ) seed = 777; keystrokes = games_keystrokesload(&num,seed,counter); @@ -1009,15 +1018,15 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) return(num); } -char games_readchar(struct games_state *rs) +gamesevent games_readevent(struct games_state *rs) { - char ch = -1; int32_t c; + gamesevent ch = -1; int32_t c; if ( rs != 0 && rs->guiflag == 0 ) { static uint32_t counter; if ( rs->ind < rs->numkeys ) { - c = rs->keystrokes[rs->ind++]; + ch = rs->keystrokes[rs->ind++]; if ( 0 ) { static FILE *fp; static int32_t counter; @@ -1030,7 +1039,7 @@ char games_readchar(struct games_state *rs) counter++; } } - return(c); + return(ch); } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); @@ -1065,7 +1074,7 @@ char games_readchar(struct games_state *rs) { if ( rs->num < sizeof(rs->buffered) ) { - rs->buffered[rs->num++] = c; + rs->buffered[rs->num++] = ch; if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) { rs->needflush = (uint32_t)time(NULL); @@ -1075,7 +1084,7 @@ char games_readchar(struct games_state *rs) } else fprintf(stderr,"buffer filled without flushed\n"); } } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); - return(c); + return(ch); } int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 5ddb10ca4..048a701f5 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -640,13 +640,13 @@ void init_colors(void) */ #include "dapps/dappstd.c" -int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,char c) +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,int16_t c) { static FILE *fp; char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; if ( fp == 0 ) fp = fopen("events.log","wb"); - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) @@ -689,7 +689,7 @@ struct games_state globalR; void *gamesiterate(struct games_state *rs) { uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; - int32_t c,skipcount=0; uint32_t eventid = 0; tetris_game *tg; + gamesevent c; uint16_t skipcount=0; uint32_t eventid = 0; tetris_game *tg; WINDOW *board, *next, *hold, *score; // Create windows for each section of the interface. tg = tg_create(rs,22, 10); @@ -709,11 +709,11 @@ void *gamesiterate(struct games_state *rs) if ( (counter++ % 5) == 0 ) doupdate(); sleep_milli(10); - c = games_readchar(rs); - if ( c >= 0 || skipcount == 0x7f ) + c = games_readevent(rs); + if ( c >= 0 || skipcount == 0x3fff ) { if ( skipcount > 0 ) - issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x80); + issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x4000); if ( c >= 0 ) issue_games_events(rs,Gametxidstr,eventid,c); skipcount = 0; @@ -723,10 +723,10 @@ void *gamesiterate(struct games_state *rs) { if ( skipcount == 0 ) { - c = games_readchar(rs); - if ( (c & 0x80) != 0 ) + c = games_readevent(rs); + if ( (c & 0x4000) == 0x4000 ) { - skipcount = (c & 0x7f); + skipcount = (c & 0x3fff); c = 'S'; } } diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index f9e4e167a..a20652012 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -42,9 +42,9 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay eventid |= (uint32_t)payload[len+33] << 8; eventid |= (uint32_t)payload[len+34] << 16; eventid |= (uint32_t)payload[len+35] << 24; - for (i=0; i Date: Tue, 26 Mar 2019 04:35:25 -1100 Subject: [PATCH 3226/3904] Gamesevent --- src/cc/dapps/dappstd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 05f4fe332..55ffb33be 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -767,7 +767,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,gam else if ( sizeof(gamesevent) == 4 ) sprintf(&hexstr[i<<3],"%08x",keystrokes[i]&0xffffffff); else if ( sizeof(gamesevent) == 8 ) - sprintf(&hexstr[i<<4],"%016x",keystrokes[i]&0xffffffffffffffff); + sprintf(&hexstr[i<<4],"%016x",(long long)(keystrokes[i]&0xffffffffffffffffLL)); } static FILE *fp; if ( fp == 0 ) @@ -955,7 +955,7 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter //printf("fsize.%ld\n",fsize); break; } - if ( (keystrokes= (char *)realloc(keystrokes,sizeof(*keystrokes)*(num+fsize))) == 0 ) + if ( (keystrokes= (gamesevent *)realloc(keystrokes,sizeof(*keystrokes)*(num+fsize))) == 0 ) { fprintf(stderr,"error reallocating keystrokes\n"); fclose(fp); From 297794b25367e2140aa5700edc8c0bd2ded736d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 04:36:01 -1100 Subject: [PATCH 3227/3904] Llx --- src/cc/dapps/dappstd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 55ffb33be..e120787bf 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -767,7 +767,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,gam else if ( sizeof(gamesevent) == 4 ) sprintf(&hexstr[i<<3],"%08x",keystrokes[i]&0xffffffff); else if ( sizeof(gamesevent) == 8 ) - sprintf(&hexstr[i<<4],"%016x",(long long)(keystrokes[i]&0xffffffffffffffffLL)); + sprintf(&hexstr[i<<4],"%016llx",(long long)(keystrokes[i]&0xffffffffffffffffLL)); } static FILE *fp; if ( fp == 0 ) From 4aed5b5b98c3a28924b7568d84cb803ee7c5a629 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 04:46:22 -1100 Subject: [PATCH 3228/3904] Uint check --- src/cc/tetris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 048a701f5..6541d61e5 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -710,7 +710,7 @@ void *gamesiterate(struct games_state *rs) doupdate(); sleep_milli(10); c = games_readevent(rs); - if ( c >= 0 || skipcount == 0x3fff ) + if ( c <= 0x7f || skipcount == 0x3fff ) { if ( skipcount > 0 ) issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x4000); From 0642013b11d5083ad953a88bfbecba447021fccc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:02:16 -1100 Subject: [PATCH 3229/3904] Skip -1 --- src/cc/dapps/dappstd.c | 4 ++-- src/cc/tetris.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index e120787bf..4bd116235 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -1070,7 +1070,7 @@ gamesevent games_readevent(struct games_state *rs) //_quit(); return(27); } - if ( rs != 0 && rs->guiflag != 0 ) + /*if ( rs != 0 && rs->guiflag != 0 ) { if ( rs->num < sizeof(rs->buffered) ) { @@ -1082,7 +1082,7 @@ gamesevent games_readevent(struct games_state *rs) //sleep(3); } } else fprintf(stderr,"buffer filled without flushed\n"); - } + }*/ } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); return(ch); } diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 6541d61e5..19aa0467b 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -640,13 +640,21 @@ void init_colors(void) */ #include "dapps/dappstd.c" -int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,int16_t c) +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) { static FILE *fp; char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; if ( fp == 0 ) fp = fopen("events.log","wb"); - sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + rs->buffered[rs->num++] = c; + if ( sizeof(c) == 1 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + else if ( sizeof(c) == 2 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + else if ( sizeof(c) == 4 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + else if ( sizeof(c) == 8 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) From bb97066b46ce6958b59a5df84eeced24070ded82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:15:09 -1100 Subject: [PATCH 3230/3904] replay2 --- src/cc/dapps/dappstd.c | 57 ------------------------------------------ src/cc/gamescc.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++ src/cc/tetris.cpp | 6 ++--- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 4bd116235..bac8cd50c 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -873,63 +873,6 @@ void games_bailout(struct games_state *rs) #endif #endif -int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) -{ - struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; - rs = (struct games_state *)calloc(1,sizeof(*rs)); - rs->seed = rs->origseed = seed; - rs->keystrokes = keystrokes; - rs->numkeys = num; - rs->sleeptime = sleepmillis * 1000; - if ( player != 0 ) - { - rs->P = *player; - rs->restoring = 1; - //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); - if ( rs->P.packsize > MAXPACK ) - rs->P.packsize = MAXPACK; - } - globalR = *rs; - uint32_t starttime = (uint32_t)time(NULL); - ptr = gamesiterate(rs); - if ( 0 ) - { - fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); - sleep(2); - starttime = (uint32_t)time(NULL); - for (i=0; i<10000; i++) - { - memset(rs,0,sizeof(*rs)); - rs->seed = rs->origseed = seed; - rs->keystrokes = keystrokes; - rs->numkeys = num; - rs->sleeptime = 0; - gamesiterate(rs); - } - fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); - sleep(3); - } - // extract playerdata - - /*if ( (fp= fopen("checkfile","wb")) != 0 ) - { - //save_file(rs,fp,0); - //fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); - if ( newdata != 0 && rs->playersize > 0 ) - memcpy(newdata,rs->playerdata,rs->playersize); - }*/ - if ( ptr != 0 ) - { - // extract data from ptr - if ( newdata != 0 && rs->playersize > 0 ) - memcpy(newdata,rs->playerdata,rs->playersize); - free(ptr); - } - n = rs->playersize; - free(rs); - return(n); -} - long get_filesize(FILE *fp) { long fsize,fpos = ftell(fp); diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2f5c031c5..31b33e2b5 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -31,6 +31,63 @@ uint64_t _games_rngnext(uint64_t initseed) return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } +int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) +{ + struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; + rs = (struct games_state *)calloc(1,sizeof(*rs)); + rs->seed = rs->origseed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = sleepmillis * 1000; + if ( player != 0 ) + { + rs->P = *player; + rs->restoring = 1; + //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); + if ( rs->P.packsize > MAXPACK ) + rs->P.packsize = MAXPACK; + } + globalR = *rs; + uint32_t starttime = (uint32_t)time(NULL); + ptr = gamesiterate(rs); + if ( 0 ) + { + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); + sleep(2); + starttime = (uint32_t)time(NULL); + for (i=0; i<10000; i++) + { + memset(rs,0,sizeof(*rs)); + rs->seed = rs->origseed = seed; + rs->keystrokes = keystrokes; + rs->numkeys = num; + rs->sleeptime = 0; + gamesiterate(rs); + } + fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime); + sleep(3); + } + // extract playerdata + + /*if ( (fp= fopen("checkfile","wb")) != 0 ) + { + //save_file(rs,fp,0); + //fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); + if ( newdata != 0 && rs->playersize > 0 ) + memcpy(newdata,rs->playerdata,rs->playersize); + }*/ + if ( ptr != 0 ) + { + // extract data from ptr + if ( newdata != 0 && rs->playersize > 0 ) + memcpy(newdata,rs->playerdata,rs->playersize); + free(ptr); + } + n = rs->playersize; + free(rs); + return(n); +} + #ifndef STANDALONE #include "tetris.cpp" // replace with game specific functions diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index a20652012..6a1269099 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -20,15 +20,15 @@ uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 // game specific code for daemon -void games_packitemstr(char *packitemstr,struct games_packitem *item) +/*void games_packitemstr(char *packitemstr,struct games_packitem *item) { sprintf(packitemstr,"not yet"); } int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) // replay in daemon { - return(-1); -} + return(0); +}*/ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) { From 2ed6eccec62b8c459c88f0d3f3bedbf25dcfb9b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:16:46 -1100 Subject: [PATCH 3231/3904] Test --- src/cc/gamescc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 31b33e2b5..d5ec503c9 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -14,8 +14,6 @@ ******************************************************************************/ #include "gamescc.h" -#include "tetris.c" // replace with game code - uint64_t _games_rngnext(uint64_t initseed) { @@ -88,6 +86,9 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 return(n); } +#include "tetris.c" // replace with game code + + #ifndef STANDALONE #include "tetris.cpp" // replace with game specific functions From d61a4c44cf1f00a739dd5da7e74c4ee5ff571d86 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:17:56 -1100 Subject: [PATCH 3232/3904] Test --- src/cc/gamescc.cpp | 4 +--- src/cc/tetris.h | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index d5ec503c9..80f89332f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -14,6 +14,7 @@ ******************************************************************************/ #include "gamescc.h" +#include "tetris.c" // replace with game code uint64_t _games_rngnext(uint64_t initseed) { @@ -86,9 +87,6 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 return(n); } -#include "tetris.c" // replace with game code - - #ifndef STANDALONE #include "tetris.cpp" // replace with game specific functions diff --git a/src/cc/tetris.h b/src/cc/tetris.h index 3c246a3bd..b2f2fbe04 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -193,8 +193,10 @@ struct games_state gamesevent buffered[5000],*keystrokes; uint8_t playerdata[1024]; }; +extern struct games_state globalR; uint64_t _games_rngnext(uint64_t initseed); +int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); #endif From 32851ac12aa85f2a599ac6b13791f75304051720 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:24:33 -1100 Subject: [PATCH 3233/3904] Baton support for games event --- src/cc/gamescc.cpp | 17 +++++++++++------ src/cc/tetris.h | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 80f89332f..227b3c5ae 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -848,9 +848,9 @@ int64_t games_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTrans return(0); } -int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) +int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gamesevent **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname) { - int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; + int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64]; gamesevent *keystrokes=0; batonvalue = numkeys = numplayers = batonht = 0; playertxid = batontxid = zeroid; if ( keystrokesp != 0 ) @@ -913,10 +913,15 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke uint256 g,b; CPubKey p; std::vector k; if ( games_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) { - keystrokes = (char *)realloc(keystrokes,numkeys + (int32_t)k.size()); + keystrokes = (char *)realloc(keystrokes,sizeof(*keystrokes)*(numkeys + (int32_t)k.size())); for (i=0; i 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); char *method = (char *)"bailout"; - UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64]; gamesevent *keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) diff --git a/src/cc/tetris.h b/src/cc/tetris.h index b2f2fbe04..94d56dbfc 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -194,7 +194,9 @@ struct games_state uint8_t playerdata[1024]; }; extern struct games_state globalR; +void *gamesiterate(struct games_state *rs); +void games_packitemstr(char *packitemstr,struct games_packitem *item); uint64_t _games_rngnext(uint64_t initseed); int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); From 985e8a71273f48f85a7f9246b11ef74f0c1263d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:26:45 -1100 Subject: [PATCH 3234/3904] Test --- src/cc/gamescc.cpp | 1 + src/cc/tetris.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 227b3c5ae..7dc368d72 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -916,6 +916,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven keystrokes = (char *)realloc(keystrokes,sizeof(*keystrokes)*(numkeys + (int32_t)k.size())); for (i=0; i playerdata) } } -char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) +gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) { - CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; + CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64]; gamesevent *keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; gamespk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; @@ -110,7 +110,7 @@ char *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto sprintf(fname,"%s.%llu.0",GAMENAME,(long long)seed); if ( (fp= fopen(fname,"wb")) != 0 ) { - if ( fwrite(keystrokes,1,numkeys,fp) != numkeys ) + if ( fwrite(keystrokes,sizeof(*keystrokes),numkeys,fp) != numkeys ) fprintf(stderr,"error writing %s\n",fname); fclose(fp); } From ce1a3197b2d933c7104dcfbf1abe7e617f82ebdf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:28:25 -1100 Subject: [PATCH 3235/3904] Test --- src/cc/tetris.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 2ef048364..216d4c4d0 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -14,7 +14,7 @@ * * ******************************************************************************/ -int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname); +int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gamesevent **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname); int32_t games_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0); uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr); @@ -169,7 +169,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; static uint256 prevgame; - char str[512],*keystrokes,gamesaddr[64],str2[67],fname[64]; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; + char str[512],gamesaddr[64],str2[67],fname[64]; gamesevent *keystrokes; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; *cashoutp = 0; gamespk = GetUnspendable(cp,0); GetCCaddress1of2(cp,gamesaddr,gamespk,pk); From 6ce5d7f762bf9cc2115151b281695c42eb7ce9d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:31:50 -1100 Subject: [PATCH 3236/3904] Hexer --- src/cc/gamescc.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 7dc368d72..0f261a184 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -913,7 +913,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven uint256 g,b; CPubKey p; std::vector k; if ( games_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) { - keystrokes = (char *)realloc(keystrokes,sizeof(*keystrokes)*(numkeys + (int32_t)k.size())); + keystrokes = (gamesevent *)realloc(keystrokes,sizeof(*keystrokes)*(numkeys + (int32_t)k.size())); for (i=0; i newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; + UniValue result(UniValue::VOBJ); CPubKey pk,gamespk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],gamesaddr[64],*pubstr,*hexstr; gamesevent *keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); result.push_back(Pair("name","games")); @@ -1263,10 +1263,25 @@ UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("status","success")); flag = 1; - hexstr = (char *)malloc(numkeys*2 + 1); + hexstr = (char *)calloc(1,sizeof(gamesevent)*numkeys*2 + 1); for (i=0; i Date: Tue, 26 Mar 2019 05:33:56 -1100 Subject: [PATCH 3237/3904] Link errors --- src/cc/tetris.c | 116 +++++++++++++++++++++++----------------------- src/cc/tetris.cpp | 4 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 19aa0467b..803d163fa 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -634,64 +634,6 @@ void init_colors(void) init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); } -#ifdef STANDALONE -/* - Main tetris game! - */ -#include "dapps/dappstd.c" - -int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) -{ - static FILE *fp; - char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; - if ( fp == 0 ) - fp = fopen("events.log","wb"); - rs->buffered[rs->num++] = c; - if ( sizeof(c) == 1 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); - else if ( sizeof(c) == 2 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); - else if ( sizeof(c) == 4 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); - else if ( sizeof(c) == 8 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) - { - retval = 0; - if ( fp != 0 ) - { - fprintf(fp,"%s\n",jprint(resobj,0)); - fflush(fp); - } - } - free_json(retjson); - } else fprintf(fp,"error parsing %s\n",retstr); - free(retstr); - } else fprintf(fp,"error issuing method %s\n",params); - return(retval); -} - -char *clonestr(char *str) -{ - char *clone; int32_t len; - if ( str == 0 || str[0] == 0 ) - { - printf("warning cloning nullstr.%p\n",str); -#ifdef __APPLE__ - while ( 1 ) sleep(1); -#endif - str = (char *)""; - } - len = strlen(str); - clone = (char *)calloc(1,len+16); - strcpy(clone,str); - return(clone); -} - struct games_state globalR; void *gamesiterate(struct games_state *rs) @@ -785,6 +727,64 @@ void *gamesiterate(struct games_state *rs) return(tg); } +#ifdef STANDALONE +/* + Main tetris game! + */ +#include "dapps/dappstd.c" + +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) +{ + static FILE *fp; + char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; + if ( fp == 0 ) + fp = fopen("events.log","wb"); + rs->buffered[rs->num++] = c; + if ( sizeof(c) == 1 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + else if ( sizeof(c) == 2 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + else if ( sizeof(c) == 4 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + else if ( sizeof(c) == 8 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + retval = 0; + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } + } + free_json(retjson); + } else fprintf(fp,"error parsing %s\n",retstr); + free(retstr); + } else fprintf(fp,"error issuing method %s\n",params); + return(retval); +} + +char *clonestr(char *str) +{ + char *clone; int32_t len; + if ( str == 0 || str[0] == 0 ) + { + printf("warning cloning nullstr.%p\n",str); +#ifdef __APPLE__ + while ( 1 ) sleep(1); +#endif + str = (char *)""; + } + len = strlen(str); + clone = (char *)calloc(1,len+16); + strcpy(clone,str); + return(clone); +} + int tetris(int argc, char **argv) { struct games_state *rs = &globalR; diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 216d4c4d0..c2caaa8a9 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -19,12 +19,12 @@ int32_t games_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr); // game specific code for daemon - -/*void games_packitemstr(char *packitemstr,struct games_packitem *item) +void games_packitemstr(char *packitemstr,struct games_packitem *item) { sprintf(packitemstr,"not yet"); } +/* int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) // replay in daemon { return(0); From a10f3988eeb975f9d7319e22e0fe812478bf89ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:35:58 -1100 Subject: [PATCH 3238/3904] Test --- src/cc/tetris.c | 71 ++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 803d163fa..f6a4974c4 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -635,6 +635,43 @@ void init_colors(void) } struct games_state globalR; +gamesevent games_readevent(struct games_state *rs); +extern char Gametxidstr[]; + +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) +{ + static FILE *fp; + char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; + if ( fp == 0 ) + fp = fopen("events.log","wb"); + rs->buffered[rs->num++] = c; + if ( sizeof(c) == 1 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + else if ( sizeof(c) == 2 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + else if ( sizeof(c) == 4 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + else if ( sizeof(c) == 8 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + retval = 0; + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } + } + free_json(retjson); + } else fprintf(fp,"error parsing %s\n",retstr); + free(retstr); + } else fprintf(fp,"error issuing method %s\n",params); + return(retval); +} void *gamesiterate(struct games_state *rs) { @@ -733,40 +770,6 @@ void *gamesiterate(struct games_state *rs) */ #include "dapps/dappstd.c" -int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) -{ - static FILE *fp; - char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; - if ( fp == 0 ) - fp = fopen("events.log","wb"); - rs->buffered[rs->num++] = c; - if ( sizeof(c) == 1 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); - else if ( sizeof(c) == 2 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); - else if ( sizeof(c) == 4 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); - else if ( sizeof(c) == 8 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) - { - retval = 0; - if ( fp != 0 ) - { - fprintf(fp,"%s\n",jprint(resobj,0)); - fflush(fp); - } - } - free_json(retjson); - } else fprintf(fp,"error parsing %s\n",retstr); - free(retstr); - } else fprintf(fp,"error issuing method %s\n",params); - return(retval); -} char *clonestr(char *str) { From 38bf6a68951aaf878ad881eae0812c704a5cfd3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:38:17 -1100 Subject: [PATCH 3239/3904] Fix --- src/cc/tetris.c | 74 +++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index f6a4974c4..3b330f5ca 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -635,43 +635,8 @@ void init_colors(void) } struct games_state globalR; -gamesevent games_readevent(struct games_state *rs); extern char Gametxidstr[]; - -int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) -{ - static FILE *fp; - char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; - if ( fp == 0 ) - fp = fopen("events.log","wb"); - rs->buffered[rs->num++] = c; - if ( sizeof(c) == 1 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); - else if ( sizeof(c) == 2 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); - else if ( sizeof(c) == 4 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); - else if ( sizeof(c) == 8 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) - { - retval = 0; - if ( fp != 0 ) - { - fprintf(fp,"%s\n",jprint(resobj,0)); - fflush(fp); - } - } - free_json(retjson); - } else fprintf(fp,"error parsing %s\n",retstr); - free(retstr); - } else fprintf(fp,"error issuing method %s\n",params); - return(retval); -} +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c); void *gamesiterate(struct games_state *rs) { @@ -689,6 +654,7 @@ void *gamesiterate(struct games_state *rs) running = tg_tick(rs,tg,move); if ( rs->guiflag != 0 ) { +#ifdef STANDALONE display_board(board,tg); display_piece(next,tg->next); display_piece(hold,tg->stored); @@ -705,6 +671,7 @@ void *gamesiterate(struct games_state *rs) issue_games_events(rs,Gametxidstr,eventid,c); skipcount = 0; } else skipcount++; +#endif } else { @@ -788,6 +755,41 @@ char *clonestr(char *str) return(clone); } +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) +{ + static FILE *fp; + char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; + if ( fp == 0 ) + fp = fopen("events.log","wb"); + rs->buffered[rs->num++] = c; + if ( sizeof(c) == 1 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + else if ( sizeof(c) == 2 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + else if ( sizeof(c) == 4 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + else if ( sizeof(c) == 8 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + retval = 0; + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } + } + free_json(retjson); + } else fprintf(fp,"error parsing %s\n",retstr); + free(retstr); + } else fprintf(fp,"error issuing method %s\n",params); + return(retval); +} + int tetris(int argc, char **argv) { struct games_state *rs = &globalR; From 82c132b6fbc6ea6f97f737626e7ea226ac362c24 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:38:58 -1100 Subject: [PATCH 3240/3904] gamesevent games_readevent(struct games_state *rs) --- src/cc/tetris.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 3b330f5ca..487566ed4 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -637,6 +637,7 @@ void init_colors(void) struct games_state globalR; extern char Gametxidstr[]; int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c); +gamesevent games_readevent(struct games_state *rs); void *gamesiterate(struct games_state *rs) { From 8ba50f49c8d7981d7530a8d725305f6f8636c28c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:41:31 -1100 Subject: [PATCH 3241/3904] Test --- src/cc/dapps/dappstd.c | 69 ------------------------------------------ src/cc/gamescc.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index bac8cd50c..3992cb80e 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -961,75 +961,6 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) return(num); } -gamesevent games_readevent(struct games_state *rs) -{ - gamesevent ch = -1; int32_t c; - if ( rs != 0 && rs->guiflag == 0 ) - { - static uint32_t counter; - if ( rs->ind < rs->numkeys ) - { - ch = rs->keystrokes[rs->ind++]; - if ( 0 ) - { - static FILE *fp; static int32_t counter; - if ( fp == 0 ) - fp = fopen("log","wb"); - if ( fp != 0 ) - { - fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); - fflush(fp); - counter++; - } - } - return(ch); - } - if ( rs->replaydone != 0 && counter++ < 3 ) - fprintf(stderr,"replay finished but readchar called\n"); - rs->replaydone = (uint32_t)time(NULL); - return(0); - } - if ( rs == 0 || rs->guiflag != 0 ) - { - c = getch(); - switch ( c ) - { - case KEY_LEFT: - c = 'h'; - break; - case KEY_RIGHT: - c = 'l'; - break; - case KEY_UP: - c = 'k'; - break; - case KEY_DOWN: - c = 'j'; - break; - } - ch = c; - if (ch == 3) - { - //_quit(); - return(27); - } - /*if ( rs != 0 && rs->guiflag != 0 ) - { - if ( rs->num < sizeof(rs->buffered) ) - { - rs->buffered[rs->num++] = ch; - if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) - { - rs->needflush = (uint32_t)time(NULL); - //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); - //sleep(3); - } - } else fprintf(stderr,"buffer filled without flushed\n"); - }*/ - } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); - return(ch); -} - int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) { char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson; diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 0f261a184..b99c052ac 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -30,6 +30,75 @@ uint64_t _games_rngnext(uint64_t initseed) return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } +gamesevent games_readevent(struct games_state *rs) +{ + gamesevent ch = -1; int32_t c; + if ( rs != 0 && rs->guiflag == 0 ) + { + static uint32_t counter; + if ( rs->ind < rs->numkeys ) + { + ch = rs->keystrokes[rs->ind++]; + if ( 0 ) + { + static FILE *fp; static int32_t counter; + if ( fp == 0 ) + fp = fopen("log","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); + fflush(fp); + counter++; + } + } + return(ch); + } + if ( rs->replaydone != 0 && counter++ < 3 ) + fprintf(stderr,"replay finished but readchar called\n"); + rs->replaydone = (uint32_t)time(NULL); + return(0); + } + if ( rs == 0 || rs->guiflag != 0 ) + { + c = getch(); + switch ( c ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } + ch = c; + if (ch == 3) + { + //_quit(); + return(27); + } + /*if ( rs != 0 && rs->guiflag != 0 ) + { + if ( rs->num < sizeof(rs->buffered) ) + { + rs->buffered[rs->num++] = ch; + if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) + { + rs->needflush = (uint32_t)time(NULL); + //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); + //sleep(3); + } + } else fprintf(stderr,"buffer filled without flushed\n"); + }*/ + } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); + return(ch); +} + int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) { struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; From e34fc6b5108521078b0c4d934044aafa91937129 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:43:30 -1100 Subject: [PATCH 3242/3904] Linker fix --- src/cc/gamescc.cpp | 138 ++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b99c052ac..2746e8097 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -30,75 +30,6 @@ uint64_t _games_rngnext(uint64_t initseed) return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } -gamesevent games_readevent(struct games_state *rs) -{ - gamesevent ch = -1; int32_t c; - if ( rs != 0 && rs->guiflag == 0 ) - { - static uint32_t counter; - if ( rs->ind < rs->numkeys ) - { - ch = rs->keystrokes[rs->ind++]; - if ( 0 ) - { - static FILE *fp; static int32_t counter; - if ( fp == 0 ) - fp = fopen("log","wb"); - if ( fp != 0 ) - { - fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); - fflush(fp); - counter++; - } - } - return(ch); - } - if ( rs->replaydone != 0 && counter++ < 3 ) - fprintf(stderr,"replay finished but readchar called\n"); - rs->replaydone = (uint32_t)time(NULL); - return(0); - } - if ( rs == 0 || rs->guiflag != 0 ) - { - c = getch(); - switch ( c ) - { - case KEY_LEFT: - c = 'h'; - break; - case KEY_RIGHT: - c = 'l'; - break; - case KEY_UP: - c = 'k'; - break; - case KEY_DOWN: - c = 'j'; - break; - } - ch = c; - if (ch == 3) - { - //_quit(); - return(27); - } - /*if ( rs != 0 && rs->guiflag != 0 ) - { - if ( rs->num < sizeof(rs->buffered) ) - { - rs->buffered[rs->num++] = ch; - if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) - { - rs->needflush = (uint32_t)time(NULL); - //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); - //sleep(3); - } - } else fprintf(stderr,"buffer filled without flushed\n"); - }*/ - } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); - return(ch); -} - int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) { struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; @@ -1628,3 +1559,72 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) #endif +gamesevent games_readevent(struct games_state *rs) +{ + gamesevent ch = -1; int32_t c; + if ( rs != 0 && rs->guiflag == 0 ) + { + static uint32_t counter; + if ( rs->ind < rs->numkeys ) + { + ch = rs->keystrokes[rs->ind++]; + if ( 0 ) + { + static FILE *fp; static int32_t counter; + if ( fp == 0 ) + fp = fopen("log","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); + fflush(fp); + counter++; + } + } + return(ch); + } + if ( rs->replaydone != 0 && counter++ < 3 ) + fprintf(stderr,"replay finished but readchar called\n"); + rs->replaydone = (uint32_t)time(NULL); + return(0); + } + if ( rs == 0 || rs->guiflag != 0 ) + { + c = getch(); + switch ( c ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } + ch = c; + if (ch == 3) + { + //_quit(); + return(27); + } + /*if ( rs != 0 && rs->guiflag != 0 ) + { + if ( rs->num < sizeof(rs->buffered) ) + { + rs->buffered[rs->num++] = ch; + if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) + { + rs->needflush = (uint32_t)time(NULL); + //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); + //sleep(3); + } + } else fprintf(stderr,"buffer filled without flushed\n"); + }*/ + } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); + return(ch); +} + From e495123a5d5611b32d5cf7ed594e7a05f3ca9e81 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:44:39 -1100 Subject: [PATCH 3243/3904] link --- src/cc/gamescc.cpp | 68 --------------------------------------------- src/cc/tetris.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 68 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2746e8097..ad578400d 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1559,72 +1559,4 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) #endif -gamesevent games_readevent(struct games_state *rs) -{ - gamesevent ch = -1; int32_t c; - if ( rs != 0 && rs->guiflag == 0 ) - { - static uint32_t counter; - if ( rs->ind < rs->numkeys ) - { - ch = rs->keystrokes[rs->ind++]; - if ( 0 ) - { - static FILE *fp; static int32_t counter; - if ( fp == 0 ) - fp = fopen("log","wb"); - if ( fp != 0 ) - { - fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); - fflush(fp); - counter++; - } - } - return(ch); - } - if ( rs->replaydone != 0 && counter++ < 3 ) - fprintf(stderr,"replay finished but readchar called\n"); - rs->replaydone = (uint32_t)time(NULL); - return(0); - } - if ( rs == 0 || rs->guiflag != 0 ) - { - c = getch(); - switch ( c ) - { - case KEY_LEFT: - c = 'h'; - break; - case KEY_RIGHT: - c = 'l'; - break; - case KEY_UP: - c = 'k'; - break; - case KEY_DOWN: - c = 'j'; - break; - } - ch = c; - if (ch == 3) - { - //_quit(); - return(27); - } - /*if ( rs != 0 && rs->guiflag != 0 ) - { - if ( rs->num < sizeof(rs->buffered) ) - { - rs->buffered[rs->num++] = ch; - if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) - { - rs->needflush = (uint32_t)time(NULL); - //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); - //sleep(3); - } - } else fprintf(stderr,"buffer filled without flushed\n"); - }*/ - } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); - return(ch); -} diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 487566ed4..9808622f4 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -732,6 +732,75 @@ void *gamesiterate(struct games_state *rs) return(tg); } +gamesevent games_readevent(struct games_state *rs) +{ + gamesevent ch = -1; int32_t c; + if ( rs != 0 && rs->guiflag == 0 ) + { + static uint32_t counter; + if ( rs->ind < rs->numkeys ) + { + ch = rs->keystrokes[rs->ind++]; + if ( 0 ) + { + static FILE *fp; static int32_t counter; + if ( fp == 0 ) + fp = fopen("log","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); + fflush(fp); + counter++; + } + } + return(ch); + } + if ( rs->replaydone != 0 && counter++ < 3 ) + fprintf(stderr,"replay finished but readchar called\n"); + rs->replaydone = (uint32_t)time(NULL); + return(0); + } + if ( rs == 0 || rs->guiflag != 0 ) + { + c = getch(); + switch ( c ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } + ch = c; + if (ch == 3) + { + //_quit(); + return(27); + } + /*if ( rs != 0 && rs->guiflag != 0 ) + { + if ( rs->num < sizeof(rs->buffered) ) + { + rs->buffered[rs->num++] = ch; + if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) + { + rs->needflush = (uint32_t)time(NULL); + //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); + //sleep(3); + } + } else fprintf(stderr,"buffer filled without flushed\n"); + }*/ + } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); + return(ch); +} + #ifdef STANDALONE /* Main tetris game! From fd1ff16d471d38297bec4f0f23f217b20768a0f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:46:18 -1100 Subject: [PATCH 3244/3904] Test --- src/cc/rogue/cursesd.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index e3eec5d41..0b68bc307 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -16,6 +16,13 @@ #ifndef H_CURSESD_H #define H_CURSESD_H +#define KEY_OFFSET 0x100 +#define KEY_DOWN (KEY_OFFSET + 0x02) /* Down arrow key */ +#define KEY_UP (KEY_OFFSET + 0x03) /* Up arrow key */ +#define KEY_LEFT (KEY_OFFSET + 0x04) /* Left arrow key */ +#define KEY_RIGHT (KEY_OFFSET + 0x05) /* Right arrow key */ + + #define COLOR_BLACK 0 #ifdef PDC_RGB /* RGB */ From db01efa0221cd74add1802356ba7bdf514828d12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:47:13 -1100 Subject: [PATCH 3245/3904] Readevent --- src/cc/gamescc.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++ src/cc/tetris.c | 69 ---------------------------------------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ad578400d..255866c86 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -30,6 +30,75 @@ uint64_t _games_rngnext(uint64_t initseed) return(((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0]); } +gamesevent games_readevent(struct games_state *rs) +{ + gamesevent ch = -1; int32_t c; + if ( rs != 0 && rs->guiflag == 0 ) + { + static uint32_t counter; + if ( rs->ind < rs->numkeys ) + { + ch = rs->keystrokes[rs->ind++]; + if ( 0 ) + { + static FILE *fp; static int32_t counter; + if ( fp == 0 ) + fp = fopen("log","wb"); + if ( fp != 0 ) + { + fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); + fflush(fp); + counter++; + } + } + return(ch); + } + if ( rs->replaydone != 0 && counter++ < 3 ) + fprintf(stderr,"replay finished but readchar called\n"); + rs->replaydone = (uint32_t)time(NULL); + return(0); + } + if ( rs == 0 || rs->guiflag != 0 ) + { + c = getch(); + switch ( c ) + { + case KEY_LEFT: + c = 'h'; + break; + case KEY_RIGHT: + c = 'l'; + break; + case KEY_UP: + c = 'k'; + break; + case KEY_DOWN: + c = 'j'; + break; + } + ch = c; + if (ch == 3) + { + //_quit(); + return(27); + } + /*if ( rs != 0 && rs->guiflag != 0 ) + { + if ( rs->num < sizeof(rs->buffered) ) + { + rs->buffered[rs->num++] = ch; + if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) + { + rs->needflush = (uint32_t)time(NULL); + //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); + //sleep(3); + } + } else fprintf(stderr,"buffer filled without flushed\n"); + }*/ + } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); + return(ch); +} + int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) { struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 9808622f4..487566ed4 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -732,75 +732,6 @@ void *gamesiterate(struct games_state *rs) return(tg); } -gamesevent games_readevent(struct games_state *rs) -{ - gamesevent ch = -1; int32_t c; - if ( rs != 0 && rs->guiflag == 0 ) - { - static uint32_t counter; - if ( rs->ind < rs->numkeys ) - { - ch = rs->keystrokes[rs->ind++]; - if ( 0 ) - { - static FILE *fp; static int32_t counter; - if ( fp == 0 ) - fp = fopen("log","wb"); - if ( fp != 0 ) - { - fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed); - fflush(fp); - counter++; - } - } - return(ch); - } - if ( rs->replaydone != 0 && counter++ < 3 ) - fprintf(stderr,"replay finished but readchar called\n"); - rs->replaydone = (uint32_t)time(NULL); - return(0); - } - if ( rs == 0 || rs->guiflag != 0 ) - { - c = getch(); - switch ( c ) - { - case KEY_LEFT: - c = 'h'; - break; - case KEY_RIGHT: - c = 'l'; - break; - case KEY_UP: - c = 'k'; - break; - case KEY_DOWN: - c = 'j'; - break; - } - ch = c; - if (ch == 3) - { - //_quit(); - return(27); - } - /*if ( rs != 0 && rs->guiflag != 0 ) - { - if ( rs->num < sizeof(rs->buffered) ) - { - rs->buffered[rs->num++] = ch; - if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) - { - rs->needflush = (uint32_t)time(NULL); - //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); - //sleep(3); - } - } else fprintf(stderr,"buffer filled without flushed\n"); - }*/ - } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); - return(ch); -} - #ifdef STANDALONE /* Main tetris game! From 2fda05a5310a37b222e4f0c7731ddebbf5e511ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 05:57:58 -1100 Subject: [PATCH 3246/3904] Disable return0 --- src/cc/gamescc.cpp | 1 + src/cc/tetris.cpp | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 255866c86..442632c4e 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -102,6 +102,7 @@ gamesevent games_readevent(struct games_state *rs) int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) { struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; +return(0); rs = (struct games_state *)calloc(1,sizeof(*rs)); rs->seed = rs->origseed = seed; rs->keystrokes = keystrokes; diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index c2caaa8a9..1e0cb95d1 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -24,12 +24,6 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) sprintf(packitemstr,"not yet"); } -/* -int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) // replay in daemon -{ - return(0); -}*/ - int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) { uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; From 21b50727bfe56f6e4ac43625046ccd6d965746f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:01:08 -1100 Subject: [PATCH 3247/3904] +print --- src/cc/gamescc.cpp | 18 +++++++++--------- src/cc/tetris.cpp | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 442632c4e..650c051b9 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -927,7 +927,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven *keystrokesp = 0; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -946,17 +946,17 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven if ( matches == 1 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); +fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( games_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || games_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1,0) < 0 ) { @@ -973,7 +973,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven } } txid = spenttxid; - //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); @@ -994,17 +994,17 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven } numkeys += (int32_t)k.size() / sizeof(gamesevent); (*keystrokesp) = keystrokes; - //fprintf(stderr,"updated keystrokes.%p[%d]\n",keystrokes,numkeys); + fprintf(stderr,"updated keystrokes.%p[%d]\n",keystrokes,numkeys); } } - //fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); + fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); if ( ++n >= GAMES_MAXITERATIONS ) { fprintf(stderr,"games_findbaton n.%d, seems something is wrong\n",n); return(-5); } } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -1017,7 +1017,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 1e0cb95d1..a91157dde 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -90,7 +90,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: { UniValue obj; seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); - //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -116,7 +116,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: fclose(fp); } } - //fprintf(stderr,"call replay2\n"); + fprintf(stderr,"call replay2\n"); num = games_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i no playerdata\n"); From 1c12ebcf34fe1d1046481122e944dd4e1ca2379f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:05:22 -1100 Subject: [PATCH 3248/3904] +print --- src/cc/gamescc.cpp | 19 ++++++++++--------- src/cc/tetris.cpp | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 650c051b9..8fa629b7f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -927,7 +927,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven *keystrokesp = 0; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -946,17 +946,17 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); if ( matches == 1 ) { numvouts = matchtx.vout.size(); -fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); +//fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( games_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || games_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1,0) < 0 ) { @@ -973,9 +973,10 @@ fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex( } } txid = spenttxid; - fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { + fprintf(stderr,"gameisover n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); return(0); } if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) @@ -994,17 +995,17 @@ fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex( } numkeys += (int32_t)k.size() / sizeof(gamesevent); (*keystrokesp) = keystrokes; - fprintf(stderr,"updated keystrokes.%p[%d]\n",keystrokes,numkeys); + //fprintf(stderr,"updated keystrokes.%p[%d]\n",keystrokes,numkeys); } } - fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); + //fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str()); if ( ++n >= GAMES_MAXITERATIONS ) { fprintf(stderr,"games_findbaton n.%d, seems something is wrong\n",n); return(-5); } } - fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -1017,7 +1018,7 @@ fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex( return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index a91157dde..1a55de005 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -89,6 +89,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: if ( (retval= games_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gamesaddr,numplayers,symbol,pname)) == 0 ) { UniValue obj; + fprintf(stderr,"got baton\n"); seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); From 33ba39090d1f82f9d11ffd2a999f6eded3732860 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:07:43 -1100 Subject: [PATCH 3249/3904] Test --- src/cc/gamescc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 8fa629b7f..503eb17e3 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -984,18 +984,19 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven uint256 g,b; CPubKey p; std::vector k; if ( games_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) { - keystrokes = (gamesevent *)realloc(keystrokes,sizeof(*keystrokes)*(numkeys + (int32_t)k.size())); - for (i=0; i Date: Tue, 26 Mar 2019 06:14:00 -1100 Subject: [PATCH 3250/3904] Test --- src/cc/gamescc.cpp | 8 ++++---- src/cc/tetris.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 503eb17e3..1684e6a18 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -976,7 +976,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { - fprintf(stderr,"gameisover n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"gameisover n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); return(0); } if ( keystrokesp != 0 && myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() >= 2 ) @@ -984,7 +984,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven uint256 g,b; CPubKey p; std::vector k; if ( games_keystrokesopretdecode(g,b,p,k,spenttx.vout[spenttx.vout.size()-1].scriptPubKey) == 'K' ) { - fprintf(stderr,"update keystrokes.%p[%d]\n",keystrokes,numkeys); + //fprintf(stderr,"update keystrokes.%p[%d]\n",keystrokes,numkeys); keystrokes = (gamesevent *)realloc(keystrokes,(int32_t)(sizeof(*keystrokes)*numkeys + k.size())); for (i=0; i 0 ) { @@ -117,7 +117,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: fclose(fp); } } - fprintf(stderr,"call replay2\n"); + //fprintf(stderr,"call replay2\n"); num = games_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i no playerdata\n"); From 63cc12029754c0deac3f433a0af52404ad3cbf27 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:25:03 -1100 Subject: [PATCH 3251/3904] Replay --- src/cc/tetris.c | 25 ++++++++++++++----------- src/cc/tetris.cpp | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 487566ed4..6b63bb008 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -644,8 +644,19 @@ void *gamesiterate(struct games_state *rs) uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; gamesevent c; uint16_t skipcount=0; uint32_t eventid = 0; tetris_game *tg; WINDOW *board, *next, *hold, *score; - // Create windows for each section of the interface. + if ( rs->guiflag != 0 ) + { + // NCURSES initialization: + initscr(); // initialize curses + cbreak(); // pass key presses to program, but not signals + noecho(); // don't echo key presses to screen + keypad(stdscr, TRUE); // allow arrow keys + timeout(0); // no blocking on getch() + curs_set(0); // set the cursor to invisible + init_colors(); // setup tetris colors + } tg = tg_create(rs,22, 10); + // Create windows for each section of the interface. board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); @@ -668,7 +679,7 @@ void *gamesiterate(struct games_state *rs) { if ( skipcount > 0 ) issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x4000); - if ( c >= 0 ) + if ( c <= 0x7f ) issue_games_events(rs,Gametxidstr,eventid,c); skipcount = 0; } else skipcount++; @@ -679,6 +690,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); + fprintf(stderr,"%04x\n",c); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); @@ -833,15 +845,6 @@ int tetris(int argc, char **argv) tg = tg_create(rs,22, 10); }*/ - // NCURSES initialization: - initscr(); // initialize curses - cbreak(); // pass key presses to program, but not signals - noecho(); // don't echo key presses to screen - keypad(stdscr, TRUE); // allow arrow keys - timeout(0); // no blocking on getch() - curs_set(0); // set the cursor to invisible - init_colors(); // setup tetris colors - // Game loop tg = (tetris_game *)gamesiterate(rs); games_bailout(rs); diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 605c969ab..7f601bb56 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -91,7 +91,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: UniValue obj; //fprintf(stderr,"got baton\n"); seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { From 73f31d4a2edf3b780088f2acff03ac356028b929 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:33:51 -1100 Subject: [PATCH 3252/3904] Keystrokes --- src/cc/dapps/dappstd.c | 10 +++++----- src/cc/tetris.c | 15 +++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 3992cb80e..4f67f20e5 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -889,7 +889,7 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter while ( 1 ) { gamesfname(fname,seed,counter); - //printf("check (%s)\n",fname); + printf("check (%s)\n",fname); if ( (fp= fopen(fname,"rb")) == 0 ) break; if ( (fsize= get_filesize(fp)) <= 0 ) @@ -898,7 +898,7 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter //printf("fsize.%ld\n",fsize); break; } - if ( (keystrokes= (gamesevent *)realloc(keystrokes,sizeof(*keystrokes)*(num+fsize))) == 0 ) + if ( (keystrokes= (gamesevent *)realloc(keystrokes,sizeof(*keystrokes)*num+fsize))) == 0 ) { fprintf(stderr,"error reallocating keystrokes\n"); fclose(fp); @@ -912,9 +912,9 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter return(0); } fclose(fp); - num += fsize; + num += (int32_t)(fsize / sizeof(gamesevent)); counter++; - //fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); + fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); } *numkeysp = num; return(keystrokes); @@ -1097,7 +1097,7 @@ int main(int argc, char **argv) seed = atol(argv[1]); // non-windows #endif // _WIN32 - //fprintf(stderr,"replay %llu\n",(long long)seed); + fprintf(stderr,"replay %llu\n",(long long)seed); return(games_replay(seed,10)); } else diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 6b63bb008..5c3f742bb 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -810,7 +810,7 @@ int tetris(int argc, char **argv) memset(rs,0,sizeof(*rs)); rs->guiflag = 1; rs->sleeptime = 1; // non-zero to allow refresh() - if ( argc == 3 && strlen(argv[2]) == 64 ) + if ( argc >= 2 && strlen(argv[2]) == 64 ) { #ifdef _WIN32 #ifdef _MSC_VER @@ -822,12 +822,15 @@ int tetris(int argc, char **argv) rs->origseed = atol(argv[1]); // non-windows #endif // _WIN32 rs->seed = rs->origseed; - strcpy(Gametxidstr,argv[2]); - fprintf(stderr,"setplayerdata %s\n",Gametxidstr); - if ( games_setplayerdata(rs,Gametxidstr) < 0 ) + if ( argc >= 3 ) { - fprintf(stderr,"invalid gametxid, or already started\n"); - return(-1); + strcpy(Gametxidstr,argv[2]); + fprintf(stderr,"setplayerdata %s\n",Gametxidstr); + if ( games_setplayerdata(rs,Gametxidstr) < 0 ) + { + fprintf(stderr,"invalid gametxid, or already started\n"); + return(-1); + } } } else rs->seed = 777; From 42b2c36f726b6f1941dc1a7fb320cf33cf04dd79 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:34:30 -1100 Subject: [PATCH 3253/3904] Test --- src/cc/dapps/dappstd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 4f67f20e5..18f66ca58 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -898,7 +898,7 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter //printf("fsize.%ld\n",fsize); break; } - if ( (keystrokes= (gamesevent *)realloc(keystrokes,sizeof(*keystrokes)*num+fsize))) == 0 ) + if ( (keystrokes= (gamesevent *)realloc(keystrokes,sizeof(*keystrokes)*num+fsize)) == 0 ) { fprintf(stderr,"error reallocating keystrokes\n"); fclose(fp); From bd855221dfa67a79ac3b6c6c2545c355d5815684 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:36:47 -1100 Subject: [PATCH 3254/3904] Activate replay --- src/cc/dapps/dappstd.c | 5 +++-- src/cc/gamescc.cpp | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 18f66ca58..d8ed48b9b 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -886,10 +886,10 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter { char fname[1024]; gamesevent *keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; *numkeysp = 0; - while ( 1 ) + if ( 1 ) { gamesfname(fname,seed,counter); - printf("check (%s)\n",fname); + //printf("check (%s)\n",fname); if ( (fp= fopen(fname,"rb")) == 0 ) break; if ( (fsize= get_filesize(fp)) <= 0 ) @@ -939,6 +939,7 @@ int32_t games_replay(uint64_t seed,int32_t sleeptime) if ( seed == 0 ) seed = 777; keystrokes = games_keystrokesload(&num,seed,counter); + fprintf(stderr,"keystrokes.%p num.%d\n",keystrokes,num); if ( num > 0 ) { sprintf(fname,"%s.%llu.player",GAMENAME,(long long)seed); diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 1684e6a18..282b0051b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -102,7 +102,6 @@ gamesevent games_readevent(struct games_state *rs) int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis) { struct games_state *rs; FILE *fp; int32_t i,n; void *ptr; -return(0); rs = (struct games_state *)calloc(1,sizeof(*rs)); rs->seed = rs->origseed = seed; rs->keystrokes = keystrokes; From 81170c2e29f845c254173ab83e7d9609665999ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:37:28 -1100 Subject: [PATCH 3255/3904] Break --- src/cc/dapps/dappstd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index d8ed48b9b..2b5900408 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -886,7 +886,7 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter { char fname[1024]; gamesevent *keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; *numkeysp = 0; - if ( 1 ) + while ( 1 ) { gamesfname(fname,seed,counter); //printf("check (%s)\n",fname); @@ -915,6 +915,7 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter num += (int32_t)(fsize / sizeof(gamesevent)); counter++; fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); + break; } *numkeysp = num; return(keystrokes); From b4a06f0cbc27d47eb441af5ac8791cfa0d4f2d0b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:39:26 -1100 Subject: [PATCH 3256/3904] Test --- src/cc/dapps/dappstd.c | 2 +- src/cc/rogue/cursesd.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 2b5900408..697e9f948 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -914,7 +914,7 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter fclose(fp); num += (int32_t)(fsize / sizeof(gamesevent)); counter++; - fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); + //fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); break; } *numkeysp = num; diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 0b68bc307..7dd83d435 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -175,6 +175,8 @@ char *unctrl(char c); #define leaveok(win,bf) 0 #define halfdelay(x) 0 #define nocbreak() 0 +#define cbreak() 0 +#define curs_set(x) 0 // for tetris #define init_pair(a,b,c) 0 From 5295446c978338d3eee62de4fabd001985b6d6cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 06:44:16 -1100 Subject: [PATCH 3257/3904] Revendian --- src/cc/dapps/dappstd.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 697e9f948..3653166cb 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -882,9 +882,21 @@ long get_filesize(FILE *fp) return(fsize); } +gamesevent revendian(gamesevent revx) +{ + gamesevent x = 0; + for (i=0; i>= 8; + } + return(x); +} + gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) { - char fname[1024]; gamesevent *keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; + char fname[1024]; gamesevent *keystrokes = 0; FILE *fp; long fsize; int32_t i,num = 0; *numkeysp = 0; while ( 1 ) { @@ -911,6 +923,8 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter free(keystrokes); return(0); } + for (i=0; i Date: Tue, 26 Mar 2019 06:44:59 -1100 Subject: [PATCH 3258/3904] Switch --- src/cc/dapps/dappstd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 3653166cb..9240c6404 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -884,11 +884,11 @@ long get_filesize(FILE *fp) gamesevent revendian(gamesevent revx) { - gamesevent x = 0; + int32_t i; gamesevent x = 0; for (i=0; i>= 8; } return(x); From 9df89f97fcccf72444b83e06bd6ea102572b9fd3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 07:01:15 -1100 Subject: [PATCH 3259/3904] +print --- src/cc/dapps/dappstd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 9240c6404..5961b5e7a 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -885,12 +885,10 @@ long get_filesize(FILE *fp) gamesevent revendian(gamesevent revx) { int32_t i; gamesevent x = 0; + fprintf(stderr,"%04x -> ",revx); for (i=0; i>= 8; - } + ((uint8_t *)&x)[i] = ((uint8_t *)&revx)[sizeof(gamesevent)-1-i]; + fprintf(stderr,"%04x\n",x); return(x); } From 15143c0129bb15824ab1c06f9b4d97319bf3617b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 07:02:35 -1100 Subject: [PATCH 3260/3904] Fix --- src/cc/dapps/dappstd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 5961b5e7a..6ef4381e5 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -921,10 +921,10 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter free(keystrokes); return(0); } - for (i=0; i Date: Tue, 26 Mar 2019 07:09:02 -1100 Subject: [PATCH 3261/3904] display_board(board,tg); display_piece(next,tg->next); display_piece(hold,tg->stored); display_score(score,tg); if ( (counter++ % 5) == 0 ) doupdate(); --- src/cc/dapps/dappstd.c | 6 +++--- src/cc/tetris.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 6ef4381e5..eee51739b 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -885,10 +885,10 @@ long get_filesize(FILE *fp) gamesevent revendian(gamesevent revx) { int32_t i; gamesevent x = 0; - fprintf(stderr,"%04x -> ",revx); + //fprintf(stderr,"%04x -> ",revx); for (i=0; i 0 ) { sprintf(fname,"%s.%llu.player",GAMENAME,(long long)seed); diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 5c3f742bb..cb54ee261 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -299,11 +299,11 @@ static void tg_handle_move(struct games_state *rs,tetris_game *obj, tetris_move { switch (move) { case TM_LEFT: - fprintf(stderr,"LEFT "); + //fprintf(stderr,"LEFT "); tg_move(obj, -1); break; case TM_RIGHT: - fprintf(stderr,"RIGHT "); + //fprintf(stderr,"RIGHT "); tg_move(obj, 1); break; case TM_DROP: @@ -644,7 +644,7 @@ void *gamesiterate(struct games_state *rs) uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; gamesevent c; uint16_t skipcount=0; uint32_t eventid = 0; tetris_game *tg; WINDOW *board, *next, *hold, *score; - if ( rs->guiflag != 0 ) + if ( rs->guiflag != 0 || rs->sleeptime != 0 ) { // NCURSES initialization: initscr(); // initialize curses @@ -664,15 +664,18 @@ void *gamesiterate(struct games_state *rs) while ( running != 0 ) { running = tg_tick(rs,tg,move); - if ( rs->guiflag != 0 ) + if ( rs->guiflag != 0 || rs->sleeptime != 0 ) { -#ifdef STANDALONE display_board(board,tg); display_piece(next,tg->next); display_piece(hold,tg->stored); display_score(score,tg); if ( (counter++ % 5) == 0 ) doupdate(); + } + if ( rs->guiflag != 0 ) + { +#ifdef STANDALONE sleep_milli(10); c = games_readevent(rs); if ( c <= 0x7f || skipcount == 0x3fff ) @@ -687,6 +690,8 @@ void *gamesiterate(struct games_state *rs) } else { + if ( rs->sleeptime >= 1000 ) + sleep_milli(rs->sleeptime/1000); if ( skipcount == 0 ) { c = games_readevent(rs); From 140468d27dcba162144a60412f7015671ad2d7a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 07:10:36 -1100 Subject: [PATCH 3262/3904] -print --- src/cc/dapps/dappstd.c | 2 +- src/cc/tetris.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index eee51739b..9b44bc6a9 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -1112,7 +1112,7 @@ int main(int argc, char **argv) #endif // _WIN32 fprintf(stderr,"replay %llu\n",(long long)seed); - return(games_replay(seed,10)); + return(games_replay(seed,3)); } else { diff --git a/src/cc/tetris.c b/src/cc/tetris.c index cb54ee261..bd9a5526d 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -695,7 +695,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - fprintf(stderr,"%04x\n",c); + //fprintf(stderr,"%04x\n",c); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From 2bcc183fb073c89dff6b9ca5e145ed0ba089a1ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 07:16:24 -1100 Subject: [PATCH 3263/3904] +print --- src/cc/tetris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index bd9a5526d..cb54ee261 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -695,7 +695,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - //fprintf(stderr,"%04x\n",c); + fprintf(stderr,"%04x\n",c); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From bd4bab770c09f227000b5641b03dcf07fd315dea Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 07:23:50 -1100 Subject: [PATCH 3264/3904] Dont flip --- src/cc/dapps/dappstd.c | 12 +----------- src/cc/gamescc.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 9b44bc6a9..764a569ac 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -882,16 +882,6 @@ long get_filesize(FILE *fp) return(fsize); } -gamesevent revendian(gamesevent revx) -{ - int32_t i; gamesevent x = 0; - //fprintf(stderr,"%04x -> ",revx); - for (i=0; i ",revx); + for (i=0; i Date: Tue, 26 Mar 2019 07:24:48 -1100 Subject: [PATCH 3265/3904] gamesevent games_revendian(gamesevent revx) --- src/cc/tetris.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/tetris.h b/src/cc/tetris.h index 94d56dbfc..338eee3cb 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -199,6 +199,7 @@ void *gamesiterate(struct games_state *rs); void games_packitemstr(char *packitemstr,struct games_packitem *item); uint64_t _games_rngnext(uint64_t initseed); int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); +gamesevent games_revendian(gamesevent revx); #endif From 4799abb82dd0bcf86353a8eee3246599a458ce92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 07:27:08 -1100 Subject: [PATCH 3266/3904] -print --- src/cc/tetris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index cb54ee261..bd9a5526d 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -695,7 +695,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - fprintf(stderr,"%04x\n",c); + //fprintf(stderr,"%04x\n",c); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From 317b1a249829b6f4e400c295280c0af00731096e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:02:29 -1100 Subject: [PATCH 3267/3904] Tweaks --- src/cc/gamescc.cpp | 222 +++++++++++++++++++++++++++++++++++------ src/cc/gamescc.h | 12 ++- src/cc/rogue_rpc.cpp | 71 +++++++------ src/cc/tetris.c | 12 ++- src/cc/tetris.cpp | 232 ++++++------------------------------------- src/cc/tetris.h | 14 +-- 6 files changed, 288 insertions(+), 275 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index c01a89b69..063da9355 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -16,6 +16,9 @@ #include "gamescc.h" #include "tetris.c" // replace with game code +int32_t GAMEDATA(struct games_player *P,void *ptr); +void GAMEJSON(UniValue &obj,struct games_player *P); + uint64_t _games_rngnext(uint64_t initseed) { uint16_t seeds[4]; int32_t i; @@ -92,19 +95,6 @@ gamesevent games_readevent(struct games_state *rs) //_quit(); return(27); } - /*if ( rs != 0 && rs->guiflag != 0 ) - { - if ( rs->num < sizeof(rs->buffered) ) - { - rs->buffered[rs->num++] = ch; - if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 ) - { - rs->needflush = (uint32_t)time(NULL); - //fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered)); - //sleep(3); - } - } else fprintf(stderr,"buffer filled without flushed\n"); - }*/ } else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs); return(ch); } @@ -121,7 +111,6 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 { rs->P = *player; rs->restoring = 1; - //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); if ( rs->P.packsize > MAXPACK ) rs->P.packsize = MAXPACK; } @@ -150,14 +139,15 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 /*if ( (fp= fopen("checkfile","wb")) != 0 ) { //save_file(rs,fp,0); - //fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); }*/ if ( ptr != 0 ) { // extract data from ptr - if ( newdata != 0 && rs->playersize > 0 ) + if ( GAMEDATA(&rs->P,ptr) < 0 ) + memset(&rs->P,0,sizeof(rs->P)); + else if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); free(ptr); } @@ -695,7 +685,6 @@ UniValue games_playerobj(std::vector playerdata,uint256 playertxid,uint } datastr[i<<1] = 0; } - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; for (i=0; i playerdata,uint256 playertxid,uint free(datastr); } obj.push_back(Pair("pack",a)); - obj.push_back(Pair("packsize",(int64_t)P.packsize)); - obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); - obj.push_back(Pair("strength",(int64_t)(P.strength&0xffff))); - obj.push_back(Pair("maxstrength",(int64_t)(P.strength>>16))); - obj.push_back(Pair("level",(int64_t)P.level)); - obj.push_back(Pair("experience",(int64_t)P.experience)); - obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); + GAMEPLAYERJSON(obj,&P); obj.push_back(Pair("chain",symbol)); obj.push_back(Pair("pname",pname)); return(obj); @@ -834,6 +817,24 @@ int32_t games_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } +int64_t games_buyins(uint256 gametxid) +{ + int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; int64_t buyins = 0; + for (i=0; i= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + { + if ( spenttx.vout[0].nValue > GAMES_REGISTRATIONSIZE ) + buyins += (spenttx.vout[0].nValue - GAMES_REGISTRATIONSIZE); + } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"vout %d is unspent\n",vout); + } + return(buyins); +} + uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr) { CBlockIndex *pindex; int32_t ht,openslots,delay,numplayers; uint256 hashBlock; uint64_t seed=0; char cmd[512]; CTransaction tx; @@ -861,6 +862,7 @@ uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 obj.push_back(Pair("alive",games_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); obj.push_back(Pair("openslots",openslots)); obj.push_back(Pair("numplayers",numplayers)); + obj.push_back(Pair("buyins",ValueFromAmount(game_buyins(gametxid)))); } obj.push_back(Pair("maxplayers",maxplayers)); obj.push_back(Pair("buyin",ValueFromAmount(buyin))); @@ -885,6 +887,27 @@ UniValue games_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } +void disp_gamesplayerdata(std::vector playerdata) +{ + struct games_player P; int32_t i; char packitemstr[512],line[512]; + if ( playerdata.size() > 0 ) + { + for (i=0; i &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) +{ + CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64]; gamesevent *keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; + gamespk = GetUnspendable(cp,0); + *numkeysp = 0; + seed = 0; + num = numkeys = 0; + playertxid = zeroid; + str[0] = 0; + if ( (err= games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) + { + if ( (retval= games_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gamesaddr,numplayers,symbol,pname)) == 0 ) + { + UniValue obj; + //fprintf(stderr,"got baton\n"); + seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i no playerdata\n"); + newdata.resize(0); + *numkeysp = numkeys; + return(keystrokes); + } + else + { + *numkeysp = numkeys; + return(keystrokes); + } + } else num = 0; + } + else + { + fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); + if ( keystrokes != 0 ) + free(keystrokes), keystrokes = 0; + } + } else fprintf(stderr,"extractgame: invalid game\n"); + //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); + return(0); +} + UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); CPubKey pk,gamespk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],gamesaddr[64],*pubstr,*hexstr; gamesevent *keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; @@ -1380,7 +1478,7 @@ UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,char *method) { //vin0 -> highlander vout from creategame TCBOO //vin1 -> keystrokes baton of completed game, must be last to quit or first to win, only spent registration batons matter. If more than 60 blocks since last keystrokes, it is forfeit @@ -1393,8 +1491,8 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // vout0 -> playerdata marker // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); char *method = (char *)"bailout"; - UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64]; gamesevent *keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64]; gamesevent *keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) @@ -1452,11 +1550,10 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - if ( (P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0) ) + if ( disp_gamesplayer(str,&P) < 0 ) { //fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); - //P.gold = (P.gold * 8) / 10; } else { @@ -1464,7 +1561,7 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); cashout = games_cashout(&P); - fprintf(stderr,"\nextracted $$$gold.%d -> %.8f GAME hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); + fprintf(stderr,"\ncashout %.8f extracted %s\n",(double)cashout/COIN,str); if ( funcid == 'H' && maxplayers > 1 ) { if ( P.amulet == 0 ) @@ -1474,7 +1571,7 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) else if ( games_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) return(cclib_error(result,"highlander must be a winner or last one standing")); } - cashout += numplayers * buyin; + cashout += games_buyins(gametxid);//numplayers * buyin; } if ( cashout > 0 ) { @@ -1516,6 +1613,16 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue games_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + return(games_finish(txfee,cp,params,"bailout")); +} + +UniValue games_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + return(games_finish(txfee,cp,params,"highlander")); +} + UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey gamespk,mypk,pk; std::string symbol,pname; char coinaddr[64]; @@ -1638,6 +1745,59 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) +{ + static uint32_t good,bad; static uint256 prevgame; + char str[512],gamesaddr[64],str2[67],fname[64]; gamesevent *keystrokes; int32_t i,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; + *cashoutp = 0; + gamespk = GetUnspendable(cp,0); + GetCCaddress1of2(cp,gamesaddr,gamespk,pk); + if ( (keystrokes= games_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) + { + free(keystrokes); + sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); + remove(fname); + for (i=0; ievalcode == EVAL_GAMES ) \ return(games_keystrokes(txfee,cp,params)); \ else if ( strcmp(method,"extract") == 0 ) \ return(games_extract(txfee,cp,params)); \ - else if ( strcmp(method,"finish") == 0 ) \ - return(games_finish(txfee,cp,params)); \ + else if ( strcmp(method,"bailout") == 0 ) \ + return(games_bailout(txfee,cp,params)); \ + else if ( strcmp(method,"highlander") == 0 ) \ + return(games_highlander(txfee,cp,params)); \ else if ( strcmp(method,"fund") == 0 ) \ return(games_fund(txfee,cp,params)); \ else \ diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ee5f3d566..4b74e21b7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -283,6 +283,24 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } +int64_t rogue_buyins(uint256 gametxid) +{ + int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; int64_t buyins = 0; + for (i=0; i= 0 ) + { + if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) + { + if ( spenttx.vout[0].nValue > ROGUE_REGISTRATIONSIZE ) + buyins += (spenttx.vout[0].nValue - ROGUE_REGISTRATIONSIZE); + } //else fprintf(stderr,"cant find spenttxid.%s\n",spenttxid.GetHex().c_str()); + } //else fprintf(stderr,"vout %d is unspent\n",vout); + } + return(buyins); +} + int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0) { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; @@ -690,6 +708,7 @@ uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 obj.push_back(Pair("alive",rogue_playersalive(openslots,numplayers,gametxid,maxplayers,ht,tx))); obj.push_back(Pair("openslots",openslots)); obj.push_back(Pair("numplayers",numplayers)); + obj.push_back(Pair("buyins",ValueFromAmount(rogue_buyins(gametxid)))); } obj.push_back(Pair("maxplayers",maxplayers)); obj.push_back(Pair("buyin",ValueFromAmount(buyin))); @@ -1093,6 +1112,20 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +int64_t rogue_cashout(struct rogue_player *P) +{ + int32_t dungeonlevel; int64_t mult = 10; + if ( P->amulet != 0 ) + mult *= 5; + dungeonlevel = P->dungeonlevel; + if ( P->amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; + if ( dungeonlevel > 42 ) + dungeonlevel = 42; + cashout = (uint64_t)P->gold * P->gold * mult * dungeonlevel; + return(cashout); +} + int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) { static uint32_t good,bad; static uint256 prevgame; @@ -1105,17 +1138,9 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C free(keystrokes); sprintf(fname,"rogue.%llu.pack",(long long)seed); remove(fname); - for (i=0; i 42 ) - dungeonlevel = 42; - *cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel; + *cashoutp = rogue_cashout(&P); if ( newdata == playerdata ) { if ( gametxid != prevgame ) @@ -1206,16 +1231,10 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("name","rogue")); result.push_back(Pair("method",method)); result.push_back(Pair("myrogueaddr",myrogueaddr)); + mult = 10; //100000; if ( strcmp(method,"bailout") == 0 ) - { funcid = 'Q'; - mult = 10; //100000; - } - else - { - funcid = 'H'; - mult = 20; //200000; - } + else funcid = 'H'; if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) @@ -1264,13 +1283,10 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); - if ( P.amulet != 0 ) - mult *= 5; - dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 26 ) - dungeonlevel = 26; - cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel; + cashout = rogue_cashout(&P); fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); + if ( komodo_nextheight() > 77777 && cashout > ROGUE_MAXCASHOUT ) + cashout = ROGUE_MAXCASHOUT; if ( funcid == 'H' && maxplayers > 1 ) { if ( P.amulet == 0 ) @@ -1280,12 +1296,11 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param else if ( rogue_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) return(cclib_error(result,"highlander must be a winner or last one standing")); } + cashout *= 2; cashout += numplayers * buyin; } if ( cashout > 0 ) { - if ( komodo_nextheight() > 77777 && cashout > ROGUE_MAXCASHOUT ) - cashout = ROGUE_MAXCASHOUT; if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr)) > cashout ) CCchange = (inputsum - cashout); else fprintf(stderr,"couldnt find enough utxos\n"); @@ -1598,13 +1613,13 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( enabled != 0 ) return eval->Invalid("mismatched playerdata"); } + if ( height > 777777 && cashout > ROGUE_MAXCASHOUT ) + cashout = ROGUE_MAXCASHOUT; if ( funcid == 'H' ) { cashout *= 2; - //cashout += numplayers * buyin; + cashout += rogue_buyins(gametxid); } - if ( height > 777777 && cashout > ROGUE_MAXCASHOUT ) - cashout = ROGUE_MAXCASHOUT; sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { diff --git a/src/cc/tetris.c b/src/cc/tetris.c index bd9a5526d..54ca3b953 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -7,12 +7,20 @@ also, the standalone game needs to support argv of seed gametxid, along with replay args */ -static int random_tetromino(struct games_state *rs) +int random_tetromino(struct games_state *rs) { rs->seed = _games_rngnext(rs->seed); return(rs->seed % NUM_TETROMINOS); } +int32_t tetrisdata(struct games_player *P,void *ptr) +{ + tetris_game *tg = ptr; + P->gold = tg->points; + P->dungeonlevel = tg->level; + return(0); +} + /***************************************************************************/ /** https://github.com/brenns10/tetris @file main.c @@ -676,7 +684,7 @@ void *gamesiterate(struct games_state *rs) if ( rs->guiflag != 0 ) { #ifdef STANDALONE - sleep_milli(10); + sleep_milli(25); c = games_readevent(rs); if ( c <= 0x7f || skipcount == 0x3fff ) { diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 7f601bb56..e44b50925 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -14,14 +14,37 @@ * * ******************************************************************************/ -int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gamesevent **keystrokesp,int32_t &numkeys,int32_t ®slot,std::vector &playerdata,uint256 &batontxid,int32_t &batonvout,int64_t &batonvalue,int32_t &batonht,uint256 gametxid,CTransaction gametx,int32_t maxplayers,char *destaddr,int32_t &numplayers,std::string &symbol,std::string &pname); -int32_t games_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0); -uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 gametxid,char *mygamesaddr); - // game specific code for daemon void games_packitemstr(char *packitemstr,struct games_packitem *item) { - sprintf(packitemstr,"not yet"); + sprintf(packitemstr,""); +} + +int64_t games_cashout(struct games_player *P) +{ + int32_t dungeonlevel = P->dungeonlevel; int64_t mult=1000,cashout = 0; + cashout = (uint64_t)P->gold * mult * dungeonlevel * dungeonlevel; + return(cashout); +} + +void tetrisjson(UniValue &obj,struct games_player *P) +{ + obj.push_back(Pair("packsize",(int64_t)P->packsize)); + obj.push_back(Pair("hitpoints",(int64_t)P->hitpoints)); + obj.push_back(Pair("strength",(int64_t)(P->strength&0xffff))); + obj.push_back(Pair("maxstrength",(int64_t)(P->strength>>16))); + obj.push_back(Pair("level",(int64_t)P->level)); + obj.push_back(Pair("experience",(int64_t)P->experience)); + obj.push_back(Pair("dungeonlevel",(int64_t)P->dungeonlevel)); +} + +int32_t disp_gamesplayer(char *str,struct games_player *P) +{ + str[0] = 0; + if ( P->gold <= 0 || P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) + return(-1); + sprintf(str," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",P->gold,P->hitpoints,P->strength&0xffff,P->strength>>16,P->level,P->experience,P->dungeonlevel); + return(0); } int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) @@ -43,205 +66,6 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay } else return(-1); } -int64_t games_cashout(struct games_player *P) -{ - int32_t dungeonlevel; int64_t mult=10,cashout = 0; - if ( P->amulet != 0 ) - mult *= 5; - dungeonlevel = P->dungeonlevel; - if ( P->amulet != 0 && dungeonlevel < 26 ) - dungeonlevel = 26; - cashout = (uint64_t)P->gold * P->gold * mult * dungeonlevel; - return(cashout); -} - -void disp_gamesplayerdata(std::vector playerdata) -{ - struct games_player P; int32_t i; char packitemstr[512]; - if ( playerdata.size() > 0 ) - { - for (i=0; i>16,P.level,P.experience,P.dungeonlevel); - for (i=0; i &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *gamesaddr) -{ - CPubKey gamespk; int32_t i,num,retval,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64]; gamesevent *keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct games_player P,endP; - gamespk = GetUnspendable(cp,0); - *numkeysp = 0; - seed = 0; - num = numkeys = 0; - playertxid = zeroid; - str[0] = 0; - if ( (err= games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) - { - if ( (retval= games_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,gamesaddr,numplayers,symbol,pname)) == 0 ) - { - UniValue obj; - //fprintf(stderr,"got baton\n"); - seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr); - //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); - memset(&P,0,sizeof(P)); - if ( playerdata.size() > 0 ) - { - for (i=0; i no playerdata\n"); - newdata.resize(0); - *numkeysp = numkeys; - return(keystrokes); - /* P.gold = (P.gold * 8) / 10; - if ( keystrokes != 0 ) - { - free(keystrokes); - keystrokes = 0; - *numkeysp = 0; - return(keystrokes); - }*/ - } - else - { - sprintf(str,"$$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); - //fprintf(stderr,"%s\n",str); - *numkeysp = numkeys; - return(keystrokes); - } - } else num = 0; - } - else - { - fprintf(stderr,"extractgame: couldnt find baton keystrokes.%p retval.%d\n",keystrokes,retval); - if ( keystrokes != 0 ) - free(keystrokes), keystrokes = 0; - } - } else fprintf(stderr,"extractgame: invalid game\n"); - //fprintf(stderr,"extract %s\n",gametxid.GetHex().c_str()); - return(0); -} - -int32_t games_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct CCcontract_info *cp,std::vector playerdata,uint256 gametxid,CPubKey pk) -{ - static uint32_t good,bad; static uint256 prevgame; - char str[512],gamesaddr[64],str2[67],fname[64]; gamesevent *keystrokes; int32_t i,dungeonlevel,numkeys; std::vector newdata; uint64_t seed; CPubKey gamespk; struct games_player P; - *cashoutp = 0; - gamespk = GetUnspendable(cp,0); - GetCCaddress1of2(cp,gamesaddr,gamespk,pk); - if ( (keystrokes= games_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,gamesaddr)) != 0 ) - { - free(keystrokes); - sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); - remove(fname); - - for (i=0; i no playerdata, good.%d bad.%d\n",good,bad); - } - *cashoutp = 0; - return(0); - } - } - if ( gametxid != prevgame ) - { - prevgame = gametxid; - bad++; - disp_gamesplayerdata(newdata); - disp_gamesplayerdata(playerdata); - fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); - fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,gamesaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); - } - } - sprintf(fname,"%s.%llu.pack",GAMENAME,(long long)seed); - remove(fname); - //fprintf(stderr,"no keys games_extractgame %s\n",gametxid.GetHex().c_str()); - return(-1); -} - bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true); diff --git a/src/cc/tetris.h b/src/cc/tetris.h index 338eee3cb..79a1c2c3e 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -163,9 +163,12 @@ void tg_print(tetris_game *obj, FILE *f); * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ -#define GAMENAME "tetris" -#define GAMEMAIN tetris -#define CHAINNAME "GTEST" +#define GAMENAME "tetris" // name of executable +#define GAMEMAIN tetris // main program of game +#define GAMEJSON tetrisjson // displays game specific json +#define GAMEDATA tetrisdata // extracts data from game specific variables into games_state +#define CHAINNAME "GTEST" // -ac_name= +typedef uint16_t gamesevent; // can be 8, 16, 32, or 64 bits #define MAXPACK 23 struct games_packitem @@ -180,8 +183,6 @@ struct games_player struct games_packitem gamespack[MAXPACK]; }; -typedef uint16_t gamesevent; - struct games_state { uint64_t seed,origseed; @@ -191,7 +192,7 @@ struct games_state FILE *logfp; struct games_player P; gamesevent buffered[5000],*keystrokes; - uint8_t playerdata[1024]; + uint8_t playerdata[8192]; }; extern struct games_state globalR; void *gamesiterate(struct games_state *rs); @@ -200,6 +201,7 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item); uint64_t _games_rngnext(uint64_t initseed); int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); gamesevent games_revendian(gamesevent revx); +int32_t disp_gamesplayer(char *str,struct games_player *P); #endif From ef1c722d2de8985d423c2ff17ca41ccd0c125490 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:04:11 -1100 Subject: [PATCH 3268/3904] Test --- src/cc/gamescc.cpp | 3 ++- src/cc/tetris.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 063da9355..6763b9033 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -17,7 +17,6 @@ #include "tetris.c" // replace with game code int32_t GAMEDATA(struct games_player *P,void *ptr); -void GAMEJSON(UniValue &obj,struct games_player *P); uint64_t _games_rngnext(uint64_t initseed) { @@ -160,6 +159,8 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 #include "tetris.cpp" // replace with game specific functions +void GAMEJSON(UniValue &obj,struct games_player *P); + /* ./c cclib rng 17 \"[%229433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775%22,250]\" { diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 54ca3b953..dd142e036 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -15,7 +15,7 @@ int random_tetromino(struct games_state *rs) int32_t tetrisdata(struct games_player *P,void *ptr) { - tetris_game *tg = ptr; + tetris_game *tg = (tetris_game *)ptr; P->gold = tg->points; P->dungeonlevel = tg->level; return(0); From 1254c3ed5cbb7e3ad6e26c3d859956be2b723198 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:10:39 -1100 Subject: [PATCH 3269/3904] Test --- src/cc/gamescc.cpp | 14 +++++++------- src/cc/tetris.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 6763b9033..62d49c3dd 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -818,7 +818,7 @@ int32_t games_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } -int64_t games_buyins(uint256 gametxid) +int64_t games_buyins(uint256 gametxid,int32_t maxplayers) { int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; int64_t buyins = 0; for (i=0; i playerdata) { - struct games_player P; int32_t i; char packitemstr[512],line[512]; + struct games_player P; int32_t i; char packitemstr[512],str[512]; if ( playerdata.size() > 0 ) { for (i=0; i 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64]; gamesevent *keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,numkeys,maxplayers,batonht,batonvout; char mygamesaddr[64],str[512]; gamesevent *keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,gamespk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) @@ -1572,7 +1572,7 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,ch else if ( games_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) return(cclib_error(result,"highlander must be a winner or last one standing")); } - cashout += games_buyins(gametxid);//numplayers * buyin; + cashout += games_buyins(gametxid,maxplayers);//numplayers * buyin; } if ( cashout > 0 ) { @@ -1616,12 +1616,12 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,ch UniValue games_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - return(games_finish(txfee,cp,params,"bailout")); + return(games_finish(txfee,cp,params,(char *)"bailout")); } UniValue games_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - return(games_finish(txfee,cp,params,"highlander")); + return(games_finish(txfee,cp,params,(char *)"highlander")); } UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index e44b50925..a862e2a3f 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -17,7 +17,7 @@ // game specific code for daemon void games_packitemstr(char *packitemstr,struct games_packitem *item) { - sprintf(packitemstr,""); + strcpy(packitemstr,""); } int64_t games_cashout(struct games_player *P) From f1737210077500e3ebec693f8ab674fec799251c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:11:29 -1100 Subject: [PATCH 3270/3904] Test --- src/cc/tetris.cpp | 2 +- src/cc/tetris.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index a862e2a3f..a461d139e 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -27,7 +27,7 @@ int64_t games_cashout(struct games_player *P) return(cashout); } -void tetrisjson(UniValue &obj,struct games_player *P) +void tetrisplayerjson(UniValue &obj,struct games_player *P) { obj.push_back(Pair("packsize",(int64_t)P->packsize)); obj.push_back(Pair("hitpoints",(int64_t)P->hitpoints)); diff --git a/src/cc/tetris.h b/src/cc/tetris.h index 79a1c2c3e..9d16a8e8b 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -165,7 +165,7 @@ void tg_print(tetris_game *obj, FILE *f); ******************************************************************************/ #define GAMENAME "tetris" // name of executable #define GAMEMAIN tetris // main program of game -#define GAMEJSON tetrisjson // displays game specific json +#define GAMEPLAYERJSON tetrisplayerjson // displays game specific json #define GAMEDATA tetrisdata // extracts data from game specific variables into games_state #define CHAINNAME "GTEST" // -ac_name= typedef uint16_t gamesevent; // can be 8, 16, 32, or 64 bits From 5abd8a92071773f5e85e7a33dfb2c587e0be71ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:19:43 -1100 Subject: [PATCH 3271/3904] test --- src/cc/tetris.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index dd142e036..3e2d4a24c 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -307,11 +307,11 @@ static void tg_handle_move(struct games_state *rs,tetris_game *obj, tetris_move { switch (move) { case TM_LEFT: - //fprintf(stderr,"LEFT "); + fprintf(stderr,"LEFT "); tg_move(obj, -1); break; case TM_RIGHT: - //fprintf(stderr,"RIGHT "); + fprintf(stderr,"RIGHT "); tg_move(obj, 1); break; case TM_DROP: @@ -459,7 +459,7 @@ void tg_init(struct games_state *rs,tetris_game *obj, int rows, int cols) obj->stored.ori = 0; obj->stored.loc.row = 0; obj->next.loc.col = obj->cols/2 - 2; - printf("%d", obj->falling.loc.col); + //printf("%d", obj->falling.loc.col); } tetris_game *tg_create(struct games_state *rs,int rows, int cols) @@ -672,7 +672,7 @@ void *gamesiterate(struct games_state *rs) while ( running != 0 ) { running = tg_tick(rs,tg,move); - if ( rs->guiflag != 0 || rs->sleeptime != 0 ) + if ( 0 && (rs->guiflag != 0 || rs->sleeptime != 0) ) { display_board(board,tg); display_piece(next,tg->next); @@ -703,7 +703,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - //fprintf(stderr,"%04x\n",c); + fprintf(stderr,"%04x\n",c); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From 701f7027f5c9252482850d68f25bfcd952c05cf6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:21:06 -1100 Subject: [PATCH 3272/3904] -flip --- src/cc/dapps/dappstd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 764a569ac..925b8749a 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -913,8 +913,8 @@ gamesevent *games_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter } fclose(fp); num += (int32_t)(fsize / sizeof(gamesevent)); - for (i=0; i Date: Tue, 26 Mar 2019 09:22:13 -1100 Subject: [PATCH 3273/3904] -print --- src/cc/tetris.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 3e2d4a24c..7db0e7fa0 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -307,11 +307,11 @@ static void tg_handle_move(struct games_state *rs,tetris_game *obj, tetris_move { switch (move) { case TM_LEFT: - fprintf(stderr,"LEFT "); + //fprintf(stderr,"LEFT "); tg_move(obj, -1); break; case TM_RIGHT: - fprintf(stderr,"RIGHT "); + //fprintf(stderr,"RIGHT "); tg_move(obj, 1); break; case TM_DROP: @@ -703,7 +703,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - fprintf(stderr,"%04x\n",c); + //fprintf(stderr,"%04x\n",c); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From 250fe82e9c18dd63e433efad944c9e8ce81db9eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:23:50 -1100 Subject: [PATCH 3274/3904] Display --- src/cc/tetris.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 7db0e7fa0..e5a9be712 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -672,7 +672,7 @@ void *gamesiterate(struct games_state *rs) while ( running != 0 ) { running = tg_tick(rs,tg,move); - if ( 0 && (rs->guiflag != 0 || rs->sleeptime != 0) ) + if ( 1 && (rs->guiflag != 0 || rs->sleeptime != 0) ) { display_board(board,tg); display_piece(next,tg->next); @@ -698,8 +698,8 @@ void *gamesiterate(struct games_state *rs) } else { - if ( rs->sleeptime >= 1000 ) - sleep_milli(rs->sleeptime/1000); + if ( rs->sleeptime != 0 ) + sleep_milli(1); if ( skipcount == 0 ) { c = games_readevent(rs); From 7c63b83176b25a0e14cdfae2ad5ebd6821fa69df Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:26:40 -1100 Subject: [PATCH 3275/3904] Test --- src/cc/tetris.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index e5a9be712..6308740e7 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -678,13 +678,13 @@ void *gamesiterate(struct games_state *rs) display_piece(next,tg->next); display_piece(hold,tg->stored); display_score(score,tg); - if ( (counter++ % 5) == 0 ) - doupdate(); } if ( rs->guiflag != 0 ) { #ifdef STANDALONE - sleep_milli(25); + sleep_milli(15); + if ( (counter++ % 10) == 0 ) + doupdate(); c = games_readevent(rs); if ( c <= 0x7f || skipcount == 0x3fff ) { @@ -699,7 +699,11 @@ void *gamesiterate(struct games_state *rs) else { if ( rs->sleeptime != 0 ) + { sleep_milli(1); + if ( (counter++ % 20) == 0 ) + doupdate(); + } if ( skipcount == 0 ) { c = games_readevent(rs); From a29ad0f9bbbd478c15a296e8ef62ed2362061991 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:28:19 -1100 Subject: [PATCH 3276/3904] +print --- src/cc/tetris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 6308740e7..852aecbc9 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -707,7 +707,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - //fprintf(stderr,"%04x\n",c); + fprintf(stderr,"%04x\n",c); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From 0d7dbc3929e4462882aa1848dfea6860c96aed29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:31:44 -1100 Subject: [PATCH 3277/3904] rs->replaydone --- src/cc/tetris.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 852aecbc9..3bf5b098a 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -698,6 +698,8 @@ void *gamesiterate(struct games_state *rs) } else { + if ( rs->replaydone != 0 ) + break; if ( rs->sleeptime != 0 ) { sleep_milli(1); @@ -707,7 +709,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - fprintf(stderr,"%04x\n",c); + fprintf(stderr,"%04x score.%d level.%d\n",c,tg->score,tg->level); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From b8f944dfe9fa3dfdf03bde72e61f6a830b221682 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:32:24 -1100 Subject: [PATCH 3278/3904] Points --- src/cc/tetris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 3bf5b098a..97c35ecd9 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -709,7 +709,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - fprintf(stderr,"%04x score.%d level.%d\n",c,tg->score,tg->level); + fprintf(stderr,"%04x score.%d level.%d\n",c,tg->points,tg->level); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From d35bad65b5bc02bc60995acba09f88eb68ab079e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:35:18 -1100 Subject: [PATCH 3279/3904] Print --- src/cc/gamescc.cpp | 1 + src/cc/tetris.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 62d49c3dd..ce0b3e479 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -152,6 +152,7 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 } n = rs->playersize; free(rs); + fprintf(stderr,"score.%d level.%d\n",tg->points,tg->level); return(n); } diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 97c35ecd9..214145659 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -709,7 +709,7 @@ void *gamesiterate(struct games_state *rs) if ( skipcount == 0 ) { c = games_readevent(rs); - fprintf(stderr,"%04x score.%d level.%d\n",c,tg->points,tg->level); + //fprintf(stderr,"%04x score.%d level.%d\n",c,tg->points,tg->level); if ( (c & 0x4000) == 0x4000 ) { skipcount = (c & 0x3fff); From 4b555126d5c5ca1163a15d2203cd10e2c54ca134 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:36:15 -1100 Subject: [PATCH 3280/3904] Test --- src/cc/gamescc.cpp | 1 - src/cc/tetris.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ce0b3e479..62d49c3dd 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -152,7 +152,6 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 } n = rs->playersize; free(rs); - fprintf(stderr,"score.%d level.%d\n",tg->points,tg->level); return(n); } diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 214145659..0a613c0c9 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -18,6 +18,7 @@ int32_t tetrisdata(struct games_player *P,void *ptr) tetris_game *tg = (tetris_game *)ptr; P->gold = tg->points; P->dungeonlevel = tg->level; + fprintf(stderr,"score.%d level.%d\n",tg->points,tg->level); return(0); } From 91fcfefd16831bebce19239153294ed092222655 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:38:35 -1100 Subject: [PATCH 3281/3904] Test --- src/cc/tetris.c | 2 +- src/cc/tetris.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.c b/src/cc/tetris.c index 0a613c0c9..c507ec019 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -18,7 +18,7 @@ int32_t tetrisdata(struct games_player *P,void *ptr) tetris_game *tg = (tetris_game *)ptr; P->gold = tg->points; P->dungeonlevel = tg->level; - fprintf(stderr,"score.%d level.%d\n",tg->points,tg->level); + //fprintf(stderr,"score.%d level.%d\n",tg->points,tg->level); return(0); } diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index a461d139e..39e8f1a65 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -41,7 +41,7 @@ void tetrisplayerjson(UniValue &obj,struct games_player *P) int32_t disp_gamesplayer(char *str,struct games_player *P) { str[0] = 0; - if ( P->gold <= 0 || P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) + if ( P->gold <= 0 )//|| P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) return(-1); sprintf(str," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",P->gold,P->hitpoints,P->strength&0xffff,P->strength>>16,P->level,P->experience,P->dungeonlevel); return(0); From c2f90d6173669d602c7644c481508699b8695d5c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:41:47 -1100 Subject: [PATCH 3282/3904] Test --- src/cc/gamescc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 62d49c3dd..867c0a79b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -151,6 +151,7 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 free(ptr); } n = rs->playersize; + fprintf(stderr,"gold.%d\n",rs->P.gold); sleep(3); free(rs); return(n); } @@ -1374,7 +1375,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: fclose(fp); } } - //fprintf(stderr,"call replay2\n"); + fprintf(stderr,"call replay2\n"); num = games_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i Date: Tue, 26 Mar 2019 09:44:32 -1100 Subject: [PATCH 3283/3904] Test --- src/cc/gamescc.cpp | 2 +- src/cc/tetris.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 867c0a79b..698890c57 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1375,7 +1375,6 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: fclose(fp); } } - fprintf(stderr,"call replay2\n"); num = games_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i no playerdata\n"); diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 39e8f1a65..8a52dcb37 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -41,8 +41,8 @@ void tetrisplayerjson(UniValue &obj,struct games_player *P) int32_t disp_gamesplayer(char *str,struct games_player *P) { str[0] = 0; - if ( P->gold <= 0 )//|| P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) - return(-1); + //if ( P->gold <= 0 )//|| P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) + // return(-1); sprintf(str," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",P->gold,P->hitpoints,P->strength&0xffff,P->strength>>16,P->level,P->experience,P->dungeonlevel); return(0); } From 67ba7536bdbed814b00041266fadaea2f3b7fb32 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:47:04 -1100 Subject: [PATCH 3284/3904] Test --- src/cc/gamescc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 698890c57..2c5668253 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -146,12 +146,13 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 // extract data from ptr if ( GAMEDATA(&rs->P,ptr) < 0 ) memset(&rs->P,0,sizeof(rs->P)); - else if ( newdata != 0 && rs->playersize > 0 ) + else rs->playersize = sizeof(rs->P); + if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); free(ptr); } n = rs->playersize; - fprintf(stderr,"gold.%d\n",rs->P.gold); sleep(3); + //fprintf(stderr,"gold.%d\n",rs->P.gold); sleep(3); free(rs); return(n); } From a43f0b65d4535cfd24f1db97547b7d954789d45b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:50:16 -1100 Subject: [PATCH 3285/3904] Test --- src/cc/dapps/dappstd.c | 2 +- src/cc/tetris.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 925b8749a..917045ed5 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -862,7 +862,7 @@ int32_t flushkeystrokes(struct games_state *rs,int32_t waitflag) return(0); } -void games_bailout(struct games_state *rs) +void gamesbailout(struct games_state *rs) { flushkeystrokes(rs,1); } diff --git a/src/cc/tetris.c b/src/cc/tetris.c index c507ec019..cb89c0da0 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -651,7 +651,7 @@ gamesevent games_readevent(struct games_state *rs); void *gamesiterate(struct games_state *rs) { uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; - gamesevent c; uint16_t skipcount=0; uint32_t eventid = 0; tetris_game *tg; + gamesevent c; uint16_t skipcount=0; int32_t prevlevel; uint32_t eventid = 0; tetris_game *tg; WINDOW *board, *next, *hold, *score; if ( rs->guiflag != 0 || rs->sleeptime != 0 ) { @@ -665,6 +665,7 @@ void *gamesiterate(struct games_state *rs) init_colors(); // setup tetris colors } tg = tg_create(rs,22, 10); + prevlevel = tg->level; // Create windows for each section of the interface. board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); @@ -693,6 +694,11 @@ void *gamesiterate(struct games_state *rs) issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x4000); if ( c <= 0x7f ) issue_games_events(rs,Gametxidstr,eventid,c); + if ( tg->level != prevlevel ) + { + flushkeystrokes(rs,0); + prevlevel = tg->level; + } skipcount = 0; } else skipcount++; #endif @@ -870,7 +876,7 @@ int tetris(int argc, char **argv) // Game loop tg = (tetris_game *)gamesiterate(rs); - games_bailout(rs); + gamesbailout(rs); // Deinitialize NCurses wclear(stdscr); endwin(); From 8660a2eedc523474c9d47fe342c4389892b593b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:51:32 -1100 Subject: [PATCH 3286/3904] -print --- src/cc/gamescc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 2c5668253..3e12a7010 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -146,9 +146,12 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 // extract data from ptr if ( GAMEDATA(&rs->P,ptr) < 0 ) memset(&rs->P,0,sizeof(rs->P)); - else rs->playersize = sizeof(rs->P); - if ( newdata != 0 && rs->playersize > 0 ) - memcpy(newdata,rs->playerdata,rs->playersize); + else + { + rs->playersize = sizeof(rs->P); + if ( newdata != 0 ) + memcpy(newdata,&rs->P,rs->playersize); + } free(ptr); } n = rs->playersize; @@ -1383,7 +1386,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std: newdata[i] = newplayer[i]; ((uint8_t *)&endP)[i] = newplayer[i]; } - fprintf(stderr,"newgold.%d\n",endP.gold); sleep(3); + //fprintf(stderr,"newgold.%d\n",endP.gold); sleep(3); if ( disp_gamesplayer(str,&endP) < 0 ) { sprintf(str,"zero value character -> no playerdata\n"); From 8a7a1da70f3773317c9e370d90e8957c0fc1e04b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 09:52:15 -1100 Subject: [PATCH 3287/3904] int32_t flushkeystrokes(struct games_state *rs,int32_t waitflag) --- src/cc/tetris.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/tetris.h b/src/cc/tetris.h index 9d16a8e8b..c4cfb3b31 100644 --- a/src/cc/tetris.h +++ b/src/cc/tetris.h @@ -196,6 +196,7 @@ struct games_state }; extern struct games_state globalR; void *gamesiterate(struct games_state *rs); +int32_t flushkeystrokes(struct games_state *rs,int32_t waitflag); void games_packitemstr(char *packitemstr,struct games_packitem *item); uint64_t _games_rngnext(uint64_t initseed); From 2e8573c0ec888a33a90abfd2a2cc72d311fde2d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 19:59:13 -1100 Subject: [PATCH 3288/3904] Fix rogue compile --- src/cc/gamescc.cpp | 13 +++---------- src/cc/rogue_rpc.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 3e12a7010..4e8660c18 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1510,15 +1510,8 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,ch result.push_back(Pair("method",method)); result.push_back(Pair("mygamesaddr",mygamesaddr)); if ( strcmp(method,"bailout") == 0 ) - { funcid = 'Q'; - //mult = 10; //100000; - } - else - { - funcid = 'H'; - //mult = 20; //200000; - } + else funcid = 'H'; if ( params != 0 && (n= cJSON_GetArraySize(params)) > 0 ) { if ( n > 0 ) @@ -1570,13 +1563,13 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,ch fprintf(stderr,"\ncashout %.8f extracted %s\n",(double)cashout/COIN,str); if ( funcid == 'H' && maxplayers > 1 ) { - if ( P.amulet == 0 ) + /*if ( P.amulet == 0 ) { if ( numplayers != maxplayers ) return(cclib_error(result,"numplayers != maxplayers")); else if ( games_playersalive(tmp,tmp,gametxid,maxplayers,gameheight,gametx) > 1 ) return(cclib_error(result,"highlander must be a winner or last one standing")); - } + }*/ cashout += games_buyins(gametxid,maxplayers);//numplayers * buyin; } if ( cashout > 0 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4b74e21b7..52323adbe 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -283,7 +283,7 @@ int32_t rogue_iamregistered(int32_t maxplayers,uint256 gametxid,CTransaction tx, return(0); } -int64_t rogue_buyins(uint256 gametxid) +int64_t rogue_buyins(uint256 gametxid,int32_t maxplayers) { int32_t i,vout; uint256 spenttxid,hashBlock; CTransaction spenttx; int64_t buyins = 0; for (i=0; iamulet != 0 ) mult *= 5; dungeonlevel = P->dungeonlevel; @@ -1618,7 +1618,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( funcid == 'H' ) { cashout *= 2; - cashout += rogue_buyins(gametxid); + cashout += rogue_buyins(gametxid,maxplayers); } sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) From 58215af9b0d138c1a0b87351958ec22541ae8ee4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 21:48:44 -1100 Subject: [PATCH 3289/3904] Make 4 cc libs --- src/cc/makecclib | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/makecclib b/src/cc/makecclib index adac757c3..3aded32e3 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,2 +1,8 @@ #!/bin/sh gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp + +gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp + +gcc -O3 -DBUILD_ROGUE -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o roguecc.so cclib.cpp + +gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp From 906cc5ccb4cd5e4aa9a059af87a78515ae5c683c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 21:49:59 -1100 Subject: [PATCH 3290/3904] -print --- src/cc/gamescc.cpp | 2 +- src/cc/tetris.c | 45 ++++++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 4e8660c18..38396562e 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -546,7 +546,7 @@ void komodo_netevent(std::vector message) { if ( (rand() % 10) == 0 ) { - fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); + //fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); komodo_sendmessage(2,2,"events",message); } } diff --git a/src/cc/tetris.c b/src/cc/tetris.c index cb89c0da0..651b1018c 100644 --- a/src/cc/tetris.c +++ b/src/cc/tetris.c @@ -801,32 +801,35 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve if ( fp == 0 ) fp = fopen("events.log","wb"); rs->buffered[rs->num++] = c; - if ( sizeof(c) == 1 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); - else if ( sizeof(c) == 2 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); - else if ( sizeof(c) == 4 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); - else if ( sizeof(c) == 8 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + if ( 0 ) { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) + if ( sizeof(c) == 1 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + else if ( sizeof(c) == 2 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + else if ( sizeof(c) == 4 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + else if ( sizeof(c) == 8 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { - if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - retval = 0; - if ( fp != 0 ) + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) { - fprintf(fp,"%s\n",jprint(resobj,0)); - fflush(fp); + retval = 0; + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } } - } - free_json(retjson); - } else fprintf(fp,"error parsing %s\n",retstr); - free(retstr); - } else fprintf(fp,"error issuing method %s\n",params); - return(retval); + free_json(retjson); + } else fprintf(fp,"error parsing %s\n",retstr); + free(retstr); + } else fprintf(fp,"error issuing method %s\n",params); + return(retval); + } else return(0); } int tetris(int argc, char **argv) From 3da4f521dc060c6a0275b4c9ff49f9aeeb74f5e8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 21:50:51 -1100 Subject: [PATCH 3291/3904] Add apps to makecclib --- src/cc/makecclib | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/makecclib b/src/cc/makecclib index 3aded32e3..d9a5f2a82 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -6,3 +6,6 @@ gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include gcc -O3 -DBUILD_ROGUE -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o roguecc.so cclib.cpp gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp + +./maketetris +make -f Makefile_rogue From 1e6630620c9db3ae2cd34cbf5fc6a721cba9b499 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 21:52:41 -1100 Subject: [PATCH 3292/3904] Fix --- src/cc/makecclib | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index d9a5f2a82..8db8514cd 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -8,4 +8,5 @@ gcc -O3 -DBUILD_ROGUE -std=c++11 -I../secp256k1/include -I../univalue/include -I gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp ./maketetris -make -f Makefile_rogue + +cd rogue; make; cd .. From 8a208a02c794571f8a65829c3c718a2626345b8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 21:54:08 -1100 Subject: [PATCH 3293/3904] Make rogue --- src/cc/makecclib | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 8db8514cd..e64934d31 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -8,5 +8,4 @@ gcc -O3 -DBUILD_ROGUE -std=c++11 -I../secp256k1/include -I../univalue/include -I gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp ./maketetris - -cd rogue; make; cd .. +./makerogue From 119decca6f464a9b4ecc22b8188593e4242338a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 21:56:35 -1100 Subject: [PATCH 3294/3904] Fix --- src/cc/makecclib | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index e64934d31..6a1908829 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,11 +1,12 @@ #!/bin/sh +rm *.so rogue/rogue tetris + gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp - -gcc -O3 -DBUILD_ROGUE -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o roguecc.so cclib.cpp +./maketetris gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp -./maketetris +make -f Makefile_rogue ./makerogue From 329b7437640fcb17908a861525c2bb075cca5693 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 22:02:53 -1100 Subject: [PATCH 3295/3904] +prints --- src/cc/makecclib | 9 +++++++-- src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 6a1908829..35b4a9d8d 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,12 +1,17 @@ #!/bin/sh rm *.so rogue/rogue tetris +echo rogue +make -f Makefile_rogue +./makerogue + +echo sudoku/musig/dilithium gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +echo games tetris gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp ./maketetris +echo customcc stub gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp -make -f Makefile_rogue -./makerogue diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 52323adbe..5040c34d3 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1341,12 +1341,12 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - return(rogue_finishgame(txfee,cp,params,"bailout")); + return(rogue_finishgame(txfee,cp,params,(char *)"bailout")); } UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - return(rogue_finishgame(txfee,cp,params,"highlander")); + return(rogue_finishgame(txfee,cp,params,(char *)"highlander")); } UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) From 3640e3c4fcb67981ca8c440fb72a9dc2ecc5608a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 22:28:18 -1100 Subject: [PATCH 3296/3904] Prices example --- src/cc/gamescc.cpp | 13 +- src/cc/makecclib | 4 + src/cc/prices.c | 896 +++++++++++++++++++++++++++++++++++++++++++++ src/cc/prices.cpp | 463 +++-------------------- src/cc/prices.h | 208 +++++++++++ 5 files changed, 1159 insertions(+), 425 deletions(-) create mode 100644 src/cc/prices.c create mode 100644 src/cc/prices.h diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 38396562e..f010ac282 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -14,7 +14,11 @@ ******************************************************************************/ #include "gamescc.h" -#include "tetris.c" // replace with game code +#ifdef BUILD_PRICES +#include "prices.c" +#elif +#include "tetris.c" +#endif int32_t GAMEDATA(struct games_player *P,void *ptr); @@ -161,8 +165,11 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 } #ifndef STANDALONE - -#include "tetris.cpp" // replace with game specific functions +#ifdef BUILD_PRICES +#include "prices.cpp" +#elif +#include "tetris.cpp" +#endif void GAMEJSON(UniValue &obj,struct games_player *P); diff --git a/src/cc/makecclib b/src/cc/makecclib index 35b4a9d8d..38634aa78 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -12,6 +12,10 @@ echo games tetris gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp ./maketetris +echo games prices +gcc -O3 -DBUILD_GAMESCC -DBUILD_PRICES -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o pricescc.so cclib.cpp +./makeprices + echo customcc stub gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp diff --git a/src/cc/prices.c b/src/cc/prices.c new file mode 100644 index 000000000..651b1018c --- /dev/null +++ b/src/cc/prices.c @@ -0,0 +1,896 @@ + +#include "tetris.h" + +/* + In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. + + also, the standalone game needs to support argv of seed gametxid, along with replay args + */ + +int random_tetromino(struct games_state *rs) +{ + rs->seed = _games_rngnext(rs->seed); + return(rs->seed % NUM_TETROMINOS); +} + +int32_t tetrisdata(struct games_player *P,void *ptr) +{ + tetris_game *tg = (tetris_game *)ptr; + P->gold = tg->points; + P->dungeonlevel = tg->level; + //fprintf(stderr,"score.%d level.%d\n",tg->points,tg->level); + return(0); +} + +/***************************************************************************/ +/** https://github.com/brenns10/tetris + @file main.c + @author Stephen Brennan + @date Created Wednesday, 10 June 2015 + @brief Main program for tetris. + @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised + BSD License. See LICENSE.txt for details. + *******************************************************************************/ + + +#include // for FILE +#include // for bool +#include +#include +#include +#include +#include +#include + +#ifdef BUILD_GAMESCC +#include "rogue/cursesd.h" +#else +#include +#endif + + +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) + +/******************************************************************************* + Array Definitions + *******************************************************************************/ + +const tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS] = +{ + // I + {{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, + {{0, 2}, {1, 2}, {2, 2}, {3, 2}}, + {{3, 0}, {3, 1}, {3, 2}, {3, 3}}, + {{0, 1}, {1, 1}, {2, 1}, {3, 1}}}, + // J + {{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, + {{0, 1}, {1, 1}, {2, 0}, {2, 1}}}, + // L + {{{0, 2}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, + {{0, 0}, {0, 1}, {1, 1}, {2, 1}}}, + // O + {{{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, + {{0, 1}, {0, 2}, {1, 1}, {1, 2}}}, + // S + {{{0, 1}, {0, 2}, {1, 0}, {1, 1}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 2}}, + {{1, 1}, {1, 2}, {2, 0}, {2, 1}}, + {{0, 0}, {1, 0}, {1, 1}, {2, 1}}}, + // T + {{{0, 1}, {1, 0}, {1, 1}, {1, 2}}, + {{0, 1}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {1, 2}, {2, 1}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 1}}}, + // Z + {{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, + {{0, 2}, {1, 1}, {1, 2}, {2, 1}}, + {{1, 0}, {1, 1}, {2, 1}, {2, 2}}, + {{0, 1}, {1, 0}, {1, 1}, {2, 0}}}, +}; + +const int GRAVITY_LEVEL[MAX_LEVEL+1] = { + // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + //10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 30, 28, 26, 24, 22, 20, 16, 12, 8, 4 +}; + +/******************************************************************************* + Helper Functions for Blocks + *******************************************************************************/ + +void sleep_milli(int milliseconds) +{ + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = milliseconds * 1000 * 1000; + nanosleep(&ts, NULL); +} + +/* + Return the block at the given row and column. + */ +char tg_get(tetris_game *obj, int row, int column) +{ + return obj->board[obj->cols * row + column]; +} + +/* + Set the block at the given row and column. + */ +static void tg_set(tetris_game *obj, int row, int column, char value) +{ + obj->board[obj->cols * row + column] = value; +} + +/* + Check whether a row and column are in bounds. + */ +bool tg_check(tetris_game *obj, int row, int col) +{ + return 0 <= row && row < obj->rows && 0 <= col && col < obj->cols; +} + +/* + Place a block onto the board. + */ +static void tg_put(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, + TYPE_TO_CELL(block.typ)); + } +} + +/* + Clear a block out of the board. + */ +static void tg_remove(tetris_game *obj, tetris_block block) +{ + int i; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, TC_EMPTY); + } +} + +/* + Check if a block can be placed on the board. + */ +static bool tg_fits(tetris_game *obj, tetris_block block) +{ + int i, r, c; + for (i = 0; i < TETRIS; i++) { + tetris_location cell = TETROMINOS[block.typ][block.ori][i]; + r = block.loc.row + cell.row; + c = block.loc.col + cell.col; + if (!tg_check(obj, r, c) || TC_IS_FILLED(tg_get(obj, r, c))) { + return false; + } + } + return true; +} + +/* + Create a new falling block and populate the next falling block with a random + one. + */ +static void tg_new_falling(struct games_state *rs,tetris_game *obj) +{ + // Put in a new falling tetromino. + obj->falling = obj->next; + obj->next.typ = random_tetromino(rs); + obj->next.ori = 0; + obj->next.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; +} + +/******************************************************************************* + Game Turn Helpers + *******************************************************************************/ + +/* + Tick gravity, and move the block down if gravity should act. + */ +static void tg_do_gravity_tick(struct games_state *rs,tetris_game *obj) +{ + obj->ticks_till_gravity--; + if (obj->ticks_till_gravity <= 0) { + tg_remove(obj, obj->falling); + obj->falling.loc.row++; + if (tg_fits(obj, obj->falling)) { + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + } else { + obj->falling.loc.row--; + tg_put(obj, obj->falling); + + tg_new_falling(rs,obj); + } + tg_put(obj, obj->falling); + } +} + +/* + Move the falling tetris block left (-1) or right (+1). + */ +static void tg_move(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + obj->falling.loc.col += direction; + if (!tg_fits(obj, obj->falling)) { + obj->falling.loc.col -= direction; + } + tg_put(obj, obj->falling); +} + +/* + Send the falling tetris block to the bottom. + */ +static void tg_down(struct games_state *rs,tetris_game *obj) +{ + tg_remove(obj, obj->falling); + while (tg_fits(obj, obj->falling)) { + obj->falling.loc.row++; + } + obj->falling.loc.row--; + tg_put(obj, obj->falling); + tg_new_falling(rs,obj); +} + +/* + Rotate the falling block in either direction (+/-1). + */ +static void tg_rotate(tetris_game *obj, int direction) +{ + tg_remove(obj, obj->falling); + + while (true) { + obj->falling.ori = (obj->falling.ori + direction) % NUM_ORIENTATIONS; + + // If the new orientation fits, we're done. + if (tg_fits(obj, obj->falling)) + break; + + // Otherwise, try moving left to make it fit. + obj->falling.loc.col--; + if (tg_fits(obj, obj->falling)) + break; + + // Finally, try moving right to make it fit. + obj->falling.loc.col += 2; + if (tg_fits(obj, obj->falling)) + break; + + // Put it back in its original location and try the next orientation. + obj->falling.loc.col--; + // Worst case, we come back to the original orientation and it fits, so this + // loop will terminate. + } + + tg_put(obj, obj->falling); +} + +/* + Swap the falling block with the block in the hold buffer. + */ +static void tg_hold(struct games_state *rs,tetris_game *obj) +{ + tg_remove(obj, obj->falling); + if (obj->stored.typ == -1) { + obj->stored = obj->falling; + tg_new_falling(rs,obj); + } else { + int typ = obj->falling.typ, ori = obj->falling.ori; + obj->falling.typ = obj->stored.typ; + obj->falling.ori = obj->stored.ori; + obj->stored.typ = typ; + obj->stored.ori = ori; + while (!tg_fits(obj, obj->falling)) { + obj->falling.loc.row--; + } + } + tg_put(obj, obj->falling); +} + +/* + Perform the action specified by the move. + */ +static void tg_handle_move(struct games_state *rs,tetris_game *obj, tetris_move move) +{ + switch (move) { + case TM_LEFT: + //fprintf(stderr,"LEFT "); + tg_move(obj, -1); + break; + case TM_RIGHT: + //fprintf(stderr,"RIGHT "); + tg_move(obj, 1); + break; + case TM_DROP: + tg_down(rs,obj); + break; + case TM_CLOCK: + tg_rotate(obj, 1); + break; + case TM_COUNTER: + tg_rotate(obj, -1); + break; + case TM_HOLD: + tg_hold(rs,obj); + break; + default: + // pass + break; + } +} + +/* + Return true if line i is full. + */ +static bool tg_line_full(tetris_game *obj, int i) +{ + int j; + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) + return false; + } + return true; +} + +/* + Shift every row above r down one. + */ +static void tg_shift_lines(tetris_game *obj, int r) +{ + int i, j; + for (i = r-1; i >= 0; i--) { + for (j = 0; j < obj->cols; j++) { + tg_set(obj, i+1, j, tg_get(obj, i, j)); + tg_set(obj, i, j, TC_EMPTY); + } + } +} + +/* + Find rows that are filled, remove them, shift, and return the number of + cleared rows. + */ +static int tg_check_lines(tetris_game *obj) +{ + int i, nlines = 0; + tg_remove(obj, obj->falling); // don't want to mess up falling block + + for (i = obj->rows-1; i >= 0; i--) { + if (tg_line_full(obj, i)) { + tg_shift_lines(obj, i); + i++; // do this line over again since they're shifted + nlines++; + } + } + + tg_put(obj, obj->falling); // replace + return nlines; +} + +/* + Adjust the score for the game, given how many lines were just cleared. + */ +static void tg_adjust_score(tetris_game *obj, int lines_cleared) +{ + static int line_multiplier[] = {0, 40, 100, 300, 1200}; + obj->points += line_multiplier[lines_cleared] * (obj->level + 1); + if (lines_cleared >= obj->lines_remaining) { + obj->level = MIN(MAX_LEVEL, obj->level + 1); + lines_cleared -= obj->lines_remaining; + obj->lines_remaining = LINES_PER_LEVEL - lines_cleared; + } else { + obj->lines_remaining -= lines_cleared; + } +} + +/* + Return true if the game is over. + */ +static bool tg_game_over(tetris_game *obj) +{ + int i, j; + bool over = false; + tg_remove(obj, obj->falling); + for (i = 0; i < 2; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + over = true; + } + } + } + tg_put(obj, obj->falling); + return over; +} + +/******************************************************************************* + Main Public Functions + *******************************************************************************/ + +/* + Do a single game tick: process gravity, user input, and score. Return true if + the game is still running, false if it is over. + */ +bool tg_tick(struct games_state *rs,tetris_game *obj, tetris_move move) +{ + int lines_cleared; + // Handle gravity. + tg_do_gravity_tick(rs,obj); + + // Handle input. + tg_handle_move(rs,obj, move); + + // Check for cleared lines + lines_cleared = tg_check_lines(obj); + + tg_adjust_score(obj, lines_cleared); + + // Return whether the game will continue (NOT whether it's over) + return !tg_game_over(obj); +} + +void tg_init(struct games_state *rs,tetris_game *obj, int rows, int cols) +{ + // Initialization logic + obj->rows = rows; + obj->cols = cols; + //obj->board = (char *)malloc(rows * cols); + memset(obj->board, TC_EMPTY, rows * cols); + obj->points = 0; + obj->level = 0; + obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; + obj->lines_remaining = LINES_PER_LEVEL; + //srand(time(NULL)); + tg_new_falling(rs,obj); + tg_new_falling(rs,obj); + obj->stored.typ = -1; + obj->stored.ori = 0; + obj->stored.loc.row = 0; + obj->next.loc.col = obj->cols/2 - 2; + //printf("%d", obj->falling.loc.col); +} + +tetris_game *tg_create(struct games_state *rs,int rows, int cols) +{ + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game) + rows*cols); + tg_init(rs,obj, rows, cols); + return obj; +} + +/*void tg_destroy(tetris_game *obj) +{ + // Cleanup logic + free(obj->board); +}*/ + +void tg_delete(tetris_game *obj) { + //tg_destroy(obj); + free(obj); +} + +/* + Load a game from a file. + +tetris_game *tg_load(FILE *f) +{ + tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); + if (fread(obj, sizeof(tetris_game), 1, f) != 1 ) + { + fprintf(stderr,"read game error\n"); + free(obj); + obj = 0; + } + else + { + obj->board = (char *)malloc(obj->rows * obj->cols); + if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + { + fprintf(stderr,"fread error\n"); + free(obj->board); + free(obj); + obj = 0; + } + } + return obj; +}*/ + +/* + Save a game to a file. + +void tg_save(tetris_game *obj, FILE *f) +{ + if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) + fprintf(stderr,"error writing tetrisgame\n"); + else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + fprintf(stderr,"error writing board\n"); +}*/ + +/* + Print a game board to a file. Really just for early debugging. + */ +void tg_print(tetris_game *obj, FILE *f) { + int i, j; + for (i = 0; i < obj->rows; i++) { + for (j = 0; j < obj->cols; j++) { + if (TC_IS_EMPTY(tg_get(obj, i, j))) { + fputs(TC_EMPTY_STR, f); + } else { + fputs(TC_BLOCK_STR, f); + } + } + fputc('\n', f); + } +} + +/* + 2 columns per cell makes the game much nicer. + */ +#define COLS_PER_CELL 2 +/* + Macro to print a cell of a specific type to a window. + */ +#define ADD_BLOCK(w,x) waddch((w),' '|A_REVERSE|COLOR_PAIR(x)); \ +waddch((w),' '|A_REVERSE|COLOR_PAIR(x)) +#define ADD_EMPTY(w) waddch((w), ' '); waddch((w), ' ') + +/* + Print the tetris board onto the ncurses window. + */ +void display_board(WINDOW *w, tetris_game *obj) +{ + int i, j; + box(w, 0, 0); + for (i = 0; i < obj->rows; i++) { + wmove(w, 1 + i, 1); + for (j = 0; j < obj->cols; j++) { + if (TC_IS_FILLED(tg_get(obj, i, j))) { + ADD_BLOCK(w,tg_get(obj, i, j)); + } else { + ADD_EMPTY(w); + } + } + } + wnoutrefresh(w); +} + +/* + Display a tetris piece in a dedicated window. + */ +void display_piece(WINDOW *w, tetris_block block) +{ + int b; + tetris_location c; + wclear(w); + box(w, 0, 0); + if (block.typ == -1) { + wnoutrefresh(w); + return; + } + for (b = 0; b < TETRIS; b++) { + c = TETROMINOS[block.typ][block.ori][b]; + wmove(w, c.row + 1, c.col * COLS_PER_CELL + 1); + ADD_BLOCK(w, TYPE_TO_CELL(block.typ)); + } + wnoutrefresh(w); +} + +/* + Display score information in a dedicated window. + */ +void display_score(WINDOW *w, tetris_game *tg) +{ + wclear(w); + box(w, 0, 0); + wprintw(w, (char *)"Score\n%d\n", tg->points); + wprintw(w, (char *)"Level\n%d\n", tg->level); + wprintw(w, (char *)"Lines\n%d\n", tg->lines_remaining); + wnoutrefresh(w); +} + +/* + Save and exit the game. + +void save(tetris_game *game, WINDOW *w) +{ + FILE *f; + + wclear(w); + box(w, 0, 0); // return the border + wmove(w, 1, 1); + wprintw(w, (char *)"Save and exit? [Y/n] "); + wrefresh(w); + timeout(-1); + if (getch() == 'n') { + timeout(0); + return; + } + f = fopen("tetris.save", "w"); + tg_save(game, f); + fclose(f); + tg_delete(game); + endwin(); + fprintf(stderr,"Game saved to \"tetris.save\".\n"); + fprintf(stderr,"Resume by passing the filename as an argument to this program.\n"); + exit(EXIT_SUCCESS); +}*/ + +/* + Do the NCURSES initialization steps for color blocks. + */ +void init_colors(void) +{ + start_color(); + //init_color(COLOR_ORANGE, 1000, 647, 0); + init_pair(TC_CELLI, COLOR_CYAN, COLOR_BLACK); + init_pair(TC_CELLJ, COLOR_BLUE, COLOR_BLACK); + init_pair(TC_CELLL, COLOR_WHITE, COLOR_BLACK); + init_pair(TC_CELLO, COLOR_YELLOW, COLOR_BLACK); + init_pair(TC_CELLS, COLOR_GREEN, COLOR_BLACK); + init_pair(TC_CELLT, COLOR_MAGENTA, COLOR_BLACK); + init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); +} + +struct games_state globalR; +extern char Gametxidstr[]; +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c); +gamesevent games_readevent(struct games_state *rs); + +void *gamesiterate(struct games_state *rs) +{ + uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; + gamesevent c; uint16_t skipcount=0; int32_t prevlevel; uint32_t eventid = 0; tetris_game *tg; + WINDOW *board, *next, *hold, *score; + if ( rs->guiflag != 0 || rs->sleeptime != 0 ) + { + // NCURSES initialization: + initscr(); // initialize curses + cbreak(); // pass key presses to program, but not signals + noecho(); // don't echo key presses to screen + keypad(stdscr, TRUE); // allow arrow keys + timeout(0); // no blocking on getch() + curs_set(0); // set the cursor to invisible + init_colors(); // setup tetris colors + } + tg = tg_create(rs,22, 10); + prevlevel = tg->level; + // Create windows for each section of the interface. + board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); + next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); + hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); + score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); + while ( running != 0 ) + { + running = tg_tick(rs,tg,move); + if ( 1 && (rs->guiflag != 0 || rs->sleeptime != 0) ) + { + display_board(board,tg); + display_piece(next,tg->next); + display_piece(hold,tg->stored); + display_score(score,tg); + } + if ( rs->guiflag != 0 ) + { +#ifdef STANDALONE + sleep_milli(15); + if ( (counter++ % 10) == 0 ) + doupdate(); + c = games_readevent(rs); + if ( c <= 0x7f || skipcount == 0x3fff ) + { + if ( skipcount > 0 ) + issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x4000); + if ( c <= 0x7f ) + issue_games_events(rs,Gametxidstr,eventid,c); + if ( tg->level != prevlevel ) + { + flushkeystrokes(rs,0); + prevlevel = tg->level; + } + skipcount = 0; + } else skipcount++; +#endif + } + else + { + if ( rs->replaydone != 0 ) + break; + if ( rs->sleeptime != 0 ) + { + sleep_milli(1); + if ( (counter++ % 20) == 0 ) + doupdate(); + } + if ( skipcount == 0 ) + { + c = games_readevent(rs); + //fprintf(stderr,"%04x score.%d level.%d\n",c,tg->points,tg->level); + if ( (c & 0x4000) == 0x4000 ) + { + skipcount = (c & 0x3fff); + c = 'S'; + } + } + if ( skipcount > 0 ) + skipcount--; + } + eventid++; + switch ( c ) + { + case 'h': + move = TM_LEFT; + break; + case 'l': + move = TM_RIGHT; + break; + case 'k': + move = TM_CLOCK; + break; + case 'j': + move = TM_DROP; + break; + case 'q': + running = false; + move = TM_NONE; + break; + /*case 'p': + wclear(board); + box(board, 0, 0); + wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); + wprintw(board, "PAUSED"); + wrefresh(board); + timeout(-1); + getch(); + timeout(0); + move = TM_NONE; + break; + case 's': + save(tg, board); + move = TM_NONE; + break;*/ + case ' ': + move = TM_HOLD; + break; + default: + move = TM_NONE; + } + } + return(tg); +} + +#ifdef STANDALONE +/* + Main tetris game! + */ +#include "dapps/dappstd.c" + + +char *clonestr(char *str) +{ + char *clone; int32_t len; + if ( str == 0 || str[0] == 0 ) + { + printf("warning cloning nullstr.%p\n",str); +#ifdef __APPLE__ + while ( 1 ) sleep(1); +#endif + str = (char *)""; + } + len = strlen(str); + clone = (char *)calloc(1,len+16); + strcpy(clone,str); + return(clone); +} + +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c) +{ + static FILE *fp; + char params[512],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; + if ( fp == 0 ) + fp = fopen("events.log","wb"); + rs->buffered[rs->num++] = c; + if ( 0 ) + { + if ( sizeof(c) == 1 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + else if ( sizeof(c) == 2 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + else if ( sizeof(c) == 4 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + else if ( sizeof(c) == 8 ) + sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + retval = 0; + if ( fp != 0 ) + { + fprintf(fp,"%s\n",jprint(resobj,0)); + fflush(fp); + } + } + free_json(retjson); + } else fprintf(fp,"error parsing %s\n",retstr); + free(retstr); + } else fprintf(fp,"error issuing method %s\n",params); + return(retval); + } else return(0); +} + +int tetris(int argc, char **argv) +{ + struct games_state *rs = &globalR; + int32_t c,skipcount=0; uint32_t eventid = 0; tetris_game *tg = 0; + memset(rs,0,sizeof(*rs)); + rs->guiflag = 1; + rs->sleeptime = 1; // non-zero to allow refresh() + if ( argc >= 2 && strlen(argv[2]) == 64 ) + { +#ifdef _WIN32 +#ifdef _MSC_VER + rs->origseed = _strtoui64(argv[1], NULL, 10); +#else + rs->origseed = atol(argv[1]); // windows, but not MSVC +#endif // _MSC_VER +#else + rs->origseed = atol(argv[1]); // non-windows +#endif // _WIN32 + rs->seed = rs->origseed; + if ( argc >= 3 ) + { + strcpy(Gametxidstr,argv[2]); + fprintf(stderr,"setplayerdata %s\n",Gametxidstr); + if ( games_setplayerdata(rs,Gametxidstr) < 0 ) + { + fprintf(stderr,"invalid gametxid, or already started\n"); + return(-1); + } + } + } else rs->seed = 777; + + /* Load file if given a filename. + if (argc >= 2) { + FILE *f = fopen(argv[1], "r"); + if (f == NULL) { + perror("tetris"); + exit(EXIT_FAILURE); + } + tg = tg_load(f); + fclose(f); + } else { + // Otherwise create new game. + tg = tg_create(rs,22, 10); + }*/ + + // Game loop + tg = (tetris_game *)gamesiterate(rs); + gamesbailout(rs); + // Deinitialize NCurses + wclear(stdscr); + endwin(); + // Output ending message. + printf("Game over!\n"); + printf("You finished with %d points on level %d.\n", tg->points, tg->level); + + // Deinitialize Tetris + tg_delete(tg); + return 0; +} + +#endif + diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index c53207562..8a52dcb37 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -1,3 +1,4 @@ + /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -13,442 +14,60 @@ * * ******************************************************************************/ -#include "CCassets.h" -#include "CCPrices.h" - -/* - Prices CC would best build on top of the oracles CC, ie. to combine payments for multiple oracles and to calculate a 51% protected price feed. - - We need to assume there is an oracle for a specific price. In the event there are more than one provider, the majority need to be within correlation distance to update a pricepoint. - - int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format); - - Using the above function, a consensus price can be obtained for a datasource. - - given an oracletxid, the marketaddr and format can be extracted to be used for future calls to OraclePrice. This allows to set a starting price and that in turn allows cash settled leveraged trading! - - Funds work like with dice, ie. there is a Prices plan that traders bet against. - - PricesFunding oracletxid, margin, priceaveraging, maxleverage, funding, longtoken, shorttoken, N [pubkeys] - - PricesBet -> oracletxid start with 'L', leverage, funding, direction - funds are locked into global CC address - it can be closed at anytime by the trader for cash settlement - the house account can close it if rekt - - Implementation Notes: - In order to eliminate the need for worrying about sybil attacks, each prices plan would be able to specific pubkey(s?) for whitelisted publishers. It would be possible to have a non-whitelisted plan that would use 50% correlation between publishers. - - delta neutral balancing of riskexposure: fabs(long exposure - short exposure) - bet +B at leverage L - absval(sum(+BLi) - sum(-Bli)) - - validate: update riskexposure and it needs to be <= funds - - PricesProfits: limit withdraw to funds in excess of riskexposure - PricesFinish: payout (if winning) and update riskexposure - need long/short exposure assets - - funding -> 1of2 CC global CC address and dealer address, exposure tokens to global 1of2 assets CC address - pricebet -> user funds and exposure token to 1of2 address. - pricewin -> winnings from dealer funds, exposure token back to global address - priceloss -> exposuretoken back to global address - - exposure address, funds address - - - -*/ - -// start of consensus code - -int64_t PricesOraclePrice(int64_t &rektprice,uint64_t mode,uint256 oracletxid,std::vectorpubkeys,int32_t dir,int64_t amount,int32_t leverage) +// game specific code for daemon +void games_packitemstr(char *packitemstr,struct games_packitem *item) { - int64_t price; - // howto ensure price when block it confirms it not known - // get price from oracle + current chaintip - // normalize leveraged amount - if ( dir > 0 ) - rektprice = price * leverage / (leverage-1); - else rektprice = price * (leverage-1) / leverage; - return(price); + strcpy(packitemstr,""); } -CScript EncodePricesFundingOpRet(uint8_t funcid,CPubKey planpk,uint256 oracletxid,uint256 longtoken,uint256 shorttoken,int32_t millimargin,uint64_t mode,int32_t maxleverage,std::vector pubkeys,uint256 bettoken) +int64_t games_cashout(struct games_player *P) { - CScript opret; - fprintf(stderr,"implement EncodePricesFundingOpRet\n"); - return(opret); + int32_t dungeonlevel = P->dungeonlevel; int64_t mult=1000,cashout = 0; + cashout = (uint64_t)P->gold * mult * dungeonlevel * dungeonlevel; + return(cashout); } -uint8_t DecodePricesFundingOpRet(CScript scriptPubKey,CPubKey &planpk,uint256 &oracletxid,uint256 &longtoken,uint256 &shorttoken,int32_t &millimargin,uint64_t &mode,int32_t &maxleverage,std::vector &pubkeys,uint256 &bettoken) +void tetrisplayerjson(UniValue &obj,struct games_player *P) { - fprintf(stderr,"implement DecodePricesFundingOpRet\n"); + obj.push_back(Pair("packsize",(int64_t)P->packsize)); + obj.push_back(Pair("hitpoints",(int64_t)P->hitpoints)); + obj.push_back(Pair("strength",(int64_t)(P->strength&0xffff))); + obj.push_back(Pair("maxstrength",(int64_t)(P->strength>>16))); + obj.push_back(Pair("level",(int64_t)P->level)); + obj.push_back(Pair("experience",(int64_t)P->experience)); + obj.push_back(Pair("dungeonlevel",(int64_t)P->dungeonlevel)); +} + +int32_t disp_gamesplayer(char *str,struct games_player *P) +{ + str[0] = 0; + //if ( P->gold <= 0 )//|| P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) + // return(-1); + sprintf(str," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",P->gold,P->hitpoints,P->strength&0xffff,P->strength>>16,P->level,P->experience,P->dungeonlevel); return(0); } -bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) +int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) { - int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - - return true; // TODO remove, for test dual-evals - - return eval->Invalid("no validation yet"); - std::vector > txids; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - preventCCvins = preventCCvouts = -1; - if ( numvouts < 1 ) - return eval->Invalid("no vouts"); - else + uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; + if ( (len= payload.size()) > 36 ) { - for (i=0; iInvalid("illegal normal vini"); - } - } - //fprintf(stderr,"check amounts\n"); - //if ( PricesExactAmounts(cp,eval,tx,1,10000) == false ) - { - fprintf(stderr,"Pricesget invalid amount\n"); - return false; - } - //else - { - txid = tx.GetHash(); - memcpy(hash,&txid,sizeof(hash)); - retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); - if ( retval != 0 ) - fprintf(stderr,"Pricesget validated\n"); - else fprintf(stderr,"Pricesget invalid\n"); - return(retval); - } - } -} -// end of consensus code - -// helper functions for rpc calls in rpcwallet.cpp - -int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char *destaddr,uint256 tolenid,int64_t total,int32_t maxinputs) -{ - // add threshold check - int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; - std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,destaddr); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - // need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && vout < vintx.vout.size() ) - { - // need to verify assetid - if ( (nValue= vintx.vout[vout].nValue) >= 10000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) - { - if ( total != 0 && maxinputs != 0 ) - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - nValue = it->second.satoshis; - totalinputs += nValue; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) - break; - } - } - } - return(totalinputs); + len -= 36; + for (i=0; i<32; i++) + ((uint8_t *)&gametxid)[i] = payload[len+i]; + eventid = (uint32_t)payload[len+32]; + eventid |= (uint32_t)payload[len+33] << 8; + eventid |= (uint32_t)payload[len+34] << 16; + eventid |= (uint32_t)payload[len+35] << 24; + //for (i=0; i > addressIndex; struct CCcontract_info *cp,C; uint64_t mode; int32_t margin,maxleverage; std::vectorpubkeys; uint256 txid,hashBlock,oracletxid,longtoken,shorttoken,bettoken; CPubKey planpk,pricespk; char str[65]; CTransaction vintx; - cp = CCinit(&C,EVAL_PRICES); - pricespk = GetUnspendable(cp,0); - SetCCtxids(addressIndex,cp->normaladdr); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - { - txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) - { - if ( vintx.vout.size() > 0 && DecodePricesFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' ) - { - result.push_back(uint256_str(str,txid)); - } - } - } - return(result); + return(true); } -// longtoken satoshis limits long exposure -// shorttoken satoshis limits short exposure -// both must be in the 1of2 CC address with its total supply -// bettoken -std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletxid,uint64_t margin,uint64_t mode,uint256 longtoken,uint256 shorttoken,int32_t maxleverage,int64_t funding,std::vector pubkeys) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CCcontract_info *cp,C; - if ( funding < 100*COIN || maxleverage <= 0 || maxleverage > 10000 ) - { - CCerror = "invalid parameter error"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - return(""); - } - cp = CCinit(&C,EVAL_PRICES); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - pricespk = GetUnspendable(cp,0); - if ( (N= (int32_t)pubkeys.size()) || N > 15 ) - { - fprintf(stderr,"too many pubkeys N.%d\n",N); - return(""); - } - for (i=0; i 0 ) - { - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(pricespk)) << OP_CHECKSIG)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodePricesFundingOpRet('F',mypk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken))); - } - else - { - CCerror = "cant find enough inputs"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - } - return(""); -} - -UniValue PricesInfo(uint256 fundingtxid) -{ - UniValue result(UniValue::VOBJ),a(UniValue::VARR); CPubKey pricespk,planpk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction vintx; int64_t balance,supply,exposure; uint64_t funding,mode; int32_t i,margin,maxleverage; char numstr[65],houseaddr[64],exposureaddr[64],str[65]; std::vectorpubkeys; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_PRICES); - pricespk = GetUnspendable(cp,0); - if ( GetTransaction(fundingtxid,vintx,hashBlock,false) == 0 ) - { - fprintf(stderr,"cant find fundingtxid\n"); - ERR_RESULT("cant find fundingtxid"); - return(result); - } - if ( vintx.vout.size() > 0 && DecodePricesFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' ) - { - result.push_back(Pair("result","success")); - result.push_back(Pair("fundingtxid",uint256_str(str,fundingtxid))); - result.push_back(Pair("bettoken",uint256_str(str,bettoken))); - result.push_back(Pair("oracletxid",uint256_str(str,oracletxid))); - sprintf(numstr,"%.3f",(double)margin/1000); - result.push_back(Pair("profitmargin",numstr)); - result.push_back(Pair("maxleverage",maxleverage)); - result.push_back(Pair("mode",(int64_t)mode)); - for (i=0; ipubkeys; - if ( amount < 10000 ) - { - CCerror = "amount must be positive"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - return(""); - } - cp = CCinit(&C,EVAL_PRICES); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - pricespk = GetUnspendable(cp,0); - GetCCaddress(cp,myaddr,mypk); - if ( GetTransaction(fundingtxid,tx,hashBlock,false) == 0 ) - { - fprintf(stderr,"cant find fundingtxid\n"); - return(""); - } - if ( tx.vout.size() > 0 && DecodePricesFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' && bettoken == refbettoken ) - { - GetCCaddress1of2(cp,houseaddr,pricespk,planpk); - if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) - { - if ( (inputs= AddTokensInputs(cp,mtx,myaddr,bettoken,amount,60)) >= amount ) - { - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,amount,pricespk,planpk)); - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(planpk)) << OP_CHECKSIG)); - if ( inputs > amount+txfee ) - CCchange = (inputs - amount); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,mypk)); - // add addr2 - - std::vector voutTokenPubkeysEmpty; //TODO: add token vout pubkeys - return(FinalizeCCTx(0,cp,mtx,mypk,txfee, - EncodeTokenOpRet(bettoken, voutTokenPubkeysEmpty, - std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('t',/*bettoken,*/zeroid, 0, Mypubkey()))))); - } - else - { - CCerror = "cant find enough bet inputs"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - } - } - else - { - CCerror = "cant find enough inputs"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - } - } - return(""); -} - -std::string PricesBet(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount,int32_t leverage) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; - if ( amount < 0 ) - { - amount = -amount; - dir = -1; - } else dir = 1; - cp = CCinit(&C,EVAL_PRICES); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - pricespk = GetUnspendable(cp,0); - GetCCaddress(cp,myaddr,mypk); - if ( GetTransaction(fundingtxid,tx,hashBlock,false) == 0 ) - { - fprintf(stderr,"cant find fundingtxid\n"); - return(""); - } - if ( tx.vout.size() > 0 && DecodePricesFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' && bettoken == refbettoken ) - { - if ( leverage > maxleverage || leverage < 1 ) - { - fprintf(stderr,"illegal leverage\n"); - return(""); - } - GetCCaddress1of2(cp,houseaddr,pricespk,planpk); - GetCCaddress1of2(cp,exposureaddr,pricespk,pricespk); - if ( dir < 0 ) - tokenid = shorttoken; - else tokenid = longtoken; - exposure = leverage * amount; - longexposure = CCtoken_balance(exposureaddr,longtoken); - shortexposure = CCtoken_balance(exposureaddr,shorttoken); - netexposure = (longexposure - shortexposure + exposure*dir); - if ( netexposure < 0 ) - netexposure = -netexposure; - balance = CCtoken_balance(myaddr,bettoken) / COIN; - if ( balance < netexposure*9/10 ) // 10% extra room for dynamically closed bets in wrong direction - { - fprintf(stderr,"balance %lld < 90%% netexposure %lld, refuse bet\n",(long long)balance,(long long)netexposure); - return(""); - } - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) - { - if ( (inputs= AddTokensInputs(cp,mtx,houseaddr,tokenid,exposure,30)) >= exposure ) - { - if ( (inputs2= AddTokensInputs(cp,mtx,myaddr,bettoken,amount,30)) >= amount ) - { - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,amount,pricespk,planpk)); - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,exposure,pricespk,pricespk)); - if ( inputs > exposure+txfee ) - CCchange = (inputs - exposure); - if ( inputs2 > amount+txfee ) - CCchange2 = (inputs2 - amount); - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,CCchange,pricespk,planpk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange2,mypk)); - // add addr2 and addr3 - //return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodePricesExtra('T',tokenid,bettoken,zeroid,dir*leverage))); - CScript opret; - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); - } - else - { - fprintf(stderr,"cant find enough bettoken inputs\n"); - return(""); - } - } - else - { - fprintf(stderr,"cant find enough exposure inputs\n"); - return(""); - } - } - else - { - CCerror = "cant find enough inputsB"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - } - } - return(""); -} - -UniValue PricesStatus(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,uint256 bettxid) -{ - UniValue result(UniValue::VOBJ); - // get height of bettxid - // get price and rekt - // get current height and price - // what about if rekt in the past? - return(result); -} - -std::string PricesFinish(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,uint256 bettxid) -{ - return(""); -} - - - diff --git a/src/cc/prices.h b/src/cc/prices.h new file mode 100644 index 000000000..ae1c46821 --- /dev/null +++ b/src/cc/prices.h @@ -0,0 +1,208 @@ + +#ifndef H_PRICES_H +#define H_PRICES_H + +/***************************************************************************/ +/** https://github.com/brenns10/tetris + @file main.c + @author Stephen Brennan + @date Created Wednesday, 10 June 2015 + @brief Main program for tetris. + @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised + BSD License. See LICENSE.txt for details. + *******************************************************************************/ + +/* + Convert a tetromino type to its corresponding cell. + */ +#define TYPE_TO_CELL(x) ((x)+1) + +/* + Strings for how you would print a tetris board. + */ +#define TC_EMPTY_STR " " +#define TC_BLOCK_STR "\u2588" + +/* + Questions about a tetris cell. + */ +#define TC_IS_EMPTY(x) ((x) == TC_EMPTY) +#define TC_IS_FILLED(x) (!TC_IS_EMPTY(x)) + +/* + How many cells in a tetromino? + */ +#define TETRIS 4 +/* + How many tetrominos? + */ +#define NUM_TETROMINOS 7 +/* + How many orientations of a tetromino? + */ +#define NUM_ORIENTATIONS 4 + +/* + Level constants. + */ +#define MAX_LEVEL 19 +#define LINES_PER_LEVEL 10 + +/* + A "cell" is a 1x1 block within a tetris board. + */ +typedef enum { + TC_EMPTY, TC_CELLI, TC_CELLJ, TC_CELLL, TC_CELLO, TC_CELLS, TC_CELLT, TC_CELLZ +} tetris_cell; + +/* + A "type" is a type/shape of a tetromino. Not including orientation. + */ +typedef enum { + TET_I, TET_J, TET_L, TET_O, TET_S, TET_T, TET_Z +} tetris_type; + +/* + A row,column pair. Negative numbers allowed, because we need them for + offsets. + */ +typedef struct { + int row; + int col; +} tetris_location; + +/* + A "block" is a struct that contains information about a tetromino. + Specifically, what type it is, what orientation it has, and where it is. + */ +typedef struct { + int typ; + int ori; + tetris_location loc; +} tetris_block; + +/* + All possible moves to give as input to the game. + */ +typedef enum { + TM_LEFT, TM_RIGHT, TM_CLOCK, TM_COUNTER, TM_DROP, TM_HOLD, TM_NONE +} tetris_move; + +/* + A game object! + */ +typedef struct { + /* + Game board stuff: + */ + int rows; + int cols; + /* + Scoring information: + */ + int points; + int level; + /* + Falling block is the one currently going down. Next block is the one that + will be falling after this one. Stored is the block that you can swap out. + */ + tetris_block falling; + tetris_block next; + tetris_block stored; + /* + Number of game ticks until the block will move down. + */ + int ticks_till_gravity; + /* + Number of lines until you advance to the next level. + */ + int lines_remaining; + char board[]; +} tetris_game; + +/* + This array stores all necessary information about the cells that are filled by + each tetromino. The first index is the type of the tetromino (i.e. shape, + e.g. I, J, Z, etc.). The next index is the orientation (0-3). The final + array contains 4 tetris_location objects, each mapping to an offset from a + point on the upper left that is the tetromino "origin". + */ +extern const tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS]; + +/* + This array tells you how many ticks per gravity by level. Decreases as level + increases, to add difficulty. + */ +extern const int GRAVITY_LEVEL[MAX_LEVEL+1]; + +// Data structure manipulation. +void tg_init(tetris_game *obj, int rows, int cols); +tetris_game *tg_create(struct games_state *rs,int rows, int cols); +void tg_destroy(tetris_game *obj); +void tg_delete(tetris_game *obj); +tetris_game *tg_load(FILE *f); +void tg_save(tetris_game *obj, FILE *f); + +// Public methods not related to memory: +char tg_get(tetris_game *obj, int row, int col); +bool tg_check(tetris_game *obj, int row, int col); +bool tg_tick(struct games_state *rs,tetris_game *obj, tetris_move move); +void tg_print(tetris_game *obj, FILE *f); + +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ +#define GAMENAME "prices" // name of executable +#define GAMEMAIN prices // main program of game +#define GAMEPLAYERJSON pricesplayerjson // displays game specific json +#define GAMEDATA pricesdata // extracts data from game specific variables into games_state +#define CHAINNAME "PRICES" // -ac_name= +typedef uint64_t gamesevent; // can be 8, 16, 32, or 64 bits + +#define MAXPACK 23 +struct games_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; + +struct games_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; + struct games_packitem gamespack[MAXPACK]; +}; + +struct games_state +{ + uint64_t seed,origseed; + char *keystrokeshex; + uint32_t needflush,replaydone; + int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; + FILE *logfp; + struct games_player P; + gamesevent buffered[5000],*keystrokes; + uint8_t playerdata[8192]; +}; +extern struct games_state globalR; +void *gamesiterate(struct games_state *rs); +int32_t flushkeystrokes(struct games_state *rs,int32_t waitflag); + +void games_packitemstr(char *packitemstr,struct games_packitem *item); +uint64_t _games_rngnext(uint64_t initseed); +int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis); +gamesevent games_revendian(gamesevent revx); +int32_t disp_gamesplayer(char *str,struct games_player *P); + +#endif + From 36fe43ff5876b0f161aaed3dc7b93999264a9ef0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 22:32:25 -1100 Subject: [PATCH 3297/3904] Make prices --- src/cc/gamescc.cpp | 4 ++-- src/cc/makeprices | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 src/cc/makeprices diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index f010ac282..ef9aa157b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -16,7 +16,7 @@ #include "gamescc.h" #ifdef BUILD_PRICES #include "prices.c" -#elif +#else #include "tetris.c" #endif @@ -167,7 +167,7 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 #ifndef STANDALONE #ifdef BUILD_PRICES #include "prices.cpp" -#elif +#else #include "tetris.cpp" #endif diff --git a/src/cc/makeprices b/src/cc/makeprices new file mode 100755 index 000000000..012b8e157 --- /dev/null +++ b/src/cc/makeprices @@ -0,0 +1,3 @@ +gcc -O3 -DBUILD_GAMESCC -DBUILD_PRICES -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o pricescc.so cclib.cpp +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE -DBUILD_PRICES gamescc.cpp -lncurses -lcurl -o tetris + From 7b832d7124d72473ca58066589970a9c764e45d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:00:55 -1100 Subject: [PATCH 3298/3904] Games dir --- src/cc/{ => games}/prices.c | 6 +- src/cc/{tetris.cpp => games/prices.cpp} | 0 src/cc/{ => games}/prices.h | 0 src/cc/{ => games}/tetris.c | 0 src/cc/games/tetris.cpp | 73 ++++ src/cc/{ => games}/tetris.h | 0 src/cc/makeprices | 3 + src/cc/prices.cpp | 462 +++++++++++++++++++++--- 8 files changed, 500 insertions(+), 44 deletions(-) rename src/cc/{ => games}/prices.c (99%) rename src/cc/{tetris.cpp => games/prices.cpp} (100%) rename src/cc/{ => games}/prices.h (100%) rename src/cc/{ => games}/tetris.c (100%) create mode 100644 src/cc/games/tetris.cpp rename src/cc/{ => games}/tetris.h (100%) diff --git a/src/cc/prices.c b/src/cc/games/prices.c similarity index 99% rename from src/cc/prices.c rename to src/cc/games/prices.c index 651b1018c..02366fbc4 100644 --- a/src/cc/prices.c +++ b/src/cc/games/prices.c @@ -1,5 +1,5 @@ -#include "tetris.h" +#include "prices.h" /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. @@ -13,7 +13,7 @@ int random_tetromino(struct games_state *rs) return(rs->seed % NUM_TETROMINOS); } -int32_t tetrisdata(struct games_player *P,void *ptr) +int32_t pricesdata(struct games_player *P,void *ptr) { tetris_game *tg = (tetris_game *)ptr; P->gold = tg->points; @@ -832,7 +832,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve } else return(0); } -int tetris(int argc, char **argv) +int prices(int argc, char **argv) { struct games_state *rs = &globalR; int32_t c,skipcount=0; uint32_t eventid = 0; tetris_game *tg = 0; diff --git a/src/cc/tetris.cpp b/src/cc/games/prices.cpp similarity index 100% rename from src/cc/tetris.cpp rename to src/cc/games/prices.cpp diff --git a/src/cc/prices.h b/src/cc/games/prices.h similarity index 100% rename from src/cc/prices.h rename to src/cc/games/prices.h diff --git a/src/cc/tetris.c b/src/cc/games/tetris.c similarity index 100% rename from src/cc/tetris.c rename to src/cc/games/tetris.c diff --git a/src/cc/games/tetris.cpp b/src/cc/games/tetris.cpp new file mode 100644 index 000000000..8a52dcb37 --- /dev/null +++ b/src/cc/games/tetris.cpp @@ -0,0 +1,73 @@ + +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +// game specific code for daemon +void games_packitemstr(char *packitemstr,struct games_packitem *item) +{ + strcpy(packitemstr,""); +} + +int64_t games_cashout(struct games_player *P) +{ + int32_t dungeonlevel = P->dungeonlevel; int64_t mult=1000,cashout = 0; + cashout = (uint64_t)P->gold * mult * dungeonlevel * dungeonlevel; + return(cashout); +} + +void tetrisplayerjson(UniValue &obj,struct games_player *P) +{ + obj.push_back(Pair("packsize",(int64_t)P->packsize)); + obj.push_back(Pair("hitpoints",(int64_t)P->hitpoints)); + obj.push_back(Pair("strength",(int64_t)(P->strength&0xffff))); + obj.push_back(Pair("maxstrength",(int64_t)(P->strength>>16))); + obj.push_back(Pair("level",(int64_t)P->level)); + obj.push_back(Pair("experience",(int64_t)P->experience)); + obj.push_back(Pair("dungeonlevel",(int64_t)P->dungeonlevel)); +} + +int32_t disp_gamesplayer(char *str,struct games_player *P) +{ + str[0] = 0; + //if ( P->gold <= 0 )//|| P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) + // return(-1); + sprintf(str," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",P->gold,P->hitpoints,P->strength&0xffff,P->strength>>16,P->level,P->experience,P->dungeonlevel); + return(0); +} + +int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) +{ + uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; + if ( (len= payload.size()) > 36 ) + { + len -= 36; + for (i=0; i<32; i++) + ((uint8_t *)&gametxid)[i] = payload[len+i]; + eventid = (uint32_t)payload[len+32]; + eventid |= (uint32_t)payload[len+33] << 8; + eventid |= (uint32_t)payload[len+34] << 16; + eventid |= (uint32_t)payload[len+35] << 24; + //for (i=0; i oracletxid start with 'L', leverage, funding, direction + funds are locked into global CC address + it can be closed at anytime by the trader for cash settlement + the house account can close it if rekt + + Implementation Notes: + In order to eliminate the need for worrying about sybil attacks, each prices plan would be able to specific pubkey(s?) for whitelisted publishers. It would be possible to have a non-whitelisted plan that would use 50% correlation between publishers. + + delta neutral balancing of riskexposure: fabs(long exposure - short exposure) + bet +B at leverage L + absval(sum(+BLi) - sum(-Bli)) + + validate: update riskexposure and it needs to be <= funds + + PricesProfits: limit withdraw to funds in excess of riskexposure + PricesFinish: payout (if winning) and update riskexposure + need long/short exposure assets + + funding -> 1of2 CC global CC address and dealer address, exposure tokens to global 1of2 assets CC address + pricebet -> user funds and exposure token to 1of2 address. + pricewin -> winnings from dealer funds, exposure token back to global address + priceloss -> exposuretoken back to global address + + exposure address, funds address + + + +*/ + +// start of consensus code + +int64_t PricesOraclePrice(int64_t &rektprice,uint64_t mode,uint256 oracletxid,std::vectorpubkeys,int32_t dir,int64_t amount,int32_t leverage) { - strcpy(packitemstr,""); + int64_t price; + // howto ensure price when block it confirms it not known + // get price from oracle + current chaintip + // normalize leveraged amount + if ( dir > 0 ) + rektprice = price * leverage / (leverage-1); + else rektprice = price * (leverage-1) / leverage; + return(price); } -int64_t games_cashout(struct games_player *P) +CScript EncodePricesFundingOpRet(uint8_t funcid,CPubKey planpk,uint256 oracletxid,uint256 longtoken,uint256 shorttoken,int32_t millimargin,uint64_t mode,int32_t maxleverage,std::vector pubkeys,uint256 bettoken) { - int32_t dungeonlevel = P->dungeonlevel; int64_t mult=1000,cashout = 0; - cashout = (uint64_t)P->gold * mult * dungeonlevel * dungeonlevel; - return(cashout); + CScript opret; + fprintf(stderr,"implement EncodePricesFundingOpRet\n"); + return(opret); } -void tetrisplayerjson(UniValue &obj,struct games_player *P) +uint8_t DecodePricesFundingOpRet(CScript scriptPubKey,CPubKey &planpk,uint256 &oracletxid,uint256 &longtoken,uint256 &shorttoken,int32_t &millimargin,uint64_t &mode,int32_t &maxleverage,std::vector &pubkeys,uint256 &bettoken) { - obj.push_back(Pair("packsize",(int64_t)P->packsize)); - obj.push_back(Pair("hitpoints",(int64_t)P->hitpoints)); - obj.push_back(Pair("strength",(int64_t)(P->strength&0xffff))); - obj.push_back(Pair("maxstrength",(int64_t)(P->strength>>16))); - obj.push_back(Pair("level",(int64_t)P->level)); - obj.push_back(Pair("experience",(int64_t)P->experience)); - obj.push_back(Pair("dungeonlevel",(int64_t)P->dungeonlevel)); -} - -int32_t disp_gamesplayer(char *str,struct games_player *P) -{ - str[0] = 0; - //if ( P->gold <= 0 )//|| P->hitpoints <= 0 || (P->strength&0xffff) <= 0 || P->level <= 0 || P->experience <= 0 || P->dungeonlevel <= 0 ) - // return(-1); - sprintf(str," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d",P->gold,P->hitpoints,P->strength&0xffff,P->strength>>16,P->level,P->experience,P->dungeonlevel); + fprintf(stderr,"implement DecodePricesFundingOpRet\n"); return(0); } -int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) +bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { - uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; - if ( (len= payload.size()) > 36 ) + int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; + + return true; // TODO remove, for test dual-evals + + return eval->Invalid("no validation yet"); + std::vector > txids; + numvins = tx.vin.size(); + numvouts = tx.vout.size(); + preventCCvins = preventCCvouts = -1; + if ( numvouts < 1 ) + return eval->Invalid("no vouts"); + else { - len -= 36; - for (i=0; i<32; i++) - ((uint8_t *)&gametxid)[i] = payload[len+i]; - eventid = (uint32_t)payload[len+32]; - eventid |= (uint32_t)payload[len+33] << 8; - eventid |= (uint32_t)payload[len+34] << 16; - eventid |= (uint32_t)payload[len+35] << 24; - //for (i=0; iInvalid("illegal normal vini"); + } + } + //fprintf(stderr,"check amounts\n"); + //if ( PricesExactAmounts(cp,eval,tx,1,10000) == false ) + { + fprintf(stderr,"Pricesget invalid amount\n"); + return false; + } + //else + { + txid = tx.GetHash(); + memcpy(hash,&txid,sizeof(hash)); + retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); + if ( retval != 0 ) + fprintf(stderr,"Pricesget validated\n"); + else fprintf(stderr,"Pricesget invalid\n"); + return(retval); + } + } } +// end of consensus code -bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +// helper functions for rpc calls in rpcwallet.cpp + +int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char *destaddr,uint256 tolenid,int64_t total,int32_t maxinputs) { - return(true); + // add threshold check + int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; + std::vector > unspentOutputs; + SetCCunspents(unspentOutputs,destaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + // need to prevent dup + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && vout < vintx.vout.size() ) + { + // need to verify assetid + if ( (nValue= vintx.vout[vout].nValue) >= 10000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + { + if ( total != 0 && maxinputs != 0 ) + mtx.vin.push_back(CTxIn(txid,vout,CScript())); + nValue = it->second.satoshis; + totalinputs += nValue; + n++; + if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) + break; + } + } + } + return(totalinputs); } +UniValue PricesList() +{ + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint64_t mode; int32_t margin,maxleverage; std::vectorpubkeys; uint256 txid,hashBlock,oracletxid,longtoken,shorttoken,bettoken; CPubKey planpk,pricespk; char str[65]; CTransaction vintx; + cp = CCinit(&C,EVAL_PRICES); + pricespk = GetUnspendable(cp,0); + SetCCtxids(addressIndex,cp->normaladdr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + txid = it->first.txhash; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + { + if ( vintx.vout.size() > 0 && DecodePricesFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' ) + { + result.push_back(uint256_str(str,txid)); + } + } + } + return(result); +} + +// longtoken satoshis limits long exposure +// shorttoken satoshis limits short exposure +// both must be in the 1of2 CC address with its total supply +// bettoken +std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletxid,uint64_t margin,uint64_t mode,uint256 longtoken,uint256 shorttoken,int32_t maxleverage,int64_t funding,std::vector pubkeys) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CCcontract_info *cp,C; + if ( funding < 100*COIN || maxleverage <= 0 || maxleverage > 10000 ) + { + CCerror = "invalid parameter error"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + cp = CCinit(&C,EVAL_PRICES); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + pricespk = GetUnspendable(cp,0); + if ( (N= (int32_t)pubkeys.size()) || N > 15 ) + { + fprintf(stderr,"too many pubkeys N.%d\n",N); + return(""); + } + for (i=0; i 0 ) + { + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(pricespk)) << OP_CHECKSIG)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodePricesFundingOpRet('F',mypk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken))); + } + else + { + CCerror = "cant find enough inputs"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + } + return(""); +} + +UniValue PricesInfo(uint256 fundingtxid) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); CPubKey pricespk,planpk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction vintx; int64_t balance,supply,exposure; uint64_t funding,mode; int32_t i,margin,maxleverage; char numstr[65],houseaddr[64],exposureaddr[64],str[65]; std::vectorpubkeys; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_PRICES); + pricespk = GetUnspendable(cp,0); + if ( GetTransaction(fundingtxid,vintx,hashBlock,false) == 0 ) + { + fprintf(stderr,"cant find fundingtxid\n"); + ERR_RESULT("cant find fundingtxid"); + return(result); + } + if ( vintx.vout.size() > 0 && DecodePricesFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("fundingtxid",uint256_str(str,fundingtxid))); + result.push_back(Pair("bettoken",uint256_str(str,bettoken))); + result.push_back(Pair("oracletxid",uint256_str(str,oracletxid))); + sprintf(numstr,"%.3f",(double)margin/1000); + result.push_back(Pair("profitmargin",numstr)); + result.push_back(Pair("maxleverage",maxleverage)); + result.push_back(Pair("mode",(int64_t)mode)); + for (i=0; ipubkeys; + if ( amount < 10000 ) + { + CCerror = "amount must be positive"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } + cp = CCinit(&C,EVAL_PRICES); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + pricespk = GetUnspendable(cp,0); + GetCCaddress(cp,myaddr,mypk); + if ( GetTransaction(fundingtxid,tx,hashBlock,false) == 0 ) + { + fprintf(stderr,"cant find fundingtxid\n"); + return(""); + } + if ( tx.vout.size() > 0 && DecodePricesFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' && bettoken == refbettoken ) + { + GetCCaddress1of2(cp,houseaddr,pricespk,planpk); + if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) + { + if ( (inputs= AddTokensInputs(cp,mtx,myaddr,bettoken,amount,60)) >= amount ) + { + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,amount,pricespk,planpk)); + mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(planpk)) << OP_CHECKSIG)); + if ( inputs > amount+txfee ) + CCchange = (inputs - amount); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,mypk)); + // add addr2 + + std::vector voutTokenPubkeysEmpty; //TODO: add token vout pubkeys + return(FinalizeCCTx(0,cp,mtx,mypk,txfee, + EncodeTokenOpRet(bettoken, voutTokenPubkeysEmpty, + std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('t',/*bettoken,*/zeroid, 0, Mypubkey()))))); + } + else + { + CCerror = "cant find enough bet inputs"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + } + } + else + { + CCerror = "cant find enough inputs"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + } + } + return(""); +} + +std::string PricesBet(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount,int32_t leverage) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; + if ( amount < 0 ) + { + amount = -amount; + dir = -1; + } else dir = 1; + cp = CCinit(&C,EVAL_PRICES); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + pricespk = GetUnspendable(cp,0); + GetCCaddress(cp,myaddr,mypk); + if ( GetTransaction(fundingtxid,tx,hashBlock,false) == 0 ) + { + fprintf(stderr,"cant find fundingtxid\n"); + return(""); + } + if ( tx.vout.size() > 0 && DecodePricesFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' && bettoken == refbettoken ) + { + if ( leverage > maxleverage || leverage < 1 ) + { + fprintf(stderr,"illegal leverage\n"); + return(""); + } + GetCCaddress1of2(cp,houseaddr,pricespk,planpk); + GetCCaddress1of2(cp,exposureaddr,pricespk,pricespk); + if ( dir < 0 ) + tokenid = shorttoken; + else tokenid = longtoken; + exposure = leverage * amount; + longexposure = CCtoken_balance(exposureaddr,longtoken); + shortexposure = CCtoken_balance(exposureaddr,shorttoken); + netexposure = (longexposure - shortexposure + exposure*dir); + if ( netexposure < 0 ) + netexposure = -netexposure; + balance = CCtoken_balance(myaddr,bettoken) / COIN; + if ( balance < netexposure*9/10 ) // 10% extra room for dynamically closed bets in wrong direction + { + fprintf(stderr,"balance %lld < 90%% netexposure %lld, refuse bet\n",(long long)balance,(long long)netexposure); + return(""); + } + if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) + { + if ( (inputs= AddTokensInputs(cp,mtx,houseaddr,tokenid,exposure,30)) >= exposure ) + { + if ( (inputs2= AddTokensInputs(cp,mtx,myaddr,bettoken,amount,30)) >= amount ) + { + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,amount,pricespk,planpk)); + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,exposure,pricespk,pricespk)); + if ( inputs > exposure+txfee ) + CCchange = (inputs - exposure); + if ( inputs2 > amount+txfee ) + CCchange2 = (inputs2 - amount); + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,CCchange,pricespk,planpk)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange2,mypk)); + // add addr2 and addr3 + //return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodePricesExtra('T',tokenid,bettoken,zeroid,dir*leverage))); + CScript opret; + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); + } + else + { + fprintf(stderr,"cant find enough bettoken inputs\n"); + return(""); + } + } + else + { + fprintf(stderr,"cant find enough exposure inputs\n"); + return(""); + } + } + else + { + CCerror = "cant find enough inputsB"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + } + } + return(""); +} + +UniValue PricesStatus(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,uint256 bettxid) +{ + UniValue result(UniValue::VOBJ); + // get height of bettxid + // get price and rekt + // get current height and price + // what about if rekt in the past? + return(result); +} + +std::string PricesFinish(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,uint256 bettxid) +{ + return(""); +} + + From 8f6561951e9fd0a9ad2646214f051edc96b3a7b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:01:45 -1100 Subject: [PATCH 3299/3904] Games/ --- src/cc/gamescc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index ef9aa157b..6bcd17b09 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -15,9 +15,9 @@ #include "gamescc.h" #ifdef BUILD_PRICES -#include "prices.c" +#include "games/prices.c" #else -#include "tetris.c" +#include "games/tetris.c" #endif int32_t GAMEDATA(struct games_player *P,void *ptr); @@ -166,9 +166,9 @@ int32_t games_replay2(uint8_t *newdata,uint64_t seed,gamesevent *keystrokes,int3 #ifndef STANDALONE #ifdef BUILD_PRICES -#include "prices.cpp" +#include "games/prices.cpp" #else -#include "tetris.cpp" +#include "games/tetris.cpp" #endif void GAMEJSON(UniValue &obj,struct games_player *P); From f31b33355a64fb5d42b7bed6bef8f8a2b8a1d8b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:03:15 -1100 Subject: [PATCH 3300/3904] Pricesplayerjson --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 8a52dcb37..cb2de54a1 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -27,7 +27,7 @@ int64_t games_cashout(struct games_player *P) return(cashout); } -void tetrisplayerjson(UniValue &obj,struct games_player *P) +void pricesplayerjson(UniValue &obj,struct games_player *P) { obj.push_back(Pair("packsize",(int64_t)P->packsize)); obj.push_back(Pair("hitpoints",(int64_t)P->hitpoints)); From 6fca707153a3dde7826bf3798085fb30f61cb8ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:04:32 -1100 Subject: [PATCH 3301/3904] (uint8_t) --- src/cc/gamescc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 6bcd17b09..56fd13310 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1461,13 +1461,13 @@ UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) switch ( sizeof(gamesevent) ) { case 1: - sprintf(&hexstr[i<<1],"%02x",keystrokes[i]); + sprintf(&hexstr[i<<1],"%02x",(uint8_t)keystrokes[i]); break; case 2: - sprintf(&hexstr[i<<2],"%04x",keystrokes[i]); + sprintf(&hexstr[i<<2],"%04x",(uint16_t)keystrokes[i]); break; case 4: - sprintf(&hexstr[i<<3],"%08x",keystrokes[i]); + sprintf(&hexstr[i<<3],"%08x",(uint32_t)keystrokes[i]); break; case 8: sprintf(&hexstr[i<<4],"%016llxx",(long long)keystrokes[i]); From 5f2eeac994966f0b2629204e09eb753f0f472a44 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:08:20 -1100 Subject: [PATCH 3302/3904] Fixes --- src/cc/makeprices | 2 +- src/cc/maketetris | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/makeprices b/src/cc/makeprices index dc120deff..8bb98dd68 100755 --- a/src/cc/makeprices +++ b/src/cc/makeprices @@ -1,6 +1,6 @@ gcc -O3 -DBUILD_GAMESCC -DBUILD_PRICES -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o pricescc.so cclib.cpp cd games -gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE -DBUILD_PRICES gamescc.cpp -lncurses -lcurl -o tetris +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE -DBUILD_PRICES ../gamescc.cpp -lncurses -lcurl -o tetris cd .. diff --git a/src/cc/maketetris b/src/cc/maketetris index 9f0af354e..f11a4de9c 100755 --- a/src/cc/maketetris +++ b/src/cc/maketetris @@ -1,2 +1,4 @@ -gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE gamescc.cpp -lncurses -lcurl -o tetris +cd games +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE ../gamescc.cpp -lncurses -lcurl -o tetris +cd .. From 7e1fc1ef0986d8564a30f9551f9865e42e28af62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:10:16 -1100 Subject: [PATCH 3303/3904] (uint8_t) --- src/cc/dapps/dappstd.c | 6 +++--- src/cc/makeprices | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 917045ed5..82366315c 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -761,11 +761,11 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,gam for (i=0; i Date: Tue, 26 Mar 2019 23:12:41 -1100 Subject: [PATCH 3304/3904] (uint8_t) --- src/cc/games/prices.c | 6 +++--- src/cc/games/tetris.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 02366fbc4..f35e8164b 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -804,11 +804,11 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve if ( 0 ) { if ( sizeof(c) == 1 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",(uint8_t)c&0xff,gametxidstr,eventid); else if ( sizeof(c) == 2 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",(uint16_t)c&0xffff,gametxidstr,eventid); else if ( sizeof(c) == 4 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",(uint32_t)c&0xffffffff,gametxidstr,eventid); else if ( sizeof(c) == 8 ) sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) diff --git a/src/cc/games/tetris.c b/src/cc/games/tetris.c index 651b1018c..254d324a8 100644 --- a/src/cc/games/tetris.c +++ b/src/cc/games/tetris.c @@ -804,11 +804,11 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve if ( 0 ) { if ( sizeof(c) == 1 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",c&0xff,gametxidstr,eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",(uint8_t)c&0xff,gametxidstr,eventid); else if ( sizeof(c) == 2 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",c&0xffff,gametxidstr,eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%04x%%22,%%22%s%%22,%u]\"]",(uint16_t)c&0xffff,gametxidstr,eventid); else if ( sizeof(c) == 4 ) - sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",c&0xffffffff,gametxidstr,eventid); + sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",(uint32_t)c&0xffffffff,gametxidstr,eventid); else if ( sizeof(c) == 8 ) sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) From 97460af39460d404315a4268c6689e46f948db5d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:21:34 -1100 Subject: [PATCH 3305/3904] Fix makecclib --- src/cc/makecclib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 38634aa78..8179623ad 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -6,7 +6,7 @@ make -f Makefile_rogue ./makerogue echo sudoku/musig/dilithium -gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp +gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o sudokucc.so cclib.cpp echo games tetris gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp From eed57deaffa0ca4ccfde66a5ac5852459af1c2d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:36:34 -1100 Subject: [PATCH 3306/3904] Btcusd --- src/cc/games/prices.c | 777 +++++------------------------------------- 1 file changed, 83 insertions(+), 694 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index f35e8164b..cb475c763 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -1,5 +1,6 @@ #include "prices.h" +#include /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. @@ -22,90 +23,6 @@ int32_t pricesdata(struct games_player *P,void *ptr) return(0); } -/***************************************************************************/ -/** https://github.com/brenns10/tetris - @file main.c - @author Stephen Brennan - @date Created Wednesday, 10 June 2015 - @brief Main program for tetris. - @copyright Copyright (c) 2015, Stephen Brennan. Released under the Revised - BSD License. See LICENSE.txt for details. - *******************************************************************************/ - - -#include // for FILE -#include // for bool -#include -#include -#include -#include -#include -#include - -#ifdef BUILD_GAMESCC -#include "rogue/cursesd.h" -#else -#include -#endif - - -#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) - -/******************************************************************************* - Array Definitions - *******************************************************************************/ - -const tetris_location TETROMINOS[NUM_TETROMINOS][NUM_ORIENTATIONS][TETRIS] = -{ - // I - {{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, - {{0, 2}, {1, 2}, {2, 2}, {3, 2}}, - {{3, 0}, {3, 1}, {3, 2}, {3, 3}}, - {{0, 1}, {1, 1}, {2, 1}, {3, 1}}}, - // J - {{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {2, 1}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, - {{0, 1}, {1, 1}, {2, 0}, {2, 1}}}, - // L - {{{0, 2}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, - {{0, 0}, {0, 1}, {1, 1}, {2, 1}}}, - // O - {{{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}, - {{0, 1}, {0, 2}, {1, 1}, {1, 2}}}, - // S - {{{0, 1}, {0, 2}, {1, 0}, {1, 1}}, - {{0, 1}, {1, 1}, {1, 2}, {2, 2}}, - {{1, 1}, {1, 2}, {2, 0}, {2, 1}}, - {{0, 0}, {1, 0}, {1, 1}, {2, 1}}}, - // T - {{{0, 1}, {1, 0}, {1, 1}, {1, 2}}, - {{0, 1}, {1, 1}, {1, 2}, {2, 1}}, - {{1, 0}, {1, 1}, {1, 2}, {2, 1}}, - {{0, 1}, {1, 0}, {1, 1}, {2, 1}}}, - // Z - {{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, - {{0, 2}, {1, 1}, {1, 2}, {2, 1}}, - {{1, 0}, {1, 1}, {2, 1}, {2, 2}}, - {{0, 1}, {1, 0}, {1, 1}, {2, 0}}}, -}; - -const int GRAVITY_LEVEL[MAX_LEVEL+1] = { - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, - //10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 30, 28, 26, 24, 22, 20, 16, 12, 8, 4 -}; - -/******************************************************************************* - Helper Functions for Blocks - *******************************************************************************/ - void sleep_milli(int milliseconds) { struct timespec ts; @@ -114,578 +31,117 @@ void sleep_milli(int milliseconds) nanosleep(&ts, NULL); } -/* - Return the block at the given row and column. - */ -char tg_get(tetris_game *obj, int row, int column) +void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) { - return obj->board[obj->cols * row + column]; -} - -/* - Set the block at the given row and column. - */ -static void tg_set(tetris_game *obj, int row, int column, char value) -{ - obj->board[obj->cols * row + column] = value; -} - -/* - Check whether a row and column are in bounds. - */ -bool tg_check(tetris_game *obj, int row, int col) -{ - return 0 <= row && row < obj->rows && 0 <= col && col < obj->cols; -} - -/* - Place a block onto the board. - */ -static void tg_put(tetris_game *obj, tetris_block block) -{ - int i; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, - TYPE_TO_CELL(block.typ)); - } -} - -/* - Clear a block out of the board. - */ -static void tg_remove(tetris_game *obj, tetris_block block) -{ - int i; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - tg_set(obj, block.loc.row + cell.row, block.loc.col + cell.col, TC_EMPTY); - } -} - -/* - Check if a block can be placed on the board. - */ -static bool tg_fits(tetris_game *obj, tetris_block block) -{ - int i, r, c; - for (i = 0; i < TETRIS; i++) { - tetris_location cell = TETROMINOS[block.typ][block.ori][i]; - r = block.loc.row + cell.row; - c = block.loc.col + cell.col; - if (!tg_check(obj, r, c) || TC_IS_FILLED(tg_get(obj, r, c))) { - return false; - } - } - return true; -} - -/* - Create a new falling block and populate the next falling block with a random - one. - */ -static void tg_new_falling(struct games_state *rs,tetris_game *obj) -{ - // Put in a new falling tetromino. - obj->falling = obj->next; - obj->next.typ = random_tetromino(rs); - obj->next.ori = 0; - obj->next.loc.row = 0; - obj->next.loc.col = obj->cols/2 - 2; -} - -/******************************************************************************* - Game Turn Helpers - *******************************************************************************/ - -/* - Tick gravity, and move the block down if gravity should act. - */ -static void tg_do_gravity_tick(struct games_state *rs,tetris_game *obj) -{ - obj->ticks_till_gravity--; - if (obj->ticks_till_gravity <= 0) { - tg_remove(obj, obj->falling); - obj->falling.loc.row++; - if (tg_fits(obj, obj->falling)) { - obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; - } else { - obj->falling.loc.row--; - tg_put(obj, obj->falling); - - tg_new_falling(rs,obj); - } - tg_put(obj, obj->falling); - } -} - -/* - Move the falling tetris block left (-1) or right (+1). - */ -static void tg_move(tetris_game *obj, int direction) -{ - tg_remove(obj, obj->falling); - obj->falling.loc.col += direction; - if (!tg_fits(obj, obj->falling)) { - obj->falling.loc.col -= direction; - } - tg_put(obj, obj->falling); -} - -/* - Send the falling tetris block to the bottom. - */ -static void tg_down(struct games_state *rs,tetris_game *obj) -{ - tg_remove(obj, obj->falling); - while (tg_fits(obj, obj->falling)) { - obj->falling.loc.row++; - } - obj->falling.loc.row--; - tg_put(obj, obj->falling); - tg_new_falling(rs,obj); -} - -/* - Rotate the falling block in either direction (+/-1). - */ -static void tg_rotate(tetris_game *obj, int direction) -{ - tg_remove(obj, obj->falling); - - while (true) { - obj->falling.ori = (obj->falling.ori + direction) % NUM_ORIENTATIONS; - - // If the new orientation fits, we're done. - if (tg_fits(obj, obj->falling)) - break; - - // Otherwise, try moving left to make it fit. - obj->falling.loc.col--; - if (tg_fits(obj, obj->falling)) - break; - - // Finally, try moving right to make it fit. - obj->falling.loc.col += 2; - if (tg_fits(obj, obj->falling)) - break; - - // Put it back in its original location and try the next orientation. - obj->falling.loc.col--; - // Worst case, we come back to the original orientation and it fits, so this - // loop will terminate. - } - - tg_put(obj, obj->falling); -} - -/* - Swap the falling block with the block in the hold buffer. - */ -static void tg_hold(struct games_state *rs,tetris_game *obj) -{ - tg_remove(obj, obj->falling); - if (obj->stored.typ == -1) { - obj->stored = obj->falling; - tg_new_falling(rs,obj); - } else { - int typ = obj->falling.typ, ori = obj->falling.ori; - obj->falling.typ = obj->stored.typ; - obj->falling.ori = obj->stored.ori; - obj->stored.typ = typ; - obj->stored.ori = ori; - while (!tg_fits(obj, obj->falling)) { - obj->falling.loc.row--; - } - } - tg_put(obj, obj->falling); -} - -/* - Perform the action specified by the move. - */ -static void tg_handle_move(struct games_state *rs,tetris_game *obj, tetris_move move) -{ - switch (move) { - case TM_LEFT: - //fprintf(stderr,"LEFT "); - tg_move(obj, -1); - break; - case TM_RIGHT: - //fprintf(stderr,"RIGHT "); - tg_move(obj, 1); - break; - case TM_DROP: - tg_down(rs,obj); - break; - case TM_CLOCK: - tg_rotate(obj, 1); - break; - case TM_COUNTER: - tg_rotate(obj, -1); - break; - case TM_HOLD: - tg_hold(rs,obj); - break; - default: - // pass - break; - } -} - -/* - Return true if line i is full. - */ -static bool tg_line_full(tetris_game *obj, int i) -{ - int j; - for (j = 0; j < obj->cols; j++) { - if (TC_IS_EMPTY(tg_get(obj, i, j))) - return false; - } - return true; -} - -/* - Shift every row above r down one. - */ -static void tg_shift_lines(tetris_game *obj, int r) -{ - int i, j; - for (i = r-1; i >= 0; i--) { - for (j = 0; j < obj->cols; j++) { - tg_set(obj, i+1, j, tg_get(obj, i, j)); - tg_set(obj, i, j, TC_EMPTY); - } - } -} - -/* - Find rows that are filled, remove them, shift, and return the number of - cleared rows. - */ -static int tg_check_lines(tetris_game *obj) -{ - int i, nlines = 0; - tg_remove(obj, obj->falling); // don't want to mess up falling block - - for (i = obj->rows-1; i >= 0; i--) { - if (tg_line_full(obj, i)) { - tg_shift_lines(obj, i); - i++; // do this line over again since they're shifted - nlines++; - } - } - - tg_put(obj, obj->falling); // replace - return nlines; -} - -/* - Adjust the score for the game, given how many lines were just cleared. - */ -static void tg_adjust_score(tetris_game *obj, int lines_cleared) -{ - static int line_multiplier[] = {0, 40, 100, 300, 1200}; - obj->points += line_multiplier[lines_cleared] * (obj->level + 1); - if (lines_cleared >= obj->lines_remaining) { - obj->level = MIN(MAX_LEVEL, obj->level + 1); - lines_cleared -= obj->lines_remaining; - obj->lines_remaining = LINES_PER_LEVEL - lines_cleared; - } else { - obj->lines_remaining -= lines_cleared; - } -} - -/* - Return true if the game is over. - */ -static bool tg_game_over(tetris_game *obj) -{ - int i, j; - bool over = false; - tg_remove(obj, obj->falling); - for (i = 0; i < 2; i++) { - for (j = 0; j < obj->cols; j++) { - if (TC_IS_FILLED(tg_get(obj, i, j))) { - over = true; - } - } - } - tg_put(obj, obj->falling); - return over; -} - -/******************************************************************************* - Main Public Functions - *******************************************************************************/ - -/* - Do a single game tick: process gravity, user input, and score. Return true if - the game is still running, false if it is over. - */ -bool tg_tick(struct games_state *rs,tetris_game *obj, tetris_move move) -{ - int lines_cleared; - // Handle gravity. - tg_do_gravity_tick(rs,obj); - - // Handle input. - tg_handle_move(rs,obj, move); - - // Check for cleared lines - lines_cleared = tg_check_lines(obj); - - tg_adjust_score(obj, lines_cleared); - - // Return whether the game will continue (NOT whether it's over) - return !tg_game_over(obj); -} - -void tg_init(struct games_state *rs,tetris_game *obj, int rows, int cols) -{ - // Initialization logic - obj->rows = rows; - obj->cols = cols; - //obj->board = (char *)malloc(rows * cols); - memset(obj->board, TC_EMPTY, rows * cols); - obj->points = 0; - obj->level = 0; - obj->ticks_till_gravity = GRAVITY_LEVEL[obj->level]; - obj->lines_remaining = LINES_PER_LEVEL; - //srand(time(NULL)); - tg_new_falling(rs,obj); - tg_new_falling(rs,obj); - obj->stored.typ = -1; - obj->stored.ori = 0; - obj->stored.loc.row = 0; - obj->next.loc.col = obj->cols/2 - 2; - //printf("%d", obj->falling.loc.col); -} - -tetris_game *tg_create(struct games_state *rs,int rows, int cols) -{ - tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game) + rows*cols); - tg_init(rs,obj, rows, cols); - return obj; -} - -/*void tg_destroy(tetris_game *obj) -{ - // Cleanup logic - free(obj->board); -}*/ - -void tg_delete(tetris_game *obj) { - //tg_destroy(obj); - free(obj); -} - -/* - Load a game from a file. - -tetris_game *tg_load(FILE *f) -{ - tetris_game *obj = (tetris_game *)malloc(sizeof(tetris_game)); - if (fread(obj, sizeof(tetris_game), 1, f) != 1 ) + FILE *fp; + long filesize,buflen = *allocsizep; + uint8_t *buf = *bufp; + *lenp = 0; + if ( (fp= fopen(portable_path(fname),"rb")) != 0 ) { - fprintf(stderr,"read game error\n"); - free(obj); - obj = 0; - } - else - { - obj->board = (char *)malloc(obj->rows * obj->cols); - if (fread(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) + fseek(fp,0,SEEK_END); + filesize = ftell(fp); + if ( filesize == 0 ) { - fprintf(stderr,"fread error\n"); - free(obj->board); - free(obj); - obj = 0; + fclose(fp); + *lenp = 0; + //printf("loadfile null size.(%s)\n",fname); + return(0); } - } - return obj; -}*/ - -/* - Save a game to a file. - -void tg_save(tetris_game *obj, FILE *f) -{ - if (fwrite(obj, sizeof(tetris_game), 1, f) != 1 ) - fprintf(stderr,"error writing tetrisgame\n"); - else if (fwrite(obj->board, sizeof(char), obj->rows * obj->cols, f) != obj->rows * obj->cols ) - fprintf(stderr,"error writing board\n"); -}*/ - -/* - Print a game board to a file. Really just for early debugging. - */ -void tg_print(tetris_game *obj, FILE *f) { - int i, j; - for (i = 0; i < obj->rows; i++) { - for (j = 0; j < obj->cols; j++) { - if (TC_IS_EMPTY(tg_get(obj, i, j))) { - fputs(TC_EMPTY_STR, f); - } else { - fputs(TC_BLOCK_STR, f); - } + if ( filesize > buflen ) + { + *allocsizep = filesize; + *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); } - fputc('\n', f); - } -} - -/* - 2 columns per cell makes the game much nicer. - */ -#define COLS_PER_CELL 2 -/* - Macro to print a cell of a specific type to a window. - */ -#define ADD_BLOCK(w,x) waddch((w),' '|A_REVERSE|COLOR_PAIR(x)); \ -waddch((w),' '|A_REVERSE|COLOR_PAIR(x)) -#define ADD_EMPTY(w) waddch((w), ' '); waddch((w), ' ') - -/* - Print the tetris board onto the ncurses window. - */ -void display_board(WINDOW *w, tetris_game *obj) -{ - int i, j; - box(w, 0, 0); - for (i = 0; i < obj->rows; i++) { - wmove(w, 1 + i, 1); - for (j = 0; j < obj->cols; j++) { - if (TC_IS_FILLED(tg_get(obj, i, j))) { - ADD_BLOCK(w,tg_get(obj, i, j)); - } else { - ADD_EMPTY(w); - } + rewind(fp); + if ( buf == 0 ) + printf("Null buf ???\n"); + else + { + if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) + printf("error reading filesize.%ld\n",(long)filesize); + buf[filesize] = 0; } - } - wnoutrefresh(w); + fclose(fp); + *lenp = filesize; + //printf("loaded.(%s)\n",buf); + } //else printf("OS_loadfile couldnt load.(%s)\n",fname); + return(buf); } -/* - Display a tetris piece in a dedicated window. - */ -void display_piece(WINDOW *w, tetris_block block) +void *filestr(long *allocsizep,char *_fname) { - int b; - tetris_location c; - wclear(w); - box(w, 0, 0); - if (block.typ == -1) { - wnoutrefresh(w); - return; - } - for (b = 0; b < TETRIS; b++) { - c = TETROMINOS[block.typ][block.ori][b]; - wmove(w, c.row + 1, c.col * COLS_PER_CELL + 1); - ADD_BLOCK(w, TYPE_TO_CELL(block.typ)); - } - wnoutrefresh(w); + long filesize = 0; char *fname,*buf = 0; void *retptr; + *allocsizep = 0; + fname = malloc(strlen(_fname)+1); + strcpy(fname,_fname); + retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); + free(fname); + return(retptr); } -/* - Display score information in a dedicated window. - */ -void display_score(WINDOW *w, tetris_game *tg) +char *send_curl(char *url,char *fname) { - wclear(w); - box(w, 0, 0); - wprintw(w, (char *)"Score\n%d\n", tg->points); - wprintw(w, (char *)"Level\n%d\n", tg->level); - wprintw(w, (char *)"Lines\n%d\n", tg->lines_remaining); - wnoutrefresh(w); + long fsize; char curlstr[1024]; + sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); + system(curlstr); + return(filestr(&fsize,fname)); } -/* - Save and exit the game. - -void save(tetris_game *game, WINDOW *w) +cJSON *get_urljson(char *url,char *fname) { - FILE *f; - - wclear(w); - box(w, 0, 0); // return the border - wmove(w, 1, 1); - wprintw(w, (char *)"Save and exit? [Y/n] "); - wrefresh(w); - timeout(-1); - if (getch() == 'n') { - timeout(0); - return; + char *jsonstr; cJSON *json = 0; + if ( (jsonstr= send_curl(url,fname)) != 0 ) + { + //printf("(%s) -> (%s)\n",url,jsonstr); + json = cJSON_Parse(jsonstr); + free(jsonstr); } - f = fopen("tetris.save", "w"); - tg_save(game, f); - fclose(f); - tg_delete(game); - endwin(); - fprintf(stderr,"Game saved to \"tetris.save\".\n"); - fprintf(stderr,"Resume by passing the filename as an argument to this program.\n"); - exit(EXIT_SUCCESS); -}*/ + return(json); +} -/* - Do the NCURSES initialization steps for color blocks. - */ -void init_colors(void) +////////////////////////////////////////////// +// start of dapp +////////////////////////////////////////////// + +uint64_t get_btcusd() { - start_color(); - //init_color(COLOR_ORANGE, 1000, 647, 0); - init_pair(TC_CELLI, COLOR_CYAN, COLOR_BLACK); - init_pair(TC_CELLJ, COLOR_BLUE, COLOR_BLACK); - init_pair(TC_CELLL, COLOR_WHITE, COLOR_BLACK); - init_pair(TC_CELLO, COLOR_YELLOW, COLOR_BLACK); - init_pair(TC_CELLS, COLOR_GREEN, COLOR_BLACK); - init_pair(TC_CELLT, COLOR_MAGENTA, COLOR_BLACK); - init_pair(TC_CELLZ, COLOR_RED, COLOR_BLACK); + cJSON *pjson,*bpi,*usd; uint64_t btcusd = 0; + if ( (pjson= get_urljson("http://api.coindesk.com/v1/bpi/currentprice.json","/tmp/oraclefeed.json")) != 0 ) + { + if ( (bpi= jobj(pjson,"bpi")) != 0 && (usd= jobj(bpi,"USD")) != 0 ) + { + btcusd = jdouble(usd,"rate_float") * SATOSHIDEN; + printf("BTC/USD %.4f\n",dstr(btcusd)); + } + free_json(pjson); + } + return(btcusd); } struct games_state globalR; extern char Gametxidstr[]; int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c); -gamesevent games_readevent(struct games_state *rs); void *gamesiterate(struct games_state *rs) { - uint32_t counter = 0; bool running = true; tetris_move move = TM_NONE; - gamesevent c; uint16_t skipcount=0; int32_t prevlevel; uint32_t eventid = 0; tetris_game *tg; - WINDOW *board, *next, *hold, *score; + bool running = true; uint32_t eventid = 0; int64_t price; if ( rs->guiflag != 0 || rs->sleeptime != 0 ) { - // NCURSES initialization: - initscr(); // initialize curses - cbreak(); // pass key presses to program, but not signals - noecho(); // don't echo key presses to screen - keypad(stdscr, TRUE); // allow arrow keys - timeout(0); // no blocking on getch() - curs_set(0); // set the cursor to invisible - init_colors(); // setup tetris colors } - tg = tg_create(rs,22, 10); - prevlevel = tg->level; - // Create windows for each section of the interface. - board = newwin(tg->rows + 2, 2 * tg->cols + 2, 0, 0); - next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); - hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); - score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); while ( running != 0 ) { - running = tg_tick(rs,tg,move); - if ( 1 && (rs->guiflag != 0 || rs->sleeptime != 0) ) + //running = tg_tick(rs,tg,move); + if ( rs->guiflag != 0 || rs->sleeptime != 0 ) { - display_board(board,tg); - display_piece(next,tg->next); - display_piece(hold,tg->stored); - display_score(score,tg); } if ( rs->guiflag != 0 ) { #ifdef STANDALONE - sleep_milli(15); - if ( (counter++ % 10) == 0 ) + sleep_milli(10000); + price = get_btcusd(); + fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/COIN); + /*if ( (counter++ % 10) == 0 ) doupdate(); c = games_readevent(rs); if ( c <= 0x7f || skipcount == 0x3fff ) @@ -700,7 +156,7 @@ void *gamesiterate(struct games_state *rs) prevlevel = tg->level; } skipcount = 0; - } else skipcount++; + } else skipcount++;*/ #endif } else @@ -713,7 +169,7 @@ void *gamesiterate(struct games_state *rs) if ( (counter++ % 20) == 0 ) doupdate(); } - if ( skipcount == 0 ) + /*if ( skipcount == 0 ) { c = games_readevent(rs); //fprintf(stderr,"%04x score.%d level.%d\n",c,tg->points,tg->level); @@ -724,56 +180,14 @@ void *gamesiterate(struct games_state *rs) } } if ( skipcount > 0 ) - skipcount--; + skipcount--;*/ } eventid++; - switch ( c ) - { - case 'h': - move = TM_LEFT; - break; - case 'l': - move = TM_RIGHT; - break; - case 'k': - move = TM_CLOCK; - break; - case 'j': - move = TM_DROP; - break; - case 'q': - running = false; - move = TM_NONE; - break; - /*case 'p': - wclear(board); - box(board, 0, 0); - wmove(board, tg->rows/2, (tg->cols*COLS_PER_CELL-6)/2); - wprintw(board, "PAUSED"); - wrefresh(board); - timeout(-1); - getch(); - timeout(0); - move = TM_NONE; - break; - case 's': - save(tg, board); - move = TM_NONE; - break;*/ - case ' ': - move = TM_HOLD; - break; - default: - move = TM_NONE; - } } - return(tg); + return(0); } #ifdef STANDALONE -/* - Main tetris game! - */ #include "dapps/dappstd.c" @@ -835,7 +249,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve int prices(int argc, char **argv) { struct games_state *rs = &globalR; - int32_t c,skipcount=0; uint32_t eventid = 0; tetris_game *tg = 0; + int32_t c,skipcount=0; uint32_t eventid = 0; memset(rs,0,sizeof(*rs)); rs->guiflag = 1; rs->sleeptime = 1; // non-zero to allow refresh() @@ -862,33 +276,8 @@ int prices(int argc, char **argv) } } } else rs->seed = 777; - - /* Load file if given a filename. - if (argc >= 2) { - FILE *f = fopen(argv[1], "r"); - if (f == NULL) { - perror("tetris"); - exit(EXIT_FAILURE); - } - tg = tg_load(f); - fclose(f); - } else { - // Otherwise create new game. - tg = tg_create(rs,22, 10); - }*/ - - // Game loop - tg = (tetris_game *)gamesiterate(rs); - gamesbailout(rs); - // Deinitialize NCurses - wclear(stdscr); - endwin(); - // Output ending message. - printf("Game over!\n"); - printf("You finished with %d points on level %d.\n", tg->points, tg->level); - - // Deinitialize Tetris - tg_delete(tg); + gamesiterate(rs); + //gamesbailout(rs); return 0; } From 02e76e122bf1b71515e0707962d1f0f0b92fb834 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:40:09 -1100 Subject: [PATCH 3307/3904] syntax --- src/cc/games/prices.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index cb475c763..81f58521c 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -31,6 +31,37 @@ void sleep_milli(int milliseconds) nanosleep(&ts, NULL); } +char *nonportable_path(char *str) +{ + int32_t i; + for (i=0; str[i]!=0; i++) + if ( str[i] == '/' ) + str[i] = '\\'; + return(str); +} + +char *portable_path(char *str) +{ +#ifdef _WIN32 + return(nonportable_path(str)); +#else +#ifdef __PNACL + /*int32_t i,n; + if ( str[0] == '/' ) + return(str); + else + { + n = (int32_t)strlen(str); + for (i=n; i>0; i--) + str[i] = str[i-1]; + str[0] = '/'; + str[n+1] = 0; + }*/ +#endif + return(str); +#endif +} + void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) { FILE *fp; @@ -73,7 +104,7 @@ void *filestr(long *allocsizep,char *_fname) { long filesize = 0; char *fname,*buf = 0; void *retptr; *allocsizep = 0; - fname = malloc(strlen(_fname)+1); + fname = (char *)malloc(strlen(_fname)+1); strcpy(fname,_fname); retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); free(fname); From 2821c37693fe66b4fafef0120cc9a6546abe1f81 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:41:07 -1100 Subject: [PATCH 3308/3904] Ncurses --- src/cc/games/prices.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 81f58521c..96506b41c 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -1,6 +1,7 @@ #include "prices.h" #include +#include /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. From 4d66ed85244123fa136689bf3e760c1aa12c8dd8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:43:26 -1100 Subject: [PATCH 3309/3904] -curses.h --- src/cc/games/prices.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 96506b41c..81f58521c 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -1,7 +1,6 @@ #include "prices.h" #include -#include /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. From 55b3b006edb1e99a85de8b60b9e00f89f20b8f71 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:44:12 -1100 Subject: [PATCH 3310/3904] Test --- src/cc/games/prices.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 81f58521c..66cf54030 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -219,6 +219,7 @@ void *gamesiterate(struct games_state *rs) } #ifdef STANDALONE +#include #include "dapps/dappstd.c" From 20ff5d20d4182a17abf495ed0b9cbaab2419b0e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:46:06 -1100 Subject: [PATCH 3311/3904] syntax --- src/cc/games/prices.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 66cf54030..e125a1602 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -116,7 +116,7 @@ char *send_curl(char *url,char *fname) long fsize; char curlstr[1024]; sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); system(curlstr); - return(filestr(&fsize,fname)); + return((char *)filestr(&fsize,fname)); } cJSON *get_urljson(char *url,char *fname) @@ -138,11 +138,11 @@ cJSON *get_urljson(char *url,char *fname) uint64_t get_btcusd() { cJSON *pjson,*bpi,*usd; uint64_t btcusd = 0; - if ( (pjson= get_urljson("http://api.coindesk.com/v1/bpi/currentprice.json","/tmp/oraclefeed.json")) != 0 ) + if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json","/tmp/oraclefeed.json")) != 0 ) { - if ( (bpi= jobj(pjson,"bpi")) != 0 && (usd= jobj(bpi,"USD")) != 0 ) + if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 && (usd= jobj(bpi,(char *)"USD")) != 0 ) { - btcusd = jdouble(usd,"rate_float") * SATOSHIDEN; + btcusd = jdouble(usd,(char *)"rate_float") * SATOSHIDEN; printf("BTC/USD %.4f\n",dstr(btcusd)); } free_json(pjson); @@ -197,8 +197,6 @@ void *gamesiterate(struct games_state *rs) if ( rs->sleeptime != 0 ) { sleep_milli(1); - if ( (counter++ % 20) == 0 ) - doupdate(); } /*if ( skipcount == 0 ) { From eca3bda195239b325d1f71b350b3983c46b6bc13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:48:03 -1100 Subject: [PATCH 3312/3904] Prints --- src/cc/games/prices.c | 2 +- src/cc/makeprices | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index e125a1602..057e8be7f 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -138,7 +138,7 @@ cJSON *get_urljson(char *url,char *fname) uint64_t get_btcusd() { cJSON *pjson,*bpi,*usd; uint64_t btcusd = 0; - if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json","/tmp/oraclefeed.json")) != 0 ) + if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json",(char *)"/tmp/oraclefeed.json")) != 0 ) { if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 && (usd= jobj(bpi,(char *)"USD")) != 0 ) { diff --git a/src/cc/makeprices b/src/cc/makeprices index ca8b80065..2779c1c5b 100755 --- a/src/cc/makeprices +++ b/src/cc/makeprices @@ -1,4 +1,6 @@ +echo pricescc.so gcc -O3 -DBUILD_GAMESCC -DBUILD_PRICES -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o pricescc.so cclib.cpp +echo prices cd games gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE -DBUILD_PRICES ../gamescc.cpp -lncurses -lcurl -o prices cd .. From 382dd5021874f14230ac7e448517f00563de1eef Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:49:50 -1100 Subject: [PATCH 3313/3904] Test --- src/cc/games/prices.c | 142 +++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 057e8be7f..fa8749605 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -31,6 +31,77 @@ void sleep_milli(int milliseconds) nanosleep(&ts, NULL); } +struct games_state globalR; +extern char Gametxidstr[]; +int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c); +uint64_t get_btcusd(); + +void *gamesiterate(struct games_state *rs) +{ + bool running = true; uint32_t eventid = 0; int64_t price; + if ( rs->guiflag != 0 || rs->sleeptime != 0 ) + { + } + while ( running != 0 ) + { + //running = tg_tick(rs,tg,move); + if ( rs->guiflag != 0 || rs->sleeptime != 0 ) + { + } + if ( rs->guiflag != 0 ) + { +#ifdef STANDALONE + sleep_milli(10000); + price = get_btcusd(); + fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/COIN); + /*if ( (counter++ % 10) == 0 ) + doupdate(); + c = games_readevent(rs); + if ( c <= 0x7f || skipcount == 0x3fff ) + { + if ( skipcount > 0 ) + issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x4000); + if ( c <= 0x7f ) + issue_games_events(rs,Gametxidstr,eventid,c); + if ( tg->level != prevlevel ) + { + flushkeystrokes(rs,0); + prevlevel = tg->level; + } + skipcount = 0; + } else skipcount++;*/ +#endif + } + else + { + if ( rs->replaydone != 0 ) + break; + if ( rs->sleeptime != 0 ) + { + sleep_milli(1); + } + /*if ( skipcount == 0 ) + { + c = games_readevent(rs); + //fprintf(stderr,"%04x score.%d level.%d\n",c,tg->points,tg->level); + if ( (c & 0x4000) == 0x4000 ) + { + skipcount = (c & 0x3fff); + c = 'S'; + } + } + if ( skipcount > 0 ) + skipcount--;*/ + } + eventid++; + } + return(0); +} + +#ifdef STANDALONE +#include +#include "dapps/dappstd.c" + char *nonportable_path(char *str) { int32_t i; @@ -150,77 +221,6 @@ uint64_t get_btcusd() return(btcusd); } -struct games_state globalR; -extern char Gametxidstr[]; -int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c); - -void *gamesiterate(struct games_state *rs) -{ - bool running = true; uint32_t eventid = 0; int64_t price; - if ( rs->guiflag != 0 || rs->sleeptime != 0 ) - { - } - while ( running != 0 ) - { - //running = tg_tick(rs,tg,move); - if ( rs->guiflag != 0 || rs->sleeptime != 0 ) - { - } - if ( rs->guiflag != 0 ) - { -#ifdef STANDALONE - sleep_milli(10000); - price = get_btcusd(); - fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/COIN); - /*if ( (counter++ % 10) == 0 ) - doupdate(); - c = games_readevent(rs); - if ( c <= 0x7f || skipcount == 0x3fff ) - { - if ( skipcount > 0 ) - issue_games_events(rs,Gametxidstr,eventid-skipcount,skipcount | 0x4000); - if ( c <= 0x7f ) - issue_games_events(rs,Gametxidstr,eventid,c); - if ( tg->level != prevlevel ) - { - flushkeystrokes(rs,0); - prevlevel = tg->level; - } - skipcount = 0; - } else skipcount++;*/ -#endif - } - else - { - if ( rs->replaydone != 0 ) - break; - if ( rs->sleeptime != 0 ) - { - sleep_milli(1); - } - /*if ( skipcount == 0 ) - { - c = games_readevent(rs); - //fprintf(stderr,"%04x score.%d level.%d\n",c,tg->points,tg->level); - if ( (c & 0x4000) == 0x4000 ) - { - skipcount = (c & 0x3fff); - c = 'S'; - } - } - if ( skipcount > 0 ) - skipcount--;*/ - } - eventid++; - } - return(0); -} - -#ifdef STANDALONE -#include -#include "dapps/dappstd.c" - - char *clonestr(char *str) { char *clone; int32_t len; From 498c813b674b21fd1557004cc029f2e65c0bf42c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:53:59 -1100 Subject: [PATCH 3314/3904] #include "rogue/cursesd.c" --- src/cc/cclib.cpp | 2 +- src/cc/games/prices.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 95748def4..975b0735c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -691,8 +691,8 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) #include "customcc.cpp" #elif BUILD_GAMESCC -#include "gamescc.cpp" #include "rogue/cursesd.c" +#include "gamescc.cpp" #else #include "sudoku.cpp" diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index fa8749605..b9da75fe2 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -53,7 +53,7 @@ void *gamesiterate(struct games_state *rs) #ifdef STANDALONE sleep_milli(10000); price = get_btcusd(); - fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/COIN); + fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/SATOSHIDEN); /*if ( (counter++ % 10) == 0 ) doupdate(); c = games_readevent(rs); @@ -184,9 +184,12 @@ void *filestr(long *allocsizep,char *_fname) char *send_curl(char *url,char *fname) { - long fsize; char curlstr[1024]; + long fsize; char curlstr[1024],*retstr,*retstr2; sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); - system(curlstr); + //retstr2 = bitcoind_RPC(&retstr,(char *)"prices",url,"","",""); + + if ( system(curlstr) != 0 ) + fprintf(stderr,"error doing system(%s)\n",curlstr); return((char *)filestr(&fsize,fname)); } From 75465c987cfbd6707f3a5438918ed12747a7ae1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:55:08 -1100 Subject: [PATCH 3315/3904] SATOSHIDEN --- src/cc/games/prices.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index b9da75fe2..3d72965fc 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -1,6 +1,7 @@ #include "prices.h" #include +#define SATOSHIDEN 100000000 /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. From 9f42c31c2a81872822e9944dd8d5fd82be943072 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:55:38 -1100 Subject: [PATCH 3316/3904] #define SATOSHIDEN ((uint64_t)100000000L) --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 3d72965fc..0ac0844c2 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -1,7 +1,7 @@ #include "prices.h" #include -#define SATOSHIDEN 100000000 +#define SATOSHIDEN ((uint64_t)100000000L) /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. From 73e6a1cb6bb803cf529f51b1a0f6cd8083b7903a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Mar 2019 23:58:10 -1100 Subject: [PATCH 3317/3904] Fx --- src/cc/makecclib | 2 -- src/cc/maketetris | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 8179623ad..81026e75a 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -9,11 +9,9 @@ echo sudoku/musig/dilithium gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o sudokucc.so cclib.cpp echo games tetris -gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp ./maketetris echo games prices -gcc -O3 -DBUILD_GAMESCC -DBUILD_PRICES -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o pricescc.so cclib.cpp ./makeprices echo customcc stub diff --git a/src/cc/maketetris b/src/cc/maketetris index f11a4de9c..c39536229 100755 --- a/src/cc/maketetris +++ b/src/cc/maketetris @@ -1,3 +1,6 @@ +echo gamescc.so with tetris +gcc -O3 -DBUILD_GAMESCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o gamescc.so cclib.cpp +echo tetris dapp cd games gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE ../gamescc.cpp -lncurses -lcurl -o tetris cd .. From f49f901f4f12d73b47915be3b9adb0ab526d3f11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:06:18 -1100 Subject: [PATCH 3318/3904] Change Tetris washout --- src/cc/games/tetris.cpp | 4 ++-- src/cc/makecclib | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/games/tetris.cpp b/src/cc/games/tetris.cpp index 8a52dcb37..f1b6416ba 100644 --- a/src/cc/games/tetris.cpp +++ b/src/cc/games/tetris.cpp @@ -22,8 +22,8 @@ void games_packitemstr(char *packitemstr,struct games_packitem *item) int64_t games_cashout(struct games_player *P) { - int32_t dungeonlevel = P->dungeonlevel; int64_t mult=1000,cashout = 0; - cashout = (uint64_t)P->gold * mult * dungeonlevel * dungeonlevel; + int32_t dungeonlevel = P->dungeonlevel; int64_t mult=10000,cashout = 0; + cashout = (uint64_t)P->gold * mult; return(cashout); } diff --git a/src/cc/makecclib b/src/cc/makecclib index 81026e75a..b2f8e2ee1 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -1,5 +1,5 @@ #!/bin/sh -rm *.so rogue/rogue tetris +rm *.so rogue/rogue games/tetris games/prices echo rogue make -f Makefile_rogue From 58be59a00d8876b492faeef0b176a09478ec704c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:10:17 -1100 Subject: [PATCH 3319/3904] Test --- src/cc/games/prices.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 0ac0844c2..658ed2406 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -185,13 +185,14 @@ void *filestr(long *allocsizep,char *_fname) char *send_curl(char *url,char *fname) { - long fsize; char curlstr[1024],*retstr,*retstr2; - sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); - //retstr2 = bitcoind_RPC(&retstr,(char *)"prices",url,"","",""); - - if ( system(curlstr) != 0 ) - fprintf(stderr,"error doing system(%s)\n",curlstr); - return((char *)filestr(&fsize,fname)); + //long fsize; char curlstr[1024]; + //sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); + char *retstr=0,*retstr2; + retstr2 = bitcoind_RPC(&retstr,(char *)"prices",url,"","",""); + return(retstr2); + //if ( system(curlstr) != 0 ) + // fprintf(stderr,"error doing system(%s)\n",curlstr); + //return((char *)filestr(&fsize,fname)); } cJSON *get_urljson(char *url,char *fname) From 5bbe79b586a6ba832fd779806eed5ba8cc341d10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:11:07 -1100 Subject: [PATCH 3320/3904] Sleep --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 658ed2406..8798fa68f 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -52,7 +52,7 @@ void *gamesiterate(struct games_state *rs) if ( rs->guiflag != 0 ) { #ifdef STANDALONE - sleep_milli(10000); + sleep(1); price = get_btcusd(); fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/SATOSHIDEN); /*if ( (counter++ % 10) == 0 ) From 73cc7ba642629343f8b7ef6e6553b3e19771c8b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:11:31 -1100 Subject: [PATCH 3321/3904] (char *) --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 8798fa68f..32e7e509c 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -188,7 +188,7 @@ char *send_curl(char *url,char *fname) //long fsize; char curlstr[1024]; //sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); char *retstr=0,*retstr2; - retstr2 = bitcoind_RPC(&retstr,(char *)"prices",url,"","",""); + retstr2 = bitcoind_RPC(&retstr,(char *)"prices",url,(char *)"",(char *)"",(char *)""); return(retstr2); //if ( system(curlstr) != 0 ) // fprintf(stderr,"error doing system(%s)\n",curlstr); From e7373723f4693bcfcef5900cf4a847a764048f0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:12:38 -1100 Subject: [PATCH 3322/3904] Units --- src/cc/games/prices.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 32e7e509c..41ddb8fd7 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -1,6 +1,7 @@ #include "prices.h" #include +#include #define SATOSHIDEN ((uint64_t)100000000L) /* @@ -52,7 +53,7 @@ void *gamesiterate(struct games_state *rs) if ( rs->guiflag != 0 ) { #ifdef STANDALONE - sleep(1); + sleep(10); price = get_btcusd(); fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/SATOSHIDEN); /*if ( (counter++ % 10) == 0 ) From e2527311f2bc8e8aa2d9bf6f18313b6556e1310f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:14:56 -1100 Subject: [PATCH 3323/3904] Test --- src/cc/games/prices.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 41ddb8fd7..339f3293c 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -190,6 +190,10 @@ char *send_curl(char *url,char *fname) //sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); char *retstr=0,*retstr2; retstr2 = bitcoind_RPC(&retstr,(char *)"prices",url,(char *)"",(char *)"",(char *)""); + if ( retstr2 != 0 ) + printf("retstr2 (%s)\n",retstr2); + if ( retstr != 0 ) + printf("retstr (%s)\n",retstr); return(retstr2); //if ( system(curlstr) != 0 ) // fprintf(stderr,"error doing system(%s)\n",curlstr); @@ -201,7 +205,7 @@ cJSON *get_urljson(char *url,char *fname) char *jsonstr; cJSON *json = 0; if ( (jsonstr= send_curl(url,fname)) != 0 ) { - //printf("(%s) -> (%s)\n",url,jsonstr); + printf("(%s) -> (%s)\n",url,jsonstr); json = cJSON_Parse(jsonstr); free(jsonstr); } From 63a02c688ab238141847f2ad93a0c0b1bebe7db4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:17:23 -1100 Subject: [PATCH 3324/3904] issue_curl --- src/cc/games/prices.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 339f3293c..6d3694d30 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -188,13 +188,11 @@ char *send_curl(char *url,char *fname) { //long fsize; char curlstr[1024]; //sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); - char *retstr=0,*retstr2; - retstr2 = bitcoind_RPC(&retstr,(char *)"prices",url,(char *)"",(char *)"",(char *)""); - if ( retstr2 != 0 ) - printf("retstr2 (%s)\n",retstr2); + char *retstr; + retstr = issue_curl(url,10); if ( retstr != 0 ) printf("retstr (%s)\n",retstr); - return(retstr2); + return(retstr); //if ( system(curlstr) != 0 ) // fprintf(stderr,"error doing system(%s)\n",curlstr); //return((char *)filestr(&fsize,fname)); From 7d251f6f240333f7727384dc7fdd5dd390df4ed7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:18:30 -1100 Subject: [PATCH 3325/3904] #define issue_curl(cmdstr) bitcoind_RPC(0,"curl",cmdstr,0,0,0,0) --- src/cc/games/prices.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 6d3694d30..e45222c13 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -3,6 +3,7 @@ #include #include #define SATOSHIDEN ((uint64_t)100000000L) +#define issue_curl(cmdstr) bitcoind_RPC(0,"prices",cmdstr,0,0,0,0) /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. @@ -189,7 +190,7 @@ char *send_curl(char *url,char *fname) //long fsize; char curlstr[1024]; //sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); char *retstr; - retstr = issue_curl(url,10); + retstr = issue_curl(url); if ( retstr != 0 ) printf("retstr (%s)\n",retstr); return(retstr); From 82850e26352730bfcbca46c608440764e65b4001 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:19:13 -1100 Subject: [PATCH 3326/3904] -0 --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index e45222c13..b5eca9c50 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -3,7 +3,7 @@ #include #include #define SATOSHIDEN ((uint64_t)100000000L) -#define issue_curl(cmdstr) bitcoind_RPC(0,"prices",cmdstr,0,0,0,0) +#define issue_curl(cmdstr) bitcoind_RPC(0,"prices",cmdstr,0,0,0) /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. From a0667c2488b6c8bed921501b950623def355259d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:19:49 -1100 Subject: [PATCH 3327/3904] Char * --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index b5eca9c50..96b7b72e0 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -3,7 +3,7 @@ #include #include #define SATOSHIDEN ((uint64_t)100000000L) -#define issue_curl(cmdstr) bitcoind_RPC(0,"prices",cmdstr,0,0,0) +#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"prices",cmdstr,0,0,0) /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. From a13b601d779caac72f7f98b579706df11317cece Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:20:17 -1100 Subject: [PATCH 3328/3904] sleep(10); --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 96b7b72e0..ff98da774 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -54,9 +54,9 @@ void *gamesiterate(struct games_state *rs) if ( rs->guiflag != 0 ) { #ifdef STANDALONE - sleep(10); price = get_btcusd(); fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/SATOSHIDEN); + sleep(10); /*if ( (counter++ % 10) == 0 ) doupdate(); c = games_readevent(rs); From ba37ac2c088950769b6e8665e398f2174f14ec66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:25:43 -1100 Subject: [PATCH 3329/3904] Encode price --- src/cc/games/prices.c | 98 ++++--------------------------------------- 1 file changed, 7 insertions(+), 91 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index ff98da774..4a95ef99e 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -55,7 +55,9 @@ void *gamesiterate(struct games_state *rs) { #ifdef STANDALONE price = get_btcusd(); - fprintf(stderr,"price %llu %.8f\n",(long long)price,(double)price/SATOSHIDEN); + fprintf(stderr,"%llu -> t%u %.4f\n",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); + issue_games_events(rs,Gametxidstr,eventid,price); + eventid++; sleep(10); /*if ( (counter++ % 10) == 0 ) doupdate(); @@ -105,98 +107,11 @@ void *gamesiterate(struct games_state *rs) #include #include "dapps/dappstd.c" -char *nonportable_path(char *str) -{ - int32_t i; - for (i=0; str[i]!=0; i++) - if ( str[i] == '/' ) - str[i] = '\\'; - return(str); -} - -char *portable_path(char *str) -{ -#ifdef _WIN32 - return(nonportable_path(str)); -#else -#ifdef __PNACL - /*int32_t i,n; - if ( str[0] == '/' ) - return(str); - else - { - n = (int32_t)strlen(str); - for (i=n; i>0; i--) - str[i] = str[i-1]; - str[0] = '/'; - str[n+1] = 0; - }*/ -#endif - return(str); -#endif -} - -void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) -{ - FILE *fp; - long filesize,buflen = *allocsizep; - uint8_t *buf = *bufp; - *lenp = 0; - if ( (fp= fopen(portable_path(fname),"rb")) != 0 ) - { - fseek(fp,0,SEEK_END); - filesize = ftell(fp); - if ( filesize == 0 ) - { - fclose(fp); - *lenp = 0; - //printf("loadfile null size.(%s)\n",fname); - return(0); - } - if ( filesize > buflen ) - { - *allocsizep = filesize; - *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); - } - rewind(fp); - if ( buf == 0 ) - printf("Null buf ???\n"); - else - { - if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) - printf("error reading filesize.%ld\n",(long)filesize); - buf[filesize] = 0; - } - fclose(fp); - *lenp = filesize; - //printf("loaded.(%s)\n",buf); - } //else printf("OS_loadfile couldnt load.(%s)\n",fname); - return(buf); -} - -void *filestr(long *allocsizep,char *_fname) -{ - long filesize = 0; char *fname,*buf = 0; void *retptr; - *allocsizep = 0; - fname = (char *)malloc(strlen(_fname)+1); - strcpy(fname,_fname); - retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); - free(fname); - return(retptr); -} - char *send_curl(char *url,char *fname) { - //long fsize; char curlstr[1024]; - //sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); char *retstr; retstr = issue_curl(url); - if ( retstr != 0 ) - printf("retstr (%s)\n",retstr); return(retstr); - //if ( system(curlstr) != 0 ) - // fprintf(stderr,"error doing system(%s)\n",curlstr); - //return((char *)filestr(&fsize,fname)); } cJSON *get_urljson(char *url,char *fname) @@ -204,7 +119,7 @@ cJSON *get_urljson(char *url,char *fname) char *jsonstr; cJSON *json = 0; if ( (jsonstr= send_curl(url,fname)) != 0 ) { - printf("(%s) -> (%s)\n",url,jsonstr); + //printf("(%s) -> (%s)\n",url,jsonstr); json = cJSON_Parse(jsonstr); free(jsonstr); } @@ -217,17 +132,18 @@ cJSON *get_urljson(char *url,char *fname) uint64_t get_btcusd() { - cJSON *pjson,*bpi,*usd; uint64_t btcusd = 0; + cJSON *pjson,*bpi,*usd; uint64_t x,btcusd = 0; if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json",(char *)"/tmp/oraclefeed.json")) != 0 ) { if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 && (usd= jobj(bpi,(char *)"USD")) != 0 ) { btcusd = jdouble(usd,(char *)"rate_float") * SATOSHIDEN; + x = ((uint64_t)time(NULL) << 32) | (btcusd / 10000); printf("BTC/USD %.4f\n",dstr(btcusd)); } free_json(pjson); } - return(btcusd); + return(x); } char *clonestr(char *str) From adcf1042a1699b1f3980d5806200a421d4b43681 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:27:54 -1100 Subject: [PATCH 3330/3904] Broadcast --- src/cc/games/prices.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 4a95ef99e..7987c45a0 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -139,7 +139,7 @@ uint64_t get_btcusd() { btcusd = jdouble(usd,(char *)"rate_float") * SATOSHIDEN; x = ((uint64_t)time(NULL) << 32) | (btcusd / 10000); - printf("BTC/USD %.4f\n",dstr(btcusd)); + //printf("BTC/USD %.4f\n",dstr(btcusd)); } free_json(pjson); } @@ -170,7 +170,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve if ( fp == 0 ) fp = fopen("events.log","wb"); rs->buffered[rs->num++] = c; - if ( 0 ) + if ( 1 ) { if ( sizeof(c) == 1 ) sprintf(params,"[\"events\",\"17\",\"[%%22%02x%%22,%%22%s%%22,%u]\"]",(uint8_t)c&0xff,gametxidstr,eventid); From 9e878493e9a7a55fea2ca44c019f2629d47b75af Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 00:32:04 -1100 Subject: [PATCH 3331/3904] +print --- src/cc/games/prices.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index cb2de54a1..82e132c7f 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -59,9 +59,9 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay eventid |= (uint32_t)payload[len+33] << 8; eventid |= (uint32_t)payload[len+34] << 16; eventid |= (uint32_t)payload[len+35] << 24; - //for (i=0; i Date: Wed, 27 Mar 2019 00:50:13 -1100 Subject: [PATCH 3332/3904] +prints --- src/cc/gamescc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 56fd13310..dc36cc757 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -553,14 +553,14 @@ void komodo_netevent(std::vector message) { if ( (rand() % 10) == 0 ) { - //fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); + fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); komodo_sendmessage(2,2,"events",message); } } } - //for (i=0; i Date: Wed, 27 Mar 2019 00:52:39 -1100 Subject: [PATCH 3333/3904] +print --- src/cc/gamescc.cpp | 4 +++- src/miner.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index dc36cc757..f04ffb22f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -477,7 +477,9 @@ int32_t games_event(uint32_t timestamp,uint256 gametxid,int32_t eventid,std::vec games_payloadrecv(mypk,timestamp,payload); komodo_sendmessage(4,8,"events",vopret); return(0); - } else return(-1); + } + fprintf(stderr,"games_eventsign error\n"); + return(-1); } UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) diff --git a/src/miner.cpp b/src/miner.cpp index eaba96ee1..ca4ce8714 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -941,6 +941,7 @@ void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,st continue; if ( numsent < minpeers || (rand() % 10) == 0 ) { + fprintf(stderr,"pushmessage\n"); pnode->PushMessage(message,payload); if ( numsent++ > maxpeers ) break; From 2bb01b26340a0e018e1241c5d34e81a2e99f17f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:26:08 -1100 Subject: [PATCH 3334/3904] fprintf(stderr,"%llu -> t%u %.4f\n",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); --- src/cc/games/prices.cpp | 5 +++-- src/cc/gamescc.cpp | 6 +++--- src/miner.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 82e132c7f..4c9698593 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -49,7 +49,7 @@ int32_t disp_gamesplayer(char *str,struct games_player *P) int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector payload) { - uint256 gametxid; int32_t i,len; char str[67]; uint32_t eventid = 0; + uint256 gametxid; int32_t i,len; char str[67]; int64_t price; uint32_t eventid = 0; if ( (len= payload.size()) > 36 ) { len -= 36; @@ -60,7 +60,8 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay eventid |= (uint32_t)payload[len+34] << 16; eventid |= (uint32_t)payload[len+35] << 24; for (i=0; i t%u %.4f ",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); fprintf(stderr," got payload, from %s %s/e%d\n",pubkey33_str(str,(uint8_t *)&pk),gametxid.GetHex().c_str(),eventid); return(0); } else return(-1); diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index f04ffb22f..17b0d371b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -555,13 +555,13 @@ void komodo_netevent(std::vector message) { if ( (rand() % 10) == 0 ) { - fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); + //fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); komodo_sendmessage(2,2,"events",message); } } } - for (i=0; iPushMessage(message,payload); if ( numsent++ > maxpeers ) break; From c9446180181a0d093e7af2ef9f319d0c611cc53b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:28:55 -1100 Subject: [PATCH 3335/3904] Test --- src/cc/games/prices.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 4c9698593..3f71c786c 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -59,8 +59,8 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay eventid |= (uint32_t)payload[len+33] << 8; eventid |= (uint32_t)payload[len+34] << 16; eventid |= (uint32_t)payload[len+35] << 24; - for (i=0; i t%u %.4f ",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); fprintf(stderr," got payload, from %s %s/e%d\n",pubkey33_str(str,(uint8_t *)&pk),gametxid.GetHex().c_str(),eventid); return(0); From c3e822b232a59a0255cbc8fc4856b3ffd5ff2197 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:37:10 -1100 Subject: [PATCH 3336/3904] prices_update --- src/cc/games/prices.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 3f71c786c..b9f9bfc76 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -14,6 +14,12 @@ * * ******************************************************************************/ + +void prices_update(uint32_t timestamp,uint32_t uprice) +{ + fprintf(stderr,"%t%u %.4f ",timstamp,uprice); +} + // game specific code for daemon void games_packitemstr(char *packitemstr,struct games_packitem *item) { @@ -61,8 +67,9 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay eventid |= (uint32_t)payload[len+35] << 24; for (i=0; i t%u %.4f ",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); - fprintf(stderr," got payload, from %s %s/e%d\n",pubkey33_str(str,(uint8_t *)&pk),gametxid.GetHex().c_str(),eventid); + prices_update((uint32_t)(price >> 32),(uint32_t)(price & 0xffffffff)/10000); + //fprintf(stderr,"%llu -> t%u %.4f ",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); + //fprintf(stderr," got payload, from %s %s/e%d\n",pubkey33_str(str,(uint8_t *)&pk),gametxid.GetHex().c_str(),eventid); return(0); } else return(-1); } From c428d5b8cb86f09cc4c0b6d074f0707b4d472dfe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:39:18 -1100 Subject: [PATCH 3337/3904] Timestamp --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index b9f9bfc76..a103c5f70 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -17,7 +17,7 @@ void prices_update(uint32_t timestamp,uint32_t uprice) { - fprintf(stderr,"%t%u %.4f ",timstamp,uprice); + fprintf(stderr,"%t%u %.4f ",timestamp,uprice); } // game specific code for daemon From 1b86b9a1a36644bb5795dfb0cc7c172b5addfe21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:39:54 -1100 Subject: [PATCH 3338/3904] Fix --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index a103c5f70..c57fd5c36 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -17,7 +17,7 @@ void prices_update(uint32_t timestamp,uint32_t uprice) { - fprintf(stderr,"%t%u %.4f ",timestamp,uprice); + fprintf(stderr,"%t%u %.4f\n",timestamp,(double)uprice/1000); } // game specific code for daemon From 837200f4eec248e53c87c9ec7f8e93edd17655bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:40:41 -1100 Subject: [PATCH 3339/3904] -% --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index c57fd5c36..f042b6b1f 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -17,7 +17,7 @@ void prices_update(uint32_t timestamp,uint32_t uprice) { - fprintf(stderr,"%t%u %.4f\n",timestamp,(double)uprice/1000); + fprintf(stderr,"t%u %.4f\n",timestamp,(double)uprice/1000); } // game specific code for daemon From 76bcf303657bec09079e52fa615a985bbd2a28e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:42:07 -1100 Subject: [PATCH 3340/3904] -/10000 --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index f042b6b1f..29ca9759e 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -67,7 +67,7 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay eventid |= (uint32_t)payload[len+35] << 24; for (i=0; i> 32),(uint32_t)(price & 0xffffffff)/10000); + prices_update((uint32_t)(price >> 32),(uint32_t)(price & 0xffffffff)); //fprintf(stderr,"%llu -> t%u %.4f ",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); //fprintf(stderr," got payload, from %s %s/e%d\n",pubkey33_str(str,(uint8_t *)&pk),gametxid.GetHex().c_str(),eventid); return(0); From 1717fb6d87d5203149bfd239fc062a47d11b496b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:42:56 -1100 Subject: [PATCH 3341/3904] -print --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 7987c45a0..ed3dae051 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -55,7 +55,7 @@ void *gamesiterate(struct games_state *rs) { #ifdef STANDALONE price = get_btcusd(); - fprintf(stderr,"%llu -> t%u %.4f\n",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); + //fprintf(stderr,"%llu -> t%u %.4f\n",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); issue_games_events(rs,Gametxidstr,eventid,price); eventid++; sleep(10); From c993184197994d899a33073d3ef5b4b51c62168e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:45:39 -1100 Subject: [PATCH 3342/3904] 10000 --- src/cc/games/prices.c | 2 +- src/cc/games/prices.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index ed3dae051..67e66bfed 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -138,7 +138,7 @@ uint64_t get_btcusd() if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 && (usd= jobj(bpi,(char *)"USD")) != 0 ) { btcusd = jdouble(usd,(char *)"rate_float") * SATOSHIDEN; - x = ((uint64_t)time(NULL) << 32) | (btcusd / 10000); + x = ((uint64_t)time(NULL) << 32) | ((btcusd / 10000) & 0xffffffff); //printf("BTC/USD %.4f\n",dstr(btcusd)); } free_json(pjson); diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 29ca9759e..7428dfb3b 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -17,7 +17,7 @@ void prices_update(uint32_t timestamp,uint32_t uprice) { - fprintf(stderr,"t%u %.4f\n",timestamp,(double)uprice/1000); + fprintf(stderr,"t%u %.4f\n",timestamp,(double)uprice/10000); } // game specific code for daemon From a2d44907bd3009b333ba75bd37fd60a2b57afc4f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 01:48:14 -1100 Subject: [PATCH 3343/3904] Is mine --- src/cc/games/prices.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 7428dfb3b..d3f74a287 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -15,9 +15,9 @@ ******************************************************************************/ -void prices_update(uint32_t timestamp,uint32_t uprice) +void prices_update(uint32_t timestamp,uint32_t uprice,int32_t ismine) { - fprintf(stderr,"t%u %.4f\n",timestamp,(double)uprice/10000); + fprintf(stderr,"%s t%u %.4f\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000); } // game specific code for daemon @@ -67,7 +67,7 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay eventid |= (uint32_t)payload[len+35] << 24; for (i=0; i> 32),(uint32_t)(price & 0xffffffff)); + prices_update((uint32_t)(price >> 32),(uint32_t)(price & 0xffffffff),pk == pubkey2pk(Mypubkey())); //fprintf(stderr,"%llu -> t%u %.4f ",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); //fprintf(stderr," got payload, from %s %s/e%d\n",pubkey33_str(str,(uint8_t *)&pk),gametxid.GetHex().c_str(),eventid); return(0); From 3d425a23fd790bf83592471e1914ba16cf4ef4c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:07:01 -1100 Subject: [PATCH 3344/3904] Net_change --- src/cc/games/prices.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 67e66bfed..421fb8ff0 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -4,6 +4,7 @@ #include #define SATOSHIDEN ((uint64_t)100000000L) #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"prices",cmdstr,0,0,0) +extern int64_t Net_change; /* In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. @@ -59,6 +60,11 @@ void *gamesiterate(struct games_state *rs) issue_games_events(rs,Gametxidstr,eventid,price); eventid++; sleep(10); + switch ( getch() ) + { + case '+': Net_change++; break; + case '-': Net_change--; break; + } /*if ( (counter++ % 10) == 0 ) doupdate(); c = games_readevent(rs); @@ -106,6 +112,7 @@ void *gamesiterate(struct games_state *rs) #ifdef STANDALONE #include #include "dapps/dappstd.c" +int64_t Net_change; char *send_curl(char *url,char *fname) { @@ -132,14 +139,16 @@ cJSON *get_urljson(char *url,char *fname) uint64_t get_btcusd() { - cJSON *pjson,*bpi,*usd; uint64_t x,btcusd = 0; + cJSON *pjson,*bpi,*usd; uint64_t x,newprice,mult,btcusd = 0; if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json",(char *)"/tmp/oraclefeed.json")) != 0 ) { if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 && (usd= jobj(bpi,(char *)"USD")) != 0 ) { btcusd = jdouble(usd,(char *)"rate_float") * SATOSHIDEN; - x = ((uint64_t)time(NULL) << 32) | ((btcusd / 10000) & 0xffffffff); - //printf("BTC/USD %.4f\n",dstr(btcusd)); + mult = SATOSHIDEN + Net_change*100000; + newprice = (btcusd * mult) / SATOSHIDEN; + x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); + printf("BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); } free_json(pjson); } From 9363ef04111d567bf316ee2def799a57ad5edce2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:10:14 -1100 Subject: [PATCH 3345/3904] cursesd --- src/cc/games/prices.c | 6 ++++++ src/cc/games/tetris.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 421fb8ff0..9d3014fdb 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -2,6 +2,12 @@ #include "prices.h" #include #include +#ifdef BUILD_GAMESCC +#include "../rogue/cursesd.h" +#else +#include +#endif + #define SATOSHIDEN ((uint64_t)100000000L) #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"prices",cmdstr,0,0,0) extern int64_t Net_change; diff --git a/src/cc/games/tetris.c b/src/cc/games/tetris.c index 254d324a8..711170b0d 100644 --- a/src/cc/games/tetris.c +++ b/src/cc/games/tetris.c @@ -43,7 +43,7 @@ int32_t tetrisdata(struct games_player *P,void *ptr) #include #ifdef BUILD_GAMESCC -#include "rogue/cursesd.h" +#include "../rogue/cursesd.h" #else #include #endif From f3123a4d5b40a205fff13664dc188c02cddf52cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:12:25 -1100 Subject: [PATCH 3346/3904] Test --- src/cc/games/prices.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 9d3014fdb..0856eaa32 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -151,8 +151,8 @@ uint64_t get_btcusd() if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 && (usd= jobj(bpi,(char *)"USD")) != 0 ) { btcusd = jdouble(usd,(char *)"rate_float") * SATOSHIDEN; - mult = SATOSHIDEN + Net_change*100000; - newprice = (btcusd * mult) / SATOSHIDEN; + mult = 10000 + Net_change*10; + newprice = (btcusd * mult) / 10000; x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); printf("BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); } From 3da222eae80b71ed44de24f4f8e1deba536554b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:14:33 -1100 Subject: [PATCH 3347/3904] Activate curses --- src/cc/games/prices.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 0856eaa32..b0a16a3cc 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -51,6 +51,9 @@ void *gamesiterate(struct games_state *rs) bool running = true; uint32_t eventid = 0; int64_t price; if ( rs->guiflag != 0 || rs->sleeptime != 0 ) { + initscr(); // initialize curses + cbreak(); // pass key presses to program, but not signals + noecho(); // don't echo key presses to screen } while ( running != 0 ) { From 86491b25f022a553a27fdc371fdeb53f95fa7eb8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:18:33 -1100 Subject: [PATCH 3348/3904] Test --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index b0a16a3cc..7d3daef1f 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -157,7 +157,7 @@ uint64_t get_btcusd() mult = 10000 + Net_change*10; newprice = (btcusd * mult) / 10000; x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); - printf("BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); + fprintf(stderr,"BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); } free_json(pjson); } From d87dcb4d44d197b5feafebbc85c0a67291650053 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:25:14 -1100 Subject: [PATCH 3349/3904] Display --- src/cc/games/prices.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 7d3daef1f..b6bb6a640 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -148,7 +148,7 @@ cJSON *get_urljson(char *url,char *fname) uint64_t get_btcusd() { - cJSON *pjson,*bpi,*usd; uint64_t x,newprice,mult,btcusd = 0; + cJSON *pjson,*bpi,*usd; char str[512]; uint64_t x,newprice,mult,btcusd = 0; if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json",(char *)"/tmp/oraclefeed.json")) != 0 ) { if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 && (usd= jobj(bpi,(char *)"USD")) != 0 ) @@ -157,7 +157,10 @@ uint64_t get_btcusd() mult = 10000 + Net_change*10; newprice = (btcusd * mult) / 10000; x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); - fprintf(stderr,"BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); + sprintf(str,"BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); + mvaddstr(0, 0, str); + clrtoeol(); + refresh(); } free_json(pjson); } From 829e9811647042f87441b4a2ea1c167f070c5c72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:27:58 -1100 Subject: [PATCH 3350/3904] doupdate --- src/cc/games/prices.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index b6bb6a640..3ac7e76fe 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -68,6 +68,7 @@ void *gamesiterate(struct games_state *rs) //fprintf(stderr,"%llu -> t%u %.4f\n",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); issue_games_events(rs,Gametxidstr,eventid,price); eventid++; + doupdate(); sleep(10); switch ( getch() ) { @@ -160,7 +161,7 @@ uint64_t get_btcusd() sprintf(str,"BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); mvaddstr(0, 0, str); clrtoeol(); - refresh(); + doupdate(); } free_json(pjson); } From 6c14369eac9c83af9fab18b9527d1b542728193c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:44:28 -1100 Subject: [PATCH 3351/3904] timeout(0); --- src/cc/games/prices.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 3ac7e76fe..97c617be7 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -54,6 +54,7 @@ void *gamesiterate(struct games_state *rs) initscr(); // initialize curses cbreak(); // pass key presses to program, but not signals noecho(); // don't echo key presses to screen + timeout(0); } while ( running != 0 ) { From 46bd37f80083ca7fb5ab27e6d87ff56585935d55 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 02:50:42 -1100 Subject: [PATCH 3352/3904] -print --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index d3f74a287..9db720907 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -17,7 +17,7 @@ void prices_update(uint32_t timestamp,uint32_t uprice,int32_t ismine) { - fprintf(stderr,"%s t%u %.4f\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000); + //fprintf(stderr,"%s t%u %.4f\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000); } // game specific code for daemon From 89913fa6ae498be1d9bbe96dcf86694182a0e579 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 03:46:03 -1100 Subject: [PATCH 3353/3904] pricedata --- src/cc/games/prices.c | 6 ------ src/cc/games/prices.cpp | 40 +++++++++++++++++++++++++++++++++++++++- src/cc/games/tetris.cpp | 6 ++++++ src/cc/gamescc.cpp | 2 +- src/cc/gamescc.h | 6 +++++- 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 97c617be7..3d4a65e14 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -12,12 +12,6 @@ #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"prices",cmdstr,0,0,0) extern int64_t Net_change; -/* - In order to port a game into gamesCC, the RNG needs to be seeded with the gametxid seed, also events needs to be broadcast using issue_games_events. Also the game engine needs to be daemonized, preferably by putting all globals into a single data structure. - - also, the standalone game needs to support argv of seed gametxid, along with replay args - */ - int random_tetromino(struct games_state *rs) { rs->seed = _games_rngnext(rs->seed); diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 9db720907..a903355e4 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -14,10 +14,48 @@ * * ******************************************************************************/ +UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t inputsum,price; CPubKey mypk; + if ( params != 0 && cJSON_GetArraySize(params) == 1 ) + { + if ( cclib_parsehash(&price,jitem(params,0),8) < 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parsehash")); + } + mypk = pubkey2pk(Mypubkey()); + if ( amount > GAMES_TXFEE ) + { + if ( (inputsum= AddNormalinputs(mtx,mypk,GAMES_TXFEE,64)) >= GAMES_TXFEE ) + { + rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,CScript() << OP_RETURN << price); + return(games_rawtxresult(result,rawtx,1)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough funds")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","amount too small")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parse")); + } + return(result); +} void prices_update(uint32_t timestamp,uint32_t uprice,int32_t ismine) { - //fprintf(stderr,"%s t%u %.4f\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000); + fprintf(stderr,"%s t%u %.4f %16llx\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000,(long long)(timestamp<<32) | uprice); } // game specific code for daemon diff --git a/src/cc/games/tetris.cpp b/src/cc/games/tetris.cpp index f1b6416ba..12c443e1e 100644 --- a/src/cc/games/tetris.cpp +++ b/src/cc/games/tetris.cpp @@ -66,6 +66,12 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay } else return(-1); } +UniValue games_oracledata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result; + return(result); +} + bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true); diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 17b0d371b..77b463822 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1731,7 +1731,7 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,opret); - return(games_rawtxresult(result,rawtx,1)); + return(games_rawtxresult(resulft,rawtx,1)); } else { diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 63d029b0a..19f3f66cf 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -46,6 +46,7 @@ std::string Games_pname; { (char *)MYCCNAME, (char *)"highlander", (char *)"gametxid", 1, 1, 'H', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"events", (char *)"eventshex [gametxid [eventid]]", 1, 3, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"pricedata", (char *)"hexstr", 1, 1, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -65,6 +66,7 @@ UniValue games_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ @@ -100,7 +102,9 @@ if ( cp->evalcode == EVAL_GAMES ) \ else if ( strcmp(method,"highlander") == 0 ) \ return(games_highlander(txfee,cp,params)); \ else if ( strcmp(method,"fund") == 0 ) \ - return(games_fund(txfee,cp,params)); \ + return(games_fund(txfee,cp,params)); \ + else if ( strcmp(method,"pricedata") == 0 ) \ + return(games_pricedata(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From 9e4f5663da07dcfcafbdf12b172da00263bc385c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 03:49:23 -1100 Subject: [PATCH 3354/3904] Test --- src/cc/games/prices.cpp | 22 ++++++++-------------- src/cc/gamescc.cpp | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index a903355e4..88fdab88a 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -14,35 +14,29 @@ * * ******************************************************************************/ +UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); + UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); std::string rawtx; int64_t inputsum,price; CPubKey mypk; if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { - if ( cclib_parsehash(&price,jitem(params,0),8) < 0 ) + if ( cclib_parsehash((uint8_t *)&price,jitem(params,0),8) < 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parsehash")); } mypk = pubkey2pk(Mypubkey()); - if ( amount > GAMES_TXFEE ) + if ( (inputsum= AddNormalinputs(mtx,mypk,GAMES_TXFEE,64)) >= GAMES_TXFEE ) { - if ( (inputsum= AddNormalinputs(mtx,mypk,GAMES_TXFEE,64)) >= GAMES_TXFEE ) - { - rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,CScript() << OP_RETURN << price); - return(games_rawtxresult(result,rawtx,1)); - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","not enough funds")); - } + rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,CScript() << OP_RETURN << price); + return(games_rawtxresult(result,rawtx,1)); } else { result.push_back(Pair("result","error")); - result.push_back(Pair("error","amount too small")); + result.push_back(Pair("error","not enough funds")); } } else @@ -55,7 +49,7 @@ UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params void prices_update(uint32_t timestamp,uint32_t uprice,int32_t ismine) { - fprintf(stderr,"%s t%u %.4f %16llx\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000,(long long)(timestamp<<32) | uprice); + fprintf(stderr,"%s t%u %.4f %16llx\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000,(long long)((uint64_t)timestamp<<32) | uprice); } // game specific code for daemon diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 77b463822..17b0d371b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1731,7 +1731,7 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,opret); - return(games_rawtxresult(resulft,rawtx,1)); + return(games_rawtxresult(result,rawtx,1)); } else { From c0798791e9d99b235d4efcf493a18bf9ee064d00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:05:10 -1100 Subject: [PATCH 3355/3904] Bet --- src/cc/games/prices.cpp | 11 +++++++---- src/cc/gamescc.h | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 88fdab88a..03fcff33a 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -19,17 +19,20 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; int64_t inputsum,price; CPubKey mypk; - if ( params != 0 && cJSON_GetArraySize(params) == 1 ) + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey mypk; + if ( params != 0 && cJSON_GetArraySize(params) == 2 ) { - if ( cclib_parsehash((uint8_t *)&price,jitem(params,0),8) < 0 ) + amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; + if ( cclib_parsehash((uint8_t *)&price,jitem(params,1),8) < 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parsehash")); } mypk = pubkey2pk(Mypubkey()); - if ( (inputsum= AddNormalinputs(mtx,mypk,GAMES_TXFEE,64)) >= GAMES_TXFEE ) + gamespk = GetUnspendable(cp,0); + if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,CScript() << OP_RETURN << price); return(games_rawtxresult(result,rawtx,1)); } diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 19f3f66cf..bfaf036d0 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -46,7 +46,7 @@ std::string Games_pname; { (char *)MYCCNAME, (char *)"highlander", (char *)"gametxid", 1, 1, 'H', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"events", (char *)"eventshex [gametxid [eventid]]", 1, 3, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, ' ', EVAL_GAMES }, \ - { (char *)MYCCNAME, (char *)"pricedata", (char *)"hexstr", 1, 1, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"bet", (char *)"amount hexstr", 2, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -66,7 +66,7 @@ UniValue games_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); -UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ @@ -103,8 +103,8 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_highlander(txfee,cp,params)); \ else if ( strcmp(method,"fund") == 0 ) \ return(games_fund(txfee,cp,params)); \ - else if ( strcmp(method,"pricedata") == 0 ) \ - return(games_pricedata(txfee,cp,params)); \ + else if ( strcmp(method,"bet") == 0 ) \ + return(games_bet(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From 29fc5b9ea069e79f0477619c26fb587e79fa3caa Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:05:50 -1100 Subject: [PATCH 3356/3904] Gamespk --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 03fcff33a..27d41ca9b 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -19,7 +19,7 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey mypk; + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey gamespk,mypk; if ( params != 0 && cJSON_GetArraySize(params) == 2 ) { amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; From 8e4a613eb06e25db6e32d97edb67df763b7d36c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:06:39 -1100 Subject: [PATCH 3357/3904] games_bet --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 27d41ca9b..e099d57af 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -16,7 +16,7 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); -UniValue games_pricedata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey gamespk,mypk; From 7c1c706f18a7062bae09d59df1754e8afae85a77 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:10:39 -1100 Subject: [PATCH 3358/3904] Test --- src/cc/games/prices.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index e099d57af..296d80a8c 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -28,6 +28,7 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parsehash")); } + fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price); mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) From 3de3e931bb5afee45f9cd1369676d3cbb6a9c648 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:12:41 -1100 Subject: [PATCH 3359/3904] Test --- src/cc/gamescc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index bfaf036d0..52627cd1c 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -109,7 +109,6 @@ if ( cp->evalcode == EVAL_GAMES ) \ { \ result.push_back(Pair("result","error")); \ result.push_back(Pair("error","invalid gamescc method")); \ - result.push_back(Pair("method",method)); \ return(result); \ } \ } From 2bf9af5f57333ddfb49df056d89e5a2dd8949dfc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:13:19 -1100 Subject: [PATCH 3360/3904] Test --- src/cc/gamescc.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 52627cd1c..af888ed05 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -71,6 +71,7 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ { \ + UniValue res; \ if ( strcmp(method,"rng") == 0 ) \ return(games_rng(txfee,cp,params)); \ else if ( strcmp(method,"rngnext") == 0 ) \ @@ -107,9 +108,9 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_bet(txfee,cp,params)); \ else \ { \ - result.push_back(Pair("result","error")); \ - result.push_back(Pair("error","invalid gamescc method")); \ - return(result); \ + res.push_back(Pair("result","error")); \ + res.push_back(Pair("error","invalid gamescc method")); \ + return(res); \ } \ } #endif From 2660c2b7f8d43f10c13ea003e73505258c8fc4de Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:50:17 -1100 Subject: [PATCH 3361/3904] issue_bet --- src/cc/games/prices.c | 34 ++++++++++++++++++++++++++++++---- src/cc/gamescc.h | 7 +++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 3d4a65e14..52ddc477c 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -10,7 +10,7 @@ #define SATOSHIDEN ((uint64_t)100000000L) #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"prices",cmdstr,0,0,0) -extern int64_t Net_change; +extern int64_t Net_change,Betsize; int random_tetromino(struct games_state *rs) { @@ -39,6 +39,7 @@ struct games_state globalR; extern char Gametxidstr[]; int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eventid,gamesevent c); uint64_t get_btcusd(); +int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize); void *gamesiterate(struct games_state *rs) { @@ -61,7 +62,8 @@ void *gamesiterate(struct games_state *rs) #ifdef STANDALONE price = get_btcusd(); //fprintf(stderr,"%llu -> t%u %.4f\n",(long long)price,(uint32_t)(price >> 32),(double)(price & 0xffffffff)/10000); - issue_games_events(rs,Gametxidstr,eventid,price); + //issue_games_events(rs,Gametxidstr,eventid,price); + issue_bet(rs,price,Betsize); eventid++; doupdate(); sleep(10); @@ -69,6 +71,10 @@ void *gamesiterate(struct games_state *rs) { case '+': Net_change++; break; case '-': Net_change--; break; + case '0': Net_change = 0; break; + case '$': Betsize = SATOSHIDEN; break; + case '^': Betsize += (Betsize >> 3); break; + case '/': Betsize -= (Betsize >> 3); break; } /*if ( (counter++ % 10) == 0 ) doupdate(); @@ -117,7 +123,7 @@ void *gamesiterate(struct games_state *rs) #ifdef STANDALONE #include #include "dapps/dappstd.c" -int64_t Net_change; +int64_t Net_change,Betsize; char *send_curl(char *url,char *fname) { @@ -153,7 +159,7 @@ uint64_t get_btcusd() mult = 10000 + Net_change*10; newprice = (btcusd * mult) / 10000; x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); - sprintf(str,"BTC/USD %.4f Net_change %lld * 0.001 -> %.4f\n",dstr(btcusd),(long long)Net_change,dstr(newprice)); + sprintf(str,"BTC/USD %.4f Net_change %lld * 0.001 -> Betsize %.8f %.4f\n",dstr(btcusd),(long long)Net_change,dstr(Betsize),dstr(newprice)); mvaddstr(0, 0, str); clrtoeol(); doupdate(); @@ -218,6 +224,26 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve } else return(0); } +int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize) +{ + char params[512],hexstr[64],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; + sprintf(params,"[\"bet\",\"17\",\"[%.8f,%%22%s%%22]\"]",dstr(x),hexstr); + if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) + { + retval = 0; + fprintf(stderr,"%s\n",jprint(resobj,0)); + } + free_json(retjson); + } + free(retstr); + } + return(retval); +} + int prices(int argc, char **argv) { struct games_state *rs = &globalR; diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index af888ed05..52627cd1c 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -71,7 +71,6 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ { \ - UniValue res; \ if ( strcmp(method,"rng") == 0 ) \ return(games_rng(txfee,cp,params)); \ else if ( strcmp(method,"rngnext") == 0 ) \ @@ -108,9 +107,9 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_bet(txfee,cp,params)); \ else \ { \ - res.push_back(Pair("result","error")); \ - res.push_back(Pair("error","invalid gamescc method")); \ - return(res); \ + result.push_back(Pair("result","error")); \ + result.push_back(Pair("error","invalid gamescc method")); \ + return(result); \ } \ } #endif From 72922243f989904eb2cbe97bc60dce2d2bf52d0b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:53:38 -1100 Subject: [PATCH 3362/3904] Fix --- src/cc/games/prices.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 52ddc477c..93c89ab83 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -227,7 +227,13 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize) { char params[512],hexstr[64],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; - sprintf(params,"[\"bet\",\"17\",\"[%.8f,%%22%s%%22]\"]",dstr(x),hexstr); + memset(hexstr,0,sizeof(hexstr)); + for (i=0; i<8; i++) + { + sprintf(&hexstr[i<<1],"%02x",x & 0xff); + x >>= 8; + } + sprintf(params,"[\"bet\",\"17\",\"[%.8f,%%22%s%%22]\"]",dstr(betsize),hexstr); if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) From 251d6fb88f962c9b4fbaf165b42312d4138f778e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:54:29 -1100 Subject: [PATCH 3363/3904] I --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 93c89ab83..13b0c4934 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -226,7 +226,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize) { - char params[512],hexstr[64],*retstr; cJSON *retjson,*resobj; int32_t retval = -1; + char params[512],hexstr[64],*retstr; cJSON *retjson,*resobj; int32_t i,retval = -1; memset(hexstr,0,sizeof(hexstr)); for (i=0; i<8; i++) { From 05b91ae06385927e506d040f330a5148057e2d79 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 04:55:34 -1100 Subject: [PATCH 3364/3904] Test --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 13b0c4934..f33838c64 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -230,7 +230,7 @@ int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize) memset(hexstr,0,sizeof(hexstr)); for (i=0; i<8; i++) { - sprintf(&hexstr[i<<1],"%02x",x & 0xff); + sprintf(&hexstr[i<<1],"%02x",(uint8_t)(x & 0xff)); x >>= 8; } sprintf(params,"[\"bet\",\"17\",\"[%.8f,%%22%s%%22]\"]",dstr(betsize),hexstr); From fb132238f0f0fcece0e0d657700852aa0edee441 Mon Sep 17 00:00:00 2001 From: "Anton \"TonyL\" Lysakov" Date: Wed, 27 Mar 2019 23:36:58 +0700 Subject: [PATCH 3365/3904] Create cryptoconditions.py Forgot that we using it as a "library" for other CC tests. So deletion was a mistake. --- qa/rpc-tests/cryptoconditions.py | 690 +++++++++++++++++++++++++++++++ 1 file changed, 690 insertions(+) create mode 100644 qa/rpc-tests/cryptoconditions.py diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py new file mode 100644 index 000000000..d5456e801 --- /dev/null +++ b/qa/rpc-tests/cryptoconditions.py @@ -0,0 +1,690 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import assert_equal, assert_greater_than, \ + initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ + stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises + +import time +from decimal import Decimal +from random import choice +from string import ascii_uppercase + +def assert_success(result): + assert_equal(result['result'], 'success') + +def assert_error(result): + assert_equal(result['result'], 'error') + +def generate_random_string(length): + random_string = ''.join(choice(ascii_uppercase) for i in range(length)) + return random_string + +class CryptoConditionsTest (BitcoinTestFramework): + + def setup_chain(self): + print("Initializing CC test directory "+self.options.tmpdir) + self.num_nodes = 2 + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + + def send_and_mine(self, xtn, rpc_connection): + txid = rpc_connection.sendrawtransaction(xtn) + assert txid, 'got txid' + # we need the tx above to be confirmed in the next block + rpc_connection.generate(1) + return txid + + def run_faucet_tests(self): + rpc = self.rpc + rpc1 = self.rpc1 + + # basic sanity tests + result = rpc.getwalletinfo() + assert_greater_than(result['txcount'], 100) + assert_greater_than(result['balance'], 0.0) + balance = result['balance'] + + faucet = rpc.faucetaddress() + assert_equal(faucet['result'], 'success') + # verify all keys look like valid AC addrs, could be better + for x in ['myCCAddress(Faucet)', 'FaucetCCAddress', 'FaucetCCTokensAddress', 'myaddress', 'FaucetNormalAddress']: + assert_equal(faucet[x][0], 'R') + + result = rpc.faucetaddress(self.pubkey) + assert_success(result) + # test that additional CCaddress key is returned + for x in ['myCCAddress(Faucet)', 'FaucetCCAddress', 'FaucetCCTokensAddress', 'myaddress', 'FaucetNormalAddress']: + assert_equal(result[x][0], 'R') + + # no funds in the faucet yet + result = rpc.faucetget() + assert_error(result) + + result = rpc.faucetinfo() + assert_success(result) + + result = rpc.faucetfund("0") + assert_error(result) + + result = rpc.faucetfund("-1") + assert_error(result) + + # we need at least 1 + txfee to get + result = rpc.faucetfund("2") + assert_success(result) + assert result['hex'], "hex key found" + + # broadcast the xtn + result = rpc.sendrawtransaction(result['hex']) + txid = result[0] + assert txid, "found txid" + + # we need the tx above to be confirmed in the next block + rpc.generate(1) + self.sync_all() + + result = rpc.getwalletinfo() + # minus one block reward + balance2 = result['balance'] - 100000 + # make sure our balance is less now + assert_greater_than(balance, balance2) + + result = rpc.faucetinfo() + assert_success(result) + assert_greater_than( result['funding'], 0 ) + + # claiming faucet on second node + faucetgethex = rpc1.faucetget() + assert_success(faucetgethex) + assert faucetgethex['hex'], "hex key found" + + balance1 = rpc1.getwalletinfo()['balance'] + + # try to broadcast the faucetget transaction + result = self.send_and_mine(faucetgethex['hex'], rpc1) + assert txid, "transaction broadcasted" + + balance2 = rpc1.getwalletinfo()['balance'] + assert_greater_than(balance2, balance1) + + self.sync_all() + + def run_dice_tests(self): + rpc = self.nodes[0] + rpc1 = self.nodes[1] + self.sync_all() + + # have to generate few blocks on second node to be able to place bets + rpc1.generate(10) + result = rpc1.getbalance() + assert_greater_than(result, 100000) + + dice = rpc.diceaddress() + assert_equal(dice['result'], 'success') + for x in ['myCCAddress(Dice)', 'DiceCCAddress', 'DiceCCTokensAddress', 'myaddress', 'DiceNormalAddress']: + assert_equal(dice[x][0], 'R') + + dice = rpc.diceaddress(self.pubkey) + assert_equal(dice['result'], 'success') + for x in ['myCCAddress(Dice)', 'DiceCCAddress', 'DiceCCTokensAddress', 'myaddress', 'DiceNormalAddress']: + assert_equal(dice[x][0], 'R') + + # no dice created yet + result = rpc.dicelist() + assert_equal(result, []) + + # creating dice plan with too long name (>8 chars) + result = rpc.dicefund("THISISTOOLONG", "10000", "10", "10000", "10", "5") + assert_error(result) + + # creating dice plan with < 100 funding + result = rpc.dicefund("LUCKY","10","1","10000","10","5") + assert_error(result) + + # creating dice plan with 0 blocks timeout + result = rpc.dicefund("LUCKY","10","1","10000","10","0") + assert_error(result) + + # creating dice plan + dicefundtx = rpc.dicefund("LUCKY","1000","1","800","10","5") + diceid = self.send_and_mine(dicefundtx['hex'], rpc) + + # checking if it in plans list now + result = rpc.dicelist() + assert_equal(result[0], diceid) + + # set dice name for futher usage + dicename = "LUCKY" + + # adding zero funds to plan + result = rpc.diceaddfunds(dicename,diceid,"0") + assert_error(result) + + # adding negative funds to plan + result = rpc.diceaddfunds(dicename,diceid,"-1") + assert_error(result) + + # adding funds to plan + addfundstx = rpc.diceaddfunds(dicename,diceid,"1100") + result = self.send_and_mine(addfundstx['hex'], rpc) + + # checking if funds added to plan + result = rpc.diceinfo(diceid) + assert_equal(result["funding"], "2100.00000000") + + # not valid dice info checking + result = rpc.diceinfo("invalid") + assert_error(result) + + # placing 0 amount bet + result = rpc1.dicebet(dicename,diceid,"0","2") + assert_error(result) + + # placing negative amount bet + result = rpc1.dicebet(dicename,diceid,"-1","2") + assert_error(result) + + # placing bet more than maxbet + result = rpc1.dicebet(dicename,diceid,"900","2") + assert_error(result) + + # placing bet with amount more than funding + result = rpc1.dicebet(dicename,diceid,"3000","2") + assert_error(result) + + # placing bet with potential won more than funding + result = rpc1.dicebet(dicename,diceid,"750","9") + assert_error(result) + + # placing 0 odds bet + result = rpc1.dicebet(dicename,diceid,"1","0") + assert_error(result) + + # placing negative odds bet + result = rpc1.dicebet(dicename,diceid,"1","-1") + assert_error(result) + + # placing bet with odds more than allowed + result = rpc1.dicebet(dicename,diceid,"1","11") + assert_error(result) + + # placing bet with not correct dice name + result = rpc1.dicebet("nope",diceid,"100","2") + assert_error(result) + + # placing bet with not correct dice id + result = rpc1.dicebet(dicename,self.pubkey,"100","2") + assert_error(result) + + # have to make some entropy for the next test + entropytx = 0 + fundingsum = 1 + while entropytx < 110: + fundingsuminput = str(fundingsum) + fundinghex = rpc.diceaddfunds(dicename,diceid,fundingsuminput) + result = self.send_and_mine(fundinghex['hex'], rpc) + entropytx = entropytx + 1 + fundingsum = fundingsum + 1 + + rpc.generate(2) + self.sync_all() + + # valid bet placing + placebet = rpc1.dicebet(dicename,diceid,"100","2") + betid = self.send_and_mine(placebet["hex"], rpc1) + assert result, "bet placed" + + # check bet status + result = rpc1.dicestatus(dicename,diceid,betid) + assert_success(result) + + # note initial dice funding state at this point. + # TODO: track player balance somehow (hard to do because of mining and fees) + diceinfo = rpc.diceinfo(diceid) + funding = float(diceinfo['funding']) + + # # placing same amount bets with amount 1 and odds 1:3, checking if balance changed correct + # losscounter = 0 + # wincounter = 0 + # betcounter = 0 + # + # while (betcounter < 10): + # placebet = rpc1.dicebet(dicename,diceid,"1","2") + # betid = self.send_and_mine(placebet["hex"], rpc1) + # time.sleep(3) + # self.sync_all() + # finish = rpc.dicefinish(dicename,diceid,betid) + # self.send_and_mine(finish["hex"], rpc1) + # self.sync_all() + # time.sleep(3) + # betresult = rpc1.dicestatus(dicename,diceid,betid) + # betcounter = betcounter + 1 + # if betresult["status"] == "loss": + # losscounter = losscounter + 1 + # elif betresult["status"] == "win": + # wincounter = wincounter + 1 + # else: + # pass + # + # # funding balance should increase if player loss, decrease if player won + # fundbalanceguess = funding + losscounter - wincounter * 2 + # fundinfoactual = rpc.diceinfo(diceid) + # assert_equal(round(fundbalanceguess),round(float(fundinfoactual['funding']))) + + def run_token_tests(self): + rpc = self.nodes[0] + result = rpc.tokenaddress() + assert_success(result) + for x in ['myCCAddress(Tokens)', 'TokensNormalAddress', 'TokensNormalAddress', 'myaddress','TokensCCAddress']: + assert_equal(result[x][0], 'R') + + result = rpc.tokenaddress(self.pubkey) + assert_success(result) + for x in ['myCCAddress(Tokens)', 'TokensNormalAddress', 'TokensNormalAddress', 'myaddress','TokensCCAddress']: + assert_equal(result[x][0], 'R') + # there are no tokens created yet + result = rpc.tokenlist() + assert_equal(result, []) + + # trying to create token with negaive supply + result = rpc.tokencreate("NUKE", "-1987420", "no bueno supply") + assert_error(result) + + # creating token with name more than 32 chars + result = rpc.tokencreate("NUKE123456789012345678901234567890", "1987420", "name too long") + assert_error(result) + + # creating valid token + result = rpc.tokencreate("DUKE", "1987.420", "Duke's custom token") + assert_success(result) + + tokenid = self.send_and_mine(result['hex'], rpc) + + result = rpc.tokenlist() + assert_equal(result[0], tokenid) + + # get token balance for token with pubkey + result = rpc.tokenbalance(tokenid, self.pubkey) + assert_success(result) + assert_equal(result['balance'], 198742000000) + assert_equal(result['tokenid'], tokenid) + + # get token balance for token without pubkey + result = rpc.tokenbalance(tokenid) + assert_success(result) + assert_equal(result['balance'], 198742000000) + assert_equal(result['tokenid'], tokenid) + + # this is not a valid assetid + result = rpc.tokeninfo(self.pubkey) + assert_error(result) + + # check tokeninfo for valid token + result = rpc.tokeninfo(tokenid) + assert_success(result) + assert_equal(result['tokenid'], tokenid) + assert_equal(result['owner'], self.pubkey) + assert_equal(result['name'], "DUKE") + assert_equal(result['supply'], 198742000000) + assert_equal(result['description'], "Duke's custom token") + + # invalid numtokens ask + result = rpc.tokenask("-1", tokenid, "1") + assert_error(result) + + # invalid numtokens ask + result = rpc.tokenask("0", tokenid, "1") + assert_error(result) + + # invalid price ask + result = rpc.tokenask("1", tokenid, "-1") + assert_error(result) + + # invalid price ask + result = rpc.tokenask("1", tokenid, "0") + assert_error(result) + + # invalid tokenid ask + result = rpc.tokenask("100", "deadbeef", "1") + assert_error(result) + + # valid ask + tokenask = rpc.tokenask("100", tokenid, "7.77") + tokenaskhex = tokenask['hex'] + tokenaskid = self.send_and_mine(tokenask['hex'], rpc) + result = rpc.tokenorders(tokenid) + order = result[0] + assert order, "found order" + + # invalid ask fillunits + result = rpc.tokenfillask(tokenid, tokenaskid, "0") + assert_error(result) + + # invalid ask fillunits + result = rpc.tokenfillask(tokenid, tokenaskid, "-777") + assert_error(result) + + # valid ask fillunits + fillask = rpc.tokenfillask(tokenid, tokenaskid, "777") + result = self.send_and_mine(fillask['hex'], rpc) + txid = result[0] + assert txid, "found txid" + + # should be no token orders + result = rpc.tokenorders(tokenid) + assert_equal(result, []) + + # checking ask cancellation + testorder = rpc.tokenask("100", tokenid, "7.77") + testorderid = self.send_and_mine(testorder['hex'], rpc) + cancel = rpc.tokencancelask(tokenid, testorderid) + self.send_and_mine(cancel["hex"], rpc) + result = rpc.tokenorders(tokenid) + assert_equal(result, []) + + # invalid numtokens bid + result = rpc.tokenbid("-1", tokenid, "1") + assert_error(result) + + # invalid numtokens bid + result = rpc.tokenbid("0", tokenid, "1") + assert_error(result) + + # invalid price bid + result = rpc.tokenbid("1", tokenid, "-1") + assert_error(result) + + # invalid price bid + result = rpc.tokenbid("1", tokenid, "0") + assert_error(result) + + # invalid tokenid bid + result = rpc.tokenbid("100", "deadbeef", "1") + assert_error(result) + + tokenbid = rpc.tokenbid("100", tokenid, "10") + tokenbidhex = tokenbid['hex'] + tokenbidid = self.send_and_mine(tokenbid['hex'], rpc) + result = rpc.tokenorders(tokenid) + order = result[0] + assert order, "found order" + + # invalid bid fillunits + result = rpc.tokenfillbid(tokenid, tokenbidid, "0") + assert_error(result) + + # invalid bid fillunits + result = rpc.tokenfillbid(tokenid, tokenbidid, "-777") + assert_error(result) + + # valid bid fillunits + fillbid = rpc.tokenfillbid(tokenid, tokenbidid, "1000") + result = self.send_and_mine(fillbid['hex'], rpc) + txid = result[0] + assert txid, "found txid" + + # should be no token orders + result = rpc.tokenorders(tokenid) + assert_equal(result, []) + + # checking bid cancellation + testorder = rpc.tokenbid("100", tokenid, "7.77") + testorderid = self.send_and_mine(testorder['hex'], rpc) + cancel = rpc.tokencancelbid(tokenid, testorderid) + self.send_and_mine(cancel["hex"], rpc) + result = rpc.tokenorders(tokenid) + assert_equal(result, []) + + # invalid token transfer amount (have to add status to CC code!) + randompubkey = "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" + result = rpc.tokentransfer(tokenid,randompubkey,"0") + assert_error(result) + + # invalid token transfer amount (have to add status to CC code!) + result = rpc.tokentransfer(tokenid,randompubkey,"-1") + assert_error(result) + + # valid token transfer + sendtokens = rpc.tokentransfer(tokenid,randompubkey,"1") + self.send_and_mine(sendtokens["hex"], rpc) + result = rpc.tokenbalance(tokenid,randompubkey) + assert_equal(result["balance"], 1) + + def run_rewards_tests(self): + rpc = self.nodes[0] + result = rpc.rewardsaddress() + for x in ['myCCAddress(Rewards)', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: + assert_equal(result[x][0], 'R') + + result = rpc.rewardsaddress(self.pubkey) + for x in ['myCCAddress(Rewards)', 'myaddress', 'RewardsCCAddress', 'RewardsCCTokensAddress', 'RewardsNormalAddress']: + assert_equal(result[x][0], 'R') + + # no rewards yet + result = rpc.rewardslist() + assert_equal(result, []) + + # looking up non-existent reward should return error + result = rpc.rewardsinfo("none") + assert_error(result) + + # creating rewards plan with name > 8 chars, should return error + result = rpc.rewardscreatefunding("STUFFSTUFF", "7777", "25", "0", "10", "10") + assert_error(result) + + # creating rewards plan with 0 funding + result = rpc.rewardscreatefunding("STUFF", "0", "25", "0", "10", "10") + assert_error(result) + + # creating rewards plan with 0 maxdays + result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "0") + assert_error(result) + + # creating rewards plan with > 25% APR + result = rpc.rewardscreatefunding("STUFF", "7777", "30", "0", "10", "10") + assert_error(result) + + # creating valid rewards plan + result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "10") + assert result['hex'], 'got raw xtn' + fundingtxid = rpc.sendrawtransaction(result['hex']) + assert fundingtxid, 'got txid' + + # confirm the above xtn + rpc.generate(1) + result = rpc.rewardsinfo(fundingtxid) + assert_success(result) + assert_equal(result['name'], 'STUFF') + assert_equal(result['APR'], "25.00000000") + assert_equal(result['minseconds'], 0) + assert_equal(result['maxseconds'], 864000) + assert_equal(result['funding'], "7777.00000000") + assert_equal(result['mindeposit'], "10.00000000") + assert_equal(result['fundingtxid'], fundingtxid) + + # checking if new plan in rewardslist + result = rpc.rewardslist() + assert_equal(result[0], fundingtxid) + + # creating reward plan with already existing name, should return error + result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "10") + assert_error(result) + + # add funding amount must be positive + result = rpc.rewardsaddfunding("STUFF", fundingtxid, "-1") + assert_error(result) + + # add funding amount must be positive + result = rpc.rewardsaddfunding("STUFF", fundingtxid, "0") + assert_error(result) + + # adding valid funding + result = rpc.rewardsaddfunding("STUFF", fundingtxid, "555") + addfundingtxid = self.send_and_mine(result['hex'], rpc) + assert addfundingtxid, 'got funding txid' + + # checking if funding added to rewardsplan + result = rpc.rewardsinfo(fundingtxid) + assert_equal(result['funding'], "8332.00000000") + + # trying to lock funds, locking funds amount must be positive + result = rpc.rewardslock("STUFF", fundingtxid, "-5") + assert_error(result) + + # trying to lock funds, locking funds amount must be positive + result = rpc.rewardslock("STUFF", fundingtxid, "0") + assert_error(result) + + # trying to lock less than the min amount is an error + result = rpc.rewardslock("STUFF", fundingtxid, "7") + assert_error(result) + + # locking funds in rewards plan + result = rpc.rewardslock("STUFF", fundingtxid, "10") + assert_success(result) + locktxid = result['hex'] + assert locktxid, "got lock txid" + + # locktxid has not been broadcast yet + result = rpc.rewardsunlock("STUFF", fundingtxid, locktxid) + assert_error(result) + + # broadcast xtn + txid = rpc.sendrawtransaction(locktxid) + assert txid, 'got txid from sendrawtransaction' + + # confirm the xtn above + rpc.generate(1) + + # will not unlock since reward amount is less than tx fee + result = rpc.rewardsunlock("STUFF", fundingtxid, locktxid) + assert_error(result) + + def run_oracles_tests(self): + rpc = self.nodes[0] + rpc1 = self.nodes[1] + + result = rpc1.oraclesaddress() + + result = rpc.oraclesaddress() + assert_success(result) + + for x in ['OraclesCCAddress', 'OraclesNormalAddress', 'myCCAddress(Oracles)','OraclesCCTokensAddress', 'myaddress']: + assert_equal(result[x][0], 'R') + + result = rpc.oraclesaddress(self.pubkey) + assert_success(result) + for x in ['OraclesCCAddress', 'OraclesNormalAddress', 'myCCAddress(Oracles)','OraclesCCTokensAddress', 'myaddress']: + assert_equal(result[x][0], 'R') + + # there are no oracles created yet + result = rpc.oracleslist() + assert_equal(result, []) + + # looking up non-existent oracle should return error. + result = rpc.oraclesinfo("none") + assert_error(result) + + # attempt to create oracle with not valid data type should return error + result = rpc.oraclescreate("Test", "Test", "Test") + assert_error(result) + + # attempt to create oracle with description > 32 symbols should return error + too_long_name = generate_random_string(33) + result = rpc.oraclescreate(too_long_name, "Test", "s") + + + # attempt to create oracle with description > 4096 symbols should return error + too_long_description = generate_random_string(4100) + result = rpc.oraclescreate("Test", too_long_description, "s") + assert_error(result) + # # valid creating oracles of different types + # # using such naming to re-use it for data publishing / reading (e.g. oracle_s for s type) + # valid_formats = ["s", "S", "d", "D", "c", "C", "t", "T", "i", "I", "l", "L", "h", "Ihh"] + # for f in valid_formats: + # result = rpc.oraclescreate("Test", "Test", f) + # assert_success(result) + # globals()["oracle_{}".format(f)] = self.send_and_mine(result['hex'], rpc) + + def run_test (self): + print("Mining blocks...") + rpc = self.nodes[0] + rpc1 = self.nodes[1] + # utxos from block 1 become mature in block 101 + rpc.generate(101) + self.sync_all() + rpc.getinfo() + rpc1.getinfo() + # this corresponds to -pubkey above + print("Importing privkeys") + rpc.importprivkey(self.privkey) + rpc1.importprivkey(self.privkey1) + self.run_faucet_tests() + self.sync_all() + self.run_rewards_tests() + self.sync_all() + self.run_dice_tests() + self.sync_all() + self.run_token_tests() + self.sync_all() + self.run_oracles_tests() + + +if __name__ == '__main__': + CryptoConditionsTest ().main() From dbb8f0acc20634c44c6b5378f5ef5d35b349a9b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 06:02:13 -1100 Subject: [PATCH 3366/3904] Test --- src/cc/games/prices.c | 6 +++--- src/cc/games/prices.cpp | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index f33838c64..271271a67 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -123,7 +123,7 @@ void *gamesiterate(struct games_state *rs) #ifdef STANDALONE #include #include "dapps/dappstd.c" -int64_t Net_change,Betsize; +int64_t Net_change,Betsize = SATOSHIDEN; char *send_curl(char *url,char *fname) { @@ -159,7 +159,7 @@ uint64_t get_btcusd() mult = 10000 + Net_change*10; newprice = (btcusd * mult) / 10000; x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); - sprintf(str,"BTC/USD %.4f Net_change %lld * 0.001 -> Betsize %.8f %.4f\n",dstr(btcusd),(long long)Net_change,dstr(Betsize),dstr(newprice)); + sprintf(str,"BTC/USD %.4f -> Betsize %.8f (^ / to change) && %.4f [+ - to change]\n",dstr(btcusd),dstr(Betsize),dstr(newprice)); mvaddstr(0, 0, str); clrtoeol(); doupdate(); @@ -241,7 +241,7 @@ int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize) if ( (resobj= jobj(retjson,(char *)"result")) != 0 ) { retval = 0; - fprintf(stderr,"%s\n",jprint(resobj,0)); + //fprintf(stderr,"%s\n",jprint(resobj,0)); } free_json(retjson); } diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 296d80a8c..a49fc1982 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -15,11 +15,18 @@ ******************************************************************************/ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); +extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey gamespk,mypk; + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey gamespk,mypk,acpk; + if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error"," no -ac_pubkey for price reference")); + } + acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); if ( params != 0 && cJSON_GetArraySize(params) == 2 ) { amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; @@ -28,7 +35,9 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parsehash")); } - fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price); + if ( mypk == acpk ) + amount = 0; // i am the reference price feed + //fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price); mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) @@ -53,7 +62,7 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) void prices_update(uint32_t timestamp,uint32_t uprice,int32_t ismine) { - fprintf(stderr,"%s t%u %.4f %16llx\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000,(long long)((uint64_t)timestamp<<32) | uprice); + //fprintf(stderr,"%s t%u %.4f %16llx\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000,(long long)((uint64_t)timestamp<<32) | uprice); } // game specific code for daemon From f18867055dddeea88e1ce5e880c8f75e292e73c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 06:45:23 -1100 Subject: [PATCH 3367/3904] Test --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 271271a67..99b95f7c2 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -159,7 +159,7 @@ uint64_t get_btcusd() mult = 10000 + Net_change*10; newprice = (btcusd * mult) / 10000; x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); - sprintf(str,"BTC/USD %.4f -> Betsize %.8f (^ / to change) && %.4f [+ - to change]\n",dstr(btcusd),dstr(Betsize),dstr(newprice)); + sprintf(str,"BTC/USD %.4f -> Betsize %.8f (^ / to change) && %.4f Net %.1f%% [+ - to change]\n",dstr(btcusd),dstr(Betsize),dstr(newprice),(double)100*mult/10000); mvaddstr(0, 0, str); clrtoeol(); doupdate(); From 2dfd8dacdb4f192f70523c5bc83ff8fb069adac6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 06:47:03 -1100 Subject: [PATCH 3368/3904] Display perc --- src/cc/games/prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index 99b95f7c2..1bc62533e 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -159,7 +159,7 @@ uint64_t get_btcusd() mult = 10000 + Net_change*10; newprice = (btcusd * mult) / 10000; x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff); - sprintf(str,"BTC/USD %.4f -> Betsize %.8f (^ / to change) && %.4f Net %.1f%% [+ - to change]\n",dstr(btcusd),dstr(Betsize),dstr(newprice),(double)100*mult/10000); + sprintf(str,"BTC/USD %.4f -> Betsize %.8f (^ / to change) && %.4f Net %.1f%% [+ - to change]\n",dstr(btcusd),dstr(Betsize),dstr(newprice),(double)100*(mult-10000)/10000); mvaddstr(0, 0, str); clrtoeol(); doupdate(); From 7596077f2a3fbe657dc6897906cf1d0d9c20cfc7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 07:10:30 -1100 Subject: [PATCH 3369/3904] Settle stub --- src/cc/games/prices.cpp | 7 +++++++ src/cc/games/tetris.cpp | 8 +++++++- src/cc/gamescc.h | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index a49fc1982..4098a3980 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -17,6 +17,13 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; + +UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result; + return(result); +} + UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); diff --git a/src/cc/games/tetris.cpp b/src/cc/games/tetris.cpp index 12c443e1e..d1ca9c30b 100644 --- a/src/cc/games/tetris.cpp +++ b/src/cc/games/tetris.cpp @@ -66,7 +66,13 @@ int32_t games_payloadrecv(CPubKey pk,uint32_t timestamp,std::vector pay } else return(-1); } -UniValue games_oracledata(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result; + return(result); +} + +UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; return(result); diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 52627cd1c..7a6b7c66c 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -47,6 +47,7 @@ std::string Games_pname; { (char *)MYCCNAME, (char *)"events", (char *)"eventshex [gametxid [eventid]]", 1, 3, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"bet", (char *)"amount hexstr", 2, 2, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"settle", (char *)"height", 1, 1, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -67,6 +68,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ if ( cp->evalcode == EVAL_GAMES ) \ @@ -105,6 +107,8 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_fund(txfee,cp,params)); \ else if ( strcmp(method,"bet") == 0 ) \ return(games_bet(txfee,cp,params)); \ + else if ( strcmp(method,"settle") == 0 ) \ + return(games_settle(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From 00eee20935f82635587776b527de745628a9dedb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 07:33:33 -1100 Subject: [PATCH 3370/3904] Settle stub --- src/cc/games/prices.cpp | 50 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 4098a3980..7bc540171 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -14,24 +14,69 @@ * * ******************************************************************************/ +#define PRICES_BETPERIOD 3 UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; + UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); + if ( params != 0 && cJSON_GetArraySize(params) == 1 ) + { + height = juint(jitem(params,0),0); + result.push_back(Pair("height",(int64_t)height)); + if ( (pindex= komodo_chainactive(height)) != 0 ) + { + if ( komodo_blockload(block,pindex) == 0 ) + { + n = pindex->block.vtx.size(); + for (i=0; i 1 ) + { + GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); + E_UNMARSHAL(vopret,ss >> pricebits); + fprintf(stderr,"i.%d %.8f %llx\n",i,(double)tx.vout[0].nValue/COIN,(long long)pricebits); + } + } + // display bets + if ( height <= nextheight-PRICES_BETPERIOD ) + { + // settle bets + } + result.push_back(Pair("result","success")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","cant load block at height")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","cant find block at height")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parse")); + } return(result); } UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey gamespk,mypk,acpk; + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; uint64_t price; CPubKey gamespk,mypk,acpk; if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error"," no -ac_pubkey for price reference")); + return(result); } acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); if ( params != 0 && cJSON_GetArraySize(params) == 2 ) @@ -41,6 +86,7 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parsehash")); + return(result); } if ( mypk == acpk ) amount = 0; // i am the reference price feed From ed6a4160aa30c9fcc3d7d9ec0d6550cd1132a2b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 07:38:43 -1100 Subject: [PATCH 3371/3904] block.vtx --- src/cc/CCinclude.h | 1 + src/cc/games/prices.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 839fd2c95..12b4a6d12 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -197,6 +197,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector payload); int32_t payments_parsehexdata(std::vector &hexdata,cJSON *item,int32_t len); +int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex); CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, vscript_t vopretNonfungible); CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector> oprets); diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 7bc540171..9909144f0 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -30,7 +30,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( komodo_blockload(block,pindex) == 0 ) { - n = pindex->block.vtx.size(); + n = block.vtx.size(); for (i=0; i Date: Wed, 27 Mar 2019 07:51:09 -1100 Subject: [PATCH 3372/3904] +prints --- src/cc/games/prices.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 9909144f0..271470219 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -21,7 +21,7 @@ extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); + UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; uint32_t timestamp,pricebits; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { height = juint(jitem(params,0),0); @@ -38,7 +38,9 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); E_UNMARSHAL(vopret,ss >> pricebits); - fprintf(stderr,"i.%d %.8f %llx\n",i,(double)tx.vout[0].nValue/COIN,(long long)pricebits); + timestamp = (uint32_t)(pricebits >> 32); + uprice = (uint32_t)pricebits; + fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f\n",scriptPubkey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000); } } // display bets From 68802af3193756d5a4671f120f95893f630c079b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 07:51:56 -1100 Subject: [PATCH 3373/3904] Price --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 271470219..305d64f4e 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -21,7 +21,7 @@ extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; uint32_t timestamp,pricebits; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); + UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; uint32_t timestamp,uprice; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { height = juint(jitem(params,0),0); From a26f3ea4a4c0eb4bfdae017c4c9883767475524c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 07:52:38 -1100 Subject: [PATCH 3374/3904] tx.vout[numvouts-1]. --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 305d64f4e..790f4a687 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -40,7 +40,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) E_UNMARSHAL(vopret,ss >> pricebits); timestamp = (uint32_t)(pricebits >> 32); uprice = (uint32_t)pricebits; - fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f\n",scriptPubkey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000); + fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f\n",tx.vout[numvouts-1].scriptPubkey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000); } } // display bets From f003d0d8befcafd6010a47cf6e1fe7239af8f81d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 07:53:33 -1100 Subject: [PATCH 3375/3904] Test --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 790f4a687..de16a7f2b 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -40,7 +40,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) E_UNMARSHAL(vopret,ss >> pricebits); timestamp = (uint32_t)(pricebits >> 32); uprice = (uint32_t)pricebits; - fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f\n",tx.vout[numvouts-1].scriptPubkey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000); + fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d\n",tx.vout[numvouts-1].scriptPubkey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts); } } // display bets From a1a8014f057355d12e1580bc2b4988c4890583f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 07:54:17 -1100 Subject: [PATCH 3376/3904] scriptPubKey --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index de16a7f2b..ba78e8560 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -40,7 +40,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) E_UNMARSHAL(vopret,ss >> pricebits); timestamp = (uint32_t)(pricebits >> 32); uprice = (uint32_t)pricebits; - fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d\n",tx.vout[numvouts-1].scriptPubkey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts); + fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts); } } // display bets From 4a998b2595fe111192bada2dff1a425d057ec14c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:01:21 -1100 Subject: [PATCH 3377/3904] +print --- src/cc/games/prices.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index ba78e8560..1171c3aba 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -34,7 +34,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) for (i=0; i 1 ) + if ( (numvouts= tx.vout.size()) > 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) { GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); E_UNMARSHAL(vopret,ss >> pricebits); @@ -91,7 +91,10 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } if ( mypk == acpk ) + { amount = 0; // i am the reference price feed + fprintf(stderr,"i am the reference\n"); + } //fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price); mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); From 03f663ea3795c3b146f54a819db3407ff1714950 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:04:06 -1100 Subject: [PATCH 3378/3904] Reorder --- src/cc/games/prices.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 1171c3aba..f5a866727 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -21,7 +21,10 @@ extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; uint32_t timestamp,uprice; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); + UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; uint32_t timestamp,uprice; CPubKey acpk,mypk,gamespk; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); + mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { height = juint(jitem(params,0),0); @@ -80,6 +83,8 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("error"," no -ac_pubkey for price reference")); return(result); } + mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); if ( params != 0 && cJSON_GetArraySize(params) == 2 ) { @@ -93,11 +98,9 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( mypk == acpk ) { amount = 0; // i am the reference price feed - fprintf(stderr,"i am the reference\n"); + //fprintf(stderr,"i am the reference\n"); } //fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price); - mypk = pubkey2pk(Mypubkey()); - gamespk = GetUnspendable(cp,0); if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); From a28e03acdd52e6dec2c2b5b3ecdb646e3fbbb558 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:14:39 -1100 Subject: [PATCH 3379/3904] Test --- src/cc/games/prices.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index f5a866727..69c45f286 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -21,10 +21,11 @@ extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; uint32_t timestamp,uprice; CPubKey acpk,mypk,gamespk; int32_t i,n,numvouts,height,nextheight = komodo_nextheight(); + UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; char acaddr[64],destaddr[64]; uint32_t timestamp,uprice; CPubKey acpk,mypk,gamespk; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,height,nextheight = komodo_nextheight(); mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); + Getscriptaddress(acaddr,CScript() << ParseHex(HexStr(acpk)) << OP_CHECKSIG); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { height = juint(jitem(params,0),0); @@ -34,16 +35,24 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( komodo_blockload(block,pindex) == 0 ) { n = block.vtx.size(); + vini = 0; for (i=0; i 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) + if ( myGetTransaction(tx.vin[vini].prevout.hash,vintx,hashBlock) == 0 ) + continue; + else if ( Getscriptaddress(destaddr,vintx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ) + continue; + else if ( (numvouts= tx.vout.size()) > 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) { + prizefund += tx.vout[0].nValue; GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); E_UNMARSHAL(vopret,ss >> pricebits); timestamp = (uint32_t)(pricebits >> 32); uprice = (uint32_t)pricebits; - fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts); + if ( strcmp(acaddr,destaddr) == 0 ) + fprintf(stderr,"REF "); + fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); } } // display bets @@ -51,6 +60,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { // settle bets } + result.push_back(Pair("prizefund",ValueToAmount(prizefund))); result.push_back(Pair("result","success")); } else From d23d46d9534325fd2c4a149c2aab6845db73560c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:19:18 -1100 Subject: [PATCH 3380/3904] ValueFromAmount --- src/cc/games/prices.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 69c45f286..64699dfe7 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -21,7 +21,7 @@ extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx; uint64_t pricebits; char acaddr[64],destaddr[64]; uint32_t timestamp,uprice; CPubKey acpk,mypk,gamespk; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,height,nextheight = komodo_nextheight(); + UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char acaddr[64],destaddr[64]; uint32_t timestamp,uprice; CPubKey acpk,mypk,gamespk; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,height,nextheight = komodo_nextheight(); mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); @@ -60,7 +60,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { // settle bets } - result.push_back(Pair("prizefund",ValueToAmount(prizefund))); + result.push_back(Pair("prizefund",ValueFromAmount(prizefund))); result.push_back(Pair("result","success")); } else From d2fbc97ee88f5f421c6bd04ca7af37a7abc3bcbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:21:49 -1100 Subject: [PATCH 3381/3904] -print --- src/cc/games/prices.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 64699dfe7..146f6a926 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -50,9 +50,9 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) E_UNMARSHAL(vopret,ss >> pricebits); timestamp = (uint32_t)(pricebits >> 32); uprice = (uint32_t)pricebits; - if ( strcmp(acaddr,destaddr) == 0 ) - fprintf(stderr,"REF "); - fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); + //if ( strcmp(acaddr,destaddr) == 0 ) + // fprintf(stderr,"REF "); + //fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); } } // display bets From a5406418471059ca5594fbbf7c3d5ff7f6416221 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:30:19 -1100 Subject: [PATCH 3382/3904] Test --- src/cc/games/prices.cpp | 83 +++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 146f6a926..770cdfc8e 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -18,10 +18,41 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; +int64_t prices_blockinfo(int32_t height,char *acaddr) +{ + std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t timestamp,uprice; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts; + if ( (pindex= komodo_chainactive(height)) != 0 ) + { + if ( komodo_blockload(block,pindex) == 0 ) + { + n = block.vtx.size(); + vini = 0; + for (i=0; i= vintx.vout.size() || Getscriptaddress(destaddr,vintx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ) + continue; + else if ( (numvouts= tx.vout.size()) > 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) + { + prizefund += tx.vout[0].nValue; + GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); + E_UNMARSHAL(vopret,ss >> pricebits); + timestamp = (uint32_t)(pricebits >> 32); + uprice = (uint32_t)pricebits; + //if ( strcmp(acaddr,destaddr) == 0 ) + // fprintf(stderr,"REF "); + //fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); + } + } + } else return(-2); + } else return(-1); +} UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char acaddr[64],destaddr[64]; uint32_t timestamp,uprice; CPubKey acpk,mypk,gamespk; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,height,nextheight = komodo_nextheight(); + UniValue result; char acaddr[64]; CPubKey acpk,mypk,gamespk; int64_t prizefund = 0; int32_t height,nextheight = komodo_nextheight(); mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); @@ -30,49 +61,21 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { height = juint(jitem(params,0),0); result.push_back(Pair("height",(int64_t)height)); - if ( (pindex= komodo_chainactive(height)) != 0 ) + if ( 1 || (prizefund= prices_blockinfo(height,acaddr)) < 0 ) { - if ( komodo_blockload(block,pindex) == 0 ) - { - n = block.vtx.size(); - vini = 0; - for (i=0; i 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) - { - prizefund += tx.vout[0].nValue; - GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); - E_UNMARSHAL(vopret,ss >> pricebits); - timestamp = (uint32_t)(pricebits >> 32); - uprice = (uint32_t)pricebits; - //if ( strcmp(acaddr,destaddr) == 0 ) - // fprintf(stderr,"REF "); - //fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); - } - } - // display bets - if ( height <= nextheight-PRICES_BETPERIOD ) - { - // settle bets - } - result.push_back(Pair("prizefund",ValueFromAmount(prizefund))); - result.push_back(Pair("result","success")); - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","cant load block at height")); - } + result.push_back(Pair("result","error")); + result.push_back(Pair("errorcode",prizefund)); + result.push_back(Pair("error","blockinfo error")); } else { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","cant find block at height")); + // display bets + if ( height <= nextheight-PRICES_BETPERIOD ) + { + // settle bets + } + result.push_back(Pair("prizefund",ValueFromAmount(prizefund))); + result.push_back(Pair("result","success")); } } else From 513731ea367a4a03eeae8a3561d7f4887eb949ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:32:55 -1100 Subject: [PATCH 3383/3904] Test --- src/cc/gamescc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 7a6b7c66c..efdd3b8e1 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -77,6 +77,8 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_rng(txfee,cp,params)); \ else if ( strcmp(method,"rngnext") == 0 ) \ return(games_rngnext(txfee,cp,params)); \ + else if ( strcmp(method,"settle") == 0 ) \ + return(games_settle(txfee,cp,params)); \ else if ( strcmp(method,"newgame") == 0 ) \ return(games_newgame(txfee,cp,params)); \ else if ( strcmp(method,"gameinfo") == 0 ) \ @@ -107,8 +109,6 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_fund(txfee,cp,params)); \ else if ( strcmp(method,"bet") == 0 ) \ return(games_bet(txfee,cp,params)); \ - else if ( strcmp(method,"settle") == 0 ) \ - return(games_settle(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From 8de793c57bdc8159fb4f951151b7c452500333d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:35:06 -1100 Subject: [PATCH 3384/3904] Test --- src/cc/games/prices.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 770cdfc8e..ea5e28211 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -53,6 +53,8 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; char acaddr[64]; CPubKey acpk,mypk,gamespk; int64_t prizefund = 0; int32_t height,nextheight = komodo_nextheight(); + result.push_back(Pair("result","success")); + return(result); mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); From 0e1310dd8a3538b7cabc96072b493339be69a9c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:42:44 -1100 Subject: [PATCH 3385/3904] Test --- src/cc/games/prices.cpp | 2 ++ src/cc/games/tetris.cpp | 2 ++ src/cc/gamescc.h | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index ea5e28211..275589b02 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -14,6 +14,8 @@ * * ******************************************************************************/ +std::string MYCCLIBNAME = (char *)"gamescc"; + #define PRICES_BETPERIOD 3 UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; diff --git a/src/cc/games/tetris.cpp b/src/cc/games/tetris.cpp index d1ca9c30b..cd609154d 100644 --- a/src/cc/games/tetris.cpp +++ b/src/cc/games/tetris.cpp @@ -14,6 +14,8 @@ * * ******************************************************************************/ +std::string MYCCLIBNAME = (char *)"gamescc"; + // game specific code for daemon void games_packitemstr(char *packitemstr,struct games_packitem *item) { diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index efdd3b8e1..b83276d8d 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -15,7 +15,6 @@ extern CWallet* pwalletMain; #include "CCinclude.h" #include "secp256k1.h" -std::string MYCCLIBNAME = (char *)"gamescc"; #define EVAL_GAMES (EVAL_FAUCET2+1) #define GAMES_TXFEE 10000 From aa24e63f86a17fee395204efa2edfa113b59ae1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:46:03 -1100 Subject: [PATCH 3386/3904] Test --- src/cc/gamescc.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index b83276d8d..4d095ab12 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -24,6 +24,7 @@ extern CWallet* pwalletMain; #define GAMES_REGISTRATIONSIZE (100 * 10000) #define GAMES_REGISTRATION 1 +extern std::string MYCCLIBNAME; #define MYCCNAME "games" @@ -76,8 +77,6 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_rng(txfee,cp,params)); \ else if ( strcmp(method,"rngnext") == 0 ) \ return(games_rngnext(txfee,cp,params)); \ - else if ( strcmp(method,"settle") == 0 ) \ - return(games_settle(txfee,cp,params)); \ else if ( strcmp(method,"newgame") == 0 ) \ return(games_newgame(txfee,cp,params)); \ else if ( strcmp(method,"gameinfo") == 0 ) \ @@ -108,6 +107,8 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_fund(txfee,cp,params)); \ else if ( strcmp(method,"bet") == 0 ) \ return(games_bet(txfee,cp,params)); \ + else if ( strcmp(method,"settle") == 0 ) \ + return(games_settle(txfee,cp,params)); \ else \ { \ result.push_back(Pair("result","error")); \ From 1a413d246f0302cbb066d05c4d898c9dbec57756 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 08:58:40 -1100 Subject: [PATCH 3387/3904] Prices --- src/cc/cclib.cpp | 2 ++ src/cc/games/prices.cpp | 2 +- src/cc/gamescc.h | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 975b0735c..00a7c6fe0 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -52,6 +52,8 @@ std::string MYCCLIBNAME = (char *)"sudoku"; void komodo_netevent(std::vector payload) {} #endif +extern std::string MYCCLIBNAME; + char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } struct CClib_rpcinfo diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 275589b02..7293a8de9 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -14,7 +14,7 @@ * * ******************************************************************************/ -std::string MYCCLIBNAME = (char *)"gamescc"; +std::string MYCCLIBNAME = (char *)"pricescc"; #define PRICES_BETPERIOD 3 UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 4d095ab12..b804216d7 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -24,7 +24,6 @@ extern CWallet* pwalletMain; #define GAMES_REGISTRATIONSIZE (100 * 10000) #define GAMES_REGISTRATION 1 -extern std::string MYCCLIBNAME; #define MYCCNAME "games" From 985386a7e31bde57567266305956f834051546aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:00:40 -1100 Subject: [PATCH 3388/3904] Prices --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 7293a8de9..8624bc635 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -14,7 +14,7 @@ * * ******************************************************************************/ -std::string MYCCLIBNAME = (char *)"pricescc"; +std::string MYCCLIBNAME = (char *)"prices"; #define PRICES_BETPERIOD 3 UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); From 2102294650bf5f4c4bd59ff47575bcf5ee7642ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:04:14 -1100 Subject: [PATCH 3389/3904] Test --- src/cc/games/prices.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 8624bc635..4777e9de0 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -55,8 +55,12 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; char acaddr[64]; CPubKey acpk,mypk,gamespk; int64_t prizefund = 0; int32_t height,nextheight = komodo_nextheight(); - result.push_back(Pair("result","success")); - return(result); + if ( 1 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error"," no -ac_pubkey for price reference")); + return(result); + } mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); From 5e817c05acf57db0342d028958d475eb6a4ca786 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:06:30 -1100 Subject: [PATCH 3390/3904] Test --- src/cc/games/prices.cpp | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 4777e9de0..91f4aa790 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -52,7 +52,7 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) } else return(-1); } -UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_origsettle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; char acaddr[64]; CPubKey acpk,mypk,gamespk; int64_t prizefund = 0; int32_t height,nextheight = komodo_nextheight(); if ( 1 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) @@ -93,6 +93,53 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } return(result); } +UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; uint64_t price; CPubKey gamespk,mypk,acpk; + if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error"," no -ac_pubkey for price reference")); + return(result); + } + mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); + if ( params != 0 && cJSON_GetArraySize(params) == 2 ) + { + amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; + if ( cclib_parsehash((uint8_t *)&price,jitem(params,1),8) < 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parsehash")); + return(result); + } + if ( mypk == acpk ) + { + amount = 0; // i am the reference price feed + //fprintf(stderr,"i am the reference\n"); + } + //fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price); + if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,CScript() << OP_RETURN << price); + return(games_rawtxresult(result,rawtx,1)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough funds")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parse")); + } + return(result); +} UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { From dcfae63863f27e4dc82587d0da2a9e370df279b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:09:10 -1100 Subject: [PATCH 3391/3904] Test --- src/cc/games/prices.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 91f4aa790..112383554 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -106,7 +106,12 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); - if ( params != 0 && cJSON_GetArraySize(params) == 2 ) + if ( params != 0 && cJSON_GetArraySize(params) == 1 ) + { + height = juint(jitem(params,0),0); + result.push_back(Pair("height",(int64_t)height)); + } + /*if ( params != 0 && cJSON_GetArraySize(params) == 2 ) { amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; if ( cclib_parsehash((uint8_t *)&price,jitem(params,1),8) < 0 ) @@ -137,7 +142,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parse")); - } + }*/ return(result); } From 23e378493fa7b9f5ec01df6a8b78e4c69f837ce5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:10:02 -1100 Subject: [PATCH 3392/3904] Test --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 112383554..c9826fd9c 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -96,7 +96,7 @@ UniValue games_origsettle(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; uint64_t price; CPubKey gamespk,mypk,acpk; + UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; uint64_t price; CPubKey gamespk,mypk,acpk; int32_t height; if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) { result.push_back(Pair("result","error")); From d294ec1b93d9fdd5b0d258e111658db5c228ae51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:12:22 -1100 Subject: [PATCH 3393/3904] Test --- src/cc/games/prices.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index c9826fd9c..a638a7016 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -93,6 +93,7 @@ UniValue games_origsettle(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } return(result); } + UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); @@ -106,10 +107,11 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); + result.push_back(Pair("result","success")); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { height = juint(jitem(params,0),0); - result.push_back(Pair("height",(int64_t)height)); + //result.push_back(Pair("height",(int64_t)height)); } /*if ( params != 0 && cJSON_GetArraySize(params) == 2 ) { From 7b6ad019e63caadbc963b64627c7958f2635a8fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:13:48 -1100 Subject: [PATCH 3394/3904] Test --- src/cc/games/prices.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index a638a7016..1ac7e3edb 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -110,8 +110,8 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","success")); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { - height = juint(jitem(params,0),0); - //result.push_back(Pair("height",(int64_t)height)); + //height = juint(jitem(params,0),0); + result.push_back(Pair("height",(int64_t)height)); } /*if ( params != 0 && cJSON_GetArraySize(params) == 2 ) { From ecd3a17c85b1b016aac8e971b61ca6f6545305cb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:16:03 -1100 Subject: [PATCH 3395/3904] Test --- src/cc/games/prices.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 1ac7e3edb..7f807954d 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -52,10 +52,10 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) } else return(-1); } -UniValue games_origsettle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; char acaddr[64]; CPubKey acpk,mypk,gamespk; int64_t prizefund = 0; int32_t height,nextheight = komodo_nextheight(); - if ( 1 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) + if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error"," no -ac_pubkey for price reference")); @@ -64,6 +64,16 @@ UniValue games_origsettle(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); + result.push_back(Pair("result","success")); + if ( params != 0 && cJSON_GetArraySize(params) == 1 ) + { + height = juint(jitem(params,0),0); + result.push_back(Pair("height",(int64_t)height)); + } + return(result); + /*mypk = pubkey2pk(Mypubkey()); + gamespk = GetUnspendable(cp,0); + acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); Getscriptaddress(acaddr,CScript() << ParseHex(HexStr(acpk)) << OP_CHECKSIG); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { @@ -91,7 +101,7 @@ UniValue games_origsettle(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parse")); } - return(result); + return(result);*/ } UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) @@ -110,7 +120,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","success")); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { - //height = juint(jitem(params,0),0); + height = juint(jitem(params,0),0); result.push_back(Pair("height",(int64_t)height)); } /*if ( params != 0 && cJSON_GetArraySize(params) == 2 ) From 42235ad98d80acd044f021e359f8f8c9bd752166 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:17:08 -1100 Subject: [PATCH 3396/3904] -2nd --- src/cc/games/prices.cpp | 54 ----------------------------------------- 1 file changed, 54 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 7f807954d..c88827fa2 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -104,60 +104,6 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result);*/ } -UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum; uint64_t price; CPubKey gamespk,mypk,acpk; int32_t height; - if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error"," no -ac_pubkey for price reference")); - return(result); - } - mypk = pubkey2pk(Mypubkey()); - gamespk = GetUnspendable(cp,0); - acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); - result.push_back(Pair("result","success")); - if ( params != 0 && cJSON_GetArraySize(params) == 1 ) - { - height = juint(jitem(params,0),0); - result.push_back(Pair("height",(int64_t)height)); - } - /*if ( params != 0 && cJSON_GetArraySize(params) == 2 ) - { - amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049; - if ( cclib_parsehash((uint8_t *)&price,jitem(params,1),8) < 0 ) - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt parsehash")); - return(result); - } - if ( mypk == acpk ) - { - amount = 0; // i am the reference price feed - //fprintf(stderr,"i am the reference\n"); - } - //fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price); - if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE ) - { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,gamespk)); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,GAMES_TXFEE,CScript() << OP_RETURN << price); - return(games_rawtxresult(result,rawtx,1)); - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","not enough funds")); - } - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt parse")); - }*/ - return(result); -} - UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); From e909810c76fc2c109ca8b71ea80dfaf0967d5466 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:18:29 -1100 Subject: [PATCH 3397/3904] Test --- src/cc/games/prices.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index c88827fa2..142bc4c6b 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -65,11 +65,11 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); result.push_back(Pair("result","success")); - if ( params != 0 && cJSON_GetArraySize(params) == 1 ) + /*if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { height = juint(jitem(params,0),0); result.push_back(Pair("height",(int64_t)height)); - } + }*/ return(result); /*mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); From bdf32a01fb74f249bcf30807af3a75db4f5b256a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:19:27 -1100 Subject: [PATCH 3398/3904] Test --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 142bc4c6b..be85b92f1 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -63,7 +63,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); - acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); + //acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); result.push_back(Pair("result","success")); /*if ( params != 0 && cJSON_GetArraySize(params) == 1 ) { From a94d3bd0f753f395bbab32de8bd55f02ec28df07 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:21:58 -1100 Subject: [PATCH 3399/3904] d'oh --- src/cc/games/prices.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index be85b92f1..7a43c8218 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -54,7 +54,7 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; char acaddr[64]; CPubKey acpk,mypk,gamespk; int64_t prizefund = 0; int32_t height,nextheight = komodo_nextheight(); + UniValue result(UniValue::VOBJ); char acaddr[64]; CPubKey acpk,mypk,gamespk; int64_t prizefund = 0; int32_t height,nextheight = komodo_nextheight(); if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 ) { result.push_back(Pair("result","error")); @@ -63,16 +63,6 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } mypk = pubkey2pk(Mypubkey()); gamespk = GetUnspendable(cp,0); - //acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); - result.push_back(Pair("result","success")); - /*if ( params != 0 && cJSON_GetArraySize(params) == 1 ) - { - height = juint(jitem(params,0),0); - result.push_back(Pair("height",(int64_t)height)); - }*/ - return(result); - /*mypk = pubkey2pk(Mypubkey()); - gamespk = GetUnspendable(cp,0); acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33); Getscriptaddress(acaddr,CScript() << ParseHex(HexStr(acpk)) << OP_CHECKSIG); if ( params != 0 && cJSON_GetArraySize(params) == 1 ) @@ -101,7 +91,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("result","error")); result.push_back(Pair("error","couldnt parse")); } - return(result);*/ + return(result); } UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) From 40174b32742b8d481c166ceea263d09977351087 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:23:55 -1100 Subject: [PATCH 3400/3904] Test --- src/cc/games/prices.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 7a43c8218..6385626fc 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -20,6 +20,8 @@ std::string MYCCLIBNAME = (char *)"prices"; UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; +// generate bars + int64_t prices_blockinfo(int32_t height,char *acaddr) { std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t timestamp,uprice; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts; @@ -69,7 +71,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { height = juint(jitem(params,0),0); result.push_back(Pair("height",(int64_t)height)); - if ( 1 || (prizefund= prices_blockinfo(height,acaddr)) < 0 ) + if ( (prizefund= prices_blockinfo(height,acaddr)) < 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("errorcode",prizefund)); @@ -80,7 +82,7 @@ UniValue games_settle(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) // display bets if ( height <= nextheight-PRICES_BETPERIOD ) { - // settle bets + // settle bets by first nonzero reference bar } result.push_back(Pair("prizefund",ValueFromAmount(prizefund))); result.push_back(Pair("result","success")); From 9c12a5523762798880c98b39a0cc0b4bfa111bab Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:25:35 -1100 Subject: [PATCH 3401/3904] Return prizefund --- src/cc/games/prices.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 6385626fc..177417c9b 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -45,11 +45,12 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) E_UNMARSHAL(vopret,ss >> pricebits); timestamp = (uint32_t)(pricebits >> 32); uprice = (uint32_t)pricebits; - //if ( strcmp(acaddr,destaddr) == 0 ) - // fprintf(stderr,"REF "); - //fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); + if ( strcmp(acaddr,destaddr) == 0 ) + fprintf(stderr,"REF "); + fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); } } + return(prizefund); } else return(-2); } else return(-1); } From 5a557264fa1c98ef90f8ce8cb8c4fb5c58532782 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 09:27:56 -1100 Subject: [PATCH 3402/3904] Test --- src/cc/games/prices.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 177417c9b..9178eb46b 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -42,12 +42,15 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) { prizefund += tx.vout[0].nValue; GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); - E_UNMARSHAL(vopret,ss >> pricebits); - timestamp = (uint32_t)(pricebits >> 32); - uprice = (uint32_t)pricebits; - if ( strcmp(acaddr,destaddr) == 0 ) - fprintf(stderr,"REF "); - fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); + if ( vopret.size() == 8 ) + { + E_UNMARSHAL(vopret,ss >> pricebits); + timestamp = (uint32_t)(pricebits >> 32); + uprice = (uint32_t)pricebits; + if ( strcmp(acaddr,destaddr) == 0 ) + fprintf(stderr,"REF "); + fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); + } else return(-3); } } return(prizefund); From 0597306ea564fa640c7e91384421945e22804928 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Mar 2019 19:31:39 -1100 Subject: [PATCH 3403/3904] 69522 exemption --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5040c34d3..c5350a68d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1521,7 +1521,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); - if ( txid == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 + if ( txid == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") || txid == Parseuint256("2a34b36cc1292aecfaabdad79b42cab9989fa6dcc87ac8ca88aa6162dab1e2c4") ) // osx rogue chain ht.50902, 69522 enabled = 0; scriptPubKey = tx.vout[numvouts-1].scriptPubKey; GetOpReturnData(scriptPubKey,vopret); From de646890858f06a30fe72ed2ec97e53c5e27e590 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 28 Mar 2019 14:45:34 +0800 Subject: [PATCH 3404/3904] fix rewards minrelease validation --- src/cc/rewards.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 73f723453..129cbc47f 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -258,11 +258,11 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t if ( !CheckTxFee(tx, txfee, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) ) return eval->Invalid("txfee is too high"); reward = RewardsCalc(amount,tx.vin[0].prevout.hash,APR,minseconds,maxseconds,mindeposit); + if ( reward == 0 ) + return eval->Invalid("no elegible rewards"); if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) { - if ( reward == 0 ) - return eval->Invalid("unlock recover no rewards"); - else if ( tx.vout[1].nValue != 10000 ) + if ( tx.vout[1].nValue != 10000 ) return eval->Invalid("wrong marker vour value"); else if ( tx.vout[1].scriptPubKey != tx.vout[0].scriptPubKey ) return eval->Invalid("unlock recover tx vout.1 mismatched scriptPubKey"); From 87b039a2673ad0f0758c5f9c18a23da5084be8b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 28 Mar 2019 14:56:51 +0800 Subject: [PATCH 3405/3904] fix --- src/cc/rewards.cpp | 3 +-- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 129cbc47f..152842bbd 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -263,7 +263,7 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) { if ( tx.vout[1].nValue != 10000 ) - return eval->Invalid("wrong marker vour value"); + return eval->Invalid("wrong marker vout value"); else if ( tx.vout[1].scriptPubKey != tx.vout[0].scriptPubKey ) return eval->Invalid("unlock recover tx vout.1 mismatched scriptPubKey"); else if ( tx.vout[0].scriptPubKey != vinTx.vout[1].scriptPubKey ) @@ -285,7 +285,6 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t else if ( tx.vout[1].scriptPubKey != vinTx.vout[1].scriptPubKey ) return eval->Invalid("unlock tx vout.1 mismatched scriptPubKey"); amount = vinTx.vout[0].nValue; - reward = RewardsCalc(amount,tx.vin[0].prevout.hash,APR,minseconds,maxseconds,mindeposit); if ( RewardsExactAmounts(cp,eval,tx,txfee+tx.vout[1].nValue,sbits,fundingtxid) == 0 ) return false; else if ( tx.vout[1].nValue > amount+reward ) diff --git a/src/main.cpp b/src/main.cpp index e520ad83f..019507c55 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1383,7 +1383,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio } } if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE ) - return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-vout-negative"); + return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-opret-too-big"); nValueOut += txout.nValue; if (!MoneyRange(nValueOut)) return state.DoS(100, error("CheckTransaction(): txout total out of range"), From fab49cbf44440d7203bd48976b8ba24088c860cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 00:52:17 -1100 Subject: [PATCH 3406/3904] prices_bar --- src/cc/games/prices.cpp | 88 ++++++++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 19 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 9178eb46b..b5540650a 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -20,37 +20,87 @@ std::string MYCCLIBNAME = (char *)"prices"; UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag); extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; -// generate bars +#define bstr(x) ((double)((uint32_t)x) / 10000.) + +struct prices_bar +{ + uint64_t open,high,low,close,sum; + int32_t num; +}; + +int32_t prices_barupdate(struct prices_bar *bar,uint64_t pricebits) +{ + uint32_t uprice,timestamp; + timestamp = (uint32_t)(pricebits >> 32); + uprice = (uint32_t)pricebits; + bar->sum += uprice, bar->num++; + if ( bar->open == 0 ) + bar->open = bar->high = bar->low = pricebits; + if ( uprice > (uint32_t)bar->high ) + bar->high = pricebits; + else if ( uprice < (uint32_t)bar->low ) + bar->low = pricebits; + bar->close = pricebits; + return(0); +} + +int32_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebits) +{ + int32_t dist = 0; uint32_t uprice = (uint32_t)pricebits; + dist = (uprice - aveprice) * (uprice - aveprice); + return(dist); +} + +void prices_bardisp(struct prices_bar *bar) +{ + if ( bar->num == 0 ) + fprintf(stderr,"BAR null\n"); + else fprintf(stderr,"BAR ave %.4f (O %.4f, H %.4f, L %.4f, C %.4f)\n",bstr(bar->sum/bar->num),bstr(bar->open),bstr(bar->high),bstr(bar->low),bstr(bar->close)); +} int64_t prices_blockinfo(int32_t height,char *acaddr) { - std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t timestamp,uprice; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts; + std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,iter; struct bar_info refbar; if ( (pindex= komodo_chainactive(height)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) { n = block.vtx.size(); vini = 0; - for (i=0; i= vintx.vout.size() || Getscriptaddress(destaddr,vintx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ) - continue; - else if ( (numvouts= tx.vout.size()) > 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) + for (i=0; i= vintx.vout.size() || Getscriptaddress(destaddr,vintx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ) + continue; + else if ( iter == 0 != strcmp(acaddr,destaddr) != 0 ) + continue; + else if ( (numvouts= tx.vout.size()) > 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) { - E_UNMARSHAL(vopret,ss >> pricebits); - timestamp = (uint32_t)(pricebits >> 32); - uprice = (uint32_t)pricebits; - if ( strcmp(acaddr,destaddr) == 0 ) - fprintf(stderr,"REF "); - fprintf(stderr,"[%02x] i.%d %.8f %llx t%u %.4f numvouts.%d %s lag.%d\n",tx.vout[numvouts-1].scriptPubKey[0],i,(double)tx.vout[0].nValue/COIN,(long long)pricebits,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp)); - } else return(-3); + prizefund += tx.vout[0].nValue; + GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); + if ( vopret.size() == 8 ) + { + E_UNMARSHAL(vopret,ss >> pricebits); + timestamp = (uint32_t)(pricebits >> 32); + uprice = (uint32_t)pricebits; + if ( iter == 0 ) + prices_barupdate(&refbar,pricebits); + if ( strcmp(acaddr,destaddr) == 0 ) + fprintf(stderr,"REF "); + fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%d\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,prices_bardist(&refbar,aveprice,pricebits)); + } else return(-3); + } + if ( iter == 0 ) + { + prices_bardisp(&refbar); + if ( refbar.num != 0 ) + aveprice = (uint32_t)refbar.sum / refbar.num; + } } } return(prizefund); From f970eb5c11009a639060215e7fb2690f6ef9135d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 00:53:02 -1100 Subject: [PATCH 3407/3904] prices_bar --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index b5540650a..1a599d390 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -60,7 +60,7 @@ void prices_bardisp(struct prices_bar *bar) int64_t prices_blockinfo(int32_t height,char *acaddr) { - std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,iter; struct bar_info refbar; + std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,iter; struct prices_bar refbar; if ( (pindex= komodo_chainactive(height)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) From 3b880b21801208d59d1f14f6903f74dc72db3399 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 00:56:02 -1100 Subject: [PATCH 3408/3904] Fix skip condition --- src/cc/games/prices.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 1a599d390..40d747f65 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -47,7 +47,11 @@ int32_t prices_barupdate(struct prices_bar *bar,uint64_t pricebits) int32_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebits) { int32_t dist = 0; uint32_t uprice = (uint32_t)pricebits; - dist = (uprice - aveprice) * (uprice - aveprice); + if ( aveprice != 0 ) + { + dist = (uprice - aveprice); + dist *= dist; + } return(dist); } @@ -77,7 +81,7 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) continue; else if ( tx.vin[vini].prevout.n >= vintx.vout.size() || Getscriptaddress(destaddr,vintx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ) continue; - else if ( iter == 0 != strcmp(acaddr,destaddr) != 0 ) + else if ( iter != strcmp(acaddr,destaddr) ) continue; else if ( (numvouts= tx.vout.size()) > 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) { From 751156efa3be2e36db315340af7765b83597c608 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:09:08 -1100 Subject: [PATCH 3409/3904] Cleanup loop --- src/cc/games/prices.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 40d747f65..f6ee704ee 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -81,11 +81,8 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) continue; else if ( tx.vin[vini].prevout.n >= vintx.vout.size() || Getscriptaddress(destaddr,vintx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ) continue; - else if ( iter != strcmp(acaddr,destaddr) ) - continue; else if ( (numvouts= tx.vout.size()) > 1 && tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) { - prizefund += tx.vout[0].nValue; GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); if ( vopret.size() == 8 ) { @@ -93,18 +90,22 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) timestamp = (uint32_t)(pricebits >> 32); uprice = (uint32_t)pricebits; if ( iter == 0 ) - prices_barupdate(&refbar,pricebits); - if ( strcmp(acaddr,destaddr) == 0 ) - fprintf(stderr,"REF "); - fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%d\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,prices_bardist(&refbar,aveprice,pricebits)); + { + prizefund += tx.vout[0].nValue; + if ( strcmp(acaddr,destaddr) == 0 ) + { + fprintf(stderr,"REF "); + prices_barupdate(&refbar,pricebits); + } + } else fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%d\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,prices_bardist(&refbar,aveprice,pricebits)); } else return(-3); } - if ( iter == 0 ) - { - prices_bardisp(&refbar); - if ( refbar.num != 0 ) - aveprice = (uint32_t)refbar.sum / refbar.num; - } + } + if ( iter == 0 ) + { + prices_bardisp(&refbar); + if ( refbar.num != 0 ) + aveprice = (uint32_t)refbar.sum / refbar.num; } } return(prizefund); From 2f9c10cb73c366e5a1d38b2e05c6be6e35424f84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:12:10 -1100 Subject: [PATCH 3410/3904] Test --- src/cc/games/prices.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index f6ee704ee..8c70750bf 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -51,6 +51,7 @@ int32_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebi { dist = (uprice - aveprice); dist *= dist; + fprintf(stderr,"dist.%d (u %u - ave %u) %d\n",dist,uprice,aveprice,uprice-aveprice); } return(dist); } @@ -97,7 +98,9 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) fprintf(stderr,"REF "); prices_barupdate(&refbar,pricebits); } - } else fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%d\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,prices_bardist(&refbar,aveprice,pricebits)); + } + else if ( strcmp(acaddr,destaddr) != 0 ) + fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%d\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,prices_bardist(&refbar,aveprice,pricebits)); } else return(-3); } } From 58ebf2262dede6fed26c0ace4bafa8a480c4c084 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:14:12 -1100 Subject: [PATCH 3411/3904] Int64 --- src/cc/games/prices.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 8c70750bf..d4a87ee39 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -44,14 +44,14 @@ int32_t prices_barupdate(struct prices_bar *bar,uint64_t pricebits) return(0); } -int32_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebits) +int64_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebits) { - int32_t dist = 0; uint32_t uprice = (uint32_t)pricebits; + int64_t dist = 0; uint32_t uprice = (uint32_t)pricebits; if ( aveprice != 0 ) { dist = (uprice - aveprice); dist *= dist; - fprintf(stderr,"dist.%d (u %u - ave %u) %d\n",dist,uprice,aveprice,uprice-aveprice); + fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); } return(dist); } @@ -100,7 +100,7 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) } } else if ( strcmp(acaddr,destaddr) != 0 ) - fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%d\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,prices_bardist(&refbar,aveprice,pricebits)); + fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%lld\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,(long long)prices_bardist(&refbar,aveprice,pricebits)); } else return(-3); } } From 4414e5a5f47bcb08a7de59ab239f55d3900163b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:17:50 -1100 Subject: [PATCH 3412/3904] Test --- src/cc/games/prices.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index d4a87ee39..abcefed74 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -51,7 +51,7 @@ int64_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebi { dist = (uprice - aveprice); dist *= dist; - fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); + //fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); } return(dist); } @@ -99,8 +99,7 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) prices_barupdate(&refbar,pricebits); } } - else if ( strcmp(acaddr,destaddr) != 0 ) - fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%lld\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,(long long)prices_bardist(&refbar,aveprice,pricebits)); + fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%lld\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,(long long)prices_bardist(&refbar,aveprice,pricebits)); } else return(-3); } } From d7758d26c83b2060577805887e8a03a0313cbab9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:20:16 -1100 Subject: [PATCH 3413/3904] Test --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index abcefed74..f8f61085b 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -51,7 +51,7 @@ int64_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebi { dist = (uprice - aveprice); dist *= dist; - //fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); + fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); } return(dist); } From a3b757fdbd1fd06a915212c7e40a4f7c9a4d7ab4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:23:03 -1100 Subject: [PATCH 3414/3904] Test --- src/cc/games/prices.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index f8f61085b..ed5c285c3 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -49,8 +49,7 @@ int64_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebi int64_t dist = 0; uint32_t uprice = (uint32_t)pricebits; if ( aveprice != 0 ) { - dist = (uprice - aveprice); - dist *= dist; + dist = ((int64_t)(uprice - aveprice) * (uprice - aveprice)); fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); } return(dist); From fda7fa0ef1e4e78562cac5316dbd4991ae4316fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:25:38 -1100 Subject: [PATCH 3415/3904] Test --- src/cc/games/prices.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index ed5c285c3..28c882446 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -46,10 +46,13 @@ int32_t prices_barupdate(struct prices_bar *bar,uint64_t pricebits) int64_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebits) { - int64_t dist = 0; uint32_t uprice = (uint32_t)pricebits; + int64_t a,b,dist = 0; uint32_t uprice = (uint32_t)pricebits; if ( aveprice != 0 ) { - dist = ((int64_t)(uprice - aveprice) * (uprice - aveprice)); + a = uprice; + b = aveprice; + dist = (a - b); + dist *= dist; fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); } return(dist); From b31363ad3cbbef4d6ad6c82140553c3b2c6fcfd2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:27:32 -1100 Subject: [PATCH 3416/3904] Test --- src/cc/games/prices.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 28c882446..9b36d6d80 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -46,14 +46,13 @@ int32_t prices_barupdate(struct prices_bar *bar,uint64_t pricebits) int64_t prices_bardist(struct prices_bar *bar,uint32_t aveprice,uint64_t pricebits) { - int64_t a,b,dist = 0; uint32_t uprice = (uint32_t)pricebits; + int64_t a,dist = 0; if ( aveprice != 0 ) { - a = uprice; - b = aveprice; - dist = (a - b); + a = (pricebits & 0xffffffff); + dist = (a - aveprice); dist *= dist; - fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); + //fprintf(stderr,"dist.%lld (u %u - ave %u) %d\n",(long long)dist,uprice,aveprice,uprice-aveprice); } return(dist); } From 1dcca1c4c1cd1da615dabed613d45bedbb6341a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:32:09 -1100 Subject: [PATCH 3417/3904] Mini --- src/cc/games/prices.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 9b36d6d80..27d98b532 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -66,7 +66,7 @@ void prices_bardisp(struct prices_bar *bar) int64_t prices_blockinfo(int32_t height,char *acaddr) { - std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t prizefund = 0; int32_t i,n,vini,numvouts,iter; struct prices_bar refbar; + std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t dist,bestdist=0,prizefund = 0; int32_t mini=-1,i,n,vini,numvouts,iter; struct prices_bar refbar; if ( (pindex= komodo_chainactive(height)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) @@ -96,11 +96,20 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) prizefund += tx.vout[0].nValue; if ( strcmp(acaddr,destaddr) == 0 ) { - fprintf(stderr,"REF "); + //fprintf(stderr,"REF "); prices_barupdate(&refbar,pricebits); } } - fprintf(stderr,"i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%lld\n",i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,(long long)prices_bardist(&refbar,aveprice,pricebits)); + else if ( strcmp(acaddr,destaddr) != 0 ) + { + dist = prices_bardist(&refbar,aveprice,pricebits); + if ( dist == 0 || dist < mindist ) + { + mindist = dist; + mini = i; + } + fprintf(stderr,"mini.%d i.%d %.8f t%u %.4f v.%d %s lag.%d i.%d dist.%lld\n",mini,i,(double)tx.vout[0].nValue/COIN,timestamp,(double)uprice/10000,numvouts,destaddr,(int32_t)(pindex->nTime-timestamp),iter,(long long)dist); + } } else return(-3); } } From 5191feefd4c543b4a02d965382cf70ba4b73627f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:32:46 -1100 Subject: [PATCH 3418/3904] Mindset --- src/cc/games/prices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 27d98b532..79e9d16c3 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -66,7 +66,7 @@ void prices_bardisp(struct prices_bar *bar) int64_t prices_blockinfo(int32_t height,char *acaddr) { - std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t dist,bestdist=0,prizefund = 0; int32_t mini=-1,i,n,vini,numvouts,iter; struct prices_bar refbar; + std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t dist,mindist=0,prizefund = 0; int32_t mini=-1,i,n,vini,numvouts,iter; struct prices_bar refbar; if ( (pindex= komodo_chainactive(height)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) From 1f36dbf75fb34899c7080e988a1f79b40ecaed5f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 01:34:24 -1100 Subject: [PATCH 3419/3904] Mindset --- src/cc/games/prices.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/games/prices.cpp b/src/cc/games/prices.cpp index 79e9d16c3..5c8437e5d 100644 --- a/src/cc/games/prices.cpp +++ b/src/cc/games/prices.cpp @@ -66,7 +66,7 @@ void prices_bardisp(struct prices_bar *bar) int64_t prices_blockinfo(int32_t height,char *acaddr) { - std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t dist,mindist=0,prizefund = 0; int32_t mini=-1,i,n,vini,numvouts,iter; struct prices_bar refbar; + std::vector vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t dist,mindist=(1LL<<60),prizefund = 0; int32_t mini=-1,i,n,vini,numvouts,iter; struct prices_bar refbar; if ( (pindex= komodo_chainactive(height)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) @@ -103,7 +103,7 @@ int64_t prices_blockinfo(int32_t height,char *acaddr) else if ( strcmp(acaddr,destaddr) != 0 ) { dist = prices_bardist(&refbar,aveprice,pricebits); - if ( dist == 0 || dist < mindist ) + if ( dist < mindist ) { mindist = dist; mini = i; From 394b00366e05193a4e98cc0d1c8f79acfa091f5a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 28 Mar 2019 20:34:55 +0800 Subject: [PATCH 3420/3904] fixed! --- src/cc/rewards.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 152842bbd..bc9464fb8 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -257,9 +257,10 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t } if ( !CheckTxFee(tx, txfee, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) ) return eval->Invalid("txfee is too high"); + amount = vinTx.vout[0].nValue; reward = RewardsCalc(amount,tx.vin[0].prevout.hash,APR,minseconds,maxseconds,mindeposit); if ( reward == 0 ) - return eval->Invalid("no elegible rewards"); + return eval->Invalid("no eligible rewards"); if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) { if ( tx.vout[1].nValue != 10000 ) @@ -284,7 +285,6 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t return eval->Invalid("unlock tx vout.1 is CC output"); else if ( tx.vout[1].scriptPubKey != vinTx.vout[1].scriptPubKey ) return eval->Invalid("unlock tx vout.1 mismatched scriptPubKey"); - amount = vinTx.vout[0].nValue; if ( RewardsExactAmounts(cp,eval,tx,txfee+tx.vout[1].nValue,sbits,fundingtxid) == 0 ) return false; else if ( tx.vout[1].nValue > amount+reward ) From 21a8da86675b4e44fde97c69a7dc18605d8e80c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:11:59 -1100 Subject: [PATCH 3421/3904] Mineropret and cbopret --- src/bitcoind.cpp | 23 ++++++++++-- src/komodo_defs.h | 2 +- src/komodo_gateway.h | 87 ++++++++++++++++++++++++++++++++++++++++++++ src/komodo_globals.h | 3 +- src/komodo_utils.h | 24 +++++++++++- src/main.cpp | 9 +++++ src/miner.cpp | 8 +++- 7 files changed, 148 insertions(+), 8 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index b2fa534a1..3c5cfe4d6 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -59,13 +59,16 @@ static bool fDaemon; #include "komodo_defs.h" #define KOMODO_ASSETCHAIN_MAXLEN 65 extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern uint32_t ASSETCHAINS_BLOCKTIME; +extern uint64_t ASSETCHAINS_CBOPRET; void komodo_passport_iteration(); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); +void komodo_cbopretupdate(); void WaitForShutdown(boost::thread_group* threadGroup) { - bool fShutdown = ShutdownRequested(); + int32_t i; bool fShutdown = ShutdownRequested(); // Tell the main threads to shutdown. while (!fShutdown) { @@ -73,13 +76,27 @@ void WaitForShutdown(boost::thread_group* threadGroup) if ( ASSETCHAINS_SYMBOL[0] == 0 ) { komodo_passport_iteration(); - MilliSleep(10000); + for (i=0; i<10; i++) + { + fShutdown = ShutdownRequested(); + if ( fShutdown != 0 ) + break; + MilliSleep(1000); + } } else { //komodo_interestsum(); //komodo_longestchain(); - MilliSleep(20000); + if ( ASSETCHAINS_CBOPRET != 0 ) + komodo_cbopretupdate(); + for (i=0; i Mineropret; + +CScript komodo_mineropret(int32_t nHeight) +{ + CScript opret; + if ( Mineropret.size() != 0 ) + { + opret << OP_RETURN << Mineropret); + } + return(opret); +} + +int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) +{ + std::vector vopret; uint32_t pricebits[4]; int32_t i; + if ( ASSETCHAINS_CBOPRET != 0 ) + { + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() == sizeof(pricebits) ) + { + memcpy(pricebits,&Mineropret[0],sizeof(pricebits)); + fprintf(stderr,"ht.%d: t%u %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000) + return(0); + } + return(-1); + } + return(0); +} + +cJSON *get_urljson(char *url) +{ + char *jsonstr; cJSON *json = 0; + if ( (jsonstr= issue_curl(url)) != 0 ) + { + fprintf(stderr,"(%s) -> (%s)\n",url,jsonstr); + json = cJSON_Parse(jsonstr); + free(jsonstr); + } + return(json); +} + +int32_t get_btcusd(uint32_t pricebits[4]) +{ + cJSON *pjson,*bpi,*obj; char str[512]; uint64_t btcusd = 0,btcgbp = 0,btceur = 0; + if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json")) != 0 ) + { + if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 ) + { + pricebits[0] = (uint32_t)time(NULL); + if ( (obj= jobj(bpi,(char *)"USD")) != 0 ) + { + btcusd = jdouble(obj,(char *)"rate_float") * SATOSHIDEN; + pricebits[1] = ((btcusd / 10000) & 0xffffffff); + } + if ( (obj= jobj(bpi,(char *)"GBP")) != 0 ) + { + btcgbp = jdouble(obj,(char *)"rate_float") * SATOSHIDEN; + pricebits[2] = ((btcgbp / 10000) & 0xffffffff); + } + if ( (obj= jobj(bpi,(char *)"EUR")) != 0 ) + { + btceur = jdouble(obj,(char *)"rate_float") * SATOSHIDEN; + pricebits[3] = ((btceur / 10000) & 0xffffffff); + } + } + free_json(pjson); + fprintf(stderr,"BTC/USD %.4f, BTC/GBP %.4f, BTC/EUR %.4f\n",dstr(btcusd),dstr(btcgbp),dstr(btceur)); + return(0); + } + return(-1); +} + +void komodo_cbopretupdate() +{ + uint32_t pricebits[4]; + if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) + { + if ( get_btcusd(pricebits) == 0 ) + { + Mineropret.resize(sizeof(pricebits)); + fprintf(stderr,"set pricebits\n"); + memcpy(&Mineropret[0],pricebits,sizeof(pricebits)); + } + } +} + diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 69ad6b840..097d10da0 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -50,6 +50,7 @@ int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JU std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES,ASSETCHAINS_MARMARA; bool VERUS_MINTBLOCKS; +std::vector Mineropret; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_BEAMPORT,ASSETCHAINS_CODAPORT; @@ -66,7 +67,7 @@ int64_t MAX_MONEY = 200000000 * 100000000LL; // spec will use an op_return with CLTV at front and anything after |OP_RETURN|PUSH of rest|OPRETTYPE_TIMELOCK|script| #define _ASSETCHAINS_TIMELOCKOFF 0xffffffffffffffff uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; -uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; +uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0; uint64_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c1f488c5c..2702772f8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1668,7 +1668,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn,hexstr; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_STAKED_NOTARY = GetArg("-stakednotary", -1); if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) { @@ -1810,6 +1810,16 @@ void komodo_args(char *argv0) ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); + ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); + hexstr = GetArg("-ac_mineropret",""); + if ( hexstr.size() != 0 ) + { + Mineropret.resize(hexstr.size()/2) + decode_hex(&Mineropret,hexstr.size()/2,(char *)hexstr.c_str()); + for (i=0; i 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -2048,6 +2058,16 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_BLOCKTIME != 60 ) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME); + if ( ASSETCHAINS_CBOPRET != 0 ) + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET); + fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); + } + if ( Mineropret.size() != 0 ) + { + for (i=0; i 0 && (nHeight & 1) == 0 ) + { + + } + else if ( ASSETCHAINS_MINEROPRET != 0 ) + { + if ( komodo_opretvalidate(nHeight,tx.vout[1].scriptPubKey) < 0 ) + return(false); + } return(true); } diff --git a/src/miner.cpp b/src/miner.cpp index 48b8c5c62..af1f14ba3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,6 +155,7 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); +CScript komodo_mineropret(int32_t nHeight); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -644,7 +645,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); } - else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_MINEROPRET != 0 ||(ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0) ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); @@ -672,6 +673,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 ptr[34] = OP_CHECKSIG; //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } + if ( ASSETCHAINS_MINEROPRET != 0 ) + { + txNew.vout.resize(txNew.size()+1); + txNew.vout[txNew.size()-1].scriptPubKey = komodo_mineropret(nHeight); + } //printf("autocreate commision vout\n"); } else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) From ca1ee9a8c1846fe6e7ce714785ec57793158ee68 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:18:06 -1100 Subject: [PATCH 3422/3904] syntax --- src/komodo_gateway.h | 6 ++---- src/komodo_utils.h | 4 ++-- src/main.cpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 46fc1d805..26443d41f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1554,9 +1554,7 @@ CScript komodo_mineropret(int32_t nHeight) { CScript opret; if ( Mineropret.size() != 0 ) - { - opret << OP_RETURN << Mineropret); - } + return(opret << OP_RETURN << Mineropret); return(opret); } @@ -1569,7 +1567,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( vopret.size() == sizeof(pricebits) ) { memcpy(pricebits,&Mineropret[0],sizeof(pricebits)); - fprintf(stderr,"ht.%d: t%u %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000) + fprintf(stderr,"ht.%d: t%u %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000); return(0); } return(-1); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2702772f8..fa3278fda 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1814,8 +1814,8 @@ void komodo_args(char *argv0) hexstr = GetArg("-ac_mineropret",""); if ( hexstr.size() != 0 ) { - Mineropret.resize(hexstr.size()/2) - decode_hex(&Mineropret,hexstr.size()/2,(char *)hexstr.c_str()); + Mineropret.resize(hexstr.size()/2); + decode_hex(&Mineropret[0],hexstr.size()/2,(char *)hexstr.c_str()); for (i=0; i Date: Thu, 28 Mar 2019 03:20:00 -1100 Subject: [PATCH 3423/3904] issue_curl --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 26443d41f..0e687c3d4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1575,6 +1575,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) return(0); } +#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) + cJSON *get_urljson(char *url) { char *jsonstr; cJSON *json = 0; From 99c55801a3b0006b93152364254e0815d1140ebd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:23:14 -1100 Subject: [PATCH 3424/3904] vout.size() --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index af1f14ba3..f79602d90 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -645,7 +645,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); } - else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_MINEROPRET != 0 ||(ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0) ) + else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_CBOPRET != 0 ||(ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0) ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); @@ -673,10 +673,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 ptr[34] = OP_CHECKSIG; //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } - if ( ASSETCHAINS_MINEROPRET != 0 ) + if ( ASSETCHAINS_CBOPRET != 0 ) { - txNew.vout.resize(txNew.size()+1); - txNew.vout[txNew.size()-1].scriptPubKey = komodo_mineropret(nHeight); + txNew.vout.resize(txNew.vout.size()+1); + txNew.vout[txNew.vout.size()-1].scriptPubKey = komodo_mineropret(nHeight); } //printf("autocreate commision vout\n"); } From f28b62c766e59259346ee41288647a9076a7ab3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:42:23 -1100 Subject: [PATCH 3425/3904] Skop genesis --- src/komodo_gateway.h | 5 +++-- src/main.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0e687c3d4..12e7cc4c2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1560,14 +1560,15 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; uint32_t pricebits[4]; int32_t i; + std::vector vopret; uint32_t pricebits[4]; int32_t i,lag; if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() == sizeof(pricebits) ) { memcpy(pricebits,&Mineropret[0],sizeof(pricebits)); - fprintf(stderr,"ht.%d: t%u %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000); + lag = (int32_t)(time(NULL) - pricebits[0]); + fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000); return(0); } return(-1); diff --git a/src/main.cpp b/src/main.cpp index d6993d203..b73a31856 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1018,9 +1018,9 @@ bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeigh { } - else if ( ASSETCHAINS_CBOPRET != 0 ) + else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 ) { - if ( komodo_opretvalidate(nHeight,tx.vout[1].scriptPubKey) < 0 ) + if ( komodo_opretvalidate(nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) return(false); } return(true); From dd3704e2b06b4701e4c745e109d4b313556a831d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:45:21 -1100 Subject: [PATCH 3426/3904] -print --- src/komodo_gateway.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 12e7cc4c2..d6e308229 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1583,7 +1583,7 @@ cJSON *get_urljson(char *url) char *jsonstr; cJSON *json = 0; if ( (jsonstr= issue_curl(url)) != 0 ) { - fprintf(stderr,"(%s) -> (%s)\n",url,jsonstr); + //fprintf(stderr,"(%s) -> (%s)\n",url,jsonstr); json = cJSON_Parse(jsonstr); free(jsonstr); } @@ -1629,7 +1629,6 @@ void komodo_cbopretupdate() if ( get_btcusd(pricebits) == 0 ) { Mineropret.resize(sizeof(pricebits)); - fprintf(stderr,"set pricebits\n"); memcpy(&Mineropret[0],pricebits,sizeof(pricebits)); } } From eab69d1d69175f23fa8ea141d80dcbbaca0e2c74 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:49:25 -1100 Subject: [PATCH 3427/3904] Reorder coinbase opret checks --- src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b73a31856..da1730696 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -980,7 +980,16 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeight) { // if time locks are on, ensure that this coin base is time locked exactly as it should be - if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || + if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) + { + + } + else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 ) + { + if ( komodo_opretvalidate(nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) + return(false); + } + else if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || (((nHeight >= 31680) || strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0) && komodo_ac_block_subsidy(nHeight) >= ASSETCHAINS_TIMELOCKGTE)) { CScriptID scriptHash; @@ -1014,15 +1023,6 @@ bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeigh } return(false); } - else if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) - { - - } - else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 ) - { - if ( komodo_opretvalidate(nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) - return(false); - } return(true); } From c2a73508a8e1670e1440e3bdd841b5ae394d3563 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:53:23 -1100 Subject: [PATCH 3428/3904] +print --- src/komodo_gateway.h | 2 +- src/main.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d6e308229..4eee1a300 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1570,7 +1570,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) lag = (int32_t)(time(NULL) - pricebits[0]); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000); return(0); - } + } else fprintf(stderr,"wrong size %d vs %d\n",(int32_t)vopret.size(),(int32_t)sizeof(pricebits)); return(-1); } return(0); diff --git a/src/main.cpp b/src/main.cpp index da1730696..b73a31856 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -980,16 +980,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeight) { // if time locks are on, ensure that this coin base is time locked exactly as it should be - if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) - { - - } - else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 ) - { - if ( komodo_opretvalidate(nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) - return(false); - } - else if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || + if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || (((nHeight >= 31680) || strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0) && komodo_ac_block_subsidy(nHeight) >= ASSETCHAINS_TIMELOCKGTE)) { CScriptID scriptHash; @@ -1023,6 +1014,15 @@ bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeigh } return(false); } + else if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) + { + + } + else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 ) + { + if ( komodo_opretvalidate(nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) + return(false); + } return(true); } From f6acb611122551d7a096ac18d5d859c7556c6cc8 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Thu, 28 Mar 2019 15:57:16 +0100 Subject: [PATCH 3429/3904] Updated ChannelsCC validation (#20) - More constrained vins/vouts - Fixed CC marker value - Added validation of ChannelsOpen in all tx - Switched to LOGSTREAM for logging --- src/cc/channels.cpp | 284 ++++++++++++++++++++++---------------------- 1 file changed, 142 insertions(+), 142 deletions(-) diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 504ba629a..08dedb3f9 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -62,6 +62,8 @@ Possible third iteration: // start of consensus code +#define CC_MARKER_VALUE 10000 + int64_t IsChannelsvout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey srcpub, CPubKey destpub,int32_t v) { char destaddr[65],channeladdr[65],tokenschanneladdr[65]; @@ -126,8 +128,8 @@ uint8_t DecodeChannelsOpRet(const CScript &scriptPubKey, uint256 &tokenid, uint2 { return(f); } - } else fprintf(stderr,"script[0] %02x != EVAL_CHANNELS\n",script[0]); - } else fprintf(stderr,"not enough opret.[%d]\n",(int32_t)vopret.size()); + } else LOGSTREAM("channelscc",CCLOG_DEBUG1, stream << "script[0] " << script[0] << " != EVAL_CHANNELS" << std::endl); + } else LOGSTREAM("channelscc",CCLOG_DEBUG1, stream << "not enough opret.[" << vopret.size() << "]" << std::endl); return(0); } @@ -167,7 +169,7 @@ bool ChannelsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti } if ( inputs != outputs ) { - fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); + LOGSTREAM("channelscc",CCLOG_INFO, stream << "inputs " << inputs << " vs outputs " << outputs << std::endl); return eval->Invalid("mismatched inputs != outputs"); } else return (true); @@ -183,7 +185,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & { int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numpayments,p1,param1; bool retval; uint256 txid,hashblock,p3,param3,opentxid,tmp_txid,genhashchain,hashchain,tokenid; - uint8_t funcid,hash[32],hashdest[32]; + uint8_t funcid,hash[32],hashdest[32]; char channeladdress[65],srcmarker[65],destmarker[65],destaddr[65],srcaddr[65],desttokensaddr[65],srctokensaddr[65]; int64_t p2,param2,payment; CPubKey srcpub, destpub; CTransaction channelOpenTx,channelCloseTx,prevTx; @@ -202,9 +204,20 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & else { txid = tx.GetHash(); - memcpy(hash,&txid,sizeof(hash)); + memcpy(hash,&txid,sizeof(hash)); if ( (funcid = DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey, tokenid, opentxid, srcpub, destpub, param1, param2, param3)) != 0) { + if (myGetTransaction(opentxid,channelOpenTx,hashblock)== 0) + return eval->Invalid("invalid channelopen tx!"); + else if ((numvouts=channelOpenTx.vout.size()) > 0 && (DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, numpayments, payment, hashchain)) != 'O') + return eval->Invalid("invalid channelopen OP_RETURN data!"); + GetCCaddress1of2(cp,channeladdress,srcpub,destpub); + GetCCaddress(cp,srcmarker,srcpub); + GetCCaddress(cp,destmarker,destpub); + Getscriptaddress(srcaddr,CScript() << ParseHex(HexStr(srcpub)) << OP_CHECKSIG); + Getscriptaddress(destaddr,CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG); + _GetCCaddress(srctokensaddr,EVAL_TOKENS,srcpub); + _GetCCaddress(desttokensaddr,EVAL_TOKENS,destpub); switch ( funcid ) { case 'O': @@ -225,56 +238,53 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & //vout.3: normal output of payment amount to receiver pubkey //vout.n-2: normal change //vout.n-1: opreturn - 'P' opentxid senderspubkey receiverspubkey depth numpayments secret - if (komodo_txnotarizedconfirmed(opentxid) == 0) - return eval->Invalid("channelOpen is not yet confirmed(notarised)!"); + if ( IsCCInput(channelOpenTx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[0],1,channeladdress,numpayments*payment)==0 ) + return eval->Invalid("vout.0 is CC or invalid amount for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[1],1,srcmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!"); + else if (komodo_txnotarizedconfirmed(opentxid) == 0) + return eval->Invalid("channelopen is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for channelPayment!"); + return eval->Invalid("vin.0 is normal for channelpayment!"); else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for channelPayment!"); + return eval->Invalid("vin.1 is CC for channelpayment!"); else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) - return eval->Invalid("vin.2 is CC for channelPayment!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition()==0 ) - return eval->Invalid("vout.0 is CC for channelPayment!"); - else if ( IsChannelsMarkervout(cp,tx,srcpub,1)==0 ) - return eval->Invalid("vout.1 is CC for channelPayment (marker to srcPub)!"); - else if ( IsChannelsMarkervout(cp,tx,destpub,2)==0 ) - return eval->Invalid("vout.2 is CC for channelPayment (marker to dstPub)!"); - else if ( tokenid!=zeroid && tx.vout[3].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.3 is CC for channelPayment!"); - else if ( tokenid==zeroid && tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) - return eval->Invalid("vout.3 is normal for channelPayment!"); - else if ( tokenid!=zeroid && tx.vout[3].scriptPubKey!=MakeCC1vout(EVAL_TOKENS,tx.vout[3].nValue,destpub).scriptPubKey) - return eval->Invalid("payment funds do not go to receiver!"); - else if ( tokenid==zeroid && tx.vout[3].scriptPubKey!=CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG) - return eval->Invalid("payment funds do not go to receiver!"); + return eval->Invalid("vin.2 is CC for channelpayment!"); + else if ( ConstrainVout(tx.vout[0],1,channeladdress,(numpayments-param2)*payment)==0 ) + return eval->Invalid("vout.0 is CC or invalid CC change amount for channelpayment!"); + else if ( ConstrainVout(tx.vout[1],1,srcmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelpayment!"); + else if ( ConstrainVout(tx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelpayment!"); + else if ( tokenid!=zeroid && ConstrainVout(tx.vout[3],1,desttokensaddr,param2*payment)==0 ) + return eval->Invalid("vout.3 is CC or invalid amount or invalid receiver for channelpayment!"); + else if ( tokenid==zeroid && ConstrainVout(tx.vout[3],0,destaddr,param2*payment)==0 ) + return eval->Invalid("vout.3 is normal or invalid amount or invalid receiver for channelpayment!"); else if ( param1 > CHANNELS_MAXPAYMENTS) return eval->Invalid("too many payment increments!"); else - { - if (myGetTransaction(opentxid,channelOpenTx,hashblock) != 0) + { + endiancpy(hash, (uint8_t * ) & param3, 32); + for (i = 0; i < numpayments-param1; i++) { - if ((numvouts=channelOpenTx.vout.size()) > 0 && (funcid=DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, numpayments, payment, hashchain)) != 0 && funcid!='O') - return eval->Invalid("invalid channelopen OP_RETURN data!"); - endiancpy(hash, (uint8_t * ) & param3, 32); - for (i = 0; i < numpayments-param1; i++) - { - vcalc_sha256(0, hashdest, hash, 32); - memcpy(hash, hashdest, 32); - } - endiancpy((uint8_t*)&genhashchain,hashdest,32); - if (hashchain!=genhashchain) - return eval->Invalid("invalid secret for payment, does not reach final hashchain!"); - else if (tx.vout[3].nValue != param2*payment) - return eval->Invalid("vout amount does not match number_of_payments*payment!"); + vcalc_sha256(0, hashdest, hash, 32); + memcpy(hash, hashdest, 32); } + endiancpy((uint8_t*)&genhashchain,hashdest,32); + if (hashchain!=genhashchain) + return eval->Invalid("invalid secret for payment, does not reach final hashchain!"); + else if (tx.vout[3].nValue != param2*payment) + return eval->Invalid("vout amount does not match number_of_payments*payment!"); if (myGetTransaction(tx.vin[1].prevout.hash,prevTx,hashblock) != 0) { if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) return eval->Invalid("invalid previous tx OP_RETURN data!"); - else if (tx.vout[1].scriptPubKey != prevTx.vout[1].scriptPubKey) - return eval->Invalid("invalid destination for sender marker!"); - else if (tx.vout[2].scriptPubKey != prevTx.vout[2].scriptPubKey) - return eval->Invalid("invalid destination for receiver marker!"); + else if ((*cp->ismyvin)(tx.vin[2].scriptSig) == 0 || prevTx.vout[tx.vin[2].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.2 is CC marker or invalid marker amount for channelpayment!"); else if (param1+param2!=p1) return eval->Invalid("invalid payment depth!"); else if (tx.vout[3].nValue > prevTx.vout[0].nValue) @@ -290,37 +300,37 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & //vout.1: CC vout marker to senders pubKey //vout.2: CC vout marker to receiver pubkey //vout.n-2: normal change - //vout.n-1: opreturn - 'C' opentxid senderspubkey receiverspubkey 0 0 0 - if (komodo_txnotarizedconfirmed(opentxid) == 0) - return eval->Invalid("channelOpen is not yet confirmed(notarised)!"); + //vout.n-1: opreturn - 'C' opentxid senderspubkey receiverspubkey numpayments payment 0 + if ( IsCCInput(channelOpenTx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[0],1,channeladdress,numpayments*payment)==0 ) + return eval->Invalid("vout.0 is CC or invalid amount for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[1],1,srcmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!"); + else if (komodo_txnotarizedconfirmed(opentxid) == 0) + return eval->Invalid("channelopen is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for channelClose!"); + return eval->Invalid("vin.0 is normal for channelclose!"); else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for channelClose!"); + return eval->Invalid("vin.1 is CC for channelclose!"); else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) - return eval->Invalid("vin.2 is CC for channelClose!"); - else if ( IsChannelsvout(cp,tx,srcpub,destpub,0)==0 ) - return eval->Invalid("vout.0 is CC for channelClose!"); - else if ( IsChannelsMarkervout(cp,tx,srcpub,1)==0 ) - return eval->Invalid("vout.1 is CC for channelClose (marker to srcPub)!"); - else if ( IsChannelsMarkervout(cp,tx,destpub,2)==0 ) - return eval->Invalid("vout.2 is CC for channelClose (marker to dstPub)!"); + return eval->Invalid("vin.2 is CC for channelclose!"); + else if ( ConstrainVout(tx.vout[0],1,channeladdress,0)==0 ) + return eval->Invalid("vout.0 is CC for channelclose!"); + else if ( ConstrainVout(tx.vout[1],1,srcmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelclose!"); + else if ( ConstrainVout(tx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelclose!"); else if ( param1 > CHANNELS_MAXPAYMENTS) return eval->Invalid("too many payment increments!"); - else if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) - return eval->Invalid("invalid open txid!"); - else if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, numpayments, payment, hashchain) != 'O') - return eval->Invalid("invalid channelopen OP_RETURN data!"); - else if (tx.vout[0].nValue != param1*payment) - return eval->Invalid("vout amount does not match number_of_payments*payment!"); else if (myGetTransaction(tx.vin[1].prevout.hash,prevTx,hashblock) != 0) { if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) return eval->Invalid("invalid previous tx OP_RETURN data!"); - else if (tx.vout[1].scriptPubKey != prevTx.vout[1].scriptPubKey) - return eval->Invalid("invalid destination for sender marker!"); - else if (tx.vout[2].scriptPubKey != prevTx.vout[2].scriptPubKey) - return eval->Invalid("invalid destination for receiver marker!"); + else if ((*cp->ismyvin)(tx.vin[2].scriptSig) == 0 || prevTx.vout[tx.vin[2].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.2 is CC marker or invalid marker amount for channelclose!"); else if (tx.vout[0].nValue != prevTx.vout[0].nValue) return eval->Invalid("invalid CC amount, amount must match funds in channel"); } @@ -334,50 +344,40 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & //vout.2: normal output of CC input to senders pubkey //vout.n-2: normal change //vout.n-1: opreturn - 'R' opentxid senderspubkey receiverspubkey numpayments payment closetxid - if (komodo_txnotarizedconfirmed(opentxid) == 0) - return eval->Invalid("channelOpen is not yet confirmed(notarised)!"); + if ( IsCCInput(channelOpenTx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[0],1,channeladdress,numpayments*payment)==0 ) + return eval->Invalid("vout.0 is CC or invalid amount for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[1],1,srcmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!"); + else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!"); + else if (komodo_txnotarizedconfirmed(opentxid) == 0) + return eval->Invalid("channelopen is not yet confirmed(notarised)!"); else if (komodo_txnotarizedconfirmed(param3) == 0) return eval->Invalid("channelClose is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) - return eval->Invalid("vin.0 is normal for channelRefund!"); + return eval->Invalid("vin.0 is normal for channelrefund!"); else if ( IsCCInput(tx.vin[1].scriptSig) == 0 ) - return eval->Invalid("vin.1 is CC for channelRefund!"); + return eval->Invalid("vin.1 is CC for channelrefund!"); else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) - return eval->Invalid("vin.2 is CC for channelRefund!"); - else if ( IsChannelsMarkervout(cp,tx,srcpub,0)==0 ) - return eval->Invalid("vout.0 is CC for channelRefund (marker to srcPub)!"); - else if ( IsChannelsMarkervout(cp,tx,destpub,1)==0 ) - return eval->Invalid("vout.1 is CC for channelRefund (marker to dstPub)!"); - else if ( tokenid!=zeroid && tx.vout[2].scriptPubKey.IsPayToCryptoCondition() == 0 ) - return eval->Invalid("vout.2 is CC for channelPayment!"); - else if ( tokenid==zeroid && tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) - return eval->Invalid("vout.2 is normal for channelPayment!"); - else if ( tokenid!=zeroid && tx.vout[2].scriptPubKey!=MakeCC1vout(EVAL_TOKENS,tx.vout[2].nValue,srcpub).scriptPubKey) - return eval->Invalid("payment funds do not go to sender!"); - else if ( tokenid==zeroid && tx.vout[2].scriptPubKey!=CScript() << ParseHex(HexStr(srcpub)) << OP_CHECKSIG) - return eval->Invalid("payment funds do not go to sender!"); + return eval->Invalid("vin.2 is CC for channelrefund!"); + else if ( ConstrainVout(tx.vout[0],1,srcmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.0 is CC marker to srcpub or invalid amount for channelrefund!"); + else if ( ConstrainVout(tx.vout[1],1,destmarker,CC_MARKER_VALUE)==0 ) + return eval->Invalid("vout.1 is CC marker to destpub or invalid amount for channelrefund!"); + else if ( tokenid!=zeroid && ConstrainVout(tx.vout[2],1,srctokensaddr,param1*payment)==0 ) + return eval->Invalid("vout.2 is CC or invalid amount or invalid receiver for channelrefund!"); + else if ( tokenid==zeroid && ConstrainVout(tx.vout[2],0,srcaddr,param1*payment)==0 ) + return eval->Invalid("vout.2 is normal or invalid amount or invalid receiver for channelrefund!"); else if ( param1 > CHANNELS_MAXPAYMENTS) return eval->Invalid("too many payment increments!"); - else if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) - return eval->Invalid("invalid open txid!"); - else if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, numpayments, payment, hashchain) != 'O') - return eval->Invalid("invalid channelopen OP_RETURN data!"); - else if (myGetTransaction(param3,channelCloseTx,hashblock) == 0) - return eval->Invalid("invalid close txid!"); - else if ((numvouts=channelCloseTx.vout.size()) > 0 && DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, param1, param2, param3) != 'C') - return eval->Invalid("invalid channelclose OP_RETURN data!"); - else if (tmp_txid!=opentxid) - return eval->Invalid("invalid close tx, opentxid do not match on close and refund!"); - else if (tx.vout[2].nValue != param1*payment) - return eval->Invalid("vout amount does not match number_of_payments*payment!"); else if (myGetTransaction(tx.vin[1].prevout.hash,prevTx,hashblock) != 0) { if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) return eval->Invalid("invalid previous tx OP_RETURN data!"); - else if (tx.vout[0].scriptPubKey != prevTx.vout[1].scriptPubKey) - return eval->Invalid("invalid destination for sender marker!"); - else if (tx.vout[1].scriptPubKey != prevTx.vout[2].scriptPubKey) - return eval->Invalid("invalid destination for receiver marker!"); + else if ((*cp->ismyvin)(tx.vin[2].scriptSig) == 0 || prevTx.vout[tx.vin[2].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.2 is CC marker or invalid marker amount for channelrefund!"); else if (tx.vout[2].nValue != prevTx.vout[0].nValue) return eval->Invalid("invalid amount, refund amount and funds in channel must match!"); } @@ -390,8 +390,8 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & else return eval->Invalid("unexpected channels missing funcid"); retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); if ( retval != 0 ) - fprintf(stderr,"Channel tx validated\n"); - else fprintf(stderr,"Channel tx invalid\n"); + LOGSTREAM("channels",CCLOG_INFO, stream << "Channels tx validated" << std::endl); + else fprintf(stderr,"Channels tx invalid\n"); return(retval); } } @@ -415,7 +415,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C } else { - fprintf(stderr,"invalid channel open txid\n"); + LOGSTREAM("channelscc",CCLOG_INFO, stream << "invalid channel open txid" << std::endl); return 0; } if (srcpub==mypk) marker=1; @@ -473,7 +473,7 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 if ( numpayments <= 0 || payment <= 0 || numpayments > CHANNELS_MAXPAYMENTS ) { CCerror = strprintf("invalid ChannelOpen param numpayments.%d max.%d payment.%lld\n",numpayments,CHANNELS_MAXPAYMENTS,(long long)payment); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } cp = CCinit(&C,EVAL_CHANNELS); @@ -484,11 +484,11 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 funds = numpayments * payment; if (tokenid!=zeroid) { - amount=AddNormalinputs(mtx,mypk,3*txfee,5); + amount=AddNormalinputs(mtx,mypk,txfee+2*CC_MARKER_VALUE,5); tokens=AddTokenCCInputs(cpTokens, mtx, mypk, tokenid, funds, 64); } - else amount=AddNormalinputs(mtx,mypk,funds+3*txfee,64); - if (amount+tokens >= funds+2*txfee) + else amount=AddNormalinputs(mtx,mypk,funds+txfee+2*CC_MARKER_VALUE,64); + if (amount+tokens >= funds+txfee+2*CC_MARKER_VALUE) { hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); endiancpy(hash,(uint8_t *)&hentropy,32); @@ -500,13 +500,13 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 endiancpy((uint8_t *)&hashchain,hashdest,32); if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS,funds,mypk,destpub)); else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS,funds,mypk,destpub)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,destpub)); if (tokenid!=zeroid && tokens>funds) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,tokens-funds,mypk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('O',tokenid,zeroid,mypk,destpub,numpayments,payment,hashchain))); } CCerror = strprintf("error adding funds"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -526,7 +526,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { CCerror = strprintf("invalid channel open txid"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, totalnumpayments, payment, hashchain)=='O') @@ -534,23 +534,23 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 if (mypk != srcpub && mypk != destpub) { CCerror = strprintf("this is not our channel"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } else if (amount % payment != 0 || amount 0) + if (AddNormalinputs(mtx,mypk,txfee+CC_MARKER_VALUE,3) > 0) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0) { @@ -562,12 +562,12 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 if (numpayments > prevdepth) { CCerror = strprintf("not enough funds in channel for that amount"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } else if (numpayments == 0) { CCerror = strprintf("invalid amount"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if (secret!=zeroid) @@ -582,7 +582,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 if (gensecret!=hashchain) { CCerror = strprintf("invalid secret supplied"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } @@ -605,13 +605,13 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 else { CCerror = strprintf("invalid previous tx"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,srcpub)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,srcpub)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,destpub)); if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, amount, destpub)); else mtx.vout.push_back(CTxOut(amount, CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG)); return (FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeChannelsOpRet('P', tokenid, opentxid, srcpub, destpub, prevdepth-numpayments, numpayments, secret))); @@ -619,12 +619,12 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 else { CCerror = strprintf("error adding CC inputs"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } CCerror = strprintf("error adding normal inputs"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -645,40 +645,40 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { CCerror = strprintf("invalid channel open txid"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { CCerror = strprintf("invalid channel open tx"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if (mypk != srcpub) { CCerror = strprintf("cannot close, you are not channel owner"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) + if ( AddNormalinputs(mtx,mypk,txfee+CC_MARKER_VALUE,3) > 0 ) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) { if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, funds, mypk, destpub)); else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds, mypk, destpub)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,destpub)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',tokenid,opentxid,mypk,destpub,funds/payment,payment,zeroid))); } else { CCerror = strprintf("error adding CC inputs"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } CCerror = strprintf("error adding normal inputs"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -699,48 +699,48 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) if (GetTransaction(closetxid,channelCloseTx,hashblock,false) == 0) { CCerror = strprintf("invalid channel close txid"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if ((numvouts=channelCloseTx.vout.size()) < 1 || DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,param1,param2,param3)!='C') { CCerror = strprintf("invalid channel close tx"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if (txid!=opentxid) { CCerror = strprintf("open and close txid are not from same channel"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { CCerror = strprintf("invalid channel open txid"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { CCerror = strprintf("invalid channel open tx"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } if (mypk != srcpub) { CCerror = strprintf("cannot refund, you are not the channel owner"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) + if ( AddNormalinputs(mtx,mypk,txfee+CC_MARKER_VALUE,3) > 0 ) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) { if ((GetTransaction(prevtxid,prevTx,hashblock,false) != 0) && (numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3) != 0) { - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,destpub)); if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,funds,mypk)); else mtx.vout.push_back(CTxOut(funds,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',tokenid,opentxid,mypk,destpub,funds/payment,payment,closetxid))); @@ -748,19 +748,19 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) else { CCerror = strprintf("previous tx is invalid"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } else { CCerror = strprintf("error adding CC inputs"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } } CCerror = strprintf("error adding normal inputs"); - fprintf(stderr,"%s\n",CCerror.c_str()); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -781,7 +781,7 @@ UniValue ChannelsList() txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second; - if ( (vout == 1 || vout == 2) && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + if ( (vout == 1 || vout == 2) && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') { From fb5b955a955e755890092066a47e293dd5aa6bea Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 03:57:28 -1100 Subject: [PATCH 3430/3904] +print --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4eee1a300..a6aa1b6f8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1630,6 +1630,7 @@ void komodo_cbopretupdate() { Mineropret.resize(sizeof(pricebits)); memcpy(&Mineropret[0],pricebits,sizeof(pricebits)); + fprintf(stderr,"set Mineropret[%d]\n",(int32_t)Mineropret.size()); } } } From 451af129c709cd3aefdc7f4403b1d1c46853c9b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:02:27 -1100 Subject: [PATCH 3431/3904] Est --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a6aa1b6f8..4a81624ac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1566,11 +1566,11 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() == sizeof(pricebits) ) { - memcpy(pricebits,&Mineropret[0],sizeof(pricebits)); + memcpy(pricebits,&vpopret[0],sizeof(pricebits)); lag = (int32_t)(time(NULL) - pricebits[0]); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000); return(0); - } else fprintf(stderr,"wrong size %d vs %d\n",(int32_t)vopret.size(),(int32_t)sizeof(pricebits)); + } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)sizeof(pricebits),(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); } return(0); @@ -1628,7 +1628,8 @@ void komodo_cbopretupdate() { if ( get_btcusd(pricebits) == 0 ) { - Mineropret.resize(sizeof(pricebits)); + if ( Mineropret.size() != sizeof(pricebits) ) + Mineropret.resize(sizeof(pricebits)); memcpy(&Mineropret[0],pricebits,sizeof(pricebits)); fprintf(stderr,"set Mineropret[%d]\n",(int32_t)Mineropret.size()); } From 6dcc38b76545713979ca69eba7ae9595d322c8ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:03:44 -1100 Subject: [PATCH 3432/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4a81624ac..2c78383df 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1566,7 +1566,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() == sizeof(pricebits) ) { - memcpy(pricebits,&vpopret[0],sizeof(pricebits)); + memcpy(pricebits,&vopret[0],sizeof(pricebits)); lag = (int32_t)(time(NULL) - pricebits[0]); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000); return(0); From 54ab6c61a174c7dc19079e2972fe0fc9d0f586b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:05:15 -1100 Subject: [PATCH 3433/3904] Height --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2c78383df..7e6deb57d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1568,7 +1568,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { memcpy(pricebits,&vopret[0],sizeof(pricebits)); lag = (int32_t)(time(NULL) - pricebits[0]); - fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000); + fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1)); return(0); } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)sizeof(pricebits),(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); From 3ba62bf865fca436f3165fb899dbaa4da4ca4512 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:07:39 -1100 Subject: [PATCH 3434/3904] Test --- src/komodo_gateway.h | 4 +++- src/komodo_utils.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7e6deb57d..9391406dc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1631,7 +1631,9 @@ void komodo_cbopretupdate() if ( Mineropret.size() != sizeof(pricebits) ) Mineropret.resize(sizeof(pricebits)); memcpy(&Mineropret[0],pricebits,sizeof(pricebits)); - fprintf(stderr,"set Mineropret[%d]\n",(int32_t)Mineropret.size()); + int32_t i; for (i=0; i Date: Thu, 28 Mar 2019 04:08:51 -1100 Subject: [PATCH 3435/3904] +print --- src/komodo_gateway.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9391406dc..63ada8787 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1554,7 +1554,10 @@ CScript komodo_mineropret(int32_t nHeight) { CScript opret; if ( Mineropret.size() != 0 ) + { + fprintf(stderr,"use Mineropret[%d]\n",(int32_t)Mineropret.size()); return(opret << OP_RETURN << Mineropret); + } return(opret); } From 4b62adba68f5603fea7dd04a28e9f2faf7059d8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:15:53 -1100 Subject: [PATCH 3436/3904] Test --- src/komodo_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d072f2dd5..a5a2eeb2c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2059,17 +2059,17 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_BLOCKTIME != 60 ) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME); + if ( Mineropret.size() != 0 ) + { + for (i=0; i Date: Thu, 28 Mar 2019 04:23:13 -1100 Subject: [PATCH 3437/3904] Fix miner --- src/komodo_utils.h | 2 +- src/miner.cpp | 48 +++++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a5a2eeb2c..1bc379f42 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2067,7 +2067,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CBOPRET != 0 ) { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET); - komodo_cbopretupdate(); + komodo_cbopretupdate(); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } } diff --git a/src/miner.cpp b/src/miner.cpp index f79602d90..31a6b3f9d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -648,37 +648,41 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_CBOPRET != 0 ||(ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0) ) { int32_t i; uint8_t *ptr; - txNew.vout.resize(2); - txNew.vout[1].nValue = commission; - if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) + if ( commission != 0 ) { - //fprintf(stderr,"mine to -ac_script\n"); - //txNew.vout[1].scriptPubKey = CScript() << ParseHex(); - int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); - len >>= 1; - txNew.vout[1].scriptPubKey.resize(len); - ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; - decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); - } - else - { - txNew.vout[1].scriptPubKey.resize(35); - ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; - ptr[0] = 33; - for (i=0; i<33; i++) + fprintf(stderr,"nonzero commission %.8f\n",(double)commission/COIN); + txNew.vout.resize(2); + txNew.vout[1].nValue = commission; + if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; - //fprintf(stderr,"%02x",ptr[i+1]); + //fprintf(stderr,"mine to -ac_script\n"); + //txNew.vout[1].scriptPubKey = CScript() << ParseHex(); + int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); + len >>= 1; + txNew.vout[1].scriptPubKey.resize(len); + ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; + decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + } + else + { + txNew.vout[1].scriptPubKey.resize(35); + ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; + ptr[0] = 33; + for (i=0; i<33; i++) + { + ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; + //fprintf(stderr,"%02x",ptr[i+1]); + } + ptr[34] = OP_CHECKSIG; + //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } - ptr[34] = OP_CHECKSIG; - //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } if ( ASSETCHAINS_CBOPRET != 0 ) { txNew.vout.resize(txNew.vout.size()+1); txNew.vout[txNew.vout.size()-1].scriptPubKey = komodo_mineropret(nHeight); } - //printf("autocreate commision vout\n"); + printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); } else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { From 99527844f38241a47a61043602cdc5671643b928 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:27:46 -1100 Subject: [PATCH 3438/3904] Fix miner --- src/miner.cpp | 62 ++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 31a6b3f9d..69580da7b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -645,44 +645,35 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); } - else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_CBOPRET != 0 ||(ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0) ) + else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; - if ( commission != 0 ) + txNew.vout.resize(2); + txNew.vout[1].nValue = commission; + if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - fprintf(stderr,"nonzero commission %.8f\n",(double)commission/COIN); - txNew.vout.resize(2); - txNew.vout[1].nValue = commission; - if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) - { - //fprintf(stderr,"mine to -ac_script\n"); - //txNew.vout[1].scriptPubKey = CScript() << ParseHex(); - int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); - len >>= 1; - txNew.vout[1].scriptPubKey.resize(len); - ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; - decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); - } - else - { - txNew.vout[1].scriptPubKey.resize(35); - ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; - ptr[0] = 33; - for (i=0; i<33; i++) - { - ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; - //fprintf(stderr,"%02x",ptr[i+1]); - } - ptr[34] = OP_CHECKSIG; - //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); - } + //fprintf(stderr,"mine to -ac_script\n"); + //txNew.vout[1].scriptPubKey = CScript() << ParseHex(); + int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); + len >>= 1; + txNew.vout[1].scriptPubKey.resize(len); + ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; + decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); } - if ( ASSETCHAINS_CBOPRET != 0 ) + else { - txNew.vout.resize(txNew.vout.size()+1); - txNew.vout[txNew.vout.size()-1].scriptPubKey = komodo_mineropret(nHeight); + txNew.vout[1].scriptPubKey.resize(35); + ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; + ptr[0] = 33; + for (i=0; i<33; i++) + { + ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; + //fprintf(stderr,"%02x",ptr[i+1]); + } + ptr[34] = OP_CHECKSIG; + //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } - printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); + //printf("autocreate commision vout\n"); } else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { @@ -733,7 +724,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); } else fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); } - + if ( ASSETCHAINS_CBOPRET != 0 ) + { + txNew.vout.resize(txNew.vout.size()+1); + txNew.vout[txNew.vout.size()-1].scriptPubKey = komodo_mineropret(nHeight); + printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); + } pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; From 7ecb2d8b5daae27acbb8094de694956214080b95 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:32:07 -1100 Subject: [PATCH 3439/3904] Test --- src/komodo_gateway.h | 2 +- src/miner.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 63ada8787..2b9e7709d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1555,7 +1555,7 @@ CScript komodo_mineropret(int32_t nHeight) CScript opret; if ( Mineropret.size() != 0 ) { - fprintf(stderr,"use Mineropret[%d]\n",(int32_t)Mineropret.size()); + //fprintf(stderr,"use Mineropret[%d]\n",(int32_t)Mineropret.size()); return(opret << OP_RETURN << Mineropret); } return(opret); diff --git a/src/miner.cpp b/src/miner.cpp index 69580da7b..9246b7e6a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -726,8 +726,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } if ( ASSETCHAINS_CBOPRET != 0 ) { - txNew.vout.resize(txNew.vout.size()+1); - txNew.vout[txNew.vout.size()-1].scriptPubKey = komodo_mineropret(nHeight); + int32_t numv = (int32_t)txNew.vout.size(); + txNew.vout.resize(numv+1); + txNew.vout[numv].nValue = 0; + txNew.vout[numv].scriptPubKey = komodo_mineropret(nHeight); printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; From eb58e86e18559b5b8f4bfed2ba6574560558d795 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:32:37 -1100 Subject: [PATCH 3440/3904] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9246b7e6a..f131bc90e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -730,7 +730,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(numv+1); txNew.vout[numv].nValue = 0; txNew.vout[numv].scriptPubKey = komodo_mineropret(nHeight); - printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); + //printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; From 71b0de3f217361465b2860a1f77eb3b763feba19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 04:34:58 -1100 Subject: [PATCH 3441/3904] -print --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2b9e7709d..e39470317 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1634,9 +1634,9 @@ void komodo_cbopretupdate() if ( Mineropret.size() != sizeof(pricebits) ) Mineropret.resize(sizeof(pricebits)); memcpy(&Mineropret[0],pricebits,sizeof(pricebits)); - int32_t i; for (i=0; i Date: Thu, 28 Mar 2019 04:36:43 -1100 Subject: [PATCH 3442/3904] Test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e39470317..03816ee79 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1563,7 +1563,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; uint32_t pricebits[4]; int32_t i,lag; + std::vector vopret; uint32_t pricebits[4]; int32_t i,lag,lag2; if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1571,7 +1571,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { memcpy(pricebits,&vopret[0],sizeof(pricebits)); lag = (int32_t)(time(NULL) - pricebits[0]); - fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1)); + lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); + fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); return(0); } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)sizeof(pricebits),(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); From 180ca470b0a9f79f7a8964f4224e62ac218c0c0e Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Thu, 28 Mar 2019 17:16:09 +0100 Subject: [PATCH 3443/3904] Fix CC change calculation for channelspayment --- src/cc/channels.cpp | 28 ++++++++++++++++++++++++++-- src/wallet/rpcwallet.cpp | 4 ++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 08dedb3f9..2887c18e1 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -254,8 +254,6 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vin.1 is CC for channelpayment!"); else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) return eval->Invalid("vin.2 is CC for channelpayment!"); - else if ( ConstrainVout(tx.vout[0],1,channeladdress,(numpayments-param2)*payment)==0 ) - return eval->Invalid("vout.0 is CC or invalid CC change amount for channelpayment!"); else if ( ConstrainVout(tx.vout[1],1,srcmarker,CC_MARKER_VALUE)==0 ) return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelpayment!"); else if ( ConstrainVout(tx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) @@ -283,6 +281,8 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & { if ((numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, tmp_txid, srcpub, destpub, p1, p2, p3) == 0) return eval->Invalid("invalid previous tx OP_RETURN data!"); + else if ( ConstrainVout(tx.vout[0],1,channeladdress,(p1-param2)*payment)==0 ) + return eval->Invalid("vout.0 is CC or invalid CC change amount for channelpayment!"); else if ((*cp->ismyvin)(tx.vin[2].scriptSig) == 0 || prevTx.vout[tx.vin[2].prevout.n].nValue!=CC_MARKER_VALUE) return eval->Invalid("vin.2 is CC marker or invalid marker amount for channelpayment!"); else if (param1+param2!=p1) @@ -550,6 +550,12 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } + if (komodo_txnotarizedconfirmed(opentxid)==false) + { + CCerror = strprintf("channelsopen tx not yet confirmed/notarized"); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } if (AddNormalinputs(mtx,mypk,txfee+CC_MARKER_VALUE,3) > 0) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0) @@ -654,6 +660,12 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } + if (komodo_txnotarizedconfirmed(opentxid)==false) + { + CCerror = strprintf("channelsopen tx not yet confirmed/notarized"); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } if (mypk != srcpub) { CCerror = strprintf("cannot close, you are not channel owner"); @@ -708,6 +720,12 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } + if (komodo_txnotarizedconfirmed(closetxid)==false) + { + CCerror = strprintf("channelsclose tx not yet confirmed/notarized"); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } if (txid!=opentxid) { CCerror = strprintf("open and close txid are not from same channel"); @@ -720,6 +738,12 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } + if (komodo_txnotarizedconfirmed(opentxid)==false) + { + CCerror = strprintf("channelsopen tx not yet confirmed/notarized"); + LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { CCerror = strprintf("invalid channel open tx"); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 107508c18..5456f3b9c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6105,6 +6105,7 @@ UniValue channelsopen(const UniValue& params, bool fHelp) tokenid=Parseuint256((char *)params[3].get_str().c_str()); } hex = ChannelOpen(0,pubkey2pk(destpub),numpayments,payment,tokenid); + RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) { result.push_back(Pair("result", "success")); @@ -6135,6 +6136,7 @@ UniValue channelspayment(const UniValue& params, bool fHelp) secret = Parseuint256((char *)params[2].get_str().c_str()); } hex = ChannelPayment(0,opentxid,amount,secret); + RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) { result.push_back(Pair("result", "success")); @@ -6155,6 +6157,7 @@ UniValue channelsclose(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); opentxid = Parseuint256((char *)params[0].get_str().c_str()); hex = ChannelClose(0,opentxid); + RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) { result.push_back(Pair("result", "success")); @@ -6176,6 +6179,7 @@ UniValue channelsrefund(const UniValue& params, bool fHelp) opentxid = Parseuint256((char *)params[0].get_str().c_str()); closetxid = Parseuint256((char *)params[1].get_str().c_str()); hex = ChannelRefund(0,opentxid,closetxid); + RETURN_IF_ERROR(CCerror); if ( hex.size() > 0 ) { result.push_back(Pair("result", "success")); From 736a5cc15c42bb46090f5038352d6473410e23c5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 05:42:16 -1100 Subject: [PATCH 3444/3904] Price bits --- src/komodo_gateway.h | 102 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 10 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 03816ee79..3a06d14b6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1549,13 +1549,79 @@ void komodo_passport_iteration() } extern std::vector Mineropret; +#define PRICES_MAXCHANGE (COIN / 100) +#define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) + +int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) +{ + CBlockIndex *pindex; CBlock block; int32_t numvouts; std::vector vopret; + if ( (pindex= komodo_chainactive(nHeight)) != 0 ) + { + if ( komodo_blockload(block,pindex) == 0 ) + { + numvouts = (int32_t)block.vout[0].size(); + GetOpReturnData(block.vout[numvouts-1].scriptPubKey,vopret); + if ( vopret.size() == PRICES_SIZEBIT0 ) + { + memcpy(prevbits,&vopret[0],PRICES_SIZEBIT0); + return(0); + } + } + } + fprintf(stderr,"couldnt get pricebits for %d\n",nHeight); + return(-1); +} + +uint32_t komodo_pricenew(uint32_t price,uint32_t refprice,int64_t tolerance) +{ + uint32_t highprice,lowprice; + highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; + lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; + if ( price > highprice ) + return(highprice); + else if ( price < lowprice ) + return(lowprice); + else return(0); +} + +int32_t komodo_pricecmp(uint32_t pricebitsA[4],uint32_t pricebitsB[4],int64_t tolerance) +{ + int32_t i; + for (i=1; i<4; i++) + if ( komodo_pricenew(pricebitsA[i],pricebitsB[i],tolerance) != 0 ) + return(-1); + return(0); +} + +int32_t komodo_priceclamp(uint32_t pricebits[4],uint32_t refprices[4],int64_t tolerance) +{ + int32_t i; uint32_t newprice; + for (i=1; i<4; i++) + { + if ( (newprice= komodo_pricenew(pricebits[i],refprices[i],tolerance)) != 0 ) + { + fprintf(stderr,"priceclamp[%d] %u -> %u\n",i,pricebits[i],newprice); + pricebits[i] = newprice; + } + } + return(0); +} CScript komodo_mineropret(int32_t nHeight) { - CScript opret; - if ( Mineropret.size() != 0 ) + CScript opret; uint32_t pricebits[4],prevbits[4]; + if ( Mineropret.size() == PRICES_SIZEBIT0 ) { - //fprintf(stderr,"use Mineropret[%d]\n",(int32_t)Mineropret.size()); + if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) + { + memcpy(pricebits,&Mineropret[0],PRICES_SIZEBIT0); + if ( komodo_pricecmp(pricebit,prevbits,PRICES_MAXCHANGE) < 0 ) + { + komodo_priceclamp(pricebits,prevbits,PRICES_MAXCHANGE); + fprintf(stderr,"update Mineropret to clamped prices\n"); + memcpy(&Mineropret[0],pricebits,PRICES_SIZEBIT0); + } + } return(opret << OP_RETURN << Mineropret); } return(opret); @@ -1563,18 +1629,34 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; uint32_t pricebits[4]; int32_t i,lag,lag2; + std::vector vopret; uint32_t pricebits[4],prevbits[4]; int32_t i,lag,lag2; if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() == sizeof(pricebits) ) + if ( vopret.size() == PRICES_SIZEBIT0 ) { - memcpy(pricebits,&vopret[0],sizeof(pricebits)); + memcpy(pricebits,&vopret[0],PRICES_SIZEBIT0); lag = (int32_t)(time(NULL) - pricebits[0]); + if ( lag < 0 ) + lag = -lag; lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); + if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() == PRICES_SIZEBIT0 ) + { + memcpy(prevbits,&Mineropret[0],PRICES_SIZEBIT0); + if ( komodo_pricecmp(pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + return(-1); + } + if ( nHeight > 1 ) + { + if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) + { + if ( komodo_pricecmp(pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + return(-1); + } else return(-1); + } return(0); - } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)sizeof(pricebits),(int32_t)scriptPubKey.size(),scriptPubKey[0]); + } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)PRICES_SIZEBIT0,(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); } return(0); @@ -1632,9 +1714,9 @@ void komodo_cbopretupdate() { if ( get_btcusd(pricebits) == 0 ) { - if ( Mineropret.size() != sizeof(pricebits) ) - Mineropret.resize(sizeof(pricebits)); - memcpy(&Mineropret[0],pricebits,sizeof(pricebits)); + if ( Mineropret.size() != PRICES_SIZEBIT0 ) + Mineropret.resize(PRICES_SIZEBIT0); + memcpy(&Mineropret[0],pricebits,PRICES_SIZEBIT0); //int32_t i; for (i=0; i Date: Thu, 28 Mar 2019 05:44:49 -1100 Subject: [PATCH 3445/3904] fix --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3a06d14b6..664548c2c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1615,7 +1615,7 @@ CScript komodo_mineropret(int32_t nHeight) if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { memcpy(pricebits,&Mineropret[0],PRICES_SIZEBIT0); - if ( komodo_pricecmp(pricebit,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { komodo_priceclamp(pricebits,prevbits,PRICES_MAXCHANGE); fprintf(stderr,"update Mineropret to clamped prices\n"); From 66f7b96df6140864ad9c663d2ae6323702a7cad1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 05:46:14 -1100 Subject: [PATCH 3446/3904] Fix --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 664548c2c..1e5aed8cf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1554,13 +1554,14 @@ extern std::vector Mineropret; int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) { - CBlockIndex *pindex; CBlock block; int32_t numvouts; std::vector vopret; + CBlockIndex *pindex; CBlock block; CTransaction tx; int32_t numvouts; std::vector vopret; if ( (pindex= komodo_chainactive(nHeight)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) { - numvouts = (int32_t)block.vout[0].size(); - GetOpReturnData(block.vout[numvouts-1].scriptPubKey,vopret); + tx = block.vtx[0]; + numvouts = (int32_t)tx.vout[0].size(); + GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); if ( vopret.size() == PRICES_SIZEBIT0 ) { memcpy(prevbits,&vopret[0],PRICES_SIZEBIT0); From 0698ed694afcf9ce65572583bb4efed583b9fc16 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 05:47:20 -1100 Subject: [PATCH 3447/3904] -tx --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1e5aed8cf..1b0664bb8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1560,7 +1560,7 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) if ( komodo_blockload(block,pindex) == 0 ) { tx = block.vtx[0]; - numvouts = (int32_t)tx.vout[0].size(); + numvouts = (int32_t)tx.vout.size(); GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); if ( vopret.size() == PRICES_SIZEBIT0 ) { From e9f398a93291935d076072c3ed5bb57a9e57bd36 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Thu, 28 Mar 2019 23:50:52 +0700 Subject: [PATCH 3448/3904] added tuis --- src/tui/LICENSE | 21 + src/tui/README.md | 58 + src/tui/lib/logo.txt | 39 + src/tui/lib/rpclib.py | 129 ++ src/tui/lib/tuilib.py | 1965 ++++++++++++++++++++++++++++++ src/tui/requirements.txt | 8 + src/tui/tui_assets.py | 67 + src/tui/tui_gateways_creation.py | 67 + src/tui/tui_gateways_usage.py | 96 ++ src/tui/tui_marmara.py | 68 ++ src/tui/tui_oracles.py | 67 + src/tui/tui_rogue.py | 116 ++ src/tui/tui_tetris.py | 96 ++ 13 files changed, 2797 insertions(+) create mode 100644 src/tui/LICENSE create mode 100644 src/tui/README.md create mode 100644 src/tui/lib/logo.txt create mode 100644 src/tui/lib/rpclib.py create mode 100755 src/tui/lib/tuilib.py create mode 100644 src/tui/requirements.txt create mode 100755 src/tui/tui_assets.py create mode 100755 src/tui/tui_gateways_creation.py create mode 100755 src/tui/tui_gateways_usage.py create mode 100755 src/tui/tui_marmara.py create mode 100755 src/tui/tui_oracles.py create mode 100755 src/tui/tui_rogue.py create mode 100755 src/tui/tui_tetris.py diff --git a/src/tui/LICENSE b/src/tui/LICENSE new file mode 100644 index 000000000..3300ef648 --- /dev/null +++ b/src/tui/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Anton Lysakov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/tui/README.md b/src/tui/README.md new file mode 100644 index 000000000..61e733794 --- /dev/null +++ b/src/tui/README.md @@ -0,0 +1,58 @@ +# Komodo Cryptoconditons Terminal User Interfaces (aka TUIs) + +These tools creating for demonstration and partial automation of Komodo cryptoconditions modules testing. (RogueCC game, AssetsCC, OraclesCC, GatewaysCC, MarmaraCC, ...) + + +Developer installation (on Ubuntu 18.04) : + +Python3 required for execution: + +* `sudo apt-get install python3.6 python3-pip libgnutls28-dev` + +pip packages needed: + +* `pip3 install setuptools wheel slick-bitcoinrpc` +* or `pip3 install -r requirements.txt` + +Starting: + +# TUI for RogueCC + +If you're looking for player 3 in 1 (daemon + game + TUI) multiOS bundle - please check `releases` of this repo. + +`python3 rogue_tui.py` + +![alt text](https://i.imgur.com/gkcxMGt.png) + +# TUI for OraclesCC + +Have files uploader/downloader functionality - also there is a AWS branch for AWS certificates uploading demonstration + +`python3 oracles_cc_tui.py` + +![alt text](https://i.imgur.com/tfHwRqc.png) + +# TUI for GatewaysCC + +![alt text](https://i.imgur.com/c8DPfpp.png) + +`python3 gateways_creation_tui.py` + +`python3 gateways_usage_tui.py` + +At the moment raw version of manual gateway how-to guide can be found here: https://docs.komodoplatform.com/cc/contracts/gateways/scenarios/tutorial.html I advice to read it before you start use this tool to understand the flow. + +# TUI for MarmaraCC + +`python3 marmara_tui.py` + +![alt text](https://i.imgur.com/uonMWHl.png) + +# TUI for AssetsCC (not much finished) + +`python3 assets_cc_tui.py` + +Before execution be sure than daemon for needed AC up. + + + diff --git a/src/tui/lib/logo.txt b/src/tui/lib/logo.txt new file mode 100644 index 000000000..15ace1ad5 --- /dev/null +++ b/src/tui/lib/logo.txt @@ -0,0 +1,39 @@ +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0xlc:ldOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0xo:,........';lxOXNMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMWNKkoc,..................':ox0XWMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMWNKkdc;............................,:ok0NWMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMWNKOdl;'.....................................,cdkKNWMMMMMMMMMMMMMM +MMMMMMMMMMMMMW0c'..............................................';kNMMMMMMMMMMMMM +MMMMMMMMMMMMMK:......................';:c:'......................,kWMMMMMMMMMMMM +MMMMMMMMMMMMXl...................;cdkKNWWNXOdl;'..................;OWMMMMMMMMMMM +MMMMMMMMMMMNo...............,cok0XWMMMMMMMMMMWNKkdc;'..............:KMMMMMMMMMMM +MMMMMMMMMMWx'...........;ox0XWMMMMMMMMMMMMMMMMMMMMWNKko:............lXMMMMMMMMMM +MMMMMMMMMWk,...........lXWMMMMMMMMMMMMWWWWMMMMMMMMMMMMMNx'...........oNMMMMMMMMM +MMMMMMMMW0;...........cKMMMMMMMMMWNXOdl::cdkKNWMMMMMMMMMNo...........'xWMMMMMMMM +MMMMMMMMKc...........;0WMMMMMWN0xl:,........';ldOXWMMMMMMXl...........,OWMMMMMMM +MMMMMMMXl...........,kWMMMMMMKl..................;OWMMMMMMK:...........;0MMMMMMM +MMMMMMNd...........'xNMMMMMMXl....................:0WMMMMMWO;...........cKMMMMMM +MMMMMNx'...........oNMMMMMMNd......................cKMMMMMMWk'...........lXMMMMM +MMMMWO,...........lXMMMMMMWx'.......................oXMMMMMMNd'...........dNMMMM +MMMMXc...........,OWMMMMMMK:........................,kWMMMMMMKc...........;0MMMM +MMMMWx'...........oXMMMMMMNd........................cKMMMMMMWk,...........lXMMMM +MMMMMNd...........'dNMMMMMMXl......................:0MMMMMMWO;...........cKMMMMM +MMMMMMXl...........,kWMMMMMMKc....................,OWMMMMMM0:...........;0MMMMMM +MMMMMMMKc...........;OWMMMMMW0:..................,kWMMMMMMXc...........,OWMMMMMM +MMMMMMMM0;...........:KMMMMMMWKko:,..........';lx0WMMMMMMNo...........'xWMMMMMMM +MMMMMMMMWk,...........lXMMMMMMMMWWXOxl:,,;cdOKNWMMMMMMMMNx'...........dNMMMMMMMM +MMMMMMMMMWx'...........dNMMMMMMMMMMMMWNXXNWMMMMMMMMMMMMWk,...........lXMMMMMMMMM +MMMMMMMMMMNo............cx0XWMMMMMMMMMMMMMMMMMMMMMMWN0kl,...........cKMMMMMMMMMM +MMMMMMMMMMMXl..............,:ok0XWMMMMMMMMMMMMWNKkdc;..............;0WMMMMMMMMMM +MMMMMMMMMMMMK:..................,cokKNWMMWNKOdl;'.................,kWMMMMMMMMMMM +MMMMMMMMMMMMWO;......................;cool;'.....................'xNMMMMMMMMMMMM +MMMMMMMMMMMMMWk;................................................'dNMMMMMMMMMMMMM +MMMMMMMMMMMMMMWXOxl;'.......................................,cdkKWMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMWNKOdc;..............................,cok0NWMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMWNKkoc,....................,:ox0XWMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0ko:,..........':lx0XWMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0xl:,,;ldOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNNXNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM \ No newline at end of file diff --git a/src/tui/lib/rpclib.py b/src/tui/lib/rpclib.py new file mode 100644 index 000000000..a79fc73d4 --- /dev/null +++ b/src/tui/lib/rpclib.py @@ -0,0 +1,129 @@ +import http +from slickrpc import Proxy + + +# RPC connection +def rpc_connect(rpc_user, rpc_password, port): + try: + rpc_connection = Proxy("http://%s:%s@127.0.0.1:%d"%(rpc_user, rpc_password, port)) + except Exception: + raise Exception("Connection error! Probably no daemon on selected port.") + return rpc_connection + + +# Non CC calls +def getinfo(rpc_connection): + try: + getinfo = rpc_connection.getinfo() + except Exception: + raise Exception("Connection error!") + return getinfo + + +def sendrawtransaction(rpc_connection, hex): + tx_id = rpc_connection.sendrawtransaction(hex) + return tx_id + + +def gettransaction(rpc_connection, tx_id): + transaction_info = rpc_connection.gettransaction(tx_id) + return transaction_info + + +def getrawtransaction(rpc_connection, tx_id): + rawtransaction = rpc_connection.getrawtransaction(tx_id) + return rawtransaction + + +def getbalance(rpc_connection): + balance = rpc_connection.getbalance() + return balance + +# Token CC calls +def token_create(rpc_connection, name, supply, description): + token_hex = rpc_connection.tokencreate(name, supply, description) + return token_hex + + +def token_info(rpc_connection, token_id): + token_info = rpc_connection.tokeninfo(token_id) + return token_info + + +#TODO: have to add option with pubkey input +def token_balance(rpc_connection, token_id): + token_balance = rpc_connection.tokenbalance(token_id) + return token_balance + +def token_list(rpc_connection): + token_list = rpc_connection.tokenlist() + return token_list + + +def token_convert(rpc_connection, evalcode, token_id, pubkey, supply): + token_convert_hex = rpc_connection.tokenconvert(evalcode, token_id, pubkey, supply) + return token_convert_hex + +def get_rawmempool(rpc_connection): + mempool = rpc_connection.getrawmempool() + return mempool + +# Oracle CC calls +def oracles_create(rpc_connection, name, description, data_type): + oracles_hex = rpc_connection.oraclescreate(name, description, data_type) + return oracles_hex + + +def oracles_register(rpc_connection, oracle_id, data_fee): + oracles_register_hex = rpc_connection.oraclesregister(oracle_id, data_fee) + return oracles_register_hex + + +def oracles_subscribe(rpc_connection, oracle_id, publisher_id, data_fee): + oracles_subscribe_hex = rpc_connection.oraclessubscribe(oracle_id, publisher_id, data_fee) + return oracles_subscribe_hex + + +def oracles_info(rpc_connection, oracle_id): + oracles_info = rpc_connection.oraclesinfo(oracle_id) + return oracles_info + + +def oracles_data(rpc_connection, oracle_id, hex_string): + oracles_data = rpc_connection.oraclesdata(oracle_id, hex_string) + return oracles_data + + +def oracles_list(rpc_connection): + oracles_list = rpc_connection.oracleslist() + return oracles_list + + +def oracles_samples(rpc_connection, oracletxid, batonutxo, num): + oracles_sample = rpc_connection.oraclessamples(oracletxid, batonutxo, num) + return oracles_sample + + +# Gateways CC calls +# Arguments changing dynamically depends of M N, so supposed to wrap it this way +# token_id, oracle_id, coin_name, token_supply, M, N + pubkeys for each N +def gateways_bind(rpc_connection, *args): + gateways_bind_hex = rpc_connection.gatewaysbind(*args) + return gateways_bind_hex + + +def gateways_deposit(rpc_connection, gateway_id, height, coin_name,\ + coin_txid, claim_vout, deposit_hex, proof, dest_pub, amount): + gateways_deposit_hex = rpc_connection.gatewaysdeposit(gateway_id, height, coin_name,\ + coin_txid, claim_vout, deposit_hex, proof, dest_pub, amount) + return gateways_deposit_hex + + +def gateways_claim(rpc_connection, gateway_id, coin_name, deposit_txid, dest_pub, amount): + gateways_claim_hex = rpc_connection.gatewaysclaim(gateway_id, coin_name, deposit_txid, dest_pub, amount) + return gateways_claim_hex + + +def gateways_withdraw(rpc_connection, gateway_id, coin_name, withdraw_pub, amount): + gateways_withdraw_hex = rpc_connection.gatewayswithdraw(gateway_id, coin_name, withdraw_pub, amount) + return gateways_withdraw_hex diff --git a/src/tui/lib/tuilib.py b/src/tui/lib/tuilib.py new file mode 100755 index 000000000..da1d7658a --- /dev/null +++ b/src/tui/lib/tuilib.py @@ -0,0 +1,1965 @@ +from lib import rpclib +import json +import time +import re +import sys +import pickle +import platform +import os +import subprocess +import signal +from slickrpc import Proxy +from binascii import hexlify +from binascii import unhexlify +from functools import partial +from shutil import copy + + +operating_system = platform.system() +if operating_system != 'Win64' and operating_system != 'Windows': + import readline + + +def colorize(string, color): + + colors = { + 'blue': '\033[94m', + 'magenta': '\033[95m', + 'green': '\033[92m', + 'red': '\033[91m' + } + if color not in colors: + return string + else: + return colors[color] + string + '\033[0m' + + +def rpc_connection_tui(): + # TODO: possible to save multiply entries from successfull sessions and ask user to choose then + while True: + restore_choice = input("Do you want to use connection details from previous session? [y/n]: ") + if restore_choice == "y": + try: + with open("connection.json", "r") as file: + connection_json = json.load(file) + rpc_user = connection_json["rpc_user"] + rpc_password = connection_json["rpc_password"] + rpc_port = connection_json["rpc_port"] + rpc_connection = rpclib.rpc_connect(rpc_user, rpc_password, int(rpc_port)) + except FileNotFoundError: + print(colorize("You do not have cached connection details. Please select n for connection setup", "red")) + break + elif restore_choice == "n": + rpc_user = input("Input your rpc user: ") + rpc_password = input("Input your rpc password: ") + rpc_port = input("Input your rpc port: ") + connection_details = {"rpc_user": rpc_user, + "rpc_password": rpc_password, + "rpc_port": rpc_port} + connection_json = json.dumps(connection_details) + with open("connection.json", "w+") as file: + file.write(connection_json) + rpc_connection = rpclib.rpc_connect(rpc_user, rpc_password, int(rpc_port)) + break + else: + print(colorize("Please input y or n", "red")) + return rpc_connection + + +def def_credentials(chain): + rpcport =''; + operating_system = platform.system() + if operating_system == 'Darwin': + ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' + elif operating_system == 'Linux': + ac_dir = os.environ['HOME'] + '/.komodo' + elif operating_system == 'Win64' or operating_system == 'Windows': + ac_dir = '%s/komodo/' % os.environ['APPDATA'] + if chain == 'KMD': + coin_config_file = str(ac_dir + '/komodo.conf') + else: + coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') + with open(coin_config_file, 'r') as f: + for line in f: + l = line.rstrip() + if re.search('rpcuser', l): + rpcuser = l.replace('rpcuser=', '') + elif re.search('rpcpassword', l): + rpcpassword = l.replace('rpcpassword=', '') + elif re.search('rpcport', l): + rpcport = l.replace('rpcport=', '') + if len(rpcport) == 0: + if chain == 'KMD': + rpcport = 7771 + else: + print("rpcport not in conf file, exiting") + print("check "+coin_config_file) + exit(1) + + return(Proxy("http://%s:%s@127.0.0.1:%d"%(rpcuser, rpcpassword, int(rpcport)))) + + +def getinfo_tui(rpc_connection): + + info_raw = rpclib.getinfo(rpc_connection) + if isinstance(info_raw, dict): + for key in info_raw: + print("{}: {}".format(key, info_raw[key])) + input("Press [Enter] to continue...") + else: + print("Error!\n") + print(info_raw) + input("\nPress [Enter] to continue...") + + +def token_create_tui(rpc_connection): + + while True: + try: + name = input("Set your token name: ") + supply = input("Set your token supply: ") + description = input("Set your token description: ") + except KeyboardInterrupt: + break + else: + token_hex = rpclib.token_create(rpc_connection, name, supply, description) + if token_hex['result'] == "error": + print(colorize("\nSomething went wrong!\n", "pink")) + print(token_hex) + print("\n") + input("Press [Enter] to continue...") + break + else: + try: + token_txid = rpclib.sendrawtransaction(rpc_connection, + token_hex['hex']) + except KeyError: + print(token_txid) + print("Error") + input("Press [Enter] to continue...") + break + finally: + print(colorize("Token creation transaction broadcasted: " + token_txid, "green")) + file = open("tokens_list", "a") + file.writelines(token_txid + "\n") + file.close() + print(colorize("Entry added to tokens_list file!\n", "green")) + input("Press [Enter] to continue...") + break + + +def oracle_create_tui(rpc_connection): + + print(colorize("\nAvailiable data types:\n", "blue")) + oracles_data_types = ["Ihh -> height, blockhash, merkleroot\ns -> <256 char string\nS -> <65536 char string\nd -> <256 binary data\nD -> <65536 binary data", + "c -> 1 byte signed little endian number, C unsigned\nt -> 2 byte signed little endian number, T unsigned", + "i -> 4 byte signed little endian number, I unsigned\nl -> 8 byte signed little endian number, L unsigned", + "h -> 32 byte hash\n"] + for oracles_type in oracles_data_types: + print(str(oracles_type)) + while True: + try: + name = input("Set your oracle name: ") + description = input("Set your oracle description: ") + oracle_data_type = input("Set your oracle type (e.g. Ihh): ") + except KeyboardInterrupt: + break + else: + oracle_hex = rpclib.oracles_create(rpc_connection, name, description, oracle_data_type) + if oracle_hex['result'] == "error": + print(colorize("\nSomething went wrong!\n", "pink")) + print(oracle_hex) + print("\n") + input("Press [Enter] to continue...") + break + else: + try: + oracle_txid = rpclib.sendrawtransaction(rpc_connection, oracle_hex['hex']) + except KeyError: + print(oracle_txid) + print("Error") + input("Press [Enter] to continue...") + break + finally: + print(colorize("Oracle creation transaction broadcasted: " + oracle_txid, "green")) + file = open("oracles_list", "a") + file.writelines(oracle_txid + "\n") + file.close() + print(colorize("Entry added to oracles_list file!\n", "green")) + input("Press [Enter] to continue...") + break + + +def oracle_register_tui(rpc_connection): + #TODO: have an idea since blackjoker new RPC call + #grab all list and printout only or which owner match with node pubkey + try: + print(colorize("Oracles created from this instance by TUI: \n", "blue")) + with open("oracles_list", "r") as file: + for oracle in file: + print(oracle) + print(colorize('_' * 65, "blue")) + print("\n") + except FileNotFoundError: + print("Seems like a no oracles created from this instance yet\n") + pass + while True: + try: + oracle_id = input("Input txid of oracle you want to register to: ") + data_fee = input("Set publisher datafee (in satoshis): ") + except KeyboardInterrupt: + break + oracle_register_hex = rpclib.oracles_register(rpc_connection, oracle_id, data_fee) + if oracle_register_hex['result'] == "error": + print(colorize("\nSomething went wrong!\n", "pink")) + print(oracle_register_hex) + print("\n") + input("Press [Enter] to continue...") + break + else: + try: + oracle_register_txid = rpclib.sendrawtransaction(rpc_connection, oracle_register_hex['hex']) + except KeyError: + print(oracle_register_hex) + print("Error") + input("Press [Enter] to continue...") + break + else: + print(colorize("Oracle registration transaction broadcasted: " + oracle_register_txid, "green")) + input("Press [Enter] to continue...") + break + + +def oracle_subscription_utxogen(rpc_connection): + # TODO: have an idea since blackjoker new RPC call + # grab all list and printout only or which owner match with node pubkey + try: + print(colorize("Oracles created from this instance by TUI: \n", "blue")) + with open("oracles_list", "r") as file: + for oracle in file: + print(oracle) + print(colorize('_' * 65, "blue")) + print("\n") + except FileNotFoundError: + print("Seems like a no oracles created from this instance yet\n") + pass + while True: + try: + oracle_id = input("Input oracle ID you want to subscribe to: ") + #printout to fast copypaste publisher id + oracle_info = rpclib.oracles_info(rpc_connection, oracle_id) + publishers = 0 + print(colorize("\nPublishers registered for a selected oracle: \n", "blue")) + try: + for entry in oracle_info["registered"]: + publisher = entry["publisher"] + print(publisher + "\n") + publishers = publishers + 1 + print("Total publishers:{}".format(publishers)) + except (KeyError, ConnectionResetError): + print(colorize("Please re-check your input. Oracle txid seems not valid.", "red")) + pass + print(colorize('_' * 65, "blue")) + print("\n") + if publishers == 0: + print(colorize("This oracle have no publishers to subscribe.\n" + "Please register as an oracle publisher first and/or wait since registration transaciton mined!", "red")) + input("Press [Enter] to continue...") + break + publisher_id = input("Input oracle publisher id you want to subscribe to: ") + data_fee = input("Input subscription fee (in COINS!): ") + utxo_num = int(input("Input how many transactions you want to broadcast: ")) + except KeyboardInterrupt: + break + while utxo_num > 0: + while True: + oracle_subscription_hex = rpclib.oracles_subscribe(rpc_connection, oracle_id, publisher_id, data_fee) + oracle_subscription_txid = rpclib.sendrawtransaction(rpc_connection, oracle_subscription_hex['hex']) + mempool = rpclib.get_rawmempool(rpc_connection) + if oracle_subscription_txid in mempool: + break + else: + pass + print(colorize("Oracle subscription transaction broadcasted: " + oracle_subscription_txid, "green")) + utxo_num = utxo_num - 1 + input("Press [Enter] to continue...") + break + +def gateways_bind_tui(rpc_connection): + # main loop with keyboard interrupt handling + while True: + try: + while True: + try: + print(colorize("Tokens created from this instance by TUI: \n", "blue")) + with open("tokens_list", "r") as file: + for oracle in file: + print(oracle) + print(colorize('_' * 65, "blue")) + print("\n") + except FileNotFoundError: + print("Seems like a no oracles created from this instance yet\n") + pass + token_id = input("Input id of token you want to use in gw bind: ") + try: + token_name = rpclib.token_info(rpc_connection, token_id)["name"] + except KeyError: + print(colorize("Not valid tokenid. Please try again.", "red")) + input("Press [Enter] to continue...") + token_info = rpclib.token_info(rpc_connection, token_id) + print(colorize("\n{} token total supply: {}\n".format(token_id, token_info["supply"]), "blue")) + token_supply = input("Input supply for token binding: ") + try: + print(colorize("\nOracles created from this instance by TUI: \n", "blue")) + with open("oracles_list", "r") as file: + for oracle in file: + print(oracle) + print(colorize('_' * 65, "blue")) + print("\n") + except FileNotFoundError: + print("Seems like a no oracles created from this instance yet\n") + pass + oracle_id = input("Input id of oracle you want to use in gw bind: ") + try: + oracle_name = rpclib.oracles_info(rpc_connection, oracle_id)["name"] + except KeyError: + print(colorize("Not valid oracleid. Please try again.", "red")) + input("Press [Enter] to continue...") + while True: + coin_name = input("Input external coin ticker (binded oracle and token need to have same name!): ") + if token_name == oracle_name and token_name == coin_name: + break + else: + print(colorize("Token name, oracle name and external coin ticker should match!", "red")) + while True: + M = input("Input minimal amount of pubkeys needed for transaction confirmation (1 for non-multisig gw): ") + N = input("Input maximal amount of pubkeys needed for transaction confirmation (1 for non-multisig gw): ") + if (int(N) >= int(M)): + break + else: + print("Maximal amount of pubkeys should be more or equal than minimal. Please try again.") + pubkeys = [] + for i in range(int(N)): + pubkeys.append(input("Input pubkey {}: ".format(i+1))) + pubtype = input("Input pubtype of external coin: ") + p2shtype = input("Input p2shtype of external coin: ") + wiftype = input("Input wiftype of external coin: ") + args = [rpc_connection, token_id, oracle_id, coin_name, token_supply, M, N] + new_args = [str(pubtype), str(p2shtype), wiftype] + args = args + pubkeys + new_args + # broadcasting block + try: + gateways_bind_hex = rpclib.gateways_bind(*args) + except Exception as e: + print(e) + input("Press [Enter] to continue...") + break + try: + gateways_bind_txid = rpclib.sendrawtransaction(rpc_connection, gateways_bind_hex["hex"]) + except Exception as e: + print(e) + print(gateways_bind_hex) + input("Press [Enter] to continue...") + break + else: + print(colorize("Gateway bind transaction broadcasted: " + gateways_bind_txid, "green")) + file = open("gateways_list", "a") + file.writelines(gateways_bind_txid + "\n") + file.close() + print(colorize("Entry added to gateways_list file!\n", "green")) + input("Press [Enter] to continue...") + break + break + except KeyboardInterrupt: + break + +# temporary :trollface: custom connection function solution +# to have connection to KMD daemon and cache it in separate file + + +def rpc_kmd_connection_tui(): + while True: + restore_choice = input("Do you want to use KMD daemon connection details from previous session? [y/n]: ") + if restore_choice == "y": + try: + with open("connection_kmd.json", "r") as file: + connection_json = json.load(file) + rpc_user = connection_json["rpc_user"] + rpc_password = connection_json["rpc_password"] + rpc_port = connection_json["rpc_port"] + rpc_connection_kmd = rpclib.rpc_connect(rpc_user, rpc_password, int(rpc_port)) + try: + print(rpc_connection_kmd.getinfo()) + print(colorize("Successfully connected!\n", "green")) + input("Press [Enter] to continue...") + break + except Exception as e: + print(e) + print(colorize("NOT CONNECTED!\n", "red")) + input("Press [Enter] to continue...") + break + except FileNotFoundError: + print(colorize("You do not have cached KMD daemon connection details." + " Please select n for connection setup", "red")) + input("Press [Enter] to continue...") + elif restore_choice == "n": + rpc_user = input("Input your rpc user: ") + rpc_password = input("Input your rpc password: ") + rpc_port = input("Input your rpc port: ") + connection_details = {"rpc_user": rpc_user, + "rpc_password": rpc_password, + "rpc_port": rpc_port} + connection_json = json.dumps(connection_details) + with open("connection_kmd.json", "w+") as file: + file.write(connection_json) + rpc_connection_kmd = rpclib.rpc_connect(rpc_user, rpc_password, int(rpc_port)) + try: + print(rpc_connection_kmd.getinfo()) + print(colorize("Successfully connected!\n", "green")) + input("Press [Enter] to continue...") + break + except Exception as e: + print(e) + print(colorize("NOT CONNECTED!\n", "red")) + input("Press [Enter] to continue...") + break + else: + print(colorize("Please input y or n", "red")) + return rpc_connection_kmd + + +def z_sendmany_twoaddresses(rpc_connection, sendaddress, recepient1, amount1, recepient2, amount2): + str_sending_block = "[{{\"address\":\"{}\",\"amount\":{}}},{{\"address\":\"{}\",\"amount\":{}}}]".format(recepient1, amount1, recepient2, amount2) + sending_block = json.loads(str_sending_block) + operation_id = rpc_connection.z_sendmany(sendaddress,sending_block) + return operation_id + + +def operationstatus_to_txid(rpc_connection, zstatus): + str_sending_block = "[\"{}\"]".format(zstatus) + sending_block = json.loads(str_sending_block) + operation_json = rpc_connection.z_getoperationstatus(sending_block) + operation_dump = json.dumps(operation_json) + operation_dict = json.loads(operation_dump)[0] + txid = operation_dict['result']['txid'] + return txid + + +def gateways_send_kmd(rpc_connection): + # TODO: have to handle CTRL+C on text input + print(colorize("Please be carefull when input wallet addresses and amounts since all transactions doing in real KMD!", "pink")) + print("Your addresses with balances: ") + list_address_groupings = rpc_connection.listaddressgroupings() + for address in list_address_groupings: + print(str(address) + "\n") + sendaddress = input("Input address from which you transfer KMD: ") + recepient1 = input("Input address which belongs to pubkey which will receive tokens: ") + amount1 = 0.0001 + recepient2 = input("Input gateway deposit address: ") + file = open("deposits_list", "a") + #have to show here deposit addresses for gateways created by user + amount2 = input("Input how many KMD you want to deposit on this gateway: ") + operation = z_sendmany_twoaddresses(rpc_connection, sendaddress, recepient1, amount1, recepient2, amount2) + print("Operation proceed! " + str(operation) + " Let's wait 2 seconds to get txid") + # trying to avoid pending status of operation + time.sleep(2) + txid = operationstatus_to_txid(rpc_connection, operation) + file.writelines(txid + "\n") + file.close() + print(colorize("KMD Transaction ID: " + str(txid) + " Entry added to deposits_list file", "green")) + input("Press [Enter] to continue...") + + +def gateways_deposit_tui(rpc_connection_assetchain, rpc_connection_komodo): + while True: + bind_txid = input("Input your gateway bind txid: ") + coin_name = input("Input your external coin ticker (e.g. KMD): ") + coin_txid = input("Input your deposit txid: ") + dest_pub = input("Input pubkey which claim deposit: ") + amount = input("Input amount of your deposit: ") + height = rpc_connection_komodo.getrawtransaction(coin_txid, 1)["height"] + deposit_hex = rpc_connection_komodo.getrawtransaction(coin_txid, 1)["hex"] + claim_vout = "0" + proof_sending_block = "[\"{}\"]".format(coin_txid) + proof = rpc_connection_komodo.gettxoutproof(json.loads(proof_sending_block)) + deposit_hex = rpclib.gateways_deposit(rpc_connection_assetchain, bind_txid, str(height), coin_name, \ + coin_txid, claim_vout, deposit_hex, proof, dest_pub, amount) + print(deposit_hex) + deposit_txid = rpclib.sendrawtransaction(rpc_connection_assetchain, deposit_hex["hex"]) + print("Done! Gateways deposit txid is: " + deposit_txid + " Please not forget to claim your deposit!") + input("Press [Enter] to continue...") + break + + +def gateways_claim_tui(rpc_connection): + while True: + bind_txid = input("Input your gateway bind txid: ") + coin_name = input("Input your external coin ticker (e.g. KMD): ") + deposit_txid = input("Input your gatewaysdeposit txid: ") + dest_pub = input("Input pubkey which claim deposit: ") + amount = input("Input amount of your deposit: ") + claim_hex = rpclib.gateways_claim(rpc_connection, bind_txid, coin_name, deposit_txid, dest_pub, amount) + try: + claim_txid = rpclib.sendrawtransaction(rpc_connection, claim_hex["hex"]) + except Exception as e: + print(e) + print(claim_hex) + input("Press [Enter] to continue...") + break + else: + print("Succesfully claimed! Claim transaction id: " + claim_txid) + input("Press [Enter] to continue...") + break + + +def gateways_withdrawal_tui(rpc_connection): + while True: + bind_txid = input("Input your gateway bind txid: ") + coin_name = input("Input your external coin ticker (e.g. KMD): ") + withdraw_pub = input("Input pubkey to which you want to withdraw: ") + amount = input("Input amount of withdrawal: ") + withdraw_hex = rpclib.gateways_withdraw(rpc_connection, bind_txid, coin_name, withdraw_pub, amount) + withdraw_txid = rpclib.sendrawtransaction(rpc_connection, withdraw_hex["hex"]) + print(withdraw_txid) + input("Press [Enter] to continue...") + break + + +def print_mempool(rpc_connection): + while True: + mempool = rpclib.get_rawmempool(rpc_connection) + tx_counter = 0 + print(colorize("Transactions in mempool: \n", "magenta")) + for transaction in mempool: + print(transaction + "\n") + tx_counter = tx_counter + 1 + print("Total: " + str(tx_counter) + " transactions\n") + print("R + Enter to refresh list. E + Enter to exit menu." + "\n") + is_refresh = input("Choose your destiny: ") + if is_refresh == "R": + print("\n") + pass + elif is_refresh == "E": + print("\n") + break + else: + print("\nPlease choose R or E\n") + + +def print_tokens_list(rpc_connection): + # TODO: have to print it with tokeninfo to have sense + pass + + +def print_tokens_balances(rpc_connection): + # TODO: checking tokenbalance for each token from tokenlist and reflect non zero ones + pass + + +def hexdump(filename, chunk_size=1<<15): + data = "" + #add_spaces = partial(re.compile(b'(..)').sub, br'\1 ') + #write = getattr(sys.stdout, 'buffer', sys.stdout).write + with open(filename, 'rb') as file: + for chunk in iter(partial(file.read, chunk_size), b''): + data += str(hexlify(chunk).decode()) + return data + + +def convert_file_oracle_d(rpc_connection): + while True: + path = input("Input path to file you want to upload to oracle: ") + try: + hex_data = (hexdump(path, 1))[2:] + except Exception as e: + print(e) + print("Seems something goes wrong (I guess you've specified wrong path)!") + input("Press [Enter] to continue...") + break + else: + length = round(len(hex_data) / 2) + if length > 256: + print("Length: " + str(length) + " bytes") + print("File is too big for this app") + input("Press [Enter] to continue...") + break + else: + hex_length = format(length, '#04x')[2:] + data_for_oracle = str(hex_length) + hex_data + print("File hex representation: \n") + print(data_for_oracle + "\n") + print("Length: " + str(length) + " bytes") + print("File converted!") + new_oracle_hex = rpclib.oracles_create(rpc_connection, "tonyconvert", path, "d") + new_oracle_txid = rpclib.sendrawtransaction(rpc_connection, new_oracle_hex["hex"]) + time.sleep(0.5) + oracle_register_hex = rpclib.oracles_register(rpc_connection, new_oracle_txid, "10000") + oracle_register_txid = rpclib.sendrawtransaction(rpc_connection, oracle_register_hex["hex"]) + time.sleep(0.5) + oracle_subscribe_hex = rpclib.oracles_subscribe(rpc_connection, new_oracle_txid, rpclib.getinfo(rpc_connection)["pubkey"], "0.001") + oracle_subscribe_txid = rpclib.sendrawtransaction(rpc_connection, oracle_subscribe_hex["hex"]) + time.sleep(0.5) + while True: + mempool = rpclib.get_rawmempool(rpc_connection) + if oracle_subscribe_txid in mempool: + print("Waiting for oracle subscribtion tx to be mined" + "\n") + time.sleep(6) + pass + else: + break + oracles_data_hex = rpclib.oracles_data(rpc_connection, new_oracle_txid, data_for_oracle) + try: + oracle_data_txid = rpclib.sendrawtransaction(rpc_connection, oracles_data_hex["hex"]) + except Exception as e: + print(oracles_data_hex) + print(e) + print("Oracle created: " + str(new_oracle_txid)) + print("Data published: " + str(oracle_data_txid)) + input("Press [Enter] to continue...") + break + + +def convert_file_oracle_D(rpc_connection): + while True: + path = input("Input path to file you want to upload to oracle: ") + try: + hex_data = (hexdump(path, 1)) + except Exception as e: + print(e) + print("Seems something goes wrong (I guess you've specified wrong path)!") + input("Press [Enter] to continue...") + break + else: + length = round(len(hex_data) / 2) + # if length > 800000: + # print("Too big file size to upload for this version of program. Maximum size is 800KB.") + # input("Press [Enter] to continue...") + # break + if length > 8000: + # if file is more than 8000 bytes - slicing it to <= 8000 bytes chunks (16000 symbols = 8000 bytes) + data = [hex_data[i:i + 16000] for i in range(0, len(hex_data), 16000)] + chunks_amount = len(data) + # TODO: have to create oracle but subscribe this time chunks amount times to send whole file in same block + # TODO: 2 - on some point file will not fit block - have to find this point + # TODO: 3 way how I want to implement it first will keep whole file in RAM - have to implement some way to stream chunks to oracle before whole file readed + # TODO: have to "optimise" registration fee + # Maybe just check size first by something like a du ? + print("Length: " + str(length) + " bytes.\n Chunks amount: " + str(chunks_amount)) + new_oracle_hex = rpclib.oracles_create(rpc_connection, "tonyconvert_" + str(chunks_amount), path, "D") + new_oracle_txid = rpclib.sendrawtransaction(rpc_connection, new_oracle_hex["hex"]) + time.sleep(0.5) + oracle_register_hex = rpclib.oracles_register(rpc_connection, new_oracle_txid, "10000") + oracle_register_txid = rpclib.sendrawtransaction(rpc_connection, oracle_register_hex["hex"]) + # subscribe chunks_amount + 1 times, but lets limit our broadcasting 100 tx per block (800KB/block) + if chunks_amount > 100: + utxo_num = 101 + else: + utxo_num = chunks_amount + while utxo_num > 0: + while True: + oracle_subscription_hex = rpclib.oracles_subscribe(rpc_connection, new_oracle_txid, rpclib.getinfo(rpc_connection)["pubkey"], "0.001") + oracle_subscription_txid = rpclib.sendrawtransaction(rpc_connection, + oracle_subscription_hex['hex']) + mempool = rpclib.get_rawmempool(rpc_connection) + if oracle_subscription_txid in mempool: + break + else: + pass + print(colorize("Oracle subscription transaction broadcasted: " + oracle_subscription_txid, "green")) + utxo_num = utxo_num - 1 + # waiting for last broadcasted subscribtion transaction to be mined to be sure that money are on oracle balance + while True: + mempool = rpclib.get_rawmempool(rpc_connection) + if oracle_subscription_txid in mempool: + print("Waiting for oracle subscribtion tx to be mined" + "\n") + time.sleep(6) + pass + else: + break + print("Oracle preparation is finished. Oracle txid: " + new_oracle_txid) + # can publish data now + counter = 0 + for chunk in data: + hex_length_bigendian = format(round(len(chunk) / 2), '#06x')[2:] + # swap to get little endian length + a = hex_length_bigendian[2:] + b = hex_length_bigendian[:2] + hex_length = a + b + data_for_oracle = str(hex_length) + chunk + counter = counter + 1 + # print("Chunk number: " + str(counter) + "\n") + # print(data_for_oracle) + try: + oracles_data_hex = rpclib.oracles_data(rpc_connection, new_oracle_txid, data_for_oracle) + except Exception as e: + print(data_for_oracle) + print(e) + input("Press [Enter] to continue...") + break + # on broadcasting ensuring that previous one reached mempool before blast next one + while True: + mempool = rpclib.get_rawmempool(rpc_connection) + oracle_data_txid = rpclib.sendrawtransaction(rpc_connection, oracles_data_hex["hex"]) + #time.sleep(0.1) + if oracle_data_txid in mempool: + break + else: + pass + # blasting not more than 100 at once (so maximum capacity per block can be changed here) + # but keep in mind that registration UTXOs amount needs to be changed too ! + if counter % 100 == 0 and chunks_amount > 100: + while True: + mempool = rpclib.get_rawmempool(rpc_connection) + if oracle_data_txid in mempool: + print("Waiting for previous data chunks to be mined before send new ones" + "\n") + print("Sent " + str(counter) + " chunks from " + str(chunks_amount)) + time.sleep(6) + pass + else: + break + + print("Last baton: " + oracle_data_txid) + input("Press [Enter] to continue...") + break + # if file suits single oraclesdata just broadcasting it straight without any slicing + else: + hex_length_bigendian = format(length, '#06x')[2:] + # swap to get little endian length + a = hex_length_bigendian[2:] + b = hex_length_bigendian[:2] + hex_length = a + b + data_for_oracle = str(hex_length) + hex_data + print("File hex representation: \n") + print(data_for_oracle + "\n") + print("Length: " + str(length) + " bytes") + print("File converted!") + new_oracle_hex = rpclib.oracles_create(rpc_connection, "tonyconvert_" + "1", path, "D") + new_oracle_txid = rpclib.sendrawtransaction(rpc_connection, new_oracle_hex["hex"]) + time.sleep(0.5) + oracle_register_hex = rpclib.oracles_register(rpc_connection, new_oracle_txid, "10000") + oracle_register_txid = rpclib.sendrawtransaction(rpc_connection, oracle_register_hex["hex"]) + time.sleep(0.5) + oracle_subscribe_hex = rpclib.oracles_subscribe(rpc_connection, new_oracle_txid, rpclib.getinfo(rpc_connection)["pubkey"], "0.001") + oracle_subscribe_txid = rpclib.sendrawtransaction(rpc_connection, oracle_subscribe_hex["hex"]) + time.sleep(0.5) + while True: + mempool = rpclib.get_rawmempool(rpc_connection) + if oracle_subscribe_txid in mempool: + print("Waiting for oracle subscribtion tx to be mined" + "\n") + time.sleep(6) + pass + else: + break + oracles_data_hex = rpclib.oracles_data(rpc_connection, new_oracle_txid, data_for_oracle) + try: + oracle_data_txid = rpclib.sendrawtransaction(rpc_connection, oracles_data_hex["hex"]) + except Exception as e: + print(oracles_data_hex) + print(e) + input("Press [Enter] to continue...") + break + else: + print("Oracle created: " + str(new_oracle_txid)) + print("Data published: " + str(oracle_data_txid)) + input("Press [Enter] to continue...") + break + + +def get_files_list(rpc_connection): + + start_time = time.time() + oracles_list = rpclib.oracles_list(rpc_connection) + files_list = [] + for oracle_txid in oracles_list: + oraclesinfo_result = rpclib.oracles_info(rpc_connection, oracle_txid) + description = oraclesinfo_result['description'] + name = oraclesinfo_result['name'] + if name[0:12] == 'tonyconvert_': + new_file = '[' + name + ': ' + description + ']: ' + oracle_txid + files_list.append(new_file) + print("--- %s seconds ---" % (time.time() - start_time)) + return files_list + + +def display_files_list(rpc_connection): + print("Scanning oracles. Please wait...") + list_to_display = get_files_list(rpc_connection) + while True: + for file in list_to_display: + print(file + "\n") + input("Press [Enter] to continue...") + break + + +def files_downloader(rpc_connection): + while True: + display_files_list(rpc_connection) + print("\n") + oracle_id = input("Input oracle ID you want to download file from: ") + output_path = input("Input output path for downloaded file (name included) e.g. /home/test.txt: ") + oracle_info = rpclib.oracles_info(rpc_connection, oracle_id) + name = oracle_info['name'] + latest_baton_txid = oracle_info['registered'][0]['batontxid'] + if name[0:12] == 'tonyconvert_': + # downloading process here + chunks_amount = int(name[12:]) + data = rpclib.oracles_samples(rpc_connection, oracle_id, latest_baton_txid, str(chunks_amount))["samples"] + for chunk in reversed(data): + with open(output_path, 'ab+') as file: + file.write(unhexlify(chunk[0])) + print("I hope that file saved to " + output_path + "\n") + input("Press [Enter] to continue...") + break + + else: + print("I cant recognize file inside this oracle. I'm very sorry, boss.") + input("Press [Enter] to continue...") + break + + +def marmara_receive_tui(rpc_connection): + while True: + issuer_pubkey = input("Input pubkey of person who do you want to receive MARMARA from: ") + issuance_sum = input("Input amount of MARMARA you want to receive: ") + blocks_valid = input("Input amount of blocks for cheque matures: ") + try: + marmara_receive_txinfo = rpc_connection.marmarareceive(issuer_pubkey, issuance_sum, "MARMARA", blocks_valid) + marmara_receive_txid = rpc_connection.sendrawtransaction(marmara_receive_txinfo["hex"]) + print("Marmara receive txid broadcasted: " + marmara_receive_txid + "\n") + print(json.dumps(marmara_receive_txinfo, indent=4, sort_keys=True) + "\n") + with open("receive_txids.txt", 'a+') as file: + file.write(marmara_receive_txid + "\n") + file.write(json.dumps(marmara_receive_txinfo, indent=4, sort_keys=True) + "\n") + print("Transaction id is saved to receive_txids.txt file.") + input("Press [Enter] to continue...") + break + except Exception as e: + print(marmara_receive_txinfo) + print(e) + print("Something went wrong. Please check your input") + + +def marmara_issue_tui(rpc_connection): + while True: + receiver_pubkey = input("Input pubkey of person who do you want to issue MARMARA: ") + issuance_sum = input("Input amount of MARMARA you want to issue: ") + maturing_block = input("Input number of block on which issuance mature: ") + approval_txid = input("Input receiving request transaction id: ") + try: + marmara_issue_txinfo = rpc_connection.marmaraissue(receiver_pubkey, issuance_sum, "MARMARA", maturing_block, approval_txid) + marmara_issue_txid = rpc_connection.sendrawtransaction(marmara_issue_txinfo["hex"]) + print("Marmara issuance txid broadcasted: " + marmara_issue_txid + "\n") + print(json.dumps(marmara_issue_txinfo, indent=4, sort_keys=True) + "\n") + with open("issue_txids.txt", "a+") as file: + file.write(marmara_issue_txid + "\n") + file.write(json.dumps(marmara_issue_txinfo, indent=4, sort_keys=True) + "\n") + print("Transaction id is saved to issue_txids.txt file.") + input("Press [Enter] to continue...") + break + except Exception as e: + print(marmara_issue_txinfo) + print(e) + print("Something went wrong. Please check your input") + + +def marmara_creditloop_tui(rpc_connection): + while True: + loop_txid = input("Input transaction ID of credit loop you want to get info about: ") + try: + marmara_creditloop_info = rpc_connection.marmaracreditloop(loop_txid) + print(json.dumps(marmara_creditloop_info, indent=4, sort_keys=True) + "\n") + input("Press [Enter] to continue...") + break + except Exception as e: + print(marmara_creditloop_info) + print(e) + print("Something went wrong. Please check your input") + + +def marmara_settlement_tui(rpc_connection): + while True: + loop_txid = input("Input transaction ID of credit loop to make settlement: ") + try: + marmara_settlement_info = rpc_connection.marmarasettlement(loop_txid) + marmara_settlement_txid = rpc_connection.sendrawtransaction(marmara_settlement_info["hex"]) + print("Loop " + loop_txid + " succesfully settled!\nSettlement txid: " + marmara_settlement_txid) + with open("settlement_txids.txt", "a+") as file: + file.write(marmara_settlement_txid + "\n") + file.write(json.dumps(marmara_settlement_info, indent=4, sort_keys=True) + "\n") + print("Transaction id is saved to settlement_txids.txt file.") + input("Press [Enter] to continue...") + break + except Exception as e: + print(marmara_settlement_info) + print(e) + print("Something went wrong. Please check your input") + input("Press [Enter] to continue...") + break + + +def marmara_lock_tui(rpc_connection): + while True: + amount = input("Input amount of coins you want to lock for settlement and staking: ") + unlock_height = input("Input height on which coins should be unlocked: ") + try: + marmara_lock_info = rpc_connection.marmaralock(amount, unlock_height) + marmara_lock_txid = rpc_connection.sendrawtransaction(marmara_lock_info["hex"]) + with open("lock_txids.txt", "a+") as file: + file.write(marmara_lock_txid + "\n") + file.write(json.dumps(marmara_lock_info, indent=4, sort_keys=True) + "\n") + print("Transaction id is saved to lock_txids.txt file.") + input("Press [Enter] to continue...") + break + except Exception as e: + print(e) + print("Something went wrong. Please check your input") + input("Press [Enter] to continue...") + break + + +def marmara_info_tui(rpc_connection): + while True: + firstheight = input("Input first height (default 0): ") + if not firstheight: + firstheight = "0" + lastheight = input("Input last height (default current (0) ): ") + if not lastheight: + lastheight = "0" + minamount = input("Input min amount (default 0): ") + if not minamount: + minamount = "0" + maxamount = input("Input max amount (default 0): ") + if not maxamount: + maxamount = "0" + issuerpk = input("Optional. Input issuer public key: ") + try: + if issuerpk: + marmara_info = rpc_connection.marmarainfo(firstheight, lastheight, minamount, maxamount, "MARMARA", issuerpk) + else: + marmara_info = rpc_connection.marmarainfo(firstheight, lastheight, minamount, maxamount) + print(json.dumps(marmara_info, indent=4, sort_keys=True) + "\n") + input("Press [Enter] to continue...") + break + except Exception as e: + print(marmara_info) + print(e) + print("Something went wrong. Please check your input") + input("Press [Enter] to continue...") + break + + +def rogue_game_info(rpc_connection, game_txid): + game_info_arg = '"' + "[%22" + game_txid + "%22]" + '"' + game_info = rpc_connection.cclib("gameinfo", "17", game_info_arg) + return game_info + + +def rogue_game_register(rpc_connection, game_txid, player_txid = False): + if player_txid: + registration_info_arg = '"' + "[%22" + game_txid + "%22,%22" + player_txid + "%22]" + '"' + else: + registration_info_arg = '"' + "[%22" + game_txid + "%22]" + '"' + registration_info = rpc_connection.cclib("register", "17", registration_info_arg) + return registration_info + + +def rogue_pending(rpc_connection): + rogue_pending_list = rpc_connection.cclib("pending", "17") + return rogue_pending_list + + +def rogue_bailout(rpc_connection, game_txid): + bailout_info_arg = '"' + "[%22" + game_txid + "%22]" + '"' + bailout_info = rpc_connection.cclib("bailout", "17", bailout_info_arg) + return bailout_info + + +def rogue_highlander(rpc_connection, game_txid): + highlander_info_arg = '"' + "[%22" + game_txid + "%22]" + '"' + highlander_info = rpc_connection.cclib("highlander", "17", highlander_info_arg) + return highlander_info + + +def rogue_players_list(rpc_connection): + rogue_players_list = rpc_connection.cclib("players", "17") + return rogue_players_list + + +def rogue_player_info(rpc_connection, playertxid): + player_info_arg = '"' + "[%22" + playertxid + "%22]" + '"' + player_info = rpc_connection.cclib("playerinfo", "17", player_info_arg) + return player_info + + +def rogue_extract(rpc_connection, game_txid, pubkey): + extract_info_arg = '"' + "[%22" + game_txid + "%22,%22" + pubkey + "%22]" + '"' + extract_info = rpc_connection.cclib("extract", "17", extract_info_arg) + return extract_info + + +def rogue_keystrokes(rpc_connection, game_txid, keystroke): + rogue_keystrokes_arg = '"' + "[%22" + game_txid + "%22,%22" + keystroke + "%22]" + '"' + keystroke_info = rpc_connection.cclib("keystrokes", "17", rogue_keystrokes_arg) + return keystroke_info + + +def print_multiplayer_games_list(rpc_connection): + while True: + pending_list = rogue_pending(rpc_connection) + multiplayer_pending_list = [] + for game in pending_list["pending"]: + if rogue_game_info(rpc_connection, game)["maxplayers"] > 1: + multiplayer_pending_list.append(game) + print("Multiplayer games availiable to join: \n") + for active_multiplayer_game in multiplayer_pending_list: + game_info = rogue_game_info(rpc_connection, active_multiplayer_game) + print(colorize("\n================================\n", "green")) + print("Game txid: " + game_info["gametxid"]) + print("Game buyin: " + str(game_info["buyin"])) + print("Game height: " + str(game_info["gameheight"])) + print("Start height: " + str(game_info["start"])) + print("Alive players: " + str(game_info["alive"])) + print("Registered players: " + str(game_info["numplayers"])) + print("Max players: " + str(game_info["maxplayers"])) + print(colorize("\n***\n", "blue")) + print("Players in game:") + for player in game_info["players"]: + print("Slot: " + str(player["slot"])) + if "baton" in player.keys(): + print("Baton: " + str(player["baton"])) + if "tokenid" in player.keys(): + print("Tokenid: " + str(player["tokenid"])) + print("Is mine?: " + str(player["ismine"])) + print(colorize("\nR + Enter - refresh list.\nE + Enter - to the game choice.\nCTRL + C - back to main menu", "blue")) + is_refresh = input("Choose your destiny: ") + if is_refresh == "R": + print("\n") + pass + elif is_refresh == "E": + print("\n") + break + else: + print("\nPlease choose R or E\n") + + +def rogue_newgame_singleplayer(rpc_connection, is_game_a_rogue=True): + try: + new_game_txid = rpc_connection.cclib("newgame", "17", "[1]")["txid"] + print("New singleplayer training game succesfully created. txid: " + new_game_txid) + while True: + mempool = rpc_connection.getrawmempool() + if new_game_txid in mempool: + print(colorize("Waiting for game transaction to be mined", "blue")) + time.sleep(5) + else: + print(colorize("Game transaction is mined", "green")) + break + players_list = rogue_players_list(rpc_connection) + if len(players_list["playerdata"]) > 0: + print_players_list(rpc_connection) + while True: + is_choice_needed = input("Do you want to choose a player for this game? [y/n] ") + if is_choice_needed == "y": + player_txid = input("Please input player txid: ") + newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid, player_txid)["txid"] + break + elif is_choice_needed == "n": + set_warriors_name(rpc_connection) + newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid)["txid"] + break + else: + print("Please choose y or n !") + else: + print("No players available to select") + input("Press [Enter] to continue...") + newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid)["txid"] + while True: + mempool = rpc_connection.getrawmempool() + if newgame_regisration_txid in mempool: + print(colorize("Waiting for registration transaction to be mined", "blue")) + time.sleep(5) + else: + print(colorize("Registration transaction is mined", "green")) + break + game_info = rogue_game_info(rpc_connection, new_game_txid) + start_time = time.time() + while True: + if is_game_a_rogue: + subprocess.call(["../cc/rogue/rogue", str(game_info["seed"]), str(game_info["gametxid"])]) + else: + subprocess.call(["../cc/games/tetris", str(game_info["seed"]), str(game_info["gametxid"])]) + time_elapsed = time.time() - start_time + if time_elapsed > 1: + break + else: + print("Game less than 1 second. Trying to start again") + time.sleep(1) + game_end_height = int(rpc_connection.getinfo()["blocks"]) + while True: + current_height = int(rpc_connection.getinfo()["blocks"]) + height_difference = current_height - game_end_height + if height_difference == 0: + print(current_height) + print(game_end_height) + print(colorize("Waiting for next block before bailout", "blue")) + time.sleep(5) + else: + break + #print("\nKeystrokes of this game:\n") + #time.sleep(0.5) + while True: + keystrokes_rpc_responses = find_game_keystrokes_in_log(new_game_txid)[1::2] + if len(keystrokes_rpc_responses) < 1: + print("No keystrokes broadcasted yet. Let's wait 5 seconds") + time.sleep(5) + else: + break + #print(keystrokes_rpc_responses) + for keystroke in keystrokes_rpc_responses: + json_keystroke = json.loads(keystroke)["result"] + if "status" in json_keystroke.keys() and json_keystroke["status"] == "error": + while True: + print("Trying to re-brodcast keystroke") + keystroke_rebroadcast = rogue_keystrokes(rpc_connection, json_keystroke["gametxid"], json_keystroke["keystrokes"]) + if "txid" in keystroke_rebroadcast.keys(): + print("Keystroke broadcasted! txid: " + keystroke_rebroadcast["txid"]) + break + else: + print("Let's try again in 5 seconds") + time.sleep(5) + # waiting for last keystroke confirmation here + last_keystroke_json = json.loads(keystrokes_rpc_responses[-1]) + while True: + while True: + try: + rpc_connection.sendrawtransaction(last_keystroke_json["result"]["hex"]) + except Exception as e: + pass + try: + confirmations_amount = rpc_connection.getrawtransaction(last_keystroke_json["result"]["txid"], 1)["confirmations"] + break + except Exception as e: + print(e) + print("Let's wait a little bit more") + time.sleep(5) + pass + if confirmations_amount < 2: + print("Last keystroke not confirmed yet! Let's wait a little") + time.sleep(10) + else: + print("Last keystroke confirmed!") + break + while True: + print("\nExtraction info:\n") + extraction_info = rogue_extract(rpc_connection, new_game_txid, rpc_connection.getinfo()["pubkey"]) + if extraction_info["status"] == "error": + print(colorize("Your warrior died or no any information about game was saved on blockchain", "red")) + print("If warrior was alive - try to wait a little (choose n to wait for a next block). If he is dead - you can bailout now (choose y).") + else: + print("Current game state:") + print("Game txid: " + extraction_info["gametxid"]) + print("Information about game saved on chain: " + extraction_info["extracted"]) + print("\n") + is_bailout_needed = input("Do you want to make bailout now [y] or wait for one more block [n]? [y/n]: ") + if is_bailout_needed == "y": + bailout_info = rogue_bailout(rpc_connection, new_game_txid) + while True: + try: + confirmations_amount = rpc_connection.getrawtransaction(bailout_info["txid"], 1)["confirmations"] + break + except Exception as e: + print(e) + print("Bailout not on blockchain yet. Let's wait a little bit more") + time.sleep(20) + pass + break + elif is_bailout_needed == "n": + game_end_height = int(rpc_connection.getinfo()["blocks"]) + while True: + current_height = int(rpc_connection.getinfo()["blocks"]) + height_difference = current_height - game_end_height + if height_difference == 0: + print(current_height) + print(game_end_height) + print(colorize("Waiting for next block before bailout", "blue")) + time.sleep(5) + else: + break + else: + print("Please choose y or n !") + print(bailout_info) + print("\nGame is finished!\n") + bailout_txid = bailout_info["txid"] + input("Press [Enter] to continue...") + except Exception as e: + print("Something went wrong.") + print(e) + input("Press [Enter] to continue...") + + +def play_multiplayer_game(rpc_connection): + # printing list of user active multiplayer games + active_games_list = rpc_connection.cclib("games", "17")["games"] + active_multiplayer_games_list = [] + for game in active_games_list: + gameinfo = rogue_game_info(rpc_connection, game) + if gameinfo["maxplayers"] > 1: + active_multiplayer_games_list.append(gameinfo) + games_counter = 0 + for active_multiplayer_game in active_multiplayer_games_list: + games_counter = games_counter + 1 + is_ready_to_start = False + try: + active_multiplayer_game["seed"] + is_ready_to_start = True + except Exception as e: + pass + print(colorize("\n================================\n", "green")) + print("Game txid: " + active_multiplayer_game["gametxid"]) + print("Game buyin: " + str(active_multiplayer_game["buyin"])) + if is_ready_to_start: + print(colorize("Ready for start!", "green")) + else: + print(colorize("Not ready for start yet, wait until start height!", "red")) + print("Game height: " + str(active_multiplayer_game["gameheight"])) + print("Start height: " + str(active_multiplayer_game["start"])) + print("Alive players: " + str(active_multiplayer_game["alive"])) + print("Registered players: " + str(active_multiplayer_game["numplayers"])) + print("Max players: " + str(active_multiplayer_game["maxplayers"])) + print(colorize("\n***\n", "blue")) + print("Players in game:") + for player in active_multiplayer_game["players"]: + print("Slot: " + str(player["slot"])) + print("Baton: " + str(player["baton"])) + print("Tokenid: " + str(player["tokenid"])) + print("Is mine?: " + str(player["ismine"])) + # asking user if he want to start any of them + while True: + start_game = input("\nDo you want to start any of your pendning multiplayer games?[y/n]: ") + if start_game == "y": + new_game_txid = input("Input txid of game which you want to start: ") + game_info = rogue_game_info(rpc_connection, new_game_txid) + try: + start_time = time.time() + while True: + subprocess.call(["cc/rogue/rogue", str(game_info["seed"]), str(game_info["gametxid"])]) + time_elapsed = time.time() - start_time + if time_elapsed > 1: + break + else: + print("Game less than 1 second. Trying to start again") + time.sleep(1) + except Exception as e: + print("Maybe game isn't ready for start yet or your input was not correct, sorry.") + input("Press [Enter] to continue...") + break + game_end_height = int(rpc_connection.getinfo()["blocks"]) + while True: + current_height = int(rpc_connection.getinfo()["blocks"]) + height_difference = current_height - game_end_height + if height_difference == 0: + print(current_height) + print(game_end_height) + print(colorize("Waiting for next block before bailout or highlander", "blue")) + time.sleep(5) + else: + break + while True: + keystrokes_rpc_responses = find_game_keystrokes_in_log(new_game_txid)[1::2] + if len(keystrokes_rpc_responses) < 1: + print("No keystrokes broadcasted yet. Let's wait 5 seconds") + time.sleep(5) + else: + break + for keystroke in keystrokes_rpc_responses: + json_keystroke = json.loads(keystroke)["result"] + if "status" in json_keystroke.keys() and json_keystroke["status"] == "error": + while True: + print("Trying to re-brodcast keystroke") + keystroke_rebroadcast = rogue_keystrokes(rpc_connection, json_keystroke["gametxid"], + json_keystroke["keystrokes"]) + if "txid" in keystroke_rebroadcast.keys(): + print("Keystroke broadcasted! txid: " + keystroke_rebroadcast["txid"]) + break + else: + print("Let's try again in 5 seconds") + time.sleep(5) + last_keystroke_json = json.loads(keystrokes_rpc_responses[-1]) + while True: + while True: + try: + confirmations_amount = rpc_connection.getrawtransaction(last_keystroke_json["result"]["txid"], 1)["confirmations"] + break + except Exception as e: + print(e) + print("Let's wait a little bit more") + rpc_connection.sendrawtransaction(last_keystroke_json["result"]["hex"]) + time.sleep(5) + pass + if confirmations_amount < 2: + print("Last keystroke not confirmed yet! Let's wait a little") + time.sleep(10) + else: + print("Last keystroke confirmed!") + break + while True: + print("\nExtraction info:\n") + extraction_info = rogue_extract(rpc_connection, new_game_txid, rpc_connection.getinfo()["pubkey"]) + if extraction_info["status"] == "error": + print(colorize("Your warrior died or no any information about game was saved on blockchain", "red")) + print("If warrior was alive - try to wait a little (choose n to wait for a next block). If he is dead - you can bailout now (choose y).") + else: + print("Current game state:") + print("Game txid: " + extraction_info["gametxid"]) + print("Information about game saved on chain: " + extraction_info["extracted"]) + print("\n") + is_bailout_needed = input( + "Do you want to make bailout now [y] or wait for one more block [n]? [y/n]: ") + if is_bailout_needed == "y": + if game_info["alive"] > 1: + bailout_info = rogue_bailout(rpc_connection, new_game_txid) + try: + bailout_txid = bailout_info["txid"] + print(bailout_info) + print("\nGame is finished!\n") + input("Press [Enter] to continue...") + break + except Exception: + highlander_info = rogue_highlander(rpc_connection, new_game_txid) + highlander_info = highlander_info["txid"] + print(highlander_info) + print("\nGame is finished!\n") + input("Press [Enter] to continue...") + break + else: + highlander_info = rogue_highlander(rpc_connection, new_game_txid) + if 'error' in highlander_info.keys() and highlander_info["error"] == 'numplayers != maxplayers': + bailout_info = rogue_bailout(rpc_connection, new_game_txid) + print(bailout_info) + print("\nGame is finished!\n") + input("Press [Enter] to continue...") + break + else: + print(highlander_info) + print("\nGame is finished!\n") + input("Press [Enter] to continue...") + break + elif is_bailout_needed == "n": + game_end_height = int(rpc_connection.getinfo()["blocks"]) + while True: + current_height = int(rpc_connection.getinfo()["blocks"]) + height_difference = current_height - game_end_height + if height_difference == 0: + print(current_height) + print(game_end_height) + print(colorize("Waiting for next block before bailout", "blue")) + time.sleep(5) + else: + break + break + break + if start_game == "n": + print("As you wish!") + input("Press [Enter] to continue...") + break + else: + print(colorize("Choose y or n!", "red")) + + +def rogue_newgame_multiplayer(rpc_connection): + while True: + max_players = input("Input game max. players (>1): ") + if int(max_players) > 1: + break + else: + print("Please re-check your input") + input("Press [Enter] to continue...") + while True: + buyin = input("Input game buyin (>0.001): ") + if float(buyin) > 0.001: + break + else: + print("Please re-check your input") + input("Press [Enter] to continue...") + try: + new_game_txid = rpc_connection.cclib("newgame", "17", '"[' + max_players + "," + buyin + ']"')["txid"] + print(colorize("New multiplayer game succesfully created. txid: " + new_game_txid, "green")) + input("Press [Enter] to continue...") + except Exception as e: + print("Something went wrong.") + print(e) + input("Press [Enter] to continue...") + + +def rogue_join_multiplayer_game(rpc_connection): + while True: + try: + print_multiplayer_games_list(rpc_connection) + # TODO: optional player data txid (print players you have and ask if you want to choose one) + game_txid = input("Input txid of game you want to join: ") + try: + while True: + print_players_list(rpc_connection) + is_choice_needed = input("Do you want to choose a player for this game? [y/n] ") + if is_choice_needed == "y": + player_txid = input("Please input player txid: ") + newgame_regisration_txid = rogue_game_register(rpc_connection, game_txid, player_txid)["txid"] + break + elif is_choice_needed == "n": + set_warriors_name(rpc_connection) + newgame_regisration_txid = rogue_game_register(rpc_connection, game_txid)["txid"] + break + else: + print("Please choose y or n !") + except Exception as e: + print("Something went wrong. Maybe you're trying to register on game twice or don't have enough funds to pay buyin.") + print(e) + input("Press [Enter] to continue...") + break + print(colorize("Succesfully registered.", "green")) + while True: + mempool = rpc_connection.getrawmempool() + if newgame_regisration_txid in mempool: + print(colorize("Waiting for registration transaction to be mined", "blue")) + time.sleep(5) + else: + print(colorize("Registration transaction is mined", "green")) + break + print(newgame_regisration_txid) + input("Press [Enter] to continue...") + break + except KeyboardInterrupt: + break + + +def print_players_list(rpc_connection): + players_list = rogue_players_list(rpc_connection) + print(colorize("\nYou own " + str(players_list["numplayerdata"]) + " warriors\n", "blue")) + warrior_counter = 0 + for player in players_list["playerdata"]: + warrior_counter = warrior_counter + 1 + player_data = rogue_player_info(rpc_connection, player)["player"] + print(colorize("\n================================\n","green")) + print("Warrior " + str(warrior_counter)) + print("Name: " + player_data["pname"] + "\n") + print("Player txid: " + player_data["playertxid"]) + print("Token txid: " + player_data["tokenid"]) + print("Hitpoints: " + str(player_data["hitpoints"])) + print("Strength: " + str(player_data["strength"])) + print("Level: " + str(player_data["level"])) + print("Experience: " + str(player_data["experience"])) + print("Dungeon Level: " + str(player_data["dungeonlevel"])) + print("Chain: " + player_data["chain"]) + print(colorize("\nInventory:\n","blue")) + for item in player_data["pack"]: + print(item) + print("\nTotal packsize: " + str(player_data["packsize"]) + "\n") + input("Press [Enter] to continue...") + + +def sell_warrior(rpc_connection): + print(colorize("Your brave warriors: \n", "blue")) + print_players_list(rpc_connection) + print("\n") + while True: + need_sell = input("Do you want to place order to sell any? [y/n]: ") + if need_sell == "y": + playertxid = input("Input playertxid of warrior you want to sell: ") + price = input("Input price (in ROGUE coins) you want to sell warrior for: ") + try: + tokenid = rogue_player_info(rpc_connection, playertxid)["player"]["tokenid"] + except Exception as e: + print(e) + print("Something went wrong. Be careful with input next time.") + input("Press [Enter] to continue...") + break + token_ask_raw = rpc_connection.tokenask("1", tokenid, price) + try: + token_ask_txid = rpc_connection.sendrawtransaction(token_ask_raw["hex"]) + except Exception as e: + print(e) + print(token_ask_raw) + print("Something went wrong. Be careful with input next time.") + input("Press [Enter] to continue...") + break + print(colorize("Ask succesfully placed. Ask txid is: " + token_ask_txid, "green")) + input("Press [Enter] to continue...") + break + if need_sell == "n": + print("As you wish!") + input("Press [Enter] to continue...") + break + else: + print(colorize("Choose y or n!", "red")) + + +#TODO: have to combine into single scanner with different cases +def is_warrior_alive(rpc_connection, warrior_txid): + warrior_alive = False + raw_transaction = rpc_connection.getrawtransaction(warrior_txid, 1) + for vout in raw_transaction["vout"]: + if vout["value"] == 0.00000001 and rpc_connection.gettxout(raw_transaction["txid"], vout["n"]): + warrior_alive = True + return warrior_alive + + +def warriors_scanner(rpc_connection): + start_time = time.time() + token_list = rpc_connection.tokenlist() + my_warriors_list = rogue_players_list(rpc_connection) + warriors_list = {} + for token in token_list: + player_info = rogue_player_info(rpc_connection, token) + if "status" in player_info and player_info["status"] == "error": + pass + elif player_info["player"]["playertxid"] in my_warriors_list["playerdata"]: + pass + elif not is_warrior_alive(rpc_connection, player_info["player"]["playertxid"]): + pass + else: + warriors_list[token] = player_info["player"] + print("--- %s seconds ---" % (time.time() - start_time)) + return warriors_list + + +def warriors_scanner_for_rating(rpc_connection): + print("It can take some time") + token_list = rpc_connection.tokenlist() + my_warriors_list = rogue_players_list(rpc_connection) + actual_playerids = [] + warriors_list = {} + for token in token_list: + player_info = rogue_player_info(rpc_connection, token) + if "status" in player_info and player_info["status"] == "error": + pass + else: + while True: + if "batontxid" in player_info["player"].keys(): + player_info = rogue_player_info(rpc_connection, player_info["player"]["batontxid"]) + else: + actual_playerids.append(player_info["player"]["playertxid"]) + break + for player_id in actual_playerids: + player_info = rogue_player_info(rpc_connection, player_id) + if not is_warrior_alive(rpc_connection, player_info["player"]["playertxid"]): + pass + else: + warriors_list[player_id] = player_info["player"] + return warriors_list + + +def warriors_scanner_for_dex(rpc_connection): + start_time = time.time() + token_list = rpc_connection.tokenlist() + my_warriors_list = rogue_players_list(rpc_connection) + warriors_list = {} + for token in token_list: + player_info = rogue_player_info(rpc_connection, token) + if "status" in player_info and player_info["status"] == "error": + pass + elif player_info["player"]["tokenid"] in my_warriors_list["playerdata"]: + pass + else: + warriors_list[token] = player_info["player"] + print("--- %s seconds ---" % (time.time() - start_time)) + return warriors_list + + +def print_warrior_list(rpc_connection): + players_list = warriors_scanner(rpc_connection) + print(colorize("All warriors on ROGUE chain: \n", "blue")) + warrior_counter = 0 + for player in players_list: + warrior_counter = warrior_counter + 1 + player_data = rogue_player_info(rpc_connection, player)["player"] + print(colorize("\n================================\n","green")) + print("Warrior " + str(warrior_counter)) + print("Name: " + player_data["pname"] + "\n") + print("Player txid: " + player_data["playertxid"]) + print("Token txid: " + player_data["tokenid"]) + print("Hitpoints: " + str(player_data["hitpoints"])) + print("Strength: " + str(player_data["strength"])) + print("Level: " + str(player_data["level"])) + print("Experience: " + str(player_data["experience"])) + print("Dungeon Level: " + str(player_data["dungeonlevel"])) + print("Chain: " + player_data["chain"]) + print(colorize("\nInventory:\n","blue")) + for item in player_data["pack"]: + print(item) + print("\nTotal packsize: " + str(player_data["packsize"]) + "\n") + input("Press [Enter] to continue...") + + +def place_bid_on_warriror(rpc_connection): + warriors_list = print_warrior_list(rpc_connection) + # TODO: have to drop my warriors or at least print my warriors ids + while True: + need_buy = input("Do you want to place order to buy some warrior? [y/n]: ") + if need_buy == "y": + playertxid = input("Input playertxid of warrior you want to place bid for: ") + price = input("Input price (in ROGUE coins) you want to buy warrior for: ") + tokenid = rogue_player_info(rpc_connection, playertxid)["player"]["tokenid"] + token_bid_raw = rpc_connection.tokenbid("1", tokenid, price) + try: + token_bid_txid = rpc_connection.sendrawtransaction(token_bid_raw["hex"]) + except Exception as e: + print(e) + print(token_bid_raw) + print("Something went wrong. Be careful with input next time.") + input("Press [Enter] to continue...") + break + print(colorize("Bid succesfully placed. Bid txid is: " + token_bid_txid, "green")) + input("Press [Enter] to continue...") + break + if need_buy == "n": + print("As you wish!") + input("Press [Enter] to continue...") + break + else: + print(colorize("Choose y or n!", "red")) + + +def check_incoming_bids(rpc_connection): + # TODO: have to scan for warriors which are in asks as well + players_list = rogue_players_list(rpc_connection) + incoming_orders = [] + for player in players_list["playerdata"]: + token_id = rogue_player_info(rpc_connection, player)["player"]["tokenid"] + orders = rpc_connection.tokenorders(token_id) + if len(orders) > 0: + for order in orders: + if order["funcid"] == "b": + incoming_orders.append(order) + return incoming_orders + + +def print_icoming_bids(rpc_connection): + incoming_bids = check_incoming_bids(rpc_connection) + for bid in incoming_bids: + print("Recieved bid for warrior " + bid["tokenid"]) + player_data = rogue_player_info(rpc_connection, bid["tokenid"])["player"] + print(colorize("\n================================\n", "green")) + print("Name: " + player_data["pname"] + "\n") + print("Player txid: " + player_data["playertxid"]) + print("Token txid: " + player_data["tokenid"]) + print("Hitpoints: " + str(player_data["hitpoints"])) + print("Strength: " + str(player_data["strength"])) + print("Level: " + str(player_data["level"])) + print("Experience: " + str(player_data["experience"])) + print("Dungeon Level: " + str(player_data["dungeonlevel"])) + print("Chain: " + player_data["chain"]) + print(colorize("\nInventory:\n", "blue")) + for item in player_data["pack"]: + print(item) + print("\nTotal packsize: " + str(player_data["packsize"]) + "\n") + print(colorize("\n================================\n", "blue")) + print("Order info: \n") + print("Bid txid: " + bid["txid"]) + print("Price: " + str(bid["price"]) + "\n") + if len(incoming_bids) == 0: + print(colorize("There is no any incoming orders!", "blue")) + input("Press [Enter] to continue...") + else: + while True: + want_to_sell = input("Do you want to fill any incoming bid? [y/n]: ") + if want_to_sell == "y": + bid_txid = input("Input bid txid you want to fill: ") + for bid in incoming_bids: + if bid_txid == bid["txid"]: + tokenid = bid["tokenid"] + fill_sum = bid["totalrequired"] + fillbid_hex = rpc_connection.tokenfillbid(tokenid, bid_txid, str(fill_sum)) + try: + fillbid_txid = rpc_connection.sendrawtransaction(fillbid_hex["hex"]) + except Exception as e: + print(e) + print(fillbid_hex) + print("Something went wrong. Be careful with input next time.") + input("Press [Enter] to continue...") + break + print(colorize("Warrior succesfully sold. Txid is: " + fillbid_txid, "green")) + input("Press [Enter] to continue...") + break + if want_to_sell == "n": + print("As you wish!") + input("Press [Enter] to continue...") + break + else: + print(colorize("Choose y or n!", "red")) + + +def find_warriors_asks(rpc_connection): + warriors_list = warriors_scanner_for_dex(rpc_connection) + warriors_asks = [] + for player in warriors_list: + orders = rpc_connection.tokenorders(player) + if len(orders) > 0: + for order in orders: + if order["funcid"] == "s": + warriors_asks.append(order) + for ask in warriors_asks: + print(colorize("\n================================\n", "green")) + print("Warrior selling on marketplace: " + ask["tokenid"]) + player_data = rogue_player_info(rpc_connection, ask["tokenid"])["player"] + print("Name: " + player_data["pname"] + "\n") + print("Player txid: " + player_data["playertxid"]) + print("Token txid: " + player_data["tokenid"]) + print("Hitpoints: " + str(player_data["hitpoints"])) + print("Strength: " + str(player_data["strength"])) + print("Level: " + str(player_data["level"])) + print("Experience: " + str(player_data["experience"])) + print("Dungeon Level: " + str(player_data["dungeonlevel"])) + print("Chain: " + player_data["chain"]) + print(colorize("\nInventory:\n", "blue")) + for item in player_data["pack"]: + print(item) + print("\nTotal packsize: " + str(player_data["packsize"]) + "\n") + print(colorize("Order info: \n", "red")) + print("Ask txid: " + ask["txid"]) + print("Price: " + str(ask["price"]) + "\n") + while True: + want_to_buy = input("Do you want to buy any warrior? [y/n]: ") + if want_to_buy == "y": + ask_txid = input("Input asktxid which you want to fill: ") + for ask in warriors_asks: + if ask_txid == ask["txid"]: + tokenid = ask["tokenid"] + try: + fillask_raw = rpc_connection.tokenfillask(tokenid, ask_txid, "1") + except Exception as e: + print("Something went wrong. Be careful with input next time.") + input("Press [Enter] to continue...") + break + try: + fillask_txid = rpc_connection.sendrawtransaction(fillask_raw["hex"]) + except Exception as e: + print(e) + print(fillask_raw) + print("Something went wrong. Be careful with input next time.") + input("Press [Enter] to continue...") + break + print(colorize("Warrior succesfully bought. Txid is: " + fillask_txid, "green")) + input("Press [Enter] to continue...") + break + if want_to_buy == "n": + print("As you wish!") + input("Press [Enter] to continue...") + break + else: + print(colorize("Choose y or n!", "red")) + + +def warriors_orders_check(rpc_connection): + my_orders_list = rpc_connection.mytokenorders("17") + warriors_orders = {} + for order in my_orders_list: + player_info = rogue_player_info(rpc_connection, order["tokenid"]) + if "status" in player_info and player_info["status"] == "error": + pass + else: + warriors_orders[order["tokenid"]] = order + bids_list = [] + asks_list = [] + for order in warriors_orders: + if warriors_orders[order]["funcid"] == "s": + asks_list.append(warriors_orders[order]) + else: + bids_list.append(order) + print(colorize("\nYour asks:\n", "blue")) + print(colorize("\n********************************\n", "red")) + for ask in asks_list: + print("txid: " + ask["txid"]) + print("Price: " + ask["price"]) + print("Warrior tokenid: " + ask["tokenid"]) + print(colorize("\n================================\n", "green")) + print("Warrior selling on marketplace: " + ask["tokenid"]) + player_data = rogue_player_info(rpc_connection, ask["tokenid"])["player"] + print("Name: " + player_data["pname"] + "\n") + print("Player txid: " + player_data["playertxid"]) + print("Token txid: " + player_data["tokenid"]) + print("Hitpoints: " + str(player_data["hitpoints"])) + print("Strength: " + str(player_data["strength"])) + print("Level: " + str(player_data["level"])) + print("Experience: " + str(player_data["experience"])) + print("Dungeon Level: " + str(player_data["dungeonlevel"])) + print("Chain: " + player_data["chain"]) + print(colorize("\nInventory:\n", "blue")) + for item in player_data["pack"]: + print(item) + print("\nTotal packsize: " + str(player_data["packsize"]) + "\n") + print(colorize("\n================================\n", "green")) + print(colorize("\nYour bids:\n", "blue")) + print(colorize("\n********************************\n", "red")) + for bid in bids_list: + print("txid: " + bid["txid"]) + print("Price: " + bid["price"]) + print("Warrior tokenid: " + bid["tokenid"]) + print(colorize("\n================================\n", "green")) + print("Warrior selling on marketplace: " + bid["tokenid"]) + player_data = rogue_player_info(rpc_connection, bid["tokenid"])["player"] + print("Name: " + player_data["pname"] + "\n") + print("Player txid: " + player_data["playertxid"]) + print("Token txid: " + player_data["tokenid"]) + print("Hitpoints: " + str(player_data["hitpoints"])) + print("Strength: " + str(player_data["strength"])) + print("Level: " + str(player_data["level"])) + print("Experience: " + str(player_data["experience"])) + print("Dungeon Level: " + str(player_data["dungeonlevel"])) + print("Chain: " + player_data["chain"]) + print(colorize("\nInventory:\n", "blue")) + for item in player_data["pack"]: + print(item) + print("\nTotal packsize: " + str(player_data["packsize"]) + "\n") + print(colorize("\n================================\n", "green")) + while True: + need_order_change = input("Do you want to cancel any of your orders? [y/n]: ") + if need_order_change == "y": + while True: + ask_or_bid = input("Do you want cancel ask or bid? [a/b]: ") + if ask_or_bid == "a": + ask_txid = input("Input txid of ask you want to cancel: ") + warrior_tokenid = input("Input warrior token id for this ask: ") + try: + ask_cancellation_hex = rpc_connection.tokencancelask(warrior_tokenid, ask_txid) + ask_cancellation_txid = rpc_connection.sendrawtransaction(ask_cancellation_hex["hex"]) + except Exception as e: + print(colorize("Please re-check your input!", "red")) + print(colorize("Ask succefully cancelled. Cancellation txid: " + ask_cancellation_txid, "green")) + break + if ask_or_bid == "b": + bid_txid = input("Input txid of bid you want to cancel: ") + warrior_tokenid = input("Input warrior token id for this bid: ") + try: + bid_cancellation_hex = rpc_connection.tokencancelbid(warrior_tokenid, bid_txid) + bid_cancellation_txid = rpc_connection.sendrawtransaction(bid_cancellation_hex["hex"]) + except Exception as e: + print(colorize("Please re-check your input!", "red")) + print(colorize("Bid succefully cancelled. Cancellation txid: " + bid_cancellation_txid, "green")) + break + else: + print(colorize("Choose a or b!", "red")) + input("Press [Enter] to continue...") + break + if need_order_change == "n": + print("As you wish!") + input("Press [Enter] to continue...") + break + else: + print(colorize("Choose y or n!", "red")) + + +def set_warriors_name(rpc_connection): + warriors_name = input("What warrior name do you want for legends and tales about your brave adventures?: ") + warrior_name_arg = '"' + "[%22" + warriors_name + "%22]" + '"' + set_name_status = rpc_connection.cclib("setname", "17", warrior_name_arg) + print(colorize("Warrior name succesfully set", "green")) + print("Result: " + set_name_status["result"]) + print("Name: " + set_name_status["pname"]) + input("Press [Enter] to continue...") + + +def top_warriors_rating(rpc_connection): + start_time = time.time() + warriors_list = warriors_scanner_for_rating(rpc_connection) + warriors_exp = {} + for warrior in warriors_list: + warriors_exp[warrior] = warriors_list[warrior]["experience"] + warriors_exp_sorted = {} + temp = [(k, warriors_exp[k]) for k in sorted(warriors_exp, key=warriors_exp.get, reverse=True)] + for k,v in temp: + warriors_exp_sorted[k] = v + counter = 0 + for experienced_warrior in warriors_exp_sorted: + if counter < 20: + counter = counter + 1 + print("\n" + str(counter) + " place.") + print(colorize("\n================================\n", "blue")) + player_data = rogue_player_info(rpc_connection, experienced_warrior)["player"] + print("Name: " + player_data["pname"] + "\n") + print("Player txid: " + player_data["playertxid"]) + print("Token txid: " + player_data["tokenid"]) + print("Hitpoints: " + str(player_data["hitpoints"])) + print("Strength: " + str(player_data["strength"])) + print("Level: " + str(player_data["level"])) + print("Experience: " + str(player_data["experience"])) + print("Dungeon Level: " + str(player_data["dungeonlevel"])) + print("Chain: " + player_data["chain"]) + print("--- %s seconds ---" % (time.time() - start_time)) + input("Press [Enter] to continue...") + + +def exit(): + sys.exit() + + +def warrior_trasnfer(rpc_connection): + print(colorize("Your brave warriors: \n", "blue")) + print_players_list(rpc_connection) + print("\n") + while True: + need_transfer = input("Do you want to transfer any warrior? [y/n]: ") + if need_transfer == "y": + warrior_tokenid = input("Input warrior tokenid: ") + recepient_pubkey = input("Input recepient pubkey: ") + try: + token_transfer_hex = rpc_connection.tokentransfer(warrior_tokenid, recepient_pubkey, "1") + token_transfer_txid = rpc_connection.sendrawtransaction(token_transfer_hex["hex"]) + except Exception as e: + print(e) + print("Something went wrong. Please be careful with your input next time!") + input("Press [Enter] to continue...") + break + print(colorize("Warrior succesfully transferred! Transfer txid: " + token_transfer_txid, "green")) + input("Press [Enter] to continue...") + break + if need_transfer == "n": + print("As you wish!") + input("Press [Enter] to continue...") + break + else: + print(colorize("Choose y or n!", "red")) + + +def check_if_config_is_here(rpc_connection, assetchain_name): + config_name = assetchain_name + ".conf" + if os.path.exists(config_name): + print(colorize("Config is already in daemon folder", "green")) + else: + if operating_system == 'Darwin': + path_to_config = os.environ['HOME'] + '/Library/Application Support/Komodo/' + assetchain_name + '/' + config_name + elif operating_system == 'Linux': + path_to_config = os.environ['HOME'] + '/.komodo/' + assetchain_name + '/' + config_name + elif operating_system == 'Win64' or operating_system == 'Windows': + path_to_config = '%s/komodo/' + assetchain_name + '/' + config_name % os.environ['APPDATA'] + try: + copy(path_to_config, os.getcwd()) + except Exception as e: + print(e) + print("Can't copy config to current daemon directory automatically by some reason.") + print("Please copy it manually. It's locating here: " + path_to_config) + + +def find_game_keystrokes_in_log(gametxid): + + operating_system = platform.system() + if operating_system == 'Win64' or operating_system == 'Windows': + p1 = subprocess.Popen(["type", "keystrokes.log"], stdout=subprocess.PIPE, shell=True) + p2 = subprocess.Popen(["findstr", gametxid], stdin=p1.stdout, stdout=subprocess.PIPE, shell=True) + else: + p1 = subprocess.Popen(["cat", "keystrokes.log"], stdout=subprocess.PIPE) + p2 = subprocess.Popen(["grep", gametxid], stdin=p1.stdout, stdout=subprocess.PIPE) + p1.stdout.close() + output = p2.communicate()[0] + keystrokes_log_for_game = bytes.decode(output).split("\n") + return keystrokes_log_for_game + + +def check_if_tx_in_mempool(rpc_connection, txid): + while True: + mempool = rpc_connection.getrawmempool() + if txid in mempool: + print(colorize("Waiting for " + txid + " transaction to be mined", "blue")) + time.sleep(5) + else: + print(colorize("Transaction is mined", "green")) + break diff --git a/src/tui/requirements.txt b/src/tui/requirements.txt new file mode 100644 index 000000000..734da529c --- /dev/null +++ b/src/tui/requirements.txt @@ -0,0 +1,8 @@ +configobj==5.0.6 +pip==9.0.1 +pycurl==7.43.0.2 +setuptools==39.0.1 +six==1.12.0 +slick-bitcoinrpc==0.1.4 +ujson==1.35 +wheel==0.32.3 diff --git a/src/tui/tui_assets.py b/src/tui/tui_assets.py new file mode 100755 index 000000000..091484a40 --- /dev/null +++ b/src/tui/tui_assets.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +from lib import rpclib, tuilib +import os +import time + + +header = "\ + ___ _ _____ \n\ + / _ \ | | / __ \\\n\ +/ /_\ \ ___ ___ ___ | |_ ___ | / \/\n\ +| _ |/ __|/ __| / _ \| __|/ __|| | \n\ +| | | |\__ \\\__ \| __/| |_ \__ \| \__/\\\n\ +\_| |_/|___/|___/ \___| \__||___/ \____/\n" + + +menuItems = [ + {"Check current connection": tuilib.getinfo_tui}, + {"Check mempool": tuilib.print_mempool}, + {"Print tokens list": tuilib.print_tokens_list}, + {"Check my tokens balances" : tuilib.print_tokens_balances}, + # transfer tokens (pre-print tokens balances) + {"Create token": tuilib.token_create_tui}, + # trading zone - pre-print token orders - possible to open order or fill existing one + {"Exit": exit} +] + + +def main(): + while True: + os.system('clear') + print(tuilib.colorize(header, 'pink')) + print(tuilib.colorize('CLI version 0.2 by Anton Lysakov\n', 'green')) + for item in menuItems: + print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) + choice = input(">> ") + try: + if int(choice) < 0: + raise ValueError + # Call the matching function + if list(menuItems[int(choice)].keys())[0] == "Exit": + list(menuItems[int(choice)].values())[0]() + else: + list(menuItems[int(choice)].values())[0](rpc_connection) + except (ValueError, IndexError): + pass + + +if __name__ == "__main__": + while True: + try: + print(tuilib.colorize("Welcome to the GatewaysCC TUI!\n" + "Please provide asset chain RPC connection details for initialization", "blue")) + rpc_connection = tuilib.rpc_connection_tui() + rpclib.getinfo(rpc_connection) + except Exception: + print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) + else: + print(tuilib.colorize("Succesfully connected!\n", "green")) + with (open("lib/logo.txt", "r")) as logo: + for line in logo: + print(line, end='') + time.sleep(0.04) + print("\n") + break + main() + diff --git a/src/tui/tui_gateways_creation.py b/src/tui/tui_gateways_creation.py new file mode 100755 index 000000000..7bb489c7f --- /dev/null +++ b/src/tui/tui_gateways_creation.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +from lib import rpclib, tuilib +import os +import time + +header = "\ + _____ _ _____ _____ \n\ +| __ \ | | / __ \/ __ \\\n\ +| | \/ __ _| |_ _____ ____ _ _ _ ___| / \/| / \/\n\ +| | __ / _` | __/ _ \ \ /\ / / _` | | | / __| | | | \n\ +| |_\ \ (_| | || __/\ V V / (_| | |_| \__ \ \__/\| \__/\\\n\ + \____/\__,_|\__\___| \_/\_/ \__,_|\__, |___/\____/ \____/\n\ + __/ | \n\ + |___/ \n" + + +menuItems = [ + {"Check current connection": tuilib.getinfo_tui}, + {"Check mempool": tuilib.print_mempool}, + {"Create token": tuilib.token_create_tui}, + {"Create oracle": tuilib.oracle_create_tui}, + {"Register as publisher for oracle": tuilib.oracle_register_tui}, + {"Subscribe on oracle (+UTXO generator)": tuilib.oracle_subscription_utxogen}, + {"Bind Gateway": tuilib.gateways_bind_tui}, + {"Exit": exit} +] + + +def main(): + while True: + os.system('clear') + print(tuilib.colorize(header, 'pink')) + print(tuilib.colorize('CLI version 0.2\n', 'green')) + for item in menuItems: + print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) + choice = input(">> ") + try: + if int(choice) < 0: + raise ValueError + # Call the matching function + if list(menuItems[int(choice)].keys())[0] == "Exit": + list(menuItems[int(choice)].values())[0]() + else: + list(menuItems[int(choice)].values())[0](rpc_connection) + except (ValueError, IndexError): + pass + + +if __name__ == "__main__": + while True: + try: + print(tuilib.colorize("Welcome to the GatewaysCC TUI!\n" + "Please provide asset chain RPC connection details for initialization", "blue")) + rpc_connection = tuilib.rpc_connection_tui() + rpclib.getinfo(rpc_connection) + except Exception: + print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) + else: + print(tuilib.colorize("Succesfully connected!\n", "green")) + with (open("lib/logo.txt", "r")) as logo: + for line in logo: + print(line, end='') + time.sleep(0.04) + print("\n") + break + main() diff --git a/src/tui/tui_gateways_usage.py b/src/tui/tui_gateways_usage.py new file mode 100755 index 000000000..0c989e3af --- /dev/null +++ b/src/tui/tui_gateways_usage.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 + +from lib import rpclib, tuilib +import os, time + +header = "\ + _____ _ _____ _____ \n\ +| __ \ | | / __ \/ __ \\\n\ +| | \/ __ _| |_ _____ ____ _ _ _ ___| / \/| / \/\n\ +| | __ / _` | __/ _ \ \ /\ / / _` | | | / __| | | | \n\ +| |_\ \ (_| | || __/\ V V / (_| | |_| \__ \ \__/\| \__/\\\n\ + \____/\__,_|\__\___| \_/\_/ \__,_|\__, |___/\____/ \____/\n\ + __/ | \n\ + |___/ \n" + +menuItems = [ + {"Check connection to assetchain": tuilib.getinfo_tui}, + {"Check assetchain mempool": tuilib.print_mempool}, + {"Check connection to KMD": tuilib.getinfo_tui}, + {"Connect to KMD daemon": tuilib.rpc_kmd_connection_tui}, + {"Send KMD gateway deposit transaction": tuilib.gateways_send_kmd}, + {"Execute gateways deposit": tuilib.gateways_deposit_tui}, + {"Execute gateways claim": tuilib.gateways_claim_tui}, + {"Execute gateways withdrawal": tuilib.gateways_withdrawal_tui}, + {"Exit": exit} +] + +def main(): + while True: + os.system('clear') + print(tuilib.colorize(header, 'pink')) + print(tuilib.colorize('CLI version 0.2\n', 'green')) + for item in menuItems: + print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) + choice = input(">> ") + try: + if int(choice) < 0: + raise ValueError + # Call the matching function + if list(menuItems[int(choice)].keys())[0] == "Exit": + list(menuItems[int(choice)].values())[0]() + # We have to call KMD specific functions with connection to KMD daemon + elif list(menuItems[int(choice)].keys())[0] == "Connect to KMD daemon": + rpc_connection_kmd = list(menuItems[int(choice)].values())[0]() + elif list(menuItems[int(choice)].keys())[0] == "Check connection to KMD": + while True: + try: + list(menuItems[int(choice)].values())[0](rpc_connection_kmd) + break + except Exception as e: + print("Please connect to KMD daemon first!") + input("Press [Enter] to continue...") + break + elif list(menuItems[int(choice)].keys())[0] == "Send KMD gateway deposit transaction": + while True: + try: + list(menuItems[int(choice)].values())[0](rpc_connection_kmd) + break + except Exception as e: + print(e) + print("Please connect to KMD daemon first!") + input("Press [Enter] to continue...") + break + elif list(menuItems[int(choice)].keys())[0] == "Execute gateways deposit": + while True: + try: + list(menuItems[int(choice)].values())[0](rpc_connection, rpc_connection_kmd) + break + except Exception as e: + print(e) + print("Please connect to KMD daemon first!") + input("Press [Enter] to continue...") + break + else: + list(menuItems[int(choice)].values())[0](rpc_connection) + except (ValueError, IndexError): + pass + + +if __name__ == "__main__": + while True: + try: + print(tuilib.colorize("Welcome to the GatewaysCC TUI!\nPlease provide RPC connection details for initialization", "blue")) + rpc_connection = tuilib.rpc_connection_tui() + rpclib.getinfo(rpc_connection) + except Exception: + print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) + else: + print(tuilib.colorize("Succesfully connected!\n", "green")) + with (open("lib/logo.txt", "r")) as logo: + for line in logo: + print(line, end='') + time.sleep(0.04) + print("\n") + break + main() diff --git a/src/tui/tui_marmara.py b/src/tui/tui_marmara.py new file mode 100755 index 000000000..cfe628890 --- /dev/null +++ b/src/tui/tui_marmara.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +from lib import rpclib, tuilib +import os +import time + + +header = "\ +___ ___ _____ _ _ _____ \n\ +| \/ | |_ _| | | |_ _|\n\ +| . . | __ _ _ __ _ __ ___ __ _ _ __ __ _ | | | | | | | |\n\ +| |\/| |/ _` | '__| '_ ` _ \ / _` | '__/ _` | | | | | | | | |\n\ +| | | | (_| | | | | | | | | (_| | | | (_| | | | | |_| |_| |_\n\ +\_| |_/\__,_|_| |_| |_| |_|\__,_|_| \__,_| \_/ \___/ \___/\n" + + +menuItems = [ + {"Check current connection": tuilib.getinfo_tui}, + {"Check mempool": tuilib.print_mempool}, + {"Check MARMARA info": tuilib.marmara_info_tui}, + {"Lock funds for MARMARA": tuilib.marmara_lock_tui}, + {"Request MARMARA cheque": tuilib.marmara_receive_tui}, + {"Issue MARMARA cheque": tuilib.marmara_issue_tui}, + {"Check credit loop status": tuilib.marmara_creditloop_tui}, + {"Settle MARMARA loop": tuilib.marmara_settlement_tui}, + {"Exit": exit} +] + + +def main(): + while True: + os.system('clear') + print(tuilib.colorize(header, 'pink')) + print(tuilib.colorize('CLI version 0.1\n', 'green')) + for item in menuItems: + print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) + choice = input(">> ") + try: + if int(choice) < 0: + raise ValueError + # Call the matching function + if list(menuItems[int(choice)].keys())[0] == "Exit": + list(menuItems[int(choice)].values())[0]() + else: + list(menuItems[int(choice)].values())[0](rpc_connection) + except (ValueError, IndexError): + pass + + +if __name__ == "__main__": + while True: + chain = input("Input assetchain name (-ac_name= value) you want to work with: ") + try: + print(tuilib.colorize("Welcome to the MarmaraCC TUI!\n" + "Please provide asset chain RPC connection details for initialization", "blue")) + rpc_connection = tuilib.def_credentials(chain) + rpclib.getinfo(rpc_connection) + except Exception: + print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) + else: + print(tuilib.colorize("Succesfully connected!\n", "green")) + with (open("lib/logo.txt", "r")) as logo: + for line in logo: + print(line, end='') + time.sleep(0.04) + print("\n") + break + main() diff --git a/src/tui/tui_oracles.py b/src/tui/tui_oracles.py new file mode 100755 index 000000000..fec874d35 --- /dev/null +++ b/src/tui/tui_oracles.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +from lib import rpclib, tuilib +import os +import time + +header = "\ + _____ _ _____ _____ \n\ +| _ | | | / __ \/ __ \\\n\ +| | | | _ __ __ _ ___ | | ___ ___ | / \/| / \/\n\ +| | | || '__| / _` | / __|| | / _ \/ __|| | | |\n\ +\ \_/ /| | | (_| || (__ | || __/\__ \| \__/\| \__/\\\n\ + \___/ |_| \__,_| \___||_| \___||___/ \____/ \____/\n" + +menuItems = [ + # TODO: Have to implement here native oracle file uploader / reader, should be dope + # TODO: data publisher / converter for different types + {"Check current connection": tuilib.getinfo_tui}, + {"Check mempool": tuilib.print_mempool}, + {"Create oracle": tuilib.oracle_create_tui}, + {"Register as publisher for oracle": tuilib.oracle_register_tui}, + {"Subscribe on oracle (+UTXO generator)": tuilib.oracle_subscription_utxogen}, + {"Upload file to oracle": tuilib.convert_file_oracle_D}, + {"Display list of files uploaded to this AC": tuilib.display_files_list}, + {"Download files from oracle": tuilib.files_downloader}, + {"Exit": exit} +] + + +def main(): + while True: + os.system('clear') + print(tuilib.colorize(header, 'pink')) + print(tuilib.colorize('CLI version 0.2 by Anton Lysakov\n', 'green')) + for item in menuItems: + print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) + choice = input(">> ") + try: + if int(choice) < 0: + raise ValueError + # Call the matching function + if list(menuItems[int(choice)].keys())[0] == "Exit": + list(menuItems[int(choice)].values())[0]() + else: + list(menuItems[int(choice)].values())[0](rpc_connection) + except (ValueError, IndexError): + pass + + +if __name__ == "__main__": + while True: + try: + print(tuilib.colorize("Welcome to the GatewaysCC TUI!\n" + "Please provide asset chain RPC connection details for initialization", "blue")) + rpc_connection = tuilib.rpc_connection_tui() + rpclib.getinfo(rpc_connection) + except Exception: + print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) + else: + print(tuilib.colorize("Succesfully connected!\n", "green")) + with (open("lib/logo.txt", "r")) as logo: + for line in logo: + print(line, end='') + time.sleep(0.04) + print("\n") + break + main() diff --git a/src/tui/tui_rogue.py b/src/tui/tui_rogue.py new file mode 100755 index 000000000..9942369e2 --- /dev/null +++ b/src/tui/tui_rogue.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 + +from lib import rpclib, tuilib +import os +import time +import sys +import platform + +header = "\ +______ _____ _____ \n\ +| ___ \ / __ \/ __ \\\n\ +| |_/ /___ __ _ _ _ ___| / \/| / \/\n\ +| // _ \ / _` | | | |/ _ \ | | |\n\ +| |\ \ (_) | (_| | |_| | __/ \__/\| \__/\\\n\ +\_| \_\___/ \__, |\__,_|\___|\____/ \____/\n\ + __/ |\n\ + |___/\n" + + +menuItems = [ + {"Check current connection": tuilib.getinfo_tui}, + {"Check mempool": tuilib.print_mempool}, + {"Check my warriors list": tuilib.print_players_list}, + {"Transfer warrior to other pubkey": tuilib.warrior_trasnfer}, + {"TOP-20 ROGUE Warriors": tuilib.top_warriors_rating}, + {"Set warriors name": tuilib.set_warriors_name}, + {"Start singleplayer training game (creating, registering and starting game)": tuilib.rogue_newgame_singleplayer}, + {"Create multiplayer game": tuilib.rogue_newgame_multiplayer}, + {"Join (register) multiplayer game": tuilib.rogue_join_multiplayer_game}, + {"Check my multiplayer games status / start": tuilib.play_multiplayer_game}, + {"Check if somebody wants to buy your warrior (incoming bids)": tuilib.print_icoming_bids}, + {"Place order to sell warrior": tuilib.sell_warrior}, + {"Place order to buy someones warrior": tuilib.place_bid_on_warriror}, + {"Check if somebody selling warrior": tuilib.find_warriors_asks}, + {"Check / cancel my warriors trade orders": tuilib.warriors_orders_check}, + # {"Manually exit the game (bailout)": "test"}, + # {"Manually claim ROGUE coins for game (highlander)": "test"}, + {"Exit": tuilib.exit} +] + +def main(): + while True: + operating_system = platform.system() + if operating_system != 'Win64' and operating_system != 'Windows': + os.system('clear') + else: + os.system('cls') + print(tuilib.colorize(header, 'pink')) + print(tuilib.colorize('TUI v0.0.3\n', 'green')) + menu_items_counter = 0 + for item in menuItems: + if menu_items_counter == 0: + print("\nUtility:\n") + menu_items_counter = menu_items_counter + 1 + print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) + if menu_items_counter == 6: + print("\nNew singleplayer game:\n") + if menu_items_counter == 7: + print("\nMultiplayer games:\n") + if menu_items_counter == 10: + print("\nDEX features:\n") + choice = input(">> ") + try: + if int(choice) < 0: + raise ValueError + # Call the matching function + if list(menuItems[int(choice)].keys())[0] == "Exit": + list(menuItems[int(choice)].values())[0]() + else: + list(menuItems[int(choice)].values())[0](rpc_connection) + except (ValueError, IndexError): + pass + + +if __name__ == "__main__": + while True: + chain = "ROGUE" + try: + print(tuilib.colorize("Welcome to the RogueCC TUI!\n" + "Please provide asset chain RPC connection details for initialization", "blue")) + rpc_connection = tuilib.def_credentials(chain) + rpclib.getinfo(rpc_connection) + # waiting until chain is in sync + while True: + have_blocks = rpclib.getinfo(rpc_connection)["blocks"] + longest_chain = rpclib.getinfo(rpc_connection)["longestchain"] + if have_blocks != longest_chain: + print(tuilib.colorize("ROGUE not synced yet.", "red")) + print("Have " + str(have_blocks) + " from " + str(longest_chain) + " blocks") + time.sleep(5) + else: + print(tuilib.colorize("Chain is synced!", "green")) + break + # checking if pubkey is set and set valid if not + info = rpclib.getinfo(rpc_connection) + if "pubkey" in info.keys(): + print("Pubkey is already set") + else: + valid_address = rpc_connection.getaccountaddress("") + valid_pubkey = rpc_connection.validateaddress(valid_address)["pubkey"] + rpc_connection.setpubkey(valid_pubkey) + print(tuilib.colorize("Pubkey is succesfully set!", "green")) + # copy ROGUE config to current daemon directory if it's not here + tuilib.check_if_config_is_here(rpc_connection, "ROGUE") + except Exception: + print(tuilib.colorize("Cant connect to ROGUE daemon RPC! Please check if daemon is up.", "pink")) + tuilib.exit() + else: + print(tuilib.colorize("Succesfully connected!\n", "green")) + with (open("lib/logo.txt", "r")) as logo: + for line in logo: + print(line, end='') + time.sleep(0.04) + print("\n") + break + main() diff --git a/src/tui/tui_tetris.py b/src/tui/tui_tetris.py new file mode 100755 index 000000000..3c42d4daa --- /dev/null +++ b/src/tui/tui_tetris.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 + +from lib import rpclib, tuilib +import os +import time +import sys +import platform + +header = "\ + _____ _ _ ______\n\ +|_ _| | | (_) | _ \n\ + | | ___| |_ _ __ _ ___| | | |__ _ _ __ _ __\n\ + | |/ _ \ __| '__| / __| | | / _` | '_ \| '_ \\\n\ + | | __/ |_| | | \__ \ |/ / (_| | |_) | |_) |\n\ + \_/\___|\__|_| |_|___/___/ \__,_| .__/| .__/\n\ + | | | |\n\ + |_| |_|" + + +menuItems = [ + {"Check current connection": tuilib.getinfo_tui}, + {"Check mempool": tuilib.print_mempool}, + {"Start singleplayer tetris game (creating, registering and starting game)": tuilib.rogue_newgame_singleplayer}, + {"Exit": tuilib.exit} +] + + +def main(): + while True: + operating_system = platform.system() + if operating_system != 'Win64' and operating_system != 'Windows': + os.system('clear') + else: + os.system('cls') + print(tuilib.colorize(header, 'pink')) + print(tuilib.colorize('TUI v0.0.3\n', 'green')) + menu_items_counter = 0 + for item in menuItems: + print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) + choice = input(">> ") + try: + if int(choice) < 0: + raise ValueError + # Call the matching function + if list(menuItems[int(choice)].keys())[0] == "Exit": + list(menuItems[int(choice)].values())[0]() + elif list(menuItems[int(choice)].keys())[0] == "Start singleplayer tetris game (creating, registering and starting game)": + list(menuItems[int(choice)].values())[0](rpc_connection, False) + else: + list(menuItems[int(choice)].values())[0](rpc_connection) + except (ValueError, IndexError): + pass + + +if __name__ == "__main__": + while True: + chain = "GTEST" + try: + print(tuilib.colorize("Welcome to the Tetris TUI!\n" + "Please provide asset chain RPC connection details for initialization", "blue")) + rpc_connection = tuilib.def_credentials(chain) + rpclib.getinfo(rpc_connection) + # waiting until chain is in sync + while True: + have_blocks = rpclib.getinfo(rpc_connection)["blocks"] + longest_chain = rpclib.getinfo(rpc_connection)["longestchain"] + if have_blocks != longest_chain: + print(tuilib.colorize("GTEST not synced yet.", "red")) + print("Have " + str(have_blocks) + " from " + str(longest_chain) + " blocks") + time.sleep(5) + else: + print(tuilib.colorize("Chain is synced!", "green")) + break + # checking if pubkey is set and set valid if not + info = rpclib.getinfo(rpc_connection) + if "pubkey" in info.keys(): + print("Pubkey is already set") + else: + valid_address = rpc_connection.getaccountaddress("") + valid_pubkey = rpc_connection.validateaddress(valid_address)["pubkey"] + rpc_connection.setpubkey(valid_pubkey) + print(tuilib.colorize("Pubkey is succesfully set!", "green")) + # copy ROGUE config to current daemon directory if it's not here + tuilib.check_if_config_is_here(rpc_connection, "GTEST") + except Exception: + print(tuilib.colorize("Cant connect to GTEST daemon RPC! Please check if daemon is up.", "pink")) + tuilib.exit() + else: + print(tuilib.colorize("Succesfully connected!\n", "green")) + with (open("lib/logo.txt", "r")) as logo: + for line in logo: + print(line, end='') + time.sleep(0.04) + print("\n") + break + main() From 7ca041ee23431d14862dc33b5ff8e918d099c9af Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 05:52:33 -1100 Subject: [PATCH 3449/3904] Test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1b0664bb8..4a17a1b3d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1578,6 +1578,7 @@ uint32_t komodo_pricenew(uint32_t price,uint32_t refprice,int64_t tolerance) uint32_t highprice,lowprice; highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; + fprintf(stderr,"%.4f -> (%.4f %.4f)\n",(double)price/10000,(double)lowprice/10000,(double)highprice/10000); if ( price > highprice ) return(highprice); else if ( price < lowprice ) From 10df98e580a9c3ac52c8c19379aecc3c0c51265f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 06:03:01 -1100 Subject: [PATCH 3450/3904] -print --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4a17a1b3d..58054feba 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1578,7 +1578,7 @@ uint32_t komodo_pricenew(uint32_t price,uint32_t refprice,int64_t tolerance) uint32_t highprice,lowprice; highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; - fprintf(stderr,"%.4f -> (%.4f %.4f)\n",(double)price/10000,(double)lowprice/10000,(double)highprice/10000); + //fprintf(stderr,"%.4f -> (%.4f %.4f)\n",(double)price/10000,(double)lowprice/10000,(double)highprice/10000); if ( price > highprice ) return(highprice); else if ( price < lowprice ) @@ -1602,7 +1602,7 @@ int32_t komodo_priceclamp(uint32_t pricebits[4],uint32_t refprices[4],int64_t to { if ( (newprice= komodo_pricenew(pricebits[i],refprices[i],tolerance)) != 0 ) { - fprintf(stderr,"priceclamp[%d] %u -> %u\n",i,pricebits[i],newprice); + fprintf(stderr,"priceclamped[%d] %u -> %u\n",i,pricebits[i],newprice); pricebits[i] = newprice; } } From 2f0c3c23fa69fb14c12f38d04d1f08645035c34a Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 29 Mar 2019 00:39:15 +0700 Subject: [PATCH 3451/3904] added komodoku gui --- src/gui/README.md | 27 +++ src/gui/Roboto-Light.ttf | Bin 0 -> 140276 bytes src/gui/Sudoku.py | 362 +++++++++++++++++++++++++++++++++++++++ src/gui/background.png | Bin 0 -> 308479 bytes src/gui/board.png | Bin 0 -> 5678 bytes src/gui/sudoku_kmdlib.py | 41 +++++ 6 files changed, 430 insertions(+) create mode 100644 src/gui/README.md create mode 100755 src/gui/Roboto-Light.ttf create mode 100644 src/gui/Sudoku.py create mode 100644 src/gui/background.png create mode 100644 src/gui/board.png create mode 100644 src/gui/sudoku_kmdlib.py diff --git a/src/gui/README.md b/src/gui/README.md new file mode 100644 index 000000000..8a3778ea0 --- /dev/null +++ b/src/gui/README.md @@ -0,0 +1,27 @@ +About +----- +Komodo SudokuCC GUI + +Just solve Sudoku and earn SUDOKU coins! + +![alt text](https://i.imgur.com/std99XW.png) + +To run you need up and running SUDOKU chain daemon built from latest https://github.com/jl777/komodo/tree/FSM and started with valid for your wallet pubkey in `-pubkey=` param. + +SUDOKU chain params: +```./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc &``` + +1) install dependencies: + +``` +$ sudo apt-get install python-pygame libgnutls28-dev +$ pip install requests wheel slick-bitcoinrpc pygame +``` + +2) and then start: + +``` +$ git clone https://github.com/tonymorony/Komodoku +$ cd Komodoku +$ python Sudoku.py +``` diff --git a/src/gui/Roboto-Light.ttf b/src/gui/Roboto-Light.ttf new file mode 100755 index 0000000000000000000000000000000000000000..664e1b2f9dbafbf6280305123d2df7fa0c66cee9 GIT binary patch literal 140276 zcmbrn2V4}#`#(N2ySGQ@=ql0$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d00001 diff --git a/src/gui/Sudoku.py b/src/gui/Sudoku.py new file mode 100644 index 000000000..7b46d93fc --- /dev/null +++ b/src/gui/Sudoku.py @@ -0,0 +1,362 @@ +#!/usr/bin/env python + +# Copyright (C) 2010 Paul Bourke +# Copyright (C) 2019 Anton Lysakov +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import pygame +import sys +import random +import sudoku_kmdlib +import time + +class PyGameBoard(): + """Represents the game's frontend using pygame""" + + def __init__(self, engine, windowSize, gridValues, timestampValues): + pygame.init() + pygame.display.set_caption('Sudoku') + self.__engine = engine + self.__gridValues = gridValues + self.__timestampValues = timestampValues + self.__screen = pygame.display.set_mode(windowSize) + background = pygame.image.load(sys.path[0] + '/background.png').convert() + board = pygame.image.load(sys.path[0] + '/board.png') + boardX = boardY = 10 + self.__screen.blit(background, (0, 0)) + self.__screen.blit(board, (boardX, boardY)) + self.__tiles = self.__createTiles(boardX, boardY) + self.__drawUI() + self.__draw() + + def __draw(self): + """Handles events and updates display buffer""" + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: + self.__handleMouse(event.pos) + elif (event.type == pygame.KEYUP): + self.__handleKeyboard(event.key) + pygame.display.flip() + + def __drawUI(self): + '''Draws the text buttons along the right panel''' + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 28) + font.set_underline(True) + self.__titleText = font.render('Sudoku', 1, (0, 0, 0)) + self.__titleTextRect = self.__titleText.get_rect() + self.__titleTextRect.centerx = 445 + self.__titleTextRect.centery = 30 + self.__screen.blit(self.__titleText, self.__titleTextRect) + + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 14) + self.__titleText = font.render('TonyL 2019', 1, (0, 0, 0)) + self.__titleTextRect = self.__titleText.get_rect() + self.__titleTextRect.centerx = 445 + self.__titleTextRect.centery = 55 + self.__screen.blit(self.__titleText, self.__titleTextRect) + + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) + self.__newGameText = font.render('-New Game-', 1, (0, 0, 0)) + self.__newGameTextRect = self.__newGameText.get_rect() + self.__newGameTextRect.centerx = 495 + self.__newGameTextRect.centery = 180 + self.__screen.blit(self.__newGameText, self.__newGameTextRect) + + self.__solveText = font.render('-Check Balance-', 1, (0, 0, 0)) + self.__solveTextRect = self.__solveText.get_rect() + self.__solveTextRect.centerx = 495 + self.__solveTextRect.centery = 220 + self.__screen.blit(self.__solveText, self.__solveTextRect) + + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) + self.__checkText = font.render('-Check Solution-', 1, (0, 0, 0)) + self.__checkTextRect = self.__checkText.get_rect() + self.__checkTextRect.centerx = 495 + self.__checkTextRect.centery = 260 + self.__screen.blit(self.__checkText, self.__checkTextRect) + + def __handleKeyboard(self, key): + """Get key pressed and update the game board""" + validKeys = {pygame.K_0: "0", pygame.K_1: "1", pygame.K_2: "2", + pygame.K_3: "3", pygame.K_4: "4", pygame.K_5: "5", + pygame.K_6: "6", pygame.K_7: "7", pygame.K_8: "8", + pygame.K_9: "9", pygame.K_BACKSPACE: "", pygame.K_DELETE: ""} + if key == pygame.K_ESCAPE: + sys.exit() + elif key in validKeys: + i = self.__currentTile.getGridLoc()[0] + j = self.__currentTile.getGridLoc()[1] + cell_num = 9 * i + (j + 1) + self.__currentTile.setFontColor(pygame.color.THECOLORS['blue']) + self.__currentTile.updateValue(validKeys[key]) + self.__gridValues[i][j] = self.__currentTile.getValue() + self.__timestampValues[cell_num] = int(round(time.time())) + + def __handleMouse(self, (x, y)): + for row in self.__tiles: + for tile in row: + if tile.getRect().collidepoint(x, y): + if not tile.isReadOnly(): + tile.highlight(pygame.color.THECOLORS['lightyellow']) + if self.__currentTile.isCorrect(): + self.__currentTile.unhighlight() + else: + self.__currentTile.highlight((255, 164, 164)) + self.__currentTile = tile + if self.__newGameTextRect.collidepoint(x, y): + self.__engine.startNewGame() + elif self.__solveTextRect.collidepoint(x, y): + self.__engine.getSolution() + elif self.__checkTextRect.collidepoint(x, y): + ret = self.__engine.checkSolution(self.__gridValues, self.__timestampValues) + + def __updateBoard(self, gridValues): + for i in range(9): + for j in range(9): + self.__tiles[i][j].updateValue(gridValues[i][j]) + + def __unhightlightBoard(self): + for i in range(9): + for j in range(9): + self.__tiles[i][j].unhighlight() + + def __createTiles(self, initX=0, initY=0): + """Set up a list of tiles corresponding to the grid, along with + each ones location coordinates on the board""" + square_size = 40 + tiles = list() + x = y = 0 + for i in range(0, 9): + row = list() + for j in range(0, 9): + if j in (0, 1, 2): + x = (j * 41) + (initX + 2) + if j in (3, 4, 5): + x = (j * 41) + (initX + 6) + if j in (6, 7, 8): + x = (j * 41) + (initX + 10) + if i in (0, 1, 2): + y = (i * 41) + (initY + 2) + if i in (3, 4, 5): + y = (i * 41) + (initY + 6) + if i in (6, 7, 8): + y = (i * 41) + (initY + 10) + tile = Tile(self.__gridValues[i][j], (x, y), (i, j), square_size) + row.append(tile) + tiles.append(row) + self.__currentTile = tiles[0][0] + return tiles + + +class Tile(): + """Represents a graphical tile on the board""" + + def __init__(self, value, coords, gridLoc, size): + xpos = coords[0] + ypos = coords[1] + self.__fontColor = pygame.color.THECOLORS["black"] + self.__readOnly = False + self.__colorSquare = pygame.Surface((size, size)).convert() + self.__colorSquare.fill(pygame.color.THECOLORS['white'], None, pygame.BLEND_RGB_ADD) + self.__colorSquareRect = self.__colorSquare.get_rect() + self.__colorSquareRect = self.__colorSquareRect.move(xpos + 1, ypos + 1) + self.__value = value + self.__gridLoc = gridLoc + self.__screen = pygame.display.get_surface() + self.__rect = pygame.Rect(xpos, ypos, size, size) + self.__isCorrect = True + if self.__value is not '-': + self.__readOnly = True + self.__draw() + + def updateValue(self, value): + self.__value = value + self.__draw() + + def isCorrect(self): + return self.__isCorrect + + def setCorrect(self, isCorrect): + self.__isCorrect = isCorrect + + def setFontColor(self, fontColor): + self.__fontColor = fontColor + + def getValue(self): + return self.__value + + def getRect(self): + return self.__rect + + def getGridLoc(self): + return self.__gridLoc + + def isReadOnly(self): + return self.__readOnly + + def highlight(self, color): + if self.__readOnly is True: + return + self.__colorSquare.fill(color) + self.__draw() + + def unhighlight(self): + self.__colorSquare.fill((255, 225, 255), None, pygame.BLEND_RGB_ADD) + self.__draw() + + def __draw(self): + value = self.__value + if self.__value == '-': + value = '' + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) + text = font.render(str(value), 1, self.__fontColor) + textpos = text.get_rect() + textpos.centerx = self.__rect.centerx + textpos.centery = self.__rect.centery + self.__screen.blit(self.__colorSquare, self.__colorSquareRect) + self.__screen.blit(text, textpos) + + +class Sudoku: + """Represents the game's backend and logic""" + + def __init__(self, puzzleFile, rpc_connection): + self.__puzzleFile = puzzleFile + self.__rpc_connection = rpc_connection + self.startNewGame() + + def startNewGame(self): + self.__linePuzzle = self.__loadPuzzle(self.__puzzleFile) + gridValues = self.lineToGrid(self.__linePuzzle) + # prefill 0 timestamps for already known numbers + timestampValues = self.prefill_timestamps(gridValues) + board = PyGameBoard(self, (600, 400), gridValues, timestampValues) + board.setValues(gridValues) + + def __loadPuzzle(self, listName): + self.__chosen_puzzle = random.choice(listName) + puzzle = self.__rpc_connection.cclib("txidinfo", "17", '"%22' + self.__chosen_puzzle + '%22"')["unsolved"] + print "Puzzle ID: " + self.__chosen_puzzle + print "Reward amount: " + str(self.__rpc_connection.cclib("txidinfo", "17", '"%22' + self.__chosen_puzzle + '%22"')["amount"]) + ret = [] + linePuzzle = str(puzzle) + for i in linePuzzle: + ret.append(i) + return ret + + def gridToLine(self, grid): + linePuzzle = '' + for i in range(9): + for j in range(9): + linePuzzle += grid[i][j] + return linePuzzle + + def lineToGrid(self, linePuzzle): + assert (len(linePuzzle) == 81) + grid = [] + for i in xrange(0, 81, 9): + grid.append(linePuzzle[i:i + 9]) + return grid + + def getSolution(self): + balance = self.__rpc_connection.cclibaddress("17")["mybalance"] + print "Your balance: " + str(balance) + + def __solve(self, linePuzzle): + linePuzzle = ''.join(linePuzzle) + i = linePuzzle.find('-') + if i == -1: + return linePuzzle + + excluded_numbers = set() + for j in range(81): + if self.sameRow(i, j) or self.sameCol(i, j) or self.sameBlock(i, j): + excluded_numbers.add(linePuzzle[j]) + + for m in '123456789': + if m not in excluded_numbers: + funcRet = self.__solve(linePuzzle[:i] + m + linePuzzle[i + 1:]) + if funcRet is not None: + return funcRet + + def prefill_timestamps(self, grid): + timestamps = {} + for i in range(9): + for j in range(9): + if grid[i][j] != '-': + cell_num = 9 * i + ( j + 1 ) + timestamps[cell_num] = 0 + return timestamps + + def sameRow(self, i, j): + return (i / 9 == j / 9) + + def sameCol(self, i, j): + return (i - j) % 9 == 0 + + def sameBlock(self, i, j): + return (i / 27 == j / 27 and i % 9 / 3 == j % 9 / 3) + + def checkSolution(self, attemptGrid, timestampValues): + # [%22%22,%22%22,t0,t1,t2,...] + attemptLine = self.gridToLine(attemptGrid) + + #print attemptLine + #print timestampValues + timestampsline = "" + for timestamp in timestampValues.values(): + timestampsline += "," + timestampsline += str(timestamp) + arg_line = "[%22"+self.__chosen_puzzle+"%22,%22"+attemptLine+"%22"+timestampsline+"]" + print arg_line + try: + solution_info = self.__rpc_connection.cclib("solution", "17", '"' + arg_line + '"') + print solution_info + solution_txid = self.__rpc_connection.sendrawtransaction(solution_info["hex"]) + print "Solution accepted!" + print solution_txid + except Exception as e: + print(e) + print(solution_info) + solution_txid = 'error' + return solution_txid + +def main(): + while True: + # Assetchain hardcoded here + chain = 'SUDOKU' + try: + print 'Welcome to the Komodo SudokuCC' + rpc_connection = sudoku_kmdlib.def_credentials(chain) + pending_puzzles = rpc_connection.cclib("pending", "17")["pending"] + puzzle_list = [] + for puzzle in pending_puzzles: + puzzle_list.append(puzzle["txid"]) + + except Exception as e: + #print rpc_connection + print e + print 'Cant connect to SUDOKU Daemon! Please re-check if it up' + sys.exit() + else: + print 'Succesfully connected!\n' + break + newGame = Sudoku(puzzle_list, rpc_connection) + +if __name__ == '__main__': + main() diff --git a/src/gui/background.png b/src/gui/background.png new file mode 100644 index 0000000000000000000000000000000000000000..dc4844a0bfb7b2e023fb5b008c3ad35565277f6c GIT binary patch literal 308479 zcmV)XK&`)tP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L04^f{04^f|c%?sf00007bV*G`2igJ; z4iYxt0v?|L03ZNKL_t(|+I+o9&urOp9kyaOC-b}Y8UnH;*pLCb5k%9nVQ?bb19@P; zu&4eth6M|c`bqLw@Wh5;1B7R806`SN2IM2D_v+QXU*A9 zjO2P^j3}ib=Zsbdj@u2b7J%mO13*d%wN~`r(JGKqv}Zs>0D#sSa?bXB`rPz+JfBbG zoRM<|FaY9bbUQxyb9=|=9i~p?;{fgV|h7kBUf(Sw1hy1T!XZn}^_fpF8&pBsaKOtcBZug*TO+QoD zkG)S>EBYO^@_*CMZLI+TxZQ3b3V1voIF18j1jLZgTH)W10j*VFbi^3Y+CZQPU_h1| zN-4PAZgy<|?0Loz(A(Sxel5lrZ4K&r3?ayKhuj0%ynS7=zbg zYv_H*cMtosl#+eFK12VR`uue5>9d>rj^AzT-S#N}1bHZ}Hv|fxFt5M0h7=QkXzPmH z+R$~N@8AEW-|K%~_l91N{;qzO|4jdU{eJ_1>$-53Yu#lC+8iyiuB`WgEE0HD;<){s8O)_D&-pHJNHca&0q5p4a-yi< ztM12?60YmA>(^`3=TU3LEg$w-d>;TP0qE$h$!7tzRm7Cg`>;KlQnGi``-}l0MATYj z-5z$<_;}0z80|TuMl-AJ($CFws@0HsZQ0wQ=#eANp zJGi<9d0>Dfkkwj268JS(*T$Q+)(U{oTf>l_PcfpliVz|Qz&uyw;kC{W6$5q5gHjJE zznSy^@h`>>iU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ql|38#J`{+>DT8~x*i zFKqlhZNmd4+v^gB%Y#_18SYnapUVq;6= z{*ALz-dLH8KFXn;7k!L((Z~50eS(M4=wmc`8I68M2Rx0o^ELV`Z==!Q zX!JN5eU3)2ql@?*eU9hR=lLFu-bbVV(ddCR`XG&7NTVOp=!rD?B8}ciqd(H+Jd#GA zq$^7=`F1AHq|rBNnRn9YpEP^ay_7~jrE5#yB@N@1@Y_hkyNu*ojNfLm7$0nO zwH=SmR~pw{?faoL8rqjH;afdzcqn^3>=z{=%uKe+gR?S=;m5Jfy~7Q--yz}0rNc@m zvHG8kgFS?IeU*j&VivB&TK6hrl>w=24q0g-d5g04tL)!~NZ!Iw{=Xu5zj}jz*?%BuD!vIl4N@(XC02ewO6u-Xup)COLX0$&vY) zNsEyqSC4Y!{mI#lWcm=Xj3h@ro#cz&Xi0vspWws#Uk5x+M{m=Pjps)B-|W~o(>spM fQws>G1!SoO#Cs0hgHCntc;ACI+qZ4nckllP8pbT8 literal 0 HcmV?d00001 diff --git a/src/gui/komodoku/Sudoku.py b/src/gui/komodoku/Sudoku.py new file mode 100644 index 000000000..7b46d93fc --- /dev/null +++ b/src/gui/komodoku/Sudoku.py @@ -0,0 +1,362 @@ +#!/usr/bin/env python + +# Copyright (C) 2010 Paul Bourke +# Copyright (C) 2019 Anton Lysakov +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import pygame +import sys +import random +import sudoku_kmdlib +import time + +class PyGameBoard(): + """Represents the game's frontend using pygame""" + + def __init__(self, engine, windowSize, gridValues, timestampValues): + pygame.init() + pygame.display.set_caption('Sudoku') + self.__engine = engine + self.__gridValues = gridValues + self.__timestampValues = timestampValues + self.__screen = pygame.display.set_mode(windowSize) + background = pygame.image.load(sys.path[0] + '/background.png').convert() + board = pygame.image.load(sys.path[0] + '/board.png') + boardX = boardY = 10 + self.__screen.blit(background, (0, 0)) + self.__screen.blit(board, (boardX, boardY)) + self.__tiles = self.__createTiles(boardX, boardY) + self.__drawUI() + self.__draw() + + def __draw(self): + """Handles events and updates display buffer""" + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: + self.__handleMouse(event.pos) + elif (event.type == pygame.KEYUP): + self.__handleKeyboard(event.key) + pygame.display.flip() + + def __drawUI(self): + '''Draws the text buttons along the right panel''' + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 28) + font.set_underline(True) + self.__titleText = font.render('Sudoku', 1, (0, 0, 0)) + self.__titleTextRect = self.__titleText.get_rect() + self.__titleTextRect.centerx = 445 + self.__titleTextRect.centery = 30 + self.__screen.blit(self.__titleText, self.__titleTextRect) + + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 14) + self.__titleText = font.render('TonyL 2019', 1, (0, 0, 0)) + self.__titleTextRect = self.__titleText.get_rect() + self.__titleTextRect.centerx = 445 + self.__titleTextRect.centery = 55 + self.__screen.blit(self.__titleText, self.__titleTextRect) + + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) + self.__newGameText = font.render('-New Game-', 1, (0, 0, 0)) + self.__newGameTextRect = self.__newGameText.get_rect() + self.__newGameTextRect.centerx = 495 + self.__newGameTextRect.centery = 180 + self.__screen.blit(self.__newGameText, self.__newGameTextRect) + + self.__solveText = font.render('-Check Balance-', 1, (0, 0, 0)) + self.__solveTextRect = self.__solveText.get_rect() + self.__solveTextRect.centerx = 495 + self.__solveTextRect.centery = 220 + self.__screen.blit(self.__solveText, self.__solveTextRect) + + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) + self.__checkText = font.render('-Check Solution-', 1, (0, 0, 0)) + self.__checkTextRect = self.__checkText.get_rect() + self.__checkTextRect.centerx = 495 + self.__checkTextRect.centery = 260 + self.__screen.blit(self.__checkText, self.__checkTextRect) + + def __handleKeyboard(self, key): + """Get key pressed and update the game board""" + validKeys = {pygame.K_0: "0", pygame.K_1: "1", pygame.K_2: "2", + pygame.K_3: "3", pygame.K_4: "4", pygame.K_5: "5", + pygame.K_6: "6", pygame.K_7: "7", pygame.K_8: "8", + pygame.K_9: "9", pygame.K_BACKSPACE: "", pygame.K_DELETE: ""} + if key == pygame.K_ESCAPE: + sys.exit() + elif key in validKeys: + i = self.__currentTile.getGridLoc()[0] + j = self.__currentTile.getGridLoc()[1] + cell_num = 9 * i + (j + 1) + self.__currentTile.setFontColor(pygame.color.THECOLORS['blue']) + self.__currentTile.updateValue(validKeys[key]) + self.__gridValues[i][j] = self.__currentTile.getValue() + self.__timestampValues[cell_num] = int(round(time.time())) + + def __handleMouse(self, (x, y)): + for row in self.__tiles: + for tile in row: + if tile.getRect().collidepoint(x, y): + if not tile.isReadOnly(): + tile.highlight(pygame.color.THECOLORS['lightyellow']) + if self.__currentTile.isCorrect(): + self.__currentTile.unhighlight() + else: + self.__currentTile.highlight((255, 164, 164)) + self.__currentTile = tile + if self.__newGameTextRect.collidepoint(x, y): + self.__engine.startNewGame() + elif self.__solveTextRect.collidepoint(x, y): + self.__engine.getSolution() + elif self.__checkTextRect.collidepoint(x, y): + ret = self.__engine.checkSolution(self.__gridValues, self.__timestampValues) + + def __updateBoard(self, gridValues): + for i in range(9): + for j in range(9): + self.__tiles[i][j].updateValue(gridValues[i][j]) + + def __unhightlightBoard(self): + for i in range(9): + for j in range(9): + self.__tiles[i][j].unhighlight() + + def __createTiles(self, initX=0, initY=0): + """Set up a list of tiles corresponding to the grid, along with + each ones location coordinates on the board""" + square_size = 40 + tiles = list() + x = y = 0 + for i in range(0, 9): + row = list() + for j in range(0, 9): + if j in (0, 1, 2): + x = (j * 41) + (initX + 2) + if j in (3, 4, 5): + x = (j * 41) + (initX + 6) + if j in (6, 7, 8): + x = (j * 41) + (initX + 10) + if i in (0, 1, 2): + y = (i * 41) + (initY + 2) + if i in (3, 4, 5): + y = (i * 41) + (initY + 6) + if i in (6, 7, 8): + y = (i * 41) + (initY + 10) + tile = Tile(self.__gridValues[i][j], (x, y), (i, j), square_size) + row.append(tile) + tiles.append(row) + self.__currentTile = tiles[0][0] + return tiles + + +class Tile(): + """Represents a graphical tile on the board""" + + def __init__(self, value, coords, gridLoc, size): + xpos = coords[0] + ypos = coords[1] + self.__fontColor = pygame.color.THECOLORS["black"] + self.__readOnly = False + self.__colorSquare = pygame.Surface((size, size)).convert() + self.__colorSquare.fill(pygame.color.THECOLORS['white'], None, pygame.BLEND_RGB_ADD) + self.__colorSquareRect = self.__colorSquare.get_rect() + self.__colorSquareRect = self.__colorSquareRect.move(xpos + 1, ypos + 1) + self.__value = value + self.__gridLoc = gridLoc + self.__screen = pygame.display.get_surface() + self.__rect = pygame.Rect(xpos, ypos, size, size) + self.__isCorrect = True + if self.__value is not '-': + self.__readOnly = True + self.__draw() + + def updateValue(self, value): + self.__value = value + self.__draw() + + def isCorrect(self): + return self.__isCorrect + + def setCorrect(self, isCorrect): + self.__isCorrect = isCorrect + + def setFontColor(self, fontColor): + self.__fontColor = fontColor + + def getValue(self): + return self.__value + + def getRect(self): + return self.__rect + + def getGridLoc(self): + return self.__gridLoc + + def isReadOnly(self): + return self.__readOnly + + def highlight(self, color): + if self.__readOnly is True: + return + self.__colorSquare.fill(color) + self.__draw() + + def unhighlight(self): + self.__colorSquare.fill((255, 225, 255), None, pygame.BLEND_RGB_ADD) + self.__draw() + + def __draw(self): + value = self.__value + if self.__value == '-': + value = '' + font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) + text = font.render(str(value), 1, self.__fontColor) + textpos = text.get_rect() + textpos.centerx = self.__rect.centerx + textpos.centery = self.__rect.centery + self.__screen.blit(self.__colorSquare, self.__colorSquareRect) + self.__screen.blit(text, textpos) + + +class Sudoku: + """Represents the game's backend and logic""" + + def __init__(self, puzzleFile, rpc_connection): + self.__puzzleFile = puzzleFile + self.__rpc_connection = rpc_connection + self.startNewGame() + + def startNewGame(self): + self.__linePuzzle = self.__loadPuzzle(self.__puzzleFile) + gridValues = self.lineToGrid(self.__linePuzzle) + # prefill 0 timestamps for already known numbers + timestampValues = self.prefill_timestamps(gridValues) + board = PyGameBoard(self, (600, 400), gridValues, timestampValues) + board.setValues(gridValues) + + def __loadPuzzle(self, listName): + self.__chosen_puzzle = random.choice(listName) + puzzle = self.__rpc_connection.cclib("txidinfo", "17", '"%22' + self.__chosen_puzzle + '%22"')["unsolved"] + print "Puzzle ID: " + self.__chosen_puzzle + print "Reward amount: " + str(self.__rpc_connection.cclib("txidinfo", "17", '"%22' + self.__chosen_puzzle + '%22"')["amount"]) + ret = [] + linePuzzle = str(puzzle) + for i in linePuzzle: + ret.append(i) + return ret + + def gridToLine(self, grid): + linePuzzle = '' + for i in range(9): + for j in range(9): + linePuzzle += grid[i][j] + return linePuzzle + + def lineToGrid(self, linePuzzle): + assert (len(linePuzzle) == 81) + grid = [] + for i in xrange(0, 81, 9): + grid.append(linePuzzle[i:i + 9]) + return grid + + def getSolution(self): + balance = self.__rpc_connection.cclibaddress("17")["mybalance"] + print "Your balance: " + str(balance) + + def __solve(self, linePuzzle): + linePuzzle = ''.join(linePuzzle) + i = linePuzzle.find('-') + if i == -1: + return linePuzzle + + excluded_numbers = set() + for j in range(81): + if self.sameRow(i, j) or self.sameCol(i, j) or self.sameBlock(i, j): + excluded_numbers.add(linePuzzle[j]) + + for m in '123456789': + if m not in excluded_numbers: + funcRet = self.__solve(linePuzzle[:i] + m + linePuzzle[i + 1:]) + if funcRet is not None: + return funcRet + + def prefill_timestamps(self, grid): + timestamps = {} + for i in range(9): + for j in range(9): + if grid[i][j] != '-': + cell_num = 9 * i + ( j + 1 ) + timestamps[cell_num] = 0 + return timestamps + + def sameRow(self, i, j): + return (i / 9 == j / 9) + + def sameCol(self, i, j): + return (i - j) % 9 == 0 + + def sameBlock(self, i, j): + return (i / 27 == j / 27 and i % 9 / 3 == j % 9 / 3) + + def checkSolution(self, attemptGrid, timestampValues): + # [%22%22,%22%22,t0,t1,t2,...] + attemptLine = self.gridToLine(attemptGrid) + + #print attemptLine + #print timestampValues + timestampsline = "" + for timestamp in timestampValues.values(): + timestampsline += "," + timestampsline += str(timestamp) + arg_line = "[%22"+self.__chosen_puzzle+"%22,%22"+attemptLine+"%22"+timestampsline+"]" + print arg_line + try: + solution_info = self.__rpc_connection.cclib("solution", "17", '"' + arg_line + '"') + print solution_info + solution_txid = self.__rpc_connection.sendrawtransaction(solution_info["hex"]) + print "Solution accepted!" + print solution_txid + except Exception as e: + print(e) + print(solution_info) + solution_txid = 'error' + return solution_txid + +def main(): + while True: + # Assetchain hardcoded here + chain = 'SUDOKU' + try: + print 'Welcome to the Komodo SudokuCC' + rpc_connection = sudoku_kmdlib.def_credentials(chain) + pending_puzzles = rpc_connection.cclib("pending", "17")["pending"] + puzzle_list = [] + for puzzle in pending_puzzles: + puzzle_list.append(puzzle["txid"]) + + except Exception as e: + #print rpc_connection + print e + print 'Cant connect to SUDOKU Daemon! Please re-check if it up' + sys.exit() + else: + print 'Succesfully connected!\n' + break + newGame = Sudoku(puzzle_list, rpc_connection) + +if __name__ == '__main__': + main() diff --git a/src/gui/komodoku/background.png b/src/gui/komodoku/background.png new file mode 100644 index 0000000000000000000000000000000000000000..dc4844a0bfb7b2e023fb5b008c3ad35565277f6c GIT binary patch literal 308479 zcmV)XK&`)tP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L04^f{04^f|c%?sf00007bV*G`2igJ; z4iYxt0v?|L03ZNKL_t(|+I+o9&urOp9kyaOC-b}Y8UnH;*pLCb5k%9nVQ?bb19@P; zu&4eth6M|c`bqLw@Wh5;1B7R806`SN2IM2D_v+QXU*A9 zjO2P^j3}ib=Zsbdj@u2b7J%mO13*d%wN~`r(JGKqv}Zs>0D#sSa?bXB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diff --git a/src/gui/Sudoku.py b/src/gui/Sudoku.py deleted file mode 100644 index 7b46d93fc..000000000 --- a/src/gui/Sudoku.py +++ /dev/null @@ -1,362 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2010 Paul Bourke -# Copyright (C) 2019 Anton Lysakov -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import pygame -import sys -import random -import sudoku_kmdlib -import time - -class PyGameBoard(): - """Represents the game's frontend using pygame""" - - def __init__(self, engine, windowSize, gridValues, timestampValues): - pygame.init() - pygame.display.set_caption('Sudoku') - self.__engine = engine - self.__gridValues = gridValues - self.__timestampValues = timestampValues - self.__screen = pygame.display.set_mode(windowSize) - background = pygame.image.load(sys.path[0] + '/background.png').convert() - board = pygame.image.load(sys.path[0] + '/board.png') - boardX = boardY = 10 - self.__screen.blit(background, (0, 0)) - self.__screen.blit(board, (boardX, boardY)) - self.__tiles = self.__createTiles(boardX, boardY) - self.__drawUI() - self.__draw() - - def __draw(self): - """Handles events and updates display buffer""" - while True: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - sys.exit() - elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: - self.__handleMouse(event.pos) - elif (event.type == pygame.KEYUP): - self.__handleKeyboard(event.key) - pygame.display.flip() - - def __drawUI(self): - '''Draws the text buttons along the right panel''' - font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 28) - font.set_underline(True) - self.__titleText = font.render('Sudoku', 1, (0, 0, 0)) - self.__titleTextRect = self.__titleText.get_rect() - self.__titleTextRect.centerx = 445 - self.__titleTextRect.centery = 30 - self.__screen.blit(self.__titleText, self.__titleTextRect) - - font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 14) - self.__titleText = font.render('TonyL 2019', 1, (0, 0, 0)) - self.__titleTextRect = self.__titleText.get_rect() - self.__titleTextRect.centerx = 445 - self.__titleTextRect.centery = 55 - self.__screen.blit(self.__titleText, self.__titleTextRect) - - font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) - self.__newGameText = font.render('-New Game-', 1, (0, 0, 0)) - self.__newGameTextRect = self.__newGameText.get_rect() - self.__newGameTextRect.centerx = 495 - self.__newGameTextRect.centery = 180 - self.__screen.blit(self.__newGameText, self.__newGameTextRect) - - self.__solveText = font.render('-Check Balance-', 1, (0, 0, 0)) - self.__solveTextRect = self.__solveText.get_rect() - self.__solveTextRect.centerx = 495 - self.__solveTextRect.centery = 220 - self.__screen.blit(self.__solveText, self.__solveTextRect) - - font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) - self.__checkText = font.render('-Check Solution-', 1, (0, 0, 0)) - self.__checkTextRect = self.__checkText.get_rect() - self.__checkTextRect.centerx = 495 - self.__checkTextRect.centery = 260 - self.__screen.blit(self.__checkText, self.__checkTextRect) - - def __handleKeyboard(self, key): - """Get key pressed and update the game board""" - validKeys = {pygame.K_0: "0", pygame.K_1: "1", pygame.K_2: "2", - pygame.K_3: "3", pygame.K_4: "4", pygame.K_5: "5", - pygame.K_6: "6", pygame.K_7: "7", pygame.K_8: "8", - pygame.K_9: "9", pygame.K_BACKSPACE: "", pygame.K_DELETE: ""} - if key == pygame.K_ESCAPE: - sys.exit() - elif key in validKeys: - i = self.__currentTile.getGridLoc()[0] - j = self.__currentTile.getGridLoc()[1] - cell_num = 9 * i + (j + 1) - self.__currentTile.setFontColor(pygame.color.THECOLORS['blue']) - self.__currentTile.updateValue(validKeys[key]) - self.__gridValues[i][j] = self.__currentTile.getValue() - self.__timestampValues[cell_num] = int(round(time.time())) - - def __handleMouse(self, (x, y)): - for row in self.__tiles: - for tile in row: - if tile.getRect().collidepoint(x, y): - if not tile.isReadOnly(): - tile.highlight(pygame.color.THECOLORS['lightyellow']) - if self.__currentTile.isCorrect(): - self.__currentTile.unhighlight() - else: - self.__currentTile.highlight((255, 164, 164)) - self.__currentTile = tile - if self.__newGameTextRect.collidepoint(x, y): - self.__engine.startNewGame() - elif self.__solveTextRect.collidepoint(x, y): - self.__engine.getSolution() - elif self.__checkTextRect.collidepoint(x, y): - ret = self.__engine.checkSolution(self.__gridValues, self.__timestampValues) - - def __updateBoard(self, gridValues): - for i in range(9): - for j in range(9): - self.__tiles[i][j].updateValue(gridValues[i][j]) - - def __unhightlightBoard(self): - for i in range(9): - for j in range(9): - self.__tiles[i][j].unhighlight() - - def __createTiles(self, initX=0, initY=0): - """Set up a list of tiles corresponding to the grid, along with - each ones location coordinates on the board""" - square_size = 40 - tiles = list() - x = y = 0 - for i in range(0, 9): - row = list() - for j in range(0, 9): - if j in (0, 1, 2): - x = (j * 41) + (initX + 2) - if j in (3, 4, 5): - x = (j * 41) + (initX + 6) - if j in (6, 7, 8): - x = (j * 41) + (initX + 10) - if i in (0, 1, 2): - y = (i * 41) + (initY + 2) - if i in (3, 4, 5): - y = (i * 41) + (initY + 6) - if i in (6, 7, 8): - y = (i * 41) + (initY + 10) - tile = Tile(self.__gridValues[i][j], (x, y), (i, j), square_size) - row.append(tile) - tiles.append(row) - self.__currentTile = tiles[0][0] - return tiles - - -class Tile(): - """Represents a graphical tile on the board""" - - def __init__(self, value, coords, gridLoc, size): - xpos = coords[0] - ypos = coords[1] - self.__fontColor = pygame.color.THECOLORS["black"] - self.__readOnly = False - self.__colorSquare = pygame.Surface((size, size)).convert() - self.__colorSquare.fill(pygame.color.THECOLORS['white'], None, pygame.BLEND_RGB_ADD) - self.__colorSquareRect = self.__colorSquare.get_rect() - self.__colorSquareRect = self.__colorSquareRect.move(xpos + 1, ypos + 1) - self.__value = value - self.__gridLoc = gridLoc - self.__screen = pygame.display.get_surface() - self.__rect = pygame.Rect(xpos, ypos, size, size) - self.__isCorrect = True - if self.__value is not '-': - self.__readOnly = True - self.__draw() - - def updateValue(self, value): - self.__value = value - self.__draw() - - def isCorrect(self): - return self.__isCorrect - - def setCorrect(self, isCorrect): - self.__isCorrect = isCorrect - - def setFontColor(self, fontColor): - self.__fontColor = fontColor - - def getValue(self): - return self.__value - - def getRect(self): - return self.__rect - - def getGridLoc(self): - return self.__gridLoc - - def isReadOnly(self): - return self.__readOnly - - def highlight(self, color): - if self.__readOnly is True: - return - self.__colorSquare.fill(color) - self.__draw() - - def unhighlight(self): - self.__colorSquare.fill((255, 225, 255), None, pygame.BLEND_RGB_ADD) - self.__draw() - - def __draw(self): - value = self.__value - if self.__value == '-': - value = '' - font = pygame.font.Font(sys.path[0] + '/Roboto-Light.ttf', 24) - text = font.render(str(value), 1, self.__fontColor) - textpos = text.get_rect() - textpos.centerx = self.__rect.centerx - textpos.centery = self.__rect.centery - self.__screen.blit(self.__colorSquare, self.__colorSquareRect) - self.__screen.blit(text, textpos) - - -class Sudoku: - """Represents the game's backend and logic""" - - def __init__(self, puzzleFile, rpc_connection): - self.__puzzleFile = puzzleFile - self.__rpc_connection = rpc_connection - self.startNewGame() - - def startNewGame(self): - self.__linePuzzle = self.__loadPuzzle(self.__puzzleFile) - gridValues = self.lineToGrid(self.__linePuzzle) - # prefill 0 timestamps for already known numbers - timestampValues = self.prefill_timestamps(gridValues) - board = PyGameBoard(self, (600, 400), gridValues, timestampValues) - board.setValues(gridValues) - - def __loadPuzzle(self, listName): - self.__chosen_puzzle = random.choice(listName) - puzzle = self.__rpc_connection.cclib("txidinfo", "17", '"%22' + self.__chosen_puzzle + '%22"')["unsolved"] - print "Puzzle ID: " + self.__chosen_puzzle - print "Reward amount: " + str(self.__rpc_connection.cclib("txidinfo", "17", '"%22' + self.__chosen_puzzle + '%22"')["amount"]) - ret = [] - linePuzzle = str(puzzle) - for i in linePuzzle: - ret.append(i) - return ret - - def gridToLine(self, grid): - linePuzzle = '' - for i in range(9): - for j in range(9): - linePuzzle += grid[i][j] - return linePuzzle - - def lineToGrid(self, linePuzzle): - assert (len(linePuzzle) == 81) - grid = [] - for i in xrange(0, 81, 9): - grid.append(linePuzzle[i:i + 9]) - return grid - - def getSolution(self): - balance = self.__rpc_connection.cclibaddress("17")["mybalance"] - print "Your balance: " + str(balance) - - def __solve(self, linePuzzle): - linePuzzle = ''.join(linePuzzle) - i = linePuzzle.find('-') - if i == -1: - return linePuzzle - - excluded_numbers = set() - for j in range(81): - if self.sameRow(i, j) or self.sameCol(i, j) or self.sameBlock(i, j): - excluded_numbers.add(linePuzzle[j]) - - for m in '123456789': - if m not in excluded_numbers: - funcRet = self.__solve(linePuzzle[:i] + m + linePuzzle[i + 1:]) - if funcRet is not None: - return funcRet - - def prefill_timestamps(self, grid): - timestamps = {} - for i in range(9): - for j in range(9): - if grid[i][j] != '-': - cell_num = 9 * i + ( j + 1 ) - timestamps[cell_num] = 0 - return timestamps - - def sameRow(self, i, j): - return (i / 9 == j / 9) - - def sameCol(self, i, j): - return (i - j) % 9 == 0 - - def sameBlock(self, i, j): - return (i / 27 == j / 27 and i % 9 / 3 == j % 9 / 3) - - def checkSolution(self, attemptGrid, timestampValues): - # [%22%22,%22%22,t0,t1,t2,...] - attemptLine = self.gridToLine(attemptGrid) - - #print attemptLine - #print timestampValues - timestampsline = "" - for timestamp in timestampValues.values(): - timestampsline += "," - timestampsline += str(timestamp) - arg_line = "[%22"+self.__chosen_puzzle+"%22,%22"+attemptLine+"%22"+timestampsline+"]" - print arg_line - try: - solution_info = self.__rpc_connection.cclib("solution", "17", '"' + arg_line + '"') - print solution_info - solution_txid = self.__rpc_connection.sendrawtransaction(solution_info["hex"]) - print "Solution accepted!" - print solution_txid - except Exception as e: - print(e) - print(solution_info) - solution_txid = 'error' - return solution_txid - -def main(): - while True: - # Assetchain hardcoded here - chain = 'SUDOKU' - try: - print 'Welcome to the Komodo SudokuCC' - rpc_connection = sudoku_kmdlib.def_credentials(chain) - pending_puzzles = rpc_connection.cclib("pending", "17")["pending"] - puzzle_list = [] - for puzzle in pending_puzzles: - puzzle_list.append(puzzle["txid"]) - - except Exception as e: - #print rpc_connection - print e - print 'Cant connect to SUDOKU Daemon! Please re-check if it up' - sys.exit() - else: - print 'Succesfully connected!\n' - break - newGame = Sudoku(puzzle_list, rpc_connection) - -if __name__ == '__main__': - main() diff --git a/src/gui/background.png b/src/gui/background.png deleted file mode 100644 index dc4844a0bfb7b2e023fb5b008c3ad35565277f6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 308479 zcmV)XK&`)tP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L04^f{04^f|c%?sf00007bV*G`2igJ; z4iYxt0v?|L03ZNKL_t(|+I+o9&urOp9kyaOC-b}Y8UnH;*pLCb5k%9nVQ?bb19@P; zu&4eth6M|c`bqLw@Wh5;1B7R806`SN2IM2D_v+QXU*A9 zjO2P^j3}ib=Zsbdj@u2b7J%mO13*d%wN~`r(JGKqv}Zs>0D#sSa?bXB`rPz+JfBbG zoRM<|FaY9bbUQxyb9=|=9i~p?;{fgV|h7kBUf(Sw1hy1T!XZn}^_fpF8&pBsaKOtcBZug*TO+QoD zkG)S>EBYO^@_*CMZLI+TxZQ3b3V1voIF18j1jLZgTH)W10j*VFbi^3Y+CZQPU_h1| zN-4PAZgy<|?0Loz(A(Sxel5lrZ4K&r3?ayKhuj0%ynS7=zbg zYv_H*cMtosl#+eFK12VR`uue5>9d>rj^AzT-S#N}1bHZ}Hv|fxFt5M0h7=QkXzPmH z+R$~N@8AEW-|K%~_l91N{;qzO|4jdU{eJ_1>$-53Yu#lC+8iyiuB`WgEE0HD;<){s8O)_D&-pHJNHca&0q5p4a-yi< ztM12?60YmA>(^`3=TU3LEg$w-d>;TP0qE$h$!7tzRm7Cg`>;KlQnGi``-}l0MATYj z-5z$<_;}0z80|TuMl-AJ($CFws@0HsZQ0wQ=#eANp zJGi<9d0>Dfkkwj268JS(*T$Q+)(U{oTf>l_PcfpliVz|Qz&uyw;kC{W6$5q5gH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#$Ix$1({ejFW4u6*op0a%;LL?>+nx@@p>r)&XTJA| zA3xq%)))QGADce=DM0CXZ>X)Y=gO~-jd@+}*?Cd@!6&xkL5gu`aUmCOY0)J?aYpBr z^Oj@J80QEsu%88KFeNqOM5l6`ec$g`Dvc&7w}GQ|*o$iY&a?1;b(zLKby!Tk00000 LNkvXXu0mjfL3yYq diff --git a/src/gui/board.png b/src/gui/board.png deleted file mode 100644 index bd77ca419999b45f31af1dc6e91aedd4b0f53a9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5678 zcmeAS@N?(olHy`uVBq!ia0y~yV5|jU4mP03i^?5=K#C>Z(btiI;o6NW{t-q%zGR7O zL`iUdT1k0gQ7VIDN`6wRf@f}GdTLN=VoGJ<$y6H#2GIkaE{-7;w~|s45`LUF;Bq^t zA;G#h!G)oLAxVn2DG(xJ$)L~>k~F@M{Q-MU|kN+74koMTY6Tl7ztmwLMJ)o!OKl^U$ z_Acp(KNlC;OMPGb(5mQ>955ZVmqSZM7DiyHsQbko(uWx3jfTYH1W+nSVtMp`@j+w+V|BDHrVGdyBIgycp zse|>{kN^MeA1_$HP(t!Qe_1)7sJYT-Q19TK`{B|jM{I$qitjzNR2=QlI_X`4raI^*LDqz40|2~awwXxSpWxo89ZJ6T-G@yGywpilHk$+ diff --git a/src/gui/sudoku_kmdlib.py b/src/gui/sudoku_kmdlib.py deleted file mode 100644 index a2b2aa239..000000000 --- a/src/gui/sudoku_kmdlib.py +++ /dev/null @@ -1,41 +0,0 @@ -import platform -import os -import re -import random -from slickrpc import Proxy - - -# define function that fetchs rpc creds from .conf -def def_credentials(chain): - rpcport =''; - operating_system = platform.system() - if operating_system == 'Darwin': - ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' - elif operating_system == 'Linux': - ac_dir = os.environ['HOME'] + '/.komodo' - elif operating_system == 'Windows': - ac_dir = '%s/komodo/' % os.environ['APPDATA'] - if chain == 'KMD': - coin_config_file = str(ac_dir + '/komodo.conf') - else: - coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') - with open(coin_config_file, 'r') as f: - for line in f: - l = line.rstrip() - if re.search('rpcuser', l): - rpcuser = l.replace('rpcuser=', '') - elif re.search('rpcpassword', l): - rpcpassword = l.replace('rpcpassword=', '') - elif re.search('rpcport', l): - rpcport = l.replace('rpcport=', '') - if len(rpcport) == 0: - if chain == 'KMD': - rpcport = 7771 - else: - print("rpcport not in conf file, exiting") - print("check "+coin_config_file) - exit(1) - - return(Proxy("http://%s:%s@127.0.0.1:%d"%(rpcuser, rpcpassword, int(rpcport)))) - - From c8fcf61bb781174e2cc5f960a304570f9ed08df4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 09:49:47 -1100 Subject: [PATCH 3454/3904] +comments --- src/komodo_gateway.h | 88 +++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 58054feba..3669f29c0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1548,10 +1548,11 @@ void komodo_passport_iteration() } } -extern std::vector Mineropret; -#define PRICES_MAXCHANGE (COIN / 100) -#define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) +extern std::vector Mineropret; // opreturn data set by the data gathering code +#define PRICES_MAXCHANGE (COIN / 100) // maximum acceptable change, set at 1% +#define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR +// komodo_heightpricebits() extracts the price data in the coinbase for nHeight int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) { CBlockIndex *pindex; CBlock block; CTransaction tx; int32_t numvouts; std::vector vopret; @@ -1562,7 +1563,7 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) tx = block.vtx[0]; numvouts = (int32_t)tx.vout.size(); GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); - if ( vopret.size() == PRICES_SIZEBIT0 ) + if ( vopret.size() >= PRICES_SIZEBIT0 ) { memcpy(prevbits,&vopret[0],PRICES_SIZEBIT0); return(0); @@ -1573,34 +1574,47 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) return(-1); } -uint32_t komodo_pricenew(uint32_t price,uint32_t refprice,int64_t tolerance) +/* + komodo_pricenew() is passed in a reference price, the change tolerance and the proposed price. it needs to return a clipped price if it is too big and also set a flag if it is at or above the limit + */ +uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int64_t tolerance) { uint32_t highprice,lowprice; - highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; - lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; - //fprintf(stderr,"%.4f -> (%.4f %.4f)\n",(double)price/10000,(double)lowprice/10000,(double)highprice/10000); - if ( price > highprice ) - return(highprice); - else if ( price < lowprice ) - return(lowprice); + highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; // calc highest acceptable price + lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; // and lowest + if ( price >= highprice ) + { + *maxflagp = 1; + if ( price > highprice ) // return non-zero only if we violate the tolerance + return(highprice); + } + else if ( price <= lowprice ) + { + *maxflagp = 1; + if ( price < lowprice ) + return(lowprice); + } else return(0); } -int32_t komodo_pricecmp(uint32_t pricebitsA[4],uint32_t pricebitsB[4],int64_t tolerance) +// komodo_pricecmp() returns -1 if any of the prices are beyond the tolerance +int32_t komodo_pricecmp(int32_t *maxflagp,uint32_t pricebitsA[4],uint32_t pricebitsB[4],int64_t tolerance) { int32_t i; + *maxflagp = 0; for (i=1; i<4; i++) - if ( komodo_pricenew(pricebitsA[i],pricebitsB[i],tolerance) != 0 ) + if ( komodo_pricenew(maxflagp,pricebitsA[i],pricebitsB[i],tolerance) != 0 ) return(-1); return(0); } +// komodo_priceclamp() clamps any price that is beyond tolerance int32_t komodo_priceclamp(uint32_t pricebits[4],uint32_t refprices[4],int64_t tolerance) { - int32_t i; uint32_t newprice; + int32_t i,maxflag = 0; uint32_t newprice; for (i=1; i<4; i++) { - if ( (newprice= komodo_pricenew(pricebits[i],refprices[i],tolerance)) != 0 ) + if ( (newprice= komodo_pricenew(&maxflagp,pricebits[i],refprices[i],tolerance)) != 0 ) { fprintf(stderr,"priceclamped[%d] %u -> %u\n",i,pricebits[i],newprice); pricebits[i] = newprice; @@ -1609,16 +1623,18 @@ int32_t komodo_priceclamp(uint32_t pricebits[4],uint32_t refprices[4],int64_t to return(0); } +// komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight CScript komodo_mineropret(int32_t nHeight) { - CScript opret; uint32_t pricebits[4],prevbits[4]; - if ( Mineropret.size() == PRICES_SIZEBIT0 ) + CScript opret; uint32_t pricebits[4],prevbits[4]; int32_t maxflag; + if ( Mineropret.size() >= PRICES_SIZEBIT0 ) { if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { memcpy(pricebits,&Mineropret[0],PRICES_SIZEBIT0); - if ( komodo_pricecmp(pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { + // if the new prices are not within tolerance, update Mineropret with clipped prices komodo_priceclamp(pricebits,prevbits,PRICES_MAXCHANGE); fprintf(stderr,"update Mineropret to clamped prices\n"); memcpy(&Mineropret[0],pricebits,PRICES_SIZEBIT0); @@ -1629,13 +1645,21 @@ CScript komodo_mineropret(int32_t nHeight) return(opret); } +/* + komodo_opretvalidate() is the entire price validation! + it prints out some useful info for debugging, like the lag from current time and prev block and the prices encoded in the opreturn. + + The only way komodo_opretvalidate() doesnt return an error is if maxflag is set or it is within tolerance of both the prior block and the local data. The local data validation only happens if it is a recent block and not a block from the past as the local node is only getting the current price data. + + */ + int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; uint32_t pricebits[4],prevbits[4]; int32_t i,lag,lag2; + std::vector vopret; uint32_t pricebits[4],prevbits[4]; int32_t i,lag,lag2,maxflag=0; if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() == PRICES_SIZEBIT0 ) + if ( vopret.size() >= PRICES_SIZEBIT0 ) { memcpy(pricebits,&vopret[0],PRICES_SIZEBIT0); lag = (int32_t)(time(NULL) - pricebits[0]); @@ -1643,20 +1667,20 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) lag = -lag; lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); - if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() == PRICES_SIZEBIT0 ) - { - memcpy(prevbits,&Mineropret[0],PRICES_SIZEBIT0); - if ( komodo_pricecmp(pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) - return(-1); - } if ( nHeight > 1 ) { if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - if ( komodo_pricecmp(pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) return(-1); } else return(-1); } + if ( maxflag == 0 && lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) + { + memcpy(prevbits,&Mineropret[0],PRICES_SIZEBIT0); + if ( komodo_pricecmp(&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + return(-1); + } return(0); } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)PRICES_SIZEBIT0,(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); @@ -1664,6 +1688,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) return(0); } +// get_urljson just returns the JSON returned by the URL using issue_curl + #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) cJSON *get_urljson(char *url) @@ -1678,6 +1704,8 @@ cJSON *get_urljson(char *url) return(json); } +// parse the coindesk specific data. yes, if this changes, it will require an update. However, regardless if the format from the data source changes, then the code that extracts it must be changed. One way to mitigate this is to have a large variety of data sources so that there is only a very remote chance that all of them are not available. Certainly the data gathering needs to be made more robust, but it doesnt really affect the proof of concept for the decentralized trustless oracle. The trustlessness is achieved by having all nodes get the oracle data. + int32_t get_btcusd(uint32_t pricebits[4]) { cJSON *pjson,*bpi,*obj; char str[512]; uint64_t btcusd = 0,btcgbp = 0,btceur = 0; @@ -1709,6 +1737,7 @@ int32_t get_btcusd(uint32_t pricebits[4]) return(-1); } +// komodo_cbopretupdate() obtains the external price data and encodes it into Mineropret, which will then be used by the miner and validation void komodo_cbopretupdate() { uint32_t pricebits[4]; @@ -1716,7 +1745,7 @@ void komodo_cbopretupdate() { if ( get_btcusd(pricebits) == 0 ) { - if ( Mineropret.size() != PRICES_SIZEBIT0 ) + if ( Mineropret.size() < PRICES_SIZEBIT0 ) Mineropret.resize(PRICES_SIZEBIT0); memcpy(&Mineropret[0],pricebits,PRICES_SIZEBIT0); //int32_t i; for (i=0; i Date: Thu, 28 Mar 2019 09:51:08 -1100 Subject: [PATCH 3455/3904] Maxflag --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3669f29c0..b7bfa9bd5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1614,7 +1614,7 @@ int32_t komodo_priceclamp(uint32_t pricebits[4],uint32_t refprices[4],int64_t to int32_t i,maxflag = 0; uint32_t newprice; for (i=1; i<4; i++) { - if ( (newprice= komodo_pricenew(&maxflagp,pricebits[i],refprices[i],tolerance)) != 0 ) + if ( (newprice= komodo_pricenew(&maxflag,pricebits[i],refprices[i],tolerance)) != 0 ) { fprintf(stderr,"priceclamped[%d] %u -> %u\n",i,pricebits[i],newprice); pricebits[i] = newprice; From b7f15dd8b3365907d944b4cc4dfdb73cefc39bc4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 10:22:29 -1100 Subject: [PATCH 3456/3904] Local validation of limit move --- src/komodo_gateway.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b7bfa9bd5..868c639d8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1590,7 +1590,7 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 } else if ( price <= lowprice ) { - *maxflagp = 1; + *maxflagp = -1; if ( price < lowprice ) return(lowprice); } @@ -1655,7 +1655,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; uint32_t pricebits[4],prevbits[4]; int32_t i,lag,lag2,maxflag=0; + std::vector vopret; uint32_t localbits[4],pricebits[4],prevbits[4],newprice; int32_t i,lag,lag2,maxflag=0; if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1675,11 +1675,29 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) return(-1); } else return(-1); } - if ( maxflag == 0 && lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) + if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) { - memcpy(prevbits,&Mineropret[0],PRICES_SIZEBIT0); - if ( komodo_pricecmp(&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) - return(-1); + memcpy(localbits,&Mineropret[0],PRICES_SIZEBIT0); + if ( maxflag == 0 ) + { + if ( komodo_pricecmp(&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) + return(-1); + } + else + { + for (i=1; i<4; i++) + { + maxflag = 0; + if ( (newprice= komodo_pricenew(maxflag,pricebits[i],prevbits[i],PRICES_MAXCHANGE)) != 0 ) // proposed price is clamped + { + // make sure local price is beyond clamped + if ( maxflag > 0 && localbits[i] < pricebits[i] ) + return(-1); + else if ( maxflag < 0 && localbits[i] > pricebits[i] ) + return(-1); + } + } + } } return(0); } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)PRICES_SIZEBIT0,(int32_t)scriptPubKey.size(),scriptPubKey[0]); From c7a0e8562d134b90697722b8bba473422cd5c101 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Mar 2019 10:23:24 -1100 Subject: [PATCH 3457/3904] & --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 868c639d8..6a9afd473 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1688,7 +1688,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) for (i=1; i<4; i++) { maxflag = 0; - if ( (newprice= komodo_pricenew(maxflag,pricebits[i],prevbits[i],PRICES_MAXCHANGE)) != 0 ) // proposed price is clamped + if ( (newprice= komodo_pricenew(&maxflag,pricebits[i],prevbits[i],PRICES_MAXCHANGE)) != 0 ) // proposed price is clamped { // make sure local price is beyond clamped if ( maxflag > 0 && localbits[i] < pricebits[i] ) From a3bbaaef9b57a74e42500e275e016bdabfd220e4 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 29 Mar 2019 07:44:41 +0700 Subject: [PATCH 3458/3904] tetris tweaks --- src/tui/lib/tuilib.py | 79 ++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/src/tui/lib/tuilib.py b/src/tui/lib/tuilib.py index da1d7658a..9a2fed639 100755 --- a/src/tui/lib/tuilib.py +++ b/src/tui/lib/tuilib.py @@ -7,6 +7,7 @@ import pickle import platform import os import subprocess +import random import signal from slickrpc import Proxy from binascii import hexlify @@ -1044,34 +1045,41 @@ def print_multiplayer_games_list(rpc_connection): def rogue_newgame_singleplayer(rpc_connection, is_game_a_rogue=True): try: - new_game_txid = rpc_connection.cclib("newgame", "17", "[1]")["txid"] - print("New singleplayer training game succesfully created. txid: " + new_game_txid) - while True: - mempool = rpc_connection.getrawmempool() - if new_game_txid in mempool: - print(colorize("Waiting for game transaction to be mined", "blue")) - time.sleep(5) - else: - print(colorize("Game transaction is mined", "green")) - break - players_list = rogue_players_list(rpc_connection) - if len(players_list["playerdata"]) > 0: - print_players_list(rpc_connection) + if is_game_a_rogue: + new_game_txid = rpc_connection.cclib("newgame", "17", "[1]")["txid"] + print("New singleplayer training game succesfully created. txid: " + new_game_txid) while True: - is_choice_needed = input("Do you want to choose a player for this game? [y/n] ") - if is_choice_needed == "y": - player_txid = input("Please input player txid: ") - newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid, player_txid)["txid"] - break - elif is_choice_needed == "n": - set_warriors_name(rpc_connection) - newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid)["txid"] - break + mempool = rpc_connection.getrawmempool() + if new_game_txid in mempool: + print(colorize("Waiting for game transaction to be mined", "blue")) + time.sleep(5) else: - print("Please choose y or n !") + print(colorize("Game transaction is mined", "green")) + break + else: + pending_games = rpc_connection.cclib("pending", "17")["pending"] + new_game_txid = random.choice(pending_games) + if is_game_a_rogue: + players_list = rogue_players_list(rpc_connection) + if len(players_list["playerdata"]) > 0: + print_players_list(rpc_connection) + while True: + is_choice_needed = input("Do you want to choose a player for this game? [y/n] ") + if is_choice_needed == "y": + player_txid = input("Please input player txid: ") + newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid, player_txid)["txid"] + break + elif is_choice_needed == "n": + set_warriors_name(rpc_connection) + newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid)["txid"] + break + else: + print("Please choose y or n !") + else: + print("No players available to select") + input("Press [Enter] to continue...") + newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid)["txid"] else: - print("No players available to select") - input("Press [Enter] to continue...") newgame_regisration_txid = rogue_game_register(rpc_connection, new_game_txid)["txid"] while True: mempool = rpc_connection.getrawmempool() @@ -1143,7 +1151,7 @@ def rogue_newgame_singleplayer(rpc_connection, is_game_a_rogue=True): print("Let's wait a little bit more") time.sleep(5) pass - if confirmations_amount < 2: + if confirmations_amount < 1: print("Last keystroke not confirmed yet! Let's wait a little") time.sleep(10) else: @@ -1163,15 +1171,16 @@ def rogue_newgame_singleplayer(rpc_connection, is_game_a_rogue=True): is_bailout_needed = input("Do you want to make bailout now [y] or wait for one more block [n]? [y/n]: ") if is_bailout_needed == "y": bailout_info = rogue_bailout(rpc_connection, new_game_txid) - while True: - try: - confirmations_amount = rpc_connection.getrawtransaction(bailout_info["txid"], 1)["confirmations"] - break - except Exception as e: - print(e) - print("Bailout not on blockchain yet. Let's wait a little bit more") - time.sleep(20) - pass + if is_game_a_rogue: + while True: + try: + confirmations_amount = rpc_connection.getrawtransaction(bailout_info["txid"], 1)["confirmations"] + break + except Exception as e: + print(e) + print("Bailout not on blockchain yet. Let's wait a little bit more") + time.sleep(20) + pass break elif is_bailout_needed == "n": game_end_height = int(rpc_connection.getinfo()["blocks"]) From aee4b6ec2b7dafc2a44de1fd31ae852d9e3c1130 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:25:55 -1100 Subject: [PATCH 3459/3904] alphadvantage api --- src/komodo_gateway.h | 101 +++++++++++++++++++++++++++++++++++++++++-- src/komodo_utils.h | 2 +- 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6a9afd473..5f235ee63 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1631,13 +1631,13 @@ CScript komodo_mineropret(int32_t nHeight) { if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - memcpy(pricebits,&Mineropret[0],PRICES_SIZEBIT0); + memcpy(pricebits,Mineropret.data(),PRICES_SIZEBIT0); if ( komodo_pricecmp(&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { // if the new prices are not within tolerance, update Mineropret with clipped prices komodo_priceclamp(pricebits,prevbits,PRICES_MAXCHANGE); fprintf(stderr,"update Mineropret to clamped prices\n"); - memcpy(&Mineropret[0],pricebits,PRICES_SIZEBIT0); + memcpy(Mineropret.data(),pricebits,PRICES_SIZEBIT0); } } return(opret << OP_RETURN << Mineropret); @@ -1677,7 +1677,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) } if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) { - memcpy(localbits,&Mineropret[0],PRICES_SIZEBIT0); + memcpy(localbits,Mineropret.data(),PRICES_SIZEBIT0); if ( maxflag == 0 ) { if ( komodo_pricecmp(&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) @@ -1709,6 +1709,19 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) // get_urljson just returns the JSON returned by the URL using issue_curl #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) +char *Cryptos[] = { "KMD", "BTC", "ETH", "LTC", "BCH", "XMR", "IOTA", "DASH", "XTZ", "XEM", "ZEC", "WAVES", "DOGE", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "DGB", "STEEM", "ENJ", "STRAT", "VEO" }; + +char *ForexMajor[] = { "USD", "EUR", "JPY", "GBP", "AUD", "CHF", "CNY", "RUB" }; + +char *ForexMinor[] = { "CAD", "NZD", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "UAH", "AED", "SAR" }; + +char *Metals[] = { "XAU", "XAG", "XPT", "XPD", }; + +char *Markets[] = { "DJIA", "SPX", "NDX", "VIX" }; + +char *Techstocks[] = +{ "AAPL","ADBE","ADSK","AKAM","AMD","AMZN","ATVI","BB","CDW","CRM","CSCO","CYBR","DBX","EA","FB","GDDY","GOOG","GRMN","GSAT","HPQ","IBM","INFY","INTC","INTU","JNPR","MSFT","MSI","MU","MXL","NATI","NCR","NFLX","NTAP","NVDA","ORCL","PANW","PYPL","QCOM","RHT","S","SHOP","SNAP","SPOT","SYMC","SYNA","T","TRIP","TWTR","TXN","VMW","VOD","VRSN","VZ","WDC","XRX","YELP","YNDX","ZEN" +}; cJSON *get_urljson(char *url) { @@ -1722,6 +1735,61 @@ cJSON *get_urljson(char *url) return(json); } +uint32_t get_stockprice(char *symbol) +{ + char url[512]; cJSON *json,*obj; uint32_t high,low,price = 0; + sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + if ( (json= get_urljson(url)) != 0 ) + { + if ( (obj= jobj(jitem(json,"Time Series (15min)"),0)) != 0 ) + { + high = jdouble(jitem(obj,0),"2. high")*10000 + 0.000049; + low = jdouble(jitem(obj,0),"3. low")*10000 + 0.000049; + price = (high + low) / 2; + } + free_json(json); + } + return(price); +} + +uint32_t get_currencyprice(char *symbol) +{ + char url[512]; cJSON *json,*obj; uint32_t price = 0; + sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + if ( (json= get_urljson(url)) != 0 ) + { + if ( (obj= jobj(jitem(json,0),0)) != 0 ) + price = jdouble(obj,"5. Exchange Rate")*10000 + 0.000049; + free_json(json); + } + return(price); +} + +int32_t get_currencies(char *list[],int32_t n) +{ + int32_t i,errs=0; uint32_t price; + for (i=0; i Date: Fri, 29 Mar 2019 01:27:32 -1100 Subject: [PATCH 3460/3904] Test --- src/komodo_gateway.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5f235ee63..d37927af2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1741,10 +1741,10 @@ uint32_t get_stockprice(char *symbol) sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); if ( (json= get_urljson(url)) != 0 ) { - if ( (obj= jobj(jitem(json,"Time Series (15min)"),0)) != 0 ) + if ( (obj= jobj(jitem(json,(char *)"Time Series (15min)"),0)) != 0 ) { - high = jdouble(jitem(obj,0),"2. high")*10000 + 0.000049; - low = jdouble(jitem(obj,0),"3. low")*10000 + 0.000049; + high = jdouble(jitem(obj,0),(char *)"2. high")*10000 + 0.000049; + low = jdouble(jitem(obj,0),(char *)"3. low")*10000 + 0.000049; price = (high + low) / 2; } free_json(json); @@ -1759,7 +1759,7 @@ uint32_t get_currencyprice(char *symbol) if ( (json= get_urljson(url)) != 0 ) { if ( (obj= jobj(jitem(json,0),0)) != 0 ) - price = jdouble(obj,"5. Exchange Rate")*10000 + 0.000049; + price = jdouble(obj,(char *)"5. Exchange Rate")*10000 + 0.000049; free_json(json); } return(price); @@ -1839,6 +1839,7 @@ void komodo_cbopretupdate() // fprintf(stderr,"%02x",Mineropret[i]); //fprintf(stderr," <- set Mineropret[%d]\n",(int32_t)Mineropret.size()); } +ASSETCHAINS_CBOPRET = 0xff; if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { get_currencies(Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); From 888282a9f9e676954184bc273f4a2899ba23ab13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:28:40 -1100 Subject: [PATCH 3461/3904] const --- src/komodo_gateway.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d37927af2..18f54c961 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1709,17 +1709,17 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) // get_urljson just returns the JSON returned by the URL using issue_curl #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) -char *Cryptos[] = { "KMD", "BTC", "ETH", "LTC", "BCH", "XMR", "IOTA", "DASH", "XTZ", "XEM", "ZEC", "WAVES", "DOGE", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "DGB", "STEEM", "ENJ", "STRAT", "VEO" }; +const char *Cryptos[] = { "KMD", "BTC", "ETH", "LTC", "BCH", "XMR", "IOTA", "DASH", "XTZ", "XEM", "ZEC", "WAVES", "DOGE", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "DGB", "STEEM", "ENJ", "STRAT", "VEO" }; -char *ForexMajor[] = { "USD", "EUR", "JPY", "GBP", "AUD", "CHF", "CNY", "RUB" }; +const char *ForexMajor[] = { "USD", "EUR", "JPY", "GBP", "AUD", "CHF", "CNY", "RUB" }; -char *ForexMinor[] = { "CAD", "NZD", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "UAH", "AED", "SAR" }; +const char *ForexMinor[] = { "CAD", "NZD", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "UAH", "AED", "SAR" }; -char *Metals[] = { "XAU", "XAG", "XPT", "XPD", }; +const char *Metals[] = { "XAU", "XAG", "XPT", "XPD", }; -char *Markets[] = { "DJIA", "SPX", "NDX", "VIX" }; +const char *Markets[] = { "DJIA", "SPX", "NDX", "VIX" }; -char *Techstocks[] = +const char *Techstocks[] = { "AAPL","ADBE","ADSK","AKAM","AMD","AMZN","ATVI","BB","CDW","CRM","CSCO","CYBR","DBX","EA","FB","GDDY","GOOG","GRMN","GSAT","HPQ","IBM","INFY","INTC","INTU","JNPR","MSFT","MSI","MU","MXL","NATI","NCR","NFLX","NTAP","NVDA","ORCL","PANW","PYPL","QCOM","RHT","S","SHOP","SNAP","SPOT","SYMC","SYNA","T","TRIP","TWTR","TXN","VMW","VOD","VRSN","VZ","WDC","XRX","YELP","YNDX","ZEN" }; From 338c0392744e438fad6eecf91f35b562f80b18c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:30:16 -1100 Subject: [PATCH 3462/3904] Obj Derek --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 18f54c961..673774be7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1741,7 +1741,7 @@ uint32_t get_stockprice(char *symbol) sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); if ( (json= get_urljson(url)) != 0 ) { - if ( (obj= jobj(jitem(json,(char *)"Time Series (15min)"),0)) != 0 ) + if ( (obj= jobj(json,(char *)"Time Series (15min)")) != 0 ) { high = jdouble(jitem(obj,0),(char *)"2. high")*10000 + 0.000049; low = jdouble(jitem(obj,0),(char *)"3. low")*10000 + 0.000049; From 8cfcf57ae3de24ece5c5573a5f6135312bf82e52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:31:12 -1100 Subject: [PATCH 3463/3904] Const --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 673774be7..328df66dc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1765,7 +1765,7 @@ uint32_t get_currencyprice(char *symbol) return(price); } -int32_t get_currencies(char *list[],int32_t n) +int32_t get_currencies(const char *list[],int32_t n) { int32_t i,errs=0; uint32_t price; for (i=0; i Date: Fri, 29 Mar 2019 01:32:07 -1100 Subject: [PATCH 3464/3904] Const --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 328df66dc..b26d8bb9b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1735,7 +1735,7 @@ cJSON *get_urljson(char *url) return(json); } -uint32_t get_stockprice(char *symbol) +uint32_t get_stockprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t high,low,price = 0; sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); @@ -1752,7 +1752,7 @@ uint32_t get_stockprice(char *symbol) return(price); } -uint32_t get_currencyprice(char *symbol) +uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); From 8d6cc79729ebd57f8c62d30df03a36db4aedb344 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:34:19 -1100 Subject: [PATCH 3465/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b26d8bb9b..265458e4d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1728,7 +1728,7 @@ cJSON *get_urljson(char *url) char *jsonstr; cJSON *json = 0; if ( (jsonstr= issue_curl(url)) != 0 ) { - //fprintf(stderr,"(%s) -> (%s)\n",url,jsonstr); + fprintf(stderr,"(%s) -> (%s)\n",url,jsonstr); json = cJSON_Parse(jsonstr); free(jsonstr); } @@ -1839,7 +1839,7 @@ void komodo_cbopretupdate() // fprintf(stderr,"%02x",Mineropret[i]); //fprintf(stderr," <- set Mineropret[%d]\n",(int32_t)Mineropret.size()); } -ASSETCHAINS_CBOPRET = 0xff; +ASSETCHAINS_CBOPRET = 5; if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { get_currencies(Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); From b2fade3af5114e9cf786db056d47f06ee283a55b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:36:54 -1100 Subject: [PATCH 3466/3904] +print --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 265458e4d..8777eb602 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1738,7 +1738,7 @@ cJSON *get_urljson(char *url) uint32_t get_stockprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t high,low,price = 0; - sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + sprintf(url,"http://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); if ( (json= get_urljson(url)) != 0 ) { if ( (obj= jobj(json,(char *)"Time Series (15min)")) != 0 ) @@ -1755,7 +1755,8 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; - sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + sprintf(url,"http://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + fprintf(stderr,"issue (%s)\n",url); if ( (json= get_urljson(url)) != 0 ) { if ( (obj= jobj(jitem(json,0),0)) != 0 ) From 99f2cd9bd9388f5bb288b1c591b439d6bf5a9f00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:39:19 -1100 Subject: [PATCH 3467/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8777eb602..b0eed88b0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1755,7 +1755,7 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; - sprintf(url,"http://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + sprintf(url,"http://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); fprintf(stderr,"issue (%s)\n",url); if ( (json= get_urljson(url)) != 0 ) { From 751251b1f110ccaaacfe1ff57a6e5cd8841fbfc1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:41:12 -1100 Subject: [PATCH 3468/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b0eed88b0..a0eac269b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1738,7 +1738,7 @@ cJSON *get_urljson(char *url) uint32_t get_stockprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t high,low,price = 0; - sprintf(url,"http://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); if ( (json= get_urljson(url)) != 0 ) { if ( (obj= jobj(json,(char *)"Time Series (15min)")) != 0 ) @@ -1755,7 +1755,7 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; - sprintf(url,"http://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); + sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); fprintf(stderr,"issue (%s)\n",url); if ( (json= get_urljson(url)) != 0 ) { From d5d5169310a7d37a390efc575916d4f48cda5982 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:45:28 -1100 Subject: [PATCH 3469/3904] Test --- src/komodo_bitcoind.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e76da09ec..5834a1f5e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -182,6 +182,7 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char * if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 ) specialcase = 1; else specialcase = 0; +specialcase = 1; if ( url[0] == 0 ) strcpy(url,"http://127.0.0.1:7876/nxt"); if ( specialcase != 0 && 0 ) @@ -247,13 +248,13 @@ try_again: numretries++; if ( specialcase != 0 ) { - printf("<<<<<<<<<<< bitcoind_RPC.(%s): BTCD.%s timeout params.(%s) s.ptr.(%s) err.%d\n",url,command,params,s.ptr,res); + fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC.(%s): BTCD.%s timeout params.(%s) s.ptr.(%s) err.%d\n",url,command,params,s.ptr,res); free(s.ptr); return(0); } else if ( numretries >= 1 ) { - //printf("Maximum number of retries exceeded!\n"); + fprintf(stderr,"Maximum number of retries exceeded!\n"); free(s.ptr); return(0); } From 10de70008ce9b644cf40a45bbf8ec81633c687c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:51:52 -1100 Subject: [PATCH 3470/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a0eac269b..5d3326efb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1755,7 +1755,7 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; - sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); + sprintf(url,"http://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); fprintf(stderr,"issue (%s)\n",url); if ( (json= get_urljson(url)) != 0 ) { From b8e28e6e7d7f64d76dfa112cb3beab4506df15ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:55:57 -1100 Subject: [PATCH 3471/3904] Useragent --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5834a1f5e..6fd5767a2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -195,7 +195,7 @@ try_again: init_string(&s); headers = curl_slist_append(0,"Expect:"); - curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; )");//"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5d3326efb..a0eac269b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1755,7 +1755,7 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; - sprintf(url,"http://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); + sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); fprintf(stderr,"issue (%s)\n",url); if ( (json= get_urljson(url)) != 0 ) { From 2420161fc83dd232c50ad0ccfb1a35df835e323b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 01:58:57 -1100 Subject: [PATCH 3472/3904] Test --- src/komodo_bitcoind.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6fd5767a2..20062c588 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -195,8 +195,9 @@ try_again: init_string(&s); headers = curl_slist_append(0,"Expect:"); - curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; )");//"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); - curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); + if ( headers != 0 ) + curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback From cdd520ef6095f99505f751ce38c23e86f04baf1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:03:10 -1100 Subject: [PATCH 3473/3904] curl_easy_setopt --- src/komodo_bitcoind.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 20062c588..a16d6d7ed 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -203,6 +203,8 @@ try_again: curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback + curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + if ( strncmp(url,"https",5) == 0 ) { curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,0); From cd66407853ff4f685d2a8402b6fbc757a3dc675f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:04:42 -1100 Subject: [PATCH 3474/3904] curl_easy_setopt --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a16d6d7ed..aa757f47e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -203,7 +203,8 @@ try_again: curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback - curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + //curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, 3); if ( strncmp(url,"https",5) == 0 ) { From aa21c5314967e3d2f0b802441e671d40a24b085d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:07:13 -1100 Subject: [PATCH 3475/3904] Test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index aa757f47e..300a33a63 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -204,7 +204,7 @@ try_again: curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback //curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); - curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, 3); + curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, 1); if ( strncmp(url,"https",5) == 0 ) { From b793b800276084eee6b67fa2462535873992c290 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:08:42 -1100 Subject: [PATCH 3476/3904] V2 --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 300a33a63..e4c6139de 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -204,7 +204,7 @@ try_again: curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback //curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); - curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, 1); + curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, 2); if ( strncmp(url,"https",5) == 0 ) { From cd196766ca70b3695052a7c3a640aab0442ae5d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:10:49 -1100 Subject: [PATCH 3477/3904] Test --- src/komodo_bitcoind.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e4c6139de..b5bc7d634 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -196,15 +196,14 @@ try_again: headers = curl_slist_append(0,"Expect:"); curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); - if ( headers != 0 ) - curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); + //curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback //curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); - curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, 2); + //curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, 2); if ( strncmp(url,"https",5) == 0 ) { From cd78a331b83a30d86f68ca058186ab2a60a13c2f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:21:39 -1100 Subject: [PATCH 3478/3904] Test --- src/komodo_bitcoind.h | 3 +- src/komodo_gateway.h | 93 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b5bc7d634..38f9041c1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -182,7 +182,6 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char * if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 ) specialcase = 1; else specialcase = 0; -specialcase = 1; if ( url[0] == 0 ) strcpy(url,"http://127.0.0.1:7876/nxt"); if ( specialcase != 0 && 0 ) @@ -196,7 +195,7 @@ try_again: headers = curl_slist_append(0,"Expect:"); curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); - //curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a0eac269b..7a002abbe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1706,6 +1706,94 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) return(0); } +char *nonportable_path(char *str) +{ + int32_t i; + for (i=0; str[i]!=0; i++) + if ( str[i] == '/' ) + str[i] = '\\'; + return(str); +} + +char *portable_path(char *str) +{ +#ifdef _WIN32 + return(nonportable_path(str)); +#else +#ifdef __PNACL + /*int32_t i,n; + if ( str[0] == '/' ) + return(str); + else + { + n = (int32_t)strlen(str); + for (i=n; i>0; i--) + str[i] = str[i-1]; + str[0] = '/'; + str[n+1] = 0; + }*/ +#endif + return(str); +#endif +} + +void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) +{ + FILE *fp; + long filesize,buflen = *allocsizep; + uint8_t *buf = *bufp; + *lenp = 0; + if ( (fp= fopen(portable_path(fname),"rb")) != 0 ) + { + fseek(fp,0,SEEK_END); + filesize = ftell(fp); + if ( filesize == 0 ) + { + fclose(fp); + *lenp = 0; + //printf("loadfile null size.(%s)\n",fname); + return(0); + } + if ( filesize > buflen ) + { + *allocsizep = filesize; + *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); + } + rewind(fp); + if ( buf == 0 ) + printf("Null buf ???\n"); + else + { + if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) + printf("error reading filesize.%ld\n",(long)filesize); + buf[filesize] = 0; + } + fclose(fp); + *lenp = filesize; + //printf("loaded.(%s)\n",buf); + } //else printf("OS_loadfile couldnt load.(%s)\n",fname); + return(buf); +} + +void *filestr(long *allocsizep,char *_fname) +{ + long filesize = 0; char *fname,*buf = 0; void *retptr; + *allocsizep = 0; + fname = malloc(strlen(_fname)+1); + strcpy(fname,_fname); + retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); + free(fname); + return(retptr); +} + +char *send_curl(char *url,char *fname) +{ + long fsize; char curlstr[1024]; + sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); + system(curlstr); + return(filestr(&fsize,fname)); +} + // get_urljson just returns the JSON returned by the URL using issue_curl #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) @@ -1755,9 +1843,8 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; - sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,"D0185MGYVTIW0G6H");//NOTARY_PUBKEY.data()+50); - fprintf(stderr,"issue (%s)\n",url); - if ( (json= get_urljson(url)) != 0 ) + sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + if ( (json= send_curl(url,"curldata")) != 0 )//get_urljson(url)) != 0 ) { if ( (obj= jobj(jitem(json,0),0)) != 0 ) price = jdouble(obj,(char *)"5. Exchange Rate")*10000 + 0.000049; From 5e0ab6bf2ab852e608771f06866fb6c50337df85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:24:21 -1100 Subject: [PATCH 3479/3904] Test --- src/komodo_gateway.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7a002abbe..e019a9d68 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1779,19 +1779,26 @@ void *filestr(long *allocsizep,char *_fname) { long filesize = 0; char *fname,*buf = 0; void *retptr; *allocsizep = 0; - fname = malloc(strlen(_fname)+1); + fname = (char *)malloc(strlen(_fname)+1); strcpy(fname,_fname); retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); free(fname); return(retptr); } -char *send_curl(char *url,char *fname) +cJSON *send_curl(char *url,char *fname) { - long fsize; char curlstr[1024]; + long fsize; char curlstr[1024],*jsonstr; cJSON *json=0; sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); - system(curlstr); - return(filestr(&fsize,fname)); + if ( system(curlstr) == 0 ) + { + if ( (jsonstr= filestr((void *)&fsize,fname)) != 0 ) + { + json = cJSON_Parse(jsonstr); + free(jsonstr); + } + } + return(json); } // get_urljson just returns the JSON returned by the URL using issue_curl From 894593a1c9928eb97ac84b1faf033f58001c1c9d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:26:01 -1100 Subject: [PATCH 3480/3904] Curl data --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e019a9d68..ca924a770 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1792,7 +1792,7 @@ cJSON *send_curl(char *url,char *fname) sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); if ( system(curlstr) == 0 ) { - if ( (jsonstr= filestr((void *)&fsize,fname)) != 0 ) + if ( (jsonstr= (char *)filestr((long *)&fsize,fname)) != 0 ) { json = cJSON_Parse(jsonstr); free(jsonstr); @@ -1851,7 +1851,7 @@ uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; sprintf(url,"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=%s&to_currency=USD&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); - if ( (json= send_curl(url,"curldata")) != 0 )//get_urljson(url)) != 0 ) + if ( (json= send_curl(url,(char *)"curldata")) != 0 )//get_urljson(url)) != 0 ) { if ( (obj= jobj(jitem(json,0),0)) != 0 ) price = jdouble(obj,(char *)"5. Exchange Rate")*10000 + 0.000049; From 10f6aa68908bb106cdf1096f51107c1a381fc5b6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 02:38:08 -1100 Subject: [PATCH 3481/3904] get_dailyfx --- src/komodo_gateway.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ca924a770..4dcefd217 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1847,6 +1847,17 @@ uint32_t get_stockprice(const char *symbol) return(price); } +uint32_t get_dailyfx() +{ + char url[512]; cJSON *json; uint32_t datenum=0,price = 0; + sprintf(url,"https://api.exchangeratesapi.io/latest"); + if ( (json= get_urljson(url)) != 0 ) + { + free_json(json); + } + return(datenum); +} + uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; @@ -1934,7 +1945,7 @@ void komodo_cbopretupdate() // fprintf(stderr,"%02x",Mineropret[i]); //fprintf(stderr," <- set Mineropret[%d]\n",(int32_t)Mineropret.size()); } -ASSETCHAINS_CBOPRET = 5; + get_dailyfx(); if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { get_currencies(Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); From 9547e334a15de98b64b50892d00830c5a4cd6681 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:07:06 -1100 Subject: [PATCH 3482/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4dcefd217..61c04c34b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1850,7 +1850,7 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_dailyfx() { char url[512]; cJSON *json; uint32_t datenum=0,price = 0; - sprintf(url,"https://api.exchangeratesapi.io/latest"); + sprintf(url,"http://api.openrates.io/latest");//http://api.exchangeratesapi.io/latest"); if ( (json= get_urljson(url)) != 0 ) { free_json(json); From 829c399f1ff33f0e55c5251b2ca8b78f6afbc1af Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:09:50 -1100 Subject: [PATCH 3483/3904] Test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 61c04c34b..8952e7df7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1850,8 +1850,9 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_dailyfx() { char url[512]; cJSON *json; uint32_t datenum=0,price = 0; - sprintf(url,"http://api.openrates.io/latest");//http://api.exchangeratesapi.io/latest"); - if ( (json= get_urljson(url)) != 0 ) + sprintf(url,"http://api.openrates.io/latest"); + if ( (json= send_curl(url,(char *)"curldata")) != 0 )//get_urljson(url)) != 0 ) + //if ( (json= get_urljson(url)) != 0 ) { free_json(json); } From 76f2e11e4734778239ce7be3ba8da2b1c7af85da Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:12:09 -1100 Subject: [PATCH 3484/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8952e7df7..9b72327f5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1789,7 +1789,7 @@ void *filestr(long *allocsizep,char *_fname) cJSON *send_curl(char *url,char *fname) { long fsize; char curlstr[1024],*jsonstr; cJSON *json=0; - sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); + sprintf(curlstr,"wget \"%s\" > %s",url,fname); if ( system(curlstr) == 0 ) { if ( (jsonstr= (char *)filestr((long *)&fsize,fname)) != 0 ) From b4d66481d86b2282ec2c4a738acb561a2b26095f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:16:04 -1100 Subject: [PATCH 3485/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9b72327f5..163e680d3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1789,7 +1789,7 @@ void *filestr(long *allocsizep,char *_fname) cJSON *send_curl(char *url,char *fname) { long fsize; char curlstr[1024],*jsonstr; cJSON *json=0; - sprintf(curlstr,"wget \"%s\" > %s",url,fname); + sprintf(curlstr,"wget -q \"%s\" -O %s",url,fname); if ( system(curlstr) == 0 ) { if ( (jsonstr= (char *)filestr((long *)&fsize,fname)) != 0 ) From 7d9ed2dcf12ea52a9b14d2228f78966f03c3ea23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:34:48 -1100 Subject: [PATCH 3486/3904] Test --- src/komodo_gateway.h | 49 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 163e680d3..05ea4ba05 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1850,15 +1850,39 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_dailyfx() { char url[512]; cJSON *json; uint32_t datenum=0,price = 0; - sprintf(url,"http://api.openrates.io/latest"); - if ( (json= send_curl(url,(char *)"curldata")) != 0 )//get_urljson(url)) != 0 ) - //if ( (json= get_urljson(url)) != 0 ) + sprintf(url,"http://api.openrates.io/latest?base=USD"); + if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { free_json(json); } return(datenum); } +uint32_t get_binanceprice(const char *symbol) +{ + char url[512]; cJSON *json; uint32_t price = 0; + sprintf(url,"https://api.binance.com/api/v1/ticker/price?symbol=%sBTC",symbol); + if ( (json= get_urljson(url)) != 0 ) + { + price = jdouble(json,(char *)"price")*SATOSHIDEN + 0.0000000049; + free_json(json); + } + return(price); +} + +int32_t get_cryptoprices(const char *list[],int32_t n) +{ + int32_t i,errs=0; uint32_t price; + for (i=0; i Date: Fri, 29 Mar 2019 03:35:52 -1100 Subject: [PATCH 3487/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 05ea4ba05..2a1b6fdeb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1961,7 +1961,7 @@ void komodo_cbopretupdate() get_cryptoprices(Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); if ( (counter % 300) == 0 ) get_dailyfx(); - if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) + /*if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { get_currencies(Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); } @@ -1984,7 +1984,7 @@ void komodo_cbopretupdate() if ( (ASSETCHAINS_CBOPRET & 64) != 0 ) { get_stocks(Techstocks,(int32_t)(sizeof(Techstocks)/sizeof(*Techstocks))); - } + }*/ } counter++; } From cfcfea00e44152ba21e07c0266d57d25f779abde Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:38:25 -1100 Subject: [PATCH 3488/3904] Test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2a1b6fdeb..a50b79819 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1862,11 +1862,12 @@ uint32_t get_binanceprice(const char *symbol) { char url[512]; cJSON *json; uint32_t price = 0; sprintf(url,"https://api.binance.com/api/v1/ticker/price?symbol=%sBTC",symbol); - if ( (json= get_urljson(url)) != 0 ) + if ( (json= issue_curl(url,(char *)"bnbprice")) != 0 ) { price = jdouble(json,(char *)"price")*SATOSHIDEN + 0.0000000049; free_json(json); } + usleep(100000); return(price); } From de144ec34e57dc93da79481967f61a5e5c7a28e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:39:15 -1100 Subject: [PATCH 3489/3904] send_curl --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a50b79819..d0ccf4f5f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1862,7 +1862,7 @@ uint32_t get_binanceprice(const char *symbol) { char url[512]; cJSON *json; uint32_t price = 0; sprintf(url,"https://api.binance.com/api/v1/ticker/price?symbol=%sBTC",symbol); - if ( (json= issue_curl(url,(char *)"bnbprice")) != 0 ) + if ( (json= send_curl(url,(char *)"bnbprice")) != 0 ) { price = jdouble(json,(char *)"price")*SATOSHIDEN + 0.0000000049; free_json(json); From 5511751b6a9eca8b8ba6a4101fb36cb27f870aac Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:41:26 -1100 Subject: [PATCH 3490/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d0ccf4f5f..f95551407 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1878,7 +1878,7 @@ int32_t get_cryptoprices(const char *list[],int32_t n) { if ( (price= get_binanceprice(list[i])) == 0 ) errs++; - else fprintf(stderr,"(%s %.4f) ",list[i],(double)price/10000); + fprintf(stderr,"(%s %.8f) ",list[i],(double)price/SATOSHIDEN); } fprintf(stderr," errs.%d\n",errs); return(-errs); From 3dacf07fe3069a67f2dbe7deb7116a644a9871b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:46:14 -1100 Subject: [PATCH 3491/3904] Test --- src/komodo_gateway.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f95551407..d60bc037f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1804,11 +1804,7 @@ cJSON *send_curl(char *url,char *fname) // get_urljson just returns the JSON returned by the URL using issue_curl #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) -const char *Cryptos[] = { "KMD", "BTC", "ETH", "LTC", "BCH", "XMR", "IOTA", "DASH", "XTZ", "XEM", "ZEC", "WAVES", "DOGE", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "DGB", "STEEM", "ENJ", "STRAT", "VEO" }; - -const char *ForexMajor[] = { "USD", "EUR", "JPY", "GBP", "AUD", "CHF", "CNY", "RUB" }; - -const char *ForexMinor[] = { "CAD", "NZD", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "UAH", "AED", "SAR" }; +const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "DASH", "XEM", "ZEC", "WAVES", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" }; const char *Metals[] = { "XAU", "XAG", "XPT", "XPD", }; From fea8ac8afd96a77e78eb6b24173f96d1ed43bcd9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:46:40 -1100 Subject: [PATCH 3492/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d60bc037f..898477215 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1819,7 +1819,7 @@ cJSON *get_urljson(char *url) char *jsonstr; cJSON *json = 0; if ( (jsonstr= issue_curl(url)) != 0 ) { - fprintf(stderr,"(%s) -> (%s)\n",url,jsonstr); + //fprintf(stderr,"(%s) -> (%s)\n",url,jsonstr); json = cJSON_Parse(jsonstr); free(jsonstr); } From de3d5538f3580cfce086ffbe6378e91693543990 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 03:53:47 -1100 Subject: [PATCH 3493/3904] Test --- src/komodo_gateway.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 898477215..704084221 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1845,10 +1845,22 @@ uint32_t get_stockprice(const char *symbol) uint32_t get_dailyfx() { - char url[512]; cJSON *json; uint32_t datenum=0,price = 0; + //{"base":"USD","rates":{"BGN":1.74344803,"NZD":1.471652701,"ILS":3.6329113924,"RUB":65.1997682296,"CAD":1.3430201462,"USD":1.0,"PHP":52.8641469068,"CHF":0.9970582992,"AUD":1.4129078267,"JPY":110.6792654662,"TRY":5.6523444464,"HKD":7.8499732573,"MYR":4.0824567659,"HRK":6.6232840078,"CZK":22.9862720628,"IDR":14267.4986628633,"DKK":6.6551078624,"NOK":8.6806917454,"HUF":285.131039401,"GBP":0.7626582278,"MXN":19.4183455161,"THB":31.8702085933,"ISK":122.5708682475,"ZAR":14.7033339276,"BRL":3.9750401141,"SGD":1.3573720806,"PLN":3.8286682118,"INR":69.33187734,"KRW":1139.1602781244,"RON":4.2423783206,"CNY":6.7387234801,"SEK":9.3385630237,"EUR":0.8914244963},"date":"2019-03-28"} + char url[512],*datestr; cJSON *json,*rates; int32_t i,n; uint32_t datenum=0,price = 0; sprintf(url,"http://api.openrates.io/latest?base=USD"); if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { + if ( (rates= jobj(json,"rates")) != 0 && (n= cJSON_GetObjectSize()) > 0 ) + { + for (i=0; i Date: Fri, 29 Mar 2019 03:54:59 -1100 Subject: [PATCH 3494/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 704084221..774450c72 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1850,7 +1850,7 @@ uint32_t get_dailyfx() sprintf(url,"http://api.openrates.io/latest?base=USD"); if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { - if ( (rates= jobj(json,"rates")) != 0 && (n= cJSON_GetObjectSize()) > 0 ) + if ( (rates= jobj(json,(char *)"rates")) != 0 && (n= cJSON_GetArraySize()) > 0 ) { for (i=0; i Date: Fri, 29 Mar 2019 03:55:54 -1100 Subject: [PATCH 3495/3904] Rates --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 774450c72..17e971535 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1850,7 +1850,7 @@ uint32_t get_dailyfx() sprintf(url,"http://api.openrates.io/latest?base=USD"); if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { - if ( (rates= jobj(json,(char *)"rates")) != 0 && (n= cJSON_GetArraySize()) > 0 ) + if ( (rates= jobj(json,(char *)"rates")) != 0 && (n= cJSON_GetArraySize(rates)) > 0 ) { for (i=0; i Date: Fri, 29 Mar 2019 03:59:08 -1100 Subject: [PATCH 3496/3904] +print --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 17e971535..d2d98d91e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1794,6 +1794,7 @@ cJSON *send_curl(char *url,char *fname) { if ( (jsonstr= (char *)filestr((long *)&fsize,fname)) != 0 ) { + fprintf(stderr,"[%s]\n",jsonstr); json = cJSON_Parse(jsonstr); free(jsonstr); } @@ -1848,8 +1849,10 @@ uint32_t get_dailyfx() //{"base":"USD","rates":{"BGN":1.74344803,"NZD":1.471652701,"ILS":3.6329113924,"RUB":65.1997682296,"CAD":1.3430201462,"USD":1.0,"PHP":52.8641469068,"CHF":0.9970582992,"AUD":1.4129078267,"JPY":110.6792654662,"TRY":5.6523444464,"HKD":7.8499732573,"MYR":4.0824567659,"HRK":6.6232840078,"CZK":22.9862720628,"IDR":14267.4986628633,"DKK":6.6551078624,"NOK":8.6806917454,"HUF":285.131039401,"GBP":0.7626582278,"MXN":19.4183455161,"THB":31.8702085933,"ISK":122.5708682475,"ZAR":14.7033339276,"BRL":3.9750401141,"SGD":1.3573720806,"PLN":3.8286682118,"INR":69.33187734,"KRW":1139.1602781244,"RON":4.2423783206,"CNY":6.7387234801,"SEK":9.3385630237,"EUR":0.8914244963},"date":"2019-03-28"} char url[512],*datestr; cJSON *json,*rates; int32_t i,n; uint32_t datenum=0,price = 0; sprintf(url,"http://api.openrates.io/latest?base=USD"); + fprintf(stderr,"dailfx\n"); if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { + fprintf(stderr,"(%s)\n",jprint(json,0)); if ( (rates= jobj(json,(char *)"rates")) != 0 && (n= cJSON_GetArraySize(rates)) > 0 ) { for (i=0; i Date: Fri, 29 Mar 2019 04:03:14 -1100 Subject: [PATCH 3497/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d2d98d91e..1a5a9a3ea 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1970,8 +1970,8 @@ void komodo_cbopretupdate() // fprintf(stderr,"%02x",Mineropret[i]); //fprintf(stderr," <- set Mineropret[%d]\n",(int32_t)Mineropret.size()); } - get_cryptoprices(Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); - if ( (counter % 300) == 0 ) + //get_cryptoprices(Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); + //if ( (counter % 300) == 0 ) get_dailyfx(); /*if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { From 7051bf44a8227e9e7d6b1483108e2e7d8e07cbd0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 04:06:42 -1100 Subject: [PATCH 3498/3904] Https --- src/komodo_gateway.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1a5a9a3ea..dbee7f803 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1848,8 +1848,7 @@ uint32_t get_dailyfx() { //{"base":"USD","rates":{"BGN":1.74344803,"NZD":1.471652701,"ILS":3.6329113924,"RUB":65.1997682296,"CAD":1.3430201462,"USD":1.0,"PHP":52.8641469068,"CHF":0.9970582992,"AUD":1.4129078267,"JPY":110.6792654662,"TRY":5.6523444464,"HKD":7.8499732573,"MYR":4.0824567659,"HRK":6.6232840078,"CZK":22.9862720628,"IDR":14267.4986628633,"DKK":6.6551078624,"NOK":8.6806917454,"HUF":285.131039401,"GBP":0.7626582278,"MXN":19.4183455161,"THB":31.8702085933,"ISK":122.5708682475,"ZAR":14.7033339276,"BRL":3.9750401141,"SGD":1.3573720806,"PLN":3.8286682118,"INR":69.33187734,"KRW":1139.1602781244,"RON":4.2423783206,"CNY":6.7387234801,"SEK":9.3385630237,"EUR":0.8914244963},"date":"2019-03-28"} char url[512],*datestr; cJSON *json,*rates; int32_t i,n; uint32_t datenum=0,price = 0; - sprintf(url,"http://api.openrates.io/latest?base=USD"); - fprintf(stderr,"dailfx\n"); + sprintf(url,"https://api.openrates.io/latest?base=USD"); if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { fprintf(stderr,"(%s)\n",jprint(json,0)); From 9645cf2e19bc9888c7c3360eab607551ab80db86 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 04:14:37 -1100 Subject: [PATCH 3499/3904] Test --- src/komodo_gateway.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dbee7f803..719b3894e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1794,7 +1794,6 @@ cJSON *send_curl(char *url,char *fname) { if ( (jsonstr= (char *)filestr((long *)&fsize,fname)) != 0 ) { - fprintf(stderr,"[%s]\n",jsonstr); json = cJSON_Parse(jsonstr); free(jsonstr); } @@ -1811,6 +1810,10 @@ const char *Metals[] = { "XAU", "XAG", "XPT", "XPD", }; const char *Markets[] = { "DJIA", "SPX", "NDX", "VIX" }; +const char *Forex[] = +{ "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" +}; + const char *Techstocks[] = { "AAPL","ADBE","ADSK","AKAM","AMD","AMZN","ATVI","BB","CDW","CRM","CSCO","CYBR","DBX","EA","FB","GDDY","GOOG","GRMN","GSAT","HPQ","IBM","INFY","INTC","INTU","JNPR","MSFT","MSI","MU","MXL","NATI","NCR","NFLX","NTAP","NVDA","ORCL","PANW","PYPL","QCOM","RHT","S","SHOP","SNAP","SPOT","SYMC","SYNA","T","TRIP","TWTR","TXN","VMW","VOD","VRSN","VZ","WDC","XRX","YELP","YNDX","ZEN" }; @@ -1851,18 +1854,17 @@ uint32_t get_dailyfx() sprintf(url,"https://api.openrates.io/latest?base=USD"); if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { - fprintf(stderr,"(%s)\n",jprint(json,0)); - if ( (rates= jobj(json,(char *)"rates")) != 0 && (n= cJSON_GetArraySize(rates)) > 0 ) + if ( (rates= jobj(json,(char *)"rates")) != 0 ) { - for (i=0; i Date: Fri, 29 Mar 2019 04:15:58 -1100 Subject: [PATCH 3500/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 719b3894e..0c0e9314f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1858,7 +1858,7 @@ uint32_t get_dailyfx() { for (i=0; i Date: Fri, 29 Mar 2019 22:54:27 +0700 Subject: [PATCH 3501/3904] moving vertically also if block not fit game field on swap --- src/cc/games/tetris.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/games/tetris.c b/src/cc/games/tetris.c index 711170b0d..a0fd0615c 100644 --- a/src/cc/games/tetris.c +++ b/src/cc/games/tetris.c @@ -296,6 +296,7 @@ static void tg_hold(struct games_state *rs,tetris_game *obj) obj->stored.ori = ori; while (!tg_fits(obj, obj->falling)) { obj->falling.loc.row--; + obj->falling.loc.col--; } } tg_put(obj, obj->falling); From e1bfe06bf51cce1c2a4ff805eaefb04f57c2daf1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 05:41:08 -1100 Subject: [PATCH 3502/3904] Cleanup --- src/komodo_gateway.h | 48 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0c0e9314f..262e73ce0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1804,19 +1804,21 @@ cJSON *send_curl(char *url,char *fname) // get_urljson just returns the JSON returned by the URL using issue_curl #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) + const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "DASH", "XEM", "ZEC", "WAVES", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" }; -const char *Metals[] = { "XAU", "XAG", "XPT", "XPD", }; - -const char *Markets[] = { "DJIA", "SPX", "NDX", "VIX" }; - const char *Forex[] = { "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" }; +/* const char *Techstocks[] = { "AAPL","ADBE","ADSK","AKAM","AMD","AMZN","ATVI","BB","CDW","CRM","CSCO","CYBR","DBX","EA","FB","GDDY","GOOG","GRMN","GSAT","HPQ","IBM","INFY","INTC","INTU","JNPR","MSFT","MSI","MU","MXL","NATI","NCR","NFLX","NTAP","NVDA","ORCL","PANW","PYPL","QCOM","RHT","S","SHOP","SNAP","SPOT","SYMC","SYNA","T","TRIP","TWTR","TXN","VMW","VOD","VRSN","VZ","WDC","XRX","YELP","YNDX","ZEN" }; +const char *Metals[] = { "XAU", "XAG", "XPT", "XPD", }; + +const char *Markets[] = { "DJIA", "SPX", "NDX", "VIX" }; +*/ cJSON *get_urljson(char *url) { @@ -1847,10 +1849,10 @@ uint32_t get_stockprice(const char *symbol) return(price); } -uint32_t get_dailyfx() +uint32_t get_dailyfx(uint32_t *prices) { //{"base":"USD","rates":{"BGN":1.74344803,"NZD":1.471652701,"ILS":3.6329113924,"RUB":65.1997682296,"CAD":1.3430201462,"USD":1.0,"PHP":52.8641469068,"CHF":0.9970582992,"AUD":1.4129078267,"JPY":110.6792654662,"TRY":5.6523444464,"HKD":7.8499732573,"MYR":4.0824567659,"HRK":6.6232840078,"CZK":22.9862720628,"IDR":14267.4986628633,"DKK":6.6551078624,"NOK":8.6806917454,"HUF":285.131039401,"GBP":0.7626582278,"MXN":19.4183455161,"THB":31.8702085933,"ISK":122.5708682475,"ZAR":14.7033339276,"BRL":3.9750401141,"SGD":1.3573720806,"PLN":3.8286682118,"INR":69.33187734,"KRW":1139.1602781244,"RON":4.2423783206,"CNY":6.7387234801,"SEK":9.3385630237,"EUR":0.8914244963},"date":"2019-03-28"} - char url[512],*datestr; cJSON *json,*rates; int32_t i,n; uint32_t datenum=0,price = 0; + char url[512],*datestr; cJSON *json,*rates; int32_t i; uint32_t datenum=0,price = 0; sprintf(url,"https://api.openrates.io/latest?base=USD"); if ( (json= send_curl(url,(char *)"dailyfx")) != 0 ) { @@ -1858,13 +1860,14 @@ uint32_t get_dailyfx() { for (i=0; i Date: Fri, 29 Mar 2019 06:05:13 -1100 Subject: [PATCH 3503/3904] Test --- src/komodo_gateway.h | 71 ++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 262e73ce0..e1a32ea05 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1565,7 +1565,7 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) { - memcpy(prevbits,&vopret[0],PRICES_SIZEBIT0); + memcpy(prevbits,vopret.data(),vopret.size()); return(0); } } @@ -1598,21 +1598,21 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 } // komodo_pricecmp() returns -1 if any of the prices are beyond the tolerance -int32_t komodo_pricecmp(int32_t *maxflagp,uint32_t pricebitsA[4],uint32_t pricebitsB[4],int64_t tolerance) +int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) { int32_t i; *maxflagp = 0; - for (i=1; i<4; i++) + for (i=1; i= PRICES_SIZEBIT0 ) { if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - memcpy(pricebits,Mineropret.data(),PRICES_SIZEBIT0); - if ( komodo_pricecmp(&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + memcpy(pricebits,Mineropret.data(),Mineropret.size()); + n = (int32_t)(Mineropret.size() / sizeof(uint32_t)); + if ( komodo_pricecmp(n,&maxflag,pricebits,prevbits,Mineropret.size()) < 0 ) { // if the new prices are not within tolerance, update Mineropret with clipped prices - komodo_priceclamp(pricebits,prevbits,PRICES_MAXCHANGE); + komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE); fprintf(stderr,"update Mineropret to clamped prices\n"); - memcpy(Mineropret.data(),pricebits,PRICES_SIZEBIT0); + memcpy(Mineropret.data(),pricebits,Mineropret.size()); } } + int32_t i; + for (i=0; i vopret; uint32_t localbits[4],pricebits[4],prevbits[4],newprice; int32_t i,lag,lag2,maxflag=0; + std::vector vopret; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) { - memcpy(pricebits,&vopret[0],PRICES_SIZEBIT0); + n = (int32_t)(vopret.size() / sizeof(uint32_t)); + memcpy(pricebits,vopret.data(),Mineropret.size()); lag = (int32_t)(time(NULL) - pricebits[0]); if ( lag < 0 ) lag = -lag; @@ -1671,21 +1677,21 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - if ( komodo_pricecmp(&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) return(-1); } else return(-1); } if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) { - memcpy(localbits,Mineropret.data(),PRICES_SIZEBIT0); + memcpy(localbits,Mineropret.data(),Mineropret.size()); if ( maxflag == 0 ) { - if ( komodo_pricecmp(&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(n,&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) return(-1); } else { - for (i=1; i<4; i++) + for (i=1; i Date: Fri, 29 Mar 2019 06:11:08 -1100 Subject: [PATCH 3504/3904] Test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a91dae1e8..44b1192a4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2067,7 +2067,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CBOPRET != 0 ) { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET); - komodo_cbopretupdate(); // will set Mineropret + //komodo_cbopretupdate(); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } } From 2b8eac7ca17485a2581fbefdf90093fb0dccdbc1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 06:14:33 -1100 Subject: [PATCH 3505/3904] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e1a32ea05..271362c4b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1985,9 +1985,9 @@ void komodo_cbopretupdate() if ( get_btcusd(pricebits) == 0 ) { memcpy(Mineropret.data(),pricebits,PRICES_SIZEBIT0); - //int32_t i; for (i=0; i Date: Sat, 30 Mar 2019 00:15:48 +0700 Subject: [PATCH 3506/3904] fixing fit from both ends --- src/cc/games/tetris.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc/games/tetris.c b/src/cc/games/tetris.c index a0fd0615c..8e7642837 100644 --- a/src/cc/games/tetris.c +++ b/src/cc/games/tetris.c @@ -296,7 +296,14 @@ static void tg_hold(struct games_state *rs,tetris_game *obj) obj->stored.ori = ori; while (!tg_fits(obj, obj->falling)) { obj->falling.loc.row--; + if (tg_fits(obj, obj->falling)) { + break; + } obj->falling.loc.col--; + if (tg_fits(obj, obj->falling)) { + break; + } + obj->falling.loc.col += 2; } } tg_put(obj, obj->falling); From b7cf1a57e9ae788fad86cc1e31e736072895e6fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 06:17:03 -1100 Subject: [PATCH 3507/3904] 333 --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 271362c4b..c71f7c4f2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1974,6 +1974,8 @@ void komodo_cbopretupdate() int32_t size; if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) { + if ( komodo_nextheight() > 333 ) + ASSETCHAINS_CBOPRET = 7; size = PRICES_SIZEBIT0; if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) size += sizeof(forexprices); From 3b4a6191f9759df2bd440f257f9c3636830e0f02 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 06:19:33 -1100 Subject: [PATCH 3508/3904] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c71f7c4f2..0612caa80 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1987,9 +1987,6 @@ void komodo_cbopretupdate() if ( get_btcusd(pricebits) == 0 ) { memcpy(Mineropret.data(),pricebits,PRICES_SIZEBIT0); - int32_t i; for (i=0; i Date: Fri, 29 Mar 2019 06:38:55 -1100 Subject: [PATCH 3509/3904] Test --- src/komodo_gateway.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0612caa80..fbdda445c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1603,8 +1603,13 @@ int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_ int32_t i; *maxflagp = 0; for (i=1; i %u out of tolerance maxflag.%d\n",i,pricebitsB[i],pricebitsA[i],*maxflagp); return(-1); + } + } return(0); } @@ -1697,6 +1702,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( (newprice= komodo_pricenew(&maxflag,pricebits[i],prevbits[i],PRICES_MAXCHANGE)) != 0 ) // proposed price is clamped { // make sure local price is beyond clamped + fprintf(stderr,"maxflag.%d i.%d localbits.%u vs pricebits.%u\n",maxflag,i,localbits[i],pricebits[i]); if ( maxflag > 0 && localbits[i] < pricebits[i] ) return(-1); else if ( maxflag < 0 && localbits[i] > pricebits[i] ) @@ -2003,9 +2009,9 @@ void komodo_cbopretupdate() memcpy(&Mineropret.data()[size],cryptoprices,sizeof(cryptoprices)); size += sizeof(cryptoprices); } - int32_t i; for (i=0; i Date: Fri, 29 Mar 2019 07:01:56 -1100 Subject: [PATCH 3510/3904] +prints --- src/komodo_gateway.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fbdda445c..94d5928a9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1584,12 +1584,14 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; // and lowest if ( price >= highprice ) { + fprintf(stderr,"high %u vs h%u l%u\n",price,highprice,lowprice); *maxflagp = 1; if ( price > highprice ) // return non-zero only if we violate the tolerance return(highprice); } else if ( price <= lowprice ) { + fprintf(stderr,"low %u vs h%u l%u\n",price,highprice,lowprice); *maxflagp = -1; if ( price < lowprice ) return(lowprice); @@ -1606,7 +1608,7 @@ int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_ { if ( komodo_pricenew(maxflagp,pricebitsA[i],pricebitsB[i],tolerance) != 0 ) { - fprintf(stderr,"i.%d %u -> %u out of tolerance maxflag.%d\n",i,pricebitsB[i],pricebitsA[i],*maxflagp); + fprintf(stderr,"i.%d/%d %u -> %u out of tolerance maxflag.%d\n",i,n,pricebitsB[i],pricebitsA[i],*maxflagp); return(-1); } } @@ -1621,7 +1623,7 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 { if ( (newprice= komodo_pricenew(&maxflag,pricebits[i],refprices[i],tolerance)) != 0 ) { - fprintf(stderr,"priceclamped[%d] %u -> %u\n",i,pricebits[i],newprice); + fprintf(stderr,"priceclamped[%d of %d] %u -> %u\n",i,n,pricebits[i],newprice); pricebits[i] = newprice; } } From 3af96cfe61f9492d23ea6bf2219ff6e93868f181 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:03:48 -1100 Subject: [PATCH 3511/3904] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 94d5928a9..b60399329 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1602,13 +1602,13 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 // komodo_pricecmp() returns -1 if any of the prices are beyond the tolerance int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) { - int32_t i; + int32_t i; uint32_t newprice; *maxflagp = 0; for (i=1; i %u out of tolerance maxflag.%d\n",i,n,pricebitsB[i],pricebitsA[i],*maxflagp); + fprintf(stderr,"i.%d/%d %u vs %u -> newprice.%u out of tolerance maxflag.%d\n",i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); } } @@ -1623,7 +1623,7 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 { if ( (newprice= komodo_pricenew(&maxflag,pricebits[i],refprices[i],tolerance)) != 0 ) { - fprintf(stderr,"priceclamped[%d of %d] %u -> %u\n",i,n,pricebits[i],newprice); + fprintf(stderr,"priceclamped[%d of %d] %u vs %u -> %u\n",i,n,refprices[i],pricebits[i],newprice); pricebits[i] = newprice; } } From ec1c7ffcc7dd2535f9772ca7e5ba8862c02a1bc9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:10:46 -1100 Subject: [PATCH 3512/3904] Int64 --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b60399329..7a12f21bd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1579,19 +1579,19 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) */ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int64_t tolerance) { - uint32_t highprice,lowprice; + uint64_t highprice,lowprice; highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; // calc highest acceptable price lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; // and lowest if ( price >= highprice ) { - fprintf(stderr,"high %u vs h%u l%u\n",price,highprice,lowprice); + fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); *maxflagp = 1; if ( price > highprice ) // return non-zero only if we violate the tolerance return(highprice); } else if ( price <= lowprice ) { - fprintf(stderr,"low %u vs h%u l%u\n",price,highprice,lowprice); + fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); *maxflagp = -1; if ( price < lowprice ) return(lowprice); From c12368a75c7fefe97453cfa2169ac02d88cf7a8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:18:47 -1100 Subject: [PATCH 3513/3904] Print --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7a12f21bd..adf71c070 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1582,6 +1582,8 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 uint64_t highprice,lowprice; highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; // calc highest acceptable price lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; // and lowest + fprintf(stderr,"ref.%u * %llu -> %llu -> highprice %llu\n",refprice,(long long)(COIN+tolerance),(long long)((uint64_t)refprice * (COIN + tolerance)),(long long)highprice); + fprintf(stderr,"ref.%u * %llu -> %llu -> lowprice %llu\n",refprice,(long long)(COIN-tolerance),(long long)((uint64_t)refprice * (COIN - tolerance)),(long long)lowprice); if ( price >= highprice ) { fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); From 5f9d3a95528174ef97161511dbda0ab407d6f27e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:27:33 -1100 Subject: [PATCH 3514/3904] Test --- src/komodo_gateway.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index adf71c070..6ef0739e9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1635,14 +1635,24 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 // komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight CScript komodo_mineropret(int32_t nHeight) { - CScript opret; uint32_t pricebits[8192],prevbits[8192]; int32_t maxflag,n; + CScript opret; uint32_t pricebits[8192],prevbits[8192]; int32_t maxflag,n,numzero=0; if ( Mineropret.size() >= PRICES_SIZEBIT0 ) { + n = (int32_t)(Mineropret.size() / sizeof(uint32_t)); + numzero = 1; + while ( numzero > 0 ) + { + memcpy(pricebits,Mineropret.data(),Mineropret.size()); + for (i=numzero=0; i Date: Fri, 29 Mar 2019 07:28:47 -1100 Subject: [PATCH 3515/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6ef0739e9..8400289ef 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1635,7 +1635,7 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 // komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight CScript komodo_mineropret(int32_t nHeight) { - CScript opret; uint32_t pricebits[8192],prevbits[8192]; int32_t maxflag,n,numzero=0; + CScript opret; uint32_t pricebits[8192],prevbits[8192]; int32_t maxflag,i,n,numzero=0; if ( Mineropret.size() >= PRICES_SIZEBIT0 ) { n = (int32_t)(Mineropret.size() / sizeof(uint32_t)); From 92f0ec2616b71cf5fbbb4d5070e83e0ab961287c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:34:46 -1100 Subject: [PATCH 3516/3904] Make sure highprice and lowprice != refprice --- src/komodo_gateway.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8400289ef..cb0bc761b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1580,20 +1580,24 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int64_t tolerance) { uint64_t highprice,lowprice; + if ( refprice < 2 ) + return(0); highprice = ((uint64_t)refprice * (COIN + tolerance)) / COIN; // calc highest acceptable price lowprice = ((uint64_t)refprice * (COIN - tolerance)) / COIN; // and lowest - fprintf(stderr,"ref.%u * %llu -> %llu -> highprice %llu\n",refprice,(long long)(COIN+tolerance),(long long)((uint64_t)refprice * (COIN + tolerance)),(long long)highprice); - fprintf(stderr,"ref.%u * %llu -> %llu -> lowprice %llu\n",refprice,(long long)(COIN-tolerance),(long long)((uint64_t)refprice * (COIN - tolerance)),(long long)lowprice); + if ( highprice == refprice ) + highprice++; + if ( lowprice == refprice ) + lowprice--; if ( price >= highprice ) { - fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + //fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); *maxflagp = 1; if ( price > highprice ) // return non-zero only if we violate the tolerance return(highprice); } else if ( price <= lowprice ) { - fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + //fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); *maxflagp = -1; if ( price < lowprice ) return(lowprice); From e955d862fb9e652e83865549a9f9732683a57150 Mon Sep 17 00:00:00 2001 From: "Anton \"TonyL\" Lysakov" Date: Sat, 30 Mar 2019 01:45:33 +0700 Subject: [PATCH 3517/3904] looking for keystrokes.log in the right place --- src/tui/lib/tuilib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tui/lib/tuilib.py b/src/tui/lib/tuilib.py index 9a2fed639..b46030af8 100755 --- a/src/tui/lib/tuilib.py +++ b/src/tui/lib/tuilib.py @@ -1952,10 +1952,10 @@ def find_game_keystrokes_in_log(gametxid): operating_system = platform.system() if operating_system == 'Win64' or operating_system == 'Windows': - p1 = subprocess.Popen(["type", "keystrokes.log"], stdout=subprocess.PIPE, shell=True) + p1 = subprocess.Popen(["type", "../keystrokes.log"], stdout=subprocess.PIPE, shell=True) p2 = subprocess.Popen(["findstr", gametxid], stdin=p1.stdout, stdout=subprocess.PIPE, shell=True) else: - p1 = subprocess.Popen(["cat", "keystrokes.log"], stdout=subprocess.PIPE) + p1 = subprocess.Popen(["cat", "../keystrokes.log"], stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", gametxid], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() output = p2.communicate()[0] From 6c9eb0e0f9c4836159d337bf0ff2f7bbdef16e28 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:46:06 -1100 Subject: [PATCH 3518/3904] Dailyfx every 5 hours -> on average -> 2 hours ave delay --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cb0bc761b..94f85531a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1993,7 +1993,7 @@ int32_t get_btcusd(uint32_t pricebits[4]) void komodo_cbopretupdate() { - static uint32_t counter; + static uint32_t lasttime; static uint32_t pricebits[4],cryptoprices[sizeof(Cryptos)/sizeof(*Cryptos)],forexprices[sizeof(Forex)/sizeof(*Forex)]; int32_t size; if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) @@ -2014,10 +2014,11 @@ void komodo_cbopretupdate() } if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { - if ( (counter % 300) == 0 || forexprices[0] == 0 ) + if ( time(NULL) > lasttime+3600*5 || forexprices[0] == 0 ) { get_dailyfx(forexprices); memcpy(&Mineropret.data()[size],forexprices,sizeof(forexprices)); + lasttime = (uint32_t)time(NULL); } size += sizeof(forexprices); } From 6053dc843dbd4e9cd110fa8ac1201f43a63efee7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:48:51 -1100 Subject: [PATCH 3519/3904] -counter --- src/komodo_gateway.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 94f85531a..43c9981f2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2045,5 +2045,4 @@ void komodo_cbopretupdate() get_stocks(Techstocks,(int32_t)(sizeof(Techstocks)/sizeof(*Techstocks))); }*/ } - counter++; } From 1976dcbfdb128ba924e437d3ef7a75fe3344e349 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:55:23 -1100 Subject: [PATCH 3520/3904] test --- src/komodo_gateway.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 43c9981f2..16a64f86b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1701,7 +1701,10 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + { + fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); return(-1); + } } else return(-1); } if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) @@ -1710,7 +1713,10 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( maxflag == 0 ) { if ( komodo_pricecmp(n,&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) + { + fprintf(stderr,"maxflag.0 cmp error\n"); return(-1); + } } else { From e24193c7a8774b9a5d911d89660499554c4b8c83 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 07:59:47 -1100 Subject: [PATCH 3521/3904] Return 0 in all fall through cases for pricecmp --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 16a64f86b..3614ec4cc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1602,7 +1602,7 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 if ( price < lowprice ) return(lowprice); } - else return(0); + return(0); } // komodo_pricecmp() returns -1 if any of the prices are beyond the tolerance From eb4c6419fd0da61ff3887fc779d11f48bd77dfc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 08:24:28 -1100 Subject: [PATCH 3522/3904] Edge case of no local prices yet --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3614ec4cc..bf07218eb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1609,10 +1609,10 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) { int32_t i; uint32_t newprice; - *maxflagp = 0; for (i=1; i newprice.%u out of tolerance maxflag.%d\n",i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); @@ -1624,9 +1624,10 @@ int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_ // komodo_priceclamp() clamps any price that is beyond tolerance int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int64_t tolerance) { - int32_t i,maxflag = 0; uint32_t newprice; + int32_t i,maxflag; uint32_t newprice; for (i=1; i %u\n",i,n,refprices[i],pricebits[i],newprice); From 78dd8ae93776ee9fcf5735977c282a2f7d39020b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 08:27:16 -1100 Subject: [PATCH 3523/3904] Only skip check if localbits is 0 --- src/komodo_gateway.h | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bf07218eb..26fbeda02 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1612,7 +1612,7 @@ int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_ for (i=1; i newprice.%u out of tolerance maxflag.%d\n",i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); @@ -1711,27 +1711,33 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) { memcpy(localbits,Mineropret.data(),Mineropret.size()); - if ( maxflag == 0 ) + for (i=0; i 0 && localbits[i] < pricebits[i] ) - return(-1); - else if ( maxflag < 0 && localbits[i] > pricebits[i] ) - return(-1); + fprintf(stderr,"maxflag.0 cmp error\n"); + return(-1); + } + } + else + { + for (i=1; i 0 && localbits[i] < pricebits[i] ) + return(-1); + else if ( maxflag < 0 && localbits[i] > pricebits[i] ) + return(-1); + } } } } From 78564c9b3b3c02c8724239fa7c55be217fefbb0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 08:28:21 -1100 Subject: [PATCH 3524/3904] Handle partial 0 --- src/komodo_gateway.h | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 26fbeda02..63c210d6a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1713,31 +1713,28 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) memcpy(localbits,Mineropret.data(),Mineropret.size()); for (i=0; i 0 && localbits[i] < pricebits[i] ) - return(-1); - else if ( maxflag < 0 && localbits[i] > pricebits[i] ) - return(-1); - } + // make sure local price is beyond clamped + fprintf(stderr,"maxflag.%d i.%d localbits.%u vs pricebits.%u\n",maxflag,i,localbits[i],pricebits[i]); + if ( maxflag > 0 && localbits[i] < pricebits[i] ) + return(-1); + else if ( maxflag < 0 && localbits[i] > pricebits[i] ) + return(-1); } } } From 67352a31b59499e452c8564af14eda31850e2ac5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 08:35:02 -1100 Subject: [PATCH 3525/3904] Fix --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 63c210d6a..1306696f0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1609,9 +1609,9 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) { int32_t i; uint32_t newprice; + *maxflagp = 0; for (i=1; i newprice.%u out of tolerance maxflag.%d\n",i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); From 725ac7114718704719a807465add337d49919261 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 08:52:12 -1100 Subject: [PATCH 3526/3904] +print --- src/komodo_gateway.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1306696f0..225524eaf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1590,14 +1590,14 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 lowprice--; if ( price >= highprice ) { - //fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); *maxflagp = 1; if ( price > highprice ) // return non-zero only if we violate the tolerance return(highprice); } else if ( price <= lowprice ) { - //fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); *maxflagp = -1; if ( price < lowprice ) return(lowprice); @@ -1606,7 +1606,7 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 } // komodo_pricecmp() returns -1 if any of the prices are beyond the tolerance -int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) +int32_t komodo_pricecmp(int32_t nHeight,int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) { int32_t i; uint32_t newprice; *maxflagp = 0; @@ -1614,7 +1614,7 @@ int32_t komodo_pricecmp(int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_ { if ( (newprice= komodo_pricenew(maxflagp,pricebitsA[i],pricebitsB[i],tolerance)) != 0 ) { - fprintf(stderr,"i.%d/%d %u vs %u -> newprice.%u out of tolerance maxflag.%d\n",i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); + fprintf(stderr,"ht.%d i.%d/%d %u vs %u -> newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); } } @@ -1657,7 +1657,7 @@ CScript komodo_mineropret(int32_t nHeight) if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { memcpy(pricebits,Mineropret.data(),Mineropret.size()); - if ( komodo_pricecmp(n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(0,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { // if the new prices are not within tolerance, update Mineropret with clipped prices komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE); @@ -1701,7 +1701,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - if ( komodo_pricecmp(n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); return(-1); @@ -1716,7 +1716,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) localbits[i] = prevbits[i]; if ( maxflag == 0 ) { - if ( komodo_pricecmp(n,&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(nHeight,n,&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) { fprintf(stderr,"maxflag.0 cmp error\n"); return(-1); From d605780e576e1f1952c8158cb693003a73559d26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 29 Mar 2019 09:04:39 -1100 Subject: [PATCH 3527/3904] +print --- src/komodo_gateway.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 225524eaf..d82cb47e8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1591,16 +1591,22 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 if ( price >= highprice ) { fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); - *maxflagp = 1; if ( price > highprice ) // return non-zero only if we violate the tolerance + { + *maxflagp = 2; return(highprice); + } + *maxflagp = 1; } else if ( price <= lowprice ) { fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); - *maxflagp = -1; if ( price < lowprice ) + { + *maxflagp = -2; return(lowprice); + } + *maxflagp = -1; } return(0); } From d3ff021e338f09f7d7acd997df32d8621aedef10 Mon Sep 17 00:00:00 2001 From: "Anton \"TonyL\" Lysakov" Date: Sun, 31 Mar 2019 05:42:13 +0700 Subject: [PATCH 3528/3904] Update tuilib.py Discovered that `keystrokes.log` creating in folder from which game calling, not especially daemon folder. So before changed from correct to not correct :/ --- src/tui/lib/tuilib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tui/lib/tuilib.py b/src/tui/lib/tuilib.py index b46030af8..9a2fed639 100755 --- a/src/tui/lib/tuilib.py +++ b/src/tui/lib/tuilib.py @@ -1952,10 +1952,10 @@ def find_game_keystrokes_in_log(gametxid): operating_system = platform.system() if operating_system == 'Win64' or operating_system == 'Windows': - p1 = subprocess.Popen(["type", "../keystrokes.log"], stdout=subprocess.PIPE, shell=True) + p1 = subprocess.Popen(["type", "keystrokes.log"], stdout=subprocess.PIPE, shell=True) p2 = subprocess.Popen(["findstr", gametxid], stdin=p1.stdout, stdout=subprocess.PIPE, shell=True) else: - p1 = subprocess.Popen(["cat", "../keystrokes.log"], stdout=subprocess.PIPE) + p1 = subprocess.Popen(["cat", "keystrokes.log"], stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", gametxid], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() output = p2.communicate()[0] From b0edb6718cdd5528742537e9f8a8aff60338686f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 04:19:43 -1100 Subject: [PATCH 3529/3904] Fix cmp bug --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d82cb47e8..bec86a439 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1722,7 +1722,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) localbits[i] = prevbits[i]; if ( maxflag == 0 ) { - if ( komodo_pricecmp(nHeight,n,&maxflag,localbits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,localbits,PRICES_MAXCHANGE) < 0 ) { fprintf(stderr,"maxflag.0 cmp error\n"); return(-1); From c85b4db249d1c027be04e08744312d93caa82e07 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 04:42:11 -1100 Subject: [PATCH 3530/3904] Test --- src/bitcoind.cpp | 2 +- src/komodo_gateway.h | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 3c5cfe4d6..0afb47894 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -90,7 +90,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) //komodo_longestchain(); if ( ASSETCHAINS_CBOPRET != 0 ) komodo_cbopretupdate(); - for (i=0; i vopret; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; + std::vector vopret; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1698,9 +1698,13 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { n = (int32_t)(vopret.size() / sizeof(uint32_t)); memcpy(pricebits,vopret.data(),Mineropret.size()); - lag = (int32_t)(time(NULL) - pricebits[0]); + lag = (int32_t)(now - pricebits[0]); + if ( lag > 60 ) // blocks from future not so good to have + return(-1); if ( lag < 0 ) lag = -lag; + if ( lag > ASSETCHAINS_BLOCKTIME ) + return(-1); lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( nHeight > 1 ) @@ -1735,11 +1739,11 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) maxflag = 0; if ( (newprice= komodo_pricenew(&maxflag,pricebits[i],prevbits[i],PRICES_MAXCHANGE)) != 0 ) // proposed price is clamped { - // make sure local price is beyond clamped + // make sure local price is moving in right direction fprintf(stderr,"maxflag.%d i.%d localbits.%u vs pricebits.%u\n",maxflag,i,localbits[i],pricebits[i]); - if ( maxflag > 0 && localbits[i] < pricebits[i] ) + if ( maxflag > 0 && localbits[i] < prevbits[i] ) return(-1); - else if ( maxflag < 0 && localbits[i] > pricebits[i] ) + else if ( maxflag < 0 && localbits[i] > prevbits[i] ) return(-1); } } @@ -2009,9 +2013,9 @@ int32_t get_btcusd(uint32_t pricebits[4]) void komodo_cbopretupdate() { - static uint32_t lasttime; + static uint32_t lasttime,lastcrypto,lastbtc; static uint32_t pricebits[4],cryptoprices[sizeof(Cryptos)/sizeof(*Cryptos)],forexprices[sizeof(Forex)/sizeof(*Forex)]; - int32_t size; + int32_t size; uint32_t now = (uint32_t)time(NULL); if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) { if ( komodo_nextheight() > 333 ) @@ -2024,13 +2028,14 @@ void komodo_cbopretupdate() if ( Mineropret.size() < size ) Mineropret.resize(size); size = PRICES_SIZEBIT0; - if ( get_btcusd(pricebits) == 0 ) + if ( now > lastbtc+30 && get_btcusd(pricebits) == 0 ) { memcpy(Mineropret.data(),pricebits,PRICES_SIZEBIT0); + lastbtc = (uint32_t)time(NULL); } if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { - if ( time(NULL) > lasttime+3600*5 || forexprices[0] == 0 ) + if ( now > lasttime+3600*5 || forexprices[0] == 0 ) { get_dailyfx(forexprices); memcpy(&Mineropret.data()[size],forexprices,sizeof(forexprices)); @@ -2040,8 +2045,12 @@ void komodo_cbopretupdate() } if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) { - get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); - memcpy(&Mineropret.data()[size],cryptoprices,sizeof(cryptoprices)); + if ( now > lastcrypto+60 ) + { + get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); + memcpy(&Mineropret.data()[size],cryptoprices,sizeof(cryptoprices)); + lastcrypto = (uint32_t)time(NULL); + } size += sizeof(cryptoprices); } //int32_t i; for (i=0; i Date: Sun, 31 Mar 2019 04:50:02 -1100 Subject: [PATCH 3531/3904] Test --- src/komodo_gateway.h | 68 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 66fff3984..74ba9a779 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1698,17 +1698,17 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { n = (int32_t)(vopret.size() / sizeof(uint32_t)); memcpy(pricebits,vopret.data(),Mineropret.size()); - lag = (int32_t)(now - pricebits[0]); - if ( lag > 60 ) // blocks from future not so good to have - return(-1); - if ( lag < 0 ) - lag = -lag; - if ( lag > ASSETCHAINS_BLOCKTIME ) - return(-1); - lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); - fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( nHeight > 1 ) { + lag = (int32_t)(now - pricebits[0]); + if ( lag > 60 ) // blocks from future not so good to have + return(-1); + if ( lag < 0 ) + lag = -lag; + if ( lag > ASSETCHAINS_BLOCKTIME ) + return(-1); + lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); + fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) @@ -1717,34 +1717,34 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) return(-1); } } else return(-1); - } - if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) - { - memcpy(localbits,Mineropret.data(),Mineropret.size()); - for (i=0; i= PRICES_SIZEBIT0 ) { - if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,localbits,PRICES_MAXCHANGE) < 0 ) + memcpy(localbits,Mineropret.data(),Mineropret.size()); + for (i=0; i 0 && localbits[i] < prevbits[i] ) - return(-1); - else if ( maxflag < 0 && localbits[i] > prevbits[i] ) - return(-1); + fprintf(stderr,"maxflag.0 cmp error\n"); + return(-1); + } + } + else + { + for (i=1; i 0 && localbits[i] < prevbits[i] ) + return(-1); + else if ( maxflag < 0 && localbits[i] > prevbits[i] ) + return(-1); + } } } } From eb23d9e3c46e858419b5d63820c5cdf3accfe6cd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 04:52:29 -1100 Subject: [PATCH 3532/3904] Fix lag calc --- src/komodo_gateway.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 74ba9a779..c8219fc08 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1701,12 +1701,18 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( nHeight > 1 ) { lag = (int32_t)(now - pricebits[0]); - if ( lag > 60 ) // blocks from future not so good to have + if ( lag > ASSETCHAINS_BLOCKTIME ) + { + fprintf(stderr,"now.%u - pricebits[0] %u -> lag.%d\n",now,pricebits[0],lag); return(-1); + } if ( lag < 0 ) lag = -lag; - if ( lag > ASSETCHAINS_BLOCKTIME ) + if ( lag > 60 ) // avoid data from future + { + fprintf(stderr,"now.%u - pricebits[0] %u -> lag.%d\n",now,pricebits[0],lag); return(-1); + } lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) From 275e78667c9c8957bf6f6f8eed9db845dd79bd73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 04:56:26 -1100 Subject: [PATCH 3533/3904] Use lag2 --- src/komodo_gateway.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c8219fc08..f989594ff 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1701,19 +1701,19 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( nHeight > 1 ) { lag = (int32_t)(now - pricebits[0]); - if ( lag > ASSETCHAINS_BLOCKTIME ) - { - fprintf(stderr,"now.%u - pricebits[0] %u -> lag.%d\n",now,pricebits[0],lag); - return(-1); - } if ( lag < 0 ) lag = -lag; - if ( lag > 60 ) // avoid data from future + lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); + if ( lag2 > 60 ) { - fprintf(stderr,"now.%u - pricebits[0] %u -> lag.%d\n",now,pricebits[0],lag); + fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); + return(-1); + } + if ( lag2 < -ASSETCHAINS_BLOCKTIME-60 ) // avoid data from future + { + fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); return(-1); } - lag2 = (int32_t)(pricebits[0] - komodo_heightstamp(nHeight-1)); fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { From c171940c3f563ffe4cfa36477deda946869ab034 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 05:00:04 -1100 Subject: [PATCH 3534/3904] Test --- src/komodo_gateway.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f989594ff..e3ab02086 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1701,15 +1701,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( nHeight > 1 ) { lag = (int32_t)(now - pricebits[0]); - if ( lag < 0 ) - lag = -lag; lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); - if ( lag2 > 60 ) - { - fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); - return(-1); - } - if ( lag2 < -ASSETCHAINS_BLOCKTIME-60 ) // avoid data from future + if ( lag < -60 ) // avoid data from future { fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); return(-1); From 14943d68064c143acc7bcbb92c8a80eba1780579 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 08:54:17 -1100 Subject: [PATCH 3535/3904] Test --- src/komodo_gateway.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e3ab02086..64b11bafe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1707,9 +1707,13 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); return(-1); } + // else need to check against current blocktime to prevent pricebits[0] games fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { + for (i=1; i Date: Sun, 31 Mar 2019 08:56:54 -1100 Subject: [PATCH 3536/3904] Test --- src/komodo_gateway.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 64b11bafe..25dc6d0bd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1711,6 +1711,9 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { + for (i=1; i Date: Sun, 31 Mar 2019 09:03:21 -1100 Subject: [PATCH 3537/3904] Retry prev block error (most likely due to unfleshed data) --- src/komodo_gateway.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 25dc6d0bd..4e49d59d0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1711,16 +1711,23 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - for (i=1; i= PRICES_SIZEBIT0 ) From 98977bb947924964ec1c0e5e1796d7c0fa8a4131 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 09:24:02 -1100 Subject: [PATCH 3538/3904] Add some forex calc --- src/komodo_gateway.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4e49d59d0..b7e1ec8f9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1690,7 +1690,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); + std::vector vopret; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1708,7 +1708,10 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) return(-1); } // else need to check against current blocktime to prevent pricebits[0] games - fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR htstamp.%d [%d]\n",nHeight,pricebits[0],lag,(double)pricebits[1]/10000,(double)pricebits[2]/10000,(double)pricebits[3]/10000,komodo_heightstamp(nHeight-1),lag2); + btcusd = (double)pricebits[1]/10000; + btcgbp = (double)pricebits[2]/10000; + btceur = (double)pricebits[3]/10000; + fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.7f, EURGBP %.6f htstamp.%d [%d]\n",nHeight,pricebits[0],lag,btcusd,btcgbp,btceur,btcgbp/btcusd,btceur/btcusd,btceur/btcgbp,komodo_heightstamp(nHeight-1),lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) @@ -1720,6 +1723,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"%.4f ",(double)pricebits[i]/10000); fprintf(stderr," newprices.%d\n",nHeight); sleep(3); + memcpy(pricebits,vopret.data(),Mineropret.size()); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) From 7a2cdcb8c57578e0fb441408c14fd820d09fd159 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 09:24:52 -1100 Subject: [PATCH 3539/3904] -timestamp prints --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b7e1ec8f9..47d84e6df 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1711,7 +1711,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) btcusd = (double)pricebits[1]/10000; btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; - fprintf(stderr,"ht.%d: t%u lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.7f, EURGBP %.6f htstamp.%d [%d]\n",nHeight,pricebits[0],lag,btcusd,btcgbp,btceur,btcgbp/btcusd,btceur/btcusd,btceur/btcgbp,komodo_heightstamp(nHeight-1),lag2); + fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.7f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcgbp/btcusd,btceur/btcusd,btceur/btcgbp,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) From 9beb02477d82a8ab322204c45a83b7b85dc438e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 09:29:55 -1100 Subject: [PATCH 3540/3904] +prints --- src/komodo_gateway.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 47d84e6df..3995dadf1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1711,7 +1711,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) btcusd = (double)pricebits[1]/10000; btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; - fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.7f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcgbp/btcusd,btceur/btcusd,btceur/btcgbp,lag2); + fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcgbp/btcusd,btceur/btcusd,btceur/btcgbp,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) @@ -1997,7 +1997,7 @@ int32_t get_stocks(const char *list[],int32_t n) int32_t get_btcusd(uint32_t pricebits[4]) { - cJSON *pjson,*bpi,*obj; char str[512]; uint64_t btcusd = 0,btcgbp = 0,btceur = 0; + cJSON *pjson,*bpi,*obj; char str[512]; double dbtcgbp,dbtcusd,dbtceur; uint64_t btcusd = 0,btcgbp = 0,btceur = 0; if ( (pjson= get_urljson((char *)"http://api.coindesk.com/v1/bpi/currentprice.json")) != 0 ) { if ( (bpi= jobj(pjson,(char *)"bpi")) != 0 ) @@ -2020,7 +2020,10 @@ int32_t get_btcusd(uint32_t pricebits[4]) } } free_json(pjson); - fprintf(stderr,"BTC/USD %.4f, BTC/GBP %.4f, BTC/EUR %.4f\n",dstr(btcusd),dstr(btcgbp),dstr(btceur)); + dbtcusd = (double)pricebits[1]/10000; + dbtcgbp = (double)pricebits[2]/10000; + dbtceur = (double)pricebits[3]/10000; + fprintf(stderr,"BTC/USD %.4f, BTC/GBP %.4f, BTC/EUR %.4f GBPUSD %.6f, EURUSD %.6f EURGBP %.6f\n",dbtcusd,dbtcgbp,dbtceur,dbtcgbp/dbtcusd,dbtceur/dbtcusd,dbtceur/dbtcgbp); return(0); } return(-1); From 8a520ea4399f415accc7e33bf9af5d4b9658f085 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 09:32:33 -1100 Subject: [PATCH 3541/3904] Invert forex calc --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3995dadf1..12a980d78 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1711,7 +1711,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) btcusd = (double)pricebits[1]/10000; btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; - fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcgbp/btcusd,btceur/btcusd,btceur/btcgbp,lag2); + fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcgbp/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) @@ -2023,7 +2023,7 @@ int32_t get_btcusd(uint32_t pricebits[4]) dbtcusd = (double)pricebits[1]/10000; dbtcgbp = (double)pricebits[2]/10000; dbtceur = (double)pricebits[3]/10000; - fprintf(stderr,"BTC/USD %.4f, BTC/GBP %.4f, BTC/EUR %.4f GBPUSD %.6f, EURUSD %.6f EURGBP %.6f\n",dbtcusd,dbtcgbp,dbtceur,dbtcgbp/dbtcusd,dbtceur/dbtcusd,dbtceur/dbtcgbp); + fprintf(stderr,"BTC/USD %.4f, BTC/GBP %.4f, BTC/EUR %.4f GBPUSD %.6f, EURUSD %.6f EURGBP %.6f\n",dbtcusd,dbtcgbp,dbtceur,dbtcusd/dbtcgbp,dbtcgbp/dbtceur,dbtcgbp/dbtceur); return(0); } return(-1); From 3e48426eb56ad0dd748eef821ed7e2139086a4ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 09:35:06 -1100 Subject: [PATCH 3542/3904] Fix eurusd --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 12a980d78..d04bb9fc4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1711,7 +1711,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) btcusd = (double)pricebits[1]/10000; btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; - fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcgbp/btceur,btcgbp/btceur,lag2); + fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) @@ -2023,7 +2023,7 @@ int32_t get_btcusd(uint32_t pricebits[4]) dbtcusd = (double)pricebits[1]/10000; dbtcgbp = (double)pricebits[2]/10000; dbtceur = (double)pricebits[3]/10000; - fprintf(stderr,"BTC/USD %.4f, BTC/GBP %.4f, BTC/EUR %.4f GBPUSD %.6f, EURUSD %.6f EURGBP %.6f\n",dbtcusd,dbtcgbp,dbtceur,dbtcusd/dbtcgbp,dbtcgbp/dbtceur,dbtcgbp/dbtceur); + fprintf(stderr,"BTC/USD %.4f, BTC/GBP %.4f, BTC/EUR %.4f GBPUSD %.6f, EURUSD %.6f EURGBP %.6f\n",dbtcusd,dbtcgbp,dbtceur,dbtcusd/dbtcgbp,dbtcusd/dbtceur,dbtcgbp/dbtceur); return(0); } return(-1); From b025dd2eaf8068b2068e09112dbbfab478197127 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 09:43:53 -1100 Subject: [PATCH 3543/3904] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d04bb9fc4..c1e5dcdcb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1590,7 +1590,7 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 lowprice--; if ( price >= highprice ) { - fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + //fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); if ( price > highprice ) // return non-zero only if we violate the tolerance { *maxflagp = 2; @@ -1600,7 +1600,7 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 } else if ( price <= lowprice ) { - fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + //fprintf(stderr,"low %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); if ( price < lowprice ) { *maxflagp = -2; @@ -2048,7 +2048,7 @@ void komodo_cbopretupdate() if ( Mineropret.size() < size ) Mineropret.resize(size); size = PRICES_SIZEBIT0; - if ( now > lastbtc+30 && get_btcusd(pricebits) == 0 ) + if ( now > lastbtc+120 && get_btcusd(pricebits) == 0 ) { memcpy(Mineropret.data(),pricebits,PRICES_SIZEBIT0); lastbtc = (uint32_t)time(NULL); @@ -2065,7 +2065,7 @@ void komodo_cbopretupdate() } if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) { - if ( now > lastcrypto+60 ) + if ( now > lastcrypto+100 ) { get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); memcpy(&Mineropret.data()[size],cryptoprices,sizeof(cryptoprices)); From c6fca9511810429d79e49fd2ae194064b28c90e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 21:26:51 -1100 Subject: [PATCH 3544/3904] Fix strange data bug --- src/komodo_gateway.h | 17 ++++++----------- src/komodo_utils.h | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c1e5dcdcb..d863c8a27 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1665,7 +1665,7 @@ CScript komodo_mineropret(int32_t nHeight) memcpy(pricebits,Mineropret.data(),Mineropret.size()); if ( komodo_pricecmp(0,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { - // if the new prices are not within tolerance, update Mineropret with clipped prices + // if the new prices are outside tolerance, update Mineropret with clamped prices komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE); fprintf(stderr,"update Mineropret to clamped prices\n"); memcpy(Mineropret.data(),pricebits,Mineropret.size()); @@ -1722,17 +1722,10 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) for (i=1; i= PRICES_SIZEBIT0 ) { @@ -2030,6 +2023,8 @@ int32_t get_btcusd(uint32_t pricebits[4]) } // komodo_cbopretupdate() obtains the external price data and encodes it into Mineropret, which will then be used by the miner and validation +// save history, use new data to approve past rejection, where is the auto-reconsiderblock? +// 51% correlation, smoothing void komodo_cbopretupdate() { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 44b1192a4..a91dae1e8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2067,7 +2067,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CBOPRET != 0 ) { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET); - //komodo_cbopretupdate(); // will set Mineropret + komodo_cbopretupdate(); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } } From 7f81f5f6ffd44e01b30007c6882eb81b7d6cb16a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 21:44:27 -1100 Subject: [PATCH 3545/3904] Allow 0 price for earlyblocks --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d863c8a27..2eac0e7f4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1618,7 +1618,7 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,int32_t *maxflagp,uint32_t *pr *maxflagp = 0; for (i=1; i newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); From dc1b504b980b606e5a60f158335aab71db618466 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 21:48:54 -1100 Subject: [PATCH 3546/3904] Latch prevbits if new is 0 --- src/komodo_gateway.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2eac0e7f4..1cc899f1a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1714,6 +1714,9 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { + for (i=0; i Date: Sun, 31 Mar 2019 21:53:31 -1100 Subject: [PATCH 3547/3904] +print --- src/komodo_gateway.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1cc899f1a..4d84fa19f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1590,7 +1590,7 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 lowprice--; if ( price >= highprice ) { - //fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); if ( price > highprice ) // return non-zero only if we violate the tolerance { *maxflagp = 2; @@ -1618,7 +1618,7 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,int32_t *maxflagp,uint32_t *pr *maxflagp = 0; for (i=1; i= 500 || pricebitsB[i] != 0) && (newprice= komodo_pricenew(maxflagp,pricebitsA[i],pricebitsB[i],tolerance)) != 0 ) { fprintf(stderr,"ht.%d i.%d/%d %u vs %u -> newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); @@ -1714,9 +1714,12 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - for (i=0; i Date: Sun, 31 Mar 2019 21:56:44 -1100 Subject: [PATCH 3548/3904] 339 exemption --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4d84fa19f..8fad25202 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1720,7 +1720,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( pricebits[i] == 0 ) pricebits[i] = prevbits[i]; } - if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( nHeight != 339 && komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { for (i=1; i Date: Sun, 31 Mar 2019 21:58:47 -1100 Subject: [PATCH 3549/3904] 340 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8fad25202..4aab886b5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1720,7 +1720,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( pricebits[i] == 0 ) pricebits[i] = prevbits[i]; } - if ( nHeight != 339 && komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( nHeight != 340 && komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { for (i=1; i Date: Sun, 31 Mar 2019 22:02:28 -1100 Subject: [PATCH 3550/3904] Skip first 500 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4aab886b5..c8a3d3c9f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1720,7 +1720,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( pricebits[i] == 0 ) pricebits[i] = prevbits[i]; } - if ( nHeight != 340 && komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( nHeight < 500 && komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { for (i=1; i Date: Sun, 31 Mar 2019 22:06:51 -1100 Subject: [PATCH 3551/3904] 500 --- src/komodo_gateway.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c8a3d3c9f..26bf2fcc3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1618,7 +1618,7 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,int32_t *maxflagp,uint32_t *pr *maxflagp = 0; for (i=1; i= 500 || pricebitsB[i] != 0) && (newprice= komodo_pricenew(maxflagp,pricebitsA[i],pricebitsB[i],tolerance)) != 0 ) + if ( (newprice= komodo_pricenew(maxflagp,pricebitsA[i],pricebitsB[i],tolerance)) != 0 ) { fprintf(stderr,"ht.%d i.%d/%d %u vs %u -> newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); @@ -1693,6 +1693,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) std::vector vopret; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 ) { + if ( nHeight < 500 ) + return(0); GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) { @@ -1714,13 +1716,13 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - if ( nHeight < 500 ) + /*if ( nHeight < 500 ) { for (i=0; i Date: Sun, 31 Mar 2019 22:09:36 -1100 Subject: [PATCH 3552/3904] 600 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 26bf2fcc3..66a6f2515 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1693,7 +1693,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) std::vector vopret; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 ) { - if ( nHeight < 500 ) + if ( nHeight < 600 ) return(0); GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) From 6e25432673f5cd2a9f8a00c64ec0ea9aef7e8a80 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:13:44 -1100 Subject: [PATCH 3553/3904] Fetch data first --- src/komodo_gateway.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 66a6f2515..e71b8cd4d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1691,9 +1691,11 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { std::vector vopret; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); - if ( ASSETCHAINS_CBOPRET != 0 ) + if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { - if ( nHeight < 600 ) + if ( komodo_heightpricebits(prevbits,nHeight-1) < 0 ) + return(-1); + if ( nHeight < 350 ) return(0); GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) @@ -1714,7 +1716,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); - if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) + //if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { /*if ( nHeight < 500 ) { @@ -1734,7 +1736,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); return(-1); } // else this is the good case we hope to happen - } else return(-1); + } //else return(-1); if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) { memcpy(localbits,Mineropret.data(),Mineropret.size()); From 6d7828d809f684ac31ad5c8c2a5f4c42bbe86682 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:17:45 -1100 Subject: [PATCH 3554/3904] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e71b8cd4d..65487219d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1693,10 +1693,6 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) std::vector vopret; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { - if ( komodo_heightpricebits(prevbits,nHeight-1) < 0 ) - return(-1); - if ( nHeight < 350 ) - return(0); GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) { @@ -1704,6 +1700,10 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) memcpy(pricebits,vopret.data(),Mineropret.size()); if ( nHeight > 1 ) { + if ( komodo_heightpricebits(prevbits,nHeight-1) < 0 ) + return(-1); + if ( nHeight < 350 ) + return(0); lag = (int32_t)(now - pricebits[0]); lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); if ( lag < -60 ) // avoid data from future From 5479c8ae392e69d861a23b2494a548c97dd51311 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:25:10 -1100 Subject: [PATCH 3555/3904] Test --- src/komodo_gateway.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 65487219d..fc410d5ad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1698,12 +1698,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { n = (int32_t)(vopret.size() / sizeof(uint32_t)); memcpy(pricebits,vopret.data(),Mineropret.size()); - if ( nHeight > 1 ) + if ( nHeight > 1 && vopret.size() == Mineropret.size() ) { - if ( komodo_heightpricebits(prevbits,nHeight-1) < 0 ) - return(-1); - if ( nHeight < 350 ) - return(0); lag = (int32_t)(now - pricebits[0]); lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); if ( lag < -60 ) // avoid data from future @@ -1769,6 +1765,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) } } } + else if ( nHeight > 500 ) + return(-1); return(0); } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)Mineropret.size(),(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); From 0cba720dbd3fec82618add4880adaa6b0a0b6ac7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:28:30 -1100 Subject: [PATCH 3556/3904] Test --- src/komodo_gateway.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fc410d5ad..f5149d473 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1698,7 +1698,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { n = (int32_t)(vopret.size() / sizeof(uint32_t)); memcpy(pricebits,vopret.data(),Mineropret.size()); - if ( nHeight > 1 && vopret.size() == Mineropret.size() ) + if ( nHeight > 1 ) { lag = (int32_t)(now - pricebits[0]); lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); @@ -1712,14 +1712,14 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); - //if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) + if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - /*if ( nHeight < 500 ) + if ( nHeight < 500 ) { for (i=0; i 500 ) - return(-1); return(0); } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)Mineropret.size(),(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); From 485376098a763386dab77d14039412d2f8623f85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:32:03 -1100 Subject: [PATCH 3557/3904] Test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f5149d473..06ed31474 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1730,7 +1730,8 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr," newprices.%d\n",nHeight); fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); - return(-1); + if ( nHeight != 339 ) + return(-1); } // else this is the good case we hope to happen } //else return(-1); if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) From dd851e864413a33986ef3b3b8dda7dd7bdbcfeee Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:37:49 -1100 Subject: [PATCH 3558/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 06ed31474..86d1ab541 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1730,7 +1730,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr," newprices.%d\n",nHeight); fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); - if ( nHeight != 339 ) + if ( nHeight != 339 && nHeight != 340 ) return(-1); } // else this is the good case we hope to happen } //else return(-1); From 46d59bf1d71ee46449971b469b0a3896d53f8cd0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:39:42 -1100 Subject: [PATCH 3559/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 86d1ab541..79b6642e5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1730,7 +1730,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr," newprices.%d\n",nHeight); fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); - if ( nHeight != 339 && nHeight != 340 ) + if ( nHeight != 339 && nHeight != 340 && nHeight != 341 ) return(-1); } // else this is the good case we hope to happen } //else return(-1); From 7291a4fc73eef6d59654ca875d7b261c7b718c75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:41:25 -1100 Subject: [PATCH 3560/3904] 500 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 79b6642e5..5f8c6d134 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1730,7 +1730,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr," newprices.%d\n",nHeight); fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); - if ( nHeight != 339 && nHeight != 340 && nHeight != 341 ) + if ( nHeight > 500 ) return(-1); } // else this is the good case we hope to happen } //else return(-1); From 1ee8042e98fb12215121fcb5b61edeb5ac69965e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:43:38 -1100 Subject: [PATCH 3561/3904] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5f8c6d134..be262b24f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1714,12 +1714,12 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - if ( nHeight < 500 ) + /*if ( nHeight < 500 ) { for (i=0; i 500 ) + //if ( nHeight > 500 ) return(-1); } // else this is the good case we hope to happen } //else return(-1); From 0792e959c86a4cf3f635c5af02d20346685cb0c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:54:42 -1100 Subject: [PATCH 3562/3904] CBOPRET reconsider --- src/main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b73a31856..bac0def5d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4120,7 +4120,14 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * GetMainSignals().BlockChecked(*pblock, state); if (!rv) { if (state.IsInvalid()) + { InvalidBlockFound(pindexNew, state); + if ( ASSETCHAINS_CBOPRET != 0 ) + { + pindex->nStatus &= ~BLOCK_FAILED_MASK; + fprinf(stderr,"reconsiderblock %d\n",(int32_t)pindex->nHeight); + } + } return error("ConnectTip(): ConnectBlock %s failed", pindexNew->GetBlockHash().ToString()); } mapBlockSource.erase(pindexNew->GetBlockHash()); @@ -5211,7 +5218,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat miSelf->second = pindex = AddToBlockIndex(block); if (ppindex) *ppindex = pindex; - if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK ) + if ( pindex != 0 && (pindex->nStatus & BLOCK_FAILED_MASK) != 0 ) { if ( ASSETCHAINS_CC == 0 )//&& (ASSETCHAINS_PRIVATE == 0 || KOMODO_INSYNC >= Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) ) return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate"); From f7a881d1b3a0b411cf522951a9e4b14fb4609093 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:55:46 -1100 Subject: [PATCH 3563/3904] pindexNew --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bac0def5d..8a139c247 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4124,8 +4124,8 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * InvalidBlockFound(pindexNew, state); if ( ASSETCHAINS_CBOPRET != 0 ) { - pindex->nStatus &= ~BLOCK_FAILED_MASK; - fprinf(stderr,"reconsiderblock %d\n",(int32_t)pindex->nHeight); + pindexNew->nStatus &= ~BLOCK_FAILED_MASK; + fprinf(stderr,"reconsiderblock %d\n",(int32_t)pindexNew->nHeight); } } return error("ConnectTip(): ConnectBlock %s failed", pindexNew->GetBlockHash().ToString()); From baacd254e3abef202f9c8674b8363f6407f3412c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:56:55 -1100 Subject: [PATCH 3564/3904] fprinTf --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8a139c247..e8e1e554c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4125,7 +4125,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * if ( ASSETCHAINS_CBOPRET != 0 ) { pindexNew->nStatus &= ~BLOCK_FAILED_MASK; - fprinf(stderr,"reconsiderblock %d\n",(int32_t)pindexNew->nHeight); + fprintf(stderr,"reconsiderblock %d\n",(int32_t)pindexNew->nHeight); } } return error("ConnectTip(): ConnectBlock %s failed", pindexNew->GetBlockHash().ToString()); From 1af4f989ac9c1fa7f91198bf1685d208d1fa6940 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 22:58:52 -1100 Subject: [PATCH 3565/3904] GetHeight() --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e8e1e554c..be516c25d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4125,7 +4125,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * if ( ASSETCHAINS_CBOPRET != 0 ) { pindexNew->nStatus &= ~BLOCK_FAILED_MASK; - fprintf(stderr,"reconsiderblock %d\n",(int32_t)pindexNew->nHeight); + fprintf(stderr,"reconsiderblock %d\n",(int32_t)pindexNew->GetHeight()); } } return error("ConnectTip(): ConnectBlock %s failed", pindexNew->GetBlockHash().ToString()); From 6b7f7d91aeb6a51d716f6aee0fcb39728d81bd5d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 23:01:10 -1100 Subject: [PATCH 3566/3904] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index be516c25d..1036670d6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4122,11 +4122,11 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * if (state.IsInvalid()) { InvalidBlockFound(pindexNew, state); - if ( ASSETCHAINS_CBOPRET != 0 ) + /*if ( ASSETCHAINS_CBOPRET != 0 ) { pindexNew->nStatus &= ~BLOCK_FAILED_MASK; fprintf(stderr,"reconsiderblock %d\n",(int32_t)pindexNew->GetHeight()); - } + }*/ } return error("ConnectTip(): ConnectBlock %s failed", pindexNew->GetBlockHash().ToString()); } From 7a739655e4b616ae4436559c5bf35718e6c35855 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 31 Mar 2019 23:07:55 -1100 Subject: [PATCH 3567/3904] Test --- src/komodo_gateway.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index be262b24f..60bf83006 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1687,6 +1687,10 @@ CScript komodo_mineropret(int32_t nHeight) The only way komodo_opretvalidate() doesnt return an error is if maxflag is set or it is within tolerance of both the prior block and the local data. The local data validation only happens if it is a recent block and not a block from the past as the local node is only getting the current price data. */ +// reconsiderblock 002aca768b09dfcf36bd934ab34b23983148b116e12cb0b6e1a3f895d1db63aa +// and +// reconsiderblock 0034cf582018eacc0b4ae001491ce460113514cb1a3f217567ef4a2207de361a +// are needed to sync past initial blocks with different data set int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { @@ -1714,12 +1718,12 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - /*if ( nHeight < 500 ) + if ( nHeight < 500 ) { for (i=0; i 500 ) - return(-1); + return(-1); } // else this is the good case we hope to happen } //else return(-1); if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) From 31580754dbd6b13c1c1bdfac909061ff33bb2674 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 02:30:27 -1100 Subject: [PATCH 3568/3904] Always do the clamp check --- src/komodo_gateway.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 60bf83006..c964f19ee 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1577,7 +1577,7 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) /* komodo_pricenew() is passed in a reference price, the change tolerance and the proposed price. it needs to return a clipped price if it is too big and also set a flag if it is at or above the limit */ -uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int64_t tolerance) +uint32_t komodo_pricenew(char *maxflagp,uint32_t price,uint32_t refprice,int64_t tolerance) { uint64_t highprice,lowprice; if ( refprice < 2 ) @@ -1612,13 +1612,12 @@ uint32_t komodo_pricenew(int32_t *maxflagp,uint32_t price,uint32_t refprice,int6 } // komodo_pricecmp() returns -1 if any of the prices are beyond the tolerance -int32_t komodo_pricecmp(int32_t nHeight,int32_t n,int32_t *maxflagp,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) +int32_t komodo_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) { int32_t i; uint32_t newprice; - *maxflagp = 0; for (i=1; i newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); return(-1); @@ -1646,7 +1645,7 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 // komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight CScript komodo_mineropret(int32_t nHeight) { - CScript opret; uint32_t pricebits[8192],prevbits[8192]; int32_t maxflag,i,n,numzero=0; + CScript opret; char maxflags[8192]; uint32_t pricebits[8192],prevbits[8192]; int32_t maxflag,i,n,numzero=0; if ( Mineropret.size() >= PRICES_SIZEBIT0 ) { n = (int32_t)(Mineropret.size() / sizeof(uint32_t)); @@ -1663,7 +1662,8 @@ CScript komodo_mineropret(int32_t nHeight) if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { memcpy(pricebits,Mineropret.data(),Mineropret.size()); - if ( komodo_pricecmp(0,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + memset(maxflags,0,sizeof(maxflags)); + if ( komodo_pricecmp(0,n,maxflags,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { // if the new prices are outside tolerance, update Mineropret with clamped prices komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE); @@ -1690,11 +1690,12 @@ CScript komodo_mineropret(int32_t nHeight) // reconsiderblock 002aca768b09dfcf36bd934ab34b23983148b116e12cb0b6e1a3f895d1db63aa // and // reconsiderblock 0034cf582018eacc0b4ae001491ce460113514cb1a3f217567ef4a2207de361a +// reconsiderbloc 000abf51c023b64af327c50c1b060797b8cb281c696d30ab92fd002a8b8c9aea // are needed to sync past initial blocks with different data set int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n,maxflag=0; uint32_t now = (uint32_t)time(NULL); + std::vector vopret; char maxflags[8192]; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1702,6 +1703,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { n = (int32_t)(vopret.size() / sizeof(uint32_t)); memcpy(pricebits,vopret.data(),Mineropret.size()); + memset(maxflags,0,sizeof(maxflags)); if ( nHeight > 1 ) { lag = (int32_t)(now - pricebits[0]); @@ -1724,7 +1726,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( pricebits[i] == 0 ) pricebits[i] = prevbits[i]; } - if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(nHeight,n,maxflags,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) { for (i=1; i Date: Mon, 1 Apr 2019 02:32:20 -1100 Subject: [PATCH 3569/3904] Maxflag --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c964f19ee..d90016ee4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1619,7 +1619,7 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *price { if ( (newprice= komodo_pricenew(&maxflags[i],pricebitsA[i],pricebitsB[i],tolerance)) != 0 ) { - fprintf(stderr,"ht.%d i.%d/%d %u vs %u -> newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,*maxflagp); + fprintf(stderr,"ht.%d i.%d/%d %u vs %u -> newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,maxflags[i]); return(-1); } } @@ -1695,7 +1695,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; char maxflags[8192]; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,lag,lag2,n; uint32_t now = (uint32_t)time(NULL); + std::vector vopret; char maxflags[8192]; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,maxflag,lag,lag2,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { GetOpReturnData(scriptPubKey,vopret); From a3c6ea84f9e14db1be10281f124d2f822f8b7525 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 02:34:02 -1100 Subject: [PATCH 3570/3904] 2048 --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d90016ee4..0b94ccda4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1629,10 +1629,10 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *price // komodo_priceclamp() clamps any price that is beyond tolerance int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int64_t tolerance) { - int32_t i,maxflag; uint32_t newprice; + int32_t i; uint32_t newprice; char maxflags[2048]; + memset(maxflags,0,sizeof(maxflags)); for (i=1; i %u\n",i,n,refprices[i],pricebits[i],newprice); @@ -1645,7 +1645,7 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 // komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight CScript komodo_mineropret(int32_t nHeight) { - CScript opret; char maxflags[8192]; uint32_t pricebits[8192],prevbits[8192]; int32_t maxflag,i,n,numzero=0; + CScript opret; char maxflags[2048]; uint32_t pricebits[2048],prevbits[2048]; int32_t maxflag,i,n,numzero=0; if ( Mineropret.size() >= PRICES_SIZEBIT0 ) { n = (int32_t)(Mineropret.size() / sizeof(uint32_t)); @@ -1695,7 +1695,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; char maxflags[8192]; double btcusd,btcgbp,btceur; uint32_t localbits[8192],pricebits[8192],prevbits[8192],newprice; int32_t i,maxflag,lag,lag2,n; uint32_t now = (uint32_t)time(NULL); + std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,maxflag,lag,lag2,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { GetOpReturnData(scriptPubKey,vopret); From 32c65f4686d999b11a419cf9a37ff6b25de90b04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 02:35:07 -1100 Subject: [PATCH 3571/3904] &maxflags[I] --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0b94ccda4..22952230e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1633,7 +1633,7 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 memset(maxflags,0,sizeof(maxflags)); for (i=1; i %u\n",i,n,refprices[i],pricebits[i],newprice); pricebits[i] = newprice; From 16eddc774c639f755a0f58497ddee700557958ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 03:06:38 -1100 Subject: [PATCH 3572/3904] Cleanup code --- src/komodo_gateway.h | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 22952230e..2f5dfc5c5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1738,36 +1738,26 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag); return(-1); } // else this is the good case we hope to happen - } //else return(-1); + } else return(-1); if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) { memcpy(localbits,Mineropret.data(),Mineropret.size()); - for (i=0; i 0 && localbits[i] < prevbits[i] ) - return(-1); - else if ( maxflag < 0 && localbits[i] > prevbits[i] ) - return(-1); - } + // make sure local price is moving in right direction + fprintf(stderr,"maxflag.%d i.%d localbits.%u vs pricebits.%u\n",maxflag,i,localbits[i],pricebits[i]); + if ( maxflag > 0 && localbits[i] < prevbits[i] ) + return(-1); + else if ( maxflag < 0 && localbits[i] > prevbits[i] ) + return(-1); } } } From 19f067493995ba4e8f864de7ac52dc03c62df9b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 04:22:00 -1100 Subject: [PATCH 3573/3904] Tweak print --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2f5dfc5c5..932efd051 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1692,6 +1692,8 @@ CScript komodo_mineropret(int32_t nHeight) // reconsiderblock 0034cf582018eacc0b4ae001491ce460113514cb1a3f217567ef4a2207de361a // reconsiderbloc 000abf51c023b64af327c50c1b060797b8cb281c696d30ab92fd002a8b8c9aea // are needed to sync past initial blocks with different data set +// pass in blockhash and nTime, latch if it is rejected due to local price, then if localprice changes in a way that would validate then issue reconsiderblock +// add rpc call for extracting rawprices int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) { @@ -1753,7 +1755,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) if ( (maxflag= maxflags[i]) != 0 ) { // make sure local price is moving in right direction - fprintf(stderr,"maxflag.%d i.%d localbits.%u vs pricebits.%u\n",maxflag,i,localbits[i],pricebits[i]); + fprintf(stderr,"maxflag.%d i.%d localbits.%u vs pricebits.%u prevbits.%u\n",maxflag,i,localbits[i],pricebits[i],prevbits[i]); if ( maxflag > 0 && localbits[i] < prevbits[i] ) return(-1); else if ( maxflag < 0 && localbits[i] > prevbits[i] ) From cf38e77da5fa12dc252f0f34ed930d2deae0a443 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 05:36:21 -1100 Subject: [PATCH 3574/3904] Change to 150000 activation --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 38f9041c1..eefccd32a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1237,7 +1237,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) + if ( height > 150000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) From b8cdcb25ba1676c60f39a14595e44d57ca7224dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 05:37:46 -1100 Subject: [PATCH 3575/3904] 150000 activation --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e76da09ec..d5d44bb3d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1234,7 +1234,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) + if ( height > 150000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) From bed1dd2d1ffc9eaaf96b0d37784a193c0963a61e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 05:38:52 -1100 Subject: [PATCH 3576/3904] 225k activation --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d5d44bb3d..d23dac77a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1234,7 +1234,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 150000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) + if ( height > 225000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) From 7b0a4efdca711257d1ce34cb80f43e10fdd216f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 05:39:18 -1100 Subject: [PATCH 3577/3904] 225k activation --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e76da09ec..d23dac77a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1234,7 +1234,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 100000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) + if ( height > 225000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) From fc12fd86d332edca0dfdd8cd36e9baad04945250 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 05:39:46 -1100 Subject: [PATCH 3578/3904] 225k activation --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index eefccd32a..e537df018 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1237,7 +1237,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) n = pblock->vtx[i].vout.size(); for (j=0; j 150000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) + if ( height > 225000 && ASSETCHAINS_STAKED != 0 && txn_count > 1 && i == txn_count-1 && j == n-1 ) break; //fprintf(stderr,"(%d %.8f).%d ",i,dstr(pblock->vtx[i].vout[j].nValue),j); if ( i != 0 || j != 1 ) From ddc0fb6de14f2f866c26175ba56ed650f42dc4f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 20:09:38 -1100 Subject: [PATCH 3579/3904] Check for lag2 --- src/komodo_gateway.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 932efd051..10c8718d9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1712,7 +1712,12 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); if ( lag < -60 ) // avoid data from future { - fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); + fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag); + return(-1); + } + if ( lag2 < 0 ) + { + fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag2.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); return(-1); } // else need to check against current blocktime to prevent pricebits[0] games From 5150bed539d194da8212b8e863b669341e6b03fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 20:16:42 -1100 Subject: [PATCH 3580/3904] Skip block 1 --- src/komodo_gateway.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 10c8718d9..b8a62792a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1706,7 +1706,7 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) n = (int32_t)(vopret.size() / sizeof(uint32_t)); memcpy(pricebits,vopret.data(),Mineropret.size()); memset(maxflags,0,sizeof(maxflags)); - if ( nHeight > 1 ) + if ( nHeight > 2 ) { lag = (int32_t)(now - pricebits[0]); lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); @@ -1720,7 +1720,6 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag2.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); return(-1); } - // else need to check against current blocktime to prevent pricebits[0] games btcusd = (double)pricebits[1]/10000; btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; From 5d1010c35ada8b091291814bc6a77fb974fdab78 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 20:28:33 -1100 Subject: [PATCH 3581/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b8a62792a..e8b33c073 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1712,12 +1712,12 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); if ( lag < -60 ) // avoid data from future { - fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag); + fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",nHeight,now,komodo_heightstamp(nHeight-1),pricebits[0],lag); return(-1); } if ( lag2 < 0 ) { - fprintf(stderr,"now.%u htstamp.%u - pricebits[0] %u -> lag2.%d\n",now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); + fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lag2.%d\n",nHeight,now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); return(-1); } btcusd = (double)pricebits[1]/10000; From 8a9eaea869704f6407855833989bf420e83254ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 20:40:26 -1100 Subject: [PATCH 3582/3904] Pass through block and previndex --- src/komodo_gateway.h | 19 +++++++++++++------ src/main.cpp | 12 ++++++------ src/main.h | 2 +- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e8b33c073..724525795 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1695,9 +1695,9 @@ CScript komodo_mineropret(int32_t nHeight) // pass in blockhash and nTime, latch if it is rejected due to local price, then if localprice changes in a way that would validate then issue reconsiderblock // add rpc call for extracting rawprices -int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) +int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,maxflag,lag,lag2,n; uint32_t now = (uint32_t)time(NULL); + std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,prevtime,maxflag,lag,lag2,lag3,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1708,16 +1708,23 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey) memset(maxflags,0,sizeof(maxflags)); if ( nHeight > 2 ) { + prevtime = previndex->nTime; lag = (int32_t)(now - pricebits[0]); - lag2 = (int32_t)(komodo_heightstamp(nHeight-1) - pricebits[0]); + lag2 = (int32_t)(pricebits[0] - prevtime); + lag3 = (int32_t)(block->nTime - pricebits[0]); if ( lag < -60 ) // avoid data from future { - fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lag.%d\n",nHeight,now,komodo_heightstamp(nHeight-1),pricebits[0],lag); + fprintf(stderr,"ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < 0 ) + if ( lag2 < 0 ) // must be after last block timestamp { - fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lag2.%d\n",nHeight,now,komodo_heightstamp(nHeight-1),pricebits[0],lag2); + fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); + return(-1); + } + if ( lag3 < -60 || lag > ASSETCHAINS_BLOCKTIME ) + { + fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } btcusd = (double)pricebits[1]/10000; diff --git a/src/main.cpp b/src/main.cpp index 1036670d6..a037bd828 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -977,7 +977,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in * Ensure that a coinbase transaction is structured according to the consensus rules of the * chain */ -bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeight) +bool ContextualCheckCoinbaseTransaction(const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight) { // if time locks are on, ensure that this coin base is time locked exactly as it should be if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || @@ -1020,7 +1020,7 @@ bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeigh } else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 ) { - if ( komodo_opretvalidate(nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) + if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) return(false); } return(true); @@ -1035,7 +1035,7 @@ bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeigh * and ContextualCheckBlock (which calls this function). * 3. The isInitBlockDownload argument is only to assist with testing. */ -bool ContextualCheckTransaction( +bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const previndex, const CTransaction& tx, CValidationState &state, const int nHeight, @@ -1171,7 +1171,7 @@ bool ContextualCheckTransaction( if (tx.IsCoinBase()) { - if (!ContextualCheckCoinbaseTransaction(tx, nHeight)) + if (!ContextualCheckCoinbaseTransaction(block,previndex,tx, nHeight)) return state.DoS(100, error("CheckTransaction(): invalid script data for coinbase time lock"), REJECT_INVALID, "bad-txns-invalid-script-data-for-coinbase-time-lock"); } @@ -1679,7 +1679,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // DoS level set to 10 to be more forgiving. // Check transaction contextually against the set of consensus rules which apply in the next block to be mined. - if (!fSkipExpiry && !ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) + if (!fSkipExpiry && !ContextualCheckTransaction(0,0,tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } @@ -5173,7 +5173,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn const CTransaction& tx = block.vtx[i]; // Check transaction contextually against consensus rules at block height - if (!ContextualCheckTransaction(tx, state, nHeight, 100)) { + if (!ContextualCheckTransaction(&block,pindexPrev,tx, state, nHeight, 100)) { return false; // Failure reason has been set in validation state object } diff --git a/src/main.h b/src/main.h index f12bcb8cd..0cdb0b7a8 100644 --- a/src/main.h +++ b/src/main.h @@ -706,7 +706,7 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons std::vector *pvChecks = NULL); /** Check a transaction contextually against a set of consensus rules */ -bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, int nHeight, int dosLevel, +bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const pindexPrev,const CTransaction& tx, CValidationState &state, int nHeight, int dosLevel, bool (*isInitBlockDownload)() = IsInitialBlockDownload); /** Apply the effects of this transaction on the UTXO set represented by view */ From c8d70aa804dbaf58dee13fd01f5bc7fdd586c1ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 20:49:11 -1100 Subject: [PATCH 3583/3904] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 724525795..1661e3225 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1714,17 +1714,17 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i lag3 = (int32_t)(block->nTime - pricebits[0]); if ( lag < -60 ) // avoid data from future { - fprintf(stderr,"ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); + fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } if ( lag2 < 0 ) // must be after last block timestamp { - fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); + fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } if ( lag3 < -60 || lag > ASSETCHAINS_BLOCKTIME ) { - fprintf(stderr,"ht.%d now.%u htstamp.%u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); + fprintf(stderr,"C ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } btcusd = (double)pricebits[1]/10000; From b1e8644e050a35b3f1a0a4ab703d0d28b520cdee Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 21:30:32 -1100 Subject: [PATCH 3584/3904] testchain_exemption = 500 --- src/komodo_gateway.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1661e3225..847c50248 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1697,6 +1697,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { + int32_t testchain_exemption = 500; std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,prevtime,maxflag,lag,lag2,lag3,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { @@ -1720,9 +1721,10 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i if ( lag2 < 0 ) // must be after last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); - return(-1); + if ( nHeight > testchain_exemption ) + return(-1); } - if ( lag3 < -60 || lag > ASSETCHAINS_BLOCKTIME ) + if ( lag3 < -60 || lag3 > ASSETCHAINS_BLOCKTIME ) { fprintf(stderr,"C ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); @@ -1733,7 +1735,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) { - if ( nHeight < 500 ) + if ( nHeight < testchain_exemption ) { for (i=0; i= PRICES_SIZEBIT0 ) { memcpy(localbits,Mineropret.data(),Mineropret.size()); - if ( nHeight < 500 ) + if ( nHeight < testchain_exemption ) { for (i=0; i Date: Mon, 1 Apr 2019 21:33:39 -1100 Subject: [PATCH 3585/3904] if ( nHeight > testchain_exemption ) --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 847c50248..100dd2a57 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1727,7 +1727,8 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i if ( lag3 < -60 || lag3 > ASSETCHAINS_BLOCKTIME ) { fprintf(stderr,"C ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); - return(-1); + if ( nHeight > testchain_exemption ) + return(-1); } btcusd = (double)pricebits[1]/10000; btcgbp = (double)pricebits[2]/10000; From 034479cf780eedac9f53774dffdd2832d0482592 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 21:37:18 -1100 Subject: [PATCH 3586/3904] 506 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 100dd2a57..3f90b4b60 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1697,7 +1697,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 500; + int32_t testchain_exemption = 506; std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,prevtime,maxflag,lag,lag2,lag3,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { From 244c924fe1343dcba2cf26e565a146e86db7db60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 21:49:56 -1100 Subject: [PATCH 3587/3904] Allow more variance from prev timestamp --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3f90b4b60..9452b62ed 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1697,7 +1697,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 506; + int32_t testchain_exemption = 350; std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,prevtime,maxflag,lag,lag2,lag3,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { @@ -1718,7 +1718,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < 0 ) // must be after last block timestamp + if ( lag2 < -ASSETCHAINS_BLOCKTIME ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); if ( nHeight > testchain_exemption ) From 698ea547d0351caa20f63ac5a8c712cd3bbf92bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 21:53:49 -1100 Subject: [PATCH 3588/3904] +print --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9452b62ed..3ed1cab49 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1720,7 +1720,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( lag2 < -ASSETCHAINS_BLOCKTIME ) // must be close to last block timestamp { - fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); + fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) return(-1); } From 3a9b1492000f316135b6f46fd508e85b967c7f89 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 21:57:23 -1100 Subject: [PATCH 3589/3904] int32_t --- src/bitcoind.cpp | 2 +- src/chainparams.cpp | 2 +- src/komodo_defs.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 0afb47894..b65fcf1a9 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -59,7 +59,7 @@ static bool fDaemon; #include "komodo_defs.h" #define KOMODO_ASSETCHAIN_MAXLEN 65 extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern uint32_t ASSETCHAINS_BLOCKTIME; +extern int32_t ASSETCHAINS_BLOCKTIME; extern uint64_t ASSETCHAINS_CBOPRET; void komodo_passport_iteration(); uint64_t komodo_interestsum(); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6bfcc0e5c..26e29d9de 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -91,7 +91,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st */ void *chainparams_commandline(void *ptr); #include "komodo_defs.h" -uint32_t ASSETCHAINS_BLOCKTIME = 60; +int32_t ASSETCHAINS_BLOCKTIME = 60; const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 0f053f6ca..b0f618e93 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -42,8 +42,8 @@ extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC,ASSETCHAINS_BLOCKTIME; -extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; +extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; +extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,ASSETCHAINS_BLOCKTIME; extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD; extern uint64_t ASSETCHAINS_TIMELOCKGTE; From d464a48a0d6aba57bcaf880ff28391f09fc07146 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 22:11:26 -1100 Subject: [PATCH 3590/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3ed1cab49..52d9f0776 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1718,7 +1718,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < -ASSETCHAINS_BLOCKTIME ) // must be close to last block timestamp + if ( lag2 < -60 )//-ASSETCHAINS_BLOCKTIME/2 ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) From 79dab848b4b73a652e7a81aa9b36047a6b096872 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 22:16:21 -1100 Subject: [PATCH 3591/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 52d9f0776..7624a57d5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1718,7 +1718,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < -60 )//-ASSETCHAINS_BLOCKTIME/2 ) // must be close to last block timestamp + if ( lag2 < -63 )//-ASSETCHAINS_BLOCKTIME/2 ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) From cbd4c636d4ea16550b2bcbef5d79d5848803368d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 22:17:59 -1100 Subject: [PATCH 3592/3904] -120 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7624a57d5..7e1ede5d5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1718,7 +1718,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < -63 )//-ASSETCHAINS_BLOCKTIME/2 ) // must be close to last block timestamp + if ( lag2 < -120 )//-ASSETCHAINS_BLOCKTIME/2 ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) From 175d0fa4a6f78d75d3d493f0b596fb9fb59c0811 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 22:19:33 -1100 Subject: [PATCH 3593/3904] 500 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7e1ede5d5..401199837 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1697,7 +1697,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 350; + int32_t testchain_exemption = 500; std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,prevtime,maxflag,lag,lag2,lag3,n; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { From c90448edbae897f41dca1225d240656ecfec5135 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 1 Apr 2019 23:09:51 -1100 Subject: [PATCH 3594/3904] prices rpc call stub --- src/komodo_gateway.h | 26 ++++++++++---- src/rpc/blockchain.cpp | 80 ++++++++++++++++++++++++++++++++---------- src/rpc/server.cpp | 1 + src/rpc/server.h | 2 ++ 4 files changed, 84 insertions(+), 25 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 401199837..a59e47a04 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1553,7 +1553,7 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR // komodo_heightpricebits() extracts the price data in the coinbase for nHeight -int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) +int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight) { CBlockIndex *pindex; CBlock block; CTransaction tx; int32_t numvouts; std::vector vopret; if ( (pindex= komodo_chainactive(nHeight)) != 0 ) @@ -1565,8 +1565,8 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) { - memcpy(prevbits,vopret.data(),vopret.size()); - return(0); + memcpy(heightbits,vopret.data(),vopret.size()); + return((int32_t)(vopret.size()/sizeof(uint32_t))); } } } @@ -1574,6 +1574,20 @@ int32_t komodo_heightpricebits(uint32_t prevbits[4],int32_t nHeight) return(-1); } +int32_t komodo_prices(uint32_t *prices,uint32_t *correlated,uint32_t *smoothed,int32_t height) +{ + int32_t i,n; + n = komodo_heightpricebits(prices,height); + for (i=0; i 0 ) { memcpy(pricebits,Mineropret.data(),Mineropret.size()); memset(maxflags,0,sizeof(maxflags)); @@ -1718,7 +1732,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < -120 )//-ASSETCHAINS_BLOCKTIME/2 ) // must be close to last block timestamp + if ( lag2 < -testchain_exemption ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) @@ -1734,7 +1748,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); - if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 ) + if ( komodo_heightpricebits(prevbits,nHeight-1) > 0 ) { if ( nHeight < testchain_exemption ) { diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6dac120e4..fc9ec5f7a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1174,38 +1174,80 @@ UniValue paxprice(const UniValue& params, bool fHelp) return ret; } -UniValue paxprices(const UniValue& params, bool fHelp) +int32_t komodo_prices(uint32_t *prices,uint32_t *correlated,uint32_t *smoothed,int32_t height); + +UniValue prices(const UniValue& params, bool fHelp) { - if ( fHelp || params.size() != 3 ) - throw runtime_error("paxprices \"base\" \"rel\" maxsamples\n"); + if ( fHelp || params.size() != 1 ) + throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t relvolume,prices[4096]; uint32_t i,n; int32_t heights[sizeof(prices)/sizeof(*prices)]; - std::string base = params[0].get_str(); - std::string rel = params[1].get_str(); - int32_t maxsamples = atoi(params[2].get_str().c_str()); + UniValue ret(UniValue::VOBJ); uint32_t *prices,*correlated,*smoothed; uint32_t i,firstn=-1,n,nextheight,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + int32_t maxsamples = atoi(params[0].get_str().c_str()); if ( maxsamples < 1 ) maxsamples = 1; else if ( maxsamples > sizeof(heights)/sizeof(*heights) ) maxsamples = sizeof(heights)/sizeof(*heights); - ret.push_back(Pair("base", base)); - ret.push_back(Pair("rel", rel)); - n = komodo_paxprices(heights,prices,maxsamples,(char *)base.c_str(),(char *)rel.c_str()); + nextheight = komodo_nextheight(); UniValue a(UniValue::VARR); - for (i=0; idaywindow+2; i++,ht--) { - UniValue item(UniValue::VOBJ); - if ( heights[i] < 0 || heights[i] > chainActive.Height() ) + if ( ht < 0 || ht > chainActive.Height() ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); else { - CBlockIndex *pblockindex = chainActive[heights[i]]; - - item.push_back(Pair("t", (int64_t)pblockindex->nTime)); - item.push_back(Pair("p", (double)prices[i] / COIN)); - a.push_back(item); + if ( (n= komodo_prices(rawprices,ht)) > 0 ) + { + if ( firstn == -1 ) + firstn = n; + else if ( n != firstn ) + throw JSONRPCError(RPC_INVALID_PARAMETER, "numprices != first numprices"); + else + { + for (j=0; j Date: Tue, 2 Apr 2019 00:08:01 -1100 Subject: [PATCH 3595/3904] KOMODO_LOCALPRICE_CACHESIZE --- src/bitcoind.cpp | 4 +- src/komodo_gateway.h | 176 ++++++++++++++++++++++++++++++++--------- src/komodo_utils.h | 4 +- src/rpc/blockchain.cpp | 82 ++++++++++--------- 4 files changed, 187 insertions(+), 79 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index b65fcf1a9..4e010d28e 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -64,7 +64,7 @@ extern uint64_t ASSETCHAINS_CBOPRET; void komodo_passport_iteration(); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -void komodo_cbopretupdate(); +void komodo_cbopretupdate(int32_t forceflag); void WaitForShutdown(boost::thread_group* threadGroup) { @@ -89,7 +89,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) //komodo_interestsum(); //komodo_longestchain(); if ( ASSETCHAINS_CBOPRET != 0 ) - komodo_cbopretupdate(); + komodo_cbopretupdate(0); for (i=0; i<=ASSETCHAINS_BLOCKTIME/5; i++) { fShutdown = ShutdownRequested(); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a59e47a04..6035cf82f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1551,6 +1551,15 @@ void komodo_passport_iteration() extern std::vector Mineropret; // opreturn data set by the data gathering code #define PRICES_MAXCHANGE (COIN / 100) // maximum acceptable change, set at 1% #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR +#define KOMODO_LOCALPRICE_CACHESIZE 7 +uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)]; + +void komodo_PriceCache_shift() +{ + int32_t i; + for (i=KOMODO_LOCALPRICE_CACHESIZE-1; i>=0; i--) + memcpy(PriceCache[i],PriceCache[i-1],sizeof(PriceCache[i])); +} // komodo_heightpricebits() extracts the price data in the coinbase for nHeight int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight) @@ -1574,20 +1583,6 @@ int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight) return(-1); } -int32_t komodo_prices(uint32_t *prices,uint32_t *correlated,uint32_t *smoothed,int32_t height) -{ - int32_t i,n; - n = komodo_heightpricebits(prices,height); - for (i=0; i vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,prevtime,maxflag,lag,lag2,lag3,n; uint32_t now = (uint32_t)time(NULL); + std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1778,16 +1773,48 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i if ( localbits[i] == 0 ) localbits[i] = prevbits[i]; } - for (i=1; i 0 && localbits[i] < prevbits[i] ) - return(-1); - else if ( maxflag < 0 && localbits[i] > prevbits[i] ) - return(-1); + if ( (maxflag= maxflags[i]) != 0 ) + { + // make sure local price is moving in right direction + fprintf(stderr,"maxflag.%d i.%d localbits.%u vs pricebits.%u prevbits.%u\n",maxflag,i,localbits[i],pricebits[i],prevbits[i]); + if ( maxflag > 0 && localbits[i] < prevbits[i] ) + { + if ( iter == 0 ) + break; + // second iteration checks recent prices to see if within local volatility + for (j=0; j= prevbits[i] ) + { + fprintf(stderr,"within recent localprices[%d] %u >= %u\n",j,PriceCache[j][i],prevbits[i]); + continue; + } + break; + } + else if ( maxflag < 0 && localbits[i] > prevbits[i] ) + { + if ( iter == 0 ) + break; + for (j=0; j 333 ) - ASSETCHAINS_CBOPRET = 7; +if ( komodo_nextheight() > 333 ) // for debug only! + ASSETCHAINS_CBOPRET = 7; size = PRICES_SIZEBIT0; if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) size += sizeof(forexprices); @@ -2076,31 +2104,48 @@ void komodo_cbopretupdate() if ( Mineropret.size() < size ) Mineropret.resize(size); size = PRICES_SIZEBIT0; - if ( now > lastbtc+120 && get_btcusd(pricebits) == 0 ) + if ( (forceflag != 0 || now > lastbtc+120) && get_btcusd(pricebits) == 0 ) { - memcpy(Mineropret.data(),pricebits,PRICES_SIZEBIT0); - lastbtc = (uint32_t)time(NULL); + if ( flags == 0 ) + komodo_PriceCache_shift(); + memcpy(PriceCache[0],pricebits,PRICES_SIZEBIT0); + flags |= 1; } if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) { - if ( now > lasttime+3600*5 || forexprices[0] == 0 ) + if ( now > lasttime+3600*5 || forexprices[0] == 0 ) // cant assume timestamp is valid for forex price as it is a daily weekday changing thing anyway. { get_dailyfx(forexprices); - memcpy(&Mineropret.data()[size],forexprices,sizeof(forexprices)); - lasttime = (uint32_t)time(NULL); + if ( flags == 0 ) + komodo_PriceCache_shift(); + flags |= 2; + memcpy(&PriceCache[0][size],forexprices,sizeof(forexprices)); } size += sizeof(forexprices); } if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) { - if ( now > lastcrypto+100 ) + if ( forceflag != 0 || flags != 0 ) { get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); - memcpy(&Mineropret.data()[size],cryptoprices,sizeof(cryptoprices)); - lastcrypto = (uint32_t)time(NULL); + if ( flags == 0 ) + komodo_PriceCache_shift(); + memcpy(&PriceCache[0][size],cryptoprices,sizeof(cryptoprices)); + flags |= 4; // very rarely we can see flags == 6 case } size += sizeof(cryptoprices); } + if ( flags != 0 ) + { + now = (uint32_t)time(NULL); + if ( (flags & 1) != 0 ) + lastbtc = now; + if ( (flags & 2) != 0 ) + lasttime = now; + if ( (flags & 4) != 0 ) + lastcrypto = now; + memcpy(Mineropret.data(),PriceCache[0],size); + } //int32_t i; for (i=0; i sizeof(heights)/sizeof(*heights) ) - maxsamples = sizeof(heights)/sizeof(*heights); nextheight = komodo_nextheight(); UniValue a(UniValue::VARR); + if ( daywindow < 7 ) + daywindow = 7; prices = (uint32_t *)calloc(sizeof(*prices),maxsamples+daywindow); correlated = (uint32_t *)calloc(sizeof(*correlated),maxsamples+daywindow); smoothed = (uint32_t *)calloc(sizeof(*smoothed),maxsamples+daywindow); @@ -1198,7 +1201,7 @@ UniValue prices(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); else { - if ( (n= komodo_prices(rawprices,ht)) > 0 ) + if ( (n= komodo_heightpricebits(rawprices,ht)) > 0 ) { if ( firstn == -1 ) firstn = n; @@ -1212,42 +1215,45 @@ UniValue prices(const UniValue& params, bool fHelp) } else throw JSONRPCError(RPC_INVALID_PARAMETER, "no komodo_rawprices found"); } } + for (i=0; i Date: Tue, 2 Apr 2019 00:10:28 -1100 Subject: [PATCH 3596/3904] Rearrange --- src/komodo_gateway.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6035cf82f..ccc1e05ce 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1552,6 +1552,16 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define PRICES_MAXCHANGE (COIN / 100) // maximum acceptable change, set at 1% #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR #define KOMODO_LOCALPRICE_CACHESIZE 7 + + +#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) + +const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "DASH", "XEM", "ZEC", "WAVES", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" }; // must be on binance (for now) + +const char *Forex[] = +{ "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" +}; // must be in ECB list + uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)]; void komodo_PriceCache_shift() @@ -1923,13 +1933,6 @@ cJSON *send_curl(char *url,char *fname) // get_urljson just returns the JSON returned by the URL using issue_curl -#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) - -const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "DASH", "XEM", "ZEC", "WAVES", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" }; - -const char *Forex[] = -{ "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" -}; /* const char *Techstocks[] = From aa2f4d910926f9d6f71fce28f306ad55131802e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 00:14:47 -1100 Subject: [PATCH 3597/3904] Arr --- src/rpc/blockchain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 20a2a8ac2..29979a489 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1178,6 +1178,8 @@ int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); uint32_t komodo_pricesmoothed(uint32_t *correlatedp,uint32_t *rawprices,int32_t numprices); uint32_t komodo_timestampset(uint32_t *correlatedp,uint32_t *rawprices,int32_t numprices); +int32_t komodo_nextheight(); +uint32_t komodo_heightstamp(int32_t height); UniValue prices(const UniValue& params, bool fHelp) { @@ -1237,9 +1239,9 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*(maxsamples+daywindow) + i; smoothed[offset] = komodo_pricesmoothed(&correlated[offset],&rawprices[offset],daywindow); UniValue parr(UniValue::VARR); - parr.push_back((double)prices[offset]/10000.); - parr.push_back((double)correlated[offset]/10000.); - parr.push_back((double)smoothed[offset]/10000.); + parr.push_back((uint64_t)prices[offset]); + parr.push_back((uint64_t)correlated[offset]); + parr.push_back((uint64_t)smoothed[offset]); prices.push_back(parr); } item.push_back(Pair("prices",prices)); From fa309e5b0e84c9287556234784d3abce1198c713 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Apr 2019 19:14:51 +0800 Subject: [PATCH 3598/3904] Add context flag to stop checking twice --- src/chain.h | 5 ++++- src/main.cpp | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/chain.h b/src/chain.h index ee56c7662..d810ed4cb 100644 --- a/src/chain.h +++ b/src/chain.h @@ -102,6 +102,9 @@ enum BlockStatus: uint32_t { //! Scripts & signatures ok. Implies all parents are also at least SCRIPTS. BLOCK_VALID_SCRIPTS = 5, + // flag to check if contextual check block has passed in Accept block, if it has not check at connect block. + BLOCK_VALID_CONTEXT = 6, + //! All validity bits. BLOCK_VALID_MASK = BLOCK_VALID_HEADER | BLOCK_VALID_TREE | BLOCK_VALID_TRANSACTIONS | BLOCK_VALID_CHAIN | BLOCK_VALID_SCRIPTS, @@ -115,7 +118,7 @@ enum BlockStatus: uint32_t { BLOCK_FAILED_MASK = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD, BLOCK_ACTIVATES_UPGRADE = 128, //! block activates a network upgrade - BLOCK_IN_TMPFILE = 256 + BLOCK_IN_TMPFILE = 256 }; //! Short-hand for the highest consensus validity we implement. diff --git a/src/main.cpp b/src/main.cpp index 20a963287..e8fe3810c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3274,14 +3274,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; } - // check pindex->CONTEXT_VALIDATED flag - if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019 + if ( fCheckPOW != 0 && (pindex->nStatus & BLOCK_VALID_CONTEXT) != BLOCK_VALID_CONTEXT ) // Activate Jan 15th, 2019 { - fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); - if ( pindex->nTime > 1547510400 ) - return false; - fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); + if ( !ContextualCheckBlock(block, state, pindex->pprev) ) + { + fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight()); + if ( pindex->nTime > 1547510400 ) + return false; + fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); + } else pindex->nStatus |= BLOCK_VALID_CONTEXT; } + // Do this here before the block is moved to the main block files. if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) { @@ -5340,7 +5343,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // See method docstring for why this is always disabled auto verifier = libzcash::ProofVerifier::Disabled(); - if ((!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev)) + bool fContextualCheckBlock = ContextualCheckBlock(block, state, pindex->pprev); + if ( (!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !fContextualCheckBlock ) { static int32_t saplinght = -1; CBlockIndex *tmpptr; @@ -5365,6 +5369,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C return false; } } + if ( fContextualCheckBlock ) + pindex->nStatus |= BLOCK_VALID_CONTEXT; int nHeight = pindex->GetHeight(); // Temp File fix. LABS has been using this for ages with no bad effects. From a29c2f179ea0545ce05b583cc7a925ab7681a6df Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 00:29:03 -1100 Subject: [PATCH 3599/3904] Test --- src/komodo_gateway.h | 12 +++++++---- src/rpc/blockchain.cpp | 46 +++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ccc1e05ce..021abbd60 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2213,14 +2213,18 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } -uint32_t komodo_timestampset(uint32_t *correlatedp,uint32_t *rawtimestamps,int32_t numtimestamps) +int64_t komodo_timestampset(int64_t *correlatedp,uint32_t *rawtimestamps,int32_t numtimestamps) { *correlatedp = rawtimestamps[0]; - return(rawtimestamps[0]); // really to do this would need to do it on a per pricefeed and which prices were used in the correlation, but that is a lot of extra work for a field which is not critical + return(*correlatedp); // really to do this would need to do it on a per pricefeed and which prices were used in the correlation, but that is a lot of extra work for a field which is not critical } -uint32_t komodo_pricesmoothed(uint32_t *correlatedp,uint32_t *rawprices,int32_t numprices) +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) { - + return(0); } +int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices) +{ + return(0); +} diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 29979a489..01939bb7d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1176,8 +1176,9 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -uint32_t komodo_pricesmoothed(uint32_t *correlatedp,uint32_t *rawprices,int32_t numprices); -uint32_t komodo_timestampset(uint32_t *correlatedp,uint32_t *rawprices,int32_t numprices); +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices); +int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices); +int64_t komodo_timestampset(int64_t *correlatedp,uint32_t *rawprices,int32_t numprices); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1186,7 +1187,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); char name[64],*str; uint32_t rawprices[2048],*prices,*correlated,*smoothed; uint32_t i,j,firstn=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + UniValue ret(UniValue::VOBJ); int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices; uint32_t i,width,j,firstn=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; int32_t maxsamples = atoi(params[0].get_str().c_str()); if ( maxsamples < 1 ) maxsamples = 1; @@ -1194,10 +1195,11 @@ UniValue prices(const UniValue& params, bool fHelp) UniValue a(UniValue::VARR); if ( daywindow < 7 ) daywindow = 7; - prices = (uint32_t *)calloc(sizeof(*prices),maxsamples+daywindow); - correlated = (uint32_t *)calloc(sizeof(*correlated),maxsamples+daywindow); - smoothed = (uint32_t *)calloc(sizeof(*smoothed),maxsamples+daywindow); - for (ht=nextheight-1,i=0; idaywindow+2; i++,ht--) + width = maxsamples+2*daywindow; + prices = (uint32_t *)calloc(sizeof(*prices),width); + correlated = (int64_t *)calloc(sizeof(*correlated),width); + //smoothed = (uint32_t *)calloc(sizeof(*smoothed),width); + for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); @@ -1212,7 +1214,7 @@ UniValue prices(const UniValue& params, bool fHelp) else { for (j=0; j Date: Tue, 2 Apr 2019 00:55:09 -1100 Subject: [PATCH 3600/3904] Fix --- src/komodo_gateway.h | 21 +++++++++++++-------- src/rpc/blockchain.cpp | 36 ++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 021abbd60..450f42aeb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2213,18 +2213,23 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } -int64_t komodo_timestampset(int64_t *correlatedp,uint32_t *rawtimestamps,int32_t numtimestamps) -{ - *correlatedp = rawtimestamps[0]; - return(*correlatedp); // really to do this would need to do it on a per pricefeed and which prices were used in the correlation, but that is a lot of extra work for a field which is not critical -} - int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) { - return(0); + int32_t i; + for (i=0; i2*daywindow+2; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) @@ -1207,9 +1208,7 @@ UniValue prices(const UniValue& params, bool fHelp) { if ( (n= komodo_heightpricebits(rawprices,ht)) > 0 ) { - if ( firstn == -1 ) - firstn = n; - else if ( n != firstn ) + if ( n != numpricefeeds ) throw JSONRPCError(RPC_INVALID_PARAMETER, "numprices != first numprices"); else { @@ -1222,15 +1221,12 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 00:56:12 -1100 Subject: [PATCH 3601/3904] uint32_t price; --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 450f42aeb..578b36cd6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2224,7 +2224,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices) { - int64_t sum = 0; uint32_t price; + int32_t i; uint32_t price; int64_t sum = 0; for (i=0; i Date: Tue, 2 Apr 2019 00:58:55 -1100 Subject: [PATCH 3602/3904] daywindow --- src/rpc/blockchain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 09c297ab9..bc8df8132 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1187,6 +1187,9 @@ UniValue prices(const UniValue& params, bool fHelp) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); UniValue ret(UniValue::VOBJ); int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + if ( ASSETCHAINS_CBOPRET == 0 ) + throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); + int32_t maxsamples = atoi(params[0].get_str().c_str()); if ( maxsamples < 1 ) maxsamples = 1; @@ -1256,7 +1259,7 @@ UniValue prices(const UniValue& params, bool fHelp) ret.push_back(Pair("height",(int64_t)nextheight-1)); ret.push_back(Pair("maxsamples",(int64_t)maxsamples)); ret.push_back(Pair("width",(int64_t)width)); - ret.push_back(Pair("daywidth",(int64_t)daywidth)); + ret.push_back(Pair("daywindow",(int64_t)daywindow)); ret.push_back(Pair("numpricefeeds",(int64_t)numpricefeeds)); free(prices); free(correlated); From ef41124c631d401166bbbd1899e5d01b0650ec98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 01:06:00 -1100 Subject: [PATCH 3603/3904] +print --- src/rpc/blockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bc8df8132..6485bc2cc 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1235,6 +1235,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( (str= komodo_pricename(name,j)) != 0 ) { item.push_back(Pair("name",str)); + fprintf(stderr,"%s from %d to %d width.%d\n",name,j*width,j*width+maxsamples+daywindow,width); for (i=0; i Date: Tue, 2 Apr 2019 01:11:41 -1100 Subject: [PATCH 3604/3904] Fix off by one in PriceCache copy --- src/komodo_gateway.h | 8 ++++++-- src/rpc/blockchain.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 578b36cd6..c780306d0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1567,8 +1567,12 @@ uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][4+sizeof(Cryptos)/sizeof(*Crypt void komodo_PriceCache_shift() { int32_t i; - for (i=KOMODO_LOCALPRICE_CACHESIZE-1; i>=0; i--) + for (i=KOMODO_LOCALPRICE_CACHESIZE-1; i>0; i--) + { memcpy(PriceCache[i],PriceCache[i-1],sizeof(PriceCache[i])); + //for (j=0; j<4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex); j++) + // PriceCache[i][j] = PriceCache[i-1][j]; + } } // komodo_heightpricebits() extracts the price data in the coinbase for nHeight @@ -1787,7 +1791,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i { for (i=1; i Date: Tue, 2 Apr 2019 01:16:42 -1100 Subject: [PATCH 3605/3904] NOT raw prices, that is just single blocks data --- src/komodo_gateway.h | 2 ++ src/rpc/blockchain.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c780306d0..a78927c05 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2199,6 +2199,7 @@ char *komodo_pricename(char *name,int32_t ind) if ( ind < sizeof(Forex)/sizeof(*Forex) ) { strcpy(name,Forex[ind]); + strcat(name,"USD"); return(name); } else ind -= sizeof(Forex)/sizeof(*Forex); } @@ -2209,6 +2210,7 @@ char *komodo_pricename(char *name,int32_t ind) if ( ind < sizeof(Cryptos)/sizeof(*Cryptos) ) { strcpy(name,Cryptos[ind]); + strcat(name,"BTC"); return(name); } else ind -= sizeof(Cryptos)/sizeof(*Cryptos); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 52a56f1ac..2ee802fb3 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1224,7 +1224,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 01:19:26 -1100 Subject: [PATCH 3606/3904] Test --- src/rpc/blockchain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 2ee802fb3..a1beefefd 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1231,7 +1231,7 @@ UniValue prices(const UniValue& params, bool fHelp) } for (j=1; j Date: Tue, 2 Apr 2019 01:20:34 -1100 Subject: [PATCH 3607/3904] Double --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a1beefefd..ac1690634 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1246,7 +1246,7 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back((double)prices[offset]/10000); + parr.push_back((double)(prices[offset]/10000)); parr.push_back(ValueFromAmount(correlated[i])); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); From f6232685cd04397b681e97e9a4a4e804a0dd78eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 01:21:19 -1100 Subject: [PATCH 3608/3904] Cons --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ac1690634..550217e2d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1246,7 +1246,7 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back((double)(prices[offset]/10000)); + parr.push_back(ValueFromAmount(prices[offset]*10000)); parr.push_back(ValueFromAmount(correlated[i])); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); From d93b34b04a92360a531bc941a6bbea9b90232c96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 01:25:45 -1100 Subject: [PATCH 3609/3904] Test --- src/komodo_gateway.h | 2 ++ src/rpc/blockchain.cpp | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a78927c05..6b8df1834 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2235,7 +2235,9 @@ int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices) { if ( (price= rawprices[i]) == 0 ) return(0); + fprintf(stderr,"%.4f ",(double)price/10000); sum += price * 10000; } + fprintf(stderr," ave %.8f [%d]\n",((double)sum/numprices)/COIN,numprices); return(sum / numprices); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 550217e2d..8a2752088 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1229,13 +1229,12 @@ UniValue prices(const UniValue& params, bool fHelp) ret.push_back(Pair("timestamps",timestamps)); ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); } - for (j=1; j Date: Tue, 2 Apr 2019 01:29:54 -1100 Subject: [PATCH 3610/3904] Limit copy range --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 8a2752088..a748e63c4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1203,7 +1203,7 @@ UniValue prices(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "illegal numpricefeeds"); prices = (uint32_t *)calloc(sizeof(*prices),width*numpricefeeds); correlated = (int64_t *)calloc(sizeof(*correlated),width); - for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) + for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); From 61e193953fa380ccb41fb22c786d80972e987a8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 01:33:28 -1100 Subject: [PATCH 3611/3904] Cross copy --- src/rpc/blockchain.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a748e63c4..c1eb1bac6 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1203,7 +1203,7 @@ UniValue prices(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "illegal numpricefeeds"); prices = (uint32_t *)calloc(sizeof(*prices),width*numpricefeeds); correlated = (int64_t *)calloc(sizeof(*correlated),width); - for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) + for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); @@ -1215,8 +1215,12 @@ UniValue prices(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "numprices != first numprices"); else { - for (j=0; j Date: Tue, 2 Apr 2019 01:34:31 -1100 Subject: [PATCH 3612/3904] ; --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c1eb1bac6..d5c78e68a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1219,7 +1219,7 @@ UniValue prices(const UniValue& params, bool fHelp) { prices[j*width + i] = rawprices[j]; if ( j == 1 ) - fprintf(stderr,"[%d] <- %.1f ",j*width+i,(double)rawprices[j]/10000) + fprintf(stderr,"[%d] <- %.1f ",j*width+i,(double)rawprices[j]/10000); } } } else throw JSONRPCError(RPC_INVALID_PARAMETER, "no komodo_rawprices found"); From 7b0d2efa74c8a3939ad5670180408ab2d0c212e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 01:37:16 -1100 Subject: [PATCH 3613/3904] cast --- src/komodo_gateway.h | 4 ++-- src/rpc/blockchain.cpp | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6b8df1834..6ecfd170c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2235,8 +2235,8 @@ int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices) { if ( (price= rawprices[i]) == 0 ) return(0); - fprintf(stderr,"%.4f ",(double)price/10000); - sum += price * 10000; + fprintf(stderr,"%.0f ",(double)price/10000); + sum += (int64_t)price * 10000; } fprintf(stderr," ave %.8f [%d]\n",((double)sum/numprices)/COIN,numprices); return(sum / numprices); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index d5c78e68a..32b1c9cb7 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1216,11 +1216,7 @@ UniValue prices(const UniValue& params, bool fHelp) else { for (j=0; j Date: Tue, 2 Apr 2019 01:45:33 -1100 Subject: [PATCH 3614/3904] Fix --- src/komodo_gateway.h | 4 ++-- src/rpc/blockchain.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6ecfd170c..a87a04e57 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2235,9 +2235,9 @@ int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices) { if ( (price= rawprices[i]) == 0 ) return(0); - fprintf(stderr,"%.0f ",(double)price/10000); + //fprintf(stderr,"%.0f ",(double)price/10000); sum += (int64_t)price * 10000; } - fprintf(stderr," ave %.8f [%d]\n",((double)sum/numprices)/COIN,numprices); + //fprintf(stderr," ave %.8f [%d]\n",((double)sum/numprices)/COIN,numprices); return(sum / numprices); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 32b1c9cb7..f927cf050 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1229,7 +1229,7 @@ UniValue prices(const UniValue& params, bool fHelp) ret.push_back(Pair("timestamps",timestamps)); ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); } - for (j=1; j<2; j++) + for (j=1; j Date: Tue, 2 Apr 2019 01:54:47 -1100 Subject: [PATCH 3615/3904] -print --- src/komodo_gateway.h | 4 ++-- src/rpc/blockchain.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a87a04e57..bb67d1e8d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2230,13 +2230,13 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices) { - int32_t i; uint32_t price; int64_t sum = 0; + int32_t i; int64_t price,sum = 0; for (i=0; i Date: Tue, 2 Apr 2019 01:58:18 -1100 Subject: [PATCH 3616/3904] Rescale --- src/rpc/blockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 1288c02ea..2b0186f22 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1245,9 +1245,9 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back(((int64_t)prices[offset]*10000)); - parr.push_back((correlated[i])); - parr.push_back((smoothed)); + parr.push_back(ValueFromAmount((int64_t)prices[offset])); + parr.push_back(ValueFromAmount(correlated[i]/10000)); + parr.push_back(ValueFromAmount(smoothed/10000)); p.push_back(parr); } item.push_back(Pair("prices",p)); From b5af10d99f56f11d17bb22dcef8ebab7e6502a8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 02:05:27 -1100 Subject: [PATCH 3617/3904] Normalize all prices --- src/komodo_gateway.h | 7 ++++--- src/rpc/blockchain.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bb67d1e8d..bbad94c51 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2228,15 +2228,16 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) return(correlated[0]); } -int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices) +int64_t komodo_pricecorrelated(int32_t ind,uint32_t *rawprices,int32_t numprices) { int32_t i; int64_t price,sum = 0; for (i=0; i= 36 ) + price *= 10000; + sum += price; } //fprintf(stderr," ave %.8f [%d]\n",((double)sum/numprices)/COIN,numprices); return(sum / numprices); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 2b0186f22..c628ab074 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1246,8 +1246,8 @@ UniValue prices(const UniValue& params, bool fHelp) smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); parr.push_back(ValueFromAmount((int64_t)prices[offset])); - parr.push_back(ValueFromAmount(correlated[i]/10000)); - parr.push_back(ValueFromAmount(smoothed/10000)); + parr.push_back(ValueFromAmount(correlated[i])); + parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); } item.push_back(Pair("prices",p)); From cf281b048edc19fdbdeb1fbb567f8964d1bcaa48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 02:07:32 -1100 Subject: [PATCH 3618/3904] int64_t komodo_pricecorrelated(int32_t ind,uint32_t *rawprices,int32_t numprices) --- src/rpc/blockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c628ab074..eab787f17 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1177,7 +1177,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices); -int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices); +int64_t komodo_pricecorrelated(int32_t ind,uint32_t *rawprices,int32_t numprices); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1238,7 +1238,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 02:13:20 -1100 Subject: [PATCH 3619/3904] Reverse --- src/komodo_gateway.h | 14 +++++++++----- src/rpc/blockchain.cpp | 12 ++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bbad94c51..293b57367 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1576,9 +1576,11 @@ void komodo_PriceCache_shift() } // komodo_heightpricebits() extracts the price data in the coinbase for nHeight -int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight) +int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight) { CBlockIndex *pindex; CBlock block; CTransaction tx; int32_t numvouts; std::vector vopret; + if ( seedp != 0 ) + *seedp = 0; if ( (pindex= komodo_chainactive(nHeight)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) @@ -1588,6 +1590,8 @@ int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight) GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) { + if ( seedp != 0 ) + memcpy(seedp,&pindex->hashMerkleRoot,sizeof(*seedp)); memcpy(heightbits,vopret.data(),vopret.size()); return((int32_t)(vopret.size()/sizeof(uint32_t))); } @@ -1682,7 +1686,7 @@ CScript komodo_mineropret(int32_t nHeight) if ( numzero != 0 ) fprintf(stderr,"numzero.%d\n",numzero); } - if ( komodo_heightpricebits(prevbits,nHeight-1) > 0 ) + if ( komodo_heightpricebits(0,prevbits,nHeight-1) > 0 ) { memcpy(pricebits,Mineropret.data(),Mineropret.size()); memset(maxflags,0,sizeof(maxflags)); @@ -1757,7 +1761,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i btcgbp = (double)pricebits[2]/10000; btceur = (double)pricebits[3]/10000; fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2); - if ( komodo_heightpricebits(prevbits,nHeight-1) > 0 ) + if ( komodo_heightpricebits(0,prevbits,nHeight-1) > 0 ) { if ( nHeight < testchain_exemption ) { @@ -2228,14 +2232,14 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) return(correlated[0]); } -int64_t komodo_pricecorrelated(int32_t ind,uint32_t *rawprices,int32_t numprices) +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices) { int32_t i; int64_t price,sum = 0; for (i=0; i= 36 ) + if ( ind < 36 ) price *= 10000; sum += price; } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index eab787f17..1cfcf4eb7 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1174,10 +1174,10 @@ UniValue paxprice(const UniValue& params, bool fHelp) return ret; } -int32_t komodo_heightpricebits(uint32_t *heightbits,int32_t nHeight); +int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices); -int64_t komodo_pricecorrelated(int32_t ind,uint32_t *rawprices,int32_t numprices); +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1186,7 +1186,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + UniValue ret(UniValue::VOBJ); uint64_t seed; int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; if ( ASSETCHAINS_CBOPRET == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); @@ -1198,7 +1198,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( daywindow < 7 ) daywindow = 7; width = maxsamples+2*daywindow; - numpricefeeds = komodo_heightpricebits(rawprices,nextheight-1); + numpricefeeds = komodo_heightpricebits(&seed,rawprices,nextheight-1); if ( numpricefeeds <= 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "illegal numpricefeeds"); prices = (uint32_t *)calloc(sizeof(*prices),width*numpricefeeds); @@ -1209,7 +1209,7 @@ UniValue prices(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); else { - if ( (n= komodo_heightpricebits(rawprices,ht)) > 0 ) + if ( (n= komodo_heightpricebits(0,rawprices,ht)) > 0 ) { if ( n != numpricefeeds ) throw JSONRPCError(RPC_INVALID_PARAMETER, "numprices != first numprices"); @@ -1238,7 +1238,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 02:17:35 -1100 Subject: [PATCH 3620/3904] Again --- src/rpc/blockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 1cfcf4eb7..5bbf1ef1f 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1245,8 +1245,8 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back(ValueFromAmount((int64_t)prices[offset])); - parr.push_back(ValueFromAmount(correlated[i])); + parr.push_back(ValueFromAmount((int64_t)prices[offset]*10000)); + parr.push_back(ValueFromAmount(correlated[i]*ind<36?10000:1)); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); } From 57b769c44d11e62a0af9dd73eb22991fc238efcd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 02:19:32 -1100 Subject: [PATCH 3621/3904] J --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5bbf1ef1f..772c590b6 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1246,7 +1246,7 @@ UniValue prices(const UniValue& params, bool fHelp) smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); parr.push_back(ValueFromAmount((int64_t)prices[offset]*10000)); - parr.push_back(ValueFromAmount(correlated[i]*ind<36?10000:1)); + parr.push_back(ValueFromAmount(correlated[i]*j<36?10000:1)); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); } From 8e84d8e0ea186f1645b8d83e660d30fb71ecc172 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 02:24:31 -1100 Subject: [PATCH 3622/3904] ugh --- src/komodo_gateway.h | 4 ++-- src/rpc/blockchain.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 293b57367..1f1ce8dc6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2202,8 +2202,8 @@ char *komodo_pricename(char *name,int32_t ind) return(0); if ( ind < sizeof(Forex)/sizeof(*Forex) ) { - strcpy(name,Forex[ind]); - strcat(name,"USD"); + name[0] = 'U', name[1] = 'S', name[2] = 'D'; + strcpy(name+3,Forex[ind]); return(name); } else ind -= sizeof(Forex)/sizeof(*Forex); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 772c590b6..5ba28438b 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1245,8 +1245,8 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back(ValueFromAmount((int64_t)prices[offset]*10000)); - parr.push_back(ValueFromAmount(correlated[i]*j<36?10000:1)); + parr.push_back(ValueFromAmount((int64_t)prices[offset]*j<36?10000:1)); + parr.push_back(ValueFromAmount(correlated[i])); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); } From d701423bfbc274a0ab520f4c8ff52a17ac9d4db0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 02:27:08 -1100 Subject: [PATCH 3623/3904] Fiddle --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5ba28438b..9f4b24235 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1245,7 +1245,7 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back(ValueFromAmount((int64_t)prices[offset]*j<36?10000:1)); + parr.push_back(ValueFromAmount((int64_t)prices[offset]*10000)); parr.push_back(ValueFromAmount(correlated[i])); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); From 2df1a61d73ed3dc27c7ae91353313dda6127cde5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 02:28:59 -1100 Subject: [PATCH 3624/3904] Finally --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 9f4b24235..bbf90f163 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1245,7 +1245,7 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back(ValueFromAmount((int64_t)prices[offset]*10000)); + parr.push_back(ValueFromAmount((int64_t)prices[offset]* j<36?10000:1)); parr.push_back(ValueFromAmount(correlated[i])); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); From b952e57e95448b2b85b0f2c492eca4941e708e06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 02:34:32 -1100 Subject: [PATCH 3625/3904] ?: precedence --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bbf90f163..668081934 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1245,7 +1245,7 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow); UniValue parr(UniValue::VARR); - parr.push_back(ValueFromAmount((int64_t)prices[offset]* j<36?10000:1)); + parr.push_back(ValueFromAmount((int64_t)prices[offset] * (j<36?10000:1))); parr.push_back(ValueFromAmount(correlated[i])); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); From d725af022effeb935cefc2f05d8efe19cc7ef00a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 2 Apr 2019 06:44:09 -0700 Subject: [PATCH 3626/3904] Client name is not a consensus-related option, it can be configured by any node --- src/clientversion.cpp | 2 +- src/init.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 663e2e937..084bbd5ce 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -35,7 +35,7 @@ * for both bitcoind and bitcoin-core, to make it harder for attackers to * target servers or GUI users specifically. */ -const std::string CLIENT_NAME = GetArg("-ac_clientname", "MagicBean"); +const std::string CLIENT_NAME = GetArg("-clientname", "MagicBean"); /** * Client version number diff --git a/src/init.cpp b/src/init.cpp index d2546347d..24b32a720 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -367,6 +367,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-blocknotify=", _("Execute command when the best block changes (%s in cmd is replaced by block hash)")); strUsage += HelpMessageOpt("-checkblocks=", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288)); strUsage += HelpMessageOpt("-checklevel=", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3)); + strUsage += HelpMessageOpt("-clientname=", _("Full node client name, default 'MagicBean'")); strUsage += HelpMessageOpt("-conf=", strprintf(_("Specify configuration file (default: %s)"), "komodo.conf")); if (mode == HMM_BITCOIND) { @@ -571,7 +572,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-ac_cclib", _("Cryptoconditions dynamicly loadable library")); strUsage += HelpMessageOpt("-ac_ccenable", _("Cryptoconditions to enable")); strUsage += HelpMessageOpt("-ac_ccactivate", _("Block height to enable Cryptoconditions")); - strUsage += HelpMessageOpt("-ac_clientname", _("Full node client name, default 'MagicBean'")); strUsage += HelpMessageOpt("-ac_decay", _("Percentage of block reward decrease at each halving")); strUsage += HelpMessageOpt("-ac_end", _("Block height at which block rewards will end")); strUsage += HelpMessageOpt("-ac_eras", _("Block reward eras")); From 4b7a2ca365e9d37fd21584c927ea19a643ecbbe2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:16:20 -1100 Subject: [PATCH 3627/3904] First version correlator --- src/komodo_gateway.h | 42 ++++++++++++++++++++++++++++++++---------- src/rpc/blockchain.cpp | 4 +++- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1f1ce8dc6..b59a6fbf1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2232,17 +2232,39 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) return(correlated[0]); } -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices) +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow) { - int32_t i; int64_t price,sum = 0; - for (i=0; i= daywindow ) + i = 0; + if ( (price= rawprices[i]) == 0 ) + return(-1); + if ( price >= lowprice && price <= highprice ) + { + sum += price; + correlation++; + if ( correlation > (daywindow>>1) ) + { + fprintf(stderr,"iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); + return(sum / correlation) + } + } + } } - //fprintf(stderr," ave %.8f [%d]\n",((double)sum/numprices)/COIN,numprices); - return(sum / numprices); + return(0); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 668081934..c68d4b14b 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1238,7 +1238,8 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 03:17:38 -1100 Subject: [PATCH 3628/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b59a6fbf1..9bfc76835 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2261,7 +2261,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( correlation > (daywindow>>1) ) { fprintf(stderr,"iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); - return(sum / correlation) + return(sum / correlation); } } } From e3a910b8cbf3c181cc37e15f0a65f7df03511a17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:30:46 -1100 Subject: [PATCH 3629/3904] +print --- src/komodo_gateway.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9bfc76835..d19325778 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1807,7 +1807,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i for (j=0; j= prevbits[i] ) { - fprintf(stderr,"within recent localprices[%d] %u >= %u\n",j,PriceCache[j][i],prevbits[i]); + fprintf(stderr,"i.%d within recent localprices[%d] %u >= %u\n",i,j,PriceCache[j][i],prevbits[i]); continue; } break; @@ -1819,7 +1819,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i for (j=0; j 333 ) // for debug only! get_stocks(Techstocks,(int32_t)(sizeof(Techstocks)/sizeof(*Techstocks))); }*/ } + pending = 0; } char *komodo_pricename(char *name,int32_t ind) @@ -2242,8 +2250,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int sum = correlation = 0; i = (j + seed) % daywindow; refprice = rawprices[i] * (ind < 36 ? 10000 : 1); - highprice = ((int64_t)refprice * (COIN + PRICES_MAXCHANGE/2)) / COIN; - lowprice = ((int64_t)refprice * (COIN - PRICES_MAXCHANGE/2)) / COIN; + highprice = ((int64_t)refprice * (COIN + PRICES_MAXCHANGE/10)) / COIN; + lowprice = ((int64_t)refprice * (COIN - PRICES_MAXCHANGE/10)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) @@ -2260,7 +2268,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation++; if ( correlation > (daywindow>>1) ) { - fprintf(stderr,"iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); + fprintf(stderr,"ind.%d iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); return(sum / correlation); } } From 790873660f8d93046bf70a4b42d4bb17f295c870 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:33:11 -1100 Subject: [PATCH 3630/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d19325778..bda57fab4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2250,8 +2250,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int sum = correlation = 0; i = (j + seed) % daywindow; refprice = rawprices[i] * (ind < 36 ? 10000 : 1); - highprice = ((int64_t)refprice * (COIN + PRICES_MAXCHANGE/10)) / COIN; - lowprice = ((int64_t)refprice * (COIN - PRICES_MAXCHANGE/10)) / COIN; + highprice = ((int64_t)refprice * (COIN + PRICES_MAXCHANGE)) / COIN; + lowprice = ((int64_t)refprice * (COIN - PRICES_MAXCHANGE)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) From 8209b487d8eb9d7ae94d4964ef708ed224acca46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:36:05 -1100 Subject: [PATCH 3631/3904] Test --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bda57fab4..2e7a3f5ea 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2242,7 +2242,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow) { - int32_t i,j,iter,correlation; int64_t price,sum; uint32_t refprice,lowprice,highprice; + int32_t i,j,iter,correlation,maxcorrelation=0; int64_t price,sum; uint32_t refprice,lowprice,highprice; if ( daywindow < 2 ) return(-1); for (iter=0; iter maxcorrelation ) + maxcorrelation = correlation; } + fprintf(stderr,"ind.%d iter.%d maxcorrelation.%d\n",ind,itermaxcorrelation); return(0); } From c808e4c196cd08a1d25c2c96d86f538a53d0721a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:45:08 -1100 Subject: [PATCH 3632/3904] Weighted correlation --- src/komodo_gateway.h | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2e7a3f5ea..3dc5b1bd8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2242,12 +2242,12 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow) { - int32_t i,j,iter,correlation,maxcorrelation=0; int64_t price,sum; uint32_t refprice,lowprice,highprice; + int32_t i,j,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den; uint32_t refprice,lowprice,highprice; if ( daywindow < 2 ) return(-1); for (iter=0; iter= lowprice && price <= highprice ) { - sum += price; correlation++; if ( correlation > (daywindow>>1) ) { - fprintf(stderr,"ind.%d iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); - return(sum / correlation); + n = 0; + i = (j + seed) % daywindow; + for (j=0; j= daywindow ) + i = 0; + if ( n >= (daywindow>>1) ) + rawprices[i] = 0; + else + { + price = rawprices[i]; + if ( price < lowprice || price > highprice ) + rawprices[i] = 0; + else n++; + } + } + fprintf(stderr,"ind.%d iter.%d j.%d i.%d n.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,n,correlation,(long long)refprice,(long long)sum/correlation); + if ( n != correlation ) + return(-1); + sum = den = n = 0; + for (i=0; i %.8f\n",((double)sum / den) / COIN); + return(sum / den); } } } From 24ff9d6e54b281a2ce558f51ad7f3bc4218f16ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:46:40 -1100 Subject: [PATCH 3633/3904] if ( n != correlation ) return(-1); --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3dc5b1bd8..9254980b2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2250,8 +2250,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation = 0; i = (j + seed) % daywindow; refprice = rawprices[i] * (ind < 36 ? 10000 : 1); - highprice = ((int64_t)refprice * (COIN + PRICES_MAXCHANGE)) / COIN; - lowprice = ((int64_t)refprice * (COIN - PRICES_MAXCHANGE)) / COIN; + highprice = ((int64_t)refprice * (COIN + 10*PRICES_MAXCHANGE)) / COIN; + lowprice = ((int64_t)refprice * (COIN - 10*PRICES_MAXCHANGE)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) @@ -2306,6 +2306,6 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( correlation > maxcorrelation ) maxcorrelation = correlation; } - fprintf(stderr,"ind.%d iter.%d maxcorrelation.%d\n",ind,itermaxcorrelation); + fprintf(stderr,"ind.%d iter.%d maxcorrelation.%d\n",ind,iter,maxcorrelation); return(0); } From db8fff57ab9a8ad1b8e3c989ccac3eadf545b686 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:55:45 -1100 Subject: [PATCH 3634/3904] Scale prices --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9254980b2..06e263616 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2250,8 +2250,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation = 0; i = (j + seed) % daywindow; refprice = rawprices[i] * (ind < 36 ? 10000 : 1); - highprice = ((int64_t)refprice * (COIN + 10*PRICES_MAXCHANGE)) / COIN; - lowprice = ((int64_t)refprice * (COIN - 10*PRICES_MAXCHANGE)) / COIN; + highprice = ((int64_t)refprice * (COIN + PRICES_MAXCHANGE)) / COIN; + lowprice = ((int64_t)refprice * (COIN - PRICES_MAXCHANGE)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) @@ -2262,6 +2262,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int i = 0; if ( (price= rawprices[i]) == 0 ) return(-1); + if ( ind < 36 ) + price *= 10000; if ( price >= lowprice && price <= highprice ) { correlation++; @@ -2306,6 +2308,6 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( correlation > maxcorrelation ) maxcorrelation = correlation; } - fprintf(stderr,"ind.%d iter.%d maxcorrelation.%d\n",ind,iter,maxcorrelation); + fprintf(stderr,"ind.%d iter.%d maxcorrelation.%d ref.%u high.%u low.%u\n",ind,iter,maxcorrelation,refprice,highprice,lowprice); return(0); } From a4788f61e7550553a2ba86e6314267771f65819d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 03:56:29 -1100 Subject: [PATCH 3635/3904] Test --- src/komodo_gateway.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 06e263616..5c578fc5e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2242,14 +2242,17 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow) { - int32_t i,j,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den; uint32_t refprice,lowprice,highprice; + int32_t i,j,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den; uint32_t mult,refprice,lowprice,highprice; if ( daywindow < 2 ) return(-1); + if ( ind < 36 ) + mult = 10000; + else mult = 1; for (iter=0; iter= lowprice && price <= highprice ) { correlation++; From f99fa65eda198c2e976c5f0c45c33f8d623643b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 04:01:54 -1100 Subject: [PATCH 3636/3904] Test --- src/komodo_gateway.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5c578fc5e..b5e000eb9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2242,7 +2242,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow) { - int32_t i,j,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den; uint32_t mult,refprice,lowprice,highprice; + int32_t i,j,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den,mult,refprice,lowprice,highprice; if ( daywindow < 2 ) return(-1); if ( ind < 36 ) @@ -2253,8 +2253,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation = 0; i = (j + seed) % daywindow; refprice = rawprices[i] * mult; - highprice = ((int64_t)refprice * (COIN + PRICES_MAXCHANGE)) / COIN; - lowprice = ((int64_t)refprice * (COIN - PRICES_MAXCHANGE)) / COIN; + highprice = (refprice * (COIN + PRICES_MAXCHANGE)) / COIN; + lowprice = (refprice * (COIN - PRICES_MAXCHANGE)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) @@ -2268,10 +2268,11 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int price *= mult; if ( price >= lowprice && price <= highprice ) { + sum += price; correlation++; if ( correlation > (daywindow>>1) ) { - n = 0; + /*n = 0; i = (j + seed) % daywindow; for (j=0; j %llu\n",ind,iter,j,i,n,correlation,(long long)refprice,(long long)sum/correlation); - if ( n != correlation ) + }*/ + fprintf(stderr,"ind.%d iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); + /*if ( n != correlation ) return(-1); sum = den = n = 0; for (i=0; i %.8f\n",((double)sum / den) / COIN); - return(sum / den); + return(sum / den);*/ + return(sum / correlation); } } } From c159b78f6f0bb33c89c86dac13ab2dba7640130b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 04:08:11 -1100 Subject: [PATCH 3637/3904] Test --- src/komodo_gateway.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b5e000eb9..09559d960 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2231,15 +2231,6 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) -{ - int32_t i; - for (i=0; i %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); + //fprintf(stderr,"ind.%d iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); /*if ( n != correlation ) return(-1); sum = den = n = 0; @@ -2312,6 +2303,17 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( correlation > maxcorrelation ) maxcorrelation = correlation; } - fprintf(stderr,"ind.%d iter.%d maxcorrelation.%d ref.%u high.%u low.%u\n",ind,iter,maxcorrelation,refprice,highprice,lowprice); + fprintf(stderr,"ind.%d iter.%d maxcorrelation.%d ref.%llu high.%llu low.%llu\n",ind,iter,maxcorrelation,(long long)refprice,(long long)highprice,(long long)lowprice); return(0); } + + +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) +{ + int32_t i; + for (i=0; i Date: Tue, 2 Apr 2019 04:18:44 -1100 Subject: [PATCH 3638/3904] Init sum --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 09559d960..b0b21b49f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2243,23 +2243,23 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int { correlation = 0; i = (j + seed) % daywindow; - refprice = rawprices[i] * mult; + refprice = rawprices[i]; highprice = (refprice * (COIN + PRICES_MAXCHANGE)) / COIN; lowprice = (refprice * (COIN - PRICES_MAXCHANGE)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) lowprice--; + sum = 0; for (j=0; j= daywindow ) i = 0; if ( (price= rawprices[i]) == 0 ) return(-1); - price *= mult; if ( price >= lowprice && price <= highprice ) { - sum += price; + sum += price * mult; correlation++; if ( correlation > (daywindow>>1) ) { From 2b1dff7b0c5c6d9325de82bf4fd6395a7f7a1781 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 04:19:05 -1100 Subject: [PATCH 3639/3904] Allow more variance --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b0b21b49f..7df402d69 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2244,8 +2244,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation = 0; i = (j + seed) % daywindow; refprice = rawprices[i]; - highprice = (refprice * (COIN + PRICES_MAXCHANGE)) / COIN; - lowprice = (refprice * (COIN - PRICES_MAXCHANGE)) / COIN; + highprice = (refprice * (COIN + PRICES_MAXCHANGE*2)) / COIN; + lowprice = (refprice * (COIN - PRICES_MAXCHANGE*2)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) From 47f2069490780624642adf8d4350da9033b1cfbf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 04:29:54 -1100 Subject: [PATCH 3640/3904] Weight correlated price --- src/komodo_gateway.h | 33 +++++++++++++++++++-------------- src/rpc/blockchain.cpp | 9 ++++++--- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7df402d69..66e9fae78 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2231,7 +2231,7 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow) +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow,uint32_t *rawprices2) { int32_t i,j,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den,mult,refprice,lowprice,highprice; if ( daywindow < 2 ) @@ -2239,13 +2239,15 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( ind < 36 ) mult = 10000; else mult = 1; + if ( memcmp(rawprices,rawprices2,daywindow*sizeof(*rawprices)) != 0 ) + fprintf(stderr,"ind.%d rawprices2 != rawprices\n",ind); for (iter=0; iter (daywindow>>1) ) { - /*n = 0; + n = 0; i = (j + seed) % daywindow; for (j=0; j= daywindow ) i = 0; if ( n >= (daywindow>>1) ) - rawprices[i] = 0; + rawprices2[i] = 0; else { price = rawprices[i]; if ( price < lowprice || price > highprice ) - rawprices[i] = 0; - else n++; + rawprices2[i] = 0; + else + { + rawprices2[i] = price; + n++; + } } - }*/ - //fprintf(stderr,"ind.%d iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); - /*if ( n != correlation ) + } + fprintf(stderr,"ind.%d iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); + if ( n != correlation ) return(-1); sum = den = n = 0; for (i=0; i %.8f\n",((double)sum / den) / COIN); - return(sum / den);*/ - return(sum / correlation); + fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); + return((sum * mult) / den); } } } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c68d4b14b..c41803908 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1177,7 +1177,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices); -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices); +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices,uint32_t *rawprices2); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1186,7 +1186,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t seed; int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + UniValue ret(UniValue::VOBJ); uint64_t seed; int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; if ( ASSETCHAINS_CBOPRET == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); @@ -1203,6 +1203,7 @@ UniValue prices(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "illegal numpricefeeds"); prices = (uint32_t *)calloc(sizeof(*prices),width*numpricefeeds); correlated = (int64_t *)calloc(sizeof(*correlated),width); + prices2 = (int64_t *)calloc(sizeof(*prices2),width); for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) @@ -1238,7 +1239,8 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 04:31:40 -1100 Subject: [PATCH 3641/3904] Test --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c41803908..9b0f5ec0a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1203,7 +1203,7 @@ UniValue prices(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "illegal numpricefeeds"); prices = (uint32_t *)calloc(sizeof(*prices),width*numpricefeeds); correlated = (int64_t *)calloc(sizeof(*correlated),width); - prices2 = (int64_t *)calloc(sizeof(*prices2),width); + prices2 = (uint32_t *)calloc(sizeof(*prices2),width); for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) From a589a789f1eeee708896253bc50d125e7e1f7bb6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 04:35:59 -1100 Subject: [PATCH 3642/3904] +print --- src/komodo_gateway.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 66e9fae78..85c24c475 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2299,7 +2299,10 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int } } if ( n != correlation || sum == 0 || den == 0 ) + { + fprintf(stderr,"n.%d vs correlation.%d sum %llu, den %llu\n",n,correlation,(long long)sum,(long long)den); return(-1); + } fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); return((sum * mult) / den); } From 41748a83fc55884bbd78e101245f59e8a1562153 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 04:39:01 -1100 Subject: [PATCH 3643/3904] Test --- src/komodo_gateway.h | 10 +++++----- src/rpc/blockchain.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 85c24c475..a3a6445f6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2233,14 +2233,14 @@ char *komodo_pricename(char *name,int32_t ind) int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow,uint32_t *rawprices2) { - int32_t i,j,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den,mult,refprice,lowprice,highprice; + int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den,mult,refprice,lowprice,highprice; if ( daywindow < 2 ) return(-1); if ( ind < 36 ) mult = 10000; else mult = 1; - if ( memcmp(rawprices,rawprices2,daywindow*sizeof(*rawprices)) != 0 ) - fprintf(stderr,"ind.%d rawprices2 != rawprices\n",ind); + //if ( memcmp(rawprices,rawprices2,daywindow*sizeof(*rawprices)) != 0 ) + // fprintf(stderr,"ind.%d rawprices2 != rawprices\n",ind); for (iter=0; iter= daywindow ) i = 0; @@ -2300,7 +2300,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int } if ( n != correlation || sum == 0 || den == 0 ) { - fprintf(stderr,"n.%d vs correlation.%d sum %llu, den %llu\n",n,correlation,(long long)sum,(long long)den); + fprintf(stderr,"seed.%llu n.%d vs correlation.%d sum %llu, den %llu\n",(long long)seed,n,correlation,(long long)sum,(long long)den); return(-1); } fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 9b0f5ec0a..bc2e50fe4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1239,7 +1239,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 04:42:42 -1100 Subject: [PATCH 3644/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a3a6445f6..5fabf72b2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2271,7 +2271,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int { if ( i >= daywindow ) i = 0; - if ( n >= (daywindow>>1) ) + if ( n > (daywindow>>1) ) rawprices2[i] = 0; else { @@ -2285,7 +2285,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int } } } - fprintf(stderr,"ind.%d iter.%d j.%d i.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,correlation,(long long)refprice,(long long)sum/correlation); + fprintf(stderr,"ind.%d iter.%d j.%d i.%d n.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,n,correlation,(long long)refprice,(long long)sum/correlation); if ( n != correlation ) return(-1); sum = den = n = 0; From 306314dceef91dc37ad0de86bf2ddf707c15e36b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 04:54:34 -1100 Subject: [PATCH 3645/3904] Smoother --- src/komodo_gateway.h | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5fabf72b2..d4b629f0d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2239,8 +2239,6 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( ind < 36 ) mult = 10000; else mult = 1; - //if ( memcmp(rawprices,rawprices2,daywindow*sizeof(*rawprices)) != 0 ) - // fprintf(stderr,"ind.%d rawprices2 != rawprices\n",ind); for (iter=0; iter %llu\n",ind,iter,j,i,n,correlation,(long long)refprice,(long long)sum/correlation); + //fprintf(stderr,"ind.%d iter.%d j.%d i.%d n.%d correlation.%d ref %llu -> %llu\n",ind,iter,j,i,n,correlation,(long long)refprice,(long long)sum/correlation); if ( n != correlation ) return(-1); sum = den = n = 0; @@ -2303,7 +2301,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int fprintf(stderr,"seed.%llu n.%d vs correlation.%d sum %llu, den %llu\n",(long long)seed,n,correlation,(long long)sum,(long long)den); return(-1); } - fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); + //fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); return((sum * mult) / den); } } @@ -2318,10 +2316,32 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) { - int32_t i; - for (i=0; i Date: Tue, 2 Apr 2019 05:00:31 -1100 Subject: [PATCH 3646/3904] Anchor to latest --- src/komodo_gateway.h | 7 ++++--- src/rpc/blockchain.cpp | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d4b629f0d..e7186ccc3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2233,7 +2233,7 @@ char *komodo_pricename(char *name,int32_t ind) int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow,uint32_t *rawprices2) { - int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t price,sum,den,mult,refprice,lowprice,highprice; + int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice; if ( daywindow < 2 ) return(-1); if ( ind < 36 ) @@ -2287,12 +2287,13 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( n != correlation ) return(-1); sum = den = n = 0; + firstprice = rawprices2[0]; for (i=0; i> 1); n++; } } @@ -2337,7 +2338,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) sum = den = 0; for (i=0; i> 1); den += (numprices - i); } smoothed = (sum / den); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bc2e50fe4..2ff865f88 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1256,6 +1256,7 @@ UniValue prices(const UniValue& params, bool fHelp) item.push_back(Pair("prices",p)); } else item.push_back(Pair("name","error")); a.push_back(item); +break; } ret.push_back(Pair("pricefeeds",a)); ret.push_back(Pair("result","success")); From fd3996cb88064c718cede483310d0d62b4d4b8bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:04:22 -1100 Subject: [PATCH 3647/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e7186ccc3..9f0f1e7fe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2302,7 +2302,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int fprintf(stderr,"seed.%llu n.%d vs correlation.%d sum %llu, den %llu\n",(long long)seed,n,correlation,(long long)sum,(long long)den); return(-1); } - //fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); + fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); return((sum * mult) / den); } } From 88eee07c7ffca378f30f8b07d6c9ad845438f30f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:08:03 -1100 Subject: [PATCH 3648/3904] tst --- src/komodo_gateway.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9f0f1e7fe..57835ab7a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1617,7 +1617,7 @@ uint32_t komodo_pricenew(char *maxflagp,uint32_t price,uint32_t refprice,int64_t lowprice--; if ( price >= highprice ) { - fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); + //fprintf(stderr,"high %u vs h%llu l%llu tolerance.%llu\n",price,(long long)highprice,(long long)lowprice,(long long)tolerance); if ( price > highprice ) // return non-zero only if we violate the tolerance { *maxflagp = 2; @@ -2287,7 +2287,10 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( n != correlation ) return(-1); sum = den = n = 0; - firstprice = rawprices2[0]; + for (i=0; i> 1); n++; - } + } else return(-1); } if ( n != correlation || sum == 0 || den == 0 ) { fprintf(stderr,"seed.%llu n.%d vs correlation.%d sum %llu, den %llu\n",(long long)seed,n,correlation,(long long)sum,(long long)den); return(-1); } - fprintf(stderr,"weighted -> %.8f\n",((double)(sum*mult) / den) / COIN); + //fprintf(stderr,"firstprice.%llu weighted -> %.8f\n",(long long)firstprice,((double)(sum*mult) / den) / COIN); return((sum * mult) / den); } } From fcea5524d7df451cb9ce0dafaf82e1c94d0f842a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:10:45 -1100 Subject: [PATCH 3649/3904] Skip --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 57835ab7a..e0efd5734 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2298,7 +2298,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int den += (daywindow - i); sum += (daywindow - i) * ((price + firstprice) >> 1); n++; - } else return(-1); + } } if ( n != correlation || sum == 0 || den == 0 ) { From 4c0eaa7a1f5411f3eddf2faa3d5e8ede5b7e7ffd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:15:02 -1100 Subject: [PATCH 3650/3904] 2/3 --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e0efd5734..3e6d8061a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2296,7 +2296,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( (price= rawprices2[i]) != 0 ) { den += (daywindow - i); - sum += (daywindow - i) * ((price + firstprice) >> 1); + sum += (daywindow - i) * ((price + firstprice*2) / 3); n++; } } @@ -2305,7 +2305,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int fprintf(stderr,"seed.%llu n.%d vs correlation.%d sum %llu, den %llu\n",(long long)seed,n,correlation,(long long)sum,(long long)den); return(-1); } - //fprintf(stderr,"firstprice.%llu weighted -> %.8f\n",(long long)firstprice,((double)(sum*mult) / den) / COIN); + fprintf(stderr,"firstprice.%llu weighted -> %.8f\n",(long long)firstprice,((double)(sum*mult) / den) / COIN); return((sum * mult) / den); } } @@ -2341,7 +2341,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices) sum = den = 0; for (i=0; i> 1); + sum += (numprices - i) * ((correlated[i] + firstprice*2) / 3); den += (numprices - i); } smoothed = (sum / den); From fe9eb8df39f1ca763cfdddb22c0435f1942de5f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:19:01 -1100 Subject: [PATCH 3651/3904] nonzprices --- src/komodo_gateway.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3e6d8061a..57b537606 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2231,7 +2231,7 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow,uint32_t *rawprices2) +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow,uint32_t *nonzprices) { int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice; if ( daywindow < 2 ) @@ -2270,15 +2270,16 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( i >= daywindow ) i = 0; if ( n > (daywindow>>1) ) - rawprices2[i] = 0; + nonzprices[i] = 0; else { price = rawprices[i]; if ( price < lowprice || price > highprice ) - rawprices2[i] = 0; + nonzprices[i] = 0; else { - rawprices2[i] = price; + nonzprices[i] = price; + fprintf(stderr,"(%d %u) ",i,rawprices[i]); n++; } } @@ -2288,12 +2289,13 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int return(-1); sum = den = n = 0; for (i=0; i Date: Tue, 2 Apr 2019 05:23:32 -1100 Subject: [PATCH 3652/3904] Test --- src/rpc/blockchain.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 2ff865f88..bc8302589 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1186,7 +1186,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t seed; int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t smoothed,*correlated; char name[64],*str; uint32_t rawprices[2048],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; if ( ASSETCHAINS_CBOPRET == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); @@ -1230,8 +1230,10 @@ UniValue prices(const UniValue& params, bool fHelp) ret.push_back(Pair("timestamps",timestamps)); ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); } + rngval = seed; for (j=1; j Date: Tue, 2 Apr 2019 05:28:11 -1100 Subject: [PATCH 3653/3904] Iter + seed --- src/komodo_gateway.h | 4 ++-- src/rpc/blockchain.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 57b537606..eff32b495 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2242,7 +2242,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int for (iter=0; iter (daywindow>>1) ) { n = 0; - i = (j + seed) % daywindow; + i = (iter + seed) % daywindow; for (k=0; k= daywindow ) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bc8302589..7055e65c3 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1241,7 +1241,6 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 05:31:47 -1100 Subject: [PATCH 3654/3904] Rngval inside inner loop --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 7055e65c3..fc476657d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1233,7 +1233,6 @@ UniValue prices(const UniValue& params, bool fHelp) rngval = seed; for (j=1; j Date: Tue, 2 Apr 2019 05:38:06 -1100 Subject: [PATCH 3655/3904] Test --- src/rpc/blockchain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index fc476657d..eaeae8f60 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1231,6 +1231,9 @@ UniValue prices(const UniValue& params, bool fHelp) ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); } rngval = seed; + for (i=0; i Date: Tue, 2 Apr 2019 05:42:40 -1100 Subject: [PATCH 3656/3904] tst --- src/rpc/blockchain.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index eaeae8f60..a72f0c341 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1222,16 +1222,13 @@ UniValue prices(const UniValue& params, bool fHelp) } else throw JSONRPCError(RPC_INVALID_PARAMETER, "no komodo_rawprices found"); } } + ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); + UniValue timestamps(UniValue::VARR); for (i=0; i Date: Tue, 2 Apr 2019 05:47:10 -1100 Subject: [PATCH 3657/3904] Test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index eff32b495..2ea4c2753 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2263,6 +2263,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation++; if ( correlation > (daywindow>>1) ) { + return(sum*mult/correlation); n = 0; i = (iter + seed) % daywindow; for (k=0; k Date: Tue, 2 Apr 2019 05:50:12 -1100 Subject: [PATCH 3658/3904] Test --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2ea4c2753..e6bdd9a8f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2251,6 +2251,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( lowprice == refprice ) lowprice--; sum = 0; + fprintf(stderr,"firsti.%d: ",firsti); for (j=0; j= daywindow ) @@ -2259,10 +2260,12 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int return(-1); if ( price >= lowprice && price <= highprice ) { - sum += price * mult; + fprintf(stderr,"%.1f ",(double)price/10000); + sum += price; correlation++; if ( correlation > (daywindow>>1) ) { + fprintf(stderr,"-> %.4f\n",(double)sum*mult/correlation); return(sum*mult/correlation); n = 0; i = (iter + seed) % daywindow; From 9b75e70178dddf5064f0eae97861e1f3dcdc4de2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:51:17 -1100 Subject: [PATCH 3659/3904] I --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e6bdd9a8f..446619eb7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2251,7 +2251,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( lowprice == refprice ) lowprice--; sum = 0; - fprintf(stderr,"firsti.%d: ",firsti); + fprintf(stderr,"firsti.%d: ",i); for (j=0; j= daywindow ) From 355ce81643952bfb6e5beddb40665b2cc68781fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:54:30 -1100 Subject: [PATCH 3660/3904] -print --- src/komodo_gateway.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 446619eb7..36de71951 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2251,7 +2251,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( lowprice == refprice ) lowprice--; sum = 0; - fprintf(stderr,"firsti.%d: ",i); + //fprintf(stderr,"firsti.%d: ",i); for (j=0; j= daywindow ) @@ -2260,13 +2260,13 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int return(-1); if ( price >= lowprice && price <= highprice ) { - fprintf(stderr,"%.1f ",(double)price/10000); + //fprintf(stderr,"%.1f ",(double)price/10000); sum += price; correlation++; if ( correlation > (daywindow>>1) ) { - fprintf(stderr,"-> %.4f\n",(double)sum*mult/correlation); - return(sum*mult/correlation); + //fprintf(stderr,"-> %.4f\n",(double)sum*mult/correlation); + //return(sum*mult/correlation); n = 0; i = (iter + seed) % daywindow; for (k=0; k %.8f\n",(long long)firstprice,((double)(sum*mult) / den) / COIN); + //fprintf(stderr,"firstprice.%llu weighted -> %.8f\n",(long long)firstprice,((double)(sum*mult) / den) / COIN); return((sum * mult) / den); } } From fae4422d85b83a007d4c7e52441e6feeab8a94fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 05:55:26 -1100 Subject: [PATCH 3661/3904] Rc --- src/rpc/blockchain.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a72f0c341..5e426b88e 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1228,9 +1228,9 @@ UniValue prices(const UniValue& params, bool fHelp) timestamps.push_back((int64_t)prices[i]); ret.push_back(Pair("timestamps",timestamps)); rngval = seed; - for (i=0; i Date: Tue, 2 Apr 2019 06:03:24 -1100 Subject: [PATCH 3662/3904] Test --- src/komodo_gateway.h | 18 ++++++++++-------- src/rpc/blockchain.cpp | 8 +++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 36de71951..2d708f036 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2239,6 +2239,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( ind < 36 ) mult = 10000; else mult = 1; + memset(nonzprices,0,sizeof(*nonzprices)*daywindow); for (iter=0; iter2*daywindow+2; i++,ht--) { @@ -1247,7 +1248,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Tue, 2 Apr 2019 06:31:42 -1100 Subject: [PATCH 3663/3904] Update --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2d708f036..65f534778 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1832,6 +1832,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i { fprintf(stderr,"force update prices\n"); komodo_cbopretupdate(1); + memcpy(localbits,Mineropret.data(),Mineropret.size()); } else return(-1); } } From 503eadb7d989ff3db774ef8cfe7acdded257686f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 06:48:55 -1100 Subject: [PATCH 3664/3904] komodo_cbopretupdate if zero price --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 65f534778..7b6227b92 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1684,7 +1684,10 @@ CScript komodo_mineropret(int32_t nHeight) if ( pricebits[i] == 0 ) numzero++; if ( numzero != 0 ) - fprintf(stderr,"numzero.%d\n",numzero); + { + fprintf(stderr,"komodo_mineropret numzero.%d vs n.%d\n",numzero,n); + komodo_cbopretupdate(1); + } } if ( komodo_heightpricebits(0,prevbits,nHeight-1) > 0 ) { From 8be53197b396c244eab12b09d8e27e26aaa7223d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 06:52:50 -1100 Subject: [PATCH 3665/3904] +prnt --- src/komodo_gateway.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7b6227b92..c04bfb381 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1682,11 +1682,15 @@ CScript komodo_mineropret(int32_t nHeight) memcpy(pricebits,Mineropret.data(),Mineropret.size()); for (i=numzero=0; i 0 ) @@ -2167,10 +2171,10 @@ if ( komodo_nextheight() > 333 ) // for debug only! if ( (flags & 4) != 0 ) lastcrypto = now; memcpy(Mineropret.data(),PriceCache[0],size); + int32_t i; for (i=0; i Date: Tue, 2 Apr 2019 06:58:35 -1100 Subject: [PATCH 3666/3904] Fix init conditions --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c04bfb381..99462fdd3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1573,6 +1573,7 @@ void komodo_PriceCache_shift() //for (j=0; j<4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex); j++) // PriceCache[i][j] = PriceCache[i-1][j]; } + memcpy(PriceCache[0],Mineropret.data(),Mineropret.size()); } // komodo_heightpricebits() extracts the price data in the coinbase for nHeight @@ -2173,7 +2174,7 @@ if ( komodo_nextheight() > 333 ) // for debug only! memcpy(Mineropret.data(),PriceCache[0],size); int32_t i; for (i=0; i Date: Tue, 2 Apr 2019 07:02:57 -1100 Subject: [PATCH 3667/3904] /sizeof(uint32_t) --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 99462fdd3..f13dbdd47 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1691,7 +1691,7 @@ CScript komodo_mineropret(int32_t nHeight) { fprintf(stderr," komodo_mineropret numzero.%d vs n.%d\n",numzero,n); komodo_cbopretupdate(1); - sleep(5); + sleep(61); } } if ( komodo_heightpricebits(0,prevbits,nHeight-1) > 0 ) @@ -1702,7 +1702,7 @@ CScript komodo_mineropret(int32_t nHeight) { // if the new prices are outside tolerance, update Mineropret with clamped prices komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE); - fprintf(stderr,"update Mineropret to clamped prices\n"); + //fprintf(stderr,"update Mineropret to clamped prices\n"); memcpy(Mineropret.data(),pricebits,Mineropret.size()); } } @@ -2146,7 +2146,7 @@ if ( komodo_nextheight() > 333 ) // for debug only! if ( flags == 0 ) komodo_PriceCache_shift(); flags |= 2; - memcpy(&PriceCache[0][size],forexprices,sizeof(forexprices)); + memcpy(&PriceCache[0][size/sizeof(uint32_t)],forexprices,sizeof(forexprices)); } size += sizeof(forexprices); } @@ -2157,7 +2157,7 @@ if ( komodo_nextheight() > 333 ) // for debug only! get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); if ( flags == 0 ) komodo_PriceCache_shift(); - memcpy(&PriceCache[0][size],cryptoprices,sizeof(cryptoprices)); + memcpy(&PriceCache[0][size/sizeof(uint32_t)],cryptoprices,sizeof(cryptoprices)); flags |= 4; // very rarely we can see flags == 6 case } size += sizeof(cryptoprices); From 62a9756bc0de1d2b130b3ad34330e7b14ce813ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 07:07:09 -1100 Subject: [PATCH 3668/3904] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f13dbdd47..6d2fef363 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2172,9 +2172,9 @@ if ( komodo_nextheight() > 333 ) // for debug only! if ( (flags & 4) != 0 ) lastcrypto = now; memcpy(Mineropret.data(),PriceCache[0],size); - int32_t i; for (i=0; i Date: Tue, 2 Apr 2019 08:13:43 -1100 Subject: [PATCH 3669/3904] Test --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6d2fef363..dbc879806 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2345,7 +2345,10 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz if ( correlated[i] == 0 ) correlated[i] = correlated[i-1]; if ( firstprice == 0 && correlated[i] != 0 ) + { firstprice = correlated[i]; + break; + } } if ( firstprice != 0 ) { @@ -2358,7 +2361,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 08:34:57 -1100 Subject: [PATCH 3670/3904] Pre-smoother --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dbc879806..276bb8667 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2312,7 +2312,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( (price= nonzprices[i]) != 0 ) { den += (daywindow - i); - sum += (daywindow - i) * price;//((price + firstprice*2) / 3); + sum += (daywindow - i) * ((price + firstprice) / 2); n++; } } @@ -2361,7 +2361,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 08:38:18 -1100 Subject: [PATCH 3671/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 276bb8667..d5f9c98f9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2361,7 +2361,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 09:35:01 -1100 Subject: [PATCH 3672/3904] 2/3 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d5f9c98f9..a926e3de0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2361,7 +2361,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 09:38:09 -1100 Subject: [PATCH 3673/3904] 1:1 --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a926e3de0..9c9b3959e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2312,7 +2312,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( (price= nonzprices[i]) != 0 ) { den += (daywindow - i); - sum += (daywindow - i) * ((price + firstprice) / 2); + sum += (daywindow - i) * price; n++; } } @@ -2361,7 +2361,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 09:43:58 -1100 Subject: [PATCH 3674/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9c9b3959e..120267dad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2364,7 +2364,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum += (daywindow - i) * correlated[i]; den += (daywindow - i); } - smoothed = (sum / den); + smoothed = ((sum / den) + firstprice) >> 1; } return(smoothed); } From 480349a221c09c65957e9becc61a75df6a4067e8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 09:49:48 -1100 Subject: [PATCH 3675/3904] 0.9 decay --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 120267dad..78d320c91 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2312,7 +2312,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( (price= nonzprices[i]) != 0 ) { den += (daywindow - i); - sum += (daywindow - i) * price; + sum += ((daywindow - i) * (price + firstprice*9)) / 10; n++; } } @@ -2361,10 +2361,10 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i> 1; + smoothed = (sum / den); } return(smoothed); } From 05bd8d8af63d51ea3ba11f4c7816f48b97f7bd7c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 10:16:03 -1100 Subject: [PATCH 3676/3904] Smooth coifs --- src/komodo_gateway.h | 36 +++++++++++++++++++++++++++--------- src/rpc/blockchain.cpp | 11 ++++++----- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 78d320c91..afa3b40c1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2312,7 +2312,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( (price= nonzprices[i]) != 0 ) { den += (daywindow - i); - sum += ((daywindow - i) * (price + firstprice*9)) / 10; + sum += ((daywindow - i) * (price + firstprice*2)) / 3; n++; } } @@ -2334,11 +2334,17 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int } -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonzprices) +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonzprices,int32_t smoothwidth) { - int32_t i; int64_t sum,den,smoothed=0,firstprice = correlated[0]; + const int64_t coeffs[7] = { 7, 13, 5, 4, 6, 7, 3 }; + int32_t i,iter; int64_t smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; if ( daywindow < 2 ) return(0); + if ( sizeof(smoothed)/sizeof(*smoothed) ) + { + fprintf(stderr,"smoothwidth %d != %d\n",smoothwidth,(int32_t)(sizeof(smoothed)/sizeof(*smoothed))); + return(0); + } memset(nonzprices,0,sizeof(*nonzprices)*daywindow); for (i=1; i %.4f\n",(double)(smoothedsum/smoothedden)/10000); + return(smoothedsum/smoothedden); } - return(smoothed); + return(0); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 0080c9b2c..520307c4b 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1183,6 +1183,7 @@ uint32_t komodo_heightstamp(int32_t height); UniValue prices(const UniValue& params, bool fHelp) { + int32_t smoothwidth = 7; if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); @@ -1197,7 +1198,7 @@ UniValue prices(const UniValue& params, bool fHelp) UniValue a(UniValue::VARR); if ( daywindow < 7 ) daywindow = 7; - width = maxsamples+2*daywindow; + width = maxsamples+2*daywindow+smoothwidth; numpricefeeds = komodo_heightpricebits(&seed,rawprices,nextheight-1); if ( numpricefeeds <= 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "illegal numpricefeeds"); @@ -1205,7 +1206,7 @@ UniValue prices(const UniValue& params, bool fHelp) correlated = (int64_t *)calloc(sizeof(*correlated),width); correlated2 = (int64_t *)calloc(sizeof(*correlated2),width); prices2 = (uint32_t *)calloc(sizeof(*prices2),width); - for (ht=nextheight-1,i=0; i2*daywindow+2; i++,ht--) + for (ht=nextheight-1,i=0; i2*daywindow+2+smoothwidth; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); @@ -1238,17 +1239,17 @@ UniValue prices(const UniValue& params, bool fHelp) if ( (str= komodo_pricename(name,j)) != 0 ) { item.push_back(Pair("name",str)); - for (i=0; i Date: Tue, 2 Apr 2019 10:17:38 -1100 Subject: [PATCH 3677/3904] Smooth width --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 520307c4b..e31f5d8a4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1176,7 +1176,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices,int64_t *correlated2); +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices,int64_t *correlated2,int32_t smoothwidth); int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices,uint32_t *rawprices2); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); From 778b70285efca1d9aab687f007644c638ae9be4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 10:19:24 -1100 Subject: [PATCH 3678/3904] Add condition --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index afa3b40c1..d0539426e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2340,7 +2340,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz int32_t i,iter; int64_t smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; if ( daywindow < 2 ) return(0); - if ( sizeof(smoothed)/sizeof(*smoothed) ) + if ( smoothwidth != sizeof(smoothed)/sizeof(*smoothed) ) { fprintf(stderr,"smoothwidth %d != %d\n",smoothwidth,(int32_t)(sizeof(smoothed)/sizeof(*smoothed))); return(0); From 903455b07b0332e031c561e186615fae64d1ad7e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 10:24:52 -1100 Subject: [PATCH 3679/3904] Gilt --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d0539426e..9543cc1b9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2336,7 +2336,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonzprices,int32_t smoothwidth) { - const int64_t coeffs[7] = { 7, 13, 5, 4, 6, 7, 3 }; + const int64_t coeffs[7] = { 7, 7, 7, 7, 7, 7, 7 }; int32_t i,iter; int64_t smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; if ( daywindow < 2 ) return(0); @@ -2378,8 +2378,8 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz for (i=0; i<7; i++) { fprintf(stderr,"%.4f ",(double)smoothed[i]/10000); - smoothedsum += coeffs[i] * smoothed[i]; - smoothedden += coeffs[i]; + smoothedsum += (7-i) * smoothed[i]; + smoothedden += (7-i); } fprintf(stderr,"-> %.4f\n",(double)(smoothedsum/smoothedden)/10000); return(smoothedsum/smoothedden); From a5957af75a3170c0816866658656787bc5e56109 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 10:25:59 -1100 Subject: [PATCH 3680/3904] 1:1 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9543cc1b9..8da2a94bf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2369,7 +2369,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 10:32:08 -1100 Subject: [PATCH 3681/3904] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8da2a94bf..63e6898eb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2254,8 +2254,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation = 0; i = (iter + seed) % daywindow; refprice = rawprices[i]; - highprice = (refprice * (COIN + PRICES_MAXCHANGE*3)) / COIN; - lowprice = (refprice * (COIN - PRICES_MAXCHANGE*3)) / COIN; + highprice = (refprice * (COIN + PRICES_MAXCHANGE*4)) / COIN; + lowprice = (refprice * (COIN - PRICES_MAXCHANGE*4)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) @@ -2312,7 +2312,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( (price= nonzprices[i]) != 0 ) { den += (daywindow - i); - sum += ((daywindow - i) * (price + firstprice*2)) / 3; + sum += ((daywindow - i) * (price + firstprice*9)) / 10; n++; } } @@ -2369,7 +2369,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 10:34:58 -1100 Subject: [PATCH 3682/3904] Arg --- src/komodo_gateway.h | 7 +++++-- src/rpc/blockchain.cpp | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 63e6898eb..0d4274ae5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2240,7 +2240,7 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow,uint32_t *nonzprices) +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t daywindow,uint32_t *nonzprices,int32_t smoothwidth) { int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice; if ( daywindow < 2 ) @@ -2249,7 +2249,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int mult = 10000; else mult = 1; memset(nonzprices,0,sizeof(*nonzprices)*daywindow); - for (iter=0; iter= daywindow ) i = 0; if ( (price= rawprices[i]) == 0 ) + { + fprintf(stderr,"null rawprice.[%d]\n",i); return(-1); + } if ( price >= lowprice && price <= highprice ) { //fprintf(stderr,"%.1f ",(double)price/10000); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index e31f5d8a4..6e6746a30 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1177,7 +1177,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices,int64_t *correlated2,int32_t smoothwidth); -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices,uint32_t *rawprices2); +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices,uint32_t *rawprices2,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1243,7 +1243,7 @@ UniValue prices(const UniValue& params, bool fHelp) { offset = j*width + i; rngval = (rngval*11109 + 13849); - if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],daywindow+smoothwidth,prices2)) < 0 ) + if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],daywindow+smoothwidth,prices2,smoothwidth)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); } for (i=0; i Date: Tue, 2 Apr 2019 10:38:42 -1100 Subject: [PATCH 3683/3904] -smoothwidth --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6e6746a30..e471492ce 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1243,7 +1243,7 @@ UniValue prices(const UniValue& params, bool fHelp) { offset = j*width + i; rngval = (rngval*11109 + 13849); - if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],daywindow+smoothwidth,prices2,smoothwidth)) < 0 ) + if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],daywindow,prices2,smoothwidth)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); } for (i=0; i Date: Tue, 2 Apr 2019 10:42:03 -1100 Subject: [PATCH 3684/3904] .9 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0d4274ae5..28913c08e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2372,7 +2372,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 10:47:41 -1100 Subject: [PATCH 3685/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 28913c08e..6d6f8f155 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2372,7 +2372,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz sum = den = 0; for (i=0; i Date: Tue, 2 Apr 2019 10:53:33 -1100 Subject: [PATCH 3686/3904] Test --- src/komodo_gateway.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6d6f8f155..64fcbb957 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2339,7 +2339,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonzprices,int32_t smoothwidth) { - const int64_t coeffs[7] = { 7, 7, 7, 7, 7, 7, 7 }; + const int64_t coeffs[7] = { -1, 9, -45, 0, 45, -9, 1 }; // / 60 int32_t i,iter; int64_t smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; if ( daywindow < 2 ) return(0); @@ -2377,12 +2377,13 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz } smoothed[iter] = (sum / den); } - smoothedsum = smoothedden = 0; + smoothedsum = 0; + smoothedden = 60; for (i=0; i<7; i++) { fprintf(stderr,"%.4f ",(double)smoothed[i]/10000); - smoothedsum += (7-i) * smoothed[i]; - smoothedden += (7-i); + smoothedsum += coeffs[i] * smoothed[i]; + //smoothedden += (7-i); } fprintf(stderr,"-> %.4f\n",(double)(smoothedsum/smoothedden)/10000); return(smoothedsum/smoothedden); From 966fafb2700a4c5543e5381f9191cadf7e1e84f1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 10:54:20 -1100 Subject: [PATCH 3687/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 64fcbb957..6f72f855b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2339,7 +2339,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonzprices,int32_t smoothwidth) { - const int64_t coeffs[7] = { -1, 9, -45, 0, 45, -9, 1 }; // / 60 + const int64_t coeffs[7] = { -1, 9, -45, 1, 45, -9, 1 }; // / 60 int32_t i,iter; int64_t smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; if ( daywindow < 2 ) return(0); @@ -2378,7 +2378,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz smoothed[iter] = (sum / den); } smoothedsum = 0; - smoothedden = 60; + smoothedden = 1; for (i=0; i<7; i++) { fprintf(stderr,"%.4f ",(double)smoothed[i]/10000); From 79120f3cac81e208c97156640c05c9f0b73b7f6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 10:58:48 -1100 Subject: [PATCH 3688/3904] Test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6f72f855b..7507122f3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2339,7 +2339,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonzprices,int32_t smoothwidth) { - const int64_t coeffs[7] = { -1, 9, -45, 1, 45, -9, 1 }; // / 60 + //const int64_t coeffs[7] = { -1, 9, -45, 1, 45, -9, 1 }; // / 60 + const int64_t coeffs[7] = { -2, 0, 18, 32, 18, 0, -2 }; int32_t i,iter; int64_t smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; if ( daywindow < 2 ) return(0); @@ -2378,7 +2379,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz smoothed[iter] = (sum / den); } smoothedsum = 0; - smoothedden = 1; + smoothedden = 64; for (i=0; i<7; i++) { fprintf(stderr,"%.4f ",(double)smoothed[i]/10000); From 8adcc5022c167ac1aed17181a1eabe2b7caa1bd8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 11:04:32 -1100 Subject: [PATCH 3689/3904] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7507122f3..778f5b318 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2315,7 +2315,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( (price= nonzprices[i]) != 0 ) { den += (daywindow - i); - sum += ((daywindow - i) * (price + firstprice*9)) / 10; + sum += ((daywindow - i) * (price + firstprice*4)) / 5; n++; } } @@ -2382,11 +2382,11 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz smoothedden = 64; for (i=0; i<7; i++) { - fprintf(stderr,"%.4f ",(double)smoothed[i]/10000); + //fprintf(stderr,"%.4f ",(double)smoothed[i]/10000); smoothedsum += coeffs[i] * smoothed[i]; //smoothedden += (7-i); } - fprintf(stderr,"-> %.4f\n",(double)(smoothedsum/smoothedden)/10000); + //fprintf(stderr,"-> %.4f\n",(double)(smoothedsum/smoothedden)/10000); return(smoothedsum/smoothedden); } return(0); From 6cf121c5d5d1f9c82d399b2358ac2db6934933ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 11:18:19 -1100 Subject: [PATCH 3690/3904] Smooth64 --- src/komodo_gateway.h | 76 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 778f5b318..6659dcced 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2336,12 +2336,82 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int return(0); } +int64_t _pairave64(int64_t valA,int64_t valB) +{ + if ( valA != 0 && valB != 0 ) + return((valA + valB) / 2); + else if ( valA != 0 ) return(valA); + else return(valB); +} + +int64_t _pairdiff64(register int64_t valA,register int64_t valB) +{ + if ( valA != 0 && valB != 0 ) + return(valA - valB); + else return(0); +} + +int64_t balanced_ave64(int64_t buf[],int32_t i,int32_t width) +{ + register int32_t nonz,j; register int64_t sum,price; + nonz = 0; + sum = 0; + for (j=-width; j<=width; j++) + { + price = buf[i + j]; + if ( price != 0 ) + { + sum += price; + nonz++; + } + } + if ( nonz != 0 ) + sum /= nonz; + return(sum); +} + +void buf_trioave64(int64_t dest[],int64_t src[],int32_t n) +{ + register int32_t i,j,width = 3; + for (i=0; i<128; i++) + src[i] = 0; + //for (i=n-width-1; i>width; i--) + // dest[i] = balanced_ave(src,i,width); + //for (i=width; i>0; i--) + // dest[i] = balanced_ave(src,i,i); + for (i=1; i Date: Tue, 2 Apr 2019 11:19:38 -1100 Subject: [PATCH 3691/3904] smoothwidth --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6659dcced..25b87d6e3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2400,8 +2400,8 @@ void smooth64(int64_t dest[],int64_t src[],int32_t width,int32_t smoothiters) buf_trioave64(smoothbufA,src,width); for (i=0; i Date: Tue, 2 Apr 2019 11:20:39 -1100 Subject: [PATCH 3692/3904] Trioave64 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 25b87d6e3..b1dbfbfe7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2403,7 +2403,7 @@ void smooth64(int64_t dest[],int64_t src[],int32_t width,int32_t smoothiters) buf_trioave64(smoothbufB,smoothbufA,width); buf_trioave64(smoothbufA,smoothbufB,width); } - buf_trioave(dest,smoothbufA,width); + buf_trioave64(dest,smoothbufA,width); } else memcpy(dest,src,width*sizeof(*dest)); } From 9b72450a1f2064c080ad86a6083b361be0e71afb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 11:24:20 -1100 Subject: [PATCH 3693/3904] Revert --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b1dbfbfe7..d16fa4bc5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2411,7 +2411,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz { //const int64_t coeffs[7] = { -1, 9, -45, 1, 45, -9, 1 }; // / 60 const int64_t coeffs[7] = { -2, 0, 18, 32, 18, 0, -2 }; - int32_t i,iter; int64_t dest[1440*3],orig[1440*3],smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; + int32_t i,iter; int64_t smoothedden,smoothedsum,sum,den,smoothed[7],firstprice = correlated[0]; if ( daywindow < 2 ) return(0); if ( smoothwidth != sizeof(smoothed)/sizeof(*smoothed) ) @@ -2438,19 +2438,19 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz correlated[i] = firstprice; else break; } - memcpy(orig,correlated,(daywindow+smoothwidth)*sizeof(*correlated)); + //memcpy(orig,correlated,(daywindow+smoothwidth)*sizeof(*correlated)); for (iter=0; iter Date: Tue, 2 Apr 2019 21:12:33 -1100 Subject: [PATCH 3694/3904] Fix localcache scan control flow --- src/komodo_gateway.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d16fa4bc5..16a96b526 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1816,9 +1816,10 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i if ( PriceCache[j][i] >= prevbits[i] ) { fprintf(stderr,"i.%d within recent localprices[%d] %u >= %u\n",i,j,PriceCache[j][i],prevbits[i]); - continue; + break; } - break; + if ( j == KOMODO_LOCALPRICE_CACHESIZE ) + break; } else if ( maxflag < 0 && localbits[i] > prevbits[i] ) { @@ -1828,9 +1829,10 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i if ( PriceCache[j][i] <= prevbits[i] ) { fprintf(stderr,"i.%d within recent localprices[%d] %u <= prev %u\n",i,j,PriceCache[j][i],prevbits[i]); - continue; + break; } - break; + if ( j == KOMODO_LOCALPRICE_CACHESIZE ) + break; } } } From 4a704517b9d3cbafe5e841a61ef72cd12a310c42 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 21:17:05 -1100 Subject: [PATCH 3695/3904] +print --- src/cc/gamescc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index b804216d7..2a8be815e 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -110,6 +110,7 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_settle(txfee,cp,params)); \ else \ { \ +fprintf(stderr,"invalid method (%s)\n",method); \ result.push_back(Pair("result","error")); \ result.push_back(Pair("error","invalid gamescc method")); \ return(result); \ From 1b6bb2d0a18aa58b22164345013e9dd7477da1bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 21:18:45 -1100 Subject: [PATCH 3696/3904] +print --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 00a7c6fe0..370b1b8e3 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -195,7 +195,7 @@ cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) { UniValue result(UniValue::VOBJ); uint64_t txfee = 10000; int32_t m; cJSON *params = cclib_reparse(&m,jsonstr); - //fprintf(stderr,"method.(%s) -> (%s)\n",jsonstr!=0?jsonstr:"",params!=0?jprint(params,0):""); + fprintf(stderr,"method.(%s) -> (%s)\n",jsonstr!=0?jsonstr:"",params!=0?jprint(params,0):""); #ifdef BUILD_ROGUE if ( cp->evalcode == EVAL_ROGUE ) { From 679d310c5edbd762cd59443f7ae3645afeed1d60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 21:20:45 -1100 Subject: [PATCH 3697/3904] Fix crash on missing method --- src/cc/cclib.cpp | 4 ++-- src/cc/gamescc.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 370b1b8e3..8552cfa1b 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -351,7 +351,7 @@ UniValue CClib_info(struct CCcontract_info *cp) UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr) { UniValue result(UniValue::VOBJ); int32_t i; std::string rawtx; cJSON *params; - //printf("CClib params.(%s)\n",jsonstr!=0?jsonstr:""); +//printf("CClib params.(%s)\n",jsonstr!=0?jsonstr:""); for (i=0; ievalcode == CClib_methods[i].evalcode && strcmp(method,CClib_methods[i].method) == 0 ) @@ -369,7 +369,7 @@ UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr) } } result.push_back(Pair("result","error")); - result.push_back(Pair("method",CClib_methods[i].method)); + result.push_back(Pair("method",method)); result.push_back(Pair("error","method not found")); return(result); } diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index 2a8be815e..b804216d7 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -110,7 +110,6 @@ if ( cp->evalcode == EVAL_GAMES ) \ return(games_settle(txfee,cp,params)); \ else \ { \ -fprintf(stderr,"invalid method (%s)\n",method); \ result.push_back(Pair("result","error")); \ result.push_back(Pair("error","invalid gamescc method")); \ return(result); \ From 5d861c188abddd2c0db60fdf31008a51f52503ed Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 23:37:01 -1100 Subject: [PATCH 3698/3904] -ac_prices --- src/cc/pegs.cpp | 10 ++++++---- src/komodo_defs.h | 1 + src/komodo_gateway.h | 31 ++++++++++++++++++++----------- src/komodo_globals.h | 1 + src/komodo_utils.h | 7 +++++++ 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index c435d9920..dba9fc818 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -16,15 +16,17 @@ #include "CCPegs.h" /* - Pegs CC builds on top of Prices CC and would bind a pricefeed to a token bid/ask automated marketmaking. + Pegs CC builds on top of CCOPRET modes which will create pricefeeds in the coinbase. + flag&1: BTC/USD 4966.1400, BTC/GBP 3770.0402, BTC/EUR 4416.8452 GBPUSD 1.317264, EURUSD 1.124364 EURGBP 0.853560 + flag&2: (BGN 1.7462) (NZD 1.4771) (ILS 3.6258) (RUB 65.3700) (CAD 1.3320) (PHP 52.4160) (CHF 0.9995) (AUD 1.4122) (JPY 111.3660) (TRY 5.5483) (HKD 7.8498) (MYR 4.0816) (HRK 6.6337) (CZK 22.9937) (IDR 14220.0000) (DKK 6.6648) (NOK 8.6111) (HUF 287.2142) (GBP 0.7678) (MXN 19.1046) (THB 31.7500) (ISK 122.4107) (ZAR 14.1300) (BRL 3.8604) (SGD 1.3551) (PLN 3.8350) (INR 68.7531) (KRW 1136.3839) (RON 4.2516) (CNY 6.7200) (SEK 9.3230) (EUR 0.8928) (2019-04-02) +flag&4: (KMD 0.00025110) (ETH 0.03357500) (LTC 0.01642400) (BCHABC 0.05167400) (XMR 0.01398800) (IOTA 0.00007217) (DASH 0.02552600) (XEM 0.00001459) (ZEC 0.01440500) (WAVES 0.00062170) (RVN 0.00001215) (LSK 0.00041130) (DCR 0.00496000) (BTS 0.00001444) (ICX 0.00008750) (HOT 0.00000027) (STEEM 0.00010070) (ENJ 0.00003221) (STRAT 0.00022790) errs.0 + Funds deposited into CC address for a specific peg would then be used to fund the bid/ask as the pricefeed changes the price. Profits/losses would accumulate in the associated address. In the event funds exceed a specified level, it can be spent into a collection address. The idea is that the collection address can further be used for revshares. - int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format); - - OraclePrice is very useful for pegs. + */ diff --git a/src/komodo_defs.h b/src/komodo_defs.h index b0f618e93..c1eeb375b 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -59,6 +59,7 @@ extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NO extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; +extern std::vector ASSETCHAINS_PRICES; extern char ASSETCHAINS_SYMBOL[65]; extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 16a96b526..620ba1f9b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1553,7 +1553,6 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR #define KOMODO_LOCALPRICE_CACHESIZE 7 - #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "DASH", "XEM", "ZEC", "WAVES", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" }; // must be on binance (for now) @@ -1563,6 +1562,7 @@ const char *Forex[] = }; // must be in ECB list uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)]; +int32_t komodo_cbopretsize(uint64_t flags); void komodo_PriceCache_shift() { @@ -1722,7 +1722,7 @@ CScript komodo_mineropret(int32_t nHeight) The only way komodo_opretvalidate() doesnt return an error is if maxflag is set or it is within tolerance of both the prior block and the local data. The local data validation only happens if it is a recent block and not a block from the past as the local node is only getting the current price data. */ -// reconsiderblock 002aca768b09dfcf36bd934ab34b23983148b116e12cb0b6e1a3f895d1db63aa +// for PRICES: reconsiderblock 002aca768b09dfcf36bd934ab34b23983148b116e12cb0b6e1a3f895d1db63aa // and // reconsiderblock 0034cf582018eacc0b4ae001491ce460113514cb1a3f217567ef4a2207de361a // reconsiderbloc 000abf51c023b64af327c50c1b060797b8cb281c696d30ab92fd002a8b8c9aea @@ -1732,7 +1732,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 500; + int32_t testchain_exemption = 0; std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { @@ -1753,7 +1753,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < -testchain_exemption ) // must be close to last block timestamp + if ( lag2 < -60 ) //testchain_exemption ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) @@ -2107,6 +2107,19 @@ int32_t get_btcusd(uint32_t pricebits[4]) // komodo_cbopretupdate() obtains the external price data and encodes it into Mineropret, which will then be used by the miner and validation // save history, use new data to approve past rejection, where is the auto-reconsiderblock? +int32_t komodo_cbopretsize(uint64_t flags) +{ + int32_t size = 0; + if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) + { + size = PRICES_SIZEBIT0; + if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) + size += sizeof(forexprices); + if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) + size += sizeof(cryptoprices); + } + return(size); +} void komodo_cbopretupdate(int32_t forceflag) { @@ -2123,13 +2136,9 @@ void komodo_cbopretupdate(int32_t forceflag) now = (uint32_t)time(NULL); if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) { -if ( komodo_nextheight() > 333 ) // for debug only! - ASSETCHAINS_CBOPRET = 7; - size = PRICES_SIZEBIT0; - if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) - size += sizeof(forexprices); - if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) - size += sizeof(cryptoprices); +//if ( komodo_nextheight() > 333 ) // for debug only! +// ASSETCHAINS_CBOPRET = 7; + size = komodo_cbopretsize(ASSETCHAINS_CBOPRET); if ( Mineropret.size() < size ) Mineropret.resize(size); size = PRICES_SIZEBIT0; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 097d10da0..1c47e72e6 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -72,6 +72,7 @@ uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAIN uint64_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; uint8_t ASSETCHAINS_CCDISABLES[256]; +std::vector ASSETCHAINS_PRICES; #define _ASSETCHAINS_EQUIHASH 0 uint32_t ASSETCHAINS_NUMALGOS = 3; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a2eb3d5a1..a382e8c22 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1812,6 +1812,13 @@ void komodo_args(char *argv0) ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); + if ( ASSETCHAINS_CBOPRET != 0 ) + { + Split(GetArg("-ac_prices",""), ASSETCHAINS_PRICES, 0); + for (i=0; i Date: Tue, 2 Apr 2019 23:47:37 -1100 Subject: [PATCH 3699/3904] SplitStr --- src/komodo_gateway.h | 3 ++- src/komodo_utils.h | 5 +++-- src/util.cpp | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 620ba1f9b..1d1379c15 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2109,7 +2109,8 @@ int32_t get_btcusd(uint32_t pricebits[4]) int32_t komodo_cbopretsize(uint64_t flags) { - int32_t size = 0; + int32_t size = 0; uint32_t cryptoprices[sizeof(Cryptos)/sizeof(*Cryptos)],forexprices[sizeof(Forex)/sizeof(*Forex)]; + if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) { size = PRICES_SIZEBIT0; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a382e8c22..0d8b2ed63 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1665,6 +1665,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) extern int64_t MAX_MONEY; void komodo_cbopretupdate(int32_t forceflag); +void SplitStr(const std::string& strVal, std::vector outVals); void komodo_args(char *argv0) { @@ -1814,9 +1815,9 @@ void komodo_args(char *argv0) ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); if ( ASSETCHAINS_CBOPRET != 0 ) { - Split(GetArg("-ac_prices",""), ASSETCHAINS_PRICES, 0); + SplitStr(GetArg("-ac_prices",""), ASSETCHAINS_PRICES); for (i=0; i outVals) +{ + stringstream ss(strVal); + vector str; + + while ( ss.peek() == ' ' ) + ss.ignore(); + + while ( ss >> str ) + { + //outVals[numVals] = i; + outVals.push_back(i); + numVals += 1; + + while ( ss.peek() == ' ' ) + ss.ignore(); + if ( ss.peek() == ',' ) + ss.ignore(); + while ( ss.peek() == ' ' ) + ss.ignore(); + } +} + void Split(const std::string& strVal, uint64_t *outVals, const uint64_t nDefault) { stringstream ss(strVal); From 2c272b175d0924ea452da3104ed6e153a45bfa42 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 23:53:14 -1100 Subject: [PATCH 3700/3904] Str --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 44e2c2dac..cca39ca38 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -405,7 +405,7 @@ void SplitStr(const std::string& strVal, std::vector outVals) while ( ss >> str ) { //outVals[numVals] = i; - outVals.push_back(i); + outVals.push_back(str); numVals += 1; while ( ss.peek() == ' ' ) From 7d4e16646ef3ba0c0e959323f4597bc966ffd6c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 2 Apr 2019 23:54:51 -1100 Subject: [PATCH 3701/3904] -= --- src/util.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index cca39ca38..ebc6dbccb 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -404,10 +404,7 @@ void SplitStr(const std::string& strVal, std::vector outVals) while ( ss >> str ) { - //outVals[numVals] = i; outVals.push_back(str); - numVals += 1; - while ( ss.peek() == ' ' ) ss.ignore(); if ( ss.peek() == ',' ) From cf437222feb010d555c4267d377789fb98bcccc0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 00:03:17 -1100 Subject: [PATCH 3702/3904] Unsmooth --- src/komodo_gateway.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1d1379c15..4f59141f5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2261,13 +2261,13 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int mult = 10000; else mult = 1; memset(nonzprices,0,sizeof(*nonzprices)*daywindow); - for (iter=0; iter (daywindow>>1) ) { + return(refprice * mult); //fprintf(stderr,"-> %.4f\n",(double)sum*mult/correlation); //return(sum*mult/correlation); n = 0; @@ -2458,8 +2459,8 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t daywindow,int64_t *nonz //smooth64(correlated+iter,dest,daywindow,1); for (i=0; i Date: Wed, 3 Apr 2019 00:06:05 -1100 Subject: [PATCH 3703/3904] Std::string --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index ebc6dbccb..4265ff759 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -397,7 +397,7 @@ void ParseParameters(int argc, const char* const argv[]) void SplitStr(const std::string& strVal, std::vector outVals) { stringstream ss(strVal); - vector str; + std::string str; while ( ss.peek() == ' ' ) ss.ignore(); From 5b9a4c353a8cfc9552c8afde59f849feb72d81b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 00:27:09 -1100 Subject: [PATCH 3704/3904] Revert incompatible changes --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4f59141f5..6862fcf14 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1732,7 +1732,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 0; + int32_t testchain_exemption = 350; std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { @@ -1753,7 +1753,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < -60 ) //testchain_exemption ) // must be close to last block timestamp + if ( lag2 < -testchain_exemption ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) @@ -2137,8 +2137,8 @@ void komodo_cbopretupdate(int32_t forceflag) now = (uint32_t)time(NULL); if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) { -//if ( komodo_nextheight() > 333 ) // for debug only! -// ASSETCHAINS_CBOPRET = 7; +if ( komodo_nextheight() > 333 ) // for debug only! + ASSETCHAINS_CBOPRET = 7; size = komodo_cbopretsize(ASSETCHAINS_CBOPRET); if ( Mineropret.size() < size ) Mineropret.resize(size); From 43e0d2fec6f390fdd391e94c714f306097556252 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 05:58:14 -1100 Subject: [PATCH 3705/3904] -ac_prices --- src/komodo_gateway.h | 98 ++++++++++++++++++++++++++---------------- src/komodo_utils.h | 13 +++++- src/rpc/blockchain.cpp | 5 ++- 3 files changed, 76 insertions(+), 40 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6862fcf14..b70574677 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1552,6 +1552,7 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define PRICES_MAXCHANGE (COIN / 100) // maximum acceptable change, set at 1% #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR #define KOMODO_LOCALPRICE_CACHESIZE 7 +#define KOMODO_MAXPRICES 2048 #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) @@ -1561,18 +1562,15 @@ const char *Forex[] = { "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" }; // must be in ECB list -uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)]; +uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][KOMODO_MAXPRICES];//4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)]; +int64_t PriceMult[KOMODO_MAXPRICES]; int32_t komodo_cbopretsize(uint64_t flags); void komodo_PriceCache_shift() { int32_t i; for (i=KOMODO_LOCALPRICE_CACHESIZE-1; i>0; i--) - { memcpy(PriceCache[i],PriceCache[i-1],sizeof(PriceCache[i])); - //for (j=0; j<4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex); j++) - // PriceCache[i][j] = PriceCache[i-1][j]; - } memcpy(PriceCache[0],Mineropret.data(),Mineropret.size()); } @@ -1657,7 +1655,7 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *price // komodo_priceclamp() clamps any price that is beyond tolerance int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int64_t tolerance) { - int32_t i; uint32_t newprice; char maxflags[2048]; + int32_t i; uint32_t newprice; char maxflags[KOMODO_MAXPRICES]; memset(maxflags,0,sizeof(maxflags)); for (i=1; i= PRICES_SIZEBIT0 ) { n = (int32_t)(Mineropret.size() / sizeof(uint32_t)); @@ -1727,13 +1725,11 @@ CScript komodo_mineropret(int32_t nHeight) // reconsiderblock 0034cf582018eacc0b4ae001491ce460113514cb1a3f217567ef4a2207de361a // reconsiderbloc 000abf51c023b64af327c50c1b060797b8cb281c696d30ab92fd002a8b8c9aea // are needed to sync past initial blocks with different data set -// pass in blockhash and nTime, latch if it is rejected due to local price, then if localprice changes in a way that would validate then issue reconsiderblock -// add rpc call for extracting rawprices int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 350; - std::vector vopret; char maxflags[2048]; double btcusd,btcgbp,btceur; uint32_t localbits[2048],pricebits[2048],prevbits[2048],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); + int32_t testchain_exemption = 0; + std::vector vopret; char maxflags[KOMODO_MAXPRICES]; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { GetOpReturnData(scriptPubKey,vopret); @@ -1753,7 +1749,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i fprintf(stderr,"A ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3); return(-1); } - if ( lag2 < -testchain_exemption ) // must be close to last block timestamp + if ( lag2 < -60 ) //testchain_exemption ) // must be close to last block timestamp { fprintf(stderr,"B ht.%d now.%u htstamp.%u %u - pricebits[0] %u -> lags.%d %d %d vs %d cmp.%d\n",nHeight,now,prevtime,block->nTime,pricebits[0],lag,lag2,lag3,ASSETCHAINS_BLOCKTIME,lag2<-ASSETCHAINS_BLOCKTIME); if ( nHeight > testchain_exemption ) @@ -2028,14 +2024,17 @@ uint32_t get_binanceprice(const char *symbol) return(price); } -int32_t get_cryptoprices(uint32_t *prices,const char *list[],int32_t n) +int32_t get_cryptoprices(uint32_t *prices,const char *list[],int32_t n,std::vector strvec) { - int32_t i,errs=0; uint32_t price; + int32_t i,errs=0; uint32_t price; char *symbol; for (i=0; i 333 ) // for debug only! - ASSETCHAINS_CBOPRET = 7; +//if ( komodo_nextheight() > 333 ) // for debug only! +// ASSETCHAINS_CBOPRET = 7; size = komodo_cbopretsize(ASSETCHAINS_CBOPRET); if ( Mineropret.size() < size ) Mineropret.resize(size); @@ -2160,19 +2158,19 @@ if ( komodo_nextheight() > 333 ) // for debug only! flags |= 2; memcpy(&PriceCache[0][size/sizeof(uint32_t)],forexprices,sizeof(forexprices)); } - size += sizeof(forexprices); + size += (sizeof(Forex)/sizeof(*Forex)) * sizeof(uint32_t); } if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) { if ( forceflag != 0 || flags != 0 ) { - get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos))); + get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos)),ASSETCHAINS_PRICES); if ( flags == 0 ) komodo_PriceCache_shift(); - memcpy(&PriceCache[0][size/sizeof(uint32_t)],cryptoprices,sizeof(cryptoprices)); + memcpy(&PriceCache[0][size/sizeof(uint32_t)],cryptoprices,(sizeof(Cryptos)/sizeof(*Cryptos)+ASSETCHAINS_PRICES.size()) * sizeof(uint32_t)); flags |= 4; // very rarely we can see flags == 6 case } - size += sizeof(cryptoprices); + size += (sizeof(Cryptos)/sizeof(*Cryptos)+ASSETCHAINS_PRICES.size()) * sizeof(uint32_t); } if ( flags != 0 ) { @@ -2205,10 +2203,35 @@ if ( komodo_nextheight() > 333 ) // for debug only! pending = 0; } +int64_t komodo_pricemult(int32_t ind) +{ + int32_t i,j; + if ( (ASSETCHAINS_CBOPRET & 1) != 0 && ind < KOMODO_MAXPRICES ) + { + if ( PriceMult[0] == 0 ) + { + for (i=0; i<4; i++) + PriceMult[i] = 10000; + if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) + { + for (j=0; j= KOMODO_MAXPRICES ) return(-1); - if ( ind < 36 ) - mult = 10000; - else mult = 1; + mult = PriceMult[ind]; memset(nonzprices,0,sizeof(*nonzprices)*daywindow); for (iter=0; iter outVals); void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn,hexstr; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_STAKED_NOTARY = GetArg("-stakednotary", -1); if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) { @@ -1735,7 +1735,7 @@ void komodo_args(char *argv0) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); } - if ( name.c_str()[0] != 0 ) + if ( name.c_str()[0] != 0 ) { std::string selectedAlgo = GetArg("-ac_algo", std::string(ASSETCHAINS_ALGORITHMS[0])); @@ -2075,6 +2075,15 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CBOPRET != 0 ) { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET); + if ( ASSETCHAINS_PRICES.size() != 0 ) + { + for (i=0; i Date: Wed, 3 Apr 2019 06:07:13 -1100 Subject: [PATCH 3706/3904] Move symbols --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b70574677..8c976ebe1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1556,8 +1556,8 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) -const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "DASH", "XEM", "ZEC", "WAVES", "RVN", "LSK", "DCR", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" }; // must be on binance (for now) - +const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "ZEC", "WAVES", "LSK", "DCR" }; // must be on binance (for now) +//"RVN", "DASH", "XEM", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" const char *Forex[] = { "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" }; // must be in ECB list From ddee092afbe481b075c4c5107eaad02d06822aa7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 06:08:56 -1100 Subject: [PATCH 3707/3904] Fix --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8c976ebe1..a81a6c6f3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2030,8 +2030,8 @@ int32_t get_cryptoprices(uint32_t *prices,const char *list[],int32_t n,std::vect for (i=0; i Date: Wed, 3 Apr 2019 06:10:27 -1100 Subject: [PATCH 3708/3904] "RVN", "DASH", "XEM", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" --- src/rpc/blockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 7e7a44f7c..5f1d671e4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1180,7 +1180,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices,int64_t *corr int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices,uint32_t *rawprices2,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); -int64_t komodo_pricesmult(int32_t ind); +int64_t komodo_pricemult(int32_t ind); UniValue prices(const UniValue& params, bool fHelp) { @@ -1252,7 +1252,7 @@ UniValue prices(const UniValue& params, bool fHelp) offset = j*width + i; smoothed = komodo_pricesmoothed(&correlated[i],daywindow,correlated2,smoothwidth); UniValue parr(UniValue::VARR); - parr.push_back(ValueFromAmount((int64_t)prices[offset] * komodo_pricesmult(j))); + parr.push_back(ValueFromAmount((int64_t)prices[offset] * komodo_pricemult(j))); parr.push_back(ValueFromAmount(correlated[i])); parr.push_back(ValueFromAmount(smoothed)); p.push_back(parr); From 02938d0a127484a3e2b979fd09c8a7d57898242c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 06:13:37 -1100 Subject: [PATCH 3709/3904] Test --- src/komodo_utils.h | 2 +- src/util.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c807eff48..2d0fe4f4e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1665,7 +1665,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) extern int64_t MAX_MONEY; void komodo_cbopretupdate(int32_t forceflag); -void SplitStr(const std::string& strVal, std::vector outVals); +void SplitStr(const std::string& strVal, std::vector &outVals); void komodo_args(char *argv0) { diff --git a/src/util.cpp b/src/util.cpp index 4265ff759..b8733ffca 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -394,7 +394,7 @@ void ParseParameters(int argc, const char* const argv[]) } } -void SplitStr(const std::string& strVal, std::vector outVals) +void SplitStr(const std::string& strVal, std::vector &outVals) { stringstream ss(strVal); std::string str; From cd16c88711502ce727863730fb39b209e363a62a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 06:22:53 -1100 Subject: [PATCH 3710/3904] Fix --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a81a6c6f3..28ed3ee3a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1556,8 +1556,8 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) -const char *Cryptos[] = { "KMD", "ETH", "LTC", "BCHABC", "XMR", "IOTA", "ZEC", "WAVES", "LSK", "DCR" }; // must be on binance (for now) -//"RVN", "DASH", "XEM", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" +const char *Cryptos[] = { "KMD", "ETH" }; // must be on binance (for now) +// "LTC", "BCHABC", "XMR", "IOTA", "ZEC", "WAVES", "LSK", "DCR", "RVN", "DASH", "XEM", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" const char *Forex[] = { "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" }; // must be in ECB list @@ -2027,7 +2027,7 @@ uint32_t get_binanceprice(const char *symbol) int32_t get_cryptoprices(uint32_t *prices,const char *list[],int32_t n,std::vector strvec) { int32_t i,errs=0; uint32_t price; char *symbol; - for (i=0; i Date: Wed, 3 Apr 2019 06:37:57 -1100 Subject: [PATCH 3711/3904] Remove , --- src/util.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util.cpp b/src/util.cpp index b8733ffca..980d82ac9 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -404,6 +404,10 @@ void SplitStr(const std::string& strVal, std::vector &outVals) while ( ss >> str ) { + if ( str.size() == 0 ) + continue; + if ( str[str.size()-1] == ',' ) + str.resize(str.size()-1); outVals.push_back(str); while ( ss.peek() == ' ' ) ss.ignore(); From 9b565ea675e39a68214e51ee64cd992d38f81305 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 07:00:43 -1100 Subject: [PATCH 3712/3904] Handle early block prices --- src/rpc/blockchain.cpp | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5f1d671e4..ce27238a9 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1188,7 +1188,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t smoothed,*correlated,*correlated2; char name[64],*str; uint32_t rawprices[1440*6],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t smoothed,*correlated,*correlated2; char name[64],*str; uint32_t rawprices[1440*6],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,num,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; if ( ASSETCHAINS_CBOPRET == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); @@ -1225,6 +1225,7 @@ UniValue prices(const UniValue& params, bool fHelp) } else throw JSONRPCError(RPC_INVALID_PARAMETER, "no komodo_rawprices found"); } } + num = i; ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); UniValue timestamps(UniValue::VARR); for (i=0; i= width ) { - offset = j*width + i; - rngval = (rngval*11109 + 13849); - if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],daywindow,prices2,smoothwidth)) < 0 ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); + for (i=0; i Date: Wed, 3 Apr 2019 07:01:10 -1100 Subject: [PATCH 3713/3904] Parr -> p --- src/rpc/blockchain.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ce27238a9..61ea71476 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1266,9 +1266,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Wed, 3 Apr 2019 07:02:44 -1100 Subject: [PATCH 3714/3904] numsamples --- src/rpc/blockchain.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 61ea71476..18927ce8b 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1188,7 +1188,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t smoothed,*correlated,*correlated2; char name[64],*str; uint32_t rawprices[1440*6],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,num,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t smoothed,*correlated,*correlated2; char name[64],*str; uint32_t rawprices[1440*6],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,numsamples,nextheight,offset,ht,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; if ( ASSETCHAINS_CBOPRET == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); @@ -1225,7 +1225,7 @@ UniValue prices(const UniValue& params, bool fHelp) } else throw JSONRPCError(RPC_INVALID_PARAMETER, "no komodo_rawprices found"); } } - num = i; + numsamples = i; ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); UniValue timestamps(UniValue::VARR); for (i=0; i= width ) + if ( numsamples >= width ) { - for (i=0; i Date: Wed, 3 Apr 2019 07:07:25 -1100 Subject: [PATCH 3715/3904] Test --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 18927ce8b..e7893a458 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1266,7 +1266,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Wed, 3 Apr 2019 07:10:39 -1100 Subject: [PATCH 3716/3904] -) --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index e7893a458..fe4d71bf4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1266,7 +1266,7 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Wed, 3 Apr 2019 07:13:40 -1100 Subject: [PATCH 3717/3904] Nested --- src/rpc/blockchain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index fe4d71bf4..11c8067f7 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1266,7 +1266,9 @@ UniValue prices(const UniValue& params, bool fHelp) for (i=0; i Date: Wed, 3 Apr 2019 07:16:02 -1100 Subject: [PATCH 3718/3904] Ht limit --- src/rpc/blockchain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 11c8067f7..0b0f0030c 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1207,7 +1207,8 @@ UniValue prices(const UniValue& params, bool fHelp) correlated = (int64_t *)calloc(sizeof(*correlated),width); correlated2 = (int64_t *)calloc(sizeof(*correlated2),width); prices2 = (uint32_t *)calloc(sizeof(*prices2),width); - for (ht=nextheight-1,i=0; i2*daywindow+2+smoothwidth; i++,ht--) + i = 0; + for (ht=nextheight-1,i=0; i2; i++,ht--) { if ( ht < 0 || ht > chainActive.Height() ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); From bf4a8750f3a18c2cdf814ac6c89e28b585d3c32b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 20:44:46 -1100 Subject: [PATCH 3719/3904] Change correlation factor to 4 --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6862fcf14..7076f7808 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2266,8 +2266,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation = 0; i = (iter + seed) % daywindow; refprice = rawprices[i]; - highprice = (refprice * (COIN + PRICES_MAXCHANGE*3)) / COIN; - lowprice = (refprice * (COIN - PRICES_MAXCHANGE*3)) / COIN; + highprice = (refprice * (COIN + PRICES_MAXCHANGE*4)) / COIN; + lowprice = (refprice * (COIN - PRICES_MAXCHANGE*4)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) From 9561e30a283b42def4621ad3e3c94fab8cc52cd4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 20:48:38 -1100 Subject: [PATCH 3720/3904] 5% --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7076f7808..e42b8aa4b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2266,8 +2266,8 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int correlation = 0; i = (iter + seed) % daywindow; refprice = rawprices[i]; - highprice = (refprice * (COIN + PRICES_MAXCHANGE*4)) / COIN; - lowprice = (refprice * (COIN - PRICES_MAXCHANGE*4)) / COIN; + highprice = (refprice * (COIN + PRICES_MAXCHANGE*5)) / COIN; + lowprice = (refprice * (COIN - PRICES_MAXCHANGE*5)) / COIN; if ( highprice == refprice ) highprice++; if ( lowprice == refprice ) From 3155223e5176b534eea98b4448fb81954a453de3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Apr 2019 21:17:53 -1100 Subject: [PATCH 3721/3904] Compiler errors --- src/cc/CCPrices.h | 22 +- src/cc/payments.cpp | 72 ++++ src/cc/prices.cpp | 835 +++++++++++++++++++++++++---------------- src/komodo_defs.h | 1 + src/komodo_gateway.h | 117 +++--- src/rpc/blockchain.cpp | 69 +++- src/txdb.cpp | 109 +++++- 7 files changed, 800 insertions(+), 425 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 1a68be7dd..9f3039a6b 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -18,17 +18,27 @@ #define CC_PRICES_H #include "CCinclude.h" +int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind,int32_t daywindow); + +#define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) +#define PRICES_TXFEE 10000 +#define PRICES_SMOOTHWIDTH 1 +#define KOMODO_MAXPRICES 2048 // must be power of 2 and less than 8192 +#define KOMODO_PRICEMASK (~(KOMODO_MAXPRICES - 1)) +#define PRICES_WEIGHT (KOMODO_MAXPRICES * 1) +#define PRICES_MUL (KOMODO_MAXPRICES * 2) +#define PRICES_DIV (KOMODO_MAXPRICES * 3) +#define PRICES_INV (KOMODO_MAXPRICES * 4) +#define PRICES_MDD (KOMODO_MAXPRICES * 5) +#define PRICES_MMD (KOMODO_MAXPRICES * 6) +#define PRICES_MMM (KOMODO_MAXPRICES * 7) +#define PRICES_DDD (KOMODO_MAXPRICES * 8) bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom UniValue PricesList(); -UniValue PricesInfo(uint256 fundingtxid); -UniValue PricesStatus(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,uint256 bettxid); -std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletxid,uint64_t margin,uint64_t mode,uint256 longtoken,uint256 shorttoken,int32_t maxleverage,int64_t funding,std::vector pubkeys); -std::string PricesAddFunding(uint64_t txfee,uint256 bettoken,uint256 fundingtxid,int64_t amount); -std::string PricesBet(uint64_t txfee,uint256 bettoken,uint256 fundingtxid,int64_t amount,int32_t leverage); -std::string PricesFinish(uint64_t txfee,uint256 bettoken,uint256 fundingtxid,uint256 bettxid); +UniValue PricesBet(uint64_t txfee,int64_t amount,int32_t leverage,std::string synthetic); #endif diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index e0c4c8ada..ae83e2661 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -732,6 +732,78 @@ UniValue PaymentsCreate(struct CCcontract_info *cp,char *jsonstr) return(result); } +UniValue PaymentsAirdrop(struct CCcontract_info *cp,char *jsonstr) +{ + // need to code: exclude list of tokenid, dust threshold, maxpayees, excluded pubkeys[] + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); CTransaction tx; CPubKey Paymentspk,mypk; char markeraddr[64]; std::vector txidoprets; uint256 hashBlock; int32_t i,n,numoprets=0,lockedblocks,minrelease; std::string rawtx; int64_t totalallocations = 0; + cJSON *params = payments_reparse(&n,jsonstr); + if ( params != 0 && n >= 4 ) + { + lockedblocks = juint(jitem(params,0),0); + minrelease = juint(jitem(params,1),0); + if ( lockedblocks < 0 || minrelease < 0 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","negative parameter")); + if ( params != 0 ) + free_json(params); + return(result); + } + for (i=0; i scriptPubKey,opret; int64_t allocation; + if ( myGetTransaction(txidoprets[i],tx,hashBlock) != 0 && tx.vout.size() > 1 && DecodePaymentsTxidOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,allocation,scriptPubKey,opret) == 'T' ) + { + totalallocations += allocation; + if ( opret.size() > 0 ) + numoprets++; + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid txidopret")); + result.push_back(Pair("txid",txidoprets[i].GetHex())); + result.push_back(Pair("txi",(int64_t)i)); + if ( params != 0 ) + free_json(params); + return(result); + } + } + if ( numoprets > 1 ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","too many opreturns")); + result.push_back(Pair("numoprets",(int64_t)numoprets)); + if ( params != 0 ) + free_json(params); + return(result); + } + mypk = pubkey2pk(Mypubkey()); + Paymentspk = GetUnspendable(cp,0); + if ( AddNormalinputs(mtx,mypk,2*PAYMENTS_TXFEE,60) > 0 ) + { + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,PAYMENTS_TXFEE,Paymentspk,Paymentspk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,EncodePaymentsOpRet(lockedblocks,minrelease,totalallocations,txidoprets)); + if ( params != 0 ) + free_json(params); + return(payments_rawtxresult(result,rawtx,1)); + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough normal funds")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","parameters error")); + } + if ( params != 0 ) + free_json(params); + return(result); +} + UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx,txO; CPubKey Paymentspk,txidpk; int32_t i,j,n,flag=0,numoprets=0,lockedblocks,minrelease; std::vector txidoprets; int64_t funds,fundsopret,totalallocations=0,allocation; char fundsaddr[64],fundsopretaddr[64],txidaddr[64],*outstr; uint256 createtxid,hashBlock; diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 1ab5aa1cb..eab975acd 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -17,123 +17,115 @@ #include "CCPrices.h" /* - Prices CC would best build on top of the oracles CC, ie. to combine payments for multiple oracles and to calculate a 51% protected price feed. +CBOPRET creates trustless oracles, which can be used for making a synthetic cash settlement system based on real world prices; - We need to assume there is an oracle for a specific price. In the event there are more than one provider, the majority need to be within correlation distance to update a pricepoint. - - int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format); - - Using the above function, a consensus price can be obtained for a datasource. + 0.5% fee based on betamount, NOT leveraged betamount!! + 0.1% collected by price basis determinant + 0.2% collected by rekt tx - given an oracletxid, the marketaddr and format can be extracted to be used for future calls to OraclePrice. This allows to set a starting price and that in turn allows cash settled leveraged trading! + PricesBet -> +/-leverage, amount, synthetic -> opreturn includes current price + funds are locked into 1of2 global CC address + for first day, long basis is MAX(correlated,smoothed), short is MIN() + reference price is the smoothed of the previous block + if synthetic value + amount goes negative, then anybody can rekt it to collect a rektfee, proof of rekt must be included to show cost basis, rekt price + original creator can liquidate at anytime and collect (synthetic value + amount) from globalfund + 0.5% of bet -> globalfund + + PricesStatus -> bettxid maxsamples returns initial params, cost basis, amount left, rekt:true/false, rektheight, initial synthetic price, current synthetic price, net gain - Funds work like with dice, ie. there is a Prices plan that traders bet against. + PricesRekt -> bettxid height -> 0.1% to miner, rest to global CC - PricesFunding oracletxid, margin, priceaveraging, maxleverage, funding, longtoken, shorttoken, N [pubkeys] + PricesClose -> bettxid returns (synthetic value + amount) - PricesBet -> oracletxid start with 'L', leverage, funding, direction - funds are locked into global CC address - it can be closed at anytime by the trader for cash settlement - the house account can close it if rekt + PricesList -> all bettxid -> list [bettxid, netgain] - Implementation Notes: - In order to eliminate the need for worrying about sybil attacks, each prices plan would be able to specific pubkey(s?) for whitelisted publishers. It would be possible to have a non-whitelisted plan that would use 50% correlation between publishers. - - delta neutral balancing of riskexposure: fabs(long exposure - short exposure) - bet +B at leverage L - absval(sum(+BLi) - sum(-Bli)) - - validate: update riskexposure and it needs to be <= funds - - PricesProfits: limit withdraw to funds in excess of riskexposure - PricesFinish: payout (if winning) and update riskexposure - need long/short exposure assets - - funding -> 1of2 CC global CC address and dealer address, exposure tokens to global 1of2 assets CC address - pricebet -> user funds and exposure token to 1of2 address. - pricewin -> winnings from dealer funds, exposure token back to global address - priceloss -> exposuretoken back to global address - - exposure address, funds address - - */ // start of consensus code -int64_t PricesOraclePrice(int64_t &rektprice,uint64_t mode,uint256 oracletxid,std::vectorpubkeys,int32_t dir,int64_t amount,int32_t leverage) -{ - int64_t price; - // howto ensure price when block it confirms it not known - // get price from oracle + current chaintip - // normalize leveraged amount - if ( dir > 0 ) - rektprice = price * leverage / (leverage-1); - else rektprice = price * (leverage-1) / leverage; - return(price); -} - -CScript EncodePricesFundingOpRet(uint8_t funcid,CPubKey planpk,uint256 oracletxid,uint256 longtoken,uint256 shorttoken,int32_t millimargin,uint64_t mode,int32_t maxleverage,std::vector pubkeys,uint256 bettoken) +CScript prices_betopret(CPubKey mypk,int32_t height,int64_t amount,int16_t leverage,int64_t firstprice,std::vector vec,uint256 tokenid) { CScript opret; - fprintf(stderr,"implement EncodePricesFundingOpRet\n"); + opret << OP_RETURN << E_MARSHAL(ss << EVAL_PRICES << 'B' << mypk << height << amount << leverage << firstprice << vec << tokenid); return(opret); } -uint8_t DecodePricesFundingOpRet(CScript scriptPubKey,CPubKey &planpk,uint256 &oracletxid,uint256 &longtoken,uint256 &shorttoken,int32_t &millimargin,uint64_t &mode,int32_t &maxleverage,std::vector &pubkeys,uint256 &bettoken) +uint8_t prices_betopretdecode(CScript scriptPubKey,CPubKey &pk,int32_t &height,int64_t &amount,int16_t &leverage,int64_t &firstprice,std::vector &vec,uint256 &tokenid) { - fprintf(stderr,"implement DecodePricesFundingOpRet\n"); + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk; ss >> height; ss >> amount; ss >> leverage; ss >> firstprice; ss >> vec; ss >> tokenid) != 0 && e == EVAL_PRICES && f == 'B' ) + { + return(f); + } + return(0); +} + +CScript prices_addopret(uint256 bettxid,CPubKey mypk,int64_t amount) +{ + CScript opret; + opret << OP_RETURN << E_MARSHAL(ss << EVAL_PRICES << 'A' << bettxid << mypk << amount); + return(opret); +} + +uint8_t prices_addopretdecode(CScript scriptPubKey,uint256 &bettxid,CPubKey &pk,int64_t &amount) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> bettxid; ss >> pk; ss >> amount) != 0 && e == EVAL_PRICES && f == 'A' ) + { + return(f); + } + return(0); +} + +CScript prices_costbasisopret(uint256 bettxid,CPubKey mypk,int32_t height,int64_t costbasis) +{ + CScript opret; + opret << OP_RETURN << E_MARSHAL(ss << EVAL_PRICES << 'C' << bettxid << mypk << height << costbasis); + return(opret); +} + +uint8_t prices_costbasisopretdecode(CScript scriptPubKey,uint256 &bettxid,CPubKey &pk,int32_t &height,int64_t &costbasis) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> bettxid; ss >> pk; ss >> height; ss >> costbasis) != 0 && e == EVAL_PRICES && f == 'C' ) + { + return(f); + } + return(0); +} + +CScript prices_finalopret(uint256 bettxid,int64_t profits,int32_t height,CPubKey mypk,int64_t firstprice,int64_t costbasis,int64_t addedbets,int64_t positionsize,int16_t leverage) +{ + CScript opret; + opret << OP_RETURN << E_MARSHAL(ss << EVAL_PRICES << 'F' << bettxid << profits << height << mypk << firstprice << costbasis << addedbets << positionsize << leverage); + return(opret); +} + +uint8_t prices_finalopretdecode(CScript scriptPubKey,uint256 &bettxid,int64_t &profits,int32_t &height,CPubKey &pk,int64_t &firstprice,int64_t &costbasis,int64_t &addedbets,int64_t &positionsize,int16_t &leverage) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> bettxid; ss >> profits; ss >> height; ss >> pk; ss >> firstprice; ss >> costbasis; ss >> addedbets; ss >> positionsize; ss >> leverage) != 0 && e == EVAL_PRICES && f == 'F' ) + { + return(f); + } return(0); } bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { - int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; - - return true; // TODO remove, for test dual-evals - - return eval->Invalid("no validation yet"); - std::vector > txids; - numvins = tx.vin.size(); - numvouts = tx.vout.size(); - preventCCvins = preventCCvouts = -1; - if ( numvouts < 1 ) - return eval->Invalid("no vouts"); - else - { - for (i=0; iInvalid("illegal normal vini"); - } - } - //fprintf(stderr,"check amounts\n"); - //if ( PricesExactAmounts(cp,eval,tx,1,10000) == false ) - { - fprintf(stderr,"Pricesget invalid amount\n"); - return false; - } - //else - { - txid = tx.GetHash(); - memcpy(hash,&txid,sizeof(hash)); - retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); - if ( retval != 0 ) - fprintf(stderr,"Pricesget validated\n"); - else fprintf(stderr,"Pricesget invalid\n"); - return(retval); - } - } + return true; } // end of consensus code // helper functions for rpc calls in rpcwallet.cpp -int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char *destaddr,uint256 tolenid,int64_t total,int32_t maxinputs) +int64_t AddPricesInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char *destaddr,int64_t total,int32_t maxinputs,uint256 vintxid,int32_t vinvout) { - // add threshold check int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; SetCCunspents(unspentOutputs,destaddr); @@ -141,11 +133,11 @@ int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char { txid = it->first.txhash; vout = (int32_t)it->first.index; - // need to prevent dup + if ( vout == vinvout && txid == vintxid ) + continue; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && vout < vintx.vout.size() ) { - // need to verify assetid - if ( (nValue= vintx.vout[vout].nValue) >= 10000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + if ( (nValue= vintx.vout[vout].nValue) >= total/maxinputs && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -162,7 +154,7 @@ int64_t AddTokensInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char UniValue PricesList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint64_t mode; int32_t margin,maxleverage; std::vectorpubkeys; uint256 txid,hashBlock,oracletxid,longtoken,shorttoken,bettoken; CPubKey planpk,pricespk; char str[65]; CTransaction vintx; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); SetCCtxids(addressIndex,cp->normaladdr); @@ -171,7 +163,7 @@ UniValue PricesList() txid = it->first.txhash; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( vintx.vout.size() > 0 && DecodePricesFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' ) + if ( vintx.vout.size() > 0 && prices_betopretdecode(vintx.vout[vintx.vout.size()-1].scriptPubKey,pk,height,amount,leverage,firstprice,vec) == 'B' ) { result.push_back(uint256_str(str,txid)); } @@ -180,274 +172,455 @@ UniValue PricesList() return(result); } -// longtoken satoshis limits long exposure -// shorttoken satoshis limits short exposure -// both must be in the 1of2 CC address with its total supply -// bettoken -std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletxid,uint64_t margin,uint64_t mode,uint256 longtoken,uint256 shorttoken,int32_t maxleverage,int64_t funding,std::vector pubkeys) +UniValue prices_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) { - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CCcontract_info *cp,C; - if ( funding < 100*COIN || maxleverage <= 0 || maxleverage > 10000 ) + CTransaction tx; + if ( rawtx.size() > 0 ) { - CCerror = "invalid parameter error"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - return(""); - } - cp = CCinit(&C,EVAL_PRICES); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - pricespk = GetUnspendable(cp,0); - if ( (N= (int32_t)pubkeys.size()) || N > 15 ) - { - fprintf(stderr,"too many pubkeys N.%d\n",N); - return(""); - } - for (i=0; i 0 ) - { - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(pricespk)) << OP_CHECKSIG)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodePricesFundingOpRet('F',mypk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken))); - } - else - { - CCerror = "cant find enough inputs"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - } - return(""); + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); } -UniValue PricesInfo(uint256 fundingtxid) +int32_t prices_syntheticvec(std::vector &vec,std::vector synthetic) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); CPubKey pricespk,planpk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction vintx; int64_t balance,supply,exposure; uint64_t funding,mode; int32_t i,margin,maxleverage; char numstr[65],houseaddr[64],exposureaddr[64],str[65]; std::vectorpubkeys; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_PRICES); - pricespk = GetUnspendable(cp,0); - if ( GetTransaction(fundingtxid,vintx,hashBlock,false) == 0 ) + int32_t i,need,depth = 0; std::string opstr; uint16_t opcode,weight; + if ( synthetic.size() == 0 ) + return(-1); + for (i=0; i= 0 ) + opcode = ind, need = 0; + else if ( (weight= atoi(opstr.c_str())) > 0 && weight < KOMODO_MAXPRICES ) + { + opcode = PRICES_WEIGHT | weight; + need = 1; + } else return(-2); + if ( depth < need ) + return(-3); + depth -= need; + if ( (opcode & KOMODO_PRICEMASK) != PRICES_WEIGHT ) // weight + depth++; + if ( depth > 3 ) + return(-4); + vec.push_back(opcode); + } + if ( depth != 0 ) + { + fprintf(stderr,"depth.%d not empty\n",depth); + return(-5); + } + return(0); +} + +int64_t prices_syntheticprice(std::vector vec,int32_t height,int32_t minmax,int16_t leverage) +{ + int32_t i,errcode,depth,retval = -1; uint16_t opcode; int64_t *pricedata,stack[4],price,den,a,b,c; + pricedata = (int64_t *)calloc(sizeof(*pricedata)*3,numblocks + PRICES_DAYWINDOW*2 + PRICES_SMOOTHWIDTH); + price = den = depth = errcode = 0; + for (i=0; i 0 ) + pricestack[depth] = MAX(pricedata[1],pricedata[2]); + else pricestack[depth] = MIN(pricedata[1],pricedata[2]); + } + } + if ( pricestack[depth] == 0 ) + errcode = -1; + depth++; + break; + case PRICES_WEIGHT: // multiply by weight and consume top of stack by updating price + if ( depth == 1 ) + { + depth--; + price += pricestack[0] * ind; + den += ind; + } else errcode = -2; + break; + case PRICES_MUL: + if ( depth >= 2 ) + { + b = pricestack[--depth]; + a = pricestack[--depth]; + pricestack[depth++] = (a * b) / SATOSHIDEN; + } else errcode = -3; + break; + case PRICES_DIV: + if ( depth >= 2 ) + { + b = pricestack[--depth]; + a = pricestack[--depth]; + pricestack[depth++] = (a * SATOSHIDEN) / b; + } else errcode = -4; + break; + case PRICES_INV: + if ( depth >= 1 ) + { + a = pricestack[--depth]; + pricestack[depth++] = (SATOSHIDEN * SATOSHIDEN) / a; + } else errcode = -5; + break; + case PRICES_MDD: + if ( depth >= 3 ) + { + c = pricestack[--depth]; + b = pricestack[--depth]; + a = pricestack[--depth]; + pricestack[depth++] = (((a * SATOSHIDEN) / b) * SATOSHIDEN) / c; + } else errcode = -6; + break; + case PRICES_MMD: + if ( depth >= 3 ) + { + c = pricestack[--depth]; + b = pricestack[--depth]; + a = pricestack[--depth]; + pricestack[depth++] = (a * b) / c; + } else errcode = -7; + break; + case PRICES_MMM: + if ( depth >= 3 ) + { + c = pricestack[--depth]; + b = pricestack[--depth]; + a = pricestack[--depth]; + pricestack[depth++] = ((a * b) / SATOSHIDEN) * c; + } else errcode = -8; + break; + case PRICES_DDD: + if ( depth >= 3 ) + { + c = pricestack[--depth]; + b = pricestack[--depth]; + a = pricestack[--depth]; + pricestack[depth++] = (((((SATOSHIDEN * SATOSHIDEN) / a) * SATOSHIDEN) / b) * SATOSHIDEN) / c; + } else errcode = -9; + break; + default: + errcode = -10; + break; + } + if ( errcode != 0 ) + break; + } + free(pricedata); + if ( den == 0 ) + return(-11); + else if ( depth != 0 ) + return(-12); + else if ( errcode != 0 ) + return(errcode); + return(price / den); +} + +int64_t prices_syntheticprofits(int64_t &costbasis,int32_t firstheight,int32_t height,int16_t leverage,std::vector vec,int64_t positionsize,int64_t addedbets) +{ + int64_t price,profits = 0; int32_t minmax; + minmax = (height > firstheight+PRICES_DAYWINDOW); + if ( (price= prices_syntheticprice(vec,height,minmax)) < 0 ) + { + fprintf(stderr,"unexpected zero synthetic price at height.%d\n",height); + return(0); + } + if ( minmax != 0 ) + { + if ( leverage > 0 && price > costbasis ) + costbasis = price; + else if ( leverage < 0 && (costbasis == 0 || price < costbasis) ) + costbasis = price; + } + profits = ((price * SATOSHIDEN) / costbasis) - SATOSHIDEN; + profits *= leverage * positionsize; + return(positionsize + addedbets + profits) +} + +void prices_betjson(UniValue &result,int64_t profits,int64_t costbasis,int64_t positionsize,int64_t addedbets,int16_t leverage,int32_t firstheight,int64_t firstprice) +{ + result.push_back(Pair("profits",ValueFromAmount(profits))); + result.push_back(Pair("costbasis",ValueFromAmount(costbasis))); + result.push_back(Pair("positionsize",ValueFromAmount(positionsize))); + result.push_back(Pair("addedbets",ValueFromAmount(addedbets))); + result.push_back(Pair("leverage",(int64_t)leverage)); + result.push_back(Pair("firstheight",(int64_t)firstheight)); + result.push_back(Pair("firstprice",ValueFromAmount(firstprice))); +} + +int64_t prices_costbasis(CTransaction bettx) +{ + int64_t costbasis = 0; + // if vout1 is spent, follow and extract costbasis from opreturn + //uint8_t prices_costbasisopretdecode(CScript scriptPubKey,uint256 &bettxid,CPubKey &pk,int32_t &height,int64_t &costbasis) + + return(costbasis); +} + +int64_t prices_batontxid(uint256 &batontxid,CTransaction bettx,uint256 bettxid); +{ + int64_t addedbets = 0; + // iterate through batons, adding up vout1 -> addedbets + return(addedbets); +} + +UniValue PricesBet(uint64_t txfee,int64_t amount,int16_t leverage,std::vector synthetic) +{ + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); + struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t betamount,firstprice; std::vector vec; + if ( leverage > PRICES_MAXLEVERAGE || leverage < -PRICES_MAXLEVERAGE ) + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","leverage too big")); return(result); } - if ( vintx.vout.size() > 0 && DecodePricesFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' ) - { - result.push_back(Pair("result","success")); - result.push_back(Pair("fundingtxid",uint256_str(str,fundingtxid))); - result.push_back(Pair("bettoken",uint256_str(str,bettoken))); - result.push_back(Pair("oracletxid",uint256_str(str,oracletxid))); - sprintf(numstr,"%.3f",(double)margin/1000); - result.push_back(Pair("profitmargin",numstr)); - result.push_back(Pair("maxleverage",maxleverage)); - result.push_back(Pair("mode",(int64_t)mode)); - for (i=0; ipubkeys; - if ( amount < 10000 ) - { - CCerror = "amount must be positive"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - return(""); - } cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) - txfee = 10000; + txfee = PRICES_TXFEE; mypk = pubkey2pk(Mypubkey()); pricespk = GetUnspendable(cp,0); GetCCaddress(cp,myaddr,mypk); - if ( GetTransaction(fundingtxid,tx,hashBlock,false) == 0 ) + if ( prices_syntheticvec(vec,synthetic) < 0 || (firstprice= prices_syntheticprice(vec,nextheight-1,1)) < 0 || vec.size() == 0 || vec.size() > 4096 ) { - fprintf(stderr,"cant find fundingtxid\n"); - return(""); + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid synthetic")); + return(result); } - if ( tx.vout.size() > 0 && DecodePricesFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' && bettoken == refbettoken ) + if ( AddNormalinputs(mtx,mypk,amount+4*txfee,64) >= amount+4*txfee ) { - GetCCaddress1of2(cp,houseaddr,pricespk,planpk); - if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) - { - if ( (inputs= AddTokensInputs(cp,mtx,myaddr,bettoken,amount,60)) >= amount ) - { - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,amount,pricespk,planpk)); - mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(planpk)) << OP_CHECKSIG)); - if ( inputs > amount+txfee ) - CCchange = (inputs - amount); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,mypk)); - // add addr2 + betamount = (amount * 199) / 200; + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); // baton for total funding + mtx.vout.push_back(MakeCC1vout(cp->evalcode,(amount-betamount)+2*txfee,pricespk)); + mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,betamount,pricespk,mypk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,prices_betopret(mypk,nextheight-1,amount,leverage,firstprice,vec,zeroid)); + return(prices_rawtxresult(result,rawtx,0)); + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough funds")); + return(result); +} - std::vector voutTokenPubkeysEmpty; //TODO: add token vout pubkeys - return(FinalizeCCTx(0,cp,mtx,mypk,txfee, - EncodeTokenOpRet(bettoken, voutTokenPubkeysEmpty, - std::make_pair(OPRETID_ASSETSDATA, EncodeAssetOpRet('t',/*bettoken,*/zeroid, 0, Mypubkey()))))); +UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount) +{ + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); + struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t addedbets=0,betamount,firstprice; std::vector vec; uint256 batonttxid; + cp = CCinit(&C,EVAL_PRICES); + if ( txfee == 0 ) + txfee = PRICES_TXFEE; + mypk = pubkey2pk(Mypubkey()); + pricespk = GetUnspendable(cp,0); + GetCCaddress(cp,myaddr,mypk); + if ( AddNormalinputs(mtx,mypk,amount+txfee,64) >= amount+txfee ) + { + if ( prices_batontxid(addedbets,batontxid,bettxid) >= 0 ) + { + mtx.vin.push_back(CTxVin(batontxid,0,CScript())); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); // baton for total funding + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,pricespk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,prices_addopret(bettxid,mypk,amount)); + return(prices_rawtxresult(result,rawtx,0)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt find batonttxid")); + return(result); + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough funds")); + return(result); +} + +UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) +{ + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); + struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock; int64_t myfee,positionsize=0,addedbets,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + cp = CCinit(&C,EVAL_PRICES); + if ( txfee == 0 ) + txfee = PRICES_TXFEE; + mypk = pubkey2pk(Mypubkey()); + pricespk = GetUnspendable(cp,0); + if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) + { + if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec) == 'B' ) + { + addedbets = prices_addedbets(bettx); + mtx.vin.push_back(CTxVin(bettx,1,CScript())); + for (i=0; ievalcode,bettx.vout[1].nValue-myfee-txfee,pricespk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,prices_costbasisopret(bettxid,mypk,firstheight+PRICES_DAYWINDOW-1,costbasis)); + return(prices_rawtxresult(result,rawtx,0)); + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","cant find bettxid")); + return(result); +} + +UniValue PricesRekt(uint64_t txfee,uint256 bettxid,int32_t rektheight) +{ + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); + struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee=0,positionsize,addedbets,firstprice,profits,costbasis=0; int32_t firstheight,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + cp = CCinit(&C,EVAL_PRICES); + if ( txfee == 0 ) + txfee = PRICES_TXFEE; + mypk = pubkey2pk(Mypubkey()); + pricespk = GetUnspendable(cp,0); + if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) + { + if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) + { + costbasis = prices_costbasis(bettx); + addedbets = prices_batontxid(batontxid,bettx,bettxid); + if ( (profits= prices_syntheticprofits(&ignore,firstheight,rektheight,leverage,vec,positionsize,addedbets)) < 0 ) + { + myfee = (positionsize + addedbets) / 500; + } + prices_betjson(result,profits,costbasis,positionsize,addedbets,leverage,firstheight,firstprice); + if ( myfee != 0 ) + { + mtx.vin.push_back(CTxVin(bettxid,2,CScript())); + mtx.vout.push_back(CTxOut(myfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,bettx.vout[2].nValue-myfee-txfee,pricespk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,prices_finalopret(bettxid,profits,rektheight,mypk,firstprice,costbasis,addedbets,positionsize,leverage)); + return(prices_rawtxresult(result,rawtx,0)); } else { - CCerror = "cant find enough bet inputs"; - fprintf(stderr,"%s\n", CCerror.c_str() ); + result.push_back(Pair("result","error")); + result.push_back(Pair("error","position not rekt")); + return(result); } } else { - CCerror = "cant find enough inputs"; - fprintf(stderr,"%s\n", CCerror.c_str() ); + result.push_back(Pair("result","error")); + result.push_back(Pair("error","cant decode opret")); + return(result); } } - return(""); -} - -std::string PricesBet(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount,int32_t leverage) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; - if ( amount < 0 ) - { - amount = -amount; - dir = -1; - } else dir = 1; - cp = CCinit(&C,EVAL_PRICES); - if ( txfee == 0 ) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - pricespk = GetUnspendable(cp,0); - GetCCaddress(cp,myaddr,mypk); - if ( GetTransaction(fundingtxid,tx,hashBlock,false) == 0 ) - { - fprintf(stderr,"cant find fundingtxid\n"); - return(""); - } - if ( tx.vout.size() > 0 && DecodePricesFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,planpk,oracletxid,longtoken,shorttoken,margin,mode,maxleverage,pubkeys,bettoken) == 'F' && bettoken == refbettoken ) - { - if ( leverage > maxleverage || leverage < 1 ) - { - fprintf(stderr,"illegal leverage\n"); - return(""); - } - GetCCaddress1of2(cp,houseaddr,pricespk,planpk); - GetCCaddress1of2(cp,exposureaddr,pricespk,pricespk); - if ( dir < 0 ) - tokenid = shorttoken; - else tokenid = longtoken; - exposure = leverage * amount; - longexposure = CCtoken_balance(exposureaddr,longtoken); - shortexposure = CCtoken_balance(exposureaddr,shorttoken); - netexposure = (longexposure - shortexposure + exposure*dir); - if ( netexposure < 0 ) - netexposure = -netexposure; - balance = CCtoken_balance(myaddr,bettoken) / COIN; - if ( balance < netexposure*9/10 ) // 10% extra room for dynamically closed bets in wrong direction - { - fprintf(stderr,"balance %lld < 90%% netexposure %lld, refuse bet\n",(long long)balance,(long long)netexposure); - return(""); - } - if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 ) - { - if ( (inputs= AddTokensInputs(cp,mtx,houseaddr,tokenid,exposure,30)) >= exposure ) - { - if ( (inputs2= AddTokensInputs(cp,mtx,myaddr,bettoken,amount,30)) >= amount ) - { - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,amount,pricespk,planpk)); - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,exposure,pricespk,pricespk)); - if ( inputs > exposure+txfee ) - CCchange = (inputs - exposure); - if ( inputs2 > amount+txfee ) - CCchange2 = (inputs2 - amount); - mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,CCchange,pricespk,planpk)); - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange2,mypk)); - // add addr2 and addr3 - //return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodePricesExtra('T',tokenid,bettoken,zeroid,dir*leverage))); - CScript opret; - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); - } - else - { - fprintf(stderr,"cant find enough bettoken inputs\n"); - return(""); - } - } - else - { - fprintf(stderr,"cant find enough exposure inputs\n"); - return(""); - } - } - else - { - CCerror = "cant find enough inputsB"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - } - } - return(""); -} - -UniValue PricesStatus(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,uint256 bettxid) -{ - UniValue result(UniValue::VOBJ); - // get height of bettxid - // get price and rekt - // get current height and price - // what about if rekt in the past? + result.push_back(Pair("result","error")); + result.push_back(Pair("error","cant find bettxid")); return(result); } -std::string PricesFinish(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,uint256 bettxid) +UniValue PricesCashout(uint64_t txfee,uint256 bettxid) { - return(""); + int32_t nextheight = komodo_nextheight(); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); + struct CCcontract_info *cp,C; char destaddr[64]; CTransaction bettx; uint256 hashBlock,tokenid; int64_t CCchange=0,positionsize,addedbets,firstprice,profits,costbasis=0; int32_t i,firstheight,height,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + cp = CCinit(&C,EVAL_PRICES); + if ( txfee == 0 ) + txfee = PRICES_TXFEE; + mypk = pubkey2pk(Mypubkey()); + pricespk = GetUnspendable(cp,0); + GetCCaddress(cp,destaddr,pricespk); + if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) + { + if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) + { + costbasis = prices_costbasis(bettx); + addedbets = prices_batontxid(batontxid,bettx,bettxid); + if ( (profits= prices_syntheticprofits(&ignore,firstheight,nextheight-1,leverage,vec,positionsize,addedbets)) < 0 ) + { + prices_betjson(result,profits,costbasis,positionsize,addedbets,leverage,firstheight,firstprice); + result.push_back(Pair("result","error")); + result.push_back(Pair("error","position rekt")); + return(result); + } + prices_betjson(result,profits,costbasis,positionsize,addedbets,leverage,firstheight,firstprice); + mtx.vin.push_back(CTxVin(bettxid,2,CScript())); + if ( (inputsum= AddPricesInputs(cp,mtx,destaddr,profits+txfee,64,bettxid,2)) > profits+txfee ) + CCchange = (inputsum - profits); + mtx.vout.push_back(CTxOut(bettx.vout[2].nValue + profits,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + if ( CCchange >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,pricespk)); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,prices_finalopret(bettxid,profits,nextheight-1,mypk,firstprice,costbasis,addedbets,positionsize,leverage)); + return(prices_rawtxresult(result,rawtx,0)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","cant decode opret")); + return(result); + } + } + return(result); +} + +UniValue PricesInfo(uint256 bettxid,int32_t height) +{ + UniValue result(UniValue::VOBJ); uint256 hashBlock,tokenid; int64_t myfee,ignore,positionsize=0,addedbets=0,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) + { + if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) + { + costbasis = prices_costbasis(bettx); + addedbets = prices_batontxid(batontxid,bettx,bettxid); + if ( (profits= prices_syntheticprofits(&ignore,firstheight,firstheight+i,leverage,vec,positionsize,addedbets)) < 0 ) + { + result.push_back(Pair("rekt",1)); + result.push_back(Pair("rektfee",(positionsize + addedbets) / 500)); + } else result.push_back(Pair("rekt",0)); + result.push_back(Pair("batontxid",batontxid.GetHex())); + prices_betjson(result,profits,costbasis,positionsize,addedbets,leverage,firstheight,firstprice); + return(result); + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","cant find bettxid")); + return(result); } diff --git a/src/komodo_defs.h b/src/komodo_defs.h index c1eeb375b..285bbb63d 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -37,6 +37,7 @@ #define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) #define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) #define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000001*COIN) +#define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 28ed3ee3a..6ea86eb9d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2182,6 +2182,9 @@ void komodo_cbopretupdate(int32_t forceflag) if ( (flags & 4) != 0 ) lastcrypto = now; memcpy(Mineropret.data(),PriceCache[0],size); + // high volatility still strands nodes so we need to check new prices to approve a stuck block + // scan list of stuck blocks (one?) and auto reconsiderblock if it changed state + //int32_t i; for (i=0; i= KOMODO_MAXPRICES ) + if ( PRICES_DAYWINDOW < 2 || ind >= KOMODO_MAXPRICES ) return(-1); mult = PriceMult[ind]; - memset(nonzprices,0,sizeof(*nonzprices)*daywindow); - for (iter=0; iter= daywindow ) + if ( i >= PRICES_DAYWINDOW ) i = 0; - if ( (price= rawprices[i]) == 0 ) + if ( (price= rawprices[i*rawskip]) == 0 ) { fprintf(stderr,"null rawprice.[%d]\n",i); return(-1); @@ -2315,28 +2319,29 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int //fprintf(stderr,"%.1f ",(double)price/10000); sum += price; correlation++; - if ( correlation > (daywindow>>1) ) + if ( correlation > (PRICES_DAYWINDOW>>1) ) { - return(refprice * mult); + if ( nonzprices == 0 ) + return(refprice * mult); //fprintf(stderr,"-> %.4f\n",(double)sum*mult/correlation); //return(sum*mult/correlation); n = 0; - i = (iter + seed) % daywindow; - for (k=0; k= daywindow ) + if ( i >= PRICES_DAYWINDOW ) i = 0; - if ( n > (daywindow>>1) ) + if ( n > (PRICES_DAYWINDOW>>1) ) nonzprices[i] = 0; else { - price = rawprices[i]; + price = rawprices[i*rawskip]; if ( price < lowprice || price > highprice ) nonzprices[i] = 0; else { nonzprices[i] = price; - //fprintf(stderr,"(%d %u) ",i,rawprices[i]); + //fprintf(stderr,"(%d %u) ",i,rawprices[i*rawskip]); n++; } } @@ -2345,17 +2350,17 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int if ( n != correlation ) return(-1); sum = den = n = 0; - for (i=0; i %.4f\n",(double)(smoothedsum/smoothedden)/10000); - return(smoothedsum/smoothedden); + if ( (price= correlated[i*cskip]) != 0 ) + nonzprice = price; + //correlated2[i] = nonzprice / PRICES_DAYWINDOW; // reduce precision + sum += nonzprice; } - return(0); + price = sum / PRICES_DAYWINDOW; + // improve smoothing with correlated2 processing + // price = smooth(correlated2,PRICES_DAYWINDOW,price/daywindow) * PRICES_DAYWINDOW; + return(price); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 0b0f0030c..c5dbd8601 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1176,19 +1176,58 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices,int64_t *correlated2,int32_t smoothwidth); -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t numprices,uint32_t *rawprices2,int32_t smoothwidth); +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int32_t int64_t *correlated2,int32_t numprices); +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t skip,int32_t numprices,uint32_t *rawprices2,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); int64_t komodo_pricemult(int32_t ind); +#define PRICES_SMOOTHWIDTH 1 + +int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) +{ + int32_t height,i,width,numpricefeeds = -1; uint64_t seed,rngval,*correlated2; uint32_t rawprices[1440*6],*ptr; + //daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + //pricedata = (uint32_t *)calloc(sizeof(*prices)*3,numblocks + daywindow*2 + PRICES_SMOOTHWIDTH); + width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; + komodo_heightpricebits(&seed,rawprices,firstheight + numblocks - 1); + if ( firstheight < width ) + return(-1); + for (i=0; i2; i++,ht--) { @@ -1233,7 +1272,7 @@ UniValue prices(const UniValue& params, bool fHelp) timestamps.push_back((int64_t)prices[i]); ret.push_back(Pair("timestamps",timestamps)); rngval = seed; - //for (i=0; i= width ) { - for (i=0; i ignoredMap = { + {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, + {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, + {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, + {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, + {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, + {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, + {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, + {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, + {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, + {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, + {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, + {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, + {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, + {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, + {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey +}; + +UniValue CBlockTreeDB::Snapshot2(int64_t dustthreshold,int32_t top,std::vector > &vaddr) +{ + int64_t total = 0; int64_t totalAddresses = 0; std::string address; + int64_t utxos = 0; int64_t ignoredAddresses = 0; + boost::scoped_ptr iter(NewIterator()); + std::map addressAmounts; + for (iter->SeekToLast(); iter->Valid(); iter->Prev()) + { + boost::this_thread::interruption_point(); + try + { + std::vector slKey = std::vector(); + pair keyObj; + iter->GetKey(keyObj); + char chType = keyObj.first; + CAddressIndexIteratorKey indexKey = keyObj.second; + //fprintf(stderr, "chType=%d\n", chType); + if (chType == DB_ADDRESSUNSPENTINDEX) + { + try { + CAmount nValue; + iter->GetValue(nValue); + getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); + if ( nValue > dustthreshold ) + { + std::map ::iterator ignored = ignoredMap.find(address); + if (ignored != ignoredMap.end()) + { + fprintf(stderr,"ignoring %s\n", address.c_str()); + ignoredAddresses++; + continue; + } + std::map ::iterator pos = addressAmounts.find(address); + if ( pos == addressAmounts.end() ) + { + // insert new address + utxo amount + //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); + addressAmounts[address] = nValue; + totalAddresses++; + } + else + { + // update unspent tally for this address + //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); + addressAmounts[address] += nValue; + } + //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); + // total += nValue; + utxos++; + } else fprintf(stderr,"ignoring amount=0 UTXO for %s\n", address.c_str()); + } + catch (const std::exception& e) + { + fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what()); + break; + } + } + } + catch (const std::exception& e) + { + fprintf(stderr, "DONE reading index entries\n"); + break; + } + } + fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses); + for (std::pair element : addressAmounts) + vaddr.push_back( make_pair(element.second, element.first) ); + std::sort(vaddr.rbegin(), vaddr.rend()); + int topN = 0; + for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) + { + //obj.push_back( make_pair("addr", it->second.c_str() ) ); + //char amount[32]; + //sprintf(amount, "%.8f", (double) it->first / COIN); + //obj.push_back( make_pair("amount", amount) ); + //obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str()) & 0x3f) ); + //addressesSorted.push_back(obj); + total += it->first; + topN++; + // If requested, only show top N addresses in output JSON + if ( top == topN ) + break; + } +} + UniValue CBlockTreeDB::Snapshot(int top) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; @@ -448,7 +553,7 @@ UniValue CBlockTreeDB::Snapshot(int top) UniValue result(UniValue::VOBJ); result.push_back(Pair("start_time", (int) time(NULL))); - std::map ignoredMap = { + /* std::map ignoredMap = { {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, @@ -466,7 +571,7 @@ UniValue CBlockTreeDB::Snapshot(int top) {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey - }; + };*/ int64_t startingHeight = chainActive.Height(); //fprintf(stderr, "Starting snapshot at height %lli\n", startingHeight); From b3d939ef5b84cca8cf61a46bf5aeba7490f08177 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Apr 2019 21:21:56 -1100 Subject: [PATCH 3722/3904] Test --- src/cc/prices.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index eab975acd..85b7f2077 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -154,7 +154,7 @@ int64_t AddPricesInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char UniValue PricesList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock,tokenid; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); SetCCtxids(addressIndex,cp->normaladdr); @@ -163,7 +163,7 @@ UniValue PricesList() txid = it->first.txhash; if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( vintx.vout.size() > 0 && prices_betopretdecode(vintx.vout[vintx.vout.size()-1].scriptPubKey,pk,height,amount,leverage,firstprice,vec) == 'B' ) + if ( vintx.vout.size() > 0 && prices_betopretdecode(vintx.vout[vintx.vout.size()-1].scriptPubKey,pk,height,amount,leverage,firstprice,vec,tokenid) == 'B' ) { result.push_back(uint256_str(str,txid)); } @@ -470,7 +470,7 @@ UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock; int64_t myfee,positionsize=0,addedbets,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee,positionsize=0,addedbets,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -478,7 +478,7 @@ UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) pricespk = GetUnspendable(cp,0); if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) { - if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec) == 'B' ) + if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) { addedbets = prices_addedbets(bettx); mtx.vin.push_back(CTxVin(bettx,1,CScript())); From 9c3418cf8d23dd5bdc763eb9a331cb267c79d470 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Apr 2019 22:50:50 -1100 Subject: [PATCH 3723/3904] Syntax --- src/cc/CCPrices.h | 2 +- src/cc/prices.cpp | 22 +++++++++++----------- src/komodo_defs.h | 1 + src/komodo_gateway.h | 12 ++++++++++++ 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 9f3039a6b..bb3b74ba6 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -26,7 +26,7 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, #define KOMODO_MAXPRICES 2048 // must be power of 2 and less than 8192 #define KOMODO_PRICEMASK (~(KOMODO_MAXPRICES - 1)) #define PRICES_WEIGHT (KOMODO_MAXPRICES * 1) -#define PRICES_MUL (KOMODO_MAXPRICES * 2) +#define PRICES_MULT (KOMODO_MAXPRICES * 2) #define PRICES_DIV (KOMODO_MAXPRICES * 3) #define PRICES_INV (KOMODO_MAXPRICES * 4) #define PRICES_MDD (KOMODO_MAXPRICES * 5) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 85b7f2077..1cb7b6667 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -154,7 +154,7 @@ int64_t AddPricesInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char UniValue PricesList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock,tokenid; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock,tokenid; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; char str[65]; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); SetCCtxids(addressIndex,cp->normaladdr); @@ -191,7 +191,7 @@ UniValue prices_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcast int32_t prices_syntheticvec(std::vector &vec,std::vector synthetic) { - int32_t i,need,depth = 0; std::string opstr; uint16_t opcode,weight; + int32_t i,need,ind,depth = 0; std::string opstr; uint16_t opcode,weight; if ( synthetic.size() == 0 ) return(-1); for (i=0; i &vec,std::vector int64_t prices_syntheticprice(std::vector vec,int32_t height,int32_t minmax,int16_t leverage) { - int32_t i,errcode,depth,retval = -1; uint16_t opcode; int64_t *pricedata,stack[4],price,den,a,b,c; - pricedata = (int64_t *)calloc(sizeof(*pricedata)*3,numblocks + PRICES_DAYWINDOW*2 + PRICES_SMOOTHWIDTH); + int32_t i,errcode,depth,retval = -1; uint16_t opcode; int64_t *pricedata,pricestack[4],price,den,a,b,c; + pricedata = (int64_t *)calloc(sizeof(*pricedata)*3,1 + PRICES_DAYWINDOW*2 + PRICES_SMOOTHWIDTH); price = den = depth = errcode = 0; for (i=0; i firstheight+PRICES_DAYWINDOW); - if ( (price= prices_syntheticprice(vec,height,minmax)) < 0 ) + if ( (price= prices_syntheticprice(vec,height,minmax,leverage)) < 0 ) { fprintf(stderr,"unexpected zero synthetic price at height.%d\n",height); return(0); @@ -366,7 +366,7 @@ int64_t prices_syntheticprofits(int64_t &costbasis,int32_t firstheight,int32_t h } profits = ((price * SATOSHIDEN) / costbasis) - SATOSHIDEN; profits *= leverage * positionsize; - return(positionsize + addedbets + profits) + return(positionsize + addedbets + profits); } void prices_betjson(UniValue &result,int64_t profits,int64_t costbasis,int64_t positionsize,int64_t addedbets,int16_t leverage,int32_t firstheight,int64_t firstprice) @@ -400,7 +400,7 @@ UniValue PricesBet(uint64_t txfee,int64_t amount,int16_t leverage,std::vector vec; + struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t betamount,firstprice; std::vector vec; char myaddr[64]; if ( leverage > PRICES_MAXLEVERAGE || leverage < -PRICES_MAXLEVERAGE ) { result.push_back(Pair("result","error")); @@ -437,7 +437,7 @@ UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t addedbets=0,betamount,firstprice; std::vector vec; uint256 batonttxid; + struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t addedbets=0,betamount,firstprice; std::vector vec; uint256 batontxid; std::string rawtx; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -511,7 +511,7 @@ UniValue PricesRekt(uint64_t txfee,uint256 bettxid,int32_t rektheight) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee=0,positionsize,addedbets,firstprice,profits,costbasis=0; int32_t firstheight,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee=0,positionsize,addedbets,firstprice,profits,ignore,costbasis=0; int32_t firstheight,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -559,7 +559,7 @@ UniValue PricesCashout(uint64_t txfee,uint256 bettxid) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; char destaddr[64]; CTransaction bettx; uint256 hashBlock,tokenid; int64_t CCchange=0,positionsize,addedbets,firstprice,profits,costbasis=0; int32_t i,firstheight,height,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + struct CCcontract_info *cp,C; char destaddr[64]; CTransaction bettx; uint256 hashBlock,batontxid,tokenid; int64_t CCchange=0,positionsize,addedbets,firstprice,profits,costbasis=0; int32_t i,firstheight,height,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -601,7 +601,7 @@ UniValue PricesCashout(uint64_t txfee,uint256 bettxid) UniValue PricesInfo(uint256 bettxid,int32_t height) { - UniValue result(UniValue::VOBJ); uint256 hashBlock,tokenid; int64_t myfee,ignore,positionsize=0,addedbets=0,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + UniValue result(UniValue::VOBJ); CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee,ignore,positionsize=0,addedbets=0,firstprice=0,profits=0,ignore,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) { if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 285bbb63d..49aa67081 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -84,5 +84,6 @@ int tx_height( const uint256 &hash ); extern char NOTARYADDRS[64][36]; extern uint8_t NUM_NOTARIES; void komodo_netevent(std::vector payload); +int32_t komodo_priceind(char *symbol); #endif diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6ea86eb9d..ba15746e0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2284,6 +2284,18 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } +int32_t komodo_priceind(char *symbol) +{ + char name[65]; int32_t i,n = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); + for (i=1; i Date: Fri, 5 Apr 2019 22:59:44 -1100 Subject: [PATCH 3724/3904] syntax --- src/cc/CCPrices.h | 1 + src/cc/prices.cpp | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index bb3b74ba6..db0e66e88 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -22,6 +22,7 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) #define PRICES_TXFEE 10000 +#define PRICES_MAXLEVERAGE 777 #define PRICES_SMOOTHWIDTH 1 #define KOMODO_MAXPRICES 2048 // must be power of 2 and less than 8192 #define KOMODO_PRICEMASK (~(KOMODO_MAXPRICES - 1)) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 1cb7b6667..4b567f139 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -212,7 +212,7 @@ int32_t prices_syntheticvec(std::vector &vec,std::vector opcode = PRICES_MMM, need = 3; else if ( opstr == "///" ) opcode = PRICES_DDD, need = 3; - else if ( (ind= prices_ind(opstr.c_str())) >= 0 ) + else if ( (ind= komodo_pricesind(opstr.c_str())) >= 0 ) opcode = ind, need = 0; else if ( (weight= atoi(opstr.c_str())) > 0 && weight < KOMODO_MAXPRICES ) { @@ -238,7 +238,7 @@ int32_t prices_syntheticvec(std::vector &vec,std::vector int64_t prices_syntheticprice(std::vector vec,int32_t height,int32_t minmax,int16_t leverage) { - int32_t i,errcode,depth,retval = -1; uint16_t opcode; int64_t *pricedata,pricestack[4],price,den,a,b,c; + int32_t i,ind,errcode,depth,retval = -1; uint16_t opcode; int64_t *pricedata,pricestack[4],price,den,a,b,c; pricedata = (int64_t *)calloc(sizeof(*pricedata)*3,1 + PRICES_DAYWINDOW*2 + PRICES_SMOOTHWIDTH); price = den = depth = errcode = 0; for (i=0; i vec,int32_t height,int32_t m den += ind; } else errcode = -2; break; - case PRICES_MUL: + case PRICES_MULT: if ( depth >= 2 ) { b = pricestack[--depth]; @@ -400,7 +400,7 @@ UniValue PricesBet(uint64_t txfee,int64_t amount,int16_t leverage,std::vector vec; char myaddr[64]; + struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t betamount,firstprice; std::vector vec; char myaddr[64]; std::string rawtx; if ( leverage > PRICES_MAXLEVERAGE || leverage < -PRICES_MAXLEVERAGE ) { result.push_back(Pair("result","error")); @@ -413,7 +413,7 @@ UniValue PricesBet(uint64_t txfee,int64_t amount,int16_t leverage,std::vector 4096 ) + if ( prices_syntheticvec(vec,synthetic) < 0 || (firstprice= prices_syntheticprice(vec,nextheight-1,1,leverage)) < 0 || vec.size() == 0 || vec.size() > 4096 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error","invalid synthetic")); @@ -437,7 +437,7 @@ UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t addedbets=0,betamount,firstprice; std::vector vec; uint256 batontxid; std::string rawtx; + struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t addedbets=0,betamount,firstprice; std::vector vec; uint256 batontxid; std::string rawtx; char myaddr[64]; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -448,7 +448,7 @@ UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount) { if ( prices_batontxid(addedbets,batontxid,bettxid) >= 0 ) { - mtx.vin.push_back(CTxVin(batontxid,0,CScript())); + mtx.vin.push_back(CTxIn(batontxid,0,CScript())); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); // baton for total funding mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,pricespk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,prices_addopret(bettxid,mypk,amount)); @@ -470,7 +470,7 @@ UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee,positionsize=0,addedbets,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,batontxid,tokenid; int64_t myfee,positionsize=0,addedbets,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -480,8 +480,8 @@ UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) { if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) { - addedbets = prices_addedbets(bettx); - mtx.vin.push_back(CTxVin(bettx,1,CScript())); + addedbets = prices_batontxid(batontxid,bettx,bettxid); + mtx.vin.push_back(CTxIn(bettx,1,CScript())); for (i=0; ievalcode,bettx.vout[2].nValue-myfee-txfee,pricespk)); rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,prices_finalopret(bettxid,profits,rektheight,mypk,firstprice,costbasis,addedbets,positionsize,leverage)); @@ -559,7 +559,7 @@ UniValue PricesCashout(uint64_t txfee,uint256 bettxid) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; char destaddr[64]; CTransaction bettx; uint256 hashBlock,batontxid,tokenid; int64_t CCchange=0,positionsize,addedbets,firstprice,profits,costbasis=0; int32_t i,firstheight,height,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + struct CCcontract_info *cp,C; char destaddr[64]; CTransaction bettx; uint256 hashBlock,batontxid,tokenid; int64_t CCchange=0,positionsize,inputsum,ignore,addedbets,firstprice,profits,costbasis=0; int32_t i,firstheight,height,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -580,7 +580,7 @@ UniValue PricesCashout(uint64_t txfee,uint256 bettxid) return(result); } prices_betjson(result,profits,costbasis,positionsize,addedbets,leverage,firstheight,firstprice); - mtx.vin.push_back(CTxVin(bettxid,2,CScript())); + mtx.vin.push_back(CTxIn(bettxid,2,CScript())); if ( (inputsum= AddPricesInputs(cp,mtx,destaddr,profits+txfee,64,bettxid,2)) > profits+txfee ) CCchange = (inputsum - profits); mtx.vout.push_back(CTxOut(bettx.vout[2].nValue + profits,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -601,7 +601,7 @@ UniValue PricesCashout(uint64_t txfee,uint256 bettxid) UniValue PricesInfo(uint256 bettxid,int32_t height) { - UniValue result(UniValue::VOBJ); CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee,ignore,positionsize=0,addedbets=0,firstprice=0,profits=0,ignore,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + UniValue result(UniValue::VOBJ); CTransaction bettx; uint256 hashBlock,batontxid,tokenid; int64_t myfee,ignore,positionsize=0,addedbets=0,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) { if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) From a44709745c6e66dd85c053127f7f375e9f2a83e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Apr 2019 23:02:48 -1100 Subject: [PATCH 3725/3904] Syntax --- src/cc/CCPrices.h | 2 +- src/cc/prices.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index db0e66e88..672d6d9d8 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -18,7 +18,7 @@ #define CC_PRICES_H #include "CCinclude.h" -int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind,int32_t daywindow); +int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind); #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) #define PRICES_TXFEE 10000 diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 4b567f139..38777e672 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -212,7 +212,7 @@ int32_t prices_syntheticvec(std::vector &vec,std::vector opcode = PRICES_MMM, need = 3; else if ( opstr == "///" ) opcode = PRICES_DDD, need = 3; - else if ( (ind= komodo_pricesind(opstr.c_str())) >= 0 ) + else if ( (ind= komodo_priceind(opstr.c_str())) >= 0 ) opcode = ind, need = 0; else if ( (weight= atoi(opstr.c_str())) > 0 && weight < KOMODO_MAXPRICES ) { @@ -446,7 +446,7 @@ UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount) GetCCaddress(cp,myaddr,mypk); if ( AddNormalinputs(mtx,mypk,amount+txfee,64) >= amount+txfee ) { - if ( prices_batontxid(addedbets,batontxid,bettxid) >= 0 ) + if ( prices_batontxid(batontxid,bettx,bettxid) >= 0 ) { mtx.vin.push_back(CTxIn(batontxid,0,CScript())); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); // baton for total funding @@ -481,7 +481,7 @@ UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) if ( prices_betopretdecode(bettx.vout[numvouts-1].scriptPubKey,pk,firstheight,positionsize,leverage,firstprice,vec,tokenid) == 'B' ) { addedbets = prices_batontxid(batontxid,bettx,bettxid); - mtx.vin.push_back(CTxIn(bettx,1,CScript())); + mtx.vin.push_back(CTxIn(bettxid,1,CScript())); for (i=0; i Date: Fri, 5 Apr 2019 23:07:28 -1100 Subject: [PATCH 3726/3904] Syntax --- src/cc/prices.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 38777e672..8cb91e539 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -212,7 +212,7 @@ int32_t prices_syntheticvec(std::vector &vec,std::vector opcode = PRICES_MMM, need = 3; else if ( opstr == "///" ) opcode = PRICES_DDD, need = 3; - else if ( (ind= komodo_priceind(opstr.c_str())) >= 0 ) + else if ( (ind= komodo_priceind((char *)opstr.c_str())) >= 0 ) opcode = ind, need = 0; else if ( (weight= atoi(opstr.c_str())) > 0 && weight < KOMODO_MAXPRICES ) { @@ -256,8 +256,8 @@ int64_t prices_syntheticprice(std::vector vec,int32_t height,int32_t m else { if ( leverage > 0 ) - pricestack[depth] = MAX(pricedata[1],pricedata[2]); - else pricestack[depth] = MIN(pricedata[1],pricedata[2]); + pricestack[depth] = (pricedata[1] > pricedata[2]) ? pricedata[1] : pricedata[2]; // MAX + else pricestack[depth] = (pricedata[1] < pricedata[2]) ? pricedata[1] : pricedata[2]; // MIN } } if ( pricestack[depth] == 0 ) @@ -389,7 +389,7 @@ int64_t prices_costbasis(CTransaction bettx) return(costbasis); } -int64_t prices_batontxid(uint256 &batontxid,CTransaction bettx,uint256 bettxid); +int64_t prices_batontxid(uint256 &batontxid,CTransaction bettx,uint256 bettxid) { int64_t addedbets = 0; // iterate through batons, adding up vout1 -> addedbets @@ -437,7 +437,7 @@ UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; CPubKey pricespk,mypk; int64_t addedbets=0,betamount,firstprice; std::vector vec; uint256 batontxid; std::string rawtx; char myaddr[64]; + struct CCcontract_info *cp,C; CTransaction bettx; CPubKey pricespk,mypk; int64_t addedbets=0,betamount,firstprice; std::vector vec; uint256 batontxid; std::string rawtx; char myaddr[64]; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -484,7 +484,7 @@ UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) mtx.vin.push_back(CTxIn(bettxid,1,CScript())); for (i=0; i Date: Fri, 5 Apr 2019 23:10:37 -1100 Subject: [PATCH 3727/3904] Syntax --- src/cc/prices.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 8cb91e539..8dc9d7d02 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -511,7 +511,7 @@ UniValue PricesRekt(uint64_t txfee,uint256 bettxid,int32_t rektheight) { int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); - struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,tokenid; int64_t myfee=0,positionsize,addedbets,firstprice,profits,ignore,costbasis=0; int32_t firstheight,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; + struct CCcontract_info *cp,C; CTransaction bettx; uint256 hashBlock,tokenid,batontxid; int64_t myfee=0,positionsize,addedbets,firstprice,profits,ignore,costbasis=0; int32_t firstheight,numvouts; int16_t leverage; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; cp = CCinit(&C,EVAL_PRICES); if ( txfee == 0 ) txfee = PRICES_TXFEE; @@ -599,7 +599,7 @@ UniValue PricesCashout(uint64_t txfee,uint256 bettxid) return(result); } -UniValue PricesInfo(uint256 bettxid,int32_t height) +UniValue PricesInfo(uint256 bettxid,int32_t refheight) { UniValue result(UniValue::VOBJ); CTransaction bettx; uint256 hashBlock,batontxid,tokenid; int64_t myfee,ignore,positionsize=0,addedbets=0,firstprice=0,profits=0,costbasis=0; int32_t i,firstheight=0,height,numvouts; int16_t leverage=0; std::vector vec; CPubKey pk,mypk,pricespk; std::string rawtx; if ( myGetTransaction(bettxid,bettx,hashBlock) != 0 && (numvouts= bettx.vout.size()) > 3 ) @@ -608,13 +608,14 @@ UniValue PricesInfo(uint256 bettxid,int32_t height) { costbasis = prices_costbasis(bettx); addedbets = prices_batontxid(batontxid,bettx,bettxid); - if ( (profits= prices_syntheticprofits(ignore,firstheight,firstheight+i,leverage,vec,positionsize,addedbets)) < 0 ) + if ( (profits= prices_syntheticprofits(ignore,firstheight,refheight,leverage,vec,positionsize,addedbets)) < 0 ) { result.push_back(Pair("rekt",1)); result.push_back(Pair("rektfee",(positionsize + addedbets) / 500)); } else result.push_back(Pair("rekt",0)); result.push_back(Pair("batontxid",batontxid.GetHex())); prices_betjson(result,profits,costbasis,positionsize,addedbets,leverage,firstheight,firstprice); + result.push_back(Pair("height",(int64_t)refheight)); return(result); } } From 50e9ffd9e0721acc3cf54d04b27a4caec12dffcb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Apr 2019 23:46:42 -1100 Subject: [PATCH 3728/3904] syntax --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c5dbd8601..3ef92e300 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1185,7 +1185,7 @@ int64_t komodo_pricemult(int32_t ind); int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) { - int32_t height,i,width,numpricefeeds = -1; uint64_t seed,rngval,*correlated2; uint32_t rawprices[1440*6],*ptr; + int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,rngval; int64_t *correlated2; uint32_t rawprices[1440*6],*ptr; //daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; //pricedata = (uint32_t *)calloc(sizeof(*prices)*3,numblocks + daywindow*2 + PRICES_SMOOTHWIDTH); width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; From 60a903bc2b71b77b4ca59c3e1eac44adb8f840de Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Apr 2019 23:53:42 -1100 Subject: [PATCH 3729/3904] syntax --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 3ef92e300..6b0c92552 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1176,7 +1176,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int32_t int64_t *correlated2,int32_t numprices); +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *correlated2,int32_t numprices); int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t skip,int32_t numprices,uint32_t *rawprices2,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); From 6dec94bf748e14143a6da276a3cad1fd8c64e79b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Apr 2019 23:57:03 -1100 Subject: [PATCH 3730/3904] syntax --- src/rpc/blockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6b0c92552..fc9a71fe2 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1177,7 +1177,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *correlated2,int32_t numprices); -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t skip,int32_t numprices,uint32_t *rawprices2,int32_t smoothwidth); +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); int64_t komodo_pricemult(int32_t ind); @@ -1185,7 +1185,7 @@ int64_t komodo_pricemult(int32_t ind); int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) { - int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,rngval; int64_t *correlated2; uint32_t rawprices[1440*6],*ptr; + int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; int64_t *correlated2; uint32_t rawprices[1440*6],*ptr; //daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; //pricedata = (uint32_t *)calloc(sizeof(*prices)*3,numblocks + daywindow*2 + PRICES_SMOOTHWIDTH); width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; @@ -1211,7 +1211,7 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, rngval = (rngval*11109 + 13849); ptr = (uint32_t *)&pricedata[i*3]; correlated2[i] = ptr[0]; - if ( (pricedata[i*3+1]= komodo_pricecorrelated(rngval,ind,(uint32_t)&pricedata[i*3],6,0,PRICES_SMOOTHWIDTH)) < 0 ) + if ( (pricedata[i*3+1]= komodo_pricecorrelated(rngval,ind,(uint32_t *)&pricedata[i*3],6,0,PRICES_SMOOTHWIDTH)) < 0 ) { free(correlated2); return(-3); From e2ddb727d4cf22f4305625ca4774bd907202da0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:01:49 -1100 Subject: [PATCH 3731/3904] SnapShot2 --- src/txdb.cpp | 41 ++++++++++++++++++++++------------------- src/txdb.h | 1 + 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 7fa658f1e..ace04ebdb 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -438,30 +438,31 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); uint32_t komodo_segid32(char *coinaddr); -const std::map ignoredMap = { - {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, - {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, - {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, - {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, - {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, - {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, - {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, - {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, - {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, - {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, - {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, - {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, - {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey +#define DECLARE_IGNORELIST std::map ignoredMap = { \ + {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, \ + {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, \ + {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, \ + {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, \ + {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, \ + {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, \ + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, \ + {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, \ + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, \ + {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, \ + {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, \ + {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, \ + {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, \ + {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, \ + {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, \ + {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, \ + {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} \ }; -UniValue CBlockTreeDB::Snapshot2(int64_t dustthreshold,int32_t top,std::vector > &vaddr) +int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold,int32_t top,std::vector > &vaddr) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; int64_t utxos = 0; int64_t ignoredAddresses = 0; + DECLARE_IGNORELIST boost::scoped_ptr iter(NewIterator()); std::map addressAmounts; for (iter->SeekToLast(); iter->Valid(); iter->Prev()) @@ -541,12 +542,14 @@ UniValue CBlockTreeDB::Snapshot2(int64_t dustthreshold,int32_t top,std::vector < if ( top == topN ) break; } + return(topN); } UniValue CBlockTreeDB::Snapshot(int top) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; int64_t utxos = 0; int64_t ignoredAddresses = 0; + DECLARE_IGNORELIST boost::scoped_ptr iter(NewIterator()); std::map addressAmounts; std::vector > vaddr; diff --git a/src/txdb.h b/src/txdb.h index b9bae2fe4..9b80b922b 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -116,6 +116,7 @@ public: bool LoadBlockIndexGuts(); bool blockOnchainActive(const uint256 &hash); UniValue Snapshot(int top); + int32_t Snapshot2(int64_t dustthreshold,int32_t top,std::vector > &vaddr); }; #endif // BITCOIN_TXDB_H From 2f9dfa9ad24fe49d8a65c47293b3fde66029e0d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:21:26 -1100 Subject: [PATCH 3732/3904] Truncated prices roc --- src/cc/CCPrices.h | 9 +++++++-- src/cc/prices.cpp | 40 ++++++++++++++++++++-------------------- src/rpc/server.cpp | 5 ----- src/rpc/server.h | 5 ----- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 672d6d9d8..9ff4f2957 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -38,8 +38,13 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom -UniValue PricesList(); -UniValue PricesBet(uint64_t txfee,int64_t amount,int32_t leverage,std::string synthetic); +UniValue PricesBet(uint64_t txfee,int64_t amount,int16_t leverage,std::vector synthetic); +UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount); +UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid); +UniValue PricesRekt(uint64_t txfee,uint256 bettxid,int32_t rektheight); +UniValue PricesCashout(uint64_t txfee,uint256 bettxid); +UniValue PricesInfo(uint256 bettxid,int32_t refheight); +UniValue PricesList() #endif diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 8dc9d7d02..cedf05f2b 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -152,26 +152,6 @@ int64_t AddPricesInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char return(totalinputs); } -UniValue PricesList() -{ - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock,tokenid; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; char str[65]; - cp = CCinit(&C,EVAL_PRICES); - pricespk = GetUnspendable(cp,0); - SetCCtxids(addressIndex,cp->normaladdr); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - { - txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) - { - if ( vintx.vout.size() > 0 && prices_betopretdecode(vintx.vout[vintx.vout.size()-1].scriptPubKey,pk,height,amount,leverage,firstprice,vec,tokenid) == 'B' ) - { - result.push_back(uint256_str(str,txid)); - } - } - } - return(result); -} - UniValue prices_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) { CTransaction tx; @@ -624,4 +604,24 @@ UniValue PricesInfo(uint256 bettxid,int32_t refheight) return(result); } +UniValue PricesList() +{ + UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock,tokenid; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; char str[65]; + cp = CCinit(&C,EVAL_PRICES); + pricespk = GetUnspendable(cp,0); + SetCCtxids(addressIndex,cp->normaladdr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + txid = it->first.txhash; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + { + if ( vintx.vout.size() > 0 && prices_betopretdecode(vintx.vout[vintx.vout.size()-1].scriptPubKey,pk,height,amount,leverage,firstprice,vec,tokenid) == 'B' ) + { + result.push_back(uint256_str(str,txid)); + } + } + } + return(result); +} + diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index e3f4ca0cf..a48ef6cb1 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -445,11 +445,6 @@ static const CRPCCommand vRPCCommands[] = { "prices", "pricesaddress", &pricesaddress, true }, { "prices", "priceslist", &priceslist, true }, { "prices", "pricesinfo", &pricesinfo, true }, - { "prices", "pricescreate", &pricescreate, true }, - { "prices", "pricesaddfunding", &pricesaddfunding, true }, - { "prices", "pricesbet", &pricesbet, true }, - { "prices", "pricesstatus", &pricesstatus, true }, - { "prices", "pricesfinish", &pricesfinish, true }, // Pegs { "pegs", "pegsaddress", &pegsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 997a418b4..79a12bb7b 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -272,11 +272,6 @@ extern UniValue oraclessamples(const UniValue& params, bool fHelp); extern UniValue pricesaddress(const UniValue& params, bool fHelp); extern UniValue priceslist(const UniValue& params, bool fHelp); extern UniValue pricesinfo(const UniValue& params, bool fHelp); -extern UniValue pricescreate(const UniValue& params, bool fHelp); -extern UniValue pricesaddfunding(const UniValue& params, bool fHelp); -extern UniValue pricesbet(const UniValue& params, bool fHelp); -extern UniValue pricesstatus(const UniValue& params, bool fHelp); -extern UniValue pricesfinish(const UniValue& params, bool fHelp); extern UniValue pegsaddress(const UniValue& params, bool fHelp); extern UniValue marmaraaddress(const UniValue& params, bool fHelp); extern UniValue marmara_poolpayout(const UniValue& params, bool fHelp); From 115f49cfc99b8aba6fc2e85603e988fdbb54d61e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:22:29 -1100 Subject: [PATCH 3733/3904] ; --- src/cc/CCPrices.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 9ff4f2957..1ecaebb2c 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -44,7 +44,7 @@ UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid); UniValue PricesRekt(uint64_t txfee,uint256 bettxid,int32_t rektheight); UniValue PricesCashout(uint64_t txfee,uint256 bettxid); UniValue PricesInfo(uint256 bettxid,int32_t refheight); -UniValue PricesList() +UniValue PricesList(); #endif From 5204312224b2b37ca3d29e2b2eb498383c688765 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:26:51 -1100 Subject: [PATCH 3734/3904] Remove rpc funds --- src/wallet/rpcwallet.cpp | 132 +-------------------------------------- 1 file changed, 1 insertion(+), 131 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 107508c18..ff56708f2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6915,137 +6915,7 @@ UniValue pricesinfo(const UniValue& params, bool fHelp) if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - return(PricesInfo(fundingtxid)); -} - -UniValue pricescreate(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); uint64_t mode; int64_t funding; int32_t i,n,margin,maxleverage; std::string hex; uint256 oracletxid,longtoken,shorttoken,bettoken; std::vector pubkeys; std::vectorpubkey; - if ( fHelp || params.size() < 8 ) - throw runtime_error("pricescreate bettoken oracletxid margin mode longtoken shorttoken maxleverage funding N [pubkeys]\n"); - if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - bettoken = Parseuint256((char *)params[0].get_str().c_str()); - oracletxid = Parseuint256((char *)params[1].get_str().c_str()); - margin = atof(params[2].get_str().c_str()) * 1000; - mode = atol(params[3].get_str().c_str()); - longtoken = Parseuint256((char *)params[4].get_str().c_str()); - shorttoken = Parseuint256((char *)params[5].get_str().c_str()); - maxleverage = atol(params[6].get_str().c_str()); - funding = atof(params[7].get_str().c_str()) * COIN + 0.00000000499999; - n = atoi(params[8].get_str().c_str()); - if ( n > 0 ) - { - for (i=0; i 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } - else - { - ERR_RESULT("couldnt create prices funding transaction"); - } - return(result); -} - -UniValue pricesaddfunding(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); std::string hex; uint256 fundingtxid,bettoken; int64_t amount; - if ( fHelp || params.size() != 3 ) - throw runtime_error("pricesaddfunding fundingtxid bettoken amount\n"); - if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - bettoken = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; - hex = PricesAddFunding(0,bettoken,fundingtxid,amount); - if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } - else - { - ERR_RESULT("couldnt create pricesaddfunding transaction"); - } - return(result); -} - -UniValue pricesbet(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); std::string hex; uint256 fundingtxid,bettoken; int64_t amount; int32_t leverage; - if ( fHelp || params.size() != 4 ) - throw runtime_error("pricesbet fundingtxid bettoken amount leverage\n"); - if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - bettoken = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; - leverage = atoi(params[3].get_str().c_str()); - hex = PricesBet(0,bettoken,fundingtxid,amount,leverage); - if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } - else - { - ERR_RESULT("couldnt create pricesbet transaction"); - } - return(result); -} - -UniValue pricesstatus(const UniValue& params, bool fHelp) -{ - uint256 fundingtxid,bettxid,bettoken; - if ( fHelp || params.size() != 3 ) - throw runtime_error("pricesstatus fundingtxid bettoken bettxid\n"); - if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - bettoken = Parseuint256((char *)params[1].get_str().c_str()); - bettxid = Parseuint256((char *)params[2].get_str().c_str()); - return(PricesStatus(0,bettoken,fundingtxid,bettxid)); -} - -UniValue pricesfinish(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); uint256 fundingtxid,bettxid,bettoken; std::string hex; - if ( fHelp || params.size() != 3 ) - throw runtime_error("pricesfinish fundingtxid bettoken bettxid\n"); - if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); - fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - bettoken = Parseuint256((char *)params[1].get_str().c_str()); - bettxid = Parseuint256((char *)params[2].get_str().c_str()); - hex = PricesFinish(0,bettoken,fundingtxid,bettxid); - if ( hex.size() > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("hex", hex)); - } - else - { - ERR_RESULT("couldnt create pricesfinish transaction"); - } - return(result); + return(PricesInfo(txfee,fundingtxid)); } UniValue dicefund(const UniValue& params, bool fHelp) From 559fb2e0d0d9fc010e07ff2ca609cb3f4276b83e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:27:42 -1100 Subject: [PATCH 3735/3904] 0 --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ff56708f2..1a55763da 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6915,7 +6915,7 @@ UniValue pricesinfo(const UniValue& params, bool fHelp) if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - return(PricesInfo(txfee,fundingtxid)); + return(PricesInfo(0,fundingtxid)); } UniValue dicefund(const UniValue& params, bool fHelp) From a8c729d8fdf2f1ab24ed29705d3c8e464c40f5c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:29:54 -1100 Subject: [PATCH 3736/3904] Height --- src/wallet/rpcwallet.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1a55763da..fb87ff9ea 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6909,13 +6909,14 @@ UniValue priceslist(const UniValue& params, bool fHelp) UniValue pricesinfo(const UniValue& params, bool fHelp) { - uint256 fundingtxid; - if ( fHelp || params.size() != 1 ) + uint256 bettxid; int32_t height; + if ( fHelp || params.size() != 2 ) throw runtime_error("pricesinfo fundingtxid\n"); if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - return(PricesInfo(0,fundingtxid)); + bettxid = Parseuint256((char *)params[0].get_str().c_str()); + height = atoi(params[1].get_str().c_str()); + return(PricesInfo(bettxid,height)); } UniValue dicefund(const UniValue& params, bool fHelp) From b81f1d4bee6da33a398be4d757530772c737c609 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:38:13 -1100 Subject: [PATCH 3737/3904] Make it PRICES compatible --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ba15746e0..f7f7874ce 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1728,7 +1728,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 0; + int32_t testchain_exemption = 350; std::vector vopret; char maxflags[KOMODO_MAXPRICES]; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { @@ -2135,8 +2135,8 @@ void komodo_cbopretupdate(int32_t forceflag) now = (uint32_t)time(NULL); if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) { -//if ( komodo_nextheight() > 333 ) // for debug only! -// ASSETCHAINS_CBOPRET = 7; +if ( komodo_nextheight() > 333 ) // for debug only! + ASSETCHAINS_CBOPRET = 7; size = komodo_cbopretsize(ASSETCHAINS_CBOPRET); if ( Mineropret.size() < size ) Mineropret.resize(size); From 88fb116c539541967c2adb5578df2fb5d47ed25a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 00:55:23 -1100 Subject: [PATCH 3738/3904] Comments --- src/cc/prices.cpp | 36 ++++++++++++++++++++++++------------ src/komodo_gateway.h | 6 +++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index cedf05f2b..85e2c645d 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -19,26 +19,38 @@ /* CBOPRET creates trustless oracles, which can be used for making a synthetic cash settlement system based on real world prices; + + 0.5% fee based on betamount, NOT leveraged betamount!! 0.1% collected by price basis determinant 0.2% collected by rekt tx - PricesBet -> +/-leverage, amount, synthetic -> opreturn includes current price - funds are locked into 1of2 global CC address - for first day, long basis is MAX(correlated,smoothed), short is MIN() - reference price is the smoothed of the previous block - if synthetic value + amount goes negative, then anybody can rekt it to collect a rektfee, proof of rekt must be included to show cost basis, rekt price - original creator can liquidate at anytime and collect (synthetic value + amount) from globalfund - 0.5% of bet -> globalfund - - PricesStatus -> bettxid maxsamples returns initial params, cost basis, amount left, rekt:true/false, rektheight, initial synthetic price, current synthetic price, net gain + UniValue PricesBet(uint64_t txfee,int64_t amount,int16_t leverage,std::vector synthetic) + funds are locked into 1of2 global CC address + for first day, long basis is MAX(correlated,smoothed), short is MIN() + reference price is the smoothed of the previous block + if synthetic value + amount goes negative, then anybody can rekt it to collect a rektfee, proof of rekt must be included to show cost basis, rekt price + original creator can liquidate at anytime and collect (synthetic value + amount) from globalfund + 0.5% of bet -> globalfund + + UniValue PricesAddFunding(uint64_t txfee,uint256 bettxid,int64_t amount) + add funding to an existing bet, doesnt change the profit calcs but does make the bet less likely to be rekt - PricesRekt -> bettxid height -> 0.1% to miner, rest to global CC + UniValue PricesSetcostbasis(uint64_t txfee,uint256 bettxid) + in the first day from the bet, the costbasis can (and usually does) change based on the MAX(correlated,smoothed) for long and MIN() for shorts + to calculate this requires a bit of work, so whatever node is first to get the proper calculation confirmed, gets a 0.1% costbasis fee - PricesClose -> bettxid returns (synthetic value + amount) + UniValue PricesRekt(uint64_t txfee,uint256 bettxid,int32_t rektheight) + similarily, any node can submit a rekt tx and cash in on 0.2% fee if their claim is confirmed - PricesList -> all bettxid -> list [bettxid, netgain] + UniValue PricesCashout(uint64_t txfee,uint256 bettxid) + only the actually creator of bet is able to cashout and only if it isnt rekt at that moment + UniValue PricesInfo(uint256 bettxid,int32_t refheight) + all relevant info about a bet + + UniValue PricesList() + a list of all pending and completed bets in different lists */ diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f7f7874ce..ba15746e0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1728,7 +1728,7 @@ CScript komodo_mineropret(int32_t nHeight) int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { - int32_t testchain_exemption = 350; + int32_t testchain_exemption = 0; std::vector vopret; char maxflags[KOMODO_MAXPRICES]; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { @@ -2135,8 +2135,8 @@ void komodo_cbopretupdate(int32_t forceflag) now = (uint32_t)time(NULL); if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) { -if ( komodo_nextheight() > 333 ) // for debug only! - ASSETCHAINS_CBOPRET = 7; +//if ( komodo_nextheight() > 333 ) // for debug only! +// ASSETCHAINS_CBOPRET = 7; size = komodo_cbopretsize(ASSETCHAINS_CBOPRET); if ( Mineropret.size() < size ) Mineropret.resize(size); From 1de369ea40560da31194b1469c9385b8de271f8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 01:23:21 -1100 Subject: [PATCH 3739/3904] Prices CC rpc purpose documented --- src/cc/prices.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 85e2c645d..7e999fe25 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -19,11 +19,39 @@ /* CBOPRET creates trustless oracles, which can be used for making a synthetic cash settlement system based on real world prices; - - 0.5% fee based on betamount, NOT leveraged betamount!! 0.1% collected by price basis determinant 0.2% collected by rekt tx + + At the simplest, prices CC allows to make leveraged cash settled bets on long and short BTCUSD: + BTCUSD, 1 with positive leverage parameter up to 777 + BTCUSD, 1 with negative leverage parameter up to -777 + + These specific limits of 0.5%, 0.1%, 0.2%, 777 should be able to be changed based on #define + + Another configuration is to send the 0.4% (or 0.2%) fees to a fee collection address (this is not currently implemented, but would be needed for systems that dont use -ac_perc to collect a global override) + + The definition of the synthetic instrument that is being tracked is actually defined with a forth type of syntax and is quite flexible to allow unlimited combinations and weights, but that is an independent aspect and will be covered later. + + Let us discuss the simplest synthetic case of a long or short of BTCUSD (or any other direct pricepoint from the trustless oracle). If you look at the charts, you will see the blue line that is direct from the miners (and therefore cant be directly used). The orange line is the 51% correlated price that is deterministically random selected from the prior 24 hours. And finally the green line which is simply the average value from the priot 24 hours. + + We will assume that the orange and green prices are able to be deterministically calculated from the raw coinbase data (blue). The prices rpc is currently working reasonably well and appears to return deterministic prices, however for use in the prices CC, it is often needed to find just a single data point. To that effect there is the temporary function prices_syntheticprice, which uses a bruteforce and totally inefficient way to calculate the correlated and smoothed prices. This inefficient process will need to be changed to a permanent storage of correlated and smoothed prices for each trustless oracle that is updated each block. This will then allow to directly lookup each value for any of the trustless prices. Such speed will indeed be needed to scale up usage of a REKT chain. + + Since the mined prices can be manipulated by any miner, combined with the +/-1% tolerance, it would be possible for an external miner to obtain a large hashrate and skew the price +1%, then to -1% to create a 2% price difference, which under high leverage might be able to generate a large profit. + + To avoid this precisely controllable biasing, the 51% correlation of past day is used (orange), which makes the price jump around a lot. The green line that sums the prior day is needed to remove this jitter back to the average value. However, this creates a 1.5 day delay to the price movement of the smoothed price compared to the current price. What this means is that if we want to use the green line to settle prices automatically, a trivial way to make money is to bet in the direct that the mined prices are relative to the smoothed prices. Given 1.5 day head start, it wont be any mystery which direction the smoothed line will move in the next 24 hours. + + So this makes the smoothed price unusable for settling the bets with. However, we cant use the correlated price either, as it would also allow to make bets when the correlated price picked a significantly lower/higher price than the raw price. The solution is to have a floating basis for the costbasis of the bet. In order to allow finding the right costbasis, for long bets the maximum price between the correlated and smoothed price is needed over the first day after the bet. For short bets, the minimum price is needed. + + What this means is that the actual starting price for a bet wont be known for sure when the bet is made, but if the price is relatively stable, there wont be much of a change. If there is a lot of recent volatility, then the starting price will have a high variability. In order to calculate the costbasis, it currently requires many calculations to find the MAX (or MIN) for the first day. Even when this is made to be a lookup, it still requires to issue a transaction to change the state of a bet from a "starting" state to a "in effect" state and this state change is indicated by whether the bettx vout that contains the costbasis utxo is spent or not. + + Once a bet goes into effect, then block by block, it is checked by the decentralized set of rekt scanners if it is rekt or not, in this case for double the reward for calculating the cost basis. This fully decentralized mechanism ensures that some node will decide to collect the free money and ensures that the bankroll is growing. To miss a rekt bet and not close it out when it can be is to allow it to survive for another block, which can change it profitability from negative to positive. + + Which comes to how profits are calculated. Once the costbasis is locked, then the profit calculation can be made based on the ratio between the costbasis and the current price, multiplied by the leverage. So, if a long position gains 10% at a 10x leverage, then approximately the entire bet amount will be made, ie. a double. Similarily with a short position, a 10% drop in price at 10x leverage will double the bet amount. Since it takes a full day to establish the costbasis, it is not possible to allow changing the costbasis for an existing bet, however it is possible to add funds so that it is less likely to be rekt. The sum of the initial bet and all added funds must be greater than the loss at every block to prevent a position from being rekt. To make it simple to calculate the amount of funds added, another bettx vout is used as a baton. Techniques similar to rogue CC to find where the bettx vout was spent and looking at each such transaction to find the total funds added can be used. + + The once that makes the bet is able to add funds or cashout at any block, as long as it isnt rekt. If it is rekt, the bettor is able to collect the rekt fee, so at least that is some consolation, but it is advised to increase the total funding to avoid being rekt. On a cashout all the funds that were bet adjusted by the profits can be collected. + + Hopefully the above description makes it clear what the following rpc calls should be doing: UniValue PricesBet(uint64_t txfee,int64_t amount,int16_t leverage,std::vector synthetic) funds are locked into 1of2 global CC address @@ -52,6 +80,9 @@ CBOPRET creates trustless oracles, which can be used for making a synthetic cash UniValue PricesList() a list of all pending and completed bets in different lists + + Appendix Synthetic position definition language: + */ // start of consensus code From ed6a0ade4400bf502b241e11477a50b02e202573 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 02:40:49 -1100 Subject: [PATCH 3740/3904] Synthetic definition language --- src/cc/prices.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 7e999fe25..6e95af3af 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -83,7 +83,58 @@ CBOPRET creates trustless oracles, which can be used for making a synthetic cash Appendix Synthetic position definition language: -*/ + Let us start from the familiar BTCUSD nomenclature. this is similar (identical) to forex EURUSD and the equivalent. Notice the price needs two things as it is actually a ratio, ie. BTCUSD is how many USD does 1 BTC get converted to. It can be thought of as the value of BTC/USD, in other words a ratio. + + The value of BTC alone, or USD alone, it is actually quite an abstract issue and it can only be approximated. Specific ways of how to do this can be discussed later, for now it is only important to understand that all prices are actually ratios. + + And these ratios work as normal algebra does. So a/b * b/c == a/c! You can try this out with BTCUSD and USDJPY -> BTC/USD * USD/JPY -> BTC/JPY or the BTCJPY price + + division is the reciprocal, so BTCUSD reciprocated is USDBTC + + Without getting into all the possible combinations of things, let us first understand what the language allows. It uses a stack based language, where individual tokens update the state. The final state needs to have an empty stack and it will have a calculated price. + + The most important is pushing a specific price onto the stack. All the correlated and smoothed prices are normalized so it has each integer unit equal to 0.00000001, amounts above 100 million are above one, amounts less are below one. 100 million is the unit constant. + + In the prices CC synthetic definition language, the symbol that is returned pushes the adjusted price to the stack. The adjustment is selecting between the correlated and smoothed if within a day from the bet creation, or just the smoothed if after a day. You can have a maximum depth of 3, any more than that and it should return an error. + + This means there are operations that are possible on 1, 2 and 3 symbols. For 1 symbol, it is easy, the only direct operation is the inverse, which is represented by "!". All items in the language are separated by "," + + "BTCUSD, !" + + The above is the inverse or USD/BTC, which is another way to short BTCUSD. It is also possible to short the entire synthetic with a negative leverage. The exact results of a -1 leverage and inverse, might not be exact due to the math involved with calculating the profit, but it should generally be similar. + + For two symbols, there is a bit more we can do, namely multiply and divide, combined with inverting, however to simplify the language any inverting is required to be done by the ordering of the symbols and usage of multiply or divide. multiply is "*" and divide is "/" the top of the stack (last to be pushed) is the divisor, the one right before the divisor is the numerator. + + "BTCUSD, USDJPY, *" <- That will create a BTCJPY synthetic + + "BTCEUR, BTCUSD, /" <- That will create a USDEUR synthetic + + If you experiment around with this, you will see that given two symbols and the proper order and * or /, you can always create the synthetic that you want, assuming what you want is the cancelling out of the term in common with the two symbols and the resulting ratio is between the two unique terms. + */ + +// Now we get to the three symbol operations, which there are 4 of *//, **/, *** and /// + +/* + these four operators work on the top of the stack in left to right order as the syntax of the definition lists it, though it is even possible to have the value from an earlier computation on the top of the stack. Ultimately all three will be multiplied together, so a * in a spot means it us used without changing. A / means its inverse will be used. + + "KMDBTC, BTCUSD, USDJPY, ***" <- this would create a KMDJPY synthetic. The various location of the / to make an inverse is to orient the raw symbol into the right orientation as the pricefeed is only getting one orientation of the ratio. + + So now we have covered all ways to map 1, 2 and 3 values on the top of the stack. A value can be on the top of the stack directly from a symbol, or as the result of some 1, 2 or 3 symbol operation. With a maximum stack depth of 3, it might require some experimentation to get a very complex synthetic to compile. Alternately, a stack deeper than 3 might be the acceptable solution if there are a family of synthetics that need it. + + At this point, it is time to describe the weights. It turns out that all above examples are incomplete and the synthetic descriptions are all insufficient and should generate an error. The reason is that the actual synthetic price is the value of the accumulator, which adds up all the weighted prices. In order to assign a weight to a price value on the stack, you simply use a number that is less than 2048. + + What such a weight number does, is consume the top of the stack, which also must be at depth of 1 and adds it to the accumulator. This allows combining multiple different synthetics into a meta synthetic, like for an aggregated index that is weighted by marketcap, or whatever other type of ratio trade that is desired. + + "BTCUSD, 1000, ETHBTC, BTCUSD, *, 300" -> that creates a dual index of BTCUSD and ETHUSD with a 30% ETH weight + + all weight operations consumes the one and only stack element and adds its weight to the accumulator, using this a very large number of terms can be all added together. Using inverses, allows to get the short direction into the equation mixed with longs, but all terms must be positive. If you want to create a spread between two synthetics, you need to create two different synthetics and go long with one and short with another. + + "BTCUSD, 1" with leverage -2 and "KMDBTC, BTCUSD, *, 1" with leverage 1 this will setup a +KMDUSD -2 BTCUSD spread when the two are combined, and would be at breakeven when KMDUSD gains 2x more percentage wise than BTC does. anytime KMD gains more, will be positive, if the gains are less, would be negative. + + Believe it or not, the string to binary compiler for synthetic description and interpretation of it is less than 200 lines of code. + + */ + // start of consensus code From dae0476a0adc89ca8c0ffca8412866af55a4cbee Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Apr 2019 06:49:05 -1100 Subject: [PATCH 3741/3904] More docs --- src/cc/pegs.cpp | 10 ---------- src/cc/prices.cpp | 5 +++++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index dba9fc818..341e34c58 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -16,17 +16,7 @@ #include "CCPegs.h" /* - Pegs CC builds on top of CCOPRET modes which will create pricefeeds in the coinbase. - - flag&1: BTC/USD 4966.1400, BTC/GBP 3770.0402, BTC/EUR 4416.8452 GBPUSD 1.317264, EURUSD 1.124364 EURGBP 0.853560 - flag&2: (BGN 1.7462) (NZD 1.4771) (ILS 3.6258) (RUB 65.3700) (CAD 1.3320) (PHP 52.4160) (CHF 0.9995) (AUD 1.4122) (JPY 111.3660) (TRY 5.5483) (HKD 7.8498) (MYR 4.0816) (HRK 6.6337) (CZK 22.9937) (IDR 14220.0000) (DKK 6.6648) (NOK 8.6111) (HUF 287.2142) (GBP 0.7678) (MXN 19.1046) (THB 31.7500) (ISK 122.4107) (ZAR 14.1300) (BRL 3.8604) (SGD 1.3551) (PLN 3.8350) (INR 68.7531) (KRW 1136.3839) (RON 4.2516) (CNY 6.7200) (SEK 9.3230) (EUR 0.8928) (2019-04-02) -flag&4: (KMD 0.00025110) (ETH 0.03357500) (LTC 0.01642400) (BCHABC 0.05167400) (XMR 0.01398800) (IOTA 0.00007217) (DASH 0.02552600) (XEM 0.00001459) (ZEC 0.01440500) (WAVES 0.00062170) (RVN 0.00001215) (LSK 0.00041130) (DCR 0.00496000) (BTS 0.00001444) (ICX 0.00008750) (HOT 0.00000027) (STEEM 0.00010070) (ENJ 0.00003221) (STRAT 0.00022790) errs.0 - Funds deposited into CC address for a specific peg would then be used to fund the bid/ask as the pricefeed changes the price. Profits/losses would accumulate in the associated address. - - In the event funds exceed a specified level, it can be spent into a collection address. The idea is that the collection address can further be used for revshares. - - */ diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 6e95af3af..ce257d33f 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -133,6 +133,11 @@ CBOPRET creates trustless oracles, which can be used for making a synthetic cash Believe it or not, the string to binary compiler for synthetic description and interpretation of it is less than 200 lines of code. + todo: complete all the above, bet tokens, cross chain prices within cluster These specific limits of 0.5%, 0.1%, 0.2%, 777 should be able to be changed based on #define + + Another configuration is to send the 0.4% (or 0.2%) fees to a fee collection scriptPubKey (this is not currently implemented, but would be needed for systems that dont use -ac_perc to collect a global override) this requires adding new vouts + + Modification: in the event there is one price in the accumulator and one price on the stack at the end, then it is a (A - B) spread */ From 6db2c41b518397d2ff948fd5a0cc9fa9e858c2ce Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 7 Apr 2019 21:57:17 +0800 Subject: [PATCH 3742/3904] inital commit for getSnapshot2 changes --- src/main.cpp | 114 +++++++++++----------------- src/rpc/misc.cpp | 5 +- src/txdb.cpp | 192 +++++++++++++---------------------------------- src/txdb.h | 2 +- 4 files changed, 98 insertions(+), 215 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e8fe3810c..8fbc0f1dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2967,6 +2967,33 @@ void DisconnectNotarisations(const CBlock &block) } } +int8_t GetAddressType(const CScript &scriptPubKey, CTxDestination &vDest, txnouttype &txType, vector> &vSols) +{ + int8_t keyType = 0; + // some non-standard types, like time lock coinbases, don't solve, but do extract + if ( (Solver(scriptPubKey, txType, vSols) || ExtractDestination(scriptPubKey, vDest)) ) + { + keyType = 1; + if (vDest.which()) + { + // if we failed to solve, and got a vDest, assume P2PKH or P2PK address returned + CKeyID kid; + if (CBitcoinAddress(vDest).GetKeyID(kid)) + { + vSols.push_back(vector(kid.begin(), kid.end())); + } + } + else if (txType == TX_SCRIPTHASH) + { + keyType = 2; + } + else if (txType == TX_CRYPTOCONDITION ) + { + keyType = 3; + } + } + return keyType; +} bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean) { @@ -3002,20 +3029,9 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex vector> vSols; CTxDestination vDest; txnouttype txType = TX_PUBKEYHASH; - int keyType = 1; - if ((Solver(out.scriptPubKey, txType, vSols) || ExtractDestination(out.scriptPubKey, vDest)) && txType != TX_MULTISIG) { - if (vDest.which()) - { - CKeyID kid; - if (CBitcoinAddress(vDest).GetKeyID(kid)) - { - vSols.push_back(vector(kid.begin(), kid.end())); - } - } - else if (txType == TX_SCRIPTHASH) - { - keyType = 2; - } + int keyType = GetAddressType(out.scriptPubKey, vDest, txType, vSols); + if ( keyType != 0 ) + { for (auto addr : vSols) { uint160 addrHash = addr.size() == 20 ? uint160(addr) : Hash160(addr); @@ -3072,23 +3088,9 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex vector> vSols; CTxDestination vDest; txnouttype txType = TX_PUBKEYHASH; - int keyType = 1; - // some non-standard types, like time lock coinbases, don't solve, but do extract - if ((Solver(prevout.scriptPubKey, txType, vSols) || ExtractDestination(prevout.scriptPubKey, vDest))) + int keyType = GetAddressType(prevout.scriptPubKey, vDest, txType, vSols); + if ( keyType != 0 ) { - // if we failed to solve, and got a vDest, assume P2PKH or P2PK address returned - if (vDest.which()) - { - CKeyID kid; - if (CBitcoinAddress(vDest).GetKeyID(kid)) - { - vSols.push_back(vector(kid.begin(), kid.end())); - } - } - else if (txType == TX_SCRIPTHASH) - { - keyType = 2; - } for (auto addr : vSols) { uint160 addrHash = addr.size() == 20 ? uint160(addr) : Hash160(addr); @@ -3448,8 +3450,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (fAddressIndex || fSpentIndex) { - for (size_t j = 0; j < tx.vin.size(); j++) { - + for (size_t j = 0; j < tx.vin.size(); j++) + { const CTxIn input = tx.vin[j]; const CTxOut &prevout = view.GetOutputFor(tx.vin[j]); @@ -3457,25 +3459,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CTxDestination vDest; txnouttype txType = TX_PUBKEYHASH; uint160 addrHash; - int keyType = 0; - // some non-standard types, like time lock coinbases, don't solve, but do extract - if ((Solver(prevout.scriptPubKey, txType, vSols) || ExtractDestination(prevout.scriptPubKey, vDest))) + int keyType = GetAddressType(prevout.scriptPubKey, vDest, txType, vSols); + if ( keyType != 0 ) { - keyType = 1; - - // if we failed to solve, and got a vDest, assume P2PKH or P2PK address returned - if (vDest.which()) - { - CKeyID kid; - if (CBitcoinAddress(vDest).GetKeyID(kid)) - { - vSols.push_back(vector(kid.begin(), kid.end())); - } - } - else if (txType == TX_SCRIPTHASH) - { - keyType = 2; - } for (auto addr : vSols) { addrHash = addr.size() == 20 ? uint160(addr) : Hash160(addr); @@ -3485,12 +3471,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // remove address from unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(keyType, addrHash, input.prevout.hash, input.prevout.n), CAddressUnspentValue())); } - } - if (fSpentIndex) { - // add the spent index to determine the txid and input that spent an output - // and to find the amount and address from an input - spentIndex.push_back(make_pair(CSpentIndexKey(input.prevout.hash, input.prevout.n), CSpentIndexValue(txhash, j, pindex->GetHeight(), prevout.nValue, keyType, addrHash))); + if (fSpentIndex) { + // add the spent index to determine the txid and input that spent an output + // and to find the amount and address from an input + spentIndex.push_back(make_pair(CSpentIndexKey(input.prevout.hash, input.prevout.n), CSpentIndexValue(txhash, j, pindex->GetHeight(), prevout.nValue, keyType, addrHash))); + } } } } @@ -3541,23 +3527,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin vector> vSols; CTxDestination vDest; txnouttype txType = TX_PUBKEYHASH; - int keyType = 1; - // some non-standard types, like time lock coinbases, don't solve, but do extract - if ((Solver(out.scriptPubKey, txType, vSols) || ExtractDestination(out.scriptPubKey, vDest)) && txType != TX_MULTISIG) + int keyType = GetAddressType(out.scriptPubKey, vDest, txType, vSols); + if ( keyType != 0 ) { - // if we failed to solve, and got a vDest, assume P2PKH or P2PK address returned - if (vDest.which()) - { - CKeyID kid; - if (CBitcoinAddress(vDest).GetKeyID(kid)) - { - vSols.push_back(vector(kid.begin(), kid.end())); - } - } - else if (txType == TX_SCRIPTHASH) - { - keyType = 2; - } for (auto addr : vSols) { addrHash = addr.size() == 20 ? uint160(addr) : Hash160(addr); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 814f7b9b8..cf7c85417 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -853,8 +853,9 @@ bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &addr address = CBitcoinAddress(CScriptID(hash)).ToString(); } else if (type == 1) { address = CBitcoinAddress(CKeyID(hash)).ToString(); - } - else { + } else if (type == 3) { + address = CBitcoinAddress(CKeyID(hash)).ToString(); + } else { return false; } return true; diff --git a/src/txdb.cpp b/src/txdb.cpp index ace04ebdb..c8721c92a 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -458,10 +458,10 @@ uint32_t komodo_segid32(char *coinaddr); {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} \ }; -int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold,int32_t top,std::vector > &vaddr) +int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,std::vector > &vaddr, UniValue &ret) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; - int64_t utxos = 0; int64_t ignoredAddresses = 0; + int64_t utxos = 0; int64_t ignoredAddresses = 0, cryptoConditionsUTXOs = 0, cryptoConditionsTotals = 0; DECLARE_IGNORELIST boost::scoped_ptr iter(NewIterator()); std::map addressAmounts; @@ -482,6 +482,12 @@ int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold,int32_t top,std::vector GetValue(nValue); getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); + if ( indexKey.type == 3 ) + { + cryptoConditionsUTXOs++; + cryptoConditionsTotals += nValue; + continue; + } if ( nValue > dustthreshold ) { std::map ::iterator ignored = ignoredMap.find(address); @@ -508,7 +514,7 @@ int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold,int32_t top,std::vector element : addressAmounts) vaddr.push_back( make_pair(element.second, element.first) ); std::sort(vaddr.rbegin(), vaddr.rend()); int topN = 0; for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) { - //obj.push_back( make_pair("addr", it->second.c_str() ) ); - //char amount[32]; - //sprintf(amount, "%.8f", (double) it->first / COIN); - //obj.push_back( make_pair("amount", amount) ); - //obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str()) & 0x3f) ); - //addressesSorted.push_back(obj); total += it->first; topN++; // If requested, only show top N addresses in output JSON if ( top == topN ) break; } + // this is for the snapshot RPC, you can skip this by passing false to the 3rd arugment. + // Still needs UniValue defined to use SnapShot2 though, can this be changed to just pass 0? + // I tried to make it a pointer, and check if the pointer was 0, but UniValue class didnt like that. + if ( fRPC ) + { + // Total amount in this snapshot, which is less than circulating supply if top parameter is used + ret.push_back(make_pair("total", (double) total / COIN )); + // Average amount in each address of this snapshot + ret.push_back(make_pair("average",(double) (total/COIN) / totalAddresses )); + // Total number of utxos processed in this snaphot + ret.push_back(make_pair("utxos", utxos)); + // Total number of addresses in this snaphot + ret.push_back(make_pair("total_addresses", top ? top : totalAddresses )); + // Total number of ignored addresses in this snaphot + ret.push_back(make_pair("ignored_addresses", ignoredAddresses)); + // Total number of crypto condition utxos we skipped + ret.push_back(make_pair("skipped_cc_utxos", cryptoConditionsUTXOs)); + // Total value of skipped crypto condition utxos + ret.push_back(make_pair("cc_utxo_value", (double) cryptoConditionsTotals / COIN)); + // The snapshot finished at this block height + ret.push_back(make_pair("ending_height", chainActive.Height())); + } return(topN); } UniValue CBlockTreeDB::Snapshot(int top) { - int64_t total = 0; int64_t totalAddresses = 0; std::string address; - int64_t utxos = 0; int64_t ignoredAddresses = 0; - DECLARE_IGNORELIST - boost::scoped_ptr iter(NewIterator()); - std::map addressAmounts; + int topN = 0; std::vector > vaddr; UniValue result(UniValue::VOBJ); - result.push_back(Pair("start_time", (int) time(NULL))); - - /* std::map ignoredMap = { - {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, - {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, - {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, - {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, - {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, - {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, - {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, - {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, - {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, - {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, - {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, - {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, - {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey - };*/ - - int64_t startingHeight = chainActive.Height(); - //fprintf(stderr, "Starting snapshot at height %lli\n", startingHeight); - for (iter->SeekToLast(); iter->Valid(); iter->Prev()) - { - boost::this_thread::interruption_point(); - try - { - std::vector slKey = std::vector(); - pair keyObj; - iter->GetKey(keyObj); - - char chType = keyObj.first; - CAddressIndexIteratorKey indexKey = keyObj.second; - - //fprintf(stderr, "chType=%d\n", chType); - if (chType == DB_ADDRESSUNSPENTINDEX) - { - try { - CAmount nValue; - iter->GetValue(nValue); - - getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); - - if (nValue > 0) { - std::map ::iterator ignored = ignoredMap.find(address); - if (ignored != ignoredMap.end()) { - fprintf(stderr,"ignoring %s\n", address.c_str()); - ignoredAddresses++; - continue; - } - - std::map ::iterator pos = addressAmounts.find(address); - if (pos == addressAmounts.end()) { - // insert new address + utxo amount - //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); - addressAmounts[address] = nValue; - totalAddresses++; - } else { - // update unspent tally for this address - //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); - addressAmounts[address] += nValue; - } - //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); - // total += nValue; - utxos++; - } else { - fprintf(stderr,"ignoring amount=0 UTXO for %s\n", address.c_str()); - } - } catch (const std::exception& e) { - fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what()); - break; - } - } - } catch (const std::exception& e) { - fprintf(stderr, "DONE reading index entries\n"); - break; - } - } - - UniValue addresses(UniValue::VARR); - //fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses); - - for (std::pair element : addressAmounts) { - vaddr.push_back( make_pair(element.second, element.first) ); - } - std::sort(vaddr.rbegin(), vaddr.rend()); - - UniValue obj(UniValue::VOBJ); UniValue addressesSorted(UniValue::VARR); - int topN = 0; - for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) + result.push_back(Pair("start_time", (int) time(NULL))); + if ( Snapshot2(0,top,true,vaddr,result) != 0 ) { - UniValue obj(UniValue::VOBJ); - obj.push_back( make_pair("addr", it->second.c_str() ) ); - char amount[32]; - sprintf(amount, "%.8f", (double) it->first / COIN); - obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str()) & 0x3f) ); - total += it->first; - addressesSorted.push_back(obj); - topN++; - // If requested, only show top N addresses in output JSON - if (top == topN) - break; - } - - if (top) - totalAddresses = top; - - if (totalAddresses > 0) { - // Array of all addreses with balances + for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) + { + UniValue obj(UniValue::VOBJ); + obj.push_back( make_pair("addr", it->second.c_str() ) ); + char amount[32]; + sprintf(amount, "%.8f", (double) it->first / COIN); + obj.push_back( make_pair("amount", amount) ); + obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str()) & 0x3f) ); + addressesSorted.push_back(obj); + topN++; + // If requested, only show top N addresses in output JSON + if ( top == topN ) + break; + } + // Array of all addreses with balances result.push_back(make_pair("addresses", addressesSorted)); - // Total amount in this snapshot, which is less than circulating supply if top parameter is used - result.push_back(make_pair("total", (double) total / COIN )); - // Average amount in each address of this snapshot - result.push_back(make_pair("average",(double) (total/COIN) / totalAddresses )); - } - // Total number of utxos processed in this snaphot - result.push_back(make_pair("utxos", utxos)); - // Total number of addresses in this snaphot - result.push_back(make_pair("total_addresses", totalAddresses)); - // Total number of ignored addresses in this snaphot - result.push_back(make_pair("ignored_addresses", ignoredAddresses)); - // The snapshot began at this block height - result.push_back(make_pair("start_height", startingHeight)); - // The snapshot finished at this block height - result.push_back(make_pair("ending_height", chainActive.Height())); + } else result.push_back(make_pair("error", "problem doing snapshot")); return(result); } diff --git a/src/txdb.h b/src/txdb.h index 9b80b922b..8b98994a2 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -116,7 +116,7 @@ public: bool LoadBlockIndexGuts(); bool blockOnchainActive(const uint256 &hash); UniValue Snapshot(int top); - int32_t Snapshot2(int64_t dustthreshold,int32_t top,std::vector > &vaddr); + int32_t Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,std::vector > &vaddr, UniValue &ret); }; #endif // BITCOIN_TXDB_H From df118e7c8ff255a3fa3ecf4d14b6e0b8ba9fff62 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 7 Apr 2019 23:16:25 +0800 Subject: [PATCH 3743/3904] fix json output --- src/txdb.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index c8721c92a..e5c260e4f 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -548,7 +548,7 @@ int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,s if ( fRPC ) { // Total amount in this snapshot, which is less than circulating supply if top parameter is used - ret.push_back(make_pair("total", (double) total / COIN )); + ret.push_back(make_pair("total", (double) (total+cryptoConditionsTotals)/ COIN )); // Average amount in each address of this snapshot ret.push_back(make_pair("average",(double) (total/COIN) / totalAddresses )); // Total number of utxos processed in this snaphot @@ -561,6 +561,8 @@ int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,s ret.push_back(make_pair("skipped_cc_utxos", cryptoConditionsUTXOs)); // Total value of skipped crypto condition utxos ret.push_back(make_pair("cc_utxo_value", (double) cryptoConditionsTotals / COIN)); + // total of all the address's, does not count coins in CC vouts. + ret.push_back(make_pair("address_total", (double) total/ COIN )); // The snapshot finished at this block height ret.push_back(make_pair("ending_height", chainActive.Height())); } From 7c86c40d7153ae22b7278de4b88e38db5128b350 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 7 Apr 2019 23:54:44 +0800 Subject: [PATCH 3744/3904] description comment --- src/txdb.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/txdb.cpp b/src/txdb.cpp index e5c260e4f..93000d9fb 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -548,6 +548,7 @@ int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,s if ( fRPC ) { // Total amount in this snapshot, which is less than circulating supply if top parameter is used + // Use the address_total for a total of all address included when using top parameter. ret.push_back(make_pair("total", (double) (total+cryptoConditionsTotals)/ COIN )); // Average amount in each address of this snapshot ret.push_back(make_pair("average",(double) (total/COIN) / totalAddresses )); From 247a2ccc7f7a03e5ea7e91c45da8d5eb5d9986a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 7 Apr 2019 06:15:43 -1100 Subject: [PATCH 3745/3904] Sync --- src/cc/pegs.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 341e34c58..0c9613df3 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -17,8 +17,7 @@ /* - -*/ + */ // start of consensus code From 07f9635bd0e2ea46208bb4c8cb1f12d43611c39f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Apr 2019 02:41:05 -1100 Subject: [PATCH 3746/3904] Comments --- src/cc/pegs.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 0c9613df3..f6c9ae5b1 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -16,7 +16,52 @@ #include "CCPegs.h" /* +pegs CC is able to create a coin backed (by any supported coin with gateways CC deposits) and pegged to any synthetic price that is able to be calculated based on prices CC + + First, the prices CC needs to be understood, so the extensive comments at the top of ~/src/cc/prices.cpp needs to be understood. + + The second aspect is the ability to import coins, as used by the crosschain burn/import and the -ac_import chains. + + + + OK, now we are ready to describe the pegs CC. Let us imagine an -ac_import sidechain with KMD gateways CC. Now we have each native coin fungible with the real KMD via the gateways deposit/withdraw mechanism. Let us start with that and make a pegged and backed USD chain. + + + + Here the native coin is KMD, but we want USD, so there needs to be a way to convert the KMD amounts into USD amounts. Something like "KMDBTC, BTCUSD, *, 1" which is the prices CC syntax to calculate KMD/USD, which is exactly what we need. So now we can assume that we have a block by block usable KMD/USD price. implementationwise, there can be an -ac option like -ac_peg="KMDBTC, BTCUSD, *, 1" and in conjunction with -ac_import=KMD gateways CC sidechain, we now have a chain where deposit of KMD issues the correct USD coins and redeem of USD coins releases the correct number of KMD coins. + + Are we done yet? + + Not quite, as the prices of KMD will be quite volatile relative to USD, which is good during bull markets, not so happy during bear markets. There are 2 halves to this problem, how to deal with massive price increase (easy to solve), how to solve 90% price drop (a lot harder). + + In order to solve both, what is needed is an "account" based tracking which updates based on both price change, coins issued, payments made. So let us create an account that is based on a specific pubkey, where all relevant deposits, issuances, withdraws are tracked via appropriate vin/vout markers. + + Let us modify the USD chain above so that only 80% of the possible USD is issued and 20% held in reserve. This 80% should be at least some easily changeable #define, or even an -ac parameter. We want the issued coins to be released without any encumberances, but the residual 20% value is still controlled (owned) but the depositor. This account has the amount of KMD deposited and USD issued. At the moment of deposit, there will still be 20% equity left. Let us start with 1000 KMD deposit, $1.5 per KMD -> 800 KMD converted to 1200 USD into depositor pubkey and the account of (1000 KMD, -1200 USD) = 200 KMD or $300 equity. + + Now it becomes easy for the bull market case, which is to allow (for a fee like 1%) issuance of more USD as the equity increases, so let us imagine KMD at $10: + + (1000 KMD, -1200 USD, 200KMD reserve) -> $2000 equity, issue 80% -> $1600 using 160 KMD + (1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve) + + we have $2800 USD in circulation, 40 KMD reserve left against $10000 marketcap of the original deposit. It it easy to see that there are never any problems with lack of KMD to redeem the issued USD in a world where prices only go up. Total USD issuance can be limited by using a decentralized account tracking based on each deposit. + + What is evident though is that with the constantly changing price and the various times that all the various deposits issue USD, the global reserves are something that will be hard to predict and in fact needs to be specifically tracked. Let us combine all accounts exposure in to a global reserves factor. This factor will control various max/min/ allowed and fee percentages. + + Now we are prepared to handle the price goes down scenario. We can rely on the global equity/reserve ratio to be changing relatively slowly as the reference price is the smooted trustless oracles price. This means there will be enough blocks to adjust the global reserves percentage. What we need to do is liquidate specific positions that have the least reserves. + + What does liquidation mean? It means a specific account will be purchased at below its current value and the KMD withdrawn. Let us assume the price drops to $5: + + (1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve) 1000 KMD with 2800 USD issued so $2200 reserves. Let us assume it can be liquidated at a 10% discount, so for $2000 in addition to the $2800, the 5000 KMD is able to be withdrawn. This removes 4800 USD coins for 1000 KMD, which is a very low reserve amount of 4%. If a low reserve amount is removed from the system, then the global reserve amount must be improved. + + Now, we have a decentralized mechanism to handle the price going lower! Combined with the fully decentralized method new USD coins are issued, makes this argubably the first decentralized blockchain that is both backed and pegged. There is the reliance on the gateways CC multisig signers, so there is a fundamental federated trust for chains without intrinsic value. + + Also, notice that the flexibly syntax of prices CC allows to define pegs easily for virtually any type of synthetic, and all the ECB fiats can easily get a backed and pegged coin. + + Let us now consider how to enforce a peg onto a specific gateways CC token. If this can also be achieved, then a full DEX for all the different gateways CC supported coins can be created onto a single fiat denominated chain. + + + */ // start of consensus code From 74aa8a95364df9b26e18bbd961e0fdcfa5fd0fd6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Apr 2019 02:47:02 -1100 Subject: [PATCH 3747/3904] Update --- src/cc/pegs.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index f6c9ae5b1..218f4c68e 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -53,6 +53,9 @@ pegs CC is able to create a coin backed (by any supported coin with gateways CC (1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve) 1000 KMD with 2800 USD issued so $2200 reserves. Let us assume it can be liquidated at a 10% discount, so for $2000 in addition to the $2800, the 5000 KMD is able to be withdrawn. This removes 4800 USD coins for 1000 KMD, which is a very low reserve amount of 4%. If a low reserve amount is removed from the system, then the global reserve amount must be improved. + In addition to the global reserves calculation, there needs to be a trigger percentage that enables positions to be liquidated. We also want to liquidate the worst positions, so in addition to the trigger percentage, there should be a liquidation threshold, and the liquidator would need to find 3 or more better positions that are beyond the liquidation threshold, to be able to liquidate. This will get us to at most 3 accounts that could be liquidated but are not able to, so some method to allow those to also be liquidated. The liquidating nodes are making instant profits, so they should be expected to do whatever blockchain scanning and proving to make things easy for the rest of the nodes + + Now, we have a decentralized mechanism to handle the price going lower! Combined with the fully decentralized method new USD coins are issued, makes this argubably the first decentralized blockchain that is both backed and pegged. There is the reliance on the gateways CC multisig signers, so there is a fundamental federated trust for chains without intrinsic value. Also, notice that the flexibly syntax of prices CC allows to define pegs easily for virtually any type of synthetic, and all the ECB fiats can easily get a backed and pegged coin. From 01be71fd44280d2c23d348b775ddf697f5a27759 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Apr 2019 05:29:47 -1100 Subject: [PATCH 3748/3904] Unsolved issue --- src/cc/pegs.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 218f4c68e..b83279276 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -53,8 +53,15 @@ pegs CC is able to create a coin backed (by any supported coin with gateways CC (1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve) 1000 KMD with 2800 USD issued so $2200 reserves. Let us assume it can be liquidated at a 10% discount, so for $2000 in addition to the $2800, the 5000 KMD is able to be withdrawn. This removes 4800 USD coins for 1000 KMD, which is a very low reserve amount of 4%. If a low reserve amount is removed from the system, then the global reserve amount must be improved. - In addition to the global reserves calculation, there needs to be a trigger percentage that enables positions to be liquidated. We also want to liquidate the worst positions, so in addition to the trigger percentage, there should be a liquidation threshold, and the liquidator would need to find 3 or more better positions that are beyond the liquidation threshold, to be able to liquidate. This will get us to at most 3 accounts that could be liquidated but are not able to, so some method to allow those to also be liquidated. The liquidating nodes are making instant profits, so they should be expected to do whatever blockchain scanning and proving to make things easy for the rest of the nodes + In addition to the global reserves calculation, there needs to be a trigger percentage that enables positions to be liquidated. We also want to liquidate the worst positions, so in addition to the trigger percentage, there should be a liquidation threshold, and the liquidator would need to find 3 or more better positions that are beyond the liquidation threshold, to be able to liquidate. This will get us to at most 3 accounts that could be liquidated but are not able to, so some method to allow those to also be liquidated. The liquidating nodes are making instant profits, so they should be expected to do whatever blockchain scanning and proving to make things easy for the rest of the nodes. + One last issue is the normal redemption case where we are not liquidating. In this case, it should be done at the current marketprice, should improve the global reserves metrics and not cause anybody whose position was modified to have cause for complaint. Ideally, there would be an account that has the identical to the global reserve percentage and also at the same price as current marketprice, but this is not realistic, so we need to identify classes of accounts and consider which ones can be fully or partially liquidated to satisfy the constraints. + + looking at our example account: + (1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve) + + what sort of non-liquidation withdraw would be acceptable? if the base amount 1000 KMD is reduced along with USD owed, then the reserve status will go up for the account. but that would seem to allow extra USD to be able to be issued. there should be no disadvantage from funding a withdraw, but also not any large advantage. it needs to be a neutral event.... + UNSOLVED selection, account adjustment issue Now, we have a decentralized mechanism to handle the price going lower! Combined with the fully decentralized method new USD coins are issued, makes this argubably the first decentralized blockchain that is both backed and pegged. There is the reliance on the gateways CC multisig signers, so there is a fundamental federated trust for chains without intrinsic value. From d8edaa38ecf3b9aa3be5470c89d1ec508bcc3380 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 01:36:30 +0800 Subject: [PATCH 3749/3904] make wallet filter work for testnet notary --- src/wallet/wallet.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1208a77f2..003404c97 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1772,7 +1772,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { // wallet filter for notary nodes. Disabled! Can be reenabled or customised for any specific use, pools could also use this to prevent wallet dwy attack. - if ( 0 && !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + if ( !tx.IsCoinBase() ) //&& !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) @@ -1782,7 +1782,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) { - if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) + if ( CBitcoinAddress(address).ToString() == "RXhapCShoqNeWytLXeWR2wX7m5xfNYfxNx" ) numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() ) { @@ -1803,6 +1803,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl // Count vouts, check if OUR notary address is the receiver. if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) { + // if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. + if ( 1 ) //MIN_RECV_SATS == 0 ) { + fprintf(stderr, "This node is on full lock down all txs are ignored! \n"); + return false; + } for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; @@ -1815,11 +1820,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } } } - // if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. - if ( MIN_RECV_SATS == 0 ) { - fprintf(stderr, "This node is on full lock down all txs are ignored! \n"); - return false; - } // If no vouts are to the notary address we will ignore them. if ( numvoutIsOurs == 0 ) { fprintf(stderr, "Received transaction to address other than notary address, ignored! \n"); From 7e74cb117ca964bf7a415656b2e622edc95d3599 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 01:39:38 +0800 Subject: [PATCH 3750/3904] fix --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 003404c97..592a22c34 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1804,7 +1804,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) { // if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. - if ( 1 ) //MIN_RECV_SATS == 0 ) { + if ( 1 ) { //MIN_RECV_SATS == 0 ) { fprintf(stderr, "This node is on full lock down all txs are ignored! \n"); return false; } From faea9232848f80892130f6f3d76cc0372560ed98 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 05:10:52 +0800 Subject: [PATCH 3751/3904] set notary address from -pubkey filter still default to on. --- src/wallet/wallet.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 592a22c34..c16720e60 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1751,6 +1751,8 @@ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS,WHITELIST_ADDRESS; extern int32_t IS_STAKED_NOTARY; extern uint64_t MIN_RECV_SATS; +bool WALLET_FILTER = true; +#include "cc/CCinclude.h" bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { @@ -1769,41 +1771,41 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl return false; } } + static std::string NotaryAddress; static bool didinit; + if ( !didinit && NotaryAddress.empty() && NOTARY_PUBKEY33[0] != 0 ) + { + didinit = true; + char Raddress[64]; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + NotaryAddress.assign(Raddress); + } if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { // wallet filter for notary nodes. Disabled! Can be reenabled or customised for any specific use, pools could also use this to prevent wallet dwy attack. - if ( !tx.IsCoinBase() ) //&& !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + if ( !tx.IsCoinBase() && WALLET_FILTER && !NotaryAddress.empty() ) //&& !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { - int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0; + int numvinIsOurs = 0, numvinIsWhiteList = 0; // numvoutIsOurs = 0, int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vin[i].prevout.hash,txin,hash,false)) + if ( GetTransaction(tx.vin[i].prevout.hash,txin,hash,false) && ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address) ) { - if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) - { - if ( CBitcoinAddress(address).ToString() == "RXhapCShoqNeWytLXeWR2wX7m5xfNYfxNx" ) - numvinIsOurs++; - if ( !WHITELIST_ADDRESS.empty() ) - { - //fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString().c_str()); - if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) { - //fprintf(stderr, "whitlisted is set to true here.\n"); - numvinIsWhiteList++; - } - } - } + if ( CBitcoinAddress(address).ToString() == NotaryAddress ) + numvinIsOurs++; + if ( !WHITELIST_ADDRESS.empty() && CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) + numvinIsWhiteList++; } } // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. if ( numvinIsOurs != 0 ) - fprintf(stderr, "We sent from address: %s vins: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); + fprintf(stderr, "We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs); if ( numvinIsWhiteList != 0 ) fprintf(stderr, "We received from whitelisted address: %s\n",WHITELIST_ADDRESS.c_str()); // Count vouts, check if OUR notary address is the receiver. if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) { - // if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. + return false; + /*/ if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. if ( 1 ) { //MIN_RECV_SATS == 0 ) { fprintf(stderr, "This node is on full lock down all txs are ignored! \n"); return false; @@ -1832,7 +1834,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl // average vout size is less than set minimum, default is 1 coin, we will ignore it fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, (long)avgVoutSize); return false; - } + } */ } } From a30fb4ae364d3040e352dc154d197c3a6ba33c8f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 05:38:10 +0800 Subject: [PATCH 3752/3904] test --- src/wallet/wallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c16720e60..ac6b7d6c0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1778,6 +1778,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl char Raddress[64]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NotaryAddress.assign(Raddress); + fprintf(stderr, "1 notary address.%s\n", NotaryAddress.c_str()); } if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { @@ -1790,12 +1791,14 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl uint256 hash; CTransaction txin; CTxDestination address; if ( GetTransaction(tx.vin[i].prevout.hash,txin,hash,false) && ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address) ) { + fprintf(stderr, "2 notary address.%s address.%s\n", NotaryAddress.c_str(), address.c_str()); if ( CBitcoinAddress(address).ToString() == NotaryAddress ) numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() && CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) numvinIsWhiteList++; } } + fprintf(stderr, "3 notary address.%s\n", NotaryAddress.c_str()); // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. if ( numvinIsOurs != 0 ) fprintf(stderr, "We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs); From 0d587ccc31697e1a758d27e9bd4da10aa3093a60 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 05:39:34 +0800 Subject: [PATCH 3753/3904] fix --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ac6b7d6c0..279b149e8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1791,7 +1791,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl uint256 hash; CTransaction txin; CTxDestination address; if ( GetTransaction(tx.vin[i].prevout.hash,txin,hash,false) && ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address) ) { - fprintf(stderr, "2 notary address.%s address.%s\n", NotaryAddress.c_str(), address.c_str()); + fprintf(stderr, "2 notary address.%s address.%s\n", NotaryAddress.c_str(), CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == NotaryAddress ) numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() && CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) From 6f5e339884dcee6c825c59de2aa339e2db2be1cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 05:50:06 +0800 Subject: [PATCH 3754/3904] fix --- src/wallet/wallet.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 279b149e8..f4a52cf24 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1778,7 +1778,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl char Raddress[64]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NotaryAddress.assign(Raddress); - fprintf(stderr, "1 notary address.%s\n", NotaryAddress.c_str()); + fprintf(stderr, "notary address set to %s\n", NotaryAddress.c_str()); } if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { @@ -1791,14 +1791,12 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl uint256 hash; CTransaction txin; CTxDestination address; if ( GetTransaction(tx.vin[i].prevout.hash,txin,hash,false) && ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address) ) { - fprintf(stderr, "2 notary address.%s address.%s\n", NotaryAddress.c_str(), CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == NotaryAddress ) numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() && CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) numvinIsWhiteList++; } } - fprintf(stderr, "3 notary address.%s\n", NotaryAddress.c_str()); // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. if ( numvinIsOurs != 0 ) fprintf(stderr, "We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs); From e101aa3f9bf3e5e831237dd5519d06a93c0a040b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 06:10:02 +0800 Subject: [PATCH 3755/3904] make -whitelistaddress= activate wallet filter --- src/wallet/wallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f4a52cf24..35edc24c6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1751,7 +1751,6 @@ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS,WHITELIST_ADDRESS; extern int32_t IS_STAKED_NOTARY; extern uint64_t MIN_RECV_SATS; -bool WALLET_FILTER = true; #include "cc/CCinclude.h" bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) @@ -1783,7 +1782,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { // wallet filter for notary nodes. Disabled! Can be reenabled or customised for any specific use, pools could also use this to prevent wallet dwy attack. - if ( !tx.IsCoinBase() && WALLET_FILTER && !NotaryAddress.empty() ) //&& !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + if ( !tx.IsCoinBase() && !WHITELIST_ADDRESS.empty() && !NotaryAddress.empty() ) //&& !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvinIsWhiteList = 0; // numvoutIsOurs = 0, int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) @@ -1793,7 +1792,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( CBitcoinAddress(address).ToString() == NotaryAddress ) numvinIsOurs++; - if ( !WHITELIST_ADDRESS.empty() && CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) + if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) numvinIsWhiteList++; } } From 2e19349105ca2813646a0240417635cba7ee9a36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Apr 2019 21:54:24 -1100 Subject: [PATCH 3756/3904] Redeem solution --- src/cc/pegs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index b83279276..00d76d8fd 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -61,7 +61,10 @@ pegs CC is able to create a coin backed (by any supported coin with gateways CC (1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve) what sort of non-liquidation withdraw would be acceptable? if the base amount 1000 KMD is reduced along with USD owed, then the reserve status will go up for the account. but that would seem to allow extra USD to be able to be issued. there should be no disadvantage from funding a withdraw, but also not any large advantage. it needs to be a neutral event.... - UNSOLVED selection, account adjustment issue + + One solution is to allow for the chance for any account to be liquidated, but the equity compensated for with a premium based on the account reserves. So in the above case, a premium of 5% on the 40KMD reserve is paid to liquidate its account. Instead of 5% premium, a lower 1% can be done if based on the MAX(correlated[daywindow],smoothed) so we get something that is close to the current marketprice. To prevent people taking advantage of the slowness of the smoothed price to adjust, there would need to be a one day delay in the withdraw. + + From a practical sense, it seems a day is a long time, so maybe having a way to pay a premium like 10%, or wait a day to get the MAX(correlated[daywindow],smoothed) price. This price "jumping" might also be taken advantage of in the deposit side, so similar to prices CC it seems good to have the MAX(correlated[daywindow],smoothed) method. Now, we have a decentralized mechanism to handle the price going lower! Combined with the fully decentralized method new USD coins are issued, makes this argubably the first decentralized blockchain that is both backed and pegged. There is the reliance on the gateways CC multisig signers, so there is a fundamental federated trust for chains without intrinsic value. From 237f11559425593a0a65554fc01d093f596b88dd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Apr 2019 18:53:32 +0800 Subject: [PATCH 3757/3904] Clean up some LABS related code, remove un-used/needed stuff. Adds actual working and feild tested wallet filter. Can set any amount of whitelist address's, in conf file or commandline args. fix daemon deadlock, when doing z_mergetoaddress and mining at same time (needs more testing on staking chains) Set z_mergtoaddress to use a 0 expiry height when not doing z-tx's. They were failing and peers were getting banned trying to broadcast them. --- src/komodo.h | 10 ------ src/komodo_defs.h | 4 +-- src/komodo_globals.h | 10 +++--- src/komodo_utils.h | 2 -- src/main.cpp | 3 -- src/miner.cpp | 35 +++++---------------- src/notaries_staked.cpp | 16 ++-------- src/notaries_staked.h | 1 - src/wallet/rpcwallet.cpp | 4 ++- src/wallet/wallet.cpp | 67 ++++++++++++---------------------------- 10 files changed, 40 insertions(+), 112 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 791adba33..3ceb29cc3 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -836,16 +836,6 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); UpdateNotaryAddrs(tmp_pubkeys,numSN); STAKED_ERA = staked_era; - if ( NOTARYADDRS[0][0] != 0 && NOTARY_PUBKEY33[0] != 0 ) - { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) - { - IS_KOMODO_NOTARY = 0; - if ( MIN_RECV_SATS == -1 ) - MIN_RECV_SATS = 100000000; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d MIN_TX_VALUE.%lu \n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era,MIN_RECV_SATS); - } - } lastStakedEra = staked_era; } } diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 49aa67081..9377ea276 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -80,9 +80,9 @@ extern int32_t VERUS_MIN_STAKEAGE; extern std::string DONATION_PUBKEY; extern uint8_t ASSETCHAINS_PRIVATE; extern int32_t USE_EXTERNAL_PUBKEY; +extern char NOTARYADDRS[64][64]; int tx_height( const uint256 &hash ); -extern char NOTARYADDRS[64][36]; -extern uint8_t NUM_NOTARIES; +extern std::vector vWhiteListAddress; void komodo_netevent(std::vector payload); int32_t komodo_priceind(char *symbol); diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 1c47e72e6..eccbb34f1 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,12 +47,14 @@ unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES,ASSETCHAINS_MARMARA; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; bool VERUS_MINTBLOCKS; std::vector Mineropret; +std::vector vWhiteListAddress; +char NOTARYADDRS[64][64]; -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_BEAMPORT,ASSETCHAINS_CODAPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1,STAKING_MIN_DIFF; uint32_t ASSETCHAINS_MAGIC = 2387029918; @@ -99,7 +101,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t ASSETCHAINS_STAKED; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,ASSETCHAINS_FOUNDERS_REWARD; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2d0fe4f4e..043d7282e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1677,8 +1677,6 @@ void komodo_args(char *argv0) fprintf(stderr, "Cannot be STAKED and KMD notary at the same time!\n"); exit(0); } - MIN_RECV_SATS = GetArg("-mintxvalue",-1); - WHITELIST_ADDRESS = GetArg("-whitelistaddress",""); memset(ccenables,0,sizeof(ccenables)); memset(disablebits,0,sizeof(disablebits)); if ( GetBoolArg("-gen", false) != 0 ) diff --git a/src/main.cpp b/src/main.cpp index 8fbc0f1dd..faa9e6a9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1270,9 +1270,6 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState } } -extern char NOTARYADDRS[64][36]; -extern uint8_t NUM_NOTARIES; - int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; diff --git a/src/miner.cpp b/src/miner.cpp index f131bc90e..54b18195a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -224,8 +224,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CBlockIndex* pindexPrev = 0; { - ENTER_CRITICAL_SECTION(cs_main); - ENTER_CRITICAL_SECTION(mempool.cs); + LOCK2(cs_main,mempool.cs); pindexPrev = chainActive.LastTip(); const int nHeight = pindexPrev->GetHeight() + 1; const Consensus::Params &consensusParams = chainparams.GetConsensus(); @@ -564,11 +563,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[512],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); - + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); if (ASSETCHAINS_LWMAPOS != 0) { uint32_t nBitsPOS; @@ -593,7 +591,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { sleep(1); if ( (rand() % 100) < 1 ) - fprintf(stderr, "%u seconds until elegible, waiting.\n", blocktime-((uint32_t)GetAdjustedTime()+57)); + fprintf(stderr, "%u seconds until elegible, waiting...\n", blocktime-((uint32_t)GetAdjustedTime()+57)); if ( chainActive.LastTip()->GetHeight() >= stakeHeight ) { fprintf(stderr, "Block Arrived, reset staking loop.\n"); @@ -603,7 +601,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 return(0); } } - + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); if ( siglen > 0 ) { CAmount txfees; @@ -616,7 +615,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nFees += txfees; pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); - } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); + } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } // Create coinbase tx @@ -688,11 +687,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (scriptPubKeyIn.IsPayToScriptHash() || scriptPubKeyIn.IsPayToCryptoCondition()) { fprintf(stderr,"CreateNewBlock: attempt to add timelock to pay2sh or pay2cc\n"); - if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) - { - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); - } return 0; } @@ -714,11 +708,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); - if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) - { - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); - } return(0); } fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); @@ -789,11 +778,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 else { fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); - if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) - { - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); - } return(0); } } @@ -808,11 +792,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr,"valid\n"); } } - if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) - { - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); - } //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a3278ac12..0b7c97ceb 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,11 +4,11 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[64][36]; +extern char NOTARYADDRS[64][64]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; -extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; +extern uint8_t NOTARY_PUBKEY33[33]; int8_t is_STAKED(const char *chain_name) { @@ -46,16 +46,6 @@ int32_t STAKED_era(int timestamp) return(0); }; -int8_t updateStakedNotary() { - std::string notaryname; - char Raddress[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - NOTARY_ADDRESS.clear(); - NOTARY_ADDRESS.assign(Raddress); - return(StakedNotaryID(notaryname,Raddress)); -} - int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { if ( STAKED_ERA != 0 ) { @@ -116,7 +106,6 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { // null pubkeys, era 0. pthread_mutex_lock(&staked_mutex); memset(NOTARYADDRS,0,sizeof(NOTARYADDRS)); - NUM_NOTARIES = 0; pthread_mutex_unlock(&staked_mutex); } else @@ -125,7 +114,6 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { pthread_mutex_lock(&staked_mutex); for (int i = 0; i builder; if (isToSaplingZaddr || saplingNoteInputs.size() > 0) { builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain); - } + } else + contextualTx.nExpiryHeight = 0; // set non z-tx to have no expiry height. + // Create operation and add to global queue std::shared_ptr q = getAsyncRPCQueue(); std::shared_ptr operation( diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 35edc24c6..9b2975db1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -38,6 +38,7 @@ #include "crypter.h" #include "coins.h" #include "zcash/zip32.h" +#include "cc/CCinclude.h" #include @@ -1747,11 +1748,6 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * pblock is optional, but should be provided if the transaction is known to be in a block. * If fUpdate is true, existing transactions will be updated. */ -extern uint8_t NOTARY_PUBKEY33[33]; -extern std::string NOTARY_ADDRESS,WHITELIST_ADDRESS; -extern int32_t IS_STAKED_NOTARY; -extern uint64_t MIN_RECV_SATS; -#include "cc/CCinclude.h" bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { @@ -1777,14 +1773,20 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl char Raddress[64]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NotaryAddress.assign(Raddress); - fprintf(stderr, "notary address set to %s\n", NotaryAddress.c_str()); + vWhiteListAddress = mapMultiArgs["-whitelistaddress"]; + if ( !vWhiteListAddress.empty() ) + { + fprintf(stderr, "Activated Wallet Filter \n Notary Address: %s \n Adding whitelist address's:\n", NotaryAddress.c_str()); + for ( auto wladdr : vWhiteListAddress ) + fprintf(stderr, " %s\n", wladdr.c_str()); + } } if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { - // wallet filter for notary nodes. Disabled! Can be reenabled or customised for any specific use, pools could also use this to prevent wallet dwy attack. - if ( !tx.IsCoinBase() && !WHITELIST_ADDRESS.empty() && !NotaryAddress.empty() ) //&& !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + // wallet filter for notary nodes. Enables by setting -whitelistaddress= as startup param or in conf file (works same as -addnode byut with R-address's) + if ( !tx.IsCoinBase() && !vWhiteListAddress.empty() && !NotaryAddress.empty() ) { - int numvinIsOurs = 0, numvinIsWhiteList = 0; // numvoutIsOurs = 0, int64_t totalvoutvalue = 0; + int numvinIsOurs = 0, numvinIsWhiteList = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; @@ -1792,50 +1794,21 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( CBitcoinAddress(address).ToString() == NotaryAddress ) numvinIsOurs++; - if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) - numvinIsWhiteList++; - } - } - // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. - if ( numvinIsOurs != 0 ) - fprintf(stderr, "We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs); - if ( numvinIsWhiteList != 0 ) - fprintf(stderr, "We received from whitelisted address: %s\n",WHITELIST_ADDRESS.c_str()); - // Count vouts, check if OUR notary address is the receiver. - if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) - { - return false; - /*/ if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. - if ( 1 ) { //MIN_RECV_SATS == 0 ) { - fprintf(stderr, "This node is on full lock down all txs are ignored! \n"); - return false; - } - for (size_t i = 0; i < tx.vout.size() ; i++) - { - CTxDestination address2; - if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) + for ( auto wladdr : vWhiteListAddress ) { - if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) + if ( CBitcoinAddress(address).ToString() == wladdr ) { - numvoutIsOurs++; - totalvoutvalue += tx.vout[i].nValue; + //fprintf(stderr, "We received from whitelisted address.%s\n", wladdr.c_str()); + numvinIsWhiteList++; } } } - // If no vouts are to the notary address we will ignore them. - if ( numvoutIsOurs == 0 ) { - fprintf(stderr, "Received transaction to address other than notary address, ignored! \n"); - return false; - } - fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,(int32_t)numvoutIsOurs); - // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. - int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; - if ( avgVoutSize < MIN_RECV_SATS ) { - // average vout size is less than set minimum, default is 1 coin, we will ignore it - fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, (long)avgVoutSize); - return false; - } */ } + // Now we know if it was a tx sent to us, by either a whitelisted address, or ourself. + if ( numvinIsOurs != 0 ) + fprintf(stderr, "We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs); + if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) + return false; } CWalletTx wtx(this,tx); From 497038ca05656d6da82985dc7c99e91e27c4535b Mon Sep 17 00:00:00 2001 From: zatJUM <45312760+zatJUM@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:59:41 +0000 Subject: [PATCH 3758/3904] Updates returned strings for cleanwallettransactions --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index da9afc215..860333b83 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1067,9 +1067,9 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) "1. \"txid\" (string, optional) The transaction id to keep.\n" "\nResult:\n" "{\n" - " \"total_transactons\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n" - " \"remaining_transactons\" : n, (numeric) Transactions in wallet after clean.\n" - " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" + " \"total_transactions\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n" + " \"remaining_transactions\" : n, (numeric) Transactions in wallet after clean.\n" + " \"removed_transactions\" : n, (numeric) The number of transactions removed.\n" "}\n" "\nExamples:\n" + HelpExampleCli("cleanwallettransactions", "") From bce0b87e6f2735dff3c1137780cb6418da3798b8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 10 Apr 2019 02:11:40 +0800 Subject: [PATCH 3759/3904] . --- src/komodo_bitcoind.h | 32 ++++++++++++---------- src/rpc/client.cpp | 1 + src/rpc/crosschain.cpp | 60 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 78 insertions(+), 15 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e537df018..aa21896aa 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1917,33 +1917,37 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar return(total); } -uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) +bool GetNotarisationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const std::vector &vin, std::vector &NotarisationNotaries) { - std::vector NotarisationNotaries; - uint32_t timestamp = pblock->nTime; - int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; - numSN = komodo_notaries(notarypubkeys, height, timestamp); - - // No point going further, no notaries can be paid. - if ( notarypubkeys[0][0] == 0 ) - return(0); - uint8_t *script; int32_t scriptlen; - // Loop over the notarisation and extract the position of the participating notaries in the array of pukeys for this era. - BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin) + if ( notarypubkeys[0][0] == 0 ) + return false; + BOOST_FOREACH(const CTxIn& txin, vin) { uint256 hash; CTransaction tx1; if ( GetTransaction(txin.prevout.hash,tx1,hash,false) ) { - for (int8_t i = 0; i < numSN; i++) + for (int8_t i = 0; i < numNN; i++) { script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 ) NotarisationNotaries.push_back(i); } - } + } else return false; } + return true; +} + +uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) +{ + std::vector NotarisationNotaries; uint8_t *script; int32_t scriptlen; + uint64_t timestamp = pblock->nTime; + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + numSN = komodo_notaries(notarypubkeys, height, timestamp); + if ( !GetNotarisationNotaries(notarypubkeys, numSN, pblock->vtx[1].vin, NotarisationNotaries) ) + return(0); + // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); if ( checkdupes.size() != NotarisationNotaries.size() ) { diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 19910b25c..cab89092c 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -171,6 +171,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "assetchainproof", 1}, { "crosschainproof", 1}, { "getproofroot", 2}, + { "getNotarisationsForBlock", 0}, { "height_MoM", 1}, { "calc_MoM", 2}, }; diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 710f99f09..72c24086f 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -33,6 +33,7 @@ #include "script/script_error.h" #include "script/sign.h" #include "script/standard.h" +#include "notaries_staked.h" #include "key_io.h" @@ -49,6 +50,7 @@ int32_t komodo_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM *mdata,char *symbol,int32_t kmdheight,int32_t notarized_height); struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi); uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth); +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); extern std::string ASSETCHAINS_SELFIMPORT; uint256 Parseuint256(char *hexstr); @@ -406,7 +408,63 @@ UniValue selfimport(const UniValue& params, bool fHelp) return result; } +bool GetNotarisationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const std::vector &vin, std::vector &NotarisationNotaries); + UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) +{ + // TODO take timestamp as param, and loop blockindex to get starting/finish height. + if (fHelp || params.size() != 1) + throw runtime_error("getNotarisationsForBlock height\n\n" + "Takes a block height and returns notarisation information " + "within the block"); + + LOCK(cs_main); + int32_t height = params[0].get_int(); + if ( height < 0 || height > chainActive.Height() ) + throw runtime_error("height out of range.\n"); + + uint256 blockHash = chainActive[height]->GetBlockHash(); + + NotarisationsInBlock nibs; + GetBlockNotarisations(blockHash, nibs); + UniValue out(UniValue::VOBJ); + //out.push_back(make_pair("blocktime",(int))); + UniValue labs(UniValue::VARR); + UniValue kmd(UniValue::VARR); + // Gets KMD notaries on KMD... but LABS notaries on labs chains needs to be fixed so LABS are identified on KMD. + int8_t numNN = 0; uint8_t notarypubkeys[64][33] = {0}; + numNN = komodo_notaries(notarypubkeys, height, chainActive[height]->nTime); + + BOOST_FOREACH(const Notarisation& n, nibs) + { + UniValue item(UniValue::VOBJ); UniValue notaryarr(UniValue::VARR); std::vector NotarisationNotaries; + if ( is_STAKED(n.second.symbol) != 0 ) + continue; // for now just skip this... need to fetch diff pubkeys for these chains. labs.push_back(item); + uint256 hash; CTransaction tx; + if ( GetTransaction(n.first,tx,hash,false) ) + { + if ( !GetNotarisationNotaries(notarypubkeys, numNN, tx.vin, NotarisationNotaries) ) + continue; + if ( NotarisationNotaries.size() < numNN/5 ) + continue; + } + item.push_back(make_pair("txid", n.first.GetHex())); + item.push_back(make_pair("chain", n.second.symbol)); + item.push_back(make_pair("height", (int)n.second.height)); + item.push_back(make_pair("blockhash", n.second.blockHash.GetHex())); + item.push_back(make_pair("KMD_height", height)); // for when timstamp input is used. + + for ( auto notary : NotarisationNotaries ) + notaryarr.push_back(notary); + item.push_back(make_pair("notaries",notaryarr)); + kmd.push_back(item); + } + out.push_back(make_pair("KMD", kmd)); + //out.push_back(make_pair("LABS", labs)); + return out; +} + +/*UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error("getNotarisationsForBlock blockHash\n\n" @@ -426,7 +484,7 @@ UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) out.push_back(item); } return out; -} +}*/ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp) From df79068ab65e64eb8d91cdfafcc5528560f40a12 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 10 Apr 2019 02:12:52 +0800 Subject: [PATCH 3760/3904] y --- src/notarystats.py | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/notarystats.py diff --git a/src/notarystats.py b/src/notarystats.py new file mode 100644 index 000000000..cc67ad10e --- /dev/null +++ b/src/notarystats.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +""" +build komodod from here: https://github.com/blackjok3rtt/komodo/tree/nota_stats +sudo apt-get install python3-dev +sudo apt-get install python3 libgnutls28-dev libssl-dev +sudo apt-get install python3-pip +pip3 install setuptools +pip3 install wheel +pip3 install base58 slick-bitcoinrpc +./notarystats.py +------------------------------------------------ +""" +import platform +import os +import re +import sys +import time +import pprint +from slickrpc import Proxy + +# fucntion to define rpc_connection +def def_credentials(chain): + rpcport = ''; + operating_system = platform.system() + if operating_system == 'Darwin': + ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' + elif operating_system == 'Linux': + ac_dir = os.environ['HOME'] + '/.komodo' + elif operating_system == 'Windows': + ac_dir = '%s/komodo/' % os.environ['APPDATA'] + if chain == 'KMD': + coin_config_file = str(ac_dir + '/komodo.conf') + else: + coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') + with open(coin_config_file, 'r') as f: + for line in f: + l = line.rstrip() + if re.search('rpcuser', l): + rpcuser = l.replace('rpcuser=', '') + elif re.search('rpcpassword', l): + rpcpassword = l.replace('rpcpassword=', '') + elif re.search('rpcport', l): + rpcport = l.replace('rpcport=', '') + if len(rpcport) == 0: + if chain == 'KMD': + rpcport = 7771 + else: + print("rpcport not in conf file, exiting") + print("check " + coin_config_file) + exit(1) + return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport)))) + + +rpc = def_credentials('KMD') +pp = pprint.PrettyPrinter(indent=2) + +#Second time filter for assetchains (block 821657) +notarynames = [ "0dev1_jl777", "0dev2_kolo", "0dev3_kolo", "0dev4_decker", "a-team_SH", "artik_AR", "artik_EU", "artik_NA", "artik_SH", "badass_EU", "badass_NA", "batman_AR", "batman_SH", "ca333_EU", "chainmakers_EU", "chainmakers_NA", "chainstrike_SH", "cipi_AR", "cipi_NA", "crackers_EU", "crackers_NA", "dwy_EU", "emmanux_SH", "etszombi_EU", "fullmoon_AR", "fullmoon_NA", "fullmoon_SH", "goldenman_EU", "indenodes_AR", "indenodes_EU", "indenodes_NA", "indenodes_SH", "jackson_AR", "jeezy_EU", "karasugoi_NA", "komodoninja_EU", "komodoninja_SH", "komodopioneers_SH", "libscott_SH", "lukechilds_AR", "madmax_AR", "meshbits_AR", "meshbits_SH", "metaphilibert_AR", "metaphilibert_SH", "patchkez_SH", "pbca26_NA", "peer2cloud_AR", "peer2cloud_SH", "polycryptoblog_NA", "hyper_AR", "hyper_EU", "hyper_SH", "hyper_NA", "popcornbag_AR", "popcornbag_NA", "alien_AR", "alien_EU", "thegaltmines_NA", "titomane_AR", "titomane_EU", "titomane_SH", "webworker01_NA", "xrobesx_NA" ] +notaries = 64 * [0] + +startheight = 821657 +stopheight = 1300000 +for i in range(startheight,stopheight): + ret = rpc.getNotarisationsForBlock(i) + KMD = ret['KMD'] + if len(KMD) > 0: + for obj in KMD: + # sanity check, KMD nota dont appear in DB anyway! + if obj['chain'] == 'KMD': + continue; + for notary in obj['notaries']: + notaries[notary] = notaries[notary] + 1 + +i = 0 +SH = [] +AR = [] +EU = [] +NA = [] +for notary in notaries: + tmpnotary = {} + tmpnotary['node'] = notarynames[i] + tmpnotary['ac_count'] = notary + if notarynames[i].endswith('SH'): + SH.append(tmpnotary) + elif notarynames[i].endswith('AR'): + AR.append(tmpnotary) + elif notarynames[i].endswith('EU'): + EU.append(tmpnotary) + elif notarynames[i].endswith('NA'): + NA.append(tmpnotary) + i = i + 1 + +regions = {} +regions['SH'] = sorted(SH, key=lambda k: k['ac_count'], reverse=True) +regions['AR'] = sorted(AR, key=lambda k: k['ac_count'], reverse=True) +regions['EU'] = sorted(EU, key=lambda k: k['ac_count'], reverse=True) +regions["NA"] = sorted(NA, key=lambda k: k['ac_count'], reverse=True) + +pp.pprint(regions) From e688959c6e3343f1c93c24b4642310ba4e93a062 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 10 Apr 2019 11:41:29 +0800 Subject: [PATCH 3761/3904] ... --- src/notarystats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/notarystats.py diff --git a/src/notarystats.py b/src/notarystats.py old mode 100644 new mode 100755 index cc67ad10e..c8b3ab1f1 --- a/src/notarystats.py +++ b/src/notarystats.py @@ -58,14 +58,14 @@ pp = pprint.PrettyPrinter(indent=2) notarynames = [ "0dev1_jl777", "0dev2_kolo", "0dev3_kolo", "0dev4_decker", "a-team_SH", "artik_AR", "artik_EU", "artik_NA", "artik_SH", "badass_EU", "badass_NA", "batman_AR", "batman_SH", "ca333_EU", "chainmakers_EU", "chainmakers_NA", "chainstrike_SH", "cipi_AR", "cipi_NA", "crackers_EU", "crackers_NA", "dwy_EU", "emmanux_SH", "etszombi_EU", "fullmoon_AR", "fullmoon_NA", "fullmoon_SH", "goldenman_EU", "indenodes_AR", "indenodes_EU", "indenodes_NA", "indenodes_SH", "jackson_AR", "jeezy_EU", "karasugoi_NA", "komodoninja_EU", "komodoninja_SH", "komodopioneers_SH", "libscott_SH", "lukechilds_AR", "madmax_AR", "meshbits_AR", "meshbits_SH", "metaphilibert_AR", "metaphilibert_SH", "patchkez_SH", "pbca26_NA", "peer2cloud_AR", "peer2cloud_SH", "polycryptoblog_NA", "hyper_AR", "hyper_EU", "hyper_SH", "hyper_NA", "popcornbag_AR", "popcornbag_NA", "alien_AR", "alien_EU", "thegaltmines_NA", "titomane_AR", "titomane_EU", "titomane_SH", "webworker01_NA", "xrobesx_NA" ] notaries = 64 * [0] -startheight = 821657 -stopheight = 1300000 +startheight = 1300000 #821657 +stopheight = 99999999 for i in range(startheight,stopheight): ret = rpc.getNotarisationsForBlock(i) KMD = ret['KMD'] if len(KMD) > 0: for obj in KMD: - # sanity check, KMD nota dont appear in DB anyway! + #for now skip KMD for this. As official stats are from BTC chain? if obj['chain'] == 'KMD': continue; for notary in obj['notaries']: From 3d83dda142d7fceafd951255d8738e90bc0521cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 10 Apr 2019 12:07:31 +0800 Subject: [PATCH 3762/3904] fix script --- src/notarystats.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notarystats.py b/src/notarystats.py index c8b3ab1f1..b606db1a6 100755 --- a/src/notarystats.py +++ b/src/notarystats.py @@ -54,18 +54,18 @@ def def_credentials(chain): rpc = def_credentials('KMD') pp = pprint.PrettyPrinter(indent=2) -#Second time filter for assetchains (block 821657) notarynames = [ "0dev1_jl777", "0dev2_kolo", "0dev3_kolo", "0dev4_decker", "a-team_SH", "artik_AR", "artik_EU", "artik_NA", "artik_SH", "badass_EU", "badass_NA", "batman_AR", "batman_SH", "ca333_EU", "chainmakers_EU", "chainmakers_NA", "chainstrike_SH", "cipi_AR", "cipi_NA", "crackers_EU", "crackers_NA", "dwy_EU", "emmanux_SH", "etszombi_EU", "fullmoon_AR", "fullmoon_NA", "fullmoon_SH", "goldenman_EU", "indenodes_AR", "indenodes_EU", "indenodes_NA", "indenodes_SH", "jackson_AR", "jeezy_EU", "karasugoi_NA", "komodoninja_EU", "komodoninja_SH", "komodopioneers_SH", "libscott_SH", "lukechilds_AR", "madmax_AR", "meshbits_AR", "meshbits_SH", "metaphilibert_AR", "metaphilibert_SH", "patchkez_SH", "pbca26_NA", "peer2cloud_AR", "peer2cloud_SH", "polycryptoblog_NA", "hyper_AR", "hyper_EU", "hyper_SH", "hyper_NA", "popcornbag_AR", "popcornbag_NA", "alien_AR", "alien_EU", "thegaltmines_NA", "titomane_AR", "titomane_EU", "titomane_SH", "webworker01_NA", "xrobesx_NA" ] notaries = 64 * [0] -startheight = 1300000 #821657 -stopheight = 99999999 +startheight = 821657 #Second time filter for assetchains (block 821657) for KMD its 814000 +stopheight = rpc.getblockcount() # @kolo what height does season end?! for i in range(startheight,stopheight): ret = rpc.getNotarisationsForBlock(i) KMD = ret['KMD'] if len(KMD) > 0: for obj in KMD: - #for now skip KMD for this. As official stats are from BTC chain? + #for now skip KMD for this. As official stats are from BTC chain + # this can be reversed to !== to count KMD numbers :) if obj['chain'] == 'KMD': continue; for notary in obj['notaries']: From 2fbb858beff294255787898d38963c1222ba2346 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Wed, 10 Apr 2019 12:27:53 +0800 Subject: [PATCH 3763/3904] remove git link --- src/notarystats.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/notarystats.py b/src/notarystats.py index b606db1a6..0e7673833 100755 --- a/src/notarystats.py +++ b/src/notarystats.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 """ -build komodod from here: https://github.com/blackjok3rtt/komodo/tree/nota_stats sudo apt-get install python3-dev sudo apt-get install python3 libgnutls28-dev libssl-dev sudo apt-get install python3-pip From 2e2bb2b51883c2e2479df531e1cff33a624e3046 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 10 Apr 2019 16:53:08 +0800 Subject: [PATCH 3764/3904] fix getsnapshot2 thanks to dimxy's advice. --- src/txdb.cpp | 28 +++++++++++++--------------- src/txdb.h | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 93000d9fb..4c9ea31ca 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -458,7 +458,7 @@ uint32_t komodo_segid32(char *coinaddr); {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} \ }; -int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,std::vector > &vaddr, UniValue &ret) +int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold, int32_t top ,std::vector > &vaddr, UniValue *ret) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; int64_t utxos = 0; int64_t ignoredAddresses = 0, cryptoConditionsUTXOs = 0, cryptoConditionsTotals = 0; @@ -542,30 +542,28 @@ int32_t CBlockTreeDB::Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,s if ( top == topN ) break; } - // this is for the snapshot RPC, you can skip this by passing false to the 3rd arugment. - // Still needs UniValue defined to use SnapShot2 though, can this be changed to just pass 0? - // I tried to make it a pointer, and check if the pointer was 0, but UniValue class didnt like that. - if ( fRPC ) + // this is for the snapshot RPC, you can skip this by passing a 0 as the last argument. + if (ret) { // Total amount in this snapshot, which is less than circulating supply if top parameter is used // Use the address_total for a total of all address included when using top parameter. - ret.push_back(make_pair("total", (double) (total+cryptoConditionsTotals)/ COIN )); + ret->push_back(make_pair("total", (double) (total+cryptoConditionsTotals)/ COIN )); // Average amount in each address of this snapshot - ret.push_back(make_pair("average",(double) (total/COIN) / totalAddresses )); + ret->push_back(make_pair("average",(double) (total/COIN) / totalAddresses )); // Total number of utxos processed in this snaphot - ret.push_back(make_pair("utxos", utxos)); + ret->push_back(make_pair("utxos", utxos)); // Total number of addresses in this snaphot - ret.push_back(make_pair("total_addresses", top ? top : totalAddresses )); + ret->push_back(make_pair("total_addresses", top ? top : totalAddresses )); // Total number of ignored addresses in this snaphot - ret.push_back(make_pair("ignored_addresses", ignoredAddresses)); + ret->push_back(make_pair("ignored_addresses", ignoredAddresses)); // Total number of crypto condition utxos we skipped - ret.push_back(make_pair("skipped_cc_utxos", cryptoConditionsUTXOs)); + ret->push_back(make_pair("skipped_cc_utxos", cryptoConditionsUTXOs)); // Total value of skipped crypto condition utxos - ret.push_back(make_pair("cc_utxo_value", (double) cryptoConditionsTotals / COIN)); + ret->push_back(make_pair("cc_utxo_value", (double) cryptoConditionsTotals / COIN)); // total of all the address's, does not count coins in CC vouts. - ret.push_back(make_pair("address_total", (double) total/ COIN )); + ret->push_back(make_pair("address_total", (double) total/ COIN )); // The snapshot finished at this block height - ret.push_back(make_pair("ending_height", chainActive.Height())); + ret->push_back(make_pair("ending_height", chainActive.Height())); } return(topN); } @@ -577,7 +575,7 @@ UniValue CBlockTreeDB::Snapshot(int top) UniValue result(UniValue::VOBJ); UniValue addressesSorted(UniValue::VARR); result.push_back(Pair("start_time", (int) time(NULL))); - if ( Snapshot2(0,top,true,vaddr,result) != 0 ) + if ( Snapshot2(0,top,vaddr,&result) != 0 ) { for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) { diff --git a/src/txdb.h b/src/txdb.h index 8b98994a2..b4c4cd6bd 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -116,7 +116,7 @@ public: bool LoadBlockIndexGuts(); bool blockOnchainActive(const uint256 &hash); UniValue Snapshot(int top); - int32_t Snapshot2(int64_t dustthreshold, int32_t top, bool fRPC ,std::vector > &vaddr, UniValue &ret); + int32_t Snapshot2(int64_t dustthreshold, int32_t top,std::vector > &vaddr, UniValue *ret); }; #endif // BITCOIN_TXDB_H From 2872c88795f76019ca7b783910220b259a43db1c Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Wed, 10 Apr 2019 13:09:11 +0200 Subject: [PATCH 3765/3904] Adding dual daemon import and gateway import. (#21) --- src/Makefile.am | 1 + src/cc/CCGateways.h | 1 - src/cc/CCImportGateway.h | 38 ++ src/cc/CCcustom.cpp | 22 +- src/cc/CCinclude.h | 14 +- src/cc/CCutils.cpp | 89 +++ src/cc/dapps/oraclefeed.c | 77 ++- src/cc/eval.h | 3 +- src/cc/gateways.cpp | 187 ++---- src/cc/import.cpp | 589 ++++++++++++----- src/cc/importgateway.cpp | 1292 +++++++++++++++++++++++++++++++++++++ src/cc/oracles.cpp | 3 +- src/importcoin.cpp | 83 ++- src/importcoin.h | 11 +- src/rpc/crosschain.cpp | 357 +++++++++- src/rpc/server.cpp | 15 + src/rpc/server.h | 13 +- src/wallet/rpcwallet.cpp | 14 +- 18 files changed, 2440 insertions(+), 369 deletions(-) create mode 100644 src/cc/CCImportGateway.h create mode 100644 src/cc/importgateway.cpp diff --git a/src/Makefile.am b/src/Makefile.am index ce7fd1731..248f9aa27 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -288,6 +288,7 @@ libbitcoin_server_a_SOURCES = \ bloom.cpp \ cc/eval.cpp \ cc/import.cpp \ + cc/importgateway.cpp \ cc/CCassetsCore.cpp \ cc/CCcustom.cpp \ cc/CCtx.cpp \ diff --git a/src/cc/CCGateways.h b/src/cc/CCGateways.h index 1f594e38b..8dfed186f 100644 --- a/src/cc/CCGateways.h +++ b/src/cc/CCGateways.h @@ -18,7 +18,6 @@ #define CC_GATEWAYS_H #include "CCinclude.h" -#include "../merkleblock.h" bool GatewaysValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys,uint8_t p1,uint8_t p2,uint8_t p3,uint8_t p4); diff --git a/src/cc/CCImportGateway.h b/src/cc/CCImportGateway.h new file mode 100644 index 000000000..995cde460 --- /dev/null +++ b/src/cc/CCImportGateway.h @@ -0,0 +1,38 @@ +/****************************************************************************** + * Copyright © 2014-2018 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + + +#ifndef CC_IMPORTGATEWAY_H +#define CC_IMPORTGATEWAY_H + +#include "CCinclude.h" + +// CCcustom +bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn); +bool ImportGatewayExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid); +std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys,uint8_t p1,uint8_t p2,uint8_t p3,uint8_t p4); +std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 burntxid,int32_t burnvout,std::string rawburntx,std::vectorproof,CPubKey destpub); +std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount); +std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string refcoin, std::string hex); +std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string refcoin,std::string hex); +std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin); +UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin); +UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin); +UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin); +UniValue ImportGatewayExternalAddress(uint256 bindtxid,CPubKey pubkey); +UniValue ImportGatewayDumpPrivKey(uint256 bindtxid,CKey key); +UniValue ImportGatewayList(); +UniValue ImportGatewayInfo(uint256 bindtxid); +#endif \ No newline at end of file diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 3a00e0c98..6c66b3599 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -31,6 +31,7 @@ #include "CCPayments.h" #include "CCGateways.h" #include "CCtokens.h" +#include "CCImportGateway.h" /* CCcustom has most of the functions that need to be extended to create a new CC contract. @@ -63,7 +64,6 @@ const char *AssetsCCaddr = "RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6"; const char *AssetsNormaladdr = "RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u"; char AssetsCChexstr[67] = { "02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702" }; uint8_t AssetsCCpriv[32] = { 0x9b, 0x17, 0x66, 0xe5, 0x82, 0x66, 0xac, 0xb6, 0xba, 0x43, 0x83, 0x74, 0xf7, 0x63, 0x11, 0x3b, 0xf0, 0xf3, 0x50, 0x6f, 0xd9, 0x6b, 0x67, 0x85, 0xf9, 0x7a, 0xf0, 0x54, 0x4d, 0xb1, 0x30, 0x77 }; - #include "CCcustom.inc" #undef FUNCNAME #undef EVALCODE @@ -75,7 +75,6 @@ const char *FaucetCCaddr = "R9zHrofhRbub7ER77B7NrVch3A63R39GuC"; const char *FaucetNormaladdr = "RKQV4oYs4rvxAWx1J43VnT73rSTVtUeckk"; char FaucetCChexstr[67] = { "03682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe12" }; uint8_t FaucetCCpriv[32] = { 0xd4, 0x4f, 0xf2, 0x31, 0x71, 0x7d, 0x28, 0x02, 0x4b, 0xc7, 0xdd, 0x71, 0xa0, 0x39, 0xc4, 0xbe, 0x1a, 0xfe, 0xeb, 0xc2, 0x46, 0xda, 0x76, 0xf8, 0x07, 0x53, 0x3d, 0x96, 0xb4, 0xca, 0xa0, 0xe9 }; - #include "CCcustom.inc" #undef FUNCNAME #undef EVALCODE @@ -243,6 +242,17 @@ uint8_t CClibCCpriv[32] = { 0x57, 0xcf, 0x49, 0x71, 0x7d, 0xb4, 0x15, 0x1b, 0x4f #undef FUNCNAME #undef EVALCODE +// ImportGateway +#define FUNCNAME IsImportGatewayInput +#define EVALCODE EVAL_IMPORTGATEWAY +const char *ImportGatewayCCaddr = "RXJT6CRAXHFuQ2UjqdxMj7EfrayF6UJpzZ"; +const char *ImportGatewayNormaladdr = "RNFRho63Ddz1Rh2eGPETykrU4fA8r67S4Y"; +char ImportGatewayCChexstr[67] = { "0397231cfe04ea32d5fafb2206773ec9fba6e15c5a4e86064468bca195f7542714" }; +uint8_t ImportGatewayCCpriv[32] = { 0x65, 0xef, 0x27, 0xeb, 0x3d, 0xb0, 0xb4, 0xae, 0x0f, 0xbc, 0x77, 0xdb, 0xf8, 0x40, 0x48, 0x90, 0x52, 0x20, 0x9e, 0x45, 0x3b, 0x49, 0xd8, 0x97, 0x60, 0x8c, 0x27, 0x4c, 0x59, 0x46, 0xe1, 0xdf }; +#include "CCcustom.inc" +#undef FUNCNAME +#undef EVALCODE + int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) { CPubKey pk; int32_t i; uint8_t pub33[33],check33[33],hash[32]; char CCaddr[64],checkaddr[64],str[67]; @@ -425,6 +435,14 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) cp->validate = TokensValidate; cp->ismyvin = IsTokensInput; break; + case EVAL_IMPORTGATEWAY: + strcpy(cp->unspendableCCaddr, ImportGatewayCCaddr); + strcpy(cp->normaladdr, ImportGatewayNormaladdr); + strcpy(cp->CChexstr, ImportGatewayCChexstr); + memcpy(cp->CCpriv, ImportGatewayCCpriv, 32); + cp->validate = ImportGatewayValidate; + cp->ismyvin = IsImportGatewayInput; + break; default: if ( CClib_initcp(cp,evalcode) < 0 ) return(0); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 12b4a6d12..d1fda0154 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -51,6 +51,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../komodo_defs.h" #include "../utlist.h" #include "../uthash.h" +#include "merkleblock.h" #define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" #define CC_MAXVINS 1024 @@ -185,9 +186,12 @@ bool GetCCParams(Eval* eval, const CTransaction &tx, uint32_t nIn, CTransaction &txOut, std::vector> &preConditions, std::vector> ¶ms); int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format); -uint8_t DecodeOraclesCreateOpRet(const CScript &scriptPubKey,std::string &name,std::string &description,std::string &format); uint256 OracleMerkle(int32_t height,uint256 reforacletxid,char *format,std::vectorpublishers); uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk); +uint8_t DecodeOraclesCreateOpRet(const CScript &scriptPubKey,std::string &name,std::string &description,std::string &format); +uint8_t DecodeOraclesOpRet(const CScript &scriptPubKey,uint256 &oracletxid,CPubKey &pk,int64_t &num); +uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); +int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t *data,int32_t offset,int32_t datalen); //int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs); @@ -212,11 +216,6 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, ui void GetNonfungibleData(uint256 tokenid, vscript_t &vopretNonfungible); bool ExtractTokensCCVinPubkeys(const CTransaction &tx, std::vector &vinPubkeys); -uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint256 &batontxid,CPubKey &pk,std::vector &data); -int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t *data,int32_t offset,int32_t datalen); - - - // CCcustom CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); //uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector &vopret1, std::vector &vopret2); @@ -270,6 +269,9 @@ bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t t std::vector Mypubkey(); bool Myprivkey(uint8_t myprivkey[]); int64_t CCduration(int32_t &numblocks,uint256 txid); +uint256 CCOraclesReverseScan(char const *logcategory,uint256 &txid,int32_t height,uint256 reforacletxid,uint256 batontxid); +int32_t CCCointxidExists(char const *logcategory,uint256 cointxid); +uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::vector &txids); bool komodo_txnotarizedconfirmed(uint256 txid); CPubKey check_signing_pubkey(CScript scriptSig); // CCtx diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 887550a0c..9a68c2456 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -532,6 +532,95 @@ int64_t CCduration(int32_t &numblocks,uint256 txid) return(duration); } +uint256 CCOraclesReverseScan(char const *logcategory,uint256 &txid,int32_t height,uint256 reforacletxid,uint256 batontxid) +{ + CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int32_t len,len2,numvouts; + int64_t val,merkleht; CPubKey pk; std::vectordata; char str[65],str2[65]; + + txid = zeroid; + LogPrint(logcategory,"start reverse scan %s\n",uint256_str(str,batontxid)); + while ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) + { + LogPrint(logcategory,"check %s\n",uint256_str(str,batontxid)); + if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid ) + { + LogPrint(logcategory,"decoded %s\n",uint256_str(str,batontxid)); + if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) + { + len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()); + len2 = oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()); + + LogPrint(logcategory,"found merkleht.%d len.%d len2.%d %s %s\n",(int32_t)merkleht,len,len2,uint256_str(str,hash),uint256_str(str2,mhash)); + if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid ) + { + txid = batontxid; + LogPrint(logcategory,"set txid\n"); + return(mhash); + } + else + { + LogPrint(logcategory,"missing hash\n"); + return(zeroid); + } + } + else LogPrint(logcategory,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); + batontxid = bhash; + LogPrint(logcategory,"new hash %s\n",uint256_str(str,batontxid)); + } else break; + } + LogPrint(logcategory,"end of loop\n"); + return(zeroid); +} + +int32_t myIs_coinaddr_inmempoolvout(char const *logcategory,char *coinaddr) +{ + int32_t i,n; char destaddr[64]; + BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) + { + const CTransaction &tx = e.GetTx(); + if ( (n= tx.vout.size()) > 0 ) + { + const uint256 &txid = tx.GetHash(); + for (i=0; i > addressIndex; + CCtxidaddr(txidaddr,cointxid); + SetCCtxids(addressIndex,txidaddr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + return(-1); + } + return(myIs_coinaddr_inmempoolvout(logcategory,txidaddr)); +} + +/* Get the block merkle root for a proof + * IN: proofData + * OUT: merkle root + * OUT: transaction IDS + */ +uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::vector &txids) +{ + CMerkleBlock merkleBlock; + if (!E_UNMARSHAL(proofData, ss >> merkleBlock)) + return uint256(); + return merkleBlock.txn.ExtractMatches(txids); +} + bool komodo_txnotarizedconfirmed(uint256 txid) { char str[65]; diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index cf7a2eacb..6ac014ad1 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -450,10 +450,12 @@ int32_t get_coinheader(char *refcoin,char *acname,bits256 *blockhashp,bits256 *m return(0); } -cJSON *get_gatewayspending(char *refcoin,char *acname,char *bindtxidstr) +cJSON *get_gatewayspending(int8_t type,char *refcoin,char *acname,char *bindtxidstr) { - cJSON *retjson; char *retstr; - if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewayspendingwithdraws",bindtxidstr,refcoin,"","")) != 0 ) + cJSON *retjson; char *retstr; char function[64]; + if (type==0) sprintf(function,"%s","gatewayspendingwithdraws"); + else if (type==1) sprintf(function,"%s","importgatewaypendingwithdraws"); + if ( (retjson= get_cli(refcoin,&retstr,acname,function,bindtxidstr,refcoin,"","")) != 0 ) { //printf("pending.(%s)\n",jprint(retjson,0)); return(retjson); @@ -466,10 +468,13 @@ cJSON *get_gatewayspending(char *refcoin,char *acname,char *bindtxidstr) return(0); } -cJSON *get_gatewaysprocessed(char *refcoin,char *acname,char *bindtxidstr) +cJSON *get_gatewaysprocessed(int8_t type,char *refcoin,char *acname,char *bindtxidstr) { cJSON *retjson; char *retstr; - if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewaysprocessed",bindtxidstr,refcoin,"","")) != 0 ) + char function[64]; + if (type==0) sprintf(function,"%s","gatewaysprocessed"); + else if (type==1) sprintf(function,"%s","importgatewayprocessed"); + if ( (retjson= get_cli(refcoin,&retstr,acname,function,bindtxidstr,refcoin,"","")) != 0 ) { //printf("pending.(%s)\n",jprint(retjson,0)); return(retjson); @@ -692,10 +697,12 @@ cJSON *addsignature(char *refcoin,char *acname,char *rawtx, int M) return(0); } -bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *hex) +bits256 gatewayspartialsign(int8_t type,char *refcoin,char *acname,bits256 txid,char *hex) { - char str[65],*retstr; cJSON *retjson; - if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewayspartialsign",bits256_str(str,txid),refcoin,hex,"")) != 0 ) + char str[65],*retstr; cJSON *retjson; char function[64]; + if (type==0) sprintf(function,"%s","gatewayspartialsign"); + else if (type==1) sprintf(function,"%s","importgatewaypartialsign"); + if ( (retjson= get_cli(refcoin,&retstr,acname,function,bits256_str(str,txid),refcoin,hex,"")) != 0 ) { if (strcmp("error",jstr(retjson,"result"))!=0) txid=broadcasttx(refcoin,acname,retjson); else printf("%s\n",jstr(retjson,"error")); @@ -710,10 +717,13 @@ bits256 gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *hex) return (zeroid); } -bits256 gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char *hex) +bits256 gatewayscompletesigning(int8_t type,char *refcoin,char *acname,bits256 withtxid,char *hex) { - char str[65],*retstr; cJSON *retjson; bits256 txid; - if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewayscompletesigning",bits256_str(str,withtxid),refcoin,hex,"")) != 0 ) + char str[65],*retstr; cJSON *retjson; bits256 txid; char function[64]; + + if (type==0) sprintf(function,"%s","gatewayscompletesigning"); + else if (type==1) sprintf(function,"%s","importgatewaycompletesigning"); + if ( (retjson= get_cli(refcoin,&retstr,acname,function,bits256_str(str,withtxid),refcoin,hex,"")) != 0 ) { if (strcmp("error",jstr(retjson,"result"))!=0) txid=broadcasttx(refcoin,acname,retjson); else printf("%s\n",jstr(retjson,"error")); @@ -728,10 +738,13 @@ bits256 gatewayscompletesigning(char *refcoin,char *acname,bits256 withtxid,char return (zeroid); } -bits256 gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid) +bits256 gatewaysmarkdone(int8_t type,char *refcoin,char *acname,bits256 withtxid) { - char str[65],str2[65],*retstr; cJSON *retjson; bits256 txid; - if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewaysmarkdone",bits256_str(str,withtxid),refcoin,"","")) != 0 ) + char str[65],str2[65],*retstr; cJSON *retjson; bits256 txid; ; char function[64]; + + if (type==0) sprintf(function,"%s","gatewaysmarkdone"); + else if (type==1) sprintf(function,"%s","importgatewaymarkdone"); + if ( (retjson= get_cli(refcoin,&retstr,acname,function,bits256_str(str,withtxid),refcoin,"","")) != 0 ) { if (strcmp("error",jstr(retjson,"result"))!=0) txid=broadcasttx(refcoin,acname,retjson); else printf("%s\n",jstr(retjson,"error")); @@ -746,10 +759,13 @@ bits256 gatewaysmarkdone(char *refcoin,char *acname,bits256 withtxid) return (zeroid); } -int32_t get_gatewaysinfo(char *refcoin,char *acname,char *depositaddr,int32_t *Mp,int32_t *Np,char *bindtxidstr,char *coin,char *oraclestr, char **pubkeys) +int32_t get_gatewaysinfo(int8_t type,char *refcoin,char *acname,char *depositaddr,int32_t *Mp,int32_t *Np,char *bindtxidstr,char *coin,char *oraclestr, char **pubkeys) { - char *oracle,*retstr,*name,*deposit,temp[128]; cJSON *retjson,*pubarray; int32_t n; - if ( (retjson= get_cli(refcoin,&retstr,acname,"gatewaysinfo",bindtxidstr,"","","")) != 0 ) + char *oracle,*retstr,*name,*deposit,temp[128]; cJSON *retjson,*pubarray; int32_t n; char function[64]; + + if (type==0) sprintf(function,"%s","gatewaysinfo"); + else if (type==1) sprintf(function,"%s","importgatewayinfo"); + if ( (retjson= get_cli(refcoin,&retstr,acname,function,bindtxidstr,"","","")) != 0 ) { if ( (oracle= jstr(retjson,"oracletxid")) != 0 && strcmp(oracle,oraclestr) == 0 && (deposit= jstr(retjson,"deposit")) != 0 ) { @@ -774,7 +790,6 @@ int32_t get_gatewaysinfo(char *refcoin,char *acname,char *depositaddr,int32_t *M strcat(*pubkeys,temp); } } - else printf("%s != %s\n",oracle,oraclestr); free_json(retjson); } else if ( retstr != 0 ) @@ -851,7 +866,7 @@ int32_t markerexists(char *refcoin,char *acname,char *coinaddr) } -void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t M,int32_t N) +void update_gatewayspending(int8_t type,char *refcoin,char *acname,char *bindtxidstr,int32_t M,int32_t N) { // check queue to prevent duplicate // check KMD chain and mempool for txidaddr @@ -864,7 +879,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t int32_t i,j,n,K,retval,processed = 0; bits256 txid,cointxid,withdrawtxid,lasttxid,completetxid; int64_t satoshis; memset(&zeroid,0,sizeof(zeroid)); - if ( (retjson= get_gatewayspending(refcoin,acname,bindtxidstr)) != 0 ) + if ( (retjson= get_gatewayspending(type,refcoin,acname,bindtxidstr)) != 0 ) { if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 ) { @@ -888,7 +903,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t { if ( (clijson=addsignature(refcoin,"",rawtx,M)) != 0 && is_cJSON_True(jobj(clijson,"complete")) != 0) { - txid=gatewayscompletesigning(refcoin,acname,withdrawtxid,jstr(clijson,"hex")); + txid=gatewayscompletesigning(type,refcoin,acname,withdrawtxid,jstr(clijson,"hex")); if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s 1of1\n",bits256_str(str,withdrawtxid)); else fprintf(stderr,"### SIGNING error broadcasting tx on %s",acname); free_json(clijson); @@ -910,13 +925,13 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t { if ( is_cJSON_True(jobj(clijson,"complete")) != 0 ) { - txid=gatewayscompletesigning(refcoin,acname,lasttxid,jstr(clijson,"hex")); + txid=gatewayscompletesigning(type,refcoin,acname,lasttxid,jstr(clijson,"hex")); if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s %dof%d\n",bits256_str(str,withdrawtxid),K+1,N); else fprintf(stderr,"### SIGNING error broadcasting tx on %s\n",acname); } else if ( jint(clijson,"partialtx") != 0 ) { - txid=gatewayspartialsign(refcoin,acname,lasttxid,jstr(clijson,"hex")); + txid=gatewayspartialsign(type,refcoin,acname,lasttxid,jstr(clijson,"hex")); if (txid.txid!=zeroid.txid) fprintf(stderr,"### SIGNING withdraw %s %d/%dof%d\n",bits256_str(str,withdrawtxid),K+1,M,N); else fprintf(stderr,"### SIGNING error broadcasting tx on %s\n",acname); } @@ -932,7 +947,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t } free_json(retjson); } - if ( (retjson= get_gatewaysprocessed(refcoin,acname,bindtxidstr)) != 0 ) + if ( (retjson= get_gatewaysprocessed(type,refcoin,acname,bindtxidstr)) != 0 ) { if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 ) { @@ -954,7 +969,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t { withdrawaddr = jstr(item,"withdrawaddr"); fprintf(stderr,"### WITHDRAW %.8f %s sent to %s\n",amount,refcoin,withdrawaddr); - txid=gatewaysmarkdone(refcoin,acname,completetxid); + txid=gatewaysmarkdone(type,refcoin,acname,completetxid); if (txid.txid!=zeroid.txid) fprintf(stderr,"### MARKDONE withdraw %s\n",bits256_str(str,withdrawtxid)); else fprintf(stderr,"### MARKDONE error broadcasting tx on %s\n",refcoin); } @@ -1024,7 +1039,7 @@ oraclesdata 17a841a919c284cea8a676f34e793da002e606f19a9258a3190bed12d5aaa3ff 034 int32_t main(int32_t argc,char **argv) { - cJSON *clijson,*clijson2,*regjson,*item; int32_t acheight,i,retval,M,N,n,height,prevheight = 0; char *pubkeys,*format,*acname,*oraclestr,*bindtxidstr,*pkstr,*pubstr,*retstr,*retstr2,depositaddr[64],hexstr[4096],refcoin[64]; uint64_t price; bits256 txid; + cJSON *clijson,*clijson2,*regjson,*item; int32_t type,i,retval,M,N,n,height,prevheight = 0; char *pubkeys,*format,*acname,*oraclestr,*bindtxidstr,*pkstr,*pubstr,*retstr,*retstr2,depositaddr[64],hexstr[4096],refcoin[64]; uint64_t price; bits256 txid; if ( argc < 6 ) { printf("usage: oraclefeed $ACNAME $ORACLETXID $MYPUBKEY $FORMAT $BINDTXID [refcoin_cli]\n"); @@ -1044,8 +1059,7 @@ int32_t main(int32_t argc,char **argv) printf("only formats of L and Ihh are supported now\n"); return(-1); } - M = N = 1; - acheight = 0; + M = N = 0; refcoin[0] = 0; while ( 1 ) { @@ -1061,7 +1075,9 @@ int32_t main(int32_t argc,char **argv) exit(0); } pubkeys=0; - if ( get_gatewaysinfo(refcoin,acname,depositaddr,&M,&N,bindtxidstr,refcoin,oraclestr,&pubkeys) < 0 ) + if ( get_gatewaysinfo(0,refcoin,acname,depositaddr,&M,&N,bindtxidstr,refcoin,oraclestr,&pubkeys) == 0 ) type=0; + else if ( get_gatewaysinfo(1,refcoin,acname,depositaddr,&M,&N,bindtxidstr,refcoin,oraclestr,&pubkeys) == 0 ) type=1; + else { printf("cant find bindtxid.(%s)\n",bindtxidstr); exit(0); @@ -1089,9 +1105,8 @@ int32_t main(int32_t argc,char **argv) if ( bits256_nonz(txid) != 0 ) { prevheight = height; - acheight = get_coinheight(refcoin,""); printf("%s ht.%d <- %s\n",refcoin,height,hexstr); - update_gatewayspending(refcoin,acname,bindtxidstr,M,N); + update_gatewayspending(type,refcoin,acname,bindtxidstr,M,N); } free_json(clijson2); } diff --git a/src/cc/eval.h b/src/cc/eval.h index a42bbdb2f..1324d5e21 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -56,7 +56,8 @@ EVAL(EVAL_MARMARA, 0xef) \ EVAL(EVAL_PAYMENTS, 0xf0) \ EVAL(EVAL_GATEWAYS, 0xf1) \ - EVAL(EVAL_TOKENS, 0xf2) + EVAL(EVAL_TOKENS, 0xf2) \ + EVAL(EVAL_IMPORTGATEWAY, 0xf3) \ // evalcodes 0x10 to 0x7f are reserved for cclib dynamic CC diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 3c1a49194..1039e9176 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -412,91 +412,6 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti else return(true); } -static int32_t myIs_coinaddr_inmempoolvout(char *coinaddr) -{ - int32_t i,n; char destaddr[64]; - BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) - { - const CTransaction &tx = e.GetTx(); - if ( (n= tx.vout.size()) > 0 ) - { - const uint256 &txid = tx.GetHash(); - for (i=0; idata; - txid = zeroid; - LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "start reverse scan " << batontxid.GetHex() << std::endl); - while ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) - { - LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "check " << batontxid.GetHex() << std::endl); - if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid ) - { - LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "decoded " << batontxid.GetHex() << std::endl); - if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) - { - len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()); - len2 = oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()); - LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "found merkleht." << (int32_t)merkleht << " len." << len << " len2." << len2 << " " << hash.GetHex() << " " << mhash.GetHex() << std::endl); - if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid ) - { - txid = batontxid; - LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "set txid" << std::endl); - return(mhash); - } - else - { - LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "missing hash" << std::endl); - return(zeroid); - } - } else LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "height." << (int32_t)merkleht << " vs search ht." << (int32_t)height << std::endl); - batontxid = bhash; - LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "new hash " << batontxid.GetHex() << std::endl); - } else break; - } - LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "end of loop\n"); - return(zeroid); -} - -int32_t GatewaysCointxidExists(struct CCcontract_info *cp,uint256 cointxid) -{ - char txidaddr[64]; std::string coin; int32_t numvouts; uint256 hashBlock; - std::vector > addressIndex; - CCtxidaddr(txidaddr,cointxid); - SetCCtxids(addressIndex,txidaddr); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - { - return(-1); - } - return(myIs_coinaddr_inmempoolvout(txidaddr)); -} - -/* Get the block merkle root for a proof - * IN: proofData - * OUT: merkle root - * OUT: transaction IDS - */ -uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::vector &txids) -{ - CMerkleBlock merkleBlock; - if (!E_UNMARSHAL(proofData, ss >> merkleBlock)) - return uint256(); - return merkleBlock.txn.ExtractMatches(txids); -} - int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 cointxid,const std::string deposithex,std::vectorproof,uint256 merkleroot,CPubKey destpub,uint8_t taddr,uint8_t prefix,uint8_t prefix2) { std::vector txids; uint256 proofroot,hashBlock,txid = zeroid; CTransaction tx; std::string name,description,format; @@ -737,7 +652,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & merkleroot = zeroid; for (i=m=0; i >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) @@ -1630,15 +1545,15 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) GetTokensCCaddress(cp,tokensaddr,gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) { - CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); + return(result); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) { - CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); + return(result); } n = msigpubkeys.size(); queueflag = 0; @@ -1717,16 +1632,16 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) gatewayspk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) - { - CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); + return(result); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin) { - CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); + return(result); } n = msigpubkeys.size(); queueflag = 0; @@ -1795,16 +1710,16 @@ UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey) cp = CCinit(&C,EVAL_GATEWAYS); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) - { - CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); + return(result); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') { - CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); + return(result); } GetCustomscriptaddress(addr,CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG,taddr,prefix,prefix2); result.push_back(Pair("result","success")); @@ -1819,16 +1734,16 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key) cp = CCinit(&C,EVAL_GATEWAYS); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) - { - CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); + return(result); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') { - CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); + return(result); } priv=EncodeCustomSecret(key,wiftype); @@ -1848,16 +1763,16 @@ UniValue GatewaysInfo(uint256 bindtxid) Gatewayspk = GetUnspendable(cp,0); GetTokensCCaddress(cp,gatewaystokens,Gatewayspk); if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) - { - CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); + return(result); } if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') { - CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); - LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); - return(""); + result.push_back(Pair("result","error")); + result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); + return(result); } if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) { @@ -1866,19 +1781,17 @@ UniValue GatewaysInfo(uint256 bindtxid) depositaddr[0] = 0; if ( tx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,tx.vout[tx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 && M <= N && N > 0 ) { - if ( N > 1 ) - { - result.push_back(Pair("M",M)); - result.push_back(Pair("N",N)); - for (i=0; i -//#define LEV_INFO 0 -//#define LEV_DEBUG1 1 -//#define LOGSTREAM(category, level, logoperator) { std::ostringstream stream; logoperator; for(int i = 0; i < level; i ++) if( LogAcceptCategory( (std::string(category) + (level > 0 ? std::string("-")+std::to_string(level) : std::string("") )).c_str() ) ) LogPrintStr(stream.str()); } - -/* - * CC Eval method for import coin. - * - * This method should control every parameter of the ImportCoin transaction, since it has no signature - * to protect it from malleability. - - ##### 0xffffffff is a special CCid for single chain/dual daemon imports - */ +#include "key_io.h" +#define CODA_BURN_ADDRESS "KPrrRoPfHOnNpZZQ6laHXdQDkSQDkVHaN0V+LizLlHxz7NaA59sBAAAA" extern std::string ASSETCHAINS_SELFIMPORT; extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT; @@ -41,10 +32,97 @@ extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::vector &txids); uint256 GatewaysReverseScan(uint256 &txid, int32_t height, uint256 reforacletxid, uint256 batontxid); int32_t GatewaysCointxidExists(struct CCcontract_info *cp, uint256 cointxid); -uint8_t DecodeGatewaysBindOpRet(char *depositaddr, const CScript &scriptPubKey, std::string &coin, uint256 &tokenid, int64_t &totalsupply, uint256 &oracletxid, uint8_t &M, uint8_t &N, std::vector &pubkeys, uint8_t &taddr, uint8_t &prefix, uint8_t &prefix2); +uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype); + +char *nonportable_path(char *str) +{ + int32_t i; + for (i=0; str[i]!=0; i++) + if ( str[i] == '/' ) + str[i] = '\\'; + return(str); +} + +char *portable_path(char *str) +{ +#ifdef _WIN32 + return(nonportable_path(str)); +#else +#ifdef __PNACL + /*int32_t i,n; + if ( str[0] == '/' ) + return(str); + else + { + n = (int32_t)strlen(str); + for (i=n; i>0; i--) + str[i] = str[i-1]; + str[0] = '/'; + str[n+1] = 0; + }*/ +#endif + return(str); +#endif +} + +void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) +{ + FILE *fp; + long filesize,buflen = *allocsizep; + uint8_t *buf = *bufp; + *lenp = 0; + if ( (fp= fopen(portable_path(fname),"rb")) != 0 ) + { + fseek(fp,0,SEEK_END); + filesize = ftell(fp); + if ( filesize == 0 ) + { + fclose(fp); + *lenp = 0; + //printf("loadfile null size.(%s)\n",fname); + return(0); + } + if ( filesize > buflen ) + { + *allocsizep = filesize; + *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); + } + rewind(fp); + if ( buf == 0 ) + printf("Null buf ???\n"); + else + { + if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) + printf("error reading filesize.%ld\n",(long)filesize); + buf[filesize] = 0; + } + fclose(fp); + *lenp = filesize; + //printf("loaded.(%s)\n",buf); + } //else printf("OS_loadfile couldnt load.(%s)\n",fname); + return(buf); +} + +void *filestr(long *allocsizep,char *_fname) +{ + long filesize = 0; char *fname,*buf = 0; void *retptr; + *allocsizep = 0; + fname = (char *)malloc(strlen(_fname)+1); + strcpy(fname,_fname); + retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); + free(fname); + return(retptr); +} // ac_import=chain support: // encode opret for gateways import +CScript EncodeImportTxOpRet(uint32_t targetCCid, std::string coin, std::vector publishers, std::vectortxids, int32_t height, uint256 cointxid, int32_t claimvout, std::string rawburntx, std::vectorproof, CPubKey destpub, int64_t amount) +{ + CScript opret; + opret << OP_RETURN << E_MARSHAL(ss << targetCCid << coin << publishers << txids << height << cointxid << claimvout << rawburntx << proof << destpub << amount); + return(opret); +} + CScript EncodeGatewaysImportTxOpRet(uint32_t targetCCid, std::string coin, uint256 bindtxid, std::vector publishers, std::vectortxids, int32_t height, uint256 cointxid, int32_t claimvout, std::string rawburntx, std::vectorproof, CPubKey destpub, int64_t amount) { CScript opret; @@ -52,169 +130,132 @@ CScript EncodeGatewaysImportTxOpRet(uint32_t targetCCid, std::string coin, uint2 return(opret); } -bool ImportCoinGatewaysVerify(char *refdepositaddr, uint256 oracletxid, int32_t claimvout, std::string refcoin, uint256 burntxid, const std::string rawburntx, std::vectorproof, uint256 merkleroot) +CScript EncodeCodaImportTxOpRet(uint32_t targetCCid, std::string coin, std::string burntx, uint256 bindtxid, CPubKey destpub, int64_t amount) +{ + CScript opret; + opret << OP_RETURN << E_MARSHAL(ss << targetCCid << burntx << bindtxid << destpub << amount); + return(opret); +} + +cJSON* CodaRPC(char **retstr,char const *arg0,char const *arg1,char const *arg2,char const *arg3,char const *arg4,char const *arg5) +{ + char cmdstr[5000],fname[256],*jsonstr; + long fsize; + cJSON *retjson=NULL; + + sprintf(fname,"/tmp/coda.%s",arg0); + sprintf(cmdstr,"coda.exe client %s %s %s %s %s %s > %s 2>&1",arg0,arg1,arg2,arg3,arg4,arg5,fname); + *retstr = 0; + if (system(cmdstr)<0) return (retjson); + if ( (jsonstr=(char *)filestr(&fsize,fname)) != 0 ) + { + jsonstr[strlen(jsonstr)-1]='\0'; + if ( (strncmp(jsonstr,"Merkle List of transactions:",28)!=0) || (retjson= cJSON_Parse(jsonstr+29)) == 0) + *retstr=jsonstr; + else free(jsonstr); + } + return(retjson); +} + +bool ImportCoinGatewaysVerify(CTransaction oracletx, int32_t claimvout, std::string refcoin, uint256 burntxid, const std::string rawburntx, std::vectorproof, uint256 merkleroot) { std::vector txids; - uint256 proofroot, hashBlock, foundtxid = zeroid; - CTransaction oracletx, burntx; + uint256 proofroot; std::string name, description, format; - char destaddr[64], destpubaddr[64], claimaddr[64]; int32_t i, numvouts; - int64_t nValue = 0; - if (myGetTransaction(oracletxid, oracletx, hashBlock) == 0 || (numvouts = oracletx.vout.size()) <= 0) - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify can't find oracletxid=" << oracletxid.GetHex() << std::endl); - return false; - } if (DecodeOraclesCreateOpRet(oracletx.vout[numvouts - 1].scriptPubKey, name, description, format) != 'C' || name != refcoin) { LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify mismatched oracle name=" << name.c_str() << " != " << refcoin.c_str() << std::endl); return false; } - proofroot = BitcoinGetProofMerkleRoot(proof, txids); - if (proofroot != merkleroot) - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify mismatched proof merkleroot=" << proofroot.GetHex() << " and oracles merkleroot=" << merkleroot.GetHex() << std::endl); - return false; - } - - // check the burntxid is in the proof: - if (std::find(txids.begin(), txids.end(), burntxid) == txids.end()) { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "ImportCoinGatewaysVerify invalid proof for this burntxid=" << burntxid.GetHex() << std::endl); - return false; - } - - /* - if (DecodeHexTx(burntx, rawburntx) != 0) - { - Getscriptaddress(claimaddr, burntx.vout[claimvout].scriptPubKey); - Getscriptaddress(destpubaddr, CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG); - if (strcmp(claimaddr, destpubaddr) == 0) - { - for (i = 0; iproof, std::string rawburntx, int32_t ivout, uint256 burntxid) -{ - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction burntx, bindtx; - CPubKey mypk, gatewayspk; - uint256 oracletxid, merkleroot, mhash, hashBlock, tokenid, txid; - int64_t totalsupply; - int32_t i, m, n, numvouts; - uint8_t M, N, taddr, prefix, prefix2; - std::string coin; - struct CCcontract_info *cp, C; - std::vector pubkeys, publishers; - std::vectortxids; - char depositaddr[64], txidaddr[64]; +// std::string MakeGatewaysImportTx(uint64_t txfee, uint256 oracletxid, int32_t height, std::string refcoin, std::vector proof, std::string rawburntx, int32_t ivout, uint256 burntxid,std::string destaddr) +// { +// CMutableTransaction burntx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); +// CTransaction oracletx,regtx; CPubKey regpk; +// uint256 proofroot,txid,tmporacletxid,merkleroot,mhash,hashBlock; int32_t i,m,n=0,numvouts; +// std::string name,desc,format; std::vector vouts; +// std::vector pubkeys; std::vectortxids; +// char markeraddr[64]; int64_t datafee; +// std::vector > unspentOutputs; - cp = CCinit(&C, EVAL_GATEWAYS); - /*if (txfee == 0) - txfee = 10000; - mypk = pubkey2pk(Mypubkey()); - gatewayspk = GetUnspendable(cp, 0); */ - - if (!E_UNMARSHAL(ParseHex(rawburntx), ss >> burntx)) - return std::string(""); - - CAmount amount = GetCoinImportValue(burntx); // equal to int64_t - - LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeGatewaysImportTx height=" << height << " coin=" << refcoin << " amount=" << (double)amount / COIN << " pubkeys num=" << pubkeys.size() << std::endl); - - if (GetTransaction(bindtxid, bindtx, hashBlock, false) == 0 || (numvouts = bindtx.vout.size()) <= 0) - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx cant find bindtxid=" << bindtxid.GetHex() << std::endl); - return(""); - } -/* if (DecodeGatewaysBindOpRet(depositaddr, bindtx.vout[numvouts - 1].scriptPubKey, coin, tokenid, totalsupply, oracletxid, M, N, pubkeys, taddr, prefix, prefix2) != 'B' || refcoin != coin) - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx invalid coin - bindtxid=" << bindtxid.GetHex() << " coin=" << coin.c_str() << std::endl); - return(""); - } eliminate link err */ - n = (int32_t)pubkeys.size(); - merkleroot = zeroid; - for (i = m = 0; i < n; i++) - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx using pubkeys[" << i << "]=" << HexStr(pubkeys[i]) << std::endl); - if ((mhash = GatewaysReverseScan(txid, height, oracletxid, OraclesBatontxid(oracletxid, pubkeys[i]))) != zeroid) - { - if (merkleroot == zeroid) - merkleroot = mhash, m = 1; - else if (mhash == merkleroot) - m ++; - publishers.push_back(pubkeys[i]); - txids.push_back(txid); - } - } - - LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeGatewaysImportTx burntxid=" << burntxid.GetHex() << " nodes m=" << m << " of n=" << n << std::endl); - if (merkleroot == zeroid || m < n / 2) // none or less than half oracle nodes sent merkleroot - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx couldnt find merkleroot for block height=" << height << "coin=" << coin.c_str() << " oracleid=" << oracletxid.GetHex() << " m=" << m << " vs n=" << n << std::endl ); - return(""); - } - if (GatewaysCointxidExists(cp, burntxid) != 0) - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx burntxid=" << burntxid.GetHex() << " already exists" << std::endl); - return(""); - } - if (!ImportCoinGatewaysVerify(depositaddr, oracletxid, ivout, coin, burntxid, rawburntx, proof, merkleroot)) - { - LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx could not validate burntx, txid=" << burntxid.GetHex() << std::endl); - return(""); - } - - - std::vector leaftxids; - BitcoinGetProofMerkleRoot(proof, leaftxids); - MerkleBranch newBranch(0, leaftxids); - TxProof txProof = std::make_pair(burntxid, newBranch); - - std::vector vouts; - - - - return HexStr(E_MARSHAL(ss << MakeImportCoinTransaction(txProof, burntx, vouts))); - - /*if (AddNormalinputs(mtx, mypk, 3 * txfee, 4) > 0) - { - mtx.vout.push_back(MakeCC1vout(cp->evalcode, txfee, destpub)); - mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(CCtxidaddr(txidaddr, burntxid))) << OP_CHECKSIG)); - return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeGatewaysImportTxOpRet(0xFFFFFFFF, coin, bindtxid, publishers, txids, height, burntxid, ivout, rawburntx, proof, destpub, amount))); - } - LOGSTREAM("importcoin", LEV_INFO, stream << "MakeGatewaysImportTx coud not find normal imputs" << std::endl);*/ - return(""); -} +// if (!E_UNMARSHAL(ParseHex(rawburntx), ss >> burntx)) +// return std::string(""); +// CAmount amount = GetCoinImportValue(burntx); // equal to int64_t +// LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeGatewaysImportTx height=" << height << " coin=" << refcoin << " amount=" << (double)amount / COIN << " pubkeys num=" << pubkeys.size() << std::endl); +// if (GetTransaction(oracletxid, oracletx, hashBlock, false) == 0 || (numvouts = oracletx.vout.size()) <= 0) +// { +// LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx cant find oracletxid=" << oracletxid.GetHex() << std::endl); +// return(""); +// } +// if (DecodeOraclesCreateOpRet(oracletx.vout[numvouts - 1].scriptPubKey,name,desc,format) != 'C') +// { +// LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx invalid oracle tx. oracletxid=" << oracletxid.GetHex() << std::endl); +// return(""); +// } +// if (name!=refcoin || format!="Ihh") +// { +// LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx invalid oracle name or format tx. oracletxid=" << oracletxid.GetHex() << " name=" << name << " format=" << format << std::endl); +// return(""); +// } +// CCtxidaddr(markeraddr,oracletxid); +// SetCCunspents(unspentOutputs,markeraddr); +// for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) +// { +// txid = it->first.txhash; +// if ( GetTransaction(txid,regtx,hashBlock,false) != 0 && regtx.vout.size() > 0 +// && DecodeOraclesOpRet(regtx.vout[regtx.vout.size()-1].scriptPubKey,tmporacletxid,regpk,datafee) == 'R' && oracletxid == tmporacletxid ) +// { +// pubkeys.push_back(regpk); +// n++; +// } +// } +// merkleroot = zeroid; +// for (i = m = 0; i < n; i++) +// { +// LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeGatewaysImportTx using pubkeys[" << i << "]=" << HexStr(pubkeys[i]) << std::endl); +// if ((mhash = CCOraclesReverseScan("importcoind-1",txid, height, oracletxid, OraclesBatontxid(oracletxid, pubkeys[i]))) != zeroid) +// { +// if (merkleroot == zeroid) +// merkleroot = mhash, m = 1; +// else if (mhash == merkleroot) +// m ++; +// txids.push_back(txid); +// } +// } +// LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeGatewaysImportTx burntxid=" << burntxid.GetHex() << " nodes m=" << m << " of n=" << n << std::endl); +// if (merkleroot == zeroid || m < n / 2) // none or less than half oracle nodes sent merkleroot +// { +// LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx couldnt find merkleroot for block height=" << height << "coin=" << refcoin.c_str() << " oracleid=" << oracletxid.GetHex() << " m=" << m << " vs n=" << n << std::endl ); +// return(""); +// } +// proofroot = BitcoinGetProofMerkleRoot(proof, txids); +// if (proofroot != merkleroot) +// { +// LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx mismatched proof merkleroot=" << proofroot.GetHex() << " and oracles merkleroot=" << merkleroot.GetHex() << std::endl); +// return(""); +// } +// // check the burntxid is in the proof: +// if (std::find(txids.begin(), txids.end(), burntxid) == txids.end()) { +// LOGSTREAM("importcoin", CCLOG_INFO, stream << "MakeGatewaysImportTx invalid proof for this burntxid=" << burntxid.GetHex() << std::endl); +// return(""); +// } +// burntx.vout.push_back(MakeBurnOutput(amount,0xffffffff,refcoin,vouts,proof,oracletxid,height)); +// std::vector leaftxids; +// BitcoinGetProofMerkleRoot(proof, leaftxids); +// MerkleBranch newBranch(0, leaftxids); +// TxProof txProof = std::make_pair(burntxid, newBranch); +// CTxDestination dest = DecodeDestination(destaddr.c_str()); +// CScript scriptPubKey = GetScriptForDestination(dest); +// vouts.push_back(CTxOut(amount,scriptPubKey)); +// return HexStr(E_MARSHAL(ss << MakeImportCoinTransaction(txProof, burntx, vouts))); +// } // makes source tx for self import tx std::string MakeSelfImportSourceTx(CTxDestination &dest, int64_t amount, CMutableTransaction &mtx) @@ -332,6 +373,90 @@ int32_t GetSelfimportProof(std::string source, CMutableTransaction &mtx, CScript return 0; } +// make import tx with burntx and dual daemon +std::string MakeCodaImportTx(uint64_t txfee, std::string receipt, std::string srcaddr, std::vector vouts) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()),burntx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; uint256 codaburntxid; std::vector dummyproof; + int32_t i,numvouts,n,m; std::string coin,error; struct CCcontract_info *cp, C; + cJSON *result,*tmp,*tmp1; unsigned char hash[SHA256_DIGEST_LENGTH+1]; + char out[SHA256_DIGEST_LENGTH*2+1],*retstr,*destaddr,*receiver; TxProof txProof; uint64_t amount; + + cp = CCinit(&C, EVAL_GATEWAYS); + if (txfee == 0) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + SHA256_CTX sha256; + SHA256_Init(&sha256); + SHA256_Update(&sha256, receipt.c_str(), receipt.size()); + SHA256_Final(hash, &sha256); + for(i = 0; i < SHA256_DIGEST_LENGTH; i++) + { + sprintf(out + (i * 2), "%02x", hash[i]); + } + out[65]='\0'; + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeCodaImportTx: hash=" << out << std::endl); + codaburntxid.SetHex(out); + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeCodaImportTx: receipt=" << receipt << " codaburntxid=" << codaburntxid.GetHex().data() << " amount=" << (double)amount / COIN << std::endl); + result=CodaRPC(&retstr,"prove-payment","-address",srcaddr.c_str(),"-receipt-chain-hash",receipt.c_str(),""); + if (result==0) + { + if (retstr!=0) + { + CCerror=std::string("CodaRPC: ")+retstr; + free(retstr); + } + return(""); + } + else + { + if ((tmp=jobj(jitem(jarray(&n,result,(char *)"payments"),0),(char *)"payload"))!=0 && (destaddr=jstr(jobj(tmp,(char *)"common"),(char *)"memo"))!=0 && + (receiver=jstr(jitem(jarray(&m,tmp,(char *)"body"),1),(char *)"receiver"))!=0 && (amount=j64bits(jitem(jarray(&m,tmp,(char *)"body"),1),(char *)"amount"))!=0) + { + LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "MakeCodaImportTx: receiver=" << receiver << " destaddr=" << destaddr << " amount=" << amount << std::endl); + if (strcmp(receiver,CODA_BURN_ADDRESS)!=0) + { + CCerror="MakeCodaImportTx: invalid burn address, coins do not go to predefined burn address - "; + CCerror+=CODA_BURN_ADDRESS; + LOGSTREAM("importcoin", CCLOG_INFO, stream << CCerror << std::endl); + free(result); + return(""); + } + CTxDestination dest = DecodeDestination(destaddr); + CScript scriptPubKey = GetScriptForDestination(dest); + if (vouts[0]!=CTxOut(amount*COIN,scriptPubKey)) + { + CCerror="MakeCodaImportTx: invalid destination address, burnTx memo!=importTx destination"; + LOGSTREAM("importcoin", CCLOG_INFO, stream << CCerror << std::endl); + free(result); + return(""); + } + if (amount*COIN!=vouts[0].nValue) + { + CCerror="MakeCodaImportTx: invalid amount, burnTx amount!=importTx amount"; + LOGSTREAM("importcoin", CCLOG_INFO, stream << CCerror << std::endl); + free(result); + return(""); + } + burntx.vin.push_back(CTxIn(codaburntxid,0,CScript())); + burntx.vout.push_back(MakeBurnOutput(amount*COIN,0xffffffff,"CODA",vouts,dummyproof,srcaddr,receipt)); + return HexStr(E_MARSHAL(ss << MakeImportCoinTransaction(txProof,burntx,vouts))); + } + else + { + CCerror="MakeCodaImportTx: invalid Coda burn tx"; + LOGSTREAM("importcoin", CCLOG_INFO, stream << CCerror << std::endl); + free(result); + return(""); + } + + } + CCerror="MakeCodaImportTx: error fetching Coda tx"; + LOGSTREAM("importcoin", CCLOG_INFO, stream << CCerror << std::endl); + free(result); + return(""); +} + // use proof from the above functions to validate the import int32_t CheckBEAMimport(TxProof proof,std::vector rawproof,CTransaction burnTx,std::vector payouts) @@ -340,17 +465,135 @@ int32_t CheckBEAMimport(TxProof proof,std::vector rawproof,CTransaction return(-1); } -int32_t CheckCODAimport(TxProof proof,std::vector rawproof,CTransaction burnTx,std::vector payouts) +int32_t CheckCODAimport(CTransaction importTx,CTransaction burnTx,std::vector payouts,std::string srcaddr,std::string receipt) { + cJSON *result,*tmp,*tmp1; char *retstr,out[SHA256_DIGEST_LENGTH*2+1]; unsigned char hash[SHA256_DIGEST_LENGTH+1]; int i,n,m; + SHA256_CTX sha256; uint256 codaburntxid; char *destaddr,*receiver; uint64_t amount; + // check with dual-CODA daemon via ASSETCHAINS_CODAPORT for validity of burnTx - return(-1); + SHA256_Init(&sha256); + SHA256_Update(&sha256, receipt.c_str(), receipt.size()); + SHA256_Final(hash, &sha256); + for(i = 0; i < SHA256_DIGEST_LENGTH; i++) + { + sprintf(out + (i * 2), "%02x", hash[i]); + } + out[65]='\0'; + codaburntxid.SetHex(out); + result=CodaRPC(&retstr,"prove-payment","-address",srcaddr.c_str(),"-receipt-chain-hash",receipt.c_str(),""); + if (result==0) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "CodaRPC error: " << retstr << std::endl); + free(retstr); + return (-1); + } + else + { + if ((tmp=jobj(jitem(jarray(&n,result,(char *)"payments"),0),(char *)"payload"))==0 || (destaddr=jstr(jobj(tmp,(char *)"common"),(char *)"memo"))==0 || + (receiver=jstr(jitem(jarray(&m,tmp,(char *)"body"),1),(char *)"receiver"))==0 || (amount=j64bits(jitem(jarray(&m,tmp,(char *)"body"),1),(char *)"amount"))==0) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "Invalid Coda burn tx" << jprint(result,1) << std::endl); + free(result); + return (-1); + } + CTxDestination dest = DecodeDestination(destaddr); + CScript scriptPubKey = GetScriptForDestination(dest); + if (payouts[0]!=CTxOut(amount*COIN,scriptPubKey)); + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "Destination address in burn tx does not match destination in import tx" << std::endl); + free(result); + return (-1); + } + if (strcmp(receiver,CODA_BURN_ADDRESS)!=0) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "Invalid burn address " << jstr(tmp1,(char *)"receiver") << std::endl); + free(result); + return (-1); + } + if (amount*COIN!=payouts[0].nValue) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "Burn amount and import amount not matching, " << j64bits(tmp,(char *)"amount") << " - " << payouts[0].nValue/COIN << std::endl); + free(result); + return (-1); + } + if (burnTx.vin[0].prevout.hash!=codaburntxid || importTx.vin[0].prevout.hash!=burnTx.GetHash()) + { + LOGSTREAM("importcoin", CCLOG_INFO, stream << "Invalid import/burn tx vin" << std::endl); + free(result); + return (-1); + } + free(result); + } + return(0); } -int32_t CheckGATEWAYimport(TxProof proof,std::vector rawproof,CTransaction burnTx,std::vector payouts) +int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string refcoin,std::vector proof, + uint256 bindtxid,std::vector publishers,std::vector txids,int32_t height,int32_t burnvout,std::string rawburntx,CPubKey destpub) { + // CTransaction oracletx,regtx; CPubKey regpk; + // uint256 proofroot,txid,tmporacletxid,merkleroot,mhash,hashBlock; int32_t i,m,n=0,numvouts; + // std::string name,desc,format; std::vector vouts; + // std::vector pubkeys; std::vectortxids; + // char markeraddr[64]; int64_t datafee; + // std::vector > unspentOutputs; // ASSETCHAINS_SELFIMPORT is coin // check for valid burn from external coin blockchain and if valid return(0); - return(-1); + // if (GetTransaction(oracletxid, oracletx, hashBlock, false) == 0 || (numvouts = oracletx.vout.size()) <= 0) + // { + // LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckGATEWAYimport cant find oracletxid=" << oracletxid.GetHex() << std::endl); + // return(-1); + // } + // if (DecodeOraclesCreateOpRet(oracletx.vout[numvouts - 1].scriptPubKey,name,desc,format) != 'C') + // { + // LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckGATEWAYimport invalid oracle tx. oracletxid=" << oracletxid.GetHex() << std::endl); + // return(-1); + // } + // if (name!=refcoin || format!="Ihh") + // { + // LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckGATEWAYimport invalid oracle name or format tx. oracletxid=" << oracletxid.GetHex() << " name=" << name << " format=" << format << std::endl); + // return(-1); + // } + // CCtxidaddr(markeraddr,oracletxid); + // SetCCunspents(unspentOutputs,markeraddr); + // for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + // { + // txid = it->first.txhash; + // if ( GetTransaction(txid,regtx,hashBlock,false) != 0 && regtx.vout.size() > 0 + // && DecodeOraclesOpRet(regtx.vout[regtx.vout.size()-1].scriptPubKey,tmporacletxid,regpk,datafee) == 'R' && oracletxid == tmporacletxid ) + // { + // pubkeys.push_back(regpk); + // n++; + // } + // } + // merkleroot = zeroid; + // for (i = m = 0; i < n; i++) + // { + // if ((mhash = CCOraclesReverseScan("importcoind-1",txid, height, oracletxid, OraclesBatontxid(oracletxid, pubkeys[i]))) != zeroid) + // { + // if (merkleroot == zeroid) + // merkleroot = mhash, m = 1; + // else if (mhash == merkleroot) + // m ++; + // txids.push_back(txid); + // } + // } + // if (merkleroot == zeroid || m < n / 2) // none or less than half oracle nodes sent merkleroot + // { + // LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckGATEWAYimport couldnt find merkleroot for block height=" << height << "coin=" << refcoin.c_str() << " oracleid=" << oracletxid.GetHex() << " m=" << m << " vs n=" << n << std::endl ); + // return(-1); + // } + // proofroot = BitcoinGetProofMerkleRoot(proof, txids); + // if (proofroot != merkleroot) + // { + // LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckGATEWAYimport mismatched proof merkleroot=" << proofroot.GetHex() << " and oracles merkleroot=" << merkleroot.GetHex() << std::endl); + // return(-1); + // } + // // check the burntxid is in the proof: + // if (std::find(txids.begin(), txids.end(), burnTx.GetHash()) == txids.end()) { + // LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckGATEWAYimport invalid proof for this burntxid=" << burnTx.GetHash().GetHex() << std::endl); + // return(-1); + // } + return(0); } int32_t CheckPUBKEYimport(TxProof proof,std::vector rawproof,CTransaction burnTx,std::vector payouts) @@ -404,10 +647,20 @@ int32_t CheckPUBKEYimport(TxProof proof,std::vector rawproof,CTransacti return(0); } +/* + * CC Eval method for import coin. + * + * This method should control every parameter of the ImportCoin transaction, since it has no signature + * to protect it from malleability. + + ##### 0xffffffff is a special CCid for single chain/dual daemon imports + */ bool Eval::ImportCoin(const std::vector params,const CTransaction &importTx,unsigned int nIn) { - TxProof proof; CTransaction burnTx; std::vector payouts; uint64_t txfee = 10000; - uint32_t targetCcid; std::string targetSymbol; uint256 payoutsHash; std::vector rawproof; + TxProof proof; CTransaction burnTx; std::vector payouts; uint64_t txfee = 10000; int32_t height,burnvout; std::vector publishers; + uint32_t targetCcid; std::string targetSymbol,srcaddr,destaddr,receipt,rawburntx; uint256 payoutsHash,bindtxid; std::vector rawproof; + std::vector txids; CPubKey destpub; + if ( importTx.vout.size() < 2 ) return Invalid("too-few-vouts"); // params @@ -458,7 +711,7 @@ bool Eval::ImportCoin(const std::vector params,const CTransaction &impo { if ( ASSETCHAINS_CODAPORT == 0 ) return Invalid("CODA-import-without-port"); - else if ( CheckCODAimport(proof,rawproof,burnTx,payouts) < 0 ) + else if ( UnmarshalBurnTx(burnTx,srcaddr,receipt)==0 || CheckCODAimport(importTx,burnTx,payouts,srcaddr,receipt) < 0 ) return Invalid("CODA-import-failure"); } else if ( targetSymbol == "PUBKEY" ) @@ -472,7 +725,7 @@ bool Eval::ImportCoin(const std::vector params,const CTransaction &impo { if ( targetSymbol != ASSETCHAINS_SELFIMPORT ) return Invalid("invalid-gateway-import-coin"); - else if ( CheckGATEWAYimport(proof,rawproof,burnTx,payouts) < 0 ) + else if ( UnmarshalBurnTx(burnTx,bindtxid,publishers,txids,height,burnvout,rawburntx,destpub)==0 || CheckGATEWAYimport(importTx,burnTx,targetSymbol,rawproof,bindtxid,publishers,txids,height,burnvout,rawburntx,destpub) < 0 ) return Invalid("GATEWAY-import-failure"); } } diff --git a/src/cc/importgateway.cpp b/src/cc/importgateway.cpp new file mode 100644 index 000000000..4e943b472 --- /dev/null +++ b/src/cc/importgateway.cpp @@ -0,0 +1,1292 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include "CCImportGateway.h" +#include "key_io.h" +#include "../importcoin.h" + +// start of consensus code + +#define KMD_PUBTYPE 60 +#define KMD_P2SHTYPE 85 +#define KMD_WIFTYPE 188 +#define KMD_TADDR 0 +#define CC_MARKER_VALUE 10000 + +CScript EncodeImportGatewayBindOpRet(uint8_t funcid,std::string coin,uint256 oracletxid,uint8_t M,uint8_t N,std::vector importgatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype) +{ + CScript opret; uint8_t evalcode = EVAL_IMPORTGATEWAY; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << oracletxid << M << N << importgatewaypubkeys << taddr << prefix << prefix2 << wiftype); + return(opret); +} + +uint8_t DecodeImportGatewayBindOpRet(char *burnaddr,const CScript &scriptPubKey,std::string &coin,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &importgatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype) +{ + std::vector vopret; uint8_t *script,e,f; std::vector pubkeys; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + burnaddr[0] = 0; + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> oracletxid; ss >> M; ss >> N; ss >> importgatewaypubkeys; ss >> taddr; ss >> prefix; ss >> prefix2; ss >> wiftype) != 0 ) + { + if ( prefix == KMD_PUBTYPE && prefix2 == KMD_P2SHTYPE ) + { + if ( N > 1 ) + { + strcpy(burnaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,importgatewaypubkeys))).ToString().c_str()); + LOGSTREAM("importgateway", CCLOG_DEBUG1, stream << "f." << f << " M." << (int)M << " of N." << (int)N << " size." << (int32_t)importgatewaypubkeys.size() << " -> " << burnaddr << std::endl); + } else Getscriptaddress(burnaddr,CScript() << ParseHex(HexStr(importgatewaypubkeys[0])) << OP_CHECKSIG); + } + else + { + if ( N > 1 ) strcpy(burnaddr,CCustomBitcoinAddress(CScriptID(GetScriptForMultisig(M,importgatewaypubkeys)),taddr,prefix,prefix2).ToString().c_str()); + else GetCustomscriptaddress(burnaddr,CScript() << ParseHex(HexStr(importgatewaypubkeys[0])) << OP_CHECKSIG,taddr,prefix,prefix2); + } + return(f); + } else LOGSTREAM("importgateway",CCLOG_DEBUG1, stream << "error decoding bind opret" << std::endl); + return(0); +} + +CScript EncodeImportGatewayDepositOpRet(uint8_t funcid,uint256 bindtxid,std::string refcoin,std::vector publishers,std::vectortxids,int32_t height,uint256 burntxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount) +{ + CScript opret; uint8_t evalcode = EVAL_IMPORTGATEWAY; + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << refcoin << bindtxid << publishers << txids << height << burntxid << claimvout << deposithex << proof << destpub << amount); + return(opret); +} + +uint8_t DecodeImportGatewayDepositOpRet(const CScript &scriptPubKey,uint256 &bindtxid,std::string &refcoin,std::vector&publishers,std::vector&txids,int32_t &height,uint256 &burntxid, int32_t &claimvout,std::string &deposithex,std::vector &proof,CPubKey &destpub,int64_t &amount) +{ + std::vector vopret; uint8_t *script,e,f; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> refcoin; ss >> bindtxid; ss >> publishers; ss >> txids; ss >> height; ss >> burntxid; ss >> claimvout; ss >> deposithex; ss >> proof; ss >> destpub; ss >> amount) != 0 ) + { + return(f); + } + return(0); +} + +CScript EncodeImportGatewayWithdrawOpRet(uint8_t funcid,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount) +{ + CScript opret; uint8_t evalcode = EVAL_IMPORTGATEWAY; + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << bindtxid << refcoin << withdrawpub << amount); + return(opret); +} + +uint8_t DecodeImportGatewayWithdrawOpRet(const CScript &scriptPubKey,uint256 &bindtxid,std::string &refcoin,CPubKey &withdrawpub,int64_t &amount) +{ + std::vector vopret; uint8_t *script,e,f; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret, ss >> e; ss >> f; ss >> bindtxid; ss >> refcoin; ss >> withdrawpub; ss >> amount) != 0 ) + { + return(f); + } + return(0); +} + +CScript EncodeImportGatewayPartialOpRet(uint8_t funcid, uint256 withdrawtxid,std::string refcoin,uint8_t K, CPubKey signerpk,std::string hex) +{ + CScript opret; uint8_t evalcode = EVAL_IMPORTGATEWAY; + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << K << signerpk << hex); + return(opret); +} + +uint8_t DecodeImportGatewayPartialOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,uint8_t &K,CPubKey &signerpk,std::string &hex) +{ + std::vector vopret; uint8_t *script,e,f; + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> K; ss >> signerpk; ss >> hex) != 0 ) + { + return(f); + } + return(0); +} + +CScript EncodeImportGatewayCompleteSigningOpRet(uint8_t funcid,uint256 withdrawtxid,std::string refcoin,uint8_t K,std::string hex) +{ + CScript opret; uint8_t evalcode = EVAL_IMPORTGATEWAY; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << K << hex); + return(opret); +} + +uint8_t DecodeImportGatewayCompleteSigningOpRet(const CScript &scriptPubKey,uint256 &withdrawtxid,std::string &refcoin,uint8_t &K,std::string &hex) +{ + std::vector vopret; uint8_t *script,e,f; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> K; ss >> hex) != 0 ) + { + return(f); + } + return(0); +} + +CScript EncodeImportGatewayMarkDoneOpRet(uint8_t funcid,uint256 withdrawtxid,std::string refcoin,uint256 completetxid) +{ + CScript opret; uint8_t evalcode = EVAL_IMPORTGATEWAY; + + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << withdrawtxid << refcoin << completetxid); + return(opret); +} + +uint8_t DecodeImportGatewayMarkDoneOpRet(const CScript &scriptPubKey, uint256 &withdrawtxid, std::string &refcoin, uint256 &completetxid) +{ + std::vector vopret; uint8_t *script,e,f; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> withdrawtxid; ss >> refcoin; ss >> completetxid;) != 0 ) + { + return(f); + } + return(0); +} + +uint8_t DecodeImportGatewayOpRet(const CScript &scriptPubKey) +{ + std::vector vopret; uint8_t *script,e,f; + + GetOpReturnData(scriptPubKey, vopret); + script = (uint8_t *)vopret.data(); + if ( vopret.size() > 2 && script[0] == EVAL_IMPORTGATEWAY) + { + f=script[1]; + if (f == 'B' || f == 'D' || f == 'C' || f == 'W' || f == 'P' || f == 'S' || f == 'M') + return(f); + } + return(0); +} + +int64_t IsImportGatewayvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +{ + char destaddr[64]; + + if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) + { + if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) + return(tx.vout[v].nValue); + } + return(0); +} + +int64_t ImportGatewayVerify(char *refburnaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 burntxid,const std::string deposithex,std::vectorproof,uint256 merkleroot,CPubKey destpub,uint8_t taddr,uint8_t prefix,uint8_t prefix2) +{ + std::vector txids; uint256 proofroot,hashBlock,txid = zeroid; CTransaction tx; std::string name,description,format; + char destaddr[64],destpubaddr[64],claimaddr[64]; int32_t i,numvouts; int64_t nValue = 0; + + if ( myGetTransaction(oracletxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + LOGSTREAM("importgateway",CCLOG_INFO, stream << "ImportGatewayVerify cant find oracletxid " << oracletxid.GetHex() << std::endl); + return(0); + } + if ( DecodeOraclesCreateOpRet(tx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' || name != refcoin ) + { + LOGSTREAM("importgateway",CCLOG_INFO, stream << "ImportGatewayVerify mismatched oracle name " << name << " != " << refcoin << std::endl); + return(0); + } + proofroot = BitcoinGetProofMerkleRoot(proof,txids); + if ( proofroot != merkleroot ) + { + LOGSTREAM("importgateway",CCLOG_INFO, stream << "ImportGatewayVerify mismatched merkleroot " << proofroot.GetHex() << " != " << merkleroot.GetHex() << std::endl); + return(0); + } + if (std::find(txids.begin(), txids.end(), burntxid) == txids.end()) + { + LOGSTREAM("importgateway",CCLOG_INFO, stream << "ImportGatewayVerify invalid proof for this burntxid" << std::endl); + return 0; + } + if ( DecodeHexTx(tx,deposithex) != 0 ) + { + GetCustomscriptaddress(claimaddr,tx.vout[claimvout].scriptPubKey,taddr,prefix,prefix2); + GetCustomscriptaddress(destpubaddr,CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG,taddr,prefix,prefix2); + if ( strcmp(claimaddr,destpubaddr) == 0 ) + { + for (i=0; i publishers; std::vectortxids; uint256 bindtxid,burntxid; std::vector proof; CPubKey claimpubkey; + if ( (numvouts= tx.vout.size()) > 0 ) + { + if ( DecodeImportGatewayDepositOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,publishers,txids,height,burntxid,claimvout,deposithex,proof,claimpubkey,amount) == 'D' && claimpubkey == mypk ) + { + return(amount); + } + } + return(0); +} + +int32_t ImportGatewayBindExists(struct CCcontract_info *cp,CPubKey importgatewaypk,std::string refcoin) +{ + char markeraddr[64],burnaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; + uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; CTransaction tx; + std::vector > addressIndex; + + _GetCCaddress(markeraddr,EVAL_IMPORTGATEWAY,importgatewaypk); + SetCCtxids(addressIndex,markeraddr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) + { + if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' ) + { + if ( coin == refcoin ) + { + LOGSTREAM("importgateway",CCLOG_INFO, stream << "trying to bind an existing import for coin" << std::endl); + return(1); + } + } + } + } + BOOST_FOREACH(const CTxMemPoolEntry &e, mempool.mapTx) + { + const CTransaction &txmempool = e.GetTx(); + const uint256 &hash = txmempool.GetHash(); + + if ((numvouts=txmempool.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B') + if (DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B') + return(1); + } + + return(0); +} + +bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn) +{ + int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks,height,claimvout; bool retval; uint8_t funcid,hash[32],K,M,N,taddr,prefix,prefix2,wiftype; + char str[65],destaddr[65],burnaddr[65],importgatewayaddr[65],validationError[512]; + std::vector txids; std::vector pubkeys,publishers,tmppublishers; std::vector proof; int64_t amount,tmpamount; + uint256 hashblock,txid,bindtxid,deposittxid,withdrawtxid,completetxid,tmptokenid,oracletxid,bindtokenid,burntxid,tmptxid,merkleroot,mhash; CTransaction bindtx,tmptx; + std::string refcoin,tmprefcoin,hex,name,description,format; CPubKey pubkey,tmppubkey,importgatewaypk; + + return (true); + numvins = tx.vin.size(); + numvouts = tx.vout.size(); + preventCCvins = preventCCvouts = -1; + if ( numvouts < 1 ) + return eval->Invalid("no vouts"); + else + { + //LogPrint("importgateway-1","check amounts\n"); + // if ( ImportGatewayExactAmounts(cp,eval,tx,1,10000) == false ) + // { + // return eval->Invalid("invalid inputs vs. outputs!"); + // } + // else + // { + importgatewaypk = GetUnspendable(cp,0); + GetCCaddress(cp, importgatewayaddr, importgatewaypk); + if ( (funcid = DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)) != 0) + { + switch ( funcid ) + { + case 'B': + //vin.0: normal input + //vout.0: CC vout marker + //vout.n-1: opreturn - 'B' coin oracletxid M N pubkeys taddr prefix prefix2 wiftype + return eval->Invalid("unexpected ImportGatewayValidate for gatewaysbind!"); + break; + case 'W': + //vin.0: normal input + //vin.1: CC input of tokens + //vout.0: CC vout marker to gateways CC address + //vout.1: CC vout of gateways tokens back to gateways tokens CC address + //vout.2: CC vout change of tokens back to owners pubkey (if any) + //vout.n-1: opreturn - 'W' bindtxid refcoin withdrawpub amount + return eval->Invalid("unexpected ImportGatewayValidate for gatewaysWithdraw!"); + break; + case 'P': + //vin.0: normal input + //vin.1: CC input of marker from previous tx (withdraw or partialsing) + //vout.0: CC vout marker to gateways CC address + //vout.n-1: opreturn - 'P' withdrawtxid refcoin number_of_signs mypk hex + if ((numvouts=tx.vout.size()) > 0 && DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,K,pubkey,hex)!='P') + return eval->Invalid("invalid gatewaysPartialSign OP_RETURN data!"); + else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid withdraw txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeImportGatewayWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,bindtxid,tmprefcoin,pubkey,amount)!='W') + return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); + else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE)==0) + return eval->Invalid("invalid marker vout for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[1],1,importgatewayaddr,amount)==0) + return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); + else if (tmptx.vout[1].nValue!=amount) + return eval->Invalid("amount in opret not matching tx tokens amount!"); + else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysbind txid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeImportGatewayBindOpRet(burnaddr,tmptx.vout[numvouts-1].scriptPubKey,tmprefcoin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') + return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (komodo_txnotarizedconfirmed(bindtxid) == false) + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (IsCCInput(tx.vin[0].scriptSig) != 0) + return eval->Invalid("vin.0 is normal for gatewayspartialsign!"); + else if ((*cp->ismyvin)(tx.vin[1].scriptSig) == 0 || myGetTransaction(tx.vin[1].prevout.hash,tmptx,hashblock)==0 || tmptx.vout[tx.vin[1].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.1 is CC marker for gatewayspartialsign or invalid marker amount!"); + else if (ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE) == 0 ) + return eval->Invalid("vout.0 invalid marker for gatewayspartialsign!"); + else if (K>M) + return eval->Invalid("invalid number of signs!"); + break; + case 'S': + //vin.0: normal input + //vin.1: CC input of marker from previous tx (withdraw or partialsing) + //vout.0: CC vout marker to gateways CC address + //vout.n-1: opreturn - 'S' withdrawtxid refcoin hex + if ((numvouts=tx.vout.size()) > 0 && DecodeImportGatewayCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,K,hex)!='S') + return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); + else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid withdraw txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeImportGatewayWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,bindtxid,tmprefcoin,pubkey,amount)!='W') + return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if ( IsCCInput(tmptx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysWithdraw!"); + else if ( IsCCInput(tmptx.vin[1].scriptSig) == 0 ) + return eval->Invalid("vin.1 is CC for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE)==0) + return eval->Invalid("invalid marker vout for gatewaysWithdraw!"); + else if ( ConstrainVout(tmptx.vout[1],1,importgatewayaddr,amount)==0) + return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); + else if (tmptx.vout[1].nValue!=amount) + return eval->Invalid("amount in opret not matching tx tokens amount!"); + else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysbind txid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeImportGatewayBindOpRet(burnaddr,tmptx.vout[numvouts-1].scriptPubKey,tmprefcoin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') + return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (komodo_txnotarizedconfirmed(bindtxid) == false) + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if (IsCCInput(tx.vin[0].scriptSig) != 0) + return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); + else if ((*cp->ismyvin)(tx.vin[1].scriptSig) == 0 || myGetTransaction(tx.vin[1].prevout.hash,tmptx,hashblock)==0 || tmptx.vout[tx.vin[1].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.1 is CC marker for gatewayscompletesigning or invalid marker amount!"); + else if (ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,CC_MARKER_VALUE) == 0 ) + return eval->Invalid("vout.0 invalid marker for gatewayscompletesigning!"); + else if (KInvalid("invalid number of signs!"); + break; + case 'M': + //vin.0: normal input + //vin.1: CC input of gatewayscompletesigning tx marker to gateways CC address + //vout.0: opreturn - 'M' withdrawtxid refcoin completetxid + if ((numvouts=tx.vout.size()) > 0 && DecodeImportGatewayMarkDoneOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,refcoin,completetxid)!='M') + return eval->Invalid("invalid gatewaysmarkdone OP_RETURN data!"); + else if (myGetTransaction(completetxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewayscompletesigning txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeImportGatewayCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S') + return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); + else if (komodo_txnotarizedconfirmed(completetxid) == false) + return eval->Invalid("gatewayscompletesigning tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid withdraw txid!"); + else if ((numvouts=tmptx.vout.size()) > 0 && DecodeImportGatewayWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,bindtxid,tmprefcoin,pubkey,amount)!='W') + return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); + else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) + return eval->Invalid("invalid gatewaysbind txid!"); + else if ((numvouts=tmptx.vout.size()) < 1 || DecodeImportGatewayBindOpRet(burnaddr,tmptx.vout[numvouts-1].scriptPubKey,tmprefcoin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B') + return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); + else if (tmprefcoin!=refcoin) + return eval->Invalid("refcoin different than in bind tx"); + else if (komodo_txnotarizedconfirmed(bindtxid) == false) + return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); + else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) + return eval->Invalid("vin.0 is normal for gatewaysmarkdone!"); + else if ((*cp->ismyvin)(tx.vin[1].scriptSig) == 0 || myGetTransaction(tx.vin[1].prevout.hash,tmptx,hashblock)==0 || tmptx.vout[tx.vin[1].prevout.n].nValue!=CC_MARKER_VALUE) + return eval->Invalid("vin.1 is CC marker for gatewaysmarkdone or invalid marker amount!"); + else if (KInvalid("invalid number of signs!"); + break; + } + } + retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); + if ( retval != 0 ) + LOGSTREAM("importgateway",CCLOG_INFO, stream << "ImportGateway tx validated" << std::endl); + else fprintf(stderr,"ImportGateway tx invalid\n"); + return(retval); + // } + } +} +// end of consensus code + +// helper functions for rpc calls in rpcwallet.cpp + +std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys,uint8_t p1,uint8_t p2,uint8_t p3,uint8_t p4) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction oracletx; uint8_t taddr,prefix,prefix2,wiftype; CPubKey mypk,importgatewaypk; CScript opret; uint256 hashBlock; + struct CCcontract_info *cp,*cpTokens,C,CTokens; std::string name,description,format; int32_t i,numvouts; + char destaddr[64],coinaddr[64],myTokenCCaddr[64],str[65],*fstr; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + cpTokens = CCinit(&CTokens,EVAL_TOKENS); + if (coin=="KMD") + { + prefix = KMD_PUBTYPE; + prefix2 = KMD_P2SHTYPE; + wiftype = KMD_WIFTYPE; + taddr = KMD_TADDR; + } + else + { + prefix = p1; + prefix2 = p2; + wiftype = p3; + taddr = p4; + LOGSTREAM("importgateway",CCLOG_DEBUG1, stream << "set prefix " << prefix << ", prefix2 " << prefix2 << ", wiftype " << wiftype << ", taddr " << taddr << " for " << coin << std::endl); + } + if ( N == 0 || N > 15 || M > N ) + { + CCerror = strprintf("illegal M.%d or N.%d",M,N); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( pubkeys.size() != N ) + { + CCerror = strprintf("M.%d N.%d but pubkeys[%d]",M,N,(int32_t)pubkeys.size()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + for (i=0; i 0 ) + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CC_MARKER_VALUE,importgatewaypk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeImportGatewayBindOpRet('B',coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype))); + } + CCerror = strprintf("cant find enough inputs"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); +} + +std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 burntxid,int32_t claimvout,std::string rawburntx,std::vectorproof,CPubKey destpub) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()), burntx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction bindtx; CPubKey mypk; uint256 oracletxid,merkleroot,mhash,hashBlock,txid; std::vector vouts; + int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::string coin; struct CCcontract_info *cp,C; + std::vector pubkeys,publishers; std::vector txids; char str[128],burnaddr[64]; int64_t amount; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + if (!E_UNMARSHAL(ParseHex(rawburntx), ss >> burntx)) + { + return std::string(""); + } + amount=burntx.vout[0].nValue; + LOGSTREAM("importgateway",CCLOG_DEBUG1, stream << "ImportGatewayDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl); + if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( DecodeImportGatewayBindOpRet(burnaddr,bindtx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) + { + CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if (komodo_txnotarizedconfirmed(bindtxid)==false) + { + CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + n = (int32_t)pubkeys.size(); + merkleroot = zeroid; + for (i=m=0; i leaftxids; + BitcoinGetProofMerkleRoot(proof, leaftxids); + MerkleBranch newBranch(0, leaftxids); + TxProof txProof = std::make_pair(burntxid, newBranch); + return HexStr(E_MARSHAL(ss << MakeImportCoinTransaction(txProof, burntx, vouts))); +} + +std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction tx; CPubKey mypk,importgatewaypk,signerpk; uint256 txid,hashBlock,oracletxid,tmptokenid,tmpbindtxid,withdrawtxid; int32_t vout,numvouts; + int64_t nValue,inputs,CCchange=0,tmpamount; uint8_t funcid,K,M,N,taddr,prefix,prefix2,wiftype; std::string coin,hex; + std::vector msigpubkeys; char burnaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C; + std::vector > unspentOutputs; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + importgatewaypk = GetUnspendable(cp, 0); + + if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || coin != refcoin ) + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if (komodo_txnotarizedconfirmed(bindtxid)==false) + { + CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + nValue = (int64_t)it->second.satoshis; + K=0; + if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P')) + { + if (funcid=='W' && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' + && refcoin==coin && tmpbindtxid==bindtxid) + { + CCerror = strprintf("unable to create withdraw, another withdraw pending"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + + else if (funcid=='P' && DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' && + GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' + && refcoin==coin && tmpbindtxid==bindtxid) + { + CCerror = strprintf("unable to create withdraw, another withdraw pending"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + } + } + if( AddNormalinputs(mtx, mypk, txfee+CC_MARKER_VALUE+amount, 64) > 0 ) + { + mtx.vout.push_back(MakeCC1vout(EVAL_IMPORTGATEWAY,CC_MARKER_VALUE,importgatewaypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_IMPORTGATEWAY,amount,importgatewaypk)); + return(FinalizeCCTx(0, cp, mtx, mypk, txfee,EncodeImportGatewayWithdrawOpRet('W',bindtxid,refcoin,withdrawpub,amount))); + } + CCerror = strprintf("cant find enough normal inputs"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); +} + +std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string refcoin, std::string hex) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,withdrawpub,signerpk,importgatewaypk; struct CCcontract_info *cp,C; CTransaction tx,tmptx; + std::vector > unspentOutputs; char funcid,str[65],burnaddr[64]; + int32_t numvouts; uint256 withdrawtxid,hashBlock,bindtxid,tokenid,oracletxid; std::string coin,tmphex; int64_t amount; + uint8_t K=0,M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + importgatewaypk = GetUnspendable(cp,0); + if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + || (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) + { + CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if (funcid=='W') + { + withdrawtxid=lasttxid; + if (DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + { + CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayBindOpRet(burnaddr,tmptx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' + || refcoin!=coin) + { + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + } + else if (funcid=='P') + { + if (DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) + { + CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) + { + CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount)!='W' + || refcoin!=coin) + { + CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayBindOpRet(burnaddr,tmptx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' + || refcoin!=coin) + { + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + } + if (AddNormalinputs(mtx,mypk,txfee,3)!=0) + { + mtx.vin.push_back(CTxIn(tx.GetHash(),0,CScript())); + mtx.vout.push_back(MakeCC1vout(EVAL_IMPORTGATEWAY,CC_MARKER_VALUE,importgatewaypk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeImportGatewayPartialOpRet('P',withdrawtxid,refcoin,K+1,mypk,hex))); + } + CCerror = strprintf("error adding funds for partialsign"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); +} + +std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string refcoin,std::string hex) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,importgatewaypk,signerpk,withdrawpub; struct CCcontract_info *cp,C; char funcid,str[65],burnaddr[64]; int64_t amount; + std::string coin,tmphex; CTransaction tx,tmptx; uint256 withdrawtxid,hashBlock,tokenid,bindtxid,oracletxid; int32_t numvouts; + uint8_t K=0,M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + mypk = pubkey2pk(Mypubkey()); + importgatewaypk = GetUnspendable(cp,0); + if ( txfee == 0 ) + txfee = 10000; + if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + || (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) + { + CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if (funcid=='W') + { + withdrawtxid=lasttxid; + if (DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + { + CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,lasttxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayBindOpRet(burnaddr,tmptx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' + || refcoin!=coin) + { + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + } + else if (funcid=='P') + { + if (DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin) + { + CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) + { + CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + { + CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,withdrawtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + { + CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayBindOpRet(burnaddr,tmptx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' + || refcoin!=coin) + { + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + } + if (AddNormalinputs(mtx,mypk,txfee,3)!=0) + { + mtx.vin.push_back(CTxIn(lasttxid,0,CScript())); + mtx.vout.push_back(MakeCC1vout(EVAL_IMPORTGATEWAY,CC_MARKER_VALUE,importgatewaypk)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeImportGatewayCompleteSigningOpRet('S',withdrawtxid,refcoin,K+1,hex))); + } + CCerror = strprintf("error adding funds for completesigning"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); +} + +std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; struct CCcontract_info *cp,C; char str[65],burnaddr[64]; CTransaction tx; int32_t numvouts; + uint256 withdrawtxid,bindtxid,oracletxid,tokenid,hashBlock; std::string coin,hex; + uint8_t K,M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; int64_t amount; CPubKey withdrawpub; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + mypk = pubkey2pk(Mypubkey()); + if ( txfee == 0 ) + txfee = 10000; + if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) + { + CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex)!='S' || refcoin!=coin) + { + CCerror = strprintf("cannot decode completesigning tx opret %s",uint256_str(str,completetxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if (komodo_txnotarizedconfirmed(completetxid)==false) + { + CCerror = strprintf("gatewayscompletesigning tx not yet confirmed/notarized"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) + { + CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) + { + CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + { + CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + else if (DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' + || refcoin!=coin) + { + CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if (AddNormalinputs(mtx,mypk,txfee,3)!=0) + { + mtx.vin.push_back(CTxIn(completetxid,0,CScript())); + mtx.vout.push_back(CTxOut(CC_MARKER_VALUE,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeImportGatewayMarkDoneOpRet('M',withdrawtxid,refcoin,completetxid))); + } + CCerror = strprintf("error adding funds for markdone"); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); +} + +UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin) +{ + UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string coin,hex,pub; + CPubKey mypk,importgatewaypk,destpub; std::vector pubkeys,publishers; std::vector txids; + uint256 tmpbindtxid,hashBlock,txid,oracletxid,burntxid; uint8_t M,N,taddr,prefix,prefix2,wiftype; + char burnaddr[65],coinaddr[65],str[65],destaddr[65],txidaddr[65]; std::vector proof; + int32_t numvouts,vout,claimvout,height; int64_t nValue,amount; struct CCcontract_info *cp,C; + std::vector > unspentOutputs; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + mypk = pubkey2pk(Mypubkey()); + importgatewaypk = GetUnspendable(cp,0); + _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,mypk); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin) + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + nValue = (int64_t)it->second.satoshis; + if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + DecodeImportGatewayDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,burntxid,claimvout,hex,proof,destpub,amount) == 'D' + && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) + { + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("burntxid",uint256_str(str,burntxid))); + obj.push_back(Pair("deposittxid",uint256_str(str,txid))); + CCtxidaddr(txidaddr,txid); + obj.push_back(Pair("deposittxidaddr",txidaddr)); + _GetCCaddress(destaddr,EVAL_TOKENS,destpub); + obj.push_back(Pair("depositaddr",burnaddr)); + obj.push_back(Pair("tokens_destination_address",destaddr)); + pub=HexStr(destpub); + obj.push_back(Pair("claim_pubkey",pub)); + obj.push_back(Pair("amount",(double)amount/COIN)); + obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + pending.push_back(obj); + } + } + result.push_back(Pair("coin",refcoin)); + result.push_back(Pair("pending",pending)); + return(result); +} + +UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin) +{ + UniValue result(UniValue::VOBJ),pending(UniValue::VARR); CTransaction tx; std::string coin,hex; CPubKey mypk,importgatewaypk,withdrawpub,signerpk; + std::vector msigpubkeys; uint256 hashBlock,txid,tmpbindtxid,tmptokenid,oracletxid,withdrawtxid; uint8_t K,M,N,taddr,prefix,prefix2,wiftype; + char funcid,burnaddr[65],coinaddr[65],destaddr[65],str[65],withaddr[65],numstr[32],signeraddr[65],txidaddr[65]; + int32_t i,n,numvouts,vout,queueflag; int64_t amount,nValue; struct CCcontract_info *cp,C; + std::vector > unspentOutputs; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + mypk = pubkey2pk(Mypubkey()); + importgatewaypk = GetUnspendable(cp,0); + _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + n = msigpubkeys.size(); + queueflag = 0; + for (i=0; i >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + nValue = (int64_t)it->second.satoshis; + K=0; + if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) + { + if (funcid=='W') + { + if (DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,amount)==0 || refcoin!=coin || tmpbindtxid!=bindtxid) continue; + } + else if (funcid=='P') + { + if (DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || GetTransaction(withdrawtxid,tx,hashBlock,false)==0 + || (numvouts=tx.vout.size())<=0 || DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,amount)!='W' + || refcoin!=coin || tmpbindtxid!=bindtxid) + continue; + } + Getscriptaddress(destaddr,tx.vout[1].scriptPubKey); + GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2); + if ( strcmp(destaddr,coinaddr) == 0 ) + { + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("withdrawtxid",uint256_str(str,tx.GetHash()))); + CCCustomtxidaddr(txidaddr,tx.GetHash(),taddr,prefix,prefix2); + obj.push_back(Pair("withdrawtxidaddr",txidaddr)); + obj.push_back(Pair("withdrawaddr",withaddr)); + sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); + obj.push_back(Pair("amount",numstr)); + obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(tx.GetHash()))); + if ( queueflag != 0 ) + { + obj.push_back(Pair("depositaddr",burnaddr)); + GetCustomscriptaddress(signeraddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG,taddr,prefix,prefix2); + obj.push_back(Pair("signeraddr",signeraddr)); + } + if (N>1) + { + obj.push_back(Pair("number_of_signs",K)); + obj.push_back(Pair("last_txid",uint256_str(str,txid))); + if (K>0) obj.push_back(Pair("hex",hex)); + } + pending.push_back(obj); + } + } + } + result.push_back(Pair("coin",refcoin)); + result.push_back(Pair("pending",pending)); + result.push_back(Pair("queueflag",queueflag)); + return(result); +} + +UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin) +{ + UniValue result(UniValue::VOBJ),processed(UniValue::VARR); CTransaction tx; std::string coin,hex; + CPubKey mypk,importgatewaypk,withdrawpub; std::vector msigpubkeys; + uint256 withdrawtxid,hashBlock,txid,tmptokenid,oracletxid; uint8_t K,M,N,taddr,prefix,prefix2,wiftype; + char burnaddr[65],coinaddr[65],str[65],numstr[32],withaddr[65],txidaddr[65]; + int32_t i,n,numvouts,vout,queueflag; int64_t nValue,amount; struct CCcontract_info *cp,C; + std::vector > unspentOutputs; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + mypk = pubkey2pk(Mypubkey()); + importgatewaypk = GetUnspendable(cp,0); + _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin) + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + n = msigpubkeys.size(); + queueflag = 0; + for (i=0; i >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + nValue = (int64_t)it->second.satoshis; + if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + DecodeImportGatewayCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) + { + if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 + && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin) + { + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("completesigningtxid",uint256_str(str,txid))); + obj.push_back(Pair("withdrawtxid",uint256_str(str,withdrawtxid))); + CCCustomtxidaddr(txidaddr,withdrawtxid,taddr,prefix,prefix2); + obj.push_back(Pair("withdrawtxidaddr",txidaddr)); + GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2); + obj.push_back(Pair("withdrawaddr",withaddr)); + obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); + obj.push_back(Pair("amount",numstr)); + obj.push_back(Pair("hex",hex)); + processed.push_back(obj); + } + } + } + result.push_back(Pair("coin",refcoin)); + result.push_back(Pair("processed",processed)); + result.push_back(Pair("queueflag",queueflag)); + return(result); +} + +UniValue ImportGatewayList() +{ + UniValue result(UniValue::VARR); std::vector > addressIndex; + struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid; CTransaction vintx; std::string coin; + char str[65],burnaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + SetCCtxids(addressIndex,cp->unspendableCCaddr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + txid = it->first.txhash; + if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + { + if ( vintx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) + { + result.push_back(uint256_str(str,txid)); + } + } + } + return(result); +} + +UniValue ImportGatewayExternalAddress(uint256 bindtxid,CPubKey pubkey) +{ + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid; CTransaction tx; + std::string coin; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + GetCustomscriptaddress(addr,CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG,taddr,prefix,prefix2); + result.push_back(Pair("result","success")); + result.push_back(Pair("address",addr)); + return(result); +} + +UniValue ImportGatewayDumpPrivKey(uint256 bindtxid,CKey key) +{ + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid; CTransaction tx; + std::string coin,priv; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + + priv=EncodeCustomSecret(key,wiftype); + result.push_back(Pair("result","success")); + result.push_back(Pair("privkey",priv.c_str())); + return(result); +} + +UniValue ImportGatewayInfo(uint256 bindtxid) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],burnaddr[64],gatewaystokens[64]; + uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2,wiftype; uint256 oracletxid,hashBlock; CTransaction tx; + CPubKey ImportGatewaypk; struct CCcontract_info *cp,C; int32_t i; int64_t numvouts,remaining; std::vector msigpubkeys; + + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + ImportGatewaypk = GetUnspendable(cp,0); + GetTokensCCaddress(cp,gatewaystokens,ImportGatewaypk); + if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + { + CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B') + { + CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()); + LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); + return(""); + } + if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("name","ImportGateway")); + burnaddr[0] = 0; + if ( tx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,tx.vout[tx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 && M <= N && N > 0 ) + { + result.push_back(Pair("M",M)); + result.push_back(Pair("N",N)); + for (i=0; i > unspentOutputs; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; struct CCcontract_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; + CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; + struct CCcontract_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,origtxid); if ( GetTransaction(origtxid,tx,hashBlock,false) == 0 ) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 018025e5a..051129020 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -35,8 +35,7 @@ CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction b mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); mtx.vout = payouts; auto importData = E_MARSHAL(ss << proof; ss << burnTx); - mtx.vout.insert(mtx.vout.begin(), CTxOut(0, CScript() << OP_RETURN << importData)); - + mtx.vout.push_back(CTxOut(0, CScript() << OP_RETURN << importData)); if (nExpiryHeightOverride != 0) mtx.nExpiryHeight = nExpiryHeightOverride; //this is for construction of the tx used for validating importtx return CTransaction(mtx); @@ -53,29 +52,97 @@ CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymb return CTxOut(value, CScript() << OP_RETURN << opret); } +CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts,std::vector rawproof, + uint256 bindtxid,std::vector publishers,std::vector txids,int32_t height,int32_t burnvout,std::string rawburntx,CPubKey destpub) +{ + std::vector opret; + opret = E_MARSHAL(ss << VARINT(targetCCid); + ss << targetSymbol; + ss << SerializeHash(payouts); + ss << rawproof; + ss << bindtxid; + ss << publishers; + ss << txids; + ss << height; + ss << burnvout; + ss << rawburntx; + ss << destpub); + + return CTxOut(value, CScript() << OP_RETURN << opret); +} -bool UnmarshalImportTx(const CTransaction &importTx, TxProof &proof, CTransaction &burnTx, +CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts,std::vector rawproof,std::string srcaddr, + std::string receipt) +{ + std::vector opret; + opret = E_MARSHAL(ss << VARINT(targetCCid); + ss << targetSymbol; + ss << SerializeHash(payouts); + ss << rawproof; + ss << srcaddr; + ss << receipt); + return CTxOut(value, CScript() << OP_RETURN << opret); +} + + +bool UnmarshalImportTx(const CTransaction importTx, TxProof &proof, CTransaction &burnTx, std::vector &payouts) { std::vector vData; - GetOpReturnData(importTx.vout[0].scriptPubKey, vData); + GetOpReturnData(importTx.vout[importTx.vout.size()-1].scriptPubKey, vData); if (importTx.vout.size() < 1) return false; - payouts = std::vector(importTx.vout.begin()+1, importTx.vout.end()); + payouts = std::vector(importTx.vout.begin(), importTx.vout.end()-1); return importTx.vin.size() == 1 && importTx.vin[0].scriptSig == (CScript() << E_MARSHAL(ss << EVAL_IMPORTCOIN)) && E_UNMARSHAL(vData, ss >> proof; ss >> burnTx); } -bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash,std::vector&rawproof) +bool UnmarshalBurnTx(const CTransaction burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash,std::vector&rawproof) { - std::vector burnOpret; uint32_t ccid = 0; + std::vector burnOpret; uint32_t ccid = 0; bool isEof=true; + if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash; - ss >> rawproof); + ss >> rawproof; isEof=ss.eof();) || !isEof; +} + +bool UnmarshalBurnTx(const CTransaction burnTx, std::string &srcaddr, std::string &receipt) +{ + std::vector burnOpret,rawproof; bool isEof=true; + std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; + + if (burnTx.vout.size() == 0) return false; + GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); + return (E_UNMARSHAL(burnOpret, ss >> VARINT(targetCCid); + ss >> targetSymbol; + ss >> payoutsHash; + ss >> rawproof; + ss >> srcaddr; + ss >> receipt)); +} + +bool UnmarshalBurnTx(const CTransaction burnTx,uint256 &bindtxid,std::vector &publishers,std::vector &txids,int32_t &height,int32_t &burnvout,std::string &rawburntx,CPubKey &destpub) +{ + std::vector burnOpret,rawproof; bool isEof=true; + uint32_t targetCCid; uint256 payoutsHash; std::string targetSymbol; + + if (burnTx.vout.size() == 0) return false; + GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); + return (E_UNMARSHAL(burnOpret, ss >> VARINT(targetCCid); + ss >> targetSymbol; + ss >> payoutsHash; + ss >> rawproof; + ss >> bindtxid; + ss >> publishers; + ss >> txids; + ss >> height; + ss >> burnvout; + ss >> rawburntx; + ss >> destpub)); } diff --git a/src/importcoin.h b/src/importcoin.h index 947debcd8..8cb8dbc58 100644 --- a/src/importcoin.h +++ b/src/importcoin.h @@ -29,10 +29,15 @@ CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts, uint32_t nExpiryHeightOverride = 0); CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts,std::vector rawproof); +CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts,std::vector rawproof, + uint256 bindtxid,std::vector publishers,std::vectortxids,int32_t height,int32_t burnvout,std::string rawburntx,CPubKey destpub); +CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts,std::vector rawproof,std::string srcaddr, + std::string receipt); -bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash,std::vector &rawproof); -bool UnmarshalImportTx(const CTransaction &importTx, TxProof &proof, CTransaction &burnTx, - std::vector &payouts); +bool UnmarshalBurnTx(const CTransaction burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash,std::vector &rawproof); +bool UnmarshalBurnTx(const CTransaction burnTx, std::string &srcaddr, std::string &receipt); +bool UnmarshalBurnTx(const CTransaction burnTx,uint256 &bindtxid,std::vector &publishers,std::vector &txids,int32_t &height,int32_t &burnvout,std::string &rawburntx,CPubKey &destpub); +bool UnmarshalImportTx(const CTransaction importTx, TxProof &proof, CTransaction &burnTx,std::vector &payouts); bool VerifyCoinImport(const CScript& scriptSig, TransactionSignatureChecker& checker, CValidationState &state); diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 710f99f09..fa795e0e5 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -24,6 +24,7 @@ #include "consensus/validation.h" #include "cc/eval.h" #include "cc/utils.h" +#include "cc/CCinclude.h" #include "main.h" #include "primitives/transaction.h" #include "rpc/server.h" @@ -35,6 +36,7 @@ #include "script/standard.h" #include "key_io.h" +#include "cc/CCImportGateway.h" #include #include @@ -42,19 +44,23 @@ using namespace std; +#define RETURN_IF_ERROR(CCerror) if ( CCerror != "" ) { ERR_RESULT(CCerror); return(result); } +#define ERR_RESULT(x) result.push_back(Pair("result", "error")) , result.push_back(Pair("error", x)); + +extern std::string CCerror; extern std::string ASSETCHAINS_SELFIMPORT; extern uint16_t ASSETCHAINS_CODAPORT, ASSETCHAINS_BEAMPORT; +int32_t ensure_CCrequirements(uint8_t evalcode); int32_t komodo_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip); int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM *mdata,char *symbol,int32_t kmdheight,int32_t notarized_height); struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi); uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth); extern std::string ASSETCHAINS_SELFIMPORT; -uint256 Parseuint256(char *hexstr); std::string MakeSelfImportSourceTx(CTxDestination &dest, int64_t amount, CMutableTransaction &mtx); int32_t GetSelfimportProof(std::string source, CMutableTransaction &mtx, CScript &scriptPubKey, TxProof &proof, std::string rawsourcetx, int32_t &ivout, uint256 sourcetxid, uint64_t burnAmount); -std::string MakeGatewaysImportTx(uint64_t txfee, uint256 bindtxid, int32_t height, std::string refcoin, std::vectorproof, std::string rawburntx, int32_t ivout, uint256 burntxid); +std::string MakeCodaImportTx(uint64_t txfee, std::string receipt, std::string srcaddr, std::vector vouts); UniValue assetchainproof(const UniValue& params, bool fHelp) { @@ -338,7 +344,6 @@ UniValue selfimport(const UniValue& params, bool fHelp) source = params[5].get_str(); } */ - if (source == "BEAM") { if (ASSETCHAINS_BEAMPORT == 0) @@ -398,14 +403,348 @@ UniValue selfimport(const UniValue& params, bool fHelp) // source is external coin is the assetchains symbol in the burnTx OP_RETURN // burnAmount, rawtx and rawproof should be enough for gatewaysdeposit equivalent - std::string hextx = MakeGatewaysImportTx(0, bindtxid, height, source, rawproof, rawsourcetx, ivout, sourcetxid); + //std::string hextx = MakeGatewaysImportTx(0, bindtxid, height, source, rawproof, rawsourcetx, ivout, ""); - result.push_back(Pair("hex", hextx)); - result.push_back(Pair("UsedRawtxVout", ivout)); // notify user about the used vout of rawtx + // result.push_back(Pair("hex", hextx)); + // result.push_back(Pair("UsedRawtxVout", ivout)); // notify user about the used vout of rawtx } return result; } +UniValue importdual(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + CMutableTransaction mtx; + std::string hex,source,sourceaddr,destaddr,burntxid; uint64_t burnAmount; + CPubKey destpub; std::vector vouts; + + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) + throw runtime_error("importdual only works on -ac_import chains"); + + if (fHelp || params.size() < 4) + throw runtime_error("burntxid source_addr dest_pubkey amount\n"); + + CCerror = ""; + + burntxid = params[0].get_str(); + sourceaddr = params[1].get_str(); + destaddr = params[2].get_str(); + burnAmount = atof(params[3].get_str().c_str()) * COIN + 0.00000000499999; + + source = ASSETCHAINS_SELFIMPORT; //defaults to -ac_import=... param + + CTxDestination dest = DecodeDestination(destaddr.c_str()); + CScript scriptPubKey = GetScriptForDestination(dest); + vouts.push_back(CTxOut(burnAmount,scriptPubKey)); + + if (source == "BEAM") + { + if (ASSETCHAINS_BEAMPORT == 0) + return(-1); + // confirm via ASSETCHAINS_BEAMPORT that burnTx/hash is a valid BEAM burn + // return(0); + return -1; + } + else if (source == "CODA") + { + if (ASSETCHAINS_CODAPORT == 0) + return(-1); + hex=MakeCodaImportTx(0,burntxid,sourceaddr,vouts); + // confirm via ASSETCHAINS_CODAPORT that burnTx/hash is a valid CODA burn + // return(0); + } + RETURN_IF_ERROR(CCerror); + if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldnt importdual"); + return result; +} + +UniValue importgatewayinfo(const UniValue& params, bool fHelp) +{ + uint256 txid; + + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) + throw runtime_error("importgatewaybind only works on -ac_import chains"); + if ( fHelp || params.size() != 1 ) + throw runtime_error("importgatewayinfo bindtxid\n"); + txid = Parseuint256(params[0].get_str().c_str()); + return(ImportGatewayInfo(txid)); +} + +UniValue importgatewaybind(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + CMutableTransaction mtx; std::vector pubkey; + std::string hex,coin; int32_t i,M,N; std::vector pubkeys; + uint256 oracletxid; uint8_t p1,p2,p3,p4; + + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) + throw runtime_error("importgatewaybind only works on -ac_import chains"); + if ( fHelp || params.size() != 8) + throw runtime_error("use \'importgatewaybind coin orcletxid M N pubkeys pubtype p2shtype wiftype [taddr]\' to bind an import gateway\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + CCerror = ""; + coin = params[0].get_str(); + oracletxid = Parseuint256(params[1].get_str().c_str()); + M = atoi(params[2].get_str().c_str()); + N = atoi(params[3].get_str().c_str()); + if ( M > N || N == 0 || N > 15 ) + throw runtime_error("illegal M or N > 15\n"); + if ( params.size() < 4+N+3 ) + throw runtime_error("not enough parameters for N pubkeys\n"); + for (i=0; i 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldnt importgatewaybind"); + return result; +} + +UniValue importgatewaydeposit(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + CMutableTransaction mtx; std::vector rawproof; + std::string hex,coin,rawburntx; int32_t height,burnvout; + CPubKey destpub; std::vector vouts; uint256 bindtxid,burntxid; + + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) + throw runtime_error("importgatewaydeposit only works on -ac_import chains"); + if ( fHelp || params.size() != 8) + throw runtime_error("use \'importgatewaydeposit bindtxid height coin burntxid nvout rawburntx rawproof destpub\' to import deposited coins\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + CCerror = ""; + bindtxid = Parseuint256(params[0].get_str().c_str()); + height = atoi(params[1].get_str().c_str()); + coin = params[2].get_str(); + burntxid = Parseuint256(params[3].get_str().c_str()); + burnvout = atoi(params[4].get_str().c_str()); + rawburntx = params[5].get_str(); + rawproof = ParseHex(params[6].get_str()); + destpub = ParseHex(params[7].get_str()); + if (coin == "BEAM" || coin == "CODA") + { + ERR_RESULT("for BEAM and CODA import use importdual RPC"); + return result; + } + else if (coin != ASSETCHAINS_SELFIMPORT) + { + ERR_RESULT("source coin not equal to ac_import name"); + return result; + } + hex = ImportGatewayDeposit(0, bindtxid, height, coin, burntxid, burnvout, rawburntx, rawproof, destpub); + RETURN_IF_ERROR(CCerror); + if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldnt importgatewaydeposit"); + return result; +} + +UniValue importgatewaywithdraw(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + CMutableTransaction mtx; std::vector rawproof; + std::string hex,coin,rawburntx; int64_t amount; int32_t height,burnvout; + CPubKey destpub; std::vector vouts; uint256 bindtxid,burntxid; + + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) + throw runtime_error("importgatewaywithdraw only works on -ac_import chains"); + if ( fHelp || params.size() != 4) + throw runtime_error("use \'importgatewaywithdraw bindtxid coin withdrawpub amount\' to burn imported coins and withdraw them on external chain\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + CCerror = ""; + bindtxid = Parseuint256(params[0].get_str().c_str()); + coin = params[1].get_str(); + destpub = ParseHex(params[2].get_str()); + amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999; + if (coin == "BEAM" || coin == "CODA") + { + ERR_RESULT("for BEAM and CODA import use importdual RPC"); + return result; + } + else if (coin != ASSETCHAINS_SELFIMPORT) + { + ERR_RESULT("source coin not equal to ac_import name"); + return result; + } + hex = ImportGatewayWithdraw(0, bindtxid, coin, destpub, amount); + RETURN_IF_ERROR(CCerror); + if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldnt importgatewaywithdraw"); + return result; +} + +UniValue importgatewaypartialsign(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); std::string coin,parthex,hex; uint256 txid; + + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) + throw runtime_error("importgatewayspartialsign only works on -ac_import chains"); + if ( fHelp || params.size() != 3 ) + throw runtime_error("importgatewayspartialsign txidaddr refcoin hex\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + txid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + parthex = params[2].get_str(); + hex = ImportGatewayPartialSign(0,txid,coin,parthex); + if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex",hex)); + } else ERR_RESULT("couldnt importgatewayspartialsign"); + return(result); +} + +UniValue importgatewaycompletesigning(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); uint256 withdrawtxid; std::string txhex,hex,coin; + + if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) + throw runtime_error("importgatewaycompletesigning only works on -ac_import chains"); + if ( fHelp || params.size() != 3 ) + throw runtime_error("importgatewaycompletesigning withdrawtxid coin hex\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + withdrawtxid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + txhex = params[2].get_str(); + hex = ImportGatewayCompleteSigning(0,withdrawtxid,coin,txhex); + RETURN_IF_ERROR(CCerror); + if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldnt importgatewaycompletesigning"); + return(result); +} + +UniValue importgatewaymarkdone(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); uint256 completetxid; std::string hex,coin; + if ( fHelp || params.size() != 2 ) + throw runtime_error("importgatewaymarkdone completesigningtx coin\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + completetxid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + hex = ImportGatewayMarkDone(0,completetxid,coin); + RETURN_IF_ERROR(CCerror); + if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldnt importgatewaymarkdone"); + return(result); +} + +UniValue importgatewaypendingdeposits(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; std::string coin; + if ( fHelp || params.size() != 2 ) + throw runtime_error("importgatewaypendingdeposits bindtxid coin\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + return(ImportGatewayPendingDeposits(bindtxid,coin)); +} + +UniValue importgatewaypendingwithdraws(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; std::string coin; + if ( fHelp || params.size() != 2 ) + throw runtime_error("importgatewaypendingwithdraws bindtxid coin\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + return(ImportGatewayPendingWithdraws(bindtxid,coin)); +} + +UniValue importgatewayprocessed(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; std::string coin; + if ( fHelp || params.size() != 2 ) + throw runtime_error("importgatewayprocessed bindtxid coin\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + return(ImportGatewayProcessedWithdraws(bindtxid,coin)); +} + +UniValue importgatewayexternaladdress(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; CPubKey pubkey; + + if ( fHelp || params.size() != 2) + throw runtime_error("importgatewayexternaladdress bindtxid pubkey\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + pubkey = ParseHex(params[1].get_str().c_str()); + return(ImportGatewayExternalAddress(bindtxid,pubkey)); +} + +UniValue importgatewaydumpprivkey(const UniValue& params, bool fHelp) +{ + uint256 bindtxid; + + if ( fHelp || params.size() != 2) + throw runtime_error("importgatewaydumpprivkey bindtxid address\n"); + if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + std::string strAddress = params[1].get_str(); + CTxDestination dest = DecodeDestination(strAddress); + if (!IsValidDestination(dest)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid transparent address"); + } + const CKeyID *keyID = boost::get(&dest); + if (!keyID) { + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); + } + CKey vchSecret; + // if (!pwalletMain->GetKey(*keyID, vchSecret)) { + // throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); + //} + return(ImportGatewayDumpPrivKey(bindtxid,vchSecret)); +} + UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -536,9 +875,9 @@ UniValue getimports(const UniValue& params, bool fHelp) UniValue objTx(UniValue::VOBJ); objTx.push_back(Pair("txid",tx.GetHash().ToString())); TxProof proof; CTransaction burnTx; std::vector payouts; CTxDestination importaddress; - TotalImported += tx.vout[1].nValue; - objTx.push_back(Pair("amount", ValueFromAmount(tx.vout[1].nValue))); - if (ExtractDestination(tx.vout[1].scriptPubKey, importaddress)) + TotalImported += tx.vout[0].nValue; + objTx.push_back(Pair("amount", ValueFromAmount(tx.vout[0].nValue))); + if (ExtractDestination(tx.vout[0].scriptPubKey, importaddress)) { objTx.push_back(Pair("address", CBitcoinAddress(importaddress).ToString())); } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index a48ef6cb1..fc34a2a3f 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -354,6 +354,21 @@ static const CRPCCommand vRPCCommands[] = { "crosschain", "migrate_createimporttransaction", &migrate_createimporttransaction, true }, { "crosschain", "migrate_completeimporttransaction", &migrate_completeimporttransaction, true }, { "crosschain", "selfimport", &selfimport, true }, + { "crosschain", "importdual", &importdual, true }, + //ImportGateway + { "crosschain", "importgatewayddress", &importgatewayaddress, true }, + { "crosschain", "importgatewayinfo", &importgatewayinfo, true }, + { "crosschain", "importgatewaybind", &importgatewaybind, true }, + { "crosschain", "importgatewaydeposit", &importgatewaydeposit, true }, + { "crosschain", "importgatewaywithdraw", &importgatewaywithdraw, true }, + { "crosschain", "importgatewaypartialsign", &importgatewaypartialsign, true }, + { "crosschain", "importgatewaycompletesigning", &importgatewaycompletesigning, true }, + { "crosschain", "importgatewaymarkdone", &importgatewaymarkdone, true }, + { "crosschain", "importgatewaypendingdeposits", &importgatewaypendingdeposits, true }, + { "crosschain", "importgatewaypendingwithdraws", &importgatewaypendingwithdraws, true }, + { "crosschain", "importgatewayprocessed", &importgatewayprocessed, true }, + + /* Mining */ { "mining", "getblocktemplate", &getblocktemplate, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 79a12bb7b..d8fd0e736 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -314,7 +314,6 @@ extern UniValue channelsopen(const UniValue& params, bool fHelp); extern UniValue channelspayment(const UniValue& params, bool fHelp); extern UniValue channelsclose(const UniValue& params, bool fHelp); extern UniValue channelsrefund(const UniValue& params, bool fHelp); - //extern UniValue tokenswapask(const UniValue& params, bool fHelp); //extern UniValue tokenfillswap(const UniValue& params, bool fHelp); extern UniValue faucetfund(const UniValue& params, bool fHelp); @@ -435,6 +434,18 @@ extern UniValue invalidateblock(const UniValue& params, bool fHelp); extern UniValue reconsiderblock(const UniValue& params, bool fHelp); extern UniValue getspentinfo(const UniValue& params, bool fHelp); extern UniValue selfimport(const UniValue& params, bool fHelp); +extern UniValue importdual(const UniValue& params, bool fHelp); +extern UniValue importgatewayaddress(const UniValue& params, bool fHelp); +extern UniValue importgatewayinfo(const UniValue& params, bool fHelp); +extern UniValue importgatewaybind(const UniValue& params, bool fHelp); +extern UniValue importgatewaydeposit(const UniValue& params, bool fHelp); +extern UniValue importgatewaywithdraw(const UniValue& params, bool fHelp); +extern UniValue importgatewaypartialsign(const UniValue& params, bool fHelp); +extern UniValue importgatewaycompletesigning(const UniValue& params, bool fHelp); +extern UniValue importgatewaymarkdone(const UniValue& params, bool fHelp); +extern UniValue importgatewaypendingdeposits(const UniValue& params, bool fHelp); +extern UniValue importgatewaypendingwithdraws(const UniValue& params, bool fHelp); +extern UniValue importgatewayprocessed(const UniValue& params, bool fHelp); extern UniValue getblocksubsidy(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d720cf33f..77b2fb62d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5858,6 +5858,19 @@ UniValue tokenaddress(const UniValue& params, bool fHelp) return(CCaddress(cp,(char *)"Tokens", pubkey)); } +UniValue importgatewayaddress(const UniValue& params, bool fHelp) +{ + struct CCcontract_info *cp,C; std::vector pubkey; + cp = CCinit(&C,EVAL_IMPORTGATEWAY); + if ( fHelp || params.size() > 1 ) + throw runtime_error("importgatewayddress [pubkey]\n"); + if ( ensure_CCrequirements(0) < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + if ( params.size() == 1 ) + pubkey = ParseHex(params[0].get_str().c_str()); + return(CCaddress(cp,(char *)"ImportGateway", pubkey)); +} + UniValue marmara_poolpayout(const UniValue& params, bool fHelp) { int32_t firstheight; double perc; char *jsonstr; @@ -7994,7 +8007,6 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret)); } - UniValue test_burntx(const UniValue& params, bool fHelp) { // make fake token tx: From ba0fda90b278fd51cf1b2b444ea6bea6916dc9a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 02:09:18 -1100 Subject: [PATCH 3766/3904] Small changes --- src/komodo_gateway.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ba15746e0..5aabbffd5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1551,7 +1551,7 @@ void komodo_passport_iteration() extern std::vector Mineropret; // opreturn data set by the data gathering code #define PRICES_MAXCHANGE (COIN / 100) // maximum acceptable change, set at 1% #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR -#define KOMODO_LOCALPRICE_CACHESIZE 7 +#define KOMODO_LOCALPRICE_CACHESIZE 13 #define KOMODO_MAXPRICES 2048 #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) @@ -1815,7 +1815,10 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i break; } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) + { + komodo_queuelocalprice(1,block.GetHash(),i,prevbits[i]); break; + } } else if ( maxflag < 0 && localbits[i] > prevbits[i] ) { @@ -1828,7 +1831,10 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i break; } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) + { + komodo_queuelocalprice(-1,block.GetHash(),i,prevbits[i]); break; + } } } } From ae7c5ee027aa4db23e7b919f77d413bc9506655e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 02:13:07 -1100 Subject: [PATCH 3767/3904] Fix declaration --- src/komodo_gateway.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5aabbffd5..44ec7c9f3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1720,11 +1720,10 @@ CScript komodo_mineropret(int32_t nHeight) The only way komodo_opretvalidate() doesnt return an error is if maxflag is set or it is within tolerance of both the prior block and the local data. The local data validation only happens if it is a recent block and not a block from the past as the local node is only getting the current price data. */ -// for PRICES: reconsiderblock 002aca768b09dfcf36bd934ab34b23983148b116e12cb0b6e1a3f895d1db63aa -// and -// reconsiderblock 0034cf582018eacc0b4ae001491ce460113514cb1a3f217567ef4a2207de361a -// reconsiderbloc 000abf51c023b64af327c50c1b060797b8cb281c696d30ab92fd002a8b8c9aea -// are needed to sync past initial blocks with different data set +void komodo_queuelocalprice(int32_t dir,uint256 blockhash,int32_t ind,uint32_t pricebits) +{ + +} int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { @@ -1816,7 +1815,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(1,block.GetHash(),i,prevbits[i]); + komodo_queuelocalprice(1,block.GetBlockHash(),i,prevbits[i]); break; } } @@ -1832,7 +1831,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(-1,block.GetHash(),i,prevbits[i]); + komodo_queuelocalprice(-1,block.GetBlockHash(),i,prevbits[i]); break; } } From 6618a43e8a8e137243572ccfd8d2b10dec1d49c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 02:14:07 -1100 Subject: [PATCH 3768/3904] -> --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 44ec7c9f3..82491941f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1815,7 +1815,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(1,block.GetBlockHash(),i,prevbits[i]); + komodo_queuelocalprice(1,block->GetBlockHash(),i,prevbits[i]); break; } } @@ -1831,7 +1831,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(-1,block.GetBlockHash(),i,prevbits[i]); + komodo_queuelocalprice(-1,block->GetBlockHash(),i,prevbits[i]); break; } } From 137f51651603c5a681699c6d3c9cd7202a55f9c1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 02:16:07 -1100 Subject: [PATCH 3769/3904] GetHash() --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 82491941f..3db8bfb1a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1815,7 +1815,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(1,block->GetBlockHash(),i,prevbits[i]); + komodo_queuelocalprice(1,block->GetHash(),i,prevbits[i]); break; } } @@ -1831,7 +1831,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(-1,block->GetBlockHash(),i,prevbits[i]); + komodo_queuelocalprice(-1,block->GetHash(),i,prevbits[i]); break; } } From a2cdadf17de5e7c0b06e69f21ee3612075d52ff5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 02:43:11 -1100 Subject: [PATCH 3770/3904] Add auto resync for local prices --- src/komodo_gateway.h | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3db8bfb1a..70a69ebc8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1720,17 +1720,33 @@ CScript komodo_mineropret(int32_t nHeight) The only way komodo_opretvalidate() doesnt return an error is if maxflag is set or it is within tolerance of both the prior block and the local data. The local data validation only happens if it is a recent block and not a block from the past as the local node is only getting the current price data. */ -void komodo_queuelocalprice(int32_t dir,uint256 blockhash,int32_t ind,uint32_t pricebits) + +struct komodo_extremeprice { - + uint256 blockhash; + uint32_t pricebits,timestamp; + int32_t height; + int16_t dir,ind; +} ExtremePrice; + +void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint256 blockhash,int32_t ind,uint32_t pricebits) +{ + ExtremePrice.dir = dir; + ExtremePrice.height = height; + ExtremePrice.blockhash = blockhash; + ExtremePrice.ind = ind; + ExtremePrice.timestamp = timestamp; + ExtremePrice.pricebits = pricebits; } int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { int32_t testchain_exemption = 0; - std::vector vopret; char maxflags[KOMODO_MAXPRICES]; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now = (uint32_t)time(NULL); + std::vector vopret; char maxflags[KOMODO_MAXPRICES]; uint245 bhash; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now; + now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { + bhash = block->GetHash(); GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() >= PRICES_SIZEBIT0 ) { @@ -1815,7 +1831,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(1,block->GetHash(),i,prevbits[i]); + komodo_queuelocalprice(1,nHeight,block->nTime,bhash,i,prevbits[i]); break; } } @@ -1831,7 +1847,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( j == KOMODO_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(-1,block->GetHash(),i,prevbits[i]); + komodo_queuelocalprice(-1,nHeight,block->nTime,bhash,i,prevbits[i]); break; } } @@ -1849,6 +1865,11 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } } } + if ( bhash == ExtremePrice.blockhash ) + { + fprintf(stderr,"approved a previously extreme price based on new data ht.%d vs %u vs %u\n",ExtremePrice.height,ExtremePrice.timestamp,(uint32_t)block.nTime); + memset(&ExtremePrice,0,sizeof(ExtremePrice)); + } return(0); } else fprintf(stderr,"wrong size %d vs %d, scriptPubKey size %d [%02x]\n",(int32_t)vopret.size(),(int32_t)Mineropret.size(),(int32_t)scriptPubKey.size(),scriptPubKey[0]); return(-1); @@ -2129,7 +2150,7 @@ void komodo_cbopretupdate(int32_t forceflag) { static uint32_t lasttime,lastcrypto,lastbtc,pending; static uint32_t pricebits[4],cryptoprices[KOMODO_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)]; - int32_t size; uint32_t flags=0,now; + int32_t size; uint32_t flags=0,now; CBlockIndex *pindex; if ( forceflag != 0 && pending != 0 ) { while ( pending != 0 ) @@ -2187,6 +2208,16 @@ void komodo_cbopretupdate(int32_t forceflag) if ( (flags & 4) != 0 ) lastcrypto = now; memcpy(Mineropret.data(),PriceCache[0],size); + if ( ExtremePrice.dir != 0 && ExtremePrice.ind > 0 && ExtremePrice.ind < size/sizeof(uint32_t) && now < ExtremePrice.timestamp+3600 ) + { + if ( (ExtremePrice.dir > 0 && PriceCache[0][ExtremePrice.ind] >= ExtremePrice.pricebits) || (ExtremePrice.dir < 0 && PriceCache[0][ExtremePrice.ind] <= ExtremePrice.pricebits) ) + { + fprintf(stderr,"future price is close enough to allow approving previously rejected block ind.%d %u vs %u ht.%d\n",ExtremePrice.ind,PriceCache[0][ExtremePrice.ind],ExtremePrice.pricebits,height); + if ( (pindex= komodo_blockindex(ExtremePrice.blockhash)) != 0 ) + pindex->nStatus &= ~BLOCK_FAILED_MASK; + else fprintf(stderr,"couldnt find block.%s\n",ExtremePrice.blockhash.GetHex()); + } + } // high volatility still strands nodes so we need to check new prices to approve a stuck block // scan list of stuck blocks (one?) and auto reconsiderblock if it changed state From 43b18d52599059914b249e9c62a74c68cd02ec77 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 02:47:17 -1100 Subject: [PATCH 3771/3904] Fix --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 70a69ebc8..9afc9845c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1742,7 +1742,7 @@ void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint25 int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { int32_t testchain_exemption = 0; - std::vector vopret; char maxflags[KOMODO_MAXPRICES]; uint245 bhash; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now; + std::vector vopret; char maxflags[KOMODO_MAXPRICES]; uint256 bhash; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now; now = (uint32_t)time(NULL); if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 ) { @@ -1867,7 +1867,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i } if ( bhash == ExtremePrice.blockhash ) { - fprintf(stderr,"approved a previously extreme price based on new data ht.%d vs %u vs %u\n",ExtremePrice.height,ExtremePrice.timestamp,(uint32_t)block.nTime); + fprintf(stderr,"approved a previously extreme price based on new data ht.%d vs %u vs %u\n",ExtremePrice.height,ExtremePrice.timestamp,(uint32_t)block->nTime); memset(&ExtremePrice,0,sizeof(ExtremePrice)); } return(0); @@ -2212,10 +2212,10 @@ void komodo_cbopretupdate(int32_t forceflag) { if ( (ExtremePrice.dir > 0 && PriceCache[0][ExtremePrice.ind] >= ExtremePrice.pricebits) || (ExtremePrice.dir < 0 && PriceCache[0][ExtremePrice.ind] <= ExtremePrice.pricebits) ) { - fprintf(stderr,"future price is close enough to allow approving previously rejected block ind.%d %u vs %u ht.%d\n",ExtremePrice.ind,PriceCache[0][ExtremePrice.ind],ExtremePrice.pricebits,height); + fprintf(stderr,"future price is close enough to allow approving previously rejected block ind.%d %u vs %u\n",ExtremePrice.ind,PriceCache[0][ExtremePrice.ind],ExtremePrice.pricebits); if ( (pindex= komodo_blockindex(ExtremePrice.blockhash)) != 0 ) pindex->nStatus &= ~BLOCK_FAILED_MASK; - else fprintf(stderr,"couldnt find block.%s\n",ExtremePrice.blockhash.GetHex()); + else fprintf(stderr,"couldnt find block.%s\n",ExtremePrice.blockhash.GetHex().c_str()); } } // high volatility still strands nodes so we need to check new prices to approve a stuck block From cd8d41c5f8301a7f8dba1056168926562135d7a2 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Wed, 10 Apr 2019 18:07:53 +0200 Subject: [PATCH 3772/3904] Fix broken build --- src/cc/import.cpp | 84 +++-------------------------------------------- 1 file changed, 4 insertions(+), 80 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 157fa6888..14f359398 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -33,86 +33,10 @@ uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::ve uint256 GatewaysReverseScan(uint256 &txid, int32_t height, uint256 reforacletxid, uint256 batontxid); int32_t GatewaysCointxidExists(struct CCcontract_info *cp, uint256 cointxid); uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype); - -char *nonportable_path(char *str) -{ - int32_t i; - for (i=0; str[i]!=0; i++) - if ( str[i] == '/' ) - str[i] = '\\'; - return(str); -} - -char *portable_path(char *str) -{ -#ifdef _WIN32 - return(nonportable_path(str)); -#else -#ifdef __PNACL - /*int32_t i,n; - if ( str[0] == '/' ) - return(str); - else - { - n = (int32_t)strlen(str); - for (i=n; i>0; i--) - str[i] = str[i-1]; - str[0] = '/'; - str[n+1] = 0; - }*/ -#endif - return(str); -#endif -} - -void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) -{ - FILE *fp; - long filesize,buflen = *allocsizep; - uint8_t *buf = *bufp; - *lenp = 0; - if ( (fp= fopen(portable_path(fname),"rb")) != 0 ) - { - fseek(fp,0,SEEK_END); - filesize = ftell(fp); - if ( filesize == 0 ) - { - fclose(fp); - *lenp = 0; - //printf("loadfile null size.(%s)\n",fname); - return(0); - } - if ( filesize > buflen ) - { - *allocsizep = filesize; - *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); - } - rewind(fp); - if ( buf == 0 ) - printf("Null buf ???\n"); - else - { - if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) - printf("error reading filesize.%ld\n",(long)filesize); - buf[filesize] = 0; - } - fclose(fp); - *lenp = filesize; - //printf("loaded.(%s)\n",buf); - } //else printf("OS_loadfile couldnt load.(%s)\n",fname); - return(buf); -} - -void *filestr(long *allocsizep,char *_fname) -{ - long filesize = 0; char *fname,*buf = 0; void *retptr; - *allocsizep = 0; - fname = (char *)malloc(strlen(_fname)+1); - strcpy(fname,_fname); - retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); - free(fname); - return(retptr); -} +char *nonportable_path(char *str); +char *portable_path(char *str); +void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep); +void *filestr(long *allocsizep,char *_fname); // ac_import=chain support: // encode opret for gateways import From 2056c8727be31a38ae563bc207e4b3b8df26e1ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 05:14:54 -1100 Subject: [PATCH 3773/3904] Token peg ideas --- src/cc/pegs.cpp | 6 ++++++ src/cc/prices.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 00d76d8fd..38933ebdc 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -72,7 +72,13 @@ pegs CC is able to create a coin backed (by any supported coin with gateways CC Let us now consider how to enforce a peg onto a specific gateways CC token. If this can also be achieved, then a full DEX for all the different gateways CC supported coins can be created onto a single fiat denominated chain. + I think just having a pegscreate rpc call that binds an existing gateways create to a price CC syntax price will be almost enough to support this. Let us assume a USD stablechain and we have a BTC token, then pegscreate "BTCUSD, 1" + that will specify using the BTCUSD price, so now we need to create a based way to do tokenbid/tokenask. For a based price, the smoothed price is substituted. + There is the issue of the one day delay, so it might make sense to allow specific bid/ask to be based on some simple combinations of the three possible prices. it might even be possible to go a bit overboard and make a forth like syntax to define the dynamic price for a bid, which maybe at times wont be valid, like it is only valid if the three prices are within 1% of each other. But all that seems over complex and for initial release it can just use the mined, correlated or smoothed price, with some specified percentage offset + + Implementation notes: + make sure that fees and markers that can be sent to an unspendable address are sent to: RNdqHx26GWy9bk8MtmH1UiXjQcXE4RKK2P, this is the address for BOTS */ diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index ce257d33f..19194d16f 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -138,6 +138,9 @@ CBOPRET creates trustless oracles, which can be used for making a synthetic cash Another configuration is to send the 0.4% (or 0.2%) fees to a fee collection scriptPubKey (this is not currently implemented, but would be needed for systems that dont use -ac_perc to collect a global override) this requires adding new vouts Modification: in the event there is one price in the accumulator and one price on the stack at the end, then it is a (A - B) spread + + Monetizations should be sent to: RGsWqwFviaNJSbmgWi6338NL2tKkY7ZqKL + */ From 9b62776a8be938892056378868a4d2ff9f7d6d77 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 05:27:06 -1100 Subject: [PATCH 3774/3904] -conflict --- src/rpc/crosschain.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 74ac53c44..0feb5173c 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -413,9 +413,9 @@ UniValue selfimport(const UniValue& params, bool fHelp) return result; } -<<<<<<< HEAD bool GetNotarisationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const std::vector &vin, std::vector &NotarisationNotaries); -======= + + UniValue importdual(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); @@ -749,7 +749,6 @@ UniValue importgatewaydumpprivkey(const UniValue& params, bool fHelp) //} return(ImportGatewayDumpPrivKey(bindtxid,vchSecret)); } ->>>>>>> FSM UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) { From 0e2969debb70a41c1ab24340ee1863d7fb5da179 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 11 Apr 2019 14:28:24 +0800 Subject: [PATCH 3775/3904] notarystats.py update to official regions/stop height. --- src/notarystats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notarystats.py b/src/notarystats.py index 0e7673833..49713b6c3 100755 --- a/src/notarystats.py +++ b/src/notarystats.py @@ -53,11 +53,11 @@ def def_credentials(chain): rpc = def_credentials('KMD') pp = pprint.PrettyPrinter(indent=2) -notarynames = [ "0dev1_jl777", "0dev2_kolo", "0dev3_kolo", "0dev4_decker", "a-team_SH", "artik_AR", "artik_EU", "artik_NA", "artik_SH", "badass_EU", "badass_NA", "batman_AR", "batman_SH", "ca333_EU", "chainmakers_EU", "chainmakers_NA", "chainstrike_SH", "cipi_AR", "cipi_NA", "crackers_EU", "crackers_NA", "dwy_EU", "emmanux_SH", "etszombi_EU", "fullmoon_AR", "fullmoon_NA", "fullmoon_SH", "goldenman_EU", "indenodes_AR", "indenodes_EU", "indenodes_NA", "indenodes_SH", "jackson_AR", "jeezy_EU", "karasugoi_NA", "komodoninja_EU", "komodoninja_SH", "komodopioneers_SH", "libscott_SH", "lukechilds_AR", "madmax_AR", "meshbits_AR", "meshbits_SH", "metaphilibert_AR", "metaphilibert_SH", "patchkez_SH", "pbca26_NA", "peer2cloud_AR", "peer2cloud_SH", "polycryptoblog_NA", "hyper_AR", "hyper_EU", "hyper_SH", "hyper_NA", "popcornbag_AR", "popcornbag_NA", "alien_AR", "alien_EU", "thegaltmines_NA", "titomane_AR", "titomane_EU", "titomane_SH", "webworker01_NA", "xrobesx_NA" ] +notarynames = [ "0dev1_jl777", "0dev2_kolo", "0dev3_kolo", "0dev4_decker_AR", "a-team_SH", "artik_AR", "artik_EU", "artik_NA", "artik_SH", "badass_EU", "badass_NA", "batman_AR", "batman_SH", "ca333", "chainmakers_EU", "chainmakers_NA", "chainstrike_SH", "cipi_AR", "cipi_NA", "crackers_EU", "crackers_NA", "dwy_EU", "emmanux_SH", "etszombi_EU", "fullmoon_AR", "fullmoon_NA", "fullmoon_SH", "goldenman_EU", "indenodes_AR", "indenodes_EU", "indenodes_NA", "indenodes_SH", "jackson_AR", "jeezy_EU", "karasugoi_NA", "komodoninja_EU", "komodoninja_SH", "komodopioneers_SH", "libscott_SH", "lukechilds_AR", "madmax_AR", "meshbits_AR", "meshbits_SH", "metaphilibert_AR", "metaphilibert_SH", "patchkez_SH", "pbca26_NA", "peer2cloud_AR", "peer2cloud_SH", "polycryptoblog_NA", "hyper_AR", "hyper_EU", "hyper_SH", "hyper_NA", "popcornbag_AR", "popcornbag_NA", "alien_AR", "alien_EU", "thegaltmines_NA", "titomane_AR", "titomane_EU", "titomane_SH", "webworker01_NA", "xrobesx_NA" ] notaries = 64 * [0] startheight = 821657 #Second time filter for assetchains (block 821657) for KMD its 814000 -stopheight = rpc.getblockcount() # @kolo what height does season end?! +stopheight = 1307200 for i in range(startheight,stopheight): ret = rpc.getNotarisationsForBlock(i) KMD = ret['KMD'] From 2993a76b3050cd885a9f58f614264f9b665eb941 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 20:39:55 -1100 Subject: [PATCH 3776/3904] komodo_pricesinit --- src/komodo_defs.h | 1 + src/komodo_gateway.h | 16 ++++++++++++++++ src/komodo_utils.h | 1 + 3 files changed, 18 insertions(+) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 9377ea276..31dde4a24 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -85,5 +85,6 @@ int tx_height( const uint256 &hash ); extern std::vector vWhiteListAddress; void komodo_netevent(std::vector payload); int32_t komodo_priceind(char *symbol); +void komodo_pricesinit(); #endif diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9afc9845c..2098d30c2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2526,3 +2526,19 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *rawprice return(price); } +void komodo_pricesinit() +{ + FILE *fp; char symbol[65]; int32_t i; + boost::filesystem::path pricefname,pricesdir = GetDataDir() / "prices"; + if (!boost::filesystem::exists(pricesdir)) + { + boost::filesystem::create_directories(pricesdir); + for (i=0; i Date: Wed, 10 Apr 2019 20:53:00 -1100 Subject: [PATCH 3777/3904] Make fp for each file --- src/komodo_gateway.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2098d30c2..5ac8ea540 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1549,10 +1549,11 @@ void komodo_passport_iteration() } extern std::vector Mineropret; // opreturn data set by the data gathering code -#define PRICES_MAXCHANGE (COIN / 100) // maximum acceptable change, set at 1% +#define PRICES_ERRORRATE (COIN / 100) // maximum acceptable change, set at 1% #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR #define KOMODO_LOCALPRICE_CACHESIZE 13 #define KOMODO_MAXPRICES 2048 +#define PRICES_SMOOTHWIDTH 1 #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) @@ -1696,10 +1697,10 @@ CScript komodo_mineropret(int32_t nHeight) { memcpy(pricebits,Mineropret.data(),Mineropret.size()); memset(maxflags,0,sizeof(maxflags)); - if ( komodo_pricecmp(0,n,maxflags,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(0,n,maxflags,pricebits,prevbits,PRICES_ERRORRATE) < 0 ) { // if the new prices are outside tolerance, update Mineropret with clamped prices - komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE); + komodo_priceclamp(n,pricebits,prevbits,PRICES_ERRORRATE); //fprintf(stderr,"update Mineropret to clamped prices\n"); memcpy(Mineropret.data(),pricebits,Mineropret.size()); } @@ -1788,7 +1789,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i if ( pricebits[i] == 0 ) pricebits[i] = prevbits[i]; } - if ( komodo_pricecmp(nHeight,n,maxflags,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) + if ( komodo_pricecmp(nHeight,n,maxflags,pricebits,prevbits,PRICES_ERRORRATE) < 0 ) { for (i=1; i Date: Wed, 10 Apr 2019 20:59:20 -1100 Subject: [PATCH 3778/3904] Fputc --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5ac8ea540..5f9a2b8b4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2541,7 +2541,7 @@ void komodo_pricesinit() pricefname = pricesdir / symbol; fp = fopen(pricefname.string().c_str(), "wb+"); fseek(fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * 3,SEEK_SET); - fputc(fp,0); + fputc(0,fp); fflush(fp); } } From 169bffa3e4231ab06172df5cd6e0892f2e98d248 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 21:06:56 -1100 Subject: [PATCH 3779/3904] +print --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5f9a2b8b4..f5ee16f7b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2530,7 +2530,8 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *rawprice void komodo_pricesinit() { FILE *fp; char symbol[65]; int32_t i; - boost::filesystem::path pricefname,pricesdir = GetDataDir() / ASSETCHAINS_SYMBOL / "prices"; + boost::filesystem::path pricefname,pricesdir = GetDataDir() / "prices"; + fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str()); if (!boost::filesystem::exists(pricesdir)) { boost::filesystem::create_directories(pricesdir); From 027662268df016a645de71a6c5ff21dd3db4da4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 21:11:27 -1100 Subject: [PATCH 3780/3904] Move pricesinit --- src/bitcoind.cpp | 2 ++ src/komodo_utils.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 4e010d28e..68e0da8b3 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -70,6 +70,8 @@ void WaitForShutdown(boost::thread_group* threadGroup) { int32_t i; bool fShutdown = ShutdownRequested(); // Tell the main threads to shutdown. + if ( ASSETCHAINS_CBOPRET != 0 ) + komodo_pricesinit(); while (!fShutdown) { //fprintf(stderr,"call passport iteration\n"); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 700615ee1..043d7282e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2082,7 +2082,6 @@ void komodo_args(char *argv0) extralen += symbol.size(); } } - komodo_pricesinit(); komodo_cbopretupdate(1); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } From 8f5feded98166b02b00a18e488a31c5a0bdc1884 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Apr 2019 22:46:42 -1100 Subject: [PATCH 3781/3904] fp0 --- src/komodo_gateway.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f5ee16f7b..e128043ff 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2529,7 +2529,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *rawprice void komodo_pricesinit() { - FILE *fp; char symbol[65]; int32_t i; + FILE *fp,*fp0 = 0; char symbol[65]; int32_t i; boost::filesystem::path pricefname,pricesdir = GetDataDir() / "prices"; fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str()); if (!boost::filesystem::exists(pricesdir)) @@ -2539,11 +2539,21 @@ void komodo_pricesinit() { if ( komodo_pricename(symbol,i) == 0 ) break; + if ( i == 0 ) + strcpy(symbol,"rawprices"); pricefname = pricesdir / symbol; fp = fopen(pricefname.string().c_str(), "wb+"); + if ( i == 0 ) + fp0 = fp; fseek(fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * 3,SEEK_SET); fputc(0,fp); fflush(fp); } + if ( fp0 != 0 && i > 0 ) + { + fseek(fp0,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(uint32_t) * i,SEEK_SET); + fputc(0,fp0); + fflush(fp0); + } } } From 6178eb87c47e643f73f7918ed120e162c342ae91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 11 Apr 2019 18:13:39 +0800 Subject: [PATCH 3782/3904] fix dpow --- src/komodo.h | 4 ++-- src/main.cpp | 57 ++++++++++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3ceb29cc3..15c1e5c02 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -691,7 +691,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - if ( !fJustCheck && matched != 0 ) + if ( matched != 0 ) printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) @@ -747,7 +747,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar } else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { - if ( !fJustCheck && notaryid >= 0 && notaryid < 64 ) + if ( notaryid >= 0 && notaryid < 64 ) komodo_paxpricefeed(height,&scriptbuf[len],opretlen); } else if ( matched != 0 ) diff --git a/src/main.cpp b/src/main.cpp index faa9e6a9c..47b089ca8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4239,37 +4239,36 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // our genesis block. In practice this (probably) won't happen because of checks elsewhere. auto reorgLength = pindexOldTip ? pindexOldTip->GetHeight() - (pindexFork ? pindexFork->GetHeight() : -1) : 0; assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); + + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + if ( pindexFork->GetHeight() < notarizedht ) + { + fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); + pindexFork = pindexOldTip; + } + if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - if ( pindexFork->GetHeight() < notarizedht ) - { - fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); - pindexFork = pindexOldTip; - } - else - { - auto msg = strprintf(_( - "A block chain reorganization has been detected that would roll back %d blocks! " - "This is larger than the maximum of %d blocks, and so the node is shutting down for your safety." - ), reorgLength, MAX_REORG_LENGTH) + "\n\n" + - _("Reorganization details") + ":\n" + - "- " + strprintf(_("Current tip: %s, height %d, work %s\nstake %s"), - pindexOldTip->phashBlock->GetHex(), pindexOldTip->GetHeight(), pindexOldTip->chainPower.chainWork.GetHex(), - pindexOldTip->chainPower.chainStake.GetHex()) + "\n" + - "- " + strprintf(_("New tip: %s, height %d, work %s\nstake %s"), - pindexMostWork->phashBlock->GetHex(), pindexMostWork->GetHeight(), pindexMostWork->chainPower.chainWork.GetHex(), - pindexMostWork->chainPower.chainStake.GetHex()) + "\n" + - "- " + strprintf(_("Fork point: %s %s, height %d"), - ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" + - _("Please help, human!"); - LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); - fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10); - uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); - StartShutdown(); - return false; - } + auto msg = strprintf(_( + "A block chain reorganization has been detected that would roll back %d blocks! " + "This is larger than the maximum of %d blocks, and so the node is shutting down for your safety." + ), reorgLength, MAX_REORG_LENGTH) + "\n\n" + + _("Reorganization details") + ":\n" + + "- " + strprintf(_("Current tip: %s, height %d, work %s\nstake %s"), + pindexOldTip->phashBlock->GetHex(), pindexOldTip->GetHeight(), pindexOldTip->chainPower.chainWork.GetHex(), + pindexOldTip->chainPower.chainStake.GetHex()) + "\n" + + "- " + strprintf(_("New tip: %s, height %d, work %s\nstake %s"), + pindexMostWork->phashBlock->GetHex(), pindexMostWork->GetHeight(), pindexMostWork->chainPower.chainWork.GetHex(), + pindexMostWork->chainPower.chainStake.GetHex()) + "\n" + + "- " + strprintf(_("Fork point: %s %s, height %d"), + ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" + + _("Please help, human!"); + LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); + fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10); + uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return false; } // Disconnect active blocks which are no longer in the best chain. From a766a16bb34ee2cb50fa657ab6cc2fa879a5db4b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 11 Apr 2019 19:13:37 +0800 Subject: [PATCH 3783/3904] fix better --- src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 47b089ca8..3d155feb3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4233,22 +4233,22 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo const CBlockIndex *pindexOldTip = chainActive.Tip(); const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork); + // stop trying to reorg if the reorged chain is before last notarized height. + // stay on the same chain tip! + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + if ( pindexFork->GetHeight() < notarizedht ) + { + fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); + return false; + } // - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks. // - If pindexMostWork is in a chain that doesn't have the same genesis block as our chain, // then pindexFork will be null, and we would need to remove the entire chain including // our genesis block. In practice this (probably) won't happen because of checks elsewhere. auto reorgLength = pindexOldTip ? pindexOldTip->GetHeight() - (pindexFork ? pindexFork->GetHeight() : -1) : 0; assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); - - int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - if ( pindexFork->GetHeight() < notarizedht ) - { - fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); - pindexFork = pindexOldTip; - } - - if (reorgLength > MAX_REORG_LENGTH) + if ( reorgLength > MAX_REORG_LENGTH) { auto msg = strprintf(_( "A block chain reorganization has been detected that would roll back %d blocks! " From 0ac427ee97842283e3369278f61ab998f12dfd8e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 00:28:35 -1100 Subject: [PATCH 3784/3904] Prices update --- src/komodo_defs.h | 3 ++ src/komodo_gateway.h | 92 +++++++++++++++++++++++++++++--------------- src/main.cpp | 2 + 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 31dde4a24..d1749def8 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -84,7 +84,10 @@ extern char NOTARYADDRS[64][64]; int tx_height( const uint256 &hash ); extern std::vector vWhiteListAddress; void komodo_netevent(std::vector payload); + +#define PRICES_SMOOTHWIDTH 1 int32_t komodo_priceind(char *symbol); void komodo_pricesinit(); +void komodo_pricesupdate(int32_t height,CBlock *pblock); #endif diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e128043ff..fac601fbc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1548,6 +1548,7 @@ void komodo_passport_iteration() } } + extern std::vector Mineropret; // opreturn data set by the data gathering code #define PRICES_ERRORRATE (COIN / 100) // maximum acceptable change, set at 1% #define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR @@ -1563,6 +1564,20 @@ const char *Forex[] = { "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" }; // must be in ECB list +struct komodo_extremeprice +{ + uint256 blockhash; + uint32_t pricebits,timestamp; + int32_t height; + int16_t dir,ind; +} ExtremePrice; + +struct komodo_priceinfo +{ + FILE *fp; + char symbol[64]; +} PRICES[KOMODO_MAXPRICES]; + uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][KOMODO_MAXPRICES];//4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)]; int64_t PriceMult[KOMODO_MAXPRICES]; int32_t komodo_cbopretsize(uint64_t flags); @@ -1575,26 +1590,33 @@ void komodo_PriceCache_shift() memcpy(PriceCache[0],Mineropret.data(),Mineropret.size()); } +int32_t _komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,CBlock *block) +{ + CTransaction tx; int32_t numvouts; std::vector vopret; + tx = block->vtx[0]; + numvouts = (int32_t)tx.vout.size(); + GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); + if ( vopret.size() >= PRICES_SIZEBIT0 ) + { + if ( seedp != 0 ) + memcpy(seedp,&block->hashMerkleRoot,sizeof(*seedp)); + memcpy(heightbits,vopret.data(),vopret.size()); + return((int32_t)(vopret.size()/sizeof(uint32_t))); + } + return(-1); +} + // komodo_heightpricebits() extracts the price data in the coinbase for nHeight int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight) { - CBlockIndex *pindex; CBlock block; CTransaction tx; int32_t numvouts; std::vector vopret; + CBlockIndex *pindex; CBlock block; if ( seedp != 0 ) *seedp = 0; if ( (pindex= komodo_chainactive(nHeight)) != 0 ) { if ( komodo_blockload(block,pindex) == 0 ) { - tx = block.vtx[0]; - numvouts = (int32_t)tx.vout.size(); - GetOpReturnData(tx.vout[numvouts-1].scriptPubKey,vopret); - if ( vopret.size() >= PRICES_SIZEBIT0 ) - { - if ( seedp != 0 ) - memcpy(seedp,&pindex->hashMerkleRoot,sizeof(*seedp)); - memcpy(heightbits,vopret.data(),vopret.size()); - return((int32_t)(vopret.size()/sizeof(uint32_t))); - } + return(_komodo_heightpricebits(seedp,heightbits,&block)); } } fprintf(stderr,"couldnt get pricebits for %d\n",nHeight); @@ -1722,13 +1744,6 @@ CScript komodo_mineropret(int32_t nHeight) */ -struct komodo_extremeprice -{ - uint256 blockhash; - uint32_t pricebits,timestamp; - int32_t height; - int16_t dir,ind; -} ExtremePrice; void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint256 blockhash,int32_t ind,uint32_t pricebits) { @@ -2529,7 +2544,7 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *rawprice void komodo_pricesinit() { - FILE *fp,*fp0 = 0; char symbol[65]; int32_t i; + int32_t i; boost::filesystem::path pricefname,pricesdir = GetDataDir() / "prices"; fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str()); if (!boost::filesystem::exists(pricesdir)) @@ -2537,23 +2552,38 @@ void komodo_pricesinit() boost::filesystem::create_directories(pricesdir); for (i=0; i 0 ) + if ( i > 0 && PRICES[0].fp != 0 ) { - fseek(fp0,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(uint32_t) * i,SEEK_SET); - fputc(0,fp0); - fflush(fp0); + fseek(PRICES[0].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(uint32_t) * i,SEEK_SET); + fputc(0,PRICES[0].fp); + fflush(PRICES[0].fp); } } } + +void komodo_pricesupdate(int32_t height,CBlock *pblock) +{ + static int numprices; + int32_t i; uint64_t seed; uint32_t rawprices[KOMODO_MAXPRICES]; + if ( numprices == 0 ) + numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); + if ( _komodo_heightpricebits(&seed,rawprices,pblock) == numprices ) + { + for (i=0; iGetHeight(),pblock); if ( ASSETCHAINS_SAPLING <= 0 && pindexNew->nTime > KOMODO_SAPLING_ACTIVATION - 24*3600 ) komodo_activate_sapling(pindexNew); return true; From c8d0608674d460bc9542a774891748594401afbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 00:35:13 -1100 Subject: [PATCH 3785/3904] PRICES[i]. --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fac601fbc..27eda9d5c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2556,7 +2556,7 @@ void komodo_pricesinit() break; if ( i == 0 ) strcpy(PRICES[i].symbol,"rawprices"); - pricefname = pricesdir / symbol; + pricefname = pricesdir / PRICES[i].symbol; PRICES[i].fp = fopen(pricefname.string().c_str(), "wb+"); fseek(PRICES[i].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * 3,SEEK_SET); fputc(0,PRICES[i].fp); From 348c7a970cc71d58055c6ed9d75af1de13e2a9c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 00:42:31 -1100 Subject: [PATCH 3786/3904] Update raw prices --- src/komodo_defs.h | 1 - src/komodo_gateway.h | 6 ++++++ src/main.cpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index d1749def8..ebfadee69 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -88,6 +88,5 @@ void komodo_netevent(std::vector payload); #define PRICES_SMOOTHWIDTH 1 int32_t komodo_priceind(char *symbol); void komodo_pricesinit(); -void komodo_pricesupdate(int32_t height,CBlock *pblock); #endif diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 27eda9d5c..625cdc6b5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2582,6 +2582,12 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) for (i=0; i Date: Thu, 11 Apr 2019 02:48:20 -1100 Subject: [PATCH 3787/3904] Calc correlated and smoothed each block --- src/komodo_gateway.h | 66 +++++++++++++++++++++++++++++++++++------- src/rpc/blockchain.cpp | 23 ++++++++------- 2 files changed, 68 insertions(+), 21 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 625cdc6b5..837a82570 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2516,9 +2516,11 @@ void smooth64(int64_t dest[],int64_t src[],int32_t width,int32_t smoothiters) } else memcpy(dest,src,width*sizeof(*dest)); } -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *rawprices,int32_t numprices) +// http://www.holoborodko.com/pavel/numerical-methods/noise-robust-smoothing-filter/ +//const int64_t coeffs[7] = { -2, 0, 18, 32, 18, 0, -2 }; + +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip) { - //const int64_t coeffs[7] = { -2, 0, 18, 32, 18, 0, -2 }; int32_t i; int64_t sum=0,nonzprice,price; if ( PRICES_DAYWINDOW < 2 ) return(0); @@ -2533,12 +2535,9 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *rawprice { if ( (price= correlated[i*cskip]) != 0 ) nonzprice = price; - //correlated2[i] = nonzprice / PRICES_DAYWINDOW; // reduce precision sum += nonzprice; } price = sum / PRICES_DAYWINDOW; - // improve smoothing with correlated2 processing - // price = smooth(correlated2,PRICES_DAYWINDOW,price/daywindow) * PRICES_DAYWINDOW; return(price); } @@ -2573,20 +2572,67 @@ void komodo_pricesinit() void komodo_pricesupdate(int32_t height,CBlock *pblock) { - static int numprices; - int32_t i; uint64_t seed; uint32_t rawprices[KOMODO_MAXPRICES]; + static int numprices; static uint32_t *ptr32,*ptr64; + int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[4]; + width = (2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) + { numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); + ptr32 = (uint32_t *)calloc(sizeof(uint32_t),numprices * width); + ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*3); + } if ( _komodo_heightpricebits(&seed,rawprices,pblock) == numprices ) { - for (i=0; i width ) + { + fseek(PRICES[0].fp,(height-width+1) * numprices * sizeof(uint32_t),SEEK_SET); + if ( fread(ptr32,sizeof(uint32_t),width*numprices,PRICES[0].fp) == width*numprices ) + { + rngval = seed; + for (ind=1; ind 0 ) + { + fseek(PRICES[ind].fp,height * sizeof(int64_t) * 3,SEEK_SET); + buf[0] = rawprices[ind]; + buf[1] = rawprices[0]; // timestamp + memcpy(&buf[2],&correlated,sizeof(correlated)); + if ( fwrite(buf,1,sizeof(buf),PRICES[ind].fp) != sizeof(buf) ) + fprintf(stderr,"error fwrite buf for ht.%d ind.%d\n",height,ind); + else + { + fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); + if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3,PRICES[ind].fp) == PRICES_DAYWINDOW*3 ) + { + if ( (smoothed= komodo_pricesmoothed(&ptr64[PRICES_DAYWINDOW*3-1],-3)) > 0 ) + { + fseek(PRICES[ind].fp,(height * 3 + 2) * sizeof(int64_t),SEEK_SET); + if ( fwrite(&smoothed,1,sizeof(smoothed),PRICES[ind].fp) != sizeof(smoothed) ) + fprintf(stderr,"error fwrite smoothed for ht.%d ind.%d\n",height,ind); + else + { + fprintf(stderr,"%.4f ",(double)smoothed/COIN); + fflush(PRICES[ind].fp); + } + } else fprintf(stderr,"error price_smoothed ht.%d ind.%d\n",height,ind); + } else fprintf(stderr,"error fread ptr64 for ht.%d ind.%d\n",height,ind); + } + } else fprintf(stderr,"error komodo_pricecorrelated for ht.%d ind.%d\n",height,ind); + } + fprintf(stderr,"height.%d\n",height); + } else fprintf(stderr,"error reading rawprices for ht.%d\n",height); + } } } else fprintf(stderr,"numprices mismatch\n"); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index fc9a71fe2..87f2658cd 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1176,7 +1176,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip,int64_t *correlated2,int32_t numprices); +int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip); int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1185,7 +1185,7 @@ int64_t komodo_pricemult(int32_t ind); int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) { - int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; int64_t *correlated2; uint32_t rawprices[1440*6],*ptr; + int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; uint32_t rawprices[1440*6],*ptr; //daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; //pricedata = (uint32_t *)calloc(sizeof(*prices)*3,numblocks + daywindow*2 + PRICES_SMOOTHWIDTH); width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; @@ -1205,20 +1205,21 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, ptr[1] = rawprices[0]; // timestamp } rngval = seed; - correlated2 = (int64_t *)calloc(sizeof(*correlated2),width); + //correlated2 = (int64_t *)calloc(sizeof(*correlated2),width); for (i=0; i2; i++,ht--) @@ -1287,14 +1288,14 @@ UniValue prices(const UniValue& params, bool fHelp) { offset = j*width + i; rngval = (rngval*11109 + 13849); - correlated2[i] = prices[offset]; + //correlated2[i] = prices[offset]; if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],1,0,PRICES_SMOOTHWIDTH)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); } for (i=0; i Date: Thu, 11 Apr 2019 02:49:33 -1100 Subject: [PATCH 3788/3904] Int64 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 837a82570..8bc639050 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2572,7 +2572,7 @@ void komodo_pricesinit() void komodo_pricesupdate(int32_t height,CBlock *pblock) { - static int numprices; static uint32_t *ptr32,*ptr64; + static int numprices; static uint32_t *ptr32; static int64_t *ptr64; int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[4]; width = (2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) From 1862321861e745a1dfa3ed50d5366e299cbfc1ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 02:52:49 -1100 Subject: [PATCH 3789/3904] Priceave --- src/komodo_gateway.h | 4 ++-- src/rpc/blockchain.cpp | 19 +++---------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8bc639050..ce89cea35 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2519,7 +2519,7 @@ void smooth64(int64_t dest[],int64_t src[],int32_t width,int32_t smoothiters) // http://www.holoborodko.com/pavel/numerical-methods/noise-robust-smoothing-filter/ //const int64_t coeffs[7] = { -2, 0, 18, 32, 18, 0, -2 }; -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip) +int64_t komodo_priceave(int64_t *correlated,int32_t cskip) { int32_t i; int64_t sum=0,nonzprice,price; if ( PRICES_DAYWINDOW < 2 ) @@ -2615,7 +2615,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3,PRICES[ind].fp) == PRICES_DAYWINDOW*3 ) { - if ( (smoothed= komodo_pricesmoothed(&ptr64[PRICES_DAYWINDOW*3-1],-3)) > 0 ) + if ( (smoothed= komodo_priceave(&ptr64[PRICES_DAYWINDOW*3-1],-3)) > 0 ) { fseek(PRICES[ind].fp,(height * 3 + 2) * sizeof(int64_t),SEEK_SET); if ( fwrite(&smoothed,1,sizeof(smoothed),PRICES[ind].fp) != sizeof(smoothed) ) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 87f2658cd..07cb8a26d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1176,7 +1176,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -int64_t komodo_pricesmoothed(int64_t *correlated,int32_t cskip); +int64_t komodo_priceave(int64_t *correlated,int32_t cskip); int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1186,8 +1186,6 @@ int64_t komodo_pricemult(int32_t ind); int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) { int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; uint32_t rawprices[1440*6],*ptr; - //daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; - //pricedata = (uint32_t *)calloc(sizeof(*prices)*3,numblocks + daywindow*2 + PRICES_SMOOTHWIDTH); width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; komodo_heightpricebits(&seed,rawprices,firstheight + numblocks - 1); if ( firstheight < width ) @@ -1205,21 +1203,15 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, ptr[1] = rawprices[0]; // timestamp } rngval = seed; - //correlated2 = (int64_t *)calloc(sizeof(*correlated2),width); for (i=0; i2; i++,ht--) { @@ -1288,14 +1278,13 @@ UniValue prices(const UniValue& params, bool fHelp) { offset = j*width + i; rngval = (rngval*11109 + 13849); - //correlated2[i] = prices[offset]; if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],1,0,PRICES_SMOOTHWIDTH)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); } for (i=0; i Date: Thu, 11 Apr 2019 21:59:04 +0800 Subject: [PATCH 3790/3904] add node ban for pushing attacking chain --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3d155feb3..5964b33d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3904,7 +3904,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); - return(false); + return state.DoS(100, error("AcceptBlock(): DisconnectTip trying to disconnect notarized blockht.%d",(int32_t)pindexDelete->GetHeight()), + REJECT_INVALID, "past-notarized-height"); } } // Apply the block atomically to the chain state. @@ -4240,7 +4241,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); - return false; + return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht), + REJECT_INVALID, "past-notarized-height"); } // - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks. // - If pindexMostWork is in a chain that doesn't have the same genesis block as our chain, From 11d424de8167c9229844b7bdd3957401680cb07e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 03:20:04 -1100 Subject: [PATCH 3791/3904] +print --- src/komodo_gateway.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ce89cea35..5d96eea06 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2580,12 +2580,13 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); ptr32 = (uint32_t *)calloc(sizeof(uint32_t),numprices * width); ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*3); + fprintf(stderr,"prices update: numprices.%d %p %p\n",numprices,ptr32,ptr64); } if ( _komodo_heightpricebits(&seed,rawprices,pblock) == numprices ) { - //for (i=0; i Date: Thu, 11 Apr 2019 03:23:38 -1100 Subject: [PATCH 3792/3904] Open files always --- src/komodo_gateway.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5d96eea06..7442bc2eb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2543,30 +2543,31 @@ int64_t komodo_priceave(int64_t *correlated,int32_t cskip) void komodo_pricesinit() { - int32_t i; + int32_t i,createflag = 0; boost::filesystem::path pricefname,pricesdir = GetDataDir() / "prices"; fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str()); if (!boost::filesystem::exists(pricesdir)) + boost::filesystem::create_directories(pricesdir), createflag = 1; + for (i=0; i 0 && PRICES[0].fp != 0 ) - { - fseek(PRICES[0].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(uint32_t) * i,SEEK_SET); - fputc(0,PRICES[0].fp); - fflush(PRICES[0].fp); - } + } + if ( i > 0 && PRICES[0].fp != 0 && createflag != 0 ) + { + fseek(PRICES[0].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(uint32_t) * i,SEEK_SET); + fputc(0,PRICES[0].fp); + fflush(PRICES[0].fp); } } From 900ba27f11878e509fb627e78cf46d101d35e0e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 03:24:38 -1100 Subject: [PATCH 3793/3904] Ind --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7442bc2eb..a3d3628b3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2585,8 +2585,8 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) } if ( _komodo_heightpricebits(&seed,rawprices,pblock) == numprices ) { - for (i=0; i Date: Thu, 11 Apr 2019 03:34:39 -1100 Subject: [PATCH 3794/3904] Null pindexFork case --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 593a41e3f..0ebc5c892 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4241,7 +4241,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // stay on the same chain tip! int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - if ( pindexFork->GetHeight() < notarizedht ) + if ( pindexFork != 0 && pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht), From 017100bc96b1ac086dd587c7a16538e9ede9a095 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 03:35:28 -1100 Subject: [PATCH 3795/3904] pindexFork != 0 && --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 593a41e3f..0ebc5c892 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4241,7 +4241,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // stay on the same chain tip! int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - if ( pindexFork->GetHeight() < notarizedht ) + if ( pindexFork != 0 && pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht), From a767d4f03f6c72f4a6e853afa136abf3a14000bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 03:35:52 -1100 Subject: [PATCH 3796/3904] pindexFork != 0 && --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 593a41e3f..0ebc5c892 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4241,7 +4241,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // stay on the same chain tip! int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - if ( pindexFork->GetHeight() < notarizedht ) + if ( pindexFork != 0 && pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht), From 9d0cc33d147f2fc542ab3949d84a4ac965672a69 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 03:36:20 -1100 Subject: [PATCH 3797/3904] pindexFork != 0 && --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 593a41e3f..0ebc5c892 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4241,7 +4241,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // stay on the same chain tip! int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - if ( pindexFork->GetHeight() < notarizedht ) + if ( pindexFork != 0 && pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht), From 4f478650b89d1a22aa1760a8bc971454859833d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 03:46:04 -1100 Subject: [PATCH 3798/3904] +print --- src/komodo_gateway.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a3d3628b3..86ab82583 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2356,6 +2356,9 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int mult = PriceMult[ind]; if ( nonzprices != 0 ) memset(nonzprices,0,sizeof(*nonzprices)*PRICES_DAYWINDOW); + for (i=0; i width ) + if ( height > PRICES_DAYWINDOW ) { fseek(PRICES[0].fp,(height-width+1) * numprices * sizeof(uint32_t),SEEK_SET); if ( fread(ptr32,sizeof(uint32_t),width*numprices,PRICES[0].fp) == width*numprices ) @@ -2612,7 +2615,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) memcpy(&buf[2],&correlated,sizeof(correlated)); if ( fwrite(buf,1,sizeof(buf),PRICES[ind].fp) != sizeof(buf) ) fprintf(stderr,"error fwrite buf for ht.%d ind.%d\n",height,ind); - else + else if ( height > PRICES_DAYWINDOW*2 ) { fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3,PRICES[ind].fp) == PRICES_DAYWINDOW*3 ) From 1065ccd67af9f6f8d6412758674a5d8c06a3d9ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 04:05:04 -1100 Subject: [PATCH 3799/3904] Sort trick --- src/komodo_gateway.h | 71 ++++++++++++++++++++++++++++++++++++------ src/rpc/blockchain.cpp | 14 ++++++--- 2 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 86ab82583..ee7480c48 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2353,12 +2353,12 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice; if ( PRICES_DAYWINDOW < 2 || ind >= KOMODO_MAXPRICES ) return(-1); - mult = PriceMult[ind]; + mult = komodo_pricemult(ind); if ( nonzprices != 0 ) memset(nonzprices,0,sizeof(*nonzprices)*PRICES_DAYWINDOW); - for (i=0; i *(int64_t *)b) return 1; + return 0; +} + +static int64_t sort64(int64_t *l, int32_t llen) +{ + qsort(l,llen,sizeof(uint64_t),cmp_llu); +} + +static int revcmp_llu(const void *a, const void*b) +{ + if(*(int64_t *)a < *(int64_t *)b) return 1; + if(*(int64_t *)a > *(int64_t *)b) return -1; + return 0; +} + +static int64_t revsort64(int64_t *l, int32_t llen) +{ + heapsort(l,llen,sizeof(uint64_t),cmp_llu); +} + +int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) +{ + int32_t i,dir=0; int64_t sum=0,nonzprice,price,halfave,decayprice; if ( PRICES_DAYWINDOW < 2 ) return(0); for (i=0; i price ) // rising prices + { + sort64(buf,PRICES_DAYWINDOW); + decayprice = buf[0]; + for (i=0; i %.4f\n",(double)halfprice/COIN,(double)price/COIN,(double)decayprice/COIN); + } + else + { + revsort64(buf,PRICES_DAYWINDOW); + decayprice = buf[0]; + for (i=0; i %.4f\n",(double)halfprice/COIN,(double)price/COIN,(double)decayprice/COIN); + } + return(decayprice); } void komodo_pricesinit() @@ -2576,7 +2626,7 @@ void komodo_pricesinit() void komodo_pricesupdate(int32_t height,CBlock *pblock) { - static int numprices; static uint32_t *ptr32; static int64_t *ptr64; + static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf; int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[4]; width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) @@ -2584,6 +2634,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); ptr32 = (uint32_t *)calloc(sizeof(uint32_t),numprices * width); ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*3); + tmpbuf = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW); fprintf(stderr,"prices update: numprices.%d %p %p\n",numprices,ptr32,ptr64); } if ( _komodo_heightpricebits(&seed,rawprices,pblock) == numprices ) @@ -2620,7 +2671,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3,PRICES[ind].fp) == PRICES_DAYWINDOW*3 ) { - if ( (smoothed= komodo_priceave(&ptr64[PRICES_DAYWINDOW*3-1],-3)) > 0 ) + if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[PRICES_DAYWINDOW*3-1],-3)) > 0 ) { fseek(PRICES[ind].fp,(height * 3 + 2) * sizeof(int64_t),SEEK_SET); if ( fwrite(&smoothed,1,sizeof(smoothed),PRICES[ind].fp) != sizeof(smoothed) ) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 07cb8a26d..0d1e7acb3 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1176,7 +1176,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -int64_t komodo_priceave(int64_t *correlated,int32_t cskip); +int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip); int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); int32_t komodo_nextheight(); uint32_t komodo_heightstamp(int32_t height); @@ -1185,7 +1185,7 @@ int64_t komodo_pricemult(int32_t ind); int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) { - int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; uint32_t rawprices[1440*6],*ptr; + int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; uint32_t rawprices[1440*6],*ptr; int64_t *tmpbuf; width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; komodo_heightpricebits(&seed,rawprices,firstheight + numblocks - 1); if ( firstheight < width ) @@ -1210,8 +1210,10 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, if ( (pricedata[i*3+1]= komodo_pricecorrelated(rngval,ind,(uint32_t *)&pricedata[i*3],6,0,PRICES_SMOOTHWIDTH)) < 0 ) return(-3); } + tmpbuf = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW); for (i=0; i Date: Thu, 11 Apr 2019 04:15:41 -1100 Subject: [PATCH 3800/3904] Fix nondeterministic qsorts --- src/cc/dilithium.c | 5 +++-- src/cryptoconditions/src/asn/constr_SET_OF.c | 3 +++ src/cryptoconditions/src/threshold.c | 15 ++++++++++++--- src/komodo_gateway.h | 18 +++++++++++------- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 7ba522f0f..087dfd9f5 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2717,8 +2717,9 @@ int64_t *tred, *tadd, *tmul, *tround, *tsample, *tpack, *tshake; static int cmp_llu(const void *a, const void*b) { if(*(int64_t *)a < *(int64_t *)b) return -1; - if(*(int64_t *)a > *(int64_t *)b) return 1; - return 0; + else if(*(int64_t *)a > *(int64_t *)b) return 1; + else if ( (uint64_t)a < (uint64_t)b ) return -1; + else return 1; } static int64_t median(int64_t *l, size_t llen) diff --git a/src/cryptoconditions/src/asn/constr_SET_OF.c b/src/cryptoconditions/src/asn/constr_SET_OF.c index 2dbc6e518..25e80cc30 100644 --- a/src/cryptoconditions/src/asn/constr_SET_OF.c +++ b/src/cryptoconditions/src/asn/constr_SET_OF.c @@ -301,6 +301,9 @@ static int _el_buf_cmp(const void *ap, const void *bp) { ret = -1; else if(a->length > b->length) ret = 1; + else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism + ret = -1; + else ret = 1; } return ret; diff --git a/src/cryptoconditions/src/threshold.c b/src/cryptoconditions/src/threshold.c index 82f0e1b0a..7fc801897 100644 --- a/src/cryptoconditions/src/threshold.c +++ b/src/cryptoconditions/src/threshold.c @@ -35,8 +35,15 @@ static uint32_t thresholdSubtypes(const CC *cond) { } -static int cmpCostDesc(const void *a, const void *b) { - return (int) ( *(unsigned long*)b - *(unsigned long*)a ); +static int cmpCostDesc(const void *a, const void *b) +{ + int retval; + retval = (int) ( *(unsigned long*)b - *(unsigned long*)a ); + if ( retval != 0 ) + return(retval); + else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism + return(-1); + else return(1); } @@ -79,7 +86,9 @@ static int cmpConditionBin(const void *a, const void *b) { if (ret == 0) return r0.encoded < r1.encoded ? -1 : 1; - return 0; + else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism + return(-1); + else return(1); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ee7480c48..c7a203c3e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2524,8 +2524,10 @@ void smooth64(int64_t dest[],int64_t src[],int32_t width,int32_t smoothiters) static int cmp_llu(const void *a, const void*b) { if(*(int64_t *)a < *(int64_t *)b) return -1; - if(*(int64_t *)a > *(int64_t *)b) return 1; - return 0; + else if(*(int64_t *)a > *(int64_t *)b) return 1; + else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism + return(-1); + else return(1); } static int64_t sort64(int64_t *l, int32_t llen) @@ -2536,13 +2538,15 @@ static int64_t sort64(int64_t *l, int32_t llen) static int revcmp_llu(const void *a, const void*b) { if(*(int64_t *)a < *(int64_t *)b) return 1; - if(*(int64_t *)a > *(int64_t *)b) return -1; - return 0; + else if(*(int64_t *)a > *(int64_t *)b) return -1; + else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism + return(-1); + else return(1); } static int64_t revsort64(int64_t *l, int32_t llen) { - heapsort(l,llen,sizeof(uint64_t),cmp_llu); + qsort(l,llen,sizeof(uint64_t),revcmp_llu); } int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) @@ -2575,7 +2579,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) decayprice = buf[0]; for (i=0; i %.4f\n",(double)halfprice/COIN,(double)price/COIN,(double)decayprice/COIN); @@ -2586,7 +2590,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) decayprice = buf[0]; for (i=0; i %.4f\n",(double)halfprice/COIN,(double)price/COIN,(double)decayprice/COIN); From 91dacca39b9a0062f422694bae4572ee819c5a7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 04:15:52 -1100 Subject: [PATCH 3801/3904] Fix qsorts --- src/pow/tromp/equi.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pow/tromp/equi.h b/src/pow/tromp/equi.h index f6d8803c2..84e566e1a 100644 --- a/src/pow/tromp/equi.h +++ b/src/pow/tromp/equi.h @@ -75,8 +75,14 @@ int verifyrec(const crypto_generichash_blake2b_state *ctx, u32 *indices, uchar * } int compu32(const void *pa, const void *pb) { + int32_t retval; u32 a = *(u32 *)pa, b = *(u32 *)pb; - return a Date: Thu, 11 Apr 2019 04:17:55 -1100 Subject: [PATCH 3802/3904] Fix --- src/komodo_gateway.h | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c7a203c3e..45e8b7fe9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2574,27 +2574,15 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) if ( halfave == price ) return(price); else if ( halfave > price ) // rising prices - { sort64(buf,PRICES_DAYWINDOW); - decayprice = buf[0]; - for (i=0; i %.4f\n",(double)halfprice/COIN,(double)price/COIN,(double)decayprice/COIN); - } - else + else revsort64(buf,PRICES_DAYWINDOW); + decayprice = buf[0]; + for (i=0; i %.4f\n",(double)halfprice/COIN,(double)price/COIN,(double)decayprice/COIN); + decayprice = ((decayprice * 9) + (buf[i] * 1)) / 10; + fprintf(stderr,"%.4f ",(double)buf[i]/COIN); } + fprintf(stderr,"%ssort half %.4f vs %.4f -> %.4f\n",halfave Date: Thu, 11 Apr 2019 04:22:23 -1100 Subject: [PATCH 3803/3904] Off by 1 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 45e8b7fe9..953947072 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2661,7 +2661,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) else if ( height > PRICES_DAYWINDOW*2 ) { fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); - if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3,PRICES[ind].fp) == PRICES_DAYWINDOW*3 ) + if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3-1,PRICES[ind].fp) == PRICES_DAYWINDOW*3-1 ) { if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[PRICES_DAYWINDOW*3-1],-3)) > 0 ) { From 00f7ff6f41e9c93f2af745fdb081953f1183b61a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 04:27:10 -1100 Subject: [PATCH 3804/3904] Another off by 1 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 953947072..d3a9cb350 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2663,7 +2663,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3-1,PRICES[ind].fp) == PRICES_DAYWINDOW*3-1 ) { - if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[PRICES_DAYWINDOW*3-1],-3)) > 0 ) + if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[PRICES_DAYWINDOW*3-2],-3)) > 0 ) { fseek(PRICES[ind].fp,(height * 3 + 2) * sizeof(int64_t),SEEK_SET); if ( fwrite(&smoothed,1,sizeof(smoothed),PRICES[ind].fp) != sizeof(smoothed) ) From ad9adcf27382187c84abf98b090f5fda3bbec12b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 04:30:45 -1100 Subject: [PATCH 3805/3904] .8f --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d3a9cb350..92296a66c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2670,7 +2670,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fprintf(stderr,"error fwrite smoothed for ht.%d ind.%d\n",height,ind); else { - fprintf(stderr,"%.4f ",(double)smoothed/COIN); + fprintf(stderr,"%.8f ",(double)smoothed/COIN); fflush(PRICES[ind].fp); } } else fprintf(stderr,"error price_smoothed ht.%d ind.%d\n",height,ind); From 3898bb8b2aef62f8e6bf862d739e845cee58e266 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 04:33:12 -1100 Subject: [PATCH 3806/3904] +print --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 92296a66c..0de71291f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2670,7 +2670,8 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fprintf(stderr,"error fwrite smoothed for ht.%d ind.%d\n",height,ind); else { - fprintf(stderr,"%.8f ",(double)smoothed/COIN); + if ( ind == 36 ) + fprintf(stderr,"(%.8f %.8f) ",(double)ptr64[PRICES_DAYWINDOW*3-2]/COIN,(double)smoothed/COIN); fflush(PRICES[ind].fp); } } else fprintf(stderr,"error price_smoothed ht.%d ind.%d\n",height,ind); From 4255005f4de9980c4f5a62d2a743c084d1e79b1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 04:42:00 -1100 Subject: [PATCH 3807/3904] Tweak prices --- src/komodo_gateway.h | 13 +++++++------ src/rpc/blockchain.cpp | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0de71291f..cf6f13174 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2565,11 +2565,12 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) { if ( (price= correlated[i*cskip]) != 0 ) nonzprice = price; - buf[i] = nonzprice; + buf[PRICES_DAYWINDOW+i] = nonzprice; sum += nonzprice; if ( i == PRICES_DAYWINDOW/2 ) halfave = (sum / (PRICES_DAYWINDOW/2)); } + memcp(buf,&buf[PRICES_DAYWINDOW],PRICES_DAYWINDOW*sizeof(*buf)); price = sum / PRICES_DAYWINDOW; if ( halfave == price ) return(price); @@ -2579,11 +2580,11 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) decayprice = buf[0]; for (i=0; i %.4f\n",halfave %.4f\n",halfave Date: Thu, 11 Apr 2019 04:42:47 -1100 Subject: [PATCH 3808/3904] memcpy --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cf6f13174..5641a1ffc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2570,7 +2570,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) if ( i == PRICES_DAYWINDOW/2 ) halfave = (sum / (PRICES_DAYWINDOW/2)); } - memcp(buf,&buf[PRICES_DAYWINDOW],PRICES_DAYWINDOW*sizeof(*buf)); + memcpy(buf,&buf[PRICES_DAYWINDOW],PRICES_DAYWINDOW*sizeof(*buf)); price = sum / PRICES_DAYWINDOW; if ( halfave == price ) return(price); From 19b8685c211620e3a1cb0137afbf50dff56270dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 04:48:31 -1100 Subject: [PATCH 3809/3904] 19 --- src/komodo_gateway.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5641a1ffc..f8bfaf048 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2551,7 +2551,7 @@ static int64_t revsort64(int64_t *l, int32_t llen) int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) { - int32_t i,dir=0; int64_t sum=0,nonzprice,price,halfave,decayprice; + int32_t i,dir=0; int64_t sum=0,nonzprice,price,halfave,thirdave,fourthave,decayprice; if ( PRICES_DAYWINDOW < 2 ) return(0); for (i=0; i %.4f\n",halfave Date: Thu, 11 Apr 2019 04:49:43 -1100 Subject: [PATCH 3810/3904] Halfave --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f8bfaf048..92e0226b4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2588,7 +2588,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) //fprintf(stderr,"%.4f ",(double)buf[i]/COIN); } //fprintf(stderr,"%ssort half %.4f vs %.4f -> %.4f\n",halfave Date: Thu, 11 Apr 2019 04:55:56 -1100 Subject: [PATCH 3811/3904] +print --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 92e0226b4..555696d56 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2587,7 +2587,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) decayprice = ((decayprice * 97) + (buf[i] * 3)) / 100; //fprintf(stderr,"%.4f ",(double)buf[i]/COIN); } - //fprintf(stderr,"%ssort half %.4f vs %.4f -> %.4f\n",halfave %.8f\n",halfave Date: Thu, 11 Apr 2019 04:59:59 -1100 Subject: [PATCH 3812/3904] /19 --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 555696d56..3c7027e13 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2587,7 +2587,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) decayprice = ((decayprice * 97) + (buf[i] * 3)) / 100; //fprintf(stderr,"%.4f ",(double)buf[i]/COIN); } - fprintf(stderr,"%ssort half %.8f %.8f %.8f %.8f %.8f %.8f -> %.8f\n",halfave %.8f\n",halfave Date: Thu, 11 Apr 2019 08:07:14 -1100 Subject: [PATCH 3813/3904] Smaller --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3c7027e13..a4a1b78e3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2576,7 +2576,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) } memcpy(buf,&buf[PRICES_DAYWINDOW],PRICES_DAYWINDOW*sizeof(*buf)); price = sum / PRICES_DAYWINDOW; - if ( halfave == price ) + //if ( halfave == price ) return(price); else if ( halfave > price ) // rising prices sort64(buf,PRICES_DAYWINDOW); From 11694fc7e74dfb1d62937aadf81eb303059ec5b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 08:08:09 -1100 Subject: [PATCH 3814/3904] return(price); --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a4a1b78e3..6bd03ccfb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2576,7 +2576,8 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) } memcpy(buf,&buf[PRICES_DAYWINDOW],PRICES_DAYWINDOW*sizeof(*buf)); price = sum / PRICES_DAYWINDOW; - //if ( halfave == price ) + return(price); + if ( halfave == price ) return(price); else if ( halfave > price ) // rising prices sort64(buf,PRICES_DAYWINDOW); From 76e3a7f283d84ec84a456aae8a16d5dd6fe9e1a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 12 Apr 2019 13:55:06 +0800 Subject: [PATCH 3815/3904] skip dpow check on everything but ProcessNewBlock. --- src/init.cpp | 2 +- src/main.cpp | 12 ++++++------ src/main.h | 2 +- src/rpc/blockchain.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 24b32a720..042d1d9fd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1886,7 +1886,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) uiInterface.InitMessage(_("Activating best chain...")); // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; - if ( !ActivateBestChain(state)) + if ( !ActivateBestChain(true,state)) strErrors << "Failed to connect best block"; } std::vector vImportFiles; diff --git a/src/main.cpp b/src/main.cpp index 0ebc5c892..f1e586337 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4231,7 +4231,7 @@ static void PruneBlockIndexCandidates() { * Try to make some progress towards making pindexMostWork the active block. * pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork. */ -static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) { +static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) { AssertLockHeld(cs_main); bool fInvalidFound = false; const CBlockIndex *pindexOldTip = chainActive.Tip(); @@ -4241,7 +4241,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // stay on the same chain tip! int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - if ( pindexFork != 0 && pindexFork->GetHeight() < notarizedht ) + if ( !fSkipdpow && pindexFork != 0 && pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht), @@ -4366,7 +4366,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo * or an activated best chain. pblock is either NULL or a pointer to a block * that is already loaded (to avoid loading it again from disk). */ -bool ActivateBestChain(CValidationState &state, CBlock *pblock) { +bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock) { CBlockIndex *pindexNewTip = NULL; CBlockIndex *pindexMostWork = NULL; const CChainParams& chainParams = Params(); @@ -4382,7 +4382,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { if (pindexMostWork == NULL || pindexMostWork == chainActive.Tip()) return true; - if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) + if (!ActivateBestChainStep(fSkipdpow, state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) return false; pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); @@ -5542,7 +5542,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo //else fprintf(stderr,"added block %s %p\n",pindex->GetBlockHash().ToString().c_str(),pindex->pprev); } - if (futureblock == 0 && !ActivateBestChain(state, pblock)) + if (futureblock == 0 && !ActivateBestChain(false, state, pblock)) return error("%s: ActivateBestChain failed", __func__); //fprintf(stderr,"finished ProcessBlock %d\n",(int32_t)chainActive.LastTip()->GetHeight()); @@ -6319,7 +6319,7 @@ bool InitBlockIndex() { return error("LoadBlockIndex(): couldnt add to block index"); if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("LoadBlockIndex(): genesis block not accepted"); - if (!ActivateBestChain(state, &block)) + if (!ActivateBestChain(true, state, &block)) return error("LoadBlockIndex(): genesis block cannot be activated"); // Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data return FlushStateToDisk(state, FLUSH_STATE_ALWAYS); diff --git a/src/main.h b/src/main.h index 0cdb0b7a8..e5f042c31 100644 --- a/src/main.h +++ b/src/main.h @@ -252,7 +252,7 @@ std::string GetWarnings(const std::string& strFor); /** Retrieve a transaction (from memory pool, or from disk, if possible) */ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false); /** Find the best known block, and make it the tip of the block chain */ -bool ActivateBestChain(CValidationState &state, CBlock *pblock = NULL); +bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock = NULL); CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); /** diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 78b7e45ef..83fcd8cad 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1879,7 +1879,7 @@ UniValue invalidateblock(const UniValue& params, bool fHelp) } if (state.IsValid()) { - ActivateBestChain(state); + ActivateBestChain(true,state); } if (!state.IsValid()) { @@ -1918,7 +1918,7 @@ UniValue reconsiderblock(const UniValue& params, bool fHelp) } if (state.IsValid()) { - ActivateBestChain(state); + ActivateBestChain(true,state); } if (!state.IsValid()) { From adf03266d4d87e6f38de7a798f93823113441d06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 19:48:16 -1100 Subject: [PATCH 3816/3904] Revert qsort changes --- src/cryptoconditions/src/asn/constr_SET_OF.c | 6 +++--- src/cryptoconditions/src/threshold.c | 9 +++++---- src/pow/tromp/equi.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cryptoconditions/src/asn/constr_SET_OF.c b/src/cryptoconditions/src/asn/constr_SET_OF.c index 25e80cc30..90e1b5539 100644 --- a/src/cryptoconditions/src/asn/constr_SET_OF.c +++ b/src/cryptoconditions/src/asn/constr_SET_OF.c @@ -301,9 +301,9 @@ static int _el_buf_cmp(const void *ap, const void *bp) { ret = -1; else if(a->length > b->length) ret = 1; - else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism - ret = -1; - else ret = 1; + // else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism + // ret = -1; + // else ret = 1; } return ret; diff --git a/src/cryptoconditions/src/threshold.c b/src/cryptoconditions/src/threshold.c index 7fc801897..ec0570850 100644 --- a/src/cryptoconditions/src/threshold.c +++ b/src/cryptoconditions/src/threshold.c @@ -39,7 +39,7 @@ static int cmpCostDesc(const void *a, const void *b) { int retval; retval = (int) ( *(unsigned long*)b - *(unsigned long*)a ); - if ( retval != 0 ) + //if ( retval != 0 ) return(retval); else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism return(-1); @@ -86,9 +86,10 @@ static int cmpConditionBin(const void *a, const void *b) { if (ret == 0) return r0.encoded < r1.encoded ? -1 : 1; - else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism - return(-1); - else return(1); + //else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism + // return(-1); + //else return(1); + return(0); } diff --git a/src/pow/tromp/equi.h b/src/pow/tromp/equi.h index 84e566e1a..0584cd6cc 100644 --- a/src/pow/tromp/equi.h +++ b/src/pow/tromp/equi.h @@ -78,7 +78,7 @@ int compu32(const void *pa, const void *pb) { int32_t retval; u32 a = *(u32 *)pa, b = *(u32 *)pb; retval = a Date: Thu, 11 Apr 2019 19:51:13 -1100 Subject: [PATCH 3817/3904] Another qsort revert --- src/cc/dilithium.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 087dfd9f5..5044edf94 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2718,8 +2718,9 @@ static int cmp_llu(const void *a, const void*b) { if(*(int64_t *)a < *(int64_t *)b) return -1; else if(*(int64_t *)a > *(int64_t *)b) return 1; - else if ( (uint64_t)a < (uint64_t)b ) return -1; - else return 1; + //else if ( (uint64_t)a < (uint64_t)b ) return -1; + //else return 1; + return(0); } static int64_t median(int64_t *l, size_t llen) From 37efdeca2eea463bba1041b908cb789fa032f899 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 19:56:40 -1100 Subject: [PATCH 3818/3904] Syntax --- src/pow/tromp/equi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pow/tromp/equi.h b/src/pow/tromp/equi.h index 0584cd6cc..b474194fc 100644 --- a/src/pow/tromp/equi.h +++ b/src/pow/tromp/equi.h @@ -78,11 +78,12 @@ int compu32(const void *pa, const void *pb) { int32_t retval; u32 a = *(u32 *)pa, b = *(u32 *)pb; retval = a Date: Thu, 11 Apr 2019 20:00:40 -1100 Subject: [PATCH 3819/3904] Fix syntax --- src/cryptoconditions/src/threshold.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cryptoconditions/src/threshold.c b/src/cryptoconditions/src/threshold.c index ec0570850..9547f4f8c 100644 --- a/src/cryptoconditions/src/threshold.c +++ b/src/cryptoconditions/src/threshold.c @@ -39,11 +39,12 @@ static int cmpCostDesc(const void *a, const void *b) { int retval; retval = (int) ( *(unsigned long*)b - *(unsigned long*)a ); - //if ( retval != 0 ) + return(retval); + /*if ( retval != 0 ) return(retval); else if ( (uint64_t)a < (uint64_t)b ) // jl777 prevent nondeterminism return(-1); - else return(1); + else return(1);*/ } From 46e282d55d523157bedbacd1cfe3e2c7ed5ce1db Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 20:38:47 -1100 Subject: [PATCH 3820/3904] +print --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 043d7282e..cb7336b82 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1811,6 +1811,7 @@ void komodo_args(char *argv0) ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); + fprintf(stderr,"ASSETCHAINS_CBOPRET.%llx\n",(long long)ASSETCHAINS_CBOPRET); if ( ASSETCHAINS_CBOPRET != 0 ) { SplitStr(GetArg("-ac_prices",""), ASSETCHAINS_PRICES); From 8a2a0985b0ffaa886d9aafbb289d54136266cec7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 20:50:49 -1100 Subject: [PATCH 3821/3904] +prints --- src/komodo_gateway.h | 24 +++++++++++------------- src/komodo_utils.h | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6bd03ccfb..8428c4a07 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1555,6 +1555,7 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define KOMODO_LOCALPRICE_CACHESIZE 13 #define KOMODO_MAXPRICES 2048 #define PRICES_SMOOTHWIDTH 1 +#define PRICES_MAXDATAPOINTS 3 #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) @@ -1747,6 +1748,7 @@ CScript komodo_mineropret(int32_t nHeight) void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint256 blockhash,int32_t ind,uint32_t pricebits) { + fprintf(stderr,"ExtremePrice dir.%d ht.%d ind.%d cmpbits.%u\n",dir,height,ind,cmpbits); ExtremePrice.dir = dir; ExtremePrice.height = height; ExtremePrice.blockhash = blockhash; @@ -2226,6 +2228,7 @@ void komodo_cbopretupdate(int32_t forceflag) memcpy(Mineropret.data(),PriceCache[0],size); if ( ExtremePrice.dir != 0 && ExtremePrice.ind > 0 && ExtremePrice.ind < size/sizeof(uint32_t) && now < ExtremePrice.timestamp+3600 ) { + fprintf(stderr,"cmp dir.%d PriceCache[0][ExtremePrice.ind] %u >= %u ExtremePrice.pricebits\n",ExtremePrice.dir,PriceCache[0][ExtremePrice.ind],ExtremePrice.pricebits); if ( (ExtremePrice.dir > 0 && PriceCache[0][ExtremePrice.ind] >= ExtremePrice.pricebits) || (ExtremePrice.dir < 0 && PriceCache[0][ExtremePrice.ind] <= ExtremePrice.pricebits) ) { fprintf(stderr,"future price is close enough to allow approving previously rejected block ind.%d %u vs %u\n",ExtremePrice.ind,PriceCache[0][ExtremePrice.ind],ExtremePrice.pricebits); @@ -2609,7 +2612,7 @@ void komodo_pricesinit() PRICES[i].fp = fopen(pricefname.string().c_str(), createflag != 0 ? "wb+" : "rb+"); if ( createflag != 0 ) { - fseek(PRICES[i].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * 3,SEEK_SET); + fseek(PRICES[i].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); fputc(0,PRICES[i].fp); fflush(PRICES[i].fp); } @@ -2631,7 +2634,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) { numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); ptr32 = (uint32_t *)calloc(sizeof(uint32_t),numprices * width); - ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*3); + ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS); tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW); fprintf(stderr,"prices update: numprices.%d %p %p\n",numprices,ptr32,ptr64); } @@ -2658,7 +2661,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) rngval = (rngval*11109 + 13849); if ( (correlated= komodo_pricecorrelated(rngval,ind,&ptr32[offset],-numprices,0,PRICES_SMOOTHWIDTH)) > 0 ) { - fseek(PRICES[ind].fp,height * sizeof(int64_t) * 3,SEEK_SET); + fseek(PRICES[ind].fp,height * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); buf[0] = rawprices[ind]; buf[1] = rawprices[0]; // timestamp memcpy(&buf[2],&correlated,sizeof(correlated)); @@ -2666,20 +2669,15 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fprintf(stderr,"error fwrite buf for ht.%d ind.%d\n",height,ind); else if ( height > PRICES_DAYWINDOW*2 ) { - fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); - if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3-1,PRICES[ind].fp) == PRICES_DAYWINDOW*3-1 ) + fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * PRICES_MAXDATAPOINTS * sizeof(int64_t),SEEK_SET); + if ( fread(ptr64,sizeof(int64_t),(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+2,PRICES[ind].fp) == (PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+2 ) { - if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[PRICES_DAYWINDOW*3-2],-3)) > 0 ) + if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+1],-PRICES_MAXDATAPOINTS)) > 0 ) { - fseek(PRICES[ind].fp,(height * 3 + 2) * sizeof(int64_t),SEEK_SET); + fseek(PRICES[ind].fp,(height * PRICES_MAXDATAPOINTS + 2) * sizeof(int64_t),SEEK_SET); if ( fwrite(&smoothed,1,sizeof(smoothed),PRICES[ind].fp) != sizeof(smoothed) ) fprintf(stderr,"error fwrite smoothed for ht.%d ind.%d\n",height,ind); - else - { - if ( ind == 36 ) - fprintf(stderr,"(%.8f %.8f) ",(double)ptr64[PRICES_DAYWINDOW*3-2]/COIN,(double)smoothed/COIN); - fflush(PRICES[ind].fp); - } + else fflush(PRICES[ind].fp); } else fprintf(stderr,"error price_smoothed ht.%d ind.%d\n",height,ind); } else fprintf(stderr,"error fread ptr64 for ht.%d ind.%d\n",height,ind); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index cb7336b82..1900df432 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1811,7 +1811,7 @@ void komodo_args(char *argv0) ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); - fprintf(stderr,"ASSETCHAINS_CBOPRET.%llx\n",(long long)ASSETCHAINS_CBOPRET); + //fprintf(stderr,"ASSETCHAINS_CBOPRET.%llx\n",(long long)ASSETCHAINS_CBOPRET); if ( ASSETCHAINS_CBOPRET != 0 ) { SplitStr(GetArg("-ac_prices",""), ASSETCHAINS_PRICES); From 0ec101d1c17cb072ec4039a8ef648cc24dc91b2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 20:52:05 -1100 Subject: [PATCH 3822/3904] pricebits --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8428c4a07..7661296b9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1748,7 +1748,7 @@ CScript komodo_mineropret(int32_t nHeight) void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint256 blockhash,int32_t ind,uint32_t pricebits) { - fprintf(stderr,"ExtremePrice dir.%d ht.%d ind.%d cmpbits.%u\n",dir,height,ind,cmpbits); + fprintf(stderr,"ExtremePrice dir.%d ht.%d ind.%d cmpbits.%u\n",dir,height,ind,pricebits); ExtremePrice.dir = dir; ExtremePrice.height = height; ExtremePrice.blockhash = blockhash; From 06e57ee1baa6ddf2a479ee379d58e46fb6f9296f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 21:49:28 -1100 Subject: [PATCH 3823/3904] Add boolean CCflag to all SetCCunspents/txids --- src/cc/CCassetstx.cpp | 55 +++------------------------------------- src/cc/CCinclude.h | 4 +-- src/cc/CCtokens.cpp | 6 ++--- src/cc/CCtx.cpp | 16 ++++++------ src/cc/CCutils.cpp | 2 +- src/cc/auction.cpp | 2 +- src/cc/cclib.cpp | 8 +++--- src/cc/channels.cpp | 6 ++--- src/cc/dice.cpp | 12 ++++----- src/cc/dilithium.c | 4 +-- src/cc/faucet.cpp | 4 +-- src/cc/fsm.cpp | 2 +- src/cc/gamescc.cpp | 6 ++--- src/cc/gateways.cpp | 14 +++++----- src/cc/heir.cpp | 14 +++++----- src/cc/import.cpp | 4 +-- src/cc/importgateway.cpp | 12 ++++----- src/cc/lotto.cpp | 6 ++--- src/cc/marmara.cpp | 8 +++--- src/cc/oracles.cpp | 20 +++++++-------- src/cc/payments.cpp | 4 +-- src/cc/pegs.cpp | 2 +- src/cc/prices.cpp | 4 +-- src/cc/rewards.cpp | 8 +++--- src/cc/rogue_rpc.cpp | 6 ++--- src/cc/sudoku.cpp | 2 +- src/komodo_bitcoind.h | 2 +- 27 files changed, 92 insertions(+), 141 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index dfe04fcb2..0929591ff 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -16,55 +16,6 @@ #include "CCassets.h" #include "CCtokens.h" -/* use AddTokenCCInputs instead -int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) -{ - char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t j,vout,n = 0; - std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); - - threshold = total/(maxinputs!=0?maxinputs:64); // TODO: is maxinputs really not over 64, what if i want to calc total balance? - - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - - if (it->second.satoshis < threshold) - continue; - - for (j=0; junspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) - continue; - fprintf(stderr,"AddAssetInputs() check destaddress=%s vout amount=%.8f\n",destaddr,(double)vintx.vout[vout].nValue/COIN); - if( (nValue = IsAssetvout(cp, price, origpubkey, vintx, vout, assetid)) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) - { - if ( total != 0 && maxinputs != 0 ) - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - nValue = it->second.satoshis; - totalinputs += nValue; - //std::cerr << "AddAssetInputs() adding input nValue=" << nValue << std::endl; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) - break; - } - } - } - - //std::cerr << "AddAssetInputs() found totalinputs=" << totalinputs << std::endl; - return(totalinputs); -} -*/ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) { @@ -165,7 +116,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) char assetsUnspendableAddr[64]; GetCCaddress(cpAssets, assetsUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsCoins, assetsUnspendableAddr); + SetCCunspents(unspentOutputsCoins, assetsUnspendableAddr,true); char assetsTokensUnspendableAddr[64]; std::vector vopretNonfungible; @@ -175,7 +126,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; } GetTokensCCaddress(cpAssets, assetsTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr); + SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr,true); // tokenbids: for (std::vector >::const_iterator itCoins = unspentOutputsCoins.begin(); @@ -195,7 +146,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) // try also dual eval tokenasks (and we do not need bids): cpAssets->additionalTokensEvalcode2 = additionalEvalCode; GetTokensCCaddress(cpAssets, assetsDualEvalTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsDualEvalTokens, assetsDualEvalTokensUnspendableAddr); + SetCCunspents(unspentOutputsDualEvalTokens, assetsDualEvalTokensUnspendableAddr,true); for (std::vector >::const_iterator itDualEvalTokens = unspentOutputsDualEvalTokens.begin(); itDualEvalTokens != unspentOutputsDualEvalTokens.end(); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index d1fda0154..a01618764 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -278,8 +278,8 @@ CPubKey check_signing_pubkey(CScript scriptSig); bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); extern std::vector NULL_pubkeys; std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); -void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); -void SetCCtxids(std::vector > &addressIndex,char *coinaddr); +void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool CCflag = true); +void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index a81a69b1f..a6ecf7123 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -580,7 +580,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C cp->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; GetTokensCCaddress(cp, tokenaddr, pk); - SetCCunspents(unspentOutputs, tokenaddr); + SetCCunspents(unspentOutputs, tokenaddr,true); if (unspentOutputs.empty()) { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); @@ -942,12 +942,12 @@ UniValue TokenList() } }; - SetCCtxids(addressIndex, cp->normaladdr); // find by old normal addr marker + SetCCtxids(addressIndex, cp->normaladdr,false); // find by old normal addr marker for (std::vector >::const_iterator it = addressIndex.begin(); it != addressIndex.end(); it++) { addTokenId(it->first.txhash); } - SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr); // find by burnable validated cc addr marker + SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr,true); // find by burnable validated cc addr marker for (std::vector >::const_iterator it = addressIndexCCMarker.begin(); it != addressIndexCCMarker.end(); it++) { addTokenId(it->first.txhash); } diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 2713dd9ed..5e8a05895 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -306,7 +306,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else return("0"); } -void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr) +void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool ccflag) { int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector > addresses; n = (int32_t)strlen(coinaddr); @@ -325,7 +325,7 @@ void SetCCunspents(std::vector > &addressIndex,char *coinaddr) +void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool ccflag) { int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector > addresses; n = (int32_t)strlen(coinaddr); @@ -344,10 +344,10 @@ void SetCCtxids(std::vector > &addressIndex } } -int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout) +int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag) { uint256 txid; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,CCflag!=0?true:false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -403,10 +403,10 @@ int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 return(0); } -int64_t CCaddress_balance(char *coinaddr) +int64_t CCaddress_balance(char *coinaddr,int32_t CCflag) { int64_t sum = 0; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,CCflag!=0?true:false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { sum += it->second.satoshis; @@ -434,7 +434,7 @@ int64_t CCtoken_balance(char *coinaddr,uint256 reftokenid) std::vector > unspentOutputs; uint8_t evalCode; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -613,7 +613,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput else threshold = total; sum = 0; Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 9a68c2456..55c93d7b3 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -600,7 +600,7 @@ int32_t CCCointxidExists(char const *logcategory,uint256 cointxid) char txidaddr[64]; std::string coin; int32_t numvouts; uint256 hashBlock; std::vector > addressIndex; CCtxidaddr(txidaddr,cointxid); - SetCCtxids(addressIndex,txidaddr); + SetCCtxids(addressIndex,txidaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { return(-1); diff --git a/src/cc/auction.cpp b/src/cc/auction.cpp index 0858facfa..7521256c7 100644 --- a/src/cc/auction.cpp +++ b/src/cc/auction.cpp @@ -124,7 +124,7 @@ int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8552cfa1b..bfd33adad 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -482,7 +482,7 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C else if ( (hash[0] & 0xff) != 0 || (hash[31] & 0xff) != 0 ) return eval->Invalid("invalid faucetget txid"); Getscriptaddress(destaddr,tx.vout[i].scriptPubKey); - SetCCtxids(txids,destaddr); + SetCCtxids(txids,destaddr,tx.vout[i].scriptPubKey.IsPayToCryptoCondition()); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { //int height = it->first.blockHeight; @@ -501,12 +501,12 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } } -int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr) +int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr,int32_t CCflag) { char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0,txfee = 10000; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,CCflag!=0?true:false); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs != 0 ) @@ -542,7 +542,7 @@ int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe char coinaddr[64]; int64_t nValue,txfee = 10000; uint256 txid,hashBlock; CTransaction vintx; int32_t vout; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 2887c18e1..254f7e3a5 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -411,7 +411,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C { if (tokenid!=zeroid) GetTokensCCaddress1of2(cp,coinaddr,srcpub,destpub); else GetCCaddress1of2(cp,coinaddr,srcpub,destpub); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); } else { @@ -797,7 +797,7 @@ UniValue ChannelsList() cp = CCinit(&C,EVAL_CHANNELS); mypk = pubkey2pk(Mypubkey()); GetCCaddress(cp,myCCaddr,mypk); - SetCCtxids(txids,myCCaddr); + SetCCtxids(txids,myCCaddr,true); result.push_back(Pair("result","success")); result.push_back(Pair("name","Channels List")); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) @@ -848,7 +848,7 @@ UniValue ChannelsInfo(uint256 channeltxid) result.push_back(Pair("Denomination (satoshi)",i64tostr(param2))); result.push_back(Pair("Amount (satoshi)",i64tostr(param1*param2))); } - SetCCtxids(addressIndex,CCaddr); + SetCCtxids(addressIndex,CCaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if (GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index ca1ad7b53..76d68e090 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -264,7 +264,7 @@ int32_t dicefinish_utxosget(int32_t &total,struct dicefinish_utxo *utxos,int32_t int32_t n = 0; int64_t threshold = 2 * 10000; total = 0; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,false); { LOCK(mempool.cs); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) @@ -1051,7 +1051,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hash,proof,hashBlock,fundingtxid; CTransaction tx; int32_t j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -1108,7 +1108,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit fundingPubKey = tx.vout[1].scriptPubKey; } else return(0); GetCCaddress(cp,coinaddr,dicepk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); entropyval = 0; int loops = 0; int numtxs = unspentOutputs.size()/2; @@ -1225,7 +1225,7 @@ bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontrac char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; GetCCaddress(cp,CCaddr,dicepk); - SetCCtxids(txids,cp->normaladdr); + SetCCtxids(txids,cp->normaladdr,false); if ( fundingtxid != zeroid ) // avoid scan unless creating new funding plan { //fprintf(stderr,"check fundingtxid\n"); @@ -1321,7 +1321,7 @@ UniValue DiceList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; cp = CCinit(&C,EVAL_DICE); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,false); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; @@ -1774,7 +1774,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx return(0.); } std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 5044edf94..5dfa1deda 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3341,7 +3341,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 checktxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -3538,7 +3538,7 @@ void dilithium_handleinit(struct CCcontract_info *cp) pthread_mutex_init(&DILITHIUM_MUTEX,NULL); dilithiumpk = GetUnspendable(cp,0); GetCCaddress(cp,CCaddr,dilithiumpk); - SetCCtxids(txids,CCaddr); + SetCCtxids(txids,CCaddr,true); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index 81a2c2933..cf12fae69 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -118,7 +118,7 @@ bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx else if ( (hash[0] & 0xff) != 0 || (hash[31] & 0xff) != 0 ) return eval->Invalid("invalid faucetget txid"); Getscriptaddress(destaddr,tx.vout[i].scriptPubKey); - SetCCtxids(txids,destaddr); + SetCCtxids(txids,destaddr,tx.vout[i].scriptPubKey.IsPayToCryptoCondition()); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { //int height = it->first.blockHeight; @@ -145,7 +145,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index 0bcc61a1b..e44f85e47 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -126,7 +126,7 @@ int64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 17b0d371b..f9611af2c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1152,7 +1152,7 @@ UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector > unspentOutputs; gamespk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,gamespk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); nextheight = komodo_nextheight(); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1638,7 +1638,7 @@ UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gamespk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetTokensCCaddress(cp,coinaddr,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); games_univalue(result,"players",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1665,7 +1665,7 @@ UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gamespk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,gamespk,mypk); - SetCCtxids(addressIndex,coinaddr); + SetCCtxids(addressIndex,coinaddr,true); games_univalue(result,"games",-1,-1); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 1039e9176..ac892b7e2 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -484,7 +484,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 std::vector > addressIndex; _GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk); - SetCCtxids(addressIndex,markeraddr); + SetCCtxids(addressIndex,markeraddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) @@ -831,7 +831,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ((numvouts=bindtx.vout.size())!=0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,refcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B') { GetTokensCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -1160,7 +1160,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin return(""); } _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1500,7 +1500,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); return(result); } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1563,7 +1563,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1651,7 +1651,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1688,7 +1688,7 @@ UniValue GatewaysList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); - SetCCtxids(addressIndex,cp->unspendableCCaddr); + SetCCtxids(addressIndex,cp->unspendableCCaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 9cb0f03bd..e047d1ab1 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -399,7 +399,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke //char markeraddr[64]; //CCtxidaddr(markeraddr, fundingtxid); - //SetCCunspents(unspentOutputs, markeraddr); + //SetCCunspents(unspentOutputs, markeraddr,true); hasHeirSpendingBegun = 0; funcId = 0; @@ -429,7 +429,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke char coinaddr[64]; GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' - SetCCunspents(unspentOutputs, coinaddr); // get vector with tx's with unspent vouts of 1of2pubkey address: + SetCCunspents(unspentOutputs, coinaddr,true); // get vector with tx's with unspent vouts of 1of2pubkey address: //std::cerr << "FindLatestFundingTx() using 1of2address=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; int32_t maxBlockHeight = 0; // max block height @@ -514,11 +514,11 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, char coinaddr[64]; Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 of 2 pubkeys' - SetCCunspents(unspentOutputs, coinaddr); + SetCCunspents(unspentOutputs, coinaddr,true); // char markeraddr[64]; // CCtxidaddr(markeraddr, fundingtxid); - // SetCCunspents(unspentOutputs, markeraddr); + // SetCCunspents(unspentOutputs, markeraddr,true); std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << std::endl; @@ -569,7 +569,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' std::vector> addressIndexes; - SetCCtxids(addressIndexes, coinaddr); + SetCCtxids(addressIndexes, coinaddr,true); //fprintf(stderr,"LifetimeHeirContractFunds() scan lifetime of %s\n",coinaddr); int64_t total = 0; @@ -1053,7 +1053,7 @@ UniValue HeirInfo(uint256 fundingtxid) //char markeraddr[64]; //CCtxidaddr(markeraddr, fundingtxid); - //SetCCunspents(unspentOutputs, markeraddr); + //SetCCunspents(unspentOutputs, markeraddr,true); // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { @@ -1218,7 +1218,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) char markeraddr[64]; GetCCaddress(cp, markeraddr, GetUnspendable(cp, NULL)); - SetCCunspents(unspentOutputs, markeraddr); + SetCCunspents(unspentOutputs, markeraddr,true); //std::cerr << "HeirList() finding heir marker from unspendable addr=" << markeraddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 14f359398..b847e07d2 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -129,7 +129,7 @@ bool ImportCoinGatewaysVerify(CTransaction oracletx, int32_t claimvout, std::str // return(""); // } // CCtxidaddr(markeraddr,oracletxid); -// SetCCunspents(unspentOutputs,markeraddr); +// SetCCunspents(unspentOutputs,markeraddr,true); // for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) // { // txid = it->first.txhash; @@ -478,7 +478,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string // return(-1); // } // CCtxidaddr(markeraddr,oracletxid); - // SetCCunspents(unspentOutputs,markeraddr); + // SetCCunspents(unspentOutputs,markeraddr,true); // for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) // { // txid = it->first.txhash; diff --git a/src/cc/importgateway.cpp b/src/cc/importgateway.cpp index 4e943b472..c755e2af7 100644 --- a/src/cc/importgateway.cpp +++ b/src/cc/importgateway.cpp @@ -261,7 +261,7 @@ int32_t ImportGatewayBindExists(struct CCcontract_info *cp,CPubKey importgateway std::vector > addressIndex; _GetCCaddress(markeraddr,EVAL_IMPORTGATEWAY,importgatewaypk); - SetCCtxids(addressIndex,markeraddr); + SetCCtxids(addressIndex,markeraddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) @@ -663,7 +663,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re return(""); } _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -992,7 +992,7 @@ UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin) LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1054,7 +1054,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1142,7 +1142,7 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1181,7 +1181,7 @@ UniValue ImportGatewayList() struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid; CTransaction vintx; std::string coin; char str[65],burnaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; cp = CCinit(&C,EVAL_IMPORTGATEWAY); - SetCCtxids(addressIndex,cp->unspendableCCaddr); + SetCCtxids(addressIndex,cp->unspendableCCaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index e9c263ff1..f873b3881 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -166,7 +166,7 @@ int64_t AddLottoInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -209,7 +209,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,u std::vector > unspentOutputs; lockedfunds = 0; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -266,7 +266,7 @@ UniValue LottoList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; cp = CCinit(&C,EVAL_LOTTO); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 60afbc7fd..fc0139dc7 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -352,7 +352,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); GetCCaddress1of2(cp,coinaddr,Marmarapk,poolpk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); unlocks = MarmaraUnlockht(firstheight); //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) @@ -387,7 +387,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, { uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,i,n = 0; uint8_t funcid; CPubKey pk; std::vector vals; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -457,7 +457,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) remains = (amount + txfee) - inputsum; std::vector > unspentOutputs; GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); threshold = remains / (MARMARA_VINS+1); uint8_t mypriv[32]; Myprivkey(mypriv); @@ -666,7 +666,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,Marmarapk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); // do all txid, conditional on spent/unspent //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index dc371ef16..1b13a00b7 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -197,7 +197,7 @@ int64_t OracleCurrentDatafee(uint256 reforacletxid,char *markeraddr,CPubKey publ { uint256 txid,oracletxid,hashBlock; int64_t datafee=0,dfee; int32_t dheight=0,vout,height,numvouts; CTransaction tx; CPubKey pk; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -260,7 +260,7 @@ uint256 OracleBatonUtxo(uint64_t txfee,struct CCcontract_info *cp,uint256 refora { uint256 txid,oracletxid,hashBlock,btxid,batontxid = zeroid; int64_t dfee; int32_t dheight=0,vout,height,numvouts; CTransaction tx; CPubKey pk; uint8_t *ptr; std::vector vopret,data; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,batonaddr); + SetCCunspents(unspentOutputs,batonaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -306,7 +306,7 @@ uint256 OraclesBatontxid(uint256 reforacletxid,CPubKey refpk) batontxid = zeroid; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,reforacletxid); - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); //char str[67]; fprintf(stderr,"markeraddr.(%s) %s\n",markeraddr,pubkey33_str(str,(uint8_t *)&refpk)); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -525,14 +525,14 @@ int32_t oracleprice_add(std::vector &publishers,CPubKey } else return(0); } -int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format) +/*int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format) { std::vector > unspentOutputs; CTransaction regtx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; std::vector publishers; std::vector prices; if ( format[0] != 'L' ) return(0); cp = CCinit(&C,EVAL_ORACLES); - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -562,7 +562,7 @@ int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char * return(OracleCorrelatedPrice(height,prices)); } return(0); -} +}*/ int64_t IsOraclesvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { @@ -708,7 +708,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint char coinaddr[64],funcid; int64_t nValue,price,totalinputs = 0; uint256 tmporacletxid,tmpbatontxid,txid,hashBlock; std::vector origpubkey,data; CTransaction vintx; int32_t numvouts,vout,n = 0; std::vector > unspentOutputs; CPubKey tmppk; int64_t tmpnum; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); //fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -746,7 +746,7 @@ int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubK char coinaddr[64]; CPubKey pk; int64_t total=0,num; uint256 txid,hashBlock,subtxid; CTransaction subtx; std::vector > addressIndex; GetCCaddress(cp,coinaddr,publisher); - SetCCtxids(addressIndex,coinaddr); + SetCCtxids(addressIndex,coinaddr,true); //fprintf(stderr,"scan lifetime of %s\n",coinaddr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { @@ -992,7 +992,7 @@ UniValue OracleInfo(uint256 origtxid) result.push_back(Pair("description",description)); result.push_back(Pair("format",format)); result.push_back(Pair("marker",markeraddr)); - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1028,7 +1028,7 @@ UniValue OraclesList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; cp = CCinit(&C,EVAL_ORACLES); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index ae83e2661..1aebcf6a4 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -317,7 +317,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( iter == 0 ) GetCCaddress(cp,coinaddr,Paymentspk); else GetCCaddress1of2(cp,coinaddr,Paymentspk,txidpk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -896,7 +896,7 @@ UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease; std::vector txidoprets; int64_t totalallocations; Paymentspk = GetUnspendable(cp,0); GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk); - SetCCtxids(addressIndex,markeraddr); + SetCCtxids(addressIndex,markeraddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 38933ebdc..21cee8ca1 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -181,7 +181,7 @@ int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 19194d16f..5d164d97e 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -230,7 +230,7 @@ int64_t AddPricesInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char { int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,destaddr); + SetCCunspents(unspentOutputs,destaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -711,7 +711,7 @@ UniValue PricesList() UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock,tokenid; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; char str[65]; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,false); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index bc9464fb8..26450f1f2 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -338,7 +338,7 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcont char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t numblocks,j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -403,7 +403,7 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontra std::vector > unspentOutputs; lockedfunds = 0; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -433,7 +433,7 @@ bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewa char CCaddr[64]; uint64_t sbits; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; GetCCaddress(cp,CCaddr,rewardspk); - SetCCtxids(txids,CCaddr); + SetCCtxids(txids,CCaddr,true); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { //int height = it->first.blockHeight; @@ -493,7 +493,7 @@ UniValue RewardsList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; cp = CCinit(&C,EVAL_REWARDS); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,false); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c5350a68d..9f2c96f22 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1397,7 +1397,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,roguepk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); nextheight = komodo_nextheight(); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1427,7 +1427,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetTokensCCaddress(cp,coinaddr,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); rogue_univalue(result,"players",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1456,7 +1456,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); //SetCCunspents(unspentOutputs,coinaddr); - SetCCtxids(addressIndex,coinaddr); + SetCCtxids(addressIndex,coinaddr,true); rogue_univalue(result,"games",-1,-1); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a9efdd950..301832bf5 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2772,7 +2772,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector > unspentOutputs; sudokupk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,sudokupk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index aa21896aa..0ae61356f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2472,7 +2472,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From d87063fdb12559a8555a9046f593fe3711d2ea3f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 21:51:16 -1100 Subject: [PATCH 3824/3904] Add flag --- src/cc/cclib.cpp | 2 +- src/cc/gamescc.cpp | 4 ++-- src/cc/rogue_rpc.cpp | 4 ++-- src/cc/sudoku.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index bfd33adad..ee52dadcf 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -596,7 +596,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para return(""); cclibpk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddCClibInputs(cp,mtx,cclibpk,nValue+txfee,60,cp->unspendableCCaddr)) > 0 ) + if ( (inputs= AddCClibInputs(cp,mtx,cclibpk,nValue+txfee,60,cp->unspendableCCaddr,1)) > 0 ) { if ( inputs > nValue ) CCchange = (inputs - nValue - txfee); diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index f9611af2c..997013b0c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1130,7 +1130,7 @@ UniValue games_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gamespk = GetUnspendable(cp,0); games_univalue(result,"newgame",maxplayers,buyin); required = (3*txfee + maxplayers*(GAMES_REGISTRATIONSIZE+txfee)); - if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,required,16,cp->unspendableCCaddr)) >= required ) + if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,required,16,cp->unspendableCCaddr,1)) >= required ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gamespk)); for (i=0; i 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,cashout,60,cp->unspendableCCaddr)) > cashout ) + if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,cashout,60,cp->unspendableCCaddr,1)) > cashout ) CCchange = (inputsum - cashout); else fprintf(stderr,"couldnt find enough utxos\n"); } diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9f2c96f22..b0ed60ab2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -806,7 +806,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); rogue_univalue(result,"newgame",maxplayers,buyin); required = (3*txfee + maxplayers*(ROGUE_REGISTRATIONSIZE+txfee)); - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,required,16,cp->unspendableCCaddr)) >= required ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,required,16,cp->unspendableCCaddr,1)) >= required ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO creation for (i=0; i 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr)) > cashout ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr,1)) > cashout ) CCchange = (inputsum - cashout); else fprintf(stderr,"couldnt find enough utxos\n"); } diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 301832bf5..c8f1c2430 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2679,7 +2679,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params sudokupk = GetUnspendable(cp,0); result.push_back(Pair("srand",(int)srandi)); result.push_back(Pair("amount",ValueFromAmount(amount))); - if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16,cp->unspendableCCaddr)) >= amount+2*txfee ) + if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16,cp->unspendableCCaddr,1)) >= amount+2*txfee ) { //printf("inputsum %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); @@ -2892,7 +2892,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( good != 0 ) { mtx.vin.push_back(CTxIn(txid,0,CScript())); - if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) + if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr,1)) >= balance ) { mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); From bc7f32a8568e58b0b2526ec9fc54f74daedf383d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 21:57:58 -1100 Subject: [PATCH 3825/3904] CCaddress_balance and CCutxo --- src/cc/CCinclude.h | 4 ++-- src/cc/gateways.cpp | 2 +- src/cc/importgateway.cpp | 2 +- src/cc/marmara.cpp | 8 ++++---- src/cc/payments.cpp | 4 ++-- src/cc/rewards.cpp | 2 +- src/cc/sudoku.cpp | 2 +- src/wallet/rpcwallet.cpp | 10 +++++----- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index a01618764..08d466411 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -179,7 +179,7 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp); CScript GetScriptForMultisig(int nRequired, const std::vector& keys); -int64_t CCaddress_balance(char *coinaddr); +int64_t CCaddress_balance(char *coinaddr,int32_t CCflag); CPubKey CCtxidaddr(char *txidaddr,uint256 txid); CPubKey CCCustomtxidaddr(char *txidaddr,uint256 txid,uint8_t taddr,uint8_t prefix,uint8_t prefix2); bool GetCCParams(Eval* eval, const CTransaction &tx, uint32_t nIn, @@ -282,7 +282,7 @@ void SetCCunspents(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); -int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout); +int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); // curve25519 and sha256 bits256 curve25519_shared(bits256 privkey,bits256 otherpub); diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index ac892b7e2..e15735d70 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -905,7 +905,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t for (i=0; i txfee ) @@ -1059,16 +1059,16 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ result.push_back(Pair("result","success")); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); result.push_back(Pair("myaddress",coinaddr)); - result.push_back(Pair("normal",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("normal",ValueFromAmount(CCaddress_balance(coinaddr,0)))); GetCCaddress1of2(cp,coinaddr,Marmarapk,Mypubkey()); result.push_back(Pair("myCCactivated",coinaddr)); - result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr,1)))); result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,0,MARMARA_VINS)))); GetCCaddress(cp,coinaddr,Mypubkey()); result.push_back(Pair("myCCaddress",coinaddr)); - result.push_back(Pair("CCutxos",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("CCutxos",ValueFromAmount(CCaddress_balance(coinaddr,1)))); if ( refpk.size() == 33 ) result.push_back(Pair("issuer",HexStr(refpk))); diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 1aebcf6a4..d83cd0bec 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -864,10 +864,10 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("txidoprets",a)); txidpk = CCtxidaddr(txidaddr,createtxid); GetCCaddress1of2(cp,fundsaddr,Paymentspk,txidpk); - funds = CCaddress_balance(fundsaddr); + funds = CCaddress_balance(fundsaddr,1); result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); GetCCaddress(cp,fundsopretaddr,Paymentspk); - fundsopret = CCaddress_balance(fundsopretaddr); + fundsopret = CCaddress_balance(fundsopretaddr,1); result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret))); result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret))); result.push_back(Pair("result","success")); diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 26450f1f2..5ca2b038a 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -650,7 +650,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2 else { GetCCaddress(cp,coinaddr,rewardspk); - if ( (amount= CCutxovalue(coinaddr,locktxid,0)) == 0 ) + if ( (amount= CCutxovalue(coinaddr,locktxid,0,1)) == 0 ) { fprintf(stderr,"%s locktxid/v0 is spent\n",coinaddr); CCerror = "locktxid/v0 is spent"; diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index c8f1c2430..61ea6c545 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2844,7 +2844,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params pk = buf2pk(pub33); GetCCaddress(cp,CCaddr,pk); result.push_back(Pair("sudokuaddr",CCaddr)); - balance = CCaddress_balance(CCaddr); + balance = CCaddress_balance(CCaddr,1); result.push_back(Pair("amount",ValueFromAmount(balance))); if ( sudoku_captcha(1,timestamps,komodo_nextheight()) < 0 ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8ee2896ba..a21de63f4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5369,11 +5369,11 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vectorunspendableCCaddr)); sprintf(str,"%sCCBalance",name); - result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr)))); + result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr,1)))); sprintf(str,"%sNormalAddress",name); result.push_back(Pair(str,cp->normaladdr)); sprintf(str,"%sNormalBalance",name); - result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr)))); + result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr,0)))); if (strcmp(name,"Gateways")==0) result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40")); if ((strcmp(name,"Channels")==0 || strcmp(name,"Heir")==0) && pubkey.size() == 33) { @@ -5402,7 +5402,7 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector Date: Thu, 11 Apr 2019 22:33:29 -1100 Subject: [PATCH 3826/3904] Extra room for more processed data --- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7661296b9..d74947d2d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1555,7 +1555,7 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define KOMODO_LOCALPRICE_CACHESIZE 13 #define KOMODO_MAXPRICES 2048 #define PRICES_SMOOTHWIDTH 1 -#define PRICES_MAXDATAPOINTS 3 +#define PRICES_MAXDATAPOINTS 8 #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1900df432..3ffaf52dd 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1670,7 +1670,7 @@ void SplitStr(const std::string& strVal, std::vector &outVals); void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_STAKED_NOTARY = GetArg("-stakednotary", -1); if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) { @@ -1817,6 +1817,8 @@ void komodo_args(char *argv0) SplitStr(GetArg("-ac_prices",""), ASSETCHAINS_PRICES); for (i=0; i 0 ) + ASSETCHAINS_CBOPRET |= 4; fprintf(stderr,"%d -ac_prices\n",(int32_t)ASSETCHAINS_PRICES.size()); } hexstr = GetArg("-ac_mineropret",""); From 8bb5f9abd52b1ceac1dbf231f68b13ee3d45f482 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 12 Apr 2019 17:35:40 +0800 Subject: [PATCH 3827/3904] fix address type --- src/base58.cpp | 8 ++++---- src/base58.h | 4 ++-- src/cc/CCtx.cpp | 4 ++-- src/rpc/misc.cpp | 4 ++-- src/txmempool.cpp | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/base58.cpp b/src/base58.cpp index 33b43d745..383666d82 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -296,13 +296,13 @@ CTxDestination CBitcoinAddress::Get() const return CNoDestination(); } -bool CBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type) const +bool CBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const { if (!IsValid()) { return false; } else if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) { memcpy(&hashBytes, &vchData[0], 20); - type = 1; + ccflag ? type = 3 : type = 1; return true; } else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) { memcpy(&hashBytes, &vchData[0], 20); @@ -392,13 +392,13 @@ CTxDestination CCustomBitcoinAddress::Get() const return CNoDestination(); } -bool CCustomBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type) const +bool CCustomBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const { if (!IsValid()) { return false; } else if (vchVersion == base58Prefixes[0]) { memcpy(&hashBytes, &vchData[0], 20); - type = 1; + ccflag ? type = 3 : type = 1; return true; } else if (vchVersion == base58Prefixes[1]) { memcpy(&hashBytes, &vchData[0], 20); diff --git a/src/base58.h b/src/base58.h index 52b3ac5f3..8be0247e0 100644 --- a/src/base58.h +++ b/src/base58.h @@ -147,7 +147,7 @@ public: CTxDestination Get() const; bool GetKeyID(CKeyID &keyID) const; bool GetKeyID_NoCheck(CKeyID& keyID) const; - bool GetIndexKey(uint160& hashBytes, int& type) const; + bool GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const; bool IsScript() const; }; @@ -172,7 +172,7 @@ public: CTxDestination Get() const; bool GetKeyID(CKeyID &keyID) const; bool GetKeyID_NoCheck(CKeyID& keyID) const; - bool GetIndexKey(uint160& hashBytes, int& type) const; + bool GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const; bool IsScript() const; }; diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 5e8a05895..7435defbf 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -315,7 +315,7 @@ void SetCCunspents(std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) @@ -334,7 +334,7 @@ void SetCCtxids(std::vector > &addressIndex for (i=0; i<=n; i++) ptr[i] = coinaddr[i]; CBitcoinAddress address(addrstr); - if ( address.GetIndexKey(hashBytes, type) == 0 ) + if ( address.GetIndexKey(hashBytes, type, ccflag) == 0 ) return; addresses.push_back(std::make_pair(hashBytes,type)); for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index cf7c85417..a77788fd7 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -867,7 +867,7 @@ bool getAddressesFromParams(const UniValue& params, std::vectorget_str()); uint160 hashBytes; int type = 0; - if (!address.GetIndexKey(hashBytes, type)) { + if (!address.GetIndexKey(hashBytes, type, 0)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses"); } addresses.push_back(std::make_pair(hashBytes, type)); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index f57860c76..2b38d7153 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -160,7 +160,7 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC if (vDest.which()) { uint160 hashBytes; - if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType)) + if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType, prevout.scriptPubKey.IsPayToCryptoCondition())) { vSols.push_back(vector(hashBytes.begin(), hashBytes.end())); } @@ -192,7 +192,7 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC if (vDest.which()) { uint160 hashBytes; - if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType)) + if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType, out.scriptPubKey.IsPayToCryptoCondition())) { vSols.push_back(vector(hashBytes.begin(), hashBytes.end())); } From 0d16e99532986684b7b7d922163b050c633ebcae Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 22:49:52 -1100 Subject: [PATCH 3828/3904] Dont fetch ahead if cbopret chain, yes it will slow it down --- src/main.cpp | 2 ++ src/main.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f1e586337..9df53b2d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -512,6 +512,8 @@ namespace { // Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last // linked block we have in common with this peer. The +1 is so we can detect stalling, namely if we would be able to // download that next block if the window were 1 larger. + if ( ASSETCHAINS_CBOPRET != 0 ) + BLOCK_DOWNLOAD_WINDOW = 1; int nWindowEnd = state->pindexLastCommonBlock->GetHeight() + BLOCK_DOWNLOAD_WINDOW; int nMaxHeight = std::min(state->pindexBestKnownBlock->GetHeight(), nWindowEnd + 1); NodeId waitingfor = -1; diff --git a/src/main.h b/src/main.h index e5f042c31..15e9f5934 100644 --- a/src/main.h +++ b/src/main.h @@ -111,7 +111,7 @@ static const unsigned int MAX_HEADERS_RESULTS = 160; * Larger windows tolerate larger download speed differences between peer, but increase the potential * degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning * harder). We'll probably want to make this a per-peer adaptive value at some point. */ -static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; +static unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; /** Time to wait (in seconds) between writing blocks/block index to disk. */ static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60; /** Time to wait (in seconds) between flushing chainstate to disk. */ From ab378bb9797a550d358155bdd22ae4199bf70141 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 12 Apr 2019 17:58:00 +0800 Subject: [PATCH 3829/3904] fix RPC calls --- src/rpc/misc.cpp | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a77788fd7..551d129f4 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -863,11 +863,14 @@ bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &addr bool getAddressesFromParams(const UniValue& params, std::vector > &addresses) { + bool ccVout = false; + if (params.size() == 2) + ccVout = true; if (params[0].isStr()) { CBitcoinAddress address(params[0].get_str()); uint160 hashBytes; int type = 0; - if (!address.GetIndexKey(hashBytes, type, 0)) { + if (!address.GetIndexKey(hashBytes, type, ccVout)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); } addresses.push_back(std::make_pair(hashBytes, type)); @@ -885,7 +888,7 @@ bool getAddressesFromParams(const UniValue& params, std::vectorget_str()); uint160 hashBytes; int type = 0; - if (!address.GetIndexKey(hashBytes, type, 0)) { + if (!address.GetIndexKey(hashBytes, type, ccVout)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses"); } addresses.push_back(std::make_pair(hashBytes, type)); @@ -909,7 +912,7 @@ bool timestampSort(std::pair a, UniValue getaddressmempool(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() > 2 || params.size() == 0) throw runtime_error( "getaddressmempool\n" "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n" @@ -921,6 +924,7 @@ UniValue getaddressmempool(const UniValue& params, bool fHelp) " ,...\n" " ]\n" "}\n" + "\nCCvout (optional) Return CCvouts instead of normal vouts\n" "\nResult:\n" "[\n" " {\n" @@ -934,8 +938,8 @@ UniValue getaddressmempool(const UniValue& params, bool fHelp) " }\n" "]\n" "\nExamples:\n" - + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}' (ccvout)") + + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]} (ccvout)") ); std::vector > addresses; @@ -980,7 +984,7 @@ UniValue getaddressmempool(const UniValue& params, bool fHelp) UniValue getaddressutxos(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() > 2 || params.size() == 0) throw runtime_error( "getaddressutxos\n" "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n" @@ -993,6 +997,7 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) " ],\n" " \"chainInfo\" (boolean) Include chain info with results\n" "}\n" + "\nCCvout (optional) Return CCvouts instead of normal vouts\n" "\nResult\n" "[\n" " {\n" @@ -1005,8 +1010,8 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) " }\n" "]\n" "\nExamples:\n" - + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}' (ccvout)") + + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]} (ccvout)") ); bool includeChainInfo = false; @@ -1066,7 +1071,7 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) UniValue getaddressdeltas(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1 || !params[0].isObject()) + if (fHelp || params.size() > 2 || params.size() == 0 || !params[0].isObject()) throw runtime_error( "getaddressdeltas\n" "\nReturns all changes for an address (requires addressindex to be enabled).\n" @@ -1081,6 +1086,7 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp) " \"end\" (number) The end block height\n" " \"chainInfo\" (boolean) Include chain info in results, only applies if start and end specified\n" "}\n" + "\nCCvout (optional) Return CCvouts instead of normal vouts\n" "\nResult:\n" "[\n" " {\n" @@ -1092,8 +1098,8 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp) " }\n" "]\n" "\nExamples:\n" - + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}' (ccvout)") + + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]} (ccvout)") ); @@ -1191,7 +1197,7 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp) UniValue getaddressbalance(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp ||params.size() > 2 || params.size() == 0) throw runtime_error( "getaddressbalance\n" "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n" @@ -1203,14 +1209,15 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp) " ,...\n" " ]\n" "}\n" + "\nCCvout (optional) Return CCvouts instead of normal vouts\n" "\nResult:\n" "{\n" " \"balance\" (string) The current balance in satoshis\n" " \"received\" (string) The total number of satoshis received (including change)\n" "}\n" "\nExamples:\n" - + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}' (ccvout)") + + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]} (ccvout)") ); std::vector > addresses; @@ -1301,9 +1308,9 @@ UniValue getsnapshot(const UniValue& params, bool fHelp) UniValue getaddresstxids(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() > 2) throw runtime_error( - "getaddresstxids\n" + "getaddresstxids (ccvout)\n" "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n" "\nArguments:\n" "{\n" @@ -1315,14 +1322,15 @@ UniValue getaddresstxids(const UniValue& params, bool fHelp) " \"start\" (number) The start block height\n" " \"end\" (number) The end block height\n" "}\n" + "\nCCvout (optional) Return CCvouts instead of normal vouts\n" "\nResult:\n" "[\n" " \"transactionid\" (string) The transaction id\n" " ,...\n" "]\n" "\nExamples:\n" - + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}' (ccvout)") + + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]} (ccvout)") ); std::vector > addresses; From 6d134de514f1075d350266315922195813faa83e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 23:20:08 -1100 Subject: [PATCH 3830/3904] +print --- src/komodo_gateway.h | 7 ++++--- src/scheduler.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d74947d2d..5d5f74155 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2628,7 +2628,7 @@ void komodo_pricesinit() void komodo_pricesupdate(int32_t height,CBlock *pblock) { static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf; - int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[4]; + int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[PRICES_MAXDATAPOINTS*2]; width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) { @@ -2662,6 +2662,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) if ( (correlated= komodo_pricecorrelated(rngval,ind,&ptr32[offset],-numprices,0,PRICES_SMOOTHWIDTH)) > 0 ) { fseek(PRICES[ind].fp,height * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); + memset(buf,0,sizeof(buf)); buf[0] = rawprices[ind]; buf[1] = rawprices[0]; // timestamp memcpy(&buf[2],&correlated,sizeof(correlated)); @@ -2670,7 +2671,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) else if ( height > PRICES_DAYWINDOW*2 ) { fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * PRICES_MAXDATAPOINTS * sizeof(int64_t),SEEK_SET); - if ( fread(ptr64,sizeof(int64_t),(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+2,PRICES[ind].fp) == (PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+2 ) + if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS,PRICES[ind].fp) == PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS ) { if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+1],-PRICES_MAXDATAPOINTS)) > 0 ) { @@ -2687,7 +2688,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) } else fprintf(stderr,"error reading rawprices for ht.%d\n",height); } else fprintf(stderr,"height.%d <= width.%d\n",height,width); } else fprintf(stderr,"null PRICES[0].fp\n"); - } else fprintf(stderr,"numprices mismatch\n"); + } else fprintf(stderr,"numprices mismatch, height.%d\n",height); } diff --git a/src/scheduler.cpp b/src/scheduler.cpp index e085791fc..4229a2efb 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -31,6 +31,17 @@ CScheduler::CScheduler() : nThreadsServicingQueue(0), stopRequested(false), stop CScheduler::~CScheduler() { + int32_t i; + if ( nThreadsServicingQueue != 0 ) + { + for (i=0; i<10; i++) + { + MilliSleep(1000); + fprintf(stderr,"CScheduler nThreadsServicingQueue.%d\n",(int32_t)nThreadsServicingQueue); + if ( nThreadsServicingQueue == 0 ) + break; + } + } assert(nThreadsServicingQueue == 0); } From 29d5c46bcde5ae653e7e6ac75f786ef03faa46b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 23:22:25 -1100 Subject: [PATCH 3831/3904] Sleep --- src/scheduler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 4229a2efb..6f9a0d5ba 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -36,7 +36,7 @@ CScheduler::~CScheduler() { for (i=0; i<10; i++) { - MilliSleep(1000); + sleep(1); fprintf(stderr,"CScheduler nThreadsServicingQueue.%d\n",(int32_t)nThreadsServicingQueue); if ( nThreadsServicingQueue == 0 ) break; From 6f78003c0e6a65256cb8b2708d026f1ffa387095 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 23:29:20 -1100 Subject: [PATCH 3832/3904] -debug --- src/scheduler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 6f9a0d5ba..08aba3225 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -31,7 +31,7 @@ CScheduler::CScheduler() : nThreadsServicingQueue(0), stopRequested(false), stop CScheduler::~CScheduler() { - int32_t i; + /*int32_t i; if ( nThreadsServicingQueue != 0 ) { for (i=0; i<10; i++) @@ -41,7 +41,7 @@ CScheduler::~CScheduler() if ( nThreadsServicingQueue == 0 ) break; } - } + }*/ assert(nThreadsServicingQueue == 0); } From d47d2dd595891e706fb564269782f6a4e528734d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 23:49:24 -1100 Subject: [PATCH 3833/3904] Better way to avoid sync errors --- src/main.cpp | 16 ++++++++-------- src/main.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9df53b2d7..db81c2070 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -512,8 +512,8 @@ namespace { // Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last // linked block we have in common with this peer. The +1 is so we can detect stalling, namely if we would be able to // download that next block if the window were 1 larger. - if ( ASSETCHAINS_CBOPRET != 0 ) - BLOCK_DOWNLOAD_WINDOW = 1; + //if ( ASSETCHAINS_CBOPRET != 0 ) + // BLOCK_DOWNLOAD_WINDOW = 1; int nWindowEnd = state->pindexLastCommonBlock->GetHeight() + BLOCK_DOWNLOAD_WINDOW; int nMaxHeight = std::min(state->pindexBestKnownBlock->GetHeight(), nWindowEnd + 1); NodeId waitingfor = -1; @@ -980,7 +980,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in * Ensure that a coinbase transaction is structured according to the consensus rules of the * chain */ -bool ContextualCheckCoinbaseTransaction(const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight) +bool ContextualCheckCoinbaseTransaction(const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight,int32_t validateprices) { // if time locks are on, ensure that this coin base is time locked exactly as it should be if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || @@ -1021,7 +1021,7 @@ bool ContextualCheckCoinbaseTransaction(const CBlock *block,CBlockIndex * const { } - else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 ) + else if ( ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 ) { if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) return(false); @@ -1043,7 +1043,7 @@ bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const prevind CValidationState &state, const int nHeight, const int dosLevel, - bool (*isInitBlockDownload)()) + bool (*isInitBlockDownload)(),int32_t validateprices) { bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); @@ -1174,7 +1174,7 @@ bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const prevind if (tx.IsCoinBase()) { - if (!ContextualCheckCoinbaseTransaction(block,previndex,tx, nHeight)) + if (!ContextualCheckCoinbaseTransaction(block,previndex,tx, nHeight,validateprices)) return state.DoS(100, error("CheckTransaction(): invalid script data for coinbase time lock"), REJECT_INVALID, "bad-txns-invalid-script-data-for-coinbase-time-lock"); } @@ -1679,7 +1679,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // DoS level set to 10 to be more forgiving. // Check transaction contextually against the set of consensus rules which apply in the next block to be mined. - if (!fSkipExpiry && !ContextualCheckTransaction(0,0,tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) + if (!fSkipExpiry && !ContextualCheckTransaction(0,0,tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel,0)) { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } @@ -5151,7 +5151,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn const CTransaction& tx = block.vtx[i]; // Check transaction contextually against consensus rules at block height - if (!ContextualCheckTransaction(&block,pindexPrev,tx, state, nHeight, 100)) { + if (!ContextualCheckTransaction(&block,pindexPrev,tx, state, nHeight, 100,1)) { return false; // Failure reason has been set in validation state object } diff --git a/src/main.h b/src/main.h index 15e9f5934..7e4c2201a 100644 --- a/src/main.h +++ b/src/main.h @@ -707,7 +707,7 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons /** Check a transaction contextually against a set of consensus rules */ bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const pindexPrev,const CTransaction& tx, CValidationState &state, int nHeight, int dosLevel, - bool (*isInitBlockDownload)() = IsInitialBlockDownload); + bool (*isInitBlockDownload)() = IsInitialBlockDownload,int32_t validateprices); /** Apply the effects of this transaction on the UTXO set represented by view */ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight); From 082aec73ffcf5dfdb50113ebaf76956414b7c2b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 23:51:44 -1100 Subject: [PATCH 3834/3904] =0 --- src/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.h b/src/main.h index 7e4c2201a..5be021f52 100644 --- a/src/main.h +++ b/src/main.h @@ -707,7 +707,7 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons /** Check a transaction contextually against a set of consensus rules */ bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const pindexPrev,const CTransaction& tx, CValidationState &state, int nHeight, int dosLevel, - bool (*isInitBlockDownload)() = IsInitialBlockDownload,int32_t validateprices); + bool (*isInitBlockDownload)() = IsInitialBlockDownload,int32_t validateprices=0); /** Apply the effects of this transaction on the UTXO set represented by view */ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight); From 3db5e5a8746eb9be334be2c2ab3c56681bacc12f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 23:52:05 -1100 Subject: [PATCH 3835/3904] =1 --- src/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.h b/src/main.h index 5be021f52..ec36c976b 100644 --- a/src/main.h +++ b/src/main.h @@ -707,7 +707,7 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons /** Check a transaction contextually against a set of consensus rules */ bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const pindexPrev,const CTransaction& tx, CValidationState &state, int nHeight, int dosLevel, - bool (*isInitBlockDownload)() = IsInitialBlockDownload,int32_t validateprices=0); + bool (*isInitBlockDownload)() = IsInitialBlockDownload,int32_t validateprices=1); /** Apply the effects of this transaction on the UTXO set represented by view */ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight); From 77ad8944ca8e7489a9f0fe03ee6ea4c557056ff2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Apr 2019 23:59:33 -1100 Subject: [PATCH 3836/3904] -,1 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index db81c2070..5ce7ca46d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5151,7 +5151,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn const CTransaction& tx = block.vtx[i]; // Check transaction contextually against consensus rules at block height - if (!ContextualCheckTransaction(&block,pindexPrev,tx, state, nHeight, 100,1)) { + if (!ContextualCheckTransaction(&block,pindexPrev,tx, state, nHeight, 100)) { return false; // Failure reason has been set in validation state object } From 9686cdd6cd0500b34f94d141307857c856d9122a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 00:47:02 -1100 Subject: [PATCH 3837/3904] Shrink lookahead if not initial download --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5ce7ca46d..2176d59b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -512,8 +512,8 @@ namespace { // Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last // linked block we have in common with this peer. The +1 is so we can detect stalling, namely if we would be able to // download that next block if the window were 1 larger. - //if ( ASSETCHAINS_CBOPRET != 0 ) - // BLOCK_DOWNLOAD_WINDOW = 1; + if ( ASSETCHAINS_CBOPRET != 0 && IsInitialBlockDownload() == 0 ) + BLOCK_DOWNLOAD_WINDOW = 1; int nWindowEnd = state->pindexLastCommonBlock->GetHeight() + BLOCK_DOWNLOAD_WINDOW; int nMaxHeight = std::min(state->pindexBestKnownBlock->GetHeight(), nWindowEnd + 1); NodeId waitingfor = -1; From 27083abb20e1822f43f03bf8ccc561e68fd1e6bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:25:01 -1100 Subject: [PATCH 3838/3904] Auto reconsider --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 2176d59b7..dd8249362 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5333,6 +5333,15 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+50000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720)); if ( pindex->GetHeight() < 0 || (pindex->GetHeight() >= saplinght && pindex->GetHeight() < saplinght+50000) || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) ) *futureblockp = 1; + if ( ASSETCHAINS_CBOPRET != 0 ) + { + CValidationState tmpstate; CBlockIndex *tmpindex; + if ( (tmpindex=komodo_chainactive(tmpptr->GetHeight())) != 0 ) + { + fprintf(stderr,"reconsider height.%d\n",(int32_t)tmpptr->GetHeight()); + ReconsiderBlock(tmpstate,tmpindex); + } + } } if ( *futureblockp == 0 ) { From e9e6e18f0596295217fdf419b0bdd46578aa44a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:29:07 -1100 Subject: [PATCH 3839/3904] -1 --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index dd8249362..b9f6cd9ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5336,9 +5336,9 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if ( ASSETCHAINS_CBOPRET != 0 ) { CValidationState tmpstate; CBlockIndex *tmpindex; - if ( (tmpindex=komodo_chainactive(tmpptr->GetHeight())) != 0 ) + if ( (tmpindex=komodo_chainactive(tmpptr->GetHeight()-1)) != 0 ) { - fprintf(stderr,"reconsider height.%d\n",(int32_t)tmpptr->GetHeight()); + fprintf(stderr,"reconsider height.%d\n",(int32_t)tmpptr->GetHeight()-1); ReconsiderBlock(tmpstate,tmpindex); } } From 5fb80dee40610f5f222f56bd90ad92acbef2cfc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:33:33 -1100 Subject: [PATCH 3840/3904] Test --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index b9f6cd9ed..1537dea1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5340,6 +5340,11 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C { fprintf(stderr,"reconsider height.%d\n",(int32_t)tmpptr->GetHeight()-1); ReconsiderBlock(tmpstate,tmpindex); + if ( (tmpindex=komodo_chainactive(tmpptr->GetHeight())) != 0 ) + { + fprintf(stderr,"reconsider height.%d\n",(int32_t)tmpptr->GetHeight()); + ReconsiderBlock(tmpstate,tmpindex); + } } } } From f9c13b8c60d3135215d368b1e04d134a83c8f132 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:36:33 -1100 Subject: [PATCH 3841/3904] Reconsider --- src/main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1537dea1c..42e2414b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5335,14 +5335,15 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C *futureblockp = 1; if ( ASSETCHAINS_CBOPRET != 0 ) { - CValidationState tmpstate; CBlockIndex *tmpindex; - if ( (tmpindex=komodo_chainactive(tmpptr->GetHeight()-1)) != 0 ) + CValidationState tmpstate; CBlockIndex *tmpindex; int32_t ht; + ht = (int32_t)pindex->GetHeight(); + if ( (tmpindex=komodo_chainactive(ht-1)) != 0 ) { - fprintf(stderr,"reconsider height.%d\n",(int32_t)tmpptr->GetHeight()-1); + fprintf(stderr,"reconsider height.%d\n",(int32_t)ht-1); ReconsiderBlock(tmpstate,tmpindex); - if ( (tmpindex=komodo_chainactive(tmpptr->GetHeight())) != 0 ) + if ( (tmpindex=komodo_chainactive(ht)) != 0 ) { - fprintf(stderr,"reconsider height.%d\n",(int32_t)tmpptr->GetHeight()); + fprintf(stderr,"reconsider height.%d\n",(int32_t)ht); ReconsiderBlock(tmpstate,tmpindex); } } From 0d2d1625bc4b666407d1d3334dadb38666efbb37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:41:33 -1100 Subject: [PATCH 3842/3904] Test --- src/main.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 42e2414b9..1493409bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5335,17 +5335,13 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C *futureblockp = 1; if ( ASSETCHAINS_CBOPRET != 0 ) { - CValidationState tmpstate; CBlockIndex *tmpindex; int32_t ht; + CValidationState tmpstate; CBlockIndex *tmpindex; int32_t ht,longest; ht = (int32_t)pindex->GetHeight(); - if ( (tmpindex=komodo_chainactive(ht-1)) != 0 ) + longest = komodo_longestchain(); + if ( (longest == 0 || ht < longest-6) && (tmpindex=komodo_chainactive(ht)) != 0 ) { - fprintf(stderr,"reconsider height.%d\n",(int32_t)ht-1); - ReconsiderBlock(tmpstate,tmpindex); - if ( (tmpindex=komodo_chainactive(ht)) != 0 ) - { - fprintf(stderr,"reconsider height.%d\n",(int32_t)ht); - ReconsiderBlock(tmpstate,tmpindex); - } + fprintf(stderr,"reconsider height.%d, longest.%d\n",(int32_t)ht,longest); + InvalidateBlock(tmpstate,tmpindex); } } } From b306b395501bbd0ba9c9a29dc27c6c52904302f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:43:27 -1100 Subject: [PATCH 3843/3904] -1 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1493409bb..fdd9d3132 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5336,7 +5336,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if ( ASSETCHAINS_CBOPRET != 0 ) { CValidationState tmpstate; CBlockIndex *tmpindex; int32_t ht,longest; - ht = (int32_t)pindex->GetHeight(); + ht = (int32_t)pindex->GetHeight()-1; longest = komodo_longestchain(); if ( (longest == 0 || ht < longest-6) && (tmpindex=komodo_chainactive(ht)) != 0 ) { From 7ad01e44ed23efdef651df8efa7b7f4749128f9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:56:16 -1100 Subject: [PATCH 3844/3904] komodo_reconsiderblock --- src/komodo_bitcoind.h | 12 ++++++++++++ src/komodo_gateway.h | 7 +++++++ src/main.cpp | 7 +++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0ae61356f..327761c00 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -448,6 +448,18 @@ int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len, return(-1); } +void komodo_reconsiderblock(uint256 blockhash) +{ + char params[256],*jsonstr,*hexstr; + sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); + komodo_reconsiderblock(Queued_reconsiderblock); + if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"reconsiderblock",params,KMD_PORT)) != 0 ) + { + fprintf(stderr,"komodo_reconsiderblock.(%s) -> (%s)\n",params,jsonstr); + free(jsonstr); + } +} + int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) { char params[256],*jsonstr,*hexstr; uint8_t *script,_script[8192]; int32_t n,len,retval = -1; cJSON *json,*txjson,*vouts,*vout,*skey; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5d5f74155..f23a2ff8f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2625,10 +2625,17 @@ void komodo_pricesinit() } } +extern Queued_reconsiderblock; + void komodo_pricesupdate(int32_t height,CBlock *pblock) { static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf; int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[PRICES_MAXDATAPOINTS*2]; + if ( Queued_reconsiderblock != zeroid ) + { + komodo_reconsiderblock(Queued_reconsiderblock); + Queued_reconsiderblock = zeroid; + } width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) { diff --git a/src/main.cpp b/src/main.cpp index fdd9d3132..d01c9babb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5273,6 +5273,8 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat return true; } +uint256 Queued_reconsiderblock; + bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, CBlockIndex** ppindex, bool fRequested, CDiskBlockPos* dbp) { const CChainParams& chainparams = Params(); @@ -5336,12 +5338,13 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if ( ASSETCHAINS_CBOPRET != 0 ) { CValidationState tmpstate; CBlockIndex *tmpindex; int32_t ht,longest; - ht = (int32_t)pindex->GetHeight()-1; + ht = (int32_t)pindex->GetHeight(); longest = komodo_longestchain(); if ( (longest == 0 || ht < longest-6) && (tmpindex=komodo_chainactive(ht)) != 0 ) { fprintf(stderr,"reconsider height.%d, longest.%d\n",(int32_t)ht,longest); - InvalidateBlock(tmpstate,tmpindex); + if ( Queued_reconsiderblock == zeroid ) + Queued_reconsiderblock = pindex->GetHash(); } } } From c28dcf1a9d078aa465fde009ed24a6c1c7899c64 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 01:58:02 -1100 Subject: [PATCH 3845/3904] Syntax --- src/komodo_bitcoind.h | 1 - src/komodo_gateway.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 327761c00..d771e2af7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -452,7 +452,6 @@ void komodo_reconsiderblock(uint256 blockhash) { char params[256],*jsonstr,*hexstr; sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); - komodo_reconsiderblock(Queued_reconsiderblock); if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"reconsiderblock",params,KMD_PORT)) != 0 ) { fprintf(stderr,"komodo_reconsiderblock.(%s) -> (%s)\n",params,jsonstr); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f23a2ff8f..bbad40c35 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2625,7 +2625,7 @@ void komodo_pricesinit() } } -extern Queued_reconsiderblock; +extern uint256 Queued_reconsiderblock; void komodo_pricesupdate(int32_t height,CBlock *pblock) { From 541df854ccdad7dd0da4ccaad97e1b3517702229 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 02:00:08 -1100 Subject: [PATCH 3846/3904] GetBlockHash() --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d01c9babb..e0e40c9a5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5344,7 +5344,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C { fprintf(stderr,"reconsider height.%d, longest.%d\n",(int32_t)ht,longest); if ( Queued_reconsiderblock == zeroid ) - Queued_reconsiderblock = pindex->GetHash(); + Queued_reconsiderblock = pindex->GetBlockHash(); } } } From 73dc3374780616d5478fdb82532c36249c79f307 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 02:09:49 -1100 Subject: [PATCH 3847/3904] +print --- src/komodo_bitcoind.h | 1 + src/komodo_gateway.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d771e2af7..6485f46a9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -457,6 +457,7 @@ void komodo_reconsiderblock(uint256 blockhash) fprintf(stderr,"komodo_reconsiderblock.(%s) -> (%s)\n",params,jsonstr); free(jsonstr); } + fprintf(stderr,"komodo_reconsiderblock.(%s) -> NULL\n",params); } int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bbad40c35..225dfd5a7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2631,6 +2631,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) { static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf; int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[PRICES_MAXDATAPOINTS*2]; + fprintf(stderr,"Queued_reconsiderblock %s\n",Queued_reconsiderblock.GetHex().c_str()); if ( Queued_reconsiderblock != zeroid ) { komodo_reconsiderblock(Queued_reconsiderblock); From b4cf30250748bab3b400c7dc50d21cf9b9a8dff3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 02:16:22 -1100 Subject: [PATCH 3848/3904] Move to right function --- src/komodo_gateway.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 225dfd5a7..274cf426c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2164,11 +2164,19 @@ int32_t komodo_cbopretsize(uint64_t flags) return(size); } +extern uint256 Queued_reconsiderblock; + void komodo_cbopretupdate(int32_t forceflag) { static uint32_t lasttime,lastcrypto,lastbtc,pending; static uint32_t pricebits[4],cryptoprices[KOMODO_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)]; int32_t size; uint32_t flags=0,now; CBlockIndex *pindex; + fprintf(stderr,"Queued_reconsiderblock %s\n",Queued_reconsiderblock.GetHex().c_str()); + if ( Queued_reconsiderblock != zeroid ) + { + komodo_reconsiderblock(Queued_reconsiderblock); + Queued_reconsiderblock = zeroid; + } if ( forceflag != 0 && pending != 0 ) { while ( pending != 0 ) @@ -2625,18 +2633,10 @@ void komodo_pricesinit() } } -extern uint256 Queued_reconsiderblock; - void komodo_pricesupdate(int32_t height,CBlock *pblock) { static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf; int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[PRICES_MAXDATAPOINTS*2]; - fprintf(stderr,"Queued_reconsiderblock %s\n",Queued_reconsiderblock.GetHex().c_str()); - if ( Queued_reconsiderblock != zeroid ) - { - komodo_reconsiderblock(Queued_reconsiderblock); - Queued_reconsiderblock = zeroid; - } width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) { From 8d672e591c4131f42701d548f8eff90148638136 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 02:22:35 -1100 Subject: [PATCH 3849/3904] Test --- src/komodo_bitcoind.h | 4 ++-- src/komodo_gateway.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6485f46a9..d9476c6ff 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -371,7 +371,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) { sprintf(url,(char *)"http://127.0.0.1:%u",port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); - //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); +printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); } @@ -454,7 +454,7 @@ void komodo_reconsiderblock(uint256 blockhash) sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"reconsiderblock",params,KMD_PORT)) != 0 ) { - fprintf(stderr,"komodo_reconsiderblock.(%s) -> (%s)\n",params,jsonstr); + fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,KMDUSERPASS,KMD_PORT,jsonstr); free(jsonstr); } fprintf(stderr,"komodo_reconsiderblock.(%s) -> NULL\n",params); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 274cf426c..54f80a8eb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2171,9 +2171,9 @@ void komodo_cbopretupdate(int32_t forceflag) static uint32_t lasttime,lastcrypto,lastbtc,pending; static uint32_t pricebits[4],cryptoprices[KOMODO_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)]; int32_t size; uint32_t flags=0,now; CBlockIndex *pindex; - fprintf(stderr,"Queued_reconsiderblock %s\n",Queued_reconsiderblock.GetHex().c_str()); if ( Queued_reconsiderblock != zeroid ) { + fprintf(stderr,"Queued_reconsiderblock %s\n",Queued_reconsiderblock.GetHex().c_str()); komodo_reconsiderblock(Queued_reconsiderblock); Queued_reconsiderblock = zeroid; } From 76e866c24347cac1b598be8cf071c103a21da2af Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 02:29:20 -1100 Subject: [PATCH 3850/3904] Call right daemon --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d9476c6ff..5e2f3a49f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -371,7 +371,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) { sprintf(url,(char *)"http://127.0.0.1:%u",port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); -printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); +//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); } @@ -452,12 +452,12 @@ void komodo_reconsiderblock(uint256 blockhash) { char params[256],*jsonstr,*hexstr; sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); - if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"reconsiderblock",params,KMD_PORT)) != 0 ) + if ( (jsonstr= komodo_issuemethod(ASSETCHAINS_USERPASS,(char *)"reconsiderblock",params,ASSETCHAINS_RPCPORT)) != 0 ) { - fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,KMDUSERPASS,KMD_PORT,jsonstr); + fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,USERPASS,KMD_PORT,jsonstr); free(jsonstr); } - fprintf(stderr,"komodo_reconsiderblock.(%s) -> NULL\n",params); + fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> NULL\n",params,USERPASS,KMD_PORT); } int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) From 4599d8ced6d28543ba21011b321c9ac7982b95bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 02:31:32 -1100 Subject: [PATCH 3851/3904] ASSETCHAINS_RPCPORT --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5e2f3a49f..a89b9db1a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -454,10 +454,10 @@ void komodo_reconsiderblock(uint256 blockhash) sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); if ( (jsonstr= komodo_issuemethod(ASSETCHAINS_USERPASS,(char *)"reconsiderblock",params,ASSETCHAINS_RPCPORT)) != 0 ) { - fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,USERPASS,KMD_PORT,jsonstr); + fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT,jsonstr); free(jsonstr); } - fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> NULL\n",params,USERPASS,KMD_PORT); + fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> NULL\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT); } int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) From 3d3be0492abdd90c3cdce340f6e5ee30138a3c51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 02:40:12 -1100 Subject: [PATCH 3852/3904] Test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a89b9db1a..c0917a765 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -454,10 +454,10 @@ void komodo_reconsiderblock(uint256 blockhash) sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); if ( (jsonstr= komodo_issuemethod(ASSETCHAINS_USERPASS,(char *)"reconsiderblock",params,ASSETCHAINS_RPCPORT)) != 0 ) { - fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT,jsonstr); + //fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT,jsonstr); free(jsonstr); } - fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> NULL\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT); + //fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> NULL\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT); } int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) From 11930668acfb107229a995b324a696548f4c2265 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 06:44:10 -1100 Subject: [PATCH 3853/3904] -print --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c0917a765..58d984eb7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -371,7 +371,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) { sprintf(url,(char *)"http://127.0.0.1:%u",port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); -//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); + //printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); } From f350e6bdad90e3fb4ef9c55f723734eeb7f44868 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:02:18 -1100 Subject: [PATCH 3854/3904] AAPL --- src/komodo_gateway.h | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 54f80a8eb..4cb803c9e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2014,18 +2014,13 @@ cJSON *get_urljson(char *url) return(json); } -uint32_t get_stockprice(const char *symbol) +uint32_t get_stockprices(std::vector symbols) { - char url[512]; cJSON *json,*obj; uint32_t high,low,price = 0; - sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + char url[32768]; cJSON *json,*obj; uint32_t high,low,price = 0; + sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL"); if ( (json= get_urljson(url)) != 0 ) { - if ( (obj= jobj(json,(char *)"Time Series (15min)")) != 0 ) - { - high = jdouble(jitem(obj,0),(char *)"2. high")*10000 + 0.000049; - low = jdouble(jitem(obj,0),(char *)"3. low")*10000 + 0.000049; - price = (high + low) / 2; - } + fprintf(stderr,"%s -> %s\n",url,jprint(json,0)); free_json(json); } return(price); @@ -2085,6 +2080,23 @@ int32_t get_cryptoprices(uint32_t *prices,const char *list[],int32_t n,std::vect return(-errs); } +/*uint32_t oldget_stockprice(const char *symbol) +{ + char url[512]; cJSON *json,*obj; uint32_t high,low,price = 0; + sprintf(url,"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=%s&interval=15min&apikey=%s",symbol,NOTARY_PUBKEY.data()+50); + if ( (json= get_urljson(url)) != 0 ) + { + if ( (obj= jobj(json,(char *)"Time Series (15min)")) != 0 ) + { + high = jdouble(jitem(obj,0),(char *)"2. high")*10000 + 0.000049; + low = jdouble(jitem(obj,0),(char *)"3. low")*10000 + 0.000049; + price = (high + low) / 2; + } + free_json(json); + } + return(price); +} + uint32_t get_currencyprice(const char *symbol) { char url[512]; cJSON *json,*obj; uint32_t price = 0; @@ -2109,7 +2121,7 @@ int32_t get_stocks(const char *list[],int32_t n) } fprintf(stderr," errs.%d\n",errs); return(-errs); -} +}*/ // parse the coindesk specific data. yes, if this changes, it will require an update. However, regardless if the format from the data source changes, then the code that extracts it must be changed. One way to mitigate this is to have a large variety of data sources so that there is only a very remote chance that all of them are not available. Certainly the data gathering needs to be made more robust, but it doesnt really affect the proof of concept for the decentralized trustless oracle. The trustlessness is achieved by having all nodes get the oracle data. @@ -2183,6 +2195,8 @@ void komodo_cbopretupdate(int32_t forceflag) fprintf(stderr,"pricewait "), sleep(1); return; } + get_stockprices("AAPL"); + pending = 1; now = (uint32_t)time(NULL); if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) From d3d42bb31c5e14aeef557dbb22c61fb4179ef9bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:05:15 -1100 Subject: [PATCH 3855/3904] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4cb803c9e..5ea46dba3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2195,7 +2195,7 @@ void komodo_cbopretupdate(int32_t forceflag) fprintf(stderr,"pricewait "), sleep(1); return; } - get_stockprices("AAPL"); + get_stockprices(0); pending = 1; now = (uint32_t)time(NULL); From b575d3ac5af3b34860d55c2cabc1e94164b8dc9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:06:12 -1100 Subject: [PATCH 3856/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5ea46dba3..605afd271 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2014,7 +2014,7 @@ cJSON *get_urljson(char *url) return(json); } -uint32_t get_stockprices(std::vector symbols) +uint32_t get_stockprices()//std::vector symbols) { char url[32768]; cJSON *json,*obj; uint32_t high,low,price = 0; sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL"); @@ -2195,7 +2195,7 @@ void komodo_cbopretupdate(int32_t forceflag) fprintf(stderr,"pricewait "), sleep(1); return; } - get_stockprices(0); + get_stockprices(); pending = 1; now = (uint32_t)time(NULL); From f0dd1cf6cfe8161960240828d6620d97115134b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:08:57 -1100 Subject: [PATCH 3857/3904] Use files --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 605afd271..9a8700c6f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2018,7 +2018,7 @@ uint32_t get_stockprices()//std::vector symbols) { char url[32768]; cJSON *json,*obj; uint32_t high,low,price = 0; sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL"); - if ( (json= get_urljson(url)) != 0 ) + if ( (json= send_curl(url,(char *)"iex")) != 0 ) //if ( (json= get_urljson(url)) != 0 ) { fprintf(stderr,"%s -> %s\n",url,jprint(json,0)); free_json(json); From 9a44dbb94938946e5638a241b3401074f9f29656 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:11:16 -1100 Subject: [PATCH 3858/3904] 2nd --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9a8700c6f..72ee7e819 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2017,10 +2017,10 @@ cJSON *get_urljson(char *url) uint32_t get_stockprices()//std::vector symbols) { char url[32768]; cJSON *json,*obj; uint32_t high,low,price = 0; - sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL"); + sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL, MSFT"); if ( (json= send_curl(url,(char *)"iex")) != 0 ) //if ( (json= get_urljson(url)) != 0 ) { - fprintf(stderr,"%s -> %s\n",url,jprint(json,0)); + //https://api.iextrading.com/1.0/tops/last?symbols=AAPL -> [{"symbol":"AAPL","price":198.63,"size":100,"time":1555092606076}] free_json(json); } return(price); From 8eccd385490801719cf042b7bd42da09672cab80 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:21:33 -1100 Subject: [PATCH 3859/3904] Test --- src/komodo_gateway.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 72ee7e819..8612ddbbb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2016,10 +2016,28 @@ cJSON *get_urljson(char *url) uint32_t get_stockprices()//std::vector symbols) { - char url[32768]; cJSON *json,*obj; uint32_t high,low,price = 0; + std::vector symbols; + char url[32768],*symbol; cJSON *json,*obj; int32_t i,n; uint32_t uprice; + symbols.push_back("AAPL"); + symbols.push_back("MSFT"); sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL, MSFT"); if ( (json= send_curl(url,(char *)"iex")) != 0 ) //if ( (json= get_urljson(url)) != 0 ) { + if ( (n= cJSON_GetArraySize(json)) > 0 ) + { + for (i=0; i [{"symbol":"AAPL","price":198.63,"size":100,"time":1555092606076}] free_json(json); } From cf09109439a1beed5e33e439b043871586b7162d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:22:29 -1100 Subject: [PATCH 3860/3904] (char *) --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8612ddbbb..0bd1476fd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2028,9 +2028,9 @@ uint32_t get_stockprices()//std::vector symbols) for (i=0; i Date: Fri, 12 Apr 2019 07:22:58 -1100 Subject: [PATCH 3861/3904] Retail --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0bd1476fd..dd9f9a6a7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2014,10 +2014,10 @@ cJSON *get_urljson(char *url) return(json); } -uint32_t get_stockprices()//std::vector symbols) +int32_t get_stockprices()//std::vector symbols) { std::vector symbols; - char url[32768],*symbol; cJSON *json,*obj; int32_t i,n; uint32_t uprice; + char url[32768],*symbol; cJSON *json,*obj; int32_t i,n=0; uint32_t uprice; symbols.push_back("AAPL"); symbols.push_back("MSFT"); sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL, MSFT"); @@ -2041,7 +2041,7 @@ uint32_t get_stockprices()//std::vector symbols) //https://api.iextrading.com/1.0/tops/last?symbols=AAPL -> [{"symbol":"AAPL","price":198.63,"size":100,"time":1555092606076}] free_json(json); } - return(price); + return(n); } uint32_t get_dailyfx(uint32_t *prices) From 77afae4f251ccb99e9ef1af94e549c094f7f0ce1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 07:51:28 -1100 Subject: [PATCH 3862/3904] Support stock prices --- src/komodo_defs.h | 2 +- src/komodo_gateway.h | 95 +++++++++++++++++++++++++++----------------- src/komodo_globals.h | 2 +- src/komodo_utils.h | 19 ++++++++- 4 files changed, 78 insertions(+), 40 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index ebfadee69..a78276fb3 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -60,7 +60,7 @@ extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NO extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; -extern std::vector ASSETCHAINS_PRICES; +extern std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; extern char ASSETCHAINS_SYMBOL[65]; extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dd9f9a6a7..96ce788f9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2014,26 +2014,34 @@ cJSON *get_urljson(char *url) return(json); } -int32_t get_stockprices()//std::vector symbols) +int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector symbols) { - std::vector symbols; - char url[32768],*symbol; cJSON *json,*obj; int32_t i,n=0; uint32_t uprice; - symbols.push_back("AAPL"); - symbols.push_back("MSFT"); - sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=AAPL, MSFT"); + char url[32768],*symbol; cJSON *json,*obj; int32_t i,n=0,retval=-1; uint32_t uprice,timestamp; + sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=%s",GetArg("-ac_stocks","")); if ( (json= send_curl(url,(char *)"iex")) != 0 ) //if ( (json= get_urljson(url)) != 0 ) { if ( (n= cJSON_GetArraySize(json)) > 0 ) { + retval = n; for (i=0; i now+60 || timestamp < now-ASSETCHAINS_BLOCKTIME ) + { + fprintf(stderr,"time error.%d\n",timestamp-now); + retval = -1; + } if ( symbols[i] != symbol ) + { + retval = -1; fprintf(stderr,"MISMATCH."); - fprintf(stderr,"(%s %u) ",symbol,uprice); + } + fprintf(stderr,"(%s %u).%d ",symbol,uprice,timestamp-now); } } fprintf(stderr,"numstocks.%d\n",n); @@ -2041,7 +2049,7 @@ int32_t get_stockprices()//std::vector symbols) //https://api.iextrading.com/1.0/tops/last?symbols=AAPL -> [{"symbol":"AAPL","price":198.63,"size":100,"time":1555092606076}] free_json(json); } - return(n); + return(retval); } uint32_t get_dailyfx(uint32_t *prices) @@ -2190,6 +2198,8 @@ int32_t komodo_cbopretsize(uint64_t flags) size += (sizeof(Forex)/sizeof(*Forex)) * sizeof(uint32_t); if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) size += (sizeof(Cryptos)/sizeof(*Cryptos) + ASSETCHAINS_PRICES.size())*sizeof(uint32_t); + if ( (ASSETCHAINS_CBOPRET & 8) != 0 ) + size += (ASSETCHAINS_STOCKS.size())*sizeof(uint32_t); } return(size); } @@ -2198,8 +2208,8 @@ extern uint256 Queued_reconsiderblock; void komodo_cbopretupdate(int32_t forceflag) { - static uint32_t lasttime,lastcrypto,lastbtc,pending; - static uint32_t pricebits[4],cryptoprices[KOMODO_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)]; + static uint32_t lasttime,lastbtc,pending; + static uint32_t pricebits[4],pricebuf[KOMODO_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)]; int32_t size; uint32_t flags=0,now; CBlockIndex *pindex; if ( Queued_reconsiderblock != zeroid ) { @@ -2213,8 +2223,6 @@ void komodo_cbopretupdate(int32_t forceflag) fprintf(stderr,"pricewait "), sleep(1); return; } - get_stockprices(); - pending = 1; now = (uint32_t)time(NULL); if ( (ASSETCHAINS_CBOPRET & 1) != 0 ) @@ -2248,23 +2256,35 @@ void komodo_cbopretupdate(int32_t forceflag) { if ( forceflag != 0 || flags != 0 ) { - get_cryptoprices(cryptoprices,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos)),ASSETCHAINS_PRICES); + get_cryptoprices(pricebuf,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos)),ASSETCHAINS_PRICES); if ( flags == 0 ) komodo_PriceCache_shift(); - memcpy(&PriceCache[0][size/sizeof(uint32_t)],cryptoprices,(sizeof(Cryptos)/sizeof(*Cryptos)+ASSETCHAINS_PRICES.size()) * sizeof(uint32_t)); + memcpy(&PriceCache[0][size/sizeof(uint32_t)],pricebuf,(sizeof(Cryptos)/sizeof(*Cryptos)+ASSETCHAINS_PRICES.size()) * sizeof(uint32_t)); flags |= 4; // very rarely we can see flags == 6 case } size += (sizeof(Cryptos)/sizeof(*Cryptos)+ASSETCHAINS_PRICES.size()) * sizeof(uint32_t); } + now = (uint32_t)time(NULL); + if ( (ASSETCHAINS_CBOPRET & 8) != 0 ) + { + if ( forceflag != 0 || flags != 0 ) + { + if ( get_stockprices(now,pricebuf,ASSETCHAINS_STOCKS) == ASSETCHAINS_STOCKS.size() ) + { + if ( flags == 0 ) + komodo_PriceCache_shift(); + memcpy(&PriceCache[0][size/sizeof(uint32_t)],pricebuf,ASSETCHAINS_STOCKS.size() * sizeof(uint32_t)); + flags |= 8; // very rarely we can see flags == 10 case + } + } + size += (ASSETCHAINS_STOCKS.size()) * sizeof(uint32_t); + } if ( flags != 0 ) { - now = (uint32_t)time(NULL); if ( (flags & 1) != 0 ) lastbtc = now; if ( (flags & 2) != 0 ) lasttime = now; - if ( (flags & 4) != 0 ) - lastcrypto = now; memcpy(Mineropret.data(),PriceCache[0],size); if ( ExtremePrice.dir != 0 && ExtremePrice.ind > 0 && ExtremePrice.ind < size/sizeof(uint32_t) && now < ExtremePrice.timestamp+3600 ) { @@ -2284,19 +2304,6 @@ void komodo_cbopretupdate(int32_t forceflag) // fprintf(stderr,"%02x",Mineropret[i]); //fprintf(stderr," <- set Mineropret[%d] size.%d %ld\n",(int32_t)Mineropret.size(),size,sizeof(PriceCache[0])); } - /* - if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) - { - get_currencies(Metals,(int32_t)(sizeof(Metals)/sizeof(*Metals))); - } - if ( (ASSETCHAINS_CBOPRET & 32) != 0 ) - { - get_stocks(Markets,(int32_t)(sizeof(Markets)/sizeof(*Markets))); - } - if ( (ASSETCHAINS_CBOPRET & 64) != 0 ) - { - get_stocks(Techstocks,(int32_t)(sizeof(Techstocks)/sizeof(*Techstocks))); - }*/ } pending = 0; } @@ -2320,6 +2327,11 @@ int64_t komodo_pricemult(int32_t ind) for (j=0; j ASSETCHAINS_PRICES; +std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; #define _ASSETCHAINS_EQUIHASH 0 uint32_t ASSETCHAINS_NUMALGOS = 3; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 3ffaf52dd..c5f562b0e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1815,11 +1815,17 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CBOPRET != 0 ) { SplitStr(GetArg("-ac_prices",""), ASSETCHAINS_PRICES); - for (i=0; i 0 ) ASSETCHAINS_CBOPRET |= 4; + SplitStr(GetArg("-ac_stocks",""), ASSETCHAINS_STOCKS); + if ( ASSETCHAINS_STOCKS.size() > 0 ) + ASSETCHAINS_CBOPRET |= 8; + for (i=0; i Date: Fri, 12 Apr 2019 07:57:20 -1100 Subject: [PATCH 3863/3904] c_Str --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 96ce788f9..36ebce74a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2017,7 +2017,7 @@ cJSON *get_urljson(char *url) int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector symbols) { char url[32768],*symbol; cJSON *json,*obj; int32_t i,n=0,retval=-1; uint32_t uprice,timestamp; - sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=%s",GetArg("-ac_stocks","")); + sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=%s",GetArg("-ac_stocks","").c_str()); if ( (json= send_curl(url,(char *)"iex")) != 0 ) //if ( (json= get_urljson(url)) != 0 ) { if ( (n= cJSON_GetArraySize(json)) > 0 ) From d1af8415a895b8fc17c235d2ad39f95c5c42b5b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:08:48 -1100 Subject: [PATCH 3864/3904] Pricing --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 36ebce74a..2575df1ac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2392,6 +2392,7 @@ char *komodo_pricename(char *name,int32_t ind) return(0); if ( ind < ASSETCHAINS_STOCKS.size() ) { + fprintf(stderr,"ind.%d vs size.%d\n",ind,(int32_t)ASSETCHAINS_PRICES.size()); strcpy(name,ASSETCHAINS_PRICES[ind].c_str()); strcat(name,"/USD"); return(name); @@ -2669,6 +2670,7 @@ void komodo_pricesinit() { if ( komodo_pricename(PRICES[i].symbol,i) == 0 ) break; + fprintf(stderr,"i.%d %s\n",i,PRICES[i].symbol); if ( i == 0 ) strcpy(PRICES[i].symbol,"rawprices"); pricefname = pricesdir / PRICES[i].symbol; From eb2b06ba62a446767fa1ac1087bf1a0dfc97b604 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:14:32 -1100 Subject: [PATCH 3865/3904] +print --- src/komodo_gateway.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2575df1ac..e2981a856 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2033,7 +2033,7 @@ int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector s prices[i] = uprice; if ( timestamp > now+60 || timestamp < now-ASSETCHAINS_BLOCKTIME ) { - fprintf(stderr,"time error.%d\n",timestamp-now); + fprintf(stderr,"time error.%d (%u vs %u)\n",timestamp-now,timestamp,now); retval = -1; } if ( symbols[i] != symbol ) @@ -2392,8 +2392,7 @@ char *komodo_pricename(char *name,int32_t ind) return(0); if ( ind < ASSETCHAINS_STOCKS.size() ) { - fprintf(stderr,"ind.%d vs size.%d\n",ind,(int32_t)ASSETCHAINS_PRICES.size()); - strcpy(name,ASSETCHAINS_PRICES[ind].c_str()); + strcpy(name,ASSETCHAINS_STOCKS[ind].c_str()); strcat(name,"/USD"); return(name); } else ind -= ASSETCHAINS_STOCKS.size(); From e6eddb7a70992a5d1b6dc3708db9e0dbc8c21762 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:17:28 -1100 Subject: [PATCH 3866/3904] -print --- src/komodo_gateway.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e2981a856..73df3a546 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2028,7 +2028,7 @@ int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector s obj = jitem(json,i); if ( (symbol= jstr(obj,(char *)"symbol")) != 0 ) { - timestamp = juint(obj,(char *)"time"); + timestamp = jdouble(obj,(char *)"time"); uprice = jdouble(obj,(char *)"price")*100 + 0.0049; prices[i] = uprice; if ( timestamp > now+60 || timestamp < now-ASSETCHAINS_BLOCKTIME ) @@ -2669,7 +2669,6 @@ void komodo_pricesinit() { if ( komodo_pricename(PRICES[i].symbol,i) == 0 ) break; - fprintf(stderr,"i.%d %s\n",i,PRICES[i].symbol); if ( i == 0 ) strcpy(PRICES[i].symbol,"rawprices"); pricefname = pricesdir / PRICES[i].symbol; From 06157628eb1c80225b93a25cb35362d36663a0ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:21:55 -1100 Subject: [PATCH 3867/3904] Atol --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 73df3a546..f03d74c11 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2016,7 +2016,7 @@ cJSON *get_urljson(char *url) int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector symbols) { - char url[32768],*symbol; cJSON *json,*obj; int32_t i,n=0,retval=-1; uint32_t uprice,timestamp; + char url[32768],*symbol,*timestr; cJSON *json,*obj; int32_t i,n=0,retval=-1; uint32_t uprice,timestamp; sprintf(url,"https://api.iextrading.com/1.0/tops/last?symbols=%s",GetArg("-ac_stocks","").c_str()); if ( (json= send_curl(url,(char *)"iex")) != 0 ) //if ( (json= get_urljson(url)) != 0 ) { @@ -2026,9 +2026,9 @@ int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector s for (i=0; i now+60 || timestamp < now-ASSETCHAINS_BLOCKTIME ) From 7d487d3ea3d27d3c34f394fefa27c65e38cc0b36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:28:56 -1100 Subject: [PATCH 3868/3904] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f03d74c11..e30ee8d00 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2026,9 +2026,9 @@ int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector s for (i=0; i now+60 || timestamp < now-ASSETCHAINS_BLOCKTIME ) From 26dddaac894c0fff7ae2e316cdc46ddc955fd83a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:31:44 -1100 Subject: [PATCH 3869/3904] Skip timestamp for now --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e30ee8d00..4dfba5392 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2028,20 +2028,20 @@ int32_t get_stockprices(uint32_t now,uint32_t *prices,std::vector s obj = jitem(json,i); if ( (symbol= jstr(obj,(char *)"symbol")) != 0 ) { - timestamp = j64bits(obj,(char *)"time"); uprice = jdouble(obj,(char *)"price")*100 + 0.0049; prices[i] = uprice; + /*timestamp = j64bits(obj,(char *)"time"); if ( timestamp > now+60 || timestamp < now-ASSETCHAINS_BLOCKTIME ) { fprintf(stderr,"time error.%d (%u vs %u)\n",timestamp-now,timestamp,now); retval = -1; - } + }*/ if ( symbols[i] != symbol ) { retval = -1; fprintf(stderr,"MISMATCH."); } - fprintf(stderr,"(%s %u).%d ",symbol,uprice,timestamp-now); + fprintf(stderr,"(%s %u) ",symbol,uprice); } } fprintf(stderr,"numstocks.%d\n",n); From 325e914ce846b6e6e0498db2e02a60db34eb4bd6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:38:43 -1100 Subject: [PATCH 3870/3904] Test --- src/bitcoind.cpp | 4 ++-- src/komodo_gateway.h | 9 +++++++++ src/komodo_utils.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 68e0da8b3..dc85547a9 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -70,8 +70,8 @@ void WaitForShutdown(boost::thread_group* threadGroup) { int32_t i; bool fShutdown = ShutdownRequested(); // Tell the main threads to shutdown. - if ( ASSETCHAINS_CBOPRET != 0 ) - komodo_pricesinit(); + //if ( ASSETCHAINS_CBOPRET != 0 ) + // komodo_pricesinit(); while (!fShutdown) { //fprintf(stderr,"call passport iteration\n"); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4dfba5392..3a3dba00e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2660,7 +2660,11 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) void komodo_pricesinit() { + static int32_t didinit; int32_t i,createflag = 0; + if ( didinit != 0 ) + return; + didinit = 1; boost::filesystem::path pricefname,pricesdir = GetDataDir() / "prices"; fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str()); if (!boost::filesystem::exists(pricesdir)) @@ -2720,6 +2724,11 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) rngval = seed; for (ind=1; ind 0 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c5f562b0e..363eb73ce 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2100,6 +2100,7 @@ void komodo_args(char *argv0) extralen += symbol.size(); } } + komodo_pricesinit(); komodo_cbopretupdate(1); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } From d0fd337b2565b11e8cb683b4acdaf9edfb1449c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:44:54 -1100 Subject: [PATCH 3871/3904] Revert --- src/bitcoind.cpp | 4 ++-- src/komodo_defs.h | 2 +- src/komodo_gateway.h | 6 ++++-- src/komodo_utils.h | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index dc85547a9..68e0da8b3 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -70,8 +70,8 @@ void WaitForShutdown(boost::thread_group* threadGroup) { int32_t i; bool fShutdown = ShutdownRequested(); // Tell the main threads to shutdown. - //if ( ASSETCHAINS_CBOPRET != 0 ) - // komodo_pricesinit(); + if ( ASSETCHAINS_CBOPRET != 0 ) + komodo_pricesinit(); while (!fShutdown) { //fprintf(stderr,"call passport iteration\n"); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index a78276fb3..4fd357ac1 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -87,6 +87,6 @@ void komodo_netevent(std::vector payload); #define PRICES_SMOOTHWIDTH 1 int32_t komodo_priceind(char *symbol); -void komodo_pricesinit(); +int32_t komodo_pricesinit(); #endif diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3a3dba00e..cebe152ff 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2658,12 +2658,12 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) return((price*7 + halfave*5 + thirdave*3 + fourthave*2 + decayprice + buf[PRICES_DAYWINDOW-1]) / 19); } -void komodo_pricesinit() +int32_t komodo_pricesinit() { static int32_t didinit; int32_t i,createflag = 0; if ( didinit != 0 ) - return; + return(-1); didinit = 1; boost::filesystem::path pricefname,pricesdir = GetDataDir() / "prices"; fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str()); @@ -2690,6 +2690,8 @@ void komodo_pricesinit() fputc(0,PRICES[0].fp); fflush(PRICES[0].fp); } + fprintf(stderr,"pricesinit done\n"); + return(0); } void komodo_pricesupdate(int32_t height,CBlock *pblock) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 363eb73ce..a3d611f9f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2100,7 +2100,7 @@ void komodo_args(char *argv0) extralen += symbol.size(); } } - komodo_pricesinit(); + //komodo_pricesinit(); komodo_cbopretupdate(1); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } From f3056d48294524939219c33750daad8fe85ad6b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 08:56:44 -1100 Subject: [PATCH 3872/3904] +print --- src/komodo_gateway.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cebe152ff..792e2b5ab 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2197,9 +2197,9 @@ int32_t komodo_cbopretsize(uint64_t flags) if ( (ASSETCHAINS_CBOPRET & 2) != 0 ) size += (sizeof(Forex)/sizeof(*Forex)) * sizeof(uint32_t); if ( (ASSETCHAINS_CBOPRET & 4) != 0 ) - size += (sizeof(Cryptos)/sizeof(*Cryptos) + ASSETCHAINS_PRICES.size())*sizeof(uint32_t); + size += (sizeof(Cryptos)/sizeof(*Cryptos) + ASSETCHAINS_PRICES.size()) * sizeof(uint32_t); if ( (ASSETCHAINS_CBOPRET & 8) != 0 ) - size += (ASSETCHAINS_STOCKS.size())*sizeof(uint32_t); + size += (ASSETCHAINS_STOCKS.size() * sizeof(uint32_t)); } return(size); } @@ -2661,7 +2661,7 @@ int64_t komodo_priceave(int64_t *buf,int64_t *correlated,int32_t cskip) int32_t komodo_pricesinit() { static int32_t didinit; - int32_t i,createflag = 0; + int32_t i,num=0,createflag = 0; if ( didinit != 0 ) return(-1); didinit = 1; @@ -2676,12 +2676,15 @@ int32_t komodo_pricesinit() if ( i == 0 ) strcpy(PRICES[i].symbol,"rawprices"); pricefname = pricesdir / PRICES[i].symbol; - PRICES[i].fp = fopen(pricefname.string().c_str(), createflag != 0 ? "wb+" : "rb+"); - if ( createflag != 0 ) + if ( (PRICES[i].fp= fopen(pricefname.string().c_str(), createflag != 0 ? "wb+" : "rb+")) != 0 ) { - fseek(PRICES[i].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); - fputc(0,PRICES[i].fp); - fflush(PRICES[i].fp); + num++; + if ( createflag != 0 ) + { + fseek(PRICES[i].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); + fputc(0,PRICES[i].fp); + fflush(PRICES[i].fp); + } } } if ( i > 0 && PRICES[0].fp != 0 && createflag != 0 ) @@ -2690,7 +2693,7 @@ int32_t komodo_pricesinit() fputc(0,PRICES[0].fp); fflush(PRICES[0].fp); } - fprintf(stderr,"pricesinit done\n"); + fprintf(stderr,"pricesinit done i.%d num.%d numprices.%d\n",i,num,(int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET)/sizeof(uint32_t))); return(0); } From 149ce304f62cc63085e0161089cddd4e56126659 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 09:00:06 -1100 Subject: [PATCH 3873/3904] pricefname.string().c_str(), createflag --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 792e2b5ab..d941699dd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2673,6 +2673,7 @@ int32_t komodo_pricesinit() { if ( komodo_pricename(PRICES[i].symbol,i) == 0 ) break; + fprintf(stderr,"%s.%d ",PRICES[i].symbol,i); if ( i == 0 ) strcpy(PRICES[i].symbol,"rawprices"); pricefname = pricesdir / PRICES[i].symbol; @@ -2685,7 +2686,7 @@ int32_t komodo_pricesinit() fputc(0,PRICES[i].fp); fflush(PRICES[i].fp); } - } + } else fprintf(stderr,"error operning %s createflag.%d\n",pricefname.string().c_str(), createflag); } if ( i > 0 && PRICES[0].fp != 0 && createflag != 0 ) { From 0c3582c06a0aad460897cc144607f76b579d5ca1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 09:03:08 -1100 Subject: [PATCH 3874/3904] Fix names --- src/komodo_gateway.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d941699dd..b0e8b391d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2348,9 +2348,9 @@ char *komodo_pricename(char *name,int32_t ind) switch ( ind ) { case 0: strcpy(name,"timestamp"); break; - case 1: strcpy(name,"BTC/USD"); break; - case 2: strcpy(name,"BTC/GBP"); break; - case 3: strcpy(name,"BTC/EUR"); break; + case 1: strcpy(name,"BTCUSD"); break; + case 2: strcpy(name,"BTCGBP"); break; + case 3: strcpy(name,"BTCEUR"); break; default: return(0); break; } return(name); @@ -2364,8 +2364,8 @@ char *komodo_pricename(char *name,int32_t ind) return(0); if ( ind < sizeof(Forex)/sizeof(*Forex) ) { - name[0] = 'U', name[1] = 'S', name[2] = 'D', name[3] = '/'; - strcpy(name+4,Forex[ind]); + name[0] = 'U', name[1] = 'S', name[2] = 'D'; + strcpy(name+3,Forex[ind]); return(name); } else ind -= sizeof(Forex)/sizeof(*Forex); } @@ -2382,7 +2382,7 @@ char *komodo_pricename(char *name,int32_t ind) ind -= (sizeof(Cryptos)/sizeof(*Cryptos)); strcpy(name,ASSETCHAINS_PRICES[ind].c_str()); } - strcat(name,"/BTC"); + strcat(name,"BTC"); return(name); } else ind -= (sizeof(Cryptos)/sizeof(*Cryptos) + ASSETCHAINS_PRICES.size()); } @@ -2393,7 +2393,7 @@ char *komodo_pricename(char *name,int32_t ind) if ( ind < ASSETCHAINS_STOCKS.size() ) { strcpy(name,ASSETCHAINS_STOCKS[ind].c_str()); - strcat(name,"/USD"); + strcat(name,"USD"); return(name); } else ind -= ASSETCHAINS_STOCKS.size(); } @@ -2673,7 +2673,7 @@ int32_t komodo_pricesinit() { if ( komodo_pricename(PRICES[i].symbol,i) == 0 ) break; - fprintf(stderr,"%s.%d ",PRICES[i].symbol,i); + //fprintf(stderr,"%s.%d ",PRICES[i].symbol,i); if ( i == 0 ) strcpy(PRICES[i].symbol,"rawprices"); pricefname = pricesdir / PRICES[i].symbol; From 456ccc25644de46a78a1ce8c8dd0d29405a3d162 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 09:07:22 -1100 Subject: [PATCH 3875/3904] Shutdown if can't open prices --- src/komodo_gateway.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b0e8b391d..dc00c2391 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2695,6 +2695,11 @@ int32_t komodo_pricesinit() fflush(PRICES[0].fp); } fprintf(stderr,"pricesinit done i.%d num.%d numprices.%d\n",i,num,(int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET)/sizeof(uint32_t))); + if ( i != num || i != komodo_cbopretsize(ASSETCHAINS_CBOPRET)/sizeof(uint32_t) ) + { + fprintf(stderr,"fatal error opening prices files, start shutdown\n"); + StartShutdown(); + } return(0); } From 45f8c77b79175d7f0b7a67e4933de695da547b57 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 09:10:47 -1100 Subject: [PATCH 3876/3904] Handle prices directory there, but missing file --- src/komodo_gateway.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dc00c2391..09af54bc4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2677,7 +2677,11 @@ int32_t komodo_pricesinit() if ( i == 0 ) strcpy(PRICES[i].symbol,"rawprices"); pricefname = pricesdir / PRICES[i].symbol; - if ( (PRICES[i].fp= fopen(pricefname.string().c_str(), createflag != 0 ? "wb+" : "rb+")) != 0 ) + if ( createflag != 0 ) + PRICES[i].fp = fopen(pricefname.string().c_str(),"wb+"); + else if ( (PRICES[i].fp= fopen(pricefname.string().c_str(),"rb+")) == 0 ) + PRICES[i].fp = fopen(pricefname.string().c_str(),"wb+"); + if ( PRICES[i].fp != 0 ) { num++; if ( createflag != 0 ) @@ -2686,7 +2690,7 @@ int32_t komodo_pricesinit() fputc(0,PRICES[i].fp); fflush(PRICES[i].fp); } - } else fprintf(stderr,"error operning %s createflag.%d\n",pricefname.string().c_str(), createflag); + } else fprintf(stderr,"error opening %s createflag.%d\n",pricefname.string().c_str(), createflag); } if ( i > 0 && PRICES[0].fp != 0 && createflag != 0 ) { From a05149ce8ef2204d89a5660a11d6cf4ce8f250b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 09:13:30 -1100 Subject: [PATCH 3877/3904] Test --- src/komodo_gateway.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 09af54bc4..20e473ad6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2348,9 +2348,9 @@ char *komodo_pricename(char *name,int32_t ind) switch ( ind ) { case 0: strcpy(name,"timestamp"); break; - case 1: strcpy(name,"BTCUSD"); break; - case 2: strcpy(name,"BTCGBP"); break; - case 3: strcpy(name,"BTCEUR"); break; + case 1: strcpy(name,"BTC_USD"); break; + case 2: strcpy(name,"BTC_GBP"); break; + case 3: strcpy(name,"BTC_EUR"); break; default: return(0); break; } return(name); @@ -2364,8 +2364,8 @@ char *komodo_pricename(char *name,int32_t ind) return(0); if ( ind < sizeof(Forex)/sizeof(*Forex) ) { - name[0] = 'U', name[1] = 'S', name[2] = 'D'; - strcpy(name+3,Forex[ind]); + name[0] = 'U', name[1] = 'S', name[2] = 'D', name[3] = '_'; + strcpy(name+4,Forex[ind]); return(name); } else ind -= sizeof(Forex)/sizeof(*Forex); } @@ -2382,7 +2382,7 @@ char *komodo_pricename(char *name,int32_t ind) ind -= (sizeof(Cryptos)/sizeof(*Cryptos)); strcpy(name,ASSETCHAINS_PRICES[ind].c_str()); } - strcat(name,"BTC"); + strcat(name,"_BTC"); return(name); } else ind -= (sizeof(Cryptos)/sizeof(*Cryptos) + ASSETCHAINS_PRICES.size()); } @@ -2393,7 +2393,7 @@ char *komodo_pricename(char *name,int32_t ind) if ( ind < ASSETCHAINS_STOCKS.size() ) { strcpy(name,ASSETCHAINS_STOCKS[ind].c_str()); - strcat(name,"USD"); + strcat(name,"_USD"); return(name); } else ind -= ASSETCHAINS_STOCKS.size(); } From bceb29eb2b62dd862f1a710e8cbb226b54903b23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Apr 2019 21:55:55 -1100 Subject: [PATCH 3878/3904] New refs --- src/cc/CCPrices.h | 1 + src/komodo_defs.h | 27 +++++++++++++++++++++++---- src/komodo_gateway.h | 24 ++++++++++++++++++++++++ src/rpc/blockchain.cpp | 33 ++------------------------------- 4 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 1ecaebb2c..633cc32e2 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -19,6 +19,7 @@ #include "CCinclude.h" int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind); +int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) #define PRICES_TXFEE 10000 diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 4fd357ac1..4db390494 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -57,25 +57,21 @@ extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; extern std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; -extern char ASSETCHAINS_SYMBOL[65]; extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; -extern char ASSETCHAINS_SYMBOL[]; extern std::string CCerror,ASSETCHAINS_CCLIB; extern uint8_t ASSETCHAINS_CCDISABLES[256]; extern int32_t USE_EXTERNAL_PUBKEY; extern std::string NOTARY_PUBKEY; extern int32_t KOMODO_EXCHANGEWALLET; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern int32_t VERUS_MIN_STAKEAGE; extern std::string DONATION_PUBKEY; extern uint8_t ASSETCHAINS_PRIVATE; @@ -85,8 +81,31 @@ int tx_height( const uint256 &hash ); extern std::vector vWhiteListAddress; void komodo_netevent(std::vector payload); +#define IGUANA_MAXSCRIPTSIZE 10001 +#define KOMODO_KVDURATION 1440 +#define KOMODO_KVBINARY 2 #define PRICES_SMOOTHWIDTH 1 +uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); +int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); +char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); +int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width); +int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); + +int32_t komodo_longestchain(); +int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +int8_t komodo_segid(int32_t nocache,int32_t height); +int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); +char *komodo_pricename(char *name,int32_t ind); int32_t komodo_priceind(char *symbol); int32_t komodo_pricesinit(); +int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip); +int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); +int32_t komodo_nextheight(); +uint32_t komodo_heightstamp(int32_t height); +int64_t komodo_pricemult(int32_t ind); +int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); +uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); + #endif diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 20e473ad6..b1860dbc1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2707,6 +2707,14 @@ int32_t komodo_pricesinit() return(0); } +pthread_mutex_t pricemutex; + +// PRICES file layouts +// [0] rawprice32 / timestamp +// [1] correlated +// [2] 24hr ave +// [3] to [7] reserved + void komodo_pricesupdate(int32_t height,CBlock *pblock) { static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf; @@ -2714,6 +2722,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) { + pthread_mutex_init(&pricemutex,0); numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); ptr32 = (uint32_t *)calloc(sizeof(uint32_t),numprices * width); ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS); @@ -2727,6 +2736,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) //fprintf(stderr,"numprices.%d\n",numprices); if ( PRICES[0].fp != 0 ) { + pthread_mutex_lock(&pricemutex); fseek(PRICES[0].fp,height * numprices * sizeof(uint32_t),SEEK_SET); if ( fwrite(rawprices,sizeof(uint32_t),numprices,PRICES[0].fp) != numprices ) fprintf(stderr,"error writing rawprices for ht.%d\n",height); @@ -2774,8 +2784,22 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fprintf(stderr,"height.%d\n",height); } else fprintf(stderr,"error reading rawprices for ht.%d\n",height); } else fprintf(stderr,"height.%d <= width.%d\n",height,width); + pthread_mutex_unlock(&pricemutex); } else fprintf(stderr,"null PRICES[0].fp\n"); } else fprintf(stderr,"numprices mismatch, height.%d\n",height); } +int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks) +{ + FILE *fp; int32_t retval = PRICES_MAXDATAPOINTS; + pthread_mutex_lock(&pricemutex); + if ( ind < KOMODO_MAXPRICES && (fp= PRICES[ind].fp) != 0 ) + { + fseek(fp,height * PRICES_MAXDATAPOINTS * sizeof(int64_t),SEEK_SET); + if ( fread(buf64,sizeof(int64_t),numblocks*PRICES_MAXDATAPOINTS,fp) != numblocks*PRICES_MAXDATAPOINTS ) + retval = -1; + } + pthread_mutex_unlock(&pricemutex); + return(retval); +} diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 83fcd8cad..84bdfd02e 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -47,10 +47,8 @@ using namespace std; extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); -int32_t komodo_longestchain(); -int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); -extern int8_t komodo_segid(int32_t nocache,int32_t height); -extern int32_t KOMODO_LONGESTCHAIN; +#include "komodo_defs.h" +#include "komodo_structs.h" double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty) { @@ -628,8 +626,6 @@ UniValue getblockhash(const UniValue& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } -extern int32_t ASSETCHAINS_STAKED; - UniValue getlastsegidstakes(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -915,20 +911,6 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp) return ret; } -#include "komodo_defs.h" -#include "komodo_structs.h" - -#define IGUANA_MAXSCRIPTSIZE 10001 -#define KOMODO_KVDURATION 1440 -#define KOMODO_KVBINARY 2 -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern int32_t ASSETCHAINS_LWMAPOS; -uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); -int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); -int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); -char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); -int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width); -int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); UniValue kvsearch(const UniValue& params, bool fHelp) { @@ -1174,15 +1156,6 @@ UniValue paxprice(const UniValue& params, bool fHelp) return ret; } -int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); -char *komodo_pricename(char *name,int32_t ind); -int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip); -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); -int32_t komodo_nextheight(); -uint32_t komodo_heightstamp(int32_t height); -int64_t komodo_pricemult(int32_t ind); -#define PRICES_SMOOTHWIDTH 1 - int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) { int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; uint32_t rawprices[1440*6],*ptr; int64_t *tmpbuf; @@ -1324,8 +1297,6 @@ UniValue prices(const UniValue& params, bool fHelp) return ret; } -uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); - UniValue gettxout(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 3) From 9d0a39dbd742239850ec3d62a2e5c395245ac645 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 13 Apr 2019 19:19:00 -1100 Subject: [PATCH 3879/3904] coinsupply inflation calc --- src/rpc/blockchain.cpp | 1 + src/rpc/misc.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 84bdfd02e..18f7b0fc0 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1255,6 +1255,7 @@ UniValue prices(const UniValue& params, bool fHelp) rngval = (rngval*11109 + 13849); if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],1,0,PRICES_SMOOTHWIDTH)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); + } tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW); for (i=0; i 1) throw runtime_error("coinsupply \n" "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" @@ -448,6 +448,26 @@ UniValue coinsupply(const UniValue& params, bool fHelp) result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); result.push_back(Pair("sprout", ValueFromAmount(sproutfunds))); result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); + if ( ASSETCHAINS_BLOCKTIME > 0 ) + { + blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME; + if ( height > blocks_per_year ) + { + supply1 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/12); + supply3 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/4); + supply12 = komodo_coinsupply(&zf,&sf,height - blocks_per_year); + if ( supply1 != 0 && supply3 != 0 && supply12 != 0 ) + { + result.push_back(Pair("lastmonth", ValueFromAmount(supply1))); + result.push_back(Pair("monthcoins", ValueFromAmount(supply - supply1))); + result.push_back(Pair("lastquarter", ValueFromAmount(supply3))); + result.push_back(Pair("quartercoins", ValueFromAmount(supply - supply3))); + result.push_back(Pair("lastyear", ValueFromAmount(supply12))); + result.push_back(Pair("yearcoins", ValueFromAmount(supply - supply12))); + result.push_back(Pair("inflation", 100. * (((double)supply/supply12)-1.))); + } + } + } } else result.push_back(Pair("error", "couldnt calculate supply")); } else { result.push_back(Pair("error", "invalid height")); From 8c27ef7372d2dacddb3d69ef30453e349a688172 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 13 Apr 2019 20:41:40 -1100 Subject: [PATCH 3880/3904] Coin supply changes to include funds --- src/rpc/misc.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 48914cce1..0d741422f 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -413,7 +413,7 @@ public: UniValue coinsupply(const UniValue& params, bool fHelp) { - int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf,sf,sproutfunds,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ); + int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf1,zf3,zf12,sf1,sf3,sf12,sproutfunds,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ); if (fHelp || params.size() > 1) throw runtime_error("coinsupply \n" "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" @@ -453,18 +453,19 @@ UniValue coinsupply(const UniValue& params, bool fHelp) blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME; if ( height > blocks_per_year ) { - supply1 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/12); - supply3 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/4); - supply12 = komodo_coinsupply(&zf,&sf,height - blocks_per_year); + supply1 = komodo_coinsupply(&zf1,&sf1,height - blocks_per_year/12); + supply3 = komodo_coinsupply(&zf3,&sf3,height - blocks_per_year/4); + supply12 = komodo_coinsupply(&zf12,&sf12,height - blocks_per_year); if ( supply1 != 0 && supply3 != 0 && supply12 != 0 ) { - result.push_back(Pair("lastmonth", ValueFromAmount(supply1))); - result.push_back(Pair("monthcoins", ValueFromAmount(supply - supply1))); - result.push_back(Pair("lastquarter", ValueFromAmount(supply3))); - result.push_back(Pair("quartercoins", ValueFromAmount(supply - supply3))); - result.push_back(Pair("lastyear", ValueFromAmount(supply12))); - result.push_back(Pair("yearcoins", ValueFromAmount(supply - supply12))); - result.push_back(Pair("inflation", 100. * (((double)supply/supply12)-1.))); + result.push_back(Pair("lastmonth", ValueFromAmount(supply1+zf1))); + result.push_back(Pair("monthcoins", ValueFromAmount(zfunds + supply - supply1-zf1))); + result.push_back(Pair("lastquarter", ValueFromAmount(supply3+zf3))); + result.push_back(Pair("quartercoins", ValueFromAmount(zfunds + supply - supply3-zf3))); + result.push_back(Pair("lastyear", ValueFromAmount(supply12+zf12))); + result.push_back(Pair("yearcoins", ValueFromAmount(zfunds + supply - supply12-zf12))); + result.push_back(Pair("inflation", 100. * (((double)(zfunds + supply)/(supply12+zf12))-1.))); + result.push_back(Pair("blocksperyear", (int64_t)blocks_per_year))); } } } From 1ca7ee28e008fa32e54b232d9a7a2050690ca979 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 13 Apr 2019 20:49:31 -1100 Subject: [PATCH 3881/3904] -) --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 0d741422f..4e21ab9e9 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -465,7 +465,7 @@ UniValue coinsupply(const UniValue& params, bool fHelp) result.push_back(Pair("lastyear", ValueFromAmount(supply12+zf12))); result.push_back(Pair("yearcoins", ValueFromAmount(zfunds + supply - supply12-zf12))); result.push_back(Pair("inflation", 100. * (((double)(zfunds + supply)/(supply12+zf12))-1.))); - result.push_back(Pair("blocksperyear", (int64_t)blocks_per_year))); + result.push_back(Pair("blocksperyear", (int64_t)blocks_per_year)); } } } From 7c56d034748a2eb1596ba7078d7fd1fbbedfa203 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 14 Apr 2019 15:51:26 +0800 Subject: [PATCH 3882/3904] try wallet fix --- src/wallet/walletdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 83a79821f..3428b8b75 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -961,7 +961,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if (GetTransaction(hash,tx,blockhash,true)) { CWalletTx wtx(pwallet,tx); - pwallet->AddToWallet(wtx, true, NULL); + pwallet->AddToWallet(wtx, false, NULL); reAdded++; } } From aec18840703dbea6a38bcaa98b3e34312308bd10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 14 Apr 2019 02:15:56 -1100 Subject: [PATCH 3883/3904] StartShutdown(); instead of exit() --- src/cc/dice.cpp | 2 +- src/cryptoconditions/src/secp256k1.c | 2 +- src/komodo_bitcoind.h | 4 ++-- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 27 ++++++++++++++++----------- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 76d68e090..20f7a0567 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1662,7 +1662,7 @@ void *dealer0_loop(void *_arg) if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); - exit(-1); + StartShutdown(); } fprintf(stderr,"dealer0 node running\n"); height = lastht = 0; diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index 31bab06e5..aa82376a3 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -68,7 +68,7 @@ void lockSign() { } if (!secp256k1_context_randomize(ec_ctx_sign, ent)) { fprintf(stderr, "Could not randomize secp256k1 context\n"); - exit(1); + StartShutdown(); } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 58d984eb7..2f9c1a8d7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -57,7 +57,7 @@ void init_string(struct return_string *s) if ( s->ptr == NULL ) { fprintf(stderr,"init_string malloc() failed\n"); - exit(-1); + StartShutdown(); } s->ptr[0] = '\0'; } @@ -94,7 +94,7 @@ size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string * if ( s->ptr == NULL ) { fprintf(stderr, "accumulate realloc() failed\n"); - exit(-1); + StartShutdown(); } memcpy(s->ptr+s->len,ptr,size*nmemb); s->ptr[new_len] = '\0'; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b1860dbc1..a6b5b4566 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max) if ( sizeof(banned_txids)/sizeof(*banned_txids) > max ) { fprintf(stderr,"komodo_bannedset: buffer too small %ld vs %d\n",sizeof(banned_txids)/sizeof(*banned_txids),max); - exit(-1); + StartShutdown(); } for (i=0; i (uint64_t)90*1000*1000000 ) { fprintf(stderr,"-ac_supply must be less than 90 billion\n"); - exit(0); + StartShutdown(); } fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY); @@ -1839,7 +1839,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_FOUNDERS_REWARD != 0 ) { fprintf(stderr,"cannot use founders reward and commission on the same chain.\n"); - exit(0); + StartShutdown(); } if ( ASSETCHAINS_CC != 0 ) { @@ -1879,7 +1879,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { fprintf(stderr,"can only have one of -ac_beam or -ac_coda\n"); - exit(0); + StartShutdown(); } ASSETCHAINS_SELFIMPORT = GetArg("-ac_import",""); // BEAM, CODA, PUBKEY, GATEWAY if ( ASSETCHAINS_SELFIMPORT == "PUBKEY" ) @@ -1887,18 +1887,18 @@ void komodo_args(char *argv0) if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 ) { fprintf(stderr,"invalid -ac_pubkey for -ac_import=PUBKEY\n"); - exit(0); + StartShutdown(); } } else if ( ASSETCHAINS_SELFIMPORT == "BEAM" && ASSETCHAINS_BEAMPORT == 0 ) { fprintf(stderr,"missing -ac_beam for BEAM rpcport\n"); - exit(0); + StartShutdown(); } else if ( ASSETCHAINS_SELFIMPORT == "CODA" && ASSETCHAINS_CODAPORT == 0 ) { fprintf(stderr,"missing -ac_coda for CODA rpcport\n"); - exit(0); + StartShutdown(); } // else it can be gateway coin @@ -1926,12 +1926,12 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_SUPPLY > 10000000000 ) { printf("ac_pubkey or ac_script wont work with ac_supply over 10 billion\n"); - exit(0); + StartShutdown(); } if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n"); - exit(0); + StartShutdown(); } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) { @@ -1972,7 +1972,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 && ASSETCHAINS_MARMARA != 0 ) { fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); - exit(0); + StartShutdown(); } if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 ) { @@ -2150,7 +2150,7 @@ void komodo_args(char *argv0) if ( strcmp(ASSETCHAINS_SYMBOL,"KMD") == 0 ) { fprintf(stderr,"cant have assetchain named KMD\n"); - exit(0); + StartShutdown(); } if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; @@ -2232,6 +2232,11 @@ void komodo_args(char *argv0) } else if ( strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 ) dpowconfs = 0; + else if ( ASSETCHAINS_PRIVATE != 0 ) + { + fprintf(stderr,"-ac_private for a non-PIRATE chain is not supported. The only reason to have an -ac_private chain is for total privacy and that is best achieved with the largest anon set. PIRATE has that and it is recommended to just use PIRATE\n"); + StartShutdown(); + } } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs); if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"SUPERNET") == 0 || strcmp(ASSETCHAINS_SYMBOL,"DEX") == 0 || strcmp(ASSETCHAINS_SYMBOL,"COQUI") == 0 || strcmp(ASSETCHAINS_SYMBOL,"PIRATE") == 0 || strcmp(ASSETCHAINS_SYMBOL,"KMDICE") == 0 ) From 9d208da4b64e21ab800fed677361d5651b777ea5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 14 Apr 2019 02:17:58 -1100 Subject: [PATCH 3884/3904] void StartShutdown() --- src/cc/CCinclude.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 08d466411..5b6d575f3 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -164,6 +164,7 @@ UniValue CClib_info(struct CCcontract_info *cp); CBlockIndex *komodo_blockindex(uint256 hash); CBlockIndex *komodo_chainactive(int32_t height); int32_t komodo_blockheight(uint256 hash); +void StartShutdown(); static const uint256 zeroid; static uint256 ignoretxid; From edfaea0c64be6a08c01a89609f199e37e7214690 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 14 Apr 2019 02:45:06 -1100 Subject: [PATCH 3885/3904] Revert to exit --- src/cryptoconditions/src/secp256k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index aa82376a3..7cb557fb0 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -68,7 +68,7 @@ void lockSign() { } if (!secp256k1_context_randomize(ec_ctx_sign, ent)) { fprintf(stderr, "Could not randomize secp256k1 context\n"); - StartShutdown(); + exit(-1); } } From 4f3253fdc903713237d0d5b379d72c4527307d79 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Sun, 14 Apr 2019 18:56:10 +0300 Subject: [PATCH 3886/3904] VOTE2019 --- src/ac/vote2019 | 2 ++ src/assetchains.json | 6 ++++++ src/assetchains.old | 1 + src/fiat/vote2019 | 2 ++ 4 files changed, 11 insertions(+) create mode 100755 src/ac/vote2019 create mode 100755 src/fiat/vote2019 diff --git a/src/ac/vote2019 b/src/ac/vote2019 new file mode 100755 index 000000000..029558808 --- /dev/null +++ b/src/ac/vote2019 @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=VOTE2019 $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index d40d63f29..87173697b 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -257,5 +257,11 @@ "ac_reward": "100000000", "ac_cc": "3", "addnode": ["138.201.136.145"] + }, +{ + "ac_name": "VOTE2019", + "ac_supply": "123651638", + "ac_public": "1", + "addnode": ["95.213.238.98"] } ] diff --git a/src/assetchains.old b/src/assetchains.old index d200d26bd..8f0d763b5 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -49,3 +49,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 & ./komodod -pubkey=$pubkey -ac_name=RICK -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 & ./komodod -pubkey=$pubkey -ac_name=MORTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 & +./komodod -pubkey=$pubkey -ac_name=VOTE2019 -ac_supply=123651638 -ac_public=1 -addnode=95.213.238.98 & diff --git a/src/fiat/vote2019 b/src/fiat/vote2019 new file mode 100755 index 000000000..029558808 --- /dev/null +++ b/src/fiat/vote2019 @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=VOTE2019 $1 $2 $3 $4 $5 $6 From f7e94b113e97df29a67cea5e965e5d4cb93c8226 Mon Sep 17 00:00:00 2001 From: phm87 <31578435+phm87@users.noreply.github.com> Date: Sun, 14 Apr 2019 18:29:28 +0200 Subject: [PATCH 3887/3904] init.cpp : Help message for -whitelistaddress= Few days ago, on discord, blackjok3r said that he hopes that somebody will add a help message for -whitelistaddress= --- src/init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.cpp b/src/init.cpp index 042d1d9fd..89390b5ed 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -399,6 +399,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX)); strUsage += HelpMessageGroup(_("Connection options:")); strUsage += HelpMessageOpt("-addnode=", _("Add a node to connect to and attempt to keep the connection open")); + strUsage += HelpMessageOpt("-whitelistaddress=", _("Enable the wallet filter for notary nodes and add one Raddress to the whitelist of the wallet filter. If -whitelistaddress= is used, then the wallet filter is automatically activated. Several Raddresses can be defined using several -whitelistaddress= (similar to -addnode). The wallet filter will filter the utxo to only ones coming from my own Raddress (derived from pubkey) and each Raddress defined using -whitelistaddress= this option is mostly for Notary Nodes).")); strUsage += HelpMessageOpt("-banscore=", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), 100)); strUsage += HelpMessageOpt("-bantime=", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), 86400)); strUsage += HelpMessageOpt("-bind=", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6")); From 35ad4a6bc329541a7539316145c4db25bf900af7 Mon Sep 17 00:00:00 2001 From: phm87 <31578435+phm87@users.noreply.github.com> Date: Sun, 14 Apr 2019 19:24:29 +0200 Subject: [PATCH 3888/3904] init.cpp : move help message -whitelistaddress= Move the help message of -whitelistaddress= to the section related to "Wallet options:" --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 89390b5ed..4003f9ced 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -399,7 +399,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX)); strUsage += HelpMessageGroup(_("Connection options:")); strUsage += HelpMessageOpt("-addnode=", _("Add a node to connect to and attempt to keep the connection open")); - strUsage += HelpMessageOpt("-whitelistaddress=", _("Enable the wallet filter for notary nodes and add one Raddress to the whitelist of the wallet filter. If -whitelistaddress= is used, then the wallet filter is automatically activated. Several Raddresses can be defined using several -whitelistaddress= (similar to -addnode). The wallet filter will filter the utxo to only ones coming from my own Raddress (derived from pubkey) and each Raddress defined using -whitelistaddress= this option is mostly for Notary Nodes).")); strUsage += HelpMessageOpt("-banscore=", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), 100)); strUsage += HelpMessageOpt("-bantime=", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), 86400)); strUsage += HelpMessageOpt("-bind=", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6")); @@ -452,6 +451,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-wallet=", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), "wallet.dat")); strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), true)); strUsage += HelpMessageOpt("-walletnotify=", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)")); + strUsage += HelpMessageOpt("-whitelistaddress=", _("Enable the wallet filter for notary nodes and add one Raddress to the whitelist of the wallet filter. If -whitelistaddress= is used, then the wallet filter is automatically activated. Several Raddresses can be defined using several -whitelistaddress= (similar to -addnode). The wallet filter will filter the utxo to only ones coming from my own Raddress (derived from pubkey) and each Raddress defined using -whitelistaddress= this option is mostly for Notary Nodes).")); strUsage += HelpMessageOpt("-zapwallettxes=", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") + " " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)")); #endif From c9f395f241503c75205be8d91d80ee86d9c1ae05 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 15 Apr 2019 12:08:58 +0800 Subject: [PATCH 3889/3904] revert miner change. Causes crash when staking. --- src/miner.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 54b18195a..f131bc90e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -224,7 +224,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CBlockIndex* pindexPrev = 0; { - LOCK2(cs_main,mempool.cs); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); pindexPrev = chainActive.LastTip(); const int nHeight = pindexPrev->GetHeight() + 1; const Consensus::Params &consensusParams = chainparams.GetConsensus(); @@ -563,10 +564,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { - uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[512],*ptr; - CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(mempool.cs); + uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[512],*ptr; + CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); + if (ASSETCHAINS_LWMAPOS != 0) { uint32_t nBitsPOS; @@ -591,7 +593,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { sleep(1); if ( (rand() % 100) < 1 ) - fprintf(stderr, "%u seconds until elegible, waiting...\n", blocktime-((uint32_t)GetAdjustedTime()+57)); + fprintf(stderr, "%u seconds until elegible, waiting.\n", blocktime-((uint32_t)GetAdjustedTime()+57)); if ( chainActive.LastTip()->GetHeight() >= stakeHeight ) { fprintf(stderr, "Block Arrived, reset staking loop.\n"); @@ -601,8 +603,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 return(0); } } - ENTER_CRITICAL_SECTION(cs_main); - ENTER_CRITICAL_SECTION(mempool.cs); + if ( siglen > 0 ) { CAmount txfees; @@ -615,7 +616,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nFees += txfees; pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); - } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); + } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } // Create coinbase tx @@ -687,6 +688,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (scriptPubKeyIn.IsPayToScriptHash() || scriptPubKeyIn.IsPayToCryptoCondition()) { fprintf(stderr,"CreateNewBlock: attempt to add timelock to pay2sh or pay2cc\n"); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } return 0; } @@ -708,6 +714,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } return(0); } fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); @@ -778,6 +789,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 else { fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } return(0); } } @@ -792,6 +808,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr,"valid\n"); } } + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } From 2e727de8eee3b65f87f6c5075de54980a7240b5d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 15 Apr 2019 19:58:13 +0800 Subject: [PATCH 3890/3904] fix wallet crash --- src/wallet/walletdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 3428b8b75..eab041d94 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -954,6 +954,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if (!deadTxns.empty()) { int32_t reAdded = 0; + CWalletDB walletdb(pwallet->strWalletFile, "r+", false); BOOST_FOREACH (uint256& hash, deadTxns) { if (!EraseTx(hash)) fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); @@ -961,7 +962,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if (GetTransaction(hash,tx,blockhash,true)) { CWalletTx wtx(pwallet,tx); - pwallet->AddToWallet(wtx, false, NULL); + pwallet->AddToWallet(wtx, false, &walletdb); reAdded++; } } From f087f49c4dc2e27d729386e39d239e4dcda2e519 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 15 Apr 2019 16:00:03 +0200 Subject: [PATCH 3891/3904] Fix looking for wrong type marker in Oracles CC --- src/cc/oracles.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 1b13a00b7..54e9202e1 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -197,7 +197,7 @@ int64_t OracleCurrentDatafee(uint256 reforacletxid,char *markeraddr,CPubKey publ { uint256 txid,oracletxid,hashBlock; int64_t datafee=0,dfee; int32_t dheight=0,vout,height,numvouts; CTransaction tx; CPubKey pk; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,markeraddr,true); + SetCCunspents(unspentOutputs,markeraddr,false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -306,7 +306,7 @@ uint256 OraclesBatontxid(uint256 reforacletxid,CPubKey refpk) batontxid = zeroid; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,reforacletxid); - SetCCunspents(unspentOutputs,markeraddr,true); + SetCCunspents(unspentOutputs,markeraddr,false); //char str[67]; fprintf(stderr,"markeraddr.(%s) %s\n",markeraddr,pubkey33_str(str,(uint8_t *)&refpk)); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -532,7 +532,7 @@ int32_t oracleprice_add(std::vector &publishers,CPubKey if ( format[0] != 'L' ) return(0); cp = CCinit(&C,EVAL_ORACLES); - SetCCunspents(unspentOutputs,markeraddr,true); + SetCCunspents(unspentOutputs,markeraddr,false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -992,7 +992,7 @@ UniValue OracleInfo(uint256 origtxid) result.push_back(Pair("description",description)); result.push_back(Pair("format",format)); result.push_back(Pair("marker",markeraddr)); - SetCCunspents(unspentOutputs,markeraddr,true); + SetCCunspents(unspentOutputs,markeraddr,false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From c3a9d0fa0cd5fd7939b68162db8b50a8505471d7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Apr 2019 12:28:27 +0800 Subject: [PATCH 3892/3904] test --- src/rpc/rawtransaction.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 6e90c4db5..41ed8ff66 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -721,7 +721,7 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp) UniValue createrawtransaction(const UniValue& params, bool fHelp) { - if (fHelp || params.size() < 2 || params.size() > 4) + if (fHelp ) || //params.size() < 2 || params.size() > 4) throw runtime_error( "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} ( locktime ) ( expiryheight )\n" "\nCreate a transaction spending the given inputs and sending to the given addresses.\n" @@ -754,6 +754,32 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"") ); + int nextBlockHeight = chainActive.Height() + 1; + CMutableTransaction rawTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); + CCcontract_info *cp, C; + + cp = CCinit(&C,EVAL_ORACLES); + CPubKey ccAddress = CPubKey(ParseHex(cp->CChexstr)); + CPubKey mypk = Mypubkey(); + + CTxOut vout = MakeCC1of2vout(EVAL_ORACLES, 1000000, mypk, ccAddress); + + std::vector vPubKeys = std::vector(); + vPubKeys.push_back(mypk); + vPubKeys.push_back(ccAddress); + + std::vector> vData = std::vector>(); + std::string test = "thisisatest"; + vData.push_back(std::vector(test.begin(), test.end())); + test = "anothertest"; + vData.push_back(std::vector(test.begin(), test.end())); + COptCCParams ccp = COptCCParams(COptCCParams::VERSION, EVAL_ORACLES, 1, 2, vPubKeys, vData); + + vout.scriptPubKey << ccp.AsVector() << OP_DROP; + rawTx.vout.push_back(vout); + + return EncodeHexTx(rawTx); + LOCK(cs_main); RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM)(UniValue::VNUM), true); if (params[0].isNull() || params[1].isNull()) From 0bb8c5be229521d584ac40900ee5a9a853a4f1a1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Apr 2019 13:14:04 +0800 Subject: [PATCH 3893/3904] fix wallet code. Force daemon close and reccomend zapwallettxns for non staking chains. --- src/wallet/walletdb.cpp | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index eab041d94..5631fb79e 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -30,6 +30,7 @@ #include "utiltime.h" #include "wallet/wallet.h" #include "zcash/Proof.hpp" +#include "komodo_defs.h" #include #include @@ -486,7 +487,6 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) { - fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); deadTxns.push_back(hash); return false; } @@ -951,23 +951,35 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) result = DB_CORRUPT; } - if (!deadTxns.empty()) + if ( !deadTxns.empty() ) { - int32_t reAdded = 0; - CWalletDB walletdb(pwallet->strWalletFile, "r+", false); - BOOST_FOREACH (uint256& hash, deadTxns) { - if (!EraseTx(hash)) - fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); - uint256 blockhash; CTransaction tx; - if (GetTransaction(hash,tx,blockhash,true)) + if ( ASSETCHAINS_STAKED != 0 ) + { + int32_t reAdded = 0; + CWalletDB walletdb(pwallet->strWalletFile, "r+", false); + BOOST_FOREACH (uint256& hash, deadTxns) { - CWalletTx wtx(pwallet,tx); - pwallet->AddToWallet(wtx, false, &walletdb); - reAdded++; + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + if (!EraseTx(hash)) + fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); + uint256 blockhash; CTransaction tx; + if (GetTransaction(hash,tx,blockhash,true)) + { + CWalletTx wtx(pwallet,tx); + pwallet->AddToWallet(wtx, false, &walletdb); + reAdded++; + } } + fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",(long)deadTxns.size(),reAdded); + fNoncriticalErrors = false; + deadTxns.clear(); + } + else if ( (GetBoolArg("-zapwallettxes", false)) ) + { + LogPrintf("Transactions are corrupted. Please restart daemon with -zapwallettxes=2\n"); + fprintf(stderr,"Transactions are corrupted. Please restart daemon with -zapwallettxes=2\n"); + return DB_CORRUPT; } - fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",(long)deadTxns.size(),reAdded); - deadTxns.clear(); } if (fNoncriticalErrors && result == DB_LOAD_OK) From ece9e468bc2de19eeb7a0aca9f63c4000887c866 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 15 Apr 2019 23:14:46 -1100 Subject: [PATCH 3894/3904] #define PRICES_MAXDATAPOINTS 8 --- src/komodo_defs.h | 1 + src/komodo_gateway.h | 1 - src/rpc/blockchain.cpp | 9 ++++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 4db390494..23a689154 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -85,6 +85,7 @@ void komodo_netevent(std::vector payload); #define KOMODO_KVDURATION 1440 #define KOMODO_KVBINARY 2 #define PRICES_SMOOTHWIDTH 1 +#define PRICES_MAXDATAPOINTS 8 uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a6b5b4566..ed80c2a4a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1555,7 +1555,6 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define KOMODO_LOCALPRICE_CACHESIZE 13 #define KOMODO_MAXPRICES 2048 #define PRICES_SMOOTHWIDTH 1 -#define PRICES_MAXDATAPOINTS 8 #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 18f7b0fc0..ab6bd7fb9 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1255,7 +1255,14 @@ UniValue prices(const UniValue& params, bool fHelp) rngval = (rngval*11109 + 13849); if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],1,0,PRICES_SMOOTHWIDTH)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); - + { + int64_t checkprices[PRICES_MAXDATAPOINTS]; + if ( komodo_priceget(checkprices,j,nextheight-1-i,1) >= 0 ) + { + if ( checkprices[1] != correlated[i] ) + fprintf(stderr,"ind.%d ht.%d %.8f != %.8f\n",j,nextheight-1-i,(double)checkprices[1]/COIN,(double)correlated[i]/COIN); + } + } } tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW); for (i=0; i Date: Mon, 15 Apr 2019 23:27:20 -1100 Subject: [PATCH 3895/3904] Smoothed --- src/rpc/blockchain.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ab6bd7fb9..c0a45e292 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1195,7 +1195,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t *tmpbuf,smoothed,*correlated; char name[64],*str; uint32_t rawprices[1440*6],*prices; uint32_t i,width,j,numpricefeeds=-1,n,numsamples,nextheight,offset,ht; + UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t *tmpbuf,smoothed,*correlated,checkprices[PRICES_MAXDATAPOINTS]; char name[64],*str; uint32_t rawprices[1440*6],*prices; uint32_t i,width,j,numpricefeeds=-1,n,numsamples,nextheight,offset,ht; if ( ASSETCHAINS_CBOPRET == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); @@ -1256,11 +1256,13 @@ UniValue prices(const UniValue& params, bool fHelp) if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],1,0,PRICES_SMOOTHWIDTH)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); { - int64_t checkprices[PRICES_MAXDATAPOINTS]; if ( komodo_priceget(checkprices,j,nextheight-1-i,1) >= 0 ) { if ( checkprices[1] != correlated[i] ) - fprintf(stderr,"ind.%d ht.%d %.8f != %.8f\n",j,nextheight-1-i,(double)checkprices[1]/COIN,(double)correlated[i]/COIN); + { + //fprintf(stderr,"ind.%d ht.%d %.8f != %.8f\n",j,nextheight-1-i,(double)checkprices[1]/COIN,(double)correlated[i]/COIN); + correlated[i] = checkprices[1]; + } } } } @@ -1269,6 +1271,14 @@ UniValue prices(const UniValue& params, bool fHelp) { offset = j*width + i; smoothed = komodo_priceave(tmpbuf,&correlated[i],1); + if ( komodo_priceget(checkprices,j,nextheight-1-i,1) >= 0 ) + { + if ( checkprices[2] != smoothed ) + { + fprintf(stderr,"ind.%d ht.%d %.8f != %.8f\n",j,nextheight-1-i,(double)checkprices[2]/COIN,(double)smoothed/COIN); + smoothed = checkprices[2]; + } + } UniValue parr(UniValue::VARR); parr.push_back(ValueFromAmount((int64_t)prices[offset] * komodo_pricemult(j))); parr.push_back(ValueFromAmount(correlated[i])); From 81aa1908d9b4bafaa307863eca616079a442c73c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 15 Apr 2019 23:31:59 -1100 Subject: [PATCH 3896/3904] Deprecate prices_extract --- src/cc/CCPrices.h | 1 - src/cc/prices.cpp | 6 ++---- src/rpc/blockchain.cpp | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 633cc32e2..3dbe6a87c 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -18,7 +18,6 @@ #define CC_PRICES_H #include "CCinclude.h" -int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind); int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 5d164d97e..407cd81fa 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -320,8 +320,7 @@ int32_t prices_syntheticvec(std::vector &vec,std::vector int64_t prices_syntheticprice(std::vector vec,int32_t height,int32_t minmax,int16_t leverage) { - int32_t i,ind,errcode,depth,retval = -1; uint16_t opcode; int64_t *pricedata,pricestack[4],price,den,a,b,c; - pricedata = (int64_t *)calloc(sizeof(*pricedata)*3,1 + PRICES_DAYWINDOW*2 + PRICES_SMOOTHWIDTH); + int32_t i,ind,errcode,depth,retval = -1; uint16_t opcode; int64_t pricedata[PRICES_MAXDATAPOINTS],pricestack[4],price,den,a,b,c; price = den = depth = errcode = 0; for (i=0; i vec,int32_t height,int32_t m { case 0: pricestack[depth] = 0; - if ( prices_extract(pricedata,height,1,ind) == 0 ) + if ( komodo_priceget(pricedata,ind,height,1) > 0 ) { if ( minmax == 0 ) pricestack[depth] = pricedata[2]; @@ -420,7 +419,6 @@ int64_t prices_syntheticprice(std::vector vec,int32_t height,int32_t m if ( errcode != 0 ) break; } - free(pricedata); if ( den == 0 ) return(-11); else if ( depth != 0 ) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c0a45e292..035d44662 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1156,7 +1156,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) return ret; } -int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) +/*int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks,int32_t ind) { int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; uint32_t rawprices[1440*6],*ptr; int64_t *tmpbuf; width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; @@ -1188,7 +1188,7 @@ int32_t prices_extract(int64_t *pricedata,int32_t firstheight,int32_t numblocks, pricedata[i*3+2] = komodo_priceave(tmpbuf,&pricedata[i*3+1],3); free(tmpbuf); return(0); -} +}*/ UniValue prices(const UniValue& params, bool fHelp) { From 997f9ce5fcfb600cc6832a431c11912c8b94b65e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Apr 2019 20:59:15 +0800 Subject: [PATCH 3897/3904] initial commit to use CCopt for custom CC --- src/cc/CCinclude.h | 4 ++-- src/cc/CCutils.cpp | 21 +++++++++++++++++++-- src/cc/customcc.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- src/main.cpp | 2 +- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 5b6d575f3..6ca6fa3bc 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -226,8 +226,8 @@ bool priv2addr(char *coinaddr,uint8_t buf33[33],uint8_t priv32[32]); CPubKey buf2pk(uint8_t *buf33); void endiancpy(uint8_t *dest,uint8_t *src,int32_t len); uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t entropyvout,int32_t usevout); -CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk); -CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2); +CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk, const std::vector>* vData = NULL); +CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2, const std::vector>* vData = NULL); CC *MakeCCcond1(uint8_t evalcode,CPubKey pk); CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2); CC* GetCryptoCondition(CScript const& scriptSig); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 55c93d7b3..a34bf1a81 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -58,20 +58,37 @@ CC *MakeCCcond1(uint8_t evalcode,CPubKey pk) return CCNewThreshold(2, {condCC, Sig}); } -CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk) +CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue, CPubKey pk, const std::vector>* vData) { CTxOut vout; CC *payoutCond = MakeCCcond1(evalcode,pk); vout = CTxOut(nValue,CCPubKey(payoutCond)); + if ( vData ) + { + std::vector> vtmpData = std::vector>(vData->begin(), vData->end()); + std::vector vPubKeys = std::vector(); + vPubKeys.push_back(pk); + COptCCParams ccp = COptCCParams(COptCCParams::VERSION, evalcode, 1, 1, vPubKeys, vtmpData); + vout.scriptPubKey << ccp.AsVector() << OP_DROP; + } cc_free(payoutCond); return(vout); } -CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk1,CPubKey pk2) +CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk1,CPubKey pk2, const std::vector>* vData) { CTxOut vout; CC *payoutCond = MakeCCcond1of2(evalcode,pk1,pk2); vout = CTxOut(nValue,CCPubKey(payoutCond)); + if ( vData ) + { + std::vector> vtmpData = std::vector>(vData->begin(), vData->end()); + std::vector vPubKeys = std::vector(); + vPubKeys.push_back(pk1); + vPubKeys.push_back(pk2); + COptCCParams ccp = COptCCParams(COptCCParams::VERSION, evalcode, 1, 2, vPubKeys, vtmpData); + vout.scriptPubKey << ccp.AsVector() << OP_DROP; + } cc_free(payoutCond); return(vout); } diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp index 9f58c5c8b..34144fedc 100644 --- a/src/cc/customcc.cpp +++ b/src/cc/customcc.cpp @@ -11,7 +11,7 @@ */ CScript custom_opret(uint8_t funcid,CPubKey pk) -{ +{ CScript opret; uint8_t evalcode = EVAL_CUSTOM; opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); return(opret); @@ -64,25 +64,54 @@ UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); if ( AddNormalinputs(mtx,mypk,COIN+txfee,64) >= COIN+txfee ) // add utxo to mtx { - mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0 - // add opreturn, change is automatically added and tx is properly signed - rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,custom_opret('1',mypk)); + // make op_return payload as normal. + CScript opret = custom_opret('1',mypk); + std::vector> vData = std::vector>(); + vData.push_back(std::vector(opret.begin(), opret.end())); + // make vout0 with op_return included as payload. + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk,&vData)); + fprintf(stderr, "vout size2.%li\n", mtx.vout.size()); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,CScript()); return(custom_rawtxresult(result,rawtx,broadcastflag)); } return(result); } +bool has_opret(const CTransaction &tx, uint8_t evalcode) +{ + for ( auto vout : tx.vout ) + { + if ( vout.scriptPubKey[1] == evalcode ) + return true; + } + return false; +} + bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { char expectedaddress[64]; CPubKey pk; - if ( tx.vout.size() != 2 ) // make sure the tx only has 2 outputs + CScript opret; int32_t numvout; + if ( !has_opret(tx, EVAL_CUSTOM) ) + { + std::vector> vParams = std::vector>(); + CScript dummy; + if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition(&dummy, vParams) && vParams.size() == 1 ) + { + opret << E_MARSHAL(ss << vParams[0]); + } + numvout = 1; + } + else + { + opret = tx.vout[1].scriptPubKey; + numvout = 2; + } + if ( tx.vout.size() != numvout ) // make sure the tx only has appropriate outputs return eval->Invalid("invalid number of vouts"); - else if ( custom_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn + else if ( custom_opretdecode(pk,opret) != '1' ) // verify opreturn payload return eval->Invalid("invalid opreturn"); GetCCaddress(cp,expectedaddress,pk); if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches return(true); else return eval->Invalid("invalid vout0 amount"); } - - diff --git a/src/main.cpp b/src/main.cpp index e0e40c9a5..304ff52a5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -796,7 +796,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; return false; - } else if (txout.scriptPubKey.IsPayToCryptoCondition() == 0 && txout.IsDust(::minRelayTxFee)) { + } else if (whichType != TX_CRYPTOCONDITION && txout.IsDust(::minRelayTxFee)) { reason = "dust"; return false; } From 660c8dc26c92c39e1077f072f56ba936acafc0ce Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Apr 2019 21:08:39 +0800 Subject: [PATCH 3898/3904] fix has_opret function --- src/cc/customcc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp index 34144fedc..2e174f510 100644 --- a/src/cc/customcc.cpp +++ b/src/cc/customcc.cpp @@ -81,7 +81,7 @@ bool has_opret(const CTransaction &tx, uint8_t evalcode) { for ( auto vout : tx.vout ) { - if ( vout.scriptPubKey[1] == evalcode ) + if ( vout.scriptPubKey[0] == OP_RETURN && vout.scriptPubKey[1] == evalcode ) return true; } return false; From 87ebcc3b2b21998761a101851bb8fab16081980f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Apr 2019 21:11:06 +0800 Subject: [PATCH 3899/3904] revert createrawtransaction --- src/rpc/rawtransaction.cpp | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 41ed8ff66..6e90c4db5 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -721,7 +721,7 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp) UniValue createrawtransaction(const UniValue& params, bool fHelp) { - if (fHelp ) || //params.size() < 2 || params.size() > 4) + if (fHelp || params.size() < 2 || params.size() > 4) throw runtime_error( "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} ( locktime ) ( expiryheight )\n" "\nCreate a transaction spending the given inputs and sending to the given addresses.\n" @@ -754,32 +754,6 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"") ); - int nextBlockHeight = chainActive.Height() + 1; - CMutableTransaction rawTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); - CCcontract_info *cp, C; - - cp = CCinit(&C,EVAL_ORACLES); - CPubKey ccAddress = CPubKey(ParseHex(cp->CChexstr)); - CPubKey mypk = Mypubkey(); - - CTxOut vout = MakeCC1of2vout(EVAL_ORACLES, 1000000, mypk, ccAddress); - - std::vector vPubKeys = std::vector(); - vPubKeys.push_back(mypk); - vPubKeys.push_back(ccAddress); - - std::vector> vData = std::vector>(); - std::string test = "thisisatest"; - vData.push_back(std::vector(test.begin(), test.end())); - test = "anothertest"; - vData.push_back(std::vector(test.begin(), test.end())); - COptCCParams ccp = COptCCParams(COptCCParams::VERSION, EVAL_ORACLES, 1, 2, vPubKeys, vData); - - vout.scriptPubKey << ccp.AsVector() << OP_DROP; - rawTx.vout.push_back(vout); - - return EncodeHexTx(rawTx); - LOCK(cs_main); RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM)(UniValue::VNUM), true); if (params[0].isNull() || params[1].isNull()) From 18854e2af787893dfd5b82284c960220a03bf3e7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Apr 2019 13:42:02 +0800 Subject: [PATCH 3900/3904] ac_nk params --- src/chainparams.cpp | 7 ++ src/chainparams.h | 2 + src/crypto/equihash.cpp | 262 ++++++++++++++++++++++++++-------------- src/crypto/equihash.h | 100 ++++++++++----- src/komodo_defs.h | 3 +- src/komodo_nk.h | 7 ++ src/komodo_utils.h | 38 +++++- src/miner.cpp | 21 ++-- src/pow.cpp | 3 + 9 files changed, 308 insertions(+), 135 deletions(-) create mode 100644 src/komodo_nk.h diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 26e29d9de..b09ccf7c3 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -92,6 +92,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st void *chainparams_commandline(void *ptr); #include "komodo_defs.h" int32_t ASSETCHAINS_BLOCKTIME = 60; +uint64_t ASSETCHAINS_NK[2]; const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); @@ -282,6 +283,12 @@ void *chainparams_commandline(void *ptr) mainParams.consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; } mainParams.SetDefaultPort(ASSETCHAINS_P2PPORT); + if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 ) + { + //BOOST_STATIC_ASSERT(equihash_parameters_acceptable(ASSETCHAINS_NK[0], ASSETCHAINS_NK[1])); + mainParams.SetNValue(ASSETCHAINS_NK[0]); + mainParams.SetKValue(ASSETCHAINS_NK[1]); + } if ( ASSETCHAINS_RPCPORT == 0 ) ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1; mainParams.pchMessageStart[0] = ASSETCHAINS_MAGIC & 0xff; diff --git a/src/chainparams.h b/src/chainparams.h index ea700c6ca..3b1ad1f72 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -119,6 +119,8 @@ public: void SetDefaultPort(uint16_t port) { nDefaultPort = port; } void SetCheckpointData(CCheckpointData checkpointData); + void SetNValue(uint64_t n) { nEquihashN = n; } + void SetKValue(uint64_t k) { nEquihashK = k; } //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); } //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; } diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp index fdb907d35..9a16fc085 100644 --- a/src/crypto/equihash.cpp +++ b/src/crypto/equihash.cpp @@ -54,33 +54,84 @@ #define __BYTE_ORDER BYTE_ORDER #endif */ + static EhSolverCancelledException solver_cancelled; +int8_t ZeroizeUnusedBits(size_t N, unsigned char* hash, size_t hLen) +{ + uint8_t rem = N % 8; + if (rem) + { + // clear lowest 8-rem bits + const size_t step = GetSizeInBytes(N); + for (size_t i = step - 1; i < hLen; i += step) + { + uint8_t b = 0xff << (8-rem); + hash[i] &= b; + } + } + return(0); +} + + template int Equihash::InitialiseState(eh_HashState& base_state) { uint32_t le_N = htole32(N); uint32_t le_K = htole32(K); + unsigned char personalization[crypto_generichash_blake2b_PERSONALBYTES] = {}; - memcpy(personalization, "ZcashPoW", 8); + if ( ASSETCHAINS_NK[0] == 0 && ASSETCHAINS_NK[1] == 0 ) + memcpy(personalization, "ZcashPoW", 8); + else + memcpy(personalization, "NandKPoW", 8); memcpy(personalization+8, &le_N, 4); memcpy(personalization+12, &le_K, 4); + + const uint8_t outlen = (512 / N) * GetSizeInBytes(N); + + BOOST_STATIC_ASSERT(!((!outlen) || (outlen > BLAKE2B_OUTBYTES))); return crypto_generichash_blake2b_init_salt_personal(&base_state, NULL, 0, // No key. - (512/N)*N/8, + outlen, NULL, // No salt. personalization); } void GenerateHash(const eh_HashState& base_state, eh_index g, - unsigned char* hash, size_t hLen) + unsigned char* hash, size_t hLen, size_t N) { - eh_HashState state; - state = base_state; - eh_index lei = htole32(g); - crypto_generichash_blake2b_update(&state, (const unsigned char*) &lei, - sizeof(eh_index)); - crypto_generichash_blake2b_final(&state, hash, hLen); + if ( ASSETCHAINS_NK[0] == 0 && ASSETCHAINS_NK[1] == 0 ) + { + eh_HashState state; + state = base_state; + eh_index lei = htole32(g); + crypto_generichash_blake2b_update(&state, (const unsigned char*) &lei, + sizeof(eh_index)); + crypto_generichash_blake2b_final(&state, hash, hLen); + } + else + { + uint32_t myHash[16] = {0}; + uint32_t startIndex = g & 0xFFFFFFF0; + + for (uint32_t g2 = startIndex; g2 <= g; g2++) { + uint32_t tmpHash[16] = {0}; + + eh_HashState state; + state = base_state; + eh_index lei = htole32(g2); + crypto_generichash_blake2b_update(&state, (const unsigned char*) &lei, + sizeof(eh_index)); + + crypto_generichash_blake2b_final(&state, (unsigned char*)&tmpHash[0], static_cast(hLen)); + + for (uint32_t idx = 0; idx < 16; idx++) myHash[idx] += tmpHash[idx]; + } + + memcpy(hash, &myHash[0], hLen); + ZeroizeUnusedBits(N, hash, hLen); + } } void ExpandArray(const unsigned char* in, size_t in_len, @@ -88,7 +139,7 @@ void ExpandArray(const unsigned char* in, size_t in_len, size_t bit_len, size_t byte_pad) { assert(bit_len >= 8); - assert(8*sizeof(uint32_t) >= 7+bit_len); + assert(8*sizeof(uint32_t) >= bit_len); size_t out_width { (bit_len+7)/8 + byte_pad }; assert(out_len == 8*out_width*in_len/bit_len); @@ -131,10 +182,10 @@ void CompressArray(const unsigned char* in, size_t in_len, size_t bit_len, size_t byte_pad) { assert(bit_len >= 8); - assert(8*sizeof(uint32_t) >= 7+bit_len); + assert(8*sizeof(uint32_t) >= bit_len); size_t in_width { (bit_len+7)/8 + byte_pad }; - assert(out_len == bit_len*in_len/(8*in_width)); + assert(out_len == (bit_len*in_len/in_width + 7)/8); uint32_t bit_len_mask { ((uint32_t)1 << bit_len) - 1 }; @@ -148,17 +199,23 @@ void CompressArray(const unsigned char* in, size_t in_len, // When we have fewer than 8 bits left in the accumulator, read the next // input element. if (acc_bits < 8) { + if (j < in_len) { acc_value = acc_value << bit_len; for (size_t x = byte_pad; x < in_width; x++) { acc_value = acc_value | ( ( // Apply bit_len_mask across byte boundaries - in[j+x] & ((bit_len_mask >> (8*(in_width-x-1))) & 0xFF) - ) << (8*(in_width-x-1))); // Big-endian + in[j + x] & ((bit_len_mask >> (8 * (in_width - x - 1))) & 0xFF) + ) << (8 * (in_width - x - 1))); // Big-endian } j += in_width; acc_bits += bit_len; } + else { + acc_value <<= 8 - acc_bits; + acc_bits += 8 - acc_bits;; + } + } acc_bits -= 8; out[i] = (acc_value >> acc_bits) & 0xFF; @@ -207,7 +264,7 @@ std::vector GetIndicesFromMinimal(std::vector minimal, ExpandArray(minimal.data(), minimal.size(), array.data(), lenIndices, cBitLen+1, bytePad); std::vector ret; - for (int i = 0; i < lenIndices; i += sizeof(eh_index)) { + for (size_t i = 0; i < lenIndices; i += sizeof(eh_index)) { ret.push_back(ArrayToEhIndex(array.data()+i)); } return ret; @@ -221,7 +278,7 @@ std::vector GetMinimalFromIndices(std::vector indices, size_t minLen { (cBitLen+1)*lenIndices/(8*sizeof(eh_index)) }; size_t bytePad { sizeof(eh_index) - ((cBitLen+1)+7)/8 }; std::vector array(lenIndices); - for (int i = 0; i < indices.size(); i++) { + for (size_t i = 0; i < indices.size(); i++) { EhIndexToArray(indices[i], array.data()+(i*sizeof(eh_index))); } std::vector ret(minLen); @@ -254,12 +311,12 @@ FullStepRow::FullStepRow(const unsigned char* hashIn, size_t hInLen, } template template -FullStepRow::FullStepRow(const FullStepRow& a, const FullStepRow& b, size_t len, size_t lenIndices, int trim) : +FullStepRow::FullStepRow(const FullStepRow& a, const FullStepRow& b, size_t len, size_t lenIndices, size_t trim) : StepRow {a} { assert(len+lenIndices <= W); assert(len-trim+(2*lenIndices) <= WIDTH); - for (int i = trim; i < len; i++) + for (size_t i = trim; i < len; i++) hash[i-trim] = a.hash[i] ^ b.hash[i]; if (a.IndicesBefore(b, len, lenIndices)) { std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-trim); @@ -281,7 +338,7 @@ template bool StepRow::IsZero(size_t len) { // This doesn't need to be constant time. - for (int i = 0; i < len; i++) { + for (size_t i = 0; i < len; i++) { if (hash[i] != 0) return false; } @@ -301,10 +358,10 @@ std::vector FullStepRow::GetIndices(size_t len, size_t len } template -bool HasCollision(StepRow& a, StepRow& b, int l) +bool HasCollision(StepRow& a, StepRow& b, size_t l) { // This doesn't need to be constant time. - for (int j = 0; j < l; j++) { + for (size_t j = 0; j < l; j++) { if (a.hash[j] != b.hash[j]) return false; } @@ -326,7 +383,7 @@ TruncatedStepRow::TruncatedStepRow(const TruncatedStepRow& a, const Tr { assert(len+lenIndices <= W); assert(len-trim+(2*lenIndices) <= WIDTH); - for (int i = trim; i < len; i++) + for (size_t i = static_cast(trim); i < len; i++) hash[i-trim] = a.hash[i] ^ b.hash[i]; if (a.IndicesBefore(b, len, lenIndices)) { std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-trim); @@ -355,10 +412,10 @@ std::shared_ptr TruncatedStepRow::GetTruncatedIndices(size_t le #ifdef ENABLE_MINING template bool Equihash::BasicSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled) { - eh_index init_size { 1 << (CollisionBitLength + 1) }; + eh_index init_size { 1U << (CollisionBitLength + 1) }; // 1) Generate first list LogPrint("pow", "Generating first list\n"); @@ -368,16 +425,16 @@ bool Equihash::BasicSolve(const eh_HashState& base_state, X.reserve(init_size); unsigned char tmpHash[HashOutput]; for (eh_index g = 0; X.size() < init_size; g++) { - GenerateHash(base_state, g, tmpHash, HashOutput); + GenerateHash(base_state, g, tmpHash, HashOutput, N); for (eh_index i = 0; i < IndicesPerHashOutput && X.size() < init_size; i++) { - X.emplace_back(tmpHash+(i*N/8), N/8, HashLength, - CollisionBitLength, (g*IndicesPerHashOutput)+i); + X.emplace_back(tmpHash+(i*GetSizeInBytes(N)), GetSizeInBytes(N), HashLength, + CollisionBitLength, static_cast(g*IndicesPerHashOutput)+i); } if (cancelled(ListGeneration)) throw solver_cancelled; } // 3) Repeat step 2 until 2n/(k+1) bits remain - for (int r = 1; r < K && X.size() > 0; r++) { + for (unsigned int r = 1; r < K && X.size() > 0; r++) { LogPrint("pow", "Round %d:\n", r); // 2a) Sort the list LogPrint("pow", "- Sorting list\n"); @@ -385,20 +442,20 @@ bool Equihash::BasicSolve(const eh_HashState& base_state, if (cancelled(ListSorting)) throw solver_cancelled; LogPrint("pow", "- Finding collisions\n"); - int i = 0; - int posFree = 0; + size_t i = 0; + size_t posFree = 0; std::vector> Xc; while (i < X.size() - 1) { // 2b) Find next set of unordered pairs with collisions on the next n/(k+1) bits - int j = 1; + size_t j = 1; while (i+j < X.size() && HasCollision(X[i], X[i+j], CollisionByteLength)) { j++; } // 2c) Calculate tuples (X_i ^ X_j, (i, j)) - for (int l = 0; l < j - 1; l++) { - for (int m = l + 1; m < j; m++) { + for (size_t l = 0; l < j - 1; l++) { + for (size_t m = l + 1; m < j; m++) { if (DistinctIndices(X[i+l], X[i+m], hashLen, lenIndices)) { Xc.emplace_back(X[i+l], X[i+m], hashLen, lenIndices, CollisionByteLength); } @@ -442,16 +499,16 @@ bool Equihash::BasicSolve(const eh_HashState& base_state, std::sort(X.begin(), X.end(), CompareSR(hashLen)); if (cancelled(FinalSorting)) throw solver_cancelled; LogPrint("pow", "- Finding collisions\n"); - int i = 0; + size_t i = 0; while (i < X.size() - 1) { - int j = 1; + size_t j = 1; while (i+j < X.size() && HasCollision(X[i], X[i+j], hashLen)) { j++; } - for (int l = 0; l < j - 1; l++) { - for (int m = l + 1; m < j; m++) { + for (size_t l = 0; l < j - 1; l++) { + for (size_t m = l + 1; m < j; m++) { FullStepRow res(X[i+l], X[i+m], hashLen, lenIndices, 0); if (DistinctIndices(X[i+l], X[i+m], hashLen, lenIndices)) { auto soln = res.GetIndices(hashLen, 2*lenIndices, CollisionBitLength); @@ -475,20 +532,21 @@ bool Equihash::BasicSolve(const eh_HashState& base_state, template void CollideBranches(std::vector>& X, const size_t hlen, const size_t lenIndices, const unsigned int clen, const unsigned int ilen, const eh_trunc lt, const eh_trunc rt) { - int i = 0; - int posFree = 0; + size_t i = 0; + size_t posFree = 0; + assert(X.size() > 0); std::vector> Xc; while (i < X.size() - 1) { // 2b) Find next set of unordered pairs with collisions on the next n/(k+1) bits - int j = 1; + size_t j = 1; while (i+j < X.size() && HasCollision(X[i], X[i+j], clen)) { j++; } // 2c) Calculate tuples (X_i ^ X_j, (i, j)) - for (int l = 0; l < j - 1; l++) { - for (int m = l + 1; m < j; m++) { + for (size_t l = 0; l < j - 1; l++) { + for (size_t m = l + 1; m < j; m++) { if (DistinctIndices(X[i+l], X[i+m], hlen, lenIndices)) { if (IsValidBranch(X[i+l], hlen, ilen, lt) && IsValidBranch(X[i+m], hlen, ilen, rt)) { Xc.emplace_back(X[i+l], X[i+m], hlen, lenIndices, clen); @@ -526,10 +584,10 @@ void CollideBranches(std::vector>& X, const size_t hlen, cons template bool Equihash::OptimisedSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled) { - eh_index init_size { 1 << (CollisionBitLength + 1) }; + eh_index init_size { 1U << (CollisionBitLength + 1) }; eh_index recreate_size { UntruncateIndex(1, 0, CollisionBitLength + 1) }; // First run the algorithm with truncated indices @@ -547,16 +605,16 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, Xt.reserve(init_size); unsigned char tmpHash[HashOutput]; for (eh_index g = 0; Xt.size() < init_size; g++) { - GenerateHash(base_state, g, tmpHash, HashOutput); + GenerateHash(base_state, g, tmpHash, HashOutput, N); for (eh_index i = 0; i < IndicesPerHashOutput && Xt.size() < init_size; i++) { - Xt.emplace_back(tmpHash+(i*N/8), N/8, HashLength, CollisionBitLength, - (g*IndicesPerHashOutput)+i, CollisionBitLength + 1); + Xt.emplace_back(tmpHash+(i*GetSizeInBytes(N)), GetSizeInBytes(N), HashLength, CollisionBitLength, + static_cast(g*IndicesPerHashOutput)+i, static_cast(CollisionBitLength + 1)); } if (cancelled(ListGeneration)) throw solver_cancelled; } // 3) Repeat step 2 until 2n/(k+1) bits remain - for (int r = 1; r < K && Xt.size() > 0; r++) { + for (unsigned int r = 1; r < K && Xt.size() > 0; r++) { LogPrint("pow", "Round %d:\n", r); // 2a) Sort the list LogPrint("pow", "- Sorting list\n"); @@ -564,21 +622,21 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, if (cancelled(ListSorting)) throw solver_cancelled; LogPrint("pow", "- Finding collisions\n"); - int i = 0; - int posFree = 0; + size_t i = 0; + size_t posFree = 0; std::vector> Xc; while (i < Xt.size() - 1) { // 2b) Find next set of unordered pairs with collisions on the next n/(k+1) bits - int j = 1; + size_t j = 1; while (i+j < Xt.size() && HasCollision(Xt[i], Xt[i+j], CollisionByteLength)) { j++; } // 2c) Calculate tuples (X_i ^ X_j, (i, j)) - bool checking_for_zero = (i == 0 && Xt[0].IsZero(hashLen)); - for (int l = 0; l < j - 1; l++) { - for (int m = l + 1; m < j; m++) { + //bool checking_for_zero = (i == 0 && Xt[0].IsZero(hashLen)); + for (size_t l = 0; l < j - 1; l++) { + for (size_t m = l + 1; m < j; m++) { // We truncated, so don't check for distinct indices here TruncatedStepRow Xi {Xt[i+l], Xt[i+m], hashLen, lenIndices, @@ -628,16 +686,16 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, std::sort(Xt.begin(), Xt.end(), CompareSR(hashLen)); if (cancelled(FinalSorting)) throw solver_cancelled; LogPrint("pow", "- Finding collisions\n"); - int i = 0; + size_t i = 0; while (i < Xt.size() - 1) { - int j = 1; + size_t j = 1; while (i+j < Xt.size() && HasCollision(Xt[i], Xt[i+j], hashLen)) { j++; } - for (int l = 0; l < j - 1; l++) { - for (int m = l + 1; m < j; m++) { + for (size_t l = 0; l < j - 1; l++) { + for (size_t m = l + 1; m < j; m++) { TruncatedStepRow res(Xt[i+l], Xt[i+m], hashLen, lenIndices, 0); auto soln = res.GetTruncatedIndices(hashLen, 2*lenIndices); @@ -676,10 +734,10 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, eh_index newIndex { UntruncateIndex(partialSoln.get()[i], j, CollisionBitLength + 1) }; if (j == 0 || newIndex % IndicesPerHashOutput == 0) { GenerateHash(base_state, newIndex/IndicesPerHashOutput, - tmpHash, HashOutput); + tmpHash, HashOutput, N); } - icv.emplace_back(tmpHash+((newIndex % IndicesPerHashOutput) * N/8), - N/8, HashLength, CollisionBitLength, newIndex); + icv.emplace_back(tmpHash+((newIndex % IndicesPerHashOutput) * GetSizeInBytes(N)), + GetSizeInBytes(N), HashLength, CollisionBitLength, newIndex); if (cancelled(PartialGeneration)) throw solver_cancelled; } boost::optional>> ic = icv; @@ -697,7 +755,7 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, ic->insert(ic->end(), X[r]->begin(), X[r]->end()); std::sort(ic->begin(), ic->end(), CompareSR(hashLen)); if (cancelled(PartialSorting)) throw solver_cancelled; - size_t lti = rti-(1<(1)<::IsValidSolution(const eh_HashState& base_state, std::vector< X.reserve(1 << K); unsigned char tmpHash[HashOutput]; for (eh_index i : GetIndicesFromMinimal(soln, CollisionBitLength)) { - GenerateHash(base_state, i/IndicesPerHashOutput, tmpHash, HashOutput); - X.emplace_back(tmpHash+((i % IndicesPerHashOutput) * N/8), - N/8, HashLength, CollisionBitLength, i); + GenerateHash(base_state, i/IndicesPerHashOutput, tmpHash, HashOutput, N); + X.emplace_back(tmpHash+((i % IndicesPerHashOutput) * GetSizeInBytes(N)), + GetSizeInBytes(N), HashLength, CollisionBitLength, i); } size_t hashLen = HashLength; size_t lenIndices = sizeof(eh_index); while (X.size() > 1) { std::vector> Xc; - for (int i = 0; i < X.size(); i += 2) { + for (size_t i = 0; i < X.size(); i += 2) { if (!HasCollision(X[i], X[i+1], CollisionByteLength)) { LogPrint("pow", "Invalid solution: invalid collision length between StepRows\n"); LogPrint("pow", "X[i] = %s\n", X[i].GetHex(hashLen)); @@ -795,50 +853,74 @@ bool Equihash::IsValidSolution(const eh_HashState& base_state, std::vector< return X[0].IsZero(hashLen); } -// Explicit instantiations for Equihash<96,3> -template int Equihash<96,3>::InitialiseState(eh_HashState& base_state); -#ifdef ENABLE_MINING -template bool Equihash<96,3>::BasicSolve(const eh_HashState& base_state, - const std::function)> validBlock, - const std::function cancelled); -template bool Equihash<96,3>::OptimisedSolve(const eh_HashState& base_state, - const std::function)> validBlock, - const std::function cancelled); -#endif -template bool Equihash<96,3>::IsValidSolution(const eh_HashState& base_state, std::vector soln); - // Explicit instantiations for Equihash<200,9> template int Equihash<200,9>::InitialiseState(eh_HashState& base_state); #ifdef ENABLE_MINING template bool Equihash<200,9>::BasicSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled); template bool Equihash<200,9>::OptimisedSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled); #endif template bool Equihash<200,9>::IsValidSolution(const eh_HashState& base_state, std::vector soln); - -// Explicit instantiations for Equihash<96,5> -template int Equihash<96,5>::InitialiseState(eh_HashState& base_state); + +// Explicit instantiations for Equihash<96,3> +template int Equihash<150,5>::InitialiseState(eh_HashState& base_state); #ifdef ENABLE_MINING -template bool Equihash<96,5>::BasicSolve(const eh_HashState& base_state, - const std::function)> validBlock, +template bool Equihash<150,5>::BasicSolve(const eh_HashState& base_state, + const std::function&)> validBlock, const std::function cancelled); -template bool Equihash<96,5>::OptimisedSolve(const eh_HashState& base_state, - const std::function)> validBlock, +template bool Equihash<150,5>::OptimisedSolve(const eh_HashState& base_state, + const std::function&)> validBlock, const std::function cancelled); #endif -template bool Equihash<96,5>::IsValidSolution(const eh_HashState& base_state, std::vector soln); +template bool Equihash<150,5>::IsValidSolution(const eh_HashState& base_state, std::vector soln); // Explicit instantiations for Equihash<48,5> +template int Equihash<144,5>::InitialiseState(eh_HashState& base_state); +#ifdef ENABLE_MINING +template bool Equihash<144,5>::BasicSolve(const eh_HashState& base_state, + const std::function&)> validBlock, + const std::function cancelled); +template bool Equihash<144,5>::OptimisedSolve(const eh_HashState& base_state, + const std::function&)> validBlock, + const std::function cancelled); +#endif +template bool Equihash<144,5>::IsValidSolution(const eh_HashState& base_state, std::vector soln); + +// Explicit instantiations for Equihash<96,5> +template int Equihash::InitialiseState(eh_HashState& base_state); +#ifdef ENABLE_MINING +template bool Equihash::BasicSolve(const eh_HashState& base_state, + const std::function&)> validBlock, + const std::function cancelled); +template bool Equihash::OptimisedSolve(const eh_HashState& base_state, + const std::function&)> validBlock, + const std::function cancelled); +#endif +template bool Equihash::IsValidSolution(const eh_HashState& base_state, std::vector soln); + +// Explicit instantiations for Equihash<96,5> template int Equihash<48,5>::InitialiseState(eh_HashState& base_state); #ifdef ENABLE_MINING template bool Equihash<48,5>::BasicSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled); template bool Equihash<48,5>::OptimisedSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled); #endif template bool Equihash<48,5>::IsValidSolution(const eh_HashState& base_state, std::vector soln); + +// Explicit instantiations for Equihash<48,5> +template int Equihash<210,9>::InitialiseState(eh_HashState& base_state); +#ifdef ENABLE_MINING +template bool Equihash<210,9>::BasicSolve(const eh_HashState& base_state, + const std::function&)> validBlock, + const std::function cancelled); +template bool Equihash<210,9>::OptimisedSolve(const eh_HashState& base_state, + const std::function&)> validBlock, + const std::function cancelled); +#endif +template bool Equihash<210,9>::IsValidSolution(const eh_HashState& base_state, std::vector soln); diff --git a/src/crypto/equihash.h b/src/crypto/equihash.h index 6691844ba..57c434dae 100644 --- a/src/crypto/equihash.h +++ b/src/crypto/equihash.h @@ -10,6 +10,7 @@ #include "utilstrencodings.h" #include "sodium.h" +#include "komodo_nk.h" #include #include @@ -24,6 +25,9 @@ typedef crypto_generichash_blake2b_state eh_HashState; typedef uint32_t eh_index; typedef uint8_t eh_trunc; +#define BLAKE2B_OUTBYTES 64 +extern uint64_t ASSETCHAINS_NK[2]; + void ExpandArray(const unsigned char* in, size_t in_len, unsigned char* out, size_t out_len, size_t bit_len, size_t byte_pad=0); @@ -61,7 +65,7 @@ public: std::string GetHex(size_t len) { return HexStr(hash, hash+len); } template - friend bool HasCollision(StepRow& a, StepRow& b, int l); + friend bool HasCollision(StepRow& a, StepRow& b, size_t l); }; class CompareSR @@ -77,7 +81,7 @@ public: }; template -bool HasCollision(StepRow& a, StepRow& b, int l); +bool HasCollision(StepRow& a, StepRow& b, size_t l); template class FullStepRow : public StepRow @@ -94,7 +98,7 @@ public: FullStepRow(const FullStepRow& a) : StepRow {a} { } template - FullStepRow(const FullStepRow& a, const FullStepRow& b, size_t len, size_t lenIndices, int trim); + FullStepRow(const FullStepRow& a, const FullStepRow& b, size_t len, size_t lenIndices, size_t trim); FullStepRow& operator=(const FullStepRow& a); inline bool IndicesBefore(const FullStepRow& a, size_t len, size_t lenIndices) const { return memcmp(hash+len, a.hash+len, lenIndices) < 0; } @@ -159,17 +163,22 @@ inline constexpr size_t equihash_solution_size(unsigned int N, unsigned int K) { return (1 << K)*(N/(K+1)+1)/8; } +constexpr uint8_t GetSizeInBytes(size_t N) +{ + return static_cast((N + 7) / 8); +} + template class Equihash { private: BOOST_STATIC_ASSERT(K < N); - BOOST_STATIC_ASSERT(N % 8 == 0); + //BOOST_STATIC_ASSERT(N % 8 == 0); BOOST_STATIC_ASSERT((N/(K+1)) + 1 < 8*sizeof(eh_index)); public: enum : size_t { IndicesPerHashOutput=512/N }; - enum : size_t { HashOutput=IndicesPerHashOutput*N/8 }; + enum : size_t { HashOutput = IndicesPerHashOutput * GetSizeInBytes(N) }; enum : size_t { CollisionBitLength=N/(K+1) }; enum : size_t { CollisionByteLength=(CollisionBitLength+7)/8 }; enum : size_t { HashLength=(K+1)*CollisionByteLength }; @@ -184,79 +193,100 @@ public: int InitialiseState(eh_HashState& base_state); #ifdef ENABLE_MINING bool BasicSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled); bool OptimisedSolve(const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled); #endif bool IsValidSolution(const eh_HashState& base_state, std::vector soln); }; #include "equihash.tcc" +/* +* Equihash 200,9 (KMD/Zcash) +* Equihash 150,5 (beam) +* Equihash 144,5 (SnowGem) +* Equihash 96,5 (Minex) +* Equihash 48,5 (regtest) +* Equihash 210,9 (Aion) */ -static Equihash<96,3> Eh96_3; static Equihash<200,9> Eh200_9; -static Equihash<96,5> Eh96_5; +static Equihash<150,5> Eh150_5; +static Equihash<144,5> Eh144_5; +static Equihash Eh96_5; static Equihash<48,5> Eh48_5; +static Equihash<210,9> Eh210_9; #define EhInitialiseState(n, k, base_state) \ - if (n == 96 && k == 3) { \ - Eh96_3.InitialiseState(base_state); \ - } else if (n == 200 && k == 9) { \ - Eh200_9.InitialiseState(base_state); \ - } else if (n == 96 && k == 5) { \ + if (n == 200 && k == 9) { \ + Eh200_9.InitialiseState(base_state); \ + } else if (n == 150 && k == 5) { \ + Eh150_5.InitialiseState(base_state); \ + } else if (n == 144 && k == 5) { \ + Eh144_5.InitialiseState(base_state); \ + } else if (n == ASSETCHAINS_N && k == ASSETCHAINS_K) { \ Eh96_5.InitialiseState(base_state); \ } else if (n == 48 && k == 5) { \ Eh48_5.InitialiseState(base_state); \ + } else if (n == 210 && k == 9) { \ + Eh210_9.InitialiseState(base_state); \ } else { \ throw std::invalid_argument("Unsupported Equihash parameters"); \ } #ifdef ENABLE_MINING inline bool EhBasicSolve(unsigned int n, unsigned int k, const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled) { - if (n == 96 && k == 3) { - return Eh96_3.BasicSolve(base_state, validBlock, cancelled); - } else if (n == 200 && k == 9) { + if (n == 200 && k == 9) { return Eh200_9.BasicSolve(base_state, validBlock, cancelled); - } else if (n == 96 && k == 5) { + } else if (n == 150 && k == 5) { + return Eh150_5.BasicSolve(base_state, validBlock, cancelled); + } else if (n == 144 && k == 5) { + return Eh144_5.BasicSolve(base_state, validBlock, cancelled); + } else if (n == ASSETCHAINS_N && k == ASSETCHAINS_K) { return Eh96_5.BasicSolve(base_state, validBlock, cancelled); - } else if (n == 48 && k == 5) { + } else if (n == 48 && k == 5) { return Eh48_5.BasicSolve(base_state, validBlock, cancelled); + } else if (n == 210 && k == 9) { + return Eh210_9.BasicSolve(base_state, validBlock, cancelled); } else { throw std::invalid_argument("Unsupported Equihash parameters"); } } inline bool EhBasicSolveUncancellable(unsigned int n, unsigned int k, const eh_HashState& base_state, - const std::function)> validBlock) + const std::function&)> validBlock) { return EhBasicSolve(n, k, base_state, validBlock, [](EhSolverCancelCheck pos) { return false; }); } inline bool EhOptimisedSolve(unsigned int n, unsigned int k, const eh_HashState& base_state, - const std::function)> validBlock, + const std::function&)> validBlock, const std::function cancelled) { - if (n == 96 && k == 3) { - return Eh96_3.OptimisedSolve(base_state, validBlock, cancelled); - } else if (n == 200 && k == 9) { + if (n == 200 && k == 9) { return Eh200_9.OptimisedSolve(base_state, validBlock, cancelled); - } else if (n == 96 && k == 5) { + } else if (n == 150 && k == 5) { + return Eh150_5.OptimisedSolve(base_state, validBlock, cancelled); + } else if (n == 144 && k == 5) { + return Eh144_5.OptimisedSolve(base_state, validBlock, cancelled); + } else if (n == ASSETCHAINS_N && k == ASSETCHAINS_K) { return Eh96_5.OptimisedSolve(base_state, validBlock, cancelled); - } else if (n == 48 && k == 5) { + } else if (n == 48 && k == 5) { return Eh48_5.OptimisedSolve(base_state, validBlock, cancelled); + } else if (n == 210 && k == 9) { + return Eh210_9.OptimisedSolve(base_state, validBlock, cancelled); } else { throw std::invalid_argument("Unsupported Equihash parameters"); } } inline bool EhOptimisedSolveUncancellable(unsigned int n, unsigned int k, const eh_HashState& base_state, - const std::function)> validBlock) + const std::function&)> validBlock) { return EhOptimisedSolve(n, k, base_state, validBlock, [](EhSolverCancelCheck pos) { return false; }); @@ -264,14 +294,18 @@ inline bool EhOptimisedSolveUncancellable(unsigned int n, unsigned int k, const #endif // ENABLE_MINING #define EhIsValidSolution(n, k, base_state, soln, ret) \ - if (n == 96 && k == 3) { \ - ret = Eh96_3.IsValidSolution(base_state, soln); \ - } else if (n == 200 && k == 9) { \ - ret = Eh200_9.IsValidSolution(base_state, soln); \ - } else if (n == 96 && k == 5) { \ + if (n == 200 && k == 9) { \ + ret = Eh200_9.IsValidSolution(base_state, soln); \ + } else if (n == 150 && k == 5) { \ + ret = Eh150_5.IsValidSolution(base_state, soln); \ + } else if (n == 144 && k == 5) { \ + ret = Eh144_5.IsValidSolution(base_state, soln); \ + } else if (n == ASSETCHAINS_N && k == ASSETCHAINS_K) { \ ret = Eh96_5.IsValidSolution(base_state, soln); \ } else if (n == 48 && k == 5) { \ ret = Eh48_5.IsValidSolution(base_state, soln); \ + } else if (n == 210 && k == 9) { \ + ret = Eh210_9.IsValidSolution(base_state, soln); \ } else { \ throw std::invalid_argument("Unsupported Equihash parameters"); \ } diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 23a689154..964ec852d 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -15,6 +15,7 @@ #ifndef KOMODO_DEFS_H #define KOMODO_DEFS_H +#include "komodo_nk.h" #define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MAX_ERAS 3 @@ -53,7 +54,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_nk.h b/src/komodo_nk.h new file mode 100644 index 000000000..3c9034dde --- /dev/null +++ b/src/komodo_nk.h @@ -0,0 +1,7 @@ +#ifndef KOMODO_NK_H +#define KOMODO_NK_H + +#define ASSETCHAINS_N 96 +#define ASSETCHAINS_K 5 + +#endif diff --git a/src/komodo_utils.h b/src/komodo_utils.h index bbd68ae30..d87b50716 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1667,6 +1667,28 @@ extern int64_t MAX_MONEY; void komodo_cbopretupdate(int32_t forceflag); void SplitStr(const std::string& strVal, std::vector &outVals); +int8_t equihash_params_possible(uint64_t n, uint64_t k) +{ + /* To add more of these you also need to edit: + * equihash.cpp very end of file with the tempate to point to the new param numbers + * equihash.h + * line 210/217 (declaration of equihash class) + * Add this object to the following functions: + * EhInitialiseState + * EhBasicSolve + * EhOptimisedSolve + * EhIsValidSolution + * Alternatively change ASSETCHAINS_N and ASSETCHAINS_K in komodo_nk.h for fast testing. + */ + if ( k == 9 && (n == 200 || n == 210) ) + return(0); + if ( k == 5 && (n == 150 || n == 144 || n == 96 || n == 48) ) + return(0); + if ( k == ASSETCHAINS_K && n == ASSETCHAINS_N) + return(0); + return(-1); +} + void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; @@ -1729,6 +1751,7 @@ void komodo_args(char *argv0) ASSETCHAINS_BLOCKTIME = GetArg("-ac_blocktime",60); ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); ASSETCHAINS_PRIVATE = GetArg("-ac_private",0); + Split(GetArg("-ac_nk",""), ASSETCHAINS_NK, 0); if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); @@ -1749,6 +1772,14 @@ void komodo_args(char *argv0) break; } } + if ( ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH && ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 ) + { + if ( equihash_params_possible(ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]) == -1 ) + { + printf("equihash values N.%li and K.%li are not currently available\n", ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]); + exit(0); + } else printf("ASSETCHAINS_ALGO, algorithm set to equihash with N.%li and K.%li\n", ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]); + } if (i == ASSETCHAINS_NUMALGOS) { printf("ASSETCHAINS_ALGO, %s not supported. using equihash\n", selectedAlgo.c_str()); @@ -1974,7 +2005,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); StartShutdown(); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 || (ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0) ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -2104,6 +2135,11 @@ void komodo_args(char *argv0) komodo_cbopretupdate(1); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } + if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 ) + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[0]),(void *)&ASSETCHAINS_NK[0]); + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[1]),(void *)&ASSETCHAINS_NK[1]); + } } addn = GetArg("-seednode",""); diff --git a/src/miner.cpp b/src/miner.cpp index f131bc90e..295fcb803 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1608,9 +1608,10 @@ void static BitcoinMiner() if ( notaryid != My_notaryid ) My_notaryid = notaryid; std::string solver; - //if ( notaryid >= 0 || ASSETCHAINS_SYMBOL[0] != 0 ) - solver = "tromp"; - //else solver = "default"; + if ( ASSETCHAINS_NK[0] == 0 && ASSETCHAINS_NK[1] == 0 ) + solver = "tromp"; + else + solver = "default"; assert(solver == "tromp" || solver == "default"); LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k); if ( ASSETCHAINS_SYMBOL[0] != 0 ) @@ -1951,11 +1952,11 @@ void static BitcoinMiner() ehSolverRuns.increment(); if (found) { int32_t i; uint256 hash = pblock->GetHash(); - for (i=0; i<32; i++) - fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); - fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); - FOUND_BLOCK = 1; - KOMODO_MAYBEMINED = Mining_height; + //for (i=0; i<32; i++) + // fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); + //fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); + //FOUND_BLOCK = 1; + //KOMODO_MAYBEMINED = Mining_height; break; } } catch (EhSolverCancelledException&) { @@ -1968,12 +1969,12 @@ void static BitcoinMiner() // Check for stop or if block needs to be rebuilt boost::this_thread::interruption_point(); // Regtest mode doesn't require peers - if ( FOUND_BLOCK != 0 ) + /*if ( FOUND_BLOCK != 0 ) { FOUND_BLOCK = 0; fprintf(stderr,"FOUND_BLOCK!\n"); //sleep(2000); - } + } */ if (vNodes.empty() && chainparams.MiningRequiresPeers()) { if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > ASSETCHAINS_MINHEIGHT ) diff --git a/src/pow.cpp b/src/pow.cpp index 1716099ee..6f5476abe 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -344,6 +344,9 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param { if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) return true; + + if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 && pblock->GetHash().ToString() == "027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71" ) + return true; unsigned int n = params.EquihashN(); unsigned int k = params.EquihashK(); From 78162cf103804c0f7483d7258cdeed601a7fcb58 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Apr 2019 15:00:47 +0800 Subject: [PATCH 3901/3904] Add height param to importprivkey --- src/rpc/client.cpp | 1 + src/wallet/rpcdump.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index cab89092c..26a613f9a 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -108,6 +108,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "lockunspent", 0 }, { "lockunspent", 1 }, { "importprivkey", 2 }, + { "importprivkey", 3 }, { "importaddress", 2 }, { "verifychain", 0 }, { "verifychain", 1 }, diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index d233b418a..c66ce3485 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -94,14 +94,15 @@ UniValue importprivkey(const UniValue& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - if (fHelp || params.size() < 1 || params.size() > 3) + if (fHelp || params.size() < 1 || params.size() > 4) throw runtime_error( - "importprivkey \"komodoprivkey\" ( \"label\" rescan )\n" + "importprivkey \"komodoprivkey\" ( \"label\" rescan height)\n" "\nAdds a private key (as returned by dumpprivkey) to your wallet.\n" "\nArguments:\n" "1. \"komodoprivkey\" (string, required) The private key (see dumpprivkey)\n" "2. \"label\" (string, optional, default=\"\") An optional label\n" "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" + "4. height (integer, optional, default=0) start at block height?\n" "\nNote: This call can take minutes to complete if rescan is true.\n" "\nExamples:\n" "\nDump a private key\n" @@ -111,7 +112,11 @@ UniValue importprivkey(const UniValue& params, bool fHelp) "\nImport using a label and without rescan\n" + HelpExampleCli("importprivkey", "\"mykey\" \"testing\" false") + "\nAs a JSON-RPC call\n" - + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false") + + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false") + + "\nImport with rescan from a block height\n" + + HelpExampleCli("importprivkey", "\"mykey\" \"testing\" true 1000") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", true, 1000") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -120,6 +125,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp) string strSecret = params[0].get_str(); string strLabel = ""; + int32_t height = 0; if (params.size() > 1) strLabel = params[1].get_str(); @@ -127,7 +133,12 @@ UniValue importprivkey(const UniValue& params, bool fHelp) bool fRescan = true; if (params.size() > 2) fRescan = params[2].get_bool(); + if ( fRescan && params.size() == 4 ) + height = params[3].get_int(); + if ( height < 0 || height > chainActive.Height() ) + throw JSONRPCError(RPC_WALLET_ERROR, "Rescan height is out of range."); + CKey key = DecodeSecret(strSecret); if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key encoding"); @@ -152,7 +163,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp) pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value' if (fRescan) { - pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true); + pwalletMain->ScanForWalletTransactions(chainActive[height], true); } } From cf02649727557d41026358f89ed040a0d1a4a62c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Apr 2019 15:27:31 +0800 Subject: [PATCH 3902/3904] Change MoMoMData RPC to use a 5 block KMD delay. Change MoMoM hash to use a range of 7 MoM hash. Add offset to migrate_completeimporttransaction. --- src/crosschain.cpp | 24 ++++++++++++++++-------- src/crosschain.h | 4 ++-- src/rpc/client.cpp | 1 + src/rpc/crosschain.cpp | 17 +++++++++++------ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index d65c5dd8c..82a46eaab 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -64,11 +64,12 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (kmdHeight < 0 || kmdHeight > chainActive.Height()) return uint256(); - int seenOwnNotarisations = 0; + int seenOwnNotarisations = 0, i = 0; int authority = GetSymbolAuthority(symbol); + std::set tmp_moms; - for (int i=0; i kmdHeight) break; NotarisationsInBlock notarisations; uint256 blockHash = *chainActive[kmdHeight-i]->phashBlock; @@ -82,17 +83,17 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh seenOwnNotarisations++; if (seenOwnNotarisations == 1) destNotarisationTxid = nota.first; - else if (seenOwnNotarisations == 2) + else if (seenOwnNotarisations == 7) goto end; //break; } } - if (seenOwnNotarisations == 1) { + if (seenOwnNotarisations >= 1) { BOOST_FOREACH(Notarisation& nota, notarisations) { if (GetSymbolAuthority(nota.second.symbol) == authority) if (nota.second.ccId == targetCCid) { - moms.push_back(nota.second.MoM); + tmp_moms.insert(nota.second.MoM); //fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); } } @@ -105,6 +106,10 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh return uint256(); end: + // add set to vector. Set makes sure there are no dupes included. + moms.clear(); + std::copy(tmp_moms.begin(), tmp_moms.end(), std::back_inserter(moms)); + //fprintf(stderr, "SeenOwnNotarisations.%i moms.size.%li blocks scanned.%i\n",seenOwnNotarisations, moms.size(), i); return GetMerkleRoot(moms); } @@ -138,7 +143,7 @@ int ScanNotarisationsFromHeight(int nHeight, const IsTarget f, Notarisation &fou /* On KMD */ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_t targetCCid, - const TxProof assetChainProof) + const TxProof assetChainProof, int32_t offset) { /* * Here we are given a proof generated by an assetchain A which goes from given txid to @@ -173,6 +178,9 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ kmdHeight = ScanNotarisationsFromHeight(kmdHeight, isTarget, nota); if (!kmdHeight) throw std::runtime_error("Cannot find notarisation for target inclusive of source"); + + if ( offset != 0 ) + kmdHeight += offset; // Get MoMs for kmd height and symbol std::vector moms; @@ -219,7 +227,7 @@ cont: * Takes an importTx that has proof leading to assetchain root * and extends proof to cross chain root */ -void CompleteImportTransaction(CTransaction &importTx) +void CompleteImportTransaction(CTransaction &importTx, int32_t offset) { TxProof proof; CTransaction burnTx; std::vector payouts; std::vector rawproof; if (!UnmarshalImportTx(importTx, proof, burnTx, payouts)) @@ -231,7 +239,7 @@ void CompleteImportTransaction(CTransaction &importTx) if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof)) throw std::runtime_error("Couldn't parse burnTx"); - proof = GetCrossChainProof(burnTx.GetHash(), targetSymbol.data(), targetCCid, proof); + proof = GetCrossChainProof(burnTx.GetHash(), targetSymbol.data(), targetCCid, proof, offset); importTx = MakeImportCoinTransaction(proof, burnTx, payouts); } diff --git a/src/crosschain.h b/src/crosschain.h index b3d1af9b2..9ff41eff1 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -38,8 +38,8 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx); uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeight, std::vector &moms, uint256 &destNotarisationTxid); TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_t targetCCid, - const TxProof assetChainProof); -void CompleteImportTransaction(CTransaction &importTx); + const TxProof assetChainProof,int32_t offset); +void CompleteImportTransaction(CTransaction &importTx,int32_t offset); /* On assetchain */ bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 26a613f9a..3f0f9dea8 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -175,6 +175,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "getNotarisationsForBlock", 0}, { "height_MoM", 1}, { "calc_MoM", 2}, + { "migrate_completeimporttransaction", 1}, }; class CRPCConvertTable diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 0feb5173c..c7992a953 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -137,12 +137,12 @@ UniValue MoMoMdata(const UniValue& params, bool fHelp) int kmdheight = atoi(params[1].get_str().c_str()); uint32_t ccid = atoi(params[2].get_str().c_str()); ret.push_back(Pair("coin",symbol)); - ret.push_back(Pair("kmdheight",kmdheight)); + ret.push_back(Pair("kmdheight",kmdheight-5)); ret.push_back(Pair("ccid", (int) ccid)); uint256 destNotarisationTxid; std::vector moms; - uint256 MoMoM = CalculateProofRoot(symbol, ccid, kmdheight, moms, destNotarisationTxid); + uint256 MoMoM = CalculateProofRoot(symbol, ccid, kmdheight-5, moms, destNotarisationTxid); UniValue valMoms(UniValue::VARR); for (int i=0; i 2) + throw runtime_error("migrate_completeimporttransaction importTx (offset)\n\n" "Takes a cross chain import tx with proof generated on assetchain " - "and extends proof to target chain proof root"); + "and extends proof to target chain proof root\n" + "offset is optional, use it to increase the used KMD height, use when import fails on target."); if (ASSETCHAINS_SYMBOL[0] != 0) throw runtime_error("Must be called on KMD"); @@ -289,7 +290,11 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp) if (!E_UNMARSHAL(ParseHexV(params[0], "argument 1"), ss >> importTx)) throw runtime_error("Couldn't parse importTx"); - CompleteImportTransaction(importTx); + int32_t offset = 0; + if ( params.size() == 2 ) + offset = params[1].get_int(); + + CompleteImportTransaction(importTx, offset); return HexStr(E_MARSHAL(ss << importTx)); } From 2692d48f0ca64ab8b686fcd852abdd57d50341b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Apr 2019 16:16:10 +0800 Subject: [PATCH 3903/3904] clean up some notary pay stuff. Put current LABS notaries in ERA1 ready for reset. --- src/komodo_bitcoind.h | 11 +++-------- src/main.cpp | 2 +- src/miner.cpp | 4 ++-- src/notaries_staked.h | 27 +++++++++++++++------------ 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2f9c1a8d7..ce2121da1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1855,7 +1855,7 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) // Because of reorgs we cannot use the notarized height value. // We need to basically guess here and just pay some static amount. // Has the unwanted effect of varying coin emission, but cannot be helped. - fprintf(stderr, "era.%i paying total of %lu\n",curEra, ASSETCHAINS_NOTARY_PAY[curEra]); + //fprintf(stderr, "era.%i paying total of %lu\n",curEra, ASSETCHAINS_NOTARY_PAY[curEra]); ret = ASSETCHAINS_NOTARY_PAY[curEra] / notarycount; return(ret); } @@ -1870,13 +1870,8 @@ int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *sc if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,script,len); - if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) + if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) != -2 ) { - fprintf(stderr, ">>>>>>VALID NOTARIZATION ht.%i\n",notarizedheight); - } - else - { - // This should no longer happen. Unless notaries are making actual invalid notarizations. fprintf(stderr, "<<<<<GetHeight()); - fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); + //fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); if ( notarypaycheque > 0 ) blockReward += notarypaycheque; else diff --git a/src/miner.cpp b/src/miner.cpp index f131bc90e..26269e007 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -371,7 +371,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } dPriority += (double)nValueIn * nConf; } - if ( numSN != 0 && TMP_NotarisationNotaries.size() >= numSN / 5 ) + if ( numSN != 0 && notarypubkeys[0][0] != 0 && TMP_NotarisationNotaries.size() >= numSN / 5 ) { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( TMP_NotarisationNotaries.begin(), TMP_NotarisationNotaries.end() ); @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 NotarisationNotaries = TMP_NotarisationNotaries; dPriority = 1e16; fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + //fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); } } } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 696c0f106..fb6051b2b 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,8 +23,8 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549188000, 1604233333, 1604244444}; -static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 19, 17 }; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1604244444, 1604244444, 1604244444, 1604244444}; +static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 20, 25, 19, 17 }; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = @@ -33,20 +33,23 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, // RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu + {"smk762", "029f6c1f38c4d6825acb3b4b5147f7992e943b617cdaa0f4f5f36187e239d52d5a" }, // RPy6Xj2LWrxNoEW9YyREDgBZDZZ5qURXBU + {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p + {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 + {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q + {"gcharang", "03336ca9db27cb6e882830e20dc525884e27dc94d557a5e68b972a5cbf9e8c62a8" }, // RJYiWn3FRCSSLf9Pe5RJcbrKQYosaMburP + {"computergenie", "027313dabde94fb72f823231d0a1c59fc7baa2e5b3bb2af97ca7d70aae116026b9" }, // RLabsCGxTRqJcJvz6foKuXAB61puJ2x8yt + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, // + {"SHossain", "02791f5c215b8a19c143a98e3371ff03b5613df9ac430c4a331ca55fed5761c800" }, // RKdLoHkyeorXmMtj91B1AAnAGiwsdt9MdF + {"Nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, // RRwCLPZDzpHEFJnLev4phy51e2stHRUAaU {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }, { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x From 1c4c00ff8b9c8fa9992101178f14d3587e3d04b9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Apr 2019 16:16:59 +0800 Subject: [PATCH 3904/3904] add ac_founders and ac_perc to getblocksubsidy --- src/komodo_bitcoind.h | 4 ++-- src/rpc/mining.cpp | 30 +++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ce2121da1..bb5a093d3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1224,7 +1224,6 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) return(0); int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; - txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); @@ -1242,8 +1241,9 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) else commission = 0; } } - else + else if ( pblock != 0 ) { + txn_count = pblock->vtx.size(); for (i=0; ivtx[i].vout.size(); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 2efe8d694..21ae07810 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -49,8 +49,10 @@ using namespace std; #include "komodo_defs.h" -extern int32_t ASSETCHAINS_FOUNDERS; +extern int32_t ASSETCHAINS_FOUNDERS; +uint64_t komodo_commission(const CBlock *pblock,int32_t height); +int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex); arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); /** @@ -1009,6 +1011,7 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) "\nResult:\n" "{\n" " \"miner\" : x.xxx (numeric) The mining reward amount in KMD.\n" + " \"ac_pubkey\" : x.xxx (numeric) The mining reward amount in KMD.\n" "}\n" "\nExamples:\n" + HelpExampleCli("getblocksubsidy", "1000") @@ -1019,11 +1022,32 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) int nHeight = (params.size()==1) ? params[0].get_int() : chainActive.Height(); if (nHeight < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - + + CAmount nFoundersReward = 0; CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus()); UniValue result(UniValue::VOBJ); result.push_back(Pair("miner", ValueFromAmount(nReward))); - //result.push_back(Pair("founders", ValueFromAmount(nFoundersReward))); + + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) + { + if ( ASSETCHAINS_FOUNDERS == 0 && ASSETCHAINS_COMMISSION != 0 ) + { + // ac comission chains need the block to exist to calulate the reward. + if ( nHeight <= chainActive.Height() ) + { + CBlockIndex* pblockIndex = chainActive[nHeight]; + CBlock block; + if ( komodo_blockload(block, pblockIndex) == 0 ) + nFoundersReward = komodo_commission(&block, nHeight); + } + } + else if ( ASSETCHAINS_FOUNDERS != 0 ) + { + // Assetchains founders chains have a fixed reward so can be calculated at any given height. + nFoundersReward = komodo_commission(0, nHeight); + } + result.push_back(Pair("ac_pubkey", ValueFromAmount(nFoundersReward))); + } return result; }

Jq5C-aTifz(E5Kg}P zmm<~<$1WVX>2;;kfiZw}c>&RhFi7@jM(Y(ZBxH%ODV9Ne0x=lyqbf>U=V6#_lt%Du z+Xl$_sLe7r8CiU~qElv9JdY>VZIj5ffMIAkFa#qV5@F`8hLp41J2&&4I#TX<9#0&# zBK-Q-Ka6$TaJG(+GS;#p5a%+n3XcpXLjX#VjJuTha@8XLNo;G zj_CYeL9HS!3oCyBj&P8JwKbAlwS&hgLL4S>N(X>egAo%46HpK$UAQu(6j0@kWqqvZ zwWIZhN=oGB&M1a}*x9Xj*)|z_Hk7yMwPyiTBNnny+UQ9`1 z`BRY>Y?MPch-#3n1p*?fBg{(H7MjJXJfBZQWW*$ez{!WqIo5o5&GEnHL! z?m-X-bRoMsQG;gcu}pRaMv%22-&aD5xm#y+VcB?0(5kLEIHNu0mDE;|geO2Wur3eD zR^(@(2i{pv^fpk+iavOoX)fa!1k&(kA|#$Y0HaGc))6pAaU}5~dSSKJ02`$-kzN}H zMJ##+LMi~NTs}!6tcD<<9P!YJupcM3?SUNmppKD%6cF&hOZpN2>;L>e;XnP){tJ}v z|2oprkO0&pfxt!Sz+fNK7;x0xNU~-DaVkAP^2JI*8;5b$Old=$OF3lp(|QMqdMk#A zMqMtpt9p$`Pd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ML(H?|nEp z+ntN1wPJl3*?(HE*4r*WQ^){ zuafAPBDJ*9xq4N=C>nb?K~qX>`$lgnv-o^GczIC-bw4wY{UpSM^`33pIZMVEcv}`q zKJ}gGmKZ1YZDW0T;p5|jZUe7xZ~XlAli(a7I;If$_3=rropoIZx+TFR#?5 zzf&06ui6b|RakO4JckSNv&e5b(^T9GFzQ4UtOXb%;|HJZ+zfsqjqgK|WDD-}0 zjOoltO-V&8&Utbfmzh2;XI&*R)1=vTeNcE;P9F$ZJ^Rx%14_Xy(}MJ-%f58|Erz5^ zy0Fd*`}xW1%gpEFAeYKCC!`O#$Ix$1({ejFW4u6*op0a%;LL?>+nx@@p>r)&XTJA| zA3xq%)))QGADce=DM0CXZ>X)Y=gO~-jd@+}*?Cd@!6&xkL5gu`aUmCOY0)J?aYpBr z^Oj@J80QEsu%88KFeNqOM5l6`ec$g`Dvc&7w}GQ|*o$iY&a?1;b(zLKby!Tk00000 LNkvXXu0mjfL3yYq literal 0 HcmV?d00001 diff --git a/src/gui/komodoku/board.png b/src/gui/komodoku/board.png new file mode 100644 index 0000000000000000000000000000000000000000..bd77ca419999b45f31af1dc6e91aedd4b0f53a9f GIT binary patch literal 5678 zcmeAS@N?(olHy`uVBq!ia0y~yV5|jU4mP03i^?5=K#C>Z(btiI;o6NW{t-q%zGR7O zL`iUdT1k0gQ7VIDN`6wRf@f}GdTLN=VoGJ<$y6H#2GIkaE{-7;w~|s45`LUF;Bq^t zA;G#h!G)oLAxVn2DG(xJ$)L~>k~F@M{Q-MU|kN+74koMTY6Tl7ztmwLMJ)o!OKl^U$ z_Acp(KNlC;OMPGb(5mQ>955ZVmqSZM7DiyHsQbko(uWx3jfTYH1W+nSVtMp`@j+w+V|BDHrVGdyBIgycp zse|>{kN^MeA1_$HP(t!Qe_1)7sJYT-Q19TK`{B|jM{I$qitjzNR2=QlI_X`4raI^*LDqz40|2~awwXxSpWxo89ZJ6T-G@yGywpilHk$+ literal 0 HcmV?d00001 diff --git a/src/gui/komodoku/sudoku_kmdlib.py b/src/gui/komodoku/sudoku_kmdlib.py new file mode 100644 index 000000000..a2b2aa239 --- /dev/null +++ b/src/gui/komodoku/sudoku_kmdlib.py @@ -0,0 +1,41 @@ +import platform +import os +import re +import random +from slickrpc import Proxy + + +# define function that fetchs rpc creds from .conf +def def_credentials(chain): + rpcport =''; + operating_system = platform.system() + if operating_system == 'Darwin': + ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' + elif operating_system == 'Linux': + ac_dir = os.environ['HOME'] + '/.komodo' + elif operating_system == 'Windows': + ac_dir = '%s/komodo/' % os.environ['APPDATA'] + if chain == 'KMD': + coin_config_file = str(ac_dir + '/komodo.conf') + else: + coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') + with open(coin_config_file, 'r') as f: + for line in f: + l = line.rstrip() + if re.search('rpcuser', l): + rpcuser = l.replace('rpcuser=', '') + elif re.search('rpcpassword', l): + rpcpassword = l.replace('rpcpassword=', '') + elif re.search('rpcport', l): + rpcport = l.replace('rpcport=', '') + if len(rpcport) == 0: + if chain == 'KMD': + rpcport = 7771 + else: + print("rpcport not in conf file, exiting") + print("check "+coin_config_file) + exit(1) + + return(Proxy("http://%s:%s@127.0.0.1:%d"%(rpcuser, rpcpassword, int(rpcport)))) + + From 6c49bda16bb1aefda799bd2ef6585985202cd906 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 29 Mar 2019 00:42:43 +0700 Subject: [PATCH 3453/3904] moved to subfolder --- src/gui/README.md | 27 --- src/gui/Roboto-Light.ttf | Bin 140276 -> 0 bytes src/gui/Sudoku.py | 362 --------------------------------------- src/gui/background.png | Bin 308479 -> 0 bytes src/gui/board.png | Bin 5678 -> 0 bytes src/gui/sudoku_kmdlib.py | 41 ----- 6 files changed, 430 deletions(-) delete mode 100644 src/gui/README.md delete mode 100755 src/gui/Roboto-Light.ttf delete mode 100644 src/gui/Sudoku.py delete mode 100644 src/gui/background.png delete mode 100644 src/gui/board.png delete mode 100644 src/gui/sudoku_kmdlib.py diff --git a/src/gui/README.md b/src/gui/README.md deleted file mode 100644 index 8a3778ea0..000000000 --- a/src/gui/README.md +++ /dev/null @@ -1,27 +0,0 @@ -About ------ -Komodo SudokuCC GUI - -Just solve Sudoku and earn SUDOKU coins! - -![alt text](https://i.imgur.com/std99XW.png) - -To run you need up and running SUDOKU chain daemon built from latest https://github.com/jl777/komodo/tree/FSM and started with valid for your wallet pubkey in `-pubkey=` param. - -SUDOKU chain params: -```./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc &``` - -1) install dependencies: - -``` -$ sudo apt-get install python-pygame libgnutls28-dev -$ pip install requests wheel slick-bitcoinrpc pygame -``` - -2) and then start: - -``` -$ git clone https://github.com/tonymorony/Komodoku -$ cd Komodoku -$ python Sudoku.py -``` diff --git a/src/gui/Roboto-Light.ttf b/src/gui/Roboto-Light.ttf deleted file mode 100755 index 664e1b2f9dbafbf6280305123d2df7fa0c66cee9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140276 zcmbrn2V4}#`#(N2ySGQ@=ql0$6hTlx)TlAW78`cKE(#h%K}E$9d+)tbR8+uzoQO4Q zj2dGSL;RS;Bqk<)j4_EV#x&)Y|9j?GxHHN3`~AKChqJr0ZRUCAnWxW6C?UiR8<`k7 z_e$)0yL75b==(Pa>HAaXzWv+Zu6s9|Fu(JJC~@8U_3d&k^+h}(?k(_uXJX&zW+x}p zU_$6tyk*3w@guXQADFR|5by4U*tHuqH9N45KRZiE&@5b!Ny{2DKKfqI1BCdm#4~5c zjGUZB?1%^2yMpUZV=|_vJ#<}gmykvkgic#JHg)9a-_jfMd+XzR^RYPLu-EQK)cc{{ zVC?wp9JlmYuc7`YA%=DtnW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IZx+TFR#?5 zzf&06ui6b|RakO4JckSNv&e5b(^T9GFzQ4UtOXb%;|HJZ+zfsqjqgK|WDD-}0 zjOoltO-V&8&Utbfmzh2;XI&*R)1=vTeNcE;P9F$ZJ^Rx%14_Xy(}MJ-%f58|Erz5^ zy0Fd*`}xW1%gpEFAeYKCC!`O#$Ix$1({ejFW4u6*op0a%;LL?>+nx@@p>r)&XTJA| zA3xq%)))QGADce=DM0CXZ>X)Y=gO~-jd@+}*?Cd@!6&xkL5gu`aUmCOY0)J?aYpBr z^Oj@J80QEsu%88KFeNqOM5l6`ec$g`Dvc&7w}GQ|*o$iY&a?1;b(zLKby!Tk00000 LNkvXXu0mjfL3yYq literal 0 HcmV?d00001 diff --git a/src/gui/board.png b/src/gui/board.png new file mode 100644 index 0000000000000000000000000000000000000000..bd77ca419999b45f31af1dc6e91aedd4b0f53a9f GIT binary patch literal 5678 zcmeAS@N?(olHy`uVBq!ia0y~yV5|jU4mP03i^?5=K#C>Z(btiI;o6NW{t-q%zGR7O zL`iUdT1k0gQ7VIDN`6wRf@f}GdTLN=VoGJ<$y6H#2GIkaE{-7;w~|s45`LUF;Bq^t zA;G#h!G)oLAxVn2DG(xJ$)L~>k~F@M{Q-MU|kN+74koMTY6Tl7ztmwLMJ)o!OKl^U$ z_Acp(KNlC;OMPGb(5mQ>955ZVmqSZM7DiyHsQbko(uWx3jfTYH1W+nSVtMp`@j+w+V|BDHrVGdyBIgycp zse|>{kN^MeA1_$HP(t!Qe_1)7sJYT-Q19TK`{B|jM{I$qitjzNR2=QlI_X`4raI^*LDqz40|2~awwXxSpWxo89ZJ6T-G@yGywpilHk$+ literal 0 HcmV?d00001 diff --git a/src/gui/sudoku_kmdlib.py b/src/gui/sudoku_kmdlib.py new file mode 100644 index 000000000..a2b2aa239 --- /dev/null +++ b/src/gui/sudoku_kmdlib.py @@ -0,0 +1,41 @@ +import platform +import os +import re +import random +from slickrpc import Proxy + + +# define function that fetchs rpc creds from .conf +def def_credentials(chain): + rpcport =''; + operating_system = platform.system() + if operating_system == 'Darwin': + ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo' + elif operating_system == 'Linux': + ac_dir = os.environ['HOME'] + '/.komodo' + elif operating_system == 'Windows': + ac_dir = '%s/komodo/' % os.environ['APPDATA'] + if chain == 'KMD': + coin_config_file = str(ac_dir + '/komodo.conf') + else: + coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf') + with open(coin_config_file, 'r') as f: + for line in f: + l = line.rstrip() + if re.search('rpcuser', l): + rpcuser = l.replace('rpcuser=', '') + elif re.search('rpcpassword', l): + rpcpassword = l.replace('rpcpassword=', '') + elif re.search('rpcport', l): + rpcport = l.replace('rpcport=', '') + if len(rpcport) == 0: + if chain == 'KMD': + rpcport = 7771 + else: + print("rpcport not in conf file, exiting") + print("check "+coin_config_file) + exit(1) + + return(Proxy("http://%s:%s@127.0.0.1:%d"%(rpcuser, rpcpassword, int(rpcport)))) + + From f4150ce014a22d6b5b24ed1a951b81c8f1c5f6a9 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 29 Mar 2019 00:40:19 +0700 Subject: [PATCH 3452/3904] fixed path --- src/gui/komodoku/README.md | 27 +++ src/gui/komodoku/Roboto-Light.ttf | Bin 0 -> 140276 bytes src/gui/komodoku/Sudoku.py | 362 ++++++++++++++++++++++++++++++ src/gui/komodoku/background.png | Bin 0 -> 308479 bytes src/gui/komodoku/board.png | Bin 0 -> 5678 bytes src/gui/komodoku/sudoku_kmdlib.py | 41 ++++ 6 files changed, 430 insertions(+) create mode 100644 src/gui/komodoku/README.md create mode 100755 src/gui/komodoku/Roboto-Light.ttf create mode 100644 src/gui/komodoku/Sudoku.py create mode 100644 src/gui/komodoku/background.png create mode 100644 src/gui/komodoku/board.png create mode 100644 src/gui/komodoku/sudoku_kmdlib.py diff --git a/src/gui/komodoku/README.md b/src/gui/komodoku/README.md new file mode 100644 index 000000000..8a3778ea0 --- /dev/null +++ b/src/gui/komodoku/README.md @@ -0,0 +1,27 @@ +About +----- +Komodo SudokuCC GUI + +Just solve Sudoku and earn SUDOKU coins! + +![alt text](https://i.imgur.com/std99XW.png) + +To run you need up and running SUDOKU chain daemon built from latest https://github.com/jl777/komodo/tree/FSM and started with valid for your wallet pubkey in `-pubkey=` param. + +SUDOKU chain params: +```./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc &``` + +1) install dependencies: + +``` +$ sudo apt-get install python-pygame libgnutls28-dev +$ pip install requests wheel slick-bitcoinrpc pygame +``` + +2) and then start: + +``` +$ git clone https://github.com/tonymorony/Komodoku +$ cd Komodoku +$ python Sudoku.py +``` diff --git a/src/gui/komodoku/Roboto-Light.ttf b/src/gui/komodoku/Roboto-Light.ttf new file mode 100755 index 0000000000000000000000000000000000000000..664e1b2f9dbafbf6280305123d2df7fa0c66cee9 GIT binary patch literal 140276 zcmbrn2V4}#`#(N2ySGQ@=ql0$6hTlx)TlAW78`cKE(#h%K}E$9d+)tbR8+uzoQO4Q zj2dGSL;RS;Bqk<)j4_EV#x&)Y|9j?GxHHN3`~AKChqJr0ZRUCAnWxW6C?UiR8<`k7 z_e$)0yL75b==(Pa>HAaXzWv+Zu6s9|Fu(JJC~@8U_3d&k^+h}(?k(_uXJX&zW+x}p zU_$6tyk*3w@guXQADFR|5by4U*tHuqH9N45KRZiE&@5b!Ny{2DKKfqI1BCdm#4~5c zjGUZB?1%^2yMpUZV=|_vJ#<}gmykvkgic#JHg)9a-_jfMd+XzR^RYPLu-EQK)cc{{ zVC?wp9JlmYuc7`YA%=DtnWILIdYfHFdk4{e@c5BASxOuB4A*mTf8d0X<5PEq-8K=r zD+&GImX$dfO-ju=*6;OL+}Z`t#1f7hlwlF`J{s=Y`ZrS74krk? z_{6OV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